summaryrefslogtreecommitdiffstats
path: root/include/linux/if_tun.h
diff options
context:
space:
mode:
authorJason Wang <jasowang@redhat.com>2018-01-04 11:14:28 +0800
committerDavid S. Miller <davem@davemloft.net>2018-01-09 10:57:08 -0500
commitfc72d1d54dd9ffe2552c76b17e9129803ca7b255 (patch)
tree4ca29f2049fa6f6d553c70a3dd50b22fdd614710 /include/linux/if_tun.h
parent5990a30510ed1c37a769d3a035ad2d030b843528 (diff)
downloadblackbird-op-linux-fc72d1d54dd9ffe2552c76b17e9129803ca7b255.tar.gz
blackbird-op-linux-fc72d1d54dd9ffe2552c76b17e9129803ca7b255.zip
tuntap: XDP transmission
This patch implements XDP transmission for TAP. Since we can't create new queues for TAP during XDP set, exist ptr_ring was reused for queuing XDP buffers. To differ xdp_buff from sk_buff, TUN_XDP_FLAG (0x1UL) was encoded into lowest bit of xpd_buff pointer during ptr_ring_produce, and was decoded during consuming. XDP metadata was stored in the headroom of the packet which should work in most of cases since driver usually reserve enough headroom. Very minor changes were done for vhost_net: it just need to peek the length depends on the type of pointer. Tests were done on two Intel E5-2630 2.40GHz machines connected back to back through two 82599ES. Traffic were generated/received through MoonGen/testpmd(rxonly). It reports ~20% improvements when xdp_redirect_map is doing redirection from ixgbe to TAP (from 2.50Mpps to 3.05Mpps) Cc: Jesper Dangaard Brouer <brouer@redhat.com> Signed-off-by: Jason Wang <jasowang@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/if_tun.h')
-rw-r--r--include/linux/if_tun.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/linux/if_tun.h b/include/linux/if_tun.h
index bdee9b83baf6..08e66827ad8e 100644
--- a/include/linux/if_tun.h
+++ b/include/linux/if_tun.h
@@ -17,9 +17,14 @@
#include <uapi/linux/if_tun.h>
+#define TUN_XDP_FLAG 0x1UL
+
#if defined(CONFIG_TUN) || defined(CONFIG_TUN_MODULE)
struct socket *tun_get_socket(struct file *);
struct ptr_ring *tun_get_tx_ring(struct file *file);
+bool tun_is_xdp_buff(void *ptr);
+void *tun_xdp_to_ptr(void *ptr);
+void *tun_ptr_to_xdp(void *ptr);
#else
#include <linux/err.h>
#include <linux/errno.h>
@@ -33,5 +38,17 @@ static inline struct ptr_ring *tun_get_tx_ring(struct file *f)
{
return ERR_PTR(-EINVAL);
}
+static inline bool tun_is_xdp_buff(void *ptr)
+{
+ return false;
+}
+void *tun_xdp_to_ptr(void *ptr)
+{
+ return NULL;
+}
+void *tun_ptr_to_xdp(void *ptr)
+{
+ return NULL;
+}
#endif /* CONFIG_TUN */
#endif /* __IF_TUN_H */
OpenPOWER on IntegriCloud