]> git.proxmox.com Git - mirror_ovs.git/commitdiff
lib/tc: add set ipv6 traffic class action offload via pedit
authorPieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>
Mon, 28 Jan 2019 12:29:10 +0000 (12:29 +0000)
committerSimon Horman <simon.horman@netronome.com>
Thu, 31 Jan 2019 09:53:25 +0000 (10:53 +0100)
Extend ovs-tc translation by allowing non-byte-aligned fields
for set actions. Use new boundary shifts and add set ipv6 traffic
class action offload via pedit.

Signed-off-by: Pieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>
Signed-off-by: Louis Peens <louis.peens@netronome.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
lib/netdev-tc-offloads.c
lib/tc.c
lib/tc.h

index 90bd3c5858bd3eebd787dcb2fdf1c8580d0519de..1c5bd22e45f10f6d27a750fc6e889db665a2db60 100644 (file)
@@ -84,6 +84,10 @@ static struct netlink_field set_flower_map[][4] = {
           offsetof(struct tc_flower_key, ipv6.rewrite_hlimit),
           MEMBER_SIZEOF(struct tc_flower_key, ipv6.rewrite_hlimit)
         },
+        { offsetof(struct ovs_key_ipv6, ipv6_tclass),
+          offsetof(struct tc_flower_key, ipv6.rewrite_tclass),
+          MEMBER_SIZEOF(struct tc_flower_key, ipv6.rewrite_tclass)
+        },
     },
     [OVS_KEY_ATTR_ETHERNET] = {
         { offsetof(struct ovs_key_ethernet, eth_src),
index 78905e1e98506b8cde2921d3c10f5be36619e6c6..e9c1fe4366941e20569c69e9f38b36e391a52bed 100644 (file)
--- a/lib/tc.c
+++ b/lib/tc.c
@@ -73,6 +73,7 @@ struct flower_key_to_pedit {
     int offset;
     int flower_offset;
     int size;
+    int boundary_shift;
 };
 
 static struct flower_key_to_pedit flower_pedit_map[] = {
@@ -80,72 +81,92 @@ static struct flower_key_to_pedit flower_pedit_map[] = {
         TCA_PEDIT_KEY_EX_HDR_TYPE_IP4,
         12,
         offsetof(struct tc_flower_key, ipv4.ipv4_src),
-        MEMBER_SIZEOF(struct tc_flower_key, ipv4.ipv4_src)
+        MEMBER_SIZEOF(struct tc_flower_key, ipv4.ipv4_src),
+        0
     }, {
         TCA_PEDIT_KEY_EX_HDR_TYPE_IP4,
         16,
         offsetof(struct tc_flower_key, ipv4.ipv4_dst),
-        MEMBER_SIZEOF(struct tc_flower_key, ipv4.ipv4_dst)
+        MEMBER_SIZEOF(struct tc_flower_key, ipv4.ipv4_dst),
+        0
     }, {
         TCA_PEDIT_KEY_EX_HDR_TYPE_IP4,
         8,
         offsetof(struct tc_flower_key, ipv4.rewrite_ttl),
-        MEMBER_SIZEOF(struct tc_flower_key, ipv4.rewrite_ttl)
+        MEMBER_SIZEOF(struct tc_flower_key, ipv4.rewrite_ttl),
+        0
     }, {
         TCA_PEDIT_KEY_EX_HDR_TYPE_IP4,
         1,
         offsetof(struct tc_flower_key, ipv4.rewrite_tos),
-        MEMBER_SIZEOF(struct tc_flower_key, ipv4.rewrite_tos)
+        MEMBER_SIZEOF(struct tc_flower_key, ipv4.rewrite_tos),
+        0
     }, {
         TCA_PEDIT_KEY_EX_HDR_TYPE_IP6,
         7,
         offsetof(struct tc_flower_key, ipv6.rewrite_hlimit),
-        MEMBER_SIZEOF(struct tc_flower_key, ipv6.rewrite_hlimit)
+        MEMBER_SIZEOF(struct tc_flower_key, ipv6.rewrite_hlimit),
+        0
     }, {
         TCA_PEDIT_KEY_EX_HDR_TYPE_IP6,
         8,
         offsetof(struct tc_flower_key, ipv6.ipv6_src),
-        MEMBER_SIZEOF(struct tc_flower_key, ipv6.ipv6_src)
+        MEMBER_SIZEOF(struct tc_flower_key, ipv6.ipv6_src),
+        0
     }, {
         TCA_PEDIT_KEY_EX_HDR_TYPE_IP6,
         24,
         offsetof(struct tc_flower_key, ipv6.ipv6_dst),
-        MEMBER_SIZEOF(struct tc_flower_key, ipv6.ipv6_dst)
+        MEMBER_SIZEOF(struct tc_flower_key, ipv6.ipv6_dst),
+        0
+    }, {
+        TCA_PEDIT_KEY_EX_HDR_TYPE_IP6,
+        0,
+        offsetof(struct tc_flower_key, ipv6.rewrite_tclass),
+        MEMBER_SIZEOF(struct tc_flower_key, ipv6.rewrite_tclass),
+        4
     }, {
         TCA_PEDIT_KEY_EX_HDR_TYPE_ETH,
         6,
         offsetof(struct tc_flower_key, src_mac),
-        MEMBER_SIZEOF(struct tc_flower_key, src_mac)
+        MEMBER_SIZEOF(struct tc_flower_key, src_mac),
+        0
     }, {
         TCA_PEDIT_KEY_EX_HDR_TYPE_ETH,
         0,
         offsetof(struct tc_flower_key, dst_mac),
-        MEMBER_SIZEOF(struct tc_flower_key, dst_mac)
+        MEMBER_SIZEOF(struct tc_flower_key, dst_mac),
+        0
     }, {
         TCA_PEDIT_KEY_EX_HDR_TYPE_ETH,
         12,
         offsetof(struct tc_flower_key, eth_type),
-        MEMBER_SIZEOF(struct tc_flower_key, eth_type)
+        MEMBER_SIZEOF(struct tc_flower_key, eth_type),
+        0
     }, {
         TCA_PEDIT_KEY_EX_HDR_TYPE_TCP,
         0,
         offsetof(struct tc_flower_key, tcp_src),
-        MEMBER_SIZEOF(struct tc_flower_key, tcp_src)
+        MEMBER_SIZEOF(struct tc_flower_key, tcp_src),
+        0
     }, {
         TCA_PEDIT_KEY_EX_HDR_TYPE_TCP,
         2,
         offsetof(struct tc_flower_key, tcp_dst),
-        MEMBER_SIZEOF(struct tc_flower_key, tcp_dst)
+        MEMBER_SIZEOF(struct tc_flower_key, tcp_dst),
+        0
     }, {
         TCA_PEDIT_KEY_EX_HDR_TYPE_UDP,
         0,
         offsetof(struct tc_flower_key, udp_src),
-        MEMBER_SIZEOF(struct tc_flower_key, udp_src)
+        MEMBER_SIZEOF(struct tc_flower_key, udp_src),
+        0
     }, {
         TCA_PEDIT_KEY_EX_HDR_TYPE_UDP,
         2,
         offsetof(struct tc_flower_key, udp_dst),
-        MEMBER_SIZEOF(struct tc_flower_key, udp_dst)
+        MEMBER_SIZEOF(struct tc_flower_key, udp_dst),
+        0
     },
 };
 
@@ -832,9 +853,13 @@ nl_parse_act_pedit(struct nlattr *options, struct tc_flower *flower)
                 int diff = flower_off + (keys->off - mf);
                 ovs_be32 *dst = (void *) (rewrite_key + diff);
                 ovs_be32 *dst_m = (void *) (rewrite_mask + diff);
-                ovs_be32 mask = ~(keys->mask);
+                ovs_be32 mask, mask_word, data_word;
                 uint32_t zero_bits;
 
+                mask_word = htonl(ntohl(keys->mask) << m->boundary_shift);
+                data_word = htonl(ntohl(keys->val) << m->boundary_shift);
+                mask = ~(mask_word);
+
                 if (keys->off < mf) {
                     zero_bits = 8 * (mf - keys->off);
                     mask &= htonl(UINT32_MAX >> zero_bits);
@@ -844,7 +869,7 @@ nl_parse_act_pedit(struct nlattr *options, struct tc_flower *flower)
                 }
 
                 *dst_m |= mask;
-                *dst |= keys->val & mask;
+                *dst |= data_word & mask;
             }
         }
 
