Skip to contentSkip to conversation

net: migrate remaining drivers to dedicated _rxfh_context ops

PATCH Superseded Jakub Kicinski 3 participants 12 messages Jun 30, 2025 – Jul 2, 2025

Subsystems (7)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

cover net: migrate remaining drivers to dedicated _rxfh_context ops

Around a year ago Ed added dedicated ops for managing RSS contexts. This significantly improved the clarity of the driver facing API. Migrate the remaining 3 drivers and remove the old way of muxing the RSS context operations via .set_rxfh().

Jakub Kicinski (5):
eth: otx2: migrate to the *_rxfh_context ops
eth: ice: drop the dead code related to rss_contexts
eth: mlx5: migrate to the *_rxfh_context ops
net: ethtool: remove the compat code for _rxfh_context ops
net: ethtool: reduce indent for _rxfh_context ops

 .../marvell/octeontx2/nic/otx2_common.h       |   8 +-
 .../ethernet/mellanox/mlx5/core/en/rx_res.h   |   2 +-
 include/linux/ethtool.h                       |   4 -
 drivers/net/ethernet/intel/ice/ice_ethtool.c  |  28 +---
 .../marvell/octeontx2/nic/otx2_common.c       |  27 ++--
 .../marvell/octeontx2/nic/otx2_ethtool.c      | 137 ++++++++++--------
 .../ethernet/marvell/octeontx2/nic/otx2_pf.c  |   6 +-
 .../ethernet/marvell/octeontx2/nic/otx2_xsk.c |   4 +-
 .../ethernet/mellanox/mlx5/core/en/rx_res.c   |  12 +-
 .../ethernet/mellanox/mlx5/core/en_ethtool.c  | 125 +++++++++++++---
 net/core/dev.c                                |   6 +-
 net/ethtool/ioctl.c                           |  68 ++-------
 net/ethtool/rss.c                             |   3 +-
 13 files changed, 218 insertions(+), 212 deletions(-)
Signature · 1 line
2.50.0
author maintainer
#1 lore raw

PATCH 1/5 eth: otx2: migrate to the *_rxfh_context ops

otx2 only supports additional indirection tables (no separate keys etc.) so the conversion to dedicated callbacks and core-allocated context is mostly removing the code which stores the extra tables in the driver. Core already stores the indirection tables for additional contexts, and doesn't call .get for them.

One subtle change here is that we'll now start with the table covering all queues, not directing all traffic to queue 0. This is what core expects if the user doesn't pass the initial indir table explicitly (there's a WARN_ON() in the core trying to make sure driver authors don't forget to populate ctx to defaults).

Drivers implementing .create_rxfh_context don't have to set cap_rss_ctx_supported, so remove it.

---
 .../marvell/octeontx2/nic/otx2_common.h       |   8 +-
 .../marvell/octeontx2/nic/otx2_common.c       |  27 ++--
 .../marvell/octeontx2/nic/otx2_ethtool.c      | 137 ++++++++++--------
 .../ethernet/marvell/octeontx2/nic/otx2_pf.c  |   6 +-
 .../ethernet/marvell/octeontx2/nic/otx2_xsk.c |   4 +-
 5 files changed, 90 insertions(+), 92 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +2 -6
index 6b59881f78e0..e3765b73c434 100644
@@ -93,10 +93,6 @@ struct otx2_lmt_info {
 	u64 lmt_addr;
 	u16 lmt_id;
 };
