net/octeontx2: fix TM node statistics query
authorSatha Rao <skoteshwar@marvell.com>
Wed, 7 Jul 2021 16:49:16 +0000 (12:49 -0400)
committerJerin Jacob <jerinj@marvell.com>
Tue, 13 Jul 2021 09:29:11 +0000 (11:29 +0200)
Until hierarchy committed TM hardware resources are not allocated
for node.
This patch check for status of HW resources before reading statistics.

Fixes: 1e25d57fae38 ("net/octeontx2: add TM stats and shaper profile")
Cc: stable@dpdk.org
Signed-off-by: Satha Rao <skoteshwar@marvell.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
drivers/net/octeontx2/otx2_tm.c

index fdd5669..6aff1f9 100644 (file)
@@ -2769,6 +2769,12 @@ otx2_nix_tm_node_stats_read(struct rte_eth_dev *eth_dev, uint32_t node_id,
                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);