From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 975A8A04C2; Mon, 25 Nov 2019 09:16:26 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 58D2637A2; Mon, 25 Nov 2019 09:16:26 +0100 (CET) Received: from relay.smtp.broadcom.com (unknown [192.19.211.62]) by dpdk.org (Postfix) with ESMTP id D1132378E for ; Mon, 25 Nov 2019 09:16:24 +0100 (CET) Received: from dhcp-10-123-153-22.dhcp.broadcom.net (bgccx-dev-host-lnx2.bec.broadcom.net [10.123.153.22]) by relay.smtp.broadcom.com (Postfix) with ESMTP id 746E828D189; Mon, 25 Nov 2019 00:16:23 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.10.3 relay.smtp.broadcom.com 746E828D189 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1574669783; bh=oqhS0epDxifm6iTSqy6LjLyyeh9fIKxCR2wpU7TVXiI=; h=From:To:Cc:Subject:Date:From; b=N2OUq6/g6kiE+u2HHNyhjgO6qxa8NCn48hMUeg02QmH/62yJhIgtY9vad0VrH2lY2 D50X9hkkCBOuFaoIzzthkYn6kFbooTv5W7wWl5+hOVv9RkxhTICWQ3E6DgSDYx5i0B gjcivbW+I5Pf04W8U0qCCGQ4OCuH9Ij08j0bvW/0= From: Kalesh A P To: ferruh.yigit@intel.com, wenzhuo.lu@intel.com, jingjing.wu@intel.com, bernard.iremonger@intel.com Cc: dev@dpdk.org Date: Mon, 25 Nov 2019 13:57:50 +0530 Message-Id: <20191125082750.10641-1-kalesh-anakkur.purayil@broadcom.com> X-Mailer: git-send-email 2.10.1 Subject: [dpdk-dev] [PATCH] app/testpmd: show mac addresses added to a port X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Kalesh AP Patch adds a runtime function to display the unicast and multicast MAC addresses added to a port. Syntax: show port (port_id) macs|mcast_macs Usage: testpmd> show port 0 macs Number of MAC address added: 1 B0:26:28:7F:F5:C1 testpmd> testpmd> show port 0 mcast_macs Number of Multicast MAC address added: 0 testpmd> testpmd> mac_addr add 0 B0:26:28:7F:22:33 testpmd> mac_addr add 0 B0:26:28:7F:22:34 testpmd> show port 0 macs Number of MAC address added: 3 B0:26:28:7F:F5:C1 B0:26:28:7F:22:33 B0:26:28:7F:22:34 testpmd> testpmd> mac_addr remove 0 B0:26:28:7F:22:33 testpmd> show port 0 macs Number of MAC address added: 2 B0:26:28:7F:F5:C1 B0:26:28:7F:22:34 Signed-off-by: Kalesh AP Reviewed-by: Ajit Khaparde --- app/test-pmd/cmdline.c | 54 +++++++++++++++++++++++++++ app/test-pmd/config.c | 57 +++++++++++++++++++++++++++++ app/test-pmd/testpmd.h | 3 ++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 15 ++++++++ 4 files changed, 129 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 9f3e0b2..2d74df8 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -241,6 +241,9 @@ static void cmd_help_long_parsed(void *parsed_result, "show port (port_id) rxq|txq (queue_id) desc (desc_id) status" " Show status of rx|tx descriptor.\n\n" + + "show port (port_id) macs|mcast_macs" + " Display list of mac addresses added to port.\n\n" ); } @@ -19171,6 +19174,56 @@ cmdline_parse_inst_t cmd_set_port_ptypes = { }, }; +/* *** display mac addresses added to a port *** */ +struct cmd_showport_macs_result { + cmdline_fixed_string_t cmd_show; + cmdline_fixed_string_t cmd_port; + cmdline_fixed_string_t cmd_keyword; + portid_t cmd_pid; +}; + +static void +cmd_showport_macs_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_showport_macs_result *res = parsed_result; + + if (port_id_is_invalid(res->cmd_pid, ENABLED_WARN)) + return; + + if (!strcmp(res->cmd_keyword, "macs")) + show_macs(res->cmd_pid); + else if (!strcmp(res->cmd_keyword, "mcast_macs")) + show_mcast_macs(res->cmd_pid); +} + +cmdline_parse_token_string_t cmd_showport_macs_show = + TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result, + cmd_show, "show"); +cmdline_parse_token_string_t cmd_showport_macs_port = + TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result, + cmd_port, "port"); +cmdline_parse_token_num_t cmd_showport_macs_pid = + TOKEN_NUM_INITIALIZER(struct cmd_showport_macs_result, + cmd_pid, UINT16); +cmdline_parse_token_string_t cmd_showport_macs_keyword = + TOKEN_STRING_INITIALIZER(struct cmd_showport_macs_result, + cmd_keyword, "macs#mcast_macs"); + +cmdline_parse_inst_t cmd_showport_macs = { + .f = cmd_showport_macs_parsed, + .data = NULL, + .help_str = "show port macs|mcast_macs", + .tokens = { + (void *)&cmd_showport_macs_show, + (void *)&cmd_showport_macs_port, + (void *)&cmd_showport_macs_pid, + (void *)&cmd_showport_macs_keyword, + NULL, + }, +}; + /* ******************************************************************************** */ /* list of instructions */ @@ -19289,6 +19342,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_setup_rxtx_queue, (cmdline_parse_inst_t *)&cmd_config_rss_reta, (cmdline_parse_inst_t *)&cmd_showport_reta, + (cmdline_parse_inst_t *)&cmd_showport_macs, (cmdline_parse_inst_t *)&cmd_config_burst, (cmdline_parse_inst_t *)&cmd_config_thresh, (cmdline_parse_inst_t *)&cmd_config_threshold, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index d599682..4e1c3ca 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -3965,3 +3965,60 @@ port_queue_region_info_display(portid_t port_id, void *buf) printf("\n\n"); } + +void +show_macs(portid_t port_id) +{ + char buf[RTE_ETHER_ADDR_FMT_SIZE]; + struct rte_eth_dev_info dev_info; + struct rte_ether_addr *addr; + uint32_t i, num_macs = 0; + struct rte_eth_dev *dev; + + dev = &rte_eth_devices[port_id]; + + rte_eth_dev_info_get(port_id, &dev_info); + + for (i = 0; i < dev_info.max_mac_addrs; i++) { + addr = &dev->data->mac_addrs[i]; + + /* skip zero address */ + if (rte_is_zero_ether_addr(addr)) + continue; + + num_macs++; + } + + printf("Number of MAC address added: %d\n", num_macs); + + for (i = 0; i < dev_info.max_mac_addrs; i++) { + addr = &dev->data->mac_addrs[i]; + + /* skip zero address */ + if (rte_is_zero_ether_addr(addr)) + continue; + + rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, addr); + printf(" %s\n", buf); + } +} + +void +show_mcast_macs(portid_t port_id) +{ + char buf[RTE_ETHER_ADDR_FMT_SIZE]; + struct rte_ether_addr *addr; + struct rte_port *port; + uint32_t i; + + port = &ports[port_id]; + + printf("Number of Multicast MAC address added: %d\n", port->mc_addr_nb); + + for (i = 0; i < port->mc_addr_nb; i++) { + addr = &port->mc_addr_pool[i]; + + rte_ether_format_addr(buf, RTE_ETHER_ADDR_FMT_SIZE, addr); + printf(" %s\n", buf); + } +} diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 217d577..857a11f 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -835,6 +835,9 @@ int eth_link_get_nowait_print_err(uint16_t port_id, struct rte_eth_link *link); int eth_macaddr_get_print_err(uint16_t port_id, struct rte_ether_addr *mac_addr); +/* Functions to display the set of MAC addresses added to a port*/ +void show_macs(portid_t port_id); +void show_mcast_macs(portid_t port_id); /* Functions to manage the set of filtered Multicast MAC addresses */ void mcast_addr_add(portid_t port_id, struct rte_ether_addr *mc_addr); diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 73ef0b4..f71b0d8 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -487,6 +487,21 @@ set packet types classification for a specific port:: testpmd> set port (port_id) ptypes_mask (mask) +show port mac addresses info +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Show mac addresses added for a specific port:: + + testpmd> show port (port_id) macs + + +show port mac addresses info +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Show multicast mac addresses added for a specific port:: + + testpmd> show port (port_id) mcast_macs + show device info ~~~~~~~~~~~~~~~~ -- 2.10.1