From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5874DA0546; Wed, 26 May 2021 05:33:50 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C3AE140150; Wed, 26 May 2021 05:33:49 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 16BCD4003F; Wed, 26 May 2021 05:33:47 +0200 (CEST) IronPort-SDR: 3UxmIzGA48Hl8qfN4ZOGBd/wR9CjeUCQyqJ2NGAc0aEHH2TjAix+CBZtaM52F6tsqwdxyQwzJ4 LAhMy3ZNHgrg== X-IronPort-AV: E=McAfee;i="6200,9189,9995"; a="202408287" X-IronPort-AV: E=Sophos;i="5.82,330,1613462400"; d="scan'208";a="202408287" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 May 2021 20:33:46 -0700 IronPort-SDR: H0fKfrNw/VoCpi5KuAMJyNlLcHcEwda0eGRdpROm+sbzozQ5QDEPNXf0XuRVYDYnr22oSG125N w3Qm5T/5Clww== X-IronPort-AV: E=Sophos;i="5.82,330,1613462400"; d="scan'208";a="476728820" Received: from unknown (HELO localhost.localdomain) ([10.240.183.93]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 May 2021 20:33:43 -0700 From: dapengx.yu@intel.com To: Qiming Yang , Qi Zhang Cc: dev@dpdk.org, zhirun.yan@intel.com, junfeng.guo@intel.com, Dapeng Yu , stable@dpdk.org Date: Wed, 26 May 2021 11:33:35 +0800 Message-Id: <20210526033335.317927-1-dapengx.yu@intel.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] net/ice: fix VXLAN flow rule creation error X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" From: Dapeng Yu In original implementation, error returned when creating VXLAN flow rule with SCTP or TCP as layer 4 protocol of inner segment. There are several root causes for the error: 1. ice_fdir_input_set_hdrs() set ICE_FLOW_SEG_HDR_UDP into protocol header flag of inner segment of VXLAN FDIR rule, even if it shall be ICE_FLOW_SEG_HDR_TCP or ICE_FLOW_SEG_HDR_SCTP 2. ice_fdir_udp4_vxlan_pkt[] is not adapted to the TCP and SCTP protocol. Its length cannot hold TCP header, only UDP protocol was supported in original implementation 3. flow type: ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN hides the flow type of inner segment of VXLAN FDIR rule, then further causes function: ice_fdir_get_gen_prgm_pkt() cannot write correct protocol id into inner segment of training packet. This patch fixes those defects described above. Fixes: 855d23a07b36 ("net/ice: support VXLAN VNI field in flow director") Cc: stable@dpdk.org Signed-off-by: Dapeng Yu --- drivers/net/ice/base/ice_fdir.c | 33 ++++++++++++++++++-- drivers/net/ice/base/ice_type.h | 4 +++ drivers/net/ice/ice_fdir_filter.c | 50 +++++++++++++++++++++++++++---- 3 files changed, 79 insertions(+), 8 deletions(-) diff --git a/drivers/net/ice/base/ice_fdir.c b/drivers/net/ice/base/ice_fdir.c index 180508243d..c8e3e60372 100644 --- a/drivers/net/ice/base/ice_fdir.c +++ b/drivers/net/ice/base/ice_fdir.c @@ -51,10 +51,11 @@ static const u8 ice_fdir_udp4_vxlan_pkt[] = { 0x00, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, - 0x45, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x40, 0x00, - 0x40, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x45, 0x00, 0x00, 0x28, 0x00, 0x00, 0x40, 0x00, + 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x50, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, }; static const u8 ice_fdir_ipv4_gtpu4_pkt[] = { @@ -1023,6 +1024,26 @@ static const struct ice_fdir_base_pkt ice_fdir_pkt[] = { sizeof(ice_fdir_udp4_vxlan_pkt), ice_fdir_udp4_vxlan_pkt, sizeof(ice_fdir_udp4_vxlan_pkt), ice_fdir_udp4_vxlan_pkt, }, + { + ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN_IPV4_UDP, + sizeof(ice_fdir_udp4_vxlan_pkt), ice_fdir_udp4_vxlan_pkt, + sizeof(ice_fdir_udp4_vxlan_pkt), ice_fdir_udp4_vxlan_pkt, + }, + { + ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN_IPV4_TCP, + sizeof(ice_fdir_udp4_vxlan_pkt), ice_fdir_udp4_vxlan_pkt, + sizeof(ice_fdir_udp4_vxlan_pkt), ice_fdir_udp4_vxlan_pkt, + }, + { + ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN_IPV4_SCTP, + sizeof(ice_fdir_udp4_vxlan_pkt), ice_fdir_udp4_vxlan_pkt, + sizeof(ice_fdir_udp4_vxlan_pkt), ice_fdir_udp4_vxlan_pkt, + }, + { + ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN_IPV4_OTHER, + sizeof(ice_fdir_udp4_vxlan_pkt), ice_fdir_udp4_vxlan_pkt, + sizeof(ice_fdir_udp4_vxlan_pkt), ice_fdir_udp4_vxlan_pkt, + }, { ICE_FLTR_PTYPE_NONF_ECPRI_TP0, sizeof(ice_fdir_ecpri_tp0_pkt), ice_fdir_ecpri_tp0_pkt, @@ -1583,6 +1604,10 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input, ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac); break; case ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN: + case ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN_IPV4_UDP: + case ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN_IPV4_TCP: + case ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN_IPV4_SCTP: + case ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN_IPV4_OTHER: ice_pkt_insert_mac_addr(pkt, input->ext_data_outer.dst_mac); ice_pkt_insert_mac_addr(pkt + ETH_ALEN, input->ext_data_outer.src_mac); ice_pkt_insert_u32(pkt, ICE_IPV4_SRC_ADDR_OFFSET, @@ -1602,6 +1627,8 @@ ice_fdir_get_gen_prgm_pkt(struct ice_hw *hw, struct ice_fdir_fltr *input, input->ip.v4.dst_port); ice_pkt_insert_u8(loc, ICE_IPV4_TOS_OFFSET, input->ip.v4.tos); ice_pkt_insert_u8(loc, ICE_IPV4_TTL_OFFSET, input->ip.v4.ttl); + ice_pkt_insert_u8(loc, ICE_IPV4_PROTO_OFFSET, + input->ip.v4.proto); ice_pkt_insert_mac_addr(loc, input->ext_data.dst_mac); ice_pkt_insert_mac_addr(loc + ETH_ALEN, input->ext_data.src_mac); break; diff --git a/drivers/net/ice/base/ice_type.h b/drivers/net/ice/base/ice_type.h index ce508a02e5..2644d5db73 100644 --- a/drivers/net/ice/base/ice_type.h +++ b/drivers/net/ice/base/ice_type.h @@ -353,6 +353,10 @@ enum ice_fltr_ptype { ICE_FLTR_PTYPE_NONF_IPV6_SCTP, ICE_FLTR_PTYPE_NONF_IPV6_OTHER, ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN, + ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN_IPV4_UDP, + ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN_IPV4_TCP, + ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN_IPV4_SCTP, + ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN_IPV4_OTHER, ICE_FLTR_PTYPE_MAX, }; diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir_filter.c index 092c704503..6ae545dbf9 100644 --- a/drivers/net/ice/ice_fdir_filter.c +++ b/drivers/net/ice/ice_fdir_filter.c @@ -786,6 +786,28 @@ ice_fdir_cross_prof_conflict(struct ice_pf *pf, (pf, cflct_ptype, is_tunnel)) goto err; break; + case ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN_IPV4_UDP: + case ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN_IPV4_TCP: + case ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN_IPV4_SCTP: + cflct_ptype = ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN_IPV4_OTHER; + if (!ice_fdir_prof_resolve_conflict + (pf, cflct_ptype, is_tunnel)) + goto err; + break; + case ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN_IPV4_OTHER: + cflct_ptype = ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN_IPV4_UDP; + if (!ice_fdir_prof_resolve_conflict + (pf, cflct_ptype, is_tunnel)) + goto err; + cflct_ptype = ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN_IPV4_TCP; + if (!ice_fdir_prof_resolve_conflict + (pf, cflct_ptype, is_tunnel)) + goto err; + cflct_ptype = ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN_IPV4_SCTP; + if (!ice_fdir_prof_resolve_conflict + (pf, cflct_ptype, is_tunnel)) + goto err; + break; default: break; } @@ -968,9 +990,11 @@ ice_fdir_input_set_hdrs(enum ice_fltr_ptype flow, struct ice_flow_seg_info *seg) ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV6 | ICE_FLOW_SEG_HDR_IPV_FRAG); break; - case ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN: - ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_UDP | - ICE_FLOW_SEG_HDR_IPV4 | + case ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN_IPV4_UDP: + case ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN_IPV4_TCP: + case ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN_IPV4_SCTP: + case ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN_IPV4_OTHER: + ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV4 | ICE_FLOW_SEG_HDR_VXLAN | ICE_FLOW_SEG_HDR_IPV_OTHER); break; @@ -1908,10 +1932,12 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad, assert(p_v4); p_v4->dst_port = tcp_spec->hdr.dst_port; p_v4->src_port = tcp_spec->hdr.src_port; + p_v4->proto = ICE_IP_PROTO_TCP; } else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6) { assert(p_v6); p_v6->dst_port = tcp_spec->hdr.dst_port; p_v6->src_port = tcp_spec->hdr.src_port; + p_v6->proto = ICE_IP_PROTO_TCP; } break; case RTE_FLOW_ITEM_TYPE_UDP: @@ -1946,10 +1972,12 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad, assert(p_v4); p_v4->dst_port = udp_spec->hdr.dst_port; p_v4->src_port = udp_spec->hdr.src_port; + p_v4->proto = ICE_IP_PROTO_UDP; } else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6) { assert(p_v6); p_v6->src_port = udp_spec->hdr.src_port; p_v6->dst_port = udp_spec->hdr.dst_port; + p_v6->proto = ICE_IP_PROTO_UDP; } break; case RTE_FLOW_ITEM_TYPE_SCTP: @@ -1983,10 +2011,12 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad, assert(p_v4); p_v4->dst_port = sctp_spec->hdr.dst_port; p_v4->src_port = sctp_spec->hdr.src_port; + p_v4->proto = ICE_IP_PROTO_SCTP; } else if (l3 == RTE_FLOW_ITEM_TYPE_IPV6) { assert(p_v6); p_v6->dst_port = sctp_spec->hdr.dst_port; p_v6->src_port = sctp_spec->hdr.src_port; + p_v6->proto = ICE_IP_PROTO_SCTP; } break; case RTE_FLOW_ITEM_TYPE_VOID: @@ -2073,8 +2103,18 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad, else if (tunnel_type == ICE_FDIR_TUNNEL_TYPE_GTPU_EH && flow_type == ICE_FLTR_PTYPE_NONF_IPV6_UDP) flow_type = ICE_FLTR_PTYPE_NONF_IPV6_GTPU_EH; - else if (tunnel_type == ICE_FDIR_TUNNEL_TYPE_VXLAN) - flow_type = ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN; + else if (tunnel_type == ICE_FDIR_TUNNEL_TYPE_VXLAN && + flow_type == ICE_FLTR_PTYPE_NONF_IPV4_UDP) + flow_type = ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN_IPV4_UDP; + else if (tunnel_type == ICE_FDIR_TUNNEL_TYPE_VXLAN && + flow_type == ICE_FLTR_PTYPE_NONF_IPV4_TCP) + flow_type = ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN_IPV4_TCP; + else if (tunnel_type == ICE_FDIR_TUNNEL_TYPE_VXLAN && + flow_type == ICE_FLTR_PTYPE_NONF_IPV4_SCTP) + flow_type = ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN_IPV4_SCTP; + else if (tunnel_type == ICE_FDIR_TUNNEL_TYPE_VXLAN && + flow_type == ICE_FLTR_PTYPE_NONF_IPV4_OTHER) + flow_type = ICE_FLTR_PTYPE_NONF_IPV4_UDP_VXLAN_IPV4_OTHER; filter->tunnel_type = tunnel_type; filter->input.flow_type = flow_type; -- 2.27.0