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 84D05A2EDB for ; Wed, 2 Oct 2019 14:04:09 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5F5761BED8; Wed, 2 Oct 2019 14:04:08 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 64E321BED7 for ; Wed, 2 Oct 2019 14:04:06 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Oct 2019 05:04:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,574,1559545200"; d="scan'208";a="191783397" Received: from irsmsx153.ger.corp.intel.com ([163.33.192.75]) by fmsmga007.fm.intel.com with ESMTP; 02 Oct 2019 05:04:04 -0700 Received: from irsmsx155.ger.corp.intel.com (163.33.192.3) by IRSMSX153.ger.corp.intel.com (163.33.192.75) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 2 Oct 2019 13:04:03 +0100 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.164]) by irsmsx155.ger.corp.intel.com ([169.254.14.139]) with mapi id 14.03.0439.000; Wed, 2 Oct 2019 13:04:03 +0100 From: "Ananyev, Konstantin" To: "Medvedkin, Vladimir" , "dev@dpdk.org" CC: "Iremonger, Bernard" , "akhil.goyal@nxp.com" Thread-Topic: [PATCH v2 3/5] ipsec: add SAD add/delete/lookup implementation Thread-Index: AQHVeH1RBMxH8rSy0kO0nsQDvueWK6dHQUPA Date: Wed, 2 Oct 2019 12:04:02 +0000 Message-ID: <2601191342CEEE43887BDE71AB977258019196FD7A@irsmsx105.ger.corp.intel.com> References: <1c66db94d50313cea92e704c04a397c3bb0110e5.1569867491.git.vladimir.medvedkin@intel.com> In-Reply-To: <1c66db94d50313cea92e704c04a397c3bb0110e5.1569867491.git.vladimir.medvedkin@intel.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOWNlZmM3NWEtMDVkNC00N2Q0LWE2NDgtOWNiMzhiMDE4MTA0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiRG95dVdkOFVWa2VwMXFcL3ExNW82YllXS1JRc2ppb0FJSEpLNjJIUXVZbE9NK0twRE9pODFKZDlZN0lxZmdHTUkifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2 3/5] ipsec: add SAD add/delete/lookup implementation 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" > Replace rte_ipsec_sad_add(), rte_ipsec_sad_del() and > rte_ipsec_sad_lookup() stubs with actual implementation. >=20 > It uses three librte_hash tables each of which contains > an entries for a specific SA type (either it is addressed by SPI only > or SPI+DIP or SPI+DIP+SIP) >=20 > Signed-off-by: Vladimir Medvedkin > --- > +/* > + * @internal helper function > + * Lookup a batch of keys in three hash tables. > + * First lookup key in SPI_ONLY table. > + * If there is an entry for the corresponding SPI check its value. > + * Two least significant bits of the value indicate > + * the presence of more specific rule in other tables. > + * Perform additional lookup in corresponding hash tables > + * and update the value if lookup succeeded. > + */ > +static int > +__ipsec_sad_lookup(const struct rte_ipsec_sad *sad, > + const union rte_ipsec_sad_key *keys[], void *sa[], uint32_t n) > +{ > + const void *keys_2[RTE_HASH_LOOKUP_BULK_MAX]; > + const void *keys_3[RTE_HASH_LOOKUP_BULK_MAX]; > + void *vals_2[RTE_HASH_LOOKUP_BULK_MAX] =3D {NULL}; > + void *vals_3[RTE_HASH_LOOKUP_BULK_MAX] =3D {NULL}; > + uint32_t idx_2[RTE_HASH_LOOKUP_BULK_MAX]; > + uint32_t idx_3[RTE_HASH_LOOKUP_BULK_MAX]; > + uint64_t mask_1, mask_2, mask_3; > + uint64_t map, map_spec; > + uint32_t n_2 =3D 0; > + uint32_t n_3 =3D 0; > + uint32_t i; > + int found =3D 0; > + > + for (i =3D 0; i < n; i++) > + sa[i] =3D NULL; > + > + /* > + * Lookup keys in SPI only hash table first. > + */ > + rte_hash_lookup_bulk_data(sad->hash[RTE_IPSEC_SAD_SPI_ONLY], > + (const void **)keys, n, &mask_1, sa); > + for (map =3D mask_1; map; map &=3D (map - 1)) { > + i =3D rte_bsf64(map); > + /* > + * if returned value indicates presence of a rule in other > + * tables save a key for further lookup. > + */ > + if ((uintptr_t)sa[i] & RTE_IPSEC_SAD_SPI_DIP_SIP) { > + idx_3[n_3] =3D i; > + keys_3[n_3++] =3D keys[i]; > + } > + if ((uintptr_t)sa[i] & RTE_IPSEC_SAD_SPI_DIP) { > + idx_2[n_2] =3D i; > + keys_2[n_2++] =3D keys[i]; > + } > + /* clear 2 LSB's which idicate the presence s/idicate/indicate/ > + * of more specific rules > + */ > + sa[i] =3D CLEAR_BIT(sa[i], RTE_IPSEC_SAD_KEY_TYPE_MASK); > + } > + > + /* Lookup for more specific rules in SPI_DIP table */ > + if (n_2 !=3D 0) { > + rte_hash_lookup_bulk_data(sad->hash[RTE_IPSEC_SAD_SPI_DIP], > + keys_2, n_2, &mask_2, vals_2); > + for (map_spec =3D mask_2; map_spec; map_spec &=3D (map_spec - 1)) { > + i =3D rte_bsf64(map_spec); > + sa[idx_2[i]] =3D vals_2[i]; > + } > + } > + /* Lookup for more specific rules in SPI_DIP_SIP table */ > + if (n_3 !=3D 0) { > + rte_hash_lookup_bulk_data(sad->hash[RTE_IPSEC_SAD_SPI_DIP_SIP], > + keys_3, n_3, &mask_3, vals_3); > + for (map_spec =3D mask_3; map_spec; map_spec &=3D (map_spec - 1)) { > + i =3D rte_bsf64(map_spec); > + sa[idx_3[i]] =3D vals_3[i]; > + } > + } > + > + for (i =3D 0; i < n; i++) > + found +=3D (sa[i] !=3D NULL); > + > + return found; > +} > + > -- Acked-by: Konstantin Ananyev Tested-by: Konstantin Ananyev > 2.7.4