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 70881A0547; Fri, 5 Mar 2021 14:46:29 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7C26122A447; Fri, 5 Mar 2021 14:41:28 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 1D76822A440 for ; Fri, 5 Mar 2021 14:41:25 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 125DelDS001639 for ; Fri, 5 Mar 2021 05:41:25 -0800 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=D7ugJKsMhXgt5zKqzwGjvKJRUsGhr0uusgE7hXyL8wE=; b=LqtPAeIARlDjV2foUpaIGCRFDX4H29U7+WmH1N4CpL6KyvVAJNgOTvfTqx6r2pPMt6Lb jVz8jCgtqiEZxUcNIwIs0s1eAPbmJJ4AKs30JMOHeXwdXM6rzjyVN1UGjjq6MeemGFPT /8QaajCvjhhC1kiCBfQ73uoiRiIsYYrhuT+JbbE5k6Re7mL59QQ9x+2mVoBtEICUVzWq XRFPtIqstC1Xono6JYhVGcHiaUyq2E8V5JWHqBguF1NF3eMUsy40O2Jf6SgDv0eKaF01 u8zGkJDauM0vJxWvL6ioypu9Gx/JxdkYNFHt3xJhRiy6+kTwVzZ+g7uavTwZBbDVxuPQ 9A== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com with ESMTP id 372s2umrr5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Fri, 05 Mar 2021 05:41:25 -0800 Received: from SC-EXCH04.marvell.com (10.93.176.84) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 5 Mar 2021 05:41:24 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 5 Mar 2021 05:41:23 -0800 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; Fri, 5 Mar 2021 05:41:23 -0800 Received: from hyd1588t430.marvell.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id D0E9F3F703F; Fri, 5 Mar 2021 05:41:20 -0800 (PST) From: Nithin Dabilpuram To: CC: , , , , , , , Nithin Dabilpuram Date: Fri, 5 Mar 2021 19:09:04 +0530 Message-ID: <20210305133918.8005-39-ndabilpuram@marvell.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20210305133918.8005-1-ndabilpuram@marvell.com> References: <20210305133918.8005-1-ndabilpuram@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369, 18.0.761 definitions=2021-03-05_08:2021-03-03, 2021-03-05 signatures=0 Subject: [dpdk-dev] [PATCH 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 859995b..84ec09f 100644 --- a/drivers/common/cnxk/roc_nix.h +++ b/drivers/common/cnxk/roc_nix.h @@ -362,6 +362,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 6274f32..b383ef2 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 4d8f092..22955fe 100644 --- a/drivers/common/cnxk/version.map +++ b/drivers/common/cnxk/version.map @@ -114,7 +114,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