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 BCF3A42C4A; Wed, 7 Jun 2023 09:46:33 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B519F42D84; Wed, 7 Jun 2023 09:45:39 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 480DE410FC for ; Wed, 7 Jun 2023 09:45:28 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QbfSc5F1wzLqhK; Wed, 7 Jun 2023 15:42:24 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by kwepemi500020.china.huawei.com (7.221.188.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 7 Jun 2023 15:45:26 +0800 From: Jie Hai To: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko CC: , Subject: [PATCH v2 10/13] ethdev: support telemetry query DCB info Date: Wed, 7 Jun 2023 15:42:05 +0800 Message-ID: <20230607074209.4798-11-haijie1@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230607074209.4798-1-haijie1@huawei.com> References: <20230530090510.56812-1-haijie1@huawei.com> <20230607074209.4798-1-haijie1@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemi500020.china.huawei.com (7.221.188.8) 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 supports querying DCB info. The command is like: --> /ethdev/dcb,0 { "/ethdev/dcb": { "tc_num": 1, "tc0": { "priority": 0, "bw_percent": "100%", "rxq_base": 0, "txq_base": 0, "nb_rxq": 4, "nb_txq": 4 } } } Signed-off-by: Jie Hai --- lib/ethdev/rte_ethdev_telemetry.c | 79 +++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/lib/ethdev/rte_ethdev_telemetry.c b/lib/ethdev/rte_ethdev_telemetry.c index 930181e5324f..d0d55993102b 100644 --- a/lib/ethdev/rte_ethdev_telemetry.c +++ b/lib/ethdev/rte_ethdev_telemetry.c @@ -629,6 +629,83 @@ eth_dev_handle_port_txq(const char *cmd __rte_unused, return 0; } +static int +eth_dev_add_dcb_tc(struct rte_eth_dcb_info *dcb_info, struct rte_tel_data *d) +{ + struct rte_tel_data *tcds[RTE_ETH_DCB_NUM_TCS] = {NULL}; + struct rte_eth_dcb_tc_queue_mapping *tcq; + char bw_percent[RTE_TEL_MAX_STRING_LEN]; + char name[RTE_TEL_MAX_STRING_LEN]; + struct rte_tel_data *tcd; + uint32_t i; + + for (i = 0; i < dcb_info->nb_tcs; i++) { + tcd = rte_tel_data_alloc(); + if (tcd == NULL) { + while (i-- > 0) + rte_tel_data_free(tcds[i]); + return -ENOMEM; + } + + tcds[i] = tcd; + rte_tel_data_start_dict(tcd); + + rte_tel_data_add_dict_uint(tcd, "priority", dcb_info->prio_tc[i]); + snprintf(bw_percent, RTE_TEL_MAX_STRING_LEN, + "%u%%", dcb_info->tc_bws[i]); + rte_tel_data_add_dict_string(tcd, "bw_percent", bw_percent); + + tcq = &dcb_info->tc_queue; + rte_tel_data_add_dict_uint(tcd, "rxq_base", tcq->tc_rxq[0][i].base); + rte_tel_data_add_dict_uint(tcd, "txq_base", tcq->tc_txq[0][i].base); + rte_tel_data_add_dict_uint(tcd, "nb_rxq", tcq->tc_rxq[0][i].nb_queue); + rte_tel_data_add_dict_uint(tcd, "nb_txq", tcq->tc_txq[0][i].nb_queue); + + snprintf(name, RTE_TEL_MAX_STRING_LEN, "tc%u", i); + rte_tel_data_add_dict_container(d, name, tcd, 0); + } + + return 0; +} + +static int +eth_dev_add_dcb_info(uint16_t port_id, struct rte_tel_data *d) +{ + struct rte_eth_dcb_info dcb_info; + int ret; + + ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info); + if (ret != 0) { + RTE_ETHDEV_LOG(ERR, + "Failed to get dcb info, ret = %d\n", ret); + return ret; + } + + rte_tel_data_start_dict(d); + rte_tel_data_add_dict_uint(d, "tc_num", dcb_info.nb_tcs); + + if (dcb_info.nb_tcs > 0) + return eth_dev_add_dcb_tc(&dcb_info, d); + + return 0; +} + +static int +eth_dev_handle_port_dcb(const char *cmd __rte_unused, + const char *params, + struct rte_tel_data *d) +{ + uint16_t port_id; + char *end_param; + int ret; + + ret = eth_dev_parse_port_params(params, &port_id, &end_param, false); + if (ret < 0) + return ret; + + return eth_dev_add_dcb_info(port_id, d); +} + RTE_INIT(ethdev_init_telemetry) { rte_telemetry_register_cmd("/ethdev/list", eth_dev_handle_port_list, @@ -656,4 +733,6 @@ RTE_INIT(ethdev_init_telemetry) "Returns Rx queue info for a port. Parameters: int port_id, int queue_id (Optional if only one queue)"); rte_telemetry_register_cmd("/ethdev/tx_queue", eth_dev_handle_port_txq, "Returns Tx queue info for a port. Parameters: int port_id, int queue_id (Optional if only one queue)"); + rte_telemetry_register_cmd("/ethdev/dcb", eth_dev_handle_port_dcb, + "Returns DCB info for a port. Parameters: int port_id"); } -- 2.33.0