From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 7E7295B34 for ; Thu, 8 Mar 2018 14:52:51 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Mar 2018 05:52:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,441,1515484800"; d="scan'208";a="26294155" Received: from dpdk51.sh.intel.com ([10.67.110.184]) by fmsmga002.fm.intel.com with ESMTP; 08 Mar 2018 05:52:49 -0800 From: Qi Zhang To: dev@dpdk.org Cc: magnus.karlsson@intel.com, bjorn.topel@intel.com, Qi Zhang Date: Thu, 8 Mar 2018 21:52:44 +0800 Message-Id: <20180308135249.28187-3-qi.z.zhang@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180308135249.28187-1-qi.z.zhang@intel.com> References: <20180308135249.28187-1-qi.z.zhang@intel.com> Subject: [dpdk-dev] [RFC v2 2/7] lib/mbuf: enable parse flags when create mempool X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Mar 2018 13:52:51 -0000 This give the option that applicaiton can configure each memory chunk's size precisely. (by MEMPOOL_F_NO_SPREAD). Signed-off-by: Qi Zhang --- lib/librte_mbuf/rte_mbuf.c | 15 ++++++++++++--- lib/librte_mbuf/rte_mbuf.h | 8 +++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c index 091d388d3..5fd91c87c 100644 --- a/lib/librte_mbuf/rte_mbuf.c +++ b/lib/librte_mbuf/rte_mbuf.c @@ -125,7 +125,7 @@ rte_pktmbuf_init(struct rte_mempool *mp, struct rte_mempool * __rte_experimental rte_pktmbuf_pool_create_by_ops(const char *name, unsigned int n, unsigned int cache_size, uint16_t priv_size, uint16_t data_room_size, - int socket_id, const char *ops_name) + unsigned int flags, int socket_id, const char *ops_name) { struct rte_mempool *mp; struct rte_pktmbuf_pool_private mbp_priv; @@ -145,7 +145,7 @@ rte_pktmbuf_pool_create_by_ops(const char *name, unsigned int n, mbp_priv.mbuf_priv_size = priv_size; mp = rte_mempool_create_empty(name, n, elt_size, cache_size, - sizeof(struct rte_pktmbuf_pool_private), socket_id, 0); + sizeof(struct rte_pktmbuf_pool_private), socket_id, flags); if (mp == NULL) return NULL; @@ -179,9 +179,18 @@ rte_pktmbuf_pool_create(const char *name, unsigned int n, int socket_id) { return rte_pktmbuf_pool_create_by_ops(name, n, cache_size, priv_size, - data_room_size, socket_id, NULL); + data_room_size, 0, socket_id, NULL); } +/* helper to create a mbuf pool with NO_SPREAD */ +struct rte_mempool * +rte_pktmbuf_pool_create_with_flags(const char *name, unsigned int n, + unsigned int cache_size, uint16_t priv_size, uint16_t data_room_size, + unsigned int flags, int socket_id) +{ + return rte_pktmbuf_pool_create_by_ops(name, n, cache_size, priv_size, + data_room_size, flags, socket_id, NULL); +} /* do some sanity checks on a mbuf: panic if it fails */ void rte_mbuf_sanity_check(const struct rte_mbuf *m, int is_header) diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 62740254d..6f6af42a8 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -1079,6 +1079,12 @@ 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 * +rte_pktmbuf_pool_create_with_flags(const char *name, unsigned int n, + unsigned cache_size, uint16_t priv_size, uint16_t data_room_size, + unsigned flags, int socket_id); + + /** * Create a mbuf pool with a given mempool ops name * @@ -1119,7 +1125,7 @@ rte_pktmbuf_pool_create(const char *name, unsigned n, struct rte_mempool * __rte_experimental rte_pktmbuf_pool_create_by_ops(const char *name, unsigned int n, unsigned int cache_size, uint16_t priv_size, uint16_t data_room_size, - int socket_id, const char *ops_name); + unsigned int flags, int socket_id, const char *ops_name); /** * Get the data room size of mbufs stored in a pktmbuf_pool -- 2.13.6