1/****************************************************************************
2**+-----------------------------------------------------------------------+**
3**|                                                                       |**
4**| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved.      |**
5**| All rights reserved.                                                  |**
6**|                                                                       |**
7**| Redistribution and use in source and binary forms, with or without    |**
8**| modification, are permitted provided that the following conditions    |**
9**| are met:                                                              |**
10**|                                                                       |**
11**|  * Redistributions of source code must retain the above copyright     |**
12**|    notice, this list of conditions and the following disclaimer.      |**
13**|  * Redistributions in binary form must reproduce the above copyright  |**
14**|    notice, this list of conditions and the following disclaimer in    |**
15**|    the documentation and/or other materials provided with the         |**
16**|    distribution.                                                      |**
17**|  * Neither the name Texas Instruments nor the names of its            |**
18**|    contributors may be used to endorse or promote products derived    |**
19**|    from this software without specific prior written permission.      |**
20**|                                                                       |**
21**| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |**
22**| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |**
23**| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |**
24**| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |**
25**| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |**
26**| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |**
27**| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |**
28**| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |**
29**| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |**
30**| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |**
31**| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |**
32**|                                                                       |**
33**+-----------------------------------------------------------------------+**
34****************************************************************************/
35
36#ifdef _WINDOWS    /*nick*/
37#elif defined(__ARMCC__)
38#include "string.h"
39#endif
40
41#include "osAdapter.h"
42#include "srcApi.h"
43#include "tiwlnif.h"
44#include "osDot11.h"
45#include "osUtil.h"
46#include "paramOut.h"
47#include "wspVer.h"
48#include "osClsfr.h"
49#include "whalHwMboxCmdBit.h"
50
51static TI_STATUS
52UtilRegulatoryDomain_setCountryIE(
53								 PTIWLN_ADAPTER_T pAdapter,
54								 externalParam_e ParamType,
55								 PUCHAR pData,
56								 ULONG Length
57								 );
58
59#ifdef TIWLN_WINCE30
60
61gprintf(const char *format ,... )
62{
63#if 1
64#ifdef DEBUG_PB
65	wchar_t Buf[500];
66#endif
67
68	FILE *Fpn;
69
70	Fpn = fopen("TILog.txt","a");
71
72	if (Fpn)
73	{
74		char Msg[500];
75		va_list ap;
76		va_start(ap,format);
77		_vsnprintf(Msg,500,format,ap);
78		fprintf(Fpn,"%s", Msg);
79#ifdef DEBUG_PB
80		mbstowcs(Buf,Msg,strlen(Msg)+1);
81		DEBUGMSG(1,(Buf));
82#endif
83
84		fclose(Fpn);
85
86	}
87#endif
88}
89
90#endif
91
92
93/*-----------------------------------------------------------------------------
94Routine Name: UtilSetParam
95Routine Description:
96Arguments:
97Return Value:
98-----------------------------------------------------------------------------*/
99TI_STATUS
100UtilSetParam(
101			PTIWLN_ADAPTER_T pAdapter,
102			externalParam_e ParamType,
103			PUCHAR pData,
104			ULONG Length
105			)
106{
107	paramInfo_t Param;
108	TI_STATUS Status;
109
110	Param.paramType = ParamType;
111	if (Length > sizeof(Param.content))
112	{
113		PRINTF(DBG_NDIS_OIDS_VERY_LOUD, (" UtilSetParam: Buffer for parameter 0x%X is bigger(%d) then Param size(%d)\n", ParamType, (int)Length, sizeof(Param.content)));
114		Param.paramLength = sizeof(Param.content);
115		NdisMoveMemory(&Param.content, pData, sizeof(Param.content));
116	} else
117	{
118		Param.paramLength = Length;
119		NdisMoveMemory(&Param.content, pData, Length);
120	}
121
122	Status = configMgr_setParam(pAdapter->CoreHalCtx, &Param);
123
124	return Status;
125}
126
127
128/*-----------------------------------------------------------------------------
129Routine Name: UtilGetParam
130Routine Description:
131Arguments:
132Return Value:
133-----------------------------------------------------------------------------*/
134TI_STATUS
135UtilGetParam(
136			PTIWLN_ADAPTER_T pAdapter,
137			externalParam_e ParamType,
138			PUCHAR pData,
139			ULONG Length
140			)
141{
142	paramInfo_t Param;
143	TI_STATUS Status;
144
145	Param.paramType = ParamType;
146	Param.paramLength = Length;
147
148	Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
149
150	if (Status == NOK)
151	{
152		PRINTF(DBG_NDIS_OIDS_VERY_LOUD, (" UtilGetParam: ERROR on return from get param, status=%d, param=%d\n",
153										 Status, ParamType));
154	} else if ( Status != NOK )
155	{
156		PRINTF(DBG_NDIS_OIDS_LOUD, (" UtilGetParam: WARNING on return from get param, status=%d, param=%d\n",
157									Status, ParamType));
158	}
159
160	if (Length > sizeof(Param.content))
161	{
162		PRINTF(DBG_NDIS_OIDS_VERY_LOUD, (" UtilGetParam: Buffer for parameter 0x%X is bigger then Param size\n", ParamType));
163		NdisMoveMemory(pData, &Param.content, sizeof(Param.content));
164	} else
165	{
166		NdisMoveMemory(pData, &Param.content, Length);
167	}
168
169	return Status;
170}
171
172/*-----------------------------------------------------------------------------
173Routine Name: UtilSetGetParam
174Routine Description:
175Arguments:
176Return Value:
177-----------------------------------------------------------------------------*/
178TI_STATUS
179UtilSetGetParam(
180			   PTIWLN_ADAPTER_T pAdapter,
181			   externalParam_e ParamType,
182			   PUCHAR pData,
183			   ULONG Length
184			   )
185{
186	paramInfo_t Param;
187	TI_STATUS Status;
188
189	Param.paramType = ParamType;
190	if (Length > sizeof(Param.content))
191	{
192		PRINTF(DBG_NDIS_OIDS_VERY_LOUD, (" UtilSetParam: Buffer for parameter 0x%X is bigger(%d) then Param size(%d)\n", ParamType, (int)Length, sizeof(Param.content)));
193		Param.paramLength = sizeof(Param.content);
194		NdisMoveMemory(&Param.content, pData, sizeof(Param.content));
195	} else
196	{
197		Param.paramLength = Length;
198		NdisMoveMemory(&Param.content, pData, Length);
199	}
200
201	Status = configMgr_setParam(pAdapter->CoreHalCtx, &Param);
202
203	if (Length > sizeof(Param.content))
204	{
205		PRINTF(DBG_NDIS_OIDS_VERY_LOUD, (" UtilGetParam: Buffer for parameter 0x%X is bigger then Param size\n", ParamType));
206		NdisMoveMemory(pData, &Param.content, sizeof(Param.content));
207	} else
208	{
209		NdisMoveMemory(pData, &Param.content, Length);
210	}
211
212	return Status;
213}
214
215/*-----------------------------------------------------------------------------
216Routine Name: UtilGetTxPowerValue
217Routine Description:
218Arguments:
219Return Value:
220-----------------------------------------------------------------------------*/
221ULONG
222UtilGetTxPowerValue(
223				   PTIWLN_ADAPTER_T pAdapter,
224				   externalParam_e ParamType,
225				   PUCHAR pData,
226				   ULONG Length
227				   )
228{
229	paramInfo_t Param;
230	TI_STATUS Status;
231
232	Param.paramType = ParamType;
233	Param.paramLength = Length;
234	Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
235
236	*(PULONG)pData = (ULONG)Param.content.regulatoryDomainParam.txPower;
237
238	return Status;
239}
240
241
242/*-----------------------------------------------------------------------------
243Routine Name:	UtilSetTxPowerDbm
244Routine Description:
245Arguments:
246Return Value:
247-----------------------------------------------------------------------------*/
248ULONG UtilSetTxPowerDbm(PTIWLN_ADAPTER_T pAdapter,
249						  PUCHAR pData,
250						  ULONG Length)
251{
252	ULONG retValue;
253
254	retValue = UtilSetParam(pAdapter, REGULATORY_DOMAIN_CURRENT_TX_POWER_IN_DBM_PARAM, pData, sizeof(UINT8));
255
256	return retValue;
257}
258
259
260/*-----------------------------------------------------------------------------
261Routine Name:	UtilGetTxPowerLevel
262Routine Description:
263Arguments:
264Return Value:
265-----------------------------------------------------------------------------*/
266ULONG UtilGetTxPowerLevel(PTIWLN_ADAPTER_T pAdapter,
267						  PUCHAR pData,
268						  PULONG Length)
269{
270	ULONG retValue;
271
272	retValue = UtilGetParam(pAdapter, REGULATORY_DOMAIN_TX_POWER_LEVEL_TABLE_PARAM, pData, sizeof(TIWLAN_POWER_LEVEL_TABLE));
273	*Length=sizeof(TIWLAN_POWER_LEVEL_TABLE);
274
275	return retValue;
276}
277
278
279
280/*-----------------------------------------------------------------------------
281Routine Name:	UtilEnableDisableRxDataFilters
282Routine Description:
283Arguments:
284Return Value:
285-----------------------------------------------------------------------------*/
286ULONG UtilEnableDisableRxDataFilters(PTIWLN_ADAPTER_T pAdapter,
287                                     PUCHAR pData,
288                                     ULONG Length)
289{
290    ULONG retValue;
291
292    retValue = UtilSetParam(pAdapter, RX_DATA_ENABLE_DISABLE_RX_DATA_FILTERS, pData, Length);
293
294    return retValue;
295}
296
297
298
299/*-----------------------------------------------------------------------------
300Routine Name:	UtilGetRxDataFiltersStatisticsCB
301
302Routine Description: This is the CB triggered when Rx Data Filter statistics
303					 are returned by the FW.
304Arguments:
305
306Return Value:
307-----------------------------------------------------------------------------*/
308static VOID UtilGetRxDataFiltersStatisticsCB(TI_HANDLE hAdapter, TI_STATUS status, PUINT8 pReadBuff)
309{
310	PTIWLN_ADAPTER_T pAdapter = (PTIWLN_ADAPTER_T) hAdapter;
311    ACXDataFilteringStatistics_t * pStatistics = (ACXDataFilteringStatistics_t *) pReadBuff;
312    TIWLAN_DATA_FILTER_STATISTICS * pResult = (TIWLAN_DATA_FILTER_STATISTICS *) &(pAdapter->pIoBuffer[0]);
313    int i;
314
315    pResult->UnmatchedPacketsCount = pStatistics->unmatchedPacketsCount;
316
317    for (i = 0; i < MAX_DATA_FILTERS; ++i)
318    {
319        pResult->MatchedPacketsCount[i] = pStatistics->matchedPacketsCount[i];
320    }
321
322    *(pAdapter->pIoCompleteBuffSize) = sizeof(TIWLAN_DATA_FILTER_STATISTICS);
323
324    /* indicate that the buffer is ready */
325	os_IoctlComplete(pAdapter, status);
326}
327
328
329/*-----------------------------------------------------------------------------
330Routine Name:	UtilEnableDisableRxDataFilters
331Routine Description:
332Arguments:
333Return Value:
334-----------------------------------------------------------------------------*/
335ULONG UtilGetRxDataFiltersStatistics(PTIWLN_ADAPTER_T pAdapter,
336                                     PUCHAR pData,
337                                     PULONG Length)
338{
339    paramInfo_t Param;
340
341    memset(&(pAdapter->IoCompleteBuff[0]) , 0xFF , MAX_IO_BUFFER_COMPLETE_SIZE);
342
343    pAdapter->pIoBuffer = pData;
344    pAdapter->pIoCompleteBuffSize = Length;
345
346    Param.paramType = RX_DATA_GET_RX_DATA_FILTERS_STATISTICS;
347    Param.paramLength = sizeof(TIWLAN_DATA_FILTER_STATISTICS);
348    Param.content.interogateCmdCBParams.CB_handle = (TI_HANDLE) pAdapter;
349    Param.content.interogateCmdCBParams.CB_Func = (PVOID) UtilGetRxDataFiltersStatisticsCB;
350    Param.content.interogateCmdCBParams.CB_buf = &(pAdapter->IoCompleteBuff[0]) ;
351
352    return configMgr_getParam(pAdapter->CoreHalCtx, &Param);
353}
354
355
356/*-----------------------------------------------------------------------------
357Routine Name:	UtilGetPowerConsumptionStatisticsCB
358
359Routine Description: This is the CB triggered when Power consumption statistics
360					 are returned by the FW.
361Arguments:
362
363Return Value:
364-----------------------------------------------------------------------------*/
365static VOID UtilGetPowerConsumptionStatisticsCB(TI_HANDLE hAdapter, TI_STATUS status, PUINT8 pReadBuff)
366{
367	PTIWLN_ADAPTER_T pAdapter = (PTIWLN_ADAPTER_T) hAdapter;
368    ACXPowerConsumptionTimeStat_t * pStatistics = (ACXPowerConsumptionTimeStat_t *) pReadBuff;
369    PowerConsumptionTimeStat_t * pResult = (PowerConsumptionTimeStat_t *) &(pAdapter->pIoBuffer[0]);
370
371    pResult->activeTimeCnt_Hi = pStatistics->activeTimeCnt_Hi;
372    pResult->activeTimeCnt_Low = pStatistics->activeTimeCnt_Low;
373    pResult->elpTimeCnt_Hi = pStatistics->elpTimeCnt_Hi;
374    pResult->elpTimeCnt_Low = pStatistics->elpTimeCnt_Low;
375    pResult->powerDownTimeCnt_Hi = pStatistics->powerDownTimeCnt_Hi;
376    pResult->powerDownTimeCnt_Low = pStatistics->powerDownTimeCnt_Low;
377
378    *(pAdapter->pIoCompleteBuffSize) = sizeof(PowerConsumptionTimeStat_t);
379
380    /* indicate that the buffer is ready */
381	os_IoctlComplete(pAdapter, status);
382}
383
384
385/*-----------------------------------------------------------------------------
386Routine Name:	UtilGetPowerConsumptionStatistics
387Routine Description: Request the power consumption statistics from the FW
388Arguments:
389Return Value:
390-----------------------------------------------------------------------------*/
391ULONG UtilGetPowerConsumptionStatistics(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length)
392{
393    paramInfo_t Param;
394
395    memset(&(pAdapter->IoCompleteBuff[0]) , 0xFF , MAX_IO_BUFFER_COMPLETE_SIZE);
396
397    pAdapter->pIoBuffer = pData;
398    pAdapter->pIoCompleteBuffSize = Length;
399
400    Param.paramType = HAL_CTRL_POWER_CONSUMPTION;
401    Param.paramLength = sizeof(PowerConsumptionTimeStat_t);
402    Param.content.interogateCmdCBParams.CB_handle = (TI_HANDLE) pAdapter;
403    Param.content.interogateCmdCBParams.CB_Func = (PVOID) UtilGetPowerConsumptionStatisticsCB;
404    Param.content.interogateCmdCBParams.CB_buf = &(pAdapter->IoCompleteBuff[0]);
405
406    return configMgr_getParam(pAdapter->CoreHalCtx, &Param);
407}
408
409
410/*-----------------------------------------------------------------------------
411Routine Name:	UtilAddRxDataFilter
412Routine Description:
413Arguments:
414Return Value:
415-----------------------------------------------------------------------------*/
416ULONG UtilAddRxDataFilter(PTIWLN_ADAPTER_T pAdapter,
417                          PUCHAR pData,
418                          ULONG Length)
419{
420    ULONG retValue;
421
422    retValue = UtilSetParam(pAdapter, RX_DATA_ADD_RX_DATA_FILTER, pData, Length);
423
424    return retValue;
425}
426
427
428
429/*-----------------------------------------------------------------------------
430Routine Name:	UtilRemoveRxDataFilter
431Routine Description:
432Arguments:
433Return Value:
434-----------------------------------------------------------------------------*/
435ULONG UtilRemoveRxDataFilter(PTIWLN_ADAPTER_T pAdapter,
436                             PUCHAR pData,
437                             ULONG Length)
438{
439    ULONG retValue;
440
441    retValue = UtilSetParam(pAdapter, RX_DATA_REMOVE_RX_DATA_FILTER, pData, Length);
442
443    return retValue;
444}
445
446
447
448/*-----------------------------------------------------------------------------
449Routine Name:	UtilGetCurrentRssiLevel
450Routine Description:
451Arguments:
452Return Value:
453-----------------------------------------------------------------------------*/
454ULONG UtilGetCurrentRssiLevel(PTIWLN_ADAPTER_T pAdapter,
455							  PUCHAR pData,
456							  PULONG Length)
457{
458	ULONG retValue;
459	retValue = UtilGetParam(pAdapter, SITE_MGR_CURRENT_SIGNAL_PARAM, pData, sizeof(INT32));
460	*Length = sizeof(INT32);
461	return retValue;
462}
463
464
465/*-----------------------------------------------------------------------------
466Routine Name:	RssiUtilIoctlCompleteCB
467
468Routine Description: This is the CB triggered when  Rssi/Snr have been
469					returned by FW - return RSSI only to user
470Arguments:
471
472Return Value:
473-----------------------------------------------------------------------------*/
474VOID RssiUtilIoctlCompleteCB(TI_HANDLE hAdapter, TI_STATUS status, PUINT8 pReadBuff)
475{
476	PTIWLN_ADAPTER_T pAdapter = (PTIWLN_ADAPTER_T)hAdapter;
477	TIWLN_RADIO_RX_QUALITY tmpRadioRxQuality;
478	paramInfo_t Param;
479	ACXRoamingStatisticsTable_t * radioResults = (ACXRoamingStatisticsTable_t *) pReadBuff;
480
481	tmpRadioRxQuality.Rssi = radioResults->rssi;
482	tmpRadioRxQuality.Snr = (INT32) radioResults->snr;
483
484	/* here we update the site manager about these new values */
485	Param.paramType = SITE_MGR_CURRENT_SIGNAL_PARAM;
486	Param.paramLength = sizeof(INT32);
487	Param.content.siteMgrCurrentRssi = tmpRadioRxQuality.Rssi;
488	configMgr_setParam(pAdapter->CoreHalCtx, &Param);
489
490
491	*(pAdapter->pIoCompleteBuffSize) = sizeof(INT32);
492	os_memoryCopy(hAdapter, (PVOID) &(pAdapter->pIoBuffer[0]), (PVOID) &(tmpRadioRxQuality.Rssi), sizeof(INT32));
493
494	/* Call back the Completion that will indicate to the user that the buffer is ready to be read */
495	os_IoctlComplete(pAdapter, status);
496}
497
498/*-----------------------------------------------------------------------------
499Routine Name:	SnrUtilIoctlCompleteCB
500
501Routine Description: This is the CB triggered when  Rssi/Snr have been
502					returned by FW - return SNR only to user
503Arguments:
504
505Return Value:
506-----------------------------------------------------------------------------*/
507VOID SnrUtilIoctlCompleteCB(TI_HANDLE hAdapter, TI_STATUS status, PUINT8 pReadBuff)
508{
509	PTIWLN_ADAPTER_T pAdapter = (PTIWLN_ADAPTER_T) hAdapter;
510	TIWLN_RADIO_RX_QUALITY tmpRadioRxQuality;
511	ACXRoamingStatisticsTable_t * radioResults = (ACXRoamingStatisticsTable_t *) pReadBuff;
512
513    tmpRadioRxQuality.Rssi = radioResults->rssi;
514	/* The SNR returned by FW is not true. We have to divide it by 2 and turns it to a signed */
515	tmpRadioRxQuality.Snr = (INT32) radioResults->snr;
516
517	*(pAdapter->pIoCompleteBuffSize) = sizeof(INT32);
518
519	os_memoryCopy(hAdapter, (PVOID) &(pAdapter->pIoBuffer[0]), (PVOID) &(tmpRadioRxQuality.Snr), sizeof(INT32));
520
521	os_IoctlComplete(pAdapter, status);
522}
523
524
525/*-----------------------------------------------------------------------------
526Routine Name:	UtilGetAsyncCurrentRssiLevel
527Routine Description:
528Arguments:
529Return Value:
530-----------------------------------------------------------------------------*/
531ULONG UtilGetAsyncCurrentRssiLevel(PTIWLN_ADAPTER_T pAdapter,
532								   PUCHAR pData,
533								   PULONG Length)
534{
535	paramInfo_t Param;
536
537
538	TI_STATUS Status;
539
540	memset(&(pAdapter->IoCompleteBuff[0]) , 0xFF , MAX_IO_BUFFER_COMPLETE_SIZE );
541
542	/* To implement the Async IOCTL store the user buffer pointer to be filled at
543	the Command Completion calback */
544	pAdapter->pIoBuffer =  pData;
545	pAdapter->pIoCompleteBuffSize =  Length ;
546
547	/* Fill the IOCTL struct to the Command Mailbox by giving a stack parameter */
548	Param.paramType = HAL_CTRL_RSSI_LEVEL_PARAM;
549	Param.paramLength = sizeof(INT32);
550	Param.content.interogateCmdCBParams.CB_handle  =  (TI_HANDLE)pAdapter;
551	Param.content.interogateCmdCBParams.CB_Func    =  (PVOID)RssiUtilIoctlCompleteCB;
552	Param.content.interogateCmdCBParams.CB_buf     =  &(pAdapter->IoCompleteBuff[0]) ;
553
554	/* This Get Param will in fact get till the HAL and will interrogate the FW */
555	Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
556
557	return Status;
558}
559
560
561/*-----------------------------------------------------------------------------
562Routine Name:	UtilGetAsyncCurrentRssiLevel
563Routine Description:
564Arguments:
565Return Value:
566-----------------------------------------------------------------------------*/
567ULONG UtilGetAsyncCurrentSnrRatio(PTIWLN_ADAPTER_T pAdapter,
568								  PUCHAR pData,
569								  PULONG Length)
570{
571	paramInfo_t Param;
572
573
574	TI_STATUS Status;
575
576	memset(&(pAdapter->IoCompleteBuff[0]) , 0xFF , MAX_IO_BUFFER_COMPLETE_SIZE );
577
578	pAdapter->pIoBuffer =  pData;
579	pAdapter->pIoCompleteBuffSize =  Length ;
580
581	Param.paramType = HAL_CTRL_SNR_RATIO_PARAM;
582	Param.paramLength = sizeof(INT32);
583	Param.content.interogateCmdCBParams.CB_handle  =  (TI_HANDLE)pAdapter;
584	Param.content.interogateCmdCBParams.CB_Func    =  (PVOID)SnrUtilIoctlCompleteCB;
585	Param.content.interogateCmdCBParams.CB_buf     =  &(pAdapter->IoCompleteBuff[0]) ;
586
587	Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
588
589	return Status;
590
591
592}
593
594
595/*-----------------------------------------------------------------------------
596Routine Name: UtilGetAPTxPowerLevel
597Routine Description:
598Arguments:
599Return Value:
600-----------------------------------------------------------------------------*/
601ULONG
602UtilGetAPTxPowerLevel(
603					 PTIWLN_ADAPTER_T pAdapter,
604					 externalParam_e ParamType,
605					 PUCHAR pData,
606					 ULONG Length
607					 )
608{
609	paramInfo_t Param;
610	TI_STATUS Status;
611
612	Param.paramType = ParamType;
613	Param.paramLength = Length;
614	Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
615
616	*(PULONG)pData = (ULONG)Param.content.APTxPower;
617
618	return Status;
619}
620
621
622/*-----------------------------------------------------------------------------
623Routine Name: UtilGetCountryCode
624Routine Description:
625Arguments:
626Return Value:
627-----------------------------------------------------------------------------*/
628ULONG
629UtilGetCountryCode(
630				  PTIWLN_ADAPTER_T pAdapter,
631				  externalParam_e ParamType,
632				  PUCHAR pData,
633				  ULONG Length
634				  )
635{
636	paramInfo_t Param;
637	TI_STATUS Status;
638
639	Param.paramType = ParamType;
640	Param.paramLength = Length;
641	Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
642
643	NdisMoveMemory(pData, Param.content.pCountryString, Length);
644
645	return Status;
646}
647
648
649
650/*-----------------------------------------------------------------------------
651Routine Name: UtilGetRegDomainBand
652Routine Description:
653Arguments:
654Return Value:
655-----------------------------------------------------------------------------*/
656ULONG
657UtilGetRegDomainBand(
658					PTIWLN_ADAPTER_T pAdapter,
659					externalParam_e ParamType,
660					PUCHAR pData,
661					ULONG Length
662					)
663{
664	paramInfo_t Param;
665	TI_STATUS Status;
666
667	Param.paramType = ParamType;
668	Param.paramLength = Length;
669
670	Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
671
672	*(PULONG)pData = (ULONG) *(PUCHAR)&Param.content;
673
674	return Status;
675}
676
677
678/*-----------------------------------------------------------------------------
679Routine Name: UtilGetPacketBursting
680Routine Description:
681Arguments:
682Return Value:
683-----------------------------------------------------------------------------*/
684ULONG
685UtilGetPacketBursting(
686					 PTIWLN_ADAPTER_T pAdapter,
687					 externalParam_e ParamType,
688					 PUCHAR pData,
689					 ULONG Length
690					 )
691{
692	paramInfo_t Param;
693	TI_STATUS Status;
694
695	Param.paramType = ParamType;
696	Param.paramLength = Length;
697
698	Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
699
700	*(PULONG)pData = (ULONG)Param.content.qosPacketBurstEnb;
701	return Status;
702}
703
704
705/*-----------------------------------------------------------------------------
706Routine Name: UtilGetMixedMode
707Routine Description:
708Arguments:
709Return Value:
710-----------------------------------------------------------------------------*/
711ULONG
712UtilGetMixedMode(
713				PTIWLN_ADAPTER_T pAdapter,
714				externalParam_e ParamType,
715				PUCHAR pData,
716				PULONG Length
717				)
718{
719	paramInfo_t Param;
720	TI_STATUS Status;
721
722	Param.paramType = ParamType;
723
724	Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
725
726	*(PULONG)pData = (ULONG)Param.content.rsnMixedMode;
727	return Status;
728}
729
730/*-----------------------------------------------------------------------------
731Routine Name: UtilGetDefaultKeyId
732Routine Description:
733Arguments:
734Return Value:
735-----------------------------------------------------------------------------*/
736ULONG
737UtilGetDefaultKeyId(
738				   PTIWLN_ADAPTER_T pAdapter,
739				   externalParam_e ParamType,
740				   PUCHAR pData,
741				   PULONG Length
742				   )
743{
744	paramInfo_t Param;
745	TI_STATUS Status;
746
747	Param.paramType = ParamType;
748
749	Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
750
751	*(PULONG)pData = (ULONG)Param.content.rsnDefaultKeyID;
752	return Status;
753}
754
755
756/*-----------------------------------------------------------------------------
757Routine Name: UtilSetTrafficIntensityThresholds
758Routine Description: Sets the traffic intensity thresholds
759Arguments:
760Return Value:
761-----------------------------------------------------------------------------*/
762ULONG UtilSetTrafficIntensityThresholds(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length)
763{
764	ULONG retValue;
765	retValue = UtilSetParam(pAdapter,CTRL_DATA_TRAFFIC_INTENSITY_THRESHOLD , pData, Length);
766	return retValue;
767}
768
769
770/*-----------------------------------------------------------------------------
771Routine Name: UtilGetTrafficIntensityThresholds
772Routine Description: retrieves the traffic intensity thresholds
773Arguments:
774Return Value:
775-----------------------------------------------------------------------------*/
776ULONG UtilGetTrafficIntensityThresholds(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length)
777{
778	ULONG retValue;
779	retValue = UtilGetParam(pAdapter, CTRL_DATA_TRAFFIC_INTENSITY_THRESHOLD, pData, (*Length));
780	*Length = sizeof(OS_802_11_TRAFFIC_INTENSITY_THRESHOLD_PARAMS);
781	return retValue;
782}
783
784
785/*-----------------------------------------------------------------------------
786Routine Name: UtilToggleTrafficIntensityEvents
787Routine Description: Toggles ON/OFF traffic intensity events
788Arguments:
789Return Value:
790-----------------------------------------------------------------------------*/
791ULONG UtilToggleTrafficIntensityEvents(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length)
792{
793	ULONG retValue;
794	retValue = UtilSetParam(pAdapter,CTRL_DATA_TOGGLE_TRAFFIC_INTENSITY_EVENTS , pData, Length);
795	return retValue;
796}
797
798
799
800
801/*-----------------------------------------------------------------------------
802Routine Name:
803
804	UtilSetBSSID
805Routine Description:
806Arguments:
807Return Value:
808-----------------------------------------------------------------------------*/
809ULONG
810UtilSetBSSID(
811			PTIWLN_ADAPTER_T pAdapter,
812			PUCHAR pData,
813			ULONG Length
814			)
815{
816	return UtilSetParam(pAdapter, SITE_MGR_DESIRED_BSSID_PARAM, pData, ETH_ADDR_SIZE);
817}
818
819/*-----------------------------------------------------------------------------
820Routine Name: UtilGetBSSID
821Routine Description:
822Arguments:
823Return Value:
824-----------------------------------------------------------------------------*/
825ULONG
826UtilGetBSSID(
827			PTIWLN_ADAPTER_T pAdapter,
828			PUCHAR pData,
829			PULONG Length
830			)
831{
832	TI_STATUS res;
833
834	if (!Length)
835		return NOK;
836
837	res = UtilGetParam(pAdapter, CTRL_DATA_CURRENT_BSSID_PARAM, pData, ETH_ADDR_SIZE);
838
839	*Length = ETH_ADDR_SIZE;
840
841	return res;
842}
843
844
845/*-----------------------------------------------------------------------------
846Routine Name: UtilGetSSID
847Routine Description:
848Arguments:
849Return Value:
850-----------------------------------------------------------------------------*/
851ULONG
852UtilGetSSID(
853		   PTIWLN_ADAPTER_T pAdapter,
854		   PUCHAR pData,
855		   PULONG Length
856		   )
857{
858	ULONG size;
859	ssid_t ssid;
860	OS_802_11_SSID* RetSsid;
861
862	if (*Length<sizeof(OS_802_11_SSID))
863		return NOK;
864
865	size = sizeof(ssid_t);
866	UtilGetParam(pAdapter, SITE_MGR_CURRENT_SSID_PARAM, (PUCHAR)&ssid, size);
867
868	RetSsid = (OS_802_11_SSID*) pData;
869
870	RetSsid->SsidLength = ssid.len;
871	NdisMoveMemory((void *)RetSsid->Ssid, (void *)ssid.ssidString, ssid.len);
872
873	*Length = sizeof(OS_802_11_SSID);
874
875	return OK;
876}
877
878
879/*-----------------------------------------------------------------------------
880Routine Name: UtilGetDesiredSSID
881Routine Description:
882Arguments:
883Return Value:
884-----------------------------------------------------------------------------*/
885ULONG
886UtilGetDesiredSSID(
887				  PTIWLN_ADAPTER_T pAdapter,
888				  PUCHAR pData,
889				  PULONG Length
890				  )
891{
892	ULONG size,retValue;
893	ssid_t ssid;
894	OS_802_11_SSID* RetSsid;
895
896	if (!(*Length))
897	{
898		*Length = sizeof(OS_802_11_SSID);
899		return NOK;
900	}
901
902	size = sizeof(ssid_t);
903	retValue = UtilGetParam(pAdapter, SITE_MGR_DESIRED_SSID_PARAM, (PUCHAR)&ssid, size);
904
905	RetSsid = (OS_802_11_SSID*) pData;
906
907	RetSsid->SsidLength = ssid.len;
908	NdisMoveMemory((void *)RetSsid->Ssid, (void *)ssid.ssidString, ssid.len);
909
910	*Length = sizeof(OS_802_11_SSID);
911	return retValue;
912}
913
914
915/*-----------------------------------------------------------------------------
916Routine Name: UtilSetSSID
917Routine Description:
918Arguments:
919Return Value:
920-----------------------------------------------------------------------------*/
921ULONG
922UtilSetSSID(
923		   PTIWLN_ADAPTER_T pAdapter,
924		   PUCHAR pData,
925		   ULONG Length
926		   )
927{
928	OS_802_11_SSID* UtilSsid;
929	ssid_t ssid;
930
931	UtilSsid = (OS_802_11_SSID*) pData;
932
933	if (UtilSsid->SsidLength<=MAX_SSID_LEN)
934	{
935		ssid.len = (UINT8)UtilSsid->SsidLength;
936
937		NdisMoveMemory((void *)ssid.ssidString, (void *)UtilSsid->Ssid, ssid.len);
938
939		/* The driver should support setting the SSID to NULL string */
940		if (ssid.len == 0)
941			ssid.ssidString[0] = '\0';
942
943#ifdef TI_DBG
944		{
945			UCHAR   tempName[33];
946
947			NdisMoveMemory(tempName, (void *)UtilSsid->Ssid, ssid.len);
948			tempName[ssid.len] ='\0';
949
950			PRINTF(DBG_NDIS_OIDS_LOUD, ("  SET SSID: Len=%d %s\n", ssid.len, tempName));
951		}
952#endif
953
954		UtilSetParam(pAdapter, SITE_MGR_DESIRED_SSID_PARAM, (PUCHAR)&ssid, sizeof(ssid_t));
955	}
956
957	return OK;
958
959}
960
961
962/*-----------------------------------------------------------------------------
963Routine Name: UtilNetworkTypesSupported
964Routine Description:
965Arguments:
966Return Value:
967-----------------------------------------------------------------------------*/
968ULONG
969UtilNetworkTypesSupported(
970						 PTIWLN_ADAPTER_T pAdapter,
971						 PUCHAR pData,
972						 PULONG Length
973						 )
974{
975	OS_802_11_NETWORK_TYPE_LIST * pList;
976	ULONG mode, size;
977
978	UtilGetParam(pAdapter, SITE_MGR_DESIRED_DOT11_MODE_PARAM,
979							(PUCHAR)&mode, sizeof(ULONG));
980
981	if (!(*Length))
982	{
983
984		/**/
985		/* Return the maximum size*/
986		/**/
987		size = sizeof(OS_802_11_NETWORK_TYPE_LIST) +
988			   3 * sizeof(OS_802_11_NETWORK_TYPE) -
989			   sizeof(OS_802_11_NETWORK_TYPE);
990
991		*Length = size;
992		return NOK;
993
994	}
995
996	pList = (OS_802_11_NETWORK_TYPE_LIST *) pData;
997
998	switch (mode)
999	{
1000
1001	case 1:
1002		pList->NumberOfItems = 1;
1003		pList->NetworkType[0] = os802_11DS;
1004		break;
1005
1006	case 2:
1007		pList->NumberOfItems = 1;
1008		pList->NetworkType[0] = os802_11OFDM5;
1009		break;
1010
1011	case 3:
1012		pList->NumberOfItems = 2;
1013		pList->NetworkType[0] = os802_11DS;
1014		pList->NetworkType[1] = os802_11OFDM24;
1015		break;
1016
1017	case 4:
1018		pList->NumberOfItems = 3;
1019		pList->NetworkType[0] = os802_11DS;
1020		pList->NetworkType[1] = os802_11OFDM24;
1021		pList->NetworkType[2] = os802_11OFDM5;
1022		break;
1023
1024	default:
1025		pList->NumberOfItems = 1;
1026		pList->NetworkType[0] = os802_11DS;
1027		break;
1028	}
1029
1030	size = sizeof(OS_802_11_NETWORK_TYPE_LIST) +
1031		   pList->NumberOfItems * sizeof(OS_802_11_NETWORK_TYPE) -
1032		   sizeof(OS_802_11_NETWORK_TYPE);
1033
1034	*Length = size;
1035	return OK;
1036}
1037
1038
1039/*-----------------------------------------------------------------------------
1040Routine Name: UtilNetworkTypeInUseGet
1041Routine Description:
1042Arguments:
1043Return Value:
1044-----------------------------------------------------------------------------*/
1045ULONG
1046UtilNetworkTypeInUseGet(
1047					   PTIWLN_ADAPTER_T pAdapter,
1048					   PUCHAR pData,
1049					   PULONG Length
1050					   )
1051{
1052	ULONG mode;
1053	if (!(*Length))
1054	{
1055
1056		*Length = sizeof(OS_802_11_NETWORK_TYPE);
1057		return NOK;
1058
1059	}
1060
1061	UtilGetParam(pAdapter, SITE_MGR_DESIRED_DOT11_MODE_PARAM,
1062				 (PUCHAR)&mode, sizeof(ULONG));
1063
1064	switch (mode)
1065	{
1066
1067	case 1:
1068		*((OS_802_11_NETWORK_TYPE *) pData) = os802_11DS;
1069		break;
1070
1071	case 2:
1072		*((OS_802_11_NETWORK_TYPE *) pData) = os802_11OFDM5;
1073		break;
1074
1075	case 3:
1076		*((OS_802_11_NETWORK_TYPE *) pData) = os802_11OFDM24;
1077		break;
1078
1079	case 4:
1080		*((OS_802_11_NETWORK_TYPE *) pData) = os802_11Automode;
1081		break;
1082
1083	default:
1084		*((OS_802_11_NETWORK_TYPE *) pData) = os802_11DS;
1085		break;
1086
1087	}
1088
1089	*Length = sizeof(OS_802_11_NETWORK_TYPE);
1090	return OK;
1091}
1092
1093
1094/*-----------------------------------------------------------------------------
1095Routine Name: UtilNetworkTypeInUseSet
1096Routine Description:
1097Arguments:
1098Return Value:
1099-----------------------------------------------------------------------------*/
1100ULONG
1101UtilNetworkTypeInUseSet(
1102					   PTIWLN_ADAPTER_T pAdapter,
1103					   PUCHAR pData,
1104					   ULONG Length
1105					   )
1106{
1107	ULONG retValue;
1108	retValue = UtilSetParam(pAdapter, SITE_MGR_DESIRED_DOT11_MODE_PARAM, pData, sizeof(ULONG));
1109	return retValue;
1110}
1111
1112
1113/*-----------------------------------------------------------------------------
1114Routine Name: UtilSetPacketBursting
1115Routine Description:
1116Arguments:
1117Return Value:
1118-----------------------------------------------------------------------------*/
1119ULONG
1120UtilSetPacketBursting(
1121					 PTIWLN_ADAPTER_T pAdapter,
1122					 PUCHAR pData,
1123					 ULONG Length
1124					 )
1125{
1126	paramInfo_t Param;
1127	TI_STATUS Status;
1128
1129	Param.paramType = QOS_PACKET_BURST_ENABLE;
1130	Param.content.qosPacketBurstEnb = *((UINT8*)pData);
1131	Status = configMgr_setParam(pAdapter->CoreHalCtx, &Param);
1132	return Status;
1133}
1134
1135
1136/*-----------------------------------------------------------------------------
1137Routine Name: UtilSetMixedMode
1138Routine Description:
1139Arguments:
1140Return Value:
1141-----------------------------------------------------------------------------*/
1142ULONG
1143UtilSetMixedMode(
1144				PTIWLN_ADAPTER_T pAdapter,
1145				PUCHAR pData,
1146				ULONG Length
1147				)
1148{
1149	paramInfo_t Param;
1150	TI_STATUS Status;
1151
1152	Param.paramType = RSN_MIXED_MODE;
1153	Param.content.rsnMixedMode = *((UINT32*)pData);
1154	Status = configMgr_setParam(pAdapter->CoreHalCtx, &Param);
1155
1156	return Status;
1157}
1158
1159
1160/*-----------------------------------------------------------------------------
1161Routine Name: UtilPowerModeSet
1162Routine Description:
1163Arguments:
1164Return Value:
1165-----------------------------------------------------------------------------*/
1166ULONG
1167UtilPowerModeSet(
1168				PTIWLN_ADAPTER_T pAdapter,
1169				PUCHAR pData,
1170				ULONG Length
1171				)
1172{
1173	ULONG retValue;
1174	PowerMgr_PowerMode_t PowerMgr_PowerMode;
1175	PowerMgr_PowerMode.PowerMode = (PowerMgr_PowerMode_e)*pData;
1176	PowerMgr_PowerMode.powerMngPriority = POWER_MANAGER_USER_PRIORITY;
1177	retValue = UtilSetParam(pAdapter, POWER_MGR_POWER_MODE,(PUCHAR)&PowerMgr_PowerMode, sizeof(PowerMgr_PowerMode));
1178	return retValue;
1179}
1180
1181
1182/*-----------------------------------------------------------------------------
1183Routine Name: UtilPowerModeGet
1184Routine Description:
1185Arguments:
1186Return Value:
1187-----------------------------------------------------------------------------*/
1188ULONG
1189UtilPowerModeGet(
1190				PTIWLN_ADAPTER_T pAdapter,
1191				PUCHAR pData,
1192				PULONG Length
1193				)
1194{
1195	ULONG retValue;
1196	retValue = UtilGetParam(pAdapter, POWER_MGR_POWER_MODE, pData, sizeof(PowerMgr_PowerMode_e));
1197	*Length = sizeof(PowerMgr_PowerMode_e);
1198	return retValue;
1199}
1200
1201
1202
1203/*-----------------------------------------------------------------------------
1204Routine Name: UtilPowerLevelPSGet
1205Routine Description:
1206Arguments:
1207Return Value:
1208-----------------------------------------------------------------------------*/
1209ULONG
1210UtilPowerLevelPSGet(
1211				   PTIWLN_ADAPTER_T pAdapter,
1212				   PUCHAR pData,
1213				   PULONG Length
1214				   )
1215{
1216	ULONG retValue;
1217	retValue = UtilGetParam(pAdapter, POWER_MGR_POWER_LEVEL_PS, pData, sizeof(powerAutho_PowerPolicy_e));
1218	*Length = sizeof(powerAutho_PowerPolicy_e);
1219	return retValue;
1220}
1221
1222/*-----------------------------------------------------------------------------
1223Routine Name: UtilPowerLevelPSSet
1224Routine Description:
1225Arguments:
1226Return Value:
1227-----------------------------------------------------------------------------*/
1228ULONG
1229UtilPowerLevelPSSet(
1230				   PTIWLN_ADAPTER_T pAdapter,
1231				   PUCHAR pData,
1232				   PULONG Length
1233				   )
1234{
1235	ULONG retValue;
1236	retValue = UtilSetParam(pAdapter, POWER_MGR_POWER_LEVEL_PS, pData, sizeof(powerAutho_PowerPolicy_e));
1237	*Length = sizeof(powerAutho_PowerPolicy_e);
1238	return retValue;
1239}
1240
1241/*-----------------------------------------------------------------------------
1242Routine Name: UtilPowerLevelDefaultGet
1243Routine Description:
1244Arguments:
1245Return Value:
1246-----------------------------------------------------------------------------*/
1247ULONG
1248UtilPowerLevelDefaultGet(
1249						PTIWLN_ADAPTER_T pAdapter,
1250						PUCHAR pData,
1251						PULONG Length
1252						)
1253{
1254	ULONG retValue;
1255	retValue = UtilGetParam(pAdapter, POWER_MGR_POWER_LEVEL_DEFAULT, pData, sizeof(powerAutho_PowerPolicy_e));
1256	*Length = sizeof(powerAutho_PowerPolicy_e);
1257	return retValue;
1258}
1259
1260/*-----------------------------------------------------------------------------
1261Routine Name: UtilPowerLevelDefaultSet
1262Routine Description:
1263Arguments:
1264Return Value:
1265-----------------------------------------------------------------------------*/
1266ULONG
1267UtilPowerLevelDefaultSet(
1268						PTIWLN_ADAPTER_T pAdapter,
1269						PUCHAR pData,
1270						PULONG Length
1271						)
1272{
1273	ULONG retValue;
1274	retValue = UtilSetParam(pAdapter, POWER_MGR_POWER_LEVEL_DEFAULT, pData, sizeof(powerAutho_PowerPolicy_e));
1275	*Length = sizeof(powerAutho_PowerPolicy_e);
1276	return retValue;
1277}
1278
1279/*-----------------------------------------------------------------------------
1280Routine Name: UtilPowerLevelDozeModeGet
1281Routine Description:
1282Arguments:
1283Return Value:
1284-----------------------------------------------------------------------------*/
1285ULONG
1286UtilPowerLevelDozeModeGet(
1287    PTIWLN_ADAPTER_T pAdapter,
1288    PUCHAR pData,
1289    PULONG Length
1290    )
1291{
1292   ULONG retValue;
1293   retValue = UtilGetParam(pAdapter, POWER_MGR_POWER_LEVEL_DOZE_MODE, pData, sizeof(PowerMgr_PowerMode_e));
1294   *Length = sizeof(PowerMgr_PowerMode_e);
1295   return retValue;
1296}
1297
1298/*-----------------------------------------------------------------------------
1299Routine Name: UtilPowerLevelDozeModeSet
1300Routine Description:
1301Arguments:
1302Return Value:
1303-----------------------------------------------------------------------------*/
1304ULONG
1305UtilPowerLevelDozeModeSet(
1306    PTIWLN_ADAPTER_T pAdapter,
1307    PUCHAR pData,
1308    PULONG Length
1309    )
1310{
1311   ULONG retValue;
1312   retValue = UtilSetParam(pAdapter, POWER_MGR_POWER_LEVEL_DOZE_MODE, pData, sizeof(PowerMgr_PowerMode_e));
1313   *Length = sizeof(PowerMgr_PowerMode_e);
1314   return retValue;
1315}
1316
1317
1318/*-----------------------------------------------------------------------------
1319Routine Name: UtilBeaconFilterDesiredStateSet
1320Routine Description:
1321Arguments:
1322Return Value:
1323-----------------------------------------------------------------------------*/
1324ULONG
1325UtilBeaconFilterDesiredStateSet(
1326							   PTIWLN_ADAPTER_T pAdapter,
1327							   PUCHAR pData,
1328							   PULONG Length
1329							   )
1330{
1331	ULONG retValue;
1332
1333	retValue = UtilSetParam(pAdapter, SITE_MGR_BEACON_FILTER_DESIRED_STATE_PARAM, pData, sizeof(UINT8));
1334	*Length = sizeof(UINT8);
1335	return retValue;
1336}
1337
1338/*-----------------------------------------------------------------------------
1339Routine Name: UtilBeaconFilterDesiredStateGet
1340Routine Description: gets the current beacon filter state
1341Arguments:
1342Return Value:
1343-----------------------------------------------------------------------------*/
1344ULONG
1345UtilBeaconFilterDesiredStateGet(
1346							   PTIWLN_ADAPTER_T pAdapter,
1347							   PUCHAR pData,
1348							   PULONG Length
1349							   )
1350{
1351	ULONG retValue;
1352	retValue = UtilGetParam(pAdapter, SITE_MGR_BEACON_FILTER_DESIRED_STATE_PARAM, pData, sizeof(UINT8));
1353	*Length = sizeof(UINT8);
1354	return retValue;
1355}
1356
1357
1358/*-----------------------------------------------------------------------------
1359Routine Name: UtilBssidListGet
1360Routine Description:
1361Arguments:
1362Return Value:
1363-----------------------------------------------------------------------------*/
1364ULONG
1365UtilBssidListGet(
1366				PTIWLN_ADAPTER_T pAdapter,
1367				PUCHAR pData,
1368				PULONG Length,
1369				BOOLEAN ExtBssid,
1370				BOOLEAN allVarIes
1371				)
1372{
1373	OS_802_11_BSSID_LIST_EX* pListEx;
1374	OS_802_11_BSSID_EX* pBssidEx;
1375	OS_802_11_BSSID* pBssid;
1376	OS_802_11_BSSID_LIST* pList;
1377	paramInfo_t Param;
1378	ULONG RetSize, i;
1379	TI_STATUS Status;
1380	PUCHAR pTempData=NULL;
1381	ULONG LocalLength = sizeof(OS_802_11_BSSID_LIST_EX)+NUM_OF_SITE_TABLE*MAX_SITES_BG_BAND*sizeof(OS_802_11_BSSID);
1382
1383
1384	/******  At the callback of RSSI update the RSSI in the Site TAble in the Site Manager *
1385	 Update Site Table in order to represent the RSSI of current AP correctly in the utility
1386	param.paramType = SITE_MGR_CURRENT_SIGNAL_PARAM;
1387	param.content.siteMgrCurrentSignal.rssi = pCurrBSS->averageRssi;
1388	siteMgr_setParam(pCurrBSS->hSiteMgr, &param);
1389	***************************************/
1390
1391
1392	if (allVarIes)
1393	{
1394		Param.paramType = SITE_MGR_BSSID_FULL_LIST_PARAM;
1395	} else
1396	{
1397		Param.paramType = SITE_MGR_BSSID_LIST_PARAM;
1398	}
1399
1400	if (ExtBssid)
1401	{
1402		*(PULONG)&Param.content = (ULONG)pData;
1403		Param.paramLength = *Length;
1404	} else
1405	{
1406		if (*Length)
1407		{
1408			pTempData = os_memoryAlloc(pAdapter, LocalLength);
1409
1410			if (!pTempData)
1411			{
1412				*(PULONG)pData = LocalLength;
1413				*Length = 0;
1414				return NOK;
1415			}
1416
1417			*(PULONG)&Param.content = (ULONG)pTempData;
1418			Param.paramLength = *Length;
1419		} else
1420		{
1421			*Length = LocalLength;
1422			return NOK;
1423		}
1424	}
1425
1426	Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
1427
1428	if (!(*Length))
1429	{
1430
1431		*Length = Param.paramLength * 4;
1432		return NOK;
1433
1434	}
1435
1436	if (Status != OK)
1437	{
1438		*(PULONG)pData = Param.paramLength;
1439		PRINT(DBG_IOCTL_LOUD, "...More buffer space needed\n");
1440		if (!ExtBssid)
1441			os_memoryFree(pAdapter, pTempData, LocalLength);
1442
1443		*Length = 0;
1444		return NOK;
1445
1446	}
1447
1448	if (!ExtBssid)
1449	{
1450
1451		pListEx = (OS_802_11_BSSID_LIST_EX*) pTempData;
1452
1453		if (pListEx->NumberOfItems)
1454		{
1455
1456			if ((sizeof(OS_802_11_BSSID_LIST) +
1457				 sizeof(OS_802_11_BSSID)*pListEx->NumberOfItems -
1458				 sizeof(OS_802_11_BSSID)) > *Length)
1459			{
1460				PRINT(DBG_IOCTL_LOUD, "Utility buffer is too small\n");
1461				os_memoryFree(pAdapter, pTempData, LocalLength);
1462				*Length = 0;
1463				return NOK;
1464			}
1465            if (pListEx->NumberOfItems >
1466                ((0xFFFFFFFFUL - ((ULONG)sizeof(OS_802_11_BSSID_LIST) - 1)) /
1467                 (ULONG)sizeof(OS_802_11_BSSID) + 1)) /* Dm: Security fix */
1468            {
1469                printk("TI: %s - Security Error\n", __FUNCTION__);
1470                PRINT(DBG_IOCTL_LOUD, "Number of AP is too big\n");
1471                os_memoryFree(pAdapter, pTempData, LocalLength);
1472                *Length = 0;
1473                return NOK;
1474            }
1475
1476            pList = (OS_802_11_BSSID_LIST *)pData;
1477			pList->NumberOfItems = pListEx->NumberOfItems;
1478
1479			*Length = RetSize = sizeof(OS_802_11_BSSID_LIST) +
1480					  sizeof(OS_802_11_BSSID)*pList->NumberOfItems -
1481					  sizeof(OS_802_11_BSSID);
1482
1483			pBssidEx = pListEx->Bssid;
1484
1485			for (i=0; i<pListEx->NumberOfItems; i++)
1486			{
1487
1488				pBssid = (OS_802_11_BSSID*) pBssidEx;
1489
1490				NdisMoveMemory(&pList->Bssid[i], pBssid,
1491							   sizeof(OS_802_11_BSSID));
1492
1493				pList->Bssid[i].Length = sizeof(OS_802_11_BSSID);
1494
1495				pBssidEx = (OS_802_11_BSSID_EX*) ((PUCHAR)pBssidEx +
1496												  pBssidEx->Length);
1497
1498			}
1499
1500		}
1501
1502		else
1503		{
1504
1505			pList = (OS_802_11_BSSID_LIST*) pData;
1506			pList->NumberOfItems = 0;
1507
1508			RetSize = sizeof(OS_802_11_BSSID_LIST);
1509			*Length = RetSize;
1510
1511		}
1512
1513		PRINT(DBG_IOCTL_LOUD, "...Copy done.\n");
1514
1515		os_memoryFree(pAdapter, pTempData, LocalLength);
1516
1517	}
1518
1519	else
1520	{
1521
1522		RetSize = Param.paramLength;
1523		*Length = RetSize;
1524
1525	}
1526
1527	return OK;
1528}
1529
1530
1531/*-----------------------------------------------------------------------------
1532Routine Name: UtilStartAppScanSet
1533Routine Description:
1534Arguments:
1535Return Value:
1536-----------------------------------------------------------------------------*/
1537ULONG
1538UtilStartAppScanSet(
1539				   PTIWLN_ADAPTER_T pAdapter,
1540				   PUCHAR pData,
1541				   ULONG Length
1542				   )
1543{
1544	ULONG retValue;
1545	/* scan concentrator will start an application scan */
1546	retValue = UtilSetParam(pAdapter, SCAN_CNCN_START_APP_SCAN, (PUCHAR)&pData, sizeof(PUCHAR));
1547	return retValue;
1548}
1549
1550
1551/*-----------------------------------------------------------------------------
1552Routine Name: UtilStopAppScanSet
1553Routine Description:
1554Arguments:
1555Return Value:
1556-----------------------------------------------------------------------------*/
1557ULONG
1558UtilStopAppScanSet(
1559				  PTIWLN_ADAPTER_T pAdapter,
1560				  PUCHAR pData,
1561				  ULONG Length
1562				  )
1563{
1564	ULONG retValue;
1565	/* scan concentrator will stop the running application scan (if any) */
1566	retValue = UtilSetParam(pAdapter, SCAN_CNCN_STOP_APP_SCAN, NULL, 0);
1567	return retValue;
1568}
1569
1570
1571/*-----------------------------------------------------------------------------
1572Routine Name: UtilScanPolicyParamSet
1573Routine Description:
1574Arguments:
1575Return Value:
1576-----------------------------------------------------------------------------*/
1577ULONG
1578UtilScanPolicyParamSet(
1579					  PTIWLN_ADAPTER_T pAdapter,
1580					  PUCHAR pData,
1581					  ULONG Length
1582					  )
1583{
1584	ULONG retValue;
1585
1586	applicationConfigBuffer_t applicationConfigBuffer;
1587
1588	applicationConfigBuffer.buffer = pData;
1589	applicationConfigBuffer.bufferSize = (UINT16)Length;
1590
1591	/* set the scan manager policy */
1592	retValue = UtilSetParam( pAdapter, SCAN_MNGR_SET_CONFIGURATION, (PUCHAR)&applicationConfigBuffer, sizeof(applicationConfigBuffer_t) );
1593
1594	return retValue;
1595}
1596
1597
1598/*-----------------------------------------------------------------------------
1599Routine Name: UtilScanBssListGet
1600Routine Description:
1601Arguments:
1602Return Value:
1603-----------------------------------------------------------------------------*/
1604ULONG
1605UtilScanBssListGet(
1606				  PTIWLN_ADAPTER_T pAdapter,
1607				  PUCHAR pData,
1608				  PULONG Length
1609				  )
1610{
1611	paramInfo_t param;
1612	TI_STATUS status;
1613
1614	param.paramType = SCAN_MNGR_BSS_LIST_GET;
1615	param.paramLength = sizeof(PUCHAR);
1616
1617	status = configMgr_getParam(pAdapter->CoreHalCtx, &param);
1618
1619	NdisMoveMemory( pData, param.content.pScanBssList, *Length );
1620	*Length = sizeof(bssList_t);
1621
1622	return status;
1623}
1624
1625
1626/*-----------------------------------------------------------------------------
1627Routine Name: UtilBssidListScanOid
1628Routine Description:
1629Arguments:
1630Return Value:
1631-----------------------------------------------------------------------------*/
1632ULONG
1633UtilBssidListScanOid(
1634					PTIWLN_ADAPTER_T pAdapter,
1635					PUCHAR pData,
1636					ULONG Length
1637					)
1638{
1639	TI_STATUS Status;
1640//TRS: Scan changes from TI
1641    Status = UtilSetParam(pAdapter, SCAN_CNCN_BSSID_LIST_SCAN_PARAM, pData, 0);
1642//TRS: end of Scan changes from TI
1643	return Status;
1644}
1645
1646
1647/*-----------------------------------------------------------------------------
1648Routine Name: UtilInfrastructureModeGet
1649Routine Description:
1650Arguments:
1651Return Value:
1652-----------------------------------------------------------------------------*/
1653ULONG
1654UtilInfrastructureModeGet(
1655						 PTIWLN_ADAPTER_T pAdapter,
1656						 PUCHAR pData,
1657						 PULONG Length
1658						 )
1659{
1660	ULONG retValue;
1661
1662	if (!Length)
1663		return NOK;
1664
1665	retValue = UtilGetParam(pAdapter, CTRL_DATA_CURRENT_BSS_TYPE_PARAM, pData, sizeof(bssType_e));
1666	*Length = sizeof(ULONG);
1667	return(retValue);
1668}
1669
1670
1671/*-----------------------------------------------------------------------------
1672Routine Name: UtilDesiredInfrastructureModeGet
1673Routine Description:
1674Arguments:
1675Return Value:
1676-----------------------------------------------------------------------------*/
1677ULONG
1678UtilDesiredInfrastructureModeGet(
1679								PTIWLN_ADAPTER_T pAdapter,
1680								PUCHAR pData,
1681								PULONG Length
1682								)
1683{
1684	ULONG retValue;
1685
1686	if (!Length)
1687		return NOK;
1688
1689	retValue = UtilGetParam(pAdapter, SITE_MGR_DESIRED_BSS_TYPE_PARAM, pData, sizeof(bssType_e));
1690
1691	*Length = sizeof(ULONG);
1692	return retValue;
1693}
1694
1695
1696/*-----------------------------------------------------------------------------
1697Routine Name: UtilInfrastructureModeSet
1698Routine Description:
1699Arguments:
1700Return Value:
1701-----------------------------------------------------------------------------*/
1702ULONG
1703UtilInfrastructureModeSet(
1704						 PTIWLN_ADAPTER_T pAdapter,
1705						 PUCHAR pData,
1706						 ULONG Length
1707						 )
1708{
1709	ULONG retValue;
1710	retValue = UtilSetParam(pAdapter, SITE_MGR_DESIRED_BSS_TYPE_PARAM, pData, sizeof(bssType_e));
1711	return retValue;
1712}
1713
1714
1715/*-----------------------------------------------------------------------------
1716Routine Name: UtilFragmentationThresholdGet
1717Routine Description:
1718Arguments:
1719Return Value:
1720-----------------------------------------------------------------------------*/
1721ULONG
1722UtilFragmentationThresholdGet(
1723							 PTIWLN_ADAPTER_T pAdapter,
1724							 PUCHAR pData,
1725							 PULONG Length
1726							 )
1727{
1728	UINT16 FragThreshold;
1729	ULONG retValue;
1730
1731	if (!Length)
1732	{
1733		*Length = sizeof(ULONG);
1734		return NOK;
1735	}
1736
1737	retValue = UtilGetParam(pAdapter, HAL_CTRL_FRAG_THRESHOLD_PARAM, pData, sizeof(ULONG));
1738
1739	FragThreshold = *(PUINT16)pData;
1740	*(PULONG)pData = FragThreshold;
1741
1742	*Length = sizeof(ULONG);
1743	return retValue;
1744}
1745
1746
1747/*-----------------------------------------------------------------------------
1748Routine Name: UtilFragmentationThresholdSet
1749Routine Description:
1750Arguments:
1751Return Value:
1752-----------------------------------------------------------------------------*/
1753ULONG
1754UtilFragmentationThresholdSet(
1755							 PTIWLN_ADAPTER_T pAdapter,
1756							 PUCHAR pData,
1757							 ULONG Length
1758							 )
1759{
1760	UINT16 FragThreshold = (UINT16) *(PULONG)pData;
1761	ULONG retValue;
1762
1763	FragThreshold = ((FragThreshold+1)>>1) << 1; /*make it always even(GreenA)*/
1764	retValue = UtilSetParam(pAdapter, HAL_CTRL_FRAG_THRESHOLD_PARAM, (PUCHAR)&FragThreshold, sizeof(UINT16));
1765
1766	return retValue;
1767}
1768
1769
1770/*-----------------------------------------------------------------------------
1771Routine Name: UtilRtsThresholdGet
1772Routine Description:
1773Arguments:
1774Return Value:
1775-----------------------------------------------------------------------------*/
1776ULONG
1777UtilRtsThresholdGet(
1778				   PTIWLN_ADAPTER_T pAdapter,
1779				   PUCHAR pData,
1780				   PULONG Length
1781				   )
1782{
1783	UINT16 RtsThreshold;
1784	ULONG retValue;
1785
1786	if (!Length)
1787	{
1788		*Length = sizeof(ULONG);
1789		return NOK;
1790	}
1791
1792	retValue = UtilGetParam(pAdapter, HAL_CTRL_RTS_THRESHOLD_PARAM, pData, sizeof(ULONG));
1793
1794	RtsThreshold = *(PUINT16)pData;
1795	*(PULONG)pData = RtsThreshold;
1796	*Length = sizeof (ULONG);
1797
1798	return retValue;
1799}
1800
1801
1802/*-----------------------------------------------------------------------------
1803Routine Name: UtilSupportedRates
1804Routine Description:
1805Arguments:
1806Return Value:
1807-----------------------------------------------------------------------------*/
1808ULONG
1809UtilSupportedRates(
1810				  PTIWLN_ADAPTER_T pAdapter,
1811				  PUCHAR pData,
1812				  PULONG Length
1813				  )
1814{
1815	rates_t rateSet;
1816	ULONG retValue;
1817
1818	retValue = UtilGetParam(pAdapter, SITE_MGR_DESIRED_SUPPORTED_RATE_SET_PARAM, (PUCHAR)&rateSet, sizeof(rates_t));
1819
1820	NdisMoveMemory(pData, (PUCHAR)&rateSet, *Length);
1821	*Length = rateSet.len +1; /* 1 is added for the length field itself */
1822
1823	return retValue;
1824}
1825
1826
1827/*-----------------------------------------------------------------------------
1828Routine Name: UtilSupportedRatesSet
1829Routine Description:
1830Arguments:
1831Return Value:
1832-----------------------------------------------------------------------------*/
1833ULONG
1834UtilSupportedRatesSet(
1835					 PTIWLN_ADAPTER_T pAdapter,
1836					 PUCHAR pData,
1837					 ULONG Length
1838					 )
1839{
1840	rates_t rateSet;
1841	ULONG retValue;
1842
1843	NdisMoveMemory(&rateSet, pData, Length);
1844
1845	retValue = UtilSetParam(pAdapter, SITE_MGR_DESIRED_SUPPORTED_RATE_SET_PARAM, (PUCHAR)&rateSet, sizeof(rates_t));
1846
1847	return retValue;
1848}
1849
1850
1851/*-----------------------------------------------------------------------------
1852Routine Name: UtilRtsThresholdSet
1853Routine Description:
1854Arguments:
1855Return Value:
1856-----------------------------------------------------------------------------*/
1857ULONG
1858UtilRtsThresholdSet(
1859				   PTIWLN_ADAPTER_T pAdapter,
1860				   PUCHAR pData,
1861				   ULONG Length
1862				   )
1863{
1864	UINT16 RtsThreshold = (UINT16) *(PULONG)pData;
1865	ULONG retValue;
1866
1867	retValue = UtilSetParam(pAdapter, HAL_CTRL_RTS_THRESHOLD_PARAM,
1868							(PUCHAR)&RtsThreshold, sizeof(UINT16));
1869
1870	return retValue;
1871
1872}
1873
1874
1875/*-----------------------------------------------------------------------------
1876Routine Name: UtilChannelGet
1877Routine Description:
1878Arguments:
1879Return Value:
1880-----------------------------------------------------------------------------*/
1881ULONG
1882UtilChannelGet(
1883			  PTIWLN_ADAPTER_T pAdapter,
1884			  PUCHAR pData,
1885			  PULONG Length
1886			  )
1887{
1888	ULONG Channel,retValue;
1889
1890	if (!Length)
1891		return NOK;
1892
1893	retValue = UtilGetParam(pAdapter, SITE_MGR_CURRENT_CHANNEL_PARAM, pData, sizeof(ULONG));
1894
1895	Channel = *(PUCHAR)pData;
1896	*(PULONG)pData = (ULONG) Channel;
1897	*Length = sizeof (ULONG);
1898
1899	return retValue;
1900}
1901
1902
1903/*-----------------------------------------------------------------------------
1904Routine Name: UtilDesiredChannelGet
1905Routine Description:
1906Arguments:
1907Return Value:
1908-----------------------------------------------------------------------------*/
1909ULONG
1910UtilDesiredChannelGet(
1911					 PTIWLN_ADAPTER_T pAdapter,
1912					 PUCHAR pData,
1913					 PULONG Length
1914					 )
1915{
1916	ULONG Channel,retValue;
1917
1918	if (!Length)
1919		return NOK;
1920
1921	retValue = UtilGetParam(pAdapter, SITE_MGR_DESIRED_CHANNEL_PARAM, pData, sizeof(ULONG));
1922
1923	Channel = *(PUCHAR)pData;
1924	*(PULONG)pData = (ULONG) Channel;
1925	*Length = sizeof (ULONG);
1926
1927	return retValue;
1928
1929}
1930
1931
1932/*-----------------------------------------------------------------------------
1933Routine Name: UtilDesiredChannelSet
1934Routine Description:
1935Arguments:
1936Return Value:
1937-----------------------------------------------------------------------------*/
1938ULONG
1939UtilDesiredChannelSet(
1940					 PTIWLN_ADAPTER_T pAdapter,
1941					 PUCHAR pData,
1942					 ULONG Length
1943					 )
1944{
1945	UINT8 Channel = *pData;
1946	ULONG retValue;
1947
1948	retValue = UtilSetParam(pAdapter, SITE_MGR_DESIRED_CHANNEL_PARAM, &Channel, sizeof(UCHAR));
1949
1950	return retValue;
1951
1952}
1953
1954
1955/*-----------------------------------------------------------------------------
1956Routine Name: UtilShortPreambleGet
1957Routine Description:
1958Arguments:
1959Return Value:
1960-----------------------------------------------------------------------------*/
1961ULONG
1962UtilShortPreambleGet(
1963					PTIWLN_ADAPTER_T pAdapter,
1964					PUCHAR pData,
1965					PULONG Length
1966					)
1967{
1968	ULONG retValue;
1969	if (!Length)
1970	{
1971		*Length = sizeof(ULONG);
1972		return NOK;
1973	}
1974
1975	retValue = UtilGetParam(pAdapter, SITE_MGR_DESIRED_PREAMBLE_TYPE_PARAM, pData, sizeof(ULONG));
1976
1977	*Length = sizeof (ULONG);
1978
1979	return retValue;
1980
1981}
1982
1983
1984/*-----------------------------------------------------------------------------
1985Routine Name: UtilShortPreambleSet
1986Routine Description:
1987Arguments:
1988Return Value:
1989-----------------------------------------------------------------------------*/
1990ULONG
1991UtilShortPreambleSet(
1992					PTIWLN_ADAPTER_T pAdapter,
1993					PUCHAR pData,
1994					ULONG Length
1995					)
1996{
1997	ULONG retValue;
1998	retValue = UtilSetParam(pAdapter, SITE_MGR_DESIRED_PREAMBLE_TYPE_PARAM,
1999							pData, sizeof(ULONG));
2000
2001	return retValue;
2002
2003}
2004
2005
2006/*-----------------------------------------------------------------------------
2007Routine Name: UtilRegulatoryDomain_enableDisable_802_11d
2008Routine Description:
2009Arguments:
2010Return Value:
2011-----------------------------------------------------------------------------*/
2012ULONG
2013UtilRegulatoryDomain_enableDisable_802_11d(
2014										  PTIWLN_ADAPTER_T pAdapter,
2015										  PUCHAR pData,
2016										  ULONG Length
2017										  )
2018{
2019	ULONG retValue;
2020	retValue = UtilSetParam(pAdapter, REGULATORY_DOMAIN_ENABLE_DISABLE_802_11D, pData, sizeof(UINT8));
2021
2022	return retValue;
2023
2024}
2025
2026/*-----------------------------------------------------------------------------
2027Routine Name: UtilRegulatoryDomain_enableDisable_802_11h
2028Routine Description:
2029Arguments:
2030Return Value:
2031-----------------------------------------------------------------------------*/
2032ULONG
2033UtilRegulatoryDomain_enableDisable_802_11h(
2034										  PTIWLN_ADAPTER_T pAdapter,
2035										  PUCHAR pData,
2036										  ULONG Length
2037										  )
2038{
2039	ULONG retValue;
2040	retValue = UtilSetParam(pAdapter, REGULATORY_DOMAIN_ENABLE_DISABLE_802_11H, pData, sizeof(UINT8));
2041
2042	return retValue;
2043
2044}
2045
2046
2047/*-----------------------------------------------------------------------------
2048Routine Name: UtilRegulatoryDomain_Get_802_11d
2049Routine Description:
2050Arguments:
2051Return Value:
2052-----------------------------------------------------------------------------*/
2053ULONG
2054UtilRegulatoryDomain_Get_802_11d(
2055								PTIWLN_ADAPTER_T pAdapter,
2056								PUCHAR pData,
2057								PULONG Length
2058								)
2059{
2060	ULONG retValue;
2061	retValue = UtilGetParam(pAdapter, REGULATORY_DOMAIN_ENABLED_PARAM, pData, sizeof(UINT8));
2062
2063	return retValue;
2064
2065}
2066
2067/*-----------------------------------------------------------------------------
2068Routine Name: UtilRegulatoryDomain_Get_802_11h
2069Routine Description:
2070Arguments:
2071Return Value:
2072-----------------------------------------------------------------------------*/
2073ULONG
2074UtilRegulatoryDomain_Get_802_11h(
2075								PTIWLN_ADAPTER_T pAdapter,
2076								PUCHAR pData,
2077								PULONG Length
2078								)
2079{
2080	ULONG retValue;
2081	retValue = UtilGetParam(pAdapter, REGULATORY_DOMAIN_MANAGEMENT_CAPABILITY_ENABLED_PARAM, pData, sizeof(UINT8));
2082
2083	return retValue;
2084
2085}
2086
2087/*-----------------------------------------------------------------------------
2088Routine Name: UtilRegulatoryDomain_setCountryIE
2089Routine Description:
2090Arguments:
2091Return Value:
2092-----------------------------------------------------------------------------*/
2093static TI_STATUS
2094UtilRegulatoryDomain_setCountryIE(
2095								 PTIWLN_ADAPTER_T pAdapter,
2096								 externalParam_e ParamType,
2097								 PUCHAR pData,
2098								 ULONG Length
2099								 )
2100{
2101	paramInfo_t Param;
2102	TI_STATUS Status;
2103	country_t  countryIe;
2104
2105	Param.paramType = ParamType;
2106	Param.paramLength = sizeof(country_t);
2107	NdisMoveMemory(&countryIe, pData, Length);
2108
2109	Param.content.pCountry = &countryIe;
2110	Status = configMgr_setParam(pAdapter->CoreHalCtx, &Param);
2111
2112	return Status;
2113
2114}
2115
2116
2117/*-----------------------------------------------------------------------------
2118Routine Name: UtilRegulatoryDomain_setCountryIE_2_4
2119Routine Description:
2120Arguments:
2121Return Value:
2122-----------------------------------------------------------------------------*/
2123ULONG
2124UtilRegulatoryDomain_setCountryIE_2_4(
2125									 PTIWLN_ADAPTER_T pAdapter,
2126									 PUCHAR pData,
2127									 ULONG Length)
2128{
2129	ULONG retValue;
2130
2131	retValue = UtilRegulatoryDomain_setCountryIE(pAdapter, REGULATORY_DOMAIN_COUNTRY_2_4_PARAM, pData, sizeof(country_t));
2132
2133	return retValue;
2134
2135}
2136
2137
2138
2139/*-----------------------------------------------------------------------------
2140Routine Name: UtilRegulatoryDomain_getCountryIE_2_4
2141Routine Description:
2142Arguments:
2143Return Value:
2144-----------------------------------------------------------------------------*/
2145ULONG
2146UtilRegulatoryDomain_getCountryIE_2_4(
2147									 PTIWLN_ADAPTER_T pAdapter,
2148									 PUCHAR pData,
2149									 PULONG Length
2150									 )
2151{
2152	ULONG retValue;
2153	retValue = UtilGetParam(pAdapter, REGULATORY_DOMAIN_COUNTRY_2_4_PARAM, pData, COUNTRY_STRING_LEN);
2154
2155	return retValue;
2156
2157}
2158
2159/*-----------------------------------------------------------------------------
2160Routine Name: UtilRegulatoryDomain_setCountryIE_5
2161Routine Description:
2162Arguments:
2163Return Value:
2164-----------------------------------------------------------------------------*/
2165ULONG
2166UtilRegulatoryDomain_setCountryIE_5(
2167								   PTIWLN_ADAPTER_T pAdapter,
2168								   PUCHAR pData,
2169								   ULONG Length
2170								   )
2171{
2172	ULONG retValue;
2173	retValue = UtilRegulatoryDomain_setCountryIE(pAdapter, REGULATORY_DOMAIN_COUNTRY_5_PARAM, pData, sizeof(country_t));
2174
2175	return retValue;
2176
2177}
2178
2179
2180/*-----------------------------------------------------------------------------
2181Routine Name: UtilRegulatoryDomain_getCountryIE_5
2182Routine Description:
2183Arguments:
2184Return Value:
2185-----------------------------------------------------------------------------*/
2186ULONG
2187UtilRegulatoryDomain_getCountryIE_5(
2188								   PTIWLN_ADAPTER_T pAdapter,
2189								   PUCHAR pData,
2190								   PULONG Length
2191								   )
2192{
2193	ULONG retValue;
2194	retValue = UtilGetParam(pAdapter, REGULATORY_DOMAIN_COUNTRY_5_PARAM, pData, COUNTRY_STRING_LEN);
2195
2196	return retValue;
2197
2198}
2199
2200/*-----------------------------------------------------------------------------
2201Routine Name: UtilRegulatoryDomain_setMinMaxDfsChannels
2202Routine Description:
2203Arguments:
2204Return Value:
2205-----------------------------------------------------------------------------*/
2206ULONG
2207UtilRegulatoryDomain_setMinMaxDfsChannels(
2208    PTIWLN_ADAPTER_T pAdapter,
2209    PUCHAR pData,
2210    ULONG Length
2211    )
2212{
2213    ULONG retValue;
2214
2215    retValue = UtilSetParam(pAdapter, REGULATORY_DOMAIN_DFS_CHANNELS_RANGE, pData, sizeof(DFS_ChannelRange_t));
2216
2217    return retValue;
2218
2219}
2220
2221
2222/*-----------------------------------------------------------------------------
2223Routine Name: UtilRegulatoryDomain_getMinMaxDfsChannels
2224Routine Description:
2225Arguments:
2226Return Value:
2227-----------------------------------------------------------------------------*/
2228ULONG
2229UtilRegulatoryDomain_getMinMaxDfsChannels(
2230    PTIWLN_ADAPTER_T pAdapter,
2231    PUCHAR pData,
2232    PULONG Length
2233    )
2234{
2235    ULONG retValue;
2236    retValue = UtilGetParam(pAdapter, REGULATORY_DOMAIN_DFS_CHANNELS_RANGE, pData, sizeof(DFS_ChannelRange_t));
2237
2238    return retValue;
2239
2240}
2241
2242
2243/*-----------------------------------------------------------------------------
2244Routine Name: UtilShortRetryGet
2245Routine Description:
2246Arguments:
2247Return Value:
2248-----------------------------------------------------------------------------*/
2249ULONG
2250UtilShortRetryGet(
2251				 PTIWLN_ADAPTER_T pAdapter,
2252				 PUCHAR pData,
2253				 PULONG Length
2254				 )
2255
2256{
2257	ULONG retValue;
2258
2259
2260	txRatePolicy_t  TxRatePolicy;
2261	/*
2262	 * NOTE: currently supporting only ONE txRatePolicy!!!!!!!!!
2263	 */
2264
2265
2266	if (!Length)
2267		return sizeof(ULONG);
2268
2269	retValue = UtilGetParam(pAdapter, CTRL_DATA_SHORT_RETRY_LIMIT_PARAM,
2270							(PUCHAR)(&TxRatePolicy), sizeof(txRatePolicy_t));
2271
2272	*(PULONG)pData = TxRatePolicy.rateClass[0].shortRetryLimit;
2273
2274	return retValue;
2275}
2276
2277
2278/*-----------------------------------------------------------------------------
2279Routine Name: UtilShortRetrySet
2280Routine Description:
2281Arguments:
2282Return Value:
2283-----------------------------------------------------------------------------*/
2284ULONG
2285UtilShortRetrySet(
2286				 PTIWLN_ADAPTER_T pAdapter,
2287				 PUCHAR pData,
2288				 ULONG Length
2289				 )
2290{
2291	ULONG retValue;
2292	txRatePolicy_t  TxRatePolicy;
2293
2294	/*
2295	 * NOTE: currently supporting only ONE txRatePolicy!!!!!!!!!
2296	 */
2297
2298
2299	TxRatePolicy.rateClass[0].shortRetryLimit = (UINT8) *(PULONG)pData;
2300
2301	retValue = UtilSetParam(pAdapter, CTRL_DATA_SHORT_RETRY_LIMIT_PARAM,
2302							(PUCHAR)(&TxRatePolicy), sizeof(txRatePolicy_t));
2303
2304	return retValue ;
2305
2306}
2307
2308
2309/*-----------------------------------------------------------------------------
2310Routine Name: UtilLongRetryGet
2311Routine Description:
2312Arguments:
2313Return Value:
2314-----------------------------------------------------------------------------*/
2315ULONG
2316UtilLongRetryGet(
2317				PTIWLN_ADAPTER_T pAdapter,
2318				PUCHAR pData,
2319				PULONG Length
2320				)
2321{
2322	ULONG retValue;
2323	txRatePolicy_t  TxRatePolicy;
2324	/*
2325	 * NOTE: currently supporting only ONE txRatePolicy!!!!!!!!!
2326	 */
2327
2328
2329	if (!Length)
2330		return NOK;
2331
2332	retValue = UtilGetParam(pAdapter, CTRL_DATA_LONG_RETRY_LIMIT_PARAM,
2333							(PUCHAR)(&TxRatePolicy), sizeof(txRatePolicy_t));
2334
2335	*(PULONG)pData = TxRatePolicy.rateClass[0].longRetryLimit;
2336	return retValue;
2337
2338}
2339
2340
2341/*-----------------------------------------------------------------------------
2342Routine Name: UtilLongRetrySet
2343Routine Description:
2344Arguments:
2345Return Value:
2346-----------------------------------------------------------------------------*/
2347ULONG
2348UtilLongRetrySet(
2349				PTIWLN_ADAPTER_T pAdapter,
2350				PUCHAR pData,
2351				ULONG Length
2352				)
2353{
2354	txRatePolicy_t  TxRatePolicy;
2355	ULONG retValue;
2356
2357	/*
2358	 * NOTE: currently supporting only ONE txRatePolicy!!!!!!!!!
2359	 */
2360
2361
2362	TxRatePolicy.rateClass[0].longRetryLimit = (UINT8) *(PULONG)pData;
2363
2364	retValue = UtilSetParam(pAdapter, CTRL_DATA_SHORT_RETRY_LIMIT_PARAM,
2365							(PUCHAR)(&TxRatePolicy), sizeof(txRatePolicy_t));
2366
2367	return retValue;
2368}
2369/*-----------------------------------------------------------------------------*/
2370ULONG
2371UtilDesiredRatesGet(
2372				   PTIWLN_ADAPTER_T pAdapter,
2373				   PUCHAR pData,
2374				   PULONG Length
2375				   )
2376{
2377	UCHAR rate;
2378	ULONG retValue;
2379
2380	if (!Length)
2381		return NOK;
2382
2383	retValue = UtilGetParam(pAdapter, SITE_MGR_DESIRED_TX_RATE_PARAM, (PUCHAR)&rate, sizeof(UCHAR));
2384
2385	*Length = sizeof(UCHAR);
2386	*(PUCHAR)pData = rate;
2387
2388	return retValue;
2389}
2390
2391/*-----------------------------------------------------------------------------
2392Routine Name: UtilCurrentRatesGet
2393Routine Description:
2394Arguments:
2395Return Value:
2396-----------------------------------------------------------------------------*/
2397ULONG
2398UtilCurrentRatesGet(
2399				   PTIWLN_ADAPTER_T pAdapter,
2400				   PUCHAR pData,
2401				   PULONG Length
2402				   )
2403{
2404	UCHAR rate;
2405	ULONG retValue;
2406
2407	rate = (UCHAR) *(PULONG)pData;
2408
2409	retValue = UtilGetParam(pAdapter, SITE_MGR_CURRENT_TX_RATE_PARAM, (PUCHAR)&rate, sizeof(UCHAR));
2410	*(PUCHAR)pData = rate;
2411	*Length = sizeof(UCHAR);
2412
2413	return retValue;
2414}
2415
2416
2417/*-----------------------------------------------------------------------------
2418Routine Name: UtilConfigurationGet
2419Routine Description:
2420Arguments:
2421Return Value:
2422-----------------------------------------------------------------------------*/
2423ULONG
2424UtilConfigurationGet(
2425					PTIWLN_ADAPTER_T pAdapter,
2426					PUCHAR pData,
2427					PULONG Length
2428					)
2429{
2430	paramInfo_t Param;
2431	ULONG retValue;
2432
2433	if (!Length)
2434	{
2435		*Length = sizeof(OS_802_11_CONFIGURATION);
2436		return NOK;
2437	}
2438
2439	Param.paramType = SITE_MGR_CONFIGURATION_PARAM;
2440	Param.paramLength = *Length;
2441	*(PULONG)&Param.content = (ULONG)pData;
2442
2443	retValue = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
2444
2445	*Length = sizeof(OS_802_11_CONFIGURATION);
2446
2447	return retValue;
2448
2449}
2450
2451
2452/*-----------------------------------------------------------------------------
2453Routine Name: UtilConfigurationSet
2454Routine Description:
2455Arguments:
2456Return Value:
2457-----------------------------------------------------------------------------*/
2458ULONG
2459UtilConfigurationSet(
2460					PTIWLN_ADAPTER_T pAdapter,
2461					PUCHAR pData,
2462					ULONG Length
2463					)
2464{
2465	paramInfo_t Param;
2466	ULONG retValue;
2467
2468	Param.paramType = SITE_MGR_CONFIGURATION_PARAM;
2469	Param.paramLength = Length;
2470	*(PULONG)&Param.content = (ULONG)pData;
2471
2472	retValue = configMgr_setParam(pAdapter->CoreHalCtx, &Param);
2473
2474	return retValue;
2475
2476}
2477
2478/*-----------------------------------------------------------------------------
2479Routine Name: UtilGetCounter
2480Routine Description:
2481Arguments:
2482Return Value:
2483-----------------------------------------------------------------------------*/
2484ULONG
2485UtilGetCounter(
2486			  PTIWLN_ADAPTER_T pAdapter,
2487			  PUCHAR pData,
2488			  ULONG Offset
2489			  )
2490{
2491	TIWLN_COUNTERS TiCounters;
2492
2493	UtilGetParam(pAdapter, SITE_MGR_TI_WLAN_COUNTERS_PARAM,
2494				 (PUCHAR)&TiCounters, sizeof(TIWLN_COUNTERS));
2495
2496	NdisMoveMemory(pData, (PUCHAR)&TiCounters + Offset, sizeof(ULONG));
2497
2498	return sizeof(ULONG);
2499}
2500
2501/*-----------------------------------------------------------------------------
2502Routine Name: UtilStatistics
2503Routine Description:
2504Arguments:
2505Return Value:
2506-----------------------------------------------------------------------------*/
2507ULONG
2508UtilStatistics(
2509			  PTIWLN_ADAPTER_T pAdapter,
2510			  PUCHAR pData,
2511			  PULONG Length
2512			  )
2513{
2514	TIWLN_STATISTICS* pStats;
2515	paramInfo_t Param;
2516	ULONG RetSize, data,retValue,dataSize;
2517
2518
2519    if (*Length >= sizeof(TIWLN_STATISTICS)) //TRS:GAA allow larger than needed buffer
2520	{
2521		pStats = (TIWLN_STATISTICS *) pData;
2522		NdisZeroMemory(pStats, sizeof(TIWLN_STATISTICS));
2523
2524		RetSize = sizeof(TIWLN_STATISTICS);
2525
2526		NdisMoveMemory(&pStats->currentMACAddress, pAdapter->CurrentAddr, ETH_ADDR_SIZE);
2527
2528		dataSize = sizeof(tiUINT32);
2529		if ((retValue = UtilPowerModeGet(pAdapter, (PUCHAR)&pStats->PowerMode, &dataSize)) != OK)
2530			return retValue;
2531
2532		dataSize = sizeof(OS_802_11_SSID);
2533		if ((retValue = UtilGetSSID(pAdapter, (PUCHAR)&pStats->dot11DesiredSSID, &dataSize)) != OK)
2534			return retValue;
2535
2536		dataSize = sizeof(UINT32);
2537		if ((retValue = UtilChannelGet(pAdapter, (PUCHAR)&pStats->dot11CurrentChannel, &dataSize)) != OK)
2538			return retValue;
2539
2540		dataSize = sizeof(ULONG);
2541		if ((retValue = UtilExtAuthenticationModeGet(pAdapter, (PUCHAR)&pStats->AuthenticationMode, &dataSize)) != OK)
2542			return retValue;
2543
2544		dataSize = sizeof(ULONG);
2545		if ((retValue = UtilRtsThresholdGet(pAdapter, (PUCHAR)&pStats->RTSThreshold,    &dataSize)) != OK)
2546			return retValue;
2547
2548		dataSize = sizeof(ULONG);
2549		if ((retValue = UtilFragmentationThresholdGet(pAdapter, (PUCHAR)&pStats->FragmentationThreshold, &dataSize)) != OK)
2550			return retValue;
2551
2552		dataSize = sizeof(ULONG);
2553        if ((retValue = UtilGetParam(pAdapter, REGULATORY_DOMAIN_CURRENT_TX_POWER_IN_DBM_PARAM,
2554									(PUCHAR)&pStats->TxPowerDbm, dataSize)) != OK)
2555			return retValue;
2556
2557		dataSize = sizeof(ULONG);
2558		if ((retValue = UtilInfrastructureModeGet(pAdapter, (PUCHAR)&pStats->dot11BSSType, &dataSize)) != OK)
2559			return retValue;
2560
2561		dataSize = sizeof(ULONG);
2562		if ((retValue = UtilWepStatusGet(pAdapter, (PUCHAR)&pStats->WEPStatus, &dataSize)) != OK)
2563			return retValue;
2564
2565		if ((retValue = UtilGetParam(pAdapter, SITE_MGR_CONNECTION_STATUS_PARAM, (PUCHAR)&pStats->dot11State, sizeof(ULONG))) != OK)
2566			return retValue;
2567
2568		pStats->dot11CurrentTxRate = pAdapter->LinkSpeed/5000;
2569
2570		if ((retValue = UtilGetParam(pAdapter, SITE_MGR_CURRENT_PREAMBLE_TYPE_PARAM, (PUCHAR)&data, sizeof(ULONG))) != OK)
2571			return retValue;
2572
2573		pStats->bShortPreambleUsed = (BOOLEAN) data;
2574
2575		Param.paramType = SITE_MGR_GET_SELECTED_BSSID_INFO;
2576		Param.content.pSiteMgrPrimarySiteDesc = &pStats->targetAP;
2577		if ((retValue = configMgr_getParam(pAdapter->CoreHalCtx, &Param)) != OK)
2578			return retValue;
2579
2580		PRINTF(DBG_IOCTL_LOUD, ("...RSSI: %d\n", pStats->targetAP.Rssi));
2581		pStats->RxLevel = pStats->targetAP.Rssi;
2582
2583		dataSize = sizeof(ULONG);
2584		if ((retValue = UtilTxAntennaGet(pAdapter, (PUCHAR)&pStats->TxAntenna, &dataSize)) != OK)
2585			return retValue;
2586
2587		dataSize = sizeof(ULONG);
2588		if ((retValue = UtilRxAntennaGet(pAdapter, (PUCHAR)&pStats->RxAntenna, &dataSize)) != OK)
2589			return retValue;
2590
2591#ifdef EXC_MODULE_INCLUDED
2592		dataSize = sizeof(BOOL);
2593		if ((retValue = UtilExcNetworkEapGet(pAdapter, (PUCHAR)&pStats->dwSecuritySuit, &dataSize)) != OK)
2594			return retValue;
2595		if ((pStats->dwSecuritySuit==OS_EXC_NETWORK_EAP_ON) && (pStats->WEPStatus==os802_11WEPEnabled))
2596		{
2597			pStats->dwSecuritySuit = TIWLN_STAT_SECURITY_RESERVE_1;
2598		} else
2599#else
2600		{
2601			pStats->dwSecuritySuit = 0;
2602		}
2603#endif
2604		if ((retValue = UtilGetParam(pAdapter, RSN_SECURITY_STATE_PARAM, (PUCHAR)&pStats->dwSecurityState, sizeof(ULONG))) != OK)
2605			return retValue;
2606
2607		pStats->dwSecurityAuthStatus = 0;
2608		pStats->dwFeatureSuit = 0;
2609
2610		if ((retValue = UtilGetParam(pAdapter, SITE_MGR_TI_WLAN_COUNTERS_PARAM, (PUCHAR)&pStats->tiCounters, sizeof(TIWLN_COUNTERS))) != OK)
2611			return retValue;
2612
2613        if ((retValue = UtilGetParam(pAdapter, MLME_BEACON_RECV, (PUCHAR)&pStats->tiCounters, sizeof(TIWLN_COUNTERS))) != OK)
2614			return retValue;
2615	}
2616
2617	else
2618	{
2619
2620		NdisZeroMemory(pData, *Length);
2621		*Length = 0;
2622		return NOK;
2623
2624	}
2625
2626	*Length = RetSize;
2627	return retValue;
2628}
2629
2630
2631/*-----------------------------------------------------------------------------
2632Routine Name: UtilTxStatistics
2633Routine Description:
2634Arguments:
2635Return Value:
2636-----------------------------------------------------------------------------*/
2637ULONG
2638UtilTxStatistics(
2639				PTIWLN_ADAPTER_T pAdapter,
2640				PUCHAR pData,
2641				ULONG inLength,
2642				PULONG outLength
2643				)
2644{
2645	ULONG retValue;
2646	txDataCounters_t  *pTxDataCounters;
2647	UINT32 resetStatsFlag;
2648
2649	if (*outLength == sizeof(TIWLN_TX_STATISTICS))
2650	{
2651		/* check whether statistics clear is also requested */
2652		resetStatsFlag = *pData;
2653
2654		/* note that only the pointer (by reference!) is passed to UtilGetParam, and the actual copying of data
2655		   is done here */
2656		if ((retValue = UtilGetParam( pAdapter, TX_DATA_COUNTERS_PARAM,
2657									  (PUCHAR)&pTxDataCounters, sizeof(txDataCounters_t*))) != OK)
2658			return retValue;
2659
2660		NdisMoveMemory( pData, pTxDataCounters, sizeof(TIWLN_TX_STATISTICS) );
2661
2662		*outLength = sizeof(TIWLN_TX_STATISTICS);
2663
2664		if ( 1 == resetStatsFlag )
2665		{
2666			UtilSetParam( pAdapter, TX_DATA_RESET_COUNTERS_PARAM, NULL, 0 );
2667		}
2668	} else
2669	{
2670		NdisZeroMemory(pData, *outLength);
2671		*outLength = 0;
2672		return NOK;
2673	}
2674
2675	return retValue;
2676}
2677
2678
2679/*-----------------------------------------------------------------------------
2680Routine Name: UtilAddWep
2681Routine Description:
2682Arguments:
2683Return Value:
2684-----------------------------------------------------------------------------*/
2685ULONG
2686UtilAddWep(
2687		  PTIWLN_ADAPTER_T pAdapter,
2688		  PUCHAR pData,
2689		  ULONG Length,
2690		  BOOLEAN CalledFromIoctl
2691		  )
2692{
2693	OS_802_11_WEP* pWep;
2694	OS_802_11_KEY  key;
2695	UINT32         keyIndexTxRx;
2696	TI_STATUS Status;
2697
2698	pWep = (OS_802_11_WEP*) pData;
2699
2700	if ((pWep->KeyIndex & 0x3FFFFFFF) > 3)
2701	{
2702		return 0;
2703	}
2704
2705	if (CalledFromIoctl)
2706	{
2707		NdisMoveMemory(&pAdapter->DefaultWepKeys[pWep->KeyIndex & 0x3FFFFFFF],
2708					   pWep, sizeof(OS_802_11_WEP));
2709	}
2710	key.Length = pWep->Length;
2711	/* Convert the Key index to match OS_802_11_KEY index */
2712
2713	keyIndexTxRx = (pWep->KeyIndex & 0x80000000);
2714
2715	key.KeyIndex = keyIndexTxRx | /*(keyIndexTxRx>>1) |*/
2716				   (pWep->KeyIndex & 0x3FFFFFFF);
2717
2718	key.KeyLength = pWep->KeyLength;
2719
2720    if( pWep->KeyLength > sizeof(key.KeyMaterial) ) { /* Dm: Security fix */
2721        printk("TI: %s - Security Error\n", __FUNCTION__);
2722        return EXTERNAL_SET_PARAM_DENIED;
2723    }
2724
2725	NdisMoveMemory(key.KeyMaterial, (void *)pWep->KeyMaterial, pWep->KeyLength);
2726	/* Set the MAC Address to zero for WEP */
2727	NdisZeroMemory(key.BSSID, sizeof(key.BSSID));
2728
2729	Status = UtilSetParam(pAdapter, RSN_ADD_KEY_PARAM,
2730						  (PUCHAR)&key, sizeof(OS_802_11_KEY));
2731
2732	return Status;
2733}
2734
2735
2736/*-----------------------------------------------------------------------------
2737Routine Name: UtilRemoveWep
2738Routine Description:
2739Arguments:
2740Return Value:
2741-----------------------------------------------------------------------------*/
2742ULONG
2743UtilRemoveWep(
2744			 PTIWLN_ADAPTER_T pAdapter,
2745			 PUCHAR pData,
2746			 ULONG Length
2747			 )
2748{
2749	UINT32          keyIndex;
2750	OS_802_11_KEY  key;
2751	TI_STATUS Status;
2752
2753	keyIndex = *(UINT32*)pData;
2754
2755	/* Convert the Key index to match OS_802_11_KEY index */
2756	NdisZeroMemory(&key, sizeof(OS_802_11_KEY));
2757
2758	key.KeyIndex = keyIndex;
2759
2760	Status = UtilSetParam(pAdapter, RSN_REMOVE_KEY_PARAM,
2761						  (PUCHAR)&key, sizeof(OS_802_11_KEY));
2762
2763	return(Status);
2764}
2765
2766
2767#define ADD_KEY_HEADER_LENGTH 26
2768
2769
2770/*-----------------------------------------------------------------------------
2771Routine Name: UtilAddKey
2772Routine Description:
2773Arguments:
2774Return Value:
2775-----------------------------------------------------------------------------*/
2776ULONG
2777UtilAddKey(
2778		  PTIWLN_ADAPTER_T pAdapter,
2779		  PUCHAR pData,
2780		  ULONG Length
2781		  )
2782{
2783	TI_STATUS   status;
2784	OS_802_11_KEY* pKey;
2785
2786	pKey = (OS_802_11_KEY*) pData;
2787
2788	status = UtilSetParam(pAdapter, RSN_ADD_KEY_PARAM, pData, pKey->Length);
2789
2790	return status;
2791}
2792
2793
2794/*-----------------------------------------------------------------------------
2795Routine Name: UtilRemoveKey
2796Routine Description:
2797Arguments:
2798Return Value:
2799-----------------------------------------------------------------------------*/
2800ULONG
2801UtilRemoveKey(
2802			 PTIWLN_ADAPTER_T pAdapter,
2803			 PUCHAR pData,
2804			 ULONG Length
2805			 )
2806{
2807	TI_STATUS               status;
2808	OS_802_11_REMOVE_KEY    *pRemoveKey;
2809	OS_802_11_KEY           key;
2810
2811	pRemoveKey = (OS_802_11_REMOVE_KEY*)pData;
2812
2813	key.KeyIndex = pRemoveKey->KeyIndex;
2814	NdisMoveMemory(key.BSSID, (void *)pRemoveKey->BSSID, sizeof(key.BSSID));
2815
2816	status = UtilSetParam(pAdapter, RSN_REMOVE_KEY_PARAM,
2817						  (PUCHAR)&key, sizeof(OS_802_11_KEY));
2818
2819	return(status);
2820}
2821
2822
2823/*-----------------------------------------------------------------------------
2824Routine Name: UtilExtAuthenticationModeSet
2825Routine Description:
2826Arguments:
2827Return Value:
2828-----------------------------------------------------------------------------*/
2829ULONG
2830UtilExtAuthenticationModeSet(
2831							PTIWLN_ADAPTER_T pAdapter,
2832							PUCHAR pData,
2833							ULONG Length
2834							)
2835{
2836	ULONG retValue;
2837
2838	retValue = UtilSetParam(pAdapter, RSN_EXT_AUTHENTICATION_MODE, pData, sizeof(ULONG));
2839
2840	return retValue;
2841}
2842
2843
2844/*-----------------------------------------------------------------------------
2845Routine Name: UtilExtAuthenticationModeGet
2846Routine Description:
2847Arguments:
2848Return Value:
2849-----------------------------------------------------------------------------*/
2850ULONG
2851UtilExtAuthenticationModeGet(
2852							PTIWLN_ADAPTER_T pAdapter,
2853							PUCHAR pData,
2854							PULONG Length
2855							)
2856{
2857	ULONG retValue;
2858
2859	if (!Length)
2860		return NOK;
2861
2862	retValue = UtilGetParam(pAdapter, RSN_EXT_AUTHENTICATION_MODE, pData, sizeof(ULONG));
2863
2864	*Length = sizeof (ULONG);
2865
2866	return retValue;
2867}
2868
2869
2870/*-----------------------------------------------------------------------------
2871Routine Name: Util802CapabilityGet
2872Routine Description:
2873Arguments:
2874Return Value:
2875-----------------------------------------------------------------------------*/
2876ULONG Util802CapabilityGet(
2877						  PTIWLN_ADAPTER_T pAdapter,
2878						  PUCHAR pData,
2879						  PULONG Length)
2880{
2881	OS_802_11_CAPABILITY         *capability_802_11;
2882	rsnAuthEncrCapability_t       rsnAuthEncrCap;
2883	OS_802_11_ENCRYPTION_STATUS   encrStatus = os802_11EncryptionDisabled;
2884	ULONG                         neededLength = 0;
2885	UINT                          i = 0;
2886	paramInfo_t                   Param;
2887	TI_STATUS                     status;
2888
2889	/* If length of the input buffer less than needed length, do nothing, */
2890	/* return the needed length                                           */
2891	neededLength = sizeof(OS_802_11_CAPABILITY) +
2892				   (sizeof(OS_802_11_AUTH_ENCRYPTION) * (MAX_AUTH_ENCR_PAIR -1));
2893
2894	if (*Length < neededLength)
2895	{
2896		*Length = neededLength;
2897		return NOK;
2898	}
2899
2900	NdisZeroMemory (pData, neededLength);
2901	capability_802_11  = (OS_802_11_CAPABILITY *)pData;
2902
2903	/* Fill Param fields and get the 802_11 capability information */
2904	Param.paramType   = RSN_AUTH_ENCR_CAPABILITY;
2905	Param.paramLength = neededLength;
2906	Param.content.pRsnAuthEncrCapability = &rsnAuthEncrCap;
2907
2908	status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
2909
2910	if (status != OK)
2911	{
2912		/* return the default values only */
2913		/* PMKIDs is 0, AUTH/Encr pairs is 1, Auth/Encr is OPEN/NONE (0/0) */
2914		capability_802_11->Length     = sizeof(OS_802_11_CAPABILITY);
2915		capability_802_11->Version    = OID_CAPABILITY_VERSION;
2916		capability_802_11->NoOfPmKIDs = 0;
2917		capability_802_11->NoOfAuthEncryptPairsSupported = 1;
2918		capability_802_11->AuthEncryptionSupported[0].AuthModeSupported  =
2919		os802_11AuthModeOpen;
2920		capability_802_11->AuthEncryptionSupported[0].EncryptionStatusSupported =
2921		os802_11EncryptionDisabled;
2922
2923
2924		*Length = sizeof(OS_802_11_CAPABILITY);
2925		return NOK;
2926	}
2927
2928	/* Copy the received info to the OS_802_11_CAPABILITY needed format */
2929	capability_802_11->Length     = neededLength;
2930	capability_802_11->Version    = OID_CAPABILITY_VERSION;
2931	capability_802_11->NoOfPmKIDs = rsnAuthEncrCap.NoOfPMKIDs;
2932	capability_802_11->NoOfAuthEncryptPairsSupported =
2933	rsnAuthEncrCap.NoOfAuthEncrPairSupported;
2934
2935	/* Convert received cipher suite type to encr.status type */
2936	for (i = 0; i < rsnAuthEncrCap.NoOfAuthEncrPairSupported; i ++)
2937	{
2938		capability_802_11->AuthEncryptionSupported[i].AuthModeSupported =
2939		(OS_802_11_AUTHENTICATION_MODE)rsnAuthEncrCap.authEncrPairs[i].authenticationMode;
2940
2941		switch (rsnAuthEncrCap.authEncrPairs[i].cipherSuite)
2942		{
2943		case RSN_CIPHER_NONE:
2944			encrStatus = os802_11EncryptionDisabled;
2945			break;
2946
2947		case RSN_CIPHER_WEP:
2948			encrStatus = os802_11WEPEnabled;
2949			break;
2950
2951		case RSN_CIPHER_TKIP:
2952			encrStatus = os802_11Encryption2Enabled;
2953			break;
2954
2955		case RSN_CIPHER_AES_CCMP:
2956			encrStatus = os802_11Encryption3Enabled;
2957			break;
2958
2959		default:
2960			encrStatus = os802_11EncryptionDisabled;
2961			break;
2962
2963		}
2964		capability_802_11->AuthEncryptionSupported[i].EncryptionStatusSupported
2965		= encrStatus;
2966	}
2967
2968	/* Success; return the actual length of the written data */
2969	*Length = neededLength;
2970	return status;
2971
2972}
2973
2974
2975/*-----------------------------------------------------------------------------
2976Routine Name:	Util802PmkidGet
2977Routine Description:
2978Arguments:
2979Return Value:
2980-----------------------------------------------------------------------------*/
2981ULONG Util802PmkidGet(
2982					 PTIWLN_ADAPTER_T pAdapter,
2983					 PUCHAR pData,
2984					 PULONG Length)
2985{
2986	OS_802_11_PMKID         *pPmkidList = (OS_802_11_PMKID *)pData;
2987	TI_STATUS                status = NOK;
2988
2989	/* Check the data buffer size */
2990	if (*Length < sizeof(OS_802_11_PMKID))
2991	{
2992		*Length = (sizeof(OS_802_11_PMKID));
2993		return NOK;
2994	}
2995
2996	NdisZeroMemory(pData, sizeof(OS_802_11_PMKID));
2997	pPmkidList->Length = *Length;
2998
2999	status = UtilGetParam(pAdapter, RSN_PMKID_LIST, pData, *Length);
3000
3001	if (status != OK)
3002	{
3003		if (*Length < (pPmkidList->Length))
3004			*Length = pPmkidList->Length;
3005		else
3006			*Length	= 0;
3007	}
3008    else
3009	{
3010		*Length = pPmkidList->Length;
3011	}
3012
3013	return status;
3014}
3015
3016/*-----------------------------------------------------------------------------
3017Routine Name:	Util802PmkidSet
3018Routine Description:
3019Arguments:
3020Return Value:
3021-----------------------------------------------------------------------------*/
3022ULONG
3023Util802PmkidSet(
3024			   PTIWLN_ADAPTER_T pAdapter,
3025			   PUCHAR pData,
3026			   ULONG Length
3027			   )
3028{
3029	paramInfo_t Param;
3030	TI_STATUS   status;
3031
3032	Param.paramType = RSN_PMKID_LIST;
3033    Param.paramLength = Length;
3034    if( Length > sizeof(Param.content) ) { /* Dm: Security fix */
3035        printk("TI: %s - Security Error\n",__FUNCTION__);
3036        return EXTERNAL_SET_PARAM_DENIED;
3037    }
3038	NdisMoveMemory(&Param.content, pData, Length);
3039
3040	status = configMgr_setParam(pAdapter->CoreHalCtx, &Param);
3041
3042	return(status);
3043}
3044
3045/*-----------------------------------------------------------------------------
3046Routine Name:	Util802FSWAvailableOptionsGet
3047Routine Description:
3048Arguments:
3049Return Value:
3050-----------------------------------------------------------------------------*/
3051ULONG
3052Util802FSWAvailableOptionsGet(
3053							 PTIWLN_ADAPTER_T pAdapter,
3054							 PUCHAR pData,
3055							 PULONG Length)
3056{
3057	ULONG retValue;
3058
3059	if (!Length)
3060	{
3061		*Length = sizeof(ULONG);
3062		return NOK;
3063	}
3064
3065	retValue = UtilGetParam(pAdapter, RSN_WPA_PROMOTE_AVAILABLE_OPTIONS,
3066							pData, sizeof(ULONG));
3067	*Length = sizeof(ULONG);
3068
3069	return retValue;
3070}
3071
3072
3073/*-----------------------------------------------------------------------------
3074Routine Name:	Util802FSWOptionsGet
3075Routine Description:
3076Arguments:
3077Return Value:
3078-----------------------------------------------------------------------------*/
3079ULONG
3080Util802FSWOptionsGet(
3081					PTIWLN_ADAPTER_T pAdapter,
3082					PUCHAR pData,
3083					PULONG Length)
3084{
3085	ULONG retValue;
3086
3087	if (!Length)
3088	{
3089		*Length = sizeof(ULONG);
3090		return NOK;
3091	}
3092
3093	retValue = UtilGetParam(pAdapter, RSN_WPA_PROMOTE_OPTIONS, pData, sizeof(ULONG));
3094
3095	*Length = sizeof(ULONG);
3096	return retValue;
3097}
3098
3099/*-----------------------------------------------------------------------------
3100Routine Name:	Util802FSWOptionsSet
3101Routine Description:
3102Arguments:
3103Return Value:
3104-----------------------------------------------------------------------------*/
3105
3106ULONG
3107Util802FSWOptionsSet(
3108					PTIWLN_ADAPTER_T pAdapter,
3109					PUCHAR pData,
3110					ULONG Length)
3111{
3112	ULONG retValue;
3113
3114	retValue = UtilSetParam(pAdapter, RSN_WPA_PROMOTE_OPTIONS, pData, sizeof(ULONG));
3115
3116	return retValue;
3117}
3118
3119/*-----------------------------------------------------------------------------
3120Routine Name:	UtilWepStatusGet
3121Routine Description:
3122Arguments:
3123Return Value:
3124-----------------------------------------------------------------------------*/
3125ULONG
3126UtilWepStatusGet(
3127				PTIWLN_ADAPTER_T pAdapter,
3128				PUCHAR pData,
3129				PULONG Length
3130				)
3131{
3132	ULONG retValue;
3133
3134	if (!Length)
3135	{
3136		*Length = sizeof(ULONG);
3137		return NOK;
3138	}
3139
3140	retValue = UtilGetParam(pAdapter, RSN_ENCRYPTION_STATUS_PARAM, pData, sizeof(ULONG));
3141
3142	*Length = sizeof(ULONG);
3143	return retValue;
3144
3145}
3146
3147
3148/*-----------------------------------------------------------------------------
3149Routine Name:	UtilWepStatusSet
3150Routine Description:
3151Arguments:
3152Return Value:
3153-----------------------------------------------------------------------------*/
3154ULONG
3155UtilWepStatusSet(
3156				PTIWLN_ADAPTER_T pAdapter,
3157				PUCHAR pData,
3158				ULONG Length
3159				)
3160{
3161	ULONG retValue;
3162	retValue = UtilSetParam(pAdapter, RSN_ENCRYPTION_STATUS_PARAM, pData, sizeof(ULONG));
3163	return retValue;
3164}
3165
3166
3167
3168/*-----------------------------------------------------------------------------
3169Routine Name:	UtilAssociationInfoGet
3170Routine Description:
3171Arguments:
3172Return Value:
3173-----------------------------------------------------------------------------*/
3174ULONG
3175UtilAssociationInfoGet(
3176					  PTIWLN_ADAPTER_T pAdapter,
3177					  PUCHAR pData,
3178					  PULONG Length
3179					  )
3180{
3181	OS_802_11_ASSOCIATION_INFORMATION  *assocInformation;
3182	UINT8 *requestIEs;
3183	UINT8 *responseIEs;
3184	ULONG TotalLength = 0,retValue;
3185	paramInfo_t param;
3186
3187	if (*Length < sizeof(OS_802_11_ASSOCIATION_INFORMATION))
3188	{
3189		PRINT(DBG_IOCTL_LOUD, "...More buffer space needed\n");
3190		return(sizeof(OS_802_11_ASSOCIATION_INFORMATION));
3191	}
3192
3193	param.paramType   = ASSOC_ASSOCIATION_INFORMATION_PARAM;
3194	param.paramLength = *Length;
3195
3196	retValue = configMgr_getParam(pAdapter->CoreHalCtx, &param);
3197
3198	TotalLength =  sizeof(OS_802_11_ASSOCIATION_INFORMATION) +
3199				   param.content.assocAssociationInformation.RequestIELength +
3200				   param.content.assocAssociationInformation.ResponseIELength;
3201
3202	if (TotalLength <= *Length)
3203	{
3204		NdisMoveMemory(pData, (UINT8 *)&param.content, sizeof(OS_802_11_ASSOCIATION_INFORMATION));
3205		assocInformation = (OS_802_11_ASSOCIATION_INFORMATION*)pData;
3206		requestIEs = (UINT8*)pData + sizeof(OS_802_11_ASSOCIATION_INFORMATION);
3207
3208		if (assocInformation->RequestIELength > 0)
3209		{
3210
3211			NdisMoveMemory(requestIEs, (UINT8*)assocInformation->OffsetRequestIEs,
3212						   assocInformation->RequestIELength);
3213
3214			assocInformation->OffsetRequestIEs = sizeof(OS_802_11_ASSOCIATION_INFORMATION);
3215		}
3216
3217		if (assocInformation->ResponseIELength > 0)
3218		{
3219
3220			responseIEs = requestIEs + assocInformation->RequestIELength;
3221
3222			NdisMoveMemory(responseIEs, (UINT8*)assocInformation->OffsetResponseIEs,
3223						   assocInformation->ResponseIELength);
3224
3225			assocInformation->OffsetResponseIEs =
3226			assocInformation->OffsetRequestIEs + assocInformation->RequestIELength;
3227		}
3228
3229		PRINTF(DBG_IOCTL_LOUD, ("UtilAssociationInfoGet: pData=%p, "
3230								"OffsetRequestIEs=0x%lx, OffsetResponseIEs=0x%lx\n",
3231								pData, (long)assocInformation->OffsetRequestIEs,
3232								(long)assocInformation->OffsetResponseIEs));
3233	} else
3234	{
3235		*(PULONG)pData = TotalLength;
3236		PRINT(DBG_IOCTL_LOUD, "...More buffer space needed\n");
3237	}
3238
3239	*Length = TotalLength;
3240	return retValue;
3241
3242}
3243
3244/*-----------------------------------------------------------------------------
3245Routine Name:	UtilCurrentRegDomainGet
3246Routine Description:
3247Arguments:
3248Return Value:
3249-----------------------------------------------------------------------------*/
3250ULONG
3251UtilCurrentRegDomainGet(
3252					   PTIWLN_ADAPTER_T pAdapter,
3253					   PUCHAR pData,
3254					   PULONG Length
3255					   )
3256{
3257	ULONG retValue;
3258
3259	if (!Length)
3260		return NOK;
3261
3262	retValue = UtilGetParam(pAdapter, REGULATORY_DOMAIN_CURRENT_REGULATORY_DOMAIN_PARAM, pData, sizeof(UINT8));
3263
3264	*Length = sizeof(UINT8);
3265
3266	return retValue;
3267}
3268
3269/*-----------------------------------------------------------------------------
3270Routine Name:	Util4xActiveStateGet
3271Routine Description:
3272Arguments:
3273Return Value:
3274-----------------------------------------------------------------------------*/
3275ULONG
3276Util4xActiveStateGet(
3277					PTIWLN_ADAPTER_T pAdapter,
3278					PUCHAR pData,
3279					PULONG Length
3280					)
3281{
3282	ULONG retValue;
3283	retValue = UtilGetParam(pAdapter, CTRL_DATA_FOUR_X_CURRRENT_STATUS_PARAM, pData, sizeof(UINT8));
3284	*Length = sizeof(UINT8);
3285	return retValue;
3286}
3287
3288/*-----------------------------------------------------------------------------
3289Routine Name:	power
3290Routine Description:
3291Arguments:
3292Return Value:
3293-----------------------------------------------------------------------------*/
3294static int power(int x, int y)
3295{
3296	int i = 0,z = 1;
3297
3298	for (i = 0; i < y; i++)
3299		z *= x;
3300
3301	return z;
3302}
3303
3304/*-----------------------------------------------------------------------------
3305Routine Name:	UtilGetSwVersion
3306Routine Description:
3307Arguments:
3308Return Value:
3309-----------------------------------------------------------------------------*/
3310ULONG
3311UtilGetSwVersion(
3312				PTIWLN_ADAPTER_T pAdapter,
3313				PUCHAR pData,
3314				PULONG Length
3315				)
3316{
3317	TIWLN_VERSION* swVer;
3318	ULONG retValue,tmpLen;
3319	UCHAR FwVersion[FW_VERSION_LEN];
3320	e2Version_t EepromVersion;
3321	int i, start = 0, end = 0, temp = 0;
3322
3323	swVer = (TIWLN_VERSION *) pData;
3324
3325	swVer->DrvVersion.major = SW_VERSION_MAJOR;
3326	swVer->DrvVersion.minor = SW_VERSION_MINOR;
3327	swVer->DrvVersion.bugfix = SW_VERSION_PATCH;
3328	swVer->DrvVersion.subld = SW_VERSION_SUBLD;
3329        swVer->DrvVersion.build = SW_VERSION_BUILD;
3330
3331	NdisZeroMemory(&swVer->FWVersion, sizeof(swVer->FWVersion));
3332
3333	UtilGetParam(pAdapter, SITE_MGR_FIRMWARE_VERSION_PARAM, FwVersion, FW_VERSION_LEN);
3334
3335	/* major */
3336	start = end = temp = 4;
3337	while (FwVersion[end++] != '.');
3338	temp = end;
3339	end -= 2;
3340	for (i = end; i>= start; i--)
3341    {
3342		swVer->FWVersion.major += (FwVersion[i] - 0x30)*power(10, end - i);
3343    }
3344
3345
3346	/* minor */
3347	start = end = temp;
3348	while (FwVersion[end++] != '.');
3349	temp = end;
3350	end -= 2;
3351	for (i = end; i>= start; i--)
3352    {
3353		swVer->FWVersion.minor += (FwVersion[i] - 0x30)*power(10, end - i);
3354    }
3355
3356	/* bug fix */
3357	start = end = temp;
3358	while (FwVersion[end++] != '.');
3359	temp = end;
3360	end -= 2;
3361	for (i = end; i>= start; i--)
3362    {
3363		swVer->FWVersion.bugfix += (FwVersion[i] - 0x30)*power(10, end - i);
3364    }
3365
3366
3367    /* build */
3368	start = end = temp;
3369	while (FwVersion[end++] != '.');
3370	temp = end;
3371	end -= 2;
3372	for (i = end; i>= start; i--)
3373    {
3374		swVer->FWVersion.subld += (FwVersion[i] - 0x30)*power(10, end - i);
3375    }
3376
3377	/* minor build */
3378	start = end = temp;
3379	while (FwVersion[end++] != 0);
3380	temp = end;
3381	end -= 2;
3382	for (i = end; i>= start; i--)
3383    {
3384		swVer->FWVersion.build += (FwVersion[i] - 0x30)*power(10, end - i);
3385    }
3386
3387
3388	NdisZeroMemory(&swVer->HWVersion, sizeof(swVer->HWVersion));
3389
3390	retValue = UtilGetParam(pAdapter, SITE_MGR_EEPROM_VERSION_PARAM, (PUCHAR)&EepromVersion, sizeof(e2Version_t));
3391
3392	swVer->HWVersion.major = (UCHAR) EepromVersion.major;
3393	swVer->HWVersion.minor = (UCHAR) EepromVersion.minor;
3394	swVer->HWVersion.bugfix = (UCHAR) EepromVersion.bugfix;
3395
3396	swVer->osNdisVersion  = (TIWLN_MAJOR_VERSION  << 16) + TIWLN_MINOR_VERSION;
3397
3398	tmpLen = sizeof(TIWLN_VERSION);
3399
3400    if (*Length >= sizeof(TIWLN_VERSION_EX)) //TRS:GAA allow larger than needed buffer
3401	{
3402
3403		((PTIWLN_VERSION_EX)swVer)->extVerSign = 2;
3404
3405		((PTIWLN_VERSION_EX)swVer)->NVVersion.bugfix = EepromVersion.last;
3406
3407		((PTIWLN_VERSION_EX)swVer)->NVVersion.minor = EepromVersion.minor;
3408
3409		((PTIWLN_VERSION_EX)swVer)->NVVersion.major =
3410		(UCHAR)EepromVersion.major;
3411
3412		((PTIWLN_VERSION_EX)swVer)->NVVersion.subld =
3413		(UCHAR)EepromVersion.bugfix;
3414
3415		tmpLen = sizeof(TIWLN_VERSION_EX);
3416
3417	}
3418
3419	*Length = tmpLen;
3420
3421	return retValue;
3422}
3423
3424
3425
3426/*-----------------------------------------------------------------------------
3427Routine Name:	UtilRxAntennaSet
3428Routine Description:
3429Arguments:
3430Return Value:
3431-----------------------------------------------------------------------------*/
3432ULONG
3433UtilRxAntennaSet(
3434				PTIWLN_ADAPTER_T pAdapter,
3435				PUCHAR pData,
3436				ULONG Length
3437				)
3438{
3439	ULONG retValue;
3440	retValue = UtilSetParam(pAdapter, HAL_CTRL_RX_ANTENNA_PARAM, pData, sizeof(ULONG));
3441	return retValue;
3442}
3443
3444
3445/*-----------------------------------------------------------------------------
3446Routine Name:	UtilRxAntennaGet
3447Routine Description:
3448Arguments:
3449Return Value:
3450-----------------------------------------------------------------------------*/
3451ULONG
3452UtilRxAntennaGet(
3453				PTIWLN_ADAPTER_T pAdapter,
3454				PUCHAR pData,
3455				PULONG Length
3456				)
3457{
3458	ULONG retValue;
3459
3460	if ((!Length) || (*Length == 0))
3461		return NOK;
3462
3463	retValue = UtilGetParam(pAdapter, HAL_CTRL_RX_ANTENNA_PARAM, pData, sizeof(UINT8));
3464	*Length = sizeof(UINT8);
3465	return retValue;
3466}
3467
3468
3469/*-----------------------------------------------------------------------------
3470Routine Name:	UtilTxAntennaSet
3471Routine Description:
3472Arguments:
3473Return Value:
3474-----------------------------------------------------------------------------*/
3475ULONG
3476UtilTxAntennaSet(
3477				PTIWLN_ADAPTER_T pAdapter,
3478				PUCHAR pData,
3479				ULONG Length
3480				)
3481{
3482	ULONG retValue;
3483	retValue = UtilSetParam(pAdapter, HAL_CTRL_TX_ANTENNA_PARAM, pData, sizeof(ULONG));
3484	return retValue;
3485}
3486
3487
3488/*-----------------------------------------------------------------------------
3489Routine Name:	UtilTxAntennaGet
3490Routine Description:
3491Arguments:
3492Return Value:
3493-----------------------------------------------------------------------------*/
3494ULONG
3495UtilTxAntennaGet(
3496				PTIWLN_ADAPTER_T pAdapter,
3497				PUCHAR pData,
3498				PULONG Length
3499				)
3500{
3501	ULONG retValue;
3502
3503	if ((!Length) || (*Length == 0))
3504		return NOK;
3505
3506	retValue = UtilGetParam(pAdapter, HAL_CTRL_TX_ANTENNA_PARAM, pData, sizeof(UINT8));
3507	*Length = sizeof (UINT8);
3508	return retValue;
3509}
3510
3511
3512/*-----------------------------------------------------------------------------
3513Routine Name:	UtilNumberOfAntennas
3514Routine Description:
3515Arguments:
3516Return Value:
3517-----------------------------------------------------------------------------*/
3518ULONG
3519UtilNumberOfAntennas(
3520					PTIWLN_ADAPTER_T pAdapter,
3521					PUCHAR pData,
3522					PULONG Length
3523					)
3524{
3525	if ((!Length) || (*Length == 0))
3526		return NOK;
3527
3528	*(PULONG)pData = 2;
3529	*Length = sizeof(ULONG);
3530	return OK;
3531}
3532
3533/*-----------------------------------------------------------------------------
3534Routine Name:
3535	UtilAntennaDivresitySet
3536Routine Description:
3537Arguments:
3538Return Value:
3539-----------------------------------------------------------------------------*/
3540ULONG
3541UtilAntennaDivresitySet(
3542					   PTIWLN_ADAPTER_T pAdapter,
3543					   PUCHAR pData,
3544					   ULONG Length
3545					   )
3546{
3547
3548	return(UtilSetParam(pAdapter, HAL_CTRL_ANTENNA_DIVERSITY_PARAMS, pData, Length));
3549}
3550
3551/*-----------------------------------------------------------------------------
3552Routine Name:	UtilDriverStatusGet
3553Routine Description:
3554Arguments:
3555Return Value:
3556-----------------------------------------------------------------------------*/
3557ULONG
3558UtilDriverStatusGet(
3559				   PTIWLN_ADAPTER_T pAdapter,
3560				   PUCHAR pData,
3561				   PULONG Length
3562				   )
3563{
3564	ULONG retValue;
3565	retValue = UtilGetParam(pAdapter, DRIVER_STATUS_PARAM, pData, sizeof(ULONG));
3566	*Length = sizeof (ULONG);
3567	return retValue;
3568}
3569
3570
3571/*-----------------------------------------------------------------------------
3572Routine Name:	UtilDriverSuspend
3573Routine Description:
3574Arguments:
3575Return Value:
3576-----------------------------------------------------------------------------*/
3577ULONG
3578UtilDriverSuspend(
3579				 PTIWLN_ADAPTER_T pAdapter,
3580				 PUCHAR pData,
3581				 ULONG Length
3582				 )
3583{
3584	ULONG retValue;
3585	OS_802_11_SSID FakeSsid;
3586	UINT32 loopIndex;
3587
3588	for (loopIndex = 0; loopIndex < MAX_SSID_LEN; loopIndex++)
3589		FakeSsid.Ssid[loopIndex] = (loopIndex+1);
3590
3591	FakeSsid.SsidLength = MAX_SSID_LEN;
3592	retValue = UtilSetSSID(pAdapter, (PUCHAR)&FakeSsid, sizeof(OS_802_11_SSID));
3593
3594	return retValue;
3595
3596}
3597
3598/*-----------------------------------------------------------------------------
3599Routine Name:	UtilDriverStatusSet
3600Routine Description:
3601Arguments:
3602Return Value:
3603-----------------------------------------------------------------------------*/
3604ULONG
3605UtilDriverStatusSet(
3606				   PTIWLN_ADAPTER_T pAdapter,
3607				   PUCHAR pData,
3608				   ULONG Length
3609				   )
3610{
3611	ULONG retValue;
3612
3613	if (*(PULONG)pData)
3614	{
3615		retValue = configMgr_start(pAdapter->CoreHalCtx);
3616	} else
3617	{
3618		retValue = configMgr_stop(pAdapter->CoreHalCtx);
3619	}
3620
3621	return retValue;
3622}
3623
3624
3625/*-----------------------------------------------------------------------------
3626Routine Name:	UtilRssiGet
3627Routine Description:
3628Arguments:
3629Return Value:
3630-----------------------------------------------------------------------------*/
3631ULONG
3632UtilRssiGet(
3633		   PTIWLN_ADAPTER_T pAdapter,
3634		   PUCHAR pData,
3635		   PULONG Length
3636		   )
3637{
3638	TIWLN_STATISTICS pStats;
3639	paramInfo_t Param;
3640	ULONG retValue;
3641
3642	if (!Length)
3643		return NOK;
3644
3645	NdisZeroMemory(&pStats, sizeof(TIWLN_STATISTICS));
3646
3647	Param.paramType = SITE_MGR_GET_SELECTED_BSSID_INFO;
3648	Param.content.pSiteMgrPrimarySiteDesc = &pStats.targetAP;
3649
3650	retValue = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
3651
3652	*(PULONG)pData = pStats.targetAP.Rssi;
3653
3654	*Length = sizeof(ULONG);
3655	return retValue;
3656}
3657
3658
3659/*-----------------------------------------------------------------------------
3660Routine Name:	UtilDeviceSuspend
3661Routine Description:
3662Arguments:
3663Return Value:
3664-----------------------------------------------------------------------------*/
3665VOID
3666UtilDeviceSuspend(
3667				 PTIWLN_ADAPTER_T pAdapter
3668				 )
3669{
3670	configMgr_stop(pAdapter->CoreHalCtx);
3671}
3672
3673
3674/*-----------------------------------------------------------------------------
3675Routine Name:	UtilDeviceResume
3676Routine Description:
3677Arguments:
3678Return Value:
3679-----------------------------------------------------------------------------*/
3680VOID
3681UtilDeviceResume(
3682				PTIWLN_ADAPTER_T pAdapter
3683				)
3684{
3685	configMgr_start(pAdapter->CoreHalCtx);
3686}
3687
3688
3689/*-----------------------------------------------------------------------------
3690Routine Name:	UtilIbssProtectionGet
3691Routine Description:
3692Arguments:
3693Return Value:
3694-----------------------------------------------------------------------------*/
3695ULONG
3696UtilIbssProtectionGet(
3697					 PTIWLN_ADAPTER_T pAdapter,
3698					 PUCHAR pData,
3699					 PULONG Length
3700					 )
3701{
3702	ULONG retValue;
3703	if (!Length)
3704		return NOK;
3705	retValue = UtilGetParam(pAdapter, CTRL_DATA_CURRENT_IBSS_PROTECTION_PARAM, pData, sizeof(ULONG));
3706	*Length = sizeof(ULONG);
3707	return retValue;
3708}
3709
3710
3711/*-----------------------------------------------------------------------------
3712Routine Name:	UtilIbssProtectionSet
3713Routine Description:
3714Arguments:
3715Return Value:
3716-----------------------------------------------------------------------------*/
3717ULONG
3718UtilIbssProtectionSet(
3719					 PTIWLN_ADAPTER_T pAdapter,
3720					 PUCHAR pData,
3721					 ULONG Length
3722					 )
3723{
3724	ULONG retValue;
3725	retValue = UtilSetParam(pAdapter, CTRL_DATA_CURRENT_IBSS_PROTECTION_PARAM, pData, sizeof(ULONG));
3726	return retValue;
3727}
3728
3729
3730/*-----------------------------------------------------------------------------
3731Routine Name:	UtilShortSlotGet
3732Routine Description:
3733Arguments:
3734Return Value:
3735-----------------------------------------------------------------------------*/
3736ULONG
3737UtilShortSlotGet(
3738				PTIWLN_ADAPTER_T pAdapter,
3739				PUCHAR pData,
3740				PULONG Length
3741				)
3742{
3743	ULONG retValue;
3744
3745	if (!Length)
3746		return NOK;
3747
3748	retValue = UtilGetParam(pAdapter, SITE_MGR_DESIRED_SLOT_TIME_PARAM, pData, sizeof(ULONG));
3749	*Length = sizeof (ULONG);
3750	return retValue;
3751}
3752
3753
3754/*-----------------------------------------------------------------------------
3755Routine Name:	UtilShortSlotSet
3756Routine Description:
3757Arguments:
3758Return Value:
3759-----------------------------------------------------------------------------*/
3760ULONG
3761UtilShortSlotSet(
3762				PTIWLN_ADAPTER_T pAdapter,
3763				PUCHAR pData,
3764				ULONG Length
3765				)
3766{
3767	ULONG retValue;
3768	retValue = UtilSetParam(pAdapter, SITE_MGR_DESIRED_SLOT_TIME_PARAM, pData, sizeof(ULONG));
3769	return retValue;
3770}
3771
3772
3773/*-----------------------------------------------------------------------------
3774Routine Name:	UtilExtRatesIeGet
3775Routine Description:
3776Arguments:
3777Return Value:
3778-----------------------------------------------------------------------------*/
3779ULONG
3780UtilExtRatesIeGet(
3781				 PTIWLN_ADAPTER_T pAdapter,
3782				 PUCHAR pData,
3783				 PULONG Length
3784				 )
3785{
3786	ULONG retValue;
3787
3788	if (!Length)
3789		return NOK;
3790
3791	retValue = UtilGetParam(pAdapter, SITE_MGR_USE_DRAFT_NUM_PARAM, pData, sizeof(ULONG));
3792
3793	*Length = sizeof(ULONG);
3794
3795	return retValue;
3796}
3797
3798
3799/*-----------------------------------------------------------------------------
3800Routine Name:	UtilExtRatesIeSet
3801Routine Description:
3802Arguments:
3803Return Value:
3804-----------------------------------------------------------------------------*/
3805ULONG
3806UtilExtRatesIeSet(
3807				 PTIWLN_ADAPTER_T pAdapter,
3808				 PUCHAR pData,
3809				 ULONG Length
3810				 )
3811{
3812	ULONG retValue;
3813	retValue = UtilSetParam(pAdapter, SITE_MGR_USE_DRAFT_NUM_PARAM, pData, sizeof(ULONG));
3814	return retValue;
3815}
3816
3817
3818/*-----------------------------------------------------------------------------
3819Routine Name:	UtilQosSetParams
3820Routine Description:
3821Arguments:
3822Return Value:
3823-----------------------------------------------------------------------------*/
3824ULONG UtilQosSetParams(PTIWLN_ADAPTER_T pAdapter,
3825					   PUCHAR pData,
3826					   ULONG Length)
3827{
3828	ULONG retValue;
3829	retValue = UtilSetParam(pAdapter, QOS_MNGR_SET_OS_PARAMS, pData, Length);
3830	return retValue;
3831}
3832
3833/*-----------------------------------------------------------------------------
3834Routine Name:	UtilQosSetParams
3835Routine Description:
3836Arguments:
3837Return Value:
3838-----------------------------------------------------------------------------*/
3839ULONG UtilQosSetRxTimeOut(PTIWLN_ADAPTER_T pAdapter,
3840						  PUCHAR pData,
3841						  ULONG Length)
3842{
3843	ULONG retValue;
3844	retValue = UtilSetParam(pAdapter, QOS_SET_RX_TIME_OUT, pData, Length);
3845	return retValue;
3846}
3847
3848/*-----------------------------------------------------------------------------
3849Routine Name:	UtilSetDTagToAcMappingTable
3850Routine Description:
3851Arguments:
3852Return Value:
3853-----------------------------------------------------------------------------*/
3854ULONG UtilSetDTagToAcMappingTable(PTIWLN_ADAPTER_T pAdapter,
3855						  		  PUCHAR pData,
3856						  		  ULONG Length)
3857{
3858	ULONG retValue;
3859	retValue = UtilSetParam(pAdapter, TX_DATA_TAG_TO_AC_CLASSIFIER_TABLE, pData, Length);
3860	return retValue;
3861}
3862
3863/*-----------------------------------------------------------------------------
3864Routine Name:	UtilSetVAD
3865Routine Description:
3866Arguments:
3867Return Value:
3868-----------------------------------------------------------------------------*/
3869ULONG UtilSetVAD(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length)
3870{
3871	ULONG retValue;
3872	retValue = UtilSetParam(pAdapter, TX_DATA_SET_VAD, pData, Length);
3873	return retValue;
3874}
3875
3876ULONG UtilGetVAD (PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length)
3877{
3878	ULONG retValue;
3879	retValue = UtilGetParam(pAdapter, TX_DATA_GET_VAD , pData, sizeof(txDataVadTimerParams_t));
3880	*Length = sizeof(txDataVadTimerParams_t);
3881	return retValue;
3882}
3883
3884/*-----------------------------------------------------------------------------
3885Routine Name: UtilRemoveClassifierEntry
3886Routine Description:
3887Arguments:
3888Return Value:
3889-----------------------------------------------------------------------------*/
3890ULONG UtilRemoveClassifierEntry(PTIWLN_ADAPTER_T pAdapter,
3891								PUCHAR ioBuffer,
3892								ULONG inBufLen)
3893{
3894	ULONG retValue;
3895	retValue = UtilSetParam(pAdapter, CTRL_DATA_CLSFR_REMOVE_ENTRY,ioBuffer, inBufLen);
3896	return retValue;
3897}
3898
3899
3900/*-----------------------------------------------------------------------------
3901Routine Name: UtilConfigTxClassifier
3902Routine Description:
3903Arguments:
3904Return Value:
3905-----------------------------------------------------------------------------*/
3906ULONG UtilConfigTxClassifier(PTIWLN_ADAPTER_T pAdapter,
3907							 PUCHAR ioBuffer,
3908							 ULONG inBufLen)
3909{
3910	ULONG retValue;
3911	retValue = UtilSetParam(pAdapter, CTRL_DATA_CLSFR_CONFIG,ioBuffer, inBufLen);
3912	return retValue;
3913}
3914
3915
3916/*-----------------------------------------------------------------------------
3917Routine Name: UtilGetClsfrType
3918Routine Description:
3919Arguments:
3920Return Value:
3921-----------------------------------------------------------------------------*/
3922ULONG UtilGetClsfrType(PTIWLN_ADAPTER_T pAdapter,
3923					   PUCHAR pData,
3924					   PULONG Length)
3925{
3926	ULONG retValue;
3927	retValue = UtilGetParam(pAdapter, CTRL_DATA_CLSFR_TYPE , pData, sizeof(clsfrTypeAndSupport));
3928	*Length = sizeof(clsfrTypeAndSupport);
3929	return retValue;
3930}
3931
3932
3933/*-----------------------------------------------------------------------------
3934Routine Name:	UtilGetAPQosParams
3935Routine Description:
3936Arguments:
3937Return Value:
3938-----------------------------------------------------------------------------*/
3939ULONG UtilGetAPQosParams(PTIWLN_ADAPTER_T pAdapter,
3940						 PUCHAR pData,
3941						 PULONG Length)
3942{
3943	ULONG retValue;
3944	retValue = UtilSetGetParam(pAdapter, QOS_MNGR_AP_QOS_PARAMETERS , pData, sizeof(OS_802_11_AC_QOS_PARAMS));
3945	*Length = sizeof(OS_802_11_AC_QOS_PARAMS);
3946	return(retValue);
3947}
3948
3949
3950/*-----------------------------------------------------------------------------
3951Routine Name:	UtilGetAPQosCapabilities
3952Routine Description:
3953Arguments:
3954Return Value:
3955-----------------------------------------------------------------------------*/
3956ULONG UtilGetAPQosCapabilities(PTIWLN_ADAPTER_T pAdapter,
3957							   PUCHAR pData,
3958							   PULONG Length)
3959{
3960	ULONG retValue;
3961	*Length=sizeof(OS_802_11_AP_QOS_CAPABILITIES_PARAMS);
3962	retValue = UtilGetParam(pAdapter, SITE_MGR_GET_AP_QOS_CAPABILITIES , pData, sizeof(OS_802_11_AP_QOS_CAPABILITIES_PARAMS));
3963	return(retValue);
3964}
3965
3966
3967/*-----------------------------------------------------------------------------
3968Routine Name:	UtilAddTspec
3969Routine Description:
3970Arguments:
3971Return Value:
3972-----------------------------------------------------------------------------*/
3973ULONG UtilAddTspec(PTIWLN_ADAPTER_T pAdapter,
3974				   PUCHAR pData,
3975				   ULONG Length)
3976{
3977	ULONG retValue;
3978	retValue = UtilSetParam(pAdapter, QOS_MNGR_ADD_TSPEC_REQUEST , pData, sizeof(OS_802_11_QOS_TSPEC_PARAMS));
3979	return retValue;
3980}
3981
3982
3983/*-----------------------------------------------------------------------------
3984Routine Name:	UtilGetTspecParams
3985Routine Description:
3986Arguments:
3987Return Value:
3988-----------------------------------------------------------------------------*/
3989ULONG UtilGetTspecParams(PTIWLN_ADAPTER_T pAdapter,
3990						 PUCHAR pData,
3991						 PULONG Length)
3992{
3993	ULONG retValue;
3994	retValue = UtilSetGetParam(pAdapter, QOS_MNGR_OS_TSPEC_PARAMS , pData, sizeof(OS_802_11_QOS_TSPEC_PARAMS));
3995	*Length = sizeof(OS_802_11_QOS_TSPEC_PARAMS);
3996	return retValue;
3997}
3998
3999
4000/*-----------------------------------------------------------------------------
4001Routine Name:	UtilDeleteTspec
4002Routine Description:
4003Arguments:
4004Return Value:
4005-----------------------------------------------------------------------------*/
4006ULONG UtilDeleteTspec(PTIWLN_ADAPTER_T pAdapter,
4007					  PUCHAR pData,
4008					  ULONG Length)
4009{
4010	ULONG retValue;
4011	retValue = UtilSetParam(pAdapter, QOS_MNGR_DEL_TSPEC_REQUEST , pData, sizeof(OS_802_11_QOS_DELETE_TSPEC_PARAMS));
4012	return retValue;
4013}
4014
4015
4016/*-----------------------------------------------------------------------------
4017Routine Name:	UtilGetCurrentAcStatus
4018Routine Description:
4019Arguments:
4020Return Value:
4021-----------------------------------------------------------------------------*/
4022ULONG UtilGetCurrentAcStatus(PTIWLN_ADAPTER_T pAdapter,
4023							 PUCHAR pData,
4024							 PULONG Length)
4025{
4026	ULONG retValue;
4027	retValue = UtilSetGetParam(pAdapter, QOS_MNGR_AC_STATUS , pData, sizeof(OS_802_11_AC_UPSD_STATUS_PARAMS));
4028	*Length = sizeof(OS_802_11_AC_UPSD_STATUS_PARAMS);
4029	return retValue;
4030}
4031
4032
4033/*-----------------------------------------------------------------------------
4034Routine Name:	UtilGetUserPriorityOfStream
4035Routine Description:
4036Arguments:
4037Return Value:
4038-----------------------------------------------------------------------------*/
4039ULONG UtilGetUserPriorityOfStream(PTIWLN_ADAPTER_T pAdapter,
4040								  PUCHAR pData,
4041								  PULONG Length)
4042{
4043	ULONG retValue;
4044	retValue = UtilSetGetParam(pAdapter, CTRL_DATA_GET_USER_PRIORITY_OF_STREAM , pData, sizeof(STREAM_TRAFFIC_PROPERTIES));
4045	*Length = sizeof(STREAM_TRAFFIC_PROPERTIES);
4046	return retValue;
4047}
4048
4049
4050/*-----------------------------------------------------------------------------
4051Routine Name:	UtilSetMediumUsageThreshold
4052Routine Description:
4053Arguments:
4054Return Value:
4055-----------------------------------------------------------------------------*/
4056ULONG UtilSetMediumUsageThreshold(PTIWLN_ADAPTER_T pAdapter,
4057								  PUCHAR pData,
4058								  ULONG Length)
4059{
4060	ULONG retValue;
4061	retValue = UtilSetParam(pAdapter, TX_DATA_SET_MEDIUM_USAGE_THRESHOLD , pData, sizeof(OS_802_11_THRESHOLD_CROSS_PARAMS));
4062	return retValue;
4063}
4064
4065
4066/*-----------------------------------------------------------------------------
4067Routine Name:	UtilSetPhyRateThreshold
4068Routine Description:
4069Arguments:
4070Return Value:
4071-----------------------------------------------------------------------------*/
4072ULONG UtilSetPhyRateThreshold(PTIWLN_ADAPTER_T pAdapter,
4073							  PUCHAR pData,
4074							  ULONG Length)
4075{
4076	ULONG retValue;
4077	retValue = UtilSetParam(pAdapter, QOS_SET_RATE_THRESHOLD , pData, sizeof(OS_802_11_THRESHOLD_CROSS_PARAMS));
4078	return retValue;
4079}
4080
4081
4082/*-----------------------------------------------------------------------------
4083Routine Name:	UtilGetMediumUsageThreshold
4084Routine Description:
4085Arguments:
4086Return Value:
4087-----------------------------------------------------------------------------*/
4088ULONG UtilGetMediumUsageThreshold(PTIWLN_ADAPTER_T pAdapter,
4089								  PUCHAR pData,
4090								  PULONG Length)
4091{
4092	ULONG retValue;
4093	retValue = UtilSetGetParam(pAdapter, TX_DATA_GET_MEDIUM_USAGE_THRESHOLD , pData, sizeof(OS_802_11_THRESHOLD_CROSS_PARAMS));
4094	*Length = sizeof(OS_802_11_THRESHOLD_CROSS_PARAMS);
4095	return retValue;
4096}
4097
4098
4099/*-----------------------------------------------------------------------------
4100Routine Name:	UtilGetPhyRateThreshold
4101Routine Description:
4102Arguments:
4103Return Value:
4104-----------------------------------------------------------------------------*/
4105ULONG UtilGetPhyRateThreshold(PTIWLN_ADAPTER_T pAdapter,
4106							  PUCHAR pData,
4107							  PULONG Length)
4108{
4109	ULONG retValue;
4110	retValue = UtilSetGetParam(pAdapter, QOS_GET_RATE_THRESHOLD , pData, sizeof(OS_802_11_THRESHOLD_CROSS_PARAMS));
4111	*Length = sizeof(OS_802_11_THRESHOLD_CROSS_PARAMS);
4112	return retValue;
4113}
4114
4115
4116/*-----------------------------------------------------------------------------
4117Routine Name:	UtilGetDesiredPsMode
4118Routine Description:
4119Arguments:
4120Return Value:
4121-----------------------------------------------------------------------------*/
4122ULONG UtilGetDesiredPsMode(PTIWLN_ADAPTER_T pAdapter,
4123						   PUCHAR pData,
4124						   PULONG  Length)
4125{
4126	ULONG retValue;
4127	retValue = UtilGetParam(pAdapter, QOS_MNGR_GET_DESIRED_PS_MODE , pData, sizeof(OS_802_11_QOS_DESIRED_PS_MODE));
4128	*Length = sizeof(OS_802_11_QOS_DESIRED_PS_MODE);
4129	return retValue;
4130}
4131
4132
4133/*-----------------------------------------------------------------------------
4134Routine Name:	UtilPollApPackets
4135Routine Description:
4136Arguments:
4137Return Value:
4138-----------------------------------------------------------------------------*/
4139ULONG UtilPollApPackets(PTIWLN_ADAPTER_T pAdapter,
4140						PUCHAR pData,
4141						ULONG Length)
4142{
4143	ULONG retValue;
4144	retValue = configMgr_PollApPackets(pAdapter->CoreHalCtx);
4145	return retValue;
4146}
4147
4148
4149/*-----------------------------------------------------------------------------
4150Routine Name:	UtilPollApPacketsFromAC
4151Routine Description:
4152Arguments:
4153Return Value:
4154-----------------------------------------------------------------------------*/
4155ULONG UtilPollApPacketsFromAC(PTIWLN_ADAPTER_T pAdapter,
4156							  PUCHAR pData,
4157							  ULONG Length)
4158{
4159	ULONG retValue;
4160	retValue = UtilSetParam(pAdapter, TX_DATA_POLL_AP_PACKETS_FROM_AC , (unsigned char *)pData, Length);
4161	return retValue;
4162}
4163
4164
4165/*-----------------------------------------------------------------------------
4166Routine Name:	UtilEnableEvent
4167Routine Description:
4168Arguments:
4169Return Value:
4170-----------------------------------------------------------------------------*/
4171ULONG UtilEnableEvent(PTIWLN_ADAPTER_T pAdapter,
4172					  PUCHAR pData,
4173					  ULONG Length)
4174{
4175	/*UtilSetParam(pAdapter,  , pData, Length);  EITAN TBD */
4176	return PARAM_NOT_SUPPORTED;
4177}
4178
4179
4180/*-----------------------------------------------------------------------------
4181Routine Name:	UtilDisableEvent
4182Routine Description:
4183Arguments:
4184Return Value:
4185-----------------------------------------------------------------------------*/
4186ULONG UtilDisableEvent(PTIWLN_ADAPTER_T pAdapter,
4187					   PUCHAR pData,
4188					   ULONG Length)
4189{
4190	/*UtilSetParam(pAdapter,  , pData, Length);  EITAN TBD */
4191	return PARAM_NOT_SUPPORTED;
4192}
4193
4194
4195/*-----------------------------------------------------------------------------
4196Routine Name:	UtilConfigRSSI
4197Routine Description:
4198Arguments:
4199Return Value:
4200-----------------------------------------------------------------------------*/
4201ULONG UtilConfigRSSI(PTIWLN_ADAPTER_T pAdapter,
4202					 UINT32 pData,
4203					 ULONG Length)
4204{
4205	ULONG retValue;
4206	retValue = UtilSetParam(pAdapter, SITE_MGR_DESIRED_RSSI_THRESHOLD_SET , (unsigned char *)pData, Length);
4207	return retValue;
4208}
4209
4210
4211/*-----------------------------------------------------------------------------
4212Routine Name:	UtilConfigPERLevel
4213Routine Description:
4214Arguments:
4215Return Value:
4216-----------------------------------------------------------------------------*/
4217ULONG UtilConfigPERLevel(PTIWLN_ADAPTER_T pAdapter,
4218						 UINT32 pData,
4219						 ULONG Length)
4220{
4221	ULONG retValue;
4222	retValue = UtilSetParam(pAdapter, SITE_MGR_DESIRED_TX_RATE_PRCT_SET , (unsigned char *)pData, Length);
4223	return retValue;
4224}
4225
4226
4227/*-----------------------------------------------------------------------------
4228Routine Name:	UtilGetDrvCapabilities
4229Routine Description:
4230Arguments:
4231Return Value:
4232-----------------------------------------------------------------------------*/
4233ULONG UtilGetDrvCapabilities(PTIWLN_ADAPTER_T pAdapter,
4234							 PUCHAR pData,
4235							 PULONG Length)
4236{
4237	/*UtilSetParam(pAdapter,  , pData, Length);  EITAN TBD */
4238	return PARAM_NOT_SUPPORTED;
4239}
4240
4241
4242/*-----------------------------------------------------------------------------
4243Routine Name:	UtilGetPrimaryBSSIDInfo
4244Routine Description:
4245Arguments:
4246Return Value:
4247-----------------------------------------------------------------------------*/
4248ULONG UtilGetPrimaryBSSIDInfo(PTIWLN_ADAPTER_T pAdapter,
4249                       PUCHAR pData,
4250                       PULONG Length)
4251{
4252	paramInfo_t Param;
4253	TI_STATUS Status;
4254
4255	if ( *Length < sizeof(OS_802_11_BSSID_EX) )
4256    {
4257		PRINTF(DBG_NDIS_OIDS_ERROR, ("UtilGetPrimaryBSSIDInfo: ERROR Length is:%ld < %d\n",
4258                                         *Length, sizeof(OS_802_11_BSSID)) );
4259        return NOK;
4260    }
4261
4262    Param.paramType = SITE_MGR_PRIMARY_SITE_PARAM;
4263	Param.paramLength = *Length;
4264	Param.content.pSiteMgrSelectedSiteInfo = (OS_802_11_BSSID_EX*)pData;
4265    Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
4266
4267	if(Status != OK) {
4268		PRINTF(DBG_NDIS_OIDS_ERROR, (" UtilGetPrimaryBSSIDInfo: ERROR on return from get param SITE_MGR_PRIMARY_SITE_PARAM\n"));
4269    }
4270    else
4271    {
4272        *Length = Param.paramLength;
4273    }
4274
4275	return Status;
4276}
4277
4278/*-----------------------------------------------------------------------------
4279Routine Name:	UtilGetSelectedBSSIDInfo
4280Routine Description:
4281Arguments:
4282Return Value:
4283-----------------------------------------------------------------------------*/
4284ULONG UtilGetSelectedBSSIDInfo(PTIWLN_ADAPTER_T pAdapter,
4285							   PUCHAR pData,
4286							   PULONG Length)
4287{
4288	paramInfo_t Param;
4289	TI_STATUS Status;
4290
4291	if ( *Length < sizeof(OS_802_11_BSSID_EX) )
4292	{
4293		PRINTF(DBG_NDIS_OIDS_ERROR, ("UtilGetSelectedBSSIDInfo: ERROR Length is:%ld < %d",
4294										 *Length, sizeof(OS_802_11_BSSID)) );
4295		return NOK;
4296	}
4297
4298	Param.paramType = SITE_MGR_GET_SELECTED_BSSID_INFO;
4299	Param.paramLength = *Length;
4300	Param.content.pSiteMgrPrimarySiteDesc = (OS_802_11_BSSID*)pData;
4301	Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
4302
4303	if(Status != OK)
4304        {
4305		PRINTF(DBG_NDIS_OIDS_ERROR, (" UtilGetSelectedBSSIDInfo: ERROR on return from get param SITE_MGR_GET_SELECTED_BSSID_INFO"));
4306	}
4307
4308	return Status;
4309}
4310
4311
4312/*-----------------------------------------------------------------------------
4313Routine Name:	UtilGetDriverState
4314Routine Description:
4315Arguments:
4316Return Value:
4317-----------------------------------------------------------------------------*/
4318ULONG UtilGetDriverState (PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG Length)
4319{
4320	ULONG retValue;
4321	retValue = UtilGetParam(pAdapter, SME_SM_STATE_PARAM , pData, *Length);
4322	*Length = sizeof (ULONG);
4323	return retValue;
4324}
4325
4326
4327/*#ifdef NDIS51_MINIPORT*/
4328
4329/*-----------------------------------------------------------------------------
4330Routine Name:	UtilPrivacyFilterGet
4331Routine Description:
4332Arguments:
4333Return Value:
4334-----------------------------------------------------------------------------*/
4335ULONG
4336UtilPrivacyFilterGet(
4337					PTIWLN_ADAPTER_T pAdapter,
4338					PUCHAR pData,
4339					PULONG Length
4340					)
4341{
4342	ULONG WepStatus,retValue,dataSize;
4343
4344	if (!Length)
4345		return NOK;
4346
4347	dataSize = sizeof (ULONG);
4348	retValue = UtilWepStatusGet(pAdapter, (PUCHAR)&WepStatus, &dataSize);
4349
4350	if (WepStatus)
4351	{
4352		*(PULONG)pData = os802_11PrivFilterAcceptAll;
4353	} else
4354	{
4355		*(PULONG)pData = os802_11PrivFilter8021xWEP;
4356	}
4357	*Length = sizeof (ULONG);
4358
4359	return retValue;
4360}
4361
4362
4363/*-----------------------------------------------------------------------------
4364Routine Name:	UtilPrivacyFilterSet
4365Routine Description:
4366Arguments:
4367Return Value:
4368-----------------------------------------------------------------------------*/
4369ULONG
4370UtilPrivacyFilterSet(
4371					PTIWLN_ADAPTER_T pAdapter,
4372					PUCHAR pData,
4373					ULONG Length
4374					)
4375{
4376	ULONG WepStatus,dataSize,retValue;
4377
4378	dataSize = sizeof(ULONG);
4379	retValue = UtilWepStatusGet(pAdapter, (PUCHAR)&WepStatus, &dataSize);
4380
4381	if ((WepStatus && (*(PULONG)pData == os802_11PrivFilter8021xWEP)) || (retValue != OK))
4382		return NOK;	/* was return -1 */
4383
4384	if ((!WepStatus) && (retValue == OK))
4385	{
4386		*(PULONG)pData = 0;
4387		retValue = UtilSetParam(pAdapter, RX_DATA_EXCLUDE_UNENCRYPTED_PARAM, pData, sizeof(ULONG));
4388	}
4389
4390	return retValue;
4391}
4392
4393
4394
4395/*#endif*/
4396
4397/*-----------------------------------------------------------------------------
4398Routine Name:	UtilReadReg
4399Routine Description:
4400Arguments:
4401Return Value:
4402-----------------------------------------------------------------------------*/
4403ULONG
4404UtilReadReg(
4405		   PTIWLN_ADAPTER_T pAdapter,
4406		   PUCHAR pData,
4407		   PULONG Length
4408		   )
4409{
4410	TIWLN_REG_RW * pReg;
4411
4412	pReg = (TIWLN_REG_RW *) pData;
4413
4414#if defined(TNETW1150)
4415	if (pReg->regAddr >= 0x3C0000)
4416		pReg->regValue = configMgr_ReadPhyRegister(pAdapter->CoreHalCtx, pReg->regAddr);
4417	else
4418		pReg->regValue = configMgr_ReadMacRegister(pAdapter->CoreHalCtx, pReg->regAddr);
4419#else
4420	if (pReg->regAddr >= 0x1000)
4421		pReg->regValue = configMgr_ReadPhyRegister(pAdapter->CoreHalCtx, pReg->regAddr);
4422	else
4423		pReg->regValue = configMgr_ReadMacRegister(pAdapter->CoreHalCtx, pReg->regAddr);
4424#endif
4425
4426
4427#ifdef __LINUX__
4428	print_info("Register %#x=%#x(%d)\n", pReg->regAddr, pReg->regValue, pReg->regValue );
4429#endif
4430	*Length = sizeof(TIWLN_REG_RW);
4431	return OK;
4432}
4433
4434/*-----------------------------------------------------------------------------
4435Routine Name:	UtilWriteReg
4436Routine Description:
4437Arguments:
4438Return Value:
4439-----------------------------------------------------------------------------*/
4440ULONG
4441UtilWriteReg(
4442			PTIWLN_ADAPTER_T pAdapter,
4443			PUCHAR pData,
4444			ULONG Length
4445			)
4446{
4447	TIWLN_REG_RW * pReg;
4448
4449	pReg = (TIWLN_REG_RW *) pData;
4450
4451#if defined(TNETW1150)
4452	if (pReg->regAddr >= 0x3C0000)
4453		configMgr_WritePhyRegister(pAdapter->CoreHalCtx, pReg->regAddr, pReg->regValue);
4454	else
4455		configMgr_WriteMacRegister(pAdapter->CoreHalCtx, pReg->regAddr, pReg->regValue);
4456#else
4457	if (pReg->regAddr >= 0x1000)
4458		configMgr_WritePhyRegister(pAdapter->CoreHalCtx, pReg->regAddr, pReg->regValue);
4459	else
4460		configMgr_WriteMacRegister(pAdapter->CoreHalCtx, pReg->regAddr, pReg->regValue);
4461#endif
4462
4463	return OK;
4464}
4465
4466
4467
4468/*-----------------------------------------------------------------------------
4469Routine Name:	UtilDisassociate
4470Routine Description:
4471Arguments:
4472Return Value:
4473-----------------------------------------------------------------------------*/
4474ULONG
4475UtilDisassociate(
4476				PTIWLN_ADAPTER_T pAdapter,
4477				PUCHAR pData,
4478				ULONG Length
4479				)
4480{
4481	OS_802_11_SSID FakeSsid;
4482	UINT32 loopIndex;
4483	ULONG retValue;
4484
4485	/*
4486	 * Clean up desired SSID value
4487	*/
4488	for (loopIndex = 0; loopIndex < MAX_SSID_LEN; loopIndex++)
4489		FakeSsid.Ssid[loopIndex] = (loopIndex+1);
4490
4491	FakeSsid.SsidLength = MAX_SSID_LEN;
4492
4493	retValue = UtilSetSSID(pAdapter, (PUCHAR)&FakeSsid, sizeof(OS_802_11_SSID));
4494
4495	return retValue;
4496}
4497
4498/*-----------------------------------------------------------------------------
4499Routine Name:	UtilInfoCodeQueryInformation
4500Routine Description:
4501Arguments:
4502Return Value:
4503-----------------------------------------------------------------------------*/
4504ULONG
4505UtilInfoCodeQueryInformation(
4506							PTIWLN_ADAPTER_T pAdapter,
4507							PUCHAR pData,
4508							PULONG Length
4509							)
4510{
4511	UINT32 InfoCode, retVal, PureInfoLength;
4512	ULONG dataSize;
4513	PRINT(DBG_IOCTL_LOUD, "UtilInfoCodeQueryInformation\n");
4514
4515	retVal = OK;
4516
4517	if (*Length<sizeof(InfoCode))
4518	{
4519		*Length = sizeof(ULONG);
4520		return NOK;
4521	}
4522
4523	InfoCode = *((UINT32*)pData);
4524	#ifndef _WINDOWS
4525		PureInfoLength = *Length - sizeof(InfoCode);
4526	#else
4527	#endif
4528
4529	switch (InfoCode)
4530	{
4531	case VAL_TX_POWER_VALUE:
4532		PRINT(DBG_IOCTL_LOUD, "case VAL_TX_POWER_VALUE (100)\n");
4533		retVal = UtilGetTxPowerValue(pAdapter, REGULATORY_DOMAIN_CURRENT_TX_POWER_IN_DBM_PARAM, pData, PureInfoLength);
4534		break;
4535	case VAL_NETWORK_TYPE:
4536		PRINT(DBG_IOCTL_LOUD, "case VAL_NETWORK_TYPE (101)\n");
4537		dataSize = PureInfoLength;
4538		retVal = UtilNetworkTypeInUseGet(pAdapter, pData, &dataSize);
4539		break;
4540	case VAL_AP_TX_POWER_LEVEL:
4541		PRINT(DBG_IOCTL_LOUD, "case VAL_AP_TX_POWER_LEVEL (102)\n");
4542		retVal = UtilGetAPTxPowerLevel(pAdapter, SITE_MGR_AP_TX_POWER_PARAM, pData, PureInfoLength);
4543		break;
4544	case VAL_PACKET_BURSTING:
4545		PRINT(DBG_IOCTL_LOUD, "case VAL_PACKET_BURSTING (106)\n");
4546		retVal = UtilGetPacketBursting(pAdapter, QOS_PACKET_BURST_ENABLE, pData, PureInfoLength);
4547		break;
4548	case VAL_MIXED_MODE:
4549		dataSize = PureInfoLength;
4550		retVal = UtilGetMixedMode(pAdapter, RSN_MIXED_MODE, pData, &dataSize);
4551		break;
4552	case VAL_DEFAULT_KEY_ID:
4553		PRINT(DBG_IOCTL_LOUD, "case VAL_DEFAULT_KEY_ID (110)\n");
4554		dataSize = PureInfoLength;
4555		retVal = UtilGetDefaultKeyId(pAdapter, RSN_DEFAULT_KEY_ID, pData, &dataSize);
4556		break;
4557	default:
4558		PRINT(DBG_IOCTL_LOUD, "case default\n");
4559		break;
4560	}
4561	*Length = PureInfoLength;
4562	return retVal;
4563}
4564
4565/*-----------------------------------------------------------------------------
4566Routine Name:	UtilInfoCodeSetInformation
4567Routine Description:
4568Arguments:
4569Return Value:
4570-----------------------------------------------------------------------------*/
4571ULONG
4572UtilInfoCodeSetInformation(
4573						  PTIWLN_ADAPTER_T pAdapter,
4574						  PUCHAR pData,
4575						  ULONG Length
4576						  )
4577{
4578	UINT32 InfoCode, retVal, PureInfoLength;
4579
4580	PRINT(DBG_IOCTL_LOUD, "UtilInfoCodeSetInformation\n");
4581
4582	if (Length<sizeof(UINT32))
4583		return NOK;
4584
4585	InfoCode = *((UINT32*)pData);
4586	retVal = PureInfoLength = Length - sizeof(InfoCode);
4587
4588	switch (InfoCode)
4589	{
4590	case VAL_TX_POWER_VALUE:
4591		PRINT(DBG_IOCTL_LOUD, "case VAL_TX_POWER_VALUE (100)\n");
4592		retVal = UtilSetParam(pAdapter, REGULATORY_DOMAIN_CURRENT_TX_POWER_IN_DBM_PARAM, pData+sizeof(InfoCode), PureInfoLength);
4593		break;
4594	case VAL_NETWORK_TYPE:
4595		PRINT(DBG_IOCTL_LOUD, "case VAL_NETWORK_TYPE (101)\n");
4596		retVal = UtilNetworkTypeInUseSet(pAdapter, pData+sizeof(InfoCode), PureInfoLength);
4597		break;
4598	case VAL_PACKET_BURSTING:
4599		PRINT(DBG_IOCTL_LOUD, "case VAL_PACKET_BURSTING (106)\n");
4600		retVal = UtilSetPacketBursting(pAdapter, pData+sizeof(InfoCode), PureInfoLength);
4601		break;
4602	case VAL_MIXED_MODE:
4603		retVal = UtilSetMixedMode(pAdapter, pData+sizeof(InfoCode), PureInfoLength);
4604		break;
4605	case VAL_DEFAULT_KEY_ID:
4606		retVal = UtilSetParam(pAdapter, RSN_DEFAULT_KEY_ID, pData+sizeof(InfoCode), PureInfoLength);
4607		break;
4608	default:
4609		PRINT(DBG_IOCTL_LOUD, "case default\n");
4610		break;
4611	}
4612	return retVal;
4613}
4614
4615#ifdef _WINDOWS
4616#endif /* _WINDOWS */
4617
4618/*-----------------------------------------------------------------------------
4619Routine Name:	UtilTxPowerLevelDbmGet
4620Routine Description:
4621Arguments:
4622Return Value:
4623-----------------------------------------------------------------------------*/
4624ULONG
4625UtilTxPowerLevelDbmGet(
4626					  PTIWLN_ADAPTER_T pAdapter,
4627					  PUCHAR pData,
4628					  PULONG Length
4629					  )
4630{
4631	ULONG retValue;
4632
4633	if (!Length)
4634		return NOK;
4635
4636	retValue = UtilGetParam(pAdapter, REGULATORY_DOMAIN_CURRENT_TX_POWER_IN_DBM_PARAM, pData, sizeof(UINT8));
4637	*Length = sizeof(INT8);
4638
4639	return retValue;
4640}
4641
4642
4643/*-----------------------------------------------------------------------------
4644Routine Name:	UtilTxPowerLevelDbmSet
4645Routine Description:
4646Arguments:
4647Return Value:
4648-----------------------------------------------------------------------------*/
4649ULONG
4650UtilTxPowerLevelDbmSet(
4651					  PTIWLN_ADAPTER_T pAdapter,
4652					  PUCHAR pData,
4653					  ULONG Length
4654					  )
4655{
4656ULONG mW, Dbm, power,retValue;
4657
4658	if (!Length)
4659		return NOK;
4660
4661	mW = *(PULONG)pData;
4662
4663	for (power=1; mW/10; mW/=10, power++);
4664
4665	Dbm = 20 * power;
4666
4667
4668	retValue = UtilSetParam(pAdapter, REGULATORY_DOMAIN_CURRENT_TX_POWER_IN_DBM_PARAM, (PUCHAR)&Dbm, sizeof(ULONG));
4669	return retValue;
4670}
4671
4672/*-----------------------------------------------------------------------------
4673Routine Name:	Util802EapTypeGet
4674Routine Description:
4675Arguments:
4676Return Value:
4677-----------------------------------------------------------------------------*/
4678ULONG
4679Util802EapTypeGet(
4680				 PTIWLN_ADAPTER_T pAdapter,
4681				 PUCHAR pData,
4682				 PULONG Length
4683				 )
4684{
4685	ULONG retValue;
4686	retValue = UtilGetParam(pAdapter, RSN_EAP_TYPE, pData, sizeof(ULONG));
4687	*Length = sizeof(ULONG);
4688	return retValue;
4689}
4690
4691/*-----------------------------------------------------------------------------
4692Routine Name:	Util802EapTypeSet
4693Routine Description:
4694Arguments:
4695Return Value:
4696-----------------------------------------------------------------------------*/
4697ULONG
4698Util802EapTypeSet(
4699				 PTIWLN_ADAPTER_T pAdapter,
4700				 PUCHAR pData,
4701				 ULONG Length
4702				 )
4703{
4704	ULONG retValue;
4705	retValue = UtilSetParam(pAdapter, RSN_EAP_TYPE, pData, sizeof(ULONG));
4706	return retValue;
4707}
4708
4709#ifdef EXC_MODULE_INCLUDED
4710
4711/*-----------------------------------------------------------------------------
4712Routine Name:	UtilExcConfigurationGet
4713Routine Description:
4714Arguments:
4715Return Value:
4716-----------------------------------------------------------------------------*/
4717ULONG
4718UtilExcConfigurationGet(
4719					   PTIWLN_ADAPTER_T pAdapter,
4720					   PUCHAR pData,
4721					   PULONG Length
4722					   )
4723{
4724	ULONG retValue;
4725	retValue = UtilGetParam(pAdapter, EXC_CONFIGURATION, pData, sizeof(ULONG));
4726	*Length = sizeof(ULONG);
4727	return retValue;
4728}
4729
4730/*-----------------------------------------------------------------------------
4731Routine Name:	UtilExcNetworkEapGet
4732Routine Description:
4733Arguments:
4734Return Value:
4735-----------------------------------------------------------------------------*/
4736ULONG
4737UtilExcNetworkEapGet(
4738					PTIWLN_ADAPTER_T pAdapter,
4739					PUCHAR pData,
4740					PULONG Length
4741					)
4742{
4743	ULONG retValue;
4744	retValue = UtilGetParam(pAdapter, RSN_EXC_NETWORK_EAP, pData, sizeof(ULONG));
4745	*Length = sizeof(ULONG);
4746	return retValue;
4747}
4748
4749/*-----------------------------------------------------------------------------
4750Routine Name:	UtilExcConfigurationSet
4751Routine Description:
4752Arguments:
4753Return Value:
4754-----------------------------------------------------------------------------*/
4755ULONG
4756UtilExcConfigurationSet(
4757					   PTIWLN_ADAPTER_T pAdapter,
4758					   PUCHAR pData,
4759					   ULONG Length
4760					   )
4761{
4762	ULONG retValue;
4763	retValue = UtilSetParam(pAdapter, EXC_CONFIGURATION, pData, sizeof(ULONG));
4764	return retValue;
4765}
4766
4767/*-----------------------------------------------------------------------------
4768Routine Name:	UtilExcNetworkEapSet
4769Routine Description:
4770Arguments:
4771Return Value:
4772-----------------------------------------------------------------------------*/
4773ULONG
4774UtilExcNetworkEapSet(
4775					PTIWLN_ADAPTER_T pAdapter,
4776					PUCHAR pData,
4777					ULONG Length
4778					)
4779{
4780	ULONG retValue;
4781	retValue = UtilSetParam(pAdapter, RSN_EXC_NETWORK_EAP, pData, sizeof(ULONG));
4782	return retValue;
4783}
4784
4785
4786/*-----------------------------------------------------------------------------
4787Routine Name: UtilExcRogueApDetectedSet
4788Routine Description:
4789Arguments:
4790Return Value:
4791-----------------------------------------------------------------------------*/
4792ULONG
4793UtilExcRogueApDetectedSet(
4794						 PTIWLN_ADAPTER_T pAdapter,
4795						 PUCHAR pData,
4796						 ULONG Length
4797						 )
4798{
4799	ULONG retValue;
4800	retValue = UtilSetParam(pAdapter, EXC_ROGUE_AP_DETECTED, pData, sizeof(OS_EXC_ROGUE_AP_DETECTED));
4801	return retValue;
4802}
4803
4804/*-----------------------------------------------------------------------------
4805Routine Name:	UtilExcReportRogueApSet
4806Routine Description:
4807Arguments:
4808Return Value:
4809-----------------------------------------------------------------------------*/
4810ULONG
4811UtilExcReportRogueApSet(
4812					   PTIWLN_ADAPTER_T pAdapter,
4813					   PUCHAR pData,
4814					   ULONG Length
4815					   )
4816{
4817	ULONG retValue;
4818	retValue = UtilSetParam(pAdapter, EXC_REPORT_ROGUE_APS, pData, 0);
4819	return retValue;
4820}
4821
4822/*-----------------------------------------------------------------------------
4823Routine Name:	UtilExcAuthSuccessSet
4824Routine Description:
4825Arguments:
4826Return Value:
4827-----------------------------------------------------------------------------*/
4828ULONG
4829UtilExcAuthSuccessSet(
4830					 PTIWLN_ADAPTER_T pAdapter,
4831					 PUCHAR pData,
4832					 ULONG Length
4833					 )
4834{
4835	ULONG retValue;
4836	retValue = UtilSetParam(pAdapter, EXC_AUTH_SUCCESS, pData, sizeof(OS_EXC_AUTH_SUCCESS));
4837	return retValue;
4838}
4839
4840
4841/*-----------------------------------------------------------------------------
4842Routine Name:	UtilExcCckmRequestSet
4843Routine Description:
4844Arguments:
4845Return Value:
4846-----------------------------------------------------------------------------*/
4847ULONG
4848UtilExcCckmRequestSet(
4849					 PTIWLN_ADAPTER_T pAdapter,
4850					 PUCHAR pData,
4851					 ULONG Length
4852					 )
4853{
4854	ULONG retValue;
4855
4856	OS_EXC_CCKM_REQUEST *cckmRequest = (OS_EXC_CCKM_REQUEST*)pData;
4857	ULONG reqLength = cckmRequest->AssociationRequestIELength+sizeof(cckmRequest->RequestCode)+sizeof(cckmRequest->AssociationRequestIELength);
4858
4859	PRINTF(DBG_IOCTL_LOUD, ("UtilExcCckmRequestSet, In Length = %d, Required Length=%d\n",
4860							(int) Length, (int) reqLength));
4861
4862	if ((cckmRequest==NULL) || (reqLength > Length))
4863	{
4864		PRINTF(DBG_IOCTL_LOUD, ("UtilExcCckmRequestSet, wrong size or pointer, In Length = %d, Required Length=%d\n",
4865								(int) Length, (int) reqLength));
4866		return NOK;
4867	}
4868	retValue = UtilSetParam(pAdapter, EXC_CCKM_REQUEST, pData, reqLength);
4869	return retValue;
4870}
4871
4872
4873/*-----------------------------------------------------------------------------
4874Routine Name:	UtilExcCckmResultSet
4875Routine Description:
4876Arguments:
4877Return Value:
4878-----------------------------------------------------------------------------*/
4879ULONG
4880UtilExcCckmResultSet(
4881					PTIWLN_ADAPTER_T pAdapter,
4882					PUCHAR pData,
4883					ULONG Length
4884					)
4885{
4886	ULONG retValue;
4887	retValue = UtilSetParam(pAdapter, EXC_CCKM_RESULT, pData, sizeof(ULONG));
4888	return retValue;
4889}
4890
4891#endif /* EXC_MODULE_INCLUDED */
4892
4893
4894/*-----------------------------------------------------------------------------
4895Routine Name: UtilGetMACAddress
4896Routine Description:
4897Arguments:
4898Return Value:
4899-----------------------------------------------------------------------------*/
4900ULONG
4901UtilGetMACAddress(
4902				 PTIWLN_ADAPTER_T pAdapter,
4903				 PUCHAR pData,
4904				 PULONG Length
4905				 )
4906{
4907	ULONG retValue;
4908
4909	if ((*Length) < MAC_ADDR_LEN)
4910	{
4911		*Length = MAC_ADDR_LEN;
4912		return NOK;
4913	}
4914
4915	retValue = UtilGetParam(pAdapter, CTRL_DATA_MAC_ADDRESS, pData, MAC_ADDR_LEN);
4916	*Length = MAC_ADDR_LEN;
4917	return retValue;
4918}
4919
4920
4921/*-----------------------------------------------------------------------------
4922Routine Name:	UtilConfigRoamingParamsSet
4923Routine Description:
4924Arguments:
4925Return Value:
4926-----------------------------------------------------------------------------*/
4927ULONG
4928UtilConfigRoamingParamsSet(
4929						  PTIWLN_ADAPTER_T pAdapter,
4930						  PUCHAR pData,
4931						  ULONG Length
4932						  )
4933{
4934	ULONG retValue;
4935	applicationConfigBuffer_t applicationConfigBuffer;
4936
4937	applicationConfigBuffer.buffer = pData;
4938	applicationConfigBuffer.bufferSize = (UINT16)Length;
4939
4940	retValue = UtilSetParam(pAdapter, ROAMING_MNGR_APPLICATION_CONFIGURATION, (PUCHAR)&applicationConfigBuffer, sizeof(applicationConfigBuffer_t));
4941
4942	return retValue;
4943}
4944
4945/*-----------------------------------------------------------------------------
4946Routine Name:	UtilConfigRoamingParamsGet
4947Routine Description:
4948Arguments:
4949Return Value:
4950-----------------------------------------------------------------------------*/
4951ULONG
4952UtilConfigRoamingParamsGet(
4953						  PTIWLN_ADAPTER_T pAdapter,
4954						  PUCHAR pData,
4955						  PULONG Length
4956						  )
4957{
4958	ULONG retValue;
4959	retValue = UtilGetParam(pAdapter, ROAMING_MNGR_APPLICATION_CONFIGURATION, pData, *Length);
4960	return retValue;
4961}
4962
4963
4964/*-----------------------------------------------------------------------------
4965Routine Name:	UtilMeasurementEnableDisableParamsSet
4966Routine Description:
4967Arguments:
4968Return Value:
4969-----------------------------------------------------------------------------*/
4970ULONG
4971UtilMeasurementEnableDisableParamsSet(
4972									 PTIWLN_ADAPTER_T pAdapter,
4973									 PUCHAR pData,
4974									 ULONG Length
4975									 )
4976{
4977	ULONG retValue;
4978	retValue = UtilSetParam(pAdapter, MEASUREMENT_ENABLE_DISABLE_PARAM, pData, Length);
4979	return retValue;
4980}
4981
4982/*-----------------------------------------------------------------------------
4983Routine Name:	UtilMeasurementMaxDurationParamsSet
4984Routine Description:
4985Arguments:
4986Return Value:
4987-----------------------------------------------------------------------------*/
4988ULONG
4989UtilMeasurementMaxDurationParamsSet(
4990								   PTIWLN_ADAPTER_T pAdapter,
4991								   PUCHAR pData,
4992								   ULONG Length
4993								   )
4994{
4995	ULONG retValue;
4996	retValue = UtilSetParam(pAdapter, MEASUREMENT_MAX_DURATION_PARAM, pData, sizeof(UINT32));
4997	return retValue;
4998}
4999
5000/*-----------------------------------------------------------------------------
5001Routine Name:	UtilEarlyWakeupIeGet
5002Routine Description:
5003Arguments:
5004Return Value:
5005-----------------------------------------------------------------------------*/
5006ULONG
5007UtilEarlyWakeupIeGet(
5008				 PTIWLN_ADAPTER_T pAdapter,
5009				 PUCHAR pData,
5010				 PULONG Length
5011				 )
5012{
5013	ULONG retValue;
5014
5015	if (!Length)
5016		return NOK;
5017
5018	retValue = UtilGetParam(pAdapter, HAL_CTRL_EARLY_WAKEUP, pData, sizeof(UINT8));
5019
5020	*Length = sizeof(UINT8);
5021
5022	return retValue;
5023}
5024
5025
5026/*-----------------------------------------------------------------------------
5027Routine Name:	UtilEarlyWakeupIeSet
5028Routine Description:
5029Arguments:
5030Return Value:
5031-----------------------------------------------------------------------------*/
5032ULONG
5033UtilEarlyWakeupIeSet(
5034				 PTIWLN_ADAPTER_T pAdapter,
5035				 PUCHAR pData,
5036				 ULONG Length
5037				 )
5038{
5039	ULONG retValue;
5040	retValue = UtilSetParam(pAdapter, HAL_CTRL_EARLY_WAKEUP, pData, sizeof(ULONG));
5041	return retValue;
5042}
5043
5044
5045
5046/*-----------------------------------------------------------------------------
5047Routine Name:	UtilBthWlanCoeEnable
5048Routine Description:
5049Arguments:
5050Return Value:
5051-----------------------------------------------------------------------------*/
5052ULONG
5053UtilBthWlanCoeEnable(
5054					PTIWLN_ADAPTER_T pAdapter,
5055					PUCHAR pData,
5056					ULONG Length
5057					)
5058{
5059	ULONG retValue;
5060	retValue = UtilSetParam(pAdapter, SOFT_GEMINI_SET_ENABLE, pData, sizeof(ULONG));
5061	return retValue;
5062}
5063
5064/*-----------------------------------------------------------------------------
5065Routine Name:	UtilBthWlanCoeRate
5066Routine Description:
5067Arguments:
5068Return Value:
5069-----------------------------------------------------------------------------*/
5070ULONG
5071UtilBthWlanCoeRate(
5072				  PTIWLN_ADAPTER_T pAdapter,
5073				  PUCHAR pData,
5074				  ULONG Length
5075				  )
5076{
5077	ULONG retValue;
5078	retValue = UtilSetParam(pAdapter, SOFT_GEMINI_SET_RATE, pData, sizeof(ULONG)*NUM_OF_RATES_IN_SG);
5079	return retValue;
5080}
5081
5082
5083/*-----------------------------------------------------------------------------
5084Routine Name:	UtilBthWlanCoeConfig
5085Routine Description:
5086Arguments:
5087Return Value:
5088-----------------------------------------------------------------------------*/
5089ULONG
5090UtilBthWlanCoeConfig(
5091					PTIWLN_ADAPTER_T pAdapter,
5092					PUCHAR pData,
5093					ULONG Length
5094					)
5095{
5096	ULONG retValue;
5097	retValue = UtilSetParam(pAdapter, SOFT_GEMINI_SET_CONFIG, pData, sizeof(ULONG) * NUM_OF_CONFIG_PARAMS_IN_SG);
5098	return retValue;
5099}
5100
5101
5102/*-----------------------------------------------------------------------------
5103Routine Name:	UtilBthWlanCoeGetStatus
5104Routine Description:
5105Arguments:
5106Return Value:
5107-----------------------------------------------------------------------------*/
5108ULONG
5109UtilBthWlanCoeGetStatus(
5110					   PTIWLN_ADAPTER_T pAdapter,
5111					   PUCHAR pData,
5112					   PULONG Length
5113					   )
5114{
5115	ULONG retValue;
5116	retValue = UtilGetParam(pAdapter, SOFT_GEMINI_GET_STATUS, pData, 0);
5117	*Length = 0;
5118	return retValue;
5119}
5120
5121
5122/*-----------------------------------------------------------------------------
5123Routine Name: UtilPltRxPerStart
5124Routine Description:
5125Arguments:
5126Return Value:
5127-----------------------------------------------------------------------------*/
5128ULONG
5129UtilPltRxPerStart(
5130				 PTIWLN_ADAPTER_T pAdapter,
5131				 PUCHAR pData,
5132				 ULONG Length
5133				 )
5134{
5135	ULONG Status;
5136	interogateCmdCBParams_t interogateCmdCBParams;
5137	memset(&(pAdapter->IoCompleteBuff[0]) , 0xFF , MAX_IO_BUFFER_COMPLETE_SIZE );
5138
5139	/* Fill the IOCTL struct to the Command Mailbox by giving a stack parameter */
5140	interogateCmdCBParams.CB_handle  =  (TI_HANDLE)pAdapter;
5141	interogateCmdCBParams.CB_Func    =  NULL;
5142	interogateCmdCBParams.CB_buf     =  NULL;
5143	Status = UtilSetParam(pAdapter, HAL_CTRL_PLT_RX_PER_START, (PUCHAR)&interogateCmdCBParams, sizeof(interogateCmdCBParams));
5144
5145	return Status;
5146}
5147
5148/*-----------------------------------------------------------------------------
5149Routine Name: UtilPltRxPerStop
5150Routine Description:
5151Arguments:
5152Return Value:
5153-----------------------------------------------------------------------------*/
5154ULONG
5155UtilPltRxPerStop(
5156				PTIWLN_ADAPTER_T pAdapter,
5157				PUCHAR pData,
5158				ULONG Length
5159				)
5160{
5161	ULONG Status;
5162	interogateCmdCBParams_t interogateCmdCBParams;
5163
5164	/* Fill the IOCTL struct to the Command Mailbox by giving a stack parameter */
5165	interogateCmdCBParams.CB_handle  =  (TI_HANDLE)pAdapter;
5166	interogateCmdCBParams.CB_Func    =  NULL;
5167	interogateCmdCBParams.CB_buf     =  NULL;
5168	Status = UtilSetParam(pAdapter, HAL_CTRL_PLT_RX_PER_STOP, (PUCHAR)&interogateCmdCBParams, sizeof(interogateCmdCBParams));
5169	return Status;
5170}
5171
5172/*-----------------------------------------------------------------------------
5173Routine Name: UtilPltRxPerClear
5174Routine Description:
5175Arguments:
5176Return Value:
5177-----------------------------------------------------------------------------*/
5178ULONG
5179UtilPltRxPerClear(
5180				 PTIWLN_ADAPTER_T pAdapter,
5181				 PUCHAR pData,
5182				 ULONG Length
5183				 )
5184{
5185	ULONG Status;
5186	interogateCmdCBParams_t interogateCmdCBParams;
5187	memset(&(pAdapter->IoCompleteBuff[0]) , 0xFF , MAX_IO_BUFFER_COMPLETE_SIZE );
5188
5189	/* Fill the IOCTL struct to the Command Mailbox by giving a stack parameter */
5190	interogateCmdCBParams.CB_handle  =  (TI_HANDLE)pAdapter;
5191	interogateCmdCBParams.CB_Func    =  NULL;
5192	interogateCmdCBParams.CB_buf     =  NULL;
5193	Status = UtilSetParam(pAdapter, HAL_CTRL_PLT_RX_PER_CLEAR, (PUCHAR)&interogateCmdCBParams, sizeof(interogateCmdCBParams));
5194	return Status;
5195}
5196
5197/*-----------------------------------------------------------------------------
5198Routine Name: UtilPltRxPerGetResults
5199Routine Description:
5200Arguments:
5201Return Value:
5202-----------------------------------------------------------------------------*/
5203ULONG
5204UtilPltRxPerGetResults(
5205					  PTIWLN_ADAPTER_T pAdapter,
5206					  PUCHAR pData,
5207					  PULONG pLength
5208					  )
5209{
5210
5211	ULONG Status;
5212	paramInfo_t Param;
5213	interogateCmdCBParams_t* pInterogateCmdCBParams = &Param.content.interogateCmdCBParams;
5214
5215	memset(&(pAdapter->IoCompleteBuff[0]) , 0xFF , MAX_IO_BUFFER_COMPLETE_SIZE );
5216
5217	/* To implement the Async IOCTL store the user buffer pointer to be filled at
5218	the Command Completion calback */
5219	pAdapter->pIoBuffer =  pData;
5220	pAdapter->pIoCompleteBuffSize =  pLength ;
5221
5222
5223	/* Fill the IOCTL struct to the Command Mailbox by giving a stack parameter */
5224	pInterogateCmdCBParams->CB_handle  =  (TI_HANDLE)pAdapter;
5225	pInterogateCmdCBParams->CB_Func    =  (PVOID)UtilPltRxPerCB;
5226	pInterogateCmdCBParams->CB_buf     =  &(pAdapter->IoCompleteBuff[0]);
5227
5228	Param.paramType = HAL_CTRL_PLT_RX_PER_GET_RESULTS;
5229	Param.paramLength = sizeof(interogateCmdCBParams_t);
5230
5231	Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
5232
5233	return Status;
5234}
5235
5236
5237/*-----------------------------------------------------------------------------
5238Routine Name:	UtilPltRxPerCB
5239
5240Routine Description: This is the CB triggered when  PltRX command been
5241					returned by FW.
5242Arguments:
5243
5244Return Value:
5245-----------------------------------------------------------------------------*/
5246VOID UtilPltRxPerCB(TI_HANDLE hAdapter,TI_STATUS status,PUINT8 pReadBuff)
5247{
5248	HwMboxCmdBit_RxPer_t* pRxPer =  (HwMboxCmdBit_RxPer_t* )pReadBuff;
5249	PTIWLN_ADAPTER_T pAdapter = (PTIWLN_ADAPTER_T)hAdapter;
5250
5251	if (pRxPer->CB_RxPerCmd == PLT_RX_PER_GETRESULTS)
5252	{
5253		*(pAdapter->pIoCompleteBuffSize) = sizeof(pRxPer->PltRxPer);
5254		os_memoryCopy(hAdapter, (void*)&(pAdapter->pIoBuffer[0]) ,(void*) &(pRxPer->PltRxPer) , *(pAdapter->pIoCompleteBuffSize));
5255		/* Call back the Completion that will indicate to the user that the buffer is ready to be read */
5256		os_IoctlComplete(pAdapter, status);
5257
5258	}
5259}
5260
5261/*-----------------------------------------------------------------------------
5262Routine Name: UtilPltTxCW
5263Routine Description:
5264Arguments:
5265Return Value:
5266-----------------------------------------------------------------------------*/
5267ULONG UtilPltTxCW(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length)
5268{
5269	ULONG retValue;
5270	retValue = UtilSetParam(pAdapter, HAL_CTRL_PLT_TX_CW, pData, Length);
5271	return retValue;
5272}
5273/*-----------------------------------------------------------------------------
5274Routine Name: UtilPltTxContinues
5275Routine Description:
5276Arguments:
5277Return Value:
5278-----------------------------------------------------------------------------*/
5279ULONG UtilPltTxContinues(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length)
5280{
5281	ULONG retValue;
5282	retValue = UtilSetParam(pAdapter, HAL_CTRL_PLT_TX_CONTINUES, pData, Length);
5283	return retValue;
5284}
5285
5286/*-----------------------------------------------------------------------------
5287Routine Name: UtilPltTxStop
5288Routine Description:
5289Arguments:
5290Return Value:
5291-----------------------------------------------------------------------------*/
5292ULONG UtilPltTxStop(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length)
5293{
5294	ULONG retValue;
5295	retValue = UtilSetParam(pAdapter, HAL_CTRL_PLT_TX_STOP, pData, 0);
5296	return retValue;
5297}
5298
5299/*-----------------------------------------------------------------------------
5300Routine Name: UtilPltWriteMib
5301Routine Description:
5302Arguments:
5303Return Value:
5304-----------------------------------------------------------------------------*/
5305ULONG UtilPltWriteMib(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, ULONG Length)
5306{
5307	ULONG retValue;
5308	retValue = UtilSetParam(pAdapter, HAL_CTRL_PLT_WRITE_MIB, pData, Length);
5309	return retValue;
5310}
5311/*-----------------------------------------------------------------------------
5312Routine Name: UtilPltReadMib
5313Routine Description:
5314Arguments:
5315Return Value:
5316-----------------------------------------------------------------------------*/
5317ULONG UtilPltReadMib(PTIWLN_ADAPTER_T pAdapter, PUCHAR pData, PULONG pOutLength, ULONG InLength)
5318{
5319	ULONG Status;
5320	paramInfo_t Param;
5321
5322	/* To implement the Async IOCTL store the user buffer pointer to be filled at
5323	the Command Completion calback */
5324	pAdapter->pIoBuffer =  pData;
5325	pAdapter->pIoCompleteBuffSize =  pOutLength;
5326
5327	os_memoryCopy((TI_HANDLE)pAdapter, (PVOID)pAdapter->IoCompleteBuff, pData, InLength);
5328
5329	/* Fill the IOCTL struct to the Command Mailbox by giving a stack parameter */
5330	Param.content.interogateCmdCBParams.CB_handle  =  (TI_HANDLE)pAdapter;
5331	Param.content.interogateCmdCBParams.CB_Func  =  (PVOID)UtilPltReadMibCB;
5332	Param.content.interogateCmdCBParams.CB_buf  =  pAdapter->IoCompleteBuff;
5333
5334	Param.paramType = HAL_CTRL_PLT_READ_MIB;
5335	Param.paramLength = sizeof(interogateCmdCBParams_t);
5336	Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
5337
5338	return Status;
5339}
5340
5341
5342/*-----------------------------------------------------------------------------
5343Routine Name:	UtilPltReadMibCB
5344
5345Routine Description: This is the CB triggered when  PltReadRegister command been
5346					returned by FW.
5347Arguments:
5348
5349Return Value:
5350-----------------------------------------------------------------------------*/
5351VOID UtilPltReadMibCB(TI_HANDLE hAdapter,TI_STATUS status,PUINT8 pReadBuff)
5352{
5353	PTIWLN_ADAPTER_T pAdapter = (PTIWLN_ADAPTER_T)hAdapter;
5354	PLT_MIB_t* pReturnMib = (PLT_MIB_t*)pAdapter->pIoBuffer;
5355	tiBOOL IsAsync = TRUE;
5356
5357	switch (pReturnMib->aMib)
5358	{
5359	case PLT_MIB_dot11StationId:
5360		{
5361			dot11StationIDStruct* pdot11StationID = (dot11StationIDStruct*)pReadBuff;
5362			pReturnMib->Length = sizeof(pReturnMib->aData.StationId);
5363			os_memoryCopy(hAdapter, (PVOID)pReturnMib->aData.StationId.addr, (PVOID)pdot11StationID->dot11StationID, sizeof(pReturnMib->aData.StationId));
5364		}
5365		break;
5366
5367	case PLT_MIB_countersTable:
5368		{
5369			ACXErrorCounters_t* pACXErrorCounters = (ACXErrorCounters_t*)pReadBuff;
5370			pReturnMib->Length = sizeof(pReturnMib->aData.CounterTable);
5371			pReturnMib->aData.CounterTable.FCSErrorCount = pACXErrorCounters->FCSErrorCount;
5372			pReturnMib->aData.CounterTable.PLCPErrorCount = pACXErrorCounters->PLCPErrorCount;
5373		}
5374		break;
5375
5376		/* MIBs with data which is already in pReadBuff and in the correct form. */
5377	case PLT_MIB_ctsToSelf:
5378	case PLT_MIB_dot11MaxReceiveLifetime:
5379	case PLT_MIB_dot11GroupAddressesTable:
5380	case PLT_MIB_arpIpAddressesTable:
5381	case PLT_MIB_rxFilter:
5382	case PLT_MIB_templateFrame:
5383	case PLT_MIB_beaconFilterIETable:
5384	case PLT_MIB_txRatePolicy:
5385		IsAsync = FALSE;
5386		PRINTF(DBG_NDIS_OIDS_LOUD, ("UtilPltReadMibCB:MIB aMib 0x%x \n",pReturnMib->aMib));
5387		os_memoryCopy(hAdapter, (PVOID)pAdapter->pIoBuffer, (PVOID)pAdapter->IoCompleteBuff, sizeof(PLT_MIB_t));
5388		break;
5389	default:
5390		PRINTF(DBG_NDIS_OIDS_LOUD, ("UtilPltReadMibCB:MIB aMib 0x%x Not supported\n",pReturnMib->aMib));
5391	}
5392	/* Call back the Completion that will indicate to the user that the buffer is ready to be read */
5393	if (IsAsync)
5394		os_IoctlComplete(pAdapter, status);
5395}
5396
5397/*-----------------------------------------------------------------------------
5398Routine Name: UtilPltReadRegister
5399Routine Description:
5400Arguments:
5401Return Value:
5402-----------------------------------------------------------------------------*/
5403ULONG
5404UtilPltReadRegister(
5405				   PTIWLN_ADAPTER_T pAdapter,
5406				   PUCHAR pData,
5407				   PULONG Length
5408				   )
5409{
5410
5411	ULONG Status;
5412	paramInfo_t Param;
5413	interogateCmdCBParams_t* pInterogateCmdCBParams = &Param.content.interogateCmdCBParams;
5414	ReadWriteCommand_t* pReadWriteCommandStruct = (ReadWriteCommand_t*)pAdapter->IoCompleteBuff;
5415	UINT32* pRegAdress = (UINT32*)pData;
5416
5417	/* To implement the Async IOCTL store the user buffer pointer to be filled at
5418	the Command Completion calback */
5419	pAdapter->pIoBuffer =  pData;
5420	pAdapter->pIoCompleteBuffSize =  Length ;
5421
5422	memset(&(pAdapter->IoCompleteBuff[0]) , 0xFF , MAX_IO_BUFFER_COMPLETE_SIZE );
5423	pReadWriteCommandStruct->addr = *pRegAdress;
5424	pReadWriteCommandStruct->size = 4;
5425
5426	/* Fill the IOCTL struct to the Command Mailbox by giving a stack parameter */
5427	pInterogateCmdCBParams->CB_handle  =  (TI_HANDLE)pAdapter;
5428	pInterogateCmdCBParams->CB_Func    =  (PVOID)UtilPltReadRegisterCB;
5429	pInterogateCmdCBParams->CB_buf     =  &(pAdapter->IoCompleteBuff[0]) ;
5430
5431	Param.paramType = HAL_CTRL_PLT_READ_REGISTER;
5432	Param.paramLength = sizeof(interogateCmdCBParams_t);
5433
5434	Status = configMgr_getParam(pAdapter->CoreHalCtx, &Param);
5435	return Status;
5436}
5437
5438/*-----------------------------------------------------------------------------
5439Routine Name:	UtilPltReadRegisterCB
5440
5441Routine Description: This is the CB triggered when  PltReadRegister command been
5442					returned by FW.
5443Arguments:
5444
5445Return Value:
5446-----------------------------------------------------------------------------*/
5447VOID UtilPltReadRegisterCB(TI_HANDLE hAdapter,TI_STATUS status,PUINT8 pReadBuff)
5448{
5449	PTIWLN_ADAPTER_T pAdapter = (PTIWLN_ADAPTER_T)hAdapter;
5450	ReadWriteCommand_t* pReadWriteCommandStruct = (ReadWriteCommand_t*)pReadBuff;
5451	UINT32* pRegDataReturn = (UINT32*)pAdapter->pIoBuffer;
5452
5453	*(pAdapter->pIoCompleteBuffSize) = sizeof(INT32);
5454
5455	/*Convert the returned data structure from ReadWriteCommandStruct to UINT32*/
5456	os_memoryCopy(hAdapter, (PVOID)pRegDataReturn, (PVOID)pReadWriteCommandStruct->value, sizeof(UINT32));
5457
5458	/* Call back the Completion that will indicate to the user that the buffer is ready to be read */
5459	os_IoctlComplete(pAdapter, status);
5460}
5461
5462/*-----------------------------------------------------------------------------
5463Routine Name: UtilPltWriteRegister
5464Routine Description:
5465Arguments:
5466Return Value:
5467-----------------------------------------------------------------------------*/
5468ULONG
5469UtilPltWriteRegister(
5470					PTIWLN_ADAPTER_T pAdapter,
5471					PUCHAR pData,
5472					ULONG Length
5473					)
5474{
5475	ReadWriteCommand_t* pReadWriteCommandStruct = (ReadWriteCommand_t*)pAdapter->IoCompleteBuff;
5476	TIWLN_REG_RW* pReg = (TIWLN_REG_RW*)pData;
5477	interogateCmdCBParams_t interogateCmdCBParams;
5478	UINT32 Status;
5479
5480
5481	pReadWriteCommandStruct->addr = pReg->regAddr;
5482	pReadWriteCommandStruct->size = pReg->regSize;
5483	os_memoryCopy((TI_HANDLE)pAdapter, (PVOID)pReadWriteCommandStruct->value, (PVOID)&pReg->regValue, pReadWriteCommandStruct->size);
5484
5485	/* Fill the IOCTL struct to the Command Mailbox by giving a stack parameter */
5486	interogateCmdCBParams.CB_handle  =  (TI_HANDLE)pAdapter;
5487	interogateCmdCBParams.CB_Func    =  NULL;
5488	interogateCmdCBParams.CB_buf     =  pAdapter->IoCompleteBuff;
5489	Status = UtilSetParam(pAdapter, HAL_CTRL_PLT_WRITE_REGISTER, (PUCHAR)&interogateCmdCBParams, sizeof(interogateCmdCBParams));
5490	return Status;
5491}
5492
5493/*-----------------------------------------------------------------------------
5494Routine Name: utilPltRxTxCal
5495Routine Description:
5496Arguments:
5497Return Value:
5498-----------------------------------------------------------------------------*/
5499ULONG UtilPltRxTxCal(
5500				   PTIWLN_ADAPTER_T pAdapter,
5501				   PUCHAR pData,
5502				   PULONG pOutLength,
5503				   ULONG  InLength)
5504
5505{
5506	paramInfo_t Param;
5507	interogateCmdCBParams_t* pInterogateCmdCBParams = &Param.content.interogateCmdCBParams;
5508
5509	/* To implement the Async IOCTL store the user buffer pointer to be filled at
5510	the Command Completion callback */
5511	pAdapter->pIoBuffer =  (PUINT8)pData;
5512	pAdapter->pIoCompleteBuffSize =  pOutLength;
5513
5514	/* Fill the IOCTL struct to the Command Mailbox by giving a stack parameter */
5515	pInterogateCmdCBParams->CB_handle  =  (TI_HANDLE)pAdapter;
5516	pInterogateCmdCBParams->CB_Func    =  (PVOID)UtilPltRxTxCalCB;
5517    pInterogateCmdCBParams->CB_buf     = pAdapter->pIoBuffer;
5518
5519	Param.paramType = HAL_CTRL_PLT_RX_TX_CAL;
5520	Param.paramLength = sizeof(interogateCmdCBParams_t);
5521
5522	return configMgr_getParam(pAdapter->CoreHalCtx, &Param);
5523}
5524
5525/*-----------------------------------------------------------------------------
5526Routine Name:	UtilPltRxTxCalCB
5527
5528Routine Description: This is the CB triggered when  utilPltRxTxCal command been
5529					returned by FW.
5530Arguments:          pReadBuff - Should return the TestCmd_t
5531
5532Return Value:
5533-----------------------------------------------------------------------------*/
5534VOID UtilPltRxTxCalCB(TI_HANDLE hAdapter,TI_STATUS status,PUINT8 pReadBuff)
5535{
5536	PTIWLN_ADAPTER_T pAdapter = (PTIWLN_ADAPTER_T)hAdapter;
5537
5538    *(pAdapter->pIoCompleteBuffSize) = sizeof(TestCmd_t);
5539
5540     /* Call back the Completion that will indicate to the user that the buffer is ready to be read */
5541	os_IoctlComplete(pAdapter, status);
5542}
5543
5544/*-----------------------------------------------------------------------------
5545Routine Name: UtilPltRxCal
5546Routine Description:
5547Arguments:
5548Return Value:
5549-----------------------------------------------------------------------------*/
5550ULONG UtilPltRxCal(
5551                   PTIWLN_ADAPTER_T pAdapter,
5552                   PUCHAR pData,
5553                   PULONG pOutLength,
5554                   ULONG InLength)
5555{
5556    whalParamInfo_t Param;
5557
5558    Param.paramType = HAL_CTRL_PLT_RX_TX_CAL;
5559    Param.paramLength = sizeof(TestCmd_t*);
5560    Param.content.interogateCmdCBParams.CB_Func = NULL;
5561    Param.content.interogateCmdCBParams.CB_handle = NULL;
5562    Param.content.interogateCmdCBParams.CB_buf = (PUINT8)pData;
5563
5564    return configMgr_getParam(pAdapter->CoreHalCtx, (paramInfo_t*)&Param);
5565}
5566
5567/*-----------------------------------------------------------------------------
5568Routine Name: utilRxCalibrationStatus
5569Routine Description:
5570Arguments:
5571Return Value:
5572-----------------------------------------------------------------------------*/
5573ULONG utilRxCalibrationStatus(
5574                   PTIWLN_ADAPTER_T pAdapter,
5575                   PUCHAR pData,
5576                   PULONG pOutLength,
5577                   ULONG  InLength)
5578{
5579    whalParamInfo_t Param;
5580    ULONG status;
5581
5582    Param.paramType = HAL_CTRL_PLT_RX_CAL_STATUS;
5583    Param.paramLength = sizeof(TI_STATUS);
5584
5585    status = configMgr_getParam(pAdapter->CoreHalCtx, (paramInfo_t*)&Param);
5586
5587    *pData = Param.content.PltRxCalibrationStatus;
5588
5589    return status;
5590}
5591