diff options
Diffstat (limited to 'platform/linux-dpdk/odp_timer.c')
-rw-r--r-- | platform/linux-dpdk/odp_timer.c | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/platform/linux-dpdk/odp_timer.c b/platform/linux-dpdk/odp_timer.c index 68ce550f5..96df1bf79 100644 --- a/platform/linux-dpdk/odp_timer.c +++ b/platform/linux-dpdk/odp_timer.c @@ -16,6 +16,7 @@ #include <odp_debug_internal.h> #include <odp_init_internal.h> #include <odp_libconfig_internal.h> +#include <odp_pool_internal.h> #include <odp_queue_if.h> #include <odp_ring_u32_internal.h> #include <odp_thread_internal.h> @@ -81,6 +82,8 @@ typedef struct { } timer_entry_t; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpedantic" typedef struct timer_pool_s { timer_entry_t timer[MAX_TIMER_RING_SIZE]; @@ -100,6 +103,7 @@ typedef struct timer_pool_s { uint32_t hwm_timers; } timer_pool_t; +#pragma GCC diagnostic pop /* Wrappers for alternative DPDK timer implementation */ typedef int (*timer_stop_fn)(struct rte_timer *tim); @@ -953,20 +957,29 @@ void *odp_timeout_user_ptr(odp_timeout_t tmo) return (void *)(uintptr_t)timeout_hdr->user_ptr; } -odp_timeout_t odp_timeout_alloc(odp_pool_t pool) +odp_timeout_t odp_timeout_alloc(odp_pool_t pool_hdl) { - odp_buffer_t buf = odp_buffer_alloc(pool); + odp_timeout_t tmo; + pool_t *pool; + int ret; + + ODP_ASSERT(pool_hdl != ODP_POOL_INVALID); + + pool = pool_entry_from_hdl(pool_hdl); + + ODP_ASSERT(pool->type == ODP_POOL_TIMEOUT); - if (odp_unlikely(buf == ODP_BUFFER_INVALID)) - return ODP_TIMEOUT_INVALID; - return odp_timeout_from_event(odp_buffer_to_event(buf)); + ret = _odp_buffer_alloc_multi(pool, (odp_buffer_hdr_t **)&tmo, 1); + + if (odp_likely(ret == 1)) + return tmo; + + return ODP_TIMEOUT_INVALID; } void odp_timeout_free(odp_timeout_t tmo) { - odp_event_t ev = odp_timeout_to_event(tmo); - - odp_buffer_free(odp_buffer_from_event(ev)); + _odp_buffer_free_multi((odp_buffer_hdr_t **)&tmo, 1); } void odp_timer_pool_print(odp_timer_pool_t timer_pool) @@ -982,7 +995,7 @@ void odp_timer_pool_print(odp_timer_pool_t timer_pool) ODP_PRINT("\nTimer pool info\n"); ODP_PRINT("---------------\n"); - ODP_PRINT(" timer pool %p\n", tp); + ODP_PRINT(" timer pool %p\n", (void *)tp); ODP_PRINT(" name %s\n", tp->name); ODP_PRINT(" num timers %u\n", tp->cur_timers); ODP_PRINT(" hwm timers %u\n", tp->hwm_timers); @@ -1001,7 +1014,7 @@ void odp_timer_print(odp_timer_t timer_hdl) ODP_PRINT("\nTimer info\n"); ODP_PRINT("----------\n"); - ODP_PRINT(" timer pool %p\n", timer->timer_pool); + ODP_PRINT(" timer pool %p\n", (void *)timer->timer_pool); ODP_PRINT(" timer index %" PRIu32 "\n", timer->timer_idx); ODP_PRINT(" dest queue 0x%" PRIx64 "\n", odp_queue_to_u64(timer->queue)); ODP_PRINT(" user ptr %p\n", timer->user_ptr); @@ -1035,7 +1048,7 @@ void odp_timeout_print(odp_timeout_t tmo) ODP_PRINT("\nTimeout info\n"); ODP_PRINT("------------\n"); ODP_PRINT(" tmo handle 0x%" PRIx64 "\n", odp_timeout_to_u64(tmo)); - ODP_PRINT(" timer pool %p\n", tp); + ODP_PRINT(" timer pool %p\n", (void *)tp); ODP_PRINT(" timer index %u\n", idx); ODP_PRINT(" expiration %" PRIu64 "\n", timeout_hdr->expiration); ODP_PRINT(" user ptr %p\n", timeout_hdr->user_ptr); |