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 81EFB45A76; Tue, 1 Oct 2024 07:53:49 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7DC8040A87; Tue, 1 Oct 2024 07:53:12 +0200 (CEST) Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by mails.dpdk.org (Postfix) with ESMTP id 110DE40613 for ; Tue, 1 Oct 2024 07:53:09 +0200 (CEST) Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-20b8be13cb1so18281475ad.1 for ; Mon, 30 Sep 2024 22:53:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1727761988; x=1728366788; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9YIL2S0KVY+pufIsnQ43hDpUs6eMSo0I8c3X8RTsx9g=; b=WXPblPbAKUpZSTk7JhUPi8VFtW8iBq8CCRxVJPH7ycLoU9HoqnPWq5dZ+qw9FviMvL UgoTOoZrGAoN9uFcWpA5Oq33aQrM9kkbor0xCDOgWW9dx56+qnP9VR7vFBBvY0D+PsKL clmG9N1ACN77k9znpl8a+FIGHeQZPlKQoyu0c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727761988; x=1728366788; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9YIL2S0KVY+pufIsnQ43hDpUs6eMSo0I8c3X8RTsx9g=; b=nFqIrprZEXdojXW1mm8NZxbnGMksvQypHmLnh7PTq1lpBbQIh3K0MeHmpypb25gi7c EHkm3QsnvNlh8+Pp9zIkfWihKKy94CsbUg1/6Dj4agDEX/SqtxH8h1eThvZzSmTaPjws trd0w5cMk938dgSreaEMsLbb7xyb5G+XtO5YM8K2WWLSDF6liuWwk97iNM4jAALd74lI DEkyFs7bQ0Z+MwnTF/iBKPZPQtMdl3JISK2kBYvU3HGy++PUq81JOZE83y72YKHEPDAe B81XdUcfyf6G6teg7kAsphkJ2YULlQ5l/T0GSl/OqZK3oZ0wFLPVUi8EEdup1BCSh8gG rtow== X-Gm-Message-State: AOJu0Yxxeyydh7Qz+KtSHiMde25+Mmh/mUJyvbmMk/ZPI1aAzGIoKXZv bkE6ss6iPOhpOn4ni4pMVIuut7hL7eZI3vc9/VAi4Gfyu2b6jWXnDIszfB22mqQ4/wQ7O+SRPko TN/6nu6YbH22xq0yHGoN4nDM9EwTqP1iAvsrs3fbW481E1v6rRWnMhwIVGFGNQSgbQvjdwt5n7e POR1rOGYmoyb9QHoNGIuNEePQbry44FXSLxhinB4YUjQ== X-Google-Smtp-Source: AGHT+IE7/MRuG67FyRMdGQHh+qVtkbVveMhwiOxU6FzDmMVM0QzEjw5vMtvE/cnDoZ8eKC+r2cy1PA== X-Received: by 2002:a17:903:1c8:b0:20b:6308:fd2f with SMTP id d9443c01a7336-20b6309058emr135947745ad.11.1727761987794; Mon, 30 Sep 2024 22:53:07 -0700 (PDT) Received: from dhcp-10-123-154-23.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7e6db2c8af2sm7513792a12.48.2024.09.30.22.53.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 22:53:07 -0700 (PDT) From: Sriharsha Basavapatna To: dev@dpdk.org Cc: Peter Spreadborough , Sriharsha Basavapatna , Kishore Padmanabha , Ajit Khaparde Subject: [PATCH v3 39/47] net/bnxt: tf_ulp: switch ulp to use rte crc32 hash Date: Tue, 1 Oct 2024 11:28:25 +0530 Message-Id: <20241001055833.757163-40-sriharsha.basavapatna@broadcom.com> X-Mailer: git-send-email 2.39.0.189.g4dbebc36b0 In-Reply-To: <20241001055833.757163-1-sriharsha.basavapatna@broadcom.com> References: <20241001055833.757163-1-sriharsha.basavapatna@broadcom.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 From: Peter Spreadborough The RTE hash is highly optimized and will use HW acceleration when available. Signed-off-by: Peter Spreadborough Signed-off-by: Sriharsha Basavapatna Reviewed-by: Kishore Padmanabha Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c | 4 ++++ drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c | 4 ++++ drivers/net/bnxt/tf_ulp/ulp_gen_hash.c | 28 ++++++++++++++++++++++---- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c index 99a6bac0ce..c591f9327c 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c +++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_tf.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "bnxt.h" #include "bnxt_ulp.h" @@ -1457,6 +1458,9 @@ ulp_tf_init(struct bnxt *bp, int rc; uint32_t ulp_dev_id = BNXT_ULP_DEVICE_ID_LAST; + /* Select 64bit SSE4.2 intrinsic if available */ + rte_hash_crc_set_alg(CRC32_SSE42_x64); + /* Allocate and Initialize the ulp context. */ rc = ulp_tf_ctx_init(bp, session); if (rc) { diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c index 765ae9f6aa..e5bb24299e 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c +++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp_tfc.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "bnxt.h" #include "bnxt_ulp.h" @@ -924,6 +925,9 @@ ulp_tfc_init(struct bnxt *bp, uint16_t sid; int rc; + /* Select 64bit SSE4.2 intrinsic if available */ + rte_hash_crc_set_alg(CRC32_SSE42_x64); + rc = bnxt_ulp_devid_get(bp, &ulp_dev_id); if (rc) { BNXT_DRV_DBG(ERR, "Unable to get device id from ulp.\n"); diff --git a/drivers/net/bnxt/tf_ulp/ulp_gen_hash.c b/drivers/net/bnxt/tf_ulp/ulp_gen_hash.c index 17bb9c6b32..7d68bfc778 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_gen_hash.c +++ b/drivers/net/bnxt/tf_ulp/ulp_gen_hash.c @@ -5,10 +5,10 @@ #include #include +#include #include "bnxt_tf_common.h" #include "ulp_gen_hash.h" #include "ulp_utils.h" -#include "tf_hash.h" static int32_t ulp_bit_alloc_list_alloc(struct bit_alloc_list *blist, @@ -203,8 +203,29 @@ ulp_gen_hash_tbl_list_key_search(struct ulp_gen_hash_tbl *hash_tbl, } /* calculate the hash */ - hash_id = tf_hash_calc_crc32(entry->key_data, - hash_tbl->key_tbl.data_size); + switch (hash_tbl->key_tbl.data_size) { + case 1: + hash_id = rte_hash_crc_1byte(*entry->key_data, + ~0U); + break; + case 2: + hash_id = rte_hash_crc_2byte(*((uint16_t *)entry->key_data), + ~0U); + break; + case 4: + hash_id = rte_hash_crc_4byte(*((uint32_t *)entry->key_data), + ~0U); + break; + case 8: + hash_id = rte_hash_crc_8byte(*((uint64_t *)entry->key_data), + ~0U); + break; + default: + hash_id = rte_hash_crc(entry->key_data, + hash_tbl->key_tbl.data_size, + ~0U); + break; + } hash_id = (uint16_t)(((hash_id >> 16) & 0xffff) ^ (hash_id & 0xffff)); hash_id &= hash_tbl->hash_mask; hash_id = hash_id * hash_tbl->hash_bkt_num; @@ -375,4 +396,3 @@ ulp_gen_hash_tbl_list_del(struct ulp_gen_hash_tbl *hash_tbl, return 0; } - -- 2.39.3