Commit 59655a5b authored by Jason Wang's avatar Jason Wang Committed by David S. Miller

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: default avatarJason Wang <jasowang@redhat.com>
Acked-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 815df9ac
...@@ -1613,7 +1613,6 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun, ...@@ -1613,7 +1613,6 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun,
unsigned int delta = 0; unsigned int delta = 0;
char *buf; char *buf;
size_t copied; size_t copied;
bool xdp_xmit = false;
int err, pad = TUN_RX_PAD; int err, pad = TUN_RX_PAD;
rcu_read_lock(); rcu_read_lock();
...@@ -1671,8 +1670,14 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun, ...@@ -1671,8 +1670,14 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun,
preempt_enable(); preempt_enable();
return NULL; return NULL;
case XDP_TX: case XDP_TX:
xdp_xmit = true; get_page(alloc_frag->page);
/* fall through */ 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: case XDP_PASS:
delta = orig_data - xdp.data; delta = orig_data - xdp.data;
break; break;
...@@ -1699,14 +1704,6 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun, ...@@ -1699,14 +1704,6 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun,
get_page(alloc_frag->page); get_page(alloc_frag->page);
alloc_frag->offset += buflen; 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(); rcu_read_unlock();
preempt_enable(); preempt_enable();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment