TWDriverCtrl.c revision 981801b95b81e6d1c7a2085967406e86af0f08fc
1/*
2 * TWDriverCtrl.c
3 *
4 * Copyright(c) 1998 - 2009 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/** \file  TWDriver.c
36 *  \brief TI WLAN Hardware Access Driver, Parameters control
37 *
38 *  \see   TWDriver.h
39 */
40
41#define __FILE_ID__  FILE_ID_118
42#include "TWDriver.h"
43#include "tidef.h"
44#include "report.h"
45#include "txHwQueue_api.h"
46#include "txXfer_api.h"
47#include "txResult_api.h"
48#include "eventMbox_api.h"
49#include "TWDriver.h"
50#include "TWDriverInternal.h"
51#include "FwEvent_api.h"
52#include "CmdBld.h"
53#include "RxQueue_api.h"
54
55
56TI_STATUS TWD_SetParam (TI_HANDLE hTWD, TTwdParamInfo *pParamInfo)
57{
58    TTwd           *pTWD = (TTwd *)hTWD;
59    TWlanParams    *pWlanParams = &DB_WLAN(pTWD->hCmdBld);
60
61    TRACE1(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_SetParam: paramType=0x%X\n", pParamInfo->paramType);
62
63    switch (pParamInfo->paramType)
64    {
65        case TWD_RTS_THRESHOLD_PARAM_ID:
66
67            if  (pParamInfo->content.halCtrlRtsThreshold > TWD_RTS_THRESHOLD_MAX)
68            {
69                TRACE1(pTWD->hReport, REPORT_SEVERITY_ERROR, "TWD########TWD_RTS_THRESHOLD_PARAM: Value out of permitted range 0x%x\n", pParamInfo->content.halCtrlRtsThreshold);
70                return (PARAM_VALUE_NOT_VALID);
71            }
72
73            if (cmdBld_CfgRtsThreshold (pTWD->hCmdBld, pParamInfo->content.halCtrlRtsThreshold, NULL, NULL) == TI_OK)
74            {
75                TRACE1(pTWD->hReport, REPORT_SEVERITY_INFORMATION, "TWD########TWD_RTS_THRESHOLD_PARAM 0x%x\n", pParamInfo->content.halCtrlRtsThreshold);
76                pWlanParams->RtsThreshold = pParamInfo->content.halCtrlRtsThreshold;
77            }
78            break;
79
80        case TWD_CTS_TO_SELF_PARAM_ID:
81            return cmdBld_CfgCtsProtection (pTWD->hCmdBld, pParamInfo->content.halCtrlCtsToSelf, NULL, NULL);
82
83        case TWD_RX_TIME_OUT_PARAM_ID:
84            if (cmdBld_CfgServicePeriodTimeout (pTWD->hCmdBld, &pParamInfo->content.halCtrlRxTimeOut, NULL, NULL) == TI_OK)
85            {
86                pWlanParams->rxTimeOut.psPoll = pParamInfo->content.halCtrlRxTimeOut.psPoll;
87                pWlanParams->rxTimeOut.UPSD   = pParamInfo->content.halCtrlRxTimeOut.UPSD;
88            }
89            break;
90
91        case TWD_FRAG_THRESHOLD_PARAM_ID:
92            if (pParamInfo->content.halCtrlFragThreshold < TWD_FRAG_THRESHOLD_MIN ||
93                pParamInfo->content.halCtrlFragThreshold > TWD_FRAG_THRESHOLD_MAX)
94                return PARAM_VALUE_NOT_VALID;
95
96            cmdBld_CfgFragmentThreshold (pTWD->hCmdBld, pParamInfo->content.halCtrlFragThreshold, NULL, NULL);
97            break;
98
99        case TWD_MAX_RX_MSDU_LIFE_TIME_PARAM_ID:
100            cmdBld_CfgRxMsduLifeTime (pTWD->hCmdBld, pParamInfo->content.halCtrlMaxRxMsduLifetime, NULL, NULL);
101            break;
102
103        case TWD_ACX_STATISTICS_PARAM_ID:
104            if (cmdBld_CfgStatisitics (pTWD->hCmdBld, NULL, NULL) != TI_OK)
105                return TI_NOK;
106            break;
107
108        case TWD_LISTEN_INTERVAL_PARAM_ID:
109            if (pParamInfo->content.halCtrlListenInterval < TWD_LISTEN_INTERVAL_MIN ||
110                pParamInfo->content.halCtrlListenInterval > TWD_LISTEN_INTERVAL_MAX)
111                return PARAM_VALUE_NOT_VALID;
112
113            pWlanParams->ListenInterval = (TI_UINT8)pParamInfo->content.halCtrlListenInterval;
114            break;
115
116        case TWD_AID_PARAM_ID:
117            pWlanParams->Aid = pParamInfo->content.halCtrlAid;
118
119            /* Configure the ACXAID info element*/
120            if (cmdBld_CfgAid (pTWD->hCmdBld, pParamInfo->content.halCtrlAid, NULL, NULL) != TI_OK)
121               return TI_NOK;
122            break;
123
124        case TWD_RSN_HW_ENC_DEC_ENABLE_PARAM_ID:
125            TRACE1(pTWD->hReport, REPORT_SEVERITY_INFORMATION, "TWD########HW_ENC_DEC_ENABLE %d\n", pParamInfo->content.rsnHwEncDecrEnable);
126
127            /* Set the Encryption/Decryption on the HW*/
128            if (cmdBld_CfgHwEncDecEnable (pTWD->hCmdBld, pParamInfo->content.rsnHwEncDecrEnable, NULL, NULL) != TI_OK)
129                return (TI_NOK);
130            break;
131
132        case TWD_RSN_KEY_ADD_PARAM_ID:
133            TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION, "TWD########KEY_ADD\n");
134
135            if (cmdBld_CmdAddKey (pTWD->hCmdBld,
136                                  (TSecurityKeys *) pParamInfo->content.configureCmdCBParams.pCb,
137                                  TI_FALSE,
138                                  pParamInfo->content.configureCmdCBParams.fCb,
139                                  pParamInfo->content.configureCmdCBParams.hCb) != TI_OK)
140                return TI_NOK;
141            break;
142
143        case TWD_RSN_KEY_REMOVE_PARAM_ID:
144            TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION, "TWD########KEY_REMOVE\n");
145
146            if (cmdBld_CmdRemoveKey (pTWD->hCmdBld,
147                                     (TSecurityKeys *) pParamInfo->content.configureCmdCBParams.pCb,
148                                     pParamInfo->content.configureCmdCBParams.fCb,
149                                     pParamInfo->content.configureCmdCBParams.hCb) != TI_OK)
150                return TI_NOK;
151            break;
152
153        case TWD_RSN_DEFAULT_KEY_ID_PARAM_ID:
154            if (*((TI_UINT8 *)pParamInfo->content.configureCmdCBParams.pCb) > MAX_DEFAULT_KEY_ID)
155                return PARAM_VALUE_NOT_VALID;
156
157            TRACE1(pTWD->hReport, REPORT_SEVERITY_INFORMATION, "TWD########DEFAULT_KEY_ID %d\n", (TI_UINT8)pParamInfo->content.rsnDefaultKeyID);
158
159			if (cmdBld_CmdSetWepDefaultKeyId (pTWD->hCmdBld,
160									  *((TI_UINT8 *)pParamInfo->content.interogateCmdCBParams.pCb),
161									  pParamInfo->content.interogateCmdCBParams.fCb,
162									  pParamInfo->content.interogateCmdCBParams.hCb) != TI_OK)
163                return TI_NOK;
164
165            break;
166
167        case TWD_RSN_SECURITY_MODE_PARAM_ID:
168            TRACE1(pTWD->hReport, REPORT_SEVERITY_INFORMATION, "TWD########SECURITY_MODE_SET %d\n", pParamInfo->content.rsnEncryptionStatus);
169            if (cmdBld_CfgSecureMode (pTWD->hCmdBld, (ECipherSuite)pParamInfo->content.rsnEncryptionStatus, NULL, NULL) != TI_OK)
170                return TI_NOK;
171            break;
172
173#ifdef XCC_MODULE_INCLUDED
174        case TWD_RSN_XCC_SW_ENC_ENABLE_PARAM_ID:
175
176            TRACE1(pTWD->hReport, REPORT_SEVERITY_INFORMATION, "TWD: XCC_SW_ENC_ENABLE %d\n", pParamInfo->content.rsnXCCSwEncFlag);
177
178            /* when SW encryption is ON, HW encryption should be turned OFF and vice versa */
179
180            TRACE1(pTWD->hReport, REPORT_SEVERITY_INFORMATION, "TWD: Set HwEncDecrEnable to %d\n", !pParamInfo->content.rsnXCCSwEncFlag);
181
182            /* Set the Encryption/Decryption on the HW*/
183            if (cmdBld_CfgHwEncDecEnable (pTWD->hCmdBld, !pParamInfo->content.rsnXCCSwEncFlag, NULL, NULL) != TI_OK)
184                return TI_NOK;
185            break;
186             /* not supported - CKIP*/
187        case TWD_RSN_XCC_MIC_FIELD_ENABLE_PARAM_ID:
188            break;
189#endif /* XCC_MODULE_INCLUDED*/
190
191        case TWD_TX_POWER_PARAM_ID:
192
193            TRACE1(pTWD->hReport, REPORT_SEVERITY_INFORMATION, "TWD_TX_POWER_PARAM_ID %d\n", pParamInfo->content.halCtrlTxPowerDbm);
194
195            pWlanParams->TxPowerDbm = pParamInfo->content.halCtrlTxPowerDbm;
196
197            /* Configure the wlan hardware */
198            if (cmdBld_CfgTxPowerDbm (pTWD->hCmdBld, pWlanParams->TxPowerDbm, NULL, NULL) != TI_OK)
199                return TI_NOK;
200            break;
201
202        case TWD_SG_ENABLE_PARAM_ID:
203            return cmdBld_CfgSgEnable (pTWD->hCmdBld,
204                                       (ESoftGeminiEnableModes)pParamInfo->content.SoftGeminiEnable,
205                                       NULL,
206                                       NULL);
207
208        case TWD_SG_CONFIG_PARAM_ID:
209            return cmdBld_CfgSg (pTWD->hCmdBld, &pParamInfo->content.SoftGeminiParam, NULL, NULL);
210
211        /*
212         *  TX Parameters
213         */
214
215        case TWD_TX_RATE_CLASS_PARAM_ID:
216            return cmdBld_CfgTxRatePolicy (pTWD->hCmdBld, pParamInfo->content.pTxRatePlicy, NULL, NULL);
217
218        case TWD_QUEUES_PARAM_ID:
219            return cmdBld_CfgTid (pTWD->hCmdBld, pParamInfo->content.pQueueTrafficParams, NULL, NULL);
220
221        case TWD_CLK_RUN_ENABLE_PARAM_ID:
222            TRACE1(pTWD->hReport, REPORT_SEVERITY_INFORMATION, "TWD_SetParam: CLK_RUN_ENABLE %d\n", pParamInfo->content.halCtrlClkRunEnable);
223
224            /* Set the Encryption/Decryption on the HW*/
225            if (cmdBld_CfgClkRun (pTWD->hCmdBld, pParamInfo->content.halCtrlClkRunEnable, NULL, NULL) != TI_OK)
226                return TI_NOK;
227            break;
228
229        case TWD_COEX_ACTIVITY_PARAM_ID:
230            cmdBld_CfgCoexActivity (pTWD->hCmdBld, &pParamInfo->content.tTwdParamsCoexActivity, NULL, NULL);
231            break;
232
233        default:
234            TRACE1(pTWD->hReport, REPORT_SEVERITY_ERROR, "TWD_SetParam - ERROR - Param is not supported, 0x%x\n", pParamInfo->paramType);
235            return PARAM_NOT_SUPPORTED;
236    }
237
238    return TI_OK;
239}
240
241TI_STATUS TWD_GetParam (TI_HANDLE hTWD, TTwdParamInfo *pParamInfo)
242{
243    TTwd *pTWD = (TTwd *)hTWD;
244
245    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_GetParam: called\n");
246
247    return cmdBld_GetParam (pTWD->hCmdBld, pParamInfo);
248}
249
250TI_STATUS TWD_CfgRx (TI_HANDLE hTWD, TI_UINT32 uRxConfigOption, TI_UINT32 uRxFilterOption)
251{
252    TTwd     *pTWD = (TTwd *)hTWD;
253
254    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgRx: called\n");
255
256    return cmdBld_CfgRx (pTWD->hCmdBld, uRxConfigOption, uRxFilterOption, NULL, NULL);
257}
258
259TI_STATUS TWD_CfgArpIpAddrTable (TI_HANDLE hTWD, TIpAddr tIpAddr, TI_BOOL bEnabled, EIpVer eIpVer)
260{
261    TTwd *pTWD = (TTwd *)hTWD;
262
263    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgArpIpAddrTable: called\n");
264
265    return cmdBld_CfgArpIpAddrTable (pTWD->hCmdBld, tIpAddr, bEnabled, eIpVer, NULL, NULL);
266}
267
268/** @ingroup Misc
269 * \brief  Configure ARP IP Filter
270 *
271 * \param hTWD 			- TWD module object handle
272 * \param  bEnabled   	- Indicates if ARP filtering is Enabled (1) or Disabled (0)
273 * \return TI_OK on success or TI_NOK on failure
274 *
275 * \par Description
276 *
277 * \sa
278 */
279TI_STATUS TWD_CfgArpIpFilter (TI_HANDLE hTWD, TI_BOOL bEnabled)
280{
281    TTwd *pTWD = (TTwd *)hTWD;
282
283    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgArpIpFilter: called\n");
284
285    return cmdBld_CfgArpIpFilter (pTWD->hCmdBld, bEnabled, NULL, NULL);
286}
287
288TI_STATUS TWD_CmdSetSplitScanTimeOut  ( TI_HANDLE hTWD, TI_UINT32 uTimeOut )
289{
290    TTwd *pTWD = (TTwd *)hTWD;
291
292    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CmdSetSplitScanTimeOut: called\n");
293
294    return cmdBld_CmdSetSplitScanTimeOut (pTWD->hCmdBld, uTimeOut);
295}
296
297TI_STATUS TWD_CmdJoinBss (TI_HANDLE hTWD, TJoinBss *pJoinBssParams)
298{
299    TTwd      *pTWD = (TTwd *)hTWD;
300
301    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CmdJoinBss: called\n");
302
303    return cmdBld_CmdJoinBss (pTWD->hCmdBld, pJoinBssParams, NULL, NULL);
304}
305
306TI_STATUS TWD_CfgKeepAlive (TI_HANDLE hTWD, TKeepAliveParams *pKeepAliveParams)
307{
308    TTwd      *pTWD = (TTwd *)hTWD;
309
310    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgKeepAlive: called\n");
311
312    return cmdBld_CfgKeepAlive (pTWD->hCmdBld, pKeepAliveParams, NULL, NULL);
313}
314
315TI_STATUS TWD_CfgKeepAliveEnaDis(TI_HANDLE hTWD, TI_UINT8 enaDisFlag)
316{
317    TTwd      *pTWD = (TTwd *)hTWD;
318
319    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgKeepAliveEnaDis: called\n");
320
321    return cmdBld_CfgKeepAliveEnaDis (pTWD->hCmdBld, enaDisFlag, NULL, NULL);
322}
323
324TI_STATUS TWD_CmdTemplate (TI_HANDLE hTWD, TSetTemplate *pTemplateParams, void *fCb, TI_HANDLE hCb)
325{
326    TTwd *pTWD = (TTwd *)hTWD;
327
328    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CmdTemplate: called\n");
329
330    return cmdBld_CmdTemplate (pTWD->hCmdBld, pTemplateParams, fCb, hCb);
331}
332
333TI_STATUS TWD_CfgSlotTime (TI_HANDLE hTWD, ESlotTime eSlotTimeVal)
334{
335    TTwd   *pTWD = (TTwd *)hTWD;
336
337    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgSlotTime: called\n");
338
339    return cmdBld_CfgSlotTime (pTWD->hCmdBld, eSlotTimeVal, NULL, NULL);
340}
341
342TI_STATUS TWD_CfgPreamble (TI_HANDLE hTWD, EPreamble ePreamble)
343{
344    TTwd   *pTWD = (TTwd *)hTWD;
345
346    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgPreamble: called\n");
347
348    return cmdBld_CfgPreamble (pTWD->hCmdBld, (Preamble_e)ePreamble, NULL, NULL);
349}
350
351TI_STATUS TWD_CfgPacketDetectionThreshold (TI_HANDLE hTWD, TI_UINT32 threshold)
352{
353    TTwd   *pTWD = (TTwd *)hTWD;
354
355    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgPacketDetectionThreshold: called\n");
356
357    return cmdBld_CfgPacketDetectionThreshold (pTWD->hCmdBld, threshold, NULL, NULL);
358}
359
360TI_STATUS TWD_CmdDisableTx (TI_HANDLE hTWD)
361{
362    TTwd   *pTWD = (TTwd *)hTWD;
363
364    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CmdDisableTx: called\n");
365
366    return cmdBld_CmdDisableTx (pTWD->hCmdBld, NULL, NULL);
367}
368
369TI_STATUS TWD_CmdEnableTx (TI_HANDLE hTWD, TI_UINT8 channel)
370{
371    TTwd   *pTWD = (TTwd *)hTWD;
372
373    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CmdEnableTx: called\n");
374
375    return cmdBld_CmdEnableTx (pTWD->hCmdBld, channel, NULL, NULL);
376}
377
378TI_STATUS TWD_CmdSetStaState (TI_HANDLE hTWD, TI_UINT8 staState, void *fCb, TI_HANDLE hCb)
379{
380    TTwd *pTWD = (TTwd *)hTWD;
381
382    TRACE1(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_SetStaState: %d\n", staState);
383
384    return cmdBld_CmdSetStaState (pTWD->hCmdBld, staState, fCb, hCb);
385}
386
387TI_STATUS TWD_ItrRoammingStatisitics (TI_HANDLE hTWD, void *fCb, TI_HANDLE hCb, void * pCb)
388{
389    TTwd   *pTWD = (TTwd *)hTWD;
390
391    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_ItrRoammingStatisitics: called\n");
392
393    return cmdBld_ItrRoamimgStatisitics (pTWD->hCmdBld, fCb, hCb, pCb);
394}
395
396/** @ingroup UnKnown
397 * \brief	Interrogate Error Count
398 *
399 * \param  hTWD     	- TWD module object handle
400 * \param  fCb          - Pointer to Command CB Function
401 * \param  hCb          - Handle to Command CB Function Obj Parameters
402 * \param  pCb          - Pointer to read parameters
403 * \return TI_OK on success or TI_NOK on failure
404 *
405 * \par Description
406 * Interrogate ACX Error counter
407 *
408 * \sa
409 */
410TI_STATUS TWD_ItrErrorCnt (TI_HANDLE hTWD, void *fCb, TI_HANDLE hCb, void *pCb)
411{
412    TTwd   *pTWD = (TTwd *)hTWD;
413
414    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_ItrErrorCnt: called\n");
415
416    return cmdBld_ItrErrorCnt (pTWD->hCmdBld, fCb, hCb, pCb);
417}
418
419TI_STATUS TWD_CmdNoiseHistogram (TI_HANDLE hTWD, TNoiseHistogram *pNoiseHistParams)
420{
421    TTwd *pTWD = (TTwd *)hTWD;
422
423    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CmdNoiseHistogram: called\n");
424
425    return cmdBld_CmdNoiseHistogram (pTWD->hCmdBld, pNoiseHistParams, NULL, NULL);
426}
427
428TI_STATUS TWD_CfgBeaconFilterOpt (TI_HANDLE hTWD, TI_UINT8 uBeaconFilteringStatus, TI_UINT8 uNumOfBeaconsToBuffer)
429{
430    TTwd   *pTWD = (TTwd *)hTWD;
431
432    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgBeaconFilterOpt: called\n");
433
434    return cmdBld_CfgBeaconFilterOpt (pTWD->hCmdBld, uBeaconFilteringStatus, uNumOfBeaconsToBuffer, NULL, NULL);
435}
436
437TI_STATUS TWD_CfgBeaconFilterTable (TI_HANDLE hTWD, TI_UINT8 uNumOfIe, TI_UINT8 *pIeTable, TI_UINT8 uIeTableSize)
438{
439    TTwd   *pTWD = (TTwd *)hTWD;
440
441    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgBeaconFilterTable: called\n");
442
443    return cmdBld_CfgBeaconFilterTable (pTWD->hCmdBld, uNumOfIe, pIeTable, uIeTableSize, NULL, NULL);
444}
445
446TI_STATUS TWD_CfgWakeUpCondition (TI_HANDLE hTWD, TPowerMgmtConfig *pPowerMgmtConfig)
447{
448    TTwd *pTWD = (TTwd *)hTWD;
449
450    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgWakeUpCondition: called\n");
451
452    return cmdBld_CfgWakeUpCondition (pTWD->hCmdBld, pPowerMgmtConfig, NULL, NULL);
453}
454
455TI_STATUS TWD_CfgBcnBrcOptions (TI_HANDLE hTWD, TPowerMgmtConfig *pPowerMgmtConfig)
456{
457    TTwd *pTWD = (TTwd *)hTWD;
458
459    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgBcnBrcOptions: called\n");
460
461    return cmdBld_CfgBcnBrcOptions (pTWD->hCmdBld, pPowerMgmtConfig, NULL, NULL);
462}
463
464TFwInfo * TWD_GetFWInfo (TI_HANDLE hTWD)
465{
466    TTwd *pTWD = (TTwd *)hTWD;
467
468    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_GetFWInfo: called\n");
469
470    return cmdBld_GetFWInfo (pTWD->hCmdBld);
471}
472
473TI_STATUS TWD_CmdSwitchChannel (TI_HANDLE hTWD, TSwitchChannelParams *pSwitchChannelCmd)
474{
475    TTwd   *pTWD = (TTwd *)hTWD;
476
477    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CmdSwitchChannel: called\n");
478
479    return cmdBld_CmdSwitchChannel (pTWD->hCmdBld, pSwitchChannelCmd, NULL, NULL);
480}
481
482TI_STATUS TWD_CmdSwitchChannelCancel (TI_HANDLE hTWD, TI_UINT8 channel)
483{
484    TTwd   *pTWD = (TTwd *)hTWD;
485
486    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CmdSwitchChannelCancel: called\n");
487
488    return cmdBld_CmdSwitchChannelCancel (pTWD->hCmdBld, channel, NULL, NULL);
489}
490
491TI_STATUS TWD_CfgMaxTxRetry (TI_HANDLE hTWD, TRroamingTriggerParams *pRoamingTriggerCmd)
492{
493    TTwd   *pTWD = (TTwd *)hTWD;
494
495    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgMaxTxRetry: called\n");
496
497    return cmdBld_CfgMaxTxRetry (pTWD->hCmdBld, pRoamingTriggerCmd, NULL, NULL);
498}
499
500TI_STATUS TWD_CfgConnMonitParams (TI_HANDLE hTWD, TRroamingTriggerParams *pRoamingTriggerCmd)
501{
502    TTwd   *pTWD = (TTwd *)hTWD;
503
504    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgConnMonitParams: called\n");
505
506    return cmdBld_CfgConnMonitParams (pTWD->hCmdBld, pRoamingTriggerCmd, NULL, NULL);
507}
508
509TI_STATUS TWD_ItrRSSI (TI_HANDLE hTWD, void *fCb, TI_HANDLE hCb, void *pCb)
510{
511    TTwd   *pTWD = (TTwd *)hTWD;
512
513    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_ItrRSSI: called\n");
514
515    return cmdBld_ItrRSSI (pTWD->hCmdBld, fCb, hCb, pCb);
516}
517
518TI_STATUS TWD_CmdFwDisconnect (TI_HANDLE hTWD, DisconnectType_e uDisconType, TI_UINT16 uDisconReason)
519{
520    TTwd   *pTWD = (TTwd *)hTWD;
521
522    return cmdBld_CmdFwDisconnect (pTWD->hCmdBld,
523                                   RX_CONFIG_OPTION_MY_DST_MY_BSS,
524                                   RX_FILTER_OPTION_FILTER_ALL,
525                                   uDisconType,
526                                   uDisconReason,
527                                   NULL,
528                                   NULL);
529}
530
531TI_STATUS TWD_CmdMeasurement (TI_HANDLE           hTWD,
532                              TMeasurementParams *pMeasurementParams,
533                              void               *fCommandResponseCb,
534                              TI_HANDLE           hCb)
535{
536    TTwd   *pTWD = (TTwd *)hTWD;
537
538    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CmdMeasurement: called\n");
539
540    return cmdBld_CmdMeasurement (pTWD->hCmdBld, pMeasurementParams, fCommandResponseCb, hCb);
541}
542
543TI_STATUS TWD_CmdMeasurementStop (TI_HANDLE hTWD, void* fCb, TI_HANDLE hCb)
544{
545    TTwd   *pTWD = (TTwd *)hTWD;
546
547    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CmdMeasurementStop: called\n");
548
549    return cmdBld_CmdMeasurementStop (pTWD->hCmdBld, fCb, hCb);
550}
551
552TI_STATUS TWD_CmdApDiscovery (TI_HANDLE hTWD, TApDiscoveryParams *pApDiscoveryParams)
553{
554    TTwd *pTWD = (TTwd *)hTWD;
555
556    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CmdApDiscovery: called\n");
557
558    return cmdBld_CmdApDiscovery (pTWD->hCmdBld, pApDiscoveryParams, NULL, NULL);
559}
560
561TI_STATUS TWD_CmdApDiscoveryStop (TI_HANDLE hTWD)
562{
563    TTwd   *pTWD = (TTwd *)hTWD;
564
565    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CmdApDiscoveryStop: called\n");
566
567    return cmdBld_CmdApDiscoveryStop (pTWD->hCmdBld, NULL, NULL);
568}
569
570TI_STATUS TWD_CfgGroupAddressTable (TI_HANDLE     hTWD,
571                                    TI_UINT8      uNumGroupAddrs,
572                                    TMacAddr      *pGroupAddr,
573                                    TI_BOOL       bEnabled)
574{
575    TTwd *pTWD = (TTwd *)hTWD;
576
577    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgGroupAddressTable: called\n");
578
579    return cmdBld_CfgGroupAddressTable (pTWD->hCmdBld, uNumGroupAddrs, pGroupAddr, bEnabled, NULL, NULL);
580}
581
582TI_STATUS TWD_GetGroupAddressTable (TI_HANDLE hTWD, TI_UINT8* pEnabled, TI_UINT8* pNumGroupAddrs, TMacAddr *pGroupAddr)
583{
584    TTwd   *pTWD = (TTwd *)hTWD;
585
586    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_GetGroupAddressTable: called\n");
587
588    return cmdBld_GetGroupAddressTable (pTWD->hCmdBld, pEnabled, pNumGroupAddrs, pGroupAddr);
589}
590
591TI_STATUS TWD_SetRadioBand (TI_HANDLE hTWD, ERadioBand eRadioBand)
592{
593    TTwd   *pTWD = (TTwd *)hTWD;
594
595    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_SetRadioBand: called\n");
596
597    return cmdBld_SetRadioBand (pTWD->hCmdBld, eRadioBand);
598}
599
600TI_STATUS TWD_CfgSleepAuth (TI_HANDLE hTWD, EPowerPolicy eMinPowerPolicy)
601{
602    TTwd *pTWD = (TTwd *)hTWD;
603
604    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgSleepAuth: called\n");
605
606    /* Configure the new power policy to the FW */
607    cmdBld_CfgSleepAuth (pTWD->hCmdBld, eMinPowerPolicy, NULL, NULL);
608
609    return TI_OK;
610}
611
612TI_STATUS TWD_CfgBurstMode (TI_HANDLE hTWD, TI_BOOL bEnabled)
613{
614    TTwd *pTWD = (TTwd *)hTWD;
615
616    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "cmdBld_CfgBurstMode: called\n");
617
618    /* Configure the burst mode to the FW */
619    cmdBld_CfgBurstMode (pTWD->hCmdBld, bEnabled, NULL, NULL);
620
621    return TI_OK;
622}
623
624
625
626TI_STATUS TWD_CmdHealthCheck (TI_HANDLE hTWD)
627{
628    TTwd   *pTWD = (TTwd *)hTWD;
629
630    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CmdHealthCheck: called\n");
631
632    return cmdBld_CmdHealthCheck (pTWD->hCmdBld, NULL, NULL);
633}
634
635TI_STATUS TWD_CfgMacClock (TI_HANDLE hTWD, TI_UINT32 uMacClock)
636{
637    TTwd *pTWD = (TTwd *)hTWD;
638
639    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgMacClock: called\n");
640
641    return cmdBld_CfgMacClock (pTWD->hCmdBld, uMacClock, NULL, NULL);
642}
643
644TI_STATUS TWD_CfgArmClock (TI_HANDLE hTWD, TI_UINT32 uArmClock)
645{
646    TTwd *pTWD = (TTwd *)hTWD;
647
648    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgArmClock: called\n");
649
650    return cmdBld_CfgArmClock (pTWD->hCmdBld, uArmClock, NULL, NULL);
651}
652
653TI_STATUS TWD_ItrMemoryMap (TI_HANDLE hTWD, MemoryMap_t *pMap, void *fCb, TI_HANDLE hCb)
654{
655    TTwd *pTWD = (TTwd *)hTWD;
656
657    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_ItrMemoryMap: called\n");
658
659    return cmdBld_ItrMemoryMap (pTWD->hCmdBld, pMap, fCb, hCb);
660}
661
662TI_STATUS TWD_ItrStatistics (TI_HANDLE hTWD, void *fCb, TI_HANDLE hCb, void *pCb)
663{
664    TTwd *pTWD = (TTwd *)hTWD;
665
666    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_ItrStatistics: called\n");
667
668    return cmdBld_ItrStatistics (pTWD->hCmdBld, fCb, hCb, pCb);
669}
670
671TI_STATUS TWD_ItrDataFilterStatistics (TI_HANDLE hTWD, void *fCb, TI_HANDLE hCb, void *pCb)
672{
673    TTwd *pTWD = (TTwd *)hTWD;
674
675    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_ItrDataFilterStatistics: called\n");
676
677    return cmdBld_ItrDataFilterStatistics (pTWD->hCmdBld, fCb, hCb, pCb);
678}
679
680TI_STATUS TWD_CfgEnableRxDataFilter (TI_HANDLE hTWD, TI_BOOL bEnabled, filter_e eDefaultAction)
681{
682    TTwd *pTWD = (TTwd *)hTWD;
683
684    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgEnableRxDataFilter: called\n");
685
686    return cmdBld_CfgEnableRxDataFilter (pTWD->hCmdBld, bEnabled, eDefaultAction, NULL, NULL);
687}
688
689TI_STATUS TWD_CfgRxDataFilter (TI_HANDLE    hTWD,
690                               TI_UINT8     index,
691                               TI_UINT8     command,
692                               filter_e     eAction,
693                               TI_UINT8     uNumFieldPatterns,
694                               TI_UINT8     uLenFieldPatterns,
695                               TI_UINT8     *pFieldPatterns)
696{
697    TTwd *pTWD = (TTwd *)hTWD;
698
699    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgRxDataFilter: called\n");
700
701    return cmdBld_CfgRxDataFilter (pTWD->hCmdBld,
702                                   index,
703                                   command,
704                                   eAction,
705                                   uNumFieldPatterns,
706                                   uLenFieldPatterns,
707                                   pFieldPatterns,
708                                   NULL,
709                                   NULL);
710}
711
712TI_STATUS TWD_CfgRssiSnrTrigger (TI_HANDLE hTWD, RssiSnrTriggerCfg_t* pRssiSnrTrigger)
713{
714    TTwd *pTWD = (TTwd *)hTWD;
715
716    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgRssiSnrTrigger: called\n");
717
718    return cmdBld_CfgRssiSnrTrigger (pTWD->hCmdBld, pRssiSnrTrigger, NULL, NULL);
719}
720
721TI_STATUS TWD_CfgAcParams (TI_HANDLE hTWD, TAcQosParams *pAcQosParams, void *fCb, TI_HANDLE hCb)
722{
723    TTwd *pTWD = (TTwd *)hTWD;
724
725    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgAcParams: called\n");
726
727    return cmdBld_CfgAcParams (pTWD->hCmdBld, pAcQosParams, fCb, hCb);
728}
729
730TI_STATUS TWD_CfgPsRxStreaming (TI_HANDLE hTWD, TPsRxStreaming *pPsRxStreaming, void *fCb, TI_HANDLE hCb)
731{
732    TTwd *pTWD = (TTwd *)hTWD;
733
734    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgPsRxStreaming: called\n");
735
736    return cmdBld_CfgPsRxStreaming (pTWD->hCmdBld, pPsRxStreaming, fCb, hCb);
737}
738
739TI_STATUS TWD_CfgBet (TI_HANDLE hTWD, TI_UINT8 Enable, TI_UINT8 MaximumConsecutiveET)
740{
741    TTwd *pTWD = (TTwd *)hTWD;
742
743    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgBet: called\n");
744
745    return cmdBld_CfgBet (pTWD->hCmdBld, Enable, MaximumConsecutiveET, NULL, NULL);
746}
747
748TI_STATUS TWD_SetSecuritySeqNum (TI_HANDLE hTWD, TI_UINT8 securitySeqNumLsByte)
749{
750    TTwd *pTWD = (TTwd *)hTWD;
751
752    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_SetSecuritySeqNum: called\n");
753
754    return cmdBld_SetSecuritySeqNum (pTWD->hCmdBld, securitySeqNumLsByte);
755}
756
757TI_STATUS TWD_CfgSetFwHtCapabilities (TI_HANDLE hTWD,
758									  Tdot11HtCapabilitiesUnparse *pHtCapabilitiesIe,
759									  TI_BOOL bAllowHtOperation)
760{
761    TTwd        *pTWD           = (TTwd *)hTWD;
762    TI_UINT32   uHtCapabilites;
763    TI_UINT8    uAmpduMaxLeng = 0;
764    TI_UINT8    uAmpduMinSpac = 0;
765    TI_UINT16   uHtCapabilitesField;
766
767    /* Note, currently this value will be set to FFFFFFFFFFFF to indicate it is relevant for all peers
768       since we only support HT in infrastructure mode. Later on this field will be relevant to IBSS/DLS operation */
769    TMacAddr    tMacAddress = {0xff,0xff,0xff,0xff,0xff,0xff};
770
771    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgSetFwHtCapabilities: called\n");
772
773    /* Allow HT Operation ? */
774    if (bAllowHtOperation == TI_TRUE)
775    {
776       /* get date from HT capabilities field */
777       /* Handle endian for the field */
778       COPY_WLAN_WORD(&uHtCapabilitesField, pHtCapabilitiesIe->aHtCapabilitiesIe);
779       uHtCapabilites = FW_CAP_BIT_MASK_HT_OPERATION |
780                        ((uHtCapabilitesField & HT_CAP_GREENFIELD_FRAME_FORMAT_BITMASK)    ? FW_CAP_BIT_MASK_GREENFIELD_FRAME_FORMAT       : 0) |
781                        ((uHtCapabilitesField & HT_CAP_SHORT_GI_FOR_20MHZ_BITMASK)         ? FW_CAP_BIT_MASK_SHORT_GI_FOR_20MHZ_PACKETS    : 0) |
782                        ((uHtCapabilitesField & HT_CAP_LSIG_TXOP_PROTECTION_BITMASK)       ? FW_CAP_BIT_MASK_LSIG_TXOP_PROTECTION          : 0);
783
784       /* get date from HT capabilities field */
785       uHtCapabilites |= ((uHtCapabilitesField & HT_EXT_HT_CONTROL_FIELDS_BITMASK) ? FW_CAP_BIT_MASK_HT_CONTROL_FIELDS : 0) |
786                         ((uHtCapabilitesField & HT_EXT_RD_INITIATION_BITMASK)     ? FW_CAP_BIT_MASK_RD_INITIATION     : 0);
787
788       /* get date from A-MPDU parameters field */
789       uAmpduMaxLeng = pHtCapabilitiesIe->aHtCapabilitiesIe[HT_CAP_AMPDU_PARAMETERS_FIELD_OFFSET] & HT_CAP_AMPDU_MAX_RX_FACTOR_BITMASK;
790       uAmpduMinSpac = (pHtCapabilitiesIe->aHtCapabilitiesIe[HT_CAP_AMPDU_PARAMETERS_FIELD_OFFSET] >> 2) & HT_CAP_AMPDU_MIN_START_SPACING_BITMASK;
791    }
792    /* not Allow HT Operation */
793    else
794    {
795        uHtCapabilites = 0;
796    }
797
798    return cmdBld_CfgSetFwHtCapabilities (pTWD->hCmdBld,
799                                          uHtCapabilites,
800                                          tMacAddress,
801                                          uAmpduMaxLeng,
802                                          uAmpduMinSpac,
803                                          NULL,
804                                          NULL);
805}
806
807TI_STATUS TWD_CfgSetFwHtInformation (TI_HANDLE hTWD, Tdot11HtInformationUnparse *pHtInformationIe)
808{
809    TTwd        *pTWD           = (TTwd *)hTWD;
810    TI_UINT8    uRifsMode;
811    TI_UINT8    uHtProtection;
812    TI_UINT8    uGfProtection;
813    TI_UINT8    uHtTxBurstLimit;
814    TI_UINT8    uDualCtsProtection;
815
816    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgSetFwHtInformation: called\n");
817
818    uRifsMode = (pHtInformationIe->aHtInformationIe[1] & HT_INF_RIFS_MOD_BITMASK) >> 3;
819
820    uHtProtection = (pHtInformationIe->aHtInformationIe[2] & HT_INF_OPERATION_MOD_BITMASK);
821
822    uGfProtection = (pHtInformationIe->aHtInformationIe[3] & HT_INF_NON_GF_PRES_BITMASK) >> 2;
823
824    uHtTxBurstLimit = (pHtInformationIe->aHtInformationIe[3] & HT_INF_TX_BURST_LIMIT_BITMASK) >> 3;
825
826    uDualCtsProtection = (pHtInformationIe->aHtInformationIe[4] & HT_INF_DUAL_BEACON_BITMASK) >> 6;
827
828    return cmdBld_CfgSetFwHtInformation (pTWD->hCmdBld,
829                                         uRifsMode,
830                                         uHtProtection,
831                                         uGfProtection,
832                                         uHtTxBurstLimit,
833                                         uDualCtsProtection,
834                                         NULL,
835                                         NULL);
836}
837
838TI_STATUS TWD_CfgSetBaInitiator (TI_HANDLE hTWD,
839                                 TI_UINT8 uTid,
840                                 TI_UINT8 uState,
841                                 TMacAddr tRa,
842                                 TI_UINT16 uWinSize,
843                                 TI_UINT16 uInactivityTimeout)
844
845{
846	TTwd *pTWD = (TTwd *)hTWD;
847
848    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgSetBaInitiator: called\n");
849
850    return cmdBld_CfgSetBaSession (pTWD->hCmdBld,
851                                   ACX_BA_SESSION_INITIATOR_POLICY,
852                                   uTid,
853                                   uState,
854                                   tRa,
855                                   uWinSize,
856                                   uInactivityTimeout,
857                                   NULL,
858                                   NULL);
859}
860
861TI_STATUS TWD_CfgSetBaReceiver (TI_HANDLE hTWD,
862                                TI_UINT8 uTid,
863                                TI_UINT8 uState,
864                                TMacAddr tRa,
865                                TI_UINT16 uWinSize)
866{
867    TTwd *pTWD = (TTwd *)hTWD;
868
869    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgSetBaReceiver: called\n");
870
871    return cmdBld_CfgSetBaSession (pTWD->hCmdBld,
872                                   ACX_BA_SESSION_RESPONDER_POLICY,
873                                   uTid,
874                                   uState,
875                                   tRa,
876                                   uWinSize,
877                                   0,
878                                   (void *)NULL,
879                                   (TI_HANDLE)NULL);
880}
881
882void TWD_CloseAllBaSessions(TI_HANDLE hTWD)
883{
884    TTwd        *pTWD = (TTwd *)hTWD;
885    TI_UINT32    i;
886
887    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CloseAllBaSessions: called\n");
888
889    /* close all BA sessions */
890    for(i=0; i <MAX_NUM_OF_802_1d_TAGS; ++i)
891    {
892        RxQueue_CloseBaSession(pTWD->hRxQueue, i);
893    }
894}
895
896TI_STATUS TWD_WdExpireEvent(TI_HANDLE hTWD)
897{
898    TTwd *pTWD = (TTwd*)hTWD;
899
900	if ( hTWD == NULL )
901	{
902		return(TI_NOK);
903	}
904
905	if (( pTWD->fFailureEventCb == NULL ) ||
906		( pTWD->hFailureEventCb == NULL ))
907	{
908		return(TI_NOK);
909	}
910
911	pTWD->fFailureEventCb(pTWD->hFailureEventCb, HW_WD_EXPIRE);
912
913	return(TI_OK);
914}
915
916