[SRU][B:linux-azure-4.15][PATCH 12/40] tuntap: XDP_TX can use native XDP
William Breathitt Gray
william.gray at canonical.com
Mon Nov 2 12:48:28 UTC 2020
From: Jason Wang <jasowang at redhat.com>
BugLink: https://bugs.launchpad.net/bugs/1877654
Now we have ndo_xdp_xmit, switch to use it instead of the slow generic
XDP TX routine. XDP_TX on TAP gets ~20% improvements from ~1.5Mpps to
~1.8Mpps on 2.60GHz Core(TM) i7-5600U.
Signed-off-by: Jason Wang <jasowang at redhat.com>
Acked-by: Michael S. Tsirkin <mst at redhat.com>
Signed-off-by: David S. Miller <davem at davemloft.net>
(backported from commit 59655a5b6c837e392e873629591069c898585592)
[ vilhelmgray: context adjustments ]
[ vilhelmgray: use local_bh_enable() instead of preempt_enable() ]
Signed-off-by: William Breathitt Gray <william.gray at canonical.com>
---
drivers/net/tun.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 6d827c0ef8cc..1d7f953d83e4 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1572,7 +1572,6 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun,
unsigned int delta = 0;
char *buf;
size_t copied;
- bool xdp_xmit = false;
int err, pad = TUN_RX_PAD;
rcu_read_lock();
@@ -1630,8 +1629,14 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun,
local_bh_enable();
return NULL;
case XDP_TX:
- xdp_xmit = true;
- /* fall through */
+ get_page(alloc_frag->page);
+ alloc_frag->offset += buflen;
+ if (tun_xdp_xmit(tun->dev, &xdp))
+ goto err_redirect;
+ tun_xdp_flush(tun->dev);
+ rcu_read_unlock();
+ local_bh_enable();
+ return NULL;
case XDP_PASS:
delta = orig_data - xdp.data;
break;
@@ -1659,14 +1664,6 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun,
get_page(alloc_frag->page);
alloc_frag->offset += buflen;
- if (xdp_xmit) {
- skb->dev = tun->dev;
- generic_xdp_tx(skb, xdp_prog);
- rcu_read_unlock();
- local_bh_enable();
- return NULL;
- }
-
rcu_read_unlock();
local_bh_enable();
--
2.25.1
More information about the kernel-team
mailing list