From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0052.outbound.protection.outlook.com [104.47.37.52]) by dpdk.org (Postfix) with ESMTP id 706B21B301 for ; Fri, 19 Jan 2018 17:35:20 +0100 (CET) Received: from BN3PR03CA0101.namprd03.prod.outlook.com (10.174.66.19) by BY2PR0301MB0728.namprd03.prod.outlook.com (10.160.63.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.407.7; Fri, 19 Jan 2018 16:35:18 +0000 Received: from BY2FFO11FD009.protection.gbl (2a01:111:f400:7c0c::182) by BN3PR03CA0101.outlook.office365.com (2603:10b6:400:4::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.428.17 via Frontend Transport; Fri, 19 Jan 2018 16:35:17 +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 BY2FFO11FD009.mail.protection.outlook.com (10.1.14.73) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.345.12 via Frontend Transport; Fri, 19 Jan 2018 16:35:16 +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 w0JGZ6aB016753; Fri, 19 Jan 2018 09:35:14 -0700 From: Hemant Agrawal To: CC: , , Date: Fri, 19 Jan 2018 22:03:55 +0530 Message-ID: <1516379639-25586-4-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516379639-25586-1-git-send-email-hemant.agrawal@nxp.com> References: <1516281992-6873-1-git-send-email-hemant.agrawal@nxp.com> <1516379639-25586-1-git-send-email-hemant.agrawal@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131608533174591038; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(39860400002)(396003)(346002)(39380400002)(376002)(2980300002)(1109001)(1110001)(339900001)(199004)(189003)(105606002)(16586007)(6666003)(51416003)(5660300001)(59450400001)(305945005)(53936002)(8676002)(81166006)(2950100002)(81156014)(77096007)(316002)(97736004)(85426001)(47776003)(296002)(8936002)(68736007)(2906002)(2351001)(26005)(86362001)(50466002)(36756003)(54906003)(48376002)(498600001)(6916009)(106466001)(356003)(104016004)(76176011)(4326008)(50226002); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR0301MB0728; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD009; 1:bdSpv7IA2qLgQwtRBuA2AwvQFVPEFfzmrUAtm4mIgqqtkuFf2Iuon8Seh0/LEkJi8tpARHdfqfDCjfgjsIwS2nRf9mywiTti1XD+2hgTwYvV+o60OzgGr0sLHPzNL1Sw MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1786d478-95ce-4da8-1e3e-08d55f5a9fbf X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(5600026)(4604075)(2017052603307); SRVR:BY2PR0301MB0728; X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0728; 3:JqKyZQtlubCHYZ3tv74trVRR8eW5YfzWviW4QB3xGJZq5DbI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L7yTU37RV/pMAwDrn8zGYc82tX36Z6IBP8fyJWBOibUBKgvGgWGa+BOCooseiA0aFtRD/lGMR06qLFFjF1TwCmpV9ImnS6nbai2vyE+5UoiSr5jlfsq0uNd8Beigc0Io8hTs1YeA0abBfBVkoiKNsnaW5tq8sl0IHdUGt0P+8I6FFNzMu+Kp1v69MrAkSH7VbsR4yJ7MhDhRiEzWTi X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(2401047)(8121501046)(5005006)(10201501046)(3231023)(2400080)(944501161)(3002001)(93006095)(93001095)(6055026)(6096035)(201703131430075)(201703131520075)(201703131448075)(201703131433075)(201703151042153)(20161123565025)(20161123561025)(20161123556025)(20161123559100)(20161123563025)(201708071742011); SRVR:BY2PR0301MB0728; BCL:0; PCL:0; RULEID:(100000803101)(100110400095)(400006); SRVR:BY2PR0301MB0728; X-Forefront-PRVS: 0557CBAD84 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR0301MB0728; 23:uJ5GgoSCs5SlyXmtooQGhEN10HgOVCvHKYw+OlX?= =?us-ascii?Q?lcFTjkTqJkd+nF8XC4uu+6Ma9q0r75VnlBhXhLr+2TiUilgBiBpK1gd4K2Lu?= =?us-ascii?Q?JXNlBTLPE4Q3rZHgykJeXkfIFPNBC/fqQ+pfgTXwg5xI1vYFqlLxFhGqVZFR?= =?us-ascii?Q?c3kuRmSLc0cLvmrWkjS+V599sjvCajnu4XMIHpzQ6qcQP8lbQeOeyywsky+l?= =?us-ascii?Q?LXnhgZ4vWNQ/yz5P0kQDP1cATYShyARfcfXqWptXJWeK8jjDmGPQ8r8CZuAT?= =?us-ascii?Q?A5p3CjCoQ6KPtC2Mh0h9J74y/LD4GMtwp/yOkwLwiODJ3ATyIv+U19jzcdza?= =?us-ascii?Q?G9OF/l+UC7uauMC1tF2Zm5Tzv7Mfyz5TjHcBQjbgJNuZvLow/H/HNuyMvUBZ?= =?us-ascii?Q?j13+vfC/c9asJxu6+MB5oSf53QPvBZJ0JQVWsOCL1aImw7JNvKPv+uv1Q/zb?= =?us-ascii?Q?+pAUONs++Jy5D++1VaqFWsxk7FpW1kaMY0mdzHfnd2WQz9witQwcHt/rMk1W?= =?us-ascii?Q?N6Luj9TA5DcGx/1xsSfnWLL3S7nW3MBzP69AGtTPbCxt1RTxDd2yBPKonC+b?= =?us-ascii?Q?pXSIO59kxwvfQcwd5KZyGPSjXOnAXAmEd0nwp+EoHrRWiCpTybLLQrvQS0GY?= =?us-ascii?Q?UUTHygRxZecAFNZWLY202grf0up67ojCPUs4Fw3tQf2RuANz5+uOPg/4D23j?= =?us-ascii?Q?E+q3rdNZDf6iUtfHBi8znSptKZL9EcDZGINDE+rMKPJZ4PBVzUDSYzysLNN3?= =?us-ascii?Q?PrLNdLEkKljAc7vIo4slCBCDLpypEKoiTKa4wSSfjs1qliZRN2+fWvYtosRP?= =?us-ascii?Q?UWm4BcqfeEHJpTP0nZlORdVAmzhnN0nzfWnyXGRyQUQwU3ssIkGOeqwUdLav?= =?us-ascii?Q?54L4GcctSVtCf9YuVJhBCh7rmU6BHL8vpvBYagX4uvPfigDj7R0E2g1jy/qs?= =?us-ascii?Q?05+DT1vL7t4SSwRHjoDF0cLYjNtKhfbpeYKnGtrAGqhoOXJO0NGcq8T340uk?= =?us-ascii?Q?IZGaS4G+7txC6B/LyqBBvufPpJjInCt2e9xnChf2U2x4bJ5g14N31PjqFuob?= =?us-ascii?Q?rdrw0FXHGZdn0oooOktXg06Q5kBHvY8PPwYP2V8STG7H+DGFu/Q=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR0301MB0728; 6:zI54lhto3ZtT5OADZ3Rf5fori+SbDoXp1V5hvvofVbewN7D8eieHYs19UYpZmF8gcukV1rmPfyDHvjCvVvcWn7ljdIzwZ2eBCs89kqv/2UnfUb65A29mCvGhCz784UdPKs4JeGQVNs1NPAOlIJrRl/BK4ZykZlbaO6rF8HVrmrxxkfKhBoc33x1enHoRlGhQ77I/7cA+uenzTcY7/TXeEpPBg9l6v2rx/84KkT7O/3Wi23y6/Eu8YzzPGUi88HxOHMtL9ZMyWMY/NSguuGuWFYVxOF7KkZEADUd9uqDjGYpMRIeaArtRr5zrMbBwwkOzGNbLzOhlXuYCOHRqrbA/ensiqrPfHhHRwB6Wrbv7qLI=; 5:kpbaaHVMTXbCwnB6UQttXPVEykOdNWtopEyLxD2FSi8jNfMBy0ECfScctViUOQbI8GQGEvPrm26RTzqktHRtUo2xnO2isDNDpwn428zP+cYBOcOzWUCZQkQgM5+xg+Ga8u3SXE++qncCN6IeVYGby5ah2Rem0eP/iO4okh5IZmg=; 24:eNGFmj88Jypfko04fxP3gr8fc/nRklWSFKiay1hxI3irlm3EGUlCagfeX9f5aGsFWEArHG93ooHi3HNM6IXK1o0fWlK1uodWK6Dtsu8jz9M=; 7:sn0IASgd+dQy8jb6rPykQk2pyK0g8ok0F7SBvKezdc70JyEy1D51yezf4JwqSS32WHrPSh/xzyejAeDyzdRoedt56hZkyUfwjzZCM12Wn7RUlmFOoCjeyluZ49tWTz8fv5Jt/GxFcxLNWrUmGRnkwlto9KnYj4ypusnvZoqOIO35CWVsF5DOHZSlNku9/8fbl7WhGH7RYuYEhewqeZGZUqC30kIwC5YdBaGzeC1yRatTSvE+JTyt9EOLSnXmX6uT SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2018 16:35:16.9442 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1786d478-95ce-4da8-1e3e-08d55f5a9fbf 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: BY2PR0301MB0728 Subject: [dpdk-dev] [PATCH v4 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: Fri, 19 Jan 2018 16:35:21 -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 | 100 +++++++++++++++++++++++++++++++++++ lib/librte_mbuf/rte_mbuf_pool_ops.h | 90 +++++++++++++++++++++++++++++++ lib/librte_mbuf/rte_mbuf_version.map | 11 ++++ 5 files changed, 205 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..52c2a9c --- /dev/null +++ b/lib/librte_mbuf/rte_mbuf_pool_ops.c @@ -0,0 +1,100 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2018 NXP + */ + +#include +#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; + memset(mz->addr, 0, mz->len); + + 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; + memset(mz->addr, 0, mz->len); + } + + 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..8559bed --- /dev/null +++ b/lib/librte_mbuf/rte_mbuf_pool_ops.h @@ -0,0 +1,90 @@ +/* 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 pool 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 pool 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. + * + * @param 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; -- 2.7.4