From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0071.outbound.protection.outlook.com [104.47.32.71]) by dpdk.org (Postfix) with ESMTP id 59D001B029 for ; Tue, 19 Dec 2017 19:10:27 +0100 (CET) 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=pmFt+lEcjMRNLpr/S6T6hKQ/QwNlbs+EYmcXHmZgyZY=; b=VV37gXVuAc+5HvbH189jTFGs3bjw7Sm8hA83hxLYgk2P5p/+W0caR72esEmLlCrngEq0qRuL+ngXgc/brc5r0Hcw94Hk9HOnTwdwcwxPe2htSHe6XdTmagsKpT7U3JPPYtd2k2p5gE3p5sF1WvLlwRWKUri3a20CvMveL6rU80g= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Pavan.Bhagavatula@cavium.com; Received: from localhost.localdomain (111.93.218.67) by DM5PR07MB3468.namprd07.prod.outlook.com (10.164.153.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.345.14; Tue, 19 Dec 2017 18:10:23 +0000 From: Pavan Nikhilesh To: santosh.shukla@caviumnetworks.com, olivier.matz@6wind.com Cc: dev@dpdk.org, Pavan Nikhilesh Date: Tue, 19 Dec 2017 23:39:28 +0530 Message-Id: <20171219180928.2702-2-pbhagavatula@caviumnetworks.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171219180928.2702-1-pbhagavatula@caviumnetworks.com> References: <20171215160031.11354-1-pbhagavatula@caviumnetworks.com> <20171219180928.2702-1-pbhagavatula@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: SG2PR06CA0139.apcprd06.prod.outlook.com (10.175.208.145) To DM5PR07MB3468.namprd07.prod.outlook.com (10.164.153.23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 470f74ff-8d9a-4031-f26b-08d5470bc74b X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(5600026)(4604075)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603307); SRVR:DM5PR07MB3468; X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3468; 3:gLrrdIoZfYl1FNP1JXPslI80GtfKr286DtBi+ND1hqsNIJ8IQvwfneZiivzQV2fyHNET1GAZOfZf19fjs+2aXpw+sqSNLyjZxPyMs/D/cfmWJMmxNLh79s5444tzj7o1t0aoGjxWQFyTNoTnXNml1RiYqSHelUPZQbicUt17rBEHqdmoz/jcXKchVkA+RMdDAAFiHb4NpNvaO3DBLx3jii1b1bAtqjPEtvUYcfEE3tqynRKIXkyeOc69DHX/Gq5/; 25:RD4FC3c1L7S9wG0YrBR/suDiCAW8FEA1Ozb0q/bzapCCpz6UbHZB3phMjXWNUa1zK1JQ7HDhJz/UJytAWKEe185Lhi+3quxf7FJC+r/f2RyznudfFTmk6JiWTtmkn/P5IBWKCTVG6r0M21kh0ZUVfZXmELmhf2+hPK3VAlBXnAiZn3PbGPbnldANx/y+/mjQvSajgF5I7u4y7sWbNicRaYqxx0jFqRMgG7Q27KUIMS2wemRf29WNY0SmxVXF2i7CxwCnEiTQNhwedqbImOf7df8Tva9IM9KJu+UAShdZGsfHuPtp7tteByaZeq+SU7b487BYBHx7OJOLuHLwRuvySw==; 31:vewY44m0Hicbc8SuOSIp+9WtqXwt0+gYwfFW7I53SmjgHBUw3OnCHeJoXOsLkKa6IlstpCh0dCSIj/JapqzIDJIPDR6NN1LsdRTVp4CZe4coK1c8/9zB81HWw98I+8RbpUwBEFwbmdrYSqLnLnxzipNZrj9lAS/2bNeWcJBU1FvjU78M/V6Oj1OFj8FsVjZ0qM1nqgCoNmaOOBBN7pUqg+f/qhRmQ231dcwW58nga/8= X-MS-TrafficTypeDiagnostic: DM5PR07MB3468: X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3468; 20:2v3exogEfAwq1ZXc8MFNVKumpn8bPLa0NgHgPE42ymKxBtf5fCectPcfwHjwYRBJwE84Hghh3KbFHruPvNNOniWdAhdNAx4yBaX5foAKNhsKKpEd1tKuC30G+BIwnC5bSuQTHdi0KDLNmBGuProblYdHV1sHUiqBqVeuB+GLoGgVdY7wbaMJQTHb6qD/C1gEaCyL6DzFCx5TrAaFv3gheZK/W6onLrgwUnBDlbh2HCj6G+2ClFWHnS45UMgegIEQ/5LWD5mRPGnthU8XAwod4EBQIUUkcuJgLf8dAsLPW2C1Gq1W+0oWNk0gNzIFUmTU2FQk/EKa+dS3yWaobPIkzzRnScnrRVJrzFjO2wHnxxsv5CUjqP47Koe3BhV9ft5/bFX2Gjid8/PWcqL1mQAY74LFX7/NvgG06y5a9zxGgQgtlVV7aBlKgsmIcbOHeaMjt8sTV1URLW3MB5uV7XmvnuoLj7p2LGTEwJWUsg0wnzlNGisBcQd8oYwCwMihmNNg7amnXEkhRIAda+jEv2TMyg/1B9vjPE/hTa5BW3quJrMhh2jxrOlfddoAJgEK69dxdYaNnjX7PzUQAn7vhKGrkrXJQpHagi4JwwoPj7jGevk=; 4:kIYMoo1AdSVfOv3MFjZ82dEum4BlmiFCBJ9EjXnBIbx8JuOgrs/pVsUES6k9PTOItRJOu1+3Gvps1kJPkMLbAOKyl0Atxgy87a1uV0tVEsysnKTnoN0HExlqH2geAhfrPsqPwJ7P+sjF+4/0RN9st1OXPQ8AhEz6Yx6d+KGstp3VSyIJr2JAsOzDH++ntayof4WqGji/AZ9kRw2arkHzF/Cc3dqO2nqqc2zFwgUdu0Wf5NJMp9zJz+3PrDD69AmQqnaXn7OGCPfxZ5FYt/oWdw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(2401047)(5005006)(8121501046)(93006095)(3231023)(3002001)(10201501046)(6041248)(20161123564025)(20161123558100)(20161123560025)(20161123562025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:DM5PR07MB3468; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:DM5PR07MB3468; X-Forefront-PRVS: 052670E5A4 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(366004)(376002)(346002)(39860400002)(396003)(189003)(199004)(68736007)(8676002)(5660300001)(81166006)(81156014)(36756003)(2950100002)(52116002)(7736002)(42882006)(16526018)(386003)(76176011)(97736004)(51416003)(4326008)(6506007)(2906002)(16586007)(305945005)(47776003)(6486002)(50466002)(575784001)(48376002)(107886003)(8936002)(316002)(106356001)(105586002)(50226002)(478600001)(6512007)(5009440100003)(1076002)(59450400001)(72206003)(3846002)(6116002)(25786009)(53936002)(66066001)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR07MB3468; 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; DM5PR07MB3468; 23:n462Tz7wj0hKPuQz7o0fEgPkBAlM39rBShNVcgOxh?= =?us-ascii?Q?/9o5ckZDGWMW0+zUyUfyQ+GCrDNwZpC4fm9PG9ctkzXZldbBJcD0kTUZlnFH?= =?us-ascii?Q?wdR85yrk789m6qKxPh81ApqzWtRFZf+PHauu4Uor4FQ7CsWyRtrG5RjwAcQn?= =?us-ascii?Q?OBXAlqPPFWdRjuLSMtDIDXlPIi66rz8LXVRH0+alLjZWuBUjoQwQgErnRmWM?= =?us-ascii?Q?MLxh+DjYPLeBm5tm4UFQxPCDVeovbsTeK139QLn38q54xAtFhWEvGw1MyqPY?= =?us-ascii?Q?99p7Dh2V3uUaOL/UsVEcI7I3EnQwKbKT5Qaxa1YX1V7pPx+y9u1ghnaSQlSO?= =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ics: 1; DM5PR07MB3468; 6:ViqW4zD1aFCwKV0ahkk+V3o7UollpC8mUbjhk/keHPdBppKvxupgWshSrZafY8nqlYgiSpe58idWEd4gtP8KzIol/1mfHhZTSTw+pHtrSPj6rT7CptlJZ/AfwT35mxU+HhuUuIyukVrpocvI+HJMYlqjsxMmSth2adaF/VDwmYLoYDDKxURiU3jjTBdmwcGImXlna3VlOP7JRGANjtwtptqZkkibSPlgW98/amYqapha/d1aBt6kMGboYiaHBtkyM07heSSIkO6gkCkaUVa5EAiMPzvNAaelsF+lK3F6F8AH1/Dd0iNiKHlUeunoqRLgwi9tFkYTWT2BsO3xKBxJ6OSor5PgiU6Lxfcwt8f8wWM=; 5:1snEnMWUTPCbZ2v0KuHj/39szSGkTUZcfjcgARdQ0GZIZ4YI18E0Mi4kXX/xN/bc09oCLiysX+YYJsX0jhCze0/taIL4t+sUQg31Op6lfnQ8av3AJtabeuaUrmK3cMUd5DbQ/GRHoFc3HjiQ/NZfu2jUAvbgI4eQ3oU0mOBAOSo=; 24:opSo4sCqxQ+P6H6DpzwJkgTLQBq9SDxZAjxwae5t4pXcueV09DfBLJBJBeRO92ZdOTHNM3aQhfC10L3XwIEeIlCv0LPxH+7Zy0CadXNcHgU=; 7:xlEf1v5dCW+3bGU07q95YI3NTz2javutDTD0xjBpMU2XOYnCbccbasCeHzvBxmUpQJk2V8j9roTDJLBxTAb1/svhAaqlnrCjswbVSzbYuPjoBosdnFw/2o/GZeuD+K+CtibgSUvnTo7L/hIX3m42wlfmu16rxcYVfiT/jLPoWw7JZ7kYKktIrfO2JqC/ZwuAYcRR9tenjKkdSXaDaCYFXcdEwwj6mCyIEuW70iBc2ZwUGPXDuh4EUfuaw/43RhRq SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2017 18:10:23.8836 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 470f74ff-8d9a-4031-f26b-08d5470bc74b X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR07MB3468 Subject: [dpdk-dev] [PATCH v2 2/2] mempool/octeontx: clean up memory area registration 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: Tue, 19 Dec 2017 18:10:28 -0000 Clean up the dependency between alloc and memory area registration, this removes the need for SLIST data structure and octeontx_pool_list. Signed-off-by: Pavan Nikhilesh Acked-by: Santosh Shukla --- drivers/mempool/octeontx/octeontx_fpavf.c | 23 ++------ drivers/mempool/octeontx/octeontx_fpavf.h | 6 ++- drivers/mempool/octeontx/rte_mempool_octeontx.c | 72 ++----------------------- 3 files changed, 12 insertions(+), 89 deletions(-) diff --git a/drivers/mempool/octeontx/octeontx_fpavf.c b/drivers/mempool/octeontx/octeontx_fpavf.c index 3bc50f35d..28f431ed9 100644 --- a/drivers/mempool/octeontx/octeontx_fpavf.c +++ b/drivers/mempool/octeontx/octeontx_fpavf.c @@ -386,8 +386,8 @@ octeontx_fpapf_aura_detach(unsigned int gpool_index) return ret; } -static int -octeontx_fpavf_pool_setup(uintptr_t handle, unsigned long memsz, +int +octeontx_fpavf_pool_set_range(uintptr_t handle, unsigned long memsz, void *memva, uint16_t gpool) { uint64_t va_end; @@ -509,12 +509,9 @@ octeontx_fpa_bufpool_free_count(uintptr_t handle) uintptr_t octeontx_fpa_bufpool_create(unsigned int object_size, unsigned int object_count, - unsigned int buf_offset, char **va_start, - int node_id) + unsigned int buf_offset, int node_id) { unsigned int gpool; - void *memva; - unsigned long memsz; uintptr_t gpool_handle; uintptr_t pool_bar; int res; @@ -522,9 +519,6 @@ octeontx_fpa_bufpool_create(unsigned int object_size, unsigned int object_count, RTE_SET_USED(node_id); RTE_BUILD_BUG_ON(sizeof(struct rte_mbuf) > OCTEONTX_FPAVF_BUF_OFFSET); - if (unlikely(*va_start == NULL)) - goto error_end; - object_size = RTE_CACHE_LINE_ROUNDUP(object_size); if (object_size > FPA_MAX_OBJ_SIZE) { errno = EINVAL; @@ -567,15 +561,6 @@ octeontx_fpa_bufpool_create(unsigned int object_size, unsigned int object_count, goto error_pool_destroy; } - /* vf pool setup */ - memsz = object_size * object_count; - memva = *va_start; - res = octeontx_fpavf_pool_setup(pool_bar, memsz, memva, gpool); - if (res < 0) { - errno = res; - goto error_gaura_detach; - } - /* Release lock */ rte_spinlock_unlock(&fpadev.lock); @@ -591,8 +576,6 @@ octeontx_fpa_bufpool_create(unsigned int object_size, unsigned int object_count, return gpool_handle; -error_gaura_detach: - (void) octeontx_fpapf_aura_detach(gpool); error_pool_destroy: octeontx_fpavf_free(gpool); octeontx_fpapf_pool_destroy(gpool); diff --git a/drivers/mempool/octeontx/octeontx_fpavf.h b/drivers/mempool/octeontx/octeontx_fpavf.h index 1d09f0079..bc5dc3bab 100644 --- a/drivers/mempool/octeontx/octeontx_fpavf.h +++ b/drivers/mempool/octeontx/octeontx_fpavf.h @@ -114,8 +114,10 @@ do { \ uintptr_t octeontx_fpa_bufpool_create(unsigned int object_size, unsigned int object_count, - unsigned int buf_offset, char **va_start, - int node); + unsigned int buf_offset, int node); +int +octeontx_fpavf_pool_set_range(uintptr_t handle, unsigned long memsz, + void *memva, uint16_t gpool); int octeontx_fpa_bufpool_destroy(uintptr_t handle, int node); int diff --git a/drivers/mempool/octeontx/rte_mempool_octeontx.c b/drivers/mempool/octeontx/rte_mempool_octeontx.c index e89355cdd..fc0cab944 100644 --- a/drivers/mempool/octeontx/rte_mempool_octeontx.c +++ b/drivers/mempool/octeontx/rte_mempool_octeontx.c @@ -36,55 +36,18 @@ #include "octeontx_fpavf.h" -/* - * Per-pool descriptor. - * Links mempool with the corresponding memzone, - * that provides memory under the pool's elements. - */ -struct octeontx_pool_info { - const struct rte_mempool *mp; - uintptr_t mz_addr; - - SLIST_ENTRY(octeontx_pool_info) link; -}; - -SLIST_HEAD(octeontx_pool_list, octeontx_pool_info); - -/* List of the allocated pools */ -static struct octeontx_pool_list octeontx_pool_head = - SLIST_HEAD_INITIALIZER(octeontx_pool_head); -/* Spinlock to protect pool list */ -static rte_spinlock_t pool_list_lock = RTE_SPINLOCK_INITIALIZER; - static int octeontx_fpavf_alloc(struct rte_mempool *mp) { uintptr_t pool; - struct octeontx_pool_info *pool_info; uint32_t memseg_count = mp->size; uint32_t object_size; - uintptr_t va_start; int rc = 0; - rte_spinlock_lock(&pool_list_lock); - SLIST_FOREACH(pool_info, &octeontx_pool_head, link) { - if (pool_info->mp == mp) - break; - } - if (pool_info == NULL) { - rte_spinlock_unlock(&pool_list_lock); - return -ENXIO; - } - - /* virtual hugepage mapped addr */ - va_start = pool_info->mz_addr; - rte_spinlock_unlock(&pool_list_lock); - object_size = mp->elt_size + mp->header_size + mp->trailer_size; pool = octeontx_fpa_bufpool_create(object_size, memseg_count, OCTEONTX_FPAVF_BUF_OFFSET, - (char **)&va_start, mp->socket_id); rc = octeontx_fpa_bufpool_block_size(pool); if (rc < 0) @@ -109,27 +72,9 @@ octeontx_fpavf_alloc(struct rte_mempool *mp) static void octeontx_fpavf_free(struct rte_mempool *mp) { - struct octeontx_pool_info *pool_info; uintptr_t pool; - pool = (uintptr_t)mp->pool_id; - rte_spinlock_lock(&pool_list_lock); - SLIST_FOREACH(pool_info, &octeontx_pool_head, link) { - if (pool_info->mp == mp) - break; - } - - if (pool_info == NULL) { - rte_spinlock_unlock(&pool_list_lock); - rte_panic("%s: trying to free pool with no valid metadata", - __func__); - } - - SLIST_REMOVE(&octeontx_pool_head, pool_info, octeontx_pool_info, link); - rte_spinlock_unlock(&pool_list_lock); - - rte_free(pool_info); octeontx_fpa_bufpool_destroy(pool, mp->socket_id); } @@ -222,21 +167,14 @@ static int octeontx_fpavf_register_memory_area(const struct rte_mempool *mp, char *vaddr, rte_iova_t paddr, size_t len) { - struct octeontx_pool_info *pool_info; - RTE_SET_USED(paddr); - RTE_SET_USED(len); + uint8_t gpool; + uintptr_t pool_bar; - pool_info = rte_malloc("octeontx_pool_info", sizeof(*pool_info), 0); - if (pool_info == NULL) - return -ENOMEM; + gpool = octeontx_fpa_bufpool_gpool(mp->pool_id); + pool_bar = mp->pool_id & ~(uint64_t)FPA_GPOOL_MASK; - pool_info->mp = mp; - pool_info->mz_addr = (uintptr_t)vaddr; - rte_spinlock_lock(&pool_list_lock); - SLIST_INSERT_HEAD(&octeontx_pool_head, pool_info, link); - rte_spinlock_unlock(&pool_list_lock); - return 0; + return octeontx_fpavf_pool_set_range(pool_bar, len, vaddr, gpool); } static struct rte_mempool_ops octeontx_fpavf_ops = { -- 2.14.1