Skip to content

Commit 3b7c13d

Browse files
JasonXingkuba-moo
authored andcommitted
igb: xsk: solve negative overflow of nb_pkts in zerocopy mode
There is no break time in the while() loop, so every time at the end of igb_xmit_zc(), negative overflow of nb_pkts will occur, which renders the return value always false. But theoretically, the result should be set after calling xsk_tx_peek_release_desc_batch(). We can take i40e_xmit_zc() as a good example. Returning false means we're not done with transmission and we need one more poll, which is exactly what igb_xmit_zc() always did before this patch. After this patch, the return value depends on the nb_pkts value. Two cases might happen then: 1. if (nb_pkts < budget), it means we process all the possible data, so return true and no more necessary poll will be triggered because of this. 2. if (nb_pkts == budget), it means we might have more data, so return false to let another poll run again. Fixes: f8e284a ("igb: Add AF_XDP zero-copy Tx support") Signed-off-by: Jason Xing <[email protected]> Reviewed-by: Aleksandr Loktionov <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 2764ab5 commit 3b7c13d

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/net/ethernet/intel/igb/igb_xsk.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ bool igb_xmit_zc(struct igb_ring *tx_ring, struct xsk_buff_pool *xsk_pool)
482482
if (!nb_pkts)
483483
return true;
484484

485-
while (nb_pkts-- > 0) {
485+
for (; i < nb_pkts; i++) {
486486
dma = xsk_buff_raw_get_dma(xsk_pool, descs[i].addr);
487487
xsk_buff_raw_dma_sync_for_device(xsk_pool, dma, descs[i].len);
488488

@@ -512,7 +512,6 @@ bool igb_xmit_zc(struct igb_ring *tx_ring, struct xsk_buff_pool *xsk_pool)
512512

513513
total_bytes += descs[i].len;
514514

515-
i++;
516515
tx_ring->next_to_use++;
517516
tx_buffer_info->next_to_watch = tx_desc;
518517
if (tx_ring->next_to_use == tx_ring->count)

0 commit comments

Comments
 (0)