From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) by dpdk.org (Postfix) with ESMTP id 39C0FAFD0 for ; Fri, 25 Apr 2014 14:00:10 +0200 (CEST) Received: by mail-wi0-f181.google.com with SMTP id hm4so2521802wib.2 for ; Fri, 25 Apr 2014 05:00:13 -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=lNaDvwKRif2tW1/dvQEeS9t2KHY++izbALzXPHs61z8=; b=kSArlDErVn0jiVLDREbxELdo8HNEA4aom+CnfYpUkVwfTo5HhfqdBcyk1gEDaN/waG BuF6N7QtKS6cHeF9jBApKdRXqWLuNnyoJ/yS82cfFGHSRLEPCa9sAjqNVxAb+65AAA+D i9L7dwTDAUd5u6Qa0CtQMaea6hLjsWfAOYgpnaVOkU7ZD+odJYYK/J3ONUigzkH3wuFY c8F6eGc7sSjaJwpo7UEFwI+M3SykeG1wb5K1wLdx5Rvm9i67gcj+6gtZ+OPUK0VOqsN8 ywQel/oPcxWxIbhz5xTSf1mXDabvqyHNi9Bre8qgtGFpNwucSmdFxG/OpCqyubZjXD6Y ev9A== X-Gm-Message-State: ALoCoQmV1wipvRCgvNsf/PXu1r46fIad8IsgvcdxEfQJ0MEPSrSbnGUy7HC9SIQa4gVN5sN52UUJ X-Received: by 10.180.39.178 with SMTP id q18mr3435835wik.56.1398427213036; Fri, 25 Apr 2014 05:00:13 -0700 (PDT) Received: from glumotte.dev.6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id q2sm5487386wix.5.2014.04.25.05.00.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 25 Apr 2014 05:00:12 -0700 (PDT) From: Olivier Matz To: dev@dpdk.org Date: Fri, 25 Apr 2014 13:59:41 +0200 Message-Id: <1398427188-14914-4-git-send-email-olivier.matz@6wind.com> X-Mailer: git-send-email 1.9.2 In-Reply-To: <1398427188-14914-1-git-send-email-olivier.matz@6wind.com> References: <1398427188-14914-1-git-send-email-olivier.matz@6wind.com> Subject: [dpdk-dev] [PATCH 03/10] bsd/devargs: use devargs for vdev and PCI whitelist/blacklist 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: Fri, 25 Apr 2014 12:00:10 -0000 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 --- lib/librte_eal/bsdapp/eal/Makefile | 1 - lib/librte_eal/bsdapp/eal/eal.c | 79 +++++++++++++++++++++----------------- 2 files changed, 43 insertions(+), 37 deletions(-) diff --git a/lib/librte_eal/bsdapp/eal/Makefile b/lib/librte_eal/bsdapp/eal/Makefile index 5f991eb..8d67ec4 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 e944aba..6be706c 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) -- 1.9.2