From 242c01792cbc6a75299951e0177c014b7b74fc6c Mon Sep 17 00:00:00 2001 From: Rakesh Kudurumalla Date: Tue, 20 Jul 2021 22:20:52 +0530 Subject: [PATCH] test: avoid hang if queues are full and Tx fails [ upstream commit 36edf3cc9ba18fb33c880518f5bb67765c3b99d4 ] Current pmd_perf_autotest() in continuous mode tries to enqueue MAX_TRAFFIC_BURST completely before starting the test. Some drivers cannot accept complete MAX_TRAFFIC_BURST even though rx+tx desc count can fit it. This patch changes behaviour to stop enqueuing after few retries. Fixes: 002ade70e933 ("app/test: measure cycles per packet in Rx/Tx") Signed-off-by: Rakesh Kudurumalla --- app/test/test_pmd_perf.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/test/test_pmd_perf.c b/app/test/test_pmd_perf.c index 0aa9dc1b1c..4094057b27 100644 --- a/app/test/test_pmd_perf.c +++ b/app/test/test_pmd_perf.c @@ -454,6 +454,7 @@ main_loop(__rte_unused void *args) #define PACKET_SIZE 64 #define FRAME_GAP 12 #define MAC_PREAMBLE 8 +#define MAX_RETRY_COUNT 5 struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; unsigned lcore_id; unsigned i, portid, nb_rx = 0, nb_tx = 0; @@ -461,6 +462,8 @@ main_loop(__rte_unused void *args) int pkt_per_port; uint64_t diff_tsc; uint64_t packets_per_second, total_packets; + int retry_cnt = 0; + int free_pkt = 0; lcore_id = rte_lcore_id(); conf = &lcore_conf[lcore_id]; @@ -478,10 +481,19 @@ main_loop(__rte_unused void *args) nb_tx = RTE_MIN(MAX_PKT_BURST, num); nb_tx = rte_eth_tx_burst(portid, 0, &tx_burst[idx], nb_tx); + if (nb_tx == 0) + retry_cnt++; num -= nb_tx; idx += nb_tx; + if (retry_cnt == MAX_RETRY_COUNT) { + retry_cnt = 0; + break; + } } } + for (free_pkt = idx; free_pkt < (MAX_TRAFFIC_BURST * conf->nb_ports); + free_pkt++) + rte_pktmbuf_free(tx_burst[free_pkt]); printf("Total packets inject to prime ports = %u\n", idx); packets_per_second = (link_mbps * 1000 * 1000) /