i40e: Support for XDP
Subsystems (3)
cover i40e: Support for XDP
From: Bj?rn T?pel <[email protected]>
This series adds XDP support for i40e-based NICs.
The first patch adds XDP_RX support, the second XDP_TX support and the last patch makes it possible to change an XDP program without rebuilding the rings.
Bj?rn
Bj?rn T?pel (3):
i40e: Initial support for XDP
i40e: Add XDP_TX support
i40e: Don't reset/rebuild rings on XDP program swap
drivers/net/ethernet/intel/i40e/i40e.h | 18 + drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 3 + drivers/net/ethernet/intel/i40e/i40e_main.c | 358 +++++++++++++++++--- drivers/net/ethernet/intel/i40e/i40e_txrx.c | 445 +++++++++++++++++++++---- drivers/net/ethernet/intel/i40e/i40e_txrx.h | 7 + 5 files changed, 715 insertions(+), 116 deletions(-)
Signature · 1 line
2.9.3
PATCH 1/3 i40e: Initial support for XDP
From: Bj?rn T?pel <[email protected]>
This commit adds basic XDP support for i40e derived NICs. All XDP actions will end up in XDP_DROP.
Only the default/main VSI has support for enabling XDP.
--- drivers/net/ethernet/intel/i40e/i40e.h | 13 +++ drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 3 + drivers/net/ethernet/intel/i40e/i40e_main.c | 74 +++++++++++++ drivers/net/ethernet/intel/i40e/i40e_txrx.c | 146 ++++++++++++++++++++----- drivers/net/ethernet/intel/i40e/i40e_txrx.h | 2 + 5 files changed, 213 insertions(+), 25 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +13 -0
@@ -545,6 +545,8 @@ struct i40e_vsi {struct i40e_ring **rx_rings;struct i40e_ring **tx_rings; +struct bpf_prog *xdp_prog; +u32 active_filters;u32 promisc_threshold;
@@ -904,4 +906,15 @@ i40e_status i40e_get_npar_bw_setting(struct i40e_pf *pf);i40e_status i40e_set_npar_bw_setting (struct i40e_pf *pf);i40e_status i40e_commit_npar_bw_setting (struct i40e_pf *pf);void i40e_print_link_message (struct i40e_vsi *vsi,bool isup); + +/** +* i40e_enabled_xdp_vsi - Check if VSI has XDP enabled +* @vsi: pointer to a vsi +* +* Returns true if the VSI has XDP enabled. +**/ +static inline bool i40e_enabled_xdp_vsi (const struct i40e_vsi *vsi) +{ +return vsi->xdp_prog; +}#endif /* _I40E_H_ */
drivers/net/ethernet/intel/i40e/i40e_ethtool.c +3 -0
@@ -1254,6 +1254,9 @@ static int i40e_set_ringparam(struct net_device *netdev,if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))return -EINVAL ; +if (i40e_enabled_xdp_vsi (vsi)) +return -EINVAL ; + if (ring->tx_pending > I40E_MAX_NUM_DESCRIPTORS || ring->tx_pending < I40E_MIN_NUM_DESCRIPTORS || ring->rx_pending > I40E_MAX_NUM_DESCRIPTORS ||
drivers/net/ethernet/intel/i40e/i40e_main.c +74 -0
104 lines not on this page · raw message
drivers/net/ethernet/intel/i40e/i40e_txrx.c +121 -25
221 lines not on this page · raw message
drivers/net/ethernet/intel/i40e/i40e_txrx.h +2 -0
@@ -341,6 +341,8 @@ struct i40e_ring {struct rcu_head rcu;/* to avoid race on free */ u16 next_to_alloc; + +struct bpf_prog *xdp_prog; }____cacheline_internodealigned_in_smp ;enum i40e_latency_range {
Signature · 1 line
2.9.3
PATCH 2/3 i40e: Add XDP_TX support
In reply to Björn TöpelFrom: Bj?rn T?pel <[email protected]>
This patch adds proper XDP_TX support.
--- drivers/net/ethernet/intel/i40e/i40e.h | 5 + drivers/net/ethernet/intel/i40e/i40e_main.c | 273 ++++++++++++++++++++----- drivers/net/ethernet/intel/i40e/i40e_txrx.c | 304 +++++++++++++++++++++++----- drivers/net/ethernet/intel/i40e/i40e_txrx.h | 5 + 4 files changed, 491 insertions(+), 96 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +5 -0
@@ -545,6 +545,10 @@ struct i40e_vsi {struct i40e_ring **rx_rings;struct i40e_ring **tx_rings; +/* The XDP rings are Tx only, and follows the count of the +* regular rings, i.e. alloc_queue_pairs/num_queue_pairs +*/ +struct i40e_ring **xdp_rings;struct bpf_prog *xdp_prog;u32 active_filters;
@@ -622,6 +626,7 @@ struct i40e_q_vector {struct i40e_ring_container rx;struct i40e_ring_container tx; +struct i40e_ring_container xdp;u8 num_ringpairs;/* total number of ring pairs in vector */
drivers/net/ethernet/intel/i40e/i40e_main.c +223 -50
445 lines not on this page · raw message
drivers/net/ethernet/intel/i40e/i40e_txrx.c +258 -46
391 lines not on this page · raw message
drivers/net/ethernet/intel/i40e/i40e_txrx.h +5 -0
@@ -220,6 +220,7 @@ static inline unsigned int i40e_txd_use_count(unsigned int size)#define I40E_TX_FLAGS_TSYN BIT(8)#define I40E_TX_FLAGS_FD_SB BIT(9)#define I40E_TX_FLAGS_UDP_TUNNEL BIT(10) +#define I40E_TX_FLAGS_XDP BIT(11)#define I40E_TX_FLAGS_VLAN_MASK 0xffff0000#define I40E_TX_FLAGS_VLAN_PRIO_MASK 0xe0000000#define I40E_TX_FLAGS_VLAN_PRIO_SHIFT 29
@@ -230,6 +231,7 @@ struct i40e_tx_buffer {union {struct sk_buff *skb;void *raw_buf; +struct page *page; };unsigned int bytecount;unsigned short gso_segs;
@@ -343,6 +345,9 @@ struct i40e_ring {u16 next_to_alloc;struct bpf_prog *xdp_prog; +struct i40e_ring *xdp_sibling;/* rx to xdp, and xdp to rx */ +bool xdp_needs_tail_bump; +u16 curr_in_use; }____cacheline_internodealigned_in_smp ;enum i40e_latency_range {
Signature · 1 line
2.9.3
PATCH 3/3 i40e: Don't reset/rebuild rings on XDP program swap
In reply to Björn TöpelFrom: Bj?rn T?pel <[email protected]>
Previously, when swapping from one XDP program to another, a reset/rebuild rings was triggered. Now, the XDP program is simply changed without that requirement.
--- drivers/net/ethernet/intel/i40e/i40e.h | 4 +-- drivers/net/ethernet/intel/i40e/i40e_main.c | 41 ++++++++++++++++++----------- drivers/net/ethernet/intel/i40e/i40e_txrx.c | 25 +++++++++++------- drivers/net/ethernet/intel/i40e/i40e_txrx.h | 2 +- 4 files changed, 44 insertions(+), 28 deletions(-)
drivers/net/ethernet/intel/i40e/i40e.h +2 -2
@@ -549,7 +549,7 @@ struct i40e_vsi {* regular rings, i.e. alloc_queue_pairs/num_queue_pairs */ struct i40e_ring **xdp_rings; -struct bpf_prog *xdp_prog; +bool xdp_enabled;u32 active_filters;u32 promisc_threshold;
@@ -920,6 +920,6 @@ void i40e_print_link_message(struct i40e_vsi *vsi, bool isup);**/ static inline bool i40e_enabled_xdp_vsi (const struct i40e_vsi *vsi) { -return vsi->xdp_prog; +return vsi->xdp_enabled; }#endif /* _I40E_H_ */
drivers/net/ethernet/intel/i40e/i40e_main.c +26 -15
68 lines not on this page · raw message
drivers/net/ethernet/intel/i40e/i40e_txrx.c +15 -10
@@ -1112,6 +1112,7 @@ void i40e_clean_rx_ring(struct i40e_ring *rx_ring)struct device *dev = rx_ring->dev;unsigned long bi_size;u16 i; +struct bpf_prog *old_prog;/* ring already cleared, nothing to do */ if (!rx_ring->rx_bi)
@@ -1145,10 +1146,10 @@ void i40e_clean_rx_ring(struct i40e_ring *rx_ring) rx_ring->next_to_clean =0 ; rx_ring->next_to_use =0 ; -if (rx_ring->xdp_prog) { -bpf_prog_put (rx_ring->xdp_prog); - rx_ring->xdp_prog =NULL ; - } + old_prog =rtnl_dereference (rx_ring->xdp_prog); +RCU_INIT_POINTER (rx_ring->xdp_prog,NULL ); +if (old_prog) +bpf_prog_put (old_prog); }/**
@@ -1880,6 +1881,7 @@ bool i40e_fetch_rx_buffer(struct i40e_ring *rx_ring, {struct i40e_rx_buffer *rx_buffer;struct page *page; +struct bpf_prog *xdp_prog; rx_buffer = &rx_ring->rx_bi[rx_ring->next_to_clean]; page = rx_buffer->page;
@@ -1892,14 +1894,17 @@ bool i40e_fetch_rx_buffer(struct i40e_ring *rx_ring,I40E_RXBUFFER_2048 , DMA_FROM_DEVICE); -if (rx_ring->xdp_prog) { -bool xdp_consumed; - - xdp_consumed =i40e_run_xdp (rx_ring, rx_buffer, - rx_desc, rx_ring->xdp_prog); -if (xdp_consumed) +rcu_read_lock (); + xdp_prog =rcu_dereference (rx_ring->xdp_prog); +if (xdp_prog) { +bool xdp_consumed =i40e_run_xdp (rx_ring, rx_buffer, + rx_desc, xdp_prog); +if (xdp_consumed) { +rcu_read_unlock ();return true; + } } +rcu_read_unlock (); *skb = rx_buffer->skb;
drivers/net/ethernet/intel/i40e/i40e_txrx.h +1 -1
@@ -344,7 +344,7 @@ struct i40e_ring {struct rcu_head rcu;/* to avoid race on free */ u16 next_to_alloc; -struct bpf_prog *xdp_prog; +struct bpf_prog __rcu *xdp_prog;struct i40e_ring *xdp_sibling;/* rx to xdp, and xdp to rx */ bool xdp_needs_tail_bump;u16 curr_in_use;
Signature · 1 line
2.9.3
Quoted 17 lines · Bj?rn T?pel
From: Bj?rn T?pel <[email protected]>
This series adds XDP support for i40e-based NICs.
The first patch adds
XDP_RXsupport, the secondXDP_TXsupport and the last patch makes it possible to change an XDP program without rebuilding the rings.Bj?rn
Bj?rn T?pel (3):
i40e: Initial support for XDP
i40e: AddXDP_TXsupport
i40e: Don't reset/rebuild rings on XDP program swap
Quoted 7 lines
drivers/net/ethernet/intel/i40e/i40e.h | 18 + drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 3 + drivers/net/ethernet/intel/i40e/i40e_main.c | 358 +++++++++++++++++--- drivers/net/ethernet/intel/i40e/i40e_txrx.c | 445 +++++++++++++++++++++---- drivers/net/ethernet/intel/i40e/i40e_txrx.h | 7 + 5 files changed, 715 insertions(+), 116 deletions(-)
Hi Jeff,
These are for the Intel driver net-next tree per our offlist email.
Thanks!
John
kbuild test robot
build botRe: [PATCH 2/3] i40e: Add XDP_TX support
In reply to Björn Töpelurl: https://github.com/0day-ci/linux/commits/Bj-rn-T-pel/i40e-Support-for-XDP/20161209-013138 config: sparc64-allmodconfig (attached as .config) compiler: sparc64-linux-gnu-gcc (Debian 6.1.1-9)…
Hi Bj?rn,
[auto build test ERROR on next-20161208]
[cannot apply to jkirsher-next-queue/dev-queue v4.9-rc8 v4.9-rc7 v4.9-rc6 v4.9-rc8] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Bj-rn-T-pel/i40e-Support-for-XDP/20161209-013138
config: sparc64-allmodconfig (attached as .config)
compiler: sparc64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=sparc64
All error/warnings (new ones prefixed by >>):
In file included from include/linux/cache.h:4:0,
from include/linux/printk.h:8,
from include/linux/kernel.h:13,
from include/linux/list.h:8,
from include/linux/timer.h:4,
from include/linux/workqueue.h:8,
from include/linux/bpf.h:11,
from drivers/net/ethernet/intel/i40e/i40e_txrx.c:27:
drivers/net/ethernet/intel/i40e/i40e_txrx.c: In function 'i40e_try_flip_rx_page':
>> drivers/net/ethernet/intel/i40e/i40e_txrx.c:1613:32: error: 'size' undeclared (first use in this function)
unsigned int truesize = ALIGN(size, L1_CACHE_BYTES);
^
include/uapi/linux/kernel.h:10:41: note: in definition of macro '__ALIGN_KERNEL_MASK'
#define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
^
include/linux/kernel.h:49:22: note: in expansion of macro '__ALIGN_KERNEL'
#define ALIGN(x, a) __ALIGN_KERNEL((x), (a))
^~~~~~~~~~~~~~
>> drivers/net/ethernet/intel/i40e/i40e_txrx.c:1613:26: note: in expansion of macro 'ALIGN'
unsigned int truesize = ALIGN(size, L1_CACHE_BYTES);
^~~~~
drivers/net/ethernet/intel/i40e/i40e_txrx.c:1613:32: note: each undeclared identifier is reported only once for each function it appears in
unsigned int truesize = ALIGN(size, L1_CACHE_BYTES);
^
include/uapi/linux/kernel.h:10:41: note: in definition of macro '__ALIGN_KERNEL_MASK'
#define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
^
include/linux/kernel.h:49:22: note: in expansion of macro '__ALIGN_KERNEL'
#define ALIGN(x, a) __ALIGN_KERNEL((x), (a))
^~~~~~~~~~~~~~
>> drivers/net/ethernet/intel/i40e/i40e_txrx.c:1613:26: note: in expansion of macro 'ALIGN'
unsigned int truesize = ALIGN(size, L1_CACHE_BYTES);
^~~~~vim +/size +1613 drivers/net/ethernet/intel/i40e/i40e_txrx.c
1607 */
1608 static bool i40e_try_flip_rx_page(struct i40e_rx_buffer *rx_buffer)
1609 {
1610 #if (PAGE_SIZE < 8192)
1611 unsigned int truesize = I40E_RXBUFFER_2048;
1612 #else
> 1613 unsigned int truesize = ALIGN(size, L1_CACHE_BYTES);
1614 unsigned int last_offset = PAGE_SIZE - I40E_RXBUFFER_2048;
1615 #endif
1616
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 48617 bytes
Desc: not available
URL: <http://lists.osuosl.org/pipermail/intel-wired-lan/attachments/20161209/4ec083e8/attachment-0001.bin>
Re: [PATCH 2/3] i40e: Add XDP_TX support
2016-12-08 20:20 GMT+01:00 kbuild test robot <[email protected]>:
Quoted 59 lines
Hi Bj?rn,
[auto build test ERROR on next-20161208]
[cannot apply to jkirsher-next-queue/dev-queue v4.9-rc8 v4.9-rc7 v4.9-rc6 v4.9-rc8] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]url: https://github.com/0day-ci/linux/commits/Bj-rn-T-pel/i40e-Support-for-XDP/20161209-013138
config: sparc64-allmodconfig (attached as .config)
compiler: sparc64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=sparc64All error/warnings (new ones prefixed by >>):
In file included from include/linux/cache.h:4:0, from include/linux/printk.h:8, from include/linux/kernel.h:13, from include/linux/list.h:8, from include/linux/timer.h:4, from include/linux/workqueue.h:8, from include/linux/bpf.h:11, from drivers/net/ethernet/intel/i40e/i40e_txrx.c:27: drivers/net/ethernet/intel/i40e/i40e_txrx.c: In function 'i40e_try_flip_rx_page':Quoted 1 line
Quoted 1 line
drivers/net/ethernet/intel/i40e/i40e_txrx.c:1613:32: error: 'size' undeclared (first use in this function)unsigned int truesize = ALIGN(size, L1_CACHE_BYTES); ^ include/uapi/linux/kernel.h:10:41: note: in definition of macro '__ALIGN_KERNEL_MASK' #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask)) ^ include/linux/kernel.h:49:22: note: in expansion of macro '__ALIGN_KERNEL' #define ALIGN(x, a) __ALIGN_KERNEL((x), (a)) ^~~~~~~~~~~~~~Quoted 1 line
Quoted 1 line
drivers/net/ethernet/intel/i40e/i40e_txrx.c:1613:26: note: in expansion of macro 'ALIGN'unsigned int truesize = ALIGN(size, L1_CACHE_BYTES); ^~~~~ drivers/net/ethernet/intel/i40e/i40e_txrx.c:1613:32: note: each undeclared identifier is reported only once for each function it appears in unsigned int truesize = ALIGN(size, L1_CACHE_BYTES); ^ include/uapi/linux/kernel.h:10:41: note: in definition of macro '__ALIGN_KERNEL_MASK' #define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask)) ^ include/linux/kernel.h:49:22: note: in expansion of macro '__ALIGN_KERNEL' #define ALIGN(x, a) __ALIGN_KERNEL((x), (a)) ^~~~~~~~~~~~~~Quoted 1 line
Quoted 1 line
drivers/net/ethernet/intel/i40e/i40e_txrx.c:1613:26: note: in expansion of macro 'ALIGN'unsigned int truesize = ALIGN(size, L1_CACHE_BYTES); ^~~~~vim +/size +1613
drivers/net/ethernet/intel/i40e/i40e_txrx.c1607 */
1608 static bool i40e_try_flip_rx_page(struct i40e_rx_buffer *rx_buffer) 1609 { 1610 #if (PAGE_SIZE < 8192)1611 unsigned int truesize =
I40E_RXBUFFER_2048;
1612 #else
Quoted 8 lines
Quoted 1 line
1613 unsigned int truesize =
ALIGN(size, L1_CACHE_BYTES);1614 unsigned int
last_offset=PAGE_SIZE-I40E_RXBUFFER_2048;
1615 #endif
1616---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Ick. I'll respin this.
Bj?rn