netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: przemyslaw.kitszel@intel.com
Cc: kuba@kernel.org, netdev@vger.kernel.org,
	aleksandr.loktionov@intel.com, andrew+netdev@lunn.ch,
	anthony.l.nguyen@intel.com, anzaki@gmail.com,
	brett.creeley@amd.com, corbet@lwn.net, davem@davemloft.net,
	edumazet@kernel.org, horms@kernel.org, jacob.e.keller@intel.com,
	jedrzej.jagielski@intel.com, jiri@resnulli.us, leon@kernel.org,
	mbloch@nvidia.com, mschmidt@redhat.com, ohartoov@nvidia.com,
	pabeni@redhat.com, poros@redhat.com, rdunlap@infradead.org,
	saeedm@nvidia.com, skhan@linuxfoundation.org, tariqt@nvidia.com
Subject: Re: [net-next v6 11/15] ice: introduce handling of virtchnl LARGE VF opcodes
Date: Thu, 19 Nov 2026 06:45:02 +0000	[thread overview]
Message-ID: <179507070227.3136.5959529573012279667@kernel.org> (raw)
In-Reply-To: <20261117094913.100756-12-przemyslaw.kitszel@intel.com>

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

Critical: 0 · High: 0 · Medium: 2 · 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).

- [Medium] The patch widens struct ice_q_vector::num_ring_rx/num_ring_tx
  from u8 to u16.
- [Medium] ice_vc_validate_qs_v2_msg() bounds each chunk (start_queue_id
  + num_queues <= min(num_vf_qs, 256)), and the only limit on num_chunks…

--

ice: introduce handling of virtchnl LARGE VF opcodes

This adds PF-side handlers for VIRTCHNL_OP_ENABLE_QUEUES_V2,
VIRTCHNL_OP_DISABLE_QUEUES_V2 and VIRTCHNL_OP_MAP_QUEUE_VECTOR. They are
allowlisted under VIRTCHNL_VF_LARGE_NUM_QPAIRS so that VFs can use more
than 16 queues. It also widens num_ring_rx/num_ring_tx in struct
ice_q_vector to u16.

> diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h
> index 89a2bdbecf609..fc2e84136e247 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 */

[Severity: Medium]

The v5 notes say these fields were widened because mapping all 256 queues
of a VF to one vector made the counters wrap. The main writer of these
fields still truncates to u8, though:

drivers/net/ethernet/intel/ice/ice_base.c:ice_vsi_map_rings_to_vectors() {
    ...
		u8 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);
		q_vector->num_ring_tx = tx_rings_per_v;
    ...
		for (q_id = q_base; q_id < (q_base + tx_rings_per_v); q_id++) {
    ...
}

With 256 rings and one q_vector, DIV_ROUND_UP(256, 1) cast to u8 is 0.
That sets num_ring_tx to 0, links no rings and leaves ring->q_vector
unchanged. The Rx side has the same problem.

This function also runs on VF VSIs. ice_pf_dcb_recfg() calls it for every
VSI except ICE_VSI_CHNL. On resume, ice_reinit_interrupt_scheme() calls it
for every VSI right after it re-allocates the q_vectors.

Readers then use the truncated count. For example, ice_vsi_release_msix(),
which ice_vsi_free_irq() also calls for VF VSIs, does this:

	for (q = 0; q < q_vector->num_ring_tx; q++) {
		ice_write_itr(&q_vector->tx, 0);
		wr32(hw, QINT_TQCTL(vsi->txq_map[txq]), 0);

Wouldn't this skip clearing QINT_TQCTL/QINT_RQCTL for every one of these
queues?

On the resume path, can rings be left with ring->q_vector pointing at
q_vectors that were freed at suspend? ice_free_q_vector() only clears the
pointer for rings on the linked list, and VF rings mapped through virtchnl
are never on that list.

At the end of the series, this needs a VF with the PF LUT
(ICE_LUT_PF_MAX_QS = 256) and ICE_MIN_INTR_PER_VF MSI-X vectors, so
num_q_vectors = 1. The VF requests 256 queues, and then a DCB
reconfiguration or a suspend/resume runs. The u8 locals and the (u8) casts
in ice_vsi_map_rings_to_vectors() are still there at the end of the
series.

Should tx_rings_per_v/rx_rings_per_v and the casts be widened to u16 in
this patch as well?

[ ... ]

> diff --git a/drivers/net/ethernet/intel/ice/virt/queues.c b/drivers/net/ethernet/intel/ice/virt/queues.c
> index 7f2b459dbc836..f87ccf5d370bb 100644
> --- a/drivers/net/ethernet/intel/ice/virt/queues.c
> +++ b/drivers/net/ethernet/intel/ice/virt/queues.c
> @@ -1046,3 +1046,342 @@ int ice_vc_request_qs_msg(struct ice_vf *vf, u8 *msg)

[ ... ]

> +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);
> +
> +	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;

[ ... ]

> +	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;
> +	}

[Severity: Medium]

Each chunk is bounds-checked here. Is anything rejecting duplicate or
overlapping chunks? The only limit on num_chunks is msglen.

