Skip to content

Commit 9e43ad7

Browse files
Edward Creekuba-moo
authored andcommitted
net: ethtool: only allow set_rxnfc with rss + ring_cookie if driver opts in
Ethtool ntuple filters with FLOW_RSS were originally defined as adding the base queue ID (ring_cookie) to the value from the indirection table, so that the same table could distribute over more than one set of queues when used by different filters. However, some drivers / hardware ignore the ring_cookie, and simply use the indirection table entries as queue IDs directly. Thus, for drivers which have not opted in by setting ethtool_ops.cap_rss_rxnfc_adds to declare that they support the original (addition) semantics, reject in ethtool_set_rxnfc any filter which combines FLOW_RSS and a nonzero ring. (For a ring_cookie of zero, both behaviours are equivalent.) Set the cap bit in sfc, as it is known to support this feature. Signed-off-by: Edward Cree <[email protected]> Reviewed-by: Martin Habets <[email protected]> Link: https://patch.msgid.link/cc3da0844083b0e301a33092a6299e4042b65221.1731499022.git.ecree.xilinx@gmail.com Signed-off-by: Jakub Kicinski <[email protected]>
1 parent b52a8de commit 9e43ad7

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

drivers/net/ethernet/sfc/ef100_ethtool.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ const struct ethtool_ops ef100_ethtool_ops = {
5959
.get_rxfh_indir_size = efx_ethtool_get_rxfh_indir_size,
6060
.get_rxfh_key_size = efx_ethtool_get_rxfh_key_size,
6161
.rxfh_per_ctx_key = true,
62+
.cap_rss_rxnfc_adds = true,
6263
.rxfh_priv_size = sizeof(struct efx_rss_context_priv),
6364
.get_rxfh = efx_ethtool_get_rxfh,
6465
.set_rxfh = efx_ethtool_set_rxfh,

drivers/net/ethernet/sfc/ethtool.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ const struct ethtool_ops efx_ethtool_ops = {
263263
.get_rxfh_indir_size = efx_ethtool_get_rxfh_indir_size,
264264
.get_rxfh_key_size = efx_ethtool_get_rxfh_key_size,
265265
.rxfh_per_ctx_key = true,
266+
.cap_rss_rxnfc_adds = true,
266267
.rxfh_priv_size = sizeof(struct efx_rss_context_priv),
267268
.get_rxfh = efx_ethtool_get_rxfh,
268269
.set_rxfh = efx_ethtool_set_rxfh,

include/linux/ethtool.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,9 @@ struct kernel_ethtool_ts_info {
734734
* @rxfh_per_ctx_key: device supports setting different RSS key for each
735735
* additional context. Netlink API should report hfunc, key, and input_xfrm
736736
* for every context, not just context 0.
737+
* @cap_rss_rxnfc_adds: device supports nonzero ring_cookie in filters with
738+
* %FLOW_RSS flag; the queue ID from the filter is added to the value from
739+
* the indirection table to determine the delivery queue.
737740
* @rxfh_indir_space: max size of RSS indirection tables, if indirection table
738741
* size as returned by @get_rxfh_indir_size may change during lifetime
739742
* of the device. Leave as 0 if the table size is constant.
@@ -956,6 +959,7 @@ struct ethtool_ops {
956959
u32 cap_rss_ctx_supported:1;
957960
u32 cap_rss_sym_xor_supported:1;
958961
u32 rxfh_per_ctx_key:1;
962+
u32 cap_rss_rxnfc_adds:1;
959963
u32 rxfh_indir_space;
960964
u16 rxfh_key_space;
961965
u16 rxfh_priv_size;

net/ethtool/ioctl.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,11 @@ static noinline_for_stack int ethtool_set_rxnfc(struct net_device *dev,
992992
if (rc)
993993
return rc;
994994

995+
/* Nonzero ring with RSS only makes sense if NIC adds them together */
996+
if (info.flow_type & FLOW_RSS && !ops->cap_rss_rxnfc_adds &&
997+
ethtool_get_flow_spec_ring(info.fs.ring_cookie))
998+
return -EINVAL;
999+
9951000
if (ops->get_rxfh) {
9961001
struct ethtool_rxfh_param rxfh = {};
9971002

0 commit comments

Comments
 (0)