Skip to content

Commit ecd63a0

Browse files
Jakub Kicinskidavem330
Jakub Kicinski
authored andcommitted
nfp: add XDP support in the driver
Add XDP support. Separate stack's and XDP's TX rings logically. Add functions for handling XDP_TX and cleanup of XDP's TX rings. For XDP allocate all RX buffers as separate pages and map them with DMA_BIDIRECTIONAL. Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 68f929f commit ecd63a0

File tree

4 files changed

+449
-101
lines changed

4 files changed

+449
-101
lines changed

drivers/net/ethernet/netronome/nfp/nfp_net.h

+14-3
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,10 @@ struct nfp_net_tx_desc {
171171
* on the head's buffer). Equal to skb->len for non-TSO packets.
172172
*/
173173
struct nfp_net_tx_buf {
174-
struct sk_buff *skb;
174+
union {
175+
struct sk_buff *skb;
176+
void *frag;
177+
};
175178
dma_addr_t dma_addr;
176179
short int fidx;
177180
u16 pkt_cnt;
@@ -341,6 +344,7 @@ struct nfp_net_rx_ring {
341344
* @napi: NAPI structure for this ring vec
342345
* @tx_ring: Pointer to TX ring
343346
* @rx_ring: Pointer to RX ring
347+
* @xdp_ring: Pointer to an extra TX ring for XDP
344348
* @irq_idx: Index into MSI-X table
345349
* @rx_sync: Seqlock for atomic updates of RX stats
346350
* @rx_pkts: Number of received packets
@@ -384,6 +388,8 @@ struct nfp_net_r_vector {
384388
u64 hw_csum_rx_inner_ok;
385389
u64 hw_csum_rx_error;
386390

391+
struct nfp_net_tx_ring *xdp_ring;
392+
387393
struct u64_stats_sync tx_sync;
388394
u64 tx_pkts;
389395
u64 tx_bytes;
@@ -432,6 +438,7 @@ struct nfp_stat_pair {
432438
* @ctrl: Local copy of the control register/word.
433439
* @fl_bufsz: Currently configured size of the freelist buffers
434440
* @rx_offset: Offset in the RX buffers where packet data starts
441+
* @xdp_prog: Installed XDP program
435442
* @cpp: Pointer to the CPP handle
436443
* @nfp_dev_cpp: Pointer to the NFP Device handle
437444
* @ctrl_area: Pointer to the CPP area for the control BAR
@@ -451,6 +458,7 @@ struct nfp_stat_pair {
451458
* @max_tx_rings: Maximum number of TX rings supported by the Firmware
452459
* @max_rx_rings: Maximum number of RX rings supported by the Firmware
453460
* @num_tx_rings: Currently configured number of TX rings
461+
* @num_stack_tx_rings: Number of TX rings used by the stack (not XDP)
454462
* @num_rx_rings: Currently configured number of RX rings
455463
* @txd_cnt: Size of the TX ring in number of descriptors
456464
* @rxd_cnt: Size of the RX ring in number of descriptors
@@ -500,6 +508,8 @@ struct nfp_net {
500508

501509
u32 rx_offset;
502510

511+
struct bpf_prog *xdp_prog;
512+
503513
struct nfp_net_tx_ring *tx_rings;
504514
struct nfp_net_rx_ring *rx_rings;
505515

@@ -532,6 +542,7 @@ struct nfp_net {
532542
unsigned int max_rx_rings;
533543

534544
unsigned int num_tx_rings;
545+
unsigned int num_stack_tx_rings;
535546
unsigned int num_rx_rings;
536547

537548
int stride_tx;
@@ -779,8 +790,8 @@ void nfp_net_coalesce_write_cfg(struct nfp_net *nn);
779790
int nfp_net_irqs_alloc(struct nfp_net *nn);
780791
void nfp_net_irqs_disable(struct nfp_net *nn);
781792
int
782-
nfp_net_ring_reconfig(struct nfp_net *nn, struct nfp_net_ring_set *rx,
783-
struct nfp_net_ring_set *tx);
793+
nfp_net_ring_reconfig(struct nfp_net *nn, struct bpf_prog **xdp_prog,
794+
struct nfp_net_ring_set *rx, struct nfp_net_ring_set *tx);
784795

785796
#ifdef CONFIG_NFP_NET_DEBUG
786797
void nfp_net_debugfs_create(void);

0 commit comments

Comments
 (0)