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 4F431A0C41; Fri, 27 Aug 2021 09:14:46 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D4D42406B4; Fri, 27 Aug 2021 09:14:45 +0200 (CEST) Received: from mail-io1-f43.google.com (mail-io1-f43.google.com [209.85.166.43]) by mails.dpdk.org (Postfix) with ESMTP id 0D6744067C for ; Fri, 27 Aug 2021 09:14:45 +0200 (CEST) Received: by mail-io1-f43.google.com with SMTP id z1so7276621ioh.7 for ; Fri, 27 Aug 2021 00:14:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xQU4vcmXhfq4j9QEKT6QKTtNxd2J4pDx7QFQ0NuO1mQ=; b=CAShyEI3ItaYW4yjbHU7ot3CCv5DtHY5SgWGh57WLdHsQBPykSQ0GTC+UZrl/XN/UK aJmY4Vm04E0iNWclWqC/bDmep9hVwn0dLH+WdkijYTUC1BrBTd/wAJGGweoFE7MGIEoX w8H5DVJCidL3zKPfosuXl336zaCOPyaAL8pd+tAqQoXOIZ72Rp5wWFBEof0OLJ4KyDzO Av42+MOg8kaZtl9rHv3Kumnurt9qJz/dDuiAno7Ktndo/jHaH8hyy/UHvmft06PiGuCf ZH92zvJtO6sUlmbo8XUsNHuGEoLsTBOsHnc+yG4Liik8wC3fBB6ZQ6CpSIjTNapaHCdh hVHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xQU4vcmXhfq4j9QEKT6QKTtNxd2J4pDx7QFQ0NuO1mQ=; b=c1+kQ54Lo8BX0n9L9ghDtMOX2KZKQ1AxgYb1gWxoCT3BkaJOcpRFFDIwBoqLE1B6W3 D7GCqstDb+4y21OTb7/pHe6+Be4z8N9zZiNx2XRMfYIwyUXbu80gPRih3vbd/8cZrNq1 k3QRS511289uxM/GYrGngAjyWwIV3zw/xshFSuwA1W3+h2JXLyb7NWUol2/zzGZ7U1dV SO1uXQhEe2Wo+FyTpElkWXVV1OzsyzZJWTRUlZwn9sFxi4cwjBXIUOSnCt75yu3dq1DS V6JydnF4Q9UDEfa2QLxXy/82FH1Wqbs6jqZYcV3jzJt1efGrOVksUgCzgnIgLZu//+aU yPhg== X-Gm-Message-State: AOAM531uOlDxA1RaPeqC+WF+QoHUCMfKlzbSKwClOIdxj4FRuuBw8BJJ IWpz51pQMDu9SUXoDS1SiIJrRfOUbHwufVLR6JA= X-Google-Smtp-Source: ABdhPJxOcz41zNtibhQoHDzdFP4ExTcWahIOMoul4Zp9iUdA+JBH5f2cpkZCaX75keeVN5Eo+MeteHaUBVecJ1M3nb8= X-Received: by 2002:a02:c055:: with SMTP id u21mr6779256jam.113.1630048484285; Fri, 27 Aug 2021 00:14:44 -0700 (PDT) MIME-Version: 1.0 References: <20210826183301.333442-1-bruce.richardson@intel.com> <20210826183301.333442-5-bruce.richardson@intel.com> In-Reply-To: <20210826183301.333442-5-bruce.richardson@intel.com> From: Jerin Jacob Date: Fri, 27 Aug 2021 12:44:17 +0530 Message-ID: To: Bruce Richardson Cc: dpdk-dev , "Walsh, Conor" , "Laatz, Kevin" , Chengwen Feng , Jerin Jacob Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [RFC PATCH 4/7] app/test: add basic dmadev copy 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 Fri, Aug 27, 2021 at 12:03 AM Bruce Richardson wrote: > > For each dmadev instance, perform some basic copy tests to validate that > functionality. > > Signed-off-by: Bruce Richardson > --- > app/test/test_dmadev.c | 157 +++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 157 insertions(+) > > diff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c > index f895556d29..a9f7d34a94 100644 > --- a/app/test/test_dmadev.c > +++ b/app/test/test_dmadev.c > @@ -1,11 +1,14 @@ > /* SPDX-License-Identifier: BSD-3-Clause > * Copyright(c) 2021 HiSilicon Limited. > */ > +#include > > #include > #include > #include > #include > +#include > +#include > > #include "test.h" > > @@ -14,6 +17,11 @@ extern int test_dmadev_api(uint16_t dev_id); > > #define PRINT_ERR(...) print_err(__func__, __LINE__, __VA_ARGS__) > > +#define COPY_LEN 1024 > + > +static struct rte_mempool *pool; > +static uint16_t id_count; > + > static inline int > __rte_format_printf(3, 4) > print_err(const char *func, int lineno, const char *format, ...) > @@ -29,10 +37,123 @@ print_err(const char *func, int lineno, const char *format, ...) > return ret; > } > > +static int > +test_enqueue_copies(int dev_id, uint16_t vchan) > +{ > + unsigned int i; > + uint16_t id; > + > + /* 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 *); > + > + for (i = 0; i < COPY_LEN; i++) > + src_data[i] = rte_rand() & 0xFF; > + > + id = rte_dmadev_copy(dev_id, vchan, src->buf_iova + src->data_off, > + dst->buf_iova + dst->data_off, COPY_LEN, RTE_DMA_OP_FLAG_SUBMIT); > + if (id != id_count) { > + PRINT_ERR("Error with rte_dmadev_copy, got %u, expected %u\n", > + id, id_count); > + return -1; > + } > + > + /* give time for copy to finish, then check it was done */ > + usleep(10); Across series, We have this pattern. IMHO, It is not portable. Can we have a helper function either common lib code or test code to busy poll for completion with timeout? and in test code, we have a much bigger timeout to accommodate all the devices. That way if the driver completes early it can continue to execute and makes it portable. > + > + for (i = 0; i < COPY_LEN; i++) { > + if (dst_data[i] != src_data[i]) { > + PRINT_ERR("Data mismatch at char %u [Got %02x not %02x]\n", i, > + dst_data[i], src_data[i]); > + rte_dmadev_dump(dev_id, stderr); > + return -1; > + } > + } > + > + /* now check completion works */ > + if (rte_dmadev_completed(dev_id, vchan, 1, &id, NULL) != 1) { > + PRINT_ERR("Error with rte_dmadev_completed\n"); > + return -1; > + } > + if (id != id_count) { > + PRINT_ERR("Error:incorrect job id received, %u [expected %u]\n", > + id, id_count); > + return -1; > + } > +