cm-kernel /drivers/net/wireless/tiwlan1251/common/src/TNETW_Driver/Ctrl/Cmd_Queue/CmdQueue.c

Language C Lines 1244
MD5 Hash 0f568a358ccd8d80d1e5e3f03b25811a Estimated Cost $19,191 (why?)
Repository git://github.com/CyanogenMod/cm-kernel.git View Raw File View Project SPDX
   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
/****************************************************************************
**+-----------------------------------------------------------------------+**
**|                                                                       |**
**| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved.      |**
**| All rights reserved.                                                  |**
**|                                                                       |**
**| Redistribution and use in source and binary forms, with or without    |**
**| modification, are permitted provided that the following conditions    |**
**| are met:                                                              |**
**|                                                                       |**
**|  * Redistributions of source code must retain the above copyright     |**
**|    notice, this list of conditions and the following disclaimer.      |**
**|  * Redistributions in binary form must reproduce the above copyright  |**
**|    notice, this list of conditions and the following disclaimer in    |**
**|    the documentation and/or other materials provided with the         |**
**|    distribution.                                                      |**
**|  * Neither the name Texas Instruments nor the names of its            |**
**|    contributors may be used to endorse or promote products derived    |**
**|    from this software without specific prior written permission.      |**
**|                                                                       |**
**| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |**
**| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |**
**| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |**
**| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |**
**| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |**
**| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |**
**| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |**
**| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |**
**| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |**
**| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |**
**| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |**
**|                                                                       |**
**+-----------------------------------------------------------------------+**
****************************************************************************/
#include "osTIType.h"
#include "whalCommon.h"
#include "whalHwDefs.h"
#include "whalBus_Api.h"
#include "CmdMBox_api.h"
#include "CmdQueue_api.h"
#include "CmdQueue.h"

#ifdef TI_DBG
static char *StateString[CMDQUEUE_STATE_NUM] = {
	"CMDQUEUE_STATE_IDLE",  /* 0 */
	"CMDQUEUE_STATE_SEND_CMD_v",  /* 1 */
	"CMDQUEUE_STATE_WAIT_SEND_CMPLT",  /* 2 */
	"CMDQUEUE_STATE_INTERROGATE_v",  /* 3 */
	"CMDQUEUE_STATE_WAIT_RESULT",  /* 4 */
	"CMDQUEUE_STATE_FINISH_v",  /* 5 */
};

static char *EventString[CMDQUEUE_EVENT_NUM] = {
	"CMDQUEUE_EVENT_RUN",  /* 1 */
	"CMDQUEUE_EVENT_SEND_CMPLT",  /* 2 */
	"CMDQUEUE_EVENT_RESULT_RECEIVED",  /* 3 */
};

#endif /* TI_DBG */


/****************************************************************************
 *                      CmdQueue_Create()
 ****************************************************************************
 * DESCRIPTION: Create the CmdQueue object
 *
 * INPUTS:  TI_HANDLE *hOs
 *
 * OUTPUT:  None
 *
 * RETURNS: The Created object
 *****************************************************************************/
TI_HANDLE CmdQueue_Create(TI_HANDLE hOs)
{
    
    CmdQueue_T  *pObj;

    pObj = os_memoryAlloc(hOs, sizeof(CmdQueue_T));
    if (pObj == NULL)
    {
        WLAN_OS_REPORT(("FATAL ERROR: CmdQueue_Create(): Error Creating CmdQueue - Aborting\n"));
        return NULL;
    }

    /* reset control module control block */
    os_memoryZero(hOs, pObj, sizeof(CmdQueue_T));
    pObj->hOs = hOs;
    
    return(pObj);   
}


/****************************************************************************
 *                      CmdQueue_Destroy()
 ****************************************************************************
 * DESCRIPTION: Destroy the object
 *
 * INPUTS:  hCmdQueue   The object to free
 *  
 * OUTPUT:  None
 *
 * RETURNS: OK or NOK
 ****************************************************************************/
int					CmdQueue_Destroy(TI_HANDLE hCmdQueue)
{
	CmdQueue_T* pCmdQueue = (CmdQueue_T*)	hCmdQueue;

	/* free context */
       os_memoryFree(pCmdQueue->hOs, pCmdQueue, sizeof(CmdQueue_T));

	return OK;
}

/****************************************************************************
 *                      CmdQueue_Config()
 ****************************************************************************
 * DESCRIPTION: Config the CmdQueue object
 *
 * INPUTS:  
 *
 * OUTPUT:  None
 *
 * RETURNS: OK or NOK
 ****************************************************************************/
int CmdQueue_Config (TI_HANDLE hCmdQueue, TI_HANDLE hCmdMBox, TI_HANDLE hReport)                                                       
{
    CmdQueue_T* pCmdQueue = (CmdQueue_T*) hCmdQueue;

    pCmdQueue->Head = 0;
    pCmdQueue->Tail = 0;
    pCmdQueue->NumberOfCommandInQueue = 0;
    pCmdQueue->MaxNumberOfCommandInQueue = 0;
    pCmdQueue->State = CMDQUEUE_STATE_IDLE;
    pCmdQueue->CmdCompleteGenericCB_Func = NULL;
    pCmdQueue->CmdCompleteGenericCB_Arg = NULL;
    pCmdQueue->FailureCB = NULL;
    pCmdQueue->FailureCbHandle = NULL;
    pCmdQueue->SM_RC = 0;
    pCmdQueue->hReport = hReport;
    pCmdQueue->hCmdMBox = hCmdMBox;
    pCmdQueue->ErrorFlag = FALSE;

    /*
     * NOTE: don't set NumberOfRecoveryNodes = 0; 
     *       its value is used by recovery process
     */

    return OK;
}

/****************************************************************************
 *                      CmdQueue_StartReconfig()
 ****************************************************************************
 * DESCRIPTION: Restart the module for recovery. Clean the queue but save al the CB in the queue.
 *
 * INPUTS:  
 *
 * OUTPUT:  
 *
 * RETURNS: OK or NOK
 ****************************************************************************/
