diff options
Diffstat (limited to 'drivers/bus/ifpga')
-rw-r--r-- | drivers/bus/ifpga/Makefile | 2 | ||||
-rw-r--r-- | drivers/bus/ifpga/ifpga_bus.c | 33 | ||||
-rw-r--r-- | drivers/bus/ifpga/meson.build | 2 | ||||
-rw-r--r-- | drivers/bus/ifpga/rte_bus_ifpga.h | 3 |
4 files changed, 18 insertions, 22 deletions
diff --git a/drivers/bus/ifpga/Makefile b/drivers/bus/ifpga/Makefile index 3ff3bdb8..514452b3 100644 --- a/drivers/bus/ifpga/Makefile +++ b/drivers/bus/ifpga/Makefile @@ -19,7 +19,7 @@ LDLIBS += -lrte_kvargs EXPORT_MAP := rte_bus_ifpga_version.map # library version -LIBABIVER := 1 +LIBABIVER := 2 SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga_bus.c SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga_common.c diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c index b324872e..5f23ed8b 100644 --- a/drivers/bus/ifpga/ifpga_bus.c +++ b/drivers/bus/ifpga/ifpga_bus.c @@ -142,6 +142,7 @@ ifpga_scan_one(struct rte_rawdev *rawdev, if (!afu_dev) goto end; + afu_dev->device.bus = &rte_ifpga_bus; afu_dev->device.devargs = devargs; afu_dev->device.numa_node = SOCKET_ID_ANY; afu_dev->device.name = devargs->name; @@ -279,14 +280,13 @@ ifpga_probe_one_driver(struct rte_afu_driver *drv, /* reference driver structure */ afu_dev->driver = drv; - afu_dev->device.driver = &drv->driver; /* call the driver probe() function */ ret = drv->probe(afu_dev); - if (ret) { + if (ret) afu_dev->driver = NULL; - afu_dev->device.driver = NULL; - } + else + afu_dev->device.driver = &drv->driver; return ret; } @@ -301,8 +301,11 @@ ifpga_probe_all_drivers(struct rte_afu_device *afu_dev) return -1; /* Check if a driver is already loaded */ - if (afu_dev->driver != NULL) - return 0; + if (rte_dev_is_probed(&afu_dev->device)) { + IFPGA_BUS_DEBUG("Device %s is already probed\n", + rte_ifpga_device_name(afu_dev)); + return -EEXIST; + } TAILQ_FOREACH(drv, &ifpga_afu_drv_list, next) { if (ifpga_probe_one_driver(drv, afu_dev)) { @@ -325,14 +328,13 @@ ifpga_probe(void) int ret = 0; TAILQ_FOREACH(afu_dev, &ifpga_afu_dev_list, next) { - if (afu_dev->device.driver) - continue; - ret = ifpga_probe_all_drivers(afu_dev); + if (ret == -EEXIST) + continue; if (ret < 0) IFPGA_BUS_ERR("failed to initialize %s device\n", rte_ifpga_device_name(afu_dev)); - } + } return ret; } @@ -347,23 +349,20 @@ static int ifpga_remove_driver(struct rte_afu_device *afu_dev) { const char *name; - const struct rte_afu_driver *driver; name = rte_ifpga_device_name(afu_dev); - if (!afu_dev->device.driver) { + if (afu_dev->driver == NULL) { IFPGA_BUS_DEBUG("no driver attach to device %s\n", name); return 1; } - driver = RTE_DRV_TO_AFU_CONST(afu_dev->device.driver); - return driver->remove(afu_dev); + return afu_dev->driver->remove(afu_dev); } static int ifpga_unplug(struct rte_device *dev) { struct rte_afu_device *afu_dev = NULL; - struct rte_devargs *devargs = NULL; int ret; if (dev == NULL) @@ -373,15 +372,13 @@ ifpga_unplug(struct rte_device *dev) if (!afu_dev) return -ENOENT; - devargs = dev->devargs; - ret = ifpga_remove_driver(afu_dev); if (ret) return ret; TAILQ_REMOVE(&ifpga_afu_dev_list, afu_dev, next); - rte_devargs_remove(devargs->bus->name, devargs->name); + rte_devargs_remove(dev->devargs); free(afu_dev); return 0; diff --git a/drivers/bus/ifpga/meson.build b/drivers/bus/ifpga/meson.build index c9b08c86..0b5c38d5 100644 --- a/drivers/bus/ifpga/meson.build +++ b/drivers/bus/ifpga/meson.build @@ -1,6 +1,8 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2010-2018 Intel Corporation +version = 2 + deps += ['pci', 'kvargs', 'rawdev'] install_headers('rte_bus_ifpga.h') sources = files('ifpga_common.c', 'ifpga_bus.c') diff --git a/drivers/bus/ifpga/rte_bus_ifpga.h b/drivers/bus/ifpga/rte_bus_ifpga.h index 51d5ae0d..d53c0f48 100644 --- a/drivers/bus/ifpga/rte_bus_ifpga.h +++ b/drivers/bus/ifpga/rte_bus_ifpga.h @@ -83,9 +83,6 @@ struct rte_afu_device { #define RTE_DEV_TO_AFU(ptr) \ container_of(ptr, struct rte_afu_device, device) -#define RTE_DRV_TO_AFU_CONST(ptr) \ - container_of(ptr, const struct rte_afu_driver, driver) - /** * Initialization function for the driver called during FPGA BUS probing. */ |