[v8,10/47] net/bnxt: tf_core: remove dead code from session-based priority TCAM mgr

Message ID 20241107135254.1611676-11-sriharsha.basavapatna@broadcom.com (mailing list archive)
State Accepted, archived
Delegated to: Ajit Khaparde
Headers
Series TruFlow update for Thor2 |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Sriharsha Basavapatna Nov. 7, 2024, 1:52 p.m. UTC
From: Randy Schacher <stuart.schacher@broadcom.com>

Remove references to tx_tcam_supported and rx_tcam_supported
logic which chooses between FW-based tcam resource allocation
and driver-based tcam manager.

Signed-off-by: Randy Schacher <stuart.schacher@broadcom.com>
Signed-off-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
Reviewed-by: Peter Spreadborough <peter.spreadborough@broadcom.com>
Reviewed-by: Manish Kurup <manish.kurup@broadcom.com>
Reviewed-by: Farah Smith <farah.smith@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/tf_core/cfa_tcam_mgr.c    |  46 ----
 drivers/net/bnxt/tf_core/cfa_tcam_mgr.h    |  29 --
 drivers/net/bnxt/tf_core/tf_session.h      |   5 -
 drivers/net/bnxt/tf_core/tf_tcam.c         | 294 +--------------------
 drivers/net/bnxt/tf_core/tf_tcam_mgr_msg.c |  28 --
 drivers/net/bnxt/tf_core/tf_tcam_mgr_msg.h |   6 -
 6 files changed, 8 insertions(+), 400 deletions(-)
  

Patch

diff --git a/drivers/net/bnxt/tf_core/cfa_tcam_mgr.c b/drivers/net/bnxt/tf_core/cfa_tcam_mgr.c
index 7a68f61997..89ca6814e5 100644
--- a/drivers/net/bnxt/tf_core/cfa_tcam_mgr.c
+++ b/drivers/net/bnxt/tf_core/cfa_tcam_mgr.c
@@ -1072,52 +1072,6 @@  cfa_tcam_mgr_init(struct tf *tfp, enum cfa_tcam_mgr_device_type type,
 	return 0;
 }
 
