diff mbox series

[ovs-dev,14/62] netdev-offload-dpdk: add vxlan encap action dump method

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

Commit Message

taoyunxiang Dec. 28, 2020, 9:24 a.m. UTC
From: Liuchang <liuchang@cmss.chinamobile.com>

Code Source From: Self Code
Description:

   For debug reason, add vxlan encap action dump method

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

Patch

diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c
index 7e59d51..8f8a85b 100644
--- a/lib/netdev-offload-dpdk.c
+++ b/lib/netdev-offload-dpdk.c
@@ -326,6 +326,31 @@  dump_flow_pattern(struct ds *s, const struct rte_flow_item *item)
         } else {
             ds_put_cstr(s, "  Mask = null\n");
         }
+    } else if (item->type == RTE_FLOW_ITEM_TYPE_VXLAN) {
+        const struct rte_flow_item_vxlan *vxlan_spec = item->spec;
+        const struct rte_flow_item_vxlan *vxlan_mask = item->mask;
+
+        ds_put_cstr(s, "rte flow vxlan pattern:\n");
+        ds_put_cstr(s, "vxlan ");
+        if (vxlan_spec) {
+            ds_put_format(s, "  Spec: flags=0x%x, vni=%d\n",
+                          vxlan_spec->flags,
+                          ntohl(*(ovs_be32 *)vxlan_spec->vni) >> 8);
+            ds_put_format(s, "vni spec %d ",
+                          ntohl(*(ovs_be32 *)vxlan_spec->vni) >> 8);
+        } else {
+            ds_put_cstr(s, "  Spec = null\n");
+        }
+        if (vxlan_mask) {
+            ds_put_format(s, "  Mask: flags=0x%x, vni=0x%06x\n",
+                          vxlan_mask->flags,
+                          ntohl(*(ovs_be32 *)vxlan_mask->vni) >> 8);
+            ds_put_format(s, "vni mask 0x%06x ",
+                          ntohl(*(ovs_be32 *)vxlan_mask->vni) >> 8);
+        } else {
+            ds_put_cstr(s, "  Mask = null\n");
+        }
+        ds_put_cstr(s, "/ ");
     } else {
         ds_put_format(s, "unknown rte flow pattern (%d)\n", item->type);
     }
@@ -374,6 +399,26 @@  dump_flow_action(struct ds *s, const struct rte_flow_action *actions)
         }
     } else if (actions->type == RTE_FLOW_ACTION_TYPE_DROP) {
         ds_put_cstr(s, "rte flow drop action\n");
+    } else if (actions->type == RTE_FLOW_ACTION_TYPE_RAW_ENCAP) {
+        const struct rte_flow_action_raw_encap *raw_encap = actions->conf;
+
+        ds_put_cstr(s, "rte flow raw-encap action:\n");
+        if (raw_encap) {
+            ds_put_format(s, "  Raw-encap: size=%ld\n", raw_encap->size);
+            ds_put_format(s, "  Raw-encap: encap=\n");
+            ds_put_hex_dump(s, raw_encap->data, raw_encap->size, 0, false);
+        } else {
+            ds_put_cstr(s, "  Raw-encap = null\n");
+        }
+    } else if (actions->type == RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP) {
+        const struct rte_flow_action_vxlan_encap *vxlan_encap = actions->conf;
+        const struct rte_flow_item *items = vxlan_encap->definition;
+
+        ds_put_cstr(s, "rte flow vxlan-encap action:\n");
+        ds_put_cstr(s, "vxlan_encap / ");
+        while (items && items->type != RTE_FLOW_ITEM_TYPE_END) {
+            dump_flow_pattern(s, items++);
+        }
     } else if (actions->type == RTE_FLOW_ACTION_TYPE_SET_MAC_SRC ||
                actions->type == RTE_FLOW_ACTION_TYPE_SET_MAC_DST) {
         const struct rte_flow_action_set_mac *set_mac = actions->conf;
@@ -459,6 +504,14 @@  netdev_offload_dpdk_flow_create(struct netdev *netdev,
     struct ds s;
 
     flow = netdev_dpdk_rte_flow_create(netdev, attr, items, actions, error);
+    /* work around: for dump_flow even if rte_flow create fail */
+    if (!VLOG_DROP_DBG(&rl)) {
+        ds_init(&s);
+        dump_flow(&s, attr, items, actions);
+        VLOG_DBG_RL(&rl, "TIMO:%s: rte_flow 0x%"PRIxPTR" printed:\n%s",
+                    netdev_get_name(netdev), (intptr_t) flow, ds_cstr(&s));
+        ds_destroy(&s);
+    }
     if (flow) {
         if (!VLOG_DROP_DBG(&rl)) {
             ds_init(&s);