Non pmd threads have a core_id == UINT32_MAX, while queue ids used by
netdevs range from 0 to the number of CPUs.  Therefore core ids cannot
be used directly to select a queue.

This commit introduces a simple mapping to fix the problem: non pmd
threads use queue 0, pmd threads on core 0 to N use queues 1 to N+1

Fixes: d5c199ea7ff7 ("netdev-dpdk: Properly support non pmd threads.")

Reported-by: 차은호 <eunho....@atto-research.com
Signed-off-by: Daniele Di Proietto <diproiet...@vmware.com>
---
 lib/dpif-netdev.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 76d1003..de700f7 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -1068,7 +1068,7 @@ do_add_port(struct dp_netdev *dp, const char *devname, 
const char *type,
         }
         /* There can only be ovs_numa_get_n_cores() pmd threads,
          * so creates a txq for each. */
-        error = netdev_set_multiq(netdev, n_cores, dp->n_dpdk_rxqs);
+        error = netdev_set_multiq(netdev, n_cores + 1, dp->n_dpdk_rxqs);
         if (error && (error != EOPNOTSUPP)) {
             VLOG_ERR("%s, cannot set multiq", devname);
             return errno;
@@ -2402,7 +2402,8 @@ dpif_netdev_pmd_set(struct dpif *dpif, unsigned int 
n_rxqs, const char *cmask)
                 }
 
                 /* Sets the new rx queue config.  */
-                err = netdev_set_multiq(port->netdev, ovs_numa_get_n_cores(),
+                err = netdev_set_multiq(port->netdev,
+                                        ovs_numa_get_n_cores() + 1,
                                         n_rxqs);
                 if (err && (err != EOPNOTSUPP)) {
                     VLOG_ERR("Failed to set dpdk interface %s rx_queue to:"
@@ -3328,8 +3329,18 @@ dpif_netdev_register_upcall_cb(struct dpif *dpif, 
upcall_callback *cb,
     dp->upcall_cb = cb;
 }
 
+static int
+core_id_to_qid(unsigned core_id)
+{
+    if (core_id != NON_PMD_CORE_ID) {
+        return core_id + 1;
+    } else {
+        return 0;
+    }
+}
+
 static void
-dp_netdev_drop_packets(struct dp_packet ** packets, int cnt, bool may_steal)
+dp_netdev_drop_packets(struct dp_packet **packets, int cnt, bool may_steal)
 {
     if (may_steal) {
         int i;
@@ -3387,7 +3398,8 @@ dp_execute_cb(void *aux_, struct dp_packet **packets, int 
cnt,
     case OVS_ACTION_ATTR_OUTPUT:
         p = dp_netdev_lookup_port(dp, u32_to_odp(nl_attr_get_u32(a)));
         if (OVS_LIKELY(p)) {
-            netdev_send(p->netdev, pmd->core_id, packets, cnt, may_steal);
+            netdev_send(p->netdev, core_id_to_qid(pmd->core_id), packets, cnt,
+                        may_steal);
             return;
         }
         break;
-- 
2.1.4

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to