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 2AC36A0C45; Sat, 18 Sep 2021 16:32:49 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3A66F41123; Sat, 18 Sep 2021 16:32:35 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 34CA64111B for ; Sat, 18 Sep 2021 16:32:30 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 18IEI6Td031020; Sat, 18 Sep 2021 07:32:27 -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=UtSLQReF8VVieyJtZdM79PJl/i9c50Ii66f+bFmjlis=; b=eCsd0wKKm3a8TXDGqcEQVq3DVmPDsckiufWS5yzAmHe60NGPwcV2r4KGoa4U1XNGQ20l oV+Q8Hp1lCPGdayuG2fQJ2DU6aTso4H5Y5BqiOa17qWFGYgt7hRhmNRn15VfnFlEXXY4 S58h61RETBsgF0u7esL7xRBbM+fFIfnlABRmQVRjwcQ6Fg+WvelJEXeFXfiCePmU11M2 oP64NFCObxGi0e/yocFa4HLydx1qCLTVJPiaH3zELaZl9EZ0+fJLU7AUCZgt3G0YJa3l NggD8ELSlMbHRiFJeJtESkoT8265+qxIDaDd9e4wrMFCqhDxdNaLC+ARFN5wDyHNRBae aQ== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com with ESMTP id 3b5dfp0hph-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sat, 18 Sep 2021 07:32:26 -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.18; Sat, 18 Sep 2021 07:32:25 -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.18 via Frontend Transport; Sat, 18 Sep 2021 07:32:25 -0700 Received: from cavium.marvell.com (unknown [10.28.34.244]) by maili.marvell.com (Postfix) with ESMTP id B1F8A3F7057; Sat, 18 Sep 2021 07:32:23 -0700 (PDT) From: To: Nithin Dabilpuram , Kiran Kumar K , Sunil Kumar Kori , Satha Rao , Ray Kinsella CC: Date: Sat, 18 Sep 2021 10:31:56 -0400 Message-ID: <1631975519-30924-7-git-send-email-skoteshwar@marvell.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1631975519-30924-1-git-send-email-skoteshwar@marvell.com> References: <1630516236-10526-1-git-send-email-skoteshwar@marvell.com> <1631975519-30924-1-git-send-email-skoteshwar@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-ORIG-GUID: z9vxktviJ9nbNARSgUX8jDaIS97UglG0 X-Proofpoint-GUID: z9vxktviJ9nbNARSgUX8jDaIS97UglG0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-09-18_05,2021-09-17_02,2020-04-07_01 Subject: [dpdk-dev] [PATCH v2 6/8] common/cnxk: set of handlers to get tm hierarchy internals 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" From: Satha Rao Platform specific TM tree hierarchy details are part of common cnxk driver. This patch introduces missing HAL apis to return state of TM hierarchy required to support ethdev TM operations inside cnxk PMD. Signed-off-by: Satha Rao --- drivers/common/cnxk/roc_model.h | 6 +++ drivers/common/cnxk/roc_nix.h | 10 ++++ drivers/common/cnxk/roc_nix_priv.h | 1 - drivers/common/cnxk/roc_nix_tm.c | 22 ++++++++- drivers/common/cnxk/roc_nix_tm_ops.c | 11 +---- drivers/common/cnxk/roc_nix_tm_utils.c | 86 ++++++++++++++++++++++++++++++++-- drivers/common/cnxk/version.map | 8 ++++ 7 files changed, 127 insertions(+), 17 deletions(-) diff --git a/drivers/common/cnxk/roc_model.h b/drivers/common/cnxk/roc_model.h index c1d11b7..856a570 100644 --- a/drivers/common/cnxk/roc_model.h +++ b/drivers/common/cnxk/roc_model.h @@ -106,6 +106,12 @@ struct roc_model { } static inline uint64_t +roc_model_is_cn96_cx(void) +{ + return (roc_model->flag & ROC_MODEL_CN96xx_C0); +} + +static inline uint64_t roc_model_is_cn95_a0(void) { return roc_model->flag & ROC_MODEL_CNF95xx_A0; diff --git a/drivers/common/cnxk/roc_nix.h b/drivers/common/cnxk/roc_nix.h index 90dc413..d9a4613 100644 --- a/drivers/common/cnxk/roc_nix.h +++ b/drivers/common/cnxk/roc_nix.h @@ -490,6 +490,16 @@ int __roc_api roc_nix_tm_node_name_get(struct roc_nix *roc_nix, uint32_t node_id, char *buf, size_t buflen); int __roc_api roc_nix_smq_flush(struct roc_nix *roc_nix); +int __roc_api roc_nix_tm_max_prio(struct roc_nix *roc_nix, int lvl); +int __roc_api roc_nix_tm_lvl_is_leaf(struct roc_nix *roc_nix, int lvl); +void __roc_api +roc_nix_tm_shaper_default_red_algo(struct roc_nix_tm_node *node, + struct roc_nix_tm_shaper_profile *profile); +int __roc_api roc_nix_tm_lvl_cnt_get(struct roc_nix *roc_nix); +int __roc_api roc_nix_tm_lvl_have_link_access(struct roc_nix *roc_nix, int lvl); +int __roc_api roc_nix_tm_prepare_rate_limited_tree(struct roc_nix *roc_nix); +bool __roc_api roc_nix_tm_is_user_hierarchy_enabled(struct roc_nix *nix); +int __roc_api roc_nix_tm_tree_type_get(struct roc_nix *nix); /* MAC */ int __roc_api roc_nix_mac_rxtx_start_stop(struct roc_nix *roc_nix, bool start); diff --git a/drivers/common/cnxk/roc_nix_priv.h b/drivers/common/cnxk/roc_nix_priv.h index 3412bf2..b67f648 100644 --- a/drivers/common/cnxk/roc_nix_priv.h +++ b/drivers/common/cnxk/roc_nix_priv.h @@ -350,7 +350,6 @@ int nix_tm_release_resources(struct nix *nix, uint8_t hw_lvl, bool contig, int nix_tm_update_parent_info(struct nix *nix, enum roc_nix_tm_tree tree); int nix_tm_sq_sched_conf(struct nix *nix, struct nix_tm_node *node, bool rr_quantum_only); -int nix_tm_prepare_rate_limited_tree(struct roc_nix *roc_nix); /* * TM priv utils. diff --git a/drivers/common/cnxk/roc_nix_tm.c b/drivers/common/cnxk/roc_nix_tm.c index 947320a..08d6e86 100644 --- a/drivers/common/cnxk/roc_nix_tm.c +++ b/drivers/common/cnxk/roc_nix_tm.c @@ -155,6 +155,20 @@ return 0; } +static int +nix_tm_root_node_get(struct nix *nix, int tree) +{ + struct nix_tm_node_list *list = nix_tm_node_list(nix, tree); + struct nix_tm_node *tm_node; + + TAILQ_FOREACH(tm_node, list, node) { + if (tm_node->hw_lvl == nix->tm_root_lvl) + return 1; + } + + return 0; +} + int nix_tm_node_add(struct roc_nix *roc_nix, struct nix_tm_node *node) { @@ -207,6 +221,10 @@ if (nix_tm_node_search(nix, node_id, tree)) return NIX_ERR_TM_NODE_EXISTS; + /* Check if root node exists */ + if (hw_lvl == nix->tm_root_lvl && nix_tm_root_node_get(nix, tree)) + return NIX_ERR_TM_NODE_EXISTS; + profile = nix_tm_shaper_profile_search(nix, profile_id); if (!nix_tm_is_leaf(nix, lvl)) { /* Check if shaper profile exists for non leaf node */ @@ -1157,7 +1175,7 @@ } int -nix_tm_prepare_rate_limited_tree(struct roc_nix *roc_nix) +roc_nix_tm_prepare_rate_limited_tree(struct roc_nix *roc_nix) { struct nix *nix = roc_nix_to_nix_priv(roc_nix); uint32_t nonleaf_id = nix->nb_tx_queues; @@ -1227,7 +1245,7 @@ goto error; node->id = i; - node->parent_id = parent; + node->parent_id = parent + i; node->priority = 0; node->weight = NIX_TM_DFLT_RR_WT; node->shaper_profile_id = ROC_NIX_TM_SHAPER_PROFILE_NONE; diff --git a/drivers/common/cnxk/roc_nix_tm_ops.c b/drivers/common/cnxk/roc_nix_tm_ops.c index 69d5837..29f276a 100644 --- a/drivers/common/cnxk/roc_nix_tm_ops.c +++ b/drivers/common/cnxk/roc_nix_tm_ops.c @@ -927,13 +927,6 @@ return rc; } - /* Prepare rlimit tree */ - rc = nix_tm_prepare_rate_limited_tree(roc_nix); - if (rc) { - plt_err("failed to prepare rlimit tm tree, rc=%d", rc); - return rc; - } - return rc; } @@ -951,11 +944,11 @@ uint8_t k = 0; int rc; - if (nix->tm_tree != ROC_NIX_TM_RLIMIT || + if ((nix->tm_tree == ROC_NIX_TM_USER) || !(nix->tm_flags & NIX_TM_HIERARCHY_ENA)) return NIX_ERR_TM_INVALID_TREE; - node = nix_tm_node_search(nix, qid, ROC_NIX_TM_RLIMIT); + node = nix_tm_node_search(nix, qid, nix->tm_tree); /* check if we found a valid leaf node */ if (!node || !nix_tm_is_leaf(nix, node->lvl) || !node->parent || diff --git a/drivers/common/cnxk/roc_nix_tm_utils.c b/drivers/common/cnxk/roc_nix_tm_utils.c index 8330624..a135454 100644 --- a/drivers/common/cnxk/roc_nix_tm_utils.c +++ b/drivers/common/cnxk/roc_nix_tm_utils.c @@ -235,6 +235,9 @@ struct nix_tm_node * struct nix_tm_shaper_data *cir, struct nix_tm_shaper_data *pir) { + memset(cir, 0, sizeof(*cir)); + memset(pir, 0, sizeof(*pir)); + if (!profile) return; @@ -624,8 +627,6 @@ struct nix_tm_node * uint64_t adjust = 0; uint8_t k = 0; - memset(&cir, 0, sizeof(cir)); - memset(&pir, 0, sizeof(pir)); nix_tm_shaper_conf_get(profile, &cir, &pir); if (profile && node->pkt_mode) @@ -1043,15 +1044,16 @@ struct nix_tm_shaper_profile * if (node->hw_lvl != NIX_TXSCH_LVL_TL1) return NIX_ERR_OP_NOTSUP; + /* Check if node has HW resource */ + if (!(node->flags & NIX_TM_NODE_HWRES)) + return 0; + schq = node->hw_id; /* Skip fetch if not requested */ if (!n_stats) goto clear_stats; memset(n_stats, 0, sizeof(struct roc_nix_tm_node_stats)); - /* Check if node has HW resource */ - if (!(node->flags & NIX_TM_NODE_HWRES)) - return 0; req = mbox_alloc_msg_nix_txschq_cfg(mbox); req->read = 1; @@ -1102,3 +1104,77 @@ struct nix_tm_shaper_profile * return mbox_process_msg(mbox, (void **)&rsp); } + +bool +roc_nix_tm_is_user_hierarchy_enabled(struct roc_nix *roc_nix) +{ + struct nix *nix = roc_nix_to_nix_priv(roc_nix); + + if ((nix->tm_flags & NIX_TM_HIERARCHY_ENA) && + (nix->tm_tree == ROC_NIX_TM_USER)) + return true; + return false; +} + +int +roc_nix_tm_tree_type_get(struct roc_nix *roc_nix) +{ + struct nix *nix = roc_nix_to_nix_priv(roc_nix); + + return nix->tm_tree; +} + +int +roc_nix_tm_max_prio(struct roc_nix *roc_nix, int lvl) +{ + struct nix *nix = roc_nix_to_nix_priv(roc_nix); + int hw_lvl = nix_tm_lvl2nix(nix, lvl); + + return nix_tm_max_prio(nix, hw_lvl); +} + +int +roc_nix_tm_lvl_is_leaf(struct roc_nix *roc_nix, int lvl) +{ + return nix_tm_is_leaf(roc_nix_to_nix_priv(roc_nix), lvl); +} + +void +roc_nix_tm_shaper_default_red_algo(struct roc_nix_tm_node *node, + struct roc_nix_tm_shaper_profile *roc_prof) +{ + struct nix_tm_node *tm_node = (struct nix_tm_node *)node; + struct nix_tm_shaper_profile *profile; + struct nix_tm_shaper_data cir, pir; + + profile = (struct nix_tm_shaper_profile *)roc_prof->reserved; + tm_node->red_algo = NIX_REDALG_STD; + + /* C0 doesn't support STALL when both PIR & CIR are enabled */ + if (profile && roc_model_is_cn96_cx()) { + nix_tm_shaper_conf_get(profile, &cir, &pir); + + if (pir.rate && cir.rate) + tm_node->red_algo = NIX_REDALG_DISCARD; + } +} + +int +roc_nix_tm_lvl_cnt_get(struct roc_nix *roc_nix) +{ + if (nix_tm_have_tl1_access(roc_nix_to_nix_priv(roc_nix))) + return NIX_TXSCH_LVL_CNT; + + return (NIX_TXSCH_LVL_CNT - 1); +} + +int +roc_nix_tm_lvl_have_link_access(struct roc_nix *roc_nix, int lvl) +{ + struct nix *nix = roc_nix_to_nix_priv(roc_nix); + + if (nix_tm_lvl2nix(nix, lvl) == NIX_TXSCH_LVL_TL1) + return 1; + + return 0; +} diff --git a/drivers/common/cnxk/version.map b/drivers/common/cnxk/version.map index 776cabb..9b7cbf6 100644 --- a/drivers/common/cnxk/version.map +++ b/drivers/common/cnxk/version.map @@ -175,10 +175,16 @@ INTERNAL { roc_nix_tm_err_to_rte_err; roc_nix_tm_fini; roc_nix_tm_free_resources; + roc_nix_tm_lvl_cnt_get; + roc_nix_tm_tree_type_get; roc_nix_tm_hierarchy_disable; roc_nix_tm_hierarchy_enable; roc_nix_tm_init; + roc_nix_tm_is_user_hierarchy_enabled; roc_nix_tm_leaf_cnt; + roc_nix_tm_lvl_have_link_access; + roc_nix_tm_lvl_is_leaf; + roc_nix_tm_max_prio; roc_nix_tm_node_add; roc_nix_tm_node_delete; roc_nix_tm_node_get; @@ -191,10 +197,12 @@ INTERNAL { roc_nix_tm_node_stats_get; roc_nix_tm_node_suspend_resume; roc_nix_tm_prealloc_res; + roc_nix_tm_prepare_rate_limited_tree; roc_nix_tm_rlimit_sq; roc_nix_tm_root_has_sp; roc_nix_tm_rsrc_count; roc_nix_tm_rsrc_max; + roc_nix_tm_shaper_default_red_algo; roc_nix_tm_shaper_profile_add; roc_nix_tm_shaper_profile_delete; roc_nix_tm_shaper_profile_get; -- 1.8.3.1