Skip to content

Commit 7f7f3e1

Browse files
committed
Merge branch 'ethtool-rss-support-rss_set-via-netlink'
Jakub Kicinski says: ==================== ethtool: rss: support RSS_SET via Netlink Support configuring RSS settings via Netlink. Creating and removing contexts remains for the following series. v2: https://lore.kernel.org/[email protected] v1: https://lore.kernel.org/[email protected] ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 870bc1a + 00e6c61 commit 7f7f3e1

File tree

12 files changed

+767
-20
lines changed

12 files changed

+767
-20
lines changed

Documentation/netlink/specs/ethtool.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,26 @@ definitions:
158158
-
159159
name: pse-event-sw-pw-control-error
160160
doc: PSE faced an error managing the power control from software
161+
-
162+
name: input-xfrm
163+
doc: RSS hash function transformations.
164+
type: flags
165+
enum-name:
166+
name-prefix: rxh-xfrm-
167+
header: linux/ethtool.h
168+
entries:
169+
-
170+
name: sym-xor
171+
doc: >-
172+
XOR the corresponding source and destination fields of each specified
173+
protocol. Both copies of the XOR'ed fields are fed into the RSS and
174+
RXHASH calculation. Note that this XORing reduces the input set
175+
entropy and could be exploited to reduce the RSS queue spread.
176+
-
177+
name: sym-or-xor
178+
doc: >-
179+
Similar to SYM_XOR, except that one copy of the XOR'ed fields is
180+
replaced by an OR of the same fields.
161181
-
162182
name: rxfh-fields
163183
name-prefix: rxh-
@@ -1621,6 +1641,7 @@ attribute-sets:
16211641
-
16221642
name: input-xfrm
16231643
type: u32
1644+
enum: input-xfrm
16241645
-
16251646
name: start-context
16261647
type: u32
@@ -2643,6 +2664,22 @@ operations:
26432664
attributes:
26442665
- header
26452666
- events
2667+
-
2668+
name: rss-set
2669+
doc: Set RSS params.
2670+
2671+
attribute-set: rss
2672+
2673+
do:
2674+
request:
2675+
attributes:
2676+
- header
2677+
- context
2678+
- hfunc
2679+
- indir
2680+
- hkey
2681+
- input-xfrm
2682+
- flow-hash
26462683
-
26472684
name: rss-ntf
26482685
doc: |

Documentation/networking/ethtool-netlink.rst

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ Userspace to kernel:
239239
``ETHTOOL_MSG_PHY_GET`` get Ethernet PHY information
240240
``ETHTOOL_MSG_TSCONFIG_GET`` get hw timestamping configuration
241241
``ETHTOOL_MSG_TSCONFIG_SET`` set hw timestamping configuration
242+
``ETHTOOL_MSG_RSS_SET`` set RSS settings
242243
===================================== =================================
243244

244245
Kernel to userspace:
@@ -292,6 +293,7 @@ Kernel to userspace:
292293
``ETHTOOL_MSG_TSCONFIG_GET_REPLY`` hw timestamping configuration
293294
``ETHTOOL_MSG_TSCONFIG_SET_REPLY`` new hw timestamping configuration
294295
``ETHTOOL_MSG_PSE_NTF`` PSE events notification
296+
``ETHTOOL_MSG_RSS_NTF`` RSS settings notification
295297
======================================== =================================
296298

297299
``GET`` requests are sent by userspace applications to retrieve device
@@ -1989,6 +1991,29 @@ hfunc. Current supported options are symmetric-xor and symmetric-or-xor.
19891991
ETHTOOL_A_RSS_FLOW_HASH carries per-flow type bitmask of which header
19901992
fields are included in the hash calculation.
19911993

1994+
RSS_SET
1995+
=======
1996+
1997+
Request contents:
1998+
1999+
===================================== ====== ==============================
2000+
``ETHTOOL_A_RSS_HEADER`` nested request header
2001+
``ETHTOOL_A_RSS_CONTEXT`` u32 context number
2002+
``ETHTOOL_A_RSS_HFUNC`` u32 RSS hash func
2003+
``ETHTOOL_A_RSS_INDIR`` binary Indir table bytes
2004+
``ETHTOOL_A_RSS_HKEY`` binary Hash key bytes
2005+
``ETHTOOL_A_RSS_INPUT_XFRM`` u32 RSS input data transformation
2006+
``ETHTOOL_A_RSS_FLOW_HASH`` nested Header fields included in hash
2007+
===================================== ====== ==============================
2008+
2009+
``ETHTOOL_A_RSS_INDIR`` is the minimal RSS table the user expects. Kernel and
2010+
the device driver may replicate the table if its smaller than smallest table
2011+
size supported by the device. For example if user requests ``[0, 1]`` but the
2012+
device needs at least 8 entries - the real table in use will end up being
2013+
``[0, 1, 0, 1, 0, 1, 0, 1]``. Most devices require the table size to be power
2014+
of 2, so tables which size is not a power of 2 will likely be rejected.
2015+
Using table of size 0 will reset the indirection table to the default.
2016+
19922017
PLCA_GET_CFG
19932018
============
19942019

@@ -2440,7 +2465,7 @@ are netlink only.
24402465
``ETHTOOL_GPFLAGS`` ``ETHTOOL_MSG_PRIVFLAGS_GET``
24412466
``ETHTOOL_SPFLAGS`` ``ETHTOOL_MSG_PRIVFLAGS_SET``
24422467
``ETHTOOL_GRXFH`` ``ETHTOOL_MSG_RSS_GET``
2443-
``ETHTOOL_SRXFH`` n/a
2468+
``ETHTOOL_SRXFH`` ``ETHTOOL_MSG_RSS_SET``
24442469
``ETHTOOL_GGRO`` ``ETHTOOL_MSG_FEATURES_GET``
24452470
``ETHTOOL_SGRO`` ``ETHTOOL_MSG_FEATURES_SET``
24462471
``ETHTOOL_GRXRINGS`` n/a
@@ -2455,7 +2480,7 @@ are netlink only.
24552480
``ETHTOOL_GRXNTUPLE`` n/a
24562481
``ETHTOOL_GSSET_INFO`` ``ETHTOOL_MSG_STRSET_GET``
24572482
``ETHTOOL_GRXFHINDIR`` ``ETHTOOL_MSG_RSS_GET``
2458-
``ETHTOOL_SRXFHINDIR`` n/a
2483+
``ETHTOOL_SRXFHINDIR`` ``ETHTOOL_MSG_RSS_SET``
24592484
``ETHTOOL_GFEATURES`` ``ETHTOOL_MSG_FEATURES_GET``
24602485
``ETHTOOL_SFEATURES`` ``ETHTOOL_MSG_FEATURES_SET``
24612486
``ETHTOOL_GCHANNELS`` ``ETHTOOL_MSG_CHANNELS_GET``

include/uapi/linux/ethtool_netlink_generated.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,7 @@ enum {
840840
ETHTOOL_MSG_PHY_GET,
841841
ETHTOOL_MSG_TSCONFIG_GET,
842842
ETHTOOL_MSG_TSCONFIG_SET,
843+
ETHTOOL_MSG_RSS_SET,
843844

844845
__ETHTOOL_MSG_USER_CNT,
845846
ETHTOOL_MSG_USER_MAX = (__ETHTOOL_MSG_USER_CNT - 1)

net/ethtool/common.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,21 @@ int ethtool_check_rss_ctx_busy(struct net_device *dev, u32 rss_context)
806806
return rc;
807807
}
808808

