From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 2AE6941DB8;
	Thu,  2 Mar 2023 21:22:35 +0100 (CET)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 58F0442BFE;
	Thu,  2 Mar 2023 21:22:04 +0100 (CET)
Received: from mga14.intel.com (mga14.intel.com [192.55.52.115])
 by mails.dpdk.org (Postfix) with ESMTP id 80F2640E09
 for <dev@dpdk.org>; Thu,  2 Mar 2023 21:21:59 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple;
 d=intel.com; i=@intel.com; q=dns/txt; s=Intel;
 t=1677788519; x=1709324519;
 h=from:to:cc:subject:date:message-id:in-reply-to:
 references:mime-version:content-transfer-encoding;
 bh=qcSkWQyXmk4eqfvGn8rQEt/phgukVzSPCPWhv5qVfwc=;
 b=iGs9LX9BL4zgBQ9u97sDTEFBqKYWQeB2sCUpovLYO5W/LcxvwbPwhU4v
 Oym+ejgOmBZGdQ2muhFeFWajNkGGvX/5KDdp/UG4pBXNepL3jbxNqlTn8
 iTrTGFVcwJrdz9kZuKmcTefIJaMExvKmeF0Ix4MgXpnYfzbEFVX36WoQY
 nW3PHLsge/egbKnisBkUJyHe1RdwrumWXaHVsnPXTREN2iBxOhXDucP/x
 sYlbmvr6M3GmdxLpco4j+YrWjdpQxPMcUaQQ2WFYEkxqK8ql1zNZxE1JB
 JoZqXnzgH2hp1ELKfaS3o5/xAMgwzyPVpm/1vshDrAEnYRLvFM5LDSAc8 A==;
X-IronPort-AV: E=McAfee;i="6500,9779,10637"; a="334871172"
X-IronPort-AV: E=Sophos;i="5.98,228,1673942400"; d="scan'208";a="334871172"
Received: from orsmga008.jf.intel.com ([10.7.209.65])
 by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 02 Mar 2023 12:21:59 -0800
X-ExtLoop1: 1
X-IronPort-AV: E=McAfee;i="6500,9779,10637"; a="705398106"
X-IronPort-AV: E=Sophos;i="5.98,228,1673942400"; d="scan'208";a="705398106"
Received: from unknown (HELO csl-npg-qt0.la.intel.com) ([10.233.181.103])
 by orsmga008.jf.intel.com with ESMTP; 02 Mar 2023 12:21:58 -0800
From: Hernan Vargas <hernan.vargas@intel.com>
To: dev@dpdk.org, gakhil@marvell.com, trix@redhat.com,
 maxime.coquelin@redhat.com
Cc: nicolas.chautru@intel.com, qi.z.zhang@intel.com,
 Hernan Vargas <hernan.vargas@intel.com>
Subject: [PATCH v3 05/17] test/bbdev: add timeout for latency tests
Date: Thu,  2 Mar 2023 12:21:59 -0800
Message-Id: <20230302202211.170017-6-hernan.vargas@intel.com>
X-Mailer: git-send-email 2.37.1
In-Reply-To: <20230302202211.170017-1-hernan.vargas@intel.com>
References: <20230302202211.170017-1-hernan.vargas@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 <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

Add a timeout to force exit the latency tests in case dequeue never
happens.

Signed-off-by: Hernan Vargas <hernan.vargas@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 app/test-bbdev/test_bbdev_perf.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/app/test-bbdev/test_bbdev_perf.c b/app/test-bbdev/test_bbdev_perf.c
index 088fc055a148..4de3d937a53d 100644
--- a/app/test-bbdev/test_bbdev_perf.c
+++ b/app/test-bbdev/test_bbdev_perf.c
@@ -26,6 +26,7 @@
 
 #define MAX_QUEUES RTE_MAX_LCORE
 #define TEST_REPETITIONS 100
+#define TIME_OUT_POLL 1e8
 #define WAIT_OFFLOAD_US 1000
 
 #ifdef RTE_BASEBAND_FPGA_LTE_FEC
@@ -4544,6 +4545,7 @@ latency_test_ldpc_dec(struct rte_mempool *mempool,
 
 	for (i = 0, dequeued = 0; dequeued < num_to_process; ++i) {
 		uint16_t enq = 0, deq = 0;
+		uint32_t time_out = 0;
 		bool first_time = true;
 		last_time = 0;
 
@@ -4595,7 +4597,8 @@ latency_test_ldpc_dec(struct rte_mempool *mempool,
 				last_time = rte_rdtsc_precise() - start_time;
 				first_time = false;
 			}
-		} while (unlikely(burst_sz != deq));
+			time_out++;
+		} while ((burst_sz != deq) && (time_out < TIME_OUT_POLL));
 
 		*max_time = RTE_MAX(*max_time, last_time);
 		*min_time = RTE_MIN(*min_time, last_time);
@@ -4604,7 +4607,12 @@ latency_test_ldpc_dec(struct rte_mempool *mempool,
 		if (extDdr)
 			retrieve_harq_ddr(dev_id, queue_id, ops_enq, burst_sz);
 
-		if (test_vector.op_type != RTE_BBDEV_OP_NONE) {
+		if (burst_sz != deq) {
+			struct rte_bbdev_info info;
+			ret = TEST_FAILED;
+			rte_bbdev_info_get(dev_id, &info);
+			TEST_ASSERT_SUCCESS(ret, "Dequeue timeout!");
+		} else if (test_vector.op_type != RTE_BBDEV_OP_NONE) {
 			ret = validate_ldpc_dec_op(ops_deq, burst_sz, ref_op,
 					vector_mask);
 			TEST_ASSERT_SUCCESS(ret, "Validation failed!");
@@ -4630,6 +4638,7 @@ latency_test_enc(struct rte_mempool *mempool,
 
 	for (i = 0, dequeued = 0; dequeued < num_to_process; ++i) {
 		uint16_t enq = 0, deq = 0;
+		uint32_t time_out = 0;
 		bool first_time = true;
 		last_time = 0;
 
@@ -4665,13 +4674,18 @@ latency_test_enc(struct rte_mempool *mempool,
 				last_time += rte_rdtsc_precise() - start_time;
 				first_time = false;
 			}
-		} while (unlikely(burst_sz != deq));
+			time_out++;
+		} while ((burst_sz != deq) && (time_out < TIME_OUT_POLL));
 
 		*max_time = RTE_MAX(*max_time, last_time);
 		*min_time = RTE_MIN(*min_time, last_time);
 		*total_time += last_time;
-
-		if (test_vector.op_type != RTE_BBDEV_OP_NONE) {
+		if (burst_sz != deq) {
+			struct rte_bbdev_info info;
+			ret = TEST_FAILED;
+			rte_bbdev_info_get(dev_id, &info);
+			TEST_ASSERT_SUCCESS(ret, "Dequeue timeout!");
+		} else if (test_vector.op_type != RTE_BBDEV_OP_NONE) {
 			ret = validate_enc_op(ops_deq, burst_sz, ref_op);
 			TEST_ASSERT_SUCCESS(ret, "Validation failed!");
 		}
-- 
2.37.1