* [dpdk-dev] [PATCH 0/3] eal: complete attach / detach support
@ 2017-05-24 15:18 Gaetan Rivet
2017-05-24 15:18 ` [dpdk-dev] [PATCH 1/3] pci: implement attach/detach bus operation Gaetan Rivet
` (3 more replies)
0 siblings, 4 replies; 14+ messages in thread
From: Gaetan Rivet @ 2017-05-24 15:18 UTC (permalink / raw)
To: dev
Cc: Gaetan Rivet, Jan Blunck, Stephen Hemminger, Maxime Coquelin,
Jerin Jacob, David Marchand
Implements attach / detach for the PCI bus, and a streamlined attach for
the virtual bus.
This is necessary to remove the final dependencies of the EAL on the virtual
and PCI buses, due to the rte_eal_dev_attach and rte_eal_dev_detach functions.
This patchset depends on:
pci: implement find_device bus operation
http://dpdk.org/ml/archives/dev/2017-May/066340.html
http://dpdk.org/dev/patchwork/patch/24498/
[PATCH 00/14] Generic devargs parsing
http://dpdk.org/ml/archives/dev/2017-May/066351.html
http://dpdk.org/dev/patchwork/patch/24508/
Gaetan Rivet (3):
pci: implement attach/detach bus operation
vdev: implement attach bus operation
vdev: use standard bus registration function
lib/librte_eal/common/eal_common_dev.c | 53 +++++++++++++++++++--------------
lib/librte_eal/common/eal_common_pci.c | 50 +++++++++++++++++++++++++++++++
lib/librte_eal/common/eal_common_vdev.c | 26 +++++-----------
3 files changed, 88 insertions(+), 41 deletions(-)
--
2.1.4
^ permalink raw reply [flat|nested] 14+ messages in thread
* [dpdk-dev] [PATCH 1/3] pci: implement attach/detach bus operation
2017-05-24 15:18 [dpdk-dev] [PATCH 0/3] eal: complete attach / detach support Gaetan Rivet
@ 2017-05-24 15:18 ` Gaetan Rivet
2017-05-24 15:18 ` [dpdk-dev] [PATCH 2/3] vdev: implement attach " Gaetan Rivet
` (2 subsequent siblings)
3 siblings, 0 replies; 14+ messages in thread
From: Gaetan Rivet @ 2017-05-24 15:18 UTC (permalink / raw)
To: dev
Cc: Gaetan Rivet, Jan Blunck, Stephen Hemminger, Maxime Coquelin,
Jerin Jacob, David Marchand
Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
lib/librte_eal/common/eal_common_pci.c | 50 ++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index 6d9fdda..269abb8 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -76,6 +76,7 @@
#include <rte_pci.h>
#include <rte_per_lcore.h>
#include <rte_memory.h>
+#include <rte_memcpy.h>
#include <rte_memzone.h>
#include <rte_eal.h>
#include <rte_string_fns.h>
@@ -546,12 +547,61 @@ pci_find_device(int (*match)(const struct rte_device *dev, const void *data),
return NULL;
}
+static int
+pci_attach(struct rte_device *dev)
+{
+ struct rte_pci_device *pdev;
+ struct rte_pci_addr addr;
+
+ if (dev == NULL)
+ return -EINVAL;
+ if (pci_parse(dev->name, &addr))
+ return -EFAULT;
+ /*
+ * Update eventual pci device in global list.
+ * Insert it if none was found.
+ */
+ if (pci_update_device(&addr) < 0)
+ return -EIO;
+ /* Find the current device holding this address in the bus. */
+ FOREACH_DEVICE_ON_PCIBUS(pdev) {
+ if (rte_eal_compare_pci_addr(&pdev->addr, &addr))
+ continue;
+ /* Update eventual devargs, others device infos. */
+ if (dev != &pdev->device)
+ rte_memcpy(&pdev->device, dev, sizeof(*dev));
+ break;
+ }
+ if (rte_pci_probe_one(&addr))
+ return -ENODEV;
+ /* Get back new device info. */
+ if (dev != &pdev->device)
+ rte_memcpy(dev, &pdev->device, sizeof(*dev));
+ return 0;
+}
+
+static int
+pci_detach(struct rte_device *dev)
+{
+ struct rte_pci_addr addr;
+
+ if (dev == NULL)
+ return -EINVAL;
+ if (pci_parse(dev->name, &addr))
+ return -EFAULT;
+ if (rte_pci_detach(&addr))
+ return -ENODEV;
+ return 0;
+}
+
struct rte_pci_bus rte_pci_bus = {
.bus = {
.scan = rte_pci_scan,
.probe = rte_pci_probe,
.find_device = pci_find_device,
.parse = pci_parse,
+ .attach = pci_attach,
+ .detach = pci_detach,
},
.device_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.device_list),
.driver_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.driver_list),
--
2.1.4
^ permalink raw reply [flat|nested] 14+ messages in thread
* [dpdk-dev] [PATCH 2/3] vdev: implement attach bus operation
2017-05-24 15:18 [dpdk-dev] [PATCH 0/3] eal: complete attach / detach support Gaetan Rivet
2017-05-24 15:18 ` [dpdk-dev] [PATCH 1/3] pci: implement attach/detach bus operation Gaetan Rivet
@ 2017-05-24 15:18 ` Gaetan Rivet
2017-05-24 15:18 ` [dpdk-dev] [PATCH 3/3] vdev: use standard bus registration function Gaetan Rivet
2017-06-01 10:11 ` [dpdk-dev] [PATCH v2 0/3] eal: complete attach / detach support Gaetan Rivet
3 siblings, 0 replies; 14+ messages in thread
From: Gaetan Rivet @ 2017-05-24 15:18 UTC (permalink / raw)
To: dev
Cc: Gaetan Rivet, Jan Blunck, Stephen Hemminger, Maxime Coquelin,
Jerin Jacob, David Marchand
Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
lib/librte_eal/common/eal_common_dev.c | 53 +++++++++++++++++++--------------
lib/librte_eal/common/eal_common_vdev.c | 8 ++++-
2 files changed, 37 insertions(+), 24 deletions(-)
diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c
index 829d7f3..fdd06be 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -61,6 +61,9 @@ static int cmp_detached_dev_name(const struct rte_device *dev,
int rte_eal_dev_attach(const char *name, const char *devargs)
{
struct rte_device *dev;
+ struct rte_device device;
+ struct rte_devargs da;
+ struct rte_bus *bus;
int ret;
if (name == NULL || devargs == NULL) {
@@ -69,31 +72,35 @@ int rte_eal_dev_attach(const char *name, const char *devargs)
}
dev = rte_bus_find_device(NULL, cmp_detached_dev_name, name);
- if (dev) {
- struct rte_bus *bus;
-
+ if (dev)
bus = rte_bus_find_by_device(dev);
- if (!bus) {
- RTE_LOG(ERR, EAL, "Cannot find bus for device (%s)\n",
- name);
- return -EINVAL;
- }
-
- if (!bus->attach) {
- RTE_LOG(ERR, EAL, "Bus function not supported\n");
- return -ENOTSUP;
- }
-
- ret = bus->attach(dev);
- goto out;
+ else
+ bus = rte_bus_from_dev(name);
+ if (!bus) {
+ RTE_LOG(ERR, EAL, "Cannot find bus for device (%s)\n",
+ name);
+ return -EINVAL;
}
-
- /*
- * If we haven't found a bus device the user meant to "hotplug" a
- * virtual device instead.
- */
- ret = rte_vdev_init(name, devargs);
-out:
+ if (!bus->attach) {
+ RTE_LOG(ERR, EAL, "Bus function not supported\n");
+ return -ENOTSUP;
+ }
+ if (!dev) {
+ char da_str[snprintf(NULL, 0, "%s,%s", name, devargs) + 1];
+
+ /*
+ * If we haven't found a bus device the user meant to "hotplug"
+ * a device instead.
+ */
+ dev = &device;
+ snprintf(da_str, sizeof(da_str), "%s,%s", name, devargs);
+ ret = rte_eal_devargs_parse(da_str, &da);
+ if (ret)
+ return ret;
+ dev->name = da.name;
+ dev->devargs = &da;
+ }
+ ret = bus->attach(dev);
if (ret)
RTE_LOG(ERR, EAL, "Driver cannot attach the device (%s)\n",
name);
diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c
index fc5e2d2..4e83326 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c
@@ -356,6 +356,12 @@ vdev_find_device(int (*match)(const struct rte_device *dev, const void *data),
}
static int
+vdev_attach(struct rte_device *dev)
+{
+ return rte_vdev_init(dev->devargs->name, dev->devargs->args);
+}
+
+static int
vdev_detach(struct rte_device *dev)
{
/*
@@ -369,7 +375,7 @@ static struct rte_bus rte_vdev_bus = {
.scan = vdev_scan,
.probe = vdev_probe,
.find_device = vdev_find_device,
- /* .attach = NULL, see comment on vdev_detach */
+ .attach = vdev_attach,
.detach = vdev_detach,
.parse = vdev_parse,
};
--
2.1.4
^ permalink raw reply [flat|nested] 14+ messages in thread
* [dpdk-dev] [PATCH 3/3] vdev: use standard bus registration function
2017-05-24 15:18 [dpdk-dev] [PATCH 0/3] eal: complete attach / detach support Gaetan Rivet
2017-05-24 15:18 ` [dpdk-dev] [PATCH 1/3] pci: implement attach/detach bus operation Gaetan Rivet
2017-05-24 15:18 ` [dpdk-dev] [PATCH 2/3] vdev: implement attach " Gaetan Rivet
@ 2017-05-24 15:18 ` Gaetan Rivet
2017-06-01 10:11 ` [dpdk-dev] [PATCH v2 0/3] eal: complete attach / detach support Gaetan Rivet
3 siblings, 0 replies; 14+ messages in thread
From: Gaetan Rivet @ 2017-05-24 15:18 UTC (permalink / raw)
To: dev
Cc: Gaetan Rivet, Jan Blunck, Stephen Hemminger, Maxime Coquelin,
Jerin Jacob, David Marchand
Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
lib/librte_eal/common/eal_common_vdev.c | 18 +-----------------
1 file changed, 1 insertion(+), 17 deletions(-)
diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c
index 4e83326..55d53c2 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c
@@ -52,14 +52,10 @@ static struct vdev_device_list vdev_device_list =
struct vdev_driver_list vdev_driver_list =
TAILQ_HEAD_INITIALIZER(vdev_driver_list);
-static void rte_vdev_bus_register(void);
-
/* register a driver */
void
rte_vdev_register(struct rte_vdev_driver *driver)
{
- rte_vdev_bus_register();
-
TAILQ_INSERT_TAIL(&vdev_driver_list, driver, next);
}
@@ -380,16 +376,4 @@ static struct rte_bus rte_vdev_bus = {
.parse = vdev_parse,
};
-RTE_INIT(rte_vdev_bus_register);
-
-static void rte_vdev_bus_register(void)
-{
- static int registered;
-
- if (registered)
- return;
-
- registered = 1;
- rte_vdev_bus.name = VIRTUAL_BUS_NAME;
- rte_bus_register(&rte_vdev_bus);
-}
+RTE_REGISTER_BUS(VIRTUAL_BUS_NAME, rte_vdev_bus);
--
2.1.4
^ permalink raw reply [flat|nested] 14+ messages in thread
* [dpdk-dev] [PATCH v2 0/3] eal: complete attach / detach support
2017-05-24 15:18 [dpdk-dev] [PATCH 0/3] eal: complete attach / detach support Gaetan Rivet
` (2 preceding siblings ...)
2017-05-24 15:18 ` [dpdk-dev] [PATCH 3/3] vdev: use standard bus registration function Gaetan Rivet
@ 2017-06-01 10:11 ` Gaetan Rivet
2017-06-01 10:12 ` [dpdk-dev] [PATCH v2 1/3] pci: implement plug/unplug bus operation Gaetan Rivet
` (3 more replies)
3 siblings, 4 replies; 14+ messages in thread
From: Gaetan Rivet @ 2017-06-01 10:11 UTC (permalink / raw)
To: dev
Cc: Gaetan Rivet, Jan Blunck, Stephen Hemminger, Maxime Coquelin,
Jerin Jacob, David Marchand
Implements attach / detach for the PCI bus, and a streamlined attach for
the virtual bus.
This is necessary to remove the final dependencies of the EAL on the virtual
and PCI buses, due to the rte_eal_dev_attach and rte_eal_dev_detach functions.
This patchset depends on:
pci: implement find_device bus operation
http://dpdk.org/ml/archives/dev/2017-May/066340.html
http://dpdk.org/dev/patchwork/patch/24498/
[PATCH 00/14] Generic devargs parsing
http://dpdk.org/ml/archives/dev/2017-May/066351.html
http://dpdk.org/dev/patchwork/patch/24508/
v1 -> v2:
* Rebase the series on the plug / unplug API.
* removed the vdev_plug implementation as it is now done in
the plug/unplug introduction.
Gaetan Rivet (3):
pci: implement plug/unplug bus operation
dev: remove vdev function dependency
vdev: use standard bus registration function
lib/librte_eal/common/eal_common_dev.c | 49 ++++++++++++++++-------------
lib/librte_eal/common/eal_common_pci.c | 56 +++++++++++++++++++++++++++++++++
lib/librte_eal/common/eal_common_vdev.c | 18 +----------
3 files changed, 84 insertions(+), 39 deletions(-)
--
2.1.4
^ permalink raw reply [flat|nested] 14+ messages in thread
* [dpdk-dev] [PATCH v2 1/3] pci: implement plug/unplug bus operation
2017-06-01 10:11 ` [dpdk-dev] [PATCH v2 0/3] eal: complete attach / detach support Gaetan Rivet
@ 2017-06-01 10:12 ` Gaetan Rivet
2017-06-01 10:12 ` [dpdk-dev] [PATCH v2 2/3] dev: remove vdev function dependency Gaetan Rivet
` (2 subsequent siblings)
3 siblings, 0 replies; 14+ messages in thread
From: Gaetan Rivet @ 2017-06-01 10:12 UTC (permalink / raw)
To: dev; +Cc: Gaetan Rivet
Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
lib/librte_eal/common/eal_common_pci.c | 56 ++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index 2a52b9e..580ce86 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -76,6 +76,7 @@
#include <rte_pci.h>
#include <rte_per_lcore.h>
#include <rte_memory.h>
+#include <rte_memcpy.h>
#include <rte_memzone.h>
#include <rte_eal.h>
#include <rte_string_fns.h>
@@ -545,12 +546,67 @@ pci_find_device(rte_dev_match_t match, const void *data)
return NULL;
}
+static int
+pci_plug(struct rte_devargs *da)
+{
+ struct rte_pci_device *pdev;
+ struct rte_pci_addr addr;
+
+ if (da == NULL)
+ return -EINVAL;
+ if (pci_parse(da->name, &addr))
+ return -EFAULT;
+ /*
+ * Update eventual pci device in global list.
+ * Insert it if none was found.
+ */
+ if (pci_update_device(&addr) < 0)
+ return -EIO;
+ /* Find the current device holding this address in the bus. */
+ FOREACH_DEVICE_ON_PCIBUS(pdev) {
+ if (rte_eal_compare_pci_addr(&pdev->addr, &addr))
+ continue;
+ /* Update eventual devargs. */
+ if (pdev->device.devargs &&
+ da != pdev->device.devargs) {
+ /* TODO: cleanup free */
+ free(pdev->device.devargs->args);
+ rte_memcpy(pdev->device.devargs, da, sizeof(*da));
+ }
+ break;
+ }
+ if (rte_pci_probe_one(&addr))
+ return -ENODEV;
+ /* Get back new device name. */
+ if (pdev->device.devargs &&
+ da != pdev->device.devargs)
+ snprintf(da->name, sizeof(da->name), "%s",
+ pdev->device.devargs->name);
+ return 0;
+}
+
+static int
+pci_unplug(struct rte_devargs *da)
+{
+ struct rte_pci_addr addr;
+
+ if (da == NULL)
+ return -EINVAL;
+ if (pci_parse(da->name, &addr))
+ return -EFAULT;
+ if (rte_pci_detach(&addr))
+ return -ENODEV;
+ return 0;
+}
+
struct rte_pci_bus rte_pci_bus = {
.bus = {
.scan = rte_pci_scan,
.probe = rte_pci_probe,
.find_device = pci_find_device,
.parse = pci_parse,
+ .plug = pci_plug,
+ .unplug = pci_unplug,
},
.device_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.device_list),
.driver_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.driver_list),
--
2.1.4
^ permalink raw reply [flat|nested] 14+ messages in thread
* [dpdk-dev] [PATCH v2 2/3] dev: remove vdev function dependency
2017-06-01 10:11 ` [dpdk-dev] [PATCH v2 0/3] eal: complete attach / detach support Gaetan Rivet
2017-06-01 10:12 ` [dpdk-dev] [PATCH v2 1/3] pci: implement plug/unplug bus operation Gaetan Rivet
@ 2017-06-01 10:12 ` Gaetan Rivet
2017-06-01 10:12 ` [dpdk-dev] [PATCH v2 3/3] vdev: use standard bus registration function Gaetan Rivet
2017-06-07 23:58 ` [dpdk-dev] [PATCH v3 0/3] eal: complete attach / detach support Gaetan Rivet
3 siblings, 0 replies; 14+ messages in thread
From: Gaetan Rivet @ 2017-06-01 10:12 UTC (permalink / raw)
To: dev; +Cc: Gaetan Rivet
Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
lib/librte_eal/common/eal_common_dev.c | 49 +++++++++++++++++++---------------
1 file changed, 27 insertions(+), 22 deletions(-)
diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c
index 968c66e..c286628 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -61,6 +61,7 @@ static int cmp_detached_dev_name(const struct rte_device *dev,
int rte_eal_dev_attach(const char *name, const char *devargs)
{
struct rte_device *dev;
+ struct rte_bus *bus;
int ret;
if (name == NULL || devargs == NULL) {
@@ -69,31 +70,35 @@ int rte_eal_dev_attach(const char *name, const char *devargs)
}
dev = rte_bus_find_device(NULL, cmp_detached_dev_name, name);
- if (dev) {
- struct rte_bus *bus;
-
+ if (dev)
bus = rte_bus_find_by_device(dev);
- if (!bus) {
- RTE_LOG(ERR, EAL, "Cannot find bus for device (%s)\n",
- name);
- return -EINVAL;
- }
-
- if (!bus->plug) {
- RTE_LOG(ERR, EAL, "Bus function not supported\n");
- return -ENOTSUP;
- }
-
+ else
+ bus = rte_bus_from_dev(name);
+ if (!bus) {
+ RTE_LOG(ERR, EAL, "Cannot find bus for device (%s)\n",
+ name);
+ return -EINVAL;
+ }
+ if (!bus->plug) {
+ RTE_LOG(ERR, EAL, "Device hotplug not supported on this bus\n");
+ return -ENOTSUP;
+ }
+ if (!dev) {
+ struct rte_devargs da;
+ char da_str[snprintf(NULL, 0, "%s,%s", name, devargs) + 1];
+
+ /*
+ * If we haven't found a bus device the user meant to hotplug
+ * a device instead.
+ */
+ snprintf(da_str, sizeof(da_str), "%s,%s", name, devargs);
+ ret = rte_eal_devargs_parse(da_str, &da);
+ if (ret)
+ return ret;
+ ret = bus->plug(&da);
+ } else {
ret = bus->plug(dev->devargs);
- goto out;
}
-
- /*
- * If we haven't found a bus device the user meant to "hotplug" a
- * virtual device instead.
- */
- ret = rte_vdev_init(name, devargs);
-out:
if (ret)
RTE_LOG(ERR, EAL, "Driver cannot attach the device (%s)\n",
name);
--
2.1.4
^ permalink raw reply [flat|nested] 14+ messages in thread
* [dpdk-dev] [PATCH v2 3/3] vdev: use standard bus registration function
2017-06-01 10:11 ` [dpdk-dev] [PATCH v2 0/3] eal: complete attach / detach support Gaetan Rivet
2017-06-01 10:12 ` [dpdk-dev] [PATCH v2 1/3] pci: implement plug/unplug bus operation Gaetan Rivet
2017-06-01 10:12 ` [dpdk-dev] [PATCH v2 2/3] dev: remove vdev function dependency Gaetan Rivet
@ 2017-06-01 10:12 ` Gaetan Rivet
2017-06-07 23:58 ` [dpdk-dev] [PATCH v3 0/3] eal: complete attach / detach support Gaetan Rivet
3 siblings, 0 replies; 14+ messages in thread
From: Gaetan Rivet @ 2017-06-01 10:12 UTC (permalink / raw)
To: dev; +Cc: Gaetan Rivet
Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
lib/librte_eal/common/eal_common_vdev.c | 18 +-----------------
1 file changed, 1 insertion(+), 17 deletions(-)
diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c
index 082bbae..9ef064f 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c
@@ -52,14 +52,10 @@ static struct vdev_device_list vdev_device_list =
struct vdev_driver_list vdev_driver_list =
TAILQ_HEAD_INITIALIZER(vdev_driver_list);
-static void rte_vdev_bus_register(void);
-
/* register a driver */
void
rte_vdev_register(struct rte_vdev_driver *driver)
{
- rte_vdev_bus_register();
-
TAILQ_INSERT_TAIL(&vdev_driver_list, driver, next);
}
@@ -374,16 +370,4 @@ static struct rte_bus rte_vdev_bus = {
.parse = vdev_parse,
};
-RTE_INIT(rte_vdev_bus_register);
-
-static void rte_vdev_bus_register(void)
-{
- static int registered;
-
- if (registered)
- return;
-
- registered = 1;
- rte_vdev_bus.name = VIRTUAL_BUS_NAME;
- rte_bus_register(&rte_vdev_bus);
-}
+RTE_REGISTER_BUS(VIRTUAL_BUS_NAME, rte_vdev_bus);
--
2.1.4
^ permalink raw reply [flat|nested] 14+ messages in thread
* [dpdk-dev] [PATCH v3 0/3] eal: complete attach / detach support
2017-06-01 10:11 ` [dpdk-dev] [PATCH v2 0/3] eal: complete attach / detach support Gaetan Rivet
` (2 preceding siblings ...)
2017-06-01 10:12 ` [dpdk-dev] [PATCH v2 3/3] vdev: use standard bus registration function Gaetan Rivet
@ 2017-06-07 23:58 ` Gaetan Rivet
2017-06-07 23:58 ` [dpdk-dev] [PATCH v3 1/3] pci: implement hotplug bus operation Gaetan Rivet
` (2 more replies)
3 siblings, 3 replies; 14+ messages in thread
From: Gaetan Rivet @ 2017-06-07 23:58 UTC (permalink / raw)
To: dev
Cc: Gaetan Rivet, Jan Blunck, Stephen Hemminger, Maxime Coquelin,
Jerin Jacob, David Marchand
Implements attach / detach for the PCI bus, and a streamlined attach for
the virtual bus.
This is necessary to remove the final dependencies of the EAL on the virtual
and PCI buses, due to the rte_eal_dev_attach and rte_eal_dev_detach functions.
This patchset depends on:
pci: implement find_device bus operation
http://dpdk.org/ml/archives/dev/2017-May/066340.html
http://dpdk.org/dev/patchwork/patch/24498/
[PATCH 00/14] Generic devargs parsing
http://dpdk.org/ml/archives/dev/2017-May/066351.html
http://dpdk.org/dev/patchwork/patch/24508/
v1 -> v2:
* Rebase the series on the plug / unplug API.
* removed the vdev_plug implementation as it is now done in
the plug/unplug introduction.
v2 -> v3:
* Fix a few bugs in rte_dev_attach / detach.
* Follow new plug / unplug API.
Gaetan Rivet (3):
pci: implement hotplug bus operation
dev: remove vdev function dependency
vdev: use standard bus registration function
lib/librte_eal/common/eal_common_dev.c | 50 ++++++++++++++----------
lib/librte_eal/common/eal_common_pci.c | 67 +++++++++++++++++++++++++++++++++
lib/librte_eal/common/eal_common_vdev.c | 18 +--------
3 files changed, 98 insertions(+), 37 deletions(-)
--
2.1.4
^ permalink raw reply [flat|nested] 14+ messages in thread
* [dpdk-dev] [PATCH v3 1/3] pci: implement hotplug bus operation
2017-06-07 23:58 ` [dpdk-dev] [PATCH v3 0/3] eal: complete attach / detach support Gaetan Rivet
@ 2017-06-07 23:58 ` Gaetan Rivet
2017-06-07 23:58 ` [dpdk-dev] [PATCH v3 2/3] dev: remove vdev function dependency Gaetan Rivet
2017-06-07 23:58 ` [dpdk-dev] [PATCH v3 3/3] vdev: use standard bus registration function Gaetan Rivet
2 siblings, 0 replies; 14+ messages in thread
From: Gaetan Rivet @ 2017-06-07 23:58 UTC (permalink / raw)
To: dev; +Cc: Gaetan Rivet
Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
lib/librte_eal/common/eal_common_pci.c | 67 ++++++++++++++++++++++++++++++++++
1 file changed, 67 insertions(+)
diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c
index b4f8056..6049b49 100644
--- a/lib/librte_eal/common/eal_common_pci.c
+++ b/lib/librte_eal/common/eal_common_pci.c
@@ -47,6 +47,7 @@
#include <rte_pci.h>
#include <rte_per_lcore.h>
#include <rte_memory.h>
+#include <rte_memcpy.h>
#include <rte_memzone.h>
#include <rte_eal.h>
#include <rte_string_fns.h>
@@ -517,12 +518,78 @@ pci_find_device(rte_dev_cmp_t cmp, const void *data)
return NULL;
}
+static struct rte_device *
+pci_plug(struct rte_devargs *da)
+{
+ struct rte_pci_device *pdev;
+ struct rte_pci_addr addr;
+
+ if (pci_parse(da->name, &addr)) {
+ rte_errno = EFAULT;
+ return NULL;
+ }
+ /*
+ * Update eventual pci device in global list.
+ * Insert it if none was found.
+ */
+ if (pci_update_device(&addr) < 0) {
+ rte_errno = EIO;
+ return NULL;
+ }
+ /* Find the current device holding this address in the bus. */
+ FOREACH_DEVICE_ON_PCIBUS(pdev) {
+ if (rte_eal_compare_pci_addr(&pdev->addr, &addr))
+ continue;
+ /* Update eventual devargs. */
+ pdev->device.devargs = rte_eal_devargs_clone(da);
+ if (pdev->device.devargs == NULL) {
+ rte_errno = ENOMEM;
+ return NULL;
+ }
+ break;
+ }
+ if (rte_pci_probe_one(&addr)) {
+ rte_errno = ENODEV;
+ return NULL;
+ }
+ /* Get back new device name. */
+ if (pdev->device.devargs &&
+ da != pdev->device.devargs)
+ snprintf(da->name, sizeof(da->name), "%s",
+ pdev->device.devargs->name);
+ return &pdev->device;
+}
+
+static int
+pci_unplug(struct rte_device *dev)
+{
+ struct rte_pci_addr addr;
+
+ if (dev == NULL) {
+ rte_errno = EINVAL;
+ return -1;
+ }
+ if (pci_parse(dev->name, &addr)) {
+ rte_errno = EFAULT;
+ return -1;
+ }
+ if (rte_pci_detach(&addr)) {
+ rte_errno = ENODEV;
+ return -1;
+ }
+ if (dev->devargs)
+ rte_eal_devargs_rmv(dev->devargs);
+ return 0;
+}
+
struct rte_pci_bus rte_pci_bus = {
.bus = {
.scan = rte_pci_scan,
.probe = rte_pci_probe,
.find_device = pci_find_device,
.parse = pci_parse,
+ .plug = pci_plug,
+ .unplug = pci_unplug,
},
.device_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.device_list),
.driver_list = TAILQ_HEAD_INITIALIZER(rte_pci_bus.driver_list),
--
2.1.4
^ permalink raw reply [flat|nested] 14+ messages in thread
* [dpdk-dev] [PATCH v3 2/3] dev: remove vdev function dependency
2017-06-07 23:58 ` [dpdk-dev] [PATCH v3 0/3] eal: complete attach / detach support Gaetan Rivet
2017-06-07 23:58 ` [dpdk-dev] [PATCH v3 1/3] pci: implement hotplug bus operation Gaetan Rivet
@ 2017-06-07 23:58 ` Gaetan Rivet
2017-06-21 14:42 ` Thomas Monjalon
2017-06-07 23:58 ` [dpdk-dev] [PATCH v3 3/3] vdev: use standard bus registration function Gaetan Rivet
2 siblings, 1 reply; 14+ messages in thread
From: Gaetan Rivet @ 2017-06-07 23:58 UTC (permalink / raw)
To: dev; +Cc: Gaetan Rivet
Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
lib/librte_eal/common/eal_common_dev.c | 50 ++++++++++++++++++++--------------
1 file changed, 30 insertions(+), 20 deletions(-)
diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c
index 8ef9b98..247c9c1 100644
--- a/lib/librte_eal/common/eal_common_dev.c
+++ b/lib/librte_eal/common/eal_common_dev.c
@@ -43,6 +43,7 @@
#include <rte_debug.h>
#include <rte_devargs.h>
#include <rte_log.h>
+#include <rte_errno.h>
#include "eal_private.h"
@@ -61,6 +62,8 @@ static int cmp_detached_dev_name(const struct rte_device *dev,
int rte_eal_dev_attach(const char *name, const char *devargs)
{
struct rte_device *dev;
+ struct rte_bus *bus;
+ struct rte_devargs da;
int ret;
if (name == NULL || devargs == NULL) {
@@ -70,30 +73,37 @@ int rte_eal_dev_attach(const char *name, const char *devargs)
dev = rte_bus_find_device(NULL, cmp_detached_dev_name, name);
if (dev) {
- struct rte_bus *bus;
-
bus = rte_bus_find_by_device(dev);
- if (!bus) {
- RTE_LOG(ERR, EAL, "Cannot find bus for device (%s)\n",
+ } else {
+ char da_str[snprintf(NULL, 0, "%s,%s", name, devargs) + 1];
+
+ /*
+ * If we haven't found a bus device the user meant to hotplug
+ * a device instead.
+ */
+ snprintf(da_str, sizeof(da_str), "%s,%s", name, devargs);
+ ret = rte_eal_devargs_parse(da_str, &da);
+ if (ret) {
+ RTE_LOG(ERR, EAL, "Could not parse device (%s)\n",
name);
- return -EINVAL;
- }
-
- if (!bus->plug) {
- RTE_LOG(ERR, EAL, "Bus function not supported\n");
- return -ENOTSUP;
+ return ret;
}
-
- ret = (bus->plug(dev->devargs) == NULL);
- goto out;
+ bus = da.bus;
}
-
- /*
- * If we haven't found a bus device the user meant to "hotplug" a
- * virtual device instead.
- */
- ret = rte_vdev_init(name, devargs);
-out:
+ if (bus == NULL) {
+ RTE_LOG(ERR, EAL, "Cannot find bus for device (%s)\n",
+ name);
+ return -EINVAL;
+ }
+ if (bus->plug == NULL) {
+ RTE_LOG(ERR, EAL, "Device hotplug not supported on this bus\n");
+ return -ENOTSUP;
+ }
+ if (dev == NULL)
+ dev = bus->plug(&da);
+ else
+ dev = bus->plug(dev->devargs);
+ ret = dev ? 0 : -rte_errno;
if (ret)
RTE_LOG(ERR, EAL, "Driver cannot attach the device (%s)\n",
name);
--
2.1.4
^ permalink raw reply [flat|nested] 14+ messages in thread
* [dpdk-dev] [PATCH v3 3/3] vdev: use standard bus registration function
2017-06-07 23:58 ` [dpdk-dev] [PATCH v3 0/3] eal: complete attach / detach support Gaetan Rivet
2017-06-07 23:58 ` [dpdk-dev] [PATCH v3 1/3] pci: implement hotplug bus operation Gaetan Rivet
2017-06-07 23:58 ` [dpdk-dev] [PATCH v3 2/3] dev: remove vdev function dependency Gaetan Rivet
@ 2017-06-07 23:58 ` Gaetan Rivet
2017-06-21 14:41 ` Thomas Monjalon
2 siblings, 1 reply; 14+ messages in thread
From: Gaetan Rivet @ 2017-06-07 23:58 UTC (permalink / raw)
To: dev; +Cc: Gaetan Rivet
Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
lib/librte_eal/common/eal_common_vdev.c | 18 +-----------------
1 file changed, 1 insertion(+), 17 deletions(-)
diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c
index d921345..d007e7e 100644
--- a/lib/librte_eal/common/eal_common_vdev.c
+++ b/lib/librte_eal/common/eal_common_vdev.c
@@ -54,14 +54,10 @@ static struct vdev_device_list vdev_device_list =
struct vdev_driver_list vdev_driver_list =
TAILQ_HEAD_INITIALIZER(vdev_driver_list);
-static void rte_vdev_bus_register(void);
-
/* register a driver */
void
rte_vdev_register(struct rte_vdev_driver *driver)
{
- rte_vdev_bus_register();
-
TAILQ_INSERT_TAIL(&vdev_driver_list, driver, next);
}
@@ -394,16 +390,4 @@ static struct rte_bus rte_vdev_bus = {
.parse = vdev_parse,
};
-RTE_INIT(rte_vdev_bus_register);
-
-static void rte_vdev_bus_register(void)
-{
- static int registered;
-
- if (registered)
- return;
-
- registered = 1;
- rte_vdev_bus.name = VIRTUAL_BUS_NAME;
- rte_bus_register(&rte_vdev_bus);
-}
+RTE_REGISTER_BUS(VIRTUAL_BUS_NAME, rte_vdev_bus);
--
2.1.4
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [dpdk-dev] [PATCH v3 3/3] vdev: use standard bus registration function
2017-06-07 23:58 ` [dpdk-dev] [PATCH v3 3/3] vdev: use standard bus registration function Gaetan Rivet
@ 2017-06-21 14:41 ` Thomas Monjalon
0 siblings, 0 replies; 14+ messages in thread
From: Thomas Monjalon @ 2017-06-21 14:41 UTC (permalink / raw)
To: Gaetan Rivet; +Cc: dev
08/06/2017 01:58, Gaetan Rivet:
> +RTE_REGISTER_BUS(VIRTUAL_BUS_NAME, rte_vdev_bus);
nice :)
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [dpdk-dev] [PATCH v3 2/3] dev: remove vdev function dependency
2017-06-07 23:58 ` [dpdk-dev] [PATCH v3 2/3] dev: remove vdev function dependency Gaetan Rivet
@ 2017-06-21 14:42 ` Thomas Monjalon
0 siblings, 0 replies; 14+ messages in thread
From: Thomas Monjalon @ 2017-06-21 14:42 UTC (permalink / raw)
To: Gaetan Rivet; +Cc: dev
08/06/2017 01:58, Gaetan Rivet:
> Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
> ---
> lib/librte_eal/common/eal_common_dev.c | 50 ++++++++++++++++++++--------------
> 1 file changed, 30 insertions(+), 20 deletions(-)
It's difficult to understand this patch.
Please add some explanations.
And it may be better to insert or merge it in the first
attach/detach series.
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2017-06-21 14:43 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-24 15:18 [dpdk-dev] [PATCH 0/3] eal: complete attach / detach support Gaetan Rivet
2017-05-24 15:18 ` [dpdk-dev] [PATCH 1/3] pci: implement attach/detach bus operation Gaetan Rivet
2017-05-24 15:18 ` [dpdk-dev] [PATCH 2/3] vdev: implement attach " Gaetan Rivet
2017-05-24 15:18 ` [dpdk-dev] [PATCH 3/3] vdev: use standard bus registration function Gaetan Rivet
2017-06-01 10:11 ` [dpdk-dev] [PATCH v2 0/3] eal: complete attach / detach support Gaetan Rivet
2017-06-01 10:12 ` [dpdk-dev] [PATCH v2 1/3] pci: implement plug/unplug bus operation Gaetan Rivet
2017-06-01 10:12 ` [dpdk-dev] [PATCH v2 2/3] dev: remove vdev function dependency Gaetan Rivet
2017-06-01 10:12 ` [dpdk-dev] [PATCH v2 3/3] vdev: use standard bus registration function Gaetan Rivet
2017-06-07 23:58 ` [dpdk-dev] [PATCH v3 0/3] eal: complete attach / detach support Gaetan Rivet
2017-06-07 23:58 ` [dpdk-dev] [PATCH v3 1/3] pci: implement hotplug bus operation Gaetan Rivet
2017-06-07 23:58 ` [dpdk-dev] [PATCH v3 2/3] dev: remove vdev function dependency Gaetan Rivet
2017-06-21 14:42 ` Thomas Monjalon
2017-06-07 23:58 ` [dpdk-dev] [PATCH v3 3/3] vdev: use standard bus registration function Gaetan Rivet
2017-06-21 14:41 ` Thomas Monjalon
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).