dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
From: Olivier Matz <olivier.matz-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
To: dev-VfR2kkLFssw@public.gmane.org
Subject: [PATCH 05/10] bsd/devargs: replace --use-device option by --pci-whitelist and --vdev
Date: Fri, 25 Apr 2014 13:59:43 +0200	[thread overview]
Message-ID: <1398427188-14914-6-git-send-email-olivier.matz@6wind.com> (raw)
In-Reply-To: <1398427188-14914-1-git-send-email-olivier.matz-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>

The bsdapp part was missing in commit cac6d08c8bde2fdb57806c49038187cdb54219a8.

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

Signed-off-by: Olivier Matz <olivier.matz-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
---
 lib/librte_eal/bsdapp/eal/eal.c | 89 +++++++++++++++++++++++------------------
 1 file changed, 50 insertions(+), 39 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index 48bce40..633069e 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -88,7 +88,10 @@
 #define OPT_NO_HUGE     "no-huge"
 #define OPT_FILE_PREFIX "file-prefix"
 #define OPT_SOCKET_MEM  "socket-mem"
-#define OPT_USE_DEVICE  "use-device"
+#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 RTE_EAL_BLACKLIST_SIZE	0x100
@@ -311,11 +314,17 @@ eal_usage(const char *prgname)
 	       "  -m MB        : memory to allocate\n"
 	       "  -r NUM       : force number of memory ranks (don't detect)\n"
 	       "  --"OPT_PROC_TYPE"  : type of this process\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"
-	       " [NOTE: PCI whitelist cannot be used with -b option]\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"
 	       "\nEAL options for DEBUG use only:\n"
@@ -483,33 +492,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)
@@ -529,7 +511,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},
 		{0, 0, 0, 0}
 	};
@@ -558,7 +542,7 @@ eal_parse_args(int argc, char **argv)
 
 	internal_config.vmware_tsc_map = 0;
 
-	while ((opt = getopt_long(argc, argvopt, "b:c:m:n:r:v",
+	while ((opt = getopt_long(argc, argvopt, "b:w:c:m:n:r:v",
 				  lgopts, &option_index)) != EOF) {
 
 		switch (opt) {
@@ -570,6 +554,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) {
@@ -648,9 +640,28 @@ eal_parse_args(int argc, char **argv)
 				return -1;
 			}
 			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;
 				}
@@ -715,7 +726,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.9.2

  parent reply	other threads:[~2014-04-25 11:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-25 11:59 [PATCH 00/10] bsd: fix compilation Olivier Matz
     [not found] ` <1398427188-14914-1-git-send-email-olivier.matz-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2014-04-25 11:59   ` [PATCH 01/10] bsd/pci: rename device and driver lists Olivier Matz
2014-04-25 11:59   ` [PATCH 02/10] bsd/devargs: introduce API and test Olivier Matz
2014-04-25 11:59   ` [PATCH 03/10] bsd/devargs: use devargs for vdev and PCI whitelist/blacklist Olivier Matz
2014-04-25 11:59   ` [PATCH 04/10] bsd/devargs: use a comma instead of semicolon to separate key/values Olivier Matz
2014-04-25 11:59   ` Olivier Matz [this message]
2014-04-25 11:59   ` [PATCH 06/10] bsd/devargs: allow to provide arguments per pci device Olivier Matz
2014-04-25 11:59   ` [PATCH 07/10] bsd/nic_uio: fix module compilation with freebsd 10 Olivier Matz
2014-04-25 11:59   ` [PATCH 08/10] bsd/mk: use the Q variable instead of @ for quiet commands Olivier Matz
     [not found]     ` <1398427188-14914-9-git-send-email-olivier.matz-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2014-04-25 13:19       ` Neil Horman
     [not found]         ` <20140425131912.GD14074-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org>
2014-04-25 14:18           ` Thomas Monjalon
2014-04-25 11:59   ` [PATCH 09/10] bsd/mem: get hugepages config Olivier Matz
2014-04-25 11:59   ` [PATCH 10/10] bsd/mem: get physical address of any pointer Olivier Matz
2014-04-25 13:27   ` [PATCH 00/10] bsd: fix compilation Neil Horman
     [not found]     ` <20140425132754.GE14074-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org>
2014-04-29 23:37       ` 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=1398427188-14914-6-git-send-email-olivier.matz@6wind.com \
    --to=olivier.matz-pdr9zngts4eavxtiumwx3w@public.gmane.org \
    --cc=dev-VfR2kkLFssw@public.gmane.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).