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 D6A48A0C56; Wed, 1 Sep 2021 21:24:20 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6E5ED40DDE; Wed, 1 Sep 2021 21:24:20 +0200 (CEST) Received: from mail.lysator.liu.se (mail.lysator.liu.se [130.236.254.3]) by mails.dpdk.org (Postfix) with ESMTP id 70F8240686 for ; Wed, 1 Sep 2021 21:24:18 +0200 (CEST) Received: from mail.lysator.liu.se (localhost [127.0.0.1]) by mail.lysator.liu.se (Postfix) with ESMTP id 0D4A740013 for ; Wed, 1 Sep 2021 21:24:18 +0200 (CEST) Received: by mail.lysator.liu.se (Postfix, from userid 1004) id EED2E4000F; Wed, 1 Sep 2021 21:24:17 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on bernadotte.lysator.liu.se X-Spam-Level: X-Spam-Status: No, score=-1.6 required=5.0 tests=ALL_TRUSTED, AWL, NICE_REPLY_A autolearn=disabled version=3.4.2 X-Spam-Score: -1.6 Received: from [192.168.1.59] (h-62-63-215-114.A163.priv.bahnhof.se [62.63.215.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.lysator.liu.se (Postfix) with ESMTPSA id 9F35040005; Wed, 1 Sep 2021 21:24:12 +0200 (CEST) To: Bruce Richardson , dev@dpdk.org Cc: conor.walsh@intel.com, kevin.laatz@intel.com, fengchengwen@huawei.com, jerinj@marvell.com References: <20210826183301.333442-1-bruce.richardson@intel.com> <20210901163216.120087-1-bruce.richardson@intel.com> <20210901163216.120087-3-bruce.richardson@intel.com> From: =?UTF-8?Q?Mattias_R=c3=b6nnblom?= Message-ID: <4ee0f186-47c5-63cc-63ad-df71b5df0f1f@lysator.liu.se> Date: Wed, 1 Sep 2021 21:24:12 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210901163216.120087-3-bruce.richardson@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Virus-Scanned: ClamAV using ClamSMTP Subject: Re: [dpdk-dev] [PATCH v2 2/6] 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" On 2021-09-01 18:32, Bruce Richardson wrote: > 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 > --- > app/test/test_dmadev.c | 81 ++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 81 insertions(+) > > diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c > index bb01e86483..12f7c69629 100644 > --- a/app/test/test_dmadev.c > +++ b/app/test/test_dmadev.c > @@ -2,6 +2,7 @@ > * Copyright(c) 2021 HiSilicon Limited. > * Copyright(c) 2021 Intel Corporation. > */ > +#include > > #include > #include > @@ -13,6 +14,77 @@ > /* from test_dmadev_api.c */ > extern int test_dmadev_api(uint16_t dev_id); > > +#define PRINT_ERR(...) print_err(__func__, __LINE__, __VA_ARGS__) > + > +static inline int Remove inline. > +__rte_format_printf(3, 4) > +print_err(const char *func, int lineno, const char *format, ...) > +{ > + va_list ap; > + int ret; > + > + ret = fprintf(stderr, "In %s:%d - ", func, lineno); Check return code here, and return on error. > + va_start(ap, format); > + ret += vfprintf(stderr, format, ap); ..and here. > + va_end(ap); > + > + return ret; A negative return value in one call and an valid byte count result for the other should produce an error, but here it might not. You might argue this is just test code, but then I suggest not checking the return values at all. > +} > + > +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) { > + PRINT_ERR("Error, no channels available on device id %u\n", dev_id); > + return -1; > + } > + if (rte_dmadev_configure(dev_id, &conf) != 0) { > + PRINT_ERR("Error with rte_dmadev_configure()\n"); > + return -1; > + } > + if (rte_dmadev_vchan_setup(dev_id, vchan, &qconf) < 0) { > + PRINT_ERR("Error with queue configuration\n"); > + return -1; > + } > + > + rte_dmadev_info_get(dev_id, &info); > + if (info.nb_vchans != 1) { > + PRINT_ERR("Error, no configured queues reported on device id %u\n", dev_id); > + return -1; > + } > + > + if (rte_dmadev_start(dev_id) != 0) { > + PRINT_ERR("Error with rte_dmadev_start()\n"); > + return -1; > + } > + if (rte_dmadev_stats_get(dev_id, vchan, &stats) != 0) { > + PRINT_ERR("Error with rte_dmadev_stats_get()\n"); > + return -1; > + } > + if (stats.completed != 0 || stats.submitted != 0 || stats.errors != 0) { > + PRINT_ERR("Error device stats are not all zero: completed = %"PRIu64", submitted = %"PRIu64", errors = %"PRIu64"\n", > + stats.completed, stats.submitted, stats.errors); > + return -1; > + } > + > + rte_dmadev_stop(dev_id); > + rte_dmadev_stats_reset(dev_id, vchan); > + return 0; > +} > + > static int > test_apis(void) > { > @@ -35,10 +107,19 @@ test_apis(void) > static int > test_dmadev(void) > { > + int i; > + > /* basic sanity on dmadev infrastructure */ > if (test_apis() < 0) > return -1; > > + 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) > + return -1; > + > return 0; > } > >