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 EB562A0093 for ; Wed, 20 May 2020 04:13:45 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AD8DA1D17B; Wed, 20 May 2020 04:13:45 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id F2F1C1D17B; Wed, 20 May 2020 04:13:42 +0200 (CEST) IronPort-SDR: EGy+6axV/6Pwd7/d6qWhwWcU3xa6sqFJzp5yAUUml3wkIFe22Dle5vwaWaKd361RPK8UPLd+4Z VewBlGyoqzkA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 May 2020 19:13:39 -0700 IronPort-SDR: EZaJBzIBuCyQq6YoCGGr5H7jok8jLEMJ+Hf3ZjQZ8o8CEP3PXLCNFDj9jeJChfrw8s5OMWLZRg OQQuEa6bJzqQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,412,1583222400"; d="scan'208";a="466353662" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga006.fm.intel.com with ESMTP; 19 May 2020 19:13:39 -0700 Received: from fmsmsx606.amr.corp.intel.com (10.18.126.86) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 19 May 2020 19:13:39 -0700 Received: from fmsmsx606.amr.corp.intel.com (10.18.126.86) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 19 May 2020 19:13:38 -0700 Received: from FMSEDG002.ED.cps.intel.com (10.1.192.134) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Tue, 19 May 2020 19:13:38 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.176) by edgegateway.intel.com (192.55.55.69) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 19 May 2020 19:13:38 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Bg9b6vROXwbIqazmavz9vHR5NyeD0wmFjGCXrYtYEZH5eklAMdbJsNd4+t6qXmsqpBXO3mEIqUYIcyt+QvG55eZIE3risHu7xqVwGnvhAaqV/PfzLtFU0OirqK7kHSCy8ZYCufXeVrKjXKbq1xXm+K9NBuLYHGuT1c2MlBsX57a0f6t5qY+jaEhSw4Uik1U5z/d5pBZ8QE84+WtMVt1r1o4mPJWDc8taRIqrfB6dzNika3pxzrVhZJiqRAtKo4CRogd/TqM2N+HDhaWorfFRYHxnaVbTxPGAXGezlnwNXAA8VPfT+vbCL2XP9nUyPVDwpb4dcnVUqoSPJjO2lE1DCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tEY8LnKfMUZzIi1T7ycOps4QGrSkHFeVtVu93ijqsDY=; b=nDjEtrVs4wLqUiaoY3WOsYlr6ykPx0Qp3sLSmLFWd1F8169kDK6tdnMX6pNLLGyUjrs2u4ce2+ghESWXaXq+uTvCpOK3kBAk3CeUPEznyh8voGJoCCty4RTosie5UuXNO9K8JFKsf6YzT9A/ANzRoJBJhnjNKRsDn0TuO+FNtHH215hhqJpnwS64KE+smayYSP3u3T2HeGsPaqYI3gxDMbammznx7lz1MxagneEUb4O55iRssIsls8S7dXajAFuoUWysywdaDpdTv0oek31MApetn3PIRQM4MTP9pZF6P89G/ScD6PCRODZ2EWOGa0WgJIFbMck7WMUe2zOTitx6iQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tEY8LnKfMUZzIi1T7ycOps4QGrSkHFeVtVu93ijqsDY=; b=V4zgK6y+QbFbLhnTLp3IyJRKijnS/VvWhjz6mQUc+9OYPsC9G3ojh2iTqvaINfnzIAc+WpJfVi0iqbzT2rCSk58pcm9EazoOIpfVEvjN5aRZJezSVS5uWd0Zp3ZQWkzEU2UNJC5MRL++n2zMGMVRxjhP7DW6nHG9M+KcXiBiSC8= Received: from MN2PR11MB3582.namprd11.prod.outlook.com (2603:10b6:208:ec::28) by MN2PR11MB4415.namprd11.prod.outlook.com (2603:10b6:208:192::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.26; Wed, 20 May 2020 02:13:34 +0000 Received: from MN2PR11MB3582.namprd11.prod.outlook.com ([fe80::e1c5:b5cf:5a94:379f]) by MN2PR11MB3582.namprd11.prod.outlook.com ([fe80::e1c5:b5cf:5a94:379f%3]) with mapi id 15.20.3000.034; Wed, 20 May 2020 02:13:33 +0000 From: "Yang, Qiming" To: "Zhang, Qi Z" CC: "dev@dpdk.org" , "Ye, Xiaolong" , "stable@dpdk.org" , "Nowlin, Dan" Thread-Topic: [PATCH] net/ice: fix tunnel type match word handling Thread-Index: AQHWLMumZ3L63GaGFk+/Kh92ZtbAvKiwPpbw Date: Wed, 20 May 2020 02:13:33 +0000 Message-ID: References: <20200518042351.39075-1-qi.z.zhang@intel.com> In-Reply-To: <20200518042351.39075-1-qi.z.zhang@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.102.204.36] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: af467bd1-8d9c-4b49-cf66-08d7fc6365fa x-ms-traffictypediagnostic: MN2PR11MB4415: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6108; x-forefront-prvs: 04097B7F7F x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: zjYJRMWRBMLxY5sSlq18G38uu16PvGXDI3KlgIBIO3aJLlMZkD6MhTHbO45PYpvGafdOBDPqCSZOycTs6ptg5xKmhYLGd1W85U22hpaPA7TaxKbVznbtdFsWnxmwOV2aWbR79JUd5B7cZ9bUCrLsWeRrx7ibXU6Afk6fuRRhEznlwQjn9hOuHnJQNfOkvNs6RC5iqRPCyIkkfgyE2nWv8O1Hpnae9tAV1LYqfoACj8urWwFGFAzMF0qHeAOEW1iRsCNMPuJ+pviND6EWNg1uBeGaA94OFdDVuYHDUoZHa0qt/3T36FSDDaVNXrGSB/FYLe1Z81NuVA8SXYOudGG0g5EPrb2Zn01WeblpcpKwnUb6yvStAhQDInfo7zAAvtLKZTTUo5ZR4WbbfvDNLA/MEl+w0I9g/AU5eC4MRkrKmZknJQYN/AeXSOIxt5LGYmta x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR11MB3582.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(346002)(366004)(376002)(136003)(396003)(39860400002)(4326008)(66476007)(52536014)(53546011)(2906002)(55016002)(9686003)(86362001)(71200400001)(26005)(450100002)(33656002)(107886003)(6636002)(8936002)(5660300002)(76116006)(66446008)(7696005)(54906003)(64756008)(66556008)(478600001)(66946007)(6506007)(8676002)(186003)(6862004)(316002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: BJQWfmwYH2ptlNFQGlyAP59xnXk67AxcVZXFGzuY5wyYIYdR3o3bqT6fD124MKw0+b2Z721aQP6QT0tq01m37rCoJgPTSoCngwBef/4lPjwPIXL8vkXViXOLj/JBGPE5eOvV+Bj/+N0/ug2zZPMeS9Dv9IMRhHHVToloCpTdTySZRCn2WoaqmhCcD8X9M+zTOF2OuiUe98UenAKnjP9jMof7VbedJl3/vSNMsm3eWF1Oa9JLBQz1FOUDEfkQFexhKxKro939hLbksx6Exq1QSd/SKbyckim8vX5XoACnIArp9iTsO1MqaJdGAquiLIPfcMoRFF68DAOBv2vrrQnSUjVjyTNgHWWhrDIIutBlYYETr4E/LPCUfGrm0fAXnuaz/VeZaX98elQHsV2bEG5cZ1YoadhWwJFGHzoiC4LjMrqa9a+rvQlLTF5kQUp1I9TLS70uOi08fCn3YbwkDcWXlAEo4l3du4gVEvm33OOPdr+DvVuomZebp3Krb33vUP0s Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: af467bd1-8d9c-4b49-cf66-08d7fc6365fa X-MS-Exchange-CrossTenant-originalarrivaltime: 20 May 2020 02:13:33.7483 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: NJ+EuXvhuUDYI4K54xTEUdq0VhXwYWvMKCsT5r+beOt8KQa6i/szz8raCRNGh8KqG8Ljt/PoGe0mhvqdMVzReQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4415 X-OriginatorOrg: intel.com Subject: Re: [dpdk-stable] [PATCH] net/ice: fix tunnel type match word handling X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Acked-by: Qiming Yang > -----Original Message----- > From: Zhang, Qi Z > Sent: Monday, May 18, 2020 12:24 > To: Yang, Qiming > Cc: dev@dpdk.org; Ye, Xiaolong ; Zhang, Qi Z > ; stable@dpdk.org; Nowlin, Dan > > Subject: [PATCH] net/ice: fix tunnel type match word handling >=20 > Use a common function when selecting the proper word and mask match for > a tunnel type when programming switch rules. >=20 > Store switch recipe field mask as little endian, which avoids needing to > convert back to big endian after reading recipe from FW. Grammar feel a little weird. >=20 > Obtain word mask from FW recipe. >=20 > Fix word matching element and index pairing. >=20 > Fixes: fed0c5ca5f19 ("net/ice/base: support programming a new switch > recipe") > Cc: stable@dpdk.org >=20 > Signed-off-by: Dan Nowlin > Signed-off-by: Qi Zhang > --- > drivers/net/ice/base/ice_osdep.h | 1 + > drivers/net/ice/base/ice_protocol_type.h | 1 + > drivers/net/ice/base/ice_switch.c | 89 ++++++++++++++++++++------= --- > --- > 3 files changed, 59 insertions(+), 32 deletions(-) >=20 > diff --git a/drivers/net/ice/base/ice_osdep.h > b/drivers/net/ice/base/ice_osdep.h > index c70f5f8a7..881bf5ddc 100644 > --- a/drivers/net/ice/base/ice_osdep.h > +++ b/drivers/net/ice/base/ice_osdep.h > @@ -78,6 +78,7 @@ typedef uint64_t s64; > #define CPU_TO_BE16(o) rte_cpu_to_be_16(o) #define CPU_TO_BE32(o) > rte_cpu_to_be_32(o) #define CPU_TO_BE64(o) rte_cpu_to_be_64(o) > +#define BE16_TO_CPU(o) rte_be_to_cpu_16(o) >=20 > #define NTOHS(a) rte_be_to_cpu_16(a) > #define NTOHL(a) rte_be_to_cpu_32(a) > diff --git a/drivers/net/ice/base/ice_protocol_type.h > b/drivers/net/ice/base/ice_protocol_type.h > index 46cd77e68..30233b9c4 100644 > --- a/drivers/net/ice/base/ice_protocol_type.h > +++ b/drivers/net/ice/base/ice_protocol_type.h > @@ -163,6 +163,7 @@ enum ice_prot_id { >=20 > #define ICE_MDID_SIZE 2 > #define ICE_TUN_FLAG_MDID 21 > +#define ICE_TUN_FLAG_MDID_OFF (ICE_MDID_SIZE * > ICE_TUN_FLAG_MDID) > #define ICE_TUN_FLAG_MASK 0xFF > #define ICE_TUN_FLAG_FV_IND 2 >=20 > diff --git a/drivers/net/ice/base/ice_switch.c > b/drivers/net/ice/base/ice_switch.c > index 17fbd26da..5f0986fcf 100644 > --- a/drivers/net/ice/base/ice_switch.c > +++ b/drivers/net/ice/base/ice_switch.c > @@ -945,6 +945,8 @@ ice_get_recp_frm_fw(struct ice_hw *hw, struct > ice_sw_recipe *recps, u8 rid, > rg_entry->fv_idx[i], &prot, &off); > lkup_exts->fv_words[fv_word_idx].prot_id =3D prot; > lkup_exts->fv_words[fv_word_idx].off =3D off; > + lkup_exts->field_mask[fv_word_idx] =3D > + rg_entry->fv_mask[i]; > fv_word_idx++; > } > /* populate rg_list with the data from the child entry of this > @@ -5253,20 +5255,23 @@ static u16 ice_find_recp(struct ice_hw *hw, > struct ice_prot_lkup_ext *lkup_exts, >=20 > /* if number of words we are looking for match */ > if (lkup_exts->n_val_words =3D=3D > recp[i].lkup_exts.n_val_words) { > - struct ice_fv_word *a =3D lkup_exts->fv_words; > - struct ice_fv_word *b =3D recp[i].lkup_exts.fv_words; > - u16 *c =3D recp[i].lkup_exts.field_mask; > - u16 *d =3D lkup_exts->field_mask; > + struct ice_fv_word *ar =3D recp[i].lkup_exts.fv_words; > + struct ice_fv_word *be =3D lkup_exts->fv_words; > + u16 *cr =3D recp[i].lkup_exts.field_mask; > + u16 *de =3D lkup_exts->field_mask; > bool found =3D true; > - u8 p, q; > - > - for (p =3D 0; p < lkup_exts->n_val_words; p++) { > - for (q =3D 0; q < recp[i].lkup_exts.n_val_words; > - q++) { > - if (a[p].off =3D=3D b[q].off && > - a[p].prot_id =3D=3D b[q].prot_id && > - d[p] =3D=3D c[q]) > - /* Found the "p"th word in > the > + u8 pe, qr; > + > + /* ar, cr, and qr are related to the recipe words, while > + * be, de and pe are related to the lookup words > + */ > + for (pe =3D 0; pe < lkup_exts->n_val_words; pe++) { > + for (qr =3D 0; qr < > recp[i].lkup_exts.n_val_words; > + qr++) { > + if (ar[qr].off =3D=3D be[pe].off && > + ar[qr].prot_id =3D=3D be[pe].prot_id > && > + cr[qr] =3D=3D de[pe]) > + /* Found the "pe"th word in > the > * given recipe > */ > break; > @@ -5277,7 +5282,7 @@ static u16 ice_find_recp(struct ice_hw *hw, struct > ice_prot_lkup_ext *lkup_exts, > * So break out from this loop and try the > next > * recipe > */ > - if (q >=3D recp[i].lkup_exts.n_val_words) { > + if (qr >=3D recp[i].lkup_exts.n_val_words) { > found =3D false; > break; > } > @@ -5285,7 +5290,8 @@ static u16 ice_find_recp(struct ice_hw *hw, struct > ice_prot_lkup_ext *lkup_exts, > /* If for "i"th recipe the found was never set to false > * then it means we found our match > */ > - if (tun_type =3D=3D recp[i].tun_type && found) > + if ((tun_type =3D=3D recp[i].tun_type || > + tun_type =3D=3D ICE_SW_TUN_AND_NON_TUN) && > found) > return i; /* Return the recipe ID */ > } > } > @@ -5339,7 +5345,8 @@ ice_fill_valid_words(struct ice_adv_lkup_elem > *rule, > ice_prot_ext[rule->type].offs[j]; > lkup_exts->fv_words[word].prot_id =3D > ice_prot_id_tbl[rule->type].protocol_id; > - lkup_exts->field_mask[word] =3D ((u16 *)&rule- > >m_u)[j]; > + lkup_exts->field_mask[word] =3D > + BE16_TO_CPU(((__be16 *)&rule->m_u)[j]); > word++; > } >=20 > @@ -5455,11 +5462,7 @@ ice_fill_fv_word_index(struct ice_hw *hw, struct > LIST_HEAD_TYPE *fv_list, >=20 > /* Store index of field vector */ > rg->fv_idx[i] =3D j; > - /* Mask is given by caller as big > - * endian, but sent to FW as little > - * endian > - */ > - rg->fv_mask[i] =3D mask << 8 | mask >> > 8; > + rg->fv_mask[i] =3D mask; > break; > } >=20 > @@ -5941,6 +5944,27 @@ ice_get_fv(struct ice_hw *hw, struct > ice_adv_lkup_elem *lkups, u16 lkups_cnt, } >=20 > /** > + * ice_tun_type_match_mask - determine if tun type needs a match mask > + * @tun_type: tunnel type > + * @mask: mask to be used for the tunnel */ static bool > +ice_tun_type_match_word(enum ice_sw_tunnel_type tun_type, u16 > *mask) { > + switch (tun_type) { > + case ICE_SW_TUN_VXLAN_GPE: > + case ICE_SW_TUN_NVGRE: > + case ICE_SW_TUN_UDP: > + case ICE_ALL_TUNNELS: > + *mask =3D ICE_TUN_FLAG_MASK; > + return true; > + > + default: > + *mask =3D 0; > + return false; > + } > +} > + > +/** > * ice_add_special_words - Add words that are not protocols, such as > metadata > * @rinfo: other information regarding the rule e.g. priority and action= info > * @lkup_exts: lookup word structure > @@ -5949,17 +5973,18 @@ static enum ice_status > ice_add_special_words(struct ice_adv_rule_info *rinfo, > struct ice_prot_lkup_ext *lkup_exts) { > + u16 mask; > + > /* If this is a tunneled packet, then add recipe index to match the > * tunnel bit in the packet metadata flags. > */ > - if (rinfo->tun_type !=3D ICE_NON_TUN) { > + if (ice_tun_type_match_word(rinfo->tun_type, &mask)) { > if (lkup_exts->n_val_words < ICE_MAX_CHAIN_WORDS) { > u8 word =3D lkup_exts->n_val_words++; >=20 > lkup_exts->fv_words[word].prot_id =3D > ICE_META_DATA_ID_HW; > - lkup_exts->fv_words[word].off =3D > ICE_TUN_FLAG_MDID * > - ICE_MDID_SIZE; > - lkup_exts->field_mask[word] =3D > ICE_TUN_FLAG_MASK; > + lkup_exts->fv_words[word].off =3D > ICE_TUN_FLAG_MDID_OFF; > + lkup_exts->field_mask[word] =3D mask; > } else { > return ICE_ERR_MAX_LIMIT; > } > @@ -6099,6 +6124,7 @@ ice_add_adv_recipe(struct ice_hw *hw, struct > ice_adv_lkup_elem *lkups, > enum ice_status status =3D ICE_SUCCESS; > struct ice_sw_recipe *rm; > bool match_tun =3D false; > + u16 mask; > u8 i; >=20 > if (!ice_is_prof_rule(rinfo->tun_type) && !lkups_cnt) @@ -6156,14 > +6182,13 @@ ice_add_adv_recipe(struct ice_hw *hw, struct > ice_adv_lkup_elem *lkups, > if (status) > goto err_unroll; >=20 > - /* There is only profile for UDP tunnels. So, it is necessary to use a > - * metadata ID flag to differentiate different tunnel types. A separate > - * recipe needs to be used for the metadata. > + /* For certain tunnel types it is necessary to use a metadata ID flag t= o > + * differentiate different tunnel types. A separate recipe needs to be > + * used for the metadata. > */ > - if ((rinfo->tun_type =3D=3D ICE_SW_TUN_VXLAN_GPE || > - rinfo->tun_type =3D=3D ICE_SW_TUN_GENEVE || > - rinfo->tun_type =3D=3D ICE_SW_TUN_VXLAN) && rm->n_grp_count > > 1) > - match_tun =3D true; > + if (ice_tun_type_match_word(rinfo->tun_type, &mask) && > + rm->n_grp_count > 1) > + match_tun =3D mask; >=20 > /* set the recipe priority if specified */ > rm->priority =3D (u8)rinfo->priority; > -- > 2.13.6