From patchwork Tue Nov 12 03:21:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhao1, Wei" X-Patchwork-Id: 62858 X-Patchwork-Delegate: xiaolong.ye@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3BB7BA04B7; Tue, 12 Nov 2019 04:56:13 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 078DA237; Tue, 12 Nov 2019 04:56:12 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 97D24A3 for ; Tue, 12 Nov 2019 04:56:09 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Nov 2019 19:56:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,294,1569308400"; d="scan'208";a="404109049" Received: from dpdk6.bj.intel.com ([172.16.182.194]) by fmsmga005.fm.intel.com with ESMTP; 11 Nov 2019 19:56:07 -0800 From: Wei Zhao To: dev@dpdk.org Cc: xiaolong.ye@intel.com, Dan Nowlin , Wei Zhao , Qi Zhang Date: Tue, 12 Nov 2019 11:21:55 +0800 Message-Id: <1573528915-38461-1-git-send-email-wei.zhao1@intel.com> X-Mailer: git-send-email 2.7.5 Subject: [dpdk-dev] [PATCH] net/ice/base: correct swtch programming IPV6 header bitmask X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Correct an error in the IPV6 header bitmask used for programming switch rules. Also, change other programming switch headers to use big endian fields in order to make setting these easier. Fixes: 04b8ec1ea807 ("net/ice/base: add protocol structures and defines") Signed-off-by: Dan Nowlin Signed-off-by: Wei Zhao Signed-off-by: Qi Zhang Acked-by: Xiaolong Ye --- drivers/net/ice/base/ice_protocol_type.h | 79 ++++++++++++++++++-------------- drivers/net/ice/base/ice_switch.c | 15 +----- drivers/net/ice/ice_switch_filter.c | 9 +++- 3 files changed, 52 insertions(+), 51 deletions(-) diff --git a/drivers/net/ice/base/ice_protocol_type.h b/drivers/net/ice/base/ice_protocol_type.h index 548c973..fdcbb2c 100644 --- a/drivers/net/ice/base/ice_protocol_type.h +++ b/drivers/net/ice/base/ice_protocol_type.h @@ -155,38 +155,47 @@ struct ice_ether_hdr { }; struct ice_ethtype_hdr { - u16 ethtype_id; + __be16 ethtype_id; }; struct ice_ether_vlan_hdr { u8 dst_addr[ETH_ALEN]; u8 src_addr[ETH_ALEN]; - u32 vlan_id; + __be32 vlan_id; }; struct ice_vlan_hdr { - u16 vlan; - u16 type; + __be16 vlan; + __be16 type; }; struct ice_ipv4_hdr { u8 version; u8 tos; - u16 total_length; - u16 id; - u16 frag_off; + __be16 total_length; + __be16 id; + __be16 frag_off; u8 time_to_live; u8 protocol; - u16 check; - u32 src_addr; - u32 dst_addr; + __be16 check; + __be32 src_addr; + __be32 dst_addr; +}; + +struct ice_le_ver_tc_flow { + union { + struct { + u32 flow_label : 20; + u32 tc : 8; + u32 version : 4; + } fld; + u32 val; + } u; }; struct ice_ipv6_hdr { - u32 version:4; - u32 tc:8; - u32 flow_label:20; - u16 payload_len; + __be32 be_ver_tc_flow; + __be16 payload_len; u8 next_hdr; u8 hop_limit; u8 src_addr[ICE_IPV6_ADDR_LENGTH]; @@ -194,32 +203,32 @@ struct ice_ipv6_hdr { }; struct ice_sctp_hdr { - u16 src_port; - u16 dst_port; - u32 verification_tag; - u32 check; + __be16 src_port; + __be16 dst_port; + __be32 verification_tag; + __be32 check; }; struct ice_l4_hdr { - u16 src_port; - u16 dst_port; - u16 len; - u16 check; + __be16 src_port; + __be16 dst_port; + __be16 len; + __be16 check; }; struct ice_udp_tnl_hdr { - u16 field; - u16 proto_type; - u32 vni; /* only use lower 24-bits */ + __be16 field; + __be16 proto_type; + __be32 vni; /* only use lower 24-bits */ }; #pragma pack(1) struct ice_udp_gtp_hdr { u8 flags; u8 msg_type; - u16 rsrvd_len; - u32 teid; - u16 rsrvd_seq_nbr; + __be16 rsrvd_len; + __be32 teid; + __be16 rsrvd_seq_nbr; u8 rsrvd_n_pdu_nbr; u8 rsrvd_next_ext; u8 rsvrd_ext_len; @@ -230,17 +239,17 @@ struct ice_udp_gtp_hdr { struct ice_pppoe_hdr { u8 rsrvd_ver_type; - u8 rsrved_code; - u16 session_id; - u16 length; - u16 ppp_prot_id; /* control and data only */ + u8 rsrvd_code; + __be16 session_id; + __be16 length; + __be16 ppp_prot_id; /* control and data only */ }; #pragma pack() struct ice_nvgre { - u16 flags; - u16 protocol; - u32 tni_flow; + __be16 flags; + __be16 protocol; + __be32 tni_flow; }; union ice_prot_hdr { diff --git a/drivers/net/ice/base/ice_switch.c b/drivers/net/ice/base/ice_switch.c index 36da27f..afa4fe3 100644 --- a/drivers/net/ice/base/ice_switch.c +++ b/drivers/net/ice/base/ice_switch.c @@ -5789,19 +5789,6 @@ 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: @@ -5896,7 +5883,7 @@ ice_fill_adv_packet_tun(struct ice_hw *hw, enum ice_sw_tunnel_type tun_type, offset = offsets[i].offset; hdr = (struct ice_l4_hdr *)&pkt[offset]; - hdr->dst_port = open_port << 8 | open_port >> 8; + hdr->dst_port = CPU_TO_BE16(open_port); return ICE_SUCCESS; } diff --git a/drivers/net/ice/ice_switch_filter.c b/drivers/net/ice/ice_switch_filter.c index 2406102..4a9356b 100644 --- a/drivers/net/ice/ice_switch_filter.c +++ b/drivers/net/ice/ice_switch_filter.c @@ -587,11 +587,16 @@ ice_switch_inset_get(const struct rte_flow_item pattern[], (RTE_IPV6_HDR_TC_MASK)) == rte_cpu_to_be_32 (RTE_IPV6_HDR_TC_MASK)) { - f->tc = (rte_be_to_cpu_32 + struct ice_le_ver_tc_flow vtf; + vtf.u.fld.version = 0; + vtf.u.fld.flow_label = 0; + vtf.u.fld.tc = (rte_be_to_cpu_32 (ipv6_spec->hdr.vtc_flow) & RTE_IPV6_HDR_TC_MASK) >> RTE_IPV6_HDR_TC_SHIFT; - s->tc = UINT8_MAX; + f->be_ver_tc_flow = CPU_TO_BE32(vtf.u.val); + vtf.u.fld.tc = UINT8_MAX; + s->be_ver_tc_flow = CPU_TO_BE32(vtf.u.val); } t++; } else if (!ipv6_spec && !ipv6_mask) {