[v5,25/51] net/bnxt: remove table scope from session

Message ID 20200703210210.40568-26-ajit.khaparde@broadcom.com (mailing list archive)
State Accepted, archived
Delegated to: Ajit Khaparde
Headers
Series net/bnxt: add features for host-based flow management |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation fail apply issues

Commit Message

Ajit Khaparde July 3, 2020, 9:01 p.m. UTC
  From: Peter Spreadborough <peter.spreadborough@broadcom.com>

- Remove table scope data from session. Added to EEM.
- Complete move to RM of table scope base and range.
- Fix some err messaging strings.
- Fix the tcam logging message.

Signed-off-by: Peter Spreadborough <peter.spreadborough@broadcom.com>
Reviewed-by: Randy Schacher <stuart.schacher@broadcom.com>
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/tf_core/tf_core.c      |  2 +-
 drivers/net/bnxt/tf_core/tf_em.h        |  1 -
 drivers/net/bnxt/tf_core/tf_em_common.c | 16 +++++++----
 drivers/net/bnxt/tf_core/tf_em_common.h |  5 +---
 drivers/net/bnxt/tf_core/tf_em_host.c   | 38 ++++++++++---------------
 drivers/net/bnxt/tf_core/tf_em_system.c | 12 +++-----
 drivers/net/bnxt/tf_core/tf_session.h   |  3 --
 drivers/net/bnxt/tf_core/tf_tcam.c      |  6 ++--
 8 files changed, 35 insertions(+), 48 deletions(-)
  

Patch

diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c
index 8727900c4..6410843f6 100644
--- a/drivers/net/bnxt/tf_core/tf_core.c
+++ b/drivers/net/bnxt/tf_core/tf_core.c
@@ -573,7 +573,7 @@  tf_free_tcam_entry(struct tf *tfp,
 	rc = dev->ops->tf_dev_free_tcam(tfp, &fparms);
 	if (rc) {
 		TFP_DRV_LOG(ERR,
-			    "%s: TCAM allocation failed, rc:%s\n",
+			    "%s: TCAM free failed, rc:%s\n",
 			    tf_dir_2_str(parms->dir),
 			    strerror(-rc));
 		return rc;
diff --git a/drivers/net/bnxt/tf_core/tf_em.h b/drivers/net/bnxt/tf_core/tf_em.h
index 6bfcbd59e..617b07587 100644
--- a/drivers/net/bnxt/tf_core/tf_em.h
+++ b/drivers/net/bnxt/tf_core/tf_em.h
@@ -9,7 +9,6 @@ 
 #include "tf_core.h"
 #include "tf_session.h"
 
-#define TF_HACK_TBL_SCOPE_BASE 68
 #define SUPPORT_CFA_HW_P4 1
 #define SUPPORT_CFA_HW_P58 0
 #define SUPPORT_CFA_HW_P59 0
diff --git a/drivers/net/bnxt/tf_core/tf_em_common.c b/drivers/net/bnxt/tf_core/tf_em_common.c
index d0d80daeb..e31a63b46 100644
--- a/drivers/net/bnxt/tf_core/tf_em_common.c
+++ b/drivers/net/bnxt/tf_core/tf_em_common.c
@@ -29,6 +29,8 @@ 
  */
 void *eem_db[TF_DIR_MAX];
 
+#define TF_EEM_DB_TBL_SCOPE 1
+
 /**
  * Init flag, set on bind and cleared on unbind
  */
@@ -39,10 +41,12 @@  static uint8_t init;
  */
 static enum tf_mem_type mem_type;
 
+/** Table scope array */
+struct tf_tbl_scope_cb tbl_scopes[TF_NUM_TBL_SCOPE];
+
 /* API defined in tf_em.h */
 struct tf_tbl_scope_cb *
-tbl_scope_cb_find(struct tf_session *session,
-		  uint32_t tbl_scope_id)
+tbl_scope_cb_find(uint32_t tbl_scope_id)
 {
 	int i;
 	struct tf_rm_is_allocated_parms parms;
@@ -50,8 +54,8 @@  tbl_scope_cb_find(struct tf_session *session,
 
 	/* Check that id is valid */
 	parms.rm_db = eem_db[TF_DIR_RX];
-	parms.db_index = 1/**** TYPE TABLE-SCOPE??? ****/;
-	parms.index = tbl_scope_id + TF_HACK_TBL_SCOPE_BASE;
+	parms.db_index = TF_EEM_DB_TBL_SCOPE;
+	parms.index = tbl_scope_id;
 	parms.allocated = &allocated;
 
 	i = tf_rm_is_allocated(&parms);
@@ -60,8 +64,8 @@  tbl_scope_cb_find(struct tf_session *session,
 		return NULL;
 
 	for (i = 0; i < TF_NUM_TBL_SCOPE; i++) {
-		if (session->tbl_scopes[i].tbl_scope_id == tbl_scope_id)
-			return &session->tbl_scopes[i];
+		if (tbl_scopes[i].tbl_scope_id == tbl_scope_id)
+			return &tbl_scopes[i];
 	}
 
 	return NULL;
diff --git a/drivers/net/bnxt/tf_core/tf_em_common.h b/drivers/net/bnxt/tf_core/tf_em_common.h
index 45699a7c3..bf01df9b8 100644
--- a/drivers/net/bnxt/tf_core/tf_em_common.h
+++ b/drivers/net/bnxt/tf_core/tf_em_common.h
@@ -14,8 +14,6 @@ 
  * Function to search for table scope control block structure
  * with specified table scope ID.
  *
- * [in] session
- *   Session to use for the search of the table scope control block
  * [in] tbl_scope_id
  *   Table scope ID to search for
  *
@@ -23,8 +21,7 @@ 
  *  Pointer to the found table scope control block struct or NULL if
  *   table scope control block struct not found
  */
-struct tf_tbl_scope_cb *tbl_scope_cb_find(struct tf_session *session,
-					  uint32_t tbl_scope_id);
+struct tf_tbl_scope_cb *tbl_scope_cb_find(uint32_t tbl_scope_id);
 
 /**
  * Create and initialize a stack to use for action entries
diff --git a/drivers/net/bnxt/tf_core/tf_em_host.c b/drivers/net/bnxt/tf_core/tf_em_host.c
index 8be39afdd..543edb54a 100644
--- a/drivers/net/bnxt/tf_core/tf_em_host.c
+++ b/drivers/net/bnxt/tf_core/tf_em_host.c
@@ -48,6 +48,9 @@ 
  * EM DBs.
  */
 extern void *eem_db[TF_DIR_MAX];
+#define TF_EEM_DB_TBL_SCOPE 1
+
+extern struct tf_tbl_scope_cb tbl_scopes[TF_NUM_TBL_SCOPE];
 
 /**
  * Function to free a page table
@@ -934,14 +937,12 @@  tf_delete_eem_entry(struct tf_tbl_scope_cb *tbl_scope_cb,
  *    -EINVAL - Error
  */
 int
-tf_em_insert_ext_entry(struct tf *tfp,
+tf_em_insert_ext_entry(struct tf *tfp __rte_unused,
 		       struct tf_insert_em_entry_parms *parms)
 {
 	struct tf_tbl_scope_cb *tbl_scope_cb;
 
-	tbl_scope_cb =
-	tbl_scope_cb_find((struct tf_session *)(tfp->session->core_data),
-			  parms->tbl_scope_id);
+	tbl_scope_cb = tbl_scope_cb_find(parms->tbl_scope_id);
 	if (tbl_scope_cb == NULL) {
 		TFP_DRV_LOG(ERR, "Invalid tbl_scope_cb\n");
 		return -EINVAL;
@@ -957,14 +958,12 @@  tf_em_insert_ext_entry(struct tf *tfp,
  *    -EINVAL - Error
  */
 int
-tf_em_delete_ext_entry(struct tf *tfp,
+tf_em_delete_ext_entry(struct tf *tfp __rte_unused,
 		       struct tf_delete_em_entry_parms *parms)
 {
 	struct tf_tbl_scope_cb *tbl_scope_cb;
 
-	tbl_scope_cb =
-	tbl_scope_cb_find((struct tf_session *)(tfp->session->core_data),
-			  parms->tbl_scope_id);
+	tbl_scope_cb = tbl_scope_cb_find(parms->tbl_scope_id);
 	if (tbl_scope_cb == NULL) {
 		TFP_DRV_LOG(ERR, "Invalid tbl_scope_cb\n");
 		return -EINVAL;
@@ -981,16 +980,13 @@  tf_em_ext_host_alloc(struct tf *tfp,
 	enum tf_dir dir;
 	struct tf_tbl_scope_cb *tbl_scope_cb;
 	struct hcapi_cfa_em_table *em_tables;
-	struct tf_session *session;
 	struct tf_free_tbl_scope_parms free_parms;
 	struct tf_rm_allocate_parms aparms = { 0 };
 	struct tf_rm_free_parms fparms = { 0 };
 
-	session = (struct tf_session *)tfp->session->core_data;
-
 	/* Get Table Scope control block from the session pool */
 	aparms.rm_db = eem_db[TF_DIR_RX];
-	aparms.db_index = 1/**** TYPE TABLE-SCOPE??? ****/;
+	aparms.db_index = TF_EEM_DB_TBL_SCOPE;
 	aparms.index = (uint32_t *)&parms->tbl_scope_id;
 	rc = tf_rm_allocate(&aparms);
 	if (rc) {
@@ -999,8 +995,7 @@  tf_em_ext_host_alloc(struct tf *tfp,
 		return rc;
 	}
 
-	parms->tbl_scope_id -= TF_HACK_TBL_SCOPE_BASE;
-	tbl_scope_cb = &session->tbl_scopes[parms->tbl_scope_id];
+	tbl_scope_cb = &tbl_scopes[parms->tbl_scope_id];
 	tbl_scope_cb->index = parms->tbl_scope_id;
 	tbl_scope_cb->tbl_scope_id = parms->tbl_scope_id;
 
@@ -1092,8 +1087,8 @@  tf_em_ext_host_alloc(struct tf *tfp,
 cleanup:
 	/* Free Table control block */
 	fparms.rm_db = eem_db[TF_DIR_RX];
-	fparms.db_index = 1/**** TYPE TABLE-SCOPE??? ****/;
-	fparms.index = parms->tbl_scope_id + TF_HACK_TBL_SCOPE_BASE;
+	fparms.db_index = TF_EEM_DB_TBL_SCOPE;
+	fparms.index = parms->tbl_scope_id;
 	tf_rm_free(&fparms);
 	return -EINVAL;
 }
@@ -1105,13 +1100,9 @@  tf_em_ext_host_free(struct tf *tfp,
 	int rc = 0;
 	enum tf_dir  dir;
 	struct tf_tbl_scope_cb *tbl_scope_cb;
-	struct tf_session *session;
 	struct tf_rm_free_parms aparms = { 0 };
 
-	session = (struct tf_session *)(tfp->session->core_data);
-
-	tbl_scope_cb = tbl_scope_cb_find(session,
-					 parms->tbl_scope_id);
+	tbl_scope_cb = tbl_scope_cb_find(parms->tbl_scope_id);
 
 	if (tbl_scope_cb == NULL) {
 		TFP_DRV_LOG(ERR, "Table scope error\n");
@@ -1120,8 +1111,8 @@  tf_em_ext_host_free(struct tf *tfp,
 
 	/* Free Table control block */
 	aparms.rm_db = eem_db[TF_DIR_RX];
-	aparms.db_index = 1/**** TYPE TABLE-SCOPE??? ****/;
-	aparms.index = parms->tbl_scope_id + TF_HACK_TBL_SCOPE_BASE;
+	aparms.db_index = TF_EEM_DB_TBL_SCOPE;
+	aparms.index = parms->tbl_scope_id;
 	rc = tf_rm_free(&aparms);
 	if (rc) {
 		TFP_DRV_LOG(ERR,
@@ -1142,5 +1133,6 @@  tf_em_ext_host_free(struct tf *tfp,
 		tf_em_ctx_unreg(tfp, tbl_scope_cb, dir);
 	}
 
+	tbl_scopes[parms->tbl_scope_id].tbl_scope_id = -1;
 	return rc;
 }
diff --git a/drivers/net/bnxt/tf_core/tf_em_system.c b/drivers/net/bnxt/tf_core/tf_em_system.c
index ee18a0c70..6dd115470 100644
--- a/drivers/net/bnxt/tf_core/tf_em_system.c
+++ b/drivers/net/bnxt/tf_core/tf_em_system.c
@@ -63,14 +63,12 @@  tf_delete_eem_entry(struct tf_tbl_scope_cb *tbl_scope_cb __rte_unused,
  *    -EINVAL - Error
  */
 int
-tf_em_insert_ext_sys_entry(struct tf *tfp,
+tf_em_insert_ext_sys_entry(struct tf *tfp __rte_unused,
 			   struct tf_insert_em_entry_parms *parms)
 {
 	struct tf_tbl_scope_cb *tbl_scope_cb;
 
-	tbl_scope_cb = tbl_scope_cb_find
-		((struct tf_session *)(tfp->session->core_data),
-		parms->tbl_scope_id);
+	tbl_scope_cb = tbl_scope_cb_find(parms->tbl_scope_id);
 	if (tbl_scope_cb == NULL) {
 		TFP_DRV_LOG(ERR, "Invalid tbl_scope_cb\n");
 		return -EINVAL;
@@ -87,14 +85,12 @@  tf_em_insert_ext_sys_entry(struct tf *tfp,
  *    -EINVAL - Error
  */
 int
-tf_em_delete_ext_sys_entry(struct tf *tfp,
+tf_em_delete_ext_sys_entry(struct tf *tfp __rte_unused,
 			   struct tf_delete_em_entry_parms *parms)
 {
 	struct tf_tbl_scope_cb *tbl_scope_cb;
 
-	tbl_scope_cb = tbl_scope_cb_find
-		((struct tf_session *)(tfp->session->core_data),
-		parms->tbl_scope_id);
+	tbl_scope_cb = tbl_scope_cb_find(parms->tbl_scope_id);
 	if (tbl_scope_cb == NULL) {
 		TFP_DRV_LOG(ERR, "Invalid tbl_scope_cb\n");
 		return -EINVAL;
diff --git a/drivers/net/bnxt/tf_core/tf_session.h b/drivers/net/bnxt/tf_core/tf_session.h
index ebee4db8c..a303fde51 100644
--- a/drivers/net/bnxt/tf_core/tf_session.h
+++ b/drivers/net/bnxt/tf_core/tf_session.h
@@ -100,9 +100,6 @@  struct tf_session {
 
 	/** Device handle */
 	struct tf_dev_info dev;
-
-	/** Table scope array */
-	struct tf_tbl_scope_cb tbl_scopes[TF_NUM_TBL_SCOPE];
 };
 
 /**
diff --git a/drivers/net/bnxt/tf_core/tf_tcam.c b/drivers/net/bnxt/tf_core/tf_tcam.c
index d5bb4eec1..b67159a54 100644
--- a/drivers/net/bnxt/tf_core/tf_tcam.c
+++ b/drivers/net/bnxt/tf_core/tf_tcam.c
@@ -287,7 +287,8 @@  tf_tcam_free(struct tf *tfp,
 	rc = tf_msg_tcam_entry_free(tfp, parms);
 	if (rc) {
 		/* Log error */
-		TFP_DRV_LOG(ERR, "%s: %s: Entry %d free failed with err %s",
+		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,
@@ -382,7 +383,8 @@  tf_tcam_set(struct tf *tfp __rte_unused,
 	rc = tf_msg_tcam_entry_set(tfp, parms);
 	if (rc) {
 		/* Log error */
-		TFP_DRV_LOG(ERR, "%s: %s: Entry %d free failed with err %s",
+		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,