All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gaetan Rivet <gaetan.rivet@6wind.com>
To: dev@dpdk.org
Cc: Gaetan Rivet <gaetan.rivet@6wind.com>, stable@dpdk.org
Subject: [PATCH v4 5/8] pci: use given name as generic name
Date: Sat, 15 Jul 2017 19:56:39 +0200	[thread overview]
Message-ID: <494ae1ab96182c559497ca76137249e2c7892644.1499964391.git.gaetan.rivet@6wind.com> (raw)
In-Reply-To: <cover.1499964391.git.gaetan.rivet@6wind.com>
In-Reply-To: <cover.1499964391.git.gaetan.rivet@6wind.com>

When an application requests the use of a PCI device, it can currently
interchangeably use either the longform DomBDF format (0000:00:00.0) or
the shorter BDF format (00:00.0).

When a device is inserted via the hotplug API, it must first be scanned
and then will be identified by its name using `find_device`. The name of
the device must match the name given by the user to be found and then
probed.

A new function sets the expected name for a scanned PCI device. It was
previously generated from parsing the PCI address. This canonical name
is superseded when an rte_devargs exists describing the device. In such
case, the device takes the given name found within the rte_devargs.

As the rte_devargs is linked to the rte_pci_device during scanning, it
can be avoided during the probe. Additionally, this fixes the issue of
the rte_devargs lookup not being done within rte_pci_probe_one.

Fixes: beec692c5157 ("eal: add name field to generic device")
Cc: stable@dpdk.org

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 lib/librte_eal/bsdapp/eal/eal_pci.c    |  4 ++--
 lib/librte_eal/common/eal_common_pci.c | 29 ++++++++++++++++++++++++-----
 lib/librte_eal/common/eal_private.h    |  5 +++++
 lib/librte_eal/linuxapp/eal/eal_pci.c  |  4 ++--
 4 files changed, 33 insertions(+), 9 deletions(-)

diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c
index e321461..97a88ec 100644
--- a/lib/librte_eal/bsdapp/eal/eal_pci.c
+++ b/lib/librte_eal/bsdapp/eal/eal_pci.c
@@ -282,8 +282,7 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)
 	/* FreeBSD has no NUMA support (yet) */
 	dev->device.numa_node = 0;
 
-	rte_pci_device_name(&dev->addr, dev->name, sizeof(dev->name));
-	dev->device.name = dev->name;
+	pci_name_set(dev);
 
 	/* FreeBSD has only one pass through driver */
 	dev->kdrv = RTE_KDRV_NIC_UIO;
@@ -334,6 +333,7 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf)
 			} else { /* already registered */
 				dev2->kdrv = dev->kdrv;
 				dev2->max_vfs = dev->max_vfs;
+				pci_name_set(dev2);
 				memmove(dev2->mem_resource,
 					dev->mem_resource,
 					sizeof(dev->mem_resource));
diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index 76bbcc8..45e697e 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -88,6 +88,29 @@ static struct rte_devargs *pci_devargs_lookup(struct rte_pci_device *dev)
 	return NULL;
 }
 
