From patchwork Mon Jan 29 08:10:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hemant Agrawal X-Patchwork-Id: 126156 Delivered-To: patch@linaro.org Received: by 10.46.84.92 with SMTP id y28csp2235864ljd; Mon, 29 Jan 2018 00:12:55 -0800 (PST) X-Google-Smtp-Source: AH8x22725IeqeP3+kOt4SBvHVxZUfmATNIXqspBBOHjrjSWg/fCmK5z5Wn/PVdse9C9gah9bq1xa X-Received: by 10.28.150.139 with SMTP id y133mr8103684wmd.142.1517213575522; Mon, 29 Jan 2018 00:12:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517213575; cv=none; d=google.com; s=arc-20160816; b=AGsLWg5xHuwvhn3Aqpw7W9DWNsDe2Ug8C4GPZfpFfBvcB3mrcuHAbWZRlz/jGsjIai WrGVR8U8Nu3O+9aQYNdx9baw1+wKTtkuECus8+NCIadwjkUIpTT1vPCCaC+VPcTuNdwb Awm0aqMT6/HCwvku/rO1dQswoAskaH+I0bcJdTiVOuBkwvLz1e4INxpv01845jVWaHIH HZQOeyzxAUZwxRPF/NJgli21HmTRUn6YboyX4lnpG95LY1CvvGcKsk8cLr7+BcrfMXPT nfUxkKrFCXVDglUqboN5YT/ej6OfKfNz48oIvskCNX5AbF0CHlBSjKLig1QVvgPKZJ94 VYoA== 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:dkim-signature:arc-authentication-results; bh=kfH+yWIkZv4tziltsCHGfL7LJyae6KAebKzXmhYVbmU=; b=gg7SH7XOchRhhhnlk+rMlgQcF8OvvVa/Kz1Cb7lJdpOPmq0QFgksVGzNMif1xvgLUP g7JN7zYbKYyxnBspDNDxn8FK5Gxj5VSTMCWmZgMUmYE11oMGyRL+OI02GyDnO/l7O9ui sWwRQO8JX+yLHUZosPSU2Fuid4Ho9elFTXUwa9K8bfz2AmAmijJ2lRHpbJdcqfdbLEum SHJWgPmD8+Y4wVmZz1znOr0ppMq9TeDd4FjgisOaIBftnhY8dllFWv6GhLZ4fAXv8qpR HGiGZErspPAj5YK9n6I/ozs8br9dtw59I9k1Co5uFHOxxbbHDiuxRgOwTRJoYtvDrPV1 A+Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@nxp.com header.s=selector1 header.b=mhz7sWWp; 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 1si9943686wru.221.2018.01.29.00.12.55; Mon, 29 Jan 2018 00:12:55 -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; dkim=fail header.i=@nxp.com header.s=selector1 header.b=mhz7sWWp; 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 DE4351B32A; Mon, 29 Jan 2018 09:12:34 +0100 (CET) Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0055.outbound.protection.outlook.com [104.47.2.55]) by dpdk.org (Postfix) with ESMTP id 6A3AC1B33B for ; Mon, 29 Jan 2018 09:12:28 +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=kfH+yWIkZv4tziltsCHGfL7LJyae6KAebKzXmhYVbmU=; b=mhz7sWWppyNim5QwX3hrcuPwjh9uDhFyqpZz7PeftAJxTAA1sxV1R5E78pFXeYAgvbgr44pQho93ADsm8GDgm8WbBAr6qEhk7scKV79gSlUxRT/tlRf2wdC9f+aWwwlJ/L8f6Th76Yrq5KBZbYCSvkyhjMVbh3ZgBE+oejRr54s= 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:22 +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:45 +0530 Message-Id: <1517213449-678-4-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 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: 6998ab4b-f7e1-4d1a-8930-08d566f007d1 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: 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vJtWI1Hun1m/V/YTRTKGc7L8lSdItve3amb/M7I4NJ2dep8hyLGJJXfUptH8cmW1qzpzYxiy499dyCOVg9WPwnOBrFtDZytY6F4zTjQESzcvcioANvTJ9wkfxkCqZn1Fvtzxe1hd2fAGSNGxPZH6u+vcdbzEvV55ifRu2liXZh72LbyBH3XhdRhwW0dEHnGUO06sWcHPIgzYpt6lhBP5UpOKbuwrTaQsXqK+uybm6gkzfMB166Zxkv6MwrYpG/jSaqLNOsmIvsZ0rIbYlWE3p9eeccBgsF5tdISZ486lQErHKyhWcyopVJjGb5HVqVj5RDs+rpZ2lCP15W4nydP72ou6eSYlKf0yaL; 4:qIrZU4Av2riRldsozGLHIOHUrp0H5I05aMXXipFctgD75r5ibUdmS1TKhpijR38q7vMIUEE/ku/3X90vwYFhd7nqFn3H0+ZzNhpcJJG1kSYWqlXwWyoUjW8csJGOLw7p7Nih1xOZTk6ecydk9x58r6Q+P+zhe48p929BcJoQ6EprqHkNnV71zjZnVnawtpwcrA4adD4ly+bnoxLEMMLOsDyqugUN2PAH0P8vC1CDGyK+m0lMzqDIVwCtp9/A9OETi7I/1Y7jG4w9Ra+qMV/AA8Fa3odHdnPWfj5/68sYTXC0DD7+fQ0spYJKWyA/6kmL X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(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)(59450400001)(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:WAVSxlg4W8zhBCzJ2f0tkwEDXbQ1V8JJlW67vzdg/?= 2utJ6M597EoBRbK0Ompea27A/9xHVhMvib+9Z1Ix+xRksmSTCqGzqarGe4/vHdzfBgyZbh8jDWktltW8T5j/eWMxUBzGnGEDG2qBCBWSCMGzbSxbE+bAIIugdy+ExlO2gl0iJn2JJYmGfTe0hIr2q0qSvR8bStoE5opKKkeU8Xej5vpybzQPVH73WCMjRQv4qqsumEXhC05hJ63Lzx+mvMJFExgaPDgnNjYPAUNhYFk9W/SrkxRWWXevv0CL8uwBjWh7pRmXfN7fNigtwZoFyMccb3ypmbP8W2AXjKK4ihOQVKl0Y0/K5XN6Er1r+Qn1ZapKMFx7pKiX19D3c0Bw5pxz29PqIKVejF3NKOeSfg+7C7PbSfqqu7uxBhN1oxDiaWJgnNbKIE/wFgk1rP872HDnPa8jsnl4H24vaYTITPTadji4EZVWm8K0THgpZfLO3qvOVcO0df8NIon1VaRl70lo/72GSj1QRiyV9hD2PVxKiQVDexj47ngE77WdwKd0zprjY68N241Llm8cXQuhXWxlFOwAN69wi5GBJ0kEMC5WAe4QpiGNvHbXYHiesFn7929OvWyJIO1EBdR8z9nMeECup8t1233XJFFOCRId/dpR7sZB5EUjiE9gZzDIq6dAzJQpuqDHfQe6KGcmMgGXmYlWVe2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A6lVLjgOaBl94Rz/lng6rk=; 7:vgesnG4a5RxucVetldDZkepQfhjSCuw1ABBPZXtKaBheuEh3Cn3UFWek0ZDQs1rqSGaq1qg36mAWosvU1rxNz9HOJFc8m868EgGit0rWkYUJUSnw7Fi6r9w76lV8kPsaZsuBLkvlcIdzcX+GIc+MEDUwUDqLAJUCxq1z47hljkopEqnR1pvGbSh8ORghhcuij27m402fmkEZ07IxpJrzLrXAF6nam+JUjlyRL6Tq51/izQoG0Yj+xD6VFiMhzzl3 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2018 08:12:22.8401 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6998ab4b-f7e1-4d1a-8930-08d566f007d1 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 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 Acked-by: Olivier Matz Acked-by: Santosh Shukla --- 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 | 96 ++++++++++++++++++++++++++++++++++++ lib/librte_mbuf/rte_mbuf_version.map | 11 +++++ 6 files changed, 208 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 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..e8ee20f --- /dev/null +++ b/lib/librte_mbuf/rte_mbuf_pool_ops.h @@ -0,0 +1,96 @@ +/* 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. + * + * @warning + * @b EXPERIMENTAL: this API may change without prior notice + */ + +#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 + * - On success, platform pool ops name. + * - On failure, NULL. + */ +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 + * - On success, user pool ops name.. + * - On failure, NULL. + */ +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..db87819 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; + +EXPERIMENTAL { + 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;