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 5C2E0A058A; Tue, 24 Mar 2020 20:57:46 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 89F482BCE; Tue, 24 Mar 2020 20:57:45 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id EC63B2BAE for ; Tue, 24 Mar 2020 20:57:43 +0100 (CET) IronPort-SDR: 2wYmkyQ88+HhVdSmgcBjrt/FbO2csJp9qIFir1kvZByhLeN/u0kdk9SOJKcSL2G48+EAZWUb8v BCZfvcxjbuOQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2020 12:57:42 -0700 IronPort-SDR: iotM53eVgTjF65g6gOdDPGPA5Smnxa4n8AJ7xlGBCyfGoll8lzaq9ekAksoUvXVTonYxLsctDf QCYjKyYvzeoA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,301,1580803200"; d="scan'208";a="446366433" Received: from orsmsx104.amr.corp.intel.com ([10.22.225.131]) by fmsmga005.fm.intel.com with ESMTP; 24 Mar 2020 12:57:42 -0700 Received: from orsmsx602.amr.corp.intel.com (10.22.229.15) by ORSMSX104.amr.corp.intel.com (10.22.225.131) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 24 Mar 2020 12:57:41 -0700 Received: from orsmsx602.amr.corp.intel.com (10.22.229.15) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 24 Mar 2020 12:57:40 -0700 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by orsmsx602.amr.corp.intel.com (10.22.229.15) 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, 24 Mar 2020 12:57:40 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.102) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 24 Mar 2020 12:57:39 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gvVXFTZOxKaqtWRzOzzpQTnGP6isbeGRwuj/ia+hc4nmtM7qD87YLWqiZLD/+CTDUsWCdMi1+ZQKexchc/3AdlkfSx8qdOWNQop0lZWG8faSLWVrGhV5KDWfnyyWnQWDVSc6Jj33KB9LQe8jFd2ViuOKmGSfO81Aqbpg0yNXc60+c213+oen52C36ONVQlK0M/pHrfKMXM5ShExF41gpo/YAK9Flc4v7YHHweXDKY/kUL0h7VNYCTeUh4GqSwf2AlgGALTpTcr0nYONazpcN9A4Bxpd7+c/utCrDoESyoXxnQh73idCzY772G40vuWEvC7I+RQK+d7ZNE2ztgchV4Q== 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=G3r6ruWrfFiuV4EqOjhgdOyxpQoxQ2SM/FNQmIy31/Y=; b=M81w+1SSPiyc+pSCcf3YKBYLMJ0GCVuqmH0+nYHqdVJjCygtDC85RHTKZ9gbc0uG3APwKj2lUazWJgxVN/OONupffPY0LkB9rn8qx8c5orfSvvO/pGLJv/LBMRjvDZfJefBfDvjalhIQZdbLOD39N8T89SAkHpIeeMWSXoMxUtvly7o02r9/HdUJZU0qMwEvUGjFLIJe3BaIgJOSVKiMvmYxJJ58K/wQ7FAN9+KNM0h2cmSaT7N5P+Awrh+7Pf9pr/a/UTtN5gsTdNfsZupwzXwAlCNzqc282Wv21x0QvMReJBtmSpeLGZ2Ab6HzaVRKjSAw7zlA+1EnOHMaouaRPQ== 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=G3r6ruWrfFiuV4EqOjhgdOyxpQoxQ2SM/FNQmIy31/Y=; b=EdmvN4ZiIouakGVqyh0fB/nE+zvUW30Ocn4Dgc4NFeoPg5G5q/8Tk/VATyCrCiCVx8eNOkmTbKtWQYA4Vq2SyjdPwpbfCU3uyBxwf1FrmVcd3p3qDcZdIu9u+DrucKNdLBNsQup/I/5tBPTyadCDDsr9IKlat2SkiZDQ8z4FJgE= Received: from SN6PR11MB2558.namprd11.prod.outlook.com (2603:10b6:805:5d::19) by SN6PR11MB2957.namprd11.prod.outlook.com (2603:10b6:805:cd::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.20; Tue, 24 Mar 2020 19:57:35 +0000 Received: from SN6PR11MB2558.namprd11.prod.outlook.com ([fe80::5df7:d515:ec1d:8db1]) by SN6PR11MB2558.namprd11.prod.outlook.com ([fe80::5df7:d515:ec1d:8db1%7]) with mapi id 15.20.2835.021; Tue, 24 Mar 2020 19:57:35 +0000 From: "Ananyev, Konstantin" To: "Medvedkin, Vladimir" , "dev@dpdk.org" CC: "akhil.goyal@nxp.com" Thread-Topic: [PATCH] ipsec: use hash lookup with hash sigs in sad lookup Thread-Index: AQHV9hInSSCjvhSSDkmQ4YwvyKyd0ahYJ5xw Date: Tue, 24 Mar 2020 19:57:35 +0000 Message-ID: References: <1583758545-375405-1-git-send-email-vladimir.medvedkin@intel.com> In-Reply-To: <1583758545-375405-1-git-send-email-vladimir.medvedkin@intel.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.2.0.6 authentication-results: spf=none (sender IP is ) smtp.mailfrom=konstantin.ananyev@intel.com; x-originating-ip: [192.198.151.178] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e62dd909-a8a3-49b9-f585-08d7d02d98f6 x-ms-traffictypediagnostic: SN6PR11MB2957: 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:873; x-forefront-prvs: 03524FBD26 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(346002)(376002)(366004)(396003)(39860400002)(33656002)(52536014)(6506007)(7696005)(110136005)(9686003)(66446008)(86362001)(8676002)(66556008)(66476007)(5660300002)(66946007)(966005)(81156014)(478600001)(4326008)(81166006)(71200400001)(8936002)(26005)(64756008)(76116006)(55016002)(186003)(2906002)(316002); DIR:OUT; SFP:1102; SCL:1; SRVR:SN6PR11MB2957; H:SN6PR11MB2558.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: /ICcfJSWL3xikQR+lI1c64pP7gLzjHz/K3Q1MhvYZjDAT8BE8j7Cee+Flr+GTI8C/CJQAUazMQIFqAVgQ3ZAZRbtRxYxq4AHgdXMLOx8/ie8KQfs1B7YxkGedqkcMvYOyDj7VqxNArqvcIYUae7yHwIMSPoQEodn8/RJKUx7ZnLgrJHsN/f0/XPrvNBQgChCuaqkV8qv5PGtvMkSJdZEJiFLVs6yQ7AU3EjVywndcI88uQboAXbwDBYpMQvQsqwoNtwBJDCFNu8U4hgUgL6Rtg3sabTWPOMFfnGYcEaczn/tqlFyOewePFFAHq16MoTSDT7MC4ipH95jUmTMtVtKss+SIj/ZL9gLiAohYyYzYQ0ygQSyIE69Y61+jnJxFzrSIM1HxtlWS7Iy7t53BwYbNQidFF/ZiMHG1OOvZGTeFJmP3iTITF6ZUvtVnIi5LgYRcD3qtqpwdWqyvCkmiA8AOeYQjIfPdY6saWIA/GLO6IgkyRxCX0DezRhKJ8rkuOrHStfqc+DE1HdnS+HJ43m+rQ== x-ms-exchange-antispam-messagedata: uTHui+S9x7up7Arjq0LA28Fl//xw5iMikrSbDq2Rl4QUCBk2gwEU4LpM/oQFMud5nA79uX3OtA7wATFk92BO/89pSxmeAqtfzCmJuuxXgwoeu2ccYQ7A1gC5BFL8eEHzlq5x36NApxiVuvfQoUPQeA== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: e62dd909-a8a3-49b9-f585-08d7d02d98f6 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Mar 2020 19:57:35.1533 (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: A4dXl80h4fNSuwWxlFXT7P/tNip9LnR/yaiVZJloI4AiCArCsjqVuhfPARsmWX8wxfRjHA12UdI7Bwo2gtjVrVMToc6INyOxnzx+lFPdPac= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR11MB2957 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH] ipsec: use hash lookup with hash sigs in sad lookup 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" Hi Vladimir, > Change hash function from jhash to crc. > Precalculate hash signatures for a bulk of keys and then > use rte_hash_lookup_with_hash_bulk_data() to speed up sad lookup Looks good in general. Few thoughts below, nothing major. =20 > Signed-off-by: Vladimir Medvedkin > --- > This patch depends on https://patches.dpdk.org/patch/66460/ >=20 > lib/librte_ipsec/ipsec_sad.c | 38 +++++++++++++++++++++++++++++--------- > 1 file changed, 29 insertions(+), 9 deletions(-) >=20 > diff --git a/lib/librte_ipsec/ipsec_sad.c b/lib/librte_ipsec/ipsec_sad.c > index 2c994ed..3292968 100644 > --- a/lib/librte_ipsec/ipsec_sad.c > +++ b/lib/librte_ipsec/ipsec_sad.c > @@ -2,10 +2,12 @@ > * Copyright(c) 2019 Intel Corporation > */ >=20 > +#include > + > #include > #include > #include > -#include > +#include > #include > #include > #include > @@ -24,7 +26,7 @@ > /* "SAD_" */ > #define SAD_FORMAT SAD_PREFIX "%s" >=20 > -#define DEFAULT_HASH_FUNC rte_jhash > +#define DEFAULT_HASH_FUNC rte_hash_crc > #define MIN_HASH_ENTRIES 8U /* From rte_cuckoo_hash.h */ >=20 > struct hash_cnt { > @@ -35,6 +37,9 @@ struct hash_cnt { > struct rte_ipsec_sad { > char name[RTE_IPSEC_SAD_NAMESIZE]; > struct rte_hash *hash[RTE_IPSEC_SAD_KEY_TYPE_MASK]; > + uint32_t spi_dip_keysize; > + uint32_t spi_dip_sip_keysize; Pure stylish thing: might be uint32_t keysize[RTE_IPSEC_SAD_KEY_TYPE_MASK]; here? > + uint32_t init_val; > /* Array to track number of more specific rules > * (spi_dip or spi_dip_sip). Used only in add/delete > * as a helper struct. > @@ -272,6 +277,7 @@ rte_ipsec_sad_create(const char *name, const struct r= te_ipsec_sad_conf *conf) >=20 > hash_params.hash_func =3D DEFAULT_HASH_FUNC; If we doing lookup_with_hash now, might be it makes sense to do add_with_hash and del_with_hash too? For code consistency. > hash_params.hash_func_init_val =3D rte_rand(); > + sad->init_val =3D hash_params.hash_func_init_val; > hash_params.socket_id =3D conf->socket_id; > hash_params.name =3D hash_name; > if (conf->flags & RTE_IPSEC_SAD_FLAG_RW_CONCURRENCY) > @@ -295,6 +301,7 @@ rte_ipsec_sad_create(const char *name, const struct r= te_ipsec_sad_conf *conf) > else > hash_params.key_len +=3D > sizeof(((struct rte_ipsec_sadv4_key *)0)->dip); > + sad->spi_dip_keysize =3D hash_params.key_len; > hash_params.entries =3D RTE_MAX(MIN_HASH_ENTRIES, > conf->max_sa[RTE_IPSEC_SAD_SPI_DIP]); > sad->hash[RTE_IPSEC_SAD_SPI_DIP] =3D rte_hash_create(&hash_params); > @@ -311,6 +318,7 @@ rte_ipsec_sad_create(const char *name, const struct r= te_ipsec_sad_conf *conf) > else > hash_params.key_len +=3D > sizeof(((struct rte_ipsec_sadv4_key *)0)->sip); > + sad->spi_dip_sip_keysize =3D hash_params.key_len; > hash_params.entries =3D RTE_MAX(MIN_HASH_ENTRIES, > conf->max_sa[RTE_IPSEC_SAD_SPI_DIP_SIP]); > sad->hash[RTE_IPSEC_SAD_SPI_DIP_SIP] =3D rte_hash_create(&hash_params); > @@ -440,15 +448,21 @@ __ipsec_sad_lookup(const struct rte_ipsec_sad *sad, > uint32_t n_3 =3D 0; > uint32_t i; > int found =3D 0; > + hash_sig_t hash_sig[RTE_HASH_LOOKUP_BULK_MAX]; > + hash_sig_t hash_sig_2[RTE_HASH_LOOKUP_BULK_MAX]; > + hash_sig_t hash_sig_3[RTE_HASH_LOOKUP_BULK_MAX]; >=20 > - for (i =3D 0; i < n; i++) > + for (i =3D 0; i < n; i++) { > sa[i] =3D NULL; > + hash_sig[i] =3D rte_hash_crc_4byte(keys[i]->v4.spi, > + sad->init_val); > + } >=20 > /* > * 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); > + rte_hash_lookup_with_hash_bulk_data(sad->hash[RTE_IPSEC_SAD_SPI_ONLY], > + (const void **)keys, hash_sig, n, &mask_1, sa); > for (map =3D mask_1; map; map &=3D (map - 1)) { > i =3D rte_bsf64(map); > /* > @@ -457,10 +471,14 @@ __ipsec_sad_lookup(const struct rte_ipsec_sad *sad, > */ > if ((uintptr_t)sa[i] & RTE_IPSEC_SAD_SPI_DIP_SIP) { > idx_3[n_3] =3D i; > + hash_sig_3[n_3] =3D rte_hash_crc(keys[i], > + sad->spi_dip_sip_keysize, sad->init_val); > keys_3[n_3++] =3D keys[i]; > } > if ((uintptr_t)sa[i] & RTE_IPSEC_SAD_SPI_DIP) { > idx_2[n_2] =3D i; > + hash_sig_2[n_2] =3D rte_hash_crc(keys[i], > + sad->spi_dip_keysize, sad->init_val); > keys_2[n_2++] =3D keys[i]; > } > /* clear 2 LSB's which indicate the presence > @@ -471,8 +489,9 @@ __ipsec_sad_lookup(const struct rte_ipsec_sad *sad, >=20 > /* 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); > + rte_hash_lookup_with_hash_bulk_data( > + sad->hash[RTE_IPSEC_SAD_SPI_DIP], > + keys_2, hash_sig_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]; > @@ -480,8 +499,9 @@ __ipsec_sad_lookup(const struct rte_ipsec_sad *sad, > } > /* 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); > + rte_hash_lookup_with_hash_bulk_data( > + sad->hash[RTE_IPSEC_SAD_SPI_DIP_SIP], > + keys_3, hash_sig_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]; > -- > 2.7.4