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 B305A458A8; Fri, 30 Aug 2024 15:55:56 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9371542EFA; Fri, 30 Aug 2024 15:55:08 +0200 (CEST) Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by mails.dpdk.org (Postfix) with ESMTP id 6CF4142ED6 for ; Fri, 30 Aug 2024 15:55:06 +0200 (CEST) Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-20219a0fe4dso16287665ad.2 for ; Fri, 30 Aug 2024 06:55:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1725026105; x=1725630905; 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=TF54oNCp0vG0MW4QPjAISJTV3xMealQjGDDEMWLW+d0=; b=WkBfGGIP2ezZXPaZSEnjFIaVWFlKrP3IorprAxBUtu7o63VVNC6o9G8M5kT8juRmdw mz8qA+6+FMewY5pohipRXaLt3Bi4HtUTyZDG0Xzj98UFJwbeL+efYqkUlsOj6vDW2MaM TI7jRtc2OMJY2hYIUbdOChfJhNzkuNti5c4M0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725026105; x=1725630905; 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=TF54oNCp0vG0MW4QPjAISJTV3xMealQjGDDEMWLW+d0=; b=XmqJBBneJsUU+NrtpGjJSqxzg4ILEZij8ZiVWaIiPGj0rZiO6vPDNUT3WbikhDh5uZ fl9GSycr/l1MHg4fdyCvZUz21KEf1G20phSY058h4gYNvjGaOT8Ln+qWTfJz6IR7FIO/ qW5dx2L+TIcpUg0G3jHWBrUf7yFR3Zs7Fi60h5ncZg9x2ITfTf2hJc5pgH+KmY1TwyAU KO58+cKk9TUovZHtV0C4AXttyU7jHfxYM2hxKWdt9gQsTbTwtCyYsCZjwYneuev00GGO 5FrVthWIxY1X0YFq04NGxsOu8ox8bqgehFJVJShwSfu5AGUG1qvafd0dggogIS6E1PKZ E9qQ== X-Gm-Message-State: AOJu0YwtsvjorjiASGQVphtuOLVjJU3UdL+DS6v6w7PgDOY1CvLnSjkf X0u3Xfi8F2BvYhOGLMfMEfoicGs9eQuKac3q8Z/i0zbs3/JnX7cs16UqzUFQCwVWZcs6tMAt0Ou efUI4hdzcpl9kgTOfhfz1pf7UEg2WF3CaHcTxbzntZQAbwADKix1w+DJHaW7UNuYxEw6Hq0ouPx WKxe6upB+VCiwWtFYUfpSXbUbNdx+Qn5g12KJCCVRh3Efz X-Google-Smtp-Source: AGHT+IH8gEYdffQ1qOzwyYNBLuNtZLvDIUrm3xQcbyRttxmEN2dy7SzbUiZl1gfpTfT1H3wjzhdMvg== X-Received: by 2002:a17:902:e849:b0:1fb:93e6:94a3 with SMTP id d9443c01a7336-2050c23dd69mr70378245ad.18.1725026105072; Fri, 30 Aug 2024 06:55:05 -0700 (PDT) Received: from dhcp-10-123-154-23.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-205155658dfsm27067145ad.297.2024.08.30.06.55.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2024 06:55:04 -0700 (PDT) From: Sriharsha Basavapatna To: dev@dpdk.org Cc: Peter Spreadborough , Ajit Khaparde , Kishore Padmanabha , Sriharsha Basavapatna Subject: [PATCH 39/47] net/bnxt: tf_ulp: switch ulp to use rte crc32 hash Date: Fri, 30 Aug 2024 19:30:41 +0530 Message-Id: <20240830140049.1715230-40-sriharsha.basavapatna@broadcom.com> X-Mailer: git-send-email 2.39.0.189.g4dbebc36b0 In-Reply-To: <20240830140049.1715230-1-sriharsha.basavapatna@broadcom.com> References: <20240830140049.1715230-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 Reviewed-by: Ajit Khaparde Reviewed-by: Kishore Padmanabha Signed-off-by: Sriharsha Basavapatna --- 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