ethtool: rss: support RSS_SET via Netlink
Subsystems (6)
Jakub Kicinski
maintainerv3 cover ethtool: rss: support RSS_SET via Netlink
Support configuring RSS settings via Netlink.
Creating and removing contexts remains for the following series.
v3:
- decode xfrm-input as flags not enum
- check driver supports get_rxnfc op
v2: https://lore.kernel.org/[email protected]
- commit message changes
- make sure driver implements the set_rxfh op
- add comment about early return when lacking get
- set IFF_RXFH_CONFIGURED even if user sets the table to identical to default
- use ethnl_update_binary()
- make sure we free indir if key parsing fails
- tests: fix existing rxfh_input_xfrm test for string decode
- tests: make defer() cleanup more intelligent WRT ordering
v1: https://lore.kernel.org/[email protected]
Jakub Kicinski (11):
ethtool: rss: initial RSS_SET (indirection table handling)
selftests: drv-net: rss_api: factor out checking min queue count
tools: ynl: support packing binary arrays of scalars
selftests: drv-net: rss_api: test setting indirection table via
Netlink
ethtool: rss: support setting hfunc via Netlink
ethtool: rss: support setting hkey via Netlink
selftests: drv-net: rss_api: test setting hashing key via Netlink
netlink: specs: define input-xfrm enum in the spec
ethtool: rss: support setting input-xfrm via Netlink
ethtool: rss: support setting flow hashing fields
selftests: drv-net: rss_api: test input-xfrm and hash fields
Documentation/netlink/specs/ethtool.yaml | 37 ++ Documentation/networking/ethtool-netlink.rst | 29 +- .../uapi/linux/ethtool_netlink_generated.h | 1 + net/ethtool/common.h | 1 + net/ethtool/netlink.h | 1 + net/ethtool/common.c | 15 + net/ethtool/ioctl.c | 4 +- net/ethtool/netlink.c | 8 + net/ethtool/rss.c | 389 ++++++++++++++++++ tools/net/ynl/pyynl/lib/ynl.py | 7 +- .../selftests/drivers/net/hw/rss_api.py | 289 ++++++++++++- .../drivers/net/hw/rss_input_xfrm.py | 6 +- 12 files changed, 767 insertions(+), 20 deletions(-)
Signature · 1 line
2.50.1
Jakub Kicinski
maintainerPATCH v3 1/11 ethtool: rss: initial RSS_SET (indirection table handling)
Add initial support for RSS_SET, for now only operations on the indirection table are supported.
Unlike the ioctl don't check if at least one parameter is being changed. This is how other ethtool-nl ops behave, so pick the ethtool-nl consistency vs copying ioctl behavior.
There are two special cases here:
1) resetting the table to defaults;
2) support for tables of different size.
For (1) I use an empty Netlink attribute (array of size 0).
(2) may require some background. AFAICT a lot of modern devices allow allocating RSS tables of different sizes. mlx5 can upsize its tables, bnxt has some "table size calculation", and Intel folks asked about RSS table sizing in context of resource allocation in the past. The ethtool IOCTL API has a concept of table size, but right now the user is expected to provide a table exactly the size the device requests. Some drivers may change the table size at runtime (in response to queue count changes) but the user is not in control of this. What's not great is that all RSS contexts share the same table size. For example a device with 128 queues enabled, 16 RSS contexts 8 queues in each will likely have 256 entry tables for each of the 16 contexts, while 32 would be more than enough given each context only has 8 queues. To address this the Netlink API should avoid enforcing table size at the uAPI level, and should allow the user to express the min table size they expect.
To fully solve (2) we will need more driver plumbing but at the uAPI level this patch allows the user to specify a table size smaller than what the device advertises. The device table size must be a multiple of the user requested table size. We then replicate the user-provided table to fill the full device size table. This addresses the "allow the user to express the min table size" objective, while not enforcing any fixed size. From Netlink perspective .get_rxfh_indir_size() is now de facto the "max" table size supported by the device.
We may choose to support table replication in ethtool, too, when we actually plumb this thru the device APIs.
Initially I was considering moving full pattern generation to the kernel (which queues to use, at which frequency and what min sequence length). I don't think this complexity would buy us much and most if not all devices have pow-2 table sizes, which simplifies the replication a lot.
---
v3:
- check ops->get_rxnfc
v2:
- make sure driver implements the set_rxfh op
- add comment about early return when lacking get
- explain why we accept empty request in commit msg
- set IFF_RXFH_CONFIGURED even if user sets the table to identical to default
--- Documentation/netlink/specs/ethtool.yaml | 12 ++ Documentation/networking/ethtool-netlink.rst | 26 ++- .../uapi/linux/ethtool_netlink_generated.h | 1 + net/ethtool/netlink.h | 1 + net/ethtool/netlink.c | 8 + net/ethtool/rss.c | 195 ++++++++++++++++++ 6 files changed, 242 insertions(+), 1 deletion(-)
Documentation/netlink/specs/ethtool.yaml +12 -0
@@ -2643,6 +2643,18 @@ c-version-name: ethtool-genl-version attributes: - header - events + - + name: rss-set + doc: Set RSS params. + + attribute-set: rss + + do: + request: + attributes: + - header + - context + - indir - name: rss-ntf doc: |
Documentation/networking/ethtool-netlink.rst +25 -1
@@ -239,6 +239,7 @@ All constants identifying message types use ``ETHTOOL_CMD_`` prefix and suffix ``ETHTOOL_MSG_PHY_GET`` get Ethernet PHY information ``ETHTOOL_MSG_TSCONFIG_GET`` get hw timestamping configuration ``ETHTOOL_MSG_TSCONFIG_SET`` set hw timestamping configuration + ``ETHTOOL_MSG_RSS_SET`` set RSS settings ===================================== ================================= Kernel to userspace:
@@ -292,6 +293,7 @@ All constants identifying message types use ``ETHTOOL_CMD_`` prefix and suffix ``ETHTOOL_MSG_TSCONFIG_GET_REPLY`` hw timestamping configuration ``ETHTOOL_MSG_TSCONFIG_SET_REPLY`` new hw timestamping configuration ``ETHTOOL_MSG_PSE_NTF`` PSE events notification + ``ETHTOOL_MSG_RSS_NTF`` RSS settings notification ======================================== ================================= ``GET`` requests are sent by userspace applications to retrieve device
@@ -1989,6 +1991,28 @@ hfunc. Current supported options are symmetric-xor and symmetric-or-xor. ETHTOOL_A_RSS_FLOW_HASH carries per-flow type bitmask of which header fields are included in the hash calculation. +RSS_SET +======= + +Request contents: + +===================================== ====== ============================== + ``ETHTOOL_A_RSS_HEADER`` nested request header + ``ETHTOOL_A_RSS_CONTEXT`` u32 context number + ``ETHTOOL_A_RSS_INDIR`` binary Indir table bytes +===================================== ====== ============================== + +``ETHTOOL_A_RSS_INDIR`` is the minimal RSS table the user expects. Kernel and +the device driver may replicate the table if its smaller than smallest table +size supported by the device. For example if user requests ``[0, 1]`` but the +device needs at least 8 entries - the real table in use will end up being +``[0, 1, 0, 1, 0, 1, 0, 1]``. Most devices require the table size to be power +of 2, so tables which size is not a power of 2 will likely be rejected. +Using table of size 0 will reset the indirection table to the default. + +Note that, at present, only a subset of RSS configuration can be accomplished +over Netlink. + PLCA_GET_CFG ============
@@ -2455,7 +2479,7 @@ are netlink only. ``ETHTOOL_GRXNTUPLE`` n/a ``ETHTOOL_GSSET_INFO`` ``ETHTOOL_MSG_STRSET_GET`` ``ETHTOOL_GRXFHINDIR`` ``ETHTOOL_MSG_RSS_GET`` - ``ETHTOOL_SRXFHINDIR`` n/a + ``ETHTOOL_SRXFHINDIR`` ``ETHTOOL_MSG_RSS_SET`` ``ETHTOOL_GFEATURES`` ``ETHTOOL_MSG_FEATURES_GET`` ``ETHTOOL_SFEATURES`` ``ETHTOOL_MSG_FEATURES_SET`` ``ETHTOOL_GCHANNELS`` ``ETHTOOL_MSG_CHANNELS_GET``
include/uapi/linux/ethtool_netlink_generated.h +1 -0
@@ -840,6 +840,7 @@ enum {ETHTOOL_MSG_PHY_GET ,ETHTOOL_MSG_TSCONFIG_GET ,ETHTOOL_MSG_TSCONFIG_SET , +ETHTOOL_MSG_RSS_SET , __ETHTOOL_MSG_USER_CNT,ETHTOOL_MSG_USER_MAX = (__ETHTOOL_MSG_USER_CNT -1 )
net/ethtool/netlink.h +1 -0
@@ -484,6 +484,7 @@ extern const struct nla_policy ethnl_module_set_policy[ETHTOOL_A_MODULE_POWER_MOextern const struct nla_policy ethnl_pse_get_policy[ETHTOOL_A_PSE_HEADER +1 ];extern const struct nla_policy ethnl_pse_set_policy[ETHTOOL_A_PSE_MAX +1 ];extern const struct nla_policy ethnl_rss_get_policy[ETHTOOL_A_RSS_START_CONTEXT +1 ]; +extern const struct nla_policy ethnl_rss_set_policy[ETHTOOL_A_RSS_START_CONTEXT +1 ];extern const struct nla_policy ethnl_plca_get_cfg_policy[ETHTOOL_A_PLCA_HEADER +1 ];extern const struct nla_policy ethnl_plca_set_cfg_policy[ETHTOOL_A_PLCA_MAX +1 ];extern const struct nla_policy ethnl_plca_get_status_policy[ETHTOOL_A_PLCA_HEADER +1 ];
net/ethtool/netlink.c +8 -0
@@ -405,6 +405,7 @@ ethnl_default_requests[__ETHTOOL_MSG_USER_CNT] = { [ETHTOOL_MSG_PSE_GET] = ðnl_pse_request_ops, [ETHTOOL_MSG_PSE_SET] = ðnl_pse_request_ops, [ETHTOOL_MSG_RSS_GET] = ðnl_rss_request_ops, + [ETHTOOL_MSG_RSS_SET] = ðnl_rss_request_ops, [ETHTOOL_MSG_PLCA_GET_CFG] = ðnl_plca_cfg_request_ops, [ETHTOOL_MSG_PLCA_SET_CFG] = ðnl_plca_cfg_request_ops, [ETHTOOL_MSG_PLCA_GET_STATUS] = ðnl_plca_status_request_ops,
@@ -1504,6 +1505,13 @@ static const struct genl_ops ethtool_genl_ops[] = { .policy = ethnl_tsconfig_set_policy, .maxattr = ARRAY_SIZE(ethnl_tsconfig_set_policy) - 1, }, + { + .cmd = ETHTOOL_MSG_RSS_SET, + .flags = GENL_UNS_ADMIN_PERM, + .doit = ethnl_default_set_doit, + .policy = ethnl_rss_set_policy, + .maxattr = ARRAY_SIZE(ethnl_rss_set_policy) - 1, + }, };static const struct genl_multicast_group ethtool_nl_mcgrps[] = {
net/ethtool/rss.c +195 -0
211 lines not on this page · raw message
Signature · 1 line
2.50.1
Jakub Kicinski
maintainerPATCH v3 2/11 selftests: drv-net: rss_api: factor out checking min queue count
In reply to Jakub KicinskiMultiple tests check min queue count, create a helper.
--- .../testing/selftests/drivers/net/hw/rss_api.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
tools/testing/selftests/drivers/net/hw/rss_api.py +9 -8
@@ -13,6 +13,13 @@ from lib.py import EthtoolFamily from lib.py import NetDrvEnv +def _require_2qs(cfg): + qcnt = len(glob.glob(f"/sys/class/net/{cfg.ifname}/queues/rx-*")) + if qcnt < 2: + raise KsftSkipEx(f"Local has only {qcnt} queues") + return qcnt + + def _ethtool_create(cfg, act, opts): output = ethtool(f"{act} {cfg.ifname} {opts}").stdout # Output will be something like: "New RSS context is 1" or
@@ -57,10 +64,7 @@ from lib.py import NetDrvEnv Check that Netlink notifications are generated when RSS indirection table was modified. """ - - qcnt = len(glob.glob(f"/sys/class/net/{cfg.ifname}/queues/rx-*")) - if qcnt < 2: - raise KsftSkipEx(f"Local has only {qcnt} queues") + _require_2qs(cfg) ethnl = EthtoolFamily() ethnl.ntf_subscribe("monitor")
@@ -88,10 +92,7 @@ from lib.py import NetDrvEnv Check that Netlink notifications are generated when RSS indirection table was modified on an additional RSS context. """ - - qcnt = len(glob.glob(f"/sys/class/net/{cfg.ifname}/queues/rx-*")) - if qcnt < 2: - raise KsftSkipEx(f"Local has only {qcnt} queues") + _require_2qs(cfg) ctx_id = _ethtool_create(cfg, "-X", "context new") defer(ethtool, f"-X {cfg.ifname} context {ctx_id} delete")
Signature · 1 line
2.50.1
Jakub Kicinski
maintainerPATCH v3 3/11 tools: ynl: support packing binary arrays of scalars
In reply to Jakub KicinskiWe support decoding a binary type with a scalar subtype already, add support for sending such arrays to the kernel. While at it also support using "None" to indicate that the binary attribute should be empty. I couldn't decide whether empty binary should be [] or None, but there should be no harm in supporting both.
---
CC: [email protected]
--- tools/net/ynl/pyynl/lib/ynl.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
tools/net/ynl/pyynl/lib/ynl.py +6 -1
@@ -575,7 +575,9 @@ genl_family_name_to_id = None elif attr["type"] == 'string': attr_payload = str(value).encode('ascii') + b'\x00' elif attr["type"] == 'binary': - if isinstance(value, bytes): + if value is None: + attr_payload = b'' + elif isinstance(value, bytes): attr_payload = value elif isinstance(value, str): if attr.display_hint:
@@ -584,6 +586,9 @@ genl_family_name_to_id = None attr_payload = bytes.fromhex(value) elif isinstance(value, dict) and attr.struct_name: attr_payload = self._encode_struct(attr.struct_name, value) + elif isinstance(value, list) and attr.sub_type in NlAttr.type_formats: + format = NlAttr.get_format(attr.sub_type) + attr_payload = b''.join([format.pack(x) for x in value]) else: raise Exception(f'Unknown type for binary attribute, value: {value}') elif attr['type'] in NlAttr.type_formats or attr.is_auto_scalar:
Signature · 1 line
2.50.1
Jakub Kicinski
maintainerPATCH v3 4/11 selftests: drv-net: rss_api: test setting indirection table via Netlink
In reply to Jakub KicinskiTest setting indirection table via Netlink.
# ./tools/testing/selftests/drivers/net/hw/rss_api.py TAP version 13 1..6 ok 1 rss_api.test_rxfh_nl_set_fail ok 2 rss_api.test_rxfh_nl_set_indir ok 3 rss_api.test_rxfh_nl_set_indir_ctx ok 4 rss_api.test_rxfh_indir_ntf ok 5 rss_api.test_rxfh_indir_ctx_ntf ok 6 rss_api.test_rxfh_fields # Totals: pass:6 fail:0 xfail:0 xpass:0 skip:0 error:0
---
v3:
- adjust docstring
v2:
- test set on lo which doesn't have any ops (expected to fail)
--- .../selftests/drivers/net/hw/rss_api.py | 96 ++++++++++++++++++- 1 file changed, 93 insertions(+), 3 deletions(-)
tools/testing/selftests/drivers/net/hw/rss_api.py +93 -3
@@ -6,10 +6,10 @@ API level tests for RSS (mostly Netlink vs IOCTL). """ import glob -from lib.py import ksft_run, ksft_exit, ksft_eq, ksft_is, ksft_ne +from lib.py import ksft_run, ksft_exit, ksft_eq, ksft_is, ksft_ne, ksft_raises from lib.py import KsftSkipEx, KsftFailEx -from lib.py import defer, ethtool -from lib.py import EthtoolFamily +from lib.py import defer, ethtool, CmdExitFailure +from lib.py import EthtoolFamily, NlError from lib.py import NetDrvEnv
@@ -59,6 +59,95 @@ from lib.py import NetDrvEnv return ret +def test_rxfh_nl_set_fail(cfg): + """ + Test error path of Netlink SET. + """ + _require_2qs(cfg) + + ethnl = EthtoolFamily() + ethnl.ntf_subscribe("monitor") + + with ksft_raises(NlError): + ethnl.rss_set({"header": {"dev-name": "lo"}, + "indir": None}) + + with ksft_raises(NlError): + ethnl.rss_set({"header": {"dev-index": cfg.ifindex}, + "indir": [100000]}) + ntf = next(ethnl.poll_ntf(duration=0.2), None) + ksft_is(ntf, None) + + +def test_rxfh_nl_set_indir(cfg): + """ + Test setting indirection table via Netlink. + """ + qcnt = _require_2qs(cfg) + + # Test some SETs with a value + reset = defer(cfg.ethnl.rss_set, + {"header": {"dev-index": cfg.ifindex}, "indir": None}) + cfg.ethnl.rss_set({"header": {"dev-index": cfg.ifindex}, + "indir": [1]}) + rss = cfg.ethnl.rss_get({"header": {"dev-index": cfg.ifindex}}) + ksft_eq(set(rss.get("indir", [-1])), {1}) + + cfg.ethnl.rss_set({"header": {"dev-index": cfg.ifindex}, + "indir": [0, 1]}) + rss = cfg.ethnl.rss_get({"header": {"dev-index": cfg.ifindex}}) + ksft_eq(set(rss.get("indir", [-1])), {0, 1}) + + # Make sure we can't set the queue count below max queue used + with ksft_raises(CmdExitFailure): + ethtool(f"-L {cfg.ifname} combined 0 rx 1") + with ksft_raises(CmdExitFailure): + ethtool(f"-L {cfg.ifname} combined 1 rx 0") + + # Test reset back to default + reset.exec() + rss = cfg.ethnl.rss_get({"header": {"dev-index": cfg.ifindex}}) + ksft_eq(set(rss.get("indir", [-1])), set(range(qcnt))) + + +def test_rxfh_nl_set_indir_ctx(cfg): + """ + Test setting indirection table for a custom context via Netlink. + """ + _require_2qs(cfg) + + # Get setting for ctx 0, we'll make sure they don't get clobbered + dflt = cfg.ethnl.rss_get({"header": {"dev-index": cfg.ifindex}}) + + # Create context + ctx_id = _ethtool_create(cfg, "-X", "context new") + defer(ethtool, f"-X {cfg.ifname} context {ctx_id} delete") + + cfg.ethnl.rss_set({"header": {"dev-index": cfg.ifindex}, + "context": ctx_id, "indir": [1]}) + rss = cfg.ethnl.rss_get({"header": {"dev-index": cfg.ifindex}, + "context": ctx_id}) + ksft_eq(set(rss.get("indir", [-1])), {1}) + + ctx0 = cfg.ethnl.rss_get({"header": {"dev-index": cfg.ifindex}}) + ksft_eq(ctx0, dflt) + + cfg.ethnl.rss_set({"header": {"dev-index": cfg.ifindex}, + "context": ctx_id, "indir": [0, 1]}) + rss = cfg.ethnl.rss_get({"header": {"dev-index": cfg.ifindex}, + "context": ctx_id}) + ksft_eq(set(rss.get("indir", [-1])), {0, 1}) + + ctx0 = cfg.ethnl.rss_get({"header": {"dev-index": cfg.ifindex}}) + ksft_eq(ctx0, dflt) + + # Make sure we can't set the queue count below max queue used + with ksft_raises(CmdExitFailure): + ethtool(f"-L {cfg.ifname} combined 0 rx 1") + with ksft_raises(CmdExitFailure): + ethtool(f"-L {cfg.ifname} combined 1 rx 0") + + def test_rxfh_indir_ntf(cfg): """ Check that Netlink notifications are generated when RSS indirection
@@ -129,6 +218,7 @@ from lib.py import NetDrvEnv """ Ksft boiler plate main """ with NetDrvEnv(__file__, nsim_test=False) as cfg: + cfg.ethnl = EthtoolFamily() ksft_run(globs=globals(), case_pfx={"test_"}, args=(cfg, )) ksft_exit()
Signature · 1 line
2.50.1
Jakub Kicinski
maintainerPATCH v3 5/11 ethtool: rss: support setting hfunc via Netlink
In reply to Jakub KicinskiSupport setting RSS hash function / algo via ethtool Netlink. Like IOCTL we don't validate that the function is within the range known to the kernel. The drivers do a pretty good job validating the inputs, and the IDs are technically "dynamically queried" rather than part of uAPI.
Only change should be that in Netlink we don't support user explicitly passing ETH_RSS_HASH_NO_CHANGE (0), if no change is requested the attribute should be absent.
The ETH_RSS_HASH_NO_CHANGE is retained in driver-facing API for consistency (not that I see a strong reason for it).
--- Documentation/netlink/specs/ethtool.yaml | 1 + Documentation/networking/ethtool-netlink.rst | 1 + net/ethtool/rss.c | 12 +++++++++++- 3 files changed, 13 insertions(+), 1 deletion(-)
Documentation/netlink/specs/ethtool.yaml +1 -0
@@ -2654,6 +2654,7 @@ c-version-name: ethtool-genl-version attributes: - header - context + - hfunc - indir - name: rss-ntf
Documentation/networking/ethtool-netlink.rst +1 -0
@@ -1999,6 +1999,7 @@ RSS_SET ===================================== ====== ============================== ``ETHTOOL_A_RSS_HEADER`` nested request header ``ETHTOOL_A_RSS_CONTEXT`` u32 context number + ``ETHTOOL_A_RSS_HFUNC`` u32 RSS hash func ``ETHTOOL_A_RSS_INDIR`` binary Indir table bytes ===================================== ====== ==============================
net/ethtool/rss.c +11 -1
@@ -475,6 +475,7 @@ void ethtool_rss_notify(struct net_device *dev, u32 rss_context)const struct nla_policy ethnl_rss_set_policy[ETHTOOL_A_RSS_START_CONTEXT +1 ] = { [ETHTOOL_A_RSS_HEADER ] =NLA_POLICY_NESTED (ethnl_header_policy), [ETHTOOL_A_RSS_CONTEXT ] = { .type =NLA_U32 , }, + [ETHTOOL_A_RSS_HFUNC ] =NLA_POLICY_MIN (NLA_U32 ,1 ), [ETHTOOL_A_RSS_INDIR ] = { .type =NLA_BINARY , }, };
@@ -489,6 +490,9 @@ ethnl_rss_set_validate(struct ethnl_req_info *req_info, struct genl_info *info)if (request->rss_context && !ops->create_rxfh_context) bad_attr = bad_attr ?: tb[ETHTOOL_A_RSS_CONTEXT ]; +if (request->rss_context && !ops->rxfh_per_ctx_key) + bad_attr = bad_attr ?: tb[ETHTOOL_A_RSS_HFUNC ]; +if (bad_attr) {NL_SET_BAD_ATTR (info->extack, bad_attr);return -EOPNOTSUPP ;
@@ -588,6 +592,8 @@ rss_set_ctx_update(struct ethtool_rxfh_context *ctx, struct nlattr **tb,ethtool_rxfh_context_indir (ctx)[i] = rxfh->indir[i]; ctx->indir_configured = !!nla_len (tb[ETHTOOL_A_RSS_INDIR ]); } +if (rxfh->hfunc !=ETH_RSS_HASH_NO_CHANGE ) + ctx->hfunc = rxfh->hfunc; } static int
@@ -618,7 +624,11 @@ ethnl_rss_set(struct ethnl_req_info *req_info, struct genl_info *info) goto exit_clean_data; indir_mod = !!tb[ETHTOOL_A_RSS_INDIR ]; - rxfh.hfunc =ETH_RSS_HASH_NO_CHANGE ; + rxfh.hfunc = data.hfunc; +ethnl_update_u8 (&rxfh.hfunc, tb[ETHTOOL_A_RSS_HFUNC ], &mod); +if (rxfh.hfunc == data.hfunc) + rxfh.hfunc =ETH_RSS_HASH_NO_CHANGE ; + rxfh.input_xfrm =RXH_XFRM_NO_CHANGE ;mutex_lock (&dev->ethtool->rss_lock);
Signature · 1 line
2.50.1
Jakub Kicinski
maintainerPATCH v3 6/11 ethtool: rss: support setting hkey via Netlink
In reply to Jakub KicinskiSupport setting RSS hashing key via ethtool Netlink. Use the Netlink policy to make sure user doesn't pass an empty key, "resetting" the key is not a thing.
---
v2:
- use ethnl_update_binary()
- make sure we free indir if key parsing fails
--- Documentation/netlink/specs/ethtool.yaml | 1 + Documentation/networking/ethtool-netlink.rst | 1 + net/ethtool/rss.c | 41 +++++++++++++++++++- 3 files changed, 42 insertions(+), 1 deletion(-)
Documentation/netlink/specs/ethtool.yaml +1 -0
@@ -2656,6 +2656,7 @@ c-version-name: ethtool-genl-version - context - hfunc - indir + - hkey - name: rss-ntf doc: |
Documentation/networking/ethtool-netlink.rst +1 -0
@@ -2001,6 +2001,7 @@ RSS_SET ``ETHTOOL_A_RSS_CONTEXT`` u32 context number ``ETHTOOL_A_RSS_HFUNC`` u32 RSS hash func ``ETHTOOL_A_RSS_INDIR`` binary Indir table bytes + ``ETHTOOL_A_RSS_HKEY`` binary Hash key bytes ===================================== ====== ============================== ``ETHTOOL_A_RSS_INDIR`` is the minimal RSS table the user expects. Kernel and
net/ethtool/rss.c +40 -1
78 lines not on this page · raw message
Signature · 1 line
2.50.1
Jakub Kicinski
maintainerPATCH v3 7/11 selftests: drv-net: rss_api: test setting hashing key via Netlink
In reply to Jakub KicinskiTest setting hashing key via Netlink.
# ./tools/testing/selftests/drivers/net/hw/rss_api.py TAP version 13 1..7 ok 1 rss_api.test_rxfh_nl_set_fail ok 2 rss_api.test_rxfh_nl_set_indir ok 3 rss_api.test_rxfh_nl_set_indir_ctx ok 4 rss_api.test_rxfh_indir_ntf ok 5 rss_api.test_rxfh_indir_ctx_ntf ok 6 rss_api.test_rxfh_nl_set_key ok 7 rss_api.test_rxfh_fields # Totals: pass:7 fail:0 xfail:0 xpass:0 skip:0 error:0
--- .../selftests/drivers/net/hw/rss_api.py | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+)
tools/testing/selftests/drivers/net/hw/rss_api.py +33 -0
@@ -6,6 +6,7 @@ API level tests for RSS (mostly Netlink vs IOCTL). """ import glob +import random from lib.py import ksft_run, ksft_exit, ksft_eq, ksft_is, ksft_ne, ksft_raises from lib.py import KsftSkipEx, KsftFailEx from lib.py import defer, ethtool, CmdExitFailure
@@ -199,6 +200,38 @@ from lib.py import NetDrvEnv ksft_eq(set(ntf["msg"]["indir"]), {1}) +def test_rxfh_nl_set_key(cfg): + """ + Test setting hashing key via Netlink. + """ + + dflt = cfg.ethnl.rss_get({"header": {"dev-index": cfg.ifindex}}) + defer(cfg.ethnl.rss_set, + {"header": {"dev-index": cfg.ifindex}, + "hkey": dflt["hkey"], "indir": None}) + + # Empty key should error out + with ksft_raises(NlError) as cm: + cfg.ethnl.rss_set({"header": {"dev-index": cfg.ifindex}, + "hkey": None}) + ksft_eq(cm.exception.nl_msg.extack['bad-attr'], '.hkey') + + # Set key to random + mod = random.randbytes(len(dflt["hkey"])) + cfg.ethnl.rss_set({"header": {"dev-index": cfg.ifindex}, + "hkey": mod}) + rss = cfg.ethnl.rss_get({"header": {"dev-index": cfg.ifindex}}) + ksft_eq(rss.get("hkey", [-1]), mod) + + # Set key to random and indir tbl to something at once + mod = random.randbytes(len(dflt["hkey"])) + cfg.ethnl.rss_set({"header": {"dev-index": cfg.ifindex}, + "indir": [0, 1], "hkey": mod}) + rss = cfg.ethnl.rss_get({"header": {"dev-index": cfg.ifindex}}) + ksft_eq(rss.get("hkey", [-1]), mod) + ksft_eq(set(rss.get("indir", [-1])), {0, 1}) + + def test_rxfh_fields(cfg): """ Test reading Rx Flow Hash over Netlink.
Signature · 1 line
2.50.1
Jakub Kicinski
maintainerPATCH v3 8/11 netlink: specs: define input-xfrm enum in the spec
In reply to Jakub KicinskiHelp YNL decode the values for input-xfrm by defining the possible values in the spec. Don't define "no change" as it's an IOCTL artifact with no use in Netlink.
With this change on mlx5 input-xfrm gets decoded:
# ynl --family ethtool --dump rss-get
[{'header': {'dev-index': 2, 'dev-name': 'eth0'},
'hfunc': 1,
'hkey': b'V\xa8\xf9\x9 ...',
'indir': [0, 1, ... ],
'input-xfrm': {'sym-or-xor'}, <<<
'flow-hash': {'ah4': {'ip-dst', 'ip-src'},
'ah6': {'ip-dst', 'ip-src'},
'esp4': {'ip-dst', 'ip-src'},
'esp6': {'ip-dst', 'ip-src'},
'ip4': {'ip-dst', 'ip-src'},
'ip6': {'ip-dst', 'ip-src'},
'tcp4': {'l4-b-0-1', 'ip-dst', 'l4-b-2-3', 'ip-src'},
'tcp6': {'l4-b-0-1', 'ip-dst', 'l4-b-2-3', 'ip-src'},
'udp4': {'l4-b-0-1', 'ip-dst', 'l4-b-2-3', 'ip-src'},
'udp6': {'l4-b-0-1', 'ip-dst', 'l4-b-2-3', 'ip-src'}}
}]---
v3:
- make input xfrm a flags field
v2:
- adjust the test to decoded values
--- Documentation/netlink/specs/ethtool.yaml | 21 +++++++++++++++++++ .../drivers/net/hw/rss_input_xfrm.py | 6 +++--- 2 files changed, 24 insertions(+), 3 deletions(-)
Documentation/netlink/specs/ethtool.yaml +21 -0
@@ -158,6 +158,26 @@ c-version-name: ethtool-genl-version - name: pse-event-sw-pw-control-error doc: PSE faced an error managing the power control from software + - + name: input-xfrm + doc: RSS hash function transformations. + type: flags + enum-name: + name-prefix: rxh-xfrm- + header: linux/ethtool.h + entries: + - + name: sym-xor + doc: >- + XOR the corresponding source and destination fields of each specified + protocol. Both copies of the XOR'ed fields are fed into the RSS and + RXHASH calculation. Note that this XORing reduces the input set + entropy and could be exploited to reduce the RSS queue spread. + - + name: sym-or-xor + doc: >- + Similar to SYM_XOR, except that one copy of the XOR'ed fields is + replaced by an OR of the same fields. - name: rxfh-fields name-prefix: rxh-
@@ -1621,6 +1641,7 @@ c-version-name: ethtool-genl-version - name: input-xfrm type: u32 + enum: input-xfrm - name: start-context type: u32
tools/testing/selftests/drivers/net/hw/rss_input_xfrm.py +3 -3
@@ -37,11 +37,11 @@ from lib.py import rand_port if not hasattr(socket, "SO_INCOMING_CPU"): raise KsftSkipEx("socket.SO_INCOMING_CPU was added in Python 3.11") - input_xfrm = cfg.ethnl.rss_get( - {'header': {'dev-name': cfg.ifname}}).get('input-xfrm') + rss = cfg.ethnl.rss_get({'header': {'dev-name': cfg.ifname}}) + input_xfrm = set(filter(lambda x: 'sym' in x, rss.get('input-xfrm', {}))) # Check for symmetric xor/or-xor - if not input_xfrm or (input_xfrm != 1 and input_xfrm != 2): + if not input_xfrm: raise KsftSkipEx("Symmetric RSS hash not requested") cpus = set()
Signature · 1 line
2.50.1
Jakub Kicinski
maintainerPATCH v3 9/11 ethtool: rss: support setting input-xfrm via Netlink
In reply to Jakub KicinskiSupport configuring symmetric hashing via Netlink.
We have the flow field config prepared as part of SET handling, so scan it for conflicts instead of querying the driver again.
---
v2:
- improve comment on xfrm_sym calculation
--- Documentation/netlink/specs/ethtool.yaml | 1 + Documentation/networking/ethtool-netlink.rst | 4 +- net/ethtool/common.h | 1 + net/ethtool/common.c | 15 ++++++ net/ethtool/ioctl.c | 4 +- net/ethtool/rss.c | 54 +++++++++++++++++++- 6 files changed, 71 insertions(+), 8 deletions(-)
Documentation/netlink/specs/ethtool.yaml +1 -0
@@ -2678,6 +2678,7 @@ c-version-name: ethtool-genl-version - hfunc - indir - hkey + - input-xfrm - name: rss-ntf doc: |
Documentation/networking/ethtool-netlink.rst +1 -3
@@ -2002,6 +2002,7 @@ RSS_SET ``ETHTOOL_A_RSS_HFUNC`` u32 RSS hash func ``ETHTOOL_A_RSS_INDIR`` binary Indir table bytes ``ETHTOOL_A_RSS_HKEY`` binary Hash key bytes + ``ETHTOOL_A_RSS_INPUT_XFRM`` u32 RSS input data transformation ===================================== ====== ============================== ``ETHTOOL_A_RSS_INDIR`` is the minimal RSS table the user expects. Kernel and
@@ -2012,9 +2013,6 @@ device needs at least 8 entries - the real table in use will end up being of 2, so tables which size is not a power of 2 will likely be rejected. Using table of size 0 will reset the indirection table to the default. -Note that, at present, only a subset of RSS configuration can be accomplished -over Netlink. - PLCA_GET_CFG ============
net/ethtool/common.h +1 -0
@@ -44,6 +44,7 @@ int ethtool_check_max_channel(struct net_device *dev,struct ethtool_channels channels, struct genl_info *info);int ethtool_check_rss_ctx_busy (struct net_device *dev,u32 rss_context); +int ethtool_rxfh_config_is_sym (u64 rxfh); void ethtool_ringparam_get_cfg(struct net_device *dev, struct ethtool_ringparam *param,
net/ethtool/common.c +15 -0
@@ -806,6 +806,21 @@ int ethtool_check_rss_ctx_busy(struct net_device *dev, u32 rss_context)return rc; } +/* Check if fields configured for flow hash are symmetric - if src is included +* so is dst and vice versa. +*/ +int ethtool_rxfh_config_is_sym (u64 rxfh) +{ +bool sym; + + sym = rxfh == (rxfh & (RXH_IP_SRC |RXH_IP_DST | +RXH_L4_B_0_1 |RXH_L4_B_2_3 )); + sym &= !!(rxfh &RXH_IP_SRC ) == !!(rxfh &RXH_IP_DST ); + sym &= !!(rxfh &RXH_L4_B_0_1 ) == !!(rxfh &RXH_L4_B_2_3 ); + +return sym; +} +int ethtool_check_ops (const struct ethtool_ops *ops) {if (WARN_ON (ops->set_coalesce && !ops->supported_coalesce_params))
net/ethtool/ioctl.c +1 -3
@@ -1027,9 +1027,7 @@ static int ethtool_check_xfrm_rxfh(u32 input_xfrm, u64 rxfh)*/ if ((input_xfrm !=RXH_XFRM_NO_CHANGE && input_xfrm & (RXH_XFRM_SYM_XOR |RXH_XFRM_SYM_OR_XOR )) && - ((rxfh & ~(RXH_IP_SRC |RXH_IP_DST |RXH_L4_B_0_1 |RXH_L4_B_2_3 )) || - (!!(rxfh &RXH_IP_SRC ) ^ !!(rxfh &RXH_IP_DST )) || - (!!(rxfh &RXH_L4_B_0_1 ) ^ !!(rxfh &RXH_L4_B_2_3 )))) + !ethtool_rxfh_config_is_sym (rxfh))return -EINVAL ;return 0 ;
net/ethtool/rss.c +52 -2
101 lines not on this page · raw message
Signature · 1 line
2.50.1
Jakub Kicinski
maintainerPATCH v3 10/11 ethtool: rss: support setting flow hashing fields
In reply to Jakub KicinskiAdd support for ETHTOOL_SRXFH (setting hashing fields) in RSS_SET.
The tricky part is dealing with symmetric hashing. In netlink user can change the hashing fields and symmetric hash in one request, in IOCTL the two used to be set via different uAPI requests. Since fields and hash function config are still separate driver callbacks - changes to the two are not atomic. Keep things simple and validate the settings against both pre- and post- change ones. Meaning that we will reject the config request if user tries to correct the flow fields and set input_xfrm in one request, or disables input_xfrm and makes flow fields non-symmetric.
We can adjust it later if there's a real need. Starting simple feels right, and potentially partially applying the settings isn't nice, either.
---
v2:
- improve commit msg
--- Documentation/netlink/specs/ethtool.yaml | 1 + Documentation/networking/ethtool-netlink.rst | 3 +- net/ethtool/netlink.h | 2 +- net/ethtool/rss.c | 111 +++++++++++++++++-- 4 files changed, 107 insertions(+), 10 deletions(-)
Documentation/netlink/specs/ethtool.yaml +1 -0
@@ -2679,6 +2679,7 @@ c-version-name: ethtool-genl-version - indir - hkey - input-xfrm + - flow-hash - name: rss-ntf doc: |
Documentation/networking/ethtool-netlink.rst +2 -1
@@ -2003,6 +2003,7 @@ RSS_SET ``ETHTOOL_A_RSS_INDIR`` binary Indir table bytes ``ETHTOOL_A_RSS_HKEY`` binary Hash key bytes ``ETHTOOL_A_RSS_INPUT_XFRM`` u32 RSS input data transformation + ``ETHTOOL_A_RSS_FLOW_HASH`` nested Header fields included in hash ===================================== ====== ============================== ``ETHTOOL_A_RSS_INDIR`` is the minimal RSS table the user expects. Kernel and
@@ -2464,7 +2465,7 @@ are netlink only. ``ETHTOOL_GPFLAGS`` ``ETHTOOL_MSG_PRIVFLAGS_GET`` ``ETHTOOL_SPFLAGS`` ``ETHTOOL_MSG_PRIVFLAGS_SET`` ``ETHTOOL_GRXFH`` ``ETHTOOL_MSG_RSS_GET`` - ``ETHTOOL_SRXFH`` n/a + ``ETHTOOL_SRXFH`` ``ETHTOOL_MSG_RSS_SET`` ``ETHTOOL_GGRO`` ``ETHTOOL_MSG_FEATURES_GET`` ``ETHTOOL_SGRO`` ``ETHTOOL_MSG_FEATURES_SET`` ``ETHTOOL_GRXRINGS`` n/a
net/ethtool/netlink.h +1 -1
@@ -484,7 +484,7 @@ extern const struct nla_policy ethnl_module_set_policy[ETHTOOL_A_MODULE_POWER_MOextern const struct nla_policy ethnl_pse_get_policy[ETHTOOL_A_PSE_HEADER +1 ];extern const struct nla_policy ethnl_pse_set_policy[ETHTOOL_A_PSE_MAX +1 ];extern const struct nla_policy ethnl_rss_get_policy[ETHTOOL_A_RSS_START_CONTEXT +1 ]; -extern const struct nla_policy ethnl_rss_set_policy[ETHTOOL_A_RSS_START_CONTEXT +1 ]; +extern const struct nla_policy ethnl_rss_set_policy[ETHTOOL_A_RSS_FLOW_HASH +1 ];extern const struct nla_policy ethnl_plca_get_cfg_policy[ETHTOOL_A_PLCA_HEADER +1 ];extern const struct nla_policy ethnl_plca_set_cfg_policy[ETHTOOL_A_PLCA_MAX +1 ];extern const struct nla_policy ethnl_plca_get_status_policy[ETHTOOL_A_PLCA_HEADER +1 ];
net/ethtool/rss.c +103 -8
166 lines not on this page · raw message
Signature · 1 line
2.50.1
Jakub Kicinski
maintainerPATCH v3 11/11 selftests: drv-net: rss_api: test input-xfrm and hash fields
In reply to Jakub KicinskiTest configuring input-xfrm and hash fields with all the limitations. Tested on mlx5 (CX6):
# ./ksft-net-drv/drivers/net/hw/rss_api.py TAP version 13 1..10 ok 1 rss_api.test_rxfh_nl_set_fail ok 2 rss_api.test_rxfh_nl_set_indir ok 3 rss_api.test_rxfh_nl_set_indir_ctx ok 4 rss_api.test_rxfh_indir_ntf ok 5 rss_api.test_rxfh_indir_ctx_ntf ok 6 rss_api.test_rxfh_nl_set_key ok 7 rss_api.test_rxfh_fields ok 8 rss_api.test_rxfh_fields_set ok 9 rss_api.test_rxfh_fields_set_xfrm ok 10 rss_api.test_rxfh_fields_ntf # Totals: pass:10 fail:0 xfail:0 xpass:0 skip:0 error:0
---
v3:
- adjust after input_xfrm became a set
v2:
- make defer() cleanup more intelligent WRT ordering
--- .../selftests/drivers/net/hw/rss_api.py | 143 ++++++++++++++++++ 1 file changed, 143 insertions(+)
tools/testing/selftests/drivers/net/hw/rss_api.py +143 -0
@@ -247,6 +247,149 @@ from lib.py import NetDrvEnv comment="Config for " + fl_type) +def test_rxfh_fields_set(cfg): + """ Test configuring Rx Flow Hash over Netlink. """ + + flow_types = ["tcp4", "tcp6", "udp4", "udp6"] + + # Collect current settings + cfg_old = cfg.ethnl.rss_get({"header": {"dev-index": cfg.ifindex}}) + # symmetric hashing is config-order-sensitive make sure we leave + # symmetric mode, or make the flow-hash sym-compatible first + changes = [{"flow-hash": cfg_old["flow-hash"],}, + {"input-xfrm": cfg_old.get("input-xfrm", {}),}] + if cfg_old.get("input-xfrm"): + changes = list(reversed(changes)) + for old in changes: + defer(cfg.ethnl.rss_set, {"header": {"dev-index": cfg.ifindex},} | old) + + # symmetric hashing prevents some of the configs below + if cfg_old.get("input-xfrm"): + cfg.ethnl.rss_set({"header": {"dev-index": cfg.ifindex}, + "input-xfrm": {}}) + + for fl_type in flow_types: + cur = _ethtool_get_cfg(cfg, fl_type) + if cur == "sdfn": + change_nl = {"ip-src", "ip-dst"} + change_ic = "sd" + else: + change_nl = {"l4-b-0-1", "l4-b-2-3", "ip-src", "ip-dst"} + change_ic = "sdfn" + + cfg.ethnl.rss_set({ + "header": {"dev-index": cfg.ifindex}, + "flow-hash": {fl_type: change_nl} + }) + reset = defer(ethtool, f"--disable-netlink -N {cfg.ifname} " + f"rx-flow-hash {fl_type} {cur}") + + cfg_nl = cfg.ethnl.rss_get({"header": {"dev-index": cfg.ifindex}}) + ksft_eq(change_nl, cfg_nl["flow-hash"][fl_type], + comment=f"Config for {fl_type} over Netlink") + cfg_ic = _ethtool_get_cfg(cfg, fl_type) + ksft_eq(change_ic, cfg_ic, + comment=f"Config for {fl_type} over IOCTL") + + reset.exec() + cfg_nl = cfg.ethnl.rss_get({"header": {"dev-index": cfg.ifindex}}) + ksft_eq(cfg_old["flow-hash"][fl_type], cfg_nl["flow-hash"][fl_type], + comment=f"Un-config for {fl_type} over Netlink") + cfg_ic = _ethtool_get_cfg(cfg, fl_type) + ksft_eq(cur, cfg_ic, comment=f"Un-config for {fl_type} over IOCTL") + + # Try to set multiple at once, the defer was already installed at the start + change = {"ip-src"} + if change == cfg_old["flow-hash"]["tcp4"]: + change = {"ip-dst"} + cfg.ethnl.rss_set({ + "header": {"dev-index": cfg.ifindex}, + "flow-hash": {x: change for x in flow_types} + }) + + cfg_nl = cfg.ethnl.rss_get({"header": {"dev-index": cfg.ifindex}}) + for fl_type in flow_types: + ksft_eq(change, cfg_nl["flow-hash"][fl_type], + comment=f"multi-config for {fl_type} over Netlink") + + +def test_rxfh_fields_set_xfrm(cfg): + """ Test changing Rx Flow Hash vs xfrm_input at once. """ + + def set_rss(cfg, xfrm, fh): + cfg.ethnl.rss_set({"header": {"dev-index": cfg.ifindex}, + "input-xfrm": xfrm, "flow-hash": fh}) + + # Install the reset handler + cfg_old = cfg.ethnl.rss_get({"header": {"dev-index": cfg.ifindex}}) + # symmetric hashing is config-order-sensitive make sure we leave + # symmetric mode, or make the flow-hash sym-compatible first + changes = [{"flow-hash": cfg_old["flow-hash"],}, + {"input-xfrm": cfg_old.get("input-xfrm", {}),}] + if cfg_old.get("input-xfrm"): + changes = list(reversed(changes)) + for old in changes: + defer(cfg.ethnl.rss_set, {"header": {"dev-index": cfg.ifindex},} | old) + + # Make sure we start with input-xfrm off, and tcp4 config non-sym + set_rss(cfg, {}, {}) + set_rss(cfg, {}, {"tcp4": {"ip-src"}}) + + # Setting sym and fixing tcp4 config not expected to pass right now + with ksft_raises(NlError): + set_rss(cfg, {"sym-xor"}, {"tcp4": {"ip-src", "ip-dst"}}) + # One at a time should work, hopefully + set_rss(cfg, 0, {"tcp4": {"ip-src", "ip-dst"}}) + no_support = False + try: + set_rss(cfg, {"sym-xor"}, {}) + except NlError: + try: + set_rss(cfg, {"sym-or-xor"}, {}) + except NlError: + no_support = True + if no_support: + raise KsftSkipEx("no input-xfrm supported") + # Disabling two at once should not work either without kernel changes + with ksft_raises(NlError): + set_rss(cfg, {}, {"tcp4": {"ip-src"}}) + + +def test_rxfh_fields_ntf(cfg): + """ Test Rx Flow Hash notifications. """ + + cur = _ethtool_get_cfg(cfg, "tcp4") + if cur == "sdfn": + change = {"ip-src", "ip-dst"} + else: + change = {"l4-b-0-1", "l4-b-2-3", "ip-src", "ip-dst"} + + ethnl = EthtoolFamily() + ethnl.ntf_subscribe("monitor") + + ethnl.rss_set({ + "header": {"dev-index": cfg.ifindex}, + "flow-hash": {"tcp4": change} + }) + reset = defer(ethtool, + f"--disable-netlink -N {cfg.ifname} rx-flow-hash tcp4 {cur}") + + ntf = next(ethnl.poll_ntf(duration=0.2), None) + if ntf is None: + raise KsftFailEx("No notification received after IOCTL change") + ksft_eq(ntf["name"], "rss-ntf") + ksft_eq(ntf["msg"]["flow-hash"]["tcp4"], change) + ksft_eq(next(ethnl.poll_ntf(duration=0.01), None), None) + + reset.exec() + ntf = next(ethnl.poll_ntf(duration=0.2), None) + if ntf is None: + raise KsftFailEx("No notification received after Netlink change") + ksft_eq(ntf["name"], "rss-ntf") + ksft_ne(ntf["msg"]["flow-hash"]["tcp4"], change) + ksft_eq(next(ethnl.poll_ntf(duration=0.01), None), None) + + def main() -> None: """ Ksft boiler plate main """
Signature · 1 line
2.50.1
Re: [PATCH net-next v3 10/11] ethtool: rss: support setting flow hashing fields
In reply to Jakub KicinskiQuoted 12 lines · Jakub Kicinski
Add support for
ETHTOOL_SRXFH(setting hashing fields) inRSS_SET.The tricky part is dealing with symmetric hashing. In netlink user can change the hashing fields and symmetric hash in one request, in IOCTL the two used to be set via different uAPI requests. Since fields and hash function config are still separate driver callbacks - changes to the two are not atomic. Keep things simple and validate the settings against both pre- and post- change ones. Meaning that we will reject the config request if user tries to correct the flow fields and set
input_xfrmin one request, or disablesinput_xfrmand makes flow fields non-symmetric.
Quoted 5 lines
We can adjust it later if there's a real need. Starting simple feels right, and potentially partially applying the settings isn't nice, either.
Signed-off-by Jakub Kicinski <[email protected]>
Re: [PATCH net-next v3 01/11] ethtool: rss: initial RSS_SET (indirection table handling)
In reply to Jakub KicinskiQuoted 43 lines · Jakub Kicinski
Add initial support for
RSS_SET, for now only operations on the indirection table are supported.Unlike the ioctl don't check if at least one parameter is being changed. This is how other ethtool-nl ops behave, so pick the ethtool-nl consistency vs copying ioctl behavior.
There are two special cases here:
1) resetting the table to defaults;
2) support for tables of different size.For (1) I use an empty Netlink attribute (array of size 0).
(2) may require some background. AFAICT a lot of modern devices allow allocating RSS tables of different sizes. mlx5 can upsize its tables, bnxt has some "table size calculation", and Intel folks asked about RSS table sizing in context of resource allocation in the past. The ethtool IOCTL API has a concept of table size, but right now the user is expected to provide a table exactly the size the device requests. Some drivers may change the table size at runtime (in response to queue count changes) but the user is not in control of this. What's not great is that all RSS contexts share the same table size. For example a device with 128 queues enabled, 16 RSS contexts 8 queues in each will likely have 256 entry tables for each of the 16 contexts, while 32 would be more than enough given each context only has 8 queues. To address this the Netlink API should avoid enforcing table size at the uAPI level, and should allow the user to express the min table size they expect.
To fully solve (2) we will need more driver plumbing but at the uAPI level this patch allows the user to specify a table size smaller than what the device advertises. The device table size must be a multiple of the user requested table size. We then replicate the user-provided table to fill the full device size table. This addresses the "allow the user to express the min table size" objective, while not enforcing any fixed size. From Netlink perspective .get_rxfh_indir_size() is now de facto the "max" table size supported by the device.
We may choose to support table replication in ethtool, too, when we actually plumb this thru the device APIs.
Quoted 7 lines
Initially I was considering moving full pattern generation to the kernel (which queues to use, at which frequency and what min sequence length). I don't think this complexity would buy us much and most if not all devices have pow-2 table sizes, which simplifies the replication a lot.
Signed-off-by Jakub Kicinski <[email protected]>
Re: [PATCH net-next v3 08/11] netlink: specs: define input-xfrm enum in the spec
In reply to Jakub KicinskiQuoted 24 lines · Jakub Kicinski
Help YNL decode the values for input-xfrm by defining the possible values in the spec. Don't define "no change" as it's an IOCTL artifact with no use in Netlink.
With this change on mlx5 input-xfrm gets decoded:
# ynl --family ethtool --dump rss-get [{'header': {'dev-index': 2, 'dev-name': 'eth0'}, 'hfunc': 1, 'hkey': b'V\xa8\xf9\x9 ...', 'indir': [0, 1, ... ], 'input-xfrm': {'sym-or-xor'}, <<< 'flow-hash': {'ah4': {'ip-dst', 'ip-src'}, 'ah6': {'ip-dst', 'ip-src'}, 'esp4': {'ip-dst', 'ip-src'}, 'esp6': {'ip-dst', 'ip-src'}, 'ip4': {'ip-dst', 'ip-src'}, 'ip6': {'ip-dst', 'ip-src'}, 'tcp4': {'l4-b-0-1', 'ip-dst', 'l4-b-2-3', 'ip-src'}, 'tcp6': {'l4-b-0-1', 'ip-dst', 'l4-b-2-3', 'ip-src'}, 'udp4': {'l4-b-0-1', 'ip-dst', 'l4-b-2-3', 'ip-src'}, 'udp6': {'l4-b-0-1', 'ip-dst', 'l4-b-2-3', 'ip-src'}} }]
Quoted 1 line
Signed-off-by Jakub Kicinski <[email protected]>
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 18 lines · On Tue, 15 Jul 2025 17:03:20 -0700 you wrote:
Support configuring RSS settings via Netlink.
Creating and removing contexts remains for the following series.v3:
- decode xfrm-input as flags not enum
- check driver supportsget_rxnfcop
v2: https://lore.kernel.org/[email protected]
- commit message changes
- make sure driver implements theset_rxfhop
- add comment about early return when lacking get
- setIFF_RXFH_CONFIGUREDeven if user sets the table to identical to default
- useethnl_update_binary()
- make sure we free indir if key parsing fails
- tests: fix existingrxfh_input_xfrmtest for string decode
- tests: makedefer()cleanup more intelligent WRT ordering
v1: https://lore.kernel.org/[email protected]
Quoted 1 line
[...]
Here is the summary with links:
- [net-next,v3,01/11] ethtool: rss: initial RSS_SET (indirection table handling)
https://git.kernel.org/netdev/net-next/c/c0ae03588bbb - [net-next,v3,02/11] selftests: drv-net: rss_api: factor out checking min queue count https://git.kernel.org/netdev/net-next/c/1560af51e1ea - [net-next,v3,03/11] tools: ynl: support packing binary arrays of scalars https://git.kernel.org/netdev/net-next/c/c3e914031039 - [net-next,v3,04/11] selftests: drv-net: rss_api: test setting indirection table via Netlink https://git.kernel.org/netdev/net-next/c/6e7eb93a692c - [net-next,v3,05/11] ethtool: rss: support setting hfunc via Netlink https://git.kernel.org/netdev/net-next/c/82ae67cbc423 - [net-next,v3,06/11] ethtool: rss: support setting hkey via Netlink https://git.kernel.org/netdev/net-next/c/51798c519a91 - [net-next,v3,07/11] selftests: drv-net: rss_api: test setting hashing key via Netlink https://git.kernel.org/netdev/net-next/c/169b26207a46 - [net-next,v3,08/11] netlink: specs: define input-xfrm enum in the spec https://git.kernel.org/netdev/net-next/c/c1b27f0695d6 - [net-next,v3,09/11] ethtool: rss: support setting input-xfrm via Netlink https://git.kernel.org/netdev/net-next/c/d3e2c7bab124 - [net-next,v3,10/11] ethtool: rss: support setting flow hashing fields https://git.kernel.org/netdev/net-next/c/2f70251112ec - [net-next,v3,11/11] selftests: drv-net: rss_api: test input-xfrm and hash fields https://git.kernel.org/netdev/net-next/c/00e6c61c5a0a
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html