From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0057.outbound.protection.outlook.com [104.47.32.57]) by dpdk.org (Postfix) with ESMTP id 62F561B68C; Sun, 24 Dec 2017 13:49:20 +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=mGfOMwy8xQO4F+G2e5CYzK+2bU2bo2ePSKdxMnu8FU8=; b=J1onOZlxtm6VCEKNx7MZd045VUdhNjkLifWgQ51+0MMznq2a0y+22Vjy2Po5E33meIPcjn/jNxk4cN2NoI32ey55zWOWkMFEaSyzTLuEWpr/Hr7MYCzLOU4mHICZhzKLc9HRVA8PbFmY1Nn+PZPwdy+1ffBtp1ezTMGSCmqRlsY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Pavan.Bhagavatula@cavium.com; Received: from localhost.localdomain (103.16.71.47) by MWHPR07MB3469.namprd07.prod.outlook.com (10.164.192.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.345.14; Sun, 24 Dec 2017 12:49:18 +0000 From: Pavan Nikhilesh To: santosh.shukla@caviumnetworks.com, olivier.matz@6wind.com Cc: dev@dpdk.org, Pavan Nikhilesh , stable@dpdk.org Date: Sun, 24 Dec 2017 18:17:56 +0530 Message-Id: <20171224124756.12160-2-pbhagavatula@caviumnetworks.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171224124756.12160-1-pbhagavatula@caviumnetworks.com> References: <20171215160031.11354-1-pbhagavatula@caviumnetworks.com> <20171224124756.12160-1-pbhagavatula@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [103.16.71.47] X-ClientProxiedBy: SG2PR04CA0127.apcprd04.prod.outlook.com (10.170.139.11) To MWHPR07MB3469.namprd07.prod.outlook.com (10.164.192.20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 803207c2-21bd-4d9b-c04d-08d54accbfd7 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060); SRVR:MWHPR07MB3469; X-Microsoft-Exchange-Diagnostics: 1; MWHPR07MB3469; 3:0k3+iJhOpUMmWR2OOb0/B1vAlh4EOtlBR5E+BH3lpyfglV/LhMkW+BPxesxIrQh/krZeE0mzKcgI14YaRnmGtjzviuF0nB9RaOXGm1UDZwMjLQTfN5IjJN9Wz5JUbqS7pxW705uI/reVXTpneTG2uYqgNrLBxdi9EzN3M+5zZ60LWK+gV1Lfhab0rOgHDy7/ffREQhLjjWLbSL5IzJvspuhiHjgNsrDnj/+RFCvKUjYQ3cGaGft85vySb1MQsPgu; 25:obK9CceuKIRaHtv5QrF4643KGoD0CoYrSxhYFL/oMlyGUZwV77T4RJS8GA/RrnOB5pdBjj7jhH/1SgPP3aTOFauCmTqswc6qhx7R796+U2zhYCIpf8QE5xM9X27WPi5L+hyZ/8wpbVgu2WkchT0ghJvLVo45Ux707vb5PWVpsoQ1btzkg5sX45rSu9dEzq0mNVUwZy3AYm+xMJBaxod+mhtq61VVDLIIIU4IKn3wvyP5UPGWq66KpgqWhUS68gCHeJ8XK6reEYvJDR+yLZrVX52DanHLpFUOZTpoDVyVn0VlrNQ7KgAUioL64htLehjNttkrv8Gt5FRzdVx7XEdfOn6Wv0TDdX5+2yVmbBOr9Ng=; 31:G4Ap0ETXIJK26+PNjATVQTS5j3PXFHN5a6GxgGUAbGXYedInfXheMGM3dSDiiX53DUAoJjmHLuiN3TQlg39KLvHgvvZZdCIJnNSyEkWChhEtnMhA6fME4/hWnlW7acLQujvvUVTp87Y9gEZhgwqLpu4czkbb+/xWksKMkSkKD3bP6tOd9r6kfuKtg3orv1Srz8Y1KeSGswY8VZYTWWL/SAgqb+XpEbhW94DIrVLRGMs= X-MS-TrafficTypeDiagnostic: MWHPR07MB3469: X-Microsoft-Exchange-Diagnostics: 1; MWHPR07MB3469; 20:IYyixGthJJmC4jCz9UwlPydVAch6TPnSCdn5KEDAWssddcWAw6G0kJo0e66MDarruSI/54xPOOmQwgMokX7wYLobUFz+ocdN5IJEDDJVdzv9+VfXJNrEdhUAO3R1qsGSwHWqSazqT+F/FMrl4ruDk/3cWC8myMonna3XQjdxVjOT7Ta0uY1nwpLk0zVIAuBSLql6I92eyUVvlbn46Kxa75l5OsOkFrAXkYdbN6nI1o6JqQQI8Dibgq10mYVkgOw/l0Woe/GBodI4daq+gbkGZbffZbcIbfJ83MfCaU7yqVEKf+5dKQi93gsoJhwEwx2oKfdxVBVvWuttLdcrLZPMuc38Fkdt5ihHGyBZXOwr9Ic8e1gE6YnxFzkfcgqBObaDOhX8XIbpu+cWtir3fhDZJYVge3dHVf0oPa6FgEJtNYnxBM0JRI+/4EEyu5evsMAqTm8/PRKtl6WunWDu5qQxJtc8H6Qwu2Y3kNKRh727oMzLkoLuc4HWKJS2S1ZnC4zsF0KO1ZUYiQICBlIpvC/nLqUFv58+cIzDGQMeQ5X+XgEUPEaf92WQi3UED7wmEhDPtwmB1wAh9KRVn0rlv40bT8OPq7NhGO1faS0cKgZ7GbE=; 4:qbWQqAxG2Y1vedsCHoJCPnxdlDSVEYO4rYQSZP4xd9jgE7Q2u8VfBMPbIFSmdg+l4csRU0/JfZx77QSGMcmJ71jZC+54s/EL8LJU+kW/62ujp1Q2zfs2zZ6DaY7g3FLwvyuRTCNwXjF4vfb0JRx3c9y4WTyebaR37dYO1kDlcqzco8eVlXPLbqNrapRj1kjM+3GxhNyG1B71Z1enfy1Ne/bQx2kqtySejR8va1ptBS2Wu0x/wqHoP6idyf4UKLMXWB9HHb2mNjH3IxK0jt3fJQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(10201501046)(3002001)(93006095)(3231023)(944501074)(6041268)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(6072148)(201708071742011); SRVR:MWHPR07MB3469; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:MWHPR07MB3469; X-Forefront-PRVS: 05315CBE52 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(376002)(346002)(396003)(39850400004)(366004)(39380400002)(189003)(199004)(36756003)(48376002)(50466002)(4326008)(25786009)(6486002)(5660300001)(106356001)(105586002)(6512007)(50226002)(66066001)(16586007)(8936002)(316002)(59450400001)(575784001)(386003)(6506007)(47776003)(16526018)(68736007)(97736004)(1076002)(305945005)(7736002)(81156014)(81166006)(76176011)(8676002)(52116002)(51416003)(2906002)(6666003)(3846002)(6116002)(478600001)(2950100002)(42882006)(72206003)(53936002)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR07MB3469; 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; MWHPR07MB3469; 23:jAgZMYVEYYFqdwZnxOBc1J0ZiYkKuRVeRFkc/iUZS?= =?us-ascii?Q?IfJ6Gc0CHjO9nzPraPUNxY12sWd2zuvRq8OfY8SNhqm1/U0OqpRG5ng+hKyu?= =?us-ascii?Q?4VvoTTLTXOs3/+SLB+RIpl7ahZIDtzUrZ7PYe2NGJiKSKWfYS4SM+9IXdnJM?= =?us-ascii?Q?NYT7jTJy3Lj3qwm3QzUthssroOgVeoDaz/6aLIezQsOa0RGnMuTqWDC5in1t?= =?us-ascii?Q?Ij1h5Y6NejMlTMz5Ltby4I8pSSIZGV1d8RcLI0oGKvzZ5XLGtW6BCb6GgsrQ?= =?us-ascii?Q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pRKNA1fXUKxlBZb+dm?= =?us-ascii?Q?lASYJanVLtIX4A=3D?= X-Microsoft-Exchange-Diagnostics: 1; MWHPR07MB3469; 6:nkOgsrLRKnY2pHECW5UEGook8CrilCR5hcTAluRTp9n2sdzziCvrEfYTcoHut0ZjTLLb2HD4SeVQQQAdqaz78JDh9okFFgkksB4ds2ocMO+HEOEBguEnbG82IVGIqZtJ4PoAxRa7sOK+Jw+h+Ev9OtymkJIDBX7UYt78KeU0zNpTAM/4gAphtazccnbfU5JV7fB9q18q4VXaHb939lGpQeWavSaoT1h9xAs3IhDa0uuqCRurXzpo/e443WAZrhXTjro5MAsyMk/d/rlNq8bMo+3eeqYXvliFWQN5NLRza8lZmIH6zUXVS6La4VCtBye6L3HNfyGFn+LRYG6M4eioKJJc8MSixdNff6vRifKsOKs=; 5:W1ZWxk0VP0jIYqMX7OxBWSoYd5fAmCJvpoLpppb0NWliyewdEbEvrPZaL6l1WV9Yv3JXCv1hL2+tHP7EX6kIIEEbyWmF9rI96ZVOMlm7dm609TIfDMaxyCft6rwXTaTIMy/hIyH9B+y+86snzHopSI/m3FnMsb0SyA8Val6ZDos=; 24:EWQ2HijzaLcWaq0Qi84hNpK13ZhB1bNx2MwNAzT+6hA4gCGrG6eOTUPtfigGqYyZqzrPZYb5oSJBbQ/ruimKLtQlyYjeN67v4VyDssqBUVk=; 7:zqMJGskfOMamjGxyGF3LwP+MthYJmLC4NYwvotaJDNCmuXfK7tnyykn8jgkDvbRLLOZ15WIHNTOFjLPbFF/ZNHEhU2ncxqeX4Rk9BhPRG7tiAYBq3x0W5I0YtTb+I9j2PZeXi2sWfA/HkJPLTk1caqqhHUUpYf701Oe5DKT+VP6uZ8s6dr5PH27XBObaB2Oc98Q0ho7CqtTbi3TdEJ4rXPkceqC01E5YCmS3ghp0gDgojq9xIMz7Hw4VT7woLtzz SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Dec 2017 12:49:18.0008 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 803207c2-21bd-4d9b-c04d-08d54accbfd7 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR07MB3469 Subject: [dpdk-dev] [PATCH v3 2/2] mempool/octeontx: fix 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: Sun, 24 Dec 2017 12:49:22 -0000 Clean up the dependency between alloc and memory area registration, this removes the need for SLIST data structure and octeontx_pool_list. Fixes: 2baa3f0b7de5 ("mempool/octeontx: support memory area ops") Cc: stable@dpdk.org 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