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 66CAAA00C4; Mon, 25 Jul 2022 12:01:41 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 40E4240684; Mon, 25 Jul 2022 12:01:41 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id E87EF4067C for ; Mon, 25 Jul 2022 12:01:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1658743300; x=1690279300; h=date:from:to:cc:subject:message-id:references: in-reply-to:mime-version; bh=YQx52Z71XUMjWt7Dl4jI9L3IelG7ADnhFbM0zSOpd7Q=; b=bfHSMBLyrxeYTeJCudY/11+zPp/7YK8m2ZOLpUzZKSk+7T+TjSaKN2u1 SM2A4gnHy6fbdNjHYP8gPHzT5pG1cOMSfxyDHEcJ5n3hOUPDx7zRut8i/ lupWINN4beLrf/RDcaPxhjHwtMGy92LJeCF5SMJtvvxgjSIg7gh/7mt1w l5I/2NlmmEt4uC2A3reioHyLkXdY2j/JAT/7ctJk5jLtwU17ADJNTutQP eC2gUdDQSyzV8vCRKK9TM3ljwpUd86p/0PuEFM/xYGlGXC8QzPitBnneU KoGbM7LoMov5qRSFAYwnA9fV2dYy7jDsiKTqYKN5O21hVv/+doRAsnQjX g==; X-IronPort-AV: E=McAfee;i="6400,9594,10418"; a="274524677" X-IronPort-AV: E=Sophos;i="5.93,192,1654585200"; d="scan'208";a="274524677" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2022 03:01:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,192,1654585200"; d="scan'208";a="726107917" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by orsmga004.jf.intel.com with ESMTP; 25 Jul 2022 03:01:38 -0700 Received: from fmsmsx601.amr.corp.intel.com (10.18.126.81) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Mon, 25 Jul 2022 03:01:37 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28 via Frontend Transport; Mon, 25 Jul 2022 03:01:37 -0700 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.103) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.28; Mon, 25 Jul 2022 03:01:35 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I7ktCJVLR0DCKD8yRH8Ec1Od8QyEf8cDmNokZGUn8JjARYmpDW+CqILxdiMg6g+As2MwiXoopsjHypSxaw6Zt0PUb8U8DtCMMosbRwrE6WshrLAsFnK9DrNRd5P3ZpPq1bXbFJSzIRjsotJmjx0H7BSUJ0aEr3eAI/ISuLOr+ArZRkmqNO8FtGd5ujNAAK8uuIHf6Zteoi9lR50EWg6CmhjnpefuDFBCkGYrrHbt2cycXtkolvf+UdLAjLZql9FCp3d2p/c0bkm52inNFtg6ln0KsNsdRLGHRvbc9zUj1t2ovQ31blMyaYVSYSea5xZ29Yv9Te2mw69a/xamKCQFpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=OCA8B4fP37+EYBfz4K/Dzi/u7aR6nO1/bovYlBy9l+Y=; b=n/W7mCz+PkbrThEZ0aZ9YxY287vnmwx7+gZ5SldWJxO4VpK0kUgE1j28RnBTJ6OU07OMMYpBauDcDwigEoZFXpig2lkvk0ljT5xssvIsxHABJg51wmGnxTdMgj3oOiqEDnYBDKiQYYh69h7gae5XEjKBIqQ22cysx8r5/agIREXnkm2lf7hJqKcSHj88KgT5jLiC2yzKzZzX18Y1FEYG+5TXBSLHDBepIvjbJHbQ3rMD9mqw1eGiYFK2Kalj9s2i35WmkbKYNZESQfx+t9Zr3V0df3+7MmJbBfvJPl9O2AUj0qLfLn3xJKFY2FtLk4r4wfsXcUcRPQabp0gC/SzDtA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from MWHPR11MB1629.namprd11.prod.outlook.com (2603:10b6:301:d::21) by MN2PR11MB3984.namprd11.prod.outlook.com (2603:10b6:208:153::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5458.19; Mon, 25 Jul 2022 10:01:32 +0000 Received: from MWHPR11MB1629.namprd11.prod.outlook.com ([fe80::8e4:e1e9:a851:4b0d]) by MWHPR11MB1629.namprd11.prod.outlook.com ([fe80::8e4:e1e9:a851:4b0d%5]) with mapi id 15.20.5458.024; Mon, 25 Jul 2022 10:01:32 +0000 Date: Mon, 25 Jul 2022 11:01:26 +0100 From: Bruce Richardson To: Chengwen Feng CC: , , Subject: Re: [PATCH] examples/dma: support DMA dequeue when no packet received Message-ID: References: <20220725081212.4473-1-fengchengwen@huawei.com> Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20220725081212.4473-1-fengchengwen@huawei.com> X-ClientProxiedBy: LO4P265CA0080.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2bd::10) To MWHPR11MB1629.namprd11.prod.outlook.com (2603:10b6:301:d::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 984423d6-1628-4fe3-315b-08da6e24a6c3 X-MS-TrafficTypeDiagnostic: MN2PR11MB3984:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: J+LJcfWhpg+tbH5NSPrJqZMacszkOrh6XtL8ZGlTRK8iJPwSIVxeGx6DerwDI2CvQS2xk7m3t3bLC/1Zj+xbmEtrl/LMKk0Kfb8rbiK4DNbYJXhLHCXIz5kvlyIw5HqB9BFUkCB62K0xbW4SSVKc9HIzuOrpJIxs8HZ1eJF2vs2X5PaoQIOxwTnUpLJY9DiWjWJYgAwqs7zEGwNA79YxBveVFXDXCUkrpvg+HmF/BZ0Ijigay0RgbnWacVNGFTdn0UZ1/BAQofFJI0p6cclnvIdOTT84RPt03qiPCTMgcU2C9NYdlkS2KegDVZzEv+DXYwwNeUvMXbL7yIzwrV4kCwIzVkVnrU5Bi87cdUllkEtLkUZrV6wQ+H9Yru1nTzOClqKGI20e0GS3EJIZTGRADXDDU3GmZvv51NRpPJpeqM3H49Ok9EqCkBXpDgUXjIS6MiRcoI2me4u+l2QH5AMHRizDoKz8/w4Et9t6p5ERhuiWkYvKFFLtVYC6UAx17c/xnXnhVjeF5H+8gaauW8/ZXbMMELdYNcCQbed4ZKZmkOF7e9O1bX0CDZq30zrrfmyCYPIFnls7JfSgFS53tylhCln6k1IhMzmmWUTMxqInbgN+2Zf6MvEYMf21TTypDH7acLpWD9F1X5lRjPR9nO2T0LcQqZI9Y5ZJ4p8GviuDDAuYmtG1TD0C6kWy05gMTKTaupmhiaG3/+saMnZjn71ig4a0ly+LfvG66R+qVPbE88h8fGyjOK/CXakBDS2AgICa X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR11MB1629.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(136003)(376002)(39860400002)(346002)(396003)(366004)(8936002)(82960400001)(83380400001)(86362001)(6512007)(107886003)(26005)(6506007)(38100700002)(186003)(478600001)(6486002)(316002)(6916009)(41300700001)(44832011)(4326008)(5660300002)(8676002)(66946007)(66556008)(66476007)(2906002)(6666004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?BvNLKtfToGbNBGmoCfDmAzd7C0C6zn2nU7vFIIWX4s09hiW4UEeLkO45m1qD?= =?us-ascii?Q?/UzQoVsdkxXqy6n1obgavRBcKRHe/O4EEz+1G/HqRcMp4pv+TjVYrBT2t2dd?= =?us-ascii?Q?ywCKRypR7b9KSM252nmEHQs7T1WDNqvrf3i5gp3MD8O9ZKWd0X4+IiptJEfI?= =?us-ascii?Q?JVtl8apnokKK0pkEm9fWFUJatbANTXlQt828jkJ2QfJRTrXkSneQPH1ip+DZ?= =?us-ascii?Q?wSIiqd6FA+0wyK8TEmZNM1EuqVMGrTWg+FL1LlvuZcsQGwsvYx4aoE4+4awF?= =?us-ascii?Q?6o51eMfF11fpy1GmDgvbawwaRAxCLkw1d0oDRKN/gBSM7D05iVmY6n5icjJD?= =?us-ascii?Q?ZRKULpq6ycQembgr0C7TFl1bn1HUTpdaSRssfXNesO1v3WNWFfjOvNciHRS9?= =?us-ascii?Q?dKuArVU8e+s6qrr//xjoAgVK/Tz0UiLb04N7qf/0NEOtcoB8bymmxMUDR2on?= =?us-ascii?Q?dQFM4D2eEW8/2CvNPfMzjs5Z9OzTF8GCaX+rfFGSPLgcYIQMTXO4BJiteTGV?= =?us-ascii?Q?ZxN9ohZlZc/E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CoPGVh9uuA?= =?us-ascii?Q?BzgjhgIY97xku41cXiTtKeurw0EvsVZyFhePjbA8U9ydTl2Y/S4tnFgLZZE+?= =?us-ascii?Q?5mNuL54//QanTbKprD8vOX5Ntgya5qfbfgfiIBmjHv7ICkr6HU4EPzhVo3Ka?= =?us-ascii?Q?F0qpxNCQ1gN1m8v1P6VG4DI6E583gyEjmHh4HEKkP9gQNph8PHmhRJVbtnpy?= =?us-ascii?Q?yQ=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: 984423d6-1628-4fe3-315b-08da6e24a6c3 X-MS-Exchange-CrossTenant-AuthSource: MWHPR11MB1629.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2022 10:01:32.4690 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ToNFSWC8YyHcAove+6WnPOTzJl0a3muzr1SiIcpzy9rw0KVsCO9Nb35LUjyjdXzRCVaUnOngPuYPs7YeFAvUdM7P1qIogmSZZfCl1RdpfNA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB3984 X-OriginatorOrg: intel.com 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 On Mon, Jul 25, 2022 at 04:12:12PM +0800, Chengwen Feng wrote: > 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 | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/examples/dma/dmafwd.c b/examples/dma/dmafwd.c > index 67b5a9b22b..e3fe226dff 100644 > --- a/examples/dma/dmafwd.c > +++ b/examples/dma/dmafwd.c > @@ -408,7 +408,7 @@ 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 && copy_mode != COPY_MODE_DMA_NUM) > continue; > > port_statistics.rx[rx_config->rxtx_port] += nb_rx; With this change, we would work through the all the receive packet processing code, and calling all it's functions, just witha packet count of zero. I therefore wonder if it would be cleaner to do the dma_dequeue immediately here on receiving zero, and then jumping to handle those dequeued packets. Something like the diff below. /Bruce @@ -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);