DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ben Walker <benjamin.walker@intel.com>
To: dev@dpdk.org
Cc: Ben Walker <benjamin.walker@intel.com>
Subject: [dpdk-dev] [PATCH 6/7] pci: Combine rte_eal_pci_scan and rte_eal_pci_probe
Date: Wed, 23 Nov 2016 12:36:43 -0700	[thread overview]
Message-ID: <1479929804-19614-7-git-send-email-benjamin.walker@intel.com> (raw)
In-Reply-To: <1479929804-19614-1-git-send-email-benjamin.walker@intel.com>

Two functions is both confusing and unnecessary. Previously,
rte_eal_pci_scan populated an internal list of devices by
scanning sysfs. Then, rte_eal_pci_probe would match registered
drivers to that internal list. These are not really useful
operations to perform separately independently, though, so
simplify the api down to just rte_eal_pci_probe which can
be called repeatedly through the lifetime of the application
to scan for new or removed PCI devices and load or unload
drivers as required.

Signed-off-by: Ben Walker <benjamin.walker@intel.com>
---
 app/test/test_pci.c                             |  2 +-
 lib/librte_eal/bsdapp/eal/eal.c                 |  3 ---
 lib/librte_eal/bsdapp/eal/eal_pci.c             | 17 +----------------
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  1 -
 lib/librte_eal/common/eal_common_pci.c          |  7 +++++++
 lib/librte_eal/common/eal_private.h             | 14 +++++---------
 lib/librte_eal/common/include/rte_pci.h         | 17 +++++------------
 lib/librte_eal/linuxapp/eal/eal.c               |  3 ---
 lib/librte_eal/linuxapp/eal/eal_pci.c           | 18 +-----------------
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  1 -
 10 files changed, 20 insertions(+), 63 deletions(-)

diff --git a/app/test/test_pci.c b/app/test/test_pci.c
index cda186d..fdd84f7 100644
--- a/app/test/test_pci.c
+++ b/app/test/test_pci.c
@@ -180,7 +180,7 @@ test_pci_setup(void)
 		TAILQ_INSERT_TAIL(&real_pci_device_list, dev, next);
 	}
 
-	ret = rte_eal_pci_scan();
+	ret = rte_eal_pci_probe();
 	TEST_ASSERT_SUCCESS(ret, "failed to scan PCI bus");
 	rte_eal_pci_dump(stdout);
 
diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c
index 35e3117..fd44528 100644
--- a/lib/librte_eal/bsdapp/eal/eal.c
+++ b/lib/librte_eal/bsdapp/eal/eal.c
@@ -561,9 +561,6 @@ rte_eal_init(int argc, char **argv)
 	if (rte_eal_timer_init() < 0)
 		rte_panic("Cannot init HPET or TSC timers\n");
 
-	if (rte_eal_pci_init() < 0)
-		rte_panic("Cannot init PCI\n");
-
 	eal_check_mem_on_local_socket();
 
 	if (eal_plugins_init() < 0)
diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c
index 8b3ed88..6c3a169 100644
--- a/lib/librte_eal/bsdapp/eal/eal_pci.c
+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
@@ -361,7 +361,7 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)
  * list. Call pci_scan_one() for each pci entry found.
  */
 int
-rte_eal_pci_scan(void)
+pci_scan(void)
 {
 	int fd;
 	unsigned dev_count = 0;
@@ -667,18 +667,3 @@ rte_eal_pci_ioport_unmap(struct rte_pci_ioport *p)
 
 	return ret;
 }
