Skip to contentSkip to conversation

selftests: net: ethtool_mm: Support devices with higher rx-min-frag-size

PATCH In review Roger Quadros 2 participants 8 messages Dec 11, 2023 – Dec 12, 2023

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover selftests: net: ethtool_mm: Support devices with higher rx-min-frag-size

Hi,

Some devices e.g. TI SoCs have an errata due to which they cannot support rx-min-frag-size of ETH_ZLEN (60). Also some devices cannot report individual pmac/emac stats.

Modify the test so it can pass for such devices.

cheers,
-roger

Roger Quadros (1):
selftests: forwarding: ethtool_mm: support devices that don't support
pmac stats

Vladimir Oltean (1):
selftests: forwarding: ethtool_mm: support devices with higher
rx-min-frag-size

 .../selftests/net/forwarding/ethtool_mm.sh    | 44 ++++++++++++++++++-
 1 file changed, 42 insertions(+), 2 deletions(-)

base-commit: 70028b2e51c61d8dda0a31985978f4745da6a11b

Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/2 selftests: forwarding: ethtool_mm: support devices with higher rx-min-frag-size

From: Vladimir Oltean <[email protected]>

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.

---
 .../selftests/net/forwarding/ethtool_mm.sh    | 37 ++++++++++++++++++-
 1 file changed, 35 insertions(+), 2 deletions(-)
tools/testing/selftests/net/forwarding/ethtool_mm.sh +35 -2
index 39e736f30322..6212913f4ad1 100755
@@ -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()
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/2 selftests: forwarding: ethtool_mm: support devices that don't support pmac stats

In reply to Roger Quadros

Some devices do not support individual 'pmac' and 'emac' stats. For such devices, resort to 'aggregate' stats.

---
 tools/testing/selftests/net/forwarding/ethtool_mm.sh | 7 +++++++
 1 file changed, 7 insertions(+)
tools/testing/selftests/net/forwarding/ethtool_mm.sh +7 -0
index 6212913f4ad1..e3f2e62029ca 100755
@@ -26,6 +26,13 @@ traffic_test()
 	local delta=
 
 	before=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOK" $src)
+	# some devices don't support individual pmac/emac stats,
+	# use aggregate stats for them.
+        if [ "$before" == null ]; then
+                src="aggregate"
+                before=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOO
+K" $src)
+        fi
 
 	$MZ $if -q -c $num_pkts -p 64 -b bcast -t ip -R $PREEMPTIBLE_PRIO
 
Signature · 1 line
2.34.1
#3 lore raw

Re: [PATCH 2/2] selftests: forwarding: ethtool_mm: support devices that don't support pmac stats

Quoted 13 lines · Roger Quadros

Some devices do not support individual 'pmac' and 'emac' stats. For such devices, resort to 'aggregate' stats.

---
 tools/testing/selftests/net/forwarding/ethtool_mm.sh | 7 +++++++
 1 file changed, 7 insertions(+)
tools/testing/selftests/net/forwarding/ethtool_mm.sh +0 -0
index 6212913f4ad1..e3f2e62029ca 100755

tools/testing/selftests/net/forwarding/ethtool_mm.sh traffic_test() · line 35

Quoted 10 lines
tools/testing/selftests/net/forwarding/ethtool_mm.sh +7 -0
@@ -26,6 +26,13 @@ traffic_test()
 	local delta=
 
 	before=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOK" $src)
+	# some devices don't support individual pmac/emac stats,
+	# use aggregate stats for them.
+        if [ "$before" == null ]; then
+                src="aggregate"
+                before=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOO
+K" $src)
+        fi

1. please follow the existing indentation scheme, don't mix tabs with spaces
2. someone mangled your patch into invalid bash syntax, splitting a line into 2
3. "FramesTransmittedOOK" has an extra "O"
4. it would be preferable if you could evaluate only once whether pMAC counters are reported, set a global variable, and in traffic_test(), if that variable is true, override $src with "aggregate".
5. why did you split the selftest patches out of the am65-cpsw patch set? It is for the am65-cpsw that they are needed.

Quoted 6 lines
tools/testing/selftests/net/forwarding/ethtool_mm.sh +0 -0
 	$MZ $if -q -c $num_pkts -p 64 -b bcast -t ip -R $PREEMPTIBLE_PRIO
 
