Skip to content

Commit cf49fc8

Browse files
committed
ethtool: Symmetric OR-XOR RSS hash
JIRA: https://issues.redhat.com/browse/RHEL-75603 commit ecdff89 Author: Gal Pressman <gal@nvidia.com> Date: Mon Feb 24 19:44:13 2025 +0200 ethtool: Symmetric OR-XOR RSS hash 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) Change 'cap_rss_sym_xor_supported' to 'supported_input_xfrm', a bitmap of supported RXH_XFRM_* types. Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com> Reviewed-by: Tariq Toukan <tariqt@nvidia.com> Signed-off-by: Gal Pressman <gal@nvidia.com> Reviewed-by: Edward Cree <ecree.xilinx@gmail.com> Link: https://patch.msgid.link/20250224174416.499070-2-gal@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Mohammad Heib <mheib@redhat.com>
1 parent 7d397cd commit cf49fc8

File tree

7 files changed

+24
-14
lines changed

7 files changed

+24
-14
lines changed

Documentation/networking/ethtool-netlink.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1934,7 +1934,7 @@ ETHTOOL_A_RSS_INDIR attribute returns RSS indirection table where each byte
19341934
indicates queue number.
19351935
ETHTOOL_A_RSS_INPUT_XFRM attribute is a bitmap indicating the type of
19361936
transformation applied to the input protocol fields before given to the RSS
1937-
hfunc. Current supported option is symmetric-xor.
1937+
hfunc. Current supported options are symmetric-xor and symmetric-or-xor.
19381938

19391939
PLCA_GET_CFG
19401940
============

Documentation/networking/scaling.rst

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,21 @@ destination address) and TCP/UDP (source port, destination port) tuples
4949
are swapped, the computed hash is the same. This is beneficial in some
5050
applications that monitor TCP/IP flows (IDS, firewalls, ...etc) and need
5151
both directions of the flow to land on the same Rx queue (and CPU). The
52-
"Symmetric-XOR" is a type of RSS algorithms that achieves this hash
53-
symmetry by XORing the input source and destination fields of the IP
54-
and/or L4 protocols. This, however, results in reduced input entropy and
55-
could potentially be exploited. Specifically, the algorithm XORs the input
52+
"Symmetric-XOR" and "Symmetric-OR-XOR" are types of RSS algorithms that
53+
achieve this hash symmetry by XOR/ORing the input source and destination
54+
fields of the IP and/or L4 protocols. This, however, results in reduced
55+
input entropy and could potentially be exploited.
56+
57+
Specifically, the "Symmetric-XOR" algorithm XORs the input
5658
as follows::
5759

5860
# (SRC_IP ^ DST_IP, SRC_IP ^ DST_IP, SRC_PORT ^ DST_PORT, SRC_PORT ^ DST_PORT)
5961

62+
The "Symmetric-OR-XOR" algorithm, on the other hand, transforms the input as
63+
follows::
64+
65+
# (SRC_IP | DST_IP, SRC_IP ^ DST_IP, SRC_PORT | DST_PORT, SRC_PORT ^ DST_PORT)
66+
6067
The result is then fed to the underlying RSS algorithm.
6168

6269
Some advanced NICs allow steering packets to queues based on

