diff mbox series

[ovs-dev,24/62] netdev-offload-dpdk: add dpdk flow_dump_crate flow_dump_destroy api

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

Commit Message

Tao YunXiang Dec. 28, 2020, 9:24 a.m. UTC
From: Rongyin <rongyin@cmss.chinamobile.com>

Code Source From: Self Code

Description:

    add dpdk flow_dump_crate flow_dump_destroy api

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

Patch

diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c
index 445ca22..63379e3 100644
--- a/lib/netdev-offload-dpdk.c
+++ b/lib/netdev-offload-dpdk.c
@@ -1390,6 +1390,13 @@  netdev_offload_dpdk_actions(struct netdev *netdev,
                                                actions.actions, &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 {
         flow = netdev_offload_dpdk_flow_create(netdev, &flow_attr, patterns->items,
@@ -1643,10 +1650,33 @@  out:
     return ret;
 }
 
+static int
+netdev_offload_dpdk_flow_dump_create(struct netdev *netdev,
+                                     struct netdev_flow_dump **dump_out)
+{
+    struct netdev_flow_dump *dump;
+
+    dump = xzalloc(sizeof *dump);
+    dump->netdev = netdev_ref(netdev);
+
+    *dump_out = dump;
+    return 0;
+}
+
+static int
+netdev_offload_dpdk_flow_dump_destroy(struct netdev_flow_dump *dump)
+{
+    netdev_close(dump->netdev);
+    free(dump);
+    return 0;
+}
+
 const struct netdev_flow_api netdev_offload_dpdk = {
     .type = "dpdk_flow_api",
     .flow_put = netdev_offload_dpdk_flow_put,
     .flow_del = netdev_offload_dpdk_flow_del,
     .init_flow_api = netdev_offload_dpdk_init_flow_api,
     .flow_get = netdev_offload_dpdk_flow_get,
+    .flow_dump_create = netdev_offload_dpdk_flow_dump_create,
+    .flow_dump_destroy = netdev_offload_dpdk_flow_dump_destroy,
 };