[dpdk-dev] [PATCH 05/11] net/octeontx2: add tm node suspend and resume cb

Nithin Dabilpuram ndabilpuram at marvell.com
Thu Mar 12 12:19:01 CET 2020


From: Krzysztof Kanas <kkanas at marvell.com>

Add TM support to suspend and resume nodes post hierarchy
commit.

Signed-off-by: Krzysztof Kanas <kkanas at marvell.com>
Signed-off-by: Nithin Dabilpuram <ndabilpuram at marvell.com>
---
 drivers/net/octeontx2/otx2_tm.c | 81 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)

diff --git a/drivers/net/octeontx2/otx2_tm.c b/drivers/net/octeontx2/otx2_tm.c
index 579265c..175d1d5 100644
--- a/drivers/net/octeontx2/otx2_tm.c
+++ b/drivers/net/octeontx2/otx2_tm.c
@@ -1534,6 +1534,28 @@ nix_tm_alloc_resources(struct rte_eth_dev *eth_dev, bool xmit_enable)
 	return 0;
 }
 
+static int
+send_tm_reqval(struct otx2_mbox *mbox,
+	       struct nix_txschq_config *req,
+	       struct rte_tm_error *error)
+{
+	int rc;
+
+	if (!req->num_regs ||
+	    req->num_regs > MAX_REGS_PER_MBOX_MSG) {
+		error->type = RTE_TM_ERROR_TYPE_UNSPECIFIED;
+		error->message = "invalid config";
+		return -EIO;
+	}
+
+	rc = otx2_mbox_process(mbox);
+	if (rc) {
+		error->type = RTE_TM_ERROR_TYPE_UNSPECIFIED;
+		error->message = "unexpected fatal error";
+	}
+	return rc;
+}
+
 static uint16_t
 nix_tm_lvl2nix(struct otx2_eth_dev *dev, uint32_t lvl)
 {
@@ -1800,9 +1822,68 @@ nix_tm_node_delete(struct rte_eth_dev *eth_dev, uint32_t node_id,
 	return 0;
 }
 
+static int
+nix_tm_node_suspend_resume(struct rte_eth_dev *eth_dev, uint32_t node_id,
+			   struct rte_tm_error *error, bool suspend)
+{
+	struct otx2_eth_dev *dev = otx2_eth_pmd_priv(eth_dev);
+	struct otx2_mbox *mbox = dev->mbox;
+	struct otx2_nix_tm_node *tm_node;
+	struct nix_txschq_config *req;
+	uint16_t flags;
+	int rc;
+
+	tm_node = nix_tm_node_search(dev, node_id, true);
+	if (!tm_node) {
+		error->type = RTE_TM_ERROR_TYPE_NODE_ID;
+		error->message = "no such node";
+		return -EINVAL;
+	}
+
+	if (!(dev->tm_flags & NIX_TM_COMMITTED)) {
+		error->type = RTE_TM_ERROR_TYPE_UNSPECIFIED;
+		error->message = "hierarchy doesn't exist";
+		return -EINVAL;
+	}
+
+	flags = tm_node->flags;
+	flags = suspend ? (flags & ~NIX_TM_NODE_ENABLED) :
+		(flags | NIX_TM_NODE_ENABLED);
+
+	if (tm_node->flags == flags)
+		return 0;
+
+	/* send mbox for state change */
+	req = otx2_mbox_alloc_msg_nix_txschq_cfg(mbox);
+
+	req->lvl = tm_node->hw_lvl;
+	req->num_regs =	prepare_tm_sw_xoff(tm_node, suspend,
+					   req->reg, req->regval);
+	rc = send_tm_reqval(mbox, req, error);
+	if (!rc)
+		tm_node->flags = flags;
+	return rc;
+}
+
+static int
+nix_tm_node_suspend(struct rte_eth_dev *eth_dev, uint32_t node_id,
+		    struct rte_tm_error *error)
+{
+	return nix_tm_node_suspend_resume(eth_dev, node_id, error, true);
+}
+
+static int
+nix_tm_node_resume(struct rte_eth_dev *eth_dev, uint32_t node_id,
+		   struct rte_tm_error *error)
+{
+	return nix_tm_node_suspend_resume(eth_dev, node_id, error, false);
+}
+
 const struct rte_tm_ops otx2_tm_ops = {
 	.node_add = nix_tm_node_add,
 	.node_delete = nix_tm_node_delete,
+	.node_suspend = nix_tm_node_suspend,
+	.node_resume = nix_tm_node_resume,
 };
 
 static int
-- 
2.8.4



More information about the dev mailing list