-int
-cfa_tcam_mgr_qcaps(struct tf *tfp __rte_unused,
-		   struct cfa_tcam_mgr_qcaps_parms *parms)
-{
-	struct cfa_tcam_mgr_data *tcam_mgr_data;
-	struct tf_session *tfs;
-	unsigned int type;
-	int rc;
-
-	CFA_TCAM_MGR_CHECK_PARMS2(tfp, parms);
-
-	rc = tf_session_get_session_internal(tfp, &tfs);
-	if (rc)
-		return rc;
-
-	tcam_mgr_data = tfs->tcam_mgr_handle;
-	if (!tcam_mgr_data) {
-		CFA_TCAM_MGR_LOG_0(ERR, "No TCAM data created for session.\n");
-		return -CFA_TCAM_MGR_ERR_CODE(PERM);
-	}
-
-	/*
-	 * This code will indicate if TCAM Manager is managing a logical TCAM
-	 * table or not.  If not, then the physical TCAM will have to be
-	 * accessed using the traditional methods.
-	 */
-	parms->rx_tcam_supported = 0;
-	parms->tx_tcam_supported = 0;
-	for (type = 0; type < CFA_TCAM_MGR_TBL_TYPE_MAX; type++) {
-		if (tcam_mgr_data->cfa_tcam_mgr_tables[TF_DIR_RX]
-				[type].max_entries > 0 &&
-		    tcam_mgr_data->cfa_tcam_mgr_tables[TF_DIR_RX]
-				[type].hcapi_type > 0)
-			parms->rx_tcam_supported |=
-				1 << cfa_tcam_mgr_get_phys_table_type(type);
-		if (tcam_mgr_data->cfa_tcam_mgr_tables[TF_DIR_TX]
-				[type].max_entries > 0 &&
-		    tcam_mgr_data->cfa_tcam_mgr_tables[TF_DIR_TX]
-				[type].hcapi_type > 0)
-			parms->tx_tcam_supported |=
-				1 << cfa_tcam_mgr_get_phys_table_type(type);
-	}
-
-	return 0;
-}
-
 static
 int cfa_tcam_mgr_validate_tcam_cnt(struct tf *tfp  __rte_unused,
 				   struct cfa_tcam_mgr_data *tcam_mgr_data,
diff --git a/drivers/net/bnxt/tf_core/cfa_tcam_mgr.h b/drivers/net/bnxt/tf_core/cfa_tcam_mgr.h
index e1a691b775..6ac1156fbf 100644
--- a/drivers/net/bnxt/tf_core/cfa_tcam_mgr.h
+++ b/drivers/net/bnxt/tf_core/cfa_tcam_mgr.h
@@ -113,18 +113,6 @@  struct cfa_tcam_mgr_init_parms {
 	uint32_t max_entries;
 };
 
-/**
- * TCAM Manager initialization parameters
- */
-struct cfa_tcam_mgr_qcaps_parms {
-	/**
-	 * [out] Bitmasks.  Set if TCAM Manager is managing a logical TCAM.
-	 * Each bitmask is indexed by logical TCAM table ID.
-	 */
-	uint32_t rx_tcam_supported;
-	uint32_t tx_tcam_supported;
-};
-
 /**
  * TCAM Manager configuration parameters
  */
@@ -360,23 +348,6 @@  cfa_tcam_mgr_init(struct tf *tfp, enum cfa_tcam_mgr_device_type type,
 int
 cfa_tcam_mgr_get_phys_table_type(enum cfa_tcam_mgr_tbl_type type);
 
-/**
- * Queries the capabilities of TCAM Manager.
- *
- * [in] context
- *   Pointer to context information
- *
- * [out] parms
- *   Pointer to parameters to be returned
- *
- * Returns
- *   - (0) if successful.
- *   - (<0) on failure.
- */
-int
-cfa_tcam_mgr_qcaps(struct tf *tfp __rte_unused,
-		   struct cfa_tcam_mgr_qcaps_parms *parms);
-
 /**
  * Initializes the TCAM module with the requested DBs. Must be
  * invoked as the first thing before any of the access functions.
diff --git a/drivers/net/bnxt/tf_core/tf_session.h b/drivers/net/bnxt/tf_core/tf_session.h
index d46d89e9e9..7668e9d0e0 100644
--- a/drivers/net/bnxt/tf_core/tf_session.h
+++ b/drivers/net/bnxt/tf_core/tf_session.h
@@ -174,11 +174,6 @@  struct tf_session {
 	 */
 	uint16_t wc_num_slices_per_row;
 
-	/**
-	 * Indicates if TCAM is controlled by TCAM Manager
-	 */
-	int tcam_mgr_control[TF_DIR_MAX][TF_TCAM_TBL_TYPE_MAX];
-
 	/**
 	 * TCAM Manager handle pointing to session based tcam memory
 	 */
diff --git a/drivers/net/bnxt/tf_core/tf_tcam.c b/drivers/net/bnxt/tf_core/tf_tcam.c
index fa8f60777d..e9bff62f88 100644
--- a/drivers/net/bnxt/tf_core/tf_tcam.c
+++ b/drivers/net/bnxt/tf_core/tf_tcam.c
@@ -37,9 +37,6 @@  tf_tcam_bind(struct tf *tfp,
 	struct tcam_rm_db *tcam_db;
 	struct tfp_calloc_parms cparms;
 	struct tf_resource_info resv_res[TF_DIR_MAX][TF_TCAM_TBL_TYPE_MAX];
-	uint32_t rx_supported;
-	uint32_t tx_supported;
-	bool no_req = true;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -167,39 +164,16 @@  tf_tcam_bind(struct tf *tfp,
 	if (rc)
 		return rc;
 
-	rc = tf_tcam_mgr_qcaps_msg(tfp, dev,
-				   &rx_supported, &tx_supported);
-	if (rc)
-		return rc;
-
-	for (t = 0; t < TF_TCAM_TBL_TYPE_MAX; t++) {
-		if (rx_supported & 1 << t)
-			tfs->tcam_mgr_control[TF_DIR_RX][t] = 1;
-		if (tx_supported & 1 << t)
-			tfs->tcam_mgr_control[TF_DIR_TX][t] = 1;
-	}
-
 	/*
 	 * Make a local copy of tcam_cnt with only resources not managed by TCAM
 	 * Manager requested.
 	 */
 	memcpy(&local_tcam_cnt, tcam_cnt, sizeof(local_tcam_cnt));
 	tcam_cnt = local_tcam_cnt;
-	for (d = 0; d < TF_DIR_MAX; d++) {
-		for (t = 0; t < TF_TCAM_TBL_TYPE_MAX; t++) {
-			/* If controlled by TCAM Manager */
-			if (tfs->tcam_mgr_control[d][t])
-				tcam_cnt[d].cnt[t] = 0;
-			else if (tcam_cnt[d].cnt[t] > 0)
-				no_req = false;
-		}
-	}
-
-	/* If no resources left to request */
-	if (no_req)
-		goto finished;
+	for (d = 0; d < TF_DIR_MAX; d++)
+		for (t = 0; t < TF_TCAM_TBL_TYPE_MAX; t++)
+			tcam_cnt[d].cnt[t] = 0;
 
-finished:
 	TFP_DRV_LOG(INFO,
 		    "TCAM - initialized\n");
 
@@ -274,14 +248,10 @@  int
 tf_tcam_alloc(struct tf *tfp,
 	      struct tf_tcam_alloc_parms *parms)
 {
-	int rc, i;
+	int rc;
 	struct tf_session *tfs;
 	struct tf_dev_info *dev;
-	struct tf_rm_allocate_parms aparms;
 	uint16_t num_slices = 1;
-	uint32_t index;
-	struct tcam_rm_db *tcam_db;
-	void *tcam_db_ptr = NULL;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -312,43 +282,7 @@  tf_tcam_alloc(struct tf *tfp,
 	if (rc)
 		return rc;
 
-	/* If TCAM controlled by TCAM Manager */
-	if (tfs->tcam_mgr_control[parms->dir][parms->type])
-		return tf_tcam_mgr_alloc_msg(tfp, dev, parms);
-	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);
-	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "Failed to get tcam_db from session, rc:%s\n",
-			    strerror(-rc));
-		return rc;
-	}
-	tcam_db = (struct tcam_rm_db *)tcam_db_ptr;
-
-	/*
-	 * For WC TCAM, number of slices could be 4, 2, 1 based on
-	 * the key_size. For other TCAM, it is always 1
-	 */
-	for (i = 0; i < num_slices; i++) {
-		memset(&aparms, 0, sizeof(aparms));
-		aparms.rm_db = tcam_db->tcam_db[parms->dir];
-		aparms.subtype = parms->type;
-		aparms.priority = parms->priority;
-		aparms.index = &index;
-		rc = tf_rm_allocate(&aparms);
-		if (rc) {
-			TFP_DRV_LOG(ERR,
-				    "%s: Failed tcam, type:%d\n",
-				    tf_dir_2_str(parms->dir),
-				    parms->type);
-			return rc;
-		}
-
-		/* return the start index of each row */
-			if (i == 0)
-				parms->idx = index;
-	}
-
-	return 0;
+	return tf_tcam_mgr_alloc_msg(tfp, dev, parms);
 }
 
 int
@@ -358,14 +292,7 @@  tf_tcam_free(struct tf *tfp,
 	int rc;
 	struct tf_session *tfs;
 	struct tf_dev_info *dev;
-	struct tf_rm_is_allocated_parms aparms;
-	struct tf_rm_free_parms fparms;
-	struct tf_rm_get_hcapi_parms hparms;
 	uint16_t num_slices = 1;
-	int allocated = 0;
-	int i;
-	struct tcam_rm_db *tcam_db;
-	void *tcam_db_ptr = NULL;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -396,91 +323,7 @@  tf_tcam_free(struct tf *tfp,
 	if (rc)
 		return rc;
 
-	/* If TCAM controlled by TCAM Manager */
-	if (tfs->tcam_mgr_control[parms->dir][parms->type])
-		/*
-		 * If a session can have multiple references to an entry, check
-		 * the reference count here before actually freeing the entry.
-		 */
-		return tf_tcam_mgr_free_msg(tfp, dev, parms);
-
-	if (parms->idx % num_slices) {
-		TFP_DRV_LOG(ERR,
-			    "%s: TCAM reserved resource is not multiple of %d\n",
-			    tf_dir_2_str(parms->dir),
-			    num_slices);
-		return -EINVAL;
-	}
-
-	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);
-	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "Failed to get em_ext_db from session, rc:%s\n",
-			    strerror(-rc));
-		return rc;
-	}
-	tcam_db = (struct tcam_rm_db *)tcam_db_ptr;
-
-	/* Check if element is in use */
-	memset(&aparms, 0, sizeof(aparms));
-	aparms.rm_db = tcam_db->tcam_db[parms->dir];
-	aparms.subtype = parms->type;
-	aparms.index = parms->idx;
-	aparms.allocated = &allocated;
-	rc = tf_rm_is_allocated(&aparms);
-	if (rc)
-		return rc;
-
-	if (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) {
-		TFP_DRV_LOG(ERR,
-			    "%s: Entry already free, type:%d, index:%d\n",
-			    tf_dir_2_str(parms->dir),
-			    parms->type,
-			    parms->idx);
-		return -EINVAL;
-	}
-
-	for (i = 0; i < num_slices; i++) {
-		/* Free requested element */
-		memset(&fparms, 0, sizeof(fparms));
-		fparms.rm_db = tcam_db->tcam_db[parms->dir];
-		fparms.subtype = parms->type;
-		fparms.index = parms->idx + i;
-		rc = tf_rm_free(&fparms);
-		if (rc) {
-			TFP_DRV_LOG(ERR,
-				    "%s: Free failed, type:%d, index:%d\n",
-				    tf_dir_2_str(parms->dir),
-				    parms->type,
-				    parms->idx);
-			return rc;
-		}
-	}
-
-	/* Convert TF type to HCAPI RM type */
-	memset(&hparms, 0, sizeof(hparms));
-
-	hparms.rm_db = tcam_db->tcam_db[parms->dir];
-	hparms.subtype = parms->type;
-	hparms.hcapi_type = &parms->hcapi_type;
-
-	rc = tf_rm_get_hcapi_type(&hparms);
-	if (rc)
-		return rc;
-
-	rc = tf_msg_tcam_entry_free(tfp, dev, parms);
-	if (rc) {
-		/* Log error */
-		TFP_DRV_LOG(ERR,
-			    "%s: %s: Entry %d free failed, rc:%s\n",
-			    tf_dir_2_str(parms->dir),
-			    tf_tcam_tbl_2_str(parms->type),
-			    parms->idx,
-			    strerror(-rc));
-		return rc;
-	}
-
-	return 0;
+	return tf_tcam_mgr_free_msg(tfp, dev, parms);
 }
 
 int
