diff mbox series

[v2,08/13] net/bnxt: add wild card TCAM byte order for Thor

Message ID 20210908050643.9989-9-venkatkumar.duvvuru@broadcom.com (mailing list archive)
State Superseded
Delegated to: Ajit Khaparde
Headers show
Series enhancements to host based flow table management | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Venkat Duvvuru Sept. 8, 2021, 5:06 a.m. UTC
From: Kishore Padmanabha <kishore.padmanabha@broadcom.com>

The wild card tcam for Thor platform is different from the profile tcam
byte order.

Signed-off-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Shuanglin Wang <shuanglin.wang@broadcom.com>
Reviewed-by: Michael Baucom <michael.baucom@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 .../generic_templates/ulp_template_db_tbl.c   |  2 ++
 drivers/net/bnxt/tf_ulp/ulp_mapper.c          | 25 +++++++++++++------
 drivers/net/bnxt/tf_ulp/ulp_template_struct.h |  1 +
 3 files changed, 21 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/bnxt/tf_ulp/generic_templates/ulp_template_db_tbl.c b/drivers/net/bnxt/tf_ulp/generic_templates/ulp_template_db_tbl.c
index b5bce6f4c7..68f1b5fd00 100644
--- a/drivers/net/bnxt/tf_ulp/generic_templates/ulp_template_db_tbl.c
+++ b/drivers/net/bnxt/tf_ulp/generic_templates/ulp_template_db_tbl.c
@@ -201,6 +201,7 @@  struct bnxt_ulp_device_params ulp_device_params[BNXT_ULP_DEVICE_ID_LAST] = {
 	.key_byte_order          = BNXT_ULP_BYTE_ORDER_LE,
 	.result_byte_order       = BNXT_ULP_BYTE_ORDER_LE,
 	.encap_byte_order        = BNXT_ULP_BYTE_ORDER_BE,
+	.wc_key_byte_order       = BNXT_ULP_BYTE_ORDER_BE,
 	.encap_byte_swap         = 1,
 	.int_flow_db_num_entries = 16384,
 	.ext_flow_db_num_entries = 32768,
@@ -223,6 +224,7 @@  struct bnxt_ulp_device_params ulp_device_params[BNXT_ULP_DEVICE_ID_LAST] = {
 	.key_byte_order          = BNXT_ULP_BYTE_ORDER_LE,
 	.result_byte_order       = BNXT_ULP_BYTE_ORDER_LE,
 	.encap_byte_order        = BNXT_ULP_BYTE_ORDER_BE,
+	.wc_key_byte_order       = BNXT_ULP_BYTE_ORDER_BE,
 	.encap_byte_swap         = 1,
 	.int_flow_db_num_entries = 16384,
 	.ext_flow_db_num_entries = 32768,
diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
index 2687a545f3..bcc089b3e1 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
@@ -1953,6 +1953,15 @@  static void ulp_mapper_wc_tcam_tbl_post_process(struct ulp_blob *blob)
 #endif
 }
 
+static int32_t ulp_mapper_tcam_is_wc_tcam(struct bnxt_ulp_mapper_tbl_info *tbl)
+{
+	if (tbl->resource_type == TF_TCAM_TBL_TYPE_WC_TCAM ||
+	    tbl->resource_type == TF_TCAM_TBL_TYPE_WC_TCAM_HIGH ||
+	    tbl->resource_type == TF_TCAM_TBL_TYPE_WC_TCAM_LOW)
+		return 1;
+	return 0;
+}
+
 static int32_t
 ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 			    struct bnxt_ulp_mapper_tbl_info *tbl)
@@ -1972,6 +1981,7 @@  ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 	uint32_t hit = 0;
 	uint16_t tmplen = 0;
 	uint16_t idx;
+	enum bnxt_ulp_byte_order key_byte_order;
 
 	/* Set the key and mask to the original key and mask. */
 	key = &okey;
@@ -2003,10 +2013,13 @@  ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 		return -EINVAL;
 	}
 
-	if (!ulp_blob_init(key, tbl->blob_key_bit_size,
-			   dparms->key_byte_order) ||
-	    !ulp_blob_init(mask, tbl->blob_key_bit_size,
-			   dparms->key_byte_order) ||
+	if (ulp_mapper_tcam_is_wc_tcam(tbl))
+		key_byte_order = dparms->wc_key_byte_order;
+	else
+		key_byte_order = dparms->key_byte_order;
+
+	if (!ulp_blob_init(key, tbl->blob_key_bit_size, key_byte_order) ||
+	    !ulp_blob_init(mask, tbl->blob_key_bit_size, key_byte_order) ||
 	    !ulp_blob_init(&data, tbl->result_bit_size,
 			   dparms->result_byte_order) ||
 	    !ulp_blob_init(&update_data, tbl->result_bit_size,
@@ -2043,9 +2056,7 @@  ulp_mapper_tcam_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 	}
 
 	/* For wild card tcam perform the post process to swap the blob */
-	if (tbl->resource_type == TF_TCAM_TBL_TYPE_WC_TCAM ||
-	    tbl->resource_type == TF_TCAM_TBL_TYPE_WC_TCAM_HIGH ||
-	    tbl->resource_type == TF_TCAM_TBL_TYPE_WC_TCAM_LOW) {
+	if (ulp_mapper_tcam_is_wc_tcam(tbl)) {
 		if (dparms->dynamic_pad_en) {
 			/* Sets up the slices for writing to the WC TCAM */
 			rc = ulp_mapper_wc_tcam_tbl_dyn_post_process(dparms,
diff --git a/drivers/net/bnxt/tf_ulp/ulp_template_struct.h b/drivers/net/bnxt/tf_ulp/ulp_template_struct.h
index 904763f27d..e2a4b81cec 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_template_struct.h
+++ b/drivers/net/bnxt/tf_ulp/ulp_template_struct.h
@@ -212,6 +212,7 @@  struct bnxt_ulp_device_params {
 	enum bnxt_ulp_byte_order	key_byte_order;
 	enum bnxt_ulp_byte_order	result_byte_order;
 	enum bnxt_ulp_byte_order	encap_byte_order;
+	enum bnxt_ulp_byte_order	wc_key_byte_order;
 	uint8_t				encap_byte_swap;
 	uint8_t				num_phy_ports;
 	uint32_t			mark_db_lfid_entries;