diff options
author | Matias Elo <matias.elo@nokia.com> | 2024-01-05 13:51:29 +0200 |
---|---|---|
committer | Matias Elo <matias.elo@nokia.com> | 2024-01-29 12:59:27 +0200 |
commit | 35d2aa014a3c8368a54779c42f7c3a65e5dd06a4 (patch) | |
tree | e773b6473dc9a3fcc707bb6c099ccbb74eec96a4 /platform/linux-dpdk/include/odp/api | |
parent | 70c22bcfd0d2644826a8128147d8a5ce5d5d213e (diff) |
linux-dpdk: timer: inline odp_timer_ns_to_tick() implementation
Inline implementation of odp_timer_ns_to_tick() function.
Signed-off-by: Matias Elo <matias.elo@nokia.com>
Reviewed-by: Tuomas Taipale <tuomas.taipale@nokia.com>
Diffstat (limited to 'platform/linux-dpdk/include/odp/api')
-rw-r--r-- | platform/linux-dpdk/include/odp/api/plat/timer_inlines.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/platform/linux-dpdk/include/odp/api/plat/timer_inlines.h b/platform/linux-dpdk/include/odp/api/plat/timer_inlines.h index 217dce54d..a85c7582d 100644 --- a/platform/linux-dpdk/include/odp/api/plat/timer_inlines.h +++ b/platform/linux-dpdk/include/odp/api/plat/timer_inlines.h @@ -34,6 +34,7 @@ #define odp_timeout_from_event_multi __odp_timeout_from_event_multi #define odp_timeout_to_event __odp_timeout_to_event #define odp_timer_tick_to_ns __odp_timer_tick_to_ns + #define odp_timer_ns_to_tick __odp_timer_ns_to_tick #else #define _ODP_INLINE #endif @@ -100,6 +101,23 @@ _ODP_INLINE uint64_t odp_timer_tick_to_ns(odp_timer_pool_t tp ODP_UNUSED, uint64 return (sec * ODP_TIME_SEC_IN_NS) + nsec; } +_ODP_INLINE uint64_t odp_timer_ns_to_tick(odp_timer_pool_t tp ODP_UNUSED, uint64_t ns) +{ + uint64_t ticks; + uint64_t sec = 0; + const uint64_t freq_hz = _odp_timer_glob.freq_hz; + + if (ns >= ODP_TIME_SEC_IN_NS) { + sec = ns / ODP_TIME_SEC_IN_NS; + ns = ns - sec * ODP_TIME_SEC_IN_NS; + } + + ticks = sec * freq_hz; + ticks += (ns * freq_hz) / ODP_TIME_SEC_IN_NS; + + return ticks; +} + /** @endcond */ #endif |