[PATCH net-next v3 1/9] selftests: forwarding: extend ethtool_std_stats_get with pause statistics

Ioana Ciornei posted 9 patches 2 weeks, 3 days ago
There is a newer version of this series
[PATCH net-next v3 1/9] selftests: forwarding: extend ethtool_std_stats_get with pause statistics
Posted by Ioana Ciornei 2 weeks, 3 days ago
Even though pause frame statistics are not exported through the same
ethtool command, there is no point in adding another helper just for
them. Extent the ethtool_std_stats_get() function so that we are able to
interrogate using the same helper all the standard statistics.

And since we are touching the else case, convert that as well to the jq
--arg form in order to be easier to read.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v3:
- none
Changes in v2:
- convert jq to the --arg usage form

 tools/testing/selftests/net/forwarding/lib.sh | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
index a9034f0bb58b..cf40cb766c68 100644
--- a/tools/testing/selftests/net/forwarding/lib.sh
+++ b/tools/testing/selftests/net/forwarding/lib.sh
@@ -831,8 +831,12 @@ ethtool_std_stats_get()
 	local name=$1; shift
 	local src=$1; shift
 
-	ethtool --json -S $dev --groups $grp -- --src $src | \
-		jq '.[]."'"$grp"'"."'$name'"'
+	if [[ "$grp" == "pause" ]]; then
+		ethtool -I --json -a "$dev" | jq --arg name "$name" '.[].statistics[$name]'
+	else
+		ethtool --json -S "$dev" --groups "$grp" -- --src "$src" | \
+			jq --arg grp "$grp" --arg name "$name" '.[][$grp][$name]'
+	fi
 }
 
 qdisc_stats_get()
-- 
2.25.1
Re: [PATCH net-next v3 1/9] selftests: forwarding: extend ethtool_std_stats_get with pause statistics
Posted by Petr Machata 2 weeks, 2 days ago
Ioana Ciornei <ioana.ciornei@nxp.com> writes:

> Even though pause frame statistics are not exported through the same
> ethtool command, there is no point in adding another helper just for
> them. Extent the ethtool_std_stats_get() function so that we are able to
> interrogate using the same helper all the standard statistics.
>
> And since we are touching the else case, convert that as well to the jq
> --arg form in order to be easier to read.
>
> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
> ---
> Changes in v3:
> - none
> Changes in v2:
> - convert jq to the --arg usage form
>
>  tools/testing/selftests/net/forwarding/lib.sh | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
> index a9034f0bb58b..cf40cb766c68 100644
> --- a/tools/testing/selftests/net/forwarding/lib.sh
> +++ b/tools/testing/selftests/net/forwarding/lib.sh
> @@ -831,8 +831,12 @@ ethtool_std_stats_get()
>  	local name=$1; shift
>  	local src=$1; shift
>  
> -	ethtool --json -S $dev --groups $grp -- --src $src | \
> -		jq '.[]."'"$grp"'"."'$name'"'
> +	if [[ "$grp" == "pause" ]]; then
> +		ethtool -I --json -a "$dev" | jq --arg name "$name" '.[].statistics[$name]'

I missed this overlong line. Fold it, please. The R-b applies with this change.

> +	else
> +		ethtool --json -S "$dev" --groups "$grp" -- --src "$src" | \
> +			jq --arg grp "$grp" --arg name "$name" '.[][$grp][$name]'
> +	fi
>  }
>  
>  qdisc_stats_get()
Re: [PATCH net-next v3 1/9] selftests: forwarding: extend ethtool_std_stats_get with pause statistics
Posted by Ioana Ciornei 2 weeks, 2 days ago
On Fri, Mar 20, 2026 at 12:20:01PM +0100, Petr Machata wrote:
> 
> Ioana Ciornei <ioana.ciornei@nxp.com> writes:
> 
> > Even though pause frame statistics are not exported through the same
> > ethtool command, there is no point in adding another helper just for
> > them. Extent the ethtool_std_stats_get() function so that we are able to
> > interrogate using the same helper all the standard statistics.
> >
> > And since we are touching the else case, convert that as well to the jq
> > --arg form in order to be easier to read.
> >
> > Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
> > ---
> > Changes in v3:
> > - none
> > Changes in v2:
> > - convert jq to the --arg usage form
> >
> >  tools/testing/selftests/net/forwarding/lib.sh | 8 ++++++--
> >  1 file changed, 6 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
> > index a9034f0bb58b..cf40cb766c68 100644
> > --- a/tools/testing/selftests/net/forwarding/lib.sh
> > +++ b/tools/testing/selftests/net/forwarding/lib.sh
> > @@ -831,8 +831,12 @@ ethtool_std_stats_get()
> >  	local name=$1; shift
> >  	local src=$1; shift
> >  
> > -	ethtool --json -S $dev --groups $grp -- --src $src | \
> > -		jq '.[]."'"$grp"'"."'$name'"'
> > +	if [[ "$grp" == "pause" ]]; then
> > +		ethtool -I --json -a "$dev" | jq --arg name "$name" '.[].statistics[$name]'
> 
> I missed this overlong line. Fold it, please. The R-b applies with this change.

Ok. Will fold it.
I also realised that I should have passed --src "$src" to this ethtool
call.
Re: [PATCH net-next v3 1/9] selftests: forwarding: extend ethtool_std_stats_get with pause statistics
Posted by Petr Machata 2 weeks, 2 days ago
Ioana Ciornei <ioana.ciornei@nxp.com> writes:

> Even though pause frame statistics are not exported through the same
> ethtool command, there is no point in adding another helper just for
> them. Extent the ethtool_std_stats_get() function so that we are able to
> interrogate using the same helper all the standard statistics.
>
> And since we are touching the else case, convert that as well to the jq
> --arg form in order to be easier to read.
>
> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>

Reviewed-by: Petr Machata <petrm@nvidia.com>