Skip to content

Commit

Permalink
tuntap: XDP_TX can use native XDP
Browse files Browse the repository at this point in the history
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@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jason Wang authored and David S. Miller committed Mar 14, 2018
1 parent 815df9a commit 59655a5
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions drivers/net/tun.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand All @@ -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();

Expand Down

0 comments on commit 59655a5

Please sign in to comment.