From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id CA557A04C0; Tue, 19 Nov 2019 04:18:32 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0DBF12BE2; Tue, 19 Nov 2019 04:18:32 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id BA4D42BD5 for ; Tue, 19 Nov 2019 04:18:30 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Nov 2019 19:18:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,322,1569308400"; d="scan'208";a="407608513" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga006.fm.intel.com with ESMTP; 18 Nov 2019 19:18:29 -0800 Received: from fmsmsx115.amr.corp.intel.com (10.18.116.19) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 18 Nov 2019 19:18:28 -0800 Received: from shsmsx153.ccr.corp.intel.com (10.239.6.53) by fmsmsx115.amr.corp.intel.com (10.18.116.19) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 18 Nov 2019 19:18:28 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.213]) by SHSMSX153.ccr.corp.intel.com ([169.254.12.215]) with mapi id 14.03.0439.000; Tue, 19 Nov 2019 11:18:26 +0800 From: "Xing, Beilei" To: "Zhang, Qi Z" , "Cao, Yahui" CC: "dev@dpdk.org" Thread-Topic: [PATCH v3] net/ice: fix FDIR flow type conflict Thread-Index: AQHVndnUyBoaFlP/5UiYhhHhEwYdGaeQogPA Date: Tue, 19 Nov 2019 03:18:26 +0000 Message-ID: <94479800C636CB44BD422CB454846E013CE88CCE@SHSMSX101.ccr.corp.intel.com> References: <20191118063436.37570-1-qi.z.zhang@intel.com> In-Reply-To: <20191118063436.37570-1-qi.z.zhang@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZjU4Y2NmZDAtYzlkNi00MWY5LWEyODgtNWE4YmVhMzNkMWViIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiN1FacGx5VDgycTA0UzExaEZXTXBuK0VuaWdOMlAreHhKTllnZ3BYc1NlTEdibnMwY09kT0NWMnl6Qjlka1wvcVwvIn0= x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v3] net/ice: fix FDIR flow type conflict 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" > -----Original Message----- > From: Zhang, Qi Z > Sent: Monday, November 18, 2019 2:35 PM > To: Xing, Beilei ; Cao, Yahui > Cc: dev@dpdk.org; Zhang, Qi Z > Subject: [PATCH v3] net/ice: fix FDIR flow type conflict >=20 > Flow type "IPv4 + UDP" or "IPv4 + TCP" is conflict with "IPv4 + any" > flow type. If a rule for IPv4 + any is created, we should reject any rule= for > IPv4 + UDP otherwise the first rule may be impacted, same decision should > be made on a reverse order. > For IPv6 and IPv4 GTPU inner case, we have the same limitation. >=20 > Fixes: 109e8e06249e ("net/ice: configure HW flow director rule") >=20 > Signed-off-by: Qi Zhang > --- >=20 > v3: > - replace EAGAIN with EEXIST when a profile already exist. >=20 > v2: > - fix check patch warning. >=20 > drivers/net/ice/ice_fdir_filter.c | 174 > ++++++++++++++++++++++++++++++++++---- > 1 file changed, 157 insertions(+), 17 deletions(-) >=20 > diff --git a/drivers/net/ice/ice_fdir_filter.c b/drivers/net/ice/ice_fdir= _filter.c > index 7876f4bbc..e5a35dfe8 100644 > --- a/drivers/net/ice/ice_fdir_filter.c > +++ b/drivers/net/ice/ice_fdir_filter.c > @@ -646,6 +646,153 @@ ice_fdir_teardown(struct ice_pf *pf) > } > } >=20 > +static int ice_fdir_cur_prof_conflict(struct ice_pf *pf, > + enum ice_fltr_ptype ptype, > + struct ice_flow_seg_info *seg, > + bool is_tunnel) > +{ > + struct ice_hw *hw =3D ICE_PF_TO_HW(pf); > + struct ice_flow_seg_info *ori_seg; > + struct ice_fd_hw_prof *hw_prof; > + > + hw_prof =3D hw->fdir_prof[ptype]; > + ori_seg =3D hw_prof->fdir_seg[is_tunnel]; > + > + /* profile does not exist */ > + if (!ori_seg) > + return 0; > + > + /* if no input set conflict, return -EEXIST */ > + if ((!is_tunnel && !memcmp(ori_seg, seg, sizeof(*seg))) || > + (is_tunnel && !memcmp(&ori_seg[1], &seg[1], sizeof(*seg)))) { > + PMD_DRV_LOG(DEBUG, "Profile already exist for flow type %d.", > + ptype); > + return -EEXIST; > + } > + > + /* a rule with input set conflict already exist, so give up */ > + if (pf->fdir_fltr_cnt[ptype][is_tunnel]) { > + PMD_DRV_LOG(DEBUG, "Failed to create profile for flow type %d > due to conflict with exist rule.", > + ptype); > + return -EINVAL; > + } > + > + /* it's safe to delete an empty profile */ > + ice_fdir_prof_rm(pf, ptype, is_tunnel); > + return 0; > +} > + > +static bool ice_fdir_prof_resolve_conflict(struct ice_pf *pf, > + enum ice_fltr_ptype ptype, > + bool is_tunnel) > +{ > + struct ice_hw *hw =3D ICE_PF_TO_HW(pf); > + struct ice_fd_hw_prof *hw_prof; > + struct ice_flow_seg_info *seg; > + > + hw_prof =3D hw->fdir_prof[ptype]; > + seg =3D hw_prof->fdir_seg[is_tunnel]; > + > + /* profile does not exist */ > + if (!seg) > + return true; > + > + /* profile exist and rule exist, fail to resolve the conflict */ > + if (pf->fdir_fltr_cnt[ptype][is_tunnel] !=3D 0) > + return false; > + > + /* it's safe to delete an empty profile */ > + ice_fdir_prof_rm(pf, ptype, is_tunnel); > + > + return true; > +} > + > +static int ice_fdir_cross_prof_conflict(struct ice_pf *pf, > + enum ice_fltr_ptype ptype, > + bool is_tunnel) > +{ > + enum ice_fltr_ptype cflct_ptype; > + > + switch (ptype) { > + /* IPv4 */ > + case ICE_FLTR_PTYPE_NONF_IPV4_UDP: > + case ICE_FLTR_PTYPE_NONF_IPV4_TCP: > + case ICE_FLTR_PTYPE_NONF_IPV4_SCTP: > + cflct_ptype =3D ICE_FLTR_PTYPE_NONF_IPV4_OTHER; > + if (!ice_fdir_prof_resolve_conflict > + (pf, cflct_ptype, is_tunnel)) > + goto err; > + break; > + case ICE_FLTR_PTYPE_NONF_IPV4_OTHER: > + cflct_ptype =3D ICE_FLTR_PTYPE_NONF_IPV4_UDP; > + if (!ice_fdir_prof_resolve_conflict > + (pf, cflct_ptype, is_tunnel)) > + goto err; > + cflct_ptype =3D ICE_FLTR_PTYPE_NONF_IPV4_TCP; > + if (!ice_fdir_prof_resolve_conflict > + (pf, cflct_ptype, is_tunnel)) > + goto err; > + cflct_ptype =3D ICE_FLTR_PTYPE_NONF_IPV4_SCTP; > + if (!ice_fdir_prof_resolve_conflict > + (pf, cflct_ptype, is_tunnel)) > + goto err; > + break; > + /* IPv4 GTPU */ > + case ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_UDP: > + case ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_TCP: > + case ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_ICMP: > + cflct_ptype =3D ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_OTHER; > + if (!ice_fdir_prof_resolve_conflict > + (pf, cflct_ptype, is_tunnel)) > + goto err; > + break; > + case ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_OTHER: > + cflct_ptype =3D ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_OTHER; > + if (!ice_fdir_prof_resolve_conflict > + (pf, cflct_ptype, is_tunnel)) > + goto err; > + cflct_ptype =3D ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_OTHER; > + if (!ice_fdir_prof_resolve_conflict > + (pf, cflct_ptype, is_tunnel)) > + goto err; > + cflct_ptype =3D ICE_FLTR_PTYPE_NONF_IPV4_GTPU_IPV4_OTHER; > + if (!ice_fdir_prof_resolve_conflict > + (pf, cflct_ptype, is_tunnel)) > + goto err; > + break; > + /* IPv6 */ > + case ICE_FLTR_PTYPE_NONF_IPV6_UDP: > + case ICE_FLTR_PTYPE_NONF_IPV6_TCP: > + case ICE_FLTR_PTYPE_NONF_IPV6_SCTP: > + cflct_ptype =3D ICE_FLTR_PTYPE_NONF_IPV6_OTHER; > + if (!ice_fdir_prof_resolve_conflict > + (pf, cflct_ptype, is_tunnel)) > + goto err; > + break; > + case ICE_FLTR_PTYPE_NONF_IPV6_OTHER: > + cflct_ptype =3D ICE_FLTR_PTYPE_NONF_IPV6_UDP; > + if (!ice_fdir_prof_resolve_conflict > + (pf, cflct_ptype, is_tunnel)) > + goto err; > + cflct_ptype =3D ICE_FLTR_PTYPE_NONF_IPV6_TCP; > + if (!ice_fdir_prof_resolve_conflict > + (pf, cflct_ptype, is_tunnel)) > + goto err; > + cflct_ptype =3D ICE_FLTR_PTYPE_NONF_IPV6_SCTP; > + if (!ice_fdir_prof_resolve_conflict > + (pf, cflct_ptype, is_tunnel)) > + goto err; > + break; > + default: > + break; > + } > + return 0; > +err: > + PMD_DRV_LOG(DEBUG, "Failed to create profile for flow type %d due > to conflict with exist rule of flow type %d.", > + ptype, cflct_ptype); > + return -EINVAL; > +} > + > static int > ice_fdir_hw_tbl_conf(struct ice_pf *pf, struct ice_vsi *vsi, > struct ice_vsi *ctrl_vsi, > @@ -655,7 +802,6 @@ ice_fdir_hw_tbl_conf(struct ice_pf *pf, struct ice_vs= i > *vsi, { > struct ice_hw *hw =3D ICE_PF_TO_HW(pf); > enum ice_flow_dir dir =3D ICE_FLOW_RX; > - struct ice_flow_seg_info *ori_seg; > struct ice_fd_hw_prof *hw_prof; > struct ice_flow_prof *prof; > uint64_t entry_1 =3D 0; > @@ -664,22 +810,15 @@ ice_fdir_hw_tbl_conf(struct ice_pf *pf, struct > ice_vsi *vsi, > int ret; > uint64_t prof_id; >=20 > - hw_prof =3D hw->fdir_prof[ptype]; > - ori_seg =3D hw_prof->fdir_seg[is_tunnel]; > - if (ori_seg) { > - if (!is_tunnel) { > - if (!memcmp(ori_seg, seg, sizeof(*seg))) > - return -EAGAIN; > - } else { > - if (!memcmp(&ori_seg[1], &seg[1], sizeof(*seg))) > - return -EAGAIN; > - } > - > - if (pf->fdir_fltr_cnt[ptype][is_tunnel]) > - return -EINVAL; > + /* check if have input set conflict on current profile. */ > + ret =3D ice_fdir_cur_prof_conflict(pf, ptype, seg, is_tunnel); > + if (ret) > + return ret; >=20 > - ice_fdir_prof_rm(pf, ptype, is_tunnel); > - } > + /* check if the profile is conflict with other profile. */ > + ret =3D ice_fdir_cross_prof_conflict(pf, ptype, is_tunnel); > + if (ret) > + return ret; >=20 > prof_id =3D ptype + is_tunnel * ICE_FLTR_PTYPE_MAX; > ret =3D ice_flow_add_prof(hw, ICE_BLK_FD, dir, prof_id, seg, @@ -703,6 > +842,7 @@ ice_fdir_hw_tbl_conf(struct ice_pf *pf, struct ice_vsi *vsi, > goto err_add_entry; > } >=20 > + hw_prof =3D hw->fdir_prof[ptype]; > pf->hw_prof_cnt[ptype][is_tunnel] =3D 0; > hw_prof->cnt =3D 0; > hw_prof->fdir_seg[is_tunnel] =3D seg; > @@ -866,7 +1006,7 @@ ice_fdir_input_set_conf(struct ice_pf *pf, enum > ice_fltr_ptype flow, > rte_free(seg); > if (is_tunnel) > rte_free(seg_tun); > - return (ret =3D=3D -EAGAIN) ? 0 : ret; > + return (ret =3D=3D -EEXIST) ? 0 : ret; > } else { > return ret; > } > -- > 2.13.6 Tested-by: Beilei Xing Acked-by: Beilei Xing