Linux-generic implementation of the function returning a DMA mapping descriptor for one, or all, defined packet pools
Signed-off-by: Christophe Milard <christophe.mil...@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(+) diff --git a/platform/linux-generic/include/odp_dma_internal.h b/platform/linux-generic/include/odp_dma_internal.h index 888ef3b..c0b3a98 100644 --- a/platform/linux-generic/include/odp_dma_internal.h +++ b/platform/linux-generic/include/odp_dma_internal.h @@ -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 * @{ diff --git a/platform/linux-generic/include/odp_pool_internal.h b/platform/linux-generic/include/odp_pool_internal.h index b12bca8..1558f80 100644 --- a/platform/linux-generic/include/odp_pool_internal.h +++ b/platform/linux-generic/include/odp_pool_internal.h @@ -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; diff --git a/platform/linux-generic/odp_pool.c b/platform/linux-generic/odp_pool.c index 125d8e6..6958ec5 100644 --- a/platform/linux-generic/odp_pool.c +++ b/platform/linux-generic/odp_pool.c @@ -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; -- 2.1.4 _______________________________________________ lng-odp mailing list lng-odp@lists.linaro.org https://lists.linaro.org/mailman/listinfo/lng-odp