From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by dpdk.org (Postfix) with ESMTP id 872D41BE91 for ; Wed, 4 Jul 2018 00:16:12 +0200 (CEST) Received: by mail-wm0-f66.google.com with SMTP id l15-v6so11493079wmc.1 for ; Tue, 03 Jul 2018 15:16:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=T5uPh9sAczvEaPKi1t8nJgmi5GdqEglAstltDvtI8Qk=; b=qaluboGjuOyzuNE8cGK2AFP1+QTaDexpZacUw9H1j8RQA6kHwMu6t5ozntG0vxBwOh aGQjZVCsF0XANwUdeKF9P6hov4cm9UJ0/1jwpQ7t+KHi4xuTqRWTBz0pktWoO3ZwmTYh IXOWUnqWAZVpMWQimO1iQ0B9/L8oN5FzobCxihta63aTxQD6F7HWUrsN0Mr/KlVsMtfZ tcN4xaLo2Aa9zB7GfcPo1T3aGyYdbSP2NLchK+MG6P/5Dl7Vxf0Cd8AYVl8O2k3rX9X/ 63gA3wwRrhXsT6txHESZgEf0C5xEc0HLp/KwMphefH4hepHuApcQBbnCCtr+ypqZuGbt teug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=T5uPh9sAczvEaPKi1t8nJgmi5GdqEglAstltDvtI8Qk=; b=hY2AQMAqZ+hgyrKTrtZrakWzctdE428AOYmo0PUkaPlE2H7OiX+IuZhNECqTwrDJVc LVYIP6duk0nQLTZ11ZOcmL9ze7oV3wS/PZeRLTe4ERany5OE6PCCHmgZCB3l1DlPqpVM FoSpsSKUsn9zbiCIwObBErOGEC6CydmXrvXn5JZFXHGlnoRRGH3Z0BohnV1SW6w8H9xk +ZVbnrNOjI8wH/GIROkF4vN3ltnfCyyg7jKBBA8XTFukNuCG67/5EyVWAkSBHNttrVjp 4t/JUHeFHPRw5VfpHjLMXWi8E0FnnmLA3jiOSawuF1xfJiDV5mPNvZ6MYsL5DY6FHTuC PJtQ== X-Gm-Message-State: APt69E2POSrJvbG2zLrLs58VMGnVZ1TaZsNT3PH+0Qe9BtAp9Xng5wE3 vyQXiKC9lhQNT1h+p5BN6ecO6KR4 X-Google-Smtp-Source: AAOMgpcW5CByVuxjbPoYUW9XlvJJo7Ob0rwhZ5G4rSsxBEt4Xb7Xwx/oCR0OlbIrtyykqq4KOe79Xg== X-Received: by 2002:a1c:e541:: with SMTP id c62-v6mr9358768wmh.154.1530656171887; Tue, 03 Jul 2018 15:16:11 -0700 (PDT) Received: from bidouze.dev.6wind.com. (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id i190-v6sm3771084wmd.33.2018.07.03.15.16.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Jul 2018 15:16:10 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet Date: Wed, 4 Jul 2018 00:15:10 +0200 Message-Id: <6408c8c42d43eba322aee3078a6f082c34da0eca.1530655929.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v9 27/27] eal: add generic dev parameter X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Jul 2018 22:16:12 -0000 Add the --dev parameter to the EAL. This new parameter takes a generic device declaration as argument. It uses the new devargs parsing API. Signed-off-by: Gaetan Rivet --- lib/librte_eal/common/eal_common_devargs.c | 4 ++++ lib/librte_eal/common/eal_common_options.c | 36 +++++++++++++++++++++++++----- lib/librte_eal/common/eal_options.h | 2 ++ 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/lib/librte_eal/common/eal_common_devargs.c b/lib/librte_eal/common/eal_common_devargs.c index 5f89e0b6e..bc3ba9fe0 100644 --- a/lib/librte_eal/common/eal_common_devargs.c +++ b/lib/librte_eal/common/eal_common_devargs.c @@ -218,6 +218,10 @@ rte_devargs_parse(struct rte_devargs *da, const char *dev) if (da == NULL) return -EINVAL; + if (strncmp(dev, "bus=", 4) == 0 || + strncmp(dev, "class=", 6) == 0) + return rte_devargs_layers_parse(da, dev); + /* Retrieve eventual bus info */ do { devname = dev; diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index ecebb2923..89d608180 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -54,6 +54,7 @@ const struct option eal_long_options[] = { {OPT_BASE_VIRTADDR, 1, NULL, OPT_BASE_VIRTADDR_NUM }, {OPT_CREATE_UIO_DEV, 0, NULL, OPT_CREATE_UIO_DEV_NUM }, + {OPT_DEV, 1, NULL, OPT_DEV_NUM }, {OPT_FILE_PREFIX, 1, NULL, OPT_FILE_PREFIX_NUM }, {OPT_HELP, 0, NULL, OPT_HELP_NUM }, {OPT_HUGE_DIR, 1, NULL, OPT_HUGE_DIR_NUM }, @@ -109,6 +110,7 @@ TAILQ_HEAD(device_option_list, device_option); struct device_option { TAILQ_ENTRY(device_option) next; + int new; enum rte_devtype type; char arg[]; }; @@ -121,7 +123,8 @@ static int mem_parsed; static int core_parsed; static int -eal_option_device_add(enum rte_devtype type, const char *optarg) +eal_option_device_add(enum rte_devtype type, const char *optarg, + int new) { struct device_option *devopt; size_t optlen; @@ -135,6 +138,7 @@ eal_option_device_add(enum rte_devtype type, const char *optarg) } devopt->type = type; + devopt->new = new; ret = snprintf(devopt->arg, optlen, "%s", optarg); if (ret < 0) { RTE_LOG(ERR, EAL, "Unable to copy device option\n"); @@ -154,7 +158,22 @@ eal_option_device_parse(void) TAILQ_FOREACH_SAFE(devopt, &devopt_list, next, tmp) { if (ret == 0) { - ret = rte_devargs_add(devopt->type, devopt->arg); + if (devopt->new) { + struct rte_devargs *da; + + da = calloc(1, sizeof(*da)); + ret = rte_devargs_parse(da, devopt->arg); + if (ret) { + free(da); + } else { + ret = rte_devargs_insert(da); + if (ret) + free(da); + } + } else { + ret = rte_devargs_add(devopt->type, + devopt->arg); + } if (ret) RTE_LOG(ERR, EAL, "Unable to parse device '%s'\n", devopt->arg); @@ -1038,7 +1057,7 @@ eal_parse_common_option(int opt, const char *optarg, if (w_used) goto bw_used; if (eal_option_device_add(RTE_DEVTYPE_BLACKLISTED_PCI, - optarg) < 0) { + optarg, 0) < 0) { return -1; } b_used = 1; @@ -1048,7 +1067,7 @@ eal_parse_common_option(int opt, const char *optarg, if (b_used) goto bw_used; if (eal_option_device_add(RTE_DEVTYPE_WHITELISTED_PCI, - optarg) < 0) { + optarg, 0) < 0) { return -1; } w_used = 1; @@ -1177,9 +1196,16 @@ eal_parse_common_option(int opt, const char *optarg, } break; + case OPT_DEV_NUM: + if (eal_option_device_add(RTE_DEVTYPE_VIRTUAL, + optarg, 1) < 0) { + return -1; + } + break; + case OPT_VDEV_NUM: if (eal_option_device_add(RTE_DEVTYPE_VIRTUAL, - optarg) < 0) { + optarg, 0) < 0) { return -1; } break; diff --git a/lib/librte_eal/common/eal_options.h b/lib/librte_eal/common/eal_options.h index 211ae06ae..b1851864f 100644 --- a/lib/librte_eal/common/eal_options.h +++ b/lib/librte_eal/common/eal_options.h @@ -21,6 +21,8 @@ enum { OPT_BASE_VIRTADDR_NUM, #define OPT_CREATE_UIO_DEV "create-uio-dev" OPT_CREATE_UIO_DEV_NUM, +#define OPT_DEV "dev" + OPT_DEV_NUM, #define OPT_FILE_PREFIX "file-prefix" OPT_FILE_PREFIX_NUM, #define OPT_HUGE_DIR "huge-dir" -- 2.11.0