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....@intel.com>
Signed-off-by: Paul M Stillwell Jr <paul.m.stillwell...@intel.com>
Signed-off-by: Qi Zhang <qi.z.zh...@intel.com>
---
 drivers/net/ice/base/ice_protocol_type.h |  6 +++---
 drivers/net/ice/base/ice_switch.c        | 13 +++++++++++++
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ice/base/ice_protocol_type.h 
b/drivers/net/ice/base/ice_protocol_type.h
index 98185c9de..f61345a7f 100644
--- a/drivers/net/ice/base/ice_protocol_type.h
+++ b/drivers/net/ice/base/ice_protocol_type.h
@@ -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;
diff --git a/drivers/net/ice/base/ice_switch.c 
b/drivers/net/ice/base/ice_switch.c
index 10dfc720a..80afa74cd 100644
--- a/drivers/net/ice/base/ice_switch.c
+++ b/drivers/net/ice/base/ice_switch.c
@@ -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:
-- 
2.13.6

Reply via email to