From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84AA4C433F5 for ; Tue, 7 Sep 2021 16:55:34 +0000 (UTC) Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by mail.kernel.org (Postfix) with ESMTP id 2FA2760EBA for ; Tue, 7 Sep 2021 16:55:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2FA2760EBA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dpdk.org Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2DDDA411D6; Tue, 7 Sep 2021 18:55:21 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mails.dpdk.org (Postfix) with ESMTP id 031A2411D3 for ; Tue, 7 Sep 2021 18:55:18 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10099"; a="220311442" X-IronPort-AV: E=Sophos;i="5.85,274,1624345200"; d="scan'208";a="220311442" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Sep 2021 09:49:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,274,1624345200"; d="scan'208";a="469268736" Received: from silpixa00399126.ir.intel.com ([10.237.223.29]) by orsmga007.jf.intel.com with ESMTP; 07 Sep 2021 09:49:46 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: conor.walsh@intel.com, kevin.laatz@intel.com, fengchengwen@huawei.com, jerinj@marvell.com, Bruce Richardson Date: Tue, 7 Sep 2021 17:49:20 +0100 Message-Id: <20210907164925.291904-4-bruce.richardson@intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210907164925.291904-1-bruce.richardson@intel.com> References: <20210826183301.333442-1-bruce.richardson@intel.com> <20210907164925.291904-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 3/8] app/test: add basic dmadev instance tests 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 Sender: "dev" Run basic sanity tests for configuring, starting and stopping a dmadev instance to help validate drivers. This also provides the framework for future tests for data-path operation. Signed-off-by: Bruce Richardson Reviewed-by: Conor Walsh --- app/test/test_dmadev.c | 72 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c index 92c47fc041..691785b74f 100644 --- a/app/test/test_dmadev.c +++ b/app/test/test_dmadev.c @@ -3,6 +3,8 @@ * Copyright(c) 2021 Intel Corporation. */ +#include + #include #include @@ -11,6 +13,65 @@ /* from test_dmadev_api.c */ extern int test_dmadev_api(uint16_t dev_id); +#define ERR_RETURN(...) do { print_err(__func__, __LINE__, __VA_ARGS__); return -1; } while (0) + +static void +__rte_format_printf(3, 4) +print_err(const char *func, int lineno, const char *format, ...) +{ + va_list ap; + + fprintf(stderr, "In %s:%d - ", func, lineno); + va_start(ap, format); + vfprintf(stderr, format, ap); + va_end(ap); +} + +static int +test_dmadev_instance(uint16_t dev_id) +{ +#define TEST_RINGSIZE 512 + struct rte_dmadev_stats stats; + struct rte_dmadev_info info; + const struct rte_dmadev_conf conf = { .nb_vchans = 1}; + const struct rte_dmadev_vchan_conf qconf = { + .direction = RTE_DMA_DIR_MEM_TO_MEM, + .nb_desc = TEST_RINGSIZE, + }; + const int vchan = 0; + + printf("\n### Test dmadev instance %u\n", dev_id); + + rte_dmadev_info_get(dev_id, &info); + if (info.max_vchans < 1) + ERR_RETURN("Error, no channels available on device id %u\n", dev_id); + + if (rte_dmadev_configure(dev_id, &conf) != 0) + ERR_RETURN("Error with rte_dmadev_configure()\n"); + + if (rte_dmadev_vchan_setup(dev_id, vchan, &qconf) < 0) + ERR_RETURN("Error with queue configuration\n"); + + rte_dmadev_info_get(dev_id, &info); + if (info.nb_vchans != 1) + ERR_RETURN("Error, no configured queues reported on device id %u\n", dev_id); + + if (rte_dmadev_start(dev_id) != 0) + ERR_RETURN("Error with rte_dmadev_start()\n"); + + if (rte_dmadev_stats_get(dev_id, vchan, &stats) != 0) + ERR_RETURN("Error with rte_dmadev_stats_get()\n"); + + if (stats.completed != 0 || stats.submitted != 0 || stats.errors != 0) + ERR_RETURN("Error device stats are not all zero: completed = %"PRIu64", " + "submitted = %"PRIu64", errors = %"PRIu64"\n", + stats.completed, stats.submitted, stats.errors); + + rte_dmadev_stop(dev_id); + rte_dmadev_stats_reset(dev_id, vchan); + return 0; +} + static int test_apis(void) { @@ -33,9 +94,18 @@ test_apis(void) static int test_dmadev(void) { + int i; + /* basic sanity on dmadev infrastructure */ if (test_apis() < 0) - return -1; + ERR_RETURN("Error performing API tests\n"); + + if (rte_dmadev_count() == 0) + return TEST_SKIPPED; + + for (i = 0; i < RTE_DMADEV_MAX_DEVS; i++) + if (rte_dmadevices[i].state == RTE_DMADEV_ATTACHED && test_dmadev_instance(i) < 0) + ERR_RETURN("Error, test failure for device %d\n", i); return 0; } -- 2.30.2