From patchwork Thu Feb 16 11:09:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 124062 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 87B8941CB1; Thu, 16 Feb 2023 12:09:38 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D44A642D1D; Thu, 16 Feb 2023 12:09:34 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 2FC1D40E0F; Thu, 16 Feb 2023 12:09:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676545772; x=1708081772; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0Pb298xtmdmJVsr6vOdGVeKDvu23mP3N9B7dlHT3QaM=; b=JFlPv6AVfF2eLsOcTMpjo60Xzba3cAOySuXrx4xfCgclK/4Rc5oEEaEl tDK6Gr5SzKyNBY8giLd3AhgGc9FJKsudckJOXQY10QnghbDJjPASWSy9m UsoddTKABil6nvM1FfpW/lwWlV25Y1HqgQzSaQOSB/HOV1h4qYdEyOs7O imE8mHlZ5oTQlmyR17n2iPgvEzf0hss+5L1+NWrLlzp8pbm3mdTkz+G1p nuWpRd2vT6g0ktaOvVVyiE5xBlCuMDpt7c2Evqu5AMsE2j9bc/35f1miW OV1aa9HyEVLZ1VNdOuGvgBjihu8jIS8LMTLwHjKlvPyU6ypBNHm0ELLLU Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="315368142" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="315368142" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2023 03:09:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="702522812" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="702522812" Received: from silpixa00401385.ir.intel.com ([10.237.214.22]) by orsmga001.jf.intel.com with ESMTP; 16 Feb 2023 03:09:29 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: fengchengwen@huawei.com, Bruce Richardson , conor.walsh@intel.com, stable@dpdk.org, Kevin Laatz Subject: [PATCH v3 1/6] dma/ioat: fix device stop if no copies done Date: Thu, 16 Feb 2023 11:09:14 +0000 Message-Id: <20230216110919.373385-2-bruce.richardson@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230216110919.373385-1-bruce.richardson@intel.com> References: <20230116153714.554470-1-bruce.richardson@intel.com> <20230216110919.373385-1-bruce.richardson@intel.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The HW DMA devices supported by IOAT driver do not transition to the "active" state until the first operation is started by the HW. Therefore, if the user calls "rte_dma_stop()" on a device without triggering any operations, the sequence of commands to be sent to the HW is different, as is the final device state. Update the IOAT driver "stop" function to take account of this difference. Fixes: 583f046dd404 ("dma/ioat: add start and stop") Cc: conor.walsh@intel.com Cc: stable@dpdk.org Signed-off-by: Bruce Richardson Reviewed-by: Conor Walsh Acked-by: Kevin Laatz --- drivers/dma/ioat/ioat_dmadev.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/dma/ioat/ioat_dmadev.c b/drivers/dma/ioat/ioat_dmadev.c index 5906eb45aa..aff7bbbfde 100644 --- a/drivers/dma/ioat/ioat_dmadev.c +++ b/drivers/dma/ioat/ioat_dmadev.c @@ -166,17 +166,28 @@ static int ioat_dev_stop(struct rte_dma_dev *dev) { struct ioat_dmadev *ioat = dev->fp_obj->dev_private; + unsigned int chansts; uint32_t retry = 0; - ioat->regs->chancmd = IOAT_CHANCMD_SUSPEND; + chansts = (unsigned int)(ioat->regs->chansts & IOAT_CHANSTS_STATUS); + if (chansts == IOAT_CHANSTS_ACTIVE || chansts == IOAT_CHANSTS_IDLE) + ioat->regs->chancmd = IOAT_CHANCMD_SUSPEND; + else + ioat->regs->chancmd = IOAT_CHANCMD_RESET; do { rte_pause(); retry++; - } while ((ioat->regs->chansts & IOAT_CHANSTS_STATUS) != IOAT_CHANSTS_SUSPENDED - && retry < 200); + chansts = (unsigned int)(ioat->regs->chansts & IOAT_CHANSTS_STATUS); + } while (chansts != IOAT_CHANSTS_SUSPENDED && + chansts != IOAT_CHANSTS_HALTED && retry < 200); + + if (chansts == IOAT_CHANSTS_SUSPENDED || chansts == IOAT_CHANSTS_HALTED) + return 0; - return ((ioat->regs->chansts & IOAT_CHANSTS_STATUS) == IOAT_CHANSTS_SUSPENDED) ? 0 : -1; + IOAT_PMD_WARN("Channel could not be suspended on stop. (chansts = %u [%s])", + chansts, chansts_readable[chansts]); + return -1; } /* Get device information of a device. */ From patchwork Thu Feb 16 11:09:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 124063 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D995A41CB1; Thu, 16 Feb 2023 12:09:44 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2FBD842D38; Thu, 16 Feb 2023 12:09:37 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id ABBF442D13; Thu, 16 Feb 2023 12:09:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676545775; x=1708081775; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LDWexLDGdfmEhEoxP/d8EPH75KfCbNNZAPyABqtfk9Y=; b=Iv7b8hh2w4wXiaLxQC296HHAwU32rPqzeDgMV8cPeIOIZPm24X9mr7N5 +mK8I5vWWWkPIU1WkKBe4EuChUEiIeenVDZhOu/UaZ1qJmwqBbSY5NXHE FnDxHKEbDeH7iXsM6g4k9R0x5QaPW8/uNWPojnSU2aLASghZ21tzYQ6CN 6YlZ2xqcJe3GHji6F7//rhXg09TP/TQEAgCnDCnT3mgmVbXFkTynoYJ2i XQ78n7k+QjtCFkLutsc9kbG+S2TxwFB0T4tFLsMkvqzaxEXfSY8tWyYOe Wc7DTjSEoLroKJhj1oTQSI9jarDV71917nf484MlhmLd3g/vlvM+EHRIz g==; X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="315368156" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="315368156" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2023 03:09:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="702522824" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="702522824" Received: from silpixa00401385.ir.intel.com ([10.237.214.22]) by orsmga001.jf.intel.com with ESMTP; 16 Feb 2023 03:09:32 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: fengchengwen@huawei.com, Bruce Richardson , conor.walsh@intel.com, stable@dpdk.org, Kevin Laatz Subject: [PATCH v3 2/6] dma/ioat: fix incorrectly set indexes after restart Date: Thu, 16 Feb 2023 11:09:15 +0000 Message-Id: <20230216110919.373385-3-bruce.richardson@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230216110919.373385-1-bruce.richardson@intel.com> References: <20230116153714.554470-1-bruce.richardson@intel.com> <20230216110919.373385-1-bruce.richardson@intel.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org As part of the process of restarting a dma instance, the IOAT driver will reset the HW addresses and state values. The read and write indexes for SW use need to be similarly reset to keep HW and SW in sync. Fixes: 583f046dd404 ("dma/ioat: add start and stop") Cc: conor.walsh@intel.com Cc: stable@dpdk.org Signed-off-by: Bruce Richardson Reviewed-by: Conor Walsh Acked-by: Kevin Laatz --- drivers/dma/ioat/ioat_dmadev.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/dma/ioat/ioat_dmadev.c b/drivers/dma/ioat/ioat_dmadev.c index aff7bbbfde..072eb17cd9 100644 --- a/drivers/dma/ioat/ioat_dmadev.c +++ b/drivers/dma/ioat/ioat_dmadev.c @@ -146,6 +146,13 @@ ioat_dev_start(struct rte_dma_dev *dev) /* Prime the status register to be set to the last element. */ ioat->status = ioat->ring_addr + ((ioat->qcfg.nb_desc - 1) * DESC_SZ); + /* reset all counters */ + ioat->next_read = 0; + ioat->next_write = 0; + ioat->last_write = 0; + ioat->offset = 0; + ioat->failure = 0; + printf("IOAT.status: %s [0x%"PRIx64"]\n", chansts_readable[ioat->status & IOAT_CHANSTS_STATUS], ioat->status); From patchwork Thu Feb 16 11:09:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 124064 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AFB0941CB1; Thu, 16 Feb 2023 12:09:50 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3D85D42D31; Thu, 16 Feb 2023 12:09:39 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 7FB4B40E0F; Thu, 16 Feb 2023 12:09:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676545777; x=1708081777; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dMoWY5wrq3Ago+KRNoPAWQZDtZIlccwlIsaL57iVgnY=; b=Ffd0qc7uFs+r5JrXjUbD4BJRYckszqNP4zwOXNfWPksQqkIkQkmjPMU2 Dez6i1cjGR+9K2v5eOp7R9KheAuyhhPF3Bfmut3m556UZloKRHZMkfCEV VCce8lIAdxxEmpBZwuJx1VwxL6kgC2+CBbHNnZvRTT1y9ixmuWBfRh7Cl LxBCg8LH0j38VoM/YoetCYOXYz2fPx7tIfJKtCalx3nBVkCUtg6IzkaFN 80DXHK0vWfY/bKgf8LAR+ufC4pbUygYM0QjYr+vtQwPrcoZonN9NubqIe ROFj15BMLffAbrj0w6f9SdFSG5+VBdYNsrWFCcP+9Ojfj0Zr4DwsM7rVs A==; X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="315368164" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="315368164" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2023 03:09:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="702522830" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="702522830" Received: from silpixa00401385.ir.intel.com ([10.237.214.22]) by orsmga001.jf.intel.com with ESMTP; 16 Feb 2023 03:09:35 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: fengchengwen@huawei.com, Bruce Richardson , conor.walsh@intel.com, stable@dpdk.org, Kevin Laatz Subject: [PATCH v3 3/6] dma/ioat: fix incorrect error reporting on restart Date: Thu, 16 Feb 2023 11:09:16 +0000 Message-Id: <20230216110919.373385-4-bruce.richardson@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230216110919.373385-1-bruce.richardson@intel.com> References: <20230116153714.554470-1-bruce.richardson@intel.com> <20230216110919.373385-1-bruce.richardson@intel.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org When the DMA device was stopped and restarted by the driver, the control register specifying the behaviour on error was not getting correctly reset. This caused unit tests to fail as explicitly introduced errors were got getting reported back. Fix by moving the setting of the register to the start function from the probe function. Fixes: 583f046dd404 ("dma/ioat: add start and stop") Cc: conor.walsh@intel.com Cc: stable@dpdk.org Signed-off-by: Bruce Richardson Reviewed-by: Conor Walsh Acked-by: Kevin Laatz --- drivers/dma/ioat/ioat_dmadev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/dma/ioat/ioat_dmadev.c b/drivers/dma/ioat/ioat_dmadev.c index 072eb17cd9..57c18c081d 100644 --- a/drivers/dma/ioat/ioat_dmadev.c +++ b/drivers/dma/ioat/ioat_dmadev.c @@ -142,6 +142,9 @@ ioat_dev_start(struct rte_dma_dev *dev) ioat->regs->chainaddr = ioat->ring_addr; /* Inform hardware of where to write the status/completions. */ ioat->regs->chancmp = ioat->status_addr; + /* Ensure channel control is set to abort on error, so we get status writeback. */ + ioat->regs->chanctrl = IOAT_CHANCTRL_ANY_ERR_ABORT_EN | + IOAT_CHANCTRL_ERR_COMPLETION_EN; /* Prime the status register to be set to the last element. */ ioat->status = ioat->ring_addr + ((ioat->qcfg.nb_desc - 1) * DESC_SZ); @@ -682,8 +685,6 @@ ioat_dmadev_create(const char *name, struct rte_pci_device *dev) return -EIO; } } - ioat->regs->chanctrl = IOAT_CHANCTRL_ANY_ERR_ABORT_EN | - IOAT_CHANCTRL_ERR_COMPLETION_EN; dmadev->fp_obj->dev_private = ioat; From patchwork Thu Feb 16 11:09:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 124065 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B50A541CB1; Thu, 16 Feb 2023 12:09:57 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 940B442D40; Thu, 16 Feb 2023 12:09:45 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 902B042D2D for ; Thu, 16 Feb 2023 12:09:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676545784; x=1708081784; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7TvFRxftjUlmlTXkv4GGx7IcHm3n2JI2aYhlNd1fqOw=; b=O6CkVdjJqGxqNvzUt0VovdwVTWG2mujYDs3POK8jK/oIYV7cyGWRbB9Q IjTU0jBzm0Qg84nWsihhAGksre8gX1b9xa6IiUWLEj5K8EpAIgp8OfoDU Dh7uLd6bc0rftM9ZAQuBw+vmwf1sl47XeTG8mM4lF+hXaRwG9TOWMcs3C 5P9qVDKPNMjt1JCuZLznEis3voh2kUWRkAkTRMpHPVg/h6vXIIC7t6OFd zCUngq/ojzZ4r6k+VgEGVtCAqMvKapT8SGaxIddsI/KAMoGWwATit5/I0 nnjUSwjCE402Rc6kzBMu9kRWGMPzXZhjjHygyBiixjeTE+FMkCQRJYeNn w==; X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="315368183" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="315368183" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2023 03:09:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="702522839" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="702522839" Received: from silpixa00401385.ir.intel.com ([10.237.214.22]) by orsmga001.jf.intel.com with ESMTP; 16 Feb 2023 03:09:42 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: fengchengwen@huawei.com, Bruce Richardson , Conor Walsh , Kevin Laatz Subject: [PATCH v3 4/6] test/dmadev: check result for device stop Date: Thu, 16 Feb 2023 11:09:17 +0000 Message-Id: <20230216110919.373385-5-bruce.richardson@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230216110919.373385-1-bruce.richardson@intel.com> References: <20230116153714.554470-1-bruce.richardson@intel.com> <20230216110919.373385-1-bruce.richardson@intel.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The DMA device stop API can return an error value so check that return value when running dmadev unit tests. Signed-off-by: Bruce Richardson Reviewed-by: Conor Walsh Acked-by: Kevin Laatz Acked-by: Chengwen Feng --- app/test/test_dmadev.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c index fe62e98af8..65226004d8 100644 --- a/app/test/test_dmadev.c +++ b/app/test/test_dmadev.c @@ -837,7 +837,10 @@ test_dmadev_instance(int16_t dev_id) goto err; rte_mempool_free(pool); - rte_dma_stop(dev_id); + + if (rte_dma_stop(dev_id) < 0) + ERR_RETURN("Error stopping device %u\n", dev_id); + rte_dma_stats_reset(dev_id, vchan); return 0; From patchwork Thu Feb 16 11:09:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 124066 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 15A6C41CB1; Thu, 16 Feb 2023 12:10:05 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 97A8B42D3D; Thu, 16 Feb 2023 12:09:48 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id B950342D43 for ; Thu, 16 Feb 2023 12:09:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676545786; x=1708081786; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JZO4As2sVLcm3wlPugCrwwUCc5fndoQDjPDO3DuJoPw=; b=Zp9L3Bzode672VG49NbVuIxVLaoCK2uIkzSPYqpCF6Pknx+I2pSFCjM1 7w73MwNxutbVBv/0pquXaWrPGC8bxMjsnwDj5OccphwNB6GUHQmFJVv9r xpGeTH7WbW5/ob5ZsUBlU6z3bjGUohe+Za3as/QptlK0RCDyBz4eyt2K6 knT94+lS4HgvXPp26avf8x15lUwW/0OX9PHxEZAsDQo9qTjceOgO2BLiQ XjyiEvo0EFju4tXHYHUdMV3JAK5AqaN806IocKHwzpsmo8TM7n1bHhIBM IlmsJOCoFbfoqKON1ULMcJjx8F4wChIg+MvpAJMKsAwCEO058ENYr6Xzx Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="315368188" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="315368188" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2023 03:09:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="702522844" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="702522844" Received: from silpixa00401385.ir.intel.com ([10.237.214.22]) by orsmga001.jf.intel.com with ESMTP; 16 Feb 2023 03:09:44 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: fengchengwen@huawei.com, Bruce Richardson , Kevin Laatz Subject: [PATCH v3 5/6] test/dmadev: create separate function for single copy test Date: Thu, 16 Feb 2023 11:09:18 +0000 Message-Id: <20230216110919.373385-6-bruce.richardson@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230216110919.373385-1-bruce.richardson@intel.com> References: <20230116153714.554470-1-bruce.richardson@intel.com> <20230216110919.373385-1-bruce.richardson@intel.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The copy tests for dmadev had separate blocks in the test function for single copy and burst copies. Separate out the single-copy block to its own function so that it can be re-used if necessary. Signed-off-by: Bruce Richardson Acked-by: Kevin Laatz Acked-by: Chengwen Feng --- app/test/test_dmadev.c | 120 ++++++++++++++++++++++------------------- 1 file changed, 64 insertions(+), 56 deletions(-) diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c index 65226004d8..0296c52d2a 100644 --- a/app/test/test_dmadev.c +++ b/app/test/test_dmadev.c @@ -175,77 +175,85 @@ do_multi_copies(int16_t dev_id, uint16_t vchan, } static int -test_enqueue_copies(int16_t dev_id, uint16_t vchan) +test_single_copy(int16_t dev_id, uint16_t vchan) { - enum rte_dma_status_code status; - unsigned int i; + uint16_t i; uint16_t id; + enum rte_dma_status_code status; + struct rte_mbuf *src, *dst; + char *src_data, *dst_data; - /* test doing a single copy */ - do { - struct rte_mbuf *src, *dst; - char *src_data, *dst_data; + src = rte_pktmbuf_alloc(pool); + dst = rte_pktmbuf_alloc(pool); + src_data = rte_pktmbuf_mtod(src, char *); + dst_data = rte_pktmbuf_mtod(dst, char *); - src = rte_pktmbuf_alloc(pool); - dst = rte_pktmbuf_alloc(pool); - src_data = rte_pktmbuf_mtod(src, char *); - dst_data = rte_pktmbuf_mtod(dst, char *); + for (i = 0; i < COPY_LEN; i++) + src_data[i] = rte_rand() & 0xFF; - for (i = 0; i < COPY_LEN; i++) - src_data[i] = rte_rand() & 0xFF; + id = rte_dma_copy(dev_id, vchan, rte_pktmbuf_iova(src), rte_pktmbuf_iova(dst), + COPY_LEN, RTE_DMA_OP_FLAG_SUBMIT); + if (id != id_count) + ERR_RETURN("Error with rte_dma_copy, got %u, expected %u\n", + id, id_count); - id = rte_dma_copy(dev_id, vchan, rte_pktmbuf_iova(src), rte_pktmbuf_iova(dst), - COPY_LEN, RTE_DMA_OP_FLAG_SUBMIT); - if (id != id_count) - ERR_RETURN("Error with rte_dma_copy, got %u, expected %u\n", - id, id_count); + /* give time for copy to finish, then check it was done */ + await_hw(dev_id, vchan); - /* give time for copy to finish, then check it was done */ - await_hw(dev_id, vchan); + for (i = 0; i < COPY_LEN; i++) + if (dst_data[i] != src_data[i]) + ERR_RETURN("Data mismatch at char %u [Got %02x not %02x]\n", i, + dst_data[i], src_data[i]); + + /* now check completion works */ + id = ~id; + if (rte_dma_completed(dev_id, vchan, 1, &id, NULL) != 1) + ERR_RETURN("Error with rte_dma_completed\n"); + + if (id != id_count) + ERR_RETURN("Error:incorrect job id received, %u [expected %u]\n", + id, id_count); + + /* check for completed and id when no job done */ + id = ~id; + if (rte_dma_completed(dev_id, vchan, 1, &id, NULL) != 0) + ERR_RETURN("Error with rte_dma_completed when no job done\n"); + if (id != id_count) + ERR_RETURN("Error:incorrect job id received when no job done, %u [expected %u]\n", + id, id_count); + + /* check for completed_status and id when no job done */ + id = ~id; + if (rte_dma_completed_status(dev_id, vchan, 1, &id, &status) != 0) + ERR_RETURN("Error with rte_dma_completed_status when no job done\n"); + if (id != id_count) + ERR_RETURN("Error:incorrect job id received when no job done, %u [expected %u]\n", + id, id_count); - for (i = 0; i < COPY_LEN; i++) - if (dst_data[i] != src_data[i]) - ERR_RETURN("Data mismatch at char %u [Got %02x not %02x]\n", i, - dst_data[i], src_data[i]); - - /* now check completion works */ - id = ~id; - if (rte_dma_completed(dev_id, vchan, 1, &id, NULL) != 1) - ERR_RETURN("Error with rte_dma_completed\n"); - - if (id != id_count) - ERR_RETURN("Error:incorrect job id received, %u [expected %u]\n", - id, id_count); - - /* check for completed and id when no job done */ - id = ~id; - if (rte_dma_completed(dev_id, vchan, 1, &id, NULL) != 0) - ERR_RETURN("Error with rte_dma_completed when no job done\n"); - if (id != id_count) - ERR_RETURN("Error:incorrect job id received when no job done, %u [expected %u]\n", - id, id_count); - - /* check for completed_status and id when no job done */ - id = ~id; - if (rte_dma_completed_status(dev_id, vchan, 1, &id, &status) != 0) - ERR_RETURN("Error with rte_dma_completed_status when no job done\n"); - if (id != id_count) - ERR_RETURN("Error:incorrect job id received when no job done, %u [expected %u]\n", - id, id_count); + rte_pktmbuf_free(src); + rte_pktmbuf_free(dst); - rte_pktmbuf_free(src); - rte_pktmbuf_free(dst); + /* now check completion returns nothing more */ + if (rte_dma_completed(dev_id, 0, 1, NULL, NULL) != 0) + ERR_RETURN("Error with rte_dma_completed in empty check\n"); + + id_count++; - /* now check completion returns nothing more */ - if (rte_dma_completed(dev_id, 0, 1, NULL, NULL) != 0) - ERR_RETURN("Error with rte_dma_completed in empty check\n"); + return 0; +} - id_count++; +static int +test_enqueue_copies(int16_t dev_id, uint16_t vchan) +{ + unsigned int i; - } while (0); + /* test doing a single copy */ + if (test_single_copy(dev_id, vchan) < 0) + return -1; /* test doing a multiple single copies */ do { + uint16_t id; const uint16_t max_ops = 4; struct rte_mbuf *src, *dst; char *src_data, *dst_data; From patchwork Thu Feb 16 11:09:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 124067 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 31F0041CB1; Thu, 16 Feb 2023 12:10:13 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id ACF7242D49; Thu, 16 Feb 2023 12:09:51 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 0347A42D49 for ; Thu, 16 Feb 2023 12:09:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676545790; x=1708081790; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EEu7bttajJBsicMhMNqv/bOb0T21DPcTbjESecENCNI=; b=DL5MM71DCE/IFJVEoMtaJ0sPaNSS/RBBjqChM8A03jB1upUq7XxyNh3B AU+CkQTsnusmeARAG/HPZdZ+2jwrOETk1DHnkZFRXAbMUcH0M/PrRfLXU m+/c6lgl04VoU/6GtSHodaSq4pPfw74eX53QkeARt8SyUBwxgiBIlkYNR mNUEv0lXGoKndnX6d4Ho3xO8Ie5ha3xVV89JroNxcUvkE9fCvlHftiT26 zWarH8/PGfmL6VBgK6QY5QNdN2qECo0I199a+jmRQtRK3Voei/d4O3r+/ aoEUzzme4gpnY2jMmdetEhOv0XragrG8RjDEEqp55HX5dX/1/kJNENCkq Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="315368191" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="315368191" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Feb 2023 03:09:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10622"; a="702522848" X-IronPort-AV: E=Sophos;i="5.97,302,1669104000"; d="scan'208";a="702522848" Received: from silpixa00401385.ir.intel.com ([10.237.214.22]) by orsmga001.jf.intel.com with ESMTP; 16 Feb 2023 03:09:48 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: fengchengwen@huawei.com, Bruce Richardson , Kevin Laatz Subject: [PATCH v3 6/6] test/dmadev: add tests for stopping and restarting dev Date: Thu, 16 Feb 2023 11:09:19 +0000 Message-Id: <20230216110919.373385-7-bruce.richardson@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230216110919.373385-1-bruce.richardson@intel.com> References: <20230116153714.554470-1-bruce.richardson@intel.com> <20230216110919.373385-1-bruce.richardson@intel.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Validate device operation when a device is stopped or restarted. The only complication - and gap in the dmadev ABI specification - is what happens to the job ids on restart. Some drivers reset them to 0, while others continue where things left off. Take account of both possibilities in the test case. Signed-off-by: Bruce Richardson Acked-by: Kevin Laatz Acked-by: Chengwen Feng --- app/test/test_dmadev.c | 46 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c index 0296c52d2a..0736ff2a18 100644 --- a/app/test/test_dmadev.c +++ b/app/test/test_dmadev.c @@ -304,6 +304,48 @@ test_enqueue_copies(int16_t dev_id, uint16_t vchan) || do_multi_copies(dev_id, vchan, 0, 0, 1); } +static int +test_stop_start(int16_t dev_id, uint16_t vchan) +{ + /* device is already started on input, should be (re)started on output */ + + uint16_t id = 0; + enum rte_dma_status_code status = RTE_DMA_STATUS_SUCCESSFUL; + + /* - test stopping a device works ok, + * - then do a start-stop without doing a copy + * - finally restart the device + * checking for errors at each stage, and validating we can still copy at the end. + */ + if (rte_dma_stop(dev_id) < 0) + ERR_RETURN("Error stopping device\n"); + + if (rte_dma_start(dev_id) < 0) + ERR_RETURN("Error restarting device\n"); + if (rte_dma_stop(dev_id) < 0) + ERR_RETURN("Error stopping device after restart (no jobs executed)\n"); + + if (rte_dma_start(dev_id) < 0) + ERR_RETURN("Error restarting device after multiple stop-starts\n"); + + /* before doing a copy, we need to know what the next id will be it should + * either be: + * - the last completed job before start if driver does not reset id on stop + * - or -1 i.e. next job is 0, if driver does reset the job ids on stop + */ + if (rte_dma_completed_status(dev_id, vchan, 1, &id, &status) != 0) + ERR_RETURN("Error with rte_dma_completed_status when no job done\n"); + id += 1; /* id_count is next job id */ + if (id != id_count && id != 0) + ERR_RETURN("Unexpected next id from device after stop-start. Got %u, expected %u or 0\n", + id, id_count); + + id_count = id; + if (test_single_copy(dev_id, vchan) < 0) + ERR_RETURN("Error performing copy after device restart\n"); + return 0; +} + /* Failure handling test cases - global macros and variables for those tests*/ #define COMP_BURST_SZ 16 #define OPT_FENCE(idx) ((fence && idx == 8) ? RTE_DMA_OP_FLAG_FENCE : 0) @@ -819,6 +861,10 @@ test_dmadev_instance(int16_t dev_id) if (runtest("copy", test_enqueue_copies, 640, dev_id, vchan, CHECK_ERRS) < 0) goto err; + /* run tests stopping/starting devices and check jobs still work after restart */ + if (runtest("stop-start", test_stop_start, 1, dev_id, vchan, CHECK_ERRS) < 0) + goto err; + /* run some burst capacity tests */ if (rte_dma_burst_capacity(dev_id, vchan) < 64) printf("DMA Dev %u: insufficient burst capacity (64 required), skipping tests\n",