From patchwork Tue May 30 09:05:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 127689 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 B168E42BE1; Tue, 30 May 2023 11:07:37 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A268241149; Tue, 30 May 2023 11:07:37 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id C869E41149 for ; Tue, 30 May 2023 11:07:35 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4QVmgz3Hj9zsSfB; Tue, 30 May 2023 17:05:19 +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; Tue, 30 May 2023 17:07:32 +0800 From: Jie Hai To: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko CC: , Subject: [PATCH 01/10] ethdev: support telemetry query MAC addresses Date: Tue, 30 May 2023 17:05:01 +0800 Message-ID: <20230530090510.56812-2-haijie1@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230530090510.56812-1-haijie1@huawei.com> References: <20230530090510.56812-1-haijie1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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 From: Dengdui Huang This patch support telemetry query MAC addresses for a specific port. The command is like: --> /ethdev/macs,0 { "/ethdev/macs": [ "00:18:2D:00:00:79", "00:18:2D:00:00:78", "00:18:2D:00:00:77" ] } Signed-off-by: Dengdui Huang --- lib/ethdev/rte_ethdev.c | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index d46e74504e64..65e0101fc0eb 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -7032,6 +7032,48 @@ int rte_eth_dev_map_aggr_tx_affinity(uint16_t port_id, uint16_t tx_queue_id, return ret; } +static int +eth_dev_handle_port_macs(const char *cmd __rte_unused, + const char *params, + struct rte_tel_data *d) +{ + char mac_addr[RTE_ETHER_ADDR_FMT_SIZE]; + struct rte_eth_dev_info dev_info; + struct rte_eth_dev *eth_dev; + unsigned long port_id; + char *end_param; + uint32_t i; + int ret; + + if (params == NULL || strlen(params) == 0 || !isdigit(*params)) + return -EINVAL; + + port_id = strtoul(params, &end_param, 0); + if (*end_param != '\0') + RTE_ETHDEV_LOG(NOTICE, + "Extra parameters passed to ethdev telemetry command, ignoring"); + + if (port_id >= UINT16_MAX) + return -EINVAL; + + ret = rte_eth_dev_info_get(port_id, &dev_info); + if (ret != 0) + return ret; + + eth_dev = &rte_eth_devices[port_id]; + rte_tel_data_start_array(d, RTE_TEL_STRING_VAL); + for (i = 0; i < dev_info.max_mac_addrs; i++) { + if (rte_is_zero_ether_addr(ð_dev->data->mac_addrs[i])) + continue; + + rte_ether_format_addr(mac_addr, sizeof(mac_addr), + ð_dev->data->mac_addrs[i]); + rte_tel_data_add_array_string(d, mac_addr); + } + + return 0; +} + RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO); RTE_INIT(ethdev_init_telemetry) @@ -7053,4 +7095,6 @@ RTE_INIT(ethdev_init_telemetry) "Returns the device info for a port. Parameters: int port_id"); rte_telemetry_register_cmd("/ethdev/module_eeprom", eth_dev_handle_port_module_eeprom, "Returns module EEPROM info with SFF specs. Parameters: int port_id"); + rte_telemetry_register_cmd("/ethdev/macs", eth_dev_handle_port_macs, + "Returns the MAC addresses for a port. Parameters: int port_id"); } From patchwork Tue May 30 09:05: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: 127690 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 A962C42BE1; Tue, 30 May 2023 11:07:43 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C444942D0D; Tue, 30 May 2023 11:07:42 +0200 (CEST) Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by mails.dpdk.org (Postfix) with ESMTP id 55A2342BC9 for ; Tue, 30 May 2023 11:07:41 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4QVmdL4JmGz18Lc8; Tue, 30 May 2023 17:03:02 +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; Tue, 30 May 2023 17:07:39 +0800 From: Jie Hai To: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko CC: , Subject: [PATCH 02/10] ethdev: support RxTx offload display Date: Tue, 30 May 2023 17:05:02 +0800 Message-ID: <20230530090510.56812-3-haijie1@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230530090510.56812-1-haijie1@huawei.com> References: <20230530090510.56812-1-haijie1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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 Currently, Rx/Tx offloads are displayed in numeric format, which is not easy to understand. This patch fixes it. Signed-off-by: Jie Hai --- lib/ethdev/rte_ethdev.c | 67 +++++++++++++++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 10 deletions(-) diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 65e0101fc0eb..3207b3177256 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -6607,16 +6607,44 @@ eth_dev_handle_port_link_status(const char *cmd __rte_unused, return 0; } +static void +eth_dev_parse_rx_offloads(uint64_t offload, struct rte_tel_data *d) +{ + uint32_t i; + + rte_tel_data_start_array(d, RTE_TEL_STRING_VAL); + for (i = 0; i < RTE_DIM(eth_dev_rx_offload_names); i++) { + if ((offload & eth_dev_rx_offload_names[i].offload) != 0) + rte_tel_data_add_array_string(d, + eth_dev_rx_offload_names[i].name); + } +} + +static void +eth_dev_parse_tx_offloads(uint64_t offload, struct rte_tel_data *d) +{ + uint32_t i; + + rte_tel_data_start_array(d, RTE_TEL_STRING_VAL); + for (i = 0; i < RTE_DIM(eth_dev_tx_offload_names); i++) { + if ((offload & eth_dev_tx_offload_names[i].offload) != 0) + rte_tel_data_add_array_string(d, + eth_dev_tx_offload_names[i].name); + } +} + static int eth_dev_handle_port_info(const char *cmd __rte_unused, const char *params, struct rte_tel_data *d) { + struct rte_tel_data *rx_offload, *tx_offload; struct rte_tel_data *rxq_state, *txq_state; char mac_addr[RTE_ETHER_ADDR_FMT_SIZE]; struct rte_eth_dev *eth_dev; char *end_param; - int port_id, i; + int port_id; + uint32_t i; if (params == NULL || strlen(params) == 0 || !isdigit(*params)) return -1; @@ -6632,14 +6660,20 @@ eth_dev_handle_port_info(const char *cmd __rte_unused, eth_dev = &rte_eth_devices[port_id]; rxq_state = rte_tel_data_alloc(); - if (!rxq_state) + if (rxq_state == NULL) return -ENOMEM; txq_state = rte_tel_data_alloc(); - if (!txq_state) { - rte_tel_data_free(rxq_state); - return -ENOMEM; - } + if (txq_state == NULL) + goto free_rxq_state; + + rx_offload = rte_tel_data_alloc(); + if (rx_offload == NULL) + goto free_txq_state; + + tx_offload = rte_tel_data_alloc(); + if (tx_offload == NULL) + goto free_rx_offload; rte_tel_data_start_dict(d); rte_tel_data_add_dict_string(d, "name", eth_dev->data->name); @@ -6681,14 +6715,27 @@ eth_dev_handle_port_info(const char *cmd __rte_unused, rte_tel_data_add_dict_int(d, "numa_node", eth_dev->data->numa_node); rte_tel_data_add_dict_uint_hex(d, "dev_flags", eth_dev->data->dev_flags, 0); - rte_tel_data_add_dict_uint_hex(d, "rx_offloads", - eth_dev->data->dev_conf.rxmode.offloads, 0); - rte_tel_data_add_dict_uint_hex(d, "tx_offloads", - eth_dev->data->dev_conf.txmode.offloads, 0); + + eth_dev_parse_rx_offloads(eth_dev->data->dev_conf.rxmode.offloads, + rx_offload); + rte_tel_data_add_dict_container(d, "rx_offloads", rx_offload, 0); + eth_dev_parse_tx_offloads(eth_dev->data->dev_conf.txmode.offloads, + tx_offload); + rte_tel_data_add_dict_container(d, "tx_offloads", tx_offload, 0); + rte_tel_data_add_dict_uint_hex(d, "ethdev_rss_hf", eth_dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf, 0); return 0; + +free_rx_offload: + rte_tel_data_free(rx_offload); +free_txq_state: + rte_tel_data_free(txq_state); +free_rxq_state: + rte_tel_data_free(rxq_state); + + return -ENOMEM; } int From patchwork Tue May 30 09:05:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 127692 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 682C742BE1; Tue, 30 May 2023 11:07:57 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F232742D33; Tue, 30 May 2023 11:07:44 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id D4B4442D0D for ; Tue, 30 May 2023 11:07:41 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QVmkW3k9MzSqQt; Tue, 30 May 2023 17:07:31 +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; Tue, 30 May 2023 17:07:39 +0800 From: Jie Hai To: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko CC: , Subject: [PATCH 03/10] ethdev: support telemetry query flow ctrl info Date: Tue, 30 May 2023 17:05:03 +0800 Message-ID: <20230530090510.56812-4-haijie1@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230530090510.56812-1-haijie1@huawei.com> References: <20230530090510.56812-1-haijie1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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 telemetry querying flow control info. The command is like: --> /ethdev/flow_ctrl,0 { "/ethdev/flow_ctrl": { "high_waterline": "0x0", "low_waterline": "0x0", "pause_time": "0xffff", "send_xon": "off", "mac_ctrl_frame_fwd": "off", "rx_pause": "off", "tx_pause": "off", "autoneg": "off" } } Signed-off-by: Jie Hai --- lib/ethdev/rte_ethdev.c | 51 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 3207b3177256..5cdb310ca979 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -7121,6 +7121,55 @@ eth_dev_handle_port_macs(const char *cmd __rte_unused, return 0; } +static int +eth_dev_handle_port_flow_ctrl(const char *cmd __rte_unused, + const char *params, + struct rte_tel_data *d) +{ + struct rte_eth_fc_conf fc_conf; + unsigned long port_id; + char *end_param; + bool rx_fc_en; + bool tx_fc_en; + int ret; + + if (params == NULL || strlen(params) == 0 || !isdigit(*params)) + return -EINVAL; + + port_id = strtoul(params, &end_param, 0); + if (*end_param != '\0') + RTE_ETHDEV_LOG(NOTICE, + "Extra parameters passed to ethdev telemetry command, ignoring\n"); + + if (port_id >= UINT16_MAX || !rte_eth_dev_is_valid_port(port_id)) + return -EINVAL; + + ret = rte_eth_dev_flow_ctrl_get(port_id, &fc_conf); + if (ret != 0) { + RTE_ETHDEV_LOG(ERR, + "Failed to get flow ctrl info, ret = %d\n", ret); + return ret; + } + + rx_fc_en = fc_conf.mode == RTE_ETH_FC_RX_PAUSE || + fc_conf.mode == RTE_ETH_FC_FULL; + tx_fc_en = fc_conf.mode == RTE_ETH_FC_TX_PAUSE || + fc_conf.mode == RTE_ETH_FC_FULL; + + rte_tel_data_start_dict(d); + rte_tel_data_add_dict_uint_hex(d, "high_waterline", fc_conf.high_water, 0); + rte_tel_data_add_dict_uint_hex(d, "low_waterline", fc_conf.low_water, 0); + rte_tel_data_add_dict_uint_hex(d, "pause_time", fc_conf.pause_time, 0); + rte_tel_data_add_dict_string(d, "send_xon", fc_conf.send_xon ? "on" : "off"); + rte_tel_data_add_dict_string(d, "mac_ctrl_frame_fwd", + fc_conf.mac_ctrl_frame_fwd ? "on" : "off"); + rte_tel_data_add_dict_string(d, "rx_pause", rx_fc_en ? "on" : "off"); + rte_tel_data_add_dict_string(d, "tx_pause", tx_fc_en ? "on" : "off"); + rte_tel_data_add_dict_string(d, "autoneg", fc_conf.autoneg ? "on" : "off"); + + return 0; +} + RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO); RTE_INIT(ethdev_init_telemetry) @@ -7144,4 +7193,6 @@ RTE_INIT(ethdev_init_telemetry) "Returns module EEPROM info with SFF specs. Parameters: int port_id"); rte_telemetry_register_cmd("/ethdev/macs", eth_dev_handle_port_macs, "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: unsigned port_id"); } From patchwork Tue May 30 09:05:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 127691 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 D6AC642BE1; Tue, 30 May 2023 11:07:49 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CB93242D32; Tue, 30 May 2023 11:07:43 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id CB93C42BDA for ; Tue, 30 May 2023 11:07:41 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4QVmh66X4bzsSdb; Tue, 30 May 2023 17:05:26 +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; Tue, 30 May 2023 17:07:40 +0800 From: Jie Hai To: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko CC: , Subject: [PATCH 04/10] ethdev: support telemetry query Rx queue info Date: Tue, 30 May 2023 17:05:04 +0800 Message-ID: <20230530090510.56812-5-haijie1@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230530090510.56812-1-haijie1@huawei.com> References: <20230530090510.56812-1-haijie1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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.c | 127 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 5cdb310ca979..35c13df1c110 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -7170,6 +7170,131 @@ eth_dev_handle_port_flow_ctrl(const char *cmd __rte_unused, return 0; } +static int +parse_queue_params(const char *params, bool is_rx, + unsigned long *port_id, unsigned long *queue_id) +{ + struct rte_eth_dev *dev; + const char *qid_param; + uint16_t nb_queues; + char *end_param; + + if (params == NULL || strlen(params) == 0 || !isdigit(*params)) + return -EINVAL; + + *port_id = strtoul(params, &end_param, 0); + if (*port_id >= UINT16_MAX || !rte_eth_dev_is_valid_port(*port_id)) + return -EINVAL; + + 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') + *queue_id = 0; + else { + qid_param = strtok(end_param, ","); + if (!qid_param || strlen(qid_param) == 0 || !isdigit(*qid_param)) + return -EINVAL; + + *queue_id = strtoul(qid_param, &end_param, 0); + } + if (*end_param != '\0') + RTE_ETHDEV_LOG(NOTICE, + "Extra parameters passed to ethdev telemetry command, ignoring\n"); + + if (*queue_id >= UINT16_MAX) + return -EINVAL; + + return 0; +} + +static int +eth_dev_add_burst_mode(unsigned long port_id, unsigned long 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 %lu\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; + unsigned long port_id, queue_id; + struct rte_eth_rxconf *rxconf; + struct rte_eth_rxq_info qinfo; + struct rte_tel_data *offload; + int ret; + + ret = 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_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO); RTE_INIT(ethdev_init_telemetry) @@ -7195,4 +7320,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: unsigned port_id"); + rte_telemetry_register_cmd("/ethdev/rx_queue", eth_dev_handle_port_rxq, + "Returns Rx queue info for a port. Parameters: unsigned port_id, unsigned queue_id (Optional if only one queue)"); } From patchwork Tue May 30 09:05:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 127693 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 E467042BE1; Tue, 30 May 2023 11:08:03 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2871442D39; Tue, 30 May 2023 11:07:46 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 5947C42D0B for ; Tue, 30 May 2023 11:07:42 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QVmgG1Y04zLnd8; Tue, 30 May 2023 17:04:42 +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; Tue, 30 May 2023 17:07:40 +0800 From: Jie Hai To: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko CC: , Subject: [PATCH 05/10] ethdev: support telemetry query Tx queue info Date: Tue, 30 May 2023 17:05:05 +0800 Message-ID: <20230530090510.56812-6-haijie1@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230530090510.56812-1-haijie1@huawei.com> References: <20230530090510.56812-1-haijie1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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 Tx queues. The command is like: --> /ethdev/tx_queue,0,0 { "/ethdev/tx_queue": { "host_threshold": 0, "prefetch_threshold": 0, "writeback_threshold": 0, "rs_threshold": 32, "free_threshold": 928, "deferred_start": "off", "offloads": [ "MBUF_FAST_FREE" ], "queue_state": 1, "nb_desc": 1024, "burst_flags": 0, "burst_mode": "Vector Neon" } } Signed-off-by: Jie Hai --- lib/ethdev/rte_ethdev.c | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 35c13df1c110..315334321cb3 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -7295,6 +7295,54 @@ eth_dev_handle_port_rxq(const char *cmd __rte_unused, return ret; } +static int +eth_dev_handle_port_txq(const char *cmd __rte_unused, + const char *params, + struct rte_tel_data *d) +{ + struct rte_eth_thresh *tx_thresh; + unsigned long port_id, queue_id; + struct rte_eth_txconf *txconf; + struct rte_eth_txq_info qinfo; + struct rte_tel_data *offload; + int ret; + + ret = parse_queue_params(params, false, &port_id, &queue_id); + if (ret != 0) + return ret; + + ret = rte_eth_tx_queue_info_get(port_id, queue_id, &qinfo); + if (ret != 0) + return ret; + + rte_tel_data_start_dict(d); + tx_thresh = &qinfo.conf.tx_thresh; + txconf = &qinfo.conf; + rte_tel_data_add_dict_uint(d, "host_threshold", tx_thresh->hthresh); + rte_tel_data_add_dict_uint(d, "prefetch_threshold", tx_thresh->pthresh); + rte_tel_data_add_dict_uint(d, "writeback_threshold", tx_thresh->wthresh); + rte_tel_data_add_dict_uint(d, "rs_threshold", txconf->tx_rs_thresh); + rte_tel_data_add_dict_uint(d, "free_threshold", txconf->tx_free_thresh); + rte_tel_data_add_dict_string(d, "deferred_start", + txconf->tx_deferred_start == 0 ? "off" : "on"); + + offload = rte_tel_data_alloc(); + if (offload == NULL) + return -ENOMEM; + + eth_dev_parse_tx_offloads(txconf->offloads, offload); + rte_tel_data_add_dict_container(d, "offloads", offload, 0); + + rte_tel_data_add_dict_uint(d, "queue_state", qinfo.queue_state); + rte_tel_data_add_dict_uint(d, "nb_desc", qinfo.nb_desc); + + ret = eth_dev_add_burst_mode(port_id, queue_id, false, d); + if (ret != 0) + rte_tel_data_free(offload); + + return 0; +} + RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO); RTE_INIT(ethdev_init_telemetry) @@ -7322,4 +7370,6 @@ RTE_INIT(ethdev_init_telemetry) "Returns flow ctrl info for a port. Parameters: unsigned port_id"); rte_telemetry_register_cmd("/ethdev/rx_queue", eth_dev_handle_port_rxq, "Returns Rx queue info for a port. Parameters: unsigned port_id, unsigned 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: unsigned port_id, unsigned queue_id (Optional if only one queue)"); } From patchwork Tue May 30 09:05:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 127694 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 88DDE42BE1; Tue, 30 May 2023 11:08:10 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5345342D31; Tue, 30 May 2023 11:07:47 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id E229C42D17 for ; Tue, 30 May 2023 11:07:42 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QVmkX5pSdzSqTw; Tue, 30 May 2023 17:07:32 +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; Tue, 30 May 2023 17:07:41 +0800 From: Jie Hai To: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko CC: , Subject: [PATCH 06/10] ethdev: add firmware version in telemetry info command Date: Tue, 30 May 2023 17:05:06 +0800 Message-ID: <20230530090510.56812-7-haijie1@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230530090510.56812-1-haijie1@huawei.com> References: <20230530090510.56812-1-haijie1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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 adds firmware version in telemetry info command. An example is like: --> /ethdev/info,0 { "/ethdev/info": { "name": "0000:bd:00.0", "fw_version": "1.20.0.17", .... } } Signed-off-by: Jie Hai --- lib/ethdev/rte_ethdev.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 315334321cb3..d906cc66d2f9 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -6640,6 +6640,7 @@ eth_dev_handle_port_info(const char *cmd __rte_unused, { struct rte_tel_data *rx_offload, *tx_offload; struct rte_tel_data *rxq_state, *txq_state; + char fw_version[RTE_TEL_MAX_STRING_LEN]; char mac_addr[RTE_ETHER_ADDR_FMT_SIZE]; struct rte_eth_dev *eth_dev; char *end_param; @@ -6677,6 +6678,11 @@ eth_dev_handle_port_info(const char *cmd __rte_unused, rte_tel_data_start_dict(d); rte_tel_data_add_dict_string(d, "name", eth_dev->data->name); + + if (rte_eth_dev_fw_version_get(port_id, fw_version, + RTE_TEL_MAX_STRING_LEN) == 0) + rte_tel_data_add_dict_string(d, "fw_version", fw_version); + rte_tel_data_add_dict_int(d, "state", eth_dev->state); rte_tel_data_add_dict_int(d, "nb_rx_queues", eth_dev->data->nb_rx_queues); From patchwork Tue May 30 09:05:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 127695 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 B857042BE1; Tue, 30 May 2023 11:08:16 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 60BFE42D43; Tue, 30 May 2023 11:07:48 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 21DA542D20 for ; Tue, 30 May 2023 11:07:43 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QVmkY1hWbzSqX8; Tue, 30 May 2023 17:07:33 +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; Tue, 30 May 2023 17:07:41 +0800 From: Jie Hai To: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko CC: , Subject: [PATCH 07/10] ethdev: support telemetry query DCB info Date: Tue, 30 May 2023 17:05:07 +0800 Message-ID: <20230530090510.56812-8-haijie1@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230530090510.56812-1-haijie1@huawei.com> References: <20230530090510.56812-1-haijie1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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.c | 85 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index d906cc66d2f9..dad9c5538149 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -7349,6 +7349,89 @@ 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) +{ + unsigned long port_id; + char *end_param; + + if (params == NULL || strlen(params) == 0 || !isdigit(*params)) + return -EINVAL; + + port_id = strtoul(params, &end_param, 0); + if (*end_param != '\0') + RTE_ETHDEV_LOG(NOTICE, + "Extra parameters passed to ethdev telemetry command, ignoring\n"); + + if (port_id >= UINT16_MAX || !rte_eth_dev_is_valid_port(port_id)) + return -EINVAL; + + return eth_dev_add_dcb_info(port_id, d); +} + RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO); RTE_INIT(ethdev_init_telemetry) @@ -7378,4 +7461,6 @@ RTE_INIT(ethdev_init_telemetry) "Returns Rx queue info for a port. Parameters: unsigned port_id, unsigned 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: unsigned port_id, unsigned 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: unsigned port_id"); } From patchwork Tue May 30 09:05:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 127696 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 3CACD42BE1; Tue, 30 May 2023 11:08:23 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8DA5B42D48; Tue, 30 May 2023 11:07:49 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id A131F406BC for ; Tue, 30 May 2023 11:07:43 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4QVmdN43GFzqTQr; Tue, 30 May 2023 17:03: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; Tue, 30 May 2023 17:07:42 +0800 From: Jie Hai To: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko CC: , Subject: [PATCH 08/10] ethdev: support telemetry query RSS info Date: Tue, 30 May 2023 17:05:08 +0800 Message-ID: <20230530090510.56812-9-haijie1@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230530090510.56812-1-haijie1@huawei.com> References: <20230530090510.56812-1-haijie1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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 RSS info by telemetry command. The command is like: --> /ethdev/rss_info,0 { "/ethdev/rss_info": { "rss_hf": "0x238c", "rss_key_len": 40, "rss_key": "6d5a56da255b0ec24167253d43a38fb0d0ca2b\ cbae7b30b477cb2da38030f20c6a42b73bbeac01fa" } } Signed-off-by: Jie Hai --- lib/ethdev/rte_ethdev.c | 86 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index dad9c5538149..6699b40d5e15 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -7432,6 +7432,90 @@ eth_dev_handle_port_dcb(const char *cmd __rte_unused, return eth_dev_add_dcb_info(port_id, d); } +static int +eth_dev_add_rss_info(struct rte_eth_rss_conf *rss_conf, struct rte_tel_data *d) +{ + const uint32_t key_len = rss_conf->rss_key_len * 2 + 1; + char *rss_key; + char *key; + uint32_t i; + int ret; + + key = rte_malloc(NULL, key_len, 0); + if (key == NULL) + return -ENOMEM; + + rss_key = rte_malloc(NULL, key_len, 0); + if (rss_key == NULL) { + ret = -ENOMEM; + goto free_key; + } + + rte_tel_data_start_dict(d); + rte_tel_data_add_dict_uint_hex(d, "rss_hf", rss_conf->rss_hf, 0); + rte_tel_data_add_dict_uint(d, "rss_key_len", rss_conf->rss_key_len); + + memset(rss_key, 0, key_len); + for (i = 0; i < rss_conf->rss_key_len; i++) { + ret = snprintf(key, key_len, "%02x", rss_conf->rss_key[i]); + if (ret < 0) + goto free_rss_key; + strlcat(rss_key, key, key_len); + } + ret = rte_tel_data_add_dict_string(d, "rss_key", rss_key); + +free_rss_key: + rte_free(rss_key); +free_key: + rte_free(key); + return ret; +} + +static int +eth_dev_handle_port_rss_info(const char *cmd __rte_unused, + const char *params, + struct rte_tel_data *d) +{ + struct rte_eth_dev_info dev_info; + struct rte_eth_rss_conf rss_conf; + unsigned long port_id; + char *end_param; + int ret; + + if (params == NULL || strlen(params) == 0 || !isdigit(*params)) + return -EINVAL; + + port_id = strtoul(params, &end_param, 0); + if (*end_param != '\0') + RTE_ETHDEV_LOG(NOTICE, + "Extra parameters passed to ethdev telemetry command, ignoring\n"); + + if (port_id >= UINT16_MAX || !rte_eth_dev_is_valid_port(port_id)) + return -EINVAL; + + ret = rte_eth_dev_info_get(port_id, &dev_info); + if (ret != 0) { + RTE_ETHDEV_LOG(ERR, + "Failed to get device info, ret = %d\n", ret); + return ret; + } + + rss_conf.rss_key_len = dev_info.hash_key_size; + rss_conf.rss_key = rte_malloc(NULL, dev_info.hash_key_size, 0); + if (rss_conf.rss_key == NULL) + return -ENOMEM; + + ret = rte_eth_dev_rss_hash_conf_get(port_id, &rss_conf); + if (ret != 0) { + rte_free(rss_conf.rss_key); + return ret; + } + + ret = eth_dev_add_rss_info(&rss_conf, d); + rte_free(rss_conf.rss_key); + return ret; +} + RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO); RTE_INIT(ethdev_init_telemetry) @@ -7463,4 +7547,6 @@ RTE_INIT(ethdev_init_telemetry) "Returns Tx queue info for a port. Parameters: unsigned port_id, unsigned 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: unsigned port_id"); + rte_telemetry_register_cmd("/ethdev/rss_info", eth_dev_handle_port_rss_info, + "Returns RSS info for a port. Parameters: unsigned port_id"); } From patchwork Tue May 30 09:05:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 127697 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 637CC42BE1; Tue, 30 May 2023 11:08:32 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2669D42D55; Tue, 30 May 2023 11:07:51 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 3E30C42D17 for ; Tue, 30 May 2023 11:07:44 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QVmgJ0lGfzLpvK; Tue, 30 May 2023 17:04:44 +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; Tue, 30 May 2023 17:07:42 +0800 From: Jie Hai To: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko CC: , Subject: [PATCH 09/10] ethdev: support telemetry query FEC info Date: Tue, 30 May 2023 17:05:09 +0800 Message-ID: <20230530090510.56812-10-haijie1@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230530090510.56812-1-haijie1@huawei.com> References: <20230530090510.56812-1-haijie1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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 getting FEC information by telemetry. The command is like: --> /ethdev/fec,0 { "/ethdev/fec": { "fec_mode": "off", "fec_capability": { "10_Gbps": "off auto baser" } } } Signed-off-by: Jie Hai --- lib/ethdev/rte_ethdev.c | 145 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index 6699b40d5e15..f7a84ae6c35d 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -160,6 +160,16 @@ enum { STAT_QMAP_RX }; +static const struct { + uint32_t capa; + const char *name; +} rte_eth_fec_capa_name[] = { + { RTE_ETH_FEC_MODE_CAPA_MASK(NOFEC), "off" }, + { RTE_ETH_FEC_MODE_CAPA_MASK(AUTO), "auto" }, + { RTE_ETH_FEC_MODE_CAPA_MASK(BASER), "baser" }, + { RTE_ETH_FEC_MODE_CAPA_MASK(RS), "rs" }, +}; + int rte_eth_iterator_init(struct rte_dev_iterator *iter, const char *devargs_str) { @@ -7516,6 +7526,139 @@ eth_dev_handle_port_rss_info(const char *cmd __rte_unused, return ret; } +static const char * +eth_dev_fec_capa_to_string(uint32_t fec_capa) +{ + uint32_t i; + + for (i = 0; i < RTE_DIM(rte_eth_fec_capa_name); i++) { + if ((fec_capa & rte_eth_fec_capa_name[i].capa) != 0) + return rte_eth_fec_capa_name[i].name; + } + + return "unknown"; +} + +static void +eth_dev_fec_capas_to_string(uint32_t fec_capa, char *fec_name, uint32_t len) +{ + bool valid = false; + size_t count = 0; + uint32_t i; + + for (i = 0; i < RTE_DIM(rte_eth_fec_capa_name); i++) { + if ((fec_capa & rte_eth_fec_capa_name[i].capa) != 0) { + strlcat(fec_name, rte_eth_fec_capa_name[i].name, len); + count = strlcat(fec_name, " ", len); + valid = true; + } + } + + if (!valid) + count = snprintf(fec_name, len, "unknown "); + + if (count >= len) { + RTE_ETHDEV_LOG(WARNING, "FEC capa names may be truncated\n"); + count = len; + } + + fec_name[count - 1] = '\0'; +} + +static int +eth_dev_get_fec_capability(uint16_t port_id, struct rte_tel_data *d) +{ + struct rte_eth_fec_capa *speed_fec_capa; + char fec_name[RTE_TEL_MAX_STRING_LEN]; + char speed[RTE_TEL_MAX_STRING_LEN]; + uint32_t capa_num; + uint32_t i, j; + int ret; + + ret = rte_eth_fec_get_capability(port_id, NULL, 0); + if (ret <= 0) + return ret == 0 ? -EINVAL : ret; + + capa_num = ret; + speed_fec_capa = calloc(capa_num, sizeof(struct rte_eth_fec_capa)); + if (speed_fec_capa == NULL) + return -ENOMEM; + + ret = rte_eth_fec_get_capability(port_id, speed_fec_capa, capa_num); + if (ret <= 0) { + ret = ret == 0 ? -EINVAL : ret; + goto out; + } + + for (i = 0; i < capa_num; i++) { + memset(fec_name, 0, RTE_TEL_MAX_STRING_LEN); + eth_dev_fec_capas_to_string(speed_fec_capa[i].capa, fec_name, + RTE_TEL_MAX_STRING_LEN); + + memset(speed, 0, RTE_TEL_MAX_STRING_LEN); + ret = snprintf(speed, RTE_TEL_MAX_STRING_LEN, "%s", + rte_eth_link_speed_to_str(speed_fec_capa[i].speed)); + if (ret < 0) + goto out; + + for (j = 0; j < strlen(speed); j++) { + if (speed[j] == ' ') + speed[j] = '_'; + } + + rte_tel_data_add_dict_string(d, speed, fec_name); + } + +out: + free(speed_fec_capa); + return ret > 0 ? 0 : ret; +} + +static int +eth_dev_handle_port_fec(const char *cmd __rte_unused, + const char *params, + struct rte_tel_data *d) +{ + struct rte_tel_data *fec_capas; + unsigned long port_id; + uint32_t fec_mode; + char *end_param; + int ret; + + if (params == NULL || strlen(params) == 0 || !isdigit(*params)) + return -EINVAL; + + port_id = strtoul(params, &end_param, 0); + if (*end_param != '\0') + RTE_ETHDEV_LOG(NOTICE, + "Extra parameters passed to ethdev telemetry command, ignoring\n"); + + if (port_id >= UINT16_MAX || !rte_eth_dev_is_valid_port(port_id)) + return -EINVAL; + + ret = rte_eth_fec_get(port_id, &fec_mode); + if (ret != 0) + return ret; + + rte_tel_data_start_dict(d); + rte_tel_data_add_dict_string(d, "fec_mode", + eth_dev_fec_capa_to_string(fec_mode)); + + fec_capas = rte_tel_data_alloc(); + if (fec_capas == NULL) + return -ENOMEM; + + rte_tel_data_start_dict(fec_capas); + ret = eth_dev_get_fec_capability(port_id, fec_capas); + if (ret != 0) { + rte_tel_data_free(fec_capas); + return ret; + } + + rte_tel_data_add_dict_container(d, "fec_capability", fec_capas, 0); + return 0; +} + RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO); RTE_INIT(ethdev_init_telemetry) @@ -7549,4 +7692,6 @@ RTE_INIT(ethdev_init_telemetry) "Returns DCB info for a port. Parameters: unsigned port_id"); rte_telemetry_register_cmd("/ethdev/rss_info", eth_dev_handle_port_rss_info, "Returns RSS info for a port. Parameters: unsigned port_id"); + rte_telemetry_register_cmd("/ethdev/fec", eth_dev_handle_port_fec, + "Returns FEC info for a port. Parameters: unsigned port_id"); } From patchwork Tue May 30 09:05:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 127698 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 2EE7242BE1; Tue, 30 May 2023 11:08:39 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3118F42D5A; Tue, 30 May 2023 11:07:52 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 1D94A42D36 for ; Tue, 30 May 2023 11:07:45 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4QVmdQ0ZhWzqTRC; Tue, 30 May 2023 17:03:06 +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; Tue, 30 May 2023 17:07:43 +0800 From: Jie Hai To: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko CC: , Subject: [PATCH 10/10] ethdev: support telemetry query VLAN info Date: Tue, 30 May 2023 17:05:10 +0800 Message-ID: <20230530090510.56812-11-haijie1@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20230530090510.56812-1-haijie1@huawei.com> References: <20230530090510.56812-1-haijie1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.69.192.56] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) 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 VLAN information by telemetry. The command is like: --> /ethdev/vlan,0 { "/ethdev/vlan": { "pvid": 0, "hw_vlan_reject_tagged": 0, "hw_vlan_reject_untagged": 0, "hw_vlan_insert_pvid": 0, "VLAN_STRIP": "off", "VLAN_EXTEND": "off", "QINQ_STRIP": "off", "VLAN_FILTER": "on", "vlan_num": 3, "vlan_ids": { "vlan_0_to_63": [ 1, 20 ], "vlan_192_to_255": [ 200 ] } } } Signed-off-by: Jie Hai --- lib/ethdev/rte_ethdev.c | 114 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c index f7a84ae6c35d..ba3484d8e870 100644 --- a/lib/ethdev/rte_ethdev.c +++ b/lib/ethdev/rte_ethdev.c @@ -7659,6 +7659,118 @@ eth_dev_handle_port_fec(const char *cmd __rte_unused, return 0; } +static int +eth_dev_add_vlan_id(int port_id, struct rte_tel_data *d) +{ + struct rte_tel_data *vlan_blks[64] = {NULL}; + uint16_t vlan_num, vidx, vbit, num_blks; + char blk_name[RTE_TEL_MAX_STRING_LEN]; + struct rte_vlan_filter_conf *vfc; + struct rte_tel_data *vlan_blk; + struct rte_tel_data *vd; + uint64_t bit_width; + uint64_t vlan_id; + + vd = rte_tel_data_alloc(); + if (vd == NULL) + return -ENOMEM; + + vfc = &rte_eth_devices[port_id].data->vlan_filter_conf; + bit_width = CHAR_BIT * sizeof(uint64_t); + vlan_num = 0; + num_blks = 0; + + rte_tel_data_start_dict(vd); + for (vidx = 0; vidx < RTE_DIM(vfc->ids); vidx++) { + if (vfc->ids[vidx] == 0) + continue; + + vlan_blk = rte_tel_data_alloc(); + if (vlan_blk == NULL) + goto free_all; + + vlan_blks[num_blks] = vlan_blk; + num_blks++; + snprintf(blk_name, RTE_TEL_MAX_STRING_LEN, "vlan_%lu_to_%lu", + bit_width * vidx, bit_width * (vidx + 1) - 1); + rte_tel_data_start_array(vlan_blk, RTE_TEL_UINT_VAL); + rte_tel_data_add_dict_container(vd, blk_name, vlan_blk, 0); + + for (vbit = 0; vbit < bit_width; vbit++) { + if ((vfc->ids[vidx] & RTE_BIT64(vbit)) == 0) + continue; + + vlan_id = bit_width * vidx + vbit; + rte_tel_data_add_array_uint(vlan_blk, vlan_id); + vlan_num++; + } + } + + rte_tel_data_add_dict_uint(d, "vlan_num", vlan_num); + rte_tel_data_add_dict_container(d, "vlan_ids", vd, 0); + + return 0; + +free_all: + while (num_blks-- > 0) + rte_tel_data_free(vlan_blks[num_blks]); + + rte_tel_data_free(vd); + return -ENOMEM; +} + +static int +eth_dev_handle_port_vlan(const char *cmd __rte_unused, + const char *params, + struct rte_tel_data *d) +{ + struct rte_eth_txmode *txmode; + struct rte_eth_conf dev_conf; + unsigned long port_id; + int offload, ret; + char *end_param; + + if (params == NULL || strlen(params) == 0 || !isdigit(*params)) + return -EINVAL; + + port_id = strtoul(params, &end_param, 0); + if (*end_param != '\0') + RTE_ETHDEV_LOG(NOTICE, + "Extra parameters passed to ethdev telemetry command, ignoring\n"); + + if (port_id >= UINT16_MAX || !rte_eth_dev_is_valid_port(port_id)) + return -EINVAL; + + ret = rte_eth_dev_conf_get(port_id, &dev_conf); + if (ret != 0) { + RTE_ETHDEV_LOG(ERR, + "Failed to get device configuration, ret = %d\n", ret); + return ret; + } + + txmode = &dev_conf.txmode; + rte_tel_data_start_dict(d); + rte_tel_data_add_dict_uint(d, "pvid", txmode->pvid); + rte_tel_data_add_dict_uint(d, "hw_vlan_reject_tagged", + txmode->hw_vlan_reject_tagged); + rte_tel_data_add_dict_uint(d, "hw_vlan_reject_untagged", + txmode->hw_vlan_reject_untagged); + rte_tel_data_add_dict_uint(d, "hw_vlan_insert_pvid", + txmode->hw_vlan_insert_pvid); + + offload = rte_eth_dev_get_vlan_offload(port_id); + rte_tel_data_add_dict_string(d, "VLAN_STRIP", + ((offload & RTE_ETH_VLAN_STRIP_OFFLOAD) != 0) ? "on" : "off"); + rte_tel_data_add_dict_string(d, "VLAN_EXTEND", + ((offload & RTE_ETH_VLAN_EXTEND_OFFLOAD) != 0) ? "on" : "off"); + rte_tel_data_add_dict_string(d, "QINQ_STRIP", + ((offload & RTE_ETH_QINQ_STRIP_OFFLOAD) != 0) ? "on" : "off"); + rte_tel_data_add_dict_string(d, "VLAN_FILTER", + ((offload & RTE_ETH_VLAN_FILTER_OFFLOAD) != 0) ? "on" : "off"); + + return eth_dev_add_vlan_id(port_id, d); +} + RTE_LOG_REGISTER_DEFAULT(rte_eth_dev_logtype, INFO); RTE_INIT(ethdev_init_telemetry) @@ -7694,4 +7806,6 @@ RTE_INIT(ethdev_init_telemetry) "Returns RSS info for a port. Parameters: unsigned port_id"); rte_telemetry_register_cmd("/ethdev/fec", eth_dev_handle_port_fec, "Returns FEC info for a port. Parameters: unsigned port_id"); + rte_telemetry_register_cmd("/ethdev/vlan", eth_dev_handle_port_vlan, + "Returns VLAN info for a port. Parameters: unsigned port_id"); }