TWDriverCtrl.c revision 653850f71f9caaa41af19cadbab24bb5e655daf4
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        case TWD_FM_COEX_PARAM_ID:
212            return cmdBld_CfgFmCoex (pTWD->hCmdBld, &pParamInfo->content.tFmCoexParams, NULL, NULL);
213
214        /*
215         *  TX Parameters
216         */
217
218        case TWD_TX_RATE_CLASS_PARAM_ID:
219            return cmdBld_CfgTxRatePolicy (pTWD->hCmdBld, pParamInfo->content.pTxRatePlicy, NULL, NULL);
220
221        case TWD_QUEUES_PARAM_ID:
222            return cmdBld_CfgTid (pTWD->hCmdBld, pParamInfo->content.pQueueTrafficParams, NULL, NULL);
223
224        case TWD_CLK_RUN_ENABLE_PARAM_ID:
225            TRACE1(pTWD->hReport, REPORT_SEVERITY_INFORMATION, "TWD_SetParam: CLK_RUN_ENABLE %d\n", pParamInfo->content.halCtrlClkRunEnable);
226
227            /* Set the Encryption/Decryption on the HW*/
228            if (cmdBld_CfgClkRun (pTWD->hCmdBld, pParamInfo->content.halCtrlClkRunEnable, NULL, NULL) != TI_OK)
229                return TI_NOK;
230            break;
231
232        case TWD_COEX_ACTIVITY_PARAM_ID:
233            cmdBld_CfgCoexActivity (pTWD->hCmdBld, &pParamInfo->content.tTwdParamsCoexActivity, NULL, NULL);
234            break;
235
236        default:
237            TRACE1(pTWD->hReport, REPORT_SEVERITY_ERROR, "TWD_SetParam - ERROR - Param is not supported, 0x%x\n", pParamInfo->paramType);
238            return PARAM_NOT_SUPPORTED;
239    }
240
241    return TI_OK;
242}
243
244TI_STATUS TWD_GetParam (TI_HANDLE hTWD, TTwdParamInfo *pParamInfo)
245{
246    TTwd *pTWD = (TTwd *)hTWD;
247
248    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_GetParam: called\n");
249
250    return cmdBld_GetParam (pTWD->hCmdBld, pParamInfo);
251}
252
253TI_STATUS TWD_CfgRx (TI_HANDLE hTWD, TI_UINT32 uRxConfigOption, TI_UINT32 uRxFilterOption)
254{
255    TTwd     *pTWD = (TTwd *)hTWD;
256
257    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgRx: called\n");
258
259    return cmdBld_CfgRx (pTWD->hCmdBld, uRxConfigOption, uRxFilterOption, NULL, NULL);
260}
261
262TI_STATUS TWD_CfgArpIpAddrTable (TI_HANDLE hTWD, TIpAddr tIpAddr, TI_BOOL bEnabled, EIpVer eIpVer)
263{
264    TTwd *pTWD = (TTwd *)hTWD;
265
266    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgArpIpAddrTable: called\n");
267
268    return cmdBld_CfgArpIpAddrTable (pTWD->hCmdBld, tIpAddr, bEnabled, eIpVer, NULL, NULL);
269}
270
271/** @ingroup Misc
272 * \brief  Configure ARP IP Filter
273 *
274 * \param hTWD 			- TWD module object handle
275 * \param  bEnabled   	- Indicates if ARP filtering is Enabled (1) or Disabled (0)
276 * \return TI_OK on success or TI_NOK on failure
277 *
278 * \par Description
279 *
280 * \sa
281 */
282TI_STATUS TWD_CfgArpIpFilter (TI_HANDLE hTWD, TI_BOOL bEnabled)
283{
284    TTwd *pTWD = (TTwd *)hTWD;
285
286    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgArpIpFilter: called\n");
287
288    return cmdBld_CfgArpIpFilter (pTWD->hCmdBld, bEnabled, NULL, NULL);
289}
290
291TI_STATUS TWD_CmdSetSplitScanTimeOut  ( TI_HANDLE hTWD, TI_UINT32 uTimeOut )
292{
293    TTwd *pTWD = (TTwd *)hTWD;
294
295    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CmdSetSplitScanTimeOut: called\n");
296
297    return cmdBld_CmdSetSplitScanTimeOut (pTWD->hCmdBld, uTimeOut);
298}
299
300TI_STATUS TWD_CmdJoinBss (TI_HANDLE hTWD, TJoinBss *pJoinBssParams)
301{
302    TTwd      *pTWD = (TTwd *)hTWD;
303
304    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CmdJoinBss: called\n");
305
306    return cmdBld_CmdJoinBss (pTWD->hCmdBld, pJoinBssParams, NULL, NULL);
307}
308
309TI_STATUS TWD_CfgKeepAlive (TI_HANDLE hTWD, TKeepAliveParams *pKeepAliveParams)
310{
311    TTwd      *pTWD = (TTwd *)hTWD;
312
313    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgKeepAlive: called\n");
314
315    return cmdBld_CfgKeepAlive (pTWD->hCmdBld, pKeepAliveParams, NULL, NULL);
316}
317
318TI_STATUS TWD_CfgKeepAliveEnaDis(TI_HANDLE hTWD, TI_UINT8 enaDisFlag)
319{
320    TTwd      *pTWD = (TTwd *)hTWD;
321
322    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgKeepAliveEnaDis: called\n");
323
324    return cmdBld_CfgKeepAliveEnaDis (pTWD->hCmdBld, enaDisFlag, NULL, NULL);
325}
326
327TI_STATUS TWD_CmdTemplate (TI_HANDLE hTWD, TSetTemplate *pTemplateParams, void *fCb, TI_HANDLE hCb)
328{
329    TTwd *pTWD = (TTwd *)hTWD;
330
331    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CmdTemplate: called\n");
332
333    return cmdBld_CmdTemplate (pTWD->hCmdBld, pTemplateParams, fCb, hCb);
334}
335
336TI_STATUS TWD_CfgSlotTime (TI_HANDLE hTWD, ESlotTime eSlotTimeVal)
337{
338    TTwd   *pTWD = (TTwd *)hTWD;
339
340    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgSlotTime: called\n");
341
342    return cmdBld_CfgSlotTime (pTWD->hCmdBld, eSlotTimeVal, NULL, NULL);
343}
344
345TI_STATUS TWD_CfgPreamble (TI_HANDLE hTWD, EPreamble ePreamble)
346{
347    TTwd   *pTWD = (TTwd *)hTWD;
348
349    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgPreamble: called\n");
350
351    return cmdBld_CfgPreamble (pTWD->hCmdBld, (Preamble_e)ePreamble, NULL, NULL);
352}
353
354TI_STATUS TWD_CfgPacketDetectionThreshold (TI_HANDLE hTWD, TI_UINT32 threshold)
355{
356    TTwd   *pTWD = (TTwd *)hTWD;
357
358    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgPacketDetectionThreshold: called\n");
359
360    return cmdBld_CfgPacketDetectionThreshold (pTWD->hCmdBld, threshold, NULL, NULL);
361}
362
363TI_STATUS TWD_CmdDisableTx (TI_HANDLE hTWD)
364{
365    TTwd   *pTWD = (TTwd *)hTWD;
366
367    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CmdDisableTx: called\n");
368
369    return cmdBld_CmdDisableTx (pTWD->hCmdBld, NULL, NULL);
370}
371
372TI_STATUS TWD_CmdEnableTx (TI_HANDLE hTWD, TI_UINT8 channel)
373{
374    TTwd   *pTWD = (TTwd *)hTWD;
375
376    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CmdEnableTx: called\n");
377
378    return cmdBld_CmdEnableTx (pTWD->hCmdBld, channel, NULL, NULL);
379}
380
381TI_STATUS TWD_CmdSetStaState (TI_HANDLE hTWD, TI_UINT8 staState, void *fCb, TI_HANDLE hCb)
382{
383    TTwd *pTWD = (TTwd *)hTWD;
384
385    TRACE1(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_SetStaState: %d\n", staState);
386
387    return cmdBld_CmdSetStaState (pTWD->hCmdBld, staState, fCb, hCb);
388}
389
390TI_STATUS TWD_ItrRoammingStatisitics (TI_HANDLE hTWD, void *fCb, TI_HANDLE hCb, void * pCb)
391{
392    TTwd   *pTWD = (TTwd *)hTWD;
393
394    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_ItrRoammingStatisitics: called\n");
395
396    return cmdBld_ItrRoamimgStatisitics (pTWD->hCmdBld, fCb, hCb, pCb);
397}
398
399/** @ingroup UnKnown
400 * \brief	Interrogate Error Count
401 *
402 * \param  hTWD     	- TWD module object handle
403 * \param  fCb          - Pointer to Command CB Function
404 * \param  hCb          - Handle to Command CB Function Obj Parameters
405 * \param  pCb          - Pointer to read parameters
406 * \return TI_OK on success or TI_NOK on failure
407 *
408 * \par Description
409 * Interrogate ACX Error counter
410 *
411 * \sa
412 */
413TI_STATUS TWD_ItrErrorCnt (TI_HANDLE hTWD, void *fCb, TI_HANDLE hCb, void *pCb)
414{
415    TTwd   *pTWD = (TTwd *)hTWD;
416
417    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_ItrErrorCnt: called\n");
418
419    return cmdBld_ItrErrorCnt (pTWD->hCmdBld, fCb, hCb, pCb);
420}
421
422TI_STATUS TWD_CmdNoiseHistogram (TI_HANDLE hTWD, TNoiseHistogram *pNoiseHistParams)
423{
424    TTwd *pTWD = (TTwd *)hTWD;
425
426    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CmdNoiseHistogram: called\n");
427
428    return cmdBld_CmdNoiseHistogram (pTWD->hCmdBld, pNoiseHistParams, NULL, NULL);
429}
430
431TI_STATUS TWD_CfgBeaconFilterOpt (TI_HANDLE hTWD, TI_UINT8 uBeaconFilteringStatus, TI_UINT8 uNumOfBeaconsToBuffer)
432{
433    TTwd   *pTWD = (TTwd *)hTWD;
434
435    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgBeaconFilterOpt: called\n");
436
437    return cmdBld_CfgBeaconFilterOpt (pTWD->hCmdBld, uBeaconFilteringStatus, uNumOfBeaconsToBuffer, NULL, NULL);
438}
439
440TI_STATUS TWD_SetRateMngDebug(TI_HANDLE hTWD, RateMangeParams_t *pRateMngParams)
441{
442  TTwd   *pTWD = (TTwd *)hTWD;
443
444   TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_SetRateMngDebug: called\n");
445
446   return cmdBld_CfgRateMngDbg (pTWD->hCmdBld, pRateMngParams, NULL, NULL);
447}
448
449TI_STATUS TWD_CfgBeaconFilterTable (TI_HANDLE hTWD, TI_UINT8 uNumOfIe, TI_UINT8 *pIeTable, TI_UINT8 uIeTableSize)
450{
451    TTwd   *pTWD = (TTwd *)hTWD;
452
453    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgBeaconFilterTable: called\n");
454
455    return cmdBld_CfgBeaconFilterTable (pTWD->hCmdBld, uNumOfIe, pIeTable, uIeTableSize, NULL, NULL);
456}
457
458TI_STATUS TWD_CfgWakeUpCondition (TI_HANDLE hTWD, TPowerMgmtConfig *pPowerMgmtConfig)
459{
460    TTwd *pTWD = (TTwd *)hTWD;
461
462    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgWakeUpCondition: called\n");
463
464    return cmdBld_CfgWakeUpCondition (pTWD->hCmdBld, pPowerMgmtConfig, NULL, NULL);
465}
466
467TI_STATUS TWD_CfgBcnBrcOptions (TI_HANDLE hTWD, TPowerMgmtConfig *pPowerMgmtConfig)
468{
469    TTwd *pTWD = (TTwd *)hTWD;
470
471    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgBcnBrcOptions: called\n");
472
473    return cmdBld_CfgBcnBrcOptions (pTWD->hCmdBld, pPowerMgmtConfig, NULL, NULL);
474}
475
476TFwInfo * TWD_GetFWInfo (TI_HANDLE hTWD)
477{
478    TTwd *pTWD = (TTwd *)hTWD;
479
480    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_GetFWInfo: called\n");
481
482    return cmdBld_GetFWInfo (pTWD->hCmdBld);
483}
484
485TI_STATUS TWD_CmdSwitchChannel (TI_HANDLE hTWD, TSwitchChannelParams *pSwitchChannelCmd)
486{
487    TTwd   *pTWD = (TTwd *)hTWD;
488
489    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CmdSwitchChannel: called\n");
490
491    return cmdBld_CmdSwitchChannel (pTWD->hCmdBld, pSwitchChannelCmd, NULL, NULL);
492}
493
494TI_STATUS TWD_CmdSwitchChannelCancel (TI_HANDLE hTWD, TI_UINT8 channel)
495{
496    TTwd   *pTWD = (TTwd *)hTWD;
497
498    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CmdSwitchChannelCancel: called\n");
499
500    return cmdBld_CmdSwitchChannelCancel (pTWD->hCmdBld, channel, NULL, NULL);
501}
502
503TI_STATUS TWD_CfgMaxTxRetry (TI_HANDLE hTWD, TRroamingTriggerParams *pRoamingTriggerCmd)
504{
505    TTwd   *pTWD = (TTwd *)hTWD;
506
507    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgMaxTxRetry: called\n");
508
509    return cmdBld_CfgMaxTxRetry (pTWD->hCmdBld, pRoamingTriggerCmd, NULL, NULL);
510}
511
512TI_STATUS TWD_CfgConnMonitParams (TI_HANDLE hTWD, TRroamingTriggerParams *pRoamingTriggerCmd)
513{
514    TTwd   *pTWD = (TTwd *)hTWD;
515
516    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgConnMonitParams: called\n");
517
518    return cmdBld_CfgConnMonitParams (pTWD->hCmdBld, pRoamingTriggerCmd, NULL, NULL);
519}
520
521TI_STATUS TWD_ItrRSSI (TI_HANDLE hTWD, void *fCb, TI_HANDLE hCb, void *pCb)
522{
523    TTwd   *pTWD = (TTwd *)hTWD;
524
525    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_ItrRSSI: called\n");
526
527    return cmdBld_ItrRSSI (pTWD->hCmdBld, fCb, hCb, pCb);
528}
529
530TI_STATUS TWD_CmdFwDisconnect (TI_HANDLE hTWD, DisconnectType_e uDisconType, TI_UINT16 uDisconReason)
531{
532    TTwd   *pTWD = (TTwd *)hTWD;
533
534    return cmdBld_CmdFwDisconnect (pTWD->hCmdBld,
535                                   RX_CONFIG_OPTION_MY_DST_MY_BSS,
536                                   RX_FILTER_OPTION_FILTER_ALL,
537                                   uDisconType,
538                                   uDisconReason,
539                                   NULL,
540                                   NULL);
541}
542
543TI_STATUS TWD_CmdMeasurement (TI_HANDLE           hTWD,
544                              TMeasurementParams *pMeasurementParams,
545                              void               *fCommandResponseCb,
546                              TI_HANDLE           hCb)
547{
548    TTwd   *pTWD = (TTwd *)hTWD;
549
550    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CmdMeasurement: called\n");
551
552    return cmdBld_CmdMeasurement (pTWD->hCmdBld, pMeasurementParams, fCommandResponseCb, hCb);
553}
554
555TI_STATUS TWD_CmdMeasurementStop (TI_HANDLE hTWD, void* fCb, TI_HANDLE hCb)
556{
557    TTwd   *pTWD = (TTwd *)hTWD;
558
559    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CmdMeasurementStop: called\n");
560
561    return cmdBld_CmdMeasurementStop (pTWD->hCmdBld, fCb, hCb);
562}
563
564TI_STATUS TWD_CmdApDiscovery (TI_HANDLE hTWD, TApDiscoveryParams *pApDiscoveryParams)
565{
566    TTwd *pTWD = (TTwd *)hTWD;
567
568    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CmdApDiscovery: called\n");
569
570    return cmdBld_CmdApDiscovery (pTWD->hCmdBld, pApDiscoveryParams, NULL, NULL);
571}
572
573TI_STATUS TWD_CmdApDiscoveryStop (TI_HANDLE hTWD)
574{
575    TTwd   *pTWD = (TTwd *)hTWD;
576
577    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CmdApDiscoveryStop: called\n");
578
579    return cmdBld_CmdApDiscoveryStop (pTWD->hCmdBld, NULL, NULL);
580}
581
582TI_STATUS TWD_CfgGroupAddressTable (TI_HANDLE     hTWD,
583                                    TI_UINT8      uNumGroupAddrs,
584                                    TMacAddr      *pGroupAddr,
585                                    TI_BOOL       bEnabled)
586{
587    TTwd *pTWD = (TTwd *)hTWD;
588
589    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgGroupAddressTable: called\n");
590
591    return cmdBld_CfgGroupAddressTable (pTWD->hCmdBld, uNumGroupAddrs, pGroupAddr, bEnabled, NULL, NULL);
592}
593
594TI_STATUS TWD_GetGroupAddressTable (TI_HANDLE hTWD, TI_UINT8* pEnabled, TI_UINT8* pNumGroupAddrs, TMacAddr *pGroupAddr)
595{
596    TTwd   *pTWD = (TTwd *)hTWD;
597
598    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_GetGroupAddressTable: called\n");
599
600    return cmdBld_GetGroupAddressTable (pTWD->hCmdBld, pEnabled, pNumGroupAddrs, pGroupAddr);
601}
602
603TI_STATUS TWD_SetRadioBand (TI_HANDLE hTWD, ERadioBand eRadioBand)
604{
605    TTwd   *pTWD = (TTwd *)hTWD;
606
607    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_SetRadioBand: called\n");
608
609    return cmdBld_SetRadioBand (pTWD->hCmdBld, eRadioBand);
610}
611
612TI_STATUS TWD_CfgSleepAuth (TI_HANDLE hTWD, EPowerPolicy eMinPowerPolicy)
613{
614    TTwd *pTWD = (TTwd *)hTWD;
615
616    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgSleepAuth: called\n");
617
618    /* Configure the new power policy to the FW */
619    cmdBld_CfgSleepAuth (pTWD->hCmdBld, eMinPowerPolicy, NULL, NULL);
620
621    return TI_OK;
622}
623
624TI_STATUS TWD_CfgBurstMode (TI_HANDLE hTWD, TI_BOOL bEnabled)
625{
626    TTwd *pTWD = (TTwd *)hTWD;
627
628    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "cmdBld_CfgBurstMode: called\n");
629
630    /* Configure the burst mode to the FW */
631    cmdBld_CfgBurstMode (pTWD->hCmdBld, bEnabled, NULL, NULL);
632
633    return TI_OK;
634}
635
636
637
638TI_STATUS TWD_CmdHealthCheck (TI_HANDLE hTWD)
639{
640    TTwd   *pTWD = (TTwd *)hTWD;
641
642    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CmdHealthCheck: called\n");
643
644    return cmdBld_CmdHealthCheck (pTWD->hCmdBld, NULL, NULL);
645}
646
647TI_STATUS TWD_CfgMacClock (TI_HANDLE hTWD, TI_UINT32 uMacClock)
648{
649    TTwd *pTWD = (TTwd *)hTWD;
650
651    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgMacClock: called\n");
652
653    return cmdBld_CfgMacClock (pTWD->hCmdBld, uMacClock, NULL, NULL);
654}
655
656TI_STATUS TWD_CfgArmClock (TI_HANDLE hTWD, TI_UINT32 uArmClock)
657{
658    TTwd *pTWD = (TTwd *)hTWD;
659
660    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgArmClock: called\n");
661
662    return cmdBld_CfgArmClock (pTWD->hCmdBld, uArmClock, NULL, NULL);
663}
664
665TI_STATUS TWD_ItrMemoryMap (TI_HANDLE hTWD, MemoryMap_t *pMap, void *fCb, TI_HANDLE hCb)
666{
667    TTwd *pTWD = (TTwd *)hTWD;
668
669    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_ItrMemoryMap: called\n");
670
671    return cmdBld_ItrMemoryMap (pTWD->hCmdBld, pMap, fCb, hCb);
672}
673
674TI_STATUS TWD_ItrStatistics (TI_HANDLE hTWD, void *fCb, TI_HANDLE hCb, void *pCb)
675{
676    TTwd *pTWD = (TTwd *)hTWD;
677
678    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_ItrStatistics: called\n");
679
680    return cmdBld_ItrStatistics (pTWD->hCmdBld, fCb, hCb, pCb);
681}
682
683TI_STATUS TWD_ItrDataFilterStatistics (TI_HANDLE hTWD, void *fCb, TI_HANDLE hCb, void *pCb)
684{
685    TTwd *pTWD = (TTwd *)hTWD;
686
687    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_ItrDataFilterStatistics: called\n");
688
689    return cmdBld_ItrDataFilterStatistics (pTWD->hCmdBld, fCb, hCb, pCb);
690}
691
692TI_STATUS TWD_CfgEnableRxDataFilter (TI_HANDLE hTWD, TI_BOOL bEnabled, filter_e eDefaultAction)
693{
694    TTwd *pTWD = (TTwd *)hTWD;
695
696    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgEnableRxDataFilter: called\n");
697
698    return cmdBld_CfgEnableRxDataFilter (pTWD->hCmdBld, bEnabled, eDefaultAction, NULL, NULL);
699}
700
701TI_STATUS TWD_CfgRxDataFilter (TI_HANDLE    hTWD,
702                               TI_UINT8     index,
703                               TI_UINT8     command,
704                               filter_e     eAction,
705                               TI_UINT8     uNumFieldPatterns,
706                               TI_UINT8     uLenFieldPatterns,
707                               TI_UINT8     *pFieldPatterns)
708{
709    TTwd *pTWD = (TTwd *)hTWD;
710
711    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgRxDataFilter: called\n");
712
713    return cmdBld_CfgRxDataFilter (pTWD->hCmdBld,
714                                   index,
715                                   command,
716                                   eAction,
717                                   uNumFieldPatterns,
718                                   uLenFieldPatterns,
719                                   pFieldPatterns,
720                                   NULL,
721                                   NULL);
722}
723
724TI_STATUS TWD_CfgRssiSnrTrigger (TI_HANDLE hTWD, RssiSnrTriggerCfg_t* pRssiSnrTrigger)
725{
726    TTwd *pTWD = (TTwd *)hTWD;
727
728    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgRssiSnrTrigger: called\n");
729
730    return cmdBld_CfgRssiSnrTrigger (pTWD->hCmdBld, pRssiSnrTrigger, NULL, NULL);
731}
732
733TI_STATUS TWD_CfgAcParams (TI_HANDLE hTWD, TAcQosParams *pAcQosParams, void *fCb, TI_HANDLE hCb)
734{
735    TTwd *pTWD = (TTwd *)hTWD;
736
737    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgAcParams: called\n");
738
739    return cmdBld_CfgAcParams (pTWD->hCmdBld, pAcQosParams, fCb, hCb);
740}
741
742TI_STATUS TWD_CfgPsRxStreaming (TI_HANDLE hTWD, TPsRxStreaming *pPsRxStreaming, void *fCb, TI_HANDLE hCb)
743{
744    TTwd *pTWD = (TTwd *)hTWD;
745
746    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgPsRxStreaming: called\n");
747
748    return cmdBld_CfgPsRxStreaming (pTWD->hCmdBld, pPsRxStreaming, fCb, hCb);
749}
750
751TI_STATUS TWD_CfgBet (TI_HANDLE hTWD, TI_UINT8 Enable, TI_UINT8 MaximumConsecutiveET)
752{
753    TTwd *pTWD = (TTwd *)hTWD;
754
755    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgBet: called\n");
756
757    return cmdBld_CfgBet (pTWD->hCmdBld, Enable, MaximumConsecutiveET, NULL, NULL);
758}
759
760TI_STATUS TWD_SetSecuritySeqNum (TI_HANDLE hTWD, TI_UINT8 securitySeqNumLsByte)
761{
762    TTwd *pTWD = (TTwd *)hTWD;
763
764    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_SetSecuritySeqNum: called\n");
765
766    return cmdBld_SetSecuritySeqNum (pTWD->hCmdBld, securitySeqNumLsByte);
767}
768
769TI_STATUS TWD_CfgSetFwHtCapabilities (TI_HANDLE hTWD,
770									  Tdot11HtCapabilitiesUnparse *pHtCapabilitiesIe,
771									  TI_BOOL bAllowHtOperation)
772{
773    TTwd        *pTWD           = (TTwd *)hTWD;
774    TI_UINT32   uHtCapabilites;
775    TI_UINT8    uAmpduMaxLeng = 0;
776    TI_UINT8    uAmpduMinSpac = 0;
777    TI_UINT16   uHtCapabilitesField;
778
779    /* Note, currently this value will be set to FFFFFFFFFFFF to indicate it is relevant for all peers
780       since we only support HT in infrastructure mode. Later on this field will be relevant to IBSS/DLS operation */
781    TMacAddr    tMacAddress = {0xff,0xff,0xff,0xff,0xff,0xff};
782
783    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgSetFwHtCapabilities: called\n");
784
785    /* Allow HT Operation ? */
786    if (bAllowHtOperation == TI_TRUE)
787    {
788       /* get date from HT capabilities field */
789       /* Handle endian for the field */
790       COPY_WLAN_WORD(&uHtCapabilitesField, pHtCapabilitiesIe->aHtCapabilitiesIe);
791       uHtCapabilites = FW_CAP_BIT_MASK_HT_OPERATION |
792                        ((uHtCapabilitesField & HT_CAP_GREENFIELD_FRAME_FORMAT_BITMASK)    ? FW_CAP_BIT_MASK_GREENFIELD_FRAME_FORMAT       : 0) |
793                        ((uHtCapabilitesField & HT_CAP_SHORT_GI_FOR_20MHZ_BITMASK)         ? FW_CAP_BIT_MASK_SHORT_GI_FOR_20MHZ_PACKETS    : 0) |
794                        ((uHtCapabilitesField & HT_CAP_LSIG_TXOP_PROTECTION_BITMASK)       ? FW_CAP_BIT_MASK_LSIG_TXOP_PROTECTION          : 0);
795
796       /* get date from HT capabilities field */
797       uHtCapabilites |= ((uHtCapabilitesField & HT_EXT_HT_CONTROL_FIELDS_BITMASK) ? FW_CAP_BIT_MASK_HT_CONTROL_FIELDS : 0) |
798                         ((uHtCapabilitesField & HT_EXT_RD_INITIATION_BITMASK)     ? FW_CAP_BIT_MASK_RD_INITIATION     : 0);
799
800       /* get date from A-MPDU parameters field */
801       uAmpduMaxLeng = pHtCapabilitiesIe->aHtCapabilitiesIe[HT_CAP_AMPDU_PARAMETERS_FIELD_OFFSET] & HT_CAP_AMPDU_MAX_RX_FACTOR_BITMASK;
802       uAmpduMinSpac = (pHtCapabilitiesIe->aHtCapabilitiesIe[HT_CAP_AMPDU_PARAMETERS_FIELD_OFFSET] >> 2) & HT_CAP_AMPDU_MIN_START_SPACING_BITMASK;
803    }
804    /* not Allow HT Operation */
805    else
806    {
807        uHtCapabilites = 0;
808    }
809
810    return cmdBld_CfgSetFwHtCapabilities (pTWD->hCmdBld,
811                                          uHtCapabilites,
812                                          tMacAddress,
813                                          uAmpduMaxLeng,
814                                          uAmpduMinSpac,
815                                          NULL,
816                                          NULL);
817}
818
819TI_STATUS TWD_CfgSetFwHtInformation (TI_HANDLE hTWD, Tdot11HtInformationUnparse *pHtInformationIe)
820{
821    TTwd        *pTWD           = (TTwd *)hTWD;
822    TI_UINT8    uRifsMode;
823    TI_UINT8    uHtProtection;
824    TI_UINT8    uGfProtection;
825    TI_UINT8    uHtTxBurstLimit;
826    TI_UINT8    uDualCtsProtection;
827
828    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgSetFwHtInformation: called\n");
829
830    uRifsMode = (pHtInformationIe->aHtInformationIe[1] & HT_INF_RIFS_MOD_BITMASK) >> 3;
831
832    uHtProtection = (pHtInformationIe->aHtInformationIe[2] & HT_INF_OPERATION_MOD_BITMASK);
833
834    uGfProtection = (pHtInformationIe->aHtInformationIe[3] & HT_INF_NON_GF_PRES_BITMASK) >> 2;
835
836    uHtTxBurstLimit = (pHtInformationIe->aHtInformationIe[3] & HT_INF_TX_BURST_LIMIT_BITMASK) >> 3;
837
838    uDualCtsProtection = (pHtInformationIe->aHtInformationIe[4] & HT_INF_DUAL_BEACON_BITMASK) >> 6;
839
840    return cmdBld_CfgSetFwHtInformation (pTWD->hCmdBld,
841                                         uRifsMode,
842                                         uHtProtection,
843                                         uGfProtection,
844                                         uHtTxBurstLimit,
845                                         uDualCtsProtection,
846                                         NULL,
847                                         NULL);
848}
849
850TI_STATUS TWD_CfgSetBaInitiator (TI_HANDLE hTWD,
851                                 TI_UINT8 uTid,
852                                 TI_UINT8 uState,
853                                 TMacAddr tRa,
854                                 TI_UINT16 uWinSize,
855                                 TI_UINT16 uInactivityTimeout)
856
857{
858	TTwd *pTWD = (TTwd *)hTWD;
859
860    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgSetBaInitiator: called\n");
861
862    return cmdBld_CfgSetBaSession (pTWD->hCmdBld,
863                                   ACX_BA_SESSION_INITIATOR_POLICY,
864                                   uTid,
865                                   uState,
866                                   tRa,
867                                   uWinSize,
868                                   uInactivityTimeout,
869                                   NULL,
870                                   NULL);
871}
872
873TI_STATUS TWD_CfgSetBaReceiver (TI_HANDLE hTWD,
874                                TI_UINT8 uTid,
875                                TI_UINT8 uState,
876                                TMacAddr tRa,
877                                TI_UINT16 uWinSize)
878{
879    TTwd *pTWD = (TTwd *)hTWD;
880
881    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CfgSetBaReceiver: called\n");
882
883    return cmdBld_CfgSetBaSession (pTWD->hCmdBld,
884                                   ACX_BA_SESSION_RESPONDER_POLICY,
885                                   uTid,
886                                   uState,
887                                   tRa,
888                                   uWinSize,
889                                   0,
890                                   (void *)NULL,
891                                   (TI_HANDLE)NULL);
892}
893
894void TWD_CloseAllBaSessions(TI_HANDLE hTWD)
895{
896    TTwd        *pTWD = (TTwd *)hTWD;
897    TI_UINT32    i;
898
899    TRACE0(pTWD->hReport, REPORT_SEVERITY_INFORMATION , "TWD_CloseAllBaSessions: called\n");
900
901    /* close all BA sessions */
902    for(i=0; i <MAX_NUM_OF_802_1d_TAGS; ++i)
903    {
904        RxQueue_CloseBaSession(pTWD->hRxQueue, i);
905    }
906}
907
908TI_STATUS TWD_WdExpireEvent(TI_HANDLE hTWD)
909{
910    TTwd *pTWD = (TTwd*)hTWD;
911
912	if ( hTWD == NULL )
913	{
914		return(TI_NOK);
915	}
916
917	if (( pTWD->fFailureEventCb == NULL ) ||
918		( pTWD->hFailureEventCb == NULL ))
919	{
920		return(TI_NOK);
921	}
922
923	pTWD->fFailureEventCb(pTWD->hFailureEventCb, HW_WD_EXPIRE);
924
925	return(TI_OK);
926}
927
928