1/*
2 * currBss.h
3 *
4 * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 *  * Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 *  * Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in
15 *    the documentation and/or other materials provided with the
16 *    distribution.
17 *  * Neither the name Texas Instruments nor the names of its
18 *    contributors may be used to endorse or promote products derived
19 *    from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34/** \file currBss.h
35 *  \brief Current BSS module API
36 *
37 *  \see currBss.c
38 */
39
40/****************************************************************************
41 *                                                                          *
42 *   MODULE:  Current BSS                                               *
43 *   PURPOSE: Current BSS Module API                                    *
44 *                                                                          *
45 ****************************************************************************/
46
47#ifndef _CURR_BSS_H_
48#define _CURR_BSS_H_
49
50#include "siteMgrApi.h"
51#include "roamingMngrTypes.h"
52#include "paramOut.h"
53
54/* Constants */
55
56#define MAX_NUM_OF_RSSI_SNR_TRIGGERS 8
57
58/* Enumerations */
59
60/**
61* Current BSS module configurable parameters type
62*/
63typedef enum
64{
65    CURR_BSS_TYPE = 0,          /**< BSS or IBSS */
66    CURR_BSS_CONNECTED_STATE,   /**< Connected or not connected, roaming enabled or not */
67    CURR_BSS_LOW_RSSI_SCAN_COND,/**< Set by AP Connection when Roaming Manager configures low RSSI threshold for BG scan */
68    CURR_BSS_HI_RSSI_SCAN_COND, /**< Set by AP Connection when Roaming Manager configures normal RSSI threshold for BG scan */
69    CURR_BSS_QUALITY_THRESHOLD, /**< Set by AP Connection when Roaming Manager configures event of type 'Low RSSI' */
70    CURR_BSS_NO_BSS_THRESHOLDS, /**< Set by AP Connection when Roaming Manager configures event of type 'BSS Loss' */
71    CURR_BSS_NUM_OF_TEST_REPEAT,/**< Set by AP Connection when Roaming Manager configures event of type 'BSS Loss' */
72    CURR_BSS_CONSEC_NACK,       /**< Set by AP Connection when Roaming Manager configures event of type 'Consecutive nack' */
73    CURR_BSS_INFO               /**< Requested by AP Connection: includes quality and last beacon info */
74} currBSS_configParam_e;
75
76
77/* Structures */
78
79typedef struct triggerDataEx
80{
81    TI_UINT8* pData;
82    TI_UINT8  dataLength;
83    TI_UINT16 clientID;
84} triggerDataEx_t;
85
86
87typedef struct triggerDesc
88{
89	TI_UINT16	clientID;
90	TI_HANDLE	fCB;
91	TI_HANDLE	hCB;
92    TI_BOOL	    WasRegisteredByApp;
93} triggerDesc_t;
94
95
96/**
97* Current BSS control block
98* Following structure defines parameters that can be configured externally,
99* internal variables, and handlers of other modules used by Current BSS module
100*/
101
102typedef struct _currBSS_t
103{
104    /* Internal variables and configurable parameters */
105    ScanBssType_e type;                   /**< Set by SME module; EBSS, IBSS or none */
106    ERadioBand  band;                   /**< Set by SME module */
107    TI_UINT8    channel;                /**< Set by AP Connection, SME and Switch Channel modules */
108    TI_BOOL     isConnected;            /**< Default: not connected */
109    bssEntry_t  currAPInfo;             /**< Set by SME upon request from AP Connection */
110
111    TI_INT8     lowRssiThreshold;       /**< Last configured threshold for Low-RSSI */
112    TI_INT8     lowSnrThreshold;        /**< Last configured threshold Low-SNR */
113    TI_INT8     lowQualityForBkgrdScan; /**< Indicator used to increase the background scan period when quality is low */
114    TI_INT8     highQualityForBkgrdScan;/**< Indicator used to reduce the background scan period when quality is normal */
115    TI_UINT8    numExpectedTbttForBSSLoss;/**< last configured value without Soft Gemini compensation */
116    TI_UINT8    maxTxRetryThreshold;    /**< last configured threshold for max Tx retry */
117
118    TI_BOOL     bUseSGParams;           /**< Whether to use the Soft Gemini compensation on the roaming triggers (currently: BSS Loss) */
119                                        /**< This compensation is needed since BT Activity might over-run beacons                       */
120    TI_UINT32   SGcompensationPercent;  /**< the percentage of increasing the TbttForBSSLoss value when SG is enabled */
121    TI_UINT8    uDefaultKeepAlivePeriod;/**< The default keep-alive period in seconds */
122    TI_UINT8    keepAliveBuffer[ WLAN_WITH_SNAP_QOS_HEADER_MAX_SIZE ];
123                                        /**< Buffer to store null-data keep-alive template */
124
125    TI_UINT16     BssLossClientID;  /* holds the application client which registered to BssLoss event*/
126    TI_UINT16     TxRetryClientID;  /* holds the application client which registered to TxRetry event*/
127    triggerDesc_t aTriggersDesc[MAX_NUM_OF_RSSI_SNR_TRIGGERS]; /* static table to be used for trigger event registration*/
128    TI_UINT8	  RoamingOperationalMode;                      /* 0 - manual , 1 - Auto */
129
130    /* Handlers of other modules used by AP Connection */
131    TI_HANDLE   hOs;
132    TI_HANDLE   hPowerMngr;
133    TI_HANDLE   hAPConn;
134    TI_HANDLE   hSme;
135    TI_HANDLE   hTWD;
136    TI_HANDLE   hMlme;
137    TI_HANDLE   hReport;
138    TI_HANDLE   hRegulatoryDomain;
139    TI_HANDLE   hSiteMgr;
140    TI_HANDLE   hScanMngr;
141    TI_HANDLE   hEvHandler;
142    TI_HANDLE   hTxCtrl;
143} currBSS_t;
144
145
146/* Typedefs */
147
148typedef void (*TCurrBssDataCb) (TI_HANDLE hCurrBSS, TI_UINT8 *data, TI_UINT8 dataLength);
149
150/* External data definitions */
151
152/* External functions definitions */
153
154/* Function prototypes */
155
156TI_HANDLE currBSS_create(TI_HANDLE hOs);
157void      currBSS_init (TStadHandlesList *pStadHandles);
158TI_STATUS currBSS_SetDefaults (TI_HANDLE hCurrBSS, TCurrBssInitParams *pInitParams);
159TI_STATUS currBSS_unload(TI_HANDLE hCurrBSS);
160
161void currBSS_updateConnectedState(TI_HANDLE hCurrBSS, TI_BOOL isConnected, ScanBssType_e type);
162TI_STATUS currBSS_updateRoamingTriggers(TI_HANDLE hCurrBSS,
163                                        roamingMngrThresholdsConfig_t *params);
164void currBSS_SGconfigureBSSLoss(TI_HANDLE hCurrBSS,
165                                        TI_UINT32 SGcompensationPercent , TI_BOOL bUseSGParams);
166bssEntry_t *currBSS_getBssInfo(TI_HANDLE hCurrBSS);
167
168TI_STATUS currBSS_getRoamingParams(TI_HANDLE hCurrBSS,
169                                   TI_UINT8 * aNumExpectedTbttForBSSLoss,
170                                   TI_INT8 * aLowQualityForBackgroungScanCondition,
171                                   TI_INT8 * aNormalQualityForBackgroungScanCondition);
172
173TI_STATUS currBSS_probRespReceivedCallb(TI_HANDLE hCurrBSS,
174                                        TRxAttr *pRxAttr,
175                                        TMacAddr *bssid,
176                                        mlmeFrameInfo_t *pFrameInfo,
177										TI_UINT8 *dataBuffer,
178                                        TI_UINT16 bufLength);
179
180TI_STATUS currBSS_beaconReceivedCallb(TI_HANDLE hCurrBSS,
181                                        TRxAttr *pRxAttr,
182                                        TMacAddr *bssid,
183                                        mlmeFrameInfo_t *pFrameInfo,
184										TI_UINT8 *dataBuffer,
185                                        TI_UINT16 bufLength);
186
187void currBSS_restartRssiCounting(TI_HANDLE hCurrBSS);
188
189void currBSS_GetDefaultKeepAlivePeriod(TI_HANDLE hCurrBSS, TI_UINT8* uDefaultKeepAlivePeriod);
190
191void currBss_DbgPrintTriggersTable(TI_HANDLE hCurrBSS);
192
193#endif /*  _CURR_BSS_H_*/
194
195