]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ethtool: Symmetric OR-XOR RSS hash
authorGal Pressman <gal@nvidia.com>
Mon, 24 Feb 2025 17:44:13 +0000 (19:44 +0200)
committerJakub Kicinski <kuba@kernel.org>
Wed, 26 Feb 2025 02:31:04 +0000 (18:31 -0800)
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>
Documentation/networking/ethtool-netlink.rst
Documentation/networking/scaling.rst
drivers/net/ethernet/intel/iavf/iavf_ethtool.c
drivers/net/ethernet/intel/ice/ice_ethtool.c
include/linux/ethtool.h
include/uapi/linux/ethtool.h
net/ethtool/ioctl.c

index 3770a22945097faab4553dbc48fc44603e5e3862..b6e9af4d0f1b9df943c7041fd0011eb125e80632 100644 (file)
@@ -1934,7 +1934,7 @@ ETHTOOL_A_RSS_INDIR attribute returns RSS indirection table where each byte
 indicates queue number.
 ETHTOOL_A_RSS_INPUT_XFRM attribute is a bitmap indicating the type of
 transformation applied to the input protocol fields before given to the RSS
-hfunc. Current supported option is symmetric-xor.
+hfunc. Current supported options are symmetric-xor and symmetric-or-xor.
 
 PLCA_GET_CFG
 ============
index 4eb50bcb9d429e2722aa235fac103b6cabd3fe02..6984700cec6ad35b939e2945cc477fe9c81547f7 100644 (file)
@@ -49,14 +49,21 @@ destination address) and TCP/UDP (source port, destination port) tuples
 are swapped, the computed hash is the same. This is beneficial in some
 applications that monitor TCP/IP flows (IDS, firewalls, ...etc) and need
 both directions of the flow to land on the same Rx queue (and CPU). The
-"Symmetric-XOR" is a type of RSS algorithms that achieves this hash
-symmetry by XORing the input source and destination fields of the IP
-and/or L4 protocols. This, however, results in reduced input entropy and
-could potentially be exploited. Specifically, the algorithm XORs the input
+"Symmetric-XOR" and "Symmetric-OR-XOR" are types of RSS algorithms that
+achieve this hash symmetry by XOR/ORing the input source and destination
+fields of the IP and/or L4 protocols. This, however, results in reduced
+input entropy and could potentially be exploited.
+
+Specifically, the "Symmetric-XOR" algorithm XORs the input
 as follows::
 
     # (SRC_IP ^ DST_IP, SRC_IP ^ DST_IP, SRC_PORT ^ DST_PORT, SRC_PORT ^ DST_PORT)
 
+The "Symmetric-OR-XOR" algorithm, on the other hand, transforms the input as
+follows::
+
+    # (SRC_IP | DST_IP, SRC_IP ^ DST_IP, SRC_PORT | DST_PORT, SRC_PORT ^ DST_PORT)
+
 The result is then fed to the underlying RSS algorithm.
 
 Some advanced NICs allow steering packets to queues based on
