From: Qi Zhang Date: Mon, 23 Sep 2019 07:44:47 +0000 (+0800) Subject: net/ice/base: support switch for IPv6 TC field X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=53c4d83e41a322c5c44cff9184772723062c65fc;p=dpdk.git net/ice/base: support switch for IPv6 TC field 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 Signed-off-by: Paul M Stillwell Jr Signed-off-by: Qi Zhang Acked-by: Qiming Yang --- diff --git a/drivers/net/ice/base/ice_protocol_type.h b/drivers/net/ice/base/ice_protocol_type.h index 98185c9de0..f61345a7fe 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 10dfc720a9..80afa74cd0 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: