From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 7D0C1DE3 for ; Mon, 8 Oct 2018 00:09:39 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 1750221C82; Sun, 7 Oct 2018 18:09:39 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Sun, 07 Oct 2018 18:09:39 -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=jYRjq6K8be LeN2SfZhodDHTibs9T+k1I2lU94hBNDdc=; b=Q0ytgb9/x24ETLNyEIs3jAGQsD qEGhSXO8o7RIBF9JFhJEOVVEMC+paGZ09736OI9Kskh6mYzRHzZCdAZnh1koaAII Ns0tceUF1vsrFLp6YutgVUjQ3VG7jJfdqqR9neq2kw3udTBYqCb3Sg6vkn2Qj+Jb YJe3jP2Mwp8X5neQI= 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=jYRjq6K8beLeN2SfZhodDHTibs9T+k1I2lU94hBNDdc=; b=eAJfyrdJ xspPgNC1E2WDdrKkwe8xtxuElbzPFHMT1O1bA83KYtyjh3GDZBBoupn/jMROadsu BAQ7UvLd/mLObwlwSq3vRZlLlH6ICo6UA/WQituEnJGz+KKjUc0QqH4rcrfPgt6q T3TW2P3+VAwKvqkm5YnkJEOUIPP0r1F8xHEL7S7c0bZsyXfoDwQ7DRHMdPGkWKye 8qes1E84GNvRUvITNcJakMQ5Fjtl7islt4dzFie1/XTTkzxFiTOy6MYJm5eLmOs1 sZjYEv+CY7kCUOctH+EEQfU/iJhSpTFfQURevdLLg4BNFydPDd7eA1/cXYZ8K4QS K5wTcDE1CqlTmw== 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 143BB102E2; Sun, 7 Oct 2018 18:09:37 -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 Date: Mon, 8 Oct 2018 00:09:32 +0200 Message-Id: <20181007220933.4533-3-thomas@monjalon.net> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181007220933.4533-1-thomas@monjalon.net> References: <20180907230958.21402-1-thomas@monjalon.net> <20181007220933.4533-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 2/3] eal: add function to query device status 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: Sun, 07 Oct 2018 22:09:39 -0000 The function rte_dev_is_probed() is added in order to improve semantic and enforce proper check of the probing status of a device. It will answer this rte_device query: Is it already successfully probed or not? Signed-off-by: Thomas Monjalon --- drivers/bus/ifpga/ifpga_bus.c | 4 ++-- drivers/bus/pci/pci_common.c | 2 +- drivers/bus/vdev/vdev.c | 2 +- drivers/bus/vmbus/vmbus_common.c | 2 +- lib/librte_eal/common/eal_common_dev.c | 9 ++++++++- lib/librte_eal/common/include/rte_dev.h | 14 ++++++++++++++ lib/librte_eal/rte_eal_version.map | 1 + 7 files changed, 28 insertions(+), 6 deletions(-) diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c index fca2dbace..2ca1efa72 100644 --- a/drivers/bus/ifpga/ifpga_bus.c +++ b/drivers/bus/ifpga/ifpga_bus.c @@ -301,7 +301,7 @@ ifpga_probe_all_drivers(struct rte_afu_device *afu_dev) return -1; /* Check if a driver is already loaded */ - if (afu_dev->device.driver != NULL) + if (rte_dev_is_probed(&afu_dev->device)) return 0; TAILQ_FOREACH(drv, &ifpga_afu_drv_list, next) { @@ -325,7 +325,7 @@ ifpga_probe(void) int ret = 0; TAILQ_FOREACH(afu_dev, &ifpga_afu_dev_list, next) { - if (afu_dev->device.driver) + if (rte_dev_is_probed(&afu_dev->device)) continue; ret = ifpga_probe_all_drivers(afu_dev); diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c index d63e68045..62b17fba9 100644 --- a/drivers/bus/pci/pci_common.c +++ b/drivers/bus/pci/pci_common.c @@ -243,7 +243,7 @@ pci_probe_all_drivers(struct rte_pci_device *dev) return -1; /* Check if a driver is already loaded */ - if (dev->device.driver != NULL) + if (rte_dev_is_probed(&dev->device)) return 0; FOREACH_DRIVER_ON_PCIBUS(dr) { diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c index 3f27f3510..f666099e6 100644 --- a/drivers/bus/vdev/vdev.c +++ b/drivers/bus/vdev/vdev.c @@ -481,7 +481,7 @@ vdev_probe(void) * we call each driver probe. */ - if (dev->device.driver) + if (rte_dev_is_probed(&dev->device)) continue; if (vdev_probe_all_drivers(dev)) { diff --git a/drivers/bus/vmbus/vmbus_common.c b/drivers/bus/vmbus/vmbus_common.c index de5548aa4..48a219f73 100644 --- a/drivers/bus/vmbus/vmbus_common.c +++ b/drivers/bus/vmbus/vmbus_common.c @@ -143,7 +143,7 @@ vmbus_probe_all_drivers(struct rte_vmbus_device *dev) int rc; /* Check if a driver is already loaded */ - if (dev->device.driver != NULL) { + if (rte_dev_is_probed(&dev->device)) { VMBUS_LOG(DEBUG, "VMBUS driver already loaded"); return 0; } diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index 7663eaa3f..7e8a9b260 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -74,6 +74,13 @@ static int cmp_dev_name(const struct rte_device *dev, const void *_name) return strcmp(dev->name, name); } +int __rte_experimental +rte_dev_is_probed(const struct rte_device *dev) +{ + /* The field driver should be set only when the probe is successful. */ + return dev->driver != NULL; +} + int rte_eal_dev_attach(const char *name, const char *devargs) { struct rte_bus *bus; @@ -189,7 +196,7 @@ rte_dev_probe(const char *devargs) goto err_devarg; } - if (dev->driver != NULL) { + if (rte_dev_is_probed(dev)) { RTE_LOG(ERR, EAL, "Device is already plugged\n"); return -EEXIST; } diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h index 5084c645b..9f169e3b3 100644 --- a/lib/librte_eal/common/include/rte_dev.h +++ b/lib/librte_eal/common/include/rte_dev.h @@ -162,6 +162,20 @@ struct rte_device { struct rte_devargs *devargs; /**< Device user arguments */ }; +/** + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + * + * Query status of a device. + * + * @param dev + * Generic device pointer. + * @return + * (int)true if already probed successfully, 0 otherwise. + */ +__rte_experimental +int rte_dev_is_probed(const struct rte_device *dev); + /** * Attach a device to a registered driver. * diff --git a/lib/librte_eal/rte_eal_version.map b/lib/librte_eal/rte_eal_version.map index 2ea7a870a..dddcb81ea 100644 --- a/lib/librte_eal/rte_eal_version.map +++ b/lib/librte_eal/rte_eal_version.map @@ -279,6 +279,7 @@ EXPERIMENTAL { rte_dev_event_callback_unregister; rte_dev_event_monitor_start; rte_dev_event_monitor_stop; + rte_dev_is_probed; rte_dev_iterator_init; rte_dev_iterator_next; rte_dev_probe; -- 2.19.0