DPDK patches and discussions
 help / color / mirror / Atom feed
From: Olivier Matz <olivier.matz@6wind.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 09/11] device-args: replace use-device eal option by pci-whitelist and vdev
Date: Fri, 28 Feb 2014 18:25:48 +0100	[thread overview]
Message-ID: <1393608350-4431-10-git-send-email-olivier.matz@6wind.com> (raw)
In-Reply-To: <1393608350-4431-1-git-send-email-olivier.matz@6wind.com>

This commit splits the "--use-device" option in two new options:

- "--pci-whitelist or -w": add a PCI device in the white list
- "--vdev": instanciate a new virtual device

Before the patch, the same option "--use-device" was used for these 2
use-cases.

By the way, we also add "--pci-blacklist" in addition to the existing
"-b" for coherency with the whitelist parameter.

Test result:

echo 100 > /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages
echo 100 > /sys/devices/system/node/node1/hugepages/hugepages-2048kB/nr_hugepages
./app/test -c 0x15 -n 3 -m 64
RTE>>eal_flags_autotest
[...]
Test OK

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 app/test/test_eal_flags.c         | 27 +++++++-----
 lib/librte_eal/linuxapp/eal/eal.c | 89 +++++++++++++++++++++------------------
 2 files changed, 64 insertions(+), 52 deletions(-)

diff --git a/app/test/test_eal_flags.c b/app/test/test_eal_flags.c
index 45d3d02..195a1f5 100644
--- a/app/test/test_eal_flags.c
+++ b/app/test/test_eal_flags.c
@@ -57,7 +57,8 @@
 #define no_hpet "--no-hpet"
 #define no_huge "--no-huge"
 #define no_shconf "--no-shconf"
-#define use_device "--use-device"
+#define pci_whitelist "--pci-whitelist"
+#define vdev "--vdev"
 #define memtest "memtest"
 #define memtest1 "memtest1"
 #define memtest2 "memtest2"
