From patchwork Tue Jun 25 01:02:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13710413 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E16A14F90 for ; Tue, 25 Jun 2024 01:02:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719277338; cv=none; b=ECyInky0GKnLj3RTMrXw3LSNR7V3THK8o64GFb6E6ZwDe8Y19zWHXKbqB9A99jhyO/2IF8OHskkot/rnXd00ruM2fzwlXhSEMGmy5G3m1F6h0mfqubZxYdy8t8Ad7u1dK2SLKcnWrO93E763OZhr6tTtjtGKLBWfmypyJdenw2s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719277338; c=relaxed/simple; bh=jZ8DSddvi4lfHZNfs+mmODAv1DgGGomOEOwTkLPBc9o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QIruwfmdhNCb3UKcy1pNNXzVPQe9Ki0a6MkAanauhbnnMY3jktUa0/p2uAKmp1MlSPHcyslbBf9TWZIxN/RXfw82fJS1ZCDLg9puQOeTklzW70W8AAGmImGAJmTgzKmAYlYfaFavAyPfsZ1bTazMcw7ZflgZUTkmuIb5oAUQalo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rfws6rEx; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rfws6rEx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2F4BC4AF5F; Tue, 25 Jun 2024 01:02:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719277337; bh=jZ8DSddvi4lfHZNfs+mmODAv1DgGGomOEOwTkLPBc9o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rfws6rExXwtNwc/xR3H3E3PT3P4cD+lfRS8Iv5SxoohJVmP1ANM8pZQFhiWj2ilwK nVgkUSVZnrINAWRjdkzIlU1vYFQ3XXhBPd9XAiJBSQtQqSwvc65ZzPil5WVuOLLQ9D nY16YYC3FkxdB6wWCT6Iu1j8qfCLJyO8giEdNcRM8uVL/AKn27MOk4iFFCx6AiQWLM eRRSCSouF/aFNbPM3B2e603dzcZ7bLWH3MHoQ2wLGpf4jiBNAHNp0NOm+rdt+Gjg7r qXlNNunmOs9pBG+rSQ1abBdWy805T8XRWofDFIXN4RxAg1vU2suJUKFWVZ384B+9qH 00eQmmoXRZ3/Q== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, willemdebruijn.kernel@gmail.com, ecree.xilinx@gmail.com, dw@davidwei.uk, przemyslaw.kitszel@intel.com, michael.chan@broadcom.com, andrew.gospodarek@broadcom.com, Jakub Kicinski Subject: [PATCH net-next v2 3/4] selftests: drv-net: add ability to wait for at least N packets to load gen Date: Mon, 24 Jun 2024 18:02:09 -0700 Message-ID: <20240625010210.2002310-4-kuba@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240625010210.2002310-1-kuba@kernel.org> References: <20240625010210.2002310-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org 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 --- v2: - add comment that pps or pkt_cnt are mutually exclusive (David) - rename variables (David) --- .../selftests/drivers/net/lib/py/load.py | 30 ++++++++++++++----- 1 file changed, 23 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..31f82f1e32c1 100644 --- a/tools/testing/selftests/drivers/net/lib/py/load.py +++ b/tools/testing/selftests/drivers/net/lib/py/load.py @@ -18,15 +18,31 @@ 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): + """ + Wait until we've seen pkt_cnt or until traffic ramps up to pps. + Only one of pkt_cnt or pss can be specified. + """ + pkt_end = 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") + pkt_start = ip("-s link show dev " + self.env.ifname, json=True)[0]["stats64"]["rx"]["packets"] + if pps: + if pkt_start - pkt_end > pps / 10: + return True + pkt_end = pkt_start + elif pkt_cnt: + if pkt_start - pkt_end > 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)