X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=vlib%2Fvlib%2Fpci%2Flinux_pci.c;h=f9ee47ac14583ed9f9c627dee607ccbeaeb5236b;hb=6b9c6df746f3d007b3021044b67a3fc1462d1b35;hp=ba6defeb2f13f9d1ee7089ff8fb2e2e54c3bf323;hpb=9b8ffd99fb35d37250cfb7094a0a31515f1bb577;p=vpp.git diff --git a/vlib/vlib/pci/linux_pci.c b/vlib/vlib/pci/linux_pci.c index ba6defeb2f1..f9ee47ac145 100644 --- a/vlib/vlib/pci/linux_pci.c +++ b/vlib/vlib/pci/linux_pci.c @@ -99,12 +99,9 @@ vlib_pci_bind_to_uio (vlib_pci_device_t * d, char *uio_driver_name) DIR *dir = 0; struct dirent *e; int fd; - pci_config_header_t *c; u8 *dev_dir_name = format (0, "/sys/bus/pci/devices/%U", format_vlib_pci_addr, &d->bus_address); - c = &d->config0.header; - /* if uio sub-directory exists, we are fine, device is already bound to UIO driver */ s = format (s, "%v/uio%c", dev_dir_name, 0); @@ -147,14 +144,11 @@ vlib_pci_bind_to_uio (vlib_pci_device_t * d, char *uio_driver_name) drvinfo.cmd = ETHTOOL_GDRVINFO; if (ioctl (fd, SIOCETHTOOL, &ifr) < 0) { - if (errno == ENOTSUP) - /* Some interfaces (eg "lo") don't support this ioctl */ - continue; - - error = clib_error_return_unix (0, "ioctl fetch intf %s bus info", - e->d_name); - close (fd); - goto done; + /* Some interfaces (eg "lo") don't support this ioctl */ + if ((errno != ENOTSUP) && (errno != ENODEV)) + clib_unix_warning ("ioctl fetch intf %s bus info error", + e->d_name); + continue; } if (strcmp ((char *) s, drvinfo.bus_info)) @@ -189,7 +183,7 @@ vlib_pci_bind_to_uio (vlib_pci_device_t * d, char *uio_driver_name) vec_reset_length (s); s = format (s, "/sys/bus/pci/drivers/%s/new_id%c", uio_driver_name, 0); - vlib_sysfs_write ((char *) s, "0x%04x 0x%04x", c->vendor_id, c->device_id); + vlib_sysfs_write ((char *) s, "0x%04x 0x%04x", d->vendor_id, d->device_id); vec_reset_length (s); s = format (s, "/sys/bus/pci/drivers/%s/bind%c", uio_driver_name, 0); @@ -430,17 +424,14 @@ init_device_from_registered (vlib_main_t * vm, vlib_pci_main_t *pm = &pci_main; pci_device_registration_t *r; pci_device_id_t *i; - pci_config_header_t *c; clib_error_t *error; - c = &dev->config0.header; - r = pm->pci_device_registrations; while (r) { for (i = r->supported_devices; i->vendor_id != 0; i++) - if (i->vendor_id == c->vendor_id && i->device_id == c->device_id) + if (i->vendor_id == dev->vendor_id && i->device_id == dev->device_id) { error = vlib_pci_bind_to_uio (dev, "uio_pci_generic"); if (error) @@ -477,6 +468,7 @@ scan_device (void *arg, u8 * dev_dir_name, u8 * ignored) clib_error_t *error = 0; vlib_pci_device_t *dev; linux_pci_device_t pdev = { 0 }; + u32 tmp; f = format (0, "%v/config%c", dev_dir_name, 0); fd = open ((char *) f, O_RDWR); @@ -595,6 +587,21 @@ scan_device (void *arg, u8 * dev_dir_name, u8 * ignored) f = format (f, "%v/numa_node%c", dev_dir_name, 0); vlib_sysfs_read ((char *) f, "%u", &dev->numa_node); + vec_reset_length (f); + f = format (f, "%v/class%c", dev_dir_name, 0); + vlib_sysfs_read ((char *) f, "0x%x", &tmp); + dev->device_class = tmp >> 8; + + vec_reset_length (f); + f = format (f, "%v/vendor%c", dev_dir_name, 0); + vlib_sysfs_read ((char *) f, "0x%x", &tmp); + dev->vendor_id = tmp; + + vec_reset_length (f); + f = format (f, "%v/device%c", dev_dir_name, 0); + vlib_sysfs_read ((char *) f, "0x%x", &tmp); + dev->device_id = tmp; + done: vec_free (f); return error;