mempool/dpaa2: add functions for CMDIF
authorNipun Gupta <nipun.gupta@nxp.com>
Fri, 4 May 2018 10:11:23 +0000 (15:41 +0530)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 8 May 2018 12:14:59 +0000 (14:14 +0200)
There are two API's which are required by NXP specific Command Interface
Application (AIOP CMDIF). This patch exposes these two API's.

Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
Acked-by: Shreyansh Jain <shreyansh.jain@nxp.com>
doc/api/doxy-api-index.md
doc/api/doxy-api.conf
drivers/mempool/dpaa2/Makefile
drivers/mempool/dpaa2/dpaa2_hw_mempool.c
drivers/mempool/dpaa2/rte_dpaa2_mempool.h [new file with mode: 0644]
drivers/mempool/dpaa2/rte_mempool_dpaa2_version.map

index 437d903..dd57f55 100644 (file)
@@ -38,6 +38,7 @@ The public API headers are grouped by topics:
   [i40e]               (@ref rte_pmd_i40e.h),
   [bnxt]               (@ref rte_pmd_bnxt.h),
   [dpaa]               (@ref rte_pmd_dpaa.h),
+  [dpaa2_mempool]      (@ref rte_dpaa2_mempool.h),
   [dpaa2_qdma]         (@ref rte_pmd_dpaa2_qdma.h),
   [crypto_scheduler]   (@ref rte_cryptodev_scheduler.h)
 
index 88bee03..71fb6b2 100644 (file)
@@ -31,6 +31,7 @@
 PROJECT_NAME            = DPDK
 INPUT                   = doc/api/doxy-api-index.md \
                           drivers/crypto/scheduler \
+                          drivers/mempool/dpaa2 \
                           drivers/net/bnxt \
                           drivers/net/bonding \
                           drivers/net/dpaa \
index 5125ad1..9e4c87d 100644 (file)
@@ -31,4 +31,6 @@ SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_MEMPOOL) += dpaa2_hw_mempool.c
 LDLIBS += -lrte_bus_fslmc
 LDLIBS += -lrte_eal -lrte_mempool -lrte_ring
 
+SYMLINK-$(CONFIG_RTE_LIBRTE_DPAA2_MEMPOOL)-include := rte_dpaa2_mempool.h
+
 include $(RTE_SDK)/mk/rte.lib.mk
index 5d057fb..e12a0ec 100644 (file)
@@ -21,6 +21,7 @@
 #include <rte_cycles.h>
 #include <rte_kvargs.h>
 #include <rte_dev.h>
+#include "rte_dpaa2_mempool.h"
 
 #include <fslmc_logs.h>
 #include <mc/fsl_dpbp.h>
@@ -244,6 +245,35 @@ aligned:
        }
 }
 
+uint16_t
+rte_dpaa2_mbuf_pool_bpid(struct rte_mempool *mp)
+{
+       struct dpaa2_bp_info *bp_info;
+
+       bp_info = mempool_to_bpinfo(mp);
+       if (!(bp_info->bp_list)) {
+               RTE_LOG(ERR, PMD, "DPAA2 buffer pool not configured\n");
+               return -ENOMEM;
+       }
+
+       return bp_info->bpid;
+}
+
+struct rte_mbuf *
+rte_dpaa2_mbuf_from_buf_addr(struct rte_mempool *mp, void *buf_addr)
+{
+       struct dpaa2_bp_info *bp_info;
+
+       bp_info = mempool_to_bpinfo(mp);
+       if (!(bp_info->bp_list)) {
+               RTE_LOG(ERR, PMD, "DPAA2 buffer pool not configured\n");
+               return NULL;
+       }
+
+       return (struct rte_mbuf *)((uint8_t *)buf_addr -
+                       bp_info->meta_data_size);
+}
+
 int
 rte_dpaa2_mbuf_alloc_bulk(struct rte_mempool *pool,
                          void **obj_table, unsigned int count)
diff --git a/drivers/mempool/dpaa2/rte_dpaa2_mempool.h b/drivers/mempool/dpaa2/rte_dpaa2_mempool.h
new file mode 100644 (file)
index 0000000..4a22b7c
--- /dev/null
@@ -0,0 +1,53 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2018 NXP
+ */
+
+#ifndef __RTE_DPAA2_MEMPOOL_H__
+#define __RTE_DPAA2_MEMPOOL_H__
+
+/**
+ * @file
+ *
+ * NXP specific mempool related functions.
+ *
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <rte_mempool.h>
+
+/**
+ * Get BPID corresponding to the packet pool
+ *
+ * @param mp
+ *   memory pool
+ *
+ * @return
+ *   BPID of the buffer pool
+ */
+uint16_t
+rte_dpaa2_mbuf_pool_bpid(struct rte_mempool *mp);
+
+/**
+ * Get MBUF from the corresponding 'buf_addr'
+ *
+ * @param mp
+ *   memory pool
+ * @param buf_addr
+ *   The 'buf_addr' of the mbuf. This is the start buffer address
+ *   of the packet buffer (mbuf).
+ *
+ * @return
+ *   - MBUF pointer for success
+ *   - NULL in case of error
+ */
+struct rte_mbuf *
+rte_dpaa2_mbuf_from_buf_addr(struct rte_mempool *mp, void *buf_addr);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __RTE_DPAA2_MEMPOOL_H__ */
index 82a5ec0..b9d996a 100644 (file)
@@ -7,3 +7,11 @@ DPDK_17.05 {
 
        local: *;
 };
+
+DPDK_18.05 {
+       global:
+
+       rte_dpaa2_mbuf_from_buf_addr;
+       rte_dpaa2_mbuf_pool_bpid;
+
+} DPDK_17.05;