From patchwork Thu Feb 29 13:48:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gowrishankar Muthukrishnan X-Patchwork-Id: 137499 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 D8E6043C3B; Thu, 29 Feb 2024 14:48:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E4FBC42E3B; Thu, 29 Feb 2024 14:48:34 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id A8CA742DEF for ; Thu, 29 Feb 2024 14:48:32 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41TBjJ5M019949; Thu, 29 Feb 2024 05:48:32 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= pfpt0220; bh=MTykTjGPGS8e8YMDqw7LTyqo5meRGbxb6U/ZB7Rf9CI=; b=iaC qqo7y6o7pILmjvrCPUrr0gUdNWue8c7TVcGmaOTii2uNQK2pXq5VoR81ZT/y8OE+ 6XkLzbv1NIfH7St64KbJFIbvvZSvsovHwJnsk/KpHDlGY/5wPfBp3gFylyGIoKrm 0jwICxZ9zVbHYiQ2alMV63Aeu+QNJdjXnJ8MPqfHVQ0/fFvekCUXBAR/2aoizEMp VBdmaimwmoSAJYwCuo7AARfoKJx1fgohWREDNRfT/HRqCMyR3gqjetQpqUauh2gC ymcEMF3GQGqVjawCJq3c+2U43InmreAkVRTETtGSDC1/QI+dmw3M/NfO0E5TYTiM XH++uPmC5P5fedfgZew== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3wjfay2xdr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 29 Feb 2024 05:48:31 -0800 (PST) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Thu, 29 Feb 2024 05:48:30 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Thu, 29 Feb 2024 05:48:30 -0800 Received: from BG-LT91401.marvell.com (unknown [10.193.66.108]) by maili.marvell.com (Postfix) with ESMTP id DB6403F724F; Thu, 29 Feb 2024 05:48:26 -0800 (PST) From: Gowrishankar Muthukrishnan To: CC: , Cheng Jiang , Kevin Laatz , Bruce Richardson , "Pavan Nikhilesh" , Amit Prakash Shukla , Chengwen Feng , Jerin , Gowrishankar Muthukrishnan Subject: [v11 3/4] app/dma-perf: validate copied memory Date: Thu, 29 Feb 2024 19:18:09 +0530 Message-ID: <1ecdf211518dd1da9bcc771d64e82e259cc0681c.1709210551.git.gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: yokFP4L5jhz6ai5NLtnqWnXngXRtqnoI X-Proofpoint-GUID: yokFP4L5jhz6ai5NLtnqWnXngXRtqnoI X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-29_02,2024-02-29_01,2023-05-22_02 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 copied memory to ensure DMA copy did not fail. Signed-off-by: Gowrishankar Muthukrishnan Acked-by: Anoob Joseph Acked-by: Chengwen Feng --- app/test-dma-perf/benchmark.c | 23 ++++++++++++++++++++++- app/test-dma-perf/main.c | 16 +++++++++++----- app/test-dma-perf/main.h | 2 +- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/app/test-dma-perf/benchmark.c b/app/test-dma-perf/benchmark.c index 3c4fddb138..9c155a58cc 100644 --- a/app/test-dma-perf/benchmark.c +++ b/app/test-dma-perf/benchmark.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "main.h" @@ -407,6 +408,11 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs, return -1; } + for (i = 0; i < nr_buf; i++) { + memset(rte_pktmbuf_mtod((*srcs)[i], void *), rte_rand(), buf_size); + memset(rte_pktmbuf_mtod((*dsts)[i], void *), 0, buf_size); + } + if (cfg->transfer_dir == RTE_DMA_DIR_DEV_TO_MEM || cfg->transfer_dir == RTE_DMA_DIR_MEM_TO_DEV) { ext_buf_info = rte_malloc(NULL, sizeof(struct rte_mbuf_ext_shared_info), 0); @@ -445,7 +451,7 @@ setup_memory_env(struct test_configure *cfg, struct rte_mbuf ***srcs, return 0; } -void +int mem_copy_benchmark(struct test_configure *cfg, bool is_dma) { uint32_t i; @@ -463,6 +469,7 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma) uint32_t avg_cycles_total; float mops, mops_total; float bandwidth, bandwidth_total; + int ret = 0; if (setup_memory_env(cfg, &srcs, &dsts) < 0) goto out; @@ -536,6 +543,18 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma) rte_eal_mp_wait_lcore(); + if (cfg->transfer_dir == RTE_DMA_DIR_MEM_TO_MEM) { + for (i = 0; i < (nr_buf / nb_workers) * nb_workers; i++) { + if (memcmp(rte_pktmbuf_mtod(srcs[i], void *), + rte_pktmbuf_mtod(dsts[i], void *), + cfg->buf_size.cur) != 0) { + printf("Copy validation fails for buffer number %d\n", i); + ret = -1; + goto out; + } + } + } + mops_total = 0; bandwidth_total = 0; avg_cycles_total = 0; @@ -601,4 +620,6 @@ mem_copy_benchmark(struct test_configure *cfg, bool is_dma) rte_dma_stop(ldm->dma_ids[i]); } } + + return ret; } diff --git a/app/test-dma-perf/main.c b/app/test-dma-perf/main.c index 051f76a6f9..df05bcd7df 100644 --- a/app/test-dma-perf/main.c +++ b/app/test-dma-perf/main.c @@ -101,20 +101,24 @@ open_output_csv(const char *rst_path_ptr) return 0; } -static void +static int run_test_case(struct test_configure *case_cfg) { + int ret = 0; + switch (case_cfg->test_type) { case TEST_TYPE_DMA_MEM_COPY: - mem_copy_benchmark(case_cfg, true); + ret = mem_copy_benchmark(case_cfg, true); break; case TEST_TYPE_CPU_MEM_COPY: - mem_copy_benchmark(case_cfg, false); + ret = mem_copy_benchmark(case_cfg, false); break; default: printf("Unknown test type. %s\n", case_cfg->test_type_str); break; } + + return ret; } static void @@ -159,8 +163,10 @@ run_test(uint32_t case_id, struct test_configure *case_cfg) case_cfg->scenario_id++; printf("\nRunning scenario %d\n", case_cfg->scenario_id); - run_test_case(case_cfg); - output_csv(false); + if (run_test_case(case_cfg) < 0) + printf("\nTest fails! skipping this scenario.\n"); + else + output_csv(false); if (var_entry->op == OP_ADD) var_entry->cur += var_entry->incr; diff --git a/app/test-dma-perf/main.h b/app/test-dma-perf/main.h index 745c24b7fe..1123e7524a 100644 --- a/app/test-dma-perf/main.h +++ b/app/test-dma-perf/main.h @@ -66,6 +66,6 @@ struct test_configure { struct test_vchan_dev_config vchan_dev; }; -void mem_copy_benchmark(struct test_configure *cfg, bool is_dma); +int mem_copy_benchmark(struct test_configure *cfg, bool is_dma); #endif /* MAIN_H */