DPDK patches and discussions
 help / color / mirror / Atom feed
From: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
To: dev@dpdk.org
Cc: Peter Spreadborough <peter.spreadborough@broadcom.com>,
	Ajit Khaparde <ajit.khaparde@broadcom.com>,
	Kishore Padmanabha <kishore.padmanabha@broadcom.com>,
	Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
Subject: [PATCH 39/47] net/bnxt: tf_ulp: switch ulp to use rte crc32 hash
Date: Fri, 30 Aug 2024 19:30:41 +0530	[thread overview]
Message-ID: <20240830140049.1715230-40-sriharsha.basavapatna@broadcom.com> (raw)
In-Reply-To: <20240830140049.1715230-1-sriharsha.basavapatna@broadcom.com>

From: Peter Spreadborough <peter.spreadborough@broadcom.com>

The RTE hash is highly optimized and will use HW acceleration
when available.

Signed-off-by: Peter Spreadborough <peter.spreadborough@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
Reviewed-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Signed-off-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
---
 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 <rte_spinlock.h>
 #include <rte_mtr.h>
 #include <rte_version.h>
+#include <rte_hash_crc.h>
 
 #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 <rte_spinlock.h>
 #include <rte_mtr.h>
 #include <rte_version.h>
+#include <rte_hash_crc.h>
 
 #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 <rte_log.h>
 #include <rte_malloc.h>
+#include <rte_hash_crc.h>
 #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


  parent reply	other threads:[~2024-08-30 13:55 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-30 14:00 [PATCH 00/47] TruFlow update for Thor2 Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 01/47] net/bnxt: tf_core: fix wc tcam multi slice delete issue Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 02/47] net/bnxt: tf_core: tcam manager data corruption Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 03/47] net/bnxt: tf_core: External EM support cleanup Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 04/47] net/bnxt: tf_core: Thor TF EM key size check Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 05/47] net/bnxt: tf_core: flow scale improvement Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 06/47] net/bnxt: tf_core: TF support flow scale query Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 07/47] net/bnxt: tf_core: fix slice count in case of HA entry move Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 08/47] net/bnxt: tf_core: convert priority based TCAM manager to dynamic allocation Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 09/47] net/bnxt: tf_core: remove dead AFM code from session-based priority TCAM mgr Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 10/47] net/bnxt: tf_core: remove dead " Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 11/47] net/bnxt: tfc: support tf-core for Thor2 Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 12/47] net/bnxt: tf_ulp: add vxlan-gpe base support Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 13/47] net/bnxt: tf_ulp: add custom l2 etype tunnel support Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 14/47] net/bnxt: tf_ulp: add support for vf to vf flow offload Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 15/47] net/bnxt: tf_ulp: Wh+ mirroring support Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 16/47] net/bnxt: tf_ulp: miscellaneous fixes Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 17/47] net/bnxt: tf_ulp: support for Thor2 ulp layer Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 18/47] net/bnxt: tf_ulp: add support for overlapping flows Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 19/47] net/bnxt: tf_ulp: convert recipe table to dynamic memory Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 20/47] net/bnxt: tf_ulp: add feature bit support Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 21/47] net/bnxt: tf_ulp: add action read and clear support Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 22/47] net/bnxt: tf_ulp: update template files Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 23/47] net/bnxt: tf_ulp: VFR updates for Thor 2 Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 24/47] net/bnxt: tf_ulp: add support for tunnel flow stats Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 25/47] net/bnxt: tf_ulp: update template files Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 26/47] net/bnxt: tf_ulp: enable recipe id generation Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 27/47] net/bnxt: tf_ulp: fixed parent child db counters Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 28/47] net/bnxt: tf_ulp: modify return values to adhere to C coding standard Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 29/47] net/bnxt: tf_ulp: update template files Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 30/47] net/bnxt: tf_ulp: add mask defaults when mask is not specified Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 31/47] net/bnxt: tf_ulp: add jump action support Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 32/47] net/bnxt: tf_ulp: add support for flow priority Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 33/47] net/bnxt: tf_ulp: support for dynamic tunnel ports Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 34/47] net/bnxt: tf_ulp: add rte_mtr support for Thor2 Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 35/47] net/bnxt: tf_ulp: TF support flow scale query Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 36/47] net/bnxt: tf_ulp: add support for rss flow query to ULP Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 37/47] net/bnxt: tf_ulp: add track type feature to tables Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 38/47] net/bnxt: tf_ulp: inline utility functions and use likely/unlikely Sriharsha Basavapatna
2024-08-30 14:00 ` Sriharsha Basavapatna [this message]
2024-08-30 14:00 ` [PATCH 40/47] net/bnxt: tf_ulp: update template files Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 41/47] net/bnxt: tf_ulp: support a few generic template items Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 42/47] net/bnxt: tf_ulp: TFC support flow scale query for Thor2 Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 43/47] net/bnxt: tf_ulp: update template files Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 44/47] net/bnxt: tf_ulp: enable support for truflow feature configuration Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 45/47] net/bnxt: tf_ulp: support a few feature extensions Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 46/47] net/bnxt: update template files Sriharsha Basavapatna
2024-08-30 14:00 ` [PATCH 47/47] net/bnxt: tf_ulp: add stats cache for thor2 Sriharsha Basavapatna
2024-09-25 12:02 ` [PATCH 00/47] TruFlow update for Thor2 Ajit Khaparde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240830140049.1715230-40-sriharsha.basavapatna@broadcom.com \
    --to=sriharsha.basavapatna@broadcom.com \
    --cc=ajit.khaparde@broadcom.com \
    --cc=dev@dpdk.org \
    --cc=kishore.padmanabha@broadcom.com \
    --cc=peter.spreadborough@broadcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).