From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f177.google.com (mail-wr0-f177.google.com [209.85.128.177]) by dpdk.org (Postfix) with ESMTP id A824A9E3 for ; Tue, 11 Apr 2017 17:45:04 +0200 (CEST) Received: by mail-wr0-f177.google.com with SMTP id z109so706055wrb.1 for ; Tue, 11 Apr 2017 08:45:04 -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=wF8CVR22AwE26U3Z1HPZL9AoVCLGYsgwJ4PtWPN0oUU=; b=NriznLjeiEZhEp9Dmq80gdOOE7aUB2jOftacuP+v2HhdQewNkDs72Iwqm7OXVhwxRj 1Xyi13euMQqXKQE9DufjNAbH8r2rN2D1p2uW9qjbibUqAXNElNc4XnxrfQh+R1b1ShIZ AFWZhbThOPNBwj2w6xl2IDpz4kJDkZ59lbYb9Bw0rRz3gU83UIXyFUJlb1vQotAJJuel wGjraoAIA3TnUWKf/+t6rI8UaOssECexb/krYcTlziVJY3xCV9AdZxEcqYIUw/EG3io+ /NsPskcSu+llILZ1bBTz03gni5/oMfYY/g0RMmfSqA3y959Thtnat1Mczfvv3m9Ww9EM Xj4g== 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=wF8CVR22AwE26U3Z1HPZL9AoVCLGYsgwJ4PtWPN0oUU=; b=Bbc/EHIgE1IkIoF3IbKptD9tTzo2xUxh9J10G4tmwS2bL7XVRBQAIIBK740bBttcDj VFzZOXfSeDIj698kxI3Xx+TZN7pehDwR4M4YPB2es+MBY0+4sqpjfN9cq5WnEQCaRJjL h6UnGuCGRZTSkfJ4d3pDCHHLBl8oJES/5n6IQJSHCscXWklMVo6WPJ7TvK3RImgsonvg KOyFeCj7yEBuWrgDQIfORVhvVFp7rbOEmZ9Y810lSm/AOa6sNKCfcrPED1EnOrb8oeTp IpWUpB8G2lHtqy5bVL+ReYqAdGIGS1xW5jWqJt8OUe4S2z5WL/ir/dJVuwMPI2zNIqam +x2Q== X-Gm-Message-State: AFeK/H1VDmvrmsCxa8U+oGxg/GLmbC3TF6tLnOt4exBkWD2rsXjYvQ48cOcTmmtyfvGG7v/+ X-Received: by 10.223.150.19 with SMTP id b19mr32248852wra.98.1491925504056; Tue, 11 Apr 2017 08:45:04 -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 u63sm2933738wmu.22.2017.04.11.08.45.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 11 Apr 2017 08:45:03 -0700 (PDT) From: Gaetan Rivet To: dev@dpdk.org Cc: Jan Blunck Date: Tue, 11 Apr 2017 17:44:08 +0200 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: <1488794430-25179-1-git-send-email-jblunck@infradead.org> In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 01/42] 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: , X-List-Received-Date: Tue, 11 Apr 2017 15:45:05 -0000 From: Jan Blunck 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 1e9031c..6e289da 100644 --- a/lib/librte_eal/bsdapp/eal/eal_pci.c +++ b/lib/librte_eal/bsdapp/eal/eal_pci.c @@ -282,6 +282,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 01e37c4..badf918 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -70,6 +70,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 de0641a..7ec9980 100644 --- a/lib/librte_eal/common/include/rte_pci.h +++ b/lib/librte_eal/common/include/rte_pci.h @@ -172,6 +172,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 7897e15..ab5f8c6 100644 --- a/lib/librte_eal/linuxapp/eal/eal_pci.c +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c @@ -324,6 +324,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) { -- 2.1.4