platforms/os/Symbian/WVSS/src/wha/TIWha.cpp
changeset 0 10c42ec6c05f
equal deleted inserted replaced
-1:000000000000 0:10c42ec6c05f
       
     1 /*
       
     2  * TIWha.cpp
       
     3  *
       
     4  * Copyright(c) 1998 - 2010 Texas Instruments. All rights reserved.      
       
     5  * All rights reserved.      
       
     6  * 
       
     7  * This program and the accompanying materials are made available under the 
       
     8  * terms of the Eclipse Public License v1.0 or BSD License which accompanies
       
     9  * this distribution. The Eclipse Public License is available at
       
    10  * http://www.eclipse.org/legal/epl-v10.html and the BSD License is as below.                                   
       
    11  *                                                                       
       
    12  * Redistribution and use in source and binary forms, with or without    
       
    13  * modification, are permitted provided that the following conditions    
       
    14  * are met:                                                              
       
    15  *                                                                       
       
    16  *  * Redistributions of source code must retain the above copyright     
       
    17  *    notice, this list of conditions and the following disclaimer.      
       
    18  *  * Redistributions in binary form must reproduce the above copyright  
       
    19  *    notice, this list of conditions and the following disclaimer in    
       
    20  *    the documentation and/or other materials provided with the         
       
    21  *    distribution.                                                      
       
    22  *  * Neither the name Texas Instruments nor the names of its            
       
    23  *    contributors may be used to endorse or promote products derived    
       
    24  *    from this software without specific prior written permission.      
       
    25  *                                                                       
       
    26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   
       
    27  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     
       
    28  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
       
    29  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  
       
    30  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
       
    31  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      
       
    32  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 
       
    33  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
       
    34  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   
       
    35  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
       
    36  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
       
    37  */
       
    38 
       
    39 
       
    40 /** \file  TIWha.cpp 
       
    41  *  \brief  Interface between the Symbian to the WVSS WLAN WL6.1 Driver
       
    42  *
       
    43  *  \see   
       
    44 */
       
    45 
       
    46 #include "TIWha.h"
       
    47 #include "TIWhaAdaptCb.h"
       
    48 #include "wlanhwbusaccesslayer.h"
       
    49 #ifdef GEM_SUPPORT
       
    50 #include "TIWhaGemDef.h"
       
    51 #endif /* GEM_SUPPORT */
       
    52 
       
    53 /* The fw that we are using in case it isn't contained in aData */
       
    54 #include "wilink6_firmware.h"
       
    55 
       
    56 #ifdef WLAN_SDIO
       
    57 #include "SdioClient.h"
       
    58 #endif //WLAN_SDIO
       
    59 
       
    60 
       
    61 const TInt KWlanDriverMajorVersion = 1;
       
    62 const TInt KWlanDriverMinorVersion = 0;
       
    63 const TInt KWlanDriverBuildVersion = 0;
       
    64 const TUint KWlanUnitsAllowedMask = 0x0000000F;
       
    65 
       
    66 
       
    67 /*******************************************************************************
       
    68  * stuff for C file linking.                                                   *
       
    69  *******************************************************************************/
       
    70 
       
    71 extern "C" 
       
    72 {
       
    73 #include "tidef.h"
       
    74 #include "report.h"
       
    75 #include "timer.h"
       
    76 #include "TWDriver.h"
       
    77 #include "version.h"
       
    78 #include "osApi.h"
       
    79 #include "context.h"
       
    80 #include "public_commands.h"
       
    81 //#include "public_radio.h"
       
    82 #include "TxnQueue.h"
       
    83 #include "BusDrv.h"
       
    84 #define __FILE_ID__								FILE_ID_144
       
    85 }
       
    86 
       
    87 #define MAX_NUM_OF_TX_QUEUES	4 
       
    88 #define TX_TOTAL_OFFSET_BEFORE_DATA (WSPI_PAD_LEN_WRITE + TX_DESCRIPTOR_SIZE)
       
    89 
       
    90 /* Stalling the CPU of OAMP3430 for 2Ms */
       
    91 #define STALL_ON_CPU 2000
       
    92 
       
    93 /* In case of a KFailed we use the Assert() function as indicated in the spec, but return KSuccess */
       
    94 #define ASSERT_MI2(hrep,mib,exp,file,func,line)              \
       
    95         if ((exp) != WHA::KSuccess) {                             \
       
    96             TRACE2(hrep, REPORT_SEVERITY_ERROR ,  " failed, mib=%d, file=, line=%d\n", mib, line);    \
       
    97             MWlanOsa::Assert( (const TInt8 *)file, line, EFalse ); \
       
    98             return WHA::KSuccess;                                  \
       
    99         }
       
   100         
       
   101 #define ASSERT_MIB(hrep,mib,exp)                             \
       
   102         ASSERT_MI2(hrep,mib,exp, __FUNCTION__,__FUNCTION__,__LINE__)
       
   103 
       
   104 
       
   105 #define ASSERT_ER2(hrep,fmsg,par,line)             \
       
   106         TRACE1(hrep, REPORT_SEVERITY_ERROR,  fmsg, par);    \
       
   107         //MWlanOsa::Assert( (const TInt8 *)file, line, EFalse ); 
       
   108 
       
   109 #define ASSERT_ERR(hrep,fmsg,par)                            \
       
   110         ASSERT_ER2(hrep,fmsg,par,__LINE__)
       
   111 
       
   112 
       
   113 #define FREF_CLK_FREQ_MASK      0x7
       
   114 
       
   115 
       
   116 /************************************************************************************/
       
   117 
       
   118 /** 
       
   119 * \fn     Create
       
   120 * \brief  static create
       
   121 * 
       
   122 * Just call constructor 
       
   123 *
       
   124 * \note   
       
   125 * return   handle to TIWha class. 
       
   126 * \sa     
       
   127 */ 
       
   128 WHA::Wha* WHA::Wha::Create(MWlanOsa& aOsa, WlanHpa& aHpa, const SHwBusAccessLayer& aTransPortLayer)
       
   129 {
       
   130     return new TIWha (aOsa, aHpa, *(aTransPortLayer.iSpia));
       
   131 }
       
   132 
       
   133 
       
   134 /** 
       
   135 * \fn     Destroy
       
   136 * \brief  static destroy
       
   137 * 
       
   138 * Just call destructor 
       
   139 *
       
   140 * \note   
       
   141 * \sa     
       
   142 */ 
       
   143 void WHA::Wha::Destroy(Wha* aWha)
       
   144 {
       
   145     delete aWha;
       
   146 }
       
   147 
       
   148 /** 
       
   149 * \fn     TIWha
       
   150 * \brief  Constructor
       
   151 * 
       
   152 * This method is the default constructor,all modules mamory alocation 
       
   153 * and software configuration (not sending any thing via BUS to the firmware)
       
   154 * 
       
   155 * \note   
       
   156 * return   handle to TIWha class. 
       
   157 * \sa     
       
   158 */ 
       
   159 TIWha::TIWha(MWlanOsa& aOsa, WlanHpa& aHpa, WlanSpia& aSpia)
       
   160 : Wha(aOsa, aHpa, aSpia) /* Construct the base class */  
       
   161 {
       
   162     /* Before initializing the report module, we should use the WLAN_OS_REPORT macro */
       
   163     WLAN_INIT_REPORT (("TIWha constructor ++\n"));
       
   164     WLAN_INIT_REPORT(("Driver Version  : %s\n", SW_VERSION_STR));
       
   165 
       
   166     /* tOsContext (hOS is made of MWlanOsa and WlanSpia */
       
   167     iTwdCtrl.tOsContext.hOsa = &aOsa;
       
   168     iTwdCtrl.tOsContext.hSpia = &aSpia;
       
   169     iTwdCtrl.tOsContext.hHpa = &aHpa;
       
   170 
       
   171     /* Nullify handles to mark that it wasn't created yet */
       
   172     iTwdCtrl.hTWD = NULL;
       
   173     iTwdCtrl.hReport = NULL;
       
   174     iTwdCtrl.hReport = NULL;
       
   175     iTwdCtrl.hContext = NULL;
       
   176     iTiWlanHpaCb = NULL;    
       
   177     /* indicate that no error indication was called */
       
   178     bErrorIndication = TI_FALSE;
       
   179 
       
   180     bConnectionTimerRunning = TI_FALSE;
       
   181     /* indicate that TIWha::Release() should be called directly if we have error indication */
       
   182     bCallRelease = TI_TRUE;
       
   183 	bFreeDriver	 = TI_FALSE;
       
   184 	bRxMemFailTimerRunning = TI_FALSE;
       
   185     uRxMemFailCount = 0;
       
   186 
       
   187     bFailureIndication = TI_FALSE;
       
   188 
       
   189 	/* Initilaize Timer handle */
       
   190 	readDot11StationIdMibTmr = NULL;
       
   191 
       
   192     /* Set the join flag to false */
       
   193     bJoined = 0;
       
   194     
       
   195     iConnectionCounter = 0;
       
   196 
       
   197     #ifdef HT_SUPPORT
       
   198 	    /* Reset the BA Vectors */
       
   199 	    iTxBlockAckUsageLast = 0;
       
   200         iRxBlockAckUsageLast = 0;
       
   201     #endif
       
   202 
       
   203     
       
   204     pFailureDfcClient = new TIFailureDfcClient(*iTwdCtrl.tOsContext.hOsa);
       
   205     if (pFailureDfcClient == NULL)
       
   206     {
       
   207         WLAN_OS_REPORT (("ERROR: CreateDriver TIFailureDfcClient failure\n"));        
       
   208     }
       
   209 
       
   210     pConnectDfcClient = new TIConnectDfcClient(*iTwdCtrl.tOsContext.hOsa);
       
   211     if (pConnectDfcClient == NULL)
       
   212     {
       
   213         WLAN_OS_REPORT (("ERROR: CreateDriver TIConnectDfcClient failure\n"));        
       
   214     }
       
   215     
       
   216     WLAN_INIT_REPORT (("TIWha constructor -- \n"));
       
   217 }
       
   218 
       
   219 
       
   220 TIWha::TIWha() 
       
   221 : Wha (*iTwdCtrl.tOsContext.hOsa,*iTwdCtrl.tOsContext.hHpa,*iTwdCtrl.tOsContext.hSpia)
       
   222 {
       
   223     iVersion = TVersion( KWlanDriverMajorVersion, 
       
   224         KWlanDriverMinorVersion,KWlanDriverBuildVersion );
       
   225     iUnitsMask = KWlanUnitsAllowedMask;
       
   226     bDriverCreated = TI_TRUE;
       
   227 /* Nullify handles to mark that it wasn't created yet */
       
   228     iTwdCtrl.hTWD = NULL;
       
   229     iTwdCtrl.hReport = NULL;
       
   230     iTwdCtrl.hReport = NULL;
       
   231     iTwdCtrl.hContext = NULL;
       
   232     iTiWlanHpaCb = NULL; 
       
   233     /* indicate that no error indication was called */
       
   234     bErrorIndication = TI_FALSE;
       
   235 
       
   236     bConnectionTimerRunning = TI_FALSE;
       
   237     /* indicate that TIWha::Release() should be called directly if we have error indication */
       
   238     bCallRelease = TI_TRUE;
       
   239 	bFreeDriver	 = TI_FALSE;
       
   240 	bRxMemFailTimerRunning = TI_FALSE;
       
   241     uRxMemFailCount = 0;
       
   242 
       
   243     bFailureIndication = TI_FALSE;
       
   244 
       
   245 	/* Initilaize Timer handle */
       
   246 	readDot11StationIdMibTmr = NULL;
       
   247 
       
   248     /* Set the join flag to false */
       
   249     bJoined = 0;
       
   250     
       
   251     iConnectionCounter = 0;
       
   252 
       
   253     #ifdef HT_SUPPORT
       
   254 	    /* Reset the BA Vectors */
       
   255 	    iTxBlockAckUsageLast = 0;
       
   256         iRxBlockAckUsageLast = 0;
       
   257     #endif
       
   258 
       
   259     WLAN_INIT_REPORT (("TIWha constructor -- \n"));
       
   260 }
       
   261 
       
   262 
       
   263 /** 
       
   264 * \fn     CreateDriver
       
   265 * \brief  Create driver modules
       
   266 * 
       
   267 * Create 'report', 'context', 'TWD', 'HpaCb'
       
   268 *
       
   269 * \note   In case of failure, The modules will be released later in DestroyDriver();
       
   270 * \sa     
       
   271 */ 
       
   272 TI_STATUS TIWha::CreateDriver()
       
   273 {
       
   274     WLAN_INIT_REPORT (("CreateDriver ++\n"));
       
   275     
       
   276 
       
   277     /* Create utils and TWD */
       
   278     iTwdCtrl.hReport  = report_Create ((TI_HANDLE)&iTwdCtrl.tOsContext);
       
   279     if (iTwdCtrl.hReport == NULL)
       
   280     {
       
   281         WLAN_OS_REPORT (("ERROR: CreateDriver report_Create failure\n"));
       
   282         return TI_NOK;
       
   283     }
       
   284     InitReportParamTable ();    
       
   285     report_SetDefaults (iTwdCtrl.hReport, &(iTwdCtrl.report_init));
       
   286     
       
   287     TRACE0(iTwdCtrl.hReport, REPORT_SEVERITY_INIT,  "CreateDriver");
       
   288 
       
   289     /* Create context module */
       
   290     iTwdCtrl.hContext       = context_Create ((TI_HANDLE)&iTwdCtrl.tOsContext);
       
   291     if (iTwdCtrl.hContext == NULL)
       
   292     {
       
   293         WLAN_OS_REPORT (("ERROR:CreateDriver context_Create failure\n"));
       
   294         return TI_NOK;
       
   295     }
       
   296 
       
   297     /* Create Timer module */
       
   298     iTwdCtrl.hTimer = tmr_Create ((TI_HANDLE)&iTwdCtrl.tOsContext);
       
   299     if (iTwdCtrl.hTimer == NULL)
       
   300     {
       
   301         WLAN_OS_REPORT (("ERROR:CreateDriver tmr_Create failure\n"));
       
   302         return TI_NOK;
       
   303     }
       
   304 
       
   305     /* Create TxnQ */
       
   306     iTwdCtrl.hTxnQ = txnQ_Create ((TI_HANDLE)&iTwdCtrl.tOsContext);
       
   307     if (iTwdCtrl.hTxnQ == NULL)
       
   308     {
       
   309         WLAN_OS_REPORT (("ERROR:CreateDriver txnQ_Create failure\n"));
       
   310         return TI_NOK;
       
   311     }
       
   312 
       
   313     /* Create TWD */
       
   314     iTwdCtrl.hTWD = TWD_Create ((TI_HANDLE)&iTwdCtrl.tOsContext);
       
   315     if (iTwdCtrl.hTWD == NULL)
       
   316     {
       
   317         WLAN_OS_REPORT (("ERROR:CreateDriver TWD_Create failure\n"));
       
   318         return TI_NOK;
       
   319     }
       
   320 
       
   321     /* Create HpaCb */
       
   322     iTiWlanHpaCb = new TIWlanHpaCB (iTwdCtrl.hTWD);
       
   323     if (iTiWlanHpaCb == NULL)
       
   324     {
       
   325         WLAN_OS_REPORT (("ERROR:CreateDriver new TIWlanHpaCB failure\n"));
       
   326         return TI_NOK;
       
   327     }
       
   328 
       
   329     return TI_OK;
       
   330 }
       
   331 
       
   332 /** 
       
   333 * \fn     DestroyDriver
       
   334 * \brief  destroy driver modules
       
   335 * 
       
   336 * Destroy 'report', 'context', 'TWD', 'HpaCb' only if it is not NULL
       
   337 *
       
   338 * \sa     
       
   339 */ 
       
   340 void TIWha::DestroyDriver()
       
   341 {
       
   342     WLAN_OS_REPORT(("DestroyDriver\n"));
       
   343 
       
   344     /* Delete TWD and utils */
       
   345     if (iTwdCtrl.hTWD != NULL)
       
   346     {
       
   347         TWD_Destroy (iTwdCtrl.hTWD);
       
   348         /* Avoid future destroy of TWD */
       
   349         iTwdCtrl.hTWD = NULL;
       
   350     }
       
   351 
       
   352 	if (iTwdCtrl.hTxnQ)
       
   353 	{
       
   354 		txnQ_Destroy(iTwdCtrl.hTxnQ);
       
   355 		iTwdCtrl.hTxnQ = NULL;
       
   356 	}
       
   357 
       
   358     if (iTwdCtrl.hContext != NULL)
       
   359     {
       
   360         context_Destroy (iTwdCtrl.hContext);
       
   361         /* Avoid future destroy of context */
       
   362         iTwdCtrl.hContext = NULL;
       
   363     }
       
   364     if (iTwdCtrl.hTimer != NULL)
       
   365     {
       
   366         tmr_Destroy (iTwdCtrl.hTimer);
       
   367         /* Avoid future destroy of timer */
       
   368         iTwdCtrl.hTimer = NULL;
       
   369     }
       
   370     if (iTiWlanHpaCb != NULL)
       
   371     {
       
   372         delete iTiWlanHpaCb;
       
   373         /* Avoid future destroy of HpaCb */
       
   374         iTiWlanHpaCb = NULL;    
       
   375     }
       
   376     if (iTwdCtrl.hReport != NULL)
       
   377     {
       
   378         report_Unload (iTwdCtrl.hReport);
       
   379         /* Avoid future destroy of report */
       
   380         iTwdCtrl.hReport = NULL;
       
   381     }
       
   382 	
       
   383     if (readDot11StationIdMibTmr != NULL)
       
   384     {
       
   385         os_timerDestroy(0,readDot11StationIdMibTmr);
       
   386         readDot11StationIdMibTmr = NULL;
       
   387     }    
       
   388 
       
   389     if (hConnectionTimer != NULL)
       
   390     {
       
   391         os_timerDestroy(0,hConnectionTimer);
       
   392         hConnectionTimer = NULL;
       
   393     }
       
   394 
       
   395     if (hInitializeTimer != NULL) 
       
   396     {
       
   397         os_timerDestroy(0,hInitializeTimer);
       
   398         hInitializeTimer = NULL;
       
   399     }
       
   400 
       
   401     if (hRxMemFailTimer != NULL)
       
   402     {
       
   403         os_timerDestroy(0,hRxMemFailTimer);
       
   404         hRxMemFailTimer = NULL;
       
   405     }
       
   406 
       
   407 }
       
   408 
       
   409 /** 
       
   410 * \fn     ~TIWha
       
   411 * \brief  destructor
       
   412 * 
       
   413 * 
       
   414 * \note   Release is called here if it was not called from UMAC
       
   415 * \param  
       
   416 * \return   
       
   417 * \sa     
       
   418 */ 
       
   419 TIWha::~TIWha()
       
   420 {  
       
   421     /* Delete iFailureDfcClient */
       
   422     if (pFailureDfcClient != NULL)
       
   423     {        
       
   424         /* Either succeeds or has no effect */
       
   425         pFailureDfcClient->pFailureDfc->Dequeue();
       
   426         /* Osa owns this. Will be deleted there. */
       
   427         pFailureDfcClient->pFailureDfc = NULL;
       
   428         
       
   429         delete pFailureDfcClient;        
       
   430     }
       
   431     
       
   432     /* Delete iConnectDfcClient */
       
   433     if (pConnectDfcClient != NULL)
       
   434     {        
       
   435         /* Either succeeds or has no effect */
       
   436         pConnectDfcClient->pConnectDfc->Dequeue();
       
   437         /* Osa owns this. Will be deleted there. */
       
   438         pConnectDfcClient->pConnectDfc = NULL;
       
   439 
       
   440         delete pConnectDfcClient;        
       
   441     }
       
   442     
       
   443     WLAN_INIT_REPORT(("~TIWha\n"));   
       
   444 }
       
   445 
       
   446 /** 
       
   447 * \fn     Initialize
       
   448 * \brief  Initialize the WLAN driver (memory allocation and modules software init. )
       
   449 *
       
   450 * \note   
       
   451 * Downloads the firmware code to the WLAN device.
       
   452 * /param aData - firmware data
       
   453 * /param aLength - length of the data in bytes
       
   454 * /return  
       
   455 */
       
   456 void TIWha::Initialize(const void* aData, TUint32 aLength)
       
   457 {
       
   458     iData = aData;
       
   459     iLength = aLength;
       
   460 
       
   461     WLAN_INIT_REPORT (("Initialize ++ \n"));
       
   462     #ifdef TI_TEST
       
   463 	    iQueueId = WHA::ELegacy;
       
   464     #endif /* TI_TEST*/
       
   465 
       
   466     /* configure HPA polarity according to CHIP configuration */
       
   467     #ifdef USE_IRQ_ACTIVE_HIGH
       
   468         WlanHpa::TConfig tConfig = {WlanHpa::EIsrPolarityHigh};
       
   469     #else
       
   470         WlanHpa::TConfig tConfig = {WlanHpa::EIsrPolarityLow};
       
   471     #endif
       
   472 
       
   473     iRxPacketsAllocated = 0;
       
   474 
       
   475     TRACE0(iTwdCtrl.hReport, REPORT_SEVERITY_INIT,  " IRQ is ");
       
   476 
       
   477     /* if we were called from failure indication then we don't reconfigure the HPA */
       
   478     if (bFailureIndication == TI_FALSE )
       
   479     {
       
   480         ((WlanHpa*)iTwdCtrl.tOsContext.hHpa)->Configure(tConfig);
       
   481     }    
       
   482 
       
   483 
       
   484     /* Power up the chip */
       
   485     ((WlanHpa*)iTwdCtrl.tOsContext.hHpa)->PowerOnDevice();
       
   486 #ifdef WLAN_SDIO
       
   487     os_StalluSec ((TI_HANDLE)&iTwdCtrl.tOsContext, 200000 );
       
   488 #endif
       
   489 
       
   490     /* Create all modules */
       
   491     if ( CreateDriver() != TI_OK)
       
   492     {
       
   493         WLAN_OS_REPORT (("Error on CreateDriver() \n"));
       
   494         InitResponse (WHA::KFailed);        
       
   495     }
       
   496 
       
   497     /* Attach our client to HPA */
       
   498     ((WlanHpa*)iTwdCtrl.tOsContext.hHpa)->Attach(*iTiWlanHpaCb);
       
   499     /* Configure the context module */
       
   500     context_Init (iTwdCtrl.hContext, (TI_HANDLE)&iTwdCtrl.tOsContext,iTwdCtrl.hReport);
       
   501 
       
   502     /* Initialize timer module */
       
   503     tmr_Init (iTwdCtrl.hTimer, (TI_HANDLE)&iTwdCtrl.tOsContext, iTwdCtrl.hReport, iTwdCtrl.hContext);
       
   504 
       
   505     hInitializeTimer = os_timerCreate(&iTwdCtrl.tOsContext,(fTimerFunction)TIWhaAdaptCB::InitializeAfterTimer,this);
       
   506 
       
   507 #ifndef WLAN_SDIO
       
   508     /* Wait some time for the HW to complete initialization */
       
   509     os_timerStart (&iTwdCtrl.tOsContext,hInitializeTimer,200);
       
   510 #else
       
   511     InitializeAfterTimer();
       
   512 #endif
       
   513 }
       
   514 
       
   515 
       
   516  /** 
       
   517  * \fn     InitializeAfterTimer
       
   518  * \brief  start second part of initialization after timer expired
       
   519  *          
       
   520  * \note    
       
   521  * \param  
       
   522  * \return  
       
   523  * \sa      
       
   524  */ 
       
   525 void TIWha::InitializeAfterTimer()
       
   526 {
       
   527     TI_STATUS status;
       
   528     TUint8* data = (TUint8*)iData;
       
   529     TUint8* pRadio;
       
   530 
       
   531     TUint32 nvsLength = 0;
       
   532     TUint32 radioLength = 0;
       
   533 
       
   534     /* Create a connection timer that will be triggered after Join command */
       
   535     hConnectionTimer = os_timerCreate(&iTwdCtrl.tOsContext,(fTimerFunction)TIWhaAdaptCB::ConnectionTimeOut,this); 
       
   536     if (hConnectionTimer == NULL)
       
   537     {
       
   538  	WLAN_OS_REPORT(("Error Failed to create hConnectionTimer"));
       
   539     }
       
   540 
       
   541     /* Create a timer for losing context for Station ID Mib */
       
   542     readDot11StationIdMibTmr = os_timerCreate(&iTwdCtrl.tOsContext,(fTimerFunction)TIWhaAdaptCB::ReadDot11StationIdCb,this); 
       
   543     if (readDot11StationIdMibTmr == NULL)
       
   544     {
       
   545         WLAN_OS_REPORT(("Error Faild to create readDot11StationIdMibTmr"));
       
   546     }
       
   547     	
       
   548     /* Create a timer in case RequestForBuffer fails */
       
   549     hRxMemFailTimer = os_timerCreate(&iTwdCtrl.tOsContext,(fTimerFunction)TIWhaAdaptCB::RxMemFailTimerCb,this); 
       
   550     if (hRxMemFailTimer == NULL)
       
   551     {
       
   552         WLAN_OS_REPORT(("Error Faild to create hRxMemFailTimer"));
       
   553     }
       
   554 
       
   555     /* enable timer operation */    
       
   556     tmr_UpdateDriverState (iTwdCtrl.hTimer, TI_TRUE);
       
   557     
       
   558     TRACE0(iTwdCtrl.hReport, REPORT_SEVERITY_INIT,  "init TWD");
       
   559     /*init the txnq */
       
   560     
       
   561     txnQ_Init (iTwdCtrl.hTxnQ,
       
   562                (TI_HANDLE)&iTwdCtrl.tOsContext,
       
   563     	  iTwdCtrl.hReport,
       
   564                iTwdCtrl.hContext);
       
   565 
       
   566 	/* Next section retrieves the pointer and Lenght of NVS & FW accordingly in th eaData Buf */
       
   567 
       
   568     /* 
       
   569     aData structue :
       
   570     ____________________________________________________________________________________________
       
   571     |         |               |            |              |          |                          |
       
   572     |NVS Len  | NVS File      |  Radio Len | Radio File   | FW Len   |  FW File                 |
       
   573     |4 Bytes  | WiLink6_nvs.h | 4 Bytes    | radio_ini.h  | 4 Bytes  |  WiLink6_firmware.h      |
       
   574     |_________|_______________|____________|______________|__________|__________________________|
       
   575 
       
   576     */
       
   577 	
       
   578     #ifdef _SYMBIAN_  
       
   579     	nvsLength = *reinterpret_cast<const TUint32*>(&data[0]); 
       
   580     	radioLength = *reinterpret_cast<const TUint32*>(&data[sizeof(TUint32) + nvsLength]);            
       
   581     	TUint32 fwLength = *reinterpret_cast<const TUint32*>(&data[sizeof(TUint32) + nvsLength + sizeof(TUint32) + radioLength]);
       
   582         
       
   583         /* in case no fw in aData, use wilink6_firmware */
       
   584         if (fwLength == 0 )
       
   585         {
       
   586             WLAN_OS_REPORT(("TIWha::Initialize:: Taking default fw"));	
       
   587             iFwFile.pBuffer = (TI_UINT8*)wilink6_firmware;
       
   588         }
       
   589         else
       
   590         {
       
   591             WLAN_OS_REPORT(("TIWha::Initialize::received fw from LDD, fwLength : %d", fwLength ));  
       
   592             /* Update first FW Pointer to be the one residing in the firmware array from the fw1273_chip.h */            
       
   593             iFwFile.pBuffer = data + 3*sizeof(TUint32) + nvsLength + radioLength;
       
   594         }
       
   595     
       
   596     	/* Retrieve NVS pointer & Lenght */
       
   597         ipNVSbuf = data + sizeof(TUint32);
       
   598         iNVSlength = nvsLength;
       
   599     
       
   600         /* Copy the content of NVS Buffer for saving the MAC Address and Burst Read to be retrieved back when NVS 
       
   601         Array is received back from the FW */
       
   602         os_memoryCopy(iTwdCtrl.tOsContext.hOsa,iNvsStart,ipNVSbuf,24);
       
   603     
       
   604         /* FEM Auto Detection */
       
   605         /* Retrieve Radio pointer  */
       
   606         pRadio =  data + sizeof(TUint32) + nvsLength + sizeof(TUint32);
       
   607     
       
   608         /* save Radio params*/    
       
   609         os_memoryCopy(iTwdCtrl.tOsContext.hOsa,&iAutoRadioParams.tGeneralParams, pRadio, GENERAL_RADIO_PARAM_LEN);    
       
   610         os_memoryCopy(iTwdCtrl.tOsContext.hOsa,&iAutoRadioParams.tStatRadioParams, (TUint8*)(pRadio + STATIC_RADIO_PARAM_OFFSET), STATIC_RADIO_PARAM_LEN);
       
   611         os_memoryCopy(iTwdCtrl.tOsContext.hOsa,&iAutoRadioParams.tDynRadioParams[0], (TUint8*)(pRadio + FEM0_DYNAMIC_RADIO_PARAM_OFFSET), DYNAMIC_RADIO_PARAM_LEN);
       
   612         os_memoryCopy(iTwdCtrl.tOsContext.hOsa,&iAutoRadioParams.tDynRadioParams[1], (TUint8*)(pRadio + FEM1_DYNAMIC_RADIO_PARAM_OFFSET), DYNAMIC_RADIO_PARAM_LEN);
       
   613             
       
   614     #else   /* Other OS */
       
   615 		/* Retrieve FW pointer  */
       
   616 		iFwFile.pBuffer = (TI_UINT8*)wilink6_firmware;
       
   617 
       
   618         /*saving  NVS pointer */
       
   619         ipNVSbuf = (uint8*)aData;
       
   620         /* Set NVS length */
       
   621         iNVSlength = aLength;
       
   622   
       
   623       	/* Copy the content of NVS Buffer frir saving the MACF Address and Burst Read to be retrieved back when NVS 
       
   624         Array is receuved back from the FW */
       
   625         os_memoryCopy(iTwdCtrl.tOsContext.hOsa,iNvsStart,ipNVSbuf,24);
       
   626 
       
   627         /* FEM Auto Detection fill radio params */
       
   628         /*FillRadioData();*/
       
   629 
       
   630     #endif
       
   631     
       
   632     #if TI_DBG
       
   633         WLAN_OS_REPORT(("TIWha::Initialize::nvsLength : %d", nvsLength ));
       
   634         WLAN_OS_REPORT(("TIWha::Initialize::radioLength : %d", radioLength ));  
       
   635     #endif
       
   636    
       
   637     WLAN_OS_REPORT((" in Initialize calling txnQ_ConnectBus "));
       
   638     /* Configure the bus - in WSPI configuration is done internaly */
       
   639     /* This will download the FW image into part with DMA of 512 bytes each time */    
       
   640     BusDrvCfg.tSdioCfg.uBlkSizeShift = SDIO_BLK_SIZE_SHIFT_DEF;
       
   641     status = txnQ_ConnectBus (iTwdCtrl.hTxnQ, &BusDrvCfg,(TTxnDoneCb)TIWhaAdaptCB::ConnectBus,this,NULL,NULL);
       
   642 
       
   643     /* If the bus connect is sync, then we should lose the context and call the CB */
       
   644     if (status == TI_OK) 
       
   645     {        
       
   646         /* Register ConnectDfcClient to handle the connect bus CB from a different context */
       
   647         pConnectDfcClient->pConnectDfc->Enqueue(*pConnectDfcClient ,(TInt)this);        
       
   648     }    
       
   649     #ifdef OMAP3430_CPU_STALL
       
   650 	    /* Add a stall to make sure that CPU is not going idle while initializing */
       
   651         os_StalluSec ((TI_HANDLE)&iTwdCtrl.tOsContext, STALL_ON_CPU );
       
   652     #endif
       
   653     TRACE0(iTwdCtrl.hReport, REPORT_SEVERITY_INIT,  "TIWha::Initialize --");
       
   654 }
       
   655 
       
   656 /** 
       
   657 * \fn     Configure
       
   658 * \brief  Configures the WLAN device after firmware download and basic 
       
   659 *                 chip init has taken place
       
   660 * \note   
       
   661 * Method configures the WLAN device after the WHA layer has send the 
       
   662 * EInitializeResponse event. Only after calling this method, 
       
   663 * WLAN device is ready for use. 
       
   664 * Note: the memory supplied by the command is valid to point the 
       
   665 * corresponding command response event is send
       
   666 *
       
   667 * 
       
   668 * /param aData firmware - data. The content is vendor specific.
       
   669 * /param aWhaSettings - output data that holds the capabilities 
       
   670 * of the WLAN vendor specific solution. 
       
   671 * \return   
       
   672 * \sa  
       
   673 */
       
   674 void TIWha::Configure(  const WHA::SConfigureData&    aData,
       
   675 							WHA::SSettings&               aWhaSettings) 
       
   676 {                                             
       
   677     TFwInfo             *tChipVer;
       
   678     TI_UINT8            *pMac;  
       
   679 
       
   680     TRACE0(iTwdCtrl.hReport, REPORT_SEVERITY_INIT,  "WHA-Configure +");
       
   681 
       
   682     /* Enable interrupts on HPA */
       
   683     ((WlanHpa*)iTwdCtrl.tOsContext.hHpa)->EnableIrq();
       
   684     
       
   685     TWD_EnableInterrupts (iTwdCtrl.hTWD);
       
   686 
       
   687     /* Call the function to fill all the parameters in the NWSA Settings */
       
   688     FillNWSASettings (&aWhaSettings);
       
   689 
       
   690     /* Retrieve FW information from TWD */
       
   691     tChipVer= TWD_GetFWInfo (iTwdCtrl.hTWD);
       
   692     pMac = (TI_UINT8 *)tChipVer->macAddress;
       
   693 
       
   694     /* Update driver's MAC address */
       
   695     MAC_COPY (iTwdCtrl.pMacAddr, tChipVer->macAddress);
       
   696 
       
   697     /*
       
   698      *  Exit from init mode should be before smeSM starts. this enable us to send
       
   699      *  command to the MboxQueue(that store the command) while the interrupts are masked.
       
   700      *  the interrupt would be enable at the end of the init process.
       
   701      */
       
   702     TWD_ExitFromInitMode (iTwdCtrl.hTWD);
       
   703 
       
   704     TRACE0(iTwdCtrl.hReport, REPORT_SEVERITY_INIT, " TIWha::Configure : Before Config HW");
       
   705     if (TWD_ConfigFw (iTwdCtrl.hTWD) != TI_OK)
       
   706     {
       
   707         TRACE0(iTwdCtrl.hReport, REPORT_SEVERITY_ERROR, " TIWha:: TWD_ConfigFw returned error");        
       
   708         ConfigFwCb( WHA::KFailed);
       
   709         return;
       
   710     }
       
   711     
       
   712     TRACE0(iTwdCtrl.hReport, REPORT_SEVERITY_INIT, "EXIT FROM INIT\n");
       
   713 
       
   714     /* Print the driver and firmware version and the mac address */
       
   715     WLAN_OS_REPORT(("\n"));
       
   716     WLAN_OS_REPORT(("--------------------------------------------------------------------\n"));
       
   717     WLAN_OS_REPORT(("Driver Version  : %s\n", SW_VERSION_STR));
       
   718     WLAN_OS_REPORT(("Firmware Version: %s\n", tChipVer->fwVer));
       
   719     WLAN_OS_REPORT(("Station ID      : %02X-%02X-%02X-%02X-%02X-%02X\n",
       
   720     				pMac[0], pMac[1], pMac[2], pMac[3], pMac[4], pMac[5]));
       
   721     WLAN_OS_REPORT(("--------------------------------------------------------------------\n"));
       
   722     WLAN_OS_REPORT(("\n"));
       
   723 
       
   724     TRACE0(iTwdCtrl.hReport, REPORT_SEVERITY_INIT, "WHA-Configure --");
       
   725 }                                             
       
   726 
       
   727 
       
   728 /** 
       
   729 * \fn     Release
       
   730 * \brief  Destroy TWD and utils
       
   731 * \note   
       
   732 *           Any symbian classes (sandbox) will be deleted in the destructor
       
   733 * 
       
   734 * /param aSynchronous - not used
       
   735 * \return KSuccess  
       
   736 * \sa  
       
   737 */
       
   738 WHA::TStatus TIWha::Release( TBool aSynchronous )
       
   739 {
       
   740     TRACE0(iTwdCtrl.hReport, REPORT_SEVERITY_INIT, "\n");
       
   741     
       
   742     /* Power off chip */
       
   743     ((WlanHpa*)iTwdCtrl.tOsContext.hHpa)->PowerOffDevice();
       
   744     
       
   745     /* Delete all modules */
       
   746     DestroyDriver();
       
   747     
       
   748     return WHA::KSuccess;
       
   749 }
       
   750 
       
   751 /**
       
   752 * Note: The WLAN host driver does not issue this command while measure
       
   753 * or 802.11 power management mode transition process is in progress.
       
   754 * This method commands the WLAN device to start scanning in order to 
       
   755 * determine the characteristics of the available BSSs and IBSSs to which 
       
   756 * it may later to elect to join. 
       
   757 * When the WLAN device receives this command, 
       
   758 * it goes into a scanning mode. 
       
   759 * The WHA layer sends the EScanCommandResponse event to inform the 
       
   760 * WLAN host driver that the WLAN vendor specific 
       
   761 * solution has accepted the command. 
       
   762 * For each command there will be both EScanCommandResponse and 
       
   763 * EScanComplete event regardless the fact if the scan did start or not.
       
   764 * If the WLAN device is able to start the scanning process, all beacons
       
   765 * and Probe response frames are sent to the WLAN host driver. 
       
   766 * When the scanning has completed, the WHA layer sends the EScanComplete
       
   767 * event to inform the WLAN host driver that the scan process has 
       
   768 * completed in the WLAN device. 
       
   769 * Note: while this command is in progress it disables the current Rx 
       
   770 * frame filtering settings for the duration of the scan. 
       
   771 * This means that only beacon and probe response frames are forwarded to
       
   772 * the WLAN host driver (unless doing a split scan) in depended of the 
       
   773 * current configuration related to Rx frame handling. 
       
   774 * Note: scanning must be supported by the WLAN vendor specific solution 
       
   775 * both in infrastructure and IBSS mode. 
       
   776 * Although frames can be lost in IBSS mode due to scanning, 
       
   777 * support for it is required.
       
   778 *
       
   779 * 
       
   780 * /param aMaxTransmitRate - specifies the transmission rate of the 
       
   781 * probe request in case of a active scan 
       
   782 * Note: just a single rate is selected not multiple as rate fallback 
       
   783 * is not to be used during the scan process
       
   784 * /param aBand - selects the used frequency band. 
       
   785 * Only 1 band is scanned at a time 
       
   786 * and 1 bit is used to select the band to be scanned
       
   787 * /param aNumOfChannels - number of channels provided in the command
       
   788 * /param aChannels - specifies the scanned channels
       
   789 * /param aScanType - specifies the scan type:
       
   790 * 0 foreground scan
       
   791 * 1 background scan
       
   792 * 2 forced background scan
       
   793 * /param aNumOfProbeRequests - number of probe requests (per SSID)
       
   794 * sent to one (1) channel. 
       
   795 * Zero (0) means that none is send, 
       
   796 * which means that a passive scan is to be done.  
       
   797 * Value greater than zero (0) means that an active scan is to be done
       
   798 * /param aSplitScan - ETrue if a split scan method is to be used. 
       
   799 * EFalse if not
       
   800 * /param aNumOfSSID - number of SSID provided in the scan command 
       
   801 * (this is zero (0) in broadcast scan)
       
   802 * /param aSsid - Array of the SSID to be probed in scan
       
   803 */
       
   804 #ifdef PLT_TESTER
       
   805 TTestCmd tTest;
       
   806 #endif /* PLT_TESTER */
       
   807 void TIWha::Scan(   WHA::TRate                  aMaxTransmitRate, 
       
   808 						WHA::TBand                  aBand,
       
   809 						TUint8                      aNumOfChannels,
       
   810 						const WHA::SChannels*   aChannels, 
       
   811 						WHA::TScanType               aScanType,
       
   812 						TUint8                      aNumOfProbeRequests,
       
   813 						TBool                       aSplitScan,
       
   814 						TUint8                      aNumOfSSID,
       
   815 						const WHA::SSSID*       aSsid)
       
   816 {
       
   817     E80211PsMode             PS_mode;
       
   818     TBool                    bEnterPS;				 /* whether to enter PS */
       
   819     TBool                    bScanOnDriverModeError; /* Forced background option */
       
   820     
       
   821     
       
   822 #ifdef PLT_TESTER
       
   823 //OpenAllReports();
       
   824 WLAN_OS_REPORT(("**************************************\n"));
       
   825 WLAN_OS_REPORT(("PLT_TESTER\n"));
       
   826 WLAN_OS_REPORT(("**************************************\n"));
       
   827 
       
   828 	iRealPlt = 0;
       
   829 
       
   830 	os_printf("************ PLT Test os_printf working ***************\n");
       
   831 	PltSm(NULL);
       
   832 
       
   833 
       
   834 return;
       
   835 #endif /* PLT_TESTER */
       
   836 
       
   837 
       
   838 
       
   839 
       
   840     TRACE4(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "TIWha::Scan: aMaxTransmitRate %d aBand %d aNumOfChannels %d aScanType 0x%x\n",        aMaxTransmitRate, aBand, aNumOfChannels, aScanType);
       
   841 
       
   842     TRACE4(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "TIWha::Scan: aNumOfProbeRequests %d aSplitScan %d aNumOfSSID %d aSsid.Len %d\n",        aNumOfProbeRequests, aSplitScan, aNumOfSSID, aSsid->iSSIDLength);
       
   843 
       
   844     TRACE0(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "[WLANPDD] WHA-Scan +");
       
   845     
       
   846     /* 
       
   847      * Configure Scan type:
       
   848      * (aNumOfProbeRequests > 0) ==> Active scan. (TI_TRUE == aSplitScan) ==> Triggered scan 
       
   849      */ 
       
   850     iTwdCtrl.iScanParams.scanType = 
       
   851     (aNumOfProbeRequests > 0) ? 
       
   852             ((TI_TRUE == aSplitScan) ? SCAN_TYPE_TRIGGERED_ACTIVE : SCAN_TYPE_NORMAL_ACTIVE) :
       
   853             ((TI_TRUE == aSplitScan) ? SCAN_TYPE_TRIGGERED_PASSIVE : SCAN_TYPE_NORMAL_PASSIVE);
       
   854             
       
   855     /* 
       
   856      * On "split scan" defines the access category for which the Fw waits before scanning the next channel
       
   857      * The default value is any AC. Note: ScanSrv configures TimeOut
       
   858      */ 
       
   859     iTwdCtrl.iScanParams.Tid  = AC_ANY_TID;
       
   860 
       
   861     /* Band */
       
   862     iTwdCtrl.iScanParams.band = 
       
   863     (aBand == WHA::KBand2dot4GHzMask) ? RADIO_BAND_2_4_GHZ : RADIO_BAND_5_0_GHZ;
       
   864 
       
   865     /* Probe requests */
       
   866 #ifdef ENHANCE_PROB_SCAN
       
   867     if (aNumOfProbeRequests) {
       
   868         iTwdCtrl.iScanParams.probeReqNumber   = aNumOfProbeRequests * PB_FACTOR_FOR_SG;
       
   869     }
       
   870 #else
       
   871     iTwdCtrl.iScanParams.probeReqNumber   = aNumOfProbeRequests; 
       
   872 #endif
       
   873     iTwdCtrl.iScanParams.probeRequestRate = (ERateMask)TIWhaUtils::WhaToMaskRate (aMaxTransmitRate);
       
   874 
       
   875     /***************** Channels ******************/
       
   876     iTwdCtrl.iScanParams.numOfChannels    = aNumOfChannels;
       
   877                     
       
   878     for (int i = 0; i < aNumOfChannels; i++)
       
   879     {
       
   880     	for (int j = 0; j < MAC_ADDR_LEN; j++ )
       
   881     	{
       
   882     		(iTwdCtrl.iScanParams.channelEntry[i]).normalChannelEntry.bssId[j] = 0xFF;
       
   883     	}
       
   884     	(iTwdCtrl.iScanParams.channelEntry[i]).normalChannelEntry.channel = aChannels[i].iChannel;
       
   885 #ifdef ENHANCE_PROB_SCAN
       
   886         if (aNumOfProbeRequests) {
       
   887             (iTwdCtrl.iScanParams.channelEntry[i]).normalChannelEntry.maxChannelDwellTime = CONVERT_TU_2_MICRO(aChannels[i].iMaxChannelTime * MAX_TIME_FACTOR_FOR_SG);
       
   888             (iTwdCtrl.iScanParams.channelEntry[i]).normalChannelEntry.minChannelDwellTime = CONVERT_TU_2_MICRO(aChannels[i].iMinChannelTime * MIN_TIME_FACTOR_FOR_SG);
       
   889         }
       
   890         else {
       
   891     	(iTwdCtrl.iScanParams.channelEntry[i]).normalChannelEntry.maxChannelDwellTime = CONVERT_TU_2_MICRO(aChannels[i].iMaxChannelTime);
       
   892     	(iTwdCtrl.iScanParams.channelEntry[i]).normalChannelEntry.minChannelDwellTime = CONVERT_TU_2_MICRO(aChannels[i].iMinChannelTime);
       
   893         }
       
   894 #else
       
   895     	(iTwdCtrl.iScanParams.channelEntry[i]).normalChannelEntry.maxChannelDwellTime = CONVERT_TU_2_MICRO(aChannels[i].iMaxChannelTime);
       
   896     	(iTwdCtrl.iScanParams.channelEntry[i]).normalChannelEntry.minChannelDwellTime = CONVERT_TU_2_MICRO(aChannels[i].iMinChannelTime);
       
   897 #endif
       
   898     	(iTwdCtrl.iScanParams.channelEntry[i]).normalChannelEntry.earlyTerminationEvent = SCAN_ET_COND_DISABLE;
       
   899     	(iTwdCtrl.iScanParams.channelEntry[i]).normalChannelEntry.ETMaxNumOfAPframes = 0;
       
   900     	(iTwdCtrl.iScanParams.channelEntry[i]).normalChannelEntry.txPowerDbm = DBM2DBMDIV10(aChannels[i].iTxPowerLevel);
       
   901       }
       
   902 
       
   903     /* Mix the channel to increase scan result and avoid collisions */
       
   904     if (aNumOfChannels > 4) {
       
   905         int Channelscan = 0;
       
   906         int Channel = 0;
       
   907         int k = 0;
       
   908         while (k < aNumOfChannels/2) {
       
   909             (iTwdCtrl.iScanParams.channelEntry[Channel]).normalChannelEntry.channel = aChannels[Channelscan].iChannel;
       
   910             Channel++;
       
   911             Channelscan += aNumOfChannels/2;
       
   912             if (aNumOfChannels - Channelscan <= 0) {
       
   913                 k++;
       
   914                 Channelscan = k;
       
   915             }
       
   916         }
       
   917     }
       
   918 
       
   919     /* Set SSID if present. This replaces the Template Frame configuration */
       
   920     if ( aNumOfSSID )
       
   921     {
       
   922         TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "TIWha::Scan: aSsid.Len %d\n", aSsid->iSSIDLength);
       
   923 
       
   924         iTwdCtrl.iScanParams.desiredSsid.len = aSsid->iSSIDLength;
       
   925         os_memoryCopy ((TI_HANDLE)&iTwdCtrl.tOsContext, 
       
   926                        (void *)iTwdCtrl.iScanParams.desiredSsid.str, 
       
   927                        (void *)aSsid->iSSID, 
       
   928                        aSsid->iSSIDLength);
       
   929     }      
       
   930     else
       
   931     {
       
   932         iTwdCtrl.iScanParams.desiredSsid.len = 0;  
       
   933     }
       
   934 
       
   935     /* PS on scan */
       
   936     switch (aScanType)
       
   937     {
       
   938     case  WHA::EFgScan:
       
   939     	bEnterPS = TI_FALSE;
       
   940     	/* Internal TI mode - means "don't care" for the Power save */
       
   941     	PS_mode = POWER_SAVE_KEEP_CURRENT;
       
   942     	bScanOnDriverModeError = TI_FALSE;
       
   943     	break;
       
   944 
       
   945     case  WHA::EBgScan:
       
   946     	bEnterPS = TI_TRUE;
       
   947     	PS_mode = POWER_SAVE_ON;
       
   948     	bScanOnDriverModeError = TI_FALSE;
       
   949     	break;
       
   950 
       
   951     case  WHA::EForcedBgScan:
       
   952     	bEnterPS = TI_TRUE;
       
   953     	PS_mode = POWER_SAVE_ON;
       
   954     	bScanOnDriverModeError = TI_TRUE;
       
   955     	break;
       
   956 
       
   957     default:
       
   958         TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_ERROR, "TIWha::Scan aScanType 0x%x:\n",aScanType);
       
   959         /* Use some defaults */
       
   960     	bEnterPS = TI_FALSE;
       
   961     	PS_mode = POWER_SAVE_KEEP_CURRENT;
       
   962     	bScanOnDriverModeError = TI_FALSE;
       
   963     }
       
   964 
       
   965 	/* Replace the Receive Packet while Scan to all scan resault sent to
       
   966 	LDD befor scan complete event sent */
       
   967 	TWD_RegisterCb (iTwdCtrl.hTWD,
       
   968 					TWD_EVENT_RX_RECEIVE_PACKET, 
       
   969 					(TTwdCB *)TIWhaAdaptCB::ReceivePacketWhileScan, 
       
   970 					this);
       
   971 	/* Set the Scan result count at the beginning of the scan to large value to continue sending resault
       
   972 	till the scan complete arrive from FW and set the correct scan result */
       
   973 	aScanResultCount = 0xFFFF;
       
   974 	/* Initiate the Sent resault to Zero */
       
   975 	SentScanResult = 0;
       
   976 
       
   977     /* Perform Scan */
       
   978     TI_STATUS status = TWD_Scan (iTwdCtrl.hTWD,
       
   979                                                                     &iTwdCtrl.iScanParams, 
       
   980                                                                     SCAN_RESULT_TAG_APPLICATION_ONE_SHOT, 
       
   981                                                                     TI_FALSE,
       
   982                                                                     bEnterPS,
       
   983                                                                     bScanOnDriverModeError, 
       
   984                                                                     PS_mode,
       
   985                                                                     TI_TRUE, 
       
   986                                                                     (TCmdResponseCb)TIWhaAdaptCB::ScanResponse,
       
   987                                                                     this);
       
   988 
       
   989     if (status != TI_OK)
       
   990     {
       
   991         TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_ERROR, "TIWha::Scan returned status = 0x%x:\n", status);
       
   992     }
       
   993 }
       
   994 
       
   995 /** 
       
   996 * \fn     StopScan
       
   997 * \brief  stop scan 
       
   998 * \note   
       
   999 *           Any symbian classes (sandbox) will be deleted in the destructor
       
  1000 * 
       
  1001 * /param aSynchronous - not used
       
  1002 * \return KSuccess  
       
  1003 * \sa  
       
  1004 */
       
  1005 void TIWha::StopScan()
       
  1006 {    
       
  1007     TI_STATUS    status;
       
  1008 
       
  1009     status = TWD_StopScan (iTwdCtrl.hTWD,
       
  1010                                                     SCAN_RESULT_TAG_APPLICATION_ONE_SHOT,
       
  1011                                                     TI_FALSE,
       
  1012                                                     (TCmdResponseCb)TIWhaAdaptCB::StopScanResponse,
       
  1013                                                     this);
       
  1014 
       
  1015     if (status != TI_OK)
       
  1016     {
       
  1017         ASSERT_ERR (iTwdCtrl.hReport, "Stop scan failure, status=%d\n", status)
       
  1018     }
       
  1019 }
       
  1020 
       
  1021 /** 
       
  1022 * \fn     Join
       
  1023 * \brief  Join a BSS/IBSS
       
  1024 *          
       
  1025 * \note   
       
  1026 * \return   
       
  1027 * \sa     
       
  1028 */ 
       
  1029 void TIWha::Join(
       
  1030 					WHA::TOperationMode aMode,
       
  1031 					const WHA::TMacAddress& aBSSID,
       
  1032 					const WHA::SSSID& aSSID, 
       
  1033 					WHA::TBand aBand,
       
  1034 					WHA::TChannelNumber aChannel,
       
  1035 					TUint32 aBeaconInterval,
       
  1036 					WHA::TRate aBasicRateSet,
       
  1037 					TUint16 aAtimWindow,
       
  1038 					WHA::TPreamble aPreambleType,
       
  1039 					TBool aProbeForJoin )
       
  1040 {    
       
  1041     TJoinBss         joinBssParams;
       
  1042     TI_STATUS        status;
       
  1043 
       
  1044 #ifdef HT_SUPPORT
       
  1045 	/* Svae the join MAC address for BA use */
       
  1046 	os_memoryCopy(&iTwdCtrl.tOsContext,iJoinedMacAddress,(void*)(aBSSID.iMacAddress),aBSSID.KMacAddressLength);
       
  1047     /* If re-join remove first all BA sessions */
       
  1048     if (bJoined) {
       
  1049         TWD_CloseAllBaSessions(iTwdCtrl.hTWD);
       
  1050     }
       
  1051 #endif /* HT_SUPPORT */
       
  1052 
       
  1053     WLAN_OS_REPORT(("TWD_JoinBss : bssType = %d beaconInterval = %d channel = %d\n",aMode, (TUint16)aBeaconInterval, aChannel));
       
  1054     WLAN_OS_REPORT(("BSSID = %x-%x-%x-%x-%x-%x\n",aBSSID.iMacAddress[0],aBSSID.iMacAddress[1],aBSSID.iMacAddress[2],aBSSID.iMacAddress[3],aBSSID.iMacAddress[4],aBSSID.iMacAddress[5]));
       
  1055         
       
  1056     /* If we are in PS mode, wake up from ELP and exit 802.11 PS mode */ 
       
  1057     if ( TWD_GetPsStatus (iTwdCtrl.hTWD) )
       
  1058     {
       
  1059         /* Configure H/W to awake */ 
       
  1060         SleepMode (WHA::KAwakeMode, TI_FALSE);
       
  1061 
       
  1062         /* Exit 802.11 PS mode with dummy callbacks */
       
  1063         TWD_SetPsMode (iTwdCtrl.hTWD, 
       
  1064                                         POWER_SAVE_OFF, 
       
  1065                                         TI_FALSE, 
       
  1066                                         this, 
       
  1067                                         (TPowerSaveCompleteCb)TIWhaAdaptCB::SetPsModeCompleteDummy, 
       
  1068                                         (TPowerSaveResponseCb)TIWhaAdaptCB::SetPsModeResponseDummy);
       
  1069     }
       
  1070          
       
  1071     /*
       
  1072      * Save BSS info parameters
       
  1073      */
       
  1074     joinBssParams.bssType = (ScanBssType_e)aMode;
       
  1075     /* Save bss type for tx packets */
       
  1076     iTwdCtrl.bssType = aMode;
       
  1077     joinBssParams.pBSSID = (TUint8 *)aBSSID.iMacAddress;
       
  1078     joinBssParams.pSSID = (TUint8 *)aSSID.iSSID;
       
  1079     joinBssParams.ssidLength = aSSID.iSSIDLength;
       
  1080     joinBssParams.beaconInterval = aBeaconInterval;
       
  1081     joinBssParams.channel = aChannel;
       
  1082 #ifndef HT_SUPPORT
       
  1083     joinBssParams.basicRateSet = TIWhaUtils::WhaToMaskRate (aBasicRateSet);
       
  1084 #else
       
  1085 	joinBssParams.basicRateSet = TIWhaUtils::HTWhaToMaskRate(aBasicRateSet,iMcsRates);
       
  1086 #endif /* HT_SUPPORT */
       
  1087 	
       
  1088     joinBssParams.txSessionCount = 0; /* currently not used - we always use session '0' */
       
  1089     /*
       
  1090      * ATIM window of IBSS
       
  1091      * Note that when ATIM window is zero the
       
  1092      * initiated IBSS does not support power-save   
       
  1093      * Note that PS on IBSS is not supported.
       
  1094      */
       
  1095         
       
  1096     /*
       
  1097      * DTIM - Temporary value till the Fw will find the right value from the first beacon 
       
  1098      */
       
  1099      joinBssParams.dtimInterval = TIWha_DEFAULT_DTIM_PERIOD;
       
  1100 
       
  1101     /* 
       
  1102      * Band value is determined out of the channel
       
  1103      */
       
  1104     if (aBand == WHA::KBand2dot4GHzMask)
       
  1105     {
       
  1106         joinBssParams.radioBand = RADIO_BAND_2_4_GHZ;
       
  1107     }   
       
  1108     else if (aBand == WHA::KBand5GHzMask)
       
  1109     {
       
  1110         joinBssParams.radioBand = RADIO_BAND_5_0_GHZ;
       
  1111     }   
       
  1112     else
       
  1113     {
       
  1114         ASSERT_ERR (iTwdCtrl.hReport, "Invalid band=%d\n", aBand)
       
  1115     }
       
  1116             
       
  1117    
       
  1118     /* Set preamble MIB. The generic command response will be stopped in TIWhaAdaptCB::CommandResponse */
       
  1119     if (aPreambleType == WHA::ELongPreamble)
       
  1120     {
       
  1121         TWD_CfgPreamble (iTwdCtrl.hTWD, PREAMBLE_LONG  );
       
  1122     }
       
  1123     else
       
  1124     {
       
  1125         TWD_CfgPreamble (iTwdCtrl.hTWD, PREAMBLE_SHORT  );
       
  1126     }
       
  1127 
       
  1128      
       
  1129 	/* 
       
  1130 	 * Reset both group and pairwise keys to WEP in order to avoid 
       
  1131 	 * a scenario which only group or pairwise are actually configured in WEP
       
  1132 	 */
       
  1133 	iTwdCtrl.ePairwiseKeyMode = TWD_CIPHER_WEP;
       
  1134 	iTwdCtrl.eGroupKeyMode	= TWD_CIPHER_WEP;
       
  1135 
       
  1136     /*
       
  1137      * Set new Tx fail low threshold so that FW fall back will start faster
       
  1138      * The reason is that at first we start in 54Mbps and we need to drop faster if the AP is far away.
       
  1139      * This will change after few seconds with the hConnectionTimer
       
  1140      */
       
  1141     SetTxFailLowThreshold (TIWHA_TX_FAIL_LOW_TH_FOR_CONNECTION);
       
  1142     if (bConnectionTimerRunning)
       
  1143     {
       
  1144         /* Other join started and ended soon, so just stop the timer before setting it again */
       
  1145         os_timerStop(&iTwdCtrl.tOsContext, hConnectionTimer);
       
  1146     }
       
  1147     bConnectionTimerRunning = TI_TRUE;
       
  1148     os_timerStart (&iTwdCtrl.tOsContext, hConnectionTimer, uConnectionApproxTimeMs);
       
  1149 
       
  1150     
       
  1151     status = TWD_CmdJoinBss (iTwdCtrl.hTWD, &joinBssParams);
       
  1152 
       
  1153     if (status != TI_OK)
       
  1154     {
       
  1155         ASSERT_ERR (iTwdCtrl.hReport, "Start join failure, status=%d\n", status)
       
  1156     }
       
  1157 
       
  1158     /* set the join flag to true */
       
  1159     bJoined = 1;
       
  1160 
       
  1161     #ifdef HT_SUPPORT	
       
  1162 	    /* Reset the BA Vectors */
       
  1163 	    iTxBlockAckUsageLast = 0;
       
  1164         iRxBlockAckUsageLast = 0;
       
  1165     #endif
       
  1166 }
       
  1167 
       
  1168 /** 
       
  1169 * \fn     SetPsMode
       
  1170 * \brief  SetPsMode 
       
  1171 *          
       
  1172 * \note   
       
  1173 * \return   
       
  1174 * \sa     
       
  1175 */ 
       
  1176 void TIWha::SetPsMode( WHA::TPsMode aPsMode )
       
  1177 {    
       
  1178     TRACE0(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "\n");
       
  1179     TI_STATUS   status;
       
  1180     E80211PsMode ePsMode; /* TWD parameter for power save on/off */
       
  1181     
       
  1182     if (aPsMode == WHA::KPsDisable)
       
  1183     {
       
  1184         ePsMode = POWER_SAVE_OFF;
       
  1185 
       
  1186         /* Configure H/W to awake, don't wait for a response */ 
       
  1187         SleepMode (WHA::KAwakeMode, FALSE);
       
  1188     }
       
  1189     else
       
  1190     {
       
  1191         ePsMode = POWER_SAVE_ON;
       
  1192     }
       
  1193 
       
  1194     /* Set 802.11 PS mode */
       
  1195     status = TWD_SetPsMode (iTwdCtrl.hTWD,
       
  1196                                             ePsMode,
       
  1197                                             TI_TRUE,
       
  1198                                             this,
       
  1199                                             (TPowerSaveCompleteCb)TIWhaAdaptCB::SetPsModeComplete,
       
  1200                                             (TPowerSaveResponseCb)TIWhaAdaptCB::SetPsModeResponse);
       
  1201 
       
  1202     /* Convert status */
       
  1203     switch (status)
       
  1204     {
       
  1205         case TI_OK:
       
  1206         case POWER_SAVE_802_11_PENDING:
       
  1207             TRACE2(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION,  ": aPsMode 0x%x, status = %d (OK or PENDING)\n", aPsMode, status);
       
  1208         break;
       
  1209         
       
  1210         case POWER_SAVE_802_11_SUCCESS:
       
  1211         case POWER_SAVE_802_11_IS_CURRENT:
       
  1212             TRACE2(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, ": aPsMode 0x%x, status = %d (IS_CURRENT || SUCCESS)\n", aPsMode, status);
       
  1213             
       
  1214         /* This case will never return a response, that's why we don't 'break' this case */ 
       
  1215 
       
  1216         default:
       
  1217             ASSERT_ERR (iTwdCtrl.hReport, "Set PS mode failure, mode=%d", aPsMode)
       
  1218     }
       
  1219 }
       
  1220 
       
  1221 /** 
       
  1222 * \fn     SetBssParameters
       
  1223 * \brief  Set AID 
       
  1224 *          
       
  1225 * \note   
       
  1226 * \return   
       
  1227 * \sa     
       
  1228 */ 
       
  1229 void TIWha::SetBssParameters(
       
  1230 								TUint8 aDTIM, 
       
  1231 								TUint16 aAID )
       
  1232 {    
       
  1233     TRACE0(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "\n");
       
  1234     
       
  1235     TTwdParamInfo    tTwdParam;
       
  1236     TI_STATUS        status;
       
  1237 
       
  1238     /* Set AID */
       
  1239     tTwdParam.paramType = TWD_AID_PARAM_ID;
       
  1240     tTwdParam.content.halCtrlAid  = aAID;
       
  1241     status = TWD_SetParam (iTwdCtrl.hTWD, &tTwdParam);
       
  1242 
       
  1243     /* DTIM is calculated in the Fw now, this is a change from WiLink 4.0.4 */
       
  1244     
       
  1245     if (status != TI_OK) 
       
  1246     {
       
  1247         ASSERT_ERR (iTwdCtrl.hReport, "Set BSS parameters failure, status=%d\n", status)
       
  1248     }
       
  1249 
       
  1250     /* Send Station connect Signaling to FW for COEX and 11N purpose */
       
  1251     TWD_CmdSetStaState(iTwdCtrl.hTWD,1,NULL,NULL);
       
  1252 
       
  1253 }
       
  1254 
       
  1255 /** 
       
  1256 * \fn     Measure
       
  1257 * \brief  Not supported in Symbian
       
  1258 *          
       
  1259 * \note   
       
  1260 * \return   
       
  1261 * \sa     
       
  1262 */ 
       
  1263 void TIWha::Measure(
       
  1264 					   WHA::TPowerLevel aTxPowerLevel,
       
  1265 					   WHA::TBand aBand,
       
  1266 					   WHA::TChannelNumber aChannel,
       
  1267 					   TUint8 aActivationDelay,
       
  1268 					   TUint8 aMeasurementOffset,
       
  1269 					   TUint8 aNumberOfMeasurementTypes,
       
  1270 					   const WHA::SParameterSet* aParameterSet )
       
  1271 {    
       
  1272         ASSERT_ERR (iTwdCtrl.hReport, "%s not supported\n", __FUNCTION__)
       
  1273 }
       
  1274 
       
  1275 /** 
       
  1276 * \fn     StopMeasure
       
  1277 * \brief  Not supported in Symbian
       
  1278 *          
       
  1279 * \note   
       
  1280 * \return   
       
  1281 * \sa     
       
  1282 */ 
       
  1283 void TIWha::StopMeasure()
       
  1284 {    
       
  1285         ASSERT_ERR (iTwdCtrl.hReport, "%s not supported\n", __FUNCTION__)
       
  1286 }
       
  1287 
       
  1288 /** 
       
  1289 * \fn     ReadMib
       
  1290 * \brief  ReadMib
       
  1291 *  
       
  1292 * 
       
  1293 * \note   
       
  1294 * \param aMib - ENUM according to wha_types.h in LDD  
       
  1295 * \return   
       
  1296 * \sa     
       
  1297 */ 
       
  1298 void TIWha::ReadMib( WHA::TMib aMib ) 
       
  1299 {
       
  1300     void       *pCb    = (void*)iTwdCtrl.readMIBBuf;
       
  1301     TMib  *pMibBuf   = (TMib *)pCb;
       
  1302     WHA::TMib        prevMib;
       
  1303     TI_STATUS   status = TI_OK;
       
  1304 
       
  1305     TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "ReadMIB: aMib %x:\n",aMib);
       
  1306 
       
  1307     prevMib = iTwdCtrl.currentReadMibID;
       
  1308     iTwdCtrl.currentReadMibID = aMib;
       
  1309    
       
  1310     switch (aMib)
       
  1311     {
       
  1312     case WHA::KMibDot11StationId:
       
  1313         /* 
       
  1314          * open a timer since we can't send read mib results in one context
       
  1315          */
       
  1316         os_timerStart(&iTwdCtrl.tOsContext,readDot11StationIdMibTmr,0);
       
  1317        
       
  1318         return;
       
  1319         
       
  1320     case WHA::KMibStatisticsTable:
       
  1321         /* 
       
  1322          * Retrieve required information from the device 
       
  1323          */
       
  1324         pMibBuf->aMib = MIB_statisticsTable;
       
  1325 
       
  1326         status = TWD_ReadMib (iTwdCtrl.hTWD, 
       
  1327                               this, 
       
  1328                               (void *)TIWhaAdaptCB::ReadMIBResponse, 
       
  1329                               pCb); 
       
  1330         break; 
       
  1331 
       
  1332     case WHA::KMibCountersTable:
       
  1333         /* 
       
  1334          * Retrieve required information from the device.
       
  1335          */
       
  1336         pMibBuf->aMib = MIB_countersTable;
       
  1337         status = TWD_ReadMib (iTwdCtrl.hTWD, 
       
  1338                               this, 
       
  1339                               (void *)TIWhaAdaptCB::ReadMIBResponse, 
       
  1340                               pCb);
       
  1341         break;
       
  1342         
       
  1343 #if 0 /* Used for debug in WiLink 4.0.4 */ 
       
  1344     case EMIBBtCoexistenceProfile:
       
  1345         /* 
       
  1346          * DEBUG ONLY:
       
  1347          */
       
  1348         paramInfo.paramType = TWD_SG_CONFIG_PARAM_ID;
       
  1349         paramInfo.content.interogateCmdCBParams.pCb = (TI_UINT8*)pCb;
       
  1350         paramInfo.content.interogateCmdCBParams.hCb = (TI_HANDLE)this;
       
  1351        paramInfo.content.interogateCmdCBParams.fCb = (void *)TIWhaAdaptCB::ReadMIBResponse;
       
  1352          
       
  1353         status = TWD_GetParam (iTwdCtrl.hTWD, &paramInfo);
       
  1354         break;
       
  1355 
       
  1356     case EMIBVersion:
       
  1357         /* 
       
  1358          * Retrieve firmware revision 
       
  1359          */
       
  1360         paramInfo.paramType = TWD_REVISION_PARAM_ID;
       
  1361         paramInfo.content.interogateCmdCBParams.pCb = (TI_UINT8*)pCb;
       
  1362         paramInfo.content.interogateCmdCBParams.hCb = (TI_HANDLE)this;
       
  1363         paramInfo.content.interogateCmdCBParams.fCb = (void *)TIWhaAdaptCB::ReadMIBResponse;
       
  1364          
       
  1365         status = TWD_GetParam (iTwdCtrl.hTWD, &paramInfo);
       
  1366         break;
       
  1367 #endif
       
  1368 
       
  1369     default:
       
  1370         iTwdCtrl.currentReadMibID = prevMib;
       
  1371         TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_ERROR, ": aMib %x: Not supported\n",aMib);
       
  1372     }
       
  1373 
       
  1374     if (status != TI_OK) 
       
  1375     {
       
  1376         TRACE2(iTwdCtrl.hReport, REPORT_SEVERITY_ERROR, ": aMib %x: status = %d\n",aMib,status);
       
  1377     }
       
  1378 }        
       
  1379 
       
  1380 /** 
       
  1381 * \fn     WriteMib
       
  1382 * \brief  WriteMib
       
  1383 *  
       
  1384 * 
       
  1385 * \note   
       
  1386 * \param aMib - ENUM according to wha_types.h in LDD  
       
  1387 * \param aLength - size of aData
       
  1388 * \param aData - pointer to general data  
       
  1389 * \param aMore - not used 
       
  1390 * \return   
       
  1391 * \sa     
       
  1392 */ 
       
  1393 WHA::TStatus TIWha::WriteMib(
       
  1394 								WHA::TMib aMib,
       
  1395 								TUint16 aLength,
       
  1396 								const void* aData,
       
  1397 								TBool aMore  )
       
  1398 {    
       
  1399     TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, " Mib = 0x%x\n",aMib);
       
  1400 
       
  1401     TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "WriteMIB - aMib = %d, aData\n", aMib);
       
  1402     
       
  1403     switch (aMib)
       
  1404     {    
       
  1405     case WHA::KMibDot11MaxReceiveLifetime:
       
  1406         /* 
       
  1407          * Converts the WriteMIB back to the correlated TWD command 
       
  1408          * and activate the TWD set command
       
  1409          */     
       
  1410         ASSERT_MIB (iTwdCtrl.hReport, aMib,
       
  1411                                 Dot11MaxReceiveLifeTime (aData))
       
  1412         break;
       
  1413         
       
  1414     case WHA::KMibDot11SlotTime:
       
  1415         /* 
       
  1416          * Converts the WriteMIB back to the correlated whal command 
       
  1417          * and activate the WHAL Set command
       
  1418          */
       
  1419         ASSERT_MIB (iTwdCtrl.hReport, aMib,
       
  1420                                 SetSlotTime (aData))
       
  1421         break;
       
  1422         
       
  1423     case WHA::KMibDot11GroupAddressesTable:
       
  1424         /* 
       
  1425          * Converts the WriteMIB back to the correlated TWD command 
       
  1426          * and activate the TWD Set command
       
  1427          */
       
  1428         ASSERT_MIB (iTwdCtrl.hReport, aMib,
       
  1429             SetDot11GroupAddrTable (aData))
       
  1430             
       
  1431         break;
       
  1432 
       
  1433     case WHA::KMibDot11WepDefaultKeyId:
       
  1434         /* 
       
  1435          * Set the default Key Id
       
  1436          */
       
  1437  
       
  1438         /*
       
  1439          * NOTE: Setting default key will cause the securityMode to change into WEP
       
  1440          */
       
  1441         ASSERT_MIB(iTwdCtrl.hReport, aMib,
       
  1442             SetDefaultKeyID (aData))
       
  1443         break;
       
  1444         
       
  1445     case WHA::KMibDot11CurrentTxPowerLevel:
       
  1446         
       
  1447         /*
       
  1448          * NOTE: no assert here. This function may return:
       
  1449          *       KSuccess - if the same value is already configured
       
  1450          *       KPending - if operation has succeeded
       
  1451          *       KFailed - UnKnown error
       
  1452          */
       
  1453         return SetCurrentTxPowerLevel ( aData);
       
  1454 
       
  1455     case WHA::KMibDot11RTSThreshold:
       
  1456         /* 
       
  1457          * Converts the WriteMIB back to the correlated TWD command 
       
  1458          * and activate the TWD Set command
       
  1459          */
       
  1460         ASSERT_MIB (iTwdCtrl.hReport, aMib,
       
  1461             Dot11RTSThreshold (aData))
       
  1462         break;
       
  1463 
       
  1464     case WHA::KMibCtsToSelf:
       
  1465         /* 
       
  1466          * Converts the WriteMIB back to the correlated TWD command 
       
  1467          * and activate the TWD Set command
       
  1468          */     
       
  1469         ASSERT_MIB (iTwdCtrl.hReport, aMib,
       
  1470             CtsToSelf (aData))
       
  1471         break;
       
  1472 
       
  1473     case WHA::KMibArpIpAddressTable:
       
  1474         /* 
       
  1475          * Converts the WriteMIB back to the correlated TWD command 
       
  1476          * and activate the TWD Set command
       
  1477          */
       
  1478         ASSERT_MIB (iTwdCtrl.hReport, aMib,
       
  1479             SetArpIpAddrTable (aData))
       
  1480         break;
       
  1481 
       
  1482     case WHA::KMibTemplateFrame:
       
  1483         /* 
       
  1484          * Converts the WriteMIB back to the correlated TWD command 
       
  1485          * and activate the TWD Set command
       
  1486          */
       
  1487         ASSERT_MIB (iTwdCtrl.hReport, aMib,
       
  1488                                 SetTemplateFrame (aData))
       
  1489         break;
       
  1490 
       
  1491     case WHA::KMibRxFilter:
       
  1492         /* 
       
  1493          * Converts the WriteMIB back to the correlated TWD command 
       
  1494          * and activate the TWD Set command
       
  1495          */
       
  1496         ASSERT_MIB (iTwdCtrl.hReport, aMib,
       
  1497                                 SetRxFilter (aData)) 
       
  1498         break;
       
  1499 
       
  1500     case WHA::KMibBeaconFilterIeTable:
       
  1501         /*      
       
  1502          * Converts the beacon filter IE table configuration 
       
  1503          * to TWD parameters and sets specific configuration
       
  1504          */
       
  1505         ASSERT_MIB (iTwdCtrl.hReport, aMib,
       
  1506             SetBeaconFilterIETable (aData))
       
  1507         break;
       
  1508 
       
  1509     case WHA::KMibBeaconFilterEnable:
       
  1510         /*      
       
  1511          * Converts beacon filtering configuration 
       
  1512          * to TWD parameters and sets specific configuration 
       
  1513          */
       
  1514         ASSERT_MIB (iTwdCtrl.hReport, aMib,
       
  1515             SetBeaconFilterEnable ( aData))
       
  1516         break;
       
  1517 
       
  1518     case WHA::KMibSleepMode:
       
  1519         /* 
       
  1520          * Set user sleep mode
       
  1521          */     
       
  1522         iTwdCtrl.sleepMode = *(WHA::TSleepMode *)aData;
       
  1523 
       
  1524         /* If we are in 802.11 PS mode then we should enter new sleepMode (otherwise we just save it) */
       
  1525         if (TWD_GetPsStatus (iTwdCtrl.hTWD))
       
  1526         {
       
  1527             /*
       
  1528              * NOTE: no assert here. This function may return:
       
  1529              *       KSuccess - if the same value is already configured
       
  1530              *       KPending - if operation has succeeded
       
  1531              */
       
  1532             return SleepMode ( iTwdCtrl.sleepMode, TI_TRUE);
       
  1533         }
       
  1534 
       
  1535         else
       
  1536         {
       
  1537             return WHA::KSuccess;
       
  1538         }
       
  1539                 
       
  1540     case WHA::KMibWlanWakeUpInterval:
       
  1541         /* 
       
  1542          * Converts the WriteMIB back to the correlated TWD command 
       
  1543          * and activate the TWD Set command
       
  1544          */     
       
  1545         ASSERT_MIB (iTwdCtrl.hReport, aMib,
       
  1546             WakeUpConditions ( aData))
       
  1547                                              
       
  1548         break;
       
  1549         
       
  1550     case WHA::KMibBeaconLostCount:
       
  1551         /* 
       
  1552          * Configure the amount of consecutive beacons that can be lost 
       
  1553          * before the WLAN device should report BSSLost indication to the 
       
  1554          * WLAN host driver.
       
  1555          */
       
  1556         ASSERT_MIB (iTwdCtrl.hReport, aMib,
       
  1557             SetBeaconLostCount (aData))
       
  1558         break;
       
  1559 
       
  1560     case WHA::KMibRcpiThreshold:
       
  1561         /*  
       
  1562          * Configure the threshold value for RCPI indication to the WLAN  
       
  1563          * host driver. RcpiIndication event is triggered when the RCPI goes 
       
  1564          * below or over the threshold.
       
  1565          */
       
  1566         ASSERT_MIB (iTwdCtrl.hReport, aMib,
       
  1567             SetRcpiThreshold (aData))
       
  1568         break;
       
  1569        
       
  1570             
       
  1571     case WHA::KMibTxRatePolicy:
       
  1572         /* 
       
  1573          * Converts the WriteMIB back to the correlated TWD command 
       
  1574          * and activate the TWD Set command
       
  1575          */
       
  1576         ASSERT_MIB (iTwdCtrl.hReport, aMib,
       
  1577             TxRatePolicy ( aLength, aData))
       
  1578         break;
       
  1579         
       
  1580 /*  SG Mibs should be integrated to Symbian */
       
  1581 	case 0x110F: /* Should be KMibbtCoexistenceMode */
       
  1582 
       
  1583         /* Call the TWD with the specific mode of Bt */
       
  1584         ASSERT_MIB (iTwdCtrl.hReport, aMib,
       
  1585             btCoexistenceMode ( aLength, aData))
       
  1586         break;
       
  1587         
       
  1588 	case 0x1110: /* should be KMibbtCoexistenceProfile */
       
  1589 
       
  1590         /* Call the TWD with the parameters of Bt */
       
  1591         ASSERT_MIB (iTwdCtrl.hReport, aMib,
       
  1592             btCoexistenceProfile ( aLength, aData))
       
  1593         break;
       
  1594 
       
  1595 #ifdef HT_SUPPORT
       
  1596 		case WHA::KMibHtCapabilities:
       
  1597 			/* send the HT Capabilties to FW */
       
  1598             SetHTCapabilities ((WHA::ShtCapabilities*)aData);
       
  1599 			break;
       
  1600 
       
  1601 		case WHA::KMibHtBssOperation:
       
  1602 			/* send the HT Information to FW */
       
  1603             SetHTInformation ((WHA::ShtBssOperation*)aData);
       
  1604 			break;
       
  1605 
       
  1606 		case WHA::KMibHtBlockAckConfigure:
       
  1607 			/* BA Initiator and Receiver to FW */
       
  1608             if (ConfigureBA ((WHA::ShtBlockAckConfigure*)aData) == TI_NOK)
       
  1609 			{
       
  1610 				/* Return success for not stuck the LDD */
       
  1611 				/* This value return when ConfigureBA do nothing */
       
  1612 			     return WHA::KSuccess; 
       
  1613 			}
       
  1614 			break;		
       
  1615 #endif /* HT_SUPPORT */
       
  1616 
       
  1617         case WHA::KMibTxAutoRatePolicy:
       
  1618 			/* Set the supported rates */
       
  1619 			TxAutoRatePolicy((WHA::StxAutoRatePolicy*)aData);
       
  1620 			break;
       
  1621 
       
  1622 
       
  1623 	#ifdef TI_TEST
       
  1624 		case EMIBPltTest:
       
  1625 
       
  1626 		    #ifdef PLT_TESTER
       
  1627 			    iRealPlt = 1;
       
  1628 		    #endif
       
  1629             os_printf("EMIBPltTest");
       
  1630 			PltTester(aData);
       
  1631 			break;
       
  1632 
       
  1633         /*  FW statistics */ 
       
  1634         case TWD_FW_PRINT_STATISTICS:
       
  1635         	TWD_ItrStatistics (iTwdCtrl.hTWD, (void*)TIWhaAdaptCB::StatisticsReadResponse, this, &(((TTwd *)(iTwdCtrl.hTWD))->acxStatistic));           
       
  1636             break;
       
  1637 
       
  1638         /*  Get AVR RSSI */ 
       
  1639         case AVR_RSSI:
       
  1640             TWD_ItrRSSI (iTwdCtrl.hTWD, (void*)TIWhaAdaptCB::AvrRssiReadResponse, this, &roamingStatistics);           
       
  1641             break;    
       
  1642         
       
  1643     	case QOS_CHANGE_QEUEU: /* change output Queue */ 
       
  1644             ChangeQueue(aData);
       
  1645     		break;    
       
  1646     
       
  1647     	case SET_POWER_LEVEL: // KMibDot11PowerSavePowerLevel
       
  1648     		SetPowerSavePowerLevel((void *)aData);
       
  1649 	#endif /* TI_TEST */
       
  1650 
       
  1651     default:
       
  1652         TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_ERROR, ": aMib %x: Not supported\n",aMib);
       
  1653         return WHA::KSuccess; 
       
  1654 
       
  1655     } /* End switch */
       
  1656 
       
  1657     /* Indicate that the WriteMIB will return a Response in a different context */
       
  1658     return WHA::KPending; 
       
  1659 }
       
  1660 
       
  1661 
       
  1662 /** 
       
  1663 * \fn     SetSlotTime
       
  1664 * 
       
  1665 * \param aData - TSlotTime
       
  1666 * \return KSuccess or KFailed  
       
  1667 * \sa     
       
  1668 */ 
       
  1669 WHA::TStatus TIWha::SetSlotTime (const void *aData) 
       
  1670 {
       
  1671     ESlotTime      slot  = PHY_SLOT_TIME_LONG;
       
  1672 
       
  1673     TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "WRITE_MIB,TIWha::, slot time = 0x%x\n", *((WHA::TSlotTime *)aData));
       
  1674 
       
  1675     switch (*((WHA::TSlotTime *)aData))
       
  1676     {   
       
  1677         case WHA::KSlotTime9:
       
  1678             slot = PHY_SLOT_TIME_SHORT;
       
  1679             break;
       
  1680         case WHA::KSlotTime20:
       
  1681             slot = PHY_SLOT_TIME_LONG;
       
  1682             break;
       
  1683         default:
       
  1684             TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_ERROR, "TIWha:: recieving slot time = %d !!!\n",*((WHA::TSlotTime *)aData));
       
  1685     }
       
  1686 
       
  1687     return (TWD_CfgSlotTime (iTwdCtrl.hTWD, slot) == TI_OK) ? WHA::KSuccess : WHA::KFailed;
       
  1688 }
       
  1689 
       
  1690 /** 
       
  1691 * \fn     Dot11MaxReceiveLifeTime
       
  1692 * 
       
  1693 * \param aData - TUint32*
       
  1694 * \return KSuccess or KFailed  
       
  1695 * \sa     
       
  1696 */ 
       
  1697 WHA::TStatus TIWha::Dot11MaxReceiveLifeTime (const void *aData) 
       
  1698 {
       
  1699     TMib  Mib;
       
  1700 
       
  1701     TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "TIWha::Dot11MaxReceiveLifeTime *aData= 0x%x\n",         *(TUint32 *)(aData));
       
  1702 
       
  1703     Mib.aMib = MIB_dot11MaxReceiveLifetime;
       
  1704     Mib.aData.MaxReceiveLifeTime = *(TUint32 *)(aData);
       
  1705 
       
  1706     return (TWD_WriteMib (iTwdCtrl.hTWD, &Mib) == TI_OK) ? WHA::KSuccess : WHA::KFailed;
       
  1707 }
       
  1708 
       
  1709 /** 
       
  1710 * \fn     SetRxFilter
       
  1711 *  
       
  1712 * 
       
  1713 * \note   - Always filter BSSID
       
  1714 * \param aData - not used
       
  1715 * \return   
       
  1716 * \sa     
       
  1717 */ 
       
  1718 WHA::TStatus TIWha::SetRxFilter (const void *aData)
       
  1719 {
       
  1720     TMib Mib;
       
  1721     
       
  1722     TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "SetRxFilter,*aData= 0x%x\n",*(TUint8 *)aData);
       
  1723 
       
  1724     Mib.aMib = MIB_rxFilter;
       
  1725     /* 
       
  1726      * Note that we ignore the requested configuration, since any other configuration is 
       
  1727      * causing a crash in the LDD. This is agreed with Palau
       
  1728      */
       
  1729     Mib.aData.RxFilter = MIB_RX_FILTER_BSSID_SET;
       
  1730     
       
  1731     return (TWD_WriteMib (iTwdCtrl.hTWD, &Mib) == TI_OK) ? WHA::KSuccess : WHA::KFailed;
       
  1732 }
       
  1733 
       
  1734 /** 
       
  1735 * \fn     SetCurrentTxPowerLevel
       
  1736 *  
       
  1737 * 
       
  1738 * \note   - 
       
  1739 * \param aData -TPowerLevel (Power level in dbm)
       
  1740 * \return   
       
  1741 *           KSuccess - if the same value is already configured
       
  1742 *           KPending - if operation has succeeded
       
  1743 *           KFailed - UnKnown error
       
  1744 * \sa     
       
  1745 */ 
       
  1746 WHA::TStatus TIWha::SetCurrentTxPowerLevel (const void *aData)
       
  1747 {
       
  1748     TTwdParamInfo    param;
       
  1749 
       
  1750     /* Activates the TWD_SetParam function */
       
  1751     param.paramType = TWD_TX_POWER_PARAM_ID;
       
  1752     param.content.halCtrlTxPowerDbm = DBM2DBMDIV10((*((WHA::TPowerLevel *) aData)));
       
  1753     
       
  1754     TRACE2(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "SetCurrentTxPowerLevel, Dbm = %d Power DBm*10 = %d \n",        *((WHA::TPowerLevel *) aData), param.content.halCtrlTxPowerDbm);
       
  1755 
       
  1756     TI_STATUS status = TWD_SetParam (iTwdCtrl.hTWD, &param);
       
  1757 
       
  1758     TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION,  "SetCurrentTxPowerLevel, status = %d \n",status);
       
  1759     
       
  1760     switch (status)
       
  1761     {
       
  1762         case TI_OK:                             return WHA::KPending;
       
  1763         case PARAM_ALREADY_CONFIGURED: return WHA::KSuccess;
       
  1764         default: 
       
  1765             TRACE2(iTwdCtrl.hReport, REPORT_SEVERITY_ERROR , "SetCurrentTxPowerLevel, returned status  = %d Power DBm*10 = %d \n",                status, param.content.halCtrlTxPowerDbm);
       
  1766         return WHA::KFailed;
       
  1767 
       
  1768     }
       
  1769 }
       
  1770 
       
  1771 /** 
       
  1772 * \fn     SetTemplateFrame
       
  1773 *  
       
  1774 * 
       
  1775 * \note   - 
       
  1776 * \param aData - StemplateFrame defined in wha_mib.h inside the LDD
       
  1777 * \return   
       
  1778 * \sa     
       
  1779 */ 
       
  1780 WHA::TStatus TIWha::SetTemplateFrame (const void *aData)
       
  1781 {
       
  1782     TMib    Mib;
       
  1783     WHA::StemplateFrame* pMIBTemplateFrame = (WHA::StemplateFrame *)aData;
       
  1784 
       
  1785     TRACE3(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "SetTemplateFrame aLength= %d,aRate= %d aType = %d\n",        pMIBTemplateFrame->iLength, pMIBTemplateFrame->iInitialTransmitRate, pMIBTemplateFrame->iFrameType);
       
  1786     
       
  1787     Mib.aMib = MIB_templateFrame;
       
  1788     Mib.aData.TemplateFrame.FrameType = TIWhaUtils::WhaToTwdFrameType(pMIBTemplateFrame->iFrameType);
       
  1789     Mib.aData.TemplateFrame.Rate = (TI_UINT32)TIWhaUtils::WhaToTwdRate (pMIBTemplateFrame->iInitialTransmitRate);
       
  1790     Mib.aData.TemplateFrame.Length = pMIBTemplateFrame->iLength;
       
  1791 
       
  1792     os_memoryCopy ((TI_HANDLE)&iTwdCtrl.tOsContext, 
       
  1793                    (void *)Mib.aData.TemplateFrame.Data, 
       
  1794                    (void *)pMIBTemplateFrame->iTemplateData, 
       
  1795                    pMIBTemplateFrame->iLength);
       
  1796         
       
  1797     return (TWD_WriteMib (iTwdCtrl.hTWD, &Mib) == TI_OK) ? WHA::KSuccess : WHA::KFailed;
       
  1798 }
       
  1799 
       
  1800 /** 
       
  1801 * \fn     SetDot11GroupAddrTable
       
  1802 * 
       
  1803 * \param aData - *Sdot11GroupAddressesTable
       
  1804 * \return KSuccess or KFailed  
       
  1805 * \sa     
       
  1806 */ 
       
  1807 WHA::TStatus TIWha::SetDot11GroupAddrTable (const void *aData)           
       
  1808 {
       
  1809     WHA::Sdot11GroupAddressesTable *pTable = (WHA::Sdot11GroupAddressesTable *)aData;
       
  1810     TMib Mib;
       
  1811     int i;
       
  1812 
       
  1813     if (NULL == aData) 
       
  1814     {
       
  1815         return WHA::KFailed;
       
  1816     } 
       
  1817 
       
  1818 
       
  1819 /*    TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION,  TIWLANWHA_MODULE_LOG, MSG_2159,  Mib.aMib, *(TUint32 *)(aData));*/
       
  1820 
       
  1821     Mib.aMib = MIB_dot11GroupAddressesTable;
       
  1822     Mib.aData.GroupAddressTable.bFilteringEnable = pTable->iEnable;
       
  1823     Mib.aData.GroupAddressTable.nNumberOfAddresses = pTable->iNumOfAddrs;
       
  1824 
       
  1825     for (i = 0; i < Mib.aData.GroupAddressTable.nNumberOfAddresses; i++)
       
  1826     {
       
  1827         os_memoryCopy ((TI_HANDLE)&iTwdCtrl.tOsContext, 
       
  1828                        (void *)Mib.aData.GroupAddressTable.aGroupTable[i], 
       
  1829                        (void *)((TI_UINT8*)pTable->iAddrData + i*MAC_ADDR_LEN), 
       
  1830                        MAC_ADDR_LEN);
       
  1831     }
       
  1832 
       
  1833     TRACE2(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION,  "SetDot11GroupAddrTable -Enabled=%d-num=%d\n" ,                            Mib.aData.GroupAddressTable.bFilteringEnable,                            Mib.aData.GroupAddressTable.nNumberOfAddresses);
       
  1834 
       
  1835     return (TWD_WriteMib (iTwdCtrl.hTWD, &Mib) == TI_OK) ? WHA::KSuccess : WHA::KFailed;
       
  1836 }
       
  1837 
       
  1838 /** 
       
  1839 * \fn     SetDefaultKeyID
       
  1840 * 
       
  1841 * \param aData - *Sdot11WepDefaultKeyId
       
  1842 * \return KSuccess or KFailed  
       
  1843 * \sa     
       
  1844 */ 
       
  1845 WHA::TStatus TIWha::SetDefaultKeyID (const void *aData) 
       
  1846 {
       
  1847     TTwdParamInfo  param;
       
  1848 
       
  1849   //  TRACE0(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION,  TIWLANWHA_MODULE_LOG, MSG_2161,((WHA::Sdot11WepDefaultKeyId*)aData)->iDot11WepDefaultKeyId);
       
  1850 
       
  1851     /* Set security mode to WEP */
       
  1852     param.paramType = TWD_RSN_SECURITY_MODE_PARAM_ID;
       
  1853     param.content.rsnEncryptionStatus = (ECipherSuite)TWD_CIPHER_WEP;
       
  1854     TWD_SetParam (iTwdCtrl.hTWD, &param);
       
  1855 
       
  1856     param.paramType = TWD_RSN_DEFAULT_KEY_ID_PARAM_ID;
       
  1857     param.content.configureCmdCBParams.pCb = (void*)aData;
       
  1858     param.content.configureCmdCBParams.fCb = NULL;
       
  1859     param.content.configureCmdCBParams.hCb = NULL;
       
  1860 
       
  1861     return (TWD_SetParam (iTwdCtrl.hTWD, &param) == TI_OK) ? WHA::KSuccess : WHA::KFailed;
       
  1862 }
       
  1863 
       
  1864 /** 
       
  1865 * \fn     Dot11RTSThreshold
       
  1866 * 
       
  1867 * \param aData - *Sdot11RTSThreshold
       
  1868 * \return KSuccess or KFailed  
       
  1869 * \sa     
       
  1870 */
       
  1871 WHA::TStatus TIWha::Dot11RTSThreshold (const void *aData)
       
  1872 {
       
  1873     TTwdParamInfo  param;
       
  1874 
       
  1875     TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "Dot11RTSThreshold ,*aData= 0x%x\n",((WHA::Sdot11RTSThreshold*)aData)->iDot11RTSThreshold);
       
  1876 
       
  1877     param.paramType = TWD_RTS_THRESHOLD_PARAM_ID;
       
  1878     param.content.halCtrlRtsThreshold = ((WHA::Sdot11RTSThreshold*)aData)->iDot11RTSThreshold;
       
  1879 
       
  1880     return (TWD_SetParam (iTwdCtrl.hTWD, &param) == TI_OK) ? WHA::KSuccess : WHA::KFailed;
       
  1881 }
       
  1882 
       
  1883 /** 
       
  1884 * \fn     CtsToSelf
       
  1885 * 
       
  1886 * \param aData - *SctsToSelf
       
  1887 * \return KSuccess or KFailed  
       
  1888 * \sa     
       
  1889 */
       
  1890 WHA::TStatus TIWha::CtsToSelf (const void *aData)
       
  1891 {
       
  1892     TMib Mib;
       
  1893 
       
  1894     TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "CtsToSelf, *aData= 0x%x\n",        ((WHA::SctsToSelf *)aData)->iCtsToSelf);
       
  1895 
       
  1896     if (NULL == aData) 
       
  1897     {
       
  1898         return PARAM_VALUE_NOT_VALID;
       
  1899     }
       
  1900     
       
  1901     Mib.aMib = MIB_ctsToSelf;
       
  1902     Mib.aData.CTSToSelfEnable = (TI_UINT32)((WHA::SctsToSelf *)aData)->iCtsToSelf;
       
  1903 
       
  1904     return (TWD_WriteMib (iTwdCtrl.hTWD, &Mib) == TI_OK) ? WHA::KSuccess : WHA::KFailed;
       
  1905 }
       
  1906 
       
  1907 /** 
       
  1908 * \fn     SetArpIpAddrTable
       
  1909 * 
       
  1910 * \param aData - *SarpIpAddressTable
       
  1911 * \return KSuccess or KFailed  
       
  1912 * \sa     
       
  1913 */
       
  1914 WHA::TStatus TIWha::SetArpIpAddrTable (const void *aData)
       
  1915 {   
       
  1916     TMib   Mib;
       
  1917 	WHA::SarpIpAddressTable *pTable = (WHA::SarpIpAddressTable *)aData;
       
  1918 
       
  1919     if (NULL == aData) 
       
  1920     {
       
  1921         return PARAM_VALUE_NOT_VALID;
       
  1922     }
       
  1923 
       
  1924     Mib.aMib = MIB_arpIpAddressesTable;
       
  1925     Mib.aData.ArpIpAddressesTable.FilteringEnable = pTable->iEnable;
       
  1926     
       
  1927     os_memoryCopy ((TI_HANDLE)&iTwdCtrl.tOsContext, 
       
  1928         Mib.aData.ArpIpAddressesTable.addr, 
       
  1929         (void*)&pTable->iIpV4Addr, 
       
  1930         sizeof(pTable->iIpV4Addr));
       
  1931 
       
  1932     TRACE2(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "SetarpIpAddressesTable,*aData= 0x%x addr = 0x%x\n",        pTable->iIpV4Addr, *(TI_UINT32*)Mib.aData.ArpIpAddressesTable.addr);
       
  1933 
       
  1934     return (TWD_WriteMib (iTwdCtrl.hTWD, &Mib) == TI_OK) ? WHA::KSuccess : WHA::KFailed;
       
  1935 }
       
  1936 
       
  1937 /** 
       
  1938 * \fn     SetBeaconFilterIETable
       
  1939 * 
       
  1940 * \param aData - *SbeaconFilterIeTable
       
  1941 * \return KSuccess or KFailed  
       
  1942 * \sa     
       
  1943 */
       
  1944 WHA::TStatus TIWha::SetBeaconFilterIETable (const void *aData)
       
  1945 {
       
  1946 	WHA::SbeaconFilterIeTable *pTable = (WHA::SbeaconFilterIeTable *)aData;
       
  1947     TMib Mib;
       
  1948 
       
  1949     if (NULL == aData) 
       
  1950     {
       
  1951         return WHA::KFailed;
       
  1952     }
       
  1953 
       
  1954     Mib.aMib = MIB_beaconFilterIETable;
       
  1955     Mib.aData.BeaconFilter.iNumberOfIEs =  pTable->iNumofElems;
       
  1956 
       
  1957     os_memoryCopy ((TI_HANDLE)&iTwdCtrl.tOsContext, 
       
  1958                    (void *)Mib.aData.BeaconFilter.iIETable, 
       
  1959                    (void *)pTable->iIeTable, 
       
  1960                    sizeof(Mib.aData.BeaconFilter.iIETable));
       
  1961     
       
  1962     return (TWD_WriteMib (iTwdCtrl.hTWD, &Mib) == TI_OK) ? WHA::KSuccess : WHA::KFailed;
       
  1963 }
       
  1964 
       
  1965 /** 
       
  1966 * \fn     SetBeaconFilterEnable
       
  1967 * 
       
  1968 * \param aData - *SbeaconFilterEnable
       
  1969 * \return KSuccess or KFailed  
       
  1970 * \sa     
       
  1971 */
       
  1972 WHA::TStatus TIWha::SetBeaconFilterEnable (const void *aData)
       
  1973 {
       
  1974 	WHA::SbeaconFilterEnable *pEnable = (WHA::SbeaconFilterEnable *)aData;
       
  1975 
       
  1976     TRACE2(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "SetBeaconFilterEnable, *beaconFilterEnable Data= 0x%x 0x%x\n",        pEnable->iEnable, pEnable->iCount);
       
  1977 
       
  1978     return (TWD_CfgBeaconFilterOpt (iTwdCtrl.hTWD, pEnable->iEnable, 
       
  1979                                     (TI_UINT8)pEnable->iCount) == TI_OK) ? WHA::KSuccess : WHA::KFailed; 
       
  1980 }
       
  1981 
       
  1982 /** 
       
  1983 * \fn     SleepMode
       
  1984 * 
       
  1985 * \param aSleepMode - TSleepMode
       
  1986 * \return KSuccess or KFailed  
       
  1987 * \sa     
       
  1988 */
       
  1989 WHA::TStatus TIWha::SleepMode (
       
  1990 							   const WHA::TSleepMode&       aSleepMode,        /* aSleepMode */
       
  1991     TBool       bResponse)          /* whether Response required */   
       
  1992 {
       
  1993     EPowerPolicy powerPolicy;
       
  1994 
       
  1995     TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "SleepMode = %d\n",aSleepMode);
       
  1996 
       
  1997     /* Save response request flag in the context */
       
  1998     iTwdCtrl.bResponse = bResponse;
       
  1999 
       
  2000     switch (aSleepMode)
       
  2001     {
       
  2002 		case WHA::KAwakeMode:
       
  2003             powerPolicy = POWERAUTHO_POLICY_AWAKE;
       
  2004             break;
       
  2005         case WHA::KPowerDownMode:
       
  2006             powerPolicy = POWERAUTHO_POLICY_ELP;
       
  2007             break;
       
  2008         case WHA::KLowPowerMode:
       
  2009             powerPolicy = POWERAUTHO_POLICY_ELP;
       
  2010             break;
       
  2011         default:
       
  2012             TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_ERROR, "Unknown SleepMode %d, setting to AWAKE\n",aSleepMode);
       
  2013             powerPolicy = POWERAUTHO_POLICY_AWAKE;
       
  2014     }
       
  2015 
       
  2016 /* Currently No support for ELP -- Remove comment when ELP will be added */
       
  2017     //#ifndef ELP_ENABLED
       
  2018         /* Disabling Low Power (ELP) mode */
       
  2019         powerPolicy = POWERAUTHO_POLICY_AWAKE;
       
  2020     //#endif
       
  2021 
       
  2022     /* Call the power authentication module to set the new power policy */
       
  2023     return (TWD_CfgSleepAuth (iTwdCtrl.hTWD, powerPolicy) == TI_OK) ? WHA::KPending : WHA::KSuccess;        
       
  2024 }
       
  2025 
       
  2026 /** 
       
  2027 * \fn     WakeUpConditions
       
  2028 * 
       
  2029 * \param aData - *SwlanWakeUpInterval
       
  2030 * \return KSuccess or KFailed  
       
  2031 * \sa     
       
  2032 */
       
  2033 WHA::TStatus TIWha::WakeUpConditions (const void *aData)
       
  2034 {
       
  2035     WHA::SwlanWakeUpInterval *pWakeUp = (WHA::SwlanWakeUpInterval *)aData;
       
  2036     TPowerMgmtConfig     PowerMgmtConfig;
       
  2037 
       
  2038     PowerMgmtConfig.listenInterval = pWakeUp->iListenInterval;
       
  2039     PowerMgmtConfig.tnetWakeupOn = (ETnetWakeOn)pWakeUp->iMode;
       
  2040 
       
  2041     TRACE2(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "WakeUpConditions ,listenInterval = 0x%x ,iWakeUpMode = 0x%x  \n", PowerMgmtConfig.listenInterval, PowerMgmtConfig.tnetWakeupOn);
       
  2042 
       
  2043     return (TWD_CfgWakeUpCondition (iTwdCtrl.hTWD, &PowerMgmtConfig) == TI_OK) ? WHA::KSuccess : WHA::KFailed;
       
  2044 }
       
  2045 
       
  2046 /** 
       
  2047 * \fn     SetBeaconLostCount
       
  2048 * 
       
  2049 * \param aData - *SbeaconLostCount
       
  2050 * \return KSuccess or KFailed  
       
  2051 * \sa     
       
  2052 */
       
  2053 WHA::TStatus TIWha::SetBeaconLostCount (const void  *aData)
       
  2054 {
       
  2055     TRroamingTriggerParams roamingTriggerCmd;
       
  2056 
       
  2057     /* Configure TWD with 'No BSS' thresholds */
       
  2058     roamingTriggerCmd.BssLossTimeout = NO_BEACON_DEFAULT_TIMEOUT;
       
  2059     roamingTriggerCmd.TsfMissThreshold = (TI_UINT16)((WHA::SbeaconLostCount *)aData)->iLostCount;
       
  2060 
       
  2061     TRACE2(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "SetBeaconLostCount  ,BssLossTimeout = 0x%x ,TsfMissThreshold = 0x%x  \n",        roamingTriggerCmd.BssLossTimeout, roamingTriggerCmd.TsfMissThreshold);
       
  2062 
       
  2063     return (TWD_CfgConnMonitParams (iTwdCtrl.hTWD, &roamingTriggerCmd) == TI_OK)
       
  2064            ? WHA::KSuccess : WHA::KFailed;
       
  2065 }
       
  2066 
       
  2067 /** 
       
  2068 * \fn     SetRcpiThreshold
       
  2069 * 
       
  2070 * \param aData - *SrcpiThreshold
       
  2071 * \description - we are supporting RCI
       
  2072 * \return KSuccess or KFailed  
       
  2073 * \sa     
       
  2074 */
       
  2075 
       
  2076 WHA::TStatus TIWha::SetRcpiThreshold (const void *aData)
       
  2077 {
       
  2078 
       
  2079     RssiSnrTriggerCfg_t tTriggerCfg;
       
  2080     WHA::TRcpi iRCPI = *(WHA::TRcpi *)aData;
       
  2081     
       
  2082     tTriggerCfg.index  = TRIGGER_EVENT_LOW_RSSI;
       
  2083     if (iRCPI<= TIWha_MIN_RCPI_VAL)
       
  2084     {
       
  2085         tTriggerCfg.threshold = TIWha_MIN_RSSI_VAL;
       
  2086     }
       
  2087     else
       
  2088     {
       
  2089         if (iRCPI >= TIWha_MAX_RCPI_VAL)
       
  2090         {
       
  2091             tTriggerCfg.threshold = TIWha_MAX_RSSI_VAL;
       
  2092         }
       
  2093         else
       
  2094         {
       
  2095             tTriggerCfg.threshold = (iRCPI / 2) + TIWha_MIN_RSSI_VAL;
       
  2096         }
       
  2097 
       
  2098     }
       
  2099 
       
  2100     tTriggerCfg.pacing    = TRIGGER_LOW_RSSI_PACING;
       
  2101     tTriggerCfg.metric    = METRIC_EVENT_RSSI_BEACON;
       
  2102     tTriggerCfg.type      = RX_QUALITY_EVENT_EDGE;
       
  2103     tTriggerCfg.direction = RSSI_EVENT_DIR_LOW;
       
  2104     tTriggerCfg.hystersis = 3;
       
  2105     tTriggerCfg.enable    = TI_TRUE;
       
  2106 
       
  2107 
       
  2108 
       
  2109     if (TI_OK == TWD_CfgRssiSnrTrigger (iTwdCtrl.hTWD, &tTriggerCfg))
       
  2110     {
       
  2111         return WHA::KSuccess;
       
  2112     }
       
  2113     else
       
  2114     {
       
  2115         return WHA::KFailed;
       
  2116     }
       
  2117 
       
  2118  
       
  2119 }
       
  2120 
       
  2121 
       
  2122 /** 
       
  2123 * \fn     TxRatePolicy
       
  2124 * 
       
  2125 * \param aData - *StxRatePolicy
       
  2126 * \return KSuccess or KFailed  
       
  2127 * \sa     
       
  2128 */
       
  2129 WHA::TStatus TIWha::TxRatePolicy (
       
  2130     TUint32     aLength,            /* Specifies the length of the MIB */
       
  2131     const void        *aData)             /* Pointer to the MIB data */
       
  2132 {
       
  2133     TMib Mib;
       
  2134     TUint32       i;
       
  2135     WHA::StxRatePolicy *pPolicy = (WHA::StxRatePolicy*) aData;
       
  2136     
       
  2137     if (NULL == aData)
       
  2138     {
       
  2139         return PARAM_VALUE_NOT_VALID;
       
  2140     }
       
  2141 
       
  2142     TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "TxRatePolicy Num of Policies = %d \n",pPolicy->iNumOfPolicyObjects);
       
  2143 
       
  2144     if (pPolicy->iNumOfPolicyObjects > MAX_NUM_OF_TX_RATE_CLASS_POLICIES)
       
  2145     {
       
  2146         TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_ERROR, "ERROR: Can't configure more than %d Classes",MAX_NUM_OF_TX_RATE_CLASS_POLICIES);
       
  2147     }
       
  2148 
       
  2149     Mib.aMib = MIB_txRatePolicy;
       
  2150     /* The length field is not in use */
       
  2151     Mib.Length = 0;
       
  2152     Mib.aData.txRatePolicy.numOfRateClasses = pPolicy->iNumOfPolicyObjects;
       
  2153 
       
  2154     for (i = 0; i < pPolicy->iNumOfPolicyObjects; i++)
       
  2155     {
       
  2156         
       
  2157         Mib.aData.txRatePolicy.rateClass[i].txEnabledRates = 0;
       
  2158         
       
  2159         /* MCS rates not support in Symbian structure */
       
  2160         (pPolicy->iTxRateClass[i].iTxPolicy54)  ? Mib.aData.txRatePolicy.rateClass[i].txEnabledRates |= HW_BIT_RATE_54MBPS  : NULL;
       
  2161         (pPolicy->iTxRateClass[i].iTxPolicy48)  ? Mib.aData.txRatePolicy.rateClass[i].txEnabledRates |= HW_BIT_RATE_48MBPS  : NULL;
       
  2162         (pPolicy->iTxRateClass[i].iTxPolicy36)  ? Mib.aData.txRatePolicy.rateClass[i].txEnabledRates |= HW_BIT_RATE_36MBPS  : NULL;
       
  2163         /* 33Mbps not support in TWD */
       
  2164         (pPolicy->iTxRateClass[i].iTxPolicy24)  ? Mib.aData.txRatePolicy.rateClass[i].txEnabledRates |= HW_BIT_RATE_24MBPS  : NULL;
       
  2165         (pPolicy->iTxRateClass[i].iTxPolicy22)  ? Mib.aData.txRatePolicy.rateClass[i].txEnabledRates |= HW_BIT_RATE_22MBPS  : NULL;
       
  2166         (pPolicy->iTxRateClass[i].iTxPolicy18)  ? Mib.aData.txRatePolicy.rateClass[i].txEnabledRates |= HW_BIT_RATE_18MBPS  : NULL;
       
  2167         (pPolicy->iTxRateClass[i].iTxPolicy12)  ? Mib.aData.txRatePolicy.rateClass[i].txEnabledRates |= HW_BIT_RATE_12MBPS  : NULL;
       
  2168         (pPolicy->iTxRateClass[i].iTxPolicy11)  ? Mib.aData.txRatePolicy.rateClass[i].txEnabledRates |= HW_BIT_RATE_11MBPS  : NULL;
       
  2169         (pPolicy->iTxRateClass[i].iTxPolicy9)   ? Mib.aData.txRatePolicy.rateClass[i].txEnabledRates |= HW_BIT_RATE_9MBPS   : NULL;
       
  2170         (pPolicy->iTxRateClass[i].iTxPolicy6)   ? Mib.aData.txRatePolicy.rateClass[i].txEnabledRates |= HW_BIT_RATE_6MBPS   : NULL;
       
  2171         (pPolicy->iTxRateClass[i].iTxPolicy5_5) ? Mib.aData.txRatePolicy.rateClass[i].txEnabledRates |= HW_BIT_RATE_5_5MBPS : NULL;
       
  2172         (pPolicy->iTxRateClass[i].iTxPolicy2)   ? Mib.aData.txRatePolicy.rateClass[i].txEnabledRates |= HW_BIT_RATE_2MBPS   : NULL;
       
  2173         (pPolicy->iTxRateClass[i].iTxPolicy1)   ? Mib.aData.txRatePolicy.rateClass[i].txEnabledRates |= HW_BIT_RATE_1MBPS   : NULL;
       
  2174         
       
  2175         //os_printf("Policy[%d] is %x ",i,Mib.aData.txRatePolicy.rateClass[i]);
       
  2176         Mib.aData.txRatePolicy.rateClass[i].longRetryLimit = pPolicy->iTxRateClass[i].iLongRetryLimit;
       
  2177         Mib.aData.txRatePolicy.rateClass[i].shortRetryLimit = pPolicy->iTxRateClass[i].iShortRetryLimit;
       
  2178         
       
  2179     }
       
  2180     
       
  2181     return (TWD_WriteMib (iTwdCtrl.hTWD, &Mib) == TI_OK) ? WHA::KSuccess : WHA::KFailed;
       
  2182     /*return WHA::KSuccess;*/
       
  2183 }
       
  2184 
       
  2185 
       
  2186 /** 
       
  2187 * \fn     btCoexistenceMode
       
  2188 * 
       
  2189 * \param aData - *TBTCoexMode
       
  2190 * \ indicats 3 operation modes
       
  2191  *  0 - Disable
       
  2192  *  1 - Enable
       
  2193  *  2 - Auto	
       
  2194 * \return KSuccess or KFailed  
       
  2195 * \sa     
       
  2196 */
       
  2197 WHA::TStatus TIWha::btCoexistenceMode(TUint32 aLength, const void *aData)
       
  2198 {
       
  2199 	ESoftGeminiEnableModes *pSGMode = (ESoftGeminiEnableModes*)aData;
       
  2200 	TTwdParamInfo			iParamInfo;
       
  2201 
       
  2202 	iParamInfo.paramType = TWD_SG_ENABLE_PARAM_ID;
       
  2203 	iParamInfo.paramLength = aLength;
       
  2204 	switch (*pSGMode)
       
  2205 	{
       
  2206 		case SG_PROTECTIVE:
       
  2207 		case SG_OPPORTUNISTIC:
       
  2208 			iParamInfo.content.SoftGeminiEnable = SG_OPPORTUNISTIC;
       
  2209             TWD_SetParam(iTwdCtrl.hTWD,&iParamInfo);
       
  2210 			break;
       
  2211 
       
  2212 		case SG_DISABLE:
       
  2213 			iParamInfo.content.SoftGeminiEnable = SG_DISABLE;
       
  2214 			TWD_SetParam(iTwdCtrl.hTWD,&iParamInfo);
       
  2215 			break;
       
  2216 
       
  2217 		default:
       
  2218 TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_ERROR, "btCoexistenceMode - Value Invalide = %d",*pSGMode);
       
  2219 			return WHA::KFailed;
       
  2220 	}
       
  2221 	return WHA::KSuccess;
       
  2222 }
       
  2223 
       
  2224 /** 
       
  2225 * \fn     btCoexistenceProfile
       
  2226 * 
       
  2227 * \param aData - *ESoftGeminiEnableProfile
       
  2228 * \ indicats 3 operation modes
       
  2229  *  0 - Data-Data
       
  2230  *  1 - VOIP-A2DP/Data
       
  2231  *  2 - Data -A2DP	
       
  2232 * \return KSuccess or KFailed  
       
  2233 * \sa     
       
  2234 */
       
  2235 WHA::TStatus TIWha::btCoexistenceProfile(TUint32 aLength, const void *aData)
       
  2236 {
       
  2237 	ESoftGeminiEnableProfile* pSGProfile = (ESoftGeminiEnableProfile*)aData;
       
  2238 	TTwdParamInfo			iParamInfo;
       
  2239 
       
  2240 	iParamInfo.paramType = TWD_SG_CONFIG_PARAM_ID;
       
  2241 	iParamInfo.paramLength = aLength;
       
  2242 	
       
  2243 
       
  2244 	switch (*pSGProfile)
       
  2245 	{
       
  2246     case BtCoexProfData:
       
  2247             iSgParams.coexParams[SOFT_GEMINI_BT_LOAD_RATIO] = 50;
       
  2248 			break;
       
  2249 
       
  2250 		case BtCoexProfDataLowLatency:
       
  2251 			iSgParams.coexParams[SOFT_GEMINI_BT_LOAD_RATIO] = 50;
       
  2252 			break;
       
  2253 
       
  2254 		case BtCoexProfA2DP:
       
  2255 			iSgParams.coexParams[SOFT_GEMINI_BT_LOAD_RATIO] = 71;
       
  2256 			break;
       
  2257 
       
  2258 		default:
       
  2259 TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_ERROR, "btCoexistenceProfile - Value Invalide = %d",*pSGProfile);
       
  2260 			return WHA::KFailed;
       
  2261 	}
       
  2262 
       
  2263 	os_memoryCopy(iTwdCtrl.tOsContext.hOsa,&iParamInfo.content.SoftGeminiParam,&iSgParams,sizeof(TSoftGeminiParams));
       
  2264 	TWD_SetParam(iTwdCtrl.hTWD,&iParamInfo);
       
  2265 	return WHA::KSuccess;
       
  2266 }
       
  2267 
       
  2268 
       
  2269 /**
       
  2270 * \fn     TConvertTwdHtCapa2SHtCapa
       
  2271 * \brief  Convert the TTwdHtCapabilities structure to WHA::SHtCapabilities  structure
       
  2272 * 
       
  2273 * \param TTwdHtCapabilities
       
  2274 * \param WHA::SHtCapabilities
       
  2275 * 
       
  2276 * /note
       
  2277 * 
       
  2278 * /return none
       
  2279 */
       
  2280 #ifdef HT_SUPPORT
       
  2281 void TIWha::TConvertTwdHtCapa2SHtCapa (TTwdHtCapabilities* pTwdHtCapabilities,WHA::SHtCapabilities* pHtCapabilities)
       
  2282 {
       
  2283 	os_memoryZero (&iTwdCtrl.tOsContext,pHtCapabilities,sizeof(WHA::SHtCapabilities));
       
  2284 	pHtCapabilities->iHTCapabilitiesBitMask = (
       
  2285                                                #ifdef GREENFIELD_FRAME_SUPPORT
       
  2286                                                ((pTwdHtCapabilities->uHTCapabilitiesBitMask & CAP_BIT_MASK_GREENFIELD_FRAME_FORMAT) << 2) |
       
  2287                                                #endif
       
  2288                                                #ifdef SHORT_GI_SUPPORT
       
  2289 											   ((pTwdHtCapabilities->uHTCapabilitiesBitMask & CAP_BIT_MASK_SHORT_GI_FOR_20MHZ_PACKETS) << 2) |
       
  2290                                                #endif
       
  2291 											   ((pTwdHtCapabilities->uHTCapabilitiesBitMask & CAP_BIT_MASK_SHORT_GI_FOR_40MHZ_PACKETS) << 2) |
       
  2292 											   ((pTwdHtCapabilities->uHTCapabilitiesBitMask & CAP_BIT_MASK_SUPPORT_FOR_STBC_IN_TRANSMISSION) << 2) |
       
  2293 											   ((pTwdHtCapabilities->uHTCapabilitiesBitMask & CAP_BIT_MASK_DELAYED_BLOCK_ACK) << 2) |
       
  2294 											   ((pTwdHtCapabilities->uHTCapabilitiesBitMask & CAP_BIT_MASK_DSSS_CCK_IN_40_MHZ) << 2) |
       
  2295 											   ((pTwdHtCapabilities->uHTCapabilitiesBitMask & CAP_BIT_MASK_LSIG_TXOP_PROTECTION) << 3) |
       
  2296 											   ((pTwdHtCapabilities->uHTCapabilitiesBitMask & CAP_BIT_MASK_PCO) << 3) |
       
  2297 											   ((pTwdHtCapabilities->uHTCapabilitiesBitMask & CAP_BIT_MASK_LDPC_CODING) >> 8));
       
  2298 
       
  2299 	pHtCapabilities->iRxMaxDataRate = pTwdHtCapabilities->uRxMaxDataRate;
       
  2300 	
       
  2301 	pHtCapabilities->iChannelWidth = pTwdHtCapabilities->uChannelWidth;
       
  2302 
       
  2303 #ifdef RXSTBC_SUPPORT
       
  2304 	pHtCapabilities->iRxStbc = pTwdHtCapabilities->uRxSTBC;
       
  2305 #else
       
  2306     pHtCapabilities->iRxStbc = RXSTBC_NOT_SUPPORTED;
       
  2307 #endif
       
  2308 
       
  2309 	pHtCapabilities->iMaxAmsdu = pTwdHtCapabilities->uMaxAMSDU;
       
  2310 
       
  2311 	pHtCapabilities->iMaxAmpdu = pTwdHtCapabilities->uMaxAMPDU;
       
  2312 
       
  2313 	pHtCapabilities->iAmpduSpacing = pTwdHtCapabilities->uAMPDUSpacing;
       
  2314 
       
  2315 	//pHtCapabilities->iRxMcs = pTwdHtCapabilities->aRxMCS;
       
  2316 	os_memoryCopy(&iTwdCtrl.tOsContext,pHtCapabilities->iRxMcs,pTwdHtCapabilities->aRxMCS,sizeof(WHA::THtMcsSet));
       
  2317 
       
  2318 	//pHtCapabilities->iTxMcs = pTwdHtCapabilities->aTxMCS;
       
  2319 
       
  2320 	os_memoryCopy(&iTwdCtrl.tOsContext,pHtCapabilities->iTxMcs,pTwdHtCapabilities->aTxMCS,sizeof(WHA::THtMcsSet));
       
  2321 
       
  2322 	pHtCapabilities->iPcoTransTime = pTwdHtCapabilities->uPCOTransTime;
       
  2323 
       
  2324 	pHtCapabilities->iMcsFeedback = pTwdHtCapabilities->uMCSFeedback;
       
  2325 }
       
  2326 #endif /* HT_SUPPORT */
       
  2327 
       
  2328 /**
       
  2329 * \fn     SetHTCapabilities
       
  2330 * \brief  set the HT capabilities of  the AP coming from become/prob resp to FW
       
  2331 * 
       
  2332 * \param ShtCapabilities
       
  2333 * 
       
  2334 * /note
       
  2335 * 
       
  2336 * /return OK for sucsses NOK for failed
       
  2337 */
       
  2338 #ifdef HT_SUPPORT
       
  2339 WHA::TStatus TIWha::SetHTCapabilities (WHA::ShtCapabilities* pApCapabilities)
       
  2340 {
       
  2341 	Tdot11HtCapabilitiesUnparse		aHtCapabilitiesUnparse;
       
  2342 	Tdot11HtCapabilitiesUnparse*	pHtCapabilitiesUnparse = &aHtCapabilitiesUnparse;
       
  2343 
       
  2344 	os_memoryZero(&iTwdCtrl.tOsContext,pHtCapabilitiesUnparse, sizeof(Tdot11HtCapabilitiesUnparse));
       
  2345 	/* Etract the HT Capabilities for FW, at this poin we ignore the HT Control field bit
       
  2346 	   since no support in FW */
       
  2347 	pHtCapabilitiesUnparse->aHtCapabilitiesIe[1] |= (((pApCapabilities->iPeerFeatures & WHA::KGreenfieldFormat) ? HT_CAP_GREENFIELD_FRAME_FORMAT_BITMASK : 0) |
       
  2348 													 ((pApCapabilities->iPeerFeatures & WHA::KShortGiFor20Mhz) ? HT_CAP_SHORT_GI_FOR_20MHZ_BITMASK : 0));
       
  2349 
       
  2350 	pHtCapabilitiesUnparse->aHtCapabilitiesIe[0] |= (((pApCapabilities->iPeerFeatures & WHA::KLsigTxopProtection) ? (HT_CAP_LSIG_TXOP_PROTECTION_BITMASK >> 8) : 0) |
       
  2351 													 ((pApCapabilities->iPeerFeatures & WHA::KReverseDirectionResp) ? (HT_EXT_RD_INITIATION_BITMASK >> 8) : 0));
       
  2352 
       
  2353 	
       
  2354 	pHtCapabilitiesUnparse->aHtCapabilitiesIe[0] |= ((pApCapabilities->iPeerFeatures & WHA::KHtcField) ? (HT_EXT_HT_CONTROL_FIELDS_BITMASK >> 8) : 0);
       
  2355 
       
  2356 	/* Extract the MAX MPDU and MPDU Spacing */
       
  2357 	pHtCapabilitiesUnparse->aHtCapabilitiesIe[HT_CAP_AMPDU_PARAMETERS_FIELD_OFFSET] = ((pApCapabilities->iMaxAmpduLength) |
       
  2358 																						(pApCapabilities->iAmpduSpacing << 2));
       
  2359 
       
  2360 
       
  2361     return TWD_CfgSetFwHtCapabilities(iTwdCtrl.hTWD,pHtCapabilitiesUnparse,(pApCapabilities->iHtSupport > 0 ? TI_TRUE : TI_FALSE));
       
  2362 }
       
  2363 #endif /* HT_SUPPORT */
       
  2364 
       
  2365 
       
  2366 /**
       
  2367 * \fn     SetHTInformation
       
  2368 * \brief  set the HT Information to FW
       
  2369 * 
       
  2370 * \param ShtBssOperation
       
  2371 * 
       
  2372 * /note
       
  2373 * 
       
  2374 * /return OK for sucsses NOK for failed
       
  2375 */
       
  2376 #ifdef HT_SUPPORT
       
  2377 WHA::TStatus TIWha::SetHTInformation (WHA::ShtBssOperation* pHtInformarion)
       
  2378 {
       
  2379 	Tdot11HtInformationUnparse	aHtInformationUnparse;
       
  2380 	Tdot11HtInformationUnparse*	pHtInformationUnparse = &aHtInformationUnparse;
       
  2381 
       
  2382 	pHtInformationUnparse->aHtInformationIe[1] = ((pHtInformarion->iInfo & WHA::ShtBssOperation::KRifsPermitted) ? WHA::ShtBssOperation::KRifsPermitted : 0);
       
  2383 	pHtInformationUnparse->aHtInformationIe[2] = pHtInformarion->iOpMode;
       
  2384 	pHtInformationUnparse->aHtInformationIe[3] = (((pHtInformarion->iInfo & WHA::ShtBssOperation::KNonGreenfieldPresent) ? HT_INF_NON_GF_PRES_BITMASK : 0));
       
  2385 												  
       
  2386 	pHtInformationUnparse->aHtInformationIe[4] = ((pHtInformarion->iInfo & WHA::ShtBssOperation::KDualCtsProtReq) ? HT_INF_DUAL_BEACON_BITMASK : 0);
       
  2387 
       
  2388 	/* Save the MCS rates for use in Join command at basic rates */
       
  2389 	os_memoryCopy(&iTwdCtrl.tOsContext,iMcsRates,pHtInformarion->iMcsSet,sizeof(WHA::THtMcsSet));
       
  2390 
       
  2391 	return TWD_CfgSetFwHtInformation(iTwdCtrl.hTWD,pHtInformationUnparse);
       
  2392 }
       
  2393 #endif /* HT_SUPPORT */
       
  2394 
       
  2395 
       
  2396 /**
       
  2397 * \fn     ConfigureBA
       
  2398 * \brief  configure the BA initiator and BA receiver
       
  2399 * 
       
  2400 * \param ShtBssOperation
       
  2401 * 
       
  2402 * /note
       
  2403 * 
       
  2404 * /return OK for sucsses NOK for failed
       
  2405 */
       
  2406 #ifdef HT_SUPPORT
       
  2407 WHA::TStatus TIWha::ConfigureBA (WHA::ShtBlockAckConfigure* pBABitMask)
       
  2408 {
       
  2409 	WHA::TStatus status = TI_NOK;
       
  2410 	iBACounertRespone = 0;
       
  2411 #ifndef __AMSDU_MODE__
       
  2412 
       
  2413 // Check for which TID is enabled for BA session  
       
  2414 
       
  2415 #ifdef TX_BA_SUPPORT
       
  2416 	/* Set all Transmit BA Support */
       
  2417 	for (int i = 0;i <= MAX_NUM_OF_802_1d_TAGS; i++)
       
  2418 	{
       
  2419 		if (((pBABitMask->iTxBlockAckUsage >> i) & 0x1) > ((iTxBlockAckUsageLast >> i) & 0x1))
       
  2420 		{
       
  2421 			status = TWD_CfgSetBaInitiator(iTwdCtrl.hTWD,i,TRUE,iJoinedMacAddress,RX_QUEUE_WIN_SIZE,HT_BA_INACTIVITY_TIMEOUT_DEF);
       
  2422 			iBACounertRespone++;
       
  2423 		}
       
  2424 		else {
       
  2425 			if (((pBABitMask->iTxBlockAckUsage >> i) & 0x1) < ((iTxBlockAckUsageLast >> i) & 0x1))
       
  2426 			{
       
  2427 				status = TWD_CfgSetBaInitiator(iTwdCtrl.hTWD,i,FALSE,iJoinedMacAddress,RX_QUEUE_WIN_SIZE,HT_BA_INACTIVITY_TIMEOUT_DEF);
       
  2428 				iBACounertRespone++;
       
  2429 			}
       
  2430 		}
       
  2431 	}
       
  2432     iTxBlockAckUsageLast = pBABitMask->iTxBlockAckUsage;
       
  2433 #endif
       
  2434 
       
  2435 	/* Set all Receive BA */
       
  2436 	
       
  2437 	for (int i = 0;i <= MAX_NUM_OF_802_1d_TAGS; i++)
       
  2438 	{
       
  2439 		if (((pBABitMask->iRxBlockAckUsage >> i) & 0x1) > ((iRxBlockAckUsageLast >> i) & 0x1))
       
  2440 		{
       
  2441 			status = TWD_CfgSetBaReceiver(iTwdCtrl.hTWD,i,TRUE,iJoinedMacAddress,RX_QUEUE_WIN_SIZE);
       
  2442 			iBACounertRespone++;
       
  2443 		}
       
  2444 		else {
       
  2445 			if (((pBABitMask->iRxBlockAckUsage >> i) & 0x1) < ((iRxBlockAckUsageLast >> i) & 0x1))
       
  2446 			{
       
  2447 				status = TWD_CfgSetBaReceiver(iTwdCtrl.hTWD,i,FALSE,iJoinedMacAddress,RX_QUEUE_WIN_SIZE);
       
  2448 				iBACounertRespone++;
       
  2449 	}
       
  2450 		}
       
  2451 	}
       
  2452 	
       
  2453 
       
  2454 	/* Save the current BA vectors */
       
  2455 	iRxBlockAckUsageLast = pBABitMask->iRxBlockAckUsage;
       
  2456 #endif
       
  2457 	return status;
       
  2458 }
       
  2459 #endif /* HT_SUPPORT */
       
  2460 
       
  2461 /**
       
  2462 * \fn     TxAutoRatePolicy
       
  2463 * \brief  Specifies the supported rates
       
  2464 * 
       
  2465 * \param StxAutoRatePolicy
       
  2466 * 
       
  2467 * /note
       
  2468 * 
       
  2469 * /return OK for sucsses NOK for failed
       
  2470 */
       
  2471 WHA::TStatus TIWha::TxAutoRatePolicy (WHA::StxAutoRatePolicy* pTxAutoRatePolicy)
       
  2472 {
       
  2473 	iTxRatePolicy.aMib = MIB_txRatePolicy;
       
  2474     /* The length field is not in use */
       
  2475     iTxRatePolicy.Length = 0;
       
  2476 	/* we only have 1 policy since FW decide on which  rate to use */
       
  2477     iTxRatePolicy.aData.txRatePolicy.numOfRateClasses = pTxAutoRatePolicy->iTxRateClassId;
       
  2478 
       
  2479     #ifdef HT_SUPPORT
       
  2480         iTxRatePolicy.aData.txRatePolicy.rateClass[pTxAutoRatePolicy->iTxRateClassId - 1].txEnabledRates = TIWhaUtils::HTWhaRateToRatePolicy(pTxAutoRatePolicy);
       
  2481     #else
       
  2482         iTxRatePolicy.aData.txRatePolicy.rateClass[pTxAutoRatePolicy->iTxRateClassId - 1].txEnabledRates = TIWhaUtils::WhaRateToRatePolicy(pTxAutoRatePolicy);
       
  2483     #endif
       
  2484 
       
  2485     #ifdef ALL_RATES_OPEN_DEBUG
       
  2486         if ( iTxRatePolicy.aData.txRatePolicy.rateClass[pTxAutoRatePolicy->iTxRateClassId - 1].txEnabledRates & HW_BIT_RATE_54MBPS)
       
  2487         {
       
  2488              iTxRatePolicy.aData.txRatePolicy.rateClass[pTxAutoRatePolicy->iTxRateClassId - 1].txEnabledRates = 0x1DFF;    
       
  2489         }
       
  2490     #endif
       
  2491     
       
  2492 	iTxRatePolicy.aData.txRatePolicy.rateClass[pTxAutoRatePolicy->iTxRateClassId - 1].shortRetryLimit = pTxAutoRatePolicy->iShortRetryLimit;
       
  2493 	iTxRatePolicy.aData.txRatePolicy.rateClass[pTxAutoRatePolicy->iTxRateClassId - 1].longRetryLimit = pTxAutoRatePolicy->iLongRetryLimit;
       
  2494 
       
  2495 	return (TWD_WriteMib (iTwdCtrl.hTWD, &iTxRatePolicy) == TI_OK) ? WHA::KSuccess : WHA::KFailed;
       
  2496 }
       
  2497 
       
  2498 /**
       
  2499 * \fn     SetPowerSavePowerLevel
       
  2500 * \brief  Set the Power save power level
       
  2501 *
       
  2502 * 
       
  2503 * /note
       
  2504 * 
       
  2505 * /return 
       
  2506 */
       
  2507 void TIWha::SetPowerSavePowerLevel(void *aMib)
       
  2508 {
       
  2509 	//os_printf("SetPowerSavePowerLevel send EPowerPolicy = %d",*((EPowerPolicy*)aMib));
       
  2510 	TWD_CfgSleepAuth(iTwdCtrl.hTWD, *((EPowerPolicy*)aMib));
       
  2511 }
       
  2512 
       
  2513 
       
  2514 /**
       
  2515 * \fn     SoftGemini_SetParams
       
  2516 * \brief  initialization of Soft Gemini parameters
       
  2517 *
       
  2518 * used for init stage to initialize the SG parameters
       
  2519 * /note
       
  2520 * 
       
  2521 * /return 
       
  2522 */
       
  2523 
       
  2524 TI_STATUS TIWha::SoftGemini_SetParams (TI_HANDLE hTWD, TSoftGeminiParams *pSgParams,ESoftGeminiEnableModes aSgMode )
       
  2525 {
       
  2526 	TTwdParamInfo			iParamInfo;
       
  2527 
       
  2528 	iParamInfo.paramType = TWD_SG_CONFIG_PARAM_ID;
       
  2529 	iParamInfo.paramLength = sizeof(TSoftGeminiParams);
       
  2530 	os_memoryCopy(iTwdCtrl.tOsContext.hOsa,&iParamInfo.content.SoftGeminiParam,&iSgParams,sizeof(TSoftGeminiParams));
       
  2531 	TWD_SetParam(iTwdCtrl.hTWD,&iParamInfo);
       
  2532 
       
  2533 	iParamInfo.paramType = TWD_SG_ENABLE_PARAM_ID;
       
  2534 	iParamInfo.paramLength = sizeof(ESoftGeminiEnableModes);
       
  2535 	iParamInfo.content.SoftGeminiEnable = aSgMode;
       
  2536 	TWD_SetParam(iTwdCtrl.hTWD,&iParamInfo);
       
  2537 	return TI_OK;
       
  2538 }
       
  2539 
       
  2540 /** 
       
  2541 * \fn     ConfigureBtCoex
       
  2542 * \brief  Set the Soft Gemini parameters and send it to FW 
       
  2543 *          
       
  2544 * \note   
       
  2545 * \return KSuccess or KFailed
       
  2546 * \sa     
       
  2547 */ 
       
  2548 void TIWha::InitBtCoex()
       
  2549 {
       
  2550     
       
  2551 	/* Set Static parameters */
       
  2552 
       
  2553     /* Setting the ratio for each profile */
       
  2554     /* Both coexBtLoadRatio & coexBtLoadRatio are 50/50 profiles */
       
  2555     /* The default profile is set to BtCoexProfData */
       
  2556 	switch (BTCOEX_DEFAULT_PROFILE)
       
  2557 	{
       
  2558 		case BtCoexProfData:
       
  2559 			iSgParams.coexParams[SOFT_GEMINI_BT_LOAD_RATIO] = 50;
       
  2560 			break;
       
  2561 
       
  2562 		case BtCoexProfDataLowLatency:
       
  2563 			iSgParams.coexParams[SOFT_GEMINI_BT_LOAD_RATIO] = 50;
       
  2564 			break;
       
  2565 
       
  2566 		case BtCoexProfA2DP:
       
  2567 			iSgParams.coexParams[SOFT_GEMINI_BT_LOAD_RATIO] = 71;
       
  2568 			break;
       
  2569 
       
  2570 		default:
       
  2571             TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_ERROR, "btCoexistenceProfile - Value Invalide = %d",BTCOEX_DEFAULT_PROFILE);
       
  2572 			return;
       
  2573 	}
       
  2574 
       
  2575     iSgParams.coexParams[SOFT_GEMINI_BT_PER_THRESHOLD] = 7500;
       
  2576     iSgParams.coexParams[SOFT_GEMINI_HV3_MAX_OVERRIDE] = 0;
       
  2577     iSgParams.coexParams[SOFT_GEMINI_BT_NFS_SAMPLE_INTERVAL] = 400;
       
  2578     iSgParams.coexParams[SOFT_GEMINI_AUTO_PS_MODE] = 0;	
       
  2579     iSgParams.coexParams[SOFT_GEMINI_AUTO_SCAN_PROBE_REQ] = 170;
       
  2580     iSgParams.coexParams[SOFT_GEMINI_ACTIVE_SCAN_DURATION_FACTOR_HV3]	= 50;   
       
  2581     iSgParams.coexParams[SOFT_GEMINI_ANTENNA_CONFIGURATION] = 0;        
       
  2582     iSgParams.coexParams[SOFT_GEMINI_BEACON_MISS_PERCENT] = 60;
       
  2583     iSgParams.coexParams[SOFT_GEMINI_RATE_ADAPT_THRESH] = 21; /* Set to MCS_7 */
       
  2584     #ifdef ENHANCED_OPPORTUNISTIC
       
  2585         iSgParams.coexParams[SOFT_GEMINI_RATE_ADAPT_SNR] = 1;        
       
  2586     #else
       
  2587         iSgParams.coexParams[SOFT_GEMINI_RATE_ADAPT_SNR]= 0;
       
  2588     #endif    
       
  2589 
       
  2590 
       
  2591     iSgParams.coexParams[SOFT_GEMINI_WLAN_PS_BT_ACL_MASTER_MIN_BR] = 10;
       
  2592     iSgParams.coexParams[SOFT_GEMINI_WLAN_PS_BT_ACL_MASTER_MAX_BR] = 30;
       
  2593     iSgParams.coexParams[SOFT_GEMINI_WLAN_PS_MAX_BT_ACL_MASTER_BR] = 8;
       
  2594 
       
  2595     iSgParams.coexParams[SOFT_GEMINI_WLAN_PS_BT_ACL_SLAVE_MIN_BR] = 20;
       
  2596     iSgParams.coexParams[SOFT_GEMINI_WLAN_PS_BT_ACL_SLAVE_MAX_BR] = 50;
       
  2597     iSgParams.coexParams[SOFT_GEMINI_WLAN_PS_MAX_BT_ACL_SLAVE_BR] = 8;
       
  2598 
       
  2599     iSgParams.coexParams[SOFT_GEMINI_WLAN_PS_BT_ACL_MASTER_MIN_EDR] = 7;
       
  2600     iSgParams.coexParams[SOFT_GEMINI_WLAN_PS_BT_ACL_MASTER_MAX_EDR] = 25;
       
  2601     iSgParams.coexParams[SOFT_GEMINI_WLAN_PS_MAX_BT_ACL_MASTER_EDR] = 20;
       
  2602 
       
  2603     iSgParams.coexParams[SOFT_GEMINI_WLAN_PS_BT_ACL_SLAVE_MIN_EDR] = 8;
       
  2604     iSgParams.coexParams[SOFT_GEMINI_WLAN_PS_BT_ACL_SLAVE_MAX_EDR] = 40;
       
  2605     iSgParams.coexParams[SOFT_GEMINI_WLAN_PS_MAX_BT_ACL_SLAVE_EDR] = 12;    
       
  2606     iSgParams.coexParams[SOFT_GEMINI_RXT] = 1200;
       
  2607     iSgParams.coexParams[SOFT_GEMINI_TXT] = 1500;
       
  2608     iSgParams.coexParams[SOFT_GEMINI_ADAPTIVE_RXT_TXT] = 1;
       
  2609     iSgParams.coexParams[SOFT_GEMINI_PS_POLL_TIMEOUT] = 10;
       
  2610     iSgParams.coexParams[SOFT_GEMINI_UPSD_TIMEOUT] = 10;
       
  2611     iSgParams.coexParams[SOFT_GEMINI_UPSD_TIMEOUT] = 10;
       
  2612 
       
  2613     iSgParams.coexParams[SOFT_GEMINI_WLAN_ACTIVE_BT_ACL_MASTER_MIN_EDR] = 7;
       
  2614     iSgParams.coexParams[SOFT_GEMINI_WLAN_ACTIVE_BT_ACL_MASTER_MAX_EDR] = 15;
       
  2615     iSgParams.coexParams[SOFT_GEMINI_WLAN_ACTIVE_MAX_BT_ACL_MASTER_EDR] = 15;
       
  2616 
       
  2617     iSgParams.coexParams[SOFT_GEMINI_WLAN_ACTIVE_BT_ACL_SLAVE_MIN_EDR] = 8;
       
  2618     iSgParams.coexParams[SOFT_GEMINI_WLAN_ACTIVE_BT_ACL_SLAVE_MAX_EDR] = 20;
       
  2619     iSgParams.coexParams[SOFT_GEMINI_WLAN_ACTIVE_MAX_BT_ACL_SLAVE_EDR] = 15;
       
  2620 
       
  2621     iSgParams.coexParams[SOFT_GEMINI_WLAN_ACTIVE_BT_ACL_MIN_BR] = 20;
       
  2622     iSgParams.coexParams[SOFT_GEMINI_WLAN_ACTIVE_BT_ACL_MAX_BR] = 50;
       
  2623     iSgParams.coexParams[SOFT_GEMINI_WLAN_ACTIVE_MAX_BT_ACL_BR] = 5;
       
  2624 
       
  2625     iSgParams.coexParams[SOFT_GEMINI_PASSIVE_SCAN_DURATION_FACTOR_HV3] = 200;
       
  2626     iSgParams.coexParams[SOFT_GEMINI_PASSIVE_SCAN_DURATION_FACTOR_A2DP] = 800;
       
  2627     iSgParams.coexParams[SOFT_GEMINI_PASSIVE_SCAN_BT_TIME] = 75;
       
  2628     iSgParams.coexParams[SOFT_GEMINI_PASSIVE_SCAN_WLAN_TIME] = 15;    
       
  2629     iSgParams.coexParams[SOFT_GEMINI_HV3_MAX_SERVED] = 6;    
       
  2630 
       
  2631     iSgParams.coexParams[SOFT_GEMINI_DHCP_TIME] = 5000;    
       
  2632     iSgParams.coexParams[SOFT_GEMINI_ACTIVE_SCAN_DURATION_FACTOR_A2DP] = 100;
       
  2633 
       
  2634     iSgParams.coexParams[SOFT_GEMINI_TEMP_PARAM_1] = 0;
       
  2635     iSgParams.coexParams[SOFT_GEMINI_TEMP_PARAM_2] = 0;
       
  2636     iSgParams.coexParams[SOFT_GEMINI_TEMP_PARAM_3] = 0;
       
  2637     iSgParams.coexParams[SOFT_GEMINI_TEMP_PARAM_4] = 0;    
       
  2638     iSgParams.coexParams[SOFT_GEMINI_TEMP_PARAM_5] = 0;    
       
  2639 }
       
  2640 
       
  2641 
       
  2642 /** 
       
  2643 * \fn     AddKey
       
  2644 * \brief  Add key according to the key type 
       
  2645 *          
       
  2646 * \note   In case we already used the given index, we remove the old key
       
  2647 * \return   
       
  2648 * \sa     
       
  2649 */ 
       
  2650 void TIWha::AddKey(
       
  2651 					  WHA::TKeyType aType, 
       
  2652 					  const void* aKey,
       
  2653 					  TUint8 aEntryIndex )
       
  2654 {    
       
  2655     TTwdParamInfo    param;
       
  2656     TSecurityKeys    key;
       
  2657     TI_STATUS        status;
       
  2658 
       
  2659     os_memoryZero ((TI_HANDLE)&iTwdCtrl.tOsContext, &key, sizeof(TSecurityKeys));
       
  2660 
       
  2661     if (aEntryIndex >= TIWha_MAX_PRIVACY_KEY_INDEX)
       
  2662     {
       
  2663         ASSERT_ERR (iTwdCtrl.hReport, "Invalid index=%d\n", aEntryIndex)
       
  2664     }
       
  2665 
       
  2666     /* if the Key already exists, we remove it, and add the new one     */
       
  2667     /* we check the encLen field beacuse if there is key in this entry  */
       
  2668     /* the encLen field is always different than zero                   */
       
  2669     if (iTwdCtrl.privacyKey[aEntryIndex].encLen !=0)
       
  2670     {
       
  2671         TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "Remove duplicate Key from AddKey, aEntryIndex= 0x%x\n", aEntryIndex);
       
  2672        RemoveKey(aEntryIndex);
       
  2673     }
       
  2674     else
       
  2675     {
       
  2676          TRACE2(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "AddKey, New key aEntryIndex= 0x%x, encLen= %d \n", aEntryIndex, iTwdCtrl.privacyKey[aEntryIndex].encLen);
       
  2677     }
       
  2678 
       
  2679     /* Set the security mode */
       
  2680     switch (aType)
       
  2681     {
       
  2682     case WHA::EWepGroupKey:
       
  2683         param.content.rsnEncryptionStatus = (ECipherSuite)TWD_CIPHER_WEP;
       
  2684         iTwdCtrl.eGroupKeyMode = TWD_CIPHER_WEP;
       
  2685         break;
       
  2686 
       
  2687     case WHA::EWepPairWiseKey:
       
  2688         param.content.rsnEncryptionStatus = (ECipherSuite)TWD_CIPHER_WEP;
       
  2689         iTwdCtrl.ePairwiseKeyMode = TWD_CIPHER_WEP;
       
  2690         break;
       
  2691 
       
  2692     case WHA::ETkipGroupKey:
       
  2693         param.content.rsnEncryptionStatus = (ECipherSuite)TWD_CIPHER_TKIP;
       
  2694         iTwdCtrl.eGroupKeyMode = TWD_CIPHER_TKIP;
       
  2695         break;
       
  2696 
       
  2697     case WHA::ETkipPairWiseKey:
       
  2698         param.content.rsnEncryptionStatus = (ECipherSuite)TWD_CIPHER_TKIP;
       
  2699         iTwdCtrl.ePairwiseKeyMode = TWD_CIPHER_TKIP;
       
  2700         break;
       
  2701 
       
  2702     case WHA::EAesGroupKey:
       
  2703         param.content.rsnEncryptionStatus = (ECipherSuite)TWD_CIPHER_AES_CCMP;
       
  2704         iTwdCtrl.eGroupKeyMode = TWD_CIPHER_AES_CCMP;
       
  2705         break;
       
  2706 
       
  2707     case WHA::EAesPairWiseKey:
       
  2708         param.content.rsnEncryptionStatus = (ECipherSuite)TWD_CIPHER_AES_CCMP;
       
  2709         iTwdCtrl.ePairwiseKeyMode = TWD_CIPHER_AES_CCMP;
       
  2710         break;
       
  2711 
       
  2712     #ifdef GEM_SUPPORT
       
  2713     case GEMGroupKey:
       
  2714             param.content.rsnEncryptionStatus = (ECipherSuite)TWD_CIPHER_GEM;
       
  2715             iTwdCtrl.eGroupKeyMode = TWD_CIPHER_GEM;
       
  2716             break;
       
  2717     
       
  2718     case GEMPairWiseKey:
       
  2719             param.content.rsnEncryptionStatus = (ECipherSuite)TWD_CIPHER_GEM;
       
  2720             iTwdCtrl.ePairwiseKeyMode = TWD_CIPHER_GEM;
       
  2721             break;
       
  2722     #endif
       
  2723 
       
  2724     default:
       
  2725             ASSERT_ERR (iTwdCtrl.hReport, "Unknown key type=%d\n", aType)
       
  2726     }   
       
  2727 
       
  2728     param.paramType = TWD_RSN_SECURITY_MODE_PARAM_ID;
       
  2729     TWD_SetParam (iTwdCtrl.hTWD, &param);
       
  2730 
       
  2731     /*  Converts the AddKey back to the correlated TWD command   */
       
  2732     if (ConstructAddKey (&key, 
       
  2733                                         aType,
       
  2734                                         aKey,
       
  2735                                         aEntryIndex) != WHA::KSuccess)
       
  2736     {
       
  2737         ASSERT_ERR (iTwdCtrl.hReport, "Failed to construct key type=%d\n", aType)
       
  2738     }
       
  2739 
       
  2740     os_memoryCopy ((TI_HANDLE)&iTwdCtrl.tOsContext, 
       
  2741                    (void *)&iTwdCtrl.privacyKey[aEntryIndex], 
       
  2742                    (void *)&key, 
       
  2743                    sizeof(TSecurityKeys));
       
  2744     
       
  2745     /* Activates the whal TWD_SetParam function (with TWD_RSN_KEY_ADD_PARAM)  */
       
  2746     param.paramType = TWD_RSN_KEY_ADD_PARAM_ID;
       
  2747     param.content.configureCmdCBParams.pCb = (TUint8*)&key;
       
  2748     param.content.configureCmdCBParams.fCb = (void *)TIWhaAdaptCB::AddKeyResponse;
       
  2749     param.content.configureCmdCBParams.hCb = this;
       
  2750 
       
  2751     status = TWD_SetParam (iTwdCtrl.hTWD, &param);
       
  2752 
       
  2753     if (status != TI_OK) 
       
  2754     {
       
  2755         ASSERT_ERR (iTwdCtrl.hReport, "Add key failure, key index=%d\n", aEntryIndex)
       
  2756     }
       
  2757 }
       
  2758 
       
  2759 /** 
       
  2760 * \fn     ConstructAddKey
       
  2761 * \brief  utility function for AddKey
       
  2762 *          
       
  2763 * \note   
       
  2764 * \return   
       
  2765 * \sa     
       
  2766 */ 
       
  2767 WHA::TStatus TIWha::ConstructAddKey (
       
  2768     TSecurityKeys   *aSecurityKey,  /* structure to be filled               */
       
  2769     WHA::TKeyType        aType,          /* Type of the key to be added          */
       
  2770     const void      *aKey,          /* Pointer to buffer specifying the key */
       
  2771                                     /* material, according to the key type  */
       
  2772                                     /* (see specification for details).     */
       
  2773     TUint8          aEntryIndex)    /* Key entry index. Valid range: 0-8.   */
       
  2774 {  
       
  2775     TUint8      broadcast[MAC_ADDR_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
       
  2776 
       
  2777     TRACE3(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "(%d) - ConstructAddKey, type=%d ïndex=%d\n",__LINE__,aType, aEntryIndex);
       
  2778     
       
  2779     /* Fill up the mutual fields */
       
  2780     switch (aType) 
       
  2781     {
       
  2782         case WHA::EWepGroupKey:
       
  2783         {
       
  2784             /* 
       
  2785              * WEP Group Key:
       
  2786              * 1) Key length 
       
  2787              * 2) Key
       
  2788              * 3) Default key number
       
  2789              */
       
  2790             WHA::SWepGroupKey* pKey = (WHA::SWepGroupKey*)aKey;  
       
  2791             
       
  2792             aSecurityKey->keyType = KEY_WEP;
       
  2793             aSecurityKey->encLen = pKey->iKeyLengthInBytes; 
       
  2794             aSecurityKey->keyIndex = pKey->iKeyId;
       
  2795             
       
  2796             if (!bJoined) {
       
  2797             /* Clear mac address to distinguish between Group and Pairwise */
       
  2798             os_memoryZero ((TI_HANDLE)&iTwdCtrl.tOsContext,
       
  2799                            (void*)aSecurityKey->macAddress,
       
  2800                            sizeof(TMacAddr));
       
  2801             }
       
  2802             else
       
  2803             {
       
  2804                 MAC_COPY (aSecurityKey->macAddress, broadcast);
       
  2805             }
       
  2806 
       
  2807 
       
  2808             os_memoryCopy ((TI_HANDLE)&iTwdCtrl.tOsContext, 
       
  2809                            (void*)aSecurityKey->encKey, 
       
  2810                            (void*)pKey->iKey, 
       
  2811                            aSecurityKey->encLen);
       
  2812                 
       
  2813             break;
       
  2814         }       
       
  2815         case WHA::EWepPairWiseKey:
       
  2816         {
       
  2817             /*
       
  2818              * WEP Pairwise Key:
       
  2819              * 1) MAC Address of the peer station
       
  2820              * 2) Key length 
       
  2821              * 3) Key
       
  2822              */
       
  2823             WHA::SWepPairwiseKey* pKey = (WHA::SWepPairwiseKey*)aKey;  
       
  2824             
       
  2825             aSecurityKey->keyType = KEY_WEP;
       
  2826             aSecurityKey->keyIndex = 0;
       
  2827             MAC_COPY (aSecurityKey->macAddress, (TI_UINT8*)&pKey->iMacAddr); 
       
  2828             aSecurityKey->encLen = pKey->iKeyLengthInBytes; 
       
  2829             os_memoryCopy ((TI_HANDLE)&iTwdCtrl.tOsContext, 
       
  2830                            (void*)aSecurityKey->encKey, 
       
  2831                            (void*)pKey->iKey, 
       
  2832                            aSecurityKey->encLen);
       
  2833         
       
  2834                 break;
       
  2835         }       
       
  2836                 
       
  2837         case WHA::ETkipGroupKey: 
       
  2838         {
       
  2839             /* TKIP Group Key:
       
  2840              * 1) 128 encryption key
       
  2841              * 2) 64 bit Rx MIC Key
       
  2842              * 3) Key ID
       
  2843              */
       
  2844             WHA::STkipGroupKey* pKey = (WHA::STkipGroupKey*)aKey; 
       
  2845             
       
  2846             aSecurityKey->keyType = KEY_TKIP;
       
  2847             aSecurityKey->encLen = WHA::KTKIPKeyLength;
       
  2848             MAC_COPY (aSecurityKey->macAddress, broadcast);
       
  2849             os_memoryCopy ((TI_HANDLE)&iTwdCtrl.tOsContext, 
       
  2850                            (void*)aSecurityKey->micRxKey, 
       
  2851                            (void*)pKey->iRxMicKey, 
       
  2852                            WHA::KTKIPKeyLength);           
       
  2853             os_memoryCopy ((TI_HANDLE)&iTwdCtrl.tOsContext, 
       
  2854                            (void*)aSecurityKey->encKey, 
       
  2855                            (void*)pKey->iTkipKey, 
       
  2856                            WHA::KTKIPKeyLength);
       
  2857             aSecurityKey->keyIndex = pKey->iKeyId;
       
  2858             break;
       
  2859         }       
       
  2860 
       
  2861         case WHA::ETkipPairWiseKey:
       
  2862         {
       
  2863             /* 
       
  2864              * TKIP Pairwise Key:
       
  2865              * 1) MAC Address of the peer station
       
  2866              * 2) 64 bit Rx MIC Key
       
  2867              * 3) 64 bit Tx MIC Key
       
  2868              * 4) 128 encryption key
       
  2869              * 5) Key ID
       
  2870              */
       
  2871             WHA::STkipPairwiseKey* pKey = (WHA::STkipPairwiseKey*)aKey;             
       
  2872 
       
  2873             aSecurityKey->keyType = KEY_TKIP;
       
  2874             aSecurityKey->encLen = WHA::KTKIPKeyLength;
       
  2875             MAC_COPY (aSecurityKey->macAddress, (TI_UINT8*)&pKey->iMacAddr); 
       
  2876             os_memoryCopy ((TI_HANDLE)&iTwdCtrl.tOsContext, 
       
  2877                            (void*)aSecurityKey->micRxKey, 
       
  2878                            (void*)pKey->iRxMicKey, 
       
  2879                            WHA::KTKIPKeyLength);            
       
  2880             os_memoryCopy ((TI_HANDLE)&iTwdCtrl.tOsContext, 
       
  2881                            (void*)aSecurityKey->micTxKey, 
       
  2882                            (void*)pKey->iTxMicKey, 
       
  2883                            WHA::KTKIPKeyLength);            
       
  2884             os_memoryCopy ((TI_HANDLE)&iTwdCtrl.tOsContext, 
       
  2885                            (void*)aSecurityKey->encKey, 
       
  2886                            (void*)pKey->iTkipKey, 
       
  2887                            WHA::KTKIPKeyLength);
       
  2888             aSecurityKey->keyIndex = pKey->iKeyId;
       
  2889             break;
       
  2890         }       
       
  2891 
       
  2892         case WHA::EAesGroupKey:
       
  2893         {
       
  2894             /* AES Group Key:
       
  2895              * 1) 128 encryption key 
       
  2896              * 2) key ID
       
  2897              */
       
  2898             WHA::SAesGroupKey* pKey = (WHA::SAesGroupKey*)aKey;             
       
  2899 
       
  2900             /* Fill security key structure */
       
  2901             aSecurityKey->keyType = KEY_AES;
       
  2902             aSecurityKey->encLen = WHA::KAesKeyLength;
       
  2903             MAC_COPY (aSecurityKey->macAddress, broadcast);
       
  2904             os_memoryCopy ((TI_HANDLE)&iTwdCtrl.tOsContext, 
       
  2905                            (void*)aSecurityKey->encKey, 
       
  2906                            (void*)pKey->iAesKey, 
       
  2907                            WHA::KAesKeyLength);
       
  2908             aSecurityKey->keyIndex = pKey->iKeyId;
       
  2909             break;
       
  2910         }       
       
  2911 
       
  2912         case WHA::EAesPairWiseKey:
       
  2913         {
       
  2914             /* 
       
  2915              * AES Pairwise Key:
       
  2916              * 1) MAC Address of the peer station
       
  2917              * 2) 128 encryption key 
       
  2918              */
       
  2919             WHA::SAesPairwiseKey* pKey = (WHA::SAesPairwiseKey*)aKey;             
       
  2920 
       
  2921             /* Fill security key structure */
       
  2922             aSecurityKey->keyType = KEY_AES;
       
  2923             aSecurityKey->encLen = WHA::KAesKeyLength;
       
  2924             aSecurityKey->keyIndex = 0;
       
  2925             MAC_COPY (aSecurityKey->macAddress, (TI_UINT8*)&pKey->iMacAddr); 
       
  2926             os_memoryCopy ((TI_HANDLE)&iTwdCtrl.tOsContext, 
       
  2927                            (void*)aSecurityKey->encKey, 
       
  2928                            (void*)pKey->iAesKey, 
       
  2929                            WHA::KAesKeyLength);                      
       
  2930             break;
       
  2931         }
       
  2932 
       
  2933         #ifdef GEM_SUPPORT
       
  2934             case GEMGroupKey:
       
  2935             {
       
  2936                 SGEMGroupKey* pKey = (SGEMGroupKey*)aKey;
       
  2937     
       
  2938                 /* Fill security key structure */
       
  2939                 aSecurityKey->keyType = KEY_GEM;
       
  2940                 aSecurityKey->encLen = KGEMKeyLength;
       
  2941                 aSecurityKey->keyIndex = pKey->iKeyId;
       
  2942                 MAC_COPY (aSecurityKey->macAddress, broadcast);
       
  2943                 GROUP_KEY_COPY ((TI_HANDLE)&iTwdCtrl.tOsContext,aSecurityKey,pKey,KGEMKeyLength);
       
  2944                 GROUP_MIC_COPY ((TI_HANDLE)&iTwdCtrl.tOsContext,aSecurityKey,pKey,KGEMMicKeyLength);
       
  2945                 break;
       
  2946             }
       
  2947     
       
  2948             case GEMPairWiseKey:
       
  2949             {
       
  2950                 SGEMPairwiseKey* pKey = (SGEMPairwiseKey*)aKey;             
       
  2951     
       
  2952                 /* Fill security key structure */
       
  2953                 aSecurityKey->keyType = KEY_GEM;
       
  2954                 aSecurityKey->encLen = KGEMKeyLength;
       
  2955                 aSecurityKey->keyIndex = pKey->iKeyId;
       
  2956                 MAC_COPY (aSecurityKey->macAddress, (TI_UINT8*)&pKey->iMacAddr); 
       
  2957                 PAIRWISE_KEY_COPY ((TI_HANDLE)&iTwdCtrl.tOsContext,aSecurityKey,pKey,KGEMKeyLength);
       
  2958                 PAIRWISE_MIC_COPY ((TI_HANDLE)&iTwdCtrl.tOsContext,aSecurityKey,pKey,KGEMMicKeyLength);
       
  2959                 break;
       
  2960             }
       
  2961         #endif /* GEM_SUPPORT */
       
  2962 
       
  2963         default:
       
  2964             /*
       
  2965              * NULL_KEY, XCC_KEY
       
  2966              */
       
  2967             TRACE2(iTwdCtrl.hReport, REPORT_SEVERITY_ERROR, "(%d) - ConstructAddKey - ERROR - Key not supported, %d\n",__LINE__,aType);
       
  2968 
       
  2969             break;
       
  2970     }
       
  2971 
       
  2972     return WHA::KSuccess;
       
  2973 }
       
  2974 
       
  2975 /** 
       
  2976 * \fn     RemoveKey
       
  2977 * \brief  Remove key from our data base and from Fw
       
  2978 *          
       
  2979 * \note   This function is never called from LDD, therfore we use dummy response
       
  2980 * \return   
       
  2981 * \sa     
       
  2982 */ 
       
  2983 void TIWha::RemoveKey( TUint8 aEntryIndex)
       
  2984 {        
       
  2985     TTwdParamInfo    param;
       
  2986     TI_STATUS        status;
       
  2987 	ECipherSuite	 eOldCipherSuite;
       
  2988     TBool 			 bSecurityChanged = FALSE;
       
  2989 
       
  2990 
       
  2991     TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "RemoveKey, aEntryIndex= 0x%x\n", aEntryIndex);
       
  2992 
       
  2993     if (aEntryIndex >= TIWha_MAX_PRIVACY_KEY_INDEX)
       
  2994     {
       
  2995         ASSERT_ERR (iTwdCtrl.hReport, "Invalid key index=%d\n", aEntryIndex)
       
  2996     }
       
  2997     
       
  2998 	param.paramType = TWD_RSN_SECURITY_MODE_PARAM_ID;
       
  2999 	status = TWD_GetParam(iTwdCtrl.hTWD, &param);
       
  3000 	if (status != TI_OK)
       
  3001     {
       
  3002         ASSERT_ERR (iTwdCtrl.hReport, "RemoveKey : Remove key failure, key index=%d\n", aEntryIndex)
       
  3003     }
       
  3004 
       
  3005 	eOldCipherSuite = param.content.rsnEncryptionStatus;
       
  3006 
       
  3007 	/* Synchronies the current security mode with the key security mode */ 
       
  3008 	switch (iTwdCtrl.privacyKey[aEntryIndex].keyType)
       
  3009 	{
       
  3010 		case KEY_WEP: param.content.rsnEncryptionStatus = TWD_CIPHER_WEP; break;
       
  3011 	    case KEY_TKIP: param.content.rsnEncryptionStatus = TWD_CIPHER_TKIP; break;
       
  3012         case KEY_AES: param.content.rsnEncryptionStatus = TWD_CIPHER_AES_CCMP; break;
       
  3013         #ifdef GEM_SUPPORT
       
  3014             case KEY_GEM: param.content.rsnEncryptionStatus = TWD_CIPHER_GEM; break;
       
  3015         #endif
       
  3016 	}
       
  3017 
       
  3018     TRACE3(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "RemoveKey, keyType= 0x%x, rsnEncryptionStatus = 0x%x eOldCipherSuite = 0x%x\n",         iTwdCtrl.privacyKey[aEntryIndex].keyType, param.content.rsnEncryptionStatus, eOldCipherSuite);
       
  3019 
       
  3020     /* Check if we should update security mode */
       
  3021     if (eOldCipherSuite != param.content.rsnEncryptionStatus)
       
  3022     {
       
  3023         bSecurityChanged = TRUE;
       
  3024         /* Change security mode in whalSecurity  */
       
  3025         status = TWD_SetParam (iTwdCtrl.hTWD, &param);
       
  3026 		if (status != TI_OK)
       
  3027 		{
       
  3028 			ASSERT_ERR (iTwdCtrl.hReport, "RemoveKey : Remove key failure, key index=%d\n", aEntryIndex)
       
  3029 		}
       
  3030     }
       
  3031 	
       
  3032     /* Activates the TWD_SetParam function (with TWD_RSN_KEY_REMOVE_PARAM) */
       
  3033     param.paramType = TWD_RSN_KEY_REMOVE_PARAM_ID;        
       
  3034     param.content.configureCmdCBParams.pCb = (TUint8*)&iTwdCtrl.privacyKey[aEntryIndex];
       
  3035     /* Note that we never response a remove key since it is internal command. Symbian never issue this command */
       
  3036     param.content.configureCmdCBParams.fCb = (void *)TIWhaAdaptCB::DummyResponse;
       
  3037     param.content.configureCmdCBParams.hCb = this;
       
  3038 
       
  3039      status = TWD_SetParam (iTwdCtrl.hTWD, &param); 
       
  3040 
       
  3041     if (status != TI_OK)
       
  3042     {
       
  3043         ASSERT_ERR (iTwdCtrl.hReport, "Remove key failure, key index=%d\n", aEntryIndex)
       
  3044     }
       
  3045     else
       
  3046     {
       
  3047         /* remove the key from the keys table */
       
  3048         os_memoryZero ((TI_HANDLE)&iTwdCtrl.tOsContext, &iTwdCtrl.privacyKey[aEntryIndex], sizeof(TSecurityKeys));
       
  3049     }
       
  3050 
       
  3051     /* Check if we should update back security mode */
       
  3052     if (bSecurityChanged)
       
  3053     {
       
  3054         param.content.rsnEncryptionStatus = eOldCipherSuite;
       
  3055         param.paramType = TWD_RSN_SECURITY_MODE_PARAM_ID;
       
  3056         status = TWD_SetParam (iTwdCtrl.hTWD, &param);
       
  3057 		if (status != TI_OK)
       
  3058 		{
       
  3059 			ASSERT_ERR (iTwdCtrl.hReport, "RemoveKey : Remove key failure, key index=%d\n", aEntryIndex)
       
  3060 		}
       
  3061     }
       
  3062 }
       
  3063 
       
  3064 /** 
       
  3065 * \fn     ConfigureQueue
       
  3066 * 
       
  3067 * \return
       
  3068 * \sa     
       
  3069 */
       
  3070 void TIWha::ConfigureQueue(
       
  3071 							  WHA::TQueueId aQueueId,
       
  3072 							  TUint32 aMaxLifeTime,
       
  3073 							  WHA::TPsScheme aPsScheme,
       
  3074 							  const WHA::SSAPSDConfig& aSAPSDConfig,
       
  3075 							  WHA::TAckPolicy aAckPolicy,
       
  3076 							  	TUint16 aMediumTime )
       
  3077 {    
       
  3078     TTwdParamInfo        param;
       
  3079     TQueueTrafficParams  QueueTrafficParams;
       
  3080     TI_STATUS            status;  
       
  3081 
       
  3082     TRACE0(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "\n");
       
  3083 
       
  3084     TRACE5(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, " TIWha::ConfigureQueue: aQueueId = 0x%x, aPsScheme = 0x%x, APSDConf[0] = 0x%x, APSDConf[1] = 0x%x, aAckPolicy = 0x%x\n",                aQueueId,aPsScheme,aSAPSDConfig.iServiceStartTime,aSAPSDConfig.iServiceInterval,aAckPolicy);
       
  3085 
       
  3086     /* Set parameters */ 
       
  3087     QueueTrafficParams.queueID = (TUint8)aQueueId;
       
  3088     /* 0- 3 EDCA , 4 - HCCA */
       
  3089     QueueTrafficParams.channelType = (aQueueId < 4) ? CHANNEL_TYPE_EDCF : CHANNEL_TYPE_HCCA;
       
  3090     QueueTrafficParams.tsid        = (TUint8)aQueueId;   
       
  3091     QueueTrafficParams.dot11EDCATableMSDULifeTime = 0;
       
  3092     QueueTrafficParams.psScheme    = aPsScheme;
       
  3093     QueueTrafficParams.APSDConf[0] = aSAPSDConfig.iServiceStartTime;
       
  3094     QueueTrafficParams.APSDConf[1] = aSAPSDConfig.iServiceInterval;
       
  3095     QueueTrafficParams.ackPolicy = aAckPolicy;
       
  3096 
       
  3097     param.paramType = (TUint32)TWD_QUEUES_PARAM_ID;
       
  3098     param.content.pQueueTrafficParams = &QueueTrafficParams;
       
  3099 
       
  3100     status = TWD_SetParam (iTwdCtrl.hTWD, &param);
       
  3101 
       
  3102     if (status != TI_OK) 
       
  3103     {
       
  3104         ASSERT_ERR ( iTwdCtrl.hReport, "ERROR:Configure queue failure, queue ID=%d\n", aQueueId)
       
  3105     }
       
  3106 }
       
  3107 
       
  3108 /** 
       
  3109 * \fn     ConfigureAC
       
  3110 * 
       
  3111 * \return
       
  3112 * \sa     
       
  3113 */
       
  3114 void TIWha::ConfigureAC(
       
  3115 						   TUint16 aCwMin[Wha::KNumOfEdcaQueues],
       
  3116 						   TUint16 aCwMax[Wha::KNumOfEdcaQueues],
       
  3117 						   TUint8 aAIFS[Wha::KNumOfEdcaQueues],
       
  3118 						   TUint16 aTxOplimit[Wha::KNumOfEdcaQueues],
       
  3119 						   TUint16 aMaxReceiveLifeTime[Wha::KNumOfEdcaQueues] )
       
  3120 {    
       
  3121     TAcQosParams      AcQosParams;
       
  3122     WHA::TStatus           status    = TI_OK;
       
  3123     TUint8            i;
       
  3124 
       
  3125     TRACE0(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "\n");
       
  3126       
       
  3127     /* configure all AC's but the last one in a loop that returns as a dummy CB */
       
  3128     for (i = 0; (i < Wha::KNumOfEdcaQueues - 1) && (TI_OK == status); i++)
       
  3129     {       
       
  3130         TRACE5(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, " TIWha::ConfigureAC: Index = 0x%x, aCwMin = 0x%x, aCwMax = 0x%x, aAIFS = 0x%x, aTxOpLimit = 0x%x\n",            i,aCwMin[i],aCwMax[i],aAIFS[i],aTxOplimit[i]);
       
  3131 
       
  3132         AcQosParams.ac = i;
       
  3133         AcQosParams.cwMin = (TUint8)aCwMin[i];
       
  3134         AcQosParams.cwMax = aCwMax[i];
       
  3135         AcQosParams.aifsn = aAIFS[i];
       
  3136         AcQosParams.txopLimit = aTxOplimit[i];
       
  3137 
       
  3138         status = TWD_CfgAcParams (iTwdCtrl.hTWD, 
       
  3139                                   &AcQosParams, 
       
  3140                                   (void *)TIWhaAdaptCB::DummyResponse,
       
  3141                                   this);
       
  3142     }
       
  3143 
       
  3144     /* After the loop - the last AC returns as a real CB */
       
  3145     if (TI_OK == status)
       
  3146     {
       
  3147         TRACE5(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, " TIWha::ConfigureAC: Index = 0x%x, aCwMin = 0x%x, aCwMax = 0x%x, aAIFS = 0x%x, aTxOpLimit = 0x%x\n",            i,aCwMin[i],aCwMax[i],aAIFS[i],aTxOplimit[i]);
       
  3148         
       
  3149         AcQosParams.ac = i;
       
  3150         AcQosParams.cwMin = (TUint8)aCwMin[i];
       
  3151         AcQosParams.cwMax = aCwMax[i];
       
  3152         AcQosParams.aifsn = aAIFS[i];
       
  3153         AcQosParams.txopLimit = aTxOplimit[i];
       
  3154 
       
  3155         status = TWD_CfgAcParams (iTwdCtrl.hTWD, 
       
  3156                                   &AcQosParams, 
       
  3157                                   NULL, /* The generic CB will be called */
       
  3158                                   NULL);
       
  3159     }
       
  3160 
       
  3161     if (status != TI_OK) 
       
  3162     {
       
  3163         TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "ERROR: Configure AC failure, status=%d\n", status);
       
  3164     }
       
  3165 }
       
  3166 
       
  3167 
       
  3168 
       
  3169 /** 
       
  3170 * \fn     Reset
       
  3171 * \brief  disconnect from BSS/IBSS
       
  3172 * \return
       
  3173 * \sa     
       
  3174 */
       
  3175 void TIWha::Reset() 
       
  3176 {    
       
  3177     TRACE0(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "\n");
       
  3178     int          status;
       
  3179 
       
  3180     /* Check if we are in 802.11 PS mode. If not we should update sleepMode */
       
  3181     if (!(TWD_GetPsStatus (iTwdCtrl.hTWD)))
       
  3182     {
       
  3183         /* Configure H/W to user sleep mode */
       
  3184         SleepMode (iTwdCtrl.sleepMode, FALSE);
       
  3185     }
       
  3186 
       
  3187 
       
  3188     /* If connection timer is running - stop it */
       
  3189     if (bConnectionTimerRunning)
       
  3190     {
       
  3191         bConnectionTimerRunning = TI_FALSE;
       
  3192         os_timerStop(&iTwdCtrl.tOsContext, hConnectionTimer);
       
  3193     }
       
  3194 
       
  3195 #ifdef HT_SUPPORT
       
  3196 	TWD_CloseAllBaSessions(iTwdCtrl.hTWD);
       
  3197 #endif /* HT_SUPPORT */
       
  3198     
       
  3199     status = TWD_CmdFwDisconnect ( iTwdCtrl.hTWD ,DISCONNECT_IMMEDIATE , STATUS_UNSPECIFIED);
       
  3200 
       
  3201     if (status != TI_OK) 
       
  3202     {
       
  3203         ASSERT_ERR ( iTwdCtrl.hReport, "Reset failure, status=%d\n", status)
       
  3204     }
       
  3205 
       
  3206     /* We are not connected */
       
  3207     bJoined = 0;
       
  3208 }
       
  3209 
       
  3210 #ifdef TI_TEST
       
  3211 TTestCmd mTest;
       
  3212 /**
       
  3213 * \fn     PltTester
       
  3214 * \brief  Called when PLT commands sent externally
       
  3215 *
       
  3216 * /Param aData - parametrs of PLT command
       
  3217 * /return  
       
  3218 */
       
  3219 void TIWha::PltTester(const void *aData)
       
  3220 {
       
  3221 	TTestCmd* pPltTester = (TTestCmd*)aData;
       
  3222 	os_memoryCopy(NULL,&mTest,(void *)aData,sizeof(TTestCmd));
       
  3223 	Plt(pPltTester->testCmdId,&mTest.testCmd_u);
       
  3224 }
       
  3225 
       
  3226 
       
  3227 
       
  3228 /**
       
  3229 * \fn     ChangeQueue
       
  3230 * \brief  Change the output queue for all packets
       
  3231 *
       
  3232 * /Param aData - queue to be set
       
  3233 * /return  
       
  3234 */
       
  3235 void TIWha::ChangeQueue(const void *aData)
       
  3236 {
       
  3237 	iQueueId = *(WHA::TQueueId*)aData;
       
  3238 
       
  3239     if( bErrorIndication == TI_FALSE)
       
  3240     {    
       
  3241         WhaCb()->CommandResponse(WHA::EWriteMIBResponse, WHA::KSuccess, iUCommandResponseParams);
       
  3242     }
       
  3243     #if TI_DBG
       
  3244         else
       
  3245         {
       
  3246             WLAN_OS_REPORT(("%s : CommandResponse Block call to LDD response \n",__FUNCTION__));
       
  3247         }
       
  3248     #endif
       
  3249 }
       
  3250 #endif /* TI_TEST */
       
  3251 
       
  3252 
       
  3253 /**
       
  3254 * \fn     Plt
       
  3255 * \brief  production line testing
       
  3256 *
       
  3257 * The host driver calls this method to perform production 
       
  3258 * line testing of the WLAN device
       
  3259 * /param eTestCmd - specific test enum
       
  3260 * /param pTestCmdParams - test specific parameters and place for return buffer
       
  3261 * /return  TStatus - KPending or KError
       
  3262 */
       
  3263 WHA::TStatus TIWha::Plt (ETestCmdID eTestCmd, void *pTestCmdParams)
       
  3264 {
       
  3265 	TI_STATUS status;
       
  3266     TRACE1(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, " CmdID = 0x%x\n", eTestCmd);
       
  3267 
       
  3268     /* Save type of test to be retrieved later on the CB */
       
  3269     iTwdCtrl.ePlt = eTestCmd;
       
  3270 
       
  3271 	switch (eTestCmd)
       
  3272 	{
       
  3273     case TEST_CMD_P2G_CAL:
       
  3274         status =  TWDriverTest (iTwdCtrl.hTWD, 
       
  3275                                   (TestCmdID_enum) eTestCmd, 
       
  3276                                   pTestCmdParams,
       
  3277                                   TIWhaAdaptCB::TxBipResponse, 
       
  3278                                   (TI_HANDLE) this);
       
  3279         break;
       
  3280         
       
  3281     case TEST_CMD_RX_PLT_CAL:
       
  3282         status =  TWDriverTest (iTwdCtrl.hTWD, 
       
  3283                                   (TestCmdID_enum) eTestCmd, 
       
  3284                                   pTestCmdParams,
       
  3285                                   TIWhaAdaptCB::RxBipResponse, 
       
  3286                                   (TI_HANDLE) this);
       
  3287         break;
       
  3288 
       
  3289     case TEST_CMD_RX_STAT_GET:
       
  3290 		status =  TWDriverTest (iTwdCtrl.hTWD, 
       
  3291 						   (TestCmdID_enum) eTestCmd, 
       
  3292 						   pTestCmdParams,
       
  3293 						   TIWhaAdaptCB::RxStatResponse, 
       
  3294 						   (TI_HANDLE) this);
       
  3295 		break;
       
  3296     case TEST_CMD_FREE_RUN_RSSI:
       
  3297         status =  TWDriverTest (iTwdCtrl.hTWD, 
       
  3298 						   (TestCmdID_enum) eTestCmd, 
       
  3299 						   pTestCmdParams,
       
  3300 						   TIWhaAdaptCB::RunRssiResponse, 
       
  3301 						   (TI_HANDLE) this);
       
  3302 		break;
       
  3303 
       
  3304 	default:
       
  3305 		status =  TWDriverTest (iTwdCtrl.hTWD, 
       
  3306     				   (TestCmdID_enum) eTestCmd, 
       
  3307     				   pTestCmdParams, 
       
  3308     				   TIWhaAdaptCB::PltResponse, 
       
  3309     				   (TI_HANDLE) this);
       
  3310     } /* switch */
       
  3311 
       
  3312 	return (status == TI_OK) ? WHA::KPending : WHA::KFailed;
       
  3313 }
       
  3314 /**
       
  3315 * \fn     Plt 
       
  3316 * \brief  production line testing 
       
  3317 *
       
  3318 * The host driver calls this method to perform production 
       
  3319 * line testing of the WLAN device
       
  3320 * /param TPltType - specific test enum
       
  3321 * /param aParams - test specific parameters and place for return buffer
       
  3322 * /return  TStatus - KPending or KError
       
  3323 */
       
  3324 void TIWha::Plt (WHA::TPltType aType, void *aParams)
       
  3325 {
       
  3326     Plt((ETestCmdID) aType,aParams);
       
  3327 }
       
  3328 
       
  3329 
       
  3330 /** 
       
  3331  * \fn     WriteMem
       
  3332  * \brief  write buffer to HW address
       
  3333  * 
       
  3334  * \note    
       
  3335  * \param  pMemoryAccess - address, length, buffer
       
  3336  * \return  TStatus 
       
  3337  */ 
       
  3338 WHA::TStatus TIWha::WriteMem (TMemoryAccess *pMemoryAccess)
       
  3339 {    
       
  3340 TRACE3(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, " addr = 0x%x length = %d p = %p\n", pMemoryAccess->addr, pMemoryAccess->length, pMemoryAccess);
       
  3341 
       
  3342     TI_STATUS status = TWD_writeMem (iTwdCtrl.hTWD, 
       
  3343         (TFwDebugParams*) pMemoryAccess, (void*)TIWhaAdaptCB::WriteMemResponse, this);
       
  3344 
       
  3345     /* convert status to WHA::TStatus */
       
  3346     return (status == TI_OK) ? WHA::KPending : WHA::KFailed;
       
  3347 }
       
  3348 
       
  3349 
       
  3350 /** 
       
  3351  * \fn     ReadMem
       
  3352  * \brief  read buffer from HW address
       
  3353  * 
       
  3354  * \note    
       
  3355  * \param  pMemoryAccess - address, length, buffer
       
  3356  * \return  TStatus 
       
  3357  */ 
       
  3358 WHA::TStatus TIWha::ReadMem (TMemoryAccess  *pMemoryAccess)
       
  3359 {
       
  3360 TRACE3(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, " addr = 0x%x length = %d p = %p\n", pMemoryAccess->addr, pMemoryAccess->length, pMemoryAccess);
       
  3361 
       
  3362     TI_STATUS status = TWD_readMem (iTwdCtrl.hTWD, 
       
  3363         (TFwDebugParams*) pMemoryAccess, (void*)TIWhaAdaptCB::ReadMemResponse, this);
       
  3364 
       
  3365     /* convert status to WHA::TStatus */
       
  3366     return (status == TI_OK) ? WHA::KPending : WHA::KFailed;
       
  3367 }
       
  3368 
       
  3369 
       
  3370 /**********************************************************
       
  3371 TIWha Service functions
       
  3372 **********************************************************/
       
  3373 
       
  3374 /**
       
  3375 * \fn     getMacAddress
       
  3376 * \brief  return the Mac address from the TWDCtrl
       
  3377 *
       
  3378 * 
       
  3379 * /note
       
  3380 * 
       
  3381 * /return 
       
  3382 */
       
  3383 void * TIWha::getMacAddress()
       
  3384 {
       
  3385 	return (void *)iTwdCtrl.pMacAddr;
       
  3386 
       
  3387 }
       
  3388 
       
  3389 /**
       
  3390 * \fn     InitTwdParamTable
       
  3391 * \brief  initialization of TWD parameters
       
  3392 *
       
  3393 * since we have no ini file, we are initializing the 
       
  3394 * Modules wit hard coded values
       
  3395 * /note
       
  3396 * 
       
  3397 * /return 
       
  3398 */
       
  3399 void TIWha::InitTwdParamTable()
       
  3400 {
       
  3401     os_memoryZero (&iTwdCtrl.tOsContext, (TI_UINT8*)&iTwdCtrl.twdInitParams, sizeof(TTwdInitParams));
       
  3402 
       
  3403     iTwdCtrl.twdInitParams.tGeneral.packetDetectionThreshold = 0;
       
  3404     iTwdCtrl.twdInitParams.tGeneral.qosNullDataTemplateSize = sizeof(QosNullDataTemplate_t);
       
  3405     iTwdCtrl.twdInitParams.tGeneral.PsPollTemplateSize = sizeof(psPollTemplate_t);
       
  3406     iTwdCtrl.twdInitParams.tGeneral.probeResponseTemplateSize = sizeof(probeRspTemplate_t);
       
  3407     iTwdCtrl.twdInitParams.tGeneral.probeRequestTemplateSize = sizeof(probeReqTemplate_t);
       
  3408     iTwdCtrl.twdInitParams.tGeneral.beaconTemplateSize = sizeof(probeRspTemplate_t);
       
  3409     iTwdCtrl.twdInitParams.tGeneral.nullTemplateSize = sizeof(nullDataTemplate_t);
       
  3410     iTwdCtrl.twdInitParams.tGeneral.disconnTemplateSize = sizeof(disconnTemplate_t);
       
  3411     /* Beacon broadcast options */
       
  3412     iTwdCtrl.twdInitParams.tGeneral.BeaconRxTimeout           = BCN_RX_TIMEOUT_DEF_VALUE;
       
  3413     iTwdCtrl.twdInitParams.tGeneral.BroadcastRxTimeout        = BROADCAST_RX_TIMEOUT_DEF_VALUE;
       
  3414     iTwdCtrl.twdInitParams.tGeneral.RxBroadcastInPs           = RX_BROADCAST_IN_PS_DEF_VALUE;
       
  3415     iTwdCtrl.twdInitParams.tGeneral.ConsecutivePsPollDeliveryFailureThreshold = CONSECUTIVE_PS_POLL_FAILURE_DEF;
       
  3416 
       
  3417     iTwdCtrl.twdInitParams.tGeneral.halCtrlRxDisableBroadcast = TWD_RX_DISABLE_BROADCAST_DEF;
       
  3418     iTwdCtrl.twdInitParams.tGeneral.halCtrlCalibrationChannel2_4 = TWD_CALIBRATION_CHANNEL_2_4_DEF;
       
  3419     iTwdCtrl.twdInitParams.tGeneral.halCtrlCalibrationChannel5_0 = TWD_CALIBRATION_CHANNEL_5_0_DEF;
       
  3420 
       
  3421 
       
  3422     iTwdCtrl.twdInitParams.tGeneral.halCtrlRtsThreshold       = TWD_RTS_THRESHOLD_DEF;
       
  3423 
       
  3424 
       
  3425     iTwdCtrl.twdInitParams.tGeneral.WiFiWmmPS                 = WIFI_WMM_PS_DEF;
       
  3426 
       
  3427     iTwdCtrl.twdInitParams.tGeneral.halCtrlMaxTxMsduLifetime  = TWD_MAX_TX_MSDU_LIFETIME_DEF;  
       
  3428     iTwdCtrl.twdInitParams.tGeneral.halCtrlMaxRxMsduLifetime  = TWD_MAX_RX_MSDU_LIFETIME_DEF;  
       
  3429 
       
  3430     iTwdCtrl.twdInitParams.tGeneral.rxTimeOut.psPoll          = QOS_RX_TIMEOUT_PS_POLL_DEF;  
       
  3431     iTwdCtrl.twdInitParams.tGeneral.rxTimeOut.UPSD            =  QOS_RX_TIMEOUT_UPSD_DEF; 
       
  3432 
       
  3433     /* RSSI/SNR Weights for Average calculations */
       
  3434     iTwdCtrl.twdInitParams.tGeneral.uRssiBeaconAverageWeight  = TWD_RSSI_WEIGHT_DEF;
       
  3435     iTwdCtrl.twdInitParams.tGeneral.uRssiPacketAverageWeight  = TWD_RSSI_WEIGHT_DEF;
       
  3436     iTwdCtrl.twdInitParams.tGeneral.uSnrBeaconAverageWeight   = TWD_RSSI_WEIGHT_DEF;
       
  3437     iTwdCtrl.twdInitParams.tGeneral.uSnrPacketAverageWeight   = TWD_RSSI_WEIGHT_DEF;
       
  3438 
       
  3439     /* No used */
       
  3440     iTwdCtrl.twdInitParams.tGeneral.halCtrlFragThreshold      = TWD_FRAG_THRESHOLD_DEF;
       
  3441     iTwdCtrl.twdInitParams.tGeneral.halCtrlListenInterval = TWD_LISTEN_INTERVAL_DEF;
       
  3442     iTwdCtrl.twdInitParams.tGeneral.halCtrlRateFallbackRetry  =  TWD_RATE_FB_RETRY_LIMIT_DEF;       
       
  3443     iTwdCtrl.twdInitParams.tGeneral.halCtrlMacClock           = 80;     
       
  3444     iTwdCtrl.twdInitParams.tGeneral.halCtrlArmClock           = 80;     
       
  3445 
       
  3446     iTwdCtrl.twdInitParams.tGeneral.TxCompletePacingThreshold = TWD_TX_CMPLT_THRESHOLD_DEF;
       
  3447     iTwdCtrl.twdInitParams.tGeneral.TxCompletePacingTimeout   = TWD_TX_CMPLT_TIMEOUT_DEF;
       
  3448     iTwdCtrl.twdInitParams.tGeneral.RxIntrPacingThreshold     = TWD_RX_INTR_THRESHOLD_DEF;
       
  3449     iTwdCtrl.twdInitParams.tGeneral.RxIntrPacingTimeout       = TWD_RX_INTR_TIMEOUT_DEF;
       
  3450 
       
  3451 	/* FM Coexistence params */
       
  3452 	iTwdCtrl.twdInitParams.tGeneral.tFmCoexParams.uEnable	  		= FM_COEX_ENABLE_DEF;
       
  3453 	iTwdCtrl.twdInitParams.tGeneral.tFmCoexParams.uSwallowPeriod 	= FM_COEX_SWALLOW_PERIOD_DEF;
       
  3454 	iTwdCtrl.twdInitParams.tGeneral.tFmCoexParams.uNDividerFrefSet1	= FM_COEX_N_DIVIDER_FREF_SET1_DEF;
       
  3455 	iTwdCtrl.twdInitParams.tGeneral.tFmCoexParams.uNDividerFrefSet2 = FM_COEX_N_DIVIDER_FREF_SET2_DEF;
       
  3456 	iTwdCtrl.twdInitParams.tGeneral.tFmCoexParams.uMDividerFrefSet1 = FM_COEX_M_DIVIDER_FREF_SET1_DEF;
       
  3457 	iTwdCtrl.twdInitParams.tGeneral.tFmCoexParams.uMDividerFrefSet2 = FM_COEX_M_DIVIDER_FREF_SET2_DEF;
       
  3458 	iTwdCtrl.twdInitParams.tGeneral.tFmCoexParams.uCoexPllStabilizationTime = FM_COEX_PLL_STABILIZATION_TIME_DEF;
       
  3459 	iTwdCtrl.twdInitParams.tGeneral.tFmCoexParams.uLdoStabilizationTime	  	= FM_COEX_LDO_STABILIZATION_TIME_DEF;
       
  3460 	iTwdCtrl.twdInitParams.tGeneral.tFmCoexParams.uFmDisturbedBandMargin	= FM_COEX_DISTURBED_BAND_MARGIN_DEF;
       
  3461 	iTwdCtrl.twdInitParams.tGeneral.tFmCoexParams.uSwallowClkDif	  		= FM_COEX_SWALLOW_CLK_DIF_DEF;
       
  3462 
       
  3463 
       
  3464 	/* Configure ARP IP */
       
  3465 
       
  3466     iTwdCtrl.twdInitParams.tArpIpFilter.isFilterEnabled       = DEF_FILTER_ENABLE_VALUE;
       
  3467     // Compialtion problem     IP_COPY(iTwdCtrl.twdInitParams.tArpIpFilter.addr = "00 22 11 33 44 55");
       
  3468 
       
  3469 
       
  3470     /* Configure address group */
       
  3471     iTwdCtrl.twdInitParams.tMacAddrFilter.numOfMacAddresses   = NUM_GROUP_ADDRESS_VALUE_DEF; 
       
  3472     iTwdCtrl.twdInitParams.tMacAddrFilter.isFilterEnabled     = DEF_FILTER_ENABLE_VALUE;
       
  3473 #if 0
       
  3474     for (k = 0; k < pWlanParams->numGroupAddrs; k++)
       
  3475     {
       
  3476     	MAC_COPY (iTwdCtrl.twdInitParams.tMacAddrFilter.macAddrTable[k]); 
       
  3477     }
       
  3478 #endif
       
  3479 
       
  3480     /* QoS configure queue */
       
  3481     iTwdCtrl.twdInitParams.tGeneral.TxBlocksThresholdPerAc[0] = QOS_TX_BLKS_THRESHOLD_BE_DEF;
       
  3482     iTwdCtrl.twdInitParams.tGeneral.TxBlocksThresholdPerAc[1] = QOS_TX_BLKS_THRESHOLD_BK_DEF;
       
  3483     iTwdCtrl.twdInitParams.tGeneral.TxBlocksThresholdPerAc[2] = QOS_TX_BLKS_THRESHOLD_VI_DEF;
       
  3484     iTwdCtrl.twdInitParams.tGeneral.TxBlocksThresholdPerAc[3] = QOS_TX_BLKS_THRESHOLD_VO_DEF;
       
  3485 
       
  3486 
       
  3487 
       
  3488     /* Configure the MAC services */ 
       
  3489 
       
  3490     /* Power server */
       
  3491     iTwdCtrl.twdInitParams.tPowerSrv.hangOverPeriod           = HANGOVER_PERIOD_DEF_VALUE + 5; /* Increase the hang over time to 10ms */
       
  3492     iTwdCtrl.twdInitParams.tPowerSrv.numNullPktRetries        = POWER_MGMNT_NUM_NULL_PACKET_RETRY_DEF_VALUE;
       
  3493     /* Scan Server */
       
  3494     iTwdCtrl.twdInitParams.tScanSrv.numberOfNoScanCompleteToRecovery = SCAN_SRV_NUMBER_OF_NO_SCAN_COMPLETE_TO_RECOVERY_DEF;
       
  3495     iTwdCtrl.twdInitParams.tScanSrv.uTriggeredScanTimeOut     = SCAN_SRV_TRIGGERED_SCAN_TIME_OUT_DEF;
       
  3496     iTwdCtrl.TxAlign.uCurrSend = 0;
       
  3497     iTwdCtrl.TxAlign.uCurrHandle = 0;
       
  3498 
       
  3499     /* Configure the rate adaptaion */
       
  3500     iTwdCtrl.twdInitParams.tRateMngParams.InverseCuriosityFactor[0] = RATE_MGMT_INVERSE_CURIOSITY_FACTOR_OTHER;
       
  3501     iTwdCtrl.twdInitParams.tRateMngParams.InverseCuriosityFactor[1] = RATE_MGMT_INVERSE_CURIOSITY_FACTOR_VOICE;
       
  3502     iTwdCtrl.twdInitParams.tRateMngParams.MaxPer = RATE_MGMT_MAX_PER;
       
  3503     iTwdCtrl.twdInitParams.tRateMngParams.PerAdd = RATE_MGMT_PER_ADD;
       
  3504     iTwdCtrl.twdInitParams.tRateMngParams.PerAddShift = RATE_MGMT_PER_ADD_SHIFT;
       
  3505     iTwdCtrl.twdInitParams.tRateMngParams.PerAlphaShift = RATE_MGMT_PER_ALPHA_SHIFT;
       
  3506     iTwdCtrl.twdInitParams.tRateMngParams.PerBeta1Shift = RATE_MGMT_PER_BETA1_SHIFT;
       
  3507     iTwdCtrl.twdInitParams.tRateMngParams.PerBeta2Shift = RATE_MGMT_PER_BETA2_SHIFT;
       
  3508     iTwdCtrl.twdInitParams.tRateMngParams.PerTh1 = RATE_MGMT_PER_TH1;
       
  3509     iTwdCtrl.twdInitParams.tRateMngParams.PerTh2 = RATE_MGMT_PER_TH2;
       
  3510     iTwdCtrl.twdInitParams.tRateMngParams.RateCheckDown = RATE_MGMT_RATE_CHECK_DOWN;
       
  3511     iTwdCtrl.twdInitParams.tRateMngParams.RateCheckUp = RATE_MGMT_RATE_CHECK_UP;
       
  3512     
       
  3513     iTwdCtrl.twdInitParams.tRateMngParams.RateRetryPolicy[0] = 1;
       
  3514     iTwdCtrl.twdInitParams.tRateMngParams.RateRetryPolicy[1] = 1;
       
  3515     iTwdCtrl.twdInitParams.tRateMngParams.RateRetryPolicy[2] = 1;
       
  3516     iTwdCtrl.twdInitParams.tRateMngParams.RateRetryPolicy[3] = 3;
       
  3517     iTwdCtrl.twdInitParams.tRateMngParams.RateRetryPolicy[4] = 3;
       
  3518     iTwdCtrl.twdInitParams.tRateMngParams.RateRetryPolicy[5] = 3;
       
  3519     iTwdCtrl.twdInitParams.tRateMngParams.RateRetryPolicy[6] = 6;
       
  3520     iTwdCtrl.twdInitParams.tRateMngParams.RateRetryPolicy[7] = 6;
       
  3521     iTwdCtrl.twdInitParams.tRateMngParams.RateRetryPolicy[8] = 6;
       
  3522     iTwdCtrl.twdInitParams.tRateMngParams.RateRetryPolicy[9] = 6;
       
  3523     iTwdCtrl.twdInitParams.tRateMngParams.RateRetryPolicy[10] = 9;
       
  3524     iTwdCtrl.twdInitParams.tRateMngParams.RateRetryPolicy[11] = 9;
       
  3525     iTwdCtrl.twdInitParams.tRateMngParams.RateRetryPolicy[12] = 9;
       
  3526 
       
  3527     iTwdCtrl.twdInitParams.tRateMngParams.RateRetryScore = RATE_MGMT_RATE_RETRY_SCORE;
       
  3528     iTwdCtrl.twdInitParams.tRateMngParams.TxFailLowTh = RATE_MGMT_TX_FAIL_LOW_TH;
       
  3529     iTwdCtrl.twdInitParams.tRateMngParams.TxFailHighTh = RATE_MGMT_TX_FAIL_HIGH_TH;
       
  3530     iTwdCtrl.twdInitParams.tRateMngParams.PerWeightShift[0] = RATE_MGMT_PER_WEIGHT_SHIFT_OTHER;
       
  3531     iTwdCtrl.twdInitParams.tRateMngParams.PerWeightShift[1] = RATE_MGMT_PER_WEIGHT_SHIFT_VOICE;
       
  3532     iTwdCtrl.twdInitParams.tRateMngParams.TpWeightShift[0] = RATE_MGMT_TP_WEIGHT_SHIFT_OTHER;
       
  3533     iTwdCtrl.twdInitParams.tRateMngParams.TpWeightShift[1] = RATE_MGMT_TP_WEIGHT_SHIFT_VOICE;
       
  3534     iTwdCtrl.twdInitParams.tRateMngParams.paramIndex = RATE_MGMT_ALL_PARAMS;
       
  3535 
       
  3536     iTwdCtrl.twdInitParams.tDcoItrimParams.enable = TWD_DCO_ITRIM_ENABLE_DEF;
       
  3537     iTwdCtrl.twdInitParams.tDcoItrimParams.moderationTimeoutUsec = TWD_DCO_ITRIM_MODERATION_TIMEOUT_DEF;
       
  3538 }
       
  3539 /**
       
  3540 * \fn     InitTwdPlatformGenParam
       
  3541 * \brief  initialization Platform General parameters
       
  3542 *
       
  3543 * 
       
  3544 * /return 
       
  3545 */
       
  3546 
       
  3547 void  TIWha::InitTwdPlatformGenParam()
       
  3548 {
       
  3549   os_memoryCopy(iTwdCtrl.tOsContext.hOsa,&iTwdCtrl.twdInitParams.tPlatformGenParams,&iAutoRadioParams.tGeneralParams,sizeof(IniFileGeneralParam));
       
  3550 }
       
  3551 
       
  3552 
       
  3553 /**
       
  3554 * \fn     InitTwdRadioParam
       
  3555 * \brief  initialization of Radio params
       
  3556 * * /return 
       
  3557 */
       
  3558 
       
  3559 void TIWha::InitTwdRadioParam()
       
  3560 {
       
  3561   uint8 FemType;
       
  3562 
       
  3563   if (iAutoRadioParams.tGeneralParams.TXBiPFEMAutoDetect == FEM_MANUAL_DETECT_MODE_E)
       
  3564       FemType = iAutoRadioParams.tGeneralParams.TXBiPFEMManufacturer;
       
  3565   else
       
  3566       FemType = TWD_GetFEMType(iTwdCtrl.hTWD);
       
  3567   /* fill TWD init parms with relevant (RFMD or TriQuint) Radio parms before calling TWD_SetDefault*/
       
  3568    os_memoryCopy(iTwdCtrl.tOsContext.hOsa,&iTwdCtrl.twdInitParams.tIniFileRadioParams.tDynRadioParams,&iAutoRadioParams.tDynRadioParams[FemType],sizeof(TDynRadioParams));
       
  3569    os_memoryCopy(iTwdCtrl.tOsContext.hOsa,&iTwdCtrl.twdInitParams.tIniFileRadioParams.tStatRadioParams,&iAutoRadioParams.tStatRadioParams,sizeof(TStatRadioParams));
       
  3570 }
       
  3571 
       
  3572 
       
  3573 /**
       
  3574 * \fn     InitTwdRadioParam
       
  3575 * \brief  initialization of Radio params
       
  3576 * * /return 
       
  3577 */
       
  3578 
       
  3579 void TIWha::InitTwdRadioSmartReflexParam()
       
  3580 {
       
  3581     /* fill TWD init parms with relevant (RFMD or TriQuint) Radio parms before calling TWD_SetDefault*/
       
  3582    os_memoryCopy(iTwdCtrl.tOsContext.hOsa,&iTwdCtrl.twdInitParams.tSmartReflexParams.errorTable, &iSmartReflexParams.tErrorTable,sizeof(TSmartReflexErrTable));
       
  3583    os_memoryZero(iTwdCtrl.tOsContext.hOsa, &iSmartReflexDebugParams, sizeof(TSmartReflexDebugParams));
       
  3584    iTwdCtrl.twdInitParams.tSmartReflexState.enable = iSmartReflexParams.SmartReflexState;
       
  3585 }        
       
  3586 
       
  3587 
       
  3588 /**
       
  3589 * \fn     InitReportParamTable
       
  3590 * \brief  initialization of Report parameters
       
  3591 *
       
  3592 * since we ave no ini file, we are initializing the 
       
  3593 * Modules with hard coded values
       
  3594 * /note
       
  3595 * 
       
  3596 * /return 
       
  3597 */
       
  3598 void TIWha::InitReportParamTable()
       
  3599 {
       
  3600     /* Open All Modules and some severity */
       
  3601     iTwdCtrl.report_init.aSeverityTable [REPORT_SEVERITY_INIT]           = '0';
       
  3602     iTwdCtrl.report_init.aSeverityTable [REPORT_SEVERITY_INFORMATION]    = '0';	
       
  3603     iTwdCtrl.report_init.aSeverityTable [REPORT_SEVERITY_WARNING]        = '0';
       
  3604     iTwdCtrl.report_init.aSeverityTable [REPORT_SEVERITY_ERROR]          = '1';
       
  3605     iTwdCtrl.report_init.aSeverityTable [REPORT_SEVERITY_FATAL_ERROR]    = '1';
       
  3606     iTwdCtrl.report_init.aSeverityTable [REPORT_SEVERITY_SM]             = '0';
       
  3607     iTwdCtrl.report_init.aSeverityTable [REPORT_SEVERITY_CONSOLE]        = '0';
       
  3608     
       
  3609     for (TUint8 index = 0; index < REPORT_FILES_NUM; index++)
       
  3610     {
       
  3611     	iTwdCtrl.report_init.aFileEnable [index] = '1';
       
  3612     }
       
  3613 }
       
  3614 
       
  3615 /**
       
  3616 * \fn     OpenAllReports
       
  3617 * \brief  open all reports in report module. 
       
  3618 *
       
  3619 * Use this function if you encounter some problem in a specific area.
       
  3620 *
       
  3621 * /note Used for debug only.
       
  3622 * 
       
  3623 * /return 
       
  3624 */
       
  3625 void TIWha::OpenAllReports()
       
  3626 {
       
  3627     for (TUint8 index = 0; index < SIZE_ARR(iTwdCtrl.report_init.aSeverityTable); index++)
       
  3628     {
       
  3629         iTwdCtrl.report_init.aSeverityTable [index] = '1';    
       
  3630     }
       
  3631 
       
  3632     for (TUint8 index = 0; index < REPORT_FILES_NUM; index++)
       
  3633     {
       
  3634     	iTwdCtrl.report_init.aFileEnable [index] = '1';
       
  3635     }
       
  3636 
       
  3637     report_SetDefaults (iTwdCtrl.hReport, &(iTwdCtrl.report_init));
       
  3638 
       
  3639     TRACE0(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, "\n");
       
  3640 }
       
  3641 
       
  3642 
       
  3643 /** 
       
  3644  * \fn     RegisterCb
       
  3645  * \brief  registers the TIWha callbacks
       
  3646  * 
       
  3647  * Register callbacks To Twd level according to the action
       
  3648  * that we would like to be triggered on 
       
  3649  * 
       
  3650  * \note    
       
  3651  * \return  status whther the registration succeed or not.
       
  3652  * \sa      
       
  3653  */
       
  3654 WHA::TStatus TIWha::RegisterCb ()
       
  3655 {   
       
  3656     /* Register the failure event callback */
       
  3657     TWD_RegisterCb (iTwdCtrl.hTWD, 
       
  3658                     TWD_EVENT_FAILURE, 
       
  3659                 (TTwdCB *)TIWhaAdaptCB::FailureIndication, 
       
  3660                  this);
       
  3661 
       
  3662 	/* Register the send packet callback */
       
  3663 	TWD_RegisterCb (iTwdCtrl.hTWD,
       
  3664 					TWD_EVENT_TX_XFER_SEND_PKT_TRANSFER, 
       
  3665 					(TTwdCB *)TIWhaAdaptCB::TxXfer, 
       
  3666 					this);
       
  3667 
       
  3668 	/* Register the send complete packet callback */
       
  3669 	TWD_RegisterCb (iTwdCtrl.hTWD,
       
  3670 					TWD_EVENT_TX_RESULT_SEND_PKT_COMPLETE, 
       
  3671 					(TTwdCB *)TIWhaAdaptCB::TxComplete, 
       
  3672 					this);
       
  3673 
       
  3674 	/* Register the receive packet callback */
       
  3675 	TWD_RegisterCb (iTwdCtrl.hTWD,
       
  3676 					TWD_EVENT_RX_RECEIVE_PACKET, 
       
  3677 					(TTwdCB *)TIWhaAdaptCB::ReceivePacket, 
       
  3678 					this);
       
  3679 
       
  3680 	/* Register the request for buffer callback */
       
  3681 	TWD_RegisterCb (iTwdCtrl.hTWD,
       
  3682 					TWD_EVENT_RX_REQUEST_FOR_BUFFER, 
       
  3683 					(TTwdCB *)TIWhaAdaptCB::RequestForBuffer, 
       
  3684 					this);
       
  3685 
       
  3686     /* register scan SRV scan complete CB */
       
  3687     TWD_RegisterScanCompleteCb (iTwdCtrl.hTWD, 
       
  3688                                                 (TScanSrvCompleteCb)TIWhaAdaptCB::ScanComplete, this);
       
  3689 
       
  3690     return WHA::KSuccess;
       
  3691 }
       
  3692 
       
  3693 /** 
       
  3694  * \fn     RegisterEvents
       
  3695  * \brief  register the TIWha Events
       
  3696  * 
       
  3697  * Register callbacks To Twd level according to the event 
       
  3698  * that we would like to be triggered on 
       
  3699  * 
       
  3700  * \note    
       
  3701  * \return  status whther the registration succeed or not.
       
  3702  * \sa      
       
  3703  */
       
  3704 WHA::TStatus TIWha::RegisterEvents ()
       
  3705 {   
       
  3706 	/* Register the Regain BSS callback */
       
  3707 	TWD_RegisterEvent (iTwdCtrl.hTWD, 
       
  3708 					   TWD_OWN_EVENT_BSS_REGAIN, 
       
  3709 					   (void *)TIWhaAdaptCB::RegainBssIndication, 
       
  3710 					   this);
       
  3711 
       
  3712 	/* Register the RSSI callback */
       
  3713 	TWD_RegisterEvent (iTwdCtrl.hTWD, 
       
  3714 					   TWD_OWN_EVENT_RSSI_SNR_TRIGGER_0, //adi - rssi - use TWD_EVENT_RSSI_SNR_TRIGGER_0
       
  3715 					   (void *)TIWhaAdaptCB::RcpiIndication, 
       
  3716 					   this);  
       
  3717 	TWD_EnableEvent (iTwdCtrl.hTWD, TWD_OWN_EVENT_RSSI_SNR_TRIGGER_0);
       
  3718 #if 0
       
  3719 	assaf: no support
       
  3720 	TWD_RegisterEvent (iTwdCtrl.hTWD, 
       
  3721 					   TWD_EVENT_RSSI_LEVEL_REGAIN,	//adi - rssi - use TWD_EVENT_RSSI_SNR_TRIGGER_0 
       
  3722 					   (void *)TIWhaAdaptCB::RcpiIndication, 
       
  3723 					   this);
       
  3724 #endif
       
  3725 	/* Register & enable the Join callback */
       
  3726         TWD_RegisterEvent (iTwdCtrl.hTWD,  
       
  3727                                         TWD_OWN_EVENT_JOIN_CMPLT, 
       
  3728                                         (void *)TIWhaAdaptCB::JoinComplete, 
       
  3729                                         this);
       
  3730 
       
  3731 	TWD_EnableEvent (iTwdCtrl.hTWD, TWD_OWN_EVENT_JOIN_CMPLT);
       
  3732 
       
  3733 #if 0    
       
  3734 	assaf: no BT support
       
  3735 	/* Register the BtCoexsitence indications */
       
  3736 	TWD_RegisterEvent (iTwdCtrl.hTWD, 
       
  3737 					   TWD_EVENT_BT_COEX_SENSE, 
       
  3738 					   (void *)TIWhaAdaptCB::btCoexSenseIndication, 
       
  3739 					   this);       
       
  3740 
       
  3741 	TWD_RegisterEvent (iTwdCtrl.hTWD, 
       
  3742 					   TWD_EVENT_BT_COEX_PROTECTIVE_MODE, 
       
  3743 					   (void *)TIWhaAdaptCB::btCoexProtectiveIndication, 
       
  3744 					   this);        
       
  3745 
       
  3746 	TWD_RegisterEvent (iTwdCtrl.hTWD, 
       
  3747 					   TWD_EVENT_BT_COEX_AVALANCHE, 
       
  3748 					   (void *)TIWhaAdaptCB::btCoexAvalancheIndication, 
       
  3749 					   this);       
       
  3750 #endif
       
  3751 	/* Roaming Triggers */
       
  3752 	TWD_RegisterEvent (iTwdCtrl.hTWD,
       
  3753 					   TWD_OWN_EVENT_BSS_LOSE,
       
  3754 					   (void *)TIWhaAdaptCB::LostBssIndication,
       
  3755 					   this);
       
  3756 
       
  3757 	TWD_EnableEvent (iTwdCtrl.hTWD, TWD_OWN_EVENT_BSS_LOSE);
       
  3758 
       
  3759 
       
  3760 
       
  3761 	return WHA::KSuccess;
       
  3762 }
       
  3763 
       
  3764  
       
  3765 
       
  3766  
       
  3767 /**
       
  3768 * \fn     FillNWSASettings
       
  3769 * \brief  Fill UMAC structure with correct settings
       
  3770 *
       
  3771 * since we ave no ini file, we are initializing the 
       
  3772 * Modules wit hard coded values
       
  3773 * \note
       
  3774 * 
       
  3775 * \param SNWSASettings - pointer pointer to the UMAC settings struct
       
  3776 * \return status
       
  3777 */
       
  3778 WHA::TStatus TIWha::FillNWSASettings (WHA::SSettings *SNWSASettings)
       
  3779 {
       
  3780 #ifdef HT_SUPPORT
       
  3781 	TTwdHtCapabilities* pTwdHtCapabilities;
       
  3782 #endif /* HT_SUPPORT */
       
  3783     TRACE0(iTwdCtrl.hReport, REPORT_SEVERITY_INIT, "FillNWSASettings +");
       
  3784     
       
  3785     /* Fill all the parameters in the NWSA Settings */
       
  3786     SNWSASettings->iNumOfSSIDs              = TIWha_SCAN_MAX_SSID_NUM;        
       
  3787     SNWSASettings->iRxBufAlignment          = TIWha_NO_BUFFER_ALIGNMENT_SETTING; /* no alignment is needed */
       
  3788     SNWSASettings->iNumOfBytesForSsid       = TIWha_MAX_SSID_LEN;            
       
  3789     SNWSASettings->iRates                   = TIWha_RATE_BIT_MASK_SUPPORT;               
       
  3790     SNWSASettings->iBand                    = TIWha_BAND_BIT_MASK_SUPPORT;                                           
       
  3791     SNWSASettings->iRxoffset                = WSPI_PAD_LEN_READ + sizeof(RxIfDescriptor_t);
       
  3792     SNWSASettings->iNumOfGroupTableEntrys   = ADDRESS_GROUP_MAX;        
       
  3793     SNWSASettings->iNumOfTxRateClasses      = MAX_NUM_OF_TX_RATE_CLASS_POLICIES;    
       
  3794     SNWSASettings->iTxFrameTrailerSpace     = 0;   
       
  3795     SNWSASettings->iTxFrameHeaderSpace      = TX_TOTAL_OFFSET_BEFORE_DATA;  
       
  3796     SNWSASettings->iFlagsMask               = TIWha_RECEIVE_PACKET_BIT_MASK_SUPPORT; 
       
  3797     SNWSASettings->iCapability              = TIWha_CAPABILITY_BIT_MASK_SUPPORT; 
       
  3798 
       
  3799 #ifdef GEM_SUPPORT
       
  3800 	SNWSASettings->iCapability				|= TIWha_CAPABILITY_GEM_SUPPORT;
       
  3801 #endif /* GEM_SUPPORT */
       
  3802 
       
  3803 #ifdef MB_ENABLE
       
  3804 	SNWSASettings->iCapability				|= TIWha_CAPABILITY_MB_SUPPORT;
       
  3805 #endif
       
  3806 
       
  3807 #ifdef HT_SUPPORT
       
  3808 	SNWSASettings->iCapability |= TIWha_CAPABILITY_HT_OPERATION;	
       
  3809 #endif /* HT_SUPPORT */
       
  3810 
       
  3811     SNWSASettings->iCapability |= TIWha_CAPABILITY_AUTO_RATE;
       
  3812 
       
  3813     /* Add DS Parameters -- Allow only APs from the requested channel 
       
  3814     to answer the probe increase scan result in crowded environment */
       
  3815     
       
  3816     //SNWSASettings->iCapability |= WHA::SSettings::KDsParamSetIeInProbe;
       
  3817 
       
  3818     /* Tx power level for each radio band  */
       
  3819     TFwInfo *pFwInfo = TWD_GetFWInfo (iTwdCtrl.hTWD);
       
  3820 
       
  3821     /* 
       
  3822      * 2.4 GHz
       
  3823      * in txPowerTable[x][y]: x - 0 for 2.4GHz, y - power level starting from 0 to NUM_POWER_LEVELS - 1 
       
  3824      */ 
       
  3825     SNWSASettings->iTxPowerRange[0].iMaxPowerLevel = 
       
  3826         pFwInfo->txPowerTable[RADIO_BAND_2_4_GHZ][0] / DBM_TO_TX_POWER_FACTOR;
       
  3827     SNWSASettings->iTxPowerRange[0].iMinPowerLevel = 
       
  3828         pFwInfo->txPowerTable[RADIO_BAND_2_4_GHZ][NUM_POWER_LEVELS - 1] / DBM_TO_TX_POWER_FACTOR;
       
  3829     SNWSASettings->iTxPowerRange[0].iStepping = 0;           
       
  3830 
       
  3831     TRACE3(iTwdCtrl.hReport, REPORT_SEVERITY_INFORMATION, ": 2.4 iMaxPowerLevel = %d iMinPowerLevel = %d stepping = %d\n",    						    SNWSASettings->iTxPowerRange[0].iMaxPowerLevel,                                          SNWSASettings->iTxPowerRange[0].iMinPowerLevel,                                          SNWSASettings->iTxPowerRange[0].iStepping);
       
  3832 
       
  3833     /* 4.9 GHZ temporary not supported for the power level */
       
  3834     SNWSASettings->iTxPowerRange[1].iMaxPowerLevel = 0;
       
  3835     SNWSASettings->iTxPowerRange[1].iMinPowerLevel = 0;
       
  3836     SNWSASettings->iTxPowerRange[1].iStepping = 0;          
       
  3837 
       
  3838     /* 5.0 GHZ temporary not supported for the power level since there are 4 sub-bands */
       
  3839     SNWSASettings->iTxPowerRange[2].iMaxPowerLevel  = 0;
       
  3840     SNWSASettings->iTxPowerRange[2].iMinPowerLevel = 0;
       
  3841     SNWSASettings->iTxPowerRange[2].iStepping = 0; 
       
  3842 
       
  3843 #ifdef HT_SUPPORT
       
  3844 	TWD_GetTwdHtCapabilities (iTwdCtrl.hTWD,&pTwdHtCapabilities);
       
  3845 	TConvertTwdHtCapa2SHtCapa (pTwdHtCapabilities,&SNWSASettings->iHtCapabilities);
       
  3846 #endif /* HT_SUPPORT */
       
  3847 
       
  3848     return WHA::KSuccess;
       
  3849 }
       
  3850 
       
  3851 
       
  3852 /****************************************************************************
       
  3853  *                     FillRadioData
       
  3854  ****************************************************************************
       
  3855  * DESCRIPTION: fill Radio params , in future will be done by Radio scope
       
  3856  * 
       
  3857  * INPUTS:   
       
  3858  * 
       
  3859  * OUTPUT:  radio params
       
  3860  * 
       
  3861  * RETURNS: OK
       
  3862  ****************************************************************************/
       
  3863 void TIWha::FillRadioData()
       
  3864 {
       
  3865    
       
  3866    iAutoRadioParams.tGeneralParams.TXBiPFEMAutoDetect = FEM_AUTO_DETECT_MODE_E;
       
  3867    iAutoRadioParams.tGeneralParams.TXBiPFEMManufacturer = FEM_TRIQUINT_TYPE_E;   
       
  3868 
       
  3869    iAutoRadioParams.tGeneralParams.RefClk = eREF_CLK_38_4_E;                                 
       
  3870    iAutoRadioParams.tGeneralParams.SettlingTime = 5;                                                                 
       
  3871    iAutoRadioParams.tGeneralParams.ClockValidOnWakeup = REF_CLK_NOT_VALID_E;                      
       
  3872    iAutoRadioParams.tGeneralParams.DC2DCMode = BT_SPI_IS_NOT_USED_E;                               
       
  3873    iAutoRadioParams.tGeneralParams.Single_Dual_Band_Solution = SINGLE_BAND_SOLUTION_E;  
       
  3874       
       
  3875    iAutoRadioParams.tStatRadioParams.RxTraceInsertionLoss_2_4G = 0;
       
  3876    iAutoRadioParams.tStatRadioParams.TXTraceLoss_2_4G  = 0;
       
  3877    iAutoRadioParams.tStatRadioParams.RxRssiAndProcessCompensation_2_4G[0] = 0xEC;
       
  3878    iAutoRadioParams.tStatRadioParams.RxRssiAndProcessCompensation_2_4G[1] = 0xF6;
       
  3879    iAutoRadioParams.tStatRadioParams.RxRssiAndProcessCompensation_2_4G[2] = 0x00;
       
  3880    iAutoRadioParams.tStatRadioParams.RxRssiAndProcessCompensation_2_4G[3] = 0x0C;
       
  3881    iAutoRadioParams.tStatRadioParams.RxRssiAndProcessCompensation_2_4G[4] = 0x18;
       
  3882    iAutoRadioParams.tStatRadioParams.RxRssiAndProcessCompensation_2_4G[5] = 0xF8;
       
  3883    iAutoRadioParams.tStatRadioParams.RxRssiAndProcessCompensation_2_4G[6] = 0xFC;
       
  3884    iAutoRadioParams.tStatRadioParams.RxRssiAndProcessCompensation_2_4G[7] = 0x00;
       
  3885    iAutoRadioParams.tStatRadioParams.RxRssiAndProcessCompensation_2_4G[8] = 0x08;
       
  3886    iAutoRadioParams.tStatRadioParams.RxRssiAndProcessCompensation_2_4G[9] = 0x10;
       
  3887    iAutoRadioParams.tStatRadioParams.RxRssiAndProcessCompensation_2_4G[10] = 0xF0;
       
  3888    iAutoRadioParams.tStatRadioParams.RxRssiAndProcessCompensation_2_4G[11] = 0xF8;
       
  3889    iAutoRadioParams.tStatRadioParams.RxRssiAndProcessCompensation_2_4G[12] = 0x00;
       
  3890    iAutoRadioParams.tStatRadioParams.RxRssiAndProcessCompensation_2_4G[13] = 0x0A;
       
  3891    iAutoRadioParams.tStatRadioParams.RxRssiAndProcessCompensation_2_4G[14] = 0x14;
       
  3892    memset(&iAutoRadioParams.tStatRadioParams.RxTraceInsertionLoss_5G[0],0,NUMBER_OF_SUB_BANDS_IN_5G_BAND_E);
       
  3893    memset(&iAutoRadioParams.tStatRadioParams.TXTraceLoss_5G[0],0,NUMBER_OF_SUB_BANDS_IN_5G_BAND_E);
       
  3894    memset(&iAutoRadioParams.tStatRadioParams.RxRssiAndProcessCompensation_5G[0],0,RSSI_AND_PROCESS_COMPENSATION_TABLE_SIZE); 
       
  3895 
       
  3896 /* RMFD deafult value */
       
  3897    if (iAutoRadioParams.tGeneralParams.Single_Dual_Band_Solution == DUAL_BAND_SOLUTION_E)
       
  3898    {
       
  3899    
       
  3900     iAutoRadioParams.tDynRadioParams[0].TXBiPReferencePDvoltage_2_4G = 0 ;									
       
  3901     iAutoRadioParams.tDynRadioParams[0].TxBiPReferencePower_2_4G = 0;																				
       
  3902     iAutoRadioParams.tDynRadioParams[0].TxBiPOffsetdB_2_4G = 0;																							
       
  3903     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_2_4G_Normal[0] = 0x1E;
       
  3904     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_2_4G_Normal[1] = 0x1F;
       
  3905     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_2_4G_Normal[2] = 0x22;
       
  3906     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_2_4G_Normal[3] = 0x24;
       
  3907     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_2_4G_Normal[4] = 0x28;
       
  3908     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_2_4G_Normal[5] = 0x29;							
       
  3909     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_2_4G_Degraded[0] = 0x1B;
       
  3910     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_2_4G_Degraded[1] = 0x1C;
       
  3911     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_2_4G_Degraded[2] = 0x1E;
       
  3912     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_2_4G_Degraded[3] = 0x20;
       
  3913     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_2_4G_Degraded[4] = 0x24;
       
  3914     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_2_4G_Degraded[5] = 0x25;							
       
  3915     for (int i=0; i<NUMBER_OF_2_4_G_CHANNELS;i++)
       
  3916     {
       
  3917         iAutoRadioParams.tDynRadioParams[0].TxPerChannelPowerLimits_2_4G_11b[i] = 0x50;
       
  3918         iAutoRadioParams.tDynRadioParams[0].TxPerChannelPowerLimits_2_4G_OFDM[i] = 0x50;
       
  3919     }
       
  3920        
       
  3921     iAutoRadioParams.tDynRadioParams[0].TxPerChannelPowerLimits_2_4G_OFDM[0] = 0x20;
       
  3922     iAutoRadioParams.tDynRadioParams[0].TxPerChannelPowerLimits_2_4G_OFDM[10] = 0x20;
       
  3923     memset(&iAutoRadioParams.tDynRadioParams[0].TxPDVsRateOffsets_2_4G[0],0,NUMBER_OF_RATE_GROUPS_E);												
       
  3924      for (int i=0; i<NUMBER_OF_RATE_GROUPS_E;i++)
       
  3925     {
       
  3926         iAutoRadioParams.tDynRadioParams[0].TxIbiasTable_2_4G[i] = 0x0E;
       
  3927     }
       
  3928        iAutoRadioParams.tDynRadioParams[0].TxIbiasTable_2_4G[5] = 0x17;
       
  3929     iAutoRadioParams.tDynRadioParams[0].RxFemInsertionLoss_2_4G = 0x0D;																			
       
  3930 
       
  3931        // SECTION 2: 5G parameters
       
  3932     memset(&iAutoRadioParams.tDynRadioParams[0].TXBiPReferencePDvoltage_5G[0],0,NUMBER_OF_RATE_GROUPS_E);
       
  3933     memset(&iAutoRadioParams.tDynRadioParams[0].TxBiPReferencePower_5G[0],0,NUMBER_OF_RATE_GROUPS_E);				
       
  3934     memset(&iAutoRadioParams.tDynRadioParams[0].TxBiPOffsetdB_5G[0],0,NUMBER_OF_RATE_GROUPS_E);								
       
  3935     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_5G_Normal[0] = 0x1D;
       
  3936     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_5G_Normal[1] = 0x1E;
       
  3937     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_5G_Normal[2] = 0x21;
       
  3938     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_5G_Normal[3] = 0x23;
       
  3939     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_5G_Normal[4] = 0x27;
       
  3940     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_5G_Normal[5] = 0;							
       
  3941     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_5G_Degraded[0]= 0x1A;
       
  3942     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_5G_Degraded[1] = 0x1B;
       
  3943     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_5G_Degraded[2] = 0x1D;
       
  3944     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_5G_Degraded[3] = 0x1F;
       
  3945     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_5G_Degraded[4] = 0x23;
       
  3946     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_5G_Degraded[5] = 0x00;						
       
  3947     memset(&iAutoRadioParams.tDynRadioParams[0].TxPerChannelPowerLimits_5G_OFDM[0],0,NUMBER_OF_5G_CHANNELS);                         
       
  3948     memset(&iAutoRadioParams.tDynRadioParams[0].TxPDVsRateOffsets_5G[0],0,NUMBER_OF_RATE_GROUPS_E);										
       
  3949     for (int i=0;i<NUMBER_OF_RATE_GROUPS_E;i++)
       
  3950     {
       
  3951         iAutoRadioParams.tDynRadioParams[0].TxIbiasTable_5G[i] = 0x27;
       
  3952         iAutoRadioParams.tDynRadioParams[0].RxFemInsertionLoss_5G[i] = 0x12;
       
  3953     }
       
  3954     
       
  3955     iAutoRadioParams.tDynRadioParams[0].TxIbiasTable_5G[5] = 0;
       
  3956     								
       
  3957    }
       
  3958    else
       
  3959    {
       
  3960     iAutoRadioParams.tDynRadioParams[0].TXBiPReferencePDvoltage_2_4G =0x24E ;									
       
  3961     iAutoRadioParams.tDynRadioParams[0].TxBiPReferencePower_2_4G = 0x78;																				
       
  3962     iAutoRadioParams.tDynRadioParams[0].TxBiPOffsetdB_2_4G = 0;																							
       
  3963     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_2_4G_Normal[0] = 0x1E;
       
  3964     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_2_4G_Normal[1] = 0x1F;
       
  3965     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_2_4G_Normal[2] = 0x22;
       
  3966     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_2_4G_Normal[3] = 0x24;
       
  3967     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_2_4G_Normal[4] = 0x28;
       
  3968     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_2_4G_Normal[5] = 0x29;							
       
  3969     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_2_4G_Degraded[0] = 0x1B;
       
  3970     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_2_4G_Degraded[1] = 0x1C;
       
  3971     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_2_4G_Degraded[2] = 0x1E;
       
  3972     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_2_4G_Degraded[3] = 0x20;
       
  3973     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_2_4G_Degraded[4] = 0x24;
       
  3974     iAutoRadioParams.tDynRadioParams[0].TxPerRatePowerLimits_2_4G_Degraded[5] = 0x25;							
       
  3975     for (int i =0;i<NUMBER_OF_2_4_G_CHANNELS;i++)
       
  3976     {
       
  3977         iAutoRadioParams.tDynRadioParams[0].TxPerChannelPowerLimits_2_4G_11b[i] = 0x50;
       
  3978         iAutoRadioParams.tDynRadioParams[0].TxPerChannelPowerLimits_2_4G_OFDM[i] = 0x50;
       
  3979     }
       
  3980     iAutoRadioParams.tDynRadioParams[0].TxPerChannelPowerLimits_2_4G_OFDM[0] = 0x20;
       
  3981     iAutoRadioParams.tDynRadioParams[0].TxPerChannelPowerLimits_2_4G_OFDM[10] = 0x20;   
       
  3982     memset(&iAutoRadioParams.tDynRadioParams[0].TxPDVsRateOffsets_2_4G[0],0,NUMBER_OF_RATE_GROUPS_E);	
       
  3983     for (int i = 0 ;i <NUMBER_OF_RATE_GROUPS_E;i++) 
       
  3984     {
       
  3985         iAutoRadioParams.tDynRadioParams[0].TxIbiasTable_2_4G[i] = 0x1A;
       
  3986     }
       
  3987    
       
  3988     iAutoRadioParams.tDynRadioParams[0].TxIbiasTable_2_4G[5] = 0x2F;
       
  3989     iAutoRadioParams.tDynRadioParams[0].RxFemInsertionLoss_2_4G = 0;	
       
  3990 
       
  3991 /* TriQuint default value */
       
  3992     iAutoRadioParams.tDynRadioParams[1].TXBiPReferencePDvoltage_2_4G= 0x168;									
       
  3993     iAutoRadioParams.tDynRadioParams[1].TxBiPReferencePower_2_4G= 0x83;																				
       
  3994     iAutoRadioParams.tDynRadioParams[1].TxBiPOffsetdB_2_4G=0;																							
       
  3995     iAutoRadioParams.tDynRadioParams[1].TxPerRatePowerLimits_2_4G_Normal[0] = 0x1E;
       
  3996     iAutoRadioParams.tDynRadioParams[1].TxPerRatePowerLimits_2_4G_Normal[1] = 0x1F;
       
  3997     iAutoRadioParams.tDynRadioParams[1].TxPerRatePowerLimits_2_4G_Normal[2] = 0x22;
       
  3998     iAutoRadioParams.tDynRadioParams[1].TxPerRatePowerLimits_2_4G_Normal[3] = 0x24;
       
  3999     iAutoRadioParams.tDynRadioParams[1].TxPerRatePowerLimits_2_4G_Normal[4] = 0x28;
       
  4000     iAutoRadioParams.tDynRadioParams[1].TxPerRatePowerLimits_2_4G_Normal[5] = 0x29;							
       
  4001     iAutoRadioParams.tDynRadioParams[1].TxPerRatePowerLimits_2_4G_Degraded[0] = 0x1B;
       
  4002     iAutoRadioParams.tDynRadioParams[1].TxPerRatePowerLimits_2_4G_Degraded[1] = 0x1C;
       
  4003     iAutoRadioParams.tDynRadioParams[1].TxPerRatePowerLimits_2_4G_Degraded[2] = 0x1E;
       
  4004     iAutoRadioParams.tDynRadioParams[1].TxPerRatePowerLimits_2_4G_Degraded[3] = 0x20;
       
  4005     iAutoRadioParams.tDynRadioParams[1].TxPerRatePowerLimits_2_4G_Degraded[4] = 0x24;
       
  4006     iAutoRadioParams.tDynRadioParams[1].TxPerRatePowerLimits_2_4G_Degraded[5] = 0x25;	
       
  4007     for (int i =0;i<NUMBER_OF_2_4_G_CHANNELS;i++)
       
  4008     {
       
  4009         iAutoRadioParams.tDynRadioParams[1].TxPerChannelPowerLimits_2_4G_11b[i] = 0x50;
       
  4010         iAutoRadioParams.tDynRadioParams[1].TxPerChannelPowerLimits_2_4G_OFDM[i] = 0x50;
       
  4011     }
       
  4012     iAutoRadioParams.tDynRadioParams[1].TxPerChannelPowerLimits_2_4G_OFDM[0] = 0x20;
       
  4013     iAutoRadioParams.tDynRadioParams[1].TxPerChannelPowerLimits_2_4G_OFDM[10] = 0x20;  
       
  4014     memset(&iAutoRadioParams.tDynRadioParams[1].TxPDVsRateOffsets_2_4G[0],0,NUMBER_OF_RATE_GROUPS_E); 
       
  4015      for (int i = 0 ;i <NUMBER_OF_RATE_GROUPS_E;i++) 
       
  4016     {
       
  4017         iAutoRadioParams.tDynRadioParams[1].TxIbiasTable_2_4G[i] = 0x11;
       
  4018     }
       
  4019   
       
  4020     iAutoRadioParams.tDynRadioParams[1].TxIbiasTable_2_4G[5] = 0x12; 													
       
  4021     iAutoRadioParams.tDynRadioParams[1].RxFemInsertionLoss_2_4G = 0x12;  
       
  4022    }
       
  4023 }
       
  4024 
       
  4025 void TIWha::FillSmartReflexData()
       
  4026 {
       
  4027     iSmartReflexParams.SmartReflexState = 0;
       
  4028 
       
  4029     iSmartReflexParams.tErrorTable[0].len = 7;
       
  4030     iSmartReflexParams.tErrorTable[0].upperLimit = 3;
       
  4031     iSmartReflexParams.tErrorTable[0].values[0] = 24;
       
  4032     iSmartReflexParams.tErrorTable[0].values[1] = 16;
       
  4033     iSmartReflexParams.tErrorTable[0].values[2] = 5;
       
  4034     iSmartReflexParams.tErrorTable[0].values[3] = -5;
       
  4035     iSmartReflexParams.tErrorTable[0].values[4] = -16;
       
  4036     iSmartReflexParams.tErrorTable[0].values[5] = -24;
       
  4037     iSmartReflexParams.tErrorTable[1].len = 7;
       
  4038     iSmartReflexParams.tErrorTable[1].upperLimit = 3;
       
  4039     iSmartReflexParams.tErrorTable[1].values[0] = 24;
       
  4040     iSmartReflexParams.tErrorTable[1].values[1] = 16;
       
  4041     iSmartReflexParams.tErrorTable[1].values[2] = 5;
       
  4042     iSmartReflexParams.tErrorTable[1].values[3] = -5;
       
  4043     iSmartReflexParams.tErrorTable[1].values[4] = -16;
       
  4044     iSmartReflexParams.tErrorTable[1].values[5] = -24;
       
  4045     iSmartReflexParams.tErrorTable[2].len = 7;
       
  4046     iSmartReflexParams.tErrorTable[2].upperLimit = 3;   
       
  4047     iSmartReflexParams.tErrorTable[2].values[0] = 24;
       
  4048     iSmartReflexParams.tErrorTable[2].values[1] = 16;
       
  4049     iSmartReflexParams.tErrorTable[2].values[2] = 5;
       
  4050     iSmartReflexParams.tErrorTable[2].values[3] = -5;
       
  4051     iSmartReflexParams.tErrorTable[2].values[4] = -16;
       
  4052     iSmartReflexParams.tErrorTable[2].values[5] = -24;
       
  4053 }
       
  4054 
       
  4055 #if TI_DBG
       
  4056 /****************************************************************************
       
  4057  *                     PrintRadioData
       
  4058  ****************************************************************************
       
  4059  * DESCRIPTION: print Radio params , used for debug
       
  4060  * 
       
  4061  * INPUTS:   
       
  4062  * 
       
  4063  * OUTPUT:  radio params
       
  4064  * 
       
  4065  * RETURNS: OK
       
  4066  ****************************************************************************/
       
  4067 void TIWha::PrintRadioData()
       
  4068 {
       
  4069     TI_UINT32 i,j;
       
  4070     TI_UINT8* pRadio;
       
  4071 
       
  4072     pRadio = reinterpret_cast<TI_UINT8*>(&iAutoRadioParams); 
       
  4073 
       
  4074     i=0;
       
  4075 	os_printf("/**********************/ \n");
       
  4076 	os_printf("/* INI General params */ \n");
       
  4077 	os_printf("/**********************/ \n");
       
  4078 
       
  4079 	os_printf("0x%x, /* RefClk */ \n",						pRadio[i++]);
       
  4080 	os_printf("0x%x, /* SettlingTime */ \n",				pRadio[i++]);
       
  4081 	os_printf("0x%x, /* ClockValidOnWakeup */ \n",			pRadio[i++]);
       
  4082 	os_printf("0x%x, /* DC2DCMode */ \n",					pRadio[i++]);
       
  4083 	os_printf("0x%x, /* Single_Dual_Band_Solution */ \n",	pRadio[i++]);
       
  4084 	os_printf("0x%x, /* TXBiPFEMAutoDetect */ \n",			pRadio[i++]);
       
  4085 	os_printf("0x%x, /* TXBiPFEMManufacturer */ \n",		pRadio[i++]);
       
  4086 	os_printf("0x%x, /* Padding */ \n",					pRadio[i++]);
       
  4087 	
       
  4088 	os_printf("/*************************/ \n");
       
  4089 	os_printf("/* INI Stat Radio params */ \n");
       
  4090 	os_printf("/*************************/ \n");
       
  4091 	
       
  4092 	os_printf("0x%x, /* RxTraceInsertionLoss_2_4G */ \n",	pRadio[i++]);
       
  4093 	os_printf("0x%x, /* TXTraceLoss_2_4G */ \n",			pRadio[i++]);
       
  4094 	for (j=0;j<15;j++)
       
  4095 		os_printf("0x%x, ", pRadio[i++]);
       
  4096 	os_printf("/* RxRssiAndProcessCompensation_2_4G[15] */ \n");
       
  4097 	for (j=0;j<7;j++)
       
  4098 		os_printf("0x%x, ", pRadio[i++]);
       
  4099 	os_printf("/* RxTraceInsertionLoss_5G[7] */ \n");
       
  4100 	for (j=0;j<7;j++)
       
  4101 		os_printf("0x%x, ", pRadio[i++]);
       
  4102 	os_printf("/* TXTraceLoss_5G[7] */ \n");
       
  4103 	for (j=0;j<15;j++)
       
  4104 		os_printf("0x%x, ", pRadio[i++]);
       
  4105 	os_printf("/* RxRssiAndProcessCompensation_5G[15] */ \n");
       
  4106 
       
  4107 	os_printf("/*******************************/ \n");
       
  4108 	os_printf("/* Dyn Radio Params. First FEM */ \n");
       
  4109 	os_printf("/*******************************/ \n");
       
  4110 	
       
  4111 	os_printf("0x%x, ", pRadio[i++]);
       
  4112 	os_printf("0x%x, /* TXBiPReferencePDvoltage_2_4G */ \n", pRadio[i++]);
       
  4113 	os_printf("0x%x, /* TxBiPReferencePower_2_4G */ \n",	pRadio[i++]);
       
  4114 	os_printf("0x%x, /* TxBiPOffsetdB_2_4G */ \n",			pRadio[i++]);
       
  4115 	for (j=0;j<6;j++)
       
  4116 		os_printf("0x%x, ", pRadio[i++]);
       
  4117 	os_printf("/* TxPerRatePowerLimits_2_4G_Normal[6] */ \n");
       
  4118 	for (j=0;j<6;j++)
       
  4119 		os_printf("0x%x, ", pRadio[i++]);
       
  4120 	os_printf("/* TxPerRatePowerLimits_2_4G_Degraded[6] */ \n");
       
  4121 	for (j=0;j<14;j++)
       
  4122 		os_printf("0x%x, ", pRadio[i++]);
       
  4123 	os_printf("/* TxPerChannelPowerLimits_2_4G_11b[14] */ \n");
       
  4124 	for (j=0;j<14;j++)
       
  4125 		os_printf("0x%x, ", pRadio[i++]);
       
  4126 	os_printf("/* TxPerChannelPowerLimits_2_4G_OFDM[14] */ \n");
       
  4127 	for (j=0;j<6;j++)
       
  4128 		os_printf("0x%x, ", pRadio[i++]);
       
  4129 	os_printf("/* TxPDVsRateOffsets_2_4G[6] */ \n");
       
  4130 	for (j=0;j<6;j++)
       
  4131 		os_printf("0x%x, ", pRadio[i++]);
       
  4132 	os_printf("/* TxIbiasTable_2_4G[6] */ \n");
       
  4133 	os_printf("0x%x, /* RxFemInsertionLoss_2_4G */ \n",			pRadio[i++]);
       
  4134 	for (j=0;j<35;j++)
       
  4135 		os_printf("0x%x, ", pRadio[i++]);
       
  4136 	os_printf("/* TxPerChannelPowerLimits_5G_OFDM[35] */ \n");
       
  4137 	for (j=0;j<14;j++)
       
  4138 		os_printf("0x%x, ", pRadio[i++]);		
       
  4139 	os_printf("/* TXBiPReferencePDvoltage_5G[7*2] */ \n");
       
  4140 	for (j=0;j<7;j++)
       
  4141 		os_printf("0x%x, ", pRadio[i++]);
       
  4142 	os_printf("/* TxBiPReferencePower_5G[7] */ \n");
       
  4143 	for (j=0;j<7;j++)
       
  4144 		os_printf("0x%x, ", pRadio[i++]);
       
  4145 	os_printf("/* TxBiPOffsetdB_5G[7] */ \n");
       
  4146 	for (j=0;j<6;j++)
       
  4147 		os_printf("0x%x, ", pRadio[i++]);
       
  4148 	os_printf("/* TxPerRatePowerLimits_5G_Normal[6] */ \n");
       
  4149 	for (j=0;j<6;j++)
       
  4150 		os_printf("0x%x, ", pRadio[i++]);
       
  4151 	os_printf("/* TxPerRatePowerLimits_5G_Degraded[6] */ \n");	
       
  4152 	for (j=0;j<6;j++)
       
  4153 		os_printf("0x%x, ", pRadio[i++]);
       
  4154 	os_printf("/* TxPDVsRateOffsets_5G[6] */ \n");
       
  4155 	for (j=0;j<6;j++)
       
  4156 		os_printf("0x%x, ", pRadio[i++]);
       
  4157 	os_printf("/* TxIbiasTable_5G[6] */ \n");
       
  4158 	for (j=0;j<7;j++)
       
  4159 		os_printf("0x%x, ", pRadio[i++]);
       
  4160 	os_printf("/* RxFemInsertionLoss_5G[7] */ \n");
       
  4161 	os_printf("0x%x, /* Padding */ \n",					pRadio[i++]);
       
  4162 
       
  4163 	os_printf("/************************************/ \n");
       
  4164 	os_printf("/* INI Dyn Radio Params. Second FEM */ \n");
       
  4165 	os_printf("/************************************/ \n");
       
  4166 	
       
  4167 	os_printf("0x%x, ", pRadio[i++]);	
       
  4168 	os_printf("0x%x, /* TXBiPReferencePDvoltage_2_4G */ \n", pRadio[i++]);	
       
  4169 	os_printf("0x%x, /* TxBiPReferencePower_2_4G */ \n",	pRadio[i++]);
       
  4170 	os_printf("0x%x, /* TxBiPOffsetdB_2_4G */ \n",			pRadio[i++]);
       
  4171 	for (j=0;j<6;j++)
       
  4172 		os_printf("0x%x, ", pRadio[i++]);
       
  4173 	os_printf("/* TxPerRatePowerLimits_2_4G_Normal[6] */ \n");
       
  4174 	for (j=0;j<6;j++)
       
  4175 		os_printf("0x%x, ", pRadio[i++]);
       
  4176 	os_printf("/* TxPerRatePowerLimits_2_4G_Degraded[6] */ \n");
       
  4177 	for (j=0;j<14;j++)
       
  4178 		os_printf("0x%x, ", pRadio[i++]);
       
  4179 	os_printf("/* TxPerChannelPowerLimits_2_4G_11b[14] */ \n");
       
  4180 	for (j=0;j<14;j++)
       
  4181 		os_printf("0x%x, ", pRadio[i++]);
       
  4182 	os_printf("/* TxPerChannelPowerLimits_2_4G_OFDM[14] */ \n");
       
  4183 	for (j=0;j<6;j++)
       
  4184 		os_printf("0x%x, ", pRadio[i++]);
       
  4185 	os_printf("/* TxPDVsRateOffsets_2_4G[6] */ \n");
       
  4186 	for (j=0;j<6;j++)
       
  4187 		os_printf("0x%x, ", pRadio[i++]);
       
  4188 	os_printf("/* TxIbiasTable_2_4G[6] */ \n");
       
  4189 	os_printf("0x%x, /* RxFemInsertionLoss_2_4G */ \n",			pRadio[i++]);
       
  4190 	for (j=0;j<14;j++)
       
  4191 	{
       
  4192 		os_printf("0x%x, ", pRadio[i++]);		
       
  4193 	}
       
  4194 	os_printf("/* TXBiPReferencePDvoltage_5G[7*2] */ \n");
       
  4195 	for (j=0;j<7;j++)
       
  4196 		os_printf("0x%x, ", pRadio[i++]);
       
  4197 	os_printf("/* TxBiPReferencePower_5G[7] */ \n");
       
  4198 	for (j=0;j<7;j++)
       
  4199 		os_printf("0x%x, ", pRadio[i++]);
       
  4200 	os_printf("/* TxBiPOffsetdB_5G[7] */ \n");
       
  4201 	for (j=0;j<6;j++)
       
  4202 		os_printf("0x%x, ", pRadio[i++]);
       
  4203 	os_printf("/* TxPerRatePowerLimits_5G_Normal[6] */ \n");
       
  4204 	for (j=0;j<6;j++)
       
  4205 		os_printf("0x%x, ", pRadio[i++]);
       
  4206 	os_printf("/* TxPerRatePowerLimits_5G_Degraded[6] */ \n");
       
  4207 	for (j=0;j<35;j++)
       
  4208 		os_printf("0x%x, ", pRadio[i++]);
       
  4209 	os_printf("/* TxPerChannelPowerLimits_5G_OFDM[35] */ \n");
       
  4210 	for (j=0;j<6;j++)
       
  4211 		os_printf("0x%x, ", pRadio[i++]);
       
  4212 	os_printf("/* TxPDVsRateOffsets_5G[6] */ \n");
       
  4213 	for (j=0;j<6;j++)
       
  4214 		os_printf("0x%x, ", pRadio[i++]);
       
  4215 	os_printf("/* TxIbiasTable_5G[6] */ \n");
       
  4216 	for (j=0;j<7;j++)
       
  4217 		os_printf("0x%x, ", pRadio[i++]);
       
  4218 	os_printf("/* RxFemInsertionLoss_5G[7] */ \n");
       
  4219 	os_printf("0x%x /* Padding */ \n",					pRadio[i++]);
       
  4220 }
       
  4221 #endif
       
  4222 
       
  4223 
       
  4224 /** 
       
  4225 * \fn     TIFailureDfcClient
       
  4226 * \brief  Constructor
       
  4227 * 
       
  4228 * This method is the default constructor for TIFailureDfcClient. 
       
  4229 * This class is in charge of creating a new DFC that will handle
       
  4230 * the failure handling & dispatch to the umac in case of a failure event.
       
  4231 * 
       
  4232 * \note   
       
  4233 * return   handle to TIFailureDfcClient class. 
       
  4234 * \sa     
       
  4235 */ 
       
  4236 TIFailureDfcClient::TIFailureDfcClient(MWlanOsa& aOsa)
       
  4237 {
       
  4238     pFailureDfc = aOsa.DfcCreate();
       
  4239 }
       
  4240 
       
  4241 
       
  4242 /**
       
  4243 * \fn     TIFailureDfcClient::OnDfc
       
  4244 * \brief  Call TIWhaAdaptCB::FailureIndicationDFC from TIFailureDfcClient context
       
  4245 * 
       
  4246 * \param handle to TIWha context
       
  4247 * 
       
  4248 * /note
       
  4249 * 
       
  4250 * /return void
       
  4251 */
       
  4252 void TIFailureDfcClient::OnDfc(TInt aCtx)
       
  4253 {
       
  4254     TIWhaAdaptCB::FailureIndicationDFC ((TI_HANDLE)aCtx);
       
  4255 }
       
  4256 
       
  4257 
       
  4258 /** 
       
  4259 * \fn     TIConnectDfcClient
       
  4260 * \brief  Constructor
       
  4261 * 
       
  4262 * This method is the default constructor for TIConnectDfcClient. 
       
  4263 * This class is in charge of creating a new DFC that will handle
       
  4264 * the end of the bus connection phase in case of a sync init bus transaction .
       
  4265 * 
       
  4266 * \note   
       
  4267 * return   handle to TIConnectDfcClient class. 
       
  4268 * \sa     
       
  4269 */ 
       
  4270 TIConnectDfcClient::TIConnectDfcClient(MWlanOsa& aOsa)
       
  4271 {
       
  4272     pConnectDfc = aOsa.DfcCreate();
       
  4273 }
       
  4274 
       
  4275 
       
  4276 /**
       
  4277 * \fn     TIConnectDfcClient::OnDfc
       
  4278 * \brief  Call TIWhaAdaptCB::ConnectBus from TIConnectDfcClient context
       
  4279 * 
       
  4280 * \param handle to TIWha context
       
  4281 * 
       
  4282 * /note
       
  4283 * 
       
  4284 * /return void
       
  4285 */
       
  4286 void TIConnectDfcClient::OnDfc(TInt aCtx)
       
  4287 {    
       
  4288     TIWhaAdaptCB::ConnectBus ((TI_HANDLE)aCtx);
       
  4289 }
       
  4290 
       
  4291 
       
  4292 
       
  4293 /*****************************************************************************************************/
       
  4294 /************************************** CREATE DRIVER ************************************************/
       
  4295 
       
  4296 
       
  4297 DECLARE_STANDARD_PDD()
       
  4298 {
       
  4299     TIWha* p = new TIWha;
       
  4300     return p;
       
  4301 }
       
  4302 
       
  4303 
       
  4304  TInt TIWha::Install()
       
  4305  {
       
  4306     TPtrC mDeviceName= DEVICE_NAME;
       
  4307 
       
  4308 	return SetName(&mDeviceName);
       
  4309  }
       
  4310 
       
  4311  void TIWha::GetCaps( TDes8& aDes ) const
       
  4312  {
       
  4313      aDes.FillZ(aDes.MaxLength());
       
  4314 
       
  4315      aDes.Copy( (TUint8*)&iVersion, Min(aDes.MaxLength(), sizeof(TVersion)) );
       
  4316  }
       
  4317 
       
  4318 
       
  4319 
       
  4320  TInt TIWha::Create( DBase *&aChannel, TInt aUnit, const TDesC* anInfo, const TVersion& aVer)
       
  4321  {
       
  4322      if ( !Kern::QueryVersionSupported( iVersion, aVer ) ) 
       
  4323         {
       
  4324          return KErrNotSupported;
       
  4325         }
       
  4326      if (bDriverCreated) {
       
  4327          aChannel = (MWlanPddIface*)this;
       
  4328          return KErrNone;
       
  4329      }
       
  4330      else
       
  4331      {
       
  4332          return KErrNotReady;
       
  4333      }
       
  4334  }
       
  4335 
       
  4336 
       
  4337  TInt TIWha::Validate( TInt aUnit, const TDesC8 *aInfo, const TVersion &aVer )
       
  4338  {
       
  4339      return KErrNone;
       
  4340  }
       
  4341 
       
  4342  TBool TIWha::Attach( MWlanOsa& aWlanOsa, MWlanOsaExt& aWlanOsaExt )
       
  4343  {
       
  4344      iTwdCtrl.tOsContext.hOsa = &aWlanOsa;
       
  4345 
       
  4346      /* Create HPA */
       
  4347      iTwdCtrl.tOsContext.hHpa = WlanHpa::Create( aWlanOsaExt, aWlanOsa);
       
  4348 
       
  4349      /* Create SPIA */
       
  4350      iTwdCtrl.tOsContext.hSpia = WlanSpia::Create( aWlanOsaExt );
       
  4351 
       
  4352      if (iTwdCtrl.tOsContext.hHpa == NULL || iTwdCtrl.tOsContext.hSpia == NULL) {
       
  4353          WLAN_OS_REPORT (("Failed to create Driver layers -- iHpa = 0x%x, , iSpia = 0x%x",iTwdCtrl.tOsContext.hHpa,iTwdCtrl.tOsContext.hSpia));
       
  4354          return EFalse;
       
  4355      }
       
  4356 
       
  4357 
       
  4358      pFailureDfcClient = new TIFailureDfcClient(*iTwdCtrl.tOsContext.hOsa);
       
  4359      if (pFailureDfcClient == NULL)
       
  4360      {
       
  4361          WLAN_OS_REPORT (("ERROR: CreateDriver TIFailureDfcClient failure\n"));        
       
  4362      }
       
  4363 
       
  4364      pConnectDfcClient = new TIConnectDfcClient(*iTwdCtrl.tOsContext.hOsa);
       
  4365      if (pConnectDfcClient == NULL)
       
  4366      {
       
  4367          WLAN_OS_REPORT (("ERROR: CreateDriver TIConnectDfcClient failure\n"));        
       
  4368      }
       
  4369 
       
  4370      return ETrue;
       
  4371  }
       
  4372 
       
  4373 
       
  4374  WHA::Wha& TIWha::Extract()
       
  4375  {
       
  4376      return *this;
       
  4377  }
       
  4378 
       
  4379 
       
  4380  void TIWha::GetCapabilities( SCapabilities*& aCapabilities )
       
  4381  {
       
  4382     aCapability = (SCapabilities*)Kern::Alloc(sizeof(SCapabilities));
       
  4383     aCapability->iCapabilities = SCapabilities::KCachedMemory;
       
  4384     aCapability->iCacheLineLength = 32;
       
  4385 
       
  4386     aCapabilities = aCapability;
       
  4387  }