diff mbox series

[ethtool,v2] ethtool: add support for RSS input transformation

Message ID 20240202202520.70162-1-ahmed.zaki@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Michal Kubecek
Headers show
Series [ethtool,v2] ethtool: add support for RSS input transformation | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Ahmed Zaki Feb. 2, 2024, 8:25 p.m. UTC
Add support for RSS input transformation [1]. Currently, only symmetric-xor
is supported. The user can set the RSS input transformation via:

    # ethtool -X <dev> xfrm symmetric-xor

and sets it off (default) by:

    # ethtool -X <dev> xfrm none

The status of the transformation is reported by a new section at the end
of "ethtool -x":

    # ethtool -x <dev>
      .
      .
      .
      .
      RSS hash function:
          toeplitz: on
          xor: off
          crc32: off
      RSS input transformation:
          symmetric-xor: on

Link: https://lore.kernel.org/netdev/20231213003321.605376-1-ahmed.zaki@intel.com/
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Signed-off-by: Ahmed Zaki <ahmed.zaki@intel.com>
---
v2: add a note in the man page on the loss of entropy due to XORing.

 ethtool.8.in  | 14 ++++++++++++++
 ethtool.c     | 16 ++++++++++++++++
 netlink/rss.c | 19 +++++++++++++++++--
 3 files changed, 47 insertions(+), 2 deletions(-)

Comments

Jakub Kicinski Feb. 3, 2024, 2:33 a.m. UTC | #1
On Fri,  2 Feb 2024 13:25:20 -0700 Ahmed Zaki wrote:
> Add support for RSS input transformation [1]. Currently, only symmetric-xor
> is supported. The user can set the RSS input transformation via:
> 
>     # ethtool -X <dev> xfrm symmetric-xor
> 
> and sets it off (default) by:
> 
>     # ethtool -X <dev> xfrm none
> 
> The status of the transformation is reported by a new section at the end
> of "ethtool -x":
> 
>     # ethtool -x <dev>
>       .
>       .
>       .
>       .
>       RSS hash function:
>           toeplitz: on
>           xor: off
>           crc32: off
>       RSS input transformation:
>           symmetric-xor: on
> 
> Link: https://lore.kernel.org/netdev/20231213003321.605376-1-ahmed.zaki@intel.com/
> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> Signed-off-by: Ahmed Zaki <ahmed.zaki@intel.com>

Acked-by: Jakub Kicinski <kuba@kernel.org>

Thanks!
Ahmed Zaki Feb. 21, 2024, 2:54 p.m. UTC | #2
On 2024-02-02 7:33 p.m., Jakub Kicinski wrote:
> On Fri,  2 Feb 2024 13:25:20 -0700 Ahmed Zaki wrote:
>> Add support for RSS input transformation [1]. Currently, only symmetric-xor
>> is supported. The user can set the RSS input transformation via:
>>
>>      # ethtool -X <dev> xfrm symmetric-xor
>>
>> and sets it off (default) by:
>>
>>      # ethtool -X <dev> xfrm none
>>
>> The status of the transformation is reported by a new section at the end
>> of "ethtool -x":
>>
>>      # ethtool -x <dev>
>>        .
>>        .
>>        .
>>        .
>>        RSS hash function:
>>            toeplitz: on
>>            xor: off
>>            crc32: off
>>        RSS input transformation:
>>            symmetric-xor: on
>>
>> Link: https://lore.kernel.org/netdev/20231213003321.605376-1-ahmed.zaki@intel.com/
>> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
>> Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
>> Signed-off-by: Ahmed Zaki <ahmed.zaki@intel.com>
> 
> Acked-by: Jakub Kicinski <kuba@kernel.org>
> 
> Thanks!

I am not sure what is the status with this. patchwork is showing it as 
archived.

We are close to the end of the release cycle and I am worried there 
might be last minute requests.

Thanks.
Jakub Kicinski Feb. 21, 2024, 6:24 p.m. UTC | #3
On Wed, 21 Feb 2024 07:54:13 -0700 Ahmed Zaki wrote:
> On 2024-02-02 7:33 p.m., Jakub Kicinski wrote:
> > On Fri,  2 Feb 2024 13:25:20 -0700 Ahmed Zaki wrote:  
> >> Add support for RSS input transformation [1]. Currently, only symmetric-xor
> >> is supported. The user can set the RSS input transformation via:
> >>
> >>      # ethtool -X <dev> xfrm symmetric-xor
> >>
> >> and sets it off (default) by:
> >>
> >>      # ethtool -X <dev> xfrm none
> >>
> >> The status of the transformation is reported by a new section at the end
> >> of "ethtool -x":
> >>
> >>      # ethtool -x <dev>
> >>        .
> >>        .
> >>        .
> >>        .
> >>        RSS hash function:
> >>            toeplitz: on
> >>            xor: off
> >>            crc32: off
> >>        RSS input transformation:
> >>            symmetric-xor: on
> >>
> >> Link: https://lore.kernel.org/netdev/20231213003321.605376-1-ahmed.zaki@intel.com/
> >> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
> >> Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> >> Signed-off-by: Ahmed Zaki <ahmed.zaki@intel.com>  
> > 
> > Acked-by: Jakub Kicinski <kuba@kernel.org>
> > 
> > Thanks!  
> 
> I am not sure what is the status with this. patchwork is showing it as 
> archived.
> 
> We are close to the end of the release cycle and I am worried there 
> might be last minute requests.

