From patchwork Wed Jun 7 07:42:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 128276 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5194742C4A; Wed, 7 Jun 2023 09:45:48 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E4C6F42D29; Wed, 7 Jun 2023 09:45:30 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 015B7410FC for ; Wed, 7 Jun 2023 09:45:26 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QbfWh6QsDzTlG5; Wed, 7 Jun 2023 15:45:04 +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:25 +0800 From: Jie Hai To: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko CC: , Subject: [PATCH v2 07/13] ethdev: support telemetry query Rx queue info Date: Wed, 7 Jun 2023 15:42:02 +0800 Message-ID: <20230607074209.4798-8-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 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 support querying information of Rx queues. The command is like: --> /ethdev/rx_queue,0,0 { "/ethdev/rx_queue": { "mempool_name": "mb_pool_0", "socket_id": 0, "host_threshold": 0, "prefetch_threshold": 0, "writeback_threshold": 0, "free_threshold": 32, "rx_drop_en": "on", "deferred_start": "off", "rx_nseg": 0, "share_group": 0, "share_qid": 0, "offloads": [ "RSS_HASH" ], "rx_nmempool": 0, "scattered_rx": "off", "queue_state": 1, "nb_desc": 1024, "rx_buf_size": 2048, "avail_thresh": 0, "burst_flags": 0, "burst_mode": "Vector Neon" } } Signed-off-by: Jie Hai --- lib/ethdev/rte_ethdev_telemetry.c | 127 ++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) diff --git a/lib/ethdev/rte_ethdev_telemetry.c b/lib/ethdev/rte_ethdev_telemetry.c index 9847aa528f14..d1875dbe110e 100644 --- a/lib/ethdev/rte_ethdev_telemetry.c +++ b/lib/ethdev/rte_ethdev_telemetry.c @@ -450,6 +450,131 @@ eth_dev_handle_port_flow_ctrl(const char *cmd __rte_unused, return 0; } +static int +ethdev_parse_queue_params(const char *params, bool is_rx, + uint16_t *port_id, uint16_t *queue_id) +{ + struct rte_eth_dev *dev; + const char *qid_param; + uint16_t nb_queues; + char *end_param; + uint64_t qid; + int ret; + + ret = eth_dev_parse_port_params(params, port_id, &end_param, true); + if (ret < 0) + return ret; + + dev = &rte_eth_devices[*port_id]; + nb_queues = is_rx ? dev->data->nb_rx_queues : dev->data->nb_tx_queues; + if (nb_queues == 1 && *end_param == '\0') + qid = 0; + else { + qid_param = strtok(end_param, ","); + if (!qid_param || strlen(qid_param) == 0 || !isdigit(*qid_param)) + return -EINVAL; + + qid = strtoul(qid_param, &end_param, 0); + } + if (*end_param != '\0') + RTE_ETHDEV_LOG(NOTICE, + "Extra parameters passed to ethdev telemetry command, ignoring\n"); + + if (qid >= UINT16_MAX) + return -EINVAL; + + *queue_id = qid; + return 0; +} + +static int +eth_dev_add_burst_mode(uint16_t port_id, uint16_t queue_id, + bool is_rx, struct rte_tel_data *d) +{ + struct rte_eth_burst_mode mode; + int ret; + + if (is_rx) + ret = rte_eth_rx_burst_mode_get(port_id, queue_id, &mode); + else + ret = rte_eth_tx_burst_mode_get(port_id, queue_id, &mode); + + if (ret == -ENOTSUP) + return 0; + + if (ret != 0) { + RTE_ETHDEV_LOG(ERR, + "Failed to get burst mode for port %u\n", port_id); + return ret; + } + + rte_tel_data_add_dict_uint(d, "burst_flags", mode.flags); + rte_tel_data_add_dict_string(d, "burst_mode", mode.info); + return 0; +} + +static int +eth_dev_handle_port_rxq(const char *cmd __rte_unused, + const char *params, + struct rte_tel_data *d) +{ + struct rte_eth_thresh *rx_thresh; + struct rte_eth_rxconf *rxconf; + struct rte_eth_rxq_info qinfo; + struct rte_tel_data *offload; + uint16_t port_id, queue_id; + int ret; + + ret = ethdev_parse_queue_params(params, true, &port_id, &queue_id); + if (ret != 0) + return ret; + + ret = rte_eth_rx_queue_info_get(port_id, queue_id, &qinfo); + if (ret != 0) + return ret; + + rte_tel_data_start_dict(d); + rte_tel_data_add_dict_string(d, "mempool_name", qinfo.mp->name); + rte_tel_data_add_dict_uint(d, "socket_id", qinfo.mp->socket_id); + + rx_thresh = &qinfo.conf.rx_thresh; + rte_tel_data_add_dict_uint(d, "host_threshold", rx_thresh->hthresh); + rte_tel_data_add_dict_uint(d, "prefetch_threshold", rx_thresh->pthresh); + rte_tel_data_add_dict_uint(d, "writeback_threshold", rx_thresh->wthresh); + + rxconf = &qinfo.conf; + rte_tel_data_add_dict_uint(d, "free_threshold", rxconf->rx_free_thresh); + rte_tel_data_add_dict_string(d, "rx_drop_en", + rxconf->rx_drop_en == 0 ? "off" : "on"); + rte_tel_data_add_dict_string(d, "deferred_start", + rxconf->rx_deferred_start == 0 ? "off" : "on"); + rte_tel_data_add_dict_uint(d, "rx_nseg", rxconf->rx_nseg); + rte_tel_data_add_dict_uint(d, "share_group", rxconf->share_group); + rte_tel_data_add_dict_uint(d, "share_qid", rxconf->share_qid); + + offload = rte_tel_data_alloc(); + if (offload == NULL) + return -ENOMEM; + + eth_dev_parse_rx_offloads(rxconf->offloads, offload); + rte_tel_data_add_dict_container(d, "offloads", offload, 0); + + rte_tel_data_add_dict_uint(d, "rx_nmempool", rxconf->rx_nmempool); + + rte_tel_data_add_dict_string(d, "scattered_rx", + qinfo.scattered_rx == 0 ? "off" : "on"); + rte_tel_data_add_dict_uint(d, "queue_state", qinfo.queue_state); + rte_tel_data_add_dict_uint(d, "nb_desc", qinfo.nb_desc); + rte_tel_data_add_dict_uint(d, "rx_buf_size", qinfo.rx_buf_size); + rte_tel_data_add_dict_uint(d, "avail_thresh", qinfo.avail_thresh); + + ret = eth_dev_add_burst_mode(port_id, queue_id, true, d); + if (ret != 0) + rte_tel_data_free(offload); + + return ret; +} + RTE_INIT(ethdev_init_telemetry) { rte_telemetry_register_cmd("/ethdev/list", eth_dev_handle_port_list, @@ -473,4 +598,6 @@ RTE_INIT(ethdev_init_telemetry) "Returns the MAC addresses for a port. Parameters: int port_id"); rte_telemetry_register_cmd("/ethdev/flow_ctrl", eth_dev_handle_port_flow_ctrl, "Returns flow ctrl info for a port. Parameters: int port_id"); + rte_telemetry_register_cmd("/ethdev/rx_queue", eth_dev_handle_port_rxq, + "Returns Rx queue info for a port. Parameters: int port_id, int queue_id (Optional if only one queue)"); }