DPDK patches and discussions
 help / color / mirror / Atom feed
From: Gaetan Rivet <gaetan.rivet@6wind.com>
To: dev@dpdk.org
Cc: Gaetan Rivet <gaetan.rivet@6wind.com>
Subject: [dpdk-dev] [PATCH v2 13/13] eal: add generic dev parameter
Date: Wed, 19 Sep 2018 18:03:43 +0200	[thread overview]
Message-ID: <af5ac3f6c87f60c958388a9cdd75c2ce4a70de93.1537372746.git.gaetan.rivet@6wind.com> (raw)
In-Reply-To: <cover.1537372746.git.gaetan.rivet@6wind.com>

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 <gaetan.rivet@6wind.com>
---
 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 dac2402a4..f1f4628db 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -219,6 +219,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 ddd624110..703932a30 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         },
@@ -111,6 +112,7 @@ TAILQ_HEAD(device_option_list, device_option);
 struct device_option {
 	TAILQ_ENTRY(device_option) next;
 
+	int new;
 	enum rte_devtype type;
 	char arg[];
 };
@@ -123,7 +125,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;
@@ -137,6 +140,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");
@@ -156,7 +160,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);
@@ -1088,7 +1107,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;
@@ -1098,7 +1117,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;
@@ -1234,9 +1253,16 @@ eal_parse_common_option(int opt, const char *optarg,
 		}
 		break;
 
+	case OPT_DEV_NUM:
+		/* devtype is meaningless in the new format. */
+		if (eal_option_device_add(0, 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 96e166787..8a17eb22c 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.18.0

  parent reply	other threads:[~2018-09-19 16:04 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-30 13:41 [dpdk-dev] [PATCH v1 00/13] Implement new devargs framework Gaetan Rivet
2018-08-30 13:41 ` [dpdk-dev] [PATCH v1 01/13] bus/pci: implement device iteration and comparison Gaetan Rivet
2018-08-30 13:41 ` [dpdk-dev] [PATCH v1 02/13] bus/pci: add device matching field id Gaetan Rivet
2018-08-30 13:41 ` [dpdk-dev] [PATCH v1 03/13] bus/vdev: implement device iteration Gaetan Rivet
2018-08-30 13:41 ` [dpdk-dev] [PATCH v1 04/13] bus/vdev: add device matching field driver Gaetan Rivet
2018-08-30 13:41 ` [dpdk-dev] [PATCH v1 05/13] ethdev: add private generic device iterator Gaetan Rivet
2018-08-31 10:09   ` Andrew Rybchenko
2018-08-31 10:22     ` Gaëtan Rivet
2018-08-30 13:41 ` [dpdk-dev] [PATCH v1 06/13] ethdev: register ether layer as a class Gaetan Rivet
2018-08-31 10:09   ` Andrew Rybchenko
2018-08-30 13:41 ` [dpdk-dev] [PATCH v1 07/13] ethdev: add device matching field name Gaetan Rivet
2018-08-31 10:10   ` Andrew Rybchenko
2018-08-30 13:41 ` [dpdk-dev] [PATCH v1 08/13] app/testpmd: add show device command Gaetan Rivet
2018-08-30 13:42 ` [dpdk-dev] [PATCH v1 09/13] bus/pci: pre-process declarative PCI devargs Gaetan Rivet
2018-08-30 13:42 ` [dpdk-dev] [PATCH v1 10/13] bus/vdev: pre-process declarative vdev devargs Gaetan Rivet
2018-08-30 13:42 ` [dpdk-dev] [PATCH v1 11/13] bus/pci: process declarative PCI devargs Gaetan Rivet
2018-08-30 16:15   ` Stephen Hemminger
2018-08-30 16:37     ` Gaëtan Rivet
2018-08-30 13:42 ` [dpdk-dev] [PATCH v1 12/13] ethdev: process declarative eth devargs Gaetan Rivet
2018-08-31 10:10   ` Andrew Rybchenko
2018-08-31 12:16     ` Gaëtan Rivet
2018-08-30 13:42 ` [dpdk-dev] [PATCH v1 13/13] eal: add generic dev parameter Gaetan Rivet
2018-08-30 15:42 ` [dpdk-dev] [PATCH v1 00/13] Implement new devargs framework Stephen Hemminger
2018-09-19 16:03 ` [dpdk-dev] [PATCH v2 " Gaetan Rivet
2018-09-19 16:03   ` [dpdk-dev] [PATCH v2 01/13] bus/pci: implement device iteration and comparison Gaetan Rivet
2018-09-19 16:03   ` [dpdk-dev] [PATCH v2 02/13] bus/pci: add device matching field id Gaetan Rivet
2018-09-19 16:03   ` [dpdk-dev] [PATCH v2 03/13] bus/vdev: implement device iteration Gaetan Rivet
2018-09-19 16:03   ` [dpdk-dev] [PATCH v2 04/13] bus/vdev: add device matching field driver Gaetan Rivet
2018-09-20 16:11     ` Thomas Monjalon
2018-09-21 11:53       ` Gaëtan Rivet
2018-09-21 12:55         ` Thomas Monjalon
2018-09-19 16:03   ` [dpdk-dev] [PATCH v2 05/13] ethdev: add private generic device iterator Gaetan Rivet
2018-09-20 10:02     ` Andrew Rybchenko
2018-09-19 16:03   ` [dpdk-dev] [PATCH v2 06/13] ethdev: register ether layer as a class Gaetan Rivet
2018-09-19 16:03   ` [dpdk-dev] [PATCH v2 07/13] ethdev: add device matching field name Gaetan Rivet
2018-09-20 16:17     ` Thomas Monjalon
2018-09-21 12:16       ` Gaëtan Rivet
2018-09-21 13:06         ` Thomas Monjalon
2018-09-19 16:03   ` [dpdk-dev] [PATCH v2 08/13] app/testpmd: add show device command Gaetan Rivet
2018-09-19 16:03   ` [dpdk-dev] [PATCH v2 09/13] bus/pci: pre-process declarative PCI devargs Gaetan Rivet
2018-09-19 16:03   ` [dpdk-dev] [PATCH v2 10/13] bus/vdev: pre-process declarative vdev devargs Gaetan Rivet
2018-09-19 16:03   ` [dpdk-dev] [PATCH v2 11/13] bus/pci: process declarative PCI devargs Gaetan Rivet
2018-09-19 16:03   ` [dpdk-dev] [PATCH v2 12/13] ethdev: process declarative eth devargs Gaetan Rivet
2018-09-20 10:11     ` Andrew Rybchenko
2018-09-19 16:03   ` Gaetan Rivet [this message]
2018-10-03 12:31   ` [dpdk-dev] [PATCH v2 00/13] Implement new devargs framework Thomas Monjalon
2020-02-19  5:43     ` Pavan Nikhilesh Bhagavatula

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=af5ac3f6c87f60c958388a9cdd75c2ce4a70de93.1537372746.git.gaetan.rivet@6wind.com \
    --to=gaetan.rivet@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).