[ovs-dev,hwol,RFC,v1,2/5] netdev-dpdk: Add vlan push/pop hw offload

Message ID 1546285557-1617-3-git-send-email-ophirmu@mellanox.com
State New
Delegated to: Ian Stokes
Headers show
Series
  • Support hw offloaded flows
Related show

Commit Message

Ophir Munk Dec. 31, 2018, 7:45 p.m.
This commit adds vlan push/pop hw offload. For more details on hw
offload please see commit message in [1].
The hw offload vlan push operation is split internally by DPDK into
three actions: pushing VLAN next ethernet type, vlan id and vlan PCP
bit.
This commit requires linking with LDFLAGS="-lnl".

[1]
Commit 1a3a23f7ed: ("netdev-dpdk: add port output hw offlowd")

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
---
 lib/netdev-dpdk.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

Patch

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 04413eb..0c0a513 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -39,6 +39,7 @@ 
 #include <rte_vhost.h>
 #include <rte_version.h>
 #include <rte_flow.h>
+#include <netlink/attr.h>
 
 #include "cmap.h"
 #include "dirs.h"
@@ -4764,6 +4765,9 @@  end_proto_check:
         goto out;
     }
     struct rte_flow_action_port_id port_id;
+    struct rte_flow_action_of_push_vlan push_vlan;
+    struct rte_flow_action_of_set_vlan_vid vlan_vid;
+    struct rte_flow_action_of_set_vlan_pcp vlan_pcp;
     NL_ATTR_FOR_EACH_UNSAFE (a, left, nl_actions, actions_len) {
         int type = nl_attr_type(a);
         switch ((enum ovs_action_attr) type) {
@@ -4782,8 +4786,26 @@  end_proto_check:
             add_flow_action(&actions, RTE_FLOW_ACTION_TYPE_PORT_ID, &port_id);
             break;
         }
-        case OVS_ACTION_ATTR_PUSH_VLAN:
-        case OVS_ACTION_ATTR_POP_VLAN:
+        case OVS_ACTION_ATTR_PUSH_VLAN: {
+            const struct ovs_action_push_vlan *vlan;
+            vlan = nla_data(a);
+            push_vlan.ethertype = vlan->vlan_tpid;
+            add_flow_action(&actions, RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
+                            &push_vlan);
+            vlan_vid.vlan_vid = vlan->vlan_tci & htons(VLAN_VID_MASK);
+            add_flow_action(&actions, RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
+                            &vlan_vid);
+            vlan_pcp.vlan_pcp =
+                (ntohs(vlan->vlan_tci) & VLAN_PCP_MASK) > VLAN_PCP_SHIFT;
+            add_flow_action(&actions, RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
+                            &vlan_pcp);
+            break;
+        }
+        case OVS_ACTION_ATTR_POP_VLAN: {
+            add_flow_action(&actions, RTE_FLOW_ACTION_TYPE_OF_POP_VLAN, NULL);
+            break;
+        }
+
         case OVS_ACTION_ATTR_UNSPEC:
         case OVS_ACTION_ATTR_USERSPACE:
         case OVS_ACTION_ATTR_SET: