diff mbox series

[ovs-dev,51/62] netdev-dpdk: add flag to distinct between pf and rep port

Message ID 20201228092520.11807-52-taoyunxiang@cmss.chinamobile.com
State Not Applicable
Headers show
Series DPDK Offload API to test | expand

Commit Message

Tao YunXiang Dec. 28, 2020, 9:25 a.m. UTC
From: Taoyunxiang <taoyunxiang@cmss.chinamobile.com>

Code Source From: Self Code
Description:
Add flag to distinct between pf and rep port.

Jira:  #[Optional]
市场项目编号(名称):[Optional]
---
 lib/netdev-dpdk.c         |  5 +++--
 lib/netdev-offload-dpdk.c | 29 +++++++++++++++++++++++++++--
 2 files changed, 30 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index cd3d156..8e093ed 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -5339,8 +5339,9 @@  netdev_dpdk_is_uplink_port(struct netdev *netdev)
 
     dev = netdev_dpdk_cast(netdev);
     ovs_mutex_lock(&dev->mutex);
-    /*ret = dev->is_uplink_port;*/
-    ret = (dev->type == DPDK_DEV_ETH);
+    if (strstr(dev->devargs,"representor=[10")) {
+        ret = true;
+    }
     ovs_mutex_unlock(&dev->mutex);
 out:
     return ret;
diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c
index b5e9002..f7c8f2b 100644
--- a/lib/netdev-offload-dpdk.c
+++ b/lib/netdev-offload-dpdk.c
@@ -2159,8 +2159,33 @@  netdev_offload_dpdk_flow_get(struct netdev *netdev,
         goto out;
     }
     attrs->dp_layer = "dpdk";
-    ret = netdev_dpdk_rte_flow_query_count(netdev, rte_flow_data->rte_flow,
-                                           &query, &error);
+    if (netdev_vport_is_vport_class(netdev->netdev_class)) {
+        struct netdev_flow_dump **netdev_dumps;
+        int num_ports = 0;
+        int i;
+
+        netdev_dumps = netdev_ports_flow_dump_create(netdev->dpif_type,
+                                                     &num_ports);
+        for (i = 0; i < num_ports; i++) {
+            if (!netdev_dpdk_is_uplink_port(netdev_dumps[i]->netdev)) {
+                continue;
+            }
+            ret = netdev_dpdk_rte_flow_query_count(netdev_dumps[i]->netdev, rte_flow_data->rte_flow,
+                                                   &query, &error);
+            break;
+        }
+        for (i = 0; i < num_ports; i++) {
+            int err = netdev_flow_dump_destroy(netdev_dumps[i]);
+
+            if (err != 0 && err != EOPNOTSUPP) {
+                VLOG_ERR("failed dumping netdev: %s", ovs_strerror(err));
+            }
+        }
+
+    } else {
+        ret = netdev_dpdk_rte_flow_query_count(netdev, rte_flow_data->rte_flow,
+                                               &query, &error);
+    }
     if (ret) {
         VLOG_DBG_RL(&rl, "%s: Failed to query ufid "UUID_FMT" flow: %p\n",
                     netdev_get_name(netdev), UUID_ARGS((struct uuid *) ufid),