Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next v7 00/15] devlink, mlx5, iavf, ice: XLVF for iavf
@ 2026-11-21 22:55 Przemek Kitszel
  2026-11-21 22:55 ` [PATCH net-next v7 01/15] iavf: keep RSS config across resets Przemek Kitszel
                   ` (15 more replies)
  0 siblings, 16 replies; 28+ messages in thread
From: Przemek Kitszel @ 2026-11-21 22:55 UTC (permalink / raw)
  To: netdev, Jakub Kicinski, Jiri Pirko
  Cc: Tony Nguyen, Aleksandr Loktionov, Michal Schmidt, edumazet, horms,
	pabeni, davem, Jonathan Corbet, skhan, rdunlap, andrew+netdev,
	saeedm, tariqt, leon, mbloch, jacob.e.keller, jedrzej.jagielski,
	anzaki, brett.creeley, ohartoov, Petr Oros, Donald Hunter,
	Przemek Kitszel

Also available here
https://github.com/pkitszel/linux/tree/xlvf-v7
(no mlx changes, just kept series name)

The purpose of this series is to allow iavf to use more than 16 queue
pairs, in two modes: up to 64 and up to 256 queue pairs.

In order to support more queues for VF, we must give it a bigger RSS
table (GLOBAL LUT or PF LUT). There are 16 GLOBAL LUTs on E810, and one
PF LUT for every PF on given card. Both kinds could be (re)assigned to
a VF, while a PF must hold at least one of them at any given moment.
GLOBAL LUT allows VF to use up to 64 queues, PF LUT lets it use up to
256 queues.

RSS LUTs are exposed to the user for assignment via devlink resources
API, which I have extended to make it possible.

The first two patches of v6 are in net-next already, thanks Jakub!
As he asked, v7 starts with two prep patches split out of the bigger
ones: "iavf: keep RSS config across resets" fixes old iavf bugs that
apply to every PF, and keeps the RSS config set by the user across
resets; "ice: prepare RSS LUT config for runtime LUT changes" adds
the locking and the queue caps needed to change an RSS LUT at runtime.

Devlink changes:
1. Add a configuration mode (cmode) to resources, reusing the values
   of enum devlink_param_cmode. Every resource reports its cmode, like
   each param value does. Existing resources are "driverinit": a size
   set by the user is staged as size_new until the next reload.
   The driver applies the size of a "runtime" resource right away, via
   .size_set(), or fails it with nothing changed, and reports the size
   via .size_get(); occ is the current use, as before. ice RSS LUTs are
   exposed that way. The first take on it was an RFC in Feb 2025, link
   in the patch. I will do the iproute2 change for the resource cmode as
   soon as this series is merged.
2. (minor) Add devlink_alloc_drv(), to allocate a devlink instance for
   a device on behalf of another driver. ice uses it for the VF devlink
   instance, which has to be owned by ice regardless of the driver bound
   to the VF device.

There are also patches for Admin Queue extension, GLOBAL RSS LUT
alloc/free, and two rather big "new opcodes" patches, by Ahmed (iavf)
and Brett (ice).

Finally there is a patch that adds devlink instance for VF and
registers devlink resources on it, combined with all the glue code to
make actual use of the whole series and accept the larger number of
queues for VF. This (the last) patch contains usage examples.

Each PF and each VF has one "rss_lut" resource, the size of the RSS LUT
it uses, in entries: 64 (VSI LUT, VF only), 512 (GLOBAL LUT), or 2048
(PF LUT). The "whole device" instance reports how many LUTs of each
kind the device has (size), and how many of them are in use (occ),
read-only. On a card with 8 PFs:
$ devlink resource show devlink_index/11
devlink_index/11:
  name rss_lut_512 size 16 occ 0 unit entry dpipe_tables none
  name rss_lut_2048 size 8 occ 8 unit entry dpipe_tables none
$ sudo devlink resource set pci/0000:18:00.0 path rss_lut size 512
$ devlink resource show pci/0000:18:00.0
pci/0000:18:00.0:
  name rss_lut size 512 unit entry size_min 512 size_max 2048 size_gran 512 dpipe_tables none

The RSS indirection table set by the user is kept on a LUT change, and
on reset: ethtool_rxfh_indir_resize() repeats it to fill a bigger LUT,
and folds it into a smaller one. ice rejects a PF LUT change when the
table can't be folded into the new LUT, or uses queues that the new LUT
can't spread traffic to. iavf drops the table only when it can't be
folded, or uses queues the VF no longer has.

Things AI reports but I don't want to change:
 * hardening against a malicious or buggy FW: we have to trust the FW
 * hardening of the VF against a malicious or buggy PF: likewise, VF has
   to trust its PF
 * iavf: ethtool -L max is the PF RSS region in LARGE mode, so iavf
   asks only for queues that RSS can spread traffic to; ice never
   grants a VF request for more queues than its RSS region, only the
   admin can give a VF more, via sriov_vf_msix_count
 * iavf: fixes of older bugs that apply to every PF are in the first
   patch, for net-next, not net: they are rarely hit without the rest
   of this series, which makes them common
 * non-atomic updates of iavf adapter->flags: pre-existing pattern in
   the whole driver, out of scope of this series

AI also reports lock inversions around
ice_tear_down_devlink_rate_tree(). They are pre-existing, patch 4/6 of
my DCB series fixes them. That series also fixes other pre-existing
issues reported by AI:
https://lore.kernel.org/netdev/20261102105346.30739-1-przemyslaw.kitszel@intel.com

My local Sashiko runs reported a few more pre-existing issues, I am
happy to work on them.

v7:
 * drop the shared devlink patches, applied to net-next by Jakub
 * split out two prep patches, and put them first (Jakub)
 * devlink: resource cmode instead of .occ_set(), occ is the current
   use again (Jakub); new DEVLINK_ATTR_RESOURCE_CMODE, reported for
   every resource; runtime resources documented in
   devlink-resource.rst; Alex's Reviewed-by dropped due to the rewrite
 * ice: one runtime "rss_lut" resource per PF and per VF, the size of
   its RSS LUT in entries, switched in one step; the whole device
   rss_lut_512 and rss_lut_2048 are read-only, size is the number of
   LUTs, occ is how many of them are in use; no "rss" parent resource
   (Jakub); a small deviation: a new size applies right away, it is the
   LUT in use, not a cap for the next LUT allocation
 * ice, iavf: keep the RSS indirection table set by the user when the
   RSS LUT size changes, and on reset: fold or unfold it with
   ethtool_rxfh_indir_resize(), instead of resetting it to the default
   spread; iavf keeps the RSS key set by the user across resets too
   (Jakub)
 * ice: reject a PF LUT change when the user RSS table uses queues that
   the new LUT can't spread traffic to, and RSS LUT changes with RSS
   disabled, e.g. in safe mode
 * ice: cap the total count of queues of each type in the chunks of
   ENABLE_QUEUES_V2 and DISABLE_QUEUES_V2, overlapping chunks made PF
   repeat the work on the same queues many times (Sashiko)
 * ice: fail __ice_vsi_get_qs() when the queues don't fit in the
   scatter count, instead of cutting the count to 16
 * ice: clear ICE_FLAG_TC_MQPRIO when the ADQ setup fails, it blocked
   RSS LUT changes (Sashiko)
 * ice: unregister the VF devlink instances before pci_disable_sriov()
 * ice: return -ENOSPC from sriov_vf_msix_count when the VF queues
   don't fit in one free range of PF queues, before anything is torn
   down
 * ice: clear the disabled state of a VF whose VSI rebuild failed on
   a PF reset, so a VFLR can recover it
 * iavf: check the length of the VIRTCHNL_OP_GET_MAX_RSS_QREGION reply,
   and cap qregion_width (Sashiko)
 * iavf: clear IAVF_FLAG_REINIT_MSIX_NEEDED also on a reset while down
   (Sashiko)
 * iavf: keep the RSS buffers on reinit after iavf_disable_vf(), they
   leaked
 * smaller fixes, mostly after Sashiko review; per-patch changelogs are
   under "---"

Previous versions (the v6 cover letter has the v2..v6 changelogs):
v6: https://lore.kernel.org/netdev/20261117094913.100756-1-przemyslaw.kitszel@intel.com
v5: https://lore.kernel.org/netdev/20261110141534.95614-1-przemyslaw.kitszel@intel.com
v4: https://lore.kernel.org/netdev/20261103141646.303620-1-przemyslaw.kitszel@intel.com
v3: https://lore.kernel.org/netdev/20261015185454.6332-1-przemyslaw.kitszel@intel.com
v2: https://lore.kernel.org/netdev/20261009121433.30347-1-przemyslaw.kitszel@intel.com
v1: https://lore.kernel.org/netdev/20260508124208.11622-1-przemyslaw.kitszel@intel.com


Ahmed Zaki (1):
  iavf: use new opcodes to request more than 16 queues

Brett Creeley (2):
  ice: add VF queue ena/dis helper functions
  ice: introduce handling of virtchnl LARGE VF opcodes

Przemek Kitszel (12):
  iavf: keep RSS config across resets
  ice: prepare RSS LUT config for runtime LUT changes
  ice: add helpers for Global RSS LUT alloc, free, vsi_update
  ice: rename ICE_MAX_RSS_QS_PER_VF to ICE_MAX_QS_PER_VF_VCV1
  ice: bump to 256qs for VF
  iavf: extend iavf_configure_queues() to support more queues
  iavf: temporary rename of IAVF_MAX_REQ_QUEUES to
    IAVF_MAX_REQ_QUEUES_VCV1
  iavf: increase max number of queues to 256
  devlink: add cmode to resources
  ice: represent RSS LUTs as devlink resources
  devlink: add devlink_alloc_drv()
  ice: support up to 256 VF queues

 Documentation/netlink/specs/devlink.yaml      |  10 +
 .../networking/devlink/devlink-info.rst       |   2 +
 .../networking/devlink/devlink-resource.rst   |  19 +
 Documentation/networking/devlink/ice.rst      |  83 ++
 drivers/net/ethernet/intel/ice/Makefile       |   1 +
 drivers/net/ethernet/intel/iavf/iavf.h        |  36 +-
 .../net/ethernet/intel/iavf/iavf_register.h   |   2 +
 .../net/ethernet/intel/ice/devlink/resource.h |  28 +
 drivers/net/ethernet/intel/ice/ice.h          |   9 +-
 drivers/net/ethernet/intel/ice/ice_adapter.h  |  29 +
 .../net/ethernet/intel/ice/ice_adminq_cmd.h   |   1 +
 drivers/net/ethernet/intel/ice/ice_common.h   |   1 +
 drivers/net/ethernet/intel/ice/ice_lag.h      |   2 +-
 drivers/net/ethernet/intel/ice/ice_lib.h      |   5 +
 drivers/net/ethernet/intel/ice/ice_switch.h   |   5 +-
 drivers/net/ethernet/intel/ice/ice_vf_lib.h   |  36 +-
 drivers/net/ethernet/intel/ice/virt/queues.h  |   5 +
 drivers/net/ethernet/intel/ice/virt/rss.h     |   1 +
 .../net/ethernet/intel/ice/virt/virtchnl.h    |   4 +
 include/linux/net/intel/virtchnl.h            | 129 +++-
 include/net/devlink.h                         |  12 +
 include/uapi/linux/devlink.h                  |   2 +
 .../net/ethernet/intel/iavf/iavf_ethtool.c    |  61 +-
 drivers/net/ethernet/intel/iavf/iavf_main.c   | 360 ++++++++-
 .../net/ethernet/intel/iavf/iavf_virtchnl.c   | 295 ++++++-
 .../net/ethernet/intel/ice/devlink/resource.c | 727 ++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_adapter.c  |  19 +-
 drivers/net/ethernet/intel/ice/ice_base.c     |  14 +-
 drivers/net/ethernet/intel/ice/ice_common.c   |   5 +-
 drivers/net/ethernet/intel/ice/ice_ethtool.c  |  90 ++-
 drivers/net/ethernet/intel/ice/ice_idc.c      |  24 +-
 drivers/net/ethernet/intel/ice/ice_lag.c      |  54 +-
 drivers/net/ethernet/intel/ice/ice_lib.c      | 197 ++++-
 drivers/net/ethernet/intel/ice/ice_main.c     |  57 +-
 drivers/net/ethernet/intel/ice/ice_sriov.c    |  32 +-
 drivers/net/ethernet/intel/ice/ice_switch.c   |  52 +-
 drivers/net/ethernet/intel/ice/ice_vf_lib.c   |  85 +-
 .../net/ethernet/intel/ice/virt/allowlist.c   |   8 +
 drivers/net/ethernet/intel/ice/virt/queues.c  | 584 ++++++++++++--
 drivers/net/ethernet/intel/ice/virt/rss.c     |  54 +-
 .../net/ethernet/intel/ice/virt/virtchnl.c    |  36 +
 net/devlink/core.c                            |  24 +
 net/devlink/netlink_gen.c                     |   5 +-
 net/devlink/resource.c                        |  84 +-
 44 files changed, 3021 insertions(+), 268 deletions(-)
 create mode 100644 drivers/net/ethernet/intel/ice/devlink/resource.h
 create mode 100644 drivers/net/ethernet/intel/ice/devlink/resource.c

-- 
2.51.1


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH net-next v7 01/15] iavf: keep RSS config across resets
  2026-11-21 22:55 [PATCH net-next v7 00/15] devlink, mlx5, iavf, ice: XLVF for iavf Przemek Kitszel
@ 2026-11-21 22:55 ` Przemek Kitszel
  2026-11-24 21:57   ` netdev-bot+sashiko
  2026-11-21 22:55 ` [PATCH net-next v7 02/15] ice: prepare RSS LUT config for runtime LUT changes Przemek Kitszel
                   ` (14 subsequent siblings)
  15 siblings, 1 reply; 28+ messages in thread
From: Przemek Kitszel @ 2026-11-21 22:55 UTC (permalink / raw)
  To: netdev, Jakub Kicinski, Jiri Pirko
  Cc: Tony Nguyen, Aleksandr Loktionov, Michal Schmidt, edumazet, horms,
	pabeni, davem, Jonathan Corbet, skhan, rdunlap, andrew+netdev,
	saeedm, tariqt, leon, mbloch, jacob.e.keller, jedrzej.jagielski,
	anzaki, brett.creeley, ohartoov, Petr Oros, Donald Hunter,
	Przemek Kitszel

The RSS key and the LUT set by the user are overwritten with the
defaults on every reset. Keep both. The LUT is replaced only when it
uses queues the VF no longer has, or when it can't be resized to a new
LUT size. ethtool_rxfh_indir_lost() needs rtnl, so it is called from
iavf_finish_config().

PF may report a different RSS key or LUT size after a reset (ice will,
once its VF RSS LUT can be changed via devlink), or stop offering
VIRTCHNL_VF_OFFLOAD_RSS_PF, which means the default sizes. Reallocate
both then, keep the key unless its size changed, and fold or unfold the
LUT set by the user with ethtool_rxfh_indir_resize(). When PF gives the
VF fewer queue pairs than it has in use (PF has lowered its limit on
reset), reinit queues and MSI-X with that count.

Keep the RSS buffers on reinit after iavf_disable_vf(), they leaked.

Zero adapter->vf_res on a failed VF resources message, as
iavf_disable_vf() does, instead of freeing it, ethtool ops use it while
init retries with the netdev registered. Skip the rest of the
VIRTCHNL_OP_GET_VF_RESOURCES reply handling when
iavf_parse_vf_resource_msg() fails. It schedules a reset that redoes it,
except when the reply has no LAN VSI.

Reset aq_wait_count when init starts over after the PF stopped
responding. It was never reset, so once it reached IAVF_AQ_MAX_ERR, the
first wait for a PF reply sent init back to __IAVF_COMM_FAILED.

Most of these issues are old and affect every PF, but are rarely hit.
The rest of this series makes them common: the VF is reset on each
change of its RSS LUT via devlink, and on init, after iavf asks the PF
for more queues and waits for them in __IAVF_INIT_FAILED. Hence fix
them first.

Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
---
v7:
 * new patch, split out of "iavf: use new opcodes to request more than
   16 queues", as it applies to every PF (Jakub)
 * keep the RSS key and the LUT set by the user across resets, and fold
   or unfold the LUT with ethtool_rxfh_indir_resize() when the LUT size
   changes, instead of filling both with the defaults; when the LUT
   can't be kept, call ethtool_rxfh_indir_lost() from
   iavf_finish_config(), under rtnl (Jakub)
 * keep the RSS buffers on reinit after iavf_disable_vf(), they leaked
   (me)
---
 drivers/net/ethernet/intel/iavf/iavf.h        |   1 +
 .../net/ethernet/intel/iavf/iavf_ethtool.c    |   1 +
 drivers/net/ethernet/intel/iavf/iavf_main.c   | 141 +++++++++++++++---
 .../net/ethernet/intel/iavf/iavf_virtchnl.c   |   3 +-
 4 files changed, 128 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ethernet/intel/iavf/iavf.h b/drivers/net/ethernet/intel/iavf/iavf.h
index 8c45536fd502..d174202bcd79 100644
--- a/drivers/net/ethernet/intel/iavf/iavf.h
+++ b/drivers/net/ethernet/intel/iavf/iavf.h
@@ -294,6 +294,7 @@ struct iavf_adapter {
 #define IAVF_FLAG_SETUP_NETDEV_FEATURES		BIT(18)
 #define IAVF_FLAG_REINIT_MSIX_NEEDED		BIT(20)
 #define IAVF_FLAG_FDIR_ENABLED			BIT(21)
+#define IAVF_FLAG_RSS_LUT_LOST			BIT(22)
 /* duplicates for common code */
 #define IAVF_FLAG_DCB_ENABLED			0
 	/* flags for admin queue service task */
diff --git a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
index e7cf12eaa268..b76622fa9661 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
@@ -1846,6 +1846,7 @@ static int iavf_set_rxfh(struct net_device *netdev,
 		/* Each 32 bits pointed by 'indir' is stored with a lut entry */
 		for (i = 0; i < adapter->rss_lut_size; i++)
 			adapter->rss_lut[i] = (u8)(rxfh->indir[i]);
+		adapter->flags &= ~IAVF_FLAG_RSS_LUT_LOST;
 	}
 
 	return iavf_config_rss(adapter);
diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
index 4de3ea8525b3..c7b12de63c2f 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
@@ -1769,16 +1769,67 @@ int iavf_config_rss(struct iavf_adapter *adapter)
 	}
 }
 
+static bool iavf_rss_lut_is_user(struct iavf_adapter *adapter)
+{
+	return netif_is_rxfh_configured(adapter->netdev) &&
+	       !(adapter->flags & IAVF_FLAG_RSS_LUT_LOST);
+}
+
+static void iavf_rss_lut_lost(struct iavf_adapter *adapter)
+{
+	adapter->flags |= IAVF_FLAG_RSS_LUT_LOST;
+	iavf_schedule_finish_config(adapter);
+}
+
+static int iavf_rss_lut_resize(struct iavf_adapter *adapter, u8 *lut, u16 size)
+{
+	struct net_device *netdev = adapter->netdev;
+	int old_size = adapter->rss_lut_size;
+	u32 *indir;
+
+	if (!iavf_rss_lut_is_user(adapter))
+		return 0;
+
+	indir = kmalloc_objs(*indir, max(old_size, size));
+	if (!indir)
+		return -ENOMEM;
+
+	for (int i = 0; i < old_size; i++)
+		indir[i] = adapter->rss_lut[i];
+	if (ethtool_rxfh_indir_can_resize(netdev, indir, old_size, size)) {
+		ethtool_rxfh_indir_resize(netdev, indir, old_size, size);
+		for (int i = 0; i < size; i++)
+			lut[i] = indir[i];
+	} else {
+		iavf_rss_lut_lost(adapter);
+	}
+
+	kfree(indir);
+	return 0;
+}
+
 /**
  * iavf_fill_rss_lut - Fill the lut with default values
  * @adapter: board private structure
+ *
+ * Keep the lut set by the user, unless it uses a queue out of range.
  **/
 static void iavf_fill_rss_lut(struct iavf_adapter *adapter)
 {
-	u16 i;
+	int max = adapter->num_active_queues;
 
-	for (i = 0; i < adapter->rss_lut_size; i++)
-		adapter->rss_lut[i] = i % adapter->num_active_queues;
+	if (iavf_rss_lut_is_user(adapter)) {
+		int max_q = 0;
+
+		for (int i = 0; i < adapter->rss_lut_size; i++)
+			max_q = max(max_q, adapter->rss_lut[i]);
+		if (max_q < max)
+			return;
+		iavf_rss_lut_lost(adapter);
+	}
+
+	for (int i = 0; i < adapter->rss_lut_size; i++)
+		adapter->rss_lut[i] = i % max;
 }
 
 /**
@@ -1805,7 +1856,6 @@ static int iavf_init_rss(struct iavf_adapter *adapter)
 	}
 
 	iavf_fill_rss_lut(adapter);
-	netdev_rss_key_fill((void *)adapter->rss_key, adapter->rss_key_size);
 
 	return iavf_config_rss(adapter);
 }
@@ -2014,6 +2064,12 @@ static void iavf_finish_config(struct work_struct *work)
 	rtnl_lock();
 	netdev_lock(adapter->netdev);
 
+	if (adapter->flags & IAVF_FLAG_RSS_LUT_LOST) {
+		adapter->flags &= ~IAVF_FLAG_RSS_LUT_LOST;
+		if (netif_is_rxfh_configured(adapter->netdev))
+			ethtool_rxfh_indir_lost(adapter->netdev);
+	}
+
 	if ((adapter->flags & IAVF_FLAG_SETUP_NETDEV_FEATURES) &&
 	    adapter->netdev->reg_state == NETREG_REGISTERED &&
 	    !test_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section)) {
@@ -2459,16 +2515,19 @@ static void iavf_init_version_check(struct iavf_adapter *adapter)
 int iavf_parse_vf_resource_msg(struct iavf_adapter *adapter)
 {
 	int i, num_req_queues = adapter->num_req_queues;
+	struct virtchnl_vsi_resource *vsi_res = NULL;
 	struct iavf_vsi *vsi = &adapter->vsi;
+	u32 key_size, lut_size;
 
 	for (i = 0; i < adapter->vf_res->num_vsis; i++) {
 		if (adapter->vf_res->vsi_res[i].vsi_type == VIRTCHNL_VSI_SRIOV)
-			adapter->vsi_res = &adapter->vf_res->vsi_res[i];
+			vsi_res = &adapter->vf_res->vsi_res[i];
 	}
-	if (!adapter->vsi_res) {
+	if (!vsi_res) {
 		dev_err(&adapter->pdev->dev, "No LAN VSI found\n");
 		return -ENODEV;
 	}
+	adapter->vsi_res = vsi_res;
 
 	if (num_req_queues &&
 	    num_req_queues > adapter->vsi_res->num_queue_pairs) {
@@ -2486,19 +2545,62 @@ int iavf_parse_vf_resource_msg(struct iavf_adapter *adapter)
 
 		return -EAGAIN;
 	}
+	/* PF could cut our queues on reset, e.g. when RSS LUT got smaller */
+	if (adapter->state != __IAVF_INIT_GET_RESOURCES &&
+	    adapter->num_active_queues > adapter->vsi_res->num_queue_pairs) {
+		adapter->flags |= IAVF_FLAG_REINIT_MSIX_NEEDED;
+		adapter->num_req_queues = adapter->vsi_res->num_queue_pairs;
+		iavf_schedule_reset(adapter, IAVF_FLAG_RESET_NEEDED);
+
+		return -EAGAIN;
+	}
 	adapter->num_req_queues = 0;
 	adapter->vsi.id = adapter->vsi_res->vsi_id;
 
 	adapter->vsi.back = adapter;
 	adapter->vsi.base_vector = 1;
 	vsi->netdev = adapter->netdev;
 	vsi->qs_handle = adapter->vsi_res->qset_handle;
 	if (adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RSS_PF) {
-		adapter->rss_key_size = adapter->vf_res->rss_key_size;
-		adapter->rss_lut_size = adapter->vf_res->rss_lut_size;
+		key_size = adapter->vf_res->rss_key_size;
+		lut_size = adapter->vf_res->rss_lut_size;
+	} else {
+		key_size = IAVF_HKEY_ARRAY_SIZE;
+		lut_size = IAVF_HLUT_ARRAY_SIZE;
+	}
+
+	if ((adapter->rss_key && adapter->rss_key_size != key_size) ||
+	    (adapter->rss_lut && adapter->rss_lut_size != lut_size)) {
+		u8 *rss_key, *rss_lut;
+
+		rss_key = kzalloc(key_size, GFP_KERNEL);
+		rss_lut = kzalloc(lut_size, GFP_KERNEL);
+		if (!rss_lut || !rss_key ||
+		    iavf_rss_lut_resize(adapter, rss_lut, lut_size)) {
+			kfree(rss_key);
+			kfree(rss_lut);
+			/* old buffers and sizes are kept, retry via reset */
+			iavf_schedule_reset(adapter, IAVF_FLAG_RESET_NEEDED);
+			return -ENOMEM;
+		}
+
+		if (adapter->rss_key_size == key_size)
+			memcpy(rss_key, adapter->rss_key, key_size);
+		else
+			netdev_rss_key_fill(rss_key, key_size);
+
+		kfree(adapter->rss_key);
+		kfree(adapter->rss_lut);
+		adapter->rss_key = rss_key;
+		adapter->rss_lut = rss_lut;
+		adapter->rss_key_size = key_size;
+		adapter->rss_lut_size = lut_size;
+		/* no queues yet on init, iavf_init_config_adapter() sets RSS */
+		if (adapter->state != __IAVF_INIT_GET_RESOURCES)
+			iavf_init_rss(adapter);
 	} else {
-		adapter->rss_key_size = IAVF_HKEY_ARRAY_SIZE;
-		adapter->rss_lut_size = IAVF_HLUT_ARRAY_SIZE;
+		adapter->rss_key_size = key_size;
+		adapter->rss_lut_size = lut_size;
 	}
 
 	return 0;
@@ -2563,8 +2665,8 @@ static void iavf_init_get_resources(struct iavf_adapter *adapter)
 	return;
 
 err_alloc:
-	kfree(adapter->vf_res);
-	adapter->vf_res = NULL;
+	/* keep it allocated, ethtool ops may run on reinit */
+	memset(adapter->vf_res, 0, IAVF_VIRTCHNL_VF_RESOURCE_SIZE);
 err:
 	iavf_change_state(adapter, __IAVF_INIT_FAILED);
 }
@@ -2862,11 +2964,15 @@ static void iavf_init_config_adapter(struct iavf_adapter *adapter)
 	iavf_misc_irq_enable(adapter);
 	wake_up(&adapter->down_waitqueue);
 
-	adapter->rss_key = kzalloc(adapter->rss_key_size, GFP_KERNEL);
-	adapter->rss_lut = kzalloc(adapter->rss_lut_size, GFP_KERNEL);
-	if (!adapter->rss_key || !adapter->rss_lut) {
-		err = -ENOMEM;
-		goto err_mem;
+	/* kept on reinit after iavf_disable_vf() */
+	if (!adapter->rss_lut) {
+		adapter->rss_key = kzalloc(adapter->rss_key_size, GFP_KERNEL);
+		adapter->rss_lut = kzalloc(adapter->rss_lut_size, GFP_KERNEL);
+		if (!adapter->rss_key || !adapter->rss_lut) {
+			err = -ENOMEM;
+			goto err_mem;
+		}
+		netdev_rss_key_fill(adapter->rss_key, adapter->rss_key_size);
 	}
 	if (RSS_AQ(adapter))
 		adapter->aq_required |= IAVF_FLAG_AQ_CONFIGURE_RSS;
@@ -2967,6 +3073,7 @@ static int iavf_watchdog_step(struct iavf_adapter *adapter)
 			 */
 			iavf_change_state(adapter, __IAVF_STARTUP);
 			adapter->flags &= ~IAVF_FLAG_PF_COMMS_FAILED;
+			adapter->aq_wait_count = 0;
 		}
 		adapter->aq_required = 0;
 		adapter->current_op = VIRTCHNL_OP_UNKNOWN;
diff --git a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
index e6b7e8f82c7c..5578525d550e 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
@@ -2622,7 +2622,8 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,
 
 		iavf_activate_fdir_filters(adapter);
 
-		iavf_parse_vf_resource_msg(adapter);
+		if (iavf_parse_vf_resource_msg(adapter))
+			break;
 
 		/* negotiated VIRTCHNL_VF_OFFLOAD_VLAN_V2, so wait for the
 		 * response to VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS to finish
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH net-next v7 02/15] ice: prepare RSS LUT config for runtime LUT changes
  2026-11-21 22:55 [PATCH net-next v7 00/15] devlink, mlx5, iavf, ice: XLVF for iavf Przemek Kitszel
  2026-11-21 22:55 ` [PATCH net-next v7 01/15] iavf: keep RSS config across resets Przemek Kitszel
@ 2026-11-21 22:55 ` Przemek Kitszel
  2026-11-24 21:57   ` netdev-bot+sashiko
  2026-11-21 22:55 ` [PATCH net-next v7 03/15] ice: add VF queue ena/dis helper functions Przemek Kitszel
                   ` (13 subsequent siblings)
  15 siblings, 1 reply; 28+ messages in thread
From: Przemek Kitszel @ 2026-11-21 22:55 UTC (permalink / raw)
  To: netdev, Jakub Kicinski, Jiri Pirko
  Cc: Tony Nguyen, Aleksandr Loktionov, Michal Schmidt, edumazet, horms,
	pabeni, davem, Jonathan Corbet, skhan, rdunlap, andrew+netdev,
	saeedm, tariqt, leon, mbloch, jacob.e.keller, jedrzej.jagielski,
	anzaki, brett.creeley, ohartoov, Petr Oros, Donald Hunter,
	Przemek Kitszel

The RSS LUT of a VSI can be changed via devlink at runtime, later in
this series. Prepare the RSS LUT config for that.

Add pf->rss_lut_lock, to protect the RSS LUT config of a VSI: the LUT
type and size, the LUT set by the user, and q_opt_rss of the VSI
context, which carries the LUT type. Take it in ethtool RSS ops, in the
RSS LUT setup of a VSI, and around VSI context writes that include
q_opt_rss.

Set the default RSS LUT type and size of a VSI only on its init, so
a VSI rebuild will keep a LUT changed via devlink.

Cap the RSS queue count of a VSI to what its RSS LUT type can address:
16 for a VSI LUT, 64 for a GLOBAL LUT, 256 for a PF LUT. Do it on
ethtool -L, when setting the default LUT, and on each RSS config of the
VSI. VFs and SFs have up to 16 queues yet, so nothing changes for them.

Take the Q_OPT section from vsi->info when toggling the RDMA filter.
The cached VSI context misses later changes, like the RSS hash function
set via ethtool, which the toggle reverted.

Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
---
v7:
 * new patch, split out of "ice: represent RSS LUTs as devlink
   resources" and "ice: support up to 256 VF queues" (Jakub)
---
 drivers/net/ethernet/intel/ice/ice.h         |   1 +
 drivers/net/ethernet/intel/ice/ice_lib.h     |   2 +
 drivers/net/ethernet/intel/ice/ice_switch.h  |   3 +-
 drivers/net/ethernet/intel/ice/ice_ethtool.c |  90 ++++++++-------
 drivers/net/ethernet/intel/ice/ice_idc.c     |  24 ++--
 drivers/net/ethernet/intel/ice/ice_lib.c     | 112 ++++++++++++++-----
 drivers/net/ethernet/intel/ice/ice_main.c    |   2 +
 drivers/net/ethernet/intel/ice/ice_switch.c  |  11 +-
 8 files changed, 161 insertions(+), 84 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h
index 432da05c48c0..f614b9360f7b 100644
--- a/drivers/net/ethernet/intel/ice/ice.h
+++ b/drivers/net/ethernet/intel/ice/ice.h
@@ -595,6 +595,7 @@ struct ice_pf {
 	struct mutex tc_mutex;		/* lock to protect TC changes */
 	struct mutex adev_mutex;	/* lock to protect aux device access */
 	struct mutex lag_mutex;		/* protect ice_lag struct in PF */
+	struct mutex rss_lut_lock;	/* protect VSI RSS LUT config */
 	u32 msg_enable;
 	struct ice_ptp ptp;
 	struct gnss_serial *gnss_serial;
diff --git a/drivers/net/ethernet/intel/ice/ice_lib.h b/drivers/net/ethernet/intel/ice/ice_lib.h
index 49454d98dcfe..e0d3ae067f35 100644
--- a/drivers/net/ethernet/intel/ice/ice_lib.h
+++ b/drivers/net/ethernet/intel/ice/ice_lib.h
@@ -18,6 +18,8 @@ enum ice_l2tsel {
 	ICE_L2TSEL_EXTRACT_FIRST_TAG_L2TAG1,
 };
 
+u16 ice_lut_type_to_qs_num(enum ice_lut_type lut_type);
+
 const char *ice_vsi_type_str(enum ice_vsi_type vsi_type);
 
 bool ice_pf_state_is_nominal(struct ice_pf *pf);
diff --git a/drivers/net/ethernet/intel/ice/ice_switch.h b/drivers/net/ethernet/intel/ice/ice_switch.h
index 671d7a5f359f..0d1ef9cd0535 100644
--- a/drivers/net/ethernet/intel/ice/ice_switch.h
+++ b/drivers/net/ethernet/intel/ice/ice_switch.h
@@ -361,7 +361,8 @@ int ice_remove_mac(struct ice_hw *hw, struct list_head *m_lst);
 bool ice_vlan_fltr_exist(struct ice_hw *hw, u16 vlan_id, u16 vsi_handle);
 int ice_add_eth_mac(struct ice_hw *hw, struct list_head *em_list);
 int ice_remove_eth_mac(struct ice_hw *hw, struct list_head *em_list);
-int ice_cfg_rdma_fltr(struct ice_hw *hw, u16 vsi_handle, bool enable);
+int ice_cfg_rdma_fltr(struct ice_hw *hw, u16 vsi_handle,
+		      const struct ice_aqc_vsi_props *info, bool enable);
 void ice_remove_vsi_fltr(struct ice_hw *hw, u16 vsi_handle);
 
 /* Promisc/defport setup for VSIs */
diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c
index dffa213734f1..6d1e506b69cd 100644
--- a/drivers/net/ethernet/intel/ice/ice_ethtool.c
+++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c
@@ -3645,11 +3645,13 @@ ice_get_rxfh(struct net_device *netdev, struct ethtool_rxfh_param *rxfh)
 	if (!rxfh->indir)
 		return 0;
 
-	lut = kzalloc(vsi->rss_table_size, GFP_KERNEL);
-	if (!lut)
-		return -ENOMEM;
+	scoped_guard(mutex, &pf->rss_lut_lock) {
+		lut = kzalloc(vsi->rss_table_size, GFP_KERNEL);
+		if (!lut)
+			return -ENOMEM;
 
-	err = ice_get_rss(vsi, rxfh->key, lut, vsi->rss_table_size);
+		err = ice_get_rss(vsi, rxfh->key, lut, vsi->rss_table_size);
+	}
 	if (err)
 		goto out;
 
@@ -3707,7 +3709,8 @@ ice_set_rxfh(struct net_device *netdev, struct ethtool_rxfh_param *rxfh,
 	if (rxfh->input_xfrm & RXH_XFRM_SYM_XOR)
 		hfunc = ICE_AQ_VSI_Q_OPT_RSS_HASH_SYM_TPLZ;
 
-	err = ice_set_rss_hfunc(vsi, hfunc);
+	scoped_guard(mutex, &pf->rss_lut_lock)
+		err = ice_set_rss_hfunc(vsi, hfunc);
 	if (err)
 		return err;
 
@@ -3727,29 +3730,31 @@ ice_set_rxfh(struct net_device *netdev, struct ethtool_rxfh_param *rxfh,
 			return err;
 	}
 
-	if (!vsi->rss_lut_user) {
-		vsi->rss_lut_user = devm_kzalloc(dev, vsi->rss_table_size,
-						 GFP_KERNEL);
-		if (!vsi->rss_lut_user)
-			return -ENOMEM;
-	}
+	scoped_guard(mutex, &pf->rss_lut_lock) {
+		if (!vsi->rss_lut_user) {
+			vsi->rss_lut_user = devm_kzalloc(dev,
+							 vsi->rss_table_size,
+							 GFP_KERNEL);
+			if (!vsi->rss_lut_user)
+				return -ENOMEM;
+		}
 
-	/* Each 32 bits pointed by 'indir' is stored with a lut entry */
-	if (rxfh->indir) {
-		int i;
+		/* Each 32 bits pointed by 'indir' is stored with a lut entry */
+		if (rxfh->indir) {
+			int i;
 
-		for (i = 0; i < vsi->rss_table_size; i++)
-			vsi->rss_lut_user[i] = (u8)(rxfh->indir[i]);
-	} else {
-		ice_fill_rss_lut(vsi->rss_lut_user, vsi->rss_table_size,
-				 vsi->rss_size);
-	}
+			for (i = 0; i < vsi->rss_table_size; i++)
+				vsi->rss_lut_user[i] = (u8)(rxfh->indir[i]);
+		} else {
+			ice_fill_rss_lut(vsi->rss_lut_user, vsi->rss_table_size,
+					 vsi->rss_size);
+		}
 
-	err = ice_set_rss_lut(vsi, vsi->rss_lut_user, vsi->rss_table_size);
-	if (err)
-		return err;
+		err = ice_set_rss_lut(vsi, vsi->rss_lut_user,
+				      vsi->rss_table_size);
+	}
 
-	return 0;
+	return err;
 }
 
 static int
@@ -3825,14 +3830,15 @@ ice_get_channels(struct net_device *dev, struct ethtool_channels *ch)
 
 /**
  * ice_get_valid_rss_size - return valid number of RSS queues
- * @hw: pointer to the HW structure
+ * @vsi: VSI to get the RSS LUT type of
  * @new_size: requested RSS queues
  */
-static int ice_get_valid_rss_size(struct ice_hw *hw, int new_size)
+static int ice_get_valid_rss_size(struct ice_vsi *vsi, int new_size)
 {
-	struct ice_hw_common_caps *caps = &hw->func_caps.common_cap;
+	struct ice_hw_common_caps *caps = &vsi->back->hw.func_caps.common_cap;
 
-	return min_t(int, new_size, BIT(caps->rss_table_entry_width));
+	new_size = min_t(int, new_size, BIT(caps->rss_table_entry_width));
+	return min_t(int, new_size, ice_lut_type_to_qs_num(vsi->rss_lut_type));
 }
 
 /**
@@ -3856,19 +3862,22 @@ static int ice_vsi_set_dflt_rss_lut(struct ice_vsi *vsi, int req_rss_size)
 	if (!req_rss_size)
 		return -EINVAL;
 
-	lut = kzalloc(vsi->rss_table_size, GFP_KERNEL);
-	if (!lut)
-		return -ENOMEM;
+	scoped_guard(mutex, &pf->rss_lut_lock) {
+		lut = kzalloc(vsi->rss_table_size, GFP_KERNEL);
+		if (!lut)
+			return -ENOMEM;
 
-	/* set RSS LUT parameters */
-	if (!test_bit(ICE_FLAG_RSS_ENA, pf->flags))
-		vsi->rss_size = 1;
-	else
-		vsi->rss_size = ice_get_valid_rss_size(hw, req_rss_size);
+		/* set RSS LUT parameters */
+		if (!test_bit(ICE_FLAG_RSS_ENA, pf->flags))
+			vsi->rss_size = 1;
+		else
+			vsi->rss_size = ice_get_valid_rss_size(vsi,
+							       req_rss_size);
 
-	/* create/set RSS LUT */
-	ice_fill_rss_lut(lut, vsi->rss_table_size, vsi->rss_size);
-	err = ice_set_rss_lut(vsi, lut, vsi->rss_table_size);
+		/* create/set RSS LUT */
+		ice_fill_rss_lut(lut, vsi->rss_table_size, vsi->rss_size);
+		err = ice_set_rss_lut(vsi, lut, vsi->rss_table_size);
+	}
 	if (err)
 		dev_err(dev, "Cannot set RSS lut, err %d aq_err %s\n", err,
 			libie_aq_str(hw->adminq.sq_last_status));
@@ -3959,7 +3968,8 @@ static int ice_set_channels(struct net_device *dev, struct ethtool_channels *ch)
 	}
 
 	/* Update rss_size due to change in Rx queues */
-	vsi->rss_size = ice_get_valid_rss_size(&pf->hw, new_rx);
+	scoped_guard(mutex, &pf->rss_lut_lock)
+		vsi->rss_size = ice_get_valid_rss_size(vsi, new_rx);
 
 adev_unlock:
 	if (locked) {
diff --git a/drivers/net/ethernet/intel/ice/ice_idc.c b/drivers/net/ethernet/intel/ice/ice_idc.c
index 102d63c3018b..3827d7b490aa 100644
--- a/drivers/net/ethernet/intel/ice/ice_idc.c
+++ b/drivers/net/ethernet/intel/ice/ice_idc.c
@@ -207,15 +207,21 @@ int ice_rdma_update_vsi_filter(struct iidc_rdma_core_dev_info *cdev,
 	if (!vsi)
 		return -EINVAL;
 
-	status = ice_cfg_rdma_fltr(&pf->hw, vsi->idx, enable);
-	if (status) {
-		dev_err(ice_pf_to_dev(pf), "Failed to  %sable RDMA filtering\n",
-			enable ? "en" : "dis");
-	} else {
-		if (enable)
-			vsi->info.q_opt_flags |= ICE_AQ_VSI_Q_OPT_PE_FLTR_EN;
-		else
-			vsi->info.q_opt_flags &= ~ICE_AQ_VSI_Q_OPT_PE_FLTR_EN;
+	scoped_guard(mutex, &pf->rss_lut_lock) {
+		status = ice_cfg_rdma_fltr(&pf->hw, vsi->idx, &vsi->info,
+					   enable);
+		if (status) {
+			dev_err(ice_pf_to_dev(pf),
+				"Failed to  %sable RDMA filtering\n",
+				enable ? "en" : "dis");
+		} else {
+			if (enable)
+				vsi->info.q_opt_flags |=
+					ICE_AQ_VSI_Q_OPT_PE_FLTR_EN;
+			else
+				vsi->info.q_opt_flags &=
+					~ICE_AQ_VSI_Q_OPT_PE_FLTR_EN;
+		}
 	}
 
 	return status;
diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
index 977cd8dd6e31..bd59c0a12215 100644
--- a/drivers/net/ethernet/intel/ice/ice_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_lib.c
@@ -10,6 +10,23 @@
 #include "ice_type.h"
 #include "ice_vsi_vlan_ops.h"
 
+#define ICE_LUT_VSI_MAX_QS	16
+#define ICE_LUT_GLOBAL_MAX_QS	64
+#define ICE_LUT_PF_MAX_QS	256
+
+u16 ice_lut_type_to_qs_num(enum ice_lut_type lut_type)
+{
+	switch (lut_type) {
+	case ICE_LUT_PF:
+		return ICE_LUT_PF_MAX_QS;
+	case ICE_LUT_GLOBAL:
+		return ICE_LUT_GLOBAL_MAX_QS;
+	case ICE_LUT_VSI:
+	default:
+		return ICE_LUT_VSI_MAX_QS;
+	}
+}
+
 /**
  * ice_vsi_type_str - maps VSI type enum to string equivalents
  * @vsi_type: VSI type enum
@@ -982,6 +999,37 @@ static void ice_rss_clean(struct ice_vsi *vsi)
 		ice_rem_vsi_rss_list(&pf->hw, vsi->idx);
 }
 
+/**
+ * ice_vsi_set_dflt_rss_lut_type - Setup default RSS LUT per VSI type
+ * @vsi: the VSI being configured
+ */
+static void ice_vsi_set_dflt_rss_lut_type(struct ice_vsi *vsi)
+{
+	struct ice_hw_common_caps *cap = &vsi->back->hw.func_caps.common_cap;
+
+	if (!test_bit(ICE_FLAG_RSS_ENA, vsi->back->flags))
+		return;
+
+	switch (vsi->type) {
+	case ICE_VSI_CHNL:
+	case ICE_VSI_PF:
+		/* PF VSI will inherit RSS instance of PF */
+		vsi->rss_table_size = (u16)cap->rss_table_size;
+		vsi->rss_lut_type = ICE_LUT_PF;
+		break;
+	case ICE_VSI_SF:
+	case ICE_VSI_VF:
+		/* VF and SF VSIs will get a small RSS table.
+		 * For VSI_LUT, LUT size should be set to 64 bytes.
+		 */
+		vsi->rss_table_size = ICE_LUT_VSI_SIZE;
+		vsi->rss_lut_type = ICE_LUT_VSI;
+		break;
+	default:
+		break;
+	}
+}
+
 /**
  * ice_vsi_set_rss_params - Setup RSS capabilities per VSI type
  * @vsi: the VSI being configured
@@ -1002,29 +1050,19 @@ static void ice_vsi_set_rss_params(struct ice_vsi *vsi)
 	switch (vsi->type) {
 	case ICE_VSI_CHNL:
 	case ICE_VSI_PF:
-		/* PF VSI will inherit RSS instance of PF */
-		vsi->rss_table_size = (u16)cap->rss_table_size;
 		if (vsi->type == ICE_VSI_CHNL)
 			vsi->rss_size = min_t(u16, vsi->num_rxq, max_rss_size);
 		else
 			vsi->rss_size = min_t(u16,
 					      netif_get_num_default_rss_queues(),
 					      max_rss_size);
-		vsi->rss_lut_type = ICE_LUT_PF;
 		break;
 	case ICE_VSI_SF:
-		vsi->rss_table_size = ICE_LUT_VSI_SIZE;
 		vsi->rss_size = min_t(u16, netif_get_num_default_rss_queues(),
 				      max_rss_size);
-		vsi->rss_lut_type = ICE_LUT_VSI;
 		break;
 	case ICE_VSI_VF:
-		/* VF VSI will get a small RSS table.
-		 * For VSI_LUT, LUT size should be set to 64 bytes.
-		 */
-		vsi->rss_table_size = ICE_LUT_VSI_SIZE;
 		vsi->rss_size = ICE_MAX_RSS_QS_PER_VF;
-		vsi->rss_lut_type = ICE_LUT_VSI;
 		break;
 	case ICE_VSI_LB:
 		break;
@@ -1558,19 +1596,22 @@ void ice_vsi_manage_rss_lut(struct ice_vsi *vsi, bool ena)
 {
 	u8 *lut;
 
-	lut = kzalloc(vsi->rss_table_size, GFP_KERNEL);
-	if (!lut)
-		return;
+	scoped_guard(mutex, &vsi->back->rss_lut_lock) {
+		lut = kzalloc(vsi->rss_table_size, GFP_KERNEL);
+		if (!lut)
+			return;
 
-	if (ena) {
-		if (vsi->rss_lut_user)
-			memcpy(lut, vsi->rss_lut_user, vsi->rss_table_size);
-		else
-			ice_fill_rss_lut(lut, vsi->rss_table_size,
-					 vsi->rss_size);
-	}
+		if (ena) {
+			if (vsi->rss_lut_user)
+				memcpy(lut, vsi->rss_lut_user,
+				       vsi->rss_table_size);
+			else
+				ice_fill_rss_lut(lut, vsi->rss_table_size,
+						 vsi->rss_size);
+		}
 
-	ice_set_rss_lut(vsi, lut, vsi->rss_table_size);
+		ice_set_rss_lut(vsi, lut, vsi->rss_table_size);
+	}
 	kfree(lut);
 }
 
@@ -1622,16 +1663,21 @@ int ice_vsi_cfg_rss_lut_key(struct ice_vsi *vsi)
 		}
 	}
 
-	lut = kzalloc(vsi->rss_table_size, GFP_KERNEL);
-	if (!lut)
-		return -ENOMEM;
+	scoped_guard(mutex, &pf->rss_lut_lock) {
+		vsi->rss_size = min(vsi->rss_size,
+				    ice_lut_type_to_qs_num(vsi->rss_lut_type));
+		lut = kzalloc(vsi->rss_table_size, GFP_KERNEL);
+		if (!lut)
+			return -ENOMEM;
 
-	if (vsi->rss_lut_user)
-		memcpy(lut, vsi->rss_lut_user, vsi->rss_table_size);
-	else
-		ice_fill_rss_lut(lut, vsi->rss_table_size, vsi->rss_size);
+		if (vsi->rss_lut_user)
+			memcpy(lut, vsi->rss_lut_user, vsi->rss_table_size);
+		else
+			ice_fill_rss_lut(lut, vsi->rss_table_size,
+					 vsi->rss_size);
 
-	err = ice_set_rss_lut(vsi, lut, vsi->rss_table_size);
+		err = ice_set_rss_lut(vsi, lut, vsi->rss_table_size);
+	}
 	if (err) {
 		dev_err(dev, "set_rss_lut failed, error %d\n", err);
 		goto ice_vsi_cfg_rss_exit;
@@ -2404,6 +2450,11 @@ static int ice_vsi_cfg_def(struct ice_vsi *vsi)
 
 	vsi->vsw = pf->first_sw;
 
+	if (vsi->flags & ICE_VSI_FLAG_INIT) {
+		scoped_guard(mutex, &pf->rss_lut_lock)
+			ice_vsi_set_dflt_rss_lut_type(vsi);
+	}
+
 	ret = ice_vsi_alloc_def(vsi, vsi->ch);
 	if (ret)
 		return ret;
@@ -2429,7 +2480,8 @@ static int ice_vsi_cfg_def(struct ice_vsi *vsi)
 	ice_vsi_set_tc_cfg(vsi);
 
 	/* create the VSI */
-	ret = ice_vsi_init(vsi, vsi->flags);
+	scoped_guard(mutex, &pf->rss_lut_lock)
+		ret = ice_vsi_init(vsi, vsi->flags);
 	if (ret)
 		goto unroll_get_qs;
 
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index c8f06c3d0fdf..0bc53f404957 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -3873,6 +3873,7 @@ void ice_deinit_pf(struct ice_pf *pf)
 {
 	/* note that we unroll also on ice_init_pf() failure here */
 
+	mutex_destroy(&pf->rss_lut_lock);
 	mutex_destroy(&pf->lag_mutex);
 	mutex_destroy(&pf->adev_mutex);
 	mutex_destroy(&pf->sw_mutex);
@@ -3978,6 +3979,7 @@ int ice_init_pf(struct ice_pf *pf)
 	mutex_init(&pf->tc_mutex);
 	mutex_init(&pf->adev_mutex);
 	mutex_init(&pf->lag_mutex);
+	mutex_init(&pf->rss_lut_lock);
 
 	INIT_HLIST_HEAD(&pf->aq_wait_list);
 	spin_lock_init(&pf->aq_wait_lock);
diff --git a/drivers/net/ethernet/intel/ice/ice_switch.c b/drivers/net/ethernet/intel/ice/ice_switch.c
index d873eda9af82..70eed3bcc404 100644
--- a/drivers/net/ethernet/intel/ice/ice_switch.c
+++ b/drivers/net/ethernet/intel/ice/ice_switch.c
@@ -1834,10 +1834,12 @@ ice_update_vsi(struct ice_hw *hw, u16 vsi_handle, struct ice_vsi_ctx *vsi_ctx,
  * ice_cfg_rdma_fltr - enable/disable RDMA filtering on VSI
  * @hw: pointer to HW struct
  * @vsi_handle: VSI SW index
+ * @info: current VSI properties, the rest of the Q_OPT section is kept
  * @enable: boolean for enable/disable
  */
 int
-ice_cfg_rdma_fltr(struct ice_hw *hw, u16 vsi_handle, bool enable)
+ice_cfg_rdma_fltr(struct ice_hw *hw, u16 vsi_handle,
+		  const struct ice_aqc_vsi_props *info, bool enable)
 {
 	struct ice_vsi_ctx *ctx, *cached_ctx;
 	int status;
@@ -1850,9 +1852,10 @@ ice_cfg_rdma_fltr(struct ice_hw *hw, u16 vsi_handle, bool enable)
 	if (!ctx)
 		return -ENOMEM;
 
-	ctx->info.q_opt_rss = cached_ctx->info.q_opt_rss;
-	ctx->info.q_opt_tc = cached_ctx->info.q_opt_tc;
-	ctx->info.q_opt_flags = cached_ctx->info.q_opt_flags;
+	/* not from the cached ctx, that misses later RSS changes */
+	ctx->info.q_opt_rss = info->q_opt_rss;
+	ctx->info.q_opt_tc = info->q_opt_tc;
+	ctx->info.q_opt_flags = info->q_opt_flags;
 
 	ctx->info.valid_sections = cpu_to_le16(ICE_AQ_VSI_PROP_Q_OPT_VALID);
 
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH net-next v7 03/15] ice: add VF queue ena/dis helper functions
  2026-11-21 22:55 [PATCH net-next v7 00/15] devlink, mlx5, iavf, ice: XLVF for iavf Przemek Kitszel
  2026-11-21 22:55 ` [PATCH net-next v7 01/15] iavf: keep RSS config across resets Przemek Kitszel
  2026-11-21 22:55 ` [PATCH net-next v7 02/15] ice: prepare RSS LUT config for runtime LUT changes Przemek Kitszel
@ 2026-11-21 22:55 ` Przemek Kitszel
  2026-11-21 22:55 ` [PATCH net-next v7 04/15] ice: add helpers for Global RSS LUT alloc, free, vsi_update Przemek Kitszel
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 28+ messages in thread
From: Przemek Kitszel @ 2026-11-21 22:55 UTC (permalink / raw)
  To: netdev, Jakub Kicinski, Jiri Pirko
  Cc: Tony Nguyen, Aleksandr Loktionov, Michal Schmidt, edumazet, horms,
	pabeni, davem, Jonathan Corbet, skhan, rdunlap, andrew+netdev,
	saeedm, tariqt, leon, mbloch, jacob.e.keller, jedrzej.jagielski,
	anzaki, brett.creeley, ohartoov, Petr Oros, Donald Hunter,
	Przemek Kitszel, Wojciech Drewek

From: Brett Creeley <brett.creeley@intel.com>

Add three new functions:
- ice_vf_vsi_dis_single_rxq()
- ice_vf_vsi_ena_single_rxq()
- ice_vf_vsi_ena_single_txq()
 (ice_vf_vsi_dis_single_txq() was introduced earlier).

Those functions wrap operations needed in the processes of enabling
and disabling single Tx/Rx VF queue, which are:
- check if the queue is not already in desired state
- perform the dis/ena operations
- bookkeeping of the queue's state.

Future commit will use them from another callsite.

Signed-off-by: Brett Creeley <brett.creeley@intel.com>
Signed-off-by: Wojciech Drewek <wojciech.drewek@intel.com>
Reviewed-by: Jedrzej Jagielski <jedrzej.jagielski@intel.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
---
v2:
 * convert one comment to kdoc (Alex)
 * fix typos (Sashiko)
 * rebase: move ice_vf_dis_rxq_interrupt(), added to ice_vc_dis_qs_msg()
   by commit fb096882095e ("ice: fix VF interrupts cleanup"), into
   ice_vf_vsi_dis_single_rxq()
---
 drivers/net/ethernet/intel/ice/virt/queues.c | 117 ++++++++++++++-----
 1 file changed, 89 insertions(+), 28 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/virt/queues.c b/drivers/net/ethernet/intel/ice/virt/queues.c
index ac7f98479b13..a22780575086 100644
--- a/drivers/net/ethernet/intel/ice/virt/queues.c
+++ b/drivers/net/ethernet/intel/ice/virt/queues.c
@@ -242,6 +242,57 @@ static void ice_vf_dis_rxq_interrupt(struct ice_vsi *vsi, u32 q_idx)
 	ice_flush(hw);
 }
 
+/**
+ * ice_vf_vsi_ena_single_rxq - enable single Rx queue based on relative q_id
+ * @vf: VF to enable queue for
+ * @vsi: VSI for the VF
+ * @q_id: VSI relative (0-based) queue ID
+ *
+ * Enable the Rx queue passed in.
+ *
+ * Return: 0 on success or negative on error.
+ */
+static int ice_vf_vsi_ena_single_rxq(struct ice_vf *vf, struct ice_vsi *vsi,
+				     u16 q_id)
+{
+	int err;
+
+	if (test_bit(q_id, vf->rxq_ena))
+		return 0;
+
+	err = ice_vsi_ctrl_one_rx_ring(vsi, true, q_id, true);
+	if (err) {
+		dev_err(ice_pf_to_dev(vsi->back), "Failed to enable Rx ring %d on VSI %d\n",
+			q_id, vsi->vsi_num);
+		return err;
+	}
+
+	ice_vf_ena_rxq_interrupt(vsi, q_id);
+	set_bit(q_id, vf->rxq_ena);
+
+	return 0;
+}
+
+/**
+ * ice_vf_vsi_ena_single_txq - enable single Tx queue based on relative q_id
+ * @vf: VF to enable queue for
+ * @vsi: VSI for the VF
+ * @q_id: VSI relative (0-based) queue ID
+ *
+ * Enable the Tx queue's interrupt. Note that the Tx queue(s) should have
+ * already been configured/enabled in VIRTCHNL_OP_CONFIG_VSI_QUEUES so this
+ * function only enables the interrupt associated with the q_id.
+ */
+static void ice_vf_vsi_ena_single_txq(struct ice_vf *vf, struct ice_vsi *vsi,
+				      u16 q_id)
+{
+	if (test_bit(q_id, vf->txq_ena))
+		return;
+
+	ice_vf_ena_txq_interrupt(vsi, q_id);
+	set_bit(q_id, vf->txq_ena);
+}
+
 /**
  * ice_vc_ena_qs_msg
  * @vf: pointer to the VF info
@@ -290,34 +341,20 @@ int ice_vc_ena_qs_msg(struct ice_vf *vf, u8 *msg)
 			goto error_param;
 		}
 
-		/* Skip queue if enabled */
-		if (test_bit(vf_q_id, vf->rxq_ena))
-			continue;
-
-		if (ice_vsi_ctrl_one_rx_ring(vsi, true, vf_q_id, true)) {
-			dev_err(ice_pf_to_dev(vsi->back), "Failed to enable Rx ring %d on VSI %d\n",
-				vf_q_id, vsi->vsi_num);
+		if (ice_vf_vsi_ena_single_rxq(vf, vsi, vf_q_id)) {
 			v_ret = VIRTCHNL_STATUS_ERR_PARAM;
 			goto error_param;
 		}
-
-		ice_vf_ena_rxq_interrupt(vsi, vf_q_id);
-		set_bit(vf_q_id, vf->rxq_ena);
 	}
 
 	q_map = vqs->tx_queues;
 	for_each_set_bit(vf_q_id, &q_map, ICE_MAX_RSS_QS_PER_VF) {
 		if (!ice_vc_isvalid_q_id(vsi, vf_q_id)) {
 			v_ret = VIRTCHNL_STATUS_ERR_PARAM;
 			goto error_param;
 		}
 
-		/* Skip queue if enabled */
-		if (test_bit(vf_q_id, vf->txq_ena))
-			continue;
-
-		ice_vf_ena_txq_interrupt(vsi, vf_q_id);
-		set_bit(vf_q_id, vf->txq_ena);
+		ice_vf_vsi_ena_single_txq(vf, vsi, vf_q_id);
 	}
 
 	/* Set flag to indicate that queues are enabled */
@@ -369,6 +406,41 @@ int ice_vf_vsi_dis_single_txq(struct ice_vf *vf, struct ice_vsi *vsi, u16 q_id)
 	return 0;
 }
 
+/**
+ * ice_vf_vsi_dis_single_rxq - disable a Rx queue for VF on relative queue ID
+ * @vf: VF to disable queue for
+ * @vsi: VSI for the VF
+ * @q_id: VSI relative (0-based) queue ID
+ *
+ * Attempt to disable the Rx queue passed in. If the Rx queue was successfully
+ * disabled then clear q_id bit in the enabled queues bitmap.
+ *
+ * Return: 0 when queue was already disabled or disabling succeeded, otherwise
+ *         negative error code.
+ */
+static int ice_vf_vsi_dis_single_rxq(struct ice_vf *vf, struct ice_vsi *vsi,
+				     u16 q_id)
+{
+	int err;
+
+	if (!test_bit(q_id, vf->rxq_ena))
+		return 0;
+
+	err = ice_vsi_ctrl_one_rx_ring(vsi, false, q_id, true);
+	if (err) {
+		dev_err(ice_pf_to_dev(vsi->back), "Failed to stop Rx ring %d on VSI %d\n",
+			q_id, vsi->vsi_num);
+		return err;
+	}
+
+	ice_vf_dis_rxq_interrupt(vsi, q_id);
+
+	/* Clear enabled queues flag */
+	clear_bit(q_id, vf->rxq_ena);
+
+	return 0;
+}
+
 /**
  * ice_vc_dis_qs_msg
  * @vf: pointer to the VF info
@@ -433,21 +505,10 @@ int ice_vc_dis_qs_msg(struct ice_vf *vf, u8 *msg)
 				goto error_param;
 			}
 
-			/* Skip queue if not enabled */
-			if (!test_bit(vf_q_id, vf->rxq_ena))
-				continue;
-
-			if (ice_vsi_ctrl_one_rx_ring(vsi, false, vf_q_id,
-						     true)) {
-				dev_err(ice_pf_to_dev(vsi->back), "Failed to stop Rx ring %d on VSI %d\n",
-					vf_q_id, vsi->vsi_num);
+			if (ice_vf_vsi_dis_single_rxq(vf, vsi, vf_q_id)) {
 				v_ret = VIRTCHNL_STATUS_ERR_PARAM;
 				goto error_param;
 			}
-
-			ice_vf_dis_rxq_interrupt(vsi, vf_q_id);
-			/* Clear enabled queues flag */
-			clear_bit(vf_q_id, vf->rxq_ena);
 		}
 	}
 
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH net-next v7 04/15] ice: add helpers for Global RSS LUT alloc, free, vsi_update
  2026-11-21 22:55 [PATCH net-next v7 00/15] devlink, mlx5, iavf, ice: XLVF for iavf Przemek Kitszel
                   ` (2 preceding siblings ...)
  2026-11-21 22:55 ` [PATCH net-next v7 03/15] ice: add VF queue ena/dis helper functions Przemek Kitszel
@ 2026-11-21 22:55 ` Przemek Kitszel
  2026-11-24 21:57   ` netdev-bot+sashiko
  2026-11-21 22:55 ` [PATCH net-next v7 05/15] ice: rename ICE_MAX_RSS_QS_PER_VF to ICE_MAX_QS_PER_VF_VCV1 Przemek Kitszel
                   ` (11 subsequent siblings)
  15 siblings, 1 reply; 28+ messages in thread
From: Przemek Kitszel @ 2026-11-21 22:55 UTC (permalink / raw)
  To: netdev, Jakub Kicinski, Jiri Pirko
  Cc: Tony Nguyen, Aleksandr Loktionov, Michal Schmidt, edumazet, horms,
	pabeni, davem, Jonathan Corbet, skhan, rdunlap, andrew+netdev,
	saeedm, tariqt, leon, mbloch, jacob.e.keller, jedrzej.jagielski,
	anzaki, brett.creeley, ohartoov, Petr Oros, Donald Hunter,
	Przemek Kitszel

Add AQ commands for RSS Global LUT allocation and free operations.
The new functions are used by subsequent commits.

Add programming code for GLOBAL LUT ID of UPDATE VSI AQ,
do the same for RSS LUT "type", also for PF LUT in case of VF VSI.

Co-developed-by: Brett Creeley <brett.creeley@intel.com>
Signed-off-by: Brett Creeley <brett.creeley@intel.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
---
v2: fix whitespace (Sashiko)
---
 drivers/net/ethernet/intel/ice/ice.h          |  1 +
 .../net/ethernet/intel/ice/ice_adminq_cmd.h   |  1 +
 drivers/net/ethernet/intel/ice/ice_switch.h   |  2 +
 drivers/net/ethernet/intel/ice/ice_lib.c      | 28 +++++++++++--
 drivers/net/ethernet/intel/ice/ice_switch.c   | 41 +++++++++++++++++++
 5 files changed, 69 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h
index f614b9360f7b..d28ff576a342 100644
--- a/drivers/net/ethernet/intel/ice/ice.h
+++ b/drivers/net/ethernet/intel/ice/ice.h
@@ -367,6 +367,7 @@ struct ice_vsi {
 	u8 *rss_hkey_user;	/* User configured hash keys */
 	u8 *rss_lut_user;	/* User configured lookup table entries */
 	u8 rss_lut_type;	/* used to configure Get/Set RSS LUT AQ call */
+	u8 global_lut_id;       /* valid when lut_type == GLOBAL_LUT */
 
 	/* aRFS members only allocated for the PF VSI */
 #define ICE_MAX_ARFS_LIST	1024
diff --git a/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h b/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h
index 42878abac9eb..90c5587642d0 100644
--- a/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h
+++ b/drivers/net/ethernet/intel/ice/ice_adminq_cmd.h
@@ -169,6 +169,7 @@ struct ice_aqc_set_port_params {
 #define ICE_AQC_RES_TYPE_VSI_LIST_PRUNE			0x04
 #define ICE_AQC_RES_TYPE_RECIPE				0x05
 #define ICE_AQC_RES_TYPE_SWID				0x07
+#define ICE_AQC_RES_TYPE_GLOBAL_RSS_HASH		0x20
 #define ICE_AQC_RES_TYPE_FDIR_COUNTER_BLOCK		0x21
 #define ICE_AQC_RES_TYPE_FDIR_GUARANTEED_ENTRIES	0x22
 #define ICE_AQC_RES_TYPE_FDIR_SHARED_ENTRIES		0x23
diff --git a/drivers/net/ethernet/intel/ice/ice_switch.h b/drivers/net/ethernet/intel/ice/ice_switch.h
index 0d1ef9cd0535..991b61b0d26a 100644
--- a/drivers/net/ethernet/intel/ice/ice_switch.h
+++ b/drivers/net/ethernet/intel/ice/ice_switch.h
@@ -388,6 +388,8 @@ ice_rem_adv_rule_by_id(struct ice_hw *hw,
 		       struct ice_rule_query_data *remove_entry);
 
 int ice_init_def_sw_recp(struct ice_hw *hw);
+int ice_alloc_rss_global_lut(struct ice_hw *hw, u16 *global_lut_id);
+int ice_free_rss_global_lut(struct ice_hw *hw, u16 global_lut_id);
 u16 ice_get_hw_vsi_num(struct ice_hw *hw, u16 vsi_handle);
 
 int ice_replay_vsi_all_fltr(struct ice_hw *hw, u16 vsi_handle);
diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
index bd59c0a12215..517d87aadfad 100644
--- a/drivers/net/ethernet/intel/ice/ice_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_lib.c
@@ -1282,30 +1282,46 @@ static void ice_set_fd_vsi_ctx(struct ice_vsi_ctx *ctxt, struct ice_vsi *vsi)
 	ctxt->info.fd_report_opt = cpu_to_le16(val);
 }
 
+/* Translate @lut_type used in most of the places to the Admin Queue
+ * Q_OPT value for RSS.
+ * Used with VSI ADD and VSI UPDATE AQs (opcodes 0x0210, 0x0211).
+ */
+static u8 ice_lut_type_to_aq_qopt_rss_val(enum ice_lut_type lut_type)
+{
+	switch (lut_type) {
+	case ICE_LUT_PF:
+		return ICE_AQ_VSI_Q_OPT_RSS_LUT_PF;
+	case ICE_LUT_GLOBAL:
+		return ICE_AQ_VSI_Q_OPT_RSS_LUT_GBL;
+	case ICE_LUT_VSI:
+	default:
+		return ICE_AQ_VSI_Q_OPT_RSS_LUT_VSI;
+	}
+}
+
 /**
  * ice_set_rss_vsi_ctx - Set RSS VSI context before adding a VSI
  * @ctxt: the VSI context being set
  * @vsi: the VSI being configured
  */
 static void ice_set_rss_vsi_ctx(struct ice_vsi_ctx *ctxt, struct ice_vsi *vsi)
 {
 	u8 lut_type, hash_type;
+	u8 global_lut_id = 0;
 	struct device *dev;
 	struct ice_pf *pf;
 
 	pf = vsi->back;
 	dev = ice_pf_to_dev(pf);
 
 	switch (vsi->type) {
 	case ICE_VSI_CHNL:
-	case ICE_VSI_PF:
-		/* PF VSI will inherit RSS instance of PF */
 		lut_type = ICE_AQ_VSI_Q_OPT_RSS_LUT_PF;
 		break;
+	case ICE_VSI_PF:
 	case ICE_VSI_VF:
 	case ICE_VSI_SF:
-		/* VF VSI will gets a small RSS table which is a VSI LUT type */
-		lut_type = ICE_AQ_VSI_Q_OPT_RSS_LUT_VSI;
+		lut_type = ice_lut_type_to_aq_qopt_rss_val(vsi->rss_lut_type);
 		break;
 	default:
 		dev_dbg(dev, "Unsupported VSI type %s\n",
@@ -1316,8 +1332,12 @@ static void ice_set_rss_vsi_ctx(struct ice_vsi_ctx *ctxt, struct ice_vsi *vsi)
 	hash_type = ICE_AQ_VSI_Q_OPT_RSS_HASH_TPLZ;
 	vsi->rss_hfunc = hash_type;
 
+	if (vsi->rss_lut_type == ICE_LUT_GLOBAL)
+		global_lut_id = vsi->global_lut_id;
+
 	ctxt->info.q_opt_rss =
 		FIELD_PREP(ICE_AQ_VSI_Q_OPT_RSS_LUT_M, lut_type) |
+		FIELD_PREP(ICE_AQ_VSI_Q_OPT_RSS_GBL_LUT_M, global_lut_id) |
 		FIELD_PREP(ICE_AQ_VSI_Q_OPT_RSS_HASH_M, hash_type);
 }
 
diff --git a/drivers/net/ethernet/intel/ice/ice_switch.c b/drivers/net/ethernet/intel/ice/ice_switch.c
index 70eed3bcc404..2a07a8881ecc 100644
--- a/drivers/net/ethernet/intel/ice/ice_switch.c
+++ b/drivers/net/ethernet/intel/ice/ice_switch.c
@@ -1527,6 +1527,47 @@ ice_aq_get_sw_cfg(struct ice_hw *hw, struct ice_aqc_get_sw_cfg_resp_elem *buf,
 	return status;
 }
 
+/* Allocate a new Global LUT for the caller.
+ * LUT ID is returned via @global_lut_id.
+ */
+int ice_alloc_rss_global_lut(struct ice_hw *hw, u16 *global_lut_id)
+{
+	DEFINE_RAW_FLEX(struct ice_aqc_alloc_free_res_elem, buf, elem, 1);
+	u16 buf_len = __struct_size(buf);
+	int err;
+
+	buf->num_elems = cpu_to_le16(1);
+	buf->res_type = cpu_to_le16(ICE_AQC_RES_TYPE_GLOBAL_RSS_HASH);
+
+	err = ice_aq_alloc_free_res(hw, buf, buf_len, ice_aqc_opc_alloc_res);
+	if (err)
+		ice_debug(hw, ICE_DBG_RES, "Failed to allocate RSS global LUT, err %d\n",
+			  err);
+	else
+		*global_lut_id = le16_to_cpu(buf->elem[0].e.sw_resp);
+
+	return err;
+}
+
+/* Free Global LUT at @global_lut_id. */
+int ice_free_rss_global_lut(struct ice_hw *hw, u16 global_lut_id)
+{
+	DEFINE_RAW_FLEX(struct ice_aqc_alloc_free_res_elem, buf, elem, 1);
+	u16 buf_len = __struct_size(buf);
+	int err;
+
+	buf->num_elems = cpu_to_le16(1);
+	buf->res_type = cpu_to_le16(ICE_AQC_RES_TYPE_GLOBAL_RSS_HASH);
+	buf->elem[0].e.sw_resp = cpu_to_le16(global_lut_id);
+
+	err = ice_aq_alloc_free_res(hw, buf, buf_len, ice_aqc_opc_free_res);
+	if (err)
+		ice_debug(hw, ICE_DBG_RES, "Failed to free RSS global LUT %d, err %d\n",
+			  global_lut_id, err);
+
+	return err;
+}
+
 /**
  * ice_aq_add_vsi
  * @hw: pointer to the HW struct
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH net-next v7 05/15] ice: rename ICE_MAX_RSS_QS_PER_VF to ICE_MAX_QS_PER_VF_VCV1
  2026-11-21 22:55 [PATCH net-next v7 00/15] devlink, mlx5, iavf, ice: XLVF for iavf Przemek Kitszel
                   ` (3 preceding siblings ...)
  2026-11-21 22:55 ` [PATCH net-next v7 04/15] ice: add helpers for Global RSS LUT alloc, free, vsi_update Przemek Kitszel
@ 2026-11-21 22:55 ` Przemek Kitszel
  2026-11-21 22:55 ` [PATCH net-next v7 06/15] ice: bump to 256qs for VF Przemek Kitszel
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 28+ messages in thread
From: Przemek Kitszel @ 2026-11-21 22:55 UTC (permalink / raw)
  To: netdev, Jakub Kicinski, Jiri Pirko
  Cc: Tony Nguyen, Aleksandr Loktionov, Michal Schmidt, edumazet, horms,
	pabeni, davem, Jonathan Corbet, skhan, rdunlap, andrew+netdev,
	saeedm, tariqt, leon, mbloch, jacob.e.keller, jedrzej.jagielski,
	anzaki, brett.creeley, ohartoov, Petr Oros, Donald Hunter,
	Przemek Kitszel

Rename ICE_MAX_RSS_QS_PER_VF to ICE_MAX_QS_PER_VF_VCV1, in preparation for
the next patch that will extend the max to 256, using old value of 16 for
the "v1" variant of virtchnl opcodes.

Suggested-by: Jedrzej Jagielski <jedrzej.jagielski@intel.com>
Suggested-by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_lag.h     |  2 +-
 drivers/net/ethernet/intel/ice/ice_vf_lib.h  |  9 +++---
 drivers/net/ethernet/intel/ice/ice_lib.c     |  2 +-
 drivers/net/ethernet/intel/ice/ice_sriov.c   |  4 +--
 drivers/net/ethernet/intel/ice/ice_vf_lib.c  | 12 ++++----
 drivers/net/ethernet/intel/ice/virt/queues.c | 30 ++++++++++----------
 6 files changed, 30 insertions(+), 29 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_lag.h b/drivers/net/ethernet/intel/ice/ice_lag.h
index f77ebcd61042..4bfffecbdc97 100644
--- a/drivers/net/ethernet/intel/ice/ice_lag.h
+++ b/drivers/net/ethernet/intel/ice/ice_lag.h
@@ -52,7 +52,7 @@ struct ice_lag {
 	u8 bond_lport_sec; /* lport values for secondary PF */
 
 	/* q_home keeps track of which interface the q is currently on */
-	u8 q_home[ICE_MAX_SRIOV_VFS][ICE_MAX_RSS_QS_PER_VF];
+	u8 q_home[ICE_MAX_SRIOV_VFS][ICE_MAX_QS_PER_VF_VCV1];
 
 	/* placeholder VSI for hanging VF queues from on secondary interface */
 	struct ice_vsi *sec_vf[ICE_MAX_SRIOV_VFS];
diff --git a/drivers/net/ethernet/intel/ice/ice_vf_lib.h b/drivers/net/ethernet/intel/ice/ice_vf_lib.h
index fa436b3b1eac..4959ecee0c21 100644
--- a/drivers/net/ethernet/intel/ice/ice_vf_lib.h
+++ b/drivers/net/ethernet/intel/ice/ice_vf_lib.h
@@ -19,7 +19,8 @@
 #define ICE_MAX_SRIOV_VFS		256
 
 /* VF resource constraints */
-#define ICE_MAX_RSS_QS_PER_VF	16
+/* for "old" virtchnl opcodes that accept up to 16 queues */
+#define ICE_MAX_QS_PER_VF_VCV1	16
 
 struct ice_pf;
 struct ice_vf;
@@ -161,8 +162,8 @@ struct ice_vf {
 	u8 dev_lan_addr[ETH_ALEN];
 	u8 hw_lan_addr[ETH_ALEN];
 	struct ice_time_mac legacy_last_added_umac;
-	DECLARE_BITMAP(txq_ena, ICE_MAX_RSS_QS_PER_VF);
-	DECLARE_BITMAP(rxq_ena, ICE_MAX_RSS_QS_PER_VF);
+	DECLARE_BITMAP(txq_ena, ICE_MAX_QS_PER_VF_VCV1);
+	DECLARE_BITMAP(rxq_ena, ICE_MAX_QS_PER_VF_VCV1);
 	struct ice_vlan port_vlan_info;	/* Port VLAN ID, QoS, and TPID */
 	struct virtchnl_vlan_caps vlan_v2_caps;
 	struct ice_mbx_vf_info mbx_info;
@@ -205,7 +206,7 @@ struct ice_vf {
 	u16 lldp_recipe_id;
 	u16 lldp_rule_id;
 
-	struct ice_vf_qs_bw qs_bw[ICE_MAX_RSS_QS_PER_VF];
+	struct ice_vf_qs_bw qs_bw[ICE_MAX_QS_PER_VF_VCV1];
 };
 
 /* Flags for controlling behavior of ice_reset_vf */
diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
index 517d87aadfad..7b9f0ddcaa2b 100644
--- a/drivers/net/ethernet/intel/ice/ice_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_lib.c
@@ -1062,7 +1062,7 @@ static void ice_vsi_set_rss_params(struct ice_vsi *vsi)
 				      max_rss_size);
 		break;
 	case ICE_VSI_VF:
-		vsi->rss_size = ICE_MAX_RSS_QS_PER_VF;
+		vsi->rss_size = ICE_MAX_QS_PER_VF_VCV1;
 		break;
 	case ICE_VSI_LB:
 		break;
diff --git a/drivers/net/ethernet/intel/ice/ice_sriov.c b/drivers/net/ethernet/intel/ice/ice_sriov.c
index c49f48b5ae38..dcd6d48ea38d 100644
--- a/drivers/net/ethernet/intel/ice/ice_sriov.c
+++ b/drivers/net/ethernet/intel/ice/ice_sriov.c
@@ -398,15 +398,15 @@ static int ice_set_per_vf_res(struct ice_pf *pf, u16 num_vfs)
 	}
 
 	num_txq = min_t(u16, num_msix_per_vf - ICE_NONQ_VECS_VF,
-			ICE_MAX_RSS_QS_PER_VF);
+			ICE_MAX_QS_PER_VF_VCV1);
 	avail_qs = ice_get_avail_txq_count(pf) / num_vfs;
 	if (!avail_qs)
 		num_txq = 0;
 	else if (num_txq > avail_qs)
 		num_txq = rounddown_pow_of_two(avail_qs);
 
 	num_rxq = min_t(u16, num_msix_per_vf - ICE_NONQ_VECS_VF,
-			ICE_MAX_RSS_QS_PER_VF);
+			ICE_MAX_QS_PER_VF_VCV1);
 	avail_qs = ice_get_avail_rxq_count(pf) / num_vfs;
 	if (!avail_qs)
 		num_rxq = 0;
diff --git a/drivers/net/ethernet/intel/ice/ice_vf_lib.c b/drivers/net/ethernet/intel/ice/ice_vf_lib.c
index a54cb2b8d3c7..be87a83d2599 100644
--- a/drivers/net/ethernet/intel/ice/ice_vf_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_vf_lib.c
@@ -528,8 +528,8 @@ static void ice_vf_rebuild_host_cfg(struct ice_vf *vf)
 static void ice_set_vf_state_qs_dis(struct ice_vf *vf)
 {
 	/* Clear Rx/Tx enabled queues flag */
-	bitmap_zero(vf->txq_ena, ICE_MAX_RSS_QS_PER_VF);
-	bitmap_zero(vf->rxq_ena, ICE_MAX_RSS_QS_PER_VF);
+	bitmap_zero(vf->txq_ena, ICE_MAX_QS_PER_VF_VCV1);
+	bitmap_zero(vf->rxq_ena, ICE_MAX_QS_PER_VF_VCV1);
 	clear_bit(ICE_VF_STATE_QS_ENA, vf->vf_states);
 }
 
@@ -1238,13 +1238,13 @@ bool ice_is_vf_trusted(struct ice_vf *vf)
  * ice_vf_has_no_qs_ena - check if the VF has any Rx or Tx queues enabled
  * @vf: the VF to check
  *
- * Returns true if the VF has no Rx and no Tx queues enabled and returns false
- * otherwise
+ * Return: true if the VF has no Rx and no Tx queues enabled and returns false
+ * otherwise.
  */
 bool ice_vf_has_no_qs_ena(struct ice_vf *vf)
 {
-	return bitmap_empty(vf->rxq_ena, ICE_MAX_RSS_QS_PER_VF) &&
-		bitmap_empty(vf->txq_ena, ICE_MAX_RSS_QS_PER_VF);
+	return bitmap_empty(vf->rxq_ena, ICE_MAX_QS_PER_VF_VCV1) &&
+	       bitmap_empty(vf->txq_ena, ICE_MAX_QS_PER_VF_VCV1);
 }
 
 /**
diff --git a/drivers/net/ethernet/intel/ice/virt/queues.c b/drivers/net/ethernet/intel/ice/virt/queues.c
index a22780575086..2667634e3c8c 100644
--- a/drivers/net/ethernet/intel/ice/virt/queues.c
+++ b/drivers/net/ethernet/intel/ice/virt/queues.c
@@ -171,8 +171,8 @@ static int ice_vf_cfg_q_quanta_profile(struct ice_vf *vf, u16 quanta_size,
 static bool ice_vc_validate_vqs_bitmaps(struct virtchnl_queue_select *vqs)
 {
 	if ((!vqs->rx_queues && !vqs->tx_queues) ||
-	    vqs->rx_queues >= BIT(ICE_MAX_RSS_QS_PER_VF) ||
-	    vqs->tx_queues >= BIT(ICE_MAX_RSS_QS_PER_VF))
+	    vqs->rx_queues >= BIT(ICE_MAX_QS_PER_VF_VCV1) ||
+	    vqs->tx_queues >= BIT(ICE_MAX_QS_PER_VF_VCV1))
 		return false;
 
 	return true;
@@ -335,7 +335,7 @@ int ice_vc_ena_qs_msg(struct ice_vf *vf, u8 *msg)
 	 * programmed using ice_vsi_cfg_txqs
 	 */
 	q_map = vqs->rx_queues;
-	for_each_set_bit(vf_q_id, &q_map, ICE_MAX_RSS_QS_PER_VF) {
+	for_each_set_bit(vf_q_id, &q_map, ICE_MAX_QS_PER_VF_VCV1) {
 		if (!ice_vc_isvalid_q_id(vsi, vf_q_id)) {
 			v_ret = VIRTCHNL_STATUS_ERR_PARAM;
 			goto error_param;
@@ -348,7 +348,7 @@ int ice_vc_ena_qs_msg(struct ice_vf *vf, u8 *msg)
 	}
 
 	q_map = vqs->tx_queues;
-	for_each_set_bit(vf_q_id, &q_map, ICE_MAX_RSS_QS_PER_VF) {
+	for_each_set_bit(vf_q_id, &q_map, ICE_MAX_QS_PER_VF_VCV1) {
 		if (!ice_vc_isvalid_q_id(vsi, vf_q_id)) {
 			v_ret = VIRTCHNL_STATUS_ERR_PARAM;
 			goto error_param;
@@ -484,7 +484,7 @@ int ice_vc_dis_qs_msg(struct ice_vf *vf, u8 *msg)
 	if (vqs->tx_queues) {
 		q_map = vqs->tx_queues;
 
-		for_each_set_bit(vf_q_id, &q_map, ICE_MAX_RSS_QS_PER_VF) {
+		for_each_set_bit(vf_q_id, &q_map, ICE_MAX_QS_PER_VF_VCV1) {
 			if (!ice_vc_isvalid_q_id(vsi, vf_q_id)) {
 				v_ret = VIRTCHNL_STATUS_ERR_PARAM;
 				goto error_param;
@@ -499,7 +499,7 @@ int ice_vc_dis_qs_msg(struct ice_vf *vf, u8 *msg)
 
 	q_map = vqs->rx_queues;
 	if (q_map) {
-		for_each_set_bit(vf_q_id, &q_map, ICE_MAX_RSS_QS_PER_VF) {
+		for_each_set_bit(vf_q_id, &q_map, ICE_MAX_QS_PER_VF_VCV1) {
 			if (!ice_vc_isvalid_q_id(vsi, vf_q_id)) {
 				v_ret = VIRTCHNL_STATUS_ERR_PARAM;
 				goto error_param;
@@ -542,7 +542,7 @@ ice_cfg_interrupt(struct ice_vf *vf, struct ice_vsi *vsi,
 	q_vector->num_ring_tx = 0;
 
 	qmap = map->rxq_map;
-	for_each_set_bit(vsi_q_id_idx, &qmap, ICE_MAX_RSS_QS_PER_VF) {
+	for_each_set_bit(vsi_q_id_idx, &qmap, ICE_MAX_QS_PER_VF_VCV1) {
 		vsi_q_id = vsi_q_id_idx;
 
 		if (!ice_vc_isvalid_q_id(vsi, vsi_q_id))
@@ -557,7 +557,7 @@ ice_cfg_interrupt(struct ice_vf *vf, struct ice_vsi *vsi,
 	}
 
 	qmap = map->txq_map;
-	for_each_set_bit(vsi_q_id_idx, &qmap, ICE_MAX_RSS_QS_PER_VF) {
+	for_each_set_bit(vsi_q_id_idx, &qmap, ICE_MAX_QS_PER_VF_VCV1) {
 		vsi_q_id = vsi_q_id_idx;
 
 		if (!ice_vc_isvalid_q_id(vsi, vsi_q_id))
@@ -681,7 +681,7 @@ int ice_vc_cfg_q_bw(struct ice_vf *vf, u8 *msg)
 		goto err;
 	}
 
-	if (qbw->num_queues > ICE_MAX_RSS_QS_PER_VF ||
+	if (qbw->num_queues > ICE_MAX_QS_PER_VF_VCV1 ||
 	    qbw->num_queues > min_t(u16, vsi->alloc_txq, vsi->alloc_rxq)) {
 		dev_err(ice_pf_to_dev(vf->pf), "VF-%d trying to configure more than allocated number of queues: %d\n",
 			vf->vf_id, min_t(u16, vsi->alloc_txq, vsi->alloc_rxq));
@@ -773,7 +773,7 @@ int ice_vc_cfg_q_quanta(struct ice_vf *vf, u8 *msg)
 		goto err;
 	}
 
-	if (end_qid > ICE_MAX_RSS_QS_PER_VF ||
+	if (end_qid > ICE_MAX_QS_PER_VF_VCV1 ||
 	    end_qid > min_t(u16, vsi->alloc_txq, vsi->alloc_rxq)) {
 		dev_err(ice_pf_to_dev(vf->pf), "VF-%d trying to configure more than allocated number of queues: %d\n",
 			vf->vf_id, min_t(u16, vsi->alloc_txq, vsi->alloc_rxq));
@@ -841,7 +841,7 @@ int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
 	if (!vsi)
 		goto error_param;
 
-	if (qci->num_queue_pairs > ICE_MAX_RSS_QS_PER_VF ||
+	if (qci->num_queue_pairs > ICE_MAX_QS_PER_VF_VCV1 ||
 	    qci->num_queue_pairs > min_t(u16, vsi->alloc_txq, vsi->alloc_rxq)) {
 		dev_err(ice_pf_to_dev(pf), "VF-%d requesting more than supported number of queues: %d\n",
 			vf->vf_id, min_t(u16, vsi->alloc_txq, vsi->alloc_rxq));
@@ -1019,16 +1019,16 @@ int ice_vc_request_qs_msg(struct ice_vf *vf, u8 *msg)
 	if (!req_queues) {
 		dev_err(dev, "VF %d tried to request 0 queues. Ignoring.\n",
 			vf->vf_id);
-	} else if (req_queues > ICE_MAX_RSS_QS_PER_VF) {
+	} else if (req_queues > ICE_MAX_QS_PER_VF_VCV1) {
 		dev_err(dev, "VF %d tried to request more than %d queues.\n",
-			vf->vf_id, ICE_MAX_RSS_QS_PER_VF);
-		vfres->num_queue_pairs = ICE_MAX_RSS_QS_PER_VF;
+			vf->vf_id, ICE_MAX_QS_PER_VF_VCV1);
+		vfres->num_queue_pairs = ICE_MAX_QS_PER_VF_VCV1;
 	} else if (req_queues > cur_queues &&
 		   req_queues - cur_queues > tx_rx_queue_left) {
 		dev_warn(dev, "VF %d requested %u more queues, but only %u left.\n",
 			 vf->vf_id, req_queues - cur_queues, tx_rx_queue_left);
 		vfres->num_queue_pairs = min_t(u16, max_allowed_vf_queues,
-					       ICE_MAX_RSS_QS_PER_VF);
+					       ICE_MAX_QS_PER_VF_VCV1);
 	} else {
 		/* request is successful, then reset VF */
 		vf->num_req_qs = req_queues;
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH net-next v7 06/15] ice: bump to 256qs for VF
  2026-11-21 22:55 [PATCH net-next v7 00/15] devlink, mlx5, iavf, ice: XLVF for iavf Przemek Kitszel
                   ` (4 preceding siblings ...)
  2026-11-21 22:55 ` [PATCH net-next v7 05/15] ice: rename ICE_MAX_RSS_QS_PER_VF to ICE_MAX_QS_PER_VF_VCV1 Przemek Kitszel
@ 2026-11-21 22:55 ` Przemek Kitszel
  2026-11-24 21:57   ` netdev-bot+sashiko
  2026-11-21 22:55 ` [PATCH net-next v7 07/15] iavf: extend iavf_configure_queues() to support more queues Przemek Kitszel
                   ` (9 subsequent siblings)
  15 siblings, 1 reply; 28+ messages in thread
From: Przemek Kitszel @ 2026-11-21 22:55 UTC (permalink / raw)
  To: netdev, Jakub Kicinski, Jiri Pirko
  Cc: Tony Nguyen, Aleksandr Loktionov, Michal Schmidt, edumazet, horms,
	pabeni, davem, Jonathan Corbet, skhan, rdunlap, andrew+netdev,
	saeedm, tariqt, leon, mbloch, jacob.e.keller, jedrzej.jagielski,
	anzaki, brett.creeley, ohartoov, Petr Oros, Donald Hunter,
	Przemek Kitszel

Adjust all bitmaps and arrays in ice to accept 256 VF queues.
Extend struct ice_vf::num_req_qs width to allow 256 queues.
Keep old/legacy size for virtchnl opcodes that were designed to accept
only up to 16 queues.

Raise also the limit for the default VF queue count to 256. New virtchnl
opcodes, needed to make use of more than 16 queues, are handled by
subsequent commits of this series, the work is split for easier review.
VIRTCHNL_OP_REQUEST_QUEUES keeps its limit of 16 queues for now, a later
commit raises it, together with a check that the queues fit in one free
range.

__ice_vsi_get_qs() falls back to scattered PF queues when no contiguous
range is free, but takes at most 16 of them, while the VSI keeps its
queue count, so the rings past 16 all map to PF queue 0. Fail instead
when the queues don't fit in the scatter count, as a VF can now have
more than 16 queues. Other VSI types and XDP rings had the same broken
mapping, now they fail too when more than 16 queues find no contiguous
range. ice_prepare_xdp_rings() then must not clear any queue bits, as it
got none.

Disable only the queue pairs that passed validation when
ice_vc_cfg_qs_msg() fails, by their queue IDs instead of their index in
the message, as the queue config can now come in many messages.

Move the Tx queues of a VF to another LAG port with ice_aq_cfg_lan_txq()
commands of up to U8_MAX queues each, as num_qs of the command is u8.
Allocate struct ice_lag with kvzalloc_obj(), as its q_home table for
256 queues of each VF makes it about 66 KB.

Reviewed-by: Jedrzej Jagielski <jedrzej.jagielski@intel.com>
Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
---
v7:
 * fail __ice_vsi_get_qs() when the queues don't fit in the scatter
   count, instead of cutting the count to 16, while the VSI kept all its
   rings, and the rest of them used PF queue 0; don't clear XDP queue
   bits after such failure, ice_prepare_xdp_rings() got none (me)
 * keep the VIRTCHNL_OP_REQUEST_QUEUES limit of 16 here, raise it only
   in "ice: support up to 256 VF queues", with the check that the queues
   fit in one free range; in between, a request for more than 16 queues
   could fail the VF reset (me)
 * commit message: describe the ice_vc_cfg_qs_msg() rollback fix, the
   LAG queue moves in commands of up to U8_MAX queues, and the
   kvzalloc_obj() of struct ice_lag (me)

v5:
 * LAG: call ice_aq_cfg_lan_txq() for up to U8_MAX queues at a time, as
   num_qs of the command is u8, 256 VF queues were sent as 0 (Sashiko)

v3:
 * fix rollback in ice_vc_cfg_qs_msg() to disable queues by their IDs,
   not by qpair index, as config could be now split into many messages;
   unwind only the entries that got past validation (Sashiko)

v2:
 * change ice_lag allocations to kvzalloc(), as they have grown to
   66KB (Sashiko)
 * commit message: mention that the default and requested VF queue
   limits are raised already here, while more than 16 queues are
   enabled by subsequent commits

Sashiko suggestions I don't want to apply:
 S: there is an existing error handling issue in ice_init_lag()
 me: pre-existing and unrelated, will be fixed separately
---
 drivers/net/ethernet/intel/ice/ice_lag.h     |  2 +-
 drivers/net/ethernet/intel/ice/ice_vf_lib.h  |  9 ++--
 drivers/net/ethernet/intel/ice/ice_base.c    |  6 +--
 drivers/net/ethernet/intel/ice/ice_lag.c     | 54 ++++++++++++++++----
 drivers/net/ethernet/intel/ice/ice_lib.c     |  2 +-
 drivers/net/ethernet/intel/ice/ice_main.c    |  2 +-
 drivers/net/ethernet/intel/ice/ice_sriov.c   |  4 +-
 drivers/net/ethernet/intel/ice/ice_vf_lib.c  |  8 +--
 drivers/net/ethernet/intel/ice/virt/queues.c | 20 ++++----
 9 files changed, 70 insertions(+), 37 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_lag.h b/drivers/net/ethernet/intel/ice/ice_lag.h
index 4bfffecbdc97..39f6a6cc844d 100644
--- a/drivers/net/ethernet/intel/ice/ice_lag.h
+++ b/drivers/net/ethernet/intel/ice/ice_lag.h
@@ -52,7 +52,7 @@ struct ice_lag {
 	u8 bond_lport_sec; /* lport values for secondary PF */
 
 	/* q_home keeps track of which interface the q is currently on */
-	u8 q_home[ICE_MAX_SRIOV_VFS][ICE_MAX_QS_PER_VF_VCV1];
+	u8 q_home[ICE_MAX_SRIOV_VFS][ICE_MAX_QS_PER_VF];
 
 	/* placeholder VSI for hanging VF queues from on secondary interface */
 	struct ice_vsi *sec_vf[ICE_MAX_SRIOV_VFS];
diff --git a/drivers/net/ethernet/intel/ice/ice_vf_lib.h b/drivers/net/ethernet/intel/ice/ice_vf_lib.h
index 4959ecee0c21..a9e95c85bc98 100644
--- a/drivers/net/ethernet/intel/ice/ice_vf_lib.h
+++ b/drivers/net/ethernet/intel/ice/ice_vf_lib.h
@@ -21,6 +21,7 @@
 /* VF resource constraints */
 /* for "old" virtchnl opcodes that accept up to 16 queues */
 #define ICE_MAX_QS_PER_VF_VCV1	16
+#define ICE_MAX_QS_PER_VF	256
 
 struct ice_pf;
 struct ice_vf;
@@ -162,8 +163,8 @@ struct ice_vf {
 	u8 dev_lan_addr[ETH_ALEN];
 	u8 hw_lan_addr[ETH_ALEN];
 	struct ice_time_mac legacy_last_added_umac;
-	DECLARE_BITMAP(txq_ena, ICE_MAX_QS_PER_VF_VCV1);
-	DECLARE_BITMAP(rxq_ena, ICE_MAX_QS_PER_VF_VCV1);
+	DECLARE_BITMAP(txq_ena, ICE_MAX_QS_PER_VF);
+	DECLARE_BITMAP(rxq_ena, ICE_MAX_QS_PER_VF);
 	struct ice_vlan port_vlan_info;	/* Port VLAN ID, QoS, and TPID */
 	struct virtchnl_vlan_caps vlan_v2_caps;
 	struct ice_mbx_vf_info mbx_info;
@@ -185,7 +186,7 @@ struct ice_vf {
 	DECLARE_BITMAP(vf_states, ICE_VF_STATES_NBITS);	/* VF runtime states */
 
 	unsigned long vf_caps;		/* VF's adv. capabilities */
-	u8 num_req_qs;			/* num of queue pairs requested by VF */
+	u16 num_req_qs;			/* num of queue pairs requested by VF */
 	u16 num_mac;
 	u16 num_mac_lldp;
 	u16 num_vf_qs;			/* num of queue configured per VF */
@@ -206,7 +207,7 @@ struct ice_vf {
 	u16 lldp_recipe_id;
 	u16 lldp_rule_id;
 
-	struct ice_vf_qs_bw qs_bw[ICE_MAX_QS_PER_VF_VCV1];
+	struct ice_vf_qs_bw qs_bw[ICE_MAX_QS_PER_VF];
 };
 
 /* Flags for controlling behavior of ice_reset_vf */
diff --git a/drivers/net/ethernet/intel/ice/ice_base.c b/drivers/net/ethernet/intel/ice/ice_base.c
index 1667f686ff75..f65634e3d44e 100644
--- a/drivers/net/ethernet/intel/ice/ice_base.c
+++ b/drivers/net/ethernet/intel/ice/ice_base.c
@@ -808,20 +808,18 @@ int ice_vsi_cfg_rxqs(struct ice_vsi *vsi)
  * @qs_cfg: gathered variables needed for pf->vsi queues assignment
  *
  * This function first tries to find contiguous space. If it is not successful,
- * it tries with the scatter approach.
+ * it tries with the scatter approach, if all queues fit in scatter_count.
  *
  * Return 0 on success and -ENOMEM in case of no left space in PF queue bitmap
  */
 int __ice_vsi_get_qs(struct ice_qs_cfg *qs_cfg)
 {
 	int ret = 0;
 
 	ret = __ice_vsi_get_qs_contig(qs_cfg);
-	if (ret) {
+	if (ret && qs_cfg->q_count <= qs_cfg->scatter_count) {
 		/* contig failed, so try with scatter approach */
 		qs_cfg->mapping_mode = ICE_VSI_MAP_SCATTER;
-		qs_cfg->q_count = min_t(unsigned int, qs_cfg->q_count,
-					qs_cfg->scatter_count);
 		ret = __ice_vsi_get_qs_sc(qs_cfg);
 	}
 	return ret;
diff --git a/drivers/net/ethernet/intel/ice/ice_lag.c b/drivers/net/ethernet/intel/ice/ice_lag.c
index 08a17ded0ad5..4bb28564c0d6 100644
--- a/drivers/net/ethernet/intel/ice/ice_lag.c
+++ b/drivers/net/ethernet/intel/ice/ice_lag.c
@@ -549,6 +549,41 @@ ice_lag_qbuf_recfg(struct ice_hw *hw, struct ice_aqc_cfg_txqs_buf *qbuf,
 	return count;
 }
 
+/**
+ * ice_lag_cfg_lan_txq - reconfigure queues for a new port
+ * @hw: HW struct to send the command on
+ * @qbuf: buffer filled by ice_lag_qbuf_recfg(), gets modified
+ * @numq: number of queues in @qbuf
+ * @oldport: lport of the current queues location
+ * @newport: lport of the destination queues location
+ *
+ * One command takes up to U8_MAX queues, a VF could have more.
+ *
+ * Return: 0 on success, negative on failure.
+ */
+static int
+ice_lag_cfg_lan_txq(struct ice_hw *hw, struct ice_aqc_cfg_txqs_buf *qbuf,
+		    u16 numq, u8 oldport, u8 newport)
+{
+	while (numq) {
+		int num = min(numq, U8_MAX);
+		int err;
+
+		err = ice_aq_cfg_lan_txq(hw, qbuf,
+					 struct_size(qbuf, queue_info, num),
+					 num, oldport, newport,
+					 ICE_AQC_Q_CFG_TC_CHNG, NULL);
+		if (err)
+			return err;
+
+		numq -= num;
+		memmove(qbuf->queue_info, &qbuf->queue_info[num],
+			numq * sizeof(*qbuf->queue_info));
+	}
+
+	return 0;
+}
+
 /**
  * ice_lag_get_sched_parent - locate or create a sched node parent
  * @hw: HW struct for getting parent in
@@ -689,8 +724,7 @@ ice_lag_move_vf_node_tc(struct ice_lag *lag, u8 oldport, u8 newport,
 		goto qbuf_none;
 	}
 
-	if (ice_aq_cfg_lan_txq(&lag->pf->hw, qbuf, qbuf_size, valq, oldport,
-			       newport, ICE_AQC_Q_CFG_TC_CHNG, NULL)) {
+	if (ice_lag_cfg_lan_txq(&lag->pf->hw, qbuf, valq, oldport, newport)) {
 		dev_warn(dev, "Failure to configure queues for LAG failover\n");
 		goto qbuf_err;
 	}
@@ -1277,9 +1311,8 @@ ice_lag_reclaim_vf_tc(struct ice_lag *lag, struct ice_hw *src_hw, u16 vsi_num,
 		goto reclaim_none;
 	}
 
-	if (ice_aq_cfg_lan_txq(hw, qbuf, qbuf_size, numq,
-			       src_hw->port_info->lport, hw->port_info->lport,
-			       ICE_AQC_Q_CFG_TC_CHNG, NULL)) {
+	if (ice_lag_cfg_lan_txq(hw, qbuf, numq, src_hw->port_info->lport,
+				hw->port_info->lport)) {
 		dev_warn(dev, "Failure to configure queues for LAG failover\n");
 		goto reclaim_qerr;
 	}
@@ -2495,9 +2528,8 @@ ice_lag_move_vf_nodes_tc_sync(struct ice_lag *lag, struct ice_hw *dest_hw,
 		goto sync_none;
 	}
 
-	if (ice_aq_cfg_lan_txq(hw, qbuf, qbuf_size, numq, hw->port_info->lport,
-			       dest_hw->port_info->lport,
-			       ICE_AQC_Q_CFG_TC_CHNG, NULL)) {
+	if (ice_lag_cfg_lan_txq(hw, qbuf, numq, hw->port_info->lport,
+				dest_hw->port_info->lport)) {
 		dev_warn(dev, "Failure to configure queues for LAG reset rebuild\n");
 		goto sync_qerr;
 	}
@@ -2577,7 +2609,7 @@ int ice_init_lag(struct ice_pf *pf)
 	if (!ice_is_feature_supported(pf, ICE_F_SRIOV_LAG))
 		return 0;
 
-	pf->lag = kzalloc_obj(*lag);
+	pf->lag = kvzalloc_obj(*lag);
 	if (!pf->lag)
 		return -ENOMEM;
 	lag = pf->lag;
@@ -2651,7 +2683,7 @@ int ice_init_lag(struct ice_pf *pf)
 	ice_free_hw_res(&pf->hw, ICE_AQC_RES_TYPE_RECIPE, 1,
 			&lag->pf_recipe);
 lag_error:
-	kfree(lag);
+	kvfree(lag);
 	pf->lag = NULL;
 	return err;
 }
@@ -2680,7 +2712,7 @@ void ice_deinit_lag(struct ice_pf *pf)
 	ice_free_hw_res(&pf->hw, ICE_AQC_RES_TYPE_RECIPE, 1,
 			&pf->lag->lport_recipe);
 
-	kfree(lag);
+	kvfree(lag);
 
 	pf->lag = NULL;
 }
diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
index 7b9f0ddcaa2b..57425683c0d4 100644
--- a/drivers/net/ethernet/intel/ice/ice_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_lib.c
@@ -1062,7 +1062,7 @@ static void ice_vsi_set_rss_params(struct ice_vsi *vsi)
 				      max_rss_size);
 		break;
 	case ICE_VSI_VF:
-		vsi->rss_size = ICE_MAX_QS_PER_VF_VCV1;
+		vsi->rss_size = ICE_MAX_QS_PER_VF;
 		break;
 	case ICE_VSI_LB:
 		break;
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 0bc53f404957..3e8cf1c5f0e8 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -2758,14 +2758,14 @@ int ice_prepare_xdp_rings(struct ice_vsi *vsi, struct bpf_prog *prog,
 			vsi->xdp_rings[i] = NULL;
 		}
 
-err_map_xdp:
 	mutex_lock(&pf->avail_q_mutex);
 	ice_for_each_xdp_txq(vsi, i) {
 		clear_bit(vsi->txq_map[i + vsi->alloc_txq], pf->avail_txqs);
 		vsi->txq_map[i + vsi->alloc_txq] = ICE_INVAL_Q_INDEX;
 	}
 	mutex_unlock(&pf->avail_q_mutex);
 
+err_map_xdp:
 	devm_kfree(dev, vsi->xdp_rings);
 	vsi->xdp_rings = NULL;
 
diff --git a/drivers/net/ethernet/intel/ice/ice_sriov.c b/drivers/net/ethernet/intel/ice/ice_sriov.c
index dcd6d48ea38d..d7c4a6540008 100644
--- a/drivers/net/ethernet/intel/ice/ice_sriov.c
+++ b/drivers/net/ethernet/intel/ice/ice_sriov.c
@@ -398,15 +398,15 @@ static int ice_set_per_vf_res(struct ice_pf *pf, u16 num_vfs)
 	}
 
 	num_txq = min_t(u16, num_msix_per_vf - ICE_NONQ_VECS_VF,
-			ICE_MAX_QS_PER_VF_VCV1);
+			ICE_MAX_QS_PER_VF);
 	avail_qs = ice_get_avail_txq_count(pf) / num_vfs;
 	if (!avail_qs)
 		num_txq = 0;
 	else if (num_txq > avail_qs)
 		num_txq = rounddown_pow_of_two(avail_qs);
 
 	num_rxq = min_t(u16, num_msix_per_vf - ICE_NONQ_VECS_VF,
-			ICE_MAX_QS_PER_VF_VCV1);
+			ICE_MAX_QS_PER_VF);
 	avail_qs = ice_get_avail_rxq_count(pf) / num_vfs;
 	if (!avail_qs)
 		num_rxq = 0;
diff --git a/drivers/net/ethernet/intel/ice/ice_vf_lib.c b/drivers/net/ethernet/intel/ice/ice_vf_lib.c
index be87a83d2599..320b393ddaaf 100644
--- a/drivers/net/ethernet/intel/ice/ice_vf_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_vf_lib.c
@@ -528,8 +528,8 @@ static void ice_vf_rebuild_host_cfg(struct ice_vf *vf)
 static void ice_set_vf_state_qs_dis(struct ice_vf *vf)
 {
 	/* Clear Rx/Tx enabled queues flag */
-	bitmap_zero(vf->txq_ena, ICE_MAX_QS_PER_VF_VCV1);
-	bitmap_zero(vf->rxq_ena, ICE_MAX_QS_PER_VF_VCV1);
+	bitmap_zero(vf->txq_ena, ICE_MAX_QS_PER_VF);
+	bitmap_zero(vf->rxq_ena, ICE_MAX_QS_PER_VF);
 	clear_bit(ICE_VF_STATE_QS_ENA, vf->vf_states);
 }
 
@@ -1243,8 +1243,8 @@ bool ice_is_vf_trusted(struct ice_vf *vf)
  */
 bool ice_vf_has_no_qs_ena(struct ice_vf *vf)
 {
-	return bitmap_empty(vf->rxq_ena, ICE_MAX_QS_PER_VF_VCV1) &&
-	       bitmap_empty(vf->txq_ena, ICE_MAX_QS_PER_VF_VCV1);
+	return bitmap_empty(vf->rxq_ena, ICE_MAX_QS_PER_VF) &&
+	       bitmap_empty(vf->txq_ena, ICE_MAX_QS_PER_VF);
 }
 
 /**
diff --git a/drivers/net/ethernet/intel/ice/virt/queues.c b/drivers/net/ethernet/intel/ice/virt/queues.c
index 2667634e3c8c..a8a2f5e5b322 100644
--- a/drivers/net/ethernet/intel/ice/virt/queues.c
+++ b/drivers/net/ethernet/intel/ice/virt/queues.c
@@ -681,7 +681,7 @@ int ice_vc_cfg_q_bw(struct ice_vf *vf, u8 *msg)
 		goto err;
 	}
 
-	if (qbw->num_queues > ICE_MAX_QS_PER_VF_VCV1 ||
+	if (qbw->num_queues > ICE_MAX_QS_PER_VF ||
 	    qbw->num_queues > min_t(u16, vsi->alloc_txq, vsi->alloc_rxq)) {
 		dev_err(ice_pf_to_dev(vf->pf), "VF-%d trying to configure more than allocated number of queues: %d\n",
 			vf->vf_id, min_t(u16, vsi->alloc_txq, vsi->alloc_rxq));
@@ -773,7 +773,7 @@ int ice_vc_cfg_q_quanta(struct ice_vf *vf, u8 *msg)
 		goto err;
 	}
 
-	if (end_qid > ICE_MAX_QS_PER_VF_VCV1 ||
+	if (end_qid > ICE_MAX_QS_PER_VF ||
 	    end_qid > min_t(u16, vsi->alloc_txq, vsi->alloc_rxq)) {
 		dev_err(ice_pf_to_dev(vf->pf), "VF-%d trying to configure more than allocated number of queues: %d\n",
 			vf->vf_id, min_t(u16, vsi->alloc_txq, vsi->alloc_rxq));
@@ -822,9 +822,9 @@ int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
 	struct virtchnl_vsi_queue_config_info *qci =
 	    (struct virtchnl_vsi_queue_config_info *)msg;
 	struct virtchnl_queue_pair_info *qpi;
+	int i, q_idx, last_valid = -1;
 	struct ice_pf *pf = vf->pf;
 	struct ice_vsi *vsi;
-	int i = -1, q_idx;
 	bool ena_ts;
 	u8 act_prt;
 
@@ -841,7 +841,7 @@ int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
 	if (!vsi)
 		goto error_param;
 
-	if (qci->num_queue_pairs > ICE_MAX_QS_PER_VF_VCV1 ||
+	if (qci->num_queue_pairs > ICE_MAX_QS_PER_VF ||
 	    qci->num_queue_pairs > min_t(u16, vsi->alloc_txq, vsi->alloc_rxq)) {
 		dev_err(ice_pf_to_dev(pf), "VF-%d requesting more than supported number of queues: %d\n",
 			vf->vf_id, min_t(u16, vsi->alloc_txq, vsi->alloc_rxq));
@@ -877,6 +877,7 @@ int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
 		if (q_idx >= vsi->alloc_txq || q_idx >= vsi->alloc_rxq) {
 			goto error_param;
 		}
+		last_valid = i;
 
 		/* copy Tx queue info from VF into VSI */
 		if (qpi->txq.ring_len > 0) {
@@ -967,13 +968,14 @@ int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
 				     VIRTCHNL_STATUS_SUCCESS, NULL, 0);
 error_param:
 	/* disable whatever we can */
-	for (; i >= 0; i--) {
-		if (ice_vsi_ctrl_one_rx_ring(vsi, false, i, true))
+	for (; last_valid >= 0; last_valid--) {
+		q_idx = qci->qpair[last_valid].rxq.queue_id;
+		if (ice_vsi_ctrl_one_rx_ring(vsi, false, q_idx, true))
 			dev_err(ice_pf_to_dev(pf), "VF-%d could not disable RX queue %d\n",
-				vf->vf_id, i);
-		if (ice_vf_vsi_dis_single_txq(vf, vsi, i))
+				vf->vf_id, q_idx);
+		if (ice_vf_vsi_dis_single_txq(vf, vsi, q_idx))
 			dev_err(ice_pf_to_dev(pf), "VF-%d could not disable TX queue %d\n",
-				vf->vf_id, i);
+				vf->vf_id, q_idx);
 	}
 
 	ice_lag_complete_vf_reset(pf->lag, act_prt);
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH net-next v7 07/15] iavf: extend iavf_configure_queues() to support more queues
  2026-11-21 22:55 [PATCH net-next v7 00/15] devlink, mlx5, iavf, ice: XLVF for iavf Przemek Kitszel
                   ` (5 preceding siblings ...)
  2026-11-21 22:55 ` [PATCH net-next v7 06/15] ice: bump to 256qs for VF Przemek Kitszel
@ 2026-11-21 22:55 ` Przemek Kitszel
  2026-11-21 22:55 ` [PATCH net-next v7 08/15] iavf: temporary rename of IAVF_MAX_REQ_QUEUES to IAVF_MAX_REQ_QUEUES_VCV1 Przemek Kitszel
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 28+ messages in thread
From: Przemek Kitszel @ 2026-11-21 22:55 UTC (permalink / raw)
  To: netdev, Jakub Kicinski, Jiri Pirko
  Cc: Tony Nguyen, Aleksandr Loktionov, Michal Schmidt, edumazet, horms,
	pabeni, davem, Jonathan Corbet, skhan, rdunlap, andrew+netdev,
	saeedm, tariqt, leon, mbloch, jacob.e.keller, jedrzej.jagielski,
	anzaki, brett.creeley, ohartoov, Petr Oros, Donald Hunter,
	Przemek Kitszel

Extend iavf_configure_queues() to support more queue pairs than fit
into a single virtchnl message (62).
Virtchnl opcode used was already generic, but we have just not needed
more than one message before.

Send one message per call, and keep IAVF_FLAG_AQ_CONFIGURE_QUEUES set
until all queue pairs are sent, similar to what iavf_add_ether_addrs()
does for MAC filters. The next message goes out on a later watchdog
run, once the reply to the previous one has cleared current_op, as for
any other op. Stop sending on a PF NACK.

Add helper, iavf_max_vc_entries(), that determines how many entries we
could fit into virtchnl message (ending by flex array member). Will be
also used on another op later in this series.

Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
---
v4:
 * send one message per watchdog run, instead of polling for the reply
   to each one with a 1s timeout, which could resend the whole config
   after a late ACK or NACK, and could take a stale reply for the
   awaited one (Sashiko)
 * stop sending the rest on a PF NACK, in iavf_virtchnl_completion()

v2:
 * fix typo (Sashiko)
 * abort iavf_configure_queues() at error (Sashiko)
 * report send and poll failures with dev_err(), they are not
   recoverable here (me)
 * cast via uintptr_t in iavf_match_vc_op_cb(), for clang W=1
   -Wpointer-to-enum-cast
 * commit message: the limit is the number of queue pairs that fit
   into a single virtchnl message (62), not 31
 * commit message: describe the switch to a synchronous op (Sashiko)
 * stop at PF NACK (Sashiko)
 * on timeout keep current_op and IAVF_FLAG_AQ_CONFIGURE_QUEUES set
   until the late reply arrives, instead of resending right away;
   clear both on other errors (no retry) (Sashiko)
 * fix dev_err() continuation alignment (Sashiko)
---
 drivers/net/ethernet/intel/iavf/iavf.h        |  2 ++
 drivers/net/ethernet/intel/iavf/iavf_main.c   |  1 +
 .../net/ethernet/intel/iavf/iavf_virtchnl.c   | 25 ++++++++++++++-----
 3 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/intel/iavf/iavf.h b/drivers/net/ethernet/intel/iavf/iavf.h
index d174202bcd79..aac942ffae43 100644
--- a/drivers/net/ethernet/intel/iavf/iavf.h
+++ b/drivers/net/ethernet/intel/iavf/iavf.h
@@ -269,6 +269,8 @@ struct iavf_adapter {
 	u8 rxdid;
 	int num_active_queues;
 	int num_req_queues;
+	/* queue pairs sent so far, for ops that take more than one message */
+	int cfg_qps_sent;
 
 	/* TX */
 	struct iavf_ring *tx_rings;
diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
index c7b12de63c2f..1057c6158caa 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
@@ -1258,6 +1258,7 @@ static void iavf_configure(struct iavf_adapter *adapter)
 
 	iavf_configure_tx(adapter);
 	iavf_configure_rx(adapter);
+	adapter->cfg_qps_sent = 0;
 	adapter->aq_required |= IAVF_FLAG_AQ_CONFIGURE_QUEUES;
 
 	for (i = 0; i < adapter->num_active_queues; i++) {
diff --git a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
index 5578525d550e..6113541527d4 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
@@ -8,6 +8,11 @@
 #include "iavf_ptp.h"
 #include "iavf_prototype.h"
 
+/* how many Flex Array Member entries do fit into VC message of type *ptr */
+#define iavf_max_vc_entries(ptr, flex_member) \
+	((IAVF_MAX_AQ_BUF_SIZE - virtchnl_struct_size(ptr, flex_member, 1)) / \
+	 sizeof(ptr->flex_member[0]) + 1)
+
 /**
  * iavf_send_pf_msg
  * @adapter: adapter structure
@@ -375,11 +380,12 @@ int iavf_get_vf_ptp_caps(struct iavf_adapter *adapter)
 void iavf_configure_queues(struct iavf_adapter *adapter)
 {
 	struct virtchnl_vsi_queue_config_info *vqci;
-	int pairs = adapter->num_active_queues;
 	struct virtchnl_queue_pair_info *vqpi;
+	int first = adapter->cfg_qps_sent;
 	u32 i, max_frame;
 	u8 rx_flags = 0;
 	size_t len;
+	int pairs;
 
 	max_frame = LIBIE_MAX_RX_FRM_LEN(adapter->rx_rings->pp->p.offset);
 	max_frame = min_not_zero(adapter->vf_res->max_mtu, max_frame);
@@ -391,6 +397,8 @@ void iavf_configure_queues(struct iavf_adapter *adapter)
 		return;
 	}
 	adapter->current_op = VIRTCHNL_OP_CONFIG_VSI_QUEUES;
+	pairs = min_t(int, adapter->num_active_queues - first,
+		      iavf_max_vc_entries(vqci, qpair));
 	len = virtchnl_struct_size(vqci, qpair, pairs);
 	vqci = kzalloc(len, GFP_KERNEL);
 	if (!vqci)
@@ -402,10 +410,7 @@ void iavf_configure_queues(struct iavf_adapter *adapter)
 	vqci->vsi_id = adapter->vsi_res->vsi_id;
 	vqci->num_queue_pairs = pairs;
 	vqpi = vqci->qpair;
-	/* Size check is not needed here - HW max is 16 queue pairs, and we
-	 * can fit info for 31 of them into the AQ buffer before it overflows.
-	 */
-	for (i = 0; i < pairs; i++) {
+	for (i = first; i < first + pairs; i++) {
 		vqpi->txq.vsi_id = vqci->vsi_id;
 		vqpi->txq.queue_id = i;
 		vqpi->txq.ring_len = adapter->tx_rings[i].count;
@@ -425,7 +430,9 @@ void iavf_configure_queues(struct iavf_adapter *adapter)
 		vqpi++;
 	}
 
-	adapter->aq_required &= ~IAVF_FLAG_AQ_CONFIGURE_QUEUES;
+	adapter->cfg_qps_sent += pairs;
+	if (adapter->cfg_qps_sent == adapter->num_active_queues)
+		adapter->aq_required &= ~IAVF_FLAG_AQ_CONFIGURE_QUEUES;
 	iavf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_VSI_QUEUES,
 			 (u8 *)vqci, len);
 	kfree(vqci);
@@ -2551,6 +2558,12 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,
 			dev_warn(&adapter->pdev->dev, "Failed to Config Queue BW, error %s\n",
 				 iavf_stat_str(&adapter->hw, v_retval));
 			break;
+		case VIRTCHNL_OP_CONFIG_VSI_QUEUES:
+			dev_err(&adapter->pdev->dev, "Failed to configure queues, error %s\n",
+				iavf_stat_str(&adapter->hw, v_retval));
+			/* don't send the remaining queue pairs */
+			adapter->aq_required &= ~IAVF_FLAG_AQ_CONFIGURE_QUEUES;
+			break;
 		default:
 			dev_err(&adapter->pdev->dev, "PF returned error %d (%s) to our request %d\n",
 				v_retval, iavf_stat_str(&adapter->hw, v_retval),
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH net-next v7 08/15] iavf: temporary rename of IAVF_MAX_REQ_QUEUES to IAVF_MAX_REQ_QUEUES_VCV1
  2026-11-21 22:55 [PATCH net-next v7 00/15] devlink, mlx5, iavf, ice: XLVF for iavf Przemek Kitszel
                   ` (6 preceding siblings ...)
  2026-11-21 22:55 ` [PATCH net-next v7 07/15] iavf: extend iavf_configure_queues() to support more queues Przemek Kitszel
@ 2026-11-21 22:55 ` Przemek Kitszel
  2026-11-21 22:55 ` [PATCH net-next v7 09/15] iavf: increase max number of queues to 256 Przemek Kitszel
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 28+ messages in thread
From: Przemek Kitszel @ 2026-11-21 22:55 UTC (permalink / raw)
  To: netdev, Jakub Kicinski, Jiri Pirko
  Cc: Tony Nguyen, Aleksandr Loktionov, Michal Schmidt, edumazet, horms,
	pabeni, davem, Jonathan Corbet, skhan, rdunlap, andrew+netdev,
	saeedm, tariqt, leon, mbloch, jacob.e.keller, jedrzej.jagielski,
	anzaki, brett.creeley, ohartoov, Petr Oros, Donald Hunter,
	Przemek Kitszel

Rename IAVF_MAX_REQ_QUEUES to IAVF_MAX_REQ_QUEUES_VCV1, in preparation for
the next patch that will extend the max to 256, using old value of 16 for
the "v1" variant of virtchnl opcodes.

Suggested-by: Jedrzej Jagielski <jedrzej.jagielski@intel.com>
Suggested-by: Jacob Keller <jacob.e.keller@intel.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
---
 drivers/net/ethernet/intel/iavf/iavf.h          |  3 ++-
 drivers/net/ethernet/intel/iavf/iavf_main.c     |  2 +-
 drivers/net/ethernet/intel/iavf/iavf_virtchnl.c | 10 +++++-----
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/intel/iavf/iavf.h b/drivers/net/ethernet/intel/iavf/iavf.h
index aac942ffae43..6af196467c5d 100644
--- a/drivers/net/ethernet/intel/iavf/iavf.h
+++ b/drivers/net/ethernet/intel/iavf/iavf.h
@@ -87,7 +87,8 @@ struct iavf_vsi {
 #define IAVF_TX_DESC(R, i) (&(((struct iavf_tx_desc *)((R)->desc))[i]))
 #define IAVF_TX_CTXTDESC(R, i) \
 	(&(((struct iavf_tx_context_desc *)((R)->desc))[i]))
-#define IAVF_MAX_REQ_QUEUES 16
+/* for "old" virtchnl opcodes that accept up to 16 queues */
+#define IAVF_MAX_REQ_QUEUES_VCV1	16
 
 #define IAVF_HKEY_ARRAY_SIZE ((IAVF_VFQF_HKEY_MAX_INDEX + 1) * 4)
 #define IAVF_HLUT_ARRAY_SIZE ((IAVF_VFQF_HLUT_MAX_INDEX + 1) * 4)
diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
index 1057c6158caa..4361ac225f47 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
@@ -5478,7 +5478,7 @@ static int iavf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	pci_set_master(pdev);
 
 	netdev = alloc_etherdev_mq(sizeof(struct iavf_adapter),
-				   IAVF_MAX_REQ_QUEUES);
+				   IAVF_MAX_REQ_QUEUES_VCV1);
 	if (!netdev) {
 		err = -ENOMEM;
 		goto err_alloc_etherdev;
diff --git a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
index 6113541527d4..68a47bdf3dcc 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
@@ -260,19 +260,19 @@ int iavf_send_vf_ptp_caps_msg(struct iavf_adapter *adapter)
  **/
 static void iavf_validate_num_queues(struct iavf_adapter *adapter)
 {
-	if (adapter->vf_res->num_queue_pairs > IAVF_MAX_REQ_QUEUES) {
+	if (adapter->vf_res->num_queue_pairs > IAVF_MAX_REQ_QUEUES_VCV1) {
 		struct virtchnl_vsi_resource *vsi_res;
 		int i;
 
 		dev_info(&adapter->pdev->dev, "Received %d queues, but can only have a max of %d\n",
 			 adapter->vf_res->num_queue_pairs,
-			 IAVF_MAX_REQ_QUEUES);
+			 IAVF_MAX_REQ_QUEUES_VCV1);
 		dev_info(&adapter->pdev->dev, "Fixing by reducing queues to %d\n",
-			 IAVF_MAX_REQ_QUEUES);
-		adapter->vf_res->num_queue_pairs = IAVF_MAX_REQ_QUEUES;
+			 IAVF_MAX_REQ_QUEUES_VCV1);
+		adapter->vf_res->num_queue_pairs = IAVF_MAX_REQ_QUEUES_VCV1;
 		for (i = 0; i < adapter->vf_res->num_vsis; i++) {
 			vsi_res = &adapter->vf_res->vsi_res[i];
-			vsi_res->num_queue_pairs = IAVF_MAX_REQ_QUEUES;
+			vsi_res->num_queue_pairs = IAVF_MAX_REQ_QUEUES_VCV1;
 		}
 	}
 }
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH net-next v7 09/15] iavf: increase max number of queues to 256
  2026-11-21 22:55 [PATCH net-next v7 00/15] devlink, mlx5, iavf, ice: XLVF for iavf Przemek Kitszel
                   ` (7 preceding siblings ...)
  2026-11-21 22:55 ` [PATCH net-next v7 08/15] iavf: temporary rename of IAVF_MAX_REQ_QUEUES to IAVF_MAX_REQ_QUEUES_VCV1 Przemek Kitszel
@ 2026-11-21 22:55 ` Przemek Kitszel
  2026-11-24 21:57   ` netdev-bot+sashiko
  2026-11-21 22:55 ` [PATCH net-next v7 10/15] iavf: use new opcodes to request more than 16 queues Przemek Kitszel
                   ` (6 subsequent siblings)
  15 siblings, 1 reply; 28+ messages in thread
From: Przemek Kitszel @ 2026-11-21 22:55 UTC (permalink / raw)
  To: netdev, Jakub Kicinski, Jiri Pirko
  Cc: Tony Nguyen, Aleksandr Loktionov, Michal Schmidt, edumazet, horms,
	pabeni, davem, Jonathan Corbet, skhan, rdunlap, andrew+netdev,
	saeedm, tariqt, leon, mbloch, jacob.e.keller, jedrzej.jagielski,
	anzaki, brett.creeley, ohartoov, Petr Oros, Donald Hunter,
	Przemek Kitszel

Increase the max number of queues that driver will handle to 256.
Use old legacy limit in the virtchnl handling of iavf_map_queues().
Still accept at most 16 queue pairs from PF, as only the new opcodes,
added later in the series, can use more.
Limit the number of queue vectors to 64, as VF interrupt registers
cover no more.

The netdev is allocated at probe, before the PF tells the VF how many
queues it may use, so it now always has 256 Tx and Rx queues. Whatever
is sized by num_tx_queues grows 16 times: the default qdisc of an up VF
has a child per Tx queue (about 6 MB with pfifo_fast, 17 MB with
fq_codel), and ethtool -S lists 256 queue pairs, unused ones as zeros.

Reviewed-by: Jedrzej Jagielski <jedrzej.jagielski@intel.com>
Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
---
v7:
 * program ITR of all vectors via VFINT_ITRN_64 when the VF has more
   than 16 of them, not just of vectors 16..63, so a VF uses one
   register layout; XL710/X722 VFs have no VFINT_ITRN_64, but neither
   more than 16 vectors (Sashiko)
 * still accept at most 16 queue pairs from PF, as only the opcodes of
   "iavf: use new opcodes to request more than 16 queues" can use more
   (me)

v5:
 * cap the legacy VIRTCHNL_OP_{EN,DIS}ABLE_QUEUES bitmaps at 16 queues,
   as done for the IRQ map: PF rejects a wider mask, and BIT() above 63
   queues is undefined (me)

v4:
 * limit MSI-X budget to 64 queue vectors, VFINT_ITRN_64 and
   VFINT_DYN_CTLN1 have no room for more (Sashiko)
 * change ADQ total_qps to u16, a sum of 256 queues wrapped to 0 in u8
   (Sashiko)
 * commit message: mention the cost of the netdev sized for 256 queues
   (Sashiko)
 * program ITR of vectors 16..63 via VFINT_ITRN_64, VFINT_ITRN1 has room
   for 16 vectors only (Sashiko)
 * revert dropping of "_i=0...15" from IAVF_Q{R,T}X_TAIL1() comments

v2:
 * change iavf_q_vector::num_ringpairs to u16 (Sashiko)
 * drop the stale "_i=0...15" range from IAVF_Q{R,T}X_TAIL1()
---
 drivers/net/ethernet/intel/iavf/iavf.h        | 10 ++++---
 .../net/ethernet/intel/iavf/iavf_register.h   |  2 ++
 drivers/net/ethernet/intel/iavf/iavf_main.c   | 27 ++++++++++++++-----
 .../net/ethernet/intel/iavf/iavf_virtchnl.c   | 11 +++++---
 4 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/intel/iavf/iavf.h b/drivers/net/ethernet/intel/iavf/iavf.h
index 6af196467c5d..c8ef153e405b 100644
--- a/drivers/net/ethernet/intel/iavf/iavf.h
+++ b/drivers/net/ethernet/intel/iavf/iavf.h
@@ -87,8 +87,10 @@ struct iavf_vsi {
 #define IAVF_TX_DESC(R, i) (&(((struct iavf_tx_desc *)((R)->desc))[i]))
 #define IAVF_TX_CTXTDESC(R, i) \
 	(&(((struct iavf_tx_context_desc *)((R)->desc))[i]))
+
 /* for "old" virtchnl opcodes that accept up to 16 queues */
 #define IAVF_MAX_REQ_QUEUES_VCV1	16
+#define IAVF_MAX_REQ_QUEUES		256
 
 #define IAVF_HKEY_ARRAY_SIZE ((IAVF_VFQF_HKEY_MAX_INDEX + 1) * 4)
 #define IAVF_HLUT_ARRAY_SIZE ((IAVF_VFQF_HLUT_MAX_INDEX + 1) * 4)
@@ -108,9 +110,9 @@ struct iavf_q_vector {
 	struct napi_struct napi;
 	struct iavf_ring_container rx;
 	struct iavf_ring_container tx;
-	u32 ring_mask;
+	DECLARE_BITMAP(ring_mask, IAVF_MAX_REQ_QUEUES);
 	u8 itr_countdown;	/* when 0 should adjust adaptive ITR */
-	u8 num_ringpairs;	/* total number of ring pairs in vector */
+	u16 num_ringpairs;	/* total number of ring pairs in vector */
 	u16 v_idx;		/* index in the vsi->q_vector array. */
 	u16 reg_idx;		/* register index of the interrupt */
 	char name[IFNAMSIZ + 15];
@@ -134,6 +136,8 @@ struct iavf_q_vector {
 
 #define MIN_MSIX_Q_VECTORS 1
 #define MIN_MSIX_COUNT (MIN_MSIX_Q_VECTORS + NONQ_VECS)
+/* VF interrupt registers cover 64 queue vectors */
+#define MAX_MSIX_Q_VECTORS 64
 
 #define IAVF_QUEUE_END_OF_LIST 0x7FF
 #define IAVF_FREE_VECTOR 0x7FFF
@@ -182,7 +186,7 @@ enum iavf_tc_state_t {
 struct iavf_channel_config {
 	struct virtchnl_channel_info ch_info[IAVF_MAX_TRAFFIC_CLASS];
 	enum iavf_tc_state_t state;
-	u8 total_qps;
+	u16 total_qps;
 };
 
 /* State of cloud filter */
diff --git a/drivers/net/ethernet/intel/iavf/iavf_register.h b/drivers/net/ethernet/intel/iavf/iavf_register.h
index a19e88898a0b..47fd2d3f5e4b 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_register.h
+++ b/drivers/net/ethernet/intel/iavf/iavf_register.h
@@ -56,6 +56,8 @@
 #define IAVF_VFINT_ICR0_ENA1_RSVD_SHIFT 31
 #define IAVF_VFINT_ICR01 0x00004800 /* Reset: CORER */
 #define IAVF_VFINT_ITRN1(_i, _INTVF) (0x00002800 + ((_i) * 64 + (_INTVF) * 4)) /* _i=0...2, _INTVF=0...15 */ /* Reset: VFR */
+#define IAVF_VFINT_ITRN_64(_i, _INTVF) \
+	(0x00002C00 + ((_i) * 256 + (_INTVF) * 4)) /* _i=0...2, _INTVF=0...63 */
 #define IAVF_QRX_TAIL1(_Q) (0x00002000 + ((_Q) * 4)) /* _i=0...15 */ /* Reset: CORER */
 #define IAVF_QTX_TAIL1(_Q) (0x00000000 + ((_Q) * 4)) /* _i=0...15 */ /* Reset: PFR */
 #define IAVF_VFQF_HENA(_i) (0x0000C400 + ((_i) * 4)) /* _i=0...1 */ /* Reset: CORER */
diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
index 4361ac225f47..a2aef35c0a07 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
@@ -419,6 +419,18 @@ static irqreturn_t iavf_msix_clean_rings(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
+/* VFINT_ITRN1 fits 16 vectors only, VFINT_ITRN_64 aliases it for up to 64,
+ * but exists only on VFs that can have more than 16 vectors
+ */
+static u32 iavf_itrn_reg(struct iavf_adapter *adapter,
+			 enum iavf_dyn_idx_t itr_idx, u16 reg_idx)
+{
+	if (adapter->num_msix_vectors - NONQ_VECS <= 16)
+		return IAVF_VFINT_ITRN1(itr_idx, reg_idx);
+
+	return IAVF_VFINT_ITRN_64(itr_idx, reg_idx);
+}
+
 /**
  * iavf_map_vector_to_rxq - associate irqs with rx queues
  * @adapter: board private structure
@@ -439,8 +451,8 @@ iavf_map_vector_to_rxq(struct iavf_adapter *adapter, int v_idx, int r_idx)
 	q_vector->rx.count++;
 	q_vector->rx.next_update = jiffies + 1;
 	q_vector->rx.target_itr = ITR_TO_REG(rx_ring->itr_setting);
-	q_vector->ring_mask |= BIT(r_idx);
-	wr32(hw, IAVF_VFINT_ITRN1(IAVF_RX_ITR, q_vector->reg_idx),
+	set_bit(r_idx, q_vector->ring_mask);
+	wr32(hw, iavf_itrn_reg(adapter, IAVF_RX_ITR, q_vector->reg_idx),
 	     q_vector->rx.current_itr >> 1);
 	q_vector->rx.current_itr = q_vector->rx.target_itr;
 }
@@ -466,7 +478,7 @@ iavf_map_vector_to_txq(struct iavf_adapter *adapter, int v_idx, int t_idx)
 	q_vector->tx.next_update = jiffies + 1;
 	q_vector->tx.target_itr = ITR_TO_REG(tx_ring->itr_setting);
 	q_vector->num_ringpairs++;
-	wr32(hw, IAVF_VFINT_ITRN1(IAVF_TX_ITR, q_vector->reg_idx),
+	wr32(hw, iavf_itrn_reg(adapter, IAVF_TX_ITR, q_vector->reg_idx),
 	     q_vector->tx.target_itr >> 1);
 	q_vector->tx.current_itr = q_vector->tx.target_itr;
 }
@@ -1661,9 +1673,9 @@ static int iavf_set_interrupt_capability(struct iavf_adapter *adapter)
 	/* It's easy to be greedy for MSI-X vectors, but it really doesn't do
 	 * us much good if we have more vectors than CPUs. However, we already
 	 * limit the total number of queues by the number of CPUs so we do not
-	 * need any further limiting here.
+	 * need any further limiting here, except for the VF registers.
 	 */
-	v_budget = min_t(int, pairs + NONQ_VECS,
+	v_budget = min_t(int, min(pairs, MAX_MSIX_Q_VECTORS) + NONQ_VECS,
 			 (int)adapter->vf_res->max_vectors);
 
 	adapter->msix_entries = kzalloc_objs(struct msix_entry, v_budget);
@@ -3841,9 +3853,10 @@ static int __iavf_setup_tc(struct net_device *netdev, void *type_data)
 	struct tc_mqprio_qopt_offload *mqprio_qopt = type_data;
 	struct iavf_adapter *adapter = netdev_priv(netdev);
 	struct virtchnl_vf_resource *vfres = adapter->vf_res;
-	u8 num_tc = 0, total_qps = 0;
 	int ret = 0, netdev_tc = 0;
+	u16 total_qps = 0;
 	u64 max_tx_rate;
+	u8 num_tc = 0;
 	u16 mode;
 	int i;
 
@@ -5478,7 +5491,7 @@ static int iavf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 	pci_set_master(pdev);
 
 	netdev = alloc_etherdev_mq(sizeof(struct iavf_adapter),
-				   IAVF_MAX_REQ_QUEUES_VCV1);
+				   IAVF_MAX_REQ_QUEUES);
 	if (!netdev) {
 		err = -ENOMEM;
 		goto err_alloc_etherdev;
diff --git a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
index 68a47bdf3dcc..151824102acd 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
@@ -456,7 +456,8 @@ void iavf_enable_queues(struct iavf_adapter *adapter)
 	}
 	adapter->current_op = VIRTCHNL_OP_ENABLE_QUEUES;
 	vqs.vsi_id = adapter->vsi_res->vsi_id;
-	vqs.tx_queues = BIT(adapter->num_active_queues) - 1;
+	vqs.tx_queues = BIT(min(adapter->num_active_queues,
+				IAVF_MAX_REQ_QUEUES_VCV1)) - 1;
 	vqs.rx_queues = vqs.tx_queues;
 	adapter->aq_required &= ~IAVF_FLAG_AQ_ENABLE_QUEUES;
 	iavf_send_pf_msg(adapter, VIRTCHNL_OP_ENABLE_QUEUES,
@@ -481,7 +482,8 @@ void iavf_disable_queues(struct iavf_adapter *adapter)
 	}
 	adapter->current_op = VIRTCHNL_OP_DISABLE_QUEUES;
 	vqs.vsi_id = adapter->vsi_res->vsi_id;
-	vqs.tx_queues = BIT(adapter->num_active_queues) - 1;
+	vqs.tx_queues = BIT(min(adapter->num_active_queues,
+				IAVF_MAX_REQ_QUEUES_VCV1)) - 1;
 	vqs.rx_queues = vqs.tx_queues;
 	adapter->aq_required &= ~IAVF_FLAG_AQ_DISABLE_QUEUES;
 	iavf_send_pf_msg(adapter, VIRTCHNL_OP_DISABLE_QUEUES,
@@ -526,8 +528,9 @@ void iavf_map_queues(struct iavf_adapter *adapter)
 
 		vecmap->vsi_id = adapter->vsi_res->vsi_id;
 		vecmap->vector_id = v_idx + NONQ_VECS;
-		vecmap->txq_map = q_vector->ring_mask;
-		vecmap->rxq_map = q_vector->ring_mask;
+		vecmap->txq_map = bitmap_read(q_vector->ring_mask, 0,
+					      IAVF_MAX_REQ_QUEUES_VCV1);
+		vecmap->rxq_map = vecmap->txq_map;
 		vecmap->rxitr_idx = IAVF_RX_ITR;
 		vecmap->txitr_idx = IAVF_TX_ITR;
 	}
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH net-next v7 10/15] iavf: use new opcodes to request more than 16 queues
  2026-11-21 22:55 [PATCH net-next v7 00/15] devlink, mlx5, iavf, ice: XLVF for iavf Przemek Kitszel
                   ` (8 preceding siblings ...)
  2026-11-21 22:55 ` [PATCH net-next v7 09/15] iavf: increase max number of queues to 256 Przemek Kitszel
@ 2026-11-21 22:55 ` Przemek Kitszel
  2026-11-24 21:57   ` netdev-bot+sashiko
  2026-11-21 22:55 ` [PATCH net-next v7 11/15] ice: introduce handling of virtchnl LARGE VF opcodes Przemek Kitszel
                   ` (5 subsequent siblings)
  15 siblings, 1 reply; 28+ messages in thread
From: Przemek Kitszel @ 2026-11-21 22:55 UTC (permalink / raw)
  To: netdev, Jakub Kicinski, Jiri Pirko
  Cc: Tony Nguyen, Aleksandr Loktionov, Michal Schmidt, edumazet, horms,
	pabeni, davem, Jonathan Corbet, skhan, rdunlap, andrew+netdev,
	saeedm, tariqt, leon, mbloch, jacob.e.keller, jedrzej.jagielski,
	anzaki, brett.creeley, ohartoov, Petr Oros, Donald Hunter,
	Przemek Kitszel

From: Ahmed Zaki <ahmed.zaki@intel.com>

Legacy virtchnl opcodes select queues by fixed width bitmaps: u32 for
VIRTCHNL_OP_ENABLE_QUEUES and VIRTCHNL_OP_DISABLE_QUEUES, u16 for
VIRTCHNL_OP_CONFIG_IRQ_MAP. Define new OP codes in order to enable
the VF to use a variable number of queues.

First the new capability VIRTCHNL_VF_LARGE_NUM_QPAIRS is defined. Only
if this cap is negotiated, the VF is allowed to use the new OP codes.
Without it, the VF still takes at most 16 queue pairs from PF.

The VIRTCHNL_OP_GET_MAX_RSS_QREGION is exchanged with the other extended
caps, like PTP, after the VF resource message is received.

With VIRTCHNL_VF_OFFLOAD_REQ_QUEUES negotiated too, iavf asks PF at init
for one queue pair per CPU, up to 256, when PF gave fewer. PF resets the
VF to grant it, so init takes one more VF reset then.

Enabling and disabling queues, and mapping queues to vectors is done
through the new VIRTCHNL_OP_ENABLE_QUEUES_V2,
VIRTCHNL_OP_DISABLE_QUEUES_V2, and VIRTCHNL_OP_MAP_QUEUE_VECTOR messages.
The queue to vector map may not fit into one message, so it is sent in
parts, one per watchdog run, as done for VIRTCHNL_OP_CONFIG_VSI_QUEUES.

Use the new iavf_request_queues() for ethtool -L.
It's not only for elegance, but it enables our brittle handcoded state
machine to go through requesting the queues before PF driver reallocates
queue-related arrays. This is done only with VIRTCHNL_VF_LARGE_NUM_QPAIRS,
and ethtool -L returns right after queuing the request, the watchdog
sends it once no other op is in flight: PF resets the VF to grant it,
a denial is only logged. ethtool -L fails with -EBUSY while PF has not
answered the previous request. A request is forgotten when init starts
over after PF stopped responding, and on a reset that does not reinit
the queues, as the previous reset has set them up already.

Signed-off-by: Ahmed Zaki <ahmed.zaki@intel.com>
Co-developed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
---
v7:
 * move the changes that apply to every PF to a new patch before this
   one, "iavf: keep RSS config across resets" (Jakub)
 * check the length of the VIRTCHNL_OP_GET_MAX_RSS_QREGION reply, and
   cap qregion_width at ilog2(IAVF_MAX_REQ_QUEUES), as BIT(width) is
   used as a queue count (Sashiko)
 * clear IAVF_FLAG_REINIT_MSIX_NEEDED also on a reset while down, it
   stayed set, and a later reset lost the channel count set while down
   (Sashiko)
 * ethtool -l: report the requested count also after the request is
   sent, until PF answers it (Sashiko)
 * commit message: describe the queue request at init, the 16 queue
   limit without VIRTCHNL_VF_LARGE_NUM_QPAIRS, when ethtool -L fails
   with -EBUSY, and when a queue request is forgotten (Sashiko)

v6:
 * ethtool -L: report the requested count until the watchdog sends the
   queue request, and drop the request on ethtool -L back to the active
   count; ethtool core skipped that as no change, and the stale request
   went out (Sashiko)
 * ethtool -L: request queues from PF only if
   VIRTCHNL_VF_OFFLOAD_REQ_QUEUES is negotiated too, as done at init;
   without it set channels locally, up to num_queue_pairs (Sashiko)

v5:
 * ethtool -L: validate rx, tx and other counts before returning early
   for an unchanged combined count; drop the cancel of a not yet sent
   queue request there, ethtool core doesn't call us without a change
   (Sashiko)
 * ethtool -L: keep the queue request pending until it is sent, it was
   dropped when sending failed, or on a VF reset that came first (me)
 * report the RX ring count limited to the PF RSS region, as
   iavf_fill_rss_lut() does, the default LUT made by ethtool core for
   ethtool -X was rejected by iavf_set_rxfh() (me)

v4:
 * iavf_map_queue_vector(): send one message per watchdog run, as
   iavf_configure_queues() does now, instead of polling for each reply
   with a 1s timeout (Sashiko)
 * stop sending the queue to vector map on a PF NACK, reported by
   iavf_virtchnl_completion()
 * refill the RSS LUT when the RSS region changes across a reset, as the
   LUT is filled before the VIRTCHNL_OP_GET_MAX_RSS_QREGION reply
   (Sashiko)
 * ethtool -L: let the watchdog send the queue request, instead of
   failing with -EBUSY whenever another op is in flight (e.g. GET_STATS);
   return -EBUSY only while PF has not answered the previous request
   (Sashiko)
 * init: check IAVF_VF_ARQLEN1 while waiting for the queue request
   outcome, as the event of the PF reset that grants it can be lost
   (Sashiko)
 * forget the queue request when init starts over after the PF stopped
   responding (Sashiko)
 * treat an error reply to a runtime queue request as a denial (Sashiko)
 * ethtool -X: reject LUT entries outside of the PF RSS region, as
   iavf_fill_rss_lut() does; comment that qregion_width 0 means the
   region is not known yet (Sashiko)
 * commit message: describe the iavf_parse_vf_resource_msg() changes
   that apply to every PF, the aq_wait_count reset, and the async
   ethtool -L (Sashiko)
 * drop num_req_queues on a reset that does not reinit queues, as the
   previous reset has set them up already; when PF lowers the limit
   right after granting the request (VF RSS LUT taken away just after
   ethtool -L), reinit quietly instead of reporting "Requested 64
   queues, but PF only gave us 16."
 * wait for the outcome of the queue request sent at init before other
   extended caps, as their polling dropped a PF denial and VF went on
   with the denied queue count; on denial ask for as many queues as PF
   can give, and allocate the granted count after the PF reset (Sashiko)
 * num_queue_pairs is the VF allocation also with
   VIRTCHNL_VF_LARGE_NUM_QPAIRS, as in legacy mode and with the
   out-of-tree drivers; ethtool -L max is the PF RSS region (Sashiko)
 * init: ask for more queues, up to one per CPU, and take the request as
   granted only when PF gives us that many, so an unrelated reset before
   the answer is not taken for a grant; on a denial that offers no more
   than we have, or on an error reply, go on with what we have (Sashiko)

v3:
 * auto-request queues in LARGE mode only at init, not on every reset,
   so ethtool -L setting is kept; do that after VSI and RSS fields are
   initialized, instead of returning early (Sashiko)

v2:
 * use proper IAVF_EXTENDED_CAP_SEND_RSS_QREGION flag when handling
   iavf_init_recv_max_rss_qregion() error (Sashiko)
 * update adapter->rss_{key,lut}_size and adapter->current_op only after
   successful allocation (Sashiko)
 * use the v2 opcodes to enable queues whenever
   VIRTCHNL_VF_LARGE_NUM_QPAIRS is negotiated, as for disabling (it was
   based on the queue count) (Sashiko)
 * set adapter->current_op in iavf_send_max_rss_qregion() (Sashiko)
 * iavf_set_channels(): stop clearing adapter->current_op before
   iavf_request_queues(), it was a debugging leftover (Sashiko)
 * iavf_request_queues(): undo current_op, num_req_queues and
   IAVF_FLAG_REINIT_ITR_NEEDED when sending the request fails (Sashiko)
 * iavf_map_queue_vector(): stop at the first send or poll error, and
   report it with dev_err()
 * request RSS qregion again after reset, together with other extended
   caps: send it from iavf_process_aq_command() and handle the reply in
   iavf_virtchnl_completion()
 * auto-request queues at init only once, and only with
   VIRTCHNL_VF_LARGE_NUM_QPAIRS (and VIRTCHNL_VF_OFFLOAD_REQ_QUEUES),
   where num_queue_pairs is the PF limit rather than the allocation;
   without it keep the previous behavior, with no extra VF reset
 * set channels locally (as before this series) unless
   VIRTCHNL_VF_LARGE_NUM_QPAIRS, so ethtool -L down no longer lowers
   max_combined for good
 * rebase over iavf_poll_virtchnl_response() changes
 * commit message: explain the limits of the legacy opcodes
 * iavf_map_queue_vector(): stop at PF NACK; on timeout keep current_op
   and IAVF_FLAG_AQ_MAP_VECTORS set until the late reply arrives, clear
   both on other errors (no retry), as in iavf_configure_queues()
   (Sashiko)

Sashiko suggestions I don't want to apply:
 S: non-atomic adapter->flags update in iavf_request_queues() races with
    lockless contexts like iavf_tx_timeout()
 me: pre-existing pattern in the whole iavf driver (iavf_set_channels()
     did the same before this series), out of scope here
---
 drivers/net/ethernet/intel/iavf/iavf.h        |  20 ++
 include/linux/net/intel/virtchnl.h            | 129 ++++++++-
 .../net/ethernet/intel/iavf/iavf_ethtool.c    |  60 +++-
 drivers/net/ethernet/intel/iavf/iavf_main.c   | 193 ++++++++++++-
 .../net/ethernet/intel/iavf/iavf_virtchnl.c   | 256 +++++++++++++++++-
 5 files changed, 630 insertions(+), 28 deletions(-)

diff --git a/drivers/net/ethernet/intel/iavf/iavf.h b/drivers/net/ethernet/intel/iavf/iavf.h
index c8ef153e405b..c86571971080 100644
--- a/drivers/net/ethernet/intel/iavf/iavf.h
+++ b/drivers/net/ethernet/intel/iavf/iavf.h
@@ -274,8 +274,11 @@ struct iavf_adapter {
 	u8 rxdid;
 	int num_active_queues;
 	int num_req_queues;
+	/* count for IAVF_FLAG_AQ_REQUEST_QUEUES */
+	int num_req_queues_next;
 	/* queue pairs sent so far, for ops that take more than one message */
 	int cfg_qps_sent;
+	int map_qps_sent;
 
 	/* TX */
 	struct iavf_ring *tx_rings;
@@ -350,13 +353,16 @@ struct iavf_adapter {
 #define IAVF_FLAG_AQ_GET_SUPPORTED_RXDIDS		BIT_ULL(42)
 #define IAVF_FLAG_AQ_GET_PTP_CAPS			BIT_ULL(43)
 #define IAVF_FLAG_AQ_SEND_PTP_CMD			BIT_ULL(44)
+#define IAVF_FLAG_AQ_GET_MAX_RSS_QREGION		BIT_ULL(45)
+#define IAVF_FLAG_AQ_REQUEST_QUEUES			BIT_ULL(46)
 
 	/* AQ messages that must be sent after IAVF_FLAG_AQ_GET_CONFIG, in
 	 * order to negotiated extended capabilities.
 	 */
 #define IAVF_FLAG_AQ_EXTENDED_CAPS			\
 	(IAVF_FLAG_AQ_GET_OFFLOAD_VLAN_V2_CAPS |	\
 	 IAVF_FLAG_AQ_GET_SUPPORTED_RXDIDS |		\
+	 IAVF_FLAG_AQ_GET_MAX_RSS_QREGION |		\
 	 IAVF_FLAG_AQ_GET_PTP_CAPS)
 
 	/* flags for processing extended capability messages during
@@ -373,12 +379,18 @@ struct iavf_adapter {
 #define IAVF_EXTENDED_CAP_RECV_RXDID			BIT_ULL(3)
 #define IAVF_EXTENDED_CAP_SEND_PTP			BIT_ULL(4)
 #define IAVF_EXTENDED_CAP_RECV_PTP			BIT_ULL(5)
+#define IAVF_EXTENDED_CAP_SEND_RSS_QREGION		BIT_ULL(6)
+#define IAVF_EXTENDED_CAP_RECV_RSS_QREGION		BIT_ULL(7)
+/* set only when iavf_parse_vf_resource_msg() requests queues */
+#define IAVF_EXTENDED_CAP_RECV_REQ_QUEUES		BIT_ULL(8)
 
 #define IAVF_EXTENDED_CAPS				\
 	(IAVF_EXTENDED_CAP_SEND_VLAN_V2 |		\
 	 IAVF_EXTENDED_CAP_RECV_VLAN_V2 |		\
 	 IAVF_EXTENDED_CAP_SEND_RXDID |			\
 	 IAVF_EXTENDED_CAP_RECV_RXDID |			\
+	 IAVF_EXTENDED_CAP_SEND_RSS_QREGION |		\
+	 IAVF_EXTENDED_CAP_RECV_RSS_QREGION |		\
 	 IAVF_EXTENDED_CAP_SEND_PTP |			\
 	 IAVF_EXTENDED_CAP_RECV_PTP)
 
@@ -418,6 +430,8 @@ struct iavf_adapter {
 #define RSS_REG(_a) (!((_a)->vf_res->vf_cap_flags & \
 		       (VIRTCHNL_VF_OFFLOAD_RSS_AQ | \
 			VIRTCHNL_VF_OFFLOAD_RSS_PF)))
+#define LARGE_NUM_QPAIRS_SUPPORT(_a) \
+	((_a)->vf_res->vf_cap_flags & VIRTCHNL_VF_LARGE_NUM_QPAIRS)
 #define VLAN_ALLOWED(_a) ((_a)->vf_res->vf_cap_flags & \
 			  VIRTCHNL_VF_OFFLOAD_VLAN)
 #define VLAN_V2_ALLOWED(_a) ((_a)->vf_res->vf_cap_flags & \
@@ -452,6 +466,7 @@ struct iavf_adapter {
 	struct virtchnl_vlan_caps vlan_v2_caps;
 	u64 supp_rxdids;
 	struct iavf_ptp ptp;
+	struct virtchnl_max_rss_qregion max_rss_qregion;
 	u16 msg_enable;
 	struct iavf_eth_stats current_stats;
 	struct virtchnl_qos_cap_list *qos_caps;
@@ -588,6 +603,9 @@ int iavf_send_vf_supported_rxdids_msg(struct iavf_adapter *adapter);
 int iavf_get_vf_supported_rxdids(struct iavf_adapter *adapter);
 int iavf_send_vf_ptp_caps_msg(struct iavf_adapter *adapter);
 int iavf_get_vf_ptp_caps(struct iavf_adapter *adapter);
+int iavf_send_max_rss_qregion(struct iavf_adapter *adapter);
+int iavf_get_max_rss_qregion(struct iavf_adapter *adapter);
+int iavf_get_req_queues_reply(struct iavf_adapter *adapter);
 void iavf_set_queue_vlan_tag_loc(struct iavf_adapter *adapter);
 u16 iavf_get_num_vlans_added(struct iavf_adapter *adapter);
 void iavf_irq_enable(struct iavf_adapter *adapter, bool flush);
@@ -602,6 +620,7 @@ void iavf_add_vlans(struct iavf_adapter *adapter);
 void iavf_del_vlans(struct iavf_adapter *adapter);
 void iavf_set_promiscuous(struct iavf_adapter *adapter);
 bool iavf_promiscuous_mode_changed(struct iavf_adapter *adapter);
+int iavf_request_queues(struct iavf_adapter *adapter, int num);
 void iavf_request_stats(struct iavf_adapter *adapter);
 int iavf_request_reset(struct iavf_adapter *adapter);
 void iavf_get_rss_hashcfg(struct iavf_adapter *adapter);
@@ -622,6 +641,7 @@ int iavf_poll_virtchnl_response(struct iavf_adapter *adapter,
 				const void *cond_data,
 				unsigned int timeout_ms);
 int iavf_config_rss(struct iavf_adapter *adapter);
+void iavf_fill_rss_lut(struct iavf_adapter *adapter);
 void iavf_cfg_queues_bw(struct iavf_adapter *adapter);
 void iavf_cfg_queues_quanta_size(struct iavf_adapter *adapter);
 void iavf_get_qos_caps(struct iavf_adapter *adapter);
diff --git a/include/linux/net/intel/virtchnl.h b/include/linux/net/intel/virtchnl.h
index 11bdab5522fd..90c5371c151b 100644
--- a/include/linux/net/intel/virtchnl.h
+++ b/include/linux/net/intel/virtchnl.h
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
-/* Copyright (c) 2013-2022, Intel Corporation. */
+/* Copyright (c) 2013-2026, Intel Corporation. */
 
 #ifndef _VIRTCHNL_H_
 #define _VIRTCHNL_H_
@@ -22,8 +22,7 @@
  * we must send all messages as "indirect", i.e. using an external buffer.
  *
  * All the VSI indexes are relative to the VF. Each VF can have maximum of
- * three VSIs. All the queue indexes are relative to the VSI.  Each VF can
- * have a maximum of sixteen queues for all of its VSIs.
+ * three VSIs. All the queue indexes are relative to the VSI.
  *
  * The PF is required to return a status code in v_retval for all messages
  * except RESET_VF, which does not require any response. The returned value
@@ -147,6 +146,7 @@ enum virtchnl_ops {
 	VIRTCHNL_OP_DEL_RSS_CFG = 46,
 	VIRTCHNL_OP_ADD_FDIR_FILTER = 47,
 	VIRTCHNL_OP_DEL_FDIR_FILTER = 48,
+	VIRTCHNL_OP_GET_MAX_RSS_QREGION = 50,
 	VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS = 51,
 	VIRTCHNL_OP_ADD_VLAN_V2 = 52,
 	VIRTCHNL_OP_DEL_VLAN_V2 = 53,
@@ -159,7 +159,11 @@ enum virtchnl_ops {
 	VIRTCHNL_OP_1588_PTP_GET_TIME = 61,
 	/* opcode 62 - 65 are reserved */
 	VIRTCHNL_OP_GET_QOS_CAPS = 66,
-	/* opcode 68 through 111 are reserved */
+	/* opcodes 67 through 106 are reserved */
+	VIRTCHNL_OP_ENABLE_QUEUES_V2 = 107,
+	VIRTCHNL_OP_DISABLE_QUEUES_V2 = 108,
+	/* opcodes 109 and 110 are reserved */
+	VIRTCHNL_OP_MAP_QUEUE_VECTOR = 111,
 	VIRTCHNL_OP_CONFIG_QUEUE_BW = 112,
 	VIRTCHNL_OP_CONFIG_QUANTA = 113,
 	VIRTCHNL_OP_MAX,
@@ -257,6 +261,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_vsi_resource);
 #define VIRTCHNL_VF_OFFLOAD_REQ_QUEUES		BIT(6)
 /* used to negotiate communicating link speeds in Mbps */
 #define VIRTCHNL_VF_CAP_ADV_LINK_SPEED		BIT(7)
+#define VIRTCHNL_VF_LARGE_NUM_QPAIRS		BIT(9)
 #define  VIRTCHNL_VF_OFFLOAD_CRC		BIT(10)
 #define VIRTCHNL_VF_OFFLOAD_TC_U32		BIT(11)
 #define VIRTCHNL_VF_OFFLOAD_VLAN_V2		BIT(15)
@@ -500,6 +505,27 @@ struct virtchnl_queue_select {
 
 VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_queue_select);
 
+/* VIRTCHNL_OP_GET_MAX_RSS_QREGION
+ *
+ * if VIRTCHNL_VF_LARGE_NUM_QPAIRS was negotiated in
+ * VIRTCHNL_OP_GET_VF_RESOURCES then this op must be supported.
+ *
+ * VF sends this message in order to query the max RSS queue region
+ * size supported by PF, when VIRTCHNL_VF_LARGE_NUM_QPAIRS is enabled.
+ * This information should be used when configuring the RSS LUT and/or
+ * configuring queue region based filters.
+ *
+ * The maximum RSS queue region is 2^qregion_width. So, a qregion_width of 6
+ * would inform the VF that the PF supports a maximum RSS queue region of 64.
+ */
+struct virtchnl_max_rss_qregion {
+	u16 vport_id;
+	u16 qregion_width;
+	u8 pad[4];
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_max_rss_qregion);
+
 /* VIRTCHNL_OP_ADD_ETH_ADDR
  * VF sends this message in order to add one or more unicast or multicast
  * address filters for the specified VSI.
@@ -1663,6 +1689,70 @@ struct virtchnl_queue_chunk {
 
 VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_queue_chunk);
 
+/* VIRTCHNL_OP_ENABLE_QUEUES_V2
+ * VIRTCHNL_OP_DISABLE_QUEUES_V2
+ *
+ * These opcodes can be used if VIRTCHNL_VF_LARGE_NUM_QPAIRS was negotiated in
+ * VIRTCHNL_OP_GET_VF_RESOURCES
+ *
+ * VF sends virtchnl_del_ena_dis_queues struct to specify the queues to be
+ * enabled/disabled in chunks. Also applicable to single queue RX or
+ * TX. PF performs requested action and returns status.
+ */
+struct virtchnl_del_ena_dis_queues {
+	u16 vport_id;
+	u16 pad;
+	u16 num_chunks;
+	u16 rsvd;
+	struct virtchnl_queue_chunk chunks[];
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_del_ena_dis_queues);
+#define virtchnl_del_ena_dis_queues_LEGACY_SIZEOF	16
+
+/* Virtchannel interrupt throttling rate index */
+enum virtchnl_itr_idx {
+	VIRTCHNL_ITR_IDX_0	= 0,
+	VIRTCHNL_ITR_IDX_1	= 1,
+	VIRTCHNL_ITR_IDX_NO_ITR	= 3,
+};
+
+/* Queue to vector mapping */
+struct virtchnl_queue_vector {
+	u16 queue_id;
+	u16 vector_id;
+	u8 pad[4];
+
+	/* see enum virtchnl_itr_idx */
+	s32 itr_idx;
+
+	/* see enum virtchnl_queue_type */
+	s32 queue_type;
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_queue_vector);
+
+/* VIRTCHNL_OP_MAP_QUEUE_VECTOR
+ *
+ * This opcode can be used only if VIRTCHNL_VF_LARGE_NUM_QPAIRS was negotiated
+ * in VIRTCHNL_OP_GET_VF_RESOURCES
+ *
+ * VF sends this message to map queues to vectors and ITR index registers.
+ * External data buffer contains virtchnl_queue_vector_maps structure
+ * that contains num_qv_maps of virtchnl_queue_vector structures.
+ * PF maps the requested queue vector maps after validating the queue and vector
+ * ids and returns a status code.
+ */
+struct virtchnl_queue_vector_maps {
+	u16 vport_id;
+	u16 num_qv_maps;
+	u8 pad[4];
+	struct virtchnl_queue_vector qv_maps[];
+};
+
+VIRTCHNL_CHECK_STRUCT_LEN(8, virtchnl_queue_vector_maps);
+#define virtchnl_queue_vector_maps_LEGACY_SIZEOF	24
+
 struct virtchnl_quanta_cfg {
 	u16 quanta_size;
 	u16 pad;
@@ -1695,6 +1785,8 @@ VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_quanta_cfg);
 		 __vss(virtchnl_rdma_qvlist_info, __vss_byelem, p, m, c),     \
 		 __vss(virtchnl_qos_cap_list, __vss_byelem, p, m, c),	      \
 		 __vss(virtchnl_queues_bw_cfg, __vss_byelem, p, m, c),	      \
+		 __vss(virtchnl_del_ena_dis_queues, __vss_byelem, p, m, c),   \
+		 __vss(virtchnl_queue_vector_maps, __vss_byelem, p, m, c),    \
 		 __vss(virtchnl_rss_key, __vss_byone, p, m, c),		      \
 		 __vss(virtchnl_rss_lut, __vss_byone, p, m, c))
 
@@ -1757,6 +1849,8 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,
 	case VIRTCHNL_OP_DISABLE_QUEUES:
 		valid_len = sizeof(struct virtchnl_queue_select);
 		break;
+	case VIRTCHNL_OP_GET_MAX_RSS_QREGION:
+		break;
 	case VIRTCHNL_OP_ADD_ETH_ADDR:
 	case VIRTCHNL_OP_DEL_ETH_ADDR:
 		valid_len = virtchnl_ether_addr_list_LEGACY_SIZEOF;
@@ -1929,7 +2023,32 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,
 	case VIRTCHNL_OP_1588_PTP_GET_TIME:
 		valid_len = sizeof(struct virtchnl_phc_time);
 		break;
-	/* These are always errors coming from the VF. */
+	case VIRTCHNL_OP_ENABLE_QUEUES_V2:
+	case VIRTCHNL_OP_DISABLE_QUEUES_V2:
+		valid_len = sizeof(struct virtchnl_del_ena_dis_queues);
+		if (msglen >= valid_len) {
+			struct virtchnl_del_ena_dis_queues *qs =
+				(struct virtchnl_del_ena_dis_queues *)msg;
+
+			if (!qs->num_chunks) {
+				err_msg_format = true;
+				break;
+			}
+			valid_len = virtchnl_struct_size(qs, chunks,
+							 qs->num_chunks);
+		}
+		break;
+	case VIRTCHNL_OP_MAP_QUEUE_VECTOR:
+		valid_len = virtchnl_queue_vector_maps_LEGACY_SIZEOF;
+		if (msglen >= valid_len) {
+			struct virtchnl_queue_vector_maps *v_qp = (void *)msg;
+
+			err_msg_format = !v_qp->num_qv_maps;
+			valid_len = virtchnl_struct_size(v_qp, qv_maps,
+							 v_qp->num_qv_maps);
+		}
+		break;
+	/* These are always errors when coming from the VF. */
 	case VIRTCHNL_OP_EVENT:
 	case VIRTCHNL_OP_UNKNOWN:
 	default:
diff --git a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
index b76622fa9661..a0d4b7bfb607 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
@@ -1643,6 +1643,11 @@ static int iavf_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
 static u32 iavf_get_rx_ring_count(struct net_device *netdev)
 {
 	struct iavf_adapter *adapter = netdev_priv(netdev);
+	u16 width = adapter->max_rss_qregion.qregion_width;
+
+	/* RSS can use only the PF RSS region, see iavf_fill_rss_lut() */
+	if (LARGE_NUM_QPAIRS_SUPPORT(adapter) && width)
+		return min_t(u32, adapter->num_active_queues, BIT(width));
 
 	return adapter->num_active_queues;
 }
@@ -1683,6 +1688,19 @@ static int iavf_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,
 
 	return ret;
 }
+
+/* in LARGE mode PF gives us up to its RSS region once it has told us that */
+static u32 iavf_max_channels(struct iavf_adapter *adapter)
+{
+	u16 width = adapter->max_rss_qregion.qregion_width;
+
+	if (LARGE_NUM_QPAIRS_SUPPORT(adapter) && width &&
+	    adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_REQ_QUEUES)
+		return BIT(width);
+
+	return adapter->vsi_res->num_queue_pairs;
+}
+
 /**
  * iavf_get_channels - get the number of channels supported by the device
  * @netdev: network interface device structure
@@ -1697,12 +1715,17 @@ static void iavf_get_channels(struct net_device *netdev,
 	struct iavf_adapter *adapter = netdev_priv(netdev);
 
 	/* Report maximum channels */
-	ch->max_combined = adapter->vsi_res->num_queue_pairs;
+	ch->max_combined = iavf_max_channels(adapter);
 
 	ch->max_other = NONQ_VECS;
 	ch->other_count = NONQ_VECS;
 
 	ch->combined_count = adapter->num_active_queues;
+	/* the requested count, until the PF grants or denies it */
+	if (adapter->aq_required & IAVF_FLAG_AQ_REQUEST_QUEUES)
+		ch->combined_count = adapter->num_req_queues_next;
+	else if (adapter->num_req_queues)
+		ch->combined_count = adapter->num_req_queues;
 }
 
 /**
@@ -1730,15 +1753,29 @@ static int iavf_set_channels(struct net_device *netdev,
 	/* All of these should have already been checked by ethtool before this
 	 * even gets to us, but just to be sure.
 	 */
-	if (num_req == 0 || num_req > adapter->vsi_res->num_queue_pairs)
+	if (num_req == 0 || num_req > iavf_max_channels(adapter))
 		return -EINVAL;
 
-	if (num_req == adapter->num_active_queues)
-		return 0;
-
 	if (ch->rx_count || ch->tx_count || ch->other_count != NONQ_VECS)
 		return -EINVAL;
 
+	/* PF has not answered our previous request yet */
+	if (adapter->current_op == VIRTCHNL_OP_REQUEST_QUEUES)
+		return -EBUSY;
+
+	if (num_req == adapter->num_active_queues) {
+		adapter->aq_required &= ~IAVF_FLAG_AQ_REQUEST_QUEUES;
+		return 0;
+	}
+
+	if (LARGE_NUM_QPAIRS_SUPPORT(adapter) &&
+	    adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_REQ_QUEUES) {
+		/* the watchdog sends it once no other op is in flight */
+		adapter->num_req_queues_next = num_req;
+		iavf_schedule_aq_request(adapter, IAVF_FLAG_AQ_REQUEST_QUEUES);
+		return 0;
+	}
+
 	adapter->num_req_queues = num_req;
 	adapter->flags |= IAVF_FLAG_REINIT_ITR_NEEDED;
 	adapter->flags |= IAVF_FLAG_RESET_NEEDED;
@@ -1817,13 +1854,26 @@ static int iavf_set_rxfh(struct net_device *netdev,
 			 struct netlink_ext_ack *extack)
 {
 	struct iavf_adapter *adapter = netdev_priv(netdev);
+	u16 width = adapter->max_rss_qregion.qregion_width;
 	u16 i;
 
 	/* Only support toeplitz hash function */
 	if (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE &&
 	    rxfh->hfunc != ETH_RSS_HASH_TOP)
 		return -EOPNOTSUPP;
 
+	/* PF takes only queues from its RSS region, see iavf_fill_rss_lut() */
+	if (rxfh->indir && LARGE_NUM_QPAIRS_SUPPORT(adapter) && width) {
+		for (i = 0; i < adapter->rss_lut_size; i++) {
+			if (rxfh->indir[i] < BIT(width))
+				continue;
+			NL_SET_ERR_MSG_FMT_MOD(extack,
+					       "RSS can use only the first %lu queues",
+					       BIT(width));
+			return -EINVAL;
+		}
+	}
+
 	if ((rxfh->input_xfrm & RXH_XFRM_SYM_XOR) &&
 	    adapter->hfunc != VIRTCHNL_RSS_ALG_TOEPLITZ_SYMMETRIC) {
 		if (!ADV_RSS_SUPPORT(adapter))
diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
index a2aef35c0a07..66beb83acc94 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_main.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
@@ -512,6 +512,7 @@ static void iavf_map_rings_to_vectors(struct iavf_adapter *adapter)
 			vidx = 0;
 	}
 
+	adapter->map_qps_sent = 0;
 	adapter->aq_required |= IAVF_FLAG_AQ_MAP_VECTORS;
 }
 
@@ -1827,10 +1828,15 @@ static int iavf_rss_lut_resize(struct iavf_adapter *adapter, u8 *lut, u16 size)
  *
  * Keep the lut set by the user, unless it uses a queue out of range.
  **/
-static void iavf_fill_rss_lut(struct iavf_adapter *adapter)
+void iavf_fill_rss_lut(struct iavf_adapter *adapter)
 {
+	struct virtchnl_max_rss_qregion *qregion = &adapter->max_rss_qregion;
 	int max = adapter->num_active_queues;
 
+	/* width == 0: PF has not told us the region yet */
+	if (LARGE_NUM_QPAIRS_SUPPORT(adapter) && qregion->qregion_width)
+		max = min(max, (int)BIT(qregion->qregion_width));
+
 	if (iavf_rss_lut_is_user(adapter)) {
 		int max_q = 0;
 
@@ -2158,6 +2164,8 @@ static int iavf_process_aq_command(struct iavf_adapter *adapter)
 {
 	if (adapter->aq_required & IAVF_FLAG_AQ_GET_CONFIG)
 		return iavf_send_vf_config_msg(adapter);
+	if (adapter->aq_required & IAVF_FLAG_AQ_GET_MAX_RSS_QREGION)
+		return iavf_send_max_rss_qregion(adapter);
 	if (adapter->aq_required & IAVF_FLAG_AQ_GET_OFFLOAD_VLAN_V2_CAPS)
 		return iavf_send_vf_offload_vlan_v2_msg(adapter);
 	if (adapter->aq_required & IAVF_FLAG_AQ_GET_SUPPORTED_RXDIDS)
@@ -2332,6 +2340,12 @@ static int iavf_process_aq_command(struct iavf_adapter *adapter)
 		iavf_virtchnl_send_ptp_cmd(adapter);
 		return IAVF_SUCCESS;
 	}
+	if (adapter->aq_required & IAVF_FLAG_AQ_REQUEST_QUEUES) {
+		/* ethtool -L has already reported success, retry until sent */
+		if (!iavf_request_queues(adapter, adapter->num_req_queues_next))
+			adapter->aq_required &= ~IAVF_FLAG_AQ_REQUEST_QUEUES;
+		return 0;
+	}
 	if (adapter->aq_required & IAVF_FLAG_AQ_REQUEST_STATS) {
 		iavf_request_stats(adapter);
 		return 0;
@@ -2527,10 +2541,11 @@ static void iavf_init_version_check(struct iavf_adapter *adapter)
  */
 int iavf_parse_vf_resource_msg(struct iavf_adapter *adapter)
 {
-	int i, num_req_queues = adapter->num_req_queues;
+	int i, qnum, num_req_queues = adapter->num_req_queues;
 	struct virtchnl_vsi_resource *vsi_res = NULL;
 	struct iavf_vsi *vsi = &adapter->vsi;
 	u32 key_size, lut_size;
+	bool init_req = false;
 
 	for (i = 0; i < adapter->vf_res->num_vsis; i++) {
 		if (adapter->vf_res->vsi_res[i].vsi_type == VIRTCHNL_VSI_SRIOV)
@@ -2542,6 +2557,18 @@ int iavf_parse_vf_resource_msg(struct iavf_adapter *adapter)
 	}
 	adapter->vsi_res = vsi_res;
 
+	/* in LARGE mode we ask PF at init for more queues, up to one per CPU */
+	if (adapter->state == __IAVF_INIT_GET_RESOURCES &&
+	    LARGE_NUM_QPAIRS_SUPPORT(adapter) &&
+	    adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_REQ_QUEUES)
+		init_req = true;
+
+	/* PF resets us to grant the request, but other resets could come
+	 * first, then we have a different count and need to ask again
+	 */
+	if (init_req && num_req_queues != adapter->vsi_res->num_queue_pairs)
+		num_req_queues = 0;
+
 	if (num_req_queues &&
 	    num_req_queues > adapter->vsi_res->num_queue_pairs) {
 		/* Problem.  The PF gave us fewer queues than what we had
@@ -2616,6 +2643,18 @@ int iavf_parse_vf_resource_msg(struct iavf_adapter *adapter)
 		adapter->rss_lut_size = lut_size;
 	}
 
+	if (init_req) {
+		qnum = min_t(int, num_online_cpus(), IAVF_MAX_REQ_QUEUES);
+		/* granted, or we have enough */
+		if (num_req_queues || qnum <= adapter->vsi_res->num_queue_pairs)
+			return 0;
+
+		adapter->current_op = VIRTCHNL_OP_UNKNOWN;
+		adapter->extended_caps |= IAVF_EXTENDED_CAP_RECV_REQ_QUEUES;
+
+		return iavf_request_queues(adapter, qnum);
+	}
+
 	return 0;
 }
 
@@ -2662,17 +2701,18 @@ static void iavf_init_get_resources(struct iavf_adapter *adapter)
 		goto err_alloc;
 	}
 
+	/* Some features require additional messages to negotiate extended
+	 * capabilities. These are processed in sequence by the
+	 * __IAVF_INIT_EXTENDED_CAPS driver state.
+	 */
+	adapter->extended_caps = IAVF_EXTENDED_CAPS;
+
 	err = iavf_parse_vf_resource_msg(adapter);
 	if (err) {
 		dev_err(&pdev->dev, "Failed to parse VF resource message from PF (%d)\n",
 			err);
 		goto err_alloc;
 	}
-	/* Some features require additional messages to negotiate extended
-	 * capabilities. These are processed in sequence by the
-	 * __IAVF_INIT_EXTENDED_CAPS driver state.
-	 */
-	adapter->extended_caps = IAVF_EXTENDED_CAPS;
 
 	iavf_change_state(adapter, __IAVF_INIT_EXTENDED_CAPS);
 	return;
@@ -2684,6 +2724,47 @@ static void iavf_init_get_resources(struct iavf_adapter *adapter)
 	iavf_change_state(adapter, __IAVF_INIT_FAILED);
 }
 
+/**
+ * iavf_init_recv_req_queues - part of requesting queues in LARGE mode
+ * @adapter: board private structure
+ *
+ * Function waits for the outcome of the queue request sent by
+ * iavf_parse_vf_resource_msg(). PF resets us when it grants the request and
+ * replies only to deny it, then we ask for as many queues as PF can give,
+ * unless we have that many already.
+ */
+static void iavf_init_recv_req_queues(struct iavf_adapter *adapter)
+{
+	int num = -EALREADY;
+
+	/* PF grants by resetting us, the event may be lost with the ARQ */
+	if (rd32(&adapter->hw, IAVF_VF_ARQLEN1) &
+	    IAVF_VF_ARQLEN1_ARQENABLE_MASK)
+		num = iavf_get_req_queues_reply(adapter);
+	else
+		iavf_schedule_reset(adapter, IAVF_FLAG_RESET_PENDING);
+
+	if (num == -EALREADY || adapter->flags & IAVF_FLAG_RESET_PENDING) {
+		/* no reply yet, or PF reset us after granting */
+		iavf_change_state(adapter, __IAVF_INIT_FAILED);
+		return;
+	}
+
+	adapter->current_op = VIRTCHNL_OP_UNKNOWN;
+	if (num > 0) {
+		dev_info(&adapter->pdev->dev,
+			 "Requested %d queues, PF can support %d\n",
+			 adapter->num_req_queues, num);
+		if (num > adapter->vsi_res->num_queue_pairs &&
+		    !iavf_request_queues(adapter, num))
+			return;
+	}
+
+	/* go on with the queues PF has given us */
+	adapter->num_req_queues = 0;
+	adapter->extended_caps &= ~IAVF_EXTENDED_CAP_RECV_REQ_QUEUES;
+}
+
 /**
  * iavf_init_send_offload_vlan_v2_caps - part of initializing VLAN V2 caps
  * @adapter: board private structure
@@ -2741,6 +2822,65 @@ static void iavf_init_recv_offload_vlan_v2_caps(struct iavf_adapter *adapter)
 	iavf_change_state(adapter, __IAVF_INIT_FAILED);
 }
 
+/*
+ * iavf_init_send_max_rss_qregion - part of querying for RSS max queue region
+ * @adapter: board private structure
+ *
+ * Function processes send of the VIRTCHNL_OP_GET_MAX_RSS_QREGION to the PF.
+ * Must clear IAVF_EXTENDED_CAP_RECV_RSS_QREGION if the message is not sent, e.g.
+ * due to the PF not negotiating VIRTCHNL_VF_LARGE_NUM_QPAIRS.
+ */
+static void iavf_init_send_max_rss_qregion(struct iavf_adapter *adapter)
+{
+	int ret;
+
+	WARN_ON(!(adapter->extended_caps & IAVF_EXTENDED_CAP_SEND_RSS_QREGION));
+
+	ret = iavf_send_max_rss_qregion(adapter);
+	if (ret == -EOPNOTSUPP) {
+		/* PF does not support VIRTCHNL_VF_LARGE_NUM_QPAIRS. In this
+		 * case, we did not send the capability exchange message and do
+		 * not expect a response.
+		 */
+		adapter->extended_caps &= ~IAVF_EXTENDED_CAP_RECV_RSS_QREGION;
+	}
+
+	/* We sent the message, so move on to the next step */
+	adapter->extended_caps &= ~IAVF_EXTENDED_CAP_SEND_RSS_QREGION;
+}
+
+/**
+ * iavf_init_recv_max_rss_qregion - part of querying for RSS max queue region
+ * @adapter: board private structure
+ *
+ * Function processes receipt of the RSS max qregion to be used for the LUT.
+ */
+static void iavf_init_recv_max_rss_qregion(struct iavf_adapter *adapter)
+{
+	int ret;
+
+	WARN_ON(!(adapter->extended_caps & IAVF_EXTENDED_CAP_RECV_RSS_QREGION));
+
+	memset(&adapter->max_rss_qregion, 0, sizeof(adapter->max_rss_qregion));
+
+	ret = iavf_get_max_rss_qregion(adapter);
+	if (ret)
+		goto err;
+
+	/* We've processed the PF response to the VIRTCHNL_OP_GET_MAX_RSS_QREGION
+	 * message we sent previously.
+	 */
+	adapter->extended_caps &= ~IAVF_EXTENDED_CAP_RECV_RSS_QREGION;
+	return;
+
+err:
+	/* We didn't receive a reply. Make sure we try sending again when
+	 * __IAVF_INIT_FAILED attempts to recover.
+	 */
+	adapter->extended_caps |= IAVF_EXTENDED_CAP_SEND_RSS_QREGION;
+	iavf_change_state(adapter, __IAVF_INIT_FAILED);
+}
+
 /**
  * iavf_init_send_supported_rxdids - part of querying for supported RXDID
  * formats
@@ -2862,6 +3002,12 @@ static void iavf_init_process_extended_caps(struct iavf_adapter *adapter)
 {
 	WARN_ON(adapter->state != __IAVF_INIT_EXTENDED_CAPS);
 
+	/* Must be first, other steps would drop the reply while polling */
+	if (adapter->extended_caps & IAVF_EXTENDED_CAP_RECV_REQ_QUEUES) {
+		iavf_init_recv_req_queues(adapter);
+		return;
+	}
+
 	/* Process capability exchange for VLAN V2 */
 	if (adapter->extended_caps & IAVF_EXTENDED_CAP_SEND_VLAN_V2) {
 		iavf_init_send_offload_vlan_v2_caps(adapter);
@@ -2889,6 +3035,16 @@ static void iavf_init_process_extended_caps(struct iavf_adapter *adapter)
 		return;
 	}
 
+	/* Process capability exchange for RSS max qregion */
+	if (adapter->extended_caps & IAVF_EXTENDED_CAP_SEND_RSS_QREGION) {
+		iavf_init_send_max_rss_qregion(adapter);
+		return;
+	}
+	if (adapter->extended_caps & IAVF_EXTENDED_CAP_RECV_RSS_QREGION) {
+		iavf_init_recv_max_rss_qregion(adapter);
+		return;
+	}
+
 	/* When we reach here, no further extended capabilities exchanges are
 	 * necessary, so we finally transition into __IAVF_INIT_CONFIG_ADAPTER
 	 */
@@ -3002,6 +3158,10 @@ static void iavf_init_config_adapter(struct iavf_adapter *adapter)
 	/* Setup initial PTP configuration */
 	iavf_ptp_init(adapter);
 
+	/* queues requested at init are set up now */
+	adapter->num_req_queues = 0;
+	adapter->flags &= ~IAVF_FLAG_REINIT_ITR_NEEDED;
+
 	iavf_schedule_finish_config(adapter);
 	return;
 
@@ -3086,7 +3246,9 @@ static int iavf_watchdog_step(struct iavf_adapter *adapter)
 			 */
 			iavf_change_state(adapter, __IAVF_STARTUP);
 			adapter->flags &= ~IAVF_FLAG_PF_COMMS_FAILED;
+			/* fresh retry budget, and init asks for queues again */
 			adapter->aq_wait_count = 0;
+			adapter->num_req_queues = 0;
 		}
 		adapter->aq_required = 0;
 		adapter->current_op = VIRTCHNL_OP_UNKNOWN;
@@ -3125,7 +3287,8 @@ static int iavf_watchdog_step(struct iavf_adapter *adapter)
 	/* check for hw reset */
 	reg_val = rd32(hw, IAVF_VF_ARQLEN1) & IAVF_VF_ARQLEN1_ARQENABLE_MASK;
 	if (!reg_val) {
-		adapter->aq_required = 0;
+		/* keep a queue request of ethtool -L that is not sent yet */
+		adapter->aq_required &= IAVF_FLAG_AQ_REQUEST_QUEUES;
 		adapter->current_op = VIRTCHNL_OP_UNKNOWN;
 		dev_err(&adapter->pdev->dev, "Hardware reset detected\n");
 		iavf_schedule_reset(adapter, IAVF_FLAG_RESET_PENDING);
@@ -3361,13 +3524,19 @@ void iavf_reset_step(struct iavf_adapter *adapter)
 			 status);
 		goto reset_err;
 	}
-	adapter->aq_required = 0;
+	/* keep a queue request of ethtool -L that is not sent yet */
+	adapter->aq_required &= IAVF_FLAG_AQ_REQUEST_QUEUES;
 
 	if ((adapter->flags & IAVF_FLAG_REINIT_MSIX_NEEDED) ||
 	    (adapter->flags & IAVF_FLAG_REINIT_ITR_NEEDED)) {
 		err = iavf_reinit_interrupt_scheme(adapter, running);
 		if (err)
 			goto reset_err;
+	} else {
+		/* queues we requested were set up by the previous reset, fewer
+		 * of them now is a config change, not a denial
+		 */
+		adapter->num_req_queues = 0;
 	}
 
 	if (RSS_AQ(adapter)) {
@@ -3379,6 +3548,7 @@ void iavf_reset_step(struct iavf_adapter *adapter)
 	}
 
 	adapter->aq_required |= IAVF_FLAG_AQ_GET_CONFIG;
+	adapter->map_qps_sent = 0;
 	adapter->aq_required |= IAVF_FLAG_AQ_MAP_VECTORS;
 
 	/* Certain capabilities require an extended negotiation process using
@@ -3444,8 +3614,6 @@ void iavf_reset_step(struct iavf_adapter *adapter)
 			err = iavf_request_traffic_irqs(adapter, netdev->name);
 			if (err)
 				goto reset_err;
-
-			adapter->flags &= ~IAVF_FLAG_REINIT_MSIX_NEEDED;
 		}
 
 		iavf_configure(adapter);
@@ -3463,7 +3631,8 @@ void iavf_reset_step(struct iavf_adapter *adapter)
 		wake_up(&adapter->down_waitqueue);
 	}
 
-	adapter->flags &= ~IAVF_FLAG_REINIT_ITR_NEEDED;
+	adapter->flags &= ~(IAVF_FLAG_REINIT_MSIX_NEEDED |
+			    IAVF_FLAG_REINIT_ITR_NEEDED);
 
 	return;
 reset_err:
diff --git a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
index 151824102acd..e643c205884f 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
@@ -170,6 +170,7 @@ int iavf_send_vf_config_msg(struct iavf_adapter *adapter)
 	       VIRTCHNL_VF_OFFLOAD_VLAN_V2 |
 	       VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC |
 	       VIRTCHNL_VF_OFFLOAD_CRC |
+	       VIRTCHNL_VF_LARGE_NUM_QPAIRS |
 	       VIRTCHNL_VF_OFFLOAD_ENCAP_CSUM |
 	       VIRTCHNL_VF_OFFLOAD_REQ_QUEUES |
 	       VIRTCHNL_VF_CAP_PTP |
@@ -251,28 +252,45 @@ int iavf_send_vf_ptp_caps_msg(struct iavf_adapter *adapter)
 				(u8 *)&hw_caps, sizeof(hw_caps));
 }
 
+int iavf_send_max_rss_qregion(struct iavf_adapter *adapter)
+{
+	adapter->aq_required &= ~IAVF_FLAG_AQ_GET_MAX_RSS_QREGION;
+
+	if (!LARGE_NUM_QPAIRS_SUPPORT(adapter))
+		return -EOPNOTSUPP;
+
+	adapter->current_op = VIRTCHNL_OP_GET_MAX_RSS_QREGION;
+	iavf_send_pf_msg(adapter, VIRTCHNL_OP_GET_MAX_RSS_QREGION, NULL, 0);
+	return 0;
+}
+
 /**
  * iavf_validate_num_queues
  * @adapter: adapter structure
  *
  * Validate that the number of queues the PF has sent in
  * VIRTCHNL_OP_GET_VF_RESOURCES is not larger than the VF can handle.
  **/
 static void iavf_validate_num_queues(struct iavf_adapter *adapter)
 {
-	if (adapter->vf_res->num_queue_pairs > IAVF_MAX_REQ_QUEUES_VCV1) {
+	u32 max_req_queues = IAVF_MAX_REQ_QUEUES;
+
+	if (!LARGE_NUM_QPAIRS_SUPPORT(adapter))
+		max_req_queues = IAVF_MAX_VSI_QP;
+
+	if (adapter->vf_res->num_queue_pairs > max_req_queues) {
 		struct virtchnl_vsi_resource *vsi_res;
 		int i;
 
 		dev_info(&adapter->pdev->dev, "Received %d queues, but can only have a max of %d\n",
 			 adapter->vf_res->num_queue_pairs,
-			 IAVF_MAX_REQ_QUEUES_VCV1);
+			 max_req_queues);
 		dev_info(&adapter->pdev->dev, "Fixing by reducing queues to %d\n",
-			 IAVF_MAX_REQ_QUEUES_VCV1);
-		adapter->vf_res->num_queue_pairs = IAVF_MAX_REQ_QUEUES_VCV1;
+			 max_req_queues);
+		adapter->vf_res->num_queue_pairs = max_req_queues;
 		for (i = 0; i < adapter->vf_res->num_vsis; i++) {
 			vsi_res = &adapter->vf_res->vsi_res[i];
-			vsi_res->num_queue_pairs = IAVF_MAX_REQ_QUEUES_VCV1;
+			vsi_res->num_queue_pairs = max_req_queues;
 		}
 	}
 }
@@ -371,6 +389,60 @@ int iavf_get_vf_ptp_caps(struct iavf_adapter *adapter)
 	return err;
 }
 
+int iavf_get_max_rss_qregion(struct iavf_adapter *adapter)
+{
+	struct iavf_arq_event_info event;
+	int err;
+	u16 len;
+
+	len = sizeof(struct virtchnl_max_rss_qregion);
+	event.buf_len = len;
+	event.msg_buf = kzalloc(len, GFP_KERNEL);
+	if (!event.msg_buf)
+		return -ENOMEM;
+
+	err = iavf_poll_virtchnl_msg(&adapter->hw, &event,
+				     VIRTCHNL_OP_GET_MAX_RSS_QREGION);
+	if (!err && event.msg_len == len) {
+		memcpy(&adapter->max_rss_qregion, event.msg_buf, len);
+		adapter->max_rss_qregion.qregion_width =
+			min(adapter->max_rss_qregion.qregion_width,
+			    ilog2(IAVF_MAX_REQ_QUEUES));
+	}
+
+	adapter->current_op = VIRTCHNL_OP_UNKNOWN;
+
+	kfree(event.msg_buf);
+	return err;
+}
+
+/**
+ * iavf_get_req_queues_reply - poll for PF reply to our queue request
+ * @adapter: private adapter structure
+ *
+ * PF resets us when it grants the request, so a reply means a denial.
+ *
+ * Return: number of queues PF can give us, or negative error code.
+ */
+int iavf_get_req_queues_reply(struct iavf_adapter *adapter)
+{
+	/* poll looks for the reset event in the same buffer */
+	union {
+		struct virtchnl_vf_res_request vfres;
+		struct virtchnl_pf_event vpe;
+	} msg = {};
+	struct iavf_arq_event_info event = {
+		.buf_len = sizeof(msg),
+		.msg_buf = (u8 *)&msg,
+	};
+	int err;
+
+	err = iavf_poll_virtchnl_msg(&adapter->hw, &event,
+				     VIRTCHNL_OP_REQUEST_QUEUES);
+
+	return err ?: msg.vfres.num_queue_pairs;
+}
+
 /**
  * iavf_configure_queues
  * @adapter: adapter structure
@@ -438,6 +510,50 @@ void iavf_configure_queues(struct iavf_adapter *adapter)
 	kfree(vqci);
 }
 
+/**
+ * iavf_enable_disable_queues_v2 - send V2 messages of ENABLE/DISABLE queues ops
+ * @adapter: private adapter structure
+ * @enable: true to enable and false to disable the queues
+ */
+static void iavf_enable_disable_queues_v2(struct iavf_adapter *adapter, bool enable)
+{
+	enum virtchnl_ops op = VIRTCHNL_OP_ENABLE_QUEUES_V2;
+	struct virtchnl_del_ena_dis_queues *msg;
+	u64 flag = IAVF_FLAG_AQ_ENABLE_QUEUES;
+	struct virtchnl_queue_chunk *chunk;
+	int len;
+
+	if (!enable) {
+		op = VIRTCHNL_OP_DISABLE_QUEUES_V2;
+		flag = IAVF_FLAG_AQ_DISABLE_QUEUES;
+	}
+
+	/* We need 2 chunks (one Tx and one Rx). */
+	len = virtchnl_struct_size(msg, chunks, 2);
+	msg = kzalloc(len, GFP_KERNEL);
+	if (!msg)
+		return;
+
+	adapter->current_op = op;
+
+	msg->vport_id = adapter->vsi_res->vsi_id;
+	msg->num_chunks = 2;
+
+	chunk = &msg->chunks[0];
+	chunk->type = VIRTCHNL_QUEUE_TYPE_RX;
+	chunk->start_queue_id = 0;
+	chunk->num_queues = adapter->num_active_queues;
+
+	chunk++;
+	chunk->type = VIRTCHNL_QUEUE_TYPE_TX;
+	chunk->start_queue_id = 0;
+	chunk->num_queues = adapter->num_active_queues;
+
+	adapter->aq_required &= ~flag;
+	iavf_send_pf_msg(adapter, op, (u8 *)msg, len);
+	kfree(msg);
+}
+
 /**
  * iavf_enable_queues
  * @adapter: adapter structure
@@ -454,6 +570,12 @@ void iavf_enable_queues(struct iavf_adapter *adapter)
 			adapter->current_op);
 		return;
 	}
+
+	if (LARGE_NUM_QPAIRS_SUPPORT(adapter)) {
+		iavf_enable_disable_queues_v2(adapter, true);
+		return;
+	}
+
 	adapter->current_op = VIRTCHNL_OP_ENABLE_QUEUES;
 	vqs.vsi_id = adapter->vsi_res->vsi_id;
 	vqs.tx_queues = BIT(min(adapter->num_active_queues,
@@ -480,6 +602,12 @@ void iavf_disable_queues(struct iavf_adapter *adapter)
 			adapter->current_op);
 		return;
 	}
+
+	if (LARGE_NUM_QPAIRS_SUPPORT(adapter)) {
+		iavf_enable_disable_queues_v2(adapter, false);
+		return;
+	}
+
 	adapter->current_op = VIRTCHNL_OP_DISABLE_QUEUES;
 	vqs.vsi_id = adapter->vsi_res->vsi_id;
 	vqs.tx_queues = BIT(min(adapter->num_active_queues,
@@ -490,6 +618,50 @@ void iavf_disable_queues(struct iavf_adapter *adapter)
 			 (u8 *)&vqs, sizeof(vqs));
 }
 
+static void iavf_map_queue_vector(struct iavf_adapter *adapter)
+{
+	struct virtchnl_queue_vector_maps *qvmaps;
+	int first = adapter->map_qps_sent;
+	struct virtchnl_queue_vector *qv;
+	int len, qnum;
+
+	qnum = min_t(int, adapter->num_active_queues - first,
+		     iavf_max_vc_entries(qvmaps, qv_maps) / 2);
+	len = virtchnl_struct_size(qvmaps, qv_maps, 2 * qnum);
+	qvmaps = kzalloc(len, GFP_KERNEL);
+	if (!qvmaps)
+		return;
+
+	qvmaps->vport_id = adapter->vsi_res->vsi_id;
+	qvmaps->num_qv_maps = 2 * qnum;
+	qv = qvmaps->qv_maps;
+	for (int qid = first; qid < first + qnum; qid++) {
+		struct iavf_q_vector *q_vector;
+
+		q_vector = adapter->tx_rings[qid].q_vector;
+		qv->queue_id = qid;
+		qv->vector_id = NONQ_VECS + q_vector->v_idx;
+		qv->itr_idx = IAVF_TX_ITR;
+		qv->queue_type = VIRTCHNL_QUEUE_TYPE_TX;
+		qv++;
+
+		q_vector = adapter->rx_rings[qid].q_vector;
+		qv->queue_id = qid;
+		qv->vector_id = NONQ_VECS + q_vector->v_idx;
+		qv->itr_idx = IAVF_RX_ITR;
+		qv->queue_type = VIRTCHNL_QUEUE_TYPE_RX;
+		qv++;
+	}
+
+	adapter->current_op = VIRTCHNL_OP_MAP_QUEUE_VECTOR;
+	adapter->map_qps_sent += qnum;
+	if (adapter->map_qps_sent == adapter->num_active_queues)
+		adapter->aq_required &= ~IAVF_FLAG_AQ_MAP_VECTORS;
+	iavf_send_pf_msg(adapter, VIRTCHNL_OP_MAP_QUEUE_VECTOR,
+			 (u8 *)qvmaps, len);
+	kfree(qvmaps);
+}
+
 /**
  * iavf_map_queues
  * @adapter: adapter structure
@@ -511,6 +683,12 @@ void iavf_map_queues(struct iavf_adapter *adapter)
 			adapter->current_op);
 		return;
 	}
+
+	if (LARGE_NUM_QPAIRS_SUPPORT(adapter)) {
+		iavf_map_queue_vector(adapter);
+		return;
+	}
+
 	adapter->current_op = VIRTCHNL_OP_CONFIG_IRQ_MAP;
 
 	q_vectors = adapter->num_msix_vectors - NONQ_VECS;
@@ -547,6 +725,40 @@ void iavf_map_queues(struct iavf_adapter *adapter)
 	kfree(vimi);
 }
 
+/**
+ * iavf_request_queues - request queues via virtchnl
+ * @adapter: adapter structure
+ * @num: number of requested queues
+ *
+ * Return: 0 on success, negative on failure.
+ */
+int iavf_request_queues(struct iavf_adapter *adapter, int num)
+{
+	struct virtchnl_vf_res_request vfres = { num };
+	int err;
+
+	if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
+		/* bail because we already have a command pending */
+		dev_err(&adapter->pdev->dev, "Cannot request queues, command %d pending\n",
+			adapter->current_op);
+		return -EBUSY;
+	}
+
+	adapter->current_op = VIRTCHNL_OP_REQUEST_QUEUES;
+	adapter->flags |= IAVF_FLAG_REINIT_ITR_NEEDED;
+	adapter->num_req_queues = num;
+
+	err = iavf_send_pf_msg(adapter, VIRTCHNL_OP_REQUEST_QUEUES,
+			       (u8 *)&vfres, sizeof(vfres));
+	if (err) {
+		adapter->current_op = VIRTCHNL_OP_UNKNOWN;
+		adapter->flags &= ~IAVF_FLAG_REINIT_ITR_NEEDED;
+		adapter->num_req_queues = 0;
+	}
+
+	return err;
+}
+
 /**
  * iavf_set_mac_addr_type - Set the correct request type from the filter type
  * @virtchnl_ether_addr: pointer to requested list element
@@ -2567,6 +2779,18 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,
 			/* don't send the remaining queue pairs */
 			adapter->aq_required &= ~IAVF_FLAG_AQ_CONFIGURE_QUEUES;
 			break;
+		case VIRTCHNL_OP_MAP_QUEUE_VECTOR:
+			dev_err(&adapter->pdev->dev, "Failed to map queues to vectors, error %s\n",
+				iavf_stat_str(&adapter->hw, v_retval));
+			/* don't send the remaining queues */
+			adapter->aq_required &= ~IAVF_FLAG_AQ_MAP_VECTORS;
+			break;
+		case VIRTCHNL_OP_REQUEST_QUEUES:
+			dev_err(&adapter->pdev->dev, "Failed to request queues, error %s\n",
+				iavf_stat_str(&adapter->hw, v_retval));
+			adapter->num_req_queues = 0;
+			adapter->flags &= ~IAVF_FLAG_REINIT_ITR_NEEDED;
+			break;
 		default:
 			dev_err(&adapter->pdev->dev, "PF returned error %d (%s) to our request %d\n",
 				v_retval, iavf_stat_str(&adapter->hw, v_retval),
@@ -2710,6 +2934,22 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,
 			aq_required;
 		}
 		break;
+	case VIRTCHNL_OP_GET_MAX_RSS_QREGION: {
+		u16 width = adapter->max_rss_qregion.qregion_width;
+
+		if (v_retval || msglen != sizeof(adapter->max_rss_qregion))
+			break;
+		memcpy(&adapter->max_rss_qregion, msg, msglen);
+		adapter->max_rss_qregion.qregion_width =
+			min(adapter->max_rss_qregion.qregion_width,
+			    ilog2(IAVF_MAX_REQ_QUEUES));
+		/* LUT was filled before this reply, for the old region */
+		if (adapter->max_rss_qregion.qregion_width != width) {
+			iavf_fill_rss_lut(adapter);
+			iavf_config_rss(adapter);
+		}
+		break;
+	}
 	case VIRTCHNL_OP_GET_SUPPORTED_RXDIDS:
 		if (msglen != sizeof(u64))
 			return;
@@ -2730,20 +2970,23 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,
 		iavf_virtchnl_ptp_get_time(adapter, msg, msglen);
 		break;
 	case VIRTCHNL_OP_ENABLE_QUEUES:
+	case VIRTCHNL_OP_ENABLE_QUEUES_V2:
 		/* enable transmits */
 		iavf_irq_enable(adapter, true);
 		adapter->flags &= ~IAVF_FLAG_QUEUES_DISABLED;
 		break;
 	case VIRTCHNL_OP_DISABLE_QUEUES:
+	case VIRTCHNL_OP_DISABLE_QUEUES_V2:
 		iavf_free_all_tx_resources(adapter);
 		iavf_free_all_rx_resources(adapter);
 		if (adapter->state == __IAVF_DOWN_PENDING) {
 			iavf_change_state(adapter, __IAVF_DOWN);
 			wake_up(&adapter->down_waitqueue);
 		}
 		break;
 	case VIRTCHNL_OP_VERSION:
 	case VIRTCHNL_OP_CONFIG_IRQ_MAP:
+	case VIRTCHNL_OP_MAP_QUEUE_VECTOR:
 		/* Don't display an error if we get these out of sequence.
 		 * If the firmware needed to get kicked, we'll get these and
 		 * it's no problem.
@@ -2766,7 +3009,8 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,
 		struct virtchnl_vf_res_request *vfres =
 			(struct virtchnl_vf_res_request *)msg;
 
-		if (vfres->num_queue_pairs != adapter->num_req_queues) {
+		if (!v_retval &&
+		    vfres->num_queue_pairs != adapter->num_req_queues) {
 			dev_info(&adapter->pdev->dev,
 				 "Requested %d queues, PF can support %d\n",
 				 adapter->num_req_queues,
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH net-next v7 11/15] ice: introduce handling of virtchnl LARGE VF opcodes
  2026-11-21 22:55 [PATCH net-next v7 00/15] devlink, mlx5, iavf, ice: XLVF for iavf Przemek Kitszel
                   ` (9 preceding siblings ...)
  2026-11-21 22:55 ` [PATCH net-next v7 10/15] iavf: use new opcodes to request more than 16 queues Przemek Kitszel
@ 2026-11-21 22:55 ` Przemek Kitszel
  2026-11-24 21:57   ` netdev-bot+sashiko
  2026-11-21 22:55 ` [PATCH net-next v7 12/15] devlink: add cmode to resources Przemek Kitszel
                   ` (4 subsequent siblings)
  15 siblings, 1 reply; 28+ messages in thread
From: Przemek Kitszel @ 2026-11-21 22:55 UTC (permalink / raw)
  To: netdev, Jakub Kicinski, Jiri Pirko
  Cc: Tony Nguyen, Aleksandr Loktionov, Michal Schmidt, edumazet, horms,
	pabeni, davem, Jonathan Corbet, skhan, rdunlap, andrew+netdev,
	saeedm, tariqt, leon, mbloch, jacob.e.keller, jedrzej.jagielski,
	anzaki, brett.creeley, ohartoov, Petr Oros, Donald Hunter,
	Przemek Kitszel

From: Brett Creeley <brett.creeley@intel.com>

With new virtchnl offload/capability VFs are able to make use of more than
16 queues. But the old opcodes were designed with a max of 16 queues,
so new ones were added (by iavf/virtchnl commit of this series).
Add handlers for VIRTCHNL_OP_ENABLE_QUEUES_V2,
VIRTCHNL_OP_DISABLE_QUEUES_V2 and VIRTCHNL_OP_MAP_QUEUE_VECTOR here.
Bigger RSS LUT support, later in the series, hooks them up, with the
get_q_vector callback of SR-IOV VFs, and adds the handler of
VIRTCHNL_OP_GET_MAX_RSS_QREGION, which is only allowlisted here.

Widen num_ring_{rx,tx} of struct ice_q_vector to u16, with the ring
counts in ice_vsi_map_rings_to_vectors(), which the PF uses too, as a
VF can map all its 256 queues to one vector.

If a VF wishes to request >16 queues it should first make sure that the
PF supports the VIRTCHNL_VF_LARGE_NUM_QPAIRS capability.

Thanks to Alex Loktionov for the message length validation.

Signed-off-by: Brett Creeley <brett.creeley@intel.com>
Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Co-developed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
---
v7:
 * cap the total count of queues of each type in the chunks of
   ENABLE_QUEUES_V2 and DISABLE_QUEUES_V2, overlapping chunks made PF
   repeat the work on the same queues many times (Sashiko)
 * accept only the itr_idx values of enum virtchnl_itr_idx in
   VIRTCHNL_OP_MAP_QUEUE_VECTOR, 2 was accepted (me)
 * widen the u8 ring counts in ice_vsi_map_rings_to_vectors() to u16,
   as num_ring_{rx,tx} (Sashiko)
 * thank Alex for the message length validation in place of his
   Co-developed-by tag with a "# msglen val" note, which checkpatch
   did not match with his Signed-off-by
 * commit message: the handlers get hooked up only later in the series;
   mention the u16 ring counts (me)

v5:
 * widen num_ring_{rx,tx} of struct ice_q_vector to u16, mapping all
   256 queues of a VF to one vector wrapped them around (Sashiko)

v4:
 * limit queue chunks to ICE_MAX_QS_PER_VF, the size of
   vf->{rx,tx}q_ena, as num_vf_qs could be set higher via
   sriov_vf_msix_count (Sashiko)
 * VIRTCHNL_OP_MAP_QUEUE_VECTOR: set ring->q_vector, num_ring_{rx,tx}
   and {rx,tx}.itr_idx, as VIRTCHNL_OP_CONFIG_IRQ_MAP does (Sashiko)
 * look up the VF VSI once per message, make ice_vc_ena_txq_chunk()
   void (Sashiko)

v3:
 * reject VIRTCHNL_OP_MAP_QUEUE_VECTOR entries with an out of range
   itr_idx (me)

v2:
 * fix error response in one case of ice_vc_map_q_vector_msg() (Alex)
 * use ice_get_vf_vsi() instead of plain array access (Sashiko)
 * return VIRTCHNL_STATUS_ERR_PARAM on error (Sashiko)
 * commit message: GET_MAX_RSS_QREGION is handled only later
---
 drivers/net/ethernet/intel/ice/ice.h          |   4 +-
 drivers/net/ethernet/intel/ice/ice_vf_lib.h   |   1 +
 drivers/net/ethernet/intel/ice/virt/queues.h  |   3 +
 drivers/net/ethernet/intel/ice/ice_base.c     |   8 +-
 .../net/ethernet/intel/ice/virt/allowlist.c   |   8 +
 drivers/net/ethernet/intel/ice/virt/queues.c  | 349 ++++++++++++++++++
 6 files changed, 366 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h
index d28ff576a342..4de947165a08 100644
--- a/drivers/net/ethernet/intel/ice/ice.h
+++ b/drivers/net/ethernet/intel/ice/ice.h
@@ -474,8 +474,8 @@ struct ice_q_vector {
 
 	u16 v_idx;			/* index in the vsi->q_vector array. */
 	u16 reg_idx;			/* PF relative register index */
-	u8 num_ring_rx;			/* total number of Rx rings in vector */
-	u8 num_ring_tx;			/* total number of Tx rings in vector */
+	u16 num_ring_rx;		/* total number of Rx rings in vector */
+	u16 num_ring_tx;		/* total number of Tx rings in vector */
 	u8 wb_on_itr:1;			/* if true, WB on ITR is enabled */
 	/* in usecs, need to use ice_intrl_to_usecs_reg() before writing this
 	 * value to the device
diff --git a/drivers/net/ethernet/intel/ice/ice_vf_lib.h b/drivers/net/ethernet/intel/ice/ice_vf_lib.h
index a9e95c85bc98..396dfb2b2d97 100644
--- a/drivers/net/ethernet/intel/ice/ice_vf_lib.h
+++ b/drivers/net/ethernet/intel/ice/ice_vf_lib.h
@@ -125,6 +125,7 @@ struct ice_vf_ops {
 	void (*clear_reset_trigger)(struct ice_vf *vf);
 	void (*irq_close)(struct ice_vf *vf);
 	void (*post_vsi_rebuild)(struct ice_vf *vf);
+	struct ice_q_vector *(*get_q_vector)(struct ice_vsi *vsi, u16 vec_id);
 };
 
 /* Virtchnl/SR-IOV config info */
diff --git a/drivers/net/ethernet/intel/ice/virt/queues.h b/drivers/net/ethernet/intel/ice/virt/queues.h
index c4a792cecea1..223f609dd4f3 100644
--- a/drivers/net/ethernet/intel/ice/virt/queues.h
+++ b/drivers/net/ethernet/intel/ice/virt/queues.h
@@ -16,5 +16,8 @@ int ice_vc_cfg_q_bw(struct ice_vf *vf, u8 *msg);
 int ice_vc_cfg_q_quanta(struct ice_vf *vf, u8 *msg);
 int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg);
 int ice_vc_request_qs_msg(struct ice_vf *vf, u8 *msg);
+int ice_vc_ena_qs_v2_msg(struct ice_vf *vf, u8 *msg, u16 msglen);
+int ice_vc_dis_qs_v2_msg(struct ice_vf *vf, u8 *msg, u16 msglen);
+int ice_vc_map_q_vector_msg(struct ice_vf *vf, u8 *msg, u16 msglen);
 
 #endif /* _ICE_VIRT_QUEUES_H_ */
diff --git a/drivers/net/ethernet/intel/ice/ice_base.c b/drivers/net/ethernet/intel/ice/ice_base.c
index f65634e3d44e..2d58a92f2942 100644
--- a/drivers/net/ethernet/intel/ice/ice_base.c
+++ b/drivers/net/ethernet/intel/ice/ice_base.c
@@ -935,12 +935,11 @@ void ice_vsi_map_rings_to_vectors(struct ice_vsi *vsi)
 
 	for (v_id = 0; v_id < q_vectors; v_id++) {
 		struct ice_q_vector *q_vector = vsi->q_vectors[v_id];
-		u8 tx_rings_per_v, rx_rings_per_v;
+		u16 tx_rings_per_v, rx_rings_per_v;
 		u16 q_id, q_base;
 
 		/* Tx rings mapping to vector */
-		tx_rings_per_v = (u8)DIV_ROUND_UP(tx_rings_rem,
-						  q_vectors - v_id);
+		tx_rings_per_v = DIV_ROUND_UP(tx_rings_rem, q_vectors - v_id);
 		q_vector->num_ring_tx = tx_rings_per_v;
 		q_vector->tx.tx_ring = NULL;
 		q_vector->tx.itr_idx = ICE_TX_ITR;
@@ -956,8 +955,7 @@ void ice_vsi_map_rings_to_vectors(struct ice_vsi *vsi)
 		tx_rings_rem -= tx_rings_per_v;
 
 		/* Rx rings mapping to vector */
-		rx_rings_per_v = (u8)DIV_ROUND_UP(rx_rings_rem,
-						  q_vectors - v_id);
+		rx_rings_per_v = DIV_ROUND_UP(rx_rings_rem, q_vectors - v_id);
 		q_vector->num_ring_rx = rx_rings_per_v;
 		q_vector->rx.rx_ring = NULL;
 		q_vector->rx.itr_idx = ICE_RX_ITR;
diff --git a/drivers/net/ethernet/intel/ice/virt/allowlist.c b/drivers/net/ethernet/intel/ice/virt/allowlist.c
index a07efec19c45..ef769b843c6f 100644
--- a/drivers/net/ethernet/intel/ice/virt/allowlist.c
+++ b/drivers/net/ethernet/intel/ice/virt/allowlist.c
@@ -95,6 +95,13 @@ static const u32 tc_allowlist_opcodes[] = {
 	VIRTCHNL_OP_CONFIG_QUANTA,
 };
 
+static const u32 large_num_qpairs_allowlist_opcodes[] = {
+	VIRTCHNL_OP_GET_MAX_RSS_QREGION,
+	VIRTCHNL_OP_ENABLE_QUEUES_V2,
+	VIRTCHNL_OP_DISABLE_QUEUES_V2,
+	VIRTCHNL_OP_MAP_QUEUE_VECTOR,
+};
+
 struct allowlist_opcode_info {
 	const u32 *opcodes;
 	size_t size;
@@ -117,6 +124,7 @@ static const struct allowlist_opcode_info allowlist_opcodes[] = {
 	ALLOW_ITEM(VIRTCHNL_VF_OFFLOAD_VLAN_V2, vlan_v2_allowlist_opcodes),
 	ALLOW_ITEM(VIRTCHNL_VF_OFFLOAD_QOS, tc_allowlist_opcodes),
 	ALLOW_ITEM(VIRTCHNL_VF_CAP_PTP, ptp_allowlist_opcodes),
+	ALLOW_ITEM(VIRTCHNL_VF_LARGE_NUM_QPAIRS, large_num_qpairs_allowlist_opcodes),
 };
 
 /**
diff --git a/drivers/net/ethernet/intel/ice/virt/queues.c b/drivers/net/ethernet/intel/ice/virt/queues.c
index a8a2f5e5b322..e8635236cb6c 100644
--- a/drivers/net/ethernet/intel/ice/virt/queues.c
+++ b/drivers/net/ethernet/intel/ice/virt/queues.c
@@ -1046,3 +1046,352 @@ int ice_vc_request_qs_msg(struct ice_vf *vf, u8 *msg)
 				     v_ret, (u8 *)vfres, sizeof(*vfres));
 }
 
+static bool ice_vc_supported_queue_type(s32 queue_type)
+{
+	return queue_type == VIRTCHNL_QUEUE_TYPE_RX ||
+	       queue_type == VIRTCHNL_QUEUE_TYPE_TX;
+}
+
+/**
+ * ice_vc_validate_qs_v2_msg - validate all qs_msg parameters
+ * @vf: VF the message was received from
+ * @qs_msg: contents of the message from the VF
+ * @msglen: length of @qs_msg
+ *
+ * Used to validate both the VIRTCHNL_OP_ENABLE_QUEUES_V2 and
+ * VIRTCHNL_OP_DISABLE_QUEUES_V2 messages. This should always be called before
+ * attempting to enable and/or disable queues on behalf of a VF in response to
+ * the previously mentioned opcodes.
+ *
+ * Return: If all checks succeed, then return true. Otherwise return
+ *         false, indicating to the caller that the qs_msg is invalid.
+ */
+static bool ice_vc_validate_qs_v2_msg(struct ice_vf *vf,
+				      struct virtchnl_del_ena_dis_queues *qs_msg,
+				      u16 msglen)
+{
+	u32 max_qs = min_t(u32, vf->num_vf_qs, ICE_MAX_QS_PER_VF);
+	u32 num_rxq = 0, num_txq = 0;
+
+	if (msglen < virtchnl_struct_size(qs_msg, chunks, 0))
+		return false;
+
+	if (msglen < virtchnl_struct_size(qs_msg, chunks, qs_msg->num_chunks))
+		return false;
+
+	if (!qs_msg->num_chunks)
+		return false;
+
+	if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states))
+		return false;
+
+	if (!ice_vc_isvalid_vsi_id(vf, qs_msg->vport_id))
+		return false;
+
+	for (int i = 0; i < qs_msg->num_chunks; i++) {
+		struct virtchnl_queue_chunk *chunk = &qs_msg->chunks[i];
+		u32 end;
+
+		if (!ice_vc_supported_queue_type(chunk->type))
+			return false;
+
+		if (!chunk->num_queues)
+			return false;
+
+		end = chunk->start_queue_id + chunk->num_queues;
+		if (end > max_qs)
+			return false;
+
+		/* chunks may overlap, cap the total work */
+		if (chunk->type == VIRTCHNL_QUEUE_TYPE_RX)
+			num_rxq += chunk->num_queues;
+		else
+			num_txq += chunk->num_queues;
+		if (num_rxq > max_qs || num_txq > max_qs)
+			return false;
+	}
+
+	return true;
+}
+
+#define ice_for_each_q_in_chunk(chunk, q_id) \
+	for ((q_id) = (chunk)->start_queue_id; \
+	     (q_id) < (chunk)->start_queue_id + (chunk)->num_queues; \
+	     (q_id)++)
+
+static int
+ice_vc_ena_rxq_chunk(struct ice_vf *vf, struct ice_vsi *vsi,
+		     struct virtchnl_queue_chunk *chunk)
+{
+	u32 vf_qid;
+
+	ice_for_each_q_in_chunk(chunk, vf_qid) {
+		int err;
+
+		err = ice_vf_vsi_ena_single_rxq(vf, vsi, vf_qid);
+		if (err)
+			return err;
+	}
+
+	return 0;
+}
+
+static void
+ice_vc_ena_txq_chunk(struct ice_vf *vf, struct ice_vsi *vsi,
+		     struct virtchnl_queue_chunk *chunk)
+{
+	u32 vf_qid;
+
+	ice_for_each_q_in_chunk(chunk, vf_qid)
+		ice_vf_vsi_ena_single_txq(vf, vsi, vf_qid);
+}
+
+/**
+ * ice_vc_ena_qs_v2_msg - message handling for VIRTCHNL_OP_ENABLE_QUEUES_V2
+ * @vf: source of the request
+ * @msg: message to handle
+ * @msglen: length of the @msg
+ *
+ * Return: 0 on success or negative on error.
+ */
+int ice_vc_ena_qs_v2_msg(struct ice_vf *vf, u8 *msg, u16 msglen)
+{
+	struct virtchnl_del_ena_dis_queues *ena_qs_msg =
+			(struct virtchnl_del_ena_dis_queues *)msg;
+	enum virtchnl_status_code v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+	struct ice_vsi *vsi;
+
+	if (!ice_vc_validate_qs_v2_msg(vf, ena_qs_msg, msglen))
+		goto error_param;
+
+	vsi = ice_get_vf_vsi(vf);
+	if (!vsi)
+		goto error_param;
+
+	for (int i = 0; i < ena_qs_msg->num_chunks; i++) {
+		struct virtchnl_queue_chunk *chunk = &ena_qs_msg->chunks[i];
+
+		if (chunk->type == VIRTCHNL_QUEUE_TYPE_RX &&
+		    ice_vc_ena_rxq_chunk(vf, vsi, chunk))
+			goto error_param;
+		else if (chunk->type == VIRTCHNL_QUEUE_TYPE_TX)
+			ice_vc_ena_txq_chunk(vf, vsi, chunk);
+	}
+
+	v_ret = VIRTCHNL_STATUS_SUCCESS;
+	set_bit(ICE_VF_STATE_QS_ENA, vf->vf_states);
+
+error_param:
+	return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_ENABLE_QUEUES_V2,
+				     v_ret, NULL, 0);
+}
+
+static int
+ice_vc_dis_rxq_chunk(struct ice_vf *vf, struct ice_vsi *vsi,
+		     struct virtchnl_queue_chunk *chunk)
+{
+	u32 vf_qid;
+
+	ice_for_each_q_in_chunk(chunk, vf_qid) {
+		int err;
+
+		err = ice_vf_vsi_dis_single_rxq(vf, vsi, vf_qid);
+		if (err)
+			return err;
+	}
+
+	return 0;
+}
+
+static int
+ice_vc_dis_txq_chunk(struct ice_vf *vf, struct ice_vsi *vsi,
+		     struct virtchnl_queue_chunk *chunk)
+{
+	u32 vf_qid;
+
+	ice_for_each_q_in_chunk(chunk, vf_qid) {
+		int err;
+
+		err = ice_vf_vsi_dis_single_txq(vf, vsi, vf_qid);
+		if (err)
+			return err;
+	}
+
+	return 0;
+}
+
+/**
+ * ice_vc_dis_qs_v2_msg - message handling for VIRTCHNL_OP_DISABLE_QUEUES_V2
+ * @vf: source of the request
+ * @msg: message to handle
+ * @msglen: length of @msg
+ *
+ * Return: 0 on success or negative on error.
+ */
+int ice_vc_dis_qs_v2_msg(struct ice_vf *vf, u8 *msg, u16 msglen)
+{
+	struct virtchnl_del_ena_dis_queues *dis_qs_msg =
+			(struct virtchnl_del_ena_dis_queues *)msg;
+	enum virtchnl_status_code v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+	struct ice_vsi *vsi;
+
+	if (!ice_vc_validate_qs_v2_msg(vf, dis_qs_msg, msglen))
+		goto error_param;
+
+	vsi = ice_get_vf_vsi(vf);
+	if (!vsi)
+		goto error_param;
+
+	for (int i = 0; i < dis_qs_msg->num_chunks; i++) {
+		struct virtchnl_queue_chunk *chunk = &dis_qs_msg->chunks[i];
+
+		if (chunk->type == VIRTCHNL_QUEUE_TYPE_RX &&
+		    ice_vc_dis_rxq_chunk(vf, vsi, chunk))
+			goto error_param;
+		else if (chunk->type == VIRTCHNL_QUEUE_TYPE_TX &&
+			 ice_vc_dis_txq_chunk(vf, vsi, chunk))
+			goto error_param;
+	}
+
+	v_ret = VIRTCHNL_STATUS_SUCCESS;
+	if (ice_vf_has_no_qs_ena(vf))
+		clear_bit(ICE_VF_STATE_QS_ENA, vf->vf_states);
+
+error_param:
+	return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_DISABLE_QUEUES_V2,
+				     v_ret, NULL, 0);
+}
+
+/**
+ * ice_vc_validate_qv_maps - validate parameters sent in the qs_msg structure
+ * @vf: VF the message was received from
+ * @qv_maps: contents of the message from the VF
+ * @msglen: length of the @qv_maps
+ *
+ * Used to validate VIRTCHNL_OP_MAP_QUEUE_VECTOR messages. This should always
+ * be called before attempting map interrupts to queues. If all checks succeed,
+ * then return success indicating to the caller that the qv_maps are valid.
+ * Otherwise return false, indicating to the caller that the qv_maps are
+ * invalid.
+ *
+ * Return: true if parameters are valid, false otherwise.
+ */
+static bool ice_vc_validate_qv_maps(struct ice_vf *vf,
+				    struct virtchnl_queue_vector_maps *qv_maps,
+				    u16 msglen)
+{
+	struct ice_vsi *vsi;
+	int total_vectors;
+
+	vsi = ice_get_vf_vsi(vf);
+	if (!vsi)
+		return false;
+
+	if (msglen < virtchnl_struct_size(qv_maps, qv_maps, 0))
+		return false;
+
+	if (msglen < virtchnl_struct_size(qv_maps, qv_maps, qv_maps->num_qv_maps))
+		return false;
+
+	if (!qv_maps->num_qv_maps)
+		return false;
+
+	if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states))
+		return false;
+
+	if (!ice_vc_isvalid_vsi_id(vf, qv_maps->vport_id))
+		return false;
+
+	total_vectors = vsi->num_q_vectors + ICE_NONQ_VECS_VF;
+
+	for (int i = 0; i < qv_maps->num_qv_maps; i++) {
+		if (!ice_vc_supported_queue_type(qv_maps->qv_maps[i].queue_type))
+			return false;
+
+		if (qv_maps->qv_maps[i].queue_id >= vf->num_vf_qs)
+			return false;
+
+		if (qv_maps->qv_maps[i].vector_id >= total_vectors ||
+		    qv_maps->qv_maps[i].vector_id < ICE_NONQ_VECS_VF)
+			return false;
+
+		if (qv_maps->qv_maps[i].itr_idx != VIRTCHNL_ITR_IDX_0 &&
+		    qv_maps->qv_maps[i].itr_idx != VIRTCHNL_ITR_IDX_1 &&
+		    qv_maps->qv_maps[i].itr_idx != VIRTCHNL_ITR_IDX_NO_ITR)
+			return false;
+	}
+
+	return true;
+}
+
+/**
+ * ice_vc_map_q_vector_msg - message handling for VIRTCHNL_OP_MAP_QUEUE_VECTOR
+ * @vf: source of the request
+ * @msg: message to handle
+ * @msglen: length of @msg
+ *
+ * Return: 0 on success or negative on error
+ */
+int ice_vc_map_q_vector_msg(struct ice_vf *vf, u8 *msg, u16 msglen)
+{
+	enum virtchnl_status_code v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+	struct virtchnl_queue_vector_maps *qv_maps;
+	struct ice_vsi *vsi;
+
+	qv_maps = (struct virtchnl_queue_vector_maps *)msg;
+
+	if (!ice_vc_validate_qv_maps(vf, qv_maps, msglen))
+		goto error_param;
+
+	vsi = ice_get_vf_vsi(vf);
+	if (!vsi)
+		goto error_param;
+
+	for (int i = 0; i < qv_maps->num_qv_maps; i++) {
+		struct virtchnl_queue_vector *qv_map = &qv_maps->qv_maps[i];
+		struct ice_q_vector *q_vector;
+		u16 vector_id;
+		int vsi_q_id;
+
+		vsi_q_id = qv_map->queue_id;
+		vector_id = qv_map->vector_id;
+
+		q_vector = vf->vf_ops->get_q_vector(vsi, vector_id);
+		if (!q_vector)
+			goto error_param;
+
+		if (!ice_vc_isvalid_q_id(vsi, vsi_q_id))
+			goto error_param;
+
+		/* keep SW state in sync with HW, as ice_cfg_interrupt() does */
+		if (qv_map->queue_type == VIRTCHNL_QUEUE_TYPE_RX) {
+			struct ice_rx_ring *ring = vsi->rx_rings[vsi_q_id];
+
+			if (ring->q_vector && ring->q_vector->num_ring_rx)
+				ring->q_vector->num_ring_rx--;
+			ring->q_vector = q_vector;
+			q_vector->num_ring_rx++;
+			q_vector->rx.itr_idx = qv_map->itr_idx;
+			ice_cfg_rxq_interrupt(vsi, vsi_q_id,
+					      q_vector->vf_reg_idx,
+					      qv_map->itr_idx);
+		} else if (qv_map->queue_type == VIRTCHNL_QUEUE_TYPE_TX) {
+			struct ice_tx_ring *ring = vsi->tx_rings[vsi_q_id];
+
+			if (ring->q_vector && ring->q_vector->num_ring_tx)
+				ring->q_vector->num_ring_tx--;
+			ring->q_vector = q_vector;
+			q_vector->num_ring_tx++;
+			q_vector->tx.itr_idx = qv_map->itr_idx;
+			ice_cfg_txq_interrupt(vsi, vsi_q_id,
+					      q_vector->vf_reg_idx,
+					      qv_map->itr_idx);
+		}
+	}
+
+	v_ret = VIRTCHNL_STATUS_SUCCESS;
+
+error_param:
+	return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_MAP_QUEUE_VECTOR,
+				     v_ret, NULL, 0);
+}
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH net-next v7 12/15] devlink: add cmode to resources
  2026-11-21 22:55 [PATCH net-next v7 00/15] devlink, mlx5, iavf, ice: XLVF for iavf Przemek Kitszel
                   ` (10 preceding siblings ...)
  2026-11-21 22:55 ` [PATCH net-next v7 11/15] ice: introduce handling of virtchnl LARGE VF opcodes Przemek Kitszel
@ 2026-11-21 22:55 ` Przemek Kitszel
  2026-11-24 21:57   ` netdev-bot+sashiko
  2026-11-21 22:55 ` [PATCH net-next v7 13/15] ice: represent RSS LUTs as devlink resources Przemek Kitszel
                   ` (3 subsequent siblings)
  15 siblings, 1 reply; 28+ messages in thread
From: Przemek Kitszel @ 2026-11-21 22:55 UTC (permalink / raw)
  To: netdev, Jakub Kicinski, Jiri Pirko
  Cc: Tony Nguyen, Aleksandr Loktionov, Michal Schmidt, edumazet, horms,
	pabeni, davem, Jonathan Corbet, skhan, rdunlap, andrew+netdev,
	saeedm, tariqt, leon, mbloch, jacob.e.keller, jedrzej.jagielski,
	anzaki, brett.creeley, ohartoov, Petr Oros, Donald Hunter,
	Przemek Kitszel

The size of a devlink resource set by the user takes effect only on
the next reload, until then it is reported as size_new. That does not
fit resources that the driver could change right away, like the RSS
lookup tables, which ice hands out to its PFs and VFs.

Add a configuration mode (cmode) to resources, reusing the values of
enum devlink_param_cmode. Existing resources are "driverinit". A driver
may make a resource "runtime" with devl_resource_runtime_register(),
then DEVLINK_CMD_RESOURCE_SET calls its .size_set() callback with the
validated size, which applies the change synchronously, or fails it
with nothing changed. As for runtime params, the driver owns the value:
.size_get() reports the size, so it stays correct also when the driver
changes it on its own, e.g. when a device reset restores the default.
There is no size_new for runtime resources, and occ is still the
current use. A runtime resource must have no parent and no children,
as the sizes in a resource tree are validated with size_new.

Report the new DEVLINK_ATTR_RESOURCE_CMODE for every resource, like
params report the cmode of each value. DEVLINK_CMD_RESOURCE_SET may
carry the expected cmode, and fails with -EOPNOTSUPP on a mismatch.

Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
---
RFC, Feb '25
https://lore.kernel.org/intel-wired-lan/20250219164410.35665-3-przemyslaw.kitszel@intel.com

v7:
 * rework: resource cmode instead of .occ_set(), occ is the current use
   again (Jakub); was "devlink: give user option to allocate resources",
   Alex's Reviewed-by dropped due to the rewrite
 * new DEVLINK_ATTR_RESOURCE_CMODE, reported for every resource, and
   checked when passed to DEVLINK_CMD_RESOURCE_SET
 * document runtime resources in devlink-resource.rst
---
 Documentation/netlink/specs/devlink.yaml      | 10 +++
 .../networking/devlink/devlink-resource.rst   | 19 +++++
 include/net/devlink.h                         |  8 ++
 include/uapi/linux/devlink.h                  |  2 +
 net/devlink/netlink_gen.c                     |  5 +-
 net/devlink/resource.c                        | 84 ++++++++++++++++++-
 6 files changed, 124 insertions(+), 4 deletions(-)

diff --git a/Documentation/netlink/specs/devlink.yaml b/Documentation/netlink/specs/devlink.yaml
index 4706de628392..709e40f8afb4 100644
--- a/Documentation/netlink/specs/devlink.yaml
+++ b/Documentation/netlink/specs/devlink.yaml
@@ -917,6 +917,13 @@ attribute-sets:
           Used with rate-set and rate-new to parent a rate object to a node on
           a different devlink instance, enabling cross-device rate scheduling.
           When absent, the parent node is resolved on the same instance.
+      -
+        name: resource-cmode
+        type: u8
+        enum: param-cmode
+        doc: |
+          Configuration mode of the resource, when a new size takes effect.
+          Runtime resources apply it immediately, others on driver reload.
 
   -
     name: dl-dev-stats
@@ -1240,6 +1247,8 @@ attribute-sets:
         name: resource-unit
       -
         name: resource-occ
+      -
+        name: resource-cmode
       -
         name: pad
 
@@ -1913,6 +1922,7 @@ operations:
             - index
             - resource-id
             - resource-size
+            - resource-cmode
 
     -
       name: resource-dump
diff --git a/Documentation/networking/devlink/devlink-resource.rst b/Documentation/networking/devlink/devlink-resource.rst
index b7172d94b2c6..cff32e5c661c 100644
--- a/Documentation/networking/devlink/devlink-resource.rst
+++ b/Documentation/networking/devlink/devlink-resource.rst
@@ -75,6 +75,25 @@ attribute, which represents the pending change in size. For example:
 Note that changes in resource size may require a device reload to properly
 take effect.
 
+Runtime Resources
+=================
+
+The configuration mode (``cmode``) of a resource tells when a new size takes
+effect. The default, ``driverinit``, is described above. A driver may register
+a resource as ``runtime`` with ``devl_resource_runtime_register()``, then
+a new size takes effect immediately: the driver applies it right away, or
+fails the request with nothing changed.
+
+The driver owns the size of a ``runtime`` resource. There is no ``size_new``,
+``size`` is the current size reported by the driver, which may also change it
+on its own, e.g. a device reset may restore the default size. ``occ`` stays
+the current usage, if the driver reports it.
+
+Every resource reports its cmode in ``DEVLINK_ATTR_RESOURCE_CMODE``, like
+params report the cmode of each value. A ``DEVLINK_CMD_RESOURCE_SET`` request
+may carry the expected cmode, the request then fails with ``EOPNOTSUPP`` if
+the resource has a different one.
+
 Port-level Resources and Full Dump
 ==================================
 
diff --git a/include/net/devlink.h b/include/net/devlink.h
index 98bdde4f72ca..dc9a642796f2 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -420,6 +420,10 @@ devlink_resource_size_params_init(struct devlink_resource_size_params *size_para
 }
 
 typedef u64 devlink_resource_occ_get_t(void *priv);
+typedef u64 devlink_resource_size_get_t(void *priv);
+typedef int devlink_resource_size_set_t(u64 size,
+					struct netlink_ext_ack *extack,
+					void *priv);
 
 #define DEVLINK_RESOURCE_ID_PARENT_TOP 0
 
@@ -1959,6 +1963,10 @@ void devl_resource_occ_get_register(struct devlink *devlink,
 				    void *occ_get_priv);
 void devl_resource_occ_get_unregister(struct devlink *devlink,
 				      u64 resource_id);
+void devl_resource_runtime_register(struct devlink *devlink, u64 resource_id,
+				    devlink_resource_size_get_t *size_get,
+				    devlink_resource_size_set_t *size_set,
+				    void *priv);
 int devl_params_register(struct devlink *devlink,
 			 const struct devlink_param *params,
 			 size_t params_count);
diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
index a6801feb7744..599fe8ecf512 100644
--- a/include/uapi/linux/devlink.h
+++ b/include/uapi/linux/devlink.h
@@ -650,6 +650,8 @@ enum devlink_attr {
 
 	DEVLINK_ATTR_PARENT_DEV,		/* nested */
 
+	DEVLINK_ATTR_RESOURCE_CMODE,		/* u8 */
+
 	/* Add new attributes above here, update the spec in
 	 * Documentation/netlink/specs/devlink.yaml and re-generate
 	 * net/devlink/netlink_gen.c.
diff --git a/net/devlink/netlink_gen.c b/net/devlink/netlink_gen.c
index 9e1b4c081a7b..16e70810a395 100644
--- a/net/devlink/netlink_gen.c
+++ b/net/devlink/netlink_gen.c
@@ -304,12 +304,13 @@ static const struct nla_policy devlink_dpipe_table_counters_set_nl_policy[DEVLIN
 };
 
 /* DEVLINK_CMD_RESOURCE_SET - do */
-static const struct nla_policy devlink_resource_set_nl_policy[DEVLINK_ATTR_INDEX + 1] = {
+static const struct nla_policy devlink_resource_set_nl_policy[DEVLINK_ATTR_RESOURCE_CMODE + 1] = {
 	[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
 	[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
 	[DEVLINK_ATTR_INDEX] = NLA_POLICY_FULL_RANGE(NLA_UINT, &devlink_attr_index_range),
 	[DEVLINK_ATTR_RESOURCE_ID] = { .type = NLA_U64, },
 	[DEVLINK_ATTR_RESOURCE_SIZE] = { .type = NLA_U64, },
+	[DEVLINK_ATTR_RESOURCE_CMODE] = NLA_POLICY_MAX(NLA_U8, 2),
 };
 
 /* DEVLINK_CMD_RESOURCE_DUMP - do */
@@ -969,7 +970,7 @@ const struct genl_split_ops devlink_nl_ops[75] = {
 		.doit		= devlink_nl_resource_set_doit,
 		.post_doit	= devlink_nl_post_doit,
 		.policy		= devlink_resource_set_nl_policy,
-		.maxattr	= DEVLINK_ATTR_INDEX,
+		.maxattr	= DEVLINK_ATTR_RESOURCE_CMODE,
 		.flags		= GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
 	},
 	{
diff --git a/net/devlink/resource.c b/net/devlink/resource.c
index c3cfda7ea070..2d31dac85eb1 100644
--- a/net/devlink/resource.c
+++ b/net/devlink/resource.c
@@ -20,6 +20,10 @@
  * @resource_list: list of child resources
  * @occ_get: occupancy getter callback
  * @occ_get_priv: occupancy getter callback priv
+ * @cmode: configuration mode, when a new size takes effect
+ * @size_get: size getter callback of a runtime resource
+ * @size_set: size setter callback of a runtime resource
+ * @size_priv: size callbacks priv
  */
 struct devlink_resource {
 	const char *name;
@@ -33,6 +37,10 @@ struct devlink_resource {
 	struct list_head resource_list;
 	devlink_resource_occ_get_t *occ_get;
 	void *occ_get_priv;
+	enum devlink_param_cmode cmode;
+	devlink_resource_size_get_t *size_get;
+	devlink_resource_size_set_t *size_set;
+	void *size_priv;
 };
 
 static struct devlink_resource *
@@ -119,6 +127,7 @@ int devlink_nl_resource_set_doit(struct sk_buff *skb, struct genl_info *info)
 {
 	struct devlink *devlink = devlink_nl_ctx(info)->devlink;
 	struct devlink_resource *resource;
+	struct nlattr *cmode_attr;
 	u64 resource_id;
 	u64 size;
 	int err;
@@ -132,11 +141,22 @@ int devlink_nl_resource_set_doit(struct sk_buff *skb, struct genl_info *info)
 	if (!resource)
 		return -EINVAL;
 
+	cmode_attr = info->attrs[DEVLINK_ATTR_RESOURCE_CMODE];
+	if (cmode_attr && nla_get_u8(cmode_attr) != resource->cmode) {
+		NL_SET_ERR_MSG_ATTR(info->extack, cmode_attr,
+				    "Configuration mode not supported by the resource");
+		return -EOPNOTSUPP;
+	}
+
 	size = nla_get_u64(info->attrs[DEVLINK_ATTR_RESOURCE_SIZE]);
 	err = devlink_resource_validate_size(resource, size, info->extack);
 	if (err)
 		return err;
 
+	if (resource->cmode == DEVLINK_PARAM_CMODE_RUNTIME)
+		return resource->size_set(size, info->extack,
+					  resource->size_priv);
+
 	resource->size_new = size;
 	devlink_resource_validate_children(resource);
 	if (resource->parent)
@@ -171,6 +191,13 @@ static int devlink_resource_occ_put(struct devlink_resource *resource,
 				  resource->occ_get(resource->occ_get_priv));
 }
 
+static u64 devlink_resource_size(struct devlink_resource *resource)
+{
+	if (resource->cmode == DEVLINK_PARAM_CMODE_RUNTIME)
+		return resource->size_get(resource->size_priv);
+	return resource->size;
+}
+
 static int devlink_resource_put(struct devlink *devlink, struct sk_buff *skb,
 				struct devlink_resource *resource)
 {
@@ -183,8 +210,10 @@ static int devlink_resource_put(struct devlink *devlink, struct sk_buff *skb,
 		return -EMSGSIZE;
 
 	if (nla_put_string(skb, DEVLINK_ATTR_RESOURCE_NAME, resource->name) ||
-	    devlink_nl_put_u64(skb, DEVLINK_ATTR_RESOURCE_SIZE, resource->size) ||
-	    devlink_nl_put_u64(skb, DEVLINK_ATTR_RESOURCE_ID, resource->id))
+	    devlink_nl_put_u64(skb, DEVLINK_ATTR_RESOURCE_SIZE,
+			       devlink_resource_size(resource)) ||
+	    devlink_nl_put_u64(skb, DEVLINK_ATTR_RESOURCE_ID, resource->id) ||
+	    nla_put_u8(skb, DEVLINK_ATTR_RESOURCE_CMODE, resource->cmode))
 		goto nla_put_failure;
 	if (resource->size != resource->size_new &&
 	    devlink_nl_put_u64(skb, DEVLINK_ATTR_RESOURCE_SIZE_NEW,
@@ -514,6 +543,11 @@ __devl_resource_register(struct devlink *devlink,
 							  NULL,
 							  parent_resource_id);
 		if (parent_resource) {
+			if (WARN_ON(parent_resource->cmode ==
+				    DEVLINK_PARAM_CMODE_RUNTIME)) {
+				kfree(resource);
+				return -EINVAL;
+			}
 			resource_list = &parent_resource->resource_list;
 			resource->parent = parent_resource;
 		} else {
@@ -527,6 +561,7 @@ __devl_resource_register(struct devlink *devlink,
 	resource->size_new = resource_size;
 	resource->id = resource_id;
 	resource->size_valid = true;
+	resource->cmode = DEVLINK_PARAM_CMODE_DRIVERINIT;
 	memcpy(&resource->size_params, params, sizeof(resource->size_params));
 	INIT_LIST_HEAD(&resource->resource_list);
 	list_add_tail(&resource->list, resource_list);
@@ -622,6 +657,8 @@ EXPORT_SYMBOL_GPL(devlink_resources_unregister);
  * @devlink: devlink
  * @resource_id: the requested resource id
  * @p_resource_size: ptr to update
+ *
+ * For a runtime resource, just get the size from its size_get() callback.
  */
 int devl_resource_size_get(struct devlink *devlink,
 			   u64 resource_id,
@@ -634,6 +671,10 @@ int devl_resource_size_get(struct devlink *devlink,
 	resource = devlink_resource_find(devlink, NULL, resource_id);
 	if (!resource)
 		return -EINVAL;
+	if (resource->cmode == DEVLINK_PARAM_CMODE_RUNTIME) {
+		*p_resource_size = resource->size_get(resource->size_priv);
+		return 0;
+	}
 	*p_resource_size = resource->size_new;
 	resource->size = resource->size_new;
 	return 0;
@@ -690,6 +731,45 @@ void devl_resource_occ_get_unregister(struct devlink *devlink,
 }
 EXPORT_SYMBOL_GPL(devl_resource_occ_get_unregister);
 
+/**
+ * devl_resource_runtime_register - make the resource size runtime configurable
+ *
+ * @devlink: devlink
+ * @resource_id: resource id
+ * @size_get: size getter callback
+ * @size_set: size setter callback
+ * @priv: size callbacks priv
+ *
+ * A new size of a runtime resource takes effect immediately: @size_set is
+ * called with a size that fits the size parameters of the resource, and must
+ * either apply it, or fail with nothing changed. The driver owns the size,
+ * @size_get reports it, also after the driver changed it on its own, e.g. when
+ * a device reset restored the default. Both callbacks are called with
+ * the instance lock held. The resource must have no parent and no children.
+ */
+void devl_resource_runtime_register(struct devlink *devlink, u64 resource_id,
+				    devlink_resource_size_get_t *size_get,
+				    devlink_resource_size_set_t *size_set,
+				    void *priv)
+{
+	struct devlink_resource *resource;
+
+	lockdep_assert_held(&devlink->lock);
+
+	resource = devlink_resource_find(devlink, NULL, resource_id);
+	if (WARN_ON(!resource || !size_get || !size_set))
+		return;
+	if (WARN_ON(resource->parent || !list_empty(&resource->resource_list)))
+		return;
+	WARN_ON(resource->cmode == DEVLINK_PARAM_CMODE_RUNTIME);
+
+	resource->cmode = DEVLINK_PARAM_CMODE_RUNTIME;
+	resource->size_get = size_get;
+	resource->size_set = size_set;
+	resource->size_priv = priv;
+}
+EXPORT_SYMBOL_GPL(devl_resource_runtime_register);
+
 /**
  * devl_port_resource_register - devlink port resource register
  *
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH net-next v7 13/15] ice: represent RSS LUTs as devlink resources
  2026-11-21 22:55 [PATCH net-next v7 00/15] devlink, mlx5, iavf, ice: XLVF for iavf Przemek Kitszel
                   ` (11 preceding siblings ...)
  2026-11-21 22:55 ` [PATCH net-next v7 12/15] devlink: add cmode to resources Przemek Kitszel
@ 2026-11-21 22:55 ` Przemek Kitszel
  2026-11-24 21:57   ` netdev-bot+sashiko
  2026-11-21 22:55 ` [PATCH net-next v7 14/15] devlink: add devlink_alloc_drv() Przemek Kitszel
                   ` (2 subsequent siblings)
  15 siblings, 1 reply; 28+ messages in thread
From: Przemek Kitszel @ 2026-11-21 22:55 UTC (permalink / raw)
  To: netdev, Jakub Kicinski, Jiri Pirko
  Cc: Tony Nguyen, Aleksandr Loktionov, Michal Schmidt, edumazet, horms,
	pabeni, davem, Jonathan Corbet, skhan, rdunlap, andrew+netdev,
	saeedm, tariqt, leon, mbloch, jacob.e.keller, jedrzej.jagielski,
	anzaki, brett.creeley, ohartoov, Petr Oros, Donald Hunter,
	Przemek Kitszel

E800 family offers three kinds of RSS LUTs: VSI LUT (sized 64), GLOBAL LUT
(sized 512), and PF LUT (sized 2048). Until now the GLOBAL kind was not
used at all. There are two possible usages for it, subsequent commit will
give VF option to acquire it, and this one enables PF to switch between PF
LUT and GLOBAL LUT - switching to smaller one is, again, to make it
possible for VF to then acquire the former one.

Devlink resources are used to let user show current usage and change the
allocation, see examples below.

Each PF has a "rss_lut" resource, the size of its RSS LUT in entries.
It is a runtime resource, a new size applies immediately. The whole
device devlink instance reports how many LUTs of each kind the device has,
and how many of them are in use (occ), those are read-only.

Default state on a card with 8 PFs, asking the "whole device" instance,
note that there are as many PF LUTs as there are PFs, and, for e810, there
are 16 GLOBAL LUTs:
$ devlink resource show devlink_index/11
devlink_index/11:
  name rss_lut_512 size 16 occ 0 unit entry dpipe_tables none
  name rss_lut_2048 size 8 occ 8 unit entry dpipe_tables none

Now let's switch a PF to a GLOBAL LUT:
$ sudo devlink resource set pci/0000:18:00.0 path rss_lut size 512
And show its resources after that:
$ devlink resource show pci/0000:18:00.0
pci/0000:18:00.0:
  name rss_lut size 512 unit entry size_min 512 size_max 2048 size_gran 512 dpipe_tables none
now `ethtool -x $ifacename` will report smaller RSS table.

Changing the LUT of a PF keeps the RSS indirection table set by the user,
ethtool_rxfh_indir_resize() repeats it to fill a bigger LUT, and folds it
into a smaller one. A change to a smaller LUT that the table can't be
folded into is rejected. Without a user table the new LUT gets the
default spread. The PF LUT change is done under rtnl, as the ethtool core
sizes its RSS buffers by the table size, and records the size of the user
table, under rtnl.

FW drops RSS LUT assignments on reset, so the driver gives the PF its PF
LUT back after each reset, with the user table repeated to fill it, and
logs when that discards a devlink change. Changes are rejected with -EBUSY
while a reset is in progress.

RSS LUTs can't be changed while ADQ is configured, or with RSS disabled,
e.g. in safe mode. ADQ can't be configured while the RSS LUTs of the PF
are reassigned.

Keep the NAC topology in the safe mode caps, otherwise the PFs of the
secondary NAC collide with the primary ones in the table of LUT owners.
ice_is_dual() and ice_is_primary() now answer the same in safe mode as
in the normal mode.

Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
---
v7:
 * keep the user RSS indirection table when the PF LUT changes, also on
   reset, instead of resetting it to the default spread: it is repeated
   to fill a bigger LUT, and folded into a smaller one, with
   ethtool_rxfh_indir_resize(); a change to a smaller LUT that the table
   can't be folded into is rejected (Jakub)
 * reject a PF LUT change when the user RSS indirection table uses
   queues that the new LUT can't spread traffic to (me)
 * one runtime "rss_lut" resource per PF, the size of its LUT in entries,
   no more two-step switch via lut_512/lut_2048 counts, no "rss" parent
   resource (Jakub); a small deviation: a new size applies right away,
   it is the LUT in use, not a cap for the next LUT allocation
 * whole device rss_lut_512 and rss_lut_2048: size is the number of LUTs
   of the device, occ is how many of them are in use, read-only (Jakub)
 * move rss_lut_lock, setting the default RSS LUT type only on VSI
   init, and the Q_OPT source of the RDMA filter toggle to a new patch,
   "ice: prepare RSS LUT config for runtime LUT changes" (Jakub)
 * move the PF rss_size limit on a LUT change here from "ice: support
   up to 256 VF queues", along with its changelog entries; with this
   patch alone a PF with more than 64 queues put queue ids above 63 into
   a GLOBAL LUT (me)
 * reject RSS LUT changes with RSS disabled, e.g. in safe mode (me)
 * ice.rst: say how many queues each kind of RSS LUT spreads traffic
   to (Sashiko)
 * check the global LUT ID from FW against the size of the table, it is
   used as an index (Sashiko)
 * one owner table for PF LUTs and one per NAC for global LUTs, instead
   of a table per devlink resource ID plus one for global LUTs of the
   secondary NAC (me)
 * clear ICE_FLAG_TC_MQPRIO when the ADQ setup fails, it blocked RSS
   LUT changes until mqprio was reconfigured (Sashiko)
 * commit message: describe the ADQ and safe mode handling (Sashiko)

v5:
 * keep the NAC topology in safe mode caps, secondary NAC PFs collided
   with primary ones in the devlink RSS LUT table (Sashiko)
 * fix the kernel-doc opener of ice_rss_lut_resource_state(), the whole
   comment was ignored (me)
 * assert rss_lut_lock in ice_vsi_update_rss_lut() (me)
 * don't set rss_size of the PF VSI when restoring its PF LUT after
   reset, the PF VSI rebuild right after sets the default anyway
   (Sashiko)

v4:
 * take rtnl when devlink changes the RSS LUT of the PF, the new LUT is
   filled based on NETIF_F_RXHASH, which raced with ndo_set_features
   (Sashiko)
 * drop the -EAGAIN checks from get/set_rxfh, they broke ethtool -L after
   ethtool -X, and were hit after the hash function and key were already
   written (Sashiko); the PF RSS LUT size now changes only under rtnl,
   also on reset (me)
 * tell the ethtool core when the user RSS LUT is dropped, on devlink LUT
   change and on reset (Sashiko)
 * reject devlink RSS LUT changes while a reset is in progress, they
   could leak a global LUT (Sashiko)
 * log when a reset discards a devlink RSS LUT assignment (Sashiko)
 * drop global RSS LUTs of the PF from the table already in
   ice_prepare_for_reset(), FW frees them on reset and could give them
   to other PFs before our rebuild cleaned the table, that hit the WARN
   in ice_devl_res_take() when LUT changes raced resets of other PFs (me)
 * taking adapter devl there also waits for devlink RSS LUT changes that
   checked for a reset just before it was requested, they could still
   leak a global LUT (Sashiko)
 * keep the specific extack message and the real errno when a LUT change
   fails (Sashiko)
 * declare rel_err at function scope, a declaration right after a label
   does not build with GCC < 11 and breaks sparse (Jakub)
 * document the devlink resources in ice.rst (Sashiko)

v3:
 * don't free the user RSS LUT in ice_vsi_decfg(), it was done outside
   of pf->rss_lut_lock, and is redundant anyway: ice_vsi_cfg_def() frees
   it under the lock when the LUT size changes (Sashiko)
 * fill the new RSS LUT under rss_lut_lock (me)
 * keep PF RSS LUT zeroed on change when RXHASH is disabled (me)
 * restore default RSS LUT assignment of PF after reset, FW drops it
 * dual-NAC: each NAC numbers its PFs from 0, offset secondary NAC PFs by
   ICE_PORTS_PER_QUAD in the devlink resource table, reserve
   2 * ICE_PORTS_PER_QUAD PF LUT slots
 * dual-NAC: FW of each NAC numbers its global LUTs from 0, keep a separate
   global LUT table for the secondary NAC
 * register PF devlink resources only in the regular probe path, not in
   FW recovery mode, where pf->adapter is NULL
 * restore VF aggregator node accounting in ice_vsi_decfg(), removed by
   mistake (me)
 * drop PF RSS LUT ownership also in ice_deinit_pf(), ice_vsi_decfg()
   skips it after a NO_INIT VSI rebuild (me)
 * drop a stray debug change of the error message in ice_get_rss_lut()

v2:
 * replace -ENOANO with proper WARN_ON for "assumption error" (Alex)
 * fix goto label (Sashiko)
 * avoid queues being 0 in ADQ mode (Sashiko)
 * undo ice_take_rss_lut_pf() on error path (Sashiko)
 * program the PF VSI context with the new LUT type and global LUT ID
   after writing the LUT, so the PF really switches to the new table;
   publish the global LUT ID to the VSI only after a successful switch
 * limit PF rss_size to the queue capacity of its current RSS LUT
   (64 for GLOBAL) on devlink LUT switch; restore it from num_rxq when
   switching back to the PF LUT
 * drop the cached user RSS LUT when the RSS table size changes, on
   devlink LUT switch and on reset
 * use logical_pf_id for all PF bookkeeping of devlink resources, as the
   PF LUT resource is sized by the number of functions
 * warn when FW fails to free a global RSS LUT
 * return -EAGAIN from get/set_rxfh when the LUT was resized after
   the core sized the indirection table
 * reject ADQ when RSS LUTs are reassigned via devlink, and reject
   devlink RSS LUT changes when ADQ is configured (-EOPNOTSUPP)
 * remove trailing whitespace
 * commit message: GLOBAL LUT is sized 512, not 256
---
 Documentation/networking/devlink/ice.rst      |  59 ++
 drivers/net/ethernet/intel/ice/Makefile       |   1 +
 .../net/ethernet/intel/ice/devlink/resource.h |  25 +
 drivers/net/ethernet/intel/ice/ice.h          |   2 +-
 drivers/net/ethernet/intel/ice/ice_adapter.h  |  29 +
 drivers/net/ethernet/intel/ice/ice_common.h   |   1 +
 drivers/net/ethernet/intel/ice/ice_lib.h      |   3 +
 .../net/ethernet/intel/ice/devlink/resource.c | 643 ++++++++++++++++++
 drivers/net/ethernet/intel/ice/ice_adapter.c  |  19 +-
 drivers/net/ethernet/intel/ice/ice_common.c   |   5 +-
 drivers/net/ethernet/intel/ice/ice_lib.c      |  57 +-
 drivers/net/ethernet/intel/ice/ice_main.c     |  27 +-
 12 files changed, 864 insertions(+), 7 deletions(-)
 create mode 100644 drivers/net/ethernet/intel/ice/devlink/resource.h
 create mode 100644 drivers/net/ethernet/intel/ice/devlink/resource.c

diff --git a/Documentation/networking/devlink/ice.rst b/Documentation/networking/devlink/ice.rst
index 792e9f8c846a..d410dd6bb29f 100644
--- a/Documentation/networking/devlink/ice.rst
+++ b/Documentation/networking/devlink/ice.rst
@@ -485,3 +485,62 @@ and arbitration among them is based on assigned weights.
 
     # assign tx_share to the VF
     $ devlink port function rate set pci/0000:4b:00.0/2 tx_share 500Mbps
+
+Resources
+=========
+
+The ``ice`` driver exposes the RSS lookup tables (LUTs) of the device as
+devlink resources. E800 devices have three kinds of RSS LUTs: a VSI LUT
+(64 entries) for each VSI, 16 global LUTs (512 entries) for each NAC of the
+device, and a PF LUT (2048 entries) for each PF. By default each PF uses its
+PF LUT. RSS spreads traffic over up to 16 queues with a VSI LUT, 64 with
+a global LUT, and 256 with a PF LUT.
+
+.. list-table:: Resources implemented
+    :widths: 15 15 70
+
+    * - Name
+      - Instance
+      - Description
+    * - ``rss_lut``
+      - PF
+      - The size of the RSS LUT of the function, 512 or 2048 for a PF.
+        Only these sizes are accepted, not every multiple of ``size_gran``.
+        A new size applies immediately (``runtime`` configuration mode).
+    * - ``rss_lut_512``
+      - whole device
+      - The number of global LUTs of the device, ``occ`` is how many of them
+        are in use. Read-only.
+    * - ``rss_lut_2048``
+      - whole device
+      - The number of PF LUTs of the device, ``occ`` is how many of them are
+        in use. Read-only.
+
+The whole device devlink instance is shared by all PFs of the device.
+
+Changing the LUT of a PF keeps the RSS indirection table set with
+``ethtool -X``, also when a reset gives the PF LUT back to the PF. The table
+is repeated to fill a bigger LUT. A change to a smaller LUT is rejected if
+the table doesn't fit it, reset the table with ``ethtool -X <dev> default``
+first.
+
+RSS LUTs can't be changed while ADQ is configured, and ADQ can't be
+configured while the RSS LUTs of the PF are reassigned.
+
+Firmware drops the LUT assignments on reset (PFR, CORER or GLOBR). The
+driver then restores the default assignment, and logs that it did so.
+Changes are rejected with ``EBUSY`` while a reset is in progress.
+
+.. code:: shell
+
+    # whole device on a card with 8 PFs
+    $ devlink resource show devlink_index/11
+    devlink_index/11:
+      name rss_lut_512 size 16 occ 0 unit entry dpipe_tables none
+      name rss_lut_2048 size 8 occ 8 unit entry dpipe_tables none
+
+    # switch a PF to a global LUT
+    $ devlink resource set pci/0000:18:00.0 path rss_lut size 512
+    $ devlink resource show pci/0000:18:00.0
+    pci/0000:18:00.0:
+      name rss_lut size 512 unit entry size_min 512 size_max 2048 size_gran 512 dpipe_tables none
diff --git a/drivers/net/ethernet/intel/ice/Makefile b/drivers/net/ethernet/intel/ice/Makefile
index a952bacb7ec7..e50e02efbf7a 100644
--- a/drivers/net/ethernet/intel/ice/Makefile
+++ b/drivers/net/ethernet/intel/ice/Makefile
@@ -34,6 +34,7 @@ ice-y := ice_main.o	\
 	 devlink/devlink.o	\
 	 devlink/health.o \
 	 devlink/port.o \
+	 devlink/resource.o \
 	 ice_sf_eth.o	\
 	 ice_sf_vsi_vlan_ops.o \
 	 ice_ddp.o	\
diff --git a/drivers/net/ethernet/intel/ice/devlink/resource.h b/drivers/net/ethernet/intel/ice/devlink/resource.h
new file mode 100644
index 000000000000..a41bda0ff6c8
--- /dev/null
+++ b/drivers/net/ethernet/intel/ice/devlink/resource.h
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (c) 2026, Intel Corporation. */
+
+#ifndef _ICE_DEVL_RESOURCE_H_
+#define _ICE_DEVL_RESOURCE_H_
+
+#include <linux/types.h>
+
+struct devlink;
+struct ice_adapter;
+struct ice_hw;
+struct ice_pf;
+
+void ice_devl_pf_resources_register(struct ice_pf *pf);
+void ice_devl_whole_dev_resources_register(const struct ice_hw *hw,
+					   struct ice_adapter *adapter);
+
+bool ice_rss_lut_is_reassigned(struct ice_pf *pf);
+int ice_take_rss_lut_pf(struct ice_pf *pf);
+void ice_release_rss_lut_pf(struct ice_pf *pf);
+void ice_prepare_rss_luts_for_reset(struct ice_pf *pf);
+int ice_rebuild_rss_luts(struct ice_pf *pf);
+void ice_free_rss_lut_flr(struct ice_pf *pf);
+
+#endif /* _ICE_DEVL_RESOURCE_H_ */
diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h
index 4de947165a08..611f1346b4a7 100644
--- a/drivers/net/ethernet/intel/ice/ice.h
+++ b/drivers/net/ethernet/intel/ice/ice.h
@@ -1114,7 +1114,7 @@ extern const struct xdp_metadata_ops ice_xdp_md_ops;
  * Acceleration Complex) configuration variant, false otherwise
  * (always false for non-E825 devices).
  */
-static inline bool ice_is_dual(struct ice_hw *hw)
+static inline bool ice_is_dual(const struct ice_hw *hw)
 {
 	return hw->mac_type == ICE_MAC_GENERIC_3K_E825 &&
 	       (hw->dev_caps.nac_topo.mode & ICE_NAC_TOPO_DUAL_M);
diff --git a/drivers/net/ethernet/intel/ice/ice_adapter.h b/drivers/net/ethernet/intel/ice/ice_adapter.h
index 698a5b9af82f..f031b0596032 100644
--- a/drivers/net/ethernet/intel/ice/ice_adapter.h
+++ b/drivers/net/ethernet/intel/ice/ice_adapter.h
@@ -16,6 +16,26 @@
 struct pci_dev;
 struct ice_pf;
 
+enum ice_devl_resource_id {
+	ICE_TOP_RESOURCE = DEVLINK_RESOURCE_ID_PARENT_TOP,
+	ICE_RSS_LUT,		/* RSS LUT size of a PF or VF */
+	ICE_RSS_LUT_GLOBAL,	/* global RSS LUTs of the device */
+	ICE_RSS_LUT_PF,		/* PF RSS LUTs of the device */
+};
+
+#define ICE_MAX_DEVL_RESOURCE_UNITS 16
+
+/**
+ * struct ice_devl_resource - owners of the RSS LUTs of one type
+ *
+ * @owner: entity that owns given resource (like ptr to ice_pf or ice_vf)
+ * @pf_id: on which PF the VF is (or just PF id when PF is the owner)
+ */
+struct ice_devl_resource {
+	void *owner[ICE_MAX_DEVL_RESOURCE_UNITS];
+	u8 pf_id[ICE_MAX_DEVL_RESOURCE_UNITS];
+};
+
 /**
  * struct ice_port_list - data used to store the list of adapter ports
  *
@@ -46,6 +66,9 @@ struct ice_port_list {
  *                  which all PFs reach. Used on E825C devices.
  * @ctrl_pf: Control PF of the adapter
  * @ports: Ports list
+ * @pf_luts: owners of the PF RSS LUTs of the device
+ * @global_luts: owners of the global RSS LUTs of the primary and the
+ *		 secondary NAC, FW of each NAC numbers them from 0
  */
 struct ice_adapter {
 	struct devlink *devlink;
@@ -61,9 +84,15 @@ struct ice_adapter {
 
 	struct ice_pf *ctrl_pf;
 	struct ice_port_list ports;
+
+	struct ice_devl_resource pf_luts;
+	struct ice_devl_resource global_luts[2];
 };
 
 struct ice_adapter *ice_adapter_get(struct pci_dev *pdev);
 void ice_adapter_put(struct ice_adapter *adapter);
 
+DEFINE_GUARD(ice_adapter_devl, struct ice_adapter *,
+	     devl_lock((_T)->devlink), devl_unlock((_T)->devlink))
+
 #endif /* _ICE_ADAPTER_H */
diff --git a/drivers/net/ethernet/intel/ice/ice_common.h b/drivers/net/ethernet/intel/ice/ice_common.h
index d1d674ca644f..d019ec759eda 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.h
+++ b/drivers/net/ethernet/intel/ice/ice_common.h
@@ -125,6 +125,7 @@ int ice_read_txq_ctx(struct ice_hw *hw, struct ice_tlan_ctx *tlan_ctx,
 int ice_write_txq_ctx(struct ice_hw *hw, struct ice_tlan_ctx *tlan_ctx,
 		      u32 txq_index);
 
+enum ice_lut_size ice_lut_type_to_size(enum ice_lut_type type);
 int
 ice_aq_get_rss_lut(struct ice_hw *hw, struct ice_aq_get_set_rss_lut_params *get_params);
 int
diff --git a/drivers/net/ethernet/intel/ice/ice_lib.h b/drivers/net/ethernet/intel/ice/ice_lib.h
index e0d3ae067f35..320edbdece3d 100644
--- a/drivers/net/ethernet/intel/ice/ice_lib.h
+++ b/drivers/net/ethernet/intel/ice/ice_lib.h
@@ -49,6 +49,9 @@ int ice_vsi_cfg_tc(struct ice_vsi *vsi, u8 ena_tc);
 
 int ice_vsi_cfg_rss_lut_key(struct ice_vsi *vsi);
 
+int ice_vsi_update_rss_lut(struct ice_vsi *vsi, enum ice_lut_type lut_type,
+			   u8 global_lut_id);
+
 void ice_vsi_cfg_netdev_tc(struct ice_vsi *vsi, u8 ena_tc);
 
 struct ice_vsi *
diff --git a/drivers/net/ethernet/intel/ice/devlink/resource.c b/drivers/net/ethernet/intel/ice/devlink/resource.c
new file mode 100644
index 000000000000..c07f61acdaed
--- /dev/null
+++ b/drivers/net/ethernet/intel/ice/devlink/resource.c
@@ -0,0 +1,643 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2026, Intel Corporation. */
+
+#include "resource.h"
+#include "ice_adapter.h"
+#include "ice.h"
+#include "ice_lib.h"
+
+#define ICE_NUM_GLOBAL_LUTS	16
+#define ICE_ANY_SLOT		-1
+
+/* each NAC numbers its PFs from 0, secondary NAC ones go after primary ones */
+static int ice_devl_pf_id(struct ice_pf *pf)
+{
+	struct ice_hw *hw = &pf->hw;
+
+	if (ice_is_primary(hw))
+		return hw->logical_pf_id;
+
+	return hw->logical_pf_id + ICE_PORTS_PER_QUAD;
+}
+
+/* each NAC has its own global LUTs, with IDs given by its FW */
+static struct ice_devl_resource *
+ice_devl_res_tbl(struct ice_pf *pf, enum ice_devl_resource_id res_id)
+{
+	if (res_id == ICE_RSS_LUT_GLOBAL)
+		return &pf->adapter->global_luts[!ice_is_primary(&pf->hw)];
+
+	return &pf->adapter->pf_luts;
+}
+
+static u32 ice_devl_res_cnt(const struct ice_devl_resource *res)
+{
+	u32 sum = 0;
+
+	for (int i = 0; i < ARRAY_SIZE(res->owner); i++)
+		sum += res->owner[i] != NULL;
+
+	return sum;
+}
+
+static int ice_devl_res_take(struct ice_pf *pf,
+			     enum ice_devl_resource_id res_id, int slot,
+			     void *owner)
+{
+	struct ice_devl_resource *res = ice_devl_res_tbl(pf, res_id);
+	int beg, end, new_id = ICE_ANY_SLOT;
+	u16 lut_id;
+
+	if (res_id == ICE_RSS_LUT_GLOBAL) {
+		int err;
+
+		WARN_ON_ONCE(slot != ICE_ANY_SLOT);
+
+		err = ice_alloc_rss_global_lut(&pf->hw, &lut_id);
+		if (err)
+			return err;
+		if (lut_id >= ARRAY_SIZE(res->owner)) {
+			ice_free_rss_global_lut(&pf->hw, lut_id);
+			return -EIO;
+		}
+
+		slot = lut_id;
+	}
+
+	end = slot == ICE_ANY_SLOT ? ARRAY_SIZE(res->owner) : slot + 1;
+	beg = slot == ICE_ANY_SLOT ? 0 : slot;
+	for (int id = beg; id < end; id++) {
+		if (!res->owner[id]) {
+			new_id = id;
+			break;
+		}
+	}
+	if (new_id == ICE_ANY_SLOT) {
+		if (WARN_ON(res_id == ICE_RSS_LUT_GLOBAL))
+			ice_free_rss_global_lut(&pf->hw, lut_id);
+
+		return -ENOSPC;
+	}
+
+	res->owner[new_id] = owner;
+	res->pf_id[new_id] = ice_devl_pf_id(pf);
+	return new_id;
+}
+
+static int ice_devl_res_free(struct ice_pf *pf,
+			     enum ice_devl_resource_id res_id, void *owner)
+{
+	struct ice_devl_resource *res = ice_devl_res_tbl(pf, res_id);
+	int err = 0, id_to_free = ICE_ANY_SLOT;
+
+	for (int i = 0; i < ARRAY_SIZE(res->owner); i++) {
+		if (res->owner[i] == owner) {
+			id_to_free = i;
+			break;
+		}
+	}
+	if (id_to_free == ICE_ANY_SLOT)
+		return 0;
+
+	if (res_id == ICE_RSS_LUT_GLOBAL) {
+		err = ice_free_rss_global_lut(&pf->hw, id_to_free);
+		if (err)
+			dev_warn(ice_pf_to_dev(pf), "failed to free global RSS LUT %d, leaked until PF reset: %d\n",
+				 id_to_free, err);
+	}
+
+	res->owner[id_to_free] = NULL;
+	return err;
+}
+
+static void ice_free_rss_lut_flr_locked(struct ice_pf *pf)
+{
+	int pf_id = ice_devl_pf_id(pf);
+	struct ice_devl_resource *res;
+
+	devl_assert_locked(pf->adapter->devlink);
+	pf->adapter->pf_luts.owner[pf_id] = NULL;
+
+	res = ice_devl_res_tbl(pf, ICE_RSS_LUT_GLOBAL);
+	for (int i = 0; i < ARRAY_SIZE(res->owner); i++) {
+		/* On FLR/PFR resources assigned to PF are cleared by FW,
+		 * reflect that in the SW table.
+		 * VFs on given PF must be de-programmed too.
+		 */
+		if (res->pf_id[i] == pf_id)
+			res->owner[i] = NULL;
+	}
+}
+
+void ice_free_rss_lut_flr(struct ice_pf *pf)
+{
+	scoped_guard(ice_adapter_devl, pf->adapter)
+		ice_free_rss_lut_flr_locked(pf);
+}
+
+static int ice_devl_res_owned_idx(struct ice_pf *pf,
+				  enum ice_devl_resource_id res_id, void *owner)
+{
+	const struct ice_devl_resource *res = ice_devl_res_tbl(pf, res_id);
+
+	for (int i = 0; i < ARRAY_SIZE(res->owner); i++) {
+		if (res->owner[i] == owner)
+			return i;
+	}
+
+	return -ENXIO;
+}
+
+static bool ice_is_devl_res_owned_by(struct ice_pf *pf,
+				     enum ice_devl_resource_id res_id,
+				     void *owner)
+{
+	return ice_devl_res_owned_idx(pf, res_id, owner) >= 0;
+}
+
+static u64 ice_rss_lut_whole_dev_occ_get_global(void *priv)
+{
+	struct ice_adapter *adapter = priv;
+
+	return ice_devl_res_cnt(&adapter->global_luts[0]) +
+	       ice_devl_res_cnt(&adapter->global_luts[1]);
+}
+
+static u64 ice_rss_lut_whole_dev_occ_get_pf(void *priv)
+{
+	struct ice_adapter *adapter = priv;
+
+	return ice_devl_res_cnt(&adapter->pf_luts);
+}
+
+static enum ice_lut_type ice_rss_lut_type(struct ice_pf *pf, void *owner)
+{
+	if (ice_is_devl_res_owned_by(pf, ICE_RSS_LUT_PF, owner))
+		return ICE_LUT_PF;
+	if (ice_is_devl_res_owned_by(pf, ICE_RSS_LUT_GLOBAL, owner))
+		return ICE_LUT_GLOBAL;
+
+	return ICE_LUT_VSI;
+}
+
+static u64 ice_rss_lut_pf_size_get(void *priv)
+{
+	struct ice_pf *pf = priv;
+
+	scoped_guard(ice_adapter_devl, pf->adapter) {
+		enum ice_lut_type type = ice_rss_lut_type(pf, pf);
+
+		/* reset in progress, it gives the PF its PF LUT back */
+		if (type == ICE_LUT_VSI)
+			type = ICE_LUT_PF;
+		return ice_lut_type_to_size(type);
+	}
+}
+
+static int ice_rss_lut_user_resize(struct ice_vsi *vsi,
+				   enum ice_lut_type lut_type, u8 **user_lut,
+				   struct netlink_ext_ack *extack)
+{
+	int qs_num = ice_lut_type_to_qs_num(lut_type);
+	int size = ice_lut_type_to_size(lut_type);
+	struct net_device *netdev = vsi->netdev;
+	int old_size = vsi->rss_table_size;
+	u32 max_q = 0;
+	int err = 0;
+	u32 *indir;
+	u8 *lut;
+
+	if (!netdev || !vsi->rss_lut_user || !netif_is_rxfh_configured(netdev))
+		return 0;
+
+	indir = kmalloc_objs(*indir, max(old_size, size));
+	if (!indir)
+		return -ENOMEM;
+
+	for (int i = 0; i < old_size; i++) {
+		indir[i] = vsi->rss_lut_user[i];
+		max_q = max(max_q, indir[i]);
+	}
+	if (!ethtool_rxfh_indir_can_resize(netdev, indir, old_size, size)) {
+		NL_SET_ERR_MSG_FMT_MOD(extack,
+				       "can't fold the RSS indirection table to %d entries, reset it first",
+				       size);
+		err = -EINVAL;
+		goto out;
+	}
+	if (max_q >= qs_num) {
+		NL_SET_ERR_MSG_FMT_MOD(extack,
+				       "RSS indirection table uses queue %u, the new LUT is limited to %d queues",
+				       max_q, qs_num);
+		err = -EINVAL;
+		goto out;
+	}
+
+	lut = devm_kmalloc(ice_pf_to_dev(vsi->back), size, GFP_KERNEL);
+	if (!lut) {
+		err = -ENOMEM;
+		goto out;
+	}
+
+	ethtool_rxfh_indir_resize(netdev, indir, old_size, size);
+	for (int i = 0; i < size; i++)
+		lut[i] = indir[i];
+	*user_lut = lut;
+out:
+	kfree(indir);
+	return err;
+}
+
+static int ice_change_rss_lut(struct ice_pf *pf, void *owner,
+			      enum ice_lut_type lut_type,
+			      struct netlink_ext_ack *extack)
+{
+	struct ice_aq_get_set_rss_lut_params params = {};
+	struct ice_hw *hw = &pf->hw;
+	int err, lut_size, lut_id;
+	struct ice_vsi *vsi;
+	u8 *user_lut = NULL;
+	u16 rss_size;
+	u8 *lut;
+
+	if (lut_type == ICE_LUT_GLOBAL) {
+		lut_id = ice_devl_res_owned_idx(pf, ICE_RSS_LUT_GLOBAL, owner);
+		if (lut_id < 0)
+			return lut_id;
+
+		params.global_lut_id = lut_id;
+	}
+
+	if (pf == owner) {
+		vsi = ice_get_main_vsi(pf);
+	} else {
+		return -EOPNOTSUPP;
+	}
+
+	lut_size = ice_lut_type_to_size(lut_type);
+	lut = kzalloc(lut_size, GFP_KERNEL);
+	if (!lut)
+		return -ENOMEM;
+	params.lut = lut;
+	params.lut_size = lut_size;
+	params.lut_type = lut_type;
+	params.vsi_handle = vsi->idx;
+	mutex_lock(&pf->rss_lut_lock);
+	rss_size = min(vsi->num_rxq, ice_lut_type_to_qs_num(lut_type));
+	err = ice_rss_lut_user_resize(vsi, lut_type, &user_lut, extack);
+	if (err)
+		goto out;
+	/* PF with RXHASH disabled keeps its LUT zeroed */
+	if (!vsi->netdev || vsi->netdev->features & NETIF_F_RXHASH) {
+		if (user_lut)
+			memcpy(lut, user_lut, lut_size);
+		else
+			ice_fill_rss_lut(lut, lut_size, rss_size);
+	}
+	err = ice_aq_set_rss_lut(hw, &params);
+	if (err) {
+		NL_SET_ERR_MSG_FMT(extack, "AQ failed: %s", libie_aq_str(hw->adminq.sq_last_status));
+		goto out;
+	}
+
+	err = ice_vsi_update_rss_lut(vsi, lut_type, params.global_lut_id);
+	if (err)
+		goto out;
+
+	devm_kfree(ice_pf_to_dev(pf), vsi->rss_lut_user);
+	vsi->rss_lut_user = user_lut;
+	user_lut = NULL;
+	if (lut_type == ICE_LUT_GLOBAL)
+		vsi->global_lut_id = params.global_lut_id;
+	vsi->rss_table_size = lut_size;
+	vsi->rss_lut_type = lut_type;
+	vsi->rss_size = rss_size;
+out:
+	mutex_unlock(&pf->rss_lut_lock);
+	devm_kfree(ice_pf_to_dev(pf), user_lut);
+	kfree(lut);
+	return err;
+}
+
+static enum ice_devl_resource_id ice_rss_lut_res_id(enum ice_lut_type type)
+{
+	return type == ICE_LUT_PF ? ICE_RSS_LUT_PF : ICE_RSS_LUT_GLOBAL;
+}
+
+static int ice_rss_lut_set(struct ice_pf *pf, void *owner, u64 size,
+			   struct netlink_ext_ack *extack)
+{
+	enum ice_lut_type old_type, new_type;
+	int err, slot;
+
+	if (!test_bit(ICE_FLAG_RSS_ENA, pf->flags)) {
+		NL_SET_ERR_MSG_MOD(extack, "RSS is not supported");
+		return -EOPNOTSUPP;
+	}
+
+	switch (size) {
+	case ICE_LUT_VSI_SIZE:
+		new_type = ICE_LUT_VSI;
+		break;
+	case ICE_LUT_GLOBAL_SIZE:
+		new_type = ICE_LUT_GLOBAL;
+		break;
+	case ICE_LUT_PF_SIZE:
+		new_type = ICE_LUT_PF;
+		break;
+	default:
+		NL_SET_ERR_MSG_MOD(extack, "RSS LUT size must be 512 or 2048");
+		return -EINVAL;
+	}
+
+	old_type = ice_rss_lut_type(pf, owner);
+	if (new_type == old_type)
+		return 0;
+
+	/* reset rebuilds the table and the VSIs, see ice_rebuild_rss_luts(),
+	 * pairs with adapter devl taken in ice_prepare_rss_luts_for_reset()
+	 */
+	if (ice_is_reset_in_progress(pf->state)) {
+		NL_SET_ERR_MSG_MOD(extack,
+				   "reset in progress, try again later");
+		return -EBUSY;
+	}
+
+	/* pairs with set_bit() under adapter devl in ice_setup_tc_mqprio_qdisc() */
+	if (test_bit(ICE_FLAG_TC_MQPRIO, pf->flags)) {
+		NL_SET_ERR_MSG_MOD(extack, "ADQ configured, can't change RSS LUTs");
+		return -EOPNOTSUPP;
+	}
+
+	if (new_type != ICE_LUT_VSI) {
+		slot = ICE_ANY_SLOT;
+		if (new_type == ICE_LUT_PF)
+			slot = ice_devl_pf_id(pf);
+		err = ice_devl_res_take(pf, ice_rss_lut_res_id(new_type), slot,
+					owner);
+		if (err < 0) {
+			if (new_type == ICE_LUT_PF)
+				NL_SET_ERR_MSG_MOD(extack,
+						   "PF LUT is used by another function");
+			else
+				NL_SET_ERR_MSG_MOD(extack,
+						   "failed to get a global RSS LUT");
+			return err;
+		}
+	}
+
+	err = ice_change_rss_lut(pf, owner, new_type, extack);
+	if (err) {
+		NL_SET_ERR_MSG_WEAK_MOD(extack, "failed to change RSS LUT");
+		if (new_type != ICE_LUT_VSI)
+			ice_devl_res_free(pf, ice_rss_lut_res_id(new_type),
+					  owner);
+		return err;
+	}
+
+	if (old_type != ICE_LUT_VSI)
+		ice_devl_res_free(pf, ice_rss_lut_res_id(old_type), owner);
+
+	return 0;
+}
+
+/* ethtool core sizes RSS buffers by rss_table_size under rtnl, and the new
+ * LUT is filled based on NETIF_F_RXHASH, which is also changed under rtnl
+ */
+static int ice_rss_lut_pf_size_set(u64 size, struct netlink_ext_ack *extack,
+				   void *priv)
+{
+	struct ice_pf *pf = priv;
+	int err;
+
+	rtnl_lock();
+	scoped_guard(ice_adapter_devl, pf->adapter)
+		err = ice_rss_lut_set(pf, pf, size, extack);
+	rtnl_unlock();
+
+	return err;
+}
+
+/**
+ * ice_rss_lut_is_reassigned - check if RSS LUTs of PF are in non-default state
+ * @pf: the PF to check
+ *
+ * Return: true if @pf lost its PF LUT, or @pf or any of its VFs owns a
+ * global LUT. Caller must hold the adapter devlink lock.
+ */
+bool ice_rss_lut_is_reassigned(struct ice_pf *pf)
+{
+	int pf_id = ice_devl_pf_id(pf);
+	struct ice_devl_resource *res;
+
+	devl_assert_locked(pf->adapter->devlink);
+	if (pf->adapter->pf_luts.owner[pf_id] != pf)
+		return true;
+
+	res = ice_devl_res_tbl(pf, ICE_RSS_LUT_GLOBAL);
+	for (int i = 0; i < ARRAY_SIZE(res->owner); i++)
+		if (res->owner[i] && res->pf_id[i] == pf_id)
+			return true;
+
+	return false;
+}
+
+/**
+ * ice_take_rss_lut_pf - allocate PF RSS LUT for PF
+ * @pf: the PF device that PF LUT is physically on, and to allocate it for
+ *
+ * Acquire PF RSS LUT for the caller.
+ *
+ * Return: 0 on success, negative on error.
+ */
+int ice_take_rss_lut_pf(struct ice_pf *pf)
+{
+	int ret, pf_id = ice_devl_pf_id(pf);
+
+	scoped_guard(ice_adapter_devl, pf->adapter) {
+		ret = ice_devl_res_take(pf, ICE_RSS_LUT_PF, pf_id, pf);
+		if (ret >= 0)
+			return 0;
+
+		return ret;
+	}
+}
+
+/**
+ * ice_release_rss_lut_pf - release PF RSS LUT of PF
+ * @pf: the PF device that PF LUT is physically on, and to release it from
+ *
+ * Release PF RSS LUT for the caller.
+ *
+ * No need to call this function in normal operation, provided for error path.
+ */
+void ice_release_rss_lut_pf(struct ice_pf *pf)
+{
+	scoped_guard(ice_adapter_devl, pf->adapter)
+		ice_devl_res_free(pf, ICE_RSS_LUT_PF, pf);
+}
+
+/**
+ * ice_prepare_rss_luts_for_reset - drop global RSS LUTs of PF from the table
+ * @pf: the PF that is about to be reset
+ *
+ * FW frees global RSS LUTs of the PF and its VFs on reset, and other PFs may
+ * get them from FW before ice_rebuild_rss_luts() of @pf, so drop them from
+ * the table now. Taking the lock also waits for RSS LUT changes that checked
+ * for reset just before it was requested.
+ */
+void ice_prepare_rss_luts_for_reset(struct ice_pf *pf)
+{
+	int pf_id = ice_devl_pf_id(pf);
+	struct ice_devl_resource *res;
+
+	scoped_guard(ice_adapter_devl, pf->adapter) {
+		if (ice_rss_lut_is_reassigned(pf))
+			dev_info(ice_pf_to_dev(pf),
+				 "reset restores the default RSS LUT assignment\n");
+
+		res = ice_devl_res_tbl(pf, ICE_RSS_LUT_GLOBAL);
+		for (int i = 0; i < ARRAY_SIZE(res->owner); i++)
+			if (res->pf_id[i] == pf_id)
+				res->owner[i] = NULL;
+	}
+}
+
+/**
+ * ice_rebuild_rss_lut_pf - restore default RSS LUT assignment after reset
+ * @pf: the PF that was reset
+ *
+ * FW drops RSS LUT assignments of the PF on reset, so give the PF LUT back to
+ * the PF, and make the PF VSI use it.
+ * Must be called before the VSIs are rebuilt.
+ *
+ * Return: 0 on success, negative on error.
+ */
+static int ice_rebuild_rss_lut_pf(struct ice_pf *pf)
+{
+	struct ice_vsi *vsi = ice_get_main_vsi(pf);
+	struct ice_adapter *adapter = pf->adapter;
+	u8 *user_lut = NULL;
+	int err;
+
+	devl_lock(adapter->devlink);
+	ice_free_rss_lut_flr_locked(pf);
+	err = ice_devl_res_take(pf, ICE_RSS_LUT_PF, ice_devl_pf_id(pf), pf);
+	if (err < 0)
+		goto unlock;
+
+	mutex_lock(&pf->rss_lut_lock);
+	if (vsi && vsi->rss_lut_type != ICE_LUT_PF) {
+		/* growing fails only on ENOMEM, losing the user RSS LUT */
+		ice_rss_lut_user_resize(vsi, ICE_LUT_PF, &user_lut, NULL);
+		devm_kfree(ice_pf_to_dev(pf), vsi->rss_lut_user);
+		vsi->rss_lut_user = user_lut;
+		vsi->rss_table_size = ice_lut_type_to_size(ICE_LUT_PF);
+		vsi->rss_lut_type = ICE_LUT_PF;
+	}
+	mutex_unlock(&pf->rss_lut_lock);
+	err = 0;
+unlock:
+	devl_unlock(adapter->devlink);
+
+	return err;
+}
+
+/**
+ * ice_rebuild_rss_luts - restore default RSS LUT assignment after reset
+ * @pf: the PF that was reset
+ *
+ * Wrapper of ice_rebuild_rss_lut_pf() that also tells the ethtool core when
+ * the user RSS LUT was dropped. Must be called without rtnl held.
+ *
+ * Return: 0 on success, negative on error.
+ */
+int ice_rebuild_rss_luts(struct ice_pf *pf)
+{
+	struct ice_vsi *vsi = ice_get_main_vsi(pf);
+	int err;
+
+	/* ethtool core sizes RSS buffers by rss_table_size under rtnl */
+	rtnl_lock();
+	err = ice_rebuild_rss_lut_pf(pf);
+	if (vsi && vsi->netdev && !vsi->rss_lut_user &&
+	    netif_is_rxfh_configured(vsi->netdev))
+		ethtool_rxfh_indir_lost(vsi->netdev);
+	rtnl_unlock();
+
+	return err;
+}
+
+static void ice_devl_hw_res_register(struct devlink *devlink, const char *name,
+				     enum ice_devl_resource_id res_id, u64 cnt,
+				     devlink_resource_occ_get_t *occ_get,
+				     struct ice_adapter *adapter)
+{
+	struct devlink_resource_size_params size_params;
+	int err;
+
+	devlink_resource_size_params_init(&size_params, cnt, cnt, 1,
+					  DEVLINK_RESOURCE_UNIT_ENTRY);
+	err = devl_resource_register(devlink, name, cnt, res_id,
+				     ICE_TOP_RESOURCE, &size_params);
+	if (WARN_ONCE(err, "failed to register devlink resource %s: %d\n",
+		      name, err))
+		return;
+
+	devl_resource_occ_get_register(devlink, res_id, occ_get, adapter);
+}
+
+static void ice_devl_rss_lut_register(struct devlink *devlink, u64 size_min,
+				      devlink_resource_size_get_t *size_get,
+				      devlink_resource_size_set_t *size_set,
+				      void *priv)
+{
+	struct devlink_resource_size_params size_params;
+	int err;
+
+	devlink_resource_size_params_init(&size_params, size_min,
+					  ICE_LUT_PF_SIZE, size_min,
+					  DEVLINK_RESOURCE_UNIT_ENTRY);
+	err = devl_resource_register(devlink, "rss_lut", size_get(priv),
+				     ICE_RSS_LUT, ICE_TOP_RESOURCE,
+				     &size_params);
+	if (WARN_ONCE(err, "failed to register devlink resource rss_lut: %d\n",
+		      err))
+		return;
+
+	devl_resource_runtime_register(devlink, ICE_RSS_LUT, size_get, size_set,
+				       priv);
+}
+
+void ice_devl_whole_dev_resources_register(const struct ice_hw *hw,
+					   struct ice_adapter *adapter)
+{
+	struct devlink *devlink = adapter->devlink;
+	int global_lut_cnt = ICE_NUM_GLOBAL_LUTS;
+	int pf_lut_cnt = hw->dev_caps.num_funcs;
+
+	devl_assert_locked(devlink);
+	/* see ice_devl_pf_id() and ice_devl_res_tbl() */
+	if (ice_is_dual(hw)) {
+		global_lut_cnt = 2 * ICE_NUM_GLOBAL_LUTS;
+		pf_lut_cnt = 2 * ICE_PORTS_PER_QUAD;
+	}
+
+	ice_devl_hw_res_register(devlink, "rss_lut_512", ICE_RSS_LUT_GLOBAL,
+				 global_lut_cnt,
+				 ice_rss_lut_whole_dev_occ_get_global, adapter);
+	ice_devl_hw_res_register(devlink, "rss_lut_2048", ICE_RSS_LUT_PF,
+				 pf_lut_cnt, ice_rss_lut_whole_dev_occ_get_pf,
+				 adapter);
+}
+
+void ice_devl_pf_resources_register(struct ice_pf *pf)
+{
+	struct devlink *devlink = priv_to_devlink(pf);
+
+	devl_assert_locked(devlink);
+	/* PF can't use a VSI LUT */
+	ice_devl_rss_lut_register(devlink, ICE_LUT_GLOBAL_SIZE,
+				  ice_rss_lut_pf_size_get,
+				  ice_rss_lut_pf_size_set, pf);
+}
diff --git a/drivers/net/ethernet/intel/ice/ice_adapter.c b/drivers/net/ethernet/intel/ice/ice_adapter.c
index 8cb61f145d27..1d12af48f065 100644
--- a/drivers/net/ethernet/intel/ice/ice_adapter.c
+++ b/drivers/net/ethernet/intel/ice/ice_adapter.c
@@ -9,6 +9,8 @@
 #include "ice_adapter.h"
 #include "ice.h"
 
+#include "devlink/resource.h"
+
 #define ICE_ADAPTER_FIXED_INDEX	BIT_ULL(63)
 
 #define ICE_ADAPTER_INDEX_E825C	\
@@ -38,8 +40,10 @@ static u64 ice_adapter_index(struct pci_dev *pdev)
 
 static int ice_adapter_init(void *priv, void *init_param)
 {
+	const struct ice_hw *hw = init_param;
 	struct ice_adapter *adapter = priv;
 	struct devlink *devlink;
+	int err;
 
 	devlink = shd_priv_to_devlink(adapter);
 	adapter->devlink = devlink;
@@ -53,12 +57,22 @@ static int ice_adapter_init(void *priv, void *init_param)
 	spin_lock_init(&adapter->ports.lock);
 	INIT_LIST_HEAD(&adapter->ports.list);
 
-	return init_srcu_struct(&adapter->ports.srcu);
+	err = init_srcu_struct(&adapter->ports.srcu);
+	if (err)
+		return err;
+
+	ice_devl_whole_dev_resources_register(hw, adapter);
+
+	return 0;
 }
 
 static void ice_adapter_fini(void *priv)
 {
 	struct ice_adapter *adapter = priv;
+	struct devlink *devlink;
+
+	devlink = shd_priv_to_devlink(adapter);
+	devl_resources_unregister(devlink);
 
 	WARN_ON(!list_empty(&adapter->ports.list));
 	for (int i = 0; i < ARRAY_SIZE(adapter->cpi_phy_lock); i++)
@@ -88,15 +102,16 @@ static const struct devlink_ops ice_adapter_devlink_ops = {
  */
 struct ice_adapter *ice_adapter_get(struct pci_dev *pdev)
 {
+	struct ice_pf *pf = pci_get_drvdata(pdev);
 	struct ice_adapter *adapter;
 	struct devlink *devlink;
 	char devlink_id[32];
 	u64 index;
 
 	index = ice_adapter_index(pdev);
 	snprintf(devlink_id, sizeof(devlink_id), "ice:%llx", index);
 	devlink = devlink_shd_get(devlink_id, &ice_adapter_devlink_ops,
-				  sizeof(*adapter), NULL, pdev->dev.driver);
+				  sizeof(*adapter), &pf->hw, pdev->dev.driver);
 	if (IS_ERR(devlink))
 		return ERR_CAST(devlink);
 
diff --git a/drivers/net/ethernet/intel/ice/ice_common.c b/drivers/net/ethernet/intel/ice/ice_common.c
index 90e01eb49ea2..48c3449a2434 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.c
+++ b/drivers/net/ethernet/intel/ice/ice_common.c
@@ -3184,6 +3184,7 @@ void ice_set_safe_mode_caps(struct ice_hw *hw)
 	struct ice_hw_func_caps *func_caps = &hw->func_caps;
 	struct ice_hw_dev_caps *dev_caps = &hw->dev_caps;
 	struct ice_hw_common_caps cached_caps;
+	struct ice_nac_topology nac_topo;
 	u32 num_funcs;
 
 	/* cache some func_caps values that should be restored after memset */
@@ -3217,6 +3218,7 @@ void ice_set_safe_mode_caps(struct ice_hw *hw)
 	/* cache some dev_caps values that should be restored after memset */
 	cached_caps = dev_caps->common_cap;
 	num_funcs = dev_caps->num_funcs;
+	nac_topo = dev_caps->nac_topo;
 
 	/* unset dev capabilities */
 	memset(dev_caps, 0, sizeof(*dev_caps));
@@ -3235,6 +3237,7 @@ void ice_set_safe_mode_caps(struct ice_hw *hw)
 	ICE_RESTORE_DEV_CAP(nvm_update_pending_orom);
 	ICE_RESTORE_DEV_CAP(nvm_update_pending_netlist);
 	dev_caps->num_funcs = num_funcs;
+	dev_caps->nac_topo = nac_topo;
 
 	/* one Tx and one Rx queue per function in safe mode */
 	dev_caps->common_cap.num_rxq = num_funcs;
@@ -4450,7 +4453,7 @@ ice_aq_sff_eeprom(struct ice_hw *hw, u16 lport, u8 bus_addr,
 	return status;
 }
 
-static enum ice_lut_size ice_lut_type_to_size(enum ice_lut_type type)
+enum ice_lut_size ice_lut_type_to_size(enum ice_lut_type type)
 {
 	switch (type) {
 	case ICE_LUT_VSI:
diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
index 57425683c0d4..a65dd342246c 100644
--- a/drivers/net/ethernet/intel/ice/ice_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_lib.c
@@ -10,6 +10,8 @@
 #include "ice_type.h"
 #include "ice_vsi_vlan_ops.h"
 
+#include "devlink/resource.h"
+
 #define ICE_LUT_VSI_MAX_QS	16
 #define ICE_LUT_GLOBAL_MAX_QS	64
 #define ICE_LUT_PF_MAX_QS	256
@@ -1341,6 +1343,34 @@ static void ice_set_rss_vsi_ctx(struct ice_vsi_ctx *ctxt, struct ice_vsi *vsi)
 		FIELD_PREP(ICE_AQ_VSI_Q_OPT_RSS_HASH_M, hash_type);
 }
 
+int ice_vsi_update_rss_lut(struct ice_vsi *vsi, enum ice_lut_type lut_type,
+			   u8 global_lut_id)
+{
+	struct ice_vsi_ctx *ctx;
+	int err;
+
+	lockdep_assert_held(&vsi->back->rss_lut_lock);
+
+	ctx = kzalloc_obj(*ctx);
+	if (!ctx)
+		return -ENOMEM;
+
+	ctx->info.valid_sections = cpu_to_le16(ICE_AQ_VSI_PROP_Q_OPT_VALID);
+	ctx->info.q_opt_rss = vsi->info.q_opt_rss &
+		~(ICE_AQ_VSI_Q_OPT_RSS_LUT_M | ICE_AQ_VSI_Q_OPT_RSS_GBL_LUT_M);
+	ctx->info.q_opt_rss |= FIELD_PREP(ICE_AQ_VSI_Q_OPT_RSS_LUT_M,
+				ice_lut_type_to_aq_qopt_rss_val(lut_type)) |
+		FIELD_PREP(ICE_AQ_VSI_Q_OPT_RSS_GBL_LUT_M, global_lut_id);
+	ctx->info.q_opt_tc = vsi->info.q_opt_tc;
+	ctx->info.q_opt_flags = vsi->info.q_opt_flags;
+
+	err = ice_update_vsi(&vsi->back->hw, vsi->idx, ctx, NULL);
+	if (!err)
+		vsi->info.q_opt_rss = ctx->info.q_opt_rss;
+	kfree(ctx);
+	return err;
+}
+
 static void
 ice_chnl_vsi_setup_q_map(struct ice_vsi *vsi, struct ice_vsi_ctx *ctxt)
 {
@@ -2471,8 +2501,15 @@ static int ice_vsi_cfg_def(struct ice_vsi *vsi)
 	vsi->vsw = pf->first_sw;
 
 	if (vsi->flags & ICE_VSI_FLAG_INIT) {
-		scoped_guard(mutex, &pf->rss_lut_lock)
+		scoped_guard(mutex, &pf->rss_lut_lock) {
+			u16 lut_size = vsi->rss_table_size;
+
 			ice_vsi_set_dflt_rss_lut_type(vsi);
+			if (vsi->rss_table_size != lut_size) {
+				devm_kfree(dev, vsi->rss_lut_user);
+				vsi->rss_lut_user = NULL;
+			}
+		}
 	}
 
 	ret = ice_vsi_alloc_def(vsi, vsi->ch);
@@ -2495,15 +2532,23 @@ static int ice_vsi_cfg_def(struct ice_vsi *vsi)
 
 	/* set RSS capabilities */
 	ice_vsi_set_rss_params(vsi);
+	if ((vsi->flags & ICE_VSI_FLAG_INIT) && vsi->type == ICE_VSI_PF) {
+		ret = ice_take_rss_lut_pf(pf);
+		if (ret) {
+			dev_err(dev, "Failed to allocate RSS LUT for PF: %d\n",
+				ret);
+			goto unroll_get_qs;
+		}
+	}
 
 	/* set TC configuration */
 	ice_vsi_set_tc_cfg(vsi);
 
 	/* create the VSI */
 	scoped_guard(mutex, &pf->rss_lut_lock)
 		ret = ice_vsi_init(vsi, vsi->flags);
 	if (ret)
-		goto unroll_get_qs;
+		goto unroll_pf_rss_lut;
 
 	ice_vsi_init_vlan_ops(vsi);
 
@@ -2615,6 +2660,9 @@ static int ice_vsi_cfg_def(struct ice_vsi *vsi)
 	ice_vsi_free_q_vectors(vsi);
 unroll_vsi_init:
 	ice_vsi_delete_from_hw(vsi);
+unroll_pf_rss_lut:
+	if ((vsi->flags & ICE_VSI_FLAG_INIT) && vsi->type == ICE_VSI_PF)
+		ice_release_rss_lut_pf(pf);
 unroll_get_qs:
 	ice_vsi_put_qs(vsi);
 unroll_vsi_alloc_stat:
@@ -2692,6 +2740,11 @@ void ice_vsi_decfg(struct ice_vsi *vsi)
 	if (vsi->type == ICE_VSI_VF &&
 	    vsi->agg_node && vsi->agg_node->valid)
 		vsi->agg_node->num_vsis--;
+
+	if (vsi->flags & ICE_VSI_FLAG_INIT) {
+		if (vsi->type == ICE_VSI_PF)
+			ice_free_rss_lut_flr(pf);
+	}
 }
 
 /**
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 3e8cf1c5f0e8..5f0de7cf0a8e 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -15,6 +15,7 @@
 #include "ice_dcb_nl.h"
 #include "devlink/devlink.h"
 #include "devlink/port.h"
+#include "devlink/resource.h"
 #include "ice_sf_eth.h"
 #include "ice_hwmon.h"
 /* Including ice_trace.h with CREATE_TRACE_POINTS defined will generate the
@@ -546,6 +547,8 @@ ice_prepare_for_reset(struct ice_pf *pf, enum ice_reset_req reset_type)
 	if (test_bit(ICE_PREPARED_FOR_RESET, pf->state))
 		return;
 
+	ice_prepare_rss_luts_for_reset(pf);
+
 	synchronize_irq(pf->oicr_irq.virq);
 
 	ice_unplug_aux_dev(pf);
@@ -3873,6 +3876,8 @@ void ice_deinit_pf(struct ice_pf *pf)
 {
 	/* note that we unroll also on ice_init_pf() failure here */
 
+	/* ice_vsi_decfg() skips it if the last VSI rebuild was NO_INIT */
+	ice_free_rss_lut_flr(pf);
 	mutex_destroy(&pf->rss_lut_lock);
 	mutex_destroy(&pf->lag_mutex);
 	mutex_destroy(&pf->adev_mutex);
@@ -4964,6 +4969,7 @@ static void ice_deinit_devlink(struct ice_pf *pf)
 	ice_devlink_unregister(pf);
 	ice_devlink_destroy_regions(pf);
 	ice_devlink_unregister_params(pf);
+	devl_resources_unregister(priv_to_devlink(pf));
 }
 
 static int ice_init(struct ice_pf *pf)
@@ -5285,6 +5291,7 @@ ice_probe(struct pci_dev *pdev, const struct pci_device_id __always_unused *ent)
 	err = ice_init_devlink(pf);
 	if (err)
 		goto unroll_load;
+	ice_devl_pf_resources_register(pf);
 	devl_unlock(priv_to_devlink(pf));
 
 	return 0;
@@ -7770,6 +7777,12 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)
 	if (ice_is_feature_supported(pf, ICE_F_GNSS))
 		ice_gnss_init(pf);
 
+	err = ice_rebuild_rss_luts(pf);
+	if (err) {
+		dev_err(dev, "RSS LUT rebuild failed: %d\n", err);
+		goto err_vsi_rebuild;
+	}
+
 	/* rebuild PF VSI */
 	err = ice_vsi_rebuild_by_type(pf, ICE_VSI_PF);
 	if (err) {
@@ -7927,6 +7940,8 @@ int ice_set_rss_lut(struct ice_vsi *vsi, u8 *lut, u16 lut_size)
 	params.lut_size = lut_size;
 	params.lut_type = vsi->rss_lut_type;
 	params.lut = lut;
+	if (params.lut_type == ICE_LUT_GLOBAL)
+		params.global_lut_id = vsi->global_lut_id;
 
 	status = ice_aq_set_rss_lut(hw, &params);
 	if (status)
@@ -7980,6 +7995,8 @@ int ice_get_rss_lut(struct ice_vsi *vsi, u8 *lut, u16 lut_size)
 	params.lut_size = lut_size;
 	params.lut_type = vsi->rss_lut_type;
 	params.lut = lut;
+	if (params.lut_type == ICE_LUT_GLOBAL)
+		params.global_lut_id = vsi->global_lut_id;
 
 	status = ice_aq_get_rss_lut(hw, &params);
 	if (status)
@@ -9194,8 +9211,14 @@ static int ice_setup_tc_mqprio_qdisc(struct net_device *netdev, void *type_data)
 				   ret);
 			return ret;
 		}
+		scoped_guard(ice_adapter_devl, pf->adapter) {
+			if (ice_rss_lut_is_reassigned(pf)) {
+				dev_err(dev, "RSS LUTs reassigned via devlink, can't configure ADQ\n");
+				return -EOPNOTSUPP;
+			}
+			set_bit(ICE_FLAG_TC_MQPRIO, pf->flags);
+		}
 		memcpy(&vsi->mqprio_qopt, mqprio_qopt, sizeof(*mqprio_qopt));
-		set_bit(ICE_FLAG_TC_MQPRIO, pf->flags);
 		/* don't assume state of hw_tc_offload during driver load
 		 * and set the flag for TC flower filter if hw_tc_offload
 		 * already ON
@@ -9263,6 +9286,7 @@ static int ice_setup_tc_mqprio_qdisc(struct net_device *netdev, void *type_data)
 		clear_bit(ICE_RESET_FAILED, pf->state);
 		if (ice_vsi_rebuild(vsi, ICE_VSI_FLAG_NO_INIT)) {
 			dev_err(dev, "Rebuild of main VSI failed again\n");
+			clear_bit(ICE_FLAG_TC_MQPRIO, pf->flags);
 			return ret;
 		}
 	}
@@ -9315,6 +9339,7 @@ static int ice_setup_tc_mqprio_qdisc(struct net_device *netdev, void *type_data)
 	if (ret) {
 		vsi->all_numtc = 0;
 		vsi->all_enatc = 0;
+		clear_bit(ICE_FLAG_TC_MQPRIO, pf->flags);
 	}
 	/* resume VSI */
 	ice_ena_vsi(vsi, true);
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH net-next v7 14/15] devlink: add devlink_alloc_drv()
  2026-11-21 22:55 [PATCH net-next v7 00/15] devlink, mlx5, iavf, ice: XLVF for iavf Przemek Kitszel
                   ` (12 preceding siblings ...)
  2026-11-21 22:55 ` [PATCH net-next v7 13/15] ice: represent RSS LUTs as devlink resources Przemek Kitszel
@ 2026-11-21 22:55 ` Przemek Kitszel
  2026-11-21 22:55 ` [PATCH net-next v7 15/15] ice: support up to 256 VF queues Przemek Kitszel
  2026-11-23  8:53 ` [PATCH net-next v7 00/15] devlink, mlx5, iavf, ice: XLVF for iavf Matthieu Baerts
  15 siblings, 0 replies; 28+ messages in thread
From: Przemek Kitszel @ 2026-11-21 22:55 UTC (permalink / raw)
  To: netdev, Jakub Kicinski, Jiri Pirko
  Cc: Tony Nguyen, Aleksandr Loktionov, Michal Schmidt, edumazet, horms,
	pabeni, davem, Jonathan Corbet, skhan, rdunlap, andrew+netdev,
	saeedm, tariqt, leon, mbloch, jacob.e.keller, jedrzej.jagielski,
	anzaki, brett.creeley, ohartoov, Petr Oros, Donald Hunter,
	Przemek Kitszel, Jiri Pirko

devlink_alloc() records the driver bound to @dev at the time of the
call as the owner of the new instance. That fits the common case of
a driver creating an instance for the device it is bound to, but not
a PF driver that creates instances for its VFs, as the VF device could
be:
 * not bound to any driver yet (VF driver not loaded, or
   sriov_drivers_autoprobe disabled), what triggers the WARN_ON() in
   __devlink_alloc();
 * bound to another driver (VF driver, or vfio-pci), which could be
   unloaded while the instance is still registered, leaving the stored
   driver pointer dangling (it is used to report the driver name in
   devlink dev info).

Add devlink_alloc_drv(), a variant of devlink_alloc() that takes the
owning driver explicitly, as devlink_shd_get() already does.

The first user is ice, in the next patch, which creates a devlink
instance for each of its VFs.

Such an instance reports the owning driver in devlink dev info, not the
one bound to the device in sysfs. Document that in devlink-info.rst.

Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
---
v5:
 * document @drv lifetime and device lock rules in kernel-doc (me)

v4:
 * document in devlink-info.rst that an instance created for another
   device reports the name of the creating driver (Sashiko)

v3:
 * new patch
---
 .../networking/devlink/devlink-info.rst       |  2 ++
 include/net/devlink.h                         |  4 ++++
 net/devlink/core.c                            | 24 +++++++++++++++++++
 3 files changed, 30 insertions(+)

diff --git a/Documentation/networking/devlink/devlink-info.rst b/Documentation/networking/devlink/devlink-info.rst
index dd6adc4d0559..7ac5625e2934 100644
--- a/Documentation/networking/devlink/devlink-info.rst
+++ b/Documentation/networking/devlink/devlink-info.rst
@@ -25,6 +25,8 @@ versions is generally discouraged - here, and via any other Linux API.
      - Description
    * - ``driver``
      - Name of the currently used device driver, also available through sysfs.
+       For an instance that a driver creates for another device, e.g. a PF
+       driver for its VFs, the name of the creating driver.
 
    * - ``serial_number``
      - Serial number of the device.
diff --git a/include/net/devlink.h b/include/net/devlink.h
index dc9a642796f2..eb38f35a0ee6 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -1695,6 +1695,10 @@ static inline struct devlink *devlink_alloc(const struct devlink_ops *ops,
 	return devlink_alloc_ns(ops, priv_size, &init_net, dev);
 }
 
+struct devlink *devlink_alloc_drv(const struct devlink_ops *ops,
+				  size_t priv_size, struct device *dev,
+				  const struct device_driver *drv);
+
 int devl_register(struct devlink *devlink);
 void devl_unregister(struct devlink *devlink);
 void devlink_register(struct devlink *devlink);
diff --git a/net/devlink/core.c b/net/devlink/core.c
index 9b844e0c1bd2..e2a7169287ec 100644
--- a/net/devlink/core.c
+++ b/net/devlink/core.c
@@ -531,6 +531,30 @@ struct devlink *devlink_alloc_ns(const struct devlink_ops *ops,
 }
 EXPORT_SYMBOL_GPL(devlink_alloc_ns);
 
+/**
+ * devlink_alloc_drv - Allocate new devlink instance resources for given driver
+ * @ops: ops
+ * @priv_size: size of user private data
+ * @dev: parent device
+ * @drv: driver that owns the instance
+ *
+ * Variant of devlink_alloc() for a driver that creates an instance for
+ * a device bound to another (or no) driver, e.g. a PF driver for its VFs.
+ *
+ * @drv must not be NULL and must outlive the instance, only a pointer to it
+ * is kept. Operations that take the device lock, like reload, lock @dev,
+ * not a device bound to @drv.
+ *
+ * Return: new devlink instance, NULL on failure.
+ */
+struct devlink *devlink_alloc_drv(const struct devlink_ops *ops,
+				  size_t priv_size, struct device *dev,
+				  const struct device_driver *drv)
+{
+	return __devlink_alloc(ops, priv_size, &init_net, dev, drv);
+}
+EXPORT_SYMBOL_GPL(devlink_alloc_drv);
+
 /**
  *	devlink_free - Free devlink instance resources
  *
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH net-next v7 15/15] ice: support up to 256 VF queues
  2026-11-21 22:55 [PATCH net-next v7 00/15] devlink, mlx5, iavf, ice: XLVF for iavf Przemek Kitszel
                   ` (13 preceding siblings ...)
  2026-11-21 22:55 ` [PATCH net-next v7 14/15] devlink: add devlink_alloc_drv() Przemek Kitszel
@ 2026-11-21 22:55 ` Przemek Kitszel
  2026-11-24 21:57   ` netdev-bot+sashiko
  2026-11-23  8:53 ` [PATCH net-next v7 00/15] devlink, mlx5, iavf, ice: XLVF for iavf Matthieu Baerts
  15 siblings, 1 reply; 28+ messages in thread
From: Przemek Kitszel @ 2026-11-21 22:55 UTC (permalink / raw)
  To: netdev, Jakub Kicinski, Jiri Pirko
  Cc: Tony Nguyen, Aleksandr Loktionov, Michal Schmidt, edumazet, horms,
	pabeni, davem, Jonathan Corbet, skhan, rdunlap, andrew+netdev,
	saeedm, tariqt, leon, mbloch, jacob.e.keller, jedrzej.jagielski,
	anzaki, brett.creeley, ohartoov, Petr Oros, Donald Hunter,
	Przemek Kitszel

Add support for up to 256 VF queues. To enable more than usual 16, user
needs to give the VF a bigger RSS LUT, via devlink resource "rss_lut" of
the VF: size 512 (one of GLOBAL LUTs) for 64 queues, or size 2048 (the PF
LUT of its PF) for maximum of 256 queues. The PF LUT is initially used by
the PF, so the PF has to switch to a GLOBAL LUT first, see examples further
below. iavf asks for one queue pair per CPU when it initializes on a VF
with a bigger RSS LUT. A VF that is already up keeps its queue count,
until more queues are requested by usual ethtool -L command.

Hook up the VIRTCHNL_OP_ENABLE_QUEUES_V2, VIRTCHNL_OP_DISABLE_QUEUES_V2
and VIRTCHNL_OP_MAP_QUEUE_VECTOR handlers, with the get_q_vector
callback of SR-IOV VFs, add the VIRTCHNL_OP_GET_MAX_RSS_QREGION handler,
and grant VIRTCHNL_VF_LARGE_NUM_QPAIRS to VFs with a GLOBAL or PF LUT.

Add devlink instance of VF device to track RSS LUT resources under
a respective PF devlink instance.

Number of MSI-X vectors assigned to VF is orthogonal to this.

Note that VF reset is deferred to service task. A message from the VF
while that reset is pending does the reset instead, without a reply, so
the VF never sees a half-applied change.

Raise the VIRTCHNL_OP_REQUEST_QUEUES limit of 16 queues to what the RSS
LUT of the VF can address. A VF request for more queues is granted only
when the VF fits in one free range of PF queues (its own queues count as
free), as scattered queue mapping is not implemented for VFs. A write
to sriov_vf_msix_count fails with -ENOSPC when the VF would not fit. A
VF without VIRTCHNL_VF_LARGE_NUM_QPAIRS can still request at most 16
queues, and its RSS LUT of 64 entries is repeated to fill the bigger LUT
of its VSI.

Mark VFs disabled when preparing for a PF reset, until
ice_reset_all_vfs() rebuilds them, so devlink does not change the RSS
LUT of a VF in between. If the VSI rebuild of a VF fails, clear that
mark anyway, so a VFLR can still reset the VF.

How to use:
1. Up to 64 queues
   a. give the VF one of 16 GLOBAL LUTs:
      sudo devlink resource set pci/0000:18:01.0 path rss_lut size 512
   b. if more queues are wanted:
      sudo ethtool -L $vfiface combined $more

2. Up to 256 queues
   a. switch the PF to a GLOBAL LUT, that frees its PF LUT:
      sudo devlink resource set pci/0000:18:00.0 path rss_lut size 512
   b. give the PF LUT to the VF:
      sudo devlink resource set pci/0000:18:01.0 path rss_lut size 2048
   c. if more queues are wanted:
      sudo ethtool -L $vfiface combined $more

3. display current RSS LUT or RSS table:
   a. see if RSS is mapped correctly (e.g. for size 512 there are 512
      entries expected):
      ethtool -x $vfiface
   b. see what devlink devices are present:
      devlink dev show # note the "whole dev aggregate" device over your pci netdevs
   c. see PF, VF, and "whole device aggregate" resources:
      devlink resource show pci/0000:18:00.0 # PF
      devlink resource show pci/0000:18:01.0 # VF
      devlink resource show devlink_index/3 # whole dev

output will look like below, for a VF with a GLOBAL LUT:
pci/0000:18:01.0:
  name rss_lut size 512 unit entry size_min 64 size_max 2048 size_gran 64 dpipe_tables none

Big thanks to Mateusz for working together on the whole story for long
time! Big thanks to Alex Loktionov for pointing the reason of one nasty
bug with the message size!

Co-developed-by: Mateusz Polchlopek <mateusz.polchlopek@intel.com>
Signed-off-by: Mateusz Polchlopek <mateusz.polchlopek@intel.com>
Signed-off-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Reviewed-by: Jedrzej Jagielski <jedrzej.jagielski@intel.com>
Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
---
v7:
 * one runtime "rss_lut" resource per VF, like for the PF, the size of
   its RSS LUT in entries (Jakub); a VF switches between LUTs in one
   step, and goes back to its VSI LUT with size 64
 * move capping the RSS queue count by the RSS LUT type to a new patch,
   "ice: prepare RSS LUT config for runtime LUT changes" (Jakub)
 * move the PF rss_size limit on a LUT change, with its changelog
   entries, to "ice: represent RSS LUTs as devlink resources", which
   needs it already (me)
 * raise the VIRTCHNL_OP_REQUEST_QUEUES limit here, not in "ice: bump to
   256qs for VF", which lacked the check that the queues fit in one free
   range (me)
 * don't join the ret and len declarations in ice_vc_get_vf_res_msg(),
   this patch doesn't touch them otherwise (me)
 * unregister the VF devlink instances before pci_disable_sriov(), not
   after the VF PCI devices they belong to are gone (me)
 * clear the disabled state of a VF whose VSI rebuild failed on a PF
   reset, it blocked the VFLR that can recover the VF (me)
 * check that the VF queues fit in one free range of PF queues also when
   sriov_vf_msix_count changes their count, and return -ENOSPC before
   anything is torn down (me)
 * commit message: describe the deferred VF reset done by the next VF
   message, the queue range check, the 16 queue limit without
   VIRTCHNL_VF_LARGE_NUM_QPAIRS, and VFs marked disabled on PF reset
   (Sashiko)
 * commit message: a VF that is already up keeps its queue count when it
   gets a bigger RSS LUT, until ethtool -L asks for more; list the LARGE
   VF opcodes hooked up here (me)

v6:
 * document in ice.rst that VF queues must fit in one free range of PF
   queues, so with many VFs only a few get 64 queues, and 256 may not be
   available even with a PF LUT (Petr)

v5:
 * keep reporting the 64 entry RSS LUT to VFs without
   VIRTCHNL_VF_LARGE_NUM_QPAIRS, and repeat their LUT over the bigger
   LUT of the VSI; iavf before this series allocates its LUT buffer
   only once, and overflowed it after a bigger LUT was assigned (Petr)
 * grant REQUEST_QUEUES only when the VF fits in one free range of Tx
   and Rx queues, counting its own queues as free; scattered mapping
   is not implemented for VFs, and requests of 64 or 256 queues
   fragmented the PF queue space, so VFs came up with unprogrammed
   queues (Petr)
 * offer no more queues than that in the reply to a too big request,
   not just the RSS LUT limit (Sashiko)
 * drop the check against ICE_MAX_QS_PER_VF, the RSS LUT limit is never
   bigger (me)
 * mark VFs disabled when preparing for PF reset, until
   ice_reset_all_vfs() rebuilds them; devlink could change the RSS LUT
   of a VF just after the PF rebuild, and the VF VSI rebuild then went
   back to the VSI LUT, with the LUT still taken in the table (Sashiko)
 * register VF devlink resources before devl_register(), and unregister
   them after devl_unregister(), under one devl lock section, so the
   VF devlink instance is never visible without them (Sashiko)
 * drop the second ice_get_vf_vsi() call in ice_vc_config_rss_lut(),
   the VSI is now looked up before the LUT size check (Sashiko)

v4:
 * after a PF reset, lower the queue count only of VFs that lost a bigger
   RSS LUT, and only to 16; ice_vsi_decfg() set every VF back to the
   default count, dropping queues granted by REQUEST_QUEUES or set via
   sriov_vf_msix_count, and took the PF from vsi->back, which is not the
   VF's PF for the SR-IOV LAG placeholder VSIs (Sashiko)
 * cap REQUEST_QUEUES at 16 for VFs without VIRTCHNL_VF_LARGE_NUM_QPAIRS,
   also when they use a bigger RSS LUT (Sashiko)
 * report ICE_VF_VSI_ID as vport_id in GET_MAX_RSS_QREGION reply, not the
   HW VSI number (Sashiko)
 * clear ICE_VF_STATE_NEEDS_RESET on every VF reset, so a VF is not reset
   again for a change that was already applied (Sashiko)
 * don't create VF devlink instance without VF pci_dev, e.g. on s390
   (Sashiko)
 * document the VF devlink instance and its RSS LUT resources in ice.rst
   (Sashiko)
 * do a pending deferred VF reset before handling the next message from
   that VF, instead of answering it from a half-applied RSS LUT change
   (GET_VF_RESOURCES offered 64 queues without LARGE_NUM_QPAIRS)
 * re-run service task at once if a deferred VF reset was scheduled
   during its pass, after ice_handle_deferred_vf_reset(); the wake-up
   from ice_schedule_vf_reset() is a no-op while the task runs, so the
   reset waited for the service timer, up to 1 s (me)
 * report the VF queue allocation in num_queue_pairs also with
   VIRTCHNL_VF_LARGE_NUM_QPAIRS, as in legacy mode and as the
   out-of-tree ice does, instead of the RSS LUT queue limit; VF learns
   the limit from GET_MAX_RSS_QREGION or from a REQUEST_QUEUES denial
   (Sashiko)
 * declare ret and len in one line in ice_vc_get_vf_res_msg()

v3:
 * allocate VF devlink with ice as the owning driver, via new
   devlink_alloc_drv(); VF device could be unbound or bound to iavf at
   that point (me)
 * create VF devlinks only after all VFs are started, not while
   ice_start_vfs() can still fail and release their VSIs (me)
 * check VF VSI for NULL in ice_vc_request_qs_msg() (me)
 * restore default RSS LUT assignment of VFs after PF reset, FW drops it
 * wake up service task when scheduling a deferred VF reset (Sashiko)
 * lower VF queue count to the capacity of its new RSS LUT when the LUT
   shrinks, instead of keeping the queues allocated and offering them
   to iavf without VIRTCHNL_VF_LARGE_NUM_QPAIRS (me)

v2:
 * drop getting VF ref around vf->needs_deferred_reset, it only opened
   a window for resource leak and was not needed anyway (Sashiko)
 * replace needs_deferred_reset bitfield with ICE_VF_STATE_NEEDS_RESET
   bit, consumed by test_and_clear_bit() before the reset, so a request
   coming in during the reset is not lost
 * take vfs.table_lock in service task only when a deferred VF reset
   is pending, so freshly enabled VFs do not time out on
   VIRTCHNL_OP_VERSION
 * add !CONFIG_PCI_IOV stub for ice_schedule_vf_reset()
 * create VF devlink in ice_start_vfs() under vfs.table_lock instead
   of lazily from the virtchnl handler; take PF devlink lock around
   devl_nested_devlink_set(); handle VF without devlink on teardown
 * take cfg_lock before the adapter devlink lock in VF resource setters,
   and reject changes while the VF is not ready (ice_vf_is_ready())
 * switch VF VSI context to the new LUT synchronously, so HW no longer
   uses the old LUT when it is released
 * use logical_pf_id for VF allocation of PF LUT slots
 * report the RSS qregion width from LUT capacity, and reject VF queue
   requests above it
 * drop ICE_VSI_FLAG_RELOAD, it was set but never tested (and
   overwritten on VF reset anyway)
 * use ice_get_vf_vsi() instead of open coding it (Sashiko)
 * commit message: the whole device aggregate is a shared devlink
   instance (devlink_index/N), not a faux device
 * check devl_nested_devlink_set() return value (Sashiko)
---
 Documentation/networking/devlink/ice.rst      | 30 +++++-
 .../net/ethernet/intel/ice/devlink/resource.h |  3 +
 drivers/net/ethernet/intel/ice/ice.h          |  1 +
 drivers/net/ethernet/intel/ice/ice_vf_lib.h   | 23 +++++
 drivers/net/ethernet/intel/ice/virt/queues.h  |  2 +
 drivers/net/ethernet/intel/ice/virt/rss.h     |  1 +
 .../net/ethernet/intel/ice/virt/virtchnl.h    |  4 +
 .../net/ethernet/intel/ice/devlink/resource.c | 94 ++++++++++++++++++-
 drivers/net/ethernet/intel/ice/ice_main.c     | 26 +++++
 drivers/net/ethernet/intel/ice/ice_sriov.c    | 28 ++++++
 drivers/net/ethernet/intel/ice/ice_vf_lib.c   | 73 ++++++++++++++
 drivers/net/ethernet/intel/ice/virt/queues.c  | 82 ++++++++++++----
 drivers/net/ethernet/intel/ice/virt/rss.c     | 54 ++++++++++-
 .../net/ethernet/intel/ice/virt/virtchnl.c    | 36 +++++++
 14 files changed, 428 insertions(+), 29 deletions(-)

diff --git a/Documentation/networking/devlink/ice.rst b/Documentation/networking/devlink/ice.rst
index d410dd6bb29f..1cb4f9182849 100644
--- a/Documentation/networking/devlink/ice.rst
+++ b/Documentation/networking/devlink/ice.rst
@@ -503,8 +503,9 @@ a global LUT, and 256 with a PF LUT.
       - Instance
       - Description
     * - ``rss_lut``
-      - PF
-      - The size of the RSS LUT of the function, 512 or 2048 for a PF.
+      - PF, VF
+      - The size of the RSS LUT of the function, 512 or 2048 for a PF, and
+        64, 512 or 2048 for a VF.
         Only these sizes are accepted, not every multiple of ``size_gran``.
         A new size applies immediately (``runtime`` configuration mode).
     * - ``rss_lut_512``
@@ -517,6 +518,24 @@ a global LUT, and 256 with a PF LUT.
         in use. Read-only.
 
 The whole device devlink instance is shared by all PFs of the device.
+The devlink instance of each VF (``pci/<VF BDF>``) is nested in the devlink
+instance of its PF. A VF can use a global LUT, or the PF LUT of its PF,
+once the PF switched to a global LUT.
+
+A VF uses its VSI LUT by default, which spreads traffic over up to 16
+queues. With a global LUT the VF can use up to 64 queues, and up to 256 with
+a PF LUT. Changing the LUT of a VF resets the VF, and lowers its queue count
+if the new LUT can't spread traffic over all of them. The VF driver picks
+the queue count as usual, more queues are requested with ``ethtool -L``.
+More than 16 queues need a VF driver that supports
+``VIRTCHNL_VF_LARGE_NUM_QPAIRS``, like ``iavf``.
+
+The queues of a VF must be one contiguous range of the PF Tx and Rx queues,
+so a request is granted only when the VF fits in one free range (its own
+queues count as free), and the driver logs how many are free otherwise.
+The queues of other VFs fragment that space, so with many VFs only a few
+of them can get 64 queues, and a VF may not get 256 queues even with a PF
+LUT.
 
 Changing the LUT of a PF keeps the RSS indirection table set with
 ``ethtool -X``, also when a reset gives the PF LUT back to the PF. The table
@@ -528,7 +547,8 @@ RSS LUTs can't be changed while ADQ is configured, and ADQ can't be
 configured while the RSS LUTs of the PF are reassigned.
 
 Firmware drops the LUT assignments on reset (PFR, CORER or GLOBR). The
-driver then restores the default assignment, and logs that it did so.
+driver then restores the default assignment, and logs that it did so. VFs
+that used a bigger LUT get at most 16 queues after that.
 Changes are rejected with ``EBUSY`` while a reset is in progress.
 
 .. code:: shell
@@ -544,3 +564,7 @@ Changes are rejected with ``EBUSY`` while a reset is in progress.
     $ devlink resource show pci/0000:18:00.0
     pci/0000:18:00.0:
       name rss_lut size 512 unit entry size_min 512 size_max 2048 size_gran 512 dpipe_tables none
+
+    # give the freed PF LUT to a VF of that PF, and use 256 queues there
+    $ devlink resource set pci/0000:18:01.0 path rss_lut size 2048
+    $ ethtool -L $VF_NETDEV combined 256
diff --git a/drivers/net/ethernet/intel/ice/devlink/resource.h b/drivers/net/ethernet/intel/ice/devlink/resource.h
index a41bda0ff6c8..4401ce0171e1 100644
--- a/drivers/net/ethernet/intel/ice/devlink/resource.h
+++ b/drivers/net/ethernet/intel/ice/devlink/resource.h
@@ -10,7 +10,9 @@ struct devlink;
 struct ice_adapter;
 struct ice_hw;
 struct ice_pf;
+struct ice_vf;
 
+void ice_devlink_vf_resources_register(struct ice_vf *vf);
 void ice_devl_pf_resources_register(struct ice_pf *pf);
 void ice_devl_whole_dev_resources_register(const struct ice_hw *hw,
 					   struct ice_adapter *adapter);
@@ -21,5 +23,6 @@ void ice_release_rss_lut_pf(struct ice_pf *pf);
 void ice_prepare_rss_luts_for_reset(struct ice_pf *pf);
 int ice_rebuild_rss_luts(struct ice_pf *pf);
 void ice_free_rss_lut_flr(struct ice_pf *pf);
+void ice_free_rss_lut_vf(struct ice_vf *vf);
 
 #endif /* _ICE_DEVL_RESOURCE_H_ */
diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h
index 611f1346b4a7..daa417edc9b7 100644
--- a/drivers/net/ethernet/intel/ice/ice.h
+++ b/drivers/net/ethernet/intel/ice/ice.h
@@ -297,6 +297,7 @@ enum ice_pf_state {
 	ICE_SIDEBANDQ_EVENT_PENDING,
 	ICE_MDD_EVENT_PENDING,
 	ICE_VFLR_EVENT_PENDING,
+	ICE_VF_RESET_PENDING,
 	ICE_FLTR_OVERFLOW_PROMISC,
 	ICE_VF_DIS,
 	ICE_CFG_BUSY,
diff --git a/drivers/net/ethernet/intel/ice/ice_vf_lib.h b/drivers/net/ethernet/intel/ice/ice_vf_lib.h
index 396dfb2b2d97..8abc8c844c96 100644
--- a/drivers/net/ethernet/intel/ice/ice_vf_lib.h
+++ b/drivers/net/ethernet/intel/ice/ice_vf_lib.h
@@ -40,6 +40,7 @@ enum ice_vf_states {
 	ICE_VF_STATE_DIS,
 	ICE_VF_STATE_MC_PROMISC,
 	ICE_VF_STATE_UC_PROMISC,
+	ICE_VF_STATE_NEEDS_RESET,	/* reset deferred to service task */
 	ICE_VF_STATES_NBITS
 };
 
@@ -145,6 +146,7 @@ struct ice_vf {
 	struct kref refcnt;
 	struct ice_pf *pf;
 	struct pci_dev *vfdev;
+	struct devlink *devlink;
 	/* Used during virtchnl message handling and NDO ops against the VF
 	 * that will trigger a VFR
 	 */
@@ -243,6 +245,12 @@ static inline bool ice_vf_is_lldp_ena(struct ice_vf *vf)
 	return vf->num_mac_lldp && vf->trusted;
 }
 
+static inline bool ice_vf_is_ready(struct ice_vf *vf)
+{
+	return test_bit(ICE_VF_STATE_INIT, vf->vf_states) &&
+	       !test_bit(ICE_VF_STATE_DIS, vf->vf_states);
+}
+
 /* VF Hash Table access functions
  *
  * These functions provide abstraction for interacting with the VF hash table.
@@ -319,9 +327,12 @@ int
 ice_vf_clear_vsi_promisc(struct ice_vf *vf, struct ice_vsi *vsi, u8 promisc_m);
 int ice_reset_vf(struct ice_vf *vf, u32 flags);
 void ice_reset_all_vfs(struct ice_pf *pf);
+void ice_schedule_vf_reset(struct ice_vf *vf);
 struct ice_vsi *ice_get_vf_ctrl_vsi(struct ice_pf *pf, struct ice_vsi *vsi);
 void ice_vf_update_mac_lldp_num(struct ice_vf *vf, struct ice_vsi *vsi,
 				bool incr);
+void ice_init_vf_devlink(struct ice_vf *vf);
+void ice_deinit_vf_devlink(struct ice_vf *vf);
 #else /* CONFIG_PCI_IOV */
 static inline struct ice_vf *ice_get_vf_by_id(struct ice_pf *pf, u16 vf_id)
 {
@@ -393,11 +404,23 @@ static inline void ice_reset_all_vfs(struct ice_pf *pf)
 {
 }
 
+static inline void ice_schedule_vf_reset(struct ice_vf *vf)
+{
+}
+
 static inline struct ice_vsi *
 ice_get_vf_ctrl_vsi(struct ice_pf *pf, struct ice_vsi *vsi)
 {
 	return NULL;
 }
+
+static inline void ice_init_vf_devlink(struct ice_vf *vf)
+{
+}
+
+static inline void ice_deinit_vf_devlink(struct ice_vf *vf)
+{
+}
 #endif /* !CONFIG_PCI_IOV */
 
 #endif /* _ICE_VF_LIB_H_ */
diff --git a/drivers/net/ethernet/intel/ice/virt/queues.h b/drivers/net/ethernet/intel/ice/virt/queues.h
index 223f609dd4f3..d9aa0153db4e 100644
--- a/drivers/net/ethernet/intel/ice/virt/queues.h
+++ b/drivers/net/ethernet/intel/ice/virt/queues.h
@@ -7,7 +7,9 @@
 #include <linux/types.h>
 
 struct ice_vf;
+struct ice_vsi;
 
+int ice_vf_max_contig_qs(struct ice_vf *vf, struct ice_vsi *vsi);
 u16 ice_vc_get_max_frame_size(struct ice_vf *vf);
 int ice_vc_ena_qs_msg(struct ice_vf *vf, u8 *msg);
 int ice_vc_dis_qs_msg(struct ice_vf *vf, u8 *msg);
diff --git a/drivers/net/ethernet/intel/ice/virt/rss.h b/drivers/net/ethernet/intel/ice/virt/rss.h
index 784d4c43ce8b..388f980b4cdf 100644
--- a/drivers/net/ethernet/intel/ice/virt/rss.h
+++ b/drivers/net/ethernet/intel/ice/virt/rss.h
@@ -14,5 +14,6 @@ int ice_vc_config_rss_lut(struct ice_vf *vf, u8 *msg);
 int ice_vc_config_rss_hfunc(struct ice_vf *vf, u8 *msg);
 int ice_vc_get_rss_hashcfg(struct ice_vf *vf);
 int ice_vc_set_rss_hashcfg(struct ice_vf *vf, u8 *msg);
+int ice_vc_get_max_rss_qregion(struct ice_vf *vf);
 
 #endif /* _ICE_VIRT_RSS_H_ */
diff --git a/drivers/net/ethernet/intel/ice/virt/virtchnl.h b/drivers/net/ethernet/intel/ice/virt/virtchnl.h
index d11789b3ae1f..18024f13fb5d 100644
--- a/drivers/net/ethernet/intel/ice/virt/virtchnl.h
+++ b/drivers/net/ethernet/intel/ice/virt/virtchnl.h
@@ -78,6 +78,10 @@ struct ice_virtchnl_ops {
 	int (*get_ptp_cap)(struct ice_vf *vf,
 			   const struct virtchnl_ptp_caps *msg);
 	int (*get_phc_time)(struct ice_vf *vf);
+	int (*get_max_rss_qregion)(struct ice_vf *vf);
+	int (*ena_qs_v2_msg)(struct ice_vf *vf, u8 *msg, u16 msglen);
+	int (*dis_qs_v2_msg)(struct ice_vf *vf, u8 *msg, u16 msglen);
+	int (*map_q_vector_msg)(struct ice_vf *vf, u8 *msg, u16 msglen);
 };
 
 #ifdef CONFIG_PCI_IOV
diff --git a/drivers/net/ethernet/intel/ice/devlink/resource.c b/drivers/net/ethernet/intel/ice/devlink/resource.c
index c07f61acdaed..34286404d475 100644
--- a/drivers/net/ethernet/intel/ice/devlink/resource.c
+++ b/drivers/net/ethernet/intel/ice/devlink/resource.c
@@ -135,6 +135,16 @@ void ice_free_rss_lut_flr(struct ice_pf *pf)
 		ice_free_rss_lut_flr_locked(pf);
 }
 
+void ice_free_rss_lut_vf(struct ice_vf *vf)
+{
+	struct ice_pf *pf = vf->pf;
+
+	scoped_guard(ice_adapter_devl, pf->adapter) {
+		ice_devl_res_free(pf, ICE_RSS_LUT_GLOBAL, vf);
+		ice_devl_res_free(pf, ICE_RSS_LUT_PF, vf);
+	}
+}
+
 static int ice_devl_res_owned_idx(struct ice_pf *pf,
 				  enum ice_devl_resource_id res_id, void *owner)
 {
@@ -194,6 +204,16 @@ static u64 ice_rss_lut_pf_size_get(void *priv)
 	}
 }
 
+static u64 ice_rss_lut_vf_size_get(void *priv)
+{
+	struct ice_vf *vf = priv;
+	struct ice_pf *pf;
+
+	pf = vf->pf;
+	scoped_guard(ice_adapter_devl, pf->adapter)
+		return ice_lut_type_to_size(ice_rss_lut_type(pf, vf));
+}
+
 static int ice_rss_lut_user_resize(struct ice_vsi *vsi,
 				   enum ice_lut_type lut_type, u8 **user_lut,
 				   struct netlink_ext_ack *extack)
@@ -255,6 +275,7 @@ static int ice_change_rss_lut(struct ice_pf *pf, void *owner,
 	struct ice_aq_get_set_rss_lut_params params = {};
 	struct ice_hw *hw = &pf->hw;
 	int err, lut_size, lut_id;
+	struct ice_vf *vf = NULL;
 	struct ice_vsi *vsi;
 	u8 *user_lut = NULL;
 	u16 rss_size;
@@ -271,7 +292,8 @@ static int ice_change_rss_lut(struct ice_pf *pf, void *owner,
 	if (pf == owner) {
 		vsi = ice_get_main_vsi(pf);
 	} else {
-		return -EOPNOTSUPP;
+		vf = owner;
+		vsi = ice_get_vf_vsi(vf);
 	}
 
 	lut_size = ice_lut_type_to_size(lut_type);
@@ -288,7 +310,7 @@ static int ice_change_rss_lut(struct ice_pf *pf, void *owner,
 	if (err)
 		goto out;
 	/* PF with RXHASH disabled keeps its LUT zeroed */
-	if (!vsi->netdev || vsi->netdev->features & NETIF_F_RXHASH) {
+	if (vf || !vsi->netdev || vsi->netdev->features & NETIF_F_RXHASH) {
 		if (user_lut)
 			memcpy(lut, user_lut, lut_size);
 		else
@@ -312,6 +334,14 @@ static int ice_change_rss_lut(struct ice_pf *pf, void *owner,
 	vsi->rss_table_size = lut_size;
 	vsi->rss_lut_type = lut_type;
 	vsi->rss_size = rss_size;
+	if (vf) {
+		u16 max_qs = ice_lut_type_to_qs_num(lut_type);
+
+		/* don't keep queues that the new LUT can't spread traffic to */
+		if ((vf->num_req_qs ?: vf->num_vf_qs) > max_qs)
+			vf->num_req_qs = max_qs;
+		ice_schedule_vf_reset(vf);
+	}
 out:
 	mutex_unlock(&pf->rss_lut_lock);
 	devm_kfree(ice_pf_to_dev(pf), user_lut);
@@ -346,7 +376,12 @@ static int ice_rss_lut_set(struct ice_pf *pf, void *owner, u64 size,
 		new_type = ICE_LUT_PF;
 		break;
 	default:
-		NL_SET_ERR_MSG_MOD(extack, "RSS LUT size must be 512 or 2048");
+		if (owner == pf)
+			NL_SET_ERR_MSG_MOD(extack,
+					   "RSS LUT size must be 512 or 2048");
+		else
+			NL_SET_ERR_MSG_MOD(extack,
+					   "RSS LUT size must be 64, 512 or 2048");
 		return -EINVAL;
 	}
 
@@ -418,6 +453,22 @@ static int ice_rss_lut_pf_size_set(u64 size, struct netlink_ext_ack *extack,
 	return err;
 }
 
+static int ice_rss_lut_vf_size_set(u64 size, struct netlink_ext_ack *extack,
+				   void *priv)
+{
+	struct ice_vf *vf = priv;
+	struct ice_pf *pf;
+
+	pf = vf->pf;
+	scoped_guard(mutex, &vf->cfg_lock) {
+		if (!ice_vf_is_ready(vf))
+			return -EBUSY;
+
+		scoped_guard(ice_adapter_devl, pf->adapter)
+			return ice_rss_lut_set(pf, vf, size, extack);
+	}
+}
+
 /**
  * ice_rss_lut_is_reassigned - check if RSS LUTs of PF are in non-default state
  * @pf: the PF to check
@@ -548,24 +599,47 @@ static int ice_rebuild_rss_lut_pf(struct ice_pf *pf)
  * @pf: the PF that was reset
  *
  * Wrapper of ice_rebuild_rss_lut_pf() that also tells the ethtool core when
- * the user RSS LUT was dropped. Must be called without rtnl held.
+ * the user RSS LUT was dropped, and makes the VF VSIs use their default LUTs.
+ * Must be called without rtnl held.
  *
  * Return: 0 on success, negative on error.
  */
 int ice_rebuild_rss_luts(struct ice_pf *pf)
 {
+	u16 max_qs = ice_lut_type_to_qs_num(ICE_LUT_VSI);
 	struct ice_vsi *vsi = ice_get_main_vsi(pf);
+	struct ice_vf *vf;
+	unsigned int bkt;
 	int err;
 
 	/* ethtool core sizes RSS buffers by rss_table_size under rtnl */
 	rtnl_lock();
 	err = ice_rebuild_rss_lut_pf(pf);
 	if (vsi && vsi->netdev && !vsi->rss_lut_user &&
 	    netif_is_rxfh_configured(vsi->netdev))
 		ethtool_rxfh_indir_lost(vsi->netdev);
 	rtnl_unlock();
+	if (err)
+		return err;
 
-	return err;
+	/* VF creation takes rtnl under table_lock, so don't nest them here */
+	mutex_lock(&pf->vfs.table_lock);
+	mutex_lock(&pf->rss_lut_lock);
+	ice_for_each_vf(pf, bkt, vf) {
+		vsi = ice_get_vf_vsi(vf);
+		if (!vsi || vsi->rss_lut_type == ICE_LUT_VSI)
+			continue;
+
+		vsi->rss_table_size = ice_lut_type_to_size(ICE_LUT_VSI);
+		vsi->rss_lut_type = ICE_LUT_VSI;
+		/* don't keep queues that the VSI LUT can't spread traffic to */
+		if ((vf->num_req_qs ?: vf->num_vf_qs) > max_qs)
+			vf->num_req_qs = max_qs;
+	}
+	mutex_unlock(&pf->rss_lut_lock);
+	mutex_unlock(&pf->vfs.table_lock);
+
+	return 0;
 }
 
 static void ice_devl_hw_res_register(struct devlink *devlink, const char *name,
@@ -641,3 +715,13 @@ void ice_devl_pf_resources_register(struct ice_pf *pf)
 				  ice_rss_lut_pf_size_get,
 				  ice_rss_lut_pf_size_set, pf);
 }
+
+void ice_devlink_vf_resources_register(struct ice_vf *vf)
+{
+	struct devlink *devlink = vf->devlink;
+
+	devl_assert_locked(devlink);
+	ice_devl_rss_lut_register(devlink, ICE_LUT_VSI_SIZE,
+				  ice_rss_lut_vf_size_get,
+				  ice_rss_lut_vf_size_set, vf);
+}
diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
index 5f0de7cf0a8e..43c6c1093d27 100644
--- a/drivers/net/ethernet/intel/ice/ice_main.c
+++ b/drivers/net/ethernet/intel/ice/ice_main.c
@@ -2276,6 +2276,30 @@ static void ice_check_media_subtask(struct ice_pf *pf)
 	}
 }
 
+static void ice_handle_deferred_vf_reset(struct ice_pf *pf)
+{
+	struct ice_vf *vf;
+	unsigned int bkt;
+	int err;
+
+	if (!test_and_clear_bit(ICE_VF_RESET_PENDING, pf->state))
+		return;
+
+	mutex_lock(&pf->vfs.table_lock);
+	ice_for_each_vf(pf, bkt, vf) {
+		if (!test_and_clear_bit(ICE_VF_STATE_NEEDS_RESET, vf->vf_states))
+			continue;
+
+		dev_info(ice_pf_to_dev(pf), "doing deferred reset of VF %d\n",
+			 vf->vf_id);
+		err = ice_reset_vf(vf, ICE_VF_RESET_NOTIFY | ICE_VF_RESET_LOCK);
+		if (err)
+			dev_warn(ice_pf_to_dev(pf), "deferred reset of VF %d failed: %d\n",
+				 vf->vf_id, err);
+	}
+	mutex_unlock(&pf->vfs.table_lock);
+}
+
 static void ice_service_task_recovery_mode(struct work_struct *work)
 {
 	struct ice_pf *pf = container_of(work, struct ice_pf, serv_task);
@@ -2358,6 +2382,7 @@ static void ice_service_task(struct work_struct *work)
 		return;
 	}
 
+	ice_handle_deferred_vf_reset(pf);
 	ice_process_vflr_event(pf);
 	ice_clean_mailboxq_subtask(pf);
 	ice_clean_sbq_subtask(pf);
@@ -2374,6 +2399,7 @@ static void ice_service_task(struct work_struct *work)
 	if (time_after(jiffies, (start_time + pf->serv_tmr_period)) ||
 	    test_bit(ICE_MDD_EVENT_PENDING, pf->state) ||
 	    test_bit(ICE_VFLR_EVENT_PENDING, pf->state) ||
+	    test_bit(ICE_VF_RESET_PENDING, pf->state) ||
 	    test_bit(ICE_MAILBOXQ_EVENT_PENDING, pf->state) ||
 	    test_bit(ICE_FD_VF_FLUSH_CTX, pf->state) ||
 	    test_bit(ICE_SIDEBANDQ_EVENT_PENDING, pf->state) ||
diff --git a/drivers/net/ethernet/intel/ice/ice_sriov.c b/drivers/net/ethernet/intel/ice/ice_sriov.c
index d7c4a6540008..24c521aaf3f3 100644
--- a/drivers/net/ethernet/intel/ice/ice_sriov.c
+++ b/drivers/net/ethernet/intel/ice/ice_sriov.c
@@ -10,6 +10,7 @@
 #include "ice_flow.h"
 #include "ice_eswitch.h"
 #include "virt/allowlist.h"
+#include "virt/queues.h"
 #include "ice_flex_pipe.h"
 #include "ice_vf_vsi_vlan_ops.h"
 #include "ice_vlan.h"
@@ -142,6 +143,12 @@ void ice_free_vfs(struct ice_pf *pf)
 	while (test_and_set_bit(ICE_VF_DIS, pf->state))
 		usleep_range(1000, 2000);
 
+	/* unregister VF devlinks while their VF pci_devs still exist */
+	mutex_lock(&vfs->table_lock);
+	ice_for_each_vf(pf, bkt, vf)
+		ice_deinit_vf_devlink(vf);
+	mutex_unlock(&vfs->table_lock);
+
 	/* Disable IOV before freeing resources. This lets any VF drivers
 	 * running in the host get themselves cleaned up before we yank
 	 * the carpet out from underneath their feet.
@@ -501,6 +508,11 @@ static int ice_start_vfs(struct ice_pf *pf)
 	}
 
 	ice_flush(hw);
+
+	/* only now, so the teardown below has no VF devlink to unregister */
+	ice_for_each_vf(pf, bkt, vf)
+		ice_init_vf_devlink(vf);
+
 	return 0;
 
 teardown:
@@ -657,6 +669,15 @@ static void ice_sriov_post_vsi_rebuild(struct ice_vf *vf)
 	wr32(&vf->pf->hw, VFGEN_RSTAT(vf->vf_id), VIRTCHNL_VFR_VFACTIVE);
 }
 
+static struct ice_q_vector *ice_sriov_get_q_vector(struct ice_vsi *vsi,
+						   u16 vector_id)
+{
+	/* Subtract non queue vector from vector_id passed by VF
+	 * to get actual number of VSI queue vector array index
+	 */
+	return vsi->q_vectors[vector_id - ICE_NONQ_VECS_VF];
+}
+
 static const struct ice_vf_ops ice_sriov_vf_ops = {
 	.reset_type = ICE_VF_RESET,
 	.free = ice_sriov_free_vf,
@@ -667,6 +688,7 @@ static const struct ice_vf_ops ice_sriov_vf_ops = {
 	.clear_reset_trigger = ice_sriov_clear_reset_trigger,
 	.irq_close = NULL,
 	.post_vsi_rebuild = ice_sriov_post_vsi_rebuild,
+	.get_q_vector = ice_sriov_get_q_vector,
 };
 
 /**
@@ -969,6 +991,12 @@ int ice_sriov_set_msix_vec_count(struct pci_dev *vf_dev, int msix_vec_count)
 		return 0;
 	}
 
+	/* VSI rebuild takes one free range for all queues of the VF */
+	if ((vf->num_req_qs ?: queues) > ice_vf_max_contig_qs(vf, vsi)) {
+		ice_put_vf(vf);
+		return -ENOSPC;
+	}
+
 	prev_msix = vf->num_msix;
 	prev_queues = vf->num_vf_qs;
 
diff --git a/drivers/net/ethernet/intel/ice/ice_vf_lib.c b/drivers/net/ethernet/intel/ice/ice_vf_lib.c
index 320b393ddaaf..015b50c70bdc 100644
--- a/drivers/net/ethernet/intel/ice/ice_vf_lib.c
+++ b/drivers/net/ethernet/intel/ice/ice_vf_lib.c
@@ -6,6 +6,7 @@
 #include "ice_lib.h"
 #include "ice_fltr.h"
 #include "virt/allowlist.h"
+#include "devlink/resource.h"
 
 /* Public functions which may be accessed by all driver files */
 
@@ -794,6 +795,8 @@ void ice_reset_all_vfs(struct ice_pf *pf)
 		ice_eswitch_detach_vf(pf, vf);
 		vf->driver_caps = 0;
 		ice_vc_set_default_allowlist(vf);
+		/* the VSI rebuild applies what a deferred reset was for */
+		clear_bit(ICE_VF_STATE_NEEDS_RESET, vf->vf_states);
 
 		ice_vf_fdir_exit(vf);
 		ice_vf_fdir_init(vf);
@@ -807,6 +810,8 @@ void ice_reset_all_vfs(struct ice_pf *pf)
 		if (ice_vf_rebuild_vsi(vf)) {
 			dev_err(dev, "VF %u VSI rebuild failed, leaving VF disabled\n",
 				vf->vf_id);
+			/* INIT stays clear, but let a VFLR reset the VF */
+			clear_bit(ICE_VF_STATE_DIS, vf->vf_states);
 			mutex_unlock(&vf->cfg_lock);
 			continue;
 		}
@@ -933,6 +938,8 @@ int ice_reset_vf(struct ice_vf *vf, u32 flags)
 
 	/* Set VF disable bit state here, before triggering reset */
 	set_bit(ICE_VF_STATE_DIS, vf->vf_states);
+	/* this reset applies what a deferred reset was requested for */
+	clear_bit(ICE_VF_STATE_NEEDS_RESET, vf->vf_states);
 	ice_trigger_vf_reset(vf, flags & ICE_VF_RESET_VFLR, false);
 
 	vsi = ice_get_vf_vsi(vf);
@@ -1010,14 +1017,29 @@ int ice_reset_vf(struct ice_vf *vf, u32 flags)
 	return err;
 }
 
+/**
+ * ice_schedule_vf_reset - reset VF, deferred to next service_task context
+ * @vf: VF to reset
+ */
+void ice_schedule_vf_reset(struct ice_vf *vf)
+{
+	set_bit(ICE_VF_STATE_NEEDS_RESET, vf->vf_states);
+	/* pairs with test_and_clear_bit() in ice_handle_deferred_vf_reset() */
+	smp_mb__after_atomic();
+	set_bit(ICE_VF_RESET_PENDING, vf->pf->state);
+	ice_service_task_schedule(vf->pf);
+}
+
 /**
  * ice_set_vf_state_dis - Set VF state to disabled
  * @vf: pointer to the VF structure
  */
 void ice_set_vf_state_dis(struct ice_vf *vf)
 {
 	ice_set_vf_state_qs_dis(vf);
 	vf->vf_ops->clear_reset_state(vf);
+	/* until ice_reset_all_vfs() rebuilds the VF */
+	set_bit(ICE_VF_STATE_DIS, vf->vf_states);
 }
 
 /* Private functions only accessed from other virtualization files */
@@ -1064,6 +1086,8 @@ void ice_deinitialize_vf_entry(struct ice_vf *vf)
 {
 	struct ice_pf *pf = vf->pf;
 
+	ice_free_rss_lut_vf(vf);
+
 	if (!ice_is_feature_supported(pf, ICE_F_MBX_LIMIT))
 		list_del(&vf->mbx_info.list_entry);
 }
@@ -1450,3 +1474,52 @@ void ice_vf_update_mac_lldp_num(struct ice_vf *vf, struct ice_vsi *vsi,
 	if (was_ena != is_ena)
 		ice_vsi_cfg_sw_lldp(vsi, false, is_ena);
 }
+
+void ice_init_vf_devlink(struct ice_vf *vf)
+{
+	struct devlink *pf_devlink = priv_to_devlink(vf->pf);
+	static const struct devlink_ops noop = {};
+	struct devlink *devlink;
+	int err;
+
+	lockdep_assert_held(&vf->pf->vfs.table_lock);
+
+	/* no VF pci_dev when the VFs were not scanned, e.g. on s390 */
+	if (!vf->vfdev)
+		return;
+
+	devlink = devlink_alloc_drv(&noop, 0, &vf->vfdev->dev,
+				    ice_pf_to_dev(vf->pf)->driver);
+	if (!devlink)
+		return;
+
+	scoped_guard(devl, pf_devlink)
+		err = devl_nested_devlink_set(pf_devlink, devlink);
+	if (err) {
+		devlink_free(devlink);
+		return;
+	}
+
+	vf->devlink = devlink;
+	scoped_guard(devl, devlink) {
+		ice_devlink_vf_resources_register(vf);
+		devl_register(devlink);
+	}
+}
+
+void ice_deinit_vf_devlink(struct ice_vf *vf)
+{
+	struct devlink *devlink = vf->devlink;
+
+	lockdep_assert_held(&vf->pf->vfs.table_lock);
+
+	if (!devlink)
+		return;
+
+	vf->devlink = NULL;
+	scoped_guard(devl, devlink) {
+		devl_unregister(devlink);
+		devl_resources_unregister(devlink);
+	}
+	devlink_free(devlink);
+}
diff --git a/drivers/net/ethernet/intel/ice/virt/queues.c b/drivers/net/ethernet/intel/ice/virt/queues.c
index e8635236cb6c..1afb7a2946fe 100644
--- a/drivers/net/ethernet/intel/ice/virt/queues.c
+++ b/drivers/net/ethernet/intel/ice/virt/queues.c
@@ -986,6 +986,48 @@ int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)
 				     VIRTCHNL_STATUS_ERR_PARAM, NULL, 0);
 }
 
+/**
+ * ice_vf_max_contig_qs - get the most queues VF could get in one range
+ * @vf: pointer to the VF info
+ * @vsi: VSI of the VF
+ *
+ * Scattered queue mapping is not implemented for VFs. Queues of the VF count
+ * as free, as VSI rebuild releases them before it takes the new range.
+ *
+ * Return: length of the longest range of free Tx queues and Rx queues.
+ */
+int ice_vf_max_contig_qs(struct ice_vf *vf, struct ice_vsi *vsi)
+{
+	struct ice_pf *pf = vf->pf;
+	unsigned long *txqs, *rxqs;
+	int max_tx = 0, max_rx = 0;
+	int b, e;
+
+	txqs = bitmap_alloc(pf->max_pf_txqs, GFP_KERNEL);
+	rxqs = bitmap_alloc(pf->max_pf_rxqs, GFP_KERNEL);
+	if (!txqs || !rxqs)
+		goto out;
+
+	scoped_guard(mutex, &pf->avail_q_mutex) {
+		bitmap_copy(txqs, pf->avail_txqs, pf->max_pf_txqs);
+		bitmap_copy(rxqs, pf->avail_rxqs, pf->max_pf_rxqs);
+	}
+	for (int i = 0; i < vsi->alloc_txq; i++)
+		clear_bit(vsi->txq_map[i], txqs);
+	for (int i = 0; i < vsi->alloc_rxq; i++)
+		clear_bit(vsi->rxq_map[i], rxqs);
+
+	for_each_clear_bitrange(b, e, txqs, pf->max_pf_txqs)
+		max_tx = max(max_tx, e - b);
+	for_each_clear_bitrange(b, e, rxqs, pf->max_pf_rxqs)
+		max_rx = max(max_rx, e - b);
+out:
+	bitmap_free(txqs);
+	bitmap_free(rxqs);
+
+	return min(max_tx, max_rx);
+}
+
 /**
  * ice_vc_request_qs_msg
  * @vf: pointer to the VF info
@@ -1004,33 +1046,41 @@ int ice_vc_request_qs_msg(struct ice_vf *vf, u8 *msg)
 	u16 req_queues = vfres->num_queue_pairs;
 	struct ice_pf *pf = vf->pf;
 	u16 max_allowed_vf_queues;
-	u16 tx_rx_queue_left;
+	struct ice_vsi *vsi;
 	struct device *dev;
-	u16 cur_queues;
+	u16 max_lut_queues;
 
 	dev = ice_pf_to_dev(pf);
 	if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states)) {
 		v_ret = VIRTCHNL_STATUS_ERR_PARAM;
 		goto error_param;
 	}
 
-	cur_queues = vf->num_vf_qs;
-	tx_rx_queue_left = min_t(u16, ice_get_avail_txq_count(pf),
-				 ice_get_avail_rxq_count(pf));
-	max_allowed_vf_queues = tx_rx_queue_left + cur_queues;
+	vsi = ice_get_vf_vsi(vf);
+	if (!vsi) {
+		v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+		goto error_param;
+	}
+
+	/* without LARGE_NUM_QPAIRS, VF can only use the v1 queue opcodes */
+	if (vf->driver_caps & VIRTCHNL_VF_LARGE_NUM_QPAIRS)
+		max_lut_queues = ice_lut_type_to_qs_num(vsi->rss_lut_type);
+	else
+		max_lut_queues = ICE_MAX_QS_PER_VF_VCV1;
+	max_allowed_vf_queues = min(ice_vf_max_contig_qs(vf, vsi),
+				    max_lut_queues);
+	if (req_queues > max_lut_queues) {
+		vfres->num_queue_pairs = max_allowed_vf_queues;
+		goto error_param;
+	}
+
 	if (!req_queues) {
 		dev_err(dev, "VF %d tried to request 0 queues. Ignoring.\n",
 			vf->vf_id);
-	} else if (req_queues > ICE_MAX_QS_PER_VF_VCV1) {
-		dev_err(dev, "VF %d tried to request more than %d queues.\n",
-			vf->vf_id, ICE_MAX_QS_PER_VF_VCV1);
-		vfres->num_queue_pairs = ICE_MAX_QS_PER_VF_VCV1;
-	} else if (req_queues > cur_queues &&
-		   req_queues - cur_queues > tx_rx_queue_left) {
-		dev_warn(dev, "VF %d requested %u more queues, but only %u left.\n",
-			 vf->vf_id, req_queues - cur_queues, tx_rx_queue_left);
-		vfres->num_queue_pairs = min_t(u16, max_allowed_vf_queues,
-					       ICE_MAX_QS_PER_VF_VCV1);
+	} else if (req_queues > max_allowed_vf_queues) {
+		dev_warn(dev, "VF %d requested %u queues, but only %u are free in one range.\n",
+			 vf->vf_id, req_queues, max_allowed_vf_queues);
+		vfres->num_queue_pairs = max_allowed_vf_queues;
 	} else {
 		/* request is successful, then reset VF */
 		vf->num_req_qs = req_queues;
diff --git a/drivers/net/ethernet/intel/ice/virt/rss.c b/drivers/net/ethernet/intel/ice/virt/rss.c
index 960012ca91b5..99d9295af79c 100644
--- a/drivers/net/ethernet/intel/ice/virt/rss.c
+++ b/drivers/net/ethernet/intel/ice/virt/rss.c
@@ -3,6 +3,7 @@
 
 #include "rss.h"
 #include "ice_vf_lib_private.h"
+#include "ice_lib.h"
 #include "ice.h"
 
 #define FIELD_SELECTOR(proto_hdr_field) \
@@ -1734,7 +1735,9 @@ int ice_vc_config_rss_lut(struct ice_vf *vf, u8 *msg)
 {
 	struct virtchnl_rss_lut *vrl = (struct virtchnl_rss_lut *)msg;
 	enum virtchnl_status_code v_ret = VIRTCHNL_STATUS_SUCCESS;
+	int lut_size = ICE_LUT_VSI_SIZE;
 	struct ice_vsi *vsi;
+	u8 *lut;
 
 	if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states)) {
 		v_ret = VIRTCHNL_STATUS_ERR_PARAM;
@@ -1746,24 +1749,38 @@ int ice_vc_config_rss_lut(struct ice_vf *vf, u8 *msg)
 		goto error_param;
 	}
 
-	if (vrl->lut_entries != ICE_LUT_VSI_SIZE) {
+	vsi = ice_get_vf_vsi(vf);
+	if (!vsi) {
 		v_ret = VIRTCHNL_STATUS_ERR_PARAM;
 		goto error_param;
 	}
 
-	if (!test_bit(ICE_FLAG_RSS_ENA, vf->pf->flags)) {
+	/* the LUT size reported in the GET_VF_RESOURCES reply */
+	if (vf->driver_caps & VIRTCHNL_VF_LARGE_NUM_QPAIRS)
+		lut_size = vsi->rss_table_size;
+	if (vrl->lut_entries != lut_size) {
 		v_ret = VIRTCHNL_STATUS_ERR_PARAM;
 		goto error_param;
 	}
 
-	vsi = ice_get_vf_vsi(vf);
-	if (!vsi) {
+	if (!test_bit(ICE_FLAG_RSS_ENA, vf->pf->flags)) {
 		v_ret = VIRTCHNL_STATUS_ERR_PARAM;
 		goto error_param;
 	}
 
-	if (ice_set_rss_lut(vsi, vrl->lut, ICE_LUT_VSI_SIZE))
+	lut = kmalloc(vsi->rss_table_size, GFP_KERNEL);
+	if (!lut) {
+		v_ret = VIRTCHNL_STATUS_ERR_NO_MEMORY;
+		goto error_param;
+	}
+
+	/* repeat the LUT of the VF over the whole RSS LUT of its VSI */
+	for (int i = 0; i < vsi->rss_table_size; i++)
+		lut[i] = vrl->lut[i % lut_size];
+
+	if (ice_set_rss_lut(vsi, lut, vsi->rss_table_size))
 		v_ret = VIRTCHNL_STATUS_ERR_ADMIN_QUEUE_ERROR;
+	kfree(lut);
 error_param:
 	return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_CONFIG_RSS_LUT, v_ret,
 				     NULL, 0);
@@ -1920,3 +1937,30 @@ int ice_vc_set_rss_hashcfg(struct ice_vf *vf, u8 *msg)
 				     NULL, 0);
 }
 
+int ice_vc_get_max_rss_qregion(struct ice_vf *vf)
+{
+	enum virtchnl_status_code v_ret = VIRTCHNL_STATUS_SUCCESS;
+	struct virtchnl_max_rss_qregion max_rss_qregion = {};
+	struct ice_vsi *vsi;
+	int err, len = 0;
+
+	if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states)) {
+		v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+		goto reply;
+	}
+
+	vsi = ice_get_vf_vsi(vf);
+	if (!vsi) {
+		v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+		goto reply;
+	}
+
+	len = sizeof(max_rss_qregion);
+	max_rss_qregion.vport_id = ICE_VF_VSI_ID;
+	max_rss_qregion.qregion_width =
+		ilog2(ice_lut_type_to_qs_num(vsi->rss_lut_type));
+reply:
+	err = ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_GET_MAX_RSS_QREGION, v_ret,
+				    (u8 *)&max_rss_qregion, len);
+	return err;
+}
diff --git a/drivers/net/ethernet/intel/ice/virt/virtchnl.c b/drivers/net/ethernet/intel/ice/virt/virtchnl.c
index ca8018e3dd42..8ea68c95f13c 100644
--- a/drivers/net/ethernet/intel/ice/virt/virtchnl.c
+++ b/drivers/net/ethernet/intel/ice/virt/virtchnl.c
@@ -329,12 +329,19 @@ static int ice_vc_get_vf_res_msg(struct ice_vf *vf, u8 *msg)
 	if (vf->driver_caps & VIRTCHNL_VF_CAP_PTP)
 		vfres->vf_cap_flags |= VIRTCHNL_VF_CAP_PTP;
 
+	if (vf->driver_caps & VIRTCHNL_VF_LARGE_NUM_QPAIRS &&
+	    vsi->rss_lut_type != ICE_LUT_VSI)
+		vfres->vf_cap_flags |= VIRTCHNL_VF_LARGE_NUM_QPAIRS;
+
 	vfres->num_vsis = 1;
 	/* Tx and Rx queue are equal for VF */
 	vfres->num_queue_pairs = vsi->num_txq;
 	vfres->max_vectors = vf->num_msix;
 	vfres->rss_key_size = ICE_VSIQF_HKEY_ARRAY_SIZE;
 	vfres->rss_lut_size = ICE_LUT_VSI_SIZE;
+	/* older VF drivers allocate their RSS LUT only once, at init */
+	if (vfres->vf_cap_flags & VIRTCHNL_VF_LARGE_NUM_QPAIRS)
+		vfres->rss_lut_size = vsi->rss_table_size;
 	vfres->max_mtu = ice_vc_get_max_frame_size(vf);
 
 	vfres->vsi_res[0].vsi_id = ICE_VF_VSI_ID;
@@ -2533,6 +2540,10 @@ static const struct ice_virtchnl_ops ice_virtchnl_dflt_ops = {
 	.cfg_q_quanta = ice_vc_cfg_q_quanta,
 	.get_ptp_cap = ice_vc_get_ptp_cap,
 	.get_phc_time = ice_vc_get_phc_time,
+	.get_max_rss_qregion = ice_vc_get_max_rss_qregion,
+	.ena_qs_v2_msg = ice_vc_ena_qs_v2_msg,
+	.dis_qs_v2_msg = ice_vc_dis_qs_v2_msg,
+	.map_q_vector_msg = ice_vc_map_q_vector_msg,
 	/* If you add a new op here please make sure to add it to
 	 * ice_virtchnl_repr_ops as well.
 	 */
@@ -2670,6 +2681,10 @@ static const struct ice_virtchnl_ops ice_virtchnl_repr_ops = {
 	.cfg_q_quanta = ice_vc_cfg_q_quanta,
 	.get_ptp_cap = ice_vc_get_ptp_cap,
 	.get_phc_time = ice_vc_get_phc_time,
+	.get_max_rss_qregion = ice_vc_get_max_rss_qregion,
+	.ena_qs_v2_msg = ice_vc_ena_qs_v2_msg,
+	.dis_qs_v2_msg = ice_vc_dis_qs_v2_msg,
+	.map_q_vector_msg = ice_vc_map_q_vector_msg,
 };
 
 /**
@@ -2766,6 +2781,13 @@ void ice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event,
 		goto error_handler;
 	}
 
+	/* VF must not see a config change before the reset that applies it */
+	if (test_and_clear_bit(ICE_VF_STATE_NEEDS_RESET, vf->vf_states)) {
+		dev_info(dev, "doing deferred reset of VF %d\n", vf_id);
+		ice_reset_vf(vf, ICE_VF_RESET_NOTIFY);
+		goto finish;
+	}
+
 	ops = vf->virtchnl_ops;
 
 	/* Perform basic checks on the msg */
@@ -2901,6 +2923,20 @@ void ice_vc_process_vf_msg(struct ice_pf *pf, struct ice_rq_event_info *event,
 	case VIRTCHNL_OP_GET_QOS_CAPS:
 		err = ops->get_qos_caps(vf);
 		break;
+	case VIRTCHNL_OP_GET_MAX_RSS_QREGION:
+		err = ops->get_max_rss_qregion(vf);
+		break;
+	case VIRTCHNL_OP_ENABLE_QUEUES_V2:
+		err = ops->ena_qs_v2_msg(vf, msg, msglen);
+		if (!err)
+			ice_vc_notify_vf_link_state(vf);
+		break;
+	case VIRTCHNL_OP_DISABLE_QUEUES_V2:
+		err = ops->dis_qs_v2_msg(vf, msg, msglen);
+		break;
+	case VIRTCHNL_OP_MAP_QUEUE_VECTOR:
+		err = ops->map_q_vector_msg(vf, msg, msglen);
+		break;
 	case VIRTCHNL_OP_CONFIG_QUEUE_BW:
 		err = ops->cfg_q_bw(vf, msg);
 		break;
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* Re: [PATCH net-next v7 00/15] devlink, mlx5, iavf, ice: XLVF for iavf
  2026-11-21 22:55 [PATCH net-next v7 00/15] devlink, mlx5, iavf, ice: XLVF for iavf Przemek Kitszel
                   ` (14 preceding siblings ...)
  2026-11-21 22:55 ` [PATCH net-next v7 15/15] ice: support up to 256 VF queues Przemek Kitszel
@ 2026-11-23  8:53 ` Matthieu Baerts
  2026-11-23 15:03   ` Przemek Kitszel
  15 siblings, 1 reply; 28+ messages in thread
From: Matthieu Baerts @ 2026-11-23  8:53 UTC (permalink / raw)
  To: Przemek Kitszel
  Cc: netdev, Jakub Kicinski, Jiri Pirko, Tony Nguyen,
	Aleksandr Loktionov, Michal Schmidt, edumazet, horms, pabeni,
	davem, Jonathan Corbet, skhan, rdunlap, andrew+netdev, saeedm,
	tariqt, leon, mbloch, jacob.e.keller, jedrzej.jagielski, anzaki,
	brett.creeley, ohartoov, Petr Oros, Donald Hunter

Hi Przemek,

Thank you for sharing these patches.

On 21/11/2026 23:55, Przemek Kitszel wrote:
> Also available here
> https://github.com/pkitszel/linux/tree/xlvf-v7
> (no mlx changes, just kept series name)
> 
> The purpose of this series is to allow iavf to use more than 16 queue
> pairs, in two modes: up to 64 and up to 256 queue pairs.
> 
> In order to support more queues for VF, we must give it a bigger RSS
> table (GLOBAL LUT or PF LUT). There are 16 GLOBAL LUTs on E810, and one
> PF LUT for every PF on given card. Both kinds could be (re)assigned to
> a VF, while a PF must hold at least one of them at any given moment.
> GLOBAL LUT allows VF to use up to 64 queues, PF LUT lets it use up to
> 256 queues.
> 
> RSS LUTs are exposed to the user for assignment via devlink resources
> API, which I have extended to make it possible.
Recently, many HW selftests have started to fail, mainly on ICE and with
tools/testing/selftests/drivers/net/hw/rss_api.py, but also on CX7:

 https://netdev.bots.linux.dev/branch_deltas/net-next-hw-2026-11-22--08-00.html

I wonder if it couldn't be due to your series. Do you mind having a
look, please?

Note that because of this series, the following WIP patch is no longer
applied, and maybe that's why some tests are starting to fail:

 https://github.com/linux-netdev/testing/commit/d00ba0185d53

I suggest dropping this series from the tests for the moment:

pw-bot: cr

Let's see if net-next-hw-2026-11-23--16-00 will still have these issues.

(Feel free to also look at the other flaky ones on Intel NICs, see my
other email thread)

 https://netdev.bots.linux.dev/contest.html?pass=0&branch=net-next-hw-2026-11-22--08-00&pw-y=0
 https://lore.kernel.org/5aec31d5-d042-4263-b3df-fa5a6a1399ec@kernel.org

Cheers,
Matt

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH net-next v7 00/15] devlink, mlx5, iavf, ice: XLVF for iavf
  2026-11-23  8:53 ` [PATCH net-next v7 00/15] devlink, mlx5, iavf, ice: XLVF for iavf Matthieu Baerts
@ 2026-11-23 15:03   ` Przemek Kitszel
  0 siblings, 0 replies; 28+ messages in thread
From: Przemek Kitszel @ 2026-11-23 15:03 UTC (permalink / raw)
  To: Matthieu Baerts
  Cc: netdev, Jakub Kicinski, Jiri Pirko, Tony Nguyen,
	Aleksandr Loktionov, Michal Schmidt, edumazet, horms, pabeni,
	davem, Jonathan Corbet, skhan, rdunlap, andrew+netdev, saeedm,
	tariqt, leon, mbloch, jacob.e.keller, jedrzej.jagielski, anzaki,
	brett.creeley, ohartoov, Petr Oros, Donald Hunter

On 11/23/26 9:53 AM, Matthieu Baerts wrote:
> Hi Przemek,
> 
> Thank you for sharing these patches.
> 
> On 21/11/2026 23:55, Przemek Kitszel wrote:
>> Also available here
>> https://github.com/pkitszel/linux/tree/xlvf-v7
>> (no mlx changes, just kept series name)
>>
>> The purpose of this series is to allow iavf to use more than 16 queue
>> pairs, in two modes: up to 64 and up to 256 queue pairs.
>>
>> In order to support more queues for VF, we must give it a bigger RSS
>> table (GLOBAL LUT or PF LUT). There are 16 GLOBAL LUTs on E810, and one
>> PF LUT for every PF on given card. Both kinds could be (re)assigned to
>> a VF, while a PF must hold at least one of them at any given moment.
>> GLOBAL LUT allows VF to use up to 64 queues, PF LUT lets it use up to
>> 256 queues.
>>
>> RSS LUTs are exposed to the user for assignment via devlink resources
>> API, which I have extended to make it possible.
> Recently, many HW selftests have started to fail, mainly on ICE and with
> tools/testing/selftests/drivers/net/hw/rss_api.py, but also on CX7:
> 
>   https://netdev.bots.linux.dev/branch_deltas/net-next-hw-2026-11-22--08-00.html
> 
> I wonder if it couldn't be due to your series. Do you mind having a
> look, please?
> 
> Note that because of this series, the following WIP patch is no longer
> applied, and maybe that's why some tests are starting to fail:
> 
>   https://github.com/linux-netdev/testing/commit/d00ba0185d53

We have the very same fix enqueued for a long time, apologies for not
speeding this up:
https://lore.kernel.org/intel-wired-lan/20261007200311.730443-1-maciej.fijalkowski@intel.com

I've checked that my code git-conflicts with the commit you provided,
albeit trivial (`patch -p1 < ~/d00ba0185d53.patch` works fine with
regular heuristics).

> 
> I suggest dropping this series from the tests for the moment:
> 
> pw-bot: cr

Overall I would prefer to merge as much as possible from this series
and (then) the adjusted little fix patch

> 
> Let's see if net-next-hw-2026-11-23--16-00 will still have these issues.
> 
> (Feel free to also look at the other flaky ones on Intel NICs, see my
> other email thread)

will do, thank you for reaching out

> 
>   https://netdev.bots.linux.dev/contest.html?pass=0&branch=net-next-hw-2026-11-22--08-00&pw-y=0
>   https://lore.kernel.org/5aec31d5-d042-4263-b3df-fa5a6a1399ec@kernel.org
> 
> Cheers,
> Matt


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH net-next v7 01/15] iavf: keep RSS config across resets
  2026-11-21 22:55 ` [PATCH net-next v7 01/15] iavf: keep RSS config across resets Przemek Kitszel
@ 2026-11-24 21:57   ` netdev-bot+sashiko
  0 siblings, 0 replies; 28+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 21:57 UTC (permalink / raw)
  To: przemyslaw.kitszel
  Cc: netdev, kuba, jiri, anthony.l.nguyen, aleksandr.loktionov,
	mschmidt, edumazet, horms, pabeni, davem, corbet, skhan, rdunlap,
	andrew+netdev, saeedm, tariqt, leon, mbloch, jacob.e.keller,
	jedrzej.jagielski, anzaki, brett.creeley, ohartoov, poros,
	donald.hunter

Thank you for your contribution! Sashiko AI review found 6 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 4 · Low: 2

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The aq_wait_count fix is incomplete.
- [Medium] When the RSS buffer reallocation in
  iavf_parse_vf_resource_msg() fails, the RSS buffers and…
- [Medium] While init retries with the netdev registered, adapter->vf_res
  is zeroed.
- [Medium] iavf: premature ethtool_rxfh_indir_lost() broadcasts zeroed
  LUT on reinit
- [Low] This commit fixes several pre-existing bugs without a Fixes: tag,
  and bundles them with a new feature, so the fixes cannot be backported…
- [Low] The new iavf_init_rss() call in the size-change branch of
  iavf_parse_vf_resource_msg() (iavf_main.c:2600) skips the RSS_AQ…

--

iavf: keep RSS config across resets

This commit keeps the user-set RSS key and LUT across VF resets. When the
PF reports a different key or LUT size, it reallocates both and folds the
LUT, and it reinits the queues when the PF cuts the queue count. It also
fixes the RSS buffer leak on reinit after iavf_disable_vf(), keeps vf_res
allocated on a failed resources message, checks what
iavf_parse_vf_resource_msg() returns, and resets aq_wait_count.

> Most of these issues are old and affect every PF, but are rarely hit.
> The rest of this series makes them common: the VF is reset on each
> change of its RSS LUT via devlink, and on init, after iavf asks the PF
> for more queues and waits for them in __IAVF_INIT_FAILED. Hence fix
> them first.

[Severity: Low]
This isn't a bug, but could the standalone fixes be split into their own
patches, each with a Fixes: tag? As far as I can tell, this commit fixes
several old bugs:

- the rss_key/rss_lut leak when iavf_init_config_adapter() allocates them
  again on reinit after iavf_disable_vf()

- the NULL adapter->vf_res left by the err_alloc path of
  iavf_init_get_resources() while the netdev stays registered; ethtool ops
  dereference it through RSS_PF(), ADV_RSS_SUPPORT() and
  LARGE_NUM_QPAIRS_SUPPORT()

- aq_wait_count never being reset

- the ignored return value of iavf_parse_vf_resource_msg() in
  iavf_virtchnl_completion()

They are bundled with the new RSS preservation feature
(IAVF_FLAG_RSS_LUT_LOST, the LUT resize, the reset on a queue cut) and
have no Fixes: tags. Stable kernels would not pick up the leak and NULL
dereference fixes this way.

> diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
> index 4de3ea8525b3f..c7b12de63c2f5 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_main.c
> +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c

[ ... ]

> @@ -2494,11 +2562,45 @@ int iavf_parse_vf_resource_msg(struct iavf_adapter *adapter)
>  	vsi->netdev = adapter->netdev;
>  	vsi->qs_handle = adapter->vsi_res->qset_handle;
>  	if (adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RSS_PF) {
> -		adapter->rss_key_size = adapter->vf_res->rss_key_size;
> -		adapter->rss_lut_size = adapter->vf_res->rss_lut_size;
> +		key_size = adapter->vf_res->rss_key_size;
> +		lut_size = adapter->vf_res->rss_lut_size;
> +	} else {
> +		key_size = IAVF_HKEY_ARRAY_SIZE;
> +		lut_size = IAVF_HLUT_ARRAY_SIZE;
> +	}
> +
> +	if ((adapter->rss_key && adapter->rss_key_size != key_size) ||
> +	    (adapter->rss_lut && adapter->rss_lut_size != lut_size)) {
> +		u8 *rss_key, *rss_lut;
> +
> +		rss_key = kzalloc(key_size, GFP_KERNEL);
> +		rss_lut = kzalloc(lut_size, GFP_KERNEL);
> +		if (!rss_lut || !rss_key ||
> +		    iavf_rss_lut_resize(adapter, rss_lut, lut_size)) {
> +			kfree(rss_key);
> +			kfree(rss_lut);
> +			/* old buffers and sizes are kept, retry via reset */
> +			iavf_schedule_reset(adapter, IAVF_FLAG_RESET_NEEDED);
> +			return -ENOMEM;
> +		}

[Severity: Medium]
Can this failure path leave the RSS sizes out of step with the
capabilities in adapter->vf_res?

When this runs, iavf_virtchnl_completion() has already copied the new
reply into adapter->vf_res. RSS_PF(), RSS_AQ() and RSS_REG() therefore
follow the new vf_cap_flags, but rss_key_size and rss_lut_size keep their
old PF-reported values.

Suppose the old negotiation had RSS_PF with a LUT larger than 64 bytes
(512 or 2048, which ice gives VFs later in this series) and the new reply
drops RSS_PF. Until reset_task runs, an ethtool -X would go:

iavf_set_rxfh()
  iavf_config_rss()
    iavf_config_rss_reg()

which does:

	dw = (u32 *)adapter->rss_lut;
	for (i = 0; i < adapter->rss_lut_size / 4; i++)
		wr32(hw, IAVF_VFQF_HLUT(i), dw[i]);

IAVF_VFQF_HLUT() only has indexes 0..IAVF_VFQF_HLUT_MAX_INDEX (15).
Would the 128 or 512 writes land past 0xD03C, in other VF BAR registers?

With RSS_AQ, iavf_config_rss_aq() casts rss_key to a fixed-size
struct iavf_aqc_get_set_rss_key_data. Could that read past the end of the
old key buffer if the old key was shorter?

This needs a small GFP_KERNEL allocation to fail, so it is unlikely to
trigger.

> +
> +		if (adapter->rss_key_size == key_size)
> +			memcpy(rss_key, adapter->rss_key, key_size);
> +		else
> +			netdev_rss_key_fill(rss_key, key_size);
> +

[ ... ]

> +		adapter->rss_lut_size = lut_size;
> +		/* no queues yet on init, iavf_init_config_adapter() sets RSS */
> +		if (adapter->state != __IAVF_INIT_GET_RESOURCES)
> +			iavf_init_rss(adapter);

[Severity: Medium]
Can this notification go out before the new LUT has any content?

On reinit after iavf_disable_vf() the netdev stays registered, and the
RSS buffers are now kept. So iavf_parse_vf_resource_msg() can run from
iavf_init_get_resources() with adapter->state set to
__IAVF_INIT_GET_RESOURCES and an old rss_lut_size. Suppose the PF
reports a different LUT size and ethtool_rxfh_indir_can_resize()
returns false. Then iavf_rss_lut_resize() leaves the kzalloc()ed
rss_lut all zeros and calls iavf_rss_lut_lost(), which queues
finish_config right away.

iavf_parse_vf_resource_msg() then installs the zeroed buffer as
adapter->rss_lut. It skips iavf_init_rss() because there are no queues
yet. The LUT is only filled later, by iavf_init_config_adapter(), and
that is several watchdog steps away: __IAVF_INIT_EXTENDED_CAPS comes
first, and the watchdog runs as delayed work.

iavf_finish_config() only needs rtnl and the netdev lock, so it can run
in that window. It clears IAVF_FLAG_RSS_LUT_LOST and calls
ethtool_rxfh_indir_lost(). As far as I can tell, that sends an RSS
notification which reads the table back through iavf_get_rxfh(). If so,
userspace is told that every entry of the new table points at queue 0.
When iavf_init_config_adapter() later programs the default spread,
nothing sends a second notification, so the reported table stays
wrong.

Outside init this does not happen, because iavf_init_rss() fills the
new buffer right after the swap, in the same call.

Would it be enough to only set IAVF_FLAG_RSS_LUT_LOST while in
__IAVF_INIT_GET_RESOURCES? The iavf_schedule_finish_config() call at
the end of iavf_init_config_adapter() could then report the loss once
the default LUT is in place.

[Severity: Low]
Should this call handle RSS_AQ the way the other callers do? Both
iavf_init_config_adapter() and iavf_reset_step() defer it:

	if (RSS_AQ(adapter)) {
		adapter->aq_required |= IAVF_FLAG_AQ_CONFIGURE_RSS;
	} else {
		err = iavf_init_rss(adapter);
		if (err)
			goto reset_err;
	}

Outside init, this code runs from the VIRTCHNL_OP_GET_VF_RESOURCES case
of iavf_virtchnl_completion(), where current_op is still
VIRTCHNL_OP_GET_VF_RESOURCES.

The commit message names a PF that stops offering RSS_PF as one of the
cases this patch handles. If such a PF grants RSS_AQ instead,
iavf_init_rss()->iavf_config_rss()->iavf_config_rss_aq() will always hit:

	if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
		/* bail because we already have a command pending */
		dev_err(&adapter->pdev->dev, "Cannot configure RSS, command %d pending\n",
			adapter->current_op);
		return -EBUSY;
	}

The -EBUSY is ignored here, while iavf_reset_step() treats an
iavf_init_rss() error as reset_err.

The deferred IAVF_FLAG_AQ_CONFIGURE_RSS handler in
iavf_process_aq_command() only clears the flag, so the end result matches
the other call sites. What this call adds is an error log that always
fires and a failure that is silently dropped.

[ ... ]

> @@ -2563,8 +2665,8 @@ static void iavf_init_get_resources(struct iavf_adapter *adapter)
>  	return;
>  
>  err_alloc:
> -	kfree(adapter->vf_res);
> -	adapter->vf_res = NULL;
> +	/* keep it allocated, ethtool ops may run on reinit */
> +	memset(adapter->vf_res, 0, IAVF_VIRTCHNL_VF_RESOURCE_SIZE);

[Severity: Medium]
With vf_res zeroed while the netdev is registered, RSS_PF() and RSS_AQ()
both return false. iavf_set_rxfh() has no adapter->state check, so can it
end up writing the RSS registers directly?

iavf_set_rxfh()
  iavf_config_rss()
    iavf_config_rss_reg()

iavf_config_rss_reg() writes rss_key_size/4 dwords to IAVF_VFQF_HKEY(i)
and rss_lut_size/4 dwords to IAVF_VFQF_HLUT(i). The RSS buffers and sizes
are now kept across reinit, so these are the PF-negotiated sizes from the
last successful init.

The HLUT register file has 16 entries (IAVF_VFQF_HLUT_MAX_INDEX is 15).
Later in this series ice gives VFs 512 or 2048 entry LUTs under RSS_PF.
Would that mean 128 or 512 writes, reaching 0xD7FC?

Even when the sizes are in range, this writes RSS registers directly on a
VF whose RSS is managed by the PF, and ethtool is told it succeeded.

iavf_disable_vf() already zeroed vf_res like this before this patch. This
change adds a second such window and keeps the large sizes alive across
both.

>  err:
>  	iavf_change_state(adapter, __IAVF_INIT_FAILED);
>  }

[ ... ]

> @@ -2967,6 +3073,7 @@ static int iavf_watchdog_step(struct iavf_adapter *adapter)
>  			 */
>  			iavf_change_state(adapter, __IAVF_STARTUP);
>  			adapter->flags &= ~IAVF_FLAG_PF_COMMS_FAILED;
> +			adapter->aq_wait_count = 0;
>  		}

[Severity: Medium]
Does this fully fix what the commit message describes?

  "It was never reset, so once it reached IAVF_AQ_MAX_ERR, the first wait
  for a PF reply sent init back to __IAVF_COMM_FAILED."

The new reset only runs in the __IAVF_COMM_FAILED recovery branch, which
is after the limit has already been hit. The only other place that
touches the counter is the __IAVF_INIT_FAILED case:

	if (++adapter->aq_wait_count > IAVF_AQ_MAX_ERR) {

Nothing resets it when init makes progress or completes. Nothing resets
it when iavf_reset_step() restarts init either:

	if (adapter->state <= __IAVF_INIT_FAILED) {
		iavf_shutdown_adminq(hw);
		iavf_change_state(adapter, __IAVF_STARTUP);
		iavf_startup(adapter);
		...

So the counter still adds up every __IAVF_INIT_FAILED visit, not just
consecutive failures, and several ordinary waits end up there:

- each extended caps RECV step polls the ARQ without blocking, shortly
  after its SEND

- GET_RESOURCES and VERSION_CHECK polls that run before the PF reply
  arrives

- later in this series, init also waits there for the reset that grants
  the queue request

Once the total passes IAVF_AQ_MAX_ERR (20), won't init still set
IAVF_FLAG_PF_COMMS_FAILED, shut down the admin queue and restart from
__IAVF_STARTUP, even though the PF answered every request?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261121230123.316391-1-przemyslaw.kitszel%40intel.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH net-next v7 02/15] ice: prepare RSS LUT config for runtime LUT changes
  2026-11-21 22:55 ` [PATCH net-next v7 02/15] ice: prepare RSS LUT config for runtime LUT changes Przemek Kitszel
@ 2026-11-24 21:57   ` netdev-bot+sashiko
  0 siblings, 0 replies; 28+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 21:57 UTC (permalink / raw)
  To: przemyslaw.kitszel
  Cc: netdev, kuba, jiri, anthony.l.nguyen, aleksandr.loktionov,
	mschmidt, edumazet, horms, pabeni, davem, corbet, skhan, rdunlap,
	andrew+netdev, saeedm, tariqt, leon, mbloch, jacob.e.keller,
	jedrzej.jagielski, anzaki, brett.creeley, ohartoov, poros,
	donald.hunter

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The ice_cfg_rdma_fltr() change
  (drivers/net/ethernet/intel/ice/ice_switch.c) fixes a user-visible…
- [Low] The commit message says pf->rss_lut_lock protects "q_opt_rss of
  the VSI context" and is taken "around VSI context writes that include…
- [Low] The patch adds scoped_guard() (a scope-based cleanup helper) to
  functions that also use goto-based cleanup labels.

--

ice: prepare RSS LUT config for runtime LUT changes

This commit adds pf->rss_lut_lock to protect the RSS LUT config of a VSI.
It now sets the default LUT type and size only on VSI init, and it caps the
RSS queue count to what the LUT type can address. It also changes
ice_cfg_rdma_fltr() to take the Q_OPT section from vsi->info instead of the
cached VSI context.

> diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h
> index 432da05c48c08..f614b9360f7bd 100644
> --- a/drivers/net/ethernet/intel/ice/ice.h
> +++ b/drivers/net/ethernet/intel/ice/ice.h
> @@ -595,6 +595,7 @@ struct ice_pf {
>  	struct mutex tc_mutex;		/* lock to protect TC changes */
>  	struct mutex adev_mutex;	/* lock to protect aux device access */
>  	struct mutex lag_mutex;		/* protect ice_lag struct in PF */
> +	struct mutex rss_lut_lock;	/* protect VSI RSS LUT config */

[Severity: Low]
The commit message says this lock protects "q_opt_rss of the VSI context"
and is taken "around VSI context writes that include q_opt_rss". Do the VF
virtchnl paths follow that contract?

In drivers/net/ethernet/intel/ice/virt/rss.c, these callers don't take
rss_lut_lock, either at this commit or at the end of the series:

ice_vc_rss_hash_update()
    read-modify-write of vsi->info.q_opt_rss, then a Q_OPT VSI update

ice_vc_config_rss_hfunc()
    ice_set_rss_hfunc(vsi, hfunc)

ice_vc_config_rss_lut()
    ice_set_rss_lut(vsi, vrl->lut, ICE_LUT_VSI_SIZE)
        reads vsi->rss_lut_type and vsi->global_lut_id

ice_set_rxfh() now calls the same ice_set_rss_hfunc() helper under
scoped_guard(mutex, &pf->rss_lut_lock), so the ethtool and virtchnl paths
don't match.

Today vf->cfg_lock, taken in ice_vc_process_vf_msg(), serializes these VF
handlers. The later devlink VF LUT change also takes vf->cfg_lock, so I
couldn't find a concrete race.

Should the virtchnl paths take rss_lut_lock too? Or should the commit
message and the lock comment be narrowed to what the lock actually covers?

Later in the series, vsi->rss_table_size replaces the hard-coded
ICE_LUT_VSI_SIZE in ice_vc_config_rss_lut().

> diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c
> index dffa213734f10..6d1e506b69cd8 100644
> --- a/drivers/net/ethernet/intel/ice/ice_ethtool.c
> +++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c
> @@ -3645,11 +3645,13 @@ ice_get_rxfh(struct net_device *netdev, struct ethtool_rxfh_param *rxfh)
>  	if (!rxfh->indir)
>  		return 0;
>  
> -	lut = kzalloc(vsi->rss_table_size, GFP_KERNEL);
> -	if (!lut)
> -		return -ENOMEM;
> +	scoped_guard(mutex, &pf->rss_lut_lock) {
> +		lut = kzalloc(vsi->rss_table_size, GFP_KERNEL);
> +		if (!lut)
> +			return -ENOMEM;
>  
> -	err = ice_get_rss(vsi, rxfh->key, lut, vsi->rss_table_size);
> +		err = ice_get_rss(vsi, rxfh->key, lut, vsi->rss_table_size);
> +	}
>  	if (err)
>  		goto out;

[Severity: Low]
This isn't a bug, but this function now uses both scoped_guard() and
goto-based cleanup. include/linux/cleanup.h says:

    the expectation is that usage of "goto" and cleanup helpers is never
    mixed in the same function.

Here lut is allocated inside the guard, which has an early return. It is
then freed by hand through goto out after the guard ends.

The same mix appears in:

ice_vsi_cfg_rss_lut_key()  - lut freed at goto ice_vsi_cfg_rss_exit
ice_vsi_cfg_def()          - scoped_guard() followed by goto unroll_get_qs
ice_set_channels()         - scoped_guard() next to goto adev_unlock

ice_vsi_set_dflt_rss_lut() and ice_vsi_manage_rss_lut() also kzalloc() lut
inside the guard and kfree() it outside.

No current path leaks, because lut is NULL on the early return. The pattern
is still there at the end of the series.

Could these functions use plain mutex_lock()/mutex_unlock()? Or could lut
become __free(kfree) and the goto labels be dropped?

[ ... ]

> diff --git a/drivers/net/ethernet/intel/ice/ice_switch.c b/drivers/net/ethernet/intel/ice/ice_switch.c
> index d873eda9af826..70eed3bcc404b 100644
> --- a/drivers/net/ethernet/intel/ice/ice_switch.c
> +++ b/drivers/net/ethernet/intel/ice/ice_switch.c

[ ... ]

> @@ -1850,9 +1852,10 @@ ice_cfg_rdma_fltr(struct ice_hw *hw, u16 vsi_handle, bool enable)
>  	if (!ctx)
>  		return -ENOMEM;
>  
> -	ctx->info.q_opt_rss = cached_ctx->info.q_opt_rss;
> -	ctx->info.q_opt_tc = cached_ctx->info.q_opt_tc;
> -	ctx->info.q_opt_flags = cached_ctx->info.q_opt_flags;
> +	/* not from the cached ctx, that misses later RSS changes */
> +	ctx->info.q_opt_rss = info->q_opt_rss;
> +	ctx->info.q_opt_tc = info->q_opt_tc;
> +	ctx->info.q_opt_flags = info->q_opt_flags;

[Severity: Low]
This change fixes a user-visible bug, which the commit message admits
("which the toggle reverted"). Could it be split out as a standalone fix
for net with a Fixes: tag?

ice_set_rss_hfunc() and the NO_INIT path of ice_vsi_init() both go through
ice_update_vsi(). That function only sends the AQ command and doesn't
refresh hw->vsi_ctx[].

Before this patch, an irdma probe or remove then did:

ice_rdma_update_vsi_filter()
    ice_cfg_rdma_fltr()
        ctx->info.q_opt_rss = cached_ctx->info.q_opt_rss;  (stale hash bits)
        ice_update_vsi()

So hardware silently went back to plain Toeplitz after a symmetric-xor hash
was set with ethtool -X. Meanwhile vsi->rss_hfunc and ethtool still
reported symmetric-xor.

As submitted, the fix depends on the new pf->rss_lut_lock and the changed
ice_cfg_rdma_fltr() signature, so stable trees can't pick it up. A
standalone version could carry:

Fixes: 352e9bf23813 ("ice: enable symmetric-xor RSS for Toeplitz hash function")

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261121230123.316391-1-przemyslaw.kitszel%40intel.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH net-next v7 04/15] ice: add helpers for Global RSS LUT alloc, free, vsi_update
  2026-11-21 22:55 ` [PATCH net-next v7 04/15] ice: add helpers for Global RSS LUT alloc, free, vsi_update Przemek Kitszel
@ 2026-11-24 21:57   ` netdev-bot+sashiko
  0 siblings, 0 replies; 28+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 21:57 UTC (permalink / raw)
  To: przemyslaw.kitszel
  Cc: netdev, kuba, jiri, anthony.l.nguyen, aleksandr.loktionov,
	mschmidt, edumazet, horms, pabeni, davem, corbet, skhan, rdunlap,
	andrew+netdev, saeedm, tariqt, leon, mbloch, jacob.e.keller,
	jedrzej.jagielski, anzaki, brett.creeley, ohartoov, poros,
	donald.hunter

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] This is fixed later in the series.

--

ice: add helpers for Global RSS LUT alloc, free, vsi_update

This commit adds AQ helpers to allocate and free a Global RSS LUT. It also
teaches ice_set_rss_vsi_ctx() to encode the RSS LUT type, and the global
LUT ID when the type is ICE_LUT_GLOBAL, into the VSI context q_opt_rss.

> diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
> index bd59c0a122158..517d87aadfad9 100644
> --- a/drivers/net/ethernet/intel/ice/ice_lib.c
> +++ b/drivers/net/ethernet/intel/ice/ice_lib.c

[ ... ]

> @@ -1316,8 +1332,12 @@ static void ice_set_rss_vsi_ctx(struct ice_vsi_ctx *ctxt, struct ice_vsi *vsi)
>  	hash_type = ICE_AQ_VSI_Q_OPT_RSS_HASH_TPLZ;
>  	vsi->rss_hfunc = hash_type;
>  
> +	if (vsi->rss_lut_type == ICE_LUT_GLOBAL)
> +		global_lut_id = vsi->global_lut_id;
> +
>  	ctxt->info.q_opt_rss =
>  		FIELD_PREP(ICE_AQ_VSI_Q_OPT_RSS_LUT_M, lut_type) |
> +		FIELD_PREP(ICE_AQ_VSI_Q_OPT_RSS_GBL_LUT_M, global_lut_id) |
>  		FIELD_PREP(ICE_AQ_VSI_Q_OPT_RSS_HASH_M, hash_type);
>  }

[Severity: Low]
With this change the VSI context binds the VSI to vsi->global_lut_id. At
this commit, though, ice_set_rss_lut() and ice_get_rss_lut() in
ice_main.c do not pass that ID down:

ice_set_rss_lut() {
    ...
	params.vsi_handle = vsi->idx;
	params.lut_size = lut_size;
	params.lut_type = vsi->rss_lut_type;
	params.lut = lut;
    ...
}

__ice_aq_get_set_rss_lut() takes the descriptor index from params:

	if (lut_type == ICE_LUT_GLOBAL)
		glob_lut_idx = FIELD_PREP(ICE_AQC_LUT_GLOBAL_IDX,
					  params->global_lut_id);

If a VSI were using a nonzero global LUT, would it end up bound to LUT N
while SET/GET_RSS_LUT read and write LUT 0?

As far as I can tell, this can't happen at any point in the series.
Nothing sets vsi->rss_lut_type to ICE_LUT_GLOBAL until "ice: represent
RSS LUTs as devlink resources". That commit also adds the following to
both ice_set_rss_lut() and ice_get_rss_lut():

	if (params.lut_type == ICE_LUT_GLOBAL)
		params.global_lut_id = vsi->global_lut_id;

So the final tree is consistent. Would it make sense to move that
params.global_lut_id assignment into this patch, so the VSI context and
the LUT AQ path pick up the global LUT ID in the same commit?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261121230123.316391-1-przemyslaw.kitszel%40intel.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH net-next v7 06/15] ice: bump to 256qs for VF
  2026-11-21 22:55 ` [PATCH net-next v7 06/15] ice: bump to 256qs for VF Przemek Kitszel
@ 2026-11-24 21:57   ` netdev-bot+sashiko
  0 siblings, 0 replies; 28+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 21:57 UTC (permalink / raw)
  To: przemyslaw.kitszel
  Cc: netdev, kuba, jiri, anthony.l.nguyen, aleksandr.loktionov,
	mschmidt, edumazet, horms, pabeni, davem, corbet, skhan, rdunlap,
	andrew+netdev, saeedm, tariqt, leon, mbloch, jacob.e.keller,
	jedrzej.jagielski, anzaki, brett.creeley, ohartoov, poros,
	donald.hunter

Thank you for your contribution! Sashiko AI review found 5 potential
issue(s) to consider.

Critical: 0 · High: 1 (2) · Medium: 4 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] The err_scatter rollback in __ice_vsi_get_qs_sc() clears the
  wrong bits when vsi_map_offset != 0: clear_bit(qs_cfg->vsi_map[index],…
- [Medium] This feature commit carries fixes for bugs that already exist,
  without Fixes: tags and without splitting them out.
- [Medium] The patch makes __ice_vsi_get_qs() fail whenever the
  contiguous search fails and q_count exceeds scatter_count (16).
- [Medium] The kernel-doc of the new helper ice_lag_cfg_lan_txq() defines
  '@numq: number of queues in @qbuf', i.e. the count that…
- [Medium] The new ice_lag_cfg_lan_txq() splits the queue move
  (ICE_AQC_Q_CFG_TC_CHNG) into several ice_aq_cfg_lan_txq() commands of…

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the patch
  resizes lag->q_home[][] to ICE_MAX_QS_PER_VF (256) and still never…
- [High] This problem wasn't introduced by this patch, but the patch
  edits these exact lines: ice_init_lag() frees struct ice_lag (now…

--

ice: bump to 256qs for VF

This commit resizes the VF bitmaps and arrays in ice for 256 queues per
VF. The legacy virtchnl opcodes keep the 16 queue limit. It also makes the
__ice_vsi_get_qs() scatter fallback fail instead of truncating, reworks
the ice_vc_cfg_qs_msg() rollback, sends LAG queue moves in commands of up
to U8_MAX queues each, and allocates struct ice_lag with kvzalloc_obj().

> Disable only the queue pairs that passed validation when
> ice_vc_cfg_qs_msg() fails, by their queue IDs instead of their index in
> the message, as the queue config can now come in many messages.

[Severity: Medium]
Do some of these changes fix bugs that exist before this series?

The old scatter clamp in __ice_vsi_get_qs() already breaks the ring
mapping for VFs. ice_sriov_set_msix_vec_count() sets
vf->num_vf_qs = queues with no 16 queue cap, so a VF can have more than 16
queues today.

Before this patch, a __ice_vsi_get_qs() failure in ice_prepare_xdp_rings()
jumped to err_map_xdp and ran:

	clear_bit(vsi->txq_map[i + vsi->alloc_txq], pf->avail_txqs);

Those txq_map slots hold 0 (freshly allocated, or zeroed by the scatter
unwind), or ICE_INVAL_Q_INDEX after an earlier XDP teardown. Doesn't that
free PF queue 0, which the main VSI still uses, or clear bit 0xffff past
the end of avail_txqs?

The old ice_vc_cfg_qs_msg() rollback disabled queues 0..i by message
index. A single message can already carry qpair[] entries whose queue_id
differs from their index. The commit message gives the reason as "the
queue config can now come in many messages".

Could these be split out with Fixes: tags so stable kernels pick them up?

> diff --git a/drivers/net/ethernet/intel/ice/ice_base.c b/drivers/net/ethernet/intel/ice/ice_base.c
> index 1667f686ff751..f65634e3d44ef 100644
> --- a/drivers/net/ethernet/intel/ice/ice_base.c
> +++ b/drivers/net/ethernet/intel/ice/ice_base.c

[ ... ]

> @@ -817,11 +817,9 @@ int __ice_vsi_get_qs(struct ice_qs_cfg *qs_cfg)
>  	int ret = 0;
>  
>  	ret = __ice_vsi_get_qs_contig(qs_cfg);
> -	if (ret) {
> +	if (ret && qs_cfg->q_count <= qs_cfg->scatter_count) {
>  		/* contig failed, so try with scatter approach */
>  		qs_cfg->mapping_mode = ICE_VSI_MAP_SCATTER;
> -		qs_cfg->q_count = min_t(unsigned int, qs_cfg->q_count,
> -					qs_cfg->scatter_count);
>  		ret = __ice_vsi_get_qs_sc(qs_cfg);
>  	}
>  	return ret;

[Severity: Medium]
With this change, __ice_vsi_get_qs() fails whenever no contiguous range is
free and q_count is above scatter_count. Can ordinary fragmentation now
trigger a Tx queue leak in ice_vsi_get_qs()?

ice_vsi_get_qs() takes the Tx queues first and then the Rx queues:

ice_vsi_get_qs() {
    ...
	ret = __ice_vsi_get_qs(&rx_qs_cfg);
	if (ret)
		return ret;
    ...
}

This return does not release the Tx bits just set in pf->avail_txqs.

ice_vsi_cfg_def() then does goto unroll_vsi_alloc_stat, which skips
unroll_get_qs and ice_vsi_put_qs(). ice_vsi_free_arrays() then frees
txq_map, so nothing can find those Tx bits again.

Before this patch, this Rx failure needed fewer than min(alloc_rxq, 16)
free Rx queues in total. Now any VSI with more than 16 Rx queues can hit
it when the Rx bitmap has no contiguous range. Examples are asymmetric
ethtool -L changes, sriov_vf_msix_count writes or SF churn.

> diff --git a/drivers/net/ethernet/intel/ice/ice_lag.c b/drivers/net/ethernet/intel/ice/ice_lag.c
> index 08a17ded0ad55..4bb28564c0d65 100644
> --- a/drivers/net/ethernet/intel/ice/ice_lag.c
> +++ b/drivers/net/ethernet/intel/ice/ice_lag.c
> @@ -549,6 +549,41 @@ ice_lag_qbuf_recfg(struct ice_hw *hw, struct ice_aqc_cfg_txqs_buf *qbuf,
>  	return count;
>  }
>  
> +/**
> + * ice_lag_cfg_lan_txq - reconfigure queues for a new port
> + * @hw: HW struct to send the command on
> + * @qbuf: buffer filled by ice_lag_qbuf_recfg(), gets modified
> + * @numq: number of queues in @qbuf
> + * @oldport: lport of the current queues location
> + * @newport: lport of the destination queues location
> + *
> + * One command takes up to U8_MAX queues, a VF could have more.
> + *
> + * Return: 0 on success, negative on failure.
> + */
> +static int
> +ice_lag_cfg_lan_txq(struct ice_hw *hw, struct ice_aqc_cfg_txqs_buf *qbuf,
> +		    u16 numq, u8 oldport, u8 newport)
> +{
> +	while (numq) {
> +		int num = min(numq, U8_MAX);
> +		int err;
> +
> +		err = ice_aq_cfg_lan_txq(hw, qbuf,
> +					 struct_size(qbuf, queue_info, num),
> +					 num, oldport, newport,
> +					 ICE_AQC_Q_CFG_TC_CHNG, NULL);
> +		if (err)
> +			return err;

[Severity: Medium]
If a later ice_aq_cfg_lan_txq() command fails here, the queues moved by
earlier commands stay on newport. Does anything handle that partial move?

All three callers treat any error as meaning nothing moved:

- ice_lag_move_vf_node_tc() goes to qbuf_err.
- ice_lag_reclaim_vf_tc() goes to reclaim_qerr.
- ice_lag_move_vf_nodes_tc_sync() goes to sync_qerr.

Each then skips ice_aq_move_sched_elems() for the VSI node and resumes
traffic.

That would leave some of the VF's queues for that TC on the destination
port. The rest, and the VSI scheduler node, stay on the source port, and
the driver does not record the split. This needs more than 255 queues in
one TC, which 256 queue VFs now allow.

[ ... ]

> @@ -689,8 +724,7 @@ ice_lag_move_vf_node_tc(struct ice_lag *lag, u8 oldport, u8 newport,
>  		goto qbuf_none;
>  	}
>  
> -	if (ice_aq_cfg_lan_txq(&lag->pf->hw, qbuf, qbuf_size, valq, oldport,
> -			       newport, ICE_AQC_Q_CFG_TC_CHNG, NULL)) {
> +	if (ice_lag_cfg_lan_txq(&lag->pf->hw, qbuf, valq, oldport, newport)) {
>  		dev_warn(dev, "Failure to configure queues for LAG failover\n");
>  		goto qbuf_err;
>  	}
> @@ -1277,9 +1311,8 @@ ice_lag_reclaim_vf_tc(struct ice_lag *lag, struct ice_hw *src_hw, u16 vsi_num,
>  		goto reclaim_none;
>  	}
>  
> -	if (ice_aq_cfg_lan_txq(hw, qbuf, qbuf_size, numq,
> -			       src_hw->port_info->lport, hw->port_info->lport,
> -			       ICE_AQC_Q_CFG_TC_CHNG, NULL)) {
> +	if (ice_lag_cfg_lan_txq(hw, qbuf, numq, src_hw->port_info->lport,
> +				hw->port_info->lport)) {

[Severity: Medium]
Should this pass valq rather than numq?

The kernel-doc of ice_lag_cfg_lan_txq() says "@numq: number of queues in
@qbuf", and ice_lag_move_vf_node_tc() above passes valq.

Here numq is ctx->num_lan_q_entries[tc]. ice_lag_qbuf_recfg() skips queues
with no q_ctx, ICE_INVAL_TEID or ICE_INVAL_Q_HANDLE, and fills only valq
entries.

When a VF has configured fewer Tx queues than it was allocated, entries
[valq, numq) of the kzalloc'ed qbuf (q_handle 0, q_teid 0) are sent to
firmware. With the chunking, those entries can also land in a later
command after earlier commands have already moved real queues.

The new ice_lag_cfg_lan_txq() call in ice_lag_move_vf_nodes_tc_sync() also
passes numq.

>  		dev_warn(dev, "Failure to configure queues for LAG failover\n");
>  		goto reclaim_qerr;
>  	}

[ ... ]

> @@ -2651,7 +2683,7 @@ int ice_init_lag(struct ice_pf *pf)
>  	ice_free_hw_res(&pf->hw, ICE_AQC_RES_TYPE_RECIPE, 1,
>  			&lag->pf_recipe);
>  lag_error:
> -	kfree(lag);
> +	kvfree(lag);
>  	pf->lag = NULL;
>  	return err;
>  }

[Severity: High]
This is a pre-existing issue, but since these lines are being changed: can
this free lag while &lag->notif_block is still registered?

ice_init_lag() calls ice_register_lag_handler(lag), which registers
lag->notif_block with register_netdevice_notifier(). That happens before
the ice_create_lag_recipe() calls.

If one of those calls fails, the path through free_lport_res and
free_rcp_res to lag_error does kvfree(lag) and sets pf->lag = NULL. It
never calls ice_unregister_lag_handler().

ice_init_features() only warns, so the probe continues. ice_deinit_lag()
later returns early because pf->lag is NULL.

The netdev notifier chain then keeps a notifier_block that lives in freed
memory. On bonding events, ice_lag_event_handler() gets the freed lag
back through container_of().

The changelog says this will be fixed separately.

> diff --git a/drivers/net/ethernet/intel/ice/ice_lag.h b/drivers/net/ethernet/intel/ice/ice_lag.h
> index 4bfffecbdc975..39f6a6cc844d8 100644
> --- a/drivers/net/ethernet/intel/ice/ice_lag.h
> +++ b/drivers/net/ethernet/intel/ice/ice_lag.h
> @@ -52,7 +52,7 @@ struct ice_lag {
>  	u8 bond_lport_sec; /* lport values for secondary PF */
>  
>  	/* q_home keeps track of which interface the q is currently on */
> -	u8 q_home[ICE_MAX_SRIOV_VFS][ICE_MAX_QS_PER_VF_VCV1];
> +	u8 q_home[ICE_MAX_SRIOV_VFS][ICE_MAX_QS_PER_VF];

[Severity: High]
This isn't a bug introduced by this patch, but the code still does not
check a VF's queue count against the size of q_home[][]. Can a VF with
more than 256 Tx queues overflow q_home[vf_id][]?

ice_sriov_set_msix_vec_count() (sriov_vf_msix_count in sysfs) sets
vf->num_vf_qs = queues. The only limits are min(avail_txq, avail_rxq) and
ICE_MIN_INTR_PER_VF. ice_vsi_get_num_qs() then sets alloc_txq to
num_req_qs ?: num_vf_qs, also with no cap.

ice_lag_aa_move_vf_qs() loops over num_q = num_lan_q_entries[0], and both
reads and writes lag->q_home[vf_id][i]:

ice_lag_aa_move_vf_qs() {
    ...
	for (int i = 0; i < num_q; i++) {
    ...
		lag->q_home[vf_id][i] = dest;
    ...
}

With i >= ICE_MAX_QS_PER_VF, this writes into the next VF's row. For the
last vf_id values it writes past the array into lag->sec_vf[], and those
VSI pointers are dereferenced later.

The later commit "ice: support up to 256 VF queues" adds only a contiguity
check (ice_vf_max_contig_qs()) in ice_sriov_set_msix_vec_count(), not a
256 queue cap. So this looks like it remains at the end of the series.

>  
>  	/* placeholder VSI for hanging VF queues from on secondary interface */
>  	struct ice_vsi *sec_vf[ICE_MAX_SRIOV_VFS];

[ ... ]

> diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
> index 0bc53f404957f..3e8cf1c5f0e81 100644
> --- a/drivers/net/ethernet/intel/ice/ice_main.c
> +++ b/drivers/net/ethernet/intel/ice/ice_main.c
> @@ -2758,7 +2758,6 @@ int ice_prepare_xdp_rings(struct ice_vsi *vsi, struct bpf_prog *prog,
>  			vsi->xdp_rings[i] = NULL;
>  		}
>  
> -err_map_xdp:
>  	mutex_lock(&pf->avail_q_mutex);
>  	ice_for_each_xdp_txq(vsi, i) {
>  		clear_bit(vsi->txq_map[i + vsi->alloc_txq], pf->avail_txqs);
> @@ -2766,6 +2765,7 @@ int ice_prepare_xdp_rings(struct ice_vsi *vsi, struct bpf_prog *prog,
>  	}
>  	mutex_unlock(&pf->avail_q_mutex);
>  
> +err_map_xdp:
>  	devm_kfree(dev, vsi->xdp_rings);
>  	vsi->xdp_rings = NULL;
>  

[Severity: High]
With the label moved, a failed __ice_vsi_get_qs() leaves all bitmap
cleanup to the helper. Does the err_scatter rollback in
__ice_vsi_get_qs_sc() work when vsi_map_offset is not 0?

__ice_vsi_get_qs_sc() {
    ...
err_scatter:
	for (index = 0; index < i; index++) {
		clear_bit(qs_cfg->vsi_map[index], qs_cfg->pf_map);
		qs_cfg->vsi_map[index + qs_cfg->vsi_map_offset] = 0;
	}
    ...
}

The slots it filled are vsi_map[index + vsi_map_offset], but the bits it
clears come from vsi_map[index].

ice_prepare_xdp_rings() passes .vsi_map = vsi->txq_map and
.vsi_map_offset = vsi->alloc_txq. A scatter allocation that fails part-way
would therefore:

- mark the VSI's live LAN Tx queues (txq_map[0..i-1]) as free in
  pf->avail_txqs
- leak the XDP bits it just set

The scatter path can still run for num_xdp_txq <= 16 when the contiguous
search fails. It can fail part-way if a concurrent allocation takes Tx
queues between ice_vsi_determine_xdp_res() and ice_prepare_xdp_rings().
Examples are a VF reset or a sriov_vf_msix_count write, which do not hold
rtnl.

A later VSI allocation could then get a hardware Tx queue that the PF VSI
is still using.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261121230123.316391-1-przemyslaw.kitszel%40intel.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH net-next v7 09/15] iavf: increase max number of queues to 256
  2026-11-21 22:55 ` [PATCH net-next v7 09/15] iavf: increase max number of queues to 256 Przemek Kitszel
@ 2026-11-24 21:57   ` netdev-bot+sashiko
  0 siblings, 0 replies; 28+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 21:57 UTC (permalink / raw)
  To: przemyslaw.kitszel
  Cc: netdev, kuba, jiri, anthony.l.nguyen, aleksandr.loktionov,
	mschmidt, edumazet, horms, pabeni, davem, corbet, skhan, rdunlap,
	andrew+netdev, saeedm, tariqt, leon, mbloch, jacob.e.keller,
	jedrzej.jagielski, anzaki, brett.creeley, ohartoov, poros,
	donald.hunter

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The commit message understates where the patch applies the legacy
  16-queue limit.

--

iavf: increase max number of queues to 256

This raises the maximum number of queues the iavf driver handles from 16
to 256. The netdev is now always allocated with 256 Tx/Rx queues, and the
queue vector count is capped at 64. The legacy virtchnl paths stay limited
to 16 queues.

> Increase the max number of queues that driver will handle to 256.
> Use old legacy limit in the virtchnl handling of iavf_map_queues().

[Severity: Low]

This isn't a bug, but is this description complete?

The patch also caps the legacy VIRTCHNL_OP_ENABLE_QUEUES and
VIRTCHNL_OP_DISABLE_QUEUES bitmaps in iavf_enable_queues() and
iavf_disable_queues():

drivers/net/ethernet/intel/iavf/iavf_virtchnl.c:iavf_enable_queues() {
    ...
	vqs.tx_queues = BIT(min(adapter->num_active_queues,
				IAVF_MAX_REQ_QUEUES_VCV1)) - 1;
    ...
}

The only explanation for this is the v5 changelog entry ("cap the legacy
VIRTCHNL_OP_{EN,DIS}ABLE_QUEUES bitmaps at 16 queues ... BIT() above 63
queues is undefined"). That entry is below the --- line, so it is dropped
when the patch is applied.

In this commit the min() has no effect, because at most 16 queue pairs are
still accepted from the PF. These lines are still the same at the end of
the series, though, so the legacy enable/disable opcodes leave out queues
16 and above without any warning.

Could the commit message also mention the 16-queue limit on the
enable/disable bitmaps? Readers of the applied commit and backporters
would then see it.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261121230123.316391-1-przemyslaw.kitszel%40intel.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH net-next v7 10/15] iavf: use new opcodes to request more than 16 queues
  2026-11-21 22:55 ` [PATCH net-next v7 10/15] iavf: use new opcodes to request more than 16 queues Przemek Kitszel
@ 2026-11-24 21:57   ` netdev-bot+sashiko
  0 siblings, 0 replies; 28+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 21:57 UTC (permalink / raw)
  To: przemyslaw.kitszel
  Cc: netdev, kuba, jiri, anthony.l.nguyen, aleksandr.loktionov,
	mschmidt, edumazet, horms, pabeni, davem, corbet, skhan, rdunlap,
	andrew+netdev, saeedm, tariqt, leon, mbloch, jacob.e.keller,
	jedrzej.jagielski, anzaki, brett.creeley, ohartoov, poros,
	donald.hunter

Thank you for your contribution! Sashiko AI review found 7 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 2 · Low: 5

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] In LARGE mode, iavf_get_channels() can report combined_count >
  max_combined in the same reply.
- [Medium] After a queue request is sent and the PF grants it, a later
  'ethtool -L combined <current active count>' can return success while…
- [Low] In iavf_reset_step()
  (drivers/net/ethernet/intel/iavf/iavf_main.c), the patch moves the…
- [Low] iavf_send_max_rss_qregion()
  (drivers/net/ethernet/intel/iavf/iavf_virtchnl.c) calls…
- [Low] In the VIRTCHNL_OP_GET_MAX_RSS_QREGION case of
  iavf_virtchnl_completion(), a change in qregion_width makes the code…
- [Low] iavf_get_req_queues_reply() returns `err ?:
  msg.vfres.num_queue_pairs` without checking event.msg_len >=…
- [Low] iavf_set_channels() checks num_req against iavf_max_channels(),
  which depends on LARGE_NUM_QPAIRS, REQ_QUEUES and BIT(qregion_width),…

--

iavf: use new opcodes to request more than 16 queues

This adds the VIRTCHNL_VF_LARGE_NUM_QPAIRS capability. It also adds the
new ENABLE_QUEUES_V2, DISABLE_QUEUES_V2, MAP_QUEUE_VECTOR and
GET_MAX_RSS_QREGION virtchnl opcodes, so iavf can use more than 16 queue
pairs. At init iavf asks for one queue pair per CPU, and ethtool -L goes
through an asynchronous REQUEST_QUEUES sent by the watchdog.

> diff --git a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
> index b76622fa9661d..a0d4b7bfb607d 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
> +++ b/drivers/net/ethernet/intel/iavf/iavf_ethtool.c

[ ... ]

> @@ -1683,6 +1688,19 @@ static int iavf_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,
>  
>  	return ret;
>  }
> +
> +/* in LARGE mode PF gives us up to its RSS region once it has told us that */
> +static u32 iavf_max_channels(struct iavf_adapter *adapter)
> +{
> +	u16 width = adapter->max_rss_qregion.qregion_width;
> +
> +	if (LARGE_NUM_QPAIRS_SUPPORT(adapter) && width &&
> +	    adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_REQ_QUEUES)
> +		return BIT(width);
> +
> +	return adapter->vsi_res->num_queue_pairs;
> +}
> +

[ ... ]

> @@ -1697,12 +1715,17 @@ static void iavf_get_channels(struct net_device *netdev,
>  	struct iavf_adapter *adapter = netdev_priv(netdev);
>  
>  	/* Report maximum channels */
> -	ch->max_combined = adapter->vsi_res->num_queue_pairs;
> +	ch->max_combined = iavf_max_channels(adapter);
>  
>  	ch->max_other = NONQ_VECS;
>  	ch->other_count = NONQ_VECS;
>  
>  	ch->combined_count = adapter->num_active_queues;

[Severity: Medium]
Can iavf_get_channels() report a combined_count larger than max_combined
in the same reply?

In LARGE mode iavf_max_channels() returns BIT(qregion_width). But
num_active_queues comes from iavf_alloc_queues(), which has no RSS
region cap:

	num_active_queues = min_t(int,
				  adapter->vsi_res->num_queue_pairs,
				  (int)(num_online_cpus()));

With the in-tree ice PF, ice_sriov_set_msix_vec_count() sets
vf->num_vf_qs = msix - 1 (e.g. 63) whatever the VF LUT type is.
ice_vc_get_max_rss_qregion() reports a width of 4 for a VSI LUT. The VF
then runs 63 queues while ethtool -l shows max_combined = 16.

The ethtool core rejects combined_count > max_combined, and
iavf_set_channels() also rejects num_req > iavf_max_channels(). So the
user can't set back the count the driver chose by itself, and netlink
set requests that keep the current combined count fail validation.

> +	/* the requested count, until the PF grants or denies it */
> +	if (adapter->aq_required & IAVF_FLAG_AQ_REQUEST_QUEUES)
> +		ch->combined_count = adapter->num_req_queues_next;
> +	else if (adapter->num_req_queues)
> +		ch->combined_count = adapter->num_req_queues;
>  }

[ ... ]

> @@ -1730,15 +1753,29 @@ static int iavf_set_channels(struct net_device *netdev,
>  	/* All of these should have already been checked by ethtool before this
>  	 * even gets to us, but just to be sure.
>  	 */
> -	if (num_req == 0 || num_req > adapter->vsi_res->num_queue_pairs)
> +	if (num_req == 0 || num_req > iavf_max_channels(adapter))
>  		return -EINVAL;
>  
> -	if (num_req == adapter->num_active_queues)
> -		return 0;
> -
>  	if (ch->rx_count || ch->tx_count || ch->other_count != NONQ_VECS)
>  		return -EINVAL;
>  
> +	/* PF has not answered our previous request yet */
> +	if (adapter->current_op == VIRTCHNL_OP_REQUEST_QUEUES)
> +		return -EBUSY;
> +
> +	if (num_req == adapter->num_active_queues) {
> +		adapter->aq_required &= ~IAVF_FLAG_AQ_REQUEST_QUEUES;
> +		return 0;
> +	}

[Severity: Medium]
Can a later ethtool -L return success here but be silently ignored,
after a queue request has been granted?

iavf_request_queues() sets:

    current_op = VIRTCHNL_OP_REQUEST_QUEUES
    num_req_queues = N
    flags |= IAVF_FLAG_REINIT_ITR_NEEDED

The PF grants the request by resetting the VF and sends no reply. If
iavf_watchdog_step() sees IAVF_VF_ARQLEN1 cleared first, it does:

	adapter->aq_required &= IAVF_FLAG_AQ_REQUEST_QUEUES;
	adapter->current_op = VIRTCHNL_OP_UNKNOWN;
	...
	iavf_schedule_reset(adapter, IAVF_FLAG_RESET_PENDING);

This leaves num_req_queues and IAVF_FLAG_REINIT_ITR_NEEDED set.
reset_task takes netdev_lock only after the watchdog releases it, so an
ethtool call can run in between.

In that window iavf_get_channels() reports combined_count = N. The core
then passes M = num_active_queues to iavf_set_channels(). The -EBUSY
check no longer fires, and this shortcut only clears
IAVF_FLAG_AQ_REQUEST_QUEUES and returns 0.

iavf_reset_step() then sees IAVF_FLAG_REINIT_ITR_NEEDED, and
iavf_alloc_queues() uses num_req_queues = N. The VF ends up with N
queues, although the last ethtool -L that returned success asked for M.

Should this shortcut also take a pending num_req_queues into account?

> +
> +	if (LARGE_NUM_QPAIRS_SUPPORT(adapter) &&
> +	    adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_REQ_QUEUES) {
> +		/* the watchdog sends it once no other op is in flight */
> +		adapter->num_req_queues_next = num_req;
> +		iavf_schedule_aq_request(adapter, IAVF_FLAG_AQ_REQUEST_QUEUES);
> +		return 0;
> +	}
> +

[ ... ]

> diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
> index a2aef35c0a074..66beb83acc94b 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_main.c
> +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c

[ ... ]

> @@ -2332,6 +2340,12 @@ static int iavf_process_aq_command(struct iavf_adapter *adapter)
>  		iavf_virtchnl_send_ptp_cmd(adapter);
>  		return IAVF_SUCCESS;
>  	}
> +	if (adapter->aq_required & IAVF_FLAG_AQ_REQUEST_QUEUES) {
> +		/* ethtool -L has already reported success, retry until sent */
> +		if (!iavf_request_queues(adapter, adapter->num_req_queues_next))
> +			adapter->aq_required &= ~IAVF_FLAG_AQ_REQUEST_QUEUES;
> +		return 0;
> +	}

[Severity: Low]
Is num_req_queues_next still valid when it is finally sent here?

iavf_set_channels() checks num_req against iavf_max_channels() and
num_active_queues, then defers the send. The patch keeps
IAVF_FLAG_AQ_REQUEST_QUEUES across resets, both in iavf_reset_step() and
in the watchdog's hardware reset detection:

	adapter->aq_required &= IAVF_FLAG_AQ_REQUEST_QUEUES;

Those resets re-negotiate vf_res->vf_cap_flags and max_rss_qregion, and
can change num_active_queues. None of the checks are repeated here.

Could the VF then send a REQUEST_QUEUES that is above BIT(new width),
or sent without LARGE_NUM_QPAIRS or REQ_QUEUES still negotiated? Could
it also equal the new active count and cause a needless VF reset?

[ ... ]

> @@ -3444,8 +3614,6 @@ void iavf_reset_step(struct iavf_adapter *adapter)
>  			err = iavf_request_traffic_irqs(adapter, netdev->name);
>  			if (err)
>  				goto reset_err;
> -
> -			adapter->flags &= ~IAVF_FLAG_REINIT_MSIX_NEEDED;
>  		}
>  
>  		iavf_configure(adapter);
> @@ -3463,7 +3631,8 @@ void iavf_reset_step(struct iavf_adapter *adapter)
>  		wake_up(&adapter->down_waitqueue);
>  	}
>  
> -	adapter->flags &= ~IAVF_FLAG_REINIT_ITR_NEEDED;
> +	adapter->flags &= ~(IAVF_FLAG_REINIT_MSIX_NEEDED |
> +			    IAVF_FLAG_REINIT_ITR_NEEDED);

[Severity: Low]
This isn't a bug, but moving the IAVF_FLAG_REINIT_MSIX_NEEDED clear out
of the running branch fixes a separate issue that affects every PF, and
the commit message doesn't describe it.

iavf_parse_vf_resource_msg() can set IAVF_FLAG_REINIT_MSIX_NEEDED while
the interface is down, in the "PF gave us fewer queues" and "PF could cut
our queues on reset" paths. Before this patch the flag stayed set. A
later reset then rebuilt the interrupt scheme with num_req_queues == 0
and lost a channel count set with ethtool -L while down.

The fix is mentioned only in the v7 changelog below the --- line, which
is dropped when the patch is applied. The v7 notes also say the every-PF
changes moved to "iavf: keep RSS config across resets", but this one is
still in this patch.

Other every-PF changes are bundled the same way:

- the reordered rx/tx/other validation in iavf_set_channels()
- the REQUEST_QUEUES completion ignoring replies with a non-zero
  v_retval
- iavf_init_config_adapter() clearing num_req_queues and
  IAVF_FLAG_REINIT_ITR_NEEDED

Could these be split out, or at least described in the commit message,
possibly with a Fixes: tag?

>  
>  	return;
>  reset_err:

> diff --git a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
> index 151824102acda..e643c205884f6 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
> +++ b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c

[ ... ]

> @@ -251,6 +252,18 @@ int iavf_send_vf_ptp_caps_msg(struct iavf_adapter *adapter)
>  				(u8 *)&hw_caps, sizeof(hw_caps));
>  }
>  
> +int iavf_send_max_rss_qregion(struct iavf_adapter *adapter)
> +{
> +	adapter->aq_required &= ~IAVF_FLAG_AQ_GET_MAX_RSS_QREGION;
> +
> +	if (!LARGE_NUM_QPAIRS_SUPPORT(adapter))
> +		return -EOPNOTSUPP;
> +
> +	adapter->current_op = VIRTCHNL_OP_GET_MAX_RSS_QREGION;
> +	iavf_send_pf_msg(adapter, VIRTCHNL_OP_GET_MAX_RSS_QREGION, NULL, 0);
> +	return 0;
> +}

[Severity: Low]
Should this return the result of iavf_send_pf_msg()?

iavf_send_vf_offload_vlan_v2_msg(), iavf_send_vf_ptp_caps_msg() and
iavf_send_vf_config_msg() all return it. iavf_process_aq_command() passes
this return value straight back to the watchdog.

As written, a failed ASQ send looks like success. At init,
iavf_init_recv_max_rss_qregion() then polls for a reply that was never
requested.

[ ... ]

> +int iavf_get_req_queues_reply(struct iavf_adapter *adapter)
> +{
> +	/* poll looks for the reset event in the same buffer */
> +	union {
> +		struct virtchnl_vf_res_request vfres;
> +		struct virtchnl_pf_event vpe;
> +	} msg = {};
> +	struct iavf_arq_event_info event = {
> +		.buf_len = sizeof(msg),
> +		.msg_buf = (u8 *)&msg,
> +	};
> +	int err;
> +
> +	err = iavf_poll_virtchnl_msg(&adapter->hw, &event,
> +				     VIRTCHNL_OP_REQUEST_QUEUES);
> +
> +	return err ?: msg.vfres.num_queue_pairs;
> +}

[Severity: Low]
Should event.msg_len be checked before msg.vfres.num_queue_pairs is used?

iavf_poll_virtchnl_msg() reuses this buffer for every ARQ message it
skips, such as link events. iavf_clean_arq_element() copies only
min(datalen, buf_len) bytes, and nothing at all for an empty message:

	e->msg_len = min(datalen, e->buf_len);
	if (e->msg_buf && (e->msg_len != 0))
		memcpy(e->msg_buf, hw->aq.arq.r.arq_bi[desc_idx].va,
		       e->msg_len);

A short or empty REQUEST_QUEUES reply would then return stale bytes from
an earlier message. iavf_get_max_rss_qregion() above does check
event.msg_len == len.

iavf_init_recv_req_queues() also passes the offered count on as is:

		if (num > adapter->vsi_res->num_queue_pairs &&
		    !iavf_request_queues(adapter, num))
			return;

There is no clamp to IAVF_MAX_REQ_QUEUES, so a value up to 65535 could
end up in adapter->num_req_queues. Should it be bounded?

[ ... ]

> @@ -2710,6 +2934,22 @@ void iavf_virtchnl_completion(struct iavf_adapter *adapter,
>  			aq_required;
>  		}
>  		break;
> +	case VIRTCHNL_OP_GET_MAX_RSS_QREGION: {
> +		u16 width = adapter->max_rss_qregion.qregion_width;
> +
> +		if (v_retval || msglen != sizeof(adapter->max_rss_qregion))
> +			break;
> +		memcpy(&adapter->max_rss_qregion, msg, msglen);
> +		adapter->max_rss_qregion.qregion_width =
> +			min(adapter->max_rss_qregion.qregion_width,
> +			    ilog2(IAVF_MAX_REQ_QUEUES));
> +		/* LUT was filled before this reply, for the old region */
> +		if (adapter->max_rss_qregion.qregion_width != width) {
> +			iavf_fill_rss_lut(adapter);
> +			iavf_config_rss(adapter);

[Severity: Low]
Does iavf_config_rss() work from here on the RSS_AQ path?

adapter->current_op is still VIRTCHNL_OP_GET_MAX_RSS_QREGION at this
point, because it is reset only after the opcode switch. So
iavf_config_rss_aq() bails out:

	if (adapter->current_op != VIRTCHNL_OP_UNKNOWN) {
		/* bail because we already have a command pending */
		dev_err(&adapter->pdev->dev, "Cannot configure RSS, command %d pending\n",

The return value is dropped, so the refilled LUT is never programmed and
nothing retries it. Only the RSS_PF and RSS_REG paths work from this
context.

> +		}
> +		break;
> +	}

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261121230123.316391-1-przemyslaw.kitszel%40intel.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH net-next v7 11/15] ice: introduce handling of virtchnl LARGE VF opcodes
  2026-11-21 22:55 ` [PATCH net-next v7 11/15] ice: introduce handling of virtchnl LARGE VF opcodes Przemek Kitszel
@ 2026-11-24 21:57   ` netdev-bot+sashiko
  0 siblings, 0 replies; 28+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 21:57 UTC (permalink / raw)
  To: przemyslaw.kitszel
  Cc: netdev, kuba, jiri, anthony.l.nguyen, aleksandr.loktionov,
	mschmidt, edumazet, horms, pabeni, davem, corbet, skhan, rdunlap,
	andrew+netdev, saeedm, tariqt, leon, mbloch, jacob.e.keller,
	jedrzej.jagielski, anzaki, brett.creeley, ohartoov, poros,
	donald.hunter

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The kernel-doc for three new handlers in
  drivers/net/ethernet/intel/ice/virt/queues.c describes the return…

--

ice: introduce handling of virtchnl LARGE VF opcodes

This commit adds PF handlers for VIRTCHNL_OP_ENABLE_QUEUES_V2,
VIRTCHNL_OP_DISABLE_QUEUES_V2 and VIRTCHNL_OP_MAP_QUEUE_VECTOR, and
allowlists them, along with GET_MAX_RSS_QREGION, behind
VIRTCHNL_VF_LARGE_NUM_QPAIRS. It also widens num_ring_{rx,tx} in struct
ice_q_vector to u16, so a VF can map all 256 of its queues to one vector.

> diff --git a/drivers/net/ethernet/intel/ice/virt/queues.c b/drivers/net/ethernet/intel/ice/virt/queues.c
> index a8a2f5e5b3223..e8635236cb6c1 100644
> --- a/drivers/net/ethernet/intel/ice/virt/queues.c
> +++ b/drivers/net/ethernet/intel/ice/virt/queues.c

[ ... ]

> +/**
> + * ice_vc_ena_qs_v2_msg - message handling for VIRTCHNL_OP_ENABLE_QUEUES_V2
> + * @vf: source of the request
> + * @msg: message to handle
> + * @msglen: length of the @msg
> + *
> + * Return: 0 on success or negative on error.
> + */
> +int ice_vc_ena_qs_v2_msg(struct ice_vf *vf, u8 *msg, u16 msglen)
> +{
> +	struct virtchnl_del_ena_dis_queues *ena_qs_msg =
> +			(struct virtchnl_del_ena_dis_queues *)msg;
> +	enum virtchnl_status_code v_ret = VIRTCHNL_STATUS_ERR_PARAM;
> +	struct ice_vsi *vsi;
> +
> +	if (!ice_vc_validate_qs_v2_msg(vf, ena_qs_msg, msglen))
> +		goto error_param;

[ ... ]

> +	v_ret = VIRTCHNL_STATUS_SUCCESS;
> +	set_bit(ICE_VF_STATE_QS_ENA, vf->vf_states);
> +
> +error_param:
> +	return ice_vc_send_msg_to_vf(vf, VIRTCHNL_OP_ENABLE_QUEUES_V2,
> +				     v_ret, NULL, 0);
> +}

[Severity: Low]
Is the "Return:" line in this kernel-doc accurate?

When validation fails, v_ret stays VIRTCHNL_STATUS_ERR_PARAM. The code then
jumps to error_param and returns the result of ice_vc_send_msg_to_vf(). That
function returns 0 whenever the mailbox write succeeds:

ice_vc_send_msg_to_vf() {
    ...
	aq_ret = ice_aq_send_msg_to_vf(&pf->hw, vf->vf_id, v_opcode, v_retval,
				       msg, msglen, NULL);
	if (aq_ret && pf->hw.mailboxq.sq_last_status != LIBIE_AQ_RC_ENOSYS) {
		...
		return -EIO;
	}

	return 0;
}

So a rejected request still returns 0. A negative value only means the
response could not be sent to the VF.

ice_vc_dis_qs_v2_msg() and ice_vc_map_q_vector_msg() have the same
"Return: 0 on success or negative on error" text. The V1 handler
ice_vc_dis_qs_msg() says:

 * Return: exit code of sending the virtchnl response.

Could the new handlers use similar wording? This text is still unchanged at
the end of the series.

[ ... ]

> +/**
> + * ice_vc_validate_qv_maps - validate parameters sent in the qs_msg structure
> + * @vf: VF the message was received from
> + * @qv_maps: contents of the message from the VF
> + * @msglen: length of the @qv_maps
> + *
> + * Used to validate VIRTCHNL_OP_MAP_QUEUE_VECTOR messages. This should always
> + * be called before attempting map interrupts to queues. If all checks succeed,
> + * then return success indicating to the caller that the qv_maps are valid.
> + * Otherwise return false, indicating to the caller that the qv_maps are
> + * invalid.
> + *
> + * Return: true if parameters are valid, false otherwise.
> + */
> +static bool ice_vc_validate_qv_maps(struct ice_vf *vf,
> +				    struct virtchnl_queue_vector_maps *qv_maps,
> +				    u16 msglen)

[Severity: Low]
This isn't a bug, but the summary line mentions "the qs_msg structure"
while the function takes struct virtchnl_queue_vector_maps *qv_maps.

The body also says "then return success", but this is a bool function that
returns true or false. Should that say "return true" to match the Return:
line?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261121230123.316391-1-przemyslaw.kitszel%40intel.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH net-next v7 12/15] devlink: add cmode to resources
  2026-11-21 22:55 ` [PATCH net-next v7 12/15] devlink: add cmode to resources Przemek Kitszel
@ 2026-11-24 21:57   ` netdev-bot+sashiko
  0 siblings, 0 replies; 28+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 21:57 UTC (permalink / raw)
  To: przemyslaw.kitszel
  Cc: netdev, kuba, jiri, anthony.l.nguyen, aleksandr.loktionov,
	mschmidt, edumazet, horms, pabeni, davem, corbet, skhan, rdunlap,
	andrew+netdev, saeedm, tariqt, leon, mbloch, jacob.e.keller,
	jedrzej.jagielski, anzaki, brett.creeley, ohartoov, poros,
	donald.hunter

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] Every resource now reports DEVLINK_ATTR_RESOURCE_CMODE.

--

devlink: add cmode to resources

This adds a configuration mode to devlink resources and reuses enum
devlink_param_cmode for it. Resources default to driverinit. A driver can
make a resource runtime with devl_resource_runtime_register(), and then
DEVLINK_CMD_RESOURCE_SET applies the new size right away through a driver
callback. The new DEVLINK_ATTR_RESOURCE_CMODE is reported for every
resource, and it may also be passed to DEVLINK_CMD_RESOURCE_SET.

> diff --git a/net/devlink/resource.c b/net/devlink/resource.c
> index c3cfda7ea0703..2d31dac85eb15 100644
> --- a/net/devlink/resource.c
> +++ b/net/devlink/resource.c

[ ... ]

> @@ -183,8 +210,10 @@ static int devlink_resource_put(struct devlink *devlink, struct sk_buff *skb,
>  		return -EMSGSIZE;
>  
>  	if (nla_put_string(skb, DEVLINK_ATTR_RESOURCE_NAME, resource->name) ||
> -	    devlink_nl_put_u64(skb, DEVLINK_ATTR_RESOURCE_SIZE, resource->size) ||
> -	    devlink_nl_put_u64(skb, DEVLINK_ATTR_RESOURCE_ID, resource->id))
> +	    devlink_nl_put_u64(skb, DEVLINK_ATTR_RESOURCE_SIZE,
> +			       devlink_resource_size(resource)) ||
> +	    devlink_nl_put_u64(skb, DEVLINK_ATTR_RESOURCE_ID, resource->id) ||
> +	    nla_put_u8(skb, DEVLINK_ATTR_RESOURCE_CMODE, resource->cmode))
>  		goto nla_put_failure;

[Severity: Low]
What cmode should port-level resources report here?

Port resources are registered via devl_port_resource_register() ->
__devl_resource_register(), so they always get
DEVLINK_PARAM_CMODE_DRIVERINIT. devlink_resource_put() then reports that
value when a port's resources are dumped.

But a port resource can never get a new size, not even on reload.
devlink_nl_resource_set_doit(), devl_resource_runtime_register() and
devl_resource_size_get() only search devlink->resource_list:

    resource = devlink_resource_find(devlink, NULL, resource_id);

DEVLINK_CMD_RESOURCE_SET also uses devlink_nl_pre_doit, and its policy
has no DEVLINK_ATTR_PORT_INDEX. So devlink_port->resource_list is never
reached on the set path.

The new spec doc for resource-cmode in
Documentation/netlink/specs/devlink.yaml says:

    Configuration mode of the resource, when a new size takes effect.
    Runtime resources apply it immediately, others on driver reload.

devlink-resource.rst says "The default, driverinit, is described above",
which points to the reload-based semantics. Neither statement holds for
port resources. The commit message and the docs don't mention port
resources at all.

DEVLINK_ATTR_RESOURCE_CMODE becomes uAPI once it is released. Could the
docs describe the port resource exception? Or could the cmode be left out
for resources that can't be set at all?

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261121230123.316391-1-przemyslaw.kitszel%40intel.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH net-next v7 13/15] ice: represent RSS LUTs as devlink resources
  2026-11-21 22:55 ` [PATCH net-next v7 13/15] ice: represent RSS LUTs as devlink resources Przemek Kitszel
@ 2026-11-24 21:57   ` netdev-bot+sashiko
  0 siblings, 0 replies; 28+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 21:57 UTC (permalink / raw)
  To: przemyslaw.kitszel
  Cc: netdev, kuba, jiri, anthony.l.nguyen, aleksandr.loktionov,
	mschmidt, edumazet, horms, pabeni, davem, corbet, skhan, rdunlap,
	andrew+netdev, saeedm, tariqt, leon, mbloch, jacob.e.keller,
	jedrzej.jagielski, anzaki, brett.creeley, ohartoov, poros,
	donald.hunter

Thank you for your contribution! Sashiko AI review found 5 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · Low: 4

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] Possible ABBA deadlock between the per-PF devlink instance lock
  and rtnl.
- [Low] The per-PF runtime devlink resource "rss_lut" is registered once
  at probe (ice_devl_pf_resources_register() in ice_probe()) and…
- [Low] In ice_setup_tc_mqprio_qdisc()
  (drivers/net/ethernet/intel/ice/ice_main.c), the new rejection "RSS…
- [Low] Cleanup guideline violation (mixing goto and guards).
- [Low] The commit body does not mention a change to existing ADQ error
  handling.

--

ice: represent RSS LUTs as devlink resources

This patch exposes the E800 RSS LUTs as devlink resources. Each PF gets a
runtime rss_lut resource to switch between its 2048-entry PF LUT and a
512-entry global LUT, and the whole-device instance reports read-only
rss_lut_512 and rss_lut_2048 counters. The user indirection table is kept
across LUT changes and resets, and ADQ and LUT reassignment are made
mutually exclusive.

> diff --git a/drivers/net/ethernet/intel/ice/devlink/resource.c b/drivers/net/ethernet/intel/ice/devlink/resource.c
> new file mode 100644
> index 0000000000000..c07f61acdaedc
> --- /dev/null
> +++ b/drivers/net/ethernet/intel/ice/devlink/resource.c
> @@ -0,0 +1,643 @@

[ ... ]

> +/* ethtool core sizes RSS buffers by rss_table_size under rtnl, and the new
> + * LUT is filled based on NETIF_F_RXHASH, which is also changed under rtnl
> + */
> +static int ice_rss_lut_pf_size_set(u64 size, struct netlink_ext_ack *extack,
> +				   void *priv)
> +{
> +	struct ice_pf *pf = priv;
> +	int err;
> +
> +	rtnl_lock();
> +	scoped_guard(ice_adapter_devl, pf->adapter)
> +		err = ice_rss_lut_set(pf, pf, size, extack);
> +	rtnl_unlock();

[Severity: High]
Can this deadlock against rtnl?

The devlink core calls the runtime size_set callback with the PF devlink
instance lock held. The devl_resource_runtime_register() kernel-doc says
"Both callbacks are called with the instance lock held". So the order
here is PF devl -> rtnl.

ice_tear_down_devlink_rate_tree() takes the same PF devlink lock:

drivers/net/ethernet/intel/ice/devlink/devlink.c:ice_tear_down_devlink_rate_tree() {
	devlink = priv_to_devlink(pf);

	devl_lock(devlink);
	mutex_lock(&pf->vfs.table_lock);
    ...
}

Its callers already hold rtnl, so the order there is rtnl -> PF devl:

- ice_setup_tc_mqprio_qdisc(), via ndo_setup_tc from tc_modify_qdisc
- ice_pf_dcb_cfg(), via dcbnl, and via the LLDP MIB change path after
  rtnl_lock()

For example:

CPU0: devlink resource set pci/X path rss_lut size 512
  devlink core holds PF devl
  ice_rss_lut_pf_size_set()
    rtnl_lock()              <- waits for CPU1

CPU1: tc qdisc add dev ethX root mqprio ... hw 1 mode channel
  rtnl held
  ice_setup_tc_mqprio_qdisc()
    ice_tear_down_devlink_rate_tree()   (before the new ADQ check)
      devl_lock(PF)          <- waits for CPU0

The rtnl -> devl order in ice_tear_down_devlink_rate_tree() is older.
ice_devlink_reinit_down() and ice_devlink_reinit_up() already take rtnl
under devl during reload. This patch adds a devl -> rtnl edge that any
runtime devlink resource set can reach.

Could rtnl be avoided here, or could the lock order in
ice_tear_down_devlink_rate_tree() be fixed?

> +
> +	return err;
> +}

[ ... ]

> diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c
> index 57425683c0d4f..a65dd342246cd 100644
> --- a/drivers/net/ethernet/intel/ice/ice_lib.c
> +++ b/drivers/net/ethernet/intel/ice/ice_lib.c

[ ... ]

> @@ -2471,8 +2501,15 @@ static int ice_vsi_cfg_def(struct ice_vsi *vsi)
>  	vsi->vsw = pf->first_sw;
>  
>  	if (vsi->flags & ICE_VSI_FLAG_INIT) {
> -		scoped_guard(mutex, &pf->rss_lut_lock)
> +		scoped_guard(mutex, &pf->rss_lut_lock) {
> +			u16 lut_size = vsi->rss_table_size;
> +
>  			ice_vsi_set_dflt_rss_lut_type(vsi);
> +			if (vsi->rss_table_size != lut_size) {
> +				devm_kfree(dev, vsi->rss_lut_user);
> +				vsi->rss_lut_user = NULL;
> +			}
> +		}
>  	}

[ ... ]

> @@ -2615,6 +2660,9 @@ static int ice_vsi_cfg_def(struct ice_vsi *vsi)
>  	ice_vsi_free_q_vectors(vsi);
>  unroll_vsi_init:
>  	ice_vsi_delete_from_hw(vsi);
> +unroll_pf_rss_lut:
> +	if ((vsi->flags & ICE_VSI_FLAG_INIT) && vsi->type == ICE_VSI_PF)
> +		ice_release_rss_lut_pf(pf);
>  unroll_get_qs:
>  	ice_vsi_put_qs(vsi);
>  unroll_vsi_alloc_stat:

[Severity: Low]
This isn't a bug, but this adds a new goto unwind label to
ice_vsi_cfg_def(). That function also uses
scoped_guard(mutex, &pf->rss_lut_lock), and this patch makes that guarded
block larger.

ice_setup_tc_mqprio_qdisc() has the same mix. It gains
scoped_guard(ice_adapter_devl, pf->adapter) below, and it already uses
goto config_tcf and goto exit.

include/linux/cleanup.h says goto-based cleanup and guard helpers should
not be mixed in one function. Could each of these functions use only one
of the two styles?

> diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
> index 3e8cf1c5f0e81..5f0de7cf0a8e5 100644
> --- a/drivers/net/ethernet/intel/ice/ice_main.c
> +++ b/drivers/net/ethernet/intel/ice/ice_main.c

[ ... ]

> @@ -3873,6 +3876,8 @@ void ice_deinit_pf(struct ice_pf *pf)
>  {
>  	/* note that we unroll also on ice_init_pf() failure here */
>  
> +	/* ice_vsi_decfg() skips it if the last VSI rebuild was NO_INIT */
> +	ice_free_rss_lut_flr(pf);
>  	mutex_destroy(&pf->rss_lut_lock);

[Severity: Low]
Can the rss_lut size_set callback still run after this?

ice_probe() registers the per-PF rss_lut resource once, through
ice_devl_pf_resources_register(). ice_deinit_devlink() unregisters it,
but only on remove.

Devlink reload goes through ice_devlink_reinit_down() -> ice_deinit_pf().
That destroys pf->rss_lut_lock and drops the PF LUT ownership here. If
ice_devlink_reinit_up() then fails, its error path ends in
ice_deinit_pf() again:

err_load:
	rtnl_lock();
	ice_vsi_decfg(vsi);
	rtnl_unlock();
unroll_pf_init:
	ice_deinit_pf(pf);

The resource stays registered with priv == pf. Take a later
"devlink resource set ... path rss_lut size 2048":

ice_rss_lut_pf_size_set()
  ice_rss_lut_set()
    ice_change_rss_lut()

ICE_FLAG_RSS_ENA is still set. ice_rss_lut_type() returns ICE_LUT_VSI
because the owner slot was cleared, so the request counts as a change.

ice_change_rss_lut() then calls mutex_lock(&pf->rss_lut_lock) on the
destroyed mutex, and ice_aq_set_rss_lut() sends a command to a control
queue that has been shut down. With size 512, ice_alloc_rss_global_lut()
sends an AQ command to the dead queue in the same way.

Should the rss_lut resource follow the reload down/up lifetime, or should
the callbacks check that the PF is loaded?

[ ... ]

> @@ -9194,8 +9211,14 @@ static int ice_setup_tc_mqprio_qdisc(struct net_device *netdev, void *type_data)
>  				   ret);
>  			return ret;
>  		}
> +		scoped_guard(ice_adapter_devl, pf->adapter) {
> +			if (ice_rss_lut_is_reassigned(pf)) {
> +				dev_err(dev, "RSS LUTs reassigned via devlink, can't configure ADQ\n");
> +				return -EOPNOTSUPP;
> +			}

[Severity: Low]
Is this rejection meant to run after the devlink-rate tree has already
been torn down? Earlier in the same case:

		if (pf->hw.port_info->is_custom_tx_enabled) {
			dev_err(dev, "Custom Tx scheduler feature enabled, can't configure ADQ\n");
			return -EBUSY;
		}
		ice_tear_down_devlink_rate_tree(pf);

		ret = ice_validate_mqprio_qopt(vsi, mqprio_qopt);

Suppose the PF was moved to a global LUT with devlink resource set, and
"tc qdisc add ... mqprio hw 1 mode channel" is tried next. The request
fails with -EOPNOTSUPP. By then devl_rate_leaf_destroy() and
devl_rate_nodes_destroy() have already removed the VF rate leaves and
rate nodes. ice_devlink_rate_init_tx_topology() only exports them again
when the representors are recreated.

What gets lost is the default exported topology. Any rate change sets
is_custom_tx_enabled, and that case returns -EBUSY before the teardown.
A failed ice_validate_mqprio_qopt() already has the same side effect, but
this adds a new rejection reason after the teardown.

The new check depends only on the RSS LUT state. Could it go next to the
is_custom_tx_enabled check, before ice_tear_down_devlink_rate_tree()?

> +			set_bit(ICE_FLAG_TC_MQPRIO, pf->flags);
> +		}
>  		memcpy(&vsi->mqprio_qopt, mqprio_qopt, sizeof(*mqprio_qopt));
> -		set_bit(ICE_FLAG_TC_MQPRIO, pf->flags);

[ ... ]

> @@ -9263,6 +9286,7 @@ static int ice_setup_tc_mqprio_qdisc(struct net_device *netdev, void *type_data)
>  		clear_bit(ICE_RESET_FAILED, pf->state);
>  		if (ice_vsi_rebuild(vsi, ICE_VSI_FLAG_NO_INIT)) {
>  			dev_err(dev, "Rebuild of main VSI failed again\n");
> +			clear_bit(ICE_FLAG_TC_MQPRIO, pf->flags);
>  			return ret;
>  		}
>  	}

[ ... ]

> @@ -9315,6 +9339,7 @@ static int ice_setup_tc_mqprio_qdisc(struct net_device *netdev, void *type_data)
>  	if (ret) {
>  		vsi->all_numtc = 0;
>  		vsi->all_enatc = 0;
> +		clear_bit(ICE_FLAG_TC_MQPRIO, pf->flags);
>  	}

[Severity: Low]
This isn't a bug, but these two clear_bit(ICE_FLAG_TC_MQPRIO, ...) calls
change the existing ADQ error handling.

Before this patch, a failed channel-mode setup left ICE_FLAG_TC_MQPRIO
set. That covers the second VSI rebuild failure, and ice_vsi_cfg_tc(),
ice_set_bw_limit() or ice_create_q_channels() failing.
ice_prepare_for_reset() and other code check that flag.

The commit message only says:

    RSS LUTs can't be changed while ADQ is configured, or with RSS disabled,
    e.g. in safe mode. ADQ can't be configured while the RSS LUTs of the PF
    are reassigned.

The reason only appears in the v7 changelog below the --- line ("clear
ICE_FLAG_TC_MQPRIO when the ADQ setup fails, it blocked RSS LUT changes
until mqprio was reconfigured"), which won't be kept in git history.

Could the commit message describe this change?

>  	/* resume VSI */
>  	ice_ena_vsi(vsi, true);

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261121230123.316391-1-przemyslaw.kitszel%40intel.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH net-next v7 15/15] ice: support up to 256 VF queues
  2026-11-21 22:55 ` [PATCH net-next v7 15/15] ice: support up to 256 VF queues Przemek Kitszel
@ 2026-11-24 21:57   ` netdev-bot+sashiko
  0 siblings, 0 replies; 28+ messages in thread
From: netdev-bot+sashiko @ 2026-11-24 21:57 UTC (permalink / raw)
  To: przemyslaw.kitszel
  Cc: netdev, kuba, jiri, anthony.l.nguyen, aleksandr.loktionov,
	mschmidt, edumazet, horms, pabeni, davem, corbet, skhan, rdunlap,
	andrew+netdev, saeedm, tariqt, leon, mbloch, jacob.e.keller,
	jedrzej.jagielski, anzaki, brett.creeley, ohartoov, poros,
	donald.hunter

Thank you for your contribution! Sashiko AI review found 8 potential
issue(s) to consider.

Critical: 0 · High: 2 · Medium: 2 · Low: 4

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] ice_init_vf_devlink()
  (drivers/net/ethernet/intel/ice/ice_vf_lib.c) asserts that…
- [High] ice_sriov_set_msix_vec_count() (sriov_vf_msix_count sysfs) reads
  and rebuilds the VF VSI without vf->cfg_lock.
- [Medium] ice: NULL pointer dereference on VF recovery after VSI rebuild
  failure
- [Medium] ice: sriov_vf_msix_count overridden by num_req_qs and not
  capped to LUT or 256
- [Low] ice_vf_max_contig_qs() returns 0 when either
  bitmap_alloc(GFP_KERNEL) fails: it jumps to `out` with max_tx and…
- [Low] ice_sriov_set_msix_vec_count() now has two capacity checks that
  measure different things.
- [Low] ice_vf_max_contig_qs() copies pf->avail_txqs/avail_rxqs under
  pf->avail_q_mutex, drops the mutex, and returns the longest free range…
- [Low] ice_init_vf_devlink() returns void and exits silently when
  devlink_alloc_drv() returns NULL or devl_nested_devlink_set() fails:…

--

ice: support up to 256 VF queues

This patch supports up to 256 queues per VF. A VF gets the bigger RSS
LUT it needs through a new per-VF devlink instance with an rss_lut
resource. It also hooks up the large-queue virtchnl opcodes, defers the
VF reset to the service task, and only grants queue requests that fit in
one contiguous free range of PF queues.

> diff --git a/drivers/net/ethernet/intel/ice/ice_sriov.c b/drivers/net/ethernet/intel/ice/ice_sriov.c
> index d7c4a65400083..24c521aaf3f3b 100644
> --- a/drivers/net/ethernet/intel/ice/ice_sriov.c
> +++ b/drivers/net/ethernet/intel/ice/ice_sriov.c

[ ... ]

> @@ -969,6 +991,12 @@ int ice_sriov_set_msix_vec_count(struct pci_dev *vf_dev, int msix_vec_count)
>  		return 0;
>  	}
>  
> +	/* VSI rebuild takes one free range for all queues of the VF */
> +	if ((vf->num_req_qs ?: queues) > ice_vf_max_contig_qs(vf, vsi)) {
> +		ice_put_vf(vf);
> +		return -ENOSPC;
> +	}
> +
>  	prev_msix = vf->num_msix;
>  	prev_queues = vf->num_vf_qs;
>  

[Severity: Medium]
This check uses vf->num_req_qs ?: queues, but
ice_sriov_set_msix_vec_count() never updates vf->num_req_qs. On
rebuild, ice_vsi_set_num_qs() overwrites vf->num_vf_qs with
vf->num_req_qs whenever that is non-zero.

This patch adds two places that set num_req_qs without the admin or
the VF asking for it. ice_change_rss_lut() and ice_rebuild_rss_luts()
set vf->num_req_qs = max_qs when (vf->num_req_qs ?: vf->num_vf_qs) is
above the LUT limit.

Take a VF with a global LUT that got 64 queues through
sriov_vf_msix_count. After a PF reset, num_req_qs is latched at 16.
>From then on, a sriov_vf_msix_count write changes vf->num_msix and sets
vf->num_vf_qs = queues, but the VSI rebuild puts the queue count back
to 16. That also happens after the VF gets a bigger LUT again. The
-ENOSPC check here is done against that stale 16, not the count that
was written. vsi->req_txq/req_rxq do not help either, since they are
only read for ICE_VSI_PF.

When num_req_qs is 0, queues is capped neither by
ice_lut_type_to_qs_num(vsi->rss_lut_type) nor by ICE_MAX_QS_PER_VF.
VIRTCHNL_VF_LARGE_NUM_QPAIRS is now granted to any VF with a global
or PF LUT. So a VF with a 512 entry global LUT and sriov_vf_msix_count
set to 128 gets num_queue_pairs = 128 in the GET_VF_RESOURCES reply,
while its LUT spreads traffic over only 64 of them.

Above 256 queues it gets worse. ice_ena_vf_q_mappings() writes
max_txq - 1 into the 8-bit VFNUMQ fields of VPLAN_TX_QBASE and
VPLAN_RX_QBASE, so 257 queues wrap to a single queue in hardware. Queue
id 256 also passes ice_vc_isvalid_q_id(), which only checks against
vsi->alloc_txq. ice_vf_vsi_dis_single_txq() then indexes past the
ICE_MAX_QS_PER_VF sized vf->txq_ena bitmap.

Should the sysfs path set or clear vf->num_req_qs together with
vf->num_vf_qs? Should it also cap queues to the RSS LUT limit and to
ICE_MAX_QS_PER_VF, the way ice_vc_request_qs_msg() caps a VF request?

[Severity: High]
ice_sriov_set_msix_vec_count() does not take vf->cfg_lock. With this
patch, the VF devlink rss_lut setter can work on the same VF VSI at the
same time:

devlink resource set pci/<VF> path rss_lut ...
  ice_rss_lut_vf_size_set()        (VF devl lock + vf->cfg_lock)
    ice_rss_lut_set()
      ice_change_rss_lut()
        writes vsi->rss_table_size, rss_lut_type, rss_size,
        vf->num_req_qs
        ice_schedule_vf_reset()

service task
  ice_handle_deferred_vf_reset()
    ice_reset_vf()
      ice_vf_reconfig_vsi()
        ice_vsi_decfg() / ice_vsi_cfg()   (cfg_lock only)

sriov_vf_msix_count store
  ice_sriov_set_msix_vec_count()   (no cfg_lock)
    reads vf->num_req_qs
    ice_vf_max_contig_qs()         walks vsi->txq_map[] / rxq_map[]
    ice_vsi_rebuild()

The sysfs path only needs the VF to be unbound. The devlink setter only
needs ice_vf_is_ready(), and an unbound VF in INIT state passes that
check.

Can the two paths run decfg/cfg on the same VSI at once? Can
ice_vf_max_contig_qs() read vsi->txq_map[] while it is being freed or
reallocated?

ice_rebuild_rss_luts() also writes vf->num_req_qs and the VF VSI rss
fields while holding table_lock and rss_lut_lock, but not cfg_lock.

The missing cfg_lock in ice_sriov_set_msix_vec_count() predates this
patch, since ndo_set_vf_* resets can already race with it. This patch
adds a new concurrent writer and new unlocked reads on top of that.

[Severity: Low]
Earlier in ice_sriov_set_msix_vec_count() there is still the older
capacity check:

	if (queues > min(ice_get_avail_txq_count(pf),
			 ice_get_avail_rxq_count(pf)))
		return -EINVAL;

That check counts the VF's current queues as used, because they are
still set in pf->avail_txqs/avail_rxqs. It also tests queues, not
vf->num_req_qs ?: queues.

The new check counts the VF's own queues as free, as the
ice_vf_max_contig_qs() kernel-doc says. Will a write that would fit once
the VF's own queues are released be rejected early with -EINVAL? Will a
VF that really does not fit usually get -EINVAL rather than -ENOSPC?

The commit message says:

  A write to sriov_vf_msix_count fails with -ENOSPC when the VF would
  not fit.

That only holds when the older check passes first. Should the two
checks be reconciled?

> diff --git a/drivers/net/ethernet/intel/ice/ice_vf_lib.c b/drivers/net/ethernet/intel/ice/ice_vf_lib.c
> index 320b393ddaaf0..015b50c70bdcc 100644
> --- a/drivers/net/ethernet/intel/ice/ice_vf_lib.c
> +++ b/drivers/net/ethernet/intel/ice/ice_vf_lib.c

[ ... ]

> @@ -1450,3 +1474,52 @@ void ice_vf_update_mac_lldp_num(struct ice_vf *vf, struct ice_vsi *vsi,
>  	if (was_ena != is_ena)
>  		ice_vsi_cfg_sw_lldp(vsi, false, is_ena);
>  }
> +
> +void ice_init_vf_devlink(struct ice_vf *vf)
> +{
> +	struct devlink *pf_devlink = priv_to_devlink(vf->pf);
> +	static const struct devlink_ops noop = {};
> +	struct devlink *devlink;
> +	int err;
> +
> +	lockdep_assert_held(&vf->pf->vfs.table_lock);
> +
> +	/* no VF pci_dev when the VFs were not scanned, e.g. on s390 */
> +	if (!vf->vfdev)
> +		return;
> +
> +	devlink = devlink_alloc_drv(&noop, 0, &vf->vfdev->dev,
> +				    ice_pf_to_dev(vf->pf)->driver);
> +	if (!devlink)
> +		return;
> +
> +	scoped_guard(devl, pf_devlink)
> +		err = devl_nested_devlink_set(pf_devlink, devlink);

[Severity: High]
Can this deadlock against ice_tear_down_devlink_rate_tree()?

ice_start_vfs() calls ice_init_vf_devlink() for every VF while
ice_ena_vfs() holds pf->vfs.table_lock. That gives the order
table_lock -> PF devl.

ice_tear_down_devlink_rate_tree() in devlink/devlink.c takes the locks
the other way round:

	devl_lock(devlink);
	mutex_lock(&pf->vfs.table_lock);

It is reached from ice_pf_dcb_cfg() (dcbnl setets/setpfc/setapp, DCB
rebuild, LLDP MIB change handling). It is also reached from
ice_setup_tc_mqprio_qdisc() in channel mode.

CPU0                              CPU1
sriov_numvfs store                dcbnl setets / LLDP MIB change
ice_ena_vfs()                     ice_pf_dcb_cfg()
  lock table_lock                   ice_tear_down_devlink_rate_tree()
  ice_start_vfs()                     devl_lock(pf devlink)
    ice_init_vf_devlink()             lock table_lock  <- waits
      devl lock(pf devlink) <- waits

Before this patch, the table_lock -> PF devl order only showed up in
switchdev mode, through ice_eswitch_attach_vf()/ice_eswitch_detach_vf()
under table_lock. Now it also happens in the default legacy mode.

> +	if (err) {
> +		devlink_free(devlink);
> +		return;
> +	}

[Severity: Low]
When devlink_alloc_drv() returns NULL or devl_nested_devlink_set()
fails, ice_init_vf_devlink() returns without logging anything.

The VF devlink instance is the only way to give a VF a bigger RSS LUT.
Would a dev_warn() on these paths help explain why "devlink resource set
pci/<VF BDF> path rss_lut ..." is not available for that VF?

> +
> +	vf->devlink = devlink;
> +	scoped_guard(devl, devlink) {
> +		ice_devlink_vf_resources_register(vf);
> +		devl_register(devlink);
> +	}
> +}

[ ... ]

> diff --git a/drivers/net/ethernet/intel/ice/virt/queues.c b/drivers/net/ethernet/intel/ice/virt/queues.c
> index e8635236cb6c1..1afb7a2946fe9 100644
> --- a/drivers/net/ethernet/intel/ice/virt/queues.c
> +++ b/drivers/net/ethernet/intel/ice/virt/queues.c
> @@ -986,6 +986,48 @@ int ice_vc_cfg_qs_msg(struct ice_vf *vf, u8 *msg)

[ ... ]

> +int ice_vf_max_contig_qs(struct ice_vf *vf, struct ice_vsi *vsi)
> +{
> +	struct ice_pf *pf = vf->pf;
> +	unsigned long *txqs, *rxqs;
> +	int max_tx = 0, max_rx = 0;
> +	int b, e;
> +
> +	txqs = bitmap_alloc(pf->max_pf_txqs, GFP_KERNEL);
> +	rxqs = bitmap_alloc(pf->max_pf_rxqs, GFP_KERNEL);
> +	if (!txqs || !rxqs)
> +		goto out;
> +
> +	scoped_guard(mutex, &pf->avail_q_mutex) {
> +		bitmap_copy(txqs, pf->avail_txqs, pf->max_pf_txqs);
> +		bitmap_copy(rxqs, pf->avail_rxqs, pf->max_pf_rxqs);
> +	}

[Severity: Low]
The snapshot is taken under avail_q_mutex, but the result is used after
the mutex is dropped.

ice_vc_request_qs_msg() then sets vf->num_req_qs and calls
ice_reset_vf(). The real allocation happens later, in
ice_vsi_get_qs()->__ice_vsi_get_qs(), under avail_q_mutex again.

A PF VSI rebuild (ethtool -L, XDP rings, ADQ channel VSIs) or another
sriov_vf_msix_count write can take queues in between. In that case
__ice_vsi_get_qs_contig() fails, and this fallback runs:

	ret = __ice_vsi_get_qs_contig(qs_cfg);
	if (ret && qs_cfg->q_count <= qs_cfg->scatter_count) {
		qs_cfg->mapping_mode = ICE_VSI_MAP_SCATTER;

ice_ena_vf_q_mappings() does not program scatter mode for VFs. Larger
counts make the rebuild fail and leave the VF disabled.

Doesn't that make the guarantee in the commit message ("granted only
when the VF fits in one free range of PF queues") best effort only?

> +	for (int i = 0; i < vsi->alloc_txq; i++)
> +		clear_bit(vsi->txq_map[i], txqs);
> +	for (int i = 0; i < vsi->alloc_rxq; i++)
> +		clear_bit(vsi->rxq_map[i], rxqs);
> +
> +	for_each_clear_bitrange(b, e, txqs, pf->max_pf_txqs)
> +		max_tx = max(max_tx, e - b);
> +	for_each_clear_bitrange(b, e, rxqs, pf->max_pf_rxqs)
> +		max_rx = max(max_rx, e - b);
> +out:
> +	bitmap_free(txqs);
> +	bitmap_free(rxqs);
> +
> +	return min(max_tx, max_rx);
> +}

[Severity: Medium]
When ice_vf_rebuild_vsi() fails here, the VF VSI is left half torn
down. ice_vsi_rebuild() runs ice_vsi_decfg() before ice_vsi_cfg_def(),
and both ice_vsi_decfg() and the ice_vsi_cfg_def() unwind call
ice_vsi_free_arrays(). That leaves vsi->txq_map, vsi->rxq_map,
vsi->tx_rings, vsi->rx_rings and vsi->q_vectors NULL, while
vsi->alloc_txq, alloc_rxq, num_txq and num_rxq keep their old values.

This patch sets ICE_VF_STATE_DIS while preparing for the PF reset, and
clears it again here so that a VFLR can reset the VF. With the bit
clear, ice_is_vf_disabled() is false, and a VFLR from the guest runs
the full reset on that VSI:

ice_process_vflr_event()
  ice_reset_vf(vf, ICE_VF_RESET_VFLR | ICE_VF_RESET_LOCK)
    ice_dis_vf_qs()
      ice_vsi_stop_all_rx_rings()    reads vsi->rxq_map[i]
    ice_reset_interrupts()           reads vsi->txq_map[i], rxq_map[i]
    ice_vf_reconfig_vsi()
      ice_vsi_decfg()                second decfg
      ice_vsi_cfg()                  with ICE_VSI_FLAG_NO_INIT

Isn't that a NULL pointer dereference in the first two steps?

Even if those were guarded, the second ice_vsi_decfg() still runs
ice_vsi_put_qs() on the NULL maps and drops vsi->agg_node->num_vsis
again. ice_vsi_cfg() with ICE_VSI_FLAG_NO_INIT then ends in
ice_update_vsi() for a VSI that firmware lost on the PF reset. That VSI
was never added back with ICE_VSI_FLAG_INIT. So the VFLR does not seem
able to recover the VF.

The new ice_vf_max_contig_qs() has the same problem. A
sriov_vf_msix_count write for this VF walks vsi->txq_map[] and
vsi->rxq_map[] up to alloc_txq and alloc_rxq without a NULL check.

Should the VSI be put into a consistent state before the bit is
cleared? Or should ice_reset_vf() notice a VF whose VSI rebuild failed
and do a full rebuild with ICE_VSI_FLAG_INIT instead?

[Severity: Low]
When either bitmap_alloc() fails, this returns 0. Callers cannot tell
that apart from "no free contiguous range".

ice_sriov_set_msix_vec_count() then returns -ENOSPC instead of -ENOMEM.

ice_vc_request_qs_msg() sets max_allowed_vf_queues to 0. It then logs
"only 0 are free in one range" and replies to the VF with
num_queue_pairs = 0.

Should the allocation failure be reported separately, for example as a
negative errno?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261121230123.316391-1-przemyslaw.kitszel%40intel.com

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2026-11-24 21:57 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-21 22:55 [PATCH net-next v7 00/15] devlink, mlx5, iavf, ice: XLVF for iavf Przemek Kitszel
2026-11-21 22:55 ` [PATCH net-next v7 01/15] iavf: keep RSS config across resets Przemek Kitszel
2026-11-24 21:57   ` netdev-bot+sashiko
2026-11-21 22:55 ` [PATCH net-next v7 02/15] ice: prepare RSS LUT config for runtime LUT changes Przemek Kitszel
2026-11-24 21:57   ` netdev-bot+sashiko
2026-11-21 22:55 ` [PATCH net-next v7 03/15] ice: add VF queue ena/dis helper functions Przemek Kitszel
2026-11-21 22:55 ` [PATCH net-next v7 04/15] ice: add helpers for Global RSS LUT alloc, free, vsi_update Przemek Kitszel
2026-11-24 21:57   ` netdev-bot+sashiko
2026-11-21 22:55 ` [PATCH net-next v7 05/15] ice: rename ICE_MAX_RSS_QS_PER_VF to ICE_MAX_QS_PER_VF_VCV1 Przemek Kitszel
2026-11-21 22:55 ` [PATCH net-next v7 06/15] ice: bump to 256qs for VF Przemek Kitszel
2026-11-24 21:57   ` netdev-bot+sashiko
2026-11-21 22:55 ` [PATCH net-next v7 07/15] iavf: extend iavf_configure_queues() to support more queues Przemek Kitszel
2026-11-21 22:55 ` [PATCH net-next v7 08/15] iavf: temporary rename of IAVF_MAX_REQ_QUEUES to IAVF_MAX_REQ_QUEUES_VCV1 Przemek Kitszel
2026-11-21 22:55 ` [PATCH net-next v7 09/15] iavf: increase max number of queues to 256 Przemek Kitszel
2026-11-24 21:57   ` netdev-bot+sashiko
2026-11-21 22:55 ` [PATCH net-next v7 10/15] iavf: use new opcodes to request more than 16 queues Przemek Kitszel
2026-11-24 21:57   ` netdev-bot+sashiko
2026-11-21 22:55 ` [PATCH net-next v7 11/15] ice: introduce handling of virtchnl LARGE VF opcodes Przemek Kitszel
2026-11-24 21:57   ` netdev-bot+sashiko
2026-11-21 22:55 ` [PATCH net-next v7 12/15] devlink: add cmode to resources Przemek Kitszel
2026-11-24 21:57   ` netdev-bot+sashiko
2026-11-21 22:55 ` [PATCH net-next v7 13/15] ice: represent RSS LUTs as devlink resources Przemek Kitszel
2026-11-24 21:57   ` netdev-bot+sashiko
2026-11-21 22:55 ` [PATCH net-next v7 14/15] devlink: add devlink_alloc_drv() Przemek Kitszel
2026-11-21 22:55 ` [PATCH net-next v7 15/15] ice: support up to 256 VF queues Przemek Kitszel
2026-11-24 21:57   ` netdev-bot+sashiko
2026-11-23  8:53 ` [PATCH net-next v7 00/15] devlink, mlx5, iavf, ice: XLVF for iavf Matthieu Baerts
2026-11-23 15:03   ` Przemek Kitszel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox