Home | History | Annotate | Download | only in Sta_Management
      1 /*
      2  * siteMgr.c
      3  *
      4  * Copyright(c) 1998 - 2010 Texas Instruments. All rights reserved.
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  *
     11  *  * Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  *  * Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in
     15  *    the documentation and/or other materials provided with the
     16  *    distribution.
     17  *  * Neither the name Texas Instruments nor the names of its
     18  *    contributors may be used to endorse or promote products derived
     19  *    from this software without specific prior written permission.
     20  *
     21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32  */
     33 
     34 /** \file siteMgr.c
     35  *  \brief Site Manager implementation
     36  *
     37  *  \see siteMgr.h
     38  */
     39 
     40 /****************************************************************************/
     41 /*                                                                          */
     42 /*      MODULE: siteMgr.c                                                   */
     43 /*    PURPOSE:  Site Manager implementation                                 */
     44 /*                                                                          */
     45 /***************************************************************************/
     46 
     47 #define __FILE_ID__  FILE_ID_85
     48 #include "tidef.h"
     49 #include "report.h"
     50 #include "osApi.h"
     51 #include "siteMgrApi.h"
     52 #include "siteHash.h"
     53 #include "smeApi.h"
     54 #include "rate.h"
     55 #include "connApi.h"
     56 #include "mlmeSm.h"
     57 #include "sme.h"
     58 #include "DataCtrl_Api.h"
     59 #include "regulatoryDomainApi.h"
     60 #include "rsnApi.h"
     61 #include "measurementMgrApi.h"
     62 #include "qosMngr_API.h"
     63 #include "PowerMgr_API.h"
     64 #include "EvHandler.h"
     65 #include "TI_IPC_Api.h"
     66 #include "MacServices_api.h"
     67 #include "apConn.h"
     68 #include "currBss.h"
     69 #include "PowerMgr.h"
     70 #include "TWDriver.h"
     71 #include "admCtrl.h"
     72 #include "DrvMainModules.h"
     73 #include "StaCap.h"
     74 #include "freq.h"
     75 #include "currBssApi.h"
     76 #include "CmdBld.h"
     77 #ifdef XCC_MODULE_INCLUDED
     78 #include "XCCMngr.h"
     79 #endif
     80 
     81 /* External function prototypes */
     82 extern TI_STATUS wlanDrvIf_getNetwIpByDevName(TIpAddr devIp, char *devName);
     83 
     84 /* definitions */
     85 #define JOIN_RATE_MASK_1M   0x01
     86 #define JOIN_RATE_MASK_2M   0x02
     87 #define JOIN_RATE_MASK_5_5M 0x04
     88 #define JOIN_RATE_MASK_11M  0x08
     89 #define JOIN_RATE_MASK_22M  0x10
     90 
     91 
     92 #define SITE_MGR_INIT_BIT           1
     93 #define TIMER_INIT_BIT              2
     94 #define DESIRED_PARAMS_INIT_BIT     3
     95 #define MGMT_PARAMS_INIT_BIT        4
     96 
     97 #define BUILT_IN_TEST_PERIOD 500
     98 
     99 #define KEEP_ALIVE_SEND_NULL_DATA_PERIOD  10000
    100 
    101 /* Reconfig constants */
    102 #define SCAN_FAIL_THRESHOLD_FOR_RECONFIG        4  /* After 4 times we reset the 580 register and still no AP found - make recovery */
    103 #define SCAN_FAIL_THRESHOLD_FOR_RESET_REG_580   90  /* After 90 times (45 seconds) and  no AP found - reset the 580 register */
    104 #define SCAN_FAIL_RECONFIG_ENABLED              TI_TRUE
    105 #define SCAN_FAIL_RECONFIG_DISABLED             TI_FALSE
    106 
    107 #define TRIGGER_HIGH_TX_PW_PACING 10
    108 #define TRIGGER_LOW_TX_PW_PACING 10
    109 #define TRIGGER_HIGH_TX_PW_HYSTERESIS 3
    110 #define TRIGGER_LOW_TX_PW_HYSTERESIS 3
    111 
    112 /* Local Macros */
    113 
    114 #define UPDATE_BEACON_INTERVAL(pSite, pFrameInfo)       pSite->beaconInterval = pFrameInfo->content.iePacket.beaconInerval
    115 
    116 #define UPDATE_CAPABILITIES(pSite, pFrameInfo)          pSite->capabilities = pFrameInfo->content.iePacket.capabilities
    117 
    118 #define UPDATE_PRIVACY(pSite, pFrameInfo)               pSite->privacy = ((pFrameInfo->content.iePacket.capabilities >> CAP_PRIVACY_SHIFT) & CAP_PRIVACY_MASK) ? TI_TRUE : TI_FALSE
    119 
    120 #define UPDATE_AGILITY(pSite, pFrameInfo)               pSite->agility = ((pFrameInfo->content.iePacket.capabilities >> CAP_AGILE_SHIFT) & CAP_AGILE_MASK) ? TI_TRUE : TI_FALSE
    121 
    122 #define UPDATE_SLOT_TIME(pSite, pFrameInfo)             pSite->newSlotTime = ((pFrameInfo->content.iePacket.capabilities >> CAP_SLOT_TIME_SHIFT) & CAP_SLOT_TIME_MASK) ? PHY_SLOT_TIME_SHORT : PHY_SLOT_TIME_LONG
    123 #define UPDATE_PROTECTION(pSite, pFrameInfo)            pSite->useProtection = (pFrameInfo->content.iePacket.useProtection)
    124 
    125 /* 1. no checking Ptrs for NULL; no checking ssid.len for limit & for zero */
    126 /* 2. a similar MACRO is defined in scanResultTable.c
    127    3. ... but there it contains pSite->ssid.str[pSite->ssid.len] = '\0'; Which of the DEFINEs is correct?*/
    128 #define UPDATE_SSID(pSite, pFrameInfo)                  if (pFrameInfo->content.iePacket.pSsid != NULL) { \
    129                                                         pSite->ssid.len = pFrameInfo->content.iePacket.pSsid->hdr[1]; \
    130                                                         if (pSite->ssid.len > MAX_SSID_LEN) { \
    131                                                             TRACE2( pSiteMgr->hReport, REPORT_SEVERITY_ERROR, \
    132                                                                   "UPDATE_SSID. pSite->ssid.len=%d exceeds the limit. Set to limit value %d\n", \
    133                                                                   pSite->ssid.len, MAX_SSID_LEN); \
    134                                                                   handleRunProblem(PROBLEM_BUF_SIZE_VIOLATION); \
    135                                                             pSite->ssid.len = MAX_SSID_LEN; \
    136                                                         } \
    137                                                         os_memoryCopy(pSiteMgr->hOs, \
    138                                                         (void *)pSite->ssid.str, \
    139                                                         (void *)pFrameInfo->content.iePacket.pSsid->serviceSetId, \
    140                                                         pSite->ssid.len);}
    141 
    142 #define UPDATE_CHANNEL(pSite, pFrameInfo, rxChannel)    if (pFrameInfo->content.iePacket.pDSParamsSet == NULL) \
    143                                                             pSite->channel = rxChannel; \
    144                                                         else \
    145                                                             pSite->channel = pFrameInfo->content.iePacket.pDSParamsSet->currChannel;
    146 
    147 
    148 
    149 #define UPDATE_DTIM_PERIOD(pSite, pFrameInfo)           if (pFrameInfo->content.iePacket.pTIM != NULL) \
    150                                                         pSite->dtimPeriod = pFrameInfo->content.iePacket.pTIM->dtimPeriod
    151 
    152 #define UPDATE_ATIM_WINDOW(pSite, pFrameInfo)           if (pFrameInfo->content.iePacket.pIBSSParamsSet != NULL) \
    153                                                         pSite->atimWindow = pFrameInfo->content.iePacket.pIBSSParamsSet->atimWindow
    154 
    155 #define UPDATE_BEACON_AP_TX_POWER(pSite, pFrameInfo)    if (pFrameInfo->content.iePacket.TPCReport != NULL) \
    156                                                         pSite->APTxPower = pFrameInfo->content.iePacket.TPCReport->transmitPower
    157 
    158 #define UPDATE_PROBE_AP_TX_POWER(pSite, pFrameInfo)     if (pFrameInfo->content.iePacket.TPCReport != NULL) \
    159                                                         pSite->APTxPower = pFrameInfo->content.iePacket.TPCReport->transmitPower
    160 
    161 #define UPDATE_BSS_TYPE(pSite, pFrameInfo)              pSite->bssType = ((pFrameInfo->content.iePacket.capabilities >> CAP_ESS_SHIFT) & CAP_ESS_MASK) ? BSS_INFRASTRUCTURE : BSS_INDEPENDENT
    162 
    163 #define UPDATE_LOCAL_TIME_STAMP(pSiteMgr, pSite, pFrameInfo)        pSite->localTimeStamp = os_timeStampMs(pSiteMgr->hOs)
    164 
    165 /* Updated from beacons */
    166 #define UPDATE_BEACON_MODULATION(pSite, pFrameInfo)     pSite->beaconModulation = ((pFrameInfo->content.iePacket.capabilities >> CAP_PBCC_SHIFT) & CAP_PBCC_MASK) ? DRV_MODULATION_PBCC : DRV_MODULATION_CCK
    167 
    168 /* Updated from probes */
    169 #define UPDATE_PROBE_MODULATION(pSite, pFrameInfo)          pSite->probeModulation = ((pFrameInfo->content.iePacket.capabilities >> CAP_PBCC_SHIFT) & CAP_PBCC_MASK) ? DRV_MODULATION_PBCC : DRV_MODULATION_CCK
    170 
    171 #define UPDATE_BEACON_RECV(pSite)                       pSite->beaconRecv = TI_TRUE
    172 
    173 #define UPDATE_PROBE_RECV(pSite)                        pSite->probeRecv = TI_TRUE
    174 
    175 
    176 #define UPDATE_RSN_IE(pSite, pRsnIe, rsnIeLen)              if (pRsnIe != NULL) { \
    177                                                             TI_UINT8 length=0, index=0;\
    178                                                             pSite->rsnIeLen = rsnIeLen;\
    179                                                             while ((length < pSite->rsnIeLen) && (index<MAX_RSN_IE)){\
    180                                                                 pSite->pRsnIe[index].hdr[0] = pRsnIe->hdr[0];\
    181                                                                 pSite->pRsnIe[index].hdr[1] = pRsnIe->hdr[1];\
    182                                                                 os_memoryCopy(pSiteMgr->hOs, (void *)pSite->pRsnIe[index].rsnIeData, (void *)pRsnIe->rsnIeData, pRsnIe->hdr[1]);\
    183                                                                 length += (pRsnIe->hdr[1]+2); \
    184                                                                 pRsnIe += 1; \
    185                                                                 index++;}\
    186                                                         } \
    187                                                         else {pSite->rsnIeLen = 0;}
    188 
    189 #define UPDATE_BEACON_TIMESTAMP(pSiteMgr, pSite, pFrameInfo)    os_memoryCopy(pSiteMgr->hOs, pSite->tsfTimeStamp, (void *)pFrameInfo->content.iePacket.timestamp, TIME_STAMP_LEN)
    190 
    191 
    192 
    193 
    194 /* Local  functions definitions*/
    195 
    196 static void update_apsd(siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo);
    197 
    198 static void release_module(siteMgr_t *pSiteMgr, TI_UINT32 initVec);
    199 
    200 static void updateSiteInfo(siteMgr_t *pSiteMgr, mlmeFrameInfo_t *pFrameInfo, siteEntry_t    *pSite, TI_UINT8 rxChannel);
    201 
    202 static void updateRates(siteMgr_t *pSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo);
    203 
    204 static void updateBeaconQosParams(siteMgr_t *pSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo);
    205 
    206 static void updateProbeQosParams(siteMgr_t *pSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo);
    207 
    208 static void updateWSCParams(siteMgr_t *pSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo);
    209 
    210 static void updatePreamble(siteMgr_t *pSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo);
    211 
    212 static void getPrimarySiteDesc(siteMgr_t *pSiteMgr, OS_802_11_BSSID *pPrimarySiteDesc, TI_BOOL supplyExtendedInfo);
    213 
    214 static TI_STATUS getPrimaryBssid(siteMgr_t *pSiteMgr, OS_802_11_BSSID_EX *primaryBssid, TI_UINT32 *pLength);
    215 
    216 static ERate translateRateMaskToValue(siteMgr_t *pSiteMgr, TI_UINT32 rateMask);
    217 
    218 static void getSupportedRateSet(siteMgr_t *pSiteMgr, TRates *pRatesSet);
    219 
    220 static TI_STATUS setSupportedRateSet(siteMgr_t *pSiteMgr, TRates *pRatesSet);
    221 
    222 static void siteMgr_externalConfigurationParametersSet(TI_HANDLE hSiteMgr);
    223 
    224 static int parseWscMethodFromIE (siteMgr_t *pSiteMgr, dot11_WSC_t *WSCParams, TIWLN_SIMPLE_CONFIG_MODE *pSelectedMethod);
    225 
    226 static TI_UINT16 incrementTxSessionCount(siteMgr_t *pSiteMgr);
    227 static void siteMgr_TxPowerAdaptation(TI_HANDLE hSiteMgr, RssiEventDir_e highLowEdge);
    228 static void siteMgr_TxPowerLowThreshold(TI_HANDLE hSiteMgr, TI_UINT8 *data, TI_UINT8 dataLength);
    229 static void siteMgr_TxPowerHighThreshold(TI_HANDLE hSiteMgr, TI_UINT8 *data, TI_UINT8 dataLength);
    230 
    231 /************************************************************************
    232 *                        siteMgr_setTemporaryTxPower                    *
    233 *************************************************************************
    234 DESCRIPTION:	This function is used to start the Tx Power Control adjust mechanism
    235 				in regulatoryDomain.
    236 
    237 INPUT:      bActivateTempFix             -   Whether the power should be adjusted
    238 ************************************************************************/
    239 void siteMgr_setTemporaryTxPower(siteMgr_t* pSiteMgr, TI_BOOL bActivateTempFix)
    240 {
    241 	paramInfo_t         param;
    242 
    243 TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "siteMgr_setTemporaryTxPower is =  \n");
    244 
    245 	/* Set the temporary Power Level via the Regulatory Domain*/
    246 	param.paramType = REGULATORY_DOMAIN_TEMPORARY_TX_ATTENUATION_PARAM;
    247 	param.content.bActivateTempPowerFix = bActivateTempFix;
    248 	regulatoryDomain_setParam(pSiteMgr->hRegulatoryDomain,&param);
    249 }
    250 
    251 /* Interface functions Implementation */
    252 
    253 
    254 /*static void UPDATE_RSN_IE (siteMgr_t* pSiteMgr, siteEntry_t   *pSite, dot11_RSN_t *pRsnIe, TI_UINT8 rsnIeLen)
    255 {
    256 
    257     if (pRsnIe != NULL) {
    258             TI_UINT8 length=0, index=0;
    259             pSite->rsnIeLen = rsnIeLen;
    260             while ((length < pSite->rsnIeLen) && (index<MAX_RSN_IE)){
    261                 pSite->pRsnIe[index].hdr = pRsnIe->hdr;
    262                 os_memoryCopy(pSiteMgr->hOs, pSite->pRsnIe[index].rsnIeData, pRsnIe->rsnIeData, pRsnIe->hdr[1]);
    263                 length += (pRsnIe->hdr[1] + 2);
    264                 pRsnIe += 1;
    265                 index++;}
    266         }
    267         else {pSite->rsnIeLen = 0;}
    268 }*/
    269 /************************************************************************
    270  *                        siteMgr_create                                *
    271  ************************************************************************
    272 DESCRIPTION: Site manager module creation function, called by the config mgr in creation phase
    273                 performs the following:
    274                 -   Allocate the site manager handle
    275                 -   Allocate the desired & mgmt params structure
    276 
    277 INPUT:      hOs             -   Handle to OS
    278 
    279 
    280 OUTPUT:
    281 
    282 
    283 RETURN:     Handle to the site manager module on success, NULL otherwise
    284 ************************************************************************/
    285 TI_HANDLE siteMgr_create(TI_HANDLE hOs)
    286 {
    287     siteMgr_t       *pSiteMgr;
    288     TI_UINT32          initVec;
    289 
    290     initVec = 0;
    291 
    292     pSiteMgr = os_memoryAlloc(hOs, sizeof(siteMgr_t));
    293     if (pSiteMgr == NULL)
    294     {
    295         return NULL;
    296     }
    297 
    298     os_memoryZero(hOs, pSiteMgr, sizeof(siteMgr_t));
    299 
    300     initVec |= (1 << SITE_MGR_INIT_BIT);
    301 
    302     pSiteMgr->pDesiredParams = os_memoryAlloc(hOs, sizeof(siteMgrInitParams_t));
    303     if (pSiteMgr->pDesiredParams == NULL)
    304     {
    305         release_module(pSiteMgr, initVec);
    306         return NULL;
    307     }
    308 
    309     initVec |= (1 << DESIRED_PARAMS_INIT_BIT);
    310 
    311     pSiteMgr->pSitesMgmtParams = os_memoryAlloc(hOs, sizeof(sitesMgmtParams_t));
    312     if (pSiteMgr->pSitesMgmtParams == NULL)
    313     {
    314         release_module(pSiteMgr, initVec);
    315         return NULL;
    316     }
    317 
    318     initVec |= (1 << MGMT_PARAMS_INIT_BIT);
    319 
    320     pSiteMgr->hOs = hOs;
    321 
    322     return(pSiteMgr);
    323 }
    324 
    325 
    326 
    327 /************************************************************************
    328  *                        siteMgr_init                                  *
    329  ************************************************************************
    330 DESCRIPTION: Module init function, called by the DrvMain in init phase
    331                 performs the following:
    332                 -   Reset & initiailzes local variables
    333                 -   Init the handles to be used by the module
    334 
    335 INPUT:      pStadHandles -  List of handles to be used by the module
    336 
    337 OUTPUT:
    338 
    339 RETURN:     void
    340 ************************************************************************/
    341 void siteMgr_init (TStadHandlesList *pStadHandles)
    342 {
    343     siteMgr_t *pSiteMgr = (siteMgr_t *)(pStadHandles->hSiteMgr);
    344 
    345     /* Init handles */
    346     pSiteMgr->hConn                 = pStadHandles->hConn;
    347     pSiteMgr->hSmeSm                = pStadHandles->hSme;
    348     pSiteMgr->hTWD                  = pStadHandles->hTWD;
    349     pSiteMgr->hCtrlData             = pStadHandles->hCtrlData;
    350     pSiteMgr->hRxData               = pStadHandles->hRxData;
    351     pSiteMgr->hTxCtrl               = pStadHandles->hTxCtrl;
    352     pSiteMgr->hRsn                  = pStadHandles->hRsn;
    353     pSiteMgr->hAuth                 = pStadHandles->hAuth;
    354     pSiteMgr->hAssoc                = pStadHandles->hAssoc;
    355     pSiteMgr->hRegulatoryDomain     = pStadHandles->hRegulatoryDomain;
    356     pSiteMgr->hMeasurementMgr       = pStadHandles->hMeasurementMgr;
    357     pSiteMgr->hReport               = pStadHandles->hReport;
    358     pSiteMgr->hOs                   = pStadHandles->hOs;
    359     pSiteMgr->hMlmeSm               = pStadHandles->hMlmeSm;
    360     pSiteMgr->hAssoc                = pStadHandles->hAssoc;
    361     pSiteMgr->hReport               = pStadHandles->hReport;
    362     pSiteMgr->hXCCMngr              = pStadHandles->hXCCMngr;
    363     pSiteMgr->hApConn               = pStadHandles->hAPConnection;
    364     pSiteMgr->hCurrBss              = pStadHandles->hCurrBss;
    365     pSiteMgr->hQosMngr              = pStadHandles->hQosMngr;
    366     pSiteMgr->hPowerMgr             = pStadHandles->hPowerMgr;
    367     pSiteMgr->hScr                  = pStadHandles->hSCR;
    368     pSiteMgr->hEvHandler            = pStadHandles->hEvHandler;
    369     pSiteMgr->hStaCap               = pStadHandles->hStaCap;
    370 }
    371 
    372 
    373 TI_STATUS siteMgr_SetDefaults (TI_HANDLE                hSiteMgr,
    374                                siteMgrInitParams_t     *pSiteMgrInitParams)
    375 {
    376     siteMgr_t       *pSiteMgr = (siteMgr_t *)hSiteMgr;
    377     TI_UINT32       timestamp;
    378     ESlotTime       slotTime;
    379     TMacAddr        saBssid;
    380     TI_STATUS       status;
    381     RssiSnrTriggerCfg_t tTriggerCfg;
    382 
    383     pSiteMgr->siteMgrTxPowerCheckTime   = 0;
    384     pSiteMgr->siteMgrWSCCurrMode        = TIWLN_SIMPLE_CONFIG_OFF;
    385     pSiteMgr->includeWSCinProbeReq      = pSiteMgrInitParams->includeWSCinProbeReq;
    386 
    387     /* Init desired parameters */
    388     os_memoryCopy(pSiteMgr->hOs, pSiteMgr->pDesiredParams, pSiteMgrInitParams, sizeof(siteMgrInitParams_t));
    389 
    390     /* Init Beacon Filter Desired State */
    391     pSiteMgr->beaconFilterParams.desiredState = pSiteMgrInitParams->beaconFilterParams.desiredState;
    392     /* Init Beacon Filter numOfStored parameter */
    393     pSiteMgr->beaconFilterParams.numOfStored = pSiteMgrInitParams->beaconFilterParams.numOfStored;
    394 
    395     /* Init management params */
    396     pSiteMgr->pSitesMgmtParams->dot11A_sitesTables.maxNumOfSites = MAX_SITES_A_BAND;
    397     siteMgr_resetSiteTable(pSiteMgr,(siteTablesParams_t *)&pSiteMgr->pSitesMgmtParams->dot11A_sitesTables);
    398     pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables.maxNumOfSites = MAX_SITES_BG_BAND;
    399     siteMgr_resetSiteTable(pSiteMgr,&pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables);
    400 
    401     /* calculate random BSSID for usage in IBSS */
    402     timestamp = os_timeStampMs(pSiteMgr->hOs);
    403     os_memoryCopy(pSiteMgr->hOs, (void *)&(pSiteMgr->ibssBssid[0]), &timestamp, sizeof(TI_UINT32));
    404 
    405     timestamp = os_timeStampMs(pSiteMgr->hOs);
    406     os_memoryCopy(pSiteMgr->hOs, (void *)&(pSiteMgr->ibssBssid[2]), &timestamp, sizeof(TI_UINT32));
    407 
    408     /* Get the Source MAC address in order to use it for AD-Hoc BSSID, solving Conexant ST issue for WiFi test */
    409     status = ctrlData_getParamBssid(pSiteMgr->hCtrlData, CTRL_DATA_MAC_ADDRESS, saBssid);
    410     if (status != TI_OK)
    411     {
    412         TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_CONSOLE ,"\n ERROR !!! : siteMgr_config - Error in getting MAC address\n" );
    413         WLAN_OS_REPORT(("\n ERROR !!! : siteMgr_config - Error in getting MAC address\n" ));
    414         return TI_NOK;
    415     }
    416     pSiteMgr->ibssBssid[0] = 0x02;
    417     pSiteMgr->ibssBssid[1] = saBssid[1];
    418     pSiteMgr->ibssBssid[2] = saBssid[2];
    419 
    420     pSiteMgr->pDesiredParams->siteMgrSupportedBand = RADIO_BAND_DUAL;
    421 
    422     pSiteMgr->beaconSentCount = 0;
    423     pSiteMgr->pDesiredParams->siteMgrDesiredAtimWindow = 0;
    424 	pSiteMgr->txSessionCount = MIN_TX_SESSION_COUNT;
    425 
    426     if(pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode == DOT11_DUAL_MODE)
    427     {
    428        if(pSiteMgr->pDesiredParams->siteMgrSupportedBand == RADIO_BAND_DUAL)
    429        {
    430            pSiteMgr->siteMgrOperationalMode = DOT11_G_MODE;
    431            pSiteMgr->radioBand = RADIO_BAND_2_4_GHZ;
    432            slotTime = pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime;
    433            pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
    434        }
    435        else if(pSiteMgr->pDesiredParams->siteMgrSupportedBand == RADIO_BAND_2_4_GHZ)
    436        {
    437            pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode = DOT11_G_MODE;
    438            pSiteMgr->siteMgrOperationalMode = DOT11_G_MODE;
    439            pSiteMgr->radioBand = RADIO_BAND_2_4_GHZ;
    440            slotTime = pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime;
    441            pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
    442        }
    443        else
    444        {
    445            pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode = DOT11_A_MODE;
    446            pSiteMgr->siteMgrOperationalMode = DOT11_A_MODE;
    447            pSiteMgr->radioBand = RADIO_BAND_5_0_GHZ;
    448            slotTime = PHY_SLOT_TIME_SHORT;
    449            pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = (siteTablesParams_t *)&pSiteMgr->pSitesMgmtParams->dot11A_sitesTables;
    450        }
    451     }
    452     else if(pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode == DOT11_G_MODE)
    453     {
    454         slotTime = pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime;
    455         pSiteMgr->radioBand = RADIO_BAND_2_4_GHZ;
    456         if((pSiteMgr->pDesiredParams->siteMgrSupportedBand == RADIO_BAND_DUAL) ||
    457            (pSiteMgr->pDesiredParams->siteMgrSupportedBand == RADIO_BAND_2_4_GHZ))
    458         {
    459             pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
    460             pSiteMgr->siteMgrOperationalMode = pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode;
    461 
    462         }
    463         else
    464         {   TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_CONSOLE ,"\nERROR !!!.....The radio doesn't support the desired dot11 mode !!! \n");
    465             WLAN_OS_REPORT(("\nERROR !!!.....The radio doesn't support the desired dot11 mode !!! \n"));
    466             return TI_NOK;
    467         }
    468     }
    469     else if(pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode == DOT11_B_MODE)
    470     {
    471         slotTime = PHY_SLOT_TIME_LONG;
    472         pSiteMgr->radioBand = RADIO_BAND_2_4_GHZ;
    473         if((pSiteMgr->pDesiredParams->siteMgrSupportedBand == RADIO_BAND_DUAL) ||
    474            (pSiteMgr->pDesiredParams->siteMgrSupportedBand == RADIO_BAND_2_4_GHZ))
    475         {
    476             pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
    477             pSiteMgr->siteMgrOperationalMode = pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode;
    478         }
    479         else
    480         {
    481             TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_CONSOLE ,"\nERROR !!!.....The radio doesn't support the desired dot11 mode !!! \n");
    482             WLAN_OS_REPORT(("\nERROR !!!.....The radio doesn't support the desired dot11 mode !!! \n"));
    483             return TI_NOK;
    484         }
    485     }
    486     else
    487     {
    488         slotTime = PHY_SLOT_TIME_SHORT;
    489         pSiteMgr->radioBand = RADIO_BAND_5_0_GHZ;
    490         if((pSiteMgr->pDesiredParams->siteMgrSupportedBand == RADIO_BAND_DUAL) ||
    491            (pSiteMgr->pDesiredParams->siteMgrSupportedBand == RADIO_BAND_5_0_GHZ))
    492         {
    493             pSiteMgr->siteMgrOperationalMode = pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode;
    494             pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = (siteTablesParams_t *)&pSiteMgr->pSitesMgmtParams->dot11A_sitesTables;
    495         }
    496         else
    497         {
    498             TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_CONSOLE ,"\nERROR !!!.....The radio doesn't support the desired dot11 mode !!! \n");
    499             WLAN_OS_REPORT(("\nERROR !!!.....The radio doesn't support the desired dot11 mode !!! \n"));
    500             return TI_NOK;
    501         }
    502     }
    503 
    504     /* Configure hal with common core-hal parameters */
    505     TWD_SetRadioBand(pSiteMgr->hTWD, pSiteMgr->radioBand);
    506     TWD_CfgSlotTime (pSiteMgr->hTWD, slotTime);
    507     siteMgr_ConfigRate(hSiteMgr);
    508 
    509     TRACE2(pSiteMgr->hReport, REPORT_SEVERITY_INIT, " SiteMgr - numOfElements = %d IETableSize = %d\n" , pSiteMgrInitParams->beaconFilterParams.numOfElements, pSiteMgrInitParams->beaconFilterParams.IETableSize);
    510     /* Send the table regardless to the state */
    511     TWD_CfgBeaconFilterTable (pSiteMgr->hTWD,
    512                               pSiteMgrInitParams->beaconFilterParams.numOfElements,
    513                               pSiteMgrInitParams->beaconFilterParams.IETable,
    514                               pSiteMgrInitParams->beaconFilterParams.IETableSize);
    515 
    516     /*  At start-up Set the Beacon Filter state as the User required */
    517     TWD_CfgBeaconFilterOpt (pSiteMgr->hTWD, pSiteMgrInitParams->beaconFilterParams.desiredState, pSiteMgr->beaconFilterParams.numOfStored);
    518 
    519     pSiteMgr->pSitesMgmtParams->pPrevPrimarySite = NULL;
    520 
    521     /* Clears the ProbeReqWSC IE */
    522     os_memoryZero(pSiteMgr->hOs,&pSiteMgr->siteMgrWSCProbeReqParams,sizeof(DOT11_WSC_PROBE_REQ_MAX_LENGTH));
    523 
    524     /* Register the RSSI Trigger events at the currBss RSSI/SNR static table*/
    525     currBSS_RegisterTriggerEvent(pSiteMgr->hCurrBss, TWD_OWN_EVENT_RSSI_SNR_TRIGGER_2, (TI_UINT8)0,(void*)siteMgr_TxPowerHighThreshold,hSiteMgr);
    526     currBSS_RegisterTriggerEvent(pSiteMgr->hCurrBss, TWD_OWN_EVENT_RSSI_SNR_TRIGGER_3, (TI_UINT8)0,(void*)siteMgr_TxPowerLowThreshold, hSiteMgr);
    527 
    528     tTriggerCfg.index     = TRIGGER_EVENT_HIGH_TX_PW;
    529     tTriggerCfg.threshold = (0 - pSiteMgr->pDesiredParams->TxPowerRssiThresh);
    530     tTriggerCfg.pacing    = TRIGGER_HIGH_TX_PW_PACING;
    531     tTriggerCfg.metric    = METRIC_EVENT_RSSI_DATA;
    532     tTriggerCfg.type      = RX_QUALITY_EVENT_EDGE;
    533     tTriggerCfg.direction = RSSI_EVENT_DIR_HIGH;
    534     tTriggerCfg.hystersis = TRIGGER_HIGH_TX_PW_HYSTERESIS;
    535     tTriggerCfg.enable     = TI_TRUE;
    536     TWD_CfgRssiSnrTrigger (pSiteMgr->hTWD, &tTriggerCfg);
    537 
    538     tTriggerCfg.index     = TRIGGER_EVENT_LOW_TX_PW;
    539     tTriggerCfg.threshold = (0 - pSiteMgr->pDesiredParams->TxPowerRssiRestoreThresh);
    540     tTriggerCfg.pacing    = TRIGGER_LOW_TX_PW_PACING;
    541     tTriggerCfg.metric    = METRIC_EVENT_RSSI_DATA;
    542     tTriggerCfg.type      = RX_QUALITY_EVENT_EDGE;
    543     tTriggerCfg.direction = RSSI_EVENT_DIR_LOW;
    544     tTriggerCfg.hystersis = TRIGGER_LOW_TX_PW_HYSTERESIS;
    545     tTriggerCfg.enable    = TI_TRUE;
    546     TWD_CfgRssiSnrTrigger (pSiteMgr->hTWD, &tTriggerCfg);
    547 
    548     TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_INIT, ".....Site manager configured successfully\n");
    549 
    550     return TI_OK;
    551 }
    552 
    553 
    554 /************************************************************************
    555  *                        siteMgr_unLoad                                    *
    556  ************************************************************************
    557 DESCRIPTION: site manager module unload function, called by the config mgr in the unlod phase
    558                 performs the following:
    559                 -   Free all memory aloocated by the module
    560 
    561 INPUT:      hSiteMgr    -   site mgr handle.
    562 
    563 
    564 OUTPUT:
    565 
    566 RETURN:     TI_OK on success, TI_NOK otherwise
    567 
    568 ************************************************************************/
    569 TI_STATUS siteMgr_unLoad(TI_HANDLE hSiteMgr)
    570 {
    571     TI_UINT32          initVec;
    572     siteMgr_t       *pSiteMgr = (siteMgr_t *)hSiteMgr;
    573 
    574     if (!pSiteMgr)
    575         return TI_OK;
    576 
    577     initVec = 0xFFFF;
    578     release_module(pSiteMgr, initVec);
    579 
    580     return TI_OK;
    581 }
    582 
    583 /***********************************************************************
    584  *                        siteMgr_setParam
    585  ***********************************************************************
    586 DESCRIPTION: site mgr set param function, called by the following:
    587                 -   config mgr in order to set a parameter from the OS abstraction layer.
    588                 In this fuction, the site manager OS abstraction layer configures the site manager to the desired params.
    589                 Sometimes it requires a re scan, depending in the parameter type
    590 
    591 INPUT:      hSiteMgr    -   Connection handle.
    592             pParam  -   Pointer to the parameter
    593 
    594 OUTPUT:
    595 
    596 RETURN:     TI_OK on success, TI_NOK on failure
    597 
    598 ************************************************************************/
    599 
    600 TI_STATUS siteMgr_setParam(TI_HANDLE        hSiteMgr,
    601                         paramInfo_t     *pParam)
    602 {
    603     siteMgr_t *pSiteMgr = (siteMgr_t *)hSiteMgr;
    604     siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
    605     OS_802_11_CONFIGURATION *pConfig;
    606     TI_UINT32      channel;
    607     ESlotTime  slotTime;
    608     paramInfo_t	param;
    609     PowerMgr_t *pPowerMgr = (PowerMgr_t*)pSiteMgr->hPowerMgr;
    610     static PowerMgr_PowerMode_e desiredPowerModeProfile;
    611 
    612     switch(pParam->paramType)
    613     {
    614     case SITE_MGR_CONFIGURATION_PARAM:
    615         pConfig = pParam->content.pSiteMgrConfiguration;
    616 
    617 /*      for(channel = 0; channel < SITE_MGR_CHANNEL_MAX+1; channel++)
    618         {
    619             if(pConfig->channel == pSiteMgr->pDesiredParams->siteMgrFreq2ChannelTable[channel])
    620                 break;
    621         }*/
    622 
    623         channel = Freq2Chan(pConfig->Union.channel);
    624 
    625         if(channel == 0 || channel > SITE_MGR_CHANNEL_MAX)
    626             return PARAM_VALUE_NOT_VALID;
    627         else
    628             pConfig->Union.channel = channel;
    629 
    630         if((pSiteMgr->pDesiredParams->siteMgrDesiredChannel != pConfig->Union.channel) ||
    631            (pSiteMgr->pDesiredParams->siteMgrDesiredAtimWindow != pConfig->ATIMWindow))
    632         {
    633             pSiteMgr->pDesiredParams->siteMgrDesiredChannel = (TI_UINT8)pConfig->Union.channel;
    634             pSiteMgr->pDesiredParams->siteMgrDesiredBeaconInterval = (TI_UINT16)pConfig->BeaconPeriod;
    635             pSiteMgr->pDesiredParams->siteMgrDesiredAtimWindow = pConfig->ATIMWindow;
    636         }
    637 
    638         return TI_OK;
    639 
    640     case SITE_MGR_DESIRED_CHANNEL_PARAM:
    641         if (pParam->content.siteMgrDesiredChannel > SITE_MGR_CHANNEL_MAX)
    642             return PARAM_VALUE_NOT_VALID;
    643 
    644         if (pSiteMgr->pDesiredParams->siteMgrDesiredChannel != pParam->content.siteMgrDesiredChannel)
    645             pSiteMgr->pDesiredParams->siteMgrDesiredChannel = (TI_UINT8)pParam->content.siteMgrDesiredChannel;
    646         return TI_OK;
    647 
    648     case SITE_MGR_DESIRED_BSSID_PARAM:
    649             MAC_COPY (pSiteMgr->pDesiredParams->siteMgrDesiredBSSID, pParam->content.siteMgrDesiredBSSID);
    650            return TI_OK;
    651 
    652     case SITE_MGR_DESIRED_SSID_PARAM:
    653 
    654         TRACE1(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "\nSet new SSID= (len=%d)  \n", pParam->content.siteMgrDesiredSSID.len);
    655 
    656         if (pParam->content.siteMgrDesiredSSID.len > MAX_SSID_LEN)
    657             return PARAM_VALUE_NOT_VALID;
    658 
    659         os_memoryCopy(pSiteMgr->hOs, &pSiteMgr->pDesiredParams->siteMgrDesiredSSID, &pParam->content.siteMgrDesiredSSID, sizeof(TSsid));
    660         /* only add null at the end of the string if the string length is less than 32 bytes and so we have one char left
    661         */
    662         if ( MAX_SSID_LEN > pSiteMgr->pDesiredParams->siteMgrDesiredSSID.len )
    663         {
    664             pSiteMgr->pDesiredParams->siteMgrDesiredSSID.str[pSiteMgr->pDesiredParams->siteMgrDesiredSSID.len] = '\0';
    665         }
    666 
    667         /* increase the random IBSS BSSID calculated during init */
    668 		pSiteMgr->ibssBssid[MAC_ADDR_LEN - 1] ++;
    669 
    670         if (OS_802_11_SSID_JUNK (pSiteMgr->pDesiredParams->siteMgrDesiredSSID.str, pSiteMgr->pDesiredParams->siteMgrDesiredSSID.len))
    671         {
    672             rsn_removedDefKeys(pSiteMgr->hRsn);
    673         }
    674 
    675         /* due to the fact we call to SME_DESIRED_SSID_ACT_PARAM also we not need to call sme_Restart */
    676         return TI_OK;
    677 
    678     case SITE_MGR_DESIRED_BSS_TYPE_PARAM:
    679 
    680          TRACE1(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "\nSet BssType = %d\n", pParam->content.siteMgrDesiredBSSType);
    681         if (pParam->content.siteMgrDesiredBSSType > BSS_ANY)
    682             return PARAM_VALUE_NOT_VALID;
    683 
    684         if (pSiteMgr->pDesiredParams->siteMgrDesiredBSSType != pParam->content.siteMgrDesiredBSSType)
    685         {
    686             pSiteMgr->pDesiredParams->siteMgrDesiredBSSType = pParam->content.siteMgrDesiredBSSType;
    687 
    688 			/* If the new BSS type is NOT Ad_Hoc, We make sure that the rate masks are set to G */
    689 			 if(pSiteMgr->pDesiredParams->siteMgrDesiredBSSType != BSS_INDEPENDENT)
    690 
    691             {
    692 				 pSiteMgr->siteMgrOperationalMode = DOT11_G_MODE;
    693                  siteMgr_ConfigRate(pSiteMgr);
    694             }
    695 
    696             /* If the new BSS type is Ad_Hoc, increase the random BSSID calculated during init */
    697             if(pSiteMgr->pDesiredParams->siteMgrDesiredBSSType == BSS_INDEPENDENT)
    698             {
    699                 pSiteMgr->ibssBssid[MAC_ADDR_LEN - 1] ++;
    700             }
    701 
    702             /* go to B_ONLY Mode only if WiFI bit is Set*/
    703             if (pSiteMgr->pDesiredParams->siteMgrWiFiAdhoc == TI_TRUE)
    704             {   /* Configuration For AdHoc when using external configuration */
    705                 if(pSiteMgr->pDesiredParams->siteMgrExternalConfiguration == TI_FALSE)
    706                 {
    707                     siteMgr_externalConfigurationParametersSet(hSiteMgr);
    708                 }
    709             }
    710         }
    711 
    712         return TI_OK;
    713 
    714     case SITE_MGR_SIMPLE_CONFIG_MODE: /* Setting the WiFiSimpleConfig mode */
    715 
    716         /* Modify the current mode and IE size */
    717 		pSiteMgr->siteMgrWSCCurrMode = pParam->content.siteMgrWSCMode.WSCMode;
    718 		pSiteMgr->uWscIeSize = pParam->content.siteMgrWSCMode.uWscIeSize;
    719 
    720         TRACE2(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "Setting SimpleConfig Mode to %d, IE Size = %d\n", pSiteMgr->siteMgrWSCCurrMode, pSiteMgr->uWscIeSize);
    721 
    722 		/* In case the WSC is on ,the ProbeReq WSC IE need to be updated */
    723         if(pSiteMgr->siteMgrWSCCurrMode != TIWLN_SIMPLE_CONFIG_OFF)
    724 		{
    725 			os_memoryCopy(pSiteMgr->hOs, &pSiteMgr->siteMgrWSCProbeReqParams, &pParam->content.siteMgrWSCMode.probeReqWSCIE, pSiteMgr->uWscIeSize);
    726 
    727 			param.paramType = RSN_WPA_PROMOTE_OPTIONS;
    728            	param.content.rsnWPAPromoteFlags = ADMCTRL_WPA_OPTION_ENABLE_PROMOTE_AUTH_MODE;
    729            	rsn_setParam(pSiteMgr->hRsn, &param);
    730 
    731             /*
    732 		     * Set the system to Active power save
    733              */
    734             desiredPowerModeProfile = pPowerMgr->desiredPowerModeProfile;
    735             param.paramType = POWER_MGR_POWER_MODE;
    736             param.content.powerMngPowerMode.PowerMode = POWER_MODE_ACTIVE;
    737             param.content.powerMngPowerMode.PowerMngPriority = POWER_MANAGER_USER_PRIORITY;
    738             powerMgr_setParam(pSiteMgr->hPowerMgr,&param);
    739         }
    740 		else
    741 		{
    742 			param.paramType = RSN_WPA_PROMOTE_OPTIONS;
    743            	param.content.rsnWPAPromoteFlags = ADMCTRL_WPA_OPTION_NONE;
    744            	rsn_setParam(pSiteMgr->hRsn, &param);
    745 
    746             /*
    747              * Set the system to last power mode
    748              */
    749             param.paramType = POWER_MGR_POWER_MODE;
    750             param.content.powerMngPowerMode.PowerMode = desiredPowerModeProfile;
    751             param.content.powerMngPowerMode.PowerMngPriority = POWER_MANAGER_USER_PRIORITY;
    752             powerMgr_setParam(pSiteMgr->hPowerMgr,&param);
    753 		}
    754 
    755         /* Update the FW prob request templates to reflect the new WSC state */
    756         setDefaultProbeReqTemplate (hSiteMgr);
    757 
    758         /* update the SME on the WPS mode */
    759         param.paramType = SME_WSC_PB_MODE_PARAM;
    760         sme_SetParam (pSiteMgr->hSmeSm, &param);
    761 
    762         return TI_OK;
    763 
    764     case SITE_MGR_DESIRED_MODULATION_TYPE_PARAM:
    765         if ((pParam->content.siteMgrDesiredModulationType < DRV_MODULATION_CCK) ||
    766             (pParam->content.siteMgrDesiredModulationType > DRV_MODULATION_OFDM))
    767             return PARAM_VALUE_NOT_VALID;
    768 
    769         if (pSiteMgr->pDesiredParams->siteMgrDesiredModulationType != pParam->content.siteMgrDesiredModulationType)
    770         {
    771             pSiteMgr->pDesiredParams->siteMgrDesiredModulationType = pParam->content.siteMgrDesiredModulationType;
    772             /* means that we are moving from non-pbcc network to pbcc */
    773             if (pParam->content.siteMgrDesiredModulationType == DRV_MODULATION_PBCC)
    774                 sme_Restart (pSiteMgr->hSmeSm);
    775             return TI_OK;
    776         }
    777         return TI_OK;
    778 
    779     case SITE_MGR_BEACON_RECV:
    780         if (!pPrimarySite)
    781         {
    782             return NO_SITE_SELECTED_YET;
    783         }
    784         pPrimarySite->beaconRecv = pParam->content.siteMgrBeaconRecv;
    785         return TI_OK;
    786 
    787 
    788     case SITE_MGR_DESIRED_BEACON_INTERVAL_PARAM:
    789         if (pParam->content.siteMgrDesiredBeaconInterval < SITE_MGR_BEACON_INTERVAL_MIN)
    790             return PARAM_VALUE_NOT_VALID;
    791 
    792         if (pSiteMgr->pDesiredParams->siteMgrDesiredBeaconInterval != pParam->content.siteMgrDesiredBeaconInterval)
    793             pSiteMgr->pDesiredParams->siteMgrDesiredBeaconInterval = pParam->content.siteMgrDesiredBeaconInterval;
    794         return TI_OK;
    795 
    796     case SITE_MGR_DESIRED_PREAMBLE_TYPE_PARAM:
    797         if ((pParam->content.siteMgrDesiredPreambleType != PREAMBLE_LONG) &&
    798             (pParam->content.siteMgrDesiredPreambleType != PREAMBLE_SHORT))
    799             return PARAM_VALUE_NOT_VALID;
    800 
    801         if (pSiteMgr->pDesiredParams->siteMgrDesiredPreambleType != pParam->content.siteMgrDesiredPreambleType)
    802         {
    803             pSiteMgr->pDesiredParams->siteMgrDesiredPreambleType = pParam->content.siteMgrDesiredPreambleType;
    804         }
    805         return TI_OK;
    806 
    807     case SITE_MGR_DESIRED_SUPPORTED_RATE_SET_PARAM:
    808         return setSupportedRateSet(pSiteMgr, &(pParam->content.siteMgrDesiredSupportedRateSet));
    809 
    810     case SITE_MGR_DESIRED_DOT11_MODE_PARAM:
    811         if(pParam->content.siteMgrDot11Mode > DOT11_MAX_MODE)
    812             return PARAM_VALUE_NOT_VALID;
    813 
    814         if(pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode != pParam->content.siteMgrDot11Mode)
    815         {
    816             pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode = pParam->content.siteMgrDot11Mode;
    817 
    818             /* since the dot11ABAmode changed, the STA operational mode should be changed */
    819             if(pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode == DOT11_DUAL_MODE)
    820             {
    821                 if(pSiteMgr->pDesiredParams->siteMgrSupportedBand == RADIO_BAND_DUAL)
    822                 {
    823                     pSiteMgr->siteMgrOperationalMode = DOT11_G_MODE;
    824                 }
    825                 else if(pSiteMgr->pDesiredParams->siteMgrSupportedBand == RADIO_BAND_2_4_GHZ)
    826                 {
    827                     pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode = DOT11_G_MODE;
    828                     pSiteMgr->siteMgrOperationalMode = DOT11_G_MODE;
    829                 }
    830                 else
    831                 {
    832                     pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode = DOT11_G_MODE;
    833                     pSiteMgr->siteMgrOperationalMode = DOT11_A_MODE;
    834                 }
    835 
    836             }
    837             else
    838                 pSiteMgr->siteMgrOperationalMode = pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode;
    839 
    840             /* configure HAL with new parameters update rates and select site table */
    841             pSiteMgr->prevRadioBand = pSiteMgr->radioBand;
    842             if(pSiteMgr->siteMgrOperationalMode == DOT11_A_MODE)
    843             {
    844                 pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = (siteTablesParams_t *)&pSiteMgr->pSitesMgmtParams->dot11A_sitesTables;
    845                 pSiteMgr->radioBand = RADIO_BAND_5_0_GHZ;
    846                 slotTime = PHY_SLOT_TIME_SHORT;
    847             }
    848             else if(pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE)
    849             {
    850                 pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
    851                 pSiteMgr->radioBand = RADIO_BAND_2_4_GHZ;
    852                 slotTime = pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime;
    853             }
    854             else
    855             {
    856                 pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
    857                 pSiteMgr->radioBand = RADIO_BAND_2_4_GHZ;
    858                 slotTime = PHY_SLOT_TIME_LONG;
    859             }
    860 
    861             if(pSiteMgr->prevRadioBand != pSiteMgr->radioBand)
    862                 siteMgr_bandParamsConfig(pSiteMgr, TI_TRUE);
    863 
    864             /* Configure TWD */
    865             TWD_SetRadioBand(pSiteMgr->hTWD, pSiteMgr->radioBand);
    866             TWD_CfgSlotTime (pSiteMgr->hTWD, slotTime);
    867 
    868             /* If the BSS type is Ad_Hoc, increase the random BSSID calculated during init */
    869             if(pSiteMgr->pDesiredParams->siteMgrDesiredBSSType == BSS_INDEPENDENT)
    870             {
    871                 pSiteMgr->ibssBssid[MAC_ADDR_LEN - 1] ++;
    872             }
    873 
    874             /*siteMgr_resetAllSiteTables(pSiteMgr); */
    875             sme_Restart (pSiteMgr->hSmeSm);
    876         }
    877         return TI_OK;
    878 
    879     case SITE_MGR_OPERATIONAL_MODE_PARAM:
    880 
    881         if(pParam->content.siteMgrDot11OperationalMode < DOT11_B_MODE ||
    882             pParam->content.siteMgrDot11OperationalMode > DOT11_G_MODE )
    883             return PARAM_VALUE_NOT_VALID;
    884 
    885         pSiteMgr->siteMgrOperationalMode = pParam->content.siteMgrDot11OperationalMode;
    886         break;
    887 
    888 
    889     case SITE_MGR_RADIO_BAND_PARAM:
    890         if((TI_INT8)pParam->content.siteMgrRadioBand < RADIO_BAND_2_4_GHZ ||
    891            (TI_INT8)pParam->content.siteMgrRadioBand > RADIO_BAND_DUAL )
    892             return PARAM_VALUE_NOT_VALID;
    893 
    894         pSiteMgr->prevRadioBand = pSiteMgr->radioBand;
    895         pSiteMgr->radioBand = pParam->content.siteMgrRadioBand;
    896         if(pSiteMgr->prevRadioBand != pSiteMgr->radioBand)
    897             siteMgr_bandParamsConfig(pSiteMgr, TI_FALSE);
    898 
    899         break;
    900 
    901     case SITE_MGR_DESIRED_SLOT_TIME_PARAM:
    902         if(pParam->content.siteMgrSlotTime != PHY_SLOT_TIME_LONG &&
    903            pParam->content.siteMgrSlotTime != PHY_SLOT_TIME_SHORT)
    904             return PARAM_VALUE_NOT_VALID;
    905 
    906         if (pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime != pParam->content.siteMgrSlotTime)
    907         {
    908             if (pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE)
    909             {
    910                 pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime = pParam->content.siteMgrSlotTime;
    911                 if (!pPrimarySite)
    912                     TWD_CfgSlotTime (pSiteMgr->hTWD, pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime);
    913                 else if (pPrimarySite->bssType != BSS_INFRASTRUCTURE)
    914                     TWD_CfgSlotTime (pSiteMgr->hTWD, pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime);
    915             }
    916 
    917         }
    918         return TI_OK;
    919 
    920     case SITE_MGR_BEACON_FILTER_DESIRED_STATE_PARAM:
    921         {
    922             /* Check if the Desired  mode has changed - If not no need to send the MIB to the FW */
    923             if (pSiteMgr->beaconFilterParams.desiredState == pParam->content.siteMgrDesiredBeaconFilterState)
    924             {
    925                 TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "Beacon Filter already \n");
    926                 break;
    927             }
    928 
    929             /* Set the New Desired User request of Beacon Filter */
    930             pSiteMgr->beaconFilterParams.desiredState = pParam->content.siteMgrDesiredBeaconFilterState;
    931 
    932             TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "New Beacon Filter State is: \n");
    933 
    934             /* Send the User required Beacon Filter Configuration to the FW */
    935             TWD_CfgBeaconFilterOpt (pSiteMgr->hTWD, pSiteMgr->beaconFilterParams.desiredState, pSiteMgr->beaconFilterParams.numOfStored);
    936         }
    937 
    938         break;
    939 
    940     case SITE_MGR_LAST_RX_RATE_PARAM:
    941         if (pPrimarySite != NULL)
    942         {
    943             pPrimarySite->rxRate = pParam->content.ctrlDataCurrentBasicRate;
    944         }
    945         break;
    946 
    947     case SITE_MGR_CURRENT_CHANNEL_PARAM:
    948         if (!pPrimarySite)
    949         {
    950             return NO_SITE_SELECTED_YET;
    951         }
    952         pPrimarySite->channel = pParam->content.siteMgrCurrentChannel;
    953         break;
    954 
    955     case SITE_MGR_CURRENT_SIGNAL_PARAM:
    956         if (!pPrimarySite)
    957         {
    958             return NO_SITE_SELECTED_YET;
    959         }
    960 
    961         pPrimarySite->rssi = pParam->content.siteMgrCurrentSignal.rssi;
    962         break;
    963 
    964     case SITE_MGRT_SET_RATE_MANAGMENT:
    965         TWD_SetRateMngDebug(pSiteMgr->hTWD,&pParam ->content.RateMng);
    966         break;
    967     case SITE_MGR_SET_WLAN_IP_PARAM:
    968         {
    969             ArpRspTemplate_t      ArpRspTemplate;
    970             TSetTemplate          templateStruct;
    971             TIpAddr staIp;
    972             EArpFilterType        filterType = ArpFilterEnabledAutoMode;
    973 
    974             staIp[0] = pParam->content.StationIP[0];
    975             staIp[1] = pParam->content.StationIP[1];
    976             staIp[2] = pParam->content.StationIP[2];
    977             staIp[3] = pParam->content.StationIP[3];
    978 
    979             templateStruct.type = ARP_RSP_TEMPLATE;
    980             templateStruct.ptr  = (TI_UINT8 *)&ArpRspTemplate;
    981 
    982             buildArpRspTemplate(pSiteMgr, &templateStruct, staIp);
    983             TWD_CmdTemplate (pSiteMgr->hTWD, &templateStruct, NULL, NULL);
    984 
    985             /* configuring the IP to 0.0.0.0 by app means disable filtering */
    986             if ((staIp[0] | staIp[1] | staIp[2] | staIp[3]) == 0)
    987             {
    988                 filterType = ArpFilterDisabled;
    989             }
    990 
    991             TWD_CfgArpIpAddrTable(pSiteMgr->hTWD, staIp , filterType, IP_VER_4);
    992         }
    993 
    994         break;
    995 
    996     default:
    997         TRACE1(pSiteMgr->hReport, REPORT_SEVERITY_ERROR, "Set param, Params is not supported, %d\n", pParam->paramType);
    998         return PARAM_NOT_SUPPORTED;
    999     }
   1000 
   1001     return TI_OK;
   1002 }
   1003 
   1004 TI_STATUS siteMgr_getParamWSC(TI_HANDLE hSiteMgr, TIWLN_SIMPLE_CONFIG_MODE *wscParam)
   1005 { /* SITE_MGR_SIMPLE_CONFIG_MODE: - Retrieving the WiFiSimpleConfig mode */
   1006     siteMgr_t       *pSiteMgr = (siteMgr_t *)hSiteMgr;
   1007 
   1008 	if (pSiteMgr == NULL)
   1009 	{
   1010 		return TI_NOK;
   1011 	}
   1012 
   1013     *wscParam = pSiteMgr->siteMgrWSCCurrMode;
   1014     return TI_OK;
   1015 }
   1016 
   1017 /***********************************************************************
   1018  *                        siteMgr_getParam
   1019  ***********************************************************************
   1020 DESCRIPTION: Site mgr get param function, called by the following:
   1021             -   config mgr in order to get a parameter from the OS abstraction layer.
   1022             -   From inside the dirver
   1023 
   1024 INPUT:      hSiteMgr    -   site mgr handle.
   1025             pParam  -   Pointer to the parameter
   1026 
   1027 OUTPUT:
   1028 
   1029 RETURN:     TI_OK on success, TI_NOK otherwise
   1030 
   1031 ************************************************************************/
   1032 TI_STATUS siteMgr_getParam(TI_HANDLE        hSiteMgr,
   1033                             paramInfo_t     *pParam)
   1034 {
   1035     siteMgr_t       *pSiteMgr = (siteMgr_t *)hSiteMgr;
   1036     siteEntry_t     *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
   1037     TI_STATUS       status = TI_OK;
   1038     TI_UINT8           siteEntryIndex;
   1039     TTwdParamInfo   tTwdParam;
   1040 
   1041 	if(pSiteMgr == NULL)
   1042 	{
   1043 		return TI_NOK;
   1044 	}
   1045 
   1046     switch(pParam->paramType)
   1047     {
   1048 
   1049     case SITE_MGR_CONFIGURATION_PARAM:
   1050         pParam->content.pSiteMgrConfiguration->Length = sizeof(OS_802_11_CONFIGURATION);
   1051         pParam->content.pSiteMgrConfiguration->ATIMWindow = pSiteMgr->pDesiredParams->siteMgrDesiredAtimWindow;
   1052         pParam->content.pSiteMgrConfiguration->BeaconPeriod = pSiteMgr->pDesiredParams->siteMgrDesiredBeaconInterval;
   1053         pParam->content.pSiteMgrConfiguration->Union.channel =
   1054             Chan2Freq(pSiteMgr->pDesiredParams->siteMgrDesiredChannel);
   1055             /*pSiteMgr->pDesiredParams->siteMgrFreq2ChannelTable[pSiteMgr->pDesiredParams->siteMgrDesiredChannel];*/
   1056         break;
   1057 
   1058     case SITE_MGR_DESIRED_CHANNEL_PARAM:
   1059         pParam->content.siteMgrDesiredChannel = pSiteMgr->pDesiredParams->siteMgrDesiredChannel;
   1060         break;
   1061 
   1062 	case SITE_MGR_SIMPLE_CONFIG_MODE: /* Retrieving the WiFiSimpleConfig mode */
   1063 		pParam->content.siteMgrWSCMode.WSCMode = pSiteMgr->siteMgrWSCCurrMode;
   1064 
   1065         TRACE1(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "Retrieving the SimpleConfig Mode (%d) \n", pSiteMgr->siteMgrWSCCurrMode);
   1066 		break;
   1067 
   1068     case SITE_MGR_DESIRED_SUPPORTED_RATE_SET_PARAM:
   1069         getSupportedRateSet(pSiteMgr, &(pParam->content.siteMgrDesiredSupportedRateSet));
   1070         break;
   1071 
   1072     case SITE_MGR_DESIRED_MODULATION_TYPE_PARAM:
   1073         pParam->content.siteMgrDesiredModulationType = pSiteMgr->pDesiredParams->siteMgrDesiredModulationType;
   1074         break;
   1075 
   1076     case SITE_MGR_DESIRED_BEACON_INTERVAL_PARAM:
   1077         pParam->content.siteMgrDesiredBeaconInterval = pSiteMgr->pDesiredParams->siteMgrDesiredBeaconInterval;
   1078         break;
   1079 
   1080     case SITE_MGR_DESIRED_PREAMBLE_TYPE_PARAM:
   1081         pParam->content.siteMgrDesiredPreambleType = pSiteMgr->pDesiredParams->siteMgrDesiredPreambleType;
   1082         break;
   1083 
   1084     case SITE_MGR_CURRENT_SIGNAL_PARAM:
   1085         if (!pPrimarySite)
   1086         {
   1087             pParam->content.siteMgrCurrentSignal.rssi = 0;
   1088             pParam->content.siteMgrCurrentSignal.snr = 0;
   1089             return NO_SITE_SELECTED_YET;
   1090         }
   1091 
   1092         pParam->content.siteMgrCurrentSignal.rssi = pPrimarySite->rssi;
   1093         pParam->content.siteMgrCurrentSignal.snr = pPrimarySite->snr;
   1094         break;
   1095 
   1096     case SITE_MGR_POWER_CONSTRAINT_PARAM:
   1097         if (!pPrimarySite)
   1098         {
   1099             pParam->content.powerConstraint = 0;
   1100             return NO_SITE_SELECTED_YET;
   1101         }
   1102         pParam->content.powerConstraint = pPrimarySite->powerConstraint;
   1103         break;
   1104 
   1105 
   1106     case SITE_MGR_DTIM_PERIOD_PARAM:
   1107         if (!pPrimarySite)
   1108         {
   1109             pParam->content.siteMgrDtimPeriod = 0;
   1110             return NO_SITE_SELECTED_YET;
   1111         }
   1112         pParam->content.siteMgrDtimPeriod = pPrimarySite->dtimPeriod;
   1113         break;
   1114 
   1115     case SITE_MGR_BEACON_RECV:
   1116         if (!pPrimarySite)
   1117         {
   1118             pParam->content.siteMgrBeaconRecv = TI_FALSE;
   1119             return NO_SITE_SELECTED_YET;
   1120         }
   1121         pParam->content.siteMgrBeaconRecv = pPrimarySite->beaconRecv;
   1122         break;
   1123 
   1124 
   1125     case SITE_MGR_BEACON_INTERVAL_PARAM:
   1126         if (!pPrimarySite)
   1127         {
   1128             pParam->content.beaconInterval = 0;
   1129             return NO_SITE_SELECTED_YET;
   1130         }
   1131         pParam->content.beaconInterval = pPrimarySite->beaconInterval;
   1132         break;
   1133 
   1134     case SITE_MGR_AP_TX_POWER_PARAM:
   1135         if (!pPrimarySite)
   1136         {
   1137             pParam->content.APTxPower = 0;
   1138             return NO_SITE_SELECTED_YET;
   1139         }
   1140         pParam->content.APTxPower = pPrimarySite->APTxPower;
   1141         break;
   1142 
   1143     case SITE_MGR_SITE_CAPABILITY_PARAM:
   1144         if (!pPrimarySite)
   1145         {
   1146             pParam->content.siteMgrSiteCapability = 0;
   1147             return NO_SITE_SELECTED_YET;
   1148         }
   1149         pParam->content.siteMgrSiteCapability = pPrimarySite->capabilities;
   1150         break;
   1151 
   1152     case SITE_MGR_CURRENT_CHANNEL_PARAM:
   1153         if (!pPrimarySite)
   1154         {
   1155             pParam->content.siteMgrCurrentChannel = 0;
   1156             return NO_SITE_SELECTED_YET;
   1157         }
   1158         pParam->content.siteMgrCurrentChannel = pPrimarySite->channel;
   1159         break;
   1160 
   1161     case SITE_MGR_CURRENT_SSID_PARAM:
   1162         if (!pPrimarySite)
   1163         {
   1164             os_memoryZero(pSiteMgr->hOs, (void *)pParam->content.siteMgrCurrentSSID.str, MAX_SSID_LEN);
   1165             pParam->content.siteMgrCurrentSSID.len = 0;
   1166             return NO_SITE_SELECTED_YET;
   1167         }
   1168         if(pPrimarySite->ssid.len == 0)
   1169             TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_ERROR, "siteMgr_getParam: ssid length is zero, while primarySite is selected \n");
   1170         os_memoryCopy(pSiteMgr->hOs, &pParam->content.siteMgrCurrentSSID, &pPrimarySite->ssid, sizeof(TSsid));
   1171         break;
   1172 
   1173 
   1174     case SITE_MGR_CURRENT_BSS_TYPE_PARAM:
   1175         if (!pPrimarySite)
   1176         {
   1177             pParam->content.siteMgrCurrentBSSType = pSiteMgr->pDesiredParams->siteMgrDesiredBSSType;
   1178             TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_ERROR, "Trying to get current BSS Type while no site is selected\n");
   1179 
   1180         }
   1181         else{
   1182             pParam->content.siteMgrCurrentBSSType = pPrimarySite->bssType;
   1183         }
   1184 
   1185         break;
   1186 
   1187 
   1188     case SITE_MGR_CURRENT_RATE_PAIR_PARAM:
   1189         if (!pPrimarySite)
   1190         {
   1191             pParam->content.siteMgrCurrentRateMask.basicRateMask = 0;
   1192             pParam->content.siteMgrCurrentRateMask.supportedRateMask = 0;
   1193             return NO_SITE_SELECTED_YET;
   1194         }
   1195         pParam->content.siteMgrCurrentRateMask.basicRateMask = pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask;
   1196         pParam->content.siteMgrCurrentRateMask.supportedRateMask = pSiteMgr->pDesiredParams->siteMgrMatchedSuppRateMask;
   1197         TRACE4(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "SITE_MGR: bitmapBasicPrimary= 0x%X,bitMapBasicDesired = 0x%X,bitMapSuppPrimary = 0x%X, bitMapSuppDesired = 0x%X\n", pPrimarySite->rateMask.basicRateMask,pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask, pPrimarySite->rateMask.supportedRateMask,pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask);
   1198         break;
   1199 
   1200     case SITE_MGR_CURRENT_MODULATION_TYPE_PARAM:
   1201         if (!pPrimarySite)
   1202         {
   1203             pParam->content.siteMgrCurrentModulationType = DRV_MODULATION_NONE;
   1204             return NO_SITE_SELECTED_YET;
   1205         }
   1206         pParam->content.siteMgrCurrentModulationType = pSiteMgr->chosenModulation;
   1207         break;
   1208 
   1209     case SITE_MGR_DESIRED_SLOT_TIME_PARAM:
   1210         pParam->content.siteMgrSlotTime = pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime;
   1211         break;
   1212 
   1213     case SITE_MGR_CURRENT_SLOT_TIME_PARAM:
   1214 
   1215         if(pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE)
   1216         {
   1217             if(!pPrimarySite)
   1218                 pParam->content.siteMgrSlotTime = pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime;
   1219             else
   1220                 pParam->content.siteMgrSlotTime = pPrimarySite->currentSlotTime;
   1221         }
   1222         else if(pSiteMgr->siteMgrOperationalMode == DOT11_A_MODE)
   1223             pParam->content.siteMgrSlotTime = PHY_SLOT_TIME_SHORT;
   1224         else
   1225             pParam->content.siteMgrSlotTime = PHY_SLOT_TIME_LONG;
   1226 
   1227         break;
   1228 
   1229     case SITE_MGR_LAST_BEACON_BUF_PARAM:
   1230         if (pPrimarySite != NULL)
   1231         {
   1232             if (pPrimarySite->probeRecv)
   1233             {
   1234                 pParam->content.siteMgrLastBeacon.isBeacon = TI_FALSE;
   1235                 pParam->content.siteMgrLastBeacon.bufLength = pPrimarySite->probeRespLength;
   1236                 pParam->content.siteMgrLastBeacon.buffer = pPrimarySite->probeRespBuffer;
   1237             }
   1238             else
   1239             {
   1240                 pParam->content.siteMgrLastBeacon.isBeacon = TI_TRUE;
   1241                 pParam->content.siteMgrLastBeacon.bufLength = pPrimarySite->beaconLength;
   1242                 pParam->content.siteMgrLastBeacon.buffer = pPrimarySite->beaconBuffer;
   1243             }
   1244         }
   1245         break;
   1246 
   1247     case SITE_MGR_BEACON_FILTER_DESIRED_STATE_PARAM:
   1248         {
   1249             if ( NULL != pSiteMgr )
   1250             {
   1251                 pParam->content.siteMgrDesiredBeaconFilterState = pSiteMgr->beaconFilterParams.desiredState;
   1252             }
   1253             else
   1254             {
   1255                 TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_ERROR, "pSite = NULL ! No info available");
   1256             }
   1257         }
   1258         break;
   1259 
   1260     case SITE_MGR_GET_SELECTED_BSSID_INFO:
   1261         getPrimarySiteDesc(pSiteMgr, pParam->content.pSiteMgrPrimarySiteDesc, TI_FALSE);
   1262         break;
   1263 
   1264 	case SITE_MGR_GET_SELECTED_BSSID_INFO_EX:
   1265        getPrimarySiteDesc(pSiteMgr, (OS_802_11_BSSID *)pParam->content.pSiteMgrSelectedSiteInfo,TI_TRUE);
   1266        break;
   1267 
   1268     case SITE_MGR_PRIMARY_SITE_PARAM:
   1269        status = getPrimaryBssid(pSiteMgr, (OS_802_11_BSSID_EX *)pParam->content.pSiteMgrSelectedSiteInfo, &pParam->paramLength);
   1270        break;
   1271 
   1272 
   1273     case SITE_MGR_TI_WLAN_COUNTERS_PARAM:
   1274         pParam->paramType = RX_DATA_COUNTERS_PARAM;
   1275         rxData_getParam(pSiteMgr->hRxData, pParam);
   1276 
   1277         tTwdParam.paramType = TWD_COUNTERS_PARAM_ID;
   1278         TWD_GetParam (pSiteMgr->hTWD, &tTwdParam);
   1279         pParam->content.siteMgrTiWlanCounters.RecvNoBuffer = tTwdParam.content.halCtrlCounters.RecvNoBuffer;
   1280         pParam->content.siteMgrTiWlanCounters.FragmentsRecv = tTwdParam.content.halCtrlCounters.FragmentsRecv;
   1281         pParam->content.siteMgrTiWlanCounters.FrameDuplicates = tTwdParam.content.halCtrlCounters.FrameDuplicates;
   1282         pParam->content.siteMgrTiWlanCounters.FcsErrors = tTwdParam.content.halCtrlCounters.FcsErrors;
   1283         pParam->content.siteMgrTiWlanCounters.RecvError = tTwdParam.content.halCtrlCounters.RecvError;
   1284 
   1285         pParam->paramType = AUTH_COUNTERS_PARAM;
   1286         auth_getParam(pSiteMgr->hAuth, pParam);
   1287 
   1288 		pParam->paramType = MLME_BEACON_RECV;
   1289         mlme_getParam(pSiteMgr->hMlmeSm, pParam);
   1290 
   1291         pParam->paramType = ASSOC_COUNTERS_PARAM;
   1292         assoc_getParam(pSiteMgr->hAssoc, pParam);
   1293         pParam->content.siteMgrTiWlanCounters.BeaconsXmit = pSiteMgr->beaconSentCount;
   1294         break;
   1295 
   1296     case SITE_MGR_FIRMWARE_VERSION_PARAM:
   1297         {
   1298             TFwInfo *pFwInfo = TWD_GetFWInfo (pSiteMgr->hTWD);
   1299             os_memoryCopy(pSiteMgr->hOs,
   1300                           pParam->content.siteMgrFwVersion,
   1301                           pFwInfo->fwVer,
   1302                           sizeof(pFwInfo->fwVer));
   1303         }
   1304         break;
   1305 
   1306     case SITE_MGR_CURRENT_TX_RATE_PARAM:
   1307         {
   1308             ERate rate = txCtrlParams_GetTxRate (pSiteMgr->hTxCtrl);
   1309             pParam->content.siteMgrCurrentTxRate = rate_DrvToNet (rate);
   1310         }
   1311         break;
   1312 
   1313     case SITE_MGR_CURRENT_RX_RATE_PARAM:
   1314         {
   1315             pParam->paramType = RX_DATA_RATE_PARAM;
   1316             rxData_getParam (pSiteMgr->hRxData, pParam);
   1317             pParam->content.siteMgrCurrentRxRate =
   1318                 (TI_UINT8)rate_DrvToNet ((ERate)pParam->content.siteMgrCurrentRxRate);
   1319         }
   1320         break;
   1321 
   1322     case SITE_MGR_DESIRED_DOT11_MODE_PARAM:
   1323         pParam->content.siteMgrDot11Mode = pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode;
   1324         break;
   1325 
   1326 	case SITE_MGR_NETWORK_TYPE_IN_USE:
   1327 		if (pPrimarySite)
   1328 		{ /* Connected - return the current mode */
   1329 			pParam->content.siteMgrDot11Mode = pSiteMgr->siteMgrOperationalMode;
   1330 		}
   1331 		else
   1332 		{ /* Disconnected - return the desired mode */
   1333 			pParam->content.siteMgrDot11Mode = pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode;
   1334 		}
   1335         break;
   1336 
   1337 
   1338     case SITE_MGR_OPERATIONAL_MODE_PARAM:
   1339         pParam->content.siteMgrDot11OperationalMode = pSiteMgr->siteMgrOperationalMode;
   1340         break;
   1341 
   1342     case SITE_MGR_RADIO_BAND_PARAM:
   1343         pParam->content.siteMgrRadioBand = pSiteMgr->radioBand;
   1344         break;
   1345 
   1346     case SITE_MGR_CURRENT_PREAMBLE_TYPE_PARAM:
   1347         if (!pPrimarySite)
   1348             return NO_SITE_SELECTED_YET;
   1349 
   1350         pParam->content.siteMgrCurrentPreambleType = pPrimarySite->currentPreambleType;
   1351         break;
   1352 
   1353     case SITE_MGR_CURRENT_BSSID_PARAM:
   1354         if (pPrimarySite != NULL)
   1355         {
   1356             MAC_COPY (pParam->content.siteMgrDesiredBSSID, pPrimarySite->bssid);
   1357         }
   1358 		else
   1359 			return NO_SITE_SELECTED_YET;
   1360         break;
   1361 
   1362     case SITE_MGR_LAST_RX_RATE_PARAM:
   1363         if (pPrimarySite != NULL)
   1364         {
   1365             pParam->content.ctrlDataCurrentBasicRate = pPrimarySite->rxRate;
   1366         }
   1367         break;
   1368 
   1369 	case SITE_MGR_GET_STATS:
   1370         if (pPrimarySite != NULL)
   1371         {
   1372 			pParam->content.siteMgrCurrentRssi = pPrimarySite->rssi;
   1373         }
   1374         break;
   1375 
   1376     case SITE_MGR_PREV_SITE_BSSID_PARAM:
   1377         if (pSiteMgr->pSitesMgmtParams->pPrevPrimarySite==NULL)
   1378         {
   1379             return TI_NOK;
   1380         }
   1381         MAC_COPY (pParam->content.siteMgrDesiredBSSID, pSiteMgr->pSitesMgmtParams->pPrevPrimarySite->bssid);
   1382         break;
   1383 
   1384     case SITE_MGR_PREV_SITE_SSID_PARAM:
   1385         if (pSiteMgr->pSitesMgmtParams->pPrevPrimarySite==NULL)
   1386         {
   1387             return TI_NOK;
   1388         }
   1389         /* It looks like it never happens. Anyway decided to check */
   1390         if ( pSiteMgr->pSitesMgmtParams->pPrevPrimarySite->ssid.len > MAX_SSID_LEN )
   1391         {
   1392             TRACE2( pSiteMgr->hReport, REPORT_SEVERITY_ERROR,
   1393                    "siteMgr_getParam. pSiteMgr->pSitesMgmtParams->pPrevPrimarySite->ssid.len=%d exceeds the limit %d\n",
   1394                    pSiteMgr->pSitesMgmtParams->pPrevPrimarySite->ssid.len, MAX_SSID_LEN);
   1395             handleRunProblem(PROBLEM_BUF_SIZE_VIOLATION);
   1396             return TI_NOK;
   1397         }
   1398         pParam->content.siteMgrDesiredSSID.len = pSiteMgr->pSitesMgmtParams->pPrevPrimarySite->ssid.len;
   1399         os_memoryCopy(pSiteMgr->hOs,
   1400                       (void *)pParam->content.siteMgrDesiredSSID.str,
   1401                       (void *)pSiteMgr->pSitesMgmtParams->pPrevPrimarySite->ssid.str,
   1402                       pSiteMgr->pSitesMgmtParams->pPrevPrimarySite->ssid.len);
   1403         break;
   1404 
   1405     case SITE_MGR_PREV_SITE_CHANNEL_PARAM:
   1406         if (pSiteMgr->pSitesMgmtParams->pPrevPrimarySite==NULL)
   1407         {
   1408             return TI_NOK;
   1409         }
   1410         pParam->content.siteMgrDesiredChannel = pSiteMgr->pSitesMgmtParams->pPrevPrimarySite->channel;
   1411         break;
   1412 
   1413     case SITE_MGR_SITE_ENTRY_BY_INDEX:
   1414         siteEntryIndex = pParam->content.siteMgrIndexOfDesiredSiteEntry;
   1415         if(siteEntryIndex >= MAX_SITES_BG_BAND)
   1416         {
   1417             return TI_NOK;
   1418         }
   1419         pParam->content.pSiteMgrDesiredSiteEntry =
   1420             (TI_UINT8*)(&(pSiteMgr->pSitesMgmtParams->pCurrentSiteTable->siteTable[siteEntryIndex]));
   1421         break;
   1422 
   1423     case SITE_MGR_CUR_NUM_OF_SITES:
   1424         pParam->content.siteMgrNumberOfSites = pSiteMgr->pSitesMgmtParams->pCurrentSiteTable->numOfSites;
   1425         break;
   1426 
   1427     case SITE_MGR_CURRENT_TSF_TIME_STAMP:
   1428         os_memoryCopy(pSiteMgr->hOs, pParam->content.siteMgrCurrentTsfTimeStamp,
   1429                       pSiteMgr->pSitesMgmtParams->pPrimarySite->tsfTimeStamp,
   1430                       TIME_STAMP_LEN);
   1431         break;
   1432 
   1433     case SITE_MGR_GET_AP_QOS_CAPABILITIES:
   1434        if (!pPrimarySite)
   1435        {
   1436            pParam->content.qosApCapabilities.uQOSFlag = 0;
   1437            pParam->content.qosApCapabilities.uAPSDFlag = 0;
   1438            TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_ERROR, "Not connected to an AP...\n");
   1439            return NOT_CONNECTED;
   1440        }
   1441        pParam->content.qosApCapabilities.uQOSFlag = pPrimarySite->WMESupported;
   1442        pParam->content.qosApCapabilities.uAPSDFlag = pPrimarySite->APSDSupport;
   1443        break;
   1444 
   1445     case SITE_MGR_GET_PRIMARY_SITE:
   1446        if (!pPrimarySite)
   1447        {
   1448            pParam->content.pPrimarySite = (void *)NULL;
   1449            return NOT_CONNECTED;
   1450        }
   1451        else
   1452        {
   1453            pParam->content.pPrimarySite = (void *)pPrimarySite;
   1454        }
   1455        break;
   1456 
   1457     case SITE_MGR_PRIMARY_SITE_HT_SUPPORT:
   1458        if (!pPrimarySite)
   1459        {
   1460            pParam->content.bPrimarySiteHtSupport = TI_FALSE;
   1461            return NOT_CONNECTED;
   1462        }
   1463        else
   1464        {
   1465            if((pPrimarySite->tHtCapabilities.tHdr[0] != TI_FALSE) && (pPrimarySite->tHtInformation.tHdr[0] != TI_FALSE))
   1466            {
   1467                pParam->content.bPrimarySiteHtSupport = TI_TRUE;
   1468            }
   1469            else
   1470            {
   1471                pParam->content.bPrimarySiteHtSupport = TI_FALSE;
   1472            }
   1473        }
   1474        break;
   1475     case SITE_MGRT_GET_RATE_MANAGMENT:
   1476          return cmdBld_ItrRateParams (pSiteMgr->hTWD,
   1477                                       pParam->content.interogateCmdCBParams.fCb,
   1478                                       pParam->content.interogateCmdCBParams.hCb,
   1479                                       (void*)pParam->content.interogateCmdCBParams.pCb);
   1480 
   1481     default:
   1482         {
   1483             TRACE1(pSiteMgr->hReport, REPORT_SEVERITY_ERROR, "Get param, Params is not supported, 0x%x\n", pParam->paramType);
   1484         }
   1485 
   1486         return PARAM_NOT_SUPPORTED;
   1487     }
   1488 
   1489     return status;
   1490 }
   1491 
   1492 
   1493 /***********************************************************************
   1494  *                        siteMgr_join
   1495  ***********************************************************************
   1496 DESCRIPTION: Called by the connection state machine in order to join a BSS.
   1497                 -   If the BSS is infrastructure, sets a NULL data template to the HAL
   1498                 -   If the BSS is IBSS, sets a probe response & beacon template to the HAL
   1499             Call the HAL with the join parameters
   1500 
   1501 
   1502 INPUT:      hSiteMgr    -   site mgr handle.
   1503             JoinCompleteCB - join command complete callback function ptr
   1504             CB_handle - handle to pass to callback function
   1505 
   1506 OUTPUT:
   1507 
   1508 RETURN:     TI_OK on success, TI_NOK otherwise
   1509 
   1510 ************************************************************************/
   1511 TI_STATUS siteMgr_join(TI_HANDLE    hSiteMgr)
   1512 {
   1513     siteMgr_t               *pSiteMgr = (siteMgr_t *)hSiteMgr;
   1514     TJoinBss                joinParams;
   1515     TSetTemplate            templateStruct;
   1516     probeRspTemplate_t      probeRspTemplate;
   1517     nullDataTemplate_t      nullDataTemplate;
   1518     disconnTemplate_t       disconnTemplate;
   1519     psPollTemplate_t        psPollTemplate;
   1520     QosNullDataTemplate_t   QosNullDataTemplate;
   1521     siteEntry_t             *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
   1522     EPreamble               curPreamble;
   1523 
   1524     if (pPrimarySite == NULL)
   1525     {
   1526         TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_ERROR, "Join BSS, Primary Site is NULL\n");
   1527         return TI_OK;
   1528     }
   1529 
   1530     /* Configure the system according to parameters of Primary Site */
   1531     systemConfig(pSiteMgr);
   1532 
   1533     joinParams.bssType = pPrimarySite->bssType;
   1534     joinParams.beaconInterval = pPrimarySite->beaconInterval;
   1535     joinParams.dtimInterval = pPrimarySite->dtimPeriod;
   1536     joinParams.pBSSID = (TI_UINT8 *)&pPrimarySite->bssid;
   1537     joinParams.pSSID = (TI_UINT8 *)&pPrimarySite->ssid.str;
   1538     joinParams.ssidLength = pPrimarySite->ssid.len;
   1539 
   1540     /*
   1541      * Set the radio band and the HW management Tx rate according to operational mode.
   1542      * The HW management frames includes Beacon and Probe-Response (in IBSS).
   1543      */
   1544     if(pSiteMgr->siteMgrOperationalMode == DOT11_A_MODE)
   1545     {
   1546         joinParams.radioBand = RADIO_BAND_5_0_GHZ;
   1547     }
   1548     else
   1549     {
   1550         joinParams.radioBand = RADIO_BAND_2_4_GHZ;
   1551     }
   1552 
   1553     joinParams.channel = pPrimarySite->channel;
   1554     if (joinParams.channel == SPECIAL_BG_CHANNEL)
   1555     {
   1556          joinParams.basicRateSet     = (TI_UINT16)rate_GetDrvBitmapForDefaultBasicSet ();
   1557     }
   1558     else /* != SPECIAL_BG_CHANNEL */
   1559     {
   1560         joinParams.basicRateSet = (TI_UINT16)pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask;
   1561     }
   1562 
   1563     ctrlData_getParamPreamble(pSiteMgr->hCtrlData, &curPreamble); /* CTRL_DATA_CURRENT_PREAMBLE_TYPE_PARAM */
   1564     /* Set the preamble before the join */
   1565     TWD_CfgPreamble (pSiteMgr->hTWD, curPreamble);
   1566 
   1567     /* Now, Set templates to the HAL */
   1568     templateStruct.uRateMask = RATE_MASK_UNSPECIFIED;
   1569     if (pPrimarySite->bssType == BSS_INDEPENDENT)
   1570     {
   1571         templateStruct.ptr = (TI_UINT8 *)&probeRspTemplate;
   1572         templateStruct.type = PROBE_RESPONSE_TEMPLATE;
   1573         buildProbeRspTemplate(pSiteMgr, &templateStruct);
   1574         TWD_CmdTemplate (pSiteMgr->hTWD, &templateStruct, NULL, NULL);
   1575 
   1576         /* We don't have to build a beacon template, because it is equal to probe response,
   1577         we only have to change the frame sup type */
   1578         probeRspTemplate.hdr.fc = ENDIAN_HANDLE_WORD(DOT11_FC_BEACON);
   1579         templateStruct.type = BEACON_TEMPLATE;
   1580         TWD_CmdTemplate (pSiteMgr->hTWD, &templateStruct, NULL, NULL);
   1581     }
   1582     else
   1583     {
   1584         templateStruct.ptr = (TI_UINT8 *)&nullDataTemplate;
   1585         templateStruct.type = NULL_DATA_TEMPLATE;
   1586         buildNullTemplate(pSiteMgr, &templateStruct);
   1587         TWD_CmdTemplate (pSiteMgr->hTWD, &templateStruct, NULL, NULL);
   1588 
   1589         /* Send PsPoll template to HAL */
   1590         templateStruct.ptr = (TI_UINT8 *)&psPollTemplate;
   1591         templateStruct.type = PS_POLL_TEMPLATE;
   1592         buildPsPollTemplate(pSiteMgr, &templateStruct);
   1593         TWD_CmdTemplate (pSiteMgr->hTWD, &templateStruct, NULL, NULL);
   1594 
   1595         /* Set QOS Null data template to the firmware.
   1596             Note:  the AC to use with this template may change in QoS-manager. */
   1597         templateStruct.ptr = (TI_UINT8 *)&QosNullDataTemplate;
   1598         templateStruct.type = QOS_NULL_DATA_TEMPLATE;
   1599         buildQosNullDataTemplate(pSiteMgr, &templateStruct, 0);
   1600         TWD_CmdTemplate (pSiteMgr->hTWD, &templateStruct, NULL, NULL);
   1601 
   1602         /* Send disconnect (Deauth/Disassoc) template to HAL */
   1603         templateStruct.ptr = (TI_UINT8 *)&disconnTemplate;
   1604         templateStruct.type = DISCONN_TEMPLATE;
   1605         buildDisconnTemplate(pSiteMgr, &templateStruct);
   1606         TWD_CmdTemplate (pSiteMgr->hTWD, &templateStruct, NULL, NULL);
   1607     }
   1608 
   1609     /* Reset the Tx Power Control adjustment in RegulatoryDomain */
   1610     siteMgr_setTemporaryTxPower(pSiteMgr, TI_FALSE);
   1611 
   1612 	/* Get a new Tx-Session-Count (also updates the TxCtrl module). */
   1613 	joinParams.txSessionCount = incrementTxSessionCount(pSiteMgr);
   1614 
   1615     return TWD_CmdJoinBss (((siteMgr_t *)hSiteMgr)->hTWD, &joinParams);
   1616 }
   1617 
   1618 
   1619 /***********************************************************************
   1620  *                        siteMgr_removeSelfSite
   1621  ***********************************************************************
   1622 DESCRIPTION: Called by the Self connection state machine in order to remove the self site from the site table.
   1623                 Remove the site entry form the table and reset the primary site pointer
   1624 
   1625 
   1626 INPUT:      hSiteMgr    -   site mgr handle.
   1627 
   1628 OUTPUT:
   1629 
   1630 RETURN:     TI_OK on success, TI_NOK otherwise
   1631 
   1632 ************************************************************************/
   1633 TI_STATUS siteMgr_removeSelfSite(TI_HANDLE  hSiteMgr)
   1634 {
   1635     siteMgr_t           *pSiteMgr  = (siteMgr_t *)hSiteMgr;
   1636     siteTablesParams_t  *currTable = pSiteMgr->pSitesMgmtParams->pCurrentSiteTable;
   1637 
   1638     if(pSiteMgr->pSitesMgmtParams->pPrimarySite == NULL)
   1639     {
   1640         TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_WARNING, "Remove self site Failure, pointer is NULL\n\n");
   1641         return TI_OK;
   1642     }
   1643 
   1644     if(pSiteMgr->pSitesMgmtParams->pPrimarySite->siteType != SITE_SELF)
   1645     {
   1646         TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_ERROR, "Remove self site Failure, site is not self\n\n");
   1647         return TI_OK;
   1648     }
   1649 
   1650     removeSiteEntry(pSiteMgr, currTable, pSiteMgr->pSitesMgmtParams->pPrimarySite);
   1651     pSiteMgr->pSitesMgmtParams->pPrimarySite = NULL;
   1652 
   1653     return TI_OK;
   1654 }
   1655 
   1656 /***********************************************************************
   1657  *                        siteMgr_IbssMerge
   1658  ***********************************************************************/
   1659 TI_STATUS siteMgr_IbssMerge(TI_HANDLE       hSiteMgr,
   1660                           TMacAddr      	our_bssid,
   1661 						  TMacAddr      	new_bssid,
   1662                           mlmeFrameInfo_t   *pFrameInfo,
   1663                           TI_UINT8          rxChannel,
   1664                           ERadioBand        band)
   1665 {
   1666 	siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   1667     siteEntry_t *pSite;
   1668 	paramInfo_t Param;
   1669 
   1670 	pSite = findAndInsertSiteEntry(pSiteMgr, (TMacAddr*)&our_bssid, band);
   1671 
   1672 	if(!pSite) {
   1673 TRACE6(pSiteMgr->hReport, REPORT_SEVERITY_ERROR, "siteMgr_IbssMerge, cannot find our site table entry, our_bssid: %X-%X-%X-%X-%X-%X\n", 						   (our_bssid)[0], (our_bssid)[1], (our_bssid)[2], (our_bssid)[3], 						   (our_bssid)[4], (our_bssid)[5]);
   1674 		return TI_NOK;
   1675 	}
   1676 
   1677 	updateSiteInfo(pSiteMgr, pFrameInfo, pSite, rxChannel);
   1678 
   1679 	pSite->siteType = SITE_PRIMARY;
   1680 	pSiteMgr->pSitesMgmtParams->pPrimarySite = pSite;
   1681 
   1682 	MAC_COPY(pSite->bssid, new_bssid);
   1683 
   1684 	Param.paramType   = SITE_MGR_DESIRED_BSSID_PARAM;
   1685     Param.paramLength = sizeof(TMacAddr);
   1686 	MAC_COPY(Param.content.siteMgrDesiredBSSID, new_bssid);
   1687 
   1688 	siteMgr_setParam ( hSiteMgr, &Param );
   1689 
   1690 	conn_ibssMerge(pSiteMgr->hConn);
   1691 
   1692 	return TI_OK;
   1693 }
   1694 
   1695 
   1696 
   1697 /***********************************************************************
   1698  *                        siteMgr_updateSite
   1699  ***********************************************************************
   1700 DESCRIPTION: Called by the MLME parser upon receiving a beacon or probe response.
   1701             Performs the following:
   1702                 -   Insert the site entry into the site hash table
   1703                 -   Update the site information in the site table
   1704                 -   If the site is the primary site, it handles the PBCC algorithm if needed
   1705                 -   If the site is NULL (means it is the first frame received from this site)
   1706                     we update the site type to be regular
   1707                 -   If the site type is self, we inform the self connection SM
   1708                     that another station joined the network we created
   1709 
   1710 
   1711 INPUT:      hSiteMgr    -   site mgr handle.
   1712             bssid       -   BSSID received
   1713             pFrameInfo  -   Frame content after the parsing
   1714             rxChannel   -   The channel on which frame was received
   1715             band        -   Band on which frame was received
   1716             measuring   -   Determines whether the beacon or probe response
   1717                             has been received while a beacon measurement
   1718                             took place
   1719 
   1720 OUTPUT:
   1721 
   1722 RETURN:     TI_OK on success, TI_NOK otherwise
   1723 
   1724 ************************************************************************/
   1725 TI_STATUS siteMgr_updateSite(TI_HANDLE          hSiteMgr,
   1726                           TMacAddr      *bssid,
   1727                           mlmeFrameInfo_t   *pFrameInfo,
   1728                           TI_UINT8             rxChannel,
   1729                           ERadioBand       band,
   1730                           TI_BOOL              measuring)
   1731 {
   1732     siteEntry_t *pSite;
   1733     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   1734     paramInfo_t param;
   1735 
   1736 
   1737     /* The following is not required, since the scanCncn is responsible to check
   1738         the channels validity before scanning.
   1739         The problem it caused was that when 802.11d is enabled,
   1740         channels that are valid for Passive only, will not be updated.*/
   1741     /*if (isChannelSupprted(pSiteMgr->hRegulatoryDomain , rxChannel) == TI_FALSE)
   1742     {
   1743         TRACE1(pSiteMgr->hReport, REPORT_SEVERITY_WARNING, "Channel ERROR - try to register a site that its channel (=%d) isn't in the regulatory domain.\n\            registration ABORTED!!!", rxChannel);
   1744         return TI_NOK;
   1745     }*/
   1746 
   1747 
   1748     pSite = findAndInsertSiteEntry(pSiteMgr, bssid, band);
   1749 
   1750 
   1751 
   1752     if (pSite == NULL)
   1753     {
   1754         TRACE6(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "Site Update failure, table is full, bssid: %X-%X-%X-%X-%X-%X\n", (*bssid)[0], (*bssid)[1], (*bssid)[2], (*bssid)[3], (*bssid)[4], (*bssid)[5]);
   1755         return TI_OK;
   1756     }
   1757 
   1758     updateSiteInfo(pSiteMgr, pFrameInfo, pSite, rxChannel);
   1759 
   1760     switch(pSite->siteType)
   1761     {
   1762     case SITE_PRIMARY:
   1763         TRACE6(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "PRIMARY site updated, bssid: %X-%X-%X-%X-%X-%X\n\n", (*bssid)[0], (*bssid)[1], (*bssid)[2], (*bssid)[3], (*bssid)[4], (*bssid)[5]);
   1764         if (pSiteMgr->pSitesMgmtParams->pPrimarySite == NULL)
   1765         {
   1766             TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_ERROR, "siteMgr_updateSite: Primary Site Is NULL\n");
   1767             pSite->siteType = SITE_REGULAR;
   1768             break;
   1769         }
   1770         /* Now, if the following is TI_TRUE we perform the PBCC algorithm: */
   1771         /* If the BSS type is infrastructure, &&
   1772             The chosen modulation is PBCC &&
   1773             The beacon modulation is not NONE &&
   1774             The current data modulation is different than the beacon modulation. */
   1775         if ((pSite->bssType == BSS_INFRASTRUCTURE) &&
   1776             (pSiteMgr->chosenModulation == DRV_MODULATION_PBCC) &&
   1777             (pSite->beaconModulation != DRV_MODULATION_NONE) &&
   1778             (pSiteMgr->currentDataModulation != pSite->beaconModulation))
   1779         {
   1780             pSiteMgr->currentDataModulation = pSite->beaconModulation;
   1781             pbccAlgorithm(pSiteMgr);
   1782         }
   1783 
   1784         /* Now handle the slot time, first check if the slot time changed since the last
   1785            setting to the HAL ,and if yes set the new value */
   1786         if((pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE) &&
   1787            (pSite->bssType == BSS_INFRASTRUCTURE))
   1788         {
   1789             if (pSite->currentSlotTime != pSite->newSlotTime)
   1790             {
   1791                 pSite->currentSlotTime = pSite->newSlotTime;
   1792                 TWD_CfgSlotTime (pSiteMgr->hTWD, pSite->currentSlotTime);
   1793             }
   1794         }
   1795 
   1796         /* Now handle the current protection status */
   1797         if((pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE) && (pSite->bssType == BSS_INFRASTRUCTURE))
   1798         {
   1799             param.paramType = CTRL_DATA_CURRENT_PROTECTION_STATUS_PARAM;
   1800             param.content.ctrlDataProtectionEnabled = pSite->useProtection;
   1801             ctrlData_setParam(pSiteMgr->hCtrlData, &param);
   1802         }
   1803 
   1804         /* Now handle the current preamble type,
   1805            if desired preamble type is long, the ctrl data param should not be changed */
   1806         if((pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE) &&
   1807            (pSite->bssType == BSS_INFRASTRUCTURE) &&
   1808            (pSiteMgr->pDesiredParams->siteMgrDesiredPreambleType != PREAMBLE_LONG))
   1809         {
   1810             param.paramType = CTRL_DATA_CURRENT_PREAMBLE_TYPE_PARAM;
   1811             if((pSite->preambleAssRspCap == PREAMBLE_LONG) ||
   1812                (pSite->barkerPreambleType == PREAMBLE_LONG))
   1813                   {
   1814                 param.content.ctrlDataCurrentPreambleType = PREAMBLE_LONG;
   1815             }
   1816             else
   1817                 param.content.ctrlDataCurrentPreambleType = PREAMBLE_SHORT;
   1818 
   1819             ctrlData_setParam(pSiteMgr->hCtrlData, &param);
   1820         }
   1821 
   1822         param.paramType = CTRL_DATA_RATE_CONTROL_ENABLE_PARAM;
   1823         ctrlData_setParam(pSiteMgr->hCtrlData, &param);
   1824         break;
   1825 
   1826     case SITE_NULL:
   1827         pSite->siteType = SITE_REGULAR;
   1828         TRACE6(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "REGULAR site added, bssid: %X-%X-%X-%X-%X-%X\n\n", (*bssid)[0], (*bssid)[1], (*bssid)[2], (*bssid)[3], (*bssid)[4], (*bssid)[5]);
   1829         break;
   1830 
   1831     case SITE_SELF:
   1832         pSite->siteType = SITE_PRIMARY;
   1833         TRACE6(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "SELF ----> PRIMARY site , bssid: %X-%X-%X-%X-%X-%X\n\n", (*bssid)[0], (*bssid)[1], (*bssid)[2], (*bssid)[3], (*bssid)[4], (*bssid)[5]);
   1834         conn_ibssStaJoined(pSiteMgr->hConn);
   1835         break;
   1836 
   1837     case SITE_REGULAR:
   1838         TRACE6(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "REGULAR site updated, bssid: %X-%X-%X-%X-%X-%X\n\n", (*bssid)[0], (*bssid)[1], (*bssid)[2], (*bssid)[3], (*bssid)[4], (*bssid)[5]);
   1839         break;
   1840 
   1841     default:
   1842         TRACE6(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "Setting site type failure, bssid: %X-%X-%X-%X-%X-%X\n\n", (*bssid)[0], (*bssid)[1], (*bssid)[2], (*bssid)[3], (*bssid)[4], (*bssid)[5]);
   1843         break;
   1844     }
   1845 
   1846     return TI_OK;
   1847 }
   1848 
   1849 /***********************************************************************
   1850  *                        siteMgr_start
   1851  ***********************************************************************
   1852 DESCRIPTION: Called by the SME SM in order to start the aging timer
   1853 
   1854 
   1855 INPUT:      hSiteMgr    -   site mgr handle.
   1856 
   1857 OUTPUT:
   1858 
   1859 RETURN:     TI_OK on success, TI_NOK otherwise
   1860 
   1861 ************************************************************************/
   1862 TI_STATUS siteMgr_start(TI_HANDLE   hSiteMgr)
   1863 {
   1864     siteMgr_t       *pSiteMgr = (siteMgr_t *)hSiteMgr;
   1865 
   1866     /* update timestamp each time aging started (needed for quiet scan) */
   1867     if(pSiteMgr->pSitesMgmtParams->pPrimarySite)
   1868         pSiteMgr->pSitesMgmtParams->pPrimarySite->localTimeStamp = os_timeStampMs(pSiteMgr->hOs);
   1869 
   1870     return TI_OK;
   1871 }
   1872 
   1873 
   1874 /***********************************************************************
   1875  *                        siteMgr_stop
   1876  ***********************************************************************
   1877 DESCRIPTION: Called by the SME SM in order to stop site mgr timers
   1878 
   1879 
   1880 INPUT:      hSiteMgr    -   site mgr handle.
   1881 
   1882 OUTPUT:
   1883 
   1884 RETURN:     TI_OK on success, TI_NOK otherwise
   1885 
   1886 ************************************************************************/
   1887 TI_STATUS siteMgr_stop(TI_HANDLE    hSiteMgr)
   1888 {
   1889 
   1890     return TI_OK;
   1891 }
   1892 
   1893 
   1894 /***********************************************************************
   1895  *                        siteMgr_updatePrimarySiteFailStatus
   1896  ***********************************************************************
   1897 DESCRIPTION: Called by the SME SM when the connection with the primary site fails
   1898                 If the primary site is NULL, return.
   1899 
   1900 
   1901 INPUT:      hSiteMgr    -   site mgr handle.
   1902             bRemoveSite -   Whether to remove the site
   1903 
   1904 OUTPUT:
   1905 
   1906 RETURN:     TI_OK on success, TI_NOK otherwise
   1907 
   1908 ************************************************************************/
   1909 
   1910 TI_STATUS siteMgr_updatePrimarySiteFailStatus(TI_HANDLE hSiteMgr,
   1911                                            TI_BOOL bRemoveSite)
   1912 {
   1913     siteMgr_t           *pSiteMgr = (siteMgr_t *)hSiteMgr;
   1914     siteTablesParams_t  *currTable = pSiteMgr->pSitesMgmtParams->pCurrentSiteTable;
   1915 
   1916     if (pSiteMgr->pSitesMgmtParams->pPrimarySite == NULL)
   1917         return TI_OK;
   1918 
   1919     TRACE1(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, " SITE MGR: bRemoveSite = %d \n", bRemoveSite);
   1920 
   1921     if (bRemoveSite)
   1922     {
   1923         removeSiteEntry(pSiteMgr, currTable, pSiteMgr->pSitesMgmtParams->pPrimarySite);
   1924         pSiteMgr->pSitesMgmtParams->pPrimarySite = NULL;
   1925     }
   1926     else	/* Currently never used */
   1927     {
   1928         pSiteMgr->pSitesMgmtParams->pPrimarySite->failStatus = STATUS_UNSPECIFIED;
   1929     }
   1930 
   1931     return TI_OK;
   1932 }
   1933 
   1934 
   1935 /***********************************************************************
   1936  *                        siteMgr_isCurrentBand24
   1937  ***********************************************************************
   1938 DESCRIPTION: The function checks the current operational mode and
   1939                 returns if the current band is 2.4Ghz or 5Ghz.
   1940 
   1941 INPUT:      hSiteMgr    -   site mgr handle.
   1942 
   1943 OUTPUT:
   1944 
   1945 RETURN:     TI_TRUE if current band is 2.4Ghz, TI_FALSE otherwise.
   1946 
   1947 ************************************************************************/
   1948 TI_BOOL siteMgr_isCurrentBand24(TI_HANDLE  hSiteMgr)
   1949 {
   1950     siteMgr_t   *pSiteMgr =     (siteMgr_t *)hSiteMgr;
   1951 
   1952     if(pSiteMgr->siteMgrOperationalMode == DOT11_A_MODE)
   1953         return TI_FALSE;
   1954 
   1955     return TI_TRUE; /* 802.11b supports onlty 2.4G band */
   1956 
   1957 }
   1958 
   1959 /***********************************************************************
   1960  *                        removeEldestSite
   1961  ***********************************************************************
   1962 DESCRIPTION: Called by the select when trying to create an IBSS and site table is full
   1963                 Remove the eldest site from the table
   1964 
   1965 INPUT:      hSiteMgr    -   site mgr handle.
   1966 
   1967 OUTPUT:
   1968 
   1969 RETURN:     TI_OK on success, TI_NOK otherwise
   1970 
   1971 ************************************************************************/
   1972 TI_STATUS removeEldestSite(siteMgr_t *pSiteMgr)
   1973 {
   1974     int             i;
   1975     siteEntry_t     *pEldestSite = NULL, *pSiteTable = pSiteMgr->pSitesMgmtParams->pCurrentSiteTable->siteTable;
   1976     siteTablesParams_t  *currTable = pSiteMgr->pSitesMgmtParams->pCurrentSiteTable;
   1977     TI_UINT32          currentTimsStamp = os_timeStampMs(pSiteMgr->hOs);
   1978     TI_UINT32          biggestGap = 0;
   1979 
   1980     for (i = 0; i < currTable->maxNumOfSites; i++)
   1981     {
   1982         if (biggestGap < ((TI_UINT32)(currentTimsStamp - pSiteTable[i].localTimeStamp)))
   1983         {
   1984             biggestGap = ((TI_UINT32)(currentTimsStamp - pSiteTable[i].localTimeStamp));
   1985             pEldestSite = &(pSiteTable[i]);
   1986         }
   1987     }
   1988 
   1989     removeSiteEntry(pSiteMgr, currTable, pEldestSite);
   1990 
   1991     return TI_OK;
   1992 }
   1993 
   1994 
   1995 /***********************************************************************
   1996  *                        update_apsd
   1997  ***********************************************************************
   1998 DESCRIPTION:    Sets the site APSD support flag according to the
   1999                 beacon's capabilities vector and the WME-params IE if exists.
   2000 
   2001 INPUT:      pSite       -   Pointer to the site entry in the site table
   2002             pFrameInfo  -   Frame information after the parsing
   2003 
   2004 OUTPUT:     pSite->APSDSupport flag
   2005 
   2006 RETURN:
   2007 
   2008 ************************************************************************/
   2009 static void update_apsd(siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo)
   2010 {
   2011     /* If WME-Params IE is not included in the beacon, set the APSD-Support flag
   2012          only by the beacons capabilities bit map. */
   2013     if (pFrameInfo->content.iePacket.WMEParams == NULL)
   2014         pSite->APSDSupport = (((pFrameInfo->content.iePacket.capabilities >> CAP_APSD_SHIFT) & CAP_APSD_MASK) ? TI_TRUE : TI_FALSE);
   2015 
   2016     /* Else, set the APSD-Support flag if either the capabilities APSD bit or the
   2017          WME-Params APSD bit indicate so. */
   2018     else
   2019         pSite->APSDSupport = ((((pFrameInfo->content.iePacket.capabilities >> CAP_APSD_SHIFT) & CAP_APSD_MASK) ? TI_TRUE : TI_FALSE) ||
   2020         (((pFrameInfo->content.iePacket.WMEParams->ACInfoField >> AP_QOS_INFO_UAPSD_SHIFT) & AP_QOS_INFO_UAPSD_MASK) ? TI_TRUE : TI_FALSE));
   2021 }
   2022 
   2023 
   2024 /***********************************************************************
   2025  *                        release_module
   2026  ***********************************************************************
   2027 DESCRIPTION:    Called by the un load function
   2028                 Go over the vector, for each bit that is set, release the corresponding module.
   2029 
   2030 INPUT:      pSiteMgr    -   site mgr handle.
   2031             initVec -   Vector that contains a bit set for each module thah had been initiualized
   2032 
   2033 OUTPUT:
   2034 
   2035 RETURN:     TI_OK on success, TI_NOK otherwise
   2036 
   2037 ************************************************************************/
   2038 static void release_module(siteMgr_t *pSiteMgr, TI_UINT32 initVec)
   2039 {
   2040     if ( (initVec & (1 << MGMT_PARAMS_INIT_BIT)) && pSiteMgr->pSitesMgmtParams)
   2041         os_memoryFree(pSiteMgr->hOs, pSiteMgr->pSitesMgmtParams, sizeof(sitesMgmtParams_t));
   2042 
   2043     if ( (initVec & (1 << DESIRED_PARAMS_INIT_BIT)) && pSiteMgr->pDesiredParams)
   2044         os_memoryFree(pSiteMgr->hOs, pSiteMgr->pDesiredParams, sizeof(siteMgrInitParams_t));
   2045 
   2046     if (initVec & (1 << SITE_MGR_INIT_BIT))
   2047         os_memoryFree(pSiteMgr->hOs, pSiteMgr, sizeof(siteMgr_t));
   2048 
   2049     initVec = 0;
   2050 }
   2051 
   2052 
   2053 static TI_BOOL isIeSsidBroadcast (dot11_SSID_t *pIESsid)
   2054 {
   2055     if ((pIESsid == NULL) || (pIESsid->hdr[1] == 0))
   2056     {
   2057         return TI_TRUE;
   2058     }
   2059 
   2060     /* According to 802.11, Broadcast SSID should be with length 0,
   2061         however, different vendors use invalid chanrs for Broadcast SSID. */
   2062     if (pIESsid->serviceSetId[0] < OS_802_11_SSID_FIRST_VALID_CHAR)
   2063     {
   2064         return TI_TRUE;
   2065     }
   2066 
   2067     return TI_FALSE;
   2068 }
   2069 
   2070 
   2071 /***********************************************************************
   2072  *                        updateSiteInfo
   2073  ***********************************************************************
   2074 DESCRIPTION:    Called upon receiving a beacon or probe response
   2075                 Go over the vector, for each bit that is set, release the corresponding module.
   2076                 Update theaite entry in the site table with the information received in the frame
   2077 
   2078 INPUT:      pSiteMgr    -   site mgr handle.
   2079             pFrameInfo  -   Frame information after the parsing
   2080             pSite       -   Pointer to the site entry in the site table
   2081 
   2082 OUTPUT:
   2083 
   2084 RETURN:     TI_OK on success, TI_NOK otherwise
   2085 
   2086 ************************************************************************/
   2087 static void updateSiteInfo(siteMgr_t *pSiteMgr, mlmeFrameInfo_t *pFrameInfo, siteEntry_t    *pSite, TI_UINT8 rxChannel)
   2088 {
   2089     paramInfo_t param;
   2090     TI_BOOL        ssidUpdated = TI_FALSE;
   2091 
   2092     switch (pFrameInfo->subType)
   2093     {
   2094     case BEACON:
   2095 
   2096         UPDATE_BEACON_INTERVAL(pSite, pFrameInfo);
   2097 
   2098         UPDATE_CAPABILITIES(pSite, pFrameInfo);
   2099 
   2100 
   2101         /***********************************/
   2102         /* Must be before UPDATE_PRIVACY and UPDATE_RSN_IE */
   2103         if (pSite->ssid.len==0)
   2104         {   /* Update the SSID only if the site's SSID is NULL */
   2105             if (isIeSsidBroadcast(pFrameInfo->content.iePacket.pSsid) == TI_FALSE)
   2106             {   /* And the SSID is not Broadcast */
   2107                 ssidUpdated = TI_TRUE;
   2108                 UPDATE_SSID(pSite, pFrameInfo);
   2109             }
   2110         }
   2111         else if (pSiteMgr->pDesiredParams->siteMgrDesiredSSID.len > 0)
   2112         {   /* There is a desired SSID */
   2113             if (pFrameInfo->content.iePacket.pSsid != NULL)
   2114             {
   2115                 if (os_memoryCompare (pSiteMgr->hOs,
   2116                                       (TI_UINT8 *)pSiteMgr->pDesiredParams->siteMgrDesiredSSID.str,
   2117                                       (TI_UINT8 *)pFrameInfo->content.iePacket.pSsid->serviceSetId,
   2118                                       pSiteMgr->pDesiredParams->siteMgrDesiredSSID.len)==0)
   2119                 {   /* update only SSID that equals the desired SSID */
   2120                     ssidUpdated = TI_TRUE;
   2121                     UPDATE_SSID(pSite, pFrameInfo);
   2122                 }
   2123             }
   2124             else
   2125             {
   2126                 TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_ERROR, "updateSiteInfo BEACON, pSsid=NULL\n");
   2127             }
   2128         }
   2129         /***********************************/
   2130 
   2131         if (ssidUpdated)
   2132         {
   2133 
   2134             UPDATE_PRIVACY(pSite, pFrameInfo);
   2135         }
   2136 
   2137         update_apsd(pSite, pFrameInfo);
   2138 
   2139         updatePreamble(pSiteMgr, pSite, pFrameInfo);
   2140 
   2141         UPDATE_AGILITY(pSite, pFrameInfo);
   2142 
   2143 
   2144         if(pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE)
   2145         {
   2146             UPDATE_SLOT_TIME(pSite, pFrameInfo);
   2147             UPDATE_PROTECTION(pSite, pFrameInfo);
   2148         }
   2149 
   2150         /* Updating HT params */
   2151         siteMgr_UpdatHtParams ((TI_HANDLE)pSiteMgr, pSite, pFrameInfo);
   2152 
   2153         updateRates(pSiteMgr, pSite, pFrameInfo);
   2154 
   2155         if ((pFrameInfo->content.iePacket.pDSParamsSet != NULL)  &&
   2156             (pFrameInfo->content.iePacket.pDSParamsSet->currChannel!=rxChannel))
   2157         {
   2158             TRACE2(pSiteMgr->hReport, REPORT_SEVERITY_ERROR, "updateSiteInfo, wrong CHANNELS:rxChannel=%d,currChannel=%d\n", rxChannel, pFrameInfo->content.iePacket.pDSParamsSet->currChannel);
   2159         }
   2160         else
   2161             UPDATE_CHANNEL(pSite, pFrameInfo , rxChannel);
   2162 
   2163 
   2164         UPDATE_BSS_TYPE(pSite, pFrameInfo);
   2165 
   2166         if (pSite->bssType == BSS_INFRASTRUCTURE)
   2167             UPDATE_DTIM_PERIOD(pSite, pFrameInfo);
   2168 
   2169         UPDATE_ATIM_WINDOW(pSite, pFrameInfo);
   2170 
   2171         UPDATE_BEACON_AP_TX_POWER(pSite, pFrameInfo);
   2172 
   2173         /* Updating QoS params */
   2174         updateBeaconQosParams(pSiteMgr, pSite, pFrameInfo);
   2175 
   2176 
   2177         /* updating CountryIE  */
   2178         if ((pFrameInfo->content.iePacket.country  != NULL) &&
   2179 			(pFrameInfo->content.iePacket.country->hdr[1] != 0))
   2180         {
   2181             /* set the country info in the regulatory domain - If a different code was detected earlier
   2182                the regDomain will ignore it */
   2183             param.paramType = REGULATORY_DOMAIN_COUNTRY_PARAM;
   2184             param.content.pCountry = (TCountry *)pFrameInfo->content.iePacket.country;
   2185             regulatoryDomain_setParam(pSiteMgr->hRegulatoryDomain,&param);
   2186         }
   2187 
   2188         /* Updating WSC params */
   2189         updateWSCParams(pSiteMgr, pSite, pFrameInfo);
   2190 
   2191         UPDATE_LOCAL_TIME_STAMP(pSiteMgr, pSite, pFrameInfo);
   2192 
   2193         UPDATE_BEACON_MODULATION(pSite, pFrameInfo);
   2194 
   2195         /* If the BSS type is independent, the beacon & probe modulation are equal,
   2196             It is important to update this field here for dynamic PBCC algorithm compatibility */
   2197         if (pSite->bssType == BSS_INDEPENDENT)
   2198             UPDATE_PROBE_MODULATION(pSite, pFrameInfo);
   2199 
   2200 
   2201         if (pSite->siteType == SITE_PRIMARY)
   2202         {
   2203 
   2204             if (pSiteMgr->pSitesMgmtParams->pPrimarySite == NULL)
   2205             {
   2206                 TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_ERROR, "updateSiteInfo: Primary Site Is NULL\n");
   2207                 pSite->siteType = SITE_REGULAR;
   2208             }
   2209             else
   2210             {
   2211                 /*  If the site that we got the beacon on is the primary site - which means we are either trying */
   2212                 /*  to connect to it or we are already connected - send the EVENT_GOT_BEACON to the conn module (through the SME module) */
   2213                 /*  so the conn module will be aware of the beacon status of the site it's trying to connect to */
   2214 
   2215 #ifdef XCC_MODULE_INCLUDED
   2216                 TI_INT8 ExternTxPower;
   2217 
   2218                 if (pFrameInfo->content.iePacket.cellTP != NULL)
   2219                 {
   2220                     ExternTxPower = pFrameInfo->content.iePacket.cellTP->power;
   2221                 }
   2222                 else	/* Set to maximum possible. Note that we add +1 so that Dbm = 26 and not 25 */
   2223                 {
   2224                     ExternTxPower = MAX_TX_POWER / DBM_TO_TX_POWER_FACTOR + 1;
   2225                 }
   2226 
   2227                 param.paramType = REGULATORY_DOMAIN_EXTERN_TX_POWER_PREFERRED;
   2228                 param.content.ExternTxPowerPreferred = ExternTxPower;
   2229                 regulatoryDomain_setParam(pSiteMgr->hRegulatoryDomain, &param);
   2230 #endif
   2231 
   2232                 /* Updating the Tx Power according to the received Power Constraint  */
   2233                 if(pFrameInfo->content.iePacket.powerConstraint  != NULL)
   2234                 {   /* Checking if the recieved constraint is different from the one that is already known  */
   2235                     if( pFrameInfo->content.iePacket.powerConstraint->powerConstraint != pSite->powerConstraint)
   2236                     {   /* check if Spectrum Management is enabled */
   2237                         param.paramType = REGULATORY_DOMAIN_MANAGEMENT_CAPABILITY_ENABLED_PARAM;
   2238                         regulatoryDomain_getParam(pSiteMgr->hRegulatoryDomain,&param);
   2239                         if(param.content.spectrumManagementEnabled)
   2240                         {   /* setting power constraint */
   2241                             pSite->powerConstraint = pFrameInfo->content.iePacket.powerConstraint->powerConstraint;
   2242                             param.paramType = REGULATORY_DOMAIN_SET_POWER_CONSTRAINT_PARAM;
   2243                             param.content.powerConstraint = pSite->powerConstraint;
   2244                             regulatoryDomain_setParam(pSiteMgr->hRegulatoryDomain,&param);
   2245 
   2246                         }
   2247                     }
   2248                 }
   2249                 /* update HT Information IE at the FW whenever any of its relevant fields is changed. */
   2250                 if (pSite->bHtInfoUpdate == TI_TRUE)
   2251                 {
   2252                     TI_BOOL b11nEnable, bWmeEnable;
   2253 
   2254                     /* verify 11n_Enable and Chip type */
   2255                     StaCap_IsHtEnable (pSiteMgr->hStaCap, &b11nEnable);
   2256 
   2257                     /* verify that WME flag enable */
   2258                     qosMngr_GetWmeEnableFlag (pSiteMgr->hQosMngr, &bWmeEnable);
   2259 
   2260                     if ((b11nEnable != TI_FALSE) && (bWmeEnable != TI_FALSE))
   2261                     {
   2262                         TWD_CfgSetFwHtInformation (pSiteMgr->hTWD, &pSite->tHtInformation);
   2263                     }
   2264                 }
   2265             }
   2266         }
   2267 
   2268         UPDATE_BEACON_RECV(pSite);
   2269 
   2270         if (ssidUpdated)
   2271         {
   2272             dot11_RSN_t *pRsnIe = pFrameInfo->content.iePacket.pRsnIe;
   2273             TI_UINT8       rsnIeLen = pFrameInfo->content.iePacket.rsnIeLen;
   2274             UPDATE_RSN_IE(pSite, pRsnIe, rsnIeLen);
   2275         }
   2276 
   2277         UPDATE_BEACON_TIMESTAMP(pSiteMgr, pSite, pFrameInfo);
   2278 
   2279 
   2280 
   2281         TWD_UpdateDtimTbtt (pSiteMgr->hTWD, pSite->dtimPeriod, pSite->beaconInterval);
   2282 
   2283         break;
   2284 
   2285 
   2286     case PROBE_RESPONSE:
   2287 
   2288         UPDATE_BEACON_INTERVAL(pSite, pFrameInfo);
   2289 
   2290         UPDATE_CAPABILITIES(pSite, pFrameInfo);
   2291 
   2292                 ssidUpdated = TI_TRUE;
   2293         if (pSite->siteType == SITE_PRIMARY)
   2294         {   /* Primary SITE */
   2295             if (pFrameInfo->content.iePacket.pSsid != NULL &&
   2296                 pSiteMgr->pDesiredParams->siteMgrDesiredSSID.len > 0)
   2297             {   /* There's a desired SSID*/
   2298                 if (os_memoryCompare (pSiteMgr->hOs,
   2299                                       (TI_UINT8*)pSiteMgr->pDesiredParams->siteMgrDesiredSSID.str,
   2300                                       (TI_UINT8*)pFrameInfo->content.iePacket.pSsid->serviceSetId,
   2301                                       pFrameInfo->content.iePacket.pSsid->hdr[1])!=0)
   2302                 {   /* Do not overwrite the primary site's SSID with a different than the desired SSID*/
   2303                     ssidUpdated = TI_FALSE;
   2304                 }
   2305 
   2306             }
   2307             else if (pFrameInfo->content.iePacket.pSsid == NULL)
   2308             {
   2309                 TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_ERROR, "updateSiteInfo PROBE_RESP, pSsid=NULL\n");
   2310             }
   2311         }
   2312 
   2313         if (ssidUpdated)
   2314         {
   2315             UPDATE_SSID(pSite, pFrameInfo);
   2316             UPDATE_PRIVACY(pSite, pFrameInfo);
   2317         }
   2318 
   2319         update_apsd(pSite, pFrameInfo);
   2320 
   2321 
   2322         if(pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE)
   2323         {
   2324             UPDATE_PROTECTION(pSite, pFrameInfo);
   2325         }
   2326 
   2327         updatePreamble(pSiteMgr, pSite, pFrameInfo);
   2328 
   2329         UPDATE_AGILITY(pSite, pFrameInfo);
   2330 
   2331         /* Updating HT params */
   2332         siteMgr_UpdatHtParams ((TI_HANDLE)pSiteMgr, pSite, pFrameInfo);
   2333 
   2334         updateRates(pSiteMgr, pSite, pFrameInfo);
   2335 
   2336         if ((pFrameInfo->content.iePacket.pDSParamsSet != NULL)  &&
   2337             (pFrameInfo->content.iePacket.pDSParamsSet->currChannel!=rxChannel))
   2338         {
   2339             TRACE2(pSiteMgr->hReport, REPORT_SEVERITY_ERROR, "updateSiteInfo, wrong CHANNELS:rxChannel=%d,currChannel=%d\n", rxChannel, pFrameInfo->content.iePacket.pDSParamsSet->currChannel);
   2340         }
   2341         else
   2342             UPDATE_CHANNEL(pSite, pFrameInfo, rxChannel);
   2343 
   2344 
   2345         UPDATE_BSS_TYPE(pSite, pFrameInfo);
   2346 
   2347         UPDATE_ATIM_WINDOW(pSite, pFrameInfo);
   2348 
   2349         UPDATE_PROBE_AP_TX_POWER(pSite, pFrameInfo);
   2350 
   2351         /* Updating WME params */
   2352         updateProbeQosParams(pSiteMgr, pSite, pFrameInfo);
   2353 
   2354 
   2355         /* updating CountryIE  */
   2356         if ((pFrameInfo->content.iePacket.country  != NULL) &&
   2357 			(pFrameInfo->content.iePacket.country->hdr[1] != 0))
   2358         {
   2359             /* set the country info in the regulatory domain - If a different code was detected earlier
   2360                the regDomain will ignore it */
   2361             param.paramType = REGULATORY_DOMAIN_COUNTRY_PARAM;
   2362             param.content.pCountry = (TCountry *)pFrameInfo->content.iePacket.country;
   2363             regulatoryDomain_setParam(pSiteMgr->hRegulatoryDomain,&param);
   2364         }
   2365 
   2366         /* Updating WSC params */
   2367         updateWSCParams(pSiteMgr, pSite, pFrameInfo);
   2368 
   2369         UPDATE_LOCAL_TIME_STAMP(pSiteMgr, pSite, pFrameInfo);
   2370 
   2371         UPDATE_PROBE_MODULATION(pSite, pFrameInfo);
   2372 
   2373         /* If the BSS type is independent, the beacon & probe modulation are equal,
   2374             It is important to update this field here for dynamic PBCC algorithm compatibility */
   2375         if (pSite->bssType == BSS_INDEPENDENT)
   2376             UPDATE_BEACON_MODULATION(pSite, pFrameInfo);
   2377 
   2378         UPDATE_PROBE_RECV(pSite);
   2379 
   2380         if (ssidUpdated)
   2381         {
   2382             dot11_RSN_t *pRsnIe = pFrameInfo->content.iePacket.pRsnIe;
   2383             TI_UINT8       rsnIeLen = pFrameInfo->content.iePacket.rsnIeLen;
   2384             UPDATE_RSN_IE(pSite, pRsnIe, rsnIeLen);
   2385 
   2386         }
   2387 
   2388         UPDATE_BEACON_TIMESTAMP(pSiteMgr, pSite, pFrameInfo);
   2389 
   2390         break;
   2391 
   2392     default:
   2393         TRACE1(pSiteMgr->hReport, REPORT_SEVERITY_ERROR, "Site Update failure, un known frame sub type %d\n\n", pFrameInfo->subType);
   2394         break;
   2395     }
   2396 }
   2397 
   2398 /***********************************************************************
   2399  *                        updatePreamble
   2400  ***********************************************************************
   2401 DESCRIPTION:    Called by the function 'updateSiteInfo()'
   2402 
   2403 INPUT:      pSiteMgr    -   site mgr handle.
   2404             pFrameInfo  -   Frame information after the parsing
   2405             pSite       -   Pointer to the site entry in the site table
   2406 
   2407 OUTPUT:
   2408 
   2409 RETURN:
   2410 
   2411 ************************************************************************/
   2412 static void updatePreamble(siteMgr_t *pSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo)
   2413 {
   2414     pSite->currentPreambleType = ((pFrameInfo->content.iePacket.capabilities >> CAP_PREAMBLE_SHIFT) & CAP_PREAMBLE_MASK) ? PREAMBLE_SHORT : PREAMBLE_LONG;
   2415 
   2416     pSite->barkerPreambleType = pFrameInfo->content.iePacket.barkerPreambleMode;
   2417 }
   2418 
   2419 /***********************************************************************
   2420  *                        updateBeaconQosParams
   2421  ***********************************************************************
   2422 DESCRIPTION:    Called by the function 'updateSiteInfo()'
   2423 
   2424 INPUT:      pSiteMgr    -   site mgr handle.
   2425             pFrameInfo  -   Frame information after the parsing
   2426             pSite       -   Pointer to the site entry in the site table
   2427 
   2428 OUTPUT:
   2429 
   2430 RETURN:
   2431 
   2432 ************************************************************************/
   2433 
   2434 static void updateBeaconQosParams(siteMgr_t *pSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo)
   2435 {
   2436     /* Updating WME params */
   2437     if (pFrameInfo->content.iePacket.WMEParams  != NULL)
   2438     {
   2439         /* Checking if this is IE includes new WME Parameters */
   2440         if(( ((pFrameInfo->content.iePacket.WMEParams->ACInfoField) & dot11_WME_ACINFO_MASK ) != pSite->lastWMEParameterCnt) ||
   2441             (!pSite->WMESupported) )
   2442         {
   2443             pSite->WMESupported = TI_TRUE;
   2444 
   2445             /* Checking if this IE is information only or is a paremeters IE */
   2446             if(pFrameInfo->content.iePacket.WMEParams->OUISubType == dot11_WME_OUI_SUB_TYPE_PARAMS_IE)
   2447             {
   2448                 if(pSite->siteType == SITE_PRIMARY)
   2449                 {
   2450                     qosMngr_updateIEinfo(pSiteMgr->hQosMngr,(TI_UINT8 *)(pFrameInfo->content.iePacket.WMEParams), QOS_WME);
   2451                 }
   2452                 /* updating the QOS_WME paraeters into the site table. */
   2453                 os_memoryCopy(pSiteMgr->hOs, &pSite->WMEParameters, &(pFrameInfo->content.iePacket.WMEParams->WME_ACParameteres), sizeof( dot11_ACParameters_t));
   2454                 pSite->lastWMEParameterCnt = (pFrameInfo->content.iePacket.WMEParams->ACInfoField) & dot11_WME_ACINFO_MASK;
   2455                 TRACE1(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "$$$$$$ QOS_WME parameters were updates according to beacon, cntSeq = %d\n",pSite->lastWMEParameterCnt);
   2456             }
   2457         }
   2458     }else
   2459     {
   2460         pSite->WMESupported = TI_FALSE;
   2461         }
   2462 
   2463 }
   2464 
   2465 /***********************************************************************
   2466  *                        updateProbeQosParams
   2467  ***********************************************************************
   2468 DESCRIPTION:    Called by the function 'updateSiteInfo()'
   2469 
   2470 INPUT:      pSiteMgr    -   site mgr handle.
   2471             pFrameInfo  -   Frame information after the parsing
   2472             pSite       -   Pointer to the site entry in the site table
   2473 
   2474 OUTPUT:
   2475 
   2476 RETURN:
   2477 
   2478 ************************************************************************/
   2479 static void updateProbeQosParams(siteMgr_t *pSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo)
   2480 {
   2481     /* Updating QOS_WME params */
   2482     if (pFrameInfo->content.iePacket.WMEParams  != NULL)
   2483     {
   2484         /* Checking if this is IE includes new QOS_WME Parameters */
   2485         if(( ((pFrameInfo->content.iePacket.WMEParams->ACInfoField) & dot11_WME_ACINFO_MASK ) != pSite->lastWMEParameterCnt) ||
   2486             (!pSite->WMESupported) )
   2487         {
   2488             pSite->WMESupported = TI_TRUE;
   2489 
   2490             /* Checking if this IE is information only or is a paremeters IE */
   2491             if(pFrameInfo->content.iePacket.WMEParams->OUISubType == dot11_WME_OUI_SUB_TYPE_PARAMS_IE)
   2492             {
   2493                 if(pSite->siteType == SITE_PRIMARY)
   2494                 {
   2495                     qosMngr_updateIEinfo(pSiteMgr->hQosMngr,(TI_UINT8 *)(pFrameInfo->content.iePacket.WMEParams),QOS_WME);
   2496                 }
   2497                 /* updating the QOS_WME paraeters into the site table. */
   2498                 os_memoryCopy(pSiteMgr->hOs, &pSite->WMEParameters, &(pFrameInfo->content.iePacket.WMEParams->WME_ACParameteres), sizeof( dot11_ACParameters_t));
   2499                 pSite->lastWMEParameterCnt = (pFrameInfo->content.iePacket.WMEParams->ACInfoField) & dot11_WME_ACINFO_MASK;
   2500                 TRACE1(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "$$$$$$ QOS_WME parameters were updates according to  probe response, cntSeq = %d\n",pSite->lastWMEParameterCnt);
   2501             }
   2502         }
   2503     }else
   2504     {
   2505         pSite->WMESupported = TI_FALSE;
   2506         }
   2507 
   2508 }
   2509 
   2510 /***********************************************************************
   2511  *                        siteMgr_UpdatHtParams
   2512  ***********************************************************************
   2513 DESCRIPTION:    Called by the function 'updateSiteInfo()' and also from scanResultTable module!
   2514 
   2515 INPUT:      hSiteMgr    -   site mgr handle.
   2516             pSite       -   Pointer to the site entry in the site table
   2517             pFrameInfo  -   Frame information after the parsing
   2518 
   2519 OUTPUT:
   2520 
   2521 RETURN:
   2522 
   2523 ************************************************************************/
   2524 void siteMgr_UpdatHtParams (TI_HANDLE hSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo)
   2525 {
   2526     siteMgr_t *pSiteMgr = (siteMgr_t *)hSiteMgr;
   2527 
   2528     /* Updating HT capabilites IE params */
   2529     if (pFrameInfo->content.iePacket.pHtCapabilities != NULL)
   2530     {
   2531 	   /* updating the HT capabilities unparse format into the site table. */
   2532        os_memoryCopy (pSiteMgr->hOs, &pSite->tHtCapabilities,
   2533                       (TI_UINT8 *)(pFrameInfo->content.iePacket.pHtCapabilities),
   2534                       sizeof(Tdot11HtCapabilitiesUnparse));
   2535 
   2536        TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION , "$$$$$$ HT capabilites parameters were updates.\n");
   2537     }
   2538     else
   2539     {
   2540         pSite->tHtCapabilities.tHdr[0] = TI_FALSE;
   2541     }
   2542 
   2543     /* Updating HT Information IE params */
   2544 	if (pFrameInfo->content.iePacket.pHtInformation != NULL)
   2545 	{
   2546 	   /* update in case different setting vlaue from the last one */
   2547        if (os_memoryCompare (pSiteMgr->hOs,
   2548                              (TI_UINT8 *)&pSite->tHtInformation,
   2549                              (TI_UINT8 *)pFrameInfo->content.iePacket.pHtInformation,
   2550                              sizeof(Tdot11HtInformationUnparse)) != 0)
   2551        {
   2552            pSite->bHtInfoUpdate = TI_TRUE;
   2553            /* updating the HT Information unparse pormat into the site table. */
   2554            os_memoryCopy (pSiteMgr->hOs, &pSite->tHtInformation, pFrameInfo->content.iePacket.pHtInformation, sizeof(Tdot11HtInformationUnparse));
   2555            TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION , "$$$$$$ HT Information parameters were updates.\n");
   2556        }
   2557        else
   2558        {
   2559            pSite->bHtInfoUpdate = TI_FALSE;
   2560        }
   2561     }
   2562 	else
   2563     {
   2564 		pSite->tHtInformation.tHdr[0] = TI_FALSE;
   2565     }
   2566 }
   2567 
   2568 
   2569 /***********************************************************************
   2570  *                        updateWSCParams
   2571  ***********************************************************************
   2572 DESCRIPTION:    Called by the function 'updateSiteInfo()'
   2573 
   2574 INPUT:      pSiteMgr    -   site mgr handle.
   2575             pFrameInfo  -   Frame information after the parsing
   2576             pSite       -   Pointer to the site entry in the site table
   2577 
   2578 OUTPUT:
   2579 
   2580 RETURN:
   2581 
   2582 ************************************************************************/
   2583 static void updateWSCParams(siteMgr_t *pSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo)
   2584 {
   2585    TRACE6(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "updateWSCParams called (BSSID: %X-%X-%X-%X-%X-%X)\n",pSite->bssid[0], pSite->bssid[1], pSite->bssid[2], pSite->bssid[3], pSite->bssid[4], pSite->bssid[5]);
   2586 
   2587 	/* if the IE is not null => the WSC is on - check which method is supported */
   2588 	if (pFrameInfo->content.iePacket.WSCParams  != NULL)
   2589 	{
   2590          parseWscMethodFromIE (pSiteMgr, pFrameInfo->content.iePacket.WSCParams, &pSite->WSCSiteMode);
   2591 
   2592          TRACE1(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "pSite->WSCSiteMode = %d\n",pSite->WSCSiteMode);
   2593 	}
   2594 	else
   2595 	{
   2596 			pSite->WSCSiteMode = TIWLN_SIMPLE_CONFIG_OFF;
   2597 	}
   2598 
   2599 }
   2600 
   2601 static int parseWscMethodFromIE (siteMgr_t *pSiteMgr, dot11_WSC_t *WSCParams, TIWLN_SIMPLE_CONFIG_MODE *pSelectedMethod)
   2602 {
   2603    TI_UINT8 *tlvPtr,*endPtr;
   2604    TI_UINT16   tlvPtrType,tlvPtrLen,selectedMethod=0;
   2605 
   2606    tlvPtr = (TI_UINT8*)WSCParams->WSCBeaconOrProbIE;
   2607    endPtr = tlvPtr + WSCParams->hdr[1] - DOT11_OUI_LEN;
   2608 
   2609    do
   2610    {
   2611       os_memoryCopy (pSiteMgr->hOs, (void *)&tlvPtrType, (void *)tlvPtr, 2);
   2612       tlvPtrType = WLANTOHS(tlvPtrType);
   2613 
   2614       /*if (tlvPtrType == DOT11_WSC_SELECTED_REGISTRAR_CONFIG_METHODS)*/
   2615       if (tlvPtrType == DOT11_WSC_DEVICE_PASSWORD_ID)
   2616       {
   2617          tlvPtr+=2;
   2618          tlvPtr+=2;
   2619          os_memoryCopy (pSiteMgr->hOs, (void *)&selectedMethod, (void *)tlvPtr, 2);
   2620          selectedMethod = WLANTOHS (selectedMethod);
   2621          break;
   2622       }
   2623       else
   2624       {
   2625          tlvPtr+=2;
   2626          os_memoryCopy (pSiteMgr->hOs, (void *)&tlvPtrLen, (void *)tlvPtr, 2);
   2627          tlvPtrLen = WLANTOHS (tlvPtrLen);
   2628          tlvPtr+=tlvPtrLen+2;
   2629       }
   2630    } while ((tlvPtr < endPtr) && (selectedMethod == 0));
   2631 
   2632    if (tlvPtr >= endPtr)
   2633    {
   2634       return TI_NOK;
   2635    }
   2636 
   2637    if (selectedMethod == DOT11_WSC_DEVICE_PASSWORD_ID_PIN)
   2638       *pSelectedMethod = TIWLN_SIMPLE_CONFIG_PIN_METHOD;
   2639    else if (selectedMethod == DOT11_WSC_DEVICE_PASSWORD_ID_PBC)
   2640       *pSelectedMethod = TIWLN_SIMPLE_CONFIG_PBC_METHOD;
   2641    else return TI_NOK;
   2642 
   2643    return TI_OK;
   2644 }
   2645 
   2646 
   2647 /***********************************************************************
   2648  *                        updateRates
   2649  ***********************************************************************
   2650 DESCRIPTION:    Called by the function 'updateSiteInfo()' in order to translate the rates received
   2651                 in the beacon or probe response to rate used by the driver. Perfoms the following:
   2652                     -   Check the rates validity. If rates are invalid, return
   2653                     -   Get the max active rate & max basic rate, if invalid, return
   2654                     -   Translate the max active rate and max basic rate from network rates to host rates.
   2655                         The max active & max basic rate are used by the driver from now on in all the processes:
   2656                         (selection, join, transmission, etc....)
   2657 
   2658 INPUT:      pSiteMgr    -   site mgr handle.
   2659             pFrameInfo  -   Frame information after the parsing
   2660             pSite       -   Pointer to the site entry in the site table
   2661 
   2662 OUTPUT:
   2663 
   2664 RETURN:     TI_OK on success, TI_NOK otherwise
   2665 
   2666 ************************************************************************/
   2667 static void updateRates(siteMgr_t *pSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo)
   2668 {
   2669     TI_UINT8   maxBasicRate = 0, maxActiveRate = 0;
   2670     TI_UINT32  bitMapExtSupp = 0;
   2671     paramInfo_t param;
   2672     TI_UINT32   uMcsbasicRateMask, uMcsSupportedRateMask;
   2673 
   2674     if (pFrameInfo->content.iePacket.pRates == NULL)
   2675     {
   2676         TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_ERROR, "updateRates, pRates=NULL, beacon & probeResp are: \n");
   2677         return;
   2678     }
   2679 
   2680     /* Update the rate elements */
   2681     maxBasicRate = rate_GetMaxBasicFromStr ((TI_UINT8 *)pFrameInfo->content.iePacket.pRates->rates,pFrameInfo->content.iePacket.pRates->hdr[1], maxBasicRate);
   2682     maxActiveRate = rate_GetMaxActiveFromStr ((TI_UINT8 *)pFrameInfo->content.iePacket.pRates->rates,pFrameInfo->content.iePacket.pRates->hdr[1], maxActiveRate);
   2683 
   2684     if(pFrameInfo->content.iePacket.pExtRates)
   2685     {
   2686         maxBasicRate = rate_GetMaxBasicFromStr ((TI_UINT8 *)pFrameInfo->content.iePacket.pExtRates->rates,pFrameInfo->content.iePacket.pExtRates->hdr[1], maxBasicRate);
   2687         maxActiveRate = rate_GetMaxActiveFromStr ((TI_UINT8 *)pFrameInfo->content.iePacket.pExtRates->rates,pFrameInfo->content.iePacket.pExtRates->hdr[1], maxActiveRate);
   2688     }
   2689 
   2690 
   2691     /*
   2692 TRACE2(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "1- maxBasicRate = 0x%X, maxActiveRate = 0x%X \n", maxBasicRate,maxActiveRate);
   2693 	*/
   2694 
   2695     if (maxActiveRate == 0)
   2696         maxActiveRate = maxBasicRate;
   2697 
   2698     /* Now update it from network to host rates */
   2699     pSite->maxBasicRate = rate_NetToDrv (maxBasicRate);
   2700     pSite->maxActiveRate = rate_NetToDrv (maxActiveRate);
   2701 
   2702     /* for now we use constat MCS rate */
   2703     if (pFrameInfo->content.iePacket.pHtInformation != NULL)
   2704     {
   2705         pSite->maxBasicRate = DRV_RATE_MCS_7;
   2706         pSite->maxActiveRate = DRV_RATE_MCS_7;
   2707     }
   2708 
   2709     if (pSite->maxActiveRate == DRV_RATE_INVALID)
   2710             TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_ERROR, "Network To Host Rate failure, no active network rate\n");
   2711 
   2712     if (pSite->maxBasicRate != DRV_RATE_INVALID)
   2713     {
   2714         if (pSite->maxActiveRate != DRV_RATE_INVALID)
   2715         {
   2716             pSite->maxActiveRate = TI_MAX (pSite->maxActiveRate, pSite->maxBasicRate);
   2717         }
   2718     } else { /* in case some vendors don't specify basic rates */
   2719         TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_WARNING, "Network To Host Rate failure, no basic network rate");
   2720         pSite->maxBasicRate = pSite->maxActiveRate;
   2721     }
   2722 
   2723     /* build rates bit map */
   2724     rate_NetStrToDrvBitmap (&pSite->rateMask.supportedRateMask,
   2725                             pFrameInfo->content.iePacket.pRates->rates,
   2726                             pFrameInfo->content.iePacket.pRates->hdr[1]);
   2727     rate_NetBasicStrToDrvBitmap (&pSite->rateMask.basicRateMask,
   2728                                  pFrameInfo->content.iePacket.pRates->rates,
   2729                                  pFrameInfo->content.iePacket.pRates->hdr[1]);
   2730 
   2731     if(pFrameInfo->content.iePacket.pExtRates)
   2732     {
   2733         rate_NetStrToDrvBitmap (&bitMapExtSupp,
   2734                                 pFrameInfo->content.iePacket.pExtRates->rates,
   2735                                        pFrameInfo->content.iePacket.pExtRates->hdr[1]);
   2736 
   2737         pSite->rateMask.supportedRateMask |= bitMapExtSupp;
   2738 
   2739         rate_NetBasicStrToDrvBitmap (&bitMapExtSupp,
   2740                                      pFrameInfo->content.iePacket.pExtRates->rates,
   2741                                         pFrameInfo->content.iePacket.pExtRates->hdr[1]);
   2742 
   2743         pSite->rateMask.basicRateMask |= bitMapExtSupp;
   2744     }
   2745 
   2746 
   2747     if (pFrameInfo->content.iePacket.pHtCapabilities != NULL)
   2748     {
   2749         /* MCS build rates bit map */
   2750         rate_McsNetStrToDrvBitmap (&uMcsSupportedRateMask,
   2751                                    (pFrameInfo->content.iePacket.pHtCapabilities->aHtCapabilitiesIe + DOT11_HT_CAPABILITIES_MCS_RATE_OFFSET));
   2752 
   2753         pSite->rateMask.supportedRateMask |= uMcsSupportedRateMask;
   2754     }
   2755 
   2756     if (pFrameInfo->content.iePacket.pHtInformation != NULL)
   2757     {
   2758         /* MCS build rates bit map */
   2759         rate_McsNetStrToDrvBitmap (&uMcsbasicRateMask,
   2760                                    (pFrameInfo->content.iePacket.pHtInformation->aHtInformationIe + DOT11_HT_INFORMATION_MCS_RATE_OFFSET));
   2761 
   2762         pSite->rateMask.basicRateMask |= uMcsbasicRateMask;
   2763     }
   2764 
   2765 
   2766     param.paramType = CTRL_DATA_CURRENT_SUPPORTED_RATE_MASK_PARAM;
   2767     param.content.ctrlDataCurrentRateMask = pSite->rateMask.supportedRateMask;
   2768     /* clear the 22Mbps bit in case the PBCC is not allowed */
   2769     if(pSiteMgr->currentDataModulation != DRV_MODULATION_PBCC && pSiteMgr->currentDataModulation != DRV_MODULATION_OFDM)
   2770     {
   2771       param.content.ctrlDataCurrentRateMask &= ~DRV_RATE_MASK_22_PBCC;
   2772     }
   2773     ctrlData_setParam(pSiteMgr->hCtrlData, &param);
   2774 }
   2775 
   2776 /***********************************************************************
   2777  *                        getPrimaryBssid
   2778  ***********************************************************************
   2779 DESCRIPTION:    Called by the OS abstraction layer in order to get the BSSID list from the site table
   2780 
   2781 INPUT:      pSiteMgr    -   site mgr handle.
   2782 
   2783 OUTPUT:     bssidList   -   BSSID list pointer
   2784 
   2785 RETURN:
   2786 
   2787 ************************************************************************/
   2788 static TI_STATUS getPrimaryBssid(siteMgr_t *pSiteMgr, OS_802_11_BSSID_EX *primaryBssid, TI_UINT32 *pLength)
   2789 {
   2790     siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
   2791     TI_UINT32                  len, firstOFDMloc = 0;
   2792     OS_802_11_FIXED_IEs     *pFixedIes;
   2793     OS_802_11_VARIABLE_IEs  *pVarIes;
   2794     TI_UINT32                  length;
   2795 
   2796 
   2797     if (primaryBssid==NULL)
   2798     {
   2799         /* we do not expect to get NULL value for pLength here */
   2800         *pLength = 0;
   2801         TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_ERROR, "getPrimaryBssid. primaryBssid ptr is NULL\n");
   2802         return TI_NOK;
   2803 
   2804     }
   2805 
   2806     if (pPrimarySite==NULL)
   2807     {
   2808         *pLength = 0;
   2809         TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "getPrimaryBssid, pPrimarySite is NULL \n");
   2810         return TI_NOK;
   2811 
   2812     }
   2813     length = pPrimarySite->beaconLength + sizeof(OS_802_11_BSSID_EX) + sizeof(OS_802_11_FIXED_IEs);
   2814     if (length > *pLength)
   2815     {
   2816         TRACE2(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "getPrimaryBssid, insufficient length,  required length=%d, pLength=%d \n", length, *pLength);
   2817         *pLength = length;
   2818 
   2819         return TI_NOK;
   2820     }
   2821 
   2822     TRACE1(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "Entering getPrimaryBssid, length = %d\n", *pLength);
   2823 
   2824     primaryBssid->Length = length;
   2825     /* MacAddress */
   2826     MAC_COPY (primaryBssid->MacAddress, pPrimarySite->bssid);
   2827 
   2828     /* Capabilities */
   2829     primaryBssid->Capabilities = pPrimarySite->capabilities;
   2830 
   2831     /* SSID */
   2832     os_memoryZero(pSiteMgr->hOs, primaryBssid->Ssid.Ssid, MAX_SSID_LEN);
   2833     if (pPrimarySite->ssid.len > MAX_SSID_LEN)
   2834     {
   2835         pPrimarySite->ssid.len = MAX_SSID_LEN;
   2836     }
   2837     os_memoryCopy (pSiteMgr->hOs,
   2838                    (void *)primaryBssid->Ssid.Ssid,
   2839                    (void *)pPrimarySite->ssid.str,
   2840                    pPrimarySite->ssid.len);
   2841     primaryBssid->Ssid.SsidLength = pPrimarySite->ssid.len;
   2842 
   2843     /* privacy */
   2844     primaryBssid->Privacy = pPrimarySite->privacy;
   2845 
   2846     /* RSSI */
   2847     primaryBssid->Rssi = pPrimarySite->rssi;
   2848 
   2849     /* NetworkTypeInUse & SupportedRates */
   2850     /* SupportedRates */
   2851     os_memoryZero(pSiteMgr->hOs, (void *)primaryBssid->SupportedRates, sizeof(OS_802_11_RATES_EX));
   2852 
   2853     rate_DrvBitmapToNetStr (pPrimarySite->rateMask.supportedRateMask,
   2854                             pPrimarySite->rateMask.basicRateMask,
   2855                             (TI_UINT8 *)primaryBssid->SupportedRates,
   2856                             &len,
   2857                             &firstOFDMloc);
   2858 
   2859     /* set network type acording to band and rates */
   2860     if (pPrimarySite->channel <= SITE_MGR_CHANNEL_B_G_MAX)
   2861     {
   2862         if (firstOFDMloc == len)
   2863         {
   2864             primaryBssid->NetworkTypeInUse = os802_11DS;
   2865         } else {
   2866             primaryBssid->NetworkTypeInUse = os802_11OFDM24;
   2867         }
   2868     } else {
   2869         primaryBssid->NetworkTypeInUse = os802_11OFDM5;
   2870     }
   2871 
   2872     /* Configuration */
   2873     primaryBssid->Configuration.Length = sizeof(OS_802_11_CONFIGURATION);
   2874     primaryBssid->Configuration.BeaconPeriod = pPrimarySite->beaconInterval;
   2875     primaryBssid->Configuration.ATIMWindow = pPrimarySite->atimWindow;
   2876     primaryBssid->Configuration.Union.channel = Chan2Freq(pPrimarySite->channel);
   2877 
   2878     /* InfrastructureMode */
   2879     if  (pPrimarySite->bssType == BSS_INDEPENDENT)
   2880         primaryBssid->InfrastructureMode = os802_11IBSS;
   2881     else
   2882         primaryBssid->InfrastructureMode = os802_11Infrastructure;
   2883     primaryBssid->IELength = 0;
   2884 
   2885     /* copy fixed IEs from site entry */
   2886     pFixedIes = (OS_802_11_FIXED_IEs*)&primaryBssid->IEs[primaryBssid->IELength];
   2887     os_memoryCopy(pSiteMgr->hOs, (void *)pFixedIes->TimeStamp, (void *)&pPrimarySite->tsfTimeStamp, TIME_STAMP_LEN);
   2888     pFixedIes->BeaconInterval = pPrimarySite->beaconInterval;
   2889     pFixedIes->Capabilities = pPrimarySite->capabilities;
   2890     primaryBssid->IELength += sizeof(OS_802_11_FIXED_IEs);
   2891     pVarIes = (OS_802_11_VARIABLE_IEs*)&primaryBssid->IEs[primaryBssid->IELength];
   2892 
   2893     /* Copy all variable IEs */
   2894     TRACE2(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "Copy all variable beaconLength=%d, IELength=%d\n", pPrimarySite->beaconLength, primaryBssid->IELength);
   2895     TRACE_INFO_HEX(pSiteMgr->hReport, pPrimarySite->beaconBuffer, pPrimarySite->beaconLength);
   2896     /* It looks like it never happens. Anyway decided to check */
   2897     if ( pPrimarySite->beaconLength > MAX_BEACON_BODY_LENGTH )
   2898     {
   2899         TRACE2(pSiteMgr->hReport, REPORT_SEVERITY_ERROR,
   2900               "getPrimaryBssid. pPrimarySite->beaconLength=%d exceeds the limit %d\n",
   2901               pPrimarySite->beaconLength, MAX_BEACON_BODY_LENGTH);
   2902         handleRunProblem(PROBLEM_BUF_SIZE_VIOLATION);
   2903         return TI_NOK;
   2904     }
   2905     os_memoryCopy(pSiteMgr->hOs, pVarIes, pPrimarySite->beaconBuffer, pPrimarySite->beaconLength);
   2906 
   2907     primaryBssid->IELength += pPrimarySite->beaconLength;
   2908 
   2909 
   2910     primaryBssid->Length = sizeof(OS_802_11_BSSID_EX) + primaryBssid->IELength - 1;
   2911 
   2912     TRACE6(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "BSSID MAC = %x-%x-%x-%x-%x-%x\n", primaryBssid->MacAddress[0], primaryBssid->MacAddress[1], primaryBssid->MacAddress[2], primaryBssid->MacAddress[3], primaryBssid->MacAddress[4], primaryBssid->MacAddress[5]);
   2913 
   2914 
   2915     TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "primaryBssid is\n");
   2916     TRACE_INFO_HEX(pSiteMgr->hReport, (TI_UINT8*)primaryBssid, primaryBssid->Length);
   2917 
   2918 
   2919     TRACE2(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "Exiting getBssidList, length =%d, IELength=%d \n", primaryBssid->Length, primaryBssid->IELength);
   2920 
   2921     *pLength = primaryBssid->Length;
   2922 
   2923     return TI_OK;
   2924 }
   2925 
   2926 #ifdef REPORT_LOG
   2927 /***********************************************************************
   2928  *                        siteMgr_printPrimarySiteDesc
   2929  ***********************************************************************
   2930 DESCRIPTION:    Called by the OS abstraction layer in order to get the primary site description
   2931 
   2932 INPUT:      pSiteMgr            -   site mgr handle.
   2933             supplyExtendedInfo  - If OS_802_11_BSSID_EX structure should be used (extended info)
   2934                                   (Assuming that if this function is called with TI_TRUE, enough memory was allocated to hold the extended info)
   2935 
   2936 OUTPUT:     pPrimarySiteDesc    -   Primary site description pointer
   2937 
   2938 RETURN:
   2939 
   2940 ************************************************************************/
   2941 void siteMgr_printPrimarySiteDesc(TI_HANDLE hSiteMgr )
   2942 {
   2943     siteMgr_t *pSiteMgr = (siteMgr_t*) hSiteMgr;
   2944 
   2945     siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
   2946 
   2947     /* the driver logger can't print %s
   2948      * TRACE1(pSiteMgr->hReport, REPORT_SEVERITY_CONSOLE, "-- SSID  = %s \n",pPrimarySite->ssid.str);
   2949      */
   2950     TRACE6(pSiteMgr->hReport, REPORT_SEVERITY_CONSOLE,"-- BSSID = %02x-%02x-%02x-%02x-%02x-%02x\n",
   2951                     pPrimarySite->bssid[0], pPrimarySite->bssid[1], pPrimarySite->bssid[2], pPrimarySite->bssid[3],
   2952                     pPrimarySite->bssid[4], pPrimarySite->bssid[5]);
   2953 
   2954 
   2955 	WLAN_OS_REPORT(("-- SSID  = %s \n",pPrimarySite->ssid.str));
   2956 	WLAN_OS_REPORT(("-- BSSID = %02x-%02x-%02x-%02x-%02x-%02x\n",
   2957 					pPrimarySite->bssid[0], pPrimarySite->bssid[1], pPrimarySite->bssid[2], pPrimarySite->bssid[3],
   2958 					pPrimarySite->bssid[4], pPrimarySite->bssid[5]));
   2959 }
   2960 #endif
   2961 
   2962 /***********************************************************************
   2963  *                        getPrimarySiteDesc
   2964  ***********************************************************************
   2965 DESCRIPTION:    Called by the OS abstraction layer in order to get the primary site description
   2966 
   2967 INPUT:      pSiteMgr            - site mgr handle.
   2968             supplyExtendedInfo  - If OS_802_11_BSSID_EX structure should be used (extended info)
   2969                                   (Assuming that if this function is called with TI_TRUE, enough memory was allocated to hold the extended info)
   2970 
   2971 OUTPUT:     pPrimarySiteDesc    - Primary site description pointer
   2972 
   2973 RETURN:
   2974 
   2975 ************************************************************************/
   2976 static void getPrimarySiteDesc(siteMgr_t *pSiteMgr, OS_802_11_BSSID *pPrimarySiteDesc, TI_BOOL supplyExtendedInfo)
   2977 {
   2978     siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
   2979     OS_802_11_BSSID_EX *pExPrimarySiteDesc = (OS_802_11_BSSID_EX *) pPrimarySiteDesc;
   2980     TI_UINT32  len, firstOFDMloc = 0;
   2981     OS_802_11_FIXED_IEs     *pFixedIes;
   2982     OS_802_11_VARIABLE_IEs  *pVarIes;
   2983     TI_UINT8 rsnIeLength,index;
   2984     OS_802_11_RATES_EX  SupportedRates;
   2985 
   2986 
   2987     if (pPrimarySiteDesc == NULL)
   2988     {
   2989         return;
   2990     }
   2991     if (pPrimarySite == NULL)
   2992     {
   2993         os_memoryZero(pSiteMgr->hOs, pPrimarySiteDesc, sizeof(OS_802_11_BSSID));
   2994         return;
   2995     }
   2996 
   2997     TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "getPrimarySiteDesc - enter\n");
   2998 
   2999 
   3000     /* If an "extended" request has been made - update the length accordingly */
   3001    if (supplyExtendedInfo == TI_FALSE)
   3002     pPrimarySiteDesc->Length = sizeof(OS_802_11_BSSID);
   3003    else
   3004     pPrimarySiteDesc->Length = sizeof(OS_802_11_BSSID_EX);
   3005 
   3006     /* MacAddress */
   3007     MAC_COPY (pPrimarySiteDesc->MacAddress, pPrimarySite->bssid);
   3008 
   3009     /* Capabilities */
   3010     pPrimarySiteDesc->Capabilities = pPrimarySite->capabilities;
   3011 
   3012     /* It looks like it never happens. Anyway decided to check */
   3013     if ( pPrimarySite->ssid.len > MAX_SSID_LEN )
   3014     {
   3015         TRACE2( pSiteMgr->hReport, REPORT_SEVERITY_ERROR,
   3016                "getPrimarySiteDesc. pPrimarySite=%d exceeds the limit %d\n",
   3017                    pPrimarySite->ssid.len, MAX_SSID_LEN);
   3018         handleRunProblem(PROBLEM_BUF_SIZE_VIOLATION);
   3019         return;
   3020     }
   3021     /* SSID */
   3022     os_memoryCopy (pSiteMgr->hOs,
   3023                    (void *)pPrimarySiteDesc->Ssid.Ssid,
   3024                    (void *)pPrimarySite->ssid.str,
   3025                    pPrimarySite->ssid.len);
   3026     pPrimarySiteDesc->Ssid.SsidLength = pPrimarySite->ssid.len;
   3027 
   3028     /* privacy */
   3029     pPrimarySiteDesc->Privacy = pPrimarySite->privacy;
   3030 
   3031     /* RSSI */
   3032 
   3033     pPrimarySiteDesc->Rssi = pPrimarySite->rssi;
   3034 
   3035     pPrimarySiteDesc->NetworkTypeInUse = os802_11DS;
   3036 
   3037     pPrimarySiteDesc->Configuration.Length = sizeof(OS_802_11_CONFIGURATION);
   3038     pPrimarySiteDesc->Configuration.BeaconPeriod = pPrimarySite->beaconInterval;
   3039     pPrimarySiteDesc->Configuration.ATIMWindow = pPrimarySite->atimWindow;
   3040     pPrimarySiteDesc->Configuration.Union.channel = pPrimarySite->channel;
   3041 
   3042     if  (pPrimarySite->bssType == BSS_INDEPENDENT)
   3043         pPrimarySiteDesc->InfrastructureMode = os802_11IBSS;
   3044     else
   3045         pPrimarySiteDesc->InfrastructureMode = os802_11Infrastructure;
   3046 
   3047    /* SupportedRates */
   3048    if (supplyExtendedInfo == TI_FALSE)
   3049       os_memoryZero(pSiteMgr->hOs, (void *)pPrimarySiteDesc->SupportedRates, sizeof(OS_802_11_RATES));
   3050    else
   3051       os_memoryZero(pSiteMgr->hOs, (void *)pExPrimarySiteDesc->SupportedRates, sizeof(OS_802_11_RATES_EX));
   3052 
   3053    rate_DrvBitmapToNetStr (pPrimarySite->rateMask.supportedRateMask,
   3054                            pPrimarySite->rateMask.basicRateMask,
   3055                            &SupportedRates[0],
   3056                            &len,
   3057                            &firstOFDMloc);
   3058 
   3059    if (supplyExtendedInfo == TI_FALSE)
   3060        os_memoryCopy(pSiteMgr->hOs, (void *)pPrimarySiteDesc->SupportedRates, (void *)SupportedRates, sizeof(OS_802_11_RATES));
   3061    else
   3062        os_memoryCopy(pSiteMgr->hOs, (void *)pExPrimarySiteDesc->SupportedRates, (void *)SupportedRates, sizeof(OS_802_11_RATES_EX));
   3063 
   3064 
   3065    if (supplyExtendedInfo == TI_TRUE)
   3066    {
   3067       pExPrimarySiteDesc->IELength = 0;
   3068 
   3069      /* copy fixed IEs from site entry */
   3070      pFixedIes = (OS_802_11_FIXED_IEs*)&pExPrimarySiteDesc->IEs[pExPrimarySiteDesc->IELength];
   3071      os_memoryCopy(pSiteMgr->hOs, (void *)pFixedIes->TimeStamp, (void *)&pPrimarySite->tsfTimeStamp, TIME_STAMP_LEN);
   3072      pFixedIes->BeaconInterval = pPrimarySite->beaconInterval;
   3073      pFixedIes->Capabilities = pPrimarySite->capabilities;
   3074      pExPrimarySiteDesc->IELength += sizeof(OS_802_11_FIXED_IEs);
   3075 
   3076      /* copy variable IEs */
   3077      /* copy SSID */
   3078      pVarIes = (OS_802_11_VARIABLE_IEs*)&pExPrimarySiteDesc->IEs[pExPrimarySiteDesc->IELength];
   3079      pVarIes->ElementID = SSID_IE_ID;
   3080      pVarIes->Length = pPrimarySite->ssid.len;
   3081      os_memoryCopy (pSiteMgr->hOs,
   3082                     (void *)pVarIes->data,
   3083                     (void *)pPrimarySite->ssid.str,
   3084                     pPrimarySite->ssid.len);
   3085      pExPrimarySiteDesc->IELength += (pVarIes->Length + 2);
   3086 
   3087 
   3088      /* copy RSN information elements */
   3089      rsnIeLength = 0;
   3090      for (index=0; index<MAX_RSN_IE && pPrimarySite->pRsnIe[index].hdr[1] > 0; index++)
   3091        {
   3092             pVarIes =  (OS_802_11_VARIABLE_IEs*)&pExPrimarySiteDesc->IEs[pExPrimarySiteDesc->IELength+rsnIeLength];
   3093          pVarIes->ElementID = pPrimarySite->pRsnIe[index].hdr[0];
   3094              pVarIes->Length = pPrimarySite->pRsnIe[index].hdr[1];
   3095              os_memoryCopy(pSiteMgr->hOs, (void *)pVarIes->data, (void *)pPrimarySite->pRsnIe[index].rsnIeData, pPrimarySite->pRsnIe[index].hdr[1]);
   3096              rsnIeLength += pPrimarySite->pRsnIe[index].hdr[1] + 2;
   3097             TRACE2(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "RSN IE ID=%d, Length=%x\n", pVarIes->ElementID, pVarIes->Length);
   3098 
   3099             TRACE_INFO_HEX(pSiteMgr->hReport, (TI_UINT8 *)pVarIes->data,pVarIes->Length);
   3100          }
   3101 
   3102          pExPrimarySiteDesc->IELength += pPrimarySite->rsnIeLen;
   3103 
   3104          pExPrimarySiteDesc->Length = sizeof(OS_802_11_BSSID_EX) + pExPrimarySiteDesc->IELength - 1;
   3105 
   3106          TRACE6(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "BSSID MAC = %x-%x-%x-%x-%x-%x\n", pExPrimarySiteDesc->MacAddress[0], pExPrimarySiteDesc->MacAddress[1], pExPrimarySiteDesc->MacAddress[2], pExPrimarySiteDesc->MacAddress[3], pExPrimarySiteDesc->MacAddress[4], pExPrimarySiteDesc->MacAddress[5]);
   3107 
   3108          TRACE1(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "pExPrimarySiteDesc length before alignment = %d\n", pExPrimarySiteDesc->Length);
   3109 
   3110          /* make sure length is 4 bytes aligned */
   3111          if (pExPrimarySiteDesc->Length % 4)
   3112          {
   3113             pExPrimarySiteDesc->Length += (4 - (pExPrimarySiteDesc->Length % 4));
   3114          }
   3115 
   3116          TRACE1(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "pExPrimarySiteDesc length after alignment = %d\n", pExPrimarySiteDesc->Length);
   3117 
   3118         }
   3119 
   3120 }
   3121 
   3122 
   3123 /***********************************************************************
   3124  *                        translateRateMaskToValue
   3125  ***********************************************************************
   3126 DESCRIPTION:    Called by the function 'siteMgr_config()' in order to translate the rate mask read
   3127                 from registry to rate value
   3128 
   3129 INPUT:      pSiteMgr            -   site mgr handle.
   3130             rateMask            -   Rate mask
   3131 
   3132 OUTPUT:     The rate after the translation
   3133 
   3134 RETURN:
   3135 
   3136 ************************************************************************/
   3137 static ERate translateRateMaskToValue(siteMgr_t *pSiteMgr, TI_UINT32 rateMask)
   3138 {
   3139 	if (rateMask & DRV_RATE_MASK_MCS_7_OFDM)
   3140         return DRV_RATE_MCS_7;
   3141     if (rateMask & DRV_RATE_MASK_MCS_6_OFDM)
   3142         return DRV_RATE_MCS_6;
   3143     if (rateMask & DRV_RATE_MASK_MCS_5_OFDM)
   3144         return DRV_RATE_MCS_5;
   3145     if (rateMask & DRV_RATE_MASK_MCS_4_OFDM)
   3146         return DRV_RATE_MCS_4;
   3147     if (rateMask & DRV_RATE_MASK_MCS_3_OFDM)
   3148         return DRV_RATE_MCS_3;
   3149     if (rateMask & DRV_RATE_MASK_MCS_2_OFDM)
   3150         return DRV_RATE_MCS_2;
   3151     if (rateMask & DRV_RATE_MASK_MCS_1_OFDM)
   3152         return DRV_RATE_MCS_1;
   3153     if (rateMask & DRV_RATE_MASK_MCS_0_OFDM)
   3154         return DRV_RATE_MCS_0;
   3155     if (rateMask & DRV_RATE_MASK_54_OFDM)
   3156         return DRV_RATE_54M;
   3157     if (rateMask & DRV_RATE_MASK_48_OFDM)
   3158         return DRV_RATE_48M;
   3159     if (rateMask & DRV_RATE_MASK_36_OFDM)
   3160         return DRV_RATE_36M;
   3161     if (rateMask & DRV_RATE_MASK_24_OFDM)
   3162         return DRV_RATE_24M;
   3163     if (rateMask & DRV_RATE_MASK_22_PBCC)
   3164         return DRV_RATE_22M;
   3165     if (rateMask & DRV_RATE_MASK_18_OFDM)
   3166         return DRV_RATE_18M;
   3167     if (rateMask & DRV_RATE_MASK_12_OFDM)
   3168         return DRV_RATE_12M;
   3169     if (rateMask & DRV_RATE_MASK_11_CCK)
   3170         return DRV_RATE_11M;
   3171     if (rateMask & DRV_RATE_MASK_9_OFDM)
   3172         return DRV_RATE_9M;
   3173     if (rateMask & DRV_RATE_MASK_6_OFDM)
   3174         return DRV_RATE_6M;
   3175     if (rateMask & DRV_RATE_MASK_5_5_CCK)
   3176         return DRV_RATE_5_5M;
   3177     if (rateMask & DRV_RATE_MASK_2_BARKER)
   3178         return DRV_RATE_2M;
   3179     if (rateMask & DRV_RATE_MASK_1_BARKER)
   3180         return DRV_RATE_1M;
   3181 
   3182     TRACE1(pSiteMgr->hReport, REPORT_SEVERITY_WARNING, "Translate rate mask to value, mask is 0x%X\n", rateMask);
   3183     if(pSiteMgr->siteMgrOperationalMode != DOT11_A_MODE)
   3184         return DRV_RATE_1M;
   3185     else
   3186         return DRV_RATE_6M;
   3187 }
   3188 
   3189 
   3190 /***********************************************************************
   3191  *                        getSupportedRateSet
   3192  ***********************************************************************
   3193 DESCRIPTION:    Called by the function 'siteMgr_getParam()' in order to get the supported rate set
   3194                 Build an array of network rates based on the max active & max basic rates
   3195 
   3196 INPUT:      pSiteMgr            -   site mgr handle.
   3197 
   3198 OUTPUT:     pRatesSet           -   The array built
   3199 
   3200 RETURN:
   3201 
   3202 ************************************************************************/
   3203 static void getSupportedRateSet(siteMgr_t *pSiteMgr, TRates *pRatesSet)
   3204 {
   3205     TI_UINT32 dontCareParam;
   3206     TI_UINT32 len = 0;
   3207 
   3208     rate_DrvBitmapToNetStr (pSiteMgr->pDesiredParams->siteMgrRegstrySuppRateMask,
   3209                                pSiteMgr->pDesiredParams->siteMgrRegstryBasicRateMask,
   3210                             (TI_UINT8 *)pRatesSet->ratesString,
   3211                             &len,
   3212                             &dontCareParam);
   3213 
   3214     pRatesSet->len = (TI_UINT8) len;
   3215 }
   3216 
   3217 /***********************************************************************
   3218  *                        setSupportedRateSet
   3219  ***********************************************************************
   3220 DESCRIPTION:    Called by the function 'siteMgr_setParam()' in order to set the supported rate set
   3221                 Go over the input array and set the max active & max basic rates. (after translation from network
   3222                 rates to host rates ofcourse)
   3223                 If max basic rate is bigger than the mac active one, print an error.
   3224                 If the basic or active rate are different than the ones already stored by the site manager,
   3225                 it initiates a reconnection by calling sme_Restart
   3226 
   3227 INPUT:      pSiteMgr            -   site mgr handle.
   3228             pRatesSet           -   The rates array received
   3229 
   3230 OUTPUT:
   3231 
   3232 RETURN:     TI_OK on success
   3233 
   3234 ************************************************************************/
   3235 static TI_STATUS setSupportedRateSet(siteMgr_t *pSiteMgr, TRates *pRatesSet)
   3236 {
   3237     TI_UINT8  i,j, drvRate;
   3238     ERate maxActiveRate = (ERate)0, maxBasicRate = (ERate)0;
   3239     TI_UINT32 suppBitMap, basicBitMap;
   3240     static  ERate basicRates_G[]  = {DRV_RATE_1M,DRV_RATE_2M,DRV_RATE_5_5M,DRV_RATE_11M};
   3241     static ERate basicRates_A[]  = {DRV_RATE_6M,DRV_RATE_12M,DRV_RATE_24M};
   3242     ERate* currentBasicRates;
   3243     TI_UINT32 currentBasicRatesLength;
   3244 
   3245 #ifndef NET_BASIC_MASK
   3246 #define NET_BASIC_MASK      0x80    /* defined in common/src/utils/utils.c */
   3247 #endif
   3248 
   3249     if(pSiteMgr->siteMgrOperationalMode == DOT11_A_MODE)
   3250     {
   3251         currentBasicRates = &basicRates_A[0];
   3252         currentBasicRatesLength = sizeof(basicRates_A) / sizeof(basicRates_A[0]);
   3253     }
   3254     else
   3255     {
   3256         currentBasicRates = &basicRates_G[0];
   3257         currentBasicRatesLength = sizeof(basicRates_G) / sizeof(basicRates_G[0]);
   3258     }
   3259     /* It looks like it never happens. Anyway decided to check */
   3260     if ( pRatesSet->len > DOT11_MAX_SUPPORTED_RATES )
   3261     {
   3262         TRACE2( pSiteMgr->hReport, REPORT_SEVERITY_ERROR,
   3263                 "setSupportedRateSet. pRatesSet->len=%d exceeds the limit %d\n",
   3264                 pRatesSet->len, DOT11_MAX_SUPPORTED_RATES);
   3265         handleRunProblem(PROBLEM_BUF_SIZE_VIOLATION);
   3266         pRatesSet->len = DOT11_MAX_SUPPORTED_RATES;
   3267     }
   3268 
   3269     /* Basic rates must be supported. If one of 1M,2M,5.5M,11M is not supported fail.*/
   3270     for (j = 0; j < currentBasicRatesLength; j++)
   3271     {
   3272         for (i = 0; i < pRatesSet->len; i++)
   3273         {
   3274             drvRate = rate_NetToDrv (pRatesSet->ratesString[i]);
   3275             if ((drvRate & ( NET_BASIC_MASK-1)) == currentBasicRates[j])
   3276                 break;
   3277         }
   3278         /* not all the basic rates are supported! Failure*/
   3279         if (i == pRatesSet->len)
   3280         {
   3281             TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_ERROR, "Rates set must contain the basic set! Failing\n");
   3282             return PARAM_VALUE_NOT_VALID;
   3283         }
   3284     }
   3285 
   3286     for (i = 0; i < pRatesSet->len; i++)
   3287     {
   3288         drvRate = rate_NetToDrv (pRatesSet->ratesString[i]);
   3289         if(pSiteMgr->siteMgrOperationalMode == DOT11_A_MODE)
   3290         {
   3291             if(drvRate < DRV_RATE_6M)
   3292             {
   3293                 TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_ERROR, "Notice, the driver configured in 11a mode, but CCK rate appears\n");
   3294                 return PARAM_VALUE_NOT_VALID;
   3295             }
   3296         }
   3297         else if(pSiteMgr->siteMgrOperationalMode == DOT11_B_MODE)
   3298         {
   3299             if(drvRate >= DRV_RATE_6M)
   3300             {
   3301                 TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_ERROR, "Notice, the driver configured in 11b mode, but OFDM rate appears\n");
   3302                 return PARAM_VALUE_NOT_VALID;
   3303             }
   3304         }
   3305         maxActiveRate = TI_MAX ((ERate)drvRate, maxActiveRate);
   3306     }
   3307 
   3308     for (i = 0; i < pRatesSet->len; i++)
   3309     {
   3310         if (NET_BASIC_RATE(pRatesSet->ratesString[i]))
   3311             maxBasicRate = TI_MAX (rate_NetToDrv (pRatesSet->ratesString[i]), maxBasicRate);
   3312     }
   3313 
   3314     /* If the basic rate is bigger than the supported one, we print an error */
   3315     if (pSiteMgr->pDesiredParams->siteMgrDesiredRatePair.maxBasic > pSiteMgr->pDesiredParams->siteMgrDesiredRatePair.maxActive)
   3316     {
   3317         TRACE2(pSiteMgr->hReport, REPORT_SEVERITY_ERROR, "Notice, the rates configuration is invalid, basic rate is bigger than supported, Max Basic: %d Max Supported: %d\n", pSiteMgr->pDesiredParams->siteMgrDesiredRatePair.maxBasic, pSiteMgr->pDesiredParams->siteMgrDesiredRatePair.maxActive);
   3318         return PARAM_VALUE_NOT_VALID;
   3319     }
   3320 
   3321     pSiteMgr->pDesiredParams->siteMgrDesiredRatePair.maxActive = maxActiveRate;
   3322     pSiteMgr->pDesiredParams->siteMgrDesiredRatePair.maxBasic = maxBasicRate;
   3323 
   3324     /* configure desired modulation */
   3325     if(maxActiveRate == DRV_RATE_22M)
   3326         pSiteMgr->pDesiredParams->siteMgrDesiredModulationType = DRV_MODULATION_PBCC;
   3327     else if(maxActiveRate < DRV_RATE_22M)
   3328         pSiteMgr->pDesiredParams->siteMgrDesiredModulationType = DRV_MODULATION_CCK;
   3329     else
   3330         pSiteMgr->pDesiredParams->siteMgrDesiredModulationType = DRV_MODULATION_OFDM;
   3331 
   3332 
   3333     rate_NetStrToDrvBitmap (&suppBitMap, pRatesSet->ratesString, pRatesSet->len);
   3334     rate_NetBasicStrToDrvBitmap (&basicBitMap, pRatesSet->ratesString, pRatesSet->len);
   3335 
   3336     if((pSiteMgr->pDesiredParams->siteMgrRegstryBasicRateMask != basicBitMap) ||
   3337        (pSiteMgr->pDesiredParams->siteMgrRegstrySuppRateMask != suppBitMap))
   3338     {
   3339         pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask = suppBitMap;
   3340         pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask = basicBitMap;
   3341         pSiteMgr->pDesiredParams->siteMgrRegstryBasicRateMask = basicBitMap;
   3342         pSiteMgr->pDesiredParams->siteMgrRegstrySuppRateMask = suppBitMap;
   3343         /* Initialize Mutual Rates Matching */
   3344         pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask = pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask;
   3345         pSiteMgr->pDesiredParams->siteMgrMatchedSuppRateMask = pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask;
   3346 
   3347         sme_Restart (pSiteMgr->hSmeSm);
   3348     }
   3349 
   3350     return TI_OK;
   3351 }
   3352 
   3353 /***********************************************************************
   3354  *                        pbccAlgorithm
   3355  ***********************************************************************
   3356 DESCRIPTION:    Called by the following functions:
   3357                 -   systemConfig(), in the system configuration phase after the selection
   3358                 -   siteMgr_updateSite(), in a case of a primary site update & if a PBCC algorithm
   3359                     is needed to be performed
   3360                 Performs the PBCC algorithm
   3361 
   3362 
   3363 INPUT:      hSiteMgr            -   site mgr handle.
   3364 
   3365 OUTPUT:
   3366 
   3367 RETURN:     TI_OK on always
   3368 
   3369 ************************************************************************/
   3370 TI_STATUS pbccAlgorithm(TI_HANDLE hSiteMgr)
   3371 {
   3372     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   3373     paramInfo_t param;
   3374     siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
   3375     TI_UINT32   supportedRateMask ;
   3376 
   3377 
   3378     if (pPrimarySite->channel == SPECIAL_BG_CHANNEL)
   3379         supportedRateMask = (rate_GetDrvBitmapForDefaultSupporteSet() & pSiteMgr->pDesiredParams->siteMgrMatchedSuppRateMask) ;
   3380     else
   3381         supportedRateMask = pSiteMgr->pDesiredParams->siteMgrMatchedSuppRateMask ;
   3382 
   3383     param.paramType = CTRL_DATA_CURRENT_SUPPORTED_RATE_MASK_PARAM;
   3384     param.content.ctrlDataCurrentRateMask = supportedRateMask;
   3385     /* clear the 22Mbps bit in case the PBCC is not allowed */
   3386     if(pSiteMgr->currentDataModulation != DRV_MODULATION_PBCC &&
   3387        pSiteMgr->currentDataModulation != DRV_MODULATION_OFDM)
   3388             param.content.ctrlDataCurrentRateMask &= ~DRV_RATE_MASK_22_PBCC;
   3389     ctrlData_setParam(pSiteMgr->hCtrlData, &param);
   3390 
   3391     param.paramType = CTRL_DATA_RATE_CONTROL_ENABLE_PARAM;
   3392     ctrlData_setParam(pSiteMgr->hCtrlData, &param);
   3393 
   3394     return TI_OK;
   3395 }
   3396 
   3397 
   3398 /***********************************************************************
   3399  *                        siteMgr_assocReport
   3400  ***********************************************************************
   3401 DESCRIPTION:    Called by the following functions:
   3402                 -   assoc_recv()
   3403 
   3404 
   3405 INPUT:      hSiteMgr            -   siteMgr handle.
   3406             capabilities        -   assoc rsp capabilities field.
   3407 			bCiscoAP			-   whether we are connected to a Cisco AP. Used for Tx Power Control adjustment
   3408 OUTPUT:
   3409 
   3410 RETURN:     TI_OK on always
   3411 
   3412 ************************************************************************/
   3413 TI_STATUS siteMgr_assocReport(TI_HANDLE hSiteMgr, TI_UINT16 capabilities, TI_BOOL bCiscoAP)
   3414 {
   3415     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   3416     siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
   3417 
   3418     /* handle AP's preamble capability */
   3419     pPrimarySite->preambleAssRspCap = ((capabilities >> CAP_PREAMBLE_SHIFT) & CAP_PREAMBLE_MASK)  ? PREAMBLE_SHORT : PREAMBLE_LONG;
   3420 
   3421 	/*
   3422 	 * Enable/Disable the Tx Power Control adjustment.
   3423 	 * When we are connected to Cisco AP - TX Power Control adjustment is disabled.
   3424 	 */
   3425 	pSiteMgr->siteMgrTxPowerEnabled = ( !bCiscoAP ) && ( pSiteMgr->pDesiredParams->TxPowerControlOn );
   3426 
   3427 TRACE1(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, ": Tx Power Control adjustment is %d\n", pSiteMgr->siteMgrTxPowerEnabled);
   3428 
   3429     return TI_OK;
   3430 }
   3431 
   3432 /***********************************************************************
   3433  *                        siteMgr_setWMEParamsSite
   3434  ***********************************************************************
   3435 DESCRIPTION:    Set the QOS_WME params as received from the associated
   3436                 AP. The function is called by the QoS Mgr
   3437                 after receving association response succefully.
   3438 
   3439 INPUT:      hSiteMgr    -   SiteMgr handle.
   3440 
   3441 OUTPUT:     pDot11_WME_PARAM_t - pointer to the QOS_WME Param IE.
   3442 
   3443 RETURN:     TI_OK on always
   3444 
   3445 ************************************************************************/
   3446 TI_STATUS siteMgr_setWMEParamsSite(TI_HANDLE hSiteMgr,dot11_WME_PARAM_t *pDot11_WME_PARAM)
   3447 {
   3448     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   3449     siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
   3450 
   3451     if( pPrimarySite == NULL )
   3452     {
   3453         return TI_OK;
   3454     }
   3455 
   3456     if( pDot11_WME_PARAM == NULL )
   3457     {
   3458         pPrimarySite->WMESupported = TI_FALSE;
   3459         return TI_OK;
   3460     }
   3461 
   3462     /* Update the QOS_WME params */
   3463     os_memoryCopy(pSiteMgr->hOs,&pPrimarySite->WMEParameters,&pDot11_WME_PARAM->WME_ACParameteres,sizeof(dot11_ACParameters_t));
   3464     pPrimarySite->lastWMEParameterCnt = (pDot11_WME_PARAM->ACInfoField & dot11_WME_ACINFO_MASK);
   3465     TRACE1(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "$$$$$$ QOS_WME parameters were updates according to association response, cntSeq = %d\n",pPrimarySite->lastWMEParameterCnt);
   3466 
   3467     return TI_OK;
   3468 }
   3469 
   3470 
   3471 /***********************************************************************
   3472  *                        siteMgr_getWMEParamsSite
   3473  ***********************************************************************
   3474 DESCRIPTION:    Get the QOS_WME params as recieved from the associated
   3475                 AP. The function is called by the Qos Mgr in order
   3476                 to set all QOS_WME parameters to the core and Hal
   3477 
   3478 INPUT:      hSiteMgr    -   SiteMgr handle.
   3479 
   3480 OUTPUT:     pWME_ACParameters_t - pointer to the QOS_WME Param.
   3481 
   3482 RETURN:     TI_OK if there are valid QOS_WME parameters , TI_NOK otherwise.
   3483 
   3484 ************************************************************************/
   3485 TI_STATUS siteMgr_getWMEParamsSite(TI_HANDLE hSiteMgr,dot11_ACParameters_t **pWME_ACParameters_t)
   3486 {
   3487     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   3488     siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
   3489 
   3490     if(pPrimarySite->WMESupported == TI_TRUE)
   3491     {
   3492         *pWME_ACParameters_t = &pPrimarySite->WMEParameters;
   3493         return TI_OK;
   3494     }
   3495     else
   3496     {
   3497         *pWME_ACParameters_t = NULL;
   3498         return TI_NOK;
   3499     }
   3500 
   3501 }
   3502 
   3503 /***********************************************************************
   3504  *                        siteMgr_setCurrentTable
   3505  ***********************************************************************
   3506 DESCRIPTION:
   3507 
   3508 INPUT:      hSiteMgr    -   SiteMgr handle.
   3509 
   3510 OUTPUT:
   3511 
   3512 RETURN:
   3513 
   3514 ************************************************************************/
   3515 void siteMgr_setCurrentTable(TI_HANDLE hSiteMgr, ERadioBand radioBand)
   3516 {
   3517     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   3518 
   3519     if(radioBand == RADIO_BAND_2_4_GHZ)
   3520         pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
   3521     else
   3522         pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = (siteTablesParams_t *)&pSiteMgr->pSitesMgmtParams->dot11A_sitesTables;
   3523 }
   3524 
   3525 /***********************************************************************
   3526  *                        siteMgr_updateRates
   3527  ***********************************************************************
   3528 DESCRIPTION:
   3529 
   3530 INPUT:      hSiteMgr    -   SiteMgr handle.
   3531 
   3532 OUTPUT:
   3533 
   3534 RETURN:
   3535 
   3536 ************************************************************************/
   3537 
   3538 void siteMgr_updateRates(TI_HANDLE hSiteMgr, TI_BOOL dot11a, TI_BOOL updateToOS)
   3539 {
   3540     TI_UINT32  statusData;
   3541     TI_UINT32  localSuppRateMask, localBasicRateMask;
   3542 
   3543     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   3544 
   3545     localSuppRateMask = pSiteMgr->pDesiredParams->siteMgrRegstrySuppRateMask;
   3546     localBasicRateMask = pSiteMgr->pDesiredParams->siteMgrRegstryBasicRateMask;
   3547 
   3548 
   3549     rate_ValidateVsBand (&localSuppRateMask, &localBasicRateMask, dot11a);
   3550 
   3551     pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask = localBasicRateMask;
   3552     pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask = localSuppRateMask;
   3553 
   3554      /* Initialize Mutual Rates Matching */
   3555     pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask = pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask;
   3556     pSiteMgr->pDesiredParams->siteMgrMatchedSuppRateMask = pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask;
   3557 
   3558     /*If we are in dual mode and we are only scanning A band we don't have to set the siteMgrCurrentDesiredTxRate.*/
   3559     if (updateToOS == TI_TRUE)
   3560     {
   3561         TI_UINT32 uSupportedRates = pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask;
   3562         ERate eMaxRate = rate_GetMaxFromDrvBitmap (uSupportedRates);
   3563 
   3564         /* Make sure that the basic rate set is included in the supported rate set */
   3565         pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask &= uSupportedRates;
   3566 
   3567         /* Set desired modulation */
   3568         pSiteMgr->pDesiredParams->siteMgrDesiredModulationType =
   3569             (eMaxRate < DRV_RATE_22M) ? DRV_MODULATION_CCK : DRV_MODULATION_OFDM;
   3570     }
   3571     pSiteMgr->pDesiredParams->siteMgrDesiredRatePair.maxBasic = translateRateMaskToValue(pSiteMgr, pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask);
   3572     pSiteMgr->pDesiredParams->siteMgrDesiredRatePair.maxActive = translateRateMaskToValue(pSiteMgr, pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask);
   3573 
   3574     if (updateToOS == TI_TRUE)
   3575 	{
   3576         siteEntry_t  *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
   3577         TI_UINT32 commonSupportedRateMask;
   3578         ERate maxRate;
   3579 
   3580         commonSupportedRateMask = pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask;
   3581         if (pPrimarySite)
   3582         {
   3583             commonSupportedRateMask &= pPrimarySite->rateMask.supportedRateMask;
   3584         }
   3585 
   3586         maxRate = translateRateMaskToValue(pSiteMgr, commonSupportedRateMask);
   3587 
   3588         /* report the desired rate to OS */
   3589         statusData = rate_DrvToNet(maxRate);
   3590         EvHandlerSendEvent(pSiteMgr->hEvHandler, IPC_EVENT_LINK_SPEED, (TI_UINT8 *)&statusData,sizeof(TI_UINT32));
   3591     }
   3592 }
   3593 
   3594 
   3595 /**
   3596  * \fn     siteMgr_SelectRateMatch
   3597  * \brief  Checks if the rates settings match those of a site
   3598  *
   3599  * Checks if the rates settings match those of a site
   3600  *
   3601  * \param  hSiteMgr - handle to the siteMgr object
   3602  * \param  pCurrentSite - the site to check
   3603  * \return TI_TRUE if site matches rates settings, TI FALSE if it doesn't
   3604  * \sa     sme_Select
   3605  */
   3606 TI_BOOL siteMgr_SelectRateMatch (TI_HANDLE hSiteMgr, TSiteEntry *pCurrentSite)
   3607 {
   3608     siteMgr_t *pSiteMgr = (siteMgr_t *)hSiteMgr;
   3609 	TI_UINT32 StaTotalRates;
   3610 	TI_UINT32 SiteTotalRates;
   3611 
   3612 	/* If the basic or active rate are invalid (0), return NO_MATCH. */
   3613 	if ((pCurrentSite->maxBasicRate == DRV_RATE_INVALID) || (pCurrentSite->maxActiveRate == DRV_RATE_INVALID))
   3614 	{
   3615         TRACE2(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "siteMgr_SelectRateMatch: basic or active rate are invalid. maxBasic=%d,maxActive=%d \n", pCurrentSite->maxBasicRate ,pCurrentSite->maxActiveRate);
   3616 		return TI_FALSE;
   3617 	}
   3618 
   3619 	if (DRV_RATE_MAX < pCurrentSite->maxBasicRate)
   3620 	{
   3621         TRACE1(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "siteMgr_SelectRateMatch: basic rate is too high. maxBasic=%d\n", pCurrentSite->maxBasicRate);
   3622 		return TI_FALSE;
   3623 	}
   3624 
   3625 	if(pCurrentSite->channel <= SITE_MGR_CHANNEL_B_G_MAX)
   3626 		siteMgr_updateRates(pSiteMgr, TI_FALSE, TI_TRUE);
   3627 	else
   3628 		siteMgr_updateRates(pSiteMgr, TI_TRUE, TI_TRUE);
   3629 
   3630 	StaTotalRates = pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask |
   3631 				    pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask;
   3632 
   3633 	SiteTotalRates = pCurrentSite->rateMask.basicRateMask | pCurrentSite->rateMask.supportedRateMask;
   3634 
   3635     if ((StaTotalRates & pCurrentSite->rateMask.basicRateMask) != pCurrentSite->rateMask.basicRateMask)
   3636     {
   3637         TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "siteMgr_SelectRateMatch: Basic or Supported Rates Doesn't Match \n");
   3638         return TI_FALSE;
   3639 
   3640     }
   3641 
   3642     return TI_TRUE;
   3643 }
   3644 
   3645 /***********************************************************************
   3646  *                        siteMgr_bandParamsConfig
   3647  ***********************************************************************
   3648 DESCRIPTION:
   3649 
   3650 INPUT:      hSiteMgr    -   SiteMgr handle.
   3651 
   3652 OUTPUT:
   3653 
   3654 RETURN:
   3655 
   3656 ************************************************************************/
   3657 void siteMgr_bandParamsConfig(TI_HANDLE hSiteMgr,  TI_BOOL updateToOS)
   3658 {
   3659     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   3660 
   3661     /* reconfig rates */
   3662     if(pSiteMgr->siteMgrOperationalMode == DOT11_A_MODE)
   3663         siteMgr_updateRates(hSiteMgr, TI_TRUE, updateToOS);
   3664     else
   3665         siteMgr_updateRates(hSiteMgr, TI_FALSE, updateToOS);
   3666 
   3667     /* go to B_ONLY Mode only if WiFI bit is Set*/
   3668     if (pSiteMgr->pDesiredParams->siteMgrWiFiAdhoc == TI_TRUE)
   3669     {   /* Configuration For AdHoc when using external configuration */
   3670         if (pSiteMgr->pDesiredParams->siteMgrExternalConfiguration == TI_FALSE)
   3671         {
   3672             siteMgr_externalConfigurationParametersSet(hSiteMgr);
   3673         }
   3674     }
   3675 
   3676 }
   3677 
   3678 void siteMgr_ConfigRate(TI_HANDLE hSiteMgr)
   3679 {
   3680     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   3681     TI_BOOL      dot11a, b11nEnable;
   3682     EDot11Mode   OperationMode;
   3683 
   3684     OperationMode = pSiteMgr->siteMgrOperationalMode;
   3685 
   3686     /* It looks like it never happens. Anyway decided to check */
   3687     if ( OperationMode > DOT11_MAX_MODE -1 )
   3688     {
   3689         TRACE2( pSiteMgr->hReport, REPORT_SEVERITY_ERROR,
   3690                 "siteMgr_ConfigRate. OperationMode=%d exceeds the limit %d\n",
   3691                 OperationMode, DOT11_MAX_MODE -1);
   3692                 handleRunProblem(PROBLEM_BUF_SIZE_VIOLATION);
   3693         return;
   3694     }
   3695     /* reconfig rates */
   3696     if (OperationMode == DOT11_A_MODE)
   3697         dot11a = TI_TRUE;
   3698     else
   3699         dot11a = TI_FALSE;
   3700 
   3701     /*
   3702     ** Specific change to ch 14, that channel is only used in Japan, and is limited
   3703     ** to rates 1,2,5.5,11
   3704     */
   3705     if(pSiteMgr->pDesiredParams->siteMgrDesiredChannel == SPECIAL_BG_CHANNEL)
   3706     {
   3707         if(pSiteMgr->pDesiredParams->siteMgrRegstryBasicRate[OperationMode] > BASIC_RATE_SET_1_2_5_5_11)
   3708             pSiteMgr->pDesiredParams->siteMgrRegstryBasicRate[OperationMode] = BASIC_RATE_SET_1_2_5_5_11;
   3709 
   3710 
   3711         if(pSiteMgr->pDesiredParams->siteMgrRegstrySuppRate[OperationMode] > SUPPORTED_RATE_SET_1_2_5_5_11)
   3712             pSiteMgr->pDesiredParams->siteMgrRegstrySuppRate[OperationMode] = SUPPORTED_RATE_SET_1_2_5_5_11;
   3713     }
   3714 
   3715     /* use HT MCS rates */
   3716     if (pSiteMgr->pDesiredParams->siteMgrDesiredBSSType == BSS_INFRASTRUCTURE)
   3717 	{
   3718 		b11nEnable = TI_TRUE;
   3719 		OperationMode = DOT11_N_MODE;
   3720 	}
   3721 	else
   3722 	{
   3723 		b11nEnable = TI_FALSE;
   3724 	}
   3725 
   3726 
   3727     pSiteMgr->pDesiredParams->siteMgrRegstryBasicRateMask =
   3728         rate_BasicToDrvBitmap ((EBasicRateSet)(pSiteMgr->pDesiredParams->siteMgrRegstryBasicRate[OperationMode]), dot11a);
   3729 
   3730     pSiteMgr->pDesiredParams->siteMgrRegstrySuppRateMask =
   3731         rate_SupportedToDrvBitmap ((EBasicRateSet)(pSiteMgr->pDesiredParams->siteMgrRegstrySuppRate[OperationMode]), dot11a);
   3732 
   3733     siteMgr_updateRates(pSiteMgr, dot11a, TI_TRUE);
   3734 
   3735         /* go to B_ONLY Mode only if WiFI bit is Set*/
   3736     if (pSiteMgr->pDesiredParams->siteMgrWiFiAdhoc == TI_TRUE)
   3737     {   /* Configuration For AdHoc when using external configuration */
   3738         if (pSiteMgr->pDesiredParams->siteMgrExternalConfiguration == TI_FALSE)
   3739         {
   3740             siteMgr_externalConfigurationParametersSet(hSiteMgr);
   3741         }
   3742     }
   3743 }
   3744 
   3745 static void siteMgr_externalConfigurationParametersSet(TI_HANDLE hSiteMgr)
   3746 {
   3747     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   3748 
   3749     /* Overwrite the parameters for AdHoc with External Configuration */
   3750 
   3751     if( ((pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode == DOT11_A_MODE) ||
   3752         (pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode == DOT11_DUAL_MODE)) &&
   3753         !pSiteMgr->pDesiredParams->siteMgrWiFiAdhoc && pSiteMgr->pDesiredParams->siteMgrDesiredBSSType == BSS_INDEPENDENT)
   3754         return;
   3755 
   3756 
   3757     if(pSiteMgr->pDesiredParams->siteMgrDesiredBSSType == BSS_INDEPENDENT)
   3758     {
   3759         pSiteMgr->siteMgrOperationalMode = DOT11_B_MODE;
   3760         pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask = rate_BasicToDrvBitmap (BASIC_RATE_SET_1_2_5_5_11, TI_FALSE);
   3761         pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask = rate_SupportedToDrvBitmap (SUPPORTED_RATE_SET_1_2_5_5_11, TI_FALSE);
   3762         pSiteMgr->pDesiredParams->siteMgrRegstryBasicRateMask = rate_BasicToDrvBitmap (BASIC_RATE_SET_1_2_5_5_11, TI_FALSE);
   3763         pSiteMgr->pDesiredParams->siteMgrRegstrySuppRateMask = rate_SupportedToDrvBitmap (SUPPORTED_RATE_SET_1_2_5_5_11, TI_FALSE);
   3764         pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime = PHY_SLOT_TIME_LONG;
   3765 
   3766         TWD_SetRadioBand(pSiteMgr->hTWD, RADIO_BAND_2_4_GHZ);
   3767         TWD_CfgSlotTime (pSiteMgr->hTWD, PHY_SLOT_TIME_LONG);
   3768 
   3769     }
   3770     else
   3771     {
   3772         if(pSiteMgr->radioBand == RADIO_BAND_2_4_GHZ)
   3773             pSiteMgr->siteMgrOperationalMode = DOT11_G_MODE;
   3774         else
   3775             pSiteMgr->siteMgrOperationalMode = DOT11_A_MODE;
   3776         pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask = rate_BasicToDrvBitmap (BASIC_RATE_SET_1_2_5_5_11, TI_FALSE);
   3777         pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask = rate_SupportedToDrvBitmap (SUPPORTED_RATE_SET_ALL, TI_FALSE);
   3778         pSiteMgr->pDesiredParams->siteMgrRegstryBasicRateMask = rate_BasicToDrvBitmap (BASIC_RATE_SET_1_2_5_5_11, TI_FALSE);
   3779         pSiteMgr->pDesiredParams->siteMgrRegstrySuppRateMask = rate_SupportedToDrvBitmap (SUPPORTED_RATE_SET_ALL, TI_FALSE);
   3780 
   3781         pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime = PHY_SLOT_TIME_LONG;
   3782 
   3783         TWD_CfgSlotTime (pSiteMgr->hTWD, PHY_SLOT_TIME_LONG);
   3784     }
   3785 }
   3786 
   3787 
   3788 TI_STATUS siteMgr_saveProbeRespBuffer(TI_HANDLE hSiteMgr, TMacAddr  *bssid, TI_UINT8 *pProbeRespBuffer, TI_UINT32 length)
   3789 {
   3790     siteEntry_t *pSite;
   3791     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   3792 
   3793     if (pSiteMgr == NULL)
   3794     {
   3795         return TI_NOK;
   3796     }
   3797 
   3798     TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION , "siteMgr_saveProbeRespBuffer called\n");
   3799 
   3800     if (pProbeRespBuffer==NULL || length>=MAX_BEACON_BODY_LENGTH)
   3801     {
   3802         return TI_NOK;
   3803     }
   3804 
   3805     pSite = findSiteEntry(pSiteMgr, bssid);
   3806     if (pSite==NULL)
   3807     {
   3808         return TI_NOK;
   3809     }
   3810 
   3811     os_memoryCopy(pSiteMgr->hOs, pSite->probeRespBuffer, pProbeRespBuffer, length);
   3812     pSite->probeRespLength = length;
   3813 
   3814     TRACE17(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "siteMgr_saveProbeRespBuffer: BSSID=%x-%x-%x-%x-%x-%x, TSF=%x-%x-%x-%x-%x-%x-%x-%x, \n ts=%d, rssi=%d\n channel = %d \n", pSite->bssid[0], pSite->bssid[1], pSite->bssid[2], pSite->bssid[3], pSite->bssid[4], pSite->bssid[5], pSite->tsfTimeStamp[0], pSite->tsfTimeStamp[1], pSite->tsfTimeStamp[2], pSite->tsfTimeStamp[3], pSite->tsfTimeStamp[4], pSite->tsfTimeStamp[5], pSite->tsfTimeStamp[6], pSite->tsfTimeStamp[7], os_timeStampMs(pSiteMgr->hOs), pSite->rssi, pSite->channel);
   3815 
   3816     return TI_OK;
   3817 }
   3818 
   3819 TI_STATUS siteMgr_saveBeaconBuffer(TI_HANDLE hSiteMgr, TMacAddr *bssid, TI_UINT8 *pBeaconBuffer, TI_UINT32 length)
   3820 {
   3821     siteEntry_t *pSite;
   3822     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   3823 
   3824     if (pSiteMgr==NULL)
   3825     {
   3826         return TI_NOK;
   3827     }
   3828 
   3829 	TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION , "siteMgr_saveBeaconBuffer called\n");
   3830 
   3831     if (pBeaconBuffer==NULL || length>=MAX_BEACON_BODY_LENGTH)
   3832     {
   3833         return TI_NOK;
   3834     }
   3835 
   3836     pSite = findSiteEntry(pSiteMgr, bssid);
   3837     if (pSite==NULL)
   3838     {
   3839         return TI_NOK;
   3840     }
   3841 
   3842     os_memoryCopy(pSiteMgr->hOs, pSite->beaconBuffer, pBeaconBuffer, length);
   3843     pSite->beaconLength = length;
   3844 
   3845     /*if (pSiteMgr->pSitesMgmtParams->pPrimarySite!=NULL)
   3846     {
   3847         if (!os_memoryCompare(pSiteMgr->hOs, pSiteMgr->pSitesMgmtParams->pPrimarySite->ssid.ssidString, pSite->ssid.ssidString, pSiteMgr->pSitesMgmtParams->pPrimarySite->ssid.len))
   3848         {
   3849             TRACE16(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "siteMgr_saveBeaconBuffer: BSSID=%x-%x-%x-%x-%x-%x, TSF=%x-%x-%x-%x-%x-%x-%x-%x, \n ts=%d, rssi=%d \n", pSite->bssid[0], pSite->bssid[1], pSite->bssid[2], pSite->bssid[3], pSite->bssid[4], pSite->bssid[5], pSite->tsfTimeStamp[0], pSite->tsfTimeStamp[1], pSite->tsfTimeStamp[2], pSite->tsfTimeStamp[3], pSite->tsfTimeStamp[4], pSite->tsfTimeStamp[5], pSite->tsfTimeStamp[6], pSite->tsfTimeStamp[7], pSite->osTimeStamp, pSite->rssi);
   3850         }
   3851     }*/
   3852     if ( MAX_SSID_LEN > pSite->ssid.len )
   3853     {
   3854         pSite->ssid.str[pSite->ssid.len] = '\0';
   3855     }
   3856 
   3857     /*
   3858 TRACE9(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "siteMgr_saveBeaconBuffer: BSSID=%x-%x-%x-%x-%x-%x, SSID=, \n ts=%d, rssi=%d\n channel = %d \n", pSite->bssid[0], pSite->bssid[1], pSite->bssid[2], pSite->bssid[3], pSite->bssid[4], pSite->bssid[5], pSite->osTimeStamp, pSite->rssi, pSite->channel);
   3859 
   3860     */
   3861     return TI_OK;
   3862 }
   3863 
   3864 void siteMgr_IsERP_Needed(TI_HANDLE hSiteMgr,TI_BOOL *useProtection,TI_BOOL *NonErpPresent,TI_BOOL *barkerPreambleType)
   3865 {
   3866     siteMgr_t       *pSiteMgr = (siteMgr_t*)hSiteMgr;
   3867     paramInfo_t     param;
   3868     siteEntry_t     *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
   3869 
   3870     *useProtection = TI_FALSE;
   3871     *NonErpPresent = TI_FALSE;
   3872     *barkerPreambleType = TI_FALSE;
   3873 
   3874     param.paramType = CTRL_DATA_CURRENT_IBSS_PROTECTION_PARAM;
   3875     ctrlData_getParam(pSiteMgr->hCtrlData, &param);
   3876 
   3877     /* On WifiAdhoc (for band B) The STa should not include in the beacon an ERP IE (see WiFi B  clause 2.2, 5.8.2) */
   3878     if (pSiteMgr->pDesiredParams->siteMgrWiFiAdhoc == TI_TRUE)
   3879     {
   3880         /* Return the default => ERP is not needed */
   3881         return;
   3882     }
   3883 
   3884     /* check if STA is connected */
   3885     if (pPrimarySite)
   3886     {
   3887         if(pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE || pSiteMgr->siteMgrOperationalMode == DOT11_DUAL_MODE)
   3888         {
   3889             if(param.content.ctrlDataIbssProtecionType == ERP_PROTECTION_STANDARD)
   3890             {
   3891                 if(pPrimarySite->siteType == SITE_SELF)
   3892                 {
   3893                     if(pPrimarySite->channel <= SITE_MGR_CHANNEL_B_G_MAX) /* if channel B&G*/
   3894                     {
   3895                             *useProtection = TI_TRUE;
   3896                             *NonErpPresent = TI_TRUE;
   3897                             *barkerPreambleType = TI_TRUE;
   3898                     }
   3899                 }
   3900                 else if(pPrimarySite->bssType == BSS_INDEPENDENT)
   3901                 {
   3902                     if(pPrimarySite->useProtection == TI_TRUE)
   3903                         *useProtection = TI_TRUE;
   3904                     if(pPrimarySite->NonErpPresent == TI_TRUE)
   3905                         *NonErpPresent = TI_TRUE;
   3906                     if(pPrimarySite->barkerPreambleType == PREAMBLE_SHORT)
   3907                         *barkerPreambleType = TI_TRUE;
   3908                 }
   3909             }
   3910         }
   3911     }
   3912 }
   3913 
   3914 /**
   3915  * \fn     siteMgr_CopyToPrimarySite()
   3916  * \brief  Responsible to copy candidate AP from SME table to site Mgr table
   3917  *
   3918  * \note
   3919  * \param  hSiteMgr - SiteMgr handle.
   3920  * \param  pCandidate - candidate AP from SME table.
   3921  * \return TI_OK on success or TI_NOK on failure
   3922  * \sa
   3923  */
   3924 TI_STATUS siteMgr_CopyToPrimarySite (TI_HANDLE hSiteMgr, TSiteEntry *pCandidate)
   3925 {
   3926     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   3927     bssEntry_t  newAP;
   3928 
   3929     MAC_COPY (newAP.BSSID, pCandidate->bssid);
   3930     newAP.band = pCandidate->eBand;
   3931     newAP.RSSI = pCandidate->rssi;
   3932     newAP.rxRate = pCandidate->rxRate;
   3933     newAP.channel = pCandidate->channel;
   3934     os_memoryCopy(pSiteMgr->hOs, (void *)&newAP.lastRxTSF, (void *)pCandidate->tsfTimeStamp , TIME_STAMP_LEN);
   3935     newAP.beaconInterval = pCandidate->beaconInterval;
   3936     newAP.capabilities = pCandidate->capabilities;
   3937     newAP.pBuffer = NULL;
   3938     /* get frame type */
   3939     if (TI_TRUE == pCandidate->probeRecv)
   3940     {
   3941         newAP.resultType = SCAN_RFT_PROBE_RESPONSE;
   3942         newAP.pBuffer = (TI_UINT8 *)(pCandidate->probeRespBuffer);
   3943         /* length of all IEs of beacon (or probe response) buffer */
   3944         newAP.bufferLength = pCandidate->probeRespLength;
   3945     }
   3946     else
   3947     {
   3948         if (TI_TRUE == pCandidate->beaconRecv)
   3949         {
   3950             newAP.resultType = SCAN_RFT_BEACON;
   3951             newAP.pBuffer = (TI_UINT8 *)(pCandidate->beaconBuffer);
   3952             /* length of all IEs of beacon (or probe response) buffer */
   3953             newAP.bufferLength = pCandidate->beaconLength;
   3954 
   3955         }
   3956         else
   3957         {
   3958             TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_ERROR, "siteMgr_CopyToPrimarySite: try to update primary site without updated prob_res\beacon\n\n");
   3959             return TI_NOK;
   3960         }
   3961     }
   3962 
   3963     if (newAP.pBuffer == NULL)
   3964     {
   3965         TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_ERROR, "siteMgr_CopyToPrimarySite: pBufferBody is NULL !\n");
   3966         return TI_NOK;
   3967     }
   3968 
   3969     return siteMgr_overwritePrimarySite (hSiteMgr, &newAP, TI_FALSE);
   3970 }
   3971 
   3972 
   3973 /***********************************************************************
   3974  *                        siteMgr_disSelectSite
   3975  ***********************************************************************
   3976 DESCRIPTION: Called by the SME SM in order to dis select the primary site.
   3977 			The function set the primary site pointer to NULL and set its type to type regular
   3978 
   3979 INPUT:      hSiteMgr	-	site mgr handle.
   3980 
   3981 OUTPUT:
   3982 
   3983 RETURN:     TI_OK
   3984 
   3985 ************************************************************************/
   3986 TI_STATUS siteMgr_disSelectSite(TI_HANDLE	hSiteMgr)
   3987 {
   3988 	siteMgr_t	*pSiteMgr = (siteMgr_t *)hSiteMgr;
   3989 
   3990 	/* This protection is because in the case that the BSS was LOST the primary site was removed already. */
   3991 	if (pSiteMgr->pSitesMgmtParams->pPrimarySite != NULL)
   3992 	{
   3993         TRACE6(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "siteMgr_disSelectSite REMOVE Primary ssid=, bssid= 0x%x-0x%x-0x%x-0x%x-0x%x-0x%x\n\n", pSiteMgr->pSitesMgmtParams->pPrimarySite->bssid[0], pSiteMgr->pSitesMgmtParams->pPrimarySite->bssid[1], pSiteMgr->pSitesMgmtParams->pPrimarySite->bssid[2], pSiteMgr->pSitesMgmtParams->pPrimarySite->bssid[3], pSiteMgr->pSitesMgmtParams->pPrimarySite->bssid[4], pSiteMgr->pSitesMgmtParams->pPrimarySite->bssid[5] );
   3994 
   3995         pSiteMgr->pSitesMgmtParams->pPrimarySite->siteType = SITE_REGULAR;
   3996 		pSiteMgr->pSitesMgmtParams->pPrevPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
   3997 		pSiteMgr->pSitesMgmtParams->pPrimarySite = NULL;
   3998 	}
   3999 
   4000 	return TI_OK;
   4001 }
   4002 
   4003 
   4004 /**
   4005 *
   4006 * siteMgr_overwritePrimarySite
   4007 *
   4008 * \b Description:
   4009 *
   4010 * This function sets new AP as a primary site and, if requested, stores previous
   4011 * AP's info; called during roaming
   4012 *
   4013 * \b ARGS:
   4014 *
   4015 *  I   - pCurrBSS - Current BSS handle \n
   4016 *
   4017 * \b RETURNS:
   4018 *
   4019 *  TI_OK on success, TI_NOK on failure.
   4020 *
   4021 * \sa
   4022 */
   4023 TI_STATUS siteMgr_overwritePrimarySite(TI_HANDLE hSiteMgr, bssEntry_t *newAP, TI_BOOL requiredToStorePrevSite)
   4024 {
   4025     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   4026     siteEntry_t *newApEntry;
   4027     mlmeIEParsingParams_t *ieListParseParams = mlmeParser_getParseIEsBuffer(pSiteMgr->hMlmeSm);
   4028 
   4029     TRACE6(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "siteMgr_overwritePrimarySite: new site bssid= 0x%x-0x%x-0x%x-0x%x-0x%x-0x%x\n\n", newAP->BSSID[0], newAP->BSSID[1], newAP->BSSID[2], newAP->BSSID[3], newAP->BSSID[4], newAP->BSSID[5]);
   4030 
   4031     /* If previous primary site present, and requested to save it - store it */
   4032     if (requiredToStorePrevSite)
   4033     {
   4034         TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "siteMgr_overwritePrimarySite: required to store prev prim site \n");
   4035         /* Store latest primary site, make ite a regular site */
   4036         pSiteMgr->pSitesMgmtParams->pPrevPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
   4037         pSiteMgr->pSitesMgmtParams->pPrevPrimarySite->siteType = SITE_REGULAR;
   4038     }
   4039     else
   4040     {
   4041         TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "siteMgr_overwritePrimarySite: not required to store prev prim site \n");
   4042         if (pSiteMgr->pSitesMgmtParams->pPrimarySite != NULL)
   4043         {
   4044             TRACE6(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "Removing Primary ssid=, bssid= 0x%x-0x%x-0x%x-0x%x-0x%x-0x%x\n\n", pSiteMgr->pSitesMgmtParams->pPrimarySite->bssid[0], pSiteMgr->pSitesMgmtParams->pPrimarySite->bssid[1], pSiteMgr->pSitesMgmtParams->pPrimarySite->bssid[2], pSiteMgr->pSitesMgmtParams->pPrimarySite->bssid[3], pSiteMgr->pSitesMgmtParams->pPrimarySite->bssid[4], pSiteMgr->pSitesMgmtParams->pPrimarySite->bssid[5] );
   4045 
   4046             pSiteMgr->pSitesMgmtParams->pPrimarySite->siteType  = SITE_REGULAR;
   4047             pSiteMgr->pSitesMgmtParams->pPrimarySite->beaconRecv = TI_FALSE;
   4048 
   4049             pSiteMgr->pSitesMgmtParams->pPrimarySite = NULL;
   4050         }
   4051         else
   4052         {
   4053             TRACE0(pSiteMgr->hReport, REPORT_SEVERITY_INFORMATION, "siteMgr_overwritePrimarySite: primary site is NULL \n");
   4054         }
   4055 
   4056     }
   4057 
   4058     /* Find not occupied entry in site table, and store new AP BSSID in */
   4059     /* If pPrimarySite is not set to NULL, store it in pPrevSite before updating */
   4060     newApEntry = findAndInsertSiteEntry(pSiteMgr, &(newAP->BSSID), newAP->band);
   4061 
   4062     if (newApEntry != NULL)
   4063     {
   4064         /* Zero frame content */
   4065         os_memoryZero(pSiteMgr->hOs, ieListParseParams, sizeof(mlmeIEParsingParams_t));
   4066 
   4067         /* Update parameters of new AP */
   4068         newApEntry->rssi            = newAP->RSSI;
   4069         newApEntry->bssType         = BSS_INFRASTRUCTURE;
   4070         newApEntry->dtimPeriod      = 1;
   4071         newApEntry->rxRate          = (ERate)newAP->rxRate;
   4072         /* Mark the site as regular in order to prevent from calling Power manager during beacon parsing */
   4073         newApEntry->siteType        = SITE_REGULAR;
   4074 
   4075         os_memoryCopy(pSiteMgr->hOs, &newApEntry->ssid, &pSiteMgr->pDesiredParams->siteMgrDesiredSSID, sizeof(TSsid));
   4076 
   4077         if (newAP->resultType == SCAN_RFT_PROBE_RESPONSE)
   4078         {
   4079             ieListParseParams->frame.subType = PROBE_RESPONSE;
   4080             siteMgr_saveProbeRespBuffer(hSiteMgr, &(newAP->BSSID), newAP->pBuffer, newAP->bufferLength);
   4081         }
   4082         else
   4083         {
   4084             ieListParseParams->frame.subType = BEACON;
   4085             siteMgr_saveBeaconBuffer(hSiteMgr, &(newAP->BSSID), newAP->pBuffer, newAP->bufferLength);
   4086         }
   4087         ieListParseParams->band = newAP->band;
   4088         ieListParseParams->rxChannel = newAP->channel;
   4089         ieListParseParams->myBssid = TI_FALSE;
   4090 
   4091         ieListParseParams->frame.content.iePacket.pRsnIe = NULL;
   4092         ieListParseParams->frame.content.iePacket.rsnIeLen = 0;
   4093         ieListParseParams->frame.content.iePacket.barkerPreambleMode = PREAMBLE_UNSPECIFIED;
   4094         os_memoryCopy(pSiteMgr->hOs, (void *)ieListParseParams->frame.content.iePacket.timestamp, (void *)&newAP->lastRxTSF, TIME_STAMP_LEN);
   4095         ieListParseParams->frame.content.iePacket.beaconInerval     = newAP->beaconInterval;
   4096         ieListParseParams->frame.content.iePacket.capabilities  = newAP->capabilities;
   4097 
   4098         if (mlmeParser_parseIEs(pSiteMgr->hMlmeSm, newAP->pBuffer, newAP->bufferLength, ieListParseParams) != TI_OK)
   4099         {
   4100             /* Error in parsing Probe response packet - exit */
   4101             return TI_NOK;
   4102         }
   4103 
   4104         siteMgr_updateSite(hSiteMgr, &(newAP->BSSID), &ieListParseParams->frame, newAP->channel, newAP->band, TI_FALSE);
   4105 
   4106         /* Select the entry as primary site */
   4107         newApEntry->siteType = SITE_PRIMARY;
   4108         pSiteMgr->pSitesMgmtParams->pPrimarySite = newApEntry;
   4109         return TI_OK;
   4110     }
   4111     else
   4112     {
   4113         return TI_NOK;
   4114     }
   4115 }
   4116 
   4117 
   4118 /**
   4119  * \fn     siteMgr_changeBandParams
   4120  * \brief  change band params at the SithMgr and the TWD
   4121 
   4122  * \param  hSiteMgr - handle to the siteMgr object.
   4123  * \param  radioBand - the set radio band.
   4124  * \return TI_TRUE if site matches RSN settings, TI FALSE if it doesn't
   4125  * \sa     sme_Select
   4126  */
   4127 void siteMgr_changeBandParams (TI_HANDLE hSiteMgr, ERadioBand radioBand)
   4128 {
   4129 	paramInfo_t	param;
   4130     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   4131 
   4132 	/* change dot11 mode */
   4133 	param.paramType = SITE_MGR_OPERATIONAL_MODE_PARAM;
   4134 	if(radioBand == RADIO_BAND_2_4_GHZ)
   4135 		param.content.siteMgrDot11OperationalMode = DOT11_G_MODE;
   4136 	else
   4137 		param.content.siteMgrDot11OperationalMode = DOT11_A_MODE;
   4138 
   4139 	siteMgr_setParam(hSiteMgr, &param);
   4140 
   4141 	param.paramType = SITE_MGR_RADIO_BAND_PARAM;
   4142 	param.content.siteMgrRadioBand = radioBand;
   4143 	siteMgr_setParam(hSiteMgr, &param);
   4144 
   4145 	siteMgr_setCurrentTable(hSiteMgr, radioBand);
   4146 
   4147 	/* configure hal with common core-hal parameters */
   4148 	TWD_SetRadioBand (pSiteMgr->hTWD, radioBand);
   4149 }
   4150 
   4151 
   4152 /***********************************************************************
   4153                 incrementTxSessionCount
   4154  ***********************************************************************
   4155 DESCRIPTION: Increment the Tx-Session-Counter (cyclic in range 1-7), which
   4156                is configured to the FW in the Join command to distinguish
   4157 			   between Tx packets of different AP-connections.
   4158 			 Update also the TxCtrl module.
   4159 
   4160 INPUT:      pSiteMgr    -   site mgr handle.
   4161 
   4162 OUTPUT:
   4163 
   4164 RETURN:     TI_UINT16 - the new Tx-Session-Count (range is 1-7).
   4165 
   4166 ************************************************************************/
   4167 static TI_UINT16 incrementTxSessionCount(siteMgr_t *pSiteMgr)
   4168 {
   4169 	pSiteMgr->txSessionCount++;
   4170 	if(pSiteMgr->txSessionCount > MAX_TX_SESSION_COUNT)
   4171 		pSiteMgr->txSessionCount = MIN_TX_SESSION_COUNT;
   4172 
   4173 	txCtrlParams_updateTxSessionCount(pSiteMgr->hTxCtrl, pSiteMgr->txSessionCount);
   4174 
   4175 	return pSiteMgr->txSessionCount;
   4176 }
   4177 
   4178 
   4179 /**
   4180 *
   4181 * siteMgr_TxPowerHighThreshold
   4182 *
   4183 * \b Description:
   4184 *
   4185 * Called by EventMBox upon TX Power Adaptation High Threshold Trigger.
   4186 *
   4187 * \b ARGS:
   4188 *
   4189 *  I   - hSiteMgr - Site Mgr handle \n
   4190 *
   4191 * \b RETURNS:
   4192 *
   4193 *  None
   4194 *
   4195 * \sa
   4196 */
   4197 void siteMgr_TxPowerHighThreshold(TI_HANDLE hSiteMgr,
   4198                                       TI_UINT8     *data,
   4199                                       TI_UINT8     dataLength)
   4200 {
   4201     siteMgr_TxPowerAdaptation(hSiteMgr, RSSI_EVENT_DIR_HIGH);
   4202 }
   4203 
   4204 /**
   4205 *
   4206 * siteMgr_TxPowerLowThreshold
   4207 *
   4208 * \b Description:
   4209 *
   4210 * Called by EventMBox upon TX Power Adaptation Low Threshold Trigger.
   4211 *
   4212 * \b ARGS:
   4213 *
   4214 *  I   - hSiteMgr - Site Mgr handle \n
   4215 *
   4216 * \b RETURNS:
   4217 *
   4218 *  None
   4219 *
   4220 * \sa
   4221 */
   4222 void siteMgr_TxPowerLowThreshold(TI_HANDLE hSiteMgr,
   4223                                       TI_UINT8     *data,
   4224                                       TI_UINT8     dataLength)
   4225 {
   4226     siteMgr_TxPowerAdaptation(hSiteMgr, RSSI_EVENT_DIR_LOW);
   4227 }
   4228 
   4229 /**
   4230 *
   4231 * siteMgr_TxPowerAdaptation
   4232 *
   4233 * \b Description:
   4234 *
   4235 * TX Power Adaptation - Used for TX power adjust .
   4236 *
   4237 * \b ARGS:
   4238 *
   4239 *  I   - hSiteMgr - Site Mgr handle \n
   4240 *      - highLowEdge - Direction of Edge event
   4241 *
   4242 * \b RETURNS:
   4243 *
   4244 *  None
   4245 *
   4246 * \sa
   4247 */
   4248 static void siteMgr_TxPowerAdaptation(TI_HANDLE hSiteMgr, RssiEventDir_e highLowEdge)
   4249 {
   4250     siteMgr_t    *pSiteMgr = (siteMgr_t *)hSiteMgr;
   4251 
   4252     if (pSiteMgr->siteMgrTxPowerEnabled)
   4253     {
   4254         if (highLowEdge == RSSI_EVENT_DIR_HIGH)
   4255         {
   4256             /* enable the "Temporary TX power" when close to AP */
   4257             siteMgr_setTemporaryTxPower (pSiteMgr, TI_TRUE) ;
   4258         }
   4259         else
   4260         {
   4261             /* disable the "Temporary TX power" when we are again far from the AP */
   4262             siteMgr_setTemporaryTxPower (pSiteMgr, TI_FALSE);
   4263         }
   4264     }
   4265 }
   4266 
   4267