Skip to content

Commit 59655a5

Browse files
jasowangdavem330
authored andcommitted
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 <jasowang@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 815df9a commit 59655a5

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

drivers/net/tun.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,7 +1613,6 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun,
16131613
unsigned int delta = 0;
16141614
char *buf;
16151615
size_t copied;
1616-
bool xdp_xmit = false;
16171616
int err, pad = TUN_RX_PAD;
16181617

16191618
rcu_read_lock();
@@ -1671,8 +1670,14 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun,
16711670
preempt_enable();
16721671
return NULL;
16731672
case XDP_TX:
1674-
xdp_xmit = true;
1675-
/* fall through */
1673+
get_page(alloc_frag->page);
1674+
alloc_frag->offset += buflen;
1675+
if (tun_xdp_xmit(tun->dev, &xdp))
1676+
goto err_redirect;
1677+
tun_xdp_flush(tun->dev);
1678+
rcu_read_unlock();
1679+
preempt_enable();
1680+
return NULL;
16761681
case XDP_PASS:
16771682
delta = orig_data - xdp.data;
16781683
break;
@@ -1699,14 +1704,6 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun,
16991704
get_page(alloc_frag->page);
17001705
alloc_frag->offset += buflen;
17011706

1702-
if (xdp_xmit) {
1703-
skb->dev = tun->dev;
1704-
generic_xdp_tx(skb, xdp_prog);
1705-
rcu_read_unlock();
1706-
preempt_enable();
1707-
return NULL;
1708-
}
1709-
17101707
rcu_read_unlock();
17111708
preempt_enable();
17121709

0 commit comments

Comments
 (0)