From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <thomas.monjalon@6wind.com>
Received: from mail-wg0-f41.google.com (mail-wg0-f41.google.com [74.125.82.41])
 by dpdk.org (Postfix) with ESMTP id 3D15A68B5
 for <dev@dpdk.org>; Mon, 18 Nov 2013 23:30:14 +0100 (CET)
Received: by mail-wg0-f41.google.com with SMTP id n12so5124602wgh.4
 for <dev@dpdk.org>; Mon, 18 Nov 2013 14:31:11 -0800 (PST)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20130820;
 h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to
 :references:in-reply-to:references;
 bh=oX3e+lAkNtNe+zR04PJGGb2dzDAyD0dpikqUkjh+nlc=;
 b=jKCOOqtteOYgMA9gZs/0b9RbTj2AUhcmFmBjWybvKHFaI3e8p6uY2b5xBqrzNDOfz4
 8cAVPFRsO3U0STeA+5IttdnfG+R3JfR9eAqiSbZkXkYUqJTTbwPKgm5kpG2YjsCbWDlX
 Di5D5eB3ZgEXa+XuvwiUdBFuPMnuL3aJwbsXJO8zOXFel9P+zF2LciDVU/pzSVLnpJJ1
 AAYfhYmEamUNmGCEKsYuiABmzWVJ5+c7qaqTK0lUuiC7gLGabgvASL4Qq98iYHipgo0w
 ys3hEjmpurk/L0D5suB8Yv5HTAZOKZGwoIoTuCdnRMbatD7dTXqfmBmEGkd4MyISuoPT
 87YQ==
X-Gm-Message-State: ALoCoQkVmw/EQpj2UQ/hG6Qq16tvEPKu234ftX8TggI+L2mWKEMqOsIVhSFANTgdGOBfLBovLhBL
X-Received: by 10.180.183.72 with SMTP id ek8mr18897953wic.49.1384813871525;
 Mon, 18 Nov 2013 14:31:11 -0800 (PST)
Received: from 6wind.com (6wind.net2.nerim.net. [213.41.180.237])
 by mx.google.com with ESMTPSA id f15sm14896538wik.6.2013.11.18.14.31.09
 for <dev@dpdk.org> (version=TLSv1 cipher=RC4-SHA bits=128/128);
 Mon, 18 Nov 2013 14:31:10 -0800 (PST)
Received: by 6wind.com (sSMTP sendmail emulation);
 Mon, 18 Nov 2013 23:31:08 +0100
From: Thomas Monjalon <thomas.monjalon@6wind.com>
To: dev@dpdk.org
Date: Mon, 18 Nov 2013 23:31:01 +0100
Message-Id: <b535ad5121cb70866e7ad365c728722d4ab21ac5.1384813681.git.thomas.monjalon@6wind.com>
X-Mailer: git-send-email 1.7.10.4
In-Reply-To: <cover.1384813680.git.thomas.monjalon@6wind.com>
References: <cover.1384813680.git.thomas.monjalon@6wind.com>
In-Reply-To: <cover.1384813680.git.thomas.monjalon@6wind.com>
References: <cover.1384813680.git.thomas.monjalon@6wind.com>
Subject: [dpdk-dev] [PATCH 2/3] app/testpmd: fix build without librte_cmdline
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Mon, 18 Nov 2013 22:30:14 -0000

Some features are not available if LIBRTE_CMDLINE is disabled:
- interactive mode
- ethernet address parsing

Note: ethernet address parsing could be rewritten without cmdline dependency.

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
---
 app/test-pmd/Makefile     |    2 ++
 app/test-pmd/parameters.c |   29 +++++++++++++++++++++++++++--
 app/test-pmd/testpmd.c    |    5 ++++-
 3 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/app/test-pmd/Makefile b/app/test-pmd/Makefile
index 8f7e579..cd04ea5 100644
--- a/app/test-pmd/Makefile
+++ b/app/test-pmd/Makefile
@@ -48,7 +48,9 @@ endif
 #
 SRCS-$(CONFIG_RTE_TEST_PMD) := testpmd.c
 SRCS-$(CONFIG_RTE_TEST_PMD) += parameters.c
+ifeq ($(CONFIG_RTE_LIBRTE_CMDLINE),y)
 SRCS-$(CONFIG_RTE_TEST_PMD) += cmdline.c
+endif
 SRCS-$(CONFIG_RTE_TEST_PMD) += config.c
 SRCS-$(CONFIG_RTE_TEST_PMD) += iofwd.c
 SRCS-$(CONFIG_RTE_TEST_PMD) += macfwd.c
diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index dbcc113..ba39ce5 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -71,27 +71,37 @@
 #include <rte_ether.h>
 #include <rte_ethdev.h>
 #include <rte_string_fns.h>
+#ifdef RTE_LIBRTE_CMDLINE
 #include <cmdline_parse.h>
 #include <cmdline_parse_etheraddr.h>
+#endif
 
 #include "testpmd.h"
 
 static void
 usage(char* progname)
 {
-	printf("usage: %s [--interactive|-i] [--help|-h] | ["
+	printf("usage: %s "
+#ifdef RTE_LIBRTE_CMDLINE
+	       "[--interactive|-i] "
+#endif
+	       "[--help|-h] | ["
 	       "--coremask=COREMASK --portmask=PORTMASK --numa "
 	       "--mbuf-size= | --total-num-mbufs= | "
 	       "--nb-cores= | --nb-ports= | "
+#ifdef RTE_LIBRTE_CMDLINE
 	       "--eth-peers-configfile= | "
 	       "--eth-peer=X,M:M:M:M:M:M | "
+#endif
 	       "--pkt-filter-mode= |"
 	       "--rss-ip | --rss-udp | "
 	       "--rxpt= | --rxht= | --rxwt= | --rxfreet= | "
 	       "--txpt= | --txht= | --txwt= | --txfreet= | "
 	       "--txrst= | --txqflags= ]\n",
 	       progname);
+#ifdef RTE_LIBRTE_CMDLINE
 	printf("  --interactive: run in interactive mode.\n");
+#endif
 	printf("  --help: display this message and quit.\n");
 	printf("  --nb-cores=N: set the number of forwarding cores "
 	       "(1 <= N <= %d).\n", nb_lcores);
@@ -118,10 +128,12 @@ usage(char* progname)
 	printf("  --total-num-mbufs=N: set the number of mbufs to be allocated "
 	       "in mbuf pools.\n");
 	printf("  --max-pkt-len=N: set the maximum size of packet to N bytes.\n");
+#ifdef RTE_LIBRTE_CMDLINE
 	printf("  --eth-peers-configfile=name: config file with ethernet addresses "
 	       "of peer ports.\n");
 	printf("  --eth-peer=X,M:M:M:M:M:M: set the MAC address of the X peer "
 	       "port (0 <= X < %d).\n", RTE_MAX_ETHPORTS);
+#endif
 	printf("  --pkt-filter-mode=N: set Flow Director mode "
 	       "(N: none (default mode) or signature or perfect).\n");
 	printf("  --pkt-filter-report-hash=N: set Flow Director report mode "
@@ -182,6 +194,7 @@ usage(char* progname)
 	       " starts forwarding\n");
 }
 
+#ifdef RTE_LIBRTE_CMDLINE
 static int
 init_peer_eth_addrs(char *config_filename)
 {
@@ -210,6 +223,7 @@ init_peer_eth_addrs(char *config_filename)
 	nb_peer_eth_addrs = (portid_t) i;
 	return 0;
 }
+#endif
 
 /*
  * Parse the coremask given as argument (hexadecimal string) and set
@@ -469,9 +483,11 @@ launch_args_parse(int argc, char** argv)
 
 	static struct option lgopts[] = {
 		{ "help",			0, 0, 0 },
+#ifdef RTE_LIBRTE_CMDLINE
 		{ "interactive",		0, 0, 0 },
 		{ "eth-peers-configfile",	1, 0, 0 },
 		{ "eth-peer",			1, 0, 0 },
+#endif
 		{ "ports",			1, 0, 0 },
 		{ "nb-cores",			1, 0, 0 },
 		{ "nb-ports",			1, 0, 0 },
@@ -521,18 +537,26 @@ launch_args_parse(int argc, char** argv)
 
 	argvopt = argv;
 
-	while ((opt = getopt_long(argc, argvopt, "ih",
+#ifdef RTE_LIBRTE_CMDLINE
+#define SHORTOPTS "ih"
+#else
+#define SHORTOPTS "h"
+#endif
+	while ((opt = getopt_long(argc, argvopt, SHORTOPTS,
 				 lgopts, &opt_idx)) != EOF) {
 		switch (opt) {
+#ifdef RTE_LIBRTE_CMDLINE
 		case 'i':
 			printf("Interactive-mode selected\n");
 			interactive = 1;
 			break;
+#endif
 		case 0: /*long options */
 			if (!strcmp(lgopts[opt_idx].name, "help")) {
 				usage(argv[0]);
 				rte_exit(EXIT_SUCCESS, "Displayed help\n");
 			}
+#ifdef RTE_LIBRTE_CMDLINE
 			if (!strcmp(lgopts[opt_idx].name, "interactive")) {
 				printf("Interactive-mode selected\n");
 				interactive = 1;
@@ -566,6 +590,7 @@ launch_args_parse(int argc, char** argv)
 						peer_addr[c];
 				nb_peer_eth_addrs++;
 			}
+#endif
 			if (!strcmp(lgopts[opt_idx].name, "nb-ports")) {
 				n = atoi(optarg);
 				if (n > 0 && n <= nb_ports)
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 6595659..f6b860f 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1736,9 +1736,12 @@ main(int argc, char** argv)
 	for (port_id = 0; port_id < nb_ports; port_id++)
 		rte_eth_promiscuous_enable(port_id);
 
+#ifdef RTE_LIBRTE_CMDLINE
 	if (interactive == 1)
 		prompt();
-	else {
+	else
+#endif
+	{
 		char c;
 		int rc;
 
-- 
1.7.10.4