mempool/octeontx: support count query
authorSantosh Shukla <santosh.shukla@caviumnetworks.com>
Sun, 8 Oct 2017 12:40:08 +0000 (18:10 +0530)
committerThomas Monjalon <thomas@monjalon.net>
Sun, 8 Oct 2017 17:30:50 +0000 (19:30 +0200)
Signed-off-by: Santosh Shukla <santosh.shukla@caviumnetworks.com>
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
drivers/mempool/octeontx/octeontx_fpavf.c
drivers/mempool/octeontx/octeontx_fpavf.h
drivers/mempool/octeontx/rte_mempool_octeontx.c

index 3290aa0..c2d0656 100644 (file)
@@ -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,
index b52224a..263f733 100644 (file)
@@ -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)
index 10264a6..42d93b8 100644 (file)
@@ -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,
 };