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 7F01DA00BE; Fri, 11 Feb 2022 05:50:11 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 60C9942715; Fri, 11 Feb 2022 05:49:47 +0100 (CET) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id 0041841141 for ; Fri, 11 Feb 2022 05:49:44 +0100 (CET) Received: from dggeme756-chm.china.huawei.com (unknown [172.30.72.55]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Jw1JS4vvzz1FCXq for ; Fri, 11 Feb 2022 12:45:28 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by dggeme756-chm.china.huawei.com (10.3.19.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.21; Fri, 11 Feb 2022 12:49:43 +0800 From: "Min Hu (Connor)" To: CC: "Min Hu (Connor)" , Yisen Zhuang , Lijun Ou Subject: [PATCH 8/9] net/hns3: dump TM configuration info Date: Fri, 11 Feb 2022 12:49:29 +0800 Message-ID: <20220211044930.2449-9-humin29@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220211044930.2449-1-humin29@huawei.com> References: <20220211044930.2449-1-humin29@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggeme756-chm.china.huawei.com (10.3.19.102) X-CFilter-Loop: Reflected 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 This patch dumps TM configuration info about shaper, port node, TC node, queue node related info. Signed-off-by: Min Hu (Connor) --- drivers/net/hns3/hns3_ethdev_dump.c | 153 ++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) diff --git a/drivers/net/hns3/hns3_ethdev_dump.c b/drivers/net/hns3/hns3_ethdev_dump.c index 3fb4959885..675c7efed4 100644 --- a/drivers/net/hns3/hns3_ethdev_dump.c +++ b/drivers/net/hns3/hns3_ethdev_dump.c @@ -639,6 +639,158 @@ get_vlan_config_info(FILE *file, struct hns3_hw *hw) get_port_pvid_info(file, hw); } +static void +get_tm_conf_shaper_info(FILE *file, struct hns3_tm_conf *conf) +{ + struct hns3_shaper_profile_list *shaper_profile_list = + &conf->shaper_profile_list; + struct hns3_tm_shaper_profile *shaper_profile; + + if (!conf->nb_shaper_profile) + return; + + fprintf(file, " shaper_profile:\n"); + TAILQ_FOREACH(shaper_profile, shaper_profile_list, node) { + fprintf(file, + " id=%u reference_count=%u peak_rate=%" PRIu64 "Bps\n", + shaper_profile->shaper_profile_id, + shaper_profile->reference_count, + shaper_profile->profile.peak.rate); + } +} + +static void +get_tm_conf_port_node_info(FILE *file, struct hns3_tm_conf *conf) +{ + if (!conf->root) + return; + + fprintf(file, + " port_node: \n" + " node_id=%u reference_count=%u shaper_profile_id=%d\n", + conf->root->id, conf->root->reference_count, + conf->root->shaper_profile ? + (int)conf->root->shaper_profile->shaper_profile_id : -1); +} + +static void +get_tm_conf_tc_node_info(FILE *file, struct hns3_tm_conf *conf) +{ + struct hns3_tm_node_list *tc_list = &conf->tc_list; + struct hns3_tm_node *tc_node[HNS3_MAX_TC_NUM]; + struct hns3_tm_node *tm_node; + uint32_t tidx; + + if (!conf->nb_tc_node) + return; + + fprintf(file, " tc_node: \n"); + memset(tc_node, 0, sizeof(tc_node)); + TAILQ_FOREACH(tm_node, tc_list, node) { + tidx = hns3_tm_calc_node_tc_no(conf, tm_node->id); + if (tidx < HNS3_MAX_TC_NUM) + tc_node[tidx] = tm_node; + } + + for (tidx = 0; tidx < HNS3_MAX_TC_NUM; tidx++) { + tm_node = tc_node[tidx]; + if (tm_node == NULL) + continue; + fprintf(file, + " id=%u TC%u reference_count=%u parent_id=%d " + "shaper_profile_id=%d\n", + tm_node->id, hns3_tm_calc_node_tc_no(conf, tm_node->id), + tm_node->reference_count, + tm_node->parent ? (int)tm_node->parent->id : -1, + tm_node->shaper_profile ? + (int)tm_node->shaper_profile->shaper_profile_id : -1); + } +} + +static void +get_tm_conf_queue_format_info(FILE *file, struct hns3_tm_node **queue_node, + uint32_t *queue_node_tc, uint32_t nb_tx_queues) +{ +#define PERLINE_QUEUES 32 +#define PERLINE_STRIDE 8 +#define LINE_BUF_SIZE 1024 + uint32_t i, j, line_num, start_queue, end_queue; + char tmpbuf[LINE_BUF_SIZE] = {0}; + + line_num = (nb_tx_queues + PERLINE_QUEUES - 1) / PERLINE_QUEUES; + for (i = 0; i < line_num; i++) { + start_queue = i * PERLINE_QUEUES; + end_queue = (i + 1) * PERLINE_QUEUES - 1; + if (end_queue > nb_tx_queues - 1) + end_queue = nb_tx_queues - 1; + fprintf(file, " %04u - %04u | ", start_queue, end_queue); + for (j = start_queue; j < nb_tx_queues; j++) { + if (j >= end_queue + 1) + break; + if (j > start_queue && j % PERLINE_STRIDE == 0) + fprintf(file, ":"); + fprintf(file, "%u", + queue_node[j] ? queue_node_tc[j] : + HNS3_MAX_TC_NUM); + } + fprintf(file, "%s\n", tmpbuf); + } +} + +static void +get_tm_conf_queue_node_info(FILE *file, struct hns3_tm_conf *conf, + uint32_t nb_tx_queues) +{ + struct hns3_tm_node_list *queue_list = &conf->queue_list; + uint32_t nb_queue_node = conf->nb_leaf_nodes_max + 1; + struct hns3_tm_node *queue_node[nb_queue_node]; + uint32_t queue_node_tc[nb_queue_node]; + struct hns3_tm_node *tm_node; + + if (!conf->nb_queue_node) + return; + + fprintf(file, + " queue_node: \n" + " tx queue id | mapped tc (8 mean node not exist)\n"); + + memset(queue_node, 0, sizeof(queue_node)); + memset(queue_node_tc, 0, sizeof(queue_node_tc)); + nb_tx_queues = RTE_MIN(nb_tx_queues, nb_queue_node); + TAILQ_FOREACH(tm_node, queue_list, node) { + if (tm_node->id >= nb_queue_node) + continue; + queue_node[tm_node->id] = tm_node; + queue_node_tc[tm_node->id] = tm_node->parent ? + hns3_tm_calc_node_tc_no(conf, tm_node->parent->id) : 0; + nb_tx_queues = RTE_MAX(nb_tx_queues, tm_node->id + 1); + } + + get_tm_conf_queue_format_info(file, queue_node, queue_node_tc, + nb_tx_queues); +} + +static void +get_tm_conf_info(FILE *file, struct rte_eth_dev *dev) +{ + struct hns3_pf *pf = HNS3_DEV_PRIVATE_TO_PF(dev->data->dev_private); + struct hns3_tm_conf *conf = &pf->tm_conf; + + fprintf(file, " - TM config info:\n"); + fprintf(file, + "\t -- nb_leaf_nodes_max=%u nb_nodes_max=%u\n" + "\t -- nb_shaper_profile=%u nb_tc_node=%u nb_queue_node=%u\n" + "\t -- committed=%u\n", + conf->nb_leaf_nodes_max, conf->nb_nodes_max, + conf->nb_shaper_profile, conf->nb_tc_node, conf->nb_queue_node, + conf->committed); + + get_tm_conf_shaper_info(file, conf); + get_tm_conf_port_node_info(file, conf); + get_tm_conf_tc_node_info(file, conf); + get_tm_conf_queue_node_info(file, conf, dev->data->nb_tx_queues); +} + int hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file) { @@ -656,6 +808,7 @@ hns3_eth_dev_priv_dump(struct rte_eth_dev *dev, FILE *file) get_rxtx_queue_info(file, dev); get_vlan_config_info(file, hw); get_fdir_basic_info(file, &hns->pf); + get_tm_conf_info(file, dev); return 0; } -- 2.33.0