1*5113495bSYour Name /*
2*5113495bSYour Name * Copyright (c) 2014-2016, 2018-2021 The Linux Foundation. All rights reserved.
3*5113495bSYour Name *
4*5113495bSYour Name * Permission to use, copy, modify, and/or distribute this software for
5*5113495bSYour Name * any purpose with or without fee is hereby granted, provided that the
6*5113495bSYour Name * above copyright notice and this permission notice appear in all
7*5113495bSYour Name * copies.
8*5113495bSYour Name *
9*5113495bSYour Name * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10*5113495bSYour Name * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11*5113495bSYour Name * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12*5113495bSYour Name * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13*5113495bSYour Name * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14*5113495bSYour Name * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15*5113495bSYour Name * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16*5113495bSYour Name * PERFORMANCE OF THIS SOFTWARE.
17*5113495bSYour Name */
18*5113495bSYour Name
19*5113495bSYour Name /**
20*5113495bSYour Name * DOC: qdf_timer
21*5113495bSYour Name * This file abstracts OS timers running in soft IRQ context.
22*5113495bSYour Name */
23*5113495bSYour Name
24*5113495bSYour Name #ifndef _QDF_TIMER_H
25*5113495bSYour Name #define _QDF_TIMER_H
26*5113495bSYour Name
27*5113495bSYour Name #include <qdf_types.h>
28*5113495bSYour Name #include <i_qdf_timer.h>
29*5113495bSYour Name
30*5113495bSYour Name typedef struct __qdf_timer_t qdf_timer_t;
31*5113495bSYour Name
32*5113495bSYour Name /**
33*5113495bSYour Name * qdf_timer_init() - initialize a timer
34*5113495bSYour Name * @hdl: OS handle
35*5113495bSYour Name * @timer: Timer object pointer
36*5113495bSYour Name * @func: Timer function
37*5113495bSYour Name * @arg: Argument of timer function
38*5113495bSYour Name * @type: deferrable or non deferrable timer type
39*5113495bSYour Name *
40*5113495bSYour Name * Timer type QDF_TIMER_TYPE_SW means its a deferrable sw timer which will
41*5113495bSYour Name * not cause CPU wake upon expiry
42*5113495bSYour Name * Timer type QDF_TIMER_TYPE_WAKE_APPS means its a non-deferrable timer which
43*5113495bSYour Name * will cause CPU wake up on expiry
44*5113495bSYour Name *
45*5113495bSYour Name * Return: QDF_STATUS
46*5113495bSYour Name */
47*5113495bSYour Name static inline QDF_STATUS
qdf_timer_init(qdf_handle_t hdl,qdf_timer_t * timer,qdf_timer_func_t func,void * arg,QDF_TIMER_TYPE type)48*5113495bSYour Name qdf_timer_init(qdf_handle_t hdl, qdf_timer_t *timer, qdf_timer_func_t func,
49*5113495bSYour Name void *arg, QDF_TIMER_TYPE type)
50*5113495bSYour Name {
51*5113495bSYour Name return __qdf_timer_init(timer, func, arg, type);
52*5113495bSYour Name }
53*5113495bSYour Name
54*5113495bSYour Name /**
55*5113495bSYour Name * qdf_timer_start() - start a timer
56*5113495bSYour Name * @timer: timer to start
57*5113495bSYour Name * @msec: Expiration period in milliseconds
58*5113495bSYour Name *
59*5113495bSYour Name * If QDF timer multiplier is set, the timeout value may get scaled.
60*5113495bSYour Name *
61*5113495bSYour Name * Return: none
62*5113495bSYour Name */
qdf_timer_start(qdf_timer_t * timer,int msec)63*5113495bSYour Name static inline void qdf_timer_start(qdf_timer_t *timer, int msec)
64*5113495bSYour Name {
65*5113495bSYour Name __qdf_timer_start(timer, msec);
66*5113495bSYour Name }
67*5113495bSYour Name
68*5113495bSYour Name /**
69*5113495bSYour Name * qdf_timer_start_on() - start a timer on assigned cpu
70*5113495bSYour Name * @timer: timer to start
71*5113495bSYour Name * @msec: Expiration period in milliseconds
72*5113495bSYour Name * @cpu: cpu to attach timer
73*5113495bSYour Name *
74*5113495bSYour Name *
75*5113495bSYour Name * Return: none
76*5113495bSYour Name */
qdf_timer_start_on(qdf_timer_t * timer,int msec,int cpu)77*5113495bSYour Name static inline void qdf_timer_start_on(qdf_timer_t *timer, int msec, int cpu)
78*5113495bSYour Name {
79*5113495bSYour Name __qdf_timer_start_on(timer, msec, cpu);
80*5113495bSYour Name }
81*5113495bSYour Name
82*5113495bSYour Name /**
83*5113495bSYour Name * qdf_timer_mod() - modify the timeout on a timer
84*5113495bSYour Name * @timer: timer to modify
85*5113495bSYour Name * @msec: Expiration period in milliseconds
86*5113495bSYour Name *
87*5113495bSYour Name * If @timer is not active, it will be activated.
88*5113495bSYour Name *
89*5113495bSYour Name * If QDF timer multiplier is set, the timeout value may get scaled.
90*5113495bSYour Name *
91*5113495bSYour Name * Return: true if @timer is already active, false if @timer was not active
92*5113495bSYour Name */
qdf_timer_mod(qdf_timer_t * timer,int msec)93*5113495bSYour Name static inline bool qdf_timer_mod(qdf_timer_t *timer, int msec)
94*5113495bSYour Name {
95*5113495bSYour Name return __qdf_timer_mod(timer, msec);
96*5113495bSYour Name }
97*5113495bSYour Name
98*5113495bSYour Name /**
99*5113495bSYour Name * qdf_timer_stop() - cancel a timer
100*5113495bSYour Name * @timer: timer to cancel
101*5113495bSYour Name *
102*5113495bSYour Name * Note! The timer callback may be executing when this function call returns.
103*5113495bSYour Name * If you want to ensure that it is not, use qdf_timer_sync_cancel() instead.
104*5113495bSYour Name *
105*5113495bSYour Name * Return: true if @timer was deactivated, false if @timer was not active
106*5113495bSYour Name */
qdf_timer_stop(qdf_timer_t * timer)107*5113495bSYour Name static inline bool qdf_timer_stop(qdf_timer_t *timer)
108*5113495bSYour Name {
109*5113495bSYour Name return __qdf_timer_stop(timer);
110*5113495bSYour Name }
111*5113495bSYour Name
112*5113495bSYour Name /**
113*5113495bSYour Name * qdf_timer_sync_cancel - Cancel a timer synchronously
114*5113495bSYour Name * @timer: timer to cancel
115*5113495bSYour Name *
116*5113495bSYour Name * If the timer callback is already running, this function blocks until it
117*5113495bSYour Name * completes.
118*5113495bSYour Name *
119*5113495bSYour Name * Return: true if @timer was deactivated, false if @timer was not active
120*5113495bSYour Name */
qdf_timer_sync_cancel(qdf_timer_t * timer)121*5113495bSYour Name static inline bool qdf_timer_sync_cancel(qdf_timer_t *timer)
122*5113495bSYour Name {
123*5113495bSYour Name return __qdf_timer_sync_cancel(timer);
124*5113495bSYour Name }
125*5113495bSYour Name
126*5113495bSYour Name /**
127*5113495bSYour Name * qdf_timer_free() - free a timer
128*5113495bSYour Name * @timer: timer to free
129*5113495bSYour Name *
130*5113495bSYour Name * If the timer callback is already running, this function blocks until it
131*5113495bSYour Name * completes.
132*5113495bSYour Name *
133*5113495bSYour Name * Return: none
134*5113495bSYour Name */
qdf_timer_free(qdf_timer_t * timer)135*5113495bSYour Name static inline void qdf_timer_free(qdf_timer_t *timer)
136*5113495bSYour Name {
137*5113495bSYour Name __qdf_timer_free(timer);
138*5113495bSYour Name }
139*5113495bSYour Name
140*5113495bSYour Name #endif /* _QDF_TIMER_H */
141