From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH v2 09/10] igbuio: show irq mode in sysfs Date: Wed, 11 Jun 2014 13:08:08 -0700 Message-ID: <20140611130808.3342aad0@nehalam.linuxnetplumber.net> References: <20140606235028.189345212@networkplumber.org> <20140606235115.248804518@networkplumber.org> <20140608153704.GA27652@localhost.localdomain> <0E29434AEE0C3A4180987AB476A6F630593A63AB@IRSMSX101.ger.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: "dev-VfR2kkLFssw@public.gmane.org" To: "Carew, Alan" Return-path: In-Reply-To: <0E29434AEE0C3A4180987AB476A6F630593A63AB-kPTMFJFq+rF9qrmMLTLiibfspsVTdybXVpNB7YpNyf8@public.gmane.org> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" 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 Signed-off-by: Stephen Hemminger --- 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//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.