From patchwork Fri Jul 7 00:09:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ga=C3=ABtan_Rivet?= X-Patchwork-Id: 26591 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 4A50B7CB1; Fri, 7 Jul 2017 02:10:15 +0200 (CEST) Received: from mail-wr0-f180.google.com (mail-wr0-f180.google.com [209.85.128.180]) by dpdk.org (Postfix) with ESMTP id 78DFB532C for ; Fri, 7 Jul 2017 02:10:01 +0200 (CEST) Received: by mail-wr0-f180.google.com with SMTP id k67so24224011wrc.2 for ; Thu, 06 Jul 2017 17:10:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=F4qOuNBwTxMwcEufGvo52z2PKIpfp4iF3J0N+o63+pk=; b=sXd4VY5dquhzaUT3Ca3ag1S7E6k/LsDFJTBeGwku9UjsXx/GlceDLo6uzqtyk27nwq 35JXuDUcxcc5fNUAJb2T6v0xSdlFGoierU/ofbdzzXQt2OGCBP/XJXiy8R54Fh8YGGyZ UfkafYPGrbR1HVjUAAGE95sJQhcGj4eSy7qXPTviupWEMpJHjScFiAScQvjodao+XU/t +Wdw8C9Kq1/6gD16cTUTW6QLwsfyOYvIWYEhwgDcIlJMisPjL2nH3PnT1vzNbtZcHVl5 NIWZWSeXbTaX13wUpKgXvVVgfcnC7MFZ84Zc+YcgRuIIYL6nBXJ1w4RtrSGoE9q5MHop ynxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=F4qOuNBwTxMwcEufGvo52z2PKIpfp4iF3J0N+o63+pk=; b=oW1/uhculBvlpnw4jsmWuXGmDbjOplE7gnHXGupNVrYx9LEcHmY/aY0vq/nFp1zFa7 qqm2gukE4YYU6eoJQglg3tYVkYbim5sn60jwTWWxSdMPBQg3KjwSIzj9TTmSHFUh9fIx ZkeN22zIWeOv3zuvoElBTtYpd7CCoAZT/J0gdRf+zXR7nwIGe/2lXHeI7r+tpFuM8+8F AuQ+13l+5OOvwRzc068G510f3rbXT0Jr+tK5IEictFlP0CMEowIXyNmhca+hlqQ26Kd7 Zn1yAKOqxMIOc+D3yvmSbs+m+lLsdRZxXfbaIxvAgzsZkCZHcl48+26KWXFfnM/NkeNz lNrg== X-Gm-Message-State: AIVw110b2BJSdI12geycGP4udv1a0t5ZwviZs+S4YqBC81QjmV0RaxeY JZ7yPuoYCeBZObj3Kqo= X-Received: by 10.28.238.219 with SMTP id j88mr263610wmi.33.1499386200700; Thu, 06 Jul 2017 17:10:00 -0700 (PDT) Received: from bidouze.dev.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id f45sm2391166wrf.2.2017.07.06.17.09.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Jul 2017 17:09:59 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Gaetan Rivet , stable@dpdk.org Date: Fri, 7 Jul 2017 02:09:12 +0200 Message-Id: <1749d93aa8ee84c30fc698fe9f5d33c46ca18e53.1499385282.git.gaetan.rivet@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Subject: [dpdk-dev] [PATCH v6 05/22] pci: use given name as generic name X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The PCI device is referenced by other DPDK systems by the name of its parameter, not by the system name. Fixes: beec692c5157 ("eal: add name field to generic device") Cc: stable@dpdk.org Signed-off-by: Gaetan Rivet --- lib/librte_eal/bsdapp/eal/eal_pci.c | 4 ++-- lib/librte_eal/common/eal_common_pci.c | 21 ++++++++++++++++----- lib/librte_eal/common/eal_private.h | 5 +++++ lib/librte_eal/linuxapp/eal/eal_pci.c | 4 ++-- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c index e321461..97a88ec 100644 --- a/lib/librte_eal/bsdapp/eal/eal_pci.c +++ b/lib/librte_eal/bsdapp/eal/eal_pci.c @@ -282,8 +282,7 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf) /* FreeBSD has no NUMA support (yet) */ dev->device.numa_node = 0; - rte_pci_device_name(&dev->addr, dev->name, sizeof(dev->name)); - dev->device.name = dev->name; + pci_name_set(dev); /* FreeBSD has only one pass through driver */ dev->kdrv = RTE_KDRV_NIC_UIO; @@ -334,6 +333,7 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf) } else { /* already registered */ dev2->kdrv = dev->kdrv; dev2->max_vfs = dev->max_vfs; + pci_name_set(dev2); memmove(dev2->mem_resource, dev->mem_resource, sizeof(dev->mem_resource)); diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c index e03a407..ab01749 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -88,6 +88,21 @@ static struct rte_devargs *pci_devargs_lookup(struct rte_pci_device *dev) return NULL; } +void +pci_name_set(struct rte_pci_device *dev) +{ + struct rte_devargs *devargs; + + rte_pci_device_name(&dev->addr, + dev->name, sizeof(dev->name)); + devargs = pci_devargs_lookup(dev); + dev->device.devargs = devargs; + if (devargs != NULL) + dev->device.name = dev->device.devargs->name; + else + dev->device.name = dev->name; +} + /* map a particular resource from a file */ void * pci_map_resource(void *requested_addr, int fd, off_t offset, size_t size, @@ -396,11 +411,7 @@ rte_pci_probe(void) FOREACH_DEVICE_ON_PCIBUS(dev) { probed++; - /* set devargs in PCI structure */ - devargs = pci_devargs_lookup(dev); - if (devargs != NULL) - dev->device.devargs = devargs; - + devargs = dev->device.devargs; /* probe all or only whitelisted devices */ if (probe_all) ret = pci_probe_all_drivers(dev); diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h index 0836339..597d82e 100644 --- a/lib/librte_eal/common/eal_private.h +++ b/lib/librte_eal/common/eal_private.h @@ -113,6 +113,11 @@ struct rte_pci_driver; struct rte_pci_device; /** + * Find the name of a PCI device. + */ +void pci_name_set(struct rte_pci_device *dev); + +/** * Add a PCI device to the PCI Bus (append to PCI Device list). This function * also updates the bus references of the PCI Device (and the generic device * object embedded within. diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c index 7d9e1a9..556ae2c 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c @@ -324,8 +324,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr) dev->device.numa_node = 0; } - rte_pci_device_name(addr, dev->name, sizeof(dev->name)); - dev->device.name = dev->name; + pci_name_set(dev); /* parse resources */ snprintf(filename, sizeof(filename), "%s/resource", dirname); @@ -373,6 +372,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr) } else { /* already registered */ dev2->kdrv = dev->kdrv; dev2->max_vfs = dev->max_vfs; + pci_name_set(dev2); memmove(dev2->mem_resource, dev->mem_resource, sizeof(dev->mem_resource)); free(dev);