int					CmdQueue_StartReconfig(TI_HANDLE hCmdQueue)
{
	CmdQueue_T* pCmdQueue = (CmdQueue_T*)	hCmdQueue;
	int CurrentCmdindex;
    	int first  = pCmdQueue->Head;
	CmdQueue_CmdNode_T* pHead ;
	CmdQueue_RecoveryNode_T* pRecoveryNode;
	
	/* 
	stop the SM
	*/
    	pCmdQueue->State = CMDQUEUE_STATE_IDLE;

	WLAN_REPORT_INFORMATION(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
        							("CmdQueue_Clean: Cleaning CmdQueue Queue"));
    
	/*
	Save The Call Back Function in the Queue in order the return them after the recovery 
	with on error status 
	*/ 

	/* Clean The Command Call Back Counter */ 
	pCmdQueue->NumberOfRecoveryNodes = 0;
	pRecoveryNode = &pCmdQueue->RecoveryQueue[pCmdQueue->NumberOfRecoveryNodes];
	for(CurrentCmdindex = 0 ; CurrentCmdindex < pCmdQueue->NumberOfCommandInQueue ; CurrentCmdindex++)
    	{
		pHead  =  &pCmdQueue->CmdQueue[first];

		if(pHead->CB_Func != NULL)
		{ /*Copy the interrogate CB and the interrogate data buffer pointer */
			pRecoveryNode->CB_Func = pHead->CB_Func;
			pRecoveryNode->CB_Arg = pHead->CB_Arg;
			pRecoveryNode->interrogateParamsBuf = pHead->interrogateParamsBuf;
			pCmdQueue->NumberOfRecoveryNodes++;
			pRecoveryNode = &pCmdQueue->RecoveryQueue[pCmdQueue->NumberOfRecoveryNodes];
		}		
		first++;
		if(first == CMDQUEUE_QUEUE_DEPTH)
			first = 0;
	}

	/*
	init the queue
	*/
	pCmdQueue->Head = 0;
    pCmdQueue->Tail = 0;
    pCmdQueue->NumberOfCommandInQueue = 0;

	return OK;
}

/****************************************************************************
 *                      CmdQueue_EndReconfig()
 ****************************************************************************
 * DESCRIPTION: Call the stored CB to end the recovery of the MBox queue
 *
 * INPUTS:  
 *
 * OUTPUT:  
 *
 * RETURNS: OK or NOK
 ****************************************************************************/
int					CmdQueue_EndReconfig(TI_HANDLE hCmdQueue)
{
	CmdQueue_T* pCmdQueue = (CmdQueue_T*)	hCmdQueue;
	
	int	Cbindex;
	CmdQueue_RecoveryNode_T *pHead;

	for(Cbindex = 0; Cbindex < pCmdQueue->NumberOfRecoveryNodes; Cbindex++)
	{
		pHead  =  &pCmdQueue->RecoveryQueue[Cbindex];

		if(pHead->interrogateParamsBuf)
	    	{
    			((CmdQueue_InterrogateCB_t)pHead->CB_Func)(pHead->CB_Arg, CMD_STATUS_FW_RESET,pHead->interrogateParamsBuf);
    		}
		else
		{
			((CmdQueue_CB_t)pHead->CB_Func)(pHead->CB_Arg, CMD_STATUS_FW_RESET);
		}
	}

	pCmdQueue->NumberOfRecoveryNodes = 0;
	
	return OK;
}

/****************************************************************************
 *                 CmdQueue_RegisterCmdCompleteGenericCB()
 ****************************************************************************
 * DESCRIPTION: Register for a call back to be called when Command Complete
 *              Occur and the CmdMboxCB was NULL
 *
 * RETURNS:None
 ****************************************************************************/
int					CmdQueue_RegisterCmdCompleteGenericCB(TI_HANDLE hCmdQueue, void *CB_Func, TI_HANDLE CB_handle)
{
	CmdQueue_T* pCmdQueue = (CmdQueue_T*)	hCmdQueue;
	
	if ((CB_Func == NULL) || (CB_handle == NULL))
	{
		WLAN_REPORT_ERROR(pCmdQueue->hReport, HAL_CTRL_MODULE_LOG, ("CmdQueue_RegisterCmdCompleteGenericCB: NULL parameter\n"));
		return NOK;
	}

	pCmdQueue->CmdCompleteGenericCB_Func = (CmdQueue_GenericCB_t)CB_Func;
	pCmdQueue->CmdCompleteGenericCB_Arg = CB_handle;

	return OK;
}

/****************************************************************************
 *                      CmdQueue_RegisterForErrorCB()
 ****************************************************************************
 * DESCRIPTION: Register for a call back to be called when an Error (Timeout)
 *              Occur
 *
 * RETURNS:None
 ****************************************************************************/
int 					CmdQueue_RegisterForErrorCB(TI_HANDLE hCmdQueue, void *CB_Func, TI_HANDLE CB_handle)
{
	CmdQueue_T* pCmdQueue = (CmdQueue_T*)	hCmdQueue;
	
	if ((CB_Func == NULL) || (CB_handle == NULL))
	{
		WLAN_REPORT_ERROR(pCmdQueue->hReport, HAL_CTRL_MODULE_LOG, ("CmdQueue_RegisterForErrorCB: NULL parameters\n"));
		return NOK;
	}

    	pCmdQueue->FailureCbHandle = CB_handle;
    	pCmdQueue->FailureCB = (CmdQueue_CB_t)CB_Func;

	return OK;
}

/****************************************************************************
 *                      CmdQueue_CmdConfigure()
 ****************************************************************************
 * DESCRIPTION: Send configure command with its information element parameter
 *
 * INPUTS:  
 *
 * OUTPUT:  None
 *
 * RETURNS: OK or NOK
 ****************************************************************************/
int 					CmdQueue_CmdConfigure(TI_HANDLE hCmdQueue, void *MboxBuf,UINT32 ParamsLen)
{
	int status;
	CmdQueue_T* pCmdQueue = (CmdQueue_T*)	hCmdQueue;

	CHECK_ERROR_FLAG(pCmdQueue->ErrorFlag);
	
	status = CmdQueue_Push(pCmdQueue, CMD_CONFIGURE,
                       				(UINT8*)MboxBuf, ParamsLen,
					   		NULL, NULL, NULL);
	
	CMDQUEUE_CONVERT_RC(status);
}

/****************************************************************************
 *                      CmdQueue_CmdConfigureWithCb()
 ****************************************************************************
 * DESCRIPTION: Send configure command with its information element parameter
 *
 * INPUTS:  
 *
 * OUTPUT:  None
 *
 * RETURNS: OK or NOK
 ****************************************************************************/
int					CmdQueue_CmdConfigureWithCb(TI_HANDLE hCmdQueue, void *MboxBuf, UINT32 ParamsLen,
										 					void *CB_Func, TI_HANDLE CB_handle)
{

	int status;
	CmdQueue_T* pCmdQueue = (CmdQueue_T*)	hCmdQueue;

	CHECK_ERROR_FLAG(pCmdQueue->ErrorFlag);
	
	status = CmdQueue_Push(pCmdQueue, CMD_CONFIGURE,
                       				(UINT8*)MboxBuf, ParamsLen,
					   		CB_Func, CB_handle, NULL);
	
	CMDQUEUE_CONVERT_RC(status);
}


#if 0

/*
 * NOTE: The following function may NOT be used in fully asynchronous mode.
 *       Its source code remained only for easier backword rollback
 */

/****************************************************************************
 *                      CmdQueue_CmdInterrogate()
 ****************************************************************************
 * DESCRIPTION: Send interrogate command with its information element parameter
 *
 * INPUTS:  
 *
 * OUTPUT:  None
 *
 * RETURNS: OK or NOK
 ****************************************************************************/
int     				CmdQueue_CmdInterrogate(TI_HANDLE hCmdQueue, void *MboxBuf, UINT32 ParamsLen)
{
	CmdQueue_T* pCmdQueue = (CmdQueue_T*)	hCmdQueue;
	int status = OK;

	CHECK_ERROR_FLAG(pCmdQueue->ErrorFlag);

	status = CmdQueue_Push(pCmdQueue, CMD_INTERROGATE,
                       				(UINT8*)MboxBuf, ParamsLen,
					   		NULL, NULL, (UINT8*)MboxBuf);

	/* 
	cause we called an interrogate cmd without a CB function then the Cmd needs to be finished 
	in this context 
	*/
	if (status == TNETWIF_PENDING)
	{
		WLAN_REPORT_ERROR(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
        		("CmdQueue_CmdInterrogate:Cmd INTERROGATE ,MboxBuf = 0x%x, Len = %d \n"
		 	, MboxBuf, ParamsLen));
	}

	CMDQUEUE_CONVERT_RC(status);
}
#endif


/****************************************************************************
 *                      CmdQueue_CmdInterrogateWithCb()
 ****************************************************************************
 * DESCRIPTION: Send interrogate command with its information element parameter
 *
 * INPUTS:  
 *
 * OUTPUT:  None
 *
 * RETURNS: OK or NOK
 ****************************************************************************/
int					CmdQueue_CmdInterrogateWithCb(TI_HANDLE hCmdQueue, void *MboxBuf, UINT32 ParamsLen,
															void *CB_Func, TI_HANDLE CB_handle, void *CB_Buf)
{
	CmdQueue_T* pCmdQueue = (CmdQueue_T*)	hCmdQueue;
	int status;

	CHECK_ERROR_FLAG(pCmdQueue->ErrorFlag);
	
	if((CB_Func == NULL) || (CB_handle == NULL) || (CB_Buf == NULL))
	{
		WLAN_REPORT_ERROR(pCmdQueue->hReport, HAL_CTRL_MODULE_LOG, 
			("CmdQueue_CommandWithCb: NULL parameters\n"));
		return NOK;
	}

	status = CmdQueue_Push(pCmdQueue, CMD_INTERROGATE,
                       				(UINT8*)MboxBuf, ParamsLen,
					   		CB_Func, CB_handle, (UINT8*)CB_Buf);    

	CMDQUEUE_CONVERT_RC(status);
}

/***************************************************************************
 *                      CmdQueue_Command()
 ****************************************************************************
 * DESCRIPTION: Send command to the wlan hardware command mailbox
 *
 * INPUTS:  
 *
 * OUTPUT:  None
 *
 * RETURNS: OK or NOK
 ****************************************************************************/
int	    				CmdQueue_Command(TI_HANDLE hCmdQueue, Command_e MboxCmdType, char *MboxBuf, UINT32 ParamsLen)
{
	CmdQueue_T* pCmdQueue = (CmdQueue_T*)	hCmdQueue;
	int status;

	CHECK_ERROR_FLAG(pCmdQueue->ErrorFlag);
	
	status = CmdQueue_Push(pCmdQueue, MboxCmdType,
                       				(UINT8*)MboxBuf, ParamsLen,
					   		NULL, NULL, NULL);

	CMDQUEUE_CONVERT_RC(status);
}

/****************************************************************************
 *                      CmdQueue_CommandWithCb()
 ****************************************************************************
 * DESCRIPTION: Send command with CB to the wlan hardware command mailbox
 *
 * INPUTS:  
 *
 * OUTPUT:  None
 *
 * RETURNS: OK or NOK
 ****************************************************************************/
int	   			 	CmdQueue_CommandWithCb(TI_HANDLE hCmdQueue, Command_e MboxCmdType, void *MboxBuf, UINT32 ParamsLen, 
															void *CB_Func, TI_HANDLE CB_handle, void* CB_Buf)
{
	CmdQueue_T* pCmdQueue = (CmdQueue_T*)hCmdQueue;
	int status;

	CHECK_ERROR_FLAG(pCmdQueue->ErrorFlag);
	
	if(((CB_Func != NULL) && (CB_handle == NULL)) || ((CB_Func == NULL) && (CB_handle != NULL)))
	{
		WLAN_REPORT_ERROR(pCmdQueue->hReport, HAL_CTRL_MODULE_LOG, 
			("CmdQueue_CommandWithCb: NULL Object with none NULL CB\n"));		
		return NOK;
	}

	status = CmdQueue_Push(pCmdQueue, MboxCmdType,
                       				(UINT8*)MboxBuf, ParamsLen,
					   		CB_Func, CB_handle, (UINT8*)CB_Buf);	

	CMDQUEUE_CONVERT_RC(status);
}


/****************************************************************************
 *                      CmdQueue_Push()
 ****************************************************************************
 * DESCRIPTION: Push the command Node to the Queue with its information element parameter
 *
 * INPUTS:  
 *
 * OUTPUT:  None
 *
 * RETURNS: NOK OK
 ****************************************************************************/
int				CmdQueue_Push(CmdQueue_T  *pCmdQueue, Command_e  cmdType,
                       							UINT8* pParamsBuf, UINT32 paramsLen,
					   					void *CB_Func, TI_HANDLE CB_Arg, UINT8* pCB_Buf)
{

#ifdef TI_DBG

	/*
	check if Queue is Full
	*/
    	if(pCmdQueue->NumberOfCommandInQueue == CMDQUEUE_QUEUE_DEPTH)
    	{
		WLAN_REPORT_ERROR(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
            		("CmdQueue_Push: ** ERROR ** The Queue is full\n"
			 "CmdType = %s %s , Len = %d   InfoElemId = 0x%x\n",
			 CmdQueue_GetCmdString(cmdType),
			 CmdQueue_GetIEString( cmdType,*(UINT16 *)pParamsBuf), paramsLen, *(UINT16 *)pParamsBuf));
        	return  NOK;
    	}
#endif /* TI_DBG*/

    /* initializes the last Node in the Queue with the arrgs */
    	pCmdQueue->CmdQueue[pCmdQueue->Tail].cmdType   = cmdType;
    	pCmdQueue->CmdQueue[pCmdQueue->Tail].paramsLen = paramsLen;
    	pCmdQueue->CmdQueue[pCmdQueue->Tail].CB_Func = CB_Func;
	pCmdQueue->CmdQueue[pCmdQueue->Tail].CB_Arg = CB_Arg;	
	if(cmdType == CMD_INTERROGATE)
	{
		os_memoryCopy(pCmdQueue->hOs, pCmdQueue->CmdQueue[pCmdQueue->Tail].paramsBuf, pParamsBuf, CMDQUEUE_INFO_ELEM_HEADER_LEN);
	}
	else
		os_memoryCopy(pCmdQueue->hOs, pCmdQueue->CmdQueue[pCmdQueue->Tail].paramsBuf, pParamsBuf, paramsLen);
	pCmdQueue->CmdQueue[pCmdQueue->Tail].interrogateParamsBuf = pCB_Buf;
            
	/*advance the Queue tail*/
	pCmdQueue->Tail++;
	if(pCmdQueue->Tail == CMDQUEUE_QUEUE_DEPTH)
		pCmdQueue->Tail = 0;
    
	/* update counters */
    	pCmdQueue->NumberOfCommandInQueue++;
#ifdef TI_DBG    
    	if(pCmdQueue->MaxNumberOfCommandInQueue < pCmdQueue->NumberOfCommandInQueue)
      		pCmdQueue->MaxNumberOfCommandInQueue = pCmdQueue->NumberOfCommandInQueue;	  
#endif /* TI_DBG*/
	  
    WLAN_REPORT_INFORMATION(pCmdQueue->hReport, CMDQUEUE_MODULE_LOG,
            ("CmdQueue_Push: CmdType = %s (%s(%d))\n"
			"Len = %d, NumOfCmd = %d \n",
			CmdQueue_GetCmdString(cmdType),
			(pParamsBuf) ?  CmdQueue_GetIEString(cmdType,*(UINT16 *)pParamsBuf):"",			
			(pParamsBuf) ?  *(UINT16 *)pParamsBuf:0,			
			paramsLen, pCmdQueue->NumberOfCommandInQueue));

	/*if Queue has only one command trigger the send command form Queue */	
	if (pCmdQueue->NumberOfCommandInQueue == 1)
	{
		return (CmdQueue_SM(pCmdQueue,CMDQUEUE_EVENT_RUN));
	}
	else
		return (OK);            
}

/****************************************************************************
 *                     CmdQueue_SM()
 ****************************************************************************
 * DESCRIPTION: inplement the CmdQueue SM
 *
 * INPUTS:  
 *
 * OUTPUT:  None
 *
 * RETURNS: OK or NOK
 ****************************************************************************/
int                 CmdQueue_SM(CmdQueue_T* pCmdQueue,CmdQueue_SMEvents_e event)
{   
    int rc = OK;
    int breakWhile = FALSE;
    CmdQueue_CmdNode_T* pHead;
    TI_STATUS status;
    
    while(!breakWhile)
    {
            WLAN_REPORT_INFORMATION(pCmdQueue->hReport, CMDQUEUE_MODULE_LOG,
            ("CmdQueue_SM: state = %s (%d) event = %s(%d), rc = %d\n",
            StateString[pCmdQueue->State],
            pCmdQueue->State,
            EventString[event],
            event,rc));

        switch(pCmdQueue->State)
        {
            /***************************************
            CMDQUEUE_STATE_IDLE
            ***************************************/
            case CMDQUEUE_STATE_IDLE:
                switch(event)
                {
                    case CMDQUEUE_EVENT_RUN:
                        pCmdQueue->State = CMDQUEUE_STATE_SEND_CMD_v;
                        break;
                    default:
                        WLAN_REPORT_ERROR(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
                            ("CmdQueue_SM: ** ERROR **  No such event (%d) for state CMDQUEUE_STATE_IDLE\n",event));        
                            return NOK;                     
                }
                break;

            /***************************************
            CMDQUEUE_STATE_SEND_CMD_v
            ***************************************/
            case CMDQUEUE_STATE_SEND_CMD_v:
                pHead = &pCmdQueue->CmdQueue[pCmdQueue->Head];

                WLAN_REPORT_INFORMATION(pCmdQueue->hReport, CMDQUEUE_MODULE_LOG,
                    ("CmdQueue_SM: Send Cmd: CmdType = %s(%s)\n"
            			"Len = %d, NumOfCmd = %d \n",
            			CmdQueue_GetCmdString(pHead->cmdType),
		            (pHead->paramsBuf) ?  CmdQueue_GetIEString(pHead->cmdType,*(UINT16 *)pHead->paramsBuf):"",
		            pHead->paramsLen, pCmdQueue->NumberOfCommandInQueue));
                
#ifdef TI_DBG
                pCmdQueue->CmdSendCounter++;
#endif /* TI_DBG    */
                pCmdQueue->State = CMDQUEUE_STATE_INTERROGATE_v;
                    
                    /* send the command to TNET */
                if(pHead->cmdType == CMD_INTERROGATE)
                    rc = CmdMBox_SendCmd(pCmdQueue->hCmdMBox, 
                            pHead->cmdType, 
                            pHead->paramsBuf, 
                            CMDQUEUE_INFO_ELEM_HEADER_LEN); 
                else
                    rc = CmdMBox_SendCmd(pCmdQueue->hCmdMBox, 
                            pHead->cmdType, 
                            pHead->paramsBuf, 
                            pHead->paramsLen);
                
                if(rc == TNETWIF_PENDING)
                {
                    if(pCmdQueue->SM_RC)
                    {                       
                        rc = pCmdQueue->SM_RC;
                    }
                    pCmdQueue->State = CMDQUEUE_STATE_WAIT_SEND_CMPLT;
                    breakWhile = TRUE;
                }
                else
                {                   
                    breakWhile = TRUE;
                }
                break;

            /***************************************
            CMDQUEUE_STATE_WAIT_SEND_CMPLT
            ***************************************/
            case CMDQUEUE_STATE_WAIT_SEND_CMPLT:
                switch(event)
                {
                    case CMDQUEUE_EVENT_SEND_CMPLT:
#ifdef TI_DBG    
                            pCmdQueue->CmdCompltCounter++;
#endif /* TI_DBG                        */
                        pCmdQueue->State = CMDQUEUE_STATE_INTERROGATE_v;
                        break;
                    default:
                        WLAN_REPORT_ERROR(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
                            ("CmdQueue_SM: ** ERROR **  No such event (%d) for state CMDQUEUE_STATE_WAIT_SEND_CMPLT\n",event));     
                            return NOK;
                }
                break;

            /***************************************
            CMDQUEUE_STATE_INTERROGATE_v
            ***************************************/
            case CMDQUEUE_STATE_INTERROGATE_v:
                pHead = &pCmdQueue->CmdQueue[pCmdQueue->Head];
                    rc = CmdMBox_GetResult(pCmdQueue->hCmdMBox,
                            pHead->interrogateParamsBuf, pHead->paramsLen, (UINT32*)&status);
                    if(rc == TNETWIF_PENDING)
                    {
                        pCmdQueue->State = CMDQUEUE_STATE_WAIT_RESULT;
                        breakWhile = TRUE;
                    }
                    else
                    {
                        if(status != OK)
                        {
                            pCmdQueue->ErrorFlag = TRUE;
                            return OK;
                        }
                        pCmdQueue->State = CMDQUEUE_STATE_FINISH_v;
                    }
                break;

            /***************************************
            CMDQUEUE_STATE_WAIT_RESULT
            ***************************************/
            case CMDQUEUE_STATE_WAIT_RESULT:                
                switch(event)
                {
                    case CMDQUEUE_EVENT_RESULT_RECEIVED:
                        rc = TNETWIF_COMPLETE;
                        pCmdQueue->State = CMDQUEUE_STATE_FINISH_v;
                        break;
                    default:
                        WLAN_REPORT_ERROR(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
                            ("CmdQueue_SM: ** ERROR **  No such event (%d) for state CMDQUEUE_STATE_WAIT_RESULT\n",event));     
                            return NOK;
                }
                break;

            /***************************************
            CMDQUEUE_STATE_FINISH_v
            ***************************************/
            case CMDQUEUE_STATE_FINISH_v:
            {
                Command_e cmdType;
                UINT16        uParam;
                void *fCb, *hCb, *pCb;

                pHead = &pCmdQueue->CmdQueue[pCmdQueue->Head];

                /* Keep callback parameters in temporary variables */
                cmdType = pHead->cmdType;
                uParam  = *(UINT16 *)pHead->paramsBuf;
                fCb = pHead->CB_Func;
                hCb = pHead->CB_Arg;
                pCb = pHead->interrogateParamsBuf;

                /* 
                 * Delete the command from the queue before calling a callback 
                 * because there may be nested calls inside a callback
                 */
                pCmdQueue->Head ++;
                if (pCmdQueue->Head >= CMDQUEUE_QUEUE_DEPTH)
                    pCmdQueue->Head = 0;                
                pCmdQueue->NumberOfCommandInQueue --;                

                /* Check if queue is empty to send the next command */
                if (pCmdQueue->NumberOfCommandInQueue > 0)               
                {
                    pCmdQueue->SM_RC = rc;
                    pCmdQueue->State = CMDQUEUE_STATE_SEND_CMD_v;
                }
                else	
                {   
                    pCmdQueue->SM_RC = 0;
                    pCmdQueue->State = CMDQUEUE_STATE_IDLE;
                    breakWhile = TRUE;
                }

                /*
                 * Call the user callback after deleting the command from the queue 
                 * because there may be nested calls inside a callback
                 */
                status = CmdMBox_GetStatus(pCmdQueue->hCmdMBox);
                if (fCb)
                {   
                    if(pCb)
                    {
                        ((CmdQueue_InterrogateCB_t)fCb) (hCb, status, pCb); 
                    }
                    else
                    {
                        ((CmdQueue_CB_t)fCb) (hCb, status);
                    }
                }
                else
                {
                    /* Call the generic callback */
                    if (pCmdQueue->CmdCompleteGenericCB_Func)
                    {
                        pCmdQueue->CmdCompleteGenericCB_Func (pCmdQueue->CmdCompleteGenericCB_Arg,                             
                                                              cmdType, 
                                                              uParam, 
                                                              status);
                    }
                }
            }               
                break;

            default:
                WLAN_REPORT_ERROR(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
                    ("CmdQueue_SM: ** ERROR **  No such state (%d)\n",pCmdQueue->State));       
                    return NOK;
        }
    }
            WLAN_REPORT_INFORMATION(pCmdQueue->hReport, CMDQUEUE_MODULE_LOG,
                             ("CmdQueue_SM: rc = %d\n",rc));

    return rc;
}

/*******************************************************************************************************
 *                     CmdQueue_SendCmplt()
 ******************************************************************************************************
 * DESCRIPTION: This function is the CB from the CmdMBox that will issue the "SendCmplt" event to 
 * 				the CmdQueue SM. Indicates that the Cmd was transferred to the FW.
 *
 * RETURNS: OK
 *************************************************************************************************/
int 			CmdQueue_SendCmplt(TI_HANDLE hCmdQueue)
{
	CmdQueue_T* pCmdQueue = (CmdQueue_T*)hCmdQueue;
    
	/* call the SM for further execution */
	return CmdQueue_SM(pCmdQueue,CMDQUEUE_EVENT_SEND_CMPLT);
}

/*******************************************************************************************************
 *                     CmdQueue_ResultReceived()
 ******************************************************************************************************
 * DESCRIPTION: This function is the CB from the CmdMBox that will issue the "ResultReceived" 
 * 				event to the CmdQueue SM. Indicates that the Cmd's results were read from 
 *				the FW.
 *
 * RETURNS: OK
 *************************************************************************************************/
int					CmdQueue_ResultReceived(TI_HANDLE hCmdQueue, UINT32 status)
{
    	CmdQueue_T* pCmdQueue = (CmdQueue_T*)hCmdQueue;

	/* call the SM for further execution */
	return CmdQueue_SM(pCmdQueue,CMDQUEUE_EVENT_RESULT_RECEIVED);
}

/****************************************************************************
 *                      CmdQueue_TimeOut()
 ****************************************************************************
 * DESCRIPTION: Called when a command timeout occur
 *
 * OUTPUT:  None
 *
 * RETURNS: OK or NOK
 ******************************************************************************/
int 			CmdQueue_Error(TI_HANDLE hCmdQueue)
{
	
	CmdQueue_T* pCmdQueue = (CmdQueue_T*)hCmdQueue;		

#ifdef TI_DBG
	CmdQueue_CmdNode_T* pHead = &pCmdQueue->CmdQueue[pCmdQueue->Head];	
	UINT32 TimeStamp = os_timeStampMs(pCmdQueue->hOs);
	
   	WLAN_REPORT_ERROR(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
    		("CmdQueue_Error: **ERROR**  Command Occured \n"
	     	"                                        Cmd = %s %s , Len = %d \n "
	   		"                                        NumOfCmd = %d \n"
			"                                        MAC TimeStamp on timeout = %d\n ",
    		CmdQueue_GetCmdString(pHead->cmdType), 
    		CmdQueue_GetIEString(pHead->cmdType, *(UINT16 *)pHead->paramsBuf),
    		pHead->paramsLen, 
    		pCmdQueue->NumberOfCommandInQueue, 
    		TimeStamp));
#endif

	/* Print The command that was sent before the timeout occur */
	CmdQueue_PrintHistory(pCmdQueue, CMDQUEUE_HISTORY_DEPTH);

	/* preform Recovery */
#ifdef TI_DBG
	if(pCmdQueue->FailureCB)
#endif		
    	pCmdQueue->FailureCB(pCmdQueue->FailureCbHandle,NOK);

	return OK;

	}

/****************************************************************************
 *                      CmdQueue_Print()
 ****************************************************************************
 * DESCRIPTION: 
 *
 * INPUTS:  
 *
 * OUTPUT:  None
 *
 * RETURNS: 
 ****************************************************************************/
void					CmdQueue_Print(TI_HANDLE hCmdQueue)
{
	CmdQueue_T* pCmdQueue = (CmdQueue_T*)hCmdQueue;	
	
    	WLAN_REPORT_REPLY(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
       	("------------- CmdQueue Queue -------------------\n"));
    
    	WLAN_REPORT_REPLY(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
        	("CmdQueue_Print:The Max NumOfCmd in Queue was = %d\n",
        	pCmdQueue->MaxNumberOfCommandInQueue));
    	WLAN_REPORT_REPLY(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
        	("CmdQueue_Print:The Current NumOfCmd in Queue = %d\n",
        	pCmdQueue->NumberOfCommandInQueue));
#ifdef TI_DBG
    	WLAN_REPORT_REPLY(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
        	("CmdQueue_Print:The Total number of Cmd send from Queue= %d\n",
        	pCmdQueue->CmdSendCounter));
    	WLAN_REPORT_REPLY(pCmdQueue->hReport, CMD_MBOX_MODULE_LOG,
        	("CmdQueue_Print:The Total number of Cmd Completed interrupt= %d\n",
        	pCmdQueue->CmdCompltCounter));
#endif

    	CmdQueue_PrintQueue(pCmdQueue);
}

/****************************************************************************
 *                      CmdQueue_PrintQueue()
 ****************************************************************************
 * DESCRIPTION: 
 *
 * INPUTS:  
 *
 * OUTPUT:  None
 *
 * RETURNS: 
 ****************************************************************************/
void				CmdQueue_PrintQueue(CmdQueue_T  *pCmdQueue)
{
	int CurrentCmdindex;
    	int first  = pCmdQueue->Head;
	CmdQueue_CmdNode_T* pHead;
    	int NumberOfCommand = pCmdQueue->NumberOfCommandInQueue;

	WLAN_OS_REPORT(("CmdQueue_PrintQueue \n"));

    	for(CurrentCmdindex = 0 ; CurrentCmdindex < NumberOfCommand ; CurrentCmdindex++)
    	{
		pHead = &pCmdQueue->CmdQueue[first];
#ifdef TI_DBG
        	WLAN_OS_REPORT(("Cmd index %d CmdType = %s %s, Len = %d, Place in Queue = %d \n",
            		CurrentCmdindex, 
            		CmdQueue_GetCmdString(pHead->cmdType),
            		CmdQueue_GetIEString(pHead->cmdType, (((pHead->cmdType == CMD_INTERROGATE)||(pHead->cmdType == CMD_CONFIGURE)) ? *(UINT16 *)pHead->paramsBuf : 0)),
            		pHead->paramsLen, 
            		first));    
#else
		WLAN_OS_REPORT(("Cmd index %d CmdType = %d %d, Len = %d, Place in Queue = %d \n",
            		CurrentCmdindex, 
            		pHead->cmdType,
            		(((pHead->cmdType == CMD_INTERROGATE)||(pHead->cmdType == CMD_CONFIGURE)||
                      (pHead->cmdType == CMD_READ_MEMORY)||(pHead->cmdType == CMD_WRITE_MEMORY)) ? *(UINT16 *)pHead->paramsBuf : 0),
            		pHead->paramsLen, 
            		first));    
#endif

        	first++;
		if(first == CMDQUEUE_QUEUE_DEPTH)
			first = 0;
    	}
}

/****************************************************************************
 *                      CmdQueue_PrintHistory()
 ****************************************************************************
 * DESCRIPTION: print the last command according to a value
 *
 * INPUTS:  NunOfCmd : the number of the last command to print 
 *
 ****************************************************************************/
void					CmdQueue_PrintHistory(TI_HANDLE hCmdQueue, int NunOfCmd)
{
	CmdQueue_T* pCmdQueue = (CmdQueue_T*)hCmdQueue;	
	int CurrentCmdindex;
    	int first  = pCmdQueue->Head;
	CmdQueue_CmdNode_T* pHead ;

    WLAN_OS_REPORT(("--------------- CmdQueue_PrintHistory of %d -------------------\n",NunOfCmd));
	
	for(CurrentCmdindex = 0 ; CurrentCmdindex < NunOfCmd ; CurrentCmdindex++)
	{
		pHead  =  &pCmdQueue->CmdQueue[first];

#ifdef TI_DBG
	    	WLAN_OS_REPORT(("Cmd index %d CmdType = %s %s, Len = %d, Place in Queue = %d \n",
            		CurrentCmdindex, 
            		CmdQueue_GetCmdString(pHead->cmdType),
            		CmdQueue_GetIEString(pHead->cmdType, (((pHead->cmdType == CMD_INTERROGATE)||(pHead->cmdType == CMD_CONFIGURE)) ? *(UINT16 *)pHead->paramsBuf : 0)),
            		pHead->paramsLen, 
            		first));
#else
		WLAN_OS_REPORT(("Cmd index %d CmdType = %d %d, Len = %d, Place in Queue = %d \n",
            		CurrentCmdindex, 
            		pHead->cmdType,
            		(((pHead->cmdType == CMD_INTERROGATE)||(pHead->cmdType == CMD_CONFIGURE)||
                      (pHead->cmdType == CMD_READ_MEMORY)||(pHead->cmdType == CMD_WRITE_MEMORY)) ? *(UINT16 *)pHead->paramsBuf : 0),
            		pHead->paramsLen, 
            		first));
#endif

		if(first == 0)
			first = CMDQUEUE_QUEUE_DEPTH-1;
		else
			first--;
	}

	WLAN_OS_REPORT(("-----------------------------------------------------------------------\n"));

}

/****************************************************************************
 *                      CmdQueue_GetMaxNumberOfCommands()
 ****************************************************************************
 * DESCRIPTION: returns maximum number of commands (ever) in CmdQueue queue
 *
 * INPUTS:  
 *
 * OUTPUT:  None
 *
 * RETURNS: maximum number of commands (ever) in mailbox queue
 ****************************************************************************/
int 					CmdQueue_GetMaxNumberOfCommands (TI_HANDLE hCmdQueue)
{
	CmdQueue_T* pCmdQueue = (CmdQueue_T*)hCmdQueue;

	return (pCmdQueue->MaxNumberOfCommandInQueue);
}

#ifdef REPORT_LOG

/****************************************************************************
 *                      CmdQueue_GetCmdString()
 ****************************************************************************
 * DESCRIPTION: 
 *
 * INPUTS:  
 *
 * OUTPUT:  None
 *
 * RETURNS: 
 ****************************************************************************/
char* 			CmdQueue_GetCmdString(int MboxCmdType)
{
	switch (MboxCmdType)
	{
		case 0: return "CMD_RESET";
		case 1: return "CMD_INTERROGATE"; 
	 	case 2: return "CMD_CONFIGURE";
	    	case 3: return "CMD_ENABLE_RX";
		case 4: return "CMD_ENABLE_TX";
		case 5: return "CMD_DISABLE_RX";
	    	case 6: return "CMD_DISABLE_TX";	
		case 8: return "CMD_SCAN";
		case 9: return "CMD_STOP_SCAN";	
	    	case 10: return "CMD_VBM";
		case 11: return "CMD_START_JOIN";	
		case 12: return "CMD_SET_KEYS";	
		case 13: return "CMD_READ_MEMORY";	
	    	case 14: return "CMD_WRITE_MEMORY";
		case 19: return "CMD_BEACON";
		case 20: return "CMD_PROBE_RESP";	
		case 21: return "CMD_NULL_DATA";	
	    	case 22: return "CMD_PROBE_REQ";	
		case 23: return "CMD_TEST";		
		case 27: return "CMD_ENABLE_RX_PATH";
		case 28: return "CMD_NOISE_HIST";	
	    	case 29: return "CMD_RX_RESET";	
		case 30: return "CMD_PS_POLL";	
		case 31: return "CMD_QOS_NULL_DATA";	
		case 32: return "CMD_LNA_CONTROL";	
		case 33: return "CMD_SET_BCN_MODE";	
		case 34: return "CMD_MEASUREMENT";	
		case 35: return "CMD_STOP_MEASUREMENT";
		case 36: return "CMD_DISCONNECT";		
		case 37: return "CMD_SET_PS_MODE";		
		case 38: return "CMD_CHANNEL_SWITCH";	
		case 39: return "CMD_STOP_CHANNEL_SWICTH";
		case 40: return "CMD_AP_DISCOVERY";
		case 41: return "CMD_STOP_AP_DISCOVERY";
		case 42: return "CMD_SPS_SCAN";			
		case 43: return "CMD_STOP_SPS_SCAN";		
		case 45: return "CMD_HEALTH_CHECK";		
		default: return " *** Error No Such CMD **** ";
	}
};

/****************************************************************************
 *                      CmdQueue_GetErrorString()
 ****************************************************************************
 * DESCRIPTION: 
 *
 * INPUTS:  
 *
 * OUTPUT:  None
 *
 * RETURNS: 
 ****************************************************************************/
char*            CmdQueue_GetErrorString(CommandStatus_e MboxError)
{
    switch (MboxError)
    {
    case CMD_MAILBOX_IDLE:
        return "CMD_MAILBOX_IDLE";
        /* break; to avoid compilation warning */

    case CMD_STATUS_SUCCESS:
        return "CMD_STATUS_SUCCESS";
        /* break; to avoid compilation warning */

    case CMD_STATUS_UNKNOWN_CMD:
        return "CMD_STATUS_UNKNOWN_CMD";
        /* break; to avoid compilation warning */

    case CMD_STATUS_UNKNOWN_IE:
        return "CMD_STATUS_UNKNOWN_IE";
        /* break; to avoid compilation warning */

    case CMD_STATUS_RX_BUSY:
        return "CMD_STATUS_RX_BUSY";
        /* break; to avoid compilation warning */

    case CMD_STATUS_INVALID_PARAM:
        return "CMD_STATUS_INVALID_PARAM";
        /* break; to avoid compilation warning */

    case CMD_STATUS_TEMPLATE_TOO_LARGE:
        return "CMD_STATUS_TEMPLATE_TOO_LARGE";
        /* break; to avoid compilation warning */

    case CMD_STATUS_OUT_OF_MEMORY:
        return "CMD_STATUS_OUT_OF_MEMORY";
        /* break; to avoid compilation warning */

    case CMD_STATUS_STA_TABLE_FULL:
        return "CMD_STATUS_STA_TABLE_FULL";
        /* break; to avoid compilation warning */

    case CMD_STATUS_RADIO_ERROR:
        return "CMD_STATUS_RADIO_ERROR";
        /* break; to avoid compilation warning */

    case CMD_STATUS_WRONG_NESTING:
        return "CMD_STATUS_WRONG_NESTING";
        /* break; to avoid compilation warning */

    case CMD_STATUS_TIMEOUT:
        return "CMD_STATUS_TIMEOUT";
        /* break; to avoid compilation warning */

    case CMD_STATUS_FW_RESET:
        return "CMD_STATUS_FW_RESET";
        /* break; to avoid compilation warning */

    default:
        return "Unrecognized error code";
        /* break; to avoid compilation warning */
    }
}


/****************************************************************************
 *                      CmdQueue_GetIEString()
 ****************************************************************************
 * DESCRIPTION: 
 *
 * INPUTS:  
 *
 * OUTPUT:  None
 *
 * RETURNS: 
 ****************************************************************************/
