From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Content-Transfer-Encoding: 8bit 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 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", -- 2.37.2