DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/3] fix flow control in testpmd
@ 2014-06-24 13:06 David Marchand
  2014-06-24 13:06 ` [dpdk-dev] [PATCH 1/3] app/testpmd: add missing autoneg field to set flow_ctrl David Marchand
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: David Marchand @ 2014-06-24 13:06 UTC (permalink / raw)
  To: dev

Here is a patchset that addresses the problem reported by Jijiang Liu and
introduces "partial" commands for setting flow control parameters in testpmd.

By the way, I tried to factorise the code in testpmd when handling flow control
"commands" so that we have only one parser even if multiple commands are
supported.

-- 
David Marchand

David Marchand (3):
  app/testpmd: add missing autoneg field to set flow_ctrl
  app/testpmd: move parser after flow_ctrl declarations
  app/testpmd: allow to set part of flow control parameters

 app/test-pmd/cmdline.c |  280 +++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 242 insertions(+), 38 deletions(-)

-- 
1.7.10.4

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

* [dpdk-dev] [PATCH 1/3] app/testpmd: add missing autoneg field to set flow_ctrl
  2014-06-24 13:06 [dpdk-dev] [PATCH 0/3] fix flow control in testpmd David Marchand
@ 2014-06-24 13:06 ` David Marchand
  2014-06-24 13:06 ` [dpdk-dev] [PATCH 2/3] app/testpmd: move parser after flow_ctrl declarations David Marchand
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: David Marchand @ 2014-06-24 13:06 UTC (permalink / raw)
  To: dev

Following commit 2d95b84aaacb3d2d0bd70367c0530d15e0cbb14e, rte_eth_fc_conf
struct contains a autoneg field that must be set by callers.
Add this parameter to testpmd.

Signed-off-by: David Marchand <david.marchand@6wind.com>
---
 app/test-pmd/cmdline.c |   15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 3298360..3d2a91a 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -326,7 +326,7 @@ static void cmd_help_long_parsed(void *parsed_result,
 
 			"set flow_ctrl rx (on|off) tx (on|off) (high_water)"
 			" (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
-                        " (on|off) (port_id)\n"
+			" (on|off) autoneg (on|off) (port_id)\n"
 			"    Set the link flow control parameter on a port.\n\n"
 
 			"set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
@@ -3814,6 +3814,8 @@ struct cmd_link_flow_ctrl_set_result {
 	cmdline_fixed_string_t tx_lfc_mode;
 	cmdline_fixed_string_t mac_ctrl_frame_fwd;
 	cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
+	cmdline_fixed_string_t autoneg_str;
+	cmdline_fixed_string_t autoneg;
 	uint32_t high_water;
 	uint32_t low_water;
 	uint16_t pause_time;
@@ -3851,6 +3853,7 @@ cmd_link_flow_ctrl_set_parsed(void *parsed_result,
 	fc_conf.pause_time = res->pause_time;
 	fc_conf.send_xon   = res->send_xon;
 	fc_conf.mac_ctrl_frame_fwd = (uint8_t)mac_ctrl_frame_fwd;
+	fc_conf.autoneg    = (!strcmp(res->autoneg, "on")) ? 1 : 0;
 
 	ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
 	if (ret != 0)
@@ -3893,6 +3896,12 @@ cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd_mode =
 cmdline_parse_token_string_t cmd_lfc_set_mac_ctrl_frame_fwd =
 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
 				mac_ctrl_frame_fwd_mode, "on#off");
+cmdline_parse_token_string_t cmd_lfc_set_autoneg_str =
+	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
+				autoneg_str, "autoneg");
+cmdline_parse_token_string_t cmd_lfc_set_autoneg =
+	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
+				autoneg, "on#off");
 cmdline_parse_token_num_t cmd_lfc_set_portid =
 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
 				port_id, UINT8);
@@ -3902,7 +3911,7 @@ cmdline_parse_inst_t cmd_link_flow_control_set = {
 	.data = NULL,
 	.help_str = "Configure the Ethernet flow control: set flow_ctrl rx on|off \
 tx on|off high_water low_water pause_time send_xon mac_ctrl_frame_fwd on|off \
-port_id",
+autoneg on|off port_id",
 	.tokens = {
 		(void *)&cmd_lfc_set_set,
 		(void *)&cmd_lfc_set_flow_ctrl,
@@ -3916,6 +3925,8 @@ port_id",
 		(void *)&cmd_lfc_set_send_xon,
 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
 		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
+		(void *)&cmd_lfc_set_autoneg_str,
+		(void *)&cmd_lfc_set_autoneg,
 		(void *)&cmd_lfc_set_portid,
 		NULL,
 	},
-- 
1.7.10.4

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

* [dpdk-dev] [PATCH 2/3] app/testpmd: move parser after flow_ctrl declarations
  2014-06-24 13:06 [dpdk-dev] [PATCH 0/3] fix flow control in testpmd David Marchand
  2014-06-24 13:06 ` [dpdk-dev] [PATCH 1/3] app/testpmd: add missing autoneg field to set flow_ctrl David Marchand
