blob: d7f9872d6259c83e5d209f59399c0780a1bc6ba3 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002 * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -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.
20 */
21
22/*
23 * 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/*
29 * This file sch_beacon_gen.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 "cds_api.h"
41#include "wni_cfg.h"
42#include "ani_global.h"
43#include "sir_mac_prot_def.h"
44
45#include "lim_utils.h"
46#include "lim_api.h"
47
48#include "wma_if.h"
49#include "cfg_api.h"
50#include "sch_api.h"
51
52#include "parser_api.h"
53
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080054
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080055const uint8_t p2p_oui[] = { 0x50, 0x6F, 0x9A, 0x9 };
56
Jeff Johnsonaeebe652016-10-07 07:46:48 -070057static tSirRetStatus sch_get_p2p_ie_offset(uint8_t *pExtraIe,
58 uint32_t extraIeLen,
59 uint16_t *pP2pIeOffset)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080060{
61 tSirRetStatus status = eSIR_FAILURE;
62 *pP2pIeOffset = 0;
63
64 /* Extra IE is not present */
65 if (0 == extraIeLen) {
66 return status;
67 }
68 /* Calculate the P2P IE Offset */
69 do {
70 if (*pExtraIe == 0xDD) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +053071 if (!qdf_mem_cmp
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080072 ((void *)(pExtraIe + 2), &p2p_oui, sizeof(p2p_oui))) {
73 status = eSIR_SUCCESS;
74 break;
75 }
76 }
77
78 (*pP2pIeOffset)++;
79 pExtraIe++;
80 } while (--extraIeLen > 0);
81
82 return status;
83}
84
85/**
86 * sch_append_addn_ie() - adds additional IEs to frame
87 * @mac_ctx: mac global context
88 * @session: pe session pointer
89 * @frm: frame where additional IE is to be added
90 * @max_bcn_size: max beacon size
91 * @num_bytes: final size
Krishna Kumaar Natarajan164e6b02015-12-17 15:19:09 -080092 * @addn_ie: pointer to additional IE
93 * @addn_ielen: lenght of additional IE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080094 *
95 * Return: status of operation
96 */
Jeff Johnsonaeebe652016-10-07 07:46:48 -070097static tSirRetStatus
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080098sch_append_addn_ie(tpAniSirGlobal mac_ctx, tpPESession session,
Krishna Kumaar Natarajan164e6b02015-12-17 15:19:09 -080099 uint8_t *frm, uint32_t max_bcn_size, uint32_t *num_bytes,
100 uint8_t *addn_ie, uint16_t addn_ielen)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800101{
102 tSirRetStatus status = eSIR_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800103 uint8_t add_ie[WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN];
104 uint8_t *p2p_ie = NULL;
105 uint8_t noa_len = 0;
106 uint8_t noa_strm[SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN];
Krishna Kumaar Natarajan164e6b02015-12-17 15:19:09 -0800107 bool valid_ie;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800108
Krishna Kumaar Natarajan164e6b02015-12-17 15:19:09 -0800109 valid_ie = (addn_ielen <= WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN &&
110 addn_ielen && ((addn_ielen + *num_bytes) <= max_bcn_size));
111
112 if (!valid_ie)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800113 return status;
114
Krishna Kumaar Natarajan164e6b02015-12-17 15:19:09 -0800115 qdf_mem_copy(&add_ie[0], addn_ie, addn_ielen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800116
Krishna Kumaar Natarajan164e6b02015-12-17 15:19:09 -0800117 p2p_ie = limGetP2pIEPtr(mac_ctx, &add_ie[0], addn_ielen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800118 if ((p2p_ie != NULL) && !mac_ctx->beacon_offload) {
119 /* get NoA attribute stream P2P IE */
120 noa_len = lim_get_noa_attr_stream(mac_ctx, noa_strm, session);
121 if (noa_len) {
Krishna Kumaar Natarajan164e6b02015-12-17 15:19:09 -0800122 if ((noa_len + addn_ielen) <=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800123 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN) {
Krishna Kumaar Natarajan164e6b02015-12-17 15:19:09 -0800124 qdf_mem_copy(&add_ie[addn_ielen], noa_strm,
125 noa_len);
126 addn_ielen += noa_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800127 p2p_ie[1] += noa_len;
128 } else {
Srinivas Girigowdad98fcbf2017-03-19 21:04:06 -0700129 pe_err("Not able to insert NoA because of length constraint");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800130 }
131 }
132 }
Krishna Kumaar Natarajan164e6b02015-12-17 15:19:09 -0800133 if (addn_ielen <= WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA_LEN) {
134 qdf_mem_copy(frm, &add_ie[0], addn_ielen);
135 *num_bytes = *num_bytes + addn_ielen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800136 } else {
Srinivas Girigowdad98fcbf2017-03-19 21:04:06 -0700137 pe_warn("Not able to insert because of len constraint %d",
Krishna Kumaar Natarajan164e6b02015-12-17 15:19:09 -0800138 addn_ielen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800139 }
140 return status;
141}
142
143/**
144 * sch_set_fixed_beacon_fields() - sets the fixed params in beacon frame
145 * @mac_ctx: mac global context
146 * @session: pe session entry
147 * @band: out param, band caclculated
148 * @opr_ch: operating channels
149 *
150 * Return: status of operation
151 */
152
153tSirRetStatus
154sch_set_fixed_beacon_fields(tpAniSirGlobal mac_ctx, tpPESession session)
155{
156 tpAniBeaconStruct bcn_struct = (tpAniBeaconStruct)
157 session->pSchBeaconFrameBegin;
158 tpSirMacMgmtHdr mac;
159 uint16_t offset;
160 uint8_t *ptr;
161 tDot11fBeacon1 *bcn_1;
162 tDot11fBeacon2 *bcn_2;
163 uint32_t i, n_status, n_bytes;
164 uint32_t wps_ap_enable = 0, tmp;
165 tDot11fIEWscProbeRes *wsc_prb_res;
166 uint8_t *extra_ie = NULL;
167 uint32_t extra_ie_len = 0;
168 uint16_t extra_ie_offset = 0;
169 uint16_t p2p_ie_offset = 0;
170 tSirRetStatus status = eSIR_SUCCESS;
171 bool is_vht_enabled = false;
Krishna Kumaar Natarajan164e6b02015-12-17 15:19:09 -0800172 uint16_t addn_ielen = 0;
173 uint8_t *addn_ie = NULL;
174 tDot11fIEExtCap extracted_extcap;
175 bool extcap_present = true, addnie_present = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800176
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530177 bcn_1 = qdf_mem_malloc(sizeof(tDot11fBeacon1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800178 if (NULL == bcn_1) {
Srinivas Girigowdad98fcbf2017-03-19 21:04:06 -0700179 pe_err("Failed to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800180 return eSIR_MEM_ALLOC_FAILED;
181 }
182
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530183 bcn_2 = qdf_mem_malloc(sizeof(tDot11fBeacon2));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800184 if (NULL == bcn_2) {
Srinivas Girigowdad98fcbf2017-03-19 21:04:06 -0700185 pe_err("Failed to allocate memory");
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530186 qdf_mem_free(bcn_1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800187 return eSIR_MEM_ALLOC_FAILED;
188 }
189
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530190 wsc_prb_res = qdf_mem_malloc(sizeof(tDot11fIEWscProbeRes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800191 if (NULL == wsc_prb_res) {
Srinivas Girigowdad98fcbf2017-03-19 21:04:06 -0700192 pe_err("Failed to allocate memory");
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530193 qdf_mem_free(bcn_1);
194 qdf_mem_free(bcn_2);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800195 return eSIR_MEM_ALLOC_FAILED;
196 }
197
Srinivas Girigowdad98fcbf2017-03-19 21:04:06 -0700198 pe_debug("Setting fixed beacon fields");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800199
200 /*
201 * First set the fixed fields:
202 * set the TFP headers, set the mac header
203 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530204 qdf_mem_set((uint8_t *) &bcn_struct->macHdr, sizeof(tSirMacMgmtHdr), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800205 mac = (tpSirMacMgmtHdr) &bcn_struct->macHdr;
206 mac->fc.type = SIR_MAC_MGMT_FRAME;
207 mac->fc.subType = SIR_MAC_MGMT_BEACON;
208
209 for (i = 0; i < 6; i++)
210 mac->da[i] = 0xff;
211
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530212 qdf_mem_copy(mac->sa, session->selfMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800213 sizeof(session->selfMacAddr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530214 qdf_mem_copy(mac->bssId, session->bssId, sizeof(session->bssId));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800215
216 mac->fc.fromDS = 0;
217 mac->fc.toDS = 0;
218
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800219 /* Skip over the timestamp (it'll be updated later). */
220 bcn_1->BeaconInterval.interval =
Agrawal Ashish18361c52016-08-18 13:42:42 +0530221 session->beaconParams.beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800222 populate_dot11f_capabilities(mac_ctx, &bcn_1->Capabilities, session);
223 if (session->ssidHidden) {
224 bcn_1->SSID.present = 1;
225 /* rest of the fileds are 0 for hidden ssid */
226 if ((session->ssId.length) &&
227 (session->ssidHidden == eHIDDEN_SSID_ZERO_CONTENTS))
228 bcn_1->SSID.num_ssid = session->ssId.length;
229 } else {
230 populate_dot11f_ssid(mac_ctx, &session->ssId, &bcn_1->SSID);
231 }
232
233 populate_dot11f_supp_rates(mac_ctx, POPULATE_DOT11F_RATES_OPERATIONAL,
234 &bcn_1->SuppRates, session);
235 populate_dot11f_ds_params(mac_ctx, &bcn_1->DSParams,
236 session->currentOperChannel);
237 populate_dot11f_ibss_params(mac_ctx, &bcn_1->IBSSParams, session);
238
239 offset = sizeof(tAniBeaconStruct);
240 ptr = session->pSchBeaconFrameBegin + offset;
241
242 if (LIM_IS_AP_ROLE(session)) {
243 /* Initialize the default IE bitmap to zero */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530244 qdf_mem_set((uint8_t *) &(session->DefProbeRspIeBitmap),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800245 (sizeof(uint32_t) * 8), 0);
246
247 /* Initialize the default IE bitmap to zero */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530248 qdf_mem_set((uint8_t *) &(session->probeRespFrame),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800249 sizeof(session->probeRespFrame), 0);
250
251 /*
252 * Can be efficiently updated whenever new IE added in Probe
253 * response in future
254 */
255 if (lim_update_probe_rsp_template_ie_bitmap_beacon1(mac_ctx,
256 bcn_1, session) != eSIR_SUCCESS)
Srinivas Girigowdad98fcbf2017-03-19 21:04:06 -0700257 pe_err("Failed to build ProbeRsp template");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800258 }
259
260 n_status = dot11f_pack_beacon1(mac_ctx, bcn_1, ptr,
261 SCH_MAX_BEACON_SIZE - offset, &n_bytes);
262 if (DOT11F_FAILED(n_status)) {
Srinivas Girigowdad98fcbf2017-03-19 21:04:06 -0700263 pe_err("Failed to packed a tDot11fBeacon1 (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800264 n_status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530265 qdf_mem_free(bcn_1);
266 qdf_mem_free(bcn_2);
267 qdf_mem_free(wsc_prb_res);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800268 return eSIR_FAILURE;
269 } else if (DOT11F_WARNED(n_status)) {
Srinivas Girigowdad98fcbf2017-03-19 21:04:06 -0700270 pe_warn("Warnings while packing a tDot11fBeacon1(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800271 n_status);
272 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800273 session->schBeaconOffsetBegin = offset + (uint16_t) n_bytes;
Srinivas Girigowdad98fcbf2017-03-19 21:04:06 -0700274 pe_debug("Initialized beacon begin, offset %d", offset);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800275
276 /* Initialize the 'new' fields at the end of the beacon */
277
278 if ((session->limSystemRole == eLIM_AP_ROLE) &&
Chandrasekaran, Manishekarabc98d12016-02-04 10:25:27 +0530279 session->dfsIncludeChanSwIe == true) {
gaolez76d2a162017-03-21 19:23:58 +0800280 if (!CHAN_HOP_ALL_BANDS_ENABLE ||
281 session->lim_non_ecsa_cap_num == 0) {
282 populate_dot_11_f_ext_chann_switch_ann(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800283 &bcn_2->ext_chan_switch_ann,
284 session);
gaolez76d2a162017-03-21 19:23:58 +0800285 pe_info("ecsa: mode:%d reg:%d chan:%d count:%d",
286 bcn_2->ext_chan_switch_ann.switch_mode,
287 bcn_2->ext_chan_switch_ann.new_reg_class,
288 bcn_2->ext_chan_switch_ann.new_channel,
289 bcn_2->ext_chan_switch_ann.switch_count);
290 }
Chandrasekaran, Manishekarabc98d12016-02-04 10:25:27 +0530291 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800292
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +0530293 populate_dot11_supp_operating_classes(mac_ctx,
294 &bcn_2->SuppOperatingClasses, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800295 populate_dot11f_country(mac_ctx, &bcn_2->Country, session);
296 if (bcn_1->Capabilities.qos)
297 populate_dot11f_edca_param_set(mac_ctx, &bcn_2->EDCAParamSet,
298 session);
299
300 if (session->lim11hEnable) {
301 populate_dot11f_power_constraints(mac_ctx,
302 &bcn_2->PowerConstraints);
303 populate_dot11f_tpc_report(mac_ctx, &bcn_2->TPCReport, session);
304 /* Need to insert channel switch announcement here */
305 if ((LIM_IS_AP_ROLE(session)
306 || LIM_IS_P2P_DEVICE_GO(session))
307 && session->dfsIncludeChanSwIe == true) {
308 /*
309 * Channel switch announcement only if radar is detected
310 * and SAP has instructed to announce channel switch IEs
311 * in beacon and probe responses
312 */
gaolez76d2a162017-03-21 19:23:58 +0800313 if (!CHAN_HOP_ALL_BANDS_ENABLE ||
314 session->lim_non_ecsa_cap_num > 0) {
315 populate_dot11f_chan_switch_ann(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800316 &bcn_2->ChanSwitchAnn, session);
gaolez76d2a162017-03-21 19:23:58 +0800317 pe_debug("csa: mode:%d chan:%d count:%d",
318 bcn_2->ChanSwitchAnn.switchMode,
319 bcn_2->ChanSwitchAnn.newChannel,
320 bcn_2->ChanSwitchAnn.switchCount);
321 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800322 /*
323 * TODO: depending the CB mode, extended channel switch
324 * announcement need to be called
325 */
326 /*
327 populate_dot11f_ext_chan_switch_ann(mac_ctx,
328 &bcn_2->ExtChanSwitchAnn, session);
329 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800330 /*
331 * TODO: If in 11AC mode, wider bw channel switch
332 * announcement needs to be called
333 */
334 /*
335 populate_dot11f_wider_bw_chan_switch_ann(mac_ctx,
336 &bcn_2->WiderBWChanSwitchAnn, session);
337 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800338 /*
339 * Populate the Channel Switch Wrapper Element if
340 * SAP operates in 40/80 Mhz Channel Width.
341 */
Chandrasekaran, Manishekarabc98d12016-02-04 10:25:27 +0530342 if (true == session->dfsIncludeChanWrapperIe) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800343 populate_dot11f_chan_switch_wrapper(mac_ctx,
344 &bcn_2->ChannelSwitchWrapper, session);
Srinivas Girigowdad98fcbf2017-03-19 21:04:06 -0700345 pe_debug("wrapper: width:%d f0:%d f1:%d",
Chandrasekaran, Manishekarabc98d12016-02-04 10:25:27 +0530346 bcn_2->ChannelSwitchWrapper.
347 WiderBWChanSwitchAnn.newChanWidth,
348 bcn_2->ChannelSwitchWrapper.
349 WiderBWChanSwitchAnn.newCenterChanFreq0,
350 bcn_2->ChannelSwitchWrapper.
351 WiderBWChanSwitchAnn.newCenterChanFreq1
352 );
353 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800354 }
355 }
356
357#ifdef FEATURE_AP_MCC_CH_AVOIDANCE
358 /* populate proprietary IE for MDM device operating in AP-MCC */
359 populate_dot11f_avoid_channel_ie(mac_ctx, &bcn_2->QComVendorIE,
360 session);
361#endif /* FEATURE_AP_MCC_CH_AVOIDANCE */
362
363 if (session->dot11mode != WNI_CFG_DOT11_MODE_11B)
364 populate_dot11f_erp_info(mac_ctx, &bcn_2->ERPInfo, session);
365
366 if (session->htCapability) {
367 populate_dot11f_ht_caps(mac_ctx, session, &bcn_2->HTCaps);
368 populate_dot11f_ht_info(mac_ctx, &bcn_2->HTInfo, session);
369 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800370 if (session->vhtCapability) {
Srinivas Girigowdad98fcbf2017-03-19 21:04:06 -0700371 pe_debug("Populate VHT IEs in Beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800372 populate_dot11f_vht_caps(mac_ctx, session, &bcn_2->VHTCaps);
373 populate_dot11f_vht_operation(mac_ctx, session,
374 &bcn_2->VHTOperation);
375 is_vht_enabled = true;
376 /* following is for MU MIMO: we do not support it yet */
377 /*
378 populate_dot11f_vht_ext_bss_load( mac_ctx, &bcn2.VHTExtBssLoad);
379 */
380 if (session->gLimOperatingMode.present)
381 populate_dot11f_operating_mode(mac_ctx,
382 &bcn_2->OperatingMode, session);
383 }
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800384
385 if (lim_is_session_he_capable(session)) {
Srinivas Girigowda817a9182017-03-19 21:39:48 -0700386 pe_warn("Populate HE IEs");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800387 populate_dot11f_he_caps(mac_ctx, session,
388 &bcn_2->vendor_he_cap);
389 populate_dot11f_he_operation(mac_ctx, session,
390 &bcn_2->vendor_he_op);
Peng Xu6363ec62017-05-15 11:06:33 -0700391 populate_dot11f_he_bss_color_change(mac_ctx, session,
392 &bcn_2->bss_color_change);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800393 }
394
Selvaraj, Sridhar35cc2cf2016-06-25 17:01:52 +0530395 if (session->limSystemRole != eLIM_STA_IN_IBSS_ROLE)
396 populate_dot11f_ext_cap(mac_ctx, is_vht_enabled, &bcn_2->ExtCap,
397 session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800398 populate_dot11f_ext_supp_rates(mac_ctx,
399 POPULATE_DOT11F_RATES_OPERATIONAL,
400 &bcn_2->ExtSuppRates, session);
401
402 if (session->pLimStartBssReq != NULL) {
403 populate_dot11f_wpa(mac_ctx, &session->pLimStartBssReq->rsnIE,
404 &bcn_2->WPA);
405 populate_dot11f_rsn_opaque(mac_ctx,
406 &session->pLimStartBssReq->rsnIE,
407 &bcn_2->RSNOpaque);
408 }
409
410 if (session->limWmeEnabled)
411 populate_dot11f_wmm(mac_ctx, &bcn_2->WMMInfoAp,
412 &bcn_2->WMMParams, &bcn_2->WMMCaps, session);
413 if (LIM_IS_AP_ROLE(session)) {
414 if (session->wps_state != SAP_WPS_DISABLED) {
415 populate_dot11f_beacon_wpsi_es(mac_ctx,
416 &bcn_2->WscBeacon, session);
417 }
418 } else {
419 if (wlan_cfg_get_int(mac_ctx,
420 (uint16_t) WNI_CFG_WPS_ENABLE, &tmp) != eSIR_SUCCESS)
Srinivas Girigowdad98fcbf2017-03-19 21:04:06 -0700421 pe_err("Failed to cfg get id %d", WNI_CFG_WPS_ENABLE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800422
423 wps_ap_enable = tmp & WNI_CFG_WPS_ENABLE_AP;
424
425 if (wps_ap_enable)
426 populate_dot11f_wsc(mac_ctx, &bcn_2->WscBeacon);
427
428 if (mac_ctx->lim.wscIeInfo.wscEnrollmentState ==
429 eLIM_WSC_ENROLL_BEGIN) {
430 populate_dot11f_wsc_registrar_info(mac_ctx,
431 &bcn_2->WscBeacon);
432 mac_ctx->lim.wscIeInfo.wscEnrollmentState =
433 eLIM_WSC_ENROLL_IN_PROGRESS;
434 }
435
436 if (mac_ctx->lim.wscIeInfo.wscEnrollmentState ==
437 eLIM_WSC_ENROLL_END) {
438 de_populate_dot11f_wsc_registrar_info(mac_ctx,
439 &bcn_2->WscBeacon);
440 mac_ctx->lim.wscIeInfo.wscEnrollmentState =
441 eLIM_WSC_ENROLL_NOOP;
442 }
443 }
444
Srinivas Girigowdaf326dfe2017-08-03 11:28:32 -0700445 if (LIM_IS_AP_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800446 /*
447 * Can be efficiently updated whenever new IE added in Probe
448 * response in future
449 */
450 lim_update_probe_rsp_template_ie_bitmap_beacon2(mac_ctx, bcn_2,
451 &session->DefProbeRspIeBitmap[0],
452 &session->probeRespFrame);
453
454 /* update probe response WPS IE instead of beacon WPS IE */
455 if (session->wps_state != SAP_WPS_DISABLED) {
456 if (session->APWPSIEs.SirWPSProbeRspIE.FieldPresent)
457 populate_dot11f_probe_res_wpsi_es(mac_ctx,
458 wsc_prb_res, session);
459 else
460 wsc_prb_res->present = 0;
461 if (wsc_prb_res->present) {
462 set_probe_rsp_ie_bitmap(
463 &session->DefProbeRspIeBitmap[0],
464 SIR_MAC_WPA_EID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530465 qdf_mem_copy((void *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800466 &session->probeRespFrame.WscProbeRes,
467 (void *)wsc_prb_res,
468 sizeof(tDot11fIEWscProbeRes));
469 }
470 }
471
472 }
473
Krishna Kumaar Natarajan164e6b02015-12-17 15:19:09 -0800474 addnie_present = (session->addIeParams.probeRespBCNDataLen != 0);
475 if (addnie_present) {
476 addn_ielen = session->addIeParams.probeRespBCNDataLen;
477 addn_ie = qdf_mem_malloc(addn_ielen);
478 if (!addn_ie) {
Srinivas Girigowdad98fcbf2017-03-19 21:04:06 -0700479 pe_err("addn_ie malloc failed");
Krishna Kumaar Natarajan164e6b02015-12-17 15:19:09 -0800480 qdf_mem_free(bcn_1);
481 qdf_mem_free(bcn_2);
482 qdf_mem_free(wsc_prb_res);
483 return eSIR_MEM_ALLOC_FAILED;
484 }
485 qdf_mem_copy(addn_ie,
486 session->addIeParams.probeRespBCNData_buff,
487 addn_ielen);
488
489 qdf_mem_zero((uint8_t *)&extracted_extcap,
490 sizeof(tDot11fIEExtCap));
491 status = lim_strip_extcap_update_struct(mac_ctx, addn_ie,
492 &addn_ielen, &extracted_extcap);
493 if (eSIR_SUCCESS != status) {
494 extcap_present = false;
Srinivas Girigowdad98fcbf2017-03-19 21:04:06 -0700495 pe_debug("extcap not extracted");
Krishna Kumaar Natarajan164e6b02015-12-17 15:19:09 -0800496 }
497 /* merge extcap IE */
Selvaraj, Sridhar35cc2cf2016-06-25 17:01:52 +0530498 if (extcap_present &&
499 session->limSystemRole != eLIM_STA_IN_IBSS_ROLE)
Krishna Kumaar Natarajan164e6b02015-12-17 15:19:09 -0800500 lim_merge_extcap_struct(&bcn_2->ExtCap,
Hu Wangfbd279d2016-10-31 18:24:34 +0800501 &extracted_extcap,
502 true);
Krishna Kumaar Natarajan164e6b02015-12-17 15:19:09 -0800503
504 }
505
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800506 n_status = dot11f_pack_beacon2(mac_ctx, bcn_2,
507 session->pSchBeaconFrameEnd,
508 SCH_MAX_BEACON_SIZE, &n_bytes);
509 if (DOT11F_FAILED(n_status)) {
Srinivas Girigowdad98fcbf2017-03-19 21:04:06 -0700510 pe_err("Failed to packed a tDot11fBeacon2 (0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800511 n_status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530512 qdf_mem_free(bcn_1);
513 qdf_mem_free(bcn_2);
514 qdf_mem_free(wsc_prb_res);
Krishna Kumaar Natarajan164e6b02015-12-17 15:19:09 -0800515 qdf_mem_free(addn_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800516 return eSIR_FAILURE;
517 } else if (DOT11F_WARNED(n_status)) {
Srinivas Girigowdad98fcbf2017-03-19 21:04:06 -0700518 pe_err("Warnings while packing a tDot11fBeacon2(0x%08x)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800519 n_status);
520 }
521
522 extra_ie = session->pSchBeaconFrameEnd + n_bytes;
523 extra_ie_offset = n_bytes;
Krishna Kumaar Natarajan164e6b02015-12-17 15:19:09 -0800524
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800525 /* TODO: Append additional IE here. */
Krishna Kumaar Natarajan164e6b02015-12-17 15:19:09 -0800526 if (addn_ielen > 0)
527 sch_append_addn_ie(mac_ctx, session,
528 session->pSchBeaconFrameEnd + n_bytes,
529 SCH_MAX_BEACON_SIZE, &n_bytes, addn_ie, addn_ielen);
530
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800531 session->schBeaconOffsetEnd = (uint16_t) n_bytes;
532 extra_ie_len = n_bytes - extra_ie_offset;
533 /* Get the p2p Ie Offset */
534 status = sch_get_p2p_ie_offset(extra_ie, extra_ie_len, &p2p_ie_offset);
535 if (eSIR_SUCCESS == status)
536 /* Update the P2P Ie Offset */
537 mac_ctx->sch.schObject.p2pIeOffset =
538 session->schBeaconOffsetBegin + TIM_IE_SIZE +
539 extra_ie_offset + p2p_ie_offset;
540 else
541 mac_ctx->sch.schObject.p2pIeOffset = 0;
542
Srinivas Girigowdad98fcbf2017-03-19 21:04:06 -0700543 pe_debug("Initialized beacon end, offset %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800544 session->schBeaconOffsetEnd);
545 mac_ctx->sch.schObject.fBeaconChanged = 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530546 qdf_mem_free(bcn_1);
547 qdf_mem_free(bcn_2);
548 qdf_mem_free(wsc_prb_res);
Krishna Kumaar Natarajan164e6b02015-12-17 15:19:09 -0800549 qdf_mem_free(addn_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800550 return eSIR_SUCCESS;
551}
552
553tSirRetStatus lim_update_probe_rsp_template_ie_bitmap_beacon1(tpAniSirGlobal pMac,
554 tDot11fBeacon1 *beacon1,
555 tpPESession
556 psessionEntry)
557{
558 uint32_t *DefProbeRspIeBitmap;
559 tDot11fProbeResponse *prb_rsp;
560 if (!psessionEntry) {
Srinivas Girigowdad98fcbf2017-03-19 21:04:06 -0700561 pe_debug("PESession is null!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800562 return eSIR_FAILURE;
563 }
564 DefProbeRspIeBitmap = &psessionEntry->DefProbeRspIeBitmap[0];
565 prb_rsp = &psessionEntry->probeRespFrame;
566 prb_rsp->BeaconInterval = beacon1->BeaconInterval;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530567 qdf_mem_copy((void *)&prb_rsp->Capabilities,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800568 (void *)&beacon1->Capabilities,
569 sizeof(beacon1->Capabilities));
570
571 /* SSID */
572 if (beacon1->SSID.present) {
573 set_probe_rsp_ie_bitmap(DefProbeRspIeBitmap, SIR_MAC_SSID_EID);
574 /* populating it, because probe response has to go with SSID even in hidden case */
575 populate_dot11f_ssid(pMac, &psessionEntry->ssId, &prb_rsp->SSID);
576 }
577 /* supported rates */
578 if (beacon1->SuppRates.present) {
579 set_probe_rsp_ie_bitmap(DefProbeRspIeBitmap, SIR_MAC_RATESET_EID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530580 qdf_mem_copy((void *)&prb_rsp->SuppRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800581 (void *)&beacon1->SuppRates,
582 sizeof(beacon1->SuppRates));
583
584 }
585 /* DS Parameter set */
586 if (beacon1->DSParams.present) {
587 set_probe_rsp_ie_bitmap(DefProbeRspIeBitmap,
588 SIR_MAC_DS_PARAM_SET_EID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530589 qdf_mem_copy((void *)&prb_rsp->DSParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800590 (void *)&beacon1->DSParams,
591 sizeof(beacon1->DSParams));
592
593 }
594
595 /* IBSS params will not be present in the Beacons transmitted by AP */
596 return eSIR_SUCCESS;
597}
598
599void lim_update_probe_rsp_template_ie_bitmap_beacon2(tpAniSirGlobal pMac,
600 tDot11fBeacon2 *beacon2,
601 uint32_t *DefProbeRspIeBitmap,
602 tDot11fProbeResponse *prb_rsp)
603{
604 /* IBSS parameter set - will not be present in probe response tx by AP */
605 /* country */
606 if (beacon2->Country.present) {
607 set_probe_rsp_ie_bitmap(DefProbeRspIeBitmap, SIR_MAC_COUNTRY_EID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530608 qdf_mem_copy((void *)&prb_rsp->Country,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800609 (void *)&beacon2->Country,
610 sizeof(beacon2->Country));
611
612 }
613 /* Power constraint */
614 if (beacon2->PowerConstraints.present) {
615 set_probe_rsp_ie_bitmap(DefProbeRspIeBitmap,
616 SIR_MAC_PWR_CONSTRAINT_EID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530617 qdf_mem_copy((void *)&prb_rsp->PowerConstraints,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800618 (void *)&beacon2->PowerConstraints,
619 sizeof(beacon2->PowerConstraints));
620
621 }
622 /* Channel Switch Annoouncement SIR_MAC_CHNL_SWITCH_ANN_EID */
623 if (beacon2->ChanSwitchAnn.present) {
624 set_probe_rsp_ie_bitmap(DefProbeRspIeBitmap,
625 SIR_MAC_CHNL_SWITCH_ANN_EID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530626 qdf_mem_copy((void *)&prb_rsp->ChanSwitchAnn,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800627 (void *)&beacon2->ChanSwitchAnn,
628 sizeof(beacon2->ChanSwitchAnn));
629
630 }
631
Abhishek Singh518323d2015-10-19 17:42:01 +0530632 /* EXT Channel Switch Announcement CHNL_EXTENDED_SWITCH_ANN_EID*/
633 if (beacon2->ext_chan_switch_ann.present) {
634 set_probe_rsp_ie_bitmap(DefProbeRspIeBitmap,
635 SIR_MAC_CHNL_EXTENDED_SWITCH_ANN_EID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530636 qdf_mem_copy((void *)&prb_rsp->ext_chan_switch_ann,
Abhishek Singh518323d2015-10-19 17:42:01 +0530637 (void *)&beacon2->ext_chan_switch_ann,
638 sizeof(beacon2->ext_chan_switch_ann));
639 }
640
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +0530641 /* Supported operating class */
642 if (beacon2->SuppOperatingClasses.present) {
643 set_probe_rsp_ie_bitmap(DefProbeRspIeBitmap,
644 SIR_MAC_OPERATING_CLASS_EID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530645 qdf_mem_copy((void *)&prb_rsp->SuppOperatingClasses,
Edhar, Mahesh Kumar5cd1e0e2015-11-16 14:32:33 +0530646 (void *)&beacon2->SuppOperatingClasses,
647 sizeof(beacon2->SuppOperatingClasses));
648 }
649
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800650#ifdef FEATURE_AP_MCC_CH_AVOIDANCE
651 if (beacon2->QComVendorIE.present) {
652 set_probe_rsp_ie_bitmap(DefProbeRspIeBitmap,
653 SIR_MAC_QCOM_VENDOR_EID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530654 qdf_mem_copy((void *)&prb_rsp->QComVendorIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800655 (void *)&beacon2->QComVendorIE,
656 sizeof(beacon2->QComVendorIE));
657 }
658#endif /* FEATURE_AP_MCC_CH_AVOIDANCE */
659
660 /* ERP information */
661 if (beacon2->ERPInfo.present) {
662 set_probe_rsp_ie_bitmap(DefProbeRspIeBitmap, SIR_MAC_ERP_INFO_EID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530663 qdf_mem_copy((void *)&prb_rsp->ERPInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800664 (void *)&beacon2->ERPInfo,
665 sizeof(beacon2->ERPInfo));
666
667 }
668 /* Extended supported rates */
669 if (beacon2->ExtSuppRates.present) {
670 set_probe_rsp_ie_bitmap(DefProbeRspIeBitmap,
671 SIR_MAC_EXTENDED_RATE_EID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530672 qdf_mem_copy((void *)&prb_rsp->ExtSuppRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800673 (void *)&beacon2->ExtSuppRates,
674 sizeof(beacon2->ExtSuppRates));
675
676 }
677
678 /* WPA */
679 if (beacon2->WPA.present) {
680 set_probe_rsp_ie_bitmap(DefProbeRspIeBitmap, SIR_MAC_WPA_EID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530681 qdf_mem_copy((void *)&prb_rsp->WPA, (void *)&beacon2->WPA,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800682 sizeof(beacon2->WPA));
683
684 }
685
686 /* RSN */
687 if (beacon2->RSNOpaque.present) {
688 set_probe_rsp_ie_bitmap(DefProbeRspIeBitmap, SIR_MAC_RSN_EID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530689 qdf_mem_copy((void *)&prb_rsp->RSNOpaque,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800690 (void *)&beacon2->RSNOpaque,
691 sizeof(beacon2->RSNOpaque));
692 }
693
694 /* EDCA Parameter set */
695 if (beacon2->EDCAParamSet.present) {
696 set_probe_rsp_ie_bitmap(DefProbeRspIeBitmap,
697 SIR_MAC_EDCA_PARAM_SET_EID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530698 qdf_mem_copy((void *)&prb_rsp->EDCAParamSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800699 (void *)&beacon2->EDCAParamSet,
700 sizeof(beacon2->EDCAParamSet));
701
702 }
703 /* Vendor specific - currently no vendor specific IEs added */
704 /* Requested IEs - currently we are not processing this will be added later */
705 /* HT capability IE */
706 if (beacon2->HTCaps.present) {
707 set_probe_rsp_ie_bitmap(DefProbeRspIeBitmap,
708 SIR_MAC_HT_CAPABILITIES_EID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530709 qdf_mem_copy((void *)&prb_rsp->HTCaps, (void *)&beacon2->HTCaps,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800710 sizeof(beacon2->HTCaps));
711 }
712 /* HT Info IE */
713 if (beacon2->HTInfo.present) {
714 set_probe_rsp_ie_bitmap(DefProbeRspIeBitmap, SIR_MAC_HT_INFO_EID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530715 qdf_mem_copy((void *)&prb_rsp->HTInfo, (void *)&beacon2->HTInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800716 sizeof(beacon2->HTInfo));
717 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800718 if (beacon2->VHTCaps.present) {
719 set_probe_rsp_ie_bitmap(DefProbeRspIeBitmap,
720 SIR_MAC_VHT_CAPABILITIES_EID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530721 qdf_mem_copy((void *)&prb_rsp->VHTCaps,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800722 (void *)&beacon2->VHTCaps,
723 sizeof(beacon2->VHTCaps));
724 }
725 if (beacon2->VHTOperation.present) {
726 set_probe_rsp_ie_bitmap(DefProbeRspIeBitmap,
727 SIR_MAC_VHT_OPERATION_EID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530728 qdf_mem_copy((void *)&prb_rsp->VHTOperation,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800729 (void *)&beacon2->VHTOperation,
730 sizeof(beacon2->VHTOperation));
731 }
732 if (beacon2->VHTExtBssLoad.present) {
733 set_probe_rsp_ie_bitmap(DefProbeRspIeBitmap,
734 SIR_MAC_VHT_EXT_BSS_LOAD_EID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530735 qdf_mem_copy((void *)&prb_rsp->VHTExtBssLoad,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800736 (void *)&beacon2->VHTExtBssLoad,
737 sizeof(beacon2->VHTExtBssLoad));
738 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800739 /* WMM IE */
740 if (beacon2->WMMParams.present) {
741 set_probe_rsp_ie_bitmap(DefProbeRspIeBitmap, SIR_MAC_WPA_EID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530742 qdf_mem_copy((void *)&prb_rsp->WMMParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800743 (void *)&beacon2->WMMParams,
744 sizeof(beacon2->WMMParams));
745 }
746 /* WMM capability - most of the case won't be present */
747 if (beacon2->WMMCaps.present) {
748 set_probe_rsp_ie_bitmap(DefProbeRspIeBitmap, SIR_MAC_WPA_EID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530749 qdf_mem_copy((void *)&prb_rsp->WMMCaps,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800750 (void *)&beacon2->WMMCaps,
751 sizeof(beacon2->WMMCaps));
752 }
753
754 /* Extended Capability */
755 if (beacon2->ExtCap.present) {
756 set_probe_rsp_ie_bitmap(DefProbeRspIeBitmap, DOT11F_EID_EXTCAP);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530757 qdf_mem_copy((void *)&prb_rsp->ExtCap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800758 (void *)&beacon2->ExtCap,
759 sizeof(beacon2->ExtCap));
760 }
761
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800762 if (beacon2->vendor_he_cap.present) {
763 set_probe_rsp_ie_bitmap(DefProbeRspIeBitmap,
764 DOT11F_EID_VENDOR_HE_CAP);
765 qdf_mem_copy((void *)&prb_rsp->vendor_he_cap,
766 (void *)&beacon2->vendor_he_cap,
767 sizeof(beacon2->vendor_he_cap));
768 }
769 if (beacon2->vendor_he_op.present) {
770 set_probe_rsp_ie_bitmap(DefProbeRspIeBitmap,
771 DOT11F_EID_VENDOR_HE_OP);
772 qdf_mem_copy((void *)&prb_rsp->vendor_he_op,
773 (void *)&beacon2->vendor_he_op,
774 sizeof(beacon2->vendor_he_op));
775 }
776
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800777}
778
779void set_probe_rsp_ie_bitmap(uint32_t *IeBitmap, uint32_t pos)
780{
781 uint32_t index, temp;
782
783 index = pos >> 5;
784 if (index >= 8) {
785 return;
786 }
787 temp = IeBitmap[index];
788
789 temp |= 1 << (pos & 0x1F);
790
791 IeBitmap[index] = temp;
792}
793
794/* -------------------------------------------------------------------- */
795/**
796 * write_beacon_to_memory
797 *
798 * FUNCTION:
799 *
800 * LOGIC:
801 *
802 * ASSUMPTIONS:
803 *
804 * NOTE:
805 *
806 * @param None
807 * @param size Size of the beacon to write to memory
808 * @param length Length field of the beacon to write to memory
809 * @return None
810 */
811
Jeff Johnsonaeebe652016-10-07 07:46:48 -0700812static void write_beacon_to_memory(tpAniSirGlobal pMac, uint16_t size,
813 uint16_t length, tpPESession psessionEntry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800814{
815 uint16_t i;
816 tpAniBeaconStruct pBeacon;
817
818 /* copy end of beacon only if length > 0 */
819 if (length > 0) {
820 for (i = 0; i < psessionEntry->schBeaconOffsetEnd; i++)
821 psessionEntry->pSchBeaconFrameBegin[size++] =
822 psessionEntry->pSchBeaconFrameEnd[i];
823 }
824 /* Update the beacon length */
825 pBeacon = (tpAniBeaconStruct) psessionEntry->pSchBeaconFrameBegin;
826 /* Do not include the beaconLength indicator itself */
827 if (length == 0) {
828 pBeacon->beaconLength = 0;
829 /* Dont copy entire beacon, Copy length field alone */
830 size = 4;
831 } else
832 pBeacon->beaconLength = (uint32_t) size - sizeof(uint32_t);
833
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800834 if (!pMac->sch.schObject.fBeaconChanged)
835 return;
836
Naveen Rawataf4388c2017-05-23 10:00:24 -0700837 /*
838 * Copy beacon data to SoftMAC shared memory...
839 * Do this by sending a message to HAL
840 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800841
Naveen Rawataf4388c2017-05-23 10:00:24 -0700842 size = (size + 3) & (~3);
843 if (eSIR_SUCCESS != sch_send_beacon_req(pMac,
844 psessionEntry->pSchBeaconFrameBegin, size, psessionEntry))
845 pe_err("sch_send_beacon_req() returned an error (zsize %d)",
846 size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800847
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800848 pMac->sch.schObject.fBeaconChanged = 0;
849}
850
851/**
852 * sch_generate_tim
853 *
854 * FUNCTION:
855 * Generate TIM
856 *
857 * LOGIC:
858 *
859 * ASSUMPTIONS:
860 *
861 * NOTE:
862 *
863 * @param pMac pointer to global mac structure
864 * @param **pPtr pointer to the buffer, where the TIM bit is to be written.
865 * @param *timLength pointer to limLength, which needs to be returned.
866 * @return None
867 */
868void sch_generate_tim(tpAniSirGlobal pMac, uint8_t **pPtr, uint16_t *timLength,
869 uint8_t dtimPeriod)
870{
871 uint8_t *ptr = *pPtr;
872 uint32_t val = 0;
873 uint32_t minAid = 1; /* Always start with AID 1 as minimum */
874 uint32_t maxAid = HAL_NUM_STA;
875
876 /* Generate partial virtual bitmap */
877 uint8_t N1 = minAid / 8;
878 uint8_t N2 = maxAid / 8;
879 if (N1 & 1)
880 N1--;
881
882 *timLength = N2 - N1 + 4;
883 val = dtimPeriod;
884
885 /*
886 * Write 0xFF to firmware's field to detect firmware's mal-function
887 * early. DTIM count and bitmap control usually cannot be 0xFF, so it
888 * is easy to know that firmware never updated DTIM count/bitmap control
889 * field after host driver downloaded beacon template if end-user complaints
890 * that DTIM count and bitmapControl is 0xFF.
891 */
892 *ptr++ = SIR_MAC_TIM_EID;
893 *ptr++ = (uint8_t) (*timLength);
894 /* location for dtimCount. will be filled in by FW. */
895 *ptr++ = 0xFF;
896 *ptr++ = (uint8_t) val;
897 /* location for bitmap control. will be filled in by FW. */
898 *ptr++ = 0xFF;
899 ptr += (N2 - N1 + 1);
900
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800901 * pPtr = ptr;
902}
903/* -------------------------------------------------------------------- */
904/**
905 * @function: SchProcessPreBeaconInd
906 *
907 * @brief : Process the PreBeacon Indication from the Lim
908 *
909 * ASSUMPTIONS:
910 *
911 * NOTE:
912 *
913 * @param : pMac - tpAniSirGlobal
914 *
915 * @return None
916 */
917
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800918void sch_process_pre_beacon_ind(tpAniSirGlobal pMac,
919 struct scheduler_msg *limMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800920{
921 tpBeaconGenParams pMsg = (tpBeaconGenParams) limMsg->bodyptr;
922 uint32_t beaconSize;
923 tpPESession psessionEntry;
924 uint8_t sessionId;
925
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530926 psessionEntry = pe_find_session_by_bssid(pMac, pMsg->bssId, &sessionId);
927 if (psessionEntry == NULL) {
Srinivas Girigowdad98fcbf2017-03-19 21:04:06 -0700928 pe_err("session lookup fails");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800929 goto end;
930 }
931
932 beaconSize = psessionEntry->schBeaconOffsetBegin;
933
934 /* If SME is not in normal mode, no need to generate beacon */
935 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE) {
Srinivas Girigowdad98fcbf2017-03-19 21:04:06 -0700936 pe_err("PreBeaconInd received in invalid state: %d",
937 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800938 goto end;
939 }
940
941 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
942
943 case eLIM_STA_IN_IBSS_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800944 /* generate IBSS parameter set */
945 if (psessionEntry->statypeForBss == STA_ENTRY_SELF)
946 write_beacon_to_memory(pMac, (uint16_t) beaconSize,
947 (uint16_t) beaconSize,
948 psessionEntry);
949 else
Srinivas Girigowdad98fcbf2017-03-19 21:04:06 -0700950 pe_err("can not send beacon for PEER session entry");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800951 break;
952
953 case eLIM_AP_ROLE: {
954 uint8_t *ptr =
955 &psessionEntry->pSchBeaconFrameBegin[psessionEntry->
956 schBeaconOffsetBegin];
957 uint16_t timLength = 0;
958 if (psessionEntry->statypeForBss == STA_ENTRY_SELF) {
959 sch_generate_tim(pMac, &ptr, &timLength,
960 psessionEntry->dtimPeriod);
961 beaconSize += 2 + timLength;
962 write_beacon_to_memory(pMac, (uint16_t) beaconSize,
963 (uint16_t) beaconSize,
964 psessionEntry);
965 } else
Srinivas Girigowdad98fcbf2017-03-19 21:04:06 -0700966 pe_err("can not send beacon for PEER session entry");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800967 }
968 break;
969
970 default:
Srinivas Girigowdad98fcbf2017-03-19 21:04:06 -0700971 pe_err("Error-PE has Receive PreBeconGenIndication when System is in %d role",
972 GET_LIM_SYSTEM_ROLE(psessionEntry));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800973 }
974
975end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530976 qdf_mem_free(pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800977
978 }