[04/11] common/cnxk: split NIX TM hierarchy enable API

Message ID 20221128095442.3185112-4-ndabilpuram@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: Jerin Jacob
Headers
Series [01/11] common/cnxk: free pending sqe buffers |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Nithin Dabilpuram Nov. 28, 2022, 9:54 a.m. UTC
  From: Satha Rao <skoteshwar@marvell.com>

roc_nix_tm_hierarchy_enable() API will do two things internally,
1) Creation of all TM nodes, allocate HW resources and connect
   them as requested.
2) Enable transmit by XON SMQ and start SQs

In test cases where both steps called independently. In order
to support this, patch split the functionality into two APIs.

Signed-off-by: Satha Rao <skoteshwar@marvell.com>
---
 drivers/common/cnxk/roc_nix.h        |   2 +
 drivers/common/cnxk/roc_nix_tm_ops.c | 116 +++++++++++++++------------
 drivers/common/cnxk/version.map      |   1 +
 3 files changed, 69 insertions(+), 50 deletions(-)
  

Patch

diff --git a/drivers/common/cnxk/roc_nix.h b/drivers/common/cnxk/roc_nix.h
index dfc87e8758..47ee078c2e 100644
--- a/drivers/common/cnxk/roc_nix.h
+++ b/drivers/common/cnxk/roc_nix.h
@@ -672,6 +672,8 @@  int __roc_api roc_nix_tm_hierarchy_disable(struct roc_nix *roc_nix);
 int __roc_api roc_nix_tm_hierarchy_enable(struct roc_nix *roc_nix,
 					  enum roc_nix_tm_tree tree,
 					  bool xmit_enable);
+int __roc_api roc_nix_tm_hierarchy_xmit_enable(struct roc_nix *roc_nix, enum roc_nix_tm_tree tree);
+
 
 /*
  * TM utilities API.
diff --git a/drivers/common/cnxk/roc_nix_tm_ops.c b/drivers/common/cnxk/roc_nix_tm_ops.c
index 4bf7b1e104..5e8637ebdd 100644
--- a/drivers/common/cnxk/roc_nix_tm_ops.c
+++ b/drivers/common/cnxk/roc_nix_tm_ops.c
@@ -549,6 +549,67 @@  roc_nix_tm_hierarchy_disable(struct roc_nix *roc_nix)
 	return rc;
 }
 
+int
+roc_nix_tm_hierarchy_xmit_enable(struct roc_nix *roc_nix, enum roc_nix_tm_tree tree)
+{
+	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
+	struct nix_tm_node_list *list;
+	struct nix_tm_node *node;
+	struct roc_nix_sq *sq;
+	uint16_t sq_id;
+	int rc;
+
+	if (tree >= ROC_NIX_TM_TREE_MAX)
+		return NIX_ERR_PARAM;
+
+	list = nix_tm_node_list(nix, tree);
+
+	/* Update SQ Sched Data while SQ is idle */
+	TAILQ_FOREACH(node, list, node) {
+		if (!nix_tm_is_leaf(nix, node->lvl))
+			continue;
+
+		rc = nix_tm_sq_sched_conf(nix, node, false);
+		if (rc) {
+			plt_err("SQ %u sched update failed, rc=%d", node->id,
+				rc);
+			return rc;
+		}
+	}
+
+	/* Finally XON all SMQ's */
+	TAILQ_FOREACH(node, list, node) {
+		if (node->hw_lvl != NIX_TXSCH_LVL_SMQ)
+			continue;
+
+		rc = nix_tm_smq_xoff(nix, node, false);
+		if (rc) {
+			plt_err("Failed to enable smq %u, rc=%d", node->hw_id,
+				rc);
+			return rc;
+		}
+	}
+
+	/* Enable xmit as all the topology is ready */
+	TAILQ_FOREACH(node, list, node) {
+		if (!nix_tm_is_leaf(nix, node->lvl))
+			continue;
+
+		sq_id = node->id;
+		sq = nix->sqs[sq_id];
+
+		rc = roc_nix_tm_sq_aura_fc(sq, true);
+		if (rc) {
+			plt_err("TM sw xon failed on SQ %u, rc=%d", node->id,
+				rc);
+			return rc;
+		}
+		node->flags |= NIX_TM_NODE_ENABLED;
+	}
+
+	return 0;
+}
+
 int
 roc_nix_tm_hierarchy_enable(struct roc_nix *roc_nix, enum roc_nix_tm_tree tree,
 			    bool xmit_enable)
@@ -556,9 +617,7 @@  roc_nix_tm_hierarchy_enable(struct roc_nix *roc_nix, enum roc_nix_tm_tree tree,
 	struct nix *nix = roc_nix_to_nix_priv(roc_nix);
 	struct nix_tm_node_list *list;
 	struct nix_tm_node *node;
-	struct roc_nix_sq *sq;
 	uint32_t tree_mask;
-	uint16_t sq_id;
 	int rc;
 
 	if (tree >= ROC_NIX_TM_TREE_MAX)
@@ -613,55 +672,12 @@  roc_nix_tm_hierarchy_enable(struct roc_nix *roc_nix, enum roc_nix_tm_tree tree,
 			node->flags |= NIX_TM_NODE_ENABLED;
 	}
 
-	if (!xmit_enable)
-		goto skip_sq_update;
+	if (xmit_enable)
+		rc = roc_nix_tm_hierarchy_xmit_enable(roc_nix, tree);
 
-	/* Update SQ Sched Data while SQ is idle */
-	TAILQ_FOREACH(node, list, node) {
-		if (!nix_tm_is_leaf(nix, node->lvl))
-			continue;
-
-		rc = nix_tm_sq_sched_conf(nix, node, false);
-		if (rc) {
-			plt_err("SQ %u sched update failed, rc=%d", node->id,
-				rc);
-			return rc;
-		}
-	}
-
-	/* Finally XON all SMQ's */
-	TAILQ_FOREACH(node, list, node) {
-		if (node->hw_lvl != NIX_TXSCH_LVL_SMQ)
-			continue;
-
-		rc = nix_tm_smq_xoff(nix, node, false);
-		if (rc) {
-			plt_err("Failed to enable smq %u, rc=%d", node->hw_id,
-				rc);
-			return rc;
-		}
-	}
-
-	/* Enable xmit as all the topology is ready */
-	TAILQ_FOREACH(node, list, node) {
-		if (!nix_tm_is_leaf(nix, node->lvl))
-			continue;
-
-		sq_id = node->id;
-		sq = nix->sqs[sq_id];
-
-		rc = roc_nix_tm_sq_aura_fc(sq, true);
-		if (rc) {
-			plt_err("TM sw xon failed on SQ %u, rc=%d", node->id,
-				rc);
-			return rc;
-		}
-		node->flags |= NIX_TM_NODE_ENABLED;
-	}
-
-skip_sq_update:
-	nix->tm_flags |= NIX_TM_HIERARCHY_ENA;
-	return 0;
+	if (!rc)
+		nix->tm_flags |= NIX_TM_HIERARCHY_ENA;
+	return rc;
 }
 
 int
diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map
index 70503c0470..63fe9deb72 100644
--- a/drivers/common/cnxk/version.map
+++ b/drivers/common/cnxk/version.map
@@ -270,6 +270,7 @@  INTERNAL {
 	roc_nix_tm_tree_type_get;
 	roc_nix_tm_hierarchy_disable;
 	roc_nix_tm_hierarchy_enable;
+	roc_nix_tm_hierarchy_xmit_enable;
 	roc_nix_tm_init;
 	roc_nix_tm_is_user_hierarchy_enabled;
 	roc_nix_tm_leaf_cnt;