Skip to contentSkip to conversation

bnxt: Fix failure to report RSS context in ntuple rule

PATCH Applied Daniel Xu 2 participants 4 messages Nov 27, 2024 – Nov 30, 2024

Subsystems (4)
lore
Share & tools
lore

Daniel Xu

author
#0 lore raw

v3 cover bnxt: Fix failure to report RSS context in ntuple rule

This patchset fixes a bug where bnxt driver was failing to report that an ntuple rule is redirecting to an RSS context. First commit is the fix, then second commit extends selftests to detect if other/new drivers are compliant with ntuple/rss_ctx API.

=== Changelog ===

Changes from v2:
* Rebase to net instead of net-next
* Make regex work with ethtool output changes

Changes from v1:
* Add selftest in patch 2

Daniel Xu (2):
bnxt_en: ethtool: Supply ntuple rss context action
selftests: drv-net: rss_ctx: Add test for ntuple rule

 drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c |  8 ++++++--
 tools/testing/selftests/drivers/net/hw/rss_ctx.py | 12 +++++++++++-
 2 files changed, 17 insertions(+), 3 deletions(-)
Signature · 1 line
2.46.0
author
#1 lore raw

PATCH v3 1/2 bnxt_en: ethtool: Supply ntuple rss context action

Commit 2f4f9fe5bf5f ("bnxt_en: Support adding ntuple rules on RSS contexts") added support for redirecting to an RSS context as an ntuple rule action. However, it forgot to update the ETHTOOL_GRXCLSRULE codepath. This caused ethtool -n to always report the action as "Action: Direct to queue 0" which is wrong.

Fix by teaching bnxt driver to report the RSS context when applicable.

Fixes 2f4f9fe5bf5f ("bnxt_en: Support adding ntuple rules on RSS contexts")
---
 drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +6 -2
index f1f6bb328a55..d87681d71106 100644
@@ -1187,10 +1187,14 @@ static int bnxt_grxclsrule(struct bnxt *bp, struct ethtool_rxnfc *cmd)
 		}
 	}
 
-	if (fltr->base.flags & BNXT_ACT_DROP)
+	if (fltr->base.flags & BNXT_ACT_DROP) {
 		fs->ring_cookie = RX_CLS_FLOW_DISC;
-	else
+	} else if (fltr->base.flags & BNXT_ACT_RSS_CTX) {
+		fs->flow_type |= FLOW_RSS;
+		cmd->rss_context = fltr->base.fw_vnic_id;
+	} else {
 		fs->ring_cookie = fltr->base.rxq;
+	}
 	rc = 0;
 
 fltr_err:
Signature · 1 line
2.46.0
author
#2 lore raw

PATCH v3 2/2 selftests: drv-net: rss_ctx: Add test for ntuple rule

In reply to Daniel Xu

Extend the rss_ctx test suite to test that an ntuple action that redirects to an RSS context contains that information in ethtool -n. Otherwise the output from ethtool is highly deceiving. This test helps ensure drivers are compliant with the API.

---
 tools/testing/selftests/drivers/net/hw/rss_ctx.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
tools/testing/selftests/drivers/net/hw/rss_ctx.py +11 -1
index 0b49ce7ae678..ca8a7edff3dd 100755
@@ -3,7 +3,8 @@
 
 import datetime
 import random
-from lib.py import ksft_run, ksft_pr, ksft_exit, ksft_eq, ksft_ne, ksft_ge, ksft_lt
+import re
+from lib.py import ksft_run, ksft_pr, ksft_exit, ksft_eq, ksft_ne, ksft_ge, ksft_lt, ksft_true
 from lib.py import NetDrvEpEnv
 from lib.py import EthtoolFamily, NetdevFamily
 from lib.py import KsftSkipEx, KsftFailEx
@@ -96,6 +97,13 @@ def _send_traffic_check(cfg, port, name, params):
                 f"traffic on inactive queues ({name}): " + str(cnts))
 
 
+def _ntuple_rule_check(cfg, rule_id, ctx_id):
+    """Check that ntuple rule references RSS context ID"""
+    text = ethtool(f"-n {cfg.ifname} rule {rule_id}").stdout
+    pattern = f"RSS Context (ID: )?{ctx_id}"
+    ksft_true(re.search(pattern, text), "RSS context not referenced in ntuple rule")
+
+
 def test_rss_key_indir(cfg):
     """Test basics like updating the main RSS key and indirection table."""
 
@@ -459,6 +467,8 @@ def test_rss_context(cfg, ctx_cnt=1, create_with_cfg=None):
         ntuple = ethtool_create(cfg, "-N", flow)
         defer(ethtool, f"-N {cfg.ifname} delete {ntuple}")
 
+        _ntuple_rule_check(cfg, ntuple, ctx_id)
+
     for i in range(ctx_cnt):
         _send_traffic_check(cfg, ports[i], f"context {i}",
                             { 'target': (2+i*2, 3+i*2),
Signature · 1 line
2.46.0
#3 lore raw
In reply to Daniel Xu
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Wed, 27 Nov 2024 15:58:28 -0700 you wrote:

This patchset fixes a bug where bnxt driver was failing to report that an ntuple rule is redirecting to an RSS context. First commit is the fix, then second commit extends selftests to detect if other/new drivers are compliant with ntuple/rss_ctx API.

=== Changelog ===

[...]

Here is the summary with links:
- [net,v3,1/2] bnxt_en: ethtool: Supply ntuple rss context action

    https://git.kernel.org/netdev/net/c/be75cda92a65
  - [net,v3,2/2] selftests: drv-net: rss_ctx: Add test for ntuple rule
    https://git.kernel.org/netdev/net/c/7078d43b2374

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html