From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id BFA3DAFCB for ; Mon, 16 Jun 2014 10:03:52 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 16 Jun 2014 01:04:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,484,1400050800"; d="scan'208";a="558093695" Received: from irsmsx104.ger.corp.intel.com ([163.33.3.159]) by orsmga002.jf.intel.com with ESMTP; 16 Jun 2014 01:04:06 -0700 Received: from irsmsx101.ger.corp.intel.com ([169.254.1.245]) by IRSMSX104.ger.corp.intel.com ([169.254.5.136]) with mapi id 14.03.0123.003; Mon, 16 Jun 2014 09:03:21 +0100 From: "Carew, Alan" To: Stephen Hemminger Thread-Topic: [dpdk-dev] [PATCH v2 09/10] igbuio: show irq mode in sysfs Thread-Index: AQHPgeJGFEa9FdnAVk6Ym2Jz5TYUVptnSnYAgATrc/CAABdIAIAHHUpw 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> In-Reply-To: <20140611130808.3342aad0@nehalam.linuxnetplumber.net> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH v2 09/10] igbuio: show irq mode in sysfs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Jun 2014 08:03:53 -0000 > -----Original Message----- > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > Sent: Wednesday, June 11, 2014 9:08 PM > To: Carew, Alan > Cc: Neil Horman; dev@dpdk.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