Skip to content

Commit 958b3d3

Browse files
Brenden Blancodavem330
authored andcommitted
net/mlx4_en: fixup xdp tx irq to match rx
In cases where the number of tx rings is not a multiple of the number of rx rings, the tx completion event will be handled on a different core from the transmit and population of the ring. Races on the ring will lead to a double-free of the page, and possibly other corruption. The rings are initialized by default with a valid multiple of rings, based on the number of cpus, therefore an invalid configuration requires ethtool to change the ring layout. For instance 'ethtool -L eth0 rx 9 tx 8' will cause packets received on rx0, and XDP_TX'd to tx48, to be completed on cpu3 (48 % 9 == 3). Resolve this discrepancy by shifting the irq for the xdp tx queues to start again from 0, modulo rx_ring_num. Fixes: 9ecc2d8 ("net/mlx4_en: add xdp forwarding and data write support") Reported-by: Jesper Dangaard Brouer <[email protected]> Signed-off-by: Brenden Blanco <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fbbfa34 commit 958b3d3

File tree

1 file changed

+9
-1
lines changed
  • drivers/net/ethernet/mellanox/mlx4

1 file changed

+9
-1
lines changed

drivers/net/ethernet/mellanox/mlx4/en_cq.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,15 @@ int mlx4_en_activate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq,
127127
/* For TX we use the same irq per
128128
ring we assigned for the RX */
129129
struct mlx4_en_cq *rx_cq;
130-
130+
int xdp_index;
131+
132+
/* The xdp tx irq must align with the rx ring that forwards to
133+
* it, so reindex these from 0. This should only happen when
134+
* tx_ring_num is not a multiple of rx_ring_num.
135+
*/
136+
xdp_index = (priv->xdp_ring_num - priv->tx_ring_num) + cq_idx;
137+
if (xdp_index >= 0)
138+
cq_idx = xdp_index;
131139
cq_idx = cq_idx % priv->rx_ring_num;
132140
rx_cq = priv->rx_cq[cq_idx];
133141
cq->vector = rx_cq->vector;

0 commit comments

Comments
 (0)