]> git.droids-corp.org - dpdk.git/commitdiff
common/cnxk: check SQ node before setting BP config
authorSatha Rao <skoteshwar@marvell.com>
Fri, 25 Feb 2022 04:59:26 +0000 (23:59 -0500)
committerJerin Jacob <jerinj@marvell.com>
Fri, 25 Feb 2022 07:47:53 +0000 (08:47 +0100)
Validate sq_node and parent before accessing their fields.
SQ was created without any associated TM node, this is valid negative
case, so return success while stopping TM without SQ node.

Signed-off-by: Satha Rao <skoteshwar@marvell.com>
Acked-by: Jerin Jacob <jerinj@marvell.com>
drivers/common/cnxk/roc_nix_tm.c
drivers/common/cnxk/roc_nix_tm_ops.c

index 5b23ecd4140817716b42377b6a8a85d32a120758..7a1778005893f20a890d318d7af4dc783f8fb9ee 100644 (file)
@@ -325,14 +325,17 @@ nix_tm_bp_config_set(struct roc_nix *roc_nix, uint16_t sq, uint16_t tc,
        struct mbox *mbox = (&nix->dev)->mbox;
        struct nix_txschq_config *req = NULL;
        struct nix_tm_node_list *list;
+       uint16_t link = nix->tx_link;
        struct nix_tm_node *sq_node;
        struct nix_tm_node *parent;
        struct nix_tm_node *node;
        uint8_t k = 0;
-       uint16_t link;
        int rc = 0;
 
        sq_node = nix_tm_node_search(nix, sq, nix->tm_tree);
+       if (!sq_node)
+               return -ENOENT;
+
        parent = sq_node->parent;
        while (parent) {
                if (parent->lvl == ROC_TM_LVL_SCH2)
@@ -340,9 +343,10 @@ nix_tm_bp_config_set(struct roc_nix *roc_nix, uint16_t sq, uint16_t tc,
 
                parent = parent->parent;
        }
+       if (!parent)
+               return -ENOENT;
 
        list = nix_tm_node_list(nix, tree);
-       link = nix->tx_link;
 
        if (parent->rel_chan != NIX_TM_CHAN_INVALID && parent->rel_chan != tc) {
                rc = -EINVAL;
index 5a25b3e9b0358c079c290692743ac38eed4c6fa6..1d9a02bc06bfac4032a9c306f84b0366ec73ce73 100644 (file)
@@ -474,7 +474,7 @@ roc_nix_tm_hierarchy_disable(struct roc_nix *roc_nix)
                        continue;
 
                rc = nix_tm_bp_config_set(roc_nix, sq->qid, 0, false);
-               if (rc) {
+               if (rc && rc != -ENOENT) {
                        plt_err("Failed to disable backpressure, rc=%d", rc);
                        goto cleanup;
                }