DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Min Hu (Connor)" <humin29@huawei.com>
To: <dev@dpdk.org>
Cc: <ferruh.yigit@intel.com>, <xiaoyun.li@intel.com>
Subject: [dpdk-dev] [PATCH v2] app/testpmd: support the query of link flow ctrl info
Date: Mon, 19 Apr 2021 16:28:18 +0800	[thread overview]
Message-ID: <1618820898-8531-1-git-send-email-humin29@huawei.com> (raw)
In-Reply-To: <1618469214-35316-1-git-send-email-humin29@huawei.com>

From: Huisong Li <lihuisong@huawei.com>

This patch supports the query of the link flow control parameter
on a port.

The command format is as follows:
show port <port_id> flow_ctrl

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 app/test-pmd/cmdline.c                      | 83 +++++++++++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  7 +++
 2 files changed, 90 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 31884c5..06a6503 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -258,6 +258,9 @@ static void cmd_help_long_parsed(void *parsed_result,
 
 			"show port (port_id) fec_mode"
 			"	Show fec mode of a port.\n\n"
+
+			"show port <port_id> flow_ctrl"
+			"	Show flow control info of a port.\n\n"
 		);
 	}
 
@@ -6899,6 +6902,85 @@ cmdline_parse_inst_t cmd_set_allmulti_mode_one = {
 	},
 };
 
+/* *** GET CURRENT ETHERNET LINK FLOW CONTROL *** */
+struct cmd_link_flow_ctrl_show {
+	cmdline_fixed_string_t show;
+	cmdline_fixed_string_t port;
+	portid_t port_id;
+	cmdline_fixed_string_t flow_ctrl;
+};
+
+cmdline_parse_token_string_t cmd_lfc_show_show =
+	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
+				show, "show");
+cmdline_parse_token_string_t cmd_lfc_show_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
+				port, "port");
+cmdline_parse_token_num_t cmd_lfc_show_portid =
+	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_show,
+				port_id, RTE_UINT16);
+cmdline_parse_token_string_t cmd_lfc_show_flow_ctrl =
+	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_show,
+				flow_ctrl, "flow_ctrl");
+
+static void
+cmd_link_flow_ctrl_show_parsed(void *parsed_result,
+			      __rte_unused struct cmdline *cl,
+			      __rte_unused void *data)
+{
+	struct cmd_link_flow_ctrl_show *res = parsed_result;
+	static const char *info_border = "*********************";
+	struct rte_eth_fc_conf fc_conf;
+	bool rx_fc_en = false;
+	bool tx_fc_en = false;
+	int ret;
+
+	if (!rte_eth_dev_is_valid_port(res->port_id)) {
+		printf("Invalid port id %u\n", res->port_id);
+		return;
+	}
+
+	ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
+	if (ret != 0) {
+		printf("Failed to get current flow ctrl information: err = %d\n",
+		       ret);
+		return;
+	}
+
+	if ((fc_conf.mode == RTE_FC_RX_PAUSE) || (fc_conf.mode == RTE_FC_FULL))
+		rx_fc_en = true;
+	if ((fc_conf.mode == RTE_FC_TX_PAUSE) || (fc_conf.mode == RTE_FC_FULL))
+		tx_fc_en = true;
+
+	printf("\n%s Flow control infos for port %-2d %s\n",
+		info_border, res->port_id, info_border);
+	printf("FC mode:\n");
+	printf("   Rx: %s\n", rx_fc_en ? "On" : "Off");
+	printf("   Tx: %s\n", tx_fc_en ? "On" : "Off");
+	printf("FC autoneg status: %s\n", fc_conf.autoneg ? "On" : "Off");
+	printf("pause_time: 0x%x\n", fc_conf.pause_time);
+	printf("high_water: 0x%x\n", fc_conf.high_water);
+	printf("low_water: 0x%x\n", fc_conf.low_water);
+	printf("Send Xon: %s\n", fc_conf.send_xon ? "On" : "Off");
+	printf("Forward MAC control frames: %s\n",
+		fc_conf.mac_ctrl_frame_fwd ? "On" : "Off");
+	printf("\n%s**************   End  ***********%s\n",
+		info_border, info_border);
+}
+
+cmdline_parse_inst_t cmd_link_flow_control_show = {
+	.f = cmd_link_flow_ctrl_show_parsed,
+	.data = NULL,
+	.help_str = "show port <port_id> flow_ctrl",
+	.tokens = {
+		(void *)&cmd_lfc_show_show,
+		(void *)&cmd_lfc_show_port,
+		(void *)&cmd_lfc_show_portid,
+		(void *)&cmd_lfc_show_flow_ctrl,
+		NULL,
+	},
+};
+
 /* *** SETUP ETHERNET LINK FLOW CONTROL *** */
 struct cmd_link_flow_ctrl_set_result {
 	cmdline_fixed_string_t set;
@@ -17037,6 +17119,7 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_xon,
 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_macfwd,
 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_autoneg,
+	(cmdline_parse_inst_t *)&cmd_link_flow_control_show,
 	(cmdline_parse_inst_t *)&cmd_priority_flow_control_set,
 	(cmdline_parse_inst_t *)&cmd_config_dcb,
 	(cmdline_parse_inst_t *)&cmd_read_reg,
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 9854b70..a7dbaf2 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -1524,6 +1524,13 @@ Where:
 
 * ``autoneg``: Change the auto-negotiation parameter.
 
+show flow ctrl
+~~~~~~~~~~~~~~
+
+show the link flow control parameter on a port::
+
+   testpmd> show port <port_id> flow_ctrl
+
 set pfc_ctrl rx
 ~~~~~~~~~~~~~~~
 
-- 
2.7.4


  parent reply	other threads:[~2021-04-19  8:28 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-15  6:46 [dpdk-dev] [PATCH] " Min Hu (Connor)
2021-04-19  2:53 ` Li, Xiaoyun
2021-04-19  6:40   ` Min Hu (Connor)
2021-04-19  8:04     ` Li, Xiaoyun
2021-04-19  8:28       ` Min Hu (Connor)
2021-04-19  8:28 ` Min Hu (Connor) [this message]
2021-04-20  0:10   ` [dpdk-dev] [PATCH v2] " Ferruh Yigit
2021-04-20  1:34   ` Li, Xiaoyun
2021-04-20  1:48     ` Ferruh Yigit
2021-04-19 15:30 ` [dpdk-dev] [PATCH] " Kevin Traynor
2021-04-21  6:18   ` Huisong Li
2021-04-21  7:56     ` Ferruh Yigit
2021-04-21  8:05       ` Ferruh Yigit
2021-04-21  9:42         ` Min Hu (Connor)
2021-04-21  9:41 ` [dpdk-dev] [PATCH v3] " Min Hu (Connor)
2021-04-21 11:12   ` Kevin Traynor
2021-04-21 11:36     ` Ferruh Yigit
2021-04-21 11:41       ` Ferruh Yigit
2021-04-21 11:42   ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1618820898-8531-1-git-send-email-humin29@huawei.com \
    --to=humin29@huawei.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=xiaoyun.li@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).