[3/3] testpmd: remove device detach into eal
Checks
Commit Message
Assume that eal detect the removal event and handle hot-unplug, so device
detach should be located in eal framework, the sequence should be eal
detect and handle hot-unplug event at first, then eal notify app to finish
pre-detach prepare, such as stop forwarding and clean ports, finally device
be detached safely in eal. This patch aim to remove the invoke of device
detach from app callback to eal device event handler.
Signed-off-by: Jeff Guo <jia.guo@intel.com>
---
app/test-pmd/testpmd.c | 1 -
drivers/bus/pci/pci_common.c | 7 +++++++
lib/librte_eal/linuxapp/eal/eal_dev.c | 16 +++++++++++++++-
3 files changed, 22 insertions(+), 2 deletions(-)
@@ -2538,7 +2538,6 @@ rmv_port_callback(void *arg)
stop_port(port_id);
no_link_check = org_no_link_check;
close_port(port_id);
- detach_port_device(port_id);
if (need_to_start)
start_packet_forwarding(0);
}
@@ -465,6 +465,13 @@ pci_hot_unplug_handler(struct rte_device *dev)
*/
rte_dev_event_callback_process(dev->name,
RTE_DEV_EVENT_REMOVE);
+ ret = rte_dev_remove(dev);
+ if (ret) {
+ RTE_LOG(ERR, EAL, "Failed to remove device %s\n",
+ dev->name);
+ return -1;
+ }
+ RTE_LOG(INFO, EAL, "Success to remove device %s\n", dev->name);
break;
#endif
case RTE_KDRV_IGB_UIO:
@@ -275,8 +275,22 @@ dev_uev_handler(__rte_unused void *param)
"for device (%s)\n", dev->name);
}
rte_spinlock_unlock(&failure_handle_lock);
+
+ rte_dev_event_callback_process(uevent.devname,
+ uevent.type);
+ ret = rte_dev_remove(dev);
+ if (ret) {
+ RTE_LOG(ERR, EAL,
+ "Failed to remove device %s\n",
+ dev->name);
+ return;
+ }
+ RTE_LOG(INFO, EAL, "Success to remove device %s\n",
+ dev->name);
+ } else {
+ rte_dev_event_callback_process(uevent.devname,
+ uevent.type);
}
- rte_dev_event_callback_process(uevent.devname, uevent.type);
}
return;