From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0047.outbound.protection.outlook.com [104.47.38.47]) by dpdk.org (Postfix) with ESMTP id 6D12F1B2D8 for ; Thu, 18 Jan 2018 14:27:55 +0100 (CET) Received: from CY4PR03CA0012.namprd03.prod.outlook.com (10.168.162.22) by DM5PR03MB2700.namprd03.prod.outlook.com (10.168.197.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.428.17; Thu, 18 Jan 2018 13:27:54 +0000 Received: from BY2FFO11FD007.protection.gbl (2a01:111:f400:7c0c::170) by CY4PR03CA0012.outlook.office365.com (2603:10b6:903:33::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.407.7 via Frontend Transport; Thu, 18 Jan 2018 13:27:54 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; NXP1.onmicrosoft.com; dkim=none (message not signed) header.d=none;NXP1.onmicrosoft.com; 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 BY2FFO11FD007.mail.protection.outlook.com (10.1.14.128) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.345.12 via Frontend Transport; Thu, 18 Jan 2018 13:27:51 +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 w0IDRdIm028023; Thu, 18 Jan 2018 06:27:48 -0700 From: Hemant Agrawal To: CC: , , Date: Thu, 18 Jan 2018 18:56:28 +0530 Message-ID: <1516281992-6873-4-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516281992-6873-1-git-send-email-hemant.agrawal@nxp.com> References: <1515996674-26338-1-git-send-email-hemant.agrawal@nxp.com> <1516281992-6873-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131607556736814824; (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)(396003)(376002)(346002)(39380400002)(39860400002)(2980300002)(1109001)(1110001)(339900001)(199004)(189003)(68736007)(16586007)(106466001)(356003)(51416003)(2351001)(508600001)(305945005)(2950100002)(6666003)(6916009)(26005)(5660300001)(59450400001)(77096007)(47776003)(76176011)(105606002)(2906002)(97736004)(53936002)(104016004)(48376002)(50466002)(85426001)(86362001)(36756003)(316002)(81156014)(81166006)(4326008)(8676002)(50226002)(54906003)(8936002)(296002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR03MB2700; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD007; 1:2vcNMnuccWbF+IT1FRvSxYCOJ2pLfdSeypQUAC7A5cmVxUu0YsKSnewJlyU6nsGM4cb8pCgrItIunv+QKOZrzom+AV915h2EGKKxJqFUg4eWhTfkpJvdnsAvY8J3l6kM MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f38c87b4-d0da-40ac-0ee8-08d55e774785 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(5600026)(4604075)(2017052603307); SRVR:DM5PR03MB2700; X-Microsoft-Exchange-Diagnostics: 1; DM5PR03MB2700; 3:d5A6HWj193LHRsX1Z4XCQN202JoWj0LwNZwykBoUvGy/JDnKIWV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KaPmw4q7HhklPpMnkKYnvVVMLX9RQTfMyRwKncBFyYYEWnOVrCMLk/OT+y+2DpoEj2O+9+cOcXr1qYZZgqMUa7QQd7G2qhz52PLEwCHiuGH7UJZFl6/b0lDA21G8e9r9rMYbCNZJjTv2kLtsGZvON1XVYHdjgLSrodzkrySM4+BDsNW6bPMKLvuJW25OJ26ZRagUaYBUm1U1Y5Zr+lHiikOc 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)(10201501046)(3231023)(944501161)(3002001)(93006095)(93001095)(6055026)(6096035)(20161123565025)(20161123561025)(201703131430075)(201703131520075)(201703131441075)(201703131448075)(201703131433075)(20161123559100)(20161123563025)(20161123556025)(201708071742011); SRVR:DM5PR03MB2700; BCL:0; PCL:0; RULEID:(100000803101)(100110400095)(400006); SRVR:DM5PR03MB2700; X-Forefront-PRVS: 05568D1FF7 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR03MB2700; 23:PUTw6CkieLUBmEpTf8GMdTd4ARgjcH+kL45iTz7Pg?= =?us-ascii?Q?ZV6UddqbY+sUp0Pnfo1LVuJQHp2glTYAtgn78LPutEfoNl/enDdE9xRLtaG8?= =?us-ascii?Q?eG4lF4ohfrVGcM67C9P0LlVIuA2GVpeKw63PmM6GJDQxKKJBpdpj/ru5m32o?= =?us-ascii?Q?/GJMS+PGjzAFo/TvLt5bxGysvHlHf37HeuZNLvvmZ+juZaRruPbNHDCI62Op?= =?us-ascii?Q?+Tw6OEFfrzutMuO1tvZuRiVs0bySEVlsx2eXOOMenrKhcQeNxkuva4mSxCry?= =?us-ascii?Q?Ni27C0Mxp08mDp1qqXoJc4ad3x7FK0uNqe8KTCbNIaSSlkoudpvB/Hb3sVtn?= =?us-ascii?Q?fzcsjlPN6v2oUZdh4IjCVNHr4xpvjXoIKrGMyl9roChrnss2OGxGtNm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BVrwv/h3Mfsn7gzrpZ4c+vm+MEtiG6lMQQ3Rlc9TlqHl/z5lhJLI8MfIvH41Tx8zNsKgWUZ1OJyUd6Rjh7cVxBRIJjoAAaW5pJIOfZPQFcqEa81sfuXvL3Tmt1HZKk3jA8KdnrpMP1+dYryMwDZXEdF5pFoMheX4GBnnGhxszqmo7zeexLL/dawKjRHQ1cnMEoCNKL9oQ/WT6tj0f98NjB/l6RaYV5I7cZON3D1MX7h/tfzvOKEm+nHcI=; 5:SS93N1AI+pO6q3WwciTsZamI0J/zi51t9UDRKij+VSPePXCnP6am+cx0/YTzCagA+eK6jmGNAInbZLLstrsu7e3eF8qIlOi9lOGmWgPNPSM3cIb3v1190PPNzn2aitHEOnN9R3rVzj3iNu5kmCMIJ7cDMNMRtIvNz9fr2Z67YsU=; 24:JHfS2yKHkWMgGyrnJkCUpu4uuz49UbiA9rtrDELQb+YIttrcr6fkVN78fKVQU4Q19XlYTQw/6P9mvQI/aA4hTvP/2V1hQWJJ8yTyYak8kpU=; 7:s5ElCx110Pv1AQ5CQyVCD/g5xlHWKGTjmJquHZA3Xhj0tlv5wvj8Bu202J+r5vTrz3U5AA0KEncO2hEf+tWDi3gv8hAeSXI9u7Mu/CfHUeFgsOManjHP79FcUGbV85edgFgoUiHTO118RmS5yM54MVfYq9chCNZSRvvk9/irFInphoXK0TJwLDEoi62CTSuUQgLDBksn+Iwn7nG+rPacKGeLZQKjDaEmj7Fv7OB2r0Kj66I6tGV5mT7LWE/mpzLl SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jan 2018 13:27:51.7314 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f38c87b4-d0da-40ac-0ee8-08d55e774785 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: DM5PR03MB2700 Subject: [dpdk-dev] [PATCH v3 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: , X-List-Received-Date: Thu, 18 Jan 2018 13:27:55 -0000 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 --- lib/librte_mbuf/Makefile | 4 +- lib/librte_mbuf/rte_mbuf.c | 5 +-- lib/librte_mbuf/rte_mbuf_pool_ops.c | 68 ++++++++++++++++++++++++++++ lib/librte_mbuf/rte_mbuf_pool_ops.h | 87 ++++++++++++++++++++++++++++++++++++ lib/librte_mbuf/rte_mbuf_version.map | 11 +++++ 5 files changed, 170 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 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..8e3a053 --- /dev/null +++ b/lib/librte_mbuf/rte_mbuf_pool_ops.c @@ -0,0 +1,68 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2018 NXP + */ + +#include +#include +#include +#include +#include +#include + +static char *plat_mbuf_pool_ops_name; + +int +rte_mbuf_register_platform_mempool_ops(const char *ops_name) +{ + if (plat_mbuf_pool_ops_name == NULL) { + plat_mbuf_pool_ops_name = + rte_malloc(NULL, RTE_MEMPOOL_OPS_NAMESIZE, 0); + if (plat_mbuf_pool_ops_name == NULL) + return -ENOMEM; + strcpy((char *)plat_mbuf_pool_ops_name, ops_name); + return 0; + } else if (strcmp(plat_mbuf_pool_ops_name, ops_name) == 0) { + return 0; + } + + RTE_LOG(ERR, MBUF, + "%s is already registered as platform mbuf pool ops\n", + plat_mbuf_pool_ops_name); + return -EEXIST; +} + +const char * +rte_mbuf_platform_mempool_ops(void) +{ + return (const char *)plat_mbuf_pool_ops_name; +} + +void +rte_mbuf_set_user_mempool_ops(const char *ops_name) +{ + rte_eal_set_mbuf_user_mempool_ops(ops_name); +} + +const char * +rte_mbuf_user_mempool_ops(void) +{ + return rte_eal_mbuf_default_mempool_ops(); +} + +/* 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..8f6db54 --- /dev/null +++ b/lib/librte_mbuf/rte_mbuf_pool_ops.h @@ -0,0 +1,87 @@ +/* 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 + +/** + * Register 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 pool ops name + * @return + * - 0: Success + * - -EEXIST: platform mempool is already registered. + * - -ENOMEM: no mempory to save ops name. + */ +int +rte_mbuf_register_platform_mempool_ops(const char *ops_name); + +/** + * Register the user preferred pktmbuf mempool ops name + * + * This function can be used by the user to configure user preferred + * mempool ops name. + * + * @param pool ops name + */ +void +rte_mbuf_set_user_mempool_ops(const char *ops_name); + +/** + * 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. + * + * @param pool ops name + */ +const char * +rte_mbuf_best_mempool_ops(void); + +/** + * Get registered platform supported pool ops name for mbuf + * + * This function returns the platform supported mempool ops name. + * + * @return + * returns platform pool ops name. + */ +const char * +rte_mbuf_platform_mempool_ops(void); + +/** + * 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); + +#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..3d60046 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_register_platform_mempool_ops; + rte_mbuf_set_user_mempool_ops; + rte_mbuf_user_mempool_ops; + +} DPDK_16.11; -- 2.7.4