History

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.

Gal Pressman committed 1 year ago

Commit ecdff891 parent ad530287 files · +24 −14Browse files

Unified · Split

7 files
  1. Documentation/networking/ethtool-netlink.rst +1 −1
  2. Documentation/networking/scaling.rst +11 −4
  3. drivers/net/ethernet/intel/iavf/iavf_ethtool.c +1 −1
  4. drivers/net/ethernet/intel/ice/ice_ethtool.c +1 −1
  5. include/linux/ethtool.h +2 −3
  6. include/uapi/linux/ethtool.h +4 −0
  7. net/ethtool/ioctl.c +4 −4
Documentation/networking/ethtool-netlink.rst+1−1
@@ -1934,7 +1934,7 @@ ETHTOOL_A_RSS_INDIR attribute returns RSS indirection table where each byte · 1933 unmodified lines
1934indicates queue number.1934indicates queue number.
1935ETHTOOL_A_RSS_INPUT_XFRM attribute is a bitmap indicating the type of1935ETHTOOL_A_RSS_INPUT_XFRM attribute is a bitmap indicating the type of
1936transformation applied to the input protocol fields before given to the RSS1936transformation applied to the input protocol fields before given to the RSS
1937hfunc. Current supported option is symmetric-xor.1937hfunc. Current supported options are symmetric-xor and symmetric-or-xor.
1938 1938
1939PLCA_GET_CFG1939PLCA_GET_CFG
1940============1940============
Documentation/networking/scaling.rst+11−4
@@ -49,14 +49,21 @@ destination address) and TCP/UDP (source port, destination port) tuples · 48 unmodified lines
49are swapped, the computed hash is the same. This is beneficial in some49are swapped, the computed hash is the same. This is beneficial in some
50applications that monitor TCP/IP flows (IDS, firewalls, ...etc) and need50applications that monitor TCP/IP flows (IDS, firewalls, ...etc) and need
51both directions of the flow to land on the same Rx queue (and CPU). The51both 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 hash52"Symmetric-XOR" and "Symmetric-OR-XOR" are types of RSS algorithms that
53symmetry by XORing the input source and destination fields of the IP53achieve this hash symmetry by XOR/ORing the input source and destination
54and/or L4 protocols. This, however, results in reduced input entropy and54fields of the IP and/or L4 protocols. This, however, results in reduced
55could potentially be exploited. Specifically, the algorithm XORs the input55input entropy and could potentially be exploited.
56
57Specifically, the "Symmetric-XOR" algorithm XORs the input
56as follows::58as follows::
57 59
58 # (SRC_IP ^ DST_IP, SRC_IP ^ DST_IP, SRC_PORT ^ DST_PORT, SRC_PORT ^ DST_PORT)60 # (SRC_IP ^ DST_IP, SRC_IP ^ DST_IP, SRC_PORT ^ DST_PORT, SRC_PORT ^ DST_PORT)
59 61
62The "Symmetric-OR-XOR" algorithm, on the other hand, transforms the input as
63follows::
64
65 # (SRC_IP | DST_IP, SRC_IP ^ DST_IP, SRC_PORT | DST_PORT, SRC_PORT ^ DST_PORT)
66
60The result is then fed to the underlying RSS algorithm.67The result is then fed to the underlying RSS algorithm.
61 68
62Some advanced NICs allow steering packets to queues based on69Some advanced NICs allow steering packets to queues based on
drivers/net/ethernet/intel/iavf/iavf_ethtool.c+1−1
@@ -1808,7 +1808,7 @@ static int iavf_set_rxfh(struct net_device *netdev, · 1807 unmodified lines
1808static const struct ethtool_ops iavf_ethtool_ops = {1808static const struct ethtool_ops iavf_ethtool_ops = {
1809 .supported_coalesce_params = ETHTOOL_COALESCE_USECS |1809 .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
1810 ETHTOOL_COALESCE_USE_ADAPTIVE,1810 ETHTOOL_COALESCE_USE_ADAPTIVE,
1811 .cap_rss_sym_xor_supported = true,1811 .supported_input_xfrm = RXH_XFRM_SYM_XOR,
1812 .get_drvinfo = iavf_get_drvinfo,1812 .get_drvinfo = iavf_get_drvinfo,
1813 .get_link = ethtool_op_get_link,1813 .get_link = ethtool_op_get_link,
1814 .get_ringparam = iavf_get_ringparam,1814 .get_ringparam = iavf_get_ringparam,
drivers/net/ethernet/intel/ice/ice_ethtool.c+1−1
@@ -4770,7 +4770,7 @@ static const struct ethtool_ops ice_ethtool_ops = { · 4769 unmodified lines
4770 .supported_coalesce_params = ETHTOOL_COALESCE_USECS |4770 .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
4771 ETHTOOL_COALESCE_USE_ADAPTIVE |4771 ETHTOOL_COALESCE_USE_ADAPTIVE |
4772 ETHTOOL_COALESCE_RX_USECS_HIGH,4772 ETHTOOL_COALESCE_RX_USECS_HIGH,
4773 .cap_rss_sym_xor_supported = true,4773 .supported_input_xfrm = RXH_XFRM_SYM_XOR,
4774 .rxfh_per_ctx_key = true,4774 .rxfh_per_ctx_key = true,
4775 .get_link_ksettings = ice_get_link_ksettings,4775 .get_link_ksettings = ice_get_link_ksettings,
4776 .set_link_ksettings = ice_set_link_ksettings,4776 .set_link_ksettings = ice_set_link_ksettings,
include/linux/ethtool.h+2−3
@@ -763,13 +763,12 @@ struct kernel_ethtool_ts_info { · 762 unmodified lines
763 763
764/**764/**
765 * struct ethtool_ops - optional netdev operations765 * struct ethtool_ops - optional netdev operations
766 * @supported_input_xfrm: supported types of input xfrm from %RXH_XFRM_*.
766 * @cap_link_lanes_supported: indicates if the driver supports lanes767 * @cap_link_lanes_supported: indicates if the driver supports lanes
767 * parameter.768 * parameter.
768 * @cap_rss_ctx_supported: indicates if the driver supports RSS769 * @cap_rss_ctx_supported: indicates if the driver supports RSS
769 * contexts via legacy API, drivers implementing @create_rxfh_context770 * contexts via legacy API, drivers implementing @create_rxfh_context
770 * do not have to set this bit.771 * do not have to set this bit.
771 * @cap_rss_sym_xor_supported: indicates if the driver supports symmetric-xor
772 * RSS.
773 * @rxfh_per_ctx_key: device supports setting different RSS key for each772 * @rxfh_per_ctx_key: device supports setting different RSS key for each
774 * additional context. Netlink API should report hfunc, key, and input_xfrm773 * additional context. Netlink API should report hfunc, key, and input_xfrm
775 * for every context, not just context 0.774 * for every context, not just context 0.
@@ -995,9 +994,9 @@ struct kernel_ethtool_ts_info { · 219 unmodified lines
995 * of the generic netdev features interface.994 * of the generic netdev features interface.
996 */995 */
997struct ethtool_ops {996struct ethtool_ops {
997 u32 supported_input_xfrm:8;
998 u32 cap_link_lanes_supported:1;998 u32 cap_link_lanes_supported:1;
999 u32 cap_rss_ctx_supported:1;999 u32 cap_rss_ctx_supported:1;
1000 u32 cap_rss_sym_xor_supported:1;
1001 u32 rxfh_per_ctx_key:1;1000 u32 rxfh_per_ctx_key:1;
1002 u32 cap_rss_rxnfc_adds:1;1001 u32 cap_rss_rxnfc_adds:1;
1003 u32 rxfh_indir_space;1002 u32 rxfh_indir_space;
include/uapi/linux/ethtool.h+4−0
@@ -2289,6 +2289,10 @@ static inline int ethtool_validate_duplex(__u8 duplex) · 2288 unmodified lines
2289 * be exploited to reduce the RSS queue spread.2289 * be exploited to reduce the RSS queue spread.
2290 */2290 */
2291#define RXH_XFRM_SYM_XOR (1 << 0)2291#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)
2292#define RXH_XFRM_NO_CHANGE 0xff2296#define RXH_XFRM_NO_CHANGE 0xff
2293 2297
2294/* L2-L4 network traffic flow types */2298/* L2-L4 network traffic flow types */
net/ethtool/ioctl.c+4−4
@@ -1011,11 +1011,11 @@ static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev, · 1010 unmodified lines
1011 if (rc)1011 if (rc)
1012 return rc;1012 return rc;
1013 1013
1014 /* Sanity check: if symmetric-xor is set, then:1014 /* Sanity check: if symmetric-xor/symmetric-or-xor is set, then:
1015 * 1 - no other fields besides IP src/dst and/or L4 src/dst1015 * 1 - no other fields besides IP src/dst and/or L4 src/dst
1016 * 2 - If src is set, dst must also be set1016 * 2 - If src is set, dst must also be set
1017 */1017 */
1018 if ((rxfh.input_xfrm & RXH_XFRM_SYM_XOR) &&1018 if ((rxfh.input_xfrm & (RXH_XFRM_SYM_XOR | RXH_XFRM_SYM_OR_XOR)) &&
1019 ((info.data & ~(RXH_IP_SRC | RXH_IP_DST |1019 ((info.data & ~(RXH_IP_SRC | RXH_IP_DST |
1020 RXH_L4_B_0_1 | RXH_L4_B_2_3)) ||1020 RXH_L4_B_0_1 | RXH_L4_B_2_3)) ||
1021 (!!(info.data & RXH_IP_SRC) ^ !!(info.data & RXH_IP_DST)) ||1021 (!!(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, · 366 unmodified lines
1388 return -EOPNOTSUPP;1388 return -EOPNOTSUPP;
1389 /* Check input data transformation capabilities */1389 /* Check input data transformation capabilities */
1390 if (rxfh.input_xfrm && rxfh.input_xfrm != RXH_XFRM_SYM_XOR &&1390 if (rxfh.input_xfrm && rxfh.input_xfrm != RXH_XFRM_SYM_XOR &&
1391 rxfh.input_xfrm != RXH_XFRM_SYM_OR_XOR &&
1391 rxfh.input_xfrm != RXH_XFRM_NO_CHANGE)1392 rxfh.input_xfrm != RXH_XFRM_NO_CHANGE)
1392 return -EINVAL;1393 return -EINVAL;
1393 if (rxfh.input_xfrm != RXH_XFRM_NO_CHANGE &&1394 if (rxfh.input_xfrm != RXH_XFRM_NO_CHANGE &&
1394 (rxfh.input_xfrm & RXH_XFRM_SYM_XOR) &&1395 rxfh.input_xfrm & ~ops->supported_input_xfrm)
1395 !ops->cap_rss_sym_xor_supported)
1396 return -EOPNOTSUPP;1396 return -EOPNOTSUPP;
1397 create = rxfh.rss_context == ETH_RXFH_CONTEXT_ALLOC;1397 create = rxfh.rss_context == ETH_RXFH_CONTEXT_ALLOC;
1398 1398

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t