809+
/* Check if fields configured for flow hash are symmetric - if src is included
810+
* so is dst and vice versa.
811+
*/
812+
int ethtool_rxfh_config_is_sym(u64 rxfh)
813+
{
814+
bool sym;
815+
816+
sym = rxfh == (rxfh & (RXH_IP_SRC | RXH_IP_DST |
817+
RXH_L4_B_0_1 | RXH_L4_B_2_3));
818+
sym &= !!(rxfh & RXH_IP_SRC) == !!(rxfh & RXH_IP_DST);
819+
sym &= !!(rxfh & RXH_L4_B_0_1) == !!(rxfh & RXH_L4_B_2_3);
820+
821+
return sym;
822+
}
823+
809824
int ethtool_check_ops(const struct ethtool_ops *ops)
810825
{
811826
if (WARN_ON(ops->set_coalesce && !ops->supported_coalesce_params))

net/ethtool/common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ int ethtool_check_max_channel(struct net_device *dev,
4444
struct ethtool_channels channels,
4545
struct genl_info *info);
4646
int ethtool_check_rss_ctx_busy(struct net_device *dev, u32 rss_context);
47+
int ethtool_rxfh_config_is_sym(u64 rxfh);
4748

4849
void ethtool_ringparam_get_cfg(struct net_device *dev,
4950
struct ethtool_ringparam *param,

net/ethtool/ioctl.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,9 +1027,7 @@ static int ethtool_check_xfrm_rxfh(u32 input_xfrm, u64 rxfh)
10271027
*/
10281028
if ((input_xfrm != RXH_XFRM_NO_CHANGE &&
10291029
input_xfrm & (RXH_XFRM_SYM_XOR | RXH_XFRM_SYM_OR_XOR)) &&
1030-
((rxfh & ~(RXH_IP_SRC | RXH_IP_DST | RXH_L4_B_0_1 | RXH_L4_B_2_3)) ||
1031-
(!!(rxfh & RXH_IP_SRC) ^ !!(rxfh & RXH_IP_DST)) ||
1032-
(!!(rxfh & RXH_L4_B_0_1) ^ !!(rxfh & RXH_L4_B_2_3))))
1030+
!ethtool_rxfh_config_is_sym(rxfh))
10331031
return -EINVAL;
10341032

10351033
return 0;

net/ethtool/netlink.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ ethnl_default_requests[__ETHTOOL_MSG_USER_CNT] = {
405405
[ETHTOOL_MSG_PSE_GET] = &ethnl_pse_request_ops,
406406
[ETHTOOL_MSG_PSE_SET] = &ethnl_pse_request_ops,
407407
[ETHTOOL_MSG_RSS_GET] = &ethnl_rss_request_ops,
408+
[ETHTOOL_MSG_RSS_SET] = &ethnl_rss_request_ops,
408409
[ETHTOOL_MSG_PLCA_GET_CFG] = &ethnl_plca_cfg_request_ops,
409410
[ETHTOOL_MSG_PLCA_SET_CFG] = &ethnl_plca_cfg_request_ops,
410411
[ETHTOOL_MSG_PLCA_GET_STATUS] = &ethnl_plca_status_request_ops,
@@ -1504,6 +1505,13 @@ static const struct genl_ops ethtool_genl_ops[] = {
15041505
.policy = ethnl_tsconfig_set_policy,
15051506
.maxattr = ARRAY_SIZE(ethnl_tsconfig_set_policy) - 1,
15061507
},
1508+
{
1509+
.cmd = ETHTOOL_MSG_RSS_SET,
1510+
.flags = GENL_UNS_ADMIN_PERM,
1511+
.doit = ethnl_default_set_doit,
1512+
.policy = ethnl_rss_set_policy,
1513+
.maxattr = ARRAY_SIZE(ethnl_rss_set_policy) - 1,
1514+
},
15071515
};
15081516

15091517
static const struct genl_multicast_group ethtool_nl_mcgrps[] = {

net/ethtool/netlink.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ extern const struct nla_policy ethnl_module_set_policy[ETHTOOL_A_MODULE_POWER_MO
484484
extern const struct nla_policy ethnl_pse_get_policy[ETHTOOL_A_PSE_HEADER + 1];
485485
extern const struct nla_policy ethnl_pse_set_policy[ETHTOOL_A_PSE_MAX + 1];
486486
extern const struct nla_policy ethnl_rss_get_policy[ETHTOOL_A_RSS_START_CONTEXT + 1];
487+
extern const struct nla_policy ethnl_rss_set_policy[ETHTOOL_A_RSS_FLOW_HASH + 1];
487488
extern const struct nla_policy ethnl_plca_get_cfg_policy[ETHTOOL_A_PLCA_HEADER + 1];
488489
extern const struct nla_policy ethnl_plca_set_cfg_policy[ETHTOOL_A_PLCA_MAX + 1];
489490
extern const struct nla_policy ethnl_plca_get_status_policy[ETHTOOL_A_PLCA_HEADER + 1];

0 commit comments

Comments
 (0)