DPDK patches and discussions
 help / color / mirror / Atom feed
From: David Marchand <david.marchand@6wind.com>
To: anatoly.burakov@intel.com
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 1/3] pci: pci_switch_module cleanup
Date: Mon, 14 Apr 2014 14:51:50 +0200	[thread overview]
Message-ID: <1397479912-4906-2-git-send-email-david.marchand@6wind.com> (raw)
In-Reply-To: <1397479912-4906-1-git-send-email-david.marchand@6wind.com>

The pci_switch_module() function should only do what its name tells: unbind pci
devices and rebind them on the specified kernel driver.
Hence, it can not call pci_uio_map_resource().

Call to pci_uio_map_resource() should be moved to rte_eal_pci_probe_one_driver()
so that we can factorize code.

Signed-off-by: David Marchand <david.marchand@6wind.com>
---
 lib/librte_eal/linuxapp/eal/eal_pci.c |   21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c
index 9538efe..8e0922d 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -107,9 +107,6 @@ TAILQ_HEAD(uio_res_list, uio_resource);
 static struct uio_res_list *uio_res_list = NULL;
 static int pci_parse_sysfs_value(const char *filename, uint64_t *val);
 
-/* forward prototype of function called in pci_switch_module below */
-static int pci_uio_map_resource(struct rte_pci_device *dev);
-
 #ifdef RTE_EAL_UNBIND_PORTS
 #define PROC_MODULES "/proc/modules"
 
@@ -279,12 +276,11 @@ error:
 
 static int
 pci_switch_module(struct rte_pci_driver *dr, struct rte_pci_device *dev,
-		int uio_status, const char *module_name)
+                  const char *module_name)
 {
 	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
 		/* check that our driver is loaded */
-		if (uio_status != 0 &&
-				(uio_status = pci_uio_check_module(module_name)) != 0)
+		if (pci_uio_check_module(module_name) != 0)
 			rte_exit(EXIT_FAILURE, "The %s module is required by the "
 					"%s driver\n", module_name, dr->name);
 
@@ -294,9 +290,6 @@ pci_switch_module(struct rte_pci_driver *dr, struct rte_pci_device *dev,
 		if (pci_uio_bind_device(dev, module_name) < 0)
 			return -1;
 	}
-	/* map the NIC resources */
-	if (pci_uio_map_resource(dev) < 0)
-		return -1;
 
 	return 0;
 }
@@ -1040,8 +1033,8 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d
 
 #ifdef RTE_EAL_UNBIND_PORTS
 		if (dr->drv_flags & RTE_PCI_DRV_NEED_IGB_UIO) {
-			/* unbind driver and load uio resources for Intel NICs */
-			if (pci_switch_module(dr, dev, 1, IGB_UIO_NAME) < 0)
+			/* unbind current driver and bind on igb_uio */
+			if (pci_switch_module(dr, dev, IGB_UIO_NAME) < 0)
 				return -1;
 		} else if (dr->drv_flags & RTE_PCI_DRV_FORCE_UNBIND &&
 		           rte_eal_process_type() == RTE_PROC_PRIMARY) {
@@ -1049,12 +1042,12 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d
 			if (pci_unbind_kernel_driver(dev) < 0)
 				return -1;
 		}
-#else
+#endif
+
 		if (dr->drv_flags & RTE_PCI_DRV_NEED_IGB_UIO)
-			/* just map resources for Intel NICs */
+			/* map resources for devices that use igb_uio */
 			if (pci_uio_map_resource(dev) < 0)
 				return -1;
-#endif
 
 		/* reference driver structure */
 		dev->driver = dr;
-- 
1.7.10.4

  reply	other threads:[~2014-04-14 12:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-11 11:53 [dpdk-dev] [PATCH] Remove RTE_EAL_UNBIND_PORTS-related code Burakov, Anatoly
2014-04-14 12:51 ` [dpdk-dev] [PATCH 0/3] remove RTE_EAL_UNBIND_PORTS related code David Marchand
2014-04-14 12:51   ` David Marchand [this message]
2014-04-15  8:39     ` [dpdk-dev] [PATCH 1/3] pci: pci_switch_module cleanup Burakov, Anatoly
2014-04-14 12:51   ` [dpdk-dev] [PATCH 2/3] pci: move RTE_PCI_DRV_FORCE_UNBIND handling out of #ifdef David Marchand
2014-04-15  8:40     ` Burakov, Anatoly
2014-04-14 12:51   ` [dpdk-dev] [PATCH 3/3] pci: remove deprecated RTE_EAL_UNBIND_PORTS option David Marchand
2014-04-15  8:41     ` Burakov, Anatoly
2014-04-28 13:18     ` David Marchand
2014-04-14 13:12   ` [dpdk-dev] [PATCH 0/3] remove RTE_EAL_UNBIND_PORTS related code Burakov, Anatoly
2014-04-14 14:19     ` David Marchand
2014-04-14 14:39       ` Burakov, Anatoly
2014-04-15  8:15         ` Thomas Monjalon
2014-04-15  8:33           ` Burakov, Anatoly

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=1397479912-4906-2-git-send-email-david.marchand@6wind.com \
    --to=david.marchand@6wind.com \
    --cc=anatoly.burakov@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).