]> git.proxmox.com Git - mirror_ovs.git/blobdiff - lib/netdev-offload-dpdk.c
netdev-offload-dpdk: Support offload of VLAN PUSH/POP actions.
[mirror_ovs.git] / lib / netdev-offload-dpdk.c
index f8c46bbaada096433c6b573e9fc84d148634c3f3..26a75f0f282ddb624ff72e9b9f1982f2c9e38d06 100644 (file)
@@ -420,6 +420,41 @@ dump_flow_action(struct ds *s, const struct rte_flow_action *actions)
         } else {
             ds_put_format(s, "  Set-%s-tcp/udp-port = null\n", dirstr);
         }
+    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN) {
+        const struct rte_flow_action_of_push_vlan *rte_push_vlan;
+
+        rte_push_vlan = actions->conf;
+        ds_put_cstr(s, "rte flow push-vlan action:\n");
+        if (rte_push_vlan) {
+            ds_put_format(s, "  Push-vlan: 0x%"PRIx16"\n",
+                          ntohs(rte_push_vlan->ethertype));
+        } else {
+            ds_put_format(s, "  Push-vlan = null\n");
+        }
+    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP) {
+        const struct rte_flow_action_of_set_vlan_pcp *rte_vlan_pcp;
+
+        rte_vlan_pcp = actions->conf;
+        ds_put_cstr(s, "rte flow set-vlan-pcp action:\n");
+        if (rte_vlan_pcp) {
+            ds_put_format(s, "  Set-vlan-pcp: %"PRIu8"\n",
+                          rte_vlan_pcp->vlan_pcp);
+        } else {
+            ds_put_format(s, "  Set-vlan-pcp = null\n");
+        }
+    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID) {
+        const struct rte_flow_action_of_set_vlan_vid *rte_vlan_vid;
+
+        rte_vlan_vid = actions->conf;
+        ds_put_cstr(s, "rte flow set-vlan-vid action:\n");
+        if (rte_vlan_vid) {
+            ds_put_format(s, "  Set-vlan-vid: %"PRIu16"\n",
+                          ntohs(rte_vlan_vid->vlan_vid));
+        } else {
+            ds_put_format(s, "  Set-vlan-vid = null\n");
+        }
+    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_POP_VLAN) {
+        ds_put_cstr(s, "rte flow pop-vlan action\n");
     } else {
         ds_put_format(s, "unknown rte flow action (%d)\n", actions->type);
     }
@@ -970,6 +1005,30 @@ parse_set_actions(struct flow_actions *actions,
     return 0;
 }
 
+static int
+parse_vlan_push_action(struct flow_actions *actions,
+                       const struct ovs_action_push_vlan *vlan_push)
+{
+    struct rte_flow_action_of_push_vlan *rte_push_vlan;
+    struct rte_flow_action_of_set_vlan_pcp *rte_vlan_pcp;
+    struct rte_flow_action_of_set_vlan_vid *rte_vlan_vid;
+
+    rte_push_vlan = xzalloc(sizeof *rte_push_vlan);
+    rte_push_vlan->ethertype = vlan_push->vlan_tpid;
+    add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN, rte_push_vlan);
+
+    rte_vlan_pcp = xzalloc(sizeof *rte_vlan_pcp);
+    rte_vlan_pcp->vlan_pcp = vlan_tci_to_pcp(vlan_push->vlan_tci);
+    add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
+                    rte_vlan_pcp);
+
+    rte_vlan_vid = xzalloc(sizeof *rte_vlan_vid);
+    rte_vlan_vid->vlan_vid = htons(vlan_tci_to_vid(vlan_push->vlan_tci));
+    add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
+                    rte_vlan_vid);
+    return 0;
+}
+
 static int
 parse_flow_actions(struct netdev *netdev,
                    struct flow_actions *actions,
@@ -998,6 +1057,14 @@ parse_flow_actions(struct netdev *netdev,
                                   masked)) {
                 return -1;
             }
+        } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_PUSH_VLAN) {
+            const struct ovs_action_push_vlan *vlan = nl_attr_get(nla);
+
+            if (parse_vlan_push_action(actions, vlan)) {
+                return -1;
+            }
+        } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_POP_VLAN) {
+            add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_POP_VLAN, NULL);
         } else {
             VLOG_DBG_RL(&rl, "Unsupported action type %d", nl_attr_type(nla));
             return -1;