From patchwork Sat Jan 20 06:15:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 125240 Delivered-To: patch@linaro.org Received: by 10.46.66.141 with SMTP id h13csp174965ljf; Fri, 19 Jan 2018 23:25:32 -0800 (PST) X-Google-Smtp-Source: AH8x224tDgqfXuqsqotYffsnfei6KP8fBVjMhIkxgd7JacRcu2f0ERP3nAKEXG1DIn9eVQyN4XEy X-Received: by 10.223.193.71 with SMTP id w7mr952160wre.88.1516433132265; Fri, 19 Jan 2018 23:25:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516433132; cv=none; d=google.com; s=arc-20160816; b=pF/IIEuhm0W8W+ZxtM5Px1ccfpSWcYMJjEA1Dd8ESp/hufP1ieU9juLnrhIuZDHa/N ilNMsqvQQX7rOy0T0G2ql3RJp4jGFFmbafz1215deOn561e5cXq4Z4gaXEFzpHIkzdzn 334E335nH2tUYOws87AV6zTCgtLfWkjl7KJv/tY3GVBzpzJshqSHU22kHqtIJddl83Ci tb4Po9X7Pcuiy4c7uUIQ8W5c24kJT2l7FSQqLKLjMiIwD27daZo05Al5A4u8D0Zb5ZQo TWd6lNQeLQuSJ3Z60eqo4RBS1r/ggA9zhpx2d+iXCjKCcyKWNVBGCOwnG+KLLCpLEeJ8 OKlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:references:in-reply-to:message-id :date:cc:to:from:arc-authentication-results; bh=tlzofG2mNt3jiWAtf4TsOnphZ6CMGyIkEP7ni7CZdio=; b=pfOBVpuzsAMv8ag6RQR6gESpFZY0+McUBNZOlcV3YxrCc/1MY7dduHzFnym0WcuKga 3butdL33/ht6EG0RZxiuhbObk0Cl50Gl2dGMst8ki9OTsY9S4FauNCVANBiDkcwwLRvb 4kNke8AY30EKGizbCFny0Ro3S4kYK9eTGnPCJ9ynWDvSMVGkoyBUkfJx3zWtu7XGwbmh TfyRPyDyuD0RkCidYZeRXyobksyVAjYMnVe/HjdMbzYpMr11KJq0t2vIK8F8HIA/ivYL myzaJTVqcnllvKy8+WEAKDnICMWjd79wgG6LS2BooMzdspXxDlnn8JTfUKLnG4RHRlBK UulA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from dpdk.org (dpdk.org. [92.243.14.124]) by mx.google.com with ESMTP id c2si2055218wrf.317.2018.01.19.23.25.32; Fri, 19 Jan 2018 23:25:32 -0800 (PST) Received-SPF: pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) client-ip=92.243.14.124; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dev-bounces@dpdk.org designates 92.243.14.124 as permitted sender) smtp.mailfrom=dev-bounces@dpdk.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A327C1B293; Sat, 20 Jan 2018 08:25:08 +0100 (CET) Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0050.outbound.protection.outlook.com [104.47.42.50]) by dpdk.org (Postfix) with ESMTP id 7AB8C1B1C9 for ; Sat, 20 Jan 2018 08:25:02 +0100 (CET) Received: from CY4PR03CA0107.namprd03.prod.outlook.com (2603:10b6:910:4d::48) by SN2PR03MB2367.namprd03.prod.outlook.com (2603:10b6:804:e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.428.17; Sat, 20 Jan 2018 07:25:00 +0000 Received: from BN1BFFO11FD036.protection.gbl (2a01:111:f400:7c10::1:125) by CY4PR03CA0107.outlook.office365.com (2603:10b6:910:4d::48) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.407.7 via Frontend Transport; Sat, 20 Jan 2018 07:25:00 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1BFFO11FD036.mail.protection.outlook.com (10.58.144.99) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.428.12 via Frontend Transport; Sat, 20 Jan 2018 07:24:57 +0000 Received: from bf-netperf1.ap.freescale.net (bf-netperf1.ap.freescale.net [10.232.134.28]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id w0K6GGgf024888; Fri, 19 Jan 2018 23:16:24 -0700 From: Hemant Agrawal To: CC: , , Date: Sat, 20 Jan 2018 11:45:04 +0530 Message-ID: <1516428908-5430-4-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516428908-5430-1-git-send-email-hemant.agrawal@nxp.com> References: <1516379639-25586-1-git-send-email-hemant.agrawal@nxp.com> <1516428908-5430-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131609067001258042; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(7966004)(346002)(39860400002)(39380400002)(396003)(376002)(2980300002)(1110001)(1109001)(339900001)(199004)(189003)(59450400001)(4326008)(105606002)(106466001)(2351001)(107886003)(51416003)(50466002)(48376002)(76176011)(5660300001)(305945005)(85426001)(2950100002)(508600001)(53936002)(6666003)(2906002)(54906003)(50226002)(47776003)(356003)(86362001)(104016004)(77096007)(36756003)(97736004)(81156014)(316002)(68736007)(6916009)(8936002)(8676002)(81166006)(16586007)(26005)(336011); DIR:OUT; SFP:1101; SCL:1; SRVR:SN2PR03MB2367; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD036; 1:jvk5LREHM9JpUen9UknJUFe+AuL0qWZ5v2W/8D7cl6H8JcEvGC4lDG2NpA15WPeoU/L6Fyk9awElUT/Ejfc6jx5EBNBWpYY2kEzGrQuUHPCerkudjf8SQ1BNntWZOq5U MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 65ba6d6d-73f9-4e0f-3ed9-08d55fd6ea49 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(5600026)(4604075)(2017052603307); SRVR:SN2PR03MB2367; X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2367; 3:CRd/mxKgm9OLjQwO7/pqNRTZpEk9T5ViDFGQTImL7i4NN6fA6YGPSmXeDze+6GRHrELAdckCJexN7lNkeiKo8KvLixZ5CzIFAYLmcHBcGmI+NpTx7inY1RE2Iw2pHpKe7KV9IK0ZMOmO2h+9DbsKFlNLD7/ODY9EZigPolwVyyuQ+U036/FBlr84ytbojCVWO/Bf5CpRnOdqWfTBSWqi9yTwxE3G8qk32yJgDPpE6TNrZ8qdeh+rMPBg0FzVRU9S148wR+WmFzEvs2fOW48TiBip2jFWdnPBSoeJGkOTqBEh8L8O0NUfDjBuErHAfF4A/KnoiR+yj4ekNrADyoElU0ZOw4xUhN1xbHCL3MDDJy4=; 25:XKivaQlwgXFJjzAdE+Ieek5GSstQkhTl3pMnAE2w2GUgIItAaByJVnuTlWF6gU3F6Jo89/9A/Xz0ffg385WpUaY+rOhy6elsGhLgZqloB1HxGy+BmNZ8gZ1G1KqTc+d7WvJDpI/YSJnxgl3uhJbSfSuJd7DabqZL1EZ82/SsfsvYLLI+QUEenYRmZ/pTIa2sJYg5lF8qaJy+SxyQrbgExpc1A9Xos2klx6gge5/15Zf5f8ZSeFzvC0sCndsz/JEQjlloM5S2wPDTiZfvpKwrM93F87sU9Z7CZtlDi+lRj53g6ixA5MCKy3iM3ntj9mbyUSc8QgAvMWC9vbNQv603aQ== X-MS-TrafficTypeDiagnostic: SN2PR03MB2367: X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2367; 31:2rKqKN3SmRvLUS8SDXRrQWsPskSVMSZpys0DCNqi+Z2y9qwK9/IoW/PRC7C8LYY+lBG0w/wgmH8tScRsoNYUEHuB+LMwnd+krSjpSPxgUAsMjd72YCXUU+sRczD2+ThM+8b3bCkcaIbUa4rrhf6YWSwZHN/FSK/kbY6x3A5YUsEWAIzkIDjExrMFex8l+svOzfwo63mT5/p8t15pjz0TY63gKD400+TNa735UH8khQY=; 4:jQlS6axh7OkwJ782pOv0zvzfA/1F5GZVJydUnPvnLvycnm1hl+hTGvEQlNDM9lndXkZpOLuMtSc96w+/6Y53AOAIg5jNYlGdczIk6OxV55FGcnLhHvrLfzxnWCyjLKCo5Toz0Iq3T4slEGmzkExq85O7HGj2JzQuhuX5m+4SNZCp1aTQZUnYQd5het8CZ0YXMJ5Unkk9HcYvt0ONHEwOYn7Wul9gTynkcfhsRWNd/Y7Xit/8WIhi3yayCZ0q+WuzVDs3uOxIp/wwjob3V5BBtX1w/2MTZniWb0IMXwb1t8asEr3NqJei3HP6jq8LDKyN X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(2401047)(5005006)(8121501046)(93006095)(93001095)(3002001)(10201501046)(3231023)(2400081)(944501161)(6055026)(6096035)(20161123559100)(201703131430075)(201703131441075)(201703131448075)(201703131433075)(20161123563025)(20161123565025)(20161123561025)(20161123556025)(201708071742011); SRVR:SN2PR03MB2367; BCL:0; PCL:0; RULEID:(100000803101)(100110400095)(400006); SRVR:SN2PR03MB2367; X-Forefront-PRVS: 0558D3C5AC X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN2PR03MB2367; 23:8eukEDSOy7xyDnfRn3tO7jaKhRrFrUCXqXSbUfASm?= AI6rmxKwEYflh1w5JFbMHpkNMq3rXesRIkxfzBckMYy7RmdWxgAdV4O50KkkJ+7Pc8mAIwV4zqJ1JT4SpkyIagbWrDhwXo8KKNn2TEwu+EdI7elmeu2kEEAcEuhqIVZVOMv4chzIGzZEvJogOEjyeI0ldyV7jk9TsSv5OXSnXteoLCsS/SzYXNGhMBkJf8ehCDCrvc1a0dv7JHkPP/GcXr2zbxDclGJHrRZl2h56ynujCN79eqS7PAQxeATdTMLZitLCaXHAnMXzcAUvYQDiKkhL85hcAMegLMsu2FoW3r6ckDS9/3hNasxKPpaMmIhh7vWIJpEWAyJ09ffvfhynBv/by04s48NE9I82s/4h90Z2YB7yjLnP2cOl3oyBkHjAdkslezg4XfqxVDqJ8ifC55vTw4QHBEhyoRCnqKmq5UO9QuBt2+7daW+DeDwLieFfhN04wXYB00Nz/4gjMRwOgdN9jVylO8V934KCTn+yo3kKes2SFG6XJokcJNaG4NBKJ19JvjJf6dupqTSVdXaAHoHznYVUJgFnPw+OBw5zxoTt+aT6YDJIXRIGerPIqG2BX1SL1bYXHEHtxjy63FtwTp6vrsVZ19Xn/Ct3C/S8g0VV4xKfRm4dYJRaBeboKfJECeUswQJGGXhtV3JfpnQcgU5rdGXCO3pYAt5Zs18AdX+ocbYs35plmpFHq7r3Ua8s7ahjxk+xMyZwE6k3x/Lwo+QjI/cgo/1o5myyMzaqHlW+A1hQynQKSjEu4B7OFOzmeVSFTF3nWnmebRRfHJP8G0Kv3oanKK31Pgn8eSRaFs65t3fdfFSvpboU88BAtsjKDP6Gppp6nPgUfNQlus3zL8M29fwpYCCHymX1ySPIK12kI79oHEext9w2v7G0K1RkL0vMZtZCeL9WYAikkrouGun30AOUhPqOWDcPPTncKP/4YCxfMwyJuFnJXZiMQpvpR6ToKurVaQsK3pun8tjfUU+tCOVYn+msb7leW7cyPXRc1Arbq1y3YnMZ/zJaXSsPyGGazjVArYlm+oSQcb9JJcRN1fSesKEGEWJTrDhNsjluwLFBInVYyfVYUYXMZkNpfAyxdkvGQIoDbB1Wwlk7h+7 X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2367; 6:SavT9VLDycf7I9r/DHu3IPM2cKubSj+YQZ9L/oXqUuEfqK/cbd9bXG7T+eWyjDlFOcCgh+2/et2MREsapPjnom8buvrT5gYkw1jSHySwdsiJeJm0hzQhbSFP1xKdkumRCX8GOk9bcQBDDFveHwNQ0WgaIKfKoWktD5o61qWlZXKsEX9OV+sFAkWKtnwBRwSaw/WTJCGqWUzuBDozTQV/vapfK5kiZMK3yKKNA3UtWbkkwzqZF+cn+riZuedEp7AyVCmMpw5Jx8VsKxQD7eqy7RrdRlnStC3fceuYlxVazoJmeecdoOpBK9ybHAIy3yZTrwEKHPLPEEwZV8PldQlLs2Tmh4FBgJLJ6Gh+namnHF0=; 5:trf5kG/6SuktNqkNeiUAvuOFUyCGRVyoZfuIxbuQ0fqsJ+uavkRT2Xy0AcXEp+QQ8tvBgaCSd1ijOCc0nmOqo9OqLWKso8b6e2ICry9jgxL1hUQXo9sv9HqXRwJTE7fZpgK7yM78JRZlJvvbL1p/hHK0cjaY+9VF1fUEOXQxLSM=; 24:7PLmp6Us4vgs15UaUL9kvzVlwfpnFGbH1drpYi6QdPSSeRo/QfC0hFA9/qd2/sBAWF6zrcHKcamhqJfNH0k0Qt921MrhufxEK5ImKDuKiNE=; 7:6vlKtIGlwIJrLF5WIewIwcklj4Z9kdozO6OpYxGUvcsTMXXv5/81mJOHBmZ0X2fy5YWtwHsI8WCIIbeiW7ZItLWpHUnjB9wdDfWng9gMFNyHVyRqs6xKrW790MOffxukZoV0FNfzds74KsSIioShWUv8o36l2AaH861+DKn99PQUffyunDkMIy7riyBiSmUgj+rEywG7QfvNvC0P97po5CpquFaf+0jBpNPm60/mqgEVvu90iZ99WeC9CTswEDim SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jan 2018 07:24:57.5205 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 65ba6d6d-73f9-4e0f-3ed9-08d55fd6ea49 X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB2367 Subject: [dpdk-dev] [PATCH v5 3/7] mbuf: add pool ops name selection API helpers 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patch add support for various mempool ops config helper APIs. 1.User defined mempool ops 2.Platform detected HW mempool ops (active). 3.Best selection of mempool ops by looking into user defined, platform registered and compile time configured. Signed-off-by: Hemant Agrawal --- doc/api/doxy-api-index.md | 1 + lib/librte_mbuf/Makefile | 4 +- lib/librte_mbuf/rte_mbuf.c | 5 +- lib/librte_mbuf/rte_mbuf_pool_ops.c | 96 ++++++++++++++++++++++++++++++++++++ lib/librte_mbuf/rte_mbuf_pool_ops.h | 91 ++++++++++++++++++++++++++++++++++ lib/librte_mbuf/rte_mbuf_version.map | 11 +++++ 6 files changed, 203 insertions(+), 5 deletions(-) create mode 100644 lib/librte_mbuf/rte_mbuf_pool_ops.c create mode 100644 lib/librte_mbuf/rte_mbuf_pool_ops.h -- 2.7.4 Acked-by: Olivier Matz diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md index 76d606f..8cbd92a 100644 --- a/doc/api/doxy-api-index.md +++ b/doc/api/doxy-api-index.md @@ -136,6 +136,7 @@ The public API headers are grouped by topics: - **containers**: [mbuf] (@ref rte_mbuf.h), + [mbuf pool ops] (@ref rte_mbuf_pool_ops.h) [ring] (@ref rte_ring.h), [tailq] (@ref rte_tailq.h), [bitmap] (@ref rte_bitmap.h) diff --git a/lib/librte_mbuf/Makefile b/lib/librte_mbuf/Makefile index 398f724..e2e3ec6 100644 --- a/lib/librte_mbuf/Makefile +++ b/lib/librte_mbuf/Makefile @@ -14,9 +14,9 @@ EXPORT_MAP := rte_mbuf_version.map LIBABIVER := 3 # all source are stored in SRCS-y -SRCS-$(CONFIG_RTE_LIBRTE_MBUF) := rte_mbuf.c rte_mbuf_ptype.c +SRCS-$(CONFIG_RTE_LIBRTE_MBUF) := rte_mbuf.c rte_mbuf_ptype.c rte_mbuf_pool_ops.c # install includes -SYMLINK-$(CONFIG_RTE_LIBRTE_MBUF)-include := rte_mbuf.h rte_mbuf_ptype.h +SYMLINK-$(CONFIG_RTE_LIBRTE_MBUF)-include := rte_mbuf.h rte_mbuf_ptype.h rte_mbuf_pool_ops.h include $(RTE_SDK)/mk/rte.lib.mk diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c index c085c37..0c4d374 100644 --- a/lib/librte_mbuf/rte_mbuf.c +++ b/lib/librte_mbuf/rte_mbuf.c @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include @@ -176,9 +177,7 @@ rte_pktmbuf_pool_create(const char *name, unsigned n, if (mp == NULL) return NULL; - mp_ops_name = rte_eal_mbuf_default_mempool_ops(); - if (mp_ops_name == NULL) - mp_ops_name = RTE_MBUF_DEFAULT_MEMPOOL_OPS; + 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"); diff --git a/lib/librte_mbuf/rte_mbuf_pool_ops.c b/lib/librte_mbuf/rte_mbuf_pool_ops.c new file mode 100644 index 0000000..9aa1541 --- /dev/null +++ b/lib/librte_mbuf/rte_mbuf_pool_ops.c @@ -0,0 +1,96 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2018 NXP + */ + +#include +#include +#include +#include +#include + +int +rte_mbuf_set_platform_mempool_ops(const char *ops_name) +{ + const struct rte_memzone *mz; + + if (strlen(ops_name) >= RTE_MEMPOOL_OPS_NAMESIZE) + return -ENAMETOOLONG; + + mz = rte_memzone_lookup("mbuf_platform_pool_ops"); + if (mz == NULL) { + mz = rte_memzone_reserve("mbuf_platform_pool_ops", + RTE_MEMPOOL_OPS_NAMESIZE, SOCKET_ID_ANY, 0); + if (mz == NULL) + return -rte_errno; + strncpy(mz->addr, ops_name, strlen(ops_name)); + return 0; + } else if (strcmp(mz->addr, ops_name) == 0) { + return 0; + } + + RTE_LOG(ERR, MBUF, + "%s is already registered as platform mbuf pool ops\n", + (char *)mz->addr); + return -EEXIST; +} + +const char * +rte_mbuf_platform_mempool_ops(void) +{ + const struct rte_memzone *mz; + + mz = rte_memzone_lookup("mbuf_platform_pool_ops"); + if (mz == NULL) + return NULL; + return mz->addr; +} + +int +rte_mbuf_set_user_mempool_ops(const char *ops_name) +{ + const struct rte_memzone *mz; + + if (strlen(ops_name) >= RTE_MEMPOOL_OPS_NAMESIZE) + return -ENAMETOOLONG; + + mz = rte_memzone_lookup("mbuf_user_pool_ops"); + if (mz == NULL) { + mz = rte_memzone_reserve("mbuf_user_pool_ops", + RTE_MEMPOOL_OPS_NAMESIZE, SOCKET_ID_ANY, 0); + if (mz == NULL) + return -rte_errno; + } + + strncpy(mz->addr, ops_name, strlen(ops_name)); + return 0; + +} + +const char * +rte_mbuf_user_mempool_ops(void) +{ + const struct rte_memzone *mz; + + mz = rte_memzone_lookup("mbuf_user_pool_ops"); + if (mz == NULL) + return rte_eal_mbuf_default_mempool_ops(); + return mz->addr; +} + +/* Return mbuf pool ops name */ +const char * +rte_mbuf_best_mempool_ops(void) +{ + /* User defined mempool ops takes the priority */ + const char *best_ops = rte_mbuf_user_mempool_ops(); + if (best_ops) + return best_ops; + + /* Next choice is platform configured mempool ops */ + best_ops = rte_mbuf_platform_mempool_ops(); + if (best_ops) + return best_ops; + + /* Last choice is to use the compile time config pool */ + return RTE_MBUF_DEFAULT_MEMPOOL_OPS; +} diff --git a/lib/librte_mbuf/rte_mbuf_pool_ops.h b/lib/librte_mbuf/rte_mbuf_pool_ops.h new file mode 100644 index 0000000..b4a2d54 --- /dev/null +++ b/lib/librte_mbuf/rte_mbuf_pool_ops.h @@ -0,0 +1,91 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2018 NXP + */ + +#ifndef _RTE_MBUF_POOL_OPS_H_ +#define _RTE_MBUF_POOL_OPS_H_ + +/** + * @file + * RTE Mbuf Pool Ops + * + * These APIs are for configuring the mbuf pool ops names to be largely used by + * rte_pktmbuf_pool_create(). However, this can also be used to set and inquire + * the best mempool ops available. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Set the platform supported pktmbuf HW mempool ops name + * + * This function allow the HW to register the actively supported HW mempool + * ops_name. Only one HW mempool ops can be registered at any point of time. + * + * @param ops_name + * @return + * - On success, zero. + * - On failure, a negative value. + */ +int +rte_mbuf_set_platform_mempool_ops(const char *ops_name); + +/** + * Get configured platform supported pktmbuf HW mempool ops name + * + * This function returns the platform supported mempool ops name. + * + * @return + * returns platform pool ops name. + */ +const char * +rte_mbuf_platform_mempool_ops(void); + +/** + * Set the user preferred pktmbuf mempool ops name + * + * This function can be used by the user to configure user preferred + * mempool ops name. + * + * @param ops_name + * @return + * - On success, zero. + * - On failure, a negative value. + */ +int +rte_mbuf_set_user_mempool_ops(const char *ops_name); + +/** + * Get user preferred pool ops name for mbuf + * + * This function returns the user configured mempool ops name. + * + * @return + * returns user pool ops name. + */ +const char * +rte_mbuf_user_mempool_ops(void); + +/** + * Get the best mempool ops name for pktmbuf. + * + * This function is used to determine the best options for mempool ops for + * pktmbuf allocations. Following are the priority order: + * 1. User defined, 2. Platform HW supported, 3. Compile time configured. + * This function is also used by the rte_pktmbuf_pool_create to get the best + * mempool ops name. + * + * @return + * returns preferred mbuf pool ops name + */ +const char * +rte_mbuf_best_mempool_ops(void); + + +#ifdef __cplusplus +} +#endif + +#endif /* _RTE_MBUF_POOL_OPS_H_ */ diff --git a/lib/librte_mbuf/rte_mbuf_version.map b/lib/librte_mbuf/rte_mbuf_version.map index 6e2ea84..0028c08 100644 --- a/lib/librte_mbuf/rte_mbuf_version.map +++ b/lib/librte_mbuf/rte_mbuf_version.map @@ -35,3 +35,14 @@ DPDK_16.11 { rte_get_tx_ol_flag_list; } DPDK_2.1; + +DPDK_18.02 { + global: + + rte_mbuf_best_mempool_ops; + rte_mbuf_platform_mempool_ops; + rte_mbuf_set_platform_mempool_ops; + rte_mbuf_set_user_mempool_ops; + rte_mbuf_user_mempool_ops; + +} DPDK_16.11;