From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id F07F6959 for ; Tue, 7 Oct 2014 10:01:38 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 07 Oct 2014 01:02:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,668,1406617200"; d="scan'208";a="614350366" Received: from irsmsx102.ger.corp.intel.com ([163.33.3.155]) by orsmga002.jf.intel.com with ESMTP; 07 Oct 2014 01:08:46 -0700 Received: from irsmsx109.ger.corp.intel.com (163.33.3.23) by IRSMSX102.ger.corp.intel.com (163.33.3.155) with Microsoft SMTP Server (TLS) id 14.3.195.1; Tue, 7 Oct 2014 09:06:32 +0100 Received: from irsmsx103.ger.corp.intel.com ([169.254.3.175]) by IRSMSX109.ger.corp.intel.com ([169.254.13.253]) with mapi id 14.03.0195.001; Tue, 7 Oct 2014 09:06:31 +0100 From: "Richardson, Bruce" To: "Wiles, Roger Keith (Wind River)" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v2] Adding the routines rte_pktmbuf_alloc_bulk() and rte_pktmbuf_free_bulk() Thread-Index: AQHP4aPPAuWFvlZXTUO5bSvjqhBLu5wkR8Qg Date: Tue, 7 Oct 2014 08:06:30 +0000 Message-ID: <59AF69C657FD0841A61C55336867B5B03441C3F7@IRSMSX103.ger.corp.intel.com> References: <1412627168-78475-1-git-send-email-keith.wiles@windriver.com> In-Reply-To: <1412627168-78475-1-git-send-email-keith.wiles@windriver.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2] Adding the routines rte_pktmbuf_alloc_bulk() and rte_pktmbuf_free_bulk() X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Oct 2014 08:01:39 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Keith Wiles > Sent: Monday, October 06, 2014 9:26 PM > To: dev@dpdk.org > Subject: [dpdk-dev] [PATCH v2] Adding the routines rte_pktmbuf_alloc_bulk= () > and rte_pktmbuf_free_bulk() >=20 > Minor helper routines to mirror the mempool routines and remove the code > from applications. The ixgbe_rxtx_vec.c routine could be changed to use > the ret_pktmbuf_alloc_bulk() routine inplace of rte_mempool_get_bulk(). >=20 Can we maybe remove the reference to the vector driver for this patch. I do= n't believe changes there are what we want to do. /Bruce > Combined __rte_mbuf_raw_alloc_bulk into the rte_pktmbuf_alloc_bulk > function. > Fixed up the comments to state the correct return values. >=20 > Signed-off-by: Keith Wiles > --- > lib/librte_mbuf/rte_mbuf.h | 55 > ++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 55 insertions(+) >=20 > diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h > index 1c6e115..337611b 100644 > --- a/lib/librte_mbuf/rte_mbuf.h > +++ b/lib/librte_mbuf/rte_mbuf.h > @@ -671,6 +671,44 @@ __rte_pktmbuf_prefree_seg(struct rte_mbuf *m) > } >=20 > /** > + * Allocate a list of mbufs from a mempool into a mbuf array. > + * > + * This mbuf list contains one segment per mbuf, which has a length of 0= . The > pointer > + * to data is initialized to have some bytes of headroom in the buffer > + * (if buffer size allows). > + * > + * The routine is just a simple wrapper routine to reduce code in the ap= plication > and > + * provide a cleaner API for multiple mbuf requests. > + * > + * @param mp > + * The mempool from which the mbuf is allocated. > + * @param m_list > + * An array of mbuf pointers, cnt must be less then or equal to the si= ze of the > array. > + * @param cnt > + * Number of slots in the m_list array to fill. > + * @return > + * - cnt is returned if a successful allocation. > + * - <0 negative number is an error code. > + */ > +static inline int __attribute__((always_inline)) > +rte_pktmbuf_alloc_bulk(struct rte_mempool *mp, struct rte_mbuf *m_list[]= , > int16_t cnt) > +{ > + int ret; > + > + ret =3D rte_mempool_get_bulk(mp, (void **)m_list, cnt); > + if ( ret =3D=3D 0 ) { > + ret =3D cnt; > + while(cnt--) { > +#ifdef RTE_MBUF_REFCNT > + rte_mbuf_refcnt_set(*m_list, 1); > +#endif /* RTE_MBUF_REFCNT */ > + rte_pktmbuf_reset(*m_list++); > + } > + } > + return ret; > +} > + > +/** > * Free a segment of a packet mbuf into its original mempool. > * > * Free an mbuf, without parsing other segments in case of chained > @@ -708,6 +746,23 @@ static inline void rte_pktmbuf_free(struct rte_mbuf > *m) > } > } >=20 > +/** > + * Free a list of packet mbufs back into its original mempool. > + * > + * Free a list of mbufs by calling rte_pktmbuf_free() in a loop as a wra= pper > function. > + * > + * @param m_list > + * An array of rte_mbuf pointers to be freed. > + * @param npkts > + * Number of packets to free in m_list. > + */ > +static inline void __attribute__((always_inline)) > +rte_pktmbuf_free_bulk(struct rte_mbuf *m_list[], int16_t npkts) > +{ > + while(npkts--) > + rte_pktmbuf_free(*m_list++); > +} > + > #ifdef RTE_MBUF_REFCNT >=20 > /** > -- > 2.1.0