[ovs-dev] netdev-offload-dpdk : add ipv6 rte flow item support
diff mbox series

Message ID 1580393053-1203-1-git-send-email-liuchang@cmss.chinamobile.com
State New
Headers show
Series
  • [ovs-dev] netdev-offload-dpdk : add ipv6 rte flow item support
Related show

Commit Message

LIU CHANG Jan. 30, 2020, 2:04 p.m. UTC
From: Liu Chang <liuchang@cmss.chinamobile.com>

Nowadays some Nics support hw offloading via dpdk rte_flow lib.
Many layer2-layer4 fields can be offloaded to nics, including smac/dmac
ipv4 sip/dip etc. Also some nics(including intel X710) supports ipv6
header offloading, but when we execute netdev_offload_dpdk_add_flow,
there is no IPV6 rte_flow pattern.

This patch adds support for IPV6 header hw-offload rte_flow pattern,
including ipv6_label, nw_ttl, nw_proto, ipv6 sip and dip, also the
corresponding mask filed is added.

Signed-off-by: Liu Chang <liuchang@cmss.chinamobile.com>
---
 lib/netdev-offload-dpdk.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

Patch
diff mbox series

diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c
index f8c46bbaa..f8d3a044a 100644
--- a/lib/netdev-offload-dpdk.c
+++ b/lib/netdev-offload-dpdk.c
@@ -635,6 +635,38 @@  parse_flow_match(struct flow_patterns *patterns,
         next_proto_mask = &mask->hdr.next_proto_id;
     }
 
+    /* IP v6 */
+    if (match->flow.dl_type == htons(ETH_TYPE_IPV6)) {
+        int i =0;
+        struct rte_flow_item_ipv6 *spec, *mask;
+
+        spec = xzalloc(sizeof *spec);
+        mask = xzalloc(sizeof *mask);
+
+        spec->hdr.vtc_flow    = match->flow.ipv6_label;
+        spec->hdr.proto       = match->flow.nw_proto;
+        spec->hdr.hop_limits  = match->flow.nw_ttl;
+
+        mask->hdr.vtc_flow    = match->wc.masks.ipv6_label;
+        mask->hdr.proto       = match->wc.masks.nw_proto;
+        mask->hdr.hop_limits  = match->wc.masks.nw_ttl;
+
+        for (i = 0; i < 16; i++) {
+
+            spec->hdr.src_addr[i] = match->flow.ipv6_src.s6_addr[i];
+            spec->hdr.dst_addr[i] = match->flow.ipv6_dst.s6_addr[i];
+
+            mask->hdr.src_addr[i] = match->wc.masks.ipv6_src.s6_addr[i];
+            mask->hdr.dst_addr[i] = match->wc.masks.ipv6_dst.s6_addr[i];
+        }
+
+        add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_IPV6, spec, mask);
+
+        /* Save proto for L4 protocol setup. */
+        proto = spec->hdr.proto & mask->hdr.proto;
+        next_proto_mask = &mask->hdr.proto;
+    }
+
     if (proto != IPPROTO_ICMP && proto != IPPROTO_UDP  &&
         proto != IPPROTO_SCTP && proto != IPPROTO_TCP  &&
         (match->wc.masks.tp_src ||