From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.50 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796342742; b=bGxd3M5bUGnWmtipfVNGZGM2WObdFPqdzhSOlasuQq2prqnXLkWEu1eYPq944eWerMbW 6h0vljG0ohgW7b/AkcyspgvThdS3QASu2SzaZFlFd1lYOqiNlgx+90CjIsdZWa22po7sx 5cwtBtnpmrQaWN/qZSlOCCMewZqLD+Wei+fvMCfBcrC17VP6LHMyGK2QYe3kvQlukDjAF PykNTFpHXOCtgRdSNpNNyr5ve2i/z6u5mqJ2q6CTUDREhYM6jqEhDDdmPr9Oq0wyQsuCV BBQJtHtkpxXdCc0amJOF4npuD5U9H0OTOc91VfzvUhf/PbIfOY1Zf3o0fQSitzc98mg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796342742; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=gsXoP6kjKXvWEElwaLibgpYc6AVIlhcjNUDWlFMTr/Q=; b=XjbLbDgEDluFacIRnUD6e03HwjkBU/TOtYdKJQJkrMg8pmTdfSWRZuwCV0pCVdnRoER9 7zw96SIY8oakvBCfCM4pgYtWAcL1t2vX1YyXKK8bE1yGyu1nxYLIymfhTFUrvR7hnynfj M6KXFTs8LeWCDHJL8RSdkwtbUlcRPHNQkxaVTgtGqMgZNQbdkKaL5hDQQxtEteqmS1VGU ElpftJiUn38VW/VcmUtBUEWHMxPyo6GUoNw4skNwZsHF14ltxW4VaRsR8AuL2qTiBf6yt 9MigtvNhBJAwtQ+des7HavsZv0APex5MmALytXK2oMI7jm2onNVtwNrNCxUGEpQZ1Ww== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=oYcKcbZK; arc=none smtp.remote-ip=209.85.128.50 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53CEF606A686 for ; Fri, 4 Dec 2026 00:05:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 53CEF606A686 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=oYcKcbZK Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4bb85e07aadso3651075e9.1 for ; Thu, 03 Dec 2026 16:05:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796342740; x=1796947540; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=gsXoP6kjKXvWEElwaLibgpYc6AVIlhcjNUDWlFMTr/Q=; b=oYcKcbZKeM/LOM4EsJc6UL//egH6AdxXkpcqMf7haZGnQEUi1ecRX2PdsXux6e1e4Q lbRrA01wDQHgdYDeNaupXJH/bdpkHnqBtiXHn5idjRfVpkmxCNdipPF7Ehh4RZ1Rrol5 zulo3SwJ4U1/fITLjwaqivyI8CmGHFatHUmCYog+Hk0KjBsnGvgkFkttutZ0lob8oBbS o95Jd9xZuywatmvB77jXCNn9cF0ljjtFBatz5jJjDwF54YdWk05MUuWep3/KOtm/KcQ1 KRWZt29irMbZw7QjnfOVOyTGcMo8WVx8/FLD79vJyokmIY24+XirhLMbjZ3iDOjv/OSp INpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796342740; x=1796947540; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=gsXoP6kjKXvWEElwaLibgpYc6AVIlhcjNUDWlFMTr/Q=; b=x6I7kRKUeKN7rudsPKAUKCFSUNfl5r3VK2vTX/S6oG6coR648wSd5fGqKh3zkCNZrS J8KoPKdbWa/nJv0fIqkHeXie5sKTfxR2aIpXW5qOdm/bKAuAKPSIviSmAoUZo7cgKu11 dPKWMmoZU7LbPFSi2YhzcO4bq4xY3a8KHKlaAVV9g+/mfuwjggCDAYYxR+HjZiEEY/8d JYaJtFafqjkYeb4FTqAapeLdmTrLJwDfJAGQ+tygzGRlanhZ479KMTkl45RBXgNNOIa3 Hxl6BLO6h4oDOBtb/dVqLRZHbYSMDB2ASaemQFVZ6JlI8NAFSUiTcZPuDv53aO4muath IOOg== X-Gm-Message-State: APuU4Z+m1dqekkebu+PZM0xv15Z97GZ3tsBB3IULkQkXb+vxUuuH6LJx x+BtoNwTIamLpk/2yGlsH5pnD/Yy3gHCIkeYBbJ1meJQmBaV8xDVt0YmpEnlBbu2 X-Gm-Gg: AZFdTZe3PCkaenfnIjzeJ7daKs8wOWGSplzhIHx9uQSLqyq+7QMFT3sx0scRcTFUQe4 l6iia05JAuBhY8HFVw7Xn20lEJmJxtbCptADoU4FPTlUb2aiGGo3xTbe+KCCEEnXo1nghnJBKGT BykTxYD7EWoPdl/bw7d+npHd0jVpEJXLZrDpHrhKB2Eo1xHAFCZ+zR07M8edDlY2Es+u4rXtE1D lchAGX7uK9G1rxsgbLzFvOdMtZQCm8jCDKTTY72dKghQMCK5K/UVciuzkC3EBCUdCm0PczMkfu8 0kcUFr8CXPS1wUyyvBWt0fr4AhRAoxWy3buD7cyd/kqhOTlzo8bsKaTmj9NpT/XUuXPoMk4Bpqn D4NxSM53QqGFTDiW88WDb2JgJMPPnQSG2AzIr3B0RlcVkKfcSYbFZMgT68C8mZGVEs84V5S/NB9 Xi7w7HLT6jQOVRFvUkvMy9DNEDC5EQjkg78p99uiT21O33TSKjUYrWXWJvrKrvx+O4t72wkje59 Dj0SdJ63uLRKg3+gZxlHojobW/Q8Xkp7vQnQehvTIdVaCj3cRG/WOk2SF809kraryHRI1m3Pnyt 6RwcBbRqNlB3pwdO7g/008txUpk= X-Received: by 2002:a05:600c:4504:b0:4bb:60bd:53b2 with SMTP id 5b1f17b1804b1-4bbeb84cce6mr4560785e9.6.1796342739555; Thu, 03 Dec 2026 16:05:39 -0800 (PST) Received: from localhost ([2a03:2880:31ff:59::]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bbea285a26sm11955695e9.7.2026.12.03.16.05.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2026 16:05:39 -0800 (PST) From: Mohsin Bashir To: netdev@vger.kernel.org Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, shuah@kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 06/11] selftests: drv-net: tc_flower_police: Test police parameters Date: Thu, 3 Dec 2026 16:05:16 -0800 Message-ID: <20261204000521.3396802-7-mohsin.bashr@gmail.com> X-Mailer: git-send-email 2.53.1 In-Reply-To: <20261204000521.3396802-1-mohsin.bashr@gmail.com> References: <20261204000521.3396802-1-mohsin.bashr@gmail.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Mohsin Bashir act_police supports more than a rate and a burst, and drivers usually offload only a subset of it. Add police_params to cover the pipe exceed action, peak rate, overhead and packet rate, and verify that traffic shows the effect of each option the device accepts. If the device rejects an option, the test checks that a plain police rule still works and skips. A rejected rule must not be left behind. Signed-off-by: Jakub Kicinski Signed-off-by: Mohsin Bashir --- .../drivers/net/hw/tc_flower_police.py | 56 +++++++++++++++++-- 1 file changed, 52 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/drivers/net/hw/tc_flower_police.py b/tools/testing/selftests/drivers/net/hw/tc_flower_police.py index cdff5cb6b6a3..66d32f6e13f7 100755 --- a/tools/testing/selftests/drivers/net/hw/tc_flower_police.py +++ b/tools/testing/selftests/drivers/net/hw/tc_flower_police.py @@ -9,6 +9,7 @@ import tempfile import time from lib.py import ksft_run, ksft_exit, ksft_pr from lib.py import ksft_eq, ksft_ge +from lib.py import ksft_variants, KsftNamedVariant from lib.py import CmdExitFailure, KsftSkipEx, KsftXfailEx, KsftFailEx from lib.py import Iperf3Runner, NetDrvEpEnv from lib.py import set_ethtool_feat @@ -68,9 +69,9 @@ def _add_secondary_addr(cfg, want=None): return addr -def _police(rate_mbit): +def _police(rate_mbit, extra="", exceed="drop"): return (f"action police rate {rate_mbit}mbit burst 1m " - "conform-exceed drop/ok") + f"conform-exceed {exceed}/ok {extra}") def _try_filter(cfg, rule, action, pref): @@ -82,10 +83,16 @@ def _try_filter(cfg, rule, action, pref): return res.ret == 0, res.stderr.strip() -def _add_filter(cfg, rule, action, pref): +def _add_filter(cfg, rule, action, pref, dst=None): added, err = _try_filter(cfg, rule, action, pref) if not added: raise KsftSkipEx(f"Rule not offloaded: {err}") + if dst is None: + return + got = _iperf3(cfg, dst, OFFERED_MBIT) + if not _check_rate(got, RATE_MBIT, f"rule at pref {pref}"): + raise KsftFailEx(f"Police rule at pref {pref} not at the " + "expected rate") def _filter_info(cfg, pref): @@ -330,6 +337,46 @@ def police_dst_prefix(cfg): ksft_pr("LOCAL_PREFIX_V6 is a /120, shorter masks not checked") +@ksft_variants([ + KsftNamedVariant("exceed_pipe", + f"{_police(RATE_MBIT, exceed='pipe')} " + f"{_police(RATE_MBIT // 2)}", + RATE_MBIT + RATE_MBIT // 2), + KsftNamedVariant("peakrate", + _police(OFFERED_MBIT * 2, + extra=f"peakrate {RATE_MBIT}mbit mtu 65535"), + RATE_MBIT), + KsftNamedVariant("overhead", + _police(RATE_MBIT, extra=f"overhead {UDP_PAYLOAD}"), + RATE_MBIT * IP6_PKT_LEN / (IP6_PKT_LEN + UDP_PAYLOAD)), + KsftNamedVariant("pkts_rate", + "action police pkts_rate 1000 pkts_burst 100 " + "conform-exceed drop/ok", 1000 * IP6_PKT_LEN * 8 / 1e6), +]) +def police_params(cfg, action, expect): + """ + Check police parameters beyond the rate and burst. A device that + offloads the rule must limit the traffic as configured. A device may + reject it, and a plain police rule must then still limit the traffic, + after which the case is skipped. + """ + _setup_clsact(cfg) + rule, dst = _dst_ip_rule(cfg) + + _check_baseline_rate(cfg) + added, err = _try_filter(cfg, rule, action, pref=10) + if added: + got = _iperf3(cfg, dst, OFFERED_MBIT) + _check_rate(got, expect, "policed flow") + return + + if _filter_info(cfg, 10) is not None: + raise KsftFailEx(f"Rejected filter left behind: {err}") + _add_filter(cfg, rule, _police(RATE_MBIT), pref=10, dst=dst) + reason = err.partition("\n")[0] + raise KsftSkipEx(f"Not offloaded: {reason}") + + def main() -> None: """Ksft boilerplate main.""" with NetDrvEpEnv(__file__, nsim_test=False) as cfg: @@ -339,7 +386,8 @@ def main() -> None: link_baseline, police_rate, police_isolation, - police_dst_prefix], + police_dst_prefix, + police_params], args=(cfg,)) ksft_exit() -- 2.53.1-Meta