From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 64196A0C4B; Fri, 15 Oct 2021 11:14:22 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4FE1340692; Fri, 15 Oct 2021 11:14:22 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id DC33F40041 for ; Fri, 15 Oct 2021 11:14:20 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10137"; a="291364644" X-IronPort-AV: E=Sophos;i="5.85,375,1624345200"; d="scan'208";a="291364644" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2021 02:14:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,375,1624345200"; d="scan'208";a="571706457" Received: from fmsmsx606.amr.corp.intel.com ([10.18.126.86]) by fmsmga002.fm.intel.com with ESMTP; 15 Oct 2021 02:14:19 -0700 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) 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.2242.12; Fri, 15 Oct 2021 02:14:19 -0700 Received: from fmsmsx612.amr.corp.intel.com (10.18.126.92) by fmsmsx607.amr.corp.intel.com (10.18.126.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Fri, 15 Oct 2021 02:14:19 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx612.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12 via Frontend Transport; Fri, 15 Oct 2021 02:14:19 -0700 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (104.47.74.40) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.12; Fri, 15 Oct 2021 02:14:18 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=APbsnsBzVgVsefCL3/mwILZfRLAy8/mjYzbj439ZaABrWHJO0rk8FwdC5QtDEwzOplkzm8pZww6VEeNHSjNvJA5dCxtO9fkf/DwmrfeZH7YEqvq6qO+hSwg0ds9eAInO5uuKhh5/bP9IjIdE2DT/f3LMJBntyDG6SFflu79ELGIrIeIvH3Oq3iIMy2UZVww0KCs7KwGRwnPQJSXyj45IwsrGuI73nArmecnSb8l/K+lMt//MTtJwMXoe+Qsj9YmcaxTJOfmeyrw6NzZSAR7ExAvwGpFSdmGv5dnQtIPlaW2qg4P4EvOsJvrCgwe0Cx577AyLjGOGBIvSrxF3sqRWWA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Dmk2zbmyjqQxjlDv9FAPm+4pQLcICEs4wdhFMRewZKo=; b=VOxGRJJ1bR0we7QKpgasiaiHqvT7rbnmkOf5fhqpMF1UfPqp+aTJ3XnBnAFQj0TWkjl4fysp48GuDl/u3gvMnBg04vchhruyPxcMssi3wD4pdfaC0nm9Wmm7PxTH8J9BniInufdGsaI/tsraEYZ3659EmepVCxTwt81rtwfLCdMR7miyaFXlujz//p9YiMcs9etnEHB/YR1fnJTymOQh6VOiVLrbI1N+vDtZDiVe5KEUlic+/8pwPoNhTvA5bdxerUUCatwCGnn/HmSkq4x+1JBOsRjkEAWFMPQEl4HEqG9kFbdRFoN3GZGBCj/paxirZyFhOUQlYvQf90RJryEGEA== 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=Dmk2zbmyjqQxjlDv9FAPm+4pQLcICEs4wdhFMRewZKo=; b=I4stcnprfpNxee+82W7pps3fwQz6XDzMNu8UKJf4P2JTehhbCx3Q/yzE5dy+izJPyJF34Llc6hzGrtK4kZ7XyWEy96Zug71DmLC5mhV+sDdtBhLe/dratekYEv8XPClVBova1H1SVtkNJUX54cKDQaARbWnSjtmN/qcYJCt1YZE= Authentication-Results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; Received: from PH0PR11MB5013.namprd11.prod.outlook.com (2603:10b6:510:30::21) by PH0PR11MB4981.namprd11.prod.outlook.com (2603:10b6:510:39::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.17; Fri, 15 Oct 2021 09:14:15 +0000 Received: from PH0PR11MB5013.namprd11.prod.outlook.com ([fe80::4c6a:b2b:c561:4c85]) by PH0PR11MB5013.namprd11.prod.outlook.com ([fe80::4c6a:b2b:c561:4c85%8]) with mapi id 15.20.4587.026; Fri, 15 Oct 2021 09:14:15 +0000 To: "Ananyev, Konstantin" , "dev@dpdk.org" CC: "Chilikin, Andrey" , "Wang, Yipeng1" , "Gobriel, Sameh" , "Richardson, Bruce" References: <1630944239-363648-1-git-send-email-vladimir.medvedkin@intel.com> <1630944239-363648-3-git-send-email-vladimir.medvedkin@intel.com> From: "Medvedkin, Vladimir" Message-ID: Date: Fri, 15 Oct 2021 11:13:55 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.14.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: DB6PR0501CA0046.eurprd05.prod.outlook.com (2603:10a6:4:67::32) To PH0PR11MB5013.namprd11.prod.outlook.com (2603:10b6:510:30::21) MIME-Version: 1.0 Received: from [192.198.151.51] (192.198.151.51) by DB6PR0501CA0046.eurprd05.prod.outlook.com (2603:10a6:4:67::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.14 via Frontend Transport; Fri, 15 Oct 2021 09:14:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f88929bb-94f2-4eb1-71b4-08d98fbc28ba X-MS-TrafficTypeDiagnostic: PH0PR11MB4981: 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:5797; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5YI5z3fN5aHV8wXyj6pvoLNTh1UcY1ZDOwAccqklXZAfPGPUYr6/aQwzSEY1J9kSwSBWMbLH93enaLSGyeNi7yVxQ+sHim8QN971GSOtlmShon5Ty0m3mW+lk9GlaeTubN+FIST2I2YfVWJy+f7bRruTti1QDn3x4Zk732xxK18VmfvAV4qJH5PHJWV83+XwW0CgIAvElHlOOOhpPfdjjd4PW2BOlagptUeOVp7cCTK/cDnucHqaIdQG8GayCg5m32ZK9UfpwN0X6GoeTrHIKV8xp2BFe5woKjBbTvXt7Me5MsKF34forMmKUoFIvAR7ye8gZbCSdXH4op0PN0CltT0R9uW9eaapnqtwfCcOJzPIl4pDGxyXyMb0ePZdUEPWXboTYhMiYRUUgLXLjhfg0Zytxqgqcdo/qiF5wij4HJR9RawOBEv2j6ogldxXdi01rroJqrT9HhZeuCADJssKNOYAaKQZv3In5DBRG5g8Dyh259Drl+bYNgd7w9R9a7E83LfpmpWX7gHNe60JXzFGPekBAj+J82G0k0xGOAeaJKMOKj1KD0ttrqbjSeDfEWVEuujABfqBa3UiueCDoemsGNkKZHbQtD9G70v5xv3ohVl/Aai2TjmeLgzKHpZ8+PfUSqwJK0QTRu8vfuJ9Y78NGB/fr63hqfUBj6OIgSRivkNPVPeQEXq+dN1a1o6buw95zksSOuhNbEbWHmTnMcSTaMW/Eugw6lXMN5aygZyhOKmBhEI6aemOXat0cdpYbiNJG60GvMW4kqUWY+8rO9LTfw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR11MB5013.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(6666004)(54906003)(110136005)(38100700002)(5660300002)(186003)(36756003)(83380400001)(82960400001)(2906002)(53546011)(31696002)(6486002)(16576012)(8936002)(31686004)(26005)(6706004)(66476007)(8676002)(66556008)(316002)(956004)(508600001)(107886003)(2616005)(66946007)(86362001)(4326008)(3940600001)(45980500001)(43740500002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Ky9FR3hPSXBmT2IrYTJjWkF5c0FwcHlRRWN5ckpKeTVUUkg4eHhkZ2hQdlIw?= =?utf-8?B?QjhaaXRZQW5BRElsWVBjREtCZ0Y5NkVhbDBvY2ZBanZGcXNiWHc2aW5MVWtB?= =?utf-8?B?bkU2V29tSDFpQndvTnBBdFR0dmNXaWJFRHYxWVRIRkRtaEVuWnh5ZEdUamFO?= =?utf-8?B?NnlIL3BvKzJ0VGNt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vcmxaWWoxTzBYSW1WeXlOaWNiVUJiOW0vazRXYkllcXFTZnFkY053?= =?utf-8?B?NHhpbFMwK0NGeDQ4a29teHMrTEFNdXdzRXlMbHl6Z2Y4Qk9BYUo0aHRDcTZu?= =?utf-8?B?UTE4aC92Z1NZdytIMmhXbzF5TVVqUEIyQkNXS2d5dUJNelYzMFFVb3JOT1Zh?= =?utf-8?B?M1pYODkvUm1ZWXQweXFPbytLaG5ueC9BaXhGYWZXZnpOVkxxWnBhY0IvbTZS?= =?utf-8?B?NVBIVkdOZGVrdzdDM1lVT3NGd0JCejRvQWpMTTZkeEdnKzREV3dENmpBYnFL?= =?utf-8?B?dlVUODhQemN1MDJoNWZ6SEh5Yzh0d2tVT3NUZjZ5c3dBcjdlVTB2OWs1a1la?= =?utf-8?B?ZDAwQXJwbUcvS0gzUTFkNmJ4NU5hcHJUWlU4OExRUUF4OEZYUStoRDRKcDM0?= =?utf-8?B?QUovTXdsRlEzbkpJVkF3WGZDUzJFaEpPV3pGUEQ1Q2xTQXpFbHhwamhpamRM?= =?utf-8?B?NGtjbzllUytML3V4TWdkS3hyK0dqNFVrUnc1cGFrODhlZFNUZjVPTjBaSlM2?= =?utf-8?B?WVJYQ3dSTUd5TDdMR2xEM2dxU01NWWhpREhUQWdiendSSTZjajFqa1UvcVFH?= =?utf-8?B?VXMzN3JaNlVpY2xva1A1ZGhrVldTQkJ5d25RVmFndS90OCtJRnA4bitOQzJO?= =?utf-8?Q?jU9QItdQz98A6E8moNcNCQKcPoeveBqfVC0M39z?= X-MS-Exchange-CrossTenant-Network-Message-Id: f88929bb-94f2-4eb1-71b4-08d98fbc28ba X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB5013.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2021 09:14:15.0970 (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: nQRlpi7cOqb+Uc4d9ircOgJDA5L/Yld8nQdIE/vlEb65A9vrvLrlVTbjEe68x5ZIFzHOIw+yroYyWhHXGXAI4whFnHX4ymRt8XKKnIZ9iqE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB4981 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH 2/5] hash: enable gfni thash implementation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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 Konstantin, On 08/10/2021 13:31, Ananyev, Konstantin wrote: > >> This patch enables new GFNI Toeplitz hash in >> predictable RSS library. >> >> Signed-off-by: Vladimir Medvedkin >> --- >> lib/hash/rte_thash.c | 43 +++++++++++++++++++++++++++++++++++++++---- >> lib/hash/rte_thash.h | 19 +++++++++++++++++++ >> lib/hash/version.map | 1 + >> 3 files changed, 59 insertions(+), 4 deletions(-) >> >> diff --git a/lib/hash/rte_thash.c b/lib/hash/rte_thash.c >> index 07447f7..86a0e96 100644 >> --- a/lib/hash/rte_thash.c >> +++ b/lib/hash/rte_thash.c >> @@ -86,6 +86,8 @@ struct rte_thash_ctx { >> uint32_t reta_sz_log; /** < size of the RSS ReTa in bits */ >> uint32_t subtuples_nb; /** < number of subtuples */ >> uint32_t flags; >> + uint64_t *matrices; > > Comment, what is that, etc. > I'll rephrase the comment below. >> + /**< rte_thash_complete_matrix generated matrices */ >> uint8_t hash_key[0]; >> }; >> >> @@ -253,12 +255,25 @@ rte_thash_init_ctx(const char *name, uint32_t key_len, uint32_t reta_sz, >> ctx->hash_key[i] = rte_rand(); >> } >> >> + if (rte_thash_gfni_supported) { > > I think it should be: > if (rte_thash_gfni_supported && rte_vect_get_max_simd_bitwidth() >= RTE_VECT_SIMD_512) > > Agree >> + ctx->matrices = rte_zmalloc(NULL, key_len * sizeof(uint64_t), >> + RTE_CACHE_LINE_SIZE); > > You can do it probably before allocation ctx, at the same place where te is allocated. > Might be a bit nicer. > I'd prefer to keep allocation and initialization of matrices in one place, below there is rte_thash_complete_matrix() which uses previously generated ctx->hash_key. >> + if (ctx->matrices == NULL) > > RTE_LOG(ERR, ...); > rte_ernno = ENOMEM; > Agree >> + goto free_ctx; >> + >> + rte_thash_complete_matrix(ctx->matrices, ctx->hash_key, >> + key_len); >> + } >> + >> te->data = (void *)ctx; >> TAILQ_INSERT_TAIL(thash_list, te, next); >> >> rte_mcfg_tailq_write_unlock(); >> >> return ctx; >> + >> +free_ctx: >> + rte_free(ctx); >> free_te: >> rte_free(te); >> exit: >> @@ -372,6 +387,10 @@ generate_subkey(struct rte_thash_ctx *ctx, struct thash_lfsr *lfsr, >> set_bit(ctx->hash_key, get_rev_bit_lfsr(lfsr), i); >> } >> >> + if (rte_thash_gfni_supported) > > Here and in data-path functions, I think it would be better: > if (ctx->matrices != NULL) Agree >> + rte_thash_complete_matrix(ctx->matrices, ctx->hash_key, >> + ctx->key_len); >> + >> return 0; >> } >> >> @@ -628,6 +647,16 @@ rte_thash_get_key(struct rte_thash_ctx *ctx) >> return ctx->hash_key; >> } >> >> +const uint64_t * >> +rte_thash_get_gfni_matrices(struct rte_thash_ctx *ctx) >> +{ >> + if (rte_thash_gfni_supported) >> + return ctx->matrices; > > Why not just always: > return ctx->matices; > ? > Agree >> + >> + rte_errno = ENOTSUP; >> + return NULL; >> +} >> + >> static inline uint8_t >> read_unaligned_byte(uint8_t *ptr, unsigned int len, unsigned int offset) >> { >> @@ -739,11 +768,17 @@ rte_thash_adjust_tuple(struct rte_thash_ctx *ctx, >> attempts = RTE_MIN(attempts, 1U << (h->tuple_len - ctx->reta_sz_log)); >> >> for (i = 0; i < attempts; i++) { >> - for (j = 0; j < (tuple_len / 4); j++) >> - tmp_tuple[j] = >> - rte_be_to_cpu_32(*(uint32_t *)&tuple[j * 4]); >> + if (rte_thash_gfni_supported) > if (ctx->matrices) > >> + hash = rte_thash_gfni(ctx->matrices, tuple, tuple_len); >> + else { >> + for (j = 0; j < (tuple_len / 4); j++) >> + tmp_tuple[j] = >> + rte_be_to_cpu_32( >> + *(uint32_t *)&tuple[j * 4]); >> + >> + hash = rte_softrss(tmp_tuple, tuple_len / 4, hash_key); >> + } >> >> - hash = rte_softrss(tmp_tuple, tuple_len / 4, hash_key); >> adj_bits = rte_thash_get_complement(h, hash, desired_value); >> >> /* >> diff --git a/lib/hash/rte_thash.h b/lib/hash/rte_thash.h >> index e3f1fc6..6e6861c 100644 >> --- a/lib/hash/rte_thash.h >> +++ b/lib/hash/rte_thash.h >> @@ -410,6 +410,25 @@ const uint8_t * >> rte_thash_get_key(struct rte_thash_ctx *ctx); >> >> /** >> + * Get a pointer to the toeplitz hash matrices contained in the context. >> + * These matrices could be used with fast toeplitz hash implementation if >> + * CPU supports GFNI. >> + * Matrices changes after each addition of a helper. >> + * >> + * @warning >> + * @b EXPERIMENTAL: this API may change without prior notice. >> + * >> + * @param ctx >> + * Thash context >> + * @return >> + * A pointer to the toeplitz hash key matrices on success >> + * NULL if GFNI is not supported. >> + */ >> +__rte_experimental >> +const uint64_t * >> +rte_thash_get_gfni_matrices(struct rte_thash_ctx *ctx); >> + >> +/** >> * Function prototype for the rte_thash_adjust_tuple >> * to check if adjusted tuple could be used. >> * Generally it is some kind of lookup function to check >> diff --git a/lib/hash/version.map b/lib/hash/version.map >> index cecf922..3eda695 100644 >> --- a/lib/hash/version.map >> +++ b/lib/hash/version.map >> @@ -43,6 +43,7 @@ EXPERIMENTAL { >> rte_thash_find_existing; >> rte_thash_free_ctx; >> rte_thash_get_complement; >> + rte_thash_get_gfni_matrices; >> rte_thash_get_helper; >> rte_thash_get_key; >> rte_thash_gfni_supported; >> -- >> 2.7.4 > -- Regards, Vladimir