blob: 6c0b520de006c353c0ceee6aa2b0df7bba6732c2 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
bingsf950e552019-12-04 14:13:05 +08002 * Copyright (c) 2012-2017, 2019 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080022/*
Kiet Lam842dad02014-02-18 18:44:02 -080023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/*
Jeff Johnson295189b2012-06-20 16:38:30 -070029 * This file schBeaconGen.cc contains beacon generation related
30 * functions
31 *
32 * Author: Sandesh Goel
33 * Date: 02/25/02
34 * History:-
35 * Date Modified by Modification Information
36 * --------------------------------------------------------------------
37 *
38 */
39
40#include "palTypes.h"
Satyanarayana Dash6f438272015-03-03 18:01:06 +053041#include "wniCfg.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070042#include "aniGlobal.h"
43#include "sirMacProtDef.h"
44
45#include "limUtils.h"
46#include "limApi.h"
47
Jeff Johnson295189b2012-06-20 16:38:30 -070048
49#include "halMsgApi.h"
50#include "cfgApi.h"
51#include "pmmApi.h"
52#include "schApi.h"
53
54#include "parserApi.h"
55
56#include "schDebug.h"
57
58//
59// March 15, 2006
60// Temporarily (maybe for all of Alpha-1), assuming TIM = 0
61//
62
63const tANI_U8 P2pOui[] = {0x50, 0x6F, 0x9A, 0x9};
64
Jeff Johnson295189b2012-06-20 16:38:30 -070065
Jeff Johnson295189b2012-06-20 16:38:30 -070066tSirRetStatus schGetP2pIeOffset(tANI_U8 *pExtraIe, tANI_U32 extraIeLen, tANI_U16 *pP2pIeOffset)
67{
68 tSirRetStatus status = eSIR_FAILURE;
69 *pP2pIeOffset = 0;
70
71 // Extra IE is not present
72 if(0 == extraIeLen)
73 {
74 return status;
75 }
76
77 // Calculate the P2P IE Offset
78 do
79 {
80 if(*pExtraIe == 0xDD)
81 {
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +053082 if ( vos_mem_compare ( (void *)(pExtraIe+2), &P2pOui, sizeof(P2pOui) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070083 {
Jeff Johnson295189b2012-06-20 16:38:30 -070084 status = eSIR_SUCCESS;
85 break;
86 }
87 }
88
89 (*pP2pIeOffset)++;
90 pExtraIe++;
91 }while(--extraIeLen > 0);
92
93 return status;
94}
Jeff Johnson295189b2012-06-20 16:38:30 -070095
96tSirRetStatus schAppendAddnIE(tpAniSirGlobal pMac, tpPESession psessionEntry,
97 tANI_U8 *pFrame, tANI_U32 maxBeaconSize,
98 tANI_U32 *nBytes)
99{
100 tSirRetStatus status = eSIR_FAILURE;
101 tANI_U32 present, len;
102 tANI_U8 addIE[WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN];
103
104 if((status = wlan_cfgGetInt(pMac, WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG,
105 &present)) != eSIR_SUCCESS)
106 {
Katya Nigam70d68332013-09-16 16:49:45 +0530107 schLog(pMac, LOGP, FL("Unable to get WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700108 return status;
109 }
110
111 if(present)
112 {
113 if((status = wlan_cfgGetStrLen(pMac, WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA,
114 &len)) != eSIR_SUCCESS)
115 {
Katya Nigam70d68332013-09-16 16:49:45 +0530116 schLog(pMac, LOGP,
Jeff Johnson295189b2012-06-20 16:38:30 -0700117 FL("Unable to get WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA length"));
118 return status;
119 }
120
121 if(len <= WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN && len &&
122 ((len + *nBytes) <= maxBeaconSize))
123 {
124 if((status = wlan_cfgGetStr(pMac,
125 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, &addIE[0], &len))
126 == eSIR_SUCCESS)
127 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700128 tANI_U8* pP2pIe = limGetP2pIEPtr(pMac, &addIE[0], len);
129 if(pP2pIe != NULL)
130 {
131 tANI_U8 noaLen = 0;
132 tANI_U8 noaStream[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
133 //get NoA attribute stream P2P IE
134 noaLen = limGetNoaAttrStream(pMac, noaStream, psessionEntry);
135 if(noaLen)
136 {
Abhishek Singhce4b6932014-06-30 15:10:08 +0530137 if ( (noaLen + len) <= WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN )
Jeff Johnson295189b2012-06-20 16:38:30 -0700138 {
139 vos_mem_copy(&addIE[len], noaStream, noaLen);
140 len += noaLen;
141 /* Update IE Len */
142 pP2pIe[1] += noaLen;
Kaushik, Sushanta5ee77a2014-07-30 19:35:25 +0530143 schLog(pMac, LOG1,
144 FL("NoA length is %d"),noaLen);
Jeff Johnson295189b2012-06-20 16:38:30 -0700145 }
146 else
147 {
Katya Nigam70d68332013-09-16 16:49:45 +0530148 schLog(pMac, LOGE,
Jeff Johnson295189b2012-06-20 16:38:30 -0700149 FL("Not able to insert NoA because of length constraint"));
150 }
151 }
152 }
Rashmi Ramanna3ec0dee2014-06-27 21:21:41 +0530153 vos_mem_copy(pFrame, &addIE[0], len);
154 *nBytes = *nBytes + len;
Kaushik, Sushanta5ee77a2014-07-30 19:35:25 +0530155 schLog(pMac, LOG1,
156 FL("Total beacon size is %d"), *nBytes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700157 }
158 }
159 }
160
161 return status;
162}
163
164// --------------------------------------------------------------------
165/**
166 * schSetFixedBeaconFields
167 *
168 * FUNCTION:
169 *
170 * LOGIC:
171 *
172 * ASSUMPTIONS:
173 *
174 * NOTE:
175 *
176 * @param None
177 * @return None
178 */
179
180tSirRetStatus schSetFixedBeaconFields(tpAniSirGlobal pMac,tpPESession psessionEntry)
181{
182 tpAniBeaconStruct pBeacon = (tpAniBeaconStruct)
183 pMac->sch.schObject.gSchBeaconFrameBegin;
184 tpSirMacMgmtHdr mac;
185 tANI_U16 offset;
186 tANI_U8 *ptr;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700187 tDot11fBeacon1 *pBcn1;
188 tDot11fBeacon2 *pBcn2;
Jeff Johnson295189b2012-06-20 16:38:30 -0700189 tANI_U32 i, nStatus, nBytes;
190 tANI_U32 wpsApEnable=0, tmp;
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700191 tDot11fIEWscProbeRes *pWscProbeRes;
Jeff Johnson295189b2012-06-20 16:38:30 -0700192 tANI_U8 *pExtraIe = NULL;
193 tANI_U32 extraIeLen =0;
194 tANI_U16 extraIeOffset = 0;
195 tANI_U16 p2pIeOffset = 0;
196 tSirRetStatus status = eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700197
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530198 pBcn1 = vos_mem_malloc(sizeof(tDot11fBeacon1));
199 if ( NULL == pBcn1 )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700200 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700201 schLog(pMac, LOGE, FL("Failed to allocate memory") );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700202 return eSIR_FAILURE;
203 }
204
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530205 pBcn2 = vos_mem_malloc(sizeof(tDot11fBeacon2));
206 if ( NULL == pBcn2 )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700207 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700208 schLog(pMac, LOGE, FL("Failed to allocate memory") );
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530209 vos_mem_free(pBcn1);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700210 return eSIR_FAILURE;
211 }
212
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530213 pWscProbeRes = vos_mem_malloc(sizeof(tDot11fIEWscProbeRes));
214 if ( NULL == pWscProbeRes )
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700215 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700216 schLog(pMac, LOGE, FL("Failed to allocate memory") );
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530217 vos_mem_free(pBcn1);
218 vos_mem_free(pBcn2);
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700219 return eSIR_FAILURE;
220 }
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700221
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700222 PELOG1(schLog(pMac, LOG1, FL("Setting fixed beacon fields"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700223
224 /*
225 * First set the fixed fields
226 */
227
228 // set the TFP headers
229
230 // set the mac header
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530231 vos_mem_set(( tANI_U8*) &pBeacon->macHdr, sizeof( tSirMacMgmtHdr ),0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700232 mac = (tpSirMacMgmtHdr) &pBeacon->macHdr;
233 mac->fc.type = SIR_MAC_MGMT_FRAME;
234 mac->fc.subType = SIR_MAC_MGMT_BEACON;
235
236 for (i=0; i<6; i++)
237 mac->da[i] = 0xff;
238
239 /* Knocking out Global pMac update */
240 /* limGetMyMacAddr(pMac, mac->sa); */
241 /* limGetBssid(pMac, mac->bssId); */
242
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530243 vos_mem_copy(mac->sa, psessionEntry->selfMacAddr, sizeof(psessionEntry->selfMacAddr));
244 vos_mem_copy(mac->bssId, psessionEntry->bssId, sizeof (psessionEntry->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -0700245
246 mac->fc.fromDS = 0;
247 mac->fc.toDS = 0;
248
249 /*
250 * Now set the beacon body
251 */
252
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530253 vos_mem_set(( tANI_U8*) pBcn1, sizeof( tDot11fBeacon1 ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700254
255 // Skip over the timestamp (it'll be updated later).
256
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700257 pBcn1->BeaconInterval.interval = pMac->sch.schObject.gSchBeaconInterval;
258 PopulateDot11fCapabilities( pMac, &pBcn1->Capabilities, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700259 if (psessionEntry->ssidHidden)
260 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700261 pBcn1->SSID.present = 1; //rest of the fileds are 0 for hidden ssid
Jeff Johnson295189b2012-06-20 16:38:30 -0700262 }
263 else
264 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700265 PopulateDot11fSSID( pMac, &psessionEntry->ssId, &pBcn1->SSID );
Jeff Johnson295189b2012-06-20 16:38:30 -0700266 }
267
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700268
269 PopulateDot11fSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL, &pBcn1->SuppRates,psessionEntry);
270 PopulateDot11fDSParams( pMac, &pBcn1->DSParams, psessionEntry->currentOperChannel, psessionEntry);
271 PopulateDot11fIBSSParams( pMac, &pBcn1->IBSSParams,psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700272
273 offset = sizeof( tAniBeaconStruct );
274 ptr = pMac->sch.schObject.gSchBeaconFrameBegin + offset;
275
Jeff Johnson295189b2012-06-20 16:38:30 -0700276 if((psessionEntry->limSystemRole == eLIM_AP_ROLE)
Sachin Ahuja825082e2014-11-25 17:34:36 +0530277 && ((psessionEntry->proxyProbeRspEn)
278 || (IS_FEATURE_SUPPORTED_BY_FW(WPS_PRBRSP_TMPL)))
Rajeev Kumar Sirasanagandla63f85cf2016-06-29 16:52:15 +0530279 && vos_is_probe_rsp_offload_enabled()
Sachin Ahuja825082e2014-11-25 17:34:36 +0530280 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700281 {
282 /* Initialize the default IE bitmap to zero */
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530283 vos_mem_set(( tANI_U8* )&(psessionEntry->DefProbeRspIeBitmap), (sizeof( tANI_U32 ) * 8), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700284
285 /* Initialize the default IE bitmap to zero */
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530286 vos_mem_set(( tANI_U8* )&(psessionEntry->probeRespFrame),
287 sizeof(psessionEntry->probeRespFrame), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700288
Kapil Guptad4c78142016-10-03 16:40:38 +0530289 /* Can be efficiently updated whenever new IE added
290 * in Probe response in future
291 */
292 if (limUpdateProbeRspTemplateIeBitmapBeacon1(pMac, pBcn1,
293 psessionEntry) != eSIR_SUCCESS)
294 {
295 schLog(pMac, LOGE,
296 FL("Failed to build ProbeRsp template"));
297 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700298 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700299
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700300 nStatus = dot11fPackBeacon1( pMac, pBcn1, ptr,
Jeff Johnson295189b2012-06-20 16:38:30 -0700301 SCH_MAX_BEACON_SIZE - offset,
302 &nBytes );
303 if ( DOT11F_FAILED( nStatus ) )
304 {
305 schLog( pMac, LOGE, FL("Failed to packed a tDot11fBeacon1 (0x%0"
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700306 "8x.)."), nStatus );
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530307 vos_mem_free(pBcn1);
308 vos_mem_free(pBcn2);
309 vos_mem_free(pWscProbeRes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700310 return eSIR_FAILURE;
311 }
312 else if ( DOT11F_WARNED( nStatus ) )
313 {
314 schLog( pMac, LOGE, FL("There were warnings while packing a tDo"
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700315 "t11fBeacon1 (0x%08x.)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700316 }
317 /*changed to correct beacon corruption */
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530318 vos_mem_set(( tANI_U8*) pBcn2, sizeof( tDot11fBeacon2 ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700319 pMac->sch.schObject.gSchBeaconOffsetBegin = offset + ( tANI_U16 )nBytes;
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700320 schLog( pMac, LOG1, FL("Initialized beacon begin, offset %d"), offset );
Jeff Johnson295189b2012-06-20 16:38:30 -0700321
322 /*
323 * Initialize the 'new' fields at the end of the beacon
324 */
325
326
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700327 PopulateDot11fCountry( pMac, &pBcn2->Country, psessionEntry);
328 if(pBcn1->Capabilities.qos)
Jeff Johnson295189b2012-06-20 16:38:30 -0700329 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700330 PopulateDot11fEDCAParamSet( pMac, &pBcn2->EDCAParamSet, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700331 }
332
Jeff Johnsone7245742012-09-05 17:12:55 -0700333 if(psessionEntry->lim11hEnable)
Jeff Johnson295189b2012-06-20 16:38:30 -0700334 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700335 PopulateDot11fPowerConstraints( pMac, &pBcn2->PowerConstraints );
336 PopulateDot11fTPCReport( pMac, &pBcn2->TPCReport, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700337 }
338
Jeff Johnson295189b2012-06-20 16:38:30 -0700339
340 if (psessionEntry->dot11mode != WNI_CFG_DOT11_MODE_11B)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700341 PopulateDot11fERPInfo( pMac, &pBcn2->ERPInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700342
Jeff Johnsone7245742012-09-05 17:12:55 -0700343 if(psessionEntry->htCapability)
Jeff Johnson295189b2012-06-20 16:38:30 -0700344 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700345 PopulateDot11fHTCaps( pMac,psessionEntry, &pBcn2->HTCaps );
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700346 PopulateDot11fHTInfo( pMac, &pBcn2->HTInfo, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700347 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530348
349#ifdef WLAN_FEATURE_AP_HT40_24G
Hardik Kantilal Patel3c235242015-01-02 17:56:18 +0530350 if ((pMac->roam.configParam.apHT40_24GEnabled)
351 && (IS_DOT11_MODE_HT(psessionEntry->dot11mode)))
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530352 {
353 PopulateDot11fOBSSScanParameters( pMac, &pBcn2->OBSSScanParameters,
354 psessionEntry);
Hardik Kantilal Patelee5874c2015-01-14 15:23:28 +0530355 /* 10.15.8 Support of DSSS/CCK in 40 MHz, An associated HT STA in
356 * a 20/40 MHz BSS may generate DSSS/CCK transmissions. Set DSSS/CCK
357 * Mode in 40 MHz bit in HT capablity.
358 */
359 pBcn2->HTCaps.dsssCckMode40MHz = 1;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530360 }
361#endif
362
363 PopulateDot11fExtCap( pMac, &pBcn2->ExtCap, psessionEntry);
364
Jeff Johnsone7245742012-09-05 17:12:55 -0700365#ifdef WLAN_FEATURE_11AC
366 if(psessionEntry->vhtCapability)
367 {
Katya Nigam70d68332013-09-16 16:49:45 +0530368 schLog( pMac, LOGW, FL("Populate VHT IEs in Beacon"));
Abhishek Singh33f76ea2015-06-04 12:27:30 +0530369 PopulateDot11fVHTCaps( pMac, &pBcn2->VHTCaps,
370 psessionEntry->currentOperChannel, eSIR_TRUE );
371 PopulateDot11fVHTOperation( pMac, &pBcn2->VHTOperation,
372 psessionEntry->currentOperChannel);
Jeff Johnsone7245742012-09-05 17:12:55 -0700373 // we do not support multi users yet
374 //PopulateDot11fVHTExtBssLoad( pMac, &bcn2.VHTExtBssLoad);
Mohit Khanna4a70d262012-09-11 16:30:12 -0700375 if(psessionEntry->gLimOperatingMode.present)
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700376 PopulateDot11fOperatingMode( pMac, &pBcn2->OperatingMode, psessionEntry );
Jeff Johnsone7245742012-09-05 17:12:55 -0700377 }
378#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700379
Abhishek Singh02605092017-10-25 14:06:12 +0530380 if (LIM_IS_AP_ROLE(psessionEntry) && psessionEntry->include_ecsa_ie) {
381 populate_dot11f_ext_chann_switch_ann(pMac, &pBcn2->ext_chan_switch_ann,
382 psessionEntry);
383 if (psessionEntry->lim11hEnable) {
384 PopulateDot11fChanSwitchAnn(pMac,
385 &pBcn2->ChanSwitchAnn, psessionEntry);
386 if (psessionEntry->include_wide_ch_bw_ie)
387 PopulateDot11fWiderBWChanSwitchAnn(pMac,
388 &pBcn2->WiderBWChanSwitchAnn, psessionEntry);
389 }
390 }
391
Jeff Johnson295189b2012-06-20 16:38:30 -0700392 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700393 &pBcn2->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700394
395 if( psessionEntry->pLimStartBssReq != NULL )
396 {
397 PopulateDot11fWPA( pMac, &psessionEntry->pLimStartBssReq->rsnIE,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700398 &pBcn2->WPA );
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700399 PopulateDot11fRSNOpaque( pMac, &psessionEntry->pLimStartBssReq->rsnIE,
400 &pBcn2->RSNOpaque );
Agrawal Ashisha8e8a722016-10-18 19:07:45 +0530401#ifdef SAP_AUTH_OFFLOAD
402 /* Software AP Authentication Offload feature
403 * only support WPA2-PSK AES and we
404 * need to update RSNIE for beacon
405 */
406 sap_auth_offload_update_rsn_ie(pMac, &pBcn2->RSNOpaque);
407#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700408 }
409
410 if(psessionEntry->limWmeEnabled)
411 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700412 PopulateDot11fWMM( pMac, &pBcn2->WMMInfoAp, &pBcn2->WMMParams, &pBcn2->WMMCaps, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700413 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700414 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
415 {
416 if(psessionEntry->wps_state != SAP_WPS_DISABLED)
417 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700418 PopulateDot11fBeaconWPSIEs( pMac, &pBcn2->WscBeacon, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700419 }
420 }
421 else
422 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800423 if (wlan_cfgGetInt(pMac, (tANI_U16) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS)
Katya Nigam70d68332013-09-16 16:49:45 +0530424 schLog(pMac, LOGP,"Failed to cfg get id %d", WNI_CFG_WPS_ENABLE );
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800425
426 wpsApEnable = tmp & WNI_CFG_WPS_ENABLE_AP;
427
428 if (wpsApEnable)
429 {
430 PopulateDot11fWsc(pMac, &pBcn2->WscBeacon);
431 }
432
433 if (pMac->lim.wscIeInfo.wscEnrollmentState == eLIM_WSC_ENROLL_BEGIN)
434 {
435 PopulateDot11fWscRegistrarInfo(pMac, &pBcn2->WscBeacon);
436 pMac->lim.wscIeInfo.wscEnrollmentState = eLIM_WSC_ENROLL_IN_PROGRESS;
437 }
438
439 if (pMac->lim.wscIeInfo.wscEnrollmentState == eLIM_WSC_ENROLL_END)
440 {
441 DePopulateDot11fWscRegistrarInfo(pMac, &pBcn2->WscBeacon);
442 pMac->lim.wscIeInfo.wscEnrollmentState = eLIM_WSC_ENROLL_NOOP;
443 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700444 }
445
Jeff Johnson295189b2012-06-20 16:38:30 -0700446 if((psessionEntry->limSystemRole == eLIM_AP_ROLE)
Sachin Ahuja825082e2014-11-25 17:34:36 +0530447 && ((psessionEntry->proxyProbeRspEn)
448 || (IS_FEATURE_SUPPORTED_BY_FW(WPS_PRBRSP_TMPL)))
Rajeev Kumar Sirasanagandla63f85cf2016-06-29 16:52:15 +0530449 && vos_is_probe_rsp_offload_enabled()
Sachin Ahuja825082e2014-11-25 17:34:36 +0530450 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700451 {
452 /* Can be efficiently updated whenever new IE added in Probe response in future */
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700453 limUpdateProbeRspTemplateIeBitmapBeacon2(pMac,pBcn2,&psessionEntry->DefProbeRspIeBitmap[0],
Jeff Johnson295189b2012-06-20 16:38:30 -0700454 &psessionEntry->probeRespFrame);
455
456 /* update probe response WPS IE instead of beacon WPS IE
457 * */
458 if(psessionEntry->wps_state != SAP_WPS_DISABLED)
459 {
460 if(psessionEntry->APWPSIEs.SirWPSProbeRspIE.FieldPresent)
461 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700462 PopulateDot11fProbeResWPSIEs(pMac, pWscProbeRes, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700463 }
464 else
465 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700466 pWscProbeRes->present = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700467 }
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700468 if(pWscProbeRes->present)
Jeff Johnson295189b2012-06-20 16:38:30 -0700469 {
470 SetProbeRspIeBitmap(&psessionEntry->DefProbeRspIeBitmap[0],SIR_MAC_WPA_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530471 vos_mem_copy((void *)&psessionEntry->probeRespFrame.WscProbeRes,
472 (void *)pWscProbeRes,
473 sizeof(tDot11fIEWscProbeRes));
Jeff Johnson295189b2012-06-20 16:38:30 -0700474 }
475 }
476
477 }
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700478 nStatus = dot11fPackBeacon2( pMac, pBcn2,
Jeff Johnson295189b2012-06-20 16:38:30 -0700479 pMac->sch.schObject.gSchBeaconFrameEnd,
480 SCH_MAX_BEACON_SIZE, &nBytes );
481 if ( DOT11F_FAILED( nStatus ) )
482 {
483 schLog( pMac, LOGE, FL("Failed to packed a tDot11fBeacon2 (0x%0"
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700484 "8x.)."), nStatus );
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530485 vos_mem_free(pBcn1);
486 vos_mem_free(pBcn2);
487 vos_mem_free(pWscProbeRes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700488 return eSIR_FAILURE;
489 }
490 else if ( DOT11F_WARNED( nStatus ) )
491 {
492 schLog( pMac, LOGE, FL("There were warnings while packing a tDo"
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700493 "t11fBeacon2 (0x%08x.)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700494 }
495
Jeff Johnson295189b2012-06-20 16:38:30 -0700496 pExtraIe = pMac->sch.schObject.gSchBeaconFrameEnd + nBytes;
497 extraIeOffset = nBytes;
Jeff Johnson295189b2012-06-20 16:38:30 -0700498
499 //TODO: Append additional IE here.
500 schAppendAddnIE(pMac, psessionEntry,
501 pMac->sch.schObject.gSchBeaconFrameEnd + nBytes,
502 SCH_MAX_BEACON_SIZE, &nBytes);
503
504 pMac->sch.schObject.gSchBeaconOffsetEnd = ( tANI_U16 )nBytes;
505
Jeff Johnson295189b2012-06-20 16:38:30 -0700506 extraIeLen = nBytes - extraIeOffset;
507
508 //Get the p2p Ie Offset
509 status = schGetP2pIeOffset(pExtraIe, extraIeLen, &p2pIeOffset);
510
511 if(eSIR_SUCCESS == status)
512 {
513 //Update the P2P Ie Offset
514 pMac->sch.schObject.p2pIeOffset =
515 pMac->sch.schObject.gSchBeaconOffsetBegin + TIM_IE_SIZE +
516 extraIeOffset + p2pIeOffset;
517 }
518 else
519 {
520 pMac->sch.schObject.p2pIeOffset = 0;
521 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700522
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700523 schLog( pMac, LOG1, FL("Initialized beacon end, offset %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700524 pMac->sch.schObject.gSchBeaconOffsetEnd );
525
526 pMac->sch.schObject.fBeaconChanged = 1;
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530527 vos_mem_free(pBcn1);
528 vos_mem_free(pBcn2);
529 vos_mem_free(pWscProbeRes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700530 return eSIR_SUCCESS;
531}
532
Kapil Guptad4c78142016-10-03 16:40:38 +0530533tSirRetStatus limUpdateProbeRspTemplateIeBitmapBeacon1(tpAniSirGlobal pMac,
Jeff Johnson295189b2012-06-20 16:38:30 -0700534 tDot11fBeacon1* beacon1,
Kapil Guptad4c78142016-10-03 16:40:38 +0530535 tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -0700536{
Kapil Guptad4c78142016-10-03 16:40:38 +0530537 tANI_U32* DefProbeRspIeBitmap;
538 tDot11fProbeResponse* prb_rsp;
539
540 if (!psessionEntry) {
541 schLog(pMac, LOGE, FL("PESession is null!"));
542 return eSIR_FAILURE;
543 }
544
545 DefProbeRspIeBitmap = &psessionEntry->DefProbeRspIeBitmap[0];
546 prb_rsp = &psessionEntry->probeRespFrame;
547
Jeff Johnson295189b2012-06-20 16:38:30 -0700548 prb_rsp->BeaconInterval = beacon1->BeaconInterval;
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530549 vos_mem_copy((void *)&prb_rsp->Capabilities, (void *)&beacon1->Capabilities,
550 sizeof(beacon1->Capabilities));
Jeff Johnson295189b2012-06-20 16:38:30 -0700551
552 /* SSID */
553 if(beacon1->SSID.present)
554 {
555 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_SSID_EID);
Kapil Guptad4c78142016-10-03 16:40:38 +0530556 /* populating it, because probe response has to go with
557 * SSID even in hidden case
558 */
559 PopulateDot11fSSID(pMac, &psessionEntry->ssId, &prb_rsp->SSID);
Jeff Johnson295189b2012-06-20 16:38:30 -0700560 }
561 /* supported rates */
562 if(beacon1->SuppRates.present)
563 {
564 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_RATESET_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530565 vos_mem_copy((void *)&prb_rsp->SuppRates, (void *)&beacon1->SuppRates,
566 sizeof(beacon1->SuppRates));
Jeff Johnson295189b2012-06-20 16:38:30 -0700567
568 }
569 /* DS Parameter set */
570 if(beacon1->DSParams.present)
571 {
572 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_DS_PARAM_SET_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530573 vos_mem_copy((void *)&prb_rsp->DSParams, (void *)&beacon1->DSParams,
574 sizeof(beacon1->DSParams));
Jeff Johnson295189b2012-06-20 16:38:30 -0700575
576 }
577
578 /* IBSS params will not be present in the Beacons transmitted by AP */
Kapil Guptad4c78142016-10-03 16:40:38 +0530579
580 return eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700581}
582
583void limUpdateProbeRspTemplateIeBitmapBeacon2(tpAniSirGlobal pMac,
584 tDot11fBeacon2* beacon2,
585 tANI_U32* DefProbeRspIeBitmap,
586 tDot11fProbeResponse* prb_rsp)
587{
588 /* IBSS parameter set - will not be present in probe response tx by AP */
589 /* country */
590 if(beacon2->Country.present)
591 {
592 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_COUNTRY_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530593 vos_mem_copy((void *)&prb_rsp->Country, (void *)&beacon2->Country,
594 sizeof(beacon2->Country));
Jeff Johnson295189b2012-06-20 16:38:30 -0700595
596 }
597 /* Power constraint */
598 if(beacon2->PowerConstraints.present)
599 {
600 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_PWR_CONSTRAINT_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530601 vos_mem_copy((void *)&prb_rsp->PowerConstraints, (void *)&beacon2->PowerConstraints,
602 sizeof(beacon2->PowerConstraints));
Jeff Johnson295189b2012-06-20 16:38:30 -0700603
604 }
Abhishek Singh02605092017-10-25 14:06:12 +0530605
606 if (beacon2->ext_chan_switch_ann.present) {
607 SetProbeRspIeBitmap(DefProbeRspIeBitmap,
608 SIR_MAC_EXT_CHNL_SWITCH_ANN_EID);
609 vos_mem_copy((void *)&prb_rsp->ext_chan_switch_ann,
610 (void *)&beacon2->ext_chan_switch_ann,
611 sizeof(beacon2->ext_chan_switch_ann));
612 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700613 /* Channel Switch Annoouncement SIR_MAC_CHNL_SWITCH_ANN_EID */
614 if(beacon2->ChanSwitchAnn.present)
615 {
616 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_CHNL_SWITCH_ANN_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530617 vos_mem_copy((void *)&prb_rsp->ChanSwitchAnn, (void *)&beacon2->ChanSwitchAnn,
618 sizeof(beacon2->ChanSwitchAnn));
Abhishek Singh02605092017-10-25 14:06:12 +0530619 if (beacon2->WiderBWChanSwitchAnn.present)
620 {
621 SetProbeRspIeBitmap(DefProbeRspIeBitmap,
622 SIR_MAC_WIDER_BW_CHANNEL_SWITCH_ANN);
623 vos_mem_copy((void *)&prb_rsp->WiderBWChanSwitchAnn,
624 (void *)&beacon2->WiderBWChanSwitchAnn,
625 sizeof(beacon2->WiderBWChanSwitchAnn));
626 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700627 }
628 /* ERP information */
629 if(beacon2->ERPInfo.present)
630 {
631 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_ERP_INFO_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530632 vos_mem_copy((void *)&prb_rsp->ERPInfo, (void *)&beacon2->ERPInfo,
633 sizeof(beacon2->ERPInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -0700634
635 }
636 /* Extended supported rates */
637 if(beacon2->ExtSuppRates.present)
638 {
639 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_EXTENDED_RATE_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530640 vos_mem_copy((void *)&prb_rsp->ExtSuppRates, (void *)&beacon2->ExtSuppRates,
641 sizeof(beacon2->ExtSuppRates));
Jeff Johnson295189b2012-06-20 16:38:30 -0700642
643 }
644
645 /* WPA */
646 if(beacon2->WPA.present)
647 {
648 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_WPA_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530649 vos_mem_copy((void *)&prb_rsp->WPA, (void *)&beacon2->WPA,
650 sizeof(beacon2->WPA));
Jeff Johnson295189b2012-06-20 16:38:30 -0700651
652 }
653
654 /* RSN */
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700655 if(beacon2->RSNOpaque.present)
Jeff Johnson295189b2012-06-20 16:38:30 -0700656 {
657 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_RSN_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530658 vos_mem_copy((void *)&prb_rsp->RSNOpaque, (void *)&beacon2->RSNOpaque,
659 sizeof(beacon2->RSNOpaque));
Jeff Johnson295189b2012-06-20 16:38:30 -0700660 }
661/*
662 // BSS load
663 if(beacon2->QBSSLoad.present)
664 {
665 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_QBSS_LOAD_EID);
666 }
667*/
668 /* EDCA Parameter set */
669 if(beacon2->EDCAParamSet.present)
670 {
671 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_EDCA_PARAM_SET_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530672 vos_mem_copy((void *)&prb_rsp->EDCAParamSet, (void *)&beacon2->EDCAParamSet,
673 sizeof(beacon2->EDCAParamSet));
Jeff Johnson295189b2012-06-20 16:38:30 -0700674
675 }
676 /* Vendor specific - currently no vendor specific IEs added */
677 /* Requested IEs - currently we are not processing this will be added later */
678 //HT capability IE
679 if(beacon2->HTCaps.present)
680 {
681 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_HT_CAPABILITIES_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530682 vos_mem_copy((void *)&prb_rsp->HTCaps, (void *)&beacon2->HTCaps,
683 sizeof(beacon2->HTCaps));
Jeff Johnson295189b2012-06-20 16:38:30 -0700684 }
685 // HT Info IE
686 if(beacon2->HTInfo.present)
687 {
688 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_HT_INFO_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530689 vos_mem_copy((void *)&prb_rsp->HTInfo, (void *)&beacon2->HTInfo,
690 sizeof(beacon2->HTInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -0700691 }
692
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530693#ifdef WLAN_FEATURE_AP_HT40_24G
694 // Overlapping BSS Scan Parameters IE
695 if (pMac->roam.configParam.apHT40_24GEnabled)
696 {
697 if (beacon2->OBSSScanParameters.present)
698 {
699 SetProbeRspIeBitmap(DefProbeRspIeBitmap,
700 SIR_MAC_OBSS_SCAN_PARAMETERS_EID);
701 vos_mem_copy((void *)&prb_rsp->OBSSScanParameters,
702 (void *)&beacon2->OBSSScanParameters,
703 sizeof(beacon2->OBSSScanParameters));
704 }
705
706 if (beacon2->ExtCap.present)
707 {
708 SetProbeRspIeBitmap(DefProbeRspIeBitmap,
709 SIR_MAC_EXTENDED_CAPABILITIES_EID);
710 vos_mem_copy((void *)&prb_rsp->ExtCap,
711 (void *)&beacon2->ExtCap,
712 sizeof(beacon2->ExtCap));
713
714 }
715 }
716#endif
717
Jeff Johnsone7245742012-09-05 17:12:55 -0700718#ifdef WLAN_FEATURE_11AC
719 if(beacon2->VHTCaps.present)
720 {
721 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_VHT_CAPABILITIES_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530722 vos_mem_copy((void *)&prb_rsp->VHTCaps, (void *)&beacon2->VHTCaps,
723 sizeof(beacon2->VHTCaps));
Jeff Johnsone7245742012-09-05 17:12:55 -0700724 }
725 if(beacon2->VHTOperation.present)
726 {
727 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_VHT_OPERATION_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530728 vos_mem_copy((void *)&prb_rsp->VHTOperation, (void *)&beacon2->VHTOperation,
729 sizeof(beacon2->VHTOperation));
Jeff Johnsone7245742012-09-05 17:12:55 -0700730 }
731 if(beacon2->VHTExtBssLoad.present)
732 {
733 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_VHT_EXT_BSS_LOAD_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530734 vos_mem_copy((void *)&prb_rsp->VHTExtBssLoad, (void *)&beacon2->VHTExtBssLoad,
735 sizeof(beacon2->VHTExtBssLoad));
Jeff Johnsone7245742012-09-05 17:12:55 -0700736 }
737#endif
738
Jeff Johnson295189b2012-06-20 16:38:30 -0700739 //WMM IE
740 if(beacon2->WMMParams.present)
741 {
742 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_WPA_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530743 vos_mem_copy((void *)&prb_rsp->WMMParams, (void *)&beacon2->WMMParams,
744 sizeof(beacon2->WMMParams));
Jeff Johnson295189b2012-06-20 16:38:30 -0700745 }
746 //WMM capability - most of the case won't be present
747 if(beacon2->WMMCaps.present)
748 {
749 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_WPA_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530750 vos_mem_copy((void *)&prb_rsp->WMMCaps, (void *)&beacon2->WMMCaps,
751 sizeof(beacon2->WMMCaps));
Jeff Johnson295189b2012-06-20 16:38:30 -0700752 }
753
754}
755
756void SetProbeRspIeBitmap(tANI_U32* IeBitmap,tANI_U32 pos)
757{
758 tANI_U32 index,temp;
759
760 index = pos >> 5;
761 if(index >= 8 )
762 {
763 return;
764 }
765 temp = IeBitmap[index];
766
767 temp |= 1 << (pos & 0x1F);
768
769 IeBitmap[index] = temp;
770}
771
Jeff Johnson295189b2012-06-20 16:38:30 -0700772
Jeff Johnson295189b2012-06-20 16:38:30 -0700773
774// --------------------------------------------------------------------
775/**
776 * writeBeaconToMemory
777 *
778 * FUNCTION:
779 *
780 * LOGIC:
781 *
782 * ASSUMPTIONS:
783 *
784 * NOTE:
785 *
786 * @param None
787 * @param size Size of the beacon to write to memory
788 * @param length Length field of the beacon to write to memory
789 * @return None
790 */
791
792void writeBeaconToMemory(tpAniSirGlobal pMac, tANI_U16 size, tANI_U16 length, tpPESession psessionEntry)
793{
794 tANI_U16 i;
795 tpAniBeaconStruct pBeacon;
796
797 // copy end of beacon only if length > 0
798 if (length > 0)
799 {
bingsf950e552019-12-04 14:13:05 +0800800 if (size + pMac->sch.schObject.gSchBeaconOffsetEnd >
801 SCH_MAX_BEACON_SIZE) {
802 PELOGE(schLog(pMac, LOGE,
803 FL("beacon template fail size %d BeaconOffsetEnd %d"),
804 size, pMac->sch.schObject.gSchBeaconOffsetEnd);)
805 return;
806 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700807 for (i=0; i < pMac->sch.schObject.gSchBeaconOffsetEnd; i++)
808 pMac->sch.schObject.gSchBeaconFrameBegin[size++] = pMac->sch.schObject.gSchBeaconFrameEnd[i];
809 }
810
811 // Update the beacon length
812 pBeacon = (tpAniBeaconStruct) pMac->sch.schObject.gSchBeaconFrameBegin;
813 // Do not include the beaconLength indicator itself
814 if (length == 0)
815 {
816 pBeacon->beaconLength = 0;
817 // Dont copy entire beacon, Copy length field alone
818 size = 4;
819 }
820 else
821 pBeacon->beaconLength = (tANI_U32) size - sizeof( tANI_U32 );
822
823 // write size bytes from gSchBeaconFrameBegin
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700824 PELOG2(schLog(pMac, LOG2, FL("Beacon size - %d bytes"), size);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700825 PELOG2(sirDumpBuf(pMac, SIR_SCH_MODULE_ID, LOG2, pMac->sch.schObject.gSchBeaconFrameBegin, size);)
826
827 if (! pMac->sch.schObject.fBeaconChanged)
828 return;
829
830 pMac->sch.gSchGenBeacon = 1;
831 if (pMac->sch.gSchGenBeacon)
832 {
833 pMac->sch.gSchBeaconsSent++;
834
835 //
836 // Copy beacon data to SoftMAC shared memory...
837 // Do this by sending a message to HAL
838 //
839
840 size = (size + 3) & (~3);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530841 if( eSIR_SUCCESS != schSendBeaconReq( pMac, pMac->sch.schObject.gSchBeaconFrameBegin,
842 size, psessionEntry))
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700843 PELOGE(schLog(pMac, LOGE, FL("schSendBeaconReq() returned an error (zsize %d)"), size);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700844 else
845 {
846 pMac->sch.gSchBeaconsWritten++;
847 }
848 }
849 pMac->sch.schObject.fBeaconChanged = 0;
850}
851
852// --------------------------------------------------------------------
853/**
854 * @function: SchProcessPreBeaconInd
855 *
856 * @brief : Process the PreBeacon Indication from the Lim
857 *
858 * ASSUMPTIONS:
859 *
860 * NOTE:
861 *
862 * @param : pMac - tpAniSirGlobal
863 *
864 * @return None
865 */
866
867void
868schProcessPreBeaconInd(tpAniSirGlobal pMac, tpSirMsgQ limMsg)
869{
870 tpBeaconGenParams pMsg = (tpBeaconGenParams)limMsg->bodyptr;
871 tANI_U32 beaconSize = pMac->sch.schObject.gSchBeaconOffsetBegin;
872 tpPESession psessionEntry;
873 tANI_U8 sessionId;
874
875 if((psessionEntry = peFindSessionByBssid(pMac,pMsg->bssId, &sessionId))== NULL)
876 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700877 PELOGE(schLog(pMac, LOGE, FL("session lookup fails"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700878 goto end;
879 }
880
881
882
883 // If SME is not in normal mode, no need to generate beacon
884 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE)
885 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700886 PELOGE(schLog(pMac, LOG1, FL("PreBeaconInd received in invalid state: %d"), psessionEntry->limSmeState);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700887 goto end;
888 }
889
890 switch(psessionEntry->limSystemRole){
891
892 case eLIM_STA_IN_IBSS_ROLE:
893 case eLIM_BT_AMP_AP_ROLE:
894 case eLIM_BT_AMP_STA_ROLE:
895 // generate IBSS parameter set
896 if(psessionEntry->statypeForBss == STA_ENTRY_SELF)
897 writeBeaconToMemory(pMac, (tANI_U16) beaconSize, (tANI_U16)beaconSize, psessionEntry);
898 else
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700899 PELOGE(schLog(pMac, LOGE, FL("can not send beacon for PEER session entry"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700900 break;
901
Jeff Johnson295189b2012-06-20 16:38:30 -0700902 case eLIM_AP_ROLE:{
903 tANI_U8 *ptr = &pMac->sch.schObject.gSchBeaconFrameBegin[pMac->sch.schObject.gSchBeaconOffsetBegin];
904 tANI_U16 timLength = 0;
905 if(psessionEntry->statypeForBss == STA_ENTRY_SELF){
906 pmmGenerateTIM(pMac, &ptr, &timLength, psessionEntry->dtimPeriod);
907 beaconSize += 2 + timLength;
908 writeBeaconToMemory(pMac, (tANI_U16) beaconSize, (tANI_U16)beaconSize, psessionEntry);
909 }
910 else
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700911 PELOGE(schLog(pMac, LOGE, FL("can not send beacon for PEER session entry"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700912 }
913 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700914
Jeff Johnson295189b2012-06-20 16:38:30 -0700915
916 default:
917 PELOGE(schLog(pMac, LOGE, FL("Error-PE has Receive PreBeconGenIndication when System is in %d role"),
918 psessionEntry->limSystemRole);)
919 }
920
921end:
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530922 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700923
924}