ethtool: rss: driver tweaks and netlink context dumps
Subsystems (13)
Jakub Kicinski
maintainerv4 cover ethtool: rss: driver tweaks and netlink context dumps
This series is a semi-related collection of RSS patches. Main point is supporting dumping RSS contexts via ethtool netlink. At present additional RSS contexts can be queried one by one, and assuming user know the right IDs. This series uses the XArray added by Ed to provide netlink dump support for ETHTOOL_GET_RSS.
Patch 1 is a trivial selftest debug patch.
Patch 2 coverts mvpp2 for no real reason other than that I had
a grand plan of converting all drivers at some stage.
Patch 3 removes a now moot check from mlx5 so that all tests
can pass.
Patch 4 and 5 make a bit used for context support optional,
for easier grepping of drivers which need converting if nothing else.
Patch 6 OTOH adds a new cap bit; some devices don't support
using a different key per context and currently act in surprising ways.
Patch 7 and 8 update the RSS netlink code to use XArray. Patch 9 and 10 add support for dumping contexts. Patch 11 and 12 are small adjustments to spec and a new test.
I'm getting distracted with other work, so probably won't have the time soon to complete next steps, but things which are missing are (and some of these may be bad ideas):
- better discovery
Some sort of API to tell the user who many contexts the device can create. Upper bound, devices often share contexts between ports etc. so it's hard to tell exactly and upfront number of contexts for a netdev. But order of magnitude (4 vs 10s) may be enough for container management system to know whether to bother.
- create/modify/delete via netlink
The only question here is how to handle all the tricky IOCTL legacy. "No change" maps trivially to attribute not present. "reset" (indir_size = 0) probably needs to be a new NLA_FLAG?
- better table size handling
The current API assumes the LUT has fixed size, which isn't true for modern devices. We should have better APIs for the drivers to resize the tables, and in user facing API - the ability to specify pattern and min size rather than exact table expected (sort of like ethtool CLI already does).
- recounted / socket-bound contexts
Support for contexts which get "cleaned up" when their parent netlink socket gets closed. The major catch is that ntuple filters (which we don't currently track) depend on the context, so we need auto-removal for both.
v4:
- adjust to the meaning of max context from net
v3: https://lore.kernel.org/[email protected]
- quite a few code comments and commit message changes
- mvpp2: fix interpretation of max_context_id (I'll take care of the net -> net-next merge as needed)
- filter by ifindex in the selftest
v2: https://lore.kernel.org/[email protected]
- fix bugs and build in mvpp2
v1: https://lore.kernel.org/[email protected]
Jakub Kicinski (12):
selftests: drv-net: rss_ctx: add identifier to traffic comments
eth: mvpp2: implement new RSS context API
eth: mlx5: allow disabling queues when RSS contexts exist
ethtool: make ethtool_ops::cap_rss_ctx_supported optional
eth: remove .cap_rss_ctx_supported from updated drivers
ethtool: rss: don't report key if device doesn't support it
ethtool: rss: move the device op invocation out of rss_prepare_data()
ethtool: rss: report info about additional contexts from XArray
ethtool: rss: support dumping RSS contexts
ethtool: rss: support skipping contexts during dump
netlink: specs: decode indirection table as u32 array
selftests: drv-net: rss_ctx: test dumping RSS contexts
Documentation/netlink/specs/ethtool.yaml | 14 +- Documentation/networking/ethtool-netlink.rst | 12 +- .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 2 +- drivers/net/ethernet/intel/ice/ice_ethtool.c | 1 + .../net/ethernet/marvell/mvpp2/mvpp2_cls.c | 18 +- .../net/ethernet/marvell/mvpp2/mvpp2_cls.h | 2 +- .../net/ethernet/marvell/mvpp2/mvpp2_main.c | 103 +++++--- .../ethernet/mellanox/mlx5/core/en_ethtool.c | 13 +- drivers/net/ethernet/sfc/ef100_ethtool.c | 2 +- drivers/net/ethernet/sfc/ethtool.c | 2 +- include/linux/ethtool.h | 7 +- include/uapi/linux/ethtool_netlink.h | 1 + net/ethtool/ioctl.c | 31 ++- net/ethtool/netlink.c | 2 + net/ethtool/netlink.h | 4 +- net/ethtool/rss.c | 233 ++++++++++++++++-- .../selftests/drivers/net/hw/rss_ctx.py | 80 +++++- tools/testing/selftests/net/lib/py/ksft.py | 6 + 18 files changed, 442 insertions(+), 91 deletions(-)
Signature · 1 line
2.46.0
Jakub Kicinski
maintainerPATCH v4 1/12 selftests: drv-net: rss_ctx: add identifier to traffic comments
Include the "name" of the context in the comment for traffic checks. Makes it easier to reason about which context failed when we loop over 32 contexts (it may matter if we failed in first vs last, for example).
--- tools/testing/selftests/drivers/net/hw/rss_ctx.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/drivers/net/hw/rss_ctx.py +2 -2
@@ -90,10 +90,10 @@ from lib.py import ethtool, ip, defer, GenerateTraffic, CmdExitFailure ksft_ge(directed, 20000, f"traffic on {name}: " + str(cnts)) if params.get('noise'): ksft_lt(sum(cnts[i] for i in params['noise']), directed / 2, - "traffic on other queues:" + str(cnts)) + f"traffic on other queues ({name})':" + str(cnts)) if params.get('empty'): ksft_eq(sum(cnts[i] for i in params['empty']), 0, - "traffic on inactive queues: " + str(cnts)) + f"traffic on inactive queues ({name}): " + str(cnts)) def test_rss_key_indir(cfg):
Signature · 1 line
2.46.0
Jakub Kicinski
maintainerPATCH v4 2/12 eth: mvpp2: implement new RSS context API
In reply to Jakub KicinskiImplement the separate create/modify/delete ops for RSS.
No problems with IDs - even tho RSS tables are per device the driver already seems to allocate IDs linearly per port. There's a translation table from per-port context ID to device context ID.
mvpp2 doesn't have a key for the hash, it defaults to an empty/previous indir table.
Note that there is no key at all, so we don't have to be concerned with reporting the wrong one (which is addressed by a patch later in the series).
Compile-tested only.
---
v4:
- adjust to meaning of max_context_id from net
v3:
- fix max_context_id to be inclusive
- extend commit message with why this is different than patch 6
v2:
- copy the default indir table
- use ID from the core
- fix build issues
--- .../net/ethernet/marvell/mvpp2/mvpp2_cls.c | 18 +--- .../net/ethernet/marvell/mvpp2/mvpp2_cls.h | 2 +- .../net/ethernet/marvell/mvpp2/mvpp2_main.c | 102 +++++++++++++----- 3 files changed, 79 insertions(+), 43 deletions(-)
drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.c +4 -14
@@ -1522,29 +1522,19 @@ static int mvpp22_rss_context_create(struct mvpp2_port *port, u32 *rss_ctx)return 0 ; } -int mvpp22_port_rss_ctx_create (struct mvpp2_port *port,u32 *port_ctx) +int mvpp22_port_rss_ctx_create (struct mvpp2_port *port,u32 port_ctx) {u32 rss_ctx; -int ret, i; +int ret; ret =mvpp22_rss_context_create (port, &rss_ctx);if (ret)return ret; -/* Find the first available context number in the port, starting from 1. -* Context 0 on each port is reserved for the default context. -*/ -for (i =1 ; i <MVPP22_N_RSS_TABLES ; i++) { -if (port->rss_ctx[i] <0 ) -break ; - } - -if (i ==MVPP22_N_RSS_TABLES ) +if (WARN_ON_ONCE (port->rss_ctx[port_ctx] >=0 ))return -EINVAL ; - port->rss_ctx[i] = rss_ctx; - *port_ctx = i; - + port->rss_ctx[port_ctx] = rss_ctx;return 0 ; }
drivers/net/ethernet/marvell/mvpp2/mvpp2_cls.h +1 -1
@@ -264,7 +264,7 @@ int mvpp22_port_rss_init(struct mvpp2_port *port);int mvpp22_port_rss_enable (struct mvpp2_port *port);int mvpp22_port_rss_disable (struct mvpp2_port *port); -int mvpp22_port_rss_ctx_create (struct mvpp2_port *port,u32 *rss_ctx); +int mvpp22_port_rss_ctx_create (struct mvpp2_port *port,u32 rss_ctx);int mvpp22_port_rss_ctx_delete (struct mvpp2_port *port,u32 rss_ctx); int mvpp22_port_rss_ctx_indir_set(struct mvpp2_port *port, u32 rss_ctx,
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +74 -28
124 lines not on this page · raw message
Signature · 1 line
2.46.0
Simon Horman
reviewerRe: [PATCH net-next v4 02/12] eth: mvpp2: implement new RSS context API
Quoted 14 lines · Jakub Kicinski
Implement the separate create/modify/delete ops for RSS.
No problems with IDs - even tho RSS tables are per device the driver already seems to allocate IDs linearly per port. There's a translation table from per-port context ID to device context ID.
mvpp2 doesn't have a key for the hash, it defaults to an empty/previous indir table.
Note that there is no key at all, so we don't have to be concerned with reporting the wrong one (which is addressed by a patch later in the series).
Quoted 7 lines
Compile-tested only.
Reviewed-by Edward Cree <[email protected]>Signed-off-by Jakub Kicinski <[email protected]>---
v4:
- adjust to meaning ofmax_context_idfrom net
Hi Jakub,
Should rxfh_max_num_contexts be used instead?
I'm seeing:
CC [M] .../mvpp2_main.o.../mvpp2_main.c:5794:10: error: ‘const struct ethtool_ops’ has no member named ‘rxfh_max_context_id’; did you mean ‘rxfh_max_num_contexts’?
5794 | .rxfh_max_context_id = MVPP22_N_RSS_TABLES,
| ^~~~~~~~~~~~~~~~~~~
| rxfh_max_num_contextsWhich seems to make sense in the context of:
- net: ethtool: fix off-by-one error in max RSS context IDs
https://git.kernel.org/netdev/net-next/c/b54de55990b0
...
kernel test robot
build botRe: [PATCH net-next v4 02/12] eth: mvpp2: implement new RSS context API
In reply to Jakub Kicinskikernel test robot noticed the following build errors:
Hi Jakub,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Jakub-Kicinski/selftests-drv-net-rss_ctx-add-identifier-to-traffic-comments/20240809-143446 base: net-next/main patch link: https://lore.kernel.org/r/20240809031827.2373341-3-kuba%40kernel.org patch subject: [PATCH net-next v4 02/12] eth: mvpp2: implement new RSS context API config: m68k-allmodconfig (https://download.01.org/0day-ci/archive/20240810/[email protected]/config) compiler: m68k-linux-gcc (GCC) 14.1.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240810/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All error/warnings (new ones prefixed by >>):
>> drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c:5795:10: error: 'const struct ethtool_ops' has no member named 'rxfh_max_context_id'; did you mean 'rxfh_max_num_contexts'?
5795 | .rxfh_max_context_id = MVPP22_N_RSS_TABLES,
| ^~~~~~~~~~~~~~~~~~~
| rxfh_max_num_contexts
In file included from drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c:42:
>> drivers/net/ethernet/marvell/mvpp2/mvpp2.h:859:41: warning: unsigned conversion from 'int' to 'unsigned char:1' changes value from '8' to '0' [-Woverflow]
859 | #define MVPP22_N_RSS_TABLES 8
| ^
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c:5795:35: note: in expansion of macro 'MVPP22_N_RSS_TABLES'
5795 | .rxfh_max_context_id = MVPP22_N_RSS_TABLES,
| ^~~~~~~~~~~~~~~~~~~vim +5795 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
5792
5793 static const struct ethtool_ops mvpp2_eth_tool_ops = {
5794 .cap_rss_ctx_supported = true,
> 5795 .rxfh_max_context_id = MVPP22_N_RSS_TABLES,
5796 .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
5797 ETHTOOL_COALESCE_MAX_FRAMES,
5798 .nway_reset = mvpp2_ethtool_nway_reset,
5799 .get_link = ethtool_op_get_link,
5800 .get_ts_info = mvpp2_ethtool_get_ts_info,
5801 .set_coalesce = mvpp2_ethtool_set_coalesce,
5802 .get_coalesce = mvpp2_ethtool_get_coalesce,
5803 .get_drvinfo = mvpp2_ethtool_get_drvinfo,
5804 .get_ringparam = mvpp2_ethtool_get_ringparam,
5805 .set_ringparam = mvpp2_ethtool_set_ringparam,
5806 .get_strings = mvpp2_ethtool_get_strings,
5807 .get_ethtool_stats = mvpp2_ethtool_get_stats,
5808 .get_sset_count = mvpp2_ethtool_get_sset_count,
5809 .get_pauseparam = mvpp2_ethtool_get_pause_param,
5810 .set_pauseparam = mvpp2_ethtool_set_pause_param,
5811 .get_link_ksettings = mvpp2_ethtool_get_link_ksettings,
5812 .set_link_ksettings = mvpp2_ethtool_set_link_ksettings,
5813 .get_rxnfc = mvpp2_ethtool_get_rxnfc,
5814 .set_rxnfc = mvpp2_ethtool_set_rxnfc,
5815 .get_rxfh_indir_size = mvpp2_ethtool_get_rxfh_indir_size,
5816 .get_rxfh = mvpp2_ethtool_get_rxfh,
5817 .set_rxfh = mvpp2_ethtool_set_rxfh,
5818 .create_rxfh_context = mvpp2_create_rxfh_context,
5819 .modify_rxfh_context = mvpp2_modify_rxfh_context,
5820 .remove_rxfh_context = mvpp2_remove_rxfh_context,
5821 };
5822
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH net-next v4 02/12] eth: mvpp2: implement new RSS context API
In reply to Jakub Kicinskikernel test robot noticed the following build errors:
Hi Jakub,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
url: https://github.com/intel-lab-lkp/linux/commits/Jakub-Kicinski/selftests-drv-net-rss_ctx-add-identifier-to-traffic-comments/20240809-143446 base: net-next/main patch link: https://lore.kernel.org/r/20240809031827.2373341-3-kuba%40kernel.org patch subject: [PATCH net-next v4 02/12] eth: mvpp2: implement new RSS context API config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20240810/[email protected]/config) compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240810/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c:5795:3: error: field designator 'rxfh_max_context_id' does not refer to any field in type 'const struct ethtool_ops'
5795 | .rxfh_max_context_id = MVPP22_N_RSS_TABLES,
| ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~1 error generated.
vim +5795 drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
5792
5793 static const struct ethtool_ops mvpp2_eth_tool_ops = {
5794 .cap_rss_ctx_supported = true,
> 5795 .rxfh_max_context_id = MVPP22_N_RSS_TABLES,
5796 .supported_coalesce_params = ETHTOOL_COALESCE_USECS |
5797 ETHTOOL_COALESCE_MAX_FRAMES,
5798 .nway_reset = mvpp2_ethtool_nway_reset,
5799 .get_link = ethtool_op_get_link,
5800 .get_ts_info = mvpp2_ethtool_get_ts_info,
5801 .set_coalesce = mvpp2_ethtool_set_coalesce,
5802 .get_coalesce = mvpp2_ethtool_get_coalesce,
5803 .get_drvinfo = mvpp2_ethtool_get_drvinfo,
5804 .get_ringparam = mvpp2_ethtool_get_ringparam,
5805 .set_ringparam = mvpp2_ethtool_set_ringparam,
5806 .get_strings = mvpp2_ethtool_get_strings,
5807 .get_ethtool_stats = mvpp2_ethtool_get_stats,
5808 .get_sset_count = mvpp2_ethtool_get_sset_count,
5809 .get_pauseparam = mvpp2_ethtool_get_pause_param,
5810 .set_pauseparam = mvpp2_ethtool_set_pause_param,
5811 .get_link_ksettings = mvpp2_ethtool_get_link_ksettings,
5812 .set_link_ksettings = mvpp2_ethtool_set_link_ksettings,
5813 .get_rxnfc = mvpp2_ethtool_get_rxnfc,
5814 .set_rxnfc = mvpp2_ethtool_set_rxnfc,
5815 .get_rxfh_indir_size = mvpp2_ethtool_get_rxfh_indir_size,
5816 .get_rxfh = mvpp2_ethtool_get_rxfh,
5817 .set_rxfh = mvpp2_ethtool_set_rxfh,
5818 .create_rxfh_context = mvpp2_create_rxfh_context,
5819 .modify_rxfh_context = mvpp2_modify_rxfh_context,
5820 .remove_rxfh_context = mvpp2_remove_rxfh_context,
5821 };
5822
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Jakub Kicinski
maintainerPATCH v4 3/12 eth: mlx5: allow disabling queues when RSS contexts exist
In reply to Jakub KicinskiSince commit 24ac7e544081 ("ethtool: use the rss context XArray in ring deactivation safety-check") core will prevent queues from being disabled while being used by additional RSS contexts. The safety check is no longer necessary, and core will do a more accurate job of only rejecting changes which can actually break things.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 12 ------------ 1 file changed, 12 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +0 -12
@@ -445,7 +445,6 @@ int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv,unsigned int count = ch->combined_count;struct mlx5e_params new_params;bool arfs_enabled; -int rss_cnt;bool opened;int err =0 ;
@@ -499,17 +498,6 @@ int mlx5e_ethtool_set_channels(struct mlx5e_priv *priv, goto out; } -/* Don't allow changing the number of channels if non-default RSS contexts exist, -* the kernel doesn't protect against set_channels operations that break them. -*/ - rss_cnt =mlx5e_rx_res_rss_cnt (priv->rx_res) -1 ; -if (rss_cnt) { - err = -EINVAL ; -netdev_err (priv->netdev,"%s: Non-default RSS contexts exist (%d), cannot change the number of channels\n" , - __func__, rss_cnt); - goto out; - } -/* Don't allow changing the number of channels if MQPRIO mode channel offload is active, * because it defines a partition over the channels queues. */
Signature · 1 line
2.46.0
Jakub Kicinski
maintainerPATCH v4 4/12 ethtool: make ethtool_ops::cap_rss_ctx_supported optional
In reply to Jakub Kicinskicap_rss_ctx_supported was created because the API for creating and configuring additional contexts is mux'ed with the normal RSS API. Presence of ops does not imply driver can actually support rss_context != 0 (in fact drivers mostly ignore that field). cap_rss_ctx_supported lets core check that the driver is context-aware before calling it.
Now that we have .create_rxfh_context, there is no such ambiguity. We can depend on presence of the op. Make setting the bit optional.
--- include/linux/ethtool.h | 3 ++- net/ethtool/ioctl.c | 6 ++++-- net/ethtool/rss.c | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-)
include/linux/ethtool.h +2 -1
@@ -727,7 +727,8 @@ struct kernel_ethtool_ts_info {* @cap_link_lanes_supported: indicates if the driver supports lanes * parameter. * @cap_rss_ctx_supported: indicates if the driver supports RSS -* contexts. +* 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_indir_space: max size of RSS indirection tables, if indirection table
net/ethtool/ioctl.c +4 -2
@@ -1227,7 +1227,8 @@ static noinline_for_stack int ethtool_get_rxfh(struct net_device *dev,if (rxfh.rsvd8[0 ] || rxfh.rsvd8[1 ] || rxfh.rsvd32)return -EINVAL ;/* Most drivers don't handle rss_context, check it's 0 as well */ -if (rxfh.rss_context && !ops->cap_rss_ctx_supported) +if (rxfh.rss_context && !(ops->cap_rss_ctx_supported || + ops->create_rxfh_context))return -EOPNOTSUPP ; rxfh.indir_size = rxfh_dev.indir_size;
@@ -1357,7 +1358,8 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,if (rxfh.rsvd8[0 ] || rxfh.rsvd8[1 ] || rxfh.rsvd32)return -EINVAL ;/* Most drivers don't handle rss_context, check it's 0 as well */ -if (rxfh.rss_context && !ops->cap_rss_ctx_supported) +if (rxfh.rss_context && !(ops->cap_rss_ctx_supported || + ops->create_rxfh_context))return -EOPNOTSUPP ;/* Check input data transformation capabilities */ if (rxfh.input_xfrm && rxfh.input_xfrm != RXH_XFRM_SYM_XOR &&
net/ethtool/rss.c +2 -1
@@ -60,7 +60,8 @@ rss_prepare_data(const struct ethnl_req_info *req_base,return -EOPNOTSUPP ;/* Some drivers don't handle rss_context */ -if (request->rss_context && !ops->cap_rss_ctx_supported) +if (request->rss_context && !(ops->cap_rss_ctx_supported || + ops->create_rxfh_context))return -EOPNOTSUPP ; ret =ethnl_ops_begin (dev);
Signature · 1 line
2.46.0
Jakub Kicinski
maintainerPATCH v4 5/12 eth: remove .cap_rss_ctx_supported from updated drivers
In reply to Jakub KicinskiRemove .cap_rss_ctx_supported from drivers which moved to the new API. This makes it easy to grep for drivers which still need to be converted.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 1 - drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 1 - drivers/net/ethernet/sfc/ef100_ethtool.c | 1 - drivers/net/ethernet/sfc/ethtool.c | 1 - 4 files changed, 4 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +0 -1
@@ -5289,7 +5289,6 @@ void bnxt_ethtool_free(struct bnxt *bp)const struct ethtool_ops bnxt_ethtool_ops = { .cap_link_lanes_supported =1 , - .cap_rss_ctx_supported =1 , .rxfh_max_num_contexts =BNXT_MAX_ETH_RSS_CTX +1 , .rxfh_indir_space =BNXT_MAX_RSS_TABLE_ENTRIES_P5 , .rxfh_priv_size =sizeof (struct bnxt_rss_ctx ),
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +0 -1
@@ -5791,7 +5791,6 @@ static const struct net_device_ops mvpp2_netdev_ops = { };static const struct ethtool_ops mvpp2_eth_tool_ops = { - .cap_rss_ctx_supported = true, .rxfh_max_context_id =MVPP22_N_RSS_TABLES , .supported_coalesce_params =ETHTOOL_COALESCE_USECS |ETHTOOL_COALESCE_MAX_FRAMES ,
drivers/net/ethernet/sfc/ef100_ethtool.c +0 -1
@@ -37,7 +37,6 @@ ef100_ethtool_get_ringparam(struct net_device *net_dev,/* Ethtool options available */ const struct ethtool_ops ef100_ethtool_ops = { - .cap_rss_ctx_supported = true, .get_drvinfo = efx_ethtool_get_drvinfo, .get_msglevel = efx_ethtool_get_msglevel, .set_msglevel = efx_ethtool_set_msglevel,
drivers/net/ethernet/sfc/ethtool.c +0 -1
@@ -240,7 +240,6 @@ static int efx_ethtool_get_ts_info(struct net_device *net_dev, }const struct ethtool_ops efx_ethtool_ops = { - .cap_rss_ctx_supported = true, .supported_coalesce_params =ETHTOOL_COALESCE_USECS |ETHTOOL_COALESCE_USECS_IRQ |ETHTOOL_COALESCE_USE_ADAPTIVE_RX ,
Signature · 1 line
2.46.0
Jakub Kicinski
maintainerPATCH v4 6/12 ethtool: rss: don't report key if device doesn't support it
In reply to Jakub Kicinskimarvell/otx2 and mvpp2 do not support setting different keys for different RSS contexts. Contexts have separate indirection tables but key is shared with all other contexts. This is likely fine, indirection table is the most important piece.
Don't report the key-related parameters from such drivers. This prevents driver-errors, e.g. otx2 always writes the main key, even when user asks to change per-context key. The second reason is that without this change tracking the keys by the core gets complicated. Even if the driver correctly reject setting key with rss_context != 0, change of the main key would have to be reflected in the XArray for all additional contexts.
Since the additional contexts don't have their own keys not including the attributes (in Netlink speak) seems intuitive. ethtool CLI seems to deal with it just fine.
Having to set the flag in majority of the drivers is a bit tedious but not reporting the key is a safer default.
---
v3:
- add safety note to the commit message
- use true in sfc, drop sienna
- extend kdoc of @rxfh_per_ctx_key
--- .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 1 + drivers/net/ethernet/intel/ice/ice_ethtool.c | 1 + .../ethernet/mellanox/mlx5/core/en_ethtool.c | 1 + drivers/net/ethernet/sfc/ef100_ethtool.c | 1 + drivers/net/ethernet/sfc/ethtool.c | 1 + include/linux/ethtool.h | 4 +++ net/ethtool/ioctl.c | 25 ++++++++++++++++--- net/ethtool/rss.c | 21 +++++++++++----- 8 files changed, 45 insertions(+), 10 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +1 -0
@@ -5289,6 +5289,7 @@ void bnxt_ethtool_free(struct bnxt *bp)const struct ethtool_ops bnxt_ethtool_ops = { .cap_link_lanes_supported =1 , + .rxfh_per_ctx_key =1 , .rxfh_max_num_contexts =BNXT_MAX_ETH_RSS_CTX +1 , .rxfh_indir_space =BNXT_MAX_RSS_TABLE_ENTRIES_P5 , .rxfh_priv_size =sizeof (struct bnxt_rss_ctx ),
drivers/net/ethernet/intel/ice/ice_ethtool.c +1 -0
@@ -4725,6 +4725,7 @@ static const struct ethtool_ops ice_ethtool_ops = {ETHTOOL_COALESCE_USE_ADAPTIVE | ETHTOOL_COALESCE_RX_USECS_HIGH, .cap_rss_sym_xor_supported = true, + .rxfh_per_ctx_key = true, .get_link_ksettings = ice_get_link_ksettings, .set_link_ksettings = ice_set_link_ksettings, .get_fec_stats = ice_get_fec_stats,
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +1 -0
@@ -2593,6 +2593,7 @@ static void mlx5e_get_ts_stats(struct net_device *netdev,const struct ethtool_ops mlx5e_ethtool_ops = { .cap_rss_ctx_supported = true, + .rxfh_per_ctx_key = true, .supported_coalesce_params =ETHTOOL_COALESCE_USECS |ETHTOOL_COALESCE_MAX_FRAMES | ETHTOOL_COALESCE_USE_ADAPTIVE |
drivers/net/ethernet/sfc/ef100_ethtool.c +1 -0
@@ -58,6 +58,7 @@ const struct ethtool_ops ef100_ethtool_ops = { .get_rxfh_indir_size = efx_ethtool_get_rxfh_indir_size, .get_rxfh_key_size = efx_ethtool_get_rxfh_key_size, + .rxfh_per_ctx_key = true, .rxfh_priv_size = sizeof(struct efx_rss_context_priv), .get_rxfh = efx_ethtool_get_rxfh, .set_rxfh = efx_ethtool_set_rxfh,
drivers/net/ethernet/sfc/ethtool.c +1 -0
@@ -267,6 +267,7 @@ const struct ethtool_ops efx_ethtool_ops = { .set_rxnfc = efx_ethtool_set_rxnfc, .get_rxfh_indir_size = efx_ethtool_get_rxfh_indir_size, .get_rxfh_key_size = efx_ethtool_get_rxfh_key_size, + .rxfh_per_ctx_key = true, .rxfh_priv_size = sizeof(struct efx_rss_context_priv), .get_rxfh = efx_ethtool_get_rxfh, .set_rxfh = efx_ethtool_set_rxfh,
include/linux/ethtool.h +4 -0
@@ -731,6 +731,9 @@ struct kernel_ethtool_ts_info {* 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. * @rxfh_indir_space: max size of RSS indirection tables, if indirection table * size as returned by @get_rxfh_indir_size may change during lifetime * of the device. Leave as 0 if the table size is constant.
@@ -952,6 +955,7 @@ struct ethtool_ops { 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 rxfh_indir_space;u16 rxfh_key_space;u16 rxfh_priv_size;
net/ethtool/ioctl.c +21 -4
@@ -1261,10 +1261,15 @@ static noinline_for_stack int ethtool_get_rxfh(struct net_device *dev,if (rxfh_dev.indir)memcpy (rxfh_dev.indir,ethtool_rxfh_context_indir (ctx), indir_bytes); -if (rxfh_dev.key) -memcpy (rxfh_dev.key,ethtool_rxfh_context_key (ctx), - user_key_size); - rxfh_dev.hfunc = ctx->hfunc; +if (!ops->rxfh_per_ctx_key) { + rxfh_dev.key_size =0 ; + }else { +if (rxfh_dev.key) +memcpy (rxfh_dev.key, +ethtool_rxfh_context_key (ctx), + user_key_size); + rxfh_dev.hfunc = ctx->hfunc; + } rxfh_dev.input_xfrm = ctx->input_xfrm; ret =0 ; }else {
@@ -1281,6 +1286,11 @@ static noinline_for_stack int ethtool_get_rxfh(struct net_device *dev, &rxfh_dev.input_xfrm, sizeof(rxfh.input_xfrm))) { ret = -EFAULT ; + } else if (copy_to_user(useraddr + + offsetof(struct ethtool_rxfh, key_size), + &rxfh_dev.key_size, + sizeof(rxfh.key_size))) { + ret = -EFAULT ; } else if (copy_to_user(useraddr + offsetof(struct ethtool_rxfh, rss_config[0]), rss_config, total_size)) {
@@ -1389,6 +1399,13 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev, indir_bytes = dev_indir_size *sizeof (rxfh_dev.indir[0 ]); +/* Check settings which may be global rather than per RSS-context */ +if (rxfh.rss_context && !ops->rxfh_per_ctx_key) +if (rxfh.key_size || + (rxfh.hfunc && rxfh.hfunc !=ETH_RSS_HASH_NO_CHANGE ) || + (rxfh.input_xfrm && rxfh.input_xfrm !=RXH_XFRM_NO_CHANGE )) +return -EOPNOTSUPP ; + rss_config =kzalloc (indir_bytes + dev_key_size,GFP_USER );if (!rss_config)return -ENOMEM ;
net/ethtool/rss.c +15 -6
@@ -10,6 +10,7 @@ struct rss_req_info {struct rss_reply_data {struct ethnl_reply_data base; +bool no_key_fields;u32 indir_size;u32 hkey_size;u32 hfunc;
@@ -60,9 +61,12 @@ rss_prepare_data(const struct ethnl_req_info *req_base,return -EOPNOTSUPP ;/* Some drivers don't handle rss_context */ -if (request->rss_context && !(ops->cap_rss_ctx_supported || - ops->create_rxfh_context)) -return -EOPNOTSUPP ; +if (request->rss_context) { +if (!ops->cap_rss_ctx_supported && !ops->create_rxfh_context) +return -EOPNOTSUPP ; + + data->no_key_fields = !ops->rxfh_per_ctx_key; + } ret =ethnl_ops_begin (dev);if (ret <0 )
@@ -132,13 +136,18 @@ rss_fill_reply(struct sk_buff *skb, const struct ethnl_req_info *req_base, nla_put_u32(skb, ETHTOOL_A_RSS_CONTEXT, request->rss_context))return -EMSGSIZE ; +if ((data->indir_size && +nla_put (skb,ETHTOOL_A_RSS_INDIR , +sizeof (u32) * data->indir_size, data->indir_table))) +return -EMSGSIZE ; + +if (data->no_key_fields) +return 0 ; +if ((data->hfunc &&nla_put_u32 (skb,ETHTOOL_A_RSS_HFUNC , data->hfunc)) || (data->input_xfrm &&nla_put_u32 (skb,ETHTOOL_A_RSS_INPUT_XFRM , data->input_xfrm)) || - (data->indir_size && -nla_put (skb,ETHTOOL_A_RSS_INDIR , -sizeof (u32) * data->indir_size, data->indir_table)) || (data->hkey_size &&nla_put (skb,ETHTOOL_A_RSS_HKEY , data->hkey_size, data->hkey)))return -EMSGSIZE ;
Signature · 1 line
2.46.0
Jakub Kicinski
maintainerPATCH v4 7/12 ethtool: rss: move the device op invocation out of rss_prepare_data()
In reply to Jakub KicinskiFactor calling device ops out of rss_prepare_data(). Next patch will add alternative path using xarray. No functional changes.
--- net/ethtool/rss.c | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-)
net/ethtool/rss.c +27 -16
@@ -43,13 +43,9 @@ rss_parse_request(struct ethnl_req_info *req_info, struct nlattr **tb, }static int -rss_prepare_data (const struct ethnl_req_info *req_base, -struct ethnl_reply_data *reply_base, -const struct genl_info *info) +rss_prepare_get (const struct rss_req_info *request,struct net_device *dev, +struct rss_reply_data *data,const struct genl_info *info) { -struct rss_reply_data *data =RSS_REPDATA (reply_base); -struct rss_req_info *request =RSS_REQINFO (req_base); -struct net_device *dev = reply_base->dev;struct ethtool_rxfh_param rxfh = {};const struct ethtool_ops *ops;u32 total_size, indir_bytes;
@@ -57,16 +53,6 @@ rss_prepare_data(const struct ethnl_req_info *req_base,int ret; ops = dev->ethtool_ops; -if (!ops->get_rxfh) -return -EOPNOTSUPP ; - -/* Some drivers don't handle rss_context */ -if (request->rss_context) { -if (!ops->cap_rss_ctx_supported && !ops->create_rxfh_context) -return -EOPNOTSUPP ; - - data->no_key_fields = !ops->rxfh_per_ctx_key; - } ret =ethnl_ops_begin (dev);if (ret <0 )
@@ -109,6 +95,31 @@ rss_prepare_data(const struct ethnl_req_info *req_base,return ret; } +static int +rss_prepare_data (const struct ethnl_req_info *req_base, +struct ethnl_reply_data *reply_base, +const struct genl_info *info) +{ +struct rss_reply_data *data =RSS_REPDATA (reply_base); +struct rss_req_info *request =RSS_REQINFO (req_base); +struct net_device *dev = reply_base->dev; +const struct ethtool_ops *ops; + + ops = dev->ethtool_ops; +if (!ops->get_rxfh) +return -EOPNOTSUPP ; + +/* Some drivers don't handle rss_context */ +if (request->rss_context) { +if (!ops->cap_rss_ctx_supported && !ops->create_rxfh_context) +return -EOPNOTSUPP ; + + data->no_key_fields = !ops->rxfh_per_ctx_key; + } + +return rss_prepare_get (request, dev, data, info); +} +static int rss_reply_size (const struct ethnl_req_info *req_base,const struct ethnl_reply_data *reply_base)
Signature · 1 line
2.46.0
Jakub Kicinski
maintainerPATCH v4 8/12 ethtool: rss: report info about additional contexts from XArray
In reply to Jakub KicinskiIOCTL already uses the XArray when reporting info about additional contexts. Do the same thing in netlink code.
--- net/ethtool/rss.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-)
net/ethtool/rss.c +36 -1
@@ -82,7 +82,6 @@ rss_prepare_get(const struct rss_req_info *request, struct net_device *dev, rxfh.indir = data->indir_table; rxfh.key_size = data->hkey_size; rxfh.key = data->hkey; - rxfh.rss_context = request->rss_context; ret = ops->get_rxfh (dev, &rxfh);if (ret)
@@ -95,6 +94,41 @@ rss_prepare_get(const struct rss_req_info *request, struct net_device *dev,return ret; } +static int +rss_prepare_ctx (const struct rss_req_info *request,struct net_device *dev, +struct rss_reply_data *data,const struct genl_info *info) +{ +struct ethtool_rxfh_context *ctx; +u32 total_size, indir_bytes; +u8 *rss_config; + + ctx =xa_load (&dev->ethtool->rss_ctx, request->rss_context); +if (!ctx) +return -ENOENT ; + + data->indir_size = ctx->indir_size; + data->hkey_size = ctx->key_size; + data->hfunc = ctx->hfunc; + data->input_xfrm = ctx->input_xfrm; + + indir_bytes = data->indir_size *sizeof (u32); + total_size = indir_bytes + data->hkey_size; + rss_config =kzalloc (total_size,GFP_KERNEL ); +if (!rss_config) +return -ENOMEM ; + + data->indir_table = (u32 *)rss_config; +memcpy (data->indir_table,ethtool_rxfh_context_indir (ctx), indir_bytes); + +if (data->hkey_size) { + data->hkey = rss_config + indir_bytes; +memcpy (data->hkey,ethtool_rxfh_context_key (ctx), + data->hkey_size); + } + +return 0 ; +} + static int rss_prepare_data(const struct ethnl_req_info *req_base, struct ethnl_reply_data *reply_base,
@@ -115,6 +149,7 @@ rss_prepare_data(const struct ethnl_req_info *req_base,return -EOPNOTSUPP ; data->no_key_fields = !ops->rxfh_per_ctx_key; +return rss_prepare_ctx (request, dev, data, info); }return rss_prepare_get (request, dev, data, info);
Signature · 1 line
2.46.0
Jakub Kicinski
maintainerPATCH v4 9/12 ethtool: rss: support dumping RSS contexts
In reply to Jakub KicinskiNow that we track RSS contexts in the core we can easily dump them. This is a major introspection improvement, as previously the only way to find all contexts would be to try all ids (of which there may be 2^32 - 1).
Don't use the XArray iterators (like xa_for_each_start()) as they do not move the index past the end of the array once done, which caused multiple bugs in Netlink dumps in the past.
---
v3:
- one_ifindex -> match_ifindex, add a comment
- add comment about context 0 not being in XArray
- extend commit message (XArray iterators)
--- Documentation/netlink/specs/ethtool.yaml | 9 +- net/ethtool/netlink.c | 2 + net/ethtool/netlink.h | 2 + net/ethtool/rss.c | 135 +++++++++++++++++++++++ 4 files changed, 146 insertions(+), 2 deletions(-)
Documentation/netlink/specs/ethtool.yaml +7 -2
@@ -1749,12 +1749,12 @@ doc: Partial family for Ethtool Netlink. attribute-set: rss - do: &rss-get-op + do: request: attributes: - header - context - reply: + reply: &rss-reply attributes: - header - context
@@ -1762,6 +1762,11 @@ doc: Partial family for Ethtool Netlink. - indir - hkey - input_xfrm + dump: + request: + attributes: + - header + reply: *rss-reply - name: plca-get-cfg doc: Get PLCA params.
net/ethtool/netlink.c +2 -0
@@ -1128,6 +1128,8 @@ static const struct genl_ops ethtool_genl_ops[] = { { .cmd = ETHTOOL_MSG_RSS_GET, .doit = ethnl_default_doit, + .start = ethnl_rss_dump_start, + .dumpit = ethnl_rss_dumpit, .policy = ethnl_rss_get_policy, .maxattr = ARRAY_SIZE(ethnl_rss_get_policy) - 1, },
net/ethtool/netlink.h +2 -0
@@ -464,6 +464,8 @@ int ethnl_tunnel_info_doit(struct sk_buff *skb, struct genl_info *info);int ethnl_tunnel_info_start (struct netlink_callback *cb);int ethnl_tunnel_info_dumpit (struct sk_buff *skb,struct netlink_callback *cb);int ethnl_act_module_fw_flash (struct sk_buff *skb,struct genl_info *info); +int ethnl_rss_dump_start (struct netlink_callback *cb); +int ethnl_rss_dumpit (struct sk_buff *skb,struct netlink_callback *cb);extern const char stats_std_names[__ETHTOOL_STATS_CNT][ETH_GSTRING_LEN ];extern const char stats_eth_phy_names[__ETHTOOL_A_STATS_ETH_PHY_CNT][ETH_GSTRING_LEN ];
net/ethtool/rss.c +135 -0
141 lines not on this page · raw message
Signature · 1 line
2.46.0
Jakub Kicinski
maintainerPATCH v4 10/12 ethtool: rss: support skipping contexts during dump
In reply to Jakub KicinskiApplications may want to deal with dynamic RSS contexts only. So dumping context 0 will be counter-productive for them. Support starting the dump from a given context ID.
Alternative would be to implement a dump flag to skip just context 0, not sure which is better...
--- Documentation/netlink/specs/ethtool.yaml | 4 ++++ Documentation/networking/ethtool-netlink.rst | 12 ++++++++++-- include/uapi/linux/ethtool_netlink.h | 1 + net/ethtool/netlink.h | 2 +- net/ethtool/rss.c | 12 +++++++++++- 5 files changed, 27 insertions(+), 4 deletions(-)
Documentation/netlink/specs/ethtool.yaml +4 -0
@@ -1028,6 +1028,9 @@ doc: Partial family for Ethtool Netlink. - name: input_xfrm type: u32 + - + name: start-context + type: u32 - name: plca attributes:
@@ -1766,6 +1769,7 @@ doc: Partial family for Ethtool Netlink. request: attributes: - header + - start-context reply: *rss-reply - name: plca-get-cfg
Documentation/networking/ethtool-netlink.rst +10 -2
@@ -1866,10 +1866,18 @@ RSS context of an interface similar to ``ETHTOOL_GRSSH`` ioctl request. Request contents: -===================================== ====== ========================== +===================================== ====== ============================ ``ETHTOOL_A_RSS_HEADER`` nested request header ``ETHTOOL_A_RSS_CONTEXT`` u32 context number -===================================== ====== ========================== + ``ETHTOOL_A_RSS_START_CONTEXT`` u32 start context number (dumps) +===================================== ====== ============================ + +``ETHTOOL_A_RSS_CONTEXT`` specifies which RSS context number to query, +if not set context 0 (the main context) is queried. Dumps can be filtered +by device (only listing contexts of a given netdev). Filtering single +context number is not supported but ``ETHTOOL_A_RSS_START_CONTEXT`` +can be used to start dumping context from the given number (primarily +used to ignore context 0s and only dump additional contexts). Kernel response contents:
include/uapi/linux/ethtool_netlink.h +1 -0
@@ -965,6 +965,7 @@ enum {ETHTOOL_A_RSS_INDIR ,/* binary */ ETHTOOL_A_RSS_HKEY ,/* binary */ ETHTOOL_A_RSS_INPUT_XFRM ,/* u32 */ +ETHTOOL_A_RSS_START_CONTEXT ,/* u32 */ __ETHTOOL_A_RSS_CNT, ETHTOOL_A_RSS_MAX = (__ETHTOOL_A_RSS_CNT - 1),
net/ethtool/netlink.h +1 -1
@@ -449,7 +449,7 @@ extern const struct nla_policy ethnl_module_get_policy[ETHTOOL_A_MODULE_HEADER +extern const struct nla_policy ethnl_module_set_policy[ETHTOOL_A_MODULE_POWER_MODE_POLICY +1 ];extern 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_CONTEXT +1 ]; +extern const struct nla_policy ethnl_rss_get_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/rss.c +11 -1
@@ -28,6 +28,7 @@ struct rss_reply_data {const struct nla_policy ethnl_rss_get_policy[] = { [ETHTOOL_A_RSS_HEADER ] =NLA_POLICY_NESTED (ethnl_header_policy), [ETHTOOL_A_RSS_CONTEXT ] = { .type =NLA_U32 }, + [ETHTOOL_A_RSS_START_CONTEXT ] = { .type =NLA_U32 }, }; static int
@@ -38,6 +39,10 @@ rss_parse_request(struct ethnl_req_info *req_info, struct nlattr **tb,if (tb[ETHTOOL_A_RSS_CONTEXT ]) request->rss_context =nla_get_u32 (tb[ETHTOOL_A_RSS_CONTEXT ]); +if (tb[ETHTOOL_A_RSS_START_CONTEXT ]) { +NL_SET_BAD_ATTR (extack, tb[ETHTOOL_A_RSS_START_CONTEXT ]); +return -EINVAL ; + }return 0 ; }
@@ -214,6 +219,7 @@ struct rss_nl_dump_ctx {/* User wants to only dump contexts from given ifindex */ unsigned int match_ifindex; +unsigned int start_ctx; };static struct rss_nl_dump_ctx *rss_dump_ctx (struct netlink_callback *cb)
@@ -236,6 +242,10 @@ int ethnl_rss_dump_start(struct netlink_callback *cb)NL_SET_BAD_ATTR (info->extack, tb[ETHTOOL_A_RSS_CONTEXT ]);return -EINVAL ; } +if (tb[ETHTOOL_A_RSS_START_CONTEXT ]) { + ctx->start_ctx =nla_get_u32 (tb[ETHTOOL_A_RSS_START_CONTEXT ]); + ctx->ctx_idx = ctx->start_ctx; + } ret = ethnl_parse_header_dev_get(&req_info, tb[ETHTOOL_A_RSS_HEADER],
@@ -317,7 +327,7 @@ rss_dump_one_dev(struct sk_buff *skb, struct netlink_callback *cb,if (ret)return ret; } - ctx->ctx_idx =0 ; + ctx->ctx_idx = ctx->start_ctx;return 0 ; }
Signature · 1 line
2.46.0
Jakub Kicinski
maintainerPATCH v4 11/12 netlink: specs: decode indirection table as u32 array
In reply to Jakub KicinskiIndirection table is dumped as a raw u32 array, decode it. It's tempting to decode hash key, too, but it is an actual bitstream, so leave it be for now.
--- Documentation/netlink/specs/ethtool.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/netlink/specs/ethtool.yaml +1 -0
@@ -1022,6 +1022,7 @@ doc: Partial family for Ethtool Netlink. - name: indir type: binary + sub-type: u32 - name: hkey type: binary
Signature · 1 line
2.46.0
Jakub Kicinski
maintainerPATCH v4 12/12 selftests: drv-net: rss_ctx: test dumping RSS contexts
In reply to Jakub KicinskiAdd a test for dumping RSS contexts. Make sure indir table and key are sane when contexts are created with various combination of inputs. Test the dump filtering by ifname and start-context.
---
v3:
- filter results by ifindex
- check for duplicates
--- .../selftests/drivers/net/hw/rss_ctx.py | 76 ++++++++++++++++++- tools/testing/selftests/net/lib/py/ksft.py | 6 ++ 2 files changed, 80 insertions(+), 2 deletions(-)
tools/testing/selftests/drivers/net/hw/rss_ctx.py +74 -2
@@ -3,7 +3,7 @@ import datetime import random -from lib.py import ksft_run, ksft_pr, ksft_exit, ksft_eq, ksft_ge, ksft_lt +from lib.py import ksft_run, ksft_pr, ksft_exit, ksft_eq, ksft_ne, ksft_ge, ksft_lt from lib.py import NetDrvEpEnv from lib.py import EthtoolFamily, NetdevFamily from lib.py import KsftSkipEx
@@ -302,6 +302,78 @@ from lib.py import ethtool, ip, defer, GenerateTraffic, CmdExitFailure ksft_eq(carrier1 - carrier0, 0) +def test_rss_context_dump(cfg): + """ + Test dumping RSS contexts. This tests mostly exercises the kernel APIs. + """ + + # Get a random key of the right size + data = get_rss(cfg) + if 'rss-hash-key' in data: + key_data = _rss_key_rand(len(data['rss-hash-key'])) + key = _rss_key_str(key_data) + else: + key_data = [] + key = "ba:ad" + + ids = [] + try: + ids.append(ethtool_create(cfg, "-X", f"context new")) + defer(ethtool, f"-X {cfg.ifname} context {ids[-1]} delete") + + ids.append(ethtool_create(cfg, "-X", f"context new weight 1 1")) + defer(ethtool, f"-X {cfg.ifname} context {ids[-1]} delete") + + ids.append(ethtool_create(cfg, "-X", f"context new hkey {key}")) + defer(ethtool, f"-X {cfg.ifname} context {ids[-1]} delete") + except CmdExitFailure: + if not ids: + raise KsftSkipEx("Unable to add any contexts") + ksft_pr(f"Added only {len(ids)} out of 3 contexts") + + expect_tuples = set([(cfg.ifname, -1)] + [(cfg.ifname, ctx_id) for ctx_id in ids]) + + # Dump all + ctxs = cfg.ethnl.rss_get({}, dump=True) + tuples = [(c['header']['dev-name'], c.get('context', -1)) for c in ctxs] + ksft_eq(len(tuples), len(set(tuples)), "duplicates in context dump") + ctx_tuples = set([ctx for ctx in tuples if ctx[0] == cfg.ifname]) + ksft_eq(expect_tuples, ctx_tuples) + + # Sanity-check the results + for data in ctxs: + ksft_ne(set(data['indir']), {0}, "indir table is all zero") + ksft_ne(set(data.get('hkey', [1])), {0}, "key is all zero") + + # More specific checks + if len(ids) > 1 and data.get('context') == ids[1]: + ksft_eq(set(data['indir']), {0, 1}, + "ctx1 - indir table mismatch") + if len(ids) > 2 and data.get('context') == ids[2]: + ksft_eq(data['hkey'], bytes(key_data), "ctx2 - key mismatch") + + # Ifindex filter + ctxs = cfg.ethnl.rss_get({'header': {'dev-name': cfg.ifname}}, dump=True) + tuples = [(c['header']['dev-name'], c.get('context', -1)) for c in ctxs] + ctx_tuples = set(tuples) + ksft_eq(len(tuples), len(ctx_tuples), "duplicates in context dump") + ksft_eq(expect_tuples, ctx_tuples) + + # Skip ctx 0 + expect_tuples.remove((cfg.ifname, -1)) + + ctxs = cfg.ethnl.rss_get({'start-context': 1}, dump=True) + tuples = [(c['header']['dev-name'], c.get('context', -1)) for c in ctxs] + ksft_eq(len(tuples), len(set(tuples)), "duplicates in context dump") + ctx_tuples = set([ctx for ctx in tuples if ctx[0] == cfg.ifname]) + ksft_eq(expect_tuples, ctx_tuples) + + # And finally both with ifindex and skip main + ctxs = cfg.ethnl.rss_get({'header': {'dev-name': cfg.ifname}, 'start-context': 1}, dump=True) + ctx_tuples = set([(c['header']['dev-name'], c.get('context', -1)) for c in ctxs]) + ksft_eq(expect_tuples, ctx_tuples) + + def test_rss_context(cfg, ctx_cnt=1, create_with_cfg=None): """ Test separating traffic into RSS contexts.
@@ -542,7 +614,7 @@ from lib.py import ethtool, ip, defer, GenerateTraffic, CmdExitFailure ksft_run([test_rss_key_indir, test_rss_queue_reconfigure, test_rss_resize, test_hitless_key_update, test_rss_context, test_rss_context4, test_rss_context32, - test_rss_context_queue_reconfigure, + test_rss_context_dump, test_rss_context_queue_reconfigure, test_rss_context_overlap, test_rss_context_overlap2, test_rss_context_out_of_order, test_rss_context4_create_with_cfg], args=(cfg, ))
tools/testing/selftests/net/lib/py/ksft.py +6 -0
@@ -55,6 +55,12 @@ KSFT_DISRUPTIVE = True _fail("Check failed", a, "!=", b, comment) +def ksft_ne(a, b, comment=""): + global KSFT_RESULT + if a == b: + _fail("Check failed", a, "==", b, comment) + + def ksft_true(a, comment=""): if not a: _fail("Check failed", a, "does not eval to True", comment)
Signature · 1 line
2.46.0