diff mbox series

[v8,net-next,02/11] selftests: forwarding: ethtool_mm: fall back to aggregate if device does not report pMAC stats

Message ID 20231213110721.69154-3-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; no diff in generated;
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: razor@blackwall.org idosch@nvidia.com liuhangbin@gmail.com linux-kselftest@vger.kernel.org petrm@nvidia.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 88 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. 13, 2023, 11:07 a.m. UTC
From: Vladimir Oltean <vladimir.oltean@nxp.com>

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

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Tested-by: Roger Quadros <rogerq@kernel.org>
Signed-off-by: Roger Quadros <rogerq@kernel.org>
---
 tools/testing/selftests/net/forwarding/ethtool_mm.sh | 11 +++++++++++
 tools/testing/selftests/net/forwarding/lib.sh        |  9 +++++++++
 2 files changed, 20 insertions(+)

Changelog:

v8: initial commit

Comments

Vladimir Oltean Dec. 14, 2023, 2:16 p.m. UTC | #1
On Wed, Dec 13, 2023 at 01:07:12PM +0200, Roger Quadros wrote:
> diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
> index 8f6ca458af9a..763c262a3453 100755
> --- a/tools/testing/selftests/net/forwarding/lib.sh
> +++ b/tools/testing/selftests/net/forwarding/lib.sh
> @@ -146,6 +146,15 @@ check_ethtool_mm_support()
>  	fi
>  }
>  
> +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') ]
> +}
> +
>  check_locked_port_support()
>  {
>  	if ! bridge -d link show | grep -q " locked"; then
> -- 
> 2.34.1
>

FYI, there's another submitted patch that touches the exact same spot,
and it looks like it has a good chance of getting merged.
https://patchwork.kernel.org/project/netdevbpf/patch/20231214135029.383595-9-tobias@waldekranz.com/

You need to pay attention to merge conflicts, so you don't waste a patch
iteration just because of that one thing.

I guess you might be able to wing it, because the other patch does this:

diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
index 8f6ca458af9a..e3740163c384 100755
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -146,6 +146,15 @@  check_ethtool_mm_support()
 	fi
 }
 
+check_ethtool_counter_group_support()
+{
+	ethtool --help 2>&1| grep -- '--all-groups' &> /dev/null
+	if [[ $? -ne 0 ]]; then
+		echo "SKIP: ethtool too old; it is missing standard counter group support"
+		exit $ksft_skip
+	fi
+}
+
 check_locked_port_support()
 {
 	if ! bridge -d link show | grep -q " locked"; then

which quite coincidentally does not change what your patch sees in its
upper context, aka 3 lines like this:

----
 	fi
 }
 
----

You can check if your patch set applies on top of Tobias', by formatting
it as patch files on top of net-next/main, resetting HEAD to net-next,
applying Tobias' series and then your patches.
Roger Quadros Dec. 14, 2023, 5:16 p.m. UTC | #2
On 14/12/2023 16:16, Vladimir Oltean wrote:
> On Wed, Dec 13, 2023 at 01:07:12PM +0200, Roger Quadros wrote:
>> diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
>> index 8f6ca458af9a..763c262a3453 100755
>> --- a/tools/testing/selftests/net/forwarding/lib.sh
>> +++ b/tools/testing/selftests/net/forwarding/lib.sh
>> @@ -146,6 +146,15 @@ check_ethtool_mm_support()
>>  	fi
>>  }
>>  
>> +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') ]
>> +}
>> +
>>  check_locked_port_support()
>>  {
>>  	if ! bridge -d link show | grep -q " locked"; then
>> -- 
>> 2.34.1
>>
> 
> FYI, there's another submitted patch that touches the exact same spot,
> and it looks like it has a good chance of getting merged.
> https://patchwork.kernel.org/project/netdevbpf/patch/20231214135029.383595-9-tobias@waldekranz.com/
> 
> You need to pay attention to merge conflicts, so you don't waste a patch
> iteration just because of that one thing.
> 
> I guess you might be able to wing it, because the other patch does this:
> 
> diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
> index 8f6ca458af9a..e3740163c384 100755
> --- a/tools/testing/selftests/net/forwarding/lib.sh
> +++ b/tools/testing/selftests/net/forwarding/lib.sh
> @@ -146,6 +146,15 @@  check_ethtool_mm_support()
>  	fi
>  }
>  
> +check_ethtool_counter_group_support()
> +{
> +	ethtool --help 2>&1| grep -- '--all-groups' &> /dev/null
> +	if [[ $? -ne 0 ]]; then
> +		echo "SKIP: ethtool too old; it is missing standard counter group support"
> +		exit $ksft_skip
> +	fi
> +}
> +
>  check_locked_port_support()
>  {
>  	if ! bridge -d link show | grep -q " locked"; then
> 
> which quite coincidentally does not change what your patch sees in its
> upper context, aka 3 lines like this:
> 
> ----
>  	fi
>  }
>  
> ----
> 
> You can check if your patch set applies on top of Tobias', by formatting
> it as patch files on top of net-next/main, resetting HEAD to net-next,
> applying Tobias' series and then your patches.

Thanks for the heads up :)
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 6212913f4ad1..50d5bfb17ef1 100755
--- a/tools/testing/selftests/net/forwarding/ethtool_mm.sh
+++ b/tools/testing/selftests/net/forwarding/ethtool_mm.sh
@@ -25,6 +25,10 @@  traffic_test()
 	local after=
 	local delta=
 
+	if [ ${has_pmac_stats[$if]} = 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
@@ -317,6 +321,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 eth-mac; 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
diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
index 8f6ca458af9a..763c262a3453 100755
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -146,6 +146,15 @@  check_ethtool_mm_support()
 	fi
 }
 
+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') ]
+}
+
 check_locked_port_support()
 {
 	if ! bridge -d link show | grep -q " locked"; then