[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aQRdnj99v64Ozvj/@test-OptiPlex-Tower-Plus-7010>
Date: Fri, 31 Oct 2025 12:26:30 +0530
From: Hariprasad Kelam <hkelam@...vell.com>
To: Zijian Zhang <zijianzhang@...edance.com>
CC: <netdev@...r.kernel.org>, <davem@...emloft.net>, <kuba@...nel.org>,
<pabeni@...hat.com>, <edumazet@...gle.com>, <andrew+netdev@...n.ch>,
<saeedm@...dia.com>, <gal@...dia.com>, <leonro@...dia.com>,
<witu@...dia.com>, <parav@...dia.com>, <tariqt@...dia.com>
Subject: Re: [PATCH net-next] net/mlx5e: Modify mlx5e_xdp_xmit sq selection
On 2025-10-31 at 06:12:50, Zijian Zhang (zijianzhang@...edance.com) wrote:
> From: Zijian Zhang <zijianzhang@...edance.com>
>
> When performing XDP_REDIRECT from one mlnx device to another, using
> smp_processor_id() to select the queue may go out-of-range.
>
> Assume eth0 is redirecting a packet to eth1, eth1 is configured
> with only 8 channels, while eth0 has its RX queues pinned to
> higher-numbered CPUs (e.g. CPU 12). When a packet is received on
> such a CPU and redirected to eth1, the driver uses smp_processor_id()
> as the SQ index. Since the CPU ID is larger than the number of queues
> on eth1, the lookup (priv->channels.c[sq_num]) goes out of range and
> the redirect fails.
>
> This patch fixes the issue by mapping the CPU ID to a valid channel
> index using modulo arithmetic:
>
> sq_num = smp_processor_id() % priv->channels.num;
>
> With this change, XDP_REDIRECT works correctly even when the source
> device uses high CPU affinities and the target device has fewer TX
> queues.
>
> Signed-off-by: Zijian Zhang <zijianzhang@...edance.com>
> ---
> drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c
> b/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c
> index 5d51600935a6..61394257c65f 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c
> @@ -855,11 +855,7 @@ int mlx5e_xdp_xmit(struct net_device *dev, int n,
> struct xdp_frame **frames,
> if (unlikely(flags & ~XDP_XMIT_FLAGS_MASK))
> return -EINVAL;
>
> - sq_num = smp_processor_id();
> -
> - if (unlikely(sq_num >= priv->channels.num))
> - return -ENXIO;
> -
> + sq_num = smp_processor_id() % priv->channels.num;
> sq = priv->channels.c[sq_num]->xdpsq;
>
> for (i = 0; i < n; i++) {
Reviewed-by: Hariprasad Kelam <hkelam@...vell.com>
Powered by blists - more mailing lists