patchwork auto-archives after a month. Michal, would you be able to
scan thru ethtool patches at least once every three weeks to avoid this?
Ahmed Zaki March 11, 2024, 3:12 p.m. UTC | #4
On 2024-02-21 11:24 a.m., Jakub Kicinski wrote:
> On Wed, 21 Feb 2024 07:54:13 -0700 Ahmed Zaki wrote:
>> On 2024-02-02 7:33 p.m., Jakub Kicinski wrote:
>>> On Fri,  2 Feb 2024 13:25:20 -0700 Ahmed Zaki wrote:
>>>> Add support for RSS input transformation [1]. Currently, only symmetric-xor
>>>> is supported. The user can set the RSS input transformation via:
>>>>
>>>>       # ethtool -X <dev> xfrm symmetric-xor
>>>>
>>>> and sets it off (default) by:
>>>>
>>>>       # ethtool -X <dev> xfrm none
>>>>
>>>> The status of the transformation is reported by a new section at the end
>>>> of "ethtool -x":
>>>>
>>>>       # ethtool -x <dev>
>>>>         .
>>>>         .
>>>>         .
>>>>         .
>>>>         RSS hash function:
>>>>             toeplitz: on
>>>>             xor: off
>>>>             crc32: off
>>>>         RSS input transformation:
>>>>             symmetric-xor: on
>>>>
>>>> Link: https://lore.kernel.org/netdev/20231213003321.605376-1-ahmed.zaki@intel.com/
>>>> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
>>>> Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
>>>> Signed-off-by: Ahmed Zaki <ahmed.zaki@intel.com>
>>>
>>> Acked-by: Jakub Kicinski <kuba@kernel.org>
>>>
>>> Thanks!
>>
>> I am not sure what is the status with this. patchwork is showing it as
>> archived.
>>
>> We are close to the end of the release cycle and I am worried there
>> might be last minute requests.
> 
> patchwork auto-archives after a month. Michal, would you be able to
> scan thru ethtool patches at least once every three weeks to avoid this?

Hello Michal,

This was auto-archived a while ago by patchwork, but it should be 
included in ethtool 6.8.

Please let me know if you need a RESEND or any other changes.

Thanks.
diff mbox series

Patch

diff --git a/ethtool.8.in b/ethtool.8.in
index 7a3080f..5924b8d 100644
--- a/ethtool.8.in
+++ b/ethtool.8.in
@@ -351,6 +351,7 @@  ethtool \- query or control network driver and hardware settings
 .RB ...\ | \ default \ ]
 .RB [ hfunc
 .IR FUNC ]
+.B2 xfrm symmetric-xor none
 .RB [ context
 .I CTX
 .RB |\  new ]
@@ -1201,6 +1202,19 @@  even if a nibble is zero.
 Sets RSS hash function of the specified network device.
 List of RSS hash functions which kernel supports is shown as a part of the --show-rxfh command output.
 .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 --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
+.B xfrm none.
+.TP
 .BI start\  N
 For the \fBequal\fR and \fBweight\fR options, sets the starting receive queue
 for spreading flows to \fIN\fR.
diff --git a/ethtool.c b/ethtool.c
index 3ac15a7..82919f8 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -4029,6 +4029,10 @@  static int do_grxfh(struct cmd_context *ctx)
 		       (const char *)hfuncs->data + i * ETH_GSTRING_LEN,
 		       (rss->hfunc & (1 << i)) ? "on" : "off");
 
+	printf("RSS input transformation:\n");
+	printf("    symmetric-xor: %s\n",
+	       (rss->input_xfrm & RXH_XFRM_SYM_XOR) ? "on" : "off");
+
 out:
 	free(hfuncs);
 	free(rss);
@@ -4146,6 +4150,7 @@  static int do_srxfh(struct cmd_context *ctx)
 	u32 arg_num = 0, indir_bytes = 0;
 	u32 req_hfunc = 0;
 	u32 entry_size = sizeof(rss_head.rss_config[0]);