Signature · 1 line
2.34.1

Something like this?

From ef5688a78908d99b607909fd7c93829c6a018b61 Mon Sep 17 00:00:00 2001
From: Vladimir Oltean <[email protected]>
Date: Mon, 11 Dec 2023 15:21:25 +0200
Subject: [PATCH] selftests: forwarding: ethtool_mm: fall back to aggregate if
device does not report pMAC stats

---
 tools/testing/selftests/net/forwarding/ethtool_mm.sh | 11 +++++++++++
 tools/testing/selftests/net/forwarding/lib.sh        |  8 ++++++++
 2 files changed, 19 insertions(+)
tools/testing/selftests/net/forwarding/ethtool_mm.sh +11 -0
index 39e736f30322..2740133f95ec 100755
@@ -25,6 +25,10 @@ traffic_test()
 	local after=
 	local delta=
 
+	if [ has_pmac_stats[$netif] = false ]; then
+		src="aggregate"
+	fi
+
 	before=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOK" $src)
 
 	$MZ $if -q -c $num_pkts -p 64 -b bcast -t ip -R $PREEMPTIBLE_PRIO
@@ -284,6 +288,13 @@ for netif in ${NETIFS[@]}; do
 		echo "SKIP: $netif does not support MAC Merge"
 		exit $ksft_skip
 	fi
+
+	if check_ethtool_pmac_std_stats_support $netif; then
+		has_pmac_stats[$netif]=true
+	else
+		has_pmac_stats[$netif]=false
+		echo "$netif does not report pMAC statistics, falling back to aggregate"
+	fi
 done
 
 trap cleanup EXIT
tools/testing/selftests/net/forwarding/lib.sh +8 -0
index 8f6ca458af9a..82ac6a066729 100755
@@ -146,6 +146,14 @@ check_ethtool_mm_support()
 	fi
 }
 
+check_ethtool_pmac_std_stats_support()
+{
+	local dev=$1; shift
+
+	[ -n "$(ethtool --json -S $dev --all-groups --src pmac 2>/dev/null | \
+		jq '.[]')" ]
+}
+
 check_locked_port_support()
 {
 	if ! bridge -d link show | grep -q " locked"; then
Signature · 1 line
2.34.1
#4 lore raw

Re: [PATCH 2/2] selftests: forwarding: ethtool_mm: support devices that don't support pmac stats

Quoted 16 lines · Vladimir Oltean
Quoted 15 lines · Roger Quadros

Some devices do not support individual 'pmac' and 'emac' stats. For such devices, resort to 'aggregate' stats.

---
 tools/testing/selftests/net/forwarding/ethtool_mm.sh | 7 +++++++
 1 file changed, 7 insertions(+)
tools/testing/selftests/net/forwarding/ethtool_mm.sh +0 -0
index 6212913f4ad1..e3f2e62029ca 100755
@@ -26,6 +26,13 @@ traffic_test()
 	local delta=
 
Quoted 10 lines

tools/testing/selftests/net/forwarding/ethtool_mm.sh traffic_test() · line 35

Quoted 8 lines
tools/testing/selftests/net/forwarding/ethtool_mm.sh +7 -0
 	before=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOK" $src)
+	# some devices don't support individual pmac/emac stats,
+	# use aggregate stats for them.
+        if [ "$before" == null ]; then
+                src="aggregate"
+                before=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOO
+K" $src)
+        fi

1. please follow the existing indentation scheme, don't mix tabs with spaces

Sure. Will fix.

Quoted 3 lines

2. someone mangled your patch into invalid bash syntax, splitting a line into 2
3. "FramesTransmittedOOK" has an extra "O"

Will fix. The mangling happened at my end.

Quoted 5 lines

4. it would be preferable if you could evaluate only once whether pMAC counters are reported, set a global variable, and in traffic_test(), if that variable is true, override $src with "aggregate".
5. why did you split the selftest patches out of the am65-cpsw patch set? It is for the am65-cpsw that they are needed.

Needed for the tests to pass, yes.
I'll add them back at the beginning of the series.

Quoted 9 lines
Quoted 7 lines
tools/testing/selftests/net/forwarding/ethtool_mm.sh +0 -0
 	$MZ $if -q -c $num_pkts -p 64 -b bcast -t ip -R $PREEMPTIBLE_PRIO
 
Signature · 1 line
2.34.1

Something like this?

Thanks for the hint!

Quoted 61 lines

From ef5688a78908d99b607909fd7c93829c6a018b61 Mon Sep 17 00:00:00 2001
From: Vladimir Oltean <[email protected]>
Date: Mon, 11 Dec 2023 15:21:25 +0200
Subject: [PATCH] selftests: forwarding: ethtool_mm: fall back to aggregate if
device does not report pMAC stats

---
 tools/testing/selftests/net/forwarding/ethtool_mm.sh | 11 +++++++++++
 tools/testing/selftests/net/forwarding/lib.sh        |  8 ++++++++
 2 files changed, 19 insertions(+)
tools/testing/selftests/net/forwarding/ethtool_mm.sh +11 -0
index 39e736f30322..2740133f95ec 100755
@@ -25,6 +25,10 @@ traffic_test()
 	local after=
 	local delta=
 
+	if [ has_pmac_stats[$netif] = false ]; then
+		src="aggregate"
+	fi
+
 	before=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOK" $src)
 
 	$MZ $if -q -c $num_pkts -p 64 -b bcast -t ip -R $PREEMPTIBLE_PRIO
@@ -284,6 +288,13 @@ for netif in ${NETIFS[@]}; do
 		echo "SKIP: $netif does not support MAC Merge"
 		exit $ksft_skip
 	fi
+
+	if check_ethtool_pmac_std_stats_support $netif; then
+		has_pmac_stats[$netif]=true
+	else
+		has_pmac_stats[$netif]=false
+		echo "$netif does not report pMAC statistics, falling back to aggregate"
+	fi
 done
 
 trap cleanup EXIT
tools/testing/selftests/net/forwarding/lib.sh +8 -0
index 8f6ca458af9a..82ac6a066729 100755
@@ -146,6 +146,14 @@ check_ethtool_mm_support()
 	fi
 }
 
