blob: 370c19f87e5c9784733665af1221b886288a88f3 [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"
Vignesh Viswanathanecd4de72018-11-22 13:02:20 +053034#include "cfg_ucfg_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080035
36/**
37 * ibss_peer_find
38 *
39 ***FUNCTION:
40 * This function is called while adding a context at
41 * DPH & Polaris for a peer in IBSS.
42 * If peer is found in the list, capabilities from the
43 * returned BSS description are used at DPH node & Polaris.
44 *
45 ***LOGIC:
46 *
47 ***ASSUMPTIONS:
48 *
49 ***NOTE:
50 *
51 * @param macAddr - MAC address of the peer
52 *
53 * @return Pointer to peer node if found, else NULL
54 */
55
Jeff Johnson9320c1e2018-12-02 13:09:20 -080056static tLimIbssPeerNode *ibss_peer_find(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080057 tSirMacAddr macAddr)
58{
Jeff Johnsonb65d2562018-11-21 21:54:36 -080059 tLimIbssPeerNode *pTempNode = mac->lim.gLimIbssPeerList;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080060
61 while (pTempNode != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053062 if (!qdf_mem_cmp((uint8_t *) macAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080063 (uint8_t *) &pTempNode->peerMacAddr,
64 sizeof(tSirMacAddr)))
65 break;
66 pTempNode = pTempNode->next;
67 }
68 return pTempNode;
69} /*** end ibss_peer_find() ***/
70
71/**
72 * ibss_peer_add
73 *
74 ***FUNCTION:
75 * This is called on a STA in IBSS upon receiving Beacon/
76 * Probe Response from a peer.
77 *
78 ***LOGIC:
79 * Node is always added to the front of the list
80 *
81 ***ASSUMPTIONS:
82 *
83 ***NOTE:
84 *
Jeff Johnsonb65d2562018-11-21 21:54:36 -080085 * @param mac - Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080086 * @param pPeerNode - Pointer to peer node to be added to the list.
87 *
88 * @return None
89 */
90
Jeff Johnson0301ecb2018-06-29 09:36:23 -070091static QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -080092ibss_peer_add(struct mac_context *mac, tLimIbssPeerNode *pPeerNode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080093{
94#ifdef ANI_SIR_IBSS_PEER_CACHING
Jeff Johnsonb65d2562018-11-21 21:54:36 -080095 uint32_t numIbssPeers = (2 * mac->lim.maxStation);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080096
Jeff Johnsonb65d2562018-11-21 21:54:36 -080097 if (mac->lim.gLimNumIbssPeers >= numIbssPeers) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080098 /**
99 * Reached max number of peers to be maintained.
100 * Delete last entry & add new entry at the beginning.
101 */
102 tLimIbssPeerNode *pTemp, *pPrev;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -0700103
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800104 pTemp = pPrev = mac->lim.gLimIbssPeerList;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800105 while (pTemp->next != NULL) {
106 pPrev = pTemp;
107 pTemp = pTemp->next;
108 }
109 if (pTemp->beacon) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530110 qdf_mem_free(pTemp->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800111 }
112
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530113 qdf_mem_free(pTemp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800114 pPrev->next = NULL;
115 } else
116#endif
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800117 mac->lim.gLimNumIbssPeers++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800118
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800119 pPeerNode->next = mac->lim.gLimIbssPeerList;
120 mac->lim.gLimIbssPeerList = pPeerNode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800121
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700122 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800123
124} /*** end limAddIbssPeerToList() ***/
125
126/**
127 * ibss_peer_collect
128 *
129 ***FUNCTION:
130 * This is called to collect IBSS peer information
131 * from received Beacon/Probe Response frame from it.
132 *
133 ***LOGIC:
134 *
135 ***ASSUMPTIONS:
136 *
137 ***NOTE:
138 *
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800139 * @param mac - Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800140 * @param pBeacon - Parsed Beacon Frame structure
141 * @param pBD - Pointer to received BD
Jeff Johnson8aebe612018-12-01 10:57:50 -0800142 * @param peer - Pointer to IBSS peer node
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800143 *
144 * @return None
145 */
146
147static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800148ibss_peer_collect(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800149 tpSchBeaconStruct pBeacon,
150 tpSirMacMgmtHdr pHdr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800151 tLimIbssPeerNode *peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800152{
Jeff Johnson8aebe612018-12-01 10:57:50 -0800153 qdf_mem_copy(peer->peerMacAddr, pHdr->sa, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800154
Jeff Johnson8aebe612018-12-01 10:57:50 -0800155 peer->capabilityInfo = pBeacon->capabilityInfo;
156 peer->extendedRatesPresent = pBeacon->extendedRatesPresent;
157 peer->edcaPresent = pBeacon->edcaPresent;
158 peer->wmeEdcaPresent = pBeacon->wmeEdcaPresent;
159 peer->wmeInfoPresent = pBeacon->wmeInfoPresent;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800160
161 if (pBeacon->IBSSParams.present) {
Jeff Johnson8aebe612018-12-01 10:57:50 -0800162 peer->atimIePresent = pBeacon->IBSSParams.present;
163 peer->peerAtimWindowLength = pBeacon->IBSSParams.atim;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800164 }
165
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800166 if (IS_DOT11_MODE_HT(pe_session->dot11mode) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800167 (pBeacon->HTCaps.present)) {
Jeff Johnson8aebe612018-12-01 10:57:50 -0800168 peer->htCapable = pBeacon->HTCaps.present;
169 qdf_mem_copy((uint8_t *) peer->supportedMCSSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800170 (uint8_t *) pBeacon->HTCaps.supportedMCSSet,
Jeff Johnson8aebe612018-12-01 10:57:50 -0800171 sizeof(peer->supportedMCSSet));
172 peer->htGreenfield = (uint8_t) pBeacon->HTCaps.greenField;
173 peer->htSupportedChannelWidthSet =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800174 (uint8_t) pBeacon->HTCaps.supportedChannelWidthSet;
Jeff Johnson8aebe612018-12-01 10:57:50 -0800175 peer->htMIMOPSState =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800176 (tSirMacHTMIMOPowerSaveState) pBeacon->HTCaps.mimoPowerSave;
Jeff Johnson8aebe612018-12-01 10:57:50 -0800177 peer->htMaxAmsduLength =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800178 (uint8_t) pBeacon->HTCaps.maximalAMSDUsize;
Jeff Johnson8aebe612018-12-01 10:57:50 -0800179 peer->htAMpduDensity = pBeacon->HTCaps.mpduDensity;
180 peer->htDsssCckRate40MHzSupport =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800181 (uint8_t) pBeacon->HTCaps.dsssCckMode40MHz;
Jeff Johnson8aebe612018-12-01 10:57:50 -0800182 peer->htShortGI20Mhz = (uint8_t) pBeacon->HTCaps.shortGI20MHz;
183 peer->htShortGI40Mhz = (uint8_t) pBeacon->HTCaps.shortGI40MHz;
184 peer->htMaxRxAMpduFactor = pBeacon->HTCaps.maxRxAMPDUFactor;
185 peer->htSecondaryChannelOffset =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800186 pBeacon->HTInfo.secondaryChannelOffset;
Jeff Johnson8aebe612018-12-01 10:57:50 -0800187 peer->htLdpcCapable = (uint8_t) pBeacon->HTCaps.advCodingCap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800188 }
189
190 /* Collect peer VHT capabilities based on the received beacon from the peer */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800191 if (pBeacon->VHTCaps.present) {
Jeff Johnson8aebe612018-12-01 10:57:50 -0800192 peer->vhtSupportedChannelWidthSet =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800193 pBeacon->VHTOperation.chanWidth;
Jeff Johnson8aebe612018-12-01 10:57:50 -0800194 peer->vhtCapable = pBeacon->VHTCaps.present;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800195
196 /* Collect VHT capabilities from beacon */
Jeff Johnson8aebe612018-12-01 10:57:50 -0800197 qdf_mem_copy((uint8_t *) &peer->VHTCaps,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800198 (uint8_t *) &pBeacon->VHTCaps,
199 sizeof(tDot11fIEVHTCaps));
200 }
Jeff Johnson8aebe612018-12-01 10:57:50 -0800201 peer->erpIePresent = pBeacon->erpPresent;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800202
Jeff Johnson8aebe612018-12-01 10:57:50 -0800203 qdf_mem_copy((uint8_t *) &peer->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800204 (uint8_t *) &pBeacon->supportedRates,
205 pBeacon->supportedRates.numRates + 1);
Jeff Johnson8aebe612018-12-01 10:57:50 -0800206 if (peer->extendedRatesPresent)
207 qdf_mem_copy((uint8_t *) &peer->extendedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800208 (uint8_t *) &pBeacon->extendedRates,
209 pBeacon->extendedRates.numRates + 1);
210 else
Jeff Johnson8aebe612018-12-01 10:57:50 -0800211 peer->extendedRates.numRates = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800212
Jeff Johnson8aebe612018-12-01 10:57:50 -0800213 peer->next = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800214} /*** end ibss_peer_collect() ***/
215
216/* handle change in peer qos/wme capabilities */
217static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800218ibss_sta_caps_update(struct mac_context *mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800219 tLimIbssPeerNode *pPeerNode, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800220{
221 uint16_t peerIdx;
222 tpDphHashNode pStaDs;
223
224 pPeerNode->beaconHBCount++; /* Update beacon count. */
225
226 /* if the peer node exists, update its qos capabilities */
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800227 pStaDs = dph_lookup_hash_entry(mac, pPeerNode->peerMacAddr, &peerIdx,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800228 &pe_session->dph.dphHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800229 if (pStaDs == NULL)
230 return;
231
232 /* Update HT Capabilities */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800233 if (IS_DOT11_MODE_HT(pe_session->dot11mode)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800234 pStaDs->mlmStaContext.htCapability = pPeerNode->htCapable;
235 if (pPeerNode->htCapable) {
236 pStaDs->htGreenfield = pPeerNode->htGreenfield;
237 pStaDs->htSupportedChannelWidthSet =
238 pPeerNode->htSupportedChannelWidthSet;
Abhishek Singh10a00262015-10-16 16:26:14 +0530239 pStaDs->htSecondaryChannelOffset =
240 pPeerNode->htSecondaryChannelOffset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800241 pStaDs->htMIMOPSState = pPeerNode->htMIMOPSState;
242 pStaDs->htMaxAmsduLength = pPeerNode->htMaxAmsduLength;
243 pStaDs->htAMpduDensity = pPeerNode->htAMpduDensity;
244 pStaDs->htDsssCckRate40MHzSupport =
245 pPeerNode->htDsssCckRate40MHzSupport;
246 pStaDs->htShortGI20Mhz = pPeerNode->htShortGI20Mhz;
247 pStaDs->htShortGI40Mhz = pPeerNode->htShortGI40Mhz;
248 pStaDs->htMaxRxAMpduFactor =
249 pPeerNode->htMaxRxAMpduFactor;
250 /* In the future, may need to check for "delayedBA" */
251 /* For now, it is IMMEDIATE BA only on ALL TID's */
252 pStaDs->baPolicyFlag = 0xFF;
253 pStaDs->htLdpcCapable = pPeerNode->htLdpcCapable;
254 }
255 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800256 if (IS_DOT11_MODE_VHT(pe_session->dot11mode)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800257 pStaDs->mlmStaContext.vhtCapability = pPeerNode->vhtCapable;
258 if (pPeerNode->vhtCapable) {
259 pStaDs->vhtSupportedChannelWidthSet =
260 pPeerNode->vhtSupportedChannelWidthSet;
261
262 /* If in 11AC mode and if session requires 11AC mode, consider peer's */
263 /* max AMPDU length factor */
264 pStaDs->htMaxRxAMpduFactor =
265 pPeerNode->VHTCaps.maxAMPDULenExp;
266 pStaDs->vhtLdpcCapable =
267 (uint8_t) pPeerNode->VHTCaps.ldpcCodingCap;
268 }
269 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800270 /* peer is 11e capable but is not 11e enabled yet */
271 /* some STA's when joining Airgo IBSS, assert qos capability even when */
Jeff Johnsona642ead2018-05-11 09:26:13 -0700272 /* they don't support qos. however, they do not include the edca parameter */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800273 /* set. so let's check for edcaParam in addition to the qos capability */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800274 if (pPeerNode->capabilityInfo.qos && (pe_session->limQosEnabled)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800275 && pPeerNode->edcaPresent) {
276 pStaDs->qosMode = 1;
277 pStaDs->wmeEnabled = 0;
278 if (!pStaDs->lleEnabled) {
279 pStaDs->lleEnabled = 1;
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800280 /* dphSetACM(mac, pStaDs); */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800281 }
282 return;
283 }
284 /* peer is not 11e capable now but was 11e enabled earlier */
285 else if (pStaDs->lleEnabled) {
286 pStaDs->qosMode = 0;
287 pStaDs->lleEnabled = 0;
288 }
289 /* peer is wme capable but is not wme enabled yet */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800290 if (pPeerNode->wmeInfoPresent && pe_session->limWmeEnabled) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800291 pStaDs->qosMode = 1;
292 pStaDs->lleEnabled = 0;
293 if (!pStaDs->wmeEnabled) {
294 pStaDs->wmeEnabled = 1;
295 }
296 return;
297 }
298 /* When the peer device supports EDCA parameters, then we were not
299 considering. Added this code when we saw that one of the Peer Device
300 was advertising WMM param where we were not honouring that. CR# 210756
301 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800302 if (pPeerNode->wmeEdcaPresent && pe_session->limWmeEnabled) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800303 pStaDs->qosMode = 1;
304 pStaDs->lleEnabled = 0;
305 if (!pStaDs->wmeEnabled) {
306 pStaDs->wmeEnabled = 1;
307 }
308 return;
309 }
310 /* peer is not wme capable now but was wme enabled earlier */
311 else if (pStaDs->wmeEnabled) {
312 pStaDs->qosMode = 0;
313 pStaDs->wmeEnabled = 0;
314 }
315
316}
317
318static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800319ibss_sta_rates_update(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800320 tpDphHashNode pStaDs,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800321 tLimIbssPeerNode *peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800322{
Jeff Johnson8aebe612018-12-01 10:57:50 -0800323 lim_populate_matching_rate_set(mac, pStaDs, &peer->supportedRates,
324 &peer->extendedRates,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800325 peer->supportedMCSSet, pe_session,
Jeff Johnson8aebe612018-12-01 10:57:50 -0800326 &peer->VHTCaps, NULL);
327 pStaDs->mlmStaContext.capabilityInfo = peer->capabilityInfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800328} /*** end ibss_sta_info_update() ***/
329
330/**
331 * ibss_sta_info_update
332 *
333 ***FUNCTION:
334 * This is called to program both SW & Polaris context
335 * for peer in IBSS.
336 *
337 ***LOGIC:
338 *
339 ***ASSUMPTIONS:
340 *
341 ***NOTE:
342 *
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800343 * @param mac - Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800344 * @param pStaDs - Pointer to DPH node
Jeff Johnson8aebe612018-12-01 10:57:50 -0800345 * @param peer - Pointer to IBSS peer node
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800346 *
347 * @return None
348 */
349
350static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800351ibss_sta_info_update(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800352 tpDphHashNode pStaDs,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800353 tLimIbssPeerNode *peer, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800354{
355 pStaDs->staType = STA_ENTRY_PEER;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800356 ibss_sta_caps_update(mac, peer, pe_session);
357 ibss_sta_rates_update(mac, pStaDs, peer, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800358} /*** end ibss_sta_info_update() ***/
359
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800360static void ibss_coalesce_free(struct mac_context *mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800361{
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800362 if (mac->lim.ibssInfo.pHdr != NULL)
363 qdf_mem_free(mac->lim.ibssInfo.pHdr);
364 if (mac->lim.ibssInfo.pBeacon != NULL)
365 qdf_mem_free(mac->lim.ibssInfo.pBeacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800366
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800367 mac->lim.ibssInfo.pHdr = NULL;
368 mac->lim.ibssInfo.pBeacon = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800369}
370
371/*
372 * save the beacon params for use when adding the bss
373 */
374static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800375ibss_coalesce_save(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800376 tpSirMacMgmtHdr pHdr, tpSchBeaconStruct pBeacon)
377{
378 /* get rid of any saved info */
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800379 ibss_coalesce_free(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800380
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800381 mac->lim.ibssInfo.pHdr = qdf_mem_malloc(sizeof(*pHdr));
382 if (!mac->lim.ibssInfo.pHdr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800383 return;
Arif Hussainf5b6c412018-10-10 19:41:09 -0700384
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800385 mac->lim.ibssInfo.pBeacon = qdf_mem_malloc(sizeof(*pBeacon));
386 if (!mac->lim.ibssInfo.pBeacon) {
387 ibss_coalesce_free(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800388 return;
389 }
390
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800391 qdf_mem_copy(mac->lim.ibssInfo.pHdr, pHdr, sizeof(*pHdr));
392 qdf_mem_copy(mac->lim.ibssInfo.pBeacon, pBeacon, sizeof(*pBeacon));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800393}
394
395/*
396 * tries to add a new entry to dph hash node
397 * if necessary, an existing entry is eliminated
398 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700399static QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800400ibss_dph_entry_add(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800401 tSirMacAddr peerAddr,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800402 tpDphHashNode *ppSta, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800403{
404 uint16_t peerIdx;
405 tpDphHashNode pStaDs;
406
407 *ppSta = NULL;
408
409 pStaDs =
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800410 dph_lookup_hash_entry(mac, peerAddr, &peerIdx,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800411 &pe_session->dph.dphHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800412 if (pStaDs != NULL) {
413 /* Trying to add context for already existing STA in IBSS */
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530414 pe_err("STA exists already");
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800415 lim_print_mac_addr(mac, peerAddr, LOGE);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700416 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800417 }
418
419 /**
420 * Assign an AID, delete context existing with that
421 * AID and then add an entry to hash table maintained
422 * by DPH module.
423 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800424 peerIdx = lim_assign_peer_idx(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800425
426 pStaDs =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800427 dph_get_hash_entry(mac, peerIdx, &pe_session->dph.dphHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800428 if (pStaDs) {
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800429 (void)lim_del_sta(mac, pStaDs, false /*asynchronous */,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800430 pe_session);
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800431 lim_delete_dph_hash_entry(mac, pStaDs->staAddr, peerIdx,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800432 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800433 }
434
435 pStaDs =
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800436 dph_add_hash_entry(mac, peerAddr, peerIdx,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800437 &pe_session->dph.dphHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800438 if (pStaDs == NULL) {
439 /* Could not add hash table entry */
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530440 pe_err("could not add hash entry at DPH for peerIdx/aid: %d MACaddr:",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800441 peerIdx);
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800442 lim_print_mac_addr(mac, peerAddr, LOGE);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700443 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800444 }
445
446 *ppSta = pStaDs;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700447 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800448}
449
450/* send a status change notification */
451static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800452ibss_status_chg_notify(struct mac_context *mac, tSirMacAddr peerAddr,
Jeff Johnson582a3382018-03-05 11:58:47 -0800453 uint16_t staIndex, uint16_t status, uint8_t sessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800454{
455
456 tLimIbssPeerNode *peerNode;
457 uint8_t *beacon = NULL;
458 uint16_t bcnLen = 0;
459
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800460 peerNode = ibss_peer_find(mac, peerAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800461 if (peerNode != NULL) {
462 if (peerNode->beacon == NULL)
463 peerNode->beaconLen = 0;
464 beacon = peerNode->beacon;
465 bcnLen = peerNode->beaconLen;
466 peerNode->beacon = NULL;
467 peerNode->beaconLen = 0;
468 }
469
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800470 lim_send_sme_ibss_peer_ind(mac, peerAddr, staIndex,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800471 beacon, bcnLen, status, sessionId);
472
473 if (beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530474 qdf_mem_free(beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800475 }
476}
477
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800478void ibss_bss_add(struct mac_context *mac, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800479{
480 tLimMlmStartReq mlmStartReq;
481 uint32_t cfg;
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800482 tpSirMacMgmtHdr pHdr = (tpSirMacMgmtHdr) mac->lim.ibssInfo.pHdr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800483 tpSchBeaconStruct pBeacon =
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800484 (tpSchBeaconStruct) mac->lim.ibssInfo.pBeacon;
Karthik Kantamnenie3bbd7f2018-09-19 20:27:32 +0530485 qdf_size_t num_ext_rates = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800486
487 if ((pHdr == NULL) || (pBeacon == NULL)) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530488 pe_err("Unable to add BSS (no cached BSS info)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800489 return;
490 }
491
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800492 qdf_mem_copy(pe_session->bssId, pHdr->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800493
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800494 sir_copy_mac_addr(pHdr->bssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800495
496 /* Copy beacon interval from sessionTable */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800497 cfg = pe_session->beaconParams.beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800498 if (cfg != pBeacon->beaconInterval)
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800499 pe_session->beaconParams.beaconInterval =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800500 pBeacon->beaconInterval;
501
502 /* This function ibss_bss_add (and hence the below code) is only called during ibss coalescing. We need to
503 * 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 -0700504 * 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 -0800505 * to peer's short slot using code below.
506 */
507 /* If cfg is already set to current peer's capability then no need to set it again */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800508 if (pe_session->shortSlotTimeSupported !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800509 pBeacon->capabilityInfo.shortSlotTime) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800510 pe_session->shortSlotTimeSupported =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800511 pBeacon->capabilityInfo.shortSlotTime;
512 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800513 qdf_mem_copy((uint8_t *) &pe_session->pLimStartBssReq->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800514 operationalRateSet, (uint8_t *) &pBeacon->supportedRates,
515 pBeacon->supportedRates.numRates);
516
517 /**
518 * WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET CFG needs to be reset, when
519 * there is no extended rate IE present in beacon. This is especially important when
520 * supportedRateSet IE contains all the extended rates as well and STA decides to coalesce.
521 * In this IBSS coalescing scenario LIM will tear down the BSS and Add a new one. So LIM needs to
522 * reset this CFG, just in case CSR originally had set this CFG when IBSS was started from the local profile.
523 * If IBSS was started by CSR from the BssDescription, then it would reset this CFG before StartBss is issued.
524 * The idea is that the count of OpRateSet and ExtendedOpRateSet rates should not be more than 12.
525 */
526
527 if (pBeacon->extendedRatesPresent)
Karthik Kantamnenie3bbd7f2018-09-19 20:27:32 +0530528 num_ext_rates = pBeacon->extendedRates.numRates;
529 if (wlan_mlme_set_cfg_str(
530 (uint8_t *)&pBeacon->extendedRates.rate,
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800531 &mac->mlme_cfg->rates.ext_opr_rate_set,
Karthik Kantamnenie3bbd7f2018-09-19 20:27:32 +0530532 num_ext_rates) != QDF_STATUS_SUCCESS) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530533 pe_err("could not update ExtendedOperRateset at CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800534 return;
535 }
536
537 /*
538 * Each IBSS node will advertise its own HT Capabilities instead of adapting to the Peer's capabilities
539 * If we don't do this then IBSS may not go back to full capabilities when the STA with lower capabilities
540 * leaves the IBSS. e.g. when non-CB STA joins an IBSS and then leaves, the IBSS will be stuck at non-CB mode
541 * even though all the nodes are capable of doing CB.
542 * so it is decided to leave the self HT capabilties intact. This may change if some issues are found in interop.
543 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530544 qdf_mem_set((void *)&mlmStartReq, sizeof(mlmStartReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800545
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530546 qdf_mem_copy(mlmStartReq.bssId, pHdr->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800547 mlmStartReq.rateSet.numRates =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800548 pe_session->pLimStartBssReq->operationalRateSet.numRates;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530549 qdf_mem_copy(&mlmStartReq.rateSet.rate[0],
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800550 &pe_session->pLimStartBssReq->operationalRateSet.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800551 rate[0], mlmStartReq.rateSet.numRates);
552 mlmStartReq.bssType = eSIR_IBSS_MODE;
553 mlmStartReq.beaconPeriod = pBeacon->beaconInterval;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800554 mlmStartReq.nwType = pe_session->pLimStartBssReq->nwType; /* pe_session->nwType is also OK???? */
555 mlmStartReq.htCapable = pe_session->htCapability;
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800556 mlmStartReq.htOperMode = mac->lim.gHTOperMode;
557 mlmStartReq.dualCTSProtection = mac->lim.gHTDualCTSProtection;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800558 mlmStartReq.txChannelWidthSet = pe_session->htRecommendedTxWidthSet;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800559
560 /* reading the channel num from session Table */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800561 mlmStartReq.channelNumber = pe_session->currentOperChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800562
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800563 mlmStartReq.cbMode = pe_session->pLimStartBssReq->cbMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800564
565 /* Copy the SSID for RxP filtering based on SSID. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530566 qdf_mem_copy((uint8_t *) &mlmStartReq.ssId,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800567 (uint8_t *) &pe_session->pLimStartBssReq->ssId,
568 pe_session->pLimStartBssReq->ssId.length + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800569
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530570 pe_debug("invoking ADD_BSS as part of coalescing!");
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +0530571#ifdef CONFIG_VDEV_SM
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800572 wlan_vdev_mlme_sm_deliver_evt(pe_session->vdev,
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +0530573 WLAN_VDEV_SM_EV_START,
574 sizeof(mlmStartReq), &mlmStartReq);
575#else
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800576 if (lim_mlm_add_bss(mac, &mlmStartReq, pe_session) !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800577 eSIR_SME_SUCCESS) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530578 pe_err("AddBss failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800579 return;
580 }
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +0530581#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800582 /* Update fields in Beacon */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800583 if (sch_set_fixed_beacon_fields(mac, pe_session) != QDF_STATUS_SUCCESS) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530584 pe_err("Unable to set fixed Beacon fields");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800585 return;
586 }
587
588}
589
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800590void ibss_bss_delete(struct mac_context *mac_ctx, struct pe_session *session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800591{
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700592 QDF_STATUS status;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -0700593
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530594 pe_debug("Initiating IBSS Delete BSS");
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +0530595 if (session->limMlmState != eLIM_MLM_BSS_STARTED_STATE) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530596 pe_warn("Incorrect LIM MLM state for delBss: %d",
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +0530597 session->limMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800598 return;
599 }
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +0530600 status = lim_del_bss(mac_ctx, NULL, session->bssIdx, session);
601 if (QDF_IS_STATUS_ERROR(status))
602 pe_err("delBss failed for bss: %d", session->bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800603}
604
605/**
606 * lim_ibss_init
607 *
608 ***FUNCTION:
609 * This function is called while starting an IBSS
610 * to initialize list used to maintain IBSS peers.
611 *
612 ***LOGIC:
613 *
614 ***ASSUMPTIONS:
615 *
616 ***NOTE:
617 *
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800618 * @param mac - Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800619 * @return None
620 */
621
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800622void lim_ibss_init(struct mac_context *mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800623{
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800624 mac->lim.gLimIbssCoalescingHappened = 0;
625 mac->lim.gLimIbssPeerList = NULL;
626 mac->lim.gLimNumIbssPeers = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800627
628 /* ibss info - params for which ibss to join while coalescing */
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800629 qdf_mem_set(&mac->lim.ibssInfo, sizeof(tAniSirLimIbss), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800630} /*** end lim_ibss_init() ***/
631
632/**
633 * lim_ibss_delete_all_peers
634 *
635 ***FUNCTION:
636 * This function is called to delete all peers.
637 *
638 ***LOGIC:
639 *
640 ***ASSUMPTIONS:
641 *
642 ***NOTE:
643 *
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800644 * @param mac - Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800645 * @return None
646 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800647void lim_ibss_delete_all_peers(struct mac_context *mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800648 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800649{
650 tLimIbssPeerNode *pCurrNode, *pTempNode;
651 tpDphHashNode pStaDs;
652 uint16_t peerIdx;
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +0530653#ifdef CONFIG_VDEV_SM
654 QDF_STATUS status;
655#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800656
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800657 pCurrNode = pTempNode = mac->lim.gLimIbssPeerList;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800658
659 while (pCurrNode != NULL) {
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800660 if (!mac->lim.gLimNumIbssPeers) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530661 pe_err("Number of peers in the list is zero and node present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800662 return;
663 }
664 /* Delete the dph entry for the station
665 * Since it is called to remove all peers, just delete from dph,
666 * no need to do any beacon related params i.e., dont call lim_delete_dph_hash_entry
667 */
668 pStaDs =
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800669 dph_lookup_hash_entry(mac, pCurrNode->peerMacAddr, &peerIdx,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800670 &pe_session->dph.dphHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800671 if (pStaDs) {
672
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800673 ibss_status_chg_notify(mac, pCurrNode->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800674 pStaDs->staIndex,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800675 eWNI_SME_IBSS_PEER_DEPARTED_IND,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800676 pe_session->smeSessionId);
677 lim_del_sta(mac, pStaDs, false, pe_session);
678 lim_release_peer_idx(mac, peerIdx, pe_session);
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800679 dph_delete_hash_entry(mac, pStaDs->staAddr, peerIdx,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800680 &pe_session->dph.dphHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800681 }
682
683 pTempNode = pCurrNode->next;
684
685 /* TODO :Sessionize this code */
686 /* Fix CR 227642: PeerList should point to the next node since the current node is being
687 * freed in the next line. In ibss_peerfind in ibss_status_chg_notify above, we use this
688 * peer list to find the next peer. So this list needs to be updated with the no of peers left
689 * after each iteration in this while loop since one by one peers are deleted (freed) in this
690 * loop causing the lim.gLimIbssPeerList to point to some freed memory.
691 */
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800692 mac->lim.gLimIbssPeerList = pTempNode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800693
694 if (pCurrNode->beacon) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530695 qdf_mem_free(pCurrNode->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800696 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530697 qdf_mem_free(pCurrNode);
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800698 if (mac->lim.gLimNumIbssPeers > 0) /* be paranoid */
699 mac->lim.gLimNumIbssPeers--;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800700 pCurrNode = pTempNode;
701 }
702
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800703 if (mac->lim.gLimNumIbssPeers)
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530704 pe_err("Number of peers: %d in the list is non-zero",
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800705 mac->lim.gLimNumIbssPeers);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800706
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800707 mac->lim.gLimNumIbssPeers = 0;
708 mac->lim.gLimIbssPeerList = NULL;
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +0530709#ifdef CONFIG_VDEV_SM
710 status =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800711 wlan_vdev_mlme_sm_deliver_evt(pe_session->vdev,
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +0530712 WLAN_VDEV_SM_EV_DISCONNECT_COMPLETE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800713 sizeof(*pe_session), pe_session);
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800714 if (!mac->lim.gLimIbssCoalescingHappened &&
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +0530715 QDF_IS_STATUS_ERROR(status)) {
716 pe_err("failed to post WLAN_VDEV_SM_EV_DISCONNECT_COMPLETE for vdevid %d",
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800717 pe_session->smeSessionId);
718 lim_send_stop_bss_failure_resp(mac, pe_session);
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +0530719 }
720#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800721}
722
723/**
724 * lim_ibss_delete() - This function is called while tearing down an IBSS
725 *
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800726 * @mac: Pointer to Global MAC structure
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800727 * @pe_session: Pointer to session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800728 *
729 * Return: none
730 */
731
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800732void lim_ibss_delete(struct mac_context *mac, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800733{
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +0530734#ifndef CONFIG_VDEV_SM
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800735 lim_ibss_delete_all_peers(mac, pe_session);
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +0530736#endif
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800737 ibss_coalesce_free(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800738}
739
740/** -------------------------------------------------------------
741 \fn lim_ibss_set_protection
742 \brief Decides all the protection related information.
743 \
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800744 \param struct mac_context * mac
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800745 \param tSirMacAddr peerMacAddr
746 \param tpUpdateBeaconParams pBeaconParams
747 \return None
748 -------------------------------------------------------------*/
749static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800750lim_ibss_set_protection(struct mac_context *mac, uint8_t enable,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800751 tpUpdateBeaconParams pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800752 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800753{
754
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800755 if (!mac->lim.cfgProtection.fromllb) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530756 pe_err("protection from 11b is disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800757 return;
758 }
759
760 if (enable) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800761 pe_session->gLim11bParams.protectionEnabled = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800762 if (false ==
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800763 pe_session->beaconParams.
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800764 llbCoexist /*mac->lim.llbCoexist */) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530765 pe_debug("=> IBSS: Enable Protection");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800766 pBeaconParams->llbCoexist =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800767 pe_session->beaconParams.llbCoexist = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800768 pBeaconParams->paramChangeBitmap |=
769 PARAM_llBCOEXIST_CHANGED;
770 }
771 } else if (true ==
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800772 pe_session->beaconParams.
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800773 llbCoexist /*mac->lim.llbCoexist */) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800774 pe_session->gLim11bParams.protectionEnabled = false;
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530775 pe_debug("===> IBSS: Disable protection");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800776 pBeaconParams->llbCoexist =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800777 pe_session->beaconParams.llbCoexist = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800778 pBeaconParams->paramChangeBitmap |= PARAM_llBCOEXIST_CHANGED;
779 }
780 return;
781}
782
783/** -------------------------------------------------------------
784 \fn lim_ibss_update_protection_params
785 \brief Decides all the protection related information.
786 \
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800787 \param struct mac_context * mac
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800788 \param tSirMacAddr peerMacAddr
789 \param tpUpdateBeaconParams pBeaconParams
790 \return None
791 -------------------------------------------------------------*/
792static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800793lim_ibss_update_protection_params(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800794 tSirMacAddr peerMacAddr,
795 tLimProtStaCacheType protStaCacheType,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800796 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800797{
798 uint32_t i;
799
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530800 pe_debug("STA is associated Addr :");
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800801 lim_print_mac_addr(mac, peerMacAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800802
803 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800804 if (mac->lim.protStaCache[i].active) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530805 pe_debug("Addr:");
Srinivas Girigowda8590a5f2017-03-10 14:28:37 -0800806 lim_print_mac_addr
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800807 (mac, mac->lim.protStaCache[i].addr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800808
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800809 if (!qdf_mem_cmp(mac->lim.protStaCache[i].addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800810 peerMacAddr,
811 sizeof(tSirMacAddr))) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530812 pe_debug("matching cache entry at: %d already active",
Srinivas Girigowda8590a5f2017-03-10 14:28:37 -0800813 i);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800814 return;
815 }
816 }
817 }
818
819 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800820 if (!mac->lim.protStaCache[i].active)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800821 break;
822 }
823
824 if (i >= LIM_PROT_STA_CACHE_SIZE) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530825 pe_err("No space in ProtStaCache");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800826 return;
827 }
828
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800829 qdf_mem_copy(mac->lim.protStaCache[i].addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800830 peerMacAddr, sizeof(tSirMacAddr));
831
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800832 mac->lim.protStaCache[i].protStaCacheType = protStaCacheType;
833 mac->lim.protStaCache[i].active = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800834 if (eLIM_PROT_STA_CACHE_TYPE_llB == protStaCacheType) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800835 pe_session->gLim11bParams.numSta++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800836 } else if (eLIM_PROT_STA_CACHE_TYPE_llG == protStaCacheType) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800837 pe_session->gLim11gParams.numSta++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800838 }
839}
840
841/** -------------------------------------------------------------
842 \fn lim_ibss_decide_protection
843 \brief Decides all the protection related information.
844 \
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800845 \param struct mac_context * mac
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800846 \param tSirMacAddr peerMacAddr
847 \param tpUpdateBeaconParams pBeaconParams
848 \return None
849 -------------------------------------------------------------*/
850static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800851lim_ibss_decide_protection(struct mac_context *mac, tpDphHashNode pStaDs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800852 tpUpdateBeaconParams pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800853 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800854{
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -0800855 enum band_info rfBand = BAND_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800856 uint32_t phyMode;
857 tLimProtStaCacheType protStaCacheType =
858 eLIM_PROT_STA_CACHE_TYPE_INVALID;
859
860 pBeaconParams->paramChangeBitmap = 0;
861
862 if (NULL == pStaDs) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530863 pe_err("pStaDs is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800864 return;
865 }
866
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800867 lim_get_rf_band_new(mac, &rfBand, pe_session);
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -0800868 if (BAND_2G == rfBand) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800869 lim_get_phy_mode(mac, &phyMode, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800870
871 /* We are 11G or 11n. Check if we need protection from 11b Stations. */
872 if ((phyMode == WNI_CFG_PHY_MODE_11G)
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800873 || (pe_session->htCapability)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800874 /* As we found in the past, it is possible that a 11n STA sends
Jeff Johnson47d75242018-05-12 15:58:53 -0700875 * Beacon with HT IE but not ERP IE. So the absence of ERP IE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800876 * in the Beacon is not enough to conclude that STA is 11b.
877 */
878 if ((pStaDs->erpEnabled == eHAL_CLEAR) &&
879 (!pStaDs->mlmStaContext.htCapability)) {
880 protStaCacheType = eLIM_PROT_STA_CACHE_TYPE_llB;
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530881 pe_err("Enable protection from 11B");
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800882 lim_ibss_set_protection(mac, true,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800883 pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800884 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800885 }
886 }
887 }
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800888 lim_ibss_update_protection_params(mac, pStaDs->staAddr, protStaCacheType,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800889 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800890 return;
891}
892
893/**
894 * lim_ibss_peer_find()
895 *
896 ***FUNCTION:
897 * This function is called while adding a context at
898 * DPH & Polaris for a peer in IBSS.
899 * If peer is found in the list, capabilities from the
900 * returned BSS description are used at DPH node & Polaris.
901 *
902 ***LOGIC:
903 *
904 ***ASSUMPTIONS:
905 *
906 ***NOTE:
907 *
908 * @param macAddr - MAC address of the peer
909 *
910 * @return Pointer to peer node if found, else NULL
911 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800912tLimIbssPeerNode *lim_ibss_peer_find(struct mac_context *mac, tSirMacAddr macAddr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800913{
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800914 return ibss_peer_find(mac, macAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800915}
916
917/**
918 * lim_ibss_sta_add()
919 *
920 ***FUNCTION:
921 * This function is called to add an STA context in IBSS role
922 * whenever a data frame is received from/for a STA that failed
923 * hash lookup at DPH.
924 *
925 ***LOGIC:
926 *
927 ***ASSUMPTIONS:
928 * NA
929 *
930 ***NOTE:
931 * NA
932 *
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800933 * @param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800934 * @param peerAdddr MAC address of the peer being added
935 * @return retCode Indicates success or failure return code
936 * @return
937 */
938
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700939QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800940lim_ibss_sta_add(struct mac_context *mac, void *pBody, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800941{
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700942 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800943 tpDphHashNode pStaDs;
944 tLimIbssPeerNode *pPeerNode;
945 tLimMlmStates prevState;
946 tSirMacAddr *pPeerAddr = (tSirMacAddr *) pBody;
947 tUpdateBeaconParams beaconParams;
948
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530949 qdf_mem_set((uint8_t *) &beaconParams, sizeof(tUpdateBeaconParams), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800950
951 if (pBody == 0) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530952 pe_err("Invalid IBSS AddSta");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700953 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800954 }
955
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530956 pe_debug("Rx Add-Ibss-Sta for MAC:");
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800957 lim_print_mac_addr(mac, *pPeerAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800958
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800959 pPeerNode = ibss_peer_find(mac, *pPeerAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800960 if (NULL != pPeerNode) {
961 retCode =
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800962 ibss_dph_entry_add(mac, *pPeerAddr, &pStaDs,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800963 pe_session);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700964 if (QDF_STATUS_SUCCESS == retCode) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800965 prevState = pStaDs->mlmStaContext.mlmState;
966 pStaDs->erpEnabled = pPeerNode->erpIePresent;
967
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800968 ibss_sta_info_update(mac, pStaDs, pPeerNode,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800969 pe_session);
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530970 pe_debug("initiating ADD STA for the IBSS peer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800971 retCode =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800972 lim_add_sta(mac, pStaDs, false, pe_session);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700973 if (retCode != QDF_STATUS_SUCCESS) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530974 pe_err("ibss-sta-add failed (reason %x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800975 retCode);
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800976 lim_print_mac_addr(mac, *pPeerAddr, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800977 pStaDs->mlmStaContext.mlmState = prevState;
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800978 dph_delete_hash_entry(mac, pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800979 pStaDs->assocId,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800980 &pe_session->dph.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800981 dphHashTable);
982 } else {
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800983 if (mac->lim.gLimProtectionControl !=
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +0530984 MLME_FORCE_POLICY_PROTECTION_DISABLE)
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800985 lim_ibss_decide_protection(mac, pStaDs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800986 &beaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800987 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800988
989 if (beaconParams.paramChangeBitmap) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +0530990 pe_debug("---> Update Beacon Params");
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800991 sch_set_fixed_beacon_fields(mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800992 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800993 beaconParams.bssIdx =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800994 pe_session->bssIdx;
Jeff Johnsonb65d2562018-11-21 21:54:36 -0800995 lim_send_beacon_params(mac, &beaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800996 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800997 }
998 }
999 } else {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301000 pe_err("hashTblAdd failed reason: %x", retCode);
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001001 lim_print_mac_addr(mac, *pPeerAddr, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001002 }
1003 } else {
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001004 retCode = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001005 }
1006
1007 return retCode;
1008}
Abhishek Singh3df76612017-05-16 14:05:32 +05301009
Abhishek Singh79e77502015-12-30 17:11:49 +05301010/**
Abhishek Singh3df76612017-05-16 14:05:32 +05301011 * lim_ibss_search_and_delete_peer()- to cleanup the IBSS
1012 * peer from lim ibss peer list
Abhishek Singh79e77502015-12-30 17:11:49 +05301013 *
1014 * @mac_ptr: Pointer to Global MAC structure
1015 * @session_entry: Session entry
1016 * @mac_addr: Mac Address of the IBSS peer
1017 *
Abhishek Singh3df76612017-05-16 14:05:32 +05301018 * This function is called to cleanup the IBSS peer from
1019 * lim ibss peer list
Abhishek Singh79e77502015-12-30 17:11:49 +05301020 *
1021 * Return: None
1022 *
1023 */
1024static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001025lim_ibss_search_and_delete_peer(struct mac_context *mac_ctx,
Jeff Johnsonb6f7d382018-11-18 22:17:15 -08001026 struct pe_session *session_entry, tSirMacAddr mac_addr)
Abhishek Singh79e77502015-12-30 17:11:49 +05301027{
1028 tLimIbssPeerNode *temp_node, *prev_node;
1029 tLimIbssPeerNode *temp_next_node = NULL;
Abhishek Singh79e77502015-12-30 17:11:49 +05301030
Abhishek Singh3df76612017-05-16 14:05:32 +05301031 prev_node = temp_node = mac_ctx->lim.gLimIbssPeerList;
Abhishek Singh79e77502015-12-30 17:11:49 +05301032
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301033 pe_debug(" PEER ADDR :" MAC_ADDRESS_STR,
Abhishek Singh79e77502015-12-30 17:11:49 +05301034 MAC_ADDR_ARRAY(mac_addr));
1035
1036 /** Compare Peer */
1037 while (NULL != temp_node) {
1038 temp_next_node = temp_node->next;
1039
1040 /* Delete the STA with MAC address */
1041 if (!qdf_mem_cmp((uint8_t *) mac_addr,
1042 (uint8_t *) &temp_node->peerMacAddr,
1043 sizeof(tSirMacAddr))) {
Abhishek Singh3df76612017-05-16 14:05:32 +05301044 if (temp_node ==
1045 mac_ctx->lim.gLimIbssPeerList) {
1046 mac_ctx->lim.gLimIbssPeerList =
1047 temp_node->next;
1048 prev_node =
1049 mac_ctx->lim.gLimIbssPeerList;
1050 } else
1051 prev_node->next = temp_node->next;
1052 if (temp_node->beacon)
1053 qdf_mem_free(temp_node->beacon);
Abhishek Singh79e77502015-12-30 17:11:49 +05301054
Abhishek Singh3df76612017-05-16 14:05:32 +05301055 qdf_mem_free(temp_node);
1056 mac_ctx->lim.gLimNumIbssPeers--;
Abhishek Singh79e77502015-12-30 17:11:49 +05301057
Abhishek Singh3df76612017-05-16 14:05:32 +05301058 temp_node = temp_next_node;
1059 break;
Abhishek Singh79e77502015-12-30 17:11:49 +05301060 }
1061 prev_node = temp_node;
1062 temp_node = temp_next_node;
1063 }
1064 /*
1065 * if it is the last peer walking out, we better
1066 * we set IBSS state to inactive.
1067 */
Abhishek Singh3df76612017-05-16 14:05:32 +05301068 if (0 == mac_ctx->lim.gLimNumIbssPeers) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301069 pe_debug("Last STA from IBSS walked out");
Abhishek Singh79e77502015-12-30 17:11:49 +05301070 session_entry->limIbssActive = false;
1071 }
1072}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001073
Abhishek Singh3df76612017-05-16 14:05:32 +05301074/**
1075 * lim_ibss_delete_peer()- to delete IBSS peer
1076 *
1077 * @mac_ptr: Pointer to Global MAC structure
1078 * @session_entry: Session entry
1079 * @mac_addr: Mac Address of the IBSS peer
1080 *
1081 * This function is called delete IBSS peer.
1082 *
1083 * Return: None
1084 *
1085 */
1086static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001087lim_ibss_delete_peer(struct mac_context *mac_ctx,
Jeff Johnsonb6f7d382018-11-18 22:17:15 -08001088 struct pe_session *session_entry, tSirMacAddr mac_addr)
Abhishek Singh3df76612017-05-16 14:05:32 +05301089{
1090 tpDphHashNode sta = NULL;
1091 uint16_t peer_idx = 0;
1092
1093 pe_debug("Delete peer :" MAC_ADDRESS_STR,
1094 MAC_ADDR_ARRAY(mac_addr));
1095
1096 sta = dph_lookup_hash_entry(mac_ctx, mac_addr,
1097 &peer_idx,
1098 &session_entry->dph.
1099 dphHashTable);
1100
1101 if (!sta) {
1102 pe_err("DPH Entry for STA %pM is missing",
1103 mac_addr);
1104 return;
1105 }
1106
1107 if (STA_INVALID_IDX != sta->staIndex) {
1108 lim_del_sta(mac_ctx, sta,
1109 true, session_entry);
1110 } else {
1111 /*
1112 * This mean ADD STA failed, thus remove the sta from
1113 * from database and no need to send del sta to firmware
1114 * and peer departed indication to upper layer.
1115 */
1116 lim_delete_dph_hash_entry(mac_ctx, sta->staAddr,
1117 peer_idx, session_entry);
1118 lim_release_peer_idx(mac_ctx,
1119 peer_idx, session_entry);
1120 lim_ibss_search_and_delete_peer(mac_ctx,
1121 session_entry, mac_addr);
1122 }
1123
1124}
1125
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001126void lim_process_ibss_del_sta_rsp(struct mac_context *mac_ctx,
Abhishek Singh3df76612017-05-16 14:05:32 +05301127 struct scheduler_msg *lim_msg,
Jeff Johnsonb6f7d382018-11-18 22:17:15 -08001128 struct pe_session *pe_session)
Abhishek Singh3df76612017-05-16 14:05:32 +05301129{
1130 tpDphHashNode sta_ds = NULL;
1131 tpDeleteStaParams del_sta_params = (tpDeleteStaParams) lim_msg->bodyptr;
1132 tSirResultCodes status = eSIR_SME_SUCCESS;
1133
1134 if (!del_sta_params) {
1135 pe_err("del_sta_params is NULL");
1136 return;
1137 }
1138 if (!LIM_IS_IBSS_ROLE(pe_session)) {
1139 pe_err("Session %d is not IBSS role", del_sta_params->assocId);
1140 status = eSIR_SME_REFUSED;
1141 goto skip_event;
1142 }
1143
1144 sta_ds = dph_get_hash_entry(mac_ctx, del_sta_params->assocId,
1145 &pe_session->dph.dphHashTable);
1146 if (!sta_ds) {
1147 pe_err("DPH Entry for STA %X is missing",
1148 del_sta_params->assocId);
1149 status = eSIR_SME_REFUSED;
1150 goto skip_event;
1151 }
1152
1153 if (QDF_STATUS_SUCCESS != del_sta_params->status) {
1154 pe_err("DEL STA failed!");
1155 status = eSIR_SME_REFUSED;
1156 goto skip_event;
1157 }
1158 pe_debug("Deleted STA associd %d staId %d MAC " MAC_ADDRESS_STR,
1159 sta_ds->assocId, sta_ds->staIndex,
1160 MAC_ADDR_ARRAY(sta_ds->staAddr));
1161
1162 lim_delete_dph_hash_entry(mac_ctx, sta_ds->staAddr,
1163 del_sta_params->assocId, pe_session);
1164 lim_release_peer_idx(mac_ctx,
1165 del_sta_params->assocId, pe_session);
1166
1167 ibss_status_chg_notify(mac_ctx,
1168 del_sta_params->staMac,
1169 sta_ds->staIndex,
Abhishek Singh3df76612017-05-16 14:05:32 +05301170 eWNI_SME_IBSS_PEER_DEPARTED_IND,
1171 pe_session->smeSessionId);
1172
1173 lim_ibss_search_and_delete_peer(mac_ctx,
1174 pe_session, del_sta_params->staMac);
1175
1176skip_event:
1177 qdf_mem_free(del_sta_params);
1178 lim_msg->bodyptr = NULL;
1179}
1180
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001181/* handle the response from HAL for an ADD STA request */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001182QDF_STATUS
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001183lim_ibss_add_sta_rsp(struct mac_context *mac, void *msg, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001184{
1185 tpDphHashNode pStaDs;
1186 uint16_t peerIdx;
1187 tpAddStaParams pAddStaParams = (tpAddStaParams) msg;
1188
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001189 SET_LIM_PROCESS_DEFD_MESGS(mac, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001190 if (pAddStaParams == NULL) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301191 pe_err("IBSS: ADD_STA_RSP with no body!");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001192 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001193 }
1194
1195 pStaDs =
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001196 dph_lookup_hash_entry(mac, pAddStaParams->staMac, &peerIdx,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001197 &pe_session->dph.dphHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001198 if (pStaDs == NULL) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301199 pe_err("IBSS: ADD_STA_RSP for unknown MAC addr: "MAC_ADDRESS_STR,
Abhishek Singh79e77502015-12-30 17:11:49 +05301200 MAC_ADDR_ARRAY(pAddStaParams->staMac));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301201 qdf_mem_free(pAddStaParams);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001202 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001203 }
1204
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301205 if (pAddStaParams->status != QDF_STATUS_SUCCESS) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301206 pe_err("IBSS: ADD_STA_RSP error: %x for MAC:"MAC_ADDRESS_STR,
Abhishek Singh79e77502015-12-30 17:11:49 +05301207 pAddStaParams->status,
1208 MAC_ADDR_ARRAY(pAddStaParams->staMac));
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001209 lim_ibss_delete_peer(mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001210 pe_session, pAddStaParams->staMac);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301211 qdf_mem_free(pAddStaParams);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001212 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001213 }
1214
1215 pStaDs->bssId = pAddStaParams->bssIdx;
1216 pStaDs->staIndex = pAddStaParams->staIdx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001217 pStaDs->valid = 1;
1218 pStaDs->mlmStaContext.mlmState = eLIM_MLM_LINK_ESTABLISHED_STATE;
1219
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301220 pe_debug("IBSS: sending IBSS_NEW_PEER msg to SME!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001221
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001222 ibss_status_chg_notify(mac, pAddStaParams->staMac,
Jeff Johnson582a3382018-03-05 11:58:47 -08001223 pStaDs->staIndex,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001224 eWNI_SME_IBSS_NEW_PEER_IND,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001225 pe_session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001226
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301227 qdf_mem_free(pAddStaParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001228
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001229 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001230}
1231
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001232void lim_ibss_del_bss_rsp_when_coalescing(struct mac_context *mac, void *msg,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001233 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001234{
1235 tpDeleteBssParams pDelBss = (tpDeleteBssParams) msg;
1236
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301237 pe_debug("IBSS: DEL_BSS_RSP Rcvd during coalescing!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001238
1239 if (pDelBss == NULL) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301240 pe_err("IBSS: DEL_BSS_RSP(coalesce) with no body!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001241 goto end;
1242 }
1243
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301244 if (pDelBss->status != QDF_STATUS_SUCCESS) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301245 pe_err("IBSS: DEL_BSS_RSP(coalesce) error: %x Bss: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001246 pDelBss->status, pDelBss->bssIdx);
1247 goto end;
1248 }
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +05301249
1250#ifndef CONFIG_VDEV_SM
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001251 /* Delete peer entries. */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001252 lim_ibss_delete_all_peers(mac, pe_session);
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +05301253#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001254 /* add the new bss */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001255 ibss_bss_add(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001256end:
1257 if (pDelBss != NULL)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301258 qdf_mem_free(pDelBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001259}
1260
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001261void lim_ibss_add_bss_rsp_when_coalescing(struct mac_context *mac, void *msg,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001262 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001263{
1264 uint8_t infoLen;
1265 tSirSmeNewBssInfo newBssInfo;
1266
1267 tpAddBssParams pAddBss = (tpAddBssParams) msg;
1268
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001269 tpSirMacMgmtHdr pHdr = (tpSirMacMgmtHdr) mac->lim.ibssInfo.pHdr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001270 tpSchBeaconStruct pBeacon =
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001271 (tpSchBeaconStruct) mac->lim.ibssInfo.pBeacon;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001272
1273 if ((pHdr == NULL) || (pBeacon == NULL)) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301274 pe_err("Unable to handle AddBssRspWhenCoalescing (no cached BSS info)");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001275 goto end;
1276 }
1277 /* Inform Host of IBSS coalescing */
1278 infoLen = sizeof(tSirMacAddr) + sizeof(tSirMacChanNum) +
1279 sizeof(uint8_t) + pBeacon->ssId.length + 1;
1280
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301281 qdf_mem_set((void *)&newBssInfo, sizeof(newBssInfo), 0);
1282 qdf_mem_copy(newBssInfo.bssId.bytes, pHdr->bssId, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001283 newBssInfo.channelNumber = (tSirMacChanNum) pAddBss->currentOperChannel;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301284 qdf_mem_copy((uint8_t *) &newBssInfo.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001285 (uint8_t *) &pBeacon->ssId, pBeacon->ssId.length + 1);
1286
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301287 pe_debug("Sending JOINED_NEW_BSS notification to SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001288
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001289 lim_send_sme_wm_status_change_ntf(mac, eSIR_SME_JOINED_NEW_BSS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001290 (uint32_t *) &newBssInfo,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001291 infoLen, pe_session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001292 {
1293 /* Configure beacon and send beacons to HAL */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001294 lim_send_beacon(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001295 }
1296
1297end:
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001298 ibss_coalesce_free(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001299}
1300
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001301void lim_ibss_del_bss_rsp(struct mac_context *mac, void *msg, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001302{
1303 tSirResultCodes rc = eSIR_SME_SUCCESS;
1304 tpDeleteBssParams pDelBss = (tpDeleteBssParams) msg;
1305 tSirMacAddr nullBssid = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
1306
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001307 SET_LIM_PROCESS_DEFD_MESGS(mac, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001308 if (pDelBss == NULL) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301309 pe_err("IBSS: DEL_BSS_RSP with no body!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001310 rc = eSIR_SME_REFUSED;
1311 goto end;
1312 }
1313
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001314 pe_session = pe_find_session_by_session_id(mac, pDelBss->sessionId);
1315 if (pe_session == NULL) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301316 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001317 goto end;
1318 }
1319
1320 /*
1321 * If delBss was issued as part of IBSS Coalescing, gLimIbssCoalescingHappened flag will be true.
1322 * BSS has to be added again in this scenario, so this case needs to be handled separately.
1323 * If delBss was issued as a result of trigger from SME_STOP_BSS Request, then limSme state changes to
1324 * 'IDLE' and gLimIbssCoalescingHappened flag will be false. In this case STOP BSS RSP has to be sent to SME.
1325 */
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001326 if (true == mac->lim.gLimIbssCoalescingHappened) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001327
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001328 lim_ibss_del_bss_rsp_when_coalescing(mac, msg, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001329 return;
1330 }
1331
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301332 if (pDelBss->status != QDF_STATUS_SUCCESS) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301333 pe_err("IBSS: DEL_BSS_RSP error: %x Bss: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001334 pDelBss->status, pDelBss->bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001335 rc = eSIR_SME_STOP_BSS_FAILURE;
1336 goto end;
1337 }
1338
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001339 if (lim_set_link_state(mac, eSIR_LINK_IDLE_STATE, nullBssid,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001340 pe_session->selfMacAddr, NULL,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001341 NULL) != QDF_STATUS_SUCCESS) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301342 pe_err("IBSS: DEL_BSS_RSP setLinkState failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001343 rc = eSIR_SME_REFUSED;
1344 goto end;
1345 }
1346
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001347 lim_ibss_delete(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001348
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001349 dph_hash_table_class_init(mac, &pe_session->dph.dphHashTable);
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001350 lim_delete_pre_auth_list(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001351
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001352 pe_session->limMlmState = eLIM_MLM_IDLE_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001353
1354 MTRACE(mac_trace
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001355 (mac, TRACE_CODE_MLM_STATE, pe_session->peSessionId,
1356 pe_session->limMlmState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001357
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001358 pe_session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001359
1360 /* Change the short slot operating mode to Default (which is 1 for now) so that when IBSS starts next time with Libra
1361 * as originator, it picks up the default. This enables us to remove hard coding of short slot = 1 from lim_apply_configuration
1362 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001363 pe_session->shortSlotTimeSupported =
Vignesh Viswanathanecd4de72018-11-22 13:02:20 +05301364 cfg_default(CFG_SHORT_SLOT_TIME_ENABLED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001365
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 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001370 if (NULL != pe_session) {
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001371 lim_send_sme_rsp(mac, eWNI_SME_STOP_BSS_RSP, rc,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001372 pe_session->smeSessionId,
1373 pe_session->transactionId);
1374 pe_delete_session(mac, pe_session);
1375 pe_session = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001376 }
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 *
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001392 * @param mac - Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001393 * @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
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001400lim_ibss_coalesce(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001401 tpSirMacMgmtHdr pHdr,
1402 tpSchBeaconStruct pBeacon,
1403 uint8_t *pIEs,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001404 uint32_t ieLen, uint16_t fTsfLater, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001405{
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
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001414 sir_copy_mac_addr(currentBssId, pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001415
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))
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001422 && pe_session->isCoalesingInIBSSAllowed) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001423 /*
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 */
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001433 pPeerNode = ibss_peer_find(mac, pHdr->sa);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001434 if (NULL != pPeerNode) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001435 lim_ibss_delete_peer(mac, pe_session,
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 */
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001450 mac->lim.gLimIbssCoalescingHappened = true;
1451 ibss_coalesce_save(mac, 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
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001455 wlan_vdev_mlme_sm_deliver_evt(pe_session->vdev,
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +05301456 WLAN_VDEV_SM_EV_DOWN,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001457 sizeof(*pe_session),
1458 pe_session);
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +05301459#else
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001460 ibss_bss_delete(mac, pe_session);
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 */
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001470 pPeerNode = ibss_peer_find(mac, pHdr->sa);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001471 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
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001479 * mac->lim.gLimNumIbssPeers will be increamented after exiting
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001480 * this function. so we will add additional 1 to compare against
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001481 * mac->lim.gLimIbssStaLimit
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001482 */
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001483 if ((mac->lim.gLimNumIbssPeers + 1) >=
1484 mac->lim.gLimIbssStaLimit) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001485 /*Print every 100th time */
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001486 if (mac->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 }
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001489 mac->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);
Arif Hussainf5b6c412018-10-10 19:41:09 -07001497 if (!pPeerNode)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001498 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001499
1500 pPeerNode->beacon = NULL;
1501 pPeerNode->beaconLen = 0;
1502
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001503 ibss_peer_collect(mac, pBeacon, pHdr, pPeerNode,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001504 pe_session);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301505 pPeerNode->beacon = qdf_mem_malloc(ieLen);
Arif Hussainf5b6c412018-10-10 19:41:09 -07001506 if (pPeerNode->beacon) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301507 qdf_mem_copy(pPeerNode->beacon, pIEs, ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001508 pPeerNode->beaconLen = (uint16_t) ieLen;
1509 }
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001510 ibss_peer_add(mac, pPeerNode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001511
1512 pStaDs =
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001513 dph_lookup_hash_entry(mac, pPeerNode->peerMacAddr, &peerIdx,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001514 &pe_session->dph.dphHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001515 if (pStaDs != NULL) {
1516 /* / DPH node already exists for the peer */
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301517 pe_warn("DPH Node present for just learned peer");
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001518 lim_print_mac_addr(mac, pPeerNode->peerMacAddr, LOGD);
1519 ibss_sta_info_update(mac, pStaDs, pPeerNode,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001520 pe_session);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001521 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001522 }
1523 retCode =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001524 lim_ibss_sta_add(mac, pPeerNode->peerMacAddr, pe_session);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001525 if (retCode != QDF_STATUS_SUCCESS) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301526 pe_err("lim-ibss-sta-add failed reason: %x", retCode);
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001527 lim_print_mac_addr(mac, pPeerNode->peerMacAddr, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001528 return retCode;
1529 }
1530 /* Decide protection mode */
1531 pStaDs =
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001532 dph_lookup_hash_entry(mac, pPeerNode->peerMacAddr, &peerIdx,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001533 &pe_session->dph.dphHashTable);
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001534 if (mac->lim.gLimProtectionControl !=
Pragaspathi Thilagaraj1ee76002018-09-18 21:38:51 +05301535 MLME_FORCE_POLICY_PROTECTION_DISABLE)
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001536 lim_ibss_decide_protection(mac, pStaDs, &beaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001537 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001538
1539 if (beaconParams.paramChangeBitmap) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301540 pe_err("beaconParams.paramChangeBitmap=1 ---> Update Beacon Params");
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001541 sch_set_fixed_beacon_fields(mac, pe_session);
1542 beaconParams.bssIdx = pe_session->bssIdx;
1543 lim_send_beacon_params(mac, &beaconParams, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001544 }
1545 } else
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001546 ibss_sta_caps_update(mac, pPeerNode, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001547
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001548 if (pe_session->limSmeState != eLIM_SME_NORMAL_STATE)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001549 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001550
1551 /* Received Beacon from same IBSS we're */
1552 /* currently part of. Inform Roaming algorithm */
1553 /* if not already that IBSS is active. */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001554 if (pe_session->limIbssActive == false) {
1555 limResetHBPktCount(pe_session);
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301556 pe_warn("Partner joined our IBSS, Sending IBSS_ACTIVE Notification to SME");
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001557 pe_session->limIbssActive = true;
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001558 lim_send_sme_wm_status_change_ntf(mac, eSIR_SME_IBSS_ACTIVE, NULL, 0,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001559 pe_session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001560 }
1561
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001562 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001563} /*** end lim_handle_ibs_scoalescing() ***/
1564
1565/**
1566 * lim_ibss_heart_beat_handle() - handle IBSS hearbeat failure
1567 *
1568 * @mac_ctx: global mac context
1569 * @session: PE session entry
1570 *
1571 * Hanlde IBSS hearbeat failure.
1572 *
1573 * Return: None.
1574 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001575void lim_ibss_heart_beat_handle(struct mac_context *mac_ctx, struct pe_session *session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001576{
1577 tLimIbssPeerNode *tempnode, *prevnode;
1578 tLimIbssPeerNode *temp_next = NULL;
1579 uint16_t peer_idx = 0;
1580 tpDphHashNode stads = 0;
1581 uint32_t threshold = 0;
1582 uint16_t sta_idx = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001583
1584 /*
1585 * MLM BSS is started and if PE in scanmode then MLM state will be
1586 * waiting for probe resp. If Heart beat timeout triggers during this
1587 * corner case then we need to reactivate HeartBeat timer.
1588 */
1589 if (session->limMlmState != eLIM_MLM_BSS_STARTED_STATE)
1590 return;
1591
1592 /* If LinkMonitor is Disabled */
1593 if (!mac_ctx->sys.gSysEnableLinkMonitorMode)
1594 return;
1595
1596 prevnode = tempnode = mac_ctx->lim.gLimIbssPeerList;
1597 threshold = (mac_ctx->lim.gLimNumIbssPeers / 4) + 1;
1598
1599 /* Monitor the HeartBeat with the Individual PEERS in the IBSS */
1600 while (tempnode != NULL) {
1601 temp_next = tempnode->next;
1602 if (tempnode->beaconHBCount) {
1603 /* There was a beacon for this peer during heart beat */
1604 tempnode->beaconHBCount = 0;
1605 tempnode->heartbeatFailure = 0;
1606 prevnode = tempnode;
1607 tempnode = temp_next;
1608 continue;
1609 }
1610
1611 /* There wasnt any beacon received during heartbeat timer. */
1612 tempnode->heartbeatFailure++;
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301613 pe_err("Heartbeat fail: %d thres: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001614 tempnode->heartbeatFailure, mac_ctx->lim.gLimNumIbssPeers);
1615 if (tempnode->heartbeatFailure >= threshold) {
1616 /* Remove this entry from the list. */
1617 stads = dph_lookup_hash_entry(mac_ctx,
1618 tempnode->peerMacAddr, &peer_idx,
1619 &session->dph.dphHashTable);
1620 if (stads) {
1621 sta_idx = stads->staIndex;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001622
1623 (void)lim_del_sta(mac_ctx, stads, false,
1624 session);
1625 lim_delete_dph_hash_entry(mac_ctx,
1626 stads->staAddr, peer_idx, session);
1627 lim_release_peer_idx(mac_ctx, peer_idx,
1628 session);
1629 /* Send indication. */
1630 ibss_status_chg_notify(mac_ctx,
1631 tempnode->peerMacAddr, sta_idx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001632 eWNI_SME_IBSS_PEER_DEPARTED_IND,
1633 session->smeSessionId);
1634 }
1635 if (tempnode == mac_ctx->lim.gLimIbssPeerList) {
1636 mac_ctx->lim.gLimIbssPeerList = tempnode->next;
1637 prevnode = mac_ctx->lim.gLimIbssPeerList;
1638 } else {
1639 prevnode->next = tempnode->next;
1640 }
1641
Kapil Guptac797b622016-10-18 12:05:44 +05301642 if (tempnode->beacon)
1643 qdf_mem_free(tempnode->beacon);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301644 qdf_mem_free(tempnode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001645 mac_ctx->lim.gLimNumIbssPeers--;
1646
1647 /* we deleted current node, so prevNode remains same. */
1648 tempnode = temp_next;
1649 continue;
1650 }
1651 prevnode = tempnode;
1652 tempnode = temp_next;
1653 }
1654
1655 /*
1656 * General IBSS Activity Monitor,
1657 * check if in IBSS Mode we are received any Beacons
1658 */
1659 if (mac_ctx->lim.gLimNumIbssPeers) {
1660 if (session->LimRxedBeaconCntDuringHB <
1661 MAX_NO_BEACONS_PER_HEART_BEAT_INTERVAL)
1662 mac_ctx->lim.gLimHeartBeatBeaconStats[
1663 session->LimRxedBeaconCntDuringHB]++;
1664 else
1665 mac_ctx->lim.gLimHeartBeatBeaconStats[0]++;
1666
1667 /* Reset number of beacons received */
1668 limResetHBPktCount(session);
1669 return;
1670 } else {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301671 pe_warn("Heartbeat Failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001672 mac_ctx->lim.gLimHBfailureCntInLinkEstState++;
1673
1674 if (session->limIbssActive == true) {
1675 /*
1676 * We don't receive Beacon frames from any
1677 * other STA in IBSS. Announce IBSS inactive
1678 * to Roaming algorithm
1679 */
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301680 pe_warn("Alone in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001681 session->limIbssActive = false;
1682
1683 lim_send_sme_wm_status_change_ntf(mac_ctx,
1684 eSIR_SME_IBSS_INACTIVE, NULL, 0,
1685 session->smeSessionId);
1686 }
1687 }
1688}
1689
1690/**
1691 * lim_ibss_decide_protection_on_delete() - decides protection related info.
1692 *
1693 * @mac_ctx: global mac context
1694 * @stads: station hash node
1695 * @bcn_param: beacon parameters
1696 * @session: PE session entry
1697 *
1698 * Decides all the protection related information.
1699 *
1700 * Return: None
1701 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001702void lim_ibss_decide_protection_on_delete(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001703 tpDphHashNode stads,
1704 tpUpdateBeaconParams bcn_param,
Jeff Johnsonb6f7d382018-11-18 22:17:15 -08001705 struct pe_session *session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001706{
1707 uint32_t phymode;
1708 tHalBitVal erpenabled = eHAL_CLEAR;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001709 enum band_info rfband = BAND_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001710 uint32_t i;
1711
1712 if (NULL == stads)
1713 return;
1714
1715 lim_get_rf_band_new(mac_ctx, &rfband, session);
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001716 if (BAND_2G != rfband)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001717 return;
1718
1719 lim_get_phy_mode(mac_ctx, &phymode, session);
1720 erpenabled = stads->erpEnabled;
1721 /* we are HT or 11G and 11B station is getting deleted. */
1722 if (((phymode == WNI_CFG_PHY_MODE_11G) ||
1723 session->htCapability) && (erpenabled == eHAL_CLEAR)) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301724 pe_err("%d A legacy STA is disassociated Addr is",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001725 session->gLim11bParams.numSta);
1726 lim_print_mac_addr(mac_ctx, stads->staAddr, LOGE);
1727 if (session->gLim11bParams.numSta == 0) {
Nishank Aggarwale11ec7b2017-03-24 17:40:40 +05301728 pe_err("No 11B STA exists. Disable protection");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001729 lim_ibss_set_protection(mac_ctx, false,
1730 bcn_param, session);
1731 }
1732
1733 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
1734 if (!mac_ctx->lim.protStaCache[i].active)
1735 continue;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301736 if (!qdf_mem_cmp(mac_ctx->lim.protStaCache[i].addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001737 stads->staAddr, sizeof(tSirMacAddr))) {
1738 session->gLim11bParams.numSta--;
1739 mac_ctx->lim.protStaCache[i].active = false;
1740 break;
1741 }
1742 }
1743
1744 }
1745}
1746
1747/** -----------------------------------------------------------------
1748 \fn __lim_ibss_peer_inactivity_handler
1749 \brief Internal function. Deletes FW indicated peer which is inactive
1750 \
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001751 \param struct mac_context * mac
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001752 \param struct pe_session * pe_session
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001753 \param tpSirIbssPeerInactivityInd peerInactivityInd
1754 \return None
1755 -----------------------------------------------------------------*/
1756static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001757__lim_ibss_peer_inactivity_handler(struct mac_context *mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001758 struct pe_session *pe_session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001759 tpSirIbssPeerInactivityInd peerInactivityInd)
1760{
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001761 if (pe_session->limMlmState != eLIM_MLM_BSS_STARTED_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001762 return;
1763 }
1764
1765 /* delete the peer for which heartbeat is observed */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001766 lim_ibss_delete_peer(mac, pe_session,
Srinivas Girigowda01d1c3c2015-11-25 16:54:41 -08001767 peerInactivityInd->peer_addr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001768}
1769
1770/** -------------------------------------------------------------
1771 \fn lim_process_ibss_peer_inactivity
1772 \brief Peer inactivity message handler
1773 \
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001774 \param struct mac_context * mac
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001775 \param void* buf
1776 \return None
1777 -------------------------------------------------------------*/
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001778void lim_process_ibss_peer_inactivity(struct mac_context *mac, void *buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001779{
1780 /*
1781 * --------------- HEARTBEAT OFFLOAD CASE ------------------
1782 * This message handler is executed when the firmware identifies
1783 * inactivity from one or more peer devices. We will come here
1784 * for every inactive peer device
1785 */
1786 uint8_t i;
1787
1788 tSirIbssPeerInactivityInd *peerInactivityInd =
1789 (tSirIbssPeerInactivityInd *) buf;
1790
1791 /*
1792 * If IBSS is not started or heartbeat offload is not enabled
1793 * we should not handle this request
1794 */
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001795 if (eLIM_STA_IN_IBSS_ROLE != mac->lim.gLimSystemRole &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001796 !IS_IBSS_HEARTBEAT_OFFLOAD_FEATURE_ENABLE) {
1797 return;
1798 }
1799
1800 /** If LinkMonitor is Disabled */
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001801 if (!mac->sys.gSysEnableLinkMonitorMode) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001802 return;
1803 }
1804
Jeff Johnsonb65d2562018-11-21 21:54:36 -08001805 for (i = 0; i < mac->lim.maxBssId; i++) {
1806 if (true == mac->lim.gpSession[i].valid &&
1807 eSIR_IBSS_MODE == mac->lim.gpSession[i].bssType) {
1808 __lim_ibss_peer_inactivity_handler(mac,
1809 &mac->lim.gpSession[i],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001810 peerInactivityInd);
1811 break;
1812 }
1813 }
1814}