From patchwork Mon Mar 6 09:59:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Blunck X-Patchwork-Id: 21429 X-Patchwork-Delegate: thomas@monjalon.net 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 516705911; Mon, 6 Mar 2017 11:01:01 +0100 (CET) Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by dpdk.org (Postfix) with ESMTP id 23861952 for ; Mon, 6 Mar 2017 11:00:46 +0100 (CET) Received: by mail-wm0-f66.google.com with SMTP id n11so12813934wma.0 for ; Mon, 06 Mar 2017 02:00:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=fI35UllzSus+1Hf0j63VL1LuuSiigqXR7GYhRQPy9NI=; b=PqhPiXT5picRp7cLrKSBLC8qgAUEtQ9v9/ERUm8q2v4Jut7jvSwsYkW1NSNaJ+bP1a ZdFl7egadMbkdt2WFRSS6xkOKBZx+Nu+/lQwCCtqB06U78X4xEYIO4JTct0SAWwoWGcc kt3QOBNiAJGsneMDzGWY1oqiGVsj6oxKD2F+sACPPHYJh2KoTSvyo5y3CN8VNLUoX81w /JXZJAl2MwNen56M6dUN4L8Gni4mKtKTdKgwYhRk0BeT11ijd2TRw1moR/oxfSXRIM4q 4TzaVVIl2dDHCDeRlkA1YmKc0+ZycEYq/9rnaAfX5GWSga3C5yLtlEJOuvORI4KD5MCn GJxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=fI35UllzSus+1Hf0j63VL1LuuSiigqXR7GYhRQPy9NI=; b=Ix94iaRND+nkg88nZp3n563Di6TI1nz0cAwY04BmMljM1dRWrZxLF9VhTntso46M5o pZ3qtkMRn2s9FIUU/qTXG3P6ZRmjFeW2PUONKIqEmKrEcaOqWu9EwjvgAKYQtfu+y39p L+g0yuh9yEo6YgF1uZBIstMhNgm+uxQTgHsSe8f9O4vep3Du+oVQF4DV2vACMQ5H9RaA SFiyEPM6QBj395ioD+WfeS67P1W73OCZjwVFKK5A2TF4N9x1kq0j1bi9NQgXKUIwI9bK uzUNT1S/Kh9oWHYGbasYuK5VTnbQGzQsSS14eGoph/6UDASeKyZIIiA8m61S7Kenseco VKSQ== X-Gm-Message-State: AMke39lojT7sGHF/sZiceif86x0nk1U2+4c691QBsTjCeyX2BKIPjGH2IW/g3ZPkGCIuuw== X-Received: by 10.28.139.195 with SMTP id n186mr11947281wmd.139.1488794445750; Mon, 06 Mar 2017 02:00:45 -0800 (PST) Received: from weierstrass.local.net ([91.200.109.169]) by smtp.gmail.com with ESMTPSA id u145sm3829237wmu.1.2017.03.06.02.00.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Mar 2017 02:00:45 -0800 (PST) From: Jan Blunck To: dev@dpdk.org Date: Mon, 6 Mar 2017 10:59:53 +0100 Message-Id: <1488794430-25179-2-git-send-email-jblunck@infradead.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488794430-25179-1-git-send-email-jblunck@infradead.org> References: <1488794430-25179-1-git-send-email-jblunck@infradead.org> Subject: [dpdk-dev] [PATCH 01/38] eal: add name field to generic device 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" This adds a name field to the generic struct rte_device. The EAL is checking for the name being populated when registering a device but doesn't enforce global unique names as this is left to the bus implementations. Signed-off-by: Jan Blunck --- lib/librte_eal/bsdapp/eal/eal_pci.c | 3 +++ lib/librte_eal/common/eal_common_dev.c | 3 +++ lib/librte_eal/common/eal_common_vdev.c | 2 ++ lib/librte_eal/common/include/rte_dev.h | 1 + lib/librte_eal/common/include/rte_pci.h | 1 + lib/librte_eal/linuxapp/eal/eal_pci.c | 3 +++ 6 files changed, 13 insertions(+) diff --git a/lib/librte_eal/bsdapp/eal/eal_pci.c b/lib/librte_eal/bsdapp/eal/eal_pci.c index 3a5c315..58cdb54 100644 --- a/lib/librte_eal/bsdapp/eal/eal_pci.c +++ b/lib/librte_eal/bsdapp/eal/eal_pci.c @@ -280,6 +280,9 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf) /* FreeBSD has no NUMA support (yet) */ dev->device.numa_node = 0; + rte_eal_pci_device_name(&dev->addr, dev->name, sizeof(dev->name)); + dev->device.name = dev->name; + /* FreeBSD has only one pass through driver */ dev->kdrv = RTE_KDRV_NIC_UIO; diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index 4bde430..12a2286 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -68,6 +68,9 @@ rte_eal_driver_unregister(struct rte_driver *driver) void rte_eal_device_insert(struct rte_device *dev) { + RTE_VERIFY(dev->name); + RTE_VERIFY(dev->name[0] != '\0'); + TAILQ_INSERT_TAIL(&dev_device_list, dev, next); } diff --git a/lib/librte_eal/common/eal_common_vdev.c b/lib/librte_eal/common/eal_common_vdev.c index 22fe2ca..c922297 100644 --- a/lib/librte_eal/common/eal_common_vdev.c +++ b/lib/librte_eal/common/eal_common_vdev.c @@ -180,6 +180,7 @@ rte_eal_vdev_init(const char *name, const char *args) dev->device.devargs = devargs; dev->device.numa_node = SOCKET_ID_ANY; + dev->device.name = devargs->virt.drv_name; ret = vdev_probe_all_drivers(dev); if (ret) { @@ -271,6 +272,7 @@ vdev_scan(void) dev->device.devargs = devargs; dev->device.numa_node = SOCKET_ID_ANY; + dev->device.name = devargs->virt.drv_name; rte_eal_device_insert(&dev->device); TAILQ_INSERT_TAIL(&vdev_device_list, dev, next); diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h index 4251099..67c2b0c 100644 --- a/lib/librte_eal/common/include/rte_dev.h +++ b/lib/librte_eal/common/include/rte_dev.h @@ -122,6 +122,7 @@ struct rte_driver; */ struct rte_device { TAILQ_ENTRY(rte_device) next; /**< Next device */ + const char *name; /**< Device name */ const struct rte_driver *driver;/**< Associated driver */ int numa_node; /**< NUMA node connection */ struct rte_devargs *devargs; /**< Device user arguments */ diff --git a/lib/librte_eal/common/include/rte_pci.h b/lib/librte_eal/common/include/rte_pci.h index 8557e47..a036fe9 100644 --- a/lib/librte_eal/common/include/rte_pci.h +++ b/lib/librte_eal/common/include/rte_pci.h @@ -158,6 +158,7 @@ struct rte_pci_device { struct rte_pci_driver *driver; /**< Associated driver */ uint16_t max_vfs; /**< sriov enable if not zero */ enum rte_kernel_driver kdrv; /**< Kernel driver passthrough */ + char name[PCI_PRI_STR_SIZE+1]; /**< PCI location (ASCII) */ }; /** diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/linuxapp/eal/eal_pci.c index e2fc219..8b131f8 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c @@ -316,6 +316,9 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr) dev->device.numa_node = tmp; } + rte_eal_pci_device_name(addr, dev->name, sizeof(dev->name)); + dev->device.name = dev->name; + /* parse resources */ snprintf(filename, sizeof(filename), "%s/resource", dirname); if (pci_parse_sysfs_resource(filename, dev) < 0) {