+check_ethtool_pmac_std_stats_support()
+{
+	local dev=$1; shift
+
+	[ -n "$(ethtool --json -S $dev --all-groups --src pmac 2>/dev/null | \
+		jq '.[]')" ]
+}
+
 check_locked_port_support()
 {
 	if ! bridge -d link show | grep -q " locked"; then
Signature · 2 lines
cheers,
-roger
#5 lore raw

Re: [PATCH 2/2] selftests: forwarding: ethtool_mm: support devices that don't support pmac stats

In reply to Vladimir Oltean

Hi Vladimir,

Quoted 50 lines · Vladimir Oltean
Quoted 13 lines · Roger Quadros

Some devices do not support individual 'pmac' and 'emac' stats. For such devices, resort to 'aggregate' stats.

---
 tools/testing/selftests/net/forwarding/ethtool_mm.sh | 7 +++++++
 1 file changed, 7 insertions(+)
tools/testing/selftests/net/forwarding/ethtool_mm.sh +0 -0
index 6212913f4ad1..e3f2e62029ca 100755

tools/testing/selftests/net/forwarding/ethtool_mm.sh traffic_test() · line 35

Quoted 10 lines
tools/testing/selftests/net/forwarding/ethtool_mm.sh +7 -0
@@ -26,6 +26,13 @@ traffic_test()
 	local delta=
 
 	before=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOK" $src)
+	# some devices don't support individual pmac/emac stats,
+	# use aggregate stats for them.
+        if [ "$before" == null ]; then
+                src="aggregate"
+                before=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOO
+K" $src)
+        fi

1. please follow the existing indentation scheme, don't mix tabs with spaces
2. someone mangled your patch into invalid bash syntax, splitting a line into 2
3. "FramesTransmittedOOK" has an extra "O"
4. it would be preferable if you could evaluate only once whether pMAC counters are reported, set a global variable, and in traffic_test(), if that variable is true, override $src with "aggregate".
5. why did you split the selftest patches out of the am65-cpsw patch set? It is for the am65-cpsw that they are needed.

Quoted 6 lines
tools/testing/selftests/net/forwarding/ethtool_mm.sh +0 -0
 	$MZ $if -q -c $num_pkts -p 64 -b bcast -t ip -R $PREEMPTIBLE_PRIO
 
Signature · 1 line
2.34.1

Something like this?

From ef5688a78908d99b607909fd7c93829c6a018b61 Mon Sep 17 00:00:00 2001
From: Vladimir Oltean <[email protected]>
Date: Mon, 11 Dec 2023 15:21:25 +0200
Subject: [PATCH] selftests: forwarding: ethtool_mm: fall back to aggregate if
device does not report pMAC stats

Quoted 5 lines
---
 tools/testing/selftests/net/forwarding/ethtool_mm.sh | 11 +++++++++++
 tools/testing/selftests/net/forwarding/lib.sh        |  8 ++++++++
 2 files changed, 19 insertions(+)

What is the proper way to run the script?

I've been hardcoding the following in the script.

NETIFS=( "eth0" "eth1" )

in setup_prepare()

	h1=eth0
	h2=eth1

and run the script like so

./run_kselftest.sh -t net/forwarding:ethtool_mm.sh

tools/testing/selftests/net/forwarding/ethtool_mm.sh traffic_test() · line 28

Quoted 10 lines
tools/testing/selftests/net/forwarding/ethtool_mm.sh +1 -0
index 39e736f30322..2740133f95ec 100755
@@ -25,6 +25,10 @@ traffic_test()
 	local after=
 	local delta=
 
+	if [ has_pmac_stats[$netif] = false ]; then

This should be

	if [ ${has_pmac_stats[$if]} = false ]; then

otherwise it doesn't work.

Quoted 27 lines
tools/testing/selftests/net/forwarding/ethtool_mm.sh +10 -0
+		src="aggregate"
+	fi
+
 	before=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOK" $src)
 
 	$MZ $if -q -c $num_pkts -p 64 -b bcast -t ip -R $PREEMPTIBLE_PRIO
@@ -284,6 +288,13 @@ for netif in ${NETIFS[@]}; do
 		echo "SKIP: $netif does not support MAC Merge"
 		exit $ksft_skip
 	fi
+
+	if check_ethtool_pmac_std_stats_support $netif; then
+		has_pmac_stats[$netif]=true
 
 
+	else
+		has_pmac_stats[$netif]=false
+		echo "$netif does not report pMAC statistics, falling back to aggregate"
+	fi
 done

trap cleanup EXIT

tools/testing/selftests/net/forwarding/lib.sh +0 -0
index 8f6ca458af9a..82ac6a066729 100755

tools/testing/selftests/net/forwarding/lib.sh check_ethtool_mm_support() · line 154

Quoted 9 lines
tools/testing/selftests/net/forwarding/lib.sh +6 -0
@@ -146,6 +146,14 @@ check_ethtool_mm_support()
 	fi
 }
 
