Support QinQ offload

Signed-off-by: Allen Chen <[email protected]>
---
 NEWS                      |  5 +++++
 lib/netdev-offload-dpdk.c | 31 +++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/NEWS b/NEWS
index 03ad245ab..39456fc21 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,8 @@
+v3.4.0 - 20 Nov 2024
+---------------------
+    - Add support for QinQ offload.
+
+
 v3.4.0 - 12 Nov 2024
 ---------------------
     - Add support for ICMPV6 offload.
diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c
index 1ec5d175b..956bb9198 100644
--- a/lib/netdev-offload-dpdk.c
+++ b/lib/netdev-offload-dpdk.c
@@ -1399,6 +1399,7 @@ parse_flow_match(struct netdev *netdev,
                  struct match *match)
 {
     struct rte_flow_item_eth *eth_spec = NULL, *eth_mask = NULL;
+    struct rte_flow_item_vlan *vlan_spec = NULL, *vlan_mask = NULL;
     struct flow *consumed_masks;
     uint8_t proto = 0;
 
@@ -1471,6 +1472,9 @@ parse_flow_match(struct netdev *netdev,
             eth_mask->type = match->wc.masks.vlans[0].tpid;
         }
 
+        vlan_spec = spec;
+        vlan_mask = mask;
+
         add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_VLAN, spec, mask, NULL);
     }
     /* For untagged matching match->wc.masks.vlans[0].tci is 0xFFFF and
@@ -1479,6 +1483,33 @@ parse_flow_match(struct netdev *netdev,
      */
     memset(&consumed_masks->vlans[0], 0, sizeof consumed_masks->vlans[0]);
 
+    /* VLAN */
+    if (match->wc.masks.vlans[1].tci && match->flow.vlans[1].tci) {
+        struct rte_flow_item_vlan *spec, *mask;
+
+        spec = xzalloc(sizeof *spec);
+        mask = xzalloc(sizeof *mask);
+
+        spec->tci = match->flow.vlans[1].tci & ~htons(VLAN_CFI);
+        mask->tci = match->wc.masks.vlans[1].tci & ~htons(VLAN_CFI);
+
+        if (vlan_spec && vlan_mask) {
+            vlan_spec->has_more_vlan = 1;
+            vlan_mask->has_more_vlan = 1;
+            spec->inner_type = vlan_spec->inner_type;
+            mask->inner_type = vlan_mask->inner_type;
+            vlan_spec->inner_type = match->flow.vlans[1].tpid;
+            vlan_mask->inner_type = match->wc.masks.vlans[1].tpid;
+        }
+
+        add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_VLAN, spec, mask, NULL);
+    }
+    /* For untagged matching match->wc.masks.vlans[0].tci is 0xFFFF and
+     * match->flow.vlans[0].tci is 0. Consuming is needed outside of the if
+     * scope to handle that.
+     */
+    memset(&consumed_masks->vlans[1], 0, sizeof consumed_masks->vlans[1]);
+
     /* IP v4 */
     if (match->flow.dl_type == htons(ETH_TYPE_IP)) {
         struct rte_flow_item_ipv4 *spec, *mask, *last = NULL;
-- 
2.33.0.windows.2

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to