diff mbox series

[v2,net-next,2/9] net: enetc: report mm tx-active based on tx-enabled and verify-status

Message ID 20230418111459.811553-3-vladimir.oltean@nxp.com (mailing list archive)
State Accepted
Commit 153b5b1d030de3f94ecac4eec73854e4710ca6ba
Delegated to: Netdev Maintainers
Headers show
Series ethtool mm API consolidation | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 21 this patch: 21
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 18 this patch: 18
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 21 this patch: 21
netdev/checkpatch warning WARNING: line length of 87 exceeds 80 columns WARNING: line length of 89 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Vladimir Oltean April 18, 2023, 11:14 a.m. UTC
The MMCSR register contains 2 fields with overlapping meaning:

- LPA (Local preemption active):
This read-only status bit indicates whether preemption is active for
this port. This bit will be set if preemption is both enabled and has
completed the verification process.
- TXSTS (Merge status):
This read-only status field provides the state of the MAC Merge sublayer
transmit status as defined in IEEE Std 802.3-2018 Clause 99.
00 Transmit preemption is inactive
01 Transmit preemption is active
10 Reserved
11 Reserved

However none of these 2 fields offer reliable reporting to software.

When connecting ENETC to a link partner which is not capable of Frame
Preemption, the expectation is that ENETC's verification should fail
(VSTS=4) and its MM TX direction should be inactive (LPA=0, TXSTS=00)
even though the MM TX is enabled (ME=1). But surprise, the LPA bit of
MMCSR stays set even if VSTS=4 and ME=1.

OTOH, the TXSTS field has the opposite problem. I cannot get its value
to change from 0, even when connecting to a link partner capable of
frame preemption, which does respond to its verification frames (ME=1
and VSTS=3, "SUCCEEDED").

The only option with such buggy hardware seems to be to reimplement the
formula for calculating tx-active in software, which is for tx-enabled
to be true, and for the verify-status to be either SUCCEEDED, or
DISABLED.

Without reliable tx-active reporting, we have no good indication when
to commit the preemptible traffic classes to hardware, which makes it
possible (but not desirable) to send preemptible traffic to a link
partner incapable of receiving it. However, currently we do not have the
logic to wait for TX to be active yet, so the impact is limited.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
v1->v2: patch is new

 drivers/net/ethernet/freescale/enetc/enetc_ethtool.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Simon Horman April 20, 2023, 2:40 p.m. UTC | #1
On Tue, Apr 18, 2023 at 02:14:52PM +0300, Vladimir Oltean wrote:
> The MMCSR register contains 2 fields with overlapping meaning:
> 
> - LPA (Local preemption active):
> This read-only status bit indicates whether preemption is active for
> this port. This bit will be set if preemption is both enabled and has
> completed the verification process.
> - TXSTS (Merge status):
> This read-only status field provides the state of the MAC Merge sublayer
> transmit status as defined in IEEE Std 802.3-2018 Clause 99.
> 00 Transmit preemption is inactive
> 01 Transmit preemption is active
> 10 Reserved
> 11 Reserved
> 
> However none of these 2 fields offer reliable reporting to software.
> 
> When connecting ENETC to a link partner which is not capable of Frame
> Preemption, the expectation is that ENETC's verification should fail
> (VSTS=4) and its MM TX direction should be inactive (LPA=0, TXSTS=00)
> even though the MM TX is enabled (ME=1). But surprise, the LPA bit of
> MMCSR stays set even if VSTS=4 and ME=1.
> 
> OTOH, the TXSTS field has the opposite problem. I cannot get its value
> to change from 0, even when connecting to a link partner capable of
> frame preemption, which does respond to its verification frames (ME=1
> and VSTS=3, "SUCCEEDED").
> 
> The only option with such buggy hardware seems to be to reimplement the
> formula for calculating tx-active in software, which is for tx-enabled
> to be true, and for the verify-status to be either SUCCEEDED, or
> DISABLED.
> 
> Without reliable tx-active reporting, we have no good indication when
> to commit the preemptible traffic classes to hardware, which makes it
> possible (but not desirable) to send preemptible traffic to a link
> partner incapable of receiving it. However, currently we do not have the
> logic to wait for TX to be active yet, so the impact is limited.
> 
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>

Reviewed-by: Simon Horman <simon.horman@corigine.com>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
index ee1ea71fe79e..deb674752851 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
@@ -976,7 +976,9 @@  static int enetc_get_mm(struct net_device *ndev, struct ethtool_mm_state *state)
 	lafs = ENETC_MMCSR_GET_LAFS(val);
 	state->rx_min_frag_size = ethtool_mm_frag_size_add_to_min(lafs);
 	state->tx_enabled = !!(val & ENETC_MMCSR_LPE); /* mirror of MMCSR_ME */
-	state->tx_active = !!(val & ENETC_MMCSR_LPA);
+	state->tx_active = state->tx_enabled &&
+			   (state->verify_status == ETHTOOL_MM_VERIFY_STATUS_SUCCEEDED ||
+			    state->verify_status == ETHTOOL_MM_VERIFY_STATUS_DISABLED);
 	state->verify_enabled = !(val & ENETC_MMCSR_VDIS);
 	state->verify_time = ENETC_MMCSR_GET_VT(val);
 	/* A verifyTime of 128 ms would exceed the 7 bit width