1 /** \file currBss.c 2 * \brief Current BSS info 3 * 4 * \see currBss.h 5 */ 6 /**************************************************************************** 7 **+-----------------------------------------------------------------------+** 8 **| |** 9 **| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved. |** 10 **| All rights reserved. |** 11 **| |** 12 **| Redistribution and use in source and binary forms, with or without |** 13 **| modification, are permitted provided that the following conditions |** 14 **| are met: |** 15 **| |** 16 **| * Redistributions of source code must retain the above copyright |** 17 **| notice, this list of conditions and the following disclaimer. |** 18 **| * Redistributions in binary form must reproduce the above copyright |** 19 **| notice, this list of conditions and the following disclaimer in |** 20 **| the documentation and/or other materials provided with the |** 21 **| distribution. |** 22 **| * Neither the name Texas Instruments nor the names of its |** 23 **| contributors may be used to endorse or promote products derived |** 24 **| from this software without specific prior written permission. |** 25 **| |** 26 **| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |** 27 **| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |** 28 **| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |** 29 **| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |** 30 **| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |** 31 **| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |** 32 **| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |** 33 **| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |** 34 **| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |** 35 **| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |** 36 **| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |** 37 **| |** 38 **+-----------------------------------------------------------------------+** 39 ****************************************************************************/ 40 41 /**************************************************************************** 42 * * 43 * MODULE: Current BSS * 44 * PURPOSE: * 45 * Roaming ability of eSTA is implemented by Roaming Manager Component and 46 * described in "Roaming Manager module LLD" document, and by 47 * AP Connection module. AP Connection module implemented as two sub-modules. 48 * The major one is AP Connection, that is responsible for: 49 * - providing Roaming Manager with access to other parts of WLAN Driver, 50 * - implementing low levels of roaming mechanism. 51 * Current BSS sub-module takes care of: 52 * - maintaining database of current AP info, 53 * - providing access to database of current AP info. 54 * The Current BSS represents the BSS we are currently connected to. 55 * Among other parameters, it holds the capabilities of the current AP, 56 * its ID and its quality. 57 * When FW indicates 'Out of Sync' event, Current BSS module is responsible 58 * for awaking the device, sending unicast Probe request, waiting for 59 * response and - in case FW comes to the conclusion that there was 60 * no response - for triggering "Beacon missed" to AP Connection module. 61 * In eSTA5.0 FW updates and checks the quality of the connection with 62 * current AP. Current BSS module is responsible to handle event of type 63 * 'Low RSSI' from FW. Third type of roaming event reported by FW is 64 * 'Consecutive no ack on TX", and it is handled as well by Current 65 * BSS module.Upon reception of any roaming event from FW, Current BSS 66 * module is transferring this event to the AP Connection module in case 67 * of BSS connection, or to SME module in case of IBSS connection. 68 * When WLAN driver is working in IBSS mode, Current BSS module is holding 69 * the parameters of BSS (channel, band, SSID etc.). 70 * * 71 ****************************************************************************/ 72 73 #include "currBss.h" 74 #include "osApi.h" 75 #include "paramIn.h" 76 #include "report.h" 77 #include "802_11Defs.h" 78 #include "utils.h" 79 #include "memMngrEx.h" 80 #include "DataCtrl_Api.h" 81 #include "qosMngr_API.h" 82 #include "regulatoryDomainApi.h" 83 #include "apConn.h" 84 #include "scanMngrApi.h" 85 #include "MacServices_api.h" 86 #include "smeApi.h" 87 #include "smeSmApi.h" 88 #include "TNETW_Driver_types.h" 89 90 /* Constants */ 91 92 #define NUM_PACKETS_4_CONN_LIVENESS 2 93 94 /* Enumerations */ 95 96 97 /* Typedefs */ 98 99 typedef UINT8 (*currBSS_beaconRxCallb_t) (TI_HANDLE hModule, UINT64 staTSF, UINT8 dtimCount); 100 101 102 /* Structures */ 103 104 /** 105 * Current BSS control block 106 * Following structure defines parameters that can be configured externally, 107 * internal variables, and handlers of other modules used by Current BSS module 108 */ 109 typedef struct _currBSS_t 110 { 111 /* Internal variables and configurable parameters */ 112 bssType_e type; /**< Set by SME module; EBSS, IBSS or none */ 113 radioBand_e band; /**< Set by SME module */ 114 UINT8 channel; /**< Set by AP Connection, SME and Switch Channel modules */ 115 UINT8 numOfPktsInRevivalTest; /**< Set by AP Connection; nmber of Probe Request Packets sent when 'Out of sync' suspected */ 116 BOOLEAN fwIsOutOfSync; /**< TRUE if 'Out of Sync' event received */ 117 BOOLEAN isConnected; /**< Default: not connected */ 118 bssEntry_t currAPInfo; /**< Set by SME upon request from AP Connection */ 119 UINT8 snr; /**< Value of SNR of last management packet received form the current AP */ 120 UINT8 snrFilterWeight; /**< The weigh for average SNR value of management packets received form the current AP */ 121 BOOLEAN rssiBelowThrReported; /**< Set to TRUE whem low RSSI threshold crossed */ 122 BOOLEAN rssiAboveThrReported; /**< Set to TRUE whem high RSSI threshold crossed */ 123 INT8 averageRssi; /**< Average value of RSSI of management packets received form the current AP */ 124 INT8 lowRssiThreshold; /**< Indicator used to increase the background scan period when quality is low */ 125 INT8 highRssiThreshold; /**< Indicator used to reduce the background scan period when quality is normal */ 126 UINT8 rssiFilterWeight; /**< The weigh for average RSSI value of management packets received form the current AP */ 127 BOOLEAN bUseSGParams; /**< Whether to use the Soft Gemini compensation on the roaming triggers (currently: BSS Loss) */ 128 /**< This compensation is needed since BT Activity might over-run beacons */ 129 UINT8 numExpectedTbttForBSSLoss; /**< last configured value without Soft Gemini compensation */ 130 UINT32 SGcompensationPercent; /*< the percentage of increasing the TbttForBSSLoss value when SG is enabled */ 131 132 /* Handlers of other modules used by AP Connection */ 133 TI_HANDLE hOs; 134 TI_HANDLE hPowerMngr; 135 TI_HANDLE hAPConn; 136 TI_HANDLE hSme; 137 TI_HANDLE hHal; 138 TI_HANDLE hMlme; 139 TI_HANDLE hReport; 140 TI_HANDLE hRegulatoryDomain; 141 TI_HANDLE hMemMgr; 142 TI_HANDLE hTxData; 143 TI_HANDLE hSiteMgr; 144 TI_HANDLE hScanMngr; 145 TI_HANDLE hMacServices; 146 } currBSS_t; 147 148 149 /* Internal functions prototypes */ 150 151 static void currBSS_lowRssiThrCrossed(currBSS_t *hCurrBSS, UINT8 *data, UINT8 dataLength); 152 static void currBSS_lowSnrThrCrossed(currBSS_t *hCurrBSS, UINT8 *data, UINT8 dataLength); 153 static void currBSS_consecTxErrors(currBSS_t *hCurrBSS, UINT8 *data, UINT8 dataLength); 154 static void currBSS_outOfSync(currBSS_t *hCurrBSS, UINT8 *data, UINT8 dataLength); 155 static void currBSS_reviveConnection(currBSS_t *hCurrBSS); 156 static void currBSS_terminateOutOfSyncMode(currBSS_t *pCurrBSS); 157 static void currBSS_beaconMissed(currBSS_t *hCurrBSS, UINT8 *data, UINT8 dataLength); 158 static void currBSS_sendUnicastProbeRequest(currBSS_t *pCurrBSS); 159 static void currBSS_reportRoamingEvent(currBSS_t *hCurrBSS, apConn_roamingTrigger_e roamingEventType, roamingEventData_u *pRoamingEventData); 160 static void currBSS_updateBSSLoss(currBSS_t *pCurrBSS); 161 162 /* Public functions implementation */ 163 164 165 /** 166 * 167 * currBSS_create 168 * 169 * \b Description: 170 * 171 * Create the Current BSS context: allocate memory for internal variables 172 * 173 * \b ARGS: 174 * 175 * I - hOS - the handle to the OS object 176 * 177 * \b RETURNS: 178 * 179 * OK on success, NOK on failure. 180 * 181 * \sa 182 */ 183 TI_HANDLE currBSS_create(TI_HANDLE hOs) 184 { 185 currBSS_t *pCurrBss; 186 187 if ((pCurrBss = os_memoryAlloc(hOs, sizeof(currBSS_t))) != NULL) 188 { 189 pCurrBss->hOs = hOs; 190 191 return pCurrBss; 192 } 193 else /* Failed to allocate control block */ 194 { 195 WLAN_OS_REPORT(("FATAL ERROR: currBSS_create(): Error allocating cb - aborting\n")); 196 return NULL; 197 } 198 } 199 200 201 /** 202 * 203 * currBSS_unload 204 * 205 * \b Description: 206 * 207 * Finish Current BSS module work. 208 * 209 * \b ARGS: 210 * 211 * 212 * \b RETURNS: 213 * 214 * OK on success, NOK on failure. 215 * 216 * \sa 217 */ 218 TI_STATUS currBSS_unload(TI_HANDLE hCurrBSS) 219 { 220 currBSS_t *pCurrBSS; 221 222 if (hCurrBSS != NULL) 223 { 224 pCurrBSS = (currBSS_t *)hCurrBSS; 225 226 /* Free pre-allocated control block */ 227 utils_nullMemoryFree(pCurrBSS->hOs, pCurrBSS, sizeof(currBSS_t)); 228 } 229 return OK; 230 } 231 232 /** 233 * 234 * currBSS_init 235 * 236 * \b Description: 237 * 238 * Prepare Current BSS module to work 239 * 240 * \b ARGS: 241 * 242 * I - hCurrBSS - Current BSS handle \n 243 * I - hMlme \n 244 * I - hScanMng \n 245 * I - hPowerMgr \n 246 * I - hAPConnection \n 247 * I - hSME \n 248 * I - hHal \n 249 * 250 * \b RETURNS: 251 * 252 * OK on success, NOK on failure. 253 * 254 * \sa 255 */ 256 TI_STATUS currBSS_init(TI_HANDLE hCurrBSS, 257 TI_HANDLE hMlme, 258 TI_HANDLE hPowerMgr, 259 TI_HANDLE hAPConnection, 260 TI_HANDLE hSME, 261 TI_HANDLE hHal, 262 TI_HANDLE hReport, 263 TI_HANDLE hMemMgr, 264 TI_HANDLE hTxData, 265 TI_HANDLE hSiteMngr, 266 TI_HANDLE hScanMngr, 267 TI_HANDLE hMacServices) 268 { 269 currBSS_t *pCurrBSS; 270 whalCtrl_roamingTriggerCmd_t params; 271 272 if (hCurrBSS != NULL) 273 { 274 pCurrBSS = (currBSS_t *)hCurrBSS; 275 276 /* Registration succeeded, continue with init procedure */ 277 pCurrBSS->band = RADIO_BAND_2_4_GHZ; 278 pCurrBSS->channel = 0; 279 pCurrBSS->isConnected = FALSE; 280 pCurrBSS->fwIsOutOfSync = FALSE; 281 pCurrBSS->rssiAboveThrReported = FALSE; 282 pCurrBSS->rssiBelowThrReported = FALSE; 283 pCurrBSS->type = BSS_ANY; 284 pCurrBSS->numOfPktsInRevivalTest = NUM_PACKETS_4_CONN_LIVENESS; 285 pCurrBSS->snr = 0; 286 pCurrBSS->snrFilterWeight = SNR_DEFAULT_WEIGHT; 287 pCurrBSS->averageRssi = 0; 288 pCurrBSS->rssiFilterWeight = RSSI_DEFAULT_WEIGHT; 289 pCurrBSS->currAPInfo.RSSI = 0; 290 pCurrBSS->highRssiThreshold = RSSI_DEFAULT_THRESHOLD; 291 pCurrBSS->lowRssiThreshold = RSSI_DEFAULT_THRESHOLD; 292 pCurrBSS->bUseSGParams = FALSE; 293 294 pCurrBSS->hAPConn = hAPConnection; 295 pCurrBSS->hTxData = hTxData; 296 pCurrBSS->hHal = hHal; 297 pCurrBSS->hMlme = hMlme; 298 pCurrBSS->hPowerMngr = hPowerMgr; 299 pCurrBSS->hSme = hSME; 300 pCurrBSS->hMemMgr = hMemMgr; 301 pCurrBSS->hSiteMgr = hSiteMngr; 302 pCurrBSS->hReport = hReport; 303 pCurrBSS->hScanMngr = hScanMngr; 304 pCurrBSS->hMacServices = hMacServices; 305 306 /* Configure and enable the Low RSSI, the Low SNR and the Missed beacon events */ 307 whalCtrl_EventMbox_RegisterForEvent(pCurrBSS->hHal, HAL_EVENT_RSSI_LEVEL, (void *)currBSS_lowRssiThrCrossed, pCurrBSS); 308 whalCtrl_EventMbox_Enable(pCurrBSS->hHal, HAL_EVENT_RSSI_LEVEL); 309 310 whalCtrl_EventMbox_RegisterForEvent(pCurrBSS->hHal, HAL_EVENT_LOW_SNR, (void *)currBSS_lowSnrThrCrossed, pCurrBSS); 311 whalCtrl_EventMbox_Enable(pCurrBSS->hHal, HAL_EVENT_LOW_SNR); 312 313 whalCtrl_EventMbox_RegisterForEvent(pCurrBSS->hHal, HAL_EVENT_BSS_REGAIN, (void *)currBSS_Bss_Regain_CallB , pCurrBSS); 314 whalCtrl_EventMbox_Enable(pCurrBSS->hHal, HAL_EVENT_BSS_REGAIN); 315 316 params.rssiFilterDepth = RSSI_DEFAULT_DEPTH; 317 params.rssiFilterWeight = RSSI_DEFAULT_WEIGHT; 318 params.rssiThreshold = RSSI_DEFAULT_THRESHOLD; 319 params.lowRSSIEventType = LOW_RSSI_EVENT_LEVEL; 320 whalCtrl_SetRSSIParamsCmd(pCurrBSS->hHal, ¶ms); 321 322 params.snrFilterDepth = SNR_DEFAULT_DEPTH; 323 params.snrFilterWeight = SNR_DEFAULT_WEIGHT; 324 params.snrThreshold = SNR_DEFAULT_THRESHOLD; 325 params.lowSNREventType = LOW_SNR_EVENT_LEVEL; 326 whalCtrl_SetSNRParamsCmd(pCurrBSS->hHal, ¶ms); 327 328 /* Register for 'Out of Sync' and 'No Beacon trigger' events */ 329 whalCtrl_EventMbox_RegisterForEvent(pCurrBSS->hHal, HAL_EVENT_BSS_LOSE, (void *)currBSS_beaconMissed, pCurrBSS); 330 whalCtrl_EventMbox_Enable(pCurrBSS->hHal, HAL_EVENT_BSS_LOSE); 331 whalCtrl_EventMbox_RegisterForEvent(pCurrBSS->hHal, HAL_EVENT_SYNCHRONIZATION_TIMEOUT, (void *)currBSS_outOfSync, pCurrBSS); 332 whalCtrl_EventMbox_Enable(pCurrBSS->hHal, HAL_EVENT_SYNCHRONIZATION_TIMEOUT); 333 /* save last configured value for handling Soft Gemini changes */ 334 pCurrBSS->numExpectedTbttForBSSLoss = OUT_OF_SYNC_DEFAULT_THRESHOLD; 335 params.TsfMissThreshold = OUT_OF_SYNC_DEFAULT_THRESHOLD; 336 params.BssLossTimeout = NO_BEACON_DEFAULT_TIMEOUT; 337 whalCtrl_SetBssLossTsfThresholdParamsCmd(pCurrBSS->hHal, ¶ms); 338 339 /* Register for BSS_RESET event' */ 340 whalCtrl_EventMbox_RegisterForEvent(pCurrBSS->hHal, HAL_EVENT_BSS_RESET, (void *)currBSS_Bss_Reset_CallB , pCurrBSS); 341 /* Register for 'Consec. Tx error' */ 342 whalCtrl_EventMbox_RegisterForEvent(pCurrBSS->hHal, HAL_EVENT_MAX_TX_RETRY, (void *)currBSS_consecTxErrors, pCurrBSS); 343 whalCtrl_EventMbox_Enable(pCurrBSS->hHal, HAL_EVENT_MAX_TX_RETRY); 344 params.maxTxRetry = NO_ACK_DEFAULT_THRESHOLD; 345 whalCtrl_SetMaxTxRetryParamsCmd(pCurrBSS->hHal, ¶ms); 346 347 return OK; 348 } 349 else /* Current BSS handle is NULL */ 350 { 351 WLAN_OS_REPORT(("FATAL ERROR: Current BSS context is not initiated\n")); 352 return NOK; 353 } 354 } 355 356 357 /** 358 * 359 * currBSS_updateRoamingTriggers 360 * 361 * \b Description: 362 * 363 * Configure parameter of Current BSS 364 * 365 * \b ARGS: 366 * 367 * I - hCurrBSS - Current BSS handle \n 368 * I - params - pointer to datablock of roaming threshols \n 369 * 370 * \b RETURNS: 371 * 372 * OK on success, NOK on failure. 373 * 374 * \sa 375 */ 376 TI_STATUS currBSS_updateRoamingTriggers(TI_HANDLE hCurrBSS, 377 roamingMngrThresholdsConfig_t *params) 378 { 379 currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS; 380 whalCtrl_roamingTriggerCmd_t roamingTriggersParams; 381 382 /* Configure HAL with RSSI parameters */ 383 roamingTriggersParams.rssiFilterDepth = RSSI_DEFAULT_DEPTH; 384 roamingTriggersParams.rssiFilterWeight = params->rssiFilterWeight /* RSSI_DEFAULT_WEIGHT */ ; 385 roamingTriggersParams.rssiThreshold = params->lowRssiThreshold; 386 roamingTriggersParams.lowRSSIEventType = LOW_RSSI_EVENT_LEVEL; 387 whalCtrl_SetRSSIParamsCmd(pCurrBSS->hHal, &roamingTriggersParams); 388 389 /* Configure HAL with SNR parameters */ 390 roamingTriggersParams.snrFilterDepth = SNR_DEFAULT_DEPTH; 391 roamingTriggersParams.snrFilterWeight = params->snrFilterWeight /* SNR_DEFAULT_WEIGHT */ ; 392 roamingTriggersParams.snrThreshold = params->lowSnrThreshold; 393 roamingTriggersParams.lowSNREventType = LOW_SNR_EVENT_LEVEL; 394 whalCtrl_SetSNRParamsCmd(pCurrBSS->hHal, &roamingTriggersParams); 395 396 /* save last configured value for handling Soft Gemini changes */ 397 pCurrBSS->numExpectedTbttForBSSLoss = params->numExpectedTbttForBSSLoss; 398 /* Configure HAL with 'No BSS' thresholds (Same as the other parameters but in a special 399 function for the Soft Gemini module consideration) */ 400 currBSS_updateBSSLoss(pCurrBSS); 401 402 /* Configure HAL with 'Consecutive NACK' thresholds */ 403 roamingTriggersParams.maxTxRetry = params->dataRetryThreshold; 404 whalCtrl_SetMaxTxRetryParamsCmd(pCurrBSS->hHal, &roamingTriggersParams); 405 406 pCurrBSS->lowRssiThreshold = params->lowQualityForBackgroungScanCondition; 407 408 pCurrBSS->highRssiThreshold = params->normalQualityForBackgroungScanCondition; 409 410 pCurrBSS->rssiFilterWeight = params->rssiFilterWeight; 411 412 pCurrBSS->snrFilterWeight = params->snrFilterWeight; 413 414 415 return OK; 416 } 417 418 /** 419 * 420 * currBSS_getRoamingParams 421 * 422 * \b Description: 423 * 424 * Retrieves the roaming triggers stored in the CurrBSS module. 425 * 426 * \b ARGS: 427 * 428 * I - hCurrBSS - Current BSS handle \n 429 * O - aNumExpectedTbttForBSSLoss - Current BSS handle \n 430 * O - aLowQualityForBackgroungScanCondition - Current BSS handle \n 431 * O - aNormalQualityForBackgroungScanCondition - Current BSS handle \n 432 * 433 * \b RETURNS: 434 * 435 * OK on success, NOK on failure. 436 * 437 * \sa 438 */ 439 TI_STATUS currBSS_getRoamingParams(TI_HANDLE hCurrBSS, 440 UINT8 * aNumExpectedTbttForBSSLoss, 441 INT8 * aLowQualityForBackgroungScanCondition, 442 INT8 * aNormalQualityForBackgroungScanCondition, 443 UINT8 * rssiFilterWeight, 444 UINT8 * snrFilterWeight) 445 { 446 currBSS_t * pCurrBSS = (currBSS_t *) hCurrBSS; 447 448 *aNumExpectedTbttForBSSLoss = pCurrBSS->numExpectedTbttForBSSLoss; 449 *aLowQualityForBackgroungScanCondition = pCurrBSS->lowRssiThreshold; 450 *aNormalQualityForBackgroungScanCondition = pCurrBSS->highRssiThreshold; 451 *rssiFilterWeight = pCurrBSS->rssiFilterWeight; 452 *snrFilterWeight = pCurrBSS->snrFilterWeight; 453 454 return OK; 455 } 456 457 /** 458 * 459 * currBSS_SGconfigureBSSLoss 460 * 461 * \b Description: 462 * 463 * This function is called by the Soft Gemini module in order to enable/disable the use of 464 * the compensation value for the BSSLoss count , and the percent of increasing that value 465 * It also set the new parameter to the FW (with another generic function) 466 * The compensation is needed since BT activity might over-run recieved beacons 467 * 468 * 469 * \b ARGS: 470 * 471 * I - hCurrBSS - Current BSS handle \n 472 * SGcompensationPercent - percent of increasing the BSSLoss value to the FW \n 473 * bUseSGParams - whether to use the SG compensation 474 * 475 * \b RETURNS: 476 * 477 * - 478 * 479 * \sa 480 */ 481 482 void currBSS_SGconfigureBSSLoss(TI_HANDLE hCurrBSS, 483 UINT32 SGcompensationPercent , BOOLEAN bUseSGParams) 484 { 485 currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS; 486 487 pCurrBSS->bUseSGParams = bUseSGParams; 488 pCurrBSS->SGcompensationPercent = SGcompensationPercent; 489 490 WLAN_REPORT_INFORMATION(pCurrBSS->hReport, ROAMING_MANAGER_MODULE_LOG,("CurrBSS_SGConf: SG =%d\n", 491 pCurrBSS->bUseSGParams)); 492 493 /* update the change of BSSLoss in the FW */ 494 currBSS_updateBSSLoss(pCurrBSS); 495 } 496 497 /** 498 * 499 * currBSS_updateBSSLoss 500 * 501 * \b Description: 502 * 503 * This function updates only BSS Loss parameter , we need it to be able to consider the 504 * Soft Gemini status , and change the parameter according to it 505 * 506 * \b ARGS: 507 * 508 * I - pCurrBSS - Current BSS handle \n 509 * 510 * \b RETURNS: 511 * 512 * - 513 * 514 * \sa 515 */ 516 void currBSS_updateBSSLoss(currBSS_t *pCurrBSS) 517 { 518 whalCtrl_roamingTriggerCmd_t roamingTriggersParams; 519 520 /* In Ad-Hoc we use default parameter */ 521 if (pCurrBSS->type == BSS_INDEPENDENT) 522 { 523 roamingTriggersParams.TsfMissThreshold = OUT_OF_SYNC_IBSS_THRESHOLD; 524 } 525 else /* In Infra we use the saved parameter */ 526 { 527 roamingTriggersParams.TsfMissThreshold = pCurrBSS->numExpectedTbttForBSSLoss; 528 } 529 530 roamingTriggersParams.BssLossTimeout = NO_BEACON_DEFAULT_TIMEOUT; 531 532 WLAN_REPORT_INFORMATION(pCurrBSS->hReport, ROAMING_MANAGER_MODULE_LOG,("CurrBSS: SG=%d, Band=%d\n", 533 pCurrBSS->bUseSGParams, 534 pCurrBSS->currAPInfo.band)); 535 /* if Soft Gemini is enabled - increase the BSSLoss value (because BT activity might over-run beacons) */ 536 if ((pCurrBSS->bUseSGParams) && (pCurrBSS->currAPInfo.band == RADIO_BAND_2_4_GHZ)) 537 { 538 roamingTriggersParams.TsfMissThreshold = (roamingTriggersParams.TsfMissThreshold * 539 (100 + pCurrBSS->SGcompensationPercent)) / 100; 540 541 WLAN_REPORT_INFORMATION(pCurrBSS->hReport, ROAMING_MANAGER_MODULE_LOG, 542 ("%s: old value = %d, new value (for SG compensation) = %d\n", __FUNCTION__, 543 pCurrBSS->numExpectedTbttForBSSLoss,roamingTriggersParams.TsfMissThreshold)); 544 } 545 whalCtrl_SetBssLossTsfThresholdParamsCmd(pCurrBSS->hHal, &roamingTriggersParams); 546 } 547 548 /** 549 * 550 * currBSS_swChFinished 551 * 552 * \b Description: 553 * 554 * Called when switch channel process is complete in order to reset RSSI calculations 555 * 556 * \b ARGS: 557 * 558 * I - hCurrBSS - Current BSS handle \n 559 * 560 * \b RETURNS: 561 * 562 * - 563 * 564 * \sa 565 */ 566 void currBSS_restartRssiCounting(TI_HANDLE hCurrBSS) 567 { 568 currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS; 569 570 pCurrBSS->averageRssi = 0; 571 pCurrBSS->currAPInfo.RSSI = 0; 572 } 573 574 /** 575 * 576 * currBSS_getBssInfo 577 * 578 * \b Description: 579 * 580 * Get parameter of Current BSS 581 * 582 * \b ARGS: 583 * 584 * I - hCurrBSS - Current BSS handle \n 585 * 586 * \b RETURNS: 587 * 588 * pointer to current BSS info block. 589 * 590 * \sa 591 */ 592 bssEntry_t *currBSS_getBssInfo(TI_HANDLE hCurrBSS) 593 { 594 currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS; 595 596 /* Return pointer to current AP info */ 597 return &(pCurrBSS->currAPInfo); 598 } 599 600 601 /** 602 * 603 * currBSS_probRespReceivedCallb 604 * 605 * \b Description: 606 * 607 * Callback function, provided to MLME module. Called each time Probe response received. 608 * This function verifies that the Probe response was sent by current AP, and then 609 * updates current AP database. 610 * 611 * \b ARGS: 612 * 613 * I - hCurrBSS - Current BSS handle \n 614 * 615 * \b RETURNS: 616 * 617 * OK on success, NOK on failure. 618 * 619 * \sa 620 */ 621 TI_STATUS currBSS_probRespReceivedCallb(TI_HANDLE hCurrBSS, 622 Rx_attr_t *pRxAttr, 623 macAddress_t *bssid, 624 mlmeFrameInfo_t *pFrameInfo, 625 char *dataBuffer, 626 UINT16 bufLength) 627 { 628 currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS; 629 paramInfo_t param; 630 631 param.paramType = SITE_MGR_CURRENT_BSSID_PARAM; 632 siteMgr_getParam(pCurrBSS->hSiteMgr, ¶m); 633 634 if ((pCurrBSS->isConnected) && (MAC_EQUAL((&(param.content.siteMgrDesiredBSSID)), (bssid)))) 635 { 636 /* If this is first probe response since FW reported 'Out of sync' situation, 637 then we were trying to revive connection, now stop sending probe requests */ 638 currBSS_terminateOutOfSyncMode(pCurrBSS); 639 640 siteMgr_updateSite(pCurrBSS->hSiteMgr, bssid, pFrameInfo, pRxAttr->channel, (radioBand_e)pRxAttr->band, FALSE); 641 /* Save the IE part of the Probe Response buffer in the site table */ 642 siteMgr_saveProbeRespBuffer(pCurrBSS->hSiteMgr, bssid, (UINT8 *)dataBuffer, bufLength); 643 } 644 return OK; 645 } 646 647 648 649 /** 650 * 651 * currBSS_beaconReceivedCallb 652 * 653 * \b Description: 654 * 655 * Callback function, provided to MLME module. Called each time Beacon received. 656 * This function verifies that the Probe response was sent by current AP, and then 657 * updates current AP database. 658 * 659 * \b ARGS: 660 * 661 * I - hCurrBSS - Current BSS handle \n 662 * 663 * \b RETURNS: 664 * 665 * OK on success, NOK on failure. 666 * 667 * \sa 668 */ 669 TI_STATUS currBSS_beaconReceivedCallb(TI_HANDLE hCurrBSS, 670 Rx_attr_t *pRxAttr, 671 macAddress_t *bssid, 672 mlmeFrameInfo_t *pFrameInfo, 673 char *dataBuffer, 674 UINT16 bufLength) 675 { 676 currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS; 677 paramInfo_t param; 678 param.paramType = SITE_MGR_CURRENT_BSSID_PARAM; 679 siteMgr_getParam(pCurrBSS->hSiteMgr, ¶m); 680 681 if ((pCurrBSS->isConnected) && (MAC_EQUAL((&(param.content.siteMgrDesiredBSSID)), (bssid)))) 682 { 683 /* If this is first beacon since FW reported 'Out of sync' situation, 684 then we were trying to revive connection, now stop sending probe requests */ 685 currBSS_terminateOutOfSyncMode(pCurrBSS); 686 687 siteMgr_updateSite(pCurrBSS->hSiteMgr, bssid, pFrameInfo, pRxAttr->channel, (radioBand_e)pRxAttr->band, FALSE); 688 /* Save the IE part of the beacon buffer in the site table */ 689 siteMgr_saveBeaconBuffer(pCurrBSS->hSiteMgr, bssid, (UINT8 *)dataBuffer, bufLength); 690 691 currBSS_updateRxSignal(hCurrBSS, pRxAttr->SNR, pRxAttr->Rssi, FALSE); 692 } 693 694 return OK; 695 } 696 697 698 699 /** 700 * 701 * currBSS_performRecovery 702 * 703 * \b Description: 704 * 705 * This function is called when FW recovery performed. 706 * 707 * \b ARGS: 708 * 709 * I - hCurrBSS - Current BSS handle \n 710 * 711 * \b RETURNS: 712 * 713 * OK on success, NOK on failure. 714 * 715 * \sa 716 */ 717 TI_STATUS currBSS_performRecovery(TI_HANDLE hCurrBSS) 718 { 719 currBSS_terminateOutOfSyncMode(hCurrBSS); 720 return OK; 721 } 722 723 724 /** 725 * 726 * currBSS_updateConnectedState 727 * 728 * \b Description: 729 * 730 * This function is called when FW recovery performed. 731 * 732 * \b ARGS: 733 * 734 * I - hCurrBSS - Current BSS handle \n 735 * I - isConnected - TRUE or FALSE \n 736 * I - type - IBSS or EBSS \n 737 * 738 * \b RETURNS: 739 * 740 * - 741 * 742 * \sa 743 */ 744 void currBSS_updateConnectedState(TI_HANDLE hCurrBSS, BOOLEAN isConnected, bssType_e type) 745 { 746 currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS; 747 paramInfo_t param; 748 pCurrBSS->type = type; 749 pCurrBSS->isConnected = isConnected; 750 751 /* If new connection established or roaming started, as well as 752 in case of disconnect, the event 'Out of sync' from FW is 753 no more relevant, do not proceed with it's handling */ 754 currBSS_terminateOutOfSyncMode(pCurrBSS); 755 pCurrBSS->averageRssi = pCurrBSS->currAPInfo.RSSI; 756 757 if (isConnected) 758 { 759 /*** Store the info of current AP ***/ 760 761 /* BSSID */ 762 param.paramType = SITE_MGR_CURRENT_BSSID_PARAM; 763 siteMgr_getParam(pCurrBSS->hSiteMgr, ¶m); 764 os_memoryCopy(pCurrBSS->hOs, (void *)pCurrBSS->currAPInfo.BSSID.addr, (void *)param.content.siteMgrDesiredBSSID.addr, MAC_ADDR_LEN); 765 766 /* Rx rate */ 767 param.paramType = SITE_MGR_LAST_RX_RATE_PARAM; 768 siteMgr_getParam(pCurrBSS->hSiteMgr, ¶m); 769 pCurrBSS->currAPInfo.rxRate = param.content.ctrlDataCurrentBasicRate; 770 771 /* Band */ 772 param.paramType = SITE_MGR_RADIO_BAND_PARAM; 773 siteMgr_getParam(pCurrBSS->hSiteMgr, ¶m); 774 pCurrBSS->currAPInfo.band = param.content.siteMgrRadioBand; 775 776 /* Channel */ 777 param.paramType = SITE_MGR_CURRENT_CHANNEL_PARAM; 778 siteMgr_getParam(pCurrBSS->hSiteMgr, ¶m); 779 pCurrBSS->currAPInfo.channel = param.content.siteMgrCurrentChannel; 780 781 /* Last Rx Tsf */ 782 param.paramType = SITE_MGR_CURRENT_TSF_TIME_STAMP; 783 siteMgr_getParam(pCurrBSS->hSiteMgr, ¶m); 784 os_memoryCopy(pCurrBSS->hOs, &pCurrBSS->currAPInfo.lastRxTSF, 785 param.content.siteMgrCurrentTsfTimeStamp, sizeof(pCurrBSS->currAPInfo.lastRxTSF)); 786 787 /* Beacon interval */ 788 param.paramType = SITE_MGR_BEACON_INTERVAL_PARAM; 789 siteMgr_getParam(pCurrBSS->hSiteMgr, ¶m); 790 pCurrBSS->currAPInfo.beaconInterval = param.content.beaconInterval; 791 792 /* Capability */ 793 param.paramType = SITE_MGR_SITE_CAPABILITY_PARAM; 794 siteMgr_getParam(pCurrBSS->hSiteMgr,¶m); 795 pCurrBSS->currAPInfo.capabilities = param.content.siteMgrSiteCapability; 796 param.paramType = SITE_MGR_CURRENT_TSF_TIME_STAMP; 797 siteMgr_getParam(pCurrBSS->hSiteMgr, ¶m); 798 799 /* pCurrBSS->currAPInfo.lastRxHostTimestamp = *((UINT64 *)(pIEs->TimeStamp));*/ /* TBD*/ 800 os_memoryCopy(pCurrBSS->hOs, &pCurrBSS->currAPInfo.lastRxHostTimestamp, param.content.siteMgrCurrentTsfTimeStamp, sizeof(UINT32)); 801 802 param.paramType = SITE_MGR_LAST_BEACON_BUF_PARAM; 803 siteMgr_getParam(pCurrBSS->hSiteMgr, ¶m); 804 pCurrBSS->currAPInfo.pBuffer = param.content.siteMgrLastBeacon.buffer; 805 pCurrBSS->currAPInfo.bufferLength = param.content.siteMgrLastBeacon.bufLength; 806 pCurrBSS->currAPInfo.resultType = (param.content.siteMgrLastBeacon.isBeacon) ? SCAN_RFT_BEACON : SCAN_RFT_PROBE_RESPONSE; 807 808 /* Set BSS Loss to Fw - note that it depends on the Connection type - (Infa/IBSS) */ 809 currBSS_updateBSSLoss(pCurrBSS); 810 811 /* 812 this section is for the first beacon. in here we set the flag for waiting for 813 the first beacon and during all this time we must keep the Hw awake 814 this things are done only for INFRA connection. 815 */ 816 if(type == BSS_INFRASTRUCTURE) 817 { 818 siteMgr_clearFirstBcnFlag(pCurrBSS->hSiteMgr); 819 } 820 } 821 else 822 { 823 /* 824 this section is for the first beacon. in here we cancel the setting of the flag 825 and the Hw available in case that the connection was closed. 826 this things are done only for INFRA connection. 827 */ 828 if(type == BSS_INFRASTRUCTURE) 829 siteMgr_setFirstBcnFlag(pCurrBSS->hSiteMgr); 830 831 } 832 } 833 834 /* Internal functions implementation */ 835 836 837 /** 838 * 839 * currBSS_outOfSync 840 * 841 * \b Description: 842 * 843 * Callback function, provided to HAL module. 844 * 845 * \b ARGS: 846 * 847 * I - hCurrBSS - Current BSS handle \n 848 * 849 * \b RETURNS: 850 * 851 * OK on success, NOK on failure. 852 * 853 * \sa 854 */ 855 static void currBSS_outOfSync(currBSS_t *hCurrBSS, 856 UINT8 *data, 857 UINT8 dataLength) 858 { 859 currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS; 860 /*while syn with current BSS is lost, we need beacons to resynchronize*/ 861 862 /* If connected, and this kind of event was not received yet, handle it */ 863 if (pCurrBSS->isConnected && 864 pCurrBSS->fwIsOutOfSync == FALSE && 865 pCurrBSS->type != BSS_INDEPENDENT) 866 { 867 868 /* TBD IBSS configuration; no roaming enabled, report SME */ 869 870 pCurrBSS->fwIsOutOfSync = TRUE; 871 872 /* force TNETW to active */ 873 MacServices_powerAutho_AwakeRequiredUpdate(pCurrBSS->hMacServices, POWERAUTHO_AWAKE_REQUIRED, POWERAUTHO_AWAKE_REASON_OUT_OS_SYNC); 874 875 /* try to send Unicast Probe requests */ 876 currBSS_reviveConnection(pCurrBSS); 877 878 } 879 else 880 { 881 /* If no connection, 882 or in the middle of roaming, 883 or this kind of event was already received, - do nothing */ 884 } 885 } 886 887 888 889 /** 890 * 891 * currBSS_reviveConnection 892 * 893 * \b Description: 894 * 895 * Called when FW indicates "Beacon missed" problem ('Out of sync' event). 896 * This function makes sure that FW is not asleep (the radio is awake), and 897 * sends Unicast Probe Request packet in order to provoke AP to answer with 898 * Probe response. 899 * If HW interface is available (normal case), called immediately upon reception 900 * of the event from FW. Otherwise, this function is a function, provided to Power control. 901 * Called by Power control module in several cases: 902 * - when Power control exits pending and informs registered clients about HW availability; 903 * - when FW recovery occurs - timeout waiting for FW to wakeup 904 * 905 * \b ARGS: 906 * 907 * I - hCurrBSS - Current BSS handle \n 908 * 909 * \b RETURNS: 910 * 911 * OK on success, NOK on failure. 912 * 913 * \sa 914 */ 915 static void currBSS_reviveConnection(currBSS_t *pCurrBSS) 916 { 917 int pktsCount; 918 919 /* TBD Turn ON LNA if the current state is OFF */ 920 921 #if 0 922 /* Perform MAC RX module reset. */ 923 /* For the moment we don't think the Rx Reset is nessasery */ 924 whalCtrl_resetMacRx(pCurrBSS->hHal); 925 #endif 926 927 WLAN_REPORT_INFORMATION(pCurrBSS->hReport, ROAMING_MANAGER_MODULE_LOG,("currBSS_reviveConnection: sending %d Probe requests\n", pCurrBSS->numOfPktsInRevivalTest)); 928 929 /* Test connection with Unicast Probe request */ 930 for (pktsCount = pCurrBSS->numOfPktsInRevivalTest; pktsCount > 0; pktsCount--) 931 { 932 currBSS_sendUnicastProbeRequest(pCurrBSS); 933 } 934 } 935 936 937 /** 938 * 939 * currBSS_sendUnicastProbeRequest 940 * 941 * \b Description: 942 * 943 * This function creaes and sends Unicast Probe request packet to current AP 944 * 945 * \b ARGS: 946 * 947 * I - pCurrBSS - Current BSS handle \n 948 * 949 * \b RETURNS: 950 * 951 * OK on success, NOK on failure. 952 * 953 * \sa 954 */ 955 static void currBSS_sendUnicastProbeRequest(currBSS_t *pCurrBSS) 956 { 957 paramInfo_t param; 958 mem_MSDU_T *pMsdu; 959 probeReqTemplate_t *pProbeReqTemplate; 960 whalCtrl_setTemplate_t templateStruct; 961 TI_STATUS status; 962 radioBand_e eRadioBand; 963 /* 1. Allocate packet */ 964 status = wlan_memMngrAllocMSDU(pCurrBSS->hMemMgr, &pMsdu, sizeof(probeReqTemplate_t)+TX_TOTAL_OFFSET_BEFORE_DATA, CURRENT_BSS_MODULE); 965 if (status != OK) 966 { 967 return; 968 } 969 970 /* 2. Build a probe request template */ 971 pProbeReqTemplate = (probeReqTemplate_t *)((char *)(memMgr_BufData(pMsdu->firstBDPtr))+ TX_TOTAL_OFFSET_BEFORE_DATA); 972 templateStruct.pTemplate = (UINT8 *)pProbeReqTemplate; 973 templateStruct.templateType = PROBE_REQUEST_TEMPLATE; 974 975 param.paramType = SITE_MGR_RADIO_BAND_PARAM; 976 siteMgr_getParam(pCurrBSS->hSiteMgr, ¶m); 977 eRadioBand = param.content.siteMgrRadioBand; 978 979 param.paramType = SITE_MGR_CURRENT_SSID_PARAM; 980 siteMgr_getParam(pCurrBSS->hSiteMgr, ¶m); 981 buildProbeReqTemplate(pCurrBSS->hSiteMgr, &templateStruct, ¶m.content.siteMgrCurrentSSID, eRadioBand); 982 983 /* 3. Update BSSID to current BSSID */ 984 param.paramType = SITE_MGR_CURRENT_BSSID_PARAM; 985 siteMgr_getParam(pCurrBSS->hSiteMgr, ¶m); 986 os_memoryCopy(pCurrBSS->hOs, &(pProbeReqTemplate->hdr.DA.addr), (void *)param.content.siteMgrDesiredBSSID.addr, MAC_ADDR_LEN); 987 os_memoryCopy(pCurrBSS->hOs, &(pProbeReqTemplate->hdr.BSSID.addr), (void *)param.content.siteMgrDesiredBSSID.addr, MAC_ADDR_LEN); 988 os_memoryCopy(pCurrBSS->hOs, &(pProbeReqTemplate->hdr.DA.addr), (void *)param.content.siteMgrDesiredBSSID.addr, MAC_ADDR_LEN); 989 /* 4. Update MSDU parameters */ 990 pMsdu->headerLen = sizeof(dot11_mgmtHeader_t) + TX_TOTAL_OFFSET_BEFORE_DATA; 991 pMsdu->dataLen = templateStruct.templateLen; 992 memMgr_BufOffset(pMsdu->firstBDPtr) = TX_TOTAL_OFFSET_BEFORE_DATA; 993 /* 994 * Fix length according to TX_DESCRIPTOR_SIZE and bus txn reserved place 995 */ 996 pMsdu->firstBDPtr->length = pMsdu->dataLen + TX_TOTAL_OFFSET_BEFORE_DATA; 997 998 /* 5. Send the packet to the TX */ 999 pMsdu->txFlags |= TX_DATA_MGMT_MSDU; 1000 status = txData_txSendMsdu(pCurrBSS->hTxData, pMsdu); 1001 } 1002 1003 1004 /** 1005 * 1006 * currBSS_terminateOutOfSyncMode 1007 * 1008 * \b Description: 1009 * 1010 * Beacon/probe response received, or connected state is changes - 1011 * if was in the middle of handling 'Out os sync' event, give it up 1012 * 1013 * \b ARGS: 1014 * 1015 * I - pCurrBSS - Current BSS handle \n 1016 * 1017 * \b RETURNS: 1018 * 1019 * OK on success, NOK on failure. 1020 * 1021 * \sa 1022 */ 1023 static void currBSS_terminateOutOfSyncMode(currBSS_t *pCurrBSS) 1024 { 1025 if (pCurrBSS->fwIsOutOfSync) 1026 { 1027 pCurrBSS->fwIsOutOfSync = FALSE; 1028 1029 /* undo forcing TNETW to active */ 1030 MacServices_powerAutho_AwakeRequiredUpdate(pCurrBSS->hMacServices, POWERAUTHO_AWAKE_NOT_REQUIRED, POWERAUTHO_AWAKE_REASON_OUT_OS_SYNC); 1031 } 1032 } 1033 1034 /** 1035 * 1036 * currBSS_beaconMissed 1037 * 1038 * \b Description: 1039 * 1040 * Callback function, provided to HAL module. 1041 * 1042 * \b ARGS: 1043 * 1044 * I - pCurrBSS - Current BSS handle \n 1045 * 1046 * \b RETURNS: 1047 * 1048 * OK on success, NOK on failure. 1049 * 1050 * \sa 1051 */ 1052 static void currBSS_beaconMissed(currBSS_t *hCurrBSS, 1053 UINT8 *data, 1054 UINT8 dataLength) 1055 { 1056 currBSS_terminateOutOfSyncMode(hCurrBSS); 1057 currBSS_reportRoamingEvent(hCurrBSS, ROAMING_TRIGGER_BSS_LOSS, NULL); 1058 } 1059 1060 1061 /** 1062 * 1063 * currBSS_consecTxErrors 1064 * 1065 * \b Description: 1066 * 1067 * Callback function, provided to HAL module. 1068 * 1069 * \b ARGS: 1070 * 1071 * I - pCurrBSS - Current BSS handle \n 1072 * 1073 * \b RETURNS: 1074 * 1075 * OK on success, NOK on failure. 1076 * 1077 * \sa 1078 */ 1079 static void currBSS_consecTxErrors(currBSS_t *hCurrBSS, 1080 UINT8 *data, 1081 UINT8 dataLength) 1082 { 1083 currBSS_reportRoamingEvent(hCurrBSS, ROAMING_TRIGGER_MAX_TX_RETRIES, NULL); 1084 } 1085 1086 1087 /** 1088 * 1089 * currBSS_lowRssiThrCrossed 1090 * 1091 * \b Description: 1092 * 1093 * Callback function, provided to HAL module. 1094 * 1095 * \b ARGS: 1096 * 1097 * I - pCurrBSS - Current BSS handle \n 1098 * 1099 * \b RETURNS: 1100 * 1101 * OK on success, NOK on failure. 1102 * 1103 * \sa 1104 */ 1105 static void currBSS_lowRssiThrCrossed(currBSS_t *hCurrBSS, 1106 UINT8 *data, 1107 UINT8 dataLength) 1108 { 1109 currBSS_reportRoamingEvent(hCurrBSS, ROAMING_TRIGGER_LOW_QUALITY, NULL); 1110 } 1111 1112 1113 /** 1114 * 1115 * currBSS_lowSnrThrCrossed 1116 * 1117 * \b Description: 1118 * 1119 * Callback function, provided to HAL module. 1120 * 1121 * \b ARGS: 1122 * 1123 * I - pCurrBSS - Current BSS handle \n 1124 * 1125 * \b RETURNS: 1126 * 1127 * OK on success, NOK on failure. 1128 * 1129 * \sa 1130 */ 1131 static void currBSS_lowSnrThrCrossed(currBSS_t *hCurrBSS, 1132 UINT8 *data, 1133 UINT8 dataLength) 1134 { 1135 currBSS_reportRoamingEvent(hCurrBSS, ROAMING_TRIGGER_LOW_SNR, NULL); 1136 } 1137 1138 /** 1139 * 1140 * currBSS_reportRoamingEvent 1141 * 1142 * \b Description: 1143 * 1144 * This function checks the mode of Current BSS module. 1145 * If connected to EBSS, it reports roaming event to AP Connection. 1146 * 1147 * \b ARGS: 1148 * 1149 * I - pCurrBSS - Current BSS handle \n 1150 * I - roamingEventType - Roaming trigger to report \n 1151 * 1152 * \b RETURNS: 1153 * 1154 * OK on success, NOK on failure. 1155 * 1156 * \sa 1157 */ 1158 static void currBSS_reportRoamingEvent(currBSS_t *pCurrBSS, 1159 apConn_roamingTrigger_e roamingEventType, 1160 roamingEventData_u *pRoamingEventData) 1161 { 1162 WLAN_REPORT_INFORMATION(pCurrBSS->hReport, ROAMING_MANAGER_MODULE_LOG,("currBSS_reportRoamingEvent: trigger %d\n", roamingEventType)); 1163 1164 if (pCurrBSS->isConnected) 1165 { 1166 if (pCurrBSS->type == BSS_INFRASTRUCTURE) 1167 { 1168 apConn_reportRoamingEvent(pCurrBSS->hAPConn, roamingEventType, pRoamingEventData); 1169 } 1170 else /* IBSS */ 1171 { 1172 if( roamingEventType == ROAMING_TRIGGER_BSS_LOSS ) 1173 { 1174 /* If in IBSS call the SME reselect function, this logic issues a DISCONNECT 1175 * event and tries to connect to other STA or establish self connection. 1176 */ 1177 smeSm_reselect(pCurrBSS->hSme); 1178 } 1179 } 1180 } 1181 } 1182 1183 /*********************************************************************** 1184 * currBSS_updateRxSignal 1185 *********************************************************************** 1186 DESCRIPTION: Called when receiving beacon or Probe response from current AP 1187 updates SNR and RSSI in siteMgr and calls apConn in case 1188 roaming trigger for BG scan occurred. 1189 1190 INPUT: hCurrBSS - currBss handle. 1191 uSNR 1192 iRSSI 1193 bAveragedData - indicate whether the given SNR,RSSI are already averaged. 1194 This is done since this values can be given directly from the 1195 Fw, which average those values. 1196 OUTPUT: 1197 1198 RETURN: 1199 1200 ************************************************************************/ 1201 void currBSS_updateRxSignal(TI_HANDLE hCurrBSS, UINT8 uSNR, INT8 iRSSI, BOOL bAveragedData) 1202 { 1203 currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS; 1204 INT8 tmpRssiAvg; 1205 INT8 rssiPrevVal; 1206 INT8 rssiLatestVal; 1207 paramInfo_t param; 1208 1209 /* Update SNR */ 1210 pCurrBSS->snr = uSNR; 1211 1212 /* Update Rx rate of primary site is done in Site Manager */ 1213 1214 /* Update RSSI: */ 1215 /* Count average RSSI */ 1216 rssiPrevVal = pCurrBSS->averageRssi; 1217 rssiLatestVal = pCurrBSS->currAPInfo.RSSI = iRSSI; 1218 1219 /* if the data is already averaged, or this is the first measured RSSI */ 1220 if ((bAveragedData) || (rssiPrevVal == 0)) 1221 { 1222 pCurrBSS->averageRssi = rssiLatestVal; 1223 } 1224 else /* average the RSSI given */ 1225 { 1226 tmpRssiAvg = ((rssiLatestVal*pCurrBSS->rssiFilterWeight) + (rssiPrevVal*(100-pCurrBSS->rssiFilterWeight)))/100; 1227 1228 /* for faster convergence on RSSI changes use rounding error calculation with latest sample and not */ 1229 /* on latest average */ 1230 if (rssiLatestVal > tmpRssiAvg) 1231 tmpRssiAvg++; 1232 else 1233 if (rssiLatestVal < tmpRssiAvg) 1234 tmpRssiAvg--; 1235 1236 pCurrBSS->averageRssi = tmpRssiAvg; 1237 } 1238 1239 /* Report to AP Connection about reaching RSSI low or normal threshold */ 1240 if ((pCurrBSS->rssiBelowThrReported == FALSE) && (pCurrBSS->averageRssi < pCurrBSS->lowRssiThreshold)) 1241 { 1242 pCurrBSS->rssiAboveThrReported = FALSE; 1243 pCurrBSS->rssiBelowThrReported = TRUE; 1244 apConn_reportRoamingEvent(pCurrBSS->hAPConn, ROAMING_TRIGGER_LOW_QUALITY_FOR_BG_SCAN, NULL); 1245 } 1246 if ((pCurrBSS->rssiAboveThrReported == FALSE) && (pCurrBSS->averageRssi > pCurrBSS->highRssiThreshold)) 1247 { 1248 pCurrBSS->rssiAboveThrReported = TRUE; 1249 pCurrBSS->rssiBelowThrReported = FALSE; 1250 apConn_reportRoamingEvent(pCurrBSS->hAPConn, ROAMING_TRIGGER_NORMAL_QUALITY_FOR_BG_SCAN, NULL); 1251 } 1252 1253 /* Update Site Table in order to represent the RSSI of current AP correctly in the utility */ 1254 param.paramType = SITE_MGR_CURRENT_SIGNAL_PARAM; 1255 param.content.siteMgrCurrentSignal.rssi = pCurrBSS->averageRssi; 1256 siteMgr_setParam(pCurrBSS->hSiteMgr, ¶m); 1257 } 1258 1259 /** 1260 * 1261 * currBSS_Bss_Regain_CallB 1262 * 1263 * \b Description: 1264 * Used by site manager in case of BSS regain 1265 * 1266 * \b ARGS: 1267 * 1268 * I - hCurrBSS - Current BSS handle \n 1269 * 1270 * \b RETURNS: 1271 * 1272 * OK on success, NOK on failure. 1273 * 1274 * \sa 1275 */ 1276 1277 TI_STATUS currBSS_Bss_Regain_CallB(TI_HANDLE hCurrBSS) 1278 1279 { 1280 currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS; 1281 paramInfo_t param; 1282 1283 if ( NULL == hCurrBSS ) 1284 { 1285 WLAN_REPORT_ERROR(pCurrBSS->hReport, CURR_BSS_MODULE_LOG,("Pointer to Curr BSS NULL, abort regain !")) ; 1286 return NOK; 1287 } 1288 1289 param.paramType = SITE_MGR_CURRENT_BSSID_PARAM; 1290 siteMgr_getParam(pCurrBSS->hSiteMgr, ¶m); 1291 1292 if (pCurrBSS->isConnected) 1293 { 1294 WLAN_REPORT_INFORMATION(pCurrBSS->hReport, CURR_BSS_MODULE_LOG,("Regain Current Connected BSS" )); 1295 1296 /* If we got the REGAIN_BSS Event from FW since it reported 'Out of sync' situation*/ 1297 /* then we were trying to revive connection, now stop sending probe requests */ 1298 currBSS_terminateOutOfSyncMode(pCurrBSS); 1299 1300 } 1301 else 1302 { 1303 WLAN_REPORT_INFORMATION(pCurrBSS->hReport, CURR_BSS_MODULE_LOG,("Can't Regain BSS not connected !" )); 1304 } 1305 return OK; 1306 1307 } 1308 1309 /** 1310 * 1311 * currBSS_Bss_Reset_CallB 1312 * 1313 * \b Description: 1314 * Used by site manager in case of BSS Reset - if tsf was changed FW will signal with this event 1315 * 1316 * \b ARGS: 1317 * 1318 * I - hCurrBSS - Current BSS handle \n 1319 * 1320 * \b RETURNS: 1321 * 1322 * OK on success, NOK on failure. 1323 * 1324 * \sa 1325 */ 1326 1327 TI_STATUS currBSS_Bss_Reset_CallB(TI_HANDLE hCurrBSS) 1328 1329 { 1330 currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS; 1331 1332 if ( NULL == hCurrBSS ) 1333 { 1334 WLAN_REPORT_ERROR(pCurrBSS->hReport, CURR_BSS_MODULE_LOG,("Pointer to Curr BSS NULL, abort Reset !")) ; 1335 return NOK; 1336 } 1337 1338 1339 if (pCurrBSS->isConnected) 1340 { 1341 WLAN_REPORT_INFORMATION(pCurrBSS->hReport, CURR_BSS_MODULE_LOG,("Reset Current Connected BSS" )); 1342 1343 /* If we got the Reset_BSS Event from FW since TSF was changed may indicate BSS reset in the AP 1344 requier to initiate fist beacon mechanism and also test connectivity with the AP (NULL packet)*/ 1345 siteMgr_clearFirstBcnFlag(pCurrBSS->hSiteMgr); 1346 1347 1348 1349 } 1350 else 1351 { 1352 WLAN_REPORT_ERROR(pCurrBSS->hReport, CURR_BSS_MODULE_LOG,("Can't Reset BSS not connected !" )); 1353 } 1354 return OK; 1355 1356 } 1357 1358