@@ -490,12 +333,7 @@  tf_tcam_set(struct tf *tfp __rte_unused,
 	int rc;
 	struct tf_session *tfs;
 	struct tf_dev_info *dev;
-	struct tf_rm_is_allocated_parms aparms;
-	struct tf_rm_get_hcapi_parms hparms;
 	uint16_t num_slice_per_row = 1;
-	int allocated = 0;
-	struct tcam_rm_db *tcam_db;
-	void *tcam_db_ptr = NULL;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -526,62 +364,7 @@  tf_tcam_set(struct tf *tfp __rte_unused,
 	if (rc)
 		return rc;
 
-	/* If TCAM controlled by TCAM Manager */
-	if (tfs->tcam_mgr_control[parms->dir][parms->type])
-		return tf_tcam_mgr_set_msg(tfp, dev, parms);
-
-	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);
-	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "Failed to get em_ext_db from session, rc:%s\n",
-			    strerror(-rc));
-		return rc;
-	}
-	tcam_db = (struct tcam_rm_db *)tcam_db_ptr;
-
-	/* Check if element is in use */
-	memset(&aparms, 0, sizeof(aparms));
-
-	aparms.rm_db = tcam_db->tcam_db[parms->dir];
-	aparms.subtype = parms->type;
-	aparms.index = parms->idx;
-	aparms.allocated = &allocated;
-	rc = tf_rm_is_allocated(&aparms);
-	if (rc)
-		return rc;
-
-	if (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) {
-		TFP_DRV_LOG(ERR,
-			    "%s: Entry is not allocated, type:%d, index:%d\n",
-			    tf_dir_2_str(parms->dir),
-			    parms->type,
-			    parms->idx);
-		return -EINVAL;
-	}
-
-	/* Convert TF type to HCAPI RM type */
-	memset(&hparms, 0, sizeof(hparms));
-
-	hparms.rm_db = tcam_db->tcam_db[parms->dir];
-	hparms.subtype = parms->type;
-	hparms.hcapi_type = &parms->hcapi_type;
-
-	rc = tf_rm_get_hcapi_type(&hparms);
-	if (rc)
-		return rc;
-
-	rc = tf_msg_tcam_entry_set(tfp, dev, parms);
-	if (rc) {
-		/* Log error */
-		TFP_DRV_LOG(ERR,
-			    "%s: %s: Entry %d set failed, rc:%s",
-			    tf_dir_2_str(parms->dir),
-			    tf_tcam_tbl_2_str(parms->type),
-			    parms->idx,
-			    strerror(-rc));
-		return rc;
-	}
-	return 0;
+	return tf_tcam_mgr_set_msg(tfp, dev, parms);
 }
 
 int
