Skip to content

Commit

Permalink
nfp: add XDP support in the driver
Browse files Browse the repository at this point in the history
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 <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jakub Kicinski authored and David S. Miller committed Nov 4, 2016
1 parent 68f929f commit ecd63a0
Show file tree
Hide file tree
Showing 4 changed files with 449 additions and 101 deletions.
17 changes: 14 additions & 3 deletions drivers/net/ethernet/netronome/nfp/nfp_net.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ struct nfp_net_tx_desc {
* on the head's buffer). Equal to skb->len for non-TSO packets.
*/
struct nfp_net_tx_buf {
struct sk_buff *skb;
union {
struct sk_buff *skb;
void *frag;
};
dma_addr_t dma_addr;
short int fidx;
u16 pkt_cnt;
Expand Down Expand Up @@ -341,6 +344,7 @@ struct nfp_net_rx_ring {
* @napi: NAPI structure for this ring vec
* @tx_ring: Pointer to TX ring
* @rx_ring: Pointer to RX ring
* @xdp_ring: Pointer to an extra TX ring for XDP
* @irq_idx: Index into MSI-X table
* @rx_sync: Seqlock for atomic updates of RX stats
* @rx_pkts: Number of received packets
Expand Down Expand Up @@ -384,6 +388,8 @@ struct nfp_net_r_vector {
u64 hw_csum_rx_inner_ok;
u64 hw_csum_rx_error;

struct nfp_net_tx_ring *xdp_ring;

struct u64_stats_sync tx_sync;
u64 tx_pkts;
u64 tx_bytes;
Expand Down Expand Up @@ -432,6 +438,7 @@ struct nfp_stat_pair {
* @ctrl: Local copy of the control register/word.
* @fl_bufsz: Currently configured size of the freelist buffers
* @rx_offset: Offset in the RX buffers where packet data starts
* @xdp_prog: Installed XDP program
* @cpp: Pointer to the CPP handle
* @nfp_dev_cpp: Pointer to the NFP Device handle
* @ctrl_area: Pointer to the CPP area for the control BAR
Expand All @@ -451,6 +458,7 @@ struct nfp_stat_pair {
* @max_tx_rings: Maximum number of TX rings supported by the Firmware
* @max_rx_rings: Maximum number of RX rings supported by the Firmware
* @num_tx_rings: Currently configured number of TX rings
* @num_stack_tx_rings: Number of TX rings used by the stack (not XDP)
* @num_rx_rings: Currently configured number of RX rings
* @txd_cnt: Size of the TX ring in number of descriptors
* @rxd_cnt: Size of the RX ring in number of descriptors
Expand Down Expand Up @@ -500,6 +508,8 @@ struct nfp_net {

u32 rx_offset;

struct bpf_prog *xdp_prog;

struct nfp_net_tx_ring *tx_rings;
struct nfp_net_rx_ring *rx_rings;

Expand Down Expand Up @@ -532,6 +542,7 @@ struct nfp_net {
unsigned int max_rx_rings;

unsigned int num_tx_rings;
unsigned int num_stack_tx_rings;
unsigned int num_rx_rings;

int stride_tx;
Expand Down Expand Up @@ -779,8 +790,8 @@ void nfp_net_coalesce_write_cfg(struct nfp_net *nn);
int nfp_net_irqs_alloc(struct nfp_net *nn);
void nfp_net_irqs_disable(struct nfp_net *nn);
int
nfp_net_ring_reconfig(struct nfp_net *nn, struct nfp_net_ring_set *rx,
struct nfp_net_ring_set *tx);
nfp_net_ring_reconfig(struct nfp_net *nn, struct bpf_prog **xdp_prog,
struct nfp_net_ring_set *rx, struct nfp_net_ring_set *tx);

#ifdef CONFIG_NFP_NET_DEBUG
void nfp_net_debugfs_create(void);
Expand Down
Loading

0 comments on commit ecd63a0

Please sign in to comment.