From: Santosh Shukla Date: Sun, 8 Oct 2017 12:40:08 +0000 (+0530) Subject: mempool/octeontx: support count query X-Git-Tag: spdx-start~1704 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=e48de68d89e9b74c27419751d019c02fdde9473e;p=dpdk.git mempool/octeontx: support count query Signed-off-by: Santosh Shukla Signed-off-by: Jerin Jacob --- diff --git a/drivers/mempool/octeontx/octeontx_fpavf.c b/drivers/mempool/octeontx/octeontx_fpavf.c index 3290aa0a5f..c2d06563b6 100644 --- a/drivers/mempool/octeontx/octeontx_fpavf.c +++ b/drivers/mempool/octeontx/octeontx_fpavf.c @@ -483,6 +483,33 @@ octeontx_fpa_bufpool_block_size(uintptr_t handle) return FPA_CACHE_LINE_2_OBJSZ(res->sz128); } +int +octeontx_fpa_bufpool_free_count(uintptr_t handle) +{ + uint64_t cnt, limit, avail; + uint8_t gpool; + uintptr_t pool_bar; + + if (unlikely(!octeontx_fpa_handle_valid(handle))) + return -EINVAL; + + /* get the gpool */ + gpool = octeontx_fpa_bufpool_gpool(handle); + + /* Get pool bar address from handle */ + pool_bar = handle & ~(uint64_t)FPA_GPOOL_MASK; + + cnt = fpavf_read64((void *)((uintptr_t)pool_bar + + FPA_VF_VHAURA_CNT(gpool))); + limit = fpavf_read64((void *)((uintptr_t)pool_bar + + FPA_VF_VHAURA_CNT_LIMIT(gpool))); + + avail = fpavf_read64((void *)((uintptr_t)pool_bar + + FPA_VF_VHPOOL_AVAILABLE(gpool))); + + return RTE_MIN(avail, (limit - cnt)); +} + uintptr_t octeontx_fpa_bufpool_create(unsigned int object_size, unsigned int object_count, unsigned int buf_offset, char **va_start, diff --git a/drivers/mempool/octeontx/octeontx_fpavf.h b/drivers/mempool/octeontx/octeontx_fpavf.h index b52224a5d4..263f733d8f 100644 --- a/drivers/mempool/octeontx/octeontx_fpavf.h +++ b/drivers/mempool/octeontx/octeontx_fpavf.h @@ -139,6 +139,8 @@ int octeontx_fpa_bufpool_destroy(uintptr_t handle, int node); int octeontx_fpa_bufpool_block_size(uintptr_t handle); +int +octeontx_fpa_bufpool_free_count(uintptr_t handle); static __rte_always_inline uint8_t octeontx_fpa_bufpool_gpool(uintptr_t handle) diff --git a/drivers/mempool/octeontx/rte_mempool_octeontx.c b/drivers/mempool/octeontx/rte_mempool_octeontx.c index 10264a6bf9..42d93b8339 100644 --- a/drivers/mempool/octeontx/rte_mempool_octeontx.c +++ b/drivers/mempool/octeontx/rte_mempool_octeontx.c @@ -149,13 +149,23 @@ octeontx_fpavf_dequeue(struct rte_mempool *mp, void **obj_table, return 0; } +static unsigned int +octeontx_fpavf_get_count(const struct rte_mempool *mp) +{ + uintptr_t pool; + + pool = (uintptr_t)mp->pool_id; + + return octeontx_fpa_bufpool_free_count(pool); +} + static struct rte_mempool_ops octeontx_fpavf_ops = { .name = "octeontx_fpavf", .alloc = octeontx_fpavf_alloc, .free = octeontx_fpavf_free, .enqueue = octeontx_fpavf_enqueue, .dequeue = octeontx_fpavf_dequeue, - .get_count = NULL, + .get_count = octeontx_fpavf_get_count, .get_capabilities = NULL, .register_memory_area = NULL, };