From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f42.google.com (mail-pa0-f42.google.com [209.85.220.42]) by dpdk.org (Postfix) with ESMTP id 50A5DB0CA for ; Wed, 11 Jun 2014 22:07:57 +0200 (CEST) Received: by mail-pa0-f42.google.com with SMTP id lj1so171011pab.29 for ; Wed, 11 Jun 2014 13:08:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=7sHztAK4qkqq7e4U12KrZsBHqDJql5PqSGYJkacdGbs=; b=bTvAU9qhY4X3gk7rXzoyTArXMipVy+SLxxHtOuxa2myNQv+tyP6EMEDoXkMHhMqISC AvrLFbGVH3BqtpGmuPglvTcHBjaySpkIn3HrPp9N1iK2ZMrlM2LJiyp/GBr3nSc9y/0+ njux4CbTSKs2fO1RVyxBfTLRiQd2hAZ6XRX526iAmzHg/XS24MBoNjE/jsSVuzfrje7d +4w0N2kd7pgg1ibsHcTWBYU6vdSFDH/sx0R0ds4M/I3p2KoskckeGy2XE9mHm5ed+fhz tcVpLVaR898sT1C12v+1MJ4fQRzNiAeGdm0r7ruN5oa4BPA2uM3o63KYwh5FjWShEWqx 7WeQ== X-Gm-Message-State: ALoCoQmSNYacjqDh7Pw+FGzpuG+4s0PfdCcSCmlgujQ089UD6+Bt0z03w3Ev6MoCRW6hJkFLRx0z X-Received: by 10.66.151.144 with SMTP id uq16mr16482606pab.68.1402517291658; Wed, 11 Jun 2014 13:08:11 -0700 (PDT) Received: from nehalam.linuxnetplumber.net (static-50-53-83-51.bvtn.or.frontiernet.net. [50.53.83.51]) by mx.google.com with ESMTPSA id ys1sm33902043pab.7.2014.06.11.13.08.11 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 11 Jun 2014 13:08:11 -0700 (PDT) Date: Wed, 11 Jun 2014 13:08:08 -0700 From: Stephen Hemminger To: "Carew, Alan" Message-ID: <20140611130808.3342aad0@nehalam.linuxnetplumber.net> In-Reply-To: <0E29434AEE0C3A4180987AB476A6F630593A63AB@IRSMSX101.ger.corp.intel.com> References: <20140606235028.189345212@networkplumber.org> <20140606235115.248804518@networkplumber.org> <20140608153704.GA27652@localhost.localdomain> <0E29434AEE0C3A4180987AB476A6F630593A63AB@IRSMSX101.ger.corp.intel.com> X-Mailer: Claws Mail 3.9.3 (GTK+ 2.24.23; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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: Wed, 11 Jun 2014 20:07:57 -0000 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.