diff mbox series

[RFC,v2,9/9] veth: Bulk skb xmit for XDP path

Message ID 20180610160217.3146-10-toshiaki.makita1@gmail.com
State RFC, archived
Delegated to: BPF Maintainers
Headers show
Series veth: Driver XDP | expand

Commit Message

Toshiaki Makita June 10, 2018, 4:02 p.m. UTC
From: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>

Aquire txq lock instead of rxq ptr_ring lock so we avoid per-packet
lock when skb->xmit_more is true. We ensure that rxqs are always not
less than txqs and txq to rxq is one to one mapping, so we can
completely remove rxq side lock.

Since we removed rxq side lock, this change does not increase the number
of locking even when bulk sending is not possible, e.g. non-GSO packets.

Signed-off-by: Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
---
 drivers/net/veth.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 67debd3eafe6..376d70f983e5 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -138,7 +138,7 @@  static void __veth_xdp_flush(struct veth_rq *rq)
 
 static int veth_xdp_rx(struct veth_rq *rq, struct sk_buff *skb)
 {
-	if (unlikely(ptr_ring_produce(&rq->xdp_ring, skb))) {
+	if (unlikely(__ptr_ring_produce(&rq->xdp_ring, skb))) {
 		dev_kfree_skb_any(skb);
 		return NET_RX_DROP;
 	}
@@ -188,7 +188,7 @@  static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev)
 		atomic64_inc(&priv->dropped);
 	}
 
-	if (rcv_xdp)
+	if (rcv_xdp && !skb->xmit_more)
 		__veth_xdp_flush(rq);
 
 	rcu_read_unlock();
@@ -829,15 +829,21 @@  static netdev_features_t veth_fix_features(struct net_device *dev,
 {
 	struct veth_priv *priv = netdev_priv(dev);
 	struct net_device *peer;
+	bool xdp = false;
 
 	peer = rtnl_dereference(priv->peer);
 	if (peer) {
 		struct veth_priv *peer_priv = netdev_priv(peer);
 
 		if (rtnl_dereference(peer_priv->rq[0].xdp_prog))
-			features &= ~NETIF_F_GSO_SOFTWARE;
+			xdp = true;
 	}
 
+	if (xdp)
+		features &= ~(NETIF_F_GSO_SOFTWARE | NETIF_F_LLTX);
+	else
+		features |= NETIF_F_LLTX;
+
 	return features;
 }