From patchwork Sun Oct 14 20:47:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 46792 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 1DB601150; Sun, 14 Oct 2018 22:47:54 +0200 (CEST) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 49F60201 for ; Sun, 14 Oct 2018 22:47:52 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id A249B211B7; Sun, 14 Oct 2018 16:47:51 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 14 Oct 2018 16:47:51 -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=qlnrf6giNP RFHd6sY9GfeIX2RCkc0lCLqYSLv1/iZEI=; b=kYtXw3MGduM022IAYcHv5KGFtz Rha+mej7k8PGYnDtrqnkssDOkXxXGo5nDE7dL/ALSBDUs2KR/F74yuTs+Bc6Svtn EmFvL2L+AFAQQfJhA/342Uu3Nn2FogBo516BHrk+joGQOiie7YCcQt8NcvCv5vdW VD7FTmM5evyLP2ud0= 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= fm1; bh=qlnrf6giNPRFHd6sY9GfeIX2RCkc0lCLqYSLv1/iZEI=; b=ihFjqwck 6ihcDrGkSM55AhUtPFo9WWUt7oAi6WXNwRpAmFwbPUU4pgysPxhYRvBJr245qInq fDyYySH+8zgClsZRizIgOb3tzI2AoB6kBsKM1X7aRp1lC8MAz8izFt4c4WFkIp5S z5B3I++XiQxv3IBMxzC5deKu9dtjoae9TYnEaEu3pAqEsDwBPtu9/qMGG2GLXIp5 wGIccj4ep+mf6Rnp4yTAtwjvd413ZYXmYlPWvk1Vp33VOj2RJckdpZ6j4/rDKaMp l9V8Bphxg22y8GwRp9uigP0FIJye53XzJPcLdDv5KDfC/VfRGzzthJR0PEjJ9wFe BwhxwHYJZo+mhw== 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 94F37E40E6; Sun, 14 Oct 2018 16:47:50 -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: Sun, 14 Oct 2018 22:47:41 +0200 Message-Id: <20181014204747.26621-2-thomas@monjalon.net> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181014204747.26621-1-thomas@monjalon.net> References: <20180907230958.21402-1-thomas@monjalon.net> <20181014204747.26621-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v5 1/7] net/mlx5: remove useless driver name comparison 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" The function mlx5_dev_to_port_id() is returning all the ports associated to a rte_device. It was comparing driver names while already comparing rte_device pointers. If two devices are the same, they will have the same driver. So the useless driver name comparison is removed. Signed-off-by: Thomas Monjalon Acked-By: Shahaf Shuler --- drivers/net/mlx5/mlx5_ethdev.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c index 61eda537b..cacdf8e18 100644 --- a/drivers/net/mlx5/mlx5_ethdev.c +++ b/drivers/net/mlx5/mlx5_ethdev.c @@ -1305,10 +1305,7 @@ mlx5_dev_to_port_id(const struct rte_device *dev, uint16_t *port_list, RTE_ETH_FOREACH_DEV(id) { struct rte_eth_dev *ldev = &rte_eth_devices[id]; - if (!ldev->device || - !ldev->device->driver || - strcmp(ldev->device->driver->name, MLX5_DRIVER_NAME) || - ldev->device != dev) + if (ldev->device != dev) continue; if (n < port_list_n) port_list[n] = id; From patchwork Sun Oct 14 20:47:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 46794 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 DBA512E8F; Sun, 14 Oct 2018 22:47:57 +0200 (CEST) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 0210B201 for ; Sun, 14 Oct 2018 22:47:53 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 95046215B2; Sun, 14 Oct 2018 16:47:52 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 14 Oct 2018 16:47:52 -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=4E9/oei6RM 0kZ8W9GfVDh8sC8elmUxUgHjAehQDRL3c=; b=B/QDIddHYRHGxh34qcdy9SkSF8 e6Oa7lFJy5ncMS1D6Z6aGAxSF3I+MlkQQO/JfiuFBtQzHAT5+gZpEok6h1/aQRPe vTU3h0N9T71X+0Ww6HMqWbLAC+XGA+P63LBMZgNJkGUxUZ0sP1QLE5Hw7SHem3HW HRe5b4HgXQrkHGd1A= 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= fm1; bh=4E9/oei6RM0kZ8W9GfVDh8sC8elmUxUgHjAehQDRL3c=; b=v71spTyR 0NA/EHBLYcwXxUYrobXftJYSvrFZqZfKusix9SSk2jXR9Q8TQmu2VlEDjmPjHxtN t1J0jq2O2SEq8dNBN+3xxR5DpCf2hk1xHXCiIwohVAUXbSwv6SNh0M8P8DcPrpTx Bctw4F9KILdM7FlYrWjFgB1z9xVCB1JR1LoFPaFW12bMZcp4L6MZv1tAO4HsU/Si mg+K0veH+5Lz29TB9DyI/H0E/avHTV5GEXZwmjZkaaXyUtzoeRoDWuYnB1Yzc1mf F/GosGo8lLk6FytrLEwA0EfiK0O5nUxPE9UKNHfc6p8HiZKvBteNsl2FAHQwUhYM lq0RxrBQWpHcOw== 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 7262EE482E; Sun, 14 Oct 2018 16:47:51 -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: Sun, 14 Oct 2018 22:47:42 +0200 Message-Id: <20181014204747.26621-3-thomas@monjalon.net> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181014204747.26621-1-thomas@monjalon.net> References: <20180907230958.21402-1-thomas@monjalon.net> <20181014204747.26621-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v5 2/7] ethdev: rename memzones allocated for DMA 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" The helper rte_eth_dma_zone_reserve() is called by PMDs when probing a new port. It creates a new memzone with an unique name. The name of this memzone was using the name of the driver doing the probe. In order to avoid assigning the driver before the end of the probing, the driver name is removed from these memzone names. The ethdev name (data->name) is not used because it may be too long and may be not set at this stage of probing. Syntax of old name: ___ Syntax of new name: eth_p_q_ Signed-off-by: Thomas Monjalon Tested-by: Andrew Rybchenko --- app/test-pmd/config.c | 4 ++-- drivers/net/bnx2x/bnx2x_rxtx.c | 15 ++------------- drivers/net/cxgbe/sge.c | 24 ++++++++++-------------- drivers/net/vmxnet3/vmxnet3_ethdev.c | 4 ++-- lib/librte_ethdev/rte_ethdev.c | 5 ++--- 5 files changed, 18 insertions(+), 34 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index bf3cd0a8c..a6db5df0c 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1479,8 +1479,8 @@ ring_dma_zone_lookup(const char *ring_name, portid_t port_id, uint16_t q_id) char mz_name[RTE_MEMZONE_NAMESIZE]; const struct rte_memzone *mz; - snprintf(mz_name, sizeof(mz_name), "%s_%s_%d_%d", - ports[port_id].dev_info.driver_name, ring_name, port_id, q_id); + snprintf(mz_name, sizeof(mz_name), "eth_p%d_q%d_%s", + port_id, q_id, ring_name); mz = rte_memzone_lookup(mz_name); if (mz == NULL) printf("%s ring memory zoneof (port %d, queue %d) not" diff --git a/drivers/net/bnx2x/bnx2x_rxtx.c b/drivers/net/bnx2x/bnx2x_rxtx.c index 589735ecd..ca28aaccf 100644 --- a/drivers/net/bnx2x/bnx2x_rxtx.c +++ b/drivers/net/bnx2x/bnx2x_rxtx.c @@ -12,19 +12,8 @@ static const struct rte_memzone * ring_dma_zone_reserve(struct rte_eth_dev *dev, const char *ring_name, uint16_t queue_id, uint32_t ring_size, int socket_id) { - char z_name[RTE_MEMZONE_NAMESIZE]; - const struct rte_memzone *mz; - - snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d", - dev->device->driver->name, ring_name, - dev->data->port_id, queue_id); - - mz = rte_memzone_lookup(z_name); - if (mz) - return mz; - - return rte_memzone_reserve_aligned(z_name, ring_size, socket_id, - RTE_MEMZONE_IOVA_CONTIG, BNX2X_PAGE_SIZE); + return rte_eth_dma_zone_reserve(dev, ring_name, queue_id, + ring_size, BNX2X_PAGE_SIZE, socket_id); } static void diff --git a/drivers/net/cxgbe/sge.c b/drivers/net/cxgbe/sge.c index 4ea40d191..f9d2d48a0 100644 --- a/drivers/net/cxgbe/sge.c +++ b/drivers/net/cxgbe/sge.c @@ -1873,10 +1873,9 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq, /* Size needs to be multiple of 16, including status entry. */ iq->size = cxgbe_roundup(iq->size, 16); - snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d", - eth_dev->device->driver->name, - fwevtq ? "fwq_ring" : "rx_ring", - eth_dev->data->port_id, queue_id); + snprintf(z_name, sizeof(z_name), "eth_p%d_q%d_%s", + eth_dev->data->port_id, queue_id, + fwevtq ? "fwq_ring" : "rx_ring"); snprintf(z_name_sw, sizeof(z_name_sw), "%s_sw_ring", z_name); iq->desc = alloc_ring(iq->size, iq->iqe_len, 0, &iq->phys_addr, NULL, 0, @@ -1938,10 +1937,9 @@ int t4_sge_alloc_rxq(struct adapter *adap, struct sge_rspq *iq, bool fwevtq, fl->size = s->fl_starve_thres - 1 + 2 * 8; fl->size = cxgbe_roundup(fl->size, 8); - snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d", - eth_dev->device->driver->name, - fwevtq ? "fwq_ring" : "fl_ring", - eth_dev->data->port_id, queue_id); + snprintf(z_name, sizeof(z_name), "eth_p%d_q%d_%s", + eth_dev->data->port_id, queue_id, + fwevtq ? "fwq_ring" : "fl_ring"); snprintf(z_name_sw, sizeof(z_name_sw), "%s_sw_ring", z_name); fl->desc = alloc_ring(fl->size, sizeof(__be64), @@ -2144,9 +2142,8 @@ int t4_sge_alloc_eth_txq(struct adapter *adap, struct sge_eth_txq *txq, /* Add status entries */ nentries = txq->q.size + s->stat_len / sizeof(struct tx_desc); - snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d", - eth_dev->device->driver->name, "tx_ring", - eth_dev->data->port_id, queue_id); + snprintf(z_name, sizeof(z_name), "eth_p%d_q%d_%s", + eth_dev->data->port_id, queue_id, "tx_ring"); snprintf(z_name_sw, sizeof(z_name_sw), "%s_sw_ring", z_name); txq->q.desc = alloc_ring(txq->q.size, sizeof(struct tx_desc), @@ -2223,9 +2220,8 @@ int t4_sge_alloc_ctrl_txq(struct adapter *adap, struct sge_ctrl_txq *txq, /* Add status entries */ nentries = txq->q.size + s->stat_len / sizeof(struct tx_desc); - snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d", - eth_dev->device->driver->name, "ctrl_tx_ring", - eth_dev->data->port_id, queue_id); + snprintf(z_name, sizeof(z_name), "eth_p%d_q%d_%s", + eth_dev->data->port_id, queue_id, "ctrl_tx_ring"); snprintf(z_name_sw, sizeof(z_name_sw), "%s_sw_ring", z_name); txq->q.desc = alloc_ring(txq->q.size, sizeof(struct tx_desc), diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c index e41fa499b..78e5b7680 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethdev.c +++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c @@ -161,8 +161,8 @@ gpa_zone_reserve(struct rte_eth_dev *dev, uint32_t size, char z_name[RTE_MEMZONE_NAMESIZE]; const struct rte_memzone *mz; - snprintf(z_name, sizeof(z_name), "%s_%d_%s", - dev->device->driver->name, dev->data->port_id, post_string); + snprintf(z_name, sizeof(z_name), "eth_p%d_%s", + dev->data->port_id, post_string); mz = rte_memzone_lookup(z_name); if (!reuse) { diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 21f1dfbe4..14fc7e328 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -3481,9 +3481,8 @@ rte_eth_dma_zone_reserve(const struct rte_eth_dev *dev, const char *ring_name, char z_name[RTE_MEMZONE_NAMESIZE]; const struct rte_memzone *mz; - snprintf(z_name, sizeof(z_name), "%s_%s_%d_%d", - dev->device->driver->name, ring_name, - dev->data->port_id, queue_id); + snprintf(z_name, sizeof(z_name), "eth_p%d_q%d_%s", + dev->data->port_id, queue_id, ring_name); mz = rte_memzone_lookup(z_name); if (mz) From patchwork Sun Oct 14 20:47:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 46795 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 EC7CA4C80; Sun, 14 Oct 2018 22:47:59 +0200 (CEST) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id B36A8201 for ; Sun, 14 Oct 2018 22:47:53 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 613B3217DD; Sun, 14 Oct 2018 16:47:53 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 14 Oct 2018 16:47:53 -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=6mffvm0zJl BMQxqr5VLR7b2ZioBabdrIOCy1zSzyq50=; b=W0tcDN6qrqx2U7jR526ajUW9mV nk30mTwqsEydGHvXVAc69uK/g4i/KFWxmmUkB2P6HLNPY+h2nM2jGi4ZtXOFRUE8 c7M8hSZJGqSW9/Xhw4IJEQR1dfffr0f1fXJDmKq1BUKGpliawXYQr7KQhG6AavgV NVMNX4yrYW1kO4xKY= 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= fm1; bh=6mffvm0zJlBMQxqr5VLR7b2ZioBabdrIOCy1zSzyq50=; b=CY9nx/1y B48oJ4NJtS+myhkSNpgrC3rjy0xeDoWWhPdrgLDR5R5iqlWilbmzdKPTjof47kPa HUmAgsD2fjoOSx1c36/2SID7rOhD4a3/nxRjaFLfzzmLKEgUub3T+FTCz1Gd+jC8 iF/ZuwmjGK18/48QIZCOfh7VEeLyZbfTSuLMDAxCed2Mv/kZE/hbsgN1q2OLZWn2 VD9TGc2qpOKaL45DU1VnAV+KJ0AGJTtpQqIFvijx9/mqmkd5U7xONPab8bGIkXgq VigJUNAVmzkYaV2nlaRIyq5mXi0uzRoGsp9mBl69gtJjwHn7Ue4P7eGBeHzpatQt oo7uYBTmaz1B5A== 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 581F1E455C; Sun, 14 Oct 2018 16:47:52 -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: Sun, 14 Oct 2018 22:47:43 +0200 Message-Id: <20181014204747.26621-4-thomas@monjalon.net> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181014204747.26621-1-thomas@monjalon.net> References: <20180907230958.21402-1-thomas@monjalon.net> <20181014204747.26621-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v5 3/7] cryptodev: remove driver name from logs 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" The logs printed by CDEV_LOG_* were prefixed with the driver name. In order to avoid assigning the driver before the end of the probing, the driver name is removed from the cryptodev library logs. Signed-off-by: Thomas Monjalon --- lib/librte_cryptodev/rte_cryptodev_pmd.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.c b/lib/librte_cryptodev/rte_cryptodev_pmd.c index 2088ac3f3..f03bdbd5e 100644 --- a/lib/librte_cryptodev/rte_cryptodev_pmd.c +++ b/lib/librte_cryptodev/rte_cryptodev_pmd.c @@ -93,24 +93,20 @@ rte_cryptodev_pmd_create(const char *name, struct rte_cryptodev *cryptodev; if (params->name[0] != '\0') { - CDEV_LOG_INFO("[%s] User specified device name = %s\n", - device->driver->name, params->name); + CDEV_LOG_INFO("User specified device name = %s\n", params->name); name = params->name; } - CDEV_LOG_INFO("[%s] - Creating cryptodev %s\n", - device->driver->name, name); + CDEV_LOG_INFO("Creating cryptodev %s\n", name); - CDEV_LOG_INFO("[%s] - Initialisation parameters - name: %s," + CDEV_LOG_INFO("Initialisation parameters - name: %s," "socket id: %d, max queue pairs: %u", - device->driver->name, name, - params->socket_id, params->max_nb_queue_pairs); + name, params->socket_id, params->max_nb_queue_pairs); /* allocate device structure */ cryptodev = rte_cryptodev_pmd_allocate(name, params->socket_id); if (cryptodev == NULL) { - CDEV_LOG_ERR("[%s] Failed to allocate crypto device for %s", - device->driver->name, name); + CDEV_LOG_ERR("Failed to allocate crypto device for %s", name); return NULL; } @@ -123,9 +119,8 @@ rte_cryptodev_pmd_create(const char *name, params->socket_id); if (cryptodev->data->dev_private == NULL) { - CDEV_LOG_ERR("[%s] Cannot allocate memory for " - "cryptodev %s private data", - device->driver->name, name); + CDEV_LOG_ERR("Cannot allocate memory for cryptodev %s" + " private data", name); rte_cryptodev_pmd_release_device(cryptodev); return NULL; @@ -145,9 +140,7 @@ rte_cryptodev_pmd_destroy(struct rte_cryptodev *cryptodev) { int retval; - CDEV_LOG_INFO("[%s] Closing crypto device %s", - cryptodev->device->driver->name, - cryptodev->device->name); + CDEV_LOG_INFO("Closing crypto device %s", cryptodev->device->name); /* free crypto device */ retval = rte_cryptodev_pmd_release_device(cryptodev); From patchwork Sun Oct 14 20:47: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: 46796 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 C530D4C9D; Sun, 14 Oct 2018 22:48:01 +0200 (CEST) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 87A991E25 for ; Sun, 14 Oct 2018 22:47:54 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 3574521ABB; Sun, 14 Oct 2018 16:47:54 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 14 Oct 2018 16:47:54 -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=O43yuK8BUF 5Fc2q4ik2ie0yzNRcx2igasn1sj/eSRmg=; b=HEoqIkL3dGqJlde/Di0cVQLjSk wnVxCLKM2E+Bv9CJhuCYj8llg+sHjMQY9pwrAS7pPZHvfUmts1g7wXDEeMpqPt3E 6vcW9KcCrURrASJIgyCFiuDfWH6b/F8vo3GVvUjeOHjSvl6coEyZgqKf3Z2wGRFQ dUIdxcEZt+L4Nys9s= 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= fm1; bh=O43yuK8BUF5Fc2q4ik2ie0yzNRcx2igasn1sj/eSRmg=; b=g/EF3/xM amUkBLRUNSeNMP36+ul7qkmR1YczqcIAPDWIq6KelehkcVp27E9DTKv1fxj4ys1J ZWA6y2Lpq9zLuBQ5GDbFtQAGhKaBKgpPK0MubGcOXxRFRtaEY5oGNJPYdIO7WzYP 8gujbmvYj6+PhykfQaVDZNIWd8wnDtfOFzXBC+NGFkxQcKkKzI73GDmcdq6AHwy+ S5xxsgq3+E3bkUTBLgRkDMgnHRq5iqZ1XoYbVvnOKM/ZfGZDp88gEI7yEIe7Ib1c /dLSqEDgaIYMzpUWETYPOYeGEYSCR73V1K8oQHtL+BhfeOp3bQCWQng9xlDUtvyd au6cYPvt48RW6w== 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 32CAFE47E1; Sun, 14 Oct 2018 16:47:53 -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: Sun, 14 Oct 2018 22:47:44 +0200 Message-Id: <20181014204747.26621-5-thomas@monjalon.net> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181014204747.26621-1-thomas@monjalon.net> References: <20180907230958.21402-1-thomas@monjalon.net> <20181014204747.26621-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v5 4/7] compressdev: remove driver name from logs 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" The logs printed by COMPRESSDEV_LOG were prefixed with the driver name. In order to avoid assigning the driver before the end of the probing, the driver name is removed from the compressdev library logs. Signed-off-by: Thomas Monjalon --- lib/librte_compressdev/rte_compressdev_pmd.c | 23 ++++++++------------ 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/lib/librte_compressdev/rte_compressdev_pmd.c b/lib/librte_compressdev/rte_compressdev_pmd.c index 7de4f339e..95beb26ab 100644 --- a/lib/librte_compressdev/rte_compressdev_pmd.c +++ b/lib/librte_compressdev/rte_compressdev_pmd.c @@ -92,24 +92,20 @@ rte_compressdev_pmd_create(const char *name, struct rte_compressdev *compressdev; if (params->name[0] != '\0') { - COMPRESSDEV_LOG(INFO, "[%s] User specified device name = %s\n", - device->driver->name, params->name); + COMPRESSDEV_LOG(INFO, "User specified device name = %s\n", + params->name); name = params->name; } - COMPRESSDEV_LOG(INFO, "[%s] - Creating compressdev %s\n", - device->driver->name, name); + COMPRESSDEV_LOG(INFO, "Creating compressdev %s\n", name); - COMPRESSDEV_LOG(INFO, - "[%s] - Init parameters - name: %s, socket id: %d", - device->driver->name, name, - params->socket_id); + COMPRESSDEV_LOG(INFO, "Init parameters - name: %s, socket id: %d", + name, params->socket_id); /* allocate device structure */ compressdev = rte_compressdev_pmd_allocate(name, params->socket_id); if (compressdev == NULL) { - COMPRESSDEV_LOG(ERR, "[%s] Failed to allocate comp device %s", - device->driver->name, name); + COMPRESSDEV_LOG(ERR, "Failed to allocate comp device %s", name); return NULL; } @@ -123,8 +119,8 @@ rte_compressdev_pmd_create(const char *name, if (compressdev->data->dev_private == NULL) { COMPRESSDEV_LOG(ERR, - "[%s] Cannot allocate memory for compressdev %s private data", - device->driver->name, name); + "Cannot allocate memory for compressdev" + " %s private data", name); rte_compressdev_pmd_release_device(compressdev); return NULL; @@ -141,8 +137,7 @@ rte_compressdev_pmd_destroy(struct rte_compressdev *compressdev) { int retval; - COMPRESSDEV_LOG(INFO, "[%s] Closing comp device %s", - compressdev->device->driver->name, + COMPRESSDEV_LOG(INFO, "Closing comp device %s", compressdev->device->name); /* free comp device */ From patchwork Sun Oct 14 20:47:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 46797 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 B38074CA6; Sun, 14 Oct 2018 22:48:03 +0200 (CEST) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 73C612BAC for ; Sun, 14 Oct 2018 22:47:55 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 203AD21ADD; Sun, 14 Oct 2018 16:47:55 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 14 Oct 2018 16:47:55 -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=EbmTYRwPgw 4C4zVggYa821/qZ2Gu894djb1WgEPjkuQ=; b=nvxbp5EfwrYd0mikvGlU13rDos DnRuFoqQy3EBmkCfQ8f39MpojE7XM3Vz+g2HjE2FpkHH2guhqwpA8KwTf2dXM1fj dUD0UAAEMS2YaWzezrLUlYAbq6ZLWbqJ6FhUBwJ/WsPFcCP4bwTuPjP5eYqDTBX3 k+QNRYK4avP73hOvY= 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= fm1; bh=EbmTYRwPgw4C4zVggYa821/qZ2Gu894djb1WgEPjkuQ=; b=ogW4bfln 0sE7y95uJAX1PaKgOAYDs/a7TklLAWJJYL9iAJaotykzXCSM3ugImdt4JlyUMQ/4 FbT0KMGgBVhpQgdgOuL+5D2sNsgfn45zYGyEZqg/pv6ov3YPlB+khcOEDnhhk8Py xTr8awrlY8zMbf9nl2lK5/gUZeBBwGIpn2XhiS8EmxvoM4SLEdKYQMEsxd1/neQt 5lNxFnXWtYvXEQT/7IbCPsdvv6Mk7+fusw4rsO4R0lXlnNW9OJDnFMZzP3F4sDRy A2w6sDNDlW+H26Cknr2QIbqC154LYqxQCQ/3HSjo4MwKuFveeXHO7K1VD6xC+iau DxbHN+z7cc1N9Q== 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 0CC7EE455C; Sun, 14 Oct 2018 16:47:53 -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: Sun, 14 Oct 2018 22:47:45 +0200 Message-Id: <20181014204747.26621-6-thomas@monjalon.net> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181014204747.26621-1-thomas@monjalon.net> References: <20180907230958.21402-1-thomas@monjalon.net> <20181014204747.26621-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v5 5/7] drivers/bus: move driver assignment to end of probing 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" The PCI mapping requires to know the PCI driver to use, even before the probing is done. That's why the PCI driver is referenced early inside the PCI device structure. See commit 1d20a073fa5e ("bus/pci: reference driver structure before mapping") However the rte_driver does not need to be referenced in rte_device before the device probing is done. By moving back this assignment at the end of the device probing, it becomes possible to make clear the status of a rte_device. Signed-off-by: Thomas Monjalon Reviewed-by: Andrew Rybchenko Tested-by: Andrew Rybchenko --- drivers/bus/ifpga/ifpga_bus.c | 9 ++++----- drivers/bus/pci/pci_common.c | 7 +++---- drivers/bus/pci/rte_bus_pci.h | 2 +- drivers/bus/vdev/vdev.c | 5 ++--- drivers/bus/vmbus/vmbus_common.c | 5 +++-- drivers/net/i40e/i40e_vf_representor.c | 3 --- drivers/net/mlx4/mlx4.c | 1 - drivers/net/mlx5/mlx5.c | 1 - drivers/net/szedata2/rte_eth_szedata2.c | 6 +++--- lib/librte_eal/common/include/rte_dev.h | 2 +- 10 files changed, 17 insertions(+), 24 deletions(-) diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c index 80663328a..fca2dbace 100644 --- a/drivers/bus/ifpga/ifpga_bus.c +++ b/drivers/bus/ifpga/ifpga_bus.c @@ -280,14 +280,13 @@ ifpga_probe_one_driver(struct rte_afu_driver *drv, /* reference driver structure */ afu_dev->driver = drv; - afu_dev->device.driver = &drv->driver; /* call the driver probe() function */ ret = drv->probe(afu_dev); - if (ret) { + if (ret) afu_dev->driver = NULL; - afu_dev->device.driver = NULL; - } + else + afu_dev->device.driver = &drv->driver; return ret; } @@ -302,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->driver != NULL) + if (afu_dev->device.driver != NULL) return 0; TAILQ_FOREACH(drv, &ifpga_afu_drv_list, next) { diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c index c7695d108..d63e68045 100644 --- a/drivers/bus/pci/pci_common.c +++ b/drivers/bus/pci/pci_common.c @@ -160,14 +160,12 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, * driver flags for adjusting configuration. */ dev->driver = dr; - dev->device.driver = &dr->driver; if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) { /* map resources for devices that use igb_uio */ ret = rte_pci_map_device(dev); if (ret != 0) { dev->driver = NULL; - dev->device.driver = NULL; return ret; } } @@ -176,7 +174,6 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, ret = dr->probe(dr, dev); if (ret) { dev->driver = NULL; - dev->device.driver = NULL; if ((dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) && /* Don't unmap if device is unsupported and * driver needs mapped resources. @@ -184,6 +181,8 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, !(ret > 0 && (dr->drv_flags & RTE_PCI_DRV_KEEP_MAPPED_RES))) rte_pci_unmap_device(dev); + } else { + dev->device.driver = &dr->driver; } return ret; @@ -244,7 +243,7 @@ pci_probe_all_drivers(struct rte_pci_device *dev) return -1; /* Check if a driver is already loaded */ - if (dev->driver != NULL) + if (dev->device.driver != NULL) return 0; FOREACH_DRIVER_ON_PCIBUS(dr) { diff --git a/drivers/bus/pci/rte_bus_pci.h b/drivers/bus/pci/rte_bus_pci.h index 0d1955ffe..984df2b37 100644 --- a/drivers/bus/pci/rte_bus_pci.h +++ b/drivers/bus/pci/rte_bus_pci.h @@ -62,7 +62,7 @@ struct rte_pci_device { struct rte_mem_resource mem_resource[PCI_MAX_RESOURCE]; /**< PCI Memory Resource */ struct rte_intr_handle intr_handle; /**< Interrupt handle */ - struct rte_pci_driver *driver; /**< Associated driver */ + struct rte_pci_driver *driver; /**< PCI driver used in probing */ 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/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c index 0142fb2c8..3f27f3510 100644 --- a/drivers/bus/vdev/vdev.c +++ b/drivers/bus/vdev/vdev.c @@ -150,10 +150,9 @@ vdev_probe_all_drivers(struct rte_vdev_device *dev) if (vdev_parse(name, &driver)) return -1; - dev->device.driver = &driver->driver; ret = driver->probe(dev); - if (ret) - dev->device.driver = NULL; + if (ret == 0) + dev->device.driver = &driver->driver; return ret; } diff --git a/drivers/bus/vmbus/vmbus_common.c b/drivers/bus/vmbus/vmbus_common.c index e3ceb6906..de5548aa4 100644 --- a/drivers/bus/vmbus/vmbus_common.c +++ b/drivers/bus/vmbus/vmbus_common.c @@ -111,7 +111,6 @@ vmbus_probe_one_driver(struct rte_vmbus_driver *dr, /* reference driver structure */ dev->driver = dr; - dev->device.driver = &dr->driver; if (dev->device.numa_node < 0) { VMBUS_LOG(WARNING, " Invalid NUMA socket, default to 0"); @@ -124,6 +123,8 @@ vmbus_probe_one_driver(struct rte_vmbus_driver *dr, if (ret) { dev->driver = NULL; rte_vmbus_unmap_device(dev); + } else { + dev->device.driver = &dr->driver; } return ret; @@ -142,7 +143,7 @@ vmbus_probe_all_drivers(struct rte_vmbus_device *dev) int rc; /* Check if a driver is already loaded */ - if (dev->driver != NULL) { + if (dev->device.driver != NULL) { VMBUS_LOG(DEBUG, "VMBUS driver already loaded"); return 0; } diff --git a/drivers/net/i40e/i40e_vf_representor.c b/drivers/net/i40e/i40e_vf_representor.c index 0bfbb4f60..24751d13c 100644 --- a/drivers/net/i40e/i40e_vf_representor.c +++ b/drivers/net/i40e/i40e_vf_representor.c @@ -487,9 +487,6 @@ i40e_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params) if (representor->vf_id >= pf->vf_num) return -ENODEV; - /** representor shares the same driver as it's PF device */ - ethdev->device->driver = representor->adapter->eth_dev->device->driver; - /* Set representor device ops */ ethdev->dev_ops = &i40e_representor_dev_ops; diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index defc0d4b0..3de7bc53e 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -734,7 +734,6 @@ mlx4_pci_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) eth_dev->data->mac_addrs = priv->mac; eth_dev->device = &pci_dev->device; rte_eth_copy_pci_info(eth_dev, pci_dev); - eth_dev->device->driver = &mlx4_driver.driver; /* Initialize local interrupt handle for current port. */ priv->intr_handle = (struct rte_intr_handle){ .fd = -1, diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 795a21977..8cbfee1ba 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1090,7 +1090,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, priv->dev_data = eth_dev->data; eth_dev->data->mac_addrs = priv->mac; eth_dev->device = dpdk_dev; - eth_dev->device->driver = &mlx5_driver.driver; err = mlx5_uar_init_primary(eth_dev); if (err) { err = rte_errno; diff --git a/drivers/net/szedata2/rte_eth_szedata2.c b/drivers/net/szedata2/rte_eth_szedata2.c index 8f92e72f2..4e5e01cf1 100644 --- a/drivers/net/szedata2/rte_eth_szedata2.c +++ b/drivers/net/szedata2/rte_eth_szedata2.c @@ -1474,7 +1474,7 @@ rte_szedata2_eth_dev_init(struct rte_eth_dev *dev, struct port_info *pi) PMD_INIT_FUNC_TRACE(); PMD_INIT_LOG(INFO, "Initializing eth_dev %s (driver %s)", data->name, - dev->device->driver->name); + RTE_STR(RTE_SZEDATA2_DRIVER_NAME)); /* Fill internal private structure. */ internals->dev = dev; @@ -1525,7 +1525,7 @@ rte_szedata2_eth_dev_init(struct rte_eth_dev *dev, struct port_info *pi) ether_addr_copy(ð_addr, data->mac_addrs); PMD_INIT_LOG(INFO, "%s device %s successfully initialized", - dev->device->driver->name, data->name); + RTE_STR(RTE_SZEDATA2_DRIVER_NAME), data->name); return 0; } @@ -1547,7 +1547,7 @@ rte_szedata2_eth_dev_uninit(struct rte_eth_dev *dev) rte_free(dev->data->mac_addrs); PMD_DRV_LOG(INFO, "%s device %s successfully uninitialized", - dev->device->driver->name, dev->data->name); + RTE_STR(RTE_SZEDATA2_DRIVER_NAME), dev->data->name); return 0; } diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h index 036180ff3..5084c645b 100644 --- a/lib/librte_eal/common/include/rte_dev.h +++ b/lib/librte_eal/common/include/rte_dev.h @@ -156,7 +156,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 */ + const struct rte_driver *driver; /**< Driver assigned after probing */ const struct rte_bus *bus; /**< Bus handle assigned on scan */ int numa_node; /**< NUMA node connection */ struct rte_devargs *devargs; /**< Device user arguments */ From patchwork Sun Oct 14 20:47:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 46798 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 9E6BE4CBD; Sun, 14 Oct 2018 22:48:05 +0200 (CEST) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 3F81D2BAC for ; Sun, 14 Oct 2018 22:47:56 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id D9DCF211B7; Sun, 14 Oct 2018 16:47:55 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 14 Oct 2018 16:47:55 -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=pS95yYSG/F b0kHXqUvWX39UMZqRReRgTyd6nnjm9M5c=; b=kDpZWLF3dpUXlienYBSyspKzac p7VYvv5LkNf12wmwKjwiaHFn+7gWaYvzH5hxgUEuZ3lIpNA07+2EYp5PMaWebflD emOXrV+HCGrvn+oLrhLZh6zcgYteCtSvUu3cvTk5/fKYnYYoYCnfxMAPWBVP/Hb/ FBz9sEmJBT9jiyjX4= 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= fm1; bh=pS95yYSG/Fb0kHXqUvWX39UMZqRReRgTyd6nnjm9M5c=; b=jLbYCyAt dxwItpnqPuukGVsdVSA0fdscPDlTw4w1qZL7Zgnk/BIMnxwiyO0X/uFJIrLPoHC/ 1TnxeFBcsr8wbMNgD7SJWLtCYYEkcjylMZvtYbYBTmaqY9aPJFf+kHDjFM95W0t7 7Fs1s07y4qkcCY5dP0mEO+GWSO04gw3dDGpspRgVhAQTKNHlZsvq78MqFUb+ti2g pAog9U0Zawri0IPrz+k4BJKeQrtX2N154WWu8q+d/v75N1BIiFIre9v9n7LR+wcH Bo7+gkqLQe2LCFLJxthNZpIxB+Ny5dhYHYztkXOyBOdQFeAOdNABeWO5PgHHvwsS o0AnJrLbbtdT4Q== 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 E1A13E47E1; Sun, 14 Oct 2018 16:47:54 -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: Sun, 14 Oct 2018 22:47:46 +0200 Message-Id: <20181014204747.26621-7-thomas@monjalon.net> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181014204747.26621-1-thomas@monjalon.net> References: <20180907230958.21402-1-thomas@monjalon.net> <20181014204747.26621-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v5 6/7] 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 Reviewed-by: Andrew Rybchenko Tested-by: Andrew Rybchenko --- 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 e968edc2e..e628c3930 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; From patchwork Sun Oct 14 20:47:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 46799 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 5F82B4F9B; Sun, 14 Oct 2018 22:48:07 +0200 (CEST) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by dpdk.org (Postfix) with ESMTP id 1DB222C28 for ; Sun, 14 Oct 2018 22:47:57 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id BE55121921; Sun, 14 Oct 2018 16:47:56 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sun, 14 Oct 2018 16:47:56 -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=/9G1aB9/LE 2sBNVwnAmqFPIl9JUStqnJoEHoBJYcaHY=; b=r5lMAbV0/b4KXlp8keasxNYZED SUMtHFfcu45BX3NISv/WyXvcLsRyMi5xbyfEZNhxT7WbKdduInKSVO3BqWDdOvSW iwvqRw8ig879oqMtfAvHyJKEshZpwp01KVsaG/CkHEMDeFyPznX6uo5pr8i/nL0o ywJf4wksyK+3bjSeM= 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= fm1; bh=/9G1aB9/LE2sBNVwnAmqFPIl9JUStqnJoEHoBJYcaHY=; b=BsDTUFHb M9DXy0VPjHsq4a3xWrE+TrU/nz2OPSt8DjtpC38eYxvHUd5c5YrL+3x1h15J8t9v nAoMh9PXhSZkr2zG8e5GKSSftVNZBIODmU/HGoAlg2tz+SeE8oZHt6NCMGEUpAT7 tHHM6jkOEDc53sqcYRJ5mg+gBHCLcwJTq1DYQeEqFKBEbL3Z+gZI1IEVA2ecpmDE b7Oat3efBY3QkMD3Fd4h0zosQF6eColuEIJ/wgU1bGWMP3NGW3KEd0ee+zC4P3Dj EWA1hkH+o3Pnfvh25R4jG7LxkUm1kUcKuaVB+yTYyKHMGMbimk+Gc5zeSukT3Cma ueRkaht9lf1y8Q== 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 BB815E484F; Sun, 14 Oct 2018 16:47:55 -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: Sun, 14 Oct 2018 22:47:47 +0200 Message-Id: <20181014204747.26621-8-thomas@monjalon.net> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181014204747.26621-1-thomas@monjalon.net> References: <20180907230958.21402-1-thomas@monjalon.net> <20181014204747.26621-1-thomas@monjalon.net> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v5 7/7] eal: allow probing a device again 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" In the devargs syntax for device representors, it is possible to add several devices at once: -w dbdf,representor=[0-3] It will become a more frequent case when introducing wildcards and ranges in the new devargs syntax. If a devargs string is provided for probing, and updated with a bigger range for a new probing, then we do not want it to fail because part of this range was already probed previously. There can be new ports to create from an existing rte_device. That's why the check for an already probed device is moved as bus responsibility. In the case of vdev, a global check is kept in insert_vdev(), assuming that a vdev will always have only one port. In the case of ifpga and vmbus, already probed devices are checked. In the case of NXP buses, the probing is done only once (no hotplug), though a check is added at bus level for consistency. In the case of PCI, a driver flag is added to allow PMD probing again. Only the PMD knows the ports attached to one rte_device. As another consequence of being able to probe in several steps, the field rte_device.devargs must not be considered as a full representation of the rte_device, but only the latest probing args. Anyway, the field rte_device.devargs is used only for probing. Signed-off-by: Thomas Monjalon Reviewed-by: Andrew Rybchenko Tested-by: Andrew Rybchenko Acked-by: Shreyansh Jain --- drivers/bus/dpaa/dpaa_bus.c | 3 +++ drivers/bus/fslmc/fslmc_bus.c | 3 +++ drivers/bus/ifpga/ifpga_bus.c | 14 ++++++----- drivers/bus/pci/pci_common.c | 33 ++++++++++++++++--------- drivers/bus/pci/rte_bus_pci.h | 4 ++- drivers/bus/vdev/vdev.c | 5 ++++ lib/librte_eal/common/eal_common_dev.c | 7 ++---- lib/librte_eal/common/include/rte_dev.h | 2 +- 8 files changed, 47 insertions(+), 24 deletions(-) diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c index 138e0f98d..89d1e415d 100644 --- a/drivers/bus/dpaa/dpaa_bus.c +++ b/drivers/bus/dpaa/dpaa_bus.c @@ -555,6 +555,9 @@ rte_dpaa_bus_probe(void) if (ret) continue; + if (rte_dev_is_probed(&dev->device)) + continue; + if (!drv->probe || (dev->device.devargs && dev->device.devargs->policy == RTE_DEV_BLACKLISTED)) diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c index 960f55071..7ebd980aa 100644 --- a/drivers/bus/fslmc/fslmc_bus.c +++ b/drivers/bus/fslmc/fslmc_bus.c @@ -386,6 +386,9 @@ rte_fslmc_probe(void) if (!drv->probe) continue; + if (rte_dev_is_probed(&dev->device)) + continue; + if (dev->device.devargs && dev->device.devargs->policy == RTE_DEV_BLACKLISTED) { DPAA2_BUS_LOG(DEBUG, "%s Blacklisted, skipping", diff --git a/drivers/bus/ifpga/ifpga_bus.c b/drivers/bus/ifpga/ifpga_bus.c index 2ca1efa72..5f23ed8b4 100644 --- a/drivers/bus/ifpga/ifpga_bus.c +++ b/drivers/bus/ifpga/ifpga_bus.c @@ -301,8 +301,11 @@ ifpga_probe_all_drivers(struct rte_afu_device *afu_dev) return -1; /* Check if a driver is already loaded */ - if (rte_dev_is_probed(&afu_dev->device)) - return 0; + if (rte_dev_is_probed(&afu_dev->device)) { + IFPGA_BUS_DEBUG("Device %s is already probed\n", + rte_ifpga_device_name(afu_dev)); + return -EEXIST; + } TAILQ_FOREACH(drv, &ifpga_afu_drv_list, next) { if (ifpga_probe_one_driver(drv, afu_dev)) { @@ -325,14 +328,13 @@ ifpga_probe(void) int ret = 0; TAILQ_FOREACH(afu_dev, &ifpga_afu_dev_list, next) { - if (rte_dev_is_probed(&afu_dev->device)) - continue; - ret = ifpga_probe_all_drivers(afu_dev); + if (ret == -EEXIST) + continue; if (ret < 0) IFPGA_BUS_ERR("failed to initialize %s device\n", rte_ifpga_device_name(afu_dev)); - } + } return ret; } diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c index 62b17fba9..11c5da587 100644 --- a/drivers/bus/pci/pci_common.c +++ b/drivers/bus/pci/pci_common.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -121,6 +122,7 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *dev) { int ret; + bool already_probed; struct rte_pci_addr *loc; if ((dr == NULL) || (dev == NULL)) @@ -151,6 +153,13 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, dev->device.numa_node = 0; } + already_probed = rte_dev_is_probed(&dev->device); + if (already_probed && !(dr->drv_flags & RTE_PCI_DRV_PROBE_AGAIN)) { + RTE_LOG(DEBUG, EAL, "Device %s is already probed\n", + dev->device.name); + return -EEXIST; + } + RTE_LOG(INFO, EAL, " probe driver: %x:%x %s\n", dev->id.vendor_id, dev->id.device_id, dr->driver.name); @@ -159,9 +168,10 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, * This needs to be before rte_pci_map_device(), as it enables to use * driver flags for adjusting configuration. */ - dev->driver = dr; + if (!already_probed) + dev->driver = dr; - if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) { + if (!already_probed && (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING)) { /* map resources for devices that use igb_uio */ ret = rte_pci_map_device(dev); if (ret != 0) { @@ -172,6 +182,8 @@ rte_pci_probe_one_driver(struct rte_pci_driver *dr, /* call the driver probe() function */ ret = dr->probe(dr, dev); + if (already_probed) + return ret; /* no rollback if already succeeded earlier */ if (ret) { dev->driver = NULL; if ((dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) && @@ -242,10 +254,6 @@ pci_probe_all_drivers(struct rte_pci_device *dev) if (dev == NULL) return -1; - /* Check if a driver is already loaded */ - if (rte_dev_is_probed(&dev->device)) - return 0; - FOREACH_DRIVER_ON_PCIBUS(dr) { rc = rte_pci_probe_one_driver(dr, dev); if (rc < 0) @@ -287,11 +295,14 @@ rte_pci_probe(void) devargs->policy == RTE_DEV_WHITELISTED) ret = pci_probe_all_drivers(dev); if (ret < 0) { - RTE_LOG(ERR, EAL, "Requested device " PCI_PRI_FMT - " cannot be used\n", dev->addr.domain, dev->addr.bus, - dev->addr.devid, dev->addr.function); - rte_errno = errno; - failed++; + if (ret != -EEXIST) { + RTE_LOG(ERR, EAL, "Requested device " + PCI_PRI_FMT " cannot be used\n", + dev->addr.domain, dev->addr.bus, + dev->addr.devid, dev->addr.function); + rte_errno = errno; + failed++; + } ret = 0; } } diff --git a/drivers/bus/pci/rte_bus_pci.h b/drivers/bus/pci/rte_bus_pci.h index 984df2b37..a3baa2895 100644 --- a/drivers/bus/pci/rte_bus_pci.h +++ b/drivers/bus/pci/rte_bus_pci.h @@ -121,7 +121,7 @@ struct rte_pci_driver { pci_probe_t *probe; /**< Device Probe function. */ pci_remove_t *remove; /**< Device Remove function. */ const struct rte_pci_id *id_table; /**< ID table, NULL terminated. */ - uint32_t drv_flags; /**< Flags contolling handling of device. */ + uint32_t drv_flags; /**< Flags RTE_PCI_DRV_*. */ }; /** @@ -137,6 +137,8 @@ struct rte_pci_bus { #define RTE_PCI_DRV_NEED_MAPPING 0x0001 /** Device needs PCI BAR mapping with enabled write combining (wc) */ #define RTE_PCI_DRV_WC_ACTIVATE 0x0002 +/** Device already probed can be probed again to check for new ports. */ +#define RTE_PCI_DRV_PROBE_AGAIN 0x0004 /** Device driver supports link state interrupt */ #define RTE_PCI_DRV_INTR_LSC 0x0008 /** Device driver supports device removal interrupt */ diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c index f666099e6..06f314843 100644 --- a/drivers/bus/vdev/vdev.c +++ b/drivers/bus/vdev/vdev.c @@ -226,6 +226,11 @@ insert_vdev(const char *name, const char *args, struct rte_vdev_device **p_dev) dev->device.name = devargs->name; if (find_vdev(name)) { + /* + * A vdev is expected to have only one port. + * So there is no reason to try probing again, + * even with new arguments. + */ ret = -EEXIST; goto fail; } diff --git a/lib/librte_eal/common/eal_common_dev.c b/lib/librte_eal/common/eal_common_dev.c index 7e8a9b260..e733eb779 100644 --- a/lib/librte_eal/common/eal_common_dev.c +++ b/lib/librte_eal/common/eal_common_dev.c @@ -196,13 +196,10 @@ rte_dev_probe(const char *devargs) goto err_devarg; } - if (rte_dev_is_probed(dev)) { - RTE_LOG(ERR, EAL, "Device is already plugged\n"); - return -EEXIST; - } - ret = dev->bus->plug(dev); if (ret) { + if (rte_dev_is_probed(dev)) /* if already succeeded earlier */ + return ret; /* no rollback */ RTE_LOG(ERR, EAL, "Driver cannot attach the device (%s)\n", dev->name); goto err_devarg; diff --git a/lib/librte_eal/common/include/rte_dev.h b/lib/librte_eal/common/include/rte_dev.h index 9f169e3b3..a7ec8ec25 100644 --- a/lib/librte_eal/common/include/rte_dev.h +++ b/lib/librte_eal/common/include/rte_dev.h @@ -159,7 +159,7 @@ struct rte_device { const struct rte_driver *driver; /**< Driver assigned after probing */ const struct rte_bus *bus; /**< Bus handle assigned on scan */ int numa_node; /**< NUMA node connection */ - struct rte_devargs *devargs; /**< Device user arguments */ + struct rte_devargs *devargs; /**< Arguments for latest probing */ }; /**