Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1 | /* |
Jeff Johnson | 582a338 | 2018-03-05 11:58:47 -0800 | [diff] [blame] | 2 | * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved. |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 3 | * |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 4 | * Permission to use, copy, modify, and/or distribute this software for |
| 5 | * any purpose with or without fee is hereby granted, provided that the |
| 6 | * above copyright notice and this permission notice appear in all |
| 7 | * copies. |
| 8 | * |
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 10 | * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 11 | * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 12 | * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 13 | * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 14 | * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 15 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 16 | * PERFORMANCE OF THIS SOFTWARE. |
| 17 | */ |
| 18 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 19 | #include "cds_api.h" |
| 20 | #include "ani_global.h" |
| 21 | #include "sir_common.h" |
| 22 | #include "wni_cfg.h" |
| 23 | #include "lim_utils.h" |
| 24 | #include "lim_assoc_utils.h" |
| 25 | #include "lim_sta_hash_api.h" |
| 26 | #include "sch_api.h" /* sch_set_fixed_beacon_fields for IBSS coalesce */ |
| 27 | #include "lim_security_utils.h" |
| 28 | #include "lim_send_messages.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 29 | #include "lim_ft_defs.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 30 | #include "lim_session.h" |
| 31 | #include "lim_ibss_peer_mgmt.h" |
| 32 | #include "lim_types.h" |
Karthik Kantamneni | e3bbd7f | 2018-09-19 20:27:32 +0530 | [diff] [blame] | 33 | #include "wlan_mlme_api.h" |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 34 | |
| 35 | /** |
| 36 | * ibss_peer_find |
| 37 | * |
| 38 | ***FUNCTION: |
| 39 | * This function is called while adding a context at |
| 40 | * DPH & Polaris for a peer in IBSS. |
| 41 | * If peer is found in the list, capabilities from the |
| 42 | * returned BSS description are used at DPH node & Polaris. |
| 43 | * |
| 44 | ***LOGIC: |
| 45 | * |
| 46 | ***ASSUMPTIONS: |
| 47 | * |
| 48 | ***NOTE: |
| 49 | * |
| 50 | * @param macAddr - MAC address of the peer |
| 51 | * |
| 52 | * @return Pointer to peer node if found, else NULL |
| 53 | */ |
| 54 | |
| 55 | static tLimIbssPeerNode *ibss_peer_find(tpAniSirGlobal pMac, |
| 56 | tSirMacAddr macAddr) |
| 57 | { |
| 58 | tLimIbssPeerNode *pTempNode = pMac->lim.gLimIbssPeerList; |
| 59 | |
| 60 | while (pTempNode != NULL) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 61 | if (!qdf_mem_cmp((uint8_t *) macAddr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 62 | (uint8_t *) &pTempNode->peerMacAddr, |
| 63 | sizeof(tSirMacAddr))) |
| 64 | break; |
| 65 | pTempNode = pTempNode->next; |
| 66 | } |
| 67 | return pTempNode; |
| 68 | } /*** end ibss_peer_find() ***/ |
| 69 | |
| 70 | /** |
| 71 | * ibss_peer_add |
| 72 | * |
| 73 | ***FUNCTION: |
| 74 | * This is called on a STA in IBSS upon receiving Beacon/ |
| 75 | * Probe Response from a peer. |
| 76 | * |
| 77 | ***LOGIC: |
| 78 | * Node is always added to the front of the list |
| 79 | * |
| 80 | ***ASSUMPTIONS: |
| 81 | * |
| 82 | ***NOTE: |
| 83 | * |
| 84 | * @param pMac - Pointer to Global MAC structure |
| 85 | * @param pPeerNode - Pointer to peer node to be added to the list. |
| 86 | * |
| 87 | * @return None |
| 88 | */ |
| 89 | |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 90 | static QDF_STATUS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 91 | ibss_peer_add(tpAniSirGlobal pMac, tLimIbssPeerNode *pPeerNode) |
| 92 | { |
| 93 | #ifdef ANI_SIR_IBSS_PEER_CACHING |
| 94 | uint32_t numIbssPeers = (2 * pMac->lim.maxStation); |
| 95 | |
| 96 | if (pMac->lim.gLimNumIbssPeers >= numIbssPeers) { |
| 97 | /** |
| 98 | * Reached max number of peers to be maintained. |
| 99 | * Delete last entry & add new entry at the beginning. |
| 100 | */ |
| 101 | tLimIbssPeerNode *pTemp, *pPrev; |
Srinivas Girigowda | 4d65ebe | 2017-10-13 21:41:42 -0700 | [diff] [blame] | 102 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 103 | pTemp = pPrev = pMac->lim.gLimIbssPeerList; |
| 104 | while (pTemp->next != NULL) { |
| 105 | pPrev = pTemp; |
| 106 | pTemp = pTemp->next; |
| 107 | } |
| 108 | if (pTemp->beacon) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 109 | qdf_mem_free(pTemp->beacon); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 110 | } |
| 111 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 112 | qdf_mem_free(pTemp); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 113 | pPrev->next = NULL; |
| 114 | } else |
| 115 | #endif |
| 116 | pMac->lim.gLimNumIbssPeers++; |
| 117 | |
| 118 | pPeerNode->next = pMac->lim.gLimIbssPeerList; |
| 119 | pMac->lim.gLimIbssPeerList = pPeerNode; |
| 120 | |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 121 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 122 | |
| 123 | } /*** end limAddIbssPeerToList() ***/ |
| 124 | |
| 125 | /** |
| 126 | * ibss_peer_collect |
| 127 | * |
| 128 | ***FUNCTION: |
| 129 | * This is called to collect IBSS peer information |
| 130 | * from received Beacon/Probe Response frame from it. |
| 131 | * |
| 132 | ***LOGIC: |
| 133 | * |
| 134 | ***ASSUMPTIONS: |
| 135 | * |
| 136 | ***NOTE: |
| 137 | * |
| 138 | * @param pMac - Pointer to Global MAC structure |
| 139 | * @param pBeacon - Parsed Beacon Frame structure |
| 140 | * @param pBD - Pointer to received BD |
| 141 | * @param pPeer - Pointer to IBSS peer node |
| 142 | * |
| 143 | * @return None |
| 144 | */ |
| 145 | |
| 146 | static void |
| 147 | ibss_peer_collect(tpAniSirGlobal pMac, |
| 148 | tpSchBeaconStruct pBeacon, |
| 149 | tpSirMacMgmtHdr pHdr, |
| 150 | tLimIbssPeerNode *pPeer, tpPESession psessionEntry) |
| 151 | { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 152 | qdf_mem_copy(pPeer->peerMacAddr, pHdr->sa, sizeof(tSirMacAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 153 | |
| 154 | pPeer->capabilityInfo = pBeacon->capabilityInfo; |
| 155 | pPeer->extendedRatesPresent = pBeacon->extendedRatesPresent; |
| 156 | pPeer->edcaPresent = pBeacon->edcaPresent; |
| 157 | pPeer->wmeEdcaPresent = pBeacon->wmeEdcaPresent; |
| 158 | pPeer->wmeInfoPresent = pBeacon->wmeInfoPresent; |
| 159 | |
| 160 | if (pBeacon->IBSSParams.present) { |
| 161 | pPeer->atimIePresent = pBeacon->IBSSParams.present; |
| 162 | pPeer->peerAtimWindowLength = pBeacon->IBSSParams.atim; |
| 163 | } |
| 164 | |
| 165 | if (IS_DOT11_MODE_HT(psessionEntry->dot11mode) && |
| 166 | (pBeacon->HTCaps.present)) { |
| 167 | pPeer->htCapable = pBeacon->HTCaps.present; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 168 | qdf_mem_copy((uint8_t *) pPeer->supportedMCSSet, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 169 | (uint8_t *) pBeacon->HTCaps.supportedMCSSet, |
| 170 | sizeof(pPeer->supportedMCSSet)); |
| 171 | pPeer->htGreenfield = (uint8_t) pBeacon->HTCaps.greenField; |
| 172 | pPeer->htSupportedChannelWidthSet = |
| 173 | (uint8_t) pBeacon->HTCaps.supportedChannelWidthSet; |
| 174 | pPeer->htMIMOPSState = |
| 175 | (tSirMacHTMIMOPowerSaveState) pBeacon->HTCaps.mimoPowerSave; |
| 176 | pPeer->htMaxAmsduLength = |
| 177 | (uint8_t) pBeacon->HTCaps.maximalAMSDUsize; |
| 178 | pPeer->htAMpduDensity = pBeacon->HTCaps.mpduDensity; |
| 179 | pPeer->htDsssCckRate40MHzSupport = |
| 180 | (uint8_t) pBeacon->HTCaps.dsssCckMode40MHz; |
| 181 | pPeer->htShortGI20Mhz = (uint8_t) pBeacon->HTCaps.shortGI20MHz; |
| 182 | pPeer->htShortGI40Mhz = (uint8_t) pBeacon->HTCaps.shortGI40MHz; |
| 183 | pPeer->htMaxRxAMpduFactor = pBeacon->HTCaps.maxRxAMPDUFactor; |
| 184 | pPeer->htSecondaryChannelOffset = |
| 185 | pBeacon->HTInfo.secondaryChannelOffset; |
| 186 | pPeer->htLdpcCapable = (uint8_t) pBeacon->HTCaps.advCodingCap; |
| 187 | } |
| 188 | |
| 189 | /* Collect peer VHT capabilities based on the received beacon from the peer */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 190 | if (pBeacon->VHTCaps.present) { |
| 191 | pPeer->vhtSupportedChannelWidthSet = |
| 192 | pBeacon->VHTOperation.chanWidth; |
| 193 | pPeer->vhtCapable = pBeacon->VHTCaps.present; |
| 194 | |
| 195 | /* Collect VHT capabilities from beacon */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 196 | qdf_mem_copy((uint8_t *) &pPeer->VHTCaps, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 197 | (uint8_t *) &pBeacon->VHTCaps, |
| 198 | sizeof(tDot11fIEVHTCaps)); |
| 199 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 200 | pPeer->erpIePresent = pBeacon->erpPresent; |
| 201 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 202 | qdf_mem_copy((uint8_t *) &pPeer->supportedRates, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 203 | (uint8_t *) &pBeacon->supportedRates, |
| 204 | pBeacon->supportedRates.numRates + 1); |
| 205 | if (pPeer->extendedRatesPresent) |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 206 | qdf_mem_copy((uint8_t *) &pPeer->extendedRates, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 207 | (uint8_t *) &pBeacon->extendedRates, |
| 208 | pBeacon->extendedRates.numRates + 1); |
| 209 | else |
| 210 | pPeer->extendedRates.numRates = 0; |
| 211 | |
| 212 | pPeer->next = NULL; |
| 213 | } /*** end ibss_peer_collect() ***/ |
| 214 | |
| 215 | /* handle change in peer qos/wme capabilities */ |
| 216 | static void |
| 217 | ibss_sta_caps_update(tpAniSirGlobal pMac, |
| 218 | tLimIbssPeerNode *pPeerNode, tpPESession psessionEntry) |
| 219 | { |
| 220 | uint16_t peerIdx; |
| 221 | tpDphHashNode pStaDs; |
| 222 | |
| 223 | pPeerNode->beaconHBCount++; /* Update beacon count. */ |
| 224 | |
| 225 | /* if the peer node exists, update its qos capabilities */ |
| 226 | pStaDs = dph_lookup_hash_entry(pMac, pPeerNode->peerMacAddr, &peerIdx, |
| 227 | &psessionEntry->dph.dphHashTable); |
| 228 | if (pStaDs == NULL) |
| 229 | return; |
| 230 | |
| 231 | /* Update HT Capabilities */ |
| 232 | if (IS_DOT11_MODE_HT(psessionEntry->dot11mode)) { |
| 233 | pStaDs->mlmStaContext.htCapability = pPeerNode->htCapable; |
| 234 | if (pPeerNode->htCapable) { |
| 235 | pStaDs->htGreenfield = pPeerNode->htGreenfield; |
| 236 | pStaDs->htSupportedChannelWidthSet = |
| 237 | pPeerNode->htSupportedChannelWidthSet; |
Abhishek Singh | 10a0026 | 2015-10-16 16:26:14 +0530 | [diff] [blame] | 238 | pStaDs->htSecondaryChannelOffset = |
| 239 | pPeerNode->htSecondaryChannelOffset; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 240 | pStaDs->htMIMOPSState = pPeerNode->htMIMOPSState; |
| 241 | pStaDs->htMaxAmsduLength = pPeerNode->htMaxAmsduLength; |
| 242 | pStaDs->htAMpduDensity = pPeerNode->htAMpduDensity; |
| 243 | pStaDs->htDsssCckRate40MHzSupport = |
| 244 | pPeerNode->htDsssCckRate40MHzSupport; |
| 245 | pStaDs->htShortGI20Mhz = pPeerNode->htShortGI20Mhz; |
| 246 | pStaDs->htShortGI40Mhz = pPeerNode->htShortGI40Mhz; |
| 247 | pStaDs->htMaxRxAMpduFactor = |
| 248 | pPeerNode->htMaxRxAMpduFactor; |
| 249 | /* In the future, may need to check for "delayedBA" */ |
| 250 | /* For now, it is IMMEDIATE BA only on ALL TID's */ |
| 251 | pStaDs->baPolicyFlag = 0xFF; |
| 252 | pStaDs->htLdpcCapable = pPeerNode->htLdpcCapable; |
| 253 | } |
| 254 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 255 | if (IS_DOT11_MODE_VHT(psessionEntry->dot11mode)) { |
| 256 | pStaDs->mlmStaContext.vhtCapability = pPeerNode->vhtCapable; |
| 257 | if (pPeerNode->vhtCapable) { |
| 258 | pStaDs->vhtSupportedChannelWidthSet = |
| 259 | pPeerNode->vhtSupportedChannelWidthSet; |
| 260 | |
| 261 | /* If in 11AC mode and if session requires 11AC mode, consider peer's */ |
| 262 | /* max AMPDU length factor */ |
| 263 | pStaDs->htMaxRxAMpduFactor = |
| 264 | pPeerNode->VHTCaps.maxAMPDULenExp; |
| 265 | pStaDs->vhtLdpcCapable = |
| 266 | (uint8_t) pPeerNode->VHTCaps.ldpcCodingCap; |
| 267 | } |
| 268 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 269 | /* peer is 11e capable but is not 11e enabled yet */ |
| 270 | /* some STA's when joining Airgo IBSS, assert qos capability even when */ |
Jeff Johnson | a642ead | 2018-05-11 09:26:13 -0700 | [diff] [blame] | 271 | /* they don't support qos. however, they do not include the edca parameter */ |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 272 | /* set. so let's check for edcaParam in addition to the qos capability */ |
| 273 | if (pPeerNode->capabilityInfo.qos && (psessionEntry->limQosEnabled) |
| 274 | && pPeerNode->edcaPresent) { |
| 275 | pStaDs->qosMode = 1; |
| 276 | pStaDs->wmeEnabled = 0; |
| 277 | if (!pStaDs->lleEnabled) { |
| 278 | pStaDs->lleEnabled = 1; |
| 279 | /* dphSetACM(pMac, pStaDs); */ |
| 280 | } |
| 281 | return; |
| 282 | } |
| 283 | /* peer is not 11e capable now but was 11e enabled earlier */ |
| 284 | else if (pStaDs->lleEnabled) { |
| 285 | pStaDs->qosMode = 0; |
| 286 | pStaDs->lleEnabled = 0; |
| 287 | } |
| 288 | /* peer is wme capable but is not wme enabled yet */ |
| 289 | if (pPeerNode->wmeInfoPresent && psessionEntry->limWmeEnabled) { |
| 290 | pStaDs->qosMode = 1; |
| 291 | pStaDs->lleEnabled = 0; |
| 292 | if (!pStaDs->wmeEnabled) { |
| 293 | pStaDs->wmeEnabled = 1; |
| 294 | } |
| 295 | return; |
| 296 | } |
| 297 | /* When the peer device supports EDCA parameters, then we were not |
| 298 | considering. Added this code when we saw that one of the Peer Device |
| 299 | was advertising WMM param where we were not honouring that. CR# 210756 |
| 300 | */ |
| 301 | if (pPeerNode->wmeEdcaPresent && psessionEntry->limWmeEnabled) { |
| 302 | pStaDs->qosMode = 1; |
| 303 | pStaDs->lleEnabled = 0; |
| 304 | if (!pStaDs->wmeEnabled) { |
| 305 | pStaDs->wmeEnabled = 1; |
| 306 | } |
| 307 | return; |
| 308 | } |
| 309 | /* peer is not wme capable now but was wme enabled earlier */ |
| 310 | else if (pStaDs->wmeEnabled) { |
| 311 | pStaDs->qosMode = 0; |
| 312 | pStaDs->wmeEnabled = 0; |
| 313 | } |
| 314 | |
| 315 | } |
| 316 | |
| 317 | static void |
| 318 | ibss_sta_rates_update(tpAniSirGlobal pMac, |
| 319 | tpDphHashNode pStaDs, |
| 320 | tLimIbssPeerNode *pPeer, tpPESession psessionEntry) |
| 321 | { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 322 | lim_populate_matching_rate_set(pMac, pStaDs, &pPeer->supportedRates, |
| 323 | &pPeer->extendedRates, |
| 324 | pPeer->supportedMCSSet, psessionEntry, |
Krishna Kumaar Natarajan | d1cd56e | 2016-09-30 08:43:03 -0700 | [diff] [blame] | 325 | &pPeer->VHTCaps, NULL); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 326 | pStaDs->mlmStaContext.capabilityInfo = pPeer->capabilityInfo; |
| 327 | } /*** end ibss_sta_info_update() ***/ |
| 328 | |
| 329 | /** |
| 330 | * ibss_sta_info_update |
| 331 | * |
| 332 | ***FUNCTION: |
| 333 | * This is called to program both SW & Polaris context |
| 334 | * for peer in IBSS. |
| 335 | * |
| 336 | ***LOGIC: |
| 337 | * |
| 338 | ***ASSUMPTIONS: |
| 339 | * |
| 340 | ***NOTE: |
| 341 | * |
| 342 | * @param pMac - Pointer to Global MAC structure |
| 343 | * @param pStaDs - Pointer to DPH node |
| 344 | * @param pPeer - Pointer to IBSS peer node |
| 345 | * |
| 346 | * @return None |
| 347 | */ |
| 348 | |
| 349 | static void |
| 350 | ibss_sta_info_update(tpAniSirGlobal pMac, |
| 351 | tpDphHashNode pStaDs, |
| 352 | tLimIbssPeerNode *pPeer, tpPESession psessionEntry) |
| 353 | { |
| 354 | pStaDs->staType = STA_ENTRY_PEER; |
| 355 | ibss_sta_caps_update(pMac, pPeer, psessionEntry); |
| 356 | ibss_sta_rates_update(pMac, pStaDs, pPeer, psessionEntry); |
| 357 | } /*** end ibss_sta_info_update() ***/ |
| 358 | |
| 359 | static void ibss_coalesce_free(tpAniSirGlobal pMac) |
| 360 | { |
| 361 | if (pMac->lim.ibssInfo.pHdr != NULL) |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 362 | qdf_mem_free(pMac->lim.ibssInfo.pHdr); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 363 | if (pMac->lim.ibssInfo.pBeacon != NULL) |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 364 | qdf_mem_free(pMac->lim.ibssInfo.pBeacon); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 365 | |
| 366 | pMac->lim.ibssInfo.pHdr = NULL; |
| 367 | pMac->lim.ibssInfo.pBeacon = NULL; |
| 368 | } |
| 369 | |
| 370 | /* |
| 371 | * save the beacon params for use when adding the bss |
| 372 | */ |
| 373 | static void |
| 374 | ibss_coalesce_save(tpAniSirGlobal pMac, |
| 375 | tpSirMacMgmtHdr pHdr, tpSchBeaconStruct pBeacon) |
| 376 | { |
| 377 | /* get rid of any saved info */ |
| 378 | ibss_coalesce_free(pMac); |
| 379 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 380 | pMac->lim.ibssInfo.pHdr = qdf_mem_malloc(sizeof(*pHdr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 381 | if (NULL == pMac->lim.ibssInfo.pHdr) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 382 | pe_err("ibbs-save: Failed malloc pHdr"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 383 | return; |
| 384 | } |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 385 | pMac->lim.ibssInfo.pBeacon = qdf_mem_malloc(sizeof(*pBeacon)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 386 | if (NULL == pMac->lim.ibssInfo.pBeacon) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 387 | pe_err("ibbs-save: Failed malloc pBeacon"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 388 | ibss_coalesce_free(pMac); |
| 389 | return; |
| 390 | } |
| 391 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 392 | qdf_mem_copy(pMac->lim.ibssInfo.pHdr, pHdr, sizeof(*pHdr)); |
| 393 | qdf_mem_copy(pMac->lim.ibssInfo.pBeacon, pBeacon, sizeof(*pBeacon)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 394 | } |
| 395 | |
| 396 | /* |
| 397 | * tries to add a new entry to dph hash node |
| 398 | * if necessary, an existing entry is eliminated |
| 399 | */ |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 400 | static QDF_STATUS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 401 | ibss_dph_entry_add(tpAniSirGlobal pMac, |
| 402 | tSirMacAddr peerAddr, |
| 403 | tpDphHashNode *ppSta, tpPESession psessionEntry) |
| 404 | { |
| 405 | uint16_t peerIdx; |
| 406 | tpDphHashNode pStaDs; |
| 407 | |
| 408 | *ppSta = NULL; |
| 409 | |
| 410 | pStaDs = |
| 411 | dph_lookup_hash_entry(pMac, peerAddr, &peerIdx, |
| 412 | &psessionEntry->dph.dphHashTable); |
| 413 | if (pStaDs != NULL) { |
| 414 | /* Trying to add context for already existing STA in IBSS */ |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 415 | pe_err("STA exists already"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 416 | lim_print_mac_addr(pMac, peerAddr, LOGE); |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 417 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 418 | } |
| 419 | |
| 420 | /** |
| 421 | * Assign an AID, delete context existing with that |
| 422 | * AID and then add an entry to hash table maintained |
| 423 | * by DPH module. |
| 424 | */ |
| 425 | peerIdx = lim_assign_peer_idx(pMac, psessionEntry); |
| 426 | |
| 427 | pStaDs = |
| 428 | dph_get_hash_entry(pMac, peerIdx, &psessionEntry->dph.dphHashTable); |
| 429 | if (pStaDs) { |
| 430 | (void)lim_del_sta(pMac, pStaDs, false /*asynchronous */, |
| 431 | psessionEntry); |
| 432 | lim_delete_dph_hash_entry(pMac, pStaDs->staAddr, peerIdx, |
| 433 | psessionEntry); |
| 434 | } |
| 435 | |
| 436 | pStaDs = |
| 437 | dph_add_hash_entry(pMac, peerAddr, peerIdx, |
| 438 | &psessionEntry->dph.dphHashTable); |
| 439 | if (pStaDs == NULL) { |
| 440 | /* Could not add hash table entry */ |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 441 | pe_err("could not add hash entry at DPH for peerIdx/aid: %d MACaddr:", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 442 | peerIdx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 443 | lim_print_mac_addr(pMac, peerAddr, LOGE); |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 444 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 445 | } |
| 446 | |
| 447 | *ppSta = pStaDs; |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 448 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | /* send a status change notification */ |
| 452 | static void |
Jeff Johnson | 582a338 | 2018-03-05 11:58:47 -0800 | [diff] [blame] | 453 | ibss_status_chg_notify(tpAniSirGlobal pMac, tSirMacAddr peerAddr, |
| 454 | uint16_t staIndex, uint16_t status, uint8_t sessionId) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 455 | { |
| 456 | |
| 457 | tLimIbssPeerNode *peerNode; |
| 458 | uint8_t *beacon = NULL; |
| 459 | uint16_t bcnLen = 0; |
| 460 | |
| 461 | peerNode = ibss_peer_find(pMac, peerAddr); |
| 462 | if (peerNode != NULL) { |
| 463 | if (peerNode->beacon == NULL) |
| 464 | peerNode->beaconLen = 0; |
| 465 | beacon = peerNode->beacon; |
| 466 | bcnLen = peerNode->beaconLen; |
| 467 | peerNode->beacon = NULL; |
| 468 | peerNode->beaconLen = 0; |
| 469 | } |
| 470 | |
Jeff Johnson | 582a338 | 2018-03-05 11:58:47 -0800 | [diff] [blame] | 471 | lim_send_sme_ibss_peer_ind(pMac, peerAddr, staIndex, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 472 | beacon, bcnLen, status, sessionId); |
| 473 | |
| 474 | if (beacon != NULL) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 475 | qdf_mem_free(beacon); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 476 | } |
| 477 | } |
| 478 | |
Rajeev Kumar Sirasanagandla | 2f17f8d | 2018-10-03 17:24:20 +0530 | [diff] [blame^] | 479 | void ibss_bss_add(tpAniSirGlobal pMac, tpPESession psessionEntry) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 480 | { |
| 481 | tLimMlmStartReq mlmStartReq; |
| 482 | uint32_t cfg; |
| 483 | tpSirMacMgmtHdr pHdr = (tpSirMacMgmtHdr) pMac->lim.ibssInfo.pHdr; |
| 484 | tpSchBeaconStruct pBeacon = |
| 485 | (tpSchBeaconStruct) pMac->lim.ibssInfo.pBeacon; |
Karthik Kantamneni | e3bbd7f | 2018-09-19 20:27:32 +0530 | [diff] [blame] | 486 | qdf_size_t num_ext_rates = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 487 | |
| 488 | if ((pHdr == NULL) || (pBeacon == NULL)) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 489 | pe_err("Unable to add BSS (no cached BSS info)"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 490 | return; |
| 491 | } |
| 492 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 493 | qdf_mem_copy(psessionEntry->bssId, pHdr->bssId, sizeof(tSirMacAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 494 | |
| 495 | sir_copy_mac_addr(pHdr->bssId, psessionEntry->bssId); |
| 496 | |
| 497 | /* Copy beacon interval from sessionTable */ |
| 498 | cfg = psessionEntry->beaconParams.beaconInterval; |
| 499 | if (cfg != pBeacon->beaconInterval) |
| 500 | psessionEntry->beaconParams.beaconInterval = |
| 501 | pBeacon->beaconInterval; |
| 502 | |
| 503 | /* This function ibss_bss_add (and hence the below code) is only called during ibss coalescing. We need to |
| 504 | * adapt to peer's capability with respect to short slot time. Changes have been made to lim_apply_configuration() |
Jeff Johnson | 33142e6 | 2018-05-06 17:58:36 -0700 | [diff] [blame] | 505 | * so that the IBSS doesn't blindly start with short slot = 1. If IBSS start is part of coalescing then it will adapt |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 506 | * to peer's short slot using code below. |
| 507 | */ |
| 508 | /* If cfg is already set to current peer's capability then no need to set it again */ |
| 509 | if (psessionEntry->shortSlotTimeSupported != |
| 510 | pBeacon->capabilityInfo.shortSlotTime) { |
| 511 | psessionEntry->shortSlotTimeSupported = |
| 512 | pBeacon->capabilityInfo.shortSlotTime; |
| 513 | } |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 514 | qdf_mem_copy((uint8_t *) &psessionEntry->pLimStartBssReq-> |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 515 | operationalRateSet, (uint8_t *) &pBeacon->supportedRates, |
| 516 | pBeacon->supportedRates.numRates); |
| 517 | |
| 518 | /** |
| 519 | * WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET CFG needs to be reset, when |
| 520 | * there is no extended rate IE present in beacon. This is especially important when |
| 521 | * supportedRateSet IE contains all the extended rates as well and STA decides to coalesce. |
| 522 | * In this IBSS coalescing scenario LIM will tear down the BSS and Add a new one. So LIM needs to |
| 523 | * reset this CFG, just in case CSR originally had set this CFG when IBSS was started from the local profile. |
| 524 | * If IBSS was started by CSR from the BssDescription, then it would reset this CFG before StartBss is issued. |
| 525 | * The idea is that the count of OpRateSet and ExtendedOpRateSet rates should not be more than 12. |
| 526 | */ |
| 527 | |
| 528 | if (pBeacon->extendedRatesPresent) |
Karthik Kantamneni | e3bbd7f | 2018-09-19 20:27:32 +0530 | [diff] [blame] | 529 | num_ext_rates = pBeacon->extendedRates.numRates; |
| 530 | if (wlan_mlme_set_cfg_str( |
| 531 | (uint8_t *)&pBeacon->extendedRates.rate, |
| 532 | &pMac->mlme_cfg->rates.ext_opr_rate_set, |
| 533 | num_ext_rates) != QDF_STATUS_SUCCESS) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 534 | pe_err("could not update ExtendedOperRateset at CFG"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 535 | return; |
| 536 | } |
| 537 | |
| 538 | /* |
| 539 | * Each IBSS node will advertise its own HT Capabilities instead of adapting to the Peer's capabilities |
| 540 | * If we don't do this then IBSS may not go back to full capabilities when the STA with lower capabilities |
| 541 | * leaves the IBSS. e.g. when non-CB STA joins an IBSS and then leaves, the IBSS will be stuck at non-CB mode |
| 542 | * even though all the nodes are capable of doing CB. |
| 543 | * so it is decided to leave the self HT capabilties intact. This may change if some issues are found in interop. |
| 544 | */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 545 | qdf_mem_set((void *)&mlmStartReq, sizeof(mlmStartReq), 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 546 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 547 | qdf_mem_copy(mlmStartReq.bssId, pHdr->bssId, sizeof(tSirMacAddr)); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 548 | mlmStartReq.rateSet.numRates = |
| 549 | psessionEntry->pLimStartBssReq->operationalRateSet.numRates; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 550 | qdf_mem_copy(&mlmStartReq.rateSet.rate[0], |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 551 | &psessionEntry->pLimStartBssReq->operationalRateSet. |
| 552 | rate[0], mlmStartReq.rateSet.numRates); |
| 553 | mlmStartReq.bssType = eSIR_IBSS_MODE; |
| 554 | mlmStartReq.beaconPeriod = pBeacon->beaconInterval; |
| 555 | mlmStartReq.nwType = psessionEntry->pLimStartBssReq->nwType; /* psessionEntry->nwType is also OK???? */ |
| 556 | mlmStartReq.htCapable = psessionEntry->htCapability; |
| 557 | mlmStartReq.htOperMode = pMac->lim.gHTOperMode; |
| 558 | mlmStartReq.dualCTSProtection = pMac->lim.gHTDualCTSProtection; |
| 559 | mlmStartReq.txChannelWidthSet = psessionEntry->htRecommendedTxWidthSet; |
| 560 | |
| 561 | /* reading the channel num from session Table */ |
| 562 | mlmStartReq.channelNumber = psessionEntry->currentOperChannel; |
| 563 | |
| 564 | mlmStartReq.cbMode = psessionEntry->pLimStartBssReq->cbMode; |
| 565 | |
| 566 | /* Copy the SSID for RxP filtering based on SSID. */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 567 | qdf_mem_copy((uint8_t *) &mlmStartReq.ssId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 568 | (uint8_t *) &psessionEntry->pLimStartBssReq->ssId, |
| 569 | psessionEntry->pLimStartBssReq->ssId.length + 1); |
| 570 | |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 571 | pe_debug("invoking ADD_BSS as part of coalescing!"); |
Rajeev Kumar Sirasanagandla | 2f17f8d | 2018-10-03 17:24:20 +0530 | [diff] [blame^] | 572 | #ifdef CONFIG_VDEV_SM |
| 573 | wlan_vdev_mlme_sm_deliver_evt(psessionEntry->vdev, |
| 574 | WLAN_VDEV_SM_EV_START, |
| 575 | sizeof(mlmStartReq), &mlmStartReq); |
| 576 | #else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 577 | if (lim_mlm_add_bss(pMac, &mlmStartReq, psessionEntry) != |
| 578 | eSIR_SME_SUCCESS) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 579 | pe_err("AddBss failure"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 580 | return; |
| 581 | } |
Rajeev Kumar Sirasanagandla | 2f17f8d | 2018-10-03 17:24:20 +0530 | [diff] [blame^] | 582 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 583 | /* Update fields in Beacon */ |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 584 | if (sch_set_fixed_beacon_fields(pMac, psessionEntry) != QDF_STATUS_SUCCESS) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 585 | pe_err("Unable to set fixed Beacon fields"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 586 | return; |
| 587 | } |
| 588 | |
| 589 | } |
| 590 | |
Rajeev Kumar Sirasanagandla | 2f17f8d | 2018-10-03 17:24:20 +0530 | [diff] [blame^] | 591 | void ibss_bss_delete(tpAniSirGlobal mac_ctx, tpPESession session) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 592 | { |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 593 | QDF_STATUS status; |
Srinivas Girigowda | 4d65ebe | 2017-10-13 21:41:42 -0700 | [diff] [blame] | 594 | |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 595 | pe_debug("Initiating IBSS Delete BSS"); |
Rajeev Kumar Sirasanagandla | 2f17f8d | 2018-10-03 17:24:20 +0530 | [diff] [blame^] | 596 | if (session->limMlmState != eLIM_MLM_BSS_STARTED_STATE) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 597 | pe_warn("Incorrect LIM MLM state for delBss: %d", |
Rajeev Kumar Sirasanagandla | 2f17f8d | 2018-10-03 17:24:20 +0530 | [diff] [blame^] | 598 | session->limMlmState); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 599 | return; |
| 600 | } |
Rajeev Kumar Sirasanagandla | 2f17f8d | 2018-10-03 17:24:20 +0530 | [diff] [blame^] | 601 | status = lim_del_bss(mac_ctx, NULL, session->bssIdx, session); |
| 602 | if (QDF_IS_STATUS_ERROR(status)) |
| 603 | pe_err("delBss failed for bss: %d", session->bssIdx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 604 | } |
| 605 | |
| 606 | /** |
| 607 | * lim_ibss_init |
| 608 | * |
| 609 | ***FUNCTION: |
| 610 | * This function is called while starting an IBSS |
| 611 | * to initialize list used to maintain IBSS peers. |
| 612 | * |
| 613 | ***LOGIC: |
| 614 | * |
| 615 | ***ASSUMPTIONS: |
| 616 | * |
| 617 | ***NOTE: |
| 618 | * |
| 619 | * @param pMac - Pointer to Global MAC structure |
| 620 | * @return None |
| 621 | */ |
| 622 | |
| 623 | void lim_ibss_init(tpAniSirGlobal pMac) |
| 624 | { |
| 625 | pMac->lim.gLimIbssCoalescingHappened = 0; |
| 626 | pMac->lim.gLimIbssPeerList = NULL; |
| 627 | pMac->lim.gLimNumIbssPeers = 0; |
| 628 | |
| 629 | /* ibss info - params for which ibss to join while coalescing */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 630 | qdf_mem_set(&pMac->lim.ibssInfo, sizeof(tAniSirLimIbss), 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 631 | } /*** end lim_ibss_init() ***/ |
| 632 | |
| 633 | /** |
| 634 | * lim_ibss_delete_all_peers |
| 635 | * |
| 636 | ***FUNCTION: |
| 637 | * This function is called to delete all peers. |
| 638 | * |
| 639 | ***LOGIC: |
| 640 | * |
| 641 | ***ASSUMPTIONS: |
| 642 | * |
| 643 | ***NOTE: |
| 644 | * |
| 645 | * @param pMac - Pointer to Global MAC structure |
| 646 | * @return None |
| 647 | */ |
Rajeev Kumar Sirasanagandla | 2f17f8d | 2018-10-03 17:24:20 +0530 | [diff] [blame^] | 648 | void lim_ibss_delete_all_peers(tpAniSirGlobal pMac, |
| 649 | tpPESession psessionEntry) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 650 | { |
| 651 | tLimIbssPeerNode *pCurrNode, *pTempNode; |
| 652 | tpDphHashNode pStaDs; |
| 653 | uint16_t peerIdx; |
Rajeev Kumar Sirasanagandla | 2f17f8d | 2018-10-03 17:24:20 +0530 | [diff] [blame^] | 654 | #ifdef CONFIG_VDEV_SM |
| 655 | QDF_STATUS status; |
| 656 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 657 | |
| 658 | pCurrNode = pTempNode = pMac->lim.gLimIbssPeerList; |
| 659 | |
| 660 | while (pCurrNode != NULL) { |
| 661 | if (!pMac->lim.gLimNumIbssPeers) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 662 | pe_err("Number of peers in the list is zero and node present"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 663 | return; |
| 664 | } |
| 665 | /* Delete the dph entry for the station |
| 666 | * Since it is called to remove all peers, just delete from dph, |
| 667 | * no need to do any beacon related params i.e., dont call lim_delete_dph_hash_entry |
| 668 | */ |
| 669 | pStaDs = |
| 670 | dph_lookup_hash_entry(pMac, pCurrNode->peerMacAddr, &peerIdx, |
| 671 | &psessionEntry->dph.dphHashTable); |
| 672 | if (pStaDs) { |
| 673 | |
| 674 | ibss_status_chg_notify(pMac, pCurrNode->peerMacAddr, |
| 675 | pStaDs->staIndex, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 676 | eWNI_SME_IBSS_PEER_DEPARTED_IND, |
| 677 | psessionEntry->smeSessionId); |
Rajeev Kumar Sirasanagandla | 2f17f8d | 2018-10-03 17:24:20 +0530 | [diff] [blame^] | 678 | lim_del_sta(pMac, pStaDs, false, psessionEntry); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 679 | lim_release_peer_idx(pMac, peerIdx, psessionEntry); |
| 680 | dph_delete_hash_entry(pMac, pStaDs->staAddr, peerIdx, |
| 681 | &psessionEntry->dph.dphHashTable); |
| 682 | } |
| 683 | |
| 684 | pTempNode = pCurrNode->next; |
| 685 | |
| 686 | /* TODO :Sessionize this code */ |
| 687 | /* Fix CR 227642: PeerList should point to the next node since the current node is being |
| 688 | * freed in the next line. In ibss_peerfind in ibss_status_chg_notify above, we use this |
| 689 | * peer list to find the next peer. So this list needs to be updated with the no of peers left |
| 690 | * after each iteration in this while loop since one by one peers are deleted (freed) in this |
| 691 | * loop causing the lim.gLimIbssPeerList to point to some freed memory. |
| 692 | */ |
| 693 | pMac->lim.gLimIbssPeerList = pTempNode; |
| 694 | |
| 695 | if (pCurrNode->beacon) { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 696 | qdf_mem_free(pCurrNode->beacon); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 697 | } |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 698 | qdf_mem_free(pCurrNode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 699 | if (pMac->lim.gLimNumIbssPeers > 0) /* be paranoid */ |
| 700 | pMac->lim.gLimNumIbssPeers--; |
| 701 | pCurrNode = pTempNode; |
| 702 | } |
| 703 | |
| 704 | if (pMac->lim.gLimNumIbssPeers) |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 705 | pe_err("Number of peers: %d in the list is non-zero", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 706 | pMac->lim.gLimNumIbssPeers); |
| 707 | |
| 708 | pMac->lim.gLimNumIbssPeers = 0; |
| 709 | pMac->lim.gLimIbssPeerList = NULL; |
Rajeev Kumar Sirasanagandla | 2f17f8d | 2018-10-03 17:24:20 +0530 | [diff] [blame^] | 710 | #ifdef CONFIG_VDEV_SM |
| 711 | status = |
| 712 | wlan_vdev_mlme_sm_deliver_evt(psessionEntry->vdev, |
| 713 | WLAN_VDEV_SM_EV_DISCONNECT_COMPLETE, |
| 714 | sizeof(*psessionEntry), psessionEntry); |
| 715 | if (!pMac->lim.gLimIbssCoalescingHappened && |
| 716 | QDF_IS_STATUS_ERROR(status)) { |
| 717 | pe_err("failed to post WLAN_VDEV_SM_EV_DISCONNECT_COMPLETE for vdevid %d", |
| 718 | psessionEntry->smeSessionId); |
| 719 | lim_send_stop_bss_failure_resp(pMac, psessionEntry); |
| 720 | } |
| 721 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 722 | } |
| 723 | |
| 724 | /** |
| 725 | * lim_ibss_delete() - This function is called while tearing down an IBSS |
| 726 | * |
| 727 | * @pMac: Pointer to Global MAC structure |
| 728 | * @psessionEntry: Pointer to session entry |
| 729 | * |
| 730 | * Return: none |
| 731 | */ |
| 732 | |
| 733 | void lim_ibss_delete(tpAniSirGlobal pMac, tpPESession psessionEntry) |
| 734 | { |
Rajeev Kumar Sirasanagandla | 2f17f8d | 2018-10-03 17:24:20 +0530 | [diff] [blame^] | 735 | #ifndef CONFIG_VDEV_SM |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 736 | lim_ibss_delete_all_peers(pMac, psessionEntry); |
Rajeev Kumar Sirasanagandla | 2f17f8d | 2018-10-03 17:24:20 +0530 | [diff] [blame^] | 737 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 738 | ibss_coalesce_free(pMac); |
| 739 | } |
| 740 | |
| 741 | /** ------------------------------------------------------------- |
| 742 | \fn lim_ibss_set_protection |
| 743 | \brief Decides all the protection related information. |
| 744 | \ |
| 745 | \param tpAniSirGlobal pMac |
| 746 | \param tSirMacAddr peerMacAddr |
| 747 | \param tpUpdateBeaconParams pBeaconParams |
| 748 | \return None |
| 749 | -------------------------------------------------------------*/ |
| 750 | static void |
| 751 | lim_ibss_set_protection(tpAniSirGlobal pMac, uint8_t enable, |
| 752 | tpUpdateBeaconParams pBeaconParams, |
| 753 | tpPESession psessionEntry) |
| 754 | { |
| 755 | |
| 756 | if (!pMac->lim.cfgProtection.fromllb) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 757 | pe_err("protection from 11b is disabled"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 758 | return; |
| 759 | } |
| 760 | |
| 761 | if (enable) { |
| 762 | psessionEntry->gLim11bParams.protectionEnabled = true; |
| 763 | if (false == |
| 764 | psessionEntry->beaconParams. |
| 765 | llbCoexist /*pMac->lim.llbCoexist */) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 766 | pe_debug("=> IBSS: Enable Protection"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 767 | pBeaconParams->llbCoexist = |
| 768 | psessionEntry->beaconParams.llbCoexist = true; |
| 769 | pBeaconParams->paramChangeBitmap |= |
| 770 | PARAM_llBCOEXIST_CHANGED; |
| 771 | } |
| 772 | } else if (true == |
| 773 | psessionEntry->beaconParams. |
| 774 | llbCoexist /*pMac->lim.llbCoexist */) { |
| 775 | psessionEntry->gLim11bParams.protectionEnabled = false; |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 776 | pe_debug("===> IBSS: Disable protection"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 777 | pBeaconParams->llbCoexist = |
| 778 | psessionEntry->beaconParams.llbCoexist = false; |
| 779 | pBeaconParams->paramChangeBitmap |= PARAM_llBCOEXIST_CHANGED; |
| 780 | } |
| 781 | return; |
| 782 | } |
| 783 | |
| 784 | /** ------------------------------------------------------------- |
| 785 | \fn lim_ibss_update_protection_params |
| 786 | \brief Decides all the protection related information. |
| 787 | \ |
| 788 | \param tpAniSirGlobal pMac |
| 789 | \param tSirMacAddr peerMacAddr |
| 790 | \param tpUpdateBeaconParams pBeaconParams |
| 791 | \return None |
| 792 | -------------------------------------------------------------*/ |
| 793 | static void |
| 794 | lim_ibss_update_protection_params(tpAniSirGlobal pMac, |
| 795 | tSirMacAddr peerMacAddr, |
| 796 | tLimProtStaCacheType protStaCacheType, |
| 797 | tpPESession psessionEntry) |
| 798 | { |
| 799 | uint32_t i; |
| 800 | |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 801 | pe_debug("STA is associated Addr :"); |
Srinivas Girigowda | 8590a5f | 2017-03-10 14:28:37 -0800 | [diff] [blame] | 802 | lim_print_mac_addr(pMac, peerMacAddr, LOGD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 803 | |
| 804 | for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) { |
| 805 | if (pMac->lim.protStaCache[i].active) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 806 | pe_debug("Addr:"); |
Srinivas Girigowda | 8590a5f | 2017-03-10 14:28:37 -0800 | [diff] [blame] | 807 | lim_print_mac_addr |
| 808 | (pMac, pMac->lim.protStaCache[i].addr, LOGD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 809 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 810 | if (!qdf_mem_cmp(pMac->lim.protStaCache[i].addr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 811 | peerMacAddr, |
| 812 | sizeof(tSirMacAddr))) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 813 | pe_debug("matching cache entry at: %d already active", |
Srinivas Girigowda | 8590a5f | 2017-03-10 14:28:37 -0800 | [diff] [blame] | 814 | i); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 815 | return; |
| 816 | } |
| 817 | } |
| 818 | } |
| 819 | |
| 820 | for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) { |
| 821 | if (!pMac->lim.protStaCache[i].active) |
| 822 | break; |
| 823 | } |
| 824 | |
| 825 | if (i >= LIM_PROT_STA_CACHE_SIZE) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 826 | pe_err("No space in ProtStaCache"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 827 | return; |
| 828 | } |
| 829 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 830 | qdf_mem_copy(pMac->lim.protStaCache[i].addr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 831 | peerMacAddr, sizeof(tSirMacAddr)); |
| 832 | |
| 833 | pMac->lim.protStaCache[i].protStaCacheType = protStaCacheType; |
| 834 | pMac->lim.protStaCache[i].active = true; |
| 835 | if (eLIM_PROT_STA_CACHE_TYPE_llB == protStaCacheType) { |
| 836 | psessionEntry->gLim11bParams.numSta++; |
| 837 | } else if (eLIM_PROT_STA_CACHE_TYPE_llG == protStaCacheType) { |
| 838 | psessionEntry->gLim11gParams.numSta++; |
| 839 | } |
| 840 | } |
| 841 | |
| 842 | /** ------------------------------------------------------------- |
| 843 | \fn lim_ibss_decide_protection |
| 844 | \brief Decides all the protection related information. |
| 845 | \ |
| 846 | \param tpAniSirGlobal pMac |
| 847 | \param tSirMacAddr peerMacAddr |
| 848 | \param tpUpdateBeaconParams pBeaconParams |
| 849 | \return None |
| 850 | -------------------------------------------------------------*/ |
| 851 | static void |
| 852 | lim_ibss_decide_protection(tpAniSirGlobal pMac, tpDphHashNode pStaDs, |
| 853 | tpUpdateBeaconParams pBeaconParams, |
| 854 | tpPESession psessionEntry) |
| 855 | { |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 856 | enum band_info rfBand = BAND_UNKNOWN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 857 | uint32_t phyMode; |
| 858 | tLimProtStaCacheType protStaCacheType = |
| 859 | eLIM_PROT_STA_CACHE_TYPE_INVALID; |
| 860 | |
| 861 | pBeaconParams->paramChangeBitmap = 0; |
| 862 | |
| 863 | if (NULL == pStaDs) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 864 | pe_err("pStaDs is NULL"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 865 | return; |
| 866 | } |
| 867 | |
| 868 | lim_get_rf_band_new(pMac, &rfBand, psessionEntry); |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 869 | if (BAND_2G == rfBand) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 870 | lim_get_phy_mode(pMac, &phyMode, psessionEntry); |
| 871 | |
| 872 | /* We are 11G or 11n. Check if we need protection from 11b Stations. */ |
| 873 | if ((phyMode == WNI_CFG_PHY_MODE_11G) |
| 874 | || (psessionEntry->htCapability)) { |
| 875 | /* As we found in the past, it is possible that a 11n STA sends |
Jeff Johnson | 47d7524 | 2018-05-12 15:58:53 -0700 | [diff] [blame] | 876 | * Beacon with HT IE but not ERP IE. So the absence of ERP IE |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 877 | * in the Beacon is not enough to conclude that STA is 11b. |
| 878 | */ |
| 879 | if ((pStaDs->erpEnabled == eHAL_CLEAR) && |
| 880 | (!pStaDs->mlmStaContext.htCapability)) { |
| 881 | protStaCacheType = eLIM_PROT_STA_CACHE_TYPE_llB; |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 882 | pe_err("Enable protection from 11B"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 883 | lim_ibss_set_protection(pMac, true, |
| 884 | pBeaconParams, |
| 885 | psessionEntry); |
| 886 | } |
| 887 | } |
| 888 | } |
| 889 | lim_ibss_update_protection_params(pMac, pStaDs->staAddr, protStaCacheType, |
| 890 | psessionEntry); |
| 891 | return; |
| 892 | } |
| 893 | |
| 894 | /** |
| 895 | * lim_ibss_peer_find() |
| 896 | * |
| 897 | ***FUNCTION: |
| 898 | * This function is called while adding a context at |
| 899 | * DPH & Polaris for a peer in IBSS. |
| 900 | * If peer is found in the list, capabilities from the |
| 901 | * returned BSS description are used at DPH node & Polaris. |
| 902 | * |
| 903 | ***LOGIC: |
| 904 | * |
| 905 | ***ASSUMPTIONS: |
| 906 | * |
| 907 | ***NOTE: |
| 908 | * |
| 909 | * @param macAddr - MAC address of the peer |
| 910 | * |
| 911 | * @return Pointer to peer node if found, else NULL |
| 912 | */ |
| 913 | tLimIbssPeerNode *lim_ibss_peer_find(tpAniSirGlobal pMac, tSirMacAddr macAddr) |
| 914 | { |
| 915 | return ibss_peer_find(pMac, macAddr); |
| 916 | } |
| 917 | |
| 918 | /** |
| 919 | * lim_ibss_sta_add() |
| 920 | * |
| 921 | ***FUNCTION: |
| 922 | * This function is called to add an STA context in IBSS role |
| 923 | * whenever a data frame is received from/for a STA that failed |
| 924 | * hash lookup at DPH. |
| 925 | * |
| 926 | ***LOGIC: |
| 927 | * |
| 928 | ***ASSUMPTIONS: |
| 929 | * NA |
| 930 | * |
| 931 | ***NOTE: |
| 932 | * NA |
| 933 | * |
| 934 | * @param pMac Pointer to Global MAC structure |
| 935 | * @param peerAdddr MAC address of the peer being added |
| 936 | * @return retCode Indicates success or failure return code |
| 937 | * @return |
| 938 | */ |
| 939 | |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 940 | QDF_STATUS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 941 | lim_ibss_sta_add(tpAniSirGlobal pMac, void *pBody, tpPESession psessionEntry) |
| 942 | { |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 943 | QDF_STATUS retCode = QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 944 | tpDphHashNode pStaDs; |
| 945 | tLimIbssPeerNode *pPeerNode; |
| 946 | tLimMlmStates prevState; |
| 947 | tSirMacAddr *pPeerAddr = (tSirMacAddr *) pBody; |
| 948 | tUpdateBeaconParams beaconParams; |
| 949 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 950 | qdf_mem_set((uint8_t *) &beaconParams, sizeof(tUpdateBeaconParams), 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 951 | |
| 952 | if (pBody == 0) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 953 | pe_err("Invalid IBSS AddSta"); |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 954 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 955 | } |
| 956 | |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 957 | pe_debug("Rx Add-Ibss-Sta for MAC:"); |
Srinivas Girigowda | 8590a5f | 2017-03-10 14:28:37 -0800 | [diff] [blame] | 958 | lim_print_mac_addr(pMac, *pPeerAddr, LOGD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 959 | |
| 960 | pPeerNode = ibss_peer_find(pMac, *pPeerAddr); |
| 961 | if (NULL != pPeerNode) { |
| 962 | retCode = |
| 963 | ibss_dph_entry_add(pMac, *pPeerAddr, &pStaDs, |
| 964 | psessionEntry); |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 965 | if (QDF_STATUS_SUCCESS == retCode) { |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 966 | prevState = pStaDs->mlmStaContext.mlmState; |
| 967 | pStaDs->erpEnabled = pPeerNode->erpIePresent; |
| 968 | |
| 969 | ibss_sta_info_update(pMac, pStaDs, pPeerNode, |
| 970 | psessionEntry); |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 971 | pe_debug("initiating ADD STA for the IBSS peer"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 972 | retCode = |
| 973 | lim_add_sta(pMac, pStaDs, false, psessionEntry); |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 974 | if (retCode != QDF_STATUS_SUCCESS) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 975 | pe_err("ibss-sta-add failed (reason %x)", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 976 | retCode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 977 | lim_print_mac_addr(pMac, *pPeerAddr, LOGE); |
| 978 | pStaDs->mlmStaContext.mlmState = prevState; |
| 979 | dph_delete_hash_entry(pMac, pStaDs->staAddr, |
| 980 | pStaDs->assocId, |
| 981 | &psessionEntry->dph. |
| 982 | dphHashTable); |
| 983 | } else { |
| 984 | if (pMac->lim.gLimProtectionControl != |
Pragaspathi Thilagaraj | 1ee7600 | 2018-09-18 21:38:51 +0530 | [diff] [blame] | 985 | MLME_FORCE_POLICY_PROTECTION_DISABLE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 986 | lim_ibss_decide_protection(pMac, pStaDs, |
| 987 | &beaconParams, |
| 988 | psessionEntry); |
| 989 | |
| 990 | if (beaconParams.paramChangeBitmap) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 991 | pe_debug("---> Update Beacon Params"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 992 | sch_set_fixed_beacon_fields(pMac, |
| 993 | psessionEntry); |
| 994 | beaconParams.bssIdx = |
| 995 | psessionEntry->bssIdx; |
| 996 | lim_send_beacon_params(pMac, &beaconParams, |
| 997 | psessionEntry); |
| 998 | } |
| 999 | } |
| 1000 | } else { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1001 | pe_err("hashTblAdd failed reason: %x", retCode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1002 | lim_print_mac_addr(pMac, *pPeerAddr, LOGE); |
| 1003 | } |
| 1004 | } else { |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 1005 | retCode = QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1006 | } |
| 1007 | |
| 1008 | return retCode; |
| 1009 | } |
Abhishek Singh | 3df7661 | 2017-05-16 14:05:32 +0530 | [diff] [blame] | 1010 | |
Abhishek Singh | 79e7750 | 2015-12-30 17:11:49 +0530 | [diff] [blame] | 1011 | /** |
Abhishek Singh | 3df7661 | 2017-05-16 14:05:32 +0530 | [diff] [blame] | 1012 | * lim_ibss_search_and_delete_peer()- to cleanup the IBSS |
| 1013 | * peer from lim ibss peer list |
Abhishek Singh | 79e7750 | 2015-12-30 17:11:49 +0530 | [diff] [blame] | 1014 | * |
| 1015 | * @mac_ptr: Pointer to Global MAC structure |
| 1016 | * @session_entry: Session entry |
| 1017 | * @mac_addr: Mac Address of the IBSS peer |
| 1018 | * |
Abhishek Singh | 3df7661 | 2017-05-16 14:05:32 +0530 | [diff] [blame] | 1019 | * This function is called to cleanup the IBSS peer from |
| 1020 | * lim ibss peer list |
Abhishek Singh | 79e7750 | 2015-12-30 17:11:49 +0530 | [diff] [blame] | 1021 | * |
| 1022 | * Return: None |
| 1023 | * |
| 1024 | */ |
| 1025 | static void |
Abhishek Singh | 3df7661 | 2017-05-16 14:05:32 +0530 | [diff] [blame] | 1026 | lim_ibss_search_and_delete_peer(tpAniSirGlobal mac_ctx, |
Abhishek Singh | 79e7750 | 2015-12-30 17:11:49 +0530 | [diff] [blame] | 1027 | tpPESession session_entry, tSirMacAddr mac_addr) |
| 1028 | { |
| 1029 | tLimIbssPeerNode *temp_node, *prev_node; |
| 1030 | tLimIbssPeerNode *temp_next_node = NULL; |
Abhishek Singh | 79e7750 | 2015-12-30 17:11:49 +0530 | [diff] [blame] | 1031 | |
Abhishek Singh | 3df7661 | 2017-05-16 14:05:32 +0530 | [diff] [blame] | 1032 | prev_node = temp_node = mac_ctx->lim.gLimIbssPeerList; |
Abhishek Singh | 79e7750 | 2015-12-30 17:11:49 +0530 | [diff] [blame] | 1033 | |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1034 | pe_debug(" PEER ADDR :" MAC_ADDRESS_STR, |
Abhishek Singh | 79e7750 | 2015-12-30 17:11:49 +0530 | [diff] [blame] | 1035 | MAC_ADDR_ARRAY(mac_addr)); |
| 1036 | |
| 1037 | /** Compare Peer */ |
| 1038 | while (NULL != temp_node) { |
| 1039 | temp_next_node = temp_node->next; |
| 1040 | |
| 1041 | /* Delete the STA with MAC address */ |
| 1042 | if (!qdf_mem_cmp((uint8_t *) mac_addr, |
| 1043 | (uint8_t *) &temp_node->peerMacAddr, |
| 1044 | sizeof(tSirMacAddr))) { |
Abhishek Singh | 3df7661 | 2017-05-16 14:05:32 +0530 | [diff] [blame] | 1045 | if (temp_node == |
| 1046 | mac_ctx->lim.gLimIbssPeerList) { |
| 1047 | mac_ctx->lim.gLimIbssPeerList = |
| 1048 | temp_node->next; |
| 1049 | prev_node = |
| 1050 | mac_ctx->lim.gLimIbssPeerList; |
| 1051 | } else |
| 1052 | prev_node->next = temp_node->next; |
| 1053 | if (temp_node->beacon) |
| 1054 | qdf_mem_free(temp_node->beacon); |
Abhishek Singh | 79e7750 | 2015-12-30 17:11:49 +0530 | [diff] [blame] | 1055 | |
Abhishek Singh | 3df7661 | 2017-05-16 14:05:32 +0530 | [diff] [blame] | 1056 | qdf_mem_free(temp_node); |
| 1057 | mac_ctx->lim.gLimNumIbssPeers--; |
Abhishek Singh | 79e7750 | 2015-12-30 17:11:49 +0530 | [diff] [blame] | 1058 | |
Abhishek Singh | 3df7661 | 2017-05-16 14:05:32 +0530 | [diff] [blame] | 1059 | temp_node = temp_next_node; |
| 1060 | break; |
Abhishek Singh | 79e7750 | 2015-12-30 17:11:49 +0530 | [diff] [blame] | 1061 | } |
| 1062 | prev_node = temp_node; |
| 1063 | temp_node = temp_next_node; |
| 1064 | } |
| 1065 | /* |
| 1066 | * if it is the last peer walking out, we better |
| 1067 | * we set IBSS state to inactive. |
| 1068 | */ |
Abhishek Singh | 3df7661 | 2017-05-16 14:05:32 +0530 | [diff] [blame] | 1069 | if (0 == mac_ctx->lim.gLimNumIbssPeers) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1070 | pe_debug("Last STA from IBSS walked out"); |
Abhishek Singh | 79e7750 | 2015-12-30 17:11:49 +0530 | [diff] [blame] | 1071 | session_entry->limIbssActive = false; |
| 1072 | } |
| 1073 | } |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1074 | |
Abhishek Singh | 3df7661 | 2017-05-16 14:05:32 +0530 | [diff] [blame] | 1075 | /** |
| 1076 | * lim_ibss_delete_peer()- to delete IBSS peer |
| 1077 | * |
| 1078 | * @mac_ptr: Pointer to Global MAC structure |
| 1079 | * @session_entry: Session entry |
| 1080 | * @mac_addr: Mac Address of the IBSS peer |
| 1081 | * |
| 1082 | * This function is called delete IBSS peer. |
| 1083 | * |
| 1084 | * Return: None |
| 1085 | * |
| 1086 | */ |
| 1087 | static void |
| 1088 | lim_ibss_delete_peer(tpAniSirGlobal mac_ctx, |
| 1089 | tpPESession session_entry, tSirMacAddr mac_addr) |
| 1090 | { |
| 1091 | tpDphHashNode sta = NULL; |
| 1092 | uint16_t peer_idx = 0; |
| 1093 | |
| 1094 | pe_debug("Delete peer :" MAC_ADDRESS_STR, |
| 1095 | MAC_ADDR_ARRAY(mac_addr)); |
| 1096 | |
| 1097 | sta = dph_lookup_hash_entry(mac_ctx, mac_addr, |
| 1098 | &peer_idx, |
| 1099 | &session_entry->dph. |
| 1100 | dphHashTable); |
| 1101 | |
| 1102 | if (!sta) { |
| 1103 | pe_err("DPH Entry for STA %pM is missing", |
| 1104 | mac_addr); |
| 1105 | return; |
| 1106 | } |
| 1107 | |
| 1108 | if (STA_INVALID_IDX != sta->staIndex) { |
| 1109 | lim_del_sta(mac_ctx, sta, |
| 1110 | true, session_entry); |
| 1111 | } else { |
| 1112 | /* |
| 1113 | * This mean ADD STA failed, thus remove the sta from |
| 1114 | * from database and no need to send del sta to firmware |
| 1115 | * and peer departed indication to upper layer. |
| 1116 | */ |
| 1117 | lim_delete_dph_hash_entry(mac_ctx, sta->staAddr, |
| 1118 | peer_idx, session_entry); |
| 1119 | lim_release_peer_idx(mac_ctx, |
| 1120 | peer_idx, session_entry); |
| 1121 | lim_ibss_search_and_delete_peer(mac_ctx, |
| 1122 | session_entry, mac_addr); |
| 1123 | } |
| 1124 | |
| 1125 | } |
| 1126 | |
| 1127 | void lim_process_ibss_del_sta_rsp(tpAniSirGlobal mac_ctx, |
| 1128 | struct scheduler_msg *lim_msg, |
| 1129 | tpPESession pe_session) |
| 1130 | { |
| 1131 | tpDphHashNode sta_ds = NULL; |
| 1132 | tpDeleteStaParams del_sta_params = (tpDeleteStaParams) lim_msg->bodyptr; |
| 1133 | tSirResultCodes status = eSIR_SME_SUCCESS; |
| 1134 | |
| 1135 | if (!del_sta_params) { |
| 1136 | pe_err("del_sta_params is NULL"); |
| 1137 | return; |
| 1138 | } |
| 1139 | if (!LIM_IS_IBSS_ROLE(pe_session)) { |
| 1140 | pe_err("Session %d is not IBSS role", del_sta_params->assocId); |
| 1141 | status = eSIR_SME_REFUSED; |
| 1142 | goto skip_event; |
| 1143 | } |
| 1144 | |
| 1145 | sta_ds = dph_get_hash_entry(mac_ctx, del_sta_params->assocId, |
| 1146 | &pe_session->dph.dphHashTable); |
| 1147 | if (!sta_ds) { |
| 1148 | pe_err("DPH Entry for STA %X is missing", |
| 1149 | del_sta_params->assocId); |
| 1150 | status = eSIR_SME_REFUSED; |
| 1151 | goto skip_event; |
| 1152 | } |
| 1153 | |
| 1154 | if (QDF_STATUS_SUCCESS != del_sta_params->status) { |
| 1155 | pe_err("DEL STA failed!"); |
| 1156 | status = eSIR_SME_REFUSED; |
| 1157 | goto skip_event; |
| 1158 | } |
| 1159 | pe_debug("Deleted STA associd %d staId %d MAC " MAC_ADDRESS_STR, |
| 1160 | sta_ds->assocId, sta_ds->staIndex, |
| 1161 | MAC_ADDR_ARRAY(sta_ds->staAddr)); |
| 1162 | |
| 1163 | lim_delete_dph_hash_entry(mac_ctx, sta_ds->staAddr, |
| 1164 | del_sta_params->assocId, pe_session); |
| 1165 | lim_release_peer_idx(mac_ctx, |
| 1166 | del_sta_params->assocId, pe_session); |
| 1167 | |
| 1168 | ibss_status_chg_notify(mac_ctx, |
| 1169 | del_sta_params->staMac, |
| 1170 | sta_ds->staIndex, |
Abhishek Singh | 3df7661 | 2017-05-16 14:05:32 +0530 | [diff] [blame] | 1171 | eWNI_SME_IBSS_PEER_DEPARTED_IND, |
| 1172 | pe_session->smeSessionId); |
| 1173 | |
| 1174 | lim_ibss_search_and_delete_peer(mac_ctx, |
| 1175 | pe_session, del_sta_params->staMac); |
| 1176 | |
| 1177 | skip_event: |
| 1178 | qdf_mem_free(del_sta_params); |
| 1179 | lim_msg->bodyptr = NULL; |
| 1180 | } |
| 1181 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1182 | /* handle the response from HAL for an ADD STA request */ |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 1183 | QDF_STATUS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1184 | lim_ibss_add_sta_rsp(tpAniSirGlobal pMac, void *msg, tpPESession psessionEntry) |
| 1185 | { |
| 1186 | tpDphHashNode pStaDs; |
| 1187 | uint16_t peerIdx; |
| 1188 | tpAddStaParams pAddStaParams = (tpAddStaParams) msg; |
| 1189 | |
| 1190 | SET_LIM_PROCESS_DEFD_MESGS(pMac, true); |
| 1191 | if (pAddStaParams == NULL) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1192 | pe_err("IBSS: ADD_STA_RSP with no body!"); |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 1193 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1194 | } |
| 1195 | |
| 1196 | pStaDs = |
| 1197 | dph_lookup_hash_entry(pMac, pAddStaParams->staMac, &peerIdx, |
| 1198 | &psessionEntry->dph.dphHashTable); |
| 1199 | if (pStaDs == NULL) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1200 | pe_err("IBSS: ADD_STA_RSP for unknown MAC addr: "MAC_ADDRESS_STR, |
Abhishek Singh | 79e7750 | 2015-12-30 17:11:49 +0530 | [diff] [blame] | 1201 | MAC_ADDR_ARRAY(pAddStaParams->staMac)); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1202 | qdf_mem_free(pAddStaParams); |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 1203 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1204 | } |
| 1205 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1206 | if (pAddStaParams->status != QDF_STATUS_SUCCESS) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1207 | pe_err("IBSS: ADD_STA_RSP error: %x for MAC:"MAC_ADDRESS_STR, |
Abhishek Singh | 79e7750 | 2015-12-30 17:11:49 +0530 | [diff] [blame] | 1208 | pAddStaParams->status, |
| 1209 | MAC_ADDR_ARRAY(pAddStaParams->staMac)); |
Abhishek Singh | 3df7661 | 2017-05-16 14:05:32 +0530 | [diff] [blame] | 1210 | lim_ibss_delete_peer(pMac, |
Abhishek Singh | 79e7750 | 2015-12-30 17:11:49 +0530 | [diff] [blame] | 1211 | psessionEntry, pAddStaParams->staMac); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1212 | qdf_mem_free(pAddStaParams); |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 1213 | return QDF_STATUS_E_FAILURE; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1214 | } |
| 1215 | |
| 1216 | pStaDs->bssId = pAddStaParams->bssIdx; |
| 1217 | pStaDs->staIndex = pAddStaParams->staIdx; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1218 | pStaDs->valid = 1; |
| 1219 | pStaDs->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE; |
| 1220 | |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1221 | pe_debug("IBSS: sending IBSS_NEW_PEER msg to SME!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1222 | |
| 1223 | ibss_status_chg_notify(pMac, pAddStaParams->staMac, |
Jeff Johnson | 582a338 | 2018-03-05 11:58:47 -0800 | [diff] [blame] | 1224 | pStaDs->staIndex, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1225 | eWNI_SME_IBSS_NEW_PEER_IND, |
| 1226 | psessionEntry->smeSessionId); |
| 1227 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1228 | qdf_mem_free(pAddStaParams); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1229 | |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 1230 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1231 | } |
| 1232 | |
| 1233 | void lim_ibss_del_bss_rsp_when_coalescing(tpAniSirGlobal pMac, void *msg, |
| 1234 | tpPESession psessionEntry) |
| 1235 | { |
| 1236 | tpDeleteBssParams pDelBss = (tpDeleteBssParams) msg; |
| 1237 | |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1238 | pe_debug("IBSS: DEL_BSS_RSP Rcvd during coalescing!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1239 | |
| 1240 | if (pDelBss == NULL) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1241 | pe_err("IBSS: DEL_BSS_RSP(coalesce) with no body!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1242 | goto end; |
| 1243 | } |
| 1244 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1245 | if (pDelBss->status != QDF_STATUS_SUCCESS) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1246 | pe_err("IBSS: DEL_BSS_RSP(coalesce) error: %x Bss: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1247 | pDelBss->status, pDelBss->bssIdx); |
| 1248 | goto end; |
| 1249 | } |
Rajeev Kumar Sirasanagandla | 2f17f8d | 2018-10-03 17:24:20 +0530 | [diff] [blame^] | 1250 | |
| 1251 | #ifndef CONFIG_VDEV_SM |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1252 | /* Delete peer entries. */ |
| 1253 | lim_ibss_delete_all_peers(pMac, psessionEntry); |
Rajeev Kumar Sirasanagandla | 2f17f8d | 2018-10-03 17:24:20 +0530 | [diff] [blame^] | 1254 | #endif |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1255 | /* add the new bss */ |
| 1256 | ibss_bss_add(pMac, psessionEntry); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1257 | end: |
| 1258 | if (pDelBss != NULL) |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1259 | qdf_mem_free(pDelBss); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1260 | } |
| 1261 | |
| 1262 | void lim_ibss_add_bss_rsp_when_coalescing(tpAniSirGlobal pMac, void *msg, |
| 1263 | tpPESession pSessionEntry) |
| 1264 | { |
| 1265 | uint8_t infoLen; |
| 1266 | tSirSmeNewBssInfo newBssInfo; |
| 1267 | |
| 1268 | tpAddBssParams pAddBss = (tpAddBssParams) msg; |
| 1269 | |
| 1270 | tpSirMacMgmtHdr pHdr = (tpSirMacMgmtHdr) pMac->lim.ibssInfo.pHdr; |
| 1271 | tpSchBeaconStruct pBeacon = |
| 1272 | (tpSchBeaconStruct) pMac->lim.ibssInfo.pBeacon; |
| 1273 | |
| 1274 | if ((pHdr == NULL) || (pBeacon == NULL)) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1275 | pe_err("Unable to handle AddBssRspWhenCoalescing (no cached BSS info)"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1276 | goto end; |
| 1277 | } |
| 1278 | /* Inform Host of IBSS coalescing */ |
| 1279 | infoLen = sizeof(tSirMacAddr) + sizeof(tSirMacChanNum) + |
| 1280 | sizeof(uint8_t) + pBeacon->ssId.length + 1; |
| 1281 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1282 | qdf_mem_set((void *)&newBssInfo, sizeof(newBssInfo), 0); |
| 1283 | qdf_mem_copy(newBssInfo.bssId.bytes, pHdr->bssId, QDF_MAC_ADDR_SIZE); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1284 | newBssInfo.channelNumber = (tSirMacChanNum) pAddBss->currentOperChannel; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1285 | qdf_mem_copy((uint8_t *) &newBssInfo.ssId, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1286 | (uint8_t *) &pBeacon->ssId, pBeacon->ssId.length + 1); |
| 1287 | |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1288 | pe_debug("Sending JOINED_NEW_BSS notification to SME"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1289 | |
| 1290 | lim_send_sme_wm_status_change_ntf(pMac, eSIR_SME_JOINED_NEW_BSS, |
| 1291 | (uint32_t *) &newBssInfo, |
| 1292 | infoLen, pSessionEntry->smeSessionId); |
| 1293 | { |
| 1294 | /* Configure beacon and send beacons to HAL */ |
Rajeev Kumar Sirasanagandla | 2f17f8d | 2018-10-03 17:24:20 +0530 | [diff] [blame^] | 1295 | lim_send_beacon(pMac, pSessionEntry); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1296 | } |
| 1297 | |
| 1298 | end: |
| 1299 | ibss_coalesce_free(pMac); |
| 1300 | } |
| 1301 | |
| 1302 | void lim_ibss_del_bss_rsp(tpAniSirGlobal pMac, void *msg, tpPESession psessionEntry) |
| 1303 | { |
| 1304 | tSirResultCodes rc = eSIR_SME_SUCCESS; |
| 1305 | tpDeleteBssParams pDelBss = (tpDeleteBssParams) msg; |
| 1306 | tSirMacAddr nullBssid = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
| 1307 | |
| 1308 | SET_LIM_PROCESS_DEFD_MESGS(pMac, true); |
| 1309 | if (pDelBss == NULL) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1310 | pe_err("IBSS: DEL_BSS_RSP with no body!"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1311 | rc = eSIR_SME_REFUSED; |
| 1312 | goto end; |
| 1313 | } |
| 1314 | |
| 1315 | psessionEntry = pe_find_session_by_session_id(pMac, pDelBss->sessionId); |
| 1316 | if (psessionEntry == NULL) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1317 | pe_err("Session Does not exist for given sessionID"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1318 | goto end; |
| 1319 | } |
| 1320 | |
| 1321 | /* |
| 1322 | * If delBss was issued as part of IBSS Coalescing, gLimIbssCoalescingHappened flag will be true. |
| 1323 | * BSS has to be added again in this scenario, so this case needs to be handled separately. |
| 1324 | * If delBss was issued as a result of trigger from SME_STOP_BSS Request, then limSme state changes to |
| 1325 | * 'IDLE' and gLimIbssCoalescingHappened flag will be false. In this case STOP BSS RSP has to be sent to SME. |
| 1326 | */ |
| 1327 | if (true == pMac->lim.gLimIbssCoalescingHappened) { |
| 1328 | |
| 1329 | lim_ibss_del_bss_rsp_when_coalescing(pMac, msg, psessionEntry); |
| 1330 | return; |
| 1331 | } |
| 1332 | |
Anurag Chouhan | fb54ab0 | 2016-02-18 18:00:46 +0530 | [diff] [blame] | 1333 | if (pDelBss->status != QDF_STATUS_SUCCESS) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1334 | pe_err("IBSS: DEL_BSS_RSP error: %x Bss: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1335 | pDelBss->status, pDelBss->bssIdx); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1336 | rc = eSIR_SME_STOP_BSS_FAILURE; |
| 1337 | goto end; |
| 1338 | } |
| 1339 | |
| 1340 | if (lim_set_link_state(pMac, eSIR_LINK_IDLE_STATE, nullBssid, |
| 1341 | psessionEntry->selfMacAddr, NULL, |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 1342 | NULL) != QDF_STATUS_SUCCESS) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1343 | pe_err("IBSS: DEL_BSS_RSP setLinkState failed"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1344 | rc = eSIR_SME_REFUSED; |
| 1345 | goto end; |
| 1346 | } |
| 1347 | |
| 1348 | lim_ibss_delete(pMac, psessionEntry); |
| 1349 | |
| 1350 | dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable); |
| 1351 | lim_delete_pre_auth_list(pMac); |
| 1352 | |
| 1353 | psessionEntry->limMlmState = eLIM_MLM_IDLE_STATE; |
| 1354 | |
| 1355 | MTRACE(mac_trace |
| 1356 | (pMac, TRACE_CODE_MLM_STATE, psessionEntry->peSessionId, |
| 1357 | psessionEntry->limMlmState)); |
| 1358 | |
| 1359 | psessionEntry->limSystemRole = eLIM_STA_ROLE; |
| 1360 | |
| 1361 | /* Change the short slot operating mode to Default (which is 1 for now) so that when IBSS starts next time with Libra |
| 1362 | * as originator, it picks up the default. This enables us to remove hard coding of short slot = 1 from lim_apply_configuration |
| 1363 | */ |
| 1364 | psessionEntry->shortSlotTimeSupported = WNI_CFG_SHORT_SLOT_TIME_STADEF; |
| 1365 | |
| 1366 | end: |
| 1367 | if (pDelBss != NULL) |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1368 | qdf_mem_free(pDelBss); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1369 | /* Delete PE session once BSS is deleted */ |
| 1370 | if (NULL != psessionEntry) { |
| 1371 | lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, rc, |
| 1372 | psessionEntry->smeSessionId, |
| 1373 | psessionEntry->transactionId); |
| 1374 | pe_delete_session(pMac, psessionEntry); |
| 1375 | psessionEntry = NULL; |
| 1376 | } |
| 1377 | } |
| 1378 | |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1379 | /** |
| 1380 | * lim_ibss_coalesce() |
| 1381 | * |
| 1382 | ***FUNCTION: |
| 1383 | * This function is called upon receiving Beacon/Probe Response |
| 1384 | * while operating in IBSS mode. |
| 1385 | * |
| 1386 | ***LOGIC: |
| 1387 | * |
| 1388 | ***ASSUMPTIONS: |
| 1389 | * |
| 1390 | ***NOTE: |
| 1391 | * |
| 1392 | * @param pMac - Pointer to Global MAC structure |
| 1393 | * @param pBeacon - Parsed Beacon Frame structure |
| 1394 | * @param pBD - Pointer to received BD |
| 1395 | * |
| 1396 | * @return Status whether to process or ignore received Beacon Frame |
| 1397 | */ |
| 1398 | |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 1399 | QDF_STATUS |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1400 | lim_ibss_coalesce(tpAniSirGlobal pMac, |
| 1401 | tpSirMacMgmtHdr pHdr, |
| 1402 | tpSchBeaconStruct pBeacon, |
| 1403 | uint8_t *pIEs, |
| 1404 | uint32_t ieLen, uint16_t fTsfLater, tpPESession psessionEntry) |
| 1405 | { |
| 1406 | uint16_t peerIdx; |
| 1407 | tSirMacAddr currentBssId; |
| 1408 | tLimIbssPeerNode *pPeerNode; |
| 1409 | tpDphHashNode pStaDs; |
| 1410 | tUpdateBeaconParams beaconParams; |
| 1411 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1412 | qdf_mem_set((uint8_t *) &beaconParams, sizeof(tUpdateBeaconParams), 0); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1413 | |
| 1414 | sir_copy_mac_addr(currentBssId, psessionEntry->bssId); |
| 1415 | |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1416 | pe_debug("Current BSSID :" MAC_ADDRESS_STR " Received BSSID :" |
| 1417 | MAC_ADDRESS_STR, MAC_ADDR_ARRAY(currentBssId), |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1418 | MAC_ADDR_ARRAY(pHdr->bssId)); |
| 1419 | |
| 1420 | /* Check for IBSS Coalescing only if Beacon is from different BSS */ |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1421 | if (qdf_mem_cmp(currentBssId, pHdr->bssId, sizeof(tSirMacAddr)) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1422 | && psessionEntry->isCoalesingInIBSSAllowed) { |
| 1423 | /* |
| 1424 | * If STA entry is already available in the LIM hash table, then it is |
| 1425 | * possible that the peer may have left and rejoined within the heartbeat |
| 1426 | * timeout. In the offloaded case with 32 peers, the HB timeout is whopping |
| 1427 | * 128 seconds. In that case, the FW will not let any frames come in until |
| 1428 | * atleast the last sequence number is received before the peer is left |
| 1429 | * Hence, if the coalescing peer is already there in the peer list and if |
| 1430 | * the BSSID matches then, invoke delSta() to cleanup the entries. We will |
| 1431 | * let the peer coalesce when we receive next beacon from the peer |
| 1432 | */ |
| 1433 | pPeerNode = ibss_peer_find(pMac, pHdr->sa); |
| 1434 | if (NULL != pPeerNode) { |
Abhishek Singh | 3df7661 | 2017-05-16 14:05:32 +0530 | [diff] [blame] | 1435 | lim_ibss_delete_peer(pMac, psessionEntry, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1436 | pHdr->sa); |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1437 | pe_warn("Peer attempting to reconnect before HB timeout, deleted"); |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 1438 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1439 | } |
| 1440 | |
| 1441 | if (!fTsfLater) { /* No Coalescing happened. */ |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1442 | pe_warn("No Coalescing happened"); |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 1443 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1444 | } |
| 1445 | /* |
| 1446 | * IBSS Coalescing happened. |
| 1447 | * save the received beacon, and delete the current BSS. The rest of the |
| 1448 | * processing will be done in the delBss response processing |
| 1449 | */ |
| 1450 | pMac->lim.gLimIbssCoalescingHappened = true; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1451 | ibss_coalesce_save(pMac, pHdr, pBeacon); |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1452 | pe_debug("IBSS Coalescing happened Delete BSSID :" MAC_ADDRESS_STR, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1453 | MAC_ADDR_ARRAY(currentBssId)); |
Rajeev Kumar Sirasanagandla | 2f17f8d | 2018-10-03 17:24:20 +0530 | [diff] [blame^] | 1454 | #ifdef CONFIG_VDEV_SM |
| 1455 | wlan_vdev_mlme_sm_deliver_evt(psessionEntry->vdev, |
| 1456 | WLAN_VDEV_SM_EV_DOWN, |
| 1457 | sizeof(*psessionEntry), |
| 1458 | psessionEntry); |
| 1459 | #else |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1460 | ibss_bss_delete(pMac, psessionEntry); |
Rajeev Kumar Sirasanagandla | 2f17f8d | 2018-10-03 17:24:20 +0530 | [diff] [blame^] | 1461 | #endif |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 1462 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1463 | } else { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1464 | if (qdf_mem_cmp |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1465 | (currentBssId, pHdr->bssId, sizeof(tSirMacAddr))) |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 1466 | return QDF_STATUS_E_INVAL; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1467 | } |
| 1468 | |
| 1469 | /* STA in IBSS mode and SSID matches with ours */ |
| 1470 | pPeerNode = ibss_peer_find(pMac, pHdr->sa); |
| 1471 | if (pPeerNode == NULL) { |
| 1472 | /* Peer not in the list - Collect BSS description & add to the list */ |
| 1473 | uint32_t frameLen; |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 1474 | QDF_STATUS retCode; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1475 | |
| 1476 | /* |
| 1477 | * Limit the Max number of IBSS Peers allowed as the max |
| 1478 | * number of STA's allowed |
| 1479 | * pMac->lim.gLimNumIbssPeers will be increamented after exiting |
| 1480 | * this function. so we will add additional 1 to compare against |
| 1481 | * pMac->lim.gLimIbssStaLimit |
| 1482 | */ |
| 1483 | if ((pMac->lim.gLimNumIbssPeers + 1) >= |
| 1484 | pMac->lim.gLimIbssStaLimit) { |
| 1485 | /*Print every 100th time */ |
| 1486 | if (pMac->lim.ibss_retry_cnt % 100 == 0) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1487 | pe_debug("**** MAX STA LIMIT HAS REACHED ****"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1488 | } |
| 1489 | pMac->lim.ibss_retry_cnt++; |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 1490 | return QDF_STATUS_E_NOSPC; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1491 | } |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1492 | pe_debug("IBSS Peer node does not exist, adding it"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1493 | frameLen = |
| 1494 | sizeof(tLimIbssPeerNode) + ieLen - sizeof(uint32_t); |
| 1495 | |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1496 | pPeerNode = qdf_mem_malloc((uint16_t) frameLen); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1497 | if (NULL == pPeerNode) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1498 | pe_err("alloc fail %d bytes storing IBSS peer info", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1499 | frameLen); |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 1500 | return QDF_STATUS_E_NOMEM; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1501 | } |
| 1502 | |
| 1503 | pPeerNode->beacon = NULL; |
| 1504 | pPeerNode->beaconLen = 0; |
| 1505 | |
| 1506 | ibss_peer_collect(pMac, pBeacon, pHdr, pPeerNode, |
| 1507 | psessionEntry); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1508 | pPeerNode->beacon = qdf_mem_malloc(ieLen); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1509 | if (NULL == pPeerNode->beacon) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1510 | pe_err("Unable to allocate memory to store beacon"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1511 | } else { |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1512 | qdf_mem_copy(pPeerNode->beacon, pIEs, ieLen); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1513 | pPeerNode->beaconLen = (uint16_t) ieLen; |
| 1514 | } |
| 1515 | ibss_peer_add(pMac, pPeerNode); |
| 1516 | |
| 1517 | pStaDs = |
| 1518 | dph_lookup_hash_entry(pMac, pPeerNode->peerMacAddr, &peerIdx, |
| 1519 | &psessionEntry->dph.dphHashTable); |
| 1520 | if (pStaDs != NULL) { |
| 1521 | /* / DPH node already exists for the peer */ |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1522 | pe_warn("DPH Node present for just learned peer"); |
Srinivas Girigowda | 8590a5f | 2017-03-10 14:28:37 -0800 | [diff] [blame] | 1523 | lim_print_mac_addr(pMac, pPeerNode->peerMacAddr, LOGD); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1524 | ibss_sta_info_update(pMac, pStaDs, pPeerNode, |
| 1525 | psessionEntry); |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 1526 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1527 | } |
| 1528 | retCode = |
| 1529 | lim_ibss_sta_add(pMac, pPeerNode->peerMacAddr, psessionEntry); |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 1530 | if (retCode != QDF_STATUS_SUCCESS) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1531 | pe_err("lim-ibss-sta-add failed reason: %x", retCode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1532 | lim_print_mac_addr(pMac, pPeerNode->peerMacAddr, LOGE); |
| 1533 | return retCode; |
| 1534 | } |
| 1535 | /* Decide protection mode */ |
| 1536 | pStaDs = |
| 1537 | dph_lookup_hash_entry(pMac, pPeerNode->peerMacAddr, &peerIdx, |
| 1538 | &psessionEntry->dph.dphHashTable); |
| 1539 | if (pMac->lim.gLimProtectionControl != |
Pragaspathi Thilagaraj | 1ee7600 | 2018-09-18 21:38:51 +0530 | [diff] [blame] | 1540 | MLME_FORCE_POLICY_PROTECTION_DISABLE) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1541 | lim_ibss_decide_protection(pMac, pStaDs, &beaconParams, |
| 1542 | psessionEntry); |
| 1543 | |
| 1544 | if (beaconParams.paramChangeBitmap) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1545 | pe_err("beaconParams.paramChangeBitmap=1 ---> Update Beacon Params"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1546 | sch_set_fixed_beacon_fields(pMac, psessionEntry); |
| 1547 | beaconParams.bssIdx = psessionEntry->bssIdx; |
| 1548 | lim_send_beacon_params(pMac, &beaconParams, psessionEntry); |
| 1549 | } |
| 1550 | } else |
| 1551 | ibss_sta_caps_update(pMac, pPeerNode, psessionEntry); |
| 1552 | |
| 1553 | if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE) |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 1554 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1555 | |
| 1556 | /* Received Beacon from same IBSS we're */ |
| 1557 | /* currently part of. Inform Roaming algorithm */ |
| 1558 | /* if not already that IBSS is active. */ |
| 1559 | if (psessionEntry->limIbssActive == false) { |
| 1560 | limResetHBPktCount(psessionEntry); |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1561 | pe_warn("Partner joined our IBSS, Sending IBSS_ACTIVE Notification to SME"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1562 | psessionEntry->limIbssActive = true; |
| 1563 | lim_send_sme_wm_status_change_ntf(pMac, eSIR_SME_IBSS_ACTIVE, NULL, 0, |
| 1564 | psessionEntry->smeSessionId); |
| 1565 | } |
| 1566 | |
Jeff Johnson | 0301ecb | 2018-06-29 09:36:23 -0700 | [diff] [blame] | 1567 | return QDF_STATUS_SUCCESS; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1568 | } /*** end lim_handle_ibs_scoalescing() ***/ |
| 1569 | |
| 1570 | /** |
| 1571 | * lim_ibss_heart_beat_handle() - handle IBSS hearbeat failure |
| 1572 | * |
| 1573 | * @mac_ctx: global mac context |
| 1574 | * @session: PE session entry |
| 1575 | * |
| 1576 | * Hanlde IBSS hearbeat failure. |
| 1577 | * |
| 1578 | * Return: None. |
| 1579 | */ |
| 1580 | void lim_ibss_heart_beat_handle(tpAniSirGlobal mac_ctx, tpPESession session) |
| 1581 | { |
| 1582 | tLimIbssPeerNode *tempnode, *prevnode; |
| 1583 | tLimIbssPeerNode *temp_next = NULL; |
| 1584 | uint16_t peer_idx = 0; |
| 1585 | tpDphHashNode stads = 0; |
| 1586 | uint32_t threshold = 0; |
| 1587 | uint16_t sta_idx = 0; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1588 | |
| 1589 | /* |
| 1590 | * MLM BSS is started and if PE in scanmode then MLM state will be |
| 1591 | * waiting for probe resp. If Heart beat timeout triggers during this |
| 1592 | * corner case then we need to reactivate HeartBeat timer. |
| 1593 | */ |
| 1594 | if (session->limMlmState != eLIM_MLM_BSS_STARTED_STATE) |
| 1595 | return; |
| 1596 | |
| 1597 | /* If LinkMonitor is Disabled */ |
| 1598 | if (!mac_ctx->sys.gSysEnableLinkMonitorMode) |
| 1599 | return; |
| 1600 | |
| 1601 | prevnode = tempnode = mac_ctx->lim.gLimIbssPeerList; |
| 1602 | threshold = (mac_ctx->lim.gLimNumIbssPeers / 4) + 1; |
| 1603 | |
| 1604 | /* Monitor the HeartBeat with the Individual PEERS in the IBSS */ |
| 1605 | while (tempnode != NULL) { |
| 1606 | temp_next = tempnode->next; |
| 1607 | if (tempnode->beaconHBCount) { |
| 1608 | /* There was a beacon for this peer during heart beat */ |
| 1609 | tempnode->beaconHBCount = 0; |
| 1610 | tempnode->heartbeatFailure = 0; |
| 1611 | prevnode = tempnode; |
| 1612 | tempnode = temp_next; |
| 1613 | continue; |
| 1614 | } |
| 1615 | |
| 1616 | /* There wasnt any beacon received during heartbeat timer. */ |
| 1617 | tempnode->heartbeatFailure++; |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1618 | pe_err("Heartbeat fail: %d thres: %d", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1619 | tempnode->heartbeatFailure, mac_ctx->lim.gLimNumIbssPeers); |
| 1620 | if (tempnode->heartbeatFailure >= threshold) { |
| 1621 | /* Remove this entry from the list. */ |
| 1622 | stads = dph_lookup_hash_entry(mac_ctx, |
| 1623 | tempnode->peerMacAddr, &peer_idx, |
| 1624 | &session->dph.dphHashTable); |
| 1625 | if (stads) { |
| 1626 | sta_idx = stads->staIndex; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1627 | |
| 1628 | (void)lim_del_sta(mac_ctx, stads, false, |
| 1629 | session); |
| 1630 | lim_delete_dph_hash_entry(mac_ctx, |
| 1631 | stads->staAddr, peer_idx, session); |
| 1632 | lim_release_peer_idx(mac_ctx, peer_idx, |
| 1633 | session); |
| 1634 | /* Send indication. */ |
| 1635 | ibss_status_chg_notify(mac_ctx, |
| 1636 | tempnode->peerMacAddr, sta_idx, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1637 | eWNI_SME_IBSS_PEER_DEPARTED_IND, |
| 1638 | session->smeSessionId); |
| 1639 | } |
| 1640 | if (tempnode == mac_ctx->lim.gLimIbssPeerList) { |
| 1641 | mac_ctx->lim.gLimIbssPeerList = tempnode->next; |
| 1642 | prevnode = mac_ctx->lim.gLimIbssPeerList; |
| 1643 | } else { |
| 1644 | prevnode->next = tempnode->next; |
| 1645 | } |
| 1646 | |
Kapil Gupta | c797b62 | 2016-10-18 12:05:44 +0530 | [diff] [blame] | 1647 | if (tempnode->beacon) |
| 1648 | qdf_mem_free(tempnode->beacon); |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1649 | qdf_mem_free(tempnode); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1650 | mac_ctx->lim.gLimNumIbssPeers--; |
| 1651 | |
| 1652 | /* we deleted current node, so prevNode remains same. */ |
| 1653 | tempnode = temp_next; |
| 1654 | continue; |
| 1655 | } |
| 1656 | prevnode = tempnode; |
| 1657 | tempnode = temp_next; |
| 1658 | } |
| 1659 | |
| 1660 | /* |
| 1661 | * General IBSS Activity Monitor, |
| 1662 | * check if in IBSS Mode we are received any Beacons |
| 1663 | */ |
| 1664 | if (mac_ctx->lim.gLimNumIbssPeers) { |
| 1665 | if (session->LimRxedBeaconCntDuringHB < |
| 1666 | MAX_NO_BEACONS_PER_HEART_BEAT_INTERVAL) |
| 1667 | mac_ctx->lim.gLimHeartBeatBeaconStats[ |
| 1668 | session->LimRxedBeaconCntDuringHB]++; |
| 1669 | else |
| 1670 | mac_ctx->lim.gLimHeartBeatBeaconStats[0]++; |
| 1671 | |
| 1672 | /* Reset number of beacons received */ |
| 1673 | limResetHBPktCount(session); |
| 1674 | return; |
| 1675 | } else { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1676 | pe_warn("Heartbeat Failure"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1677 | mac_ctx->lim.gLimHBfailureCntInLinkEstState++; |
| 1678 | |
| 1679 | if (session->limIbssActive == true) { |
| 1680 | /* |
| 1681 | * We don't receive Beacon frames from any |
| 1682 | * other STA in IBSS. Announce IBSS inactive |
| 1683 | * to Roaming algorithm |
| 1684 | */ |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1685 | pe_warn("Alone in IBSS"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1686 | session->limIbssActive = false; |
| 1687 | |
| 1688 | lim_send_sme_wm_status_change_ntf(mac_ctx, |
| 1689 | eSIR_SME_IBSS_INACTIVE, NULL, 0, |
| 1690 | session->smeSessionId); |
| 1691 | } |
| 1692 | } |
| 1693 | } |
| 1694 | |
| 1695 | /** |
| 1696 | * lim_ibss_decide_protection_on_delete() - decides protection related info. |
| 1697 | * |
| 1698 | * @mac_ctx: global mac context |
| 1699 | * @stads: station hash node |
| 1700 | * @bcn_param: beacon parameters |
| 1701 | * @session: PE session entry |
| 1702 | * |
| 1703 | * Decides all the protection related information. |
| 1704 | * |
| 1705 | * Return: None |
| 1706 | */ |
| 1707 | void lim_ibss_decide_protection_on_delete(tpAniSirGlobal mac_ctx, |
| 1708 | tpDphHashNode stads, |
| 1709 | tpUpdateBeaconParams bcn_param, |
| 1710 | tpPESession session) |
| 1711 | { |
| 1712 | uint32_t phymode; |
| 1713 | tHalBitVal erpenabled = eHAL_CLEAR; |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1714 | enum band_info rfband = BAND_UNKNOWN; |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1715 | uint32_t i; |
| 1716 | |
| 1717 | if (NULL == stads) |
| 1718 | return; |
| 1719 | |
| 1720 | lim_get_rf_band_new(mac_ctx, &rfband, session); |
Varun Reddy Yeturu | a48bc41 | 2017-11-17 15:33:35 -0800 | [diff] [blame] | 1721 | if (BAND_2G != rfband) |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1722 | return; |
| 1723 | |
| 1724 | lim_get_phy_mode(mac_ctx, &phymode, session); |
| 1725 | erpenabled = stads->erpEnabled; |
| 1726 | /* we are HT or 11G and 11B station is getting deleted. */ |
| 1727 | if (((phymode == WNI_CFG_PHY_MODE_11G) || |
| 1728 | session->htCapability) && (erpenabled == eHAL_CLEAR)) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1729 | pe_err("%d A legacy STA is disassociated Addr is", |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1730 | session->gLim11bParams.numSta); |
| 1731 | lim_print_mac_addr(mac_ctx, stads->staAddr, LOGE); |
| 1732 | if (session->gLim11bParams.numSta == 0) { |
Nishank Aggarwal | e11ec7b | 2017-03-24 17:40:40 +0530 | [diff] [blame] | 1733 | pe_err("No 11B STA exists. Disable protection"); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1734 | lim_ibss_set_protection(mac_ctx, false, |
| 1735 | bcn_param, session); |
| 1736 | } |
| 1737 | |
| 1738 | for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) { |
| 1739 | if (!mac_ctx->lim.protStaCache[i].active) |
| 1740 | continue; |
Anurag Chouhan | 600c3a0 | 2016-03-01 10:33:54 +0530 | [diff] [blame] | 1741 | if (!qdf_mem_cmp(mac_ctx->lim.protStaCache[i].addr, |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1742 | stads->staAddr, sizeof(tSirMacAddr))) { |
| 1743 | session->gLim11bParams.numSta--; |
| 1744 | mac_ctx->lim.protStaCache[i].active = false; |
| 1745 | break; |
| 1746 | } |
| 1747 | } |
| 1748 | |
| 1749 | } |
| 1750 | } |
| 1751 | |
| 1752 | /** ----------------------------------------------------------------- |
| 1753 | \fn __lim_ibss_peer_inactivity_handler |
| 1754 | \brief Internal function. Deletes FW indicated peer which is inactive |
| 1755 | \ |
| 1756 | \param tpAniSirGlobal pMac |
| 1757 | \param tpPESession psessionEntry |
| 1758 | \param tpSirIbssPeerInactivityInd peerInactivityInd |
| 1759 | \return None |
| 1760 | -----------------------------------------------------------------*/ |
| 1761 | static void |
| 1762 | __lim_ibss_peer_inactivity_handler(tpAniSirGlobal pMac, |
| 1763 | tpPESession psessionEntry, |
| 1764 | tpSirIbssPeerInactivityInd peerInactivityInd) |
| 1765 | { |
| 1766 | if (psessionEntry->limMlmState != eLIM_MLM_BSS_STARTED_STATE) { |
| 1767 | return; |
| 1768 | } |
| 1769 | |
| 1770 | /* delete the peer for which heartbeat is observed */ |
Abhishek Singh | 3df7661 | 2017-05-16 14:05:32 +0530 | [diff] [blame] | 1771 | lim_ibss_delete_peer(pMac, psessionEntry, |
Srinivas Girigowda | 01d1c3c | 2015-11-25 16:54:41 -0800 | [diff] [blame] | 1772 | peerInactivityInd->peer_addr.bytes); |
Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame] | 1773 | } |
| 1774 | |
| 1775 | /** ------------------------------------------------------------- |
| 1776 | \fn lim_process_ibss_peer_inactivity |
| 1777 | \brief Peer inactivity message handler |
| 1778 | \ |
| 1779 | \param tpAniSirGlobal pMac |
| 1780 | \param void* buf |
| 1781 | \return None |
| 1782 | -------------------------------------------------------------*/ |
| 1783 | void lim_process_ibss_peer_inactivity(tpAniSirGlobal pMac, void *buf) |
| 1784 | { |
| 1785 | /* |
| 1786 | * --------------- HEARTBEAT OFFLOAD CASE ------------------ |
| 1787 | * This message handler is executed when the firmware identifies |
| 1788 | * inactivity from one or more peer devices. We will come here |
| 1789 | * for every inactive peer device |
| 1790 | */ |
| 1791 | uint8_t i; |
| 1792 | |
| 1793 | tSirIbssPeerInactivityInd *peerInactivityInd = |
| 1794 | (tSirIbssPeerInactivityInd *) buf; |
| 1795 | |
| 1796 | /* |
| 1797 | * If IBSS is not started or heartbeat offload is not enabled |
| 1798 | * we should not handle this request |
| 1799 | */ |
| 1800 | if (eLIM_STA_IN_IBSS_ROLE != pMac->lim.gLimSystemRole && |
| 1801 | !IS_IBSS_HEARTBEAT_OFFLOAD_FEATURE_ENABLE) { |
| 1802 | return; |
| 1803 | } |
| 1804 | |
| 1805 | /** If LinkMonitor is Disabled */ |
| 1806 | if (!pMac->sys.gSysEnableLinkMonitorMode) { |
| 1807 | return; |
| 1808 | } |
| 1809 | |
| 1810 | for (i = 0; i < pMac->lim.maxBssId; i++) { |
| 1811 | if (true == pMac->lim.gpSession[i].valid && |
| 1812 | eSIR_IBSS_MODE == pMac->lim.gpSession[i].bssType) { |
| 1813 | __lim_ibss_peer_inactivity_handler(pMac, |
| 1814 | &pMac->lim.gpSession[i], |
| 1815 | peerInactivityInd); |
| 1816 | break; |
| 1817 | } |
| 1818 | } |
| 1819 | } |