Skip to content

Commit 7379f97

Browse files
John FastabendJeff Kirsher
authored andcommitted
ixgbe: delay tail write to every 'n' packets
Current XDP implementation hits the tail on every XDP_TX return code. This patch changes driver behavior to only hit the tail after packet processing is complete. With this patch I can run XDP drop programs @ 14+Mpps and XDP_TX programs are at ~13.5Mpps. Signed-off-by: John Fastabend <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 33fdc82 commit 7379f97

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2283,6 +2283,7 @@ static int ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector,
22832283
unsigned int mss = 0;
22842284
#endif /* IXGBE_FCOE */
22852285
u16 cleaned_count = ixgbe_desc_unused(rx_ring);
2286+
bool xdp_xmit = false;
22862287

22872288
while (likely(total_rx_packets < budget)) {
22882289
union ixgbe_adv_rx_desc *rx_desc;
@@ -2322,10 +2323,12 @@ static int ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector,
23222323
}
23232324

23242325
if (IS_ERR(skb)) {
2325-
if (PTR_ERR(skb) == -IXGBE_XDP_TX)
2326+
if (PTR_ERR(skb) == -IXGBE_XDP_TX) {
2327+
xdp_xmit = true;
23262328
ixgbe_rx_buffer_flip(rx_ring, rx_buffer, size);
2327-
else
2329+
} else {
23282330
rx_buffer->pagecnt_bias++;
2331+
}
23292332
total_rx_packets++;
23302333
total_rx_bytes += size;
23312334
} else if (skb) {
@@ -2393,6 +2396,16 @@ static int ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector,
23932396
total_rx_packets++;
23942397
}
23952398

2399+
if (xdp_xmit) {
2400+
struct ixgbe_ring *ring = adapter->xdp_ring[smp_processor_id()];
2401+
2402+
/* Force memory writes to complete before letting h/w
2403+
* know there are new descriptors to fetch.
2404+
*/
2405+
wmb();
2406+
writel(ring->next_to_use, ring->tail);
2407+
}
2408+
23962409
u64_stats_update_begin(&rx_ring->syncp);
23972410
rx_ring->stats.packets += total_rx_packets;
23982411
rx_ring->stats.bytes += total_rx_bytes;
@@ -8238,14 +8251,8 @@ static int ixgbe_xmit_xdp_ring(struct ixgbe_adapter *adapter,
82388251
tx_desc->read.olinfo_status =
82398252
cpu_to_le32(len << IXGBE_ADVTXD_PAYLEN_SHIFT);
82408253

8241-
/* Force memory writes to complete before letting h/w know there
8242-
* are new descriptors to fetch. (Only applicable for weak-ordered
8243-
* memory model archs, such as IA-64).
8244-
*
8245-
* We also need this memory barrier to make certain all of the
8246-
* status bits have been updated before next_to_watch is written.
8247-
*/
8248-
wmb();
8254+
/* Avoid any potential race with xdp_xmit and cleanup */
8255+
smp_wmb();
82498256

82508257
/* set next_to_watch value indicating a packet is present */
82518258
i++;
@@ -8255,7 +8262,6 @@ static int ixgbe_xmit_xdp_ring(struct ixgbe_adapter *adapter,
82558262
tx_buffer->next_to_watch = tx_desc;
82568263
ring->next_to_use = i;
82578264

8258-
writel(i, ring->tail);
82598265
return IXGBE_XDP_TX;
82608266
}
82618267

0 commit comments

Comments
 (0)