From patchwork Mon Jan 16 17:37:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 122117 X-Patchwork-Delegate: david.marchand@redhat.com 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 73B2D423F2; Mon, 16 Jan 2023 18:38:01 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9590140DFD; Mon, 16 Jan 2023 18:37:57 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 4354B40042; Mon, 16 Jan 2023 18:37:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673890675; x=1705426675; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3XTT/Yug2Xu3WXQwJd6lUQK2JpZXU0dgzCzxwxuUVUM=; b=hsi2i5LuihxSKHeM+Yz3UG9VnCBY3KQryZM315AY3dnESWJ5y0wEqXPf MUzm+shPap0+HZR8EoGaVLVGSHVR2gLkBHf9jKR64kxpfSzzabc2c2L7I WNilq/c0pQKvmd8hp9K35ZIdbG7heMkRdPvSUaD2J5vyhjDQtcJSX+Z5i ejMFHDGwu6cHToo5BgPXV1kNIpIOPtysWatAN3pPyTcY6GmE3WIbshFpt O7RlGe4AodE7zm5JamIHM1MnT2/WZUkolAGGxG4Ut/TCVoJT4BbyXWhRD EuA3qbjtDoztl+YpbjUdL42YlfPJRzCf0dDsePpCYvEeSNGs40VtodLBu A==; X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="326570388" X-IronPort-AV: E=Sophos;i="5.97,221,1669104000"; d="scan'208";a="326570388" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2023 09:37:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="987869172" X-IronPort-AV: E=Sophos;i="5.97,221,1669104000"; d="scan'208";a="987869172" Received: from silpixa00401385.ir.intel.com ([10.237.214.55]) by fmsmga005.fm.intel.com with ESMTP; 16 Jan 2023 09:37:53 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , conor.walsh@intel.com, stable@dpdk.org, Kevin Laatz Subject: [PATCH v2 1/6] dma/ioat: fix device stop if no copies done Date: Mon, 16 Jan 2023 17:37:32 +0000 Message-Id: <20230116173738.562322-2-bruce.richardson@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230116173738.562322-1-bruce.richardson@intel.com> References: <20230116153714.554470-1-bruce.richardson@intel.com> <20230116173738.562322-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 Mon Jan 16 17:37:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 122118 X-Patchwork-Delegate: david.marchand@redhat.com 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 5950D423F2; Mon, 16 Jan 2023 18:38:07 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A8EF840A7D; Mon, 16 Jan 2023 18:37:59 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 279B542D0C; Mon, 16 Jan 2023 18:37:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673890678; x=1705426678; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VPjhE4TyFn1xnrh9RXxQFdJknzloQglA6je+k/AymO0=; b=HeNt+8hQKKDlkTcNbc8kqS2z3CPGk8sTLbi+zPR5G6fBGFxymvk8okt3 T7b4mZSZyxA6II25mQHi+Sz3aDXPBarFQ93GH4a0OPBGcJj4vgBE5xtgE 7va/b2Tn4y5fur1cWdlTyNeiw0mBD8X1j3DeRI/SPg6EEIslVt6/ecxt2 ST4/skGpZ1q/oMa1U2kZL8pVI6+h/4ADxjSs6ruvutRhkkr5p9NqwilU2 VtnTRMgVJCUYDloB39+bWoyamupgIyjzeEdeloLxOcRtCImPO+b5IBCpZ xgmBxLqd65GCb42lm0Ehfato2vWZBU5rc6vI8wXW0aknc8f2iUac3lx7K Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="326570391" X-IronPort-AV: E=Sophos;i="5.97,221,1669104000"; d="scan'208";a="326570391" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2023 09:37:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="987869175" X-IronPort-AV: E=Sophos;i="5.97,221,1669104000"; d="scan'208";a="987869175" Received: from silpixa00401385.ir.intel.com ([10.237.214.55]) by fmsmga005.fm.intel.com with ESMTP; 16 Jan 2023 09:37:54 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , conor.walsh@intel.com, stable@dpdk.org, Kevin Laatz Subject: [PATCH v2 2/6] dma/ioat: fix incorrectly set indexes after restart Date: Mon, 16 Jan 2023 17:37:33 +0000 Message-Id: <20230116173738.562322-3-bruce.richardson@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230116173738.562322-1-bruce.richardson@intel.com> References: <20230116153714.554470-1-bruce.richardson@intel.com> <20230116173738.562322-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 Mon Jan 16 17:37:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 122119 X-Patchwork-Delegate: david.marchand@redhat.com 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 3E652423F2; Mon, 16 Jan 2023 18:38:14 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E217042D27; Mon, 16 Jan 2023 18:38:00 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id E5CCB42D0C; Mon, 16 Jan 2023 18:37:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673890679; x=1705426679; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=leGtDM/a3StluTw/9dzlevlJ23l6D91yAdjApzDtd4g=; b=didGG6t3IYpXYTa+/FteXHbSFYn1+A6zt++scOD0QFk4IC+qyEM61XEO qdICwHVtA+kCxOu8o+Pbvzda7y1u3HzbbrwyyPZF9BgaH9vM0z/xJeJhH I5WuZD/2XVkq2JbVt4rAzDz3hwBeoK6p9zNIJuXAm8c39gAMg9FSky9nh H27Ti6UwMszUxgEAT45jvoZsAUDdrSnrf91NngTRa+uANgYhaCsXbaRVx M2VuAh0DVXO6PL4OLxce2nR9OYz0j7aK5Pn6gsqzsIrQW1leZ+xl/IppS sQtxfBP1uqikOecpJZvkG2mN+4ZMNg6ntvOxYVjkJizl4/D83znYZirs5 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="326570394" X-IronPort-AV: E=Sophos;i="5.97,221,1669104000"; d="scan'208";a="326570394" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2023 09:37:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="987869180" X-IronPort-AV: E=Sophos;i="5.97,221,1669104000"; d="scan'208";a="987869180" Received: from silpixa00401385.ir.intel.com ([10.237.214.55]) by fmsmga005.fm.intel.com with ESMTP; 16 Jan 2023 09:37:56 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , conor.walsh@intel.com, stable@dpdk.org, Kevin Laatz Subject: [PATCH v2 3/6] dma/ioat: fix incorrect error reporting on restart Date: Mon, 16 Jan 2023 17:37:34 +0000 Message-Id: <20230116173738.562322-4-bruce.richardson@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230116173738.562322-1-bruce.richardson@intel.com> References: <20230116153714.554470-1-bruce.richardson@intel.com> <20230116173738.562322-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 Mon Jan 16 17:37:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 122120 X-Patchwork-Delegate: david.marchand@redhat.com 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 02D53423F2; Mon, 16 Jan 2023 18:38:19 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 28AD242D2A; Mon, 16 Jan 2023 18:38:02 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id B3FBF42D0E for ; Mon, 16 Jan 2023 18:37:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673890679; x=1705426679; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=clFEMN+caSJ2XWJZ8CvtgRiTLoqxEFz9MbLvMRL/uW0=; b=LqU6UNj5tPajUNvmoeO/fduzbL/GY6YVOEVucKZJFpuFV3/9mAqhDoIZ uvlA9WRsJ3ZR5SPWqbHfRhQElSLw6ZjpN8fYn53NfH3WrDLyEZPYwUHk+ HilJth/kqoPQdMKKIzt2Y88D4YR1GC36UmkCRChKNgufIbTzN347aauy6 ctc93JCfxpOq7wlK20bb+ILDAZzQ1Ya1q+nRQi2IBBTB33/IN3Ntuj6sN HIwR4yHYXenH8TtgfxBK1SwPduMO0wUCxPR52yXll+giu6y9J/xN81gup L/myK6/svtG93RzCP8iK9g05i5o3zhRnvZwcFJknPmjTEEjwuOGrCUTU9 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="326570399" X-IronPort-AV: E=Sophos;i="5.97,221,1669104000"; d="scan'208";a="326570399" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2023 09:37:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="987869185" X-IronPort-AV: E=Sophos;i="5.97,221,1669104000"; d="scan'208";a="987869185" Received: from silpixa00401385.ir.intel.com ([10.237.214.55]) by fmsmga005.fm.intel.com with ESMTP; 16 Jan 2023 09:37:58 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , Chengwen Feng , Kevin Laatz Subject: [PATCH v2 4/6] test/dmadev: check result for device stop Date: Mon, 16 Jan 2023 17:37:35 +0000 Message-Id: <20230116173738.562322-5-bruce.richardson@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230116173738.562322-1-bruce.richardson@intel.com> References: <20230116153714.554470-1-bruce.richardson@intel.com> <20230116173738.562322-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 --- app/test/test_dmadev.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c index fe62e98af8..4e1dbcaa19 100644 --- a/app/test/test_dmadev.c +++ b/app/test/test_dmadev.c @@ -837,7 +837,11 @@ 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) { + rte_mempool_free(pool); + ERR_RETURN("Error stopping device %u\n", dev_id); + } rte_dma_stats_reset(dev_id, vchan); return 0; From patchwork Mon Jan 16 17:37:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 122121 X-Patchwork-Delegate: david.marchand@redhat.com 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 38007423F2; Mon, 16 Jan 2023 18:38:26 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 88A7842D26; Mon, 16 Jan 2023 18:38:04 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 18A8842D28 for ; Mon, 16 Jan 2023 18:38:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673890681; x=1705426681; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=e3jZHM4yJk/8BqAo8Z2/tMLG0wzwKz0BNGq6sSvTkyo=; b=QqXTIMDZdiLfQkoBWTD0lfHGlClnPK5RLpY5QZ+e3CMbEv8efxTB46I2 XfzeDeA0WvJvG8QoZXQBYv6J8k/54jl5ymLHw+mvMFGFEeU6ySsePF9Hx W6ONWoD46ioxxvckOrghoCO8hs8T/1ZKcDRogf2/l6KbyJPr6K9mJhOGm fTPv8JJEOwZAzUViazu9P09DRmnlDykZmglCzCQTHJJ2KIZ3DkNhiaWZP 1cXVpwG8D0O118WPpjT9GwwU6i8J6CcbgQZdGs/gSH7UtWT+dadZdUaBy Reh11SN4B53FZ9vQoGFBfKDjFD9xXixEi94BaonUsOTWQk7IXVP97Ulbx Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="326570408" X-IronPort-AV: E=Sophos;i="5.97,221,1669104000"; d="scan'208";a="326570408" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2023 09:38:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="987869189" X-IronPort-AV: E=Sophos;i="5.97,221,1669104000"; d="scan'208";a="987869189" Received: from silpixa00401385.ir.intel.com ([10.237.214.55]) by fmsmga005.fm.intel.com with ESMTP; 16 Jan 2023 09:37:59 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , Chengwen Feng , Kevin Laatz Subject: [PATCH v2 5/6] test/dmadev: create separate function for single copy test Date: Mon, 16 Jan 2023 17:37:36 +0000 Message-Id: <20230116173738.562322-6-bruce.richardson@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230116173738.562322-1-bruce.richardson@intel.com> References: <20230116153714.554470-1-bruce.richardson@intel.com> <20230116173738.562322-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 4e1dbcaa19..de787c14e2 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 Mon Jan 16 17:37:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 122122 X-Patchwork-Delegate: david.marchand@redhat.com 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 AEA2E423F2; Mon, 16 Jan 2023 18:38:31 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6F37F42D3B; Mon, 16 Jan 2023 18:38:05 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 9378642D21 for ; Mon, 16 Jan 2023 18:38:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673890682; x=1705426682; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1LqDA38j0pDRXE4FLbv7jwinXiFM33626cWChtIHxVE=; b=X+g/m9MPTE6IqBBx2lQ9lmv4bjS8bst7RCsrrnc/IoPgyelAga6UjXfM SEsFHUA09EQ2uP0Ul2PpyG0+droV8HyZRmlmFOI6L1tQ5fjP1xGXGgS0O DFLoEWoufQq2XZoX/Pe9ebuVx406dOg32ht1HFKjy836XXntW1u+kNzxb BpO73pytM54st6Ob4NZosrdmivcjGBt5MIePiiCUdNKN0j/amLvd+i4JA pDkABH/+e/fIsWJntPXmMAQxcAdzWmQVhdW7l5midrsqxIWTnVijPP8vr WpODaF0Eq/26y9nsKTYq+ovj33RLhS0a5lox02j3ZCTFJrDXKIhG9bIlm Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="326570417" X-IronPort-AV: E=Sophos;i="5.97,221,1669104000"; d="scan'208";a="326570417" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2023 09:38:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="987869197" X-IronPort-AV: E=Sophos;i="5.97,221,1669104000"; d="scan'208";a="987869197" Received: from silpixa00401385.ir.intel.com ([10.237.214.55]) by fmsmga005.fm.intel.com with ESMTP; 16 Jan 2023 09:38:00 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , Chengwen Feng , Kevin Laatz Subject: [PATCH v2 6/6] test/dmadev: add tests for stopping and restarting dev Date: Mon, 16 Jan 2023 17:37:37 +0000 Message-Id: <20230116173738.562322-7-bruce.richardson@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230116173738.562322-1-bruce.richardson@intel.com> References: <20230116153714.554470-1-bruce.richardson@intel.com> <20230116173738.562322-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 --- 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 de787c14e2..8fb73a41e2 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",