1 /*
2  * Copyright (c) 2011-2019 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /*
21  * @file VossWrapper.h
22  *
23  * @brief This header file contains the various structure definitions and
24  * function prototypes for the RTOS abstraction layer, implemented for VOSS
25  */
26 
27 #ifndef __VOSS_WRAPPER_H
28 #define __VOSS_WRAPPER_H
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 
35 /*---------------------------------------------------------------------------
36  * Include Files
37  * ------------------------------------------------------------------------*/
38 
39 #include "sir_types.h"
40 #include "sir_params.h"
41 #include "sys_def.h"
42 #include "qdf_mc_timer.h"
43 #include "qdf_types.h"
44 #include "qdf_trace.h"
45 #include "qdf_mem.h"
46 
47 /* Interlocked Compare Exchange related definitions */
48 
49 /* Define basic constants for the ThreadX kernel.  */
50 
51 #define TX_AUTO_ACTIVATE    1
52 #define TX_NO_ACTIVATE      0
53 
54 /* API return values.  */
55 #define TX_SUCCESS          0x00
56 #define TX_QUEUE_FULL    0x01
57 /* ... */
58 #define TX_NO_INSTANCE      0x0D
59 /* ... */
60 #define TX_TIMER_ERROR      0x15
61 #define TX_TICK_ERROR       0x16
62 /* ... */
63 
64 #ifndef true
65 #define true                1
66 #endif
67 
68 #ifndef false
69 #define false               0
70 #endif
71 
72 /* Following macro specifies the number of milliseconds which constitute 1 ThreadX timer tick. Used
73    for mimicking the ThreadX timer behaviour on VOSS. */
74 /* Use the same MACRO used by firmware modules to calculate TICKs from mSec */
75 /* Mismatch would cause wrong timer value to be programmed */
76 #define TX_MSECS_IN_1_TICK  SYS_TICK_DUR_MS
77 
78 /* Signature with which the TX_TIMER struct is initialized, when the timer is created */
79 #define TX_AIRGO_TMR_SIGNATURE   0xDEADBEEF
80 
81 #ifdef TIMER_MANAGER
82 #define  tx_timer_create(a, b, c, d, e, f, g, h)    tx_timer_create_intern_debug((void *)a, b, c, d, e, f, g, h, __FILE__, __LINE__)
83 #else
84 #define  tx_timer_create(a, b, c, d, e, f, g, h)    tx_timer_create_intern((void *)a, b, c, d, e, f, g, h)
85 #endif
86 
87 /*--------------------------------------------------------------------*/
88 /* Timer structure                                                    */
89 /* This structure is used to implement ThreadX timer facility.  Just  */
90 /* like ThreadX, timer expiration handler executes at the highest     */
91 /* possible priority level, i.e. DISPATCH_LEVEL.                      */
92 /*--------------------------------------------------------------------*/
93 typedef struct TX_TIMER_STRUCT {
94 #ifdef WLAN_DEBUG
95 #define TIMER_MAX_NAME_LEN 50
96 	char timerName[TIMER_MAX_NAME_LEN];
97 #endif
98 	uint8_t sessionId;
99 	uint32_t expireInput;
100 	uint64_t tmrSignature;
101 	void (*pExpireFunc)(void *, uint32_t);
102 	uint64_t initScheduleTimeInMsecs;
103 	uint64_t rescheduleTimeInMsecs;
104 	qdf_mc_timer_t qdf_timer;
105 
106 	/* Pointer to the MAC global structure, which stores the context for the NIC, */
107 	/* for which this timer is supposed to operate. */
108 	void *mac;
109 
110 } TX_TIMER;
111 
112 #define TX_TIMER_VALID(timer) (timer.mac != 0)
113 
114 uint32_t tx_timer_activate(TX_TIMER *);
115 uint32_t tx_timer_change(TX_TIMER *, uint64_t, uint64_t);
116 uint32_t tx_timer_change_context(TX_TIMER *, uint32_t);
117 #ifdef TIMER_MANAGER
118 uint32_t tx_timer_create_intern_debug(void *, TX_TIMER *,
119 				      char *, void (*)(void *,
120 						       uint32_t),
121 				      uint32_t, uint64_t,
122 				      uint64_t, uint64_t,
123 				      char *fileName,
124 				      uint32_t lineNum);
125 #else
126 uint32_t tx_timer_create_intern(void *, TX_TIMER *, char *,
127 				void (*)(void *, uint32_t),
128 				uint32_t, uint64_t, uint64_t,
129 				uint64_t);
130 #endif
131 uint32_t tx_timer_deactivate(TX_TIMER *);
132 uint32_t tx_timer_delete(TX_TIMER *);
133 bool tx_timer_running(TX_TIMER *);
134 
135 #ifdef __cplusplus
136 }
137 #endif
138 #endif
139