For VIRTCHNL_OP_DISABLE_QUEUES_V2, ice_vc_dis_txq_chunk() calls
ice_vf_vsi_dis_single_txq() for every queue in every chunk. That helper
does not return early for queues that are already disabled:

drivers/net/ethernet/intel/ice/virt/queues.c:ice_vf_vsi_dis_single_txq() {
	if (!test_bit(q_id, vf->txq_ena))
		dev_dbg(ice_pf_to_dev(vsi->back), "Queue %u on VSI %u is not enabled, but stopping it anyway\n",
			q_id, vsi->vsi_num);
	...
	err = ice_vsi_stop_tx_ring(vsi, ICE_NO_RESET, vf->vf_id, ring, &txq_meta);
	...
}

Each ice_vsi_stop_tx_ring() call does an MMIO read-modify-write of
QINT_TQCTL, an ndelay(100), ice_trigger_sw_intr() and ice_dis_vsi_txq().
ice_dis_vsi_txq() takes pi->sched_lock and searches the Tx scheduler tree
with ice_sched_find_node_by_teid().

A 4 KiB mailbox message can hold the 8 byte header plus about 511 chunks,
each set to {type TX, start 0, num max_qs}. With 256 queues, that is about
130k stop-ring operations from one message. They run in the PF service
task with vf->cfg_lock held.

The v1 DISABLE_QUEUES bitmap limits this to at most 16 queues, and each
one is processed once.

Can a VF keep sending this message to keep the PF service task busy? That
would delay mailbox handling for other VFs, as well as AdminQ events and
resets. The validation and the Tx disable helper are unchanged at the end
of the series.

Could the validation build a bitmap of the requested queues and reject
overlapping chunks? Another option is to skip queues that are not set in
vf->txq_ena on the v2 path.

[ ... ]

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

  reply	other threads:[~2026-11-19  6:45 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17  9:44 [net-next v6 00/15] devlink, mlx5, iavf, ice: XLVF for iavf Przemek Kitszel
2026-11-17  9:44 ` [net-next v6 01/15] devlink, mlx5: add init/fini ops for shared devlink Przemek Kitszel
2026-11-17  9:44 ` [net-next v6 02/15] ice: use shared devlink to store ice_adapters instead of custom xarray Przemek Kitszel
2026-11-17  9:44 ` [net-next v6 03/15] ice: add VF queue ena/dis helper functions Przemek Kitszel
2026-11-17  9:44 ` [net-next v6 04/15] ice: add helpers for Global RSS LUT alloc, free, vsi_update Przemek Kitszel
2026-11-17  9:44 ` [net-next v6 05/15] ice: rename ICE_MAX_RSS_QS_PER_VF to ICE_MAX_QS_PER_VF_VCV1 Przemek Kitszel
2026-11-19  6:44   ` netdev-bot+sashiko
2026-11-17  9:44 ` [net-next v6 06/15] ice: bump to 256qs for VF Przemek Kitszel
2026-11-19  6:44   ` netdev-bot+sashiko
2026-11-17  9:44 ` [net-next v6 07/15] iavf: extend iavf_configure_queues() to support more queues Przemek Kitszel
2026-11-17  9:44 ` [net-next v6 08/15] iavf: temporary rename of IAVF_MAX_REQ_QUEUES to IAVF_MAX_REQ_QUEUES_VCV1 Przemek Kitszel
2026-11-17  9:44 ` [net-next v6 09/15] iavf: increase max number of queues to 256 Przemek Kitszel
2026-11-19  6:44   ` netdev-bot+sashiko
2026-11-17  9:44 ` [net-next v6 10/15] iavf: use new opcodes to request more than 16 queues Przemek Kitszel
2026-11-19  6:45   ` netdev-bot+sashiko
2026-11-17  9:44 ` [net-next v6 11/15] ice: introduce handling of virtchnl LARGE VF opcodes Przemek Kitszel
2026-11-19  6:45   ` netdev-bot+sashiko [this message]
2026-11-17  9:44 ` [net-next v6 12/15] devlink: give user option to allocate resources Przemek Kitszel
2026-11-19  6:45   ` netdev-bot+sashiko
2026-11-17  9:44 ` [net-next v6 13/15] ice: represent RSS LUTs as devlink resources Przemek Kitszel
2026-11-19  6:45   ` netdev-bot+sashiko
2026-11-17  9:44 ` [net-next v6 14/15] devlink: add devlink_alloc_drv() Przemek Kitszel
2026-11-19  6:45   ` netdev-bot+sashiko
2026-11-17  9:44 ` [net-next v6 15/15] ice: support up to 256 VF queues Przemek Kitszel
2026-11-19  6:45   ` netdev-bot+sashiko

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=179507070227.3136.5959529573012279667@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --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=jacob.e.keller@intel.com \
    --cc=jedrzej.jagielski@intel.com \
    --cc=jiri@resnulli.us \
    --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=poros@redhat.com \
    --cc=przemyslaw.kitszel@intel.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;
as well as URLs for NNTP newsgroup(s).