pci: rename enum_ctx struct to spdk_pci_driver
Although the struct is used as an enumeration context, it really is a pci driver. The subsuequent patch introduces a few functions around the pci driver, so rename the struct to make it align nicely with those functions. Change-Id: I919c30e55d9f42d795ecd8e20e5d29f3918c17a5 Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/434414 (master) Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448376 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
508d2b6f34
commit
1069db5c5b
@ -74,7 +74,7 @@ extern struct rte_pci_bus rte_pci_bus;
|
||||
|
||||
struct spdk_pci_device {
|
||||
struct rte_pci_device *dev_handle;
|
||||
struct spdk_pci_enum_ctx *enum_ctx;
|
||||
struct spdk_pci_driver *driver;
|
||||
struct spdk_pci_addr addr;
|
||||
struct spdk_pci_id id;
|
||||
int socket_id;
|
||||
@ -82,7 +82,7 @@ struct spdk_pci_device {
|
||||
TAILQ_ENTRY(spdk_pci_device) tailq;
|
||||
};
|
||||
|
||||
struct spdk_pci_enum_ctx {
|
||||
struct spdk_pci_driver {
|
||||
struct rte_pci_driver driver;
|
||||
spdk_pci_enum_cb cb_fn;
|
||||
void *cb_arg;
|
||||
@ -92,8 +92,8 @@ struct spdk_pci_enum_ctx {
|
||||
int spdk_pci_device_init(struct rte_pci_driver *driver, struct rte_pci_device *device);
|
||||
int spdk_pci_device_fini(struct rte_pci_device *device);
|
||||
|
||||
int spdk_pci_enumerate(struct spdk_pci_enum_ctx *ctx, spdk_pci_enum_cb enum_cb, void *enum_ctx);
|
||||
int spdk_pci_device_attach(struct spdk_pci_enum_ctx *ctx, spdk_pci_enum_cb enum_cb, void *enum_ctx,
|
||||
int spdk_pci_enumerate(struct spdk_pci_driver *driver, spdk_pci_enum_cb enum_cb, void *enum_ctx);
|
||||
int spdk_pci_device_attach(struct spdk_pci_driver *driver, spdk_pci_enum_cb enum_cb, void *enum_ctx,
|
||||
struct spdk_pci_addr *pci_address);
|
||||
|
||||
int spdk_mem_map_init(void);
|
||||
|
@ -44,14 +44,14 @@ static pthread_mutex_t g_pci_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static TAILQ_HEAD(, spdk_pci_device) g_pci_devices = TAILQ_HEAD_INITIALIZER(g_pci_devices);
|
||||
|
||||
int
|
||||
spdk_pci_device_init(struct rte_pci_driver *driver,
|
||||
spdk_pci_device_init(struct rte_pci_driver *_drv,
|
||||
struct rte_pci_device *_dev)
|
||||
{
|
||||
struct spdk_pci_enum_ctx *ctx = (struct spdk_pci_enum_ctx *)driver;
|
||||
struct spdk_pci_driver *driver = (struct spdk_pci_driver *)_drv;
|
||||
struct spdk_pci_device *dev;
|
||||
int rc;
|
||||
|
||||
if (!ctx->cb_fn) {
|
||||
if (!driver->cb_fn) {
|
||||
#if RTE_VERSION < RTE_VERSION_NUM(17, 02, 0, 1)
|
||||
rte_eal_pci_unmap_device(_dev);
|
||||
#endif
|
||||
@ -66,7 +66,7 @@ spdk_pci_device_init(struct rte_pci_driver *driver,
|
||||
}
|
||||
|
||||
dev->dev_handle = _dev;
|
||||
dev->enum_ctx = ctx;
|
||||
dev->driver = driver;
|
||||
|
||||
dev->addr.domain = _dev->addr.domain;
|
||||
dev->addr.bus = _dev->addr.bus;
|
||||
@ -78,7 +78,7 @@ spdk_pci_device_init(struct rte_pci_driver *driver,
|
||||
dev->id.subdevice_id = _dev->id.subsystem_device_id;
|
||||
dev->socket_id = _dev->device.numa_node;
|
||||
|
||||
rc = ctx->cb_fn(ctx->cb_arg, dev);
|
||||
rc = driver->cb_fn(driver->cb_arg, dev);
|
||||
if (rc != 0) {
|
||||
free(dev);
|
||||
return rc;
|
||||
@ -133,7 +133,7 @@ spdk_pci_device_detach(struct spdk_pci_device *dev)
|
||||
}
|
||||
|
||||
int
|
||||
spdk_pci_device_attach(struct spdk_pci_enum_ctx *ctx,
|
||||
spdk_pci_device_attach(struct spdk_pci_driver *driver,
|
||||
spdk_pci_enum_cb enum_cb,
|
||||
void *enum_ctx, struct spdk_pci_addr *pci_address)
|
||||
{
|
||||
@ -160,7 +160,7 @@ spdk_pci_device_attach(struct spdk_pci_enum_ctx *ctx,
|
||||
}
|
||||
}
|
||||
|
||||
if (dev != NULL && dev->enum_ctx == ctx) {
|
||||
if (dev != NULL && dev->driver == driver) {
|
||||
if (dev->attached) {
|
||||
pthread_mutex_unlock(&g_pci_mutex);
|
||||
return -1;
|
||||
@ -174,17 +174,17 @@ spdk_pci_device_attach(struct spdk_pci_enum_ctx *ctx,
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (!ctx->is_registered) {
|
||||
ctx->is_registered = true;
|
||||
if (!driver->is_registered) {
|
||||
driver->is_registered = true;
|
||||
#if RTE_VERSION >= RTE_VERSION_NUM(17, 05, 0, 4)
|
||||
rte_pci_register(&ctx->driver);
|
||||
rte_pci_register(&driver->driver);
|
||||
#else
|
||||
rte_eal_pci_register(&ctx->driver);
|
||||
rte_eal_pci_register(&driver->driver);
|
||||
#endif
|
||||
}
|
||||
|
||||
ctx->cb_fn = enum_cb;
|
||||
ctx->cb_arg = enum_ctx;
|
||||
driver->cb_fn = enum_cb;
|
||||
driver->cb_arg = enum_ctx;
|
||||
|
||||
#if RTE_VERSION >= RTE_VERSION_NUM(18, 11, 0, 0)
|
||||
rc = rte_eal_hotplug_add("pci", bdf, "");
|
||||
@ -196,8 +196,8 @@ spdk_pci_device_attach(struct spdk_pci_enum_ctx *ctx,
|
||||
rc = rte_eal_pci_probe_one(&addr);
|
||||
#endif
|
||||
|
||||
ctx->cb_arg = NULL;
|
||||
ctx->cb_fn = NULL;
|
||||
driver->cb_arg = NULL;
|
||||
driver->cb_fn = NULL;
|
||||
pthread_mutex_unlock(&g_pci_mutex);
|
||||
|
||||
return rc == 0 ? 0 : -1;
|
||||
@ -208,7 +208,7 @@ spdk_pci_device_attach(struct spdk_pci_enum_ctx *ctx,
|
||||
* and rte_eal_pci_probe simultaneously.
|
||||
*/
|
||||
int
|
||||
spdk_pci_enumerate(struct spdk_pci_enum_ctx *ctx,
|
||||
spdk_pci_enumerate(struct spdk_pci_driver *driver,
|
||||
spdk_pci_enum_cb enum_cb,
|
||||
void *enum_ctx)
|
||||
{
|
||||
@ -218,7 +218,7 @@ spdk_pci_enumerate(struct spdk_pci_enum_ctx *ctx,
|
||||
pthread_mutex_lock(&g_pci_mutex);
|
||||
|
||||
TAILQ_FOREACH(dev, &g_pci_devices, tailq) {
|
||||
if (dev->attached || dev->enum_ctx != ctx) {
|
||||
if (dev->attached || dev->driver != driver) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -231,17 +231,17 @@ spdk_pci_enumerate(struct spdk_pci_enum_ctx *ctx,
|
||||
}
|
||||
}
|
||||
|
||||
if (!ctx->is_registered) {
|
||||
ctx->is_registered = true;
|
||||
if (!driver->is_registered) {
|
||||
driver->is_registered = true;
|
||||
#if RTE_VERSION >= RTE_VERSION_NUM(17, 05, 0, 4)
|
||||
rte_pci_register(&ctx->driver);
|
||||
rte_pci_register(&driver->driver);
|
||||
#else
|
||||
rte_eal_pci_register(&ctx->driver);
|
||||
rte_eal_pci_register(&driver->driver);
|
||||
#endif
|
||||
}
|
||||
|
||||
ctx->cb_fn = enum_cb;
|
||||
ctx->cb_arg = enum_ctx;
|
||||
driver->cb_fn = enum_cb;
|
||||
driver->cb_arg = enum_ctx;
|
||||
|
||||
#if RTE_VERSION >= RTE_VERSION_NUM(17, 11, 0, 3)
|
||||
if (rte_bus_probe() != 0) {
|
||||
@ -250,14 +250,14 @@ spdk_pci_enumerate(struct spdk_pci_enum_ctx *ctx,
|
||||
#else
|
||||
if (rte_eal_pci_probe() != 0) {
|
||||
#endif
|
||||
ctx->cb_arg = NULL;
|
||||
ctx->cb_fn = NULL;
|
||||
driver->cb_arg = NULL;
|
||||
driver->cb_fn = NULL;
|
||||
pthread_mutex_unlock(&g_pci_mutex);
|
||||
return -1;
|
||||
}
|
||||
|
||||
ctx->cb_arg = NULL;
|
||||
ctx->cb_fn = NULL;
|
||||
driver->cb_arg = NULL;
|
||||
driver->cb_fn = NULL;
|
||||
pthread_mutex_unlock(&g_pci_mutex);
|
||||
|
||||
return 0;
|
||||
|
@ -88,7 +88,7 @@ static struct rte_pci_id ioat_driver_id[] = {
|
||||
{ .vendor_id = 0, /* sentinel */ },
|
||||
};
|
||||
|
||||
static struct spdk_pci_enum_ctx g_ioat_pci_drv = {
|
||||
static struct spdk_pci_driver g_ioat_pci_drv = {
|
||||
.driver = {
|
||||
.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
|
||||
.id_table = ioat_driver_id,
|
||||
|
@ -46,7 +46,7 @@ static struct rte_pci_id nvme_pci_driver_id[] = {
|
||||
{ .vendor_id = 0, /* sentinel */ },
|
||||
};
|
||||
|
||||
static struct spdk_pci_enum_ctx g_nvme_pci_drv = {
|
||||
static struct spdk_pci_driver g_nvme_pci_drv = {
|
||||
.driver = {
|
||||
.drv_flags = RTE_PCI_DRV_NEED_MAPPING
|
||||
#if RTE_VERSION >= RTE_VERSION_NUM(18, 8, 0, 0)
|
||||
|
@ -41,7 +41,7 @@ static struct rte_pci_id virtio_pci_driver_id[] = {
|
||||
{ .vendor_id = 0, /* sentinel */ },
|
||||
};
|
||||
|
||||
static struct spdk_pci_enum_ctx g_virtio_pci_drv = {
|
||||
static struct spdk_pci_driver g_virtio_pci_drv = {
|
||||
.driver = {
|
||||
.drv_flags = RTE_PCI_DRV_NEED_MAPPING
|
||||
#if RTE_VERSION >= RTE_VERSION_NUM(18, 8, 0, 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user