1/*
2 * CmdBld.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  CmdBld.c
36 *  \brief Command builder main
37 *
38 *  \see   CmdBld.h
39 */
40#define __FILE_ID__  FILE_ID_90
41#include "TWDriver.h"
42#include "osApi.h"
43#include "tidef.h"
44#include "report.h"
45#include "public_infoele.h"
46#include "CmdBld.h"
47#include "txResult_api.h"
48#include "CmdBldCmdIE.h"
49#include "CmdBldCfgIE.h"
50#include "CmdBldItrIE.h"
51#include "CmdQueue_api.h"
52#include "eventMbox_api.h"
53#include "TWDriverInternal.h"
54#include "HwInit_api.h"
55
56#define DEFAULT_TRACE_ENABLE                   0
57#define DEFAULT_TRACE_OUT                      0
58
59#define DEFAULT_PBCC_DYNAMIC_ENABLE_VAL        0
60#define DEFAULT_PBCC_DYNAMIC_INTERVAL          500
61#define DEFAULT_PBCC_DYNAMIC_IGNORE_MCAST      0
62
63#define DEFAULT_HW_RADIO_CHANNEL               11
64
65#define DEFAULT_CW_MIN                         15
66
67#define DEFAULT_USE_DEVICE_ERROR_INTERRUPT     1
68
69#define DEFAULT_UCAST_PRIORITY                 0
70
71#define DEFAULT_NUM_STATIONS                   1
72
73/* only for AP */
74/*  8 increase number of BC frames */
75#define DEFAULT_NUM_BCAST_TX_DESC              16
76
77#define DEFAULT_BCAST_PRIORITY                 0x81
78
79/* hw access method*/
80typedef enum
81{
82    HW_ACCESS_BUS_SLAVE_INDIRECT    = 0,
83    HW_ACCESS_BUS_SLAVE_DIRECT      = 1,
84    HW_ACCESS_BUS_MASTER            = 2
85
86} EHwAccessMethod;
87
88typedef int (*TConfigFwCb) (TI_HANDLE, TI_STATUS);
89
90
91static TI_STATUS cmdBld_ConfigSeq               (TI_HANDLE hCmdBld);
92static TI_STATUS cmdBld_GetCurrentAssociationId (TI_HANDLE hCmdBld, TI_UINT16 *pAidVal);
93static TI_STATUS cmdBld_GetArpIpAddressesTable  (TI_HANDLE hCmdBld, TIpAddr *pIpAddr, TI_UINT8 *pEnabled , EIpVer *pIpVer);
94static TI_STATUS cmdBld_JoinCmpltForReconfigCb  (TI_HANDLE hCmdBld);
95static TI_STATUS cmdBld_DummyCb                 (TI_HANDLE hCmdBld);
96
97
98
99
100TI_HANDLE cmdBld_Create (TI_HANDLE hOs)
101{
102    TCmdBld        *pCmdBld;
103    TI_UINT32          uNumOfStations;
104
105    /* Allocate the command builder */
106    pCmdBld = (TCmdBld *)os_memoryAlloc (hOs, sizeof(TCmdBld));
107    if (pCmdBld == NULL)
108    {
109        WLAN_OS_REPORT(("cmdBld_Create: Error memory allocation\n"));
110        return NULL;
111    }
112    os_memoryZero (hOs, (void *)pCmdBld, sizeof(TCmdBld));
113
114    pCmdBld->hOs = hOs;
115
116    /* Create the Params object */
117    /* make this code flat, move it to configure */
118    {
119        TWlanParams     *pWlanParams    = &DB_WLAN(pCmdBld);
120        TDmaParams      *pDmaParams     = &DB_DMA(pCmdBld);
121        TBssInfoParams  *pBssInfoParams = &DB_BSS(pCmdBld);
122        TGenCounters    *pGenCounters   = &DB_CNT(pCmdBld);
123
124        /* General counters */
125        pGenCounters->FcsErrCnt                     = 0;
126
127        /* BSS info paramaters */
128        pBssInfoParams->RadioChannel                = DEFAULT_HW_RADIO_CHANNEL;
129        pBssInfoParams->Ctrl                        = 0;
130        /*
131         * Intilaize the ctrl field in the BSS join structure
132         * Only bit_7 in the ctrl field is vurrently in use.
133         * If bit_7 is on => Doing Tx flash before joining new AP
134         */
135        pBssInfoParams->Ctrl                        |= JOIN_CMD_CTRL_TX_FLUSH;
136
137        /* WLAN parameters*/
138
139        /* Init filters as station (start/join with BssType will overwrite the values) */
140        cmdBld_SetRxFilter ((TI_HANDLE)pCmdBld, RX_CONFIG_OPTION_MY_DST_MY_BSS, RX_FILTER_OPTION_FILTER_ALL);
141        pWlanParams->UseDeviceErrorInterrupt        = DEFAULT_USE_DEVICE_ERROR_INTERRUPT;
142        /* Initialize the params object database fields */
143        pWlanParams->hwAccessMethod = HW_ACCESS_BUS_SLAVE_INDIRECT;
144        pWlanParams->maxSitesFragCollect = TWD_SITE_FRAG_COLLECT_DEF;
145        pWlanParams->RtsThreshold = TWD_RTS_THRESHOLD_DEF;
146        pWlanParams->bJoin = TI_FALSE;
147        /* Soft Gemini defaults */
148        pWlanParams->SoftGeminiEnable = SG_DISABLE;
149        /* Beacon filter defaults */
150        pWlanParams->beaconFilterParams.desiredState    = TI_FALSE;
151        pWlanParams->beaconFilterParams.numOfElements   = DEF_NUM_STORED_FILTERS;
152        pWlanParams->beaconFilterIETable.numberOfIEs    = DEF_BEACON_FILTER_IE_TABLE_NUM;
153        pWlanParams->beaconFilterIETable.IETableSize    = BEACON_FILTER_IE_TABLE_DEF_SIZE;
154        /* Roaming  parameters */
155        pWlanParams->roamTriggers.BssLossTimeout    = NO_BEACON_DEFAULT_TIMEOUT;
156        pWlanParams->roamTriggers.TsfMissThreshold  = OUT_OF_SYNC_DEFAULT_THRESHOLD;
157        /* CoexActivity table */
158        pWlanParams->tWlanParamsCoexActivityTable.numOfElements = COEX_ACTIVITY_TABLE_DEF_NUM;
159
160        /* DMA parameters */
161        /* Initialize the Params object database fields*/
162        pDmaParams->NumStations                     = DEFAULT_NUM_STATIONS;
163        uNumOfStations                              = (TI_UINT32)pDmaParams->NumStations;
164    }
165
166    pCmdBld->uLastElpCtrlMode = ELPCTRL_MODE_NORMAL;
167
168    /* Create security objects */
169    pCmdBld->tSecurity.eSecurityMode = TWD_CIPHER_NONE;
170    pCmdBld->tSecurity.uNumOfStations = uNumOfStations;
171    DB_KEYS(pCmdBld).pReconfKeys = (TSecurityKeys*)os_memoryAlloc (hOs,
172                                        sizeof(TSecurityKeys) * (uNumOfStations * NO_OF_RECONF_SECUR_KEYS_PER_STATION + NO_OF_EXTRA_RECONF_SECUR_KEYS));
173    os_memoryZero (hOs,
174                   (void *)(DB_KEYS(pCmdBld).pReconfKeys),
175                   sizeof(TSecurityKeys) * (uNumOfStations * NO_OF_RECONF_SECUR_KEYS_PER_STATION + NO_OF_EXTRA_RECONF_SECUR_KEYS));
176
177
178    WLAN_INIT_REPORT(("cmdBld_Create end %x\n",(TI_HANDLE)pCmdBld));
179
180    return (TI_HANDLE)pCmdBld;
181}
182
183
184TI_STATUS cmdBld_Destroy (TI_HANDLE hCmdBld)
185{
186    TCmdBld      *pCmdBld = (TCmdBld *)hCmdBld;
187    TDmaParams   *pDmaParams = NULL;
188    TI_UINT32        uNumOfStations;
189
190    if (pCmdBld == NULL)
191    {
192        return TI_OK;
193    }
194
195    pDmaParams = &DB_DMA(hCmdBld);
196
197    uNumOfStations = (TI_UINT32)pDmaParams->NumStations;
198
199    if (DB_KEYS(pCmdBld).pReconfKeys)
200    {
201        os_memoryFree (pCmdBld->hOs,
202                       DB_KEYS(pCmdBld).pReconfKeys,
203                       sizeof(TSecurityKeys) * (uNumOfStations * NO_OF_RECONF_SECUR_KEYS_PER_STATION + NO_OF_EXTRA_RECONF_SECUR_KEYS));
204    }
205
206    /* free the whalCtrl data structure */
207    os_memoryFree (pCmdBld->hOs, pCmdBld, sizeof(TCmdBld));
208
209    return TI_OK;
210}
211
212TI_STATUS cmdBld_Restart (TI_HANDLE hCmdBld)
213{
214    TCmdBld      *pCmdBld = (TCmdBld *)hCmdBld;
215
216    /* This init is for recovery stage */
217    pCmdBld->uLastElpCtrlMode = ELPCTRL_MODE_NORMAL;
218
219    /*
220     * This call is to have the recovery process in AWAKE mode
221     * Prevent move to sleep mode between Hw_Init and Fw_Init
222     */
223    cmdBld_CfgIeSleepAuth (hCmdBld, DB_WLAN(hCmdBld).minPowerLevel, NULL, NULL);
224
225    return TI_OK;
226}
227
228TI_STATUS cmdBld_Config (TI_HANDLE  hCmdBld,
229                         TI_HANDLE  hReport,
230                         void      *fFinalizeDownload,
231                         TI_HANDLE  hFinalizeDownload,
232                         TI_HANDLE  hEventMbox,
233                         TI_HANDLE  hCmdQueue,
234                         TI_HANDLE  hTwIf)
235{
236    TCmdBld        *pCmdBld = (TCmdBld *)hCmdBld;
237    TI_UINT32       index;
238
239    pCmdBld->hReport = hReport;
240    pCmdBld->fFinalizeDownload = fFinalizeDownload;
241    pCmdBld->hFinalizeDownload = hFinalizeDownload;
242    pCmdBld->hEventMbox = hEventMbox;
243    pCmdBld->hCmdQueue = hCmdQueue;
244    pCmdBld->hTwIf  = hTwIf;
245
246    /* Reset all reconfig valid fields*/
247    DB_KEYS(pCmdBld).bHwEncDecrEnableValid = TI_FALSE;
248    DB_KEYS(pCmdBld).bDefaultKeyIdValid    = TI_FALSE;
249    for (index = 0;
250         index < pCmdBld->tSecurity.uNumOfStations * NO_OF_RECONF_SECUR_KEYS_PER_STATION + NO_OF_EXTRA_RECONF_SECUR_KEYS;
251         index++)
252        (DB_KEYS(pCmdBld).pReconfKeys + index)->keyType = KEY_NULL;
253
254
255    return TI_OK;
256}
257
258
259
260static void cmdBld_ConfigFwCb (TI_HANDLE hCmdBld, TI_STATUS status, void *pData)
261{
262    TCmdBld        *pCmdBld = (TCmdBld *)hCmdBld;
263    MemoryMap_t    *pMemMap = &pCmdBld->tMemMap;
264    TDmaParams     *pDmaParams = &DB_DMA(hCmdBld);
265
266    /* Arrived from callback */
267    if (pData)
268    {
269        TI_UINT32         *pSwap, i, uMemMapNumFields;
270
271        /* Solve endian problem (all fields are 32 bit) */
272        uMemMapNumFields = (sizeof(MemoryMap_t) - sizeof(EleHdrStruct)) % 4;
273        pSwap = (TI_UINT32* )&(pMemMap->codeStart);
274        for (i = 0; i < uMemMapNumFields; i++)
275        {
276            pSwap[i] = ENDIAN_HANDLE_LONG(pSwap[i]);
277        }
278    }
279
280    /* Save number of TX blocks */
281    pDmaParams->NumTxBlocks = pMemMap->numTxMemBlks;
282    /* Firmware Control block is internally pointing to TxResultInterface structure */
283    pDmaParams->fwTxResultInterface = pMemMap->trqBlock.controlBlock;
284    pDmaParams->fwRxCBufPtr =           pMemMap->rxCBufPtr;
285    pDmaParams->fwTxCBufPtr =           pMemMap->txCBufPtr;
286    pDmaParams->fwRxControlPtr =        pMemMap->rxControlPtr;
287    pDmaParams->fwTxControlPtr =        pMemMap->txControlPtr;
288
289    pDmaParams->PacketMemoryPoolStart = (TI_UINT32)pMemMap->packetMemoryPoolStart;
290
291    /* Call the upper layer callback */
292    (*((TConfigFwCb)pCmdBld->fConfigFwCb)) (pCmdBld->hConfigFwCb, TI_OK);
293}
294
295
296/****************************************************************************
297 *                      cmdBld_ConfigFw()
298 ****************************************************************************
299 * DESCRIPTION: Configure the WLAN firmware
300 *
301 * INPUTS: None
302 *
303 * OUTPUT: None
304 *
305 * RETURNS: TI_OK or TI_NOK
306 ****************************************************************************/
307TI_STATUS cmdBld_ConfigFw (TI_HANDLE hCmdBld, void *fConfigFwCb, TI_HANDLE hConfigFwCb)
308{
309    TCmdBld        *pCmdBld = (TCmdBld *)hCmdBld;
310
311    pCmdBld->fConfigFwCb = fConfigFwCb;
312    pCmdBld->hConfigFwCb = hConfigFwCb;
313    pCmdBld->uIniSeq = 0;
314    /* should be re-initialized for recovery,   pCmdBld->uLastElpCtrlMode = ELPCTRL_MODE_KEEP_AWAKE; */
315
316    /* Start configuration sequence */
317    return cmdBld_ConfigSeq (hCmdBld);
318}
319
320
321typedef TI_STATUS (*TCmdCfgFunc) (TI_HANDLE);
322
323
324static TI_STATUS __cmd_probe_req (TI_HANDLE hCmdBld)
325{
326    TI_STATUS   tStatus = TI_OK;
327
328    /* keep space for 2.4 GHz probe request */
329    tStatus = cmdBld_CmdIeConfigureTemplateFrame (hCmdBld,
330                                                  NULL,
331                                                  DB_WLAN(hCmdBld).probeRequestTemplateSize,
332                                                  CFG_TEMPLATE_PROBE_REQ_2_4,
333                                                  0,
334                                                  NULL,
335                                                  NULL);
336    if (TI_OK != tStatus)
337    {
338        return tStatus;
339    }
340
341    /* keep space for 5.0 GHz probe request */
342    return cmdBld_CmdIeConfigureTemplateFrame (hCmdBld,
343                                               NULL,
344                                               DB_WLAN(hCmdBld).probeRequestTemplateSize,
345                                               CFG_TEMPLATE_PROBE_REQ_5,
346                                               0,
347                                             (void *)cmdBld_ConfigSeq,
348                                             hCmdBld);
349}
350
351
352static TI_STATUS __cmd_null_data (TI_HANDLE hCmdBld)
353{
354    return cmdBld_CmdIeConfigureTemplateFrame (hCmdBld,
355                                             NULL,
356                                             DB_WLAN(hCmdBld).nullTemplateSize,
357                                               TEMPLATE_NULL_DATA,
358                                               0,
359                                             (void *)cmdBld_ConfigSeq,
360                                             hCmdBld);
361}
362
363static TI_STATUS __cmd_burst_mode_enable (TI_HANDLE hCmdBld)
364{
365	return cmdBld_CfgIeBurstMode (hCmdBld,
366							  DB_AC(hCmdBld).isBurstModeEnabled,
367							  (void *)cmdBld_ConfigSeq,
368							  hCmdBld);
369}
370
371
372static TI_STATUS __cmd_smart_reflex_debug (TI_HANDLE hCmdBld)
373{
374    return cmdBld_CfgIeSRDebug (hCmdBld,
375							   &(DB_SR(hCmdBld).tSmartReflexDebugParams),
376							   (void *)cmdBld_ConfigSeq,
377							   hCmdBld);
378}
379
380
381static TI_STATUS __cmd_smart_reflex_state (TI_HANDLE hCmdBld)
382{
383	return cmdBld_CfgIeSRState (hCmdBld,
384							   (uint8) DB_SR(hCmdBld).tSmartReflexState.enable,
385							   (void *)cmdBld_ConfigSeq,
386							   hCmdBld);
387}
388
389
390static TI_STATUS __cmd_smart_reflex_params (TI_HANDLE hCmdBld)
391{
392	return cmdBld_CfgIeSRParams (hCmdBld,
393							     &(DB_SR(hCmdBld).tSmartReflexParams),
394							    (void *)cmdBld_ConfigSeq,
395							     hCmdBld);
396}
397
398
399static TI_STATUS __cmd_disconn (TI_HANDLE hCmdBld)
400{
401    return cmdBld_CmdIeConfigureTemplateFrame (hCmdBld,
402                                             NULL,
403                                             DB_WLAN(hCmdBld).disconnTemplateSize,
404                                             TEMPLATE_DISCONNECT,
405                                             0,
406                                             (void *)cmdBld_ConfigSeq,
407                                             hCmdBld);
408}
409
410static TI_STATUS __cmd_ps_poll (TI_HANDLE hCmdBld)
411{
412    return cmdBld_CmdIeConfigureTemplateFrame (hCmdBld,
413                                             NULL,
414                                             DB_WLAN(hCmdBld).PsPollTemplateSize,
415                                               TEMPLATE_PS_POLL,
416                                               0,
417                                             (void *)cmdBld_ConfigSeq,
418                                             hCmdBld);
419}
420
421
422static TI_STATUS __cmd_qos_null_data (TI_HANDLE hCmdBld)
423{
424    return cmdBld_CmdIeConfigureTemplateFrame (hCmdBld,
425                                             NULL,
426                                             DB_WLAN(hCmdBld).qosNullDataTemplateSize,
427                                               TEMPLATE_QOS_NULL_DATA,
428                                               0,
429                                             (void *)cmdBld_ConfigSeq,
430                                             hCmdBld);
431}
432
433
434static TI_STATUS __cmd_probe_resp (TI_HANDLE hCmdBld)
435{
436    return cmdBld_CmdIeConfigureTemplateFrame (hCmdBld,
437                                             NULL,
438                                             DB_WLAN(hCmdBld).probeResponseTemplateSize,
439                                               TEMPLATE_PROBE_RESPONSE,
440                                               0,
441                                             (void *)cmdBld_ConfigSeq,
442                                             hCmdBld);
443}
444
445
446static TI_STATUS __cmd_beacon (TI_HANDLE hCmdBld)
447{
448    return cmdBld_CmdIeConfigureTemplateFrame (hCmdBld,
449                                             NULL,
450                                             DB_WLAN(hCmdBld).beaconTemplateSize,
451                                               TEMPLATE_BEACON,
452                                               0,
453                                             (void *)cmdBld_ConfigSeq,
454                                             hCmdBld);
455}
456
457static TI_STATUS __cmd_keep_alive_tmpl (TI_HANDLE hCmdBld)
458{
459    TI_UINT32   index;
460    TI_STATUS   status = TI_NOK;
461
462    /*
463     * config templates
464     * fisr configure all indexes but the last one with no CB, and than configure the last one
465     * with a CB to continue configuration.
466     */
467    for (index = 0; index < KLV_MAX_TMPL_NUM - 1; index++)
468    {
469        status =  cmdBld_CmdIeConfigureTemplateFrame (hCmdBld,
470                                                      NULL,
471                                                      MAX_TEMPLATES_SIZE,
472                                                      TEMPLATE_KLV,
473                                                      index,
474                                                      NULL,
475                                                      NULL);
476        if (TI_OK != status)
477        {
478            return status;
479        }
480    }
481
482    status =  cmdBld_CmdIeConfigureTemplateFrame (hCmdBld,
483                                                  NULL,
484                                                  MAX_TEMPLATES_SIZE,
485                                                  TEMPLATE_KLV,
486                                                  index,
487                                                  (void *)cmdBld_ConfigSeq,
488                                                  hCmdBld);
489
490    return status;
491}
492
493
494static TI_STATUS __cfg_mem (TI_HANDLE hCmdBld)
495{
496    /* Configure the weight among the different hardware queues */
497    return cmdBld_CfgIeConfigMemory (hCmdBld, &DB_DMA(hCmdBld), (void *)cmdBld_ConfigSeq, hCmdBld);
498}
499
500
501static TI_STATUS __cfg_rx_msdu_life_time (TI_HANDLE hCmdBld)
502{
503    /* Configure the Rx Msdu Life Time (expiry time of de-fragmentation in FW) */
504    return cmdBld_CfgIeRxMsduLifeTime (hCmdBld,
505                                       DB_WLAN(hCmdBld).MaxRxMsduLifetime,
506                                       (void *)cmdBld_ConfigSeq,
507                                       hCmdBld);
508}
509
510
511static TI_STATUS __cfg_rx (TI_HANDLE hCmdBld)
512{
513    return cmdBld_CfgIeRx (hCmdBld,
514                           DB_WLAN(hCmdBld).RxConfigOption,
515                           DB_WLAN(hCmdBld).RxFilterOption,
516                           (void *)cmdBld_ConfigSeq,
517                           hCmdBld);
518}
519
520
521static TI_STATUS __cfg_ac_params_0 (TI_HANDLE hCmdBld)
522{
523    /*
524     * NOTE: Set following parameter only if configured.
525     *       Otherwise, is contains garbage.
526     */
527
528    if (DB_AC(hCmdBld).isAcConfigured[0])
529    {
530        return cmdBld_CfgAcParams (hCmdBld, &DB_AC(hCmdBld).ac[0], (void *)cmdBld_ConfigSeq, hCmdBld);
531    }
532    else
533    {
534        return TI_NOK;
535    }
536}
537
538
539static TI_STATUS __cfg_ac_params_1 (TI_HANDLE hCmdBld)
540{
541    /*
542     * NOTE: Set following parameter only if configured.
543     *       Otherwise, is contains garbage.
544     */
545
546    if (DB_AC(hCmdBld).isAcConfigured[1])
547    {
548        return cmdBld_CfgAcParams (hCmdBld, &DB_AC(hCmdBld).ac[1], (void *)cmdBld_ConfigSeq, hCmdBld);
549    }
550    else
551    {
552        return TI_NOK;
553    }
554}
555
556
557static TI_STATUS __cfg_ac_params_2 (TI_HANDLE hCmdBld)
558{
559    /*
560     * NOTE: Set following parameter only if configured.
561     *       Otherwise, is contains garbage.
562     */
563
564    if (DB_AC(hCmdBld).isAcConfigured[2])
565    {
566        return cmdBld_CfgAcParams (hCmdBld, &DB_AC(hCmdBld).ac[2], (void *)cmdBld_ConfigSeq, hCmdBld);
567    }
568    else
569    {
570        return TI_NOK;
571    }
572}
573
574
575static TI_STATUS __cfg_ac_params_3 (TI_HANDLE hCmdBld)
576{
577    /*
578     * NOTE: Set following parameter only if configured.
579     *       Otherwise, is contains garbage.
580     */
581
582    if (DB_AC(hCmdBld).isAcConfigured[3])
583    {
584        return cmdBld_CfgAcParams (hCmdBld, &DB_AC(hCmdBld).ac[3], (void *)cmdBld_ConfigSeq, hCmdBld);
585    }
586    else
587    {
588        return TI_NOK;
589    }
590}
591
592
593static TI_STATUS __cfg_tid_0 (TI_HANDLE hCmdBld)
594{
595    /*
596     * NOTE: Set following parameter only if configured.
597     *       Otherwise, is contains garbage.
598     */
599    if (DB_QUEUES(hCmdBld).isQueueConfigured[0])
600    {
601        return cmdBld_CfgTid (hCmdBld, &DB_QUEUES(hCmdBld).queues[0], (void *)cmdBld_ConfigSeq, hCmdBld);
602    }
603    else
604    {
605        return TI_NOK;
606    }
607}
608
609
610static TI_STATUS __cfg_tid_1 (TI_HANDLE hCmdBld)
611{
612    /*
613     * NOTE: Set following parameter only if configured.
614     *       Otherwise, is contains garbage.
615     */
616    if (DB_QUEUES(hCmdBld).isQueueConfigured[1])
617    {
618        return cmdBld_CfgTid (hCmdBld, &DB_QUEUES(hCmdBld).queues[1], (void *)cmdBld_ConfigSeq, hCmdBld);
619    }
620    else
621    {
622        return TI_NOK;
623    }
624}
625
626
627static TI_STATUS __cfg_tid_2 (TI_HANDLE hCmdBld)
628{
629    /*
630     * NOTE: Set following parameter only if configured.
631     *       Otherwise, is contains garbage.
632     */
633    if (DB_QUEUES(hCmdBld).isQueueConfigured[2])
634    {
635        return cmdBld_CfgTid (hCmdBld, &DB_QUEUES(hCmdBld).queues[2], (void *)cmdBld_ConfigSeq, hCmdBld);
636    }
637    else
638    {
639        return TI_NOK;
640    }
641}
642
643
644static TI_STATUS __cfg_tid_3 (TI_HANDLE hCmdBld)
645{
646    /*
647     * NOTE: Set following parameter only if configured.
648     *       Otherwise, is contains garbage.
649     */
650    if (DB_QUEUES(hCmdBld).isQueueConfigured[3])
651    {
652        return cmdBld_CfgTid (hCmdBld, &DB_QUEUES(hCmdBld).queues[3], (void *)cmdBld_ConfigSeq, hCmdBld);
653    }
654    else
655    {
656        return TI_NOK;
657    }
658}
659
660
661static TI_STATUS __cfg_ps_rx_streaming (TI_HANDLE hCmdBld)
662{
663    TI_UINT32       index;
664    TI_STATUS        eStatus;
665    TPsRxStreaming *pPsRxStreaming;
666
667
668    if (!DB_WLAN(hCmdBld).bJoin)
669    {
670        return TI_NOK;
671    }
672
673    /* Config enabled streams (disable is the FW default). */
674    for (index = 0; index < MAX_NUM_OF_802_1d_TAGS - 1; index++)
675    {
676        pPsRxStreaming = &(DB_PS_STREAM(hCmdBld).tid[index]);
677
678        if (pPsRxStreaming->bEnabled)
679        {
680            eStatus = cmdBld_CfgPsRxStreaming (hCmdBld, pPsRxStreaming, NULL, NULL);
681            if (eStatus != TI_OK)
682            {
683                return eStatus;
684            }
685        }
686    }
687
688    /* Set NOK for a case the following config is skipped, to indicate that no callback is expected */
689    eStatus = TI_NOK;
690
691    pPsRxStreaming = &(DB_PS_STREAM(hCmdBld).tid[MAX_NUM_OF_802_1d_TAGS - 1]);
692    if (pPsRxStreaming->bEnabled)
693    {
694        eStatus = cmdBld_CfgPsRxStreaming (hCmdBld, pPsRxStreaming, (void *)cmdBld_ConfigSeq, hCmdBld);
695        if (eStatus != TI_OK)
696        {
697            return eStatus;
698        }
699    }
700
701    return eStatus;
702    }
703
704
705static TI_STATUS __cfg_rx_data_filter (TI_HANDLE hCmdBld)
706{
707    TI_UINT32       index;
708    TI_STATUS       eStatus;
709    TRxDataFilter   *pFilters;
710
711
712    if (DB_RX_DATA_FLTR(hCmdBld).bEnabled)
713    {
714        eStatus = cmdBld_CfgIeEnableRxDataFilter (hCmdBld,
715                                                  DB_RX_DATA_FLTR(hCmdBld).bEnabled,
716                                                  DB_RX_DATA_FLTR(hCmdBld).eDefaultAction,
717                                                  NULL,
718                                                  NULL);
719        if (eStatus != TI_OK)
720        {
721            return eStatus;
722        }
723    }
724
725    /*
726     * Config enabled filters (last one is separated to use the callback)
727     */
728    for (index = 0; index < MAX_DATA_FILTERS - 1; index++)
729    {
730        pFilters = &(DB_RX_DATA_FLTR(hCmdBld).aRxDataFilter[index]);
731
732        if (pFilters->uCommand == ADD_FILTER)
733        {
734            eStatus = cmdBld_CfgIeRxDataFilter (hCmdBld,
735                                                pFilters->uIndex,
736                                                pFilters->uCommand,
737                                                pFilters->eAction,
738                                                pFilters->uNumFieldPatterns,
739                                                pFilters->uLenFieldPatterns,
740                                                pFilters->aFieldPattern,
741                                                NULL,
742                                                NULL);
743            if (eStatus != TI_OK)
744    {
745                return eStatus;
746            }
747        }
748    }
749
750    /* Set NOK for a case the following config is skipped, to indicate that no callback is expected */
751        eStatus = TI_NOK;
752
753    pFilters = &(DB_RX_DATA_FLTR(hCmdBld).aRxDataFilter[MAX_DATA_FILTERS - 1]);
754    if (pFilters->uCommand == ADD_FILTER)
755    {
756        eStatus = cmdBld_CfgIeRxDataFilter (hCmdBld,
757                                            pFilters->uIndex,
758                                            pFilters->uCommand,
759                                            pFilters->eAction,
760                                            pFilters->uNumFieldPatterns,
761                                            pFilters->uLenFieldPatterns,
762                                            pFilters->aFieldPattern,
763                                            (void *)cmdBld_ConfigSeq,
764                                            hCmdBld);
765        if (eStatus != TI_OK)
766        {
767            return eStatus;
768        }
769    }
770
771    return eStatus;
772}
773
774
775static TI_STATUS __cfg_pd_threshold (TI_HANDLE hCmdBld)
776{
777    return cmdBld_CfgIePacketDetectionThreshold (hCmdBld,
778                                                 DB_WLAN(hCmdBld).PacketDetectionThreshold,
779                                                 (void *)cmdBld_ConfigSeq,
780                                                 hCmdBld);
781}
782
783
784static TI_STATUS __cfg_slot_time (TI_HANDLE hCmdBld)
785{
786    return cmdBld_CfgIeSlotTime (hCmdBld, DB_WLAN(hCmdBld).SlotTime, (void *)cmdBld_ConfigSeq, hCmdBld);
787}
788
789
790static TI_STATUS __cfg_arp_ip_filter (TI_HANDLE hCmdBld)
791{
792    return cmdBld_CfgIeArpIpFilter (hCmdBld,
793                                    DB_WLAN(hCmdBld).arp_IP_addr,
794                                    (TI_BOOL)DB_WLAN(hCmdBld).isArpIpFilteringEnabled,
795                                    (void *)cmdBld_ConfigSeq,
796                                    hCmdBld);
797}
798
799static TI_STATUS __cfg_group_address_table (TI_HANDLE hCmdBld)
800{
801    return cmdBld_CfgIeGroupAdressTable (hCmdBld,
802                                         DB_WLAN(hCmdBld).numGroupAddrs,
803                                         DB_WLAN(hCmdBld).aGroupAddr,
804                                         DB_WLAN(hCmdBld).isMacAddrFilteringnabled,
805                                         (void *)cmdBld_ConfigSeq,
806                                         hCmdBld);
807}
808
809
810static TI_STATUS __cfg_service_period_timeout (TI_HANDLE hCmdBld)
811{
812    return cmdBld_CfgIeServicePeriodTimeout (hCmdBld,
813                                             &DB_WLAN(hCmdBld).rxTimeOut,
814                                             (void *)cmdBld_ConfigSeq,
815                                             hCmdBld);
816}
817
818
819static TI_STATUS __cfg_rts_threshold (TI_HANDLE hCmdBld)
820{
821    return cmdBld_CfgRtsThreshold (hCmdBld,
822                                   DB_WLAN(hCmdBld).RtsThreshold,
823                                   (void *)cmdBld_ConfigSeq,
824                                   hCmdBld);
825}
826
827
828
829static TI_STATUS __cfg_fragment_threshold (TI_HANDLE hCmdBld)
830{
831    return cmdBld_CfgIeFragmentThreshold (hCmdBld,
832                                          DB_WLAN(hCmdBld).FragmentThreshold,
833                                          (void *)cmdBld_ConfigSeq,
834                                          hCmdBld);
835}
836
837
838static TI_STATUS __cfg_pm_config (TI_HANDLE hCmdBld)
839{
840    return cmdBld_CfgIePmConfig (hCmdBld,
841                                 DB_WLAN(hCmdBld).uHostClkSettlingTime,
842                                 DB_WLAN(hCmdBld).uHostFastWakeupSupport,
843                                 (void *)cmdBld_ConfigSeq,
844                                 hCmdBld);
845}
846
847
848static TI_STATUS __cfg_beacon_filter_opt (TI_HANDLE hCmdBld)
849{
850    /* Set The Beacon Filter in HAL */
851    return cmdBld_CfgIeBeaconFilterOpt (hCmdBld,
852                                        DB_WLAN(hCmdBld).beaconFilterParams.desiredState,
853                                        DB_WLAN(hCmdBld).beaconFilterParams.numOfElements,
854                                        (void *)cmdBld_ConfigSeq,
855                                        hCmdBld);
856}
857
858
859static TI_STATUS __cfg_beacon_filter_table (TI_HANDLE hCmdBld)
860{
861    return cmdBld_CfgIeBeaconFilterTable (hCmdBld,
862                                          DB_WLAN(hCmdBld).beaconFilterIETable.numberOfIEs,
863                                          DB_WLAN(hCmdBld).beaconFilterIETable.IETable,
864                                          DB_WLAN(hCmdBld).beaconFilterIETable.IETableSize,
865                                          (void *)cmdBld_ConfigSeq,
866                                          hCmdBld);
867}
868
869
870static TI_STATUS __cfg_tx_cmplt_pacing (TI_HANDLE hCmdBld)
871{
872    return cmdBld_CfgIeTxCmpltPacing (hCmdBld,
873                                      DB_WLAN(hCmdBld).TxCompletePacingThreshold,
874                                      DB_WLAN(hCmdBld).TxCompletePacingTimeout,
875                                      (void *)cmdBld_ConfigSeq,
876                                      hCmdBld);
877}
878
879
880static TI_STATUS __cfg_rx_intr_pacing (TI_HANDLE hCmdBld)
881{
882    return cmdBld_CfgIeRxIntrPacing (hCmdBld,
883                                     DB_WLAN(hCmdBld).RxIntrPacingThreshold,
884                                     DB_WLAN(hCmdBld).RxIntrPacingTimeout,
885                         (void *)cmdBld_ConfigSeq,
886                               hCmdBld);
887}
888
889
890static TI_STATUS __cfg_coex_activity_table (TI_HANDLE hCmdBld)
891{
892    TCmdBld       *pCmdBld = (TCmdBld *)hCmdBld;
893    TI_UINT32 uNumberOfIEs = DB_WLAN(hCmdBld).tWlanParamsCoexActivityTable.numOfElements;
894    TCoexActivity *CoexActivityTable = DB_WLAN(hCmdBld).tWlanParamsCoexActivityTable.entry;
895    TI_STATUS   status = TI_NOK;
896    TI_UINT32   index;
897
898    TRACE1(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , " CoexActivity, uNumberOfIEs=%d\n", uNumberOfIEs);
899    if (uNumberOfIEs == 0)
900    {
901        return status;
902    }
903    /*
904     * config CoexActivity table
905     * first configure all indexes but the last one with no CB, and than configure the last one
906     * with a CB to continue configuration.
907     */
908    for (index = 0; index < uNumberOfIEs-1; index++)
909    {
910        TRACE1(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , " CoexActivity, send %d\n", index);
911        status =  cmdBld_CfgIeCoexActivity (hCmdBld, &CoexActivityTable[index],
912                                                NULL, NULL);
913        if (TI_OK != status)
914        {
915            return status;
916        }
917    }
918
919    /* Send last activity with a callback to continue config sequence */
920    TRACE1(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , " CoexActivity, send last %d\n", index);
921    status =  cmdBld_CfgIeCoexActivity (hCmdBld, &CoexActivityTable[index],
922                                            (void *)cmdBld_ConfigSeq, hCmdBld);
923
924    return status;
925}
926
927static TI_STATUS __cfg_cca_threshold (TI_HANDLE hCmdBld)
928{
929    return cmdBld_CfgIeCcaThreshold (hCmdBld,
930                                     DB_WLAN(hCmdBld).EnergyDetection,
931                                     (void *)cmdBld_ConfigSeq,
932                                     hCmdBld);
933}
934
935
936static TI_STATUS __cfg_bcn_brc_options (TI_HANDLE hCmdBld)
937{
938    TPowerMgmtConfig powerMgmtConfig;
939
940    /* Beacon broadcast options */
941    powerMgmtConfig.BcnBrcOptions = DB_WLAN(hCmdBld).BcnBrcOptions;
942    powerMgmtConfig.ConsecutivePsPollDeliveryFailureThreshold = DB_WLAN(hCmdBld).ConsecutivePsPollDeliveryFailureThreshold;
943
944    return cmdBld_CfgIeBcnBrcOptions (hCmdBld,
945                                      &powerMgmtConfig,
946                                      (void *)cmdBld_ConfigSeq,
947                                      hCmdBld);
948}
949
950
951static TI_STATUS __cmd_enable_rx (TI_HANDLE hCmdBld)
952{
953    /* Enable rx path on the hardware */
954    return cmdBld_CmdEnableRx (hCmdBld, (void *)cmdBld_ConfigSeq, hCmdBld);
955}
956
957
958static TI_STATUS __cmd_enable_tx (TI_HANDLE hCmdBld)
959{
960    /* Enable tx path on the hardware */
961    return cmdBld_CmdEnableTx (hCmdBld,
962                               DB_DEFAULT_CHANNEL(hCmdBld),
963                               (void *)cmdBld_ConfigSeq,
964                               hCmdBld);
965}
966
967
968static TI_STATUS __cfg_ps_wmm (TI_HANDLE hCmdBld)
969{
970    /* ACX for a work around for Wi-Fi test */
971    return cmdBld_CfgIePsWmm (hCmdBld,
972                              DB_WLAN(hCmdBld).WiFiWmmPS,
973                              (void *)cmdBld_ConfigSeq,
974                              hCmdBld);
975}
976
977
978static TI_STATUS __cfg_rssi_snr_weights (TI_HANDLE hCmdBld)
979{
980    /* RSSI/SNR Weights for Average calculations */
981    return cmdBld_CfgIeRssiSnrWeights (hCmdBld,
982                                       &DB_WLAN(hCmdBld).tRssiSnrWeights,
983                                       (void *)cmdBld_ConfigSeq,
984                                       hCmdBld);
985}
986
987
988static TI_STATUS __cfg_event_scan_cmplt (TI_HANDLE hCmdBld)
989{
990    TCmdBld   *pCmdBld = (TCmdBld *)hCmdBld;
991
992    /* Enable the scan complete interrupt source */
993    return eventMbox_UnMaskEvent (pCmdBld->hEventMbox,
994                               TWD_OWN_EVENT_SCAN_CMPLT,
995                               (void *)cmdBld_ConfigSeq,
996                               hCmdBld);
997}
998
999static TI_STATUS __cfg_event_sps_scan_cmplt (TI_HANDLE hCmdBld)
1000{
1001    TCmdBld   *pCmdBld = (TCmdBld *)hCmdBld;
1002
1003    return eventMbox_UnMaskEvent (pCmdBld->hEventMbox,
1004                               TWD_OWN_EVENT_SPS_SCAN_CMPLT,
1005                               (void *)cmdBld_ConfigSeq,
1006                               hCmdBld);
1007}
1008
1009static TI_STATUS __cfg_event_plt_rx_calibration_cmplt (TI_HANDLE hCmdBld)
1010{
1011    TCmdBld   *pCmdBld = (TCmdBld *)hCmdBld;
1012
1013    return eventMbox_UnMaskEvent (pCmdBld->hEventMbox,
1014                               TWD_OWN_EVENT_PLT_RX_CALIBRATION_COMPLETE,
1015                               (void *)cmdBld_ConfigSeq,
1016                               hCmdBld);
1017}
1018
1019
1020static TI_STATUS __cfg_hw_enc_dec_enable (TI_HANDLE hCmdBld)
1021{
1022    return cmdBld_CfgHwEncDecEnable (hCmdBld, TI_TRUE, (void *)cmdBld_ConfigSeq, hCmdBld);
1023}
1024
1025
1026static TI_STATUS __cfg_rssi_snr_trigger_0 (TI_HANDLE hCmdBld)
1027{
1028    /* RSSI/SNR Troggers */
1029    return  cmdBld_CfgIeRssiSnrTrigger (hCmdBld,
1030                                        &DB_WLAN(hCmdBld).tRssiSnrTrigger[0],
1031                                        (void *)cmdBld_ConfigSeq,
1032                                        hCmdBld);
1033}
1034
1035
1036static TI_STATUS __cfg_rssi_snr_trigger_1 (TI_HANDLE hCmdBld)
1037{
1038    /* RSSI/SNR Troggers */
1039    return  cmdBld_CfgIeRssiSnrTrigger (hCmdBld,
1040                                        &DB_WLAN(hCmdBld).tRssiSnrTrigger[1],
1041                                        (void *)cmdBld_ConfigSeq,
1042                                        hCmdBld);
1043}
1044
1045
1046static TI_STATUS __cfg_rssi_snr_trigger_2 (TI_HANDLE hCmdBld)
1047{
1048    /* RSSI/SNR Troggers */
1049    return  cmdBld_CfgIeRssiSnrTrigger (hCmdBld,
1050                                        &DB_WLAN(hCmdBld).tRssiSnrTrigger[2],
1051                                        (void *)cmdBld_ConfigSeq,
1052                                        hCmdBld);
1053}
1054
1055
1056static TI_STATUS __cfg_rssi_snr_trigger_3 (TI_HANDLE hCmdBld)
1057{
1058    /* RSSI/SNR Troggers */
1059    return  cmdBld_CfgIeRssiSnrTrigger (hCmdBld,
1060                                        &DB_WLAN(hCmdBld).tRssiSnrTrigger[3],
1061                                        (void *)cmdBld_ConfigSeq,
1062                                        hCmdBld);
1063}
1064
1065
1066static TI_STATUS __cfg_rssi_snr_trigger_4 (TI_HANDLE hCmdBld)
1067{
1068    /* RSSI/SNR Troggers */
1069    return  cmdBld_CfgIeRssiSnrTrigger (hCmdBld,
1070                                        &DB_WLAN(hCmdBld).tRssiSnrTrigger[4],
1071                                        (void *)cmdBld_ConfigSeq,
1072                                        hCmdBld);
1073}
1074
1075
1076static TI_STATUS __cfg_rssi_snr_trigger_5 (TI_HANDLE hCmdBld)
1077{
1078    /* RSSI/SNR Troggers */
1079    return  cmdBld_CfgIeRssiSnrTrigger (hCmdBld,
1080                                        &DB_WLAN(hCmdBld).tRssiSnrTrigger[5],
1081                                        (void *)cmdBld_ConfigSeq,
1082                                        hCmdBld);
1083}
1084
1085
1086static TI_STATUS __cfg_rssi_snr_trigger_6 (TI_HANDLE hCmdBld)
1087{
1088    /* RSSI/SNR Troggers */
1089    return  cmdBld_CfgIeRssiSnrTrigger (hCmdBld,
1090                                        &DB_WLAN(hCmdBld).tRssiSnrTrigger[6],
1091                                        (void *)cmdBld_ConfigSeq,
1092                                        hCmdBld);
1093}
1094
1095
1096static TI_STATUS __cfg_rssi_snr_trigger_7 (TI_HANDLE hCmdBld)
1097{
1098    /* RSSI/SNR Troggers */
1099    return  cmdBld_CfgIeRssiSnrTrigger (hCmdBld,
1100                                        &DB_WLAN(hCmdBld).tRssiSnrTrigger[7],
1101                                        (void *)cmdBld_ConfigSeq,
1102                                        hCmdBld);
1103}
1104
1105
1106static TI_STATUS __cfg_max_tx_retry (TI_HANDLE hCmdBld)
1107{
1108    return cmdBld_CfgIeMaxTxRetry (hCmdBld,
1109                                   &DB_WLAN(hCmdBld).roamTriggers,
1110                                   (void *)cmdBld_ConfigSeq,
1111                                   hCmdBld);
1112}
1113
1114
1115
1116static TI_STATUS __cfg_split_scan_timeout (TI_HANDLE hCmdBld)
1117{
1118    return cmdBld_CmdIeSetSplitScanTimeOut (hCmdBld,
1119                                            DB_WLAN(hCmdBld).uSlicedScanTimeOut,
1120                                            (void *)cmdBld_ConfigSeq,
1121                                            hCmdBld);
1122}
1123
1124
1125static TI_STATUS __cfg_conn_monit_params (TI_HANDLE hCmdBld)
1126{
1127    return cmdBld_CfgIeConnMonitParams (hCmdBld,
1128                                        &DB_WLAN(hCmdBld).roamTriggers,
1129                                        (void *)cmdBld_ConfigSeq,
1130                                        hCmdBld);
1131}
1132
1133
1134static TI_STATUS __cfg_bet (TI_HANDLE hCmdBld)
1135{
1136    return cmdBld_CfgBet (hCmdBld,
1137                          DB_WLAN(hCmdBld).BetEnable,
1138                          DB_WLAN(hCmdBld).MaximumConsecutiveET,
1139                          (void *)cmdBld_ConfigSeq,
1140                          hCmdBld);
1141}
1142
1143
1144static TI_STATUS __cfg_cts_protection (TI_HANDLE hCmdBld)
1145{
1146    return cmdBld_CfgIeCtsProtection (hCmdBld,
1147                                      DB_WLAN(hCmdBld).CtsToSelf,
1148                                      (void *)cmdBld_ConfigSeq,
1149                                      hCmdBld);
1150}
1151
1152
1153static TI_STATUS __cfg_radio_params (TI_HANDLE hCmdBld)
1154{
1155    return cmdBld_CfgIeRadioParams (hCmdBld,
1156                                    &DB_RADIO(hCmdBld),
1157                                    (void *)cmdBld_ConfigSeq,
1158                                    hCmdBld);
1159}
1160
1161static TI_STATUS __cfg_platform_params (TI_HANDLE hCmdBld)
1162{
1163    return cmdBld_CfgPlatformGenParams(hCmdBld,
1164                                      &DB_GEN(hCmdBld),
1165                                      (void *)cmdBld_ConfigSeq,
1166                                      hCmdBld);
1167}
1168
1169
1170
1171static TI_STATUS __cfg_tx_rate_policy (TI_HANDLE hCmdBld)
1172{
1173    /*
1174     * JOIN (use the local parameters), otherwize the CORE will reconnect
1175     */
1176    if (DB_WLAN(hCmdBld).bJoin)
1177    {
1178        /* Set TxRatePolicy */
1179        return cmdBld_CfgTxRatePolicy (hCmdBld,
1180                                       &DB_BSS(hCmdBld).TxRateClassParams,
1181                                       (void *)cmdBld_ConfigSeq,
1182                                       hCmdBld);
1183    }
1184
1185    return TI_NOK;
1186}
1187
1188
1189static TI_STATUS __cmd_beacon_join (TI_HANDLE hCmdBld)
1190{
1191    if (DB_WLAN(hCmdBld).bJoin && DB_TEMP(hCmdBld).Beacon.Size != 0)
1192    {
1193        return cmdBld_CmdIeConfigureTemplateFrame (hCmdBld,
1194                                                   &(DB_TEMP(hCmdBld).Beacon),
1195                                                 (TI_UINT16)DB_TEMP(hCmdBld).Beacon.Size,
1196                                                   TEMPLATE_BEACON,
1197                                                   0,
1198                                                 (void *)cmdBld_ConfigSeq,
1199                                                 hCmdBld);
1200    }
1201
1202    return TI_NOK;
1203}
1204
1205static TI_STATUS __cmd_probe_resp_join (TI_HANDLE hCmdBld)
1206{
1207    if (DB_WLAN(hCmdBld).bJoin && DB_TEMP(hCmdBld).ProbeResp.Size != 0)
1208    {
1209        return cmdBld_CmdIeConfigureTemplateFrame (hCmdBld,
1210                                                   &(DB_TEMP(hCmdBld).ProbeResp),
1211                                                 (TI_UINT16)DB_TEMP(hCmdBld).ProbeResp.Size,
1212                                                   TEMPLATE_PROBE_RESPONSE,
1213                                                   0,
1214                                                 (void *)cmdBld_ConfigSeq,
1215                                                 hCmdBld);
1216    }
1217
1218    return TI_NOK;
1219}
1220
1221
1222static TI_STATUS __cmd_probe_req_join (TI_HANDLE hCmdBld)
1223{
1224    TI_STATUS   tStatus;
1225
1226    /* set Probe Req template also if join == false ! */
1227    if (DB_TEMP(hCmdBld).ProbeReq24.Size != 0)
1228    {
1229        tStatus =  cmdBld_CmdIeConfigureTemplateFrame (hCmdBld,
1230                                                       &(DB_TEMP(hCmdBld).ProbeReq24),
1231                                                       (TI_UINT16)DB_TEMP(hCmdBld).ProbeReq24.Size,
1232                                                       CFG_TEMPLATE_PROBE_REQ_2_4,
1233                                                       0,
1234                                                       NULL,
1235                                                       NULL);
1236        if (TI_OK != tStatus)
1237        {
1238            return tStatus;
1239        }
1240    }
1241
1242    /* set Probe Req template also if join == false ! */
1243    if (DB_TEMP(hCmdBld).ProbeReq50.Size != 0)
1244    {
1245        return cmdBld_CmdIeConfigureTemplateFrame (hCmdBld,
1246                                                   &(DB_TEMP(hCmdBld).ProbeReq50),
1247                                                   (TI_UINT16)DB_TEMP(hCmdBld).ProbeReq50.Size,
1248                                                   CFG_TEMPLATE_PROBE_REQ_5,
1249                                                   0,
1250                                                 (void *)cmdBld_ConfigSeq,
1251                                                 hCmdBld);
1252    }
1253
1254    return TI_NOK;
1255}
1256
1257
1258static TI_STATUS __cmd_null_data_join (TI_HANDLE hCmdBld)
1259{
1260    if (DB_WLAN(hCmdBld).bJoin && DB_TEMP(hCmdBld).NullData.Size != 0)
1261    {
1262        return cmdBld_CmdIeConfigureTemplateFrame (hCmdBld,
1263                                                   &(DB_TEMP(hCmdBld).NullData),
1264                                                 (TI_UINT16)DB_TEMP(hCmdBld).NullData.Size,
1265                                                   TEMPLATE_NULL_DATA,
1266                                                   0,
1267                                                 (void *)cmdBld_ConfigSeq,
1268                                                 hCmdBld);
1269    }
1270
1271    return TI_NOK;
1272}
1273
1274static TI_STATUS __cmd_disconn_join (TI_HANDLE hCmdBld)
1275{
1276    if (DB_WLAN(hCmdBld).bJoin && DB_TEMP(hCmdBld).Disconn.Size != 0)
1277    {
1278        return cmdBld_CmdIeConfigureTemplateFrame (hCmdBld,
1279                                                   &(DB_TEMP(hCmdBld).Disconn),
1280                                                   (TI_UINT16)DB_TEMP(hCmdBld).Disconn.Size,
1281                                                   TEMPLATE_DISCONNECT,
1282                                                   0,
1283                                                   (void *)cmdBld_ConfigSeq,
1284                                                   hCmdBld);
1285    }
1286
1287    return TI_NOK;
1288}
1289
1290static TI_STATUS __cmd_ps_poll_join (TI_HANDLE hCmdBld)
1291{
1292    if (DB_WLAN(hCmdBld).bJoin && DB_TEMP(hCmdBld).PsPoll.Size != 0)
1293    {
1294        return cmdBld_CmdIeConfigureTemplateFrame (hCmdBld,
1295                                                   &(DB_TEMP(hCmdBld).PsPoll),
1296                                                 (TI_UINT16)DB_TEMP(hCmdBld).PsPoll.Size,
1297                                                   TEMPLATE_PS_POLL,
1298                                                   0,
1299                                                 (void *)cmdBld_ConfigSeq,
1300                                                 hCmdBld);
1301    }
1302
1303    return TI_NOK;
1304}
1305
1306
1307static TI_STATUS __cmd_keep_alive_tmpl_join (TI_HANDLE hCmdBld)
1308{
1309    TI_UINT32   index;
1310    TI_STATUS   status = TI_NOK;
1311
1312    /*
1313     * config templates
1314     * first configure all indexes but the last one with no CB, and than configure the last one
1315     * with a CB to continue configuration.
1316     */
1317    for (index = 0; index < KLV_MAX_TMPL_NUM - 1; index++)
1318    {
1319        if (DB_WLAN(hCmdBld).bJoin && DB_TEMP(hCmdBld).KeepAlive[ index ].Size != 0)
1320        {
1321            status =  cmdBld_CmdIeConfigureTemplateFrame (hCmdBld,
1322                                                          &(DB_TEMP(hCmdBld).KeepAlive[index]),
1323                                                          (TI_UINT16)DB_TEMP(hCmdBld).KeepAlive[index].Size,
1324                                                          TEMPLATE_KLV,
1325                                                          index,
1326                                                          NULL,
1327                                                          NULL);
1328            if (TI_OK != status)
1329            {
1330                return status;
1331            }
1332        }
1333    }
1334
1335    if (DB_WLAN(hCmdBld).bJoin && DB_TEMP(hCmdBld).KeepAlive[ index ].Size != 0)
1336    {
1337        status =  cmdBld_CmdIeConfigureTemplateFrame (hCmdBld,
1338                                                      &(DB_TEMP(hCmdBld).KeepAlive[index]),
1339                                                      (TI_UINT16)DB_TEMP(hCmdBld).KeepAlive[index].Size,
1340                                                      TEMPLATE_KLV,
1341                                                      index,
1342                                                      (void *)cmdBld_ConfigSeq,
1343                                                      hCmdBld);
1344        if (TI_OK != status)
1345        {
1346            return status;
1347        }
1348    }
1349
1350    return status;
1351}
1352
1353
1354static TI_STATUS __cmd_keep_alive_params(TI_HANDLE hCmdBld)
1355{
1356    TI_UINT32   index;
1357    TI_STATUS   status;
1358
1359    /* config gloabl enable / disable flag */
1360    cmdBld_CfgKeepAliveEnaDis (hCmdBld, DB_KLV(hCmdBld).enaDisFlag, NULL, NULL);
1361
1362    /*
1363     * config per-template params
1364     * fisr configure all indexes but the last one with no CB, and than configure the last one
1365     * with a CB to continue configuration.
1366     */
1367    for (index = 0; index < KLV_MAX_TMPL_NUM - 1; index++)
1368    {
1369        if (DB_WLAN(hCmdBld).bJoin && DB_KLV(hCmdBld).keepAliveParams[ index ].enaDisFlag != 0)
1370        {
1371            status =  cmdBld_CmdIeConfigureKeepAliveParams (hCmdBld,
1372                                                            index,
1373                                                            DB_KLV(hCmdBld).keepAliveParams[ index ].enaDisFlag,
1374                                                            DB_KLV(hCmdBld).keepAliveParams[ index ].trigType,
1375                                                            DB_KLV(hCmdBld).keepAliveParams[ index ].interval,
1376                                                            NULL,
1377                                                            NULL);
1378            if (TI_OK != status)
1379            {
1380                return status;
1381            }
1382        }
1383    }
1384
1385    /* Set NOK for a case the following config is skipped, to indicate that no callback is expected */
1386    status = TI_NOK;
1387
1388    if (DB_WLAN(hCmdBld).bJoin && DB_KLV(hCmdBld).keepAliveParams[ index ].enaDisFlag != 0)
1389    {
1390        status =  cmdBld_CmdIeConfigureKeepAliveParams (hCmdBld,
1391                                                        index,
1392                                                        DB_KLV(hCmdBld).keepAliveParams[ index ].enaDisFlag,
1393                                                        DB_KLV(hCmdBld).keepAliveParams[ index ].trigType,
1394                                                        DB_KLV(hCmdBld).keepAliveParams[ index ].interval,
1395                                                        (void *)cmdBld_ConfigSeq,
1396                                                        hCmdBld);
1397        if (TI_OK != status)
1398        {
1399            return status;
1400        }
1401    }
1402
1403    return status;
1404}
1405
1406static TI_STATUS __cmd_power_auth (TI_HANDLE hCmdBld)
1407{
1408    return cmdBld_CfgIeSleepAuth (hCmdBld,
1409                              DB_WLAN(hCmdBld).minPowerLevel,
1410                              (void *)cmdBld_ConfigSeq,
1411                              hCmdBld);
1412}
1413
1414static TI_STATUS __cmd_start_join (TI_HANDLE hCmdBld)
1415{
1416    TCmdBld *pCmdBld = (TCmdBld *)hCmdBld;
1417
1418    if (DB_WLAN(hCmdBld).bJoin)
1419    {
1420        /*
1421         * Replace the Join-Complete event CB by a local function.
1422         * Thus, the reconfig sequence will not continue until the Join is completed!
1423         * The original CB is restored after Join-Complete.
1424         */
1425        eventMbox_ReplaceEvent (pCmdBld->hEventMbox,
1426                                  TWD_OWN_EVENT_JOIN_CMPLT,
1427                                  (void *)cmdBld_JoinCmpltForReconfigCb,
1428                                  hCmdBld,
1429                                  &pCmdBld->fJoinCmpltOriginalCbFunc,
1430                                  &pCmdBld->hJoinCmpltOriginalCbHndl);
1431        /*
1432         * Call the hardware to start/join the bss
1433         */
1434        return cmdBld_CmdStartJoin (hCmdBld,
1435                                    DB_BSS(hCmdBld).ReqBssType,
1436                                    (void *)cmdBld_DummyCb,
1437                                    hCmdBld);
1438    }
1439
1440    return TI_NOK;
1441}
1442
1443static TI_STATUS __cmd_sta_state (TI_HANDLE hCmdBld)
1444{
1445    if (DB_WLAN(hCmdBld).bStaConnected)
1446    {
1447        return cmdBld_CmdSetStaState (hCmdBld,
1448                                    STA_STATE_CONNECTED,
1449                                    (void *)cmdBld_ConfigSeq,
1450                                    hCmdBld);
1451    }
1452
1453    return TI_NOK;
1454}
1455
1456static TI_STATUS __cfg_aid (TI_HANDLE hCmdBld)
1457{
1458    if (DB_WLAN(hCmdBld).bJoin)
1459    {
1460        return cmdBld_CfgAid (hCmdBld, DB_WLAN(hCmdBld).Aid, (void *)cmdBld_ConfigSeq, hCmdBld);
1461    }
1462
1463    return TI_NOK;
1464}
1465
1466
1467static TI_STATUS __cfg_slot_time_join (TI_HANDLE hCmdBld)
1468{
1469    if (DB_WLAN(hCmdBld).bJoin)
1470    {
1471        /* Slot time must be setting after doing join */
1472        return cmdBld_CfgSlotTime (hCmdBld, (ESlotTime)(DB_WLAN(hCmdBld).SlotTime), (void *)cmdBld_ConfigSeq, hCmdBld);
1473    }
1474
1475    return TI_NOK;
1476}
1477
1478
1479static TI_STATUS __cfg_preamble_join (TI_HANDLE hCmdBld)
1480{
1481    if (DB_WLAN(hCmdBld).bJoin)
1482    {
1483        /* Preamble type must be set after doing join */
1484        return cmdBld_CfgPreamble (hCmdBld, DB_WLAN(hCmdBld).preamble, (void *)cmdBld_ConfigSeq, hCmdBld);
1485    }
1486
1487    return TI_NOK;
1488}
1489
1490
1491static TI_STATUS __cfg_ht_capabilities (TI_HANDLE hCmdBld)
1492{
1493    if (DB_WLAN(hCmdBld).bJoin && DB_BSS(hCmdBld).bHtCap)
1494    {
1495        /* HT capabilities must be set after doing join */
1496        return cmdBld_CfgIeSetFwHtCapabilities (hCmdBld,
1497                                                DB_BSS(hCmdBld).uHtCapabilites,
1498                                                DB_BSS(hCmdBld).tMacAddress,
1499                                                DB_BSS(hCmdBld).uAmpduMaxLeng,
1500                                                DB_BSS(hCmdBld).uAmpduMinSpac,
1501                                                (void *)cmdBld_ConfigSeq,
1502                                                hCmdBld);
1503    }
1504
1505    return TI_NOK;
1506}
1507
1508
1509static TI_STATUS __cfg_ht_information (TI_HANDLE hCmdBld)
1510{
1511    if (DB_WLAN(hCmdBld).bJoin && DB_BSS(hCmdBld).bHtInf)
1512    {
1513        /* HT Information must be set after doing join */
1514        return cmdBld_CfgIeSetFwHtInformation (hCmdBld,
1515                                               DB_BSS(hCmdBld).uRifsMode,
1516                                               DB_BSS(hCmdBld).uHtProtection,
1517                                               DB_BSS(hCmdBld).uGfProtection,
1518                                               DB_BSS(hCmdBld).uHtTxBurstLimit,
1519                                               DB_BSS(hCmdBld).uDualCtsProtection,
1520                                               (void *)cmdBld_ConfigSeq,
1521                                               hCmdBld);
1522    }
1523
1524    return TI_NOK;
1525}
1526
1527
1528static TI_STATUS __cfg_ba_set_session (TI_HANDLE hCmdBld)
1529{
1530	TI_STATUS tRes = TI_NOK;
1531
1532    if (DB_WLAN(hCmdBld).bJoin)
1533    {
1534        TI_UINT32 uTid;
1535		TI_UINT32 uLastTid = MAX_NUM_OF_802_1d_TAGS; /* initial value is "not found" */
1536
1537		/* Look through configured BA sessions in data base to find the last set TID */
1538        for (uTid = 0; uTid < MAX_NUM_OF_802_1d_TAGS; uTid++)
1539        {
1540            /* Is BA initiator or responder configured? */
1541            if (DB_BSS(hCmdBld).bBaInitiator[uTid] || DB_BSS(hCmdBld).bBaResponder[uTid])
1542            {
1543				uLastTid = uTid;
1544            }
1545		}
1546
1547		if (uLastTid != MAX_NUM_OF_802_1d_TAGS)
1548		{
1549			/* At least one TID is set */
1550			for (uTid = 0; uTid < uLastTid; ++uTid)
1551			{
1552				if (DB_BSS(hCmdBld).bBaInitiator[uTid])
1553				{
1554					/* set BA Initiator */
1555					tRes = cmdBld_CfgIeSetBaSession (hCmdBld,
1556													 ACX_BA_SESSION_INITIATOR_POLICY,
1557													 uTid,
1558													 DB_BSS(hCmdBld).tBaSessionInitiatorPolicy[uTid].uPolicy,
1559													 DB_BSS(hCmdBld).tBaSessionInitiatorPolicy[uTid].aMacAddress,
1560													 DB_BSS(hCmdBld).tBaSessionInitiatorPolicy[uTid].uWinSize,
1561													 DB_BSS(hCmdBld).tBaSessionInitiatorPolicy[uTid].uInactivityTimeout,
1562													 NULL,
1563													 NULL);
1564					if (tRes != TI_OK)
1565					{
1566						return tRes;
1567					}
1568				}
1569
1570				if (DB_BSS(hCmdBld).bBaResponder[uTid])
1571				{
1572					/* set BA Responder */
1573					tRes = cmdBld_CfgIeSetBaSession (hCmdBld,
1574													 ACX_BA_SESSION_RESPONDER_POLICY,
1575													 uTid,
1576													 DB_BSS(hCmdBld).tBaSessionResponderPolicy[uTid].uPolicy,
1577													 DB_BSS(hCmdBld).tBaSessionResponderPolicy[uTid].aMacAddress,
1578													 DB_BSS(hCmdBld).tBaSessionResponderPolicy[uTid].uWinSize,
1579													 DB_BSS(hCmdBld).tBaSessionResponderPolicy[uTid].uInactivityTimeout,
1580													 NULL,
1581													 NULL);
1582					if (tRes != TI_OK)
1583					{
1584						return tRes;
1585					}
1586				}
1587			}
1588
1589			/* Push the last command of the last TID entry into queue with a call back function */
1590			if (DB_BSS(hCmdBld).bBaInitiator[uLastTid] && !(DB_BSS(hCmdBld).bBaResponder[uLastTid]))
1591			{
1592
1593				tRes = cmdBld_CfgIeSetBaSession (hCmdBld,
1594												 ACX_BA_SESSION_INITIATOR_POLICY,
1595												 uLastTid,
1596												 DB_BSS(hCmdBld).tBaSessionInitiatorPolicy[uLastTid].uPolicy,
1597												 DB_BSS(hCmdBld).tBaSessionInitiatorPolicy[uLastTid].aMacAddress,
1598												 DB_BSS(hCmdBld).tBaSessionInitiatorPolicy[uLastTid].uWinSize,
1599												 DB_BSS(hCmdBld).tBaSessionInitiatorPolicy[uLastTid].uInactivityTimeout,
1600												 (void *)cmdBld_ConfigSeq,
1601												 hCmdBld);
1602			}
1603			else if (!(DB_BSS(hCmdBld).bBaInitiator[uLastTid]) && DB_BSS(hCmdBld).bBaResponder[uLastTid])
1604			{
1605				tRes = cmdBld_CfgIeSetBaSession (hCmdBld,
1606												 ACX_BA_SESSION_RESPONDER_POLICY,
1607												 uLastTid,
1608												 DB_BSS(hCmdBld).tBaSessionResponderPolicy[uLastTid].uPolicy,
1609												 DB_BSS(hCmdBld).tBaSessionResponderPolicy[uLastTid].aMacAddress,
1610												 DB_BSS(hCmdBld).tBaSessionResponderPolicy[uLastTid].uWinSize,
1611												 DB_BSS(hCmdBld).tBaSessionResponderPolicy[uLastTid].uInactivityTimeout,
1612												 (void *)cmdBld_ConfigSeq,
1613												 hCmdBld);
1614			}
1615			else
1616			{
1617				/* Initiator & Responsder policy is to be set */
1618				tRes = cmdBld_CfgIeSetBaSession (hCmdBld,
1619												 ACX_BA_SESSION_INITIATOR_POLICY,
1620												 uLastTid,
1621												 DB_BSS(hCmdBld).tBaSessionInitiatorPolicy[uLastTid].uPolicy,
1622												 DB_BSS(hCmdBld).tBaSessionInitiatorPolicy[uLastTid].aMacAddress,
1623												 DB_BSS(hCmdBld).tBaSessionInitiatorPolicy[uLastTid].uWinSize,
1624												 DB_BSS(hCmdBld).tBaSessionInitiatorPolicy[uLastTid].uInactivityTimeout,
1625												 NULL,
1626												 NULL);
1627				if (tRes != TI_OK)
1628				{
1629					return tRes;
1630				}
1631
1632				tRes = cmdBld_CfgIeSetBaSession (hCmdBld,
1633												 ACX_BA_SESSION_RESPONDER_POLICY,
1634												 uLastTid,
1635												 DB_BSS(hCmdBld).tBaSessionResponderPolicy[uLastTid].uPolicy,
1636												 DB_BSS(hCmdBld).tBaSessionResponderPolicy[uLastTid].aMacAddress,
1637												 DB_BSS(hCmdBld).tBaSessionResponderPolicy[uLastTid].uWinSize,
1638												 DB_BSS(hCmdBld).tBaSessionResponderPolicy[uLastTid].uInactivityTimeout,
1639												 (void *)cmdBld_ConfigSeq,
1640												 hCmdBld);
1641			}
1642		}
1643	}
1644
1645	return tRes;
1646}
1647
1648
1649static TI_STATUS __cfg_tx_power_join (TI_HANDLE hCmdBld)
1650{
1651    if (DB_WLAN(hCmdBld).bJoin)
1652    {
1653        /* Tx-power must be set after doing join */
1654        return cmdBld_CfgTxPowerDbm (hCmdBld, DB_WLAN(hCmdBld).TxPowerDbm, (void *)cmdBld_ConfigSeq, hCmdBld);
1655    }
1656
1657    return TI_NOK;
1658}
1659
1660
1661static TI_STATUS __cfg_keys (TI_HANDLE hCmdBld)
1662{
1663    TCmdBld   *pCmdBld = (TCmdBld *)hCmdBld;
1664    TI_UINT32  index;
1665
1666    if (!DB_WLAN(hCmdBld).bJoin)
1667    {
1668        return TI_NOK;
1669    }
1670
1671    if (pCmdBld->tSecurity.eSecurityMode != TWD_CIPHER_NONE)
1672    {
1673        /*
1674         * We are doing recovery during security so increase security-sequence-number by 255 just to ensure
1675         *   the AP will see progress from last Tx before the recovery (actually needed only for TKIP and AES).
1676         * Decrementing the low byte by one is handled like it wrpped around, i.e. increment total number by 255.
1677         */
1678        cmdBld_SetSecuritySeqNum (hCmdBld, (TI_UINT8)(pCmdBld->uSecuritySeqNumLow - 1));
1679
1680
1681        /* set the keys to the HW*/
1682        for (index = 0;
1683             index < pCmdBld->tSecurity.uNumOfStations * NO_OF_RECONF_SECUR_KEYS_PER_STATION + NO_OF_EXTRA_RECONF_SECUR_KEYS;
1684             index++)
1685        {
1686            if ((DB_KEYS(pCmdBld).pReconfKeys + index)->keyType != KEY_NULL)
1687            {
1688                if (cmdBld_CmdAddKey (hCmdBld, DB_KEYS(pCmdBld).pReconfKeys + index, TI_TRUE, NULL, NULL) != TI_OK)
1689                {
1690                    TRACE1(pCmdBld->hReport, REPORT_SEVERITY_ERROR, "__cfg_keys: ERROR cmdBld_CmdAddKey failure index=%d\n", index);
1691                    return TI_NOK;
1692                }
1693            }
1694        }
1695
1696        if (DB_KEYS(pCmdBld).bDefaultKeyIdValid)
1697        {
1698            /* Set the deafult key ID to the HW*/
1699            if (cmdBld_CmdSetWepDefaultKeyId (hCmdBld, DB_KEYS(pCmdBld).uReconfDefaultKeyId, NULL, NULL) != TI_OK)
1700            {
1701                TRACE0(pCmdBld->hReport, REPORT_SEVERITY_ERROR, "__cfg_keys: ERROR cmdBld_CmdSetWepDefaultKeyId failure\n");
1702                return TI_NOK;
1703            }
1704        }
1705    }
1706
1707    /* Set the encryption/decryption control on the HW */
1708    if (cmdBld_CfgHwEncDecEnable (hCmdBld,
1709                                  DB_KEYS(pCmdBld).bReconfHwEncEnable,
1710                                  (void *)cmdBld_ConfigSeq,
1711                                  hCmdBld) != TI_OK)
1712    {
1713        TRACE0(pCmdBld->hReport, REPORT_SEVERITY_ERROR, "__cfg_keys: ERROR cmdBld_CfgHwEncDecEnable failure \n");
1714        return TI_NOK;
1715    }
1716
1717    return TI_OK;
1718}
1719
1720static TI_STATUS __cfg_sg_enable (TI_HANDLE hCmdBld)
1721{
1722    /* Set the Soft Gemini state */
1723    return cmdBld_CfgSgEnable (hCmdBld,
1724                               DB_WLAN(hCmdBld).SoftGeminiEnable,
1725                               (void *)cmdBld_ConfigSeq,
1726                               hCmdBld);
1727}
1728
1729
1730static TI_STATUS __cfg_sg (TI_HANDLE hCmdBld)
1731{
1732    /* Set the Soft Gemini params */
1733
1734	/* signals the FW to config all the paramters from the DB*/
1735	DB_WLAN(hCmdBld).SoftGeminiParams.paramIdx = 0xFF;
1736
1737    return cmdBld_CfgSg (hCmdBld,
1738                         &DB_WLAN(hCmdBld).SoftGeminiParams,
1739                         (void *)cmdBld_ConfigSeq,
1740                         hCmdBld);
1741}
1742
1743
1744static TI_STATUS __cfg_fm_coex (TI_HANDLE hCmdBld)
1745{
1746    /* Set the FM Coexistence params */
1747    return cmdBld_CfgIeFmCoex (hCmdBld,
1748                               &DB_WLAN(hCmdBld).tFmCoexParams,
1749                               (void *)cmdBld_ConfigSeq,
1750                               hCmdBld);
1751}
1752
1753
1754static TI_STATUS __cfg_rate_management (TI_HANDLE hCmdBld)
1755{
1756	DB_RM(hCmdBld).rateMngParams.paramIndex = 0xFF;
1757
1758	return cmdBld_CfgIeRateMngDbg(hCmdBld,
1759						   &DB_RM(hCmdBld).rateMngParams,
1760						   (void *)cmdBld_ConfigSeq,
1761						   hCmdBld);
1762
1763}
1764
1765
1766TI_STATUS __itr_memory_map (TI_HANDLE hCmdBld)
1767{
1768    TCmdBld   *pCmdBld = (TCmdBld *)hCmdBld;
1769
1770    WLAN_OS_REPORT(("Interrogate TX/RX parameters\n"));
1771
1772    /* Interrogate TX/RX parameters */
1773    return cmdBld_ItrIeMemoryMap (hCmdBld,
1774                                  &pCmdBld->tMemMap,
1775                                  (void *)cmdBld_ConfigFwCb,
1776                                  hCmdBld);
1777}
1778
1779
1780static const TCmdCfgFunc aCmdIniSeq [] =
1781{
1782    __cfg_platform_params,
1783    __cfg_radio_params,
1784    __cmd_probe_req,
1785    __cmd_null_data,
1786    __cmd_disconn,
1787    __cmd_ps_poll,
1788    __cmd_qos_null_data,
1789    __cmd_probe_resp,
1790    __cmd_beacon,
1791    __cmd_keep_alive_tmpl,
1792    __cfg_mem,
1793    __cfg_rx_msdu_life_time,
1794    __cfg_rx,
1795    __cfg_ac_params_0,
1796    __cfg_tid_0,
1797    __cfg_ac_params_1,
1798    __cfg_tid_1,
1799    __cfg_ac_params_2,
1800    __cfg_tid_2,
1801    __cfg_ac_params_3,
1802    __cfg_tid_3,
1803    __cfg_pd_threshold,
1804    __cfg_slot_time,
1805    __cfg_arp_ip_filter,
1806    __cfg_group_address_table,
1807    __cfg_service_period_timeout,
1808    __cfg_rts_threshold,
1809    __cfg_fragment_threshold,
1810    __cfg_pm_config,
1811    __cfg_beacon_filter_opt,
1812    __cfg_beacon_filter_table,
1813    __cfg_tx_cmplt_pacing,
1814    __cfg_rx_intr_pacing,
1815    __cfg_sg,
1816    __cfg_sg_enable,
1817    __cfg_coex_activity_table,
1818    __cfg_fm_coex,
1819    __cfg_cca_threshold,
1820    __cfg_bcn_brc_options,
1821    __cmd_enable_rx,
1822    __cmd_enable_tx,
1823    __cfg_ps_wmm,
1824    __cfg_event_scan_cmplt,
1825    __cfg_event_sps_scan_cmplt,
1826    __cfg_event_plt_rx_calibration_cmplt,
1827    __cfg_hw_enc_dec_enable,
1828    __cfg_rssi_snr_weights,
1829    __cfg_rssi_snr_trigger_0,
1830    __cfg_rssi_snr_trigger_1,
1831    __cfg_rssi_snr_trigger_2,
1832    __cfg_rssi_snr_trigger_3,
1833    __cfg_rssi_snr_trigger_4,
1834    __cfg_rssi_snr_trigger_5,
1835    __cfg_rssi_snr_trigger_6,
1836    __cfg_rssi_snr_trigger_7,
1837    __cfg_max_tx_retry,
1838    __cfg_split_scan_timeout,
1839
1840    /* Re-join sequence */
1841    __cfg_tx_rate_policy,
1842    __cmd_beacon_join,
1843    __cmd_probe_resp_join,
1844    __cmd_probe_req_join,
1845    __cmd_null_data_join,
1846    __cmd_disconn_join,
1847    __cmd_ps_poll_join,
1848    __cmd_keep_alive_tmpl_join,
1849    __cfg_slot_time_join,
1850    __cfg_preamble_join,
1851    __cfg_ht_capabilities,
1852    __cfg_ht_information,
1853    __cmd_start_join,
1854    __cfg_aid,
1855    __cfg_ba_set_session,
1856    __cfg_tx_power_join,
1857    __cfg_keys,
1858    __cmd_keep_alive_params,
1859    __cfg_conn_monit_params,
1860    __cfg_bet,
1861    __cfg_cts_protection,
1862    __cfg_ps_rx_streaming,
1863    __cfg_rx_data_filter,
1864    __cmd_sta_state,
1865    __cmd_power_auth,
1866	__cmd_burst_mode_enable,
1867    __cmd_smart_reflex_state,
1868    __cmd_smart_reflex_params,
1869    __cmd_smart_reflex_debug,
1870	__cfg_rate_management,
1871    /* Interrogate command -> must be last!! */
1872    __itr_memory_map,
1873
1874    NULL
1875};
1876
1877
1878/****************************************************************************
1879 *                      cmdBld_ConfigSeq()
1880 ****************************************************************************
1881 * DESCRIPTION: Configuration sequence engine
1882 *
1883 * INPUTS: None
1884 *
1885 * OUTPUT: None
1886 *
1887 * RETURNS: TI_OK or TI_NOK
1888 ****************************************************************************/
1889TI_STATUS cmdBld_ConfigSeq (TI_HANDLE hCmdBld)
1890{
1891    TCmdBld   *pCmdBld = (TCmdBld *)hCmdBld;
1892
1893    do
1894    {
1895        if (aCmdIniSeq [pCmdBld->uIniSeq++] == NULL)
1896        {
1897            return TI_NOK;
1898        }
1899    }
1900    while ((*aCmdIniSeq [pCmdBld->uIniSeq - 1])(hCmdBld) != TI_OK);
1901
1902    return TI_OK;
1903}
1904
1905/****************************************************************************
1906 *                      cmdBld_FinalizeDownload()
1907 ****************************************************************************
1908 * DESCRIPTION: Finalize all the remaining initialization after the download has finished
1909 *
1910 * INPUTS:
1911 *
1912 * OUTPUT:  None
1913 *
1914 * RETURNS: void
1915 ****************************************************************************/
1916void cmdBld_FinalizeDownload (TI_HANDLE hCmdBld, TBootAttr *pBootAttr, FwStaticData_t *pFwInfo)
1917{
1918    TCmdBld *pCmdBld = (TCmdBld *)hCmdBld;
1919    TI_UINT8    *pMacAddr = pFwInfo->dot11StationID;
1920    TI_UINT32    i;
1921    TI_UINT8     uTmp;
1922
1923    /* Save FW version */
1924    os_memoryCopy (pCmdBld->hOs,
1925                   (void *)DB_HW(hCmdBld).fwVer,
1926                   (void *)pFwInfo->FWVersion,
1927                   sizeof(DB_HW(hCmdBld).fwVer));
1928
1929    /* Save MAC adress (correct the bytes order first) */
1930    for (i = 0; i < 3; i++)
1931    {
1932        uTmp = pMacAddr[i];
1933        pMacAddr[i] = pMacAddr[5 - i];
1934        pMacAddr[5 - i] = uTmp;
1935    }
1936    MAC_COPY (DB_HW(hCmdBld).macAddress, pMacAddr);
1937
1938    /* Save chip ID */
1939    os_memoryCopy (pCmdBld->hOs,
1940                   (void *)&(DB_HW(hCmdBld).uHardWareVersion),
1941                   (void *)&(pFwInfo->HardWareVersion),
1942                   sizeof(DB_HW(hCmdBld).uHardWareVersion));
1943
1944    /* Save power-levels table */
1945    os_memoryCopy (pCmdBld->hOs,
1946                   (void *)DB_HW(hCmdBld).txPowerTable,
1947                   (void *)pFwInfo->txPowerTable,
1948                   sizeof(DB_HW(hCmdBld).txPowerTable));
1949
1950    /* Call the upper layer callback */
1951    (*((TFinalizeCb)pCmdBld->fFinalizeDownload)) (pCmdBld->hFinalizeDownload);
1952}
1953
1954
1955TI_STATUS cmdBld_GetParam (TI_HANDLE hCmdBld, TTwdParamInfo *pParamInfo)
1956{
1957    TCmdBld       *pCmdBld = (TCmdBld *)hCmdBld;
1958    TWlanParams   *pWlanParams = &DB_WLAN(hCmdBld);
1959
1960    switch (pParamInfo->paramType)
1961    {
1962        case TWD_RTS_THRESHOLD_PARAM_ID:
1963            pParamInfo->content.halCtrlRtsThreshold = pWlanParams->RtsThreshold;
1964            break;
1965
1966        case TWD_FRAG_THRESHOLD_PARAM_ID:
1967            pParamInfo->content.halCtrlFragThreshold = pWlanParams->FragmentThreshold;
1968            break;
1969
1970        case TWD_COUNTERS_PARAM_ID:
1971            /* Constant zero because the ACX last buffer next pointer is always pointed
1972               to itself, so it's like an endless buffer*/
1973            pParamInfo->content.halCtrlCounters.RecvNoBuffer = 0;
1974            pParamInfo->content.halCtrlCounters.FragmentsRecv = 0; /* not supported;*/
1975            pParamInfo->content.halCtrlCounters.FrameDuplicates = 0;/* not supported*/
1976            pParamInfo->content.halCtrlCounters.FcsErrors = DB_CNT(hCmdBld).FcsErrCnt;
1977            pParamInfo->content.halCtrlCounters.RecvError = DB_CNT(hCmdBld).FcsErrCnt;
1978            break;
1979
1980        case TWD_LISTEN_INTERVAL_PARAM_ID:
1981            pParamInfo->content.halCtrlListenInterval = pWlanParams->ListenInterval;
1982            break;
1983
1984        case TWD_RSN_DEFAULT_KEY_ID_PARAM_ID:
1985            /* Not implemented */
1986            return TI_NOK;
1987
1988        case TWD_RSN_SECURITY_MODE_PARAM_ID:
1989             pParamInfo->content.rsnEncryptionStatus = pCmdBld->tSecurity.eSecurityMode;
1990            break;
1991
1992      case TWD_ACX_STATISTICS_PARAM_ID:
1993            /* Not implemented */
1994         #if 0
1995            {
1996                acxStatisitcs_t     acxStatisitics;
1997                pParamInfo->content.acxStatisitics.FWpacketReceived = acxStatisitics.FWpacketReceived;
1998                /* Not supported */
1999                pParamInfo->content.acxStatisitics.HALpacketReceived = 0;
2000            }
2001         #endif
2002            return TI_NOK;
2003
2004    case TWD_MEDIUM_OCCUPANCY_PARAM_ID:
2005        if (cmdBld_ItrIeMediumOccupancy (hCmdBld, pParamInfo->content.interogateCmdCBParams) != TI_OK)
2006            return TI_NOK;
2007            break;
2008
2009    case TWD_TSF_DTIM_MIB_PARAM_ID:
2010        if (cmdBld_ItrIeTfsDtim (hCmdBld, pParamInfo->content.interogateCmdCBParams) != TI_OK)
2011            return TI_NOK;
2012        break;
2013
2014    case TWD_AID_PARAM_ID:
2015        if (cmdBld_GetCurrentAssociationId (hCmdBld, &pParamInfo->content.halCtrlAid) != TI_OK)
2016            return TI_NOK;
2017
2018        TRACE1(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , " AID 2 %d\n", pParamInfo->content.halCtrlAid);
2019        break;
2020
2021    case TWD_NOISE_HISTOGRAM_PARAM_ID:
2022        if (cmdBld_ItrIeNoiseHistogramResults (hCmdBld, pParamInfo->content.interogateCmdCBParams) != TI_OK)
2023        {
2024            return TI_NOK;
2025        }
2026        break;
2027
2028    case TWD_CURRENT_CHANNEL_PARAM_ID:
2029        /* Get current channel number */
2030        pParamInfo->content.halCtrlCurrentChannel = DB_BSS(hCmdBld).RadioChannel;
2031        break;
2032
2033    /* SNR and RSSI belongs to the same MIB, and the relevant CB is passed here*/
2034    case TWD_RSSI_LEVEL_PARAM_ID:
2035    case TWD_SNR_RATIO_PARAM_ID:
2036        /* Retrive the Callback function and read buffer pointer that are in fact stored in the TIWLAN_ADAPTER and then send it to the Command Mailbox */
2037        cmdBld_ItrRSSI (hCmdBld,
2038                        pParamInfo->content.interogateCmdCBParams.fCb,
2039                        pParamInfo->content.interogateCmdCBParams.hCb,
2040                        pParamInfo->content.interogateCmdCBParams.pCb);
2041        break;
2042
2043    case TWD_BCN_BRC_OPTIONS_PARAM_ID:
2044        pParamInfo->content.BcnBrcOptions.BeaconRxTimeout    = pWlanParams->BcnBrcOptions.BeaconRxTimeout;
2045        pParamInfo->content.BcnBrcOptions.BroadcastRxTimeout = pWlanParams->BcnBrcOptions.BroadcastRxTimeout;
2046        pParamInfo->content.BcnBrcOptions.RxBroadcastInPs    = pWlanParams->BcnBrcOptions.RxBroadcastInPs;
2047        break;
2048
2049    case TWD_MAX_RX_MSDU_LIFE_TIME_PARAM_ID:
2050        pParamInfo->content.halCtrlMaxRxMsduLifetime = pWlanParams->MaxRxMsduLifetime;
2051        break;
2052
2053    case TWD_TX_RATE_CLASS_PARAM_ID:
2054        pParamInfo->content.pTxRatePlicy = &DB_BSS(hCmdBld).TxRateClassParams;
2055        break;
2056
2057    case TWD_SG_CONFIG_PARAM_ID:
2058        return cmdBld_ItrSg (hCmdBld,
2059                             pParamInfo->content.interogateCmdCBParams.fCb,
2060                             pParamInfo->content.interogateCmdCBParams.hCb,
2061                             (void*)pParamInfo->content.interogateCmdCBParams.pCb);
2062
2063    case TWD_TX_POWER_PARAM_ID:
2064        pParamInfo->content.halCtrlTxPowerDbm = DB_WLAN(hCmdBld).TxPowerDbm;
2065        break;
2066
2067	case TWD_RADIO_TEST_PARAM_ID:
2068        TRACE0(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "Radio Test\n");
2069		return cmdBld_CmdTest (hCmdBld,
2070							   pParamInfo->content.interogateCmdCBParams.fCb,
2071							   pParamInfo->content.interogateCmdCBParams.hCb,
2072							   (TTestCmd*)pParamInfo->content.interogateCmdCBParams.pCb);
2073	default:
2074        TRACE1(pCmdBld->hReport, REPORT_SEVERITY_ERROR, "cmdBld_GetParam - ERROR - Param is not supported, %d\n\n", pParamInfo->paramType);
2075        return (PARAM_NOT_SUPPORTED);
2076    }
2077
2078    return TI_OK;
2079}
2080
2081
2082static TI_STATUS cmdBld_ReadMibBeaconFilterIETable (TI_HANDLE hCmdBld, TI_HANDLE hCb, void* fCb, void* pCb)
2083{
2084    TCmdBld	*pCmdBld 				= (TCmdBld *)hCmdBld;
2085    TMib *pMib 						= (TMib*)pCb;
2086    TCmdQueueInterrogateCb RetFunc 	= (TCmdQueueInterrogateCb)fCb;
2087    TI_UINT8 IETableSize 			= 0;
2088
2089    /*Get params*/
2090    pMib->aData.BeaconFilter.iNumberOfIEs = DB_WLAN(hCmdBld).beaconFilterIETable.numberOfIEs;
2091    IETableSize = DB_WLAN(hCmdBld).beaconFilterIETable.IETableSize;
2092
2093    os_memoryZero (pCmdBld->hOs,
2094                   pMib->aData.BeaconFilter.iIETable,
2095                   sizeof(pMib->aData.BeaconFilter.iIETable));
2096
2097    os_memoryCopy (pCmdBld->hOs,
2098                   pMib->aData.BeaconFilter.iIETable,
2099                   DB_WLAN(hCmdBld).beaconFilterIETable.IETable,
2100                   IETableSize);
2101
2102    pMib->Length = IETableSize + 1;
2103
2104    RetFunc(hCb, TI_OK, pCb);
2105
2106    return TI_OK;
2107}
2108
2109/**
2110 * \author \n
2111 * \date \n
2112 * \brief Coordinates between legacy TxRatePolicy implementation and the MIB format: \n
2113 *        Converts the pGwsi_txRatePolicy back to whal commands
2114 *        Activates the whal whalCtrl_set function
2115 * Function Scope \e Public.\n
2116 * \param  - \n
2117 * \return \n
2118 */
2119static TI_STATUS cmdBld_ReadMibTxRatePolicy (TI_HANDLE hCmdBld, TI_HANDLE hCb, void* fCb, void* pCb)
2120{
2121    TMib* pMib = (TMib*)pCb;
2122    TCmdQueueInterrogateCb RetFunc = (TCmdQueueInterrogateCb)fCb;
2123    TI_STATUS status = TI_OK;
2124    TTwdParamInfo param;
2125
2126    param.paramType = TWD_TX_RATE_CLASS_PARAM_ID;
2127    cmdBld_GetParam (hCmdBld, &param);
2128    if (param.content.pTxRatePlicy == NULL)
2129        return TI_NOK;
2130
2131    /*Copy the data form the param to the MIB*/
2132    pMib->aData.txRatePolicy = *param.content.pTxRatePlicy;
2133    pMib->Length = pMib->aData.txRatePolicy.numOfRateClasses * sizeof(pMib->aData.txRatePolicy.rateClass[0]) +
2134                   sizeof(pMib->aData.txRatePolicy.numOfRateClasses);
2135    RetFunc (hCb, status, pCb);
2136    return status;
2137}
2138
2139
2140TI_STATUS cmdBld_ReadMib (TI_HANDLE hCmdBld, TI_HANDLE hCb, void* fCb, void* pCb)
2141{
2142    TCmdBld     *pCmdBld = (TCmdBld *)hCmdBld;
2143    TMib    *pMibBuf = (TMib*)pCb;
2144    TCmdQueueInterrogateCb RetFunc = (TCmdQueueInterrogateCb)fCb;
2145    TI_STATUS Status = TI_OK;
2146
2147    TRACE1(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION, "cmdBld_ReadMib :pMibBuf %p:\n",pMibBuf);
2148
2149    TRACE1(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION, "cmdBld_ReadMib :aMib %x:\n", pMibBuf->aMib);
2150
2151    switch (pMibBuf->aMib)
2152    {
2153    case MIB_dot11MaxReceiveLifetime:
2154        {
2155            TTwdParamInfo ParamInfo;
2156            ParamInfo.paramType = TWD_MAX_RX_MSDU_LIFE_TIME_PARAM_ID;
2157            ParamInfo.paramLength = sizeof(ParamInfo.content.halCtrlMaxRxMsduLifetime);
2158            Status = cmdBld_GetParam (hCmdBld, &ParamInfo);
2159            pMibBuf->aData.MaxReceiveLifeTime = ParamInfo.content.halCtrlMaxRxMsduLifetime / 1024; /* converting from usecs to TUs*/
2160            pMibBuf->Length = sizeof(pMibBuf->aData.MaxReceiveLifeTime);
2161        }
2162        break;
2163
2164    case MIB_dot11GroupAddressesTable:
2165        {
2166            Status = cmdBld_GetGroupAddressTable (hCmdBld,
2167                                                  &pMibBuf->aData.GroupAddressTable.bFilteringEnable,
2168                                                  &pMibBuf->aData.GroupAddressTable.nNumberOfAddresses,
2169                                                  pMibBuf->aData.GroupAddressTable.aGroupTable);
2170
2171            pMibBuf->Length = sizeof(pMibBuf->aData.GroupAddressTable.bFilteringEnable) +
2172                              sizeof(pMibBuf->aData.GroupAddressTable.nNumberOfAddresses) +
2173                              pMibBuf->aData.GroupAddressTable.nNumberOfAddresses * sizeof(TMacAddr);
2174        }
2175        break;
2176
2177    case MIB_ctsToSelf:
2178        {
2179            TTwdParamInfo ParamInfo;
2180            ParamInfo.paramType = TWD_CTS_TO_SELF_PARAM_ID;
2181            ParamInfo.paramLength = sizeof(ParamInfo.content.halCtrlCtsToSelf);
2182            Status = cmdBld_GetParam (hCmdBld, &ParamInfo);
2183            pMibBuf->aData.CTSToSelfEnable = ParamInfo.content.halCtrlCtsToSelf;
2184            pMibBuf->Length = sizeof(pMibBuf->aData.CTSToSelfEnable);
2185        }
2186        break;
2187
2188    case MIB_arpIpAddressesTable:
2189        {
2190            TIpAddr   IpAddress;
2191            EIpVer    IPver;
2192            TI_UINT8  Enable;
2193
2194            pMibBuf->Length = sizeof(TMibArpIpAddressesTable);
2195            Status = cmdBld_GetArpIpAddressesTable (hCmdBld, &IpAddress, &Enable, &IPver);
2196            if (Status == TI_OK)
2197            {
2198                pMibBuf->aData.ArpIpAddressesTable.FilteringEnable = Enable;
2199
2200                if (IP_VER_4 == IPver) /* IP_VER_4 only */
2201                {
2202                    IP_COPY (pMibBuf->aData.ArpIpAddressesTable.addr, IpAddress);
2203                }
2204                else
2205                {
2206                    Status = TI_NOK;
2207                }
2208            }
2209            return Status;
2210        }
2211
2212    case MIB_rxFilter:
2213        {
2214            TI_UINT32 RxConfigOption;
2215            TI_UINT32 RxFilterOption;
2216
2217            pMibBuf->Length = 1;
2218            pMibBuf->aData.RxFilter = 0;
2219
2220            /* Get RX filter data */
2221            Status = cmdBld_GetRxFilters (hCmdBld, &RxConfigOption, &RxFilterOption);
2222            if (TI_OK == Status)
2223            {
2224                /*Translate to MIB bitmap*/
2225                if ((RxConfigOption & RX_CFG_MAC) == RX_CFG_ENABLE_ANY_DEST_MAC)
2226                    pMibBuf->aData.RxFilter |= MIB_RX_FILTER_PROMISCOUS_SET;
2227
2228                if ((RxConfigOption & RX_CFG_BSSID) == RX_CFG_ENABLE_ONLY_MY_BSSID)
2229                    pMibBuf->aData.RxFilter |= MIB_RX_FILTER_BSSID_SET;
2230            }
2231        }
2232        break;
2233
2234    case MIB_beaconFilterIETable:
2235        return cmdBld_ReadMibBeaconFilterIETable (hCmdBld, hCb, fCb, pCb);
2236
2237    case MIB_txRatePolicy:
2238        return cmdBld_ReadMibTxRatePolicy (hCmdBld, hCb, fCb, pCb);
2239
2240    case MIB_countersTable:
2241        return cmdBld_ItrErrorCnt (hCmdBld, fCb, hCb, pCb);
2242
2243    case MIB_statisticsTable:
2244        return cmdBld_ItrRoamimgStatisitics (hCmdBld, fCb, hCb, pCb);
2245
2246    default:
2247        TRACE1(pCmdBld->hReport, REPORT_SEVERITY_ERROR, "TWD_ReadMib:MIB aMib 0x%x Not supported\n",pMibBuf->aMib);
2248        return TI_NOK;
2249    }
2250
2251    if(RetFunc)
2252        RetFunc(hCb, Status, pCb);
2253
2254    return TI_OK;
2255}
2256
2257
2258TI_STATUS cmdBld_GetGroupAddressTable (TI_HANDLE hCmdBld, TI_UINT8* pEnabled, TI_UINT8* pNumGroupAddrs, TMacAddr *pGroupAddr)
2259{
2260    TCmdBld   *pCmdBld = (TCmdBld *)hCmdBld;
2261    TI_UINT32     i;
2262
2263    if (NULL == pEnabled || NULL == pNumGroupAddrs || NULL == pGroupAddr)
2264    {
2265        TRACE3(pCmdBld->hReport, REPORT_SEVERITY_ERROR, "cmdBld_GetGroupAddressTable: pisEnabled=0x%p pnumGroupAddrs=0x%p  Group_addr=0x%p !!!\n", pEnabled, pNumGroupAddrs, pGroupAddr);
2266        return PARAM_VALUE_NOT_VALID;
2267    }
2268
2269    *pNumGroupAddrs = DB_WLAN(hCmdBld).numGroupAddrs;
2270    *pEnabled = DB_WLAN(hCmdBld).isMacAddrFilteringnabled;
2271
2272    os_memoryZero (pCmdBld->hOs, pGroupAddr, sizeof(pGroupAddr));
2273    for (i = 0; i < *pNumGroupAddrs; i++)
2274    {
2275        os_memoryCopy (pCmdBld->hOs,
2276                       (void *)&((*pGroupAddr)[MAC_ADDR_LEN*i]),
2277                       &DB_WLAN(hCmdBld).aGroupAddr[i],
2278                       MAC_ADDR_LEN);
2279    }
2280
2281    return TI_OK;
2282}
2283
2284
2285TI_STATUS cmdBld_GetRxFilters (TI_HANDLE hCmdBld, TI_UINT32* pRxConfigOption, TI_UINT32* pRxFilterOption)
2286{
2287    *pRxConfigOption = DB_WLAN(hCmdBld).RxConfigOption;
2288    *pRxFilterOption = DB_WLAN(hCmdBld).RxFilterOption;
2289
2290    return TI_OK;
2291}
2292
2293
2294TFwInfo * cmdBld_GetFWInfo (TI_HANDLE hCmdBld)
2295{
2296    return &DB_HW(hCmdBld);
2297}
2298
2299
2300
2301TI_STATUS cmdBld_SetRadioBand (TI_HANDLE hCmdBld, ERadioBand eRadioBand)
2302{
2303    DB_WLAN(hCmdBld).RadioBand = eRadioBand;
2304
2305    return TI_OK;
2306}
2307
2308
2309/****************************************************************************
2310 *                      cmdBld_CurrentAssociationIdGet()
2311 ****************************************************************************
2312 * DESCRIPTION: Get the current TX antenna
2313 *
2314 * INPUTS:
2315 *
2316 * OUTPUT:
2317 *
2318 * RETURNS: TI_OK or TI_NOK
2319 ****************************************************************************/
2320TI_STATUS cmdBld_GetCurrentAssociationId (TI_HANDLE hCmdBld, TI_UINT16 *pAidVal)
2321{
2322    *pAidVal = DB_WLAN(hCmdBld).Aid;
2323
2324    return TI_OK;
2325}
2326
2327
2328 /****************************************************************************
2329 *                      cmdBld_GetArpIpAddressesTable()
2330 ****************************************************************************
2331 * DESCRIPTION: Sets the Group table according to the given configuration.
2332 *
2333 * OUTPUT:  None
2334 *
2335 * RETURNS: TI_OK or TI_NOK
2336 ****************************************************************************/
2337TI_STATUS cmdBld_GetArpIpAddressesTable (TI_HANDLE hCmdBld, TIpAddr *pIp, TI_UINT8* pbEnabled, EIpVer *pIpVer)
2338{
2339    *pIpVer = (EIpVer)DB_WLAN(hCmdBld).arp_IP_ver;
2340
2341    IP_COPY (*pIp, DB_WLAN(hCmdBld).arp_IP_addr);
2342
2343    *pbEnabled = DB_WLAN(hCmdBld).isArpIpFilteringEnabled;
2344
2345    return TI_OK;
2346}
2347
2348
2349TI_STATUS cmdBld_ConvertAppRatesBitmap (TI_UINT32 uAppRatesBitmap, TI_UINT32 uAppModulation, EHwRateBitFiled *pHwRatesBitmap)
2350{
2351    EHwRateBitFiled uRatesBitmap = 0;
2352
2353    if (uAppRatesBitmap & DRV_RATE_MASK_1_BARKER)    uRatesBitmap |= HW_BIT_RATE_1MBPS;
2354    if (uAppRatesBitmap & DRV_RATE_MASK_2_BARKER)    uRatesBitmap |= HW_BIT_RATE_2MBPS;
2355    if (uAppRatesBitmap & DRV_RATE_MASK_5_5_CCK)     uRatesBitmap |= HW_BIT_RATE_5_5MBPS;
2356    if (uAppRatesBitmap & DRV_RATE_MASK_11_CCK)      uRatesBitmap |= HW_BIT_RATE_11MBPS;
2357    if (uAppRatesBitmap & DRV_RATE_MASK_22_PBCC)     uRatesBitmap |= HW_BIT_RATE_22MBPS;
2358    if (uAppRatesBitmap & DRV_RATE_MASK_6_OFDM)      uRatesBitmap |= HW_BIT_RATE_6MBPS;
2359    if (uAppRatesBitmap & DRV_RATE_MASK_9_OFDM)      uRatesBitmap |= HW_BIT_RATE_9MBPS;
2360    if (uAppRatesBitmap & DRV_RATE_MASK_12_OFDM)     uRatesBitmap |= HW_BIT_RATE_12MBPS;
2361    if (uAppRatesBitmap & DRV_RATE_MASK_18_OFDM)     uRatesBitmap |= HW_BIT_RATE_18MBPS;
2362    if (uAppRatesBitmap & DRV_RATE_MASK_24_OFDM)     uRatesBitmap |= HW_BIT_RATE_24MBPS;
2363    if (uAppRatesBitmap & DRV_RATE_MASK_36_OFDM)     uRatesBitmap |= HW_BIT_RATE_36MBPS;
2364    if (uAppRatesBitmap & DRV_RATE_MASK_48_OFDM)     uRatesBitmap |= HW_BIT_RATE_48MBPS;
2365    if (uAppRatesBitmap & DRV_RATE_MASK_54_OFDM)     uRatesBitmap |= HW_BIT_RATE_54MBPS;
2366    if (uAppRatesBitmap & DRV_RATE_MASK_MCS_0_OFDM)  uRatesBitmap |= HW_BIT_RATE_MCS_0;
2367    if (uAppRatesBitmap & DRV_RATE_MASK_MCS_1_OFDM)  uRatesBitmap |= HW_BIT_RATE_MCS_1;
2368    if (uAppRatesBitmap & DRV_RATE_MASK_MCS_2_OFDM)  uRatesBitmap |= HW_BIT_RATE_MCS_2;
2369    if (uAppRatesBitmap & DRV_RATE_MASK_MCS_3_OFDM)  uRatesBitmap |= HW_BIT_RATE_MCS_3;
2370    if (uAppRatesBitmap & DRV_RATE_MASK_MCS_4_OFDM)  uRatesBitmap |= HW_BIT_RATE_MCS_4;
2371    if (uAppRatesBitmap & DRV_RATE_MASK_MCS_5_OFDM)  uRatesBitmap |= HW_BIT_RATE_MCS_5;
2372    if (uAppRatesBitmap & DRV_RATE_MASK_MCS_6_OFDM)  uRatesBitmap |= HW_BIT_RATE_MCS_6;
2373    if (uAppRatesBitmap & DRV_RATE_MASK_MCS_7_OFDM)  uRatesBitmap |= HW_BIT_RATE_MCS_7;
2374
2375    *pHwRatesBitmap = uRatesBitmap;
2376
2377    return TI_OK;
2378}
2379
2380EHwRateBitFiled rateNumberToBitmap(TI_UINT8 uRate)
2381{
2382	switch(uRate)
2383	{
2384	case 1:   return HW_BIT_RATE_1MBPS;
2385	case 2:   return HW_BIT_RATE_2MBPS;
2386	case 5:   return HW_BIT_RATE_5_5MBPS;
2387	case 6:   return HW_BIT_RATE_6MBPS;
2388	case 9:   return HW_BIT_RATE_9MBPS;
2389	case 11:  return HW_BIT_RATE_11MBPS;
2390	case 12:  return HW_BIT_RATE_12MBPS;
2391	case 18:  return HW_BIT_RATE_18MBPS;
2392	case 22:  return HW_BIT_RATE_22MBPS;
2393	case 24:  return HW_BIT_RATE_24MBPS;
2394	case 36:  return HW_BIT_RATE_36MBPS;
2395	case 48:  return HW_BIT_RATE_48MBPS;
2396	case 54:  return HW_BIT_RATE_54MBPS;
2397	default:
2398		return 0;
2399	}
2400}
2401
2402TI_STATUS cmdBld_ConvertAppRate (ERate AppRate, TI_UINT8 *pHwRate)
2403{
2404    TI_UINT8     Rate = 0;
2405    TI_STATUS status = TI_OK;
2406
2407    switch (AppRate)
2408    {
2409        /*
2410         *  The handle for 5.5/11/22 PBCC was removed !!!
2411         */
2412
2413        case DRV_RATE_1M:           Rate = txPolicy1;          break;
2414        case DRV_RATE_2M:           Rate = txPolicy2;          break;
2415        case DRV_RATE_5_5M:         Rate = txPolicy5_5;        break;
2416        case DRV_RATE_11M:          Rate = txPolicy11;         break;
2417        case DRV_RATE_22M:          Rate = txPolicy22;         break;
2418        case DRV_RATE_6M:           Rate = txPolicy6;          break;
2419        case DRV_RATE_9M:           Rate = txPolicy9;          break;
2420        case DRV_RATE_12M:          Rate = txPolicy12;         break;
2421        case DRV_RATE_18M:          Rate = txPolicy18;         break;
2422        case DRV_RATE_24M:          Rate = txPolicy24;         break;
2423        case DRV_RATE_36M:          Rate = txPolicy36;         break;
2424        case DRV_RATE_48M:          Rate = txPolicy48;         break;
2425        case DRV_RATE_54M:          Rate = txPolicy54;         break;
2426        case DRV_RATE_MCS_0:          Rate = txPolicyMcs0;         break;
2427        case DRV_RATE_MCS_1:          Rate = txPolicyMcs1;         break;
2428        case DRV_RATE_MCS_2:          Rate = txPolicyMcs2;         break;
2429        case DRV_RATE_MCS_3:          Rate = txPolicyMcs3;         break;
2430        case DRV_RATE_MCS_4:          Rate = txPolicyMcs4;         break;
2431        case DRV_RATE_MCS_5:          Rate = txPolicyMcs5;         break;
2432        case DRV_RATE_MCS_6:          Rate = txPolicyMcs6;         break;
2433        case DRV_RATE_MCS_7:          Rate = txPolicyMcs7;         break;
2434
2435        default:
2436            WLAN_OS_REPORT(("%s wrong app rate = %d\n",__FUNCTION__,AppRate));
2437            status = TI_NOK;
2438            break;
2439    }
2440
2441    if (status == TI_OK)
2442        *pHwRate = Rate;
2443    else
2444        *pHwRate = txPolicy1;
2445
2446    return status;
2447}
2448
2449
2450TI_STATUS cmdBld_SetRxFilter (TI_HANDLE hCmdBld, TI_UINT32 uRxConfigOption, TI_UINT32 uRxFilterOption)
2451{
2452    DB_WLAN(hCmdBld).RxConfigOption = uRxConfigOption;
2453    DB_WLAN(hCmdBld).RxFilterOption = uRxFilterOption;
2454    DB_WLAN(hCmdBld).RxConfigOption |= RX_CFG_ENABLE_PHY_HEADER_PLCP;
2455
2456    if (DB_WLAN(hCmdBld).RxDisableBroadcast)
2457    {
2458        DB_WLAN(hCmdBld).RxConfigOption |= RX_CFG_DISABLE_BCAST;
2459    }
2460
2461    return TI_OK;
2462}
2463
2464
2465TI_UINT8 cmdBld_GetBssType (TI_HANDLE hCmdBld)
2466{
2467    return DB_BSS(hCmdBld).ReqBssType;
2468}
2469
2470
2471TI_UINT32 cmdBld_GetAckPolicy (TI_HANDLE hCmdBld, TI_UINT32 uQueueId)
2472{
2473    return (TI_UINT32)DB_QUEUES(hCmdBld).queues[uQueueId].ackPolicy;
2474}
2475
2476
2477TI_STATUS cmdBld_SetSecuritySeqNum (TI_HANDLE hCmdBld, TI_UINT8 securitySeqNumLsByte)
2478{
2479    TCmdBld *pCmdBld = (TCmdBld *)hCmdBld;
2480
2481    /* If 8 lsb wrap around occurred (new < old). */
2482    if ((TI_UINT16)securitySeqNumLsByte < (pCmdBld->uSecuritySeqNumLow & 0xFF))
2483    {
2484        /* Increment the upper byte of the 16 lsb. */
2485        pCmdBld->uSecuritySeqNumLow += 0x100;
2486
2487        /* If 16 bit wrap around occurred, increment the upper 32 bit. */
2488        if (!(pCmdBld->uSecuritySeqNumLow & 0xFF00))
2489            pCmdBld->uSecuritySeqNumHigh++;
2490    }
2491
2492    /* Save new sequence number 8 lsb (received from the FW). */
2493    pCmdBld->uSecuritySeqNumLow &= 0xFF00;
2494    pCmdBld->uSecuritySeqNumLow |= (TI_UINT16)securitySeqNumLsByte;
2495
2496    return TI_OK;
2497}
2498
2499/****************************************************************************
2500 *                      cmdBld_JoinCmpltForReconfigCb()
2501 ****************************************************************************
2502 * DESCRIPTION:   The Join-Complete callback used by the reconfig sequenc (see __cmd_start_join()).
2503 *                It restores the original Join-Complete CB and continues the sequence.
2504 *                It is needed so the reconfig sequence won't progress before the Join
2505 *                    command is completed (otherwise the FW may drop the other commands).
2506 *
2507 * INPUTS: hCmdBld - The module object
2508 *
2509 * OUTPUT:  None
2510 *
2511 * RETURNS: TI_OK
2512 ****************************************************************************/
2513static TI_STATUS cmdBld_JoinCmpltForReconfigCb (TI_HANDLE hCmdBld)
2514{
2515    TCmdBld    *pCmdBld = (TCmdBld *)hCmdBld;
2516    void       *fDummyCb;
2517    TI_HANDLE   hDummyHndl;
2518
2519    /* Restored the original Join-Complete callback function */
2520    eventMbox_ReplaceEvent (pCmdBld->hEventMbox,
2521                              TWD_OWN_EVENT_JOIN_CMPLT,
2522                              pCmdBld->fJoinCmpltOriginalCbFunc,
2523                              pCmdBld->hJoinCmpltOriginalCbHndl,
2524                              &fDummyCb,
2525                              &hDummyHndl);
2526
2527    /* Call the reconfig sequence to continue the configuration after Join completion */
2528    cmdBld_ConfigSeq (hCmdBld);
2529
2530    return TI_OK;
2531}
2532
2533
2534
2535static TI_STATUS cmdBld_DummyCb (TI_HANDLE hCmdBld)
2536{
2537    return TI_OK;
2538}
2539
2540
2541
2542
2543
2544#ifdef TI_DBG
2545
2546void cmdBld_DbgForceTemplatesRates (TI_HANDLE hCmdBld, TI_UINT32 uRateMask)
2547{
2548    TCmdBld *pCmdBld = (TCmdBld *)hCmdBld;
2549
2550    pCmdBld->uDbgTemplatesRateMask = uRateMask;
2551}
2552
2553#endif /* TI_DBG */
2554
2555