All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Marchand <david.marchand-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
To: dev-VfR2kkLFssw@public.gmane.org
Subject: [PATCH 5/5] app/testpmd: allow to configure mtu
Date: Mon, 26 May 2014 13:31:32 +0200	[thread overview]
Message-ID: <1401103892-17225-6-git-send-email-david.marchand@6wind.com> (raw)
In-Reply-To: <1401103892-17225-1-git-send-email-david.marchand-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>

From: Ivan Boule <ivan.boule-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>

Take avantage of the .set_mtu ethdev function and make it possible to configure
MTU on devices using testpmd.

Signed-off-by: Ivan Boule <ivan.boule-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
Signed-off-by: David Marchand <david.marchand-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
---
 app/test-pmd/cmdline.c |   54 ++++++++++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/config.c  |   13 ++++++++++++
 app/test-pmd/testpmd.h |    2 +-
 3 files changed, 68 insertions(+), 1 deletion(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 68bcd7b..517944b 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -516,6 +516,8 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"port config all (txfreet|txrst|rxfreet) (value)\n"
 			"    Set free threshold for rx/tx, or set"
 			" tx rs bit threshold.\n\n"
+			"port config mtu X value\n"
+			"    Set the MTU of port X to a given value\n\n"
 		);
 	}
 
@@ -1014,6 +1016,57 @@ cmdline_parse_inst_t cmd_config_max_pkt_len = {
 	},
 };
 
+/* *** configure port MTU *** */
+struct cmd_config_mtu_result {
+	cmdline_fixed_string_t port;
+	cmdline_fixed_string_t keyword;
+	cmdline_fixed_string_t mtu;
+	uint8_t port_id;
+	uint16_t value;
+};
+
+static void
+cmd_config_mtu_parsed(void *parsed_result,
+		      __attribute__((unused)) struct cmdline *cl,
+		      __attribute__((unused)) void *data)
+{
+	struct cmd_config_mtu_result *res = parsed_result;
+
+	if (res->value < ETHER_MIN_LEN) {
+		printf("mtu cannot be less than %d\n", ETHER_MIN_LEN);
+		return;
+	}
+	port_mtu_set(res->port_id, res->value);
+}
+
+cmdline_parse_token_string_t cmd_config_mtu_port =
+	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, port,
+				 "port");
+cmdline_parse_token_string_t cmd_config_mtu_keyword =
+	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
+				 "config");
+cmdline_parse_token_string_t cmd_config_mtu_mtu =
+	TOKEN_STRING_INITIALIZER(struct cmd_config_mtu_result, keyword,
+				 "mtu");
+cmdline_parse_token_num_t cmd_config_mtu_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, port_id, UINT8);
+cmdline_parse_token_num_t cmd_config_mtu_value =
+	TOKEN_NUM_INITIALIZER(struct cmd_config_mtu_result, value, UINT16);
+
+cmdline_parse_inst_t cmd_config_mtu = {
+	.f = cmd_config_mtu_parsed,
+	.data = NULL,
+	.help_str = "port config mtu value",
+	.tokens = {
+		(void *)&cmd_config_mtu_port,
+		(void *)&cmd_config_mtu_keyword,
+		(void *)&cmd_config_mtu_mtu,
+		(void *)&cmd_config_mtu_port_id,
+		(void *)&cmd_config_mtu_value,
+		NULL,
+	},
+};
+
 /* *** configure rx mode *** */
 struct cmd_config_rx_mode_flag {
 	cmdline_fixed_string_t port;
@@ -5366,6 +5419,7 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_config_speed_all,
 	(cmdline_parse_inst_t *)&cmd_config_speed_specific,
 	(cmdline_parse_inst_t *)&cmd_config_rx_tx,
+	(cmdline_parse_inst_t *)&cmd_config_mtu,
 	(cmdline_parse_inst_t *)&cmd_config_max_pkt_len,
 	(cmdline_parse_inst_t *)&cmd_config_rx_mode_flag,
 	(cmdline_parse_inst_t *)&cmd_config_rss,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index d3934e5..88a808c 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -503,6 +503,19 @@ port_reg_set(portid_t port_id, uint32_t reg_off, uint32_t reg_v)
 	display_port_reg_value(port_id, reg_off, reg_v);
 }
 
+void
+port_mtu_set(portid_t port_id, uint16_t mtu)
+{
+	int diag;
+
+	if (port_id_is_invalid(port_id))
+		return;
+	diag = rte_eth_dev_set_mtu(port_id, &mtu);
+	if (diag == 0)
+		return;
+	printf("Set MTU failed. diag=%d\n", diag);
+}
+
 /*
  * RX/TX ring descriptors display functions.
  */
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 0cf5a92..9b7dcbb 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -454,7 +454,7 @@ void fwd_config_setup(void);
 void set_def_fwd_config(void);
 int init_fwd_streams(void);
 
-
+void port_mtu_set(portid_t port_id, uint16_t mtu);
 void port_reg_bit_display(portid_t port_id, uint32_t reg_off, uint8_t bit_pos);
 void port_reg_bit_set(portid_t port_id, uint32_t reg_off, uint8_t bit_pos,
 		      uint8_t bit_v);
-- 
1.7.10.4

      parent reply	other threads:[~2014-05-26 11:31 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-26 11:31 [PATCH 0/5] add mtu and flow control handlers David Marchand
     [not found] ` <1401103892-17225-1-git-send-email-david.marchand-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2014-05-26 11:31   ` [PATCH 1/5] ethdev: retrieve flow control configuration David Marchand
2014-05-26 11:31   ` [PATCH 2/5] ethdev: add autoneg parameter in flow ctrl accessors David Marchand
2014-05-26 11:31   ` [PATCH 3/5] ethdev: add mtu accessors David Marchand
     [not found]     ` <1401103892-17225-4-git-send-email-david.marchand-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2014-06-10 17:23       ` Ananyev, Konstantin
     [not found]         ` <2601191342CEEE43887BDE71AB9772580EFB5EEE-kPTMFJFq+rEu0RiL9chJVbfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2014-06-12 14:20           ` David Marchand
2014-05-26 11:31   ` [PATCH 4/5] ixgbe: add get/set_mtu to ixgbevf David Marchand
2014-05-26 11:31   ` David Marchand [this message]

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=1401103892-17225-6-git-send-email-david.marchand@6wind.com \
    --to=david.marchand-pdr9zngts4eavxtiumwx3w@public.gmane.org \
    --cc=dev-VfR2kkLFssw@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.