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 D74DA1B396 for ; Fri, 28 Sep 2018 18:40:48 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 82D9D21D2E; Fri, 28 Sep 2018 12:40:48 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Fri, 28 Sep 2018 12:40:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to:x-me-sender:x-me-sender :x-sasl-enc; s=mesmtp; bh=sBoS9Q/Q3TTuqrR5vS6xrtcaZTXJcMqLSN3dF9 Ngxig=; b=jZLyARIbWk0h//Ghrd/fMRz2GyF+j8AMS0c7UZdVX3KO94R6mROjxO V3/29rIp3ANCSGEruL03PzR+vOuX+8zHQ4HLcgm2vo32AJSignc4gXErkDH4acNv fkGuvbtvUsps7SlWMVQBFFZ8kaqPowNf6ky4nLGE9Hn+8Y3GLZqWo= 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-sender:x-me-sender:x-sasl-enc; s=fm3; bh=sBoS9Q/Q3TTuqrR5v S6xrtcaZTXJcMqLSN3dF9Ngxig=; b=NYVkZwwKplPc0eCCPU8VEODJNaB+zyUOs 3j8DHm+EEeT22wMoNYh4UE93a+IpjXm7UD3DLPFBg254D4fqCcwB0dDmMSyJOGqU /ZAlhSGxadVLwI6u40zR8AFDbP7FpC7J+AcW0quCLDx29yk5cNNFrubpy6W1KAc0 vylf45S1Av9lUWIoZz3zDW4XowXH1gNOzJkTktUJcji0F9bzwp8BVCnyWUj1nEmw dtom2daHSstTVxCXEJrjJkgdd7MKhZyeBPmsChBt5U0MwRptLh9Qd2GXlD8WQ1Hs GmCPS6TjRKpvigkO5fFR98xrFMqvLV3aqWREZ5X1kJqV/Djv+5UlQ== X-ME-Proxy: X-ME-Sender: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 834F6102DD; Fri, 28 Sep 2018 12:40:47 -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: Fri, 28 Sep 2018 18:40:38 +0200 Message-Id: <20180928164039.2380-3-thomas@monjalon.net> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180928164039.2380-1-thomas@monjalon.net> References: <20180907230958.21402-1-thomas@monjalon.net> <20180928164039.2380-1-thomas@monjalon.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 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: Fri, 28 Sep 2018 16:40:49 -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 a20afb5c7..5ce886d13 100644 --- a/drivers/bus/ifpga/ifpga_bus.c +++ b/drivers/bus/ifpga/ifpga_bus.c @@ -300,7 +300,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) { @@ -324,7 +324,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 a0adc99c8..d95410e19 100644 --- a/drivers/bus/pci/pci_common.c +++ b/drivers/bus/pci/pci_common.c @@ -245,7 +245,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 e7f321706..514d9d5c6 100644 --- a/drivers/bus/vdev/vdev.c +++ b/drivers/bus/vdev/vdev.c @@ -479,7 +479,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 b40e4c0d0..907c5c481 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; @@ -184,7 +191,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 61542c7d1..5b16ee27b 100644 --- a/lib/librte_eal/common/include/rte_dev.h +++ b/lib/librte_eal/common/include/rte_dev.h @@ -161,6 +161,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