1 /****************************************************************************
2 **+-----------------------------------------------------------------------+**
3 **| |**
4 **| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved. |**
5 **| All rights reserved. |**
6 **| |**
7 **| Redistribution and use in source and binary forms, with or without |**
8 **| modification, are permitted provided that the following conditions |**
9 **| are met: |**
10 **| |**
11 **| * Redistributions of source code must retain the above copyright |**
12 **| notice, this list of conditions and the following disclaimer. |**
13 **| * Redistributions in binary form must reproduce the above copyright |**
14 **| notice, this list of conditions and the following disclaimer in |**
15 **| the documentation and/or other materials provided with the |**
16 **| distribution. |**
17 **| * Neither the name Texas Instruments nor the names of its |**
18 **| contributors may be used to endorse or promote products derived |**
19 **| from this software without specific prior written permission. |**
20 **| |**
21 **| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |**
22 **| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |**
23 **| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |**
24 **| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |**
25 **| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |**
26 **| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |**
27 **| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |**
28 **| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |**
29 **| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |**
30 **| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |**
31 **| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |**
32 **| |**
33 **+-----------------------------------------------------------------------+**
34 ****************************************************************************/
35
36 /****************************************************************************
37 *
38 * MODULE: GWSI_Synchronizer.c
39 * PURPOSE: GWSI Synchronizer used to synchronize between the CMD,INT,TX
40 *
41 ****************************************************************************/
42
43 #include "commonTypes.h"
44 #include "memMngrEx.h" /* MSDU */
45 #include "report.h"
46
47
48 /* First the TNETW Arbiter interface needs the HAL definitions to use them in its API */
49 #include "TNETWArb.h"
50 #include "TNETWIF.h"
51
52 /* Those are functions that he client can send to the GWSI Synchronizer */
53 /* The client wants to start its process */
54
55 /***********************************************************************************
56 Internal Synchronizer function use
57 **************************************************************************************/
58
59 /****************************************************************************
60 * TNETWArb_Init()
61 ****************************************************************************
62 * DESCRIPTION: Initialize the synchronizer database.
63 *
64 * INPUTS: TI_HANDLE hOs
65 *
66 * OUTPUT:
67 *
68 * RETURNS: TI_HANDLE hTNETWArb - Handle of the TNETW Arbiter module
69 ****************************************************************************/
TNETWArb_Init(TI_HANDLE hOs)70 TI_HANDLE TNETWArb_Init (TI_HANDLE hOs)
71 {
72 /* Handle to TNETW Arbiter struct */
73 TNETWArb_t *pTNETWArb;
74
75 pTNETWArb = (TNETWArb_t *)os_memoryAlloc (hOs, sizeof(TNETWArb_t));
76 if (pTNETWArb == NULL)
77 return NULL;
78
79 os_memoryZero (hOs, pTNETWArb, sizeof(TNETWArb_t));
80
81 pTNETWArb->hOs = hOs;
82
83
84
85 /* Get the TNETW Arbiter SM handle */
86 pTNETWArb->hTNETWArbSM = TNETWArbSM_Create(hOs);
87
88 return (TI_HANDLE)pTNETWArb;
89 }
90
91
92 /****************************************************************************
93 * TNETWArb_Config()
94 ****************************************************************************
95 * DESCRIPTION: Configure the TNETWIF module
96 *
97 * INPUTS: TI_HANDLE hTNETWArb
98 * TI_HANDLE hReport
99 * TI_HANDLE hELPCtrl
100 *
101 * OUTPUT: void
102 *
103 * RETURNS: void
104 ****************************************************************************/
105
TNETWArb_Config(TI_HANDLE hTNETWArb,TI_HANDLE hReport,TI_HANDLE hELPCtrl)106 void TNETWArb_Config (TI_HANDLE hTNETWArb,TI_HANDLE hReport,TI_HANDLE hELPCtrl)
107 {
108
109 /* Handle to TNETW Arbiter struct */
110 TNETWArb_t *pTNETWArb = (TNETWArb_t *)hTNETWArb;
111 UINT8 index;
112
113 pTNETWArb->hReport = hReport;
114
115 /* Init buffer Q lists */
116 for(index = 0 ; index < NUM_OF_TNETWARB_QUEUES ; index++)
117 {
118 TNETWArb_init_q (&(pTNETWArb->TNETWArbiter_Queues[index]));
119 }
120
121 /* CAll the TNETW Arbiter Initializeto set the buffer free and their next buffer to NULL */
122 TNETWArb_buffer_init(&(pTNETWArb->TNETWArb_Client_Instance_Array[0][0]));
123
124
125 /* Clear the Event to dispatch bit */
126 pTNETWArb->event_to_dispatch&=~TNETWARB_IS_EVENT_PENDING;
127
128 /* For now the Handle to theBus Arbiter is NULL */
129 TNETWArbSM_Init(pTNETWArb->hTNETWArbSM,pTNETWArb->hReport,hTNETWArb,hELPCtrl,NULL);
130 }
131
132
133 /****************************************************************************/
134 /* TNETWIF_Destroy()
135 ****************************************************************************
136 * DESCRIPTION: Destroy The TNETWIF Module
137 *
138 * INPUTS:
139 *
140 * OUTPUT: String the name of the Queue
141 *
142 * RETURNS:
143 ****************************************************************************/
TNETWArb_Destroy(TI_HANDLE hTNETWArb)144 TI_STATUS TNETWArb_Destroy (TI_HANDLE hTNETWArb)
145 {
146
147 /* Handle to TNETW Arbiter struct */
148 TNETWArb_t *pTNETWArb = (TNETWArb_t *)hTNETWArb;
149
150
151 /* Call the TNETWArb SM Destruction function */
152 if (pTNETWArb->hTNETWArbSM)
153 TNETWArbSM_Destroy (pTNETWArb->hTNETWArbSM);
154
155 /* Free the TNETW Arbiter memory */
156 if (pTNETWArb)
157 os_memoryFree(pTNETWArb->hOs, pTNETWArb, sizeof(TNETWArb_t));
158
159 return OK;
160
161 }
162
163 /****************************************************************************
164 * TNETWArb_register_handler()
165 ****************************************************************************
166 * DESCRIPTION: Register the Client Callback function to the TNETW Arbiter
167 * This function will be called in case of DMA Done i.e BusTXn Complete
168 *
169 * INPUTS: TI_HANDLE hTNETWArb
170 * UINT8 module_id
171 * TNETWIF_callback_t module_CB_Func
172 * TI_HANDLE module_handle
173 *
174 * OUTPUT: void
175 *
176 * RETURNS: void
177 ****************************************************************************/
TNETWArb_register_handler(TI_HANDLE hTNETWArb,UINT8 module_id,TNETWIF_callback_t module_CB_Func,TI_HANDLE module_handle)178 void TNETWArb_register_handler(TI_HANDLE hTNETWArb,UINT8 module_id,TNETWIF_callback_t module_CB_Func,TI_HANDLE module_handle)
179 {
180 /* Handle to TNETW Arbiter struct */
181 TNETWArb_t *pTNETWArb = (TNETWArb_t *)hTNETWArb;
182 TNETWARB_INSTANCE_T *pTNETWARB_Inst;
183
184 /* Get the pointer to the TNETWARB_INSTANCE struct */
185 pTNETWARB_Inst = (TNETWARB_INSTANCE_T *) (&(pTNETWArb->TNETWArb_Client_Instance_Array[module_id][BUFFER_HDR_SIZE]));
186
187 pTNETWARB_Inst->module_id = module_id;
188 pTNETWARB_Inst->instance_callback = module_CB_Func;
189 pTNETWARB_Inst->instance_handle = module_handle;
190
191 if (module_id == DEFAULT_MODULE_ID)
192 pTNETWArb->pDefInst = pTNETWARB_Inst;
193 }
194
195
196 /****************************************************************************
197 * TNETWArb_Start()
198 ****************************************************************************
199 * DESCRIPTION: Client registration to the TNETW Arbiter whishing to have **
200 ** access to the Bus
201 *
202 * INPUTS: TI_HANDLE hTNETWArb
203 * UINT8 module_id
204 * TI_HANDLE ClientCallBack_Handle
205 * TNETWIF_callback_t module_CB_Func
206 *
207 * OUTPUT: void
208 *
209 * RETURNS: TI_STATUS - TNETWIF_ERROR - In case that the Client is already registered to the TNETWIF
210 * TNETWIF_COMPLETE - In case that the Client callback has been immediately called
211 * TNETWIF_PENDING - In case that the Client will be called later
212 ****************************************************************************/
TNETWArb_Start(TI_HANDLE hTNETWArb,UINT8 module_id,TI_HANDLE ClientCallBack_Handle,TNETWIF_callback_t ClientCallBack_Func)213 TI_STATUS TNETWArb_Start (TI_HANDLE hTNETWArb, UINT8 module_id, TI_HANDLE ClientCallBack_Handle, TNETWIF_callback_t ClientCallBack_Func)
214 {
215 /* Handle to TNETW Arbiter struct */
216 TNETWArb_t *pTNETWArb = (TNETWArb_t *)hTNETWArb;
217 TNETWARB_INSTANCE_T *pTNETWARB_Inst;
218 TI_STATUS ret;
219
220 WLAN_REPORT_INFORMATION (pTNETWArb->hReport, TNETW_ARBITER_MODULE_LOG,
221 ("\n TNETWArb_Start: Register START to Synchronizer from module_id %x \n",module_id));
222
223 #ifdef TI_DBG
224 pTNETWArb->stat.uStart ++;
225 #endif
226
227 /* Get the instance buffer matching to the module_id */
228 pTNETWARB_Inst = (TNETWARB_INSTANCE_T *) TNETWArb_getpoolbuf(hTNETWArb,module_id);
229
230 /* If the instance is already allocated then return error to Client caller */
231 if(pTNETWARB_Inst == NULL)
232 {
233 WLAN_REPORT_ERROR(pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG,("\n TNETWArb_Start Module %s Already requested TNETWIF!!!! \n", TNETWIF_ModuleIdToString(module_id)));
234 TNETWIF_printErrorLog();
235 return TNETWIF_ERROR;
236 }
237
238 TNETWArb_Enqueue (&(pTNETWArb->TNETWArbiter_Queues[TODO_LIST_INDEX]), (void*)pTNETWARB_Inst);
239
240 WLAN_REPORT_INFORMATION(pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG,("TNETWArb_Start: Enqueue in TODO: module %s, pTNETWARB_Inst %x instance_handle: %X\n", TNETWIF_ModuleIdToString(module_id), pTNETWARB_Inst,ClientCallBack_Handle));
241
242 /* Fill the Client instance with the callback handle and function passed in the call */
243 pTNETWARB_Inst->module_id = module_id;
244 pTNETWARB_Inst->instance_callback = ClientCallBack_Func;
245 pTNETWARB_Inst->instance_handle = ClientCallBack_Handle;
246
247 WLAN_REPORT_INFORMATION (pTNETWArb->hReport, TNETW_ARBITER_MODULE_LOG,
248 ("\n TNETWArb_Start: Call TNETWArbSM_SMEvent with TNETWARBSM_EV_START for module %s \n",TNETWIF_ModuleIdToString(module_id)));
249
250 /* Send the event EV_REG to the TNETW Arbiter for handling and take appropriate actions */
251 ret = TNETWArbSM_SMEvent (pTNETWArb->hTNETWArbSM,
252 (module_id == FW_EVENT_MODULE_ID) ? TNETWARBSM_EV_HW_AVAIL : TNETWARBSM_EV_START);
253
254 return ret;
255 }
256
257
258
259 /*********************************************************************************************************
260 ** **
261 ** Function Name: TNETWArb_Restart **
262 ** **
263 ** Description: Client Re-registration to the TNETW Arbiter whishing to **
264 ** regain access to the Bus **
265 ** This will do the following: **
266 ** 1) Remove the instance from the Running Instance **
267 ** 2) Add it to the TODO Queue **
268 ** 3) Will set the Current event to be dispatched later on **
269 ** from where the Restart was called inside the TNETW Arbiter **
270 ** This is done to prevent nesting operations from within the Client context **
271 ** **
272 **********************************************************************************************************/
TNETWArb_Restart(TI_HANDLE hTNETWArb,UINT8 module_id,TI_HANDLE ClientCallBack_Handle,TNETWIF_callback_t ClientCallBack_Func)273 TI_STATUS TNETWArb_Restart (TI_HANDLE hTNETWArb,UINT8 module_id,TI_HANDLE ClientCallBack_Handle,TNETWIF_callback_t ClientCallBack_Func)
274 {
275 /* Handle to TNETW Arbiter struct */
276 TNETWArb_t *pTNETWArb = (TNETWArb_t *)hTNETWArb;
277 TNETWARB_INSTANCE_T *pTNETWARB_Inst;
278
279 #ifdef TNETWARB_DEBUG
280 /* For debug, verify that the running instance is not NULL. */
281 if(pTNETWArb->TNETWArb_Running_instance == NULL )
282 {
283 WLAN_REPORT_ERROR(pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG,
284 ("TNETWArb_Restart: There is no module running, requested by module %d\n", module_id));
285 return TNETWIF_ERROR;
286 }
287
288 /* For debug check that the instance requesting restart is really the running instance */
289 if(pTNETWArb->TNETWArb_Running_instance->module_id != module_id )
290 {
291 /* In this case return to caller ERROR */
292 return TNETWIF_ERROR;
293 }
294 #endif
295
296 #ifdef TI_DBG
297 pTNETWArb->stat.uRestart ++;
298 #endif
299
300 /* Take the Running instance control block */
301 pTNETWARB_Inst = pTNETWArb->TNETWArb_Running_instance ;
302
303 /* First indicate that there is not any handle in the Running instance */
304 pTNETWArb->TNETWArb_Running_instance = NULL;
305
306 /* Enqueue the client request or i.e its instance in the TODO List */
307 TNETWArb_Enqueue(&(pTNETWArb->TNETWArbiter_Queues[TODO_LIST_INDEX]), (void*)pTNETWARB_Inst);
308
309 WLAN_REPORT_INFORMATION(pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG,("TNETWArb_Restart: Enqueue in TODO: module %s, instance_handle: %X\n", TNETWIF_ModuleIdToString(module_id), ClientCallBack_Handle));
310
311 /* Fill the Client instance with the callback handle and function given by the call */
312 pTNETWARB_Inst->module_id = module_id;
313 pTNETWARB_Inst->instance_callback = ClientCallBack_Func;
314 pTNETWARB_Inst->instance_handle = ClientCallBack_Handle;
315
316
317 /* Set the event to dispatch so that when this function will return back then the context will return to the TNETW Arbiter */
318 /* Then the TNETW Arbiter will dispatch the event to the STate Machine within its context and not within the Client context
319 to prevent nesting of many calls and prevent to increse the stack */
320 pTNETWArb->event_to_dispatch = TNETWARBSM_EV_RESTART;
321 pTNETWArb->event_to_dispatch|=TNETWARB_IS_EVENT_PENDING;
322
323 /* Return Pending since the Restart will be handled in a later context */
324 return TNETWIF_PENDING;
325
326 }
327
328 /*********************************************************************************************************
329 ** **
330 ** Function Name: TNETWArb_Finish **
331 ** **
332 ** Description: Client De-registration to the TNETW Arbiter whishing to **
333 ** release access to the Bus **
334 ** This will do the following: **
335 ** 1) Remove the instance from the Running Instance **
336 ** 3) Will set the Current event to be dispatched later on **
337 ** from where the Finish was called inside the TNETW Arbiter **
338 ** This is done to prevent nesting operations from within the Client context **
339 ** **
340 **********************************************************************************************************/
TNETWArb_Finish(TI_HANDLE hTNETWArb,UINT8 module_id,TI_HANDLE ClientCallBack_Handle,TNETWIF_callback_t ClientCallBack_Func)341 TI_STATUS TNETWArb_Finish (TI_HANDLE hTNETWArb,UINT8 module_id,TI_HANDLE ClientCallBack_Handle,TNETWIF_callback_t ClientCallBack_Func)
342 {
343 /* Handle to TNETW Arbiter struct */
344 TNETWArb_t *pTNETWArb = (TNETWArb_t *)hTNETWArb;
345 TNETWARB_INSTANCE_T *pTNETWARB_Inst;
346
347 #ifdef TNETWARB_DEBUG
348 /* For debug, verify that the running instance is not NULL. */
349 if(pTNETWArb->TNETWArb_Running_instance == NULL )
350 {
351 WLAN_REPORT_ERROR(pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG,
352 ("TNETWArb_Finish: There is no module running, requested by module %d\n", module_id));
353 return TNETWIF_ERROR;
354 }
355
356 /* For debug check that the instance requesting restart is really the running instance */
357 if(pTNETWArb->TNETWArb_Running_instance->module_id != module_id )
358 {
359 WLAN_REPORT_ERROR(pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG,
360 ("TNETWArb_Finish: Module %s is not Running module %s is Running \n",
361 TNETWIF_ModuleIdToString(module_id),
362 TNETWIF_ModuleIdToString(pTNETWArb->TNETWArb_Running_instance->module_id)));
363 /* In this case return to caller ERROR */
364 return TNETWIF_ERROR;
365 }
366
367 #endif
368
369 #ifdef TI_DBG
370 pTNETWArb->stat.uFinish ++;
371 #endif
372
373 /* Take the Running instance control block */
374 pTNETWARB_Inst = pTNETWArb->TNETWArb_Running_instance ;
375
376 WLAN_REPORT_INFORMATION(pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG,
377 ("TNETWArb_Finish: module %s, instance_handle: %X\n",
378 TNETWIF_ModuleIdToString(module_id),
379 pTNETWARB_Inst->instance_handle));
380
381 /* Free the buffer instance */
382 TNETWArb_freebuf((void *)pTNETWARB_Inst);
383
384 /* Indicate that there is not any handle in the Running instance */
385 pTNETWArb->TNETWArb_Running_instance = NULL;
386
387 /* Fill the Client instance with NULL callback to ease debugging */
388 pTNETWARB_Inst->module_id = module_id;
389 pTNETWARB_Inst->instance_callback = NULL;
390 pTNETWARB_Inst->instance_handle = NULL;
391
392
393 /* Now check the Event to send to the TNETW Arbiter State Machine */
394 /* If there are more reequest in the TODO Queue then Send PROCESS_NEXT_EV else send FINISH event to TNETW Arbiter */
395 if(TNETWArb_getfirst(&(pTNETWArb->TNETWArbiter_Queues[TODO_LIST_INDEX])))
396 {
397 /* Set the event to dispatch so that when this function will return back then the context will return to the TNETW Arbiter */
398 /* Then the TNETW Arbiter will dispatch the event to the STate Machine within its context and not within the Client context
399 to prevent nesting of many calls and prevent to increse the stack */
400 pTNETWArb->event_to_dispatch = TNETWARBSM_EV_RESTART;
401 WLAN_REPORT_INFORMATION(pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG ,
402 ("TNETWArb_Finish: module %s, instance_handle: %x Send TNETWARBSM_EV_RESTART \n",
403 TNETWIF_ModuleIdToString(module_id),
404 pTNETWARB_Inst->instance_handle));
405
406 }
407 else
408 {
409 /* Set the event to dispatch so that when this function will return back then the context will return to the TNETW Arbiter */
410 /* Then the TNETW Arbiter will dispatch the event to the STate Machine within its context and not within the Client context
411 to prevent nesting of many calls and prevent to increse the stack */
412 pTNETWArb->event_to_dispatch = TNETWARBSM_EV_FINISH;
413 WLAN_REPORT_INFORMATION(pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG,
414 ("TNETWArb_Finish: module %s, TNETWARBSM_EV_FINISH \n",
415 TNETWIF_ModuleIdToString(module_id),
416 pTNETWARB_Inst->instance_handle));
417
418 }
419
420
421 pTNETWArb->event_to_dispatch|=TNETWARB_IS_EVENT_PENDING;
422
423 /* Return Pending since the Process_Next/Finish Event will be handled in a later context */
424 return TNETWIF_COMPLETE;
425
426 }
427
428
429 /****************************************************************************
430 * TNETWArb_CallTxnCb()
431 ****************************************************************************
432 * DESCRIPTION: This function is used to call the client callback function that was previously
433 * supplied to the TNETWIF via 2 ways:
434 * 1) When the Client requested with TNETWIF_Start to access the Bus
435 * 2) When the Client call the TNETWIF with Async or Optimzed mode.
436 * In this case the callback will be called when the DMA will finish.
437 *
438 * Note :The Client can request FINISHor RESTART bu the TNETW Arbiter state machine will
439 * be sent the event only after that the client function callback returns.
440 * This is done to prevent a deep nesting in case of RESTART.
441 *
442 * INPUTS: TI_HANDLE hTNETWArb
443 *
444 * OUTPUT: void
445 *
446 * RETURNS: void
447 ****************************************************************************/
TNETWArb_CallTxnCb(TI_HANDLE hTNETWArb)448 TI_STATUS TNETWArb_CallTxnCb (TI_HANDLE hTNETWArb)
449 {
450 TNETWArb_t *pTNETWArb = (TNETWArb_t *)hTNETWArb;
451 TNETWARB_INSTANCE_T *pTNETWArbInst;
452
453 /*
454 * If the pDefInst is not NULL it is a special arbiter client (ELP control).
455 * Call the ELP control callback.
456 */
457 if (pTNETWArb->pDefInst != NULL)
458 {
459 pTNETWArbInst = pTNETWArb->pDefInst;
460 pTNETWArb->pDefInst = NULL;
461
462 if (pTNETWArbInst->instance_callback != NULL)
463 ((TNETWIF_callback_t)(pTNETWArbInst->instance_callback))
464 (pTNETWArbInst->instance_handle, pTNETWArbInst->module_id, OK);
465
466 return TNETWIF_COMPLETE;
467 }
468
469 /* Otherwise, call a regular arbiter client callback */
470 else
471 {
472 return TNETWArb_CallClientCallback (hTNETWArb);
473 }
474 }
475
476
477
478 /****************************************************************************
479 * TNETWArb_CallClientCallback()
480 ****************************************************************************
481 * DESCRIPTION: This function is used to call the client callback function that was previously
482 * supplied to the TNETWIF via 2 ways:
483 * 1) When the Client requested with TNETWIF_Start to access the Bus
484 * 2) When the Client call the TNETWIF with Async or Optimzed mode.
485 * In this case the callback will be called when the DMA will finish.
486 *
487 * Note :The Client can request FINISHor RESTART bu the TNETW Arbiter state machine will
488 * be sent the event only after that the client function callback returns.
489 * This is done to prevent a deep nesting in case of RESTART.
490 *
491 * INPUTS: TI_HANDLE hTNETWArb
492 *
493 * OUTPUT: void
494 *
495 * RETURNS: void
496 ****************************************************************************/
TNETWArb_CallClientCallback(TI_HANDLE hTNETWArb)497 TI_STATUS TNETWArb_CallClientCallback (TI_HANDLE hTNETWArb)
498 {
499 /* Handle to TNETW Arbiter struct */
500 TNETWArb_t *pTNETWArb = (TNETWArb_t *)hTNETWArb;
501 TNETWARB_INSTANCE_T *pTNETWARB_Inst;
502
503 /* Take the Running instance control block */
504 if (pTNETWArb->TNETWArb_Running_instance != NULL)
505 {
506 pTNETWARB_Inst = pTNETWArb->TNETWArb_Running_instance;
507 }
508 else
509 {
510 WLAN_REPORT_ERROR (pTNETWArb->hReport, TNETW_ARBITER_MODULE_LOG,
511 ("TNETWArb_CallClientCallback: no running instance\n"));
512 TNETWIF_printErrorLog();
513
514 return TNETWIF_ERROR;
515 }
516
517 /* Call the client callback */
518 if (pTNETWARB_Inst->instance_callback != NULL)
519 ((TNETWIF_callback_t)(pTNETWARB_Inst->instance_callback))
520 (pTNETWARB_Inst->instance_handle, pTNETWARB_Inst->module_id, OK);
521
522 /* Check if there is an event to be dispatch */
523 if (pTNETWArb->event_to_dispatch & TNETWARB_IS_EVENT_PENDING)
524 {
525 TI_STATUS status;
526
527 pTNETWArb->event_to_dispatch &= ~TNETWARB_IS_EVENT_PENDING;
528
529
530 /* Now check the Event to send to the TNETW Arbiter State Machine */
531 /* If there are more request in the TODO Queue then Send PROCESS_NEXT_EV else send FINISH event to TNETW Arbiter */
532 if (TNETWArb_getfirst (&pTNETWArb->TNETWArbiter_Queues[TODO_LIST_INDEX]))
533 {
534 /* Set the event to dispatch so that when this function will return back then the context will return to the TNETW Arbiter */
535 /* Then the TNETW Arbiter will dispatch the event to the STate Machine within its context and not within the Client context
536 to prevent nesting of many calls and prevent to increase the stack */
537 pTNETWArb->event_to_dispatch = TNETWARBSM_EV_RESTART;
538 status = TNETWIF_PENDING;
539 WLAN_REPORT_INFORMATION (pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG ,("TNETWArb_CallClientCallback: module %s, instance_handle: %x Send TNETWARBSM_EV_RESTART \n", TNETWIF_ModuleIdToString(pTNETWARB_Inst->module_id), pTNETWARB_Inst->instance_handle));
540 }
541 else
542 {
543 /* Set the event to dispatch so that when this function will return back then the context will return to the TNETW Arbiter */
544 /* Then the TNETW Arbiter will dispatch the event to the STate Machine within its context and not within the Client context
545 to prevent nesting of many calls and prevent to increase the stack */
546 pTNETWArb->event_to_dispatch = TNETWARBSM_EV_FINISH;
547 status = TNETWIF_COMPLETE;
548 WLAN_REPORT_INFORMATION (pTNETWArb->hReport,TNETW_ARBITER_MODULE_LOG,("TNETWArb_CallClientCallback: module %s, TNETWARBSM_EV_FINISH \n", TNETWIF_ModuleIdToString(pTNETWARB_Inst->module_id), pTNETWARB_Inst->instance_handle));
549 }
550
551 WLAN_REPORT_INFORMATION (pTNETWArb->hReport, TNETW_ARBITER_MODULE_LOG, ("TNETWArb_CallClientCallback: module %s, instance_handle: %x Send pTNETWArb->event_to_dispatch %d \n", TNETWIF_ModuleIdToString(pTNETWARB_Inst->module_id), pTNETWARB_Inst->instance_handle, pTNETWArb->event_to_dispatch));
552
553 TNETWArbSM_SMEvent (pTNETWArb->hTNETWArbSM, pTNETWArb->event_to_dispatch);
554
555 return status;
556 }
557
558 return TNETWIF_PENDING;
559 }
560
561
562 /****************************************************************************
563 * TNETWArb_TxnCb()
564 ****************************************************************************
565 * DESCRIPTION: ELP Controller Callabck - Indicate to the TNETWArb that the HW is now Available
566 * The FW has waken up.
567 *
568 * INPUTS: hTNETWArb - the handle to the TNETW Arbiter
569 *
570 * OUTPUT:
571 *
572 * RETURNS: OK
573 ****************************************************************************/
TNETWArb_TxnCb(TI_HANDLE hTNETWArb,UINT8 module_id,TI_STATUS status)574 void TNETWArb_TxnCb (TI_HANDLE hTNETWArb, UINT8 module_id, TI_STATUS status)
575 {
576 TNETWArb_t *pTNETWArb = (TNETWArb_t *)hTNETWArb;
577
578 TNETWArbSM_TxnCb (pTNETWArb->hTNETWArbSM);
579 }
580
581
582 #ifdef TI_DBG
TNETWArb_PrintStat(TI_HANDLE hTNETWArb)583 void TNETWArb_PrintStat (TI_HANDLE hTNETWArb)
584 {
585 TNETWArb_t *pTNETWArb = (TNETWArb_t *)hTNETWArb;
586
587 WLAN_OS_REPORT (("Num of start = %u\n", pTNETWArb->stat.uStart));
588 WLAN_OS_REPORT (("Num of restart = %u\n", pTNETWArb->stat.uRestart));
589 WLAN_OS_REPORT (("Num of finish = %u\n", pTNETWArb->stat.uFinish));
590
591 TNETWIF_printErrorLog();
592 }
593 #endif
594
595
596 /****************************************************************************
597 * BusArbiter_Recovery()
598 ****************************************************************************
599 * DESCRIPTION: handles the recovery
600 *
601 * INPUTS: TI_HANDLE hBusArbiter
602 *
603 * OUTPUT: void
604 *
605 * RETURNS: void
606 ****************************************************************************/
TNETWArb_Recovery(TI_HANDLE hTNETWArb,TI_HANDLE hELPCtrl)607 TI_STATUS TNETWArb_Recovery(TI_HANDLE hTNETWArb, TI_HANDLE hELPCtrl)
608 {
609 TNETWArb_t *pTNETWArb = (TNETWArb_t *)hTNETWArb;
610
611 /* should be updated - see CE20 */
612 TNETWArb_Config (hTNETWArb, pTNETWArb->hReport, hELPCtrl);
613 return OK;
614
615 }
616
617