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;
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;
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;
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);
return gpool_handle;
-error_gaura_detach:
- (void) octeontx_fpapf_aura_detach(gpool);
error_pool_destroy:
octeontx_fpavf_free(gpool);
octeontx_fpapf_pool_destroy(gpool);
#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)
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);
}
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 = {