From 1069db5c5bc2c1d8ea672e4308c983298429e9b9 Mon Sep 17 00:00:00 2001 From: Darek Stojaczyk Date: Sat, 1 Dec 2018 10:31:35 +0100 Subject: [PATCH] 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 Reviewed-on: https://review.gerrithub.io/434414 (master) Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448376 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- lib/env_dpdk/env_internal.h | 8 +++--- lib/env_dpdk/pci.c | 54 ++++++++++++++++++------------------- lib/env_dpdk/pci_ioat.c | 2 +- lib/env_dpdk/pci_nvme.c | 2 +- lib/env_dpdk/pci_virtio.c | 2 +- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/lib/env_dpdk/env_internal.h b/lib/env_dpdk/env_internal.h index baa7f839e5..3b3f4f462c 100644 --- a/lib/env_dpdk/env_internal.h +++ b/lib/env_dpdk/env_internal.h @@ -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); diff --git a/lib/env_dpdk/pci.c b/lib/env_dpdk/pci.c index e4439345d8..9aed2336ef 100644 --- a/lib/env_dpdk/pci.c +++ b/lib/env_dpdk/pci.c @@ -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; diff --git a/lib/env_dpdk/pci_ioat.c b/lib/env_dpdk/pci_ioat.c index 6ed7d8cccf..95359eee92 100644 --- a/lib/env_dpdk/pci_ioat.c +++ b/lib/env_dpdk/pci_ioat.c @@ -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, diff --git a/lib/env_dpdk/pci_nvme.c b/lib/env_dpdk/pci_nvme.c index d7a82a8e17..b46dda411b 100644 --- a/lib/env_dpdk/pci_nvme.c +++ b/lib/env_dpdk/pci_nvme.c @@ -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) diff --git a/lib/env_dpdk/pci_virtio.c b/lib/env_dpdk/pci_virtio.c index 5f58b0aa3b..007dbc0080 100644 --- a/lib/env_dpdk/pci_virtio.c +++ b/lib/env_dpdk/pci_virtio.c @@ -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)