From patchwork Mon Jan 16 15:37:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 122103 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 B3FA5423F1; Mon, 16 Jan 2023 16:37:41 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E8A5242D0C; Mon, 16 Jan 2023 16:37:40 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 515BB40F18; Mon, 16 Jan 2023 16:37:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673883458; x=1705419458; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=E+L7rpIcPsEH0Ztr+0whh7NB28tFlYDHF0rcs5bb29k=; b=VuEKeOVUtAAx4tjO0UL6Ngbts1pTzPLY09bnPsCjvIQtm8XIGRNk9k7u Ijbp6NhsMA9W0SJPBQh+Ls+/134Fff1NTSpKvwa64Bqu4AN8o6iSdVfVu Xvjxn96SVErXEkGNIAEVFyENteoxRok2ecJ4bKDzH5Lo+q0kmW/ctjHNS fcU0DL0FfwMREd1Z8o57p/K5JEJc1GorIvKvrQQsTdbGJU/TRshQC4Ady JhTGUCplPnEfoMx64oCWgSjibedeNqMxzzqeqcmhLbyo9MSmxvIrC4m+4 6eWn0n93J9UzHHKemPhHos6rhwgJCFlLGv7ijzmvEjbS0xyrTuZrhF1xW g==; X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="351735350" X-IronPort-AV: E=Sophos;i="5.97,221,1669104000"; d="scan'208";a="351735350" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2023 07:37:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="727505465" X-IronPort-AV: E=Sophos;i="5.97,221,1669104000"; d="scan'208";a="727505465" Received: from silpixa00401385.ir.intel.com ([10.237.214.55]) by fmsmga004.fm.intel.com with ESMTP; 16 Jan 2023 07:37:36 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , conor.walsh@intel.com, stable@dpdk.org, Kevin Laatz Subject: [PATCH 1/5] dma/ioat: fix device stop if no copies done Date: Mon, 16 Jan 2023 15:37:10 +0000 Message-Id: <20230116153714.554470-2-bruce.richardson@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230116153714.554470-1-bruce.richardson@intel.com> References: <20230116153714.554470-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 --- drivers/dma/ioat/ioat_dmadev.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) -- 2.37.2 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 15:37:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 122104 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 7E64F423F1; Mon, 16 Jan 2023 16:37:49 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0867C42D21; Mon, 16 Jan 2023 16:37:42 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id A9D1C40F18; Mon, 16 Jan 2023 16:37:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673883461; x=1705419461; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mbIx9zd3vsxExwZmUhZ4YT8HslOf+mQIXJW29tDJsFs=; b=CfRq06VXHwN2NibAPU4j2n+jgJLdUXWROc5a4WFyayHNrGThpMuXneVA bA/I1bfZRdW7iUEMEkg5Ou3xEJJ4kD00SfQjVmzgqZnzG17jTsEIn3dj5 1sW6JoqkwOP0iH6gK7vKmVH/cjShRDul/JX5LXH025+Nb7rELopRUWCFF lPnOQx9K5bxndTjaSrm5YdUkfhhB1+oCsW2shw9w7qx7ctt5pM8DYpfsu YMLbVskX5YpiKVYJKnFsCEgzAlXHJCi0iEzK7nAbtpDFFLU7nUkaOO5jQ 9kDAJ/t4x/IaW8VoAiuJcSsJGxb/yqvXKB/5ZzzDWV2ApdaJYxti3te5b Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="351735360" X-IronPort-AV: E=Sophos;i="5.97,221,1669104000"; d="scan'208";a="351735360" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2023 07:37:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="727505469" X-IronPort-AV: E=Sophos;i="5.97,221,1669104000"; d="scan'208";a="727505469" Received: from silpixa00401385.ir.intel.com ([10.237.214.55]) by fmsmga004.fm.intel.com with ESMTP; 16 Jan 2023 07:37:39 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , conor.walsh@intel.com, stable@dpdk.org, Kevin Laatz Subject: [PATCH 2/5] dma/ioat: fix incorrectly set indexes after restart Date: Mon, 16 Jan 2023 15:37:11 +0000 Message-Id: <20230116153714.554470-3-bruce.richardson@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230116153714.554470-1-bruce.richardson@intel.com> References: <20230116153714.554470-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 --- drivers/dma/ioat/ioat_dmadev.c | 7 +++++++ 1 file changed, 7 insertions(+) -- 2.37.2 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 15:37:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 122105 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 7C75C423F1; Mon, 16 Jan 2023 16:37:56 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F089342C54; Mon, 16 Jan 2023 16:37:44 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 6A5A342C54 for ; Mon, 16 Jan 2023 16:37:43 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673883463; x=1705419463; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dMtPYaqO1H4YzTxPQY04XxsyD6/YnL3VpwmaVaxASic=; b=U+N0rs//QI12CzAl3JZo0fJAXUBtpxjMCrHuIvOWUm1j4y8VWSogvVea IIG66w8QqCyXj8XsU9ibF/pocMpqyHlTKhYyo1wYEn+lSTQILT/xF3FVK Y+GrWAgpq5YcEUoF9t44p2rrxwxzb8pO0bdeYJYgv3ekMJZKieaRQgc0N r1GEgUPWB+b8bmOIiLMArvSpFzZoB29LXZ+XRdikBC1UxpecsQHe2qlTU +EOW81y6EK4aQMVIBucLPw+sd4Frqa7rgNZEbV37DeyRI4oIZWknDBED2 vYjswmA2542oUnDxohVdRr3J6VH+bRPPSvDpbEPiHOJFSuymIHxPSS4d4 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="351735370" X-IronPort-AV: E=Sophos;i="5.97,221,1669104000"; d="scan'208";a="351735370" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2023 07:37:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="727505474" X-IronPort-AV: E=Sophos;i="5.97,221,1669104000"; d="scan'208";a="727505474" Received: from silpixa00401385.ir.intel.com ([10.237.214.55]) by fmsmga004.fm.intel.com with ESMTP; 16 Jan 2023 07:37:41 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , Chengwen Feng , Kevin Laatz Subject: [PATCH 3/5] test/dmadev: check result for device stop Date: Mon, 16 Jan 2023 15:37:12 +0000 Message-Id: <20230116153714.554470-4-bruce.richardson@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230116153714.554470-1-bruce.richardson@intel.com> References: <20230116153714.554470-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 --- app/test/test_dmadev.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) -- 2.37.2 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 15:37:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 122106 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 236BB423F1; Mon, 16 Jan 2023 16:38:03 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E4F5C42D25; Mon, 16 Jan 2023 16:37:47 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id AE3C142D20 for ; Mon, 16 Jan 2023 16:37:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673883465; x=1705419465; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yCSHy5UJAXvcA4avgSN8/YLlIuBAq1j+VH22ghiS6Os=; b=dYA8cNhlRw3OcCd5m/5MR8KcM2XNyo9nQ8iN7tuR7RWFSABI36CbRYP+ gBhjaw1c5CmirJMIS6ob+oE/G6q1UTQdCMAwdz+cBiiHDgmpZ4OOsjTME +fcTVvMDM5oFmhqB1I1OhxYdi8kTqn28Q2y/8KpjCHI7rxUUKSuTWlnSX NQtTXOs47sb8Dnu+o/zTe197bz1Mi0BBdlSjPg0RS1INjKg8QeRBtme5u 0MItE5ovBbO5buMWfV5C80Juc+zKKffqhhu5U4XKMBvSKG+so6PF03Dp5 0t8ajVswGsREajPiQM7x7v9aALm3EcZyqOFsfX+rStr2y53XxcwlMjmfW w==; X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="351735376" X-IronPort-AV: E=Sophos;i="5.97,221,1669104000"; d="scan'208";a="351735376" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2023 07:37:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="727505482" X-IronPort-AV: E=Sophos;i="5.97,221,1669104000"; d="scan'208";a="727505482" Received: from silpixa00401385.ir.intel.com ([10.237.214.55]) by fmsmga004.fm.intel.com with ESMTP; 16 Jan 2023 07:37:44 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , Chengwen Feng , Kevin Laatz Subject: [PATCH 4/5] test/dmadev: create separate function for single copy test Date: Mon, 16 Jan 2023 15:37:13 +0000 Message-Id: <20230116153714.554470-5-bruce.richardson@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230116153714.554470-1-bruce.richardson@intel.com> References: <20230116153714.554470-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 --- app/test/test_dmadev.c | 120 ++++++++++++++++++++++------------------- 1 file changed, 64 insertions(+), 56 deletions(-) -- 2.37.2 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 15:37: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: 122107 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 BF8D2423F1; Mon, 16 Jan 2023 16:38:09 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DA8BE42D2A; Mon, 16 Jan 2023 16:37:50 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 99D5A42D28 for ; Mon, 16 Jan 2023 16:37:48 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673883468; x=1705419468; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iDSkM+8xi3b0znao6Wpk15vMoYIl+fTZGYTqHG/9m50=; b=O264Stg9chvJzSKJ52s2AL+L9HGN01ORGOmw9mTj3QHDIJcrvQdmSSUk FU4B1DuFhAsapLpPqk340OZfDmZEdJe40QnYXmVxVGCUvEkWQrE3aCF4M /jinA+lTYZ45nhvVgzXT2OP2wqA0JspiRQZiEvHs43wan/M10L5ljmDt6 U/riPaecv/0ut4D+Db9EdwkwB5OssX5Olbq1AjlGoK6FtNg1ZFYi1+uhh ZyyW+iK1e89BC6qs4pjm+p73C9SRS6tdXhhHBAYygpMxSsQNZGt6zpgCf 0Mkml5imEqB1yFO7e7mTmT6Gwp8Jox67o9QU7m6tB8ui4x7gduD0oeq6i Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="351735383" X-IronPort-AV: E=Sophos;i="5.97,221,1669104000"; d="scan'208";a="351735383" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jan 2023 07:37:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10592"; a="727505495" X-IronPort-AV: E=Sophos;i="5.97,221,1669104000"; d="scan'208";a="727505495" Received: from silpixa00401385.ir.intel.com ([10.237.214.55]) by fmsmga004.fm.intel.com with ESMTP; 16 Jan 2023 07:37:47 -0800 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , Chengwen Feng , Kevin Laatz Subject: [PATCH 5/5] test/dmadev: add tests for stopping and restarting dev Date: Mon, 16 Jan 2023 15:37:14 +0000 Message-Id: <20230116153714.554470-6-bruce.richardson@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230116153714.554470-1-bruce.richardson@intel.com> References: <20230116153714.554470-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 posibilities in the test case. Signed-off-by: Bruce Richardson --- 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",