netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Roger Quadros <rogerq@kernel.org>
To: Vladimir Oltean <vladimir.oltean@nxp.com>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, shuah@kernel.org, s-vadapalli@ti.com,
	r-gunasekaran@ti.com, vigneshr@ti.com, srk@ti.com,
	horms@kernel.org, p-varis@ti.com, netdev@vger.kernel.org
Subject: Re: [PATCH 2/2] selftests: forwarding: ethtool_mm: support devices that don't support pmac stats
Date: Tue, 12 Dec 2023 21:48:05 +0200	[thread overview]
Message-ID: <133dfdf9-cfe3-422b-81d5-e7f26a192597@kernel.org> (raw)
In-Reply-To: <20231212145748.zuhn4o5j63ejcfyz@skbuf>



On 12/12/2023 16:57, Vladimir Oltean wrote:
> On Tue, Dec 12, 2023 at 04:07:18PM +0200, Roger Quadros wrote:
>> 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
> 
> 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.
> 
>>> diff --git a/tools/testing/selftests/net/forwarding/ethtool_mm.sh b/tools/testing/selftests/net/forwarding/ethtool_mm.sh
>>> index 39e736f30322..2740133f95ec 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[$netif] = false ]; then
>>
>> This should be
>> 	if [ ${has_pmac_stats[$if]} = false ]; then
>>
>> otherwise it doesn't work.
> 
> Makes sense.
> 
>>> +		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
>>> diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh
>>> index 8f6ca458af9a..82ac6a066729 100755
>>> --- a/tools/testing/selftests/net/forwarding/lib.sh
>>> +++ b/tools/testing/selftests/net/forwarding/lib.sh
>>> @@ -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?
> 
> 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

-- 
cheers,
-roger

      reply	other threads:[~2023-12-12 19:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-11 12:01 [PATCH 0/2] selftests: net: ethtool_mm: Support devices with higher rx-min-frag-size Roger Quadros
2023-12-11 12:01 ` [PATCH 1/2] selftests: forwarding: ethtool_mm: support " Roger Quadros
2023-12-11 12:01 ` [PATCH 2/2] selftests: forwarding: ethtool_mm: support devices that don't support pmac stats Roger Quadros
2023-12-11 13:24   ` Vladimir Oltean
2023-12-11 13:53     ` Roger Quadros
2023-12-12 14:07     ` Roger Quadros
2023-12-12 14:57       ` Vladimir Oltean
2023-12-12 19:48         ` Roger Quadros [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=133dfdf9-cfe3-422b-81d5-e7f26a192597@kernel.org \
    --to=rogerq@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=p-varis@ti.com \
    --cc=pabeni@redhat.com \
    --cc=r-gunasekaran@ti.com \
    --cc=s-vadapalli@ti.com \
    --cc=shuah@kernel.org \
    --cc=srk@ti.com \
    --cc=vigneshr@ti.com \
    --cc=vladimir.oltean@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).