diff mbox series

[v2,17/58] net/bnxt: modify resource reservation strategy

Message ID 20210613000652.28191-18-ajit.khaparde@broadcom.com (mailing list archive)
State Accepted
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

Ajit Khaparde June 13, 2021, 12:06 a.m. UTC
From: Jay Ding <jay.ding@broadcom.com>

Allow an application to only reserve resources for one direction.

Signed-off-by: Jay Ding <jay.ding@broadcom.com>
Signed-off-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        |  4 --
 drivers/net/bnxt/tf_core/tf_em_common.c   | 61 +++++++++++------------
 drivers/net/bnxt/tf_core/tf_em_internal.c | 13 +++--
 drivers/net/bnxt/tf_core/tf_identifier.c  | 15 +++---
 drivers/net/bnxt/tf_core/tf_tbl.c         | 12 +++--
 drivers/net/bnxt/tf_core/tf_tcam.c        | 14 ++++--
 6 files changed, 65 insertions(+), 54 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/bnxt/tf_core/tf_core.c b/drivers/net/bnxt/tf_core/tf_core.c
index 945e54bfdd..de2a93646f 100644
--- a/drivers/net/bnxt/tf_core/tf_core.c
+++ b/drivers/net/bnxt/tf_core/tf_core.c
@@ -1636,7 +1636,6 @@  int tf_get_session_info(struct tf *tfp,
 		TFP_DRV_LOG(ERR,
 			    "Ident get resc info failed, rc:%s\n",
 			    strerror(-rc));
-		return rc;
 	}
 
 	if (dev->ops->tf_dev_get_tbl_resc_info == NULL) {
@@ -1652,7 +1651,6 @@  int tf_get_session_info(struct tf *tfp,
 		TFP_DRV_LOG(ERR,
 			    "Tbl get resc info failed, rc:%s\n",
 			    strerror(-rc));
-		return rc;
 	}
 
 	if (dev->ops->tf_dev_get_tcam_resc_info == NULL) {
@@ -1668,7 +1666,6 @@  int tf_get_session_info(struct tf *tfp,
 		TFP_DRV_LOG(ERR,
 			    "TCAM get resc info failed, rc:%s\n",
 			    strerror(-rc));
-		return rc;
 	}
 
 	if (dev->ops->tf_dev_get_em_resc_info == NULL) {
@@ -1684,7 +1681,6 @@  int tf_get_session_info(struct tf *tfp,
 		TFP_DRV_LOG(ERR,
 			    "EM get resc info failed, rc:%s\n",
 			    strerror(-rc));
-		return rc;
 	}
 
 	return 0;
diff --git a/drivers/net/bnxt/tf_core/tf_em_common.c b/drivers/net/bnxt/tf_core/tf_em_common.c
index ed8f6db58c..812ccb0d29 100644
--- a/drivers/net/bnxt/tf_core/tf_em_common.c
+++ b/drivers/net/bnxt/tf_core/tf_em_common.c
@@ -301,6 +301,7 @@  tf_em_page_tbl_pgcnt(uint32_t num_pages,
 {
 	return roundup(num_pages, MAX_PAGE_PTRS(page_size)) /
 		       MAX_PAGE_PTRS(page_size);
+	return 0;
 }
 
 /**
@@ -722,10 +723,6 @@  tf_insert_eem_entry(struct tf_dev_info *dev,
 	if (!mask)
 		return -EINVAL;
 
-#ifdef TF_EEM_DEBUG
-	dump_raw((uint8_t *)parms->key, TF_P4_HW_EM_KEY_MAX_SIZE + 4, "In Key");
-#endif
-
 	if (dev->ops->tf_dev_cfa_key_hash == NULL)
 		return -EINVAL;
 
@@ -737,10 +734,6 @@  tf_insert_eem_entry(struct tf_dev_info *dev,
 	key0_index = key0_hash & mask;
 	key1_index = key1_hash & mask;
 
-#ifdef TF_EEM_DEBUG
-	TFP_DRV_LOG(DEBUG, "Key0 hash:0x%08x\n", key0_hash);
-	TFP_DRV_LOG(DEBUG, "Key1 hash:0x%08x\n", key1_hash);
-#endif
 	/*
 	 * Use the "result" arg to populate all of the key entry then
 	 * store the byte swapped "raw" entry in a local copy ready
@@ -1010,35 +1003,41 @@  tf_em_ext_common_unbind(struct tf *tfp)
 	}
 	ext_db = (struct em_ext_db *)ext_ptr;
 
-	entry = ext_db->tbl_scope_ll.head;
-	while (entry != NULL) {
-		tbl_scope_cb = (struct tf_tbl_scope_cb *)entry;
-		entry = entry->next;
-		tparms.tbl_scope_id = tbl_scope_cb->tbl_scope_id;
-
-		if (dev->ops->tf_dev_free_tbl_scope) {
-			dev->ops->tf_dev_free_tbl_scope(tfp, &tparms);
-		} else {
-			/* should not reach here */
-			ll_delete(&ext_db->tbl_scope_ll, &tbl_scope_cb->ll_entry);
-			tfp_free(tbl_scope_cb);
+	if (ext_db != NULL) {
+		entry = ext_db->tbl_scope_ll.head;
+		while (entry != NULL) {
+			tbl_scope_cb = (struct tf_tbl_scope_cb *)entry;
+			entry = entry->next;
+			tparms.tbl_scope_id =
+				tbl_scope_cb->tbl_scope_id;
+
+			if (dev->ops->tf_dev_free_tbl_scope) {
+				dev->ops->tf_dev_free_tbl_scope(tfp,
+								&tparms);
+			} else {
+				/* should not reach here */
+				ll_delete(&ext_db->tbl_scope_ll,
+					  &tbl_scope_cb->ll_entry);
+				tfp_free(tbl_scope_cb);
+			}
 		}
-	}
 
-	for (i = 0; i < TF_DIR_MAX; i++) {
-		if (ext_db->eem_db[i] == NULL)
-			continue;
+		for (i = 0; i < TF_DIR_MAX; i++) {
+			if (ext_db->eem_db[i] == NULL)
+				continue;
 
-		fparms.dir = i;
-		fparms.rm_db = ext_db->eem_db[i];
-		rc = tf_rm_free_db(tfp, &fparms);
-		if (rc)
-			return rc;
+			fparms.dir = i;
+			fparms.rm_db = ext_db->eem_db[i];
+			rc = tf_rm_free_db(tfp, &fparms);
+			if (rc)
+				return rc;
 
-		ext_db->eem_db[i] = NULL;
+			ext_db->eem_db[i] = NULL;
+		}
+
+		tfp_free(ext_db);
 	}
 
-	tfp_free(ext_db);
 	tf_session_set_em_ext_db(tfp, NULL);
 
 	return 0;
diff --git a/drivers/net/bnxt/tf_core/tf_em_internal.c b/drivers/net/bnxt/tf_core/tf_em_internal.c
index 3b1e4e385d..93de513989 100644
--- a/drivers/net/bnxt/tf_core/tf_em_internal.c
+++ b/drivers/net/bnxt/tf_core/tf_em_internal.c
@@ -349,6 +349,7 @@  tf_em_int_bind(struct tf *tfp,
 	       struct tf_em_cfg_parms *parms)
 {
 	int rc;
+	int db_rc[TF_DIR_MAX] = { 0 };
 	int i;
 	struct tf_rm_create_db_parms db_cfg = { 0 };
 	struct tf_rm_get_alloc_info_parms iparms;
@@ -408,18 +409,22 @@  tf_em_int_bind(struct tf *tfp,
 		db_cfg.rm_db = (void *)&em_db->em_db[i];
 		if (tf_session_is_shared_session(tfs) &&
 			(!tf_session_is_shared_session_creator(tfs)))
-			rc = tf_rm_create_db_no_reservation(tfp, &db_cfg);
+			db_rc[i] = tf_rm_create_db_no_reservation(tfp, &db_cfg);
 		else
-			rc = tf_rm_create_db(tfp, &db_cfg);
-		if (rc) {
+			db_rc[i] = tf_rm_create_db(tfp, &db_cfg);
+		if (db_rc[i]) {
 			TFP_DRV_LOG(ERR,
 				    "%s: EM Int DB creation failed\n",
 				    tf_dir_2_str(i));
 
-			return rc;
 		}
 	}
 
+	/* No db created */
+	if (db_rc[TF_DIR_RX] && db_rc[TF_DIR_TX])
+		return db_rc[TF_DIR_RX];
+
+
 	if (!tf_session_is_shared_session(tfs)) {
 		for (i = 0; i < TF_DIR_MAX; i++) {
 			iparms.rm_db = em_db->em_db[i];
diff --git a/drivers/net/bnxt/tf_core/tf_identifier.c b/drivers/net/bnxt/tf_core/tf_identifier.c
index ebb975562d..3cc87de4ef 100644
--- a/drivers/net/bnxt/tf_core/tf_identifier.c
+++ b/drivers/net/bnxt/tf_core/tf_identifier.c
@@ -30,6 +30,7 @@  tf_ident_bind(struct tf *tfp,
 	      struct tf_ident_cfg_parms *parms)
 {
 	int rc;
+	int db_rc[TF_DIR_MAX] = { 0 };
 	int i;
 	struct tf_rm_create_db_parms db_cfg = { 0 };
 	struct tf_shadow_ident_cfg_parms shadow_cfg = { 0 };
@@ -70,15 +71,13 @@  tf_ident_bind(struct tf *tfp,
 		db_cfg.alloc_cnt = parms->resources->ident_cnt[i].cnt;
 		if (tf_session_is_shared_session(tfs) &&
 			(!tf_session_is_shared_session_creator(tfs)))
-			rc = tf_rm_create_db_no_reservation(tfp, &db_cfg);
+			db_rc[i] = tf_rm_create_db_no_reservation(tfp, &db_cfg);
 		else
-			rc = tf_rm_create_db(tfp, &db_cfg);
-		if (rc) {
-			TFP_DRV_LOG(ERR,
+			db_rc[i] = tf_rm_create_db(tfp, &db_cfg);
+		if (db_rc[i]) {
+			TFP_DRV_LOG(INFO,
 				    "%s: Identifier DB creation failed\n",
 				    tf_dir_2_str(i));
-
-			return rc;
 		}
 
 		if (parms->shadow_copy) {
@@ -99,6 +98,10 @@  tf_ident_bind(struct tf *tfp,
 		}
 	}
 
+	/* No db created */
+	if (db_rc[TF_DIR_RX] && db_rc[TF_DIR_TX])
+		return db_rc[TF_DIR_RX];
+
 	TFP_DRV_LOG(INFO,
 		    "Identifier - initialized\n");
 
diff --git a/drivers/net/bnxt/tf_core/tf_tbl.c b/drivers/net/bnxt/tf_core/tf_tbl.c
index ca1aef8ebf..192115183b 100644
--- a/drivers/net/bnxt/tf_core/tf_tbl.c
+++ b/drivers/net/bnxt/tf_core/tf_tbl.c
@@ -41,6 +41,7 @@  tf_tbl_bind(struct tf *tfp,
 	    struct tf_tbl_cfg_parms *parms)
 {
 	int rc, d, i;
+	int db_rc[TF_DIR_MAX] = { 0 };
 	struct tf_rm_create_db_parms db_cfg = { 0 };
 	struct tbl_rm_db *tbl_db;
 	struct tfp_calloc_parms cparms;
@@ -79,18 +80,21 @@  tf_tbl_bind(struct tf *tfp,
 		db_cfg.rm_db = (void *)&tbl_db->tbl_db[d];
 		if (tf_session_is_shared_session(tfs) &&
 			(!tf_session_is_shared_session_creator(tfs)))
-			rc = tf_rm_create_db_no_reservation(tfp, &db_cfg);
+			db_rc[d] = tf_rm_create_db_no_reservation(tfp, &db_cfg);
 		else
-			rc = tf_rm_create_db(tfp, &db_cfg);
-		if (rc) {
+			db_rc[d] = tf_rm_create_db(tfp, &db_cfg);
+		if (db_rc[d]) {
 			TFP_DRV_LOG(ERR,
 				    "%s: Table DB creation failed\n",
 				    tf_dir_2_str(d));
 
-			return rc;
 		}
 	}
 
+	/* No db created */
+	if (db_rc[TF_DIR_RX] && db_rc[TF_DIR_TX])
+		return db_rc[TF_DIR_RX];
+
 	TFP_DRV_LOG(INFO,
 		    "Table Type - initialized\n");
 
diff --git a/drivers/net/bnxt/tf_core/tf_tcam.c b/drivers/net/bnxt/tf_core/tf_tcam.c
index 0f05af87f1..ce959e3923 100644
--- a/drivers/net/bnxt/tf_core/tf_tcam.c
+++ b/drivers/net/bnxt/tf_core/tf_tcam.c
@@ -33,6 +33,7 @@  tf_tcam_bind(struct tf *tfp,
 	     struct tf_tcam_cfg_parms *parms)
 {
 	int rc;
+	int db_rc[TF_DIR_MAX] = { 0 };
 	int i, d;
 	struct tf_rm_alloc_info info;
 	struct tf_rm_free_db_parms fparms;
@@ -109,17 +110,20 @@  tf_tcam_bind(struct tf *tfp,
 		db_cfg.rm_db = (void *)&tcam_db->tcam_db[d];
 		if (tf_session_is_shared_session(tfs) &&
 			(!tf_session_is_shared_session_creator(tfs)))
-			rc = tf_rm_create_db_no_reservation(tfp, &db_cfg);
+			db_rc[d] = tf_rm_create_db_no_reservation(tfp, &db_cfg);
 		else
-			rc = tf_rm_create_db(tfp, &db_cfg);
-		if (rc) {
-			TFP_DRV_LOG(ERR,
+			db_rc[d] = tf_rm_create_db(tfp, &db_cfg);
+		if (db_rc[d]) {
+			TFP_DRV_LOG(INFO,
 				    "%s: TCAM DB creation failed\n",
 				    tf_dir_2_str(d));
-			return rc;
 		}
 	}
 
+	/* No db created */
+	if (db_rc[TF_DIR_RX] && db_rc[TF_DIR_TX])
+		return db_rc[TF_DIR_RX];
+
 	/* check if reserved resource for WC is multiple of num_slices */
 	for (d = 0; d < TF_DIR_MAX; d++) {
 		memset(&info, 0, sizeof(info));