This is what I am testing, along with 10 other virtio patches. Subject: virtio: check for using msix interrupt
Fix how the device driver detects MSI-X vs INTX mode. Look in sysfs to find if MSI-X is enabled. Suggested-by: Neil Horman <nhorman at tuxdriver.com> Signed-off-by: Stephen Hemminger <stephen at networkplumber.org> --- a/lib/librte_pmd_virtio/virtio_ethdev.c +++ b/lib/librte_pmd_virtio/virtio_ethdev.c @@ -709,6 +709,28 @@ return 0; } +/* + * Detect if using INTX or MSI-X by looking for: + * /sys/bus/pci/devices/<D:B:D.F>/msi_irqs/ + * if directory exists, must be using msi-x + */ +static int +has_msix(const struct rte_pci_addr *loc) +{ + DIR *d; + char dirname[PATH_MAX]; + + rte_snprintf(dirname, sizeof(dirname), + SYSFS_PCI_DEVICES "/" PCI_PRI_FMT "/msi_irqs", + loc->domain, loc->bus, loc->devid, loc->function); + + d = opendir(dirname); + if (d) + closedir(d); + + return (d != NULL); +} + static int get_uio_dev(struct rte_pci_addr *loc, char *buf, unsigned int buflen) { unsigned int uio_num; @@ -872,6 +894,8 @@ PMD_INIT_LOG(DEBUG, "PCI Port IO found start=0x%lx with size=0x%lx\n", start, size); + + hw->use_msix = has_msix(&pci_dev->addr); } #endif hw->io_base = (uint32_t)(uintptr_t)pci_dev->mem_resource[0].addr; --- a/lib/librte_pmd_virtio/virtio_pci.h +++ b/lib/librte_pmd_virtio/virtio_pci.h @@ -177,6 +177,7 @@ uint16_t subsystem_device_id; uint16_t subsystem_vendor_id; uint8_t revision_id; + uint8_t use_msix; uint8_t mac_addr[ETHER_ADDR_LEN]; int adapter_stopped; }; @@ -194,13 +195,11 @@ uint16_t max_virtqueue_pairs; } __attribute__((packed)); -/* Value indicated in device config */ -#define VIRTIO_PCI_FLAG_MSIX 0x0020 /* * The remaining space is defined by each driver as the per-driver * configuration space. */ -#define VIRTIO_PCI_CONFIG(hw) (((hw)->guest_features & VIRTIO_PCI_FLAG_MSIX) ? 24 : 20) +#define VIRTIO_PCI_CONFIG(hw) (((hw)->use_msix) ? 24 : 20) /* * How many bits to shift physical queue address written to QUEUE_PFN.