From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Carew, Alan" Subject: Re: [PATCH v2 09/10] igbuio: show irq mode in sysfs Date: Mon, 16 Jun 2014 08:03:21 +0000 Message-ID: <0E29434AEE0C3A4180987AB476A6F630593A6E2E@IRSMSX101.ger.corp.intel.com> References: <20140606235028.189345212@networkplumber.org> <20140606235115.248804518@networkplumber.org> <20140608153704.GA27652@localhost.localdomain> <0E29434AEE0C3A4180987AB476A6F630593A63AB@IRSMSX101.ger.corp.intel.com> <20140611130808.3342aad0@nehalam.linuxnetplumber.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Cc: "dev-VfR2kkLFssw@public.gmane.org" To: Stephen Hemminger Return-path: In-Reply-To: <20140611130808.3342aad0-We1ePj4FEcvRI77zikRAJc56i+j3xesD0e7PPNI6Mm0@public.gmane.org> Content-Language: en-US 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" > -----Original Message----- > From: Stephen Hemminger [mailto:stephen-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@public.gmane.org] > Sent: Wednesday, June 11, 2014 9:08 PM > To: Carew, Alan > Cc: Neil Horman; dev-VfR2kkLFssw@public.gmane.org > Subject: Re: [dpdk-dev] [PATCH v2 09/10] igbuio: show irq mode in sysfs >=20 > This is what I am testing, along with 10 other virtio patches. >=20 > Subject: virtio: check for using msix interrupt >=20 > Fix how the device driver detects MSI-X vs INTX mode. > Look in sysfs to find if MSI-X is enabled. >=20 > Suggested-by: Neil Horman > Signed-off-by: Stephen Hemminger >=20 >=20 > --- a/lib/librte_pmd_virtio/virtio_ethdev.c > +++ b/lib/librte_pmd_virtio/virtio_ethdev.c > @@ -709,6 +709,28 @@ > return 0; > } >=20 > +/* > + * 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 =3D opendir(dirname); > + if (d) > + closedir(d); > + > + return (d !=3D 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=3D0x%lx with size=3D0x%lx\n", > start, size); > + > + hw->use_msix =3D has_msix(&pci_dev->addr); > } > #endif > hw->io_base =3D (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)); >=20 > -/* 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) >=20 > /* > * How many bits to shift physical queue address written to QUEUE_PFN. Hi Stephen, The mechanism is fine, however I would be against OS specific code in abstr= acted drivers. If "has_msix" was a helper function in eal (and suitably ren= amed) we could then add a FreeBSD equivalent implementation. A less favoura= ble solution would be conditional compilation(RTE_EXEC_ENV_LINUXAPP/BSDPAPP= ) around the above function. Thanks, Alan