[2/3] net/octeontx2: get tm node stats after resource allocated

Message ID 1625676557-2269-2-git-send-email-skoteshwar@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: Jerin Jacob
Headers
Series [1/3] net/octeontx2: handle link status when device stopped |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Satha Koteswara Rao Kottidi July 7, 2021, 4:49 p.m. UTC
  From: Satha Rao <skoteshwar@marvell.com>

We are getting kernel crash while reading tm node stats when tm
hierarchy is not committed. Until hierarchy committed hardware
resources are not allocated for node, this causes mbox timeout.
This patch check for status of HW resources before reading statistics.

Signed-off-by: Satha Rao <skoteshwar@marvell.com>
---
 drivers/net/octeontx2/otx2_tm.c | 6 ++++++
 1 file changed, 6 insertions(+)
  

Patch

diff --git a/drivers/net/octeontx2/otx2_tm.c b/drivers/net/octeontx2/otx2_tm.c
index fdd5669..6aff1f9 100644
--- a/drivers/net/octeontx2/otx2_tm.c
+++ b/drivers/net/octeontx2/otx2_tm.c
@@ -2769,6 +2769,12 @@  int otx2_nix_sq_enable(void *_txq)
 		return -EINVAL;
 	}
 
+	if (!(tm_node->flags & NIX_TM_NODE_HWRES)) {
+		error->type = RTE_TM_ERROR_TYPE_NODE_ID;
+		error->message = "HW resources not allocated";
+		return -EINVAL;
+	}
+
 	/* Stats support only for leaf node or TL1 root */
 	if (nix_tm_is_leaf(dev, tm_node->lvl)) {
 		reg = (((uint64_t)tm_node->id) << 32);