env: Rename pci_device_rte_hotremove to pci_device_rte_dev_event
Give this a more generic name. We're going to be using these events for more than just hotremove coming up. Signed-off-by: Ben Walker <benjamin.walker@intel.com> Change-Id: Ia5356e9ab809807ba4d85ecc212a496e96012bce Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3559 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
parent
0d73f143b8
commit
a9be2ce64a
@ -209,36 +209,39 @@ spdk_pci_get_driver(const char *name)
|
||||
}
|
||||
|
||||
static void
|
||||
pci_device_rte_hotremove(const char *device_name,
|
||||
pci_device_rte_dev_event(const char *device_name,
|
||||
enum rte_dev_event_type event,
|
||||
void *cb_arg)
|
||||
{
|
||||
struct spdk_pci_device *dev;
|
||||
bool can_detach = false;
|
||||
|
||||
if (event != RTE_DEV_EVENT_REMOVE) {
|
||||
return;
|
||||
}
|
||||
switch (event) {
|
||||
default:
|
||||
case RTE_DEV_EVENT_ADD:
|
||||
/* Nothing to do here yet. */
|
||||
break;
|
||||
case RTE_DEV_EVENT_REMOVE:
|
||||
pthread_mutex_lock(&g_pci_mutex);
|
||||
TAILQ_FOREACH(dev, &g_pci_devices, internal.tailq) {
|
||||
struct rte_pci_device *rte_dev = dev->dev_handle;
|
||||
|
||||
pthread_mutex_lock(&g_pci_mutex);
|
||||
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 &&
|
||||
!dev->internal.pending_removal) {
|
||||
can_detach = !dev->internal.attached;
|
||||
/* prevent any further attaches */
|
||||
dev->internal.pending_removal = true;
|
||||
break;
|
||||
if (strcmp(rte_dev->name, device_name) == 0 &&
|
||||
!dev->internal.pending_removal) {
|
||||
can_detach = !dev->internal.attached;
|
||||
/* prevent any further attaches */
|
||||
dev->internal.pending_removal = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&g_pci_mutex);
|
||||
pthread_mutex_unlock(&g_pci_mutex);
|
||||
|
||||
if (dev != NULL && can_detach) {
|
||||
/* if device is not attached we can remove it right away.
|
||||
* Otherwise it will be removed at detach.
|
||||
*/
|
||||
remove_rte_dev(dev->dev_handle);
|
||||
if (dev != NULL && can_detach) {
|
||||
/* if device is not attached we can remove it right away.
|
||||
* Otherwise it will be removed at detach. */
|
||||
remove_rte_dev(dev->dev_handle);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -342,7 +345,7 @@ _pci_env_init(void)
|
||||
|
||||
/* Register a single hotremove callback for all devices. */
|
||||
if (spdk_process_is_primary()) {
|
||||
rte_dev_event_callback_register(NULL, pci_device_rte_hotremove, NULL);
|
||||
rte_dev_event_callback_register(NULL, pci_device_rte_dev_event, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -383,7 +386,7 @@ pci_env_fini(void)
|
||||
}
|
||||
|
||||
if (spdk_process_is_primary()) {
|
||||
rte_dev_event_callback_unregister(NULL, pci_device_rte_hotremove, NULL);
|
||||
rte_dev_event_callback_unregister(NULL, pci_device_rte_dev_event, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user