diff mbox series

[ethtool-next,6/6] Symmetric OR-XOR RSS hash

Message ID 20250303121941.105747-7-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
Add an additional type of symmetric RSS hash type: OR-XOR.
The "Symmetric-OR-XOR" algorithm transforms the input as follows:

(SRC_IP | DST_IP, SRC_IP ^ DST_IP, SRC_PORT | DST_PORT, SRC_PORT ^ DST_PORT)

Symmetric OR-XOR can be used through:
ethtool -X eth2 xfrm symmetric-or-xor

Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Gal Pressman <gal@nvidia.com>
---
 ethtool.8.in  | 14 +++++++-------
 ethtool.c     |  7 ++++++-
 netlink/rss.c |  7 ++++++-
 3 files changed, 19 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/ethtool.8.in b/ethtool.8.in
index 9e272f7056a8..ffee0fe5a3b5 100644
--- a/ethtool.8.in
+++ b/ethtool.8.in
@@ -358,7 +358,7 @@  ethtool \- query or control network driver and hardware settings
 .RB ...\ | \ default \ ]
 .RB [ hfunc
 .IR FUNC ]
-.B2 xfrm symmetric-xor none
+.B3 xfrm symmetric-xor symmetric-or-xor none
 .RB [ context
 .I CTX
 .RB |\  new ]
@@ -1253,15 +1253,15 @@  List of RSS hash functions which kernel supports is shown as a part of the --sho
 .TP
 .BI xfrm
 Sets the RSS input transformation. Currently, only the
-.B symmetric-xor
-transformation is supported where the NIC XORs the L3 and/or L4 source and
-destination fields (as selected by
+.B symmetric-xor and symmetric-or-xor
+transformations are supported where the NIC XORs/ORs the L3 and/or L4 source
+and destination fields (as selected by
 .B --config-nfc rx-flow-hash
 ) before passing them to the hash algorithm. The RSS hash function will
 then yield the same hash for the other flow direction where the source and
-destination fields are swapped (i.e. Symmetric RSS). Note that XORing the
-input parameters reduces the entropy of the input set and the hash algorithm
-could potentially be exploited. Switch off (default) by
+destination fields are swapped (i.e. Symmetric RSS). Note that this operation
+reduces the entropy of the input set and the hash algorithm could potentially
+be exploited. Switch off (default) by
 .B xfrm none.
 .TP
 .BI start\  N
diff --git a/ethtool.c b/ethtool.c
index f679f253d490..2df99eefecde 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -4119,6 +4119,9 @@  static int do_grxfh(struct cmd_context *ctx)
 	printf("    symmetric-xor: %s\n",
 	       (rss->input_xfrm & RXH_XFRM_SYM_XOR) ? "on" : "off");
 	rss->input_xfrm &= ~RXH_XFRM_SYM_XOR;
+	printf("    symmetric-or-xor: %s\n",
+	       (rss->input_xfrm & RXH_XFRM_SYM_OR_XOR) ? "on" : "off");
+	rss->input_xfrm &= ~RXH_XFRM_SYM_OR_XOR;
 
 	if (rss->input_xfrm)
 		printf("    Unknown bits in RSS input transformation: 0x%x\n",
@@ -4291,6 +4294,8 @@  static int do_srxfh(struct cmd_context *ctx)
 				exit_bad_args();
 			if (!strcmp(ctx->argp[arg_num], "symmetric-xor"))
 				req_input_xfrm = RXH_XFRM_SYM_XOR;
+			else if (!strcmp(ctx->argp[arg_num], "symmetric-or-xor"))
+				req_input_xfrm = RXH_XFRM_SYM_OR_XOR;
 			else if (!strcmp(ctx->argp[arg_num], "none"))
 				req_input_xfrm = 0;
 			else
@@ -6001,7 +6006,7 @@  static const struct option args[] = {
 			  "		[ equal N | weight W0 W1 ... | default ]\n"
 			  "		[ hkey %x:%x:%x:%x:%x:.... ]\n"
 			  "		[ hfunc FUNC ]\n"
-			  "		[ xfrm symmetric-xor|none ]\n"
+			  "		[ xfrm symmetric-xor | symmetric-or-xor | none ]\n"
 			  "		[ delete ]\n"
 	},
 	{
diff --git a/netlink/rss.c b/netlink/rss.c
index 9ce56c2c687d..83cc50416dc7 100644
--- a/netlink/rss.c
+++ b/netlink/rss.c
@@ -58,7 +58,9 @@  void dump_json_rss_info(struct cmd_context *ctx, u32 *indir_table,
 	open_json_object("rss-input-transformation");
 	print_bool(PRINT_JSON, "symmetric-xor", NULL,
 		   (input_xfrm & RXH_XFRM_SYM_XOR) ? true : false);
-	if (input_xfrm & ~RXH_XFRM_SYM_XOR)
+	print_bool(PRINT_JSON, "symmetric-or-xor", NULL,
+		   (input_xfrm & RXH_XFRM_SYM_OR_XOR) ? true : false);
+	if (input_xfrm & ~(RXH_XFRM_SYM_XOR | RXH_XFRM_SYM_OR_XOR))
 		print_uint(PRINT_JSON, "raw", NULL, input_xfrm);
 
 	close_json_object();
@@ -177,6 +179,9 @@  int rss_reply_cb(const struct nlmsghdr *nlhdr, void *data)
 		printf("    symmetric-xor: %s\n",
 		       (input_xfrm & RXH_XFRM_SYM_XOR) ? "on" : "off");
 		input_xfrm &= ~RXH_XFRM_SYM_XOR;
+		printf("    symmetric-or-xor: %s\n",
+		       (input_xfrm & RXH_XFRM_SYM_OR_XOR) ? "on" : "off");
+		input_xfrm &= ~RXH_XFRM_SYM_OR_XOR;
 
 		if (input_xfrm)
 			printf("    Unknown bits in RSS input transformation: 0x%x\n", input_xfrm);