index 74a1e9fe182128dc411f1d0579bcc1309861a745..288bb5b2e72ef793bcdc40c71bb3e4c263031adf 100644 (file)
@@ -1808,7 +1808,7 @@ static int iavf_set_rxfh(struct net_device *netdev,
 static const struct ethtool_ops iavf_ethtool_ops = {
        .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
                                     ETHTOOL_COALESCE_USE_ADAPTIVE,
-       .cap_rss_sym_xor_supported = true,
+       .supported_input_xfrm   = RXH_XFRM_SYM_XOR,
        .get_drvinfo            = iavf_get_drvinfo,
        .get_link               = ethtool_op_get_link,
        .get_ringparam          = iavf_get_ringparam,
index b0805704834d727f99d3c276fe69afbc7d224611..7c2dc347e4e57c2f4cd551a138a88d539e5309e9 100644 (file)
@@ -4770,7 +4770,7 @@ static const struct ethtool_ops ice_ethtool_ops = {
        .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
                                     ETHTOOL_COALESCE_USE_ADAPTIVE |
                                     ETHTOOL_COALESCE_RX_USECS_HIGH,
-       .cap_rss_sym_xor_supported = true,
+       .supported_input_xfrm   = RXH_XFRM_SYM_XOR,
        .rxfh_per_ctx_key       = true,
        .get_link_ksettings     = ice_get_link_ksettings,
        .set_link_ksettings     = ice_set_link_ksettings,
index 870994cc3ef7e6e1d145cebcdb4452d38dd50198..7f222dccc7d1da19dd10b3b17025da48283f2ab7 100644 (file)
@@ -763,13 +763,12 @@ struct kernel_ethtool_ts_info {
 
 /**
  * struct ethtool_ops - optional netdev operations
+ * @supported_input_xfrm: supported types of input xfrm from %RXH_XFRM_*.
  * @cap_link_lanes_supported: indicates if the driver supports lanes
  *     parameter.
  * @cap_rss_ctx_supported: indicates if the driver supports RSS
  *     contexts via legacy API, drivers implementing @create_rxfh_context
  *     do not have to set this bit.
- * @cap_rss_sym_xor_supported: indicates if the driver supports symmetric-xor
- *     RSS.
  * @rxfh_per_ctx_key: device supports setting different RSS key for each
  *     additional context. Netlink API should report hfunc, key, and input_xfrm
  *     for every context, not just context 0.
@@ -995,9 +994,9 @@ struct kernel_ethtool_ts_info {
  * of the generic netdev features interface.
  */
 struct ethtool_ops {
+       u32     supported_input_xfrm:8;
        u32     cap_link_lanes_supported:1;
        u32     cap_rss_ctx_supported:1;
-       u32     cap_rss_sym_xor_supported:1;
        u32     rxfh_per_ctx_key:1;
        u32     cap_rss_rxnfc_adds:1;
        u32     rxfh_indir_space;
index 2feba0929a8a94019e4d0b2f7fadd4e320ddbec6..84833cca29fec4dcf07626f1094d2e4a230e3301 100644 (file)
@@ -2289,6 +2289,10 @@ static inline int ethtool_validate_duplex(__u8 duplex)
  * be exploited to reduce the RSS queue spread.
  */
 #define        RXH_XFRM_SYM_XOR        (1 << 0)
+/* Similar to SYM_XOR, except that one copy of the XOR'ed fields is replaced by
+ * an OR of the same fields
+ */
+#define        RXH_XFRM_SYM_OR_XOR     (1 << 1)
 #define        RXH_XFRM_NO_CHANGE      0xff
 
 /* L2-L4 network traffic flow types */
index 271c7cef9ef3e30e856c58b64c8c578e01e49b11..77d714874ecae32feb655a24b10d25959c2c23d1 100644 (file)
@@ -1011,11 +1011,11 @@ static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev,
                if (rc)
                        return rc;
 
-               /* Sanity check: if symmetric-xor is set, then:
+               /* Sanity check: if symmetric-xor/symmetric-or-xor is set, then:
                 * 1 - no other fields besides IP src/dst and/or L4 src/dst
                 * 2 - If src is set, dst must also be set
                 */
-               if ((rxfh.input_xfrm & RXH_XFRM_SYM_XOR) &&
+               if ((rxfh.input_xfrm & (RXH_XFRM_SYM_XOR | RXH_XFRM_SYM_OR_XOR)) &&
                    ((info.data & ~(RXH_IP_SRC | RXH_IP_DST |
                                    RXH_L4_B_0_1 | RXH_L4_B_2_3)) ||
                     (!!(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,
                return -EOPNOTSUPP;
        /* Check input data transformation capabilities */
        if (rxfh.input_xfrm && rxfh.input_xfrm != RXH_XFRM_SYM_XOR &&
+           rxfh.input_xfrm != RXH_XFRM_SYM_OR_XOR &&
            rxfh.input_xfrm != RXH_XFRM_NO_CHANGE)
                return -EINVAL;
        if (rxfh.input_xfrm != RXH_XFRM_NO_CHANGE &&
-           (rxfh.input_xfrm & RXH_XFRM_SYM_XOR) &&
-           !ops->cap_rss_sym_xor_supported)
+           rxfh.input_xfrm & ~ops->supported_input_xfrm)
                return -EOPNOTSUPP;
        create = rxfh.rss_context == ETH_RXFH_CONTEXT_ALLOC;