@ 2014-06-24 13:06 ` David Marchand
  2014-06-24 13:06 ` [dpdk-dev] [PATCH 3/3] app/testpmd: allow to set part of flow control parameters David Marchand
  2014-06-27  0:59 ` [dpdk-dev] [PATCH 0/3] fix flow control in testpmd Thomas Monjalon
  3 siblings, 0 replies; 5+ messages in thread
From: David Marchand @ 2014-06-24 13:06 UTC (permalink / raw)
  To: dev

Prepare for next commit.

Signed-off-by: David Marchand <david.marchand@6wind.com>
---
 app/test-pmd/cmdline.c |   74 ++++++++++++++++++++++++------------------------
 1 file changed, 37 insertions(+), 37 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 3d2a91a..8b85d4d 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -3823,43 +3823,6 @@ struct cmd_link_flow_ctrl_set_result {
 	uint8_t  port_id;
 };
 
-static void
-cmd_link_flow_ctrl_set_parsed(void *parsed_result,
-		       __attribute__((unused)) struct cmdline *cl,
-		       __attribute__((unused)) void *data)
-{
-	struct cmd_link_flow_ctrl_set_result *res = parsed_result;
-	struct rte_eth_fc_conf fc_conf;
-	int rx_fc_enable, tx_fc_enable, mac_ctrl_frame_fwd;
-	int ret;
-
-	/*
-	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
-	 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
-	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
-	 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
-	 */
-	static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
-			{RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
-	};
-
-	rx_fc_enable = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
-	tx_fc_enable = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
-	mac_ctrl_frame_fwd = (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) ? 1 : 0;
-
-	fc_conf.mode       = rx_tx_onoff_2_lfc_mode[rx_fc_enable][tx_fc_enable];
-	fc_conf.high_water = res->high_water;
-	fc_conf.low_water  = res->low_water;
-	fc_conf.pause_time = res->pause_time;
-	fc_conf.send_xon   = res->send_xon;
-	fc_conf.mac_ctrl_frame_fwd = (uint8_t)mac_ctrl_frame_fwd;
-	fc_conf.autoneg    = (!strcmp(res->autoneg, "on")) ? 1 : 0;
-
-	ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
-	if (ret != 0)
-		printf("bad flow contrl parameter, return code = %d \n", ret);
-}
-
 cmdline_parse_token_string_t cmd_lfc_set_set =
 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
 				set, "set");
@@ -3932,6 +3895,43 @@ autoneg on|off port_id",
 	},
 };
 
+static void
+cmd_link_flow_ctrl_set_parsed(void *parsed_result,
+		       __attribute__((unused)) struct cmdline *cl,
+		       __attribute__((unused)) void *data)
+{
+	struct cmd_link_flow_ctrl_set_result *res = parsed_result;
+	struct rte_eth_fc_conf fc_conf;
+	int rx_fc_enable, tx_fc_enable, mac_ctrl_frame_fwd;
+	int ret;
+
+	/*
+	 * Rx on/off, flow control is enabled/disabled on RX side. This can indicate
+	 * the RTE_FC_TX_PAUSE, Transmit pause frame at the Rx side.
+	 * Tx on/off, flow control is enabled/disabled on TX side. This can indicate
+	 * the RTE_FC_RX_PAUSE, Respond to the pause frame at the Tx side.
+	 */
+	static enum rte_eth_fc_mode rx_tx_onoff_2_lfc_mode[2][2] = {
+			{RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
+	};
+
+	rx_fc_enable = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
+	tx_fc_enable = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
+	mac_ctrl_frame_fwd = (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) ? 1 : 0;
+
+	fc_conf.mode       = rx_tx_onoff_2_lfc_mode[rx_fc_enable][tx_fc_enable];
+	fc_conf.high_water = res->high_water;
+	fc_conf.low_water  = res->low_water;
+	fc_conf.pause_time = res->pause_time;
+	fc_conf.send_xon   = res->send_xon;
+	fc_conf.mac_ctrl_frame_fwd = (uint8_t)mac_ctrl_frame_fwd;
+	fc_conf.autoneg    = (!strcmp(res->autoneg, "on")) ? 1 : 0;
+
+	ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
+	if (ret != 0)
+		printf("bad flow contrl parameter, return code = %d \n", ret);
+}
+
 /* *** SETUP ETHERNET PIRORITY FLOW CONTROL *** */
 struct cmd_priority_flow_ctrl_set_result {
 	cmdline_fixed_string_t set;
-- 
1.7.10.4

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

* [dpdk-dev] [PATCH 3/3] app/testpmd: allow to set part of flow control parameters
  2014-06-24 13:06 [dpdk-dev] [PATCH 0/3] fix flow control in testpmd David Marchand
  2014-06-24 13:06 ` [dpdk-dev] [PATCH 1/3] app/testpmd: add missing autoneg field to set flow_ctrl David Marchand
  2014-06-24 13:06 ` [dpdk-dev] [PATCH 2/3] app/testpmd: move parser after flow_ctrl declarations David Marchand
@ 2014-06-24 13:06 ` David Marchand
  2014-06-27  0:59 ` [dpdk-dev] [PATCH 0/3] fix flow control in testpmd Thomas Monjalon
  3 siblings, 0 replies; 5+ messages in thread
From: David Marchand @ 2014-06-24 13:06 UTC (permalink / raw)
  To: dev

We might want to only change a parameter rather than have to set all possible
parameters, so add "partial" commands.
These commands only change the specified parameter.

To avoid duplicating code all around, a unique parser is kept. This parser uses
the .data parameter to select the right behavior.

Signed-off-by: David Marchand <david.marchand@6wind.com>
---
 app/test-pmd/cmdline.c |  219 +++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 206 insertions(+), 13 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 8b85d4d..ba8ca13 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -327,6 +327,14 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"set flow_ctrl rx (on|off) tx (on|off) (high_water)"
 			" (low_water) (pause_time) (send_xon) mac_ctrl_frame_fwd"
 			" (on|off) autoneg (on|off) (port_id)\n"
+			"set flow_ctrl rx (on|off) (portid)\n"
+			"set flow_ctrl tx (on|off) (portid)\n"
+			"set flow_ctrl high_water (high_water) (portid)\n"
+			"set flow_ctrl low_water (low_water) (portid)\n"
+			"set flow_ctrl pause_time (pause_time) (portid)\n"
+			"set flow_ctrl send_xon (send_xon) (portid)\n"
+			"set flow_ctrl mac_ctrl_frame_fwd (on|off) (portid)\n"
+			"set flow_ctrl autoneg (on|off) (port_id)\n"
 			"    Set the link flow control parameter on a port.\n\n"
 
 			"set pfc_ctrl rx (on|off) tx (on|off) (high_water)"
@@ -3816,9 +3824,13 @@ struct cmd_link_flow_ctrl_set_result {
 	cmdline_fixed_string_t mac_ctrl_frame_fwd_mode;
 	cmdline_fixed_string_t autoneg_str;
 	cmdline_fixed_string_t autoneg;
+	cmdline_fixed_string_t hw_str;
 	uint32_t high_water;
+	cmdline_fixed_string_t lw_str;
 	uint32_t low_water;
+	cmdline_fixed_string_t pt_str;
 	uint16_t pause_time;
+	cmdline_fixed_string_t xon_str;
 	uint16_t send_xon;
 	uint8_t  port_id;
 };
@@ -3841,15 +3853,27 @@ cmdline_parse_token_string_t cmd_lfc_set_tx =
 cmdline_parse_token_string_t cmd_lfc_set_tx_mode =
 	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
 				tx_lfc_mode, "on#off");
+cmdline_parse_token_string_t cmd_lfc_set_high_water_str =
+	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
+				hw_str, "high_water");
 cmdline_parse_token_num_t cmd_lfc_set_high_water =
 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
 				high_water, UINT32);
+cmdline_parse_token_string_t cmd_lfc_set_low_water_str =
+	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
+				lw_str, "low_water");
 cmdline_parse_token_num_t cmd_lfc_set_low_water =
 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
 				low_water, UINT32);
+cmdline_parse_token_string_t cmd_lfc_set_pause_time_str =
+	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
+				pt_str, "pause_time");
 cmdline_parse_token_num_t cmd_lfc_set_pause_time =
 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
 				pause_time, UINT16);
+cmdline_parse_token_string_t cmd_lfc_set_send_xon_str =
+	TOKEN_STRING_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
+				xon_str, "send_xon");
 cmdline_parse_token_num_t cmd_lfc_set_send_xon =
 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
 				send_xon, UINT16);
@@ -3869,6 +3893,11 @@ cmdline_parse_token_num_t cmd_lfc_set_portid =
 	TOKEN_NUM_INITIALIZER(struct cmd_link_flow_ctrl_set_result,
 				port_id, UINT8);
 
+/* forward declaration */
+static void
+cmd_link_flow_ctrl_set_parsed(void *parsed_result, struct cmdline *cl,
+			      void *data);
+
 cmdline_parse_inst_t cmd_link_flow_control_set = {
 	.f = cmd_link_flow_ctrl_set_parsed,
 	.data = NULL,
@@ -3895,14 +3924,135 @@ autoneg on|off port_id",
 	},
 };
 
+cmdline_parse_inst_t cmd_link_flow_control_set_rx = {
+	.f = cmd_link_flow_ctrl_set_parsed,
+	.data = (void *)&cmd_link_flow_control_set_rx,
+	.help_str = "Change rx flow control parameter: set flow_ctrl "
+		    "rx on|off port_id",
+	.tokens = {
+		(void *)&cmd_lfc_set_set,
+		(void *)&cmd_lfc_set_flow_ctrl,
+		(void *)&cmd_lfc_set_rx,
+		(void *)&cmd_lfc_set_rx_mode,
+		(void *)&cmd_lfc_set_portid,
+		NULL,
+	},
+};
+
+cmdline_parse_inst_t cmd_link_flow_control_set_tx = {
+	.f = cmd_link_flow_ctrl_set_parsed,
+	.data = (void *)&cmd_link_flow_control_set_tx,
+	.help_str = "Change tx flow control parameter: set flow_ctrl "
+		    "tx on|off port_id",
+	.tokens = {
+		(void *)&cmd_lfc_set_set,
+		(void *)&cmd_lfc_set_flow_ctrl,
+		(void *)&cmd_lfc_set_tx,
+		(void *)&cmd_lfc_set_tx_mode,
+		(void *)&cmd_lfc_set_portid,
+		NULL,
+	},
+};
+
+cmdline_parse_inst_t cmd_link_flow_control_set_hw = {
+	.f = cmd_link_flow_ctrl_set_parsed,
+	.data = (void *)&cmd_link_flow_control_set_hw,
+	.help_str = "Change high water flow control parameter: set flow_ctrl "
+		    "high_water value port_id",
+	.tokens = {
+		(void *)&cmd_lfc_set_set,
+		(void *)&cmd_lfc_set_flow_ctrl,
+		(void *)&cmd_lfc_set_high_water_str,
+		(void *)&cmd_lfc_set_high_water,
+		(void *)&cmd_lfc_set_portid,
+		NULL,
+	},
+};
+
+cmdline_parse_inst_t cmd_link_flow_control_set_lw = {
+	.f = cmd_link_flow_ctrl_set_parsed,
+	.data = (void *)&cmd_link_flow_control_set_lw,
+	.help_str = "Change low water flow control parameter: set flow_ctrl "
+		    "low_water value port_id",
+	.tokens = {
+		(void *)&cmd_lfc_set_set,
+		(void *)&cmd_lfc_set_flow_ctrl,
+		(void *)&cmd_lfc_set_low_water_str,
+		(void *)&cmd_lfc_set_low_water,
+		(void *)&cmd_lfc_set_portid,
+		NULL,
+	},
+};
+
+cmdline_parse_inst_t cmd_link_flow_control_set_pt = {
+	.f = cmd_link_flow_ctrl_set_parsed,
+	.data = (void *)&cmd_link_flow_control_set_pt,
+	.help_str = "Change pause time flow control parameter: set flow_ctrl "
+		    "pause_time value port_id",
+	.tokens = {
+		(void *)&cmd_lfc_set_set,
+		(void *)&cmd_lfc_set_flow_ctrl,
+		(void *)&cmd_lfc_set_pause_time_str,
+		(void *)&cmd_lfc_set_pause_time,
+		(void *)&cmd_lfc_set_portid,
+		NULL,
+	},
+};
+
+cmdline_parse_inst_t cmd_link_flow_control_set_xon = {
+	.f = cmd_link_flow_ctrl_set_parsed,
+	.data = (void *)&cmd_link_flow_control_set_xon,
+	.help_str = "Change send_xon flow control parameter: set flow_ctrl "
+		    "send_xon value port_id",
+	.tokens = {
+		(void *)&cmd_lfc_set_set,
+		(void *)&cmd_lfc_set_flow_ctrl,
+		(void *)&cmd_lfc_set_send_xon_str,
+		(void *)&cmd_lfc_set_send_xon,
+		(void *)&cmd_lfc_set_portid,
+		NULL,
+	},
+};
+
+cmdline_parse_inst_t cmd_link_flow_control_set_macfwd = {
+	.f = cmd_link_flow_ctrl_set_parsed,
+	.data = (void *)&cmd_link_flow_control_set_macfwd,
+	.help_str = "Change mac ctrl fwd flow control parameter: set flow_ctrl "
+		    "mac_ctrl_frame_fwd on|off port_id",
+	.tokens = {
+		(void *)&cmd_lfc_set_set,
+		(void *)&cmd_lfc_set_flow_ctrl,
+		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd_mode,
+		(void *)&cmd_lfc_set_mac_ctrl_frame_fwd,
+		(void *)&cmd_lfc_set_portid,
+		NULL,
+	},
+};
+
+cmdline_parse_inst_t cmd_link_flow_control_set_autoneg = {
+	.f = cmd_link_flow_ctrl_set_parsed,
+	.data = (void *)&cmd_link_flow_control_set_autoneg,
+	.help_str = "Change autoneg flow control parameter: set flow_ctrl "
+		    "autoneg on|off port_id",
+	.tokens = {
+		(void *)&cmd_lfc_set_set,
+		(void *)&cmd_lfc_set_flow_ctrl,
+		(void *)&cmd_lfc_set_autoneg_str,
+		(void *)&cmd_lfc_set_autoneg,
+		(void *)&cmd_lfc_set_portid,
+		NULL,
+	},
+};
+
 static void
 cmd_link_flow_ctrl_set_parsed(void *parsed_result,
-		       __attribute__((unused)) struct cmdline *cl,
-		       __attribute__((unused)) void *data)
+			      __attribute__((unused)) struct cmdline *cl,
+			      void *data)
 {
 	struct cmd_link_flow_ctrl_set_result *res = parsed_result;
+	cmdline_parse_inst_t *cmd = data;
 	struct rte_eth_fc_conf fc_conf;
-	int rx_fc_enable, tx_fc_enable, mac_ctrl_frame_fwd;
+	int rx_fc_en, tx_fc_en;
 	int ret;
 
 	/*
@@ -3915,17 +4065,52 @@ cmd_link_flow_ctrl_set_parsed(void *parsed_result,
 			{RTE_FC_NONE, RTE_FC_TX_PAUSE}, {RTE_FC_RX_PAUSE, RTE_FC_FULL}
 	};
 
-	rx_fc_enable = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
-	tx_fc_enable = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
-	mac_ctrl_frame_fwd = (!strcmp(res->mac_ctrl_frame_fwd_mode, "on")) ? 1 : 0;
+	/* Partial command line, retrieve current configuration */
+	if (cmd) {
+		ret = rte_eth_dev_flow_ctrl_get(res->port_id, &fc_conf);
+		if (ret != 0) {
+			printf("cannot get current flow ctrl parameters, return"
+			       "code = %d\n", ret);
+			return;
+		}
+
+		if ((fc_conf.mode == RTE_FC_RX_PAUSE) ||
+		    (fc_conf.mode == RTE_FC_FULL))
+			rx_fc_en = 1;
+		if ((fc_conf.mode == RTE_FC_TX_PAUSE) ||
+		    (fc_conf.mode == RTE_FC_FULL))
+			tx_fc_en = 1;
+	}
+
+	if (!cmd || cmd == &cmd_link_flow_control_set_rx)
+		rx_fc_en = (!strcmp(res->rx_lfc_mode, "on")) ? 1 : 0;
+
+	if (!cmd || cmd == &cmd_link_flow_control_set_tx)
+		tx_fc_en = (!strcmp(res->tx_lfc_mode, "on")) ? 1 : 0;
+
+	fc_conf.mode = rx_tx_onoff_2_lfc_mode[rx_fc_en][tx_fc_en];
+
+	if (!cmd || cmd == &cmd_link_flow_control_set_hw)
+		fc_conf.high_water = res->high_water;
+
+	if (!cmd || cmd == &cmd_link_flow_control_set_lw)
+		fc_conf.low_water = res->low_water;
+
+	if (!cmd || cmd == &cmd_link_flow_control_set_pt)
+		fc_conf.pause_time = res->pause_time;
+
+	if (!cmd || cmd == &cmd_link_flow_control_set_xon)
+		fc_conf.send_xon = res->send_xon;
+
+	if (!cmd || cmd == &cmd_link_flow_control_set_macfwd) {
+		if (!strcmp(res->mac_ctrl_frame_fwd_mode, "on"))
+			fc_conf.mac_ctrl_frame_fwd = 1;
+		else
+			fc_conf.mac_ctrl_frame_fwd = 0;
+	}
 
-	fc_conf.mode       = rx_tx_onoff_2_lfc_mode[rx_fc_enable][tx_fc_enable];
-	fc_conf.high_water = res->high_water;
-	fc_conf.low_water  = res->low_water;
-	fc_conf.pause_time = res->pause_time;
-	fc_conf.send_xon   = res->send_xon;
-	fc_conf.mac_ctrl_frame_fwd = (uint8_t)mac_ctrl_frame_fwd;
-	fc_conf.autoneg    = (!strcmp(res->autoneg, "on")) ? 1 : 0;
+	if (!cmd || cmd == &cmd_link_flow_control_set_autoneg)
+		fc_conf.autoneg = (!strcmp(res->autoneg, "on")) ? 1 : 0;
 
 	ret = rte_eth_dev_flow_ctrl_set(res->port_id, &fc_conf);
 	if (ret != 0)
@@ -6592,6 +6777,14 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_tx_vlan_set_pvid,
 	(cmdline_parse_inst_t *)&cmd_tx_cksum_set,
 	(cmdline_parse_inst_t *)&cmd_link_flow_control_set,
+	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_rx,
+	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_tx,
+	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_hw,
+	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_lw,
+	(cmdline_parse_inst_t *)&cmd_link_flow_control_set_pt,
+	(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_priority_flow_control_set,
 	(cmdline_parse_inst_t *)&cmd_config_dcb,
 	(cmdline_parse_inst_t *)&cmd_read_reg,
-- 
1.7.10.4

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

* Re: [dpdk-dev] [PATCH 0/3] fix flow control in testpmd
  2014-06-24 13:06 [dpdk-dev] [PATCH 0/3] fix flow control in testpmd David Marchand
                   ` (2 preceding siblings ...)
  2014-06-24 13:06 ` [dpdk-dev] [PATCH 3/3] app/testpmd: allow to set part of flow control parameters David Marchand
@ 2014-06-27  0:59 ` Thomas Monjalon
  3 siblings, 0 replies; 5+ messages in thread
