-#endif
-
- _vec_len (path) = 0;
- path = format (path, "/sys/bus/pci/devices/%s/driver/unbind%c",
- devname, 0);
-
- /*
- * If the device is bound to a driver...
- */
- if (stat ((const char *)path, &st) == 0)
- {
- u8 * device_path;
-
- /*
- * If the interface is not a virtio...
- */
- if (!driver_name || strcmp(driver_name, VIRTIO_PCI_NAME))
- {
- /*
- * If it is already bound to driver, don't unbind/bind it.
- */
- device_path = format (0, "/sys/bus/pci/drivers/%s/%s/device%c",
- driver_name, devname, 0);
- if (stat ((const char *)device_path, &st) == 0)
- bind_uio = 0;
-
- vec_free (device_path);
- }
-
- /*
- * unbind it from the current driver
- */
- if (bind_uio)
- {
- _vec_len (path) -= 1;
- path = format (path, "%c", 0);
- error = write_sys_fs ((char *)path, "%s", devname);
- if (error)
- goto done;
- }
- }
-
- /*
- * DAW-FIXME: The following bind/unbind dance is necessary for the dpdk
- * virtio poll-mode driver to work.
- */
-
- if (driver_name && !strcmp(driver_name, VIRTIO_PCI_NAME))
- {
- /*
- * bind interface to the native kernel module
- */
- _vec_len (path) = 0;
- path = format (path, "/sys/bus/pci/drivers/%s/bind%c",
- driver_name, 0);
- error = write_sys_fs ((char *)path, "%s", devname);
- if (error)
- goto done;
-
- /*
- * unbind interface from the native kernel module
- */
- _vec_len (path) -= 5;
- path = format (path, "unbind%c", 0);
- error = write_sys_fs ((char *)path, "%s", devname);
- if (error)
- goto done;
- }
-
- /*
- * bind the interface to igb_uio
- */
- if (bind_uio)
- {
- int pci_vendor_id = strtol((char *) pci_vid, NULL, 16);
- int pci_device_id = strtol((char *) pci_did, NULL, 16);
-
- /*
- * Set PCI ID to ".../virtio-pci/new_id" for Intel fortvile adapaters
- */
- if (pci_vendor_id == 0x8086 &&
- (pci_device_id == I40E_DEV_ID_10G_BASE_T ||
- pci_device_id == I40E_DEV_ID_SFP_XL710 ||
- pci_device_id == I40E_DEV_ID_QSFP_A ||
- pci_device_id == I40E_DEV_ID_QSFP_B ||
- pci_device_id == I40E_DEV_ID_QSFP_C))
- {
- _vec_len (path) = 0;
- path = format (path, "/sys/bus/pci/drivers/%s/new_id%c", driver_name, 0);
- error = write_sys_fs ((char *) path, "%s %s", pci_vid, pci_did);
- if (error)
- continue;
- }
-
- _vec_len (path) = 0;
- path = format (path, "/sys/bus/pci/drivers/%s/bind%c", driver_name, 0);
- error = write_sys_fs ((char *) path, "%s", devname);
- if (error)
- {
- error = 0;
- continue;
- }
- }
- }
-
- done:
- vec_free (line);
- vec_free (path);
- vec_free (devname);
- vec_free (pci_vid);
- vec_free (pci_did);
- vec_free (modcmd);
- pclose (fp);
- return error;
-}
-
-static uword
-unformat_socket_mem (unformat_input_t * input, va_list * va)
-{
- uword ** r = va_arg (* va, uword **);
- int i = 0;
- u32 mem;
-
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (input, ","))
- hash_set (*r, i, 1024);
- else if (unformat (input, "%u,", &mem))
- hash_set (*r, i, mem);
- else if (unformat (input, "%u", &mem))
- hash_set (*r, i, mem);
- else
- {
- unformat_put_input (input);
- goto done;
- }
- i++;
- }
-
-done:
- return 1;
-}
-
-static u32
-get_node_free_hugepages_num (u32 node, u32 page_size)
-{
- FILE * fp;
- u8 * tmp;