-
-/* Init the PCI EAL subsystem */
-int
-rte_eal_pci_init(void)
-{
-	/* for debug purposes, PCI can be disabled */
-	if (internal_config.no_pci)
-		return 0;
-
-	if (rte_eal_pci_scan() < 0) {
-		RTE_LOG(ERR, EAL, "%s(): Cannot scan PCI bus\n", __func__);
-		return -1;
-	}
-	return 0;
-}
diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index 2f81f7c..67c469c 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -44,7 +44,6 @@ DPDK_2.0 {
 	rte_eal_pci_probe;
 	rte_eal_pci_probe_one;
 	rte_eal_pci_register;
-	rte_eal_pci_scan;
 	rte_eal_pci_unregister;
 	rte_eal_process_type;
 	rte_eal_remote_launch;
diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index 4f8c3a0..62b996d 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -81,6 +81,7 @@
 #include <rte_devargs.h>
 
 #include "eal_private.h"
+#include "eal_internal_cfg.h"
 
 struct pci_driver_list pci_driver_list =
 	TAILQ_HEAD_INITIALIZER(pci_driver_list);
@@ -423,6 +424,12 @@ rte_eal_pci_probe(void)
 	int probe_all = 0;
 	int ret = 0;
 
+	if (internal_config.no_pci) {
+		return 0;
+	}
+
+	pci_scan();
+
 	if (rte_eal_devargs_type_count(RTE_DEVTYPE_WHITELISTED_PCI) == 0)
 		probe_all = 1;
 
diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h
index 9e7d8f6..54f18ea 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -108,18 +108,14 @@ int rte_eal_timer_init(void);
  */
 int rte_eal_log_init(const char *id, int facility);
 
-/**
- * Init the PCI infrastructure
+struct rte_pci_driver;
+struct rte_pci_device;
+
+/* Scan the PCI bus for devices
  *
  * This function is private to EAL.
- *
- * @return
- *   0 on success, negative on error
  */
-int rte_eal_pci_init(void);
-
-struct rte_pci_driver;
-struct rte_pci_device;
+int pci_scan(void);
 
 /**
  * Update a pci device object by asking the kernel for the latest information.
diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h
index 5d0feac..2154a54 100644
--- a/lib/librte_eal/common/include/rte_pci.h
+++ b/lib/librte_eal/common/include/rte_pci.h
@@ -386,20 +386,13 @@ RTE_PMD_EXPORT_NAME(nm, __COUNTER__)
 void rte_eal_pci_unregister(struct rte_pci_driver *driver);
 
 /**
- * Scan the content of the PCI bus, and the devices in the devices
- * list
- *
- * @return
- *  0 on success, negative on error
- */
-int rte_eal_pci_scan(void);
-
-/**
- * Probe the PCI bus for registered drivers.
+ * Scan the PCI bus for devices and match them to their driver.
  *
  * Scan the content of the PCI bus, and call the probe() function for
- * all registered drivers that have a matching entry in its id_table
- * for discovered devices.
+ * all registered drivers that have a matching entry in their id_table.
+ * If a device already has a driver loaded, probe will not be called.
+ * If a previously discovered device is no longer present on the system,
+ * the associated driver's remove() callback will be called.
  *
  * @return
  *   - 0 on success.
diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
index 2075282..f47f361 100644
--- a/lib/librte_eal/linuxapp/eal/eal.c
+++ b/lib/librte_eal/linuxapp/eal/eal.c
@@ -802,9 +802,6 @@ rte_eal_init(int argc, char **argv)
 	if (rte_eal_log_init(logid, internal_config.syslog_facility) < 0)
 		rte_panic("Cannot init logs\n");
 
-	if (rte_eal_pci_init() < 0)
-		rte_panic("Cannot init PCI\n");
-
 #ifdef VFIO_PRESENT
 	if (rte_eal_vfio_setup() < 0)
 		rte_panic("Cannot init VFIO\n");
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c
index f237864..663e106 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -479,7 +479,7 @@ parse_pci_addr_format(const char *buf, int bufsize, struct rte_pci_addr *addr)
  * list
  */
 int
-rte_eal_pci_scan(void)
+pci_scan(void)
 {
 	struct dirent *e;
 	DIR *dir;
@@ -806,19 +806,3 @@ rte_eal_pci_ioport_unmap(struct rte_pci_ioport *p)
 
 	return ret;
 }
-
-/* Init the PCI EAL subsystem */
-int
-rte_eal_pci_init(void)
-{
-	/* for debug purposes, PCI can be disabled */
-	if (internal_config.no_pci)
-		return 0;
-
-	if (rte_eal_pci_scan() < 0) {
-		RTE_LOG(ERR, EAL, "%s(): Cannot scan PCI bus\n", __func__);
-		return -1;
-	}
-
-	return 0;
-}
diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
index 83721ba..856728e 100644
--- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
@@ -44,7 +44,6 @@ DPDK_2.0 {
 	rte_eal_pci_probe;
 	rte_eal_pci_probe_one;
 	rte_eal_pci_register;
-	rte_eal_pci_scan;
 	rte_eal_pci_unregister;
 	rte_eal_process_type;
 	rte_eal_remote_launch;
-- 
2.7.4

  parent reply	other threads:[~2016-11-23 19:36 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-23 19:36 [dpdk-dev] Improved PCI hotplug support Ben Walker
2016-11-23 19:36 ` [dpdk-dev] [PATCH 1/7] pci: If a driver's probe function fails, unmap resources Ben Walker
2016-11-23 19:36 ` [dpdk-dev] [PATCH 2/7] pci: Separate detaching ethernet ports from PCI devices Ben Walker
2016-11-23 19:36 ` [dpdk-dev] [PATCH 3/7] pci: Pass rte_pci_addr to functions instead of separate args Ben Walker
2016-11-23 19:36 ` [dpdk-dev] [PATCH 4/7] pci: rte_eal_pci_scan now handles removal of PCI devices Ben Walker
2016-11-23 19:36 ` [dpdk-dev] [PATCH 5/7] pci: Move driver registration above pci scan Ben Walker
2016-11-23 19:36 ` Ben Walker [this message]
2016-11-23 19:36 ` [dpdk-dev] [PATCH 7/7] pci: Clarify interfaces for dynamic attach/detach of drivers Ben Walker
2016-11-23 20:07 ` [dpdk-dev] [PATCH v2 1/7] pci: If a driver's probe function fails, unmap resources Ben Walker
2016-11-23 20:07   ` [dpdk-dev] [PATCH v2 2/7] pci: Separate detaching ethernet ports from PCI devices Ben Walker
2016-11-25  9:25     ` Shreyansh Jain
2016-11-23 20:07   ` [dpdk-dev] [PATCH v2 3/7] pci: Pass rte_pci_addr to functions instead of separate args Ben Walker
2016-11-25 10:33     ` Shreyansh Jain
2016-12-01  6:26     ` Shreyansh Jain
2016-12-02 16:16       ` Walker, Benjamin
2016-11-23 20:07   ` [dpdk-dev] [PATCH v2 4/7] pci: rte_eal_pci_scan now handles removal of PCI devices Ben Walker
2016-11-25 10:44     ` Shreyansh Jain
2017-02-09 16:59     ` [dpdk-dev] [PATCH v3 1/3] " Ben Walker
2017-02-09 16:59       ` [dpdk-dev] [PATCH v3 2/3] pci: Move driver registration above pci scan Ben Walker
2017-02-09 16:59       ` [dpdk-dev] [PATCH v3 3/3] pci: Clarify interfaces for dynamic attach/detach of drivers Ben Walker
2019-01-23 16:19       ` [dpdk-dev] [PATCH v3 1/3] pci: rte_eal_pci_scan now handles removal of PCI devices Ferruh Yigit
2016-11-23 20:07   ` [dpdk-dev] [PATCH v2 5/7] pci: Move driver registration above pci scan Ben Walker
2016-11-23 20:07   ` [dpdk-dev] [PATCH v2 6/7] pci: Combine rte_eal_pci_scan and rte_eal_pci_probe Ben Walker
2016-11-25 10:56     ` Shreyansh Jain
2016-11-23 20:07   ` [dpdk-dev] [PATCH v2 7/7] pci: Clarify interfaces for dynamic attach/detach of drivers Ben Walker
2016-12-03  6:55     ` Shreyansh Jain
2016-11-25  9:21   ` [dpdk-dev] [PATCH v2 1/7] pci: If a driver's probe function fails, unmap resources Shreyansh Jain
2016-12-21 16:19     ` Thomas Monjalon
2017-01-04 17:39       ` Thomas Monjalon
2017-01-09 17:12         ` Thomas Monjalon
2017-01-11 17:10   ` [dpdk-dev] [PATCH v3 1/3] " Ben Walker
2017-01-11 17:10     ` [dpdk-dev] [PATCH v3 2/3] pci: Separate detaching ethernet ports from PCI devices Ben Walker
2017-01-11 17:10     ` [dpdk-dev] [PATCH v3 3/3] pci: Pass rte_pci_addr to functions instead of separate args Ben Walker
2017-01-12 14:58       ` Thomas Monjalon

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=1479929804-19614-7-git-send-email-benjamin.walker@intel.com \
    --to=benjamin.walker@intel.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).