blob: f9c3b6567699dca22256475bf1382d8b8ac60482 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam1ed83fc2014-02-19 01:15:45 -08002 * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam1ed83fc2014-02-19 01:15:45 -080021
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Jeff Johnson295189b2012-06-20 16:38:30 -070028#if !defined( __VOS_SCHED_H )
29#define __VOS_SCHED_H
30
31/**=========================================================================
32
33 \file vos_sched.h
34
35 \brief virtual Operating System Servies (vOSS)
36
37 Definitions for some of the internal data type that is internally used
38 by the vOSS scheduler on Windows Mobile.
39
40 This file defines a vOSS message queue on Win Mobile and give some
41 insights about how the scheduler implements the execution model supported
42 by vOSS.
43
44
Jeff Johnson295189b2012-06-20 16:38:30 -070045
46 ========================================================================*/
47
48/*===========================================================================
49
50 EDIT HISTORY FOR FILE
51
52
53 This section contains comments describing changes made to the module.
54 Notice that changes are listed in reverse chronological order.
55
56
57 $Header:$ $DateTime: $ $Author: $
58
59
60 when who what, where, why
61 -------- --- --------------------------------------------------------
62 09/15/08 lac Removed hardcoded #define for VOS_TRACE.
63 06/12/08 hba Created module.
64
65===========================================================================*/
66
67/*--------------------------------------------------------------------------
68 Include Files
69 ------------------------------------------------------------------------*/
70#include <vos_event.h>
Vinay Krishna Eranna2025d892014-09-18 16:51:42 +053071#include <vos_nvitem.h>
72#include <vos_mq.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070073#include "i_vos_types.h"
74#include "i_vos_packet.h"
75#include <linux/wait.h>
76#include <linux/wakelock.h>
Jeff Johnson295189b2012-06-20 16:38:30 -070077
78#define TX_POST_EVENT_MASK 0x001
79#define TX_SUSPEND_EVENT_MASK 0x002
80#define MC_POST_EVENT_MASK 0x001
81#define MC_SUSPEND_EVENT_MASK 0x002
Jeff Johnson295189b2012-06-20 16:38:30 -070082#define RX_POST_EVENT_MASK 0x001
83#define RX_SUSPEND_EVENT_MASK 0x002
Jeff Johnson295189b2012-06-20 16:38:30 -070084#define TX_SHUTDOWN_EVENT_MASK 0x010
85#define MC_SHUTDOWN_EVENT_MASK 0x010
Jeff Johnson295189b2012-06-20 16:38:30 -070086#define RX_SHUTDOWN_EVENT_MASK 0x010
Jeff Johnson295189b2012-06-20 16:38:30 -070087#define WD_POST_EVENT_MASK 0x001
88#define WD_SHUTDOWN_EVENT_MASK 0x002
89#define WD_CHIP_RESET_EVENT_MASK 0x004
90#define WD_WLAN_SHUTDOWN_EVENT_MASK 0x008
91#define WD_WLAN_REINIT_EVENT_MASK 0x010
92
93
94
95/*
96** Maximum number of messages in the system
97** These are buffers to account for all current messages
98** with some accounting of what we think is a
99** worst-case scenario. Must be able to handle all
100** incoming frames, as well as overhead for internal
101** messaging
102*/
103#define VOS_CORE_MAX_MESSAGES (VPKT_NUM_RX_RAW_PACKETS + 32)
104
105
106/*
107** vOSS Message queue definition.
108*/
109typedef struct _VosMqType
110{
111 /* Lock use to synchronize access to this message queue */
112 spinlock_t mqLock;
113
114 /* List of vOS Messages waiting on this queue */
115 struct list_head mqList;
116
117} VosMqType, *pVosMqType;
118
119
120/*
121** vOSS Scheduler context
122** The scheduler context contains the following:
123** ** the messages queues
124** ** the handle to the tread
125** ** pointer to the events that gracefully shutdown the MC and Tx threads
126**
127*/
128typedef struct _VosSchedContext
129{
130 /* Place holder to the VOSS Context */
131 v_PVOID_t pVContext;
Jeff Johnson295189b2012-06-20 16:38:30 -0700132 /* WDA Message queue on the Main thread*/
133 VosMqType wdaMcMq;
Jeff Johnson295189b2012-06-20 16:38:30 -0700134
135
136
137 /* PE Message queue on the Main thread*/
138 VosMqType peMcMq;
139
140 /* SME Message queue on the Main thread*/
141 VosMqType smeMcMq;
142
143 /* TL Message queue on the Main thread */
144 VosMqType tlMcMq;
145
146 /* SYS Message queue on the Main thread */
147 VosMqType sysMcMq;
148
Jeff Johnson295189b2012-06-20 16:38:30 -0700149 /* WDI Message queue on the Main thread*/
150 VosMqType wdiMcMq;
151
152 /* WDI Message queue on the Tx Thread*/
153 VosMqType wdiTxMq;
154
155 /* WDI Message queue on the Rx Thread*/
156 VosMqType wdiRxMq;
Jeff Johnson295189b2012-06-20 16:38:30 -0700157
158 /* TL Message queue on the Tx thread */
159 VosMqType tlTxMq;
160
Katya Nigam664f5032014-05-05 12:24:32 +0530161 /* TL Message queue on the Rx thread */
162 VosMqType tlRxMq;
163
Jeff Johnson295189b2012-06-20 16:38:30 -0700164 /* SYS Message queue on the Tx thread */
165 VosMqType sysTxMq;
166
Jeff Johnson295189b2012-06-20 16:38:30 -0700167 VosMqType sysRxMq;
Jeff Johnson295189b2012-06-20 16:38:30 -0700168
169 /* Handle of Event for MC thread to signal startup */
170 struct completion McStartEvent;
171
172 /* Handle of Event for Tx thread to signal startup */
173 struct completion TxStartEvent;
174
Jeff Johnson295189b2012-06-20 16:38:30 -0700175 /* Handle of Event for Rx thread to signal startup */
176 struct completion RxStartEvent;
Jeff Johnson295189b2012-06-20 16:38:30 -0700177
178 struct task_struct* McThread;
179
180 /* TX Thread handle */
181
182 struct task_struct* TxThread;
183
Jeff Johnson295189b2012-06-20 16:38:30 -0700184 /* RX Thread handle */
185 struct task_struct* RxThread;
Jeff Johnson295189b2012-06-20 16:38:30 -0700186
187
188 /* completion object for MC thread shutdown */
189 struct completion McShutdown;
190
191 /* completion object for Tx thread shutdown */
192 struct completion TxShutdown;
193
Jeff Johnson295189b2012-06-20 16:38:30 -0700194 /* completion object for Rx thread shutdown */
195 struct completion RxShutdown;
Jeff Johnson295189b2012-06-20 16:38:30 -0700196
197 /* Wait queue for MC thread */
198 wait_queue_head_t mcWaitQueue;
199
200 unsigned long mcEventFlag;
201
202 /* Wait queue for Tx thread */
203 wait_queue_head_t txWaitQueue;
204
205 unsigned long txEventFlag;
206
Jeff Johnson295189b2012-06-20 16:38:30 -0700207 /* Wait queue for Rx thread */
208 wait_queue_head_t rxWaitQueue;
209
210 unsigned long rxEventFlag;
Jeff Johnson295189b2012-06-20 16:38:30 -0700211
212 /* Completion object to resume Mc thread */
213 struct completion ResumeMcEvent;
214
215 /* Completion object to resume Tx thread */
216 struct completion ResumeTxEvent;
217
Jeff Johnson295189b2012-06-20 16:38:30 -0700218 /* Completion object to resume Rx thread */
219 struct completion ResumeRxEvent;
Jeff Johnson295189b2012-06-20 16:38:30 -0700220
221 /* lock to make sure that McThread and TxThread Suspend/resume mechanism is in sync*/
222 spinlock_t McThreadLock;
223 spinlock_t TxThreadLock;
224 spinlock_t RxThreadLock;
225
226} VosSchedContext, *pVosSchedContext;
227
228/*
229** VOSS watchdog context
230** The watchdog context contains the following:
231** The messages queues and events
232** The handle to the thread
233**
234*/
235typedef struct _VosWatchdogContext
236{
237
238 /* Place holder to the VOSS Context */
239 v_PVOID_t pVContext;
240
241 /* Handle of Event for Watchdog thread to signal startup */
242 struct completion WdStartEvent;
243
244 /* Watchdog Thread handle */
245
246 struct task_struct* WdThread;
247
248 /* completion object for Watchdog thread shutdown */
249 struct completion WdShutdown;
250
251 /* Wait queue for Watchdog thread */
252 wait_queue_head_t wdWaitQueue;
253
254 /* Event flag for events handled by Watchdog */
255 unsigned long wdEventFlag;
256
257 v_BOOL_t resetInProgress;
258
Pradeep Kumar Goudagunta22d8e4d2014-07-17 15:03:51 +0530259 v_BOOL_t isFatalError;
260
Jeff Johnson295189b2012-06-20 16:38:30 -0700261 /* Lock for preventing multiple reset being triggered simultaneously */
262 spinlock_t wdLock;
263
264} VosWatchdogContext, *pVosWatchdogContext;
265
266/*
267** vOSS Sched Msg Wrapper
268** Wrapper messages so that they can be chained to their respective queue
269** in the scheduler.
270*/
271typedef struct _VosMsgWrapper
272{
273 /* Message node */
274 struct list_head msgNode;
275
276 /* the Vos message it is associated to */
277 vos_msg_t *pVosMsg;
278
279} VosMsgWrapper, *pVosMsgWrapper;
280
281
282
283typedef struct _VosContextType
284{
285 /* Messages buffers */
286 vos_msg_t aMsgBuffers[VOS_CORE_MAX_MESSAGES];
287
288 VosMsgWrapper aMsgWrappers[VOS_CORE_MAX_MESSAGES];
289
290 /* Free Message queue*/
291 VosMqType freeVosMq;
292
293 /* Scheduler Context */
294 VosSchedContext vosSched;
295
296 /* Watchdog Context */
297 VosWatchdogContext vosWatchdog;
298
299 /* HDD Module Context */
300 v_VOID_t *pHDDContext;
301
Jeff Johnson295189b2012-06-20 16:38:30 -0700302 /* HDD SoftAP Module Context */
303 v_VOID_t *pHDDSoftAPContext;
Jeff Johnson295189b2012-06-20 16:38:30 -0700304
305 /* TL Module Context */
306 v_VOID_t *pTLContext;
307
308 /* MAC Module Context */
309 v_VOID_t *pMACContext;
310
Jeff Johnson295189b2012-06-20 16:38:30 -0700311 /* BAP Context */
312 v_VOID_t *pBAPContext;
313
Jeff Johnson295189b2012-06-20 16:38:30 -0700314 /* SAP Context */
315 v_VOID_t *pSAPContext;
Jeff Johnson295189b2012-06-20 16:38:30 -0700316
317 /* VOS Packet Context */
318 vos_pkt_context_t vosPacket;
319
320 vos_event_t ProbeEvent;
321
322 volatile v_U8_t isLogpInProgress;
323
Jeff Johnson295189b2012-06-20 16:38:30 -0700324 vos_event_t wdaCompleteEvent;
325
326 /* WDA Context */
327 v_VOID_t *pWDAContext;
Jeff Johnson295189b2012-06-20 16:38:30 -0700328
329 volatile v_U8_t isLoadUnloadInProgress;
330
Sameer Thalappil9ab2fe52013-10-22 12:50:24 -0700331 /* SSR re-init in progress */
332 volatile v_U8_t isReInitInProgress;
333
Leo Chang80de3c22013-11-26 10:52:12 -0800334 /* NV BIN Version */
335 eNvVersionType nvVersion;
336
Girish Gowlia33f0372015-01-19 15:39:04 +0530337 /* Roam delay statistic enabled in ini*/
338 v_U8_t roamDelayStatsEnabled;
Sachin Ahuja715aafc2015-07-21 23:35:10 +0530339
340 /*Fw log complete Event*/
341 vos_event_t fwLogsComplete;
Jeff Johnson295189b2012-06-20 16:38:30 -0700342} VosContextType, *pVosContextType;
343
344
345
346/*---------------------------------------------------------------------------
347 Function declarations and documenation
348---------------------------------------------------------------------------*/
349
350int vos_sched_is_tx_thread(int threadID);
Jeff Johnson295189b2012-06-20 16:38:30 -0700351int vos_sched_is_rx_thread(int threadID);
Jeff Johnson295189b2012-06-20 16:38:30 -0700352/*---------------------------------------------------------------------------
353
354 \brief vos_sched_open() - initialize the vOSS Scheduler
355
356 The \a vos_sched_open() function initializes the vOSS Scheduler
357 Upon successful initialization:
358
359 - All the message queues are initialized
360
361 - The Main Controller thread is created and ready to receive and
362 dispatch messages.
363
364 - The Tx thread is created and ready to receive and dispatch messages
365
366
367 \param pVosContext - pointer to the global vOSS Context
368
369 \param pVosSchedContext - pointer to a previously allocated buffer big
370 enough to hold a scheduler context.
371 \
372
373 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
374 is ready to be used.
375
376 VOS_STATUS_E_RESOURCES - System resources (other than memory)
377 are unavailable to initilize the scheduler
378
379 VOS_STATUS_E_NOMEM - insufficient memory exists to initialize
380 the scheduler
381
382 VOS_STATUS_E_INVAL - Invalid parameter passed to the scheduler Open
383 function
384
385 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
386
387 \sa vos_sched_open()
388
389 -------------------------------------------------------------------------*/
390VOS_STATUS vos_sched_open( v_PVOID_t pVosContext,
391 pVosSchedContext pSchedCxt,
392 v_SIZE_t SchedCtxSize);
393
394/*---------------------------------------------------------------------------
395
396 \brief vos_watchdog_open() - initialize the vOSS watchdog
397
398 The \a vos_watchdog_open() function initializes the vOSS watchdog. Upon successful
399 initialization, the watchdog thread is created and ready to receive and process messages.
400
401
402 \param pVosContext - pointer to the global vOSS Context
403
404 \param pWdContext - pointer to a previously allocated buffer big
405 enough to hold a watchdog context.
406
407 \return VOS_STATUS_SUCCESS - Watchdog was successfully initialized and
408 is ready to be used.
409
410 VOS_STATUS_E_RESOURCES - System resources (other than memory)
411 are unavailable to initilize the Watchdog
412
413 VOS_STATUS_E_NOMEM - insufficient memory exists to initialize
414 the Watchdog
415
416 VOS_STATUS_E_INVAL - Invalid parameter passed to the Watchdog Open
417 function
418
419 VOS_STATUS_E_FAILURE - Failure to initialize the Watchdog/
420
421 \sa vos_watchdog_open()
422
423 -------------------------------------------------------------------------*/
424
425VOS_STATUS vos_watchdog_open
426
427(
428 v_PVOID_t pVosContext,
429 pVosWatchdogContext pWdContext,
430 v_SIZE_t wdCtxSize
431);
432
433/*---------------------------------------------------------------------------
434
435 \brief vos_sched_close() - Close the vOSS Scheduler
436
437 The \a vos_sched_closes() function closes the vOSS Scheduler
438 Upon successful closing:
439
440 - All the message queues are flushed
441
442 - The Main Controller thread is closed
443
444 - The Tx thread is closed
445
446
447 \param pVosContext - pointer to the global vOSS Context
448
449 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
450 is ready to be used.
451
452 VOS_STATUS_E_INVAL - Invalid parameter passed to the scheduler Open
453 function
454
455 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
456
457 \sa vos_sched_close()
458
459---------------------------------------------------------------------------*/
460VOS_STATUS vos_sched_close( v_PVOID_t pVosContext);
461
462/*---------------------------------------------------------------------------
463
464 \brief vos_watchdog_close() - Close the vOSS Watchdog
465
466 The \a vos_watchdog_close() function closes the vOSS Watchdog
467 Upon successful closing:
468
469 - The Watchdog thread is closed
470
471
472 \param pVosContext - pointer to the global vOSS Context
473
474 \return VOS_STATUS_SUCCESS - Watchdog was successfully initialized and
475 is ready to be used.
476
477 VOS_STATUS_E_INVAL - Invalid parameter passed
478
479 VOS_STATUS_E_FAILURE - Failure to initialize the Watchdog/
480
481 \sa vos_watchdog_close()
482
483---------------------------------------------------------------------------*/
484VOS_STATUS vos_watchdog_close ( v_PVOID_t pVosContext );
485
486/* Helper routines provided to other VOS API's */
487VOS_STATUS vos_mq_init(pVosMqType pMq);
488void vos_mq_deinit(pVosMqType pMq);
489void vos_mq_put(pVosMqType pMq, pVosMsgWrapper pMsgWrapper);
490pVosMsgWrapper vos_mq_get(pVosMqType pMq);
491v_BOOL_t vos_is_mq_empty(pVosMqType pMq);
492pVosSchedContext get_vos_sched_ctxt(void);
493pVosWatchdogContext get_vos_watchdog_ctxt(void);
494VOS_STATUS vos_sched_init_mqs (pVosSchedContext pSchedContext);
495void vos_sched_deinit_mqs (pVosSchedContext pSchedContext);
496void vos_sched_flush_mc_mqs (pVosSchedContext pSchedContext);
497void vos_sched_flush_tx_mqs (pVosSchedContext pSchedContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700498void vos_sched_flush_rx_mqs (pVosSchedContext pSchedContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700499void clearWlanResetReason(void);
500
501void vos_timer_module_init( void );
502VOS_STATUS vos_watchdog_wlan_shutdown(void);
503VOS_STATUS vos_watchdog_wlan_re_init(void);
Pradeep Kumar Goudagunta22d8e4d2014-07-17 15:03:51 +0530504v_BOOL_t isSsrPanicOnFailure(void);
Mahesh A Saptasagar96395ab2014-04-08 12:48:39 +0530505void vos_ssr_protect(const char *caller_func);
506void vos_ssr_unprotect(const char *caller_func);
Jeff Johnson295189b2012-06-20 16:38:30 -0700507
508#endif // #if !defined __VOSS_SCHED_H