Commit 27d4073f authored by Ray Jui's avatar Ray Jui Committed by David S. Miller

bnxt_en: Prevent XDP redirect from running when stopping TX queue

Add checks in the XDP redirect callback to prevent XDP from running when
the TX ring is undergoing shutdown.

Also remove redundant checks in the XDP redirect callback to validate the
txr and the flag that indicates the ring supports XDP. The modulo
arithmetic on 'tx_nr_rings_xdp' already guarantees the derived TX
ring is an XDP ring.  txr is also guaranteed to be valid after checking
BNXT_STATE_OPEN and within RCU grace period.

Fixes: f18c2b77 ("bnxt_en: optimized XDP_REDIRECT support")
Reviewed-by: default avatarVladimir Olovyannikov <vladimir.olovyannikov@broadcom.com>
Signed-off-by: default avatarRay Jui <ray.jui@broadcom.com>
Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent facc173c
...@@ -229,14 +229,16 @@ int bnxt_xdp_xmit(struct net_device *dev, int num_frames, ...@@ -229,14 +229,16 @@ int bnxt_xdp_xmit(struct net_device *dev, int num_frames,
ring = smp_processor_id() % bp->tx_nr_rings_xdp; ring = smp_processor_id() % bp->tx_nr_rings_xdp;
txr = &bp->tx_ring[ring]; txr = &bp->tx_ring[ring];
if (READ_ONCE(txr->dev_state) == BNXT_DEV_STATE_CLOSING)
return -EINVAL;
if (static_branch_unlikely(&bnxt_xdp_locking_key)) if (static_branch_unlikely(&bnxt_xdp_locking_key))
spin_lock(&txr->xdp_tx_lock); spin_lock(&txr->xdp_tx_lock);
for (i = 0; i < num_frames; i++) { for (i = 0; i < num_frames; i++) {
struct xdp_frame *xdp = frames[i]; struct xdp_frame *xdp = frames[i];
if (!txr || !bnxt_tx_avail(bp, txr) || if (!bnxt_tx_avail(bp, txr))
!(bp->bnapi[ring]->flags & BNXT_NAPI_FLAG_XDP))
break; break;
mapping = dma_map_single(&pdev->dev, xdp->data, xdp->len, mapping = dma_map_single(&pdev->dev, xdp->data, xdp->len,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment