[v5,29/30] net/ice/base: add switch support for IPv6 tc field
Checks
Commit Message
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>
---
drivers/net/ice/base/ice_protocol_type.h | 6 +++---
drivers/net/ice/base/ice_switch.c | 13 +++++++++++++
2 files changed, 16 insertions(+), 3 deletions(-)
@@ -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;
@@ -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: