From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f170.google.com (mail-wi0-f170.google.com [209.85.212.170]) by dpdk.org (Postfix) with ESMTP id DA43E6934 for ; Fri, 16 May 2014 09:21:38 +0200 (CEST) Received: by mail-wi0-f170.google.com with SMTP id bs8so1720447wib.3 for ; Fri, 16 May 2014 00:21:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=A2rD93AfUleJLAGlzu27B3UyyNT0IORgvPyW2GJbvgI=; b=l9+bjQ1ZZ0eZ3YQ7KN7J3eOoX1k1gEVexp7jdMZAmTXh0nMQAT4oEVzn5PgP1PYoRx TNCszxx0v4qycpNyOjnlPt9yyW2xdSBQ435wRTx3NUFtwBvXLrnxN94jpSwUaeKo8hi4 F0aJnjRw+kvViMPorLyeG6+U5pLvJvaxZDs3T9v4sCYmKJCp5aaJzy77tTWP4HuEAZfn gV2tFpeKK6OMj76NMRqRtd3i2Yxy1FxtEZL20gTMuxX+KCLdtYjS64+m1jFfH9LHwiKG +kwu5yJKd996hBaDXM3t9SpNDGcE9XG/7WmseDqYE1iJ7uaH4arc5OQpJJ8vfqNJRp1Z 9VCg== X-Gm-Message-State: ALoCoQl1jGNfuuO2wKutD1ikKXcGdL5ZS54hnjAT7yexvP2/TUbRUrFNvTsQCjbaTURxXDfXJt7b X-Received: by 10.180.228.42 with SMTP id sf10mr34538885wic.33.1400224906792; Fri, 16 May 2014 00:21:46 -0700 (PDT) Received: from [10.16.0.189] (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id cz8sm781133wjc.11.2014.05.16.00.21.45 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 16 May 2014 00:21:46 -0700 (PDT) Message-ID: <5375BC79.1090309@6wind.com> Date: Fri, 16 May 2014 09:21:29 +0200 From: Ivan Boule User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.5.0 MIME-Version: 1.0 To: Thomas Monjalon , dev@dpdk.org References: <1400146513-14283-1-git-send-email-thomas.monjalon@6wind.com> <1400170121-2737-1-git-send-email-thomas.monjalon@6wind.com> In-Reply-To: <1400170121-2737-1-git-send-email-thomas.monjalon@6wind.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v3] app/testpmd: list forwarding engines 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, 16 May 2014 07:21:39 -0000 On 05/15/2014 06:08 PM, Thomas Monjalon wrote: > Having a function to list forwarding engines helps to show them > in cli help and in parameters usage witout duplicating code. > > Signed-off-by: Thomas Monjalon > --- > app/test-pmd/cmdline.c | 52 +++++++++++++++++++++++++++-------------------- > app/test-pmd/config.c | 19 +++++++++++++++++ > app/test-pmd/parameters.c | 3 ++- > app/test-pmd/testpmd.h | 1 + > 4 files changed, 52 insertions(+), 23 deletions(-) > > changes in v2: > - factorize also contextual help > changes in v3: > - remove useless loop > > diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c > index 7becedc..c6a417a 100644 > --- a/app/test-pmd/cmdline.c > +++ b/app/test-pmd/cmdline.c > @@ -294,17 +294,9 @@ static void cmd_help_long_parsed(void *parsed_result, > " bit 3 - insert sctp checksum offload if set\n" > " Please check the NIC datasheet for HW limits.\n\n" > > -#ifdef RTE_LIBRTE_IEEE1588 > - "set fwd (io|mac|mac_retry|rxonly|txonly|csum|ieee1588)\n" > - " Set IO, MAC, MAC_RETRY, RXONLY, CSUM or TXONLY or ieee1588" > - " packet forwarding mode.\n\n" > + "set fwd (%s)\n" > + " Set packet forwarding mode.\n\n" > > -#else > - "set fwd (io|mac|mac_retry|rxonly|txonly|csum)\n" > - " Set IO, MAC, MAC_RETRY, RXONLY, CSUM or TXONLY packet" > - " forwarding mode.\n\n" > - > -#endif > "mac_addr add (port_id) (XX:XX:XX:XX:XX:XX)\n" > " Add a MAC address on port_id.\n\n" > > @@ -398,6 +390,7 @@ static void cmd_help_long_parsed(void *parsed_result, > " using the lowest port on the NIC.\n\n" > #endif > > + , list_pkt_forwarding_modes() > ); > } > > @@ -2688,22 +2681,12 @@ cmdline_parse_token_string_t cmd_setfwd_fwd = > TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, fwd, "fwd"); > cmdline_parse_token_string_t cmd_setfwd_mode = > TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_mode_result, mode, > -#ifdef RTE_LIBRTE_IEEE1588 > - "io#mac#mac_retry#rxonly#txonly#csum#ieee1588"); > -#else > - "io#mac#mac_retry#rxonly#txonly#csum"); > -#endif > + "" /* defined at init */); > > cmdline_parse_inst_t cmd_set_fwd_mode = { > .f = cmd_set_fwd_mode_parsed, > .data = NULL, > -#ifdef RTE_LIBRTE_IEEE1588 > - .help_str = "set fwd io|mac|mac_retry|rxonly|txonly|csum|ieee1588 - set IO, MAC," > - " MAC_RETRY, RXONLY, TXONLY, CSUM or IEEE1588 packet forwarding mode", > -#else > - .help_str = "set fwd io|mac|mac_retry|rxonly|txonly|csum - set IO, MAC," > - " MAC_RETRY, RXONLY, CSUM or TXONLY packet forwarding mode", > -#endif > + .help_str = NULL, /* defined at init */ > .tokens = { > (void *)&cmd_setfwd_set, > (void *)&cmd_setfwd_fwd, > @@ -2712,6 +2695,28 @@ cmdline_parse_inst_t cmd_set_fwd_mode = { > }, > }; > > +static void cmd_set_fwd_mode_init(void) > +{ > + char *modes, *c; > + static char token[128]; > + static char help[256]; > + cmdline_parse_token_string_t *token_struct; > + > + modes = list_pkt_forwarding_modes(); > + rte_snprintf(help, sizeof help, "set fwd %s - " > + "set packet forwarding mode", modes); > + cmd_set_fwd_mode.help_str = help; > + > + /* string token separator is # */ > + for (c = token; *modes != '\0'; modes++) > + if (*modes == '|') > + *c++ = '#'; > + else > + *c++ = *modes; > + token_struct = (cmdline_parse_token_string_t*)cmd_set_fwd_mode.tokens[2]; > + token_struct->string_data.str = token; > +} > + > /* *** SET BURST TX DELAY TIME RETRY NUMBER *** */ > struct cmd_set_burst_tx_retry_result { > cmdline_fixed_string_t set; > @@ -5198,6 +5203,9 @@ prompt(void) > { > struct cmdline *cl; > > + /* initialize non-constant commands */ > + cmd_set_fwd_mode_init(); > + > cl = cmdline_stdin_new(main_ctx, "testpmd> "); > if (cl == NULL) { > return; > diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c > index d0e21b7..41326fe 100644 > --- a/app/test-pmd/config.c > +++ b/app/test-pmd/config.c > @@ -1231,6 +1231,25 @@ set_tx_pkt_segments(unsigned *seg_lengths, unsigned nb_segs) > tx_pkt_nb_segs = (uint8_t) nb_segs; > } > > +char* > +list_pkt_forwarding_modes(void) > +{ > + static char fwd_modes[128] = ""; > + const char *separator = "|"; > + struct fwd_engine *fwd_eng; > + unsigned i = 0; > + > + if (strlen (fwd_modes) == 0) { > + while ((fwd_eng = fwd_engines[i++]) != NULL) { > + strcat(fwd_modes, fwd_eng->fwd_mode_name); > + strcat(fwd_modes, separator); > + } > + fwd_modes[strlen(fwd_modes) - strlen(separator)] = '\0'; > + } > + > + return fwd_modes; > +} > + > void > set_pkt_forwarding_mode(const char *fwd_mode_name) > { > diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c > index 67081d7..8a3ce2c 100644 > --- a/app/test-pmd/parameters.c > +++ b/app/test-pmd/parameters.c > @@ -158,7 +158,8 @@ usage(char* progname) > printf(" --disable-rss: disable rss.\n"); > printf(" --port-topology=N: set port topology (N: paired (default) or " > "chained).\n"); > - printf(" --forward-mode=N: set forwarding mode.\n"); > + printf(" --forward-mode=N: set forwarding mode (N: %s).\n", > + list_pkt_forwarding_modes()); > printf(" --rss-ip: set RSS functions to IPv4/IPv6 only .\n"); > printf(" --rss-udp: set RSS functions to IPv4/IPv6 + UDP.\n"); > printf(" --rxq=N: set the number of RX queues per port to N.\n"); > diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h > index 52d3543..0e4a35e 100644 > --- a/app/test-pmd/testpmd.h > +++ b/app/test-pmd/testpmd.h > @@ -491,6 +491,7 @@ void tx_cksum_set(portid_t port_id, uint8_t cksum_mask); > void set_verbose_level(uint16_t vb_level); > void set_tx_pkt_segments(unsigned *seg_lengths, unsigned nb_segs); > void set_nb_pkt_per_burst(uint16_t pkt_burst); > +char *list_pkt_forwarding_modes(void); > void set_pkt_forwarding_mode(const char *fwd_mode); > void start_packet_forwarding(int with_tx_first); > void stop_packet_forwarding(void); Acked by: Ivan Boule -- Ivan Boule 6WIND Development Engineer