[dpdk][hotplug] DPDK网卡设备热插拔
dpdk pci网卡设备的热插拔。
样例程序如下:
... ... static int driverctl(char* pci) { int pid; pid = fork(); if (pid == 0) { execlp("driverctl", "driverctl", "--nosave", "set-override", pci, "igb_uio", NULL); perror("driverctl set-override failed."); exit(1); } else if (pid > 0) { wait(NULL); } else { perror("fork failed."); exit(1); } return 0; } static int dpdk_bind_ethernet(struct pci_mac_map_t* port) { uint8_t portid; if (port->stat == PCI_STAT_DPDK) return 0; /* bind driver. */ /* FIXME: Only support igb_uio. */ log(LOG_INFO, "driverctl bind: %s.\n", port->pci); if (driverctl(port->pci) < 0) { log(LOG_ERR, "driverctl()\n"); return -1; } /* attach. */ log(LOG_INFO, "dpdk attach: %s.\n", port->pci); if (rte_eth_dev_attach(port->pci, &portid) < 0) { ctrl_debug(LOG_ERR, "rte_eth_dev_attach()\n"); return -1; } return portid; } ... ...