diff mbox series

[ethtool-next,2/6] Print unknown RSS hash function value when encountered

Message ID 20250303121941.105747-3-gal@nvidia.com (mailing list archive)
State New
Delegated to: Michal Kubecek
Headers show
Series Symmetric OR-XOR RSS hash | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch, async

Commit Message

Gal Pressman March 3, 2025, 12:19 p.m. UTC
It is possible for the kernel to report unknown RSS hash function, for
example, when a new driver which uses a new hash function by default is
used with an old userspace ethtool.

When such hash function is encountered, print its raw value so the user
is at least aware that some unparsable function is used.

Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Gal Pressman <gal@nvidia.com>
---
 ethtool.c     | 6 +++++-
 netlink/rss.c | 7 +++++++
 2 files changed, 12 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/ethtool.c b/ethtool.c
index a1393bc14b7b..712e5b4fbceb 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -4106,10 +4106,14 @@  static int do_grxfh(struct cmd_context *ctx)
 		return 1;
 	}
 
-	for (i = 0; i < hfuncs->len; i++)
+	for (i = 0; i < hfuncs->len; i++) {
 		printf("    %s: %s\n",
 		       (const char *)hfuncs->data + i * ETH_GSTRING_LEN,
 		       (rss->hfunc & (1 << i)) ? "on" : "off");
+		rss->hfunc &= ~(1 << i);
+	}
+	if (rss->hfunc)
+		printf("    Unknown hash function: 0x%x\n", rss->hfunc);
 
 	printf("RSS input transformation:\n");
 	printf("    symmetric-xor: %s\n",
diff --git a/netlink/rss.c b/netlink/rss.c
index 0ee8a0dbaaa2..7a8c4e5e7379 100644
--- a/netlink/rss.c
+++ b/netlink/rss.c
@@ -56,6 +56,9 @@  void dump_json_rss_info(struct cmd_context *ctx, u32 *indir_table,
 				break;
 			}
 		}
+
+		if (i == get_count(hash_funcs))
+			print_uint(PRINT_JSON, "rss-hash-function-raw", NULL, hfunc);
 	}
 
 	close_json_object();
@@ -163,7 +166,11 @@  int rss_reply_cb(const struct nlmsghdr *nlhdr, void *data)
 		for (unsigned int i = 0; i < get_count(hash_funcs); i++) {
 			printf("    %s: %s\n", get_string(hash_funcs, i),
 			       (rss_hfunc & (1 << i)) ? "on" : "off");
+			rss_hfunc &= ~(1 << i);
 		}
+		if (rss_hfunc)
+			printf("    Unknown hash function: 0x%x\n", rss_hfunc);
+
 		printf("RSS input transformation:\n");
 		printf("    symmetric-xor: %s\n",
 		       (input_xfrm & RXH_XFRM_SYM_XOR) ? "on" : "off");