@@ -295,26 +296,30 @@ test_whitelist_flag(void)
 
 	const char *wlinval[][11] = {
 		{prgname, prefix, mp_flag, "-n", "1", "-c", "1",
-				use_device, "error", "", ""},
+				pci_whitelist, "error", "", ""},
 		{prgname, prefix, mp_flag, "-n", "1", "-c", "1",
-				use_device, "0:0:0", "", ""},
+				pci_whitelist, "0:0:0", "", ""},
 		{prgname, prefix, mp_flag, "-n", "1", "-c", "1",
-				use_device, "0:error:0.1", "", ""},
+				pci_whitelist, "0:error:0.1", "", ""},
 		{prgname, prefix, mp_flag, "-n", "1", "-c", "1",
-				use_device, "0:0:0.1error", "", ""},
+				pci_whitelist, "0:0:0.1error", "", ""},
 		{prgname, prefix, mp_flag, "-n", "1", "-c", "1",
-				use_device, "error0:0:0.1", "", ""},
+				pci_whitelist, "error0:0:0.1", "", ""},
 		{prgname, prefix, mp_flag, "-n", "1", "-c", "1",
-				use_device, "0:0:0.1.2", "", ""},
+				pci_whitelist, "0:0:0.1.2", "", ""},
 	};
 	/* Test with valid whitelist option */
 	const char *wlval1[] = {prgname, prefix, mp_flag, "-n", "1", "-c", "1",
-			use_device, "00FF:09:0B.3"};
+			pci_whitelist, "00FF:09:0B.3"};
 	const char *wlval2[] = {prgname, prefix, mp_flag, "-n", "1", "-c", "1",
-			use_device, "09:0B.3", use_device, "0a:0b.1"};
+			pci_whitelist, "09:0B.3", pci_whitelist, "0a:0b.1"};
 	const char *wlval3[] = {prgname, prefix, mp_flag, "-n", "1", "-c", "1",
-			use_device, "09:0B.3,type=test",
-			use_device, "08:00.1,type=normal"};
+			pci_whitelist, "09:0B.3,type=test",
+			pci_whitelist, "08:00.1,type=normal",
+#ifdef CONFIG_RTE_LIBRTE_PMD_RING
+			vdev, "eth_ring,arg=test",
+#endif
+	};
 
 	for (i = 0; i < sizeof(wlinval) / sizeof(wlinval[0]); i++) {
 		if (launch_proc(wlinval[i]) == 0) {
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 67b2097..16ebec0 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -92,6 +92,9 @@
 #define OPT_FILE_PREFIX "file-prefix"
 #define OPT_SOCKET_MEM  "socket-mem"
 #define OPT_USE_DEVICE  "use-device"
+#define OPT_PCI_WHITELIST "pci-whitelist"
+#define OPT_PCI_BLACKLIST "pci-blacklist"
+#define OPT_VDEV        "vdev"
 #define OPT_SYSLOG      "syslog"
 #define OPT_BASE_VIRTADDR   "base-virtaddr"
 #define OPT_XEN_DOM0    "xen-dom0"
@@ -336,9 +339,6 @@ eal_usage(const char *prgname)
 	       "  -n NUM       : Number of memory channels\n"
 		   "  -v           : Display version information on startup\n"
 	       "  -d LIB.so    : add driver (can be used multiple times)\n"
-	       "  -b <domain:bus:devid.func>: to prevent EAL from using specified "
-           "PCI device\n"
-	       "                 (multiple -b options are allowed)\n"
 	       "  -m MB        : memory to allocate (see also --"OPT_SOCKET_MEM")\n"
 	       "  -r NUM       : force number of memory ranks (don't detect)\n"
 	       "  --"OPT_XEN_DOM0" : support application running on Xen Domain0 "
@@ -349,11 +349,17 @@ eal_usage(const char *prgname)
 	       "  --"OPT_HUGE_DIR"   : directory where hugetlbfs is mounted\n"
 	       "  --"OPT_PROC_TYPE"  : type of this process\n"
 	       "  --"OPT_FILE_PREFIX": prefix for hugepage filenames\n"
-	       "  --"OPT_USE_DEVICE": use the specified ethernet device(s) only.\n"
-	       "               The argument format is <[domain:]bus:devid.func> to add\n"
-	       "               a PCI device to the white list or <driver><id>[;key=val;...]\n"
-	       "               to add a virtual device.\n"
+	       "  --"OPT_PCI_BLACKLIST", -b: add a PCI device in black list.\n"
+	       "               Prevent EAL from using this PCI device. The argument\n"
+	       "               format is <domain:bus:devid.func>.\n"
+	       "  --"OPT_PCI_WHITELIST", -w: add a PCI device in white list.\n"
+	       "               Only use the specified PCI devices. The argument format\n"
+	       "               is <[domain:]bus:devid.func>. This option can be present\n"
+	       "               several times (once per device).\n"
 	       "               [NOTE: PCI whitelist cannot be used with -b option]\n"
+	       "  --"OPT_VDEV": add a virtual device.\n"
+	       "               The argument format is <driver><id>[,key=val,...]\n"
+	       "               (ex: --vdev=eth_pcap0,iface=eth2).\n"
 	       "  --"OPT_VMWARE_TSC_MAP": use VMware TSC map instead of "
 	    		   "native RDTSC\n"
 	       "  --"OPT_BASE_VIRTADDR": specify base virtual address\n"
@@ -601,34 +607,6 @@ eal_parse_proc_type(const char *arg)
 	return RTE_PROC_INVALID;
 }
 
-static int
-eal_parse_use_device(const char *optarg)
-{
-	struct rte_pci_addr addr;
-	char *dup, *sep;
-
-	dup = strdup(optarg);
-	if (dup == NULL)
-		return -1;
-
-	/* remove arguments in 'dup' string */
-	sep = strchr(dup, ',');
-	if (sep != NULL)
-		*sep = '\0';
-
-	/* if argument is a PCI address, it's a whitelisted device */
-	if (eal_parse_pci_DomBDF(dup, &addr) == 0 ||
-		eal_parse_pci_BDF(dup, &addr) == 0) {
-		rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI, optarg);
-	}
-	else {
-		rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL, optarg);
-	}
-
-	free(dup);
-	return 0;
-}
-
 /* Parse the argument given in the command line of the application */
 static int
 eal_parse_args(int argc, char **argv)
@@ -648,7 +626,9 @@ eal_parse_args(int argc, char **argv)
 		{OPT_PROC_TYPE, 1, 0, 0},
 		{OPT_FILE_PREFIX, 1, 0, 0},
 		{OPT_SOCKET_MEM, 1, 0, 0},
