From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0058.outbound.protection.outlook.com [104.47.42.58]) by dpdk.org (Postfix) with ESMTP id 960DD199B9 for ; Thu, 7 Sep 2017 17:31:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=KPpIxxom9bQ/dgYFFPlKgDnWeS0ucCF+B+HV2qZTmDQ=; b=ZR0N1kVGK3EW+Zrlt+jKbMKuKU5XJlEzDtbjOFfi2ROKb0jUPmxhLgngcTVSsx+EmoJJAW9/2p0N+/g4h1sM2aIkXarFI5jOEhY3AUq0mCcwp46fDlvej9WK9OLargY1YnBafpW0t96Fh8CRtdWpxafv7C8wkhdqOf5lNmF0B3M= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Santosh.Shukla@cavium.com; Received: from localhost.localdomain (14.140.2.178) by MWHPR07MB3101.namprd07.prod.outlook.com (10.172.95.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.13.10; Thu, 7 Sep 2017 15:31:38 +0000 From: Santosh Shukla To: olivier.matz@6wind.com, dev@dpdk.org Cc: thomas@monjalon.net, jerin.jacob@caviumnetworks.com, hemant.agrawal@nxp.com, Santosh Shukla Date: Thu, 7 Sep 2017 21:00:39 +0530 Message-Id: <20170907153042.30890-6-santosh.shukla@caviumnetworks.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170907153042.30890-1-santosh.shukla@caviumnetworks.com> References: <20170906112834.32378-1-santosh.shukla@caviumnetworks.com> <20170907153042.30890-1-santosh.shukla@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.140.2.178] X-ClientProxiedBy: BM1PR01CA0072.INDPRD01.PROD.OUTLOOK.COM (10.174.208.140) To MWHPR07MB3101.namprd07.prod.outlook.com (10.172.95.7) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d88ae6e3-d50b-44de-31a8-08d4f6058942 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:MWHPR07MB3101; X-Microsoft-Exchange-Diagnostics: 1; MWHPR07MB3101; 3:CeWHKNt4/0GLnGoBuL14RrH3lfXAkJnL8pwxJJtQfN7L8dXAeoWNvzlsIDSY9UQSmMSDRveGsB+ln4LzmRczXxNvPBpHImhVo12hLKij51XQFYTiCco8h7Nv9vc097bMToKQ3esUyOrILFt/143W6PW0NNn935D2qlnmOmFYAWIaxRC30/ci6D89Rp/yCPZM+Chxtmhtwstv3m1nX4Je4Tj/Y49Wc9gxWvZ4TCppSRpHY3c7LpNdIjs3qpvtoxAg; 25:ZSc8pWjzNRUhmPEg58uB8CMRABqcaX6oBQfImaGSclFX7zBeULTyBMaCDD5RTJq2msufCrZyfB0RUFRr2+gW7O5n/9JTUT5A+wgs2LPuH+ZYn2UbudtC/3NC4JWpocjWLvkExV8GXbmIwDrL8JXbztgKvkwe3BGZff758utT5xZOIPHS3Gw6m0lfuWRIMCAB0FyJv8X3WnFg3Tvwv+NN+ayCw/6i/VKmODO29/rfiGg4PAxpvrjQ58kKQ2csvY6lN1zdeMnp9We2uncD21aDfdCwd4F4O1UpObseW9lK0E98oEwqrNu/IGR2g0GamBYute8pWRI0LVLoBcnq2XIjwA==; 31:p5RMEfSu5k+LXG9H1HW3aNI632gqoA2Y8Xsu0VIpDm1kn+9klcAIiQnfL2YSSUbo8bCUwgPc08ocESXWs5ltPtgTj6eH2c2LUTUNQXnsDG50Fpcmrj1kTe9M83DVy3d7x5md/I8cM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X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(100000703101)(100105400095)(93006095)(3002001)(10201501046)(6041248)(20161123555025)(20161123558100)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:MWHPR07MB3101; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:MWHPR07MB3101; X-Forefront-PRVS: 04238CD941 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(6009001)(189002)(199003)(25786009)(5660300001)(966005)(50986999)(76176999)(42186005)(106356001)(105586002)(4326008)(33646002)(8656003)(66066001)(53376002)(53936002)(36756003)(107886003)(110136004)(8936002)(50226002)(305945005)(6306002)(8676002)(7736002)(5003940100001)(1076002)(6512007)(47776003)(81156014)(3846002)(50466002)(6116002)(5009440100003)(101416001)(68736007)(48376002)(97736004)(81166006)(189998001)(2906002)(72206003)(6506006)(2950100002)(42882006)(478600001)(6486002)(110426004)(15583001); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR07MB3101; H:localhost.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR07MB3101; 23:uaHKdX5zOh5p71KXfZZGR91KGrN58R5gfw7UJ0As+?= =?us-ascii?Q?I8mX4CtnqJ8E+HMjX8AhMpJgsqH1jQzV1ctyqVAejYVvku1AQlNQZRCqB+qR?= =?us-ascii?Q?gIymZTwU371tE44xkp/mdLHZ8n8m1+QxXbHxP/FD2BFUzu4Xr+61+thrQC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iyzf/naPmm96J0nDVOjEKgIqrSEwAtneZo5/hkz6qDM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Sep 2017 15:31:38.1668 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR07MB3101 Subject: [dpdk-dev] [PATCH v6 5/8] mempool: get the mempool capability 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, 07 Sep 2017 15:31:43 -0000 Allow the mempool driver to advertise his pool capabilities. For that pupose, an api(rte_mempool_ops_get_capabilities) and ->get_capabilities() handler has been introduced. - Upon ->get_capabilities() call, mempool driver will advertise his capabilities to mempool flags param. Signed-off-by: Santosh Shukla Signed-off-by: Jerin Jacob --- v5 --> v6: - Fixed typos from Capability to capabilities (suggested by Olivier) - Now mp->flags |= flag happens at mempool layer (suggested by Olivier) - For -ENOTSUP return type - patch ignore and allows not supported message, For other error value <0, returns from rte_mempool_populate_default(). - Updated API error description for same. For history: refer [1]. [1] http://dpdk.org/dev/patchwork/patch/28416/ v4 --> v5: - Added flags as second param in get_capability api (suggested by Olivier) - Removed 80 char warning. (suggested by Olivier) - Upadted API description, now explicitly mentioning that update as a Or'ed operation by mempool handle. (suggested by Olivier) refer [2]. [1] http://dpdk.org/dev/patchwork/patch/27598/ lib/librte_mempool/rte_mempool.c | 13 +++++++++++++ lib/librte_mempool/rte_mempool.h | 27 +++++++++++++++++++++++++++ lib/librte_mempool/rte_mempool_ops.c | 15 +++++++++++++++ lib/librte_mempool/rte_mempool_version.map | 7 +++++++ 4 files changed, 62 insertions(+) diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index 005240042..92de39562 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -522,12 +522,25 @@ rte_mempool_populate_default(struct rte_mempool *mp) size_t size, total_elt_sz, align, pg_sz, pg_shift; phys_addr_t paddr; unsigned mz_id, n; + unsigned int mp_flags; int ret; /* mempool must not be populated */ if (mp->nb_mem_chunks != 0) return -EEXIST; + /* Get mempool capabilities */ + mp_flags = 0; + ret = rte_mempool_ops_get_capabilities(mp, &mp_flags); + if (ret == -ENOTSUP) + RTE_LOG(DEBUG, MEMPOOL, "get_capability not supported for %s\n", + mp->name); + else if (ret < 0) + return ret; + + /* update mempool capabilities */ + mp->flags |= mp_flags; + if (rte_xen_dom0_supported()) { pg_sz = RTE_PGSIZE_2M; pg_shift = rte_bsf32(pg_sz); diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h index 85eb770dc..d251d4255 100644 --- a/lib/librte_mempool/rte_mempool.h +++ b/lib/librte_mempool/rte_mempool.h @@ -389,6 +389,12 @@ typedef int (*rte_mempool_dequeue_t)(struct rte_mempool *mp, */ typedef unsigned (*rte_mempool_get_count)(const struct rte_mempool *mp); +/** + * Get the mempool capabilities. + */ +typedef int (*rte_mempool_get_capabilities_t)(const struct rte_mempool *mp, + unsigned int *flags); + /** Structure defining mempool operations structure */ struct rte_mempool_ops { char name[RTE_MEMPOOL_OPS_NAMESIZE]; /**< Name of mempool ops struct. */ @@ -397,6 +403,10 @@ struct rte_mempool_ops { rte_mempool_enqueue_t enqueue; /**< Enqueue an object. */ rte_mempool_dequeue_t dequeue; /**< Dequeue an object. */ rte_mempool_get_count get_count; /**< Get qty of available objs. */ + /** + * Get the mempool capabilities + */ + rte_mempool_get_capabilities_t get_capabilities; } __rte_cache_aligned; #define RTE_MEMPOOL_MAX_OPS_IDX 16 /**< Max registered ops structs */ @@ -508,6 +518,23 @@ rte_mempool_ops_enqueue_bulk(struct rte_mempool *mp, void * const *obj_table, unsigned rte_mempool_ops_get_count(const struct rte_mempool *mp); +/** + * @internal wrapper for mempool_ops get_capabilities callback. + * + * @param mp [in] + * Pointer to the memory pool. + * @param flags [out] + * Pointer to the mempool flags. + * @return + * - 0: Success; The mempool driver has advertised his pool capabilities in + * flags param. + * - -ENOTSUP - doesn't support get_capabilities ops (valid case). + * - Otherwise, pool create fails. + */ +int +rte_mempool_ops_get_capabilities(const struct rte_mempool *mp, + unsigned int *flags); + /** * @internal wrapper for mempool_ops free callback. * diff --git a/lib/librte_mempool/rte_mempool_ops.c b/lib/librte_mempool/rte_mempool_ops.c index 5f24de250..f2af5e5bb 100644 --- a/lib/librte_mempool/rte_mempool_ops.c +++ b/lib/librte_mempool/rte_mempool_ops.c @@ -37,6 +37,7 @@ #include #include +#include /* indirect jump table to support external memory pools. */ struct rte_mempool_ops_table rte_mempool_ops_table = { @@ -85,6 +86,7 @@ rte_mempool_register_ops(const struct rte_mempool_ops *h) ops->enqueue = h->enqueue; ops->dequeue = h->dequeue; ops->get_count = h->get_count; + ops->get_capabilities = h->get_capabilities; rte_spinlock_unlock(&rte_mempool_ops_table.sl); @@ -123,6 +125,19 @@ rte_mempool_ops_get_count(const struct rte_mempool *mp) return ops->get_count(mp); } +/* wrapper to get external mempool capabilities. */ +int +rte_mempool_ops_get_capabilities(const struct rte_mempool *mp, + unsigned int *flags) +{ + struct rte_mempool_ops *ops; + + ops = rte_mempool_get_ops(mp->ops_index); + + RTE_FUNC_PTR_OR_ERR_RET(ops->get_capabilities, -ENOTSUP); + return ops->get_capabilities(mp, flags); +} + /* sets mempool ops previously registered by rte_mempool_register_ops. */ int rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name, diff --git a/lib/librte_mempool/rte_mempool_version.map b/lib/librte_mempool/rte_mempool_version.map index f9c079447..3c3471507 100644 --- a/lib/librte_mempool/rte_mempool_version.map +++ b/lib/librte_mempool/rte_mempool_version.map @@ -41,3 +41,10 @@ DPDK_16.07 { rte_mempool_set_ops_byname; } DPDK_2.0; + +DPDK_17.11 { + global: + + rte_mempool_ops_get_capabilities; + +} DPDK_16.07; -- 2.14.1