From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BC622A0548; Thu, 1 Apr 2021 14:44:24 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E3608141256; Thu, 1 Apr 2021 14:40:33 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id A40341411B5 for ; Thu, 1 Apr 2021 14:40:32 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 131CPLcj019084 for ; Thu, 1 Apr 2021 05:40:31 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=lbb08LKIH4sX7uIAB+IflFjHKrapbB9stcbF1hjmCu8=; b=SmTtl0Pa7Px71qyXLTk4YyGXHMkmr2s146QWQYx8ZtPJmF0GIzJ99LlgDkz+n3jxAE9p 4XLG3qYoLxDPbiGfVquizVjRPPYRMaWoOfTaFIVuSBSPKOHki0u317jiUi+mlO1ECCq8 CDpg2h/5Nn57xXQD+GsB24+Yl/zGgKmrMDz6ybzHDU3KCyro5kVn0SFpfvRF8+f5fzQd pO8cSiWMMDUpm0WQ8SQl6yJ/AMwhWdT5odl67UryDYig5YpaImqlbU+o+eyq/0FzZnqm CyXKD1w9xBfzGzK/8YoZN/8XxdiXc+nqE6MtPonyzYvOBTPucC9zvuRu/PNyId6yikfO AA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com with ESMTP id 37n28jje55-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Thu, 01 Apr 2021 05:40:31 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 1 Apr 2021 05:40:29 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 1 Apr 2021 05:40:29 -0700 Received: from hyd1588t430.marvell.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id 1A0E23F7041; Thu, 1 Apr 2021 05:40:26 -0700 (PDT) From: Nithin Dabilpuram To: CC: , , , , , , , Nithin Dabilpuram Date: Thu, 1 Apr 2021 18:08:03 +0530 Message-ID: <20210401123817.14348-39-ndabilpuram@marvell.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20210401123817.14348-1-ndabilpuram@marvell.com> References: <20210305133918.8005-1-ndabilpuram@marvell.com> <20210401123817.14348-1-ndabilpuram@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-GUID: xHBcke7MZ1QIWRf_A2x7vR4HH9Q4Kf4w X-Proofpoint-ORIG-GUID: xHBcke7MZ1QIWRf_A2x7vR4HH9Q4Kf4w X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369, 18.0.761 definitions=2021-04-01_05:2021-03-31, 2021-04-01 signatures=0 Subject: [dpdk-dev] [PATCH v3 38/52] common/cnxk: add nix tm dynamic update support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add support for dynamic node update of shaper profile, RR quantum and also support to suspend or resume an active TM node. Signed-off-by: Nithin Dabilpuram --- drivers/common/cnxk/roc_nix.h | 10 ++ drivers/common/cnxk/roc_nix_tm_ops.c | 220 +++++++++++++++++++++++++++++++++++ drivers/common/cnxk/version.map | 3 + 3 files changed, 233 insertions(+) diff --git a/drivers/common/cnxk/roc_nix.h b/drivers/common/cnxk/roc_nix.h index 8992ad3..ad00efe 100644 --- a/drivers/common/cnxk/roc_nix.h +++ b/drivers/common/cnxk/roc_nix.h @@ -375,6 +375,16 @@ int __roc_api roc_nix_tm_node_add(struct roc_nix *roc_nix, int __roc_api roc_nix_tm_node_delete(struct roc_nix *roc_nix, uint32_t node_id, bool free); int __roc_api roc_nix_tm_free_resources(struct roc_nix *roc_nix, bool hw_only); +int __roc_api roc_nix_tm_node_suspend_resume(struct roc_nix *roc_nix, + uint32_t node_id, bool suspend); +int __roc_api roc_nix_tm_node_parent_update(struct roc_nix *roc_nix, + uint32_t node_id, + uint32_t new_parent_id, + uint32_t priority, uint32_t weight); +int __roc_api roc_nix_tm_node_shaper_update(struct roc_nix *roc_nix, + uint32_t node_id, + uint32_t profile_id, + bool force_update); int __roc_api roc_nix_tm_node_pkt_mode_update(struct roc_nix *roc_nix, uint32_t node_id, bool pkt_mode); int __roc_api roc_nix_tm_shaper_profile_add( diff --git a/drivers/common/cnxk/roc_nix_tm_ops.c b/drivers/common/cnxk/roc_nix_tm_ops.c index d13cc8a..e4463d1 100644 --- a/drivers/common/cnxk/roc_nix_tm_ops.c +++ b/drivers/common/cnxk/roc_nix_tm_ops.c @@ -545,6 +545,226 @@ roc_nix_tm_hierarchy_enable(struct roc_nix *roc_nix, enum roc_nix_tm_tree tree, } int +roc_nix_tm_node_suspend_resume(struct roc_nix *roc_nix, uint32_t node_id, + bool suspend) +{ + struct nix *nix = roc_nix_to_nix_priv(roc_nix); + struct mbox *mbox = (&nix->dev)->mbox; + struct nix_txschq_config *req; + struct nix_tm_node *node; + uint16_t flags; + int rc; + + node = nix_tm_node_search(nix, node_id, ROC_NIX_TM_USER); + if (!node) + return NIX_ERR_TM_INVALID_NODE; + + flags = node->flags; + flags = suspend ? (flags & ~NIX_TM_NODE_ENABLED) : + (flags | NIX_TM_NODE_ENABLED); + + if (node->flags == flags) + return 0; + + /* send mbox for state change */ + req = mbox_alloc_msg_nix_txschq_cfg(mbox); + + req->lvl = node->hw_lvl; + req->num_regs = + nix_tm_sw_xoff_prep(node, suspend, req->reg, req->regval); + rc = mbox_process(mbox); + if (!rc) + node->flags = flags; + return rc; +} + +int +roc_nix_tm_node_shaper_update(struct roc_nix *roc_nix, uint32_t node_id, + uint32_t profile_id, bool force_update) +{ + struct nix *nix = roc_nix_to_nix_priv(roc_nix); + struct nix_tm_shaper_profile *profile = NULL; + struct mbox *mbox = (&nix->dev)->mbox; + struct nix_txschq_config *req; + struct nix_tm_node *node; + uint8_t k; + int rc; + + /* Shaper updates valid only for user nodes */ + node = nix_tm_node_search(nix, node_id, ROC_NIX_TM_USER); + if (!node || nix_tm_is_leaf(nix, node->lvl)) + return NIX_ERR_TM_INVALID_NODE; + + if (profile_id != ROC_NIX_TM_SHAPER_PROFILE_NONE) { + profile = nix_tm_shaper_profile_search(nix, profile_id); + if (!profile) + return NIX_ERR_TM_INVALID_SHAPER_PROFILE; + } + + /* Pkt mode should match existing node's pkt mode */ + if (profile && profile->pkt_mode != node->pkt_mode) + return NIX_ERR_TM_PKT_MODE_MISMATCH; + + if ((profile_id == node->shaper_profile_id) && !force_update) { + return 0; + } else if (profile_id != node->shaper_profile_id) { + struct nix_tm_shaper_profile *old; + + /* Find old shaper profile and reduce ref count */ + old = nix_tm_shaper_profile_search(nix, + node->shaper_profile_id); + if (old) + old->ref_cnt--; + + if (profile) + profile->ref_cnt++; + + /* Reduce older shaper ref count and increase new one */ + node->shaper_profile_id = profile_id; + } + + /* Nothing to do if hierarchy not yet enabled */ + if (!(nix->tm_flags & NIX_TM_HIERARCHY_ENA)) + return 0; + + node->flags &= ~NIX_TM_NODE_ENABLED; + + /* Flush the specific node with SW_XOFF */ + req = mbox_alloc_msg_nix_txschq_cfg(mbox); + req->lvl = node->hw_lvl; + k = nix_tm_sw_xoff_prep(node, true, req->reg, req->regval); + req->num_regs = k; + + rc = mbox_process(mbox); + if (rc) + return rc; + + /* Update the PIR/CIR and clear SW XOFF */ + req = mbox_alloc_msg_nix_txschq_cfg(mbox); + req->lvl = node->hw_lvl; + + k = nix_tm_shaper_reg_prep(node, profile, req->reg, req->regval); + + k += nix_tm_sw_xoff_prep(node, false, &req->reg[k], &req->regval[k]); + + req->num_regs = k; + rc = mbox_process(mbox); + if (!rc) + node->flags |= NIX_TM_NODE_ENABLED; + return rc; +} + +int +roc_nix_tm_node_parent_update(struct roc_nix *roc_nix, uint32_t node_id, + uint32_t new_parent_id, uint32_t priority, + uint32_t weight) +{ + struct nix *nix = roc_nix_to_nix_priv(roc_nix); + struct mbox *mbox = (&nix->dev)->mbox; + struct nix_tm_node *node, *sibling; + struct nix_tm_node *new_parent; + struct nix_txschq_config *req; + struct nix_tm_node_list *list; + uint8_t k; + int rc; + + node = nix_tm_node_search(nix, node_id, ROC_NIX_TM_USER); + if (!node) + return NIX_ERR_TM_INVALID_NODE; + + /* Parent id valid only for non root nodes */ + if (node->hw_lvl != nix->tm_root_lvl) { + new_parent = + nix_tm_node_search(nix, new_parent_id, ROC_NIX_TM_USER); + if (!new_parent) + return NIX_ERR_TM_INVALID_PARENT; + + /* Current support is only for dynamic weight update */ + if (node->parent != new_parent || node->priority != priority) + return NIX_ERR_TM_PARENT_PRIO_UPDATE; + } + + list = nix_tm_node_list(nix, ROC_NIX_TM_USER); + /* Skip if no change */ + if (node->weight == weight) + return 0; + + node->weight = weight; + + /* Nothing to do if hierarchy not yet enabled */ + if (!(nix->tm_flags & NIX_TM_HIERARCHY_ENA)) + return 0; + + /* For leaf nodes, SQ CTX needs update */ + if (nix_tm_is_leaf(nix, node->lvl)) { + /* Update SQ quantum data on the fly */ + rc = nix_tm_sq_sched_conf(nix, node, true); + if (rc) + return NIX_ERR_TM_SQ_UPDATE_FAIL; + } else { + /* XOFF Parent node */ + req = mbox_alloc_msg_nix_txschq_cfg(mbox); + req->lvl = node->parent->hw_lvl; + req->num_regs = nix_tm_sw_xoff_prep(node->parent, true, + req->reg, req->regval); + rc = mbox_process(mbox); + if (rc) + return rc; + + /* XOFF this node and all other siblings */ + req = mbox_alloc_msg_nix_txschq_cfg(mbox); + req->lvl = node->hw_lvl; + + k = 0; + TAILQ_FOREACH(sibling, list, node) { + if (sibling->parent != node->parent) + continue; + k += nix_tm_sw_xoff_prep(sibling, true, &req->reg[k], + &req->regval[k]); + } + req->num_regs = k; + rc = mbox_process(mbox); + if (rc) + return rc; + + /* Update new weight for current node */ + req = mbox_alloc_msg_nix_txschq_cfg(mbox); + req->lvl = node->hw_lvl; + req->num_regs = + nix_tm_sched_reg_prep(nix, node, req->reg, req->regval); + rc = mbox_process(mbox); + if (rc) + return rc; + + /* XON this node and all other siblings */ + req = mbox_alloc_msg_nix_txschq_cfg(mbox); + req->lvl = node->hw_lvl; + + k = 0; + TAILQ_FOREACH(sibling, list, node) { + if (sibling->parent != node->parent) + continue; + k += nix_tm_sw_xoff_prep(sibling, false, &req->reg[k], + &req->regval[k]); + } + req->num_regs = k; + rc = mbox_process(mbox); + if (rc) + return rc; + + /* XON Parent node */ + req = mbox_alloc_msg_nix_txschq_cfg(mbox); + req->lvl = node->parent->hw_lvl; + req->num_regs = nix_tm_sw_xoff_prep(node->parent, false, + req->reg, req->regval); + rc = mbox_process(mbox); + if (rc) + return rc; + } + return 0; +} + +int roc_nix_tm_init(struct roc_nix *roc_nix) { struct nix *nix = roc_nix_to_nix_priv(roc_nix); diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map index 854c3c1..a5efbea 100644 --- a/drivers/common/cnxk/version.map +++ b/drivers/common/cnxk/version.map @@ -115,7 +115,10 @@ INTERNAL { roc_nix_tm_node_lvl; roc_nix_tm_node_name_get; roc_nix_tm_node_next; + roc_nix_tm_node_parent_update; roc_nix_tm_node_pkt_mode_update; + roc_nix_tm_node_shaper_update; + roc_nix_tm_node_suspend_resume; roc_nix_tm_rlimit_sq; roc_nix_tm_shaper_profile_add; roc_nix_tm_shaper_profile_delete; -- 2.8.4