From: Thomas Monjalon @ 2014-06-27  0:59 UTC (permalink / raw)
  To: David Marchand; +Cc: dev

2014-06-24 15:06, David Marchand:
> Here is a patchset that addresses the problem reported by Jijiang Liu and
> introduces "partial" commands for setting flow control parameters in
> testpmd.
> 
> By the way, I tried to factorise the code in testpmd when handling flow
> control "commands" so that we have only one parser even if multiple
> commands are supported.

Acked-by: Thomas Monjalon <thomas.monjalon@6wind.com>

Applied for version 1.7.0.

Thanks
-- 
Thomas

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

end of thread, other threads:[~2014-06-27  0:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-24 13:06 [dpdk-dev] [PATCH 0/3] fix flow control in testpmd David Marchand
2014-06-24 13:06 ` [dpdk-dev] [PATCH 1/3] app/testpmd: add missing autoneg field to set flow_ctrl David Marchand
2014-06-24 13:06 ` [dpdk-dev] [PATCH 2/3] app/testpmd: move parser after flow_ctrl declarations David Marchand
2014-06-24 13:06 ` [dpdk-dev] [PATCH 3/3] app/testpmd: allow to set part of flow control parameters David Marchand
2014-06-27  0:59 ` [dpdk-dev] [PATCH 0/3] fix flow control in testpmd Thomas Monjalon

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).