From 76a7517caac6d8c8f406043c0b95642693bb78c9 Mon Sep 17 00:00:00 2001 From: Darek Stojaczyk Date: Fri, 7 Dec 2018 11:51:02 +0100 Subject: [PATCH] pci: remove virtio-specific attach functions As a part of cleanup they're replaced by a device-agnostic attach API, which is easier for us to manage. Change-Id: I2ec68f20ba209f02ee5c2de4b6fe5330a4bc0853 Signed-off-by: Darek Stojaczyk Reviewed-on: https://review.gerrithub.io/436480 Tested-by: SPDK CI Jenkins Chandler-Test-Pool: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- include/spdk/env.h | 23 +++++++---------------- lib/env_dpdk/pci_virtio.c | 13 +++---------- lib/virtio/virtio_pci.c | 6 ++++-- test/common/lib/test_env.c | 1 + 4 files changed, 15 insertions(+), 28 deletions(-) diff --git a/include/spdk/env.h b/include/spdk/env.h index de58683ef..a3ab17232 100644 --- a/include/spdk/env.h +++ b/include/spdk/env.h @@ -633,6 +633,13 @@ struct spdk_pci_driver *spdk_pci_nvme_get_driver(void); */ struct spdk_pci_driver *spdk_pci_ioat_get_driver(void); +/** + * Get the Virtio PCI driver object. + * + * \return PCI driver. + */ +struct spdk_pci_driver *spdk_pci_virtio_get_driver(void); + /** * Enumerate all PCI devices supported by the provided driver and try to * attach those that weren't attached yet. The provided callback will be @@ -653,14 +660,6 @@ struct spdk_pci_driver *spdk_pci_ioat_get_driver(void); */ int spdk_pci_enumerate(struct spdk_pci_driver *driver, spdk_pci_enum_cb enum_cb, void *enum_ctx); -/** - * Enumerate all Virtio devices on the PCI bus and try to attach those that - * weren't attached yet. - * - * \see spdk_pci_enumerate - */ -int spdk_pci_virtio_enumerate(spdk_pci_enum_cb enum_cb, void *enum_ctx); - /** * Map a PCI BAR in the current process. * @@ -846,14 +845,6 @@ void spdk_pci_device_detach(struct spdk_pci_device *device); 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); -/** - * Attach a PCI Virtio device. - * - * \see spdk_pci_device_attach - */ -int spdk_pci_virtio_device_attach(spdk_pci_enum_cb enum_cb, void *enum_ctx, - struct spdk_pci_addr *pci_address); - /** * Read \c len bytes from the PCI configuration space. * diff --git a/lib/env_dpdk/pci_virtio.c b/lib/env_dpdk/pci_virtio.c index 5ef92af62..38bfbc30e 100644 --- a/lib/env_dpdk/pci_virtio.c +++ b/lib/env_dpdk/pci_virtio.c @@ -59,17 +59,10 @@ static struct spdk_pci_driver g_virtio_pci_drv = { .is_registered = false, }; -int -spdk_pci_virtio_device_attach(spdk_pci_enum_cb enum_cb, - void *enum_ctx, struct spdk_pci_addr *pci_address) +struct spdk_pci_driver * +spdk_pci_virtio_get_driver(void) { - return spdk_pci_device_attach(&g_virtio_pci_drv, enum_cb, enum_ctx, pci_address); -} - -int -spdk_pci_virtio_enumerate(spdk_pci_enum_cb enum_cb, void *enum_ctx) -{ - return spdk_pci_enumerate(&g_virtio_pci_drv, enum_cb, enum_ctx); + return &g_virtio_pci_drv; } SPDK_PMD_REGISTER_PCI(g_virtio_pci_drv); diff --git a/lib/virtio/virtio_pci.c b/lib/virtio/virtio_pci.c index c21492a7c..9afb88293 100644 --- a/lib/virtio/virtio_pci.c +++ b/lib/virtio/virtio_pci.c @@ -549,7 +549,8 @@ virtio_pci_dev_enumerate(virtio_pci_create_cb enum_cb, void *enum_ctx, ctx.enum_ctx = enum_ctx; ctx.device_id = pci_device_id; - return spdk_pci_virtio_enumerate(virtio_pci_dev_probe_cb, &ctx); + return spdk_pci_enumerate(spdk_pci_virtio_get_driver(), + virtio_pci_dev_probe_cb, &ctx); } int @@ -567,7 +568,8 @@ virtio_pci_dev_attach(virtio_pci_create_cb enum_cb, void *enum_ctx, ctx.enum_ctx = enum_ctx; ctx.device_id = pci_device_id; - return spdk_pci_virtio_device_attach(virtio_pci_dev_probe_cb, &ctx, pci_address); + return spdk_pci_device_attach(spdk_pci_virtio_get_driver(), + virtio_pci_dev_probe_cb, &ctx, pci_address); } int diff --git a/test/common/lib/test_env.c b/test/common/lib/test_env.c index 682632dc2..ff12daf16 100644 --- a/test/common/lib/test_env.c +++ b/test/common/lib/test_env.c @@ -42,6 +42,7 @@ DEFINE_STUB(spdk_process_is_primary, bool, (void), true) DEFINE_STUB(spdk_memzone_lookup, void *, (const char *name), NULL) DEFINE_STUB(spdk_pci_nvme_get_driver, struct spdk_pci_driver *, (void), NULL) DEFINE_STUB(spdk_pci_ioat_get_driver, struct spdk_pci_driver *, (void), NULL) +DEFINE_STUB(spdk_pci_virtio_get_driver, struct spdk_pci_driver *, (void), NULL) /* * These mocks don't use the DEFINE_STUB macros because