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 6458FA0588; Tue, 7 Apr 2020 14:58:35 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BF7A12BD8; Tue, 7 Apr 2020 14:58:34 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 04F0DFFA for ; Tue, 7 Apr 2020 14:58:32 +0200 (CEST) IronPort-SDR: 1gy7DXpzYKw2/LbhYhDAGCldZpuKzOiqRzsBqildxVAxzcDTbLAFvhAAtOHvKk1NEsitV+/HIE hqdQj/7VWt/w== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Apr 2020 05:58:32 -0700 IronPort-SDR: V6qiclejpjoznvTvCQv+t3mdVyVzIh+gBlbKesByRGK2uB9xlqfM8H/ewPARBUBTCFfuyuFd6u oAo2JGM9mTQQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,354,1580803200"; d="scan'208";a="254447449" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga006.jf.intel.com with ESMTP; 07 Apr 2020 05:58:31 -0700 Received: from fmsmsx111.amr.corp.intel.com (10.18.116.5) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 7 Apr 2020 05:58:31 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx111.amr.corp.intel.com (10.18.116.5) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 7 Apr 2020 05:58:31 -0700 Received: from NAM04-SN1-obe.outbound.protection.outlook.com (104.47.44.54) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 7 Apr 2020 05:58:31 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hqwkPgmjWE5CwaqDHNUKATU7nniT4tNnPSWSA3BphnkZPyne3/ixSUtCCjAaYGkbvgqArpWKaEOgaV1N66HkC8MtAItYpKI8C+SzSwOD1Fm1vh/Icmm1xF4uhmJjXLhzzVUOOty0Hwipy5SwmbgqrwWd1sZpLdJX2RRW3gCzBBPI+Oe7IEGvWebKHtjssDKTadrmRjdbdUVMFxhtjDIzZ8G2YHTuBL/uOXVvAAc22pVMplvbGoPbodz5r8wQ/yfwthX3O+O2THxcwiRO7eo0DvaqaiGSSoeT2sYAJm77/HljkNpZJVU9Q5rvOnGtYCaG4A1kg4OBu+PEQh/8zBQFiQ== 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=Vbs7zDyCLqyFmf7x7W7wOSg4mWny86G9MC3i0aTXM9U=; b=fJROei0s3ikRoVBmucAwP1GhA+jA3NQDJ1JRDZseVcRY78ZgMRDFQ8iCjEwljxTkcFDd+VS8t1gaOoDgTKK3SPaeCjHs2QPQXpSdZ8qvmKG8ymtab964cqpp6++YIr4V8cUD2mr9h5DTKUxjX+qmQhWV2MePmex1yzWFNBVtkRBKNb7qHbN6/x/UiJKhXO2t7BI0pkyOpn6SzRuHxCHZhbjlt57U9ZxPQ72lO17wbyc9Vt6tvUHJk1zMbe4qL5LxKd26btGQgO5zANGTw1tp5ssDMW4kbmtzMeN+OtOWn6cG9bQi9K/KsejgzhZSkXfBsYN+Hy1UXfgdbIU1OmgBsw== 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=Vbs7zDyCLqyFmf7x7W7wOSg4mWny86G9MC3i0aTXM9U=; b=xXvNX/qHukKB0JjVU+0pfkDmXqQ39qcELTLxZ+H7N5ew56cLU+ttxy56729x9lgsTSblUt6fJlwgsVlHPcNnDt9Y7JpA25x2Ys7v3yFGXkqYsi5KziRHCJzyhdGQFhMBf64nVM+OrlDC9Ue8QceRU1Xep0GAbZ4nyBPVW/fbelQ= Received: from BYAPR11MB2549.namprd11.prod.outlook.com (2603:10b6:a02:c4::33) by BYAPR11MB3048.namprd11.prod.outlook.com (2603:10b6:a03:89::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2878.21; Tue, 7 Apr 2020 12:58:29 +0000 Received: from BYAPR11MB2549.namprd11.prod.outlook.com ([fe80::141d:cf28:589e:5f49]) by BYAPR11MB2549.namprd11.prod.outlook.com ([fe80::141d:cf28:589e:5f49%4]) with mapi id 15.20.2878.018; Tue, 7 Apr 2020 12:58:29 +0000 From: "Ananyev, Konstantin" To: "Medvedkin, Vladimir" , "dev@dpdk.org" CC: "akhil.goyal@nxp.com" Thread-Topic: [PATCH v2 1/2] ipsec: use hash lookup with hash sigs in sad lookup Thread-Index: AQHWA44TP5K038erDEm7t2m/e9/ef6htrh4Q Date: Tue, 7 Apr 2020 12:58:29 +0000 Message-ID: References: <1583758545-375405-1-git-send-email-vladimir.medvedkin@intel.com> <2811605d29b62740ba467527271c7a30fe75cf78.1585240684.git.vladimir.medvedkin@intel.com> In-Reply-To: <2811605d29b62740ba467527271c7a30fe75cf78.1585240684.git.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.181] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 59af7250-488f-4d75-6717-08d7daf35e97 x-ms-traffictypediagnostic: BYAPR11MB3048: 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:826; x-forefront-prvs: 036614DD9C x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR11MB2549.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(10019020)(39860400002)(396003)(366004)(136003)(376002)(346002)(316002)(26005)(7696005)(52536014)(33656002)(478600001)(186003)(966005)(71200400001)(6506007)(76116006)(66946007)(110136005)(64756008)(66476007)(86362001)(5660300002)(66446008)(81166006)(55016002)(8676002)(8936002)(2906002)(66556008)(4326008)(81156014)(9686003); DIR:OUT; SFP:1102; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Bvg/WoLkS44xJ54MG5RD3/+QMUrToPDgzcbIXvP2xnCfelOtbx4d+5Qs5hggPT/xBzZN1E/WOxnKF+C2Cf4BAfsRr573pjneeRoU5qYNJ26L0H8CZuaAm7zttXao22Qn6rX+2XoTVu1sSVeLhSG7UKjvXwRXDj8Ng0IESlMJdO9JlzcTyLtnWJS1f2iEkTovgHae4OGoMvpIhUZ6+3i2+8fRke10xi/PzvAdtGt4QUWZJtFpQCYqMVy7EKRwurb5E/j4PgBoD2bgDV7mbxF897OY/wKHCv0Ft7bVZnHch0JH5saIArmdcI0yAeqj+wQZdPRShk+M3BgzwnwQ6CqJlNtPJpwWbkiX6xzAEVZ6QnqiELPa/coIW0op0V2Y5o3FV66yY0YSKL1u8xWiEOM9oANDckfx4rkCifoAiqC59Trr8O5dBNJorXwKf2+QUVpWaG3Z2WkVg5oPkKxA+m6MikKQJDqrsoyCsmij7zqrjyVCNnpe1DBpwMvwtRG5vi+9+TyvmeNWWMwjIkk3fjXmsQ== x-ms-exchange-antispam-messagedata: 2S7sVhDKpgylyTYRKqlQJr4wQ8rebu1j/k00wkr+4SiqBmusnhEzesclHnhpnOKcXgKxQ63w3kzTkp3rho+HqPW0qCOa4ruFqEQMrA3FM5kYtQFzoC7O+aCM9SGADAqLsLPpXoMhHPII0p0V2b1tzw== Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 59af7250-488f-4d75-6717-08d7daf35e97 X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Apr 2020 12:58:29.3604 (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: yZB3FZX+sAhbvmtpaNFtymCqRmx1gOVTfngblxZmY8mz9xewvT/oHOcS+9SjwvuM6DKziLp6cDft6uMRyRzG0aSPss6BItq8eb+3ur8FdH0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB3048 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v2 1/2] 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" > 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 I think you need to state somewhere that this patch depends on: http://patches.dpdk.org/patch/67210/ Also probably this and next patch can be squashed into one. Apart from that: Acked-by: Konstantin Ananyev =20 >=20 > Signed-off-by: Vladimir Medvedkin > --- > 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; > + 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; > 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