[ovs-dev] [PATCH 15/62] netdev-offload-dpdk: add vlan push action offloading mechanism

Tao YunXiang taoyunxiang at cmss.chinamobile.com
Mon Dec 28 09:24:33 UTC 2020


From: Liuchang <liuchang at cmss.chinamobile.com>

Code Source From: Self Code
Description:

    add vlan push action offloading machenism

Jira:  #[Optional]
市场项目编号(名称):[Optional]
---
 lib/netdev-offload-dpdk.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c
index 8f8a85b..cc5cbe0 100644
--- a/lib/netdev-offload-dpdk.c
+++ b/lib/netdev-offload-dpdk.c
@@ -419,6 +419,15 @@ dump_flow_action(struct ds *s, const struct rte_flow_action *actions)
         while (items && items->type != RTE_FLOW_ITEM_TYPE_END) {
             dump_flow_pattern(s, items++);
         }
+    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN) {
+        const struct rte_flow_action_of_push_vlan *vlan_tci = actions->conf;
+         
+        if (vlan_tci) {
+            ds_put_format(s, "rte flow vlan-push action:\n");
+            ds_put_format(s, "vlan-encap: tci=%"PRIu16"\n",ntohs(vlan_tci->ethertype));
+        } else {
+            ds_put_format(s, "vlan-encap: null\n");
+        }
     } 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;
@@ -1202,9 +1211,14 @@ parse_clone_actions(struct netdev *netdev,
             if (add_output_action(netdev, actions, ca,info)) {
                 return -1;
             }
-        /* work around: tmp bypass vlan push action*/
         } else if (clone_type == OVS_ACTION_ATTR_PUSH_VLAN) {
-            continue;
+            const struct ovs_action_push_vlan *vlan = nl_attr_get(ca);
+            struct rte_flow_action_of_push_vlan *vlan_tci;
+
+            vlan_tci = xzalloc(sizeof *vlan_tci);
+            vlan_tci->ethertype = vlan->vlan_tci & ~htons(VLAN_CFI);
+            add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
+                            vlan_tci);
         } else {
             VLOG_DBG_RL(&rl,
                         "Unsupported nested action inside clone(), "
@@ -1255,6 +1269,14 @@ parse_flow_actions(struct netdev *netdev,
                 return -1;
             }
 
+        } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_PUSH_VLAN) {
+            const struct ovs_action_push_vlan *vlan = nl_attr_get(nla);
+            struct rte_flow_action_of_push_vlan *vlan_tci;
+
+            vlan_tci = xzalloc(sizeof *vlan_tci);
+            vlan_tci->ethertype = vlan->vlan_tci & ~htons(VLAN_CFI);
+            add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
+                            vlan_tci);
         } else {
             VLOG_DBG_RL(&rl, "Unsupported action type %d", nl_attr_type(nla));
             return -1;
-- 
1.8.3.1





More information about the dev mailing list