25. Port Hotplug Framework
The Port Hotplug Framework provides DPDK applications with the ability to attach and detach ports at runtime. Because the framework depends on PMD implementation, the ports that PMDs cannot handle are out of scope of this framework. Furthermore, after detaching a port from a DPDK application, the framework doesn’t provide a way for removing the devices from the system. For the ports backed by a physical NIC, the kernel will need to support PCI Hotplug feature.
The basic requirements of the Port Hotplug Framework are:
DPDK applications that use the Port Hotplug Framework must manage their own ports.
The Port Hotplug Framework is implemented to allow DPDK applications to manage ports. For example, when DPDK applications call the port attach function, the attached port number is returned. DPDK applications can also detach the port by port number.
Kernel support is needed for attaching or detaching physical device ports.
To attach new physical device ports, the device will be recognized by userspace driver I/O framework in kernel at first. Then DPDK applications can call the Port Hotplug functions to attach the ports. For detaching, steps are vice versa.
Before detaching, they must be stopped and closed.
DPDK applications must call “rte_eth_dev_stop()” and “rte_eth_dev_close()” APIs before detaching ports. These functions will start finalization sequence of the PMDs.
The framework doesn’t affect legacy DPDK applications behavior.
If the Port Hotplug functions aren’t called, all legacy DPDK apps can still work without modifications.
25.2. Port Hotplug API overview
Attaching a port
“rte_eth_dev_attach()” API attaches a port to DPDK application, and returns the attached port number. Before calling the API, the device should be recognized by an userspace driver I/O framework. The API receives a pci address like “0000:01:00.0” or a virtual device name like “eth_pcap0,iface=eth0”. In the case of virtual device name, the format is the same as the general “–vdev” option of DPDK.
Detaching a port
“rte_eth_dev_detach()” API detaches a port from DPDK application, and returns a pci address of the detached device or a virtual device name of the device.
“testpmd” supports the Port Hotplug Framework.
- The Port Hotplug APIs are not thread safe.
- The framework can only be enabled with Linux. BSD is not supported.
- To detach a port, the port should be backed by a device that igb_uio manages. VFIO is not supported.
- Not all PMDs support detaching feature. To know whether a PMD can support detaching, search for the “RTE_PCI_DRV_DETACHABLE” flag in PMD implementation. If the flag is defined in the PMD, detaching is supported.