-#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)
- {
- _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 u32
-get_node_free_hugepages_num (u32 node, u32 page_size)
-{
- FILE * fp;
- u8 * tmp;
-
- tmp = format (0, "/sys/devices/system/node/node%u/hugepages/hugepages-%ukB/"
- "free_hugepages%c", node, page_size, 0);
- fp = fopen ((char *) tmp, "r");
- vec_free(tmp);
-
- if (fp != NULL)
- {
- u8 * buffer = 0;
- u32 pages_avail = 0;