From: Przemek Kitszel <przemyslaw.kitszel@intel.com>
To: netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>,
Jiri Pirko <jiri@resnulli.us>
Cc: Tony Nguyen <anthony.l.nguyen@intel.com>,
Aleksandr Loktionov <aleksandr.loktionov@intel.com>,
Michal Schmidt <mschmidt@redhat.com>,
intel-wired-lan@lists.osuosl.org, edumazet@kernel.org,
horms@kernel.org, pabeni@redhat.com, davem@davemloft.net,
Jonathan Corbet <corbet@lwn.net>,
skhan@linuxfoundation.org, rdunlap@infradead.org,
andrew+netdev@lunn.ch, saeedm@nvidia.com, tariqt@nvidia.com,
leon@kernel.org, mbloch@nvidia.com, jacob.e.keller@intel.com,
jedrzej.jagielski@intel.com, anzaki@gmail.com,
brett.creeley@amd.com, jtornosm@redhat.com, ohartoov@nvidia.com,
Przemek Kitszel <przemyslaw.kitszel@intel.com>
Subject: [PATCH net-next v2 07/14] iavf: extend iavf_configure_queues() to support more queues
Date: Fri, 9 Oct 2026 14:04:18 +0200 [thread overview]
Message-ID: <20261009121433.30347-8-przemyslaw.kitszel@intel.com> (raw)
In-Reply-To: <20261009121433.30347-1-przemyslaw.kitszel@intel.com>
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 the messages one by one, waiting for the PF reply to each of them
with iavf_poll_virtchnl_response(), similar to iavf_set_mac_sync().
That keeps only one virtchnl op in flight, without the need to track
across watchdog runs what was already sent (as iavf_add_ether_addrs()
does for MAC filters). So the op becomes synchronous also for the
single message case: the watchdog, holding netdev_lock, waits up to 1s
for each reply.
Stop at the first PF NACK, without a retry, as before. On timeout keep
the op pending, as PF may still reply; once it does, the whole
configuration is resent.
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.
Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
---
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)
---
.../net/ethernet/intel/iavf/iavf_virtchnl.c | 86 ++++++++++++++++---
1 file changed, 75 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
index e6b7e8f82c7c..67d797a1003f 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
@@ -8,6 +8,19 @@
#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)
+
+static bool iavf_match_vc_op_cb(struct iavf_adapter *adapter, const void *data,
+ enum virtchnl_ops recv_op)
+{
+ enum virtchnl_ops wanted_op = (enum virtchnl_ops)(uintptr_t)data;
+
+ return recv_op == wanted_op;
+}
+
/**
* iavf_send_pf_msg
* @adapter: adapter structure
@@ -377,8 +390,10 @@ 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;
- u32 i, max_frame;
+ struct iavf_arq_event_info event;
+ int max_pairs, err = 0;
u8 rx_flags = 0;
+ u32 max_frame;
size_t len;
max_frame = LIBIE_MAX_RX_FRM_LEN(adapter->rx_rings->pp->p.offset);
@@ -390,22 +405,30 @@ void iavf_configure_queues(struct iavf_adapter *adapter)
adapter->current_op);
return;
}
- adapter->current_op = VIRTCHNL_OP_CONFIG_VSI_QUEUES;
- len = virtchnl_struct_size(vqci, qpair, pairs);
+
+ max_pairs = iavf_max_vc_entries(vqci, qpair);
+ len = virtchnl_struct_size(vqci, qpair, min(pairs, max_pairs));
vqci = kzalloc(len, GFP_KERNEL);
if (!vqci)
return;
+ /* any message may arrive while polling, not only the awaited one */
+ event.buf_len = IAVF_MAX_AQ_BUF_SIZE;
+ event.msg_buf = kzalloc(IAVF_MAX_AQ_BUF_SIZE, GFP_KERNEL);
+ if (!event.msg_buf) {
+ kfree(vqci);
+ return;
+ }
+
if (iavf_ptp_cap_supported(adapter, VIRTCHNL_1588_PTP_CAP_RX_TSTAMP))
rx_flags |= VIRTCHNL_PTP_RX_TSTAMP;
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 (int i = 0, in_msg = 0; i < pairs; i++) {
+ const bool last = i + 1 == pairs;
+
vqpi->txq.vsi_id = vqci->vsi_id;
vqpi->txq.queue_id = i;
vqpi->txq.ring_len = adapter->tx_rings[i].count;
@@ -423,11 +446,52 @@ void iavf_configure_queues(struct iavf_adapter *adapter)
NETIF_F_RXFCS);
vqpi->rxq.flags = rx_flags;
vqpi++;
+ in_msg++;
+ if (last || in_msg == max_pairs) {
+ adapter->current_op = VIRTCHNL_OP_CONFIG_VSI_QUEUES;
+ vqci->num_queue_pairs = in_msg;
+
+ err = iavf_send_pf_msg(adapter,
+ VIRTCHNL_OP_CONFIG_VSI_QUEUES,
+ (u8 *)vqci,
+ virtchnl_struct_size(vqci, qpair, in_msg));
+ if (err) {
+ dev_err(&adapter->pdev->dev,
+ "sending VC msg to PF failed, err: %d\n",
+ err);
+ break;
+ }
+
+ err = iavf_poll_virtchnl_response(adapter, &event,
+ iavf_match_vc_op_cb,
+ (void *)VIRTCHNL_OP_CONFIG_VSI_QUEUES,
+ 1000);
+ if (err) {
+ dev_err(&adapter->pdev->dev,
+ "config queues poll failed, err: %d\n",
+ err);
+ break;
+ }
+
+ /* PF NACK, iavf_virtchnl_completion() has logged it */
+ if (event.desc.cookie_low) {
+ err = -EIO;
+ break;
+ }
+
+ vqpi = vqci->qpair;
+ in_msg = 0;
+ }
}
- adapter->aq_required &= ~IAVF_FLAG_AQ_CONFIGURE_QUEUES;
- iavf_send_pf_msg(adapter, VIRTCHNL_OP_CONFIG_VSI_QUEUES,
- (u8 *)vqci, len);
+ /* keep the op pending on timeout, as PF may still reply, the whole
+ * config is resent once it does
+ */
+ if (err != -EAGAIN) {
+ adapter->aq_required &= ~IAVF_FLAG_AQ_CONFIGURE_QUEUES;
+ adapter->current_op = VIRTCHNL_OP_UNKNOWN;
+ }
+ kfree(event.msg_buf);
kfree(vqci);
}
--
2.51.1
next prev parent reply other threads:[~2026-10-09 12:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 12:04 [PATCH net-next v2 00/14] devlink, mlx5, iavf, ice: XLVF for iavf Przemek Kitszel
2026-10-09 12:04 ` [PATCH net-next v2 01/14] devlink, mlx5: add init/fini ops for shared devlink Przemek Kitszel
2026-10-09 12:04 ` [PATCH net-next v2 02/14] ice: use shared devlink to store ice_adapters instead of custom xarray Przemek Kitszel
2026-10-09 12:04 ` [PATCH net-next v2 03/14] ice: add VF queue ena/dis helper functions Przemek Kitszel
2026-10-09 12:04 ` [PATCH net-next v2 04/14] ice: add helpers for Global RSS LUT alloc, free, vsi_update Przemek Kitszel
2026-10-09 12:04 ` [PATCH net-next v2 05/14] ice: rename ICE_MAX_RSS_QS_PER_VF to ICE_MAX_QS_PER_VF_VCV1 Przemek Kitszel
2026-10-09 12:04 ` [PATCH net-next v2 06/14] ice: bump to 256qs for VF Przemek Kitszel
2026-10-09 12:04 ` Przemek Kitszel [this message]
2026-10-09 12:04 ` [PATCH net-next v2 08/14] iavf: temporary rename of IAVF_MAX_REQ_QUEUES to IAVF_MAX_REQ_QUEUES_VCV1 Przemek Kitszel
2026-10-09 12:04 ` [PATCH net-next v2 09/14] iavf: increase max number of queues to 256 Przemek Kitszel
2026-10-09 12:04 ` [PATCH net-next v2 10/14] iavf: use new opcodes to request more than 16 queues Przemek Kitszel
2026-10-09 12:04 ` [PATCH net-next v2 11/14] ice: introduce handling of virtchnl LARGE VF opcodes Przemek Kitszel
2026-10-09 12:04 ` [PATCH net-next v2 12/14] devlink: give user option to allocate resources Przemek Kitszel
2026-10-09 12:04 ` [PATCH net-next v2 13/14] ice: represent RSS LUTs as devlink resources Przemek Kitszel
2026-10-09 12:04 ` [PATCH net-next v2 14/14] ice: support up to 256 VF queues Przemek Kitszel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261009121433.30347-8-przemyslaw.kitszel@intel.com \
--to=przemyslaw.kitszel@intel.com \
--cc=aleksandr.loktionov@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=anthony.l.nguyen@intel.com \
--cc=anzaki@gmail.com \
--cc=brett.creeley@amd.com \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=jacob.e.keller@intel.com \
--cc=jedrzej.jagielski@intel.com \
--cc=jiri@resnulli.us \
--cc=jtornosm@redhat.com \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=mbloch@nvidia.com \
--cc=mschmidt@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=ohartoov@nvidia.com \
--cc=pabeni@redhat.com \
--cc=rdunlap@infradead.org \
--cc=saeedm@nvidia.com \
--cc=skhan@linuxfoundation.org \
--cc=tariqt@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox