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. Fixes: 9d2b68cc108d ("net: enetc: add support for XDP_REDIRECT") Signed-off-by: Vladimir Oltean --- v1->v2: patch is new --- drivers/net/ethernet/freescale/enetc/enetc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index ac6cad5605e4..5b97f9e668ba 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -1823,7 +1823,8 @@ int enetc_xdp_xmit(struct net_device *ndev, int num_frames, xdp_tx_frm_cnt++; } - if (unlikely((flags & XDP_XMIT_FLUSH) || k != xdp_tx_frm_cnt)) + if (unlikely(xdp_tx_frm_cnt && ((flags & XDP_XMIT_FLUSH) || + xdp_tx_frm_cnt < num_frames))) enetc_update_tx_ring_tail(tx_ring); tx_ring->stats.xdp_tx += xdp_tx_frm_cnt; -- 2.43.0