From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f52.google.com (mail-oo1-f52.google.com [209.85.161.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 954143C3F7C for ; Wed, 5 Aug 2026 03:09:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785899394; cv=none; b=nNt9w0k3TruNobX8LRMsy2ric5HVNSLbShadfOdpfiPgnbyCV2fAbrENp09HfpUYKwMYz7RerZLCP/LEZqTHSPE4NrpuMjGxhsSduOtlC4MmIPuxw8+/7sxfSaoU7TG6uRhqrcRwDvxhlmZGXEcdso9gRv5NnZi+Bo/xKA4+UXM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785899394; c=relaxed/simple; bh=PE7ifyCGoFgRy7ddoLf7ecEm718DOJWN2jboMYBlwCo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=minQpGoPE4H1ttaV0LPF/UPJFd0pxZCKaNkjVcaWlfYEeZk3qmMAuuRRxY0B+HGH8X/ntRX2tOm5MAfwIrOy6xaae52jXD6YDvt/xjdn5TF+tnPUA0Gf6hO+c6/xP/UFZjqEW3M5hBeGo3HyWCB3wJIwdavevqHAxlDNaguuhCA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HBb7gtoj; arc=none smtp.client-ip=209.85.161.52 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.b="HBb7gtoj" Received: by mail-oo1-f52.google.com with SMTP id 006d021491bc7-6ae5baaef5dso483684eaf.1 for ; Tue, 04 Aug 2026 20:09:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785899391; x=1786504191; 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=Lf+95Lv9aBLdQ2fxeuuLQftB8DvcOe6MQ4BDksXA8qc=; b=HBb7gtojsfYlAkR1l0hQQZN5GlTdFPTu30bKeB6GWNVz7aYoEdx2pleAntMWnkYOZo fXrVRSixOCjqGcA3orqqd2VjtkaICVXB8CG7tvNKt+g5WgCwjUJFwwCR5V8hkFJxEJjZ uAUA2GIqwITDBtTNSn7arbs8hB+XezdcDpBdvW1gmSd7gTqYo9fDr+jEws/OC3JOgnhe W+qMBjLf9vqv2G9E+9NODTkQ5xLToGSPZz8Il5sCPYctaxErHc8uyaPKa5FVi2MpZ1o2 aPhjEbKF8gdEYd9duNFBVpiy/sgVKJ5OA30H4Z9+cDPzxWrjXpbr6k9AjEDEEe8qwpC1 snGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785899391; x=1786504191; 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=Lf+95Lv9aBLdQ2fxeuuLQftB8DvcOe6MQ4BDksXA8qc=; b=imgO/gyL2t2cUfmhAX17L49M9mbit0O2Rd2xBHT3Gae52fnztZGzGEDnn4gKbhORB4 W0i2rYY7Y+GpI3n2rrG3Lhd0W0ljgYk7IZDtOwR/t5ELFghmo0eT1J0602xX6Hjuj2/3 rtHP1b0CfI3m/akmt1ciIRJ5dyWuNJo+caHr30fMGawpxp85xSEY0je/DFShXxZZKQ7c djDjl6/Vw1TXpEq4h0Cu5xyUuLjDdJG/oiFKBQ8keBJ8MfLc/mQAJZ1oIyZuxOiVxC1Q Liuq3ydVw9N2k1xBn5OzcvFf8WG/S/dGGJBQW8wCgeBxD5/lZCzuQiri3DEYVVom0zzT JgXg== X-Forwarded-Encrypted: i=1; AHgh+RrI7TXlJqj9FK6LQfi6qkNgsq8AB3PiilDuqcJONP6H1GUQe+6dcxrwgKcCrxkZ7cKfV5wjzmMcXBVm8lI=@vger.kernel.org X-Gm-Message-State: AOJu0YwGS25GhP6qniAnbvzbWzzFvf6oZTtRVsgaa10gTHzKChEvuuqP QhQl+FceupQI/iASBvjOLYiFeRiHgo9jc8/OXazigiW9wOzl8YPZdBo9 X-Gm-Gg: AR+sD12BMUHnQXui6d4IcjOJ7ziqR2B8ej+6SPks52Aw2KXs9BxEho/kdxeg7RadSDF 6pz8aQ2U6ZTDDc4oFSJnOWeHpU32GOEmEo2kNkNRdkU3nJ8mpREoaZaooYK9N+Zv15UIHQvwvh8 FtxMpIqCiHvqjwnLeZb+nt1TNbvsGAQLwzwjfufL814Wq8VQK5jbQsHZFn1q5X3imMxryqP36Sz qw5cn7Q88f23eQBD/86bPBrva24/HXxVYSpnr0V1I9cftuG0EJ6G/4NGvPbdOorE3UuNL1y3g61 5djGXDs+77CHCwvNKeziIwfVT5t3aa8MFgLnPMQ+tFKm25Tu3NaLPXnL/SokwlhBQawhA7WyGDC ljxNcOVjLiR65O+lMvYoEQ6EeKMJXKRZpKcyMV5FpiyzMV8E7lN4RGQ7jUW8akE8LmIG4CUZHIG fDUGtfkwGwgCFgNszbyP04PPs/zqt5q2Qp2Ofljepm3ihS2UeBRexlKwc9 X-Received: by 2002:a4a:edca:0:b0:6ae:7f68:22f3 with SMTP id 006d021491bc7-6ae82a9ea9amr7666929eaf.16.1785899391072; Tue, 04 Aug 2026 20:09:51 -0700 (PDT) Received: from localhost ([2a03:2880:31ff:8::]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7f1df5a4f9bsm2087676a34.23.2026.08.04.20.09.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 20:09:50 -0700 (PDT) From: Mohsin Bashir To: netdev@vger.kernel.org Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, pabeni@redhat.com, shuah@kernel.org, alexander.duyck@gmail.com Subject: [PATCH net-next 04/14] selftests: net: shaper: Add basic_groups_with_rate test Date: Tue, 4 Aug 2026 20:09:26 -0700 Message-ID: <20260805030936.1092907-5-mohsin.bashr@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260805030936.1092907-1-mohsin.bashr@gmail.com> References: <20260805030936.1092907-1-mohsin.bashr@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Mohsin Bashir Add a test that groups queues under the netdev parent with rate limiting enabled. Extract the common group-under-netdev flow into _group_under_netdev helper to share with basic_groups. The test independently checks for netdev scope bw_max and metric capabilities before proceeding, and verifies that the netdev shaper persists after leaf deletion. Signed-off-by: Jakub Kicinski Signed-off-by: Mohsin Bashir --- tools/testing/selftests/drivers/net/shaper.py | 83 +++++++++++++++---- 1 file changed, 68 insertions(+), 15 deletions(-) diff --git a/tools/testing/selftests/drivers/net/shaper.py b/tools/testing/selftests/drivers/net/shaper.py index 45a4bf42995e..168a8dd057e5 100755 --- a/tools/testing/selftests/drivers/net/shaper.py +++ b/tools/testing/selftests/drivers/net/shaper.py @@ -167,20 +167,25 @@ def del_nshapers(cfg, nl_shaper) -> None: shapers = nl_shaper.get({'ifindex': cfg.ifindex}, dump=True) ksft_eq(len(shapers), 0) -def basic_groups(cfg, nl_shaper) -> None: - _require_queues(cfg, 3) - - _require_caps(cfg, nl_shaper, 'netdev', [], "netdev scope not supported by the device") - _require_caps(cfg, nl_shaper, 'queue', ['support-nesting', 'support-weight'], - "queue scope not supported with nesting and weight") - - node_handle = nl_shaper.group({ - 'ifindex': cfg.ifindex, - 'leaves':[{'handle': {'scope': 'queue', 'id': 1}, - 'weight': 1}, - {'handle': {'scope': 'queue', 'id': 2}, - 'weight': 2}], - 'handle': {'scope':'netdev'}}) +def _group_under_netdev(cfg, nl_shaper, bw_max=None): + r"""Group queues under a netdev-scope node; caller owns node teardown. + + netdev netdev + / \ del Q1,Q2 + Q1 Q2 -------> (netdev node persists) + """ + group_args = { + 'ifindex': cfg.ifindex, + 'leaves': [{'handle': {'scope': 'queue', 'id': 1}, + 'weight': 1}, + {'handle': {'scope': 'queue', 'id': 2}, + 'weight': 2}], + 'handle': {'scope': 'netdev'}} + if bw_max: + group_args['metric'] = 'bps' + group_args['bw-max'] = bw_max + + node_handle = nl_shaper.group(group_args) ksft_eq(node_handle, {'ifindex': cfg.ifindex, 'handle': {'scope': 'netdev'}}) @@ -194,10 +199,29 @@ def basic_groups(cfg, nl_shaper) -> None: ksft_eq(shaper, {'ifindex': cfg.ifindex, 'parent': {'scope': 'netdev'}, 'handle': {'scope': 'queue', 'id': 1}, - 'weight': 1 }) + 'weight': 1}) for dq in del_queues: dq.exec() + # Caller owns the node teardown so it can verify the netdev-scope node + # survives leaf deletion before removing it. + return del_node + +def basic_groups(cfg, nl_shaper) -> None: + r"""Group queues under a netdev-scope node, then tear it down. + + netdev + / \ + Q1 Q2 + """ + _require_queues(cfg, 3) + + _require_caps(cfg, nl_shaper, 'netdev', [], "netdev scope not supported by the device") + _require_caps(cfg, nl_shaper, 'queue', ['support-nesting', 'support-weight'], + "queue scope not supported with nesting and weight") + + del_node = _group_under_netdev(cfg, nl_shaper) + shapers = nl_shaper.get({'ifindex': cfg.ifindex}, dump=True) ksft_eq(shapers, [{'ifindex': cfg.ifindex, 'handle': {'scope': 'netdev'}}]) @@ -206,6 +230,34 @@ def basic_groups(cfg, nl_shaper) -> None: shapers = nl_shaper.get({'ifindex': cfg.ifindex}, dump=True) ksft_eq(len(shapers), 0) +def basic_groups_with_rate(cfg, nl_shaper) -> None: + r"""Rate-limited netdev-scope node outlives deletion of its leaves. + + netdev[10kbps] netdev[10kbps] + / \ del Q1,Q2 + Q1 Q2 -------> (node persists) + """ + bw_max = 10000 + + _require_queues(cfg, 3) + + _require_caps(cfg, nl_shaper, 'netdev', ['support-bw-max', 'support-metric-bps'], + "device does not support netdev scope rate limiting") + _require_caps(cfg, nl_shaper, 'queue', ['support-nesting', 'support-weight'], + "device does not support queue scope shapers with nesting and weight") + + del_node = _group_under_netdev(cfg, nl_shaper, bw_max=bw_max) + + # Deleting all the leaves shaper does not affect the node one + # when the latter has 'netdev' scope. + shapers = nl_shaper.get({'ifindex': cfg.ifindex}, dump=True) + ksft_eq(shapers, [{'ifindex': cfg.ifindex, + 'handle': {'scope': 'netdev'}, + 'metric': 'bps', + 'bw-max': bw_max}]) + + del_node.exec() + def qgroups(cfg, nl_shaper) -> None: _require_queues(cfg, 4) _require_caps(cfg, nl_shaper, 'node', @@ -488,6 +540,7 @@ def main() -> None: set_nshapers, del_nshapers, basic_groups, + basic_groups_with_rate, qgroups, delegation, dup_leaves, -- 2.53.0-Meta