From patchwork Wed Jun 7 07:41:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 128275 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 1AE2A42C4A; Wed, 7 Jun 2023 09:45:42 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B8C7E410FC; Wed, 7 Jun 2023 09:45:29 +0200 (CEST) Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by mails.dpdk.org (Postfix) with ESMTP id 39230427F5 for ; Wed, 7 Jun 2023 09:45:27 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4QbfV51c0dzlXGT; Wed, 7 Jun 2023 15:43:41 +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:23 +0800 From: Jie Hai To: Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko CC: , Subject: [PATCH v2 04/13] ethdev: support telemetry query MAC addresses Date: Wed, 7 Jun 2023 15:41:59 +0800 Message-ID: <20230607074209.4798-5-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 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 Signed-off-by: Jie Hai --- lib/ethdev/rte_ethdev_telemetry.c | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/lib/ethdev/rte_ethdev_telemetry.c b/lib/ethdev/rte_ethdev_telemetry.c index 5e70d0c2a66a..6ba7adf7d08f 100644 --- a/lib/ethdev/rte_ethdev_telemetry.c +++ b/lib/ethdev/rte_ethdev_telemetry.c @@ -327,6 +327,41 @@ eth_dev_handle_port_info(const char *cmd __rte_unused, return 0; } +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; + uint16_t port_id; + char *end_param; + uint32_t i; + int ret; + + ret = eth_dev_parse_port_params(params, &port_id, &end_param, false); + if (ret < 0) + return ret; + + 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_INIT(ethdev_init_telemetry) { rte_telemetry_register_cmd("/ethdev/list", eth_dev_handle_port_list, @@ -346,4 +381,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"); }