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 AFABAA00C4; Mon, 25 Jul 2022 14:29:29 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1D8B7410FA; Mon, 25 Jul 2022 14:29:29 +0200 (CEST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 4BA7340684 for ; Mon, 25 Jul 2022 14:29:27 +0200 (CEST) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Lrzlc0b08zWfBY; Mon, 25 Jul 2022 20:25:32 +0800 (CST) Received: from localhost.localdomain (10.67.165.24) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 25 Jul 2022 20:28:58 +0800 From: Chengwen Feng To: CC: , , Subject: [PATCH v2] examples/dma: support DMA dequeue when no packet received Date: Mon, 25 Jul 2022 20:22:00 +0800 Message-ID: <20220725122200.47851-1-fengchengwen@huawei.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.67.165.24] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml500024.china.huawei.com (7.185.36.10) X-CFilter-Loop: Reflected 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 Currently the example using DMA in asynchronous mode, which are: nb_rx = rte_eth_rx_burst(); if (nb_rx == 0) continue; ... dma_enqueue(); // enqueue the received packets copy request nb_cpl = dma_dequeue(); // get copy completed packets ... There are no waiting inside dma_dequeue(), and this is why it's called asynchronus. If there are no packet received, it won't call dma_dequeue(), but some packets may still in the DMA queue which enqueued in last cycle. As a result, when the traffic is stopped, the sent packets and received packets are unbalanced from the perspective of the traffic generator. The patch supports DMA dequeue when no packet received, it helps to judge the test result by comparing the sent packets with the received packets on traffic generator sides. Signed-off-by: Chengwen Feng --- examples/dma/dmafwd.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/dma/dmafwd.c b/examples/dma/dmafwd.c index 67b5a9b22b..9fc46f5255 100644 --- a/examples/dma/dmafwd.c +++ b/examples/dma/dmafwd.c @@ -408,8 +408,13 @@ dma_rx_port(struct rxtx_port_config *rx_config) nb_rx = rte_eth_rx_burst(rx_config->rxtx_port, i, pkts_burst, MAX_PKT_BURST); - if (nb_rx == 0) + if (nb_rx == 0) { + if (copy_mode == COPY_MODE_DMA_NUM && + (nb_rx = dma_dequeue(pkts_burst, pkts_burst_copy, + MAX_PKT_BURST, rx_config->dmadev_ids[i])) > 0) + goto handle_tx; continue; + } port_statistics.rx[rx_config->rxtx_port] += nb_rx; @@ -450,6 +455,7 @@ dma_rx_port(struct rxtx_port_config *rx_config) pkts_burst_copy[j]); } +handle_tx: rte_mempool_put_bulk(dma_pktmbuf_pool, (void *)pkts_burst, nb_rx); -- 2.33.0