[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <94ac1a2f-d6d0-473b-80ca-012a0ad7dc02@davidwei.uk>
Date: Thu, 20 Jun 2024 18:14:24 -0700
From: David Wei <dw@...idwei.uk>
To: Jakub Kicinski <kuba@...nel.org>, davem@...emloft.net
Cc: netdev@...r.kernel.org, edumazet@...gle.com, pabeni@...hat.com,
willemdebruijn.kernel@...il.com, ecree.xilinx@...il.com
Subject: Re: [PATCH net-next 3/4] selftests: drv-net: add ability to wait for
at least N packets to load gen
On 2024-06-20 16:29, Jakub Kicinski wrote:
> Teach the load generator how to wait for at least given number
> of packets to be received. This will be useful for filtering
> where we'll want to send a non-trivial number of packets and
> make sure they landed in right queues.
>
> Signed-off-by: Jakub Kicinski <kuba@...nel.org>
> ---
> .../selftests/drivers/net/lib/py/load.py | 26 ++++++++++++++-----
> 1 file changed, 19 insertions(+), 7 deletions(-)
>
> diff --git a/tools/testing/selftests/drivers/net/lib/py/load.py b/tools/testing/selftests/drivers/net/lib/py/load.py
> index abdb677bdb1c..ae60c438f6c2 100644
> --- a/tools/testing/selftests/drivers/net/lib/py/load.py
> +++ b/tools/testing/selftests/drivers/net/lib/py/load.py
> @@ -18,15 +18,27 @@ from lib.py import ksft_pr, cmd, ip, rand_port, wait_port_listen
> background=True, host=env.remote)
>
> # Wait for traffic to ramp up
> - pkt = ip("-s link show dev " + env.ifname, json=True)[0]["stats64"]["rx"]["packets"]
> + if not self._wait_pkts(pps=1000):
> + self.stop(verbose=True)
> + raise Exception("iperf3 traffic did not ramp up")
> +
> + def _wait_pkts(self, pkt_cnt=None, pps=None):
Do you need to emphasise that pkt_cnt and pps are mutually exclusive?
> + pkt = ip("-s link show dev " + self.env.ifname, json=True)[0]["stats64"]["rx"]["packets"]
> for _ in range(50):
> time.sleep(0.1)
> - now = ip("-s link show dev " + env.ifname, json=True)[0]["stats64"]["rx"]["packets"]
> - if now - pkt > 1000:
> - return
> - pkt = now
> - self.stop(verbose=True)
> - raise Exception("iperf3 traffic did not ramp up")
> + now = ip("-s link show dev " + self.env.ifname, json=True)[0]["stats64"]["rx"]["packets"]
nit: with duck typing `now' reads like a time value to me. Maybe
pkt_start and pkt_now?
> + if pps:
> + if now - pkt > pps / 10:
> + return True
> + pkt = now
> + elif pkt_cnt:
> + if now - pkt > pkt_cnt:
> + return True
> + return False
> +
> + def wait_pkts_and_stop(self, pkt_cnt):
> + failed = not self._wait_pkts(pkt_cnt=pkt_cnt)
> + self.stop(verbose=failed)
>
> def stop(self, verbose=None):
> self._iperf_client.process(terminate=True)
Powered by blists - more mailing lists