DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] app/testpmd: show mac addresses added to a port
@ 2019-11-25  8:27 Kalesh A P
  2019-12-03 11:59 ` Ferruh Yigit
  0 siblings, 1 reply; 3+ messages in thread
From: Kalesh A P @ 2019-11-25  8:27 UTC (permalink / raw)
  To: ferruh.yigit, wenzhuo.lu, jingjing.wu, bernard.iremonger; +Cc: dev

From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>

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 <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 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 <port_id> 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] app/testpmd: show mac addresses added to a port
  2019-11-25  8:27 [dpdk-dev] [PATCH] app/testpmd: show mac addresses added to a port Kalesh A P
@ 2019-12-03 11:59 ` Ferruh Yigit
  2019-12-03 12:01   ` Ferruh Yigit
  0 siblings, 1 reply; 3+ messages in thread
From: Ferruh Yigit @ 2019-12-03 11:59 UTC (permalink / raw)
  To: Kalesh A P, wenzhuo.lu, jingjing.wu, bernard.iremonger; +Cc: dev

On 11/25/2019 8:27 AM, Kalesh A P wrote:
> From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
> 
> 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 <kalesh-anakkur.purayil@broadcom.com>
> Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>

Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

> @@ -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
> +~~~~~~~~~~~~~~~~~~~~~~~~~~

Causing warning [1], will fix while merging.

[1]
WARNING: Title underline too short.

> +
> +Show mac addresses added for a specific port::
> +
> +   testpmd> show port (port_id) macs
> +
> +
> +show port mac addresses info
> +~~~~~~~~~~~~~~~~~~~~~~~~~~

's/mac addresses/multicast mac addresses', again I can fix while merging.

> +
> +Show multicast mac addresses added for a specific port::
> +
> +   testpmd> show port (port_id) mcast_macs
> +
>  show device info
>  ~~~~~~~~~~~~~~~~
>  
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] app/testpmd: show mac addresses added to a port
  2019-12-03 11:59 ` Ferruh Yigit
@ 2019-12-03 12:01   ` Ferruh Yigit
  0 siblings, 0 replies; 3+ messages in thread
From: Ferruh Yigit @ 2019-12-03 12:01 UTC (permalink / raw)
  To: Kalesh A P, wenzhuo.lu, jingjing.wu, bernard.iremonger; +Cc: dev

On 12/3/2019 11:59 AM, Ferruh Yigit wrote:
> On 11/25/2019 8:27 AM, Kalesh A P wrote:
>> From: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
>>
>> 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 <kalesh-anakkur.purayil@broadcom.com>
>> Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
> 
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied to dpdk-next-net/master, thanks.

(fixed doc warnings while merging.)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-12-03 12:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-25  8:27 [dpdk-dev] [PATCH] app/testpmd: show mac addresses added to a port Kalesh A P
2019-12-03 11:59 ` Ferruh Yigit
2019-12-03 12:01   ` Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).