Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
csr_wifi_fsm_types.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  (c) Cambridge Silicon Radio Limited 2011
4  All rights reserved and confidential information of CSR
5 
6  Refer to LICENSE.txt included with this source for details
7  on the license terms.
8 
9 *****************************************************************************/
10 
11 #ifndef CSR_WIFI_FSM_TYPES_H
12 #define CSR_WIFI_FSM_TYPES_H
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 #include <linux/types.h>
19 #include "csr_macro.h"
20 #include "csr_panic.h"
21 #include "csr_sched.h"
22 
23 #ifdef CSR_WIFI_FSM_MUTEX_ENABLE
24 #include "csr_framework_ext.h"
25 #endif
26 
27 #include "csr_wifi_fsm.h"
28 
29 #define CSR_WIFI_FSM_MAX_TRANSITION_HISTORY 10
30 
38 typedef struct CsrWifiFsmEventList
39 {
43 
44 
53 typedef struct CsrWifiFsmTimerId
54 {
60 
70 typedef struct CsrWifiFsmTimer
71 {
76 
77  /* Private pointer to allow an optimal Event list */
79 
83 
84 
93 typedef struct
94 {
96  void *alienEvent;
98 
99 
107 typedef struct CsrWifiFsmTimerList
108 {
113 
128 
145 
160 
176 
177 
178 #ifdef CSR_WIFI_FSM_DUMP_ENABLE
179 
192 typedef void (*CsrWifiFsmDumpFnPtr)(CsrWifiFsmContext *context, void *fsmData);
193 #endif
194 
202 typedef struct
203 {
206 #ifdef CSR_LOG_ENABLE
207  const char *transitionName;
208 #endif
210 
219 typedef struct
220 {
221  const u8 numEntries;
222  const u8 saveAll;
223  const CsrWifiFsmEventEntry *eventEntryArray; /* array of transition function pointers for state */
224 #ifdef CSR_LOG_ENABLE
225  u16 stateNumber;
226  const char *stateName;
227 #endif
229 
237 typedef struct
238 {
239  u16 numStates; /* number of states */
240  const CsrWifiFsmTableEntry *aStateEventMatrix; /* state event matrix */
242 
252 typedef struct
253 {
254  const char *processName;
255  const u32 processId;
261 #ifdef CSR_WIFI_FSM_DUMP_ENABLE
262  const CsrWifiFsmDumpFnPtr dumpFn; /* Called to dump fsm specific trace if not NULL */
263 #endif
265 
266 #ifdef CSR_WIFI_FSM_DUMP_ENABLE
267 
271 typedef struct
272 {
273  u16 transitionNumber;
275  u16 fromState;
276  u16 toState;
277  CsrWifiFsmTransitionFnPtr transitionFn;
278  u16 transitionCount; /* number consecutive of times this transition was seen */
279 #ifdef CSR_LOG_ENABLE
280  const char *transitionName;
281 #endif
282 } CsrWifiFsmTransitionRecord;
283 
288 typedef struct
289 {
290  u16 numTransitions;
291  CsrWifiFsmTransitionRecord records[CSR_WIFI_FSM_MAX_TRANSITION_HISTORY];
292 } CsrWifiFsmTransitionRecords;
293 #endif
294 
303 typedef struct
304 {
305  const CsrWifiFsmProcessStateMachine *fsmInfo; /* state machine info that is constant regardless of context */
306  u16 instanceId; /* Runtime process id */
307  u16 state; /* Current state */
308  void *params; /* Instance user data */
309  CsrWifiFsmEventList savedEventQueue; /* The saved event queue */
310  struct CsrWifiFsmInstanceEntry *subFsm; /* Sub Fsm instance data */
311  struct CsrWifiFsmInstanceEntry *subFsmCaller; /* The Fsm instance that created the SubFsm and should be used for callbacks*/
312 #ifdef CSR_WIFI_FSM_DUMP_ENABLE
313  CsrWifiFsmTransitionRecords transitionRecords; /* Last X transitions in the FSM */
314 #endif
316 
330 typedef void (*CsrWifiFsmOnCreateFnPtr)(void *extContext, const CsrWifiFsmInstanceEntry *instance);
331 
346 typedef void (*CsrWifiFsmOnTransitionFnPtr)(void *extContext, const CsrWifiFsmEventEntry *eventEntryArray, const CsrWifiFsmEvent *event);
347 
360 typedef void (*CsrWifiFsmOnStateChangeFnPtr)(void *extContext, u16 nextstate);
361 
375 typedef void (*CsrWifiFsmOnEventFnPtr)(void *extContext, const CsrWifiFsmEvent *event);
376 
385 {
386  CsrWifiFsmEventList eventQueue; /* The internal event queue */
387  CsrWifiFsmEventList externalEventQueue; /* The external event queue */
388 #ifdef CSR_WIFI_FSM_MUTEX_ENABLE
389  CsrMutexHandle externalEventQueueLock; /* The external event queue mutex */
390 #endif
391  u32 timeOffset; /* Amount to adjust the TimeOfDayMs by */
392  CsrWifiFsmTimerList timerQueue; /* The internal timer queue */
393  u8 useTempSaveList; /* Should the temp save list be used */
394  CsrWifiFsmEventList tempSaveList; /* The temp save event queue */
395  CsrWifiFsmEvent *eventForwardedOrSaved; /* The event that was forwarded or Saved */
396  u16 maxProcesses; /* Size of instanceArray */
397  u16 numProcesses; /* Current number allocated in instanceArray */
398  CsrWifiFsmInstanceEntry *instanceArray; /* Array of processes for this component */
399  CsrWifiFsmInstanceEntry *ownerInstance; /* The Process that owns currentInstance (SubFsm support) */
400  CsrWifiFsmInstanceEntry *currentInstance; /* Current Process that is executing */
402  CsrWifiFsmOnEventFnPtr appIgnoreCallback; /* Application Ignore event Callback */
403  CsrWifiFsmDestLookupCallbackPtr appEvtDstCallback; /* Application Lookup event Destination Function*/
404 
405  void *applicationContext; /* Internal fsm application context */
406  void *externalContext; /* External context (set by the user of the fsm)*/
407  CsrLogTextTaskId loggingTaskId; /* Task Id to use in any logging output */
408 
409 #ifndef CSR_WIFI_FSM_SCHEDULER_DISABLED
410  CsrSchedTid schedTimerId; /* Scheduler TimerId for use in Scheduler Tasks */
411  u32 schedTimerNexttimeoutMs; /* Next timeout time for the current timer */
412 #endif
413 
414 #ifdef CSR_WIFI_FSM_MUTEX_ENABLE
415 #ifdef CSR_WIFI_FSM_TRANSITION_LOCK
416  CsrMutexHandle transitionLock; /* Lock when calling transition functions */
417 #endif
418 #endif
419 
420 #ifdef CSR_LOG_ENABLE
421  CsrWifiFsmOnCreateFnPtr onCreate; /* Debug Transition Callback */
422  CsrWifiFsmOnTransitionFnPtr onTransition; /* Debug Transition Callback */
423  CsrWifiFsmOnTransitionFnPtr onUnhandedCallback; /* Unhanded event Callback */
424  CsrWifiFsmOnStateChangeFnPtr onStateChange; /* Debug State Change Callback */
425  CsrWifiFsmOnEventFnPtr onIgnoreCallback; /* Ignore event Callback */
426  CsrWifiFsmOnEventFnPtr onSaveCallback; /* Save event Callback */
427  CsrWifiFsmOnEventFnPtr onErrorCallback; /* Error event Callback */
428  CsrWifiFsmOnEventFnPtr onInvalidCallback; /* Invalid event Callback */
429 #endif
430 #ifdef CSR_WIFI_FSM_DUMP_ENABLE
431  u16 masterTransitionNumber; /* Increments on every transition */
432 #endif
433 };
434 
435 
436 #ifdef __cplusplus
437 }
438 #endif
439 
440 #endif /* CSR_WIFI_FSM_TYPES_H */