Skip to content

Commit 1f09049

Browse files
walking-machinekuba-moo
authored andcommitted
ice: xsk: Fix cleaning of XDP_TX frames
Incrementation of xsk_frames inside the for-loop produces infinite loop, if we have both normal AF_XDP-TX and XDP_TXed buffers to complete. Split xsk_frames into 2 variables (xsk_frames and completed_frames) to eliminate this bug. Fixes: 2932279 ("ice: xsk: change batched Tx descriptor cleaning") Acked-by: Maciej Fijalkowski <[email protected]> Signed-off-by: Larysa Zaremba <[email protected]> Reviewed-by: Alexander Duyck <[email protected]> Acked-by: Tony Nguyen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent ee05917 commit 1f09049

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

drivers/net/ethernet/intel/ice/ice_xsk.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,7 @@ static void ice_clean_xdp_irq_zc(struct ice_tx_ring *xdp_ring)
800800
struct ice_tx_desc *tx_desc;
801801
u16 cnt = xdp_ring->count;
802802
struct ice_tx_buf *tx_buf;
803+
u16 completed_frames = 0;
803804
u16 xsk_frames = 0;
804805
u16 last_rs;
805806
int i;
@@ -809,19 +810,21 @@ static void ice_clean_xdp_irq_zc(struct ice_tx_ring *xdp_ring)
809810
if ((tx_desc->cmd_type_offset_bsz &
810811
cpu_to_le64(ICE_TX_DESC_DTYPE_DESC_DONE))) {
811812
if (last_rs >= ntc)
812-
xsk_frames = last_rs - ntc + 1;
813+
completed_frames = last_rs - ntc + 1;
813814
else
814-
xsk_frames = last_rs + cnt - ntc + 1;
815+
completed_frames = last_rs + cnt - ntc + 1;
815816
}
816817

817-
if (!xsk_frames)
818+
if (!completed_frames)
818819
return;
819820

820-
if (likely(!xdp_ring->xdp_tx_active))
821+
if (likely(!xdp_ring->xdp_tx_active)) {
822+
xsk_frames = completed_frames;
821823
goto skip;
824+
}
822825

823826
ntc = xdp_ring->next_to_clean;
824-
for (i = 0; i < xsk_frames; i++) {
827+
for (i = 0; i < completed_frames; i++) {
825828
tx_buf = &xdp_ring->tx_buf[ntc];
826829

827830
if (tx_buf->raw_buf) {
@@ -837,7 +840,7 @@ static void ice_clean_xdp_irq_zc(struct ice_tx_ring *xdp_ring)
837840
}
838841
skip:
839842
tx_desc->cmd_type_offset_bsz = 0;
840-
xdp_ring->next_to_clean += xsk_frames;
843+
xdp_ring->next_to_clean += completed_frames;
841844
if (xdp_ring->next_to_clean >= cnt)
842845
xdp_ring->next_to_clean -= cnt;
843846
if (xsk_frames)

0 commit comments

Comments
 (0)