net/ice/base: support switch for IPv6 TC field
authorQi Zhang <qi.z.zhang@intel.com>
Mon, 23 Sep 2019 07:44:47 +0000 (15:44 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 7 Oct 2019 13:00:56 +0000 (15:00 +0200)
Add support for IPv6 traffic class (tc) field for switch rule.
Correct ice_ipv6_hdr based on the IPv6 Protocol using bitfields.
Add big/little endian convert for tc field before it is inserted,
since tc is only one byte and also does not have a byte-aligned
offset.

Signed-off-by: Junfeng Guo <junfeng.guo@intel.com>
Signed-off-by: Paul M Stillwell Jr <paul.m.stillwell.jr@intel.com>
Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Qiming Yang <qiming.yang@intel.com>
drivers/net/ice/base/ice_protocol_type.h
drivers/net/ice/base/ice_switch.c

index 98185c9..f61345a 100644 (file)
@@ -183,9 +183,9 @@ struct ice_ipv4_hdr {
 };
 
 struct ice_ipv6_hdr {
-       u8 version;
-       u8 tc;
-       u16 flow_label;
+       u32 version:4;
+       u32 tc:8;
+       u32 flow_label:20;
        u16 payload_len;
        u8 next_hdr;
        u8 hop_limit;
index 10dfc72..80afa74 100644 (file)
@@ -5785,6 +5785,19 @@ ice_fill_adv_dummy_packet(struct ice_adv_lkup_elem *lkups, u16 lkups_cnt,
                        break;
                case ICE_IPV6_OFOS:
                case ICE_IPV6_IL:
+                       /* Based on the same mechanism below, if tc (Traffic
+                        * Class) for IPv6 has mask, it means tc field is set.
+                        * Since tc is only one byte, we have to handle the
+                        * big/little endian issue before it can be inserted.
+                        */
+                       if (lkups[i].m_u.ipv6_hdr.tc) {
+                               ((u16 *)&lkups[i].h_u)[0] =
+                                       (((u16 *)&lkups[i].h_u)[0] << 8) |
+                                       (((u16 *)&lkups[i].h_u)[0] >> 8);
+                               ((u16 *)&lkups[i].m_u)[0] =
+                                       (((u16 *)&lkups[i].m_u)[0] << 8) |
+                                       (((u16 *)&lkups[i].m_u)[0] >> 8);
+                       }
                        len = sizeof(struct ice_ipv6_hdr);
                        break;
                case ICE_TCP_IL: