Home | History | Annotate | Download | only in Cmd_Queue
      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 #include "osTIType.h"
     36 #include "whalCommon.h"
     37 #include "whalHwDefs.h"
     38 #include "whalBus_Api.h"
     39 #include "CmdMBox_api.h"
     40 #include "CmdQueue_api.h"
     41 #include "CmdQueue.h"
     42 
     43 #ifdef TI_DBG
     44 static char *StateString[CMDQUEUE_STATE_NUM] = {
     45 	"CMDQUEUE_STATE_IDLE",  /* 0 */
     46 	"CMDQUEUE_STATE_SEND_CMD_v",  /* 1 */
     47 	"CMDQUEUE_STATE_WAIT_SEND_CMPLT",  /* 2 */
     48 	"CMDQUEUE_STATE_INTERROGATE_v",  /* 3 */
     49 	"CMDQUEUE_STATE_WAIT_RESULT",  /* 4 */
     50 	"CMDQUEUE_STATE_FINISH_v",  /* 5 */
     51 };
     52 
     53 static char *EventString[CMDQUEUE_EVENT_NUM] = {
     54 	"CMDQUEUE_EVENT_RUN",  /* 1 */
     55 	"CMDQUEUE_EVENT_SEND_CMPLT",  /* 2 */
     56 	"CMDQUEUE_EVENT_RESULT_RECEIVED",  /* 3 */
     57 };
     58 
     59 #endif /* TI_DBG */
     60 
     61 
     62 /****************************************************************************
     63  *                      CmdQueue_Create()
     64  ****************************************************************************
     65  * DESCRIPTION: Create the CmdQueue object
     66  *
     67  * INPUTS:  TI_HANDLE *hOs
     68  *
     69  * OUTPUT:  None
     70  *
     71  * RETURNS: The Created object
     72  *****************************************************************************/
     73 TI_HANDLE CmdQueue_Create(TI_HANDLE hOs)
     74 {
     75 
     76     CmdQueue_T  *pObj;
     77 
     78     pObj = os_memoryAlloc(hOs, sizeof(CmdQueue_T));
     79     if (pObj == NULL)
     80     {
     81         WLAN_OS_REPORT(("FATAL ERROR: CmdQueue_Create(): Error Creating CmdQueue - Aborting\n"));
     82         return NULL;
     83     }
     84 
     85     /* reset control module control block */
     86     os_memoryZero(hOs, pObj, sizeof(CmdQueue_T));
     87     pObj->hOs = hOs;
     88 
     89     return(pObj);
     90 }
     91 
     92 
     93 /****************************************************************************
     94  *                      CmdQueue_Destroy()
     95  ****************************************************************************
     96  * DESCRIPTION: Destroy the object
     97  *
     98  * INPUTS:  hCmdQueue   The object to free
     99  *
    100  * OUTPUT:  None
    101  *
    102  * RETURNS: OK or NOK
    103  ****************************************************************************/
    104 int					CmdQueue_Destroy(TI_HANDLE hCmdQueue)
    105 {
    106 	CmdQueue_T* pCmdQueue = (CmdQueue_T*)	hCmdQueue;
    107 
    108 	/* free context */
    109        os_memoryFree(pCmdQueue->hOs, pCmdQueue, sizeof(CmdQueue_T));
    110 
    111 	return OK;
    112 }
    113 
    114 /****************************************************************************
    115  *                      CmdQueue_Config()
    116  ****************************************************************************
    117  * DESCRIPTION: Config the CmdQueue object
    118  *
    119  * INPUTS:
    120  *
    121  * OUTPUT:  None
    122  *
    123  * RETURNS: OK or NOK
    124  ****************************************************************************/
    125 int CmdQueue_Config (TI_HANDLE hCmdQueue, TI_HANDLE hCmdMBox, TI_HANDLE hReport)
    126 {
    127     CmdQueue_T* pCmdQueue = (CmdQueue_T*) hCmdQueue;
    128 
    129     pCmdQueue->Head = 0;
    130     pCmdQueue->Tail = 0;
    131     pCmdQueue->NumberOfCommandInQueue = 0;
    132     pCmdQueue->MaxNumberOfCommandInQueue = 0;
    133     pCmdQueue->State = CMDQUEUE_STATE_IDLE;
    134     pCmdQueue->CmdCompleteGenericCB_Func = NULL;
    135     pCmdQueue->CmdCompleteGenericCB_Arg = NULL;
    136     pCmdQueue->FailureCB = NULL;
    137     pCmdQueue->FailureCbHandle = NULL;
    138     pCmdQueue->SM_RC = 0;
    139     pCmdQueue->hReport = hReport;
    140     pCmdQueue->hCmdMBox = hCmdMBox;
    141     pCmdQueue->ErrorFlag = FALSE;
    142 
    143     /*
    144      * NOTE: don't set NumberOfRecoveryNodes = 0;
    145      *       its value is used by recovery process
    146      */
    147 
    148     return OK;
    149 }
    150 
    151 /****************************************************************************
    152  *                      CmdQueue_StartReconfig()
    153  ****************************************************************************
    154  * DESCRIPTION: Restart the module for recovery. Clean the queue but save al the CB in the queue.
    155  *
    156  * INPUTS:
    157  *
    158  * OUTPUT:
    159  *
    160  * RETURNS: OK or NOK
    161  ****************************************************************************/
    162 int					CmdQueue_StartReconfig(TI_HANDLE hCmdQueue)
    163 {
    164 	CmdQueue_T* pCmdQueue = (CmdQueue_T*)	hCmdQueue;
    165 	int CurrentCmdindex;
    166     	int first  = pCmdQueue->Head;
    167 	CmdQueue_CmdNode_T* pHead ;
    168 	CmdQueue_RecoveryNode_T* pRecoveryNode;
    169 
    170 	/*
    171 	stop the SM
    172 	*/
    173     	pCmdQueue->State = CMDQUEUE_STATE_IDLE;
    174 
    175 	WLAN_REPORT_INFORMATION(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
    176         							("CmdQueue_Clean: Cleaning CmdQueue Queue"));
    177 
    178 	/*
    179 	Save The Call Back Function in the Queue in order the return them after the recovery
    180 	with on error status
    181 	*/
    182 
    183 	/* Clean The Command Call Back Counter */
    184 	pCmdQueue->NumberOfRecoveryNodes = 0;
    185 	pRecoveryNode = &pCmdQueue->RecoveryQueue[pCmdQueue->NumberOfRecoveryNodes];
    186 	for(CurrentCmdindex = 0 ; CurrentCmdindex < pCmdQueue->NumberOfCommandInQueue ; CurrentCmdindex++)
    187     	{
    188 		pHead  =  &pCmdQueue->CmdQueue[first];
    189 
    190 		if(pHead->CB_Func != NULL)
    191 		{ /*Copy the interrogate CB and the interrogate data buffer pointer */
    192 			pRecoveryNode->CB_Func = pHead->CB_Func;
    193 			pRecoveryNode->CB_Arg = pHead->CB_Arg;
    194 			pRecoveryNode->interrogateParamsBuf = pHead->interrogateParamsBuf;
    195 			pCmdQueue->NumberOfRecoveryNodes++;
    196 			pRecoveryNode = &pCmdQueue->RecoveryQueue[pCmdQueue->NumberOfRecoveryNodes];
    197 		}
    198 		first++;
    199 		if(first == CMDQUEUE_QUEUE_DEPTH)
    200 			first = 0;
    201 	}
    202 
    203 	/*
    204 	init the queue
    205 	*/
    206 	pCmdQueue->Head = 0;
    207     pCmdQueue->Tail = 0;
    208     pCmdQueue->NumberOfCommandInQueue = 0;
    209 
    210 	return OK;
    211 }
    212 
    213 /****************************************************************************
    214  *                      CmdQueue_EndReconfig()
    215  ****************************************************************************
    216  * DESCRIPTION: Call the stored CB to end the recovery of the MBox queue
    217  *
    218  * INPUTS:
    219  *
    220  * OUTPUT:
    221  *
    222  * RETURNS: OK or NOK
    223  ****************************************************************************/
    224 int					CmdQueue_EndReconfig(TI_HANDLE hCmdQueue)
    225 {
    226 	CmdQueue_T* pCmdQueue = (CmdQueue_T*)	hCmdQueue;
    227 
    228 	int	Cbindex;
    229 	CmdQueue_RecoveryNode_T *pHead;
    230 
    231 	for(Cbindex = 0; Cbindex < pCmdQueue->NumberOfRecoveryNodes; Cbindex++)
    232 	{
    233 		pHead  =  &pCmdQueue->RecoveryQueue[Cbindex];
    234 
    235 		if(pHead->interrogateParamsBuf)
    236 	    	{
    237     			((CmdQueue_InterrogateCB_t)pHead->CB_Func)(pHead->CB_Arg, CMD_STATUS_FW_RESET,pHead->interrogateParamsBuf);
    238     		}
    239 		else
    240 		{
    241 			((CmdQueue_CB_t)pHead->CB_Func)(pHead->CB_Arg, CMD_STATUS_FW_RESET);
    242 		}
    243 	}
    244 
    245 	pCmdQueue->NumberOfRecoveryNodes = 0;
    246 
    247 	return OK;
    248 }
    249 
    250 /****************************************************************************
    251  *                 CmdQueue_RegisterCmdCompleteGenericCB()
    252  ****************************************************************************
    253  * DESCRIPTION: Register for a call back to be called when Command Complete
    254  *              Occur and the CmdMboxCB was NULL
    255  *
    256  * RETURNS:None
    257  ****************************************************************************/
    258 int					CmdQueue_RegisterCmdCompleteGenericCB(TI_HANDLE hCmdQueue, void *CB_Func, TI_HANDLE CB_handle)
    259 {
    260 	CmdQueue_T* pCmdQueue = (CmdQueue_T*)	hCmdQueue;
    261 
    262 	if ((CB_Func == NULL) || (CB_handle == NULL))
    263 	{
    264 		WLAN_REPORT_ERROR(pCmdQueue->hReport, HAL_CTRL_MODULE_LOG, ("CmdQueue_RegisterCmdCompleteGenericCB: NULL parameter\n"));
    265 		return NOK;
    266 	}
    267 
    268 	pCmdQueue->CmdCompleteGenericCB_Func = (CmdQueue_GenericCB_t)CB_Func;
    269 	pCmdQueue->CmdCompleteGenericCB_Arg = CB_handle;
    270 
    271 	return OK;
    272 }
    273 
    274 /****************************************************************************
    275  *                      CmdQueue_RegisterForErrorCB()
    276  ****************************************************************************
    277  * DESCRIPTION: Register for a call back to be called when an Error (Timeout)
    278  *              Occur
    279  *
    280  * RETURNS:None
    281  ****************************************************************************/
    282 int 					CmdQueue_RegisterForErrorCB(TI_HANDLE hCmdQueue, void *CB_Func, TI_HANDLE CB_handle)
    283 {
    284 	CmdQueue_T* pCmdQueue = (CmdQueue_T*)	hCmdQueue;
    285 
    286 	if ((CB_Func == NULL) || (CB_handle == NULL))
    287 	{
    288 		WLAN_REPORT_ERROR(pCmdQueue->hReport, HAL_CTRL_MODULE_LOG, ("CmdQueue_RegisterForErrorCB: NULL parameters\n"));
    289 		return NOK;
    290 	}
    291 
    292     	pCmdQueue->FailureCbHandle = CB_handle;
    293     	pCmdQueue->FailureCB = (CmdQueue_CB_t)CB_Func;
    294 
    295 	return OK;
    296 }
    297 
    298 /****************************************************************************
    299  *                      CmdQueue_CmdConfigure()
    300  ****************************************************************************
    301  * DESCRIPTION: Send configure command with its information element parameter
    302  *
    303  * INPUTS:
    304  *
    305  * OUTPUT:  None
    306  *
    307  * RETURNS: OK or NOK
    308  ****************************************************************************/
    309 int 					CmdQueue_CmdConfigure(TI_HANDLE hCmdQueue, void *MboxBuf,UINT32 ParamsLen)
    310 {
    311 	int status;
    312 	CmdQueue_T* pCmdQueue = (CmdQueue_T*)	hCmdQueue;
    313 
    314 	CHECK_ERROR_FLAG(pCmdQueue->ErrorFlag);
    315 
    316 	status = CmdQueue_Push(pCmdQueue, CMD_CONFIGURE,
    317                        				(UINT8*)MboxBuf, ParamsLen,
    318 					   		NULL, NULL, NULL);
    319 
    320 	CMDQUEUE_CONVERT_RC(status);
    321 }
    322 
    323 /****************************************************************************
    324  *                      CmdQueue_CmdConfigureWithCb()
    325  ****************************************************************************
    326  * DESCRIPTION: Send configure command with its information element parameter
    327  *
    328  * INPUTS:
    329  *
    330  * OUTPUT:  None
    331  *
    332  * RETURNS: OK or NOK
    333  ****************************************************************************/
    334 int					CmdQueue_CmdConfigureWithCb(TI_HANDLE hCmdQueue, void *MboxBuf, UINT32 ParamsLen,
    335 										 					void *CB_Func, TI_HANDLE CB_handle)
    336 {
    337 
    338 	int status;
    339 	CmdQueue_T* pCmdQueue = (CmdQueue_T*)	hCmdQueue;
    340 
    341 	CHECK_ERROR_FLAG(pCmdQueue->ErrorFlag);
    342 
    343 	status = CmdQueue_Push(pCmdQueue, CMD_CONFIGURE,
    344                        				(UINT8*)MboxBuf, ParamsLen,
    345 					   		CB_Func, CB_handle, NULL);
    346 
    347 	CMDQUEUE_CONVERT_RC(status);
    348 }
    349 
    350 
    351 #if 0
    352 
    353 /*
    354  * NOTE: The following function may NOT be used in fully asynchronous mode.
    355  *       Its source code remained only for easier backword rollback
    356  */
    357 
    358 /****************************************************************************
    359  *                      CmdQueue_CmdInterrogate()
    360  ****************************************************************************
    361  * DESCRIPTION: Send interrogate command with its information element parameter
    362  *
    363  * INPUTS:
    364  *
    365  * OUTPUT:  None
    366  *
    367  * RETURNS: OK or NOK
    368  ****************************************************************************/
    369 int     				CmdQueue_CmdInterrogate(TI_HANDLE hCmdQueue, void *MboxBuf, UINT32 ParamsLen)
    370 {
    371 	CmdQueue_T* pCmdQueue = (CmdQueue_T*)	hCmdQueue;
    372 	int status = OK;
    373 
    374 	CHECK_ERROR_FLAG(pCmdQueue->ErrorFlag);
    375 
    376 	status = CmdQueue_Push(pCmdQueue, CMD_INTERROGATE,
    377                        				(UINT8*)MboxBuf, ParamsLen,
    378 					   		NULL, NULL, (UINT8*)MboxBuf);
    379 
    380 	/*
    381 	cause we called an interrogate cmd without a CB function then the Cmd needs to be finished
    382 	in this context
    383 	*/
    384 	if (status == TNETWIF_PENDING)
    385 	{
    386 		WLAN_REPORT_ERROR(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
    387         		("CmdQueue_CmdInterrogate:Cmd INTERROGATE ,MboxBuf = 0x%x, Len = %d \n"
    388 		 	, MboxBuf, ParamsLen));
    389 	}
    390 
    391 	CMDQUEUE_CONVERT_RC(status);
    392 }
    393 #endif
    394 
    395 
    396 /****************************************************************************
    397  *                      CmdQueue_CmdInterrogateWithCb()
    398  ****************************************************************************
    399  * DESCRIPTION: Send interrogate command with its information element parameter
    400  *
    401  * INPUTS:
    402  *
    403  * OUTPUT:  None
    404  *
    405  * RETURNS: OK or NOK
    406  ****************************************************************************/
    407 int					CmdQueue_CmdInterrogateWithCb(TI_HANDLE hCmdQueue, void *MboxBuf, UINT32 ParamsLen,
    408 															void *CB_Func, TI_HANDLE CB_handle, void *CB_Buf)
    409 {
    410 	CmdQueue_T* pCmdQueue = (CmdQueue_T*)	hCmdQueue;
    411 	int status;
    412 
    413 	CHECK_ERROR_FLAG(pCmdQueue->ErrorFlag);
    414 
    415 	if((CB_Func == NULL) || (CB_handle == NULL) || (CB_Buf == NULL))
    416 	{
    417 		WLAN_REPORT_ERROR(pCmdQueue->hReport, HAL_CTRL_MODULE_LOG,
    418 			("CmdQueue_CommandWithCb: NULL parameters\n"));
    419 		return NOK;
    420 	}
    421 
    422 	status = CmdQueue_Push(pCmdQueue, CMD_INTERROGATE,
    423                        				(UINT8*)MboxBuf, ParamsLen,
    424 					   		CB_Func, CB_handle, (UINT8*)CB_Buf);
    425 
    426 	CMDQUEUE_CONVERT_RC(status);
    427 }
    428 
    429 /***************************************************************************
    430  *                      CmdQueue_Command()
    431  ****************************************************************************
    432  * DESCRIPTION: Send command to the wlan hardware command mailbox
    433  *
    434  * INPUTS:
    435  *
    436  * OUTPUT:  None
    437  *
    438  * RETURNS: OK or NOK
    439  ****************************************************************************/
    440 int	    				CmdQueue_Command(TI_HANDLE hCmdQueue, Command_e MboxCmdType, char *MboxBuf, UINT32 ParamsLen)
    441 {
    442 	CmdQueue_T* pCmdQueue = (CmdQueue_T*)	hCmdQueue;
    443 	int status;
    444 
    445 	CHECK_ERROR_FLAG(pCmdQueue->ErrorFlag);
    446 
    447 	status = CmdQueue_Push(pCmdQueue, MboxCmdType,
    448                        				(UINT8*)MboxBuf, ParamsLen,
    449 					   		NULL, NULL, NULL);
    450 
    451 	CMDQUEUE_CONVERT_RC(status);
    452 }
    453 
    454 /****************************************************************************
    455  *                      CmdQueue_CommandWithCb()
    456  ****************************************************************************
    457  * DESCRIPTION: Send command with CB to the wlan hardware command mailbox
    458  *
    459  * INPUTS:
    460  *
    461  * OUTPUT:  None
    462  *
    463  * RETURNS: OK or NOK
    464  ****************************************************************************/
    465 int	   			 	CmdQueue_CommandWithCb(TI_HANDLE hCmdQueue, Command_e MboxCmdType, void *MboxBuf, UINT32 ParamsLen,
    466 															void *CB_Func, TI_HANDLE CB_handle, void* CB_Buf)
    467 {
    468 	CmdQueue_T* pCmdQueue = (CmdQueue_T*)hCmdQueue;
    469 	int status;
    470 
    471 	CHECK_ERROR_FLAG(pCmdQueue->ErrorFlag);
    472 
    473 	if(((CB_Func != NULL) && (CB_handle == NULL)) || ((CB_Func == NULL) && (CB_handle != NULL)))
    474 	{
    475 		WLAN_REPORT_ERROR(pCmdQueue->hReport, HAL_CTRL_MODULE_LOG,
    476 			("CmdQueue_CommandWithCb: NULL Object with none NULL CB\n"));
    477 		return NOK;
    478 	}
    479 
    480 	status = CmdQueue_Push(pCmdQueue, MboxCmdType,
    481                        				(UINT8*)MboxBuf, ParamsLen,
    482 					   		CB_Func, CB_handle, (UINT8*)CB_Buf);
    483 
    484 	CMDQUEUE_CONVERT_RC(status);
    485 }
    486 
    487 
    488 /****************************************************************************
    489  *                      CmdQueue_Push()
    490  ****************************************************************************
    491  * DESCRIPTION: Push the command Node to the Queue with its information element parameter
    492  *
    493  * INPUTS:
    494  *
    495  * OUTPUT:  None
    496  *
    497  * RETURNS: NOK OK
    498  ****************************************************************************/
    499 int				CmdQueue_Push(CmdQueue_T  *pCmdQueue, Command_e  cmdType,
    500                        							UINT8* pParamsBuf, UINT32 paramsLen,
    501 					   					void *CB_Func, TI_HANDLE CB_Arg, UINT8* pCB_Buf)
    502 {
    503 
    504 #ifdef TI_DBG
    505 
    506 	/*
    507 	check if Queue is Full
    508 	*/
    509     	if(pCmdQueue->NumberOfCommandInQueue == CMDQUEUE_QUEUE_DEPTH)
    510     	{
    511 		WLAN_REPORT_ERROR(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
    512             		("CmdQueue_Push: ** ERROR ** The Queue is full\n"
    513 			 "CmdType = %s %s , Len = %d   InfoElemId = 0x%x\n",
    514 			 CmdQueue_GetCmdString(cmdType),
    515 			 CmdQueue_GetIEString( cmdType,*(UINT16 *)pParamsBuf), paramsLen, *(UINT16 *)pParamsBuf));
    516         	return  NOK;
    517     	}
    518 #endif /* TI_DBG*/
    519 
    520     /* initializes the last Node in the Queue with the arrgs */
    521     	pCmdQueue->CmdQueue[pCmdQueue->Tail].cmdType   = cmdType;
    522     	pCmdQueue->CmdQueue[pCmdQueue->Tail].paramsLen = paramsLen;
    523     	pCmdQueue->CmdQueue[pCmdQueue->Tail].CB_Func = CB_Func;
    524 	pCmdQueue->CmdQueue[pCmdQueue->Tail].CB_Arg = CB_Arg;
    525 	if(cmdType == CMD_INTERROGATE)
    526 	{
    527 		os_memoryCopy(pCmdQueue->hOs, pCmdQueue->CmdQueue[pCmdQueue->Tail].paramsBuf, pParamsBuf, CMDQUEUE_INFO_ELEM_HEADER_LEN);
    528 	}
    529 	else
    530 		os_memoryCopy(pCmdQueue->hOs, pCmdQueue->CmdQueue[pCmdQueue->Tail].paramsBuf, pParamsBuf, paramsLen);
    531 	pCmdQueue->CmdQueue[pCmdQueue->Tail].interrogateParamsBuf = pCB_Buf;
    532 
    533 	/*advance the Queue tail*/
    534 	pCmdQueue->Tail++;
    535 	if(pCmdQueue->Tail == CMDQUEUE_QUEUE_DEPTH)
    536 		pCmdQueue->Tail = 0;
    537 
    538 	/* update counters */
    539     	pCmdQueue->NumberOfCommandInQueue++;
    540 #ifdef TI_DBG
    541     	if(pCmdQueue->MaxNumberOfCommandInQueue < pCmdQueue->NumberOfCommandInQueue)
    542       		pCmdQueue->MaxNumberOfCommandInQueue = pCmdQueue->NumberOfCommandInQueue;
    543 #endif /* TI_DBG*/
    544 
    545     WLAN_REPORT_INFORMATION(pCmdQueue->hReport, CMDQUEUE_MODULE_LOG,
    546             ("CmdQueue_Push: CmdType = %s (%s(%d))\n"
    547 			"Len = %d, NumOfCmd = %d \n",
    548 			CmdQueue_GetCmdString(cmdType),
    549 			(pParamsBuf) ?  CmdQueue_GetIEString(cmdType,*(UINT16 *)pParamsBuf):"",
    550 			(pParamsBuf) ?  *(UINT16 *)pParamsBuf:0,
    551 			paramsLen, pCmdQueue->NumberOfCommandInQueue));
    552 
    553 	/*if Queue has only one command trigger the send command form Queue */
    554 	if (pCmdQueue->NumberOfCommandInQueue == 1)
    555 	{
    556 		return (CmdQueue_SM(pCmdQueue,CMDQUEUE_EVENT_RUN));
    557 	}
    558 	else
    559 		return (OK);
    560 }
    561 
    562 /****************************************************************************
    563  *                     CmdQueue_SM()
    564  ****************************************************************************
    565  * DESCRIPTION: inplement the CmdQueue SM
    566  *
    567  * INPUTS:
    568  *
    569  * OUTPUT:  None
    570  *
    571  * RETURNS: OK or NOK
    572  ****************************************************************************/
    573 int                 CmdQueue_SM(CmdQueue_T* pCmdQueue,CmdQueue_SMEvents_e event)
    574 {
    575     int rc = OK;
    576     int breakWhile = FALSE;
    577     CmdQueue_CmdNode_T* pHead;
    578     TI_STATUS status;
    579 
    580     while(!breakWhile)
    581     {
    582             WLAN_REPORT_INFORMATION(pCmdQueue->hReport, CMDQUEUE_MODULE_LOG,
    583             ("CmdQueue_SM: state = %s (%d) event = %s(%d), rc = %d\n",
    584             StateString[pCmdQueue->State],
    585             pCmdQueue->State,
    586             EventString[event],
    587             event,rc));
    588 
    589         switch(pCmdQueue->State)
    590         {
    591             /***************************************
    592             CMDQUEUE_STATE_IDLE
    593             ***************************************/
    594             case CMDQUEUE_STATE_IDLE:
    595                 switch(event)
    596                 {
    597                     case CMDQUEUE_EVENT_RUN:
    598                         pCmdQueue->State = CMDQUEUE_STATE_SEND_CMD_v;
    599                         break;
    600                     default:
    601                         WLAN_REPORT_ERROR(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
    602                             ("CmdQueue_SM: ** ERROR **  No such event (%d) for state CMDQUEUE_STATE_IDLE\n",event));
    603                             return NOK;
    604                 }
    605                 break;
    606 
    607             /***************************************
    608             CMDQUEUE_STATE_SEND_CMD_v
    609             ***************************************/
    610             case CMDQUEUE_STATE_SEND_CMD_v:
    611                 pHead = &pCmdQueue->CmdQueue[pCmdQueue->Head];
    612 
    613                 WLAN_REPORT_INFORMATION(pCmdQueue->hReport, CMDQUEUE_MODULE_LOG,
    614                     ("CmdQueue_SM: Send Cmd: CmdType = %s(%s)\n"
    615             			"Len = %d, NumOfCmd = %d \n",
    616             			CmdQueue_GetCmdString(pHead->cmdType),
    617 		            (pHead->paramsBuf) ?  CmdQueue_GetIEString(pHead->cmdType,*(UINT16 *)pHead->paramsBuf):"",
    618 		            pHead->paramsLen, pCmdQueue->NumberOfCommandInQueue));
    619 
    620 #ifdef TI_DBG
    621                 pCmdQueue->CmdSendCounter++;
    622 #endif /* TI_DBG    */
    623                 pCmdQueue->State = CMDQUEUE_STATE_INTERROGATE_v;
    624 
    625                     /* send the command to TNET */
    626                 if(pHead->cmdType == CMD_INTERROGATE)
    627                     rc = CmdMBox_SendCmd(pCmdQueue->hCmdMBox,
    628                             pHead->cmdType,
    629                             pHead->paramsBuf,
    630                             CMDQUEUE_INFO_ELEM_HEADER_LEN);
    631                 else
    632                     rc = CmdMBox_SendCmd(pCmdQueue->hCmdMBox,
    633                             pHead->cmdType,
    634                             pHead->paramsBuf,
    635                             pHead->paramsLen);
    636 
    637                 if(rc == TNETWIF_PENDING)
    638                 {
    639                     if(pCmdQueue->SM_RC)
    640                     {
    641                         rc = pCmdQueue->SM_RC;
    642                     }
    643                     pCmdQueue->State = CMDQUEUE_STATE_WAIT_SEND_CMPLT;
    644                     breakWhile = TRUE;
    645                 }
    646                 else
    647                 {
    648                     breakWhile = TRUE;
    649                 }
    650                 break;
    651 
    652             /***************************************
    653             CMDQUEUE_STATE_WAIT_SEND_CMPLT
    654             ***************************************/
    655             case CMDQUEUE_STATE_WAIT_SEND_CMPLT:
    656                 switch(event)
    657                 {
    658                     case CMDQUEUE_EVENT_SEND_CMPLT:
    659 #ifdef TI_DBG
    660                             pCmdQueue->CmdCompltCounter++;
    661 #endif /* TI_DBG                        */
    662                         pCmdQueue->State = CMDQUEUE_STATE_INTERROGATE_v;
    663                         break;
    664                     default:
    665                         WLAN_REPORT_ERROR(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
    666                             ("CmdQueue_SM: ** ERROR **  No such event (%d) for state CMDQUEUE_STATE_WAIT_SEND_CMPLT\n",event));
    667                             return NOK;
    668                 }
    669                 break;
    670 
    671             /***************************************
    672             CMDQUEUE_STATE_INTERROGATE_v
    673             ***************************************/
    674             case CMDQUEUE_STATE_INTERROGATE_v:
    675                 pHead = &pCmdQueue->CmdQueue[pCmdQueue->Head];
    676                     rc = CmdMBox_GetResult(pCmdQueue->hCmdMBox,
    677                             pHead->interrogateParamsBuf, pHead->paramsLen, (UINT32*)&status);
    678                     if(rc == TNETWIF_PENDING)
    679                     {
    680                         pCmdQueue->State = CMDQUEUE_STATE_WAIT_RESULT;
    681                         breakWhile = TRUE;
    682                     }
    683                     else
    684                     {
    685                         if(status != OK)
    686                         {
    687                             pCmdQueue->ErrorFlag = TRUE;
    688                             return OK;
    689                         }
    690                         pCmdQueue->State = CMDQUEUE_STATE_FINISH_v;
    691                     }
    692                 break;
    693 
    694             /***************************************
    695             CMDQUEUE_STATE_WAIT_RESULT
    696             ***************************************/
    697             case CMDQUEUE_STATE_WAIT_RESULT:
    698                 switch(event)
    699                 {
    700                     case CMDQUEUE_EVENT_RESULT_RECEIVED:
    701                         rc = TNETWIF_COMPLETE;
    702                         pCmdQueue->State = CMDQUEUE_STATE_FINISH_v;
    703                         break;
    704                     default:
    705                         WLAN_REPORT_ERROR(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
    706                             ("CmdQueue_SM: ** ERROR **  No such event (%d) for state CMDQUEUE_STATE_WAIT_RESULT\n",event));
    707                             return NOK;
    708                 }
    709                 break;
    710 
    711             /***************************************
    712             CMDQUEUE_STATE_FINISH_v
    713             ***************************************/
    714             case CMDQUEUE_STATE_FINISH_v:
    715             {
    716                 Command_e cmdType;
    717                 UINT16        uParam;
    718                 void *fCb, *hCb, *pCb;
    719 
    720                 pHead = &pCmdQueue->CmdQueue[pCmdQueue->Head];
    721 
    722                 /* Keep callback parameters in temporary variables */
    723                 cmdType = pHead->cmdType;
    724                 uParam  = *(UINT16 *)pHead->paramsBuf;
    725                 fCb = pHead->CB_Func;
    726                 hCb = pHead->CB_Arg;
    727                 pCb = pHead->interrogateParamsBuf;
    728 
    729                 /*
    730                  * Delete the command from the queue before calling a callback
    731                  * because there may be nested calls inside a callback
    732                  */
    733                 pCmdQueue->Head ++;
    734                 if (pCmdQueue->Head >= CMDQUEUE_QUEUE_DEPTH)
    735                     pCmdQueue->Head = 0;
    736                 pCmdQueue->NumberOfCommandInQueue --;
    737 
    738                 /* Check if queue is empty to send the next command */
    739                 if (pCmdQueue->NumberOfCommandInQueue > 0)
    740                 {
    741                     pCmdQueue->SM_RC = rc;
    742                     pCmdQueue->State = CMDQUEUE_STATE_SEND_CMD_v;
    743                 }
    744                 else
    745                 {
    746                     pCmdQueue->SM_RC = 0;
    747                     pCmdQueue->State = CMDQUEUE_STATE_IDLE;
    748                     breakWhile = TRUE;
    749                 }
    750 
    751                 /*
    752                  * Call the user callback after deleting the command from the queue
    753                  * because there may be nested calls inside a callback
    754                  */
    755                 status = CmdMBox_GetStatus(pCmdQueue->hCmdMBox);
    756                 if (fCb)
    757                 {
    758                     if(pCb)
    759                     {
    760                         ((CmdQueue_InterrogateCB_t)fCb) (hCb, status, pCb);
    761                     }
    762                     else
    763                     {
    764                         ((CmdQueue_CB_t)fCb) (hCb, status);
    765                     }
    766                 }
    767                 else
    768                 {
    769                     /* Call the generic callback */
    770                     if (pCmdQueue->CmdCompleteGenericCB_Func)
    771                     {
    772                         pCmdQueue->CmdCompleteGenericCB_Func (pCmdQueue->CmdCompleteGenericCB_Arg,
    773                                                               cmdType,
    774                                                               uParam,
    775                                                               status);
    776                     }
    777                 }
    778             }
    779                 break;
    780 
    781             default:
    782                 WLAN_REPORT_ERROR(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
    783                     ("CmdQueue_SM: ** ERROR **  No such state (%d)\n",pCmdQueue->State));
    784                     return NOK;
    785         }
    786     }
    787             WLAN_REPORT_INFORMATION(pCmdQueue->hReport, CMDQUEUE_MODULE_LOG,
    788                              ("CmdQueue_SM: rc = %d\n",rc));
    789 
    790     return rc;
    791 }
    792 
    793 /*******************************************************************************************************
    794  *                     CmdQueue_SendCmplt()
    795  ******************************************************************************************************
    796  * DESCRIPTION: This function is the CB from the CmdMBox that will issue the "SendCmplt" event to
    797  * 				the CmdQueue SM. Indicates that the Cmd was transferred to the FW.
    798  *
    799  * RETURNS: OK
    800  *************************************************************************************************/
    801 int 			CmdQueue_SendCmplt(TI_HANDLE hCmdQueue)
    802 {
    803 	CmdQueue_T* pCmdQueue = (CmdQueue_T*)hCmdQueue;
    804 
    805 	/* call the SM for further execution */
    806 	return CmdQueue_SM(pCmdQueue,CMDQUEUE_EVENT_SEND_CMPLT);
    807 }
    808 
    809 /*******************************************************************************************************
    810  *                     CmdQueue_ResultReceived()
    811  ******************************************************************************************************
    812  * DESCRIPTION: This function is the CB from the CmdMBox that will issue the "ResultReceived"
    813  * 				event to the CmdQueue SM. Indicates that the Cmd's results were read from
    814  *				the FW.
    815  *
    816  * RETURNS: OK
    817  *************************************************************************************************/
    818 int					CmdQueue_ResultReceived(TI_HANDLE hCmdQueue, UINT32 status)
    819 {
    820     	CmdQueue_T* pCmdQueue = (CmdQueue_T*)hCmdQueue;
    821 
    822 	/* call the SM for further execution */
    823 	return CmdQueue_SM(pCmdQueue,CMDQUEUE_EVENT_RESULT_RECEIVED);
    824 }
    825 
    826 /****************************************************************************
    827  *                      CmdQueue_TimeOut()
    828  ****************************************************************************
    829  * DESCRIPTION: Called when a command timeout occur
    830  *
    831  * OUTPUT:  None
    832  *
    833  * RETURNS: OK or NOK
    834  ******************************************************************************/
    835 int 			CmdQueue_Error(TI_HANDLE hCmdQueue)
    836 {
    837 
    838 	CmdQueue_T* pCmdQueue = (CmdQueue_T*)hCmdQueue;
    839 
    840 #ifdef TI_DBG
    841 	CmdQueue_CmdNode_T* pHead = &pCmdQueue->CmdQueue[pCmdQueue->Head];
    842 	UINT32 TimeStamp = os_timeStampMs(pCmdQueue->hOs);
    843 
    844    	WLAN_REPORT_ERROR(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
    845     		("CmdQueue_Error: **ERROR**  Command Occured \n"
    846 	     	"                                        Cmd = %s %s , Len = %d \n "
    847 	   		"                                        NumOfCmd = %d \n"
    848 			"                                        MAC TimeStamp on timeout = %d\n ",
    849     		CmdQueue_GetCmdString(pHead->cmdType),
    850     		CmdQueue_GetIEString(pHead->cmdType, *(UINT16 *)pHead->paramsBuf),
    851     		pHead->paramsLen,
    852     		pCmdQueue->NumberOfCommandInQueue,
    853     		TimeStamp));
    854 #endif
    855 
    856 	/* Print The command that was sent before the timeout occur */
    857 	CmdQueue_PrintHistory(pCmdQueue, CMDQUEUE_HISTORY_DEPTH);
    858 
    859 	/* preform Recovery */
    860 #ifdef TI_DBG
    861 	if(pCmdQueue->FailureCB)
    862 #endif
    863     	pCmdQueue->FailureCB(pCmdQueue->FailureCbHandle,NOK);
    864 
    865 	return OK;
    866 
    867 	}
    868 
    869 /****************************************************************************
    870  *                      CmdQueue_Print()
    871  ****************************************************************************
    872  * DESCRIPTION:
    873  *
    874  * INPUTS:
    875  *
    876  * OUTPUT:  None
    877  *
    878  * RETURNS:
    879  ****************************************************************************/
    880 void					CmdQueue_Print(TI_HANDLE hCmdQueue)
    881 {
    882 	CmdQueue_T* pCmdQueue = (CmdQueue_T*)hCmdQueue;
    883 
    884     	WLAN_REPORT_REPLY(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
    885        	("------------- CmdQueue Queue -------------------\n"));
    886 
    887     	WLAN_REPORT_REPLY(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
    888         	("CmdQueue_Print:The Max NumOfCmd in Queue was = %d\n",
    889         	pCmdQueue->MaxNumberOfCommandInQueue));
    890     	WLAN_REPORT_REPLY(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
    891         	("CmdQueue_Print:The Current NumOfCmd in Queue = %d\n",
    892         	pCmdQueue->NumberOfCommandInQueue));
    893 #ifdef TI_DBG
    894     	WLAN_REPORT_REPLY(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
    895         	("CmdQueue_Print:The Total number of Cmd send from Queue= %d\n",
    896         	pCmdQueue->CmdSendCounter));
    897     	WLAN_REPORT_REPLY(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
    898         	("CmdQueue_Print:The Total number of Cmd Completed interrupt= %d\n",
    899         	pCmdQueue->CmdCompltCounter));
    900 #endif
    901 
    902     	CmdQueue_PrintQueue(pCmdQueue);
    903 }
    904 
    905 /****************************************************************************
    906  *                      CmdQueue_PrintQueue()
    907  ****************************************************************************
    908  * DESCRIPTION:
    909  *
    910  * INPUTS:
    911  *
    912  * OUTPUT:  None
    913  *
    914  * RETURNS:
    915  ****************************************************************************/
    916 void				CmdQueue_PrintQueue(CmdQueue_T  *pCmdQueue)
    917 {
    918 	int CurrentCmdindex;
    919     	int first  = pCmdQueue->Head;
    920 	CmdQueue_CmdNode_T* pHead;
    921     	int NumberOfCommand = pCmdQueue->NumberOfCommandInQueue;
    922 
    923 	WLAN_OS_REPORT(("CmdQueue_PrintQueue \n"));
    924 
    925     	for(CurrentCmdindex = 0 ; CurrentCmdindex < NumberOfCommand ; CurrentCmdindex++)
    926     	{
    927 		pHead = &pCmdQueue->CmdQueue[first];
    928 #ifdef TI_DBG
    929         	WLAN_OS_REPORT(("Cmd index %d CmdType = %s %s, Len = %d, Place in Queue = %d \n",
    930             		CurrentCmdindex,
    931             		CmdQueue_GetCmdString(pHead->cmdType),
    932             		CmdQueue_GetIEString(pHead->cmdType, (((pHead->cmdType == CMD_INTERROGATE)||(pHead->cmdType == CMD_CONFIGURE)) ? *(UINT16 *)pHead->paramsBuf : 0)),
    933             		pHead->paramsLen,
    934             		first));
    935 #else
    936 		WLAN_OS_REPORT(("Cmd index %d CmdType = %d %d, Len = %d, Place in Queue = %d \n",
    937             		CurrentCmdindex,
    938             		pHead->cmdType,
    939             		(((pHead->cmdType == CMD_INTERROGATE)||(pHead->cmdType == CMD_CONFIGURE)||
    940                       (pHead->cmdType == CMD_READ_MEMORY)||(pHead->cmdType == CMD_WRITE_MEMORY)) ? *(UINT16 *)pHead->paramsBuf : 0),
    941             		pHead->paramsLen,
    942             		first));
    943 #endif
    944 
    945         	first++;
    946 		if(first == CMDQUEUE_QUEUE_DEPTH)
    947 			first = 0;
    948     	}
    949 }
    950 
    951 /****************************************************************************
    952  *                      CmdQueue_PrintHistory()
    953  ****************************************************************************
    954  * DESCRIPTION: print the last command according to a value
    955  *
    956  * INPUTS:  NunOfCmd : the number of the last command to print
    957  *
    958  ****************************************************************************/
    959 void					CmdQueue_PrintHistory(TI_HANDLE hCmdQueue, int NunOfCmd)
    960 {
    961 	CmdQueue_T* pCmdQueue = (CmdQueue_T*)hCmdQueue;
    962 	int CurrentCmdindex;
    963     	int first  = pCmdQueue->Head;
    964 	CmdQueue_CmdNode_T* pHead ;
    965 
    966     WLAN_OS_REPORT(("--------------- CmdQueue_PrintHistory of %d -------------------\n",NunOfCmd));
    967 
    968 	for(CurrentCmdindex = 0 ; CurrentCmdindex < NunOfCmd ; CurrentCmdindex++)
    969 	{
    970 		pHead  =  &pCmdQueue->CmdQueue[first];
    971 
    972 #ifdef TI_DBG
    973 	    	WLAN_OS_REPORT(("Cmd index %d CmdType = %s %s, Len = %d, Place in Queue = %d \n",
    974             		CurrentCmdindex,
    975             		CmdQueue_GetCmdString(pHead->cmdType),
    976             		CmdQueue_GetIEString(pHead->cmdType, (((pHead->cmdType == CMD_INTERROGATE)||(pHead->cmdType == CMD_CONFIGURE)) ? *(UINT16 *)pHead->paramsBuf : 0)),
    977             		pHead->paramsLen,
    978             		first));
    979 #else
    980 		WLAN_OS_REPORT(("Cmd index %d CmdType = %d %d, Len = %d, Place in Queue = %d \n",
    981             		CurrentCmdindex,
    982             		pHead->cmdType,
    983             		(((pHead->cmdType == CMD_INTERROGATE)||(pHead->cmdType == CMD_CONFIGURE)||
    984                       (pHead->cmdType == CMD_READ_MEMORY)||(pHead->cmdType == CMD_WRITE_MEMORY)) ? *(UINT16 *)pHead->paramsBuf : 0),
    985             		pHead->paramsLen,
    986             		first));
    987 #endif
    988 
    989 		if(first == 0)
    990 			first = CMDQUEUE_QUEUE_DEPTH-1;
    991 		else
    992 			first--;
    993 	}
    994 
    995 	WLAN_OS_REPORT(("-----------------------------------------------------------------------\n"));
    996 
    997 }
    998 
    999 /****************************************************************************
   1000  *                      CmdQueue_GetMaxNumberOfCommands()
   1001  ****************************************************************************
   1002  * DESCRIPTION: returns maximum number of commands (ever) in CmdQueue queue
   1003  *
   1004  * INPUTS:
   1005  *
   1006  * OUTPUT:  None
   1007  *
   1008  * RETURNS: maximum number of commands (ever) in mailbox queue
   1009  ****************************************************************************/
   1010 int 					CmdQueue_GetMaxNumberOfCommands (TI_HANDLE hCmdQueue)
   1011 {
   1012 	CmdQueue_T* pCmdQueue = (CmdQueue_T*)hCmdQueue;
   1013 
   1014 	return (pCmdQueue->MaxNumberOfCommandInQueue);
   1015 }
   1016 
   1017 #ifdef REPORT_LOG
   1018 
   1019 /****************************************************************************
   1020  *                      CmdQueue_GetCmdString()
   1021  ****************************************************************************
   1022  * DESCRIPTION:
   1023  *
   1024  * INPUTS:
   1025  *
   1026  * OUTPUT:  None
   1027  *
   1028  * RETURNS:
   1029  ****************************************************************************/
   1030 char* 			CmdQueue_GetCmdString(int MboxCmdType)
   1031 {
   1032 	switch (MboxCmdType)
   1033 	{
   1034 		case 0: return "CMD_RESET";
   1035 		case 1: return "CMD_INTERROGATE";
   1036 	 	case 2: return "CMD_CONFIGURE";
   1037 	    	case 3: return "CMD_ENABLE_RX";
   1038 		case 4: return "CMD_ENABLE_TX";
   1039 		case 5: return "CMD_DISABLE_RX";
   1040 	    	case 6: return "CMD_DISABLE_TX";
   1041 		case 8: return "CMD_SCAN";
   1042 		case 9: return "CMD_STOP_SCAN";
   1043 	    	case 10: return "CMD_VBM";
   1044 		case 11: return "CMD_START_JOIN";
   1045 		case 12: return "CMD_SET_KEYS";
   1046 		case 13: return "CMD_READ_MEMORY";
   1047 	    	case 14: return "CMD_WRITE_MEMORY";
   1048 		case 19: return "CMD_BEACON";
   1049 		case 20: return "CMD_PROBE_RESP";
   1050 		case 21: return "CMD_NULL_DATA";
   1051 	    	case 22: return "CMD_PROBE_REQ";
   1052 		case 23: return "CMD_TEST";
   1053 		case 27: return "CMD_ENABLE_RX_PATH";
   1054 		case 28: return "CMD_NOISE_HIST";
   1055 	    	case 29: return "CMD_RX_RESET";
   1056 		case 30: return "CMD_PS_POLL";
   1057 		case 31: return "CMD_QOS_NULL_DATA";
   1058 		case 32: return "CMD_LNA_CONTROL";
   1059 		case 33: return "CMD_SET_BCN_MODE";
   1060 		case 34: return "CMD_MEASUREMENT";
   1061 		case 35: return "CMD_STOP_MEASUREMENT";
   1062 		case 36: return "CMD_DISCONNECT";
   1063 		case 37: return "CMD_SET_PS_MODE";
   1064 		case 38: return "CMD_CHANNEL_SWITCH";
   1065 		case 39: return "CMD_STOP_CHANNEL_SWICTH";
   1066 		case 40: return "CMD_AP_DISCOVERY";
   1067 		case 41: return "CMD_STOP_AP_DISCOVERY";
   1068 		case 42: return "CMD_SPS_SCAN";
   1069 		case 43: return "CMD_STOP_SPS_SCAN";
   1070 		case 45: return "CMD_HEALTH_CHECK";
   1071 		default: return " *** Error No Such CMD **** ";
   1072 	}
   1073 };
   1074 
   1075 /****************************************************************************
   1076  *                      CmdQueue_GetErrorString()
   1077  ****************************************************************************
   1078  * DESCRIPTION:
   1079  *
   1080  * INPUTS:
   1081  *
   1082  * OUTPUT:  None
   1083  *
   1084  * RETURNS:
   1085  ****************************************************************************/
   1086 char*            CmdQueue_GetErrorString(CommandStatus_e MboxError)
   1087 {
   1088     switch (MboxError)
   1089     {
   1090     case CMD_MAILBOX_IDLE:
   1091         return "CMD_MAILBOX_IDLE";
   1092         /* break; to avoid compilation warning */
   1093 
   1094     case CMD_STATUS_SUCCESS:
   1095         return "CMD_STATUS_SUCCESS";
   1096         /* break; to avoid compilation warning */
   1097 
   1098     case CMD_STATUS_UNKNOWN_CMD:
   1099         return "CMD_STATUS_UNKNOWN_CMD";
   1100         /* break; to avoid compilation warning */
   1101 
   1102     case CMD_STATUS_UNKNOWN_IE:
   1103         return "CMD_STATUS_UNKNOWN_IE";
   1104         /* break; to avoid compilation warning */
   1105 
   1106     case CMD_STATUS_RX_BUSY:
   1107         return "CMD_STATUS_RX_BUSY";
   1108         /* break; to avoid compilation warning */
   1109 
   1110     case CMD_STATUS_INVALID_PARAM:
   1111         return "CMD_STATUS_INVALID_PARAM";
   1112         /* break; to avoid compilation warning */
   1113 
   1114     case CMD_STATUS_TEMPLATE_TOO_LARGE:
   1115         return "CMD_STATUS_TEMPLATE_TOO_LARGE";
   1116         /* break; to avoid compilation warning */
   1117 
   1118     case CMD_STATUS_OUT_OF_MEMORY:
   1119         return "CMD_STATUS_OUT_OF_MEMORY";
   1120         /* break; to avoid compilation warning */
   1121 
   1122     case CMD_STATUS_STA_TABLE_FULL:
   1123         return "CMD_STATUS_STA_TABLE_FULL";
   1124         /* break; to avoid compilation warning */
   1125 
   1126     case CMD_STATUS_RADIO_ERROR:
   1127         return "CMD_STATUS_RADIO_ERROR";
   1128         /* break; to avoid compilation warning */
   1129 
   1130     case CMD_STATUS_WRONG_NESTING:
   1131         return "CMD_STATUS_WRONG_NESTING";
   1132         /* break; to avoid compilation warning */
   1133 
   1134     case CMD_STATUS_TIMEOUT:
   1135         return "CMD_STATUS_TIMEOUT";
   1136         /* break; to avoid compilation warning */
   1137 
   1138     case CMD_STATUS_FW_RESET:
   1139         return "CMD_STATUS_FW_RESET";
   1140         /* break; to avoid compilation warning */
   1141 
   1142     default:
   1143         return "Unrecognized error code";
   1144         /* break; to avoid compilation warning */
   1145     }
   1146 }
   1147 
   1148 
   1149 /****************************************************************************
   1150  *                      CmdQueue_GetIEString()
   1151  ****************************************************************************
   1152  * DESCRIPTION:
   1153  *
   1154  * INPUTS:
   1155  *
   1156  * OUTPUT:  None
   1157  *
   1158  * RETURNS:
   1159  ****************************************************************************/
   1160 char* 			CmdQueue_GetIEString(int MboxCmdType, UINT16 Id)
   1161 {
   1162 	if( MboxCmdType== CMD_INTERROGATE || MboxCmdType == CMD_CONFIGURE)
   1163 	{
   1164 		switch (Id)
   1165 		{
   1166 		case ACX_WAKE_UP_CONDITIONS: 		return " (ACX_WAKE_UP_CONDITIONS)";
   1167 		case ACX_MEM_CFG: 					return " (ACX_MEM_CFG)";
   1168 		case ACX_SLOT: 						return " (ACX_SLOT) ";
   1169 		case ACX_QUEUE_HEAD: 				return " (ACX_QUEUE_HEAD)";
   1170 		case ACX_AC_CFG: 					return " (ACX_AC_CFG) ";
   1171 		case ACX_MEM_MAP: 					return " (ACX_MEM_MAP)";
   1172 		case ACX_AID: 						return " (ACX_AID)";
   1173 		case ACX_RADIO_PARAM: 				return " (ACX_RADIO_PARAM)";
   1174 		case ACX_CFG: 						return " (ACX_CFG) ";
   1175         case ACX_FW_REV: 					return " (ACX_FW_REV) ";
   1176         case ACX_FCS_ERROR_CNT: 			return " (ACX_FCS_ERROR_CNT) ";
   1177         case ACX_MEDIUM_USAGE: 				return " (ACX_MEDIUM_USAGE) ";
   1178 		case ACX_RX_CFG: 					return " (ACX_RX_CFG) ";
   1179 		case ACX_TX_QUEUE_CFG: 				return " (ACX_TX_QUEUE_CFG) ";
   1180 		case ACX_BSS_IN_PS: 				return " (ACX_BSS_IN_PS) ";
   1181 		case ACX_STATISTICS: 				return " (ACX_STATISTICS) ";
   1182 		case ACX_FEATURE_CFG: 				return " (ACX_FEATURE_CFG) ";
   1183 		case ACX_MISC_CFG: 					return " (ACX_MISC_CFG) ";
   1184 		case ACX_TID_CFG: 					return " (ACX_TID_CFG) ";
   1185 		case ACX_CAL_ASSESSMENT: 			return " (ACX_CAL_ASSESSMENT) ";
   1186 		case ACX_BEACON_FILTER_OPT: 		return " (ACX_BEACON_FILTER_OPT) ";
   1187 		case ACX_LOW_RSSI: 					return " (ACX_LOW_RSSI)";
   1188         case ACX_NOISE_HIST: 				return " (ACX_NOISE_HIST)";
   1189 		case ACX_HDK_VERSION: 				return " (ACX_HDK_VERSION)";
   1190 		case ACX_PD_THRESHOLD: 				return " (ACX_PD_THRESHOLD) ";
   1191 		case ACX_DATA_PATH_PARAMS: 			return " (ACX_DATA_PATH_PARAMS) ";
   1192    	case ACX_CCA_THRESHOLD: 				return " (ACX_CCA_THRESHOLD)";
   1193 		case ACX_EVENT_MBOX_MASK: 			return " (ACX_EVENT_MBOX_MASK) ";
   1194 #ifdef FW_RUNNING_AS_AP
   1195 		case ACX_DTIM_PERIOD: 				return " (ACX_DTIM_PERIOD) ";
   1196 #else
   1197 		case ACX_WR_TBTT_AND_DTIM: 			return " (ACX_WR_TBTT_AND_DTIM) ";
   1198 #endif
   1199 		case ACX_ACI_OPTION_CFG: 			return " (ACX_ACI_OPTION_CFG) ";
   1200         case ACX_GPIO_CFG: 					return " (ACX_GPIO_CFG) ";
   1201         case ACX_GPIO_SET: 					return " (ACX_GPIO_SET) ";
   1202 		case ACX_PM_CFG: 					return " (ACX_PM_CFG) ";
   1203 		case ACX_CONN_MONIT_PARAMS: 		return " (ACX_CONN_MONIT_PARAMS) ";
   1204 		case ACX_AVERAGE_RSSI: 				return " (ACX_AVERAGE_RSSI) ";
   1205 		case ACX_CONS_TX_FAILURE: 			return " (ACX_CONS_TX_FAILURE) ";
   1206 		case ACX_BCN_DTIM_OPTIONS: 			return " (ACX_BCN_DTIM_OPTIONS) ";
   1207 		case ACX_SG_ENABLE: 				return " (ACX_SG_ENABLE) ";
   1208 		case ACX_SG_CFG: 					return " (ACX_SG_CFG) ";
   1209 		case ACX_ANTENNA_DIVERSITY_CFG: 	return " (ACX_ANTENNA_DIVERSITY_CFG) ";
   1210 		case ACX_LOW_SNR: 					return " (ACX_LOW_SNR) ";
   1211 		case ACX_BEACON_FILTER_TABLE: 		return " (ACX_BEACON_FILTER_TABLE) ";
   1212 		case ACX_ARP_IP_FILTER: 			return " (ACX_ARP_IP_FILTER) ";
   1213 		case ACX_ROAMING_STATISTICS_TBL:	return " (ACX_ROAMING_STATISTICS_TBL) ";
   1214 		case ACX_RATE_POLICY: 				return " (ACX_RATE_POLICY) ";
   1215 		case ACX_CTS_PROTECTION: 			return " (ACX_CTS_PROTECTION) ";
   1216 		case ACX_SLEEP_AUTH: 				return " (ACX_SLEEP_AUTH) ";
   1217 		case ACX_PREAMBLE_TYPE: 			return " (ACX_PREAMBLE_TYPE) ";
   1218 		case ACX_ERROR_CNT: 				return " (ACX_ERROR_CNT) ";
   1219 		case ACX_FW_GEN_FRAME_RATES: 		return " (ACX_FW_GEN_FRAME_RATES) ";
   1220 		case ACX_IBSS_FILTER: 				return " (ACX_IBSS_FILTER) ";
   1221 		case ACX_SERVICE_PERIOD_TIMEOUT:	return " (ACX_SERVICE_PERIOD_TIMEOUT) ";
   1222 		case ACX_TSF_INFO: 					return " (ACX_TSF_INFO) ";
   1223 		case ACX_CONFIG_PS_WMM: 			return " (ACX_CONFIG_PS_WMM) ";
   1224 		case ACX_ENABLE_RX_DATA_FILTER: 	return " (ACX_ENABLE_RX_DATA_FILTER) ";
   1225 		case ACX_SET_RX_DATA_FILTER: 		return " (ACX_SET_RX_DATA_FILTER) ";
   1226 		case ACX_GET_DATA_FILTER_STATISTICS:return " (ACX_GET_DATA_FILTER_STATISTICS) ";
   1227 		case ACX_POWER_LEVEL_TABLE: 		return " (ACX_POWER_LEVEL_TABLE) ";
   1228 		case ACX_BET_ENABLE: 				return " (ACX_BET_ENABLE) ";
   1229 		case DOT11_STATION_ID: 				return " (DOT11_STATION_ID) ";
   1230 		case DOT11_RX_MSDU_LIFE_TIME: 		return " (DOT11_RX_MSDU_LIFE_TIME) ";
   1231 		case DOT11_CUR_TX_PWR: 				return " (DOT11_CUR_TX_PWR) ";
   1232 		case DOT11_DEFAULT_KEY: 			return " (DOT11_DEFAULT_KEY) ";
   1233 		case DOT11_RX_DOT11_MODE: 			return " (DOT11_RX_DOT11_MODE) ";
   1234 		case DOT11_RTS_THRESHOLD: 			return " (DOT11_RTS_THRESHOLD) ";
   1235 		case DOT11_GROUP_ADDRESS_TBL: 		return " (DOT11_GROUP_ADDRESS_TBL) ";
   1236 
   1237 		default:	return " *** Error No Such IE **** ";
   1238 		}
   1239 	}
   1240 	return "";
   1241 }
   1242 #endif /* REPORT_LOG */
   1243 
   1244