From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f176.google.com (mail-wi0-f176.google.com [209.85.212.176]) by dpdk.org (Postfix) with ESMTP id 62A04C36A for ; Wed, 22 Apr 2015 11:57:49 +0200 (CEST) Received: by widdi4 with SMTP id di4so50925718wid.0 for ; Wed, 22 Apr 2015 02:57:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mOEZ1W4EvkTlYelhg6LjMWJKaBUGohrSwjwC696u6co=; b=Zb0z9E9GrWNWzmhmXx8TIOUt9GnCz3nwUJXRskeSQWtTwmoXSzNUGZIlG1NCWOQYuU yR9jFCkH1IGBcHzsHKwlSG5qCBh2uX1NNhewbXd/jgzyW31z5lNtArPgZCMJAJjIY/CS jyCWzARAnzu3afqS90bgIronUHQsItHYOpiGHfYTUjXazt72gyCt4Y/knkJbG9zi97H1 eoKwaICpgf2wqrrUn5ZmkdWkuyD0PX+tr1PD3zwdOfv/RceLqvjQbgzR8spJKUyAENpz Ru6mKyTcxyiyWzAM3DV6UjDiK/FcLOwic6Yyw/juD8J01/VVopqbvBbP8J7Xtm/wqp/f +5bg== X-Gm-Message-State: ALoCoQk0j34pk0MM6Q8Vw9TSfqW0vxV8B+KZYHPGp5rVPgdUsYbrP2oEP0aMFUUSW8WOT5hidvPK X-Received: by 10.194.190.49 with SMTP id gn17mr50378465wjc.11.1429696669290; Wed, 22 Apr 2015 02:57:49 -0700 (PDT) Received: from glumotte.dev.6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id yr1sm6570006wjc.37.2015.04.22.02.57.48 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 22 Apr 2015 02:57:48 -0700 (PDT) From: Olivier Matz To: dev@dpdk.org Date: Wed, 22 Apr 2015 11:57:23 +0200 Message-Id: <1429696650-9043-7-git-send-email-olivier.matz@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1429696650-9043-1-git-send-email-olivier.matz@6wind.com> References: <1429610122-30943-1-git-send-email-olivier.matz@6wind.com> <1429696650-9043-1-git-send-email-olivier.matz@6wind.com> Subject: [dpdk-dev] [PATCH v6 06/13] mbuf: introduce a new helper to create a mbuf pool 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: Wed, 22 Apr 2015 09:57:49 -0000 Add a new wrapper to rte_mempool_create() to simplify the creation of a packet mbuf pool. This wrapper can be used if there is no specific mempool flags, and no specific mbuf or pool constructor function, which is most of the use cases. Signed-off-by: Olivier Matz Acked-by: Neil Horman --- doc/guides/rel_notes/updating_apps.rst | 4 ++++ lib/librte_mbuf/rte_mbuf.c | 21 ++++++++++++++++++ lib/librte_mbuf/rte_mbuf.h | 40 ++++++++++++++++++++++++++++++++++ lib/librte_mbuf/rte_mbuf_version.map | 8 +++++++ 4 files changed, 73 insertions(+) diff --git a/doc/guides/rel_notes/updating_apps.rst b/doc/guides/rel_notes/updating_apps.rst index f513615..f4dd196 100644 --- a/doc/guides/rel_notes/updating_apps.rst +++ b/doc/guides/rel_notes/updating_apps.rst @@ -16,6 +16,10 @@ DPDK 2.0 to DPDK 2.1 rte_pktmbuf_pool_private structure and pass it to rte_pktmbuf_pool_init(). +* A simpler helper rte_pktmbuf_pool_create() can be used to create a + packet mbuf pool. The old way using rte_mempool_create() is still + supported though and is still used for more specific cases. + DPDK 1.7 to DPDK 1.8 -------------------- diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c index d1f2a6f..26b6f12 100644 --- a/lib/librte_mbuf/rte_mbuf.c +++ b/lib/librte_mbuf/rte_mbuf.c @@ -143,6 +143,27 @@ rte_pktmbuf_init(struct rte_mempool *mp, m->port = 0xff; } +/* helper to create a mbuf pool */ +struct rte_mempool * +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_pktmbuf_pool_private mbp_priv; + unsigned elt_size; + + + elt_size = sizeof(struct rte_mbuf) + (unsigned)priv_size + + (unsigned)data_room_size; + 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); +} + /* 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 a4146fa..42db8e3 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -642,6 +642,46 @@ void rte_pktmbuf_init(struct rte_mempool *mp, void *opaque_arg, void rte_pktmbuf_pool_init(struct rte_mempool *mp, void *opaque_arg); /** + * Create a mbuf pool. + * + * This function creates and initializes a packet mbuf pool. It is + * a wrapper to rte_mempool_create() with the proper packet constructor + * and mempool constructor. + * + * @param name + * The name of the mbuf pool. + * @param n + * The number of elements in the mbuf pool. The optimum size (in terms + * of memory usage) for a mempool is when n is a power of two minus one: + * n = (2^q - 1). + * @param cache_size + * Size of the per-core object cache. See rte_mempool_create() for + * details. + * @param priv_size + * Size of application private are between the rte_mbuf structure + * and the data buffer. + * @param data_room_size + * Size of data buffer in each mbuf, including RTE_PKTMBUF_HEADROOM. + * @param socket_id + * The socket identifier where the memory should be allocated. The + * value can be *SOCKET_ID_ANY* if there is no NUMA constraint for the + * reserved zone. + * @return + * The pointer to the new allocated mempool, on success. NULL on error + * with rte_errno set appropriately. Possible rte_errno values include: + * - E_RTE_NO_CONFIG - function could not get pointer to rte_config structure + * - E_RTE_SECONDARY - function was called from a secondary process instance + * - EINVAL - cache size provided is too large + * - ENOSPC - the maximum number of memzones has already been allocated + * - EEXIST - a memzone with the same name already exists + * - ENOMEM - no appropriate memory area found in which to create memzone + */ +struct rte_mempool * +rte_pktmbuf_pool_create(const char *name, unsigned n, + unsigned cache_size, uint16_t priv_size, uint16_t data_room_size, + int socket_id); + +/** * Get the data room size of mbufs stored in a pktmbuf_pool * * The data room size is the amount of data that can be stored in a diff --git a/lib/librte_mbuf/rte_mbuf_version.map b/lib/librte_mbuf/rte_mbuf_version.map index c4be3df..7ae2244 100644 --- a/lib/librte_mbuf/rte_mbuf_version.map +++ b/lib/librte_mbuf/rte_mbuf_version.map @@ -11,3 +11,11 @@ DPDK_2.0 { local: *; }; + +DPDK_2.1 { + global: + + rte_pktmbuf_pool_create; + + local: *; +} DPDK_2.0; -- 2.1.4