blob: 0fc798995ae4202d67d41e5d0b5d55e1082988f6 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Rajeev Kumar Sirasanagandla63f85cf2016-06-29 16:52:15 +05302 * Copyright (c) 2012-2016 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
380 PopulateDot11fExtSuppRates( pMac, POPULATE_DOT11F_RATES_OPERATIONAL,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700381 &pBcn2->ExtSuppRates, psessionEntry );
Jeff Johnson295189b2012-06-20 16:38:30 -0700382
383 if( psessionEntry->pLimStartBssReq != NULL )
384 {
385 PopulateDot11fWPA( pMac, &psessionEntry->pLimStartBssReq->rsnIE,
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700386 &pBcn2->WPA );
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700387 PopulateDot11fRSNOpaque( pMac, &psessionEntry->pLimStartBssReq->rsnIE,
388 &pBcn2->RSNOpaque );
Jeff Johnson295189b2012-06-20 16:38:30 -0700389 }
390
391 if(psessionEntry->limWmeEnabled)
392 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700393 PopulateDot11fWMM( pMac, &pBcn2->WMMInfoAp, &pBcn2->WMMParams, &pBcn2->WMMCaps, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700394 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700395 if(psessionEntry->limSystemRole == eLIM_AP_ROLE)
396 {
397 if(psessionEntry->wps_state != SAP_WPS_DISABLED)
398 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700399 PopulateDot11fBeaconWPSIEs( pMac, &pBcn2->WscBeacon, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700400 }
401 }
402 else
403 {
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800404 if (wlan_cfgGetInt(pMac, (tANI_U16) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS)
Katya Nigam70d68332013-09-16 16:49:45 +0530405 schLog(pMac, LOGP,"Failed to cfg get id %d", WNI_CFG_WPS_ENABLE );
Jeff Johnson3c3e1782013-02-27 10:48:42 -0800406
407 wpsApEnable = tmp & WNI_CFG_WPS_ENABLE_AP;
408
409 if (wpsApEnable)
410 {
411 PopulateDot11fWsc(pMac, &pBcn2->WscBeacon);
412 }
413
414 if (pMac->lim.wscIeInfo.wscEnrollmentState == eLIM_WSC_ENROLL_BEGIN)
415 {
416 PopulateDot11fWscRegistrarInfo(pMac, &pBcn2->WscBeacon);
417 pMac->lim.wscIeInfo.wscEnrollmentState = eLIM_WSC_ENROLL_IN_PROGRESS;
418 }
419
420 if (pMac->lim.wscIeInfo.wscEnrollmentState == eLIM_WSC_ENROLL_END)
421 {
422 DePopulateDot11fWscRegistrarInfo(pMac, &pBcn2->WscBeacon);
423 pMac->lim.wscIeInfo.wscEnrollmentState = eLIM_WSC_ENROLL_NOOP;
424 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700425 }
426
Jeff Johnson295189b2012-06-20 16:38:30 -0700427 if((psessionEntry->limSystemRole == eLIM_AP_ROLE)
Sachin Ahuja825082e2014-11-25 17:34:36 +0530428 && ((psessionEntry->proxyProbeRspEn)
429 || (IS_FEATURE_SUPPORTED_BY_FW(WPS_PRBRSP_TMPL)))
Rajeev Kumar Sirasanagandla63f85cf2016-06-29 16:52:15 +0530430 && vos_is_probe_rsp_offload_enabled()
Sachin Ahuja825082e2014-11-25 17:34:36 +0530431 )
Jeff Johnson295189b2012-06-20 16:38:30 -0700432 {
433 /* Can be efficiently updated whenever new IE added in Probe response in future */
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700434 limUpdateProbeRspTemplateIeBitmapBeacon2(pMac,pBcn2,&psessionEntry->DefProbeRspIeBitmap[0],
Jeff Johnson295189b2012-06-20 16:38:30 -0700435 &psessionEntry->probeRespFrame);
436
437 /* update probe response WPS IE instead of beacon WPS IE
438 * */
439 if(psessionEntry->wps_state != SAP_WPS_DISABLED)
440 {
441 if(psessionEntry->APWPSIEs.SirWPSProbeRspIE.FieldPresent)
442 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700443 PopulateDot11fProbeResWPSIEs(pMac, pWscProbeRes, psessionEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700444 }
445 else
446 {
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700447 pWscProbeRes->present = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700448 }
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700449 if(pWscProbeRes->present)
Jeff Johnson295189b2012-06-20 16:38:30 -0700450 {
451 SetProbeRspIeBitmap(&psessionEntry->DefProbeRspIeBitmap[0],SIR_MAC_WPA_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530452 vos_mem_copy((void *)&psessionEntry->probeRespFrame.WscProbeRes,
453 (void *)pWscProbeRes,
454 sizeof(tDot11fIEWscProbeRes));
Jeff Johnson295189b2012-06-20 16:38:30 -0700455 }
456 }
457
458 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700459
Madan Mohan Koyyalamudi19032762012-10-21 12:42:11 -0700460 nStatus = dot11fPackBeacon2( pMac, pBcn2,
Jeff Johnson295189b2012-06-20 16:38:30 -0700461 pMac->sch.schObject.gSchBeaconFrameEnd,
462 SCH_MAX_BEACON_SIZE, &nBytes );
463 if ( DOT11F_FAILED( nStatus ) )
464 {
465 schLog( pMac, LOGE, FL("Failed to packed a tDot11fBeacon2 (0x%0"
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700466 "8x.)."), nStatus );
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530467 vos_mem_free(pBcn1);
468 vos_mem_free(pBcn2);
469 vos_mem_free(pWscProbeRes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700470 return eSIR_FAILURE;
471 }
472 else if ( DOT11F_WARNED( nStatus ) )
473 {
474 schLog( pMac, LOGE, FL("There were warnings while packing a tDo"
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700475 "t11fBeacon2 (0x%08x.)."), nStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700476 }
477
Jeff Johnson295189b2012-06-20 16:38:30 -0700478 pExtraIe = pMac->sch.schObject.gSchBeaconFrameEnd + nBytes;
479 extraIeOffset = nBytes;
Jeff Johnson295189b2012-06-20 16:38:30 -0700480
481 //TODO: Append additional IE here.
482 schAppendAddnIE(pMac, psessionEntry,
483 pMac->sch.schObject.gSchBeaconFrameEnd + nBytes,
484 SCH_MAX_BEACON_SIZE, &nBytes);
485
486 pMac->sch.schObject.gSchBeaconOffsetEnd = ( tANI_U16 )nBytes;
487
Jeff Johnson295189b2012-06-20 16:38:30 -0700488 extraIeLen = nBytes - extraIeOffset;
489
490 //Get the p2p Ie Offset
491 status = schGetP2pIeOffset(pExtraIe, extraIeLen, &p2pIeOffset);
492
493 if(eSIR_SUCCESS == status)
494 {
495 //Update the P2P Ie Offset
496 pMac->sch.schObject.p2pIeOffset =
497 pMac->sch.schObject.gSchBeaconOffsetBegin + TIM_IE_SIZE +
498 extraIeOffset + p2pIeOffset;
499 }
500 else
501 {
502 pMac->sch.schObject.p2pIeOffset = 0;
503 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700504
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700505 schLog( pMac, LOG1, FL("Initialized beacon end, offset %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -0700506 pMac->sch.schObject.gSchBeaconOffsetEnd );
507
508 pMac->sch.schObject.fBeaconChanged = 1;
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530509 vos_mem_free(pBcn1);
510 vos_mem_free(pBcn2);
511 vos_mem_free(pWscProbeRes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700512 return eSIR_SUCCESS;
513}
514
Kapil Guptad4c78142016-10-03 16:40:38 +0530515tSirRetStatus limUpdateProbeRspTemplateIeBitmapBeacon1(tpAniSirGlobal pMac,
Jeff Johnson295189b2012-06-20 16:38:30 -0700516 tDot11fBeacon1* beacon1,
Kapil Guptad4c78142016-10-03 16:40:38 +0530517 tpPESession psessionEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -0700518{
Kapil Guptad4c78142016-10-03 16:40:38 +0530519 tANI_U32* DefProbeRspIeBitmap;
520 tDot11fProbeResponse* prb_rsp;
521
522 if (!psessionEntry) {
523 schLog(pMac, LOGE, FL("PESession is null!"));
524 return eSIR_FAILURE;
525 }
526
527 DefProbeRspIeBitmap = &psessionEntry->DefProbeRspIeBitmap[0];
528 prb_rsp = &psessionEntry->probeRespFrame;
529
Jeff Johnson295189b2012-06-20 16:38:30 -0700530 prb_rsp->BeaconInterval = beacon1->BeaconInterval;
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530531 vos_mem_copy((void *)&prb_rsp->Capabilities, (void *)&beacon1->Capabilities,
532 sizeof(beacon1->Capabilities));
Jeff Johnson295189b2012-06-20 16:38:30 -0700533
534 /* SSID */
535 if(beacon1->SSID.present)
536 {
537 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_SSID_EID);
Kapil Guptad4c78142016-10-03 16:40:38 +0530538 /* populating it, because probe response has to go with
539 * SSID even in hidden case
540 */
541 PopulateDot11fSSID(pMac, &psessionEntry->ssId, &prb_rsp->SSID);
Jeff Johnson295189b2012-06-20 16:38:30 -0700542 }
543 /* supported rates */
544 if(beacon1->SuppRates.present)
545 {
546 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_RATESET_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530547 vos_mem_copy((void *)&prb_rsp->SuppRates, (void *)&beacon1->SuppRates,
548 sizeof(beacon1->SuppRates));
Jeff Johnson295189b2012-06-20 16:38:30 -0700549
550 }
551 /* DS Parameter set */
552 if(beacon1->DSParams.present)
553 {
554 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_DS_PARAM_SET_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530555 vos_mem_copy((void *)&prb_rsp->DSParams, (void *)&beacon1->DSParams,
556 sizeof(beacon1->DSParams));
Jeff Johnson295189b2012-06-20 16:38:30 -0700557
558 }
559
560 /* IBSS params will not be present in the Beacons transmitted by AP */
Kapil Guptad4c78142016-10-03 16:40:38 +0530561
562 return eSIR_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700563}
564
565void limUpdateProbeRspTemplateIeBitmapBeacon2(tpAniSirGlobal pMac,
566 tDot11fBeacon2* beacon2,
567 tANI_U32* DefProbeRspIeBitmap,
568 tDot11fProbeResponse* prb_rsp)
569{
570 /* IBSS parameter set - will not be present in probe response tx by AP */
571 /* country */
572 if(beacon2->Country.present)
573 {
574 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_COUNTRY_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530575 vos_mem_copy((void *)&prb_rsp->Country, (void *)&beacon2->Country,
576 sizeof(beacon2->Country));
Jeff Johnson295189b2012-06-20 16:38:30 -0700577
578 }
579 /* Power constraint */
580 if(beacon2->PowerConstraints.present)
581 {
582 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_PWR_CONSTRAINT_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530583 vos_mem_copy((void *)&prb_rsp->PowerConstraints, (void *)&beacon2->PowerConstraints,
584 sizeof(beacon2->PowerConstraints));
Jeff Johnson295189b2012-06-20 16:38:30 -0700585
586 }
587 /* Channel Switch Annoouncement SIR_MAC_CHNL_SWITCH_ANN_EID */
588 if(beacon2->ChanSwitchAnn.present)
589 {
590 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_CHNL_SWITCH_ANN_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530591 vos_mem_copy((void *)&prb_rsp->ChanSwitchAnn, (void *)&beacon2->ChanSwitchAnn,
592 sizeof(beacon2->ChanSwitchAnn));
Jeff Johnson295189b2012-06-20 16:38:30 -0700593
594 }
595 /* ERP information */
596 if(beacon2->ERPInfo.present)
597 {
598 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_ERP_INFO_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530599 vos_mem_copy((void *)&prb_rsp->ERPInfo, (void *)&beacon2->ERPInfo,
600 sizeof(beacon2->ERPInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -0700601
602 }
603 /* Extended supported rates */
604 if(beacon2->ExtSuppRates.present)
605 {
606 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_EXTENDED_RATE_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530607 vos_mem_copy((void *)&prb_rsp->ExtSuppRates, (void *)&beacon2->ExtSuppRates,
608 sizeof(beacon2->ExtSuppRates));
Jeff Johnson295189b2012-06-20 16:38:30 -0700609
610 }
611
612 /* WPA */
613 if(beacon2->WPA.present)
614 {
615 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_WPA_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530616 vos_mem_copy((void *)&prb_rsp->WPA, (void *)&beacon2->WPA,
617 sizeof(beacon2->WPA));
Jeff Johnson295189b2012-06-20 16:38:30 -0700618
619 }
620
621 /* RSN */
Chet Lanctot4b9abd72013-06-27 11:14:56 -0700622 if(beacon2->RSNOpaque.present)
Jeff Johnson295189b2012-06-20 16:38:30 -0700623 {
624 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_RSN_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530625 vos_mem_copy((void *)&prb_rsp->RSNOpaque, (void *)&beacon2->RSNOpaque,
626 sizeof(beacon2->RSNOpaque));
Jeff Johnson295189b2012-06-20 16:38:30 -0700627 }
628/*
629 // BSS load
630 if(beacon2->QBSSLoad.present)
631 {
632 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_QBSS_LOAD_EID);
633 }
634*/
635 /* EDCA Parameter set */
636 if(beacon2->EDCAParamSet.present)
637 {
638 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_EDCA_PARAM_SET_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530639 vos_mem_copy((void *)&prb_rsp->EDCAParamSet, (void *)&beacon2->EDCAParamSet,
640 sizeof(beacon2->EDCAParamSet));
Jeff Johnson295189b2012-06-20 16:38:30 -0700641
642 }
643 /* Vendor specific - currently no vendor specific IEs added */
644 /* Requested IEs - currently we are not processing this will be added later */
645 //HT capability IE
646 if(beacon2->HTCaps.present)
647 {
648 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_HT_CAPABILITIES_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530649 vos_mem_copy((void *)&prb_rsp->HTCaps, (void *)&beacon2->HTCaps,
650 sizeof(beacon2->HTCaps));
Jeff Johnson295189b2012-06-20 16:38:30 -0700651 }
652 // HT Info IE
653 if(beacon2->HTInfo.present)
654 {
655 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_HT_INFO_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530656 vos_mem_copy((void *)&prb_rsp->HTInfo, (void *)&beacon2->HTInfo,
657 sizeof(beacon2->HTInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -0700658 }
659
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +0530660#ifdef WLAN_FEATURE_AP_HT40_24G
661 // Overlapping BSS Scan Parameters IE
662 if (pMac->roam.configParam.apHT40_24GEnabled)
663 {
664 if (beacon2->OBSSScanParameters.present)
665 {
666 SetProbeRspIeBitmap(DefProbeRspIeBitmap,
667 SIR_MAC_OBSS_SCAN_PARAMETERS_EID);
668 vos_mem_copy((void *)&prb_rsp->OBSSScanParameters,
669 (void *)&beacon2->OBSSScanParameters,
670 sizeof(beacon2->OBSSScanParameters));
671 }
672
673 if (beacon2->ExtCap.present)
674 {
675 SetProbeRspIeBitmap(DefProbeRspIeBitmap,
676 SIR_MAC_EXTENDED_CAPABILITIES_EID);
677 vos_mem_copy((void *)&prb_rsp->ExtCap,
678 (void *)&beacon2->ExtCap,
679 sizeof(beacon2->ExtCap));
680
681 }
682 }
683#endif
684
Jeff Johnsone7245742012-09-05 17:12:55 -0700685#ifdef WLAN_FEATURE_11AC
686 if(beacon2->VHTCaps.present)
687 {
688 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_VHT_CAPABILITIES_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530689 vos_mem_copy((void *)&prb_rsp->VHTCaps, (void *)&beacon2->VHTCaps,
690 sizeof(beacon2->VHTCaps));
Jeff Johnsone7245742012-09-05 17:12:55 -0700691 }
692 if(beacon2->VHTOperation.present)
693 {
694 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_VHT_OPERATION_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530695 vos_mem_copy((void *)&prb_rsp->VHTOperation, (void *)&beacon2->VHTOperation,
696 sizeof(beacon2->VHTOperation));
Jeff Johnsone7245742012-09-05 17:12:55 -0700697 }
698 if(beacon2->VHTExtBssLoad.present)
699 {
700 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_VHT_EXT_BSS_LOAD_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530701 vos_mem_copy((void *)&prb_rsp->VHTExtBssLoad, (void *)&beacon2->VHTExtBssLoad,
702 sizeof(beacon2->VHTExtBssLoad));
Jeff Johnsone7245742012-09-05 17:12:55 -0700703 }
704#endif
705
Jeff Johnson295189b2012-06-20 16:38:30 -0700706 //WMM IE
707 if(beacon2->WMMParams.present)
708 {
709 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_WPA_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530710 vos_mem_copy((void *)&prb_rsp->WMMParams, (void *)&beacon2->WMMParams,
711 sizeof(beacon2->WMMParams));
Jeff Johnson295189b2012-06-20 16:38:30 -0700712 }
713 //WMM capability - most of the case won't be present
714 if(beacon2->WMMCaps.present)
715 {
716 SetProbeRspIeBitmap(DefProbeRspIeBitmap,SIR_MAC_WPA_EID);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530717 vos_mem_copy((void *)&prb_rsp->WMMCaps, (void *)&beacon2->WMMCaps,
718 sizeof(beacon2->WMMCaps));
Jeff Johnson295189b2012-06-20 16:38:30 -0700719 }
720
721}
722
723void SetProbeRspIeBitmap(tANI_U32* IeBitmap,tANI_U32 pos)
724{
725 tANI_U32 index,temp;
726
727 index = pos >> 5;
728 if(index >= 8 )
729 {
730 return;
731 }
732 temp = IeBitmap[index];
733
734 temp |= 1 << (pos & 0x1F);
735
736 IeBitmap[index] = temp;
737}
738
Jeff Johnson295189b2012-06-20 16:38:30 -0700739
Jeff Johnson295189b2012-06-20 16:38:30 -0700740
741// --------------------------------------------------------------------
742/**
743 * writeBeaconToMemory
744 *
745 * FUNCTION:
746 *
747 * LOGIC:
748 *
749 * ASSUMPTIONS:
750 *
751 * NOTE:
752 *
753 * @param None
754 * @param size Size of the beacon to write to memory
755 * @param length Length field of the beacon to write to memory
756 * @return None
757 */
758
759void writeBeaconToMemory(tpAniSirGlobal pMac, tANI_U16 size, tANI_U16 length, tpPESession psessionEntry)
760{
761 tANI_U16 i;
762 tpAniBeaconStruct pBeacon;
763
764 // copy end of beacon only if length > 0
765 if (length > 0)
766 {
767 for (i=0; i < pMac->sch.schObject.gSchBeaconOffsetEnd; i++)
768 pMac->sch.schObject.gSchBeaconFrameBegin[size++] = pMac->sch.schObject.gSchBeaconFrameEnd[i];
769 }
770
771 // Update the beacon length
772 pBeacon = (tpAniBeaconStruct) pMac->sch.schObject.gSchBeaconFrameBegin;
773 // Do not include the beaconLength indicator itself
774 if (length == 0)
775 {
776 pBeacon->beaconLength = 0;
777 // Dont copy entire beacon, Copy length field alone
778 size = 4;
779 }
780 else
781 pBeacon->beaconLength = (tANI_U32) size - sizeof( tANI_U32 );
782
783 // write size bytes from gSchBeaconFrameBegin
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700784 PELOG2(schLog(pMac, LOG2, FL("Beacon size - %d bytes"), size);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700785 PELOG2(sirDumpBuf(pMac, SIR_SCH_MODULE_ID, LOG2, pMac->sch.schObject.gSchBeaconFrameBegin, size);)
786
787 if (! pMac->sch.schObject.fBeaconChanged)
788 return;
789
790 pMac->sch.gSchGenBeacon = 1;
791 if (pMac->sch.gSchGenBeacon)
792 {
793 pMac->sch.gSchBeaconsSent++;
794
795 //
796 // Copy beacon data to SoftMAC shared memory...
797 // Do this by sending a message to HAL
798 //
799
800 size = (size + 3) & (~3);
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530801 if( eSIR_SUCCESS != schSendBeaconReq( pMac, pMac->sch.schObject.gSchBeaconFrameBegin,
802 size, psessionEntry))
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700803 PELOGE(schLog(pMac, LOGE, FL("schSendBeaconReq() returned an error (zsize %d)"), size);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700804 else
805 {
806 pMac->sch.gSchBeaconsWritten++;
807 }
808 }
809 pMac->sch.schObject.fBeaconChanged = 0;
810}
811
812// --------------------------------------------------------------------
813/**
814 * @function: SchProcessPreBeaconInd
815 *
816 * @brief : Process the PreBeacon Indication from the Lim
817 *
818 * ASSUMPTIONS:
819 *
820 * NOTE:
821 *
822 * @param : pMac - tpAniSirGlobal
823 *
824 * @return None
825 */
826
827void
828schProcessPreBeaconInd(tpAniSirGlobal pMac, tpSirMsgQ limMsg)
829{
830 tpBeaconGenParams pMsg = (tpBeaconGenParams)limMsg->bodyptr;
831 tANI_U32 beaconSize = pMac->sch.schObject.gSchBeaconOffsetBegin;
832 tpPESession psessionEntry;
833 tANI_U8 sessionId;
834
835 if((psessionEntry = peFindSessionByBssid(pMac,pMsg->bssId, &sessionId))== NULL)
836 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700837 PELOGE(schLog(pMac, LOGE, FL("session lookup fails"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700838 goto end;
839 }
840
841
842
843 // If SME is not in normal mode, no need to generate beacon
844 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE)
845 {
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700846 PELOGE(schLog(pMac, LOG1, FL("PreBeaconInd received in invalid state: %d"), psessionEntry->limSmeState);)
Jeff Johnson295189b2012-06-20 16:38:30 -0700847 goto end;
848 }
849
850 switch(psessionEntry->limSystemRole){
851
852 case eLIM_STA_IN_IBSS_ROLE:
853 case eLIM_BT_AMP_AP_ROLE:
854 case eLIM_BT_AMP_STA_ROLE:
855 // generate IBSS parameter set
856 if(psessionEntry->statypeForBss == STA_ENTRY_SELF)
857 writeBeaconToMemory(pMac, (tANI_U16) beaconSize, (tANI_U16)beaconSize, psessionEntry);
858 else
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700859 PELOGE(schLog(pMac, LOGE, FL("can not send beacon for PEER session entry"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700860 break;
861
Jeff Johnson295189b2012-06-20 16:38:30 -0700862 case eLIM_AP_ROLE:{
863 tANI_U8 *ptr = &pMac->sch.schObject.gSchBeaconFrameBegin[pMac->sch.schObject.gSchBeaconOffsetBegin];
864 tANI_U16 timLength = 0;
865 if(psessionEntry->statypeForBss == STA_ENTRY_SELF){
866 pmmGenerateTIM(pMac, &ptr, &timLength, psessionEntry->dtimPeriod);
867 beaconSize += 2 + timLength;
868 writeBeaconToMemory(pMac, (tANI_U16) beaconSize, (tANI_U16)beaconSize, psessionEntry);
869 }
870 else
Kiran Kumar Lokereaf882c82013-03-18 16:07:05 -0700871 PELOGE(schLog(pMac, LOGE, FL("can not send beacon for PEER session entry"));)
Jeff Johnson295189b2012-06-20 16:38:30 -0700872 }
873 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700874
Jeff Johnson295189b2012-06-20 16:38:30 -0700875
876 default:
877 PELOGE(schLog(pMac, LOGE, FL("Error-PE has Receive PreBeconGenIndication when System is in %d role"),
878 psessionEntry->limSystemRole);)
879 }
880
881end:
Madan Mohan Koyyalamudifff03f22013-07-11 11:32:07 +0530882 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700883
884}