@@ -22,6 +22,7 @@ extern "C" {
#include <odp/align.h>
#include <odp_align_internal.h>
#include <odp/byteorder.h>
+#include <odp/dma.h>
/** @addtogroup odp_dma
* @{
@@ -30,6 +30,7 @@ extern "C" {
#include <odp/atomic.h>
#include <odp_atomic_internal.h>
#include <odp/thread.h>
+#include <odp_dma_internal.h>
#include <string.h>
/**
@@ -159,6 +160,9 @@ extern void *pool_entry_ptr[];
#define pool_is_secure(pool) 0
#endif
+/* get a DMA mapping descriptor for a single, or all, packet pools */
+odp_dma_map_t _odp_pool_get_dma_map(odp_pool_t pool_hdl);
+
static inline void *get_blk(struct pool_entry_s *pool)
{
void *myhead;
@@ -7,6 +7,7 @@
#include <odp/std_types.h>
#include <odp/pool.h>
#include <odp_buffer_internal.h>
+#include <odp_dma_internal.h>
#include <odp_pool_internal.h>
#include <odp_buffer_inlines.h>
#include <odp_packet_internal.h>
@@ -597,6 +598,64 @@ void _odp_flush_caches(void)
}
}
+/**
+ * Builds a DMA map descriptor for all packet pools.
+ */
+static dma_map_t *get_all_pkt_pool_dma_map(void)
+{
+ int i;
+ dma_map_t *dma_map;
+ dma_map_t *dma_map_head;
+ dma_map_t *dma_map_curr;
+ pool_entry_t *pool;
+
+ dma_map_head = NULL;
+ dma_map_curr = NULL;
+
+ for (i = 0; i < ODP_CONFIG_POOLS; i++) {
+ pool = get_pool_entry(i);
+ if (pool->s.params.type != ODP_POOL_PACKET)
+ continue;
+ if (dma_map_head == NULL) {
+ dma_map_head =
+ (dma_map_t *)_odp_pool_get_dma_map(pool->s.pool_hdl);
+ dma_map_curr = dma_map_head;
+ continue;
+ }
+ dma_map = (dma_map_t *)_odp_pool_get_dma_map(pool->s.pool_hdl);
+ dma_map_curr = _odp_dma_map_link(dma_map_curr, dma_map);
+ }
+
+ return dma_map_head;
+}
+
+/**
+ * Builds a DMA map descriptor for one or all packet pools.
+ * If the packet pool handle is invalid, all packets pools are assumed.
+ */
+odp_dma_map_t _odp_pool_get_dma_map(odp_pool_t pool_hdl)
+{
+ uint32_t pool_id;
+ pool_entry_t *bpool;
+ dma_map_t *dma_map;
+
+ /* specific case to get a dma mapping for all existing pot pools: */
+ if (pool_hdl == ODP_POOL_ALL_PKTS)
+ return (odp_dma_map_t)get_all_pkt_pool_dma_map();
+
+ pool_id = pool_handle_to_index((odp_pool_t)pool_hdl);
+ bpool = get_pool_entry(pool_id);
+ dma_map = _odp_dma_map_alloc();
+
+ if (odp_unlikely(dma_map == NULL))
+ return ODP_DMA_REGION_INVALID;
+
+ dma_map->addr = bpool->s.pool_base_addr;
+ dma_map->dma_addr = (odp_dma_addr_t)bpool->s.pool_base_addr;
+ dma_map->size = bpool->s.pool_size;
+ return (odp_dma_map_t)dma_map;
+}
+
void odp_pool_print(odp_pool_t pool_hdl)
{
pool_entry_t *pool;
Linux-generic implementation of the function returning a DMA mapping descriptor for one, or all, defined packet pools Signed-off-by: Christophe Milard <christophe.milard@linaro.org> --- platform/linux-generic/include/odp_dma_internal.h | 1 + platform/linux-generic/include/odp_pool_internal.h | 4 ++ platform/linux-generic/odp_pool.c | 59 ++++++++++++++++++++++ 3 files changed, 64 insertions(+)