From db531332cff36ce8084405b983c5cf851e04e196 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Thu, 15 Sep 2022 20:53:18 +0000 Subject: [PATCH] env_dpdk: add dpdk_pci_device_get_name This touches the rte_pci_device structure, so let's make a separate accessor function just for that. We will start putting the definitions for these new dpdk_pci_device_xxx functions at the end of pci.c. At the end of this series, we will then just lop off the end of pci.c containing all of the dpdk_pci_device functions and move them to a DPDK-dependent pci_22_07.c file. Signed-off-by: Jim Harris Change-Id: I0323fc19b51d21d1bac899df21d6ebf4354ab339 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14542 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Aleksey Marchuk Reviewed-by: Konrad Sztyber --- lib/env_dpdk/pci.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/env_dpdk/pci.c b/lib/env_dpdk/pci.c index 7fd5e4dbe..0c2baa8fe 100644 --- a/lib/env_dpdk/pci.c +++ b/lib/env_dpdk/pci.c @@ -56,6 +56,8 @@ SPDK_STATIC_ASSERT(offsetof(struct spdk_pci_driver, driver_buf) == 0, "driver_bu SPDK_STATIC_ASSERT(offsetof(struct spdk_pci_driver, driver) >= sizeof(struct rte_pci_driver), "driver_buf not big enough"); +const char *dpdk_pci_device_get_name(struct rte_pci_device *); + int pci_device_init(struct rte_pci_driver *driver, struct rte_pci_device *device); int pci_device_fini(struct rte_pci_device *device); @@ -130,7 +132,7 @@ remove_rte_dev(struct rte_pci_device *rte_dev) char bdf[32]; int i = 0, rc; - snprintf(bdf, sizeof(bdf), "%s", rte_dev->device.name); + snprintf(bdf, sizeof(bdf), "%s", dpdk_pci_device_get_name(rte_dev)); do { rc = rte_eal_hotplug_remove("pci", bdf); } while (rc == -ENOMSG && ++i <= DPDK_HOTPLUG_RETRY_COUNT); @@ -198,7 +200,7 @@ detach_rte(struct spdk_pci_device *dev) pthread_mutex_unlock(&g_pci_mutex); if (!removed) { SPDK_ERRLOG("Timeout waiting for DPDK to remove PCI device %s.\n", - rte_dev->name); + dpdk_pci_device_get_name(rte_dev)); /* If we reach this state, then the device couldn't be removed and most likely a subsequent hot add of a device in the same BDF will fail */ } @@ -260,7 +262,7 @@ pci_device_rte_dev_event(const char *device_name, TAILQ_FOREACH(dev, &g_pci_devices, internal.tailq) { struct rte_pci_device *rte_dev = dev->dev_handle; - if (strcmp(rte_dev->name, device_name) == 0 && + if (strcmp(dpdk_pci_device_get_name(rte_dev), device_name) == 0 && !dev->internal.pending_removal) { can_detach = !dev->internal.attached; /* prevent any further attaches */ @@ -1272,3 +1274,9 @@ dpdk_pci_device_vtophys(struct rte_pci_device *dev, uint64_t vaddr) return SPDK_VTOPHYS_ERROR; } + +const char * +dpdk_pci_device_get_name(struct rte_pci_device *rte_dev) +{ + return rte_dev->name; +}