char* 			CmdQueue_GetIEString(int MboxCmdType, UINT16 Id)
{
	if( MboxCmdType== CMD_INTERROGATE || MboxCmdType == CMD_CONFIGURE)	
	{
		switch (Id)
		{
		case ACX_WAKE_UP_CONDITIONS: 		return " (ACX_WAKE_UP_CONDITIONS)";
		case ACX_MEM_CFG: 					return " (ACX_MEM_CFG)";                 
		case ACX_SLOT: 						return " (ACX_SLOT) ";                    
		case ACX_QUEUE_HEAD: 				return " (ACX_QUEUE_HEAD)";	
		case ACX_AC_CFG: 					return " (ACX_AC_CFG) ";                  
		case ACX_MEM_MAP: 					return " (ACX_MEM_MAP)";
		case ACX_AID: 						return " (ACX_AID)";
		case ACX_RADIO_PARAM: 				return " (ACX_RADIO_PARAM)";          
		case ACX_CFG: 						return " (ACX_CFG) ";                  
        case ACX_FW_REV: 					return " (ACX_FW_REV) ";                  
        case ACX_FCS_ERROR_CNT: 			return " (ACX_FCS_ERROR_CNT) ";               
        case ACX_MEDIUM_USAGE: 				return " (ACX_MEDIUM_USAGE) ";                  
		case ACX_RX_CFG: 					return " (ACX_RX_CFG) ";                  
		case ACX_TX_QUEUE_CFG: 				return " (ACX_TX_QUEUE_CFG) "; 
		case ACX_BSS_IN_PS: 				return " (ACX_BSS_IN_PS) ";
		case ACX_STATISTICS: 				return " (ACX_STATISTICS) ";
		case ACX_FEATURE_CFG: 				return " (ACX_FEATURE_CFG) ";                    
		case ACX_MISC_CFG: 					return " (ACX_MISC_CFG) ";               
		case ACX_TID_CFG: 					return " (ACX_TID_CFG) ";                    
		case ACX_CAL_ASSESSMENT: 			return " (ACX_CAL_ASSESSMENT) ";            
		case ACX_BEACON_FILTER_OPT: 		return " (ACX_BEACON_FILTER_OPT) ";             			      											  
		case ACX_LOW_RSSI: 					return " (ACX_LOW_RSSI)";              
        case ACX_NOISE_HIST: 				return " (ACX_NOISE_HIST)";           
		case ACX_HDK_VERSION: 				return " (ACX_HDK_VERSION)";         
		case ACX_PD_THRESHOLD: 				return " (ACX_PD_THRESHOLD) ";                 
		case ACX_DATA_PATH_PARAMS: 			return " (ACX_DATA_PATH_PARAMS) ";                
   	case ACX_CCA_THRESHOLD: 				return " (ACX_CCA_THRESHOLD)";            
		case ACX_EVENT_MBOX_MASK: 			return " (ACX_EVENT_MBOX_MASK) ";
#ifdef FW_RUNNING_AS_AP                            
		case ACX_DTIM_PERIOD: 				return " (ACX_DTIM_PERIOD) ";            
#else
		case ACX_WR_TBTT_AND_DTIM: 			return " (ACX_WR_TBTT_AND_DTIM) ";  
#endif
		case ACX_ACI_OPTION_CFG: 			return " (ACX_ACI_OPTION_CFG) ";                
        case ACX_GPIO_CFG: 					return " (ACX_GPIO_CFG) ";  
        case ACX_GPIO_SET: 					return " (ACX_GPIO_SET) ";  
		case ACX_PM_CFG: 					return " (ACX_PM_CFG) ";
		case ACX_CONN_MONIT_PARAMS: 		return " (ACX_CONN_MONIT_PARAMS) ";
		case ACX_AVERAGE_RSSI: 				return " (ACX_AVERAGE_RSSI) ";
		case ACX_CONS_TX_FAILURE: 			return " (ACX_CONS_TX_FAILURE) ";
		case ACX_BCN_DTIM_OPTIONS: 			return " (ACX_BCN_DTIM_OPTIONS) ";                             
		case ACX_SG_ENABLE: 				return " (ACX_SG_ENABLE) ";                                       
		case ACX_SG_CFG: 					return " (ACX_SG_CFG) ";                                       
		case ACX_ANTENNA_DIVERSITY_CFG: 	return " (ACX_ANTENNA_DIVERSITY_CFG) ";                                      
		case ACX_LOW_SNR: 					return " (ACX_LOW_SNR) ";
		case ACX_BEACON_FILTER_TABLE: 		return " (ACX_BEACON_FILTER_TABLE) ";
		case ACX_ARP_IP_FILTER: 			return " (ACX_ARP_IP_FILTER) ";
		case ACX_ROAMING_STATISTICS_TBL:	return " (ACX_ROAMING_STATISTICS_TBL) ";  
		case ACX_RATE_POLICY: 				return " (ACX_RATE_POLICY) ";  
		case ACX_CTS_PROTECTION: 			return " (ACX_CTS_PROTECTION) ";  
		case ACX_SLEEP_AUTH: 				return " (ACX_SLEEP_AUTH) ";  
		case ACX_PREAMBLE_TYPE: 			return " (ACX_PREAMBLE_TYPE) ";  
		case ACX_ERROR_CNT: 				return " (ACX_ERROR_CNT) ";  
		case ACX_FW_GEN_FRAME_RATES: 		return " (ACX_FW_GEN_FRAME_RATES) ";  
		case ACX_IBSS_FILTER: 				return " (ACX_IBSS_FILTER) ";  
		case ACX_SERVICE_PERIOD_TIMEOUT:	return " (ACX_SERVICE_PERIOD_TIMEOUT) ";  
		case ACX_TSF_INFO: 					return " (ACX_TSF_INFO) ";  
		case ACX_CONFIG_PS_WMM: 			return " (ACX_CONFIG_PS_WMM) "; 
		case ACX_ENABLE_RX_DATA_FILTER: 	return " (ACX_ENABLE_RX_DATA_FILTER) ";
		case ACX_SET_RX_DATA_FILTER: 		return " (ACX_SET_RX_DATA_FILTER) ";
		case ACX_GET_DATA_FILTER_STATISTICS:return " (ACX_GET_DATA_FILTER_STATISTICS) ";
		case ACX_POWER_LEVEL_TABLE: 		return " (ACX_POWER_LEVEL_TABLE) ";
		case ACX_BET_ENABLE: 				return " (ACX_BET_ENABLE) ";
		case DOT11_STATION_ID: 				return " (DOT11_STATION_ID) ";
		case DOT11_RX_MSDU_LIFE_TIME: 		return " (DOT11_RX_MSDU_LIFE_TIME) ";
		case DOT11_CUR_TX_PWR: 				return " (DOT11_CUR_TX_PWR) ";
		case DOT11_DEFAULT_KEY: 			return " (DOT11_DEFAULT_KEY) ";
		case DOT11_RX_DOT11_MODE: 			return " (DOT11_RX_DOT11_MODE) ";
		case DOT11_RTS_THRESHOLD: 			return " (DOT11_RTS_THRESHOLD) ";
		case DOT11_GROUP_ADDRESS_TBL: 		return " (DOT11_GROUP_ADDRESS_TBL) ";  
               
		default:	return " *** Error No Such IE **** ";
		}
	}
	return "";
}
#endif /* REPORT_LOG */
Back to Top