@@ -591,11 +374,6 @@  tf_tcam_get(struct tf *tfp __rte_unused,
 	int rc;
 	struct tf_session *tfs;
 	struct tf_dev_info *dev;
-	struct tf_rm_is_allocated_parms aparms;
-	struct tf_rm_get_hcapi_parms hparms;
-	int allocated = 0;
-	struct tcam_rm_db *tcam_db;
-	void *tcam_db_ptr = NULL;
 
 	TF_CHECK_PARMS2(tfp, parms);
 
@@ -609,63 +387,7 @@  tf_tcam_get(struct tf *tfp __rte_unused,
 	if (rc)
 		return rc;
 
-	/* If TCAM controlled by TCAM Manager */
-	if (tfs->tcam_mgr_control[parms->dir][parms->type])
-		return tf_tcam_mgr_get_msg(tfp, dev, parms);
-
-	rc = tf_session_get_db(tfp, TF_MODULE_TYPE_TCAM, &tcam_db_ptr);
-	if (rc) {
-		TFP_DRV_LOG(ERR,
-			    "Failed to get em_ext_db from session, rc:%s\n",
-			    strerror(-rc));
-		return rc;
-	}
-	tcam_db = (struct tcam_rm_db *)tcam_db_ptr;
-
-	/* Check if element is in use */
-	memset(&aparms, 0, sizeof(aparms));
-
-	aparms.rm_db = tcam_db->tcam_db[parms->dir];
-	aparms.subtype = parms->type;
-	aparms.index = parms->idx;
-	aparms.allocated = &allocated;
-	rc = tf_rm_is_allocated(&aparms);
-	if (rc)
-		return rc;
-
-	if (allocated != TF_RM_ALLOCATED_ENTRY_IN_USE) {
-		TFP_DRV_LOG(ERR,
-			    "%s: Entry is not allocated, type:%d, index:%d\n",
-			    tf_dir_2_str(parms->dir),
-			    parms->type,
-			    parms->idx);
-		return -EINVAL;
-	}
-
-	/* Convert TF type to HCAPI RM type */
-	memset(&hparms, 0, sizeof(hparms));
-
-	hparms.rm_db = tcam_db->tcam_db[parms->dir];
-	hparms.subtype = parms->type;
-	hparms.hcapi_type = &parms->hcapi_type;
-
-	rc = tf_rm_get_hcapi_type(&hparms);
-	if (rc)
-		return rc;
-
-	rc = tf_msg_tcam_entry_get(tfp, dev, parms);
-	if (rc) {
-		/* Log error */
-		TFP_DRV_LOG(ERR,
-			    "%s: %s: Entry %d set failed, rc:%s",
-			    tf_dir_2_str(parms->dir),
-			    tf_tcam_tbl_2_str(parms->type),
-			    parms->idx,
-			    strerror(-rc));
-		return rc;
-	}
-
-	return 0;
+	return tf_tcam_mgr_get_msg(tfp, dev, parms);
 }
 
 int
diff --git a/drivers/net/bnxt/tf_core/tf_tcam_mgr_msg.c b/drivers/net/bnxt/tf_core/tf_tcam_mgr_msg.c
index 8cf4d4d1fb..9e5d39fde5 100644
--- a/drivers/net/bnxt/tf_core/tf_tcam_mgr_msg.c
+++ b/drivers/net/bnxt/tf_core/tf_tcam_mgr_msg.c
@@ -38,34 +38,6 @@  static enum cfa_tcam_mgr_tbl_type tcam_types[TF_TCAM_TBL_TYPE_MAX] = {
 
 static uint16_t hcapi_type[TF_TCAM_TBL_TYPE_MAX];
 
-/*
- * This is the glue between the core tf_tcam and the TCAM manager.  It is
- * intended to abstract out the location of the TCAM manager so that the core
- * code will be the same if the TCAM manager is in the core or in firmware.
- *
- * If the TCAM manager is in the core, then this file will just translate to
- * TCAM manager APIs.  If TCAM manager is in firmware, then this file will cause
- * messages to be sent (except for bind and unbind).
- */
-
-int
-tf_tcam_mgr_qcaps_msg(struct tf *tfp,
-		      struct tf_dev_info *dev __rte_unused,
-		      uint32_t *rx_tcam_supported,
-		      uint32_t *tx_tcam_supported)
-{
-	struct cfa_tcam_mgr_qcaps_parms mgr_parms;
-	int rc;
-
-	memset(&mgr_parms, 0, sizeof(mgr_parms));
-	rc = cfa_tcam_mgr_qcaps(tfp, &mgr_parms);
-	if (rc >= 0) {
-		*rx_tcam_supported = mgr_parms.rx_tcam_supported;
-		*tx_tcam_supported = mgr_parms.tx_tcam_supported;
-	}
-	return rc;
-}
-
 int
 tf_tcam_mgr_bind_msg(struct tf *tfp,
 		     struct tf_dev_info *dev __rte_unused,
diff --git a/drivers/net/bnxt/tf_core/tf_tcam_mgr_msg.h b/drivers/net/bnxt/tf_core/tf_tcam_mgr_msg.h
index 8a8d136f5e..eb4617049a 100644
--- a/drivers/net/bnxt/tf_core/tf_tcam_mgr_msg.h
+++ b/drivers/net/bnxt/tf_core/tf_tcam_mgr_msg.h
@@ -9,12 +9,6 @@ 
 #include "tf_tcam.h"
 #include "tf_rm.h"
 
-int
-tf_tcam_mgr_qcaps_msg(struct tf *tfp,
-		      struct tf_dev_info *dev __rte_unused,
-		      uint32_t *rx_tcam_supported,
-		      uint32_t *tx_tcam_supported);
-
 int
 tf_tcam_mgr_bind_msg(struct tf *tfp,
 		     struct tf_dev_info *dev,