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 3598645B90; Mon, 21 Oct 2024 10:20:07 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8543340B92; Mon, 21 Oct 2024 10:19:27 +0200 (CEST) Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by mails.dpdk.org (Postfix) with ESMTP id 7150E406B7 for ; Mon, 21 Oct 2024 10:19:24 +0200 (CEST) Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-7eae96e6624so656237a12.2 for ; Mon, 21 Oct 2024 01:19:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1729498763; x=1730103563; 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=fMTQ9rubN46gD/XH5iFXK4pGa7u/ZNC7Vf09F+nDUeA=; b=RhNyOAKbv7kHgRKAq8DkBeyYOkyr4rFXY6BIbyUR4mB5nrCeeYCJK+bnu86vtoGNa6 uBVwB6xOJY2oLTpFU4ukS0Wd8gxVh55uo3uNTY4BMEvD6QzZKZ+V78WXOWOCTO1q8kQN HLOMRcxUv88o0HrSV46QHOWtX3AWczq3eDgVg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729498763; x=1730103563; 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=fMTQ9rubN46gD/XH5iFXK4pGa7u/ZNC7Vf09F+nDUeA=; b=AxZMroaZ+++ej6C4N8xKA38r/y3D+0wjZb4LkZ0vecmS3qCQ3dzk9AjbehUd0HaqMj OsFHnvhe8Ud1tcGIAWXTn8V3yyRLgxmlS5lLoACAqLXXZ8ii+1T2MDsGWzXTu3+5yaSQ 5QkxQ+/Rhd+TXvOuwxXjwmUVdf97Gy9dmEXNqCYvRsTeMWgR/M7ddinC6iFklQbLPn8m tTAfaLCwcH2gZvtJ3QYkGUYBzFnVt27urX4S1HPNKdoyVK4AQXorA76CSEshwpSkm8tC sAPSAKlDI495qr/5kMfjeKhI3JPpCZTPmkxrDXcSc4WjNvhXtNZ6hlN3lmGpPUdZSYz1 m2jQ== X-Gm-Message-State: AOJu0YycPqTKcklgYikNpCJ2mhaT/fXnz+J8xR4sBfj5wA24fsBmHjpT VFh6/hV652qtMxMISpJLwyamDKlYzMR/GApij4jUneeAa5xH5EsT4UTpHMoHB5RYp6Q/6/wfjvo qwO6kEUWNIlVbMajae+0kY/cGDg3jDMHJXy7O6T2f0gZlaQQf+rdK6u/NfyQ/mjcfhZxh5VLUje olZCAMobA3z/KJA01IDuK+6Wlu5Dptpp2OSVWpoHQvXA== X-Google-Smtp-Source: AGHT+IF97O8ll52nOzVd8WvhBtbVCrjXjjbXat5BuOT5yWPC9E4J0rHIKSkS+7OCF/8xfKDUwGqNqg== X-Received: by 2002:a05:6a20:4c22:b0:1d9:3957:8a14 with SMTP id adf61e73a8af0-1d939578a36mr9744250637.1.1729498762841; Mon, 21 Oct 2024 01:19:22 -0700 (PDT) Received: from dhcp-10-123-154-23.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71ec1313926sm2291631b3a.4.2024.10.21.01.19.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 01:19:21 -0700 (PDT) From: Sriharsha Basavapatna To: dev@dpdk.org Cc: Peter Spreadborough , Sriharsha Basavapatna , Kishore Padmanabha , Ajit Khaparde Subject: [PATCH v6 39/47] net/bnxt: tf_ulp: switch ulp to use rte crc32 hash Date: Mon, 21 Oct 2024 13:55:59 +0530 Message-Id: <20241021082607.232829-40-sriharsha.basavapatna@broadcom.com> X-Mailer: git-send-email 2.39.0.189.g4dbebc36b0 In-Reply-To: <20241021082607.232829-1-sriharsha.basavapatna@broadcom.com> References: <20241021082607.232829-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 d7decacc26..3d48f42c1b 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" @@ -925,6 +926,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