+check_ethtool_pmac_std_stats_support()
+{
+	local dev=$1; shift
+
+	[ -n "$(ethtool --json -S $dev --all-groups --src pmac 2>/dev/null | \
+		jq '.[]')" ]

This is evaluating to true instead of false on my platform so something needs to be fixed here.

Below is the output of "ethtool --json -S eth0 --all-groups --src pmac"

[ {
        "ifname": "eth0",
        "eth-phy": {},
        "eth-mac": {},
        "eth-ctrl": {},
        "rmon": {}
    } ]

I suppose we want to check if eth-mac has anything or not.

Something like this works

	[ 0 -ne $(ethtool --json -S $dev --all-groups --src pmac 2>/dev/null \
		| jq '.[]."eth-mac" | length') ]

OK?

tools/testing/selftests/net/forwarding/lib.sh check_ethtool_mm_support() · line 159

Quoted 5 lines
tools/testing/selftests/net/forwarding/lib.sh +2 -0
+}
+
 check_locked_port_support()
 {
 	if ! bridge -d link show | grep -q " locked"; then

also I had to revert a recent commit

25ae948b4478 ("selftests/net: add lib.sh")

else i get an error message syaing ../lib.sh not found. Looks like that is not getting deployed on kselftest-install

I will report this in the original patch thread as well.

Signature · 2 lines
cheers,
-roger
#6 lore raw

Re: [PATCH 2/2] selftests: forwarding: ethtool_mm: support devices that don't support pmac stats

Quoted 6 lines · Roger Quadros

What is the proper way to run the script?

I've been hardcoding the following in the script.

NETIFS=( "eth0" "eth1" )

Quoted 7 lines

in setup_prepare()

	h1=eth0
	h2=eth1

and run the script like so

./run_kselftest.sh -t net/forwarding:ethtool_mm.sh

IDK. I rsync the selftest dir to my board and do:

$ cd selftests/net/forwarding
$ ./ethtool.mm eth0 eth1

Running through run_kselftest.sh is probably better. I think that also supports passing the network interfaces as arguments, no need to hack up the script.

Quoted 8 lines
Quoted 8 lines
tools/testing/selftests/net/forwarding/ethtool_mm.sh +0 -0
index 39e736f30322..2740133f95ec 100755
@@ -25,6 +25,10 @@ traffic_test()
 	local after=
 	local delta=
 
Quoted 6 lines

tools/testing/selftests/net/forwarding/ethtool_mm.sh traffic_test() · line 28

Quoted 1 line
tools/testing/selftests/net/forwarding/ethtool_mm.sh +1 -0
+	if [ has_pmac_stats[$netif] = false ]; then

This should be

	if [ ${has_pmac_stats[$if]} = false ]; then

otherwise it doesn't work.

Makes sense.

Quoted 49 lines
Quoted 27 lines
tools/testing/selftests/net/forwarding/ethtool_mm.sh +10 -0
+		src="aggregate"
+	fi
+
 	before=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOK" $src)
 
 	$MZ $if -q -c $num_pkts -p 64 -b bcast -t ip -R $PREEMPTIBLE_PRIO
@@ -284,6 +288,13 @@ for netif in ${NETIFS[@]}; do
 		echo "SKIP: $netif does not support MAC Merge"
 		exit $ksft_skip
 	fi
+
+	if check_ethtool_pmac_std_stats_support $netif; then
+		has_pmac_stats[$netif]=true
 
 
+	else
+		has_pmac_stats[$netif]=false
+		echo "$netif does not report pMAC statistics, falling back to aggregate"
+	fi
 done

trap cleanup EXIT

tools/testing/selftests/net/forwarding/lib.sh +0 -0
index 8f6ca458af9a..82ac6a066729 100755

tools/testing/selftests/net/forwarding/lib.sh check_ethtool_mm_support() · line 154

Quoted 9 lines
tools/testing/selftests/net/forwarding/lib.sh +6 -0
@@ -146,6 +146,14 @@ check_ethtool_mm_support()
 	fi
 }
 