@@ -1832,6 +1857,7 @@ nl_msg_put_flower_rewrite_pedits(struct ofpbuf *request,
 
         for (j = 0; j < cnt; j++,  mask++, data++, cur_offset += 4) {
             ovs_be32 mask_word = *mask;
+            ovs_be32 data_word = *data;
 
             if (j == 0) {
                 mask_word &= first_word_mask;
@@ -1853,8 +1879,10 @@ nl_msg_put_flower_rewrite_pedits(struct ofpbuf *request,
             pedit_key_ex->cmd = TCA_PEDIT_KEY_EX_CMD_SET;
             pedit_key_ex->htype = m->htype;
             pedit_key->off = cur_offset;
+            mask_word = htonl(ntohl(mask_word) >> m->boundary_shift);
+            data_word = htonl(ntohl(data_word) >> m->boundary_shift);
             pedit_key->mask = ~mask_word;
-            pedit_key->val = *data & mask_word;
+            pedit_key->val = data_word & mask_word;
             sel.sel.nkeys++;
 
             err = csum_update_flag(flower, m->htype);
index 04b08e298401631e80668ea8bad753831f3b3a13..6c909df21a9b860f1bdd308e14f9c891d7cc6c36 100644 (file)
--- a/lib/tc.h
+++ b/lib/tc.h
@@ -109,6 +109,7 @@ struct tc_flower_key {
         struct in6_addr ipv6_src;
         struct in6_addr ipv6_dst;
         uint8_t rewrite_hlimit;
+        uint8_t rewrite_tclass;
     } ipv6;
 
     struct {