From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from wes1-so1.wedos.net (wes1-so1.wedos.net [46.28.106.15]) by dpdk.org (Postfix) with ESMTP id 97A195A26 for ; Mon, 23 May 2016 14:42:36 +0200 (CEST) Received: from pcviktorin.fit.vutbr.cz (pcviktorin.fit.vutbr.cz [147.229.13.147]) by wes1-so1.wedos.net (Postfix) with ESMTPSA id 3rCyqc2DBMz8n8; Mon, 23 May 2016 14:42:36 +0200 (CEST) Date: Mon, 23 May 2016 14:40:55 +0200 From: Jan Viktorin To: David Hunt Cc: dev@dpdk.org, olivier.matz@6wind.com, yuanhan.liu@linux.intel.com, pmatilai@redhat.com Message-ID: <20160523144055.29288cd5@pcviktorin.fit.vutbr.cz> In-Reply-To: <1463665501-18325-4-git-send-email-david.hunt@intel.com> References: <1463665501-18325-4-git-send-email-david.hunt@intel.com> Organization: RehiveTech MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [dpdk-dev, v5, 3/3] mbuf: get default mempool handler from configuration 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: Mon, 23 May 2016 12:42:36 -0000 On Thu, 19 May 2016 14:45:01 +0100 David Hunt wrote: > By default, the mempool handler used for mbuf allocations is a multi > producer and multi consumer ring. We could imagine a target (maybe some > network processors?) that provides an hardware-assisted pool > mechanism. In this case, the default configuration for this architecture > would contain a different value for RTE_MBUF_DEFAULT_MEMPOOL_HANDLER. > > Signed-off-by: David Hunt > Signed-off-by: Olivier Matz > > --- > config/common_base | 1 + > lib/librte_mbuf/rte_mbuf.c | 21 +++++++++++++++++---- > 2 files changed, 18 insertions(+), 4 deletions(-) > > diff --git a/config/common_base b/config/common_base > index 3535c6e..5cf5e52 100644 > --- a/config/common_base > +++ b/config/common_base > @@ -394,6 +394,7 @@ CONFIG_RTE_LIBRTE_MEMPOOL_DEBUG=n > # > CONFIG_RTE_LIBRTE_MBUF=y > CONFIG_RTE_LIBRTE_MBUF_DEBUG=n > +CONFIG_RTE_MBUF_DEFAULT_MEMPOOL_HANDLER="ring_mp_mc" > CONFIG_RTE_MBUF_REFCNT_ATOMIC=y > CONFIG_RTE_PKTMBUF_HEADROOM=128 > > diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c > index eec1456..5dcdc05 100644 > --- a/lib/librte_mbuf/rte_mbuf.c > +++ b/lib/librte_mbuf/rte_mbuf.c > @@ -153,6 +153,7 @@ rte_pktmbuf_pool_create(const char *name, unsigned n, > unsigned cache_size, uint16_t priv_size, uint16_t data_room_size, > int socket_id) > { > + struct rte_mempool *mp; > struct rte_pktmbuf_pool_private mbp_priv; > unsigned elt_size; > > @@ -167,10 +168,22 @@ rte_pktmbuf_pool_create(const char *name, unsigned n, > mbp_priv.mbuf_data_room_size = data_room_size; > mbp_priv.mbuf_priv_size = priv_size; > > - return rte_mempool_create(name, n, elt_size, > - cache_size, sizeof(struct rte_pktmbuf_pool_private), > - rte_pktmbuf_pool_init, &mbp_priv, rte_pktmbuf_init, NULL, > - socket_id, 0); > + mp = rte_mempool_create_empty(name, n, elt_size, cache_size, > + sizeof(struct rte_pktmbuf_pool_private), socket_id, 0); > + if (mp == NULL) > + return NULL; > + > + rte_mempool_set_handler(mp, RTE_MBUF_DEFAULT_MEMPOOL_HANDLER); Check for a failure is missing here. Especially -EEXIST. > + rte_pktmbuf_pool_init(mp, &mbp_priv); > + > + if (rte_mempool_populate_default(mp) < 0) { > + rte_mempool_free(mp); > + return NULL; > + } > + > + rte_mempool_obj_iter(mp, rte_pktmbuf_init, NULL); > + > + return mp; > } > > /* do some sanity checks on a mbuf: panic if it fails */ -- Jan Viktorin E-mail: Viktorin@RehiveTech.com System Architect Web: www.RehiveTech.com RehiveTech Brno, Czech Republic