[ovs-dev] [PATCH] netdev-offload-dpdk : add ipv6 rte flow item support

Timo_Liu liuchang at cmss.chinamobile.com
Thu Sep 12 02:45:27 UTC 2019



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 at cmss.chinamobile.com>






diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c

index 01e9004..ab3f82b 100644

--- a/lib/netdev-offload-dpdk.c

+++ b/lib/netdev-offload-dpdk.c

@@ -433,7 +433,10 @@ netdev_offload_dpdk_add_flow(struct netdev *netdev,

     struct flow_items {

         struct rte_flow_item_eth  eth;

         struct rte_flow_item_vlan vlan;

-        struct rte_flow_item_ipv4 ipv4;

+        union {

+            struct rte_flow_item_ipv4 ipv4;

+            struct rte_flow_item_ipv6 ipv6;

+        };

         union {

             struct rte_flow_item_tcp  tcp;

             struct rte_flow_item_udp  udp;

@@ -503,6 +506,31 @@ netdev_offload_dpdk_add_flow(struct netdev *netdev,

                 mask.ipv4.hdr.next_proto_id;

     }




+    /* IP v6 */

+    if (match->flow.dl_type == htons(ETH_TYPE_IPV6)) {

+        int i =0;

+

+        spec.ipv6.hdr.vtc_flow   = match->flow.ipv6_label;

+        spec.ipv6.hdr.proto      = match->flow.nw_proto;

+        spec.ipv6.hdr.hop_limits = match->flow.nw_ttl;

+

+        mask.ipv6.hdr.vtc_flow   = match->wc.masks.ipv6_label;

+        mask.ipv6.hdr.proto      = match->wc.masks.nw_proto;

+        mask.ipv6.hdr.hop_limits = match->wc.masks.nw_ttl;

+



+        for (i = 0; i < 16; i++) {

+            spec.ipv6.hdr.src_addr[i] = match->flow.ipv6_src.s6_addr[i];

+            spec.ipv6.hdr.dst_addr[i] = match->flow.ipv6_dst.s6_addr[i];

+

+            mask.ipv6.hdr.src_addr[i] = match->wc.masks.ipv6_src.s6_addr[i];

+            mask.ipv6.hdr.dst_addr[i] = match->wc.masks.ipv6_dst.s6_addr[i];

+        }

+

+        add_flow_pattern(&amp;patterns, RTE_FLOW_ITEM_TYPE_IPV6,

+                         &amp;spec.ipv6, &amp;mask.ipv6);

+

+    }

+

     if (proto != IPPROTO_ICMP &amp;&amp; proto != IPPROTO_UDP  &amp;&amp;

         proto != IPPROTO_SCTP &amp;&amp; proto != IPPROTO_TCP  &amp;&amp;

         (match->wc.masks.tp_src ||








Best Regards

Timo_liu


More information about the dev mailing list