enetc_xdp_xmit() keeps track of 3 numbers: - num_frames: total length of passed struct xdp_frame **frames array - xdp_tx_frm_cnt: number of frames successfully sent - k: index of currently sent frame from array With "k != xdp_tx_frm_cnt", the intention was to detect an early break due to an inability to send a frame, and to trigger a TX doorbell anyway. However, that doesn't work because every time when the loop breaks, k and xdp_tx_frm_cnt are mathematically equal. The correct condition on which we should ring the doorbell is when at least one frame was sent, and either the caller required us to flush, or we couldn't enqueue the entire passed array. After updating the enetc_update_tx_ring_tail() calling condition, we can delete the 'xdp_tx_frm_cnt' variable, since it is equal to 'k' after the loop exits. Fixes: 9d2b68cc108d ("net: enetc: add support for XDP_REDIRECT") Signed-off-by: Vladimir Oltean --- v2->v3: delete redundant xdp_tx_frm_cnt variable v1->v2: patch is new --- drivers/net/ethernet/freescale/enetc/enetc.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index e7ecdf8ef67c..c9c23e994f6d 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -1813,7 +1813,6 @@ int enetc_xdp_xmit(struct net_device *ndev, int num_frames, struct skb_shared_info *shinfo; struct enetc_bdr *tx_ring; int xdp_tx_bd_cnt, i, k; - int xdp_tx_frm_cnt = 0; if (unlikely(test_bit(ENETC_TX_DOWN, &priv->flags) || !netif_carrier_ok(ndev))) @@ -1845,19 +1844,17 @@ int enetc_xdp_xmit(struct net_device *ndev, int num_frames, &xdp_redirect_arr[i]); break; } - - xdp_tx_frm_cnt++; } - if (unlikely((flags & XDP_XMIT_FLUSH) || k != xdp_tx_frm_cnt)) + if (unlikely(k && ((flags & XDP_XMIT_FLUSH) || k < num_frames))) enetc_update_tx_ring_tail(tx_ring); - tx_ring->stats.xdp_tx += xdp_tx_frm_cnt; - tx_ring->stats.xdp_tx_drops += num_frames - xdp_tx_frm_cnt; + tx_ring->stats.xdp_tx += k; + tx_ring->stats.xdp_tx_drops += num_frames - k; enetc_unlock_mdio(); - return xdp_tx_frm_cnt; + return k; } EXPORT_SYMBOL_GPL(enetc_xdp_xmit); -- 2.43.0