From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0049.outbound.protection.outlook.com [104.47.2.49]) by dpdk.org (Postfix) with ESMTP id B09651B32F for ; Mon, 29 Jan 2018 09:12:29 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=DRAuNPQhrL3kb25fg2VE+v2SNn1WExwmiRtyf0pnBuA=; b=oer8SB4jrhGkA5nngM4D1wHhozoCrhGgCk+fdRpO6zeAi4et9cGE4daYEkYMCYQhCnsuLWIjJ5S9Y4Xx2MfqqGmiM0C2dMlO8DXOS3grg6Ae277KM6xrLv1YwGLjweyzn2baT/3Qn8aOkDA/IwnX5OqPe6e18zObQWabosJcF88= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=hemant.agrawal@nxp.com; Received: from bf-netperf1.ap.freescale.net (192.88.169.1) by AM2PR04MB0756.eurprd04.prod.outlook.com (2a01:111:e400:8411::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.444.14; Mon, 29 Jan 2018 08:12:27 +0000 From: Hemant Agrawal To: thomas@monjalon.net, dev@dpdk.org Cc: jerin.jacob@caviumnetworks.com, olivier.matz@6wind.com, santosh.shukla@caviumnetworks.com Date: Mon, 29 Jan 2018 13:40:46 +0530 Message-Id: <1517213449-678-5-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517213449-678-1-git-send-email-hemant.agrawal@nxp.com> References: <1516629083-13967-1-git-send-email-hemant.agrawal@nxp.com> <1517213449-678-1-git-send-email-hemant.agrawal@nxp.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [192.88.169.1] X-ClientProxiedBy: BM1PR01CA0094.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:1::34) To AM2PR04MB0756.eurprd04.prod.outlook.com (2a01:111:e400:8411::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: c8e93976-ed70-48f3-536a-08d566f009cd X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:AM2PR04MB0756; X-Microsoft-Exchange-Diagnostics: 1; AM2PR04MB0756; 3:0C6Cw+rbMCaVL/uWgAPwiNtdC9tfY9GPaQkgQ2GgEs6WJHnjXOXjIfMOis2cdaJFJzZ/BJL+xrChQJxP4FXJxxBasHyaYv8NKqhO6XbidMbtdI3Kyak4ZbNoMmAFmIcbyDfzOPbiBznvn98/tJs5NhBkuJOyvd+XGFcfZWXcFfHJndqDDPA3bf7iiefyjlnXL95knlT32SKKNe+aJLDZYo5B1iWXYnX6nhNPQMOHbjf9R8JJxWHsF++WbFVEEr87; 25:1Xxg9DrbswVox/5tWwpN9jN+48MEdROOijLQZXBkFPw1VGa3+EqUgPL1fReP46gMIwGzpcxm2v5z2ElrG3af2gW43ckUixHmGBnLkbPhmMWj0kpwzBEBRhkvcHMgqVEK3z5L15312fwZuFdtXzTpLyUsu47qDk7UqM+opGPADRQ8s3Ntj/ZqE2nxNijkOdYw5kyMEB58ghLUgMSy+xUy0Ba9FshB8OwKBd7rjhvr/YOkM2wfuEyhjRZqeOYso/s/K9JmzEsB2HMNuRgwCWihp1YOJN1CmWvGNDRuGAnDNWJyJ6fS/urqGgOgErPqtFmOFREGv+nIQw35i3ZawZXWoA==; 31:FlCGgcJkCmzwFicH19XTWGQHXr9PgsmhNqxm4Z899+lR0Dt4bh2qyzRge0j8e2559rHVs1Q1v/RIaj+Jk0HFMrkTujDV60HlgCxW4yxQlUNY17C5juGJh6PnfhEXOkMtcphIiQuUr7ZQOF2S9aF6XJBxBbWpK7e1k+p+cO0GegQ50HnulFioyKASGYDvdiiydPkO2Fu602fcVxiWFWvF9fFrIZewl6yA+NhAbTQIOr8= X-MS-TrafficTypeDiagnostic: AM2PR04MB0756: X-Microsoft-Exchange-Diagnostics: 1; AM2PR04MB0756; 20:Yl+KNW/rxztY4dbvz/FRX5clXMZCiQU2HWcOV4YGwvqzoZdVorW0I7FNELTf+aT1PNCCNrKEnJmJPnt6xUVqF6xvKzb8WOA69c7XhXgIuFijYCHUGyLLM2xysspyMeRKoy9z33w0vHphck2XuVOw2uSmD+BncNnMX0QGPAwKwQRYK5jUoBc1WR9GzqTh5UEMRvYWepjjjCku/z2qnb9xDDhf6s9UCjLVH41F5vX1GCd0DiAmduWhg7DzCN/27G3cX6g8zvRTGZYfH5SYnX5dS8mf8oAVlKBoYEZt2uND30SCwNzzsta7NFDs2v5F/RCsg7n8ox2F7zUyTT5o8fKeN434d/Y0pPPs8+RxMgt0FIt4wBJnR/XOiVGU4b9sHNzG5ETgj+RtGm5rKipzLFo9xvs4IslSn+6yzkNxdt/pXt3K02Sf84ekwpJ6iZQysQGwab7a/8b+jgB2zg/2Vb5vkGQYkgCtESytVvtvuCeqZKoerxOMnX0AAQ8HveRYJ8h8; 4:1PN1t6M3eiQ/I49CTj/gWHdWjD06V8CX40qI8Wh5MnSQ1UVlZLvnV2zRfjIh+i4hxS71LFfFsDRm+mTUJ270IBRbM66ogp+Sca9IWbnioyLGEZsn11jvliwkmWZmSXrmbMHXQeblRMLjxWH4cqKyiWn4zacthbGgfbizYclLb4BQyejHakpGxhOcDyrBzB4YwlF6st0huBe1jzBDisAACYmgXgpCr5tAqXbq7jHWT84oaIfKbC8LyaJI8hoKaEoeN32IEkS9/yWVc6KDNbvoZXRZVAqyA/yABDXB9PK4OmxiTvVNGf29HMNw+nKWA8zDnrqXRD1Yzs+gC+SWMC2RToT+ah+t/kmmfof3ElU0pa4= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(131327999870524)(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231101)(944501161)(3002001)(10201501046)(6055026)(6041288)(20161123564045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(6072148)(201708071742011); SRVR:AM2PR04MB0756; BCL:0; PCL:0; RULEID:; SRVR:AM2PR04MB0756; X-Forefront-PRVS: 0567A15835 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(396003)(366004)(376002)(39380400002)(346002)(189003)(199004)(5660300001)(6486002)(4326008)(86362001)(16526019)(3846002)(105586002)(68736007)(36756003)(6116002)(76176011)(25786009)(6506007)(106356001)(386003)(305945005)(7736002)(51416003)(52116002)(97736004)(81156014)(81166006)(2906002)(50226002)(8676002)(47776003)(478600001)(8936002)(26005)(66066001)(316002)(16586007)(48376002)(6512007)(2950100002)(53936002)(186003)(50466002)(6666003); DIR:OUT; SFP:1101; SCL:1; SRVR:AM2PR04MB0756; H:bf-netperf1.ap.freescale.net; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM2PR04MB0756; 23:Y50dvhCY38hV6UaNq6u8qBxzdlJZVk19alM8c5S7c?= =?us-ascii?Q?f47jjG0xFTYvaVu1sKam06pXypwhkJqdwiISK4jEXz/QaZXTyNY/MLwwJ4jh?= =?us-ascii?Q?OkzqnxwytrCIfMRwWG4R7dhCyVd3N6Zc08H8USgxn67xJxbsXJUxWpolSka8?= =?us-ascii?Q?1W/y3rwhW6E0TYl7ybjLIjB8BsYP85bjVFxmtci4bqAXpumxJqiRTY9lpv3+?= =?us-ascii?Q?IzqCW3Ua5d2BWq26nw6drUcnsO4GRYICLM6Mv87niHww93jCko6g3+sm+JtG?= =?us-ascii?Q?w3ENziD8AsCy0HtRatWg6omKDKg1Kteoc79EwzNe9f8wK09UVsrRjlhcngFm?= =?us-ascii?Q?aAUndOGgeia9hbEnrlGdUtvB6wynq53d4o4mTFuLGesEhjME8sjqoxIOok75?= =?us-ascii?Q?+POGZcCCV169mrc23bP9Y5O+Wwd9neGEo9idM76LJDeqrdd+ON9xKg0BhHpp?= =?us-ascii?Q?p+X+1Oag36n8MJftikC1UrV6JikVYlD7gQR2xG4zIm/ea3HVoT6QnBfdz+JQ?= =?us-ascii?Q?I9gfwooNf+s+3R6Z1JLZYQKyhKfMT8FLBZQWNh5Rwjk8gLaJqpgBIa6YvQvu?= =?us-ascii?Q?PwFBcioGMK0JKDS1pttzv3dXg4xy83wHYZ8BLG0akEeKtRDInXGfmUeRmjwy?= =?us-ascii?Q?u6duaoQsvWzx50ufA5aWDr9scMgb7eth8oJC+OEXUiTwYYkRsjab4SGrK+m9?= =?us-ascii?Q?O0PiBdFmjezue4/7FjlkoiZj/jZmKkG+DxZa0NChiPx1ED9/KbxeZxEWoau8?= =?us-ascii?Q?qM+slqVjVefWrPhR7od9Iyj+RFEvPVKvIrETvG2YBjJn9uDQm54KrOtnoGim?= =?us-ascii?Q?JziX7ocD/FkRGhljsqsxgV+DLUgBAXzQMEENPZi5l7lEG0/iqG0FtlM7ojE4?= =?us-ascii?Q?hXLMqVYiqs02o3MoNp8r4v9098//RSLZQwpA/TVnArO2cciJYBjgCcQXblfE?= =?us-ascii?Q?vcPfe0mxmMtCAnP5iqwnH5QFWj5MDoae1AiAIja5hJw82lj4euCnNcvoDica?= =?us-ascii?Q?pAsgLrRGOjgozBn1ThisvsNBWwtRvdBrQ0GpHazO2gd/XuObye6OQqSRVJyh?= =?us-ascii?Q?fWg/lFrnSjxniclj6jo9/1Blt8S?= X-Microsoft-Exchange-Diagnostics: 1; AM2PR04MB0756; 6:ZLJHgESDTJhmdZ/S9E3PPa65gInzHKhwG06FsPk465eZgceb/2wooFqqlBfk7n+SOQfp7fSHfUF25TbhY9la1bgqPD6fbfvhB9Yg3HqgR/Adh/MVgiMhXeBMmGfmH+NB6UPw2kQqcrPuSxhU++RDYsh8f8gFMDyZmfM4BnYV0evPlI59Ez8CLRoXkUEDOgFThpXoT95+r0+3ZkrBdaJ0cF0cin6Z1Ll5vQW9o/ROasOJBWVw9b6Ai7EyeT+Z8ULHJBL/CjIKsXOl/HaiH5rL4O6ZjszcARVteUhEMjazO5nzln4VJGLx2ayKLQX3GhyN0990scV3LmGz4bKSkjQW9ZHoKE1NC9A8L1rolQJT8o0=; 5:V+tvaVL/jwP655qIM5N5SZVlHr2ssh2wOwGCBeJ9ps0BNYeuVWeJA7McmeKYiJ++EzUP+wTdc1OT0JgGy75eO8nQnJsYmsf1icEhITNzL8MizOWjS0zTsSLmYyNJcrWHTDwj+C10/Yfxk+iV1N9lkA2MaKxVVFHs+xCg5YUmOGA=; 24:7WBJkRHZgZ1Xz9++iuStLWR7WtLB9KiylthlJWOz6Ew6Yobk6YR/LflWgXV1d6NCbOhHcW4dIRi1dAmgh8XgcKobQ/tUnH7mM4zMvwXSVkE=; 7:MiNhuYQ5jt3kmBZ5Trc6WtWtGNWYewA/yGgbvqMQ2dBj1EN13wRX6gvD2t5R4sDFSm1kluaS8NsoiNFzQ6S1HRDgOAQWJzR8ghLAqND55KQ8WgesFMV72sAeDXWVjguVHR+wzUkQAhPwK+8VCzSQAx0EvNTZihsCqEqi2IKLCyoDNgZne2pzNMKvsqkiB1oSOnbk9xQbwAdBlkLR9Rjmk1JZfeOQ4Ba0WS+pC/mbtuz+ZVc/ZylxhUImEWk+nxc9 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2018 08:12:27.0429 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c8e93976-ed70-48f3-536a-08d566f009cd X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM2PR04MB0756 Subject: [dpdk-dev] [PATCH v7 4/7] mbuf: pktmbuf pool create helper for specific mempool ops 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: Mon, 29 Jan 2018 08:12:29 -0000 Introduce a new helper for pktmbuf pool, which will allow the application to optionally specify the mempool ops name as well. Signed-off-by: Hemant Agrawal Acked-by: Olivier Matz Acked-by: Santosh Shukla --- lib/librte_mbuf/rte_mbuf.c | 23 ++++++++++++++------ lib/librte_mbuf/rte_mbuf.h | 42 ++++++++++++++++++++++++++++++++++++ lib/librte_mbuf/rte_mbuf_version.map | 1 + 3 files changed, 60 insertions(+), 6 deletions(-) diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c index 0c4d374..a256b42 100644 --- a/lib/librte_mbuf/rte_mbuf.c +++ b/lib/librte_mbuf/rte_mbuf.c @@ -149,15 +149,15 @@ rte_pktmbuf_init(struct rte_mempool *mp, m->next = NULL; } -/* helper to create a mbuf pool */ +/* Helper to create a mbuf pool with given mempool ops name*/ 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) +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) { struct rte_mempool *mp; struct rte_pktmbuf_pool_private mbp_priv; - const char *mp_ops_name; + const char *mp_ops_name = ops_name; unsigned elt_size; int ret; @@ -177,7 +177,8 @@ rte_pktmbuf_pool_create(const char *name, unsigned n, if (mp == NULL) return NULL; - mp_ops_name = rte_mbuf_best_mempool_ops(); + if (mp_ops_name == NULL) + mp_ops_name = rte_mbuf_best_mempool_ops(); ret = rte_mempool_set_ops_byname(mp, mp_ops_name, NULL); if (ret != 0) { RTE_LOG(ERR, MBUF, "error setting mempool handler\n"); @@ -199,6 +200,16 @@ rte_pktmbuf_pool_create(const char *name, unsigned n, return mp; } +/* helper to create a mbuf pool */ +struct rte_mempool * +rte_pktmbuf_pool_create(const char *name, unsigned int n, + unsigned int cache_size, uint16_t priv_size, uint16_t data_room_size, + int socket_id) +{ + return rte_pktmbuf_pool_create_by_ops(name, n, cache_size, priv_size, + data_room_size, 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 2fd4f5e..fb367f8 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -1101,6 +1101,48 @@ rte_pktmbuf_pool_create(const char *name, unsigned n, int socket_id); /** + * Create a mbuf pool with a given mempool ops name + * + * This function creates and initializes a packet mbuf pool. It is + * a wrapper to rte_mempool functions. + * + * @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. This value must be aligned to RTE_MBUF_PRIV_ALIGN. + * @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. + * @param ops_name + * The mempool ops name to be used for this mempool instead of + * default mempool. The value can be *NULL* to use default mempool. + * @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, or priv_size is not aligned. + * - 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_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); + +/** * 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 db87819..d418dcb 100644 --- a/lib/librte_mbuf/rte_mbuf_version.map +++ b/lib/librte_mbuf/rte_mbuf_version.map @@ -44,5 +44,6 @@ EXPERIMENTAL { rte_mbuf_set_platform_mempool_ops; rte_mbuf_set_user_mempool_ops; rte_mbuf_user_mempool_ops; + rte_pktmbuf_pool_create_by_ops; } DPDK_16.11; -- 2.7.4