Home | History | Annotate | Download | only in siteMgr
      1 /****************************************************************************
      2 **+-----------------------------------------------------------------------+**
      3 **|                                                                       |**
      4 **| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved.      |**
      5 **| All rights reserved.                                                  |**
      6 **|                                                                       |**
      7 **| Redistribution and use in source and binary forms, with or without    |**
      8 **| modification, are permitted provided that the following conditions    |**
      9 **| are met:                                                              |**
     10 **|                                                                       |**
     11 **|  * Redistributions of source code must retain the above copyright     |**
     12 **|    notice, this list of conditions and the following disclaimer.      |**
     13 **|  * Redistributions in binary form must reproduce the above copyright  |**
     14 **|    notice, this list of conditions and the following disclaimer in    |**
     15 **|    the documentation and/or other materials provided with the         |**
     16 **|    distribution.                                                      |**
     17 **|  * Neither the name Texas Instruments nor the names of its            |**
     18 **|    contributors may be used to endorse or promote products derived    |**
     19 **|    from this software without specific prior written permission.      |**
     20 **|                                                                       |**
     21 **| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS   |**
     22 **| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT     |**
     23 **| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |**
     24 **| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT  |**
     25 **| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |**
     26 **| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT      |**
     27 **| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |**
     28 **| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |**
     29 **| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT   |**
     30 **| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |**
     31 **| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  |**
     32 **|                                                                       |**
     33 **+-----------------------------------------------------------------------+**
     34 ****************************************************************************/
     35 
     36 /** \file siteMgr.c
     37  *  \brief Site Manager implementation
     38  *
     39  *  \see siteMgr.h
     40  */
     41 
     42 #include "report.h"
     43 #include "osTIType.h"
     44 #include "osApi.h"
     45 #include "siteMgrApi.h"
     46 #include "siteHash.h"
     47 #include "smeApi.h"
     48 #include "utils.h"
     49 #include "connApi.h"
     50 #include "mlmeSm.h"
     51 #include "smeSmApi.h"
     52 #include "DataCtrl_Api.h"
     53 #include "regulatoryDomainApi.h"
     54 #include "rsnApi.h"
     55 #include "measurementMgrApi.h"
     56 #include "qosMngr_API.h"
     57 #include "PowerMgr_API.h"
     58 #include "EvHandler.h"
     59 #include "TI_IPC_Api.h"
     60 #include "MacServices_api.h"
     61 #include "whalHwDefs.h"
     62 #include "apConn.h"
     63 #include "currBss.h"
     64 #include "PowerMgr.h"
     65 
     66 #ifdef EXC_MODULE_INCLUDED
     67 #include "excMngr.h"
     68 #endif
     69 #include "configMgr.h"
     70 
     71 /* definitions */
     72 
     73 #define JOIN_RATE_MASK_1M   0x01
     74 #define JOIN_RATE_MASK_2M   0x02
     75 #define JOIN_RATE_MASK_5_5M 0x04
     76 #define JOIN_RATE_MASK_11M  0x08
     77 #define JOIN_RATE_MASK_22M  0x10
     78 
     79 
     80 #define SITE_MGR_INIT_BIT           1
     81 #define TIMER_INIT_BIT              2
     82 #define DESIRED_PARAMS_INIT_BIT     3
     83 #define MGMT_PARAMS_INIT_BIT        4
     84 
     85 #define BUILT_IN_TEST_PERIOD 500
     86 
     87 #define KEEP_ALIVE_SEND_NULL_DATA_PERIOD  10000
     88 
     89 #define SITE_MGR_IBSS_AGING_TIMEOUT_DEF   10 * 1000        /* 10 seconds */
     90 
     91 #define DEAFULT_BEACON_FILTERING_NUM        (10)
     92 
     93 /* Reconfig constants */
     94 #define SCAN_FAIL_THRESHOLD_FOR_RECONFIG        4  /* After 4 times we reset the 580 register and still no AP found - make recovery */
     95 #define SCAN_FAIL_THRESHOLD_FOR_RESET_REG_580   90  /* After 90 times (45 seconds) and  no AP found - reset the 580 register */
     96 #define SCAN_FAIL_RECONFIG_ENABLED              TRUE
     97 #define SCAN_FAIL_RECONFIG_DISABLED             FALSE
     98 
     99 /* Local Macros */
    100 
    101 #define UPDATE_BEACON_INTERVAL(pSite, pFrameInfo)       pSite->beaconInterval = pFrameInfo->content.iePacket.beaconInerval
    102 
    103 #define UPDATE_CAPABILITIES(pSite, pFrameInfo)          pSite->capabilities = pFrameInfo->content.iePacket.capabilities
    104 
    105 #define UPDATE_PRIVACY(pSite, pFrameInfo)               pSite->privacy = ((pFrameInfo->content.iePacket.capabilities >> CAP_PRIVACY_SHIFT) & CAP_PRIVACY_MASK) ? TRUE : FALSE
    106 
    107 #define UPDATE_AGILITY(pSite, pFrameInfo)               pSite->agility = ((pFrameInfo->content.iePacket.capabilities >> CAP_AGILE_SHIFT) & CAP_AGILE_MASK) ? TRUE : FALSE
    108 
    109 #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
    110 #define UPDATE_PROTECTION(pSite, pFrameInfo)            pSite->useProtection = (pFrameInfo->content.iePacket.useProtection)
    111 
    112 #define UPDATE_SSID(pSite, pFrameInfo)                  if (pFrameInfo->content.iePacket.pSsid != NULL) { \
    113                                                         pSite->ssid.len = pFrameInfo->content.iePacket.pSsid->hdr.eleLen; \
    114         os_memoryCopy(pSiteMgr->hOs, (void *)pSite->ssid.ssidString, (void *)pFrameInfo->content.iePacket.pSsid->serviceSetId, pFrameInfo->content.iePacket.pSsid->hdr.eleLen) ;}
    115 
    116 #define UPDATE_CHANNEL(pSite, pFrameInfo, rxChannel)    if (pFrameInfo->content.iePacket.pDSParamsSet == NULL) \
    117                                                             pSite->channel = rxChannel; \
    118                                                         else \
    119                                                             pSite->channel = pFrameInfo->content.iePacket.pDSParamsSet->currChannel;
    120 
    121 
    122 
    123 #define UPDATE_DTIM_PERIOD(pSite, pFrameInfo)           if (pFrameInfo->content.iePacket.pTIM != NULL) \
    124                                                         pSite->dtimPeriod = pFrameInfo->content.iePacket.pTIM->dtimPeriod
    125 
    126 #define UPDATE_ATIM_WINDOW(pSite, pFrameInfo)           if (pFrameInfo->content.iePacket.pIBSSParamsSet != NULL) \
    127                                                         pSite->atimWindow = pFrameInfo->content.iePacket.pIBSSParamsSet->atimWindow
    128 
    129 #define UPDATE_BEACON_AP_TX_POWER(pSite, pFrameInfo)    if (pFrameInfo->content.iePacket.TPCReport != NULL) \
    130                                                         pSite->APTxPower = pFrameInfo->content.iePacket.TPCReport->transmitPower
    131 
    132 #define UPDATE_PROBE_AP_TX_POWER(pSite, pFrameInfo)     if (pFrameInfo->content.iePacket.TPCReport != NULL) \
    133                                                         pSite->APTxPower = pFrameInfo->content.iePacket.TPCReport->transmitPower
    134 
    135 #define UPDATE_BSS_TYPE(pSite, pFrameInfo)              pSite->bssType = ((pFrameInfo->content.iePacket.capabilities >> CAP_ESS_SHIFT) & CAP_ESS_MASK) ? BSS_INFRASTRUCTURE : BSS_INDEPENDENT
    136 
    137 #define UPDATE_LOCAL_TIME_STAMP(pSiteMgr, pSite, pFrameInfo)        pSite->localTimeStamp = os_timeStampMs(pSiteMgr->hOs)
    138 
    139 #define UPDATE_DTIM_TIME(pSiteMgr, pSite, pFrameInfo)       pSite->dtimTimeStamp = os_timeStampMs(pSiteMgr->hOs)
    140 
    141 /* Updated from beacons */
    142 #define UPDATE_BEACON_MODULATION(pSite, pFrameInfo)     pSite->beaconModulation = ((pFrameInfo->content.iePacket.capabilities >> CAP_PBCC_SHIFT) & CAP_PBCC_MASK) ? DRV_MODULATION_PBCC : DRV_MODULATION_CCK
    143 
    144 /* Updated from probes */
    145 #define UPDATE_PROBE_MODULATION(pSite, pFrameInfo)          pSite->probeModulation = ((pFrameInfo->content.iePacket.capabilities >> CAP_PBCC_SHIFT) & CAP_PBCC_MASK) ? DRV_MODULATION_PBCC : DRV_MODULATION_CCK
    146 
    147 #define UPDATE_BEACON_RECV(pSite)                       pSite->beaconRecv = TRUE
    148 
    149 #define UPDATE_PROBE_RECV(pSite)                        pSite->probeRecv = TRUE
    150 
    151 
    152 #define UPDATE_RSN_IE(pSite, pRsnIe, rsnIeLen)              if (pRsnIe != NULL) { \
    153                                                             UINT8 length=0, index=0;\
    154                                                             pSite->rsnIeLen = rsnIeLen;\
    155                                                             while ((length < pSite->rsnIeLen) && (index<MAX_RSN_IE)){\
    156                                                                 pSite->pRsnIe[index].hdr = pRsnIe->hdr;\
    157                                                                 os_memoryCopy(pSiteMgr->hOs, (void *)pSite->pRsnIe[index].rsnIeData, (void *)pRsnIe->rsnIeData, pRsnIe->hdr.eleLen);\
    158                                                                 length += (pRsnIe->hdr.eleLen+2); \
    159                                                                 pRsnIe += 1; \
    160                                                                 index++;}\
    161                                                         } \
    162                                                         else {pSite->rsnIeLen = 0;}
    163 
    164 #define UPDATE_BEACON_TIMESTAMP(pSiteMgr, pSite, pFrameInfo)    os_memoryCopy(pSiteMgr->hOs, pSite->tsfTimeStamp, (void *)pFrameInfo->content.iePacket.timestamp, TIME_STAMP_LEN)
    165 
    166 #define SET_ENTRY_FLAG_IN_SITE_TABLE(pSite)             pSite->Not_Received = 0
    167 
    168 
    169 
    170 
    171 /* Local  functions definitions*/
    172 
    173 static void update_apsd(siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo);
    174 
    175 static void release_module(siteMgr_t *pSiteMgr, UINT32 initVec);
    176 
    177 static void updateSiteInfo(siteMgr_t *pSiteMgr, mlmeFrameInfo_t *pFrameInfo, siteEntry_t    *pSite, UINT8 rxChannel);
    178 
    179 static void updateRates(siteMgr_t *pSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo);
    180 
    181 static void updateBeaconQosParams(siteMgr_t *pSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo);
    182 
    183 static void updateProbeQosParams(siteMgr_t *pSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo);
    184 
    185 static void updatePreamble(siteMgr_t *pSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo);
    186 
    187 static void updateFourX(siteMgr_t *pSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo);
    188 
    189 static TI_STATUS getBssidList(siteMgr_t *pSiteMgr, OS_802_11_BSSID_LIST_EX *bssidList, UINT32* pLength, BOOL allVarIes);
    190 
    191 static void getPrimarySiteDesc(siteMgr_t *pSiteMgr, OS_802_11_BSSID *pPrimarySiteDesc, BOOL supplyExtendedInfo);
    192 
    193 static TI_STATUS getPrimaryBssid(siteMgr_t *pSiteMgr, OS_802_11_BSSID_EX *primaryBssid, UINT32 *pLength);
    194 
    195 static rate_e translateRateMaskToValue(siteMgr_t *pSiteMgr, UINT32 rateMask);
    196 
    197 static void getSupportedRateSet(siteMgr_t *pSiteMgr, rates_t *pRatesSet);
    198 
    199 static TI_STATUS setSupportedRateSet(siteMgr_t *pSiteMgr, rates_t *pRatesSet);
    200 
    201 static void validateDesiredTxRate(rate_e desiredTxRate,modulationType_e desiredModulation,UINT32 suppRates,UINT32 *bitMap,BOOL *txDesiredRateSupported);
    202 
    203 static TI_STATUS calculateBssidListSize(siteMgr_t *pSiteMgr, UINT32 *pLength, BOOL allVarIes);
    204 
    205 static void siteMgr_externalConfigurationParametersSet(TI_HANDLE hSiteMgr);
    206 
    207 
    208 void siteMgr_gotFirstBcn(TI_HANDLE hSiteMgr);
    209 
    210 /**************************************************************/
    211 /* DEBUG CLI CRASH                                            */
    212 /**************************************************************/
    213 static    whalCtrl_joinBss_t      joinParams;
    214 static    whalCtrl_setTemplate_t  templateStruct;
    215 static    probeRspTemplate_t      probeRspTemplate;
    216 static    nullDataTemplate_t      nullDataTemplate;
    217 static    psPollTemplate_t        psPollTemplate;
    218 static    QosNullDataTemplate_t   QosNullDataTemplate;
    219 /**************************************************************/
    220 
    221 #define CHAN_FREQ_TABLE_SIZE        (sizeof(ChanFreq) / sizeof(struct CHAN_FREQ))
    222 
    223 struct CHAN_FREQ {
    224     UINT8       chan;
    225     UINT32      freq;
    226 } ChanFreq[] = {
    227     {1,2412000}, {2,2417000}, {3,2422000}, {4,2427000},
    228     {5,2432000}, {6,2437000}, {7,2442000}, {8,2447000},
    229     {9,2452000},
    230     {10,2457000}, {11,2462000}, {12,2467000}, {13,2472000},
    231     {14,2484000}, {36,5180000}, {40,5200000}, {44,5220000},
    232     {48,5240000}, {52,5260000}, {56,5280000}, {60,5300000},
    233     {64,5320000},
    234     {100,5500000}, {104,5520000}, {108,5540000}, {112,5560000},
    235     {116,5580000}, {120,5600000}, {124,5620000}, {128,5640000},
    236     {132,5660000}, {136,5680000}, {140,5700000}, {149,5745000},
    237     {153,5765000}, {157,5785000}, {161,5805000} };
    238 
    239 
    240 
    241 static UINT8 Freq2Chan(UINT32 freq)
    242 {
    243     UINT32 i;
    244 
    245     for(i=0; i<CHAN_FREQ_TABLE_SIZE; i++)
    246         if(ChanFreq[i].freq == freq) return ChanFreq[i].chan;
    247 
    248     return 0;
    249 }
    250 
    251 
    252 static UINT32 Chan2Freq(UINT8 chan)
    253 {
    254     UINT32 i;
    255 
    256     for(i=0; i<CHAN_FREQ_TABLE_SIZE; i++)
    257         if(ChanFreq[i].chan == chan) return ChanFreq[i].freq;
    258 
    259     return 0;
    260 }
    261 
    262 /************************************************************************
    263 *                        siteMgr_setTemporaryTxPower                    *
    264 *************************************************************************
    265 DESCRIPTION:	This function is used to start the Tx Power Control adjust mechanism
    266 				in regulatoryDomain.
    267 
    268 INPUT:      bActivateTempFix             -   Whether the power should be adjusted
    269 ************************************************************************/
    270 void siteMgr_setTemporaryTxPower(siteMgr_t* pSiteMgr, BOOL bActivateTempFix)
    271 {
    272 	paramInfo_t         param;
    273 
    274 	WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
    275 		("siteMgr_setTemporaryTxPower is = %s \n", (bActivateTempFix ? "ON" : "OFF")));
    276 
    277 	/* Set the temporary Power Level via the Regulatory Domain*/
    278 	param.paramType = REGULATORY_DOMAIN_TEMPORARY_TX_ATTENUATION_PARAM;
    279 	param.content.bActivateTempPowerFix = bActivateTempFix;
    280 	regulatoryDomain_setParam(pSiteMgr->hRegulatoryDomain,&param);
    281 }
    282 
    283 /* Interface functions Implementation */
    284 
    285 
    286 /*static void UPDATE_RSN_IE (siteMgr_t* pSiteMgr, siteEntry_t   *pSite, dot11_RSN_t *pRsnIe, UINT8 rsnIeLen)
    287 {
    288 
    289     if (pRsnIe != NULL) {
    290             UINT8 length=0, index=0;
    291             pSite->rsnIeLen = rsnIeLen;
    292             while ((length < pSite->rsnIeLen) && (index<MAX_RSN_IE)){
    293                 pSite->pRsnIe[index].hdr = pRsnIe->hdr;
    294                 os_memoryCopy(pSiteMgr->hOs, pSite->pRsnIe[index].rsnIeData, pRsnIe->rsnIeData, pRsnIe->hdr.eleLen);
    295                 length += (pRsnIe->hdr.eleLen+2);
    296                 pRsnIe += 1;
    297                 index++;}
    298         }
    299         else {pSite->rsnIeLen = 0;}
    300 }*/
    301 /************************************************************************
    302  *                        siteMgr_create                                *
    303  ************************************************************************
    304 DESCRIPTION: Site manager module creation function, called by the config mgr in creation phase
    305                 performs the following:
    306                 -   Allocate the site manager handle
    307                 -   Allocate the desired & mgmt params structure
    308 
    309 INPUT:      hOs             -   Handle to OS
    310 
    311 
    312 OUTPUT:
    313 
    314 
    315 RETURN:     Handle to the site manager module on success, NULL otherwise
    316 ************************************************************************/
    317 TI_HANDLE siteMgr_create(TI_HANDLE hOs)
    318 {
    319     siteMgr_t       *pSiteMgr;
    320     UINT32          initVec;
    321 
    322     initVec = 0;
    323 
    324     pSiteMgr = os_memoryAlloc(hOs, sizeof(siteMgr_t));
    325     if (pSiteMgr == NULL)
    326         return NULL;
    327 
    328     os_memoryZero(hOs, pSiteMgr, sizeof(siteMgr_t));
    329 
    330     initVec |= (1 << SITE_MGR_INIT_BIT);
    331 
    332     pSiteMgr->pDesiredParams = os_memoryAlloc(hOs, sizeof(siteMgrInitParams_t));
    333     if (pSiteMgr->pDesiredParams == NULL)
    334     {
    335         release_module(pSiteMgr, initVec);
    336         return NULL;
    337     }
    338 
    339     initVec |= (1 << DESIRED_PARAMS_INIT_BIT);
    340 
    341     pSiteMgr->pSitesMgmtParams = os_memoryAlloc(hOs, sizeof(sitesMgmtParams_t));
    342     if (pSiteMgr->pSitesMgmtParams == NULL)
    343     {
    344         release_module(pSiteMgr, initVec);
    345         return NULL;
    346     }
    347 
    348     initVec |= (1 << MGMT_PARAMS_INIT_BIT);
    349 
    350     pSiteMgr->hOs = hOs;
    351 
    352     return(pSiteMgr);
    353 }
    354 
    355 
    356 
    357 /************************************************************************
    358  *                        siteMgr_config                                    *
    359  ************************************************************************
    360 DESCRIPTION: Site manager module configuration function, called by the config mgr in configuration phase
    361                 performs the following:
    362                 -   Reset & initiailzes local variables
    363                 -   Init the handles to be used by the module
    364 
    365 INPUT:      hSiteMgr    -   site manager handle
    366             List of handles to be used by the module
    367             pSiteMgrInitParams  -   Init table of the module, contains the following:
    368                 -   Parameters read from registry
    369                 -   Chip parameters
    370 
    371 
    372 OUTPUT:
    373 
    374 RETURN:     OK on success, NOK otherwise
    375 
    376 ************************************************************************/
    377 TI_STATUS siteMgr_config(   TI_HANDLE       hSiteMgr,
    378                         TI_HANDLE       hConn,
    379                         TI_HANDLE       hSmeSm,
    380                         TI_HANDLE       hCtrlData,
    381                         TI_HANDLE       hRxData,
    382                         TI_HANDLE       hTxData,
    383                         TI_HANDLE       hRsn,
    384                         TI_HANDLE       hAuth,
    385                         TI_HANDLE       hAssoc,
    386                         TI_HANDLE       hHalCtrl,
    387                         TI_HANDLE       hMlmeSm,
    388                         TI_HANDLE       hRegulatoryDomain,
    389                         TI_HANDLE       hMeasurementMgr,
    390                         TI_HANDLE       hApConn,
    391                         TI_HANDLE       hCurrBss,
    392                         TI_HANDLE       hReport,
    393                         TI_HANDLE       hOs ,
    394                         TI_HANDLE       hExcMngr,
    395                         TI_HANDLE       hQosMngr,
    396                         TI_HANDLE       thePowerMgrHandle,
    397                         TI_HANDLE       hScr,
    398                         TI_HANDLE       hEvHandler,
    399                         TI_HANDLE       hMacServices,
    400                         siteMgrInitParams_t     *pSiteMgrInitParams)
    401 {
    402     siteMgr_t       *pSiteMgr = (siteMgr_t *)hSiteMgr;
    403     UINT32          timestamp;
    404     slotTime_e      slotTime;
    405     paramInfo_t     saParam;
    406     TI_STATUS       status;
    407 
    408     /* Init handles */
    409     pSiteMgr->hConn                 = hConn;
    410     pSiteMgr->hSmeSm                = hSmeSm;
    411     pSiteMgr->hHalCtrl              = hHalCtrl;
    412     pSiteMgr->hCtrlData             = hCtrlData;
    413     pSiteMgr->hRxData               = hRxData;
    414     pSiteMgr->hTxData               = hTxData;
    415     pSiteMgr->hRsn                  = hRsn;
    416     pSiteMgr->hAuth                 = hAuth;
    417     pSiteMgr->hAssoc                = hAssoc;
    418     pSiteMgr->hRegulatoryDomain     = hRegulatoryDomain;
    419     pSiteMgr->hMeasurementMgr       = hMeasurementMgr;
    420     pSiteMgr->hReport               = hReport;
    421     pSiteMgr->hOs                   = hOs;
    422     pSiteMgr->hMlmeSm               = hMlmeSm;
    423     pSiteMgr->hAssoc                = hAssoc;
    424     pSiteMgr->hReport               = hReport;
    425     pSiteMgr->hExcMngr              = hExcMngr;
    426     pSiteMgr->hApConn               = hApConn;
    427     pSiteMgr->hCurrBss              = hCurrBss;
    428     pSiteMgr->hQosMngr              = hQosMngr;
    429     pSiteMgr->hPowerMgr             = thePowerMgrHandle;
    430     pSiteMgr->hScr                  = hScr;
    431     pSiteMgr->hEvHandler            = hEvHandler;
    432     pSiteMgr->hMacServices          = hMacServices;
    433 
    434 	/* Reset counter for Tx Power Control adjustment */
    435     pSiteMgr->siteMgrTxPowerCheckTime   = 0;
    436 
    437     /* Init desired parameters */
    438     os_memoryCopy(hOs, pSiteMgr->pDesiredParams, pSiteMgrInitParams, sizeof(siteMgrInitParams_t));
    439 
    440     /* Init Beacon Filter Desired State */
    441     pSiteMgr->beaconFilterParams.desiredState = pSiteMgrInitParams->beaconFilterParams.desiredState;
    442     /* Init Beacon Filter numOfStored parameter */
    443     pSiteMgr->beaconFilterParams.numOfStored = pSiteMgrInitParams->beaconFilterParams.numOfStored;
    444 
    445     /* Init management params */
    446     pSiteMgr->pSitesMgmtParams->dot11A_sitesTables.maxNumOfSites = MAX_SITES_A_BAND;
    447     siteMgr_resetSiteTable(pSiteMgr,(siteTablesParams_t *)&pSiteMgr->pSitesMgmtParams->dot11A_sitesTables);
    448     pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables.maxNumOfSites = MAX_SITES_BG_BAND;
    449     siteMgr_resetSiteTable(pSiteMgr,&pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables);
    450 
    451     /* calculate random BSSID for usage in IBSS */
    452     timestamp = os_timeStampMs(pSiteMgr->hOs);
    453     os_memoryCopy(pSiteMgr->hOs, (void *)&(pSiteMgr->ibssBssid.addr[0]), &timestamp, sizeof(UINT32));
    454     pSiteMgr->ibssBssid.addr[0] = 0x00;
    455     timestamp = os_timeStampMs(pSiteMgr->hOs);
    456     os_memoryCopy(pSiteMgr->hOs, (void *)&(pSiteMgr->ibssBssid.addr[2]), &timestamp, sizeof(UINT32));
    457 
    458     /* Get the Source MAC address in order to use it for AD-Hoc BSSID, solving Conexant ST issue for WiFi test */
    459     saParam.paramType = CTRL_DATA_MAC_ADDRESS;
    460     status = ctrlData_getParam(hCtrlData, &saParam);
    461     if (status != OK)
    462     {
    463         WLAN_OS_REPORT(("\n ERROR !!! : siteMgr_config - Error in getting MAC address\n" ));
    464         return NOK;
    465     }
    466     pSiteMgr->ibssBssid.addr[0] = 0x02;
    467     pSiteMgr->ibssBssid.addr[1] = saParam.content.ctrlDataDeviceMacAddress.addr[1];
    468     pSiteMgr->ibssBssid.addr[2] = saParam.content.ctrlDataDeviceMacAddress.addr[2];
    469 
    470     pSiteMgr->keepAliveEnable = pSiteMgrInitParams->siteMgrDesiredkeepAliveEnable;
    471     pSiteMgr->numOfBeaconFiltering = DEAFULT_BEACON_FILTERING_NUM;
    472 
    473     switch(pSiteMgr->pDesiredParams->siteMgrRadioValues.siteMgr_radioType)
    474     {
    475     case MAXIM:
    476     pSiteMgr->pDesiredParams->siteMgrRadioValues.pSiteMgr_selectedRadioValues =
    477         &pSiteMgr->pDesiredParams->siteMgrRadioValues.siteMgr_maximRadioValues;
    478     pSiteMgr->pDesiredParams->siteMgrSupportedBand = RADIO_BAND_2_4_GHZ;
    479        WLAN_REPORT_INIT(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("MAXIM  !!! \n"));
    480 
    481         break;
    482 
    483     case RFMD:
    484         pSiteMgr->pDesiredParams->siteMgrRadioValues.pSiteMgr_selectedRadioValues =
    485             &pSiteMgr->pDesiredParams->siteMgrRadioValues.siteMgr_rfmdRadioValues;
    486         pSiteMgr->pDesiredParams->siteMgrSupportedBand = RADIO_BAND_2_4_GHZ;
    487         WLAN_REPORT_INIT(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("RFMD  !!! \n"));
    488         break;
    489 
    490     case RADIA_BG:
    491     pSiteMgr->pDesiredParams->siteMgrRadioValues.pSiteMgr_selectedRadioValues =
    492         &pSiteMgr->pDesiredParams->siteMgrRadioValues.siteMgr_radiaRadioValues;
    493     pSiteMgr->pDesiredParams->siteMgrSupportedBand = RADIO_BAND_2_4_GHZ;
    494        WLAN_REPORT_INIT(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("RADIA bg  !!! \n"));
    495        break;
    496 
    497     case RADIA_ABG:
    498     pSiteMgr->pDesiredParams->siteMgrRadioValues.pSiteMgr_selectedRadioValues =
    499         &pSiteMgr->pDesiredParams->siteMgrRadioValues.siteMgr_radiaRadioValues;
    500     pSiteMgr->pDesiredParams->siteMgrSupportedBand = RADIO_BAND_DUAL;
    501     WLAN_REPORT_INIT(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("RADIA abg  !!! \n"));
    502 
    503         break;
    504 
    505     default:
    506     pSiteMgr->pDesiredParams->siteMgrRadioValues.pSiteMgr_selectedRadioValues = NULL;
    507     WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
    508                     ("!!!.....UnKnown Radio Type !!!\n"));
    509     }
    510 
    511     pSiteMgr->beaconSentCount = 0;
    512     pSiteMgr->pDesiredParams->siteMgrDesiredAtimWindow = 0;
    513 
    514     if(pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode == DOT11_DUAL_MODE)
    515     {
    516        if(pSiteMgr->pDesiredParams->siteMgrSupportedBand == RADIO_BAND_DUAL)
    517        {
    518            pSiteMgr->siteMgrOperationalMode = DOT11_G_MODE;
    519            pSiteMgr->radioBand = RADIO_BAND_2_4_GHZ;
    520            slotTime = pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime;
    521            pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
    522        }
    523        else if(pSiteMgr->pDesiredParams->siteMgrSupportedBand == RADIO_BAND_2_4_GHZ)
    524        {
    525            pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode = DOT11_G_MODE;
    526            pSiteMgr->siteMgrOperationalMode = DOT11_G_MODE;
    527            pSiteMgr->radioBand = RADIO_BAND_2_4_GHZ;
    528            slotTime = pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime;
    529            pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
    530        }
    531        else
    532        {
    533            pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode = DOT11_A_MODE;
    534            pSiteMgr->siteMgrOperationalMode = DOT11_A_MODE;
    535            pSiteMgr->radioBand = RADIO_BAND_5_0_GHZ;
    536            slotTime = PHY_SLOT_TIME_SHORT;
    537            pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = (siteTablesParams_t *)&pSiteMgr->pSitesMgmtParams->dot11A_sitesTables;
    538        }
    539     }
    540     else if(pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode == DOT11_G_MODE)
    541     {
    542         slotTime = pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime;
    543         pSiteMgr->radioBand = RADIO_BAND_2_4_GHZ;
    544         if((pSiteMgr->pDesiredParams->siteMgrSupportedBand == RADIO_BAND_DUAL) ||
    545            (pSiteMgr->pDesiredParams->siteMgrSupportedBand == RADIO_BAND_2_4_GHZ))
    546         {
    547             pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
    548             pSiteMgr->siteMgrOperationalMode = pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode;
    549 
    550         }
    551         else
    552         {
    553             WLAN_OS_REPORT(("\nERROR !!!.....The radio doesn't support the desired dot11 mode !!! \n"));
    554             return NOK;
    555         }
    556     }
    557     else if(pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode == DOT11_B_MODE)
    558     {
    559         slotTime = PHY_SLOT_TIME_LONG;
    560         pSiteMgr->radioBand = RADIO_BAND_2_4_GHZ;
    561         if((pSiteMgr->pDesiredParams->siteMgrSupportedBand == RADIO_BAND_DUAL) ||
    562            (pSiteMgr->pDesiredParams->siteMgrSupportedBand == RADIO_BAND_2_4_GHZ))
    563         {
    564             pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
    565             pSiteMgr->siteMgrOperationalMode = pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode;
    566         }
    567         else
    568         {
    569             WLAN_OS_REPORT(("\nERROR !!!.....The radio doesn't support the desired dot11 mode !!! \n"));
    570             return NOK;
    571         }
    572     }
    573     else
    574     {
    575         slotTime = PHY_SLOT_TIME_SHORT;
    576         pSiteMgr->radioBand = RADIO_BAND_5_0_GHZ;
    577         if((pSiteMgr->pDesiredParams->siteMgrSupportedBand == RADIO_BAND_DUAL) ||
    578            (pSiteMgr->pDesiredParams->siteMgrSupportedBand == RADIO_BAND_5_0_GHZ))
    579         {
    580             pSiteMgr->siteMgrOperationalMode = pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode;
    581             pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = (siteTablesParams_t *)&pSiteMgr->pSitesMgmtParams->dot11A_sitesTables;
    582         }
    583         else
    584         {
    585             WLAN_OS_REPORT(("\nERROR !!!.....The radio doesn't support the desired dot11 mode !!! \n"));
    586             return NOK;
    587         }
    588     }
    589 
    590 
    591     /* configure hal with common core-hal parameters */
    592     whalCtrl_SetRadioBand(pSiteMgr->hHalCtrl, pSiteMgr->radioBand);
    593     whalCtrl_SetSlotTime(pSiteMgr->hHalCtrl, slotTime);
    594     siteMgr_ConfigRate(hSiteMgr);
    595 
    596     WLAN_REPORT_INIT(hReport, SITE_MGR_MODULE_LOG,
    597         (" SiteMgr - numOfElements = %d IETableSize = %d\n" , pSiteMgrInitParams->beaconFilterParams.numOfElements, pSiteMgrInitParams->beaconFilterParams.IETableSize)) ;
    598     /*send the table regardless to the state*/
    599     whalCtrl_SetBeaconFilterIETable(pSiteMgr->hHalCtrl ,(UINT8 *)&(pSiteMgrInitParams->beaconFilterParams.numOfElements), (UINT8 *)&(pSiteMgrInitParams->beaconFilterParams.IETable[0]) , (UINT8 *)&(pSiteMgrInitParams->beaconFilterParams.IETableSize)) ;
    600 
    601     /*  At start-up Set the Beacon Filter state as the User required */
    602     whalCtrl_SetBeaconFiltering(pSiteMgr->hHalCtrl, pSiteMgrInitParams->beaconFilterParams.desiredState, pSiteMgr->beaconFilterParams.numOfStored);
    603 
    604     pSiteMgr->pSitesMgmtParams->pPrevPrimarySite = NULL;
    605 
    606     pSiteMgr->powerSaveLdMode = FALSE;
    607 
    608     WLAN_REPORT_INIT(hReport, SITE_MGR_MODULE_LOG,  (".....Site manager configured successfully\n"));
    609 
    610     return OK;
    611 }
    612 
    613 
    614 /************************************************************************
    615  *                        siteMgr_unLoad                                    *
    616  ************************************************************************
    617 DESCRIPTION: site manager module unload function, called by the config mgr in the unlod phase
    618                 performs the following:
    619                 -   Free all memory aloocated by the module
    620 
    621 INPUT:      hSiteMgr    -   site mgr handle.
    622 
    623 
    624 OUTPUT:
    625 
    626 RETURN:     OK on success, NOK otherwise
    627 
    628 ************************************************************************/
    629 TI_STATUS siteMgr_unLoad(TI_HANDLE hSiteMgr)
    630 {
    631     UINT32          initVec;
    632     siteMgr_t       *pSiteMgr = (siteMgr_t *)hSiteMgr;
    633 
    634     if (!pSiteMgr)
    635         return OK;
    636 
    637     initVec = 0xFFFF;
    638     release_module(pSiteMgr, initVec);
    639 
    640     return OK;
    641 }
    642 
    643 /***********************************************************************
    644  *                        siteMgr_setParam
    645  ***********************************************************************
    646 DESCRIPTION: site mgr set param function, called by the following:
    647                 -   config mgr in order to set a parameter from the OS abstraction layer.
    648                 In this fuction, the site manager OS abstraction layer configures the site manager to the desired params.
    649                 Sometimes it requires a re scan, depending in the parameter type
    650 
    651 INPUT:      hSiteMgr    -   Connection handle.
    652             pParam  -   Pointer to the parameter
    653 
    654 OUTPUT:
    655 
    656 RETURN:     RE_SCAN_NEEDED if re scan needed, OK on success, NOK on failure
    657 
    658 ************************************************************************/
    659 
    660 TI_STATUS siteMgr_setParam(TI_HANDLE        hSiteMgr,
    661                         paramInfo_t     *pParam)
    662 {
    663     siteMgr_t *pSiteMgr = (siteMgr_t *)hSiteMgr;
    664     siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
    665     OS_802_11_CONFIGURATION *pConfig;
    666     UINT32      channel;
    667     slotTime_e  slotTime;
    668 
    669     switch(pParam->paramType)
    670     {
    671     case SITE_MGR_CONFIGURATION_PARAM:
    672         pConfig = pParam->content.pSiteMgrConfiguration;
    673 
    674 /*      for(channel = 0; channel < SITE_MGR_CHANNEL_MAX+1; channel++)
    675         {
    676             if(pConfig->channel == pSiteMgr->pDesiredParams->siteMgrFreq2ChannelTable[channel])
    677                 break;
    678         }*/
    679 
    680         channel = Freq2Chan(pConfig->Union.channel);
    681 
    682         if(channel == 0 || channel > SITE_MGR_CHANNEL_MAX)
    683             return PARAM_VALUE_NOT_VALID;
    684         else
    685             pConfig->Union.channel = channel;
    686 
    687         if((pSiteMgr->pDesiredParams->siteMgrDesiredChannel != pConfig->Union.channel) ||
    688            (pSiteMgr->pDesiredParams->siteMgrDesiredChannel != pConfig->Union.channel) ||
    689            (pSiteMgr->pDesiredParams->siteMgrDesiredAtimWindow != pConfig->ATIMWindow))
    690         {
    691             pSiteMgr->pDesiredParams->siteMgrDesiredChannel = (UINT8)pConfig->Union.channel;
    692             pSiteMgr->pDesiredParams->siteMgrDesiredBeaconInterval = (UINT16)pConfig->BeaconPeriod;
    693             pSiteMgr->pDesiredParams->siteMgrDesiredAtimWindow = pConfig->ATIMWindow;
    694         }
    695 
    696         return OK;
    697 
    698     case SITE_MGR_DESIRED_CHANNEL_PARAM:
    699         if (pParam->content.siteMgrDesiredChannel > SITE_MGR_CHANNEL_MAX)
    700             return PARAM_VALUE_NOT_VALID;
    701 
    702         if (pSiteMgr->pDesiredParams->siteMgrDesiredChannel != pParam->content.siteMgrDesiredChannel)
    703             pSiteMgr->pDesiredParams->siteMgrDesiredChannel = (UINT8)pParam->content.siteMgrDesiredChannel;
    704         return OK;
    705 
    706     case SITE_MGR_DESIRED_BSSID_PARAM:
    707             os_memoryCopy(pSiteMgr->hOs, (void *)pSiteMgr->pDesiredParams->siteMgrDesiredBSSID.addr, (void *)pParam->content.siteMgrDesiredBSSID.addr, sizeof(macAddress_t));
    708 #if 0
    709             WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Set BSSID = 0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x \n",
    710                                                                               pSiteMgr->pDesiredParams->siteMgrDesiredBSSID.addr[0],
    711                                                                               pSiteMgr->pDesiredParams->siteMgrDesiredBSSID.addr[1],
    712                                                                               pSiteMgr->pDesiredParams->siteMgrDesiredBSSID.addr[2],
    713                                                                               pSiteMgr->pDesiredParams->siteMgrDesiredBSSID.addr[3],
    714                                                                               pSiteMgr->pDesiredParams->siteMgrDesiredBSSID.addr[4],
    715                                                                               pSiteMgr->pDesiredParams->siteMgrDesiredBSSID.addr[5]));
    716 #endif
    717            return OK;
    718 
    719 
    720 
    721     case SITE_MGR_DESIRED_SSID_PARAM:
    722 
    723         WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
    724                                 ("\nSet new SSID=%s (len=%d)  \n",
    725                                  pParam->content.siteMgrDesiredSSID.ssidString,
    726                                  pParam->content.siteMgrDesiredSSID.len));
    727 
    728         if (pParam->content.siteMgrDesiredSSID.len > MAX_SSID_LEN)
    729             return PARAM_VALUE_NOT_VALID;
    730 
    731         os_memoryCopy(pSiteMgr->hOs, &pSiteMgr->pDesiredParams->siteMgrDesiredSSID, &pParam->content.siteMgrDesiredSSID, sizeof(ssid_t));
    732         /* 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
    733            TODO: another byte must be added, and the alignment change MUST be tested (esp. in CLI commands with ssid_t */
    734         if ( MAX_SSID_LEN > pSiteMgr->pDesiredParams->siteMgrDesiredSSID.len )
    735         {
    736             pSiteMgr->pDesiredParams->siteMgrDesiredSSID.ssidString[pSiteMgr->pDesiredParams->siteMgrDesiredSSID.len] = '\0';
    737         }
    738 
    739         /* increase the random IBSS BSSID calculated during init */
    740         pSiteMgr->ibssBssid.addr[MAC_ADDR_LEN - 1] ++;
    741 
    742         if (utils_isJunkSSID(&pSiteMgr->pDesiredParams->siteMgrDesiredSSID))
    743         {
    744             rsn_removedDefKeys(pSiteMgr->hRsn);
    745         }
    746         return RE_SCAN_NEEDED;
    747 
    748 
    749     case SITE_MGR_DESIRED_BSS_TYPE_PARAM:
    750          WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
    751                                 ("\nSet BssType = %d\n", pParam->content.siteMgrDesiredBSSType));
    752         if (pParam->content.siteMgrDesiredBSSType > BSS_ANY)
    753             return PARAM_VALUE_NOT_VALID;
    754 
    755         if (pSiteMgr->pDesiredParams->siteMgrDesiredBSSType != pParam->content.siteMgrDesiredBSSType)
    756         {
    757             pSiteMgr->pDesiredParams->siteMgrDesiredBSSType = pParam->content.siteMgrDesiredBSSType;
    758 
    759 			/* If the new BSS type is NOT Ad_Hoc, We make sure that the rate masks are set to G */
    760 			 if(pSiteMgr->pDesiredParams->siteMgrDesiredBSSType != BSS_INDEPENDENT)
    761 
    762             {
    763 				 pSiteMgr->siteMgrOperationalMode = DOT11_G_MODE;
    764                  siteMgr_ConfigRate(pSiteMgr);
    765             }
    766 
    767             /* If the new BSS type is Ad_Hoc, increase the random BSSID calculated during init */
    768             if(pSiteMgr->pDesiredParams->siteMgrDesiredBSSType == BSS_INDEPENDENT)
    769             {
    770                 pSiteMgr->ibssBssid.addr[MAC_ADDR_LEN - 1] ++;
    771             }
    772 
    773             /* go to B_ONLY Mode only if WiFI bit is Set*/
    774             if (pSiteMgr->pDesiredParams->siteMgrWiFiAdhoc == TRUE)
    775             {   /* Configuration For AdHoc when using external configuration */
    776                 if(pSiteMgr->pDesiredParams->siteMgrExternalConfiguration == FALSE)
    777                 {
    778                     siteMgr_externalConfigurationParametersSet(hSiteMgr);
    779                 }
    780             }
    781         }
    782 
    783         return OK;
    784 
    785     case SITE_MGR_DESIRED_MODULATION_TYPE_PARAM:
    786         if ((pParam->content.siteMgrDesiredModulationType < DRV_MODULATION_CCK) ||
    787             (pParam->content.siteMgrDesiredModulationType > DRV_MODULATION_OFDM))
    788             return PARAM_VALUE_NOT_VALID;
    789 
    790         if (pSiteMgr->pDesiredParams->siteMgrDesiredModulationType != pParam->content.siteMgrDesiredModulationType)
    791         {
    792             pSiteMgr->pDesiredParams->siteMgrDesiredModulationType = pParam->content.siteMgrDesiredModulationType;
    793             /* means that we are moving from non-pbcc network to pbcc */
    794             if (pParam->content.siteMgrDesiredModulationType == DRV_MODULATION_PBCC)
    795                 return RE_SCAN_NEEDED;
    796             return OK;
    797         }
    798         return OK;
    799 
    800     case SITE_MGR_BEACON_RECV:
    801         if (!pPrimarySite)
    802         {
    803             return NO_SITE_SELECTED_YET;
    804         }
    805         pPrimarySite->beaconRecv = pParam->content.siteMgrBeaconRecv;
    806         return OK;
    807 
    808 
    809     case SITE_MGR_DESIRED_BEACON_INTERVAL_PARAM:
    810         if (pParam->content.siteMgrDesiredBeaconInterval < SITE_MGR_BEACON_INTERVAL_MIN)
    811             return PARAM_VALUE_NOT_VALID;
    812 
    813         if (pSiteMgr->pDesiredParams->siteMgrDesiredBeaconInterval != pParam->content.siteMgrDesiredBeaconInterval)
    814             pSiteMgr->pDesiredParams->siteMgrDesiredBeaconInterval = pParam->content.siteMgrDesiredBeaconInterval;
    815         return OK;
    816 
    817     case SITE_MGR_DESIRED_PREAMBLE_TYPE_PARAM:
    818         if ((pParam->content.siteMgrDesiredPreambleType != PREAMBLE_LONG) &&
    819             (pParam->content.siteMgrDesiredPreambleType != PREAMBLE_SHORT))
    820             return PARAM_VALUE_NOT_VALID;
    821 
    822         if (pSiteMgr->pDesiredParams->siteMgrDesiredPreambleType != pParam->content.siteMgrDesiredPreambleType)
    823         {
    824             pSiteMgr->pDesiredParams->siteMgrDesiredPreambleType = pParam->content.siteMgrDesiredPreambleType;
    825         }
    826         return OK;
    827 
    828     case SITE_MGR_DESIRED_SUPPORTED_RATE_SET_PARAM:
    829         return setSupportedRateSet(pSiteMgr, &(pParam->content.siteMgrDesiredSupportedRateSet));
    830 
    831     case SITE_MGR_DESIRED_DOT11_MODE_PARAM:
    832         if(pParam->content.siteMgrDot11Mode > DOT11_MAX_MODE)
    833             return PARAM_VALUE_NOT_VALID;
    834 
    835         if(pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode != pParam->content.siteMgrDot11Mode)
    836         {
    837             pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode = pParam->content.siteMgrDot11Mode;
    838 
    839             /* since the dot11ABAmode changed, the STA operational mode should be changed */
    840             if(pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode == DOT11_DUAL_MODE)
    841             {
    842                 if(pSiteMgr->pDesiredParams->siteMgrSupportedBand == RADIO_BAND_DUAL)
    843                 {
    844                     pSiteMgr->siteMgrOperationalMode = DOT11_G_MODE;
    845                 }
    846                 else if(pSiteMgr->pDesiredParams->siteMgrSupportedBand == RADIO_BAND_2_4_GHZ)
    847                 {
    848                     pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode = DOT11_G_MODE;
    849                     pSiteMgr->siteMgrOperationalMode = DOT11_G_MODE;
    850                 }
    851                 else
    852                 {
    853                     pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode = DOT11_G_MODE;
    854                     pSiteMgr->siteMgrOperationalMode = DOT11_A_MODE;
    855                 }
    856 
    857             }
    858             else
    859                 pSiteMgr->siteMgrOperationalMode = pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode;
    860 
    861             /* configure HAL with new parameters update rates and select site table */
    862             pSiteMgr->prevRadioBand = pSiteMgr->radioBand;
    863             if(pSiteMgr->siteMgrOperationalMode == DOT11_A_MODE)
    864             {
    865                 pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = (siteTablesParams_t *)&pSiteMgr->pSitesMgmtParams->dot11A_sitesTables;
    866                 pSiteMgr->radioBand = RADIO_BAND_5_0_GHZ;
    867                 slotTime = PHY_SLOT_TIME_SHORT;
    868             }
    869             else if(pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE)
    870             {
    871                 pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
    872                 pSiteMgr->radioBand = RADIO_BAND_2_4_GHZ;
    873                 slotTime = pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime;
    874             }
    875             else
    876             {
    877                 pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
    878                 pSiteMgr->radioBand = RADIO_BAND_2_4_GHZ;
    879                 slotTime = PHY_SLOT_TIME_LONG;
    880             }
    881 
    882             if(pSiteMgr->prevRadioBand != pSiteMgr->radioBand)
    883                 siteMgr_bandParamsConfig(pSiteMgr, TRUE);
    884 
    885             /* configure HAL */
    886             whalCtrl_SetRadioBand(pSiteMgr->hHalCtrl, pSiteMgr->radioBand);
    887             whalCtrl_SetSlotTime(pSiteMgr->hHalCtrl, slotTime);
    888 
    889             /* If the BSS type is Ad_Hoc, increase the random BSSID calculated during init */
    890             if(pSiteMgr->pDesiredParams->siteMgrDesiredBSSType == BSS_INDEPENDENT)
    891             {
    892                 pSiteMgr->ibssBssid.addr[MAC_ADDR_LEN - 1] ++;
    893             }
    894 
    895             /*siteMgr_resetAllSiteTables(pSiteMgr); */
    896             return RE_SCAN_NEEDED;
    897         }
    898         return OK;
    899 
    900     case SITE_MGR_OPERATIONAL_MODE_PARAM:
    901 
    902         if(pParam->content.siteMgrDot11OperationalMode < DOT11_B_MODE ||
    903             pParam->content.siteMgrDot11OperationalMode > DOT11_G_MODE )
    904             return PARAM_VALUE_NOT_VALID;
    905 
    906         pSiteMgr->siteMgrOperationalMode = pParam->content.siteMgrDot11OperationalMode;
    907         break;
    908 
    909 
    910     case SITE_MGR_USE_DRAFT_NUM_PARAM:
    911         if(pParam->content.siteMgrUseDraftNum != DRAFT_5_AND_EARLIER &&
    912            pParam->content.siteMgrUseDraftNum != DRAFT_6_AND_LATER)
    913             return PARAM_VALUE_NOT_VALID;
    914 
    915         if(pSiteMgr->pDesiredParams->siteMgrUseDraftNum != pParam->content.siteMgrUseDraftNum)
    916         {
    917             pSiteMgr->pDesiredParams->siteMgrUseDraftNum = pParam->content.siteMgrUseDraftNum;
    918             return RE_SCAN_NEEDED;
    919         }
    920         return OK;
    921 
    922     case SITE_MGR_RADIO_BAND_PARAM:
    923         if((INT8)pParam->content.siteMgrRadioBand < RADIO_BAND_2_4_GHZ ||
    924            (INT8)pParam->content.siteMgrRadioBand > RADIO_BAND_DUAL )
    925             return PARAM_VALUE_NOT_VALID;
    926 
    927         pSiteMgr->prevRadioBand = pSiteMgr->radioBand;
    928         pSiteMgr->radioBand = pParam->content.siteMgrRadioBand;
    929         if(pSiteMgr->prevRadioBand != pSiteMgr->radioBand)
    930             siteMgr_bandParamsConfig(pSiteMgr, FALSE);
    931 
    932         break;
    933 
    934     case SITE_MGR_DESIRED_SLOT_TIME_PARAM:
    935         if(pParam->content.siteMgrSlotTime != PHY_SLOT_TIME_LONG &&
    936            pParam->content.siteMgrSlotTime != PHY_SLOT_TIME_SHORT)
    937             return PARAM_VALUE_NOT_VALID;
    938 
    939         if(pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime != pParam->content.siteMgrSlotTime)
    940         {
    941             if(pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE)
    942             {
    943                 pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime = pParam->content.siteMgrSlotTime;
    944                 if(!pPrimarySite)
    945                     whalCtrl_SetSlotTime(pSiteMgr->hHalCtrl, pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime);
    946                 else if(pPrimarySite->bssType != BSS_INFRASTRUCTURE)
    947                     whalCtrl_SetSlotTime(pSiteMgr->hHalCtrl, pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime);
    948             }
    949 
    950         }
    951         return OK;
    952 
    953     case SITE_MGR_BEACON_FILTER_DESIRED_STATE_PARAM:
    954         {
    955             int desiredStateBeforeChange = pSiteMgr->beaconFilterParams.desiredState;
    956 
    957             /* Set the New Desired User request of Beacon Filter */
    958             pSiteMgr->beaconFilterParams.desiredState = pParam->content.siteMgrDesiredBeaconFilterState;
    959 
    960             /* Check if the Desired  mode has changed - If not no need to send the MIB to the FW */
    961             if ( pSiteMgr->beaconFilterParams.desiredState == desiredStateBeforeChange )
    962             {
    963                 WLAN_REPORT_DEBUG_CONTROL(pSiteMgr->hReport,
    964                     ("Beacon Filter already %s" , (TRUE == desiredStateBeforeChange)? "ENABLED":"DISABLED" ) );
    965                 break;
    966             }
    967 
    968             WLAN_REPORT_DEBUG_CONTROL(pSiteMgr->hReport,
    969                 ("\n New   Beacon Filter Desired State is : %s pSiteMgr->beaconFilterParams.currentState %s\n" , ( TRUE == (pSiteMgr->beaconFilterParams.desiredState) )?"ENABLED":"DISABLED",( TRUE == (pSiteMgr->beaconFilterParams.currentState) )?"ENABLED":"DISABLED"));
    970 
    971 
    972             /* Check if the new Desired state is TRUE then Also check the Current State and then if FALSEdo not send the MIB to FW*/
    973             if ( (TRUE == pSiteMgr->beaconFilterParams.desiredState ) && (FALSE == pSiteMgr->beaconFilterParams.currentState ))
    974             {
    975                 WLAN_REPORT_DEBUG_CONTROL(pSiteMgr->hReport,
    976                     ("\n New   Beacon Filter Desired State is TRUE But Current State is DISABLED So the MIBwill be sent Later !!!!"));
    977 
    978             }
    979             /* In any other cases the User required Beacon Filter Configuration will be sent to FW immediately */
    980             else
    981             {
    982                 WLAN_REPORT_DEBUG_CONTROL(pSiteMgr->hReport,
    983                     ("\n New   Sending  Beacon Filter Desired State To FW !!!!"));
    984 
    985                 whalCtrl_SetBeaconFiltering(pSiteMgr->hHalCtrl, pSiteMgr->beaconFilterParams.desiredState, pSiteMgr->beaconFilterParams.numOfStored);
    986             }
    987 
    988 
    989         }
    990 
    991         break;
    992 
    993     case SITE_MGR_DISASSOCIATE_PARAM:
    994     case SITE_MGR_DEAUTHENTICATE_PARAM:
    995         if(!pPrimarySite)
    996             return OK;
    997 
    998         else { /* Set Junk SSID */
    999             pSiteMgr->pDesiredParams->siteMgrDesiredSSID.len = 4;
   1000             pSiteMgr->pDesiredParams->siteMgrDesiredSSID.ssidString[0]=1;
   1001             pSiteMgr->pDesiredParams->siteMgrDesiredSSID.ssidString[1]=1;
   1002             pSiteMgr->pDesiredParams->siteMgrDesiredSSID.ssidString[2]=1;
   1003             pSiteMgr->pDesiredParams->siteMgrDesiredSSID.ssidString[3]=1;
   1004             return RE_SCAN_NEEDED;
   1005         }
   1006 
   1007 
   1008     case SITE_MGR_BSSID_LIST_SCAN_PARAM:
   1009 #if 0
   1010         /* TODO - merge fix from WinCE version (and generalize it if time permits) */
   1011         /* Must return NOK in each case the scan is not actually performed */
   1012         if(!pPrimarySite)
   1013         {
   1014             WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   1015                 ("Not connected to Network => do the BSSID_LIST_SCAN command\n"));
   1016             smeSm_startScan(pSiteMgr->hSmeSm);
   1017         }
   1018 
   1019         param.paramType = RX_DATA_COUNTERS_PARAM;
   1020         rxData_getParam(pSiteMgr->hRxData, &param);
   1021 
   1022         /* get current received data frames counter */
   1023         currRxPacketsCount = param.content.siteMgrTiWlanCounters.DirectedFramesRecv;
   1024 
   1025         if((pSiteMgr->rxPacketsCount + 1) < currRxPacketsCount)
   1026         {
   1027             WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   1028                 ("Traffic is active now => ignoring the BSSID_LIST_SCAN command\n"));
   1029             return NOK;
   1030         }
   1031         else
   1032         {
   1033             WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   1034                 ("Traffic is not active now => do the BSSID_LIST_SCAN command\n"));
   1035             smeSm_startScan(pSiteMgr->hSmeSm);
   1036 
   1037         }
   1038     }
   1039 #endif
   1040         return OK;
   1041 
   1042     case SITE_MGR_LAST_RX_RATE_PARAM:
   1043         if (pPrimarySite != NULL)
   1044         {
   1045             pPrimarySite->rxRate = pParam->content.ctrlDataCurrentBasicRate;
   1046         }
   1047         break;
   1048 
   1049     case SITE_MGR_CURRENT_CHANNEL_PARAM:
   1050         if (!pPrimarySite)
   1051         {
   1052             return NO_SITE_SELECTED_YET;
   1053         }
   1054         pPrimarySite->channel = pParam->content.siteMgrCurrentChannel;
   1055         break;
   1056 
   1057     case SITE_MGR_CURRENT_SIGNAL_PARAM:
   1058         if (!pPrimarySite)
   1059         {
   1060             return NO_SITE_SELECTED_YET;
   1061         }
   1062 
   1063         pPrimarySite->rssi = pParam->content.siteMgrCurrentSignal.rssi;
   1064         break;
   1065 
   1066     default:
   1067         WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, ("Set param, Params is not supported, %d\n", pParam->paramType));
   1068         return PARAM_NOT_SUPPORTED;
   1069     }
   1070 
   1071     return OK;
   1072 }
   1073 
   1074 /***********************************************************************
   1075  *                        siteMgr_getParam
   1076  ***********************************************************************
   1077 DESCRIPTION: Site mgr get param function, called by the following:
   1078             -   config mgr in order to get a parameter from the OS abstraction layer.
   1079             -   From inside the dirver
   1080 
   1081 INPUT:      hSiteMgr    -   site mgr handle.
   1082             pParam  -   Pointer to the parameter
   1083 
   1084 OUTPUT:
   1085 
   1086 RETURN:     OK on success, NOK otherwise
   1087 
   1088 ************************************************************************/
   1089 TI_STATUS siteMgr_getParam(TI_HANDLE        hSiteMgr,
   1090                         paramInfo_t     *pParam)
   1091 {
   1092     siteMgr_t       *pSiteMgr = (siteMgr_t *)hSiteMgr;
   1093     siteEntry_t     *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
   1094     TI_STATUS       status = OK;
   1095     UINT8           siteEntryIndex;
   1096     UINT32          dtimInterval;
   1097     UINT32          delta;
   1098     whalParamInfo_t whalParam;
   1099 
   1100     switch(pParam->paramType)
   1101     {
   1102 
   1103     case SITE_MGR_CONFIGURATION_PARAM:
   1104         pParam->content.pSiteMgrConfiguration->Length = sizeof(OS_802_11_CONFIGURATION);
   1105         pParam->content.pSiteMgrConfiguration->ATIMWindow = pSiteMgr->pDesiredParams->siteMgrDesiredAtimWindow;
   1106         pParam->content.pSiteMgrConfiguration->BeaconPeriod = pSiteMgr->pDesiredParams->siteMgrDesiredBeaconInterval;
   1107         pParam->content.pSiteMgrConfiguration->Union.channel =
   1108             Chan2Freq(pSiteMgr->pDesiredParams->siteMgrDesiredChannel);
   1109             /*pSiteMgr->pDesiredParams->siteMgrFreq2ChannelTable[pSiteMgr->pDesiredParams->siteMgrDesiredChannel];*/
   1110 
   1111         if(pPrimarySite) {
   1112             pParam->content.pSiteMgrConfiguration->FHConfig.DwellTime = pPrimarySite->FHParams.dwellTime;
   1113             pParam->content.pSiteMgrConfiguration->FHConfig.HopPattern = pPrimarySite->FHParams.hopPattern;
   1114             pParam->content.pSiteMgrConfiguration->FHConfig.HopSet = pPrimarySite->FHParams.hopSet;
   1115         }
   1116         else {
   1117             pParam->content.pSiteMgrConfiguration->FHConfig.DwellTime = 0;
   1118             pParam->content.pSiteMgrConfiguration->FHConfig.HopPattern = 0;
   1119             pParam->content.pSiteMgrConfiguration->FHConfig.HopSet = 0;
   1120         }
   1121 
   1122         pParam->content.pSiteMgrConfiguration->FHConfig.Length = sizeof(OS_802_11_CONFIGURATION_FH);
   1123         break;
   1124 
   1125     case SITE_MGR_DESIRED_CHANNEL_PARAM:
   1126         pParam->content.siteMgrDesiredChannel = pSiteMgr->pDesiredParams->siteMgrDesiredChannel;
   1127         break;
   1128 
   1129     case SITE_MGR_DESIRED_BSSID_PARAM:
   1130         os_memoryCopy(pSiteMgr->hOs, &pParam->content.siteMgrDesiredBSSID, &pSiteMgr->pDesiredParams->siteMgrDesiredBSSID, sizeof(macAddress_t));
   1131         break;
   1132 
   1133     case SITE_MGR_DESIRED_SSID_PARAM:
   1134         os_memoryCopy(pSiteMgr->hOs, &pParam->content.siteMgrDesiredSSID, &pSiteMgr->pDesiredParams->siteMgrDesiredSSID, sizeof(ssid_t));
   1135         break;
   1136 
   1137     case SITE_MGR_DESIRED_BSS_TYPE_PARAM:
   1138         pParam->content.siteMgrDesiredBSSType = pSiteMgr->pDesiredParams->siteMgrDesiredBSSType;
   1139         break;
   1140 
   1141     case SITE_MGR_DESIRED_SUPPORTED_RATE_SET_PARAM:
   1142         getSupportedRateSet(pSiteMgr, &(pParam->content.siteMgrDesiredSupportedRateSet));
   1143         break;
   1144 
   1145     case SITE_MGR_DESIRED_MODULATION_TYPE_PARAM:
   1146         pParam->content.siteMgrDesiredModulationType = pSiteMgr->pDesiredParams->siteMgrDesiredModulationType;
   1147         break;
   1148 
   1149     case SITE_MGR_DESIRED_BEACON_INTERVAL_PARAM:
   1150         pParam->content.siteMgrDesiredBeaconInterval = pSiteMgr->pDesiredParams->siteMgrDesiredBeaconInterval;
   1151         break;
   1152 
   1153     case SITE_MGR_DESIRED_PREAMBLE_TYPE_PARAM:
   1154         pParam->content.siteMgrDesiredPreambleType = pSiteMgr->pDesiredParams->siteMgrDesiredPreambleType;
   1155         break;
   1156 
   1157     case SITE_MGR_CURRENT_RADIO_TYPE_PARAM:
   1158         pParam->content.siteMgrRadioType = pSiteMgr->pDesiredParams->siteMgrRadioValues.siteMgr_radioType;
   1159         break;
   1160 
   1161     case SITE_MGR_CURRENT_SIGNAL_PARAM:
   1162         if (!pPrimarySite)
   1163         {
   1164             pParam->content.siteMgrCurrentSignal.rssi = 0;
   1165             pParam->content.siteMgrCurrentSignal.snr = 0;
   1166             return NO_SITE_SELECTED_YET;
   1167         }
   1168 
   1169         pParam->content.siteMgrCurrentSignal.rssi = pPrimarySite->rssi;
   1170         pParam->content.siteMgrCurrentSignal.snr = pPrimarySite->snr;
   1171         break;
   1172 
   1173     case SITE_MGR_POWER_CONSTRAINT_PARAM:
   1174         if (!pPrimarySite)
   1175         {
   1176             pParam->content.powerConstraint = 0;
   1177             return NO_SITE_SELECTED_YET;
   1178         }
   1179         pParam->content.powerConstraint = pPrimarySite->powerConstraint;
   1180         break;
   1181 
   1182 
   1183     case SITE_MGR_DTIM_PERIOD_PARAM:
   1184         if (!pPrimarySite)
   1185         {
   1186             pParam->content.siteMgrDtimPeriod = 0;
   1187             return NO_SITE_SELECTED_YET;
   1188         }
   1189         pParam->content.siteMgrDtimPeriod = pPrimarySite->dtimPeriod;
   1190         break;
   1191 
   1192     case SITE_MGR_BEACON_RECV:
   1193         if (!pPrimarySite)
   1194         {
   1195             pParam->content.siteMgrBeaconRecv = FALSE;
   1196             return NO_SITE_SELECTED_YET;
   1197         }
   1198         pParam->content.siteMgrBeaconRecv = pPrimarySite->beaconRecv;
   1199         break;
   1200 
   1201 
   1202     case SITE_MGR_BEACON_INTERVAL_PARAM:
   1203         if (!pPrimarySite)
   1204         {
   1205             pParam->content.beaconInterval = 0;
   1206             return NO_SITE_SELECTED_YET;
   1207         }
   1208         pParam->content.beaconInterval = pPrimarySite->beaconInterval;
   1209         break;
   1210 
   1211     case SITE_MGR_AP_TX_POWER_PARAM:
   1212         if (!pPrimarySite)
   1213         {
   1214             pParam->content.APTxPower = 0;
   1215             return NO_SITE_SELECTED_YET;
   1216         }
   1217         pParam->content.APTxPower = pPrimarySite->APTxPower;
   1218         break;
   1219 
   1220     case SITE_MGR_SITE_CAPABILITY_PARAM:
   1221         if (!pPrimarySite)
   1222         {
   1223             pParam->content.siteMgrSiteCapability = 0;
   1224             return NO_SITE_SELECTED_YET;
   1225         }
   1226         pParam->content.siteMgrSiteCapability = pPrimarySite->capabilities;
   1227         break;
   1228 
   1229     case SITE_MGR_4X_PARAM:
   1230         if(!pPrimarySite)
   1231             return NO_SITE_SELECTED_YET;
   1232 
   1233         pParam->content.siteMgrFourxParam = pPrimarySite->fourXsupported;
   1234         break;
   1235 
   1236     case SITE_MGR_CURRENT_CHANNEL_PARAM:
   1237         if (!pPrimarySite)
   1238         {
   1239             pParam->content.siteMgrCurrentChannel = 0;
   1240             return NO_SITE_SELECTED_YET;
   1241         }
   1242         pParam->content.siteMgrCurrentChannel = pPrimarySite->channel;
   1243         break;
   1244 
   1245     case SITE_MGR_CURRENT_SSID_PARAM:
   1246         if (!pPrimarySite)
   1247         {
   1248             os_memoryZero(pSiteMgr->hOs, (void *)pParam->content.siteMgrCurrentSSID.ssidString, MAX_SSID_LEN);
   1249             pParam->content.siteMgrCurrentSSID.len = 0;
   1250             return NO_SITE_SELECTED_YET;
   1251         }
   1252         if(pPrimarySite->ssid.len == 0)
   1253             WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, ("siteMgr_getParam: ssid length is zero, while primarySite is selected \n"));
   1254         os_memoryCopy(pSiteMgr->hOs, &pParam->content.siteMgrCurrentSSID, &pPrimarySite->ssid, sizeof(ssid_t));
   1255         break;
   1256 
   1257 
   1258     case SITE_MGR_CURRENT_BSS_TYPE_PARAM:
   1259         if (!pPrimarySite)
   1260         {
   1261             pParam->content.siteMgrCurrentBSSType = pSiteMgr->pDesiredParams->siteMgrDesiredBSSType;
   1262             WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, ("Trying to get current BSS Type while no site is selected\n"));
   1263 
   1264         }
   1265         else{
   1266             pParam->content.siteMgrCurrentBSSType = pPrimarySite->bssType;
   1267         }
   1268 
   1269         break;
   1270 
   1271 
   1272     case SITE_MGR_CURRENT_RATE_PAIR_PARAM:
   1273         if (!pPrimarySite)
   1274         {
   1275             pParam->content.siteMgrCurrentRateMask.basicRateMask = 0;
   1276             pParam->content.siteMgrCurrentRateMask.supportedRateMask = 0;
   1277             return NO_SITE_SELECTED_YET;
   1278         }
   1279         pParam->content.siteMgrCurrentRateMask.basicRateMask = pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask;
   1280         pParam->content.siteMgrCurrentRateMask.supportedRateMask = pSiteMgr->pDesiredParams->siteMgrMatchedSuppRateMask;
   1281         WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   1282                                 ("SITE_MGR: bitmapBasicPrimary= 0x%X,bitMapBasicDesired = 0x%X,bitMapSuppPrimary = 0x%X, bitMapSuppDesired = 0x%X\n",
   1283                                 pPrimarySite->rateMask.basicRateMask,pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask,
   1284                                 pPrimarySite->rateMask.supportedRateMask,pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask));
   1285 
   1286         break;
   1287 
   1288     case SITE_MGR_CURRENT_MODULATION_TYPE_PARAM:
   1289         if (!pPrimarySite)
   1290         {
   1291             pParam->content.siteMgrCurrentModulationType = DRV_MODULATION_NONE;
   1292             return NO_SITE_SELECTED_YET;
   1293         }
   1294         pParam->content.siteMgrCurrentModulationType = pSiteMgr->chosenModulation;
   1295         break;
   1296 
   1297     case SITE_MGR_NEXT_DTIM_TIME_STAMP_PARAM:
   1298         if (!pPrimarySite)
   1299         {
   1300             pParam->content.siteMgrNextDtimTimeStamp = 0;
   1301             return NO_SITE_SELECTED_YET;
   1302         }
   1303         /* Convert TBTT to msec (*1024/1000) */
   1304         dtimInterval = (UINT32)pPrimarySite->beaconInterval * 1024 *
   1305              (UINT32)pPrimarySite->dtimPeriod / 1000 ;
   1306         delta = os_timeStampMs(pSiteMgr->hOs) - pPrimarySite->dtimTimeStamp;
   1307         if(delta < dtimInterval)
   1308             delta = 0;
   1309         pParam->content.siteMgrNextDtimTimeStamp = pPrimarySite->dtimTimeStamp + dtimInterval + delta;
   1310         WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   1311                                 ("Get DTIM - dtimTimeStamp=%d, dtimInterval=%d, delta=%d\n",
   1312                         pPrimarySite->dtimTimeStamp, dtimInterval, delta));
   1313         break;
   1314 
   1315     case SITE_MGR_DESIRED_SLOT_TIME_PARAM:
   1316         pParam->content.siteMgrSlotTime = pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime;
   1317         break;
   1318 
   1319     case SITE_MGR_CURRENT_SLOT_TIME_PARAM:
   1320 
   1321         if(pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE)
   1322         {
   1323             if(!pPrimarySite)
   1324                 pParam->content.siteMgrSlotTime = pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime;
   1325             else
   1326                 pParam->content.siteMgrSlotTime = pPrimarySite->currentSlotTime;
   1327         }
   1328         else if(pSiteMgr->siteMgrOperationalMode == DOT11_A_MODE)
   1329             pParam->content.siteMgrSlotTime = PHY_SLOT_TIME_SHORT;
   1330         else
   1331             pParam->content.siteMgrSlotTime = PHY_SLOT_TIME_LONG;
   1332 
   1333         break;
   1334 
   1335     case SITE_MGR_BSSID_LIST_PARAM:
   1336         if (pParam->paramLength == 0)
   1337         {
   1338 
   1339             calculateBssidListSize(pSiteMgr, &pParam->paramLength, FALSE);
   1340 
   1341             return NOK;
   1342         }
   1343         else
   1344         {
   1345             status = getBssidList(pSiteMgr, pParam->content.pSiteMgrBssidList, &pParam->paramLength, FALSE);
   1346         }
   1347         break;
   1348 
   1349     case SITE_MGR_BSSID_FULL_LIST_PARAM:
   1350         if (pParam->paramLength == 0)
   1351         {
   1352 
   1353             calculateBssidListSize(pSiteMgr, &pParam->paramLength, TRUE);
   1354 
   1355             return NOK;
   1356         }
   1357         else
   1358         {
   1359             status = getBssidList(pSiteMgr, pParam->content.pSiteMgrBssidList, &pParam->paramLength, TRUE);
   1360         }
   1361         break;
   1362 
   1363     case SITE_MGR_LAST_BEACON_BUF_PARAM:
   1364         if (pPrimarySite != NULL)
   1365         {
   1366             if (pPrimarySite->probeRecv)
   1367             {
   1368                 pParam->content.siteMgrLastBeacon.isBeacon = FALSE;
   1369                 pParam->content.siteMgrLastBeacon.bufLength = pPrimarySite->probeRespLength;
   1370                 pParam->content.siteMgrLastBeacon.buffer = pPrimarySite->probeRespBuffer;
   1371             }
   1372             else
   1373             {
   1374                 pParam->content.siteMgrLastBeacon.isBeacon = TRUE;
   1375                 pParam->content.siteMgrLastBeacon.bufLength = pPrimarySite->beaconLength;
   1376                 pParam->content.siteMgrLastBeacon.buffer = pPrimarySite->beaconBuffer;
   1377             }
   1378         }
   1379         break;
   1380 
   1381     case SITE_MGR_BEACON_FILTER_DESIRED_STATE_PARAM:
   1382         {
   1383             if ( NULL != pSiteMgr )
   1384             {
   1385                 pParam->content.siteMgrDesiredBeaconFilterState = pSiteMgr->beaconFilterParams.desiredState;
   1386             }
   1387             else
   1388             {
   1389                 WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG ,("pSite = NULL ! No info available"));
   1390             }
   1391         }
   1392         break;
   1393 
   1394     case SITE_MGR_GET_SELECTED_BSSID_INFO:
   1395         getPrimarySiteDesc(pSiteMgr, pParam->content.pSiteMgrPrimarySiteDesc, FALSE);
   1396         break;
   1397 
   1398     case SITE_MGR_PRIMARY_SITE_PARAM:
   1399        status = getPrimaryBssid(pSiteMgr, (OS_802_11_BSSID_EX *)pParam->content.pSiteMgrSelectedSiteInfo, &pParam->paramLength);
   1400        break;
   1401 
   1402 
   1403     case SITE_MGR_TI_WLAN_COUNTERS_PARAM:
   1404         pParam->paramType = RX_DATA_COUNTERS_PARAM;
   1405         rxData_getParam(pSiteMgr->hRxData, pParam);
   1406 
   1407         whalParam.paramType = HAL_CTRL_COUNTERS_PARAM;
   1408         whalCtrl_GetParam(pSiteMgr->hHalCtrl, &whalParam);
   1409         pParam->content.siteMgrTiWlanCounters.RecvNoBuffer = whalParam.content.halCtrlCounters.RecvNoBuffer;
   1410         pParam->content.siteMgrTiWlanCounters.FragmentsRecv = whalParam.content.halCtrlCounters.FragmentsRecv;
   1411         pParam->content.siteMgrTiWlanCounters.FrameDuplicates = whalParam.content.halCtrlCounters.FrameDuplicates;
   1412         pParam->content.siteMgrTiWlanCounters.FcsErrors = whalParam.content.halCtrlCounters.FcsErrors;
   1413         pParam->content.siteMgrTiWlanCounters.RecvError = whalParam.content.halCtrlCounters.RecvError;
   1414 
   1415         pParam->paramType = AUTH_COUNTERS_PARAM;
   1416         auth_getParam(pSiteMgr->hAuth, pParam);
   1417 
   1418         pParam->paramType = ASSOC_COUNTERS_PARAM;
   1419         assoc_getParam(pSiteMgr->hAssoc, pParam);
   1420         pParam->content.siteMgrTiWlanCounters.BeaconsXmit = pSiteMgr->beaconSentCount;
   1421         break;
   1422 
   1423     case SITE_MGR_EEPROM_VERSION_PARAM:
   1424         os_memoryCopy(pSiteMgr->hOs, &(pParam->content.siteMgrEEpromVersion), &(pSiteMgr->pDesiredParams->siteMgrEEpromVersion), sizeof(e2Version_t));
   1425         break;
   1426 
   1427     case SITE_MGR_FIRMWARE_VERSION_PARAM:
   1428         os_memoryCopy(pSiteMgr->hOs, &(pParam->content.siteMgrFwVersion), &(pSiteMgr->pDesiredParams->siteMgrFwVersion), FW_VERSION_LEN);
   1429         break;
   1430 
   1431     case SITE_MGR_DESIRED_TX_RATE_PARAM:
   1432         pParam->content.siteMgrDesiredTxRate = hostToUtilityRate(pSiteMgr->pDesiredParams->siteMgrCurrentDesiredTxRate);
   1433         break;
   1434 
   1435     case SITE_MGR_CURRENT_TX_RATE_PARAM:
   1436         /* Collect txAttr from control */
   1437         {   txData_attr_t txAttr;
   1438 
   1439             ctrlData_getTxAttributes(pSiteMgr->hCtrlData, TX_DATA_DATA_MSDU, &txAttr, QOS_AC_BE);
   1440 
   1441             pParam->content.siteMgrCurrentTxRate = hostToUtilityRate( txAttr.Rate );
   1442         }
   1443         break;
   1444 
   1445     case SITE_MGR_DESIRED_DOT11_MODE_PARAM:
   1446         pParam->content.siteMgrDot11Mode = pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode;
   1447         break;
   1448 
   1449 	case SITE_MGR_NETWORK_TYPE_IN_USE:
   1450 		if (pPrimarySite)
   1451 		{ /* Connected - return the current mode */
   1452 			pParam->content.siteMgrDot11Mode = pSiteMgr->siteMgrOperationalMode;
   1453 		}
   1454 		else
   1455 		{ /* Disconnected - return the desired mode */
   1456 			pParam->content.siteMgrDot11Mode = pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode;
   1457 		}
   1458         break;
   1459 
   1460 
   1461     case SITE_MGR_OPERATIONAL_MODE_PARAM:
   1462         pParam->content.siteMgrDot11OperationalMode = pSiteMgr->siteMgrOperationalMode;
   1463         break;
   1464 
   1465     case SITE_MGR_USE_DRAFT_NUM_PARAM:
   1466         pParam->content.siteMgrUseDraftNum = pSiteMgr->pDesiredParams->siteMgrUseDraftNum;
   1467         break;
   1468 
   1469     case SITE_MGR_RADIO_BAND_PARAM:
   1470         pParam->content.siteMgrRadioBand = pSiteMgr->radioBand;
   1471         break;
   1472 
   1473     case SITE_MGR_CURRENT_PREAMBLE_TYPE_PARAM:
   1474         if (!pPrimarySite)
   1475             return NO_SITE_SELECTED_YET;
   1476 
   1477         pParam->content.siteMgrCurrentPreambleType = pPrimarySite->currentPreambleType;
   1478         break;
   1479 
   1480     case SITE_MGR_CURRENT_BSSID_PARAM:
   1481         if (pPrimarySite != NULL)
   1482         {
   1483             os_memoryCopy(pSiteMgr->hOs, (void *)pParam->content.siteMgrDesiredBSSID.addr, (void *)pPrimarySite->bssid.addr, MAC_ADDR_LEN);
   1484         }
   1485         break;
   1486 
   1487     case SITE_MGR_LAST_RX_RATE_PARAM:
   1488         if (pPrimarySite != NULL)
   1489         {
   1490             pParam->content.ctrlDataCurrentBasicRate = pPrimarySite->rxRate;
   1491         }
   1492         break;
   1493 
   1494     case SITE_MGR_PREV_SITE_BSSID_PARAM:
   1495         if (pSiteMgr->pSitesMgmtParams->pPrevPrimarySite==NULL)
   1496         {
   1497             return NOK;
   1498         }
   1499         os_memoryCopy(pSiteMgr->hOs, (void *)pParam->content.siteMgrDesiredBSSID.addr, (void *)pSiteMgr->pSitesMgmtParams->pPrevPrimarySite->bssid.addr, MAC_ADDR_LEN);
   1500         break;
   1501 
   1502     case SITE_MGR_PREV_SITE_SSID_PARAM:
   1503         if (pSiteMgr->pSitesMgmtParams->pPrevPrimarySite==NULL)
   1504         {
   1505             return NOK;
   1506         }
   1507         pParam->content.siteMgrDesiredSSID.len = pSiteMgr->pSitesMgmtParams->pPrevPrimarySite->ssid.len;
   1508         os_memoryCopy(pSiteMgr->hOs, (void *)pParam->content.siteMgrDesiredSSID.ssidString, (void *)pSiteMgr->pSitesMgmtParams->pPrevPrimarySite->ssid.ssidString, pSiteMgr->pSitesMgmtParams->pPrevPrimarySite->ssid.len);
   1509         break;
   1510 
   1511     case SITE_MGR_PREV_SITE_CHANNEL_PARAM:
   1512         if (pSiteMgr->pSitesMgmtParams->pPrevPrimarySite==NULL)
   1513         {
   1514             return NOK;
   1515         }
   1516         pParam->content.siteMgrDesiredChannel = pSiteMgr->pSitesMgmtParams->pPrevPrimarySite->channel;
   1517         break;
   1518 
   1519     case SITE_MGR_SITE_ENTRY_BY_INDEX:
   1520         siteEntryIndex = pParam->content.siteMgrIndexOfDesiredSiteEntry;
   1521         if(siteEntryIndex >= MAX_SITES_BG_BAND)
   1522         {
   1523             return NOK;
   1524         }
   1525         pParam->content.pSiteMgrDesiredSiteEntry =
   1526             (UINT8*)(&(pSiteMgr->pSitesMgmtParams->pCurrentSiteTable->siteTable[siteEntryIndex]));
   1527         break;
   1528 
   1529     case SITE_MGR_CUR_NUM_OF_SITES:
   1530         pParam->content.siteMgrNumberOfSites = pSiteMgr->pSitesMgmtParams->pCurrentSiteTable->numOfSites;
   1531         break;
   1532 
   1533     case SITE_MGR_CURRENT_TSF_TIME_STAMP:
   1534         os_memoryCopy(pSiteMgr->hOs, pParam->content.siteMgrCurrentTsfTimeStamp,
   1535                       pSiteMgr->pSitesMgmtParams->pPrimarySite->tsfTimeStamp,
   1536                       TIME_STAMP_LEN);
   1537         break;
   1538 
   1539     case SITE_MGR_GET_AP_QOS_CAPABILITIES:
   1540        if (!pPrimarySite)
   1541         {
   1542             pParam->content.qosApCapabilities.uQOSFlag = 0;
   1543             pParam->content.qosApCapabilities.uAPSDFlag = 0;
   1544             return NOT_CONNECTED;
   1545         }
   1546        pParam->content.qosApCapabilities.uQOSFlag = pPrimarySite->WMESupported;
   1547        pParam->content.qosApCapabilities.uAPSDFlag = pPrimarySite->APSDSupport;
   1548 
   1549         break;
   1550 
   1551     default:
   1552         {
   1553             UINT8* ptr = NULL;
   1554             WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, ("Get param, Params is not supported, %d\n", pParam->paramType));
   1555             *ptr=3;
   1556         }
   1557 
   1558         return PARAM_NOT_SUPPORTED;
   1559     }
   1560 
   1561     return status;
   1562 }
   1563 
   1564 
   1565 /***********************************************************************
   1566  *                        calculateHwGenTxRate
   1567  ***********************************************************************
   1568 DESCRIPTION: Service routine, which calculates the HW generated frames rate
   1569              to be used.
   1570 
   1571 INPUT:      basicBitMap - bit map of basic rates
   1572             mode        - operating mode
   1573 
   1574 OUTPUT:
   1575 
   1576 RETURN:     rate
   1577 
   1578 ************************************************************************/
   1579 void calculateHwGenTxRate(siteMgr_t *pSiteMgr, rate_e *rate)
   1580 {
   1581 
   1582     UINT32 rateBitMap = 0;
   1583     modulationType_e modulation = DRV_MODULATION_NONE; /* Not used */
   1584     mgmtCtrlTxRateOption_e mgmtCtrlTxRateOption = pSiteMgr->pDesiredParams->siteMgrRegstryDesiredMgmtCtrlTxRateOption;
   1585     UINT32 mgmtCtrlDesiredTxRateBitMap = ((0x01) << (pSiteMgr->pDesiredParams->siteMgrRegstryDesiredMgmtCtrlTxRate -1));
   1586 
   1587 
   1588     /* ratebitmap is the matched basic rate from the STA and AP */
   1589     if (pSiteMgr->pSitesMgmtParams->pPrimarySite->channel == SPECIAL_BG_CHANNEL)
   1590     {
   1591         rateBitMap = (UINT16)getBasicRateMaskForSpecialBGchannel() ;
   1592     }
   1593     else
   1594     {
   1595         rateBitMap = pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask;
   1596     }
   1597 
   1598     /* Check if the user request specific Rate */
   1599     if(mgmtCtrlTxRateOption == SPECIFIC_TX_RATE)
   1600     {
   1601         /* If the required rate is included in the matched basic rate, this specific rate is the only one to use */
   1602         if(rateBitMap & mgmtCtrlDesiredTxRateBitMap)
   1603         {
   1604             rateBitMap = mgmtCtrlDesiredTxRateBitMap;
   1605         }
   1606         else
   1607         {
   1608             /* If the specific required Tx Rate is not in the basic rate => Use Max basic rate */
   1609             mgmtCtrlTxRateOption = MAX_BASIC_TX_RATE;
   1610         }
   1611     }
   1612 
   1613     /* Now calculate HW Tx rate according to the rate bitmap */
   1614     if(mgmtCtrlTxRateOption == MAX_BASIC_TX_RATE)
   1615         getMaxRate(rateBitMap,rate,&modulation,pSiteMgr->siteMgrOperationalMode);
   1616     else
   1617     {
   1618         /* If we are here , means: The mgmtCtrlTxRateOption is either MIN_BASIC_TX_RATE or SPECIFIC_TX_RATE. */
   1619         getMinRate(rateBitMap,rate,&modulation,pSiteMgr->siteMgrOperationalMode);
   1620 
   1621     }
   1622 }
   1623 
   1624 
   1625 
   1626 
   1627 /***********************************************************************
   1628  *                        siteMgr_join
   1629  ***********************************************************************
   1630 DESCRIPTION: Called by the connection state machine in order to join a BSS.
   1631                 -   If the BSS is infrastructure, sets a NULL data template to the HAL
   1632                 -   If the BSS is IBSS, sets a probe response & beacon template to the HAL
   1633             Call the HAL with the join parameters
   1634 
   1635 
   1636 INPUT:      hSiteMgr    -   site mgr handle.
   1637             JoinCompleteCB - join command complete callback function ptr
   1638             CB_handle - handle to pass to callback function
   1639 
   1640 OUTPUT:
   1641 
   1642 RETURN:     OK on success, NOK otherwise
   1643 
   1644 ************************************************************************/
   1645 TI_STATUS siteMgr_join(TI_HANDLE    hSiteMgr)
   1646 {
   1647     siteMgr_t               *pSiteMgr = (siteMgr_t *)hSiteMgr;
   1648     siteEntry_t             *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
   1649     rate_e                  rate;
   1650 	paramInfoPartial_t      param;
   1651 
   1652     if (pPrimarySite == NULL)
   1653     {
   1654         WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, ("Join BSS, Primary Site is NULL\n"));
   1655         return OK;
   1656     }
   1657 
   1658     /* Configure the system according to parameters of Primary Site */
   1659     systemConfig(pSiteMgr);
   1660 
   1661     joinParams.bssType = pPrimarySite->bssType;
   1662     joinParams.beaconInterval = pPrimarySite->beaconInterval;
   1663     joinParams.dtimInterval = pPrimarySite->dtimPeriod;
   1664     joinParams.pBSSID = (UINT8 *)&(pPrimarySite->bssid.addr);
   1665     joinParams.pSSID = (UINT8 *)&(pPrimarySite->ssid.ssidString);
   1666     joinParams.ssidLength = pPrimarySite->ssid.len;
   1667 
   1668     joinParams.channel = pPrimarySite->channel;
   1669 
   1670         if (joinParams.channel == SPECIAL_BG_CHANNEL)
   1671     {
   1672          joinParams.basicRateSet     = (UINT16)getBasicRateMaskForSpecialBGchannel() ;
   1673          joinParams.supportedRateSet = (UINT16)getSupportedRateMaskForSpecialBGchannel() ;
   1674     }
   1675     else /* != SPECIAL_BG_CHANNEL */
   1676     {
   1677         joinParams.basicRateSet = (UINT16)pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask;
   1678         joinParams.supportedRateSet = (UINT16)pSiteMgr->pDesiredParams->siteMgrMatchedSuppRateMask;
   1679     }
   1680     calculateHwGenTxRate(pSiteMgr, &rate);
   1681     joinParams.hwGenCtrlTxRate = rate;
   1682 
   1683     param.paramType = CTRL_DATA_CURRENT_PREAMBLE_TYPE_PARAM;
   1684     ctrlData_getParamPartial(pSiteMgr->hCtrlData, &param);
   1685     joinParams.preamble = param.content.ctrlDataCurrentPreambleType;
   1686      /*set the preamble before the join*/
   1687     whalCtrl_SetPreamble(pSiteMgr->hHalCtrl, joinParams.preamble);
   1688 
   1689 
   1690 
   1691 /*
   1692  * Set the radio band and the HW management Tx rate according to operational mode.
   1693  * The HW management frames includes Beacon and Probe-Response (in IBSS).
   1694  */
   1695     if(pSiteMgr->siteMgrOperationalMode == DOT11_A_MODE)
   1696     {
   1697         joinParams.radioBand = RADIO_BAND_5_0_GHZ;
   1698         joinParams.hwGenMgmtTxRate = DRV_RATE_6M;
   1699     }
   1700     else
   1701     {
   1702         joinParams.radioBand = RADIO_BAND_2_4_GHZ;
   1703         joinParams.hwGenMgmtTxRate = DRV_RATE_2M;
   1704     }
   1705 
   1706     /* Now, Set templates to the HAL */
   1707     if (pPrimarySite->bssType == BSS_INDEPENDENT)
   1708     {
   1709         templateStruct.pTemplate = (UINT8 *)&probeRspTemplate;
   1710         templateStruct.templateType = PROBE_RESPONSE_TEMPLATE;
   1711         buildProbeRspTemplate(pSiteMgr, &templateStruct);
   1712         whalCtrl_SetTemplate(pSiteMgr->hHalCtrl, &templateStruct);
   1713 
   1714         /* We don't have to build a beacon template, because it is equal to probe response,
   1715         we only have to change the frame sup type */
   1716         probeRspTemplate.hdr.fc = ENDIAN_HANDLE_WORD(DOT11_FC_BEACON);
   1717         templateStruct.templateType = BEACON_TEMPLATE;
   1718         whalCtrl_SetTemplate(pSiteMgr->hHalCtrl, &templateStruct);
   1719     }
   1720     else
   1721     {
   1722         templateStruct.pTemplate = (UINT8 *)&nullDataTemplate;
   1723         templateStruct.templateType = NULL_DATA_TEMPLATE;
   1724         buildNullTemplate(pSiteMgr, &templateStruct);
   1725         whalCtrl_SetTemplate(pSiteMgr->hHalCtrl, &templateStruct);
   1726 
   1727         /* Send PsPoll template to HAL */
   1728         templateStruct.pTemplate = (UINT8 *)&psPollTemplate;
   1729         templateStruct.templateType = PS_POLL_TEMPLATE;
   1730         buildPsPollTemplate(pSiteMgr, &templateStruct);
   1731         whalCtrl_SetTemplate(pSiteMgr->hHalCtrl, &templateStruct);
   1732 
   1733         /* Set QOS Null data template to the firmware.
   1734             Note:  the AC to use with this template may change in QoS-manager. */
   1735         templateStruct.pTemplate = (UINT8 *)&QosNullDataTemplate;
   1736         templateStruct.templateType = QOS_NULL_DATA_TEMPLATE;
   1737         buildQosNullDataTemplate(pSiteMgr, &templateStruct, 0);
   1738         whalCtrl_SetTemplate(pSiteMgr->hHalCtrl, &templateStruct);
   1739     }
   1740 
   1741     /* Reset the Tx Power Control adjustment in RegulatoryDomain */
   1742     siteMgr_setTemporaryTxPower(pSiteMgr, FALSE);
   1743 
   1744     /*
   1745     clear the beacon receive flag to indicates when receive a beacon after the join command.
   1746     need for PowerMgr_startPS() - must be called only after join command and then only after
   1747     receiving beacon of the primary site!
   1748     */
   1749     pPrimarySite->beaconReceiveAfterJoin = FALSE;
   1750 
   1751     /* Stop Tx till geting Join Event complete */
   1752     txData_disableTransmission(pSiteMgr->hTxData, DISABLE_IMMEDIATELY);
   1753 
   1754     /* This is the forbidden period to enable the current state from the cli, even if desired state is TRUE */
   1755     /* Also This is set to FALSE since the First Beaqcin shall be received for the Power Manager */
   1756     pSiteMgr->beaconFilterParams.currentState = FALSE;
   1757     whalCtrl_SetBeaconFiltering(pSiteMgr->hHalCtrl, FALSE, pSiteMgr->beaconFilterParams.numOfStored);
   1758 
   1759     WLAN_REPORT_INFORMATION(pSiteMgr->hReport , SITE_MGR_MODULE_LOG , ("--          Beacon Filter Active Mode  Disable Beacon Filtering !!!  --\n"));
   1760 
   1761     return (TI_STATUS)whalCtrl_JoinBss (((siteMgr_t *)hSiteMgr)->hHalCtrl, &joinParams);
   1762 }
   1763 
   1764 /***********************************************************************
   1765  *                        siteMgr_forceInfraJoin
   1766  ***********************************************************************
   1767 DESCRIPTION: Called by the connection state machine in order to join a BSS.
   1768                 -   If the BSS is infrastructure, sets a NULL data template to the HAL
   1769                 -   If the BSS is IBSS, sets a probe response & beacon template to the HAL
   1770             Call the HAL with the join parameters
   1771 
   1772 
   1773 INPUT:      hSiteMgr    -   site mgr handle.
   1774             JoinCompleteCB - join command complete callback function ptr
   1775             CB_handle - handle to pass to callback function
   1776 
   1777 OUTPUT:
   1778 
   1779 RETURN:     OK on success, NOK otherwise
   1780 
   1781 ************************************************************************/
   1782 TI_STATUS siteMgr_forceInfraJoin(TI_HANDLE    hSiteMgr)
   1783 {
   1784     siteMgr_t               *pSiteMgr = (siteMgr_t *)hSiteMgr;
   1785     whalCtrl_joinBss_t      joinParams;
   1786     UINT8                   junkBSSID[MAC_ADDR_LEN] = {0xAA,0xAA,0xAA,0xAA,0xAA,0xAA};
   1787     UINT8                   junkSSID[1] = {0x01};
   1788 
   1789     WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, ("Force INFRA Join\n"));
   1790 
   1791     joinParams.bssType = BSS_INFRASTRUCTURE;
   1792     joinParams.beaconInterval = 200;
   1793     joinParams.dtimInterval = 3;
   1794     joinParams.pBSSID = (UINT8 *)junkBSSID;
   1795     joinParams.pSSID = (UINT8 *)junkSSID;
   1796     joinParams.ssidLength = 1;
   1797 
   1798     joinParams.channel = 11;
   1799 
   1800     joinParams.basicRateSet = (UINT16)pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask;
   1801     joinParams.supportedRateSet = (UINT16)pSiteMgr->pDesiredParams->siteMgrMatchedSuppRateMask;
   1802 
   1803     joinParams.hwGenCtrlTxRate = DRV_RATE_2M;
   1804     joinParams.hwGenMgmtTxRate = DRV_RATE_2M;
   1805     joinParams.preamble = PREAMBLE_LONG;
   1806 
   1807     if(pSiteMgr->siteMgrOperationalMode == DOT11_A_MODE)
   1808         joinParams.radioBand = RADIO_BAND_5_0_GHZ;
   1809     else
   1810         joinParams.radioBand = RADIO_BAND_2_4_GHZ;
   1811 
   1812     /* Stop Tx till geting Join Event complete */
   1813     txData_disableTransmission(pSiteMgr->hTxData, DISABLE_IMMEDIATELY);
   1814     return (TI_STATUS)whalCtrl_JoinBss (((siteMgr_t *)hSiteMgr)->hHalCtrl, &joinParams);
   1815 }
   1816 
   1817 /***********************************************************************
   1818  *                        siteMgr_disJoin
   1819  ***********************************************************************
   1820 DESCRIPTION: Called by the connection state machine in order to dis join a BSS.
   1821 
   1822 
   1823 INPUT:      hSiteMgr    -   site mgr handle.
   1824 
   1825 OUTPUT:
   1826 
   1827 RETURN:     OK on success, NOK otherwise
   1828 
   1829 ************************************************************************/
   1830 TI_STATUS siteMgr_disJoin(TI_HANDLE hSiteMgr)
   1831 {
   1832 #if 0
   1833     siteMgr_t               *pSiteMgr = (siteMgr_t *)hSiteMgr;
   1834     whalCtrl_joinBss_t      joinParams;
   1835     macAddress_t            dummyMac = {0xDE, 0xAD, 0xBE, 0xEF, 0xDE, 0xAD};
   1836     ssid_t                  dummySsid;
   1837 
   1838     joinParams.bssType = BSS_INFRASTRUCTURE;
   1839     joinParams.beaconInterval = SITE_MGR_BEACON_INTERVAL_DEF;
   1840     joinParams.dtimInterval = 1;
   1841     joinParams.channel = SITE_MGR_CHANNEL_DEF;
   1842 
   1843     joinParams.pBSSID = (UINT8 *)&(dummyMac.addr);
   1844 
   1845     dummySsid.len = 2;
   1846     os_memoryCopy(pSiteMgr->hOs, dummySsid.ssidString, "TI_WLAN", 7);
   1847     joinParams.pSSID = (UINT8 *)&(dummySsid.ssidString);
   1848     joinParams.ssidLength = dummySsid.len;
   1849 
   1850     joinParams.basicRateSet = buildRatesBitMap(pSiteMgr, SITE_MGR_DEF_RATE_SET_MAX_BASIC_DEF);
   1851     joinParams.supportedRateSet = buildRatesBitMap(pSiteMgr, SITE_MGR_DEF_RATE_SET_MAX_ACTIVE_DEF);
   1852 
   1853     return whalCtrl_JoinBss (((siteMgr_t *)hSiteMgr)->hHalCtrl, &joinParams);
   1854 #else
   1855     return OK;
   1856 #endif
   1857 }
   1858 
   1859 /***********************************************************************
   1860  *                        siteMgr_removeSelfSite
   1861  ***********************************************************************
   1862 DESCRIPTION: Called by the Self connection state machine in order to remove the self site from the site table.
   1863                 Remove the site entry form the table and reset the primary site pointer
   1864 
   1865 
   1866 INPUT:      hSiteMgr    -   site mgr handle.
   1867 
   1868 OUTPUT:
   1869 
   1870 RETURN:     OK on success, NOK otherwise
   1871 
   1872 ************************************************************************/
   1873 TI_STATUS siteMgr_removeSelfSite(TI_HANDLE  hSiteMgr)
   1874 {
   1875     siteMgr_t           *pSiteMgr  = (siteMgr_t *)hSiteMgr;
   1876     siteTablesParams_t  *currTable = pSiteMgr->pSitesMgmtParams->pCurrentSiteTable;
   1877 
   1878     if(pSiteMgr->pSitesMgmtParams->pPrimarySite == NULL)
   1879     {
   1880         WLAN_REPORT_WARNING(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Remove self site Failure, pointer is NULL\n\n"));
   1881         return OK;
   1882     }
   1883 
   1884     if(pSiteMgr->pSitesMgmtParams->pPrimarySite->siteType != SITE_SELF)
   1885     {
   1886         WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Remove self site Failure, site is not self\n\n"));
   1887         return OK;
   1888     }
   1889 
   1890     removeSiteEntry(pSiteMgr, currTable, pSiteMgr->pSitesMgmtParams->pPrimarySite);
   1891     pSiteMgr->pSitesMgmtParams->pPrimarySite = NULL;
   1892 
   1893     return OK;
   1894 }
   1895 
   1896 /***********************************************************************
   1897  *                        siteMgr_updateSite
   1898  ***********************************************************************
   1899 DESCRIPTION: Called by the MLME parser upon receiving a beacon or probe response.
   1900             Performs the following:
   1901                 -   Insert the site entry into the site hash table
   1902                 -   Update the site information in the site table
   1903                 -   If the site is the primary site, it handles the PBCC algorithm if needed
   1904                 -   If the site is NULL (means it is the first frame received from this site)
   1905                     we update the site type to be regular
   1906                 -   If the site type is self, we inform the self connection SM
   1907                     that another station joined the network we created
   1908 
   1909 
   1910 INPUT:      hSiteMgr    -   site mgr handle.
   1911             bssid       -   BSSID received
   1912             pFrameInfo  -   Frame content after the parsing
   1913             rxChannel   -   The channel on which frame was received
   1914             band        -   Band on which frame was received
   1915             measuring   -   Determines whether the beacon or probe response
   1916                             has been received while a beacon measurement
   1917                             took place
   1918 
   1919 OUTPUT:
   1920 
   1921 RETURN:     OK on success, NOK otherwise
   1922 
   1923 ************************************************************************/
   1924 TI_STATUS siteMgr_updateSite(TI_HANDLE          hSiteMgr,
   1925                           macAddress_t      *bssid,
   1926                           mlmeFrameInfo_t   *pFrameInfo,
   1927                           UINT8             rxChannel,
   1928                           radioBand_e       band,
   1929                           BOOL              measuring)
   1930 {
   1931     siteEntry_t *pSite;
   1932     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   1933     paramInfo_t param;
   1934 
   1935 
   1936     /* The following is not required, since the scanCncn is responsible to check
   1937         the channels validity before scanning.
   1938         The problem it caused was that when 802.11d is enabled,
   1939         channels that are valid for Passive only, will not be updated.*/
   1940     /*if (isChannelSupprted(pSiteMgr->hRegulatoryDomain , rxChannel) == FALSE)
   1941     {
   1942         WLAN_REPORT_WARNING(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   1943             ("Channel ERROR - try to register a site that its channel (=%d) isn't in the regulatory domain.\n\
   1944             registration ABORTED!!!",
   1945             rxChannel));
   1946         return NOK;
   1947     }*/
   1948 
   1949 
   1950     pSite = findAndInsertSiteEntry(pSiteMgr, bssid, band);
   1951 
   1952 
   1953 
   1954     if (pSite == NULL)
   1955     {
   1956         WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Site Update failure, table is full, bssid: %X-%X-%X-%X-%X-%X\n", bssid->addr[0], bssid->addr[1], bssid->addr[2], bssid->addr[3], bssid->addr[4], bssid->addr[5]));
   1957         return OK;
   1958     }
   1959 
   1960     updateSiteInfo(pSiteMgr, pFrameInfo, pSite, rxChannel);
   1961 
   1962     if (measuring != FALSE)
   1963     {
   1964         pSite->detectedWhileMeasuring = TRUE;
   1965     }
   1966 
   1967     switch(pSite->siteType)
   1968     {
   1969     case SITE_PRIMARY:
   1970         WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_UPDATE_MODULE_LOG,  ("PRIMARY site updated, bssid: %X-%X-%X-%X-%X-%X\n\n", bssid->addr[0], bssid->addr[1], bssid->addr[2], bssid->addr[3], bssid->addr[4], bssid->addr[5]));
   1971         if (pSiteMgr->pSitesMgmtParams->pPrimarySite == NULL)
   1972         {
   1973             WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, ("siteMgr_updateSite: Primary Site Is NULL\n"));
   1974             pSite->siteType = SITE_REGULAR;
   1975             break;
   1976         }
   1977         /* Now, if the following is TRUE we perform the PBCC algorithm: */
   1978         /* If the BSS type is infrastructure, &&
   1979             The chosen modulation is PBCC &&
   1980             The beacon modulation is not NONE &&
   1981             The current data modulation is different than the beacon modulation. */
   1982         if ((pSite->bssType == BSS_INFRASTRUCTURE) &&
   1983             (pSiteMgr->chosenModulation == DRV_MODULATION_PBCC) &&
   1984             (pSite->beaconModulation != DRV_MODULATION_NONE) &&
   1985             (pSiteMgr->currentDataModulation != pSite->beaconModulation))
   1986         {
   1987             pSiteMgr->currentDataModulation = pSite->beaconModulation;
   1988             pbccAlgorithm(pSiteMgr);
   1989         }
   1990 
   1991         /* Now handle the slot time, first check if the slot time changed since the last
   1992            setting to the HAL ,and if yes set the new value */
   1993         if((pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE) &&
   1994            (pSite->bssType == BSS_INFRASTRUCTURE))
   1995         {
   1996             if (pSite->currentSlotTime != pSite->newSlotTime)
   1997             {
   1998                 pSite->currentSlotTime = pSite->newSlotTime;
   1999                 whalCtrl_SetSlotTime(pSiteMgr->hHalCtrl, pSite->currentSlotTime);
   2000             }
   2001         }
   2002 
   2003         /* Now handle the current protection status */
   2004         if((pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE) &&
   2005            (pSite->bssType == BSS_INFRASTRUCTURE))
   2006         {
   2007             param.paramType = CTRL_DATA_CURRENT_PROTECTION_STATUS_PARAM;
   2008             param.content.ctrlDataProtectionEnabled = pSite->useProtection;
   2009             ctrlData_setParam(pSiteMgr->hCtrlData, &param);
   2010         }
   2011 
   2012         /* Now handle the current preamble type,
   2013            if desired preamble type is long, the ctrl data param should not be changed */
   2014         if((pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE) &&
   2015            (pSite->bssType == BSS_INFRASTRUCTURE) &&
   2016            (pSiteMgr->pDesiredParams->siteMgrDesiredPreambleType != PREAMBLE_LONG))
   2017         {
   2018             param.paramType = CTRL_DATA_CURRENT_PREAMBLE_TYPE_PARAM;
   2019             if((pSite->preambleAssRspCap == PREAMBLE_LONG) ||
   2020                (pSite->barkerPreambleType == PREAMBLE_LONG))
   2021                   {
   2022                 param.content.ctrlDataCurrentPreambleType = PREAMBLE_LONG;
   2023             }
   2024             else
   2025                 param.content.ctrlDataCurrentPreambleType = PREAMBLE_SHORT;
   2026 
   2027             ctrlData_setParam(pSiteMgr->hCtrlData, &param);
   2028 
   2029         }
   2030 
   2031         /*
   2032          * NOTE: THIS MUST BE AFTER SETTING PREAMBLE TYPE
   2033          */
   2034         if (pSiteMgr->chosenModulation != DRV_MODULATION_PBCC)
   2035         {
   2036             if (pSiteMgr->pDesiredParams->siteMgrCurrentDesiredTxRate == DRV_RATE_AUTO)
   2037             {
   2038                 param.paramType = CTRL_DATA_RATE_CONTROL_ENABLE_PARAM;
   2039                 param.content.ctrlDataRateControlEnable = TRUE;
   2040                 ctrlData_setParam(pSiteMgr->hCtrlData, &param);
   2041             }
   2042             else
   2043             {
   2044                 param.paramType = CTRL_DATA_RATE_CONTROL_ENABLE_PARAM;
   2045                 param.content.ctrlDataRateControlEnable = FALSE;
   2046                 ctrlData_setParam(pSiteMgr->hCtrlData, &param);
   2047             }
   2048 
   2049         }
   2050             break;
   2051 
   2052     case SITE_NULL:
   2053         pSite->siteType = SITE_REGULAR;
   2054         WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_UPDATE_MODULE_LOG,  ("REGULAR site added, bssid: %X-%X-%X-%X-%X-%X\n\n", bssid->addr[0], bssid->addr[1], bssid->addr[2], bssid->addr[3], bssid->addr[4], bssid->addr[5]));
   2055         break;
   2056 
   2057     case SITE_SELF:
   2058         pSite->siteType = SITE_PRIMARY;
   2059         WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("SELF ----> PRIMARY site , bssid: %X-%X-%X-%X-%X-%X\n\n", bssid->addr[0], bssid->addr[1], bssid->addr[2], bssid->addr[3], bssid->addr[4], bssid->addr[5]));
   2060         conn_ibssStaJoined(pSiteMgr->hConn);
   2061         break;
   2062 
   2063     case SITE_REGULAR:
   2064         WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_UPDATE_MODULE_LOG,  ("REGULAR site updated, bssid: %X-%X-%X-%X-%X-%X\n\n", bssid->addr[0], bssid->addr[1], bssid->addr[2], bssid->addr[3], bssid->addr[4], bssid->addr[5]));
   2065         break;
   2066 
   2067     default:
   2068         WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Setting site type failure, bssid: %X-%X-%X-%X-%X-%X\n\n", bssid->addr[0], bssid->addr[1], bssid->addr[2], bssid->addr[3], bssid->addr[4], bssid->addr[5]));
   2069         break;
   2070     }
   2071 
   2072     return OK;
   2073 }
   2074 
   2075 /***********************************************************************
   2076  *                        siteMgr_start
   2077  ***********************************************************************
   2078 DESCRIPTION: Called by the SME SM in order to start the aging timer
   2079 
   2080 
   2081 INPUT:      hSiteMgr    -   site mgr handle.
   2082 
   2083 OUTPUT:
   2084 
   2085 RETURN:     OK on success, NOK otherwise
   2086 
   2087 ************************************************************************/
   2088 TI_STATUS siteMgr_start(TI_HANDLE   hSiteMgr)
   2089 {
   2090     siteMgr_t       *pSiteMgr = (siteMgr_t *)hSiteMgr;
   2091 
   2092     /* update timestamp each time aging started (needed for quiet scan) */
   2093     if(pSiteMgr->pSitesMgmtParams->pPrimarySite)
   2094         pSiteMgr->pSitesMgmtParams->pPrimarySite->localTimeStamp = os_timeStampMs(pSiteMgr->hOs);
   2095 
   2096     return OK;
   2097 }
   2098 
   2099 
   2100 /***********************************************************************
   2101  *                        siteMgr_stop
   2102  ***********************************************************************
   2103 DESCRIPTION: Called by the SME SM in order to stop site mgr timers
   2104 
   2105 
   2106 INPUT:      hSiteMgr    -   site mgr handle.
   2107 
   2108 OUTPUT:
   2109 
   2110 RETURN:     OK on success, NOK otherwise
   2111 
   2112 ************************************************************************/
   2113 TI_STATUS siteMgr_stop(TI_HANDLE    hSiteMgr)
   2114 {
   2115 
   2116     return OK;
   2117 }
   2118 
   2119 /***********************************************************************
   2120  *                        siteMgr_CheckRxSignalValidity
   2121  ***********************************************************************
   2122 DESCRIPTION: Called by the mlme_parserRecv when receiving managment frame
   2123                 Find the ste in the site table and validate that the
   2124                 RSSI of that site signal is not lower then -80DB + not lower
   2125                 then the exising site RSSI
   2126 
   2127 
   2128 INPUT:      hSiteMgr    -   site mgr handle.
   2129             rxLevel     -   Rx level the frame received in
   2130             bssid       -   BSSID of the frame
   2131 
   2132 OUTPUT:
   2133 
   2134 RETURN:     OK / NOK
   2135 
   2136 ************************************************************************/
   2137 TI_STATUS siteMgr_CheckRxSignalValidity(TI_HANDLE  hSiteMgr,
   2138                          INT8               rxLevel,
   2139                          UINT8              channel,
   2140                          macAddress_t       *bssid)
   2141 {
   2142     siteEntry_t *pSite;
   2143     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   2144 
   2145     pSite = NULL;
   2146     pSite = findSiteEntry(pSiteMgr, bssid);
   2147 
   2148     if (pSite != NULL)
   2149     {
   2150         if ((channel != pSite->channel) &&
   2151             (rxLevel < pSite->rssi))
   2152         {   /* Ignore wrong packets with lower RSSI that were detect as
   2153             ripples from different channels */
   2154             WLAN_REPORT_WARNING(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   2155                               ("siteMgr_CheckRxSignalValidity:Rx RSSI =%d, on channel=%d, is lower then given RSSI =%d on channel=%d, dropping it.\n",
   2156                                rxLevel,  channel, pSite->rssi, pSite->channel));
   2157             return NOK;
   2158         }
   2159     }
   2160     return OK;
   2161 }
   2162 
   2163 /***********************************************************************
   2164  *                        siteMgr_updateRxSignal
   2165  ***********************************************************************
   2166 DESCRIPTION: Called by the Rx data when receiving a frae in the RX
   2167                 Find the ste in the site table and updates the SNR and RSSI
   2168 
   2169 
   2170 INPUT:      hSiteMgr    -   site mgr handle.
   2171             snr         -   SNR the frame received in
   2172             rxLevel     -   Rx level the frame received in
   2173             bssid       -   BSSID of the frame
   2174 
   2175 OUTPUT:
   2176 
   2177 RETURN:     OK on success, NOK otherwise
   2178 
   2179 ************************************************************************/
   2180 TI_STATUS siteMgr_updateRxSignal(TI_HANDLE  hSiteMgr,
   2181                          UINT8              snr,
   2182                          INT8               rxLevel,
   2183                          rate_e             rate,
   2184                          macAddress_t       *bssid,
   2185                          BOOL               dataMsdu)
   2186 {
   2187     siteEntry_t *pSite;
   2188     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   2189 
   2190     pSite = findSiteEntry(pSiteMgr, bssid);
   2191 
   2192     if (pSite != NULL)
   2193     {
   2194         pSite->localTimeStamp = os_timeStampMs(pSiteMgr->hOs);
   2195 
   2196         pSite->snr = snr;
   2197 
   2198     /* We check the rate just for finding error case */
   2199     switch(rate)
   2200         {
   2201         case DRV_RATE_1M:
   2202         case DRV_RATE_2M:
   2203         case DRV_RATE_5_5M:
   2204         case DRV_RATE_11M:
   2205         case DRV_RATE_22M:
   2206         case DRV_RATE_6M:
   2207         case DRV_RATE_9M:
   2208         case DRV_RATE_12M:
   2209         case DRV_RATE_18M:
   2210         case DRV_RATE_24M:
   2211         case DRV_RATE_36M:
   2212         case DRV_RATE_48M:
   2213         case DRV_RATE_54M:
   2214             pSite->rxRate = rate;
   2215             break;
   2216         default:
   2217             pSite->rxRate = (rate_e)0;
   2218             WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   2219                 ("siteMgr_updateRxSignal:Rx Rate is GARBAGE!\nRx Rate = %d\n", rate));
   2220             break;
   2221         }
   2222         /* Is this is not a primary site, update rssi;
   2223            For the Primary site, we store average RSSI that is counted and updated from Current BSS module */
   2224         if (pSite->siteType != SITE_PRIMARY)
   2225         {
   2226             pSite->rssi = (INT8)rxLevel;
   2227         }
   2228     }
   2229 
   2230     return OK;
   2231 }
   2232 
   2233 
   2234 /***********************************************************************
   2235  *                        siteMgr_updatePrimarySiteFailStatus
   2236  ***********************************************************************
   2237 DESCRIPTION: Called by the SME SM when the connection with the primary site fails
   2238                 If the primary site is NULL, return.
   2239 
   2240 
   2241 INPUT:      hSiteMgr    -   site mgr handle.
   2242             bRemoveSite -   Whether to remove the site
   2243 
   2244 OUTPUT:
   2245 
   2246 RETURN:     OK on success, NOK otherwise
   2247 
   2248 ************************************************************************/
   2249 TI_STATUS siteMgr_updatePrimarySiteFailStatus(TI_HANDLE hSiteMgr,
   2250                                            BOOL bRemoveSite)
   2251 {
   2252     siteMgr_t           *pSiteMgr = (siteMgr_t *)hSiteMgr;
   2253     siteTablesParams_t  *currTable = pSiteMgr->pSitesMgmtParams->pCurrentSiteTable;
   2254 
   2255     if (pSiteMgr->pSitesMgmtParams->pPrimarySite == NULL)
   2256         return OK;
   2257 
   2258     WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   2259     (" SITE MGR: bRemoveSite = %d \n", bRemoveSite));
   2260 
   2261     if (bRemoveSite)
   2262     {
   2263         removeSiteEntry(pSiteMgr, currTable, pSiteMgr->pSitesMgmtParams->pPrimarySite);
   2264         pSiteMgr->pSitesMgmtParams->pPrimarySite = NULL;
   2265     }
   2266     else	/* Currently never used */
   2267     {
   2268         pSiteMgr->pSitesMgmtParams->pPrimarySite->failStatus = STATUS_UNSPECIFIED;
   2269         pSiteMgr->pSitesMgmtParams->pPrimarySite->attemptsNumber++;
   2270         pSiteMgr->pSitesMgmtParams->pPrimarySite->attemptsNumber &= 0x0F;
   2271     }
   2272 
   2273     return OK;
   2274 }
   2275 
   2276 
   2277 
   2278 /***********************************************************************
   2279  *          siteMgr_resetEventStatisticsHistory
   2280  ***********************************************************************
   2281 DESCRIPTION: Called by the SME SM when successing in establishing a connection with the primary site
   2282                 If thr primary site is NULL, return.
   2283                 Otherwise, reset the site rssi level
   2284 
   2285 INPUT:      hSiteMgr    -   site mgr handle.
   2286 
   2287 OUTPUT:
   2288 
   2289 RETURN:     OK on success, NOK otherwise
   2290 
   2291 ************************************************************************/
   2292 TI_STATUS siteMgr_resetEventStatisticsHistory(TI_HANDLE hSiteMgr)
   2293 {
   2294     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   2295 
   2296     if (pSiteMgr->pSitesMgmtParams->pPrimarySite == NULL)
   2297     {
   2298         WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, ("siteMgr_resetPrimarySiteRssiPerLevelBeaconMissed: Primary Site Is NULL\n"));
   2299         return OK;
   2300     }
   2301 
   2302     return OK;
   2303 }
   2304 
   2305 
   2306 /***********************************************************************
   2307  *                        siteMgr_resetPrimarySiteAttemptsNumber
   2308  ***********************************************************************
   2309 DESCRIPTION: Called by the SME SM when successing in establishing a connection with the primary site
   2310                 If thr primary site is NULL, return.
   2311                 Otherwise, reset the site attemptsNumber counter.
   2312 
   2313 
   2314 INPUT:      hSiteMgr    -   site mgr handle.
   2315 
   2316 OUTPUT:
   2317 
   2318 RETURN:     OK on success, NOK otherwise
   2319 
   2320 ************************************************************************/
   2321 TI_STATUS siteMgr_resetPrimarySiteAttemptsNumber(TI_HANDLE  hSiteMgr)
   2322 {
   2323     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   2324 
   2325     if (pSiteMgr->pSitesMgmtParams->pPrimarySite == NULL)
   2326     {
   2327         WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, ("siteMgr_resetPrimarySiteAttemptsNumber: Primary Site Is NULL\n"));
   2328         return OK;
   2329     }
   2330     pSiteMgr->pSitesMgmtParams->pPrimarySite->attemptsNumber = 0;
   2331 
   2332     return OK;
   2333 }
   2334 
   2335 /***********************************************************************
   2336  *                        siteMgr_resetPrevPrimarySiteRssi
   2337  ***********************************************************************
   2338 DESCRIPTION: Called by the SME SM when successing in establishing a connection with the primary site
   2339                 If thr primary site is NULL, return.
   2340                 Otherwise, reset the site attemptsNumber counter.
   2341 
   2342 
   2343 INPUT:      hSiteMgr    -   site mgr handle.
   2344 
   2345 OUTPUT:
   2346 
   2347 RETURN:     OK on success, NOK otherwise
   2348 
   2349 ************************************************************************/
   2350 TI_STATUS siteMgr_resetPrevPrimarySiteRssi(TI_HANDLE    hSiteMgr)
   2351 {
   2352     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   2353 
   2354     if (pSiteMgr->pSitesMgmtParams->pPrevPrimarySite == NULL)
   2355     {
   2356         WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   2357                                 ("Previous Primary Site Is NULL\n"));
   2358         return OK;
   2359     }
   2360 
   2361     WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   2362                             ("Resetting previous primary site RSSI\n"));
   2363     /*
   2364     pSiteMgr->pSitesMgmtParams->pPrevPrimarySite->rssi = 0;
   2365     pSiteMgr->pSitesMgmtParams->pPrevPrimarySite->attemptsNumber = 0;
   2366     */
   2367 
   2368     return OK;
   2369 }
   2370 
   2371 /***********************************************************************
   2372  *                        siteMgr_isCurrentBand24
   2373  ***********************************************************************
   2374 DESCRIPTION: The function checks the current operational mode and
   2375                 returns if the current band is 2.4Ghz or 5Ghz.
   2376 
   2377 INPUT:      hSiteMgr    -   site mgr handle.
   2378 
   2379 OUTPUT:
   2380 
   2381 RETURN:     TRUE if current band is 2.4Ghz, FALSE otherwise.
   2382 
   2383 ************************************************************************/
   2384 BOOL siteMgr_isCurrentBand24(TI_HANDLE  hSiteMgr)
   2385 {
   2386     siteMgr_t   *pSiteMgr =     (siteMgr_t *)hSiteMgr;
   2387 
   2388     if(pSiteMgr->siteMgrOperationalMode == DOT11_A_MODE)
   2389         return FALSE;
   2390 
   2391     return TRUE; /* 802.11b supports onlty 2.4G band */
   2392 
   2393 }
   2394 
   2395 
   2396 /***********************************************************************
   2397  *                        siteMgr_isThereValidSSID
   2398  ***********************************************************************
   2399 DESCRIPTION: checks if a valid SSID exists
   2400 
   2401 INPUT:      hSiteMgr    -   site mgr handle.
   2402 
   2403 OUTPUT:
   2404 
   2405 RETURN:     TRUE if valid SSID found, FALSE if not
   2406 
   2407 ************************************************************************/
   2408 BOOL siteMgr_isThereValidSSID (TI_HANDLE hSiteMgr)
   2409 {
   2410    paramInfo_t param;
   2411 
   2412    param.paramType = SITE_MGR_DESIRED_SSID_PARAM;
   2413    siteMgr_getParam(hSiteMgr,&param);
   2414 
   2415     if((utils_isAnySSID(&param.content.siteMgrDesiredSSID)) || (utils_isJunkSSID(&param.content.siteMgrDesiredSSID)))
   2416       return (FALSE);
   2417     else
   2418        return (TRUE);
   2419 }
   2420 
   2421 /***********************************************************************
   2422  *                        removeEldestSite
   2423  ***********************************************************************
   2424 DESCRIPTION: Called by the select when trying to create an IBSS and site table is full
   2425                 Remove the eldest site from the table
   2426 
   2427 INPUT:      hSiteMgr    -   site mgr handle.
   2428 
   2429 OUTPUT:
   2430 
   2431 RETURN:     OK on success, NOK otherwise
   2432 
   2433 ************************************************************************/
   2434 TI_STATUS removeEldestSite(siteMgr_t *pSiteMgr)
   2435 {
   2436     int             i;
   2437     siteEntry_t     *pEldestSite = NULL, *pSiteTable = pSiteMgr->pSitesMgmtParams->pCurrentSiteTable->siteTable;
   2438     siteTablesParams_t  *currTable = pSiteMgr->pSitesMgmtParams->pCurrentSiteTable;
   2439     UINT32          currentTimsStamp = os_timeStampMs(pSiteMgr->hOs);
   2440     UINT32          biggestGap = 0;
   2441 
   2442     for (i = 0; i < currTable->maxNumOfSites; i++)
   2443     {
   2444         if (biggestGap < ((UINT32)(currentTimsStamp - pSiteTable[i].localTimeStamp)))
   2445         {
   2446             biggestGap = ((UINT32)(currentTimsStamp - pSiteTable[i].localTimeStamp));
   2447             pEldestSite = &(pSiteTable[i]);
   2448         }
   2449     }
   2450 
   2451     removeSiteEntry(pSiteMgr, currTable, pEldestSite);
   2452 
   2453     return OK;
   2454 }
   2455 
   2456 
   2457 /***********************************************************************
   2458  *                        update_apsd
   2459  ***********************************************************************
   2460 DESCRIPTION:    Sets the site APSD support flag according to the
   2461                 beacon's capabilities vector and the WME-params IE if exists.
   2462 
   2463 INPUT:      pSite       -   Pointer to the site entry in the site table
   2464             pFrameInfo  -   Frame information after the parsing
   2465 
   2466 OUTPUT:     pSite->APSDSupport flag
   2467 
   2468 RETURN:
   2469 
   2470 ************************************************************************/
   2471 static void update_apsd(siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo)
   2472 {
   2473     /* If WME-Params IE is not included in the beacon, set the APSD-Support flag
   2474          only by the beacons capabilities bit map. */
   2475     if (pFrameInfo->content.iePacket.WMEParams == NULL)
   2476         pSite->APSDSupport = (((pFrameInfo->content.iePacket.capabilities >> CAP_APSD_SHIFT) & CAP_APSD_MASK) ? TRUE : FALSE);
   2477 
   2478     /* Else, set the APSD-Support flag if either the capabilities APSD bit or the
   2479          WME-Params APSD bit indicate so. */
   2480     else
   2481         pSite->APSDSupport = ((((pFrameInfo->content.iePacket.capabilities >> CAP_APSD_SHIFT) & CAP_APSD_MASK) ? TRUE : FALSE) ||
   2482         (((pFrameInfo->content.iePacket.WMEParams->ACInfoField >> AP_QOS_INFO_UAPSD_SHIFT) & AP_QOS_INFO_UAPSD_MASK) ? TRUE : FALSE));
   2483 }
   2484 
   2485 
   2486 /***********************************************************************
   2487  *                        release_module
   2488  ***********************************************************************
   2489 DESCRIPTION:    Called by the un load function
   2490                 Go over the vector, for each bit that is set, release the corresponding module.
   2491 
   2492 INPUT:      pSiteMgr    -   site mgr handle.
   2493             initVec -   Vector that contains a bit set for each module thah had been initiualized
   2494 
   2495 OUTPUT:
   2496 
   2497 RETURN:     OK on success, NOK otherwise
   2498 
   2499 ************************************************************************/
   2500 static void release_module(siteMgr_t *pSiteMgr, UINT32 initVec)
   2501 {
   2502     if (initVec & (1 << MGMT_PARAMS_INIT_BIT))
   2503         utils_nullMemoryFree(pSiteMgr->hOs, pSiteMgr->pSitesMgmtParams, sizeof(sitesMgmtParams_t));
   2504 
   2505     if (initVec & (1 << DESIRED_PARAMS_INIT_BIT))
   2506         utils_nullMemoryFree(pSiteMgr->hOs, pSiteMgr->pDesiredParams, sizeof(siteMgrInitParams_t));
   2507 
   2508     if (initVec & (1 << SITE_MGR_INIT_BIT))
   2509         utils_nullMemoryFree(pSiteMgr->hOs, pSiteMgr, sizeof(siteMgr_t));
   2510 
   2511     initVec = 0;
   2512 }
   2513 
   2514 
   2515 /***********************************************************************
   2516  *                        updateSiteInfo
   2517  ***********************************************************************
   2518 DESCRIPTION:    Called upon receiving a beacon or probe response
   2519                 Go over the vector, for each bit that is set, release the corresponding module.
   2520                 Update theaite entry in the site table with the information received in the frame
   2521 
   2522 INPUT:      pSiteMgr    -   site mgr handle.
   2523             pFrameInfo  -   Frame information after the parsing
   2524             pSite       -   Pointer to the site entry in the site table
   2525 
   2526 OUTPUT:
   2527 
   2528 RETURN:     OK on success, NOK otherwise
   2529 
   2530 ************************************************************************/
   2531 static void updateSiteInfo(siteMgr_t *pSiteMgr, mlmeFrameInfo_t *pFrameInfo, siteEntry_t    *pSite, UINT8 rxChannel)
   2532 {
   2533     paramInfo_t param;
   2534     BOOL        ssidUpdated;
   2535 
   2536 
   2537     SET_ENTRY_FLAG_IN_SITE_TABLE(pSite);
   2538     ssidUpdated = FALSE;
   2539 
   2540     switch (pFrameInfo->subType)
   2541     {
   2542     case BEACON:
   2543 
   2544         UPDATE_BEACON_INTERVAL(pSite, pFrameInfo);
   2545 
   2546         UPDATE_CAPABILITIES(pSite, pFrameInfo);
   2547 
   2548 		if (utils_isIESSID_Broadcast(pFrameInfo->content.iePacket.pSsid) == FALSE)
   2549         {   /* And the SSID is not Broadcast */
   2550                 ssidUpdated = TRUE;
   2551                 UPDATE_SSID(pSite, pFrameInfo);
   2552         }
   2553 
   2554         if (ssidUpdated)
   2555         {
   2556             UPDATE_PRIVACY(pSite, pFrameInfo);
   2557         }
   2558 
   2559         update_apsd(pSite, pFrameInfo);
   2560 
   2561         updatePreamble(pSiteMgr, pSite, pFrameInfo);
   2562 
   2563         UPDATE_AGILITY(pSite, pFrameInfo);
   2564 
   2565 
   2566         if(pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE)
   2567         {
   2568             UPDATE_SLOT_TIME(pSite, pFrameInfo);
   2569             UPDATE_PROTECTION(pSite, pFrameInfo);
   2570         }
   2571 
   2572         updateRates(pSiteMgr, pSite, pFrameInfo);
   2573 
   2574         if ((pFrameInfo->content.iePacket.pDSParamsSet != NULL)  &&
   2575             (pFrameInfo->content.iePacket.pDSParamsSet->currChannel!=rxChannel))
   2576         {
   2577             WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   2578                            ("updateSiteInfo, wrong CHANNELS:rxChannel=%d,currChannel=%d\n",
   2579                             rxChannel, pFrameInfo->content.iePacket.pDSParamsSet->currChannel));
   2580         }
   2581         else
   2582             UPDATE_CHANNEL(pSite, pFrameInfo , rxChannel);
   2583 
   2584 
   2585         UPDATE_BSS_TYPE(pSite, pFrameInfo);
   2586 
   2587         if (pSite->bssType == BSS_INFRASTRUCTURE)
   2588             UPDATE_DTIM_PERIOD(pSite, pFrameInfo);
   2589 
   2590         UPDATE_ATIM_WINDOW(pSite, pFrameInfo);
   2591 
   2592         UPDATE_BEACON_AP_TX_POWER(pSite, pFrameInfo);
   2593 
   2594         /* Updating QoS params */
   2595         updateBeaconQosParams(pSiteMgr, pSite, pFrameInfo);
   2596 
   2597         /* updating CountryIE  */
   2598         if ((pFrameInfo->content.iePacket.country  != NULL) &&
   2599             (pFrameInfo->content.iePacket.country->hdr.eleLen != 0))
   2600         {
   2601             /* set the country info in the regulatory domain - If a different code was detected earlier
   2602                the regDomain will ignore it */
   2603             param.paramType = REGULATORY_DOMAIN_COUNTRY_PARAM;
   2604             param.content.pCountry = (country_t *)pFrameInfo->content.iePacket.country;
   2605             regulatoryDomain_setParam(pSiteMgr->hRegulatoryDomain,&param);
   2606         }
   2607 
   2608         /* Checking if this beacon is a DTIM i.e. DTIM count is zero */
   2609         if( (pFrameInfo->content.iePacket.pTIM != NULL) && (pFrameInfo->content.iePacket.pTIM->dtimCount == 0))
   2610         {
   2611             /* Update the DTIM beacon time */
   2612             UPDATE_DTIM_TIME(pSiteMgr, pSite, pFrameInfo);
   2613         }
   2614 
   2615         UPDATE_LOCAL_TIME_STAMP(pSiteMgr, pSite, pFrameInfo);
   2616 
   2617         UPDATE_BEACON_MODULATION(pSite, pFrameInfo);
   2618 
   2619         /* If the BSS type is independent, the beacon & probe modulation are equal,
   2620             It is important to update this field here for dynamic PBCC algorithm compatibility */
   2621         if (pSite->bssType == BSS_INDEPENDENT)
   2622             UPDATE_PROBE_MODULATION(pSite, pFrameInfo);
   2623 
   2624 
   2625         if (pSite->siteType == SITE_PRIMARY)
   2626         {
   2627 
   2628             if (pSiteMgr->pSitesMgmtParams->pPrimarySite == NULL)
   2629             {
   2630                 WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, ("updateSiteInfo: Primary Site Is NULL\n"));
   2631                 pSite->siteType = SITE_REGULAR;
   2632             }
   2633             else
   2634             {
   2635                 /*  If the site that we got the beacon on is the primary site - which means we are either trying */
   2636                 /*  to connect to it or we are already connected - send the EVENT_GOT_BEACON to the conn module (through the SME module) */
   2637                 /*  so the conn module will be aware of the beacon status of the site it's trying to connect to */
   2638 
   2639 #ifdef EXC_MODULE_INCLUDED
   2640                 UINT8 ExternTxPower;
   2641 
   2642                 if (pFrameInfo->content.iePacket.cellTP != NULL)
   2643                 {
   2644                     ExternTxPower = pFrameInfo->content.iePacket.cellTP->power;
   2645                 }
   2646                 else	/* Set to maximum possible. Note that we add +1 so that Dbm = 26 and not 25 */
   2647                 {
   2648                     ExternTxPower = MAX_TX_POWER / DBM_TO_TX_POWER_FACTOR + 1;
   2649                 }
   2650 
   2651                 param.paramType = REGULATORY_DOMAIN_EXTERN_TX_POWER_PREFERRED;
   2652                 param.content.ExternTxPowerPreferred = ExternTxPower;
   2653                 regulatoryDomain_setParam(pSiteMgr->hRegulatoryDomain, &param);
   2654 #endif
   2655 
   2656 				/* Updating the Tx Power according to the received Power Constraint  */
   2657 				if(pFrameInfo->content.iePacket.powerConstraint  != NULL)
   2658 				{   /* Checking if the recieved constraint is different from the one that is already known  */
   2659 					if( pFrameInfo->content.iePacket.powerConstraint->powerConstraint != pSite->powerConstraint)
   2660 					{   /* check if Spectrum Management is enabled */
   2661 						param.paramType = REGULATORY_DOMAIN_MANAGEMENT_CAPABILITY_ENABLED_PARAM;
   2662 						regulatoryDomain_getParam(pSiteMgr->hRegulatoryDomain,&param);
   2663 						if(param.content.spectrumManagementEnabled)
   2664 						{   /* setting power constraint */
   2665 							pSite->powerConstraint = pFrameInfo->content.iePacket.powerConstraint->powerConstraint;
   2666 							param.paramType = REGULATORY_DOMAIN_SET_POWER_CONSTRAINT_PARAM;
   2667 							param.content.powerConstraint = pSite->powerConstraint;
   2668 							regulatoryDomain_setParam(pSiteMgr->hRegulatoryDomain,&param);
   2669 
   2670 						}
   2671 					}
   2672 				}
   2673 
   2674                 if (pSite->beaconReceiveAfterJoin == FALSE)
   2675                 {
   2676                     /*
   2677                     use for indicate to that it safe to call to PowerMgr_startPS() that can be call only
   2678                     after join command followed by beacon receive later.
   2679                     every join command the beaconReceiveAfterJoin flag is cleared therefor it will
   2680                     be true after the join command.
   2681 
   2682                     the right follow is: join --> receive primary site beacon --> PowerMgr_startPS().
   2683 
   2684                     Note: the beaconReceiveAfterJoin flag is in use for the SME path!
   2685                     */
   2686                     siteMgr_gotFirstBcn(pSiteMgr);
   2687                     /* set Hw not available now that the first beacon arrived */
   2688                     MacServices_powerAutho_AwakeRequiredUpdate(pSiteMgr->hMacServices, POWERAUTHO_AWAKE_NOT_REQUIRED, POWERAUTHO_AWAKE_REASON_FIRST_BEACON);
   2689 
   2690                     pSite->beaconReceiveAfterJoin = TRUE;
   2691 
   2692                     WLAN_REPORT_INFORMATION(pSiteMgr->hReport,
   2693                                             SITE_MGR_MODULE_LOG,
   2694                                             ("1st beacon after join command RECEIVED!!!\n"));
   2695         }
   2696 
   2697             }
   2698         }
   2699 
   2700         UPDATE_BEACON_RECV(pSite);
   2701 
   2702         if (ssidUpdated)
   2703         {
   2704             dot11_RSN_t *pRsnIe = pFrameInfo->content.iePacket.pRsnIe;
   2705             UINT8       rsnIeLen = pFrameInfo->content.iePacket.rsnIeLen;
   2706             UPDATE_RSN_IE(pSite, pRsnIe, rsnIeLen);
   2707         }
   2708 
   2709 
   2710         UPDATE_BEACON_TIMESTAMP(pSiteMgr, pSite, pFrameInfo);
   2711 
   2712         break;
   2713 
   2714 
   2715     case PROBE_RESPONSE:
   2716 
   2717         UPDATE_BEACON_INTERVAL(pSite, pFrameInfo);
   2718 
   2719         UPDATE_CAPABILITIES(pSite, pFrameInfo);
   2720 
   2721                 ssidUpdated = TRUE;
   2722         if (pSite->siteType == SITE_PRIMARY)
   2723         {   /* Primary SITE */
   2724             if ((pFrameInfo->content.iePacket.pSsid != NULL) &&
   2725                 (pSiteMgr->pDesiredParams->siteMgrDesiredSSID.len>0))
   2726             {   /* There's a desired SSID*/
   2727                 if (os_memoryCompare(pSiteMgr->hOs, (UINT8*)(pSiteMgr->pDesiredParams->siteMgrDesiredSSID.ssidString),
   2728                                      (UINT8*)(pFrameInfo->content.iePacket.pSsid->serviceSetId), pFrameInfo->content.iePacket.pSsid->hdr.eleLen)!=0)
   2729                 {   /* Do not overwrite the primary site's SSID with a different than the desired SSID*/
   2730                     ssidUpdated = FALSE;
   2731                 }
   2732 
   2733             }
   2734             else if (pFrameInfo->content.iePacket.pSsid == NULL)
   2735             {
   2736                 WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   2737                                   ("updateSiteInfo PROBE_RESP, pSsid=NULL\n"));
   2738             }
   2739         }
   2740 
   2741         if (ssidUpdated)
   2742         {
   2743             UPDATE_SSID(pSite, pFrameInfo);
   2744             UPDATE_PRIVACY(pSite, pFrameInfo);
   2745         }
   2746 
   2747         update_apsd(pSite, pFrameInfo);
   2748 
   2749 
   2750         if(pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE)
   2751         {
   2752             UPDATE_PROTECTION(pSite, pFrameInfo);
   2753         }
   2754 
   2755         updateFourX(pSiteMgr, pSite, pFrameInfo);
   2756 
   2757         updatePreamble(pSiteMgr, pSite, pFrameInfo);
   2758 
   2759         UPDATE_AGILITY(pSite, pFrameInfo);
   2760 
   2761         updateRates(pSiteMgr, pSite, pFrameInfo);
   2762 
   2763         if ((pFrameInfo->content.iePacket.pDSParamsSet != NULL)  &&
   2764             (pFrameInfo->content.iePacket.pDSParamsSet->currChannel!=rxChannel))
   2765         {
   2766             WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   2767                            ("updateSiteInfo, wrong CHANNELS:rxChannel=%d,currChannel=%d\n",
   2768                             rxChannel, pFrameInfo->content.iePacket.pDSParamsSet->currChannel));
   2769         }
   2770         else
   2771             UPDATE_CHANNEL(pSite, pFrameInfo, rxChannel);
   2772 
   2773 
   2774         UPDATE_BSS_TYPE(pSite, pFrameInfo);
   2775 
   2776         UPDATE_ATIM_WINDOW(pSite, pFrameInfo);
   2777 
   2778         UPDATE_PROBE_AP_TX_POWER(pSite, pFrameInfo);
   2779 
   2780         /* Updating WME params */
   2781         updateProbeQosParams(pSiteMgr, pSite, pFrameInfo);
   2782 
   2783 
   2784         /* updating CountryIE  */
   2785         if ((pFrameInfo->content.iePacket.country  != NULL) &&
   2786             (pFrameInfo->content.iePacket.country->hdr.eleLen != 0))
   2787         {
   2788             /* set the country info in the regulatory domain - If a different code was detected earlier
   2789                the regDomain will ignore it */
   2790             param.paramType = REGULATORY_DOMAIN_COUNTRY_PARAM;
   2791             param.content.pCountry = (country_t *)pFrameInfo->content.iePacket.country;
   2792             regulatoryDomain_setParam(pSiteMgr->hRegulatoryDomain,&param);
   2793 		}
   2794 
   2795         UPDATE_LOCAL_TIME_STAMP(pSiteMgr, pSite, pFrameInfo);
   2796 
   2797         UPDATE_PROBE_MODULATION(pSite, pFrameInfo);
   2798 
   2799         /* If the BSS type is independent, the beacon & probe modulation are equal,
   2800             It is important to update this field here for dynamic PBCC algorithm compatibility */
   2801         if (pSite->bssType == BSS_INDEPENDENT)
   2802             UPDATE_BEACON_MODULATION(pSite, pFrameInfo);
   2803 
   2804         UPDATE_PROBE_RECV(pSite);
   2805 
   2806         if (ssidUpdated)
   2807         {
   2808             dot11_RSN_t *pRsnIe = pFrameInfo->content.iePacket.pRsnIe;
   2809             UINT8       rsnIeLen = pFrameInfo->content.iePacket.rsnIeLen;
   2810             UPDATE_RSN_IE(pSite, pRsnIe, rsnIeLen);
   2811 
   2812         }
   2813 
   2814         UPDATE_BEACON_TIMESTAMP(pSiteMgr, pSite, pFrameInfo);
   2815 
   2816         break;
   2817 
   2818     default:
   2819         WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Site Update failure, un known frame sub type %d\n\n", pFrameInfo->subType));
   2820         break;
   2821     }
   2822 }
   2823 
   2824 
   2825 /***********************************************************************
   2826  *                        updateFourX
   2827  ***********************************************************************
   2828 DESCRIPTION:    Called by the function 'updateSiteInfo()'
   2829 
   2830 INPUT:      pSiteMgr    -   site mgr handle.
   2831             pFrameInfo  -   Frame information after the parsing
   2832             pSite       -   Pointer to the site entry in the site table
   2833 
   2834 OUTPUT:
   2835 
   2836 RETURN:
   2837 
   2838 ************************************************************************/
   2839 static void updateFourX(siteMgr_t *pSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo)
   2840 {
   2841     UINT8 ti_oui[] = TI_OUI;
   2842 
   2843     /* It is done to overcome interop issues. We don't send AssocReq with 4x IE
   2844        if ProbeReq without 4x IE was received previously */
   2845     if (pFrameInfo->content.iePacket.fourXParams != NULL)
   2846     {
   2847         os_memoryCopy(pSiteMgr->hOs, &pSite->fourXParams, pFrameInfo->content.iePacket.fourXParams, pFrameInfo->content.iePacket.fourXParams->hdr.eleLen+sizeof( dot11_eleHdr_t));
   2848 
   2849         if( (pSite->fourXParams.hdr.eleId != DOT11_4X_ELE_ID) ||
   2850             (pSite->fourXParams.hdr.eleLen > DOT11_4X_MAX_LEN) ||
   2851             (os_memoryCompare(pSiteMgr->hOs ,ti_oui, (PUINT8)pSite->fourXParams.fourXCapabilities, DOT11_OUI_LEN) != 0) )
   2852         {
   2853             pSite->fourXsupported = FALSE;
   2854         }
   2855     }
   2856     else
   2857         pSite->fourXsupported = FALSE;
   2858 }
   2859 
   2860 /***********************************************************************
   2861  *                        updatePreamble
   2862  ***********************************************************************
   2863 DESCRIPTION:    Called by the function 'updateSiteInfo()'
   2864 
   2865 INPUT:      pSiteMgr    -   site mgr handle.
   2866             pFrameInfo  -   Frame information after the parsing
   2867             pSite       -   Pointer to the site entry in the site table
   2868 
   2869 OUTPUT:
   2870 
   2871 RETURN:
   2872 
   2873 ************************************************************************/
   2874 static void updatePreamble(siteMgr_t *pSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo)
   2875 {
   2876     pSite->currentPreambleType = ((pFrameInfo->content.iePacket.capabilities >> CAP_PREAMBLE_SHIFT) & CAP_PREAMBLE_MASK) ? PREAMBLE_SHORT : PREAMBLE_LONG;
   2877 
   2878     pSite->barkerPreambleType = pFrameInfo->content.iePacket.barkerPreambleMode;
   2879 }
   2880 
   2881 /***********************************************************************
   2882  *                        updateBeaconQosParams
   2883  ***********************************************************************
   2884 DESCRIPTION:    Called by the function 'updateSiteInfo()'
   2885 
   2886 INPUT:      pSiteMgr    -   site mgr handle.
   2887             pFrameInfo  -   Frame information after the parsing
   2888             pSite       -   Pointer to the site entry in the site table
   2889 
   2890 OUTPUT:
   2891 
   2892 RETURN:
   2893 
   2894 ************************************************************************/
   2895 
   2896 static void updateBeaconQosParams(siteMgr_t *pSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo)
   2897 {
   2898     /* Updating WME params */
   2899     if (pFrameInfo->content.iePacket.WMEParams  != NULL)
   2900     {
   2901         /* Checking if this is IE includes new WME Parameters */
   2902         if(( ((pFrameInfo->content.iePacket.WMEParams->ACInfoField) & dot11_WME_ACINFO_MASK ) != pSite->lastWMEParameterCnt) ||
   2903             (!pSite->WMESupported) )
   2904         {
   2905             pSite->WMESupported = TRUE;
   2906 
   2907             /* Checking if this IE is information only or is a paremeters IE */
   2908             if(pFrameInfo->content.iePacket.WMEParams->OUISubType == dot11_WME_OUI_SUB_TYPE_PARAMS_IE)
   2909             {
   2910                 if(pSite->siteType == SITE_PRIMARY)
   2911                 {
   2912                     qosMngr_updateIEinfo(pSiteMgr->hQosMngr,(UINT8 *)(pFrameInfo->content.iePacket.WMEParams),WME);
   2913                 }
   2914                 /* updating the WME paraeters into the site table. */
   2915                 os_memoryCopy(pSiteMgr->hOs, &pSite->WMEParameters, &(pFrameInfo->content.iePacket.WMEParams->WME_ACParameteres), sizeof( ACParameters_t));
   2916                 pSite->lastWMEParameterCnt = (pFrameInfo->content.iePacket.WMEParams->ACInfoField) & dot11_WME_ACINFO_MASK;
   2917                 WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,("$$$$$$ WME parameters were updates according to beacon, cntSeq = %d\n",pSite->lastWMEParameterCnt));
   2918             }
   2919         }
   2920     }else
   2921     {
   2922         pSite->WMESupported = FALSE;
   2923         }
   2924 
   2925 }
   2926 
   2927 /***********************************************************************
   2928  *                        updateProbeQosParams
   2929  ***********************************************************************
   2930 DESCRIPTION:    Called by the function 'updateSiteInfo()'
   2931 
   2932 INPUT:      pSiteMgr    -   site mgr handle.
   2933             pFrameInfo  -   Frame information after the parsing
   2934             pSite       -   Pointer to the site entry in the site table
   2935 
   2936 OUTPUT:
   2937 
   2938 RETURN:
   2939 
   2940 ************************************************************************/
   2941 static void updateProbeQosParams(siteMgr_t *pSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo)
   2942 {
   2943     /* Updating WME params */
   2944     if (pFrameInfo->content.iePacket.WMEParams  != NULL)
   2945     {
   2946         /* Checking if this is IE includes new WME Parameters */
   2947         if(( ((pFrameInfo->content.iePacket.WMEParams->ACInfoField) & dot11_WME_ACINFO_MASK ) != pSite->lastWMEParameterCnt) ||
   2948             (!pSite->WMESupported) )
   2949         {
   2950             pSite->WMESupported = TRUE;
   2951 
   2952             /* Checking if this IE is information only or is a paremeters IE */
   2953             if(pFrameInfo->content.iePacket.WMEParams->OUISubType == dot11_WME_OUI_SUB_TYPE_PARAMS_IE)
   2954             {
   2955                 if(pSite->siteType == SITE_PRIMARY)
   2956                 {
   2957                     qosMngr_updateIEinfo(pSiteMgr->hQosMngr,(UINT8 *)(pFrameInfo->content.iePacket.WMEParams),WME);
   2958                 }
   2959                 /* updating the WME paraeters into the site table. */
   2960                 os_memoryCopy(pSiteMgr->hOs, &pSite->WMEParameters, &(pFrameInfo->content.iePacket.WMEParams->WME_ACParameteres), sizeof( ACParameters_t));
   2961                 pSite->lastWMEParameterCnt = (pFrameInfo->content.iePacket.WMEParams->ACInfoField) & dot11_WME_ACINFO_MASK;
   2962                 WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,("$$$$$$ WME parameters were updates according to  probe response, cntSeq = %d\n",pSite->lastWMEParameterCnt));
   2963             }
   2964         }
   2965     }else
   2966     {
   2967         pSite->WMESupported = FALSE;
   2968         }
   2969 
   2970 }
   2971 
   2972 /***********************************************************************
   2973  *                        updateRates
   2974  ***********************************************************************
   2975 DESCRIPTION:    Called by the function 'updateSiteInfo()' in order to translate the rates received
   2976                 in the beacon or probe response to rate used by the driver. Perfoms the following:
   2977                     -   Check the rates. validity. If rates are invalid, return
   2978                     -   Get the max active rate & max basic rate, if invalid, return
   2979                     -   Translate the max active rate and max basic rate from network rates to host rates.
   2980                         The max active & max basic rate are used by the driver from now on in all the processes:
   2981                         (selection, join, transmission, etc....)
   2982 
   2983 INPUT:      pSiteMgr    -   site mgr handle.
   2984             pFrameInfo  -   Frame information after the parsing
   2985             pSite       -   Pointer to the site entry in the site table
   2986 
   2987 OUTPUT:
   2988 
   2989 RETURN:     OK on success, NOK otherwise
   2990 
   2991 ************************************************************************/
   2992 static void updateRates(siteMgr_t *pSiteMgr, siteEntry_t *pSite, mlmeFrameInfo_t *pFrameInfo)
   2993 {
   2994     UINT8   maxBasicRate = 0, maxActiveRate = 0;
   2995     UINT32  bitMapExtSupp = 0;
   2996     paramInfo_t param;
   2997 
   2998     if (pFrameInfo->content.iePacket.pRates == NULL)
   2999     {
   3000         WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("updateRates, pRates=NULL, beacon & probeResp are: \n"));
   3001         WLAN_REPORT_HEX_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   3002                           (UINT8*)pFrameInfo->content.iePacket.pRates, pFrameInfo->content.iePacket.pRates->hdr.eleLen+2);
   3003         WLAN_REPORT_HEX_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   3004                           (UINT8*)pFrameInfo->content.iePacket.pRates, pFrameInfo->content.iePacket.pRates->hdr.eleLen+2);
   3005         return;
   3006     }
   3007 
   3008     /* Update the rate elements */
   3009     maxBasicRate = getMaxBasicRatefromString((UINT8 *)pFrameInfo->content.iePacket.pRates->rates,pFrameInfo->content.iePacket.pRates->hdr.eleLen, maxBasicRate);
   3010     maxActiveRate = getMaxActiveRatefromString((UINT8 *)pFrameInfo->content.iePacket.pRates->rates,pFrameInfo->content.iePacket.pRates->hdr.eleLen, maxActiveRate);
   3011 
   3012     if(pFrameInfo->content.iePacket.pExtRates)
   3013     {
   3014         maxBasicRate = getMaxBasicRatefromString((UINT8 *)pFrameInfo->content.iePacket.pExtRates->rates,pFrameInfo->content.iePacket.pExtRates->hdr.eleLen, maxBasicRate);
   3015         maxActiveRate = getMaxActiveRatefromString((UINT8 *)pFrameInfo->content.iePacket.pExtRates->rates,pFrameInfo->content.iePacket.pExtRates->hdr.eleLen, maxActiveRate);
   3016     }
   3017 
   3018 
   3019     /*WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("1- maxBasicRate = 0x%X, maxActiveRate = 0x%X \n", maxBasicRate,maxActiveRate));*/
   3020 
   3021     if (maxActiveRate == 0)
   3022         maxActiveRate = maxBasicRate;
   3023 
   3024     /* Now update it from network to host rates */
   3025     pSite->maxBasicRate = networkToHostRate(maxBasicRate);
   3026 
   3027     pSite->maxActiveRate = networkToHostRate(maxActiveRate);
   3028     if (pSite->maxActiveRate == DRV_RATE_INVALID)
   3029             WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Network To Host Rate failure, no active network rate\n"));
   3030 
   3031     if (pSite->maxBasicRate != DRV_RATE_INVALID)
   3032     {
   3033         if (pSite->maxActiveRate != DRV_RATE_INVALID)
   3034         {
   3035             pSite->maxActiveRate = MAX(pSite->maxActiveRate,pSite->maxBasicRate);
   3036         }
   3037     } else { /* in case some vendors don't specify basic rates */
   3038         WLAN_REPORT_WARNING(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Network To Host Rate failure, no basic network rate"));
   3039         pSite->maxBasicRate = pSite->maxActiveRate;
   3040     }
   3041 
   3042     /* build rates bit map */
   3043     networkStringToBitMapSuppRates((UINT32 *)&pSite->rateMask.supportedRateMask,
   3044                                    (UINT8 *)pFrameInfo->content.iePacket.pRates->rates,
   3045                                    pFrameInfo->content.iePacket.pRates->hdr.eleLen);
   3046     networkStringToBitMapBasicRates((UINT32 *)&pSite->rateMask.basicRateMask,
   3047                                     (UINT8 *)pFrameInfo->content.iePacket.pRates->rates,
   3048                                     pFrameInfo->content.iePacket.pRates->hdr.eleLen);
   3049 
   3050     if(pFrameInfo->content.iePacket.pExtRates)
   3051     {
   3052         networkStringToBitMapSuppRates(&bitMapExtSupp, (UINT8 *)pFrameInfo->content.iePacket.pExtRates->rates,
   3053                                        pFrameInfo->content.iePacket.pExtRates->hdr.eleLen);
   3054 
   3055         pSite->rateMask.supportedRateMask |= bitMapExtSupp;
   3056 
   3057         networkStringToBitMapBasicRates(&bitMapExtSupp, (UINT8 *)pFrameInfo->content.iePacket.pExtRates->rates,
   3058                                         pFrameInfo->content.iePacket.pExtRates->hdr.eleLen);
   3059 
   3060         pSite->rateMask.basicRateMask |= bitMapExtSupp;
   3061     }
   3062 
   3063 
   3064     param.paramType = CTRL_DATA_CURRENT_SUPPORTED_RATE_MASK_PARAM;
   3065     param.content.ctrlDataCurrentRateMask = pSite->rateMask.supportedRateMask;
   3066     /* clear the 22Mbps bit in case the PBCC is not allowed */
   3067     if(pSiteMgr->currentDataModulation != DRV_MODULATION_PBCC && pSiteMgr->currentDataModulation != DRV_MODULATION_OFDM)
   3068     {
   3069       param.content.ctrlDataCurrentRateMask &= ~DRV_RATE_MASK_22_PBCC;
   3070     }
   3071     ctrlData_setParam(pSiteMgr->hCtrlData, &param);
   3072 
   3073     param.paramType = CTRL_DATA_CURRENT_BASIC_RATE_MASK_PARAM;
   3074     param.content.ctrlDataBasicRateBitMask = pSite->rateMask.basicRateMask;
   3075     ctrlData_setParam(pSiteMgr->hCtrlData, &param);
   3076 
   3077 
   3078     /*WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("2- pSite->maxActiveRate = 0x%X, pSite->maxBasicRate = 0x%X \n", pSite->maxActiveRate,pSite->maxBasicRate));*/
   3079 
   3080 }
   3081 
   3082 /***********************************************************************
   3083  *                        getBssidList
   3084  ***********************************************************************
   3085 DESCRIPTION:    Called by the OS abstraction layer in order to get the BSSID list from the site table
   3086 
   3087 INPUT:      pSiteMgr    -   site mgr handle.
   3088 
   3089 OUTPUT:     bssidList   -   BSSID list pointer
   3090 
   3091 RETURN:
   3092 
   3093 ************************************************************************/
   3094 static TI_STATUS getBssidList(siteMgr_t *pSiteMgr, OS_802_11_BSSID_LIST_EX *bssidList, UINT32 *pLength, BOOL allVarIes)
   3095 {
   3096     UINT8                   siteTableIndex, tableIndex, i, index, rsnIeLength;
   3097     siteEntry_t             *pSiteEntry;
   3098     OS_802_11_BSSID_EX      *pBssid;
   3099     OS_802_11_FIXED_IEs     *pFixedIes;
   3100     OS_802_11_VARIABLE_IEs  *pVarIes;
   3101 
   3102     UINT32                  length;
   3103     UINT8                   *pData;
   3104     UINT32                  len, firstOFDMloc = 0;
   3105     siteTablesParams_t      *currTable;
   3106     short                   numOfTables;
   3107 
   3108     UINT8		    *pDesiredIe;
   3109     UINT8                   *pSiteEntryIeBuffer;
   3110     UINT16                  ieLength;
   3111 
   3112     UINT8                   wpsOuiBuffer[DOT11_WPS_OUI_LEN+1]=DOT11_WPS_OUI;
   3113 
   3114 #ifdef DBG_BSSIS_NAME_PRINT
   3115     UINT8                   tempName[33];
   3116 #endif
   3117 
   3118     numOfTables = NUM_OF_SITE_TABLE;
   3119 
   3120 
   3121     bssidList->NumberOfItems = 0;
   3122 
   3123     calculateBssidListSize(pSiteMgr, &length, allVarIes);
   3124 
   3125     if (length > *pLength)
   3126     {
   3127         *pLength = length;
   3128         return NOK;
   3129     }
   3130 
   3131     length = sizeof(OS_802_11_BSSID_LIST_EX) - sizeof(OS_802_11_BSSID_EX);
   3132 
   3133     pData = (UINT8*)&bssidList->Bssid[0];
   3134 
   3135     WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Entering getBssidList, length = %d, pData = 0x%X\n", *pLength, (UINT32)pData));
   3136 
   3137     currTable = pSiteMgr->pSitesMgmtParams->pCurrentSiteTable;
   3138 
   3139     for (tableIndex = 0; tableIndex < numOfTables ; tableIndex++)
   3140     {
   3141         for (siteTableIndex = 0, i = 0; siteTableIndex < currTable->maxNumOfSites; siteTableIndex++)
   3142         {
   3143             pBssid = (OS_802_11_BSSID_EX*)pData;
   3144 
   3145             pSiteEntry = &(currTable->siteTable[siteTableIndex]);
   3146 
   3147             if (pSiteEntry->siteType == SITE_NULL)
   3148                 continue;
   3149 
   3150 
   3151             /* MacAddress */
   3152             os_memoryCopy(pSiteMgr->hOs, (void *)pBssid->MacAddress, (void *)&(pSiteEntry->bssid.addr), MAC_ADDR_LEN);
   3153 
   3154 
   3155             /* Capabilities */
   3156             pBssid->Union.Capabilities = pSiteEntry->capabilities;
   3157 
   3158             /* SSID */
   3159             /* This line is in order to prevent presantation problems at the utility. */
   3160             os_memoryZero(pSiteMgr->hOs, &(pBssid->Ssid.Ssid), MAX_SSID_LEN);
   3161             if (pSiteEntry->ssid.len > MAX_SSID_LEN)
   3162             {
   3163                 pSiteEntry->ssid.len = MAX_SSID_LEN;
   3164             }
   3165             os_memoryCopy(pSiteMgr->hOs, (void *)pBssid->Ssid.Ssid, &(pSiteEntry->ssid.ssidString), pSiteEntry->ssid.len);
   3166             pBssid->Ssid.SsidLength = pSiteEntry->ssid.len;
   3167 
   3168             /* privacy */
   3169             pBssid->Privacy = pSiteEntry->privacy;
   3170 
   3171             /* RSSI */
   3172 
   3173             pBssid->Rssi = (pSiteEntry->rssi);
   3174 
   3175             pBssid->Configuration.Length = sizeof(OS_802_11_CONFIGURATION);
   3176             pBssid->Configuration.BeaconPeriod = pSiteEntry->beaconInterval;
   3177             pBssid->Configuration.ATIMWindow = pSiteEntry->atimWindow;
   3178             pBssid->Configuration.Union.channel = Chan2Freq(pSiteEntry->channel);
   3179 
   3180             pBssid->Configuration.FHConfig.Length = sizeof(OS_802_11_CONFIGURATION_FH);
   3181             pBssid->Configuration.FHConfig.DwellTime = pSiteEntry->FHParams.dwellTime;
   3182             pBssid->Configuration.FHConfig.HopPattern = pSiteEntry->FHParams.hopPattern;
   3183             pBssid->Configuration.FHConfig.HopSet = pSiteEntry->FHParams.hopSet;
   3184 
   3185             if  (pSiteEntry->bssType == BSS_INDEPENDENT)
   3186                 pBssid->InfrastructureMode = os802_11IBSS;
   3187             else
   3188                 pBssid->InfrastructureMode = os802_11Infrastructure;
   3189 
   3190             /* SupportedRates */
   3191             os_memoryZero(pSiteMgr->hOs, (void *)pBssid->SupportedRates, sizeof(OS_802_11_RATES_EX));
   3192 
   3193             bitMapToNetworkStringRates(pSiteEntry->rateMask.supportedRateMask,
   3194                                        pSiteEntry->rateMask.basicRateMask,
   3195                                        (UINT8 *)pBssid->SupportedRates,
   3196                                        &len, &firstOFDMloc);
   3197 
   3198             /* set network type acording to band and rates */
   3199             if (currTable == &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables)
   3200             {
   3201                 if (firstOFDMloc == len)
   3202                 {
   3203                     pBssid->NetworkTypeInUse = os802_11DS;
   3204                 } else {
   3205                     pBssid->NetworkTypeInUse = os802_11OFDM24;
   3206                 }
   3207             } else {
   3208                 pBssid->NetworkTypeInUse = os802_11OFDM5;
   3209             }
   3210 
   3211             pBssid->IELength = 0;
   3212 
   3213             /* copy fixed IEs from site entry */
   3214             pFixedIes = (OS_802_11_FIXED_IEs*)&pBssid->IEs[pBssid->IELength];
   3215             os_memoryCopy(pSiteMgr->hOs, (void *)pFixedIes->TimeStamp, &pSiteEntry->localTimeStamp, sizeof(pSiteEntry->localTimeStamp));
   3216             pFixedIes->BeaconInterval = pSiteEntry->beaconInterval;
   3217             pFixedIes->Capabilities = pSiteEntry->capabilities;
   3218             pBssid->IELength += sizeof(OS_802_11_FIXED_IEs);
   3219             pVarIes = (OS_802_11_VARIABLE_IEs*)&pBssid->IEs[pBssid->IELength];
   3220 
   3221             if (!allVarIes)
   3222             {   /* copy only several variable IEs */
   3223 
   3224                 /* copy SSID */
   3225                 pVarIes->ElementID = SSID_IE_ID;
   3226                 pVarIes->Length = pSiteEntry->ssid.len;
   3227                 os_memoryCopy(pSiteMgr->hOs, (void *)pVarIes->data, (void *)pSiteEntry->ssid.ssidString, pSiteEntry->ssid.len);
   3228                 pBssid->IELength += (pVarIes->Length + 2);
   3229 
   3230                 /* copy RATES */
   3231                 pVarIes = (OS_802_11_VARIABLE_IEs*)&pBssid->IEs[pBssid->IELength];
   3232                 pVarIes->ElementID = SUPPORTED_RATES_IE_ID;
   3233                 bitMapToNetworkStringRates(pSiteEntry->rateMask.supportedRateMask, pSiteEntry->rateMask.basicRateMask,
   3234                                            (UINT8 *)pVarIes->data, &len, &firstOFDMloc);
   3235                 pVarIes->Length = len;
   3236                 pBssid->IELength += (pVarIes->Length + 2);
   3237 
   3238                 /* copy FH */
   3239                 pVarIes = (OS_802_11_VARIABLE_IEs*)&pBssid->IEs[pBssid->IELength];
   3240                 pVarIes->ElementID = FH_PARAMETER_SET_IE_ID;
   3241                 pVarIes->Length = DOT11_FH_PARAMS_ELE_LEN;
   3242                 os_memoryCopy(pSiteMgr->hOs, (void *)pVarIes->data, &pSiteEntry->FHParams.dwellTime, sizeof(pSiteEntry->FHParams.dwellTime));
   3243                 os_memoryCopy(pSiteMgr->hOs, (void *)&pVarIes->data[2], &pSiteEntry->FHParams.hopSet, sizeof(pSiteEntry->FHParams.hopSet));
   3244                 os_memoryCopy(pSiteMgr->hOs, (void *)&pVarIes->data[3], &pSiteEntry->FHParams.hopPattern, sizeof(pSiteEntry->FHParams.hopPattern));
   3245                 pVarIes->data[4] = 1;
   3246                 pBssid->IELength += (pVarIes->Length + 2);
   3247 
   3248                 /* copy DS */
   3249                 pVarIes = (OS_802_11_VARIABLE_IEs*)&pBssid->IEs[pBssid->IELength];
   3250                 pVarIes->ElementID = DS_PARAMETER_SET_IE_ID;
   3251                 pVarIes->Length = DOT11_DS_PARAMS_ELE_LEN;
   3252                 os_memoryCopy(pSiteMgr->hOs, (void *)pVarIes->data, &pSiteEntry->channel, DOT11_DS_PARAMS_ELE_LEN);
   3253                 pBssid->IELength += (pVarIes->Length + 2);
   3254 
   3255                 /* copy RSN information elements */
   3256                 rsnIeLength = 0;
   3257                 for (index=0; index<MAX_RSN_IE && pSiteEntry->pRsnIe[index].hdr.eleLen>0; index++)
   3258                 {
   3259                     pVarIes =  (OS_802_11_VARIABLE_IEs*)&pBssid->IEs[pBssid->IELength+rsnIeLength];
   3260                     pVarIes->ElementID = pSiteEntry->pRsnIe[index].hdr.eleId;
   3261                     pVarIes->Length = pSiteEntry->pRsnIe[index].hdr.eleLen;
   3262                     os_memoryCopy(pSiteMgr->hOs, (void *)pVarIes->data, (void *)pSiteEntry->pRsnIe[index].rsnIeData, pSiteEntry->pRsnIe[index].hdr.eleLen);
   3263                     rsnIeLength += pSiteEntry->pRsnIe[index].hdr.eleLen+2;
   3264                     WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   3265                                             ("RSN IE ID=%d, Length=%x\n", pVarIes->ElementID, pVarIes->Length));
   3266 
   3267                     WLAN_REPORT_HEX_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, (UINT8 *)pVarIes->data,pVarIes->Length);
   3268                 }
   3269 
   3270                 pBssid->IELength += pSiteEntry->rsnIeLen;
   3271 
   3272                 /* create information element for the WME/EXC.
   3273                     Note that the existence of these IEs should be considered as a fact that the site supports this feature.
   3274                     by alcel
   3275                 */
   3276                 if (pSiteEntry->WMESupported)
   3277                 {
   3278                     /* oui */
   3279                     UINT8 ouiWME[3] = { 0x50,0xf2,0x01};
   3280                     dot11_WME_PARAM_t *pWMEParams;
   3281 
   3282 
   3283                     /* fill in the general element  parameters */
   3284 
   3285                     pVarIes =  (OS_802_11_VARIABLE_IEs*)&pBssid->IEs[pBssid->IELength];
   3286                     pVarIes->ElementID =DOT11_WME_ELE_ID;
   3287                     pVarIes->Length = DOT11_WME_PARAM_ELE_LEN;
   3288 
   3289                     WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   3290                                             ("WMESupported ID=%d, Length=%x\n", pVarIes->ElementID, pVarIes->Length));
   3291 
   3292                     /* fill in the specific element  parameters */
   3293                     pWMEParams = (dot11_WME_PARAM_t *) pVarIes;
   3294                     os_memoryCopy(pSiteMgr->hOs,(void *)pWMEParams->OUI,ouiWME,3);
   3295                     pWMEParams->OUIType = dot11_WME_OUI_TYPE;
   3296                     pWMEParams->OUISubType = dot11_WME_OUI_SUB_TYPE_PARAMS_IE;
   3297                     pWMEParams->version = dot11_WME_VERSION;
   3298                     pWMEParams->ACInfoField = dot11_WME_ACINFO_MASK & pSiteEntry->lastWMEParameterCnt;
   3299 
   3300                     /* fill in the data  */
   3301 
   3302                     os_memoryCopy(pSiteMgr->hOs,&(pWMEParams->WME_ACParameteres),&(pSiteEntry->WMEParameters),sizeof(ACParameters_t));
   3303 
   3304 
   3305                     /* update the general length */
   3306 
   3307                     pBssid->IELength += (pVarIes->Length + 2);
   3308                 }
   3309 
   3310 				/* copy WPS information elements */
   3311 
   3312 				if ((pSiteEntry->probeRecv) &&
   3313 					(pSiteEntry->siteType != SITE_PRIMARY))
   3314 				{
   3315 					pSiteEntryIeBuffer = pSiteEntry->probeRespBuffer;
   3316 					ieLength = pSiteEntry->probeRespLength;
   3317 				}
   3318 				else
   3319 				{
   3320 					pSiteEntryIeBuffer = pSiteEntry->beaconBuffer;
   3321 					ieLength = pSiteEntry->beaconLength;
   3322 				}
   3323 
   3324 				parseIeBuffer(pSiteMgr->hOs, pSiteEntryIeBuffer, ieLength, DOT11_WPS_ELE_ID, &pDesiredIe, wpsOuiBuffer, DOT11_WPS_OUI_LEN);
   3325 
   3326 				if (pDesiredIe)
   3327 				{
   3328 					pVarIes = (OS_802_11_VARIABLE_IEs*)&pBssid->IEs[pBssid->IELength];
   3329 					pVarIes->ElementID = DOT11_WPS_ELE_ID;
   3330 					pVarIes->Length = *((UINT8*)(pDesiredIe + 1));
   3331 					os_memoryCopy(pSiteMgr->hOs, (void *)pVarIes->data, (UINT8*)(pDesiredIe+2), pVarIes->Length);
   3332 
   3333 					pBssid->IELength += (pVarIes->Length + 2);
   3334 				}
   3335             }
   3336             else
   3337             {   /* Copy all variable IEs */
   3338 
   3339                 if ((pSiteEntry->probeRecv) &&
   3340                     (pSiteEntry->siteType != SITE_PRIMARY))
   3341                 {
   3342                     pSiteEntryIeBuffer = pSiteEntry->probeRespBuffer;
   3343                     ieLength = pSiteEntry->probeRespLength;
   3344                 }
   3345                 else
   3346                 {
   3347                     pSiteEntryIeBuffer = pSiteEntry->beaconBuffer;
   3348                     ieLength = pSiteEntry->beaconLength;
   3349                 }
   3350                 WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   3351                                         ("Copy all variable IEs Length=%x\n", ieLength));
   3352                 WLAN_REPORT_HEX_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   3353                                             pSiteEntryIeBuffer, ieLength);
   3354 
   3355                 os_memoryCopy(pSiteMgr->hOs, pVarIes, pSiteEntryIeBuffer, ieLength);
   3356 
   3357                 pBssid->IELength += ieLength;
   3358             }
   3359 
   3360             pBssid->Length = sizeof(OS_802_11_BSSID_EX) + pBssid->IELength - 1;
   3361 
   3362             WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   3363                                     ("BSSID MAC = %x-%x-%x-%x-%x-%x\n",
   3364                                      pBssid->MacAddress[0], pBssid->MacAddress[1], pBssid->MacAddress[2],
   3365                                      pBssid->MacAddress[3], pBssid->MacAddress[4], pBssid->MacAddress[5]));
   3366 
   3367 #ifdef DBG_BSSIS_NAME_PRINT
   3368             os_memoryCopy(pSiteMgr->hOs, tempName, &pBssid->Ssid.Ssid[0], pBssid->Ssid.SsidLength);
   3369             tempName[pBssid->Ssid.SsidLength] ='\0';
   3370 
   3371             WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   3372                                     ("BSSID NAME = %s\n",tempName)) ;
   3373 #endif
   3374 
   3375 
   3376             /* make sure length is 4 bytes aligned */
   3377             if (pBssid->Length % 4)
   3378             {
   3379                 pBssid->Length += (4 - (pBssid->Length % 4));
   3380             }
   3381 
   3382             WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   3383                                     ("BSSID length after alignment = %d\n", pBssid->Length));
   3384 
   3385             pData += pBssid->Length;
   3386             length += pBssid->Length;
   3387 
   3388 
   3389             i++;
   3390         }
   3391 
   3392         bssidList->NumberOfItems += i;
   3393 
   3394         if(pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode == DOT11_DUAL_MODE)
   3395         {
   3396             /* change site table */
   3397             if(currTable == &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables)
   3398                 currTable = (siteTablesParams_t *)&pSiteMgr->pSitesMgmtParams->dot11A_sitesTables;
   3399             else
   3400                 currTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
   3401         }
   3402         else
   3403             break;
   3404 
   3405     }
   3406 
   3407 
   3408     WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   3409                       ("Exiting getBssidList, site count = %i, length = %d, pData = 0x%X\n",
   3410                       bssidList->NumberOfItems, length, (UINT32)pData));
   3411 
   3412     *pLength = length;
   3413 
   3414     return OK;
   3415 }
   3416 
   3417 /***********************************************************************
   3418  *                        getPrimaryBssid
   3419  ***********************************************************************
   3420 DESCRIPTION:    Called by the OS abstraction layer in order to get the BSSID list from the site table
   3421 
   3422 INPUT:      pSiteMgr    -   site mgr handle.
   3423 
   3424 OUTPUT:     bssidList   -   BSSID list pointer
   3425 
   3426 RETURN:
   3427 
   3428 ************************************************************************/
   3429 static TI_STATUS getPrimaryBssid(siteMgr_t *pSiteMgr, OS_802_11_BSSID_EX *primaryBssid, UINT32 *pLength)
   3430 {
   3431     siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
   3432     UINT32                  len, firstOFDMloc = 0;
   3433     OS_802_11_FIXED_IEs     *pFixedIes;
   3434     OS_802_11_VARIABLE_IEs  *pVarIes;
   3435     UINT32                  length;
   3436 
   3437 
   3438     if ((primaryBssid==NULL) || (pLength==NULL))
   3439     {
   3440         *pLength = 0;
   3441         WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   3442                           ("getPrimaryBssid, one of the ptr is NULL, primaryBssid=%p,pLength=%p  \n",
   3443                            primaryBssid, pLength));
   3444         return NOK;
   3445 
   3446     }
   3447 
   3448     if (pPrimarySite==NULL)
   3449     {
   3450         *pLength = 0;
   3451         WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   3452                           ("getPrimaryBssid, pPrimarySite is NULL \n"));
   3453         return NOK;
   3454 
   3455     }
   3456     length = pPrimarySite->beaconLength + sizeof(OS_802_11_BSSID_EX) + sizeof(OS_802_11_FIXED_IEs);
   3457     if (length > *pLength)
   3458     {
   3459         WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   3460                           ("getPrimaryBssid, insufficient length,  required length=%d, pLength=%d \n",
   3461                            length, *pLength));
   3462         *pLength = length;
   3463 
   3464         return NOK;
   3465     }
   3466 
   3467     WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Entering getPrimaryBssid, length = %d\n", *pLength));
   3468 
   3469     primaryBssid->Length = length;
   3470     /* MacAddress */
   3471     os_memoryCopy(pSiteMgr->hOs, (void *)primaryBssid->MacAddress, (void *)&(pPrimarySite->bssid.addr), MAC_ADDR_LEN);
   3472 
   3473     /* Capabilities */
   3474     primaryBssid->Union.Capabilities = pPrimarySite->capabilities;
   3475 
   3476     /* SSID */
   3477     os_memoryZero(pSiteMgr->hOs, &(primaryBssid->Ssid.Ssid), MAX_SSID_LEN);
   3478     if (pPrimarySite->ssid.len > MAX_SSID_LEN)
   3479     {
   3480         pPrimarySite->ssid.len = MAX_SSID_LEN;
   3481     }
   3482     os_memoryCopy(pSiteMgr->hOs, (void *)primaryBssid->Ssid.Ssid, (void *)&(pPrimarySite->ssid.ssidString), pPrimarySite->ssid.len);
   3483     primaryBssid->Ssid.SsidLength = pPrimarySite->ssid.len;
   3484 
   3485     /* privacy */
   3486     primaryBssid->Privacy = pPrimarySite->privacy;
   3487 
   3488     /* RSSI */
   3489     primaryBssid->Rssi = pPrimarySite->rssi;
   3490 
   3491     /* NetworkTypeInUse & SupportedRates */
   3492     /* SupportedRates */
   3493     os_memoryZero(pSiteMgr->hOs, (void *)primaryBssid->SupportedRates, sizeof(OS_802_11_RATES_EX));
   3494 
   3495     bitMapToNetworkStringRates(pPrimarySite->rateMask.supportedRateMask,
   3496                                pPrimarySite->rateMask.basicRateMask,
   3497                                (UINT8 *)primaryBssid->SupportedRates,
   3498                                &len, &firstOFDMloc);
   3499 
   3500     /* set network type acording to band and rates */
   3501     if (pPrimarySite->channel <= SITE_MGR_CHANNEL_B_G_MAX)
   3502     {
   3503         if (firstOFDMloc == len)
   3504         {
   3505             primaryBssid->NetworkTypeInUse = os802_11DS;
   3506         } else {
   3507             primaryBssid->NetworkTypeInUse = os802_11OFDM24;
   3508         }
   3509     } else {
   3510         primaryBssid->NetworkTypeInUse = os802_11OFDM5;
   3511     }
   3512 
   3513     /* Configuration */
   3514     primaryBssid->Configuration.Length = sizeof(OS_802_11_CONFIGURATION);
   3515     primaryBssid->Configuration.BeaconPeriod = pPrimarySite->beaconInterval;
   3516     primaryBssid->Configuration.ATIMWindow = pPrimarySite->atimWindow;
   3517     primaryBssid->Configuration.Union.channel = Chan2Freq(pPrimarySite->channel);
   3518 
   3519     primaryBssid->Configuration.FHConfig.Length = sizeof(OS_802_11_CONFIGURATION_FH);
   3520     primaryBssid->Configuration.FHConfig.DwellTime = pPrimarySite->FHParams.dwellTime;
   3521     primaryBssid->Configuration.FHConfig.HopPattern = pPrimarySite->FHParams.hopPattern;
   3522     primaryBssid->Configuration.FHConfig.HopSet = pPrimarySite->FHParams.hopSet;
   3523 
   3524     /* InfrastructureMode */
   3525     if  (pPrimarySite->bssType == BSS_INDEPENDENT)
   3526         primaryBssid->InfrastructureMode = os802_11IBSS;
   3527     else
   3528         primaryBssid->InfrastructureMode = os802_11Infrastructure;
   3529 
   3530 
   3531 
   3532     primaryBssid->IELength = 0;
   3533 
   3534     /* copy fixed IEs from site entry */
   3535     pFixedIes = (OS_802_11_FIXED_IEs*)&primaryBssid->IEs[primaryBssid->IELength];
   3536     os_memoryCopy(pSiteMgr->hOs, (void *)pFixedIes->TimeStamp, (void *)&pPrimarySite->localTimeStamp, sizeof(pPrimarySite->localTimeStamp));
   3537     pFixedIes->BeaconInterval = pPrimarySite->beaconInterval;
   3538     pFixedIes->Capabilities = pPrimarySite->capabilities;
   3539     primaryBssid->IELength += sizeof(OS_802_11_FIXED_IEs);
   3540     pVarIes = (OS_802_11_VARIABLE_IEs*)&primaryBssid->IEs[primaryBssid->IELength];
   3541 
   3542     /* Coppy all variable IEs */
   3543     WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   3544                             ("Coppy all variable beaconLength=%d, IELength=%d\n",
   3545                              pPrimarySite->beaconLength, primaryBssid->IELength));
   3546     WLAN_REPORT_HEX_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   3547                                 pPrimarySite->beaconBuffer, pPrimarySite->beaconLength);
   3548 
   3549     os_memoryCopy(pSiteMgr->hOs, pVarIes, pPrimarySite->beaconBuffer, pPrimarySite->beaconLength);
   3550 
   3551     primaryBssid->IELength += pPrimarySite->beaconLength;
   3552 
   3553 
   3554     primaryBssid->Length = sizeof(OS_802_11_BSSID_EX) + primaryBssid->IELength - 1;
   3555 
   3556     WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   3557                             ("BSSID MAC = %x-%x-%x-%x-%x-%x\n",
   3558                              primaryBssid->MacAddress[0], primaryBssid->MacAddress[1], primaryBssid->MacAddress[2],
   3559                              primaryBssid->MacAddress[3], primaryBssid->MacAddress[4], primaryBssid->MacAddress[5]));
   3560 
   3561 
   3562     WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   3563                             ("primaryBssid is\n"));
   3564     WLAN_REPORT_HEX_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   3565                                 (UINT8*)primaryBssid, primaryBssid->Length);
   3566 
   3567 
   3568     WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   3569                       ("Exiting getBssidList, length =%d, IELength=%d \n",
   3570                        primaryBssid->Length,
   3571                        primaryBssid->IELength));
   3572 
   3573     *pLength = primaryBssid->Length;
   3574 
   3575     return OK;
   3576 }
   3577 
   3578 /***********************************************************************
   3579  *                        siteMgr_printPrimarySiteDesc
   3580  ***********************************************************************
   3581 DESCRIPTION:    Called by the OS abstraction layer in order to get the primary site description
   3582 
   3583 INPUT:      pSiteMgr            -   site mgr handle.
   3584             supplyExtendedInfo  - If OS_802_11_BSSID_EX structure should be used (extended info)
   3585                                   (Assuming that if this function is called with TRUE, enough memory was allocated to hold the extended info)
   3586 
   3587 OUTPUT:     pPrimarySiteDesc    -   Primary site description pointer
   3588 
   3589 RETURN:
   3590 
   3591 ************************************************************************/
   3592 void siteMgr_printPrimarySiteDesc(TI_HANDLE hSiteMgr )
   3593 {
   3594     siteMgr_t *pSiteMgr = (siteMgr_t*) hSiteMgr;
   3595 #ifdef REPORT_LOG
   3596     siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
   3597     macAddress_t *bssid = &pPrimarySite->bssid;
   3598 #endif
   3599 
   3600     WLAN_REPORT_INFORMATION( pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   3601                              ("-- SSID  = %s \n",pPrimarySite->ssid.ssidString) );
   3602     WLAN_REPORT_INFORMATION( pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   3603                              ("-- BSSID = %02X-%02X-%02X-%02X-%02X-%02X\n",
   3604                               bssid->addr[0], bssid->addr[1], bssid->addr[2],
   3605                               bssid->addr[3], bssid->addr[4], bssid->addr[5]) );
   3606 }
   3607 
   3608 /***********************************************************************
   3609  *                        getPrimarySiteDesc
   3610  ***********************************************************************
   3611 DESCRIPTION:    Called by the OS abstraction layer in order to get the primary site description
   3612 
   3613 INPUT:      pSiteMgr            -   site mgr handle.
   3614             supplyExtendedInfo  - If OS_802_11_BSSID_EX structure should be used (extended info)
   3615                                   (Assuming that if this function is called with TRUE, enough memory was allocated to hold the extended info)
   3616 
   3617 OUTPUT:     pPrimarySiteDesc    -   Primary site description pointer
   3618 
   3619 RETURN:
   3620 
   3621 ************************************************************************/
   3622 static void getPrimarySiteDesc(siteMgr_t *pSiteMgr, OS_802_11_BSSID *pPrimarySiteDesc, BOOL supplyExtendedInfo)
   3623 {
   3624     siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
   3625     OS_802_11_BSSID_EX *pExPrimarySiteDesc = (OS_802_11_BSSID_EX *) pPrimarySiteDesc;
   3626     UINT32  len, firstOFDMloc = 0;
   3627     OS_802_11_FIXED_IEs     *pFixedIes;
   3628     OS_802_11_VARIABLE_IEs  *pVarIes;
   3629     UINT8 rsnIeLength,index;
   3630     OS_802_11_RATES_EX  SupportedRates;
   3631 
   3632 
   3633     if (pPrimarySiteDesc == NULL)
   3634     {
   3635         return;
   3636     }
   3637     if (pPrimarySite == NULL)
   3638     {
   3639         os_memoryZero(pSiteMgr->hOs, pPrimarySiteDesc, sizeof(OS_802_11_BSSID));
   3640         return;
   3641     }
   3642 
   3643     WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   3644                             ("getPrimarySiteDesc - enter\n"));
   3645 
   3646 
   3647     /* If an "extended" request has been made - update the length accordingly */
   3648    if (supplyExtendedInfo == FALSE)
   3649     pPrimarySiteDesc->Length = sizeof(OS_802_11_BSSID);
   3650    else
   3651     pPrimarySiteDesc->Length = sizeof(OS_802_11_BSSID_EX);
   3652 
   3653     /* MacAddress */
   3654     os_memoryCopy(pSiteMgr->hOs, (void *)pPrimarySiteDesc->MacAddress, (void *)&(pPrimarySite->bssid.addr), MAC_ADDR_LEN);
   3655 
   3656     /* Capabilities */
   3657     pPrimarySiteDesc->Union.Capabilities = pPrimarySite->capabilities;
   3658 
   3659     /* SSID */
   3660     os_memoryCopy(pSiteMgr->hOs, (void *)&(pPrimarySiteDesc->Ssid.Ssid[0]), (void *)&(pPrimarySite->ssid.ssidString[0]), pPrimarySite->ssid.len);
   3661     pPrimarySiteDesc->Ssid.SsidLength = pPrimarySite->ssid.len;
   3662 
   3663     /* privacy */
   3664     pPrimarySiteDesc->Privacy = pPrimarySite->privacy;
   3665 
   3666     /* RSSI */
   3667 
   3668     pPrimarySiteDesc->Rssi = pPrimarySite->rssi;
   3669 
   3670 	bitMapToNetworkStringRates(pPrimarySite->rateMask.supportedRateMask,
   3671 							   pPrimarySite->rateMask.basicRateMask,
   3672 							   &SupportedRates[0],
   3673 							   &len, &firstOFDMloc);
   3674 
   3675     /* set network type acording to band and rates */
   3676     if (pPrimarySite->channel <= SITE_MGR_CHANNEL_B_G_MAX)
   3677     {
   3678         if (firstOFDMloc == len)
   3679         {
   3680             pPrimarySiteDesc->NetworkTypeInUse = os802_11DS;
   3681         } else {
   3682             pPrimarySiteDesc->NetworkTypeInUse = os802_11OFDM24;
   3683         }
   3684     } else {
   3685         pPrimarySiteDesc->NetworkTypeInUse = os802_11OFDM5;
   3686     }
   3687 
   3688 
   3689     pPrimarySiteDesc->Configuration.Length = sizeof(OS_802_11_CONFIGURATION);
   3690     pPrimarySiteDesc->Configuration.BeaconPeriod = pPrimarySite->beaconInterval;
   3691     pPrimarySiteDesc->Configuration.ATIMWindow = pPrimarySite->atimWindow;
   3692     pPrimarySiteDesc->Configuration.Union.channel = pPrimarySite->channel;
   3693 
   3694     pPrimarySiteDesc->Configuration.FHConfig.Length = sizeof(OS_802_11_CONFIGURATION_FH);
   3695     pPrimarySiteDesc->Configuration.FHConfig.DwellTime = pPrimarySite->FHParams.dwellTime;
   3696     pPrimarySiteDesc->Configuration.FHConfig.HopPattern = pPrimarySite->FHParams.hopPattern;
   3697     pPrimarySiteDesc->Configuration.FHConfig.HopSet = pPrimarySite->FHParams.hopSet;
   3698 
   3699     if  (pPrimarySite->bssType == BSS_INDEPENDENT)
   3700         pPrimarySiteDesc->InfrastructureMode = os802_11IBSS;
   3701     else
   3702         pPrimarySiteDesc->InfrastructureMode = os802_11Infrastructure;
   3703 
   3704    /* SupportedRates */
   3705    if (supplyExtendedInfo == FALSE)
   3706       os_memoryZero(pSiteMgr->hOs, (void *)pPrimarySiteDesc->SupportedRates, sizeof(OS_802_11_RATES));
   3707    else
   3708       os_memoryZero(pSiteMgr->hOs, (void *)pPrimarySiteDesc->SupportedRates, sizeof(OS_802_11_RATES_EX));
   3709 
   3710 
   3711    if (supplyExtendedInfo == FALSE)
   3712        os_memoryCopy(pSiteMgr->hOs, (void *)pPrimarySiteDesc->SupportedRates, (void *)SupportedRates, sizeof(OS_802_11_RATES));
   3713    else
   3714        os_memoryCopy(pSiteMgr->hOs, (void *)pPrimarySiteDesc->SupportedRates, (void *)SupportedRates, sizeof(OS_802_11_RATES_EX));
   3715 
   3716 
   3717    if (supplyExtendedInfo == TRUE)
   3718    {
   3719       pExPrimarySiteDesc->IELength = 0;
   3720 
   3721      /* copy fixed IEs from site entry */
   3722      pFixedIes = (OS_802_11_FIXED_IEs*)&pExPrimarySiteDesc->IEs[pExPrimarySiteDesc->IELength];
   3723      os_memoryCopy(pSiteMgr->hOs, (void *)pFixedIes->TimeStamp, (void *)&pPrimarySite->localTimeStamp, sizeof(pPrimarySite->localTimeStamp));
   3724      pFixedIes->BeaconInterval = pPrimarySite->beaconInterval;
   3725      pFixedIes->Capabilities = pPrimarySite->capabilities;
   3726      pExPrimarySiteDesc->IELength += sizeof(OS_802_11_FIXED_IEs);
   3727 
   3728      /* copy variable IEs */
   3729      /* copy SSID */
   3730      pVarIes = (OS_802_11_VARIABLE_IEs*)&pExPrimarySiteDesc->IEs[pExPrimarySiteDesc->IELength];
   3731      pVarIes->ElementID = SSID_IE_ID;
   3732      pVarIes->Length = pPrimarySite->ssid.len;
   3733      os_memoryCopy(pSiteMgr->hOs, (void *)pVarIes->data, (void *)pPrimarySite->ssid.ssidString, pPrimarySite->ssid.len);
   3734      pExPrimarySiteDesc->IELength += (pVarIes->Length + 2);
   3735 
   3736      /* copy RATES */
   3737 
   3738      pVarIes = (OS_802_11_VARIABLE_IEs*)&pExPrimarySiteDesc->IEs[pExPrimarySiteDesc->IELength];
   3739      pVarIes->ElementID = SUPPORTED_RATES_IE_ID;
   3740      bitMapToNetworkStringRates(pPrimarySite->rateMask.supportedRateMask, pPrimarySite->rateMask.basicRateMask,
   3741                                 (UINT8 *)pVarIes->data, &len, &firstOFDMloc);
   3742      pVarIes->Length = len;
   3743      pExPrimarySiteDesc->IELength += (pVarIes->Length + 2);
   3744 
   3745      /* copy FH */
   3746      pVarIes = (OS_802_11_VARIABLE_IEs*)&pExPrimarySiteDesc->IEs[pExPrimarySiteDesc->IELength];
   3747      pVarIes->ElementID = FH_PARAMETER_SET_IE_ID;
   3748      pVarIes->Length = DOT11_FH_PARAMS_ELE_LEN;
   3749      os_memoryCopy(pSiteMgr->hOs, (void *)pVarIes->data, (void *)&pPrimarySite->FHParams.dwellTime, sizeof(pPrimarySite->FHParams.dwellTime));
   3750      os_memoryCopy(pSiteMgr->hOs, (void *)&pVarIes->data[2], (void *)&pPrimarySite->FHParams.hopSet, sizeof(pPrimarySite->FHParams.hopSet));
   3751      os_memoryCopy(pSiteMgr->hOs, (void *)&pVarIes->data[3], (void *)&pPrimarySite->FHParams.hopPattern, sizeof(pPrimarySite->FHParams.hopPattern));
   3752      pVarIes->data[4] = 1;
   3753      pExPrimarySiteDesc->IELength += (pVarIes->Length + 2);
   3754 
   3755      /* copy DS */
   3756      pVarIes = (OS_802_11_VARIABLE_IEs*)&pExPrimarySiteDesc->IEs[pExPrimarySiteDesc->IELength];
   3757      pVarIes->ElementID = DS_PARAMETER_SET_IE_ID;
   3758      pVarIes->Length = DOT11_DS_PARAMS_ELE_LEN;
   3759      os_memoryCopy(pSiteMgr->hOs, (void *)pVarIes->data, (void *)&pPrimarySite->channel, DOT11_DS_PARAMS_ELE_LEN);
   3760      pExPrimarySiteDesc->IELength += (pVarIes->Length + 2);
   3761 
   3762      /* copy RSN information elements */
   3763      rsnIeLength = 0;
   3764      for (index=0; index<MAX_RSN_IE && pPrimarySite->pRsnIe[index].hdr.eleLen>0; index++)
   3765        {
   3766             pVarIes =  (OS_802_11_VARIABLE_IEs*)&pExPrimarySiteDesc->IEs[pExPrimarySiteDesc->IELength+rsnIeLength];
   3767          pVarIes->ElementID = pPrimarySite->pRsnIe[index].hdr.eleId;
   3768              pVarIes->Length = pPrimarySite->pRsnIe[index].hdr.eleLen;
   3769              os_memoryCopy(pSiteMgr->hOs, (void *)pVarIes->data, (void *)pPrimarySite->pRsnIe[index].rsnIeData, pPrimarySite->pRsnIe[index].hdr.eleLen);
   3770              rsnIeLength += pPrimarySite->pRsnIe[index].hdr.eleLen+2;
   3771             WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   3772                                     ("RSN IE ID=%d, Length=%x\n", pVarIes->ElementID, pVarIes->Length));
   3773 
   3774             WLAN_REPORT_HEX_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG, (UINT8 *)pVarIes->data,pVarIes->Length);
   3775          }
   3776 
   3777          pExPrimarySiteDesc->IELength += pPrimarySite->rsnIeLen;
   3778 
   3779          pExPrimarySiteDesc->Length = sizeof(OS_802_11_BSSID_EX) + pExPrimarySiteDesc->IELength - 1;
   3780 
   3781          WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   3782                                  ("BSSID MAC = %x-%x-%x-%x-%x-%x\n",
   3783                                   pExPrimarySiteDesc->MacAddress[0], pExPrimarySiteDesc->MacAddress[1], pExPrimarySiteDesc->MacAddress[2],
   3784                                   pExPrimarySiteDesc->MacAddress[3], pExPrimarySiteDesc->MacAddress[4], pExPrimarySiteDesc->MacAddress[5]));
   3785 
   3786          WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   3787                                  ("pExPrimarySiteDesc length before alignment = %d\n", pExPrimarySiteDesc->Length));
   3788 
   3789          /* make sure length is 4 bytes aligned */
   3790          if (pExPrimarySiteDesc->Length % 4)
   3791          {
   3792             pExPrimarySiteDesc->Length += (4 - (pExPrimarySiteDesc->Length % 4));
   3793          }
   3794 
   3795          WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   3796                                  ("pExPrimarySiteDesc length after alignment = %d\n", pExPrimarySiteDesc->Length));
   3797 
   3798         }
   3799 
   3800 }
   3801 
   3802 
   3803 /***********************************************************************
   3804  *                        translateRateMaskToValue
   3805  ***********************************************************************
   3806 DESCRIPTION:    Called by the function 'siteMgr_config()' in order to translate the rate mask read
   3807                 from registry to rate value
   3808 
   3809 INPUT:      pSiteMgr            -   site mgr handle.
   3810             rateMask            -   Rate mask
   3811 
   3812 OUTPUT:     The rate after the translation
   3813 
   3814 RETURN:
   3815 
   3816 ************************************************************************/
   3817 static rate_e translateRateMaskToValue(siteMgr_t *pSiteMgr, UINT32 rateMask)
   3818 {
   3819     if (rateMask & DRV_RATE_MASK_54_OFDM)
   3820         return DRV_RATE_54M;
   3821     if (rateMask & DRV_RATE_MASK_48_OFDM)
   3822         return DRV_RATE_48M;
   3823     if (rateMask & DRV_RATE_MASK_36_OFDM)
   3824         return DRV_RATE_36M;
   3825     if (rateMask & DRV_RATE_MASK_24_OFDM)
   3826         return DRV_RATE_24M;
   3827     if (rateMask & DRV_RATE_MASK_22_PBCC)
   3828         return DRV_RATE_22M;
   3829     if (rateMask & DRV_RATE_MASK_18_OFDM)
   3830         return DRV_RATE_18M;
   3831     if (rateMask & DRV_RATE_MASK_12_OFDM)
   3832         return DRV_RATE_12M;
   3833     if (rateMask & DRV_RATE_MASK_11_CCK)
   3834         return DRV_RATE_11M;
   3835     if (rateMask & DRV_RATE_MASK_9_OFDM)
   3836         return DRV_RATE_9M;
   3837     if (rateMask & DRV_RATE_MASK_6_OFDM)
   3838         return DRV_RATE_6M;
   3839     if (rateMask & DRV_RATE_MASK_5_5_CCK)
   3840         return DRV_RATE_5_5M;
   3841     if (rateMask & DRV_RATE_MASK_2_BARKER)
   3842         return DRV_RATE_2M;
   3843     if (rateMask & DRV_RATE_MASK_1_BARKER)
   3844         return DRV_RATE_1M;
   3845 
   3846     WLAN_REPORT_WARNING(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Translate rate mask to value, mask is 0x%X\n", rateMask));
   3847     if(pSiteMgr->siteMgrOperationalMode != DOT11_A_MODE)
   3848         return DRV_RATE_1M;
   3849     else
   3850         return DRV_RATE_6M;
   3851 }
   3852 
   3853 
   3854 /***********************************************************************
   3855  *                        getSupportedRateSet
   3856  ***********************************************************************
   3857 DESCRIPTION:    Called by the function 'siteMgr_getParam()' in order to get the supported rate set
   3858                 Build an array of network rates based on the max active & max basic rates
   3859 
   3860 INPUT:      pSiteMgr            -   site mgr handle.
   3861 
   3862 OUTPUT:     pRatesSet           -   The array built
   3863 
   3864 RETURN:
   3865 
   3866 ************************************************************************/
   3867 static void getSupportedRateSet(siteMgr_t *pSiteMgr, rates_t *pRatesSet)
   3868 {
   3869     UINT32 dontCareParam;
   3870     UINT32 len = 0;
   3871 
   3872     bitMapToNetworkStringRates(pSiteMgr->pDesiredParams->siteMgrRegstrySuppRateMask,
   3873                                pSiteMgr->pDesiredParams->siteMgrRegstryBasicRateMask,
   3874                                (UINT8 *)pRatesSet->ratesString, &len, &dontCareParam);
   3875 
   3876     pRatesSet->len = (UINT8) len;
   3877 }
   3878 
   3879 /***********************************************************************
   3880  *                        setSupportedRateSet
   3881  ***********************************************************************
   3882 DESCRIPTION:    Called by the function 'siteMgr_setParam()' in order to set the supported rate set
   3883                 Go over the input array and set the max active & max basic rates. (after translation from network
   3884                 rates to host rates ofcourse)
   3885                 If max basic rate is bigger than the mac active one, print an error.
   3886                 If the basic or active rate are different than the ones already stored by the site manager,
   3887                 it returns RE_SCAN_NEEDED
   3888 
   3889 INPUT:      pSiteMgr            -   site mgr handle.
   3890             pRatesSet           -   The rates array received
   3891 
   3892 OUTPUT:
   3893 
   3894 RETURN:     RE_SCAN_NEEDED if re scan is needed, OK on success
   3895 
   3896 ************************************************************************/
   3897 static TI_STATUS setSupportedRateSet(siteMgr_t *pSiteMgr, rates_t *pRatesSet)
   3898 {
   3899     UINT8  i,j, drvRate;
   3900     rate_e maxActiveRate = (rate_e)0, maxBasicRate = (rate_e)0;
   3901     UINT32 suppBitMap, basicBitMap;
   3902     static  rate_e basicRates_G[]  = {DRV_RATE_1M,DRV_RATE_2M,DRV_RATE_5_5M,DRV_RATE_11M};
   3903     static rate_e basicRates_A[]  = {DRV_RATE_6M,DRV_RATE_12M,DRV_RATE_24M};
   3904     rate_e* currentBasicRates;
   3905     UINT32 currentBasicRatesLength;
   3906 
   3907 #ifndef NET_BASIC_MASK
   3908 #define NET_BASIC_MASK      0x80    /* defined in common/src/utils/utils.c */
   3909 #endif
   3910 
   3911     if(pSiteMgr->siteMgrOperationalMode == DOT11_A_MODE)
   3912     {
   3913         currentBasicRates = &basicRates_A[0];
   3914         currentBasicRatesLength = sizeof(basicRates_A) / sizeof(basicRates_A[0]);
   3915     }
   3916     else
   3917     {
   3918         currentBasicRates = &basicRates_G[0];
   3919         currentBasicRatesLength = sizeof(basicRates_G) / sizeof(basicRates_G[0]);
   3920     }
   3921 
   3922         /* Basic rates must be supported. If one of 1M,2M,5.5M,11M is not supported fail.*/
   3923 
   3924     for (j=0;j < currentBasicRatesLength;j++)
   3925     {
   3926         for (i = 0; i < pRatesSet->len; i++)
   3927         {
   3928             drvRate = utilityToHostRate(pRatesSet->ratesString[i]);
   3929             if ((drvRate & ( NET_BASIC_MASK-1)) == currentBasicRates[j])
   3930                 break;
   3931         }
   3932         /* not all the basic rates are supported! Failure*/
   3933         if (i == pRatesSet->len)
   3934         {
   3935             WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Rates set must contain the basic set! Failing\n"));
   3936             return PARAM_VALUE_NOT_VALID;
   3937         }
   3938     }
   3939 
   3940     for (i = 0; i < pRatesSet->len; i++)
   3941     {
   3942         drvRate = utilityToHostRate(pRatesSet->ratesString[i]);
   3943         if(pSiteMgr->siteMgrOperationalMode == DOT11_A_MODE)
   3944         {
   3945             if(drvRate < DRV_RATE_6M)
   3946             {
   3947                 WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Notice, the driver configured in 11a mode, but CCK rate appears\n"));
   3948                 return PARAM_VALUE_NOT_VALID;
   3949             }
   3950         }
   3951         else if(pSiteMgr->siteMgrOperationalMode == DOT11_B_MODE)
   3952         {
   3953             if(drvRate >= DRV_RATE_6M)
   3954             {
   3955                 WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Notice, the driver configured in 11b mode, but OFDM rate appears\n"));
   3956                 return PARAM_VALUE_NOT_VALID;
   3957             }
   3958         }
   3959         maxActiveRate = MAX((rate_e)drvRate, maxActiveRate);
   3960     }
   3961 
   3962     for (i = 0; i < pRatesSet->len; i++)
   3963     {
   3964         if (IS_BASIC_RATE(pRatesSet->ratesString[i]))
   3965             maxBasicRate = MAX(utilityToHostRate(pRatesSet->ratesString[i]), maxBasicRate);
   3966     }
   3967 
   3968     /* If the basic rate is bigger than the supported one, we print an error */
   3969     if (pSiteMgr->pDesiredParams->siteMgrDesiredRatePair.maxBasic > pSiteMgr->pDesiredParams->siteMgrDesiredRatePair.maxActive)
   3970     {
   3971         WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("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));
   3972         return PARAM_VALUE_NOT_VALID;
   3973     }
   3974 
   3975     pSiteMgr->pDesiredParams->siteMgrDesiredRatePair.maxActive = maxActiveRate;
   3976     pSiteMgr->pDesiredParams->siteMgrDesiredRatePair.maxBasic = maxBasicRate;
   3977 
   3978 
   3979     /* configure desired modulation */
   3980     if(maxActiveRate == DRV_RATE_22M)
   3981         pSiteMgr->pDesiredParams->siteMgrDesiredModulationType = DRV_MODULATION_PBCC;
   3982     else if(maxActiveRate < DRV_RATE_22M)
   3983         pSiteMgr->pDesiredParams->siteMgrDesiredModulationType = DRV_MODULATION_CCK;
   3984     else
   3985         pSiteMgr->pDesiredParams->siteMgrDesiredModulationType = DRV_MODULATION_OFDM;
   3986 
   3987 
   3988     networkStringToBitMapSuppRates(&suppBitMap,
   3989                                    (UINT8 *)pRatesSet->ratesString,
   3990                                    pRatesSet->len);
   3991 
   3992     networkStringToBitMapBasicRates(&basicBitMap,
   3993                                     (UINT8 *)pRatesSet->ratesString,
   3994                                     pRatesSet->len);
   3995 
   3996     if((pSiteMgr->pDesiredParams->siteMgrRegstryBasicRateMask != basicBitMap) ||
   3997        (pSiteMgr->pDesiredParams->siteMgrRegstrySuppRateMask != suppBitMap))
   3998     {
   3999         pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask = suppBitMap;
   4000         pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask = basicBitMap;
   4001         pSiteMgr->pDesiredParams->siteMgrRegstryBasicRateMask = basicBitMap;
   4002         pSiteMgr->pDesiredParams->siteMgrRegstrySuppRateMask = suppBitMap;
   4003         /* Initialize Mutual Rates Matching */
   4004         pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask = pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask;
   4005         pSiteMgr->pDesiredParams->siteMgrMatchedSuppRateMask = pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask;
   4006         pSiteMgr->pDesiredParams->siteMgrMatchedMaxBasicRate = getMaxRatefromBitmap(pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask);
   4007         pSiteMgr->pDesiredParams->siteMgrMatchedMaxActiveRate = getMaxRatefromBitmap(pSiteMgr->pDesiredParams->siteMgrMatchedSuppRateMask);
   4008 
   4009         return RE_SCAN_NEEDED;
   4010     }
   4011 
   4012     return OK;
   4013 }
   4014 
   4015 /***********************************************************************
   4016  *                        pbccAlgorithm
   4017  ***********************************************************************
   4018 DESCRIPTION:    Called by the following functions:
   4019                 -   systemConfig(), in the system configuration phase after the selection
   4020                 -   siteMgr_updateSite(), in a case of a primary site update & if a PBCC algorithm
   4021                     is needed to be performed
   4022                 Performs the PBCC algorithm
   4023 
   4024 
   4025 INPUT:      hSiteMgr            -   site mgr handle.
   4026 
   4027 OUTPUT:
   4028 
   4029 RETURN:     OK on always
   4030 
   4031 ************************************************************************/
   4032 TI_STATUS pbccAlgorithm(TI_HANDLE hSiteMgr)
   4033 {
   4034     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   4035     paramInfo_t param;
   4036     siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
   4037     UINT32      bitMap = 0;
   4038     BOOL        desiredTxRateSupported = FALSE;
   4039     UINT32      supportedRateMask ;
   4040 
   4041 
   4042     /* First set the data modulation. */
   4043     param.paramType = CTRL_DATA_CURRENT_MODULATION_TYPE_PARAM;                  /* Current Modulation Type */
   4044     param.content.ctrlDataCurrentModulationType = pSiteMgr->currentDataModulation;
   4045     ctrlData_setParam(pSiteMgr->hCtrlData, &param);
   4046 
   4047     if (pPrimarySite->channel == SPECIAL_BG_CHANNEL)
   4048         supportedRateMask = (getSupportedRateMaskForSpecialBGchannel() & pSiteMgr->pDesiredParams->siteMgrMatchedSuppRateMask) ;
   4049     else
   4050         supportedRateMask = pSiteMgr->pDesiredParams->siteMgrMatchedSuppRateMask ;
   4051 
   4052     validateDesiredTxRate(pSiteMgr->pDesiredParams->siteMgrCurrentDesiredTxRate,
   4053                           pSiteMgr->currentDataModulation,
   4054                           supportedRateMask,
   4055                           &bitMap,
   4056                           &desiredTxRateSupported);
   4057 
   4058     if(desiredTxRateSupported == FALSE)
   4059     {
   4060         WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Notice, the rates configuration is invalid, desired tx rate is not supported => switched to auto"));
   4061         pSiteMgr->pDesiredParams->siteMgrCurrentDesiredTxRate = DRV_RATE_AUTO;
   4062     }
   4063 
   4064     param.paramType = CTRL_DATA_CURRENT_SUPPORTED_RATE_MASK_PARAM;
   4065     param.content.ctrlDataCurrentRateMask = supportedRateMask;
   4066     /* clear the 22Mbps bit in case the PBCC is not allowed */
   4067     if(pSiteMgr->currentDataModulation != DRV_MODULATION_PBCC &&
   4068        pSiteMgr->currentDataModulation != DRV_MODULATION_OFDM)
   4069             param.content.ctrlDataCurrentRateMask &= ~DRV_RATE_MASK_22_PBCC;
   4070     ctrlData_setParam(pSiteMgr->hCtrlData, &param);
   4071 
   4072     param.paramType = CTRL_DATA_CURRENT_ACTIVE_RATE_PARAM;
   4073 
   4074     param.content.ctrlDataCurrentActiveRate = pSiteMgr->pDesiredParams->siteMgrCurrentDesiredTxRate;
   4075     ctrlData_setParam(pSiteMgr->hCtrlData, &param);
   4076 
   4077     /*
   4078      * NOTE: THIS MUST BE AFTER SETTING PREAMBLE TYPE
   4079      */
   4080 
   4081     if (pSiteMgr->pDesiredParams->siteMgrCurrentDesiredTxRate == DRV_RATE_AUTO)
   4082     {
   4083         param.paramType = CTRL_DATA_RATE_CONTROL_ENABLE_PARAM;
   4084         param.content.ctrlDataRateControlEnable = TRUE;
   4085         ctrlData_setParam(pSiteMgr->hCtrlData, &param);
   4086     }
   4087     else
   4088     {
   4089         param.paramType = CTRL_DATA_RATE_CONTROL_ENABLE_PARAM;
   4090         param.content.ctrlDataRateControlEnable = FALSE;
   4091         ctrlData_setParam(pSiteMgr->hCtrlData, &param);
   4092     }
   4093 
   4094     return OK;
   4095 }
   4096 
   4097 /***********************************************************************
   4098  *                        validateDesiredTxRate
   4099  ***********************************************************************
   4100 DESCRIPTION:    Called by the following functions:
   4101                 -   pbccAlgorithm()
   4102 
   4103 
   4104 INPUT:      desiredTxRate           -   configured desired tx rate.
   4105             desiredModulation       -   configured desired tx modulation.
   4106             suppRates               -   rates, supported by both STA and primary site.
   4107 
   4108 OUTPUT:     bitMap                  -   rates bit map to be set to the ctrlData module
   4109             txDesiredRateSupported  -   indication whether the desired tx rate supported
   4110                                         by both STA and the primary site.
   4111 RETURN:     OK on always
   4112 
   4113 ************************************************************************/
   4114 void validateDesiredTxRate(rate_e desiredTxRate, modulationType_e desiredModulation,
   4115                            UINT32 suppRates, UINT32 *bitMap, BOOL *txDesiredRateSupported)
   4116 {
   4117 
   4118     UINT32  maskTable[DRV_RATE_MAX+1] =
   4119                                         {DRV_RATE_MASK_AUTO,
   4120                                          DRV_RATE_MASK_1_BARKER,
   4121                                          DRV_RATE_MASK_2_BARKER,
   4122                                          DRV_RATE_MASK_5_5_CCK,
   4123                                          DRV_RATE_MASK_11_CCK,
   4124                                          DRV_RATE_MASK_22_PBCC
   4125                                          ,DRV_RATE_MASK_6_OFDM,
   4126                                          DRV_RATE_MASK_9_OFDM,
   4127                                          DRV_RATE_MASK_12_OFDM,
   4128                                          DRV_RATE_MASK_18_OFDM,
   4129                                          DRV_RATE_MASK_24_OFDM,
   4130                                          DRV_RATE_MASK_36_OFDM,
   4131                                          DRV_RATE_MASK_48_OFDM,
   4132                                          DRV_RATE_MASK_54_OFDM
   4133                                         };
   4134 
   4135     if(desiredModulation != DRV_MODULATION_PBCC)
   4136     {
   4137         if(desiredTxRate == DRV_RATE_22M)
   4138             *bitMap = DRV_RATE_MASK_11_CCK;
   4139         else
   4140             *bitMap = maskTable[desiredTxRate];
   4141     }
   4142     else
   4143         *bitMap = maskTable[desiredTxRate];
   4144 
   4145     if((suppRates & maskTable[desiredTxRate]) || (desiredTxRate == DRV_RATE_AUTO))
   4146         *txDesiredRateSupported = TRUE;
   4147     else
   4148         *txDesiredRateSupported = FALSE;
   4149 }
   4150 
   4151 /***********************************************************************
   4152  *                        siteMgr_assocReport
   4153  ***********************************************************************
   4154 DESCRIPTION:    Called by the following functions:
   4155                 -   assoc_recv()
   4156 
   4157 
   4158 INPUT:      hSiteMgr            -   siteMgr handle.
   4159             capabilities        -   assoc rsp capabilities field.
   4160 			bCiscoAP			-   whether we are connected to a Cisco AP. Used for Tx Power Control adjustment
   4161 OUTPUT:
   4162 
   4163 RETURN:     OK on always
   4164 
   4165 ************************************************************************/
   4166 TI_STATUS siteMgr_assocReport(TI_HANDLE hSiteMgr, UINT16 capabilities, BOOL bCiscoAP)
   4167 {
   4168     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   4169     siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
   4170 
   4171     /* handle AP's preamble capability */
   4172     pPrimarySite->preambleAssRspCap = ((capabilities >> CAP_PREAMBLE_SHIFT) & CAP_PREAMBLE_MASK)  ? PREAMBLE_SHORT : PREAMBLE_LONG;
   4173 
   4174 	/*
   4175 	 * Enable/Disable the ATx Power Control adjustment.
   4176 	 * When we are connected to Cisco AP - TX Power Control adjustment is disabled.
   4177 	 */
   4178 	pSiteMgr->bTempTxPowerEnabled = ( !bCiscoAP ) && ( pSiteMgr->pDesiredParams->TxPowerControlOn );
   4179 
   4180 	WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   4181 		("%s: Tx Power Control adjustment is %d\n",__FUNCTION__, pSiteMgr->bTempTxPowerEnabled));
   4182 
   4183     return OK;
   4184 }
   4185 
   4186 /***********************************************************************
   4187  *                        siteMgr_setWMEParamsSite
   4188  ***********************************************************************
   4189 DESCRIPTION:    Set the WME params as received from the associated
   4190                 AP. The function is called by the QoS Mgr
   4191                 after receving association response succefully.
   4192 
   4193 INPUT:      hSiteMgr    -   SiteMgr handle.
   4194 
   4195 OUTPUT:     pDot11_WME_PARAM_t - pointer to the WME Param IE.
   4196 
   4197 RETURN:     OK on always
   4198 
   4199 ************************************************************************/
   4200 TI_STATUS siteMgr_setWMEParamsSite(TI_HANDLE hSiteMgr,dot11_WME_PARAM_t *pDot11_WME_PARAM)
   4201 {
   4202     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   4203     siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
   4204 
   4205     if( pPrimarySite == NULL )
   4206     {
   4207         return OK;
   4208     }
   4209 
   4210     if( pDot11_WME_PARAM == NULL )
   4211     {
   4212         pPrimarySite->WMESupported = FALSE;
   4213         return OK;
   4214     }
   4215 
   4216     /* Update the WME params */
   4217     os_memoryCopy(pSiteMgr->hOs,&pPrimarySite->WMEParameters,&pDot11_WME_PARAM->WME_ACParameteres,sizeof(ACParameters_t));
   4218     pPrimarySite->lastWMEParameterCnt = (pDot11_WME_PARAM->ACInfoField & dot11_WME_ACINFO_MASK);
   4219     WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,("$$$$$$ WME parameters were updates according to association response, cntSeq = %d\n",pPrimarySite->lastWMEParameterCnt));
   4220 
   4221     return OK;
   4222 }
   4223 
   4224 
   4225 /***********************************************************************
   4226  *                        siteMgr_getWMEParamsSite
   4227  ***********************************************************************
   4228 DESCRIPTION:    Get the WME params as recieved from the associated
   4229                 AP. The function is called by the Qos Mgr in order
   4230                 to set all WME parameters to the core and Hal
   4231 
   4232 INPUT:      hSiteMgr    -   SiteMgr handle.
   4233 
   4234 OUTPUT:     pWME_ACParameters_t - pointer to the WME Param.
   4235 
   4236 RETURN:     OK if there are valid WME parameters , NOK otherwise.
   4237 
   4238 ************************************************************************/
   4239 TI_STATUS siteMgr_getWMEParamsSite(TI_HANDLE hSiteMgr,ACParameters_t **pWME_ACParameters_t)
   4240 {
   4241     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   4242     siteEntry_t *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
   4243 
   4244     if(pPrimarySite->WMESupported == TRUE)
   4245     {
   4246         *pWME_ACParameters_t = &pPrimarySite->WMEParameters;
   4247         return OK;
   4248     }
   4249     else
   4250     {
   4251         *pWME_ACParameters_t = NULL;
   4252         return NOK;
   4253     }
   4254 
   4255 }
   4256 
   4257 
   4258 
   4259 /***********************************************************************
   4260  *                        calculateBssidListSize
   4261  ***********************************************************************
   4262 DESCRIPTION:    Calculate the size of memory buffer required for BSSID
   4263                 List.
   4264 
   4265 
   4266 INPUT:      hSiteMgr            -   site mgr handle.
   4267 
   4268 OUTPUT:
   4269 
   4270 RETURN:     OK on always
   4271 
   4272 ************************************************************************/
   4273 static TI_STATUS calculateBssidListSize(siteMgr_t *pSiteMgr, UINT32 *pLength, BOOL allVarIes)
   4274 {
   4275     UINT32 siteTableIndex, tableIndex;
   4276     UINT32 length;
   4277     siteEntry_t* pSiteEntry;
   4278     siteTablesParams_t* currTable;
   4279 
   4280     *pLength = sizeof(OS_802_11_BSSID_LIST_EX) - sizeof(OS_802_11_BSSID_EX);
   4281 
   4282     currTable = pSiteMgr->pSitesMgmtParams->pCurrentSiteTable;
   4283 
   4284     for (tableIndex = 0; tableIndex < NUM_OF_SITE_TABLE ; tableIndex++)
   4285     {
   4286         for (siteTableIndex = 0; siteTableIndex < currTable->maxNumOfSites; siteTableIndex++)
   4287         {
   4288             pSiteEntry = (siteEntry_t*)&currTable->siteTable[siteTableIndex];
   4289 
   4290             if (pSiteEntry->siteType != SITE_NULL)
   4291             {
   4292                 if (allVarIes)
   4293                 {
   4294                     length = sizeof(OS_802_11_BSSID_EX) + sizeof(OS_802_11_FIXED_IEs);
   4295                     if (pSiteEntry->probeRecv)
   4296                     {
   4297                         length += pSiteEntry->probeRespLength;
   4298                     }
   4299                     else
   4300                     {
   4301                         length += pSiteEntry->beaconLength;
   4302                     }
   4303 
   4304                 }
   4305                 else
   4306                 {
   4307                     length = (sizeof(OS_802_11_BSSID_EX) + sizeof(OS_802_11_FIXED_IEs) +
   4308                               (pSiteEntry->ssid.len + 2) + (MAX_SUPPORTED_RATES + 2) +
   4309                               (DOT11_FH_PARAMS_ELE_LEN + 2) + (DOT11_DS_PARAMS_ELE_LEN +2) +
   4310                               pSiteEntry->rsnIeLen);
   4311                     /* WME information element by alcel*/
   4312                     if (pSiteEntry->WMESupported)
   4313                     {
   4314                         /* length of element + header*/
   4315                         length += (DOT11_WME_ELE_LEN + 2);
   4316                     }
   4317                 }
   4318 
   4319                 /* make sure length is 4 bytes aligned */
   4320                 if (length % 4)
   4321                 {
   4322                     length += (4 - (length % 4));
   4323                 }
   4324 
   4325                 *pLength += length;
   4326 
   4327                 WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   4328                                         ("BSSID length =%d on table index %d \n", length, tableIndex));
   4329 
   4330             }
   4331         }
   4332 
   4333 
   4334         if(pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode == DOT11_DUAL_MODE)
   4335         {
   4336             /* change site table */
   4337             if(currTable == &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables)
   4338                 currTable = (siteTablesParams_t *)&pSiteMgr->pSitesMgmtParams->dot11A_sitesTables;
   4339             else
   4340                 currTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
   4341         }
   4342         else
   4343             break;
   4344 
   4345     }
   4346 
   4347     return OK;
   4348 }
   4349 
   4350 
   4351 
   4352 
   4353 
   4354 
   4355 
   4356 
   4357 /***********************************************************************
   4358  *                        siteMgr_setCurrentTable
   4359  ***********************************************************************
   4360 DESCRIPTION:
   4361 
   4362 INPUT:      hSiteMgr    -   SiteMgr handle.
   4363 
   4364 OUTPUT:
   4365 
   4366 RETURN:
   4367 
   4368 ************************************************************************/
   4369 void siteMgr_setCurrentTable(TI_HANDLE hSiteMgr, radioBand_e radioBand)
   4370 {
   4371     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   4372 
   4373     if(radioBand == RADIO_BAND_2_4_GHZ)
   4374         pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = &pSiteMgr->pSitesMgmtParams->dot11BG_sitesTables;
   4375     else
   4376         pSiteMgr->pSitesMgmtParams->pCurrentSiteTable = (siteTablesParams_t *)&pSiteMgr->pSitesMgmtParams->dot11A_sitesTables;
   4377 }
   4378 
   4379 
   4380 
   4381 /***********************************************************************
   4382  *                        siteMgr_updateRates
   4383  ***********************************************************************
   4384 DESCRIPTION:
   4385 
   4386 INPUT:      hSiteMgr    -   SiteMgr handle.
   4387 
   4388 OUTPUT:
   4389 
   4390 RETURN:
   4391 
   4392 ************************************************************************/
   4393 
   4394 void siteMgr_updateRates(TI_HANDLE hSiteMgr, BOOL dot11a, BOOL updateToOS)
   4395 {
   4396     UINT32                  statusData;
   4397     rate_e                  txDesiredRate;
   4398     UINT32                  localSuppRateMask, localBasicRateMask;
   4399 
   4400     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   4401 
   4402     localSuppRateMask = pSiteMgr->pDesiredParams->siteMgrRegstrySuppRateMask;
   4403     localBasicRateMask = pSiteMgr->pDesiredParams->siteMgrRegstryBasicRateMask;
   4404 
   4405 
   4406     validateRatesVsBand(&localSuppRateMask, &localBasicRateMask, dot11a);
   4407 
   4408     pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask = localBasicRateMask;
   4409     pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask = localSuppRateMask;
   4410 
   4411      /* Initialize Mutual Rates Matching */
   4412     pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask = pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask;
   4413     pSiteMgr->pDesiredParams->siteMgrMatchedSuppRateMask = pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask;
   4414     pSiteMgr->pDesiredParams->siteMgrMatchedMaxBasicRate = getMaxRatefromBitmap(pSiteMgr->pDesiredParams->siteMgrMatchedBasicRateMask);
   4415     pSiteMgr->pDesiredParams->siteMgrMatchedMaxActiveRate = getMaxRatefromBitmap(pSiteMgr->pDesiredParams->siteMgrMatchedSuppRateMask);
   4416 
   4417 
   4418     /*If we are in dual mode and we are only scanning A band we don't have to set the siteMgrCurrentDesiredTxRate.*/
   4419     if (updateToOS == TRUE)
   4420     {
   4421         /* Validate that the masks and tx rate are OK */
   4422         txDesiredRate = pSiteMgr->pDesiredParams->siteMgrRegstryDesiredTxRate;
   4423 
   4424         validateRates((UINT32 *)&pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask,
   4425                       (UINT32 *)&pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask,
   4426                           (UINT32 *)&txDesiredRate,
   4427                           &pSiteMgr->pDesiredParams->siteMgrDesiredModulationType, dot11a);
   4428 
   4429         pSiteMgr->pDesiredParams->siteMgrCurrentDesiredTxRate = txDesiredRate;
   4430     }
   4431     pSiteMgr->pDesiredParams->siteMgrDesiredRatePair.maxBasic = translateRateMaskToValue(pSiteMgr, pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask);
   4432     pSiteMgr->pDesiredParams->siteMgrDesiredRatePair.maxActive = translateRateMaskToValue(pSiteMgr, pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask);
   4433 
   4434     if (updateToOS == TRUE) {
   4435         /* report the desired rate to OS */
   4436         statusData = hostToUtilityRate(pSiteMgr->pDesiredParams->siteMgrDesiredRatePair.maxActive);
   4437 
   4438         EvHandlerSendEvent(pSiteMgr->hEvHandler, IPC_EVENT_LINK_SPEED, (UINT8 *)&statusData,sizeof(UINT32));
   4439     }
   4440 
   4441 }
   4442 
   4443 /***********************************************************************
   4444  *                        siteMgr_bandParamsConfig
   4445  ***********************************************************************
   4446 DESCRIPTION:
   4447 
   4448 INPUT:      hSiteMgr    -   SiteMgr handle.
   4449 
   4450 OUTPUT:
   4451 
   4452 RETURN:
   4453 
   4454 ************************************************************************/
   4455 void siteMgr_bandParamsConfig(TI_HANDLE hSiteMgr,  BOOL updateToOS)
   4456 {
   4457     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   4458 
   4459     /* reconfig rates */
   4460     if(pSiteMgr->siteMgrOperationalMode == DOT11_A_MODE)
   4461         siteMgr_updateRates(hSiteMgr, TRUE, updateToOS);
   4462     else
   4463         siteMgr_updateRates(hSiteMgr, FALSE, updateToOS);
   4464 
   4465     /* go to B_ONLY Mode only if WiFI bit is Set*/
   4466     if (pSiteMgr->pDesiredParams->siteMgrWiFiAdhoc == TRUE)
   4467     {   /* Configuration For AdHoc when using external configuration */
   4468         if (pSiteMgr->pDesiredParams->siteMgrExternalConfiguration == FALSE)
   4469         {
   4470             siteMgr_externalConfigurationParametersSet(hSiteMgr);
   4471         }
   4472     }
   4473 
   4474 }
   4475 
   4476 void siteMgr_keepAliveSendNullDataTimer(TI_HANDLE hSiteMgr)
   4477 {
   4478     paramInfo_t param;
   4479     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   4480     UINT32      txPacketsCount = 0;
   4481     UINT32      TxQid;
   4482 
   4483     if ((pSiteMgr->pSitesMgmtParams->pPrimarySite != NULL) &&
   4484         (pSiteMgr->pSitesMgmtParams->pPrimarySite->bssType != BSS_INFRASTRUCTURE))
   4485     {   /* No need for kepp alive when not in Infra */
   4486         return;
   4487     }
   4488     param.paramType = TX_DATA_COUNTERS_PARAM;
   4489     txData_getParam(pSiteMgr->hTxData, &param);
   4490     /* get current tx data frames counter */
   4491     for (TxQid = 0; TxQid < MAX_NUM_OF_TX_QUEUES; TxQid++)
   4492         txPacketsCount += param.content.pTxDataCounters[TxQid].XmitOk;
   4493 
   4494     if (pSiteMgr->txPacketsCount==txPacketsCount)
   4495     {  /* send NULL data */
   4496         WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,("siteMgr_keepAliveSendNullDataTimer\n"));
   4497 
   4498         /* sending null frame with power save bit set to off (if keepAliveEnable in the registry)
   4499           Note: the Hardware modify the PS bit according to the current PS mode. */
   4500         if(pSiteMgr->keepAliveEnable == TRUE)
   4501         {
   4502             txData_sendNullFrame(pSiteMgr->hTxData, FALSE, SITE_MGR_MODULE);
   4503         }
   4504         txPacketsCount++;
   4505 
   4506     }
   4507     pSiteMgr->txPacketsCount=txPacketsCount;
   4508 
   4509 }
   4510 
   4511 void siteMgr_ConfigRate(TI_HANDLE hSiteMgr)
   4512 {
   4513     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   4514     BOOL        dot11a;
   4515     dot11mode_e OperationMode ;
   4516 
   4517     OperationMode = pSiteMgr->siteMgrOperationalMode;
   4518 
   4519     /* reconfig rates */
   4520     if(OperationMode == DOT11_A_MODE)
   4521         dot11a = TRUE;
   4522     else
   4523         dot11a = FALSE;
   4524 
   4525     /*
   4526     ** Specific change to ch 14, that channel is only used in Japan, and is limited
   4527     ** to rates 1,2,5.5,11
   4528     */
   4529     if(pSiteMgr->pDesiredParams->siteMgrDesiredChannel == SPECIAL_BG_CHANNEL)
   4530     {
   4531         if(pSiteMgr->pDesiredParams->siteMgrRegstryBasicRate[OperationMode] > BASIC_RATE_SET_1_2_5_5_11)
   4532             pSiteMgr->pDesiredParams->siteMgrRegstryBasicRate[OperationMode] = BASIC_RATE_SET_1_2_5_5_11;
   4533 
   4534 
   4535         if(pSiteMgr->pDesiredParams->siteMgrRegstrySuppRate[OperationMode] > SUPPORTED_RATE_SET_1_2_5_5_11)
   4536             pSiteMgr->pDesiredParams->siteMgrRegstrySuppRate[OperationMode] = SUPPORTED_RATE_SET_1_2_5_5_11;
   4537     }
   4538 
   4539     pSiteMgr->pDesiredParams->siteMgrRegstryBasicRateMask =
   4540         translateBasicRateValueToMask(pSiteMgr->pDesiredParams->siteMgrRegstryBasicRate[OperationMode], dot11a);
   4541 
   4542     pSiteMgr->pDesiredParams->siteMgrRegstrySuppRateMask =
   4543         translateSupportedRateValueToMask(pSiteMgr->pDesiredParams->siteMgrRegstrySuppRate[OperationMode], dot11a);
   4544 
   4545     siteMgr_updateRates(pSiteMgr, dot11a, TRUE);
   4546 
   4547         /* go to B_ONLY Mode only if WiFI bit is Set*/
   4548     if (pSiteMgr->pDesiredParams->siteMgrWiFiAdhoc == TRUE)
   4549     {   /* Configuration For AdHoc when using external configuration */
   4550         if (pSiteMgr->pDesiredParams->siteMgrExternalConfiguration == FALSE)
   4551         {
   4552             siteMgr_externalConfigurationParametersSet(hSiteMgr);
   4553         }
   4554     }
   4555 }
   4556 
   4557 static void siteMgr_externalConfigurationParametersSet(TI_HANDLE hSiteMgr)
   4558 {
   4559     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   4560 
   4561     /* Overwrite the parameters for AdHoc with External Configuration */
   4562 
   4563     if( ((pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode == DOT11_A_MODE) ||
   4564         (pSiteMgr->pDesiredParams->siteMgrDesiredDot11Mode == DOT11_DUAL_MODE)) &&
   4565         !pSiteMgr->pDesiredParams->siteMgrWiFiAdhoc && pSiteMgr->pDesiredParams->siteMgrDesiredBSSType == BSS_INDEPENDENT)
   4566         return;
   4567 
   4568 
   4569     if(pSiteMgr->pDesiredParams->siteMgrDesiredBSSType == BSS_INDEPENDENT)
   4570     {
   4571         pSiteMgr->siteMgrOperationalMode = DOT11_B_MODE;
   4572         pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask = translateBasicRateValueToMask(BASIC_RATE_SET_1_2_5_5_11, FALSE);
   4573         pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask = translateSupportedRateValueToMask(SUPPORTED_RATE_SET_1_2_5_5_11, FALSE);
   4574         pSiteMgr->pDesiredParams->siteMgrCurrentDesiredTxRate = DRV_RATE_AUTO;
   4575         pSiteMgr->pDesiredParams->siteMgrRegstryBasicRateMask = translateBasicRateValueToMask(BASIC_RATE_SET_1_2_5_5_11, FALSE);
   4576         pSiteMgr->pDesiredParams->siteMgrRegstrySuppRateMask = translateSupportedRateValueToMask(SUPPORTED_RATE_SET_1_2_5_5_11, FALSE);
   4577         pSiteMgr->pDesiredParams->siteMgrRegstryDesiredTxRate = DRV_RATE_AUTO;
   4578         pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime = PHY_SLOT_TIME_LONG;
   4579 
   4580         whalCtrl_SetRadioBand(pSiteMgr->hHalCtrl, RADIO_BAND_2_4_GHZ);
   4581         whalCtrl_SetSlotTime(pSiteMgr->hHalCtrl, PHY_SLOT_TIME_LONG);
   4582 
   4583     }
   4584     else
   4585     {
   4586         if(pSiteMgr->radioBand == RADIO_BAND_2_4_GHZ)
   4587             pSiteMgr->siteMgrOperationalMode = DOT11_G_MODE;
   4588         else
   4589             pSiteMgr->siteMgrOperationalMode = DOT11_A_MODE;
   4590         pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.basicRateMask = translateBasicRateValueToMask(BASIC_RATE_SET_1_2_5_5_11, FALSE);
   4591         pSiteMgr->pDesiredParams->siteMgrCurrentDesiredRateMask.supportedRateMask = translateSupportedRateValueToMask(SUPPORTED_RATE_SET_ALL, FALSE);
   4592         pSiteMgr->pDesiredParams->siteMgrCurrentDesiredTxRate = DRV_RATE_AUTO;
   4593         pSiteMgr->pDesiredParams->siteMgrRegstryBasicRateMask = translateBasicRateValueToMask(BASIC_RATE_SET_1_2_5_5_11, FALSE);
   4594         pSiteMgr->pDesiredParams->siteMgrRegstrySuppRateMask = translateSupportedRateValueToMask(SUPPORTED_RATE_SET_ALL, FALSE);
   4595         pSiteMgr->pDesiredParams->siteMgrRegstryDesiredTxRate = DRV_RATE_AUTO;
   4596 
   4597         pSiteMgr->pDesiredParams->siteMgrDesiredSlotTime = PHY_SLOT_TIME_LONG;
   4598 
   4599         whalCtrl_SetSlotTime(pSiteMgr->hHalCtrl, PHY_SLOT_TIME_LONG);
   4600     }
   4601 }
   4602 
   4603 void siteMgr_checkTxPower(TI_HANDLE hSiteMgr)
   4604 {
   4605     siteMgr_t           *pSiteMgr = (siteMgr_t *)hSiteMgr;
   4606 
   4607     if ( (pSiteMgr->pSitesMgmtParams->pPrimarySite) && (pSiteMgr->bTempTxPowerEnabled)
   4608         && (++pSiteMgr->siteMgrTxPowerCheckTime >= pSiteMgr->pDesiredParams->TxPowerCheckTime) )
   4609         {
   4610             pSiteMgr->siteMgrTxPowerCheckTime = 0; /* reset counter for next check */
   4611 
   4612             WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   4613                 ("%s: RSSI = %d TxPowerRssiThresh = %d TxPowerRssiRestoreThresh = %D\n",
   4614 				__FUNCTION__, pSiteMgr->pSitesMgmtParams->pPrimarySite->rssi,
   4615 				pSiteMgr->pDesiredParams->TxPowerRssiThresh,pSiteMgr->pDesiredParams->TxPowerRssiRestoreThresh));
   4616 
   4617         if ((pSiteMgr->pSitesMgmtParams->pPrimarySite->rssi) >= (INT32) (0 - pSiteMgr->pDesiredParams->TxPowerRssiThresh))
   4618         {
   4619             /* activate Tx Power Control adjustment */
   4620 			siteMgr_setTemporaryTxPower(pSiteMgr, TRUE);
   4621         }
   4622         else if (pSiteMgr->pSitesMgmtParams->pPrimarySite->rssi <= (INT32) (0 - pSiteMgr->pDesiredParams->TxPowerRssiRestoreThresh))
   4623         {
   4624 			/* deactivate Tx Power Control adjustment */
   4625 			siteMgr_setTemporaryTxPower(pSiteMgr, FALSE);
   4626         }
   4627     }
   4628 }
   4629 
   4630 TI_STATUS siteMgr_saveProbeRespBuffer(TI_HANDLE hSiteMgr, macAddress_t  *bssid, UINT8 *pProbeRespBuffer, UINT32 length)
   4631 {
   4632     siteEntry_t *pSite;
   4633     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   4634 
   4635     if ((pSiteMgr==NULL) || (pProbeRespBuffer==NULL) || (length>=MAX_MGMT_BODY_LENGTH))
   4636     {
   4637         return NOK;
   4638     }
   4639 
   4640     pSite = findSiteEntry(pSiteMgr, bssid);
   4641     if (pSite==NULL)
   4642     {
   4643         /*WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   4644                           ("siteMgr_saveProbeRespBuffer: site doesn't exist\n"));*/
   4645         return NOK;
   4646 
   4647     }
   4648 
   4649     os_memoryCopy(pSiteMgr->hOs, pSite->probeRespBuffer, pProbeRespBuffer, length);
   4650     pSite->osTimeStamp = os_timeStampMs(pSiteMgr->hOs);
   4651     pSite->probeRespLength = length;
   4652 
   4653     WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   4654                           ("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",
   4655                            pSite->bssid.addr[0], pSite->bssid.addr[1], pSite->bssid.addr[2],
   4656                            pSite->bssid.addr[3], pSite->bssid.addr[4], pSite->bssid.addr[5],
   4657                            pSite->tsfTimeStamp[0], pSite->tsfTimeStamp[1], pSite->tsfTimeStamp[2], pSite->tsfTimeStamp[3],
   4658                            pSite->tsfTimeStamp[4], pSite->tsfTimeStamp[5], pSite->tsfTimeStamp[6], pSite->tsfTimeStamp[7],
   4659                            pSite->osTimeStamp,  pSite->rssi, pSite->channel));
   4660 
   4661     return OK;
   4662 }
   4663 
   4664 TI_STATUS siteMgr_saveBeaconBuffer(TI_HANDLE hSiteMgr, macAddress_t *bssid, UINT8 *pBeaconBuffer, UINT32 length)
   4665 {
   4666     siteEntry_t *pSite;
   4667     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   4668 
   4669     if ((pSiteMgr==NULL) || (pBeaconBuffer==NULL) || (length>=MAX_MGMT_BODY_LENGTH))
   4670     {
   4671         return NOK;
   4672     }
   4673 
   4674     pSite = findSiteEntry(pSiteMgr, bssid);
   4675     if (pSite==NULL)
   4676     {
   4677         /*WLAN_REPORT_ERROR(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   4678                           ("siteMgr_saveBeaconBuffer: site doesn't exist\n"));*/
   4679         return NOK;
   4680 
   4681     }
   4682 
   4683     os_memoryCopy(pSiteMgr->hOs, pSite->beaconBuffer, pBeaconBuffer, length);
   4684     pSite->osTimeStamp = os_timeStampMs(pSiteMgr->hOs);
   4685     pSite->beaconLength = length;
   4686 
   4687     /*if (pSiteMgr->pSitesMgmtParams->pPrimarySite!=NULL)
   4688     {
   4689         if (!os_memoryCompare(pSiteMgr->hOs, pSiteMgr->pSitesMgmtParams->pPrimarySite->ssid.ssidString, pSite->ssid.ssidString, pSiteMgr->pSitesMgmtParams->pPrimarySite->ssid.len))
   4690         {
   4691             WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   4692                                   ("siteMgr_saveBeaconBuffer: BSSID=%x-%x-%x-%x-%x-%x, TSF=%x-%x-%x-%x-%x-%x-%x-%x, \n ts=%d, rssi=%d \n",
   4693                                    pSite->bssid.addr[0], pSite->bssid.addr[1], pSite->bssid.addr[2],
   4694                                    pSite->bssid.addr[3], pSite->bssid.addr[4], pSite->bssid.addr[5],
   4695                                    pSite->tsfTimeStamp[0], pSite->tsfTimeStamp[1], pSite->tsfTimeStamp[2], pSite->tsfTimeStamp[3],
   4696                                    pSite->tsfTimeStamp[4], pSite->tsfTimeStamp[5], pSite->tsfTimeStamp[6], pSite->tsfTimeStamp[7],
   4697                                    pSite->osTimeStamp,  pSite->rssi));
   4698         }
   4699     }*/
   4700     pSite->ssid.ssidString[pSite->ssid.len] = '\0';
   4701 
   4702     /*WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   4703                           ("siteMgr_saveBeaconBuffer: BSSID=%x-%x-%x-%x-%x-%x, SSID=%s, \n ts=%d, rssi=%d\n channel = %d \n",
   4704                            pSite->bssid.addr[0], pSite->bssid.addr[1], pSite->bssid.addr[2],
   4705                            pSite->bssid.addr[3], pSite->bssid.addr[4], pSite->bssid.addr[5],
   4706                            pSite->ssid.ssidString, pSite->osTimeStamp,  pSite->rssi, pSite->channel));
   4707 
   4708     */
   4709     return OK;
   4710 }
   4711 
   4712 
   4713 void siteMgr_resetChannelList(TI_HANDLE hSiteMgr)
   4714 {
   4715     UINT8       index;
   4716     siteMgr_t   *pSiteMgr = (siteMgr_t*)hSiteMgr;
   4717 
   4718     if (hSiteMgr==NULL)
   4719     {
   4720         return;
   4721     }
   4722 
   4723     for (index=0; index < pSiteMgr->pSitesMgmtParams->pCurrentSiteTable->maxNumOfSites; index++)
   4724     {
   4725         if (pSiteMgr->pSitesMgmtParams->pCurrentSiteTable->siteTable[index].siteType != SITE_NULL)
   4726         {
   4727             pSiteMgr->pSitesMgmtParams->pCurrentSiteTable->siteTable[index].prioritySite = FALSE;
   4728         }
   4729     }
   4730 
   4731 }
   4732 
   4733 
   4734 siteEntry_t *siteMgr_findSiteEntry(TI_HANDLE hSiteMgrm, macAddress_t *bssid)
   4735 {
   4736     return (findSiteEntry(hSiteMgrm, bssid));
   4737 }
   4738 
   4739 
   4740 
   4741 void siteMgr_IsERP_Needed(TI_HANDLE hSiteMgr,BOOL *useProtection,BOOL *NonErpPresent,BOOL *barkerPreambleType)
   4742 {
   4743     siteMgr_t       *pSiteMgr = (siteMgr_t*)hSiteMgr;
   4744     paramInfo_t     param;
   4745     siteEntry_t     *pPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
   4746 
   4747     *useProtection = FALSE;
   4748     *NonErpPresent = FALSE;
   4749     *barkerPreambleType = FALSE;
   4750 
   4751     param.paramType = CTRL_DATA_CURRENT_IBSS_PROTECTION_PARAM;
   4752     ctrlData_getParam(pSiteMgr->hCtrlData, &param);
   4753 
   4754     /* 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) */
   4755     if (pSiteMgr->pDesiredParams->siteMgrWiFiAdhoc == TRUE)
   4756     {
   4757         /* Return the default => ERP is not needed */
   4758         return;
   4759     }
   4760 
   4761     /* check if STA is connected */
   4762     if (pPrimarySite)
   4763     {
   4764         if(pSiteMgr->siteMgrOperationalMode == DOT11_G_MODE || pSiteMgr->siteMgrOperationalMode == DOT11_DUAL_MODE)
   4765         {
   4766             if(param.content.ctrlDataIbssProtecionType == ERP_PROTECTION_STANDARD)
   4767             {
   4768                 if(pPrimarySite->siteType == SITE_SELF)
   4769                 {
   4770                     if(pPrimarySite->channel <= SITE_MGR_CHANNEL_B_G_MAX) /* if channel B&G*/
   4771                     {
   4772                             *useProtection = TRUE;
   4773                             *NonErpPresent = TRUE;
   4774                             *barkerPreambleType = TRUE;
   4775                     }
   4776                 }
   4777                 else if(pPrimarySite->bssType == BSS_INDEPENDENT)
   4778                 {
   4779                     if(pPrimarySite->useProtection == TRUE)
   4780                         *useProtection = TRUE;
   4781                     if(pPrimarySite->NonErpPresent == TRUE)
   4782                         *NonErpPresent = TRUE;
   4783                     if(pPrimarySite->barkerPreambleType == PREAMBLE_SHORT)
   4784                         *barkerPreambleType = TRUE;
   4785                 }
   4786             }
   4787         }
   4788     }
   4789 }
   4790 
   4791 
   4792 
   4793 
   4794 void siteMgr_gotFirstBcn(TI_HANDLE hSiteMgr)
   4795 {
   4796         siteMgr_t   *pSiteMgr = (siteMgr_t*)hSiteMgr;
   4797         int status ;
   4798 
   4799     WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,
   4800                                 ("siteMgr_gotFirstBcn: dtimPeriod=%d, beaconInterval=%d\n",
   4801                                 pSiteMgr->pSitesMgmtParams->pPrimarySite->dtimPeriod,
   4802                                 pSiteMgr->pSitesMgmtParams->pPrimarySite->beaconInterval));
   4803 
   4804     /* Check if the Beacon Filter Desired State is TRUE */
   4805     pSiteMgr->beaconFilterParams.currentState = TRUE;
   4806     /* If the Beacon Filter was TRUE then send it to FW if not do not do nothing */
   4807     if( TRUE == pSiteMgr->beaconFilterParams.desiredState )
   4808     {
   4809         if ( (status = whalCtrl_SetBeaconFiltering(pSiteMgr->hHalCtrl, pSiteMgr->beaconFilterParams.desiredState, pSiteMgr->beaconFilterParams.numOfStored)) != OK)
   4810         {
   4811             WLAN_REPORT_INFORMATION(pSiteMgr->hReport,
   4812                               POWER_MANAGER_MODULE_LOG,
   4813                               ("%s(%d) - Error N.%d in configuring beacon filtering !\n",
   4814                               __FILE__,__LINE__,status));
   4815         }
   4816         else
   4817         {
   4818             WLAN_REPORT_INFORMATION(pSiteMgr->hReport,SITE_MGR_MODULE_LOG , ("--          Beacon Filter Enable Beacon Filtering MIB Was Sent to FW !!!  --\n"));
   4819         }
   4820     }
   4821     else
   4822     {
   4823             WLAN_REPORT_INFORMATION(pSiteMgr->hReport,SITE_MGR_MODULE_LOG , ("--          Beacon Filter Disable Beacon Filtering - Do not send to FW Already Disabled !!!  --\n"));
   4824     }
   4825 
   4826     whalCtrl_setDtimPeriod(pSiteMgr->hHalCtrl, pSiteMgr->pSitesMgmtParams->pPrimarySite->dtimPeriod,
   4827                             pSiteMgr->pSitesMgmtParams->pPrimarySite->beaconInterval);
   4828 
   4829     /* The power mode configuration gets overridden by the above DTIM period */
   4830     /* configuration. We use this call to send it again to the firmware. */
   4831     PowerMgr_reloadPowerMode(pSiteMgr->hPowerMgr);
   4832 }
   4833 
   4834 void siteMgr_clearFirstBcnFlag(TI_HANDLE hSiteMgr)
   4835 {
   4836     siteMgr_t   *pSiteMgr = (siteMgr_t*)hSiteMgr;
   4837 
   4838     /* This is set to FALSE since the First Beaqcin should be received for the first beacon mechanism */
   4839 	pSiteMgr->beaconFilterParams.currentState = FALSE;
   4840 	whalCtrl_SetBeaconFiltering(pSiteMgr->hHalCtrl, FALSE, pSiteMgr->beaconFilterParams.numOfStored);
   4841 
   4842 
   4843     /* set Hw available until we get the first beacon */
   4844     MacServices_powerAutho_AwakeRequiredUpdate(pSiteMgr->hMacServices, POWERAUTHO_AWAKE_REQUIRED, POWERAUTHO_AWAKE_REASON_FIRST_BEACON);
   4845 
   4846     if(pSiteMgr->pSitesMgmtParams->pPrimarySite != NULL)
   4847         pSiteMgr->pSitesMgmtParams->pPrimarySite->beaconReceiveAfterJoin = FALSE;
   4848 }
   4849 
   4850 void siteMgr_setFirstBcnFlag(TI_HANDLE hSiteMgr)
   4851 {
   4852     siteMgr_t   *pSiteMgr = (siteMgr_t*)hSiteMgr;
   4853 
   4854     /* set Hw not available until now that the connection was closed */
   4855     MacServices_powerAutho_AwakeRequiredUpdate(pSiteMgr->hMacServices, POWERAUTHO_AWAKE_NOT_REQUIRED, POWERAUTHO_AWAKE_REASON_FIRST_BEACON);
   4856 
   4857     if(pSiteMgr->pSitesMgmtParams->pPrimarySite != NULL)
   4858         pSiteMgr->pSitesMgmtParams->pPrimarySite->beaconReceiveAfterJoin = TRUE;
   4859 }
   4860 
   4861 /**
   4862 *
   4863 * siteMgr_overwritePrimarySite
   4864 *
   4865 * \b Description:
   4866 *
   4867 * This function sets new AP as a primary site and, if requested, stores previous
   4868 * AP's info; called during roaming
   4869 *
   4870 * \b ARGS:
   4871 *
   4872 *  I   - pCurrBSS - Current BSS handle \n
   4873 *
   4874 * \b RETURNS:
   4875 *
   4876 *  OK on success, NOK on failure.
   4877 *
   4878 * \sa
   4879 */
   4880 TI_STATUS siteMgr_overwritePrimarySite(TI_HANDLE hSiteMgr, bssEntry_t *newAP, BOOL requiredToStorePrevSite)
   4881 {
   4882     siteMgr_t   *pSiteMgr = (siteMgr_t *)hSiteMgr;
   4883     siteEntry_t *newApEntry;
   4884     mlmeIEParsingParams_t *ieListParseParams = mlmeParser_getParseIEsBuffer(pSiteMgr->hMlmeSm);
   4885 
   4886     WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("siteMgr_overwritePrimarySite: new site bssid= 0x%x-0x%x-0x%x-0x%x-0x%x-0x%x\n\n",
   4887                newAP->BSSID.addr[0], newAP->BSSID.addr[1], newAP->BSSID.addr[2],
   4888                newAP->BSSID.addr[3], newAP->BSSID.addr[4], newAP->BSSID.addr[5]));
   4889 
   4890     /* If previous primary site present, and requested to save it - store it */
   4891     if (requiredToStorePrevSite)
   4892     {
   4893         WLAN_REPORT_INFORMATION(pSiteMgr->hReport,
   4894                                 SITE_MGR_MODULE_LOG,
   4895                                 ("siteMgr_overwritePrimarySite: required to store prev prim site \n"));
   4896         /* Store latest primary site, make ite a regular site */
   4897         pSiteMgr->pSitesMgmtParams->pPrevPrimarySite = pSiteMgr->pSitesMgmtParams->pPrimarySite;
   4898         pSiteMgr->pSitesMgmtParams->pPrevPrimarySite->siteType = SITE_REGULAR;
   4899     }
   4900     else
   4901     {
   4902         WLAN_REPORT_INFORMATION(pSiteMgr->hReport,
   4903                                 SITE_MGR_MODULE_LOG,
   4904                                 ("siteMgr_overwritePrimarySite: not required to store prev prim site \n"));
   4905         if (pSiteMgr->pSitesMgmtParams->pPrimarySite != NULL)
   4906         {
   4907             WLAN_REPORT_INFORMATION(pSiteMgr->hReport, SITE_MGR_MODULE_LOG,  ("Removing Primary ssid=%s, bssid= 0x%x-0x%x-0x%x-0x%x-0x%x-0x%x\n\n",
   4908             pSiteMgr->pSitesMgmtParams->pPrimarySite->ssid.ssidString,
   4909             pSiteMgr->pSitesMgmtParams->pPrimarySite->bssid.addr[0], pSiteMgr->pSitesMgmtParams->pPrimarySite->bssid.addr[1], pSiteMgr->pSitesMgmtParams->pPrimarySite->bssid.addr[2],
   4910             pSiteMgr->pSitesMgmtParams->pPrimarySite->bssid.addr[3], pSiteMgr->pSitesMgmtParams->pPrimarySite->bssid.addr[4], pSiteMgr->pSitesMgmtParams->pPrimarySite->bssid.addr[5] ));
   4911 
   4912             pSiteMgr->pSitesMgmtParams->pPrimarySite->siteType  = SITE_REGULAR;
   4913             pSiteMgr->pSitesMgmtParams->pPrimarySite->beaconRecv = FALSE;
   4914             pSiteMgr->pSitesMgmtParams->pPrimarySite->beaconReceiveAfterJoin = TRUE;
   4915 
   4916             pSiteMgr->pSitesMgmtParams->pPrimarySite = NULL;
   4917         }
   4918         else
   4919         {
   4920             WLAN_REPORT_ERROR(pSiteMgr->hReport,
   4921                                     SITE_MGR_MODULE_LOG,
   4922                                     ("siteMgr_overwritePrimarySite: primary site is NULL \n"));
   4923         }
   4924 
   4925     }
   4926 
   4927     /* Find not occupied entry in site table, and store new AP BSSID in */
   4928     /* If pPrimarySite is not set to NULL, store it in pPrevSite before updating */
   4929     newApEntry = findAndInsertSiteEntry(pSiteMgr, &(newAP->BSSID), newAP->band);
   4930 
   4931     if (newApEntry != NULL)
   4932     {
   4933         /* Zero frame content */
   4934         os_memoryZero(pSiteMgr->hOs, ieListParseParams, sizeof(mlmeIEParsingParams_t));
   4935 
   4936         /* Update parameters of new AP */
   4937         newApEntry->rssi            = newAP->RSSI;
   4938         newApEntry->bssType         = BSS_INFRASTRUCTURE;
   4939         newApEntry->dtimPeriod      = 1;
   4940         newApEntry->rxRate          = (rate_e)newAP->rxRate;
   4941         /* Mark the site as regular in order to prevent from calling Power manager during beacon parsing */
   4942         newApEntry->siteType        = SITE_REGULAR;
   4943 
   4944         os_memoryCopy(pSiteMgr->hOs, &newApEntry->ssid, &pSiteMgr->pDesiredParams->siteMgrDesiredSSID, sizeof(ssid_t));
   4945 
   4946         if (newAP->resultType == SCAN_RFT_PROBE_RESPONSE)
   4947         {
   4948             ieListParseParams->frame.subType = PROBE_RESPONSE;
   4949             siteMgr_saveProbeRespBuffer(hSiteMgr, &(newAP->BSSID), newAP->pBuffer, newAP->bufferLength);
   4950         }
   4951         else
   4952         {
   4953             ieListParseParams->frame.subType = BEACON;
   4954             siteMgr_saveBeaconBuffer(hSiteMgr, &(newAP->BSSID), newAP->pBuffer, newAP->bufferLength);
   4955         }
   4956         ieListParseParams->band = newAP->band;
   4957         ieListParseParams->rxChannel = newAP->channel;
   4958         ieListParseParams->myBssid = FALSE;
   4959 
   4960         ieListParseParams->frame.content.iePacket.pRsnIe = NULL;
   4961         ieListParseParams->frame.content.iePacket.rsnIeLen = 0;
   4962         ieListParseParams->frame.content.iePacket.barkerPreambleMode = PREAMBLE_UNSPECIFIED;
   4963         os_memoryCopy(pSiteMgr->hOs, (void *)ieListParseParams->frame.content.iePacket.timestamp, (void *)&newAP->lastRxTSF, TIME_STAMP_LEN);
   4964         ieListParseParams->frame.content.iePacket.beaconInerval     = newAP->beaconInterval;
   4965         ieListParseParams->frame.content.iePacket.capabilities  = newAP->capabilities;
   4966 
   4967         if (mlmeParser_parseIEs(pSiteMgr->hMlmeSm, newAP->pBuffer, newAP->bufferLength, ieListParseParams) != OK)
   4968         {
   4969             /* Error in parsing Probe response packet - exit */
   4970             return NOK;
   4971         }
   4972 
   4973         siteMgr_updateSite(hSiteMgr, &(newAP->BSSID), &ieListParseParams->frame, newAP->channel, newAP->band, FALSE);
   4974 
   4975         /* Select the entry as primary site */
   4976         newApEntry->siteType = SITE_PRIMARY;
   4977         pSiteMgr->pSitesMgmtParams->pPrimarySite = newApEntry;
   4978         return OK;
   4979     }
   4980     else
   4981     {
   4982         return NOK;
   4983     }
   4984 }
   4985 
   4986 #if 0
   4987 /***********************************************************************
   4988                 siteMgr_updateLowPriorityTimeout
   4989  ***********************************************************************
   4990 DESCRIPTION: Call to the PowerCtrl with the new claculated low priority
   4991              timeout that is depend on the:
   4992              - short/long doze.
   4993              - beacon filtering number.
   4994              - beacon interval.
   4995 
   4996 INPUT:      hSiteMgr    -   site mgr handle.
   4997 
   4998 OUTPUT:
   4999 
   5000 RETURN:     UINT32 - the timeout in mSec.
   5001 
   5002 ************************************************************************/
   5003 static void siteMgr_updateLowPriorityTimeout(TI_HANDLE hSiteMgr)
   5004 {
   5005     siteMgr_t *pSiteMgr = (siteMgr_t*)hSiteMgr;
   5006     UINT32 lowPriorityTimeout = 0;
   5007 
   5008     if(pSiteMgr->pDesiredParams->siteMgrDesiredBSSType == BSS_INDEPENDENT)
   5009     {
   5010         lowPriorityTimeout = SITE_MGR_IBSS_AGING_TIMEOUT_DEF;
   5011     }
   5012     else
   5013     {
   5014         /*
   5015         If the pPrimarySite is NULL then we cannot update the aging timeout
   5016         */
   5017         if (pSiteMgr->pSitesMgmtParams->pPrimarySite == NULL)
   5018         {
   5019             WLAN_REPORT_ERROR(pSiteMgr->hReport,
   5020                               SITE_MGR_MODULE_LOG,
   5021                               ("there is NO primary site! pPrimarySite is NULL\n"));
   5022             return;
   5023         }
   5024         else
   5025         {
   5026             /*
   5027             in shortDoze and active mode the system behaviour is the same as regarding to
   5028             beacon evnets. On each beacon the TNET is awake and should received the beacon
   5029             */
   5030             if(pSiteMgr->powerSaveLdMode == FALSE)
   5031             {
   5032                 lowPriorityTimeout = pSiteMgr->pSitesMgmtParams->pPrimarySite->beaconInterval;
   5033             }
   5034             else
   5035             /*
   5036             In longDoze, the interval time should based on  numOfBeaconFiltering * Dtim interval
   5037             */
   5038             {
   5039                 /*
   5040                 if beacon filtering disable.
   5041                 */
   5042                 if ( 0 == pSiteMgr->numOfBeaconFiltering )
   5043                 {
   5044                     lowPriorityTimeout = pSiteMgr->pSitesMgmtParams->pPrimarySite->dtimPeriod * pSiteMgr->pSitesMgmtParams->pPrimarySite->beaconInterval;
   5045                 }
   5046                 else
   5047                 {
   5048                     lowPriorityTimeout = pSiteMgr->numOfBeaconFiltering * pSiteMgr->pSitesMgmtParams->pPrimarySite->dtimPeriod * pSiteMgr->pSitesMgmtParams->pPrimarySite->beaconInterval;
   5049                 }
   5050             }
   5051 
   5052             WLAN_REPORT_INFORMATION(pSiteMgr->hReport,
   5053                                     SITE_MGR_MODULE_LOG,
   5054                                     ("siteMgr_calcLowPriorityTimeout: lowPriorityTimeout = %d, BeaconInterval = %d, DtimPeriod = %d,powerSaveLdMode = %d, numOfBeaconFiltering = %d\n",
   5055                                     lowPriorityTimeout,
   5056                                     pSiteMgr->pSitesMgmtParams->pPrimarySite->beaconInterval,
   5057                                     pSiteMgr->pSitesMgmtParams->pPrimarySite->dtimPeriod,
   5058                                     pSiteMgr->powerSaveLdMode,
   5059                                     pSiteMgr->numOfBeaconFiltering));
   5060         }
   5061     }
   5062 
   5063     if (lowPriorityTimeout != 0)
   5064     {
   5065 #ifdef NO_HAL_VOB
   5066         whalCtrl_setLowPriorityTimeout(pSiteMgr->hHalCtrl,
   5067                                        lowPriorityTimeout);
   5068 #endif
   5069     }
   5070     else
   5071     {
   5072         WLAN_REPORT_ERROR(pSiteMgr->hReport,
   5073                           SITE_MGR_MODULE_LOG,
   5074                           ("illegal lowPriorityTimeout (=%d), configuration ABORTED!\n",lowPriorityTimeout));
   5075     }
   5076 }
   5077 
   5078 #endif
   5079