[ovs-dev] [PATCH] netdev: Remove modulo operation in dpdk/vhost/afxdp tx path

Li RongQing lirongqing at baidu.com
Tue Mar 23 03:51:33 UTC 2021


After 324c8374852a ("dpif-netdev: XPS (Transmit Packet Steering)
implementation."), it is impossible that qid is greater than or
equal to n_txq of netdev. so remove this modulo operation which
is in hot path

Signed-off-by: Li RongQing <lirongqing at baidu.com>
---
 lib/netdev-afxdp.c | 1 -
 lib/netdev-dpdk.c  | 3 +--
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/lib/netdev-afxdp.c b/lib/netdev-afxdp.c
index 482400d8d..c16ba7b90 100644
--- a/lib/netdev-afxdp.c
+++ b/lib/netdev-afxdp.c
@@ -1117,7 +1117,6 @@ netdev_afxdp_batch_send(struct netdev *netdev, int qid,
 
     if (concurrent_txq) {
         dev = netdev_linux_cast(netdev);
-        qid = qid % netdev_n_txq(netdev);
 
         ovs_spin_lock(&dev->tx_locks[qid].lock);
         ret = __netdev_afxdp_batch_send(netdev, qid, batch);
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 9d8096668..0078957ff 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -2598,7 +2598,7 @@ __netdev_dpdk_vhost_send(struct netdev *netdev, int qid,
     int max_retries = VHOST_ENQ_RETRY_MIN;
     int vid = netdev_dpdk_get_vid(dev);
 
-    qid = dev->tx_q[qid % netdev->n_txq].map;
+    qid = dev->tx_q[qid].map;
 
     if (OVS_UNLIKELY(vid < 0 || !dev->vhost_reconfigured || qid < 0
                      || !(dev->flags & NETDEV_UP))) {
@@ -2872,7 +2872,6 @@ netdev_dpdk_send__(struct netdev_dpdk *dev, int qid,
     }
 
     if (OVS_UNLIKELY(concurrent_txq)) {
-        qid = qid % dev->up.n_txq;
         rte_spinlock_lock(&dev->tx_q[qid].tx_lock);
     }
 
-- 
2.17.3



More information about the dev mailing list