+check_ethtool_pmac_std_stats_support()
+{
+	local dev=$1; shift
+
+	[ -n "$(ethtool --json -S $dev --all-groups --src pmac 2>/dev/null | \
+		jq '.[]')" ]

This is evaluating to true instead of false on my platform so something needs to be fixed here.

Below is the output of "ethtool --json -S eth0 --all-groups --src pmac"

[ {
        "ifname": "eth0",
        "eth-phy": {},
        "eth-mac": {},
        "eth-ctrl": {},
        "rmon": {}
    } ]
Quoted 8 lines

I suppose we want to check if eth-mac has anything or not.

Something like this works

	[ 0 -ne $(ethtool --json -S $dev --all-groups --src pmac 2>/dev/null \
		| jq '.[]."eth-mac" | length') ]

OK?

Maybe giving the stats group as argument instead of hardcoding "eth-mac" would make sense. I hoped we could avoid hardcoding one particular group of counters in check_ethtool_pmac_std_stats_support().

Quoted 8 lines

tools/testing/selftests/net/forwarding/lib.sh check_ethtool_mm_support() · line 159

Quoted 5 lines
tools/testing/selftests/net/forwarding/lib.sh +2 -0
+}
+
 check_locked_port_support()
 {
 	if ! bridge -d link show | grep -q " locked"; then

also I had to revert a recent commit

Quoted 6 lines

25ae948b4478 ("selftests/net: add lib.sh")

else i get an error message syaing ../lib.sh not found. Looks like that is not getting deployed on kselftest-install

I will report this in the original patch thread as well.

I'm not using that part, so I didn't notice it :)

