CNDP 22.08.0
Loading...
Searching...
No Matches
cthread_timer.h
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2019-2022 Intel Corporation
3 */
4
5#ifndef _CTHREAD_TIMER_H_
6#define _CTHREAD_TIMER_H_
7
8#include <cne.h>
9#include <cne_system.h>
10#include <cne_timer.h>
11#include "cthread_int.h"
12#include "cthread_sched.h"
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18static inline uint64_t
19_ns_to_clks(uint64_t ns)
20{
21 uint64_t clkns = cne_get_timer_hz();
22
23 clkns *= ns;
24 clkns /= 1000000000ULL;
25
26 return clkns;
27}
28
29static inline uint64_t
30_clks_to_ns(uint64_t clks)
31{
32 uint64_t ns = cne_get_timer_hz();
33
34 if (ns) {
35 ns = 1000000000ULL / ns; /* nsecs per clk */
36 ns *= clks; /* nsec per clk times clks */
37 }
38
39 return ns;
40}
41
42static inline void
43_timer_start(struct cthread *ct, uint64_t clks)
44{
45 if (clks > 0)
46 cne_timer_reset_sync(&ct->tim, clks, SINGLE, cne_id(), _sched_timer_cb, (void *)ct);
47}
48
49static inline void
50_timer_stop(struct cthread *ct)
51{
52 if (ct != NULL)
54}
55
56#ifdef __cplusplus
57}
58#endif
59
60#endif /* _CTHREAD_TIMER_H_ */
CNDP_API int cne_id(void)
CNDP_API uint64_t cne_get_timer_hz(void)
void cne_timer_stop_sync(struct cne_timer *tim)
void cne_timer_reset_sync(struct cne_timer *tim, uint64_t ticks, enum cne_timer_type type, unsigned tim_thread, cne_timer_cb_t fct, void *arg)
struct cne_timer tim