From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wg0-f44.google.com (mail-wg0-f44.google.com [74.125.82.44]) by dpdk.org (Postfix) with ESMTP id 249A1B0A6 for ; Fri, 13 Jun 2014 15:37:44 +0200 (CEST) Received: by mail-wg0-f44.google.com with SMTP id x13so2759818wgg.27 for ; Fri, 13 Jun 2014 06:37:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BltBq6NorB+CV2YPjZ+lPSzMCljCJoML+sjoEw3CLn8=; b=OgL4Etnd90KfOBnytGM2AMu888tWOmK9m1dAy4V2UUjYT13GbUuOmugIT3yOYHKN9W 5elpf/rPuQDIDcEyZIl7uznIVX09Gqxxo8T++8M6PpmS/gie1/RwDVaQpA2aO7gYDjHF nbv1iTM6hugHaY6ACTqT0TVONgwe+P5HsO5fy3l6mZcU9Ce8i1Ma7bmKwKr2lKTlWkMW +8/jDLHQYBs7dgINfTcjWYAaaufLlMzgZRykpnv6TAa6/8Jq9Q0NfHYysJM4pU0AlYpv GE6mJ8SZgQiGoxntp0bDIIwf4smTm8W5rvsl5jOigZAipVJ2wU6mMT/tLWH3dM01XWoA kiXA== X-Gm-Message-State: ALoCoQnQ0SITJT1EgEUWs5/NM4kjdg26RoDIgvd70o9hdJmecl29DYEAefhwidUTLS2Qh7kXcIkg X-Received: by 10.180.37.198 with SMTP id a6mr4880056wik.58.1402666679438; Fri, 13 Jun 2014 06:37:59 -0700 (PDT) Received: from alcyon.dev.6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by mx.google.com with ESMTPSA id s9sm2568157wix.13.2014.06.13.06.37.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Jun 2014 06:37:58 -0700 (PDT) From: David Marchand To: dev@dpdk.org Date: Fri, 13 Jun 2014 15:37:43 +0200 Message-Id: <1402666663-10260-8-git-send-email-david.marchand@6wind.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1402666663-10260-1-git-send-email-david.marchand@6wind.com> References: <1402666663-10260-1-git-send-email-david.marchand@6wind.com> Subject: [dpdk-dev] [PATCH v2 7/7] app/testpmd: allow to configure mtu X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jun 2014 13:37:45 -0000 From: Ivan Boule Take avantage of the .set_mtu ethdev function and make it possible to configure MTU on devices using testpmd. Signed-off-by: Ivan Boule Signed-off-by: David Marchand --- 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 4678977..6b150c1 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -523,6 +523,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" ); } @@ -1021,6 +1023,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; @@ -5600,6 +5653,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 52ad01a..4cebe00 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -493,6 +493,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 4fabf1c..4c1ed03 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