[ovs-dev] [PATCH v1] netdev: fix partial offloading test cases failure

Yanqin Wei Yanqin.Wei at arm.com
Tue Feb 25 01:46:32 UTC 2020


Some partial offloading test cases are failing inconsistently. The root
cause is that dummy netdev is assigned with incorrect offloading flow API.
dpif-netdev - partial hw offload - dummy
dpif-netdev - partial hw offload - dummy-pmd
dpif-netdev - partial hw offload with packet modifications - dummy
dpif-netdev - partial hw offload with packet modifications - dummy-pmd

This patch fixes this issue by adding a specified flow api type in netdev.
Dummy netdev class can specify flow type in construct function. All of the
above cases can pass consistently.

Reviewed-by: Gavin Hu <Gavin.Hu at arm.com>
Reviewed-by: Lijian Zhang <Lijian.Zhang at arm.com>
Signed-off-by: Yanqin Wei <Yanqin.Wei at arm.com>
---
 lib/netdev-dummy.c    |  5 ++++-
 lib/netdev-offload.c  | 11 +++++++++++
 lib/netdev-provider.h |  1 +
 lib/netdev.c          |  1 +
 4 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/lib/netdev-dummy.c b/lib/netdev-dummy.c
index 71df29184..252b9d802 100644
--- a/lib/netdev-dummy.c
+++ b/lib/netdev-dummy.c
@@ -50,6 +50,8 @@ VLOG_DEFINE_THIS_MODULE(netdev_dummy);
 
 #define C_STATS_SIZE 2
 
+#define DUMMY_OFFLOAD_TYPE "dummy"
+
 struct reconnect;
 
 struct dummy_packet_stream {
@@ -709,6 +711,7 @@ netdev_dummy_construct(struct netdev *netdev_)
 
     dummy_packet_conn_init(&netdev->conn);
 
+    netdev_->flow_api_type = DUMMY_OFFLOAD_TYPE;
     ovs_list_init(&netdev->rxes);
     hmap_init(&netdev->offloaded_flows);
     ovs_mutex_unlock(&netdev->mutex);
@@ -1588,7 +1591,7 @@ netdev_dummy_offloads_init_flow_api(struct netdev *netdev)
 }
 
 static const struct netdev_flow_api netdev_offload_dummy = {
-    .type = "dummy",
+    .type = DUMMY_OFFLOAD_TYPE,
     .flow_put = netdev_dummy_flow_put,
     .flow_del = netdev_dummy_flow_del,
     .init_flow_api = netdev_dummy_offloads_init_flow_api,
diff --git a/lib/netdev-offload.c b/lib/netdev-offload.c
index 32eab5910..c4bc71618 100644
--- a/lib/netdev-offload.c
+++ b/lib/netdev-offload.c
@@ -173,6 +173,17 @@ netdev_assign_flow_api(struct netdev *netdev)
 {
     struct netdev_registered_flow_api *rfa;
 
+    if (netdev->flow_api_type &&
+        (rfa = netdev_lookup_flow_api(netdev->flow_api_type))) {
+        if (!rfa->flow_api->init_flow_api(netdev)) {
+            ovs_refcount_ref(&rfa->refcnt);
+            ovsrcu_set(&netdev->flow_api, rfa->flow_api);
+            VLOG_INFO("%s: Sepecified flow API '%s'.",
+                      netdev_get_name(netdev), rfa->flow_api->type);
+            return 0;
+        }
+    }
+
     CMAP_FOR_EACH (rfa, cmap_node, &netdev_flow_apis) {
         if (!rfa->flow_api->init_flow_api(netdev)) {
             ovs_refcount_ref(&rfa->refcnt);
diff --git a/lib/netdev-provider.h b/lib/netdev-provider.h
index 22f4cde33..5942166a8 100644
--- a/lib/netdev-provider.h
+++ b/lib/netdev-provider.h
@@ -93,6 +93,7 @@ struct netdev {
     struct ovs_list saved_flags_list; /* Contains "struct netdev_saved_flags". */
 
     /* Functions to control flow offloading. */
+    char *flow_api_type;
     OVSRCU_TYPE(const struct netdev_flow_api *) flow_api;
     struct netdev_hw_info hw_info;	/* offload-capable netdev info */
 };
diff --git a/lib/netdev.c b/lib/netdev.c
index f95b19af4..5c799f854 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -423,6 +423,7 @@ netdev_open(const char *name, const char *type, struct netdev **netdevp)
                 netdev->reconfigure_seq = seq_create();
                 netdev->last_reconfigure_seq =
                     seq_read(netdev->reconfigure_seq);
+                netdev->flow_api_type = NULL;
                 ovsrcu_set(&netdev->flow_api, NULL);
                 netdev->hw_info.oor = false;
                 netdev->node = shash_add(&netdev_shash, name, netdev);
-- 
2.17.1



More information about the dev mailing list