diff mbox series

[v7,net-next,8/8] selftests: forwarding: ethtool_mm: support devices with higher rx-min-frag-size

Message ID 20231201135802.28139-9-rogerq@kernel.org (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: ethernet: am65-cpsw: Add mqprio, frame pre-emption & coalescing | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors;
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: 8 this patch: 8
netdev/cc_maintainers warning 5 maintainers not CCed: idosch@nvidia.com shuah@kernel.org linux-kselftest@vger.kernel.org razor@blackwall.org liuhangbin@gmail.com
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success net selftest script(s) already in Makefile
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch warning WARNING: line length of 96 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Roger Quadros Dec. 1, 2023, 1:58 p.m. UTC
From: Vladimir Oltean <vladimir.oltean@nxp.com>

Some devices have errata due to which they cannot report ETH_ZLEN (60)
in the rx-min-frag-size. This was foreseen of course, and lldpad has
logic that when we request it to advertise addFragSize 0, it will round
it up to the lowest value that is _actually_ supported by the hardware.

The problem is that the selftest expects lldpad to report back to us the
same value as we requested.

Make the selftest smarter by figuring out on its own what is a
reasonable value to expect.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Roger Quadros <rogerq@kernel.org>
---
 .../selftests/net/forwarding/ethtool_mm.sh    | 37 ++++++++++++++++++-
 1 file changed, 35 insertions(+), 2 deletions(-)

Changelog:

v7: initial commit

Comments

Vladimir Oltean Dec. 4, 2023, 11:13 a.m. UTC | #1
On Fri, Dec 01, 2023 at 03:58:02PM +0200, Roger Quadros wrote:
> From: Vladimir Oltean <vladimir.oltean@nxp.com>
> 
> Some devices have errata due to which they cannot report ETH_ZLEN (60)
> in the rx-min-frag-size. This was foreseen of course, and lldpad has
> logic that when we request it to advertise addFragSize 0, it will round
> it up to the lowest value that is _actually_ supported by the hardware.
> 
> The problem is that the selftest expects lldpad to report back to us the
> same value as we requested.
> 
> Make the selftest smarter by figuring out on its own what is a
> reasonable value to expect.
> 
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> Tested-by: Roger Quadros <rogerq@kernel.org>
> ---

This needs your sign off as well after mine, otherwise in the git log it
will imply that I sent the patch myself. I think you can reply with the
tag to this email and either the patchwork bot or one of the maintainers
will pick it up automatically, it's not a reason in itself to resend.
Vladimir Oltean Dec. 4, 2023, 12:36 p.m. UTC | #2
On Fri, Dec 01, 2023 at 03:58:02PM +0200, Roger Quadros wrote:
> From: Vladimir Oltean <vladimir.oltean@nxp.com>
> 
> Some devices have errata due to which they cannot report ETH_ZLEN (60)
> in the rx-min-frag-size. This was foreseen of course, and lldpad has
> logic that when we request it to advertise addFragSize 0, it will round
> it up to the lowest value that is _actually_ supported by the hardware.
> 
> The problem is that the selftest expects lldpad to report back to us the
> same value as we requested.
> 
> Make the selftest smarter by figuring out on its own what is a
> reasonable value to expect.
> 
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> Tested-by: Roger Quadros <rogerq@kernel.org>
> ---

When you do resend, please make sure that this change is present before
your driver support, such that bisections show that the selftest passes
since the very introduction of this feature.
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/forwarding/ethtool_mm.sh b/tools/testing/selftests/net/forwarding/ethtool_mm.sh
index 39e736f30322..6212913f4ad1 100755
--- a/tools/testing/selftests/net/forwarding/ethtool_mm.sh
+++ b/tools/testing/selftests/net/forwarding/ethtool_mm.sh
@@ -155,15 +155,48 @@  manual_failed_verification_h2_to_h1()
 	manual_failed_verification $h2 $h1
 }
 
+smallest_supported_add_frag_size()
+{
+	local iface=$1
+	local rx_min_frag_size=
+
+	rx_min_frag_size=$(ethtool --json --show-mm $iface | \
+		jq '.[]."rx-min-frag-size"')
+
+	if [ $rx_min_frag_size -le 60 ]; then
+		echo 0
+	elif [ $rx_min_frag_size -le 124 ]; then
+		echo 1
+	elif [ $rx_min_frag_size -le 188 ]; then
+		echo 2
+	elif [ $rx_min_frag_size -le 252 ]; then
+		echo 3
+	else
+		echo "$iface: RX min frag size $rx_min_frag_size cannot be advertised over LLDP"
+		exit 1
+	fi
+}
+
+expected_add_frag_size()
+{
+	local iface=$1
+	local requested=$2
+	local min=$(smallest_supported_add_frag_size $iface)
+
+	[ $requested -le $min ] && echo $min || echo $requested
+}
+
 lldp_change_add_frag_size()
 {
 	local add_frag_size=$1
+	local pattern=
 
 	lldptool -T -i $h1 -V addEthCaps addFragSize=$add_frag_size >/dev/null
 	# Wait for TLVs to be received
 	sleep 2
-	lldptool -i $h2 -t -n -V addEthCaps | \
-		grep -q "Additional fragment size: $add_frag_size"
+	pattern=$(printf "Additional fragment size: %d" \
+			 $(expected_add_frag_size $h1 $add_frag_size))
+	lldptool -i $h2 -t -n -V addEthCaps | grep -q "$pattern"
 }
 
 lldp()