Skip to content

Commit fc9df2a

Browse files
Andre Guedesanguy11
authored andcommitted
igc: Enable RX via AF_XDP zero-copy
Add support for receiving packets via AF_XDP zero-copy mechanism. Add a new flag to 'enum igc_ring_flags_t' to indicate the ring has AF_XDP zero-copy enabled so proper ring setup is carried out during ring configuration in igc_configure_rx_ring(). RX buffers can now be allocated via the shared pages mechanism (default behavior of the driver) or via xsk pool (when AF_XDP zero-copy is enabled) so a union is added to the 'struct igc_rx_buffer' to cover both cases. When AF_XDP zero-copy is enabled, rx buffers are allocated from the xsk pool using the new helper igc_alloc_rx_buffers_zc() which is the counterpart of igc_alloc_rx_buffers(). Likewise other Intel drivers that support AF_XDP zero-copy, in igc we have a dedicated path for cleaning up rx irqs when zero-copy is enabled. This avoids adding too many checks within igc_clean_rx_irq(), resulting in a more readable and efficient code since this function is called from the hot-path of the driver. Signed-off-by: Andre Guedes <[email protected]> Signed-off-by: Vedang Patel <[email protected]> Signed-off-by: Jithu Joseph <[email protected]> Reviewed-by: Maciej Fijalkowski <[email protected]> Tested-by: Dvora Fuxbrumer <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 859b4df commit fc9df2a

File tree

5 files changed

+450
-19
lines changed

5 files changed

+450
-19
lines changed

drivers/net/ethernet/intel/igc/igc.h

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ struct igc_ring {
118118
};
119119

120120
struct xdp_rxq_info xdp_rxq;
121+
struct xsk_buff_pool *xsk_pool;
121122
} ____cacheline_internodealigned_in_smp;
122123

123124
/* Board specific private data structure */
@@ -255,6 +256,9 @@ bool igc_has_link(struct igc_adapter *adapter);
255256
void igc_reset(struct igc_adapter *adapter);
256257
int igc_set_spd_dplx(struct igc_adapter *adapter, u32 spd, u8 dplx);
257258
void igc_update_stats(struct igc_adapter *adapter);
259+
void igc_disable_rx_ring(struct igc_ring *ring);
260+
void igc_enable_rx_ring(struct igc_ring *ring);
261+
int igc_xsk_wakeup(struct net_device *dev, u32 queue_id, u32 flags);
258262

259263
/* igc_dump declarations */
260264
void igc_rings_dump(struct igc_adapter *adapter);
@@ -432,14 +436,19 @@ struct igc_tx_buffer {
432436
};
433437

434438
struct igc_rx_buffer {
435-
dma_addr_t dma;
436-
struct page *page;
439+
union {
440+
struct {
441+
dma_addr_t dma;
442+
struct page *page;
437443
#if (BITS_PER_LONG > 32) || (PAGE_SIZE >= 65536)
438-
__u32 page_offset;
444+
__u32 page_offset;
439445
#else
440-
__u16 page_offset;
446+
__u16 page_offset;
441447
#endif
442-
__u16 pagecnt_bias;
448+
__u16 pagecnt_bias;
449+
};
450+
struct xdp_buff *xdp;
451+
};
443452
};
444453

445454
struct igc_q_vector {
@@ -525,7 +534,8 @@ enum igc_ring_flags_t {
525534
IGC_RING_FLAG_RX_SCTP_CSUM,
526535
IGC_RING_FLAG_RX_LB_VLAN_BSWAP,
527536
IGC_RING_FLAG_TX_CTX_IDX,
528-
IGC_RING_FLAG_TX_DETECT_HANG
537+
IGC_RING_FLAG_TX_DETECT_HANG,
538+
IGC_RING_FLAG_AF_XDP_ZC,
529539
};
530540

531541
#define ring_uses_large_buffer(ring) \

drivers/net/ethernet/intel/igc/igc_base.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ union igc_adv_rx_desc {
8181

8282
/* Additional Receive Descriptor Control definitions */
8383
#define IGC_RXDCTL_QUEUE_ENABLE 0x02000000 /* Ena specific Rx Queue */
84+
#define IGC_RXDCTL_SWFLUSH 0x04000000 /* Receive Software Flush */
8485

8586
/* SRRCTL bit definitions */
8687
#define IGC_SRRCTL_BSIZEPKT_SHIFT 10 /* Shift _right_ */

0 commit comments

Comments
 (0)