From: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Date: 2020-05-12 21:11:20
The Ethernet TX performance has been historically bad on Meson8b and
Meson8m2 SoCs because high packet loss was seen. I found out that this
was related (yet again) to the RGMII TX delay configuration.
In the process of discussing the big picture (and not just a single
patch) [0] with Andrew I discovered that the IP block behind the
dwmac-meson8b driver actually seems to support the configuration of the
RGMII RX delay (at least on the Meson8b SoC generation).
Since I sent the first RFC I got additional documentation from Jianxin
(many thanks!). Also I have discovered some more interesting details:
- Meson8b Odroid-C1 requires an RX delay (by either the PHY or the MAC)
Based on the vendor u-boot code (not upstream) I assume that it will
be the same for all Meson8b and Meson8m2 boards
- Khadas VIM2 seems to have the RX delay built into the PCB trace
length. When I enable the RX delay on the PHY or MAC I can't get any
data through. I expect that we will have the same situation on all
GXBB, GXM, AXG, G12A, G12B and SM1 boards. Further clarification is
needed here though (since I can't visually see these lengthened
traces on the PCB). This will be done before sending patches for
these boards.
Dependencies for this series:
There is a soft dependency for patch #2 on commit f22531438ff42c
"dt-bindings: net: dwmac: increase 'maxItems' for 'clocks',
'clock-names' properties" which is currently in Rob's -next tree.
That commit is needed to make the dt-bindings schema validation
pass for patch #2. That patch has been for ~4 weeks in Robs tree,
so I assume that is not going to be dropped.
Changes since RFC v2 at [2]:
- dropped $ref: /schemas/types.yaml#definitions/uint32 from the
"amlogic,rx-delay-ns" in patch #1 ("Don't need to define the
type when in standard units." says Rob - thanks, I learned
something new). Also use "default: 0" for for this property
instead of explaining it in the description text.
- added a note to the cover-letter about a hidden dependency for
dt-binding schema validation in patch #2
- Added Andrew's Reviewed-by to patches 1-7. Thank you again for
the quick and detailed reviews, I appreciate this!
- error out if the (optional) timing-adjustment clock is missing
but we're asked to enable the RGMII RX delay. The MAC won't
work in this specific case and either the RX delay has to be
provided by the PHY or the timing-adjustment clock has to be
added.
- dropped the dts patches (#9-11) which were only added to give
an overview how this is going to be used. those will be sent
separately
- dropped the RFC prefix
Changes since RFC v1 at [1]:
- add support for the timing adjustment clock input (dt-bindings and
in the driver) thanks to the input from the unnamed Ethernet engineer
at Amlogic. This is the missing link between the fclk_div2 clock and
the Ethernet controller on Meson8b (no traffic would flow if that
clock was disabled)
- add support fot the amlogic,rx-delay-ns property. The only supported
values so far are 0ns and 2ns. The registers seem to allow more
precise timing adjustments, but I could not make that work so far.
- add more register documentation (for the new RX delay bits) and
unified the placement of existing register documentation. Again,
thanks to Jianxin and the unnamed Ethernet engineer at Amlogic
- DO NOT MERGE: .dts patches to show the conversion of the Meson8b
and Meson8m2 boards to "rgmii-id". I didn't have time for all arm64
patches yet, but these will switch to phy-mode = "rgmii-txid" with
amlogic,rx-delay-ns = <0> (because the delay seems to be provided by
the PCB trace length).
[0] https://patchwork.kernel.org/patch/11309891/
[1] https://patchwork.kernel.org/cover/11310719/
[2] https://patchwork.kernel.org/cover/11518257/
Martin Blumenstingl (8):
dt-bindings: net: meson-dwmac: Add the amlogic,rx-delay-ns property
dt-bindings: net: dwmac-meson: Document the "timing-adjustment" clock
net: stmmac: dwmac-meson8b: use FIELD_PREP instead of open-coding it
net: stmmac: dwmac-meson8b: Move the documentation for the TX delay
net: stmmac: dwmac-meson8b: Add the PRG_ETH0_ADJ_* bits
net: stmmac: dwmac-meson8b: Fetch the "timing-adjustment" clock
net: stmmac: dwmac-meson8b: Make the clock enabling code re-usable
net: stmmac: dwmac-meson8b: add support for the RX delay configuration
.../bindings/net/amlogic,meson-dwmac.yaml | 23 ++-
.../ethernet/stmicro/stmmac/dwmac-meson8b.c | 146 ++++++++++++++----
2 files changed, 134 insertions(+), 35 deletions(-)
--
2.26.2
From: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Date: 2020-05-12 21:11:23
The PRG_ETHERNET registers on Meson8b and newer SoCs can add an RX
delay. Add a property with the known supported values so it can be
configured according to the board layout.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
.../bindings/net/amlogic,meson-dwmac.yaml | 13 +++++++++++++
1 file changed, 13 insertions(+)
@@ -67,6 +67,19 @@ allOf:PHY and MAC are adding a delay).Any configuration is ignored when the phy-mode is set to "rmii".+amlogic,rx-delay-ns:+enum:+-0+-2+default:0+description:+The internal RGMII RX clock delay (provided by this IP block) in+nanoseconds. When phy-mode is set to "rgmii" then the RX delay+should be explicitly configured. When the phy-mode is set to+either "rgmii-id" or "rgmii-rxid" the RX clock delay is already+provided by the PHY. Any configuration is ignored when the+phy-mode is set to "rmii".+properties:compatible:additionalItems:true
From: Pavel Machek <hidden> Date: 2020-05-24 21:28:50
On Tue 2020-05-12 23:10:56, Martin Blumenstingl wrote:
quoted hunk
The PRG_ETHERNET registers on Meson8b and newer SoCs can add an RX
delay. Add a property with the known supported values so it can be
configured according to the board layout.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
.../bindings/net/amlogic,meson-dwmac.yaml | 13 +++++++++++++
1 file changed, 13 insertions(+)
On Tue 2020-05-12 23:10:56, Martin Blumenstingl wrote:
quoted
The PRG_ETHERNET registers on Meson8b and newer SoCs can add an RX
delay. Add a property with the known supported values so it can be
configured according to the board layout.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
.../bindings/net/amlogic,meson-dwmac.yaml | 13 +++++++++++++
1 file changed, 13 insertions(+)
@@ -67,6 +67,19 @@ allOf:PHY and MAC are adding a delay).Any configuration is ignored when the phy-mode is set to "rmii".+amlogic,rx-delay-ns:+enum:
Is it likely other MACs will need rx-delay property, too? Should we get rid of the amlogic,
prefix?
Yes, there are several MAC bindings that already define a delay property:
Documentation/devicetree/bindings/net/allwinner,sun8i-a83t-emac.yaml:
allwinner,rx-delay-ps:
Documentation/devicetree/bindings/net/allwinner,sun8i-a83t-emac.yaml:
allwinner,rx-delay-ps:
Documentation/devicetree/bindings/net/apm-xgene-enet.txt:- rx-delay:
Delay value for RGMII bridge RX clock.
Documentation/devicetree/bindings/net/apm-xgene-enet.txt: rx-delay
= <2>;
Documentation/devicetree/bindings/net/cavium-pip.txt:- rx-delay: Delay
value for RGMII receive clock. Optional. Disabled if 0.
Documentation/devicetree/bindings/net/mediatek-dwmac.txt:-
mediatek,rx-delay-ps: RX clock delay macro value. Default is 0.
Documentation/devicetree/bindings/net/mediatek-dwmac.txt:
mediatek,rx-delay-ps = <1530>;
standardizing on rx-delay-ps and tx-delay-ps would make sense since that
is the lowest resolution and the property would be correctly named with
an unit in the name.
--
Florian
From: Pavel Machek <hidden> Date: 2020-05-25 09:07:23
Hi!
quoted
On Tue 2020-05-12 23:10:56, Martin Blumenstingl wrote:
quoted
The PRG_ETHERNET registers on Meson8b and newer SoCs can add an RX
delay. Add a property with the known supported values so it can be
configured according to the board layout.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
.../bindings/net/amlogic,meson-dwmac.yaml | 13 +++++++++++++
1 file changed, 13 insertions(+)
@@ -67,6 +67,19 @@ allOf:PHY and MAC are adding a delay).Any configuration is ignored when the phy-mode is set to "rmii".+amlogic,rx-delay-ns:+enum:
Is it likely other MACs will need rx-delay property, too? Should we get rid of the amlogic,
prefix?
Yes, there are several MAC bindings that already define a delay property:
Documentation/devicetree/bindings/net/allwinner,sun8i-a83t-emac.yaml:
allwinner,rx-delay-ps:
Documentation/devicetree/bindings/net/allwinner,sun8i-a83t-emac.yaml:
allwinner,rx-delay-ps:
Documentation/devicetree/bindings/net/apm-xgene-enet.txt:- rx-delay:
Delay value for RGMII bridge RX clock.
Documentation/devicetree/bindings/net/apm-xgene-enet.txt: rx-delay
= <2>;
Documentation/devicetree/bindings/net/cavium-pip.txt:- rx-delay: Delay
value for RGMII receive clock. Optional. Disabled if 0.
Documentation/devicetree/bindings/net/mediatek-dwmac.txt:-
mediatek,rx-delay-ps: RX clock delay macro value. Default is 0.
Documentation/devicetree/bindings/net/mediatek-dwmac.txt:
mediatek,rx-delay-ps = <1530>;
standardizing on rx-delay-ps and tx-delay-ps would make sense since that
is the lowest resolution and the property would be correctly named with
an unit in the name.
From: Andrew Lunn <andrew@lunn.ch> Date: 2020-05-25 13:57:38
quoted
standardizing on rx-delay-ps and tx-delay-ps would make sense since that
is the lowest resolution and the property would be correctly named with
an unit in the name.
Seems like similar patch is already being reviewed from Dan Murphy (?)
from TI.
Dan is working on the PHY side. But there is probably code which can
be shared.
One question to consider, do we want the same properties names for MAC
and PHY, or do we want to make them different, to avoid confusion?
Andrew
From: Pavel Machek <hidden> Date: 2020-05-25 20:17:51
On Mon 2020-05-25 15:57:28, Andrew Lunn wrote:
quoted
quoted
standardizing on rx-delay-ps and tx-delay-ps would make sense since that
is the lowest resolution and the property would be correctly named with
an unit in the name.
Seems like similar patch is already being reviewed from Dan Murphy (?)
from TI.
Dan is working on the PHY side. But there is probably code which can
be shared.
One question to consider, do we want the same properties names for MAC
and PHY, or do we want to make them different, to avoid confusion?
From: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Date: 2020-05-12 21:11:28
Use FIELD_PREP() to shift a value to the correct offset based on a
bitmask instead of open-coding the logic.
No functional changes.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
@@ -32,7 +33,6 @@#define PRG_ETH0_CLK_M250_SEL_SHIFT 4#define PRG_ETH0_CLK_M250_SEL_MASK GENMASK(4, 4)-#define PRG_ETH0_TXDLY_SHIFT 5#define PRG_ETH0_TXDLY_MASK GENMASK(6, 5)/* divider for the result of m250_sel */
@@ -262,7 +262,8 @@ static int meson8b_init_prg_eth(struct meson8b_dwmac *dwmac)PRG_ETH0_INVERTED_RMII_CLK,0);meson8b_dwmac_mask_bits(dwmac,PRG_ETH0,PRG_ETH0_TXDLY_MASK,-tx_dly_val<<PRG_ETH0_TXDLY_SHIFT);+FIELD_PREP(PRG_ETH0_TXDLY_MASK,+tx_dly_val));/* Configure the 125MHz RGMII TX clock, the IP block changes*theoutputautomatically(=withoutushavingtoconfigure
From: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Date: 2020-05-12 21:11:33
The PRG_ETHERNET registers have a built-in timing adjustment circuit
which can provide the RX delay in RGMII mode. This is driven by an
external (to this IP, but internal to the SoC) clock input. Fetch this
clock as optional (even though it's there on all supported SoCs) since
we just learned about it and existing .dtbs don't specify it.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c | 8 ++++++++
1 file changed, 8 insertions(+)
From: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Date: 2020-05-12 21:11:35
The timing adjustment clock will need similar logic as the RGMII clock:
It has to be enabled in the driver conditionally and when the driver is
unloaded it should be disabled again. Extract the existing code for the
RGMII clock into a new function so it can be re-used.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
.../ethernet/stmicro/stmmac/dwmac-meson8b.c | 23 +++++++++++++++----
1 file changed, 18 insertions(+), 5 deletions(-)
@@ -266,6 +266,22 @@ static int meson_axg_set_phy_mode(struct meson8b_dwmac *dwmac)return0;}+staticintmeson8b_devm_clk_prepare_enable(structmeson8b_dwmac*dwmac,+structclk*clk)+{+intret;++ret=clk_prepare_enable(clk);+if(ret)+returnret;++devm_add_action_or_reset(dwmac->dev,+(void(*)(void*))clk_disable_unprepare,+dwmac->rgmii_tx_clk);++return0;+}+staticintmeson8b_init_prg_eth(structmeson8b_dwmac*dwmac){intret;
@@ -299,16 +315,13 @@ static int meson8b_init_prg_eth(struct meson8b_dwmac *dwmac)returnret;}-ret=clk_prepare_enable(dwmac->rgmii_tx_clk);+ret=meson8b_devm_clk_prepare_enable(dwmac,+dwmac->rgmii_tx_clk);if(ret){dev_err(dwmac->dev,"failed to enable the RGMII TX clock\n");returnret;}--devm_add_action_or_reset(dwmac->dev,-(void(*)(void*))clk_disable_unprepare,-dwmac->rgmii_tx_clk);break;casePHY_INTERFACE_MODE_RMII:
From: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Date: 2020-05-12 21:11:39
The PRG_ETHERNET registers can add an RX delay in RGMII mode. This
requires an internal re-timing circuit whose input clock is called
"timing adjustment clock". Document this clock input so the clock can be
enabled as needed.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
Rob, there is a soft dependency for this patch on commit f22531438ff42c
"dt-bindings: net: dwmac: increase 'maxItems' for 'clocks',
'clock-names' properties" which is currently in your dt-next branch.
That commit is needed to make the dt-bindings schema validation pass,
because it increases the maximum number allowed clocks for anything
that extends "snps,dwmac" from three to five (here I need four clocks).
.../devicetree/bindings/net/amlogic,meson-dwmac.yaml | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
@@ -40,18 +40,22 @@ allOf:then:properties:clocks:+minItems:3+maxItems:4items:-description:GMAC main clock-description:First parent clock of the internal mux-description:Second parent clock of the internal mux+-description:The clock which drives the timing adjustment logicclock-names:minItems:3-maxItems:3+maxItems:4items:-const:stmmaceth-const:clkin0-const:clkin1+-const:timing-adjustmentamlogic,tx-delay-ns:$ref:/schemas/types.yaml#definitions/uint32
From: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Date: 2020-05-12 21:11:46
Configure the PRG_ETH0_ADJ_* bits to enable or disable the RX delay
based on the various RGMII PHY modes. For now the only supported RX
delay settings are:
- disabled, use for example for phy-mode "rgmii-id"
- 0ns - this is treated identical to "disabled", used for example on
boards where the PHY provides 2ns TX delay and the PCB trace length
already adds 2ns RX delay
- 2ns - for whenever the PHY cannot add the RX delay and the traces on
the PCB don't add any RX delay
Disabling the RX delay (in case u-boot enables it, which is the case
for example on Meson8b Odroid-C1) simply means that PRG_ETH0_ADJ_ENABLE,
PRG_ETH0_ADJ_SETUP, PRG_ETH0_ADJ_DELAY and PRG_ETH0_ADJ_SKEW should be
disabled (just disabling PRG_ETH0_ADJ_ENABLE may be enough, since that
disables the whole re-timing logic - but I find it makes more sense to
clear the other bits as well since they depend on that setting).
u-boot on Odroid-C1 uses the following steps to enable a 2ns RX delay:
- enabling enabling the timing adjustment clock
- enabling the timing adjustment logic by setting PRG_ETH0_ADJ_ENABLE
- setting the PRG_ETH0_ADJ_SETUP bit
The documentation for the PRG_ETH0_ADJ_DELAY and PRG_ETH0_ADJ_SKEW
registers indicates that we can even set different RX delays. However,
I could not find out how this works exactly, so for now we only support
a 2ns RX delay using the exact same way that Odroid-C1's u-boot does.
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
.../ethernet/stmicro/stmmac/dwmac-meson8b.c | 85 ++++++++++++++-----
1 file changed, 62 insertions(+), 23 deletions(-)
@@ -284,25 +285,64 @@ static int meson8b_devm_clk_prepare_enable(struct meson8b_dwmac *dwmac,staticintmeson8b_init_prg_eth(structmeson8b_dwmac*dwmac){+u32tx_dly_config,rx_dly_config,delay_config;intret;-u8tx_dly_val=0;++tx_dly_config=FIELD_PREP(PRG_ETH0_TXDLY_MASK,+dwmac->tx_delay_ns>>1);++if(dwmac->rx_delay_ns==2)+rx_dly_config=PRG_ETH0_ADJ_ENABLE|PRG_ETH0_ADJ_SETUP;+else+rx_dly_config=0;switch(dwmac->phy_mode){casePHY_INTERFACE_MODE_RGMII:+delay_config=tx_dly_config|rx_dly_config;+break;casePHY_INTERFACE_MODE_RGMII_RXID:-tx_dly_val=dwmac->tx_delay_ns>>1;-/* fall through */--casePHY_INTERFACE_MODE_RGMII_ID:+delay_config=tx_dly_config;+break;casePHY_INTERFACE_MODE_RGMII_TXID:+delay_config=rx_dly_config;+break;+casePHY_INTERFACE_MODE_RGMII_ID:+casePHY_INTERFACE_MODE_RMII:+delay_config=0;+break;+default:+dev_err(dwmac->dev,"unsupported phy-mode %s\n",+phy_modes(dwmac->phy_mode));+return-EINVAL;+};++if(rx_dly_config&PRG_ETH0_ADJ_ENABLE){+if(!dwmac->timing_adj_clk){+dev_err(dwmac->dev,+"The timing-adjustment clock is mandatory for the RX delay re-timing\n");+return-EINVAL;+}++/* The timing adjustment logic is driven by a separate clock */+ret=meson8b_devm_clk_prepare_enable(dwmac,+dwmac->timing_adj_clk);+if(ret){+dev_err(dwmac->dev,+"Failed to enable the timing-adjustment clock\n");+returnret;+}+}++meson8b_dwmac_mask_bits(dwmac,PRG_ETH0,PRG_ETH0_TXDLY_MASK|+PRG_ETH0_ADJ_ENABLE|PRG_ETH0_ADJ_SETUP|+PRG_ETH0_ADJ_DELAY|PRG_ETH0_ADJ_SKEW,+delay_config);++if(phy_interface_mode_is_rgmii(dwmac->phy_mode)){/* only relevant for RMII mode -> disable in RGMII mode */meson8b_dwmac_mask_bits(dwmac,PRG_ETH0,PRG_ETH0_INVERTED_RMII_CLK,0);-meson8b_dwmac_mask_bits(dwmac,PRG_ETH0,PRG_ETH0_TXDLY_MASK,-FIELD_PREP(PRG_ETH0_TXDLY_MASK,-tx_dly_val));-/* Configure the 125MHz RGMII TX clock, the IP block changes*theoutputautomatically(=withoutushavingtoconfigure*aregister)basedontheline-speed(125MHzforGbitspeeds,
@@ -322,24 +362,11 @@ static int meson8b_init_prg_eth(struct meson8b_dwmac *dwmac)"failed to enable the RGMII TX clock\n");returnret;}-break;--casePHY_INTERFACE_MODE_RMII:+}else{/* invert internal clk_rmii_i to generate 25/2.5 tx_rx_clk */meson8b_dwmac_mask_bits(dwmac,PRG_ETH0,PRG_ETH0_INVERTED_RMII_CLK,PRG_ETH0_INVERTED_RMII_CLK);--/* TX clock delay cannot be configured in RMII mode */-meson8b_dwmac_mask_bits(dwmac,PRG_ETH0,PRG_ETH0_TXDLY_MASK,-0);--break;--default:-dev_err(dwmac->dev,"unsupported phy-mode %s\n",-phy_modes(dwmac->phy_mode));-return-EINVAL;}/* enable TX_CLK and PHY_REF_CLK generator */
@@ -394,6 +421,18 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)&dwmac->tx_delay_ns))dwmac->tx_delay_ns=2;+/* use 0ns as fallback since this is what most boards actually use */+if(of_property_read_u32(pdev->dev.of_node,"amlogic,rx-delay-ns",+&dwmac->rx_delay_ns))+dwmac->rx_delay_ns=0;++if(dwmac->rx_delay_ns!=0&&dwmac->rx_delay_ns!=2){+dev_err(&pdev->dev,+"The only allowed RX delays values are: 0ns, 2ns");+ret=-EINVAL;+gotoerr_remove_config_dt;+}+dwmac->timing_adj_clk=devm_clk_get_optional(dwmac->dev,"timing-adjustment");if(IS_ERR(dwmac->timing_adj_clk)){
From: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Date: 2020-05-12 21:11:54
Move the documentation for the TX delay above the PRG_ETH0_TXDLY_MASK
definition. Future commits will add more registers also with
documentation above their register bit definitions. Move the existing
comment so it will be consistent with the upcoming changes.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
From: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Date: 2020-05-12 21:12:00
The PRG_ETH0_ADJ_* are used for applying the RGMII RX delay. The public
datasheets only have very limited description for these registers, but
Jianxin Pan provided more detailed documentation from an (unnamed)
Amlogic engineer. Add the PRG_ETH0_ADJ_* bits along with the improved
description.
Suggested-by: Jianxin Pan <redacted>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
.../ethernet/stmicro/stmmac/dwmac-meson8b.c | 21 +++++++++++++++++++
1 file changed, 21 insertions(+)
@@ -48,6 +48,27 @@#define PRG_ETH0_INVERTED_RMII_CLK BIT(11)#define PRG_ETH0_TX_AND_PHY_REF_CLK BIT(12)+/* Bypass (= 0, the signal from the GPIO input directly connects to the+*internalsampling)orenable(=1)theinternallogicforRXENandRXD[3:0]+*timingtuning.+*/+#define PRG_ETH0_ADJ_ENABLE BIT(13)+/* Controls whether the RXEN and RXD[3:0] signals should be aligned with the+*inputRXrising/fallingedgeandsenttotheEthernetinternals.Thissets+*theautomaticallydelayandskewautomatically(internally).+*/+#define PRG_ETH0_ADJ_SETUP BIT(14)+/* An internal counter based on the "timing-adjustment" clock. The counter is+*clearedonboth,thefallingandrisingedgeoftheRX_CLK.Thisselectsthe+*delay(=thecountervalue)whentostartsamplingRXENandRXD[3:0].+*/+#define PRG_ETH0_ADJ_DELAY GENMASK(19, 15)+/* Adjusts the skew between each bit of RXEN and RXD[3:0]. If a signal has a+*largeinputdelay,thebitforthatsignal(RXEN=bit0,RXD[3]=bit1,+*...)canbeconfiguredtobe1tocompensateforadelayofabout1ns.+*/+#define PRG_ETH0_ADJ_SKEW GENMASK(24, 20)+#define MUX_CLK_NUM_PARENTS 2structmeson8b_dwmac;
From: David Miller <davem@davemloft.net> Date: 2020-05-13 19:23:43
From: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Date: Tue, 12 May 2020 23:10:55 +0200
The Ethernet TX performance has been historically bad on Meson8b and
Meson8m2 SoCs because high packet loss was seen. I found out that this
was related (yet again) to the RGMII TX delay configuration.
In the process of discussing the big picture (and not just a single
patch) [0] with Andrew I discovered that the IP block behind the
dwmac-meson8b driver actually seems to support the configuration of the
RGMII RX delay (at least on the Meson8b SoC generation).
Since I sent the first RFC I got additional documentation from Jianxin
(many thanks!). Also I have discovered some more interesting details:
- Meson8b Odroid-C1 requires an RX delay (by either the PHY or the MAC)
Based on the vendor u-boot code (not upstream) I assume that it will
be the same for all Meson8b and Meson8m2 boards
- Khadas VIM2 seems to have the RX delay built into the PCB trace
length. When I enable the RX delay on the PHY or MAC I can't get any
data through. I expect that we will have the same situation on all
GXBB, GXM, AXG, G12A, G12B and SM1 boards. Further clarification is
needed here though (since I can't visually see these lengthened
traces on the PCB). This will be done before sending patches for
these boards.