-/* RSS configuration */
-struct otx2_rss_ctx {
-	u8  ind_tbl[MAX_RSS_INDIR_TBL_SIZE];
-};
 
 struct otx2_rss_info {
 	u8 enable;
@@ -104,7 +100,7 @@ struct otx2_rss_info {
 	u16 rss_size;
 #define RSS_HASH_KEY_SIZE	44   /* 352 bit key */
 	u8  key[RSS_HASH_KEY_SIZE];
-	struct otx2_rss_ctx	*rss_ctx[MAX_RSS_GROUPS];
+	u32 ind_tbl[MAX_RSS_INDIR_TBL_SIZE];
 };
 
 /* NIX (or NPC) RX errors */
@@ -1067,7 +1063,7 @@ int otx2_set_hw_capabilities(struct otx2_nic *pfvf);
 int otx2_rss_init(struct otx2_nic *pfvf);
 int otx2_set_flowkey_cfg(struct otx2_nic *pfvf);
 void otx2_set_rss_key(struct otx2_nic *pfvf);
-int otx2_set_rss_table(struct otx2_nic *pfvf, int ctx_id);
+int otx2_set_rss_table(struct otx2_nic *pfvf, int ctx_id, const u32 *ind_tbl);
 
 /* Mbox handlers */
 void mbox_handler_msix_offset(struct otx2_nic *pfvf,
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +9 -18
index 9a10396e7504..f674729124e6 100644
@@ -318,21 +318,20 @@ int otx2_set_flowkey_cfg(struct otx2_nic *pfvf)
 	return err;
 }
 
-int otx2_set_rss_table(struct otx2_nic *pfvf, int ctx_id)
+int otx2_set_rss_table(struct otx2_nic *pfvf, int ctx_id, const u32 *ind_tbl)
 {
 	struct otx2_rss_info *rss = &pfvf->hw.rss_info;
 	const int index = rss->rss_size * ctx_id;
 	struct mbox *mbox = &pfvf->mbox;
-	struct otx2_rss_ctx *rss_ctx;
 	struct nix_aq_enq_req *aq;
 	int idx, err;
 
 	mutex_lock(&mbox->lock);
-	rss_ctx = rss->rss_ctx[ctx_id];
+	ind_tbl = ind_tbl ?: rss->ind_tbl;
 	/* Get memory to put this msg */
 	for (idx = 0; idx < rss->rss_size; idx++) {
 		/* Ignore the queue if AF_XDP zero copy is enabled */
-		if (test_bit(rss_ctx->ind_tbl[idx], pfvf->af_xdp_zc_qidx))
+		if (test_bit(ind_tbl[idx], pfvf->af_xdp_zc_qidx))
 			continue;
 
 		aq = otx2_mbox_alloc_msg_nix_aq_enq(mbox);
@@ -352,7 +351,7 @@ int otx2_set_rss_table(struct otx2_nic *pfvf, int ctx_id)
 			}
 		}
 
-		aq->rss.rq = rss_ctx->ind_tbl[idx];
+		aq->rss.rq = ind_tbl[idx];
 
 		/* Fill AQ info */
 		aq->qidx = index + idx;
@@ -390,30 +389,22 @@ void otx2_set_rss_key(struct otx2_nic *pfvf)
 int otx2_rss_init(struct otx2_nic *pfvf)
 {
 	struct otx2_rss_info *rss = &pfvf->hw.rss_info;
-	struct otx2_rss_ctx *rss_ctx;
 	int idx, ret = 0;
 
-	rss->rss_size = sizeof(*rss->rss_ctx[DEFAULT_RSS_CONTEXT_GROUP]);
+	rss->rss_size = sizeof(*rss->ind_tbl);
 
 	/* Init RSS key if it is not setup already */
 	if (!rss->enable)
 		netdev_rss_key_fill(rss->key, sizeof(rss->key));
 	otx2_set_rss_key(pfvf);
 
-	if (!netif_is_rxfh_configured(pfvf->netdev)) {
-		/* Set RSS group 0 as default indirection table */
-		rss->rss_ctx[DEFAULT_RSS_CONTEXT_GROUP] = kzalloc(rss->rss_size,
-								  GFP_KERNEL);
-		if (!rss->rss_ctx[DEFAULT_RSS_CONTEXT_GROUP])
-			return -ENOMEM;
-
-		rss_ctx = rss->rss_ctx[DEFAULT_RSS_CONTEXT_GROUP];
+	if (!netif_is_rxfh_configured(pfvf->netdev))
 		for (idx = 0; idx < rss->rss_size; idx++)
-			rss_ctx->ind_tbl[idx] =
+			rss->ind_tbl[idx] =
 				ethtool_rxfh_indir_default(idx,
 							   pfvf->hw.rx_queues);
-	}
-	ret = otx2_set_rss_table(pfvf, DEFAULT_RSS_CONTEXT_GROUP);
+
+	ret = otx2_set_rss_table(pfvf, DEFAULT_RSS_CONTEXT_GROUP, NULL);
 	if (ret)
 		return ret;
 
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c +76 -61

232 lines not on this page · raw message

drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +1 -5
index 4e2d1206e1b0..b23585c5e5c2 100644
@@ -2158,7 +2158,6 @@ int otx2_stop(struct net_device *netdev)
 	struct otx2_nic *pf = netdev_priv(netdev);
 	struct otx2_cq_poll *cq_poll = NULL;
 	struct otx2_qset *qset = &pf->qset;
-	struct otx2_rss_info *rss;
 	int qidx, vec, wrk;
 
 	/* If the DOWN flag is set resources are already freed */
@@ -2176,10 +2175,7 @@ int otx2_stop(struct net_device *netdev)
 	otx2_rxtx_enable(pf, false);
 
 	/* Clear RSS enable flag */
-	rss = &pf->hw.rss_info;
-	rss->enable = false;
-	if (!netif_is_rxfh_configured(netdev))
-		kfree(rss->rss_ctx[DEFAULT_RSS_CONTEXT_GROUP]);
+	pf->hw.rss_info.enable = false;
 
 	/* Cleanup Queue IRQ */
 	vec = pci_irq_vector(pf->pdev,
drivers/net/ethernet/marvell/octeontx2/nic/otx2_xsk.c +2 -2
index b328aae23d73..7d67b4cbaf71 100644
@@ -132,7 +132,7 @@ int otx2_xsk_pool_enable(struct otx2_nic *pf, struct xsk_buff_pool *pool, u16 qi
 	set_bit(qidx, pf->af_xdp_zc_qidx);
 	otx2_clean_up_rq(pf, qidx);
 	/* Reconfigure RSS table as 'qidx' cannot be part of RSS now */
-	otx2_set_rss_table(pf, DEFAULT_RSS_CONTEXT_GROUP);
+	otx2_set_rss_table(pf, DEFAULT_RSS_CONTEXT_GROUP, NULL);
 	/* Kick start the NAPI context so that receiving will start */
 	return otx2_xsk_wakeup(pf->netdev, qidx, XDP_WAKEUP_RX);
 }
@@ -153,7 +153,7 @@ int otx2_xsk_pool_disable(struct otx2_nic *pf, u16 qidx)
 	clear_bit(qidx, pf->af_xdp_zc_qidx);
 	xsk_pool_dma_unmap(pool, DMA_ATTR_SKIP_CPU_SYNC | DMA_ATTR_WEAK_ORDERING);
 	/* Reconfigure RSS table as 'qidx' now need to be part of RSS now */
-	otx2_set_rss_table(pf, DEFAULT_RSS_CONTEXT_GROUP);
+	otx2_set_rss_table(pf, DEFAULT_RSS_CONTEXT_GROUP, NULL);
 
 	return 0;
 }
Signature · 1 line
2.50.0
author maintainer
#2 lore raw

PATCH 2/5 eth: ice: drop the dead code related to rss_contexts

In reply to Jakub Kicinski

ICE appears to have some odd form of rss_context use plumbed in for .get_rxfh. The .set_rxfh side does not support creating contexts, however, so this must be dead code. For at least a year now (since commit 7964e7884643 ("net: ethtool: use the tracking array for get_rxfh on custom RSS contexts")) we have not been calling .get_rxfh with a non-zero rss_context. We just get the info from the RSS XArray under dev->ethtool.

Remove what must be dead code in the driver, clear the support flags.

---
 drivers/net/ethernet/intel/ice/ice_ethtool.c | 28 +++-----------------
 1 file changed, 3 insertions(+), 25 deletions(-)
drivers/net/ethernet/intel/ice/ice_ethtool.c +3 -25
index ea7e8b879b48..e54221fba849 100644
@@ -3591,11 +3591,10 @@ static int
 ice_get_rxfh(struct net_device *netdev, struct ethtool_rxfh_param *rxfh)
 {
 	struct ice_netdev_priv *np = netdev_priv(netdev);
-	u32 rss_context = rxfh->rss_context;
 	struct ice_vsi *vsi = np->vsi;
 	struct ice_pf *pf = vsi->back;
 	u16 qcount, offset;
-	int err, num_tc, i;
+	int err, i;
 	u8 *lut;
 
 	if (!test_bit(ICE_FLAG_RSS_ENA, pf->flags)) {
@@ -3603,24 +3602,8 @@ ice_get_rxfh(struct net_device *netdev, struct ethtool_rxfh_param *rxfh)
 		return -EOPNOTSUPP;
 	}
 
-	if (rss_context && !ice_is_adq_active(pf)) {
-		netdev_err(netdev, "RSS context cannot be non-zero when ADQ is not configured.\n");
-		return -EINVAL;
-	}
-
-	qcount = vsi->mqprio_qopt.qopt.count[rss_context];
-	offset = vsi->mqprio_qopt.qopt.offset[rss_context];
-
-	if (rss_context && ice_is_adq_active(pf)) {
-		num_tc = vsi->mqprio_qopt.qopt.num_tc;
-		if (rss_context >= num_tc) {
-			netdev_err(netdev, "RSS context:%d  > num_tc:%d\n",
-				   rss_context, num_tc);
-			return -EINVAL;
-		}
-		/* Use channel VSI of given TC */
-		vsi = vsi->tc_map_vsi[rss_context];
-	}
+	qcount = vsi->mqprio_qopt.qopt.count[0];
+	offset = vsi->mqprio_qopt.qopt.offset[0];
 
 	rxfh->hfunc = ETH_RSS_HASH_TOP;
 	if (vsi->rss_hfunc == ICE_AQ_VSI_Q_OPT_RSS_HASH_SYM_TPLZ)
@@ -3680,9 +3663,6 @@ ice_set_rxfh(struct net_device *netdev, struct ethtool_rxfh_param *rxfh,
 	    rxfh->hfunc != ETH_RSS_HASH_TOP)
 		return -EOPNOTSUPP;
 
-	if (rxfh->rss_context)
-		return -EOPNOTSUPP;
-
 	if (!test_bit(ICE_FLAG_RSS_ENA, pf->flags)) {
 		/* RSS not supported return error here */
 		netdev_warn(netdev, "RSS is not configured on this VSI!\n");
@@ -4750,12 +4730,10 @@ static int ice_repr_ethtool_reset(struct net_device *dev, u32 *flags)
 }
 
 static const struct ethtool_ops ice_ethtool_ops = {
-	.cap_rss_ctx_supported  = true,
 	.supported_coalesce_params = ETHTOOL_COALESCE_USECS |
 				     ETHTOOL_COALESCE_USE_ADAPTIVE |
 				     ETHTOOL_COALESCE_RX_USECS_HIGH,
 	.supported_input_xfrm	= RXH_XFRM_SYM_XOR,
-	.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,
Signature · 1 line
2.50.0
author maintainer
#3 lore raw

PATCH 3/5 eth: mlx5: migrate to the *_rxfh_context ops

In reply to Jakub Kicinski

Convert mlx5 to dedicated RXFH ops. This is a fairly shallow conversion, TBH, most of the driver code stays as is, but we let the core allocate the context ID for the driver.

Tested with drivers/net/hw/rss_ctx.py on MCX6.

---
 .../ethernet/mellanox/mlx5/core/en/rx_res.h   |   2 +-
 .../ethernet/mellanox/mlx5/core/en/rx_res.c   |  12 +-
 .../ethernet/mellanox/mlx5/core/en_ethtool.c  | 125 +++++++++++++++---
 3 files changed, 108 insertions(+), 31 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.h +1 -1
index 3e09d91281af..5baa840b08ab 100644
@@ -61,7 +61,7 @@ int mlx5e_rx_res_rss_set_hash_fields(struct mlx5e_rx_res *res, u32 rss_idx,
 int mlx5e_rx_res_packet_merge_set_param(struct mlx5e_rx_res *res,
 					struct mlx5e_packet_merge_param *pkt_merge_param);
 
-int mlx5e_rx_res_rss_init(struct mlx5e_rx_res *res, u32 *rss_idx, unsigned int init_nch);
+int mlx5e_rx_res_rss_init(struct mlx5e_rx_res *res, u32 rss_idx, unsigned int init_nch);
 int mlx5e_rx_res_rss_destroy(struct mlx5e_rx_res *res, u32 rss_idx);
 int mlx5e_rx_res_rss_cnt(struct mlx5e_rx_res *res);
 int mlx5e_rx_res_rss_index(struct mlx5e_rx_res *res, struct mlx5e_rss *rss);
drivers/net/ethernet/mellanox/mlx5/core/en/rx_res.c +3 -9
index 5fcbe47337b0..4368c7d32674 100644
@@ -71,17 +71,12 @@ static int mlx5e_rx_res_rss_init_def(struct mlx5e_rx_res *res,
 	return 0;
 }
 
-int mlx5e_rx_res_rss_init(struct mlx5e_rx_res *res, u32 *rss_idx, unsigned int init_nch)
+int mlx5e_rx_res_rss_init(struct mlx5e_rx_res *res, u32 rss_idx, unsigned int init_nch)
 {
 	bool inner_ft_support = res->features & MLX5E_RX_RES_FEATURE_INNER_FT;
 	struct mlx5e_rss *rss;
-	int i;
 
-	for (i = 1; i < MLX5E_MAX_NUM_RSS; i++)
-		if (!res->rss[i])
-			break;
-
-	if (i == MLX5E_MAX_NUM_RSS)
+	if (WARN_ON_ONCE(res->rss[rss_idx]))
 		return -ENOSPC;
 
 	rss = mlx5e_rss_init(res->mdev, inner_ft_support, res->drop_rqn,
@@ -97,8 +92,7 @@ int mlx5e_rx_res_rss_init(struct mlx5e_rx_res *res, u32 *rss_idx, unsigned int i
 		mlx5e_rss_enable(rss, res->rss_rqns, vhca_ids, res->rss_nch);
 	}
 
-	res->rss[i] = rss;
-	*rss_idx = i;
+	res->rss[rss_idx] = rss;
 
 	return 0;
 }
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +104 -21

167 lines not on this page · raw message

Signature · 1 line
2.50.0
#4 lore raw

Re: [PATCH net-next 3/5] eth: mlx5: migrate to the *_rxfh_context ops

Quoted 7 lines · Jakub Kicinski

Convert mlx5 to dedicated RXFH ops. This is a fairly shallow conversion, TBH, most of the driver code stays as is, but we let the core allocate the context ID for the driver.

Tested with drivers/net/hw/rss_ctx.py on MCX6.

FWIW, I started doing this a while ago and then got distracted by implementing the netlink counterpart of set rxfh (code is slowly going through internal review), so a welcome change, thanks!

Also, the ethtool ioctl set_rxfh() function was a nightmare, so its simplification in this series is a great change.

Reviewed-by on v1 3/5
#5 lore raw

Re: [PATCH net-next 3/5] eth: mlx5: migrate to the *_rxfh_context ops

In reply to Jakub Kicinski
Quoted 8 lines · Jakub Kicinski

Convert mlx5 to dedicated RXFH ops. This is a fairly shallow conversion, TBH, most of the driver code stays as is, but we let the core allocate the context ID for the driver.

Tested with drivers/net/hw/rss_ctx.py on MCX6.

---

drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c static int mlx5e_get_rxfh(struct net_device *netdev, struct ethtool_rxfh_param * · line 1504

Quoted 7 lines
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +2 -3
+static int mlx5e_rxfh_hfunc_check(struct mlx5e_priv *priv,
+				  const struct ethtool_rxfh_param *rxfh)
 {
-	bool symmetric = rxfh->input_xfrm == RXH_XFRM_SYM_OR_XOR;
-	struct mlx5e_priv *priv = netdev_priv(dev);
-	u32 *rss_context = &rxfh->rss_context;
 	u8 hfunc = rxfh->hfunc;

This variable is kinda redundant now.

Quoted 29 lines
(quoted diff) +22 -3
 	unsigned int count;
-	int err;
-
-	mutex_lock(&priv->state_lock);
 
 	count = priv->channels.params.num_channels;
 
+static int mlx5e_create_rxfh_context(struct net_device *dev,
+				     struct ethtool_rxfh_context *ctx,
+				     const struct ethtool_rxfh_param *rxfh,
+				     struct netlink_ext_ack *extack)
+{
+	bool symmetric = rxfh->input_xfrm == RXH_XFRM_SYM_OR_XOR;
+	struct mlx5e_priv *priv = netdev_priv(dev);
+	u8 hfunc = rxfh->hfunc;
+	int err;
+
+	mutex_lock(&priv->state_lock);
+
+	err = mlx5e_rxfh_hfunc_check(priv, rxfh);
+	if (err)
+		goto unlock;
+
+	err = mlx5e_rx_res_rss_init(priv->rx_res, rxfh->rss_context,
+				    priv->channels.params.num_channels);
+	if (err)
+		goto unlock;
+
+	err = mlx5e_rx_res_rss_set_rxfh(priv->rx_res, rxfh->rss_context,

Review

Quoted 10 lines
(quoted diff) +10 -0
+					rxfh->indir, rxfh->key,
+					hfunc == ETH_RSS_HASH_NO_CHANGE ? NULL : &hfunc,
+					rxfh->input_xfrm == RXH_XFRM_NO_CHANGE ? NULL : &symmetric);
+	if (err)
+		goto unlock;
+
+	mlx5e_rx_res_rss_get_rxfh(priv->rx_res, rxfh->rss_context,
+				  ethtool_rxfh_context_indir(ctx),
+				  ethtool_rxfh_context_key(ctx),
+				  &ctx->hfunc, &symmetric);

We don't expect it to fail so no return value check here, but maybe a WARN_ON_ONCE() should be added?

drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c static int mlx5e_set_rxfh(struct net_device *dev, struct ethtool_rxfh_param *rxf · line 1585

Quoted 7 lines
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +7 -0
+	if (symmetric)
+		ctx->input_xfrm = RXH_XFRM_SYM_OR_XOR;
+
+unlock:
+	mutex_unlock(&priv->state_lock);
+	return err;
+}

Thanks Jakub!

author maintainer
#6 lore raw

Re: [PATCH net-next 3/5] eth: mlx5: migrate to the *_rxfh_context ops

Quoted 7 lines · On Tue, 1 Jul 2025 09:25:41 +0300 Gal Pressman wrote:

drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c static int mlx5e_set_rxfh(struct net_device *dev, struct ethtool_rxfh_param *rxf · line 1578

Quoted 4 lines
drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +4 -0
+	mlx5e_rx_res_rss_get_rxfh(priv->rx_res, rxfh->rss_context,
+				  ethtool_rxfh_context_indir(ctx),
+				  ethtool_rxfh_context_key(ctx),
+				  &ctx->hfunc, &symmetric);  

We don't expect it to fail so no return value check here, but maybe a WARN_ON_ONCE() should be added?

Hm.. you know what, I think I'll pop that WARN_ON_ONCE() inside mlx5e_rx_res_rss_get_rxfh() and make it return void. Core doesn't call get_rxfh for custom contexts any more, the only calls to mlx5e_rx_res_rss_get_rxfh() are this one right after creation and the one that asks for context 0, which I suppose must always exist.

author maintainer
#7 lore raw

PATCH 4/5 net: ethtool: remove the compat code for _rxfh_context ops

In reply to Jakub Kicinski

All drivers are now converted to dedicated _rxfh_context ops. Remove the use of >set_rxfh() to manage additional contexts.

---
 include/linux/ethtool.h |  4 ----
 net/core/dev.c          |  6 +-----
 net/ethtool/ioctl.c     | 39 +++------------------------------------
 net/ethtool/rss.c       |  3 +--
 4 files changed, 5 insertions(+), 47 deletions(-)
include/linux/ethtool.h +0 -4
index 59877fd2a1d3..de5bd76a400c 100644
@@ -865,9 +865,6 @@ struct kernel_ethtool_ts_info {
  * @supported_input_xfrm: supported types of input xfrm from %RXH_XFRM_*.
  * @cap_link_lanes_supported: indicates if the driver supports lanes
  *	parameter.
- * @cap_rss_ctx_supported: indicates if the driver supports RSS
- *	contexts via legacy API, drivers implementing @create_rxfh_context
- *	do not have to set this bit.
  * @rxfh_per_ctx_fields: device supports selecting different header fields
  *	for Rx hash calculation and RSS for each additional context.
  * @rxfh_per_ctx_key: device supports setting different RSS key for each
@@ -1100,7 +1097,6 @@ struct kernel_ethtool_ts_info {
 struct ethtool_ops {
 	u32     supported_input_xfrm:8;
 	u32     cap_link_lanes_supported:1;
-	u32     cap_rss_ctx_supported:1;
 	u32	rxfh_per_ctx_fields:1;
 	u32	rxfh_per_ctx_key:1;
 	u32	cap_rss_rxnfc_adds:1;
net/core/dev.c +1 -5
index 7ee808eb068e..d8936457d2f9 100644
@@ -11988,11 +11988,7 @@ static void netdev_rss_contexts_free(struct net_device *dev)
 		rxfh.rss_delete = true;
 
 		xa_erase(&dev->ethtool->rss_ctx, context);
-		if (dev->ethtool_ops->create_rxfh_context)
-			dev->ethtool_ops->remove_rxfh_context(dev, ctx,
-							      context, NULL);
-		else
-			dev->ethtool_ops->set_rxfh(dev, &rxfh, NULL);
+		dev->ethtool_ops->remove_rxfh_context(dev, ctx, context, NULL);
 		kfree(ctx);
 	}
 	xa_destroy(&dev->ethtool->rss_ctx);
net/ethtool/ioctl.c +3 -36
index b6d96e562c9a..17dbda6afd96 100644
@@ -1391,8 +1391,7 @@ 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 ||
-				  ops->create_rxfh_context))
+	if (rxfh.rss_context && !ops->create_rxfh_context)
 		return -EOPNOTSUPP;
 
 	rxfh.indir_size = rxfh_dev.indir_size;
@@ -1534,8 +1533,7 @@ 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 ||
-				  ops->create_rxfh_context))
+	if (rxfh.rss_context && !ops->create_rxfh_context)
 		return -EOPNOTSUPP;
 	/* Check input data transformation capabilities */
 	if (rxfh.input_xfrm && rxfh.input_xfrm != RXH_XFRM_SYM_XOR &&
@@ -1670,7 +1668,7 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
 	rxfh_dev.rss_context = rxfh.rss_context;
 	rxfh_dev.input_xfrm = rxfh.input_xfrm;
 
-	if (rxfh.rss_context && ops->create_rxfh_context) {
+	if (rxfh.rss_context) {
 		if (create) {
 			ret = ops->create_rxfh_context(dev, ctx, &rxfh_dev,
 						       extack);
@@ -1712,37 +1710,6 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
 		else if (rxfh.indir_size != ETH_RXFH_INDIR_NO_CHANGE)
 			dev->priv_flags |= IFF_RXFH_CONFIGURED;
 	}
-	/* Update rss_ctx tracking */
-	if (create && !ops->create_rxfh_context) {
-		/* driver uses old API, it chose context ID */
-		if (WARN_ON(xa_load(&dev->ethtool->rss_ctx, rxfh_dev.rss_context))) {
-			/* context ID reused, our tracking is screwed */
-			kfree(ctx);
-			goto out_unlock;
-		}
-		/* Allocate the exact ID the driver gave us */
-		if (xa_is_err(xa_store(&dev->ethtool->rss_ctx, rxfh_dev.rss_context,
-				       ctx, GFP_KERNEL))) {
-			kfree(ctx);
-			goto out_unlock;
-		}
-
-		/* Fetch the defaults for the old API, in the new API drivers
-		 * should write defaults into ctx themselves.
-		 */
-		rxfh_dev.indir = (u32 *)rss_config;
-		rxfh_dev.indir_size = dev_indir_size;
-
-		rxfh_dev.key = rss_config + indir_bytes;
-		rxfh_dev.key_size = dev_key_size;
-
-		ret = ops->get_rxfh(dev, &rxfh_dev);
-		if (WARN_ON(ret)) {
-			xa_erase(&dev->ethtool->rss_ctx, rxfh.rss_context);
-			kfree(ctx);
-			goto out_unlock;
-		}
-	}
 	if (rxfh_dev.rss_delete) {
 		WARN_ON(xa_erase(&dev->ethtool->rss_ctx, rxfh.rss_context) != ctx);
 		kfree(ctx);
net/ethtool/rss.c +1 -2
index e717f23cbc10..4e8ca2c38175 100644
@@ -163,8 +163,7 @@ 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)
+	if (request->rss_context && !ops->create_rxfh_context)
 		return -EOPNOTSUPP;
 
 	mutex_lock(&dev->ethtool->rss_lock);
Signature · 1 line
2.50.0
#8 lore raw

Re: [PATCH net-next 4/5] net: ethtool: remove the compat code for _rxfh_context ops

kernel test robot noticed the following build warnings:

Hi Jakub,

kernel test robot noticed the following build warnings:

[auto build test WARNING on net-next/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Jakub-Kicinski/eth-otx2-migrate-to-the-_rxfh_context-ops/20250701-002143
base:   net-next/main
patch link:    https://lore.kernel.org/r/20250630160953.1093267-5-kuba%40kernel.org
patch subject: [PATCH net-next 4/5] net: ethtool: remove the compat code for _rxfh_context ops
config: arm-randconfig-r072-20250701 (https://download.01.org/0day-ci/archive/20250701/[email protected]/config)
compiler: arm-linux-gnueabi-gcc (GCC) 13.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250701/[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 warnings (new ones prefixed by >>):

net/core/dev.c: In function 'netdev_rss_contexts_free':

>> net/core/dev.c:11981:43: warning: variable 'rxfh' set but not used [-Wunused-but-set-variable]

11981 | struct ethtool_rxfh_param rxfh;
| ^~~~

vim +/rxfh +11981 net/core/dev.c

^1da177e4c3f41 Linus Torvalds 2005-04-16  11973  
6ad2962f8adfd5 Edward Cree    2024-06-27  11974  static void netdev_rss_contexts_free(struct net_device *dev)
6ad2962f8adfd5 Edward Cree    2024-06-27  11975  {
6ad2962f8adfd5 Edward Cree    2024-06-27  11976  	struct ethtool_rxfh_context *ctx;
6ad2962f8adfd5 Edward Cree    2024-06-27  11977  	unsigned long context;
6ad2962f8adfd5 Edward Cree    2024-06-27  11978  
87925151191b64 Edward Cree    2024-06-27  11979  	mutex_lock(&dev->ethtool->rss_lock);
6ad2962f8adfd5 Edward Cree    2024-06-27  11980  	xa_for_each(&dev->ethtool->rss_ctx, context, ctx) {
6ad2962f8adfd5 Edward Cree    2024-06-27 @11981  		struct ethtool_rxfh_param rxfh;
6ad2962f8adfd5 Edward Cree    2024-06-27  11982  
6ad2962f8adfd5 Edward Cree    2024-06-27  11983  		rxfh.indir = ethtool_rxfh_context_indir(ctx);
6ad2962f8adfd5 Edward Cree    2024-06-27  11984  		rxfh.key = ethtool_rxfh_context_key(ctx);
6ad2962f8adfd5 Edward Cree    2024-06-27  11985  		rxfh.hfunc = ctx->hfunc;
6ad2962f8adfd5 Edward Cree    2024-06-27  11986  		rxfh.input_xfrm = ctx->input_xfrm;
6ad2962f8adfd5 Edward Cree    2024-06-27  11987  		rxfh.rss_context = context;
6ad2962f8adfd5 Edward Cree    2024-06-27  11988  		rxfh.rss_delete = true;
6ad2962f8adfd5 Edward Cree    2024-06-27  11989  
6ad2962f8adfd5 Edward Cree    2024-06-27  11990  		xa_erase(&dev->ethtool->rss_ctx, context);
122f0aaf307490 Jakub Kicinski 2025-06-30  11991  		dev->ethtool_ops->remove_rxfh_context(dev, ctx, context, NULL);
6ad2962f8adfd5 Edward Cree    2024-06-27  11992  		kfree(ctx);
6ad2962f8adfd5 Edward Cree    2024-06-27  11993  	}
6ad2962f8adfd5 Edward Cree    2024-06-27  11994  	xa_destroy(&dev->ethtool->rss_ctx);
87925151191b64 Edward Cree    2024-06-27  11995  	mutex_unlock(&dev->ethtool->rss_lock);
6ad2962f8adfd5 Edward Cree    2024-06-27  11996  }
6ad2962f8adfd5 Edward Cree    2024-06-27  11997  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
author maintainer
#10 lore raw

PATCH 5/5 net: ethtool: reduce indent for _rxfh_context ops

In reply to Jakub Kicinski

Now that we don't have the compat code we can reduce the indent a little. No functional changes.

---
 net/ethtool/ioctl.c | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)
net/ethtool/ioctl.c +13 -18
index 17dbda6afd96..fcd2a9a20527 100644
@@ -1668,25 +1668,20 @@ static noinline_for_stack int ethtool_set_rxfh(struct net_device *dev,
 	rxfh_dev.rss_context = rxfh.rss_context;
 	rxfh_dev.input_xfrm = rxfh.input_xfrm;
 
-	if (rxfh.rss_context) {
-		if (create) {
-			ret = ops->create_rxfh_context(dev, ctx, &rxfh_dev,
-						       extack);
-			/* Make sure driver populates defaults */
-			WARN_ON_ONCE(!ret && !rxfh_dev.key &&
-				     ops->rxfh_per_ctx_key &&
-				     !memchr_inv(ethtool_rxfh_context_key(ctx),
-						 0, ctx->key_size));
-		} else if (rxfh_dev.rss_delete) {
-			ret = ops->remove_rxfh_context(dev, ctx,
-						       rxfh.rss_context,
-						       extack);
-		} else {
-			ret = ops->modify_rxfh_context(dev, ctx, &rxfh_dev,
-						       extack);
-		}
-	} else {
+	if (!rxfh.rss_context) {
 		ret = ops->set_rxfh(dev, &rxfh_dev, extack);
+	} else if (create) {
+		ret = ops->create_rxfh_context(dev, ctx, &rxfh_dev, extack);
+		/* Make sure driver populates defaults */
+		WARN_ON_ONCE(!ret && !rxfh_dev.key &&
+			     ops->rxfh_per_ctx_key &&
+			     !memchr_inv(ethtool_rxfh_context_key(ctx),
+					 0, ctx->key_size));
+	} else if (rxfh_dev.rss_delete) {
+		ret = ops->remove_rxfh_context(dev, ctx,
+					       rxfh.rss_context, extack);
+	} else {
+		ret = ops->modify_rxfh_context(dev, ctx, &rxfh_dev, extack);
 	}
 	if (ret) {
 		if (create) {
Signature · 1 line
2.50.0