drivers/net/ethernet/intel/iavf/iavf_ethtool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1808,7 +1808,7 @@ static int iavf_set_rxfh(struct net_device *netdev,
18081808
static const struct ethtool_ops iavf_ethtool_ops = {
18091809
.supported_coalesce_params = ETHTOOL_COALESCE_USECS |
18101810
ETHTOOL_COALESCE_USE_ADAPTIVE,
1811-
.cap_rss_sym_xor_supported = true,
1811+
.supported_input_xfrm = RXH_XFRM_SYM_XOR,
18121812
.get_drvinfo = iavf_get_drvinfo,
18131813
.get_link = ethtool_op_get_link,
18141814
.get_ringparam = iavf_get_ringparam,

drivers/net/ethernet/intel/ice/ice_ethtool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4719,7 +4719,7 @@ static const struct ethtool_ops ice_ethtool_ops = {
47194719
.supported_coalesce_params = ETHTOOL_COALESCE_USECS |
47204720
ETHTOOL_COALESCE_USE_ADAPTIVE |
47214721
ETHTOOL_COALESCE_RX_USECS_HIGH,
4722-
.cap_rss_sym_xor_supported = true,
4722+
.supported_input_xfrm = RXH_XFRM_SYM_XOR,
47234723
.rxfh_per_ctx_key = true,
47244724
.get_link_ksettings = ice_get_link_ksettings,
47254725
.set_link_ksettings = ice_set_link_ksettings,

include/linux/ethtool.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -763,13 +763,12 @@ struct kernel_ethtool_ts_info {
763763

764764
/**
765765
* struct ethtool_ops - optional netdev operations
766+
* @supported_input_xfrm: supported types of input xfrm from %RXH_XFRM_*.
766767
* @cap_link_lanes_supported: indicates if the driver supports lanes
767768
* parameter.
768769
* @cap_rss_ctx_supported: indicates if the driver supports RSS
769770
* contexts via legacy API, drivers implementing @create_rxfh_context
770771
* do not have to set this bit.
771-
* @cap_rss_sym_xor_supported: indicates if the driver supports symmetric-xor
772-
* RSS.
773772
* @rxfh_per_ctx_key: device supports setting different RSS key for each
774773
* additional context. Netlink API should report hfunc, key, and input_xfrm
775774
* for every context, not just context 0.
@@ -995,9 +994,9 @@ struct kernel_ethtool_ts_info {
995994
* of the generic netdev features interface.
996995
*/
997996
struct ethtool_ops {
997+
u32 supported_input_xfrm:8;
998998
u32 cap_link_lanes_supported:1;
999999
u32 cap_rss_ctx_supported:1;
1000-
u32 cap_rss_sym_xor_supported:1;
10011000
u32 rxfh_per_ctx_key:1;
10021001
u32 cap_rss_rxnfc_adds:1;
10031002
u32 rxfh_indir_space;

include/uapi/linux/ethtool.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2289,6 +2289,10 @@ static inline int ethtool_validate_duplex(__u8 duplex)
22892289
* be exploited to reduce the RSS queue spread.
22902290
*/
22912291
#define RXH_XFRM_SYM_XOR (1 << 0)
2292+
/* Similar to SYM_XOR, except that one copy of the XOR'ed fields is replaced by
2293+
* an OR of the same fields
2294+
*/
2295+
#define RXH_XFRM_SYM_OR_XOR (1 << 1)
22922296
#define RXH_XFRM_NO_CHANGE 0xff
22932297

22942298
/* L2-L4 network traffic flow types */

net/ethtool/ioctl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,11 +1011,11 @@ static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev,
10111011
if (rc)
10121012
return rc;
10131013

1014-
/* Sanity check: if symmetric-xor is set, then:
1014+
/* Sanity check: if symmetric-xor/symmetric-or-xor is set, then:
10151015
* 1 - no other fields besides IP src/dst and/or L4 src/dst
10161016
* 2 - If src is set, dst must also be set
10171017
*/
1018-
if ((rxfh.input_xfrm & RXH_XFRM_SYM_XOR) &&
1018+
if ((rxfh.input_xfrm & (RXH_XFRM_SYM_XOR | RXH_XFRM_SYM_OR_XOR)) &&
10191019
((info.data & ~(RXH_IP_SRC | RXH_IP_DST |
10201020
RXH_L4_B_0_1 | RXH_L4_B_2_3)) ||
10211021
(!!(info.data & RXH_IP_SRC) ^ !!(info.data & RXH_IP_DST)) ||
@@ -1388,11 +1388,11 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
13881388
return -EOPNOTSUPP;
13891389
/* Check input data transformation capabilities */
13901390
if (rxfh.input_xfrm && rxfh.input_xfrm != RXH_XFRM_SYM_XOR &&
1391+
rxfh.input_xfrm != RXH_XFRM_SYM_OR_XOR &&
13911392
rxfh.input_xfrm != RXH_XFRM_NO_CHANGE)
13921393
return -EINVAL;
13931394
if (rxfh.input_xfrm != RXH_XFRM_NO_CHANGE &&
1394-
(rxfh.input_xfrm & RXH_XFRM_SYM_XOR) &&
1395-
!ops->cap_rss_sym_xor_supported)
1395+
rxfh.input_xfrm & ~ops->supported_input_xfrm)
13961396
return -EOPNOTSUPP;
13971397
create = rxfh.rss_context == ETH_RXFH_CONTEXT_ALLOC;
13981398

0 commit comments

Comments
 (0)