X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=drivers%2Fmempool%2Focteontx%2Frte_mempool_octeontx.c;h=d143d05cb02481729ba7a23d1313a1eef4813427;hb=9aa8c7c855a82db086c866d7c1c5d49bfaffef0c;hp=e89355cdd2a306746baee9660848f46132dd6689;hpb=169a9de21e263aa6599cdc2d87a45ae158d9f509;p=deb_dpdk.git diff --git a/drivers/mempool/octeontx/rte_mempool_octeontx.c b/drivers/mempool/octeontx/rte_mempool_octeontx.c index e89355cd..d143d05c 100644 --- a/drivers/mempool/octeontx/rte_mempool_octeontx.c +++ b/drivers/mempool/octeontx/rte_mempool_octeontx.c @@ -1,34 +1,7 @@ -/* - * BSD LICENSE - * - * Copyright (C) 2017 Cavium Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2017 Cavium, Inc */ + #include #include #include @@ -36,55 +9,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 +45,9 @@ _end: 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 +140,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 = {