From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wg0-f46.google.com (mail-wg0-f46.google.com [74.125.82.46]) by dpdk.org (Postfix) with ESMTP id EF991B0C0 for ; Wed, 14 May 2014 19:05:24 +0200 (CEST) Received: by mail-wg0-f46.google.com with SMTP id n12so2254971wgh.5 for ; Wed, 14 May 2014 10:05:32 -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=jrVI/tM/dekXjXJEvZEBhAKsU5Q4eNq/cztGtY/vm3k=; b=OvPmnR0zLfcHplpbhIUquRJxD9j9vhVC4S+xEiakj4QsK7IspnG5RqyU9DtNgkP/WW wTbEhkQdoKG0/L0I7fUsEwBzXQq13J5AmGfaL8kpB4pyAyoFLrfyztEd8Hyw1+6AyQWH e/LKuGhxmMW1PrF8G81cyjb0U/yBKAsGxIbsE4KAt8OBLL/miuWbeFHBTaJK0gVImf/7 1KOkSnymgoT3xYsWglKV6zLZ+6RpEN50/XJVsTxSEf4+eDoebonqSj5ZHzYtrAhGh+5i z8XieiAFJowCZVIHY518mage0cUoo2gmGuV6DLpR56yG1A1x2IRcA7Icq8YVxqf/3+C/ Fyew== X-Gm-Message-State: ALoCoQmL2amPw8zIGMkw++QQ+ogsyjS6xJmprEYcwYSULgTrfKEesEd4u3lIHGy7WmA3cU5jSJRp X-Received: by 10.180.80.232 with SMTP id u8mr27132358wix.13.1400087132558; Wed, 14 May 2014 10:05:32 -0700 (PDT) Received: from XPS13.dev.6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id nb8sm28747936wic.18.2014.05.14.10.05.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 May 2014 10:05:31 -0700 (PDT) From: Thomas Monjalon To: dev@dpdk.org Date: Wed, 14 May 2014 19:05:13 +0200 Message-Id: <1400087113-5270-1-git-send-email-thomas.monjalon@6wind.com> X-Mailer: git-send-email 1.9.2 In-Reply-To: <59AF69C657FD0841A61C55336867B5B01A9F8609@IRSMSX103.ger.corp.intel.com> References: <59AF69C657FD0841A61C55336867B5B01A9F8609@IRSMSX103.ger.corp.intel.com> Subject: [dpdk-dev] [PATCH] app/testpmd: list forwarding modes 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: Wed, 14 May 2014 17:05:25 -0000 Having a function to list forwarding modes helps to show them in cli help and in parameters usage witout duplicating code. Signed-off-by: Thomas Monjalon --- app/test-pmd/cmdline.c | 13 +++---------- app/test-pmd/config.c | 20 ++++++++++++++++++++ app/test-pmd/parameters.c | 3 ++- app/test-pmd/testpmd.h | 1 + 4 files changed, 26 insertions(+), 11 deletions(-) This patch is based on top of "test-pmd: allow command line selection of forwarding mode". It fixes issue raised by Bruce: http://dpdk.org/ml/archives/dev/2014-April/001809.html diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 7f59333..c81d69a 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" - -#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" + "set fwd (%s)\n" + " Set 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() ); } diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index d0e21b7..8f08cc2 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1231,6 +1231,26 @@ 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 modes[128] = ""; + struct fwd_engine *fwd_eng; + unsigned i; + + if (strlen (modes) == 0) { + i = 0; + while ((fwd_eng = fwd_engines[i]) != NULL) { + strcat(modes, fwd_eng->fwd_mode_name); + strcat(modes, "|"); + i++; + } + modes[strlen(modes) - 1] = '\0'; + } + + return 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..4afa793 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); -- 1.9.2