blob: 7dcd7a59123fe340a3de879e72f62a76633bda6c [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhishek Singh880d7122015-08-26 16:23:04 +05302 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
Kiet Lam1ed83fc2014-02-19 01:15:45 -08003 *
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);
Abhishek Singh880d7122015-08-26 16:23:04 +0530352int vos_sched_is_mc_thread(int threadID);
Jeff Johnson295189b2012-06-20 16:38:30 -0700353/*---------------------------------------------------------------------------
354
355 \brief vos_sched_open() - initialize the vOSS Scheduler
356
357 The \a vos_sched_open() function initializes the vOSS Scheduler
358 Upon successful initialization:
359
360 - All the message queues are initialized
361
362 - The Main Controller thread is created and ready to receive and
363 dispatch messages.
364
365 - The Tx thread is created and ready to receive and dispatch messages
366
367
368 \param pVosContext - pointer to the global vOSS Context
369
370 \param pVosSchedContext - pointer to a previously allocated buffer big
371 enough to hold a scheduler context.
372 \
373
374 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
375 is ready to be used.
376
377 VOS_STATUS_E_RESOURCES - System resources (other than memory)
378 are unavailable to initilize the scheduler
379
380 VOS_STATUS_E_NOMEM - insufficient memory exists to initialize
381 the scheduler
382
383 VOS_STATUS_E_INVAL - Invalid parameter passed to the scheduler Open
384 function
385
386 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
387
388 \sa vos_sched_open()
389
390 -------------------------------------------------------------------------*/
391VOS_STATUS vos_sched_open( v_PVOID_t pVosContext,
392 pVosSchedContext pSchedCxt,
393 v_SIZE_t SchedCtxSize);
394
395/*---------------------------------------------------------------------------
396
397 \brief vos_watchdog_open() - initialize the vOSS watchdog
398
399 The \a vos_watchdog_open() function initializes the vOSS watchdog. Upon successful
400 initialization, the watchdog thread is created and ready to receive and process messages.
401
402
403 \param pVosContext - pointer to the global vOSS Context
404
405 \param pWdContext - pointer to a previously allocated buffer big
406 enough to hold a watchdog context.
407
408 \return VOS_STATUS_SUCCESS - Watchdog was successfully initialized and
409 is ready to be used.
410
411 VOS_STATUS_E_RESOURCES - System resources (other than memory)
412 are unavailable to initilize the Watchdog
413
414 VOS_STATUS_E_NOMEM - insufficient memory exists to initialize
415 the Watchdog
416
417 VOS_STATUS_E_INVAL - Invalid parameter passed to the Watchdog Open
418 function
419
420 VOS_STATUS_E_FAILURE - Failure to initialize the Watchdog/
421
422 \sa vos_watchdog_open()
423
424 -------------------------------------------------------------------------*/
425
426VOS_STATUS vos_watchdog_open
427
428(
429 v_PVOID_t pVosContext,
430 pVosWatchdogContext pWdContext,
431 v_SIZE_t wdCtxSize
432);
433
434/*---------------------------------------------------------------------------
435
436 \brief vos_sched_close() - Close the vOSS Scheduler
437
438 The \a vos_sched_closes() function closes the vOSS Scheduler
439 Upon successful closing:
440
441 - All the message queues are flushed
442
443 - The Main Controller thread is closed
444
445 - The Tx thread is closed
446
447
448 \param pVosContext - pointer to the global vOSS Context
449
450 \return VOS_STATUS_SUCCESS - Scheduler was successfully initialized and
451 is ready to be used.
452
453 VOS_STATUS_E_INVAL - Invalid parameter passed to the scheduler Open
454 function
455
456 VOS_STATUS_E_FAILURE - Failure to initialize the scheduler/
457
458 \sa vos_sched_close()
459
460---------------------------------------------------------------------------*/
461VOS_STATUS vos_sched_close( v_PVOID_t pVosContext);
462
463/*---------------------------------------------------------------------------
464
465 \brief vos_watchdog_close() - Close the vOSS Watchdog
466
467 The \a vos_watchdog_close() function closes the vOSS Watchdog
468 Upon successful closing:
469
470 - The Watchdog thread is closed
471
472
473 \param pVosContext - pointer to the global vOSS Context
474
475 \return VOS_STATUS_SUCCESS - Watchdog was successfully initialized and
476 is ready to be used.
477
478 VOS_STATUS_E_INVAL - Invalid parameter passed
479
480 VOS_STATUS_E_FAILURE - Failure to initialize the Watchdog/
481
482 \sa vos_watchdog_close()
483
484---------------------------------------------------------------------------*/
485VOS_STATUS vos_watchdog_close ( v_PVOID_t pVosContext );
486
487/* Helper routines provided to other VOS API's */
488VOS_STATUS vos_mq_init(pVosMqType pMq);
489void vos_mq_deinit(pVosMqType pMq);
490void vos_mq_put(pVosMqType pMq, pVosMsgWrapper pMsgWrapper);
491pVosMsgWrapper vos_mq_get(pVosMqType pMq);
492v_BOOL_t vos_is_mq_empty(pVosMqType pMq);
493pVosSchedContext get_vos_sched_ctxt(void);
494pVosWatchdogContext get_vos_watchdog_ctxt(void);
495VOS_STATUS vos_sched_init_mqs (pVosSchedContext pSchedContext);
496void vos_sched_deinit_mqs (pVosSchedContext pSchedContext);
497void vos_sched_flush_mc_mqs (pVosSchedContext pSchedContext);
498void vos_sched_flush_tx_mqs (pVosSchedContext pSchedContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700499void vos_sched_flush_rx_mqs (pVosSchedContext pSchedContext);
Jeff Johnson295189b2012-06-20 16:38:30 -0700500void clearWlanResetReason(void);
501
502void vos_timer_module_init( void );
503VOS_STATUS vos_watchdog_wlan_shutdown(void);
504VOS_STATUS vos_watchdog_wlan_re_init(void);
Pradeep Kumar Goudagunta22d8e4d2014-07-17 15:03:51 +0530505v_BOOL_t isSsrPanicOnFailure(void);
Mahesh A Saptasagar96395ab2014-04-08 12:48:39 +0530506void vos_ssr_protect(const char *caller_func);
507void vos_ssr_unprotect(const char *caller_func);
Jeff Johnson295189b2012-06-20 16:38:30 -0700508
509#endif // #if !defined __VOSS_SCHED_H