#7 lore raw

Re: [PATCH 2/2] selftests: forwarding: ethtool_mm: support devices that don't support pmac stats

Quoted 94 lines · Vladimir Oltean
Quoted 6 lines · Roger Quadros

What is the proper way to run the script?

I've been hardcoding the following in the script.

NETIFS=( "eth0" "eth1" )

Quoted 7 lines

in setup_prepare()

	h1=eth0
	h2=eth1

and run the script like so

./run_kselftest.sh -t net/forwarding:ethtool_mm.sh

IDK. I rsync the selftest dir to my board and do:

$ cd selftests/net/forwarding
$ ./ethtool.mm eth0 eth1

Running through run_kselftest.sh is probably better. I think that also supports passing the network interfaces as arguments, no need to hack up the script.

Quoted 8 lines
Quoted 8 lines
tools/testing/selftests/net/forwarding/ethtool_mm.sh +0 -0
index 39e736f30322..2740133f95ec 100755
@@ -25,6 +25,10 @@ traffic_test()
 	local after=
 	local delta=
 
Quoted 6 lines

tools/testing/selftests/net/forwarding/ethtool_mm.sh traffic_test() · line 28

Quoted 1 line
tools/testing/selftests/net/forwarding/ethtool_mm.sh +1 -0
+	if [ has_pmac_stats[$netif] = false ]; then

This should be

	if [ ${has_pmac_stats[$if]} = false ]; then

otherwise it doesn't work.

Makes sense.

Quoted 53 lines
Quoted 27 lines
tools/testing/selftests/net/forwarding/ethtool_mm.sh +10 -0
+		src="aggregate"
+	fi
+
 	before=$(ethtool_std_stats_get $if "eth-mac" "FramesTransmittedOK" $src)
 
 	$MZ $if -q -c $num_pkts -p 64 -b bcast -t ip -R $PREEMPTIBLE_PRIO
@@ -284,6 +288,13 @@ for netif in ${NETIFS[@]}; do
 		echo "SKIP: $netif does not support MAC Merge"
 		exit $ksft_skip
 	fi
+
+	if check_ethtool_pmac_std_stats_support $netif; then
+		has_pmac_stats[$netif]=true
 
 
+	else
+		has_pmac_stats[$netif]=false
+		echo "$netif does not report pMAC statistics, falling back to aggregate"
+	fi
 done

trap cleanup EXIT

tools/testing/selftests/net/forwarding/lib.sh +0 -0
index 8f6ca458af9a..82ac6a066729 100755

tools/testing/selftests/net/forwarding/lib.sh check_ethtool_mm_support() · line 154

Quoted 9 lines
tools/testing/selftests/net/forwarding/lib.sh +6 -0
@@ -146,6 +146,14 @@ check_ethtool_mm_support()
 	fi
 }
 
+check_ethtool_pmac_std_stats_support()
+{
+	local dev=$1; shift
+
+	[ -n "$(ethtool --json -S $dev --all-groups --src pmac 2>/dev/null | \
+		jq '.[]')" ]

This is evaluating to true instead of false on my platform so something needs to be fixed here.

Below is the output of "ethtool --json -S eth0 --all-groups --src pmac"

[ {
        "ifname": "eth0",
        "eth-phy": {},
        "eth-mac": {},
        "eth-ctrl": {},
        "rmon": {}
    } ]

I suppose we want to check if eth-mac has anything or not.

Something like this works

Quoted 8 lines
Quoted 4 lines
	[ 0 -ne $(ethtool --json -S $dev --all-groups --src pmac 2>/dev/null \
		| jq '.[]."eth-mac" | length') ]

OK?

Maybe giving the stats group as argument instead of hardcoding "eth-mac" would make sense. I hoped we could avoid hardcoding one particular group of counters in check_ethtool_pmac_std_stats_support().

You mean like this?

check_ethtool_pmac_std_stats_support()

{
	local dev=$1; shift
	local grp=$1; shift

	[ 0 -ne $(ethtool --json -S $dev --all-groups --src pmac 2>/dev/null \
		| jq '.[]."$grp" | length') ]
}

Caller will call like so
check_ethtool_pmac_std_stats_support $netif eth-mac

Signature · 2 lines
cheers,
-roger