From: Olivier Matz Date: Fri, 25 Apr 2014 11:59:41 +0000 (+0200) Subject: devargs: use devargs for vdev and PCI lists with bsd X-Git-Tag: spdx-start~10873 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=cd25fb08639e111d77f766b860f3cad5452bec83;p=dpdk.git devargs: use devargs for vdev and PCI lists with bsd The bsdapp part was missing in commit 12204589517e06230e24e0f23396222f2929bd77. This patch removes old whitelist code and use the newly introduced rte_devargs to get the PCI white list, the PCI black list and the list of virtual devices. Signed-off-by: Olivier Matz Acked-by: Neil Horman --- diff --git a/lib/librte_eal/bsdapp/eal/Makefile b/lib/librte_eal/bsdapp/eal/Makefile index 5f991ebc78..8d67ec4af3 100644 --- a/lib/librte_eal/bsdapp/eal/Makefile +++ b/lib/librte_eal/bsdapp/eal/Makefile @@ -68,7 +68,6 @@ SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_tailqs.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_errno.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_cpuflags.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_hexdump.c -SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_whitelist.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_devargs.c SRCS-$(CONFIG_RTE_LIBRTE_EAL_BSDAPP) += eal_common_vdev.c diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c index 7bac3521ae..ddfb026ab9 100644 --- a/lib/librte_eal/bsdapp/eal/eal.c +++ b/lib/librte_eal/bsdapp/eal/eal.c @@ -2,6 +2,7 @@ * BSD LICENSE * * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. + * Copyright(c) 2014 6WIND S.A. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -65,6 +66,7 @@ #include #include #include +#include #include #include #include @@ -132,8 +134,6 @@ static struct rte_config rte_config = { .mem_config = &early_mem_config, }; -static struct rte_pci_addr eal_dev_blacklist[RTE_EAL_BLACKLIST_SIZE]; - /* internal configuration (per-core) */ struct lcore_config lcore_config[RTE_MAX_LCORE]; @@ -307,15 +307,15 @@ eal_usage(const char *prgname) " -c COREMASK : A hexadecimal bitmask of cores to run on\n" " -n NUM : Number of memory channels\n" " -v : Display version information on startup\n" - " -b : to prevent EAL from using specified " - "PCI device\n" " (multiple -b options are allowed)\n" " -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. " - "Use comma-separate <[domain:]bus:devid.func> values.\n" - " [NOTE: Cannot be used with -b option]\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 [;key=val;...]\n" + " to add a virtual device.\n" + " [NOTE: PCI whitelist cannot be used with -b option]\n" " --"OPT_VMWARE_TSC_MAP": use VMware TSC map instead of " "native RDTSC\n" "\nEAL options for DEBUG use only:\n" @@ -483,20 +483,31 @@ eal_parse_proc_type(const char *arg) return RTE_PROC_INVALID; } -static ssize_t -eal_parse_blacklist_opt(const char *optarg, size_t idx) +static int +eal_parse_use_device(const char *optarg) { - if (idx >= sizeof (eal_dev_blacklist) / sizeof (eal_dev_blacklist[0])) { - RTE_LOG(ERR, EAL, "%s - too many devices to blacklist...\n", optarg); - return (-EINVAL); - } else if (eal_parse_pci_DomBDF(optarg, eal_dev_blacklist + idx) < 0 && - eal_parse_pci_BDF(optarg, eal_dev_blacklist + idx) < 0) { - RTE_LOG(ERR, EAL, "%s - invalid device to blacklist...\n", optarg); - return (-EINVAL); + 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); } - idx += 1; - return (idx); + free(dup); + return 0; } /* Parse the argument given in the command line of the application */ @@ -507,7 +518,6 @@ eal_parse_args(int argc, char **argv) char **argvopt; int option_index; int coremask_ok = 0; - ssize_t blacklist_index = 0; char *prgname = argv[0]; static struct option lgopts[] = { {OPT_NO_HUGE, 0, 0, 0}, @@ -554,8 +564,8 @@ eal_parse_args(int argc, char **argv) switch (opt) { /* blacklist */ case 'b': - if ((blacklist_index = eal_parse_blacklist_opt(optarg, - blacklist_index)) < 0) { + if (rte_eal_devargs_add(RTE_DEVTYPE_BLACKLISTED_PCI, + optarg) < 0) { eal_usage(prgname); return (-1); } @@ -638,7 +648,12 @@ eal_parse_args(int argc, char **argv) return -1; } else if (!strcmp(lgopts[option_index].name, OPT_USE_DEVICE)) { - eal_dev_whitelist_add_entry(optarg); + if (eal_parse_use_device(optarg) < 0) { + RTE_LOG(ERR, EAL, "invalid parameters for --" + OPT_USE_DEVICE "\n"); + eal_usage(prgname); + return -1; + } } else if (!strcmp(lgopts[option_index].name, OPT_SYSLOG)) { if (eal_parse_syslog(optarg) < 0) { @@ -697,20 +712,12 @@ eal_parse_args(int argc, char **argv) return -1; } - /* if no blacklist, parse a whitelist */ - if (blacklist_index > 0) { - if (eal_dev_whitelist_exists()) { - RTE_LOG(ERR, EAL, "Error: blacklist [-b] and whitelist " - "[--use-device] options cannot be used at the same time\n"); - eal_usage(prgname); - return -1; - } - rte_eal_pci_set_blacklist(eal_dev_blacklist, blacklist_index); - } else { - if (eal_dev_whitelist_exists() && eal_dev_whitelist_parse() < 0) { - RTE_LOG(ERR,EAL, "Error parsing whitelist[--use-device] options\n"); - return -1; - } + 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"); + eal_usage(prgname); + return -1; } if (optind >= 0)