Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Previously licensed under the ISC license by Qualcomm Atheros, Inc. |
| 5 | * |
| 6 | * |
| 7 | * Permission to use, copy, modify, and/or distribute this software for |
| 8 | * any purpose with or without fee is hereby granted, provided that the |
| 9 | * above copyright notice and this permission notice appear in all |
| 10 | * copies. |
| 11 | * |
| 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 13 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 14 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 15 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 16 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 17 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 18 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 19 | * PERFORMANCE OF THIS SOFTWARE. |
| 20 | */ |
| 21 | |
| 22 | /* |
| 23 | * This file was originally distributed by Qualcomm Atheros, Inc. |
| 24 | * under proprietary terms before Copyright ownership was assigned |
| 25 | * to the Linux Foundation. |
| 26 | */ |
| 27 | |
| 28 | #ifndef WLAN_QCT_WLANSAP_INTERNAL_H |
| 29 | #define WLAN_QCT_WLANSAP_INTERNAL_H |
| 30 | |
| 31 | /* |
| 32 | * This file contains the internal API exposed by the wlan SAP PAL layer |
| 33 | * module. |
| 34 | */ |
| 35 | |
| 36 | #include "cds_api.h" |
| 37 | #include "cds_packet.h" |
| 38 | |
| 39 | /* Pick up the CSR API definitions */ |
| 40 | #include "csr_api.h" |
| 41 | #include "sap_api.h" |
| 42 | #include "sap_fsm_ext.h" |
| 43 | #include "sap_ch_select.h" |
| 44 | |
| 45 | /*---------------------------------------------------------------------------- |
| 46 | * Preprocessor Definitions and Constants |
| 47 | * -------------------------------------------------------------------------*/ |
| 48 | #ifdef __cplusplus |
| 49 | extern "C" { |
| 50 | #endif |
| 51 | |
| 52 | /*---------------------------------------------------------------------------- |
| 53 | * Defines |
| 54 | * -------------------------------------------------------------------------*/ |
| 55 | /* DFS Non Occupancy Period =30 minutes, in microseconds */ |
| 56 | #define SAP_DFS_NON_OCCUPANCY_PERIOD (30 * 60 * 1000 * 1000) |
| 57 | |
| 58 | #define SAP_DEBUG |
| 59 | /* Used to enable or disable security on the BT-AMP link */ |
| 60 | #define WLANSAP_SECURITY_ENABLED_STATE true |
| 61 | #ifdef WLAN_FEATURE_MBSSID |
| 62 | /* When MBSSID feature is enabled, SAP context is directly passed to SAP APIs */ |
| 63 | #define CDS_GET_SAP_CB(ctx) (ptSapContext)(ctx) |
| 64 | #else |
| 65 | /* How do I get SAP context from cds context? */ |
| 66 | #define CDS_GET_SAP_CB(ctx) cds_get_context(CDF_MODULE_ID_SAP) |
| 67 | #endif |
| 68 | |
| 69 | #define CDS_GET_HAL_CB(ctx) cds_get_context(CDF_MODULE_ID_PE) |
| 70 | /* MAC Address length */ |
| 71 | #define ANI_EAPOL_KEY_RSN_NONCE_SIZE 32 |
| 72 | |
| 73 | #define IS_ETSI_WEATHER_CH(_ch) ((_ch >= 120) && (_ch <= 130)) |
| 74 | #define IS_CH_BONDING_WITH_WEATHER_CH(_ch) (_ch == 116) |
| 75 | #define IS_CHAN_JAPAN_W53(_ch) ((_ch >= 52) && (_ch <= 64)) |
| 76 | #define IS_CHAN_JAPAN_INDOOR(_ch) ((_ch >= 36) && (_ch <= 64)) |
| 77 | #define IS_CHAN_JAPAN_OUTDOOR(_ch)((_ch >= 100) && (_ch <= 140)) |
| 78 | #define DEFAULT_CAC_TIMEOUT (60 * 1000) /* msecs - 1 min */ |
| 79 | #define ETSI_WEATHER_CH_CAC_TIMEOUT (10 * 60 * 1000) /* msecs - 10 min */ |
| 80 | #define SAP_CHAN_PREFERRED_INDOOR 1 |
| 81 | #define SAP_CHAN_PREFERRED_OUTDOOR 2 |
| 82 | |
| 83 | extern const sRegulatoryChannel *reg_channels; |
| 84 | |
| 85 | /*---------------------------------------------------------------------------- |
| 86 | * Typedefs |
| 87 | * -------------------------------------------------------------------------*/ |
| 88 | typedef struct sSapContext tSapContext; |
| 89 | /* tSapContext, *ptSapContext; */ |
| 90 | /*---------------------------------------------------------------------------- |
| 91 | * Type Declarations - For internal SAP context information |
| 92 | * -------------------------------------------------------------------------*/ |
| 93 | /*---------------------------------------------------------------------------- |
| 94 | * Opaque SAP context Type Declaration |
| 95 | * -------------------------------------------------------------------------*/ |
| 96 | /* We were only using this syntax, when this was truly opaque. */ |
| 97 | /* (I.E., it was defined in a different file.) */ |
| 98 | |
| 99 | /* SAP FSM states for Access Point role */ |
| 100 | typedef enum { |
| 101 | eSAP_DISCONNECTED, |
| 102 | eSAP_CH_SELECT, |
| 103 | eSAP_DFS_CAC_WAIT, |
| 104 | eSAP_STARTING, |
| 105 | eSAP_STARTED, |
| 106 | eSAP_DISCONNECTING |
| 107 | } eSapFsmStates_t; |
| 108 | |
| 109 | /*---------------------------------------------------------------------------- |
| 110 | * SAP context Data Type Declaration |
| 111 | * -------------------------------------------------------------------------*/ |
| 112 | /*---------------------------------------------------------------------------- |
| 113 | * Type Declarations - QOS related |
| 114 | * -------------------------------------------------------------------------*/ |
| 115 | /* SAP QOS config */ |
| 116 | typedef struct sSapQosCfg { |
| 117 | uint8_t WmmIsEnabled; |
| 118 | } tSapQosCfg; |
| 119 | |
| 120 | typedef struct sSapAcsChannelInfo { |
| 121 | uint32_t channelNum; |
| 122 | uint32_t weight; |
| 123 | } tSapAcsChannelInfo; |
| 124 | |
| 125 | #ifdef FEATURE_AP_MCC_CH_AVOIDANCE |
| 126 | /* |
| 127 | * In a setup having two MDM both operating in AP+AP MCC scenario |
| 128 | * if both the AP decides to use same or close channel set, CTS to |
| 129 | * self, mechanism is causing issues with connectivity. For this, its |
| 130 | * proposed that 2nd MDM devices which comes up later should detect |
| 131 | * presence of first MDM device via special Q2Q IE present in becon |
| 132 | * and avoid those channels mentioned in IE. |
| 133 | * |
| 134 | * Following struct will keep this info in sapCtx struct, and will be used |
| 135 | * to avoid such channels in Random Channel Select in case of radar ind. |
| 136 | */ |
| 137 | struct sap_avoid_channels_info { |
| 138 | bool present; |
| 139 | uint8_t channels[WNI_CFG_VALID_CHANNEL_LIST_LEN]; |
| 140 | }; |
| 141 | #endif /* FEATURE_AP_MCC_CH_AVOIDANCE */ |
| 142 | |
| 143 | typedef struct sSapContext { |
| 144 | |
| 145 | cdf_mutex_t SapGlobalLock; |
| 146 | |
| 147 | /* Include the current channel of AP */ |
| 148 | uint32_t channel; |
| 149 | uint32_t secondary_ch; |
| 150 | |
| 151 | /* Include the SME(CSR) sessionId here */ |
| 152 | uint8_t sessionId; |
| 153 | |
| 154 | /* Include the key material for this physical link */ |
| 155 | uint8_t key_type; |
| 156 | uint8_t key_length; |
| 157 | uint8_t key_material[32]; |
| 158 | |
| 159 | /* Include the associations MAC addresses */ |
| 160 | uint8_t self_mac_addr[CDS_MAC_ADDRESS_LEN]; |
| 161 | |
| 162 | /* Own SSID */ |
| 163 | uint8_t ownSsid[MAX_SSID_LEN]; |
| 164 | uint32_t ownSsidLen; |
| 165 | |
| 166 | /* Flag for signaling if security is enabled */ |
| 167 | uint8_t ucSecEnabled; |
| 168 | |
| 169 | /* Include the SME(CSR) context here */ |
| 170 | tCsrRoamProfile csr_roamProfile; |
| 171 | uint32_t csr_roamId; |
| 172 | |
| 173 | /* Sap session */ |
| 174 | bool isSapSessionOpen; |
| 175 | |
| 176 | /* SAP event Callback to hdd */ |
| 177 | tpWLAN_SAPEventCB pfnSapEventCallback; |
| 178 | |
| 179 | /* Include the enclosing CDS context here */ |
| 180 | void *p_cds_gctx; |
| 181 | |
| 182 | /* |
| 183 | * Include the state machine structure here, state var that keeps |
| 184 | * track of state machine |
| 185 | */ |
| 186 | eSapFsmStates_t sapsMachine; |
| 187 | |
| 188 | /* Actual storage for AP and self (STA) SSID */ |
| 189 | tCsrSSIDInfo SSIDList[2]; |
| 190 | |
| 191 | /* Actual storage for AP bssid */ |
| 192 | struct cdf_mac_addr bssid; |
| 193 | |
| 194 | /* Mac filtering settings */ |
| 195 | eSapMacAddrACL eSapMacAddrAclMode; |
| 196 | struct cdf_mac_addr acceptMacList[MAX_ACL_MAC_ADDRESS]; |
| 197 | uint8_t nAcceptMac; |
| 198 | struct cdf_mac_addr denyMacList[MAX_ACL_MAC_ADDRESS]; |
| 199 | uint8_t nDenyMac; |
| 200 | |
| 201 | /* QOS config */ |
| 202 | tSapQosCfg SapQosCfg; |
| 203 | |
| 204 | void *pUsrContext; |
| 205 | |
| 206 | uint32_t nStaWPARSnReqIeLength; |
| 207 | uint8_t pStaWpaRsnReqIE[MAX_ASSOC_IND_IE_LEN]; |
| 208 | tSirAPWPSIEs APWPSIEs; |
| 209 | tSirRSNie APWPARSNIEs; |
| 210 | |
| 211 | #ifdef FEATURE_WLAN_WAPI |
| 212 | uint32_t nStaWAPIReqIeLength; |
| 213 | uint8_t pStaWapiReqIE[MAX_ASSOC_IND_IE_LEN]; |
| 214 | #endif |
| 215 | |
| 216 | uint32_t nStaAddIeLength; |
| 217 | uint8_t pStaAddIE[MAX_ASSOC_IND_IE_LEN]; |
| 218 | uint8_t *channelList; |
| 219 | tSapChannelListInfo SapChnlList; |
| 220 | uint16_t ch_width_orig; |
| 221 | chan_params_t ch_params; |
| 222 | |
| 223 | /* session to scan */ |
| 224 | bool isScanSessionOpen; |
| 225 | /* |
| 226 | * This list of channels will hold 5Ghz enabled,DFS in the |
| 227 | * Current RegDomain.This list will be used to select a channel, |
| 228 | * for SAP to start including any DFS channel and also to select |
| 229 | * any random channel[5Ghz-(NON-DFS/DFS)],if SAP is operating |
| 230 | * on a DFS channel and a RADAR is detected on the channel. |
| 231 | */ |
| 232 | tAll5GChannelList SapAllChnlList; |
| 233 | |
| 234 | tSapAcsChannelInfo acsBestChannelInfo; |
| 235 | bool enableOverLapCh; |
| 236 | struct sap_acs_cfg *acs_cfg; |
| 237 | |
| 238 | #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH |
| 239 | uint8_t cc_switch_mode; |
| 240 | #endif |
| 241 | |
| 242 | #if defined(FEATURE_WLAN_STA_AP_MODE_DFS_DISABLE) || \ |
| 243 | defined(WLAN_FEATURE_MBSSID) |
| 244 | bool dfs_ch_disable; |
| 245 | #endif |
| 246 | bool isCacEndNotified; |
| 247 | bool isCacStartNotified; |
| 248 | bool is_sap_ready_for_chnl_chng; |
| 249 | |
| 250 | #ifdef FEATURE_AP_MCC_CH_AVOIDANCE |
| 251 | /* |
| 252 | * In a setup having two MDM both operating in AP+AP MCC scenario |
| 253 | * if both the AP decides to use same or close channel set, CTS to |
| 254 | * self, mechanism is causing issues with connectivity. For this, its |
| 255 | * proposed that 2nd MDM devices which comes up later should detect |
| 256 | * presence of first MDM device via special Q2Q IE present in becon |
| 257 | * and avoid those channels mentioned in IE. |
| 258 | * |
| 259 | * this struct contains the list of channels on which another MDM AP |
| 260 | * in MCC mode were detected. |
| 261 | */ |
| 262 | struct sap_avoid_channels_info sap_detected_avoid_ch_ie; |
| 263 | #endif /* FEATURE_AP_MCC_CH_AVOIDANCE */ |
| 264 | /* |
| 265 | * sap_state, sap_status are created |
| 266 | * to inform upper layers about ACS scan status. |
| 267 | * Don't use these members for anyother purposes. |
| 268 | */ |
| 269 | eSapHddEvent sap_state; |
| 270 | eSapStatus sap_status; |
| 271 | uint32_t roc_ind_scan_id; |
| 272 | } *ptSapContext; |
| 273 | |
| 274 | /*---------------------------------------------------------------------------- |
| 275 | * External declarations for global context |
| 276 | * -------------------------------------------------------------------------*/ |
| 277 | /* The main per-Physical Link (per WLAN association) context. */ |
| 278 | extern ptSapContext gp_sap_ctx; |
| 279 | |
| 280 | /*---------------------------------------------------------------------------- |
| 281 | * SAP state machine event definition |
| 282 | * -------------------------------------------------------------------------*/ |
| 283 | /* The event structure */ |
| 284 | typedef struct sWLAN_SAPEvent { |
| 285 | /* A VOID pointer type for all possible inputs */ |
| 286 | void *params; |
| 287 | /* State machine input event message */ |
| 288 | uint32_t event; |
| 289 | /* introduced to handle csr_roam_completeCallback roamStatus */ |
| 290 | uint32_t u1; |
| 291 | /* introduced to handle csr_roam_completeCallback roamResult */ |
| 292 | uint32_t u2; |
| 293 | } tWLAN_SAPEvent, *ptWLAN_SAPEvent; |
| 294 | |
| 295 | /*---------------------------------------------------------------------------- |
| 296 | * Function Declarations and Documentation |
| 297 | * -------------------------------------------------------------------------*/ |
| 298 | |
| 299 | CDF_STATUS |
| 300 | wlansap_scan_callback |
| 301 | (tHalHandle halHandle, |
| 302 | void *pContext, |
| 303 | uint8_t sessionId, uint32_t scanID, eCsrScanStatus scanStatus); |
| 304 | |
| 305 | CDF_STATUS |
| 306 | wlansap_pre_start_bss_acs_scan_callback( |
| 307 | tHalHandle hal_handle, |
| 308 | void *pcontext, |
| 309 | uint8_t sessionid, |
| 310 | uint32_t scanid, |
| 311 | eCsrScanStatus scan_status |
| 312 | ); |
| 313 | |
| 314 | CDF_STATUS |
| 315 | wlansap_roam_callback |
| 316 | (void *pContext, |
| 317 | tCsrRoamInfo *pCsrRoamInfo, |
| 318 | uint32_t roamId, |
| 319 | eRoamCmdStatus roamStatus, eCsrRoamResult roamResult); |
| 320 | |
| 321 | CDF_STATUS wlansap_clean_cb(ptSapContext pSapCtx, uint32_t freeFlag); |
| 322 | CDF_STATUS SapFsm(ptSapContext sapContext, ptWLAN_SAPEvent sapEvent, |
| 323 | uint8_t *status); |
| 324 | |
| 325 | void |
| 326 | wlansap_pmc_full_pwr_req_cb(void *callbackContext, CDF_STATUS status); |
| 327 | |
| 328 | uint8_t sap_select_channel(tHalHandle halHandle, ptSapContext pSapCtx, |
| 329 | tScanResultHandle pScanResult); |
| 330 | |
| 331 | CDF_STATUS |
| 332 | sap_signal_hdd_event(ptSapContext sapContext, |
| 333 | tCsrRoamInfo *pCsrRoamInfo, |
| 334 | eSapHddEvent sapHddevent, void *); |
| 335 | |
| 336 | CDF_STATUS sap_fsm(ptSapContext sapContext, ptWLAN_SAPEvent sapEvent); |
| 337 | |
| 338 | eSapStatus |
| 339 | sapconvert_to_csr_profile(tsap_Config_t *pconfig_params, |
| 340 | eCsrRoamBssType bssType, |
| 341 | tCsrRoamProfile *profile); |
| 342 | |
| 343 | void sap_free_roam_profile(tCsrRoamProfile *profile); |
| 344 | |
| 345 | CDF_STATUS |
| 346 | sap_is_peer_mac_allowed(ptSapContext sapContext, uint8_t *peerMac); |
| 347 | |
| 348 | void |
| 349 | sap_sort_mac_list(struct cdf_mac_addr *macList, uint8_t size); |
| 350 | |
| 351 | void |
| 352 | sap_add_mac_to_acl(struct cdf_mac_addr *macList, uint8_t *size, |
| 353 | uint8_t *peerMac); |
| 354 | |
| 355 | void |
| 356 | sap_remove_mac_from_acl(struct cdf_mac_addr *macList, uint8_t *size, |
| 357 | uint8_t index); |
| 358 | |
| 359 | void |
| 360 | sap_print_acl(struct cdf_mac_addr *macList, uint8_t size); |
| 361 | |
| 362 | eSapBool |
| 363 | sap_search_mac_list(struct cdf_mac_addr *macList, uint8_t num_mac, |
| 364 | uint8_t *peerMac, uint8_t *index); |
| 365 | |
| 366 | CDF_STATUS sap_acquire_global_lock(ptSapContext pSapCtx); |
| 367 | |
| 368 | CDF_STATUS sap_release_global_lock(ptSapContext pSapCtx); |
| 369 | |
| 370 | #ifdef FEATURE_WLAN_CH_AVOID |
| 371 | void sap_update_unsafe_channel_list(ptSapContext pSapCtx); |
| 372 | #endif /* FEATURE_WLAN_CH_AVOID */ |
| 373 | |
| 374 | uint8_t |
| 375 | sap_indicate_radar(ptSapContext sapContext, |
| 376 | tSirSmeDfsEventInd *dfs_event); |
| 377 | |
| 378 | CDF_STATUS sap_init_dfs_channel_nol_list(ptSapContext sapContext); |
| 379 | |
| 380 | bool sap_dfs_is_channel_in_nol_list(ptSapContext sapContext, |
| 381 | uint8_t channelNumber, |
| 382 | ePhyChanBondState chanBondState); |
| 383 | void sap_dfs_cac_timer_callback(void *data); |
| 384 | |
| 385 | void sap_cac_reset_notify(tHalHandle hHal); |
| 386 | |
| 387 | bool sap_acs_channel_check(ptSapContext sapContext, uint8_t channelNumber); |
| 388 | |
| 389 | bool |
| 390 | sap_channel_matrix_check(ptSapContext sapContext, |
| 391 | ePhyChanBondState cbMode, |
| 392 | uint8_t target_channel); |
| 393 | |
| 394 | bool is_concurrent_sap_ready_for_channel_change(tHalHandle hHal, |
| 395 | ptSapContext |
| 396 | sapContext); |
| 397 | |
| 398 | uint8_t sap_get_total_number_sap_intf(tHalHandle hHal); |
| 399 | |
| 400 | bool sap_dfs_is_w53_invalid(tHalHandle hHal, uint8_t channelID); |
| 401 | |
| 402 | bool sap_dfs_is_channel_in_preferred_location(tHalHandle hHal, |
| 403 | uint8_t channelID); |
| 404 | |
| 405 | CDF_STATUS sap_goto_channel_sel( |
| 406 | ptSapContext sapContext, |
| 407 | ptWLAN_SAPEvent sapEvent, |
| 408 | bool sap_do_acs_pre_start_bss); |
| 409 | |
| 410 | void sap_config_acs_result(tHalHandle hal, ptSapContext sap_ctx, |
| 411 | uint32_t sec_ch); |
| 412 | /** |
| 413 | * sap_check_in_avoid_ch_list() - checks if given channel present is channel |
| 414 | * avoidance list |
| 415 | * avoid_channels_info struct |
| 416 | * @sap_ctx: sap context. |
| 417 | * @channel: channel to be checked in sap_ctx's avoid ch list |
| 418 | * |
| 419 | * sap_ctx contains sap_avoid_ch_info strcut containing the list of channels on |
| 420 | * which MDM device's AP with MCC was detected. This function checks if given |
| 421 | * channel is present in that list. |
| 422 | * |
| 423 | * Return: true, if channel was present, false othersie. |
| 424 | */ |
| 425 | bool |
| 426 | sap_check_in_avoid_ch_list(ptSapContext sap_ctx, uint8_t channel); |
| 427 | #ifdef __cplusplus |
| 428 | } |
| 429 | #endif |
| 430 | #endif |