4 * Copyright(c) 1998 - 2010 Texas Instruments. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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
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.
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.
35 * \brief Current BSS info
40 /****************************************************************************
42 * MODULE: Current BSS *
44 * Roaming ability of eSTA is implemented by Roaming Manager Component and
45 * described in "Roaming Manager module LLD" document, and by
46 * AP Connection module. AP Connection module implemented as two sub-modules.
47 * The major one is AP Connection, that is responsible for:
48 * - providing Roaming Manager with access to other parts of WLAN Driver,
49 * - implementing low levels of roaming mechanism.
50 * Current BSS sub-module takes care of:
51 * - maintaining database of current AP info,
52 * - providing access to database of current AP info.
53 * The Current BSS represents the BSS we are currently connected to.
54 * Among other parameters, it holds the capabilities of the current AP,
55 * its ID and its quality.
56 * When FW indicates 'Out of Sync' event, Current BSS module is responsible
57 * for awaking the device, sending unicast Probe request, waiting for
58 * response and - in case FW comes to the conclusion that there was
59 * no response - for triggering "Beacon missed" to AP Connection module.
60 * In eSTA5.0 FW updates and checks the quality of the connection with
61 * current AP. Current BSS module is responsible to handle event of type
62 * 'Low RSSI' from FW. Third type of roaming event reported by FW is
63 * 'Consecutive no ack on TX", and it is handled as well by Current
64 * BSS module.Upon reception of any roaming event from FW, Current BSS
65 * module is transferring this event to the AP Connection module in case
66 * of BSS connection, or to SME module in case of IBSS connection.
67 * When WLAN driver is working in IBSS mode, Current BSS module is holding
68 * the parameters of BSS (channel, band, SSID etc.).
70 ****************************************************************************/
72 #define __FILE_ID__ FILE_ID_65
74 #include "currBssApi.h"
77 #include "802_11Defs.h"
78 #include "DataCtrl_Api.h"
79 #include "qosMngr_API.h"
80 #include "regulatoryDomainApi.h"
82 #include "scanMngrApi.h"
83 #include "MacServices_api.h"
87 #include "EvHandler.h"
88 #include "DrvMainModules.h"
89 #include "siteMgrApi.h"
91 #include "roamingMngrTypes.h"
94 #define TRIGGER_LOW_RSSI_PACING 1000
95 #define TRIGGER_LOW_SNR_PACING 1000
96 #define TRIGGER_BG_SCAN_PACING 10
97 #define TRIGGER_BG_SCAN_HYSTERESIS 3
98 static const TI_UINT32 KEEP_ALIVE_NULL_DATA_INDEX = 3;
105 typedef TI_UINT8 (*currBSS_beaconRxCallb_t) (TI_HANDLE hModule, TI_UINT64 staTSF, TI_UINT8 dtimCount);
111 /* Internal functions prototypes */
113 static void currBSS_lowRssiThrCrossed(currBSS_t *hCurrBSS, TI_UINT8 *data, TI_UINT8 dataLength);
114 static void currBSS_lowSnrThrCrossed(currBSS_t *hCurrBSS, TI_UINT8 *data, TI_UINT8 dataLength);
115 static void currBSS_BackgroundScanQuality(TI_HANDLE hCurrBSS, TI_UINT8 *data, TI_UINT8 dataLength);
116 static void currBSS_consecTxErrors(currBSS_t *hCurrBSS, TI_UINT8 *data, TI_UINT8 dataLength);
117 static void currBSS_BssLost (currBSS_t *hCurrBSS, TI_UINT8 *data, TI_UINT8 dataLength);
118 static void currBSS_reportRoamingEvent(currBSS_t *hCurrBSS, apConn_roamingTrigger_e roamingEventType, roamingEventData_u *pRoamingEventData);
119 static void currBSS_updateBSSLoss(currBSS_t *pCurrBSS);
121 static TI_STATUS currBss_HandleTriggerEvent(TI_HANDLE hCurrBSS, TI_UINT8 *data, TI_UINT8 dataLength, TI_UINT8 eventID);
122 static triggerDesc_t* currBss_findEmptyUserTrigger(TI_HANDLE hCurrBSS, TI_UINT16 clientID, TI_UINT8* triggerIdx);
123 static void currBSS_RssiSnrTrigger0 (TI_HANDLE hCurrBSS, TI_UINT8 *data, TI_UINT8 dataLength);
124 static void currBSS_RssiSnrTrigger1 (TI_HANDLE hCurrBSS, TI_UINT8 *data, TI_UINT8 dataLength);
125 static void currBSS_RssiSnrTrigger2 (TI_HANDLE hCurrBSS, TI_UINT8 *data, TI_UINT8 dataLength);
126 static void currBSS_RssiSnrTrigger3 (TI_HANDLE hCurrBSS, TI_UINT8 *data, TI_UINT8 dataLength);
127 static void currBSS_RssiSnrTrigger4 (TI_HANDLE hCurrBSS, TI_UINT8 *data, TI_UINT8 dataLength);
128 static void currBSS_RssiSnrTrigger5 (TI_HANDLE hCurrBSS, TI_UINT8 *data, TI_UINT8 dataLength);
129 static void currBSS_RssiSnrTrigger6 (TI_HANDLE hCurrBSS, TI_UINT8 *data, TI_UINT8 dataLength);
130 static void currBSS_RssiSnrTrigger7 (TI_HANDLE hCurrBSS, TI_UINT8 *data, TI_UINT8 dataLength);
132 /* Public functions implementation */
142 * Create the Current BSS context: allocate memory for internal variables
146 * I - hOS - the handle to the OS object
150 * TI_OK on success, TI_NOK on failure.
154 TI_HANDLE currBSS_create(TI_HANDLE hOs)
158 if ((pCurrBss = os_memoryAlloc(hOs, sizeof(currBSS_t))) != NULL)
164 else /* Failed to allocate control block */
166 WLAN_OS_REPORT(("FATAL ERROR: currBSS_create(): Error allocating cb - aborting\n"));
178 * Finish Current BSS module work.
185 * TI_OK on success, TI_NOK on failure.
189 TI_STATUS currBSS_unload(TI_HANDLE hCurrBSS)
193 if (hCurrBSS != NULL)
195 pCurrBSS = (currBSS_t *)hCurrBSS;
197 /* Free pre-allocated control block */
198 os_memoryFree(pCurrBSS->hOs, pCurrBSS, sizeof(currBSS_t));
210 * Get other modules handles.
214 * I pStadHandles - The driver modules handles
222 void currBSS_init (TStadHandlesList *pStadHandles)
224 currBSS_t *pCurrBSS = (currBSS_t *)(pStadHandles->hCurrBss);
227 pCurrBSS->hAPConn = pStadHandles->hAPConnection;
228 pCurrBSS->hTWD = pStadHandles->hTWD;
229 pCurrBSS->hMlme = pStadHandles->hMlmeSm;
230 pCurrBSS->hPowerMngr = pStadHandles->hPowerMgr;
231 pCurrBSS->hSme = pStadHandles->hSme;
232 pCurrBSS->hSiteMgr = pStadHandles->hSiteMgr;
233 pCurrBSS->hConn = pStadHandles->hConn;
234 pCurrBSS->hReport = pStadHandles->hReport;
235 pCurrBSS->hScanMngr = pStadHandles->hScanMngr;
236 pCurrBSS->hEvHandler = pStadHandles->hEvHandler;
237 pCurrBSS->hTxCtrl = pStadHandles->hTxCtrl;
239 for (i=0; i< MAX_NUM_OF_RSSI_SNR_TRIGGERS ; i++)
241 pCurrBSS->aTriggersDesc[i].clientID = 0;
242 pCurrBSS->aTriggersDesc[i].fCB = NULL;
243 pCurrBSS->aTriggersDesc[i].hCB = NULL;
244 pCurrBSS->aTriggersDesc[i].WasRegisteredByApp = TI_FALSE;
252 * currBSS_SetDefaults
256 * Prepare Current BSS module to work
260 * I - hCurrBSS - Current BSS handle \n
264 * TI_OK on success, TI_NOK on failure.
268 TI_STATUS currBSS_SetDefaults (TI_HANDLE hCurrBSS, TCurrBssInitParams *pInitParams)
270 currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS;
271 TRroamingTriggerParams params;
272 RssiSnrTriggerCfg_t tTriggerCfg;
274 /* save the roaming operational mode */
275 pCurrBSS->RoamingOperationalMode = pInitParams->RoamingOperationalMode;
277 /* Registration succeeded, continue with init procedure */
278 pCurrBSS->band = RADIO_BAND_2_4_GHZ;
279 pCurrBSS->channel = 0;
280 pCurrBSS->isConnected = TI_FALSE;
281 pCurrBSS->type = BSS_ANY;
282 pCurrBSS->currAPInfo.RSSI = 0;
283 pCurrBSS->bUseSGParams = TI_FALSE;
284 pCurrBSS->uDefaultKeepAlivePeriod = pInitParams->uNullDataKeepAlivePeriod;
287 /* register the static callbacks */
288 TWD_RegisterEvent(pCurrBSS->hTWD,TWD_OWN_EVENT_RSSI_SNR_TRIGGER_0,(void*) currBSS_RssiSnrTrigger0, pCurrBSS);
289 TWD_RegisterEvent(pCurrBSS->hTWD,TWD_OWN_EVENT_RSSI_SNR_TRIGGER_1,(void*) currBSS_RssiSnrTrigger1, pCurrBSS);
290 TWD_RegisterEvent(pCurrBSS->hTWD,TWD_OWN_EVENT_RSSI_SNR_TRIGGER_2,(void*) currBSS_RssiSnrTrigger2, pCurrBSS);
291 TWD_RegisterEvent(pCurrBSS->hTWD,TWD_OWN_EVENT_RSSI_SNR_TRIGGER_3,(void*) currBSS_RssiSnrTrigger3, pCurrBSS);
292 TWD_RegisterEvent(pCurrBSS->hTWD,TWD_OWN_EVENT_RSSI_SNR_TRIGGER_4,(void*) currBSS_RssiSnrTrigger4, pCurrBSS);
293 TWD_RegisterEvent(pCurrBSS->hTWD,TWD_OWN_EVENT_RSSI_SNR_TRIGGER_5,(void*) currBSS_RssiSnrTrigger5, pCurrBSS);
294 TWD_RegisterEvent(pCurrBSS->hTWD,TWD_OWN_EVENT_RSSI_SNR_TRIGGER_6,(void*) currBSS_RssiSnrTrigger6, pCurrBSS);
295 TWD_RegisterEvent(pCurrBSS->hTWD,TWD_OWN_EVENT_RSSI_SNR_TRIGGER_7,(void*) currBSS_RssiSnrTrigger7, pCurrBSS);
297 if (ROAMING_OPERATIONAL_MODE_AUTO == pCurrBSS->RoamingOperationalMode)
299 /* Configure and enable the Low RSSI, the Low SNR and the Missed beacon events */
300 currBSS_RegisterTriggerEvent(hCurrBSS, TWD_OWN_EVENT_RSSI_SNR_TRIGGER_0, 0, (void*)currBSS_lowRssiThrCrossed, hCurrBSS);
301 currBSS_RegisterTriggerEvent(hCurrBSS, TWD_OWN_EVENT_RSSI_SNR_TRIGGER_1, 0, (void*)currBSS_lowSnrThrCrossed, hCurrBSS);
302 currBSS_RegisterTriggerEvent(hCurrBSS, TWD_OWN_EVENT_RSSI_SNR_TRIGGER_4, 0, (void*)currBSS_BackgroundScanQuality, hCurrBSS);
304 pCurrBSS->lowRssiThreshold = RSSI_DEFAULT_THRESHOLD;
305 tTriggerCfg.index = TRIGGER_EVENT_LOW_RSSI;
306 tTriggerCfg.threshold = pCurrBSS->lowRssiThreshold;
307 tTriggerCfg.pacing = TRIGGER_LOW_RSSI_PACING;
308 tTriggerCfg.metric = METRIC_EVENT_RSSI_BEACON;
309 tTriggerCfg.type = RX_QUALITY_EVENT_LEVEL;
310 tTriggerCfg.direction = RSSI_EVENT_DIR_LOW;
311 tTriggerCfg.hystersis = 0;
312 tTriggerCfg.enable = TI_TRUE;
313 TWD_CfgRssiSnrTrigger (pCurrBSS->hTWD, &tTriggerCfg);
315 pCurrBSS->lowSnrThreshold = SNR_DEFAULT_THRESHOLD;
316 tTriggerCfg.index = TRIGGER_EVENT_LOW_SNR;
317 tTriggerCfg.threshold = pCurrBSS->lowSnrThreshold;
318 tTriggerCfg.pacing = TRIGGER_LOW_SNR_PACING;
319 tTriggerCfg.metric = METRIC_EVENT_SNR_BEACON;
320 tTriggerCfg.type = RX_QUALITY_EVENT_LEVEL;
321 tTriggerCfg.direction = RSSI_EVENT_DIR_LOW;
322 tTriggerCfg.hystersis = 0;
323 tTriggerCfg.enable = TI_TRUE;
324 TWD_CfgRssiSnrTrigger (pCurrBSS->hTWD, &tTriggerCfg);
326 pCurrBSS->highQualityForBkgrdScan = RSSI_DEFAULT_THRESHOLD;
327 pCurrBSS->lowQualityForBkgrdScan = RSSI_DEFAULT_THRESHOLD;
328 tTriggerCfg.index = TRIGGER_EVENT_BG_SCAN;
329 tTriggerCfg.threshold = pCurrBSS->lowQualityForBkgrdScan;
330 tTriggerCfg.pacing = TRIGGER_BG_SCAN_PACING;
331 tTriggerCfg.metric = METRIC_EVENT_RSSI_DATA;
332 tTriggerCfg.type = RX_QUALITY_EVENT_EDGE;
333 tTriggerCfg.direction = RSSI_EVENT_DIR_BIDIR;
334 tTriggerCfg.hystersis = TRIGGER_BG_SCAN_HYSTERESIS;
335 tTriggerCfg.enable = TI_TRUE;
336 TWD_CfgRssiSnrTrigger (pCurrBSS->hTWD, &tTriggerCfg);
338 /* Register for 'BSS-Loss' event */
339 TWD_RegisterEvent (pCurrBSS->hTWD, TWD_OWN_EVENT_BSS_LOSE, (void *)currBSS_BssLost, pCurrBSS);
340 TWD_EnableEvent (pCurrBSS->hTWD, TWD_OWN_EVENT_BSS_LOSE);
342 /* save last configured value for handling Soft Gemini changes */
343 pCurrBSS->numExpectedTbttForBSSLoss = OUT_OF_SYNC_DEFAULT_THRESHOLD;
344 params.TsfMissThreshold = OUT_OF_SYNC_DEFAULT_THRESHOLD;
345 params.BssLossTimeout = NO_BEACON_DEFAULT_TIMEOUT;
346 TWD_CfgConnMonitParams (pCurrBSS->hTWD, ¶ms);
348 /* Register for 'Consec. Tx error' */
349 TWD_RegisterEvent (pCurrBSS->hTWD, TWD_OWN_EVENT_MAX_TX_RETRY, (void *)currBSS_consecTxErrors, pCurrBSS);
350 TWD_EnableEvent (pCurrBSS->hTWD, TWD_OWN_EVENT_MAX_TX_RETRY);
352 pCurrBSS->maxTxRetryThreshold = NO_ACK_DEFAULT_THRESHOLD;
353 params.maxTxRetry = NO_ACK_DEFAULT_THRESHOLD;
354 TWD_CfgMaxTxRetry (pCurrBSS->hTWD, ¶ms);
363 * currBSS_updateRoamingTriggers
367 * Configure parameter of Current BSS
371 * I - hCurrBSS - Current BSS handle \n
372 * I - params - pointer to datablock of roaming threshols \n
376 * TI_OK on success, TI_NOK on failure.
380 TI_STATUS currBSS_updateRoamingTriggers (TI_HANDLE hCurrBSS, roamingMngrThresholdsConfig_t *params)
382 currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS;
383 TRroamingTriggerParams roamingTriggersParams;
384 RssiSnrTriggerCfg_t tTriggerCfg;
386 if (pCurrBSS->lowRssiThreshold != params->lowRssiThreshold)
388 pCurrBSS->lowRssiThreshold = params->lowRssiThreshold;
390 tTriggerCfg.index = TRIGGER_EVENT_LOW_RSSI;
391 tTriggerCfg.threshold = pCurrBSS->lowRssiThreshold;
392 tTriggerCfg.pacing = TRIGGER_LOW_RSSI_PACING;
393 tTriggerCfg.metric = METRIC_EVENT_RSSI_BEACON;
394 tTriggerCfg.type = RX_QUALITY_EVENT_LEVEL;
395 tTriggerCfg.direction = RSSI_EVENT_DIR_LOW;
396 tTriggerCfg.hystersis = 0;
397 tTriggerCfg.enable = TI_TRUE;
399 TWD_CfgRssiSnrTrigger (pCurrBSS->hTWD, &tTriggerCfg);
402 if (pCurrBSS->lowSnrThreshold != params->lowSnrThreshold)
404 pCurrBSS->lowSnrThreshold = params->lowSnrThreshold;
406 tTriggerCfg.index = TRIGGER_EVENT_LOW_SNR;
407 tTriggerCfg.threshold = pCurrBSS->lowSnrThreshold;
408 tTriggerCfg.pacing = TRIGGER_LOW_SNR_PACING;
409 tTriggerCfg.metric = METRIC_EVENT_SNR_BEACON;
410 tTriggerCfg.type = RX_QUALITY_EVENT_LEVEL;
411 tTriggerCfg.direction = RSSI_EVENT_DIR_LOW;
412 tTriggerCfg.hystersis = 0;
413 tTriggerCfg.enable = TI_TRUE;
415 TWD_CfgRssiSnrTrigger (pCurrBSS->hTWD, &tTriggerCfg);
418 if (pCurrBSS->lowQualityForBkgrdScan != params->lowQualityForBackgroungScanCondition)
420 pCurrBSS->lowQualityForBkgrdScan = params->lowQualityForBackgroungScanCondition;
421 tTriggerCfg.index = TRIGGER_EVENT_BG_SCAN;
422 tTriggerCfg.threshold = pCurrBSS->lowQualityForBkgrdScan;
423 tTriggerCfg.pacing = TRIGGER_BG_SCAN_PACING;
424 tTriggerCfg.metric = METRIC_EVENT_RSSI_DATA;
425 tTriggerCfg.type = RX_QUALITY_EVENT_EDGE;
426 tTriggerCfg.direction = RSSI_EVENT_DIR_BIDIR;
427 tTriggerCfg.hystersis = TRIGGER_BG_SCAN_HYSTERESIS;
428 tTriggerCfg.enable = TI_TRUE;
430 TWD_CfgRssiSnrTrigger (pCurrBSS->hTWD, &tTriggerCfg);
433 if (pCurrBSS->numExpectedTbttForBSSLoss != params->numExpectedTbttForBSSLoss)
435 /* save last configured value for handling Soft Gemini changes */
436 pCurrBSS->numExpectedTbttForBSSLoss = params->numExpectedTbttForBSSLoss;
437 /* Configure TWD with 'No BSS' thresholds (Same as the other parameters but in a special
438 function for the Soft Gemini module consideration) */
439 currBSS_updateBSSLoss(pCurrBSS);
442 /* Configure TWD with 'Consecutive NACK' thresholds */
443 if (pCurrBSS->maxTxRetryThreshold != params->dataRetryThreshold)
445 pCurrBSS->maxTxRetryThreshold = params->dataRetryThreshold;
446 roamingTriggersParams.maxTxRetry = pCurrBSS->maxTxRetryThreshold;
447 TWD_CfgMaxTxRetry (pCurrBSS->hTWD, &roamingTriggersParams);
450 pCurrBSS->highQualityForBkgrdScan = params->normalQualityForBackgroungScanCondition;
457 * currBSS_getRoamingParams
461 * Retrieves the roaming triggers stored in the CurrBSS module.
465 * I - hCurrBSS - Current BSS handle \n
466 * O - aNumExpectedTbttForBSSLoss - Current BSS handle \n
467 * O - aLowQualityForBackgroungScanCondition - Current BSS handle \n
468 * O - aNormalQualityForBackgroungScanCondition - Current BSS handle \n
472 * TI_OK on success, TI_NOK on failure.
476 TI_STATUS currBSS_getRoamingParams(TI_HANDLE hCurrBSS,
477 TI_UINT8 * aNumExpectedTbttForBSSLoss,
478 TI_INT8 * aLowQualityForBackgroungScanCondition,
479 TI_INT8 * aNormalQualityForBackgroungScanCondition)
481 currBSS_t * pCurrBSS = (currBSS_t *) hCurrBSS;
483 *aNumExpectedTbttForBSSLoss = pCurrBSS->numExpectedTbttForBSSLoss;
484 *aLowQualityForBackgroungScanCondition = pCurrBSS->lowQualityForBkgrdScan;
485 *aNormalQualityForBackgroungScanCondition = pCurrBSS->highQualityForBkgrdScan;
492 * currBSS_SGconfigureBSSLoss
496 * This function is called by the Soft Gemini module in order to enable/disable the use of
497 * the compensation value for the BSSLoss count , and the percent of increasing that value
498 * It also set the new parameter to the FW (with another generic function)
499 * The compensation is needed since BT activity might over-run recieved beacons
504 * I - hCurrBSS - Current BSS handle \n
505 * SGcompensationPercent - percent of increasing the BSSLoss value to the FW \n
506 * bUseSGParams - whether to use the SG compensation
515 void currBSS_SGconfigureBSSLoss(TI_HANDLE hCurrBSS,
516 TI_UINT32 SGcompensationPercent , TI_BOOL bUseSGParams)
518 currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS;
520 pCurrBSS->bUseSGParams = bUseSGParams;
521 pCurrBSS->SGcompensationPercent = SGcompensationPercent;
523 TRACE1(pCurrBSS->hReport, REPORT_SEVERITY_INFORMATION, "CurrBSS_SGConf: SG =%d\n", pCurrBSS->bUseSGParams);
525 /* update the change of BSSLoss in the FW */
526 currBSS_updateBSSLoss(pCurrBSS);
531 * currBSS_updateBSSLoss
535 * This function updates only BSS Loss parameter , we need it to be able to consider the
536 * Soft Gemini status , and change the parameter according to it
540 * I - pCurrBSS - Current BSS handle \n
548 void currBSS_updateBSSLoss(currBSS_t *pCurrBSS)
550 TRroamingTriggerParams roamingTriggersParams;
551 TI_UINT16 desiredBeaconInterval = 0;
552 TI_UINT32 connSelfTimeout = 0;
555 pParam = (paramInfo_t *)os_memoryAlloc(pCurrBSS->hOs, sizeof(paramInfo_t));
558 pParam->paramType = SITE_MGR_DESIRED_BEACON_INTERVAL_PARAM;
559 siteMgr_getParam(pCurrBSS->hSiteMgr, pParam);
560 desiredBeaconInterval = pParam->content.siteMgrDesiredBeaconInterval;
562 pParam->paramType = CONN_SELF_TIMEOUT_PARAM;
563 conn_getParam(pCurrBSS->hConn, pParam);
564 connSelfTimeout = pParam->content.connSelfTimeout;
566 os_memoryFree(pCurrBSS->hOs, pParam, sizeof(paramInfo_t));
570 TRACE0(pCurrBSS->hReport, REPORT_SEVERITY_ERROR, "currBSS_updateBSSLoss: Error allocating paramInfo_t\n");
573 if (pCurrBSS->type == BSS_INDEPENDENT)
575 if (desiredBeaconInterval > 0)
577 /* Calculate the number of beacons for miss timeout */
578 roamingTriggersParams.TsfMissThreshold = connSelfTimeout / desiredBeaconInterval;
582 /* Use default parameter */
583 roamingTriggersParams.TsfMissThreshold = OUT_OF_SYNC_IBSS_THRESHOLD;
586 else /* In Infra we use the saved parameter */
588 roamingTriggersParams.TsfMissThreshold = pCurrBSS->numExpectedTbttForBSSLoss;
591 roamingTriggersParams.BssLossTimeout = NO_BEACON_DEFAULT_TIMEOUT;
593 TRACE2(pCurrBSS->hReport, REPORT_SEVERITY_INFORMATION, ": SG=%d, Band=%d\n", pCurrBSS->bUseSGParams, pCurrBSS->currAPInfo.band);
595 /* if Soft Gemini is enabled - increase the BSSLoss value (because BT activity might over-run beacons) */
596 if ((pCurrBSS->bUseSGParams) && (pCurrBSS->currAPInfo.band == RADIO_BAND_2_4_GHZ))
598 roamingTriggersParams.TsfMissThreshold = (roamingTriggersParams.TsfMissThreshold *
599 (100 + pCurrBSS->SGcompensationPercent)) / 100;
601 TRACE2(pCurrBSS->hReport, REPORT_SEVERITY_INFORMATION, ": old value = %d, new value (for SG compensation) = %d\n", pCurrBSS->numExpectedTbttForBSSLoss,roamingTriggersParams.TsfMissThreshold);
604 TWD_CfgConnMonitParams (pCurrBSS->hTWD, &roamingTriggersParams);
609 * currBSS_swChFinished
613 * Called when switch channel process is complete in order to reset RSSI calculations
617 * I - hCurrBSS - Current BSS handle \n
625 void currBSS_restartRssiCounting(TI_HANDLE hCurrBSS)
627 currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS;
629 pCurrBSS->currAPInfo.RSSI = 0;
638 * Get parameter of Current BSS
642 * I - hCurrBSS - Current BSS handle \n
646 * pointer to current BSS info block.
650 bssEntry_t *currBSS_getBssInfo(TI_HANDLE hCurrBSS)
652 currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS;
654 /* Return pointer to current AP info */
655 return &(pCurrBSS->currAPInfo);
661 * currBSS_probRespReceivedCallb
665 * Callback function, provided to MLME module. Called each time Probe response received.
666 * This function verifies that the Probe response was sent by current AP, and then
667 * updates current AP database.
671 * I - hCurrBSS - Current BSS handle \n
675 * TI_OK on success, TI_NOK on failure.
679 TI_STATUS currBSS_probRespReceivedCallb(TI_HANDLE hCurrBSS,
682 mlmeFrameInfo_t *pFrameInfo,
683 TI_UINT8 *dataBuffer,
686 currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS;
689 pParam = (paramInfo_t *)os_memoryAlloc(pCurrBSS->hOs, sizeof(paramInfo_t));
694 pParam->paramType = SITE_MGR_CURRENT_BSSID_PARAM;
695 siteMgr_getParam(pCurrBSS->hSiteMgr, pParam);
697 if (pCurrBSS->isConnected && MAC_EQUAL (pParam->content.siteMgrDesiredBSSID, *bssid))
699 siteMgr_updateSite(pCurrBSS->hSiteMgr, bssid, pFrameInfo, pRxAttr->channel, (ERadioBand)pRxAttr->band, TI_FALSE);
700 /* Save the IE part of the Probe Response buffer in the site table */
701 siteMgr_saveProbeRespBuffer(pCurrBSS->hSiteMgr, bssid, (TI_UINT8 *)dataBuffer, bufLength);
703 os_memoryFree(pCurrBSS->hOs, pParam, sizeof(paramInfo_t));
711 * currBSS_beaconReceivedCallb
715 * Callback function, provided to MLME module. Called each time Beacon received.
716 * This function verifies that the Probe response was sent by current AP, and then
717 * updates current AP database.
721 * I - hCurrBSS - Current BSS handle \n
725 * TI_OK on success, TI_NOK on failure.
729 TI_STATUS currBSS_beaconReceivedCallb(TI_HANDLE hCurrBSS,
732 mlmeFrameInfo_t *pFrameInfo,
733 TI_UINT8 *dataBuffer,
736 currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS;
738 ScanBssType_e eFrameBssType, eCurrentBSSType;
739 TMacAddr desiredBSSID;
741 pParam = (paramInfo_t *)os_memoryAlloc(pCurrBSS->hOs, sizeof(paramInfo_t));
747 eFrameBssType = ((pFrameInfo->content.iePacket.capabilities >> CAP_ESS_SHIFT) & CAP_ESS_MASK) ? BSS_INFRASTRUCTURE : BSS_INDEPENDENT;
749 /* Get current BSS type */
750 pParam->paramType = SITE_MGR_CURRENT_BSS_TYPE_PARAM;
751 siteMgr_getParam (pCurrBSS->hSiteMgr, pParam);
752 eCurrentBSSType = pParam->content.siteMgrCurrentBSSType; /* Save parameter because the next line overrides it */
754 /* Get current BSSID */
755 pParam->paramType = SITE_MGR_CURRENT_BSSID_PARAM;
756 siteMgr_getParam(pCurrBSS->hSiteMgr, pParam);
757 TRACE12(pCurrBSS->hReport, REPORT_SEVERITY_INFORMATION,
758 "currBSS_beaconReceivedCallb: bssid = %02x.%02x.%02x.%02x.%02x.%02x, siteMgrDesiredBSSID = %02x.%02x.%02x.%02x.%02x.%02x\n",
759 (*bssid)[0], (*bssid)[1], (*bssid)[2], (*bssid)[3], (*bssid)[4], (*bssid)[5],
760 pParam->content.siteMgrDesiredBSSID[0],
761 pParam->content.siteMgrDesiredBSSID[1],
762 pParam->content.siteMgrDesiredBSSID[2],
763 pParam->content.siteMgrDesiredBSSID[3],
764 pParam->content.siteMgrDesiredBSSID[4],
765 pParam->content.siteMgrDesiredBSSID[5]);
766 MAC_COPY(desiredBSSID, pParam->content.siteMgrDesiredBSSID);
768 if (pCurrBSS->isConnected && (eCurrentBSSType == eFrameBssType))
770 TI_BOOL bFramePrivacy = 0, bCurrentSitePrivacy = 0;
771 /* if the bss type is ibss save set the current site privacy (the beacons transimted by STA)
772 and set the privacy from the received frame, so that if the privacy is different there will
774 if (eFrameBssType == BSS_INDEPENDENT)
776 pParam->paramType = SITE_MGR_SITE_CAPABILITY_PARAM;
777 siteMgr_getParam(pCurrBSS->hSiteMgr, pParam);
779 bCurrentSitePrivacy = ((pParam->content.siteMgrSiteCapability >> CAP_PRIVACY_SHIFT) & CAP_PRIVACY_MASK) ? TI_TRUE : TI_FALSE;
780 bFramePrivacy = ((pFrameInfo->content.iePacket.capabilities >> CAP_PRIVACY_SHIFT) & CAP_PRIVACY_MASK) ? TI_TRUE : TI_FALSE;
783 if (MAC_EQUAL(desiredBSSID, *bssid))
785 if ((eFrameBssType == BSS_INFRASTRUCTURE) ||
786 ((eFrameBssType == BSS_INDEPENDENT) && (bCurrentSitePrivacy == bFramePrivacy)) )
788 siteMgr_updateSite(pCurrBSS->hSiteMgr, bssid, pFrameInfo, pRxAttr->channel, (ERadioBand)pRxAttr->band, TI_FALSE);
789 /* Save the IE part of the beacon buffer in the site table */
790 siteMgr_saveBeaconBuffer(pCurrBSS->hSiteMgr, bssid, (TI_UINT8 *)dataBuffer, bufLength);
793 else if (eFrameBssType == BSS_INDEPENDENT)
795 /* Check if the Station sending the beacon uses privacy for the ibss and
796 compare it to the self site. If privacy usage mathces, merge ibss
797 and if not continue using self site */
798 if (bCurrentSitePrivacy == bFramePrivacy)
800 siteMgr_IbssMerge(pCurrBSS->hSiteMgr, desiredBSSID, *bssid,
801 pFrameInfo, pRxAttr->channel, (ERadioBand)pRxAttr->band);
802 siteMgr_updateSite(pCurrBSS->hSiteMgr, bssid, pFrameInfo, pRxAttr->channel, (ERadioBand)pRxAttr->band, TI_FALSE);
803 siteMgr_saveBeaconBuffer(pCurrBSS->hSiteMgr, bssid, (TI_UINT8 *)dataBuffer, bufLength);
808 os_memoryFree(pCurrBSS->hOs, pParam, sizeof(paramInfo_t));
815 * currBSS_updateConnectedState
819 * This function is called when FW recovery performed.
823 * I - hCurrBSS - Current BSS handle \n
824 * I - isConnected - TI_TRUE or TI_FALSE \n
825 * I - type - IBSS or EBSS \n
833 void currBSS_updateConnectedState(TI_HANDLE hCurrBSS, TI_BOOL isConnected, ScanBssType_e type)
835 currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS;
837 pCurrBSS->type = type;
838 pCurrBSS->isConnected = isConnected;
842 /*** Store the info of current AP ***/
845 pParam = (paramInfo_t *)os_memoryAlloc(pCurrBSS->hOs, sizeof(paramInfo_t));
852 pParam->paramType = SITE_MGR_CURRENT_BSSID_PARAM;
853 siteMgr_getParam(pCurrBSS->hSiteMgr, pParam);
854 MAC_COPY (pCurrBSS->currAPInfo.BSSID, pParam->content.siteMgrDesiredBSSID);
857 pParam->paramType = SITE_MGR_LAST_RX_RATE_PARAM;
858 siteMgr_getParam(pCurrBSS->hSiteMgr, pParam);
859 pCurrBSS->currAPInfo.rxRate = pParam->content.ctrlDataCurrentBasicRate;
862 pParam->paramType = SITE_MGR_RADIO_BAND_PARAM;
863 siteMgr_getParam(pCurrBSS->hSiteMgr, pParam);
864 pCurrBSS->currAPInfo.band = pParam->content.siteMgrRadioBand;
867 pParam->paramType = SITE_MGR_CURRENT_CHANNEL_PARAM;
868 siteMgr_getParam(pCurrBSS->hSiteMgr, pParam);
869 pCurrBSS->currAPInfo.channel = pParam->content.siteMgrCurrentChannel;
872 pParam->paramType = SITE_MGR_CURRENT_TSF_TIME_STAMP;
873 siteMgr_getParam(pCurrBSS->hSiteMgr, pParam);
874 os_memoryCopy(pCurrBSS->hOs, &pCurrBSS->currAPInfo.lastRxTSF,
875 pParam->content.siteMgrCurrentTsfTimeStamp, sizeof(pCurrBSS->currAPInfo.lastRxTSF));
877 /* Beacon interval */
878 pParam->paramType = SITE_MGR_BEACON_INTERVAL_PARAM;
879 siteMgr_getParam(pCurrBSS->hSiteMgr, pParam);
880 pCurrBSS->currAPInfo.beaconInterval = pParam->content.beaconInterval;
883 pParam->paramType = SITE_MGR_SITE_CAPABILITY_PARAM;
884 siteMgr_getParam(pCurrBSS->hSiteMgr,pParam);
885 pCurrBSS->currAPInfo.capabilities = pParam->content.siteMgrSiteCapability;
886 pParam->paramType = SITE_MGR_CURRENT_TSF_TIME_STAMP;
887 siteMgr_getParam(pCurrBSS->hSiteMgr, pParam);
889 /* pCurrBSS->currAPInfo.lastRxHostTimestamp = *((TI_UINT64 *)(pIEs->TimeStamp));*/ /* TBD*/
890 os_memoryCopy(pCurrBSS->hOs, &pCurrBSS->currAPInfo.lastRxHostTimestamp, pParam->content.siteMgrCurrentTsfTimeStamp, sizeof(TI_UINT32));
892 pParam->paramType = SITE_MGR_LAST_BEACON_BUF_PARAM;
893 siteMgr_getParam(pCurrBSS->hSiteMgr, pParam);
894 pCurrBSS->currAPInfo.pBuffer = pParam->content.siteMgrLastBeacon.buffer;
895 pCurrBSS->currAPInfo.bufferLength = pParam->content.siteMgrLastBeacon.bufLength;
896 pCurrBSS->currAPInfo.resultType = (pParam->content.siteMgrLastBeacon.isBeacon) ? SCAN_RFT_BEACON : SCAN_RFT_PROBE_RESPONSE;
898 /* Set BSS Loss to Fw - note that it depends on the Connection type - (Infa/IBSS) */
899 currBSS_updateBSSLoss(pCurrBSS);
901 if(type == BSS_INFRASTRUCTURE)
903 TI_UINT32 uKeepAlivePreiod = pCurrBSS->uDefaultKeepAlivePeriod * 1000; /* convert to ms */
904 TSetTemplate tKeepAliveTemplate;
905 TKeepAliveParams tKeepAliveParams;
908 * only configure the null-data keepa-live message if the interval is valid
909 * (either the default interval or the one from teh XCC IE)
911 if (0 != uKeepAlivePreiod)
913 TRACE0(pCurrBSS->hReport, REPORT_SEVERITY_INFORMATION , "currBSS_updateConnectedState: Configuring null-data keep-alive");
915 /* build null-data template */
916 tKeepAliveTemplate.ptr = &(pCurrBSS->keepAliveBuffer[ 0 ]);
917 if ( TI_OK != txCtrlServ_buildNullFrame (pCurrBSS->hTxCtrl,
918 tKeepAliveTemplate.ptr, &(tKeepAliveTemplate.len)))
920 TRACE0(pCurrBSS->hReport, REPORT_SEVERITY_ERROR , "currBSS_updateConnectedState: error building null data frame\n");
924 /* configure null-data template */
925 tKeepAliveTemplate.type = KEEP_ALIVE_TEMPLATE;
926 tKeepAliveTemplate.index = KEEP_ALIVE_NULL_DATA_INDEX;
927 tKeepAliveTemplate.uRateMask = RATE_MASK_UNSPECIFIED;
928 TWD_CmdTemplate (pCurrBSS->hTWD, &tKeepAliveTemplate, NULL, NULL);
930 /* configure paramters */
931 tKeepAliveParams.index = KEEP_ALIVE_NULL_DATA_INDEX;
932 tKeepAliveParams.enaDisFlag = TI_TRUE; /* enabled */
933 tKeepAliveParams.trigType = KEEP_ALIVE_TRIG_TYPE_NO_TX;
934 tKeepAliveParams.interval = uKeepAlivePreiod;
935 TWD_CfgKeepAlive (pCurrBSS->hTWD, &tKeepAliveParams);
938 os_memoryFree(pCurrBSS->hOs, pParam, sizeof(paramInfo_t));
942 if(type == BSS_INFRASTRUCTURE)
944 TKeepAliveParams tKeepAliveParams;
946 /* disable NULL-data keep-palive template */
947 tKeepAliveParams.index = KEEP_ALIVE_NULL_DATA_INDEX;
948 tKeepAliveParams.enaDisFlag = TI_FALSE; /* disabled */
949 tKeepAliveParams.interval = 1000; /* minimum accepted by the FW */
950 tKeepAliveParams.trigType = KEEP_ALIVE_TRIG_TYPE_NO_TX;
951 TWD_CfgKeepAlive (pCurrBSS->hTWD, &tKeepAliveParams);
964 * Callback function, called upon BSS-Loss event from FW.
968 * I - hCurrBSS - Current BSS handle \n
976 static void currBSS_BssLost (currBSS_t *hCurrBSS,
980 currBSS_reportRoamingEvent(hCurrBSS, ROAMING_TRIGGER_BSS_LOSS, NULL);
986 * currBSS_consecTxErrors
990 * Callback function, provided to HAL module.
994 * I - pCurrBSS - Current BSS handle \n
998 * TI_OK on success, TI_NOK on failure.
1002 static void currBSS_consecTxErrors(currBSS_t *hCurrBSS,
1004 TI_UINT8 dataLength)
1006 currBSS_reportRoamingEvent(hCurrBSS, ROAMING_TRIGGER_MAX_TX_RETRIES, NULL);
1012 * currBSS_lowRssiThrCrossed
1016 * Callback function, provided to HAL module.
1020 * I - pCurrBSS - Current BSS handle \n
1024 * TI_OK on success, TI_NOK on failure.
1028 static void currBSS_lowRssiThrCrossed(currBSS_t *hCurrBSS,
1030 TI_UINT8 dataLength)
1032 currBSS_reportRoamingEvent(hCurrBSS, ROAMING_TRIGGER_LOW_QUALITY, NULL);
1038 * currBSS_lowSnrThrCrossed
1042 * Callback function, provided to HAL module.
1046 * I - pCurrBSS - Current BSS handle \n
1050 * TI_OK on success, TI_NOK on failure.
1054 static void currBSS_lowSnrThrCrossed(currBSS_t *hCurrBSS,
1056 TI_UINT8 dataLength)
1058 currBSS_reportRoamingEvent(hCurrBSS, ROAMING_TRIGGER_LOW_SNR, NULL);
1063 * currBSS_reportRoamingEvent
1067 * This function checks the mode of Current BSS module.
1068 * If connected to EBSS, it reports roaming event to AP Connection.
1072 * I - pCurrBSS - Current BSS handle \n
1073 * I - roamingEventType - Roaming trigger to report \n
1077 * TI_OK on success, TI_NOK on failure.
1081 static void currBSS_reportRoamingEvent(currBSS_t *pCurrBSS,
1082 apConn_roamingTrigger_e roamingEventType,
1083 roamingEventData_u *pRoamingEventData)
1085 TRACE1(pCurrBSS->hReport, REPORT_SEVERITY_INFORMATION, "currBSS_reportRoamingEvent: trigger %d\n", roamingEventType);
1087 if (pCurrBSS->isConnected)
1089 if (pCurrBSS->type == BSS_INFRASTRUCTURE)
1091 apConn_reportRoamingEvent(pCurrBSS->hAPConn, roamingEventType, pRoamingEventData);
1095 if( roamingEventType == ROAMING_TRIGGER_BSS_LOSS )
1097 /* If in IBSS call the SME restart function, this logic issues a DISCONNECT
1098 * event and tries to connect to other STA or establish self connection.
1100 sme_Restart (pCurrBSS->hSme);
1109 * currBSS_GetDefaultKeepAlivePeriod
1113 * Get DefaultKeepAlivePeriod parameter value.
1117 * I - hCurrBSS - Current BSS handle \n
1118 * I - uDefaultKeepAlivePeriod - The value \n
1126 void currBSS_GetDefaultKeepAlivePeriod (TI_HANDLE hCurrBSS, TI_UINT8* uKeepAlivePeriod)
1128 currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS;
1130 *uKeepAlivePeriod = pCurrBSS->uDefaultKeepAlivePeriod;
1136 * currBSS_BackgroundScanQuality
1140 * Called be EventMBox upon Background Scan Quality Trigger.
1144 * I - hCurrBSS - Current BSS handle \n
1152 static void currBSS_BackgroundScanQuality(TI_HANDLE hCurrBSS,
1154 TI_UINT8 dataLength)
1156 currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS;
1157 TI_UINT8 averageRssi = *data;
1158 paramInfo_t *pParam;
1160 TRACE1(pCurrBSS->hReport, REPORT_SEVERITY_INFORMATION, "BackgroundScanQuality Event: RSSI = %d\n", averageRssi );
1162 /* Report to AP Connection about reaching RSSI low or normal (high) threshold */
1163 if (averageRssi < pCurrBSS->lowQualityForBkgrdScan)
1165 apConn_reportRoamingEvent(pCurrBSS->hAPConn, ROAMING_TRIGGER_LOW_QUALITY_FOR_BG_SCAN, NULL);
1169 apConn_reportRoamingEvent(pCurrBSS->hAPConn, ROAMING_TRIGGER_NORMAL_QUALITY_FOR_BG_SCAN, NULL);
1173 pCurrBSS->currAPInfo.RSSI = averageRssi;
1175 /* Update Site Table in order to represent the RSSI of current AP correctly in the utility */
1176 pParam = (paramInfo_t *)os_memoryAlloc(pCurrBSS->hOs, sizeof(paramInfo_t));
1181 pParam->paramType = SITE_MGR_CURRENT_SIGNAL_PARAM;
1182 pParam->content.siteMgrCurrentSignal.rssi = averageRssi;
1183 siteMgr_setParam(pCurrBSS->hSiteMgr, pParam);
1184 os_memoryFree(pCurrBSS->hOs, pParam, sizeof(paramInfo_t));
1190 * currBss_findEmptyUserTrigger
1194 * Called be EventMBox upon Background Scan Quality Trigger.
1198 * I - hCurrBSS - Current BSS handle \n
1206 static triggerDesc_t* currBss_findEmptyUserTrigger(TI_HANDLE hCurrBSS, TI_UINT16 clientID, TI_UINT8* triggerIdx)
1208 currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS;
1211 for (i=0; i< MAX_NUM_OF_RSSI_SNR_TRIGGERS ; i++)
1213 if (clientID == pCurrBSS->aTriggersDesc[i].clientID || /* if the same client ID found, overwrite this trigger*/
1214 (pCurrBSS->aTriggersDesc[i].WasRegisteredByApp == TI_FALSE && pCurrBSS->aTriggersDesc[i].fCB == NULL))
1217 return &pCurrBSS->aTriggersDesc[i];
1226 * \fn currBSS_RegisterTriggerEvent
1227 * \brief register the event in the currBss static table.
1230 * \param hCurrBSS - Current BSS handle
1231 * \param triggerID - The RSSI/SNR trigger ID as defined in the TWD. this arg is the table index.
1232 * \param clientID - The client ID, '0' value means internal driver module client
1233 * \param fCB - the trigger event handler. NULL value will be set for external app registration.
1234 * \return >= 0 if the empty Trigger event ID (index table) has been found and occupied
1235 else -1 to signal an error
1238 TI_INT8 currBSS_RegisterTriggerEvent (TI_HANDLE hCurrBSS, TI_UINT8 triggerID,TI_UINT16 clientID, void* fCB, TI_HANDLE hCB)
1240 currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS;
1241 triggerDesc_t *pEmptyTrigger;
1242 TI_UINT8 emptyTriggerIdx = 0;
1244 if (triggerID >= MAX_NUM_OF_RSSI_SNR_TRIGGERS)
1246 TRACE1(pCurrBSS->hReport, REPORT_SEVERITY_ERROR , "currBSS_RegisterTriggerEvent: triggerID=%d is not in legal range \n", triggerID);
1250 TRACE3(pCurrBSS->hReport, REPORT_SEVERITY_INFORMATION, "currBSS_RegisterTriggerEvent: triggerID=%d, clientID=%d , fCB=%d. \n",triggerID, clientID ,fCB);
1252 if(clientID > 0) /* this event is registered by application */
1254 pEmptyTrigger = currBss_findEmptyUserTrigger(hCurrBSS, clientID, &emptyTriggerIdx);
1255 if (pEmptyTrigger != NULL)
1257 pEmptyTrigger->clientID = clientID;
1258 pEmptyTrigger->fCB = NULL;
1259 pEmptyTrigger->hCB = NULL;
1260 pEmptyTrigger->WasRegisteredByApp = TI_TRUE;
1264 TRACE0(pCurrBSS->hReport, REPORT_SEVERITY_ERROR , "currBSS_RegisterTriggerEvent: Table is full!. no Empty trigger is available! \n");
1270 pCurrBSS->aTriggersDesc[triggerID].clientID = 0;
1271 pCurrBSS->aTriggersDesc[triggerID].fCB = fCB;
1272 pCurrBSS->aTriggersDesc[triggerID].hCB = hCB;
1273 pCurrBSS->aTriggersDesc[triggerID].WasRegisteredByApp = TI_FALSE;
1276 TWD_EnableEvent (pCurrBSS->hTWD, triggerID);
1277 return emptyTriggerIdx;
1284 * \fn currBss_HandleTriggerEvent
1285 * \brief called by the user trigger event callbcack.
1288 * \param hCurrBSS - Current BSS handle
1289 * \param data - The event data
1290 * \param dataLength - The event data length
1291 * \param eventID - The event ID
1295 static TI_STATUS currBss_HandleTriggerEvent(TI_HANDLE hCurrBSS, TI_UINT8 *data, TI_UINT8 dataLength, TI_UINT8 eventID)
1297 triggerDesc_t *pTrigger;
1298 triggerDataEx_t triggerInfo;
1299 currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS;
1301 TRACE1(pCurrBSS->hReport ,REPORT_SEVERITY_INFORMATION, "currBss_HandleTriggerEvent(). eventID =%d \n",eventID);
1303 if (eventID < MAX_NUM_OF_RSSI_SNR_TRIGGERS)
1305 pTrigger = &pCurrBSS->aTriggersDesc[eventID];
1312 if (TI_FALSE == pTrigger->WasRegisteredByApp)
1314 ((TCurrBssDataCb)pTrigger->fCB)(pTrigger->hCB, data, dataLength);
1318 triggerInfo.data = *data; /* RSSI_SNR Triggers - holds one byte only */
1319 triggerInfo.clientID = pTrigger->clientID;
1320 EvHandlerSendEvent(pCurrBSS->hEvHandler, IPC_EVENT_RSSI_SNR_TRIGGER, (TI_UINT8*)&triggerInfo, sizeof(triggerInfo));
1327 * \fn currBSS_RssiSnrTrigger0-7
1328 * \brief User Defined Trigger 0-7 callbacks
1330 * Called by EventMBox upon User Defined Trigger 0 - 7.
1333 * \param hCurrBSS - Current BSS handle
1334 * \param data - The event data
1335 * \param dataLength - The event data length
1340 static void currBSS_RssiSnrTrigger0 (TI_HANDLE hCurrBSS, TI_UINT8 *data, TI_UINT8 dataLength)
1342 TI_UINT8 eventID = TWD_OWN_EVENT_RSSI_SNR_TRIGGER_0;
1343 currBss_HandleTriggerEvent (hCurrBSS, data, dataLength, eventID);
1345 static void currBSS_RssiSnrTrigger1 (TI_HANDLE hCurrBSS, TI_UINT8 *data, TI_UINT8 dataLength)
1347 TI_UINT8 eventID = TWD_OWN_EVENT_RSSI_SNR_TRIGGER_1;
1348 currBss_HandleTriggerEvent (hCurrBSS, data, dataLength, eventID);
1350 static void currBSS_RssiSnrTrigger2 (TI_HANDLE hCurrBSS, TI_UINT8 *data, TI_UINT8 dataLength)
1352 TI_UINT8 eventID = TWD_OWN_EVENT_RSSI_SNR_TRIGGER_2;
1353 currBss_HandleTriggerEvent (hCurrBSS, data, dataLength, eventID);
1355 static void currBSS_RssiSnrTrigger3 (TI_HANDLE hCurrBSS, TI_UINT8 *data, TI_UINT8 dataLength)
1357 TI_UINT8 eventID = TWD_OWN_EVENT_RSSI_SNR_TRIGGER_3;
1358 currBss_HandleTriggerEvent (hCurrBSS, data, dataLength, eventID);
1360 static void currBSS_RssiSnrTrigger4 (TI_HANDLE hCurrBSS, TI_UINT8 *data, TI_UINT8 dataLength)
1362 TI_UINT8 eventID = TWD_OWN_EVENT_RSSI_SNR_TRIGGER_4;
1363 currBss_HandleTriggerEvent (hCurrBSS, data, dataLength, eventID);
1365 static void currBSS_RssiSnrTrigger5 (TI_HANDLE hCurrBSS, TI_UINT8 *data, TI_UINT8 dataLength)
1367 TI_UINT8 eventID = TWD_OWN_EVENT_RSSI_SNR_TRIGGER_5;
1368 currBss_HandleTriggerEvent (hCurrBSS, data, dataLength, eventID);
1370 static void currBSS_RssiSnrTrigger6 (TI_HANDLE hCurrBSS, TI_UINT8 *data, TI_UINT8 dataLength)
1372 TI_UINT8 eventID = TWD_OWN_EVENT_RSSI_SNR_TRIGGER_6;
1373 currBss_HandleTriggerEvent (hCurrBSS, data, dataLength, eventID);
1375 static void currBSS_RssiSnrTrigger7 (TI_HANDLE hCurrBSS, TI_UINT8 *data, TI_UINT8 dataLength)
1377 TI_UINT8 eventID = TWD_OWN_EVENT_RSSI_SNR_TRIGGER_7;
1378 currBss_HandleTriggerEvent (hCurrBSS, data, dataLength, eventID);
1382 static TI_STATUS currBSS_BssLossThresholdCrossed(TI_HANDLE hCurrBSS, TI_UINT8 *data, TI_UINT8 dataLength)
1384 currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS;
1386 EvHandlerSendEvent(pCurrBSS->hEvHandler, IPC_EVENT_BSS_LOSS, data, dataLength);
1388 currBSS_reportRoamingEvent(hCurrBSS, ROAMING_TRIGGER_BSS_LOSS, NULL);
1392 static TI_STATUS currBSS_MaxTxRetryThresholdCrossed(TI_HANDLE hCurrBSS, TI_UINT8 *data, TI_UINT8 dataLength)
1394 currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS;
1396 EvHandlerSendEvent(pCurrBSS->hEvHandler, IPC_EVENT_TX_RETRY_FALIURE, data, dataLength);
1398 currBSS_reportRoamingEvent(hCurrBSS, ROAMING_TRIGGER_BSS_LOSS, NULL);
1404 TI_STATUS currBss_registerBssLossEvent(TI_HANDLE hCurrBSS,TI_UINT32 uNumOfBeacons, TI_UINT16 uClientID)
1406 TRroamingTriggerParams params;
1407 currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS;
1409 TRACE2(pCurrBSS->hReport,REPORT_SEVERITY_INFORMATION , "currBss_registerBssLossEvent() uNumOfBeacons=%d,uClientID =%d \n", uNumOfBeacons,uClientID );
1411 /* Register for 'BSS-Loss' event */
1412 TWD_RegisterEvent (pCurrBSS->hTWD, TWD_OWN_EVENT_BSS_LOSE, (void *)currBSS_BssLossThresholdCrossed, pCurrBSS);
1413 TWD_EnableEvent (pCurrBSS->hTWD, TWD_OWN_EVENT_BSS_LOSE);
1415 pCurrBSS->numExpectedTbttForBSSLoss = uNumOfBeacons;
1416 params.TsfMissThreshold = uNumOfBeacons; /* number of missing beacon allowed before out-of-sync event is issued*/
1417 params.BssLossTimeout = NO_BEACON_DEFAULT_TIMEOUT;
1418 TWD_CfgConnMonitParams (pCurrBSS->hTWD, ¶ms);
1423 TI_STATUS currBss_registerTxRetryEvent(TI_HANDLE hCurrBSS,TI_UINT8 uMaxTxRetryThreshold, TI_UINT16 uClientID)
1425 TRroamingTriggerParams params;
1426 currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS;
1428 TRACE2(pCurrBSS->hReport,REPORT_SEVERITY_INFORMATION , "currBss_registerTxRetryEvent() uMaxTxRetryThreshold=%d,uClientID =%d \n", uMaxTxRetryThreshold,uClientID );
1429 /* Register for 'Consec. Tx error' */
1430 TWD_RegisterEvent (pCurrBSS->hTWD, TWD_OWN_EVENT_MAX_TX_RETRY, (void *)currBSS_MaxTxRetryThresholdCrossed, pCurrBSS);
1431 TWD_EnableEvent (pCurrBSS->hTWD, TWD_OWN_EVENT_MAX_TX_RETRY);
1433 pCurrBSS->maxTxRetryThreshold = uMaxTxRetryThreshold;
1434 params.maxTxRetry = uMaxTxRetryThreshold;
1435 TWD_CfgMaxTxRetry (pCurrBSS->hTWD, ¶ms);
1444 TI_STATUS currBSS_setParam(TI_HANDLE hCurrBSS, paramInfo_t *pParam)
1446 currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS;
1447 TI_STATUS status = TI_OK;
1451 TRACE0(pCurrBSS->hReport, REPORT_SEVERITY_ERROR , " currBSS_setParam(): pParam is NULL!\n");
1455 TRACE1(pCurrBSS->hReport,REPORT_SEVERITY_INFORMATION , "currBSS_setParam() %X \n", pParam->paramType);
1457 switch (pParam->paramType)
1459 case CURR_BSS_REGISTER_LINK_QUALITY_EVENT_PARAM:
1461 TUserDefinedQualityTrigger *pUserTrigger = &pParam->content.rssiSnrTrigger;
1462 RssiSnrTriggerCfg_t tTriggerCfg;
1463 TI_INT8 triggerID = 0;
1465 TRACE8(pCurrBSS->hReport, REPORT_SEVERITY_INFORMATION , "currBSS_setParam - USER_DEFINED_TRIGGER: \n index = %d, \n threshold = %d, \n pacing = %d, \n metric = %d, \n type = %d, \n direction = %d, \n hystersis = %d, \n enable = %d \n",pUserTrigger->uIndex,pUserTrigger->iThreshold,pUserTrigger->uPacing,pUserTrigger->uMetric,pUserTrigger->uType,pUserTrigger->uDirection,pUserTrigger->uHystersis,pUserTrigger->uEnable);
1466 /* Copy from user structure to driver structure */
1467 tTriggerCfg.index = pUserTrigger->uIndex;
1468 tTriggerCfg.threshold = pUserTrigger->iThreshold;
1469 tTriggerCfg.pacing = pUserTrigger->uPacing;
1470 tTriggerCfg.metric = pUserTrigger->uMetric;
1471 tTriggerCfg.type = pUserTrigger->uType;
1472 tTriggerCfg.direction = pUserTrigger->uDirection;
1473 tTriggerCfg.hystersis = pUserTrigger->uHystersis;
1474 tTriggerCfg.enable = pUserTrigger->uEnable;
1476 /* the registration request is not from EMP (clientID must be greater than 0)
1477 so it is probably external user mode application like the CLI that sends always '0' as client ID*/
1478 if (pUserTrigger->uClientID == 0)
1480 pUserTrigger->uClientID = pUserTrigger->uIndex + 1; /* use the index (starting from '0') as positive client ID*/
1482 /* Register the event and enable it before configuration. */
1483 triggerID = currBSS_RegisterTriggerEvent(hCurrBSS, (TI_UINT8)0, pUserTrigger->uClientID, (void*)0, hCurrBSS);
1487 TRACE0(pCurrBSS->hReport, REPORT_SEVERITY_ERROR , "currBSS_setParam: RSSI/SNR user trigger registration FAILED!! \n");
1492 tTriggerCfg.index = (uint8)triggerID; /* the index is used for the eventMBox triggerID mapping*/
1494 /* Send user defined trigger to FW (the related FW events are handled by the currBSS) */
1495 status = TWD_CfgRssiSnrTrigger (pCurrBSS->hTWD, &tTriggerCfg);
1501 TRACE1(pCurrBSS->hReport, REPORT_SEVERITY_ERROR, "currBSS_setParam bad param= %X\n", pParam->paramType);
1509 TI_STATUS currBSS_getParam(TI_HANDLE hCurrBSS, paramInfo_t *pParam)
1514 void currBss_DbgPrintTriggersTable(TI_HANDLE hCurrBSS)
1518 currBSS_t *pCurrBSS = (currBSS_t *)hCurrBSS;
1520 WLAN_OS_REPORT(("\n ------------------- Triggers Table -------------------------- \n"));
1522 for (i=0; i< MAX_NUM_OF_RSSI_SNR_TRIGGERS ; i++)
1524 WLAN_OS_REPORT(("\n TriggerIdx[%d]: clientID=%d , fCB=%d, WasRegisteredByApp=%d. \n",
1526 pCurrBSS->aTriggersDesc[i].clientID,
1527 pCurrBSS->aTriggersDesc[i].fCB,
1528 pCurrBSS->aTriggersDesc[i].WasRegisteredByApp));
1530 WLAN_OS_REPORT(("\n --------------------------------------------------------------- \n"));