From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id B5AA5A00E6 for ; Wed, 20 Mar 2019 12:57:44 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BC7CB568A; Wed, 20 Mar 2019 12:57:43 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id AC87B2C60 for ; Wed, 20 Mar 2019 12:57:41 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Mar 2019 04:57:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,248,1549958400"; d="scan'208";a="308782663" Received: from irsmsx105.ger.corp.intel.com ([163.33.3.28]) by orsmga005.jf.intel.com with ESMTP; 20 Mar 2019 04:57:39 -0700 Received: from irsmsx102.ger.corp.intel.com ([169.254.2.146]) by irsmsx105.ger.corp.intel.com ([169.254.7.210]) with mapi id 14.03.0415.000; Wed, 20 Mar 2019 11:57:38 +0000 From: "Van Haaren, Harry" To: "songj@zctt.com" , "users@dpdk.org" Thread-Topic: [dpdk-users] How to getting first objects from a rte_mempool buffer every time? Thread-Index: AdTfCehwCRpx+mXASbmbr1MqpO4QZwAB+XNg Date: Wed, 20 Mar 2019 11:57:38 +0000 Message-ID: References: <000001d4df09$e970f1e0$bc52d5a0$@zctt.com>+86DF114D4D1219DB In-Reply-To: <000001d4df09$e970f1e0$bc52d5a0$@zctt.com>+86DF114D4D1219DB Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYTg0NDI4OTUtYWZjNy00YzBlLWFiYjktNTJmZmNmYTYwMDFjIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiNVVIcHB3a3FveEFaa01SMHA3bWtrcGI0Sm1HbGlOYzl3NnFkR0dlemVpbk1cL2Q0N2VkS1BoZDhRNERVQkJ5QTYifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="iso-2022-jp" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-users] How to getting first objects from a rte_mempool buffer every time? X-BeenThere: users@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK usage discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: users-bounces@dpdk.org Sender: "users" > -----Original Message----- > From: users [mailto:users-bounces@dpdk.org] On Behalf Of ?? > Sent: Wednesday, March 20, 2019 10:45 AM > To: users@dpdk.org > Subject: [dpdk-users] How to getting first objects from a rte_mempool buf= fer > every time? >=20 > Hi all=1B$B!$=1B(B Hi Jie, > I have a pcap file that contained 100 IP packets. I can send them by DPDK= by > below steps: >=20 > 1. I create a rte_mempool buffer by rte_pktmbuf_pool_create. load the= se > 100 packets into this buffer. >=20 > 2. call rte_mempool_get_bulk to getting packets form rte_mempool buff= er > into rte_mbuf buffer, >=20 > 3. put rte_mbuf buffer into rte_eth_tx_burst for sending . >=20 > The pcap packets can be sent out from 1 to 100 Ok. >=20 > Now I want to send the only first 10 packets every time, >=20 > rte_mempool_get_bulk can get 1-10 objects, but next time it will get 11-2= 0 > objects. >=20 > I don=1B$B!G=1B(Bt know if there is easy way to getting first 10 objects = from > rte_mempool buffer every time? The mempool data-structure is not designed for this usage. If you require the first 10 items, I recommend dequeueing them from the mempool once (as you have described above), and then caching them in anothe= r data-structure to "loop" over them. Typically an rte_ring would work well here, with the 10 items being dequeue= d and re-enqueued over-and-over again to loop. Note; when sending an mbuf via Ethdev, the refcount will be decremented, and possibly the mbuf will be free()-ed and returned to the mempool. If you wish to "keep" the mbuf in the rte_ring cache, consider incrementing the refcount of the mbuf every time before you TX it - the result will be t= hat the mbuf is not freed back to the mempool, and remain valid to TX again. > Thanks > Jie Hope that helps! -Harry