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] After this patch, the stack's Rx queue count and igb's ring count
can disagree until the next open.
--
igb: keep the stack's Rx queues that still have an XSK pool
This patch adds igb_set_real_num_queues(). When igb lowers its own queue
counts after a VF enable or an MSI-X to MSI fallback on resume, the helper
keeps the stack's real Rx queue count up to the highest queue that still
has a zero-copy XSK pool. That way the pool can still be found and
disabled, and the count is lowered at the next open.
Closes: https://lore.kernel.org/netdev/xupy…@zptk6ynkbu5f/
> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
> index 5774a4d3c9810..9752350ffc68b 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
> @@ -4128,6 +4128,29 @@ static int igb_sw_init(struct igb_adapter *adapter)
> return 0;
> }
>
> +/* ethtool refuses to remove a queue that still has an XSK pool. igb can't
> + * refuse when it lowers its queue counts by itself, so keep the stack's Rx
> + * queue instead, or a zero-copy pool couldn't be disabled anymore: lower the
> + * count once it's gone, at the next open.
> + */
> +static int igb_set_real_num_queues(struct igb_adapter *adapter)
> +{
> + struct net_device *netdev = adapter->netdev;
> + unsigned int rxq = adapter->num_rx_queues;
> + struct xsk_buff_pool *pool;
> + unsigned int i;
> +
> + for (i = netdev->real_num_rx_queues; i > rxq; i--) {
> + pool = xsk_get_pool_from_qid(netdev, i - 1);
> + if (pool && pool->umem->zc) {
> + rxq = i;
> + break;
> + }
> + }
> +
> + return netif_set_real_num_queues(netdev, adapter->num_tx_queues, rxq);
[Severity: Low]
Until the next open, can this leave the stack advertising Rx queues that
have no ring behind them?
For example, say a zero-copy pool is bound to queue 2. A VF enable or an
MSI-X to MSI fallback then lowers adapter->num_rx_queues to 1, but
real_num_rx_queues stays at 3. Queue 1 has no ring, yet the stack still
counts it as real.
In that window, a new AF_XDP bind to queue 1 passes the check in
xsk_reg_pool_at_qid():
net/xdp/xsk.c:xsk_reg_pool_at_qid() {
...
if (queue_id >= max(dev->real_num_rx_queues,
dev->real_num_tx_queues))
return -EINVAL;
...
}
With XDP_COPY, xp_assign_dev() returns 0 straight away. With default
flags, ndo_bpf(XDP_SETUP_XSK_POOL) reaches igb_xsk_pool_enable(), which
rejects the queue:
drivers/net/ethernet/intel/igb/igb_xsk.c:igb_xsk_pool_enable() {
...
if (qid >= adapter->num_rx_queues)
return -EINVAL;
...
}
xp_assign_dev() then falls back to copy mode and returns 0.
So the bind succeeds, but the socket never gets any Rx traffic, because no
ring has queue_index 1. On Tx, real_num_tx_queues follows the device, so
__xsk_generic_xmit() skips the socket and returns no error:
net/xdp/xsk.c:__xsk_generic_xmit() {
...
if (xs->queue_id >= xs->dev->real_num_tx_queues)
goto out;
...
}
Before this patch, igb would have lowered real_num_rx_queues to 1 and the
same bind would have failed with -EINVAL.
Is this window intended? Or should binds to queues at or above
adapter->num_rx_queues still be refused while the count is held up?
> +}
> +
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/2026…%40mandelbit.com