+void
+pci_name_set(struct rte_pci_device *dev)
+{
+	struct rte_devargs *devargs;
+
+	/* Each device has its internal, canonical name set. */
+	rte_pci_device_name(&dev->addr,
+			dev->name, sizeof(dev->name));
+	devargs = pci_devargs_lookup(dev);
+	dev->device.devargs = devargs;
+	/* In blacklist mode, if the device is not blacklisted, no
+	 * rte_devargs exists for it.
+	 */
+	if (devargs != NULL)
+		/* If an rte_devargs exists, the generic rte_device uses the
+		 * given name as its namea
+		 */
+		dev->device.name = dev->device.devargs->name;
+	else
+		/* Otherwise, it uses the internal, canonical form. */
+		dev->device.name = dev->name;
+}
+
 /* map a particular resource from a file */
 void *
 pci_map_resource(void *requested_addr, int fd, off_t offset, size_t size,
@@ -396,11 +419,7 @@ rte_pci_probe(void)
 	FOREACH_DEVICE_ON_PCIBUS(dev) {
 		probed++;
 
-		/* set devargs in PCI structure */
-		devargs = pci_devargs_lookup(dev);
-		if (devargs != NULL)
-			dev->device.devargs = devargs;
-
+		devargs = dev->device.devargs;
 		/* probe all or only whitelisted devices */
 		if (probe_all)
 			ret = pci_probe_all_drivers(dev);
diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h
index 0836339..597d82e 100644
--- a/lib/librte_eal/common/eal_private.h
+++ b/lib/librte_eal/common/eal_private.h
@@ -113,6 +113,11 @@ struct rte_pci_driver;
 struct rte_pci_device;
 
 /**
+ * Find the name of a PCI device.
+ */
+void pci_name_set(struct rte_pci_device *dev);
+
+/**
  * Add a PCI device to the PCI Bus (append to PCI Device list). This function
  * also updates the bus references of the PCI Device (and the generic device
  * object embedded within.
diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c
index 7d9e1a9..556ae2c 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
@@ -324,8 +324,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)
 		dev->device.numa_node = 0;
 	}
 
-	rte_pci_device_name(addr, dev->name, sizeof(dev->name));
-	dev->device.name = dev->name;
+	pci_name_set(dev);
 
 	/* parse resources */
 	snprintf(filename, sizeof(filename), "%s/resource", dirname);
@@ -373,6 +372,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)
 			} else { /* already registered */
 				dev2->kdrv = dev->kdrv;
 				dev2->max_vfs = dev->max_vfs;
+				pci_name_set(dev2);
 				memmove(dev2->mem_resource, dev->mem_resource,
 					sizeof(dev->mem_resource));
 				free(dev);
-- 
2.1.4

  parent reply	other threads:[~2017-07-15 17:57 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-09  1:45 [PATCH 0/9] fix hotplug API Gaetan Rivet
2017-07-09  1:45 ` [PATCH 1/9] eal: return device handle upon plugin Gaetan Rivet
2017-07-09  1:45 ` [PATCH 2/9] eal: fix hotplug add Gaetan Rivet
2017-07-09  1:45 ` [PATCH 3/9] devargs: introduce removal function Gaetan Rivet
2017-07-09  1:45 ` [PATCH 4/9] eal: release devargs on device removal Gaetan Rivet
2017-07-09  1:45 ` [PATCH 5/9] pci: use given name as generic name Gaetan Rivet
2017-07-09  1:45 ` [PATCH 6/9] pci: fix generic driver pointer on probe error Gaetan Rivet
2017-07-09  1:45 ` [PATCH 7/9] pci: fix hotplug operations Gaetan Rivet
2017-07-09  1:45 ` [PATCH 8/9] vdev: implement plug operation Gaetan Rivet
2017-07-09  1:45 ` [PATCH 9/9] bus: remove useless plug parameter Gaetan Rivet
2017-07-09 10:38 ` [PATCH 0/9] fix hotplug API Jan Blunck
2017-07-09 12:19   ` Gaëtan Rivet
2017-07-09 14:19   ` Thomas Monjalon
     [not found]     ` <20170711160211.GW11154@bidouze.vm.6wind.com>
     [not found]       ` <CALe+Z00Rc_6cn_ckWrK1cD2RsdWENM3s+ytOpxNymTmaqh8e0g@mail.gmail.com>
2017-07-11 19:21         ` Gaëtan Rivet
2017-07-10 23:18 ` [PATCH v2 0/8] " Gaetan Rivet
2017-07-10 23:19   ` [PATCH v2 1/8] vdev: implement plug operation Gaetan Rivet
2017-07-10 23:19   ` [PATCH v2 2/8] devargs: introduce removal function Gaetan Rivet
2017-07-10 23:19   ` [PATCH v2 3/8] devargs: introduce insert function Gaetan Rivet
2017-07-11 22:13     ` Thomas Monjalon
2017-07-10 23:19   ` [PATCH v2 4/8] eal: fix hotplug add / remove Gaetan Rivet
2017-07-11 22:18     ` Thomas Monjalon
2017-07-10 23:19   ` [PATCH v2 5/8] pci: use given name as generic name Gaetan Rivet
2017-07-11 22:05     ` [dpdk-stable] " Thomas Monjalon
2017-07-10 23:19   ` [PATCH v2 6/8] pci: fix generic driver pointer on probe error Gaetan Rivet
2017-07-10 23:19   ` [PATCH v2 7/8] pci: fix hotplug operations Gaetan Rivet
2017-07-10 23:19   ` [PATCH v2 8/8] bus: remove useless plug parameter Gaetan Rivet
2017-07-11 23:25   ` [PATCH v3 0/8] fix hotplug API Gaetan Rivet
2017-07-11 23:25     ` [PATCH v3 1/8] vdev: implement plug operation Gaetan Rivet
2017-07-11 23:25     ` [PATCH v3 2/8] devargs: introduce removal function Gaetan Rivet
2017-07-12  8:27       ` Jan Blunck
2017-07-12 17:22         ` Gaëtan Rivet
2017-07-11 23:25     ` [PATCH v3 3/8] devargs: introduce insert function Gaetan Rivet
2017-07-12  8:20       ` Jan Blunck
2017-07-12 17:20         ` Gaëtan Rivet
2017-07-13 19:44           ` Jan Blunck
2017-07-11 23:25     ` [PATCH v3 4/8] eal: fix hotplug add / remove Gaetan Rivet
2017-07-12  8:44       ` Jan Blunck
2017-07-12 17:33         ` Gaëtan Rivet
2017-07-11 23:25     ` [PATCH v3 5/8] pci: use given name as generic name Gaetan Rivet
2017-07-11 23:25     ` [PATCH v3 6/8] pci: fix generic driver pointer on probe error Gaetan Rivet
2017-07-11 23:25     ` [PATCH v3 7/8] pci: fix hotplug operations Gaetan Rivet
2017-07-11 23:25     ` [PATCH v3 8/8] bus: remove useless plug parameter Gaetan Rivet
2017-07-15 17:56     ` [PATCH v4 0/8] fix hotplug API Gaetan Rivet
2017-07-15 17:56       ` [PATCH v4 1/8] vdev: implement plug operation Gaetan Rivet
2017-07-15 17:56       ` [PATCH v4 2/8] devargs: introduce removal function Gaetan Rivet
2017-07-15 17:56       ` [PATCH v4 3/8] devargs: introduce insert function Gaetan Rivet
2017-07-15 17:56       ` [PATCH v4 4/8] eal: fix hotplug add / remove Gaetan Rivet
2017-07-15 17:56       ` Gaetan Rivet [this message]
2017-07-15 17:56       ` [PATCH v4 6/8] pci: fix generic driver pointer on probe error Gaetan Rivet
2017-07-15 17:56       ` [PATCH v4 7/8] pci: fix hotplug operations Gaetan Rivet
2017-07-15 17:56       ` [PATCH v4 8/8] bus: remove useless plug parameter Gaetan Rivet
2017-07-19 21:27       ` [PATCH v4 0/8] fix hotplug API 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=494ae1ab96182c559497ca76137249e2c7892644.1499964391.git.gaetan.rivet@6wind.com \
    --to=gaetan.rivet@6wind.com \
    --cc=dev@dpdk.org \
    --cc=stable@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.