Skip to content

Commit 39edd6a

Browse files
mfijalkoNobody
authored andcommitted
ice: xsk: borrow xdp_tx_active logic from i40e
One of the things that commit 5574ff7 ("i40e: optimize AF_XDP Tx completion path") introduced was the @xdp_tx_active field. Its usage from i40e can be adjusted to ice driver and give us positive performance results. If the descriptor that @next_dd to points has been sent by HW (its DD bit is set), then we are sure that there are ICE_TX_THRESH count of descriptors ready to be cleaned. If @xdp_tx_active is 0 which means that related xdp_ring is not used for XDP_{TX, REDIRECT} workloads, then we know how many XSK entries should placed to completion queue, IOW walking through the ring can be skipped. Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
1 parent 22f859b commit 39edd6a

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

drivers/net/ethernet/intel/ice/ice_txrx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ struct ice_tx_ring {
334334
spinlock_t tx_lock;
335335
u16 tx_thresh;
336336
u32 txq_teid; /* Added Tx queue TEID */
337+
u16 xdp_tx_active;
337338
#define ICE_TX_FLAGS_RING_XDP BIT(0)
338339
u8 flags;
339340
u8 dcb_tc; /* Traffic class of ring */

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ int ice_xmit_xdp_ring(void *data, u16 size, struct ice_tx_ring *xdp_ring)
302302
tx_desc->cmd_type_offset_bsz = ice_build_ctob(ICE_TX_DESC_CMD_EOP, 0,
303303
size, 0);
304304

305+
xdp_ring->xdp_tx_active++;
305306
i++;
306307
if (i == xdp_ring->count) {
307308
i = 0;

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,7 @@ static void
679679
ice_clean_xdp_tx_buf(struct ice_tx_ring *xdp_ring, struct ice_tx_buf *tx_buf)
680680
{
681681
xdp_return_frame((struct xdp_frame *)tx_buf->raw_buf);
682+
xdp_ring->xdp_tx_active--;
682683
dma_unmap_single(xdp_ring->dev, dma_unmap_addr(tx_buf, dma),
683684
dma_unmap_len(tx_buf, len), DMA_TO_DEVICE);
684685
dma_unmap_len_set(tx_buf, len, 0);
@@ -695,12 +696,11 @@ static u16 ice_clean_xdp_irq_zc(struct ice_tx_ring *xdp_ring, int napi_budget)
695696
{
696697
u16 tx_thresh = xdp_ring->tx_thresh;
697698
int budget = napi_budget / tx_thresh;
698-
u16 ntc = xdp_ring->next_to_clean;
699699
struct ice_tx_desc *next_dd_desc;
700700
u16 next_dd = xdp_ring->next_dd;
701701
u16 desc_cnt = xdp_ring->count;
702702
struct ice_tx_buf *tx_buf;
703-
u16 cleared_dds = 0;
703+
u16 ntc, cleared_dds = 0;
704704
u32 xsk_frames = 0;
705705
u16 i;
706706

@@ -712,6 +712,12 @@ static u16 ice_clean_xdp_irq_zc(struct ice_tx_ring *xdp_ring, int napi_budget)
712712

713713
cleared_dds++;
714714
xsk_frames = 0;
715+
if (likely(!xdp_ring->xdp_tx_active)) {
716+
xsk_frames = tx_thresh;
717+
goto skip;
718+
}
719+
720+
ntc = xdp_ring->next_to_clean;
715721

716722
for (i = 0; i < tx_thresh; i++) {
717723
tx_buf = &xdp_ring->tx_buf[ntc];
@@ -727,6 +733,10 @@ static u16 ice_clean_xdp_irq_zc(struct ice_tx_ring *xdp_ring, int napi_budget)
727733
if (ntc >= xdp_ring->count)
728734
ntc = 0;
729735
}
736+
skip:
737+
xdp_ring->next_to_clean += tx_thresh;
738+
if (xdp_ring->next_to_clean >= desc_cnt)
739+
xdp_ring->next_to_clean -= desc_cnt;
730740
if (xsk_frames)
731741
xsk_tx_completed(xdp_ring->xsk_pool, xsk_frames);
732742
next_dd_desc->cmd_type_offset_bsz = 0;
@@ -735,7 +745,6 @@ static u16 ice_clean_xdp_irq_zc(struct ice_tx_ring *xdp_ring, int napi_budget)
735745
next_dd = tx_thresh - 1;
736746
} while (budget--);
737747

738-
xdp_ring->next_to_clean = ntc;
739748
xdp_ring->next_dd = next_dd;
740749

741750
return cleared_dds * tx_thresh;

0 commit comments

Comments
 (0)