diff options
| author | Jason Wang <[email protected]> | 2018-03-14 11:23:40 +0800 |
|---|---|---|
| committer | David S. Miller <[email protected]> | 2018-03-14 13:20:48 -0400 |
| commit | 59655a5b6c837e392e873629591069c898585592 (patch) | |
| tree | 0088c7be13366a70f1a87ace645447a9a97a020e | |
| parent | 815df9ac6c993c526c6ef82d970890a1f4b51f2f (diff) | |
tuntap: XDP_TX can use native XDP
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 <[email protected]>
Acked-by: Michael S. Tsirkin <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
| -rw-r--r-- | drivers/net/tun.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 475088f947bb..baeafa004463 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1613,7 +1613,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(); @@ -1671,8 +1670,14 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun, preempt_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(); + preempt_enable(); + return NULL; case XDP_PASS: delta = orig_data - xdp.data; break; @@ -1699,14 +1704,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(); - preempt_enable(); - return NULL; - } - rcu_read_unlock(); preempt_enable(); |