+	u32 req_input_xfrm = 0xff;
 	u32 num_weights = 0;
 	u32 rss_context = 0;
 	int delete = 0;
@@ -4189,6 +4194,15 @@  static int do_srxfh(struct cmd_context *ctx)
 			if (!req_hfunc_name)
 				exit_bad_args();
 			++arg_num;
+		} else if (!strcmp(ctx->argp[arg_num], "xfrm")) {
+			++arg_num;
+			if (!strcmp(ctx->argp[arg_num], "symmetric-xor"))
+				req_input_xfrm = RXH_XFRM_SYM_XOR;
+			else if (!strcmp(ctx->argp[arg_num], "none"))
+				req_input_xfrm = 0;
+			else
+				exit_bad_args();
+			++arg_num;
 		} else if (!strcmp(ctx->argp[arg_num], "context")) {
 			++arg_num;
 			if(!strcmp(ctx->argp[arg_num], "new"))
@@ -4333,6 +4347,7 @@  static int do_srxfh(struct cmd_context *ctx)
 	rss->cmd = ETHTOOL_SRSSH;
 	rss->rss_context = rss_context;
 	rss->hfunc = req_hfunc;
+	rss->input_xfrm = req_input_xfrm;
 	if (delete) {
 		rss->indir_size = rss->key_size = 0;
 	} else {
@@ -5887,6 +5902,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"
 			  "		[ delete ]\n"
 	},
 	{
diff --git a/netlink/rss.c b/netlink/rss.c
index 4ad6065..dc28698 100644
--- a/netlink/rss.c
+++ b/netlink/rss.c
@@ -21,7 +21,8 @@  struct cb_args {
 
 void dump_json_rss_info(struct cmd_context *ctx, u32 *indir_table,
 			u32 indir_size, u8 *hkey, u32 hkey_size,
-			const struct stringset *hash_funcs, u8 hfunc)
+			const struct stringset *hash_funcs, u8 hfunc,
+			u32 input_xfrm)
 {
 	unsigned int i;
 
@@ -46,6 +47,12 @@  void dump_json_rss_info(struct cmd_context *ctx, u32 *indir_table,
 			if (hfunc & (1 << i)) {
 				print_string(PRINT_JSON, "rss-hash-function",
 					     NULL, get_string(hash_funcs, i));
+				open_json_object("rss-input-transformation");
+				print_bool(PRINT_JSON, "symmetric-xor", NULL,
+					   (input_xfrm & RXH_XFRM_SYM_XOR) ?
+					   true : false);
+
+				close_json_object();
 				break;
 			}
 		}
@@ -89,6 +96,7 @@  int rss_reply_cb(const struct nlmsghdr *nlhdr, void *data)
 	const struct stringset *hash_funcs;
 	u32 rss_hfunc = 0, indir_size;
 	u32 *indir_table = NULL;
+	u32 input_xfrm = 0;
 	u8 *hkey = NULL;
 	bool silent;
 	int err_ret;
@@ -118,6 +126,9 @@  int rss_reply_cb(const struct nlmsghdr *nlhdr, void *data)
 		hkey = mnl_attr_get_payload(tb[ETHTOOL_A_RSS_HKEY]);
 	}
 
+	if (tb[ETHTOOL_A_RSS_INPUT_XFRM])
+		input_xfrm = mnl_attr_get_u32(tb[ETHTOOL_A_RSS_INPUT_XFRM]);
+
 	/* Fetch RSS hash functions and their status and print */
 	if (!nlctx->is_monitor) {
 		ret = netlink_init_ethnl2_socket(nlctx);
@@ -153,7 +164,8 @@  int rss_reply_cb(const struct nlmsghdr *nlhdr, void *data)
 	indir_size = indir_bytes / sizeof(u32);
 	if (is_json_context()) {
 		dump_json_rss_info(nlctx->ctx, (u32 *)indir_table, indir_size,
-				   hkey, hkey_bytes, hash_funcs, rss_hfunc);
+				   hkey, hkey_bytes, hash_funcs, rss_hfunc,
+				   input_xfrm);
 	} else {
 		print_indir_table(nlctx->ctx, args->num_rings,
 				  indir_size, (u32 *)indir_table);
@@ -167,6 +179,9 @@  int rss_reply_cb(const struct nlmsghdr *nlhdr, void *data)
 			printf("    %s: %s\n", get_string(hash_funcs, i),
 			       (rss_hfunc & (1 << i)) ? "on" : "off");
 		}
+		printf("RSS input transformation:\n");
+		printf("    symmetric-xor: %s\n",
+		       (input_xfrm & RXH_XFRM_SYM_XOR) ? "on" : "off");
 	}
 
 	return MNL_CB_OK;