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 v1 01/13] bus/pci: implement device iteration and comparison
Date: Thu, 30 Aug 2018 15:41:52 +0200	[thread overview]
Message-ID: <e43e97e762d5cf8865f93c202098a970904403ba.1535633784.git.gaetan.rivet@6wind.com> (raw)
In-Reply-To: <cover.1535633783.git.gaetan.rivet@6wind.com>

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 drivers/bus/pci/Makefile     |  3 +-
 drivers/bus/pci/meson.build  |  6 +++-
 drivers/bus/pci/pci_common.c |  3 +-
 drivers/bus/pci/pci_params.c | 53 ++++++++++++++++++++++++++++++++++++
 drivers/bus/pci/private.h    | 25 +++++++++++++++++
 5 files changed, 86 insertions(+), 4 deletions(-)
 create mode 100644 drivers/bus/pci/pci_params.c

diff --git a/drivers/bus/pci/Makefile b/drivers/bus/pci/Makefile
index cf373068a..4de953f8f 100644
--- a/drivers/bus/pci/Makefile
+++ b/drivers/bus/pci/Makefile
@@ -26,10 +26,11 @@ CFLAGS += -I$(RTE_SDK)/lib/librte_eal/$(SYSTEM)app/eal
 CFLAGS += -DALLOW_EXPERIMENTAL_API
 
 LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
-LDLIBS += -lrte_ethdev -lrte_pci
+LDLIBS += -lrte_ethdev -lrte_pci -lrte_kvargs
 
 include $(RTE_SDK)/drivers/bus/pci/$(SYSTEM)/Makefile
 SRCS-$(CONFIG_RTE_LIBRTE_PCI_BUS) := $(addprefix $(SYSTEM)/,$(SRCS))
+SRCS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci_params.c
 SRCS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci_common.c
 SRCS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci_common_uio.c
 
diff --git a/drivers/bus/pci/meson.build b/drivers/bus/pci/meson.build
index 72939e598..23d6a5fec 100644
--- a/drivers/bus/pci/meson.build
+++ b/drivers/bus/pci/meson.build
@@ -3,7 +3,9 @@
 
 deps += ['pci']
 install_headers('rte_bus_pci.h')
-sources = files('pci_common.c', 'pci_common_uio.c')
+sources = files('pci_common.c',
+	'pci_common_uio.c',
+	'pci_params.c')
 if host_machine.system() == 'linux'
 	sources += files('linux/pci.c',
 			'linux/pci_uio.c',
@@ -17,3 +19,5 @@ endif
 
 # memseg walk is not part of stable API yet
 allow_experimental_apis = true
+
+deps += ['kvargs']
diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
index 7736b3f9c..c7695d108 100644
--- a/drivers/bus/pci/pci_common.c
+++ b/drivers/bus/pci/pci_common.c
@@ -27,8 +27,6 @@
 #include "private.h"
 
 
-extern struct rte_pci_bus rte_pci_bus;
-
 #define SYSFS_PCI_DEVICES "/sys/bus/pci/devices"
 
 const char *rte_pci_get_sysfs_path(void)
@@ -435,6 +433,7 @@ struct rte_pci_bus rte_pci_bus = {
 		.unplug = pci_unplug,
 		.parse = pci_parse,
 		.get_iommu_class = rte_pci_get_iommu_class,
+		.dev_iterate = rte_pci_dev_iterate,
 	},
 	.device_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.device_list),
 	.driver_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.driver_list),
diff --git a/drivers/bus/pci/pci_params.c b/drivers/bus/pci/pci_params.c
new file mode 100644
index 000000000..0fde75803
--- /dev/null
+++ b/drivers/bus/pci/pci_params.c
@@ -0,0 +1,53 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2018 Gaëtan Rivet
+ */
+
+#include <rte_bus.h>
+#include <rte_dev.h>
+#include <rte_errno.h>
+#include <rte_kvargs.h>
+#include <rte_pci.h>
+
+#include "private.h"
+
+enum pci_params {
+	RTE_PCI_PARAMS_MAX,
+};
+
+static const char * const pci_params_keys[] = {
+	[RTE_PCI_PARAMS_MAX] = NULL,
+};
+
+static int
+pci_dev_match(const struct rte_device *dev,
+	      const void *_kvlist)
+{
+	const struct rte_kvargs *kvlist = _kvlist;
+
+	(void) dev;
+	(void) kvlist;
+	return 0;
+}
+
+void *
+rte_pci_dev_iterate(const void *start,
+		    const char *str,
+		    const struct rte_dev_iterator *it __rte_unused)
+{
+	rte_bus_find_device_t find_device;
+	struct rte_kvargs *kvargs = NULL;
+	struct rte_device *dev;
+
+	if (str != NULL) {
+		kvargs = rte_kvargs_parse(str, pci_params_keys);
+		if (kvargs == NULL) {
+			RTE_LOG(ERR, EAL, "cannot parse argument list\n");
+			rte_errno = EINVAL;
+			return NULL;
+		}
+	}
+	find_device = rte_pci_bus.bus.find_device;
+	dev = find_device(start, pci_dev_match, kvargs);
+	rte_kvargs_free(kvargs);
+	return dev;
+}
diff --git a/drivers/bus/pci/private.h b/drivers/bus/pci/private.h
index 8ddd03e16..0e689fa74 100644
--- a/drivers/bus/pci/private.h
+++ b/drivers/bus/pci/private.h
@@ -10,6 +10,8 @@
 #include <rte_pci.h>
 #include <rte_bus_pci.h>
 
+extern struct rte_pci_bus rte_pci_bus;
+
 struct rte_pci_driver;
 struct rte_pci_device;
 
@@ -166,4 +168,27 @@ rte_pci_match(const struct rte_pci_driver *pci_drv,
 enum rte_iova_mode
 rte_pci_get_iommu_class(void);
 
+/*
+ * Iterate over internal devices,
+ * matching any device against the provided
+ * string.
+ *
+ * @param start
+ *   Iteration starting point.
+ *
+ * @param str
+ *   Device string to match against.
+ *
+ * @param it
+ *   (unused) iterator structure.
+ *
+ * @return
+ *   A pointer to the next matching device if any.
+ *   NULL otherwise.
+ */
+void *
+rte_pci_dev_iterate(const void *start,
+		    const char *str,
+		    const struct rte_dev_iterator *it);
+
 #endif /* _PCI_PRIVATE_H_ */
-- 
2.18.0

  reply	other threads:[~2018-08-30 13:42 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 ` Gaetan Rivet [this message]
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   ` [dpdk-dev] [PATCH v2 13/13] eal: add generic dev parameter Gaetan Rivet
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=e43e97e762d5cf8865f93c202098a970904403ba.1535633784.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).