blob: e9e1618d70f0e06ad156b518efb368b515bdf958 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Jeff Johnson582a3382018-03-05 11:58:47 -08002 * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * 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 Dhavali7090c5f2015-11-02 17:55:19 -080019#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 Dhavali7090c5f2015-11-02 17:55:19 -080029#include "lim_ft_defs.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080030#include "lim_session.h"
31#include "lim_ibss_peer_mgmt.h"
32#include "lim_types.h"
Karthik Kantamnenie3bbd7f2018-09-19 20:27:32 +053033#include "wlan_mlme_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080034
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
55static tLimIbssPeerNode *ibss_peer_find(tpAniSirGlobal pMac,
56 tSirMacAddr macAddr)
57{
58 tLimIbssPeerNode *pTempNode = pMac->lim.gLimIbssPeerList;
59
60 while (pTempNode != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053061 if (!qdf_mem_cmp((uint8_t *) macAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080062 (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 Johnson0301ecb2018-06-29 09:36:23 -070090static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080091ibss_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 Girigowda4d65ebe2017-10-13 21:41:42 -0700102
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800103 pTemp = pPrev = pMac->lim.gLimIbssPeerList;
104 while (pTemp->next != NULL) {
105 pPrev = pTemp;
106 pTemp = pTemp->next;
107 }
108 if (pTemp->beacon) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530109 qdf_mem_free(pTemp->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800110 }
111
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530112 qdf_mem_free(pTemp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800113 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 Johnson0301ecb2018-06-29 09:36:23 -0700121 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800122
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
146static void
147ibss_peer_collect(tpAniSirGlobal pMac,
148 tpSchBeaconStruct pBeacon,
149 tpSirMacMgmtHdr pHdr,
150 tLimIbssPeerNode *pPeer, tpPESession psessionEntry)
151{
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530152 qdf_mem_copy(pPeer->peerMacAddr, pHdr->sa, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800153
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 Chouhan600c3a02016-03-01 10:33:54 +0530168 qdf_mem_copy((uint8_t *) pPeer->supportedMCSSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800169 (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 Dhavali7090c5f2015-11-02 17:55:19 -0800190 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 Chouhan600c3a02016-03-01 10:33:54 +0530196 qdf_mem_copy((uint8_t *) &pPeer->VHTCaps,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800197 (uint8_t *) &pBeacon->VHTCaps,
198 sizeof(tDot11fIEVHTCaps));
199 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800200 pPeer->erpIePresent = pBeacon->erpPresent;
201
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530202 qdf_mem_copy((uint8_t *) &pPeer->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800203 (uint8_t *) &pBeacon->supportedRates,
204 pBeacon->supportedRates.numRates + 1);
205 if (pPeer->extendedRatesPresent)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530206 qdf_mem_copy((uint8_t *) &pPeer->extendedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800207 (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 */
216static void
217ibss_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 Singh10a00262015-10-16 16:26:14 +0530238 pStaDs->htSecondaryChannelOffset =
239 pPeerNode->htSecondaryChannelOffset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800240 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 Dhavali7090c5f2015-11-02 17:55:19 -0800255 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 Dhavali7090c5f2015-11-02 17:55:19 -0800269 /* peer is 11e capable but is not 11e enabled yet */
270 /* some STA's when joining Airgo IBSS, assert qos capability even when */
Jeff Johnsona642ead2018-05-11 09:26:13 -0700271 /* they don't support qos. however, they do not include the edca parameter */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800272 /* 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
317static void
318ibss_sta_rates_update(tpAniSirGlobal pMac,
319 tpDphHashNode pStaDs,
320 tLimIbssPeerNode *pPeer, tpPESession psessionEntry)
321{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800322 lim_populate_matching_rate_set(pMac, pStaDs, &pPeer->supportedRates,
323 &pPeer->extendedRates,
324 pPeer->supportedMCSSet, psessionEntry,
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -0700325 &pPeer->VHTCaps, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800326 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
349static void
350ibss_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
359static void ibss_coalesce_free(tpAniSirGlobal pMac)
360{
361 if (pMac->lim.ibssInfo.pHdr != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530362 qdf_mem_free(pMac->lim.ibssInfo.pHdr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800363 if (pMac->lim.ibssInfo.pBeacon != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530364 qdf_mem_free(pMac->lim.ibssInfo.pBeacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800365
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 */
373static void
374ibss_coalesce_save(tpAniSirGlobal pMac,
375 tpSirMacMgmtHdr pHdr, tpSchBeaconStruct pBeacon)
376{
377 /* get rid of any saved info */
378 ibss_coalesce_free(pMac);
379
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530380 pMac->lim.ibssInfo.pHdr = qdf_mem_malloc(sizeof(*pHdr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800381 if (NULL == pMac->lim.ibssInfo.pHdr) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530382 pe_err("ibbs-save: Failed malloc pHdr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800383 return;
384 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530385 pMac->lim.ibssInfo.pBeacon = qdf_mem_malloc(sizeof(*pBeacon));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800386 if (NULL == pMac->lim.ibssInfo.pBeacon) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530387 pe_err("ibbs-save: Failed malloc pBeacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800388 ibss_coalesce_free(pMac);
389 return;
390 }
391
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530392 qdf_mem_copy(pMac->lim.ibssInfo.pHdr, pHdr, sizeof(*pHdr));
393 qdf_mem_copy(pMac->lim.ibssInfo.pBeacon, pBeacon, sizeof(*pBeacon));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800394}
395
396/*
397 * tries to add a new entry to dph hash node
398 * if necessary, an existing entry is eliminated
399 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700400static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800401ibss_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 Aggarwale11ec7b2017-03-24 17:40:40 +0530415 pe_err("STA exists already");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800416 lim_print_mac_addr(pMac, peerAddr, LOGE);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700417 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800418 }
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 Aggarwale11ec7b2017-03-24 17:40:40 +0530441 pe_err("could not add hash entry at DPH for peerIdx/aid: %d MACaddr:",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800442 peerIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800443 lim_print_mac_addr(pMac, peerAddr, LOGE);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700444 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800445 }
446
447 *ppSta = pStaDs;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700448 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800449}
450
451/* send a status change notification */
452static void
Jeff Johnson582a3382018-03-05 11:58:47 -0800453ibss_status_chg_notify(tpAniSirGlobal pMac, tSirMacAddr peerAddr,
454 uint16_t staIndex, uint16_t status, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800455{
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 Johnson582a3382018-03-05 11:58:47 -0800471 lim_send_sme_ibss_peer_ind(pMac, peerAddr, staIndex,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800472 beacon, bcnLen, status, sessionId);
473
474 if (beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530475 qdf_mem_free(beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800476 }
477}
478
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +0530479void ibss_bss_add(tpAniSirGlobal pMac, tpPESession psessionEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800480{
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 Kantamnenie3bbd7f2018-09-19 20:27:32 +0530486 qdf_size_t num_ext_rates = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800487
488 if ((pHdr == NULL) || (pBeacon == NULL)) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530489 pe_err("Unable to add BSS (no cached BSS info)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800490 return;
491 }
492
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530493 qdf_mem_copy(psessionEntry->bssId, pHdr->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800494
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 Johnson33142e62018-05-06 17:58:36 -0700505 * so that the IBSS doesn't blindly start with short slot = 1. If IBSS start is part of coalescing then it will adapt
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800506 * 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 Chouhan600c3a02016-03-01 10:33:54 +0530514 qdf_mem_copy((uint8_t *) &psessionEntry->pLimStartBssReq->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800515 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 Kantamnenie3bbd7f2018-09-19 20:27:32 +0530529 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 Aggarwale11ec7b2017-03-24 17:40:40 +0530534 pe_err("could not update ExtendedOperRateset at CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800535 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 Chouhan600c3a02016-03-01 10:33:54 +0530545 qdf_mem_set((void *)&mlmStartReq, sizeof(mlmStartReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800546
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530547 qdf_mem_copy(mlmStartReq.bssId, pHdr->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800548 mlmStartReq.rateSet.numRates =
549 psessionEntry->pLimStartBssReq->operationalRateSet.numRates;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530550 qdf_mem_copy(&mlmStartReq.rateSet.rate[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800551 &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 Chouhan600c3a02016-03-01 10:33:54 +0530567 qdf_mem_copy((uint8_t *) &mlmStartReq.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800568 (uint8_t *) &psessionEntry->pLimStartBssReq->ssId,
569 psessionEntry->pLimStartBssReq->ssId.length + 1);
570
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530571 pe_debug("invoking ADD_BSS as part of coalescing!");
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +0530572#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 Dhavali7090c5f2015-11-02 17:55:19 -0800577 if (lim_mlm_add_bss(pMac, &mlmStartReq, psessionEntry) !=
578 eSIR_SME_SUCCESS) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530579 pe_err("AddBss failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800580 return;
581 }
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +0530582#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800583 /* Update fields in Beacon */
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700584 if (sch_set_fixed_beacon_fields(pMac, psessionEntry) != QDF_STATUS_SUCCESS) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530585 pe_err("Unable to set fixed Beacon fields");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800586 return;
587 }
588
589}
590
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +0530591void ibss_bss_delete(tpAniSirGlobal mac_ctx, tpPESession session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800592{
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700593 QDF_STATUS status;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -0700594
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530595 pe_debug("Initiating IBSS Delete BSS");
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +0530596 if (session->limMlmState != eLIM_MLM_BSS_STARTED_STATE) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530597 pe_warn("Incorrect LIM MLM state for delBss: %d",
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +0530598 session->limMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800599 return;
600 }
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +0530601 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 Dhavali7090c5f2015-11-02 17:55:19 -0800604}
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
623void 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 Chouhan600c3a02016-03-01 10:33:54 +0530630 qdf_mem_set(&pMac->lim.ibssInfo, sizeof(tAniSirLimIbss), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800631} /*** 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 Sirasanagandla2f17f8d2018-10-03 17:24:20 +0530648void lim_ibss_delete_all_peers(tpAniSirGlobal pMac,
649 tpPESession psessionEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800650{
651 tLimIbssPeerNode *pCurrNode, *pTempNode;
652 tpDphHashNode pStaDs;
653 uint16_t peerIdx;
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +0530654#ifdef CONFIG_VDEV_SM
655 QDF_STATUS status;
656#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800657
658 pCurrNode = pTempNode = pMac->lim.gLimIbssPeerList;
659
660 while (pCurrNode != NULL) {
661 if (!pMac->lim.gLimNumIbssPeers) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530662 pe_err("Number of peers in the list is zero and node present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800663 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 Dhavali7090c5f2015-11-02 17:55:19 -0800676 eWNI_SME_IBSS_PEER_DEPARTED_IND,
677 psessionEntry->smeSessionId);
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +0530678 lim_del_sta(pMac, pStaDs, false, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800679 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 Chouhan600c3a02016-03-01 10:33:54 +0530696 qdf_mem_free(pCurrNode->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800697 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530698 qdf_mem_free(pCurrNode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800699 if (pMac->lim.gLimNumIbssPeers > 0) /* be paranoid */
700 pMac->lim.gLimNumIbssPeers--;
701 pCurrNode = pTempNode;
702 }
703
704 if (pMac->lim.gLimNumIbssPeers)
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530705 pe_err("Number of peers: %d in the list is non-zero",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800706 pMac->lim.gLimNumIbssPeers);
707
708 pMac->lim.gLimNumIbssPeers = 0;
709 pMac->lim.gLimIbssPeerList = NULL;
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +0530710#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 Dhavali7090c5f2015-11-02 17:55:19 -0800722}
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
733void lim_ibss_delete(tpAniSirGlobal pMac, tpPESession psessionEntry)
734{
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +0530735#ifndef CONFIG_VDEV_SM
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800736 lim_ibss_delete_all_peers(pMac, psessionEntry);
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +0530737#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800738 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 -------------------------------------------------------------*/
750static void
751lim_ibss_set_protection(tpAniSirGlobal pMac, uint8_t enable,
752 tpUpdateBeaconParams pBeaconParams,
753 tpPESession psessionEntry)
754{
755
756 if (!pMac->lim.cfgProtection.fromllb) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530757 pe_err("protection from 11b is disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800758 return;
759 }
760
761 if (enable) {
762 psessionEntry->gLim11bParams.protectionEnabled = true;
763 if (false ==
764 psessionEntry->beaconParams.
765 llbCoexist /*pMac->lim.llbCoexist */) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530766 pe_debug("=> IBSS: Enable Protection");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800767 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 Aggarwale11ec7b2017-03-24 17:40:40 +0530776 pe_debug("===> IBSS: Disable protection");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800777 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 -------------------------------------------------------------*/
793static void
794lim_ibss_update_protection_params(tpAniSirGlobal pMac,
795 tSirMacAddr peerMacAddr,
796 tLimProtStaCacheType protStaCacheType,
797 tpPESession psessionEntry)
798{
799 uint32_t i;
800
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530801 pe_debug("STA is associated Addr :");
Srinivas Girigowda8590a5f2017-03-10 14:28:37 -0800802 lim_print_mac_addr(pMac, peerMacAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800803
804 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
805 if (pMac->lim.protStaCache[i].active) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530806 pe_debug("Addr:");
Srinivas Girigowda8590a5f2017-03-10 14:28:37 -0800807 lim_print_mac_addr
808 (pMac, pMac->lim.protStaCache[i].addr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800809
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530810 if (!qdf_mem_cmp(pMac->lim.protStaCache[i].addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800811 peerMacAddr,
812 sizeof(tSirMacAddr))) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530813 pe_debug("matching cache entry at: %d already active",
Srinivas Girigowda8590a5f2017-03-10 14:28:37 -0800814 i);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800815 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 Aggarwale11ec7b2017-03-24 17:40:40 +0530826 pe_err("No space in ProtStaCache");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800827 return;
828 }
829
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530830 qdf_mem_copy(pMac->lim.protStaCache[i].addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800831 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 -------------------------------------------------------------*/
851static void
852lim_ibss_decide_protection(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
853 tpUpdateBeaconParams pBeaconParams,
854 tpPESession psessionEntry)
855{
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -0800856 enum band_info rfBand = BAND_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800857 uint32_t phyMode;
858 tLimProtStaCacheType protStaCacheType =
859 eLIM_PROT_STA_CACHE_TYPE_INVALID;
860
861 pBeaconParams->paramChangeBitmap = 0;
862
863 if (NULL == pStaDs) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530864 pe_err("pStaDs is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800865 return;
866 }
867
868 lim_get_rf_band_new(pMac, &rfBand, psessionEntry);
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -0800869 if (BAND_2G == rfBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800870 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 Johnson47d75242018-05-12 15:58:53 -0700876 * Beacon with HT IE but not ERP IE. So the absence of ERP IE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800877 * 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 Aggarwale11ec7b2017-03-24 17:40:40 +0530882 pe_err("Enable protection from 11B");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800883 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 */
913tLimIbssPeerNode *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 Johnson0301ecb2018-06-29 09:36:23 -0700940QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800941lim_ibss_sta_add(tpAniSirGlobal pMac, void *pBody, tpPESession psessionEntry)
942{
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700943 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800944 tpDphHashNode pStaDs;
945 tLimIbssPeerNode *pPeerNode;
946 tLimMlmStates prevState;
947 tSirMacAddr *pPeerAddr = (tSirMacAddr *) pBody;
948 tUpdateBeaconParams beaconParams;
949
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530950 qdf_mem_set((uint8_t *) &beaconParams, sizeof(tUpdateBeaconParams), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800951
952 if (pBody == 0) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530953 pe_err("Invalid IBSS AddSta");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700954 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800955 }
956
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530957 pe_debug("Rx Add-Ibss-Sta for MAC:");
Srinivas Girigowda8590a5f2017-03-10 14:28:37 -0800958 lim_print_mac_addr(pMac, *pPeerAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800959
960 pPeerNode = ibss_peer_find(pMac, *pPeerAddr);
961 if (NULL != pPeerNode) {
962 retCode =
963 ibss_dph_entry_add(pMac, *pPeerAddr, &pStaDs,
964 psessionEntry);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700965 if (QDF_STATUS_SUCCESS == retCode) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800966 prevState = pStaDs->mlmStaContext.mlmState;
967 pStaDs->erpEnabled = pPeerNode->erpIePresent;
968
969 ibss_sta_info_update(pMac, pStaDs, pPeerNode,
970 psessionEntry);
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530971 pe_debug("initiating ADD STA for the IBSS peer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800972 retCode =
973 lim_add_sta(pMac, pStaDs, false, psessionEntry);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700974 if (retCode != QDF_STATUS_SUCCESS) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530975 pe_err("ibss-sta-add failed (reason %x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800976 retCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800977 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 Thilagaraj1ee76002018-09-18 21:38:51 +0530985 MLME_FORCE_POLICY_PROTECTION_DISABLE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800986 lim_ibss_decide_protection(pMac, pStaDs,
987 &beaconParams,
988 psessionEntry);
989
990 if (beaconParams.paramChangeBitmap) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530991 pe_debug("---> Update Beacon Params");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800992 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 Aggarwale11ec7b2017-03-24 17:40:40 +05301001 pe_err("hashTblAdd failed reason: %x", retCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001002 lim_print_mac_addr(pMac, *pPeerAddr, LOGE);
1003 }
1004 } else {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001005 retCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001006 }
1007
1008 return retCode;
1009}
Abhishek Singh3df76612017-05-16 14:05:32 +05301010
Abhishek Singh79e77502015-12-30 17:11:49 +05301011/**
Abhishek Singh3df76612017-05-16 14:05:32 +05301012 * lim_ibss_search_and_delete_peer()- to cleanup the IBSS
1013 * peer from lim ibss peer list
Abhishek Singh79e77502015-12-30 17:11:49 +05301014 *
1015 * @mac_ptr: Pointer to Global MAC structure
1016 * @session_entry: Session entry
1017 * @mac_addr: Mac Address of the IBSS peer
1018 *
Abhishek Singh3df76612017-05-16 14:05:32 +05301019 * This function is called to cleanup the IBSS peer from
1020 * lim ibss peer list
Abhishek Singh79e77502015-12-30 17:11:49 +05301021 *
1022 * Return: None
1023 *
1024 */
1025static void
Abhishek Singh3df76612017-05-16 14:05:32 +05301026lim_ibss_search_and_delete_peer(tpAniSirGlobal mac_ctx,
Abhishek Singh79e77502015-12-30 17:11:49 +05301027 tpPESession session_entry, tSirMacAddr mac_addr)
1028{
1029 tLimIbssPeerNode *temp_node, *prev_node;
1030 tLimIbssPeerNode *temp_next_node = NULL;
Abhishek Singh79e77502015-12-30 17:11:49 +05301031
Abhishek Singh3df76612017-05-16 14:05:32 +05301032 prev_node = temp_node = mac_ctx->lim.gLimIbssPeerList;
Abhishek Singh79e77502015-12-30 17:11:49 +05301033
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301034 pe_debug(" PEER ADDR :" MAC_ADDRESS_STR,
Abhishek Singh79e77502015-12-30 17:11:49 +05301035 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 Singh3df76612017-05-16 14:05:32 +05301045 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 Singh79e77502015-12-30 17:11:49 +05301055
Abhishek Singh3df76612017-05-16 14:05:32 +05301056 qdf_mem_free(temp_node);
1057 mac_ctx->lim.gLimNumIbssPeers--;
Abhishek Singh79e77502015-12-30 17:11:49 +05301058
Abhishek Singh3df76612017-05-16 14:05:32 +05301059 temp_node = temp_next_node;
1060 break;
Abhishek Singh79e77502015-12-30 17:11:49 +05301061 }
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 Singh3df76612017-05-16 14:05:32 +05301069 if (0 == mac_ctx->lim.gLimNumIbssPeers) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301070 pe_debug("Last STA from IBSS walked out");
Abhishek Singh79e77502015-12-30 17:11:49 +05301071 session_entry->limIbssActive = false;
1072 }
1073}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001074
Abhishek Singh3df76612017-05-16 14:05:32 +05301075/**
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 */
1087static void
1088lim_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
1127void 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 Singh3df76612017-05-16 14:05:32 +05301171 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
1177skip_event:
1178 qdf_mem_free(del_sta_params);
1179 lim_msg->bodyptr = NULL;
1180}
1181
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001182/* handle the response from HAL for an ADD STA request */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001183QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001184lim_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 Aggarwale11ec7b2017-03-24 17:40:40 +05301192 pe_err("IBSS: ADD_STA_RSP with no body!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001193 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001194 }
1195
1196 pStaDs =
1197 dph_lookup_hash_entry(pMac, pAddStaParams->staMac, &peerIdx,
1198 &psessionEntry->dph.dphHashTable);
1199 if (pStaDs == NULL) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301200 pe_err("IBSS: ADD_STA_RSP for unknown MAC addr: "MAC_ADDRESS_STR,
Abhishek Singh79e77502015-12-30 17:11:49 +05301201 MAC_ADDR_ARRAY(pAddStaParams->staMac));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301202 qdf_mem_free(pAddStaParams);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001203 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001204 }
1205
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301206 if (pAddStaParams->status != QDF_STATUS_SUCCESS) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301207 pe_err("IBSS: ADD_STA_RSP error: %x for MAC:"MAC_ADDRESS_STR,
Abhishek Singh79e77502015-12-30 17:11:49 +05301208 pAddStaParams->status,
1209 MAC_ADDR_ARRAY(pAddStaParams->staMac));
Abhishek Singh3df76612017-05-16 14:05:32 +05301210 lim_ibss_delete_peer(pMac,
Abhishek Singh79e77502015-12-30 17:11:49 +05301211 psessionEntry, pAddStaParams->staMac);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301212 qdf_mem_free(pAddStaParams);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001213 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001214 }
1215
1216 pStaDs->bssId = pAddStaParams->bssIdx;
1217 pStaDs->staIndex = pAddStaParams->staIdx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001218 pStaDs->valid = 1;
1219 pStaDs->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
1220
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301221 pe_debug("IBSS: sending IBSS_NEW_PEER msg to SME!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001222
1223 ibss_status_chg_notify(pMac, pAddStaParams->staMac,
Jeff Johnson582a3382018-03-05 11:58:47 -08001224 pStaDs->staIndex,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001225 eWNI_SME_IBSS_NEW_PEER_IND,
1226 psessionEntry->smeSessionId);
1227
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301228 qdf_mem_free(pAddStaParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001229
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001230 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001231}
1232
1233void lim_ibss_del_bss_rsp_when_coalescing(tpAniSirGlobal pMac, void *msg,
1234 tpPESession psessionEntry)
1235{
1236 tpDeleteBssParams pDelBss = (tpDeleteBssParams) msg;
1237
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301238 pe_debug("IBSS: DEL_BSS_RSP Rcvd during coalescing!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001239
1240 if (pDelBss == NULL) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301241 pe_err("IBSS: DEL_BSS_RSP(coalesce) with no body!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001242 goto end;
1243 }
1244
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301245 if (pDelBss->status != QDF_STATUS_SUCCESS) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301246 pe_err("IBSS: DEL_BSS_RSP(coalesce) error: %x Bss: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001247 pDelBss->status, pDelBss->bssIdx);
1248 goto end;
1249 }
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +05301250
1251#ifndef CONFIG_VDEV_SM
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001252 /* Delete peer entries. */
1253 lim_ibss_delete_all_peers(pMac, psessionEntry);
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +05301254#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001255 /* add the new bss */
1256 ibss_bss_add(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001257end:
1258 if (pDelBss != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301259 qdf_mem_free(pDelBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001260}
1261
1262void 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 Aggarwale11ec7b2017-03-24 17:40:40 +05301275 pe_err("Unable to handle AddBssRspWhenCoalescing (no cached BSS info)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001276 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 Chouhan600c3a02016-03-01 10:33:54 +05301282 qdf_mem_set((void *)&newBssInfo, sizeof(newBssInfo), 0);
1283 qdf_mem_copy(newBssInfo.bssId.bytes, pHdr->bssId, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001284 newBssInfo.channelNumber = (tSirMacChanNum) pAddBss->currentOperChannel;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301285 qdf_mem_copy((uint8_t *) &newBssInfo.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001286 (uint8_t *) &pBeacon->ssId, pBeacon->ssId.length + 1);
1287
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301288 pe_debug("Sending JOINED_NEW_BSS notification to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001289
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 Sirasanagandla2f17f8d2018-10-03 17:24:20 +05301295 lim_send_beacon(pMac, pSessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001296 }
1297
1298end:
1299 ibss_coalesce_free(pMac);
1300}
1301
1302void 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 Aggarwale11ec7b2017-03-24 17:40:40 +05301310 pe_err("IBSS: DEL_BSS_RSP with no body!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001311 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 Aggarwale11ec7b2017-03-24 17:40:40 +05301317 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001318 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 Chouhanfb54ab02016-02-18 18:00:46 +05301333 if (pDelBss->status != QDF_STATUS_SUCCESS) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301334 pe_err("IBSS: DEL_BSS_RSP error: %x Bss: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001335 pDelBss->status, pDelBss->bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001336 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 Johnson0301ecb2018-06-29 09:36:23 -07001342 NULL) != QDF_STATUS_SUCCESS) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301343 pe_err("IBSS: DEL_BSS_RSP setLinkState failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001344 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
1366end:
1367 if (pDelBss != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301368 qdf_mem_free(pDelBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001369 /* 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 Dhavali7090c5f2015-11-02 17:55:19 -08001379/**
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 Johnson0301ecb2018-06-29 09:36:23 -07001399QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001400lim_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 Chouhan600c3a02016-03-01 10:33:54 +05301412 qdf_mem_set((uint8_t *) &beaconParams, sizeof(tUpdateBeaconParams), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001413
1414 sir_copy_mac_addr(currentBssId, psessionEntry->bssId);
1415
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301416 pe_debug("Current BSSID :" MAC_ADDRESS_STR " Received BSSID :"
1417 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(currentBssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001418 MAC_ADDR_ARRAY(pHdr->bssId));
1419
1420 /* Check for IBSS Coalescing only if Beacon is from different BSS */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301421 if (qdf_mem_cmp(currentBssId, pHdr->bssId, sizeof(tSirMacAddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001422 && 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 Singh3df76612017-05-16 14:05:32 +05301435 lim_ibss_delete_peer(pMac, psessionEntry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001436 pHdr->sa);
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301437 pe_warn("Peer attempting to reconnect before HB timeout, deleted");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001438 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001439 }
1440
1441 if (!fTsfLater) { /* No Coalescing happened. */
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301442 pe_warn("No Coalescing happened");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001443 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001444 }
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 Dhavali7090c5f2015-11-02 17:55:19 -08001451 ibss_coalesce_save(pMac, pHdr, pBeacon);
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301452 pe_debug("IBSS Coalescing happened Delete BSSID :" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001453 MAC_ADDR_ARRAY(currentBssId));
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +05301454#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 Dhavali7090c5f2015-11-02 17:55:19 -08001460 ibss_bss_delete(pMac, psessionEntry);
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +05301461#endif
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001462 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001463 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301464 if (qdf_mem_cmp
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001465 (currentBssId, pHdr->bssId, sizeof(tSirMacAddr)))
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001466 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001467 }
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 Johnson0301ecb2018-06-29 09:36:23 -07001474 QDF_STATUS retCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001475
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 Aggarwale11ec7b2017-03-24 17:40:40 +05301487 pe_debug("**** MAX STA LIMIT HAS REACHED ****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001488 }
1489 pMac->lim.ibss_retry_cnt++;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001490 return QDF_STATUS_E_NOSPC;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001491 }
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301492 pe_debug("IBSS Peer node does not exist, adding it");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001493 frameLen =
1494 sizeof(tLimIbssPeerNode) + ieLen - sizeof(uint32_t);
1495
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301496 pPeerNode = qdf_mem_malloc((uint16_t) frameLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001497 if (NULL == pPeerNode) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301498 pe_err("alloc fail %d bytes storing IBSS peer info",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001499 frameLen);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001500 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001501 }
1502
1503 pPeerNode->beacon = NULL;
1504 pPeerNode->beaconLen = 0;
1505
1506 ibss_peer_collect(pMac, pBeacon, pHdr, pPeerNode,
1507 psessionEntry);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301508 pPeerNode->beacon = qdf_mem_malloc(ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001509 if (NULL == pPeerNode->beacon) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301510 pe_err("Unable to allocate memory to store beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001511 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301512 qdf_mem_copy(pPeerNode->beacon, pIEs, ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001513 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 Aggarwale11ec7b2017-03-24 17:40:40 +05301522 pe_warn("DPH Node present for just learned peer");
Srinivas Girigowda8590a5f2017-03-10 14:28:37 -08001523 lim_print_mac_addr(pMac, pPeerNode->peerMacAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001524 ibss_sta_info_update(pMac, pStaDs, pPeerNode,
1525 psessionEntry);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001526 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001527 }
1528 retCode =
1529 lim_ibss_sta_add(pMac, pPeerNode->peerMacAddr, psessionEntry);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001530 if (retCode != QDF_STATUS_SUCCESS) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301531 pe_err("lim-ibss-sta-add failed reason: %x", retCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001532 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 Thilagaraj1ee76002018-09-18 21:38:51 +05301540 MLME_FORCE_POLICY_PROTECTION_DISABLE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001541 lim_ibss_decide_protection(pMac, pStaDs, &beaconParams,
1542 psessionEntry);
1543
1544 if (beaconParams.paramChangeBitmap) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301545 pe_err("beaconParams.paramChangeBitmap=1 ---> Update Beacon Params");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001546 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 Johnson0301ecb2018-06-29 09:36:23 -07001554 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001555
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 Aggarwale11ec7b2017-03-24 17:40:40 +05301561 pe_warn("Partner joined our IBSS, Sending IBSS_ACTIVE Notification to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001562 psessionEntry->limIbssActive = true;
1563 lim_send_sme_wm_status_change_ntf(pMac, eSIR_SME_IBSS_ACTIVE, NULL, 0,
1564 psessionEntry->smeSessionId);
1565 }
1566
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001567 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001568} /*** 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 */
1580void 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 Dhavali7090c5f2015-11-02 17:55:19 -08001588
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 Aggarwale11ec7b2017-03-24 17:40:40 +05301618 pe_err("Heartbeat fail: %d thres: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001619 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 Dhavali7090c5f2015-11-02 17:55:19 -08001627
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 Dhavali7090c5f2015-11-02 17:55:19 -08001637 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 Guptac797b622016-10-18 12:05:44 +05301647 if (tempnode->beacon)
1648 qdf_mem_free(tempnode->beacon);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301649 qdf_mem_free(tempnode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001650 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 Aggarwale11ec7b2017-03-24 17:40:40 +05301676 pe_warn("Heartbeat Failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001677 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 Aggarwale11ec7b2017-03-24 17:40:40 +05301685 pe_warn("Alone in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001686 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 */
1707void 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 Yeturua48bc412017-11-17 15:33:35 -08001714 enum band_info rfband = BAND_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001715 uint32_t i;
1716
1717 if (NULL == stads)
1718 return;
1719
1720 lim_get_rf_band_new(mac_ctx, &rfband, session);
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001721 if (BAND_2G != rfband)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001722 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 Aggarwale11ec7b2017-03-24 17:40:40 +05301729 pe_err("%d A legacy STA is disassociated Addr is",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001730 session->gLim11bParams.numSta);
1731 lim_print_mac_addr(mac_ctx, stads->staAddr, LOGE);
1732 if (session->gLim11bParams.numSta == 0) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301733 pe_err("No 11B STA exists. Disable protection");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001734 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 Chouhan600c3a02016-03-01 10:33:54 +05301741 if (!qdf_mem_cmp(mac_ctx->lim.protStaCache[i].addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001742 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 -----------------------------------------------------------------*/
1761static 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 Singh3df76612017-05-16 14:05:32 +05301771 lim_ibss_delete_peer(pMac, psessionEntry,
Srinivas Girigowda01d1c3c2015-11-25 16:54:41 -08001772 peerInactivityInd->peer_addr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001773}
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 -------------------------------------------------------------*/
1783void 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}