... ...static int driverctl(char*pci)
{intpid;
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;
}returnportid;
}
... ...