-		{OPT_USE_DEVICE, 1, 0, 0},
+		{OPT_PCI_WHITELIST, 1, 0, 0},
+		{OPT_PCI_BLACKLIST, 1, 0, 0},
+		{OPT_VDEV, 1, 0, 0},
 		{OPT_SYSLOG, 1, NULL, 0},
 		{OPT_BASE_VIRTADDR, 1, 0, 0},
 		{OPT_XEN_DOM0, 0, 0, 0},
@@ -683,7 +663,7 @@ eal_parse_args(int argc, char **argv)
 	internal_config.vmware_tsc_map = 0;
 	internal_config.base_virtaddr = 0;
 
-	while ((opt = getopt_long(argc, argvopt, "b:c:d:m:n:r:v",
+	while ((opt = getopt_long(argc, argvopt, "b:w:c:d:m:n:r:v",
 				  lgopts, &option_index)) != EOF) {
 
 		switch (opt) {
@@ -695,6 +675,14 @@ eal_parse_args(int argc, char **argv)
 				return (-1);
 			}
 			break;
+		/* whitelist */
+		case 'w':
+			if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI,
+					optarg) < 0) {
+				eal_usage(prgname);
+				return -1;
+			}
+			break;
 		/* coremask */
 		case 'c':
 			if (eal_parse_coremask(optarg) < 0) {
@@ -794,9 +782,28 @@ eal_parse_args(int argc, char **argv)
 				}
 			}
 			else if (!strcmp(lgopts[option_index].name, OPT_USE_DEVICE)) {
-				if (eal_parse_use_device(optarg) < 0) {
-					RTE_LOG(ERR, EAL, "invalid parameters for --"
-							OPT_USE_DEVICE "\n");
+				printf("The --use-device option is deprecated, please use\n"
+					"--whitelist or --vdev instead.\n");
+				eal_usage(prgname);
+				return -1;
+			}
+			else if (!strcmp(lgopts[option_index].name, OPT_PCI_BLACKLIST)) {
+				if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED_PCI,
+						optarg) < 0) {
+					eal_usage(prgname);
+					return -1;
+				}
+			}
+			else if (!strcmp(lgopts[option_index].name, OPT_PCI_WHITELIST)) {
+				if (rte_eal_devargs_add(RTE_DEVTYPE_WHITELISTED_PCI,
+						optarg) < 0) {
+					eal_usage(prgname);
+					return -1;
+				}
+			}
+			else if (!strcmp(lgopts[option_index].name, OPT_VDEV)) {
+				if (rte_eal_devargs_add(RTE_DEVTYPE_VIRTUAL,
+						optarg) < 0) {
 					eal_usage(prgname);
 					return -1;
 				}
@@ -879,7 +886,7 @@ eal_parse_args(int argc, char **argv)
 	if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI) != 0 &&
 		rte_eal_devargs_type_count(RTE_DEVTYPE_BLACKLISTED_PCI) != 0) {
 		RTE_LOG(ERR, EAL, "Error: blacklist [-b] and whitelist "
-			"[--use-device] options cannot be used at the same time\n");
+			"[-w] options cannot be used at the same time\n");
 		eal_usage(prgname);
 		return -1;
 	}
-- 
1.8.5.3

  parent reply	other threads:[~2014-02-28 17:24 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-28 17:25 [dpdk-dev] [PATCH 00/11] eal: allow virtual pmd drivers as shared lib Olivier Matz
2014-02-28 17:25 ` [dpdk-dev] [PATCH 01/11] mk: use whole-archive option when creating dpdk binaries Olivier Matz
2014-04-10 13:58   ` Thomas Monjalon
2014-02-28 17:25 ` [dpdk-dev] [PATCH 02/11] devices-args: introduce rte_devargs in eal Olivier Matz
2014-02-28 21:39   ` Stephen Hemminger
2014-03-01 12:02     ` Olivier MATZ
2014-03-01 12:14       ` [dpdk-dev] [PATCH v2 " Olivier Matz
2014-04-10 13:59         ` Thomas Monjalon
2014-02-28 17:25 ` [dpdk-dev] [PATCH 03/11] devices-args: use rte_devargs and remove old whitelist code Olivier Matz
2014-03-01 12:14   ` [dpdk-dev] [PATCH v2 " Olivier Matz
2014-04-10 14:01     ` Thomas Monjalon
2014-02-28 17:25 ` [dpdk-dev] [PATCH 04/11] devices-args: add a dump_devargs command in basic test application Olivier Matz
2014-04-10 14:02   ` Thomas Monjalon
2014-02-28 17:25 ` [dpdk-dev] [PATCH 05/11] pci: rename device_list as pci_device_list Olivier Matz
2014-04-10 14:03   ` Thomas Monjalon
2014-02-28 17:25 ` [dpdk-dev] [PATCH 06/11] vdev: rename eal_common_nonpci_devs.c as eal_common_vdev.c Olivier Matz
2014-04-10 14:39   ` Thomas Monjalon
2014-04-11  7:36     ` [dpdk-dev] [PATCH v2 06/11] vdev: rename nonpci_devs as vdev Olivier Matz
2014-04-11 11:25       ` Thomas Monjalon
2014-04-11 11:45         ` [dpdk-dev] [PATCH v3 " Olivier Matz
2014-04-11 12:37           ` Thomas Monjalon
2014-02-28 17:25 ` [dpdk-dev] [PATCH 07/11] vdev: allow external registration of virtual device drivers Olivier Matz
2014-04-10 14:55   ` Thomas Monjalon
2014-04-11  7:36     ` [dpdk-dev] [PATCH v2 07/11 1/2] vdev: new registration API Olivier Matz
2014-04-11  7:36       ` [dpdk-dev] [PATCH v2 07/11 2/2] vdev: allow external registration of virtual device drivers Olivier Matz
2014-04-11 14:31         ` Thomas Monjalon
2014-04-11 10:49       ` [dpdk-dev] [PATCH v2 07/11 1/2] vdev: new registration API Neil Horman
2014-04-11 13:11         ` Thomas Monjalon
2014-04-11 15:50           ` Neil Horman
2014-04-11 16:18             ` Thomas Monjalon
2014-04-11 17:44               ` Neil Horman
2014-04-11 20:08                 ` Richardson, Bruce
2014-04-12  6:05                   ` Thomas Monjalon
2014-04-12 11:03                     ` Neil Horman
2014-04-12 11:23                       ` Richardson, Bruce
2014-04-12 14:06                         ` Neil Horman
2014-04-14 13:20                     ` John W. Linville
2014-04-14 13:45                       ` Thomas Monjalon
2014-04-14 13:54                         ` Neil Horman
2014-04-14 14:10                         ` John W. Linville
2014-04-14 14:39                           ` Thomas Monjalon
2014-04-11 14:31       ` Thomas Monjalon
2014-02-28 17:25 ` [dpdk-dev] [PATCH 08/11] device-args: use a comma instead of semicolon to separate key/values Olivier Matz
2014-04-10 14:05   ` Thomas Monjalon
2014-02-28 17:25 ` Olivier Matz [this message]
2014-03-01 12:14   ` [dpdk-dev] [PATCH v2 09/11] device-args: replace use-device eal option by pci-whitelist and vdev Olivier Matz
2014-04-10 14:06     ` Thomas Monjalon
2014-03-03 17:14   ` [dpdk-dev] [PATCH " Richardson, Bruce
2014-03-04 13:09     ` Olivier MATZ
2014-03-04 13:14       ` Richardson, Bruce
2014-03-24 22:39         ` Thomas Monjalon
2014-02-28 17:25 ` [dpdk-dev] [PATCH 10/11] device-args: allow to provide per pci device command line arguments Olivier Matz
2014-03-01 12:14   ` [dpdk-dev] [PATCH v2 " Olivier Matz
2014-04-10 14:06     ` Thomas Monjalon
2014-02-28 17:25 ` [dpdk-dev] [PATCH 11/11] testpmd: add several dump commands, useful for debug Olivier Matz
2014-03-01 12:15   ` [dpdk-dev] [PATCH v2 " Olivier Matz
2014-04-10 14:08     ` Thomas Monjalon

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=1393608350-4431-10-git-send-email-olivier.matz@6wind.com \
    --to=olivier.matz@6wind.com \
    --cc=dev@dpdk.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).