From patchwork Wed Oct 3 23:10:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 46003 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 [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 51F201B439; Thu, 4 Oct 2018 01:11:02 +0200 (CEST) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id D4F6D1B110 for ; Thu, 4 Oct 2018 01:10:57 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 6047C21F21; Wed, 3 Oct 2018 19:10:57 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Wed, 03 Oct 2018 19:10:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=mesmtp; bh=9769F+gWfy uykX6iWuWxs6clyPCdwxMriXkRS1iWswc=; b=CH2Mh9WCwOjl13RzvoddofWykQ 6UZpjA++Blh1pEZvc1XzToEZtRtFOiam5DugWAP9f/LcNG5rREzf/LGe+pTdnV+l VZUkArYaa6oq49kgBsg6r/hLBSPDbBi+oemHStximKFqQKOY5RgjBeQMP2GLWcJm 5kHONxyHdCzseK2fk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=9769F+gWfyuykX6iWuWxs6clyPCdwxMriXkRS1iWswc=; b=fxkZ2PPs 17Wr0HN06VSzl3S7mcoUgoQmW7SXMKXTl86OCTOOpmeZHcfmqLY+Aj9BuIOAI3Fm Xxp2zjaByOVEvjl/fGyTy/tdUkkuO+2TLs76KKuF4sMdxjE0VnkUmPyItOc3dIA0 jqhqJDtuPy3NNFLZghnrZK10oIAu/CN9BLRHBzHIzHS6hT+tnX94cBmtBVy2xlJw 0oRSiVZSxVzuKL0bZXVA16E3XNChYuwADlidHQW3Lx5PaZtvzE8bagk3zesNRgNV ZZVH8o4Nt8gccJh71RNuMF2L9Is/IadlCJbwlGAejwvkWyiJZvxPl8CJhOxo0clq YMOlRGTDS8WwYg== X-ME-Sender: X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 40479102E2; Wed, 3 Oct 2018 19:10:56 -0400 (EDT) From: Thomas Monjalon To: dev@dpdk.org Cc: gaetan.rivet@6wind.com, ophirmu@mellanox.com, qi.z.zhang@intel.com, ferruh.yigit@intel.com, ktraynor@redhat.com Date: Thu, 4 Oct 2018 01:10:44 +0200 Message-Id: <20181003231046.26772-4-thomas@monjalon.net> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181003231046.26772-1-thomas@monjalon.net> References: <20180907222727.20521-1-thomas@monjalon.net> <20181003231046.26772-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v5 3/5] eal: add bus pointer in device structure 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" When a device is added with a devargs (hotplug or whitelist), the bus pointer can be retrieved via its devargs. But there is no such devargs.bus in case of standard scan. A pointer to the rte_bus handle is added to rte_device. When a device is allocated (during a scan), the pointer to its bus is assigned. It will make possible to remove a rte_device, using the function pointer from its bus. The function rte_bus_find_by_device() becomes useless, and may be removed later. Signed-off-by: Thomas Monjalon Acked-by: Gaetan Rivet --- doc/guides/rel_notes/release_18_11.rst | 2 ++ drivers/bus/dpaa/dpaa_bus.c | 2 ++ drivers/bus/fslmc/fslmc_bus.c | 2 ++ drivers/bus/ifpga/ifpga_bus.c | 1 + drivers/bus/pci/bsd/pci.c | 2 ++ drivers/bus/pci/linux/pci.c | 1 + drivers/bus/pci/private.h | 2 ++ drivers/bus/vdev/vdev.c | 1 + drivers/bus/vmbus/linux/vmbus_bus.c | 1 + drivers/bus/vmbus/private.h | 3 +++ lib/librte_eal/common/include/rte_dev.h | 1 + 11 files changed, 18 insertions(+) diff --git a/doc/guides/rel_notes/release_18_11.rst b/doc/guides/rel_notes/release_18_11.rst index d534bb71c..2c6791e5e 100644 --- a/doc/guides/rel_notes/release_18_11.rst +++ b/doc/guides/rel_notes/release_18_11.rst @@ -164,6 +164,8 @@ ABI Changes ``rte_config`` structure on account of improving DPDK usability when using either ``--legacy-mem`` or ``--single-file-segments`` flags. +* eal: The structure ``rte_device`` got a new field to reference a ``rte_bus``. + Removed Items ------------- diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c index 49cd04dbb..138e0f98d 100644 --- a/drivers/bus/dpaa/dpaa_bus.c +++ b/drivers/bus/dpaa/dpaa_bus.c @@ -165,6 +165,8 @@ dpaa_create_device_list(void) goto cleanup; } + dev->device.bus = &rte_dpaa_bus.bus; + cfg = &dpaa_netcfg->port_cfg[i]; fman_intf = cfg->fman_if; diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c index bfe81e236..960f55071 100644 --- a/drivers/bus/fslmc/fslmc_bus.c +++ b/drivers/bus/fslmc/fslmc_bus.c @@ -161,6 +161,8 @@ scan_one_fslmc_device(char *dev_name) return -ENOMEM; } + dev->device.bus = &rte_fslmc_bus.bus; + /* Parse the device name and ID */ t_ptr = strtok(dup_dev_name, "."); if (!t_ptr) { diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c index 3ef035b7e..80663328a 100644 --- a/drivers/bus/ifpga/ifpga_bus.c +++ b/drivers/bus/ifpga/ifpga_bus.c @@ -142,6 +142,7 @@ ifpga_scan_one(struct rte_rawdev *rawdev, if (!afu_dev) goto end; + afu_dev->device.bus = &rte_ifpga_bus; afu_dev->device.devargs = devargs; afu_dev->device.numa_node = SOCKET_ID_ANY; afu_dev->device.name = devargs->name; diff --git a/drivers/bus/pci/bsd/pci.c b/drivers/bus/pci/bsd/pci.c index 655b34b7e..40641cad4 100644 --- a/drivers/bus/pci/bsd/pci.c +++ b/drivers/bus/pci/bsd/pci.c @@ -223,6 +223,8 @@ pci_scan_one(int dev_pci_fd, struct pci_conf *conf) } memset(dev, 0, sizeof(*dev)); + dev->device.bus = &rte_pci_bus.bus; + dev->addr.domain = conf->pc_sel.pc_domain; dev->addr.bus = conf->pc_sel.pc_bus; dev->addr.devid = conf->pc_sel.pc_dev; diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c index 04648ac93..e31bbb370 100644 --- a/drivers/bus/pci/linux/pci.c +++ b/drivers/bus/pci/linux/pci.c @@ -228,6 +228,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr) return -1; memset(dev, 0, sizeof(*dev)); + dev->device.bus = &rte_pci_bus.bus; dev->addr = *addr; /* get vendor id */ diff --git a/drivers/bus/pci/private.h b/drivers/bus/pci/private.h index 0e689fa74..04bffa6e7 100644 --- a/drivers/bus/pci/private.h +++ b/drivers/bus/pci/private.h @@ -15,6 +15,8 @@ extern struct rte_pci_bus rte_pci_bus; struct rte_pci_driver; struct rte_pci_device; +extern struct rte_pci_bus rte_pci_bus; + /** * Probe the PCI bus * diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c index efca962f7..0142fb2c8 100644 --- a/drivers/bus/vdev/vdev.c +++ b/drivers/bus/vdev/vdev.c @@ -456,6 +456,7 @@ vdev_scan(void) continue; } + dev->device.bus = &rte_vdev_bus; dev->device.devargs = devargs; dev->device.numa_node = SOCKET_ID_ANY; dev->device.name = devargs->name; diff --git a/drivers/bus/vmbus/linux/vmbus_bus.c b/drivers/bus/vmbus/linux/vmbus_bus.c index 527a6a39f..a4755a387 100644 --- a/drivers/bus/vmbus/linux/vmbus_bus.c +++ b/drivers/bus/vmbus/linux/vmbus_bus.c @@ -229,6 +229,7 @@ vmbus_scan_one(const char *name) if (dev == NULL) return -1; + dev->device.bus = &rte_vmbus_bus.bus; dev->device.name = strdup(name); if (!dev->device.name) goto error; diff --git a/drivers/bus/vmbus/private.h b/drivers/bus/vmbus/private.h index f2022a68c..211127dd8 100644 --- a/drivers/bus/vmbus/private.h +++ b/drivers/bus/vmbus/private.h @@ -10,11 +10,14 @@ #include #include #include +#include #ifndef PAGE_SIZE #define PAGE_SIZE 4096 #endif +extern struct rte_vmbus_bus rte_vmbus_bus; + extern int vmbus_logtype_bus; #define VMBUS_LOG(level, fmt, args...) \ rte_log(RTE_LOG_ ## level, vmbus_logtype_bus, "%s(): " fmt "\n", \ diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h index b80a80598..d82cba847 100644 --- a/lib/librte_eal/common/include/rte_dev.h +++ b/lib/librte_eal/common/include/rte_dev.h @@ -157,6 +157,7 @@ struct rte_device { TAILQ_ENTRY(rte_device) next; /**< Next device */ const char *name; /**< Device name */ const struct rte_driver *driver;/**< Associated driver */ + const struct rte_bus *bus; /**< Bus handle assigned on scan */ int numa_node; /**< NUMA node connection */ struct rte_devargs *devargs; /**< Device user arguments */ };