blob: 934531e065727c5871f4f34e1075a3476bbf0415 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
2 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
3 *
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 lim_process_sme_req_messages.cc contains the code
30 * for processing SME request messages.
31 * Author: Chandra Modumudi
32 * Date: 02/11/02
33 * History:-
34 * Date Modified by Modification Information
35 * --------------------------------------------------------------------
36 *
37 */
38
39#include "cds_api.h"
40#include "wni_api.h"
41#include "wni_cfg.h"
42#include "cfg_api.h"
43#include "sir_api.h"
44#include "sch_api.h"
45#include "utils_api.h"
46#include "lim_types.h"
47#include "lim_utils.h"
48#include "lim_assoc_utils.h"
49#include "lim_security_utils.h"
50#include "lim_ser_des_utils.h"
51#include "lim_sme_req_utils.h"
52#include "lim_ibss_peer_mgmt.h"
53#include "lim_admit_control.h"
54#include "dph_hash_table.h"
55#include "lim_send_messages.h"
56#include "lim_api.h"
57#include "wmm_apsd.h"
58#include "sir_mac_prot_def.h"
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -080059#include "rrm_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080060
61#include "sap_api.h"
62
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080063
64#if defined WLAN_FEATURE_VOWIFI_11R
65#include <lim_ft.h>
66#endif
Abhishek Singh518323d2015-10-19 17:42:01 +053067#include "cds_regdomain_common.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080068
69/*
70 * This overhead is time for sending NOA start to host in case of GO/sending
71 * NULL data & receiving ACK in case of P2P Client and starting actual scanning
72 * with init scan req/rsp plus in case of concurrency, taking care of sending
73 * null data and receiving ACK to/from AP/Also SetChannel with calibration
74 * is taking around 7ms .
75 */
76#define SCAN_MESSAGING_OVERHEAD 20 /* in msecs */
77#define JOIN_NOA_DURATION 2000 /* in msecs */
78#define OEM_DATA_NOA_DURATION 60 /* in msecs */
79#define DEFAULT_PASSIVE_MAX_CHANNEL_TIME 110 /* in msecs */
80
81#define CONV_MS_TO_US 1024 /* conversion factor from ms to us */
82
83/* SME REQ processing function templates */
84static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal, uint32_t *);
85static bool __lim_process_sme_start_bss_req(tpAniSirGlobal, tpSirMsgQ pMsg);
86static void __lim_process_sme_scan_req(tpAniSirGlobal, uint32_t *);
87static void __lim_process_sme_join_req(tpAniSirGlobal, uint32_t *);
88static void __lim_process_sme_reassoc_req(tpAniSirGlobal, uint32_t *);
89static void __lim_process_sme_disassoc_req(tpAniSirGlobal, uint32_t *);
90static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal, uint32_t *);
91static void __lim_process_sme_deauth_req(tpAniSirGlobal, uint32_t *);
92static void __lim_process_sme_set_context_req(tpAniSirGlobal, uint32_t *);
93static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal, tpSirMsgQ pMsg);
94static void lim_process_sme_channel_change_request(tpAniSirGlobal pMac,
95 uint32_t *pMsg);
96static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg);
97static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal pMac, uint32_t *pMsg);
98static void lim_process_nss_update_request(tpAniSirGlobal pMac, uint32_t *pMsg);
99static void lim_process_set_ie_req(tpAniSirGlobal pMac, uint32_t *pMsg);
100
101static void lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
102 uint8_t **pDstData_buff,
103 uint16_t *pDstDataLen,
104 uint8_t *pSrcData_buff,
105 uint16_t srcDataLen);
106
107static void lim_update_add_ie_buffer(tpAniSirGlobal pMac,
108 uint8_t **pDstData_buff,
109 uint16_t *pDstDataLen,
110 uint8_t *pSrcData_buff, uint16_t srcDataLen);
111
112static void lim_process_modify_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
113
114static void lim_process_update_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
115
116extern void pe_register_wma_handle(tpAniSirGlobal pMac);
117
Abhishek Singh518323d2015-10-19 17:42:01 +0530118static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
119 uint32_t *msg);
120
121
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800122/**
123 * lim_process_set_hw_mode() - Send set HW mode command to WMA
124 * @mac: Globacl MAC pointer
125 * @msg: Message containing the hw mode index
126 *
127 * Send the set HW mode command to WMA
128 *
129 * Return: CDF_STATUS_SUCCESS if message posting is successful
130 */
131static CDF_STATUS lim_process_set_hw_mode(tpAniSirGlobal mac, uint32_t *msg)
132{
133 CDF_STATUS status = CDF_STATUS_SUCCESS;
134 cds_msg_t cds_message;
135 struct sir_hw_mode *req_msg;
136 uint32_t len;
137 struct s_sir_set_hw_mode *buf;
138 tSirMsgQ resp_msg;
139 struct sir_set_hw_mode_resp *param;
140
141 buf = (struct s_sir_set_hw_mode *) msg;
142 if (!buf) {
143 lim_log(mac, LOGE, FL("Set HW mode param is NULL"));
144 /* To free the active command list */
145 goto fail;
146 }
147
148 len = sizeof(*req_msg);
149
150 req_msg = cdf_mem_malloc(len);
151 if (!req_msg) {
152 lim_log(mac, LOGE, FL("cdf_mem_malloc failed"));
153 /* Free the active command list
154 * Probably the malloc is going to fail there as well?!
155 */
156 return CDF_STATUS_E_NOMEM;
157 }
158
159 cdf_mem_zero(req_msg, len);
160
161 req_msg->hw_mode_index = buf->set_hw.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530162 req_msg->reason = buf->set_hw.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800163 /* Other parameters are not needed for WMA */
164
165 cds_message.bodyptr = req_msg;
166 cds_message.type = SIR_HAL_SOC_SET_HW_MODE;
167
168 lim_log(mac, LOG1, FL("Posting SIR_HAL_SOC_SET_HW_MOD to WMA"));
169 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
170 if (!CDF_IS_STATUS_SUCCESS(status)) {
171 lim_log(mac, LOGE,
172 FL("vos_mq_post_message failed!(err=%d)"),
173 status);
174 cdf_mem_free(req_msg);
175 goto fail;
176 }
177 return status;
178fail:
179 param = cdf_mem_malloc(sizeof(*param));
180 if (!param) {
181 lim_log(mac, LOGE, FL("HW mode resp failed"));
182 return CDF_STATUS_E_FAILURE;
183 }
184 param->status = SET_HW_MODE_STATUS_ECANCELED;
185 param->cfgd_hw_mode_index = 0;
186 param->num_vdev_mac_entries = 0;
187 resp_msg.type = eWNI_SME_SET_HW_MODE_RESP;
188 resp_msg.bodyptr = param;
189 resp_msg.bodyval = 0;
190 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
191 return CDF_STATUS_SUCCESS;
192}
193
194/**
195 * lim_process_set_dual_mac_cfg_req() - Set dual mac config command to WMA
196 * @mac: Global MAC pointer
197 * @msg: Message containing the dual mac config parameter
198 *
199 * Send the set dual mac config command to WMA
200 *
201 * Return: CDF_STATUS_SUCCESS if message posting is successful
202 */
203static CDF_STATUS lim_process_set_dual_mac_cfg_req(tpAniSirGlobal mac,
204 uint32_t *msg)
205{
206 CDF_STATUS status = CDF_STATUS_SUCCESS;
207 cds_msg_t cds_message;
208 struct sir_dual_mac_config *req_msg;
209 uint32_t len;
210 struct sir_set_dual_mac_cfg *buf;
211 tSirMsgQ resp_msg;
212 struct sir_dual_mac_config_resp *param;
213
214 buf = (struct sir_set_dual_mac_cfg *) msg;
215 if (!buf) {
216 lim_log(mac, LOGE, FL("Set Dual mac config is NULL"));
217 /* To free the active command list */
218 goto fail;
219 }
220
221 len = sizeof(*req_msg);
222
223 req_msg = cdf_mem_malloc(len);
224 if (!req_msg) {
225 lim_log(mac, LOGE, FL("vos_mem_malloc failed"));
226 /* Free the active command list
227 * Probably the malloc is going to fail there as well?!
228 */
229 return CDF_STATUS_E_NOMEM;
230 }
231
232 cdf_mem_zero(req_msg, len);
233
234 req_msg->scan_config = buf->set_dual_mac.scan_config;
235 req_msg->fw_mode_config = buf->set_dual_mac.fw_mode_config;
236 /* Other parameters are not needed for WMA */
237
238 cds_message.bodyptr = req_msg;
239 cds_message.type = SIR_HAL_SOC_DUAL_MAC_CFG_REQ;
240
241 lim_log(mac, LOG1,
242 FL("Post SIR_HAL_SOC_DUAL_MAC_CFG_REQ to WMA: %x %x"),
243 req_msg->scan_config, req_msg->fw_mode_config);
244 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
245 if (!CDF_IS_STATUS_SUCCESS(status)) {
246 lim_log(mac, LOGE,
247 FL("vos_mq_post_message failed!(err=%d)"),
248 status);
249 cdf_mem_free(req_msg);
250 goto fail;
251 }
252 return status;
253fail:
254 param = cdf_mem_malloc(sizeof(*param));
255 if (!param) {
256 lim_log(mac, LOGE, FL("Dual mac config resp failed"));
257 return CDF_STATUS_E_FAILURE;
258 }
259 param->status = SET_HW_MODE_STATUS_ECANCELED;
260 resp_msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
261 resp_msg.bodyptr = param;
262 resp_msg.bodyval = 0;
263 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
264 return CDF_STATUS_SUCCESS;
265}
266
267/**
268 * __lim_fresh_scan_reqd() - determine if a fresh scan request must be issued.
269 * @mac_ctx: Pointer to Global MAC structure
270 * @return_fresh_results: Trigger fresh scan.
271 *
272 * PE will do fresh scan, if all of the active sessions are in
273 * good state (Link Est or BSS Started). If one of the sessions
274 * is not in one of the above states, then PE does not do fresh
275 * scan. If no session exists (scanning very first time),
276 * then PE will always do fresh scan if SME asks it to do that.
277 *
278 * Return: true for fresh scan results, false if in invalid state.
279 */
280static uint8_t
281__lim_fresh_scan_reqd(tpAniSirGlobal mac_ctx, uint8_t return_fresh_results)
282{
283 uint8_t valid_state = true;
284 int i;
285
286 lim_log(mac_ctx, LOG1, FL("gLimSmeState: %d, returnFreshResults 0x%x"),
287 mac_ctx->lim.gLimSmeState, return_fresh_results);
288
289 if (mac_ctx->lim.gLimSmeState != eLIM_SME_IDLE_STATE) {
290 lim_log(mac_ctx, LOG1, FL("return FALSE"));
291 return false;
292 }
293
294 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
295 lim_log(mac_ctx, LOG1,
296 FL("session %d, bsstype %d, limSystemRole %d, limSmeState %d"),
297 i, mac_ctx->lim.gpSession[i].bssType,
298 mac_ctx->lim.gpSession[i].limSystemRole,
299 mac_ctx->lim.gpSession[i].limSmeState);
300 if (mac_ctx->lim.gpSession[i].valid == true) {
301 if (!((((mac_ctx->lim.gpSession[i].bssType ==
302 eSIR_INFRASTRUCTURE_MODE) ||
303 (mac_ctx->lim.gpSession[i].limSystemRole ==
304 eLIM_BT_AMP_STA_ROLE)) &&
305 (mac_ctx->lim.gpSession[i].limSmeState ==
306 eLIM_SME_LINK_EST_STATE)) ||
307 (((mac_ctx->lim.gpSession[i].bssType ==
308 eSIR_IBSS_MODE) ||
309 (mac_ctx->lim.gpSession[i].limSystemRole ==
310 eLIM_BT_AMP_AP_ROLE) ||
311 (mac_ctx->lim.gpSession[i].limSystemRole ==
312 eLIM_BT_AMP_STA_ROLE)) &&
313 (mac_ctx->lim.gpSession[i].limSmeState ==
314 eLIM_SME_NORMAL_STATE)) ||
315 ((((mac_ctx->lim.gpSession[i].bssType ==
316 eSIR_INFRA_AP_MODE) &&
317 (mac_ctx->lim.gpSession[i].pePersona ==
318 CDF_P2P_GO_MODE)) ||
319 (mac_ctx->lim.gpSession[i].limSystemRole ==
320 eLIM_AP_ROLE)) &&
321 (mac_ctx->lim.gpSession[i].limSmeState ==
322 eLIM_SME_NORMAL_STATE)))) {
323 valid_state = false;
324 break;
325 }
326 }
327 }
328
329 lim_log(mac_ctx, LOG1, FL("valid_state: %d"), valid_state);
330
331 if ((valid_state) &&
332 (return_fresh_results & SIR_BG_SCAN_RETURN_FRESH_RESULTS))
333 return true;
334 else
335 return false;
336}
337
338/**
339 * __lim_is_sme_assoc_cnf_valid()
340 *
341 ***FUNCTION:
342 * This function is called by __lim_process_sme_assoc_cnf_new() upon
343 * receiving SME_ASSOC_CNF.
344 *
345 ***LOGIC:
346 * Message validity checks are performed in this function
347 *
348 ***ASSUMPTIONS:
349 *
350 ***NOTE:
351 *
352 * @param pMeasReq Pointer to Received ASSOC_CNF message
353 * @return true When received SME_ASSOC_CNF is formatted
354 * correctly
355 * false otherwise
356 */
357
358static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
359{
360 if (lim_is_group_addr(pAssocCnf->peerMacAddr))
361 return false;
362 else
363 return true;
364} /*** end __lim_is_sme_assoc_cnf_valid() ***/
365
366/**
367 * __lim_get_sme_join_req_size_for_alloc()
368 *
369 ***FUNCTION:
370 * This function is called in various places to get IE length
371 * from tSirBssDescription structure
372 * number being scanned.
373 *
374 ***PARAMS:
375 *
376 ***LOGIC:
377 *
378 ***ASSUMPTIONS:
379 * NA
380 *
381 ***NOTE:
382 * NA
383 *
384 * @param pBssDescr
385 * @return Total IE length
386 */
387
388static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
389{
390 uint16_t len = 0;
391
392 if (!pBuf)
393 return len;
394
395 pBuf += sizeof(uint16_t);
396 len = lim_get_u16(pBuf);
397 return len + sizeof(uint16_t);
398}
399
400/**
401 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
402 * @pMac: Global MAC context
403 * @pMsg: Pointer to message posted from SME to LIM.
404 *
405 * Has role only if 11h is enabled. Not used on STA side.
406 * Defers the message if SME is in learn state and brings
407 * the LIM back to normal mode.
408 *
409 * Return: true - If defered false - Otherwise
410 */
411
412static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
413{
414 if (lim_is_system_in_scan_state(pMac)) {
415 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
416 lim_log(pMac, LOGE, FL("Could not defer Msg = %d"),
417 pMsg->type);
418 return false;
419 }
420 lim_log(pMac, LOG1,
421 FL("Defer the message, in learn mode type = %d"),
422 pMsg->type);
423 return true;
424 }
425 return false;
426}
427
428/**
429 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
430 * @mac_ctx: Pointer to Global MAC structure
431 * @message: Pointer to message posted from SME to LIM.
432 *
433 * Has role only if 11h is enabled. Not used on STA side.
434 * Defers the message if radar is detected.
435 *
436 * Return: true, if defered otherwise return false.
437 */
438static bool
439__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx, tpSirMsgQ message)
440{
441 /*
442 * fRadarDetCurOperChan will be set only if we
443 * detect radar in current operating channel and
444 * System Role == AP ROLE
445 *
446 * TODO: Need to take care radar detection.
447 *
448 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
449 */
450 if (0) {
451 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
452 lim_log(mac_ctx, LOGE, FL("Could not defer Msg = %d"),
453 message->type);
454 return false;
455 }
456 lim_log(mac_ctx, LOG1,
457 FL("Defer the message, in learn mode type = %d"),
458 message->type);
459 return true;
460 }
461 return false;
462}
463
464/**
465 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
466 * @pMac: Global MAC context
467 * @pMsgBuf: Message from WMA
468 *
469 * handles the notification from HDD. PE just forwards this message to HAL.
470 *
471 * Return: true-Posting to HAL failed, so PE will consume the buffer.
472 * false-Posting to HAL successful, so HAL will consume the buffer.
473 */
474
475static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
476{
477 tSirMsgQ msg;
478 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
479
480 msg.type = WMA_SYS_READY_IND;
481 msg.reserved = 0;
482 msg.bodyptr = pMsgBuf;
483 msg.bodyval = 0;
484
485 if (ANI_DRIVER_TYPE(pMac) != eDRIVER_TYPE_MFG) {
486 pe_register_wma_handle(pMac);
487 pMac->lim.add_bssdescr_callback = ready_req->add_bssdescr_cb;
488 }
489 PELOGW(lim_log(pMac, LOGW, FL("sending WMA_SYS_READY_IND msg to HAL"));)
490 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
491
492 if (eSIR_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
493 lim_log(pMac, LOGP, FL("wma_post_ctrl_msg failed"));
494 return true;
495 }
496 return false;
497}
498
499#ifdef WLAN_FEATURE_11AC
500
501uint32_t lim_get_center_channel(tpAniSirGlobal pMac, uint8_t primarychanNum,
502 ePhyChanBondState secondaryChanOffset,
503 uint8_t chanWidth)
504{
505 if (chanWidth == WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ) {
506 switch (secondaryChanOffset) {
507 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
508 return primarychanNum;
509 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
510 return primarychanNum + 2;
511 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
512 return primarychanNum - 2;
513 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
514 return primarychanNum + 6;
515 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
516 return primarychanNum + 2;
517 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
518 return primarychanNum - 2;
519 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
520 return primarychanNum - 6;
521 default:
522 return eSIR_CFG_INVALID_ID;
523 }
524 } else if (chanWidth == WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ) {
525 switch (secondaryChanOffset) {
526 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
527 return primarychanNum + 2;
528 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
529 return primarychanNum - 2;
530 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
531 return primarychanNum;
532 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
533 return primarychanNum + 2;
534 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
535 return primarychanNum - 2;
536 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
537 return primarychanNum + 2;
538 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
539 return primarychanNum - 2;
540 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
541 return primarychanNum + 2;
542 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
543 return primarychanNum - 2;
544 default:
545 return eSIR_CFG_INVALID_ID;
546 }
547 }
548 return primarychanNum;
549}
550
551#endif
552
553/**
554 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
555 *@mac_ctx: Pointer to Global MAC structure
556 *@session: A pointer to session entry
557 *@sme_start_bss_req: Start BSS Request from upper layers.
558 *
559 * This function is used to configure the start bss parameters
560 * in to the session.
561 *
562 * Return: None.
563 */
564static void
565lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
566 tpSirSmeStartBssReq sme_start_bss_req)
567{
568 session->limSystemRole = eLIM_AP_ROLE;
569 session->privacy = sme_start_bss_req->privacy;
570 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
571 session->authType = sme_start_bss_req->authType;
572 /* Store the DTIM period */
573 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
574 /* Enable/disable UAPSD */
575 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
576 if (session->pePersona == CDF_P2P_GO_MODE) {
577 session->proxyProbeRspEn = 0;
578 } else {
579 /*
580 * To detect PBC overlap in SAP WPS mode,
581 * Host handles Probe Requests.
582 */
583 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
584 session->proxyProbeRspEn = 1;
585 else
586 session->proxyProbeRspEn = 0;
587 }
588 session->ssidHidden = sme_start_bss_req->ssidHidden;
589 session->wps_state = sme_start_bss_req->wps_state;
590 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
591 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
592 &session->shortSlotTimeSupported);
593 session->isCoalesingInIBSSAllowed =
594 sme_start_bss_req->isCoalesingInIBSSAllowed;
595
596}
597
598/**
599 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
600 *@mac_ctx: Pointer to Global MAC structure
601 *@msg_buf: A pointer to the SME message buffer
602 *
603 * This function is called to process SME_START_BSS_REQ message
604 * from HDD or upper layer application.
605 *
606 * Return: None
607 */
608static void
609__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
610{
611 uint16_t size;
612 uint32_t val = 0;
613 tSirRetStatus ret_status;
614 tSirMacChanNum channel_number;
615 tLimMlmStartReq *mlm_start_req = NULL;
616 tpSirSmeStartBssReq sme_start_bss_req = NULL;
617 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
618 /* Flag Used in case of IBSS to Auto generate BSSID. */
619 uint32_t auto_gen_bssid = false;
620 uint8_t session_id;
621 tpPESession session = NULL;
622 uint8_t sme_session_id = 0;
623 uint16_t sme_transaction_id = 0;
624 uint32_t chanwidth;
625 tSirRetStatus cfg_get_wmi_dfs_master_param = eSIR_SUCCESS;
626
627/* FEATURE_WLAN_DIAG_SUPPORT */
628#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
629 /*
630 * Since the session is not created yet, sending NULL.
631 * The response should have the correct state.
632 */
633 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
634 NULL, 0, 0);
635#endif /* FEATURE_WLAN_DIAG_SUPPORT */
636
637 lim_log(mac_ctx, LOG1, FL("Received START_BSS_REQ"));
638
639 /*
640 * Global Sme state and mlm states are not defined yet,
641 * for BT-AMP Suppoprt . TO BE DONE
642 */
643 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
644 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
645 size = sizeof(tSirSmeStartBssReq);
646
647 sme_start_bss_req = cdf_mem_malloc(size);
648 if (NULL == sme_start_bss_req) {
649 lim_log(mac_ctx, LOGE,
650 FL("Allocate Memory fail for LimStartBssReq"));
651 /* Send failure response to host */
652 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
653 goto end;
654 }
655
656 cdf_mem_set((void *)sme_start_bss_req, size, 0);
657 cdf_mem_copy(sme_start_bss_req, msg_buf,
658 sizeof(tSirSmeStartBssReq));
659 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
660 sme_start_bss_req)) {
661 lim_log(mac_ctx, LOGW,
662 FL("Received invalid eWNI_SME_START_BSS_REQ"));
663 ret_code = eSIR_SME_INVALID_PARAMETERS;
664 goto free;
665 }
666
667 /*
668 * This is the place where PE is going to create a session.
669 * If session is not existed, then create a new session
670 */
671 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800672 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800673 if (session != NULL) {
674 lim_log(mac_ctx, LOGW,
675 FL("Session Already exists for given BSSID"));
676 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
677 session = NULL;
678 goto free;
679 } else {
680 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800681 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800682 &session_id, mac_ctx->lim.maxStation,
683 sme_start_bss_req->bssType);
684 if (session == NULL) {
685 lim_log(mac_ctx, LOGW,
686 FL("Session Can not be created "));
687 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
688 goto free;
689 }
690 }
691
692 /* Probe resp add ie */
693 lim_start_bss_update_add_ie_buffer(mac_ctx,
694 &session->addIeParams.probeRespData_buff,
695 &session->addIeParams.probeRespDataLen,
696 sme_start_bss_req->addIeParams.probeRespData_buff,
697 sme_start_bss_req->addIeParams.probeRespDataLen);
698
699 /* Probe Beacon add ie */
700 lim_start_bss_update_add_ie_buffer(mac_ctx,
701 &session->addIeParams.probeRespBCNData_buff,
702 &session->addIeParams.probeRespBCNDataLen,
703 sme_start_bss_req->addIeParams.probeRespBCNData_buff,
704 sme_start_bss_req->addIeParams.probeRespBCNDataLen);
705
706 /* Assoc resp IE */
707 lim_start_bss_update_add_ie_buffer(mac_ctx,
708 &session->addIeParams.assocRespData_buff,
709 &session->addIeParams.assocRespDataLen,
710 sme_start_bss_req->addIeParams.assocRespData_buff,
711 sme_start_bss_req->addIeParams.assocRespDataLen);
712
713 /* Store the session related params in newly created session */
714 session->pLimStartBssReq = sme_start_bss_req;
715
716 /* Store PE session_id in session Table */
717 session->peSessionId = session_id;
718
719 /* Store SME session Id in sessionTable */
720 session->smeSessionId = sme_start_bss_req->sessionId;
721
722 session->transactionId = sme_start_bss_req->transactionId;
723
724 cdf_mem_copy(&(session->htConfig),
725 &(sme_start_bss_req->htConfig),
726 sizeof(session->htConfig));
727
728 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800729 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800730
731 /* Copy SSID to session table */
732 cdf_mem_copy((uint8_t *) &session->ssId,
733 (uint8_t *) &sme_start_bss_req->ssId,
734 (sme_start_bss_req->ssId.length + 1));
735
736 session->bssType = sme_start_bss_req->bssType;
737
738 session->nwType = sme_start_bss_req->nwType;
739
740 session->beaconParams.beaconInterval =
741 sme_start_bss_req->beaconInterval;
742
743 /* Store the channel number in session Table */
744 session->currentOperChannel =
745 sme_start_bss_req->channelId;
746
747 /* Store Persona */
748 session->pePersona = sme_start_bss_req->bssPersona;
749 CDF_TRACE(CDF_MODULE_ID_PE, CDF_TRACE_LEVEL_INFO,
750 FL("PE PERSONA=%d"), session->pePersona);
751
752 /* Update the phymode */
753 session->gLimPhyMode = sme_start_bss_req->nwType;
754
755 session->maxTxPower =
756 cfg_get_regulatory_max_transmit_power(mac_ctx,
757 session->currentOperChannel);
758 /* Store the dot 11 mode in to the session Table */
759 session->dot11mode = sme_start_bss_req->dot11mode;
760#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
761 session->cc_switch_mode =
762 sme_start_bss_req->cc_switch_mode;
763#endif
764 session->htCapability =
765 IS_DOT11_MODE_HT(session->dot11mode);
766 session->vhtCapability =
767 IS_DOT11_MODE_VHT(session->dot11mode);
768 CDF_TRACE(CDF_MODULE_ID_PE, CDF_TRACE_LEVEL_INFO,
769 FL("*****session->vhtCapability = %d"),
770 session->vhtCapability);
771 session->txLdpcIniFeatureEnabled =
772 sme_start_bss_req->txLdpcIniFeatureEnabled;
773
774 if (mac_ctx->roam.configParam.enable2x2)
775 session->nss = 2;
776 else
777 session->nss = 1;
778#ifdef WLAN_FEATURE_11W
779 session->limRmfEnabled =
780 sme_start_bss_req->pmfCapable ? 1 : 0;
781 lim_log(mac_ctx, LOG1, FL("Session RMF enabled: %d"),
782 session->limRmfEnabled);
783#endif
784
785 cdf_mem_copy((void *)&session->rateSet,
786 (void *)&sme_start_bss_req->operationalRateSet,
787 sizeof(tSirMacRateSet));
788 cdf_mem_copy((void *)&session->extRateSet,
789 (void *)&sme_start_bss_req->extendedRateSet,
790 sizeof(tSirMacRateSet));
791
792 switch (sme_start_bss_req->bssType) {
793 case eSIR_INFRA_AP_MODE:
794 lim_configure_ap_start_bss_session(mac_ctx, session,
795 sme_start_bss_req);
796 break;
797 case eSIR_IBSS_MODE:
798 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
799 lim_get_short_slot_from_phy_mode(mac_ctx, session,
800 session->gLimPhyMode,
801 &session->shortSlotTimeSupported);
802
803 /*
804 * initialize to "OPEN".
805 * will be updated upon key installation
806 */
807 session->encryptType = eSIR_ED_NONE;
808
809 break;
810
811 case eSIR_BTAMP_AP_MODE:
812 session->limSystemRole = eLIM_BT_AMP_AP_ROLE;
813 break;
814
815 case eSIR_BTAMP_STA_MODE:
816 session->limSystemRole = eLIM_BT_AMP_STA_ROLE;
817 break;
818
819 /*
820 * There is one more mode called auto mode.
821 * which is used no where
822 */
823
824 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
825
826 default:
827 /* not used anywhere...used in scan function */
828 break;
829 }
830
831 /*
832 * BT-AMP: Allocate memory for the array of
833 * parsed (Re)Assoc request structure
834 */
835 if ((sme_start_bss_req->bssType == eSIR_BTAMP_AP_MODE) ||
836 (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE)) {
837 session->parsedAssocReq =
838 cdf_mem_malloc(session->dph.dphHashTable.
839 size * sizeof(tpSirAssocReq));
840 if (NULL == session->parsedAssocReq) {
841 lim_log(mac_ctx, LOGW,
842 FL("AllocateMemory() failed"));
843 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
844 goto free;
845 }
846 cdf_mem_set(session->parsedAssocReq,
847 (session->dph.dphHashTable.size *
848 sizeof(tpSirAssocReq)), 0);
849 }
850
851 if (!sme_start_bss_req->channelId) {
852 lim_log(mac_ctx, LOGE,
853 FL("Received invalid eWNI_SME_START_BSS_REQ"));
854 ret_code = eSIR_SME_INVALID_PARAMETERS;
855 goto free;
856 }
857 channel_number = sme_start_bss_req->channelId;
858#ifdef QCA_HT_2040_COEX
859 if (sme_start_bss_req->obssEnabled)
860 session->htSupportedChannelWidthSet =
861 session->htCapability;
862 else
863#endif
864 session->htSupportedChannelWidthSet =
865 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
866 session->htSecondaryChannelOffset =
867 sme_start_bss_req->sec_ch_offset;
868 session->htRecommendedTxWidthSet =
869 (session->htSecondaryChannelOffset) ? 1 : 0;
870 CDF_TRACE(CDF_MODULE_ID_PE, CDF_TRACE_LEVEL_INFO,
871 FL("cbMode %u"), sme_start_bss_req->cbMode);
872 if (session->vhtCapability || session->htCapability) {
873 chanwidth = sme_start_bss_req->vht_channel_width;
874 lim_log(mac_ctx, LOG1, FL("vht_channel_width %u"),
875 sme_start_bss_req->vht_channel_width);
876 if (channel_number <= RF_CHAN_14 &&
877 chanwidth != eHT_CHANNEL_WIDTH_20MHZ) {
878 chanwidth = CH_WIDTH_20MHZ;
879 session->htSupportedChannelWidthSet = 0;
880 lim_log(mac_ctx, LOG1,
881 FL("Set chanwidth to 20Mhz, chan %d"),
882 channel_number);
883 }
884 session->ch_width = chanwidth;
885 if (session->htSupportedChannelWidthSet) {
886 session->ch_center_freq_seg0 =
887 sme_start_bss_req->center_freq_seg0;
888 session->ch_center_freq_seg1 =
889 sme_start_bss_req->center_freq_seg1;
890 } else {
891 session->ch_center_freq_seg0 = 0;
892 session->ch_center_freq_seg1 = 0;
893 }
894 }
895
896 if (session->vhtCapability &&
897 (CH_WIDTH_160MHZ > session->ch_width)) {
898 if (wlan_cfg_get_int(mac_ctx,
899 WNI_CFG_VHT_SU_BEAMFORMER_CAP, &val) !=
900 eSIR_SUCCESS)
901 lim_log(mac_ctx, LOGE, FL(
902 "cfg get vht su bformer failed"));
903
904 session->enable_su_tx_bformer = val;
905 } else {
906 session->nss = 1;
907 }
908 lim_log(mac_ctx, LOG1, FL("vht su tx bformer %d"), val);
909
910 /* Delete pre-auth list if any */
911 lim_delete_pre_auth_list(mac_ctx);
912
913 /*
914 * keep the RSN/WPA IE information in PE Session Entry
915 * later will be using this to check when received (Re)Assoc req
916 */
917 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
918 &sme_start_bss_req->rsnIE, session);
919
920 if (LIM_IS_AP_ROLE(session) || LIM_IS_IBSS_ROLE(session)) {
921 session->gLimProtectionControl =
922 sme_start_bss_req->protEnabled;
923 /*
924 * each byte will have the following info
925 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
926 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
927 */
928 cdf_mem_copy((void *)&session->cfgProtection,
929 (void *)&sme_start_bss_req->ht_capab,
930 sizeof(uint16_t));
931 /* Initialize WPS PBC session link list */
932 session->pAPWPSPBCSession = NULL;
933 }
934 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
935 mlm_start_req = cdf_mem_malloc(sizeof(tLimMlmStartReq));
936 if (NULL == mlm_start_req) {
937 lim_log(mac_ctx, LOGP,
938 FL("Allocate Memory failed for mlmStartReq"));
939 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
940 goto free;
941 }
942
943 cdf_mem_set((void *)mlm_start_req, sizeof(tLimMlmStartReq), 0);
944
945 /* Copy SSID to the MLM start structure */
946 cdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
947 (uint8_t *) &sme_start_bss_req->ssId,
948 sme_start_bss_req->ssId.length + 1);
949 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
950 mlm_start_req->obssProtEnabled =
951 sme_start_bss_req->obssProtEnabled;
952
953 mlm_start_req->bssType = session->bssType;
954
955 /* Fill PE session Id from the session Table */
956 mlm_start_req->sessionId = session->peSessionId;
957
958 if ((mlm_start_req->bssType == eSIR_BTAMP_STA_MODE) ||
959 (mlm_start_req->bssType == eSIR_BTAMP_AP_MODE) ||
960 (mlm_start_req->bssType == eSIR_INFRA_AP_MODE)) {
961 /*
962 * Copy the BSSId from sessionTable to
963 * mlmStartReq struct
964 */
965 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
966 } else {
967 /* ibss mode */
968 mac_ctx->lim.gLimIbssCoalescingHappened = false;
969
970 ret_status = wlan_cfg_get_int(mac_ctx,
971 WNI_CFG_IBSS_AUTO_BSSID,
972 &auto_gen_bssid);
973 if (ret_status != eSIR_SUCCESS) {
974 lim_log(mac_ctx, LOGP,
975 FL("Get Auto Gen BSSID fail,Status=%d"),
976 ret_status);
977 ret_code = eSIR_LOGP_EXCEPTION;
978 goto free;
979 }
980
981 if (!auto_gen_bssid) {
982 /*
983 * We're not auto generating BSSID.
984 * Instead, get it from session entry
985 */
986 sir_copy_mac_addr(mlm_start_req->bssId,
987 session->bssId);
988 /*
989 * Start IBSS group BSSID
990 * Auto Generating BSSID.
991 */
992 auto_gen_bssid = ((mlm_start_req->bssId[0] &
993 0x01) ? true : false);
994 }
995
996 if (auto_gen_bssid) {
997 /*
998 * if BSSID is not any uc id.
999 * then use locally generated BSSID.
1000 * Autogenerate the BSSID
1001 */
1002 lim_get_random_bssid(mac_ctx,
1003 mlm_start_req->bssId);
1004 mlm_start_req->bssId[0] = 0x02;
1005
1006 /*
1007 * Copy randomly generated BSSID
1008 * to the session Table
1009 */
1010 sir_copy_mac_addr(session->bssId,
1011 mlm_start_req->bssId);
1012 }
1013 }
1014 /* store the channel num in mlmstart req structure */
1015 mlm_start_req->channelNumber = session->currentOperChannel;
1016 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
1017 mlm_start_req->beaconPeriod =
1018 session->beaconParams.beaconInterval;
1019
1020 if (LIM_IS_AP_ROLE(session)) {
1021 mlm_start_req->dtimPeriod = session->dtimPeriod;
1022 mlm_start_req->wps_state = session->wps_state;
1023
1024 } else {
1025 if (wlan_cfg_get_int(mac_ctx,
1026 WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
1027 lim_log(mac_ctx, LOGP,
1028 FL("could not retrieve DTIM Period"));
1029 mlm_start_req->dtimPeriod = (uint8_t) val;
1030 }
1031
1032 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_PERIOD, &val) !=
1033 eSIR_SUCCESS)
1034 lim_log(mac_ctx, LOGP,
1035 FL("could not retrieve Beacon interval"));
1036 mlm_start_req->cfParamSet.cfpPeriod = (uint8_t) val;
1037
1038 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_MAX_DURATION, &val) !=
1039 eSIR_SUCCESS)
1040 lim_log(mac_ctx, LOGP,
1041 FL("could not retrieve CFPMaxDuration"));
1042 mlm_start_req->cfParamSet.cfpMaxDuration = (uint16_t) val;
1043
1044 /*
1045 * this may not be needed anymore now,
1046 * as rateSet is now included in the
1047 * session entry and MLM has session context.
1048 */
1049 cdf_mem_copy((void *)&mlm_start_req->rateSet,
1050 (void *)&session->rateSet,
1051 sizeof(tSirMacRateSet));
1052
1053 /* Now populate the 11n related parameters */
1054 mlm_start_req->nwType = session->nwType;
1055 mlm_start_req->htCapable = session->htCapability;
1056
1057 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1058 /* Unused */
1059 mlm_start_req->dualCTSProtection =
1060 mac_ctx->lim.gHTDualCTSProtection;
1061 mlm_start_req->txChannelWidthSet =
1062 session->htRecommendedTxWidthSet;
1063
1064 session->limRFBand = lim_get_rf_band(channel_number);
1065
1066 /* Initialize 11h Enable Flag */
1067 session->lim11hEnable = 0;
1068 if ((mlm_start_req->bssType != eSIR_IBSS_MODE) &&
1069 (SIR_BAND_5_GHZ == session->limRFBand)) {
1070 if (wlan_cfg_get_int(mac_ctx,
1071 WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
1072 lim_log(mac_ctx, LOGP,
1073 FL("Fail to get WNI_CFG_11H_ENABLED "));
1074 else
1075 session->lim11hEnable = val;
1076
1077 if (session->lim11hEnable &&
1078 (eSIR_INFRA_AP_MODE ==
1079 mlm_start_req->bssType)) {
1080 cfg_get_wmi_dfs_master_param =
1081 wlan_cfg_get_int(mac_ctx,
1082 WNI_CFG_DFS_MASTER_ENABLED,
1083 &val);
1084 session->lim11hEnable = val;
1085 }
1086 if (cfg_get_wmi_dfs_master_param != eSIR_SUCCESS)
1087 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
1088 lim_log(mac_ctx, LOGE,
1089 FL("Get Fail, CFG DFS ENABLE"));
1090 }
1091
1092 if (!session->lim11hEnable) {
1093 if (cfg_set_int(mac_ctx,
1094 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
1095 eSIR_SUCCESS)
1096 /*
1097 * Failed to set the CFG param
1098 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1099 */
1100 lim_log(mac_ctx, LOGE,
1101 FL("Set LOCAL_POWER_CONSTRAINT failed"));
1102 }
1103
1104 session->limPrevSmeState = session->limSmeState;
1105 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1106 MTRACE(mac_trace
1107 (mac_ctx, TRACE_CODE_SME_STATE,
1108 session->peSessionId,
1109 session->limSmeState));
1110
1111 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1112 (uint32_t *) mlm_start_req);
1113 return;
1114 } else {
1115
1116 lim_log(mac_ctx, LOGE,
1117 FL("Received unexpected START_BSS_REQ, in state %X"),
1118 mac_ctx->lim.gLimSmeState);
1119 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
1120 goto end;
1121 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1122
1123free:
1124 if ((session != NULL) &&
1125 (session->pLimStartBssReq == sme_start_bss_req)) {
1126 session->pLimStartBssReq = NULL;
1127 }
1128 cdf_mem_free(sme_start_bss_req);
1129 cdf_mem_free(mlm_start_req);
1130
1131end:
1132 if (sme_start_bss_req != NULL) {
1133 sme_session_id = sme_start_bss_req->sessionId;
1134 sme_transaction_id = sme_start_bss_req->transactionId;
1135 }
1136 if (NULL != session) {
1137 pe_delete_session(mac_ctx, session);
1138 session = NULL;
1139 }
1140 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1141 session, sme_session_id, sme_transaction_id);
1142}
1143
1144/**
1145 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1146 *
1147 * @pMac: Global MAC context
1148 * @pMsg: Message pointer
1149 *
1150 * Wrapper for the function __lim_handle_sme_start_bss_request
1151 * This message will be defered until softmac come out of
1152 * scan mode or if we have detected radar on the current
1153 * operating channel.
1154 *
1155 * return true - If we consumed the buffer
1156 * false - If have defered the message.
1157 */
1158static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1159{
1160 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1161 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1162 /**
1163 * If message defered, buffer is not consumed yet.
1164 * So return false
1165 */
1166 return false;
1167 }
1168
1169 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1170 return true;
1171}
1172
1173/**
1174 * lim_get_random_bssid()
1175 *
1176 * FUNCTION:This function is called to process generate the random number for bssid
1177 * This function is called to process SME_SCAN_REQ message
1178 * from HDD or upper layer application.
1179 *
1180 * LOGIC:
1181 *
1182 * ASSUMPTIONS:
1183 *
1184 * NOTE:
1185 * 1. geneartes the unique random number for bssid in ibss
1186 *
1187 * @param pMac Pointer to Global MAC structure
1188 * @param *data Pointer to bssid buffer
1189 * @return None
1190 */
1191void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1192{
1193 uint32_t random[2];
1194 random[0] = tx_time_get();
1195 random[0] |= (random[0] << 15);
1196 random[1] = random[0] >> 1;
1197 cdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
1198}
1199
1200static CDF_STATUS lim_send_hal_start_scan_offload_req(tpAniSirGlobal pMac,
1201 tpSirSmeScanReq pScanReq)
1202{
1203 tSirScanOffloadReq *pScanOffloadReq;
1204 uint8_t *p;
1205 uint8_t *ht_cap_ie;
1206 tSirMsgQ msg;
1207 uint16_t i, len;
1208 uint16_t ht_cap_len = 0, addn_ie_len = 0;
1209#ifdef WLAN_FEATURE_11AC
1210 uint8_t *vht_cap_ie;
1211 uint16_t vht_cap_len = 0;
1212#endif /* WLAN_FEATURE_11AC */
1213 tSirRetStatus status, rc = eSIR_SUCCESS;
1214 tDot11fIEExtCap extracted_extcap = {0};
1215 bool extcap_present = true;
1216
1217 if (pScanReq->uIEFieldLen) {
1218 status = lim_strip_extcap_update_struct(pMac,
1219 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1220 &pScanReq->uIEFieldLen, &extracted_extcap);
1221
1222 if (eSIR_SUCCESS != status) {
1223 extcap_present = false;
1224 lim_log(pMac, LOG1,
1225 FL("Unable to Strip ExtCap IE from Scan Req"));
1226 }
1227
1228 if (extcap_present) {
1229 lim_log(pMac, LOG1,
1230 FL("Extcap was part of SCAN IE - Updating FW"));
1231 lim_send_ext_cap_ie(pMac, pScanReq->sessionId,
1232 &extracted_extcap, true);
1233 }
1234 } else {
1235 lim_log(pMac, LOG1,
1236 FL("No IEs in the scan request from supplicant"));
1237 }
1238
1239 /**
1240 * The tSirScanOffloadReq will reserve the space for first channel,
1241 * so allocate the memory for (numChannels - 1) and uIEFieldLen
1242 */
1243 len = sizeof(tSirScanOffloadReq) +
1244 (pScanReq->channelList.numChannels - 1) + pScanReq->uIEFieldLen;
1245
1246 if (IS_DOT11_MODE_HT(pScanReq->dot11mode)) {
1247 lim_log(pMac, LOG1,
1248 FL("Adding HT Caps IE since dot11mode=%d"),
1249 pScanReq->dot11mode);
1250 /* 2 bytes for EID and Length */
1251 ht_cap_len = 2 + sizeof(tHtCaps);
1252 len += ht_cap_len;
1253 addn_ie_len += ht_cap_len;
1254 }
1255
1256#ifdef WLAN_FEATURE_11AC
1257 if (IS_DOT11_MODE_VHT(pScanReq->dot11mode)) {
1258 lim_log(pMac, LOG1,
1259 FL("Adding VHT Caps IE since dot11mode=%d"),
1260 pScanReq->dot11mode);
1261 /* 2 bytes for EID and Length */
1262 vht_cap_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
1263 sizeof(tSirVhtMcsInfo);
1264 len += vht_cap_len;
1265 addn_ie_len += vht_cap_len;
1266 }
1267#endif /* WLAN_FEATURE_11AC */
1268
1269 pScanOffloadReq = cdf_mem_malloc(len);
1270 if (NULL == pScanOffloadReq) {
1271 lim_log(pMac, LOGE,
1272 FL("AllocateMemory failed for pScanOffloadReq"));
1273 return CDF_STATUS_E_NOMEM;
1274 }
1275
1276 cdf_mem_set((uint8_t *) pScanOffloadReq, len, 0);
1277
1278 msg.type = WMA_START_SCAN_OFFLOAD_REQ;
1279 msg.bodyptr = pScanOffloadReq;
1280 msg.bodyval = 0;
1281
Srinivas Girigowda2c6bf002015-09-24 11:43:31 -07001282 cdf_copy_macaddr(&pScanOffloadReq->bssId, &pScanReq->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001283
1284 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID) {
1285 lim_log(pMac, LOGE,
1286 FL("Invalid value (%d) for numSsid"),
1287 SIR_SCAN_MAX_NUM_SSID);
1288 cdf_mem_free(pScanOffloadReq);
1289 return CDF_STATUS_E_FAILURE;
1290 }
1291
1292 pScanOffloadReq->numSsid = pScanReq->numSsid;
1293 for (i = 0; i < pScanOffloadReq->numSsid; i++) {
1294 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
1295 cdf_mem_copy((uint8_t *) pScanOffloadReq->ssId[i].ssId,
1296 (uint8_t *) pScanReq->ssId[i].ssId,
1297 pScanOffloadReq->ssId[i].length);
1298 }
1299
1300 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Srinivas Girigowda2c6bf002015-09-24 11:43:31 -07001301 cdf_copy_macaddr(&pScanOffloadReq->selfMacAddr, &pScanReq->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001302 pScanOffloadReq->bssType = pScanReq->bssType;
1303 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1304 pScanOffloadReq->scanType = pScanReq->scanType;
1305 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1306 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1307 pScanOffloadReq->restTime = pScanReq->restTime;
1308
1309 /* for normal scan, the value for p2pScanType should be 0
1310 always */
1311 if (pScanReq->p2pSearch)
1312 pScanOffloadReq->p2pScanType = P2P_SCAN_TYPE_SEARCH;
1313
1314 pScanOffloadReq->sessionId = pScanReq->sessionId;
1315 pScanOffloadReq->scan_id = pScanReq->scan_id;
1316
1317 if (pScanOffloadReq->sessionId >= pMac->lim.maxBssId)
1318 lim_log(pMac, LOGE, FL("Invalid pe sessionID : %d"),
1319 pScanOffloadReq->sessionId);
1320
1321 pScanOffloadReq->channelList.numChannels =
1322 pScanReq->channelList.numChannels;
1323 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1324 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1325 p[i] = pScanReq->channelList.channelNumber[i];
1326
1327 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1328 pScanOffloadReq->uIEFieldOffset = len - addn_ie_len -
1329 pScanOffloadReq->uIEFieldLen;
1330 cdf_mem_copy((uint8_t *) pScanOffloadReq +
1331 pScanOffloadReq->uIEFieldOffset,
1332 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1333 pScanReq->uIEFieldLen);
1334
1335 /* Copy HT Capability info if dot11mode is HT */
1336 if (IS_DOT11_MODE_HT(pScanReq->dot11mode)) {
1337 /* Populate EID and Length field here */
1338 ht_cap_ie = (uint8_t *) pScanOffloadReq +
1339 pScanOffloadReq->uIEFieldOffset +
1340 pScanOffloadReq->uIEFieldLen;
1341 cdf_mem_set(ht_cap_ie, ht_cap_len, 0);
1342 *ht_cap_ie = SIR_MAC_HT_CAPABILITIES_EID;
1343 *(ht_cap_ie + 1) = ht_cap_len - 2;
1344 lim_set_ht_caps(pMac, NULL, ht_cap_ie, ht_cap_len);
1345 pScanOffloadReq->uIEFieldLen += ht_cap_len;
1346 }
1347
1348#ifdef WLAN_FEATURE_11AC
1349 /* Copy VHT Capability info if dot11mode is VHT Capable */
1350 if (IS_DOT11_MODE_VHT(pScanReq->dot11mode)) {
1351 /* Populate EID and Length field here */
1352 vht_cap_ie = (uint8_t *) pScanOffloadReq +
1353 pScanOffloadReq->uIEFieldOffset +
1354 pScanOffloadReq->uIEFieldLen;
1355 cdf_mem_set(vht_cap_ie, vht_cap_len, 0);
1356 *vht_cap_ie = SIR_MAC_VHT_CAPABILITIES_EID;
1357 *(vht_cap_ie + 1) = vht_cap_len - 2;
1358 lim_set_vht_caps(pMac, NULL, vht_cap_ie, vht_cap_len);
1359 pScanOffloadReq->uIEFieldLen += vht_cap_len;
1360 }
1361#endif /* WLAN_FEATURE_11AC */
1362
1363 rc = wma_post_ctrl_msg(pMac, &msg);
1364 if (rc != eSIR_SUCCESS) {
1365 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() return failure"));
1366 cdf_mem_free(pScanOffloadReq);
1367 return CDF_STATUS_E_FAILURE;
1368 }
1369
1370 lim_log(pMac, LOG1, FL("Processed Offload Scan Request Successfully"));
1371
1372 return CDF_STATUS_SUCCESS;
1373}
1374
1375/**
1376 * __lim_process_sme_scan_req() - Process the SME Scan Request
1377 * @mac_ctx: Global MAC Context
1378 * @msg_buf: Buffer which contains the request and pertinent parameters
1379 *
1380 * This function is called to process SME_SCAN_REQ message
1381 * from HDD or upper layer application.
1382 *
1383 * Return: None
1384 */
1385
1386static void __lim_process_sme_scan_req(tpAniSirGlobal mac_ctx,
1387 uint32_t *msg_buf)
1388{
1389 tpSirSmeScanReq scan_req;
1390 uint8_t valid_req = 0;
1391
1392#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1393 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL,
1394 eSIR_SUCCESS, eSIR_SUCCESS);
1395#endif
1396
1397 scan_req = (tpSirSmeScanReq) msg_buf;
1398 lim_log(mac_ctx, LOG1,
1399 FL("SME SCAN REQ id %d numChan %d min %d max %d IELen %d first %d fresh %d unique %d type %d rsp %d"),
1400 scan_req->scan_id, scan_req->channelList.numChannels,
1401 scan_req->minChannelTime, scan_req->maxChannelTime,
1402 scan_req->uIEFieldLen, scan_req->returnAfterFirstMatch,
1403 scan_req->returnFreshResults, scan_req->returnUniqueResults,
1404 scan_req->scanType, mac_ctx->lim.gLimRspReqd ? 1 : 0);
1405 /*
1406 * Since scan req always requires a response, we will overwrite response
1407 * required here. This is added esp to take care of the condition where
1408 * in p2p go case, we hold the scan req and insert single NOA. We send
1409 * the held scan request to FW later on getting start NOA ind from FW so
1410 * we lose state of the gLimRspReqd flag for the scan req if any other
1411 * request comes by then. e.g. While unit testing, we found when insert
1412 * single NOA is done, we see a get stats request which turns the flag
1413 * gLimRspReqd to false; now when we actually start the saved scan req
1414 * for init scan after getting NOA started, the gLimRspReqd being a
1415 * global flag is showing false instead of true value for this saved
1416 * scan req. Since all scan reqs coming to lim require a response,
1417 * there is no harm in setting the global flag gLimRspReqd to true here.
1418 */
1419 mac_ctx->lim.gLimRspReqd = true;
1420
1421 /*
1422 * copy the Self MAC address from SmeReq to the globalplace,
1423 * used for sending probe req
1424 */
Srinivas Girigowda2c6bf002015-09-24 11:43:31 -07001425 sir_copy_mac_addr(mac_ctx->lim.gSelfMacAddr,
1426 scan_req->selfMacAddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001427 valid_req = lim_is_sme_scan_req_valid(mac_ctx, scan_req);
1428
1429 if (!valid_req || mac_ctx->lim.scan_disabled) {
1430 lim_log(mac_ctx, LOGE,
1431 FL("Scan disabled %d, Valid Scan Req %d"),
1432 mac_ctx->lim.scan_disabled, valid_req);
1433
1434 if (mac_ctx->lim.gLimRspReqd) {
1435 mac_ctx->lim.gLimRspReqd = false;
1436
1437 lim_send_sme_scan_rsp(mac_ctx,
1438 eSIR_SME_INVALID_PARAMETERS,
1439 scan_req->sessionId,
1440 scan_req->transactionId,
1441 scan_req->scan_id);
1442 }
1443 return;
1444 }
1445
1446 /*
1447 * If scan request is received in idle, joinFailed
1448 * states or in link established state (in STA role)
1449 * or in normal state (in STA-in-IBSS/AP role) with
1450 * 'return fresh scan results' request from HDD or
1451 * it is periodic background scanning request,
1452 * trigger fresh scan request to MLM
1453 */
1454 if (__lim_fresh_scan_reqd(mac_ctx, scan_req->returnFreshResults)) {
1455
1456 mac_ctx->lim.gLim24Band11dScanDone = 0;
1457 mac_ctx->lim.gLim50Band11dScanDone = 0;
1458 mac_ctx->lim.gLimReturnAfterFirstMatch =
1459 scan_req->returnAfterFirstMatch;
1460 mac_ctx->lim.gLimReturnUniqueResults =
1461 ((scan_req->returnUniqueResults) > 0 ? true : false);
1462
1463 if (CDF_STATUS_SUCCESS !=
1464 lim_send_hal_start_scan_offload_req(mac_ctx,
1465 scan_req)) {
1466 lim_log(mac_ctx, LOGE, FL(
1467 "Couldn't send Offload scan request"));
1468 lim_send_sme_scan_rsp(mac_ctx,
1469 eSIR_SME_INVALID_PARAMETERS,
1470 scan_req->sessionId,
1471 scan_req->transactionId,
1472 scan_req->scan_id);
1473 return;
1474 }
1475 }
1476 else {
1477 /* In all other cases return 'cached' scan results */
1478 if (mac_ctx->lim.gLimRspReqd) {
1479 mac_ctx->lim.gLimRspReqd = false;
1480 lim_send_sme_scan_rsp(mac_ctx, eSIR_SME_SUCCESS,
1481 scan_req->sessionId,
1482 scan_req->transactionId, scan_req->scan_id);
1483 }
1484 }
1485}
1486
1487#ifdef FEATURE_OEM_DATA_SUPPORT
1488
1489static void __lim_process_sme_oem_data_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
1490{
1491 tpSirOemDataReq pOemDataReq;
1492 tLimMlmOemDataReq *pMlmOemDataReq;
1493
1494 pOemDataReq = (tpSirOemDataReq) pMsgBuf;
1495
1496 /* post the lim mlm message now */
1497 pMlmOemDataReq = cdf_mem_malloc(sizeof(tLimMlmOemDataReq));
1498 if (NULL == pMlmOemDataReq) {
1499 lim_log(pMac, LOGP,
1500 FL("AllocateMemory failed for mlmOemDataReq"));
1501 return;
1502 }
1503 /* Initialize this buffer */
1504 cdf_mem_set(pMlmOemDataReq, (sizeof(tLimMlmOemDataReq)), 0);
1505
Srinivas Girigowda0ee66862015-09-24 14:03:29 -07001506 cdf_copy_macaddr(&pMlmOemDataReq->selfMacAddr,
1507 &pOemDataReq->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001508 cdf_mem_copy(pMlmOemDataReq->oemDataReq, pOemDataReq->oemDataReq,
1509 OEM_DATA_REQ_SIZE);
1510
1511 /* Issue LIM_MLM_OEM_DATA_REQ to MLM */
1512 lim_post_mlm_message(pMac, LIM_MLM_OEM_DATA_REQ,
1513 (uint32_t *) pMlmOemDataReq);
1514
1515 return;
1516
1517} /*** end __lim_process_sme_oem_data_req() ***/
1518
1519#endif /* FEATURE_OEM_DATA_SUPPORT */
1520
1521/**
1522 * __lim_process_clear_dfs_channel_list()
1523 *
1524 ***FUNCTION:
1525 ***Clear DFS channel list when country is changed/aquired.
1526 .*This message is sent from SME.
1527 *
1528 ***LOGIC:
1529 *
1530 ***ASSUMPTIONS:
1531 *
1532 ***NOTE:
1533 *
1534 * @param pMac Pointer to Global MAC structure
1535 * @param *pMsgBuf A pointer to the SME message buffer
1536 * @return None
1537 */
1538static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1539{
1540 cdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
1541}
1542
1543/**
1544 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1545 * @mac_ctx: Pointer to Global MAC structure
1546 * @msg_buf: A pointer to the SME message buffer
1547 *
1548 * This function is called to process SME_JOIN_REQ message
1549 * from HDD or upper layer application.
1550 *
1551 * Return: None
1552 */
1553static void
1554__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1555{
1556 tpSirSmeJoinReq sme_join_req = NULL;
1557 tLimMlmJoinReq *mlm_join_req;
1558 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1559 uint32_t val = 0;
1560 uint16_t n_size;
1561 uint8_t session_id;
1562 tpPESession session = NULL;
1563 uint8_t sme_session_id;
1564 uint16_t sme_transaction_id;
1565 tPowerdBm local_power_constraint = 0, reg_max = 0;
1566 uint16_t ie_len;
1567 uint8_t *vendor_ie;
1568 tSirBssDescription bss_desc;
1569
1570/* FEATURE_WLAN_DIAG_SUPPORT */
1571#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1572 /*
1573 * Not sending any session, since it is not created yet.
1574 * The response whould have correct state.
1575 */
1576 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1577#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1578
1579 lim_log(mac_ctx, LOG1, FL("Received SME_JOIN_REQ"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001580
1581 /*
1582 * Expect Join request in idle state.
1583 * Reassociate request is expected in link established state.
1584 */
1585
1586 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1587 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1588 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1589 msg_buf);
1590
1591 sme_join_req = cdf_mem_malloc(n_size);
1592 if (NULL == sme_join_req) {
1593 lim_log(mac_ctx, LOGP,
1594 FL("AllocateMemory failed for sme_join_req"));
1595 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1596 return;
1597 }
1598 (void)cdf_mem_set((void *)sme_join_req, n_size, 0);
1599 (void)cdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
1600 n_size);
1601
1602 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1603 /* Received invalid eWNI_SME_JOIN_REQ */
1604 /* Log the event */
1605 lim_log(mac_ctx, LOGW,
1606 FL("SessionId:%d JOIN REQ with invalid data"),
1607 sme_join_req->sessionId);
1608 ret_code = eSIR_SME_INVALID_PARAMETERS;
1609 goto end;
1610 }
1611
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001612 /*
1613 * Update the capability here itself as this is used in
1614 * lim_extract_ap_capability() below. If not updated issues
1615 * like not honoring power constraint on 1st association after
1616 * driver loading might occur.
1617 */
1618 lim_update_rrm_capability(mac_ctx, sme_join_req);
1619
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001620 bss_desc = sme_join_req->bssDescription;
1621 /* check for the existence of start BSS session */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001622 session = pe_find_session_by_bssid(mac_ctx, bss_desc.bssId,
1623 &session_id);
1624
1625 if (session != NULL) {
1626 lim_log(mac_ctx, LOGE,
1627 FL("Session(%d) Already exists for BSSID: "
1628 MAC_ADDRESS_STR " in limSmeState = %X"),
1629 session_id,
1630 MAC_ADDR_ARRAY(bss_desc.bssId),
1631 session->limSmeState);
1632
1633 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1634 session->smeSessionId == sme_join_req->sessionId) {
1635 /*
1636 * Received eWNI_SME_JOIN_REQ for same
1637 * BSS as currently associated.
1638 * Log the event and send success
1639 */
1640 lim_log(mac_ctx, LOGW,
1641 FL("SessionId: %d"), session_id);
1642 lim_log(mac_ctx, LOGW,
1643 FL("JOIN_REQ for current joined BSS"));
1644 /* Send Join success response to host */
1645 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1646 session = NULL;
1647 goto end;
1648 } else {
1649 lim_log(mac_ctx, LOGE,
1650 FL("JOIN_REQ not for current joined BSS"));
1651 ret_code = eSIR_SME_REFUSED;
1652 session = NULL;
1653 goto end;
1654 }
1655 } else {
1656 /*
1657 * Session Entry does not exist for given BSSId
1658 * Try to Create a new session
1659 */
1660 session = pe_create_session(mac_ctx, bss_desc.bssId,
1661 &session_id, mac_ctx->lim.maxStation,
1662 eSIR_INFRASTRUCTURE_MODE);
1663 if (session == NULL) {
1664 lim_log(mac_ctx, LOGE,
1665 FL("Session Can not be created "));
1666 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1667 goto end;
1668 } else
1669 lim_log(mac_ctx, LOG1,
1670 FL("SessionId:%d New session created"),
1671 session_id);
1672 }
1673 session->isAmsduSupportInAMPDU =
1674 sme_join_req->isAmsduSupportInAMPDU;
1675
1676 /*
1677 * Store Session related parameters
1678 * Store PE session Id in session Table
1679 */
1680 session->peSessionId = session_id;
1681
1682 /* store the smejoin req handle in session table */
1683 session->pLimJoinReq = sme_join_req;
1684
1685 /* Store SME session Id in sessionTable */
1686 session->smeSessionId = sme_join_req->sessionId;
1687
1688 /* Store SME transaction Id in session Table */
1689 session->transactionId = sme_join_req->transactionId;
1690
1691 /* Store beaconInterval */
1692 session->beaconParams.beaconInterval =
1693 bss_desc.beaconInterval;
1694
1695 cdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
1696 sizeof(session->htConfig));
1697
1698 /* Copying of bssId is already done, while creating session */
1699 sir_copy_mac_addr(session->selfMacAddr,
1700 sme_join_req->selfMacAddr);
1701 session->bssType = sme_join_req->bsstype;
1702
1703 session->statypeForBss = STA_ENTRY_PEER;
1704 session->limWmeEnabled = sme_join_req->isWMEenabled;
1705 session->limQosEnabled = sme_join_req->isQosEnabled;
1706
1707 /* Store vendor specfic IE for CISCO AP */
1708 ie_len = (bss_desc.length + sizeof(bss_desc.length) -
1709 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1710
1711 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
1712 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
1713 ((uint8_t *)&bss_desc.ieFields), ie_len);
1714
1715 if (NULL != vendor_ie) {
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08001716 lim_log(mac_ctx, LOG1, FL("Cisco vendor OUI present"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001717 session->isCiscoVendorAP = true;
1718 } else {
1719 session->isCiscoVendorAP = false;
1720 }
1721
1722 /* Copy the dot 11 mode in to the session table */
1723
1724 session->dot11mode = sme_join_req->dot11mode;
1725#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1726 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1727#endif
1728 session->nwType = bss_desc.nwType;
1729 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1730 session->enableHtSmps = sme_join_req->enableHtSmps;
1731 session->htSmpsvalue = sme_join_req->htSmps;
1732
1733 /*Store Persona */
1734 session->pePersona = sme_join_req->staPersona;
1735 CDF_TRACE(CDF_MODULE_ID_PE, CDF_TRACE_LEVEL_INFO,
1736 FL("PE PERSONA=%d cbMode %u"),
1737 session->pePersona, sme_join_req->cbMode);
1738 if (mac_ctx->roam.configParam.enable2x2)
1739 session->nss = 2;
1740 else
1741 session->nss = 1;
1742#ifdef WLAN_FEATURE_11AC
1743 session->vhtCapability =
1744 IS_DOT11_MODE_VHT(session->dot11mode);
1745 CDF_TRACE(CDF_MODULE_ID_PE, CDF_TRACE_LEVEL_INFO_MED,
1746 "***__lim_process_sme_join_req: vhtCapability=%d****",
1747 session->vhtCapability);
1748 if (session->vhtCapability) {
1749 if (session->pePersona == CDF_STA_MODE) {
1750 session->txBFIniFeatureEnabled =
1751 sme_join_req->txBFIniFeatureEnabled;
1752 } else {
1753 session->txBFIniFeatureEnabled = 0;
1754 }
1755 session->txMuBformee = sme_join_req->txMuBformee;
1756 session->enableVhtpAid =
1757 sme_join_req->enableVhtpAid;
1758 session->enableVhtGid =
1759 sme_join_req->enableVhtGid;
1760
1761 CDF_TRACE(CDF_MODULE_ID_PE, CDF_TRACE_LEVEL_INFO_MED,
1762 FL("***txBFIniFeatureEnabled=%d***"),
1763 session->txBFIniFeatureEnabled);
1764 if (wlan_cfg_get_int(mac_ctx,
1765 WNI_CFG_VHT_SU_BEAMFORMER_CAP, &val) !=
1766 eSIR_SUCCESS)
1767 lim_log(mac_ctx, LOGE, FL(
1768 "cfg get vht su bformer failed"));
1769
1770 session->enable_su_tx_bformer = val;
1771 lim_log(mac_ctx, LOGE, FL("vht su tx bformer %d"), val);
1772 }
1773 if (session->vhtCapability && session->txBFIniFeatureEnabled) {
1774 if (cfg_set_int(mac_ctx, WNI_CFG_VHT_SU_BEAMFORMEE_CAP,
1775 session->txBFIniFeatureEnabled) !=
1776 eSIR_SUCCESS) {
1777 /*
1778 * Set failed for
1779 * CFG_VHT_SU_BEAMFORMEE_CAP
1780 */
1781 lim_log(mac_ctx, LOGP,
1782 FL("Failed CFG_VHT_SU_BEAMFORMEE_CAP"));
1783 ret_code = eSIR_LOGP_EXCEPTION;
1784 goto end;
1785 }
1786 CDF_TRACE(CDF_MODULE_ID_PE, CDF_TRACE_LEVEL_INFO_MED,
1787 "%s: txBFCsnValue=%d", __func__,
1788 sme_join_req->txBFCsnValue);
1789 if (cfg_set_int(mac_ctx,
1790 WNI_CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED,
1791 sme_join_req->txBFCsnValue) != eSIR_SUCCESS) {
1792 /*
1793 * Set Failed for CFG
1794 * CFG_VHT_CSN_BEAMFORMEE_ANT_SUPPORTED
1795 */
1796 lim_log(mac_ctx, LOGP, FL("Set Fail CFG"));
1797 ret_code = eSIR_LOGP_EXCEPTION;
1798 goto end;
1799 }
1800 }
1801#endif
1802
1803 /*Phy mode */
1804 session->gLimPhyMode = bss_desc.nwType;
1805 handle_ht_capabilityand_ht_info(mac_ctx, session);
1806 /* Copy The channel Id to the session Table */
1807 session->currentOperChannel = bss_desc.channelId;
1808 /* cbMode is already merged value of peer and self -
1809 * done by csr in csr_get_cb_mode_from_ies */
1810 session->htSupportedChannelWidthSet =
1811 (sme_join_req->cbMode) ? 1 : 0;
1812 session->htRecommendedTxWidthSet =
1813 session->htSupportedChannelWidthSet;
1814 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1815
1816 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1817 session->ch_center_freq_seg0 =
1818 session->currentOperChannel - 2;
1819 session->ch_width = CH_WIDTH_40MHZ;
1820 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1821 sme_join_req->cbMode) {
1822 session->ch_center_freq_seg0 =
1823 session->currentOperChannel + 2;
1824 session->ch_width = CH_WIDTH_40MHZ;
1825 } else {
1826 session->ch_center_freq_seg0 = 0;
1827 session->ch_width = CH_WIDTH_20MHZ;
1828 }
1829
1830 /* Record if management frames need to be protected */
1831#ifdef WLAN_FEATURE_11W
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001832 if (eSIR_ED_AES_128_CMAC == sme_join_req->MgmtEncryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001833 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001834 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001835 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001836#endif
1837
1838#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1839 session->rssi = bss_desc.rssi;
1840#endif
1841
1842 /* Copy the SSID from smejoinreq to session entry */
1843 session->ssId.length = sme_join_req->ssId.length;
1844 cdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
1845 session->ssId.length);
1846
1847 /*
1848 * Determin 11r or ESE connection based on input from SME
1849 * which inturn is dependent on the profile the user wants
1850 * to connect to, So input is coming from supplicant
1851 */
1852#ifdef WLAN_FEATURE_VOWIFI_11R
1853 session->is11Rconnection = sme_join_req->is11Rconnection;
1854#endif
1855#ifdef FEATURE_WLAN_ESE
1856 session->isESEconnection = sme_join_req->isESEconnection;
1857#endif
1858#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
1859 session->isFastTransitionEnabled =
1860 sme_join_req->isFastTransitionEnabled;
1861#endif
1862
1863#ifdef FEATURE_WLAN_LFR
1864 session->isFastRoamIniFeatureEnabled =
1865 sme_join_req->isFastRoamIniFeatureEnabled;
1866#endif
1867 session->txLdpcIniFeatureEnabled =
1868 sme_join_req->txLdpcIniFeatureEnabled;
1869
1870 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1871 session->limSystemRole = eLIM_STA_ROLE;
1872 } else if (session->bssType == eSIR_BTAMP_AP_MODE) {
1873 session->limSystemRole = eLIM_BT_AMP_STA_ROLE;
1874 } else {
1875 /*
1876 * Throw an error and return and make
1877 * sure to delete the session.
1878 */
1879 lim_log(mac_ctx, LOGE,
1880 FL("recvd JOIN_REQ with invalid bss type %d"),
1881 session->bssType);
1882 ret_code = eSIR_SME_INVALID_PARAMETERS;
1883 goto end;
1884 }
1885
1886 if (sme_join_req->addIEScan.length)
1887 cdf_mem_copy(&session->pLimJoinReq->addIEScan,
1888 &sme_join_req->addIEScan, sizeof(tSirAddie));
1889
1890 if (sme_join_req->addIEAssoc.length)
1891 cdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
1892 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1893
1894 val = sizeof(tLimMlmJoinReq) +
1895 session->pLimJoinReq->bssDescription.length + 2;
1896 mlm_join_req = cdf_mem_malloc(val);
1897 if (NULL == mlm_join_req) {
1898 lim_log(mac_ctx, LOGP,
1899 FL("AllocateMemory failed for mlmJoinReq"));
1900 return;
1901 }
1902 (void)cdf_mem_set((void *)mlm_join_req, val, 0);
1903
1904 /* PE SessionId is stored as a part of JoinReq */
1905 mlm_join_req->sessionId = session->peSessionId;
1906
1907 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1908 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1909 eSIR_SUCCESS) {
1910 lim_log(mac_ctx, LOGP,
1911 FL("couldn't retrieve JoinFailureTimer value"
1912 " setting to default value"));
1913 mlm_join_req->joinFailureTimeout =
1914 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1915 }
1916
1917 /* copy operational rate from session */
1918 cdf_mem_copy((void *)&session->rateSet,
1919 (void *)&sme_join_req->operationalRateSet,
1920 sizeof(tSirMacRateSet));
1921 cdf_mem_copy((void *)&session->extRateSet,
1922 (void *)&sme_join_req->extendedRateSet,
1923 sizeof(tSirMacRateSet));
1924 /*
1925 * this may not be needed anymore now, as rateSet is now
1926 * included in the session entry and MLM has session context.
1927 */
1928 cdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
1929 (void *)&session->rateSet,
1930 sizeof(tSirMacRateSet));
1931
1932 session->encryptType = sme_join_req->UCEncryptionType;
1933
1934 mlm_join_req->bssDescription.length =
1935 session->pLimJoinReq->bssDescription.length;
1936
1937 cdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
1938 (uint8_t *)
1939 &session->pLimJoinReq->bssDescription.bssId,
1940 session->pLimJoinReq->bssDescription.length + 2);
1941
1942 session->limCurrentBssCaps =
1943 session->pLimJoinReq->bssDescription.capabilityInfo;
1944
1945 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1946 session->currentOperChannel);
1947 local_power_constraint = reg_max;
1948
1949 lim_extract_ap_capability(mac_ctx,
1950 (uint8_t *)
1951 session->pLimJoinReq->bssDescription.ieFields,
1952 lim_get_ielen_from_bss_description(
1953 &session->pLimJoinReq->bssDescription),
1954 &session->limCurrentBssQosCaps,
1955 &session->limCurrentBssPropCap,
1956 &session->gLimCurrentBssUapsd,
1957 &local_power_constraint, session);
1958
1959#ifdef FEATURE_WLAN_ESE
1960 session->maxTxPower = lim_get_max_tx_power(reg_max,
1961 local_power_constraint,
1962 mac_ctx->roam.configParam.nTxPowerCap);
1963#else
1964 session->maxTxPower =
1965 CDF_MIN(reg_max, (local_power_constraint));
1966#endif
1967#if defined WLAN_VOWIFI_DEBUG
1968 lim_log(mac_ctx, LOGE,
1969 "Regulatory max = %d, local power constraint = %d"
1970 reg_max, local_power_constraint);
1971 lim_log(mac_ctx, LOGE, FL(" max tx = %d"),
1972 session->maxTxPower);
1973#endif
1974
1975 if (session->gLimCurrentBssUapsd) {
1976 session->gUapsdPerAcBitmask =
1977 session->pLimJoinReq->uapsdPerAcBitmask;
1978 lim_log(mac_ctx, LOG1,
1979 FL("UAPSD flag for all AC - 0x%2x"),
1980 session->gUapsdPerAcBitmask);
1981
1982 /* resetting the dynamic uapsd mask */
1983 session->gUapsdPerAcDeliveryEnableMask = 0;
1984 session->gUapsdPerAcTriggerEnableMask = 0;
1985 }
1986
1987 session->limRFBand =
1988 lim_get_rf_band(session->currentOperChannel);
1989
1990 /* Initialize 11h Enable Flag */
1991 if (SIR_BAND_5_GHZ == session->limRFBand) {
1992 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1993 &val) != eSIR_SUCCESS) {
1994 lim_log(mac_ctx, LOGP,
1995 FL("Fail to get WNI_CFG_11H_ENABLED "));
1996 session->lim11hEnable =
1997 WNI_CFG_11H_ENABLED_STADEF;
1998 } else {
1999 session->lim11hEnable = val;
2000 }
2001 } else {
2002 session->lim11hEnable = 0;
2003 }
2004
2005 /*
2006 * To care of the scenario when STA transitions from
2007 * IBSS to Infrastructure mode.
2008 */
2009 mac_ctx->lim.gLimIbssCoalescingHappened = false;
2010
2011 session->limPrevSmeState = session->limSmeState;
2012 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
2013 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2014 session->peSessionId,
2015 session->limSmeState));
2016
2017 lim_log(mac_ctx, LOG1,
2018 FL("SME JoinReq:Sessionid %d SSID len %d SSID : %s Channel %d, BSSID " MAC_ADDRESS_STR),
2019 mlm_join_req->sessionId, session->ssId.length,
2020 session->ssId.ssId, session->currentOperChannel,
2021 MAC_ADDR_ARRAY(session->bssId));
2022
2023 /* Indicate whether spectrum management is enabled */
2024 session->spectrumMgtEnabled =
2025 sme_join_req->spectrumMgtIndicator;
2026
2027 /* Enable the spectrum management if this is a DFS channel */
2028 if (session->country_info_present &&
2029 lim_isconnected_on_dfs_channel(
2030 session->currentOperChannel))
2031 session->spectrumMgtEnabled = true;
2032
2033 session->isOSENConnection = sme_join_req->isOSENConnection;
2034
2035 lim_log(mac_ctx, LOG1,
2036 FL("SessionId:%d MLM_JOIN_REQ is posted to MLM SM"),
2037 mlm_join_req->sessionId);
2038 /* Issue LIM_MLM_JOIN_REQ to MLM */
2039 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
2040 (uint32_t *) mlm_join_req);
2041 return;
2042
2043 } else {
2044 /* Received eWNI_SME_JOIN_REQ un expected state */
2045 lim_log(mac_ctx, LOGE,
2046 FL("received unexpected SME_JOIN_REQ in state %X"),
2047 mac_ctx->lim.gLimSmeState);
2048 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
2049 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2050 session = NULL;
2051 goto end;
2052 }
2053
2054end:
2055 sme_session_id = sme_join_req->sessionId;
2056 sme_transaction_id = sme_join_req->transactionId;
2057
2058 if (sme_join_req) {
2059 cdf_mem_free(sme_join_req);
2060 sme_join_req = NULL;
2061 if (NULL != session)
2062 session->pLimJoinReq = NULL;
2063 }
2064 if (ret_code != eSIR_SME_SUCCESS) {
2065 if (NULL != session) {
2066 pe_delete_session(mac_ctx, session);
2067 session = NULL;
2068 }
2069 }
2070 lim_log(mac_ctx, LOG1,
2071 FL("Send failure status on sessionid: %d with ret_code = %d"),
2072 sme_session_id, ret_code);
2073 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
2074 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
2075 sme_transaction_id);
2076}
2077
2078#if defined FEATURE_WLAN_ESE || defined WLAN_FEATURE_VOWIFI
2079uint8_t lim_get_max_tx_power(tPowerdBm regMax, tPowerdBm apTxPower,
2080 uint8_t iniTxPower)
2081{
2082 uint8_t maxTxPower = 0;
2083 uint8_t txPower = CDF_MIN(regMax, (apTxPower));
2084 txPower = CDF_MIN(txPower, iniTxPower);
2085 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2086 maxTxPower = txPower;
2087 else if (txPower < MIN_TX_PWR_CAP)
2088 maxTxPower = MIN_TX_PWR_CAP;
2089 else
2090 maxTxPower = MAX_TX_PWR_CAP;
2091
2092 return maxTxPower;
2093}
2094#endif
2095
2096/**
2097 * __lim_process_sme_reassoc_req() - process reassoc req
2098 *
2099 * @mac_ctx: Pointer to Global MAC structure
2100 * @msg_buf: pointer to the SME message buffer
2101 *
2102 * This function is called to process SME_REASSOC_REQ message
2103 * from HDD or upper layer application.
2104 *
2105 * Return: None
2106 */
2107
2108static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2109 uint32_t *msg_buf)
2110{
2111 uint16_t caps;
2112 uint32_t val;
2113 tpSirSmeJoinReq reassoc_req = NULL;
2114 tLimMlmReassocReq *mlm_reassoc_req;
2115 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2116 tpPESession session_entry = NULL;
2117 uint8_t session_id;
2118 uint8_t sme_session_id;
2119 uint16_t transaction_id;
2120 tPowerdBm local_pwr_constraint = 0, reg_max = 0;
2121 uint32_t tele_bcn_en = 0;
2122 uint16_t size;
2123
2124 lim_log(mac_ctx, LOG3, FL("Received REASSOC_REQ"));
2125
2126 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
2127 reassoc_req = cdf_mem_malloc(size);
2128 if (NULL == reassoc_req) {
2129 lim_log(mac_ctx, LOGP,
2130 FL("call to AllocateMemory failed for reassoc_req"));
2131
2132 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2133 goto end;
2134 }
2135 (void)cdf_mem_set((void *)reassoc_req, size, 0);
2136 (void)cdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
2137
2138 if (!lim_is_sme_join_req_valid(mac_ctx,
2139 (tpSirSmeJoinReq)reassoc_req)) {
2140 /*
2141 * Received invalid eWNI_SME_REASSOC_REQ
2142 */
2143 lim_log(mac_ctx, LOGW,
2144 FL("received SME_REASSOC_REQ with invalid data"));
2145
2146 ret_code = eSIR_SME_INVALID_PARAMETERS;
2147 goto end;
2148 }
2149
2150 session_entry = pe_find_session_by_bssid(mac_ctx,
2151 reassoc_req->bssDescription.bssId,
2152 &session_id);
2153 if (session_entry == NULL) {
2154 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2155 LOGE);
2156 lim_log(mac_ctx, LOGE,
2157 FL("Session does not exist for given bssId"));
2158 ret_code = eSIR_SME_INVALID_PARAMETERS;
2159 goto end;
2160 }
2161#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2162 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2163 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2164#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2165 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2166
2167 /* Store the reassoc handle in the session Table */
2168 session_entry->pLimReAssocReq = reassoc_req;
2169
2170 session_entry->dot11mode = reassoc_req->dot11mode;
2171 session_entry->vhtCapability =
2172 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
2173 /*
2174 * Reassociate request is expected
2175 * in link established state only.
2176 */
2177
2178 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
2179#if defined(WLAN_FEATURE_VOWIFI_11R) || defined(FEATURE_WLAN_ESE) || \
2180 defined(FEATURE_WLAN_LFR)
2181 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2182 /*
2183 * May be from 11r FT pre-auth. So lets check it
2184 * before we bail out
2185 */
2186 lim_log(mac_ctx, LOG1, FL(
2187 "Session in reassoc state is %d"),
2188 session_entry->peSessionId);
2189
2190 /* Make sure its our preauth bssid */
2191 if (!cdf_mem_compare(reassoc_req->bssDescription.bssId,
2192 session_entry->limReAssocbssId,
2193 6)) {
2194 lim_print_mac_addr(mac_ctx,
2195 reassoc_req->bssDescription.
2196 bssId, LOGE);
2197 lim_log(mac_ctx, LOGP,
2198 FL("Unknown bssId in reassoc state"));
2199 ret_code = eSIR_SME_INVALID_PARAMETERS;
2200 goto end;
2201 }
2202
2203 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2204 session_entry);
2205 return;
2206 }
2207#endif
2208 /*
2209 * Should not have received eWNI_SME_REASSOC_REQ
2210 */
2211 lim_log(mac_ctx, LOGE,
2212 FL("received unexpected SME_REASSOC_REQ in state %X"),
2213 session_entry->limSmeState);
2214 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2215
2216 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2217 goto end;
2218 }
2219
2220 cdf_mem_copy(session_entry->limReAssocbssId,
2221 session_entry->pLimReAssocReq->bssDescription.bssId,
2222 sizeof(tSirMacAddr));
2223
2224 session_entry->limReassocChannelId =
2225 session_entry->pLimReAssocReq->bssDescription.channelId;
2226
2227 session_entry->reAssocHtSupportedChannelWidthSet =
2228 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2229 session_entry->reAssocHtRecommendedTxWidthSet =
2230 session_entry->reAssocHtSupportedChannelWidthSet;
2231 session_entry->reAssocHtSecondaryChannelOffset =
2232 session_entry->pLimReAssocReq->cbMode;
2233
2234 session_entry->limReassocBssCaps =
2235 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2236 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2237 session_entry->currentOperChannel);
2238 local_pwr_constraint = reg_max;
2239
2240 lim_extract_ap_capability(mac_ctx,
2241 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2242 lim_get_ielen_from_bss_description(
2243 &session_entry->pLimReAssocReq->bssDescription),
2244 &session_entry->limReassocBssQosCaps,
2245 &session_entry->limReassocBssPropCap,
2246 &session_entry->gLimCurrentBssUapsd,
2247 &local_pwr_constraint, session_entry);
2248 session_entry->maxTxPower = CDF_MIN(reg_max, (local_pwr_constraint));
2249#if defined WLAN_VOWIFI_DEBUG
2250 lim_log(mac_ctx, LOGE,
2251 "Regulatory max = %d, local pwr constraint = %d, max tx = %d",
2252 reg_max, local_pwr_constraint,
2253 session_entry->maxTxPower);
2254#endif
2255 /* Copy the SSID from session entry to local variable */
2256 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
2257 cdf_mem_copy(session_entry->limReassocSSID.ssId,
2258 reassoc_req->ssId.ssId,
2259 session_entry->limReassocSSID.length);
2260 if (session_entry->gLimCurrentBssUapsd) {
2261 session_entry->gUapsdPerAcBitmask =
2262 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
2263 lim_log(mac_ctx, LOG1,
2264 FL("UAPSD flag for all AC - 0x%2x"),
2265 session_entry->gUapsdPerAcBitmask);
2266 }
2267
2268 mlm_reassoc_req = cdf_mem_malloc(sizeof(tLimMlmReassocReq));
2269 if (NULL == mlm_reassoc_req) {
2270 lim_log(mac_ctx, LOGP,
2271 FL("call to AllocateMemory failed for mlmReassocReq"));
2272
2273 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2274 goto end;
2275 }
2276
2277 cdf_mem_copy(mlm_reassoc_req->peerMacAddr,
2278 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2279
2280 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2281 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
2282 eSIR_SUCCESS) {
2283 /*
2284 * Could not get ReassocFailureTimeout value
2285 * from CFG. Log error.
2286 */
2287 lim_log(mac_ctx, LOGP,
2288 FL("could not retrieve ReassocFailureTimeout value"));
2289 }
2290
2291 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
2292 eSIR_SUCCESS) {
2293 /*
2294 * Could not get Capabilities value
2295 * from CFG. Log error.
2296 */
2297 lim_log(mac_ctx, LOGP, FL(
2298 "could not retrieve Capabilities value"));
2299 }
2300 mlm_reassoc_req->capabilityInfo = caps;
2301
2302 /* Update PE session_id */
2303 mlm_reassoc_req->sessionId = session_id;
2304
2305 /*
2306 * If telescopic beaconing is enabled, set listen interval to
2307 * WNI_CFG_TELE_BCN_MAX_LI
2308 */
2309 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2310 &tele_bcn_en) != eSIR_SUCCESS)
2311 lim_log(mac_ctx, LOGP,
2312 FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
2313
2314 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2315
2316 if (tele_bcn_en) {
2317 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2318 eSIR_SUCCESS)
2319 /*
2320 * Could not get ListenInterval value
2321 * from CFG. Log error.
2322 */
2323 lim_log(mac_ctx, LOGP,
2324 FL("could not retrieve ListenInterval"));
2325 } else {
2326 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
2327 eSIR_SUCCESS)
2328 /*
2329 * Could not get ListenInterval value
2330 * from CFG. Log error.
2331 */
2332 lim_log(mac_ctx, LOGP,
2333 FL("could not retrieve ListenInterval"));
2334 }
2335
2336 mlm_reassoc_req->listenInterval = (uint16_t) val;
2337
2338 /* Indicate whether spectrum management is enabled */
2339 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2340
2341 /* Enable the spectrum management if this is a DFS channel */
2342 if (session_entry->country_info_present &&
2343 lim_isconnected_on_dfs_channel(
2344 session_entry->currentOperChannel))
2345 session_entry->spectrumMgtEnabled = true;
2346
2347 session_entry->limPrevSmeState = session_entry->limSmeState;
2348 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2349
2350 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2351 session_entry->peSessionId,
2352 session_entry->limSmeState));
2353
2354 lim_post_mlm_message(mac_ctx,
2355 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2356 return;
2357end:
2358 if (reassoc_req) {
2359 cdf_mem_free(reassoc_req);
2360 if (session_entry)
2361 session_entry->pLimReAssocReq = NULL;
2362 }
2363
2364 if (session_entry) {
2365 /*
2366 * error occurred after we determined the session so extract
2367 * session and transaction info from there
2368 */
2369 sme_session_id = session_entry->smeSessionId;
2370 transaction_id = session_entry->transactionId;
2371 } else
2372 /*
2373 * error occurred before or during the time we determined
2374 * the session so extract the session and transaction info
2375 * from the message
2376 */
2377 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2378 &sme_session_id, &transaction_id);
2379
2380 /*
2381 * Send Reassoc failure response to host
2382 * (note session_entry may be NULL, but that's OK)
2383 */
2384 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2385 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2386 session_entry, sme_session_id,
2387 transaction_id);
2388}
2389
2390bool send_disassoc_frame = 1;
2391/**
2392 * __lim_process_sme_disassoc_req()
2393 *
2394 ***FUNCTION:
2395 * This function is called to process SME_DISASSOC_REQ message
2396 * from HDD or upper layer application.
2397 *
2398 ***LOGIC:
2399 *
2400 ***ASSUMPTIONS:
2401 *
2402 ***NOTE:
2403 *
2404 * @param pMac Pointer to Global MAC structure
2405 * @param *pMsgBuf A pointer to the SME message buffer
2406 * @return None
2407 */
2408
2409static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2410{
2411 uint16_t disassocTrigger, reasonCode;
2412 tLimMlmDisassocReq *pMlmDisassocReq;
2413 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2414 tSirSmeDisassocReq smeDisassocReq;
2415 tpPESession psessionEntry = NULL;
2416 uint8_t sessionId;
2417 uint8_t smesessionId;
2418 uint16_t smetransactionId;
2419
2420 if (pMsgBuf == NULL) {
2421 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
2422 return;
2423 }
2424
2425 cdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
2426 smesessionId = smeDisassocReq.sessionId;
2427 smetransactionId = smeDisassocReq.transactionId;
2428 if (!lim_is_sme_disassoc_req_valid(pMac,
2429 &smeDisassocReq,
2430 psessionEntry)) {
2431 PELOGE(lim_log(pMac, LOGE,
2432 FL("received invalid SME_DISASSOC_REQ message"));)
2433 if (pMac->lim.gLimRspReqd) {
2434 pMac->lim.gLimRspReqd = false;
2435
2436 retCode = eSIR_SME_INVALID_PARAMETERS;
2437 disassocTrigger = eLIM_HOST_DISASSOC;
2438 goto sendDisassoc;
2439 }
2440
2441 return;
2442 }
2443
2444 psessionEntry = pe_find_session_by_bssid(pMac,
2445 smeDisassocReq.bssId,
2446 &sessionId);
2447 if (psessionEntry == NULL) {
2448 lim_log(pMac, LOGE,
2449 FL("session does not exist for given bssId "
2450 MAC_ADDRESS_STR),
2451 MAC_ADDR_ARRAY(smeDisassocReq.bssId));
2452 retCode = eSIR_SME_INVALID_PARAMETERS;
2453 disassocTrigger = eLIM_HOST_DISASSOC;
2454 goto sendDisassoc;
2455 }
2456 lim_log(pMac, LOG1,
2457 FL("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2458 MAC_ADDRESS_STR), smesessionId,
2459 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2460 pMac->lim.gLimSmeState,
2461 MAC_ADDR_ARRAY(smeDisassocReq.peerMacAddr));
2462
2463#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2464 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2465 0, smeDisassocReq.reasonCode);
2466#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2467
2468 /* Update SME session Id and SME transaction ID */
2469
2470 psessionEntry->smeSessionId = smesessionId;
2471 psessionEntry->transactionId = smetransactionId;
2472
2473 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2474 case eLIM_STA_ROLE:
2475 case eLIM_BT_AMP_STA_ROLE:
2476 switch (psessionEntry->limSmeState) {
2477 case eLIM_SME_ASSOCIATED_STATE:
2478 case eLIM_SME_LINK_EST_STATE:
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002479 lim_log(pMac, LOG1,
2480 FL("Rcvd SME_DISASSOC_REQ in limSmeState: %d "),
2481 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002482 psessionEntry->limPrevSmeState =
2483 psessionEntry->limSmeState;
2484 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2485#ifdef FEATURE_WLAN_TDLS
2486 /* Delete all TDLS peers connected before leaving BSS */
2487 lim_delete_tdls_peers(pMac, psessionEntry);
2488#endif
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002489 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2490 psessionEntry->peSessionId,
2491 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002492 break;
2493
2494 case eLIM_SME_WT_DEAUTH_STATE:
2495 /* PE shall still process the DISASSOC_REQ and proceed with
2496 * link tear down even if it had already sent a DEAUTH_IND to
2497 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2498 * its been set when PE entered WT_DEAUTH_STATE.
2499 */
2500 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2501 MTRACE(mac_trace
2502 (pMac, TRACE_CODE_SME_STATE,
2503 psessionEntry->peSessionId,
2504 psessionEntry->limSmeState));
2505 lim_log(pMac, LOG1,
2506 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE. "));
2507 break;
2508
2509 case eLIM_SME_WT_DISASSOC_STATE:
2510 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2511 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2512 * PE can continue processing DISASSOC_REQ and send the response instead
2513 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2514 * for disassoc frame.
2515 *
2516 * It will send a disassoc, which is ok. However, we can use the global flag
2517 * sendDisassoc to not send disassoc frame.
2518 */
2519 lim_log(pMac, LOG1,
2520 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE. "));
2521 break;
2522
2523 case eLIM_SME_JOIN_FAILURE_STATE: {
2524 /* Already in Disconnected State, return success */
2525 lim_log(pMac, LOG1,
2526 FL("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE. "));
2527 if (pMac->lim.gLimRspReqd) {
2528 retCode = eSIR_SME_SUCCESS;
2529 disassocTrigger = eLIM_HOST_DISASSOC;
2530 goto sendDisassoc;
2531 }
2532 }
2533 break;
2534 default:
2535 /**
2536 * STA is not currently associated.
2537 * Log error and send response to host
2538 */
2539 lim_log(pMac, LOGE,
2540 FL("received unexpected SME_DISASSOC_REQ in state %X"),
2541 psessionEntry->limSmeState);
2542 lim_print_sme_state(pMac, LOGE,
2543 psessionEntry->limSmeState);
2544
2545 if (pMac->lim.gLimRspReqd) {
2546 if (psessionEntry->limSmeState !=
2547 eLIM_SME_WT_ASSOC_STATE)
2548 pMac->lim.gLimRspReqd = false;
2549
2550 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2551 disassocTrigger = eLIM_HOST_DISASSOC;
2552 goto sendDisassoc;
2553 }
2554
2555 return;
2556 }
2557
2558 break;
2559
2560 case eLIM_AP_ROLE:
2561 case eLIM_BT_AMP_AP_ROLE:
2562 /* Fall through */
2563 break;
2564
2565 case eLIM_STA_IN_IBSS_ROLE:
2566 default:
2567 /* eLIM_UNKNOWN_ROLE */
2568 lim_log(pMac, LOGE,
2569 FL("received unexpected SME_DISASSOC_REQ for role %d"),
2570 GET_LIM_SYSTEM_ROLE(psessionEntry));
2571
2572 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2573 disassocTrigger = eLIM_HOST_DISASSOC;
2574 goto sendDisassoc;
2575 } /* end switch (pMac->lim.gLimSystemRole) */
2576
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302577 disassocTrigger = eLIM_HOST_DISASSOC;
2578 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002579
2580 if (smeDisassocReq.doNotSendOverTheAir) {
2581 lim_log(pMac, LOG1, FL("do not send dissoc over the air"));
2582 send_disassoc_frame = 0;
2583 }
2584 /* Trigger Disassociation frame to peer MAC entity */
2585 lim_log(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2586 " : %d, reasonCode : %d"),
2587 disassocTrigger, reasonCode);
2588
2589 pMlmDisassocReq = cdf_mem_malloc(sizeof(tLimMlmDisassocReq));
2590 if (NULL == pMlmDisassocReq) {
2591 /* Log error */
2592 lim_log(pMac, LOGP,
2593 FL("call to AllocateMemory failed for mlmDisassocReq"));
2594
2595 return;
2596 }
2597
2598 cdf_mem_copy((uint8_t *) &pMlmDisassocReq->peerMacAddr,
2599 (uint8_t *) &smeDisassocReq.peerMacAddr,
2600 sizeof(tSirMacAddr));
2601
2602 pMlmDisassocReq->reasonCode = reasonCode;
2603 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2604
2605 /* Update PE session ID */
2606 pMlmDisassocReq->sessionId = sessionId;
2607
2608 lim_post_mlm_message(pMac,
2609 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2610 return;
2611
2612sendDisassoc:
2613 if (psessionEntry)
2614 lim_send_sme_disassoc_ntf(pMac, smeDisassocReq.peerMacAddr,
2615 retCode,
2616 disassocTrigger,
2617 1, smesessionId, smetransactionId,
2618 psessionEntry);
2619 else
2620 lim_send_sme_disassoc_ntf(pMac, smeDisassocReq.peerMacAddr,
2621 retCode,
2622 disassocTrigger,
2623 1, smesessionId, smetransactionId, NULL);
2624
2625} /*** end __lim_process_sme_disassoc_req() ***/
2626
2627/** -----------------------------------------------------------------
2628 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2629
2630 This function is called to process SME_DISASSOC_CNF message
2631 from HDD or upper layer application.
2632
2633 \param pMac - global mac structure
2634 \param pStaDs - station dph hash node
2635 \return none
2636 \sa
2637 ----------------------------------------------------------------- */
2638static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2639{
2640 tSirSmeDisassocCnf smeDisassocCnf;
2641 uint16_t aid;
2642 tpDphHashNode pStaDs;
2643 tpPESession psessionEntry;
2644 uint8_t sessionId;
2645
2646 PELOG1(lim_log(pMac, LOG1, FL("received DISASSOC_CNF message"));)
2647
2648 cdf_mem_copy(&smeDisassocCnf, pMsgBuf,
2649 sizeof(struct sSirSmeDisassocCnf));
2650
2651 psessionEntry = pe_find_session_by_bssid(pMac,
2652 smeDisassocCnf.bssId,
2653 &sessionId);
2654 if (psessionEntry == NULL) {
2655 lim_log(pMac, LOGE,
2656 FL("session does not exist for given bssId"));
2657 return;
2658 }
2659
2660 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
2661 lim_log(pMac, LOGE,
2662 FL("received invalid SME_DISASSOC_CNF message"));
2663 return;
2664 }
2665#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2666 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2667 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2668 psessionEntry,
2669 (uint16_t) smeDisassocCnf.statusCode, 0);
2670 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2671 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2672 psessionEntry,
2673 (uint16_t) smeDisassocCnf.statusCode, 0);
2674#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2675
2676 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2677 case eLIM_STA_ROLE:
2678 case eLIM_BT_AMP_STA_ROLE: /* To test reconn */
2679 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2680 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2681 && (psessionEntry->limSmeState !=
2682 eLIM_SME_WT_DEAUTH_STATE)) {
2683 lim_log(pMac, LOGE,
2684 FL
2685 ("received unexp SME_DISASSOC_CNF in state %X"),
2686 psessionEntry->limSmeState);
2687 lim_print_sme_state(pMac, LOGE,
2688 psessionEntry->limSmeState);
2689 return;
2690 }
2691 break;
2692
2693 case eLIM_AP_ROLE:
2694 /* Fall through */
2695 break;
2696
2697 case eLIM_STA_IN_IBSS_ROLE:
2698 default: /* eLIM_UNKNOWN_ROLE */
2699 lim_log(pMac, LOGE,
2700 FL("received unexpected SME_DISASSOC_CNF role %d"),
2701 GET_LIM_SYSTEM_ROLE(psessionEntry));
2702
2703 return;
2704 }
2705
2706 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2707 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2708 LIM_IS_AP_ROLE(psessionEntry)) {
2709 pStaDs = dph_lookup_hash_entry(pMac,
2710 smeDisassocCnf.peerMacAddr, &aid,
2711 &psessionEntry->dph.dphHashTable);
2712 if (pStaDs == NULL) {
2713 lim_log(pMac, LOGE,
2714 FL("DISASSOC_CNF for a STA with no context, addr= "
2715 MAC_ADDRESS_STR),
2716 MAC_ADDR_ARRAY(smeDisassocCnf.peerMacAddr));
2717 return;
2718 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302719
2720 if ((pStaDs->mlmStaContext.mlmState ==
2721 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2722 (pStaDs->mlmStaContext.mlmState ==
2723 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
2724 lim_log(pMac, LOGE,
2725 FL("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d"),
2726 MAC_ADDR_ARRAY(smeDisassocCnf.peerMacAddr),
2727 pStaDs->mlmStaContext.mlmState);
2728 return;
2729 }
2730
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002731#if defined WLAN_FEATURE_VOWIFI_11R
2732 /* Delete FT session if there exists one */
2733 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
2734#endif
2735 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2736
2737 lim_clean_up_disassoc_deauth_req(pMac,
2738 (char *)&smeDisassocCnf.peerMacAddr,
2739 0);
2740 }
2741
2742 return;
2743}
2744
2745/**
2746 * __lim_process_sme_deauth_req() - process sme deauth req
2747 * @mac_ctx: Pointer to Global MAC structure
2748 * @msg_buf: pointer to the SME message buffer
2749 *
2750 * This function is called to process SME_DEAUTH_REQ message
2751 * from HDD or upper layer application.
2752 *
2753 * Return: None
2754 */
2755
2756static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2757 uint32_t *msg_buf)
2758{
2759 uint16_t deauth_trigger, reason_code;
2760 tLimMlmDeauthReq *mlm_deauth_req;
2761 tSirSmeDeauthReq sme_deauth_req;
2762 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2763 tpPESession session_entry;
2764 uint8_t session_id; /* PE sessionId */
2765 uint8_t sme_session_id;
2766 uint16_t sme_transaction_id;
2767
2768 lim_log(mac_ctx, LOG1, FL("received DEAUTH_REQ message"));
2769
2770 cdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
2771 sme_session_id = sme_deauth_req.sessionId;
2772 sme_transaction_id = sme_deauth_req.transactionId;
2773
2774 /*
2775 * We need to get a session first but we don't even know
2776 * if the message is correct.
2777 */
2778 session_entry = pe_find_session_by_bssid(mac_ctx, sme_deauth_req.bssId,
2779 &session_id);
2780 if (session_entry == NULL) {
2781 lim_log(mac_ctx, LOGE,
2782 FL("session does not exist for given bssId"));
2783 ret_code = eSIR_SME_INVALID_PARAMETERS;
2784 deauth_trigger = eLIM_HOST_DEAUTH;
2785 goto send_deauth;
2786 }
2787
2788 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2789 session_entry)) {
2790 lim_log(mac_ctx, LOGE,
2791 FL("received invalid SME_DEAUTH_REQ message"));
2792 mac_ctx->lim.gLimRspReqd = false;
2793
2794 ret_code = eSIR_SME_INVALID_PARAMETERS;
2795 deauth_trigger = eLIM_HOST_DEAUTH;
2796 goto send_deauth;
2797 }
2798 lim_log(mac_ctx, LOG1,
2799 FL("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2800 MAC_ADDRESS_STR), sme_session_id,
2801 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2802 session_entry->limSmeState,
2803 MAC_ADDR_ARRAY(sme_deauth_req.peerMacAddr));
2804#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2805 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2806 session_entry, 0, sme_deauth_req.reasonCode);
2807#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2808
2809 /* Update SME session ID and Transaction ID */
2810 session_entry->smeSessionId = sme_session_id;
2811 session_entry->transactionId = sme_transaction_id;
2812
2813 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2814 case eLIM_STA_ROLE:
2815 case eLIM_BT_AMP_STA_ROLE:
2816
2817 switch (session_entry->limSmeState) {
2818 case eLIM_SME_ASSOCIATED_STATE:
2819 case eLIM_SME_LINK_EST_STATE:
2820 case eLIM_SME_WT_ASSOC_STATE:
2821 case eLIM_SME_JOIN_FAILURE_STATE:
2822 case eLIM_SME_IDLE_STATE:
2823 session_entry->limPrevSmeState =
2824 session_entry->limSmeState;
2825 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2826 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2827 session_entry->peSessionId,
2828 session_entry->limSmeState));
2829 /* Send Deauthentication request to MLM below */
2830 break;
2831 case eLIM_SME_WT_DEAUTH_STATE:
2832 case eLIM_SME_WT_DISASSOC_STATE:
2833 /*
2834 * PE Recieved a Deauth/Disassoc frame. Normally it get
2835 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2836 * Which means host is also trying to disconnect.
2837 * PE can continue processing DEAUTH_REQ and send
2838 * the response instead of failing the request.
2839 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2840 * was sent for deauth/disassoc frame.
2841 */
2842 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2843 lim_log(mac_ctx, LOG1, FL(
2844 "Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE"));
2845 break;
2846 default:
2847 /*
2848 * STA is not in a state to deauthenticate with
2849 * peer. Log error and send response to host.
2850 */
2851 lim_log(mac_ctx, LOGE, FL(
2852 "received unexp SME_DEAUTH_REQ in state %X"),
2853 session_entry->limSmeState);
2854 lim_print_sme_state(mac_ctx, LOGE,
2855 session_entry->limSmeState);
2856
2857 if (mac_ctx->lim.gLimRspReqd) {
2858 mac_ctx->lim.gLimRspReqd = false;
2859
2860 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2861 deauth_trigger = eLIM_HOST_DEAUTH;
2862
2863 /*
2864 * here we received deauth request from AP so sme state
2865 * is eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED
2866 * delSta then mlm state should be
2867 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got delBSS
2868 * rsp then mlm state should be eLIM_MLM_IDLE_STATE
2869 * so the below condition captures the state where
2870 * delSta not done and firmware still in
2871 * connected state.
2872 */
2873 if (session_entry->limSmeState ==
2874 eLIM_SME_WT_DEAUTH_STATE &&
2875 session_entry->limMlmState !=
2876 eLIM_MLM_IDLE_STATE &&
2877 session_entry->limMlmState !=
2878 eLIM_MLM_WT_DEL_STA_RSP_STATE)
2879 ret_code = eSIR_SME_DEAUTH_STATUS;
2880 goto send_deauth;
2881 }
2882 return;
2883 }
2884 break;
2885
2886 case eLIM_STA_IN_IBSS_ROLE:
2887 lim_log(mac_ctx, LOGE, FL("Deauth not allowed in IBSS"));
2888 if (mac_ctx->lim.gLimRspReqd) {
2889 mac_ctx->lim.gLimRspReqd = false;
2890 ret_code = eSIR_SME_INVALID_PARAMETERS;
2891 deauth_trigger = eLIM_HOST_DEAUTH;
2892 goto send_deauth;
2893 }
2894 return;
2895 case eLIM_AP_ROLE:
2896 break;
2897 default:
2898 lim_log(mac_ctx, LOGE,
2899 FL("received unexpected SME_DEAUTH_REQ for role %X"),
2900 GET_LIM_SYSTEM_ROLE(session_entry));
2901 if (mac_ctx->lim.gLimRspReqd) {
2902 mac_ctx->lim.gLimRspReqd = false;
2903 ret_code = eSIR_SME_INVALID_PARAMETERS;
2904 deauth_trigger = eLIM_HOST_DEAUTH;
2905 goto send_deauth;
2906 }
2907 return;
2908 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2909
2910 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2911 /* Deauthentication is triggered by Link Monitoring */
2912 lim_log(mac_ctx, LOG1, FL("** Lost link with AP **"));
2913 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2914 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2915 } else {
2916 deauth_trigger = eLIM_HOST_DEAUTH;
2917 reason_code = sme_deauth_req.reasonCode;
2918 }
2919
2920 /* Trigger Deauthentication frame to peer MAC entity */
2921 mlm_deauth_req = cdf_mem_malloc(sizeof(tLimMlmDeauthReq));
2922 if (NULL == mlm_deauth_req) {
2923 lim_log(mac_ctx, LOGP,
2924 FL("call to AllocateMemory failed for mlmDeauthReq"));
2925 if (mac_ctx->lim.gLimRspReqd) {
2926 mac_ctx->lim.gLimRspReqd = false;
2927 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2928 deauth_trigger = eLIM_HOST_DEAUTH;
2929 goto send_deauth;
2930 }
2931 return;
2932 }
2933
2934 cdf_mem_copy((uint8_t *) &mlm_deauth_req->peerMacAddr,
2935 (uint8_t *) &sme_deauth_req.peerMacAddr,
2936 sizeof(tSirMacAddr));
2937
2938 mlm_deauth_req->reasonCode = reason_code;
2939 mlm_deauth_req->deauthTrigger = deauth_trigger;
2940
2941 /* Update PE session Id */
2942 mlm_deauth_req->sessionId = session_id;
2943
2944 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2945 (uint32_t *)mlm_deauth_req);
2946 return;
2947
2948send_deauth:
2949 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peerMacAddr, ret_code,
2950 deauth_trigger, 1, sme_session_id, sme_transaction_id);
2951}
2952
2953/**
2954 * __lim_process_sme_set_context_req()
2955 *
2956 * @mac_ctx: Pointer to Global MAC structure
2957 * @msg_buf: pointer to the SME message buffer
2958 *
2959 * This function is called to process SME_SETCONTEXT_REQ message
2960 * from HDD or upper layer application.
2961 *
2962 * Return: None
2963 */
2964
2965static void
2966__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2967{
2968 tpSirSmeSetContextReq set_context_req;
2969 tLimMlmSetKeysReq *mlm_set_key_req;
2970 tpPESession session_entry;
2971 uint8_t session_id; /* PE sessionID */
2972 uint8_t sme_session_id;
2973 uint16_t sme_transaction_id;
2974
2975 lim_log(mac_ctx, LOG1, FL("received SETCONTEXT_REQ message"));
2976
2977 if (msg_buf == NULL) {
2978 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
2979 return;
2980 }
2981
2982 set_context_req = cdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
2983 if (NULL == set_context_req) {
2984 lim_log(mac_ctx, LOGP, FL(
2985 "call to AllocateMemory failed for set_context_req"));
2986 return;
2987 }
2988 cdf_mem_copy(set_context_req, msg_buf,
2989 sizeof(struct sSirSmeSetContextReq));
2990 sme_session_id = set_context_req->sessionId;
2991 sme_transaction_id = set_context_req->transactionId;
2992
2993 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
2994 lim_log(mac_ctx, LOGW,
2995 FL("received invalid SME_SETCONTEXT_REQ message"));
2996 goto end;
2997 }
2998
2999 if (set_context_req->keyMaterial.numKeys >
3000 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3001 lim_log(mac_ctx, LOGE, FL(
3002 "numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS"),
3003 set_context_req->keyMaterial.numKeys);
3004 lim_send_sme_set_context_rsp(mac_ctx,
3005 set_context_req->peerMacAddr, 1,
3006 eSIR_SME_INVALID_PARAMETERS, NULL,
3007 sme_session_id, sme_transaction_id);
3008 goto end;
3009 }
3010
3011 session_entry = pe_find_session_by_bssid(mac_ctx,
3012 set_context_req->bssId, &session_id);
3013 if (session_entry == NULL) {
3014 lim_log(mac_ctx, LOGW,
3015 FL("Session does not exist for given BSSID"));
3016 lim_send_sme_set_context_rsp(mac_ctx,
3017 set_context_req->peerMacAddr, 1,
3018 eSIR_SME_INVALID_PARAMETERS, NULL,
3019 sme_session_id, sme_transaction_id);
3020 goto end;
3021 }
3022#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3023 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
3024 session_entry, 0, 0);
3025#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3026
3027 if (((LIM_IS_STA_ROLE(session_entry) ||
3028 LIM_IS_BT_AMP_STA_ROLE(session_entry)) &&
3029 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3030 ((LIM_IS_IBSS_ROLE(session_entry) ||
3031 LIM_IS_AP_ROLE(session_entry) ||
3032 LIM_IS_BT_AMP_AP_ROLE(session_entry)) &&
3033 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
3034 /* Trigger MLM_SETKEYS_REQ */
3035 mlm_set_key_req = cdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
3036 if (NULL == mlm_set_key_req) {
3037 lim_log(mac_ctx, LOGP, FL(
3038 "mem alloc failed for mlmSetKeysReq"));
3039 goto end;
3040 }
3041 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
3042 mlm_set_key_req->numKeys =
3043 set_context_req->keyMaterial.numKeys;
3044 if (mlm_set_key_req->numKeys >
3045 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3046 lim_log(mac_ctx, LOGP, FL(
3047 "no.of keys exceeded max num of default keys limit"));
3048 goto end;
3049 }
3050 cdf_mem_copy((uint8_t *) &mlm_set_key_req->peerMacAddr,
3051 (uint8_t *) &set_context_req->peerMacAddr,
3052 sizeof(tSirMacAddr));
3053
3054 cdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
3055 (uint8_t *) &set_context_req->keyMaterial.key,
3056 sizeof(tSirKeys) *
3057 (mlm_set_key_req->numKeys ? mlm_set_key_req->
3058 numKeys : 1));
3059
3060 mlm_set_key_req->sessionId = session_id;
3061 mlm_set_key_req->smesessionId = sme_session_id;
3062#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
3063 lim_log(mac_ctx, LOG1, FL(
3064 "received SETCONTEXT_REQ message sessionId=%d"),
3065 mlm_set_key_req->sessionId);
3066#endif
3067
3068 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
3069 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
3070 LIM_IS_AP_ROLE(session_entry)) {
3071 if (set_context_req->keyMaterial.key[0].keyLength) {
3072 uint8_t key_id;
3073 key_id =
3074 set_context_req->keyMaterial.key[0].keyId;
3075 cdf_mem_copy((uint8_t *)
3076 &session_entry->WEPKeyMaterial[key_id],
3077 (uint8_t *) &set_context_req->keyMaterial,
3078 sizeof(tSirKeyMaterial));
3079 } else {
3080 uint32_t i;
3081 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
3082 i++) {
3083 cdf_mem_copy((uint8_t *)
3084 &mlm_set_key_req->key[i],
3085 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
3086 sizeof(tSirKeys));
3087 }
3088 }
3089 }
3090 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
3091 (uint32_t *) mlm_set_key_req);
3092 } else {
3093 lim_log(mac_ctx, LOGE, FL(
3094 "rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
3095 GET_LIM_SYSTEM_ROLE(session_entry),
3096 session_entry->limSmeState);
3097 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
3098
3099 lim_send_sme_set_context_rsp(mac_ctx,
3100 set_context_req->peerMacAddr, 1,
3101 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
3102 session_entry, sme_session_id,
3103 sme_transaction_id);
3104 }
3105end:
3106 cdf_mem_free(set_context_req);
3107 return;
3108}
3109
3110/**
3111 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
3112 *
3113 * @mac_ctx: Pointer to Global MAC structure
3114 * @msg_buf: pointer to the SME message buffer
3115 *
3116 * This function is called to process SME_GET_ASSOC_STAS_REQ message
3117 * from HDD or upper layer application.
3118 *
3119 * Return: None
3120 */
3121
3122void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
3123 uint32_t *msg_buf)
3124{
3125 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3126 tpDphHashNode sta_ds = NULL;
3127 tpPESession session_entry = NULL;
3128 tSap_Event sap_event;
3129 tpWLAN_SAPEventCB sap_event_cb = NULL;
3130 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3131 uint8_t session_id = CSR_SESSION_ID_INVALID;
3132 uint8_t assoc_id = 0;
3133 uint8_t sta_cnt = 0;
3134
3135 if (msg_buf == NULL) {
3136 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3137 return;
3138 }
3139
3140 cdf_mem_copy(&get_assoc_stas_req, msg_buf,
3141 sizeof(struct sSirSmeGetAssocSTAsReq));
3142 /*
3143 * Get Associated stations from PE.
3144 * Find PE session Entry
3145 */
3146 session_entry = pe_find_session_by_bssid(mac_ctx,
3147 get_assoc_stas_req.bssId,
3148 &session_id);
3149 if (session_entry == NULL) {
3150 lim_log(mac_ctx, LOGE,
3151 FL("session does not exist for given bssId"));
3152 goto lim_assoc_sta_end;
3153 }
3154
3155 if (!LIM_IS_AP_ROLE(session_entry)) {
3156 lim_log(mac_ctx, LOGE, FL(
3157 "Received unexpected message in state %X, in role %X"),
3158 session_entry->limSmeState,
3159 GET_LIM_SYSTEM_ROLE(session_entry));
3160 goto lim_assoc_sta_end;
3161 }
3162 /* Retrieve values obtained in the request message */
3163 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3164 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3165
3166 if (NULL == assoc_sta_tmp)
3167 goto lim_assoc_sta_end;
3168 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3169 assoc_id++) {
3170 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3171 &session_entry->dph.dphHashTable);
3172 if (NULL == sta_ds)
3173 continue;
3174 if (sta_ds->valid) {
3175 cdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
3176 (uint8_t *) &sta_ds->staAddr,
3177 CDF_MAC_ADDR_SIZE);
3178 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3179 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3180
3181 cdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
3182 (uint8_t *)&sta_ds->supportedRates,
3183 sizeof(tSirSupportedRates));
3184 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3185 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3186 assoc_sta_tmp->Support40Mhz =
3187 sta_ds->htDsssCckRate40MHzSupport;
3188
3189 lim_log(mac_ctx, LOG1, FL("dph Station Number = %d"),
3190 sta_cnt + 1);
3191 lim_log(mac_ctx, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3192 MAC_ADDR_ARRAY(sta_ds->staAddr));
3193 lim_log(mac_ctx, LOG1, FL("Association Id = %d"),
3194 sta_ds->assocId);
3195 lim_log(mac_ctx, LOG1, FL("Station Index = %d"),
3196 sta_ds->staIndex);
3197 assoc_sta_tmp++;
3198 sta_cnt++;
3199 }
3200 }
3201lim_assoc_sta_end:
3202 /*
3203 * Call hdd callback with sap event to send the list of
3204 * associated stations from PE
3205 */
3206 if (sap_event_cb != NULL) {
3207 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3208 sap_event.sapevt.sapAssocStaListEvent.module =
3209 CDF_MODULE_ID_PE;
3210 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3211 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3212 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3213 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3214 }
3215}
3216
3217/**
3218 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3219 *
3220 * @mac_ctx: Pointer to Global MAC structure
3221 * @msg_buf: pointer to WPS PBC overlap query message
3222 *
3223 * This function parses get WPS PBC overlap information
3224 * message and call callback to pass WPS PBC overlap
3225 * information back to hdd.
3226 *
3227 * Return: None
3228 */
3229void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3230 uint32_t *msg_buf)
3231{
3232 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3233 tpPESession session_entry = NULL;
3234 tSap_Event sap_event;
3235 tpWLAN_SAPEventCB sap_event_cb = NULL;
3236 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003237 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3238
3239 if (msg_buf == NULL) {
3240 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3241 return;
3242 }
3243
3244 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
3245 sap_get_wpspbc_event->status = CDF_STATUS_E_FAULT;
3246
3247 cdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
3248 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3249 /*
3250 * Get Associated stations from PE
3251 * Find PE session Entry
3252 */
3253 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003254 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003255 if (session_entry == NULL) {
3256 lim_log(mac_ctx, LOGE,
3257 FL("session does not exist for given bssId"));
3258 goto lim_get_wpspbc_sessions_end;
3259 }
3260
3261 if (!LIM_IS_AP_ROLE(session_entry)) {
3262 lim_log(mac_ctx, LOGE,
3263 FL("Received unexpected message in role %X"),
3264 GET_LIM_SYSTEM_ROLE(session_entry));
3265 goto lim_get_wpspbc_sessions_end;
3266 }
3267 /*
3268 * Call hdd callback with sap event to send the
3269 * WPS PBC overlap information
3270 */
3271 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
3272 sap_get_wpspbc_event->module = CDF_MODULE_ID_PE;
3273
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003274 if (cdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003275 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003276 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003277 sap_get_wpspbc_event->UUID_E,
3278 &sap_get_wpspbc_event->wpsPBCOverlap,
3279 session_entry);
3280 } else {
3281 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003282 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003283 session_entry);
3284 /* don't have to inform the HDD/Host */
3285 return;
3286 }
3287
3288 lim_log(mac_ctx, LOGE, FL("wpsPBCOverlap %d"),
3289 sap_get_wpspbc_event->wpsPBCOverlap);
3290 lim_print_mac_addr(mac_ctx,
3291 sap_get_wpspbc_event->addr.bytes, LOG4);
3292
3293 sap_get_wpspbc_event->status = CDF_STATUS_SUCCESS;
3294
3295lim_get_wpspbc_sessions_end:
3296 sap_event_cb =
3297 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3298 if (NULL != sap_event_cb)
3299 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3300}
3301
3302/**
3303 * __lim_counter_measures()
3304 *
3305 * FUNCTION:
3306 * This function is called to "implement" MIC counter measure
3307 * and is *temporary* only
3308 *
3309 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3310 * we don't do the proper STA disassoc sequence since the
3311 * BSS will be stoped anyway
3312 *
3313 ***ASSUMPTIONS:
3314 *
3315 ***NOTE:
3316 *
3317 * @param pMac Pointer to Global MAC structure
3318 * @return None
3319 */
3320
3321static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3322{
3323 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3324 if (LIM_IS_AP_ROLE(psessionEntry) ||
3325 LIM_IS_BT_AMP_AP_ROLE(psessionEntry) ||
3326 LIM_IS_BT_AMP_STA_ROLE(psessionEntry))
3327 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3328 mac, psessionEntry, false);
3329};
3330
3331void lim_process_tkip_counter_measures(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3332{
3333 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3334 tpPESession psessionEntry;
3335 uint8_t sessionId; /* PE sessionId */
3336
3337 cdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
3338 sizeof(struct sSirSmeTkipCntrMeasReq));
3339
3340 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003341 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003342 if (NULL == psessionEntry) {
3343 lim_log(pMac, LOGE,
3344 FL("session does not exist for given BSSID "));
3345 return;
3346 }
3347
3348 if (tkipCntrMeasReq.bEnable)
3349 __lim_counter_measures(pMac, psessionEntry);
3350
3351 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3352}
3353
3354static void
3355__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3356{
3357 tSirSmeStopBssReq stopBssReq;
3358 tSirRetStatus status;
3359 tLimSmeStates prevState;
3360 tpPESession psessionEntry;
3361 uint8_t smesessionId;
3362 uint8_t sessionId;
3363 uint16_t smetransactionId;
3364 uint8_t i = 0;
3365 tpDphHashNode pStaDs = NULL;
3366
3367 cdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
3368 smesessionId = stopBssReq.sessionId;
3369 smetransactionId = stopBssReq.transactionId;
3370
3371 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
3372 PELOGW(lim_log(pMac, LOGW,
3373 FL("received invalid SME_STOP_BSS_REQ message"));)
3374 /* Send Stop BSS response to host */
3375 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3376 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3377 smetransactionId);
3378 return;
3379 }
3380
3381 psessionEntry = pe_find_session_by_bssid(pMac,
3382 stopBssReq.bssId,
3383 &sessionId);
3384 if (psessionEntry == NULL) {
3385 lim_log(pMac, LOGW,
3386 FL("session does not exist for given BSSID "));
3387 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3388 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3389 smetransactionId);
3390 return;
3391 }
3392#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3393 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3394 0, 0);
3395#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3396
3397 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3398 LIM_IS_STA_ROLE(psessionEntry)) {
3399 /**
3400 * Should not have received STOP_BSS_REQ in states
3401 * other than 'normal' state or on STA in Infrastructure
3402 * mode. Log error and return response to host.
3403 */
3404 lim_log(pMac, LOGE,
3405 FL
3406 ("received unexpected SME_STOP_BSS_REQ in state %X, for role %d"),
3407 psessionEntry->limSmeState,
3408 GET_LIM_SYSTEM_ROLE(psessionEntry));
3409 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3410 /* / Send Stop BSS response to host */
3411 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3412 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3413 smetransactionId);
3414 return;
3415 }
3416
3417 if (LIM_IS_AP_ROLE(psessionEntry))
3418 lim_wpspbc_close(pMac, psessionEntry);
3419
3420 lim_log(pMac, LOGW,
3421 FL("RECEIVED STOP_BSS_REQ with reason code=%d"),
3422 stopBssReq.reasonCode);
3423
3424 prevState = psessionEntry->limSmeState;
3425
3426 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3427 MTRACE(mac_trace
3428 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3429 psessionEntry->limSmeState));
3430
3431 /* Update SME session Id and Transaction Id */
3432 psessionEntry->smeSessionId = smesessionId;
3433 psessionEntry->transactionId = smetransactionId;
3434
3435 /* BTAMP_STA and STA_IN_IBSS should NOT send Disassoc frame */
3436 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3437 !LIM_IS_BT_AMP_STA_ROLE(psessionEntry)) {
3438 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3439 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3440 /* Send disassoc all stations associated thru TKIP */
3441 __lim_counter_measures(pMac, psessionEntry);
3442 else
3443 lim_send_disassoc_mgmt_frame(pMac,
3444 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3445 bcAddr, psessionEntry, false);
3446 }
3447
3448 /* Free the buffer allocated in START_BSS_REQ */
3449 cdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3450 psessionEntry->addIeParams.probeRespDataLen = 0;
3451 psessionEntry->addIeParams.probeRespData_buff = NULL;
3452
3453 cdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3454 psessionEntry->addIeParams.assocRespDataLen = 0;
3455 psessionEntry->addIeParams.assocRespData_buff = NULL;
3456
3457 cdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3458 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3459 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
3460
3461 /* lim_del_bss is also called as part of coalescing, when we send DEL BSS followed by Add Bss msg. */
3462 pMac->lim.gLimIbssCoalescingHappened = false;
3463
3464 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3465 pStaDs =
3466 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3467 if (NULL == pStaDs)
3468 continue;
3469 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3470 if (eSIR_SUCCESS == status) {
3471 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3472 pStaDs->assocId, psessionEntry);
3473 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3474 } else {
3475 lim_log(pMac, LOGE,
3476 FL("lim_del_sta failed with Status : %d"), status);
3477 CDF_ASSERT(0);
3478 }
3479 }
3480 /* send a delBss to HAL and wait for a response */
3481 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3482
3483 if (status != eSIR_SUCCESS) {
3484 PELOGE(lim_log
3485 (pMac, LOGE, FL("delBss failed for bss %d"),
3486 psessionEntry->bssIdx);
3487 )
3488 psessionEntry->limSmeState = prevState;
3489
3490 MTRACE(mac_trace
3491 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3492 psessionEntry->limSmeState));
3493
3494 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3495 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3496 smetransactionId);
3497 }
3498}
3499
3500/**
3501 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3502 * @pMac: Global MAC context
3503 * @pMsg: Message from SME
3504 *
3505 * Wrapper for the function __lim_handle_sme_stop_bss_request
3506 * This message will be defered until softmac come out of
3507 * scan mode. Message should be handled even if we have
3508 * detected radar in the current operating channel.
3509 *
3510 * Return: true - If we consumed the buffer
3511 * false - If have defered the message.
3512 */
3513
3514static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3515{
3516 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3517 /**
3518 * If message defered, buffer is not consumed yet.
3519 * So return false
3520 */
3521 return false;
3522 }
3523 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3524 return true;
3525} /*** end __lim_process_sme_stop_bss_req() ***/
3526
3527void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3528 uint32_t body, tpPESession psessionEntry)
3529{
3530
3531 (void)body;
3532 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3533 lim_ibss_delete(pMac, psessionEntry);
3534 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3535 lim_delete_pre_auth_list(pMac);
3536 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3537 psessionEntry->smeSessionId,
3538 psessionEntry->transactionId);
3539 return;
3540}
3541
3542/**
3543 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3544 *
3545 * @mac_ctx: pointer to mac context
3546 * @msg_type: message type
3547 * @msg_buf: pointer to the SME message buffer
3548 *
3549 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3550 * in BTAMP AP.
3551 *
3552 * Return: None
3553 */
3554
3555void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3556 uint32_t *msg_buf)
3557{
3558 tSirSmeAssocCnf assoc_cnf;
3559 tpDphHashNode sta_ds = NULL;
3560 tpPESession session_entry = NULL;
3561 uint8_t session_id;
3562 tpSirAssocReq assoc_req;
3563
3564 if (msg_buf == NULL) {
3565 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL "));
3566 goto end;
3567 }
3568
3569 cdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
3570 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
3571 lim_log(mac_ctx, LOGE,
3572 FL("Received invalid SME_RE(ASSOC)_CNF message "));
3573 goto end;
3574 }
3575
3576 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssId,
3577 &session_id);
3578 if (session_entry == NULL) {
3579 lim_log(mac_ctx, LOGE,
3580 FL("session does not exist for given bssId"));
3581 goto end;
3582 }
3583
3584 if ((!LIM_IS_AP_ROLE(session_entry) &&
3585 !LIM_IS_BT_AMP_AP_ROLE(session_entry)) ||
3586 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3587 (session_entry->limSmeState !=
3588 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
3589 lim_log(mac_ctx, LOGE, FL(
3590 "Rcvd unexpected msg %X in state %X, in role %X"),
3591 msg_type, session_entry->limSmeState,
3592 GET_LIM_SYSTEM_ROLE(session_entry));
3593 goto end;
3594 }
3595 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3596 &session_entry->dph.dphHashTable);
3597 if (sta_ds == NULL) {
3598 lim_log(mac_ctx, LOGE, FL(
3599 "Rcvd invalid msg %X due to no STA ctx, aid %d, peer "),
3600 msg_type, assoc_cnf.aid);
3601 lim_print_mac_addr(mac_ctx, assoc_cnf.peerMacAddr, LOG1);
3602
3603 /*
3604 * send a DISASSOC_IND message to WSM to make sure
3605 * the state in WSM and LIM is the same
3606 */
3607 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peerMacAddr,
3608 eSIR_SME_STA_NOT_ASSOCIATED,
3609 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3610 session_entry->smeSessionId,
3611 session_entry->transactionId,
3612 session_entry);
3613 goto end;
3614 }
3615 if (!cdf_mem_compare((uint8_t *)sta_ds->staAddr,
3616 (uint8_t *) assoc_cnf.peerMacAddr,
3617 sizeof(tSirMacAddr))) {
3618 lim_log(mac_ctx, LOG1, FL(
3619 "peerMacAddr mismatched for aid %d, peer "),
3620 assoc_cnf.aid);
3621 lim_print_mac_addr(mac_ctx, assoc_cnf.peerMacAddr, LOG1);
3622 goto end;
3623 }
3624
3625 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3626 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3627 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3628 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3629 (msg_type != eWNI_SME_ASSOC_CNF))) {
3630 lim_log(mac_ctx, LOG1, FL(
3631 "not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3632 "StaD mlmState : %d"),
3633 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
3634 lim_print_mac_addr(mac_ctx, assoc_cnf.peerMacAddr, LOG1);
3635 goto end;
3636 }
3637 /*
3638 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3639 * has been received
3640 */
3641 lim_log(mac_ctx, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
3642 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3643 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3644
3645 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3646 /*
3647 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3648 * when it had received Assoc Request frame. Now, PE just needs
3649 * to send association rsp frame to the requesting BTAMP-STA.
3650 */
3651 sta_ds->mlmStaContext.mlmState =
3652 eLIM_MLM_LINK_ESTABLISHED_STATE;
3653 lim_log(mac_ctx, LOG1,
3654 FL("sending Assoc Rsp frame to STA (assoc id=%d) "),
3655 sta_ds->assocId);
3656 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3657 sta_ds->assocId, sta_ds->staAddr,
3658 sta_ds->mlmStaContext.subType, sta_ds,
3659 session_entry);
3660 goto end;
3661 } else {
3662 /*
3663 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3664 * to be associated since the HAL sta entry is created for
3665 * denied STA we need to remove this HAL entry.
3666 * So to do that set updateContext to 1
3667 */
3668 if (!sta_ds->mlmStaContext.updateContext)
3669 sta_ds->mlmStaContext.updateContext = 1;
3670 lim_log(mac_ctx, LOG1,
3671 FL("Recv Assoc Cnf, status Code : %d(assoc id=%d) "),
3672 assoc_cnf.statusCode, sta_ds->assocId);
3673 lim_reject_association(mac_ctx, sta_ds->staAddr,
3674 sta_ds->mlmStaContext.subType,
3675 true, sta_ds->mlmStaContext.authType,
3676 sta_ds->assocId, true,
3677 eSIR_MAC_UNSPEC_FAILURE_STATUS,
3678 session_entry);
3679 }
3680end:
3681 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3682 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3683 assoc_req = (tpSirAssocReq)
3684 session_entry->parsedAssocReq[sta_ds->assocId];
3685 if (assoc_req->assocReqFrame) {
3686 cdf_mem_free(assoc_req->assocReqFrame);
3687 assoc_req->assocReqFrame = NULL;
3688 }
3689 cdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
3690 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3691 }
3692}
3693
3694static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3695{
3696 tpDphHashNode pStaDs;
3697 tSirMacAddr peerMac;
3698 tpSirAddtsReq pSirAddts;
3699 uint32_t timeout;
3700 tpPESession psessionEntry;
3701 uint8_t sessionId; /* PE sessionId */
3702 uint8_t smesessionId;
3703 uint16_t smetransactionId;
3704
3705 if (pMsgBuf == NULL) {
3706 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
3707 return;
3708 }
3709
3710 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3711 &smetransactionId);
3712
3713 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3714
3715 psessionEntry = pe_find_session_by_bssid(pMac,
3716 pSirAddts->bssId,
3717 &sessionId);
3718 if (psessionEntry == NULL) {
3719 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3720 return;
3721 }
3722#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3723 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3724 0);
3725#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3726
3727 /* if sta
3728 * - verify assoc state
3729 * - send addts request to ap
3730 * - wait for addts response from ap
3731 * if ap, just ignore with error log
3732 */
3733 PELOG1(lim_log(pMac, LOG1,
3734 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
3735 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3736 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
3737 )
3738
3739 if (!LIM_IS_STA_ROLE(psessionEntry) &&
3740 !LIM_IS_BT_AMP_STA_ROLE(psessionEntry)) {
3741 PELOGE(lim_log(pMac, LOGE, "AddTs received on AP - ignoring");)
3742 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3743 psessionEntry, pSirAddts->req.tspec,
3744 smesessionId, smetransactionId);
3745 return;
3746 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003747
3748 pStaDs =
3749 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3750 &psessionEntry->dph.dphHashTable);
3751
3752 if (pStaDs == NULL) {
3753 PELOGE(lim_log
3754 (pMac, LOGE, "Cannot find AP context for addts req");
3755 )
3756 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3757 psessionEntry, pSirAddts->req.tspec,
3758 smesessionId, smetransactionId);
3759 return;
3760 }
3761
3762 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3763 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
3764 lim_log(pMac, LOGE, "AddTs received in invalid MLM state");
3765 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3766 psessionEntry, pSirAddts->req.tspec,
3767 smesessionId, smetransactionId);
3768 return;
3769 }
3770
3771 pSirAddts->req.wsmTspecPresent = 0;
3772 pSirAddts->req.wmeTspecPresent = 0;
3773 pSirAddts->req.lleTspecPresent = 0;
3774
3775 if ((pStaDs->wsmEnabled) &&
3776 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3777 SIR_MAC_ACCESSPOLICY_EDCA))
3778 pSirAddts->req.wsmTspecPresent = 1;
3779 else if (pStaDs->wmeEnabled)
3780 pSirAddts->req.wmeTspecPresent = 1;
3781 else if (pStaDs->lleEnabled)
3782 pSirAddts->req.lleTspecPresent = 1;
3783 else {
3784 PELOGW(lim_log
3785 (pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));
3786 )
3787 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3788 psessionEntry, pSirAddts->req.tspec,
3789 smesessionId, smetransactionId);
3790 return;
3791 }
3792
3793 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3794 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
3795 lim_log(pMac, LOGE,
3796 "AddTs received in invalid LIMsme state (%d)",
3797 psessionEntry->limSmeState);
3798 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3799 psessionEntry, pSirAddts->req.tspec,
3800 smesessionId, smetransactionId);
3801 return;
3802 }
3803
3804 if (pMac->lim.gLimAddtsSent) {
3805 lim_log(pMac, LOGE,
3806 "Addts (token %d, tsid %d, up %d) is still pending",
3807 pMac->lim.gLimAddtsReq.req.dialogToken,
3808 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3809 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3810 userPrio);
3811 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3812 psessionEntry, pSirAddts->req.tspec,
3813 smesessionId, smetransactionId);
3814 return;
3815 }
3816
3817 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3818
3819 /* save the addts request */
3820 pMac->lim.gLimAddtsSent = true;
3821 cdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
3822 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3823
3824 /* ship out the message now */
3825 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3826 psessionEntry);
3827 PELOG1(lim_log(pMac, LOG1, "Sent ADDTS request");)
3828 /* start a timer to wait for the response */
3829 if (pSirAddts->timeout)
3830 timeout = pSirAddts->timeout;
3831 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3832 eSIR_SUCCESS) {
3833 lim_log(pMac, LOGP,
3834 FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
3835 WNI_CFG_ADDTS_RSP_TIMEOUT);
3836 return;
3837 }
3838
3839 timeout = SYS_MS_TO_TICKS(timeout);
3840 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3841 != TX_SUCCESS) {
3842 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3843 return;
3844 }
3845 pMac->lim.gLimAddtsRspTimerCount++;
3846 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3847 pMac->lim.gLimAddtsRspTimerCount) !=
3848 TX_SUCCESS) {
3849 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3850 return;
3851 }
3852 MTRACE(mac_trace
3853 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3854 eLIM_ADDTS_RSP_TIMER));
3855
3856 /* add the sessionId to the timer object */
3857 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3858 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3859 TX_SUCCESS) {
3860 lim_log(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
3861 return;
3862 }
3863 return;
3864}
3865
3866static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3867{
3868 tSirMacAddr peerMacAddr;
3869 uint8_t ac;
3870 tSirMacTSInfo *pTsinfo;
3871 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3872 tpDphHashNode pStaDs = NULL;
3873 tpPESession psessionEntry;
3874 uint8_t sessionId;
3875 uint32_t status = eSIR_SUCCESS;
3876 uint8_t smesessionId;
3877 uint16_t smetransactionId;
3878
3879 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3880 &smetransactionId);
3881
3882 psessionEntry = pe_find_session_by_bssid(pMac,
3883 pDeltsReq->bssId,
3884 &sessionId);
3885 if (psessionEntry == NULL) {
3886 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3887 status = eSIR_FAILURE;
3888 goto end;
3889 }
3890#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3891 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3892 0);
3893#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3894
3895 if (eSIR_SUCCESS !=
3896 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
3897 PELOGE(lim_log(pMac, LOGE, FL("lim_validate_delts_req failed"));)
3898 status = eSIR_FAILURE;
3899 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3900 smesessionId, smetransactionId);
3901 return;
3902 }
3903
3904 lim_log(pMac, LOG1,
3905 FL("Sent DELTS request to station with assocId = %d MacAddr = "
3906 MAC_ADDRESS_STR),
3907 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3908
3909 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3910 pDeltsReq->req.wmeTspecPresent,
3911 &pDeltsReq->req.tsinfo,
3912 &pDeltsReq->req.tspec, psessionEntry);
3913
3914 pTsinfo =
3915 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3916 tsinfo : &pDeltsReq->req.tsinfo;
3917
3918 /* We've successfully send DELTS frame to AP. Update the
3919 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3920 * is no longer trigger enabled or delivery enabled
3921 */
3922 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3923 pTsinfo, CLEAR_UAPSD_MASK);
3924
3925 /* We're deleting the TSPEC, so this particular AC is no longer
3926 * admitted. PE needs to downgrade the EDCA
3927 * parameters(for the AC for which TS is being deleted) to the
3928 * next best AC for which ACM is not enabled, and send the
3929 * updated values to HAL.
3930 */
3931 ac = upToAc(pTsinfo->traffic.userPrio);
3932
3933 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3934 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3935 ~(1 << ac);
3936 } else if (pTsinfo->traffic.direction ==
3937 SIR_MAC_DIRECTION_DNLINK) {
3938 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3939 ~(1 << ac);
3940 } else if (pTsinfo->traffic.direction ==
3941 SIR_MAC_DIRECTION_BIDIR) {
3942 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3943 ~(1 << ac);
3944 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3945 ~(1 << ac);
3946 }
3947
3948 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3949 psessionEntry);
3950
3951 pStaDs =
3952 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3953 &psessionEntry->dph.dphHashTable);
3954 if (pStaDs != NULL) {
3955 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3956 pStaDs->bssId);
3957 status = eSIR_SUCCESS;
3958 } else {
3959 lim_log(pMac, LOGE, FL("Self entry missing in Hash Table "));
3960 status = eSIR_FAILURE;
3961 }
3962#ifdef FEATURE_WLAN_ESE
3963#ifdef FEATURE_WLAN_ESE_UPLOAD
3964 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003965#endif /* FEATURE_WLAN_ESE_UPLOAD */
3966#endif
3967
3968 /* send an sme response back */
3969end:
3970 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3971 smesessionId, smetransactionId);
3972}
3973
3974void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
3975{
3976 /* fetch the sessionEntry based on the sessionId */
3977 tpPESession psessionEntry;
3978 psessionEntry = pe_find_session_by_session_id(pMac,
3979 pMac->lim.limTimers.gLimAddtsRspTimer.
3980 sessionId);
3981 if (psessionEntry == NULL) {
3982 lim_log(pMac, LOGP,
3983 FL("Session Does not exist for given sessionID"));
3984 return;
3985 }
3986
3987 if (!LIM_IS_STA_ROLE(psessionEntry) &&
3988 !LIM_IS_BT_AMP_STA_ROLE(psessionEntry)) {
3989 lim_log(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)",
3990 GET_LIM_SYSTEM_ROLE(psessionEntry));
3991 pMac->lim.gLimAddtsSent = false;
3992 return;
3993 }
3994
3995 if (!pMac->lim.gLimAddtsSent) {
3996 lim_log(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");
3997 return;
3998 }
3999
4000 if (param != pMac->lim.gLimAddtsRspTimerCount) {
4001 lim_log(pMac, LOGE,
4002 FL("Invalid AddtsRsp Timer count %d (exp %d)"), param,
4003 pMac->lim.gLimAddtsRspTimerCount);
4004 return;
4005 }
4006 /* this a real response timeout */
4007 pMac->lim.gLimAddtsSent = false;
4008 pMac->lim.gLimAddtsRspTimerCount++;
4009
4010 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
4011 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
4012 psessionEntry->smeSessionId,
4013 psessionEntry->transactionId);
4014}
4015
4016/**
4017 * __lim_process_sme_get_statistics_request()
4018 *
4019 ***FUNCTION:
4020 *
4021 *
4022 ***NOTE:
4023 *
4024 * @param pMac Pointer to Global MAC structure
4025 * @param *pMsgBuf A pointer to the SME message buffer
4026 * @return None
4027 */
4028static void
4029__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4030{
4031 tpAniGetPEStatsReq pPEStatsReq;
4032 tSirMsgQ msgQ;
4033
4034 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4035
4036 msgQ.type = WMA_GET_STATISTICS_REQ;
4037
4038 msgQ.reserved = 0;
4039 msgQ.bodyptr = pMsgBuf;
4040 msgQ.bodyval = 0;
4041 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4042
4043 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
4044 cdf_mem_free(pMsgBuf);
4045 pMsgBuf = NULL;
4046 lim_log(pMac, LOGP, "Unable to forward request");
4047 return;
4048 }
4049
4050 return;
4051}
4052
4053#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
4054/**
4055 *FUNCTION: __lim_process_sme_get_tsm_stats_request()
4056 *
4057 ***NOTE:
4058 *
4059 * @param pMac Pointer to Global MAC structure
4060 * @param *pMsgBuf A pointer to the SME message buffer
4061 * @return None
4062 */
4063static void
4064__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4065{
4066 tSirMsgQ msgQ;
4067
4068 msgQ.type = WMA_TSM_STATS_REQ;
4069 msgQ.reserved = 0;
4070 msgQ.bodyptr = pMsgBuf;
4071 msgQ.bodyval = 0;
4072 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4073
4074 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
4075 cdf_mem_free(pMsgBuf);
4076 pMsgBuf = NULL;
4077 lim_log(pMac, LOGP, "Unable to forward request");
4078 return;
4079 }
4080}
4081#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
4082
4083static void
4084__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4085{
4086 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4087 tpPESession psessionEntry;
4088 uint8_t sessionId; /* PE sessionID */
4089
4090 PELOG1(lim_log(pMac, LOG1, FL("received UPDATE_APWPSIEs_REQ message")););
4091
4092 if (pMsgBuf == NULL) {
4093 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4094 return;
4095 }
4096
4097 pUpdateAPWPSIEsReq = cdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
4098 if (NULL == pUpdateAPWPSIEsReq) {
4099 lim_log(pMac, LOGP,
4100 FL
4101 ("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
4102 return;
4103 }
4104 cdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
4105 sizeof(struct sSirUpdateAPWPSIEsReq));
4106
4107 psessionEntry = pe_find_session_by_bssid(pMac,
4108 pUpdateAPWPSIEsReq->bssId,
4109 &sessionId);
4110 if (psessionEntry == NULL) {
4111 lim_log(pMac, LOGW,
4112 FL("Session does not exist for given BSSID"));
4113 goto end;
4114 }
4115
4116 cdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
4117 sizeof(tSirAPWPSIEs));
4118
4119 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4120 lim_send_beacon_ind(pMac, psessionEntry);
4121
4122end:
4123 cdf_mem_free(pUpdateAPWPSIEsReq);
4124 return;
4125}
4126
4127void
4128lim_send_vdev_restart(tpAniSirGlobal pMac,
4129 tpPESession psessionEntry, uint8_t sessionId)
4130{
4131 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
4132 tSirMsgQ msgQ;
4133 tSirRetStatus retCode = eSIR_SUCCESS;
4134
4135 if (psessionEntry == NULL) {
4136 PELOGE(lim_log
4137 (pMac, LOGE, "%s:%d: Invalid parameters", __func__,
4138 __LINE__);
4139 )
4140 return;
4141 }
4142
4143 pHalHiddenSsidVdevRestart =
4144 cdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
4145 if (NULL == pHalHiddenSsidVdevRestart) {
4146 PELOGE(lim_log
4147 (pMac, LOGE, "%s:%d: Unable to allocate memory",
4148 __func__, __LINE__);
4149 )
4150 return;
4151 }
4152
4153 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4154 pHalHiddenSsidVdevRestart->sessionId = sessionId;
4155
4156 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4157 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4158 msgQ.bodyval = 0;
4159
4160 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4161 if (eSIR_SUCCESS != retCode) {
4162 PELOGE(lim_log
4163 (pMac, LOGE, "%s:%d: wma_post_ctrl_msg() failed", __func__,
4164 __LINE__);
4165 )
4166 cdf_mem_free(pHalHiddenSsidVdevRestart);
4167 }
4168}
4169
4170static void __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4171{
4172 tpSirUpdateParams pUpdateParams;
4173 tpPESession psessionEntry;
4174
4175 PELOG1(lim_log(pMac, LOG1, FL("received HIDE_SSID message")););
4176
4177 if (pMsgBuf == NULL) {
4178 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4179 return;
4180 }
4181
4182 pUpdateParams = (tpSirUpdateParams) pMsgBuf;
4183
Naveen Rawat9e4872a2015-11-13 09:43:11 -08004184 psessionEntry = pe_find_session_by_sme_session_id(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004185 pUpdateParams->sessionId);
4186 if (psessionEntry == NULL) {
4187 lim_log(pMac, LOGW,
4188 "Session does not exist for given sessionId %d",
4189 pUpdateParams->sessionId);
4190 return;
4191 }
4192
4193 /* Update the session entry */
4194 psessionEntry->ssidHidden = pUpdateParams->ssidHidden;
4195
4196 /* Send vdev restart */
4197 lim_send_vdev_restart(pMac, psessionEntry, pUpdateParams->sessionId);
4198
4199 /* Update beacon */
4200 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4201 lim_send_beacon_ind(pMac, psessionEntry);
4202
4203 return;
4204} /*** end __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4205
4206static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4207{
4208 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4209 tpPESession psessionEntry;
4210 uint8_t sessionId; /* PE sessionID */
4211
4212 if (pMsgBuf == NULL) {
4213 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4214 return;
4215 }
4216
4217 pUpdateAPWPARSNIEsReq = cdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
4218 if (NULL == pUpdateAPWPARSNIEsReq) {
4219 lim_log(pMac, LOGP,
4220 FL
4221 ("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
4222 return;
4223 }
4224 cdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
4225 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4226
4227 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004228 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004229 &sessionId);
4230 if (psessionEntry == NULL) {
4231 lim_log(pMac, LOGW,
4232 FL("Session does not exist for given BSSID"));
4233 goto end;
4234 }
4235
4236 cdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
4237 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4238
4239 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4240 &psessionEntry->
4241 pLimStartBssReq->rsnIE,
4242 psessionEntry);
4243
4244 psessionEntry->pLimStartBssReq->privacy = 1;
4245 psessionEntry->privacy = 1;
4246
4247 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4248 lim_send_beacon_ind(pMac, psessionEntry);
4249
4250end:
4251 cdf_mem_free(pUpdateAPWPARSNIEsReq);
4252 return;
4253} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4254
4255/*
4256 Update the beacon Interval dynamically if beaconInterval is different in MCC
4257 */
4258static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4259{
4260 tpSirChangeBIParams pChangeBIParams;
4261 tpPESession psessionEntry;
4262 uint8_t sessionId = 0;
4263 tUpdateBeaconParams beaconParams;
4264
4265 PELOG1(lim_log(pMac, LOG1,
4266 FL("received Update Beacon Interval message"));
4267 );
4268
4269 if (pMsgBuf == NULL) {
4270 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4271 return;
4272 }
4273
4274 cdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
4275 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4276
4277 psessionEntry = pe_find_session_by_bssid(pMac,
4278 pChangeBIParams->bssId,
4279 &sessionId);
4280 if (psessionEntry == NULL) {
4281 lim_log(pMac, LOGE,
4282 FL("Session does not exist for given BSSID"));
4283 return;
4284 }
4285
4286 /*Update sessionEntry Beacon Interval */
4287 if (psessionEntry->beaconParams.beaconInterval !=
4288 pChangeBIParams->beaconInterval) {
4289 psessionEntry->beaconParams.beaconInterval =
4290 pChangeBIParams->beaconInterval;
4291 }
4292
4293 /*Update sch beaconInterval */
4294 if (pMac->sch.schObject.gSchBeaconInterval !=
4295 pChangeBIParams->beaconInterval) {
4296 pMac->sch.schObject.gSchBeaconInterval =
4297 pChangeBIParams->beaconInterval;
4298
4299 PELOG1(lim_log(pMac, LOG1,
4300 FL
4301 ("LIM send update BeaconInterval Indication : %d"),
4302 pChangeBIParams->beaconInterval);
4303 );
4304
4305 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4306 /* Update beacon */
4307 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4308
4309 beaconParams.bssIdx = psessionEntry->bssIdx;
4310 /* Set change in beacon Interval */
4311 beaconParams.beaconInterval =
4312 pChangeBIParams->beaconInterval;
4313 beaconParams.paramChangeBitmap =
4314 PARAM_BCN_INTERVAL_CHANGED;
4315 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4316 }
4317 }
4318
4319 return;
4320} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4321
4322#ifdef QCA_HT_2040_COEX
4323static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4324 uint32_t *pMsgBuf)
4325{
4326 tpSirSetHT2040Mode pSetHT2040Mode;
4327 tpPESession psessionEntry;
4328 uint8_t sessionId = 0;
4329 cds_msg_t msg;
4330 tUpdateVHTOpMode *pHtOpMode = NULL;
4331 uint16_t staId = 0;
4332 tpDphHashNode pStaDs = NULL;
4333
4334 PELOG1(lim_log(pMac, LOG1, FL("received Set HT 20/40 mode message")););
4335 if (pMsgBuf == NULL) {
4336 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4337 return;
4338 }
4339
4340 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4341
4342 psessionEntry = pe_find_session_by_bssid(pMac,
4343 pSetHT2040Mode->bssId,
4344 &sessionId);
4345 if (psessionEntry == NULL) {
4346 lim_log(pMac, LOG1,
4347 FL("Session does not exist for given BSSID "));
4348 lim_print_mac_addr(pMac, pSetHT2040Mode->bssId, LOG1);
4349 return;
4350 }
4351
4352 lim_log(pMac, LOG1, FL("Update session entry for cbMod=%d"),
4353 pSetHT2040Mode->cbMode);
4354 /*Update sessionEntry HT related fields */
4355 switch (pSetHT2040Mode->cbMode) {
4356 case PHY_SINGLE_CHANNEL_CENTERED:
4357 psessionEntry->htSecondaryChannelOffset =
4358 PHY_SINGLE_CHANNEL_CENTERED;
4359 psessionEntry->htRecommendedTxWidthSet = 0;
4360 if (pSetHT2040Mode->obssEnabled)
4361 psessionEntry->htSupportedChannelWidthSet
4362 = eHT_CHANNEL_WIDTH_40MHZ;
4363 else
4364 psessionEntry->htSupportedChannelWidthSet
4365 = eHT_CHANNEL_WIDTH_20MHZ;
4366 break;
4367 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4368 psessionEntry->htSecondaryChannelOffset =
4369 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4370 psessionEntry->htRecommendedTxWidthSet = 1;
4371 break;
4372 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4373 psessionEntry->htSecondaryChannelOffset =
4374 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4375 psessionEntry->htRecommendedTxWidthSet = 1;
4376 break;
4377 default:
4378 lim_log(pMac, LOGE, FL("Invalid cbMode"));
4379 return;
4380 }
4381
4382 /* Update beacon */
4383 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4384 lim_send_beacon_ind(pMac, psessionEntry);
4385
4386 /* update OP Mode for each associated peer */
4387 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4388 pStaDs = dph_get_hash_entry(pMac, staId,
4389 &psessionEntry->dph.dphHashTable);
4390 if (NULL == pStaDs)
4391 continue;
4392
4393 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
4394 pHtOpMode = cdf_mem_malloc(sizeof(tUpdateVHTOpMode));
4395 if (NULL == pHtOpMode) {
4396 lim_log(pMac, LOGE,
4397 FL
4398 ("%s: Not able to allocate memory for setting OP mode"),
4399 __func__);
4400 return;
4401 }
4402 pHtOpMode->opMode =
4403 (psessionEntry->htSecondaryChannelOffset ==
4404 PHY_SINGLE_CHANNEL_CENTERED) ?
4405 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4406 pHtOpMode->staId = staId;
4407 cdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
4408 sizeof(tSirMacAddr));
4409 pHtOpMode->smesessionId = sessionId;
4410
4411 msg.type = WMA_UPDATE_OP_MODE;
4412 msg.reserved = 0;
4413 msg.bodyptr = pHtOpMode;
4414 if (!CDF_IS_STATUS_SUCCESS
4415 (cds_mq_post_message(CDF_MODULE_ID_WMA, &msg))) {
4416 lim_log(pMac, LOGE,
4417 FL
4418 ("%s: Not able to post WMA_UPDATE_OP_MODE message to WMA"),
4419 __func__);
4420 cdf_mem_free(pHtOpMode);
4421 return;
4422 }
4423 lim_log(pMac, LOG1,
4424 FL
4425 ("%s: Notifed FW about OP mode: %d for staId=%d"),
4426 __func__, pHtOpMode->opMode, staId);
4427
4428 } else
4429 lim_log(pMac, LOG1,
4430 FL("%s: station %d does not support HT40\n"),
4431 __func__, staId);
4432 }
4433
4434 return;
4435}
4436#endif
4437
4438/* -------------------------------------------------------------------- */
4439/**
4440 * __lim_process_report_message
4441 *
4442 * FUNCTION: Processes the next received Radio Resource Management message
4443 *
4444 * LOGIC:
4445 *
4446 * ASSUMPTIONS:
4447 *
4448 * NOTE:
4449 *
4450 * @param None
4451 * @return None
4452 */
4453
4454void __lim_process_report_message(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4455{
4456#ifdef WLAN_FEATURE_VOWIFI
4457 switch (pMsg->type) {
4458 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4459 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4460 break;
4461 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004462 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004463 break;
4464 default:
4465 lim_log(pMac, LOGE, FL("Invalid msg type:%d"), pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004466 }
4467#endif
4468}
4469
4470#if defined(FEATURE_WLAN_ESE) || defined(WLAN_FEATURE_VOWIFI)
4471/* -------------------------------------------------------------------- */
4472/**
4473 * lim_send_set_max_tx_power_req
4474 *
4475 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4476 *
4477 * LOGIC:
4478 *
4479 * ASSUMPTIONS:
4480 *
4481 * NOTE:
4482 *
4483 * @param txPower txPower to be set.
4484 * @param pSessionEntry session entry.
4485 * @return None
4486 */
4487tSirRetStatus
4488lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, tPowerdBm txPower,
4489 tpPESession pSessionEntry)
4490{
4491 tpMaxTxPowerParams pMaxTxParams = NULL;
4492 tSirRetStatus retCode = eSIR_SUCCESS;
4493 tSirMsgQ msgQ;
4494
4495 if (pSessionEntry == NULL) {
4496 PELOGE(lim_log
4497 (pMac, LOGE, "%s:%d: Inavalid parameters", __func__,
4498 __LINE__);
4499 )
4500 return eSIR_FAILURE;
4501 }
4502
4503 pMaxTxParams = cdf_mem_malloc(sizeof(tMaxTxPowerParams));
4504 if (NULL == pMaxTxParams) {
4505 lim_log(pMac, LOGP,
4506 FL("Unable to allocate memory for pMaxTxParams "));
4507 return eSIR_MEM_ALLOC_FAILED;
4508
4509 }
4510#if defined(WLAN_VOWIFI_DEBUG) || defined(FEATURE_WLAN_ESE)
4511 lim_log(pMac, LOG1,
4512 FL("pMaxTxParams allocated...will be freed in other module"));
4513#endif
4514 if (pMaxTxParams == NULL) {
4515 lim_log(pMac, LOGE, FL("pMaxTxParams is NULL"));
4516 return eSIR_FAILURE;
4517 }
4518 pMaxTxParams->power = txPower;
Srinivas Girigowda97215232015-09-24 12:26:28 -07004519 cdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
4520 CDF_MAC_ADDR_SIZE);
4521 cdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
4522 pSessionEntry->selfMacAddr,
4523 CDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004524
4525 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4526 msgQ.bodyptr = pMaxTxParams;
4527 msgQ.bodyval = 0;
4528 PELOG1(lim_log
4529 (pMac, LOG1, FL("Posting WMA_SET_MAX_TX_POWER_REQ to WMA"));
4530 )
4531 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4532 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4533 if (eSIR_SUCCESS != retCode) {
4534 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() failed"));
4535 cdf_mem_free(pMaxTxParams);
4536 }
4537 return retCode;
4538}
4539#endif
4540
4541/**
4542 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4543 *
4544 * @mac_ctx: Pointer to Global MAC structure
4545 * @msg_buf: pointer to the SME message buffer
4546 *
4547 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4548 * from SME. It Register this information within PE.
4549 *
4550 * Return: None
4551 */
4552static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4553 uint32_t *msg_buf)
4554{
4555 CDF_STATUS cdf_status;
4556 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4557 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4558 struct mgmt_frm_reg_info *next = NULL;
4559 bool match = false;
4560
4561 lim_log(mac_ctx, LOG1, FL(
4562 "registerFrame %d, frameType %d, matchLen %d"),
4563 sme_req->registerFrame, sme_req->frameType,
4564 sme_req->matchLen);
4565 /* First check whether entry exists already */
4566 cdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
4567 cdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4568 (cdf_list_node_t **) &lim_mgmt_regn);
4569 cdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
4570
4571 while (lim_mgmt_regn != NULL) {
4572 if (lim_mgmt_regn->frameType != sme_req->frameType)
4573 goto skip_match;
4574 if (sme_req->matchLen) {
4575 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
4576 (cdf_mem_compare(lim_mgmt_regn->matchData,
4577 sme_req->matchData,
4578 lim_mgmt_regn->matchLen))) {
4579 /* found match! */
4580 match = true;
4581 break;
4582 }
4583 } else {
4584 /* found match! */
4585 match = true;
4586 break;
4587 }
4588skip_match:
4589 cdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
4590 cdf_status = cdf_list_peek_next(
4591 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4592 (cdf_list_node_t *)lim_mgmt_regn,
4593 (cdf_list_node_t **)&next);
4594 cdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
4595 lim_mgmt_regn = next;
4596 next = NULL;
4597 }
4598 if (match) {
4599 cdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
4600 cdf_list_remove_node(
4601 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4602 (cdf_list_node_t *)lim_mgmt_regn);
4603 cdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
4604 cdf_mem_free(lim_mgmt_regn);
4605 }
4606
4607 if (sme_req->registerFrame) {
4608 lim_mgmt_regn =
4609 cdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
4610 sme_req->matchLen);
4611 if (lim_mgmt_regn != NULL) {
4612 cdf_mem_set((void *)lim_mgmt_regn,
4613 sizeof(struct mgmt_frm_reg_info) +
4614 sme_req->matchLen, 0);
4615 lim_mgmt_regn->frameType = sme_req->frameType;
4616 lim_mgmt_regn->matchLen = sme_req->matchLen;
4617 lim_mgmt_regn->sessionId = sme_req->sessionId;
4618 if (sme_req->matchLen) {
4619 cdf_mem_copy(lim_mgmt_regn->matchData,
4620 sme_req->matchData,
4621 sme_req->matchLen);
4622 }
4623 cdf_mutex_acquire(
4624 &mac_ctx->lim.lim_frame_register_lock);
4625 cdf_list_insert_front(&mac_ctx->lim.
4626 gLimMgmtFrameRegistratinQueue,
4627 &lim_mgmt_regn->node);
4628 cdf_mutex_release(
4629 &mac_ctx->lim.lim_frame_register_lock);
4630 }
4631 }
4632 return;
4633}
4634
4635static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4636{
4637 lim_log(pMac, LOG1, FL("Dereg msgType %d"),
4638 pMac->lim.gDeferMsgTypeForNOA);
4639 pMac->lim.gDeferMsgTypeForNOA = 0;
4640 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4641 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
4642 cdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
4643 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4644 }
4645}
4646
4647/**
4648 * lim_process_regd_defd_sme_req_after_noa_start()
4649 *
4650 * mac_ctx: Pointer to Global MAC structure
4651 *
4652 * This function is called to process deferred sme req message
4653 * after noa start.
4654 *
4655 * Return: None
4656 */
4657void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4658{
4659 bool buf_consumed = true;
4660
4661 lim_log(mac_ctx, LOG1, FL("Process defd sme req %d"),
4662 mac_ctx->lim.gDeferMsgTypeForNOA);
4663
4664 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4665 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
4666 lim_log(mac_ctx, LOGW,
4667 FL("start rcvd from FW when no sme deferred msg pending. Do nothing. "));
4668 lim_log(mac_ctx, LOGW,
4669 FL("It may happen when NOA start ind and timeout happen at the same time"));
4670 return;
4671 }
4672 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4673 case eWNI_SME_SCAN_REQ:
4674 __lim_process_sme_scan_req(mac_ctx,
4675 mac_ctx->lim.gpDefdSmeMsgForNOA);
4676 break;
4677#ifdef FEATURE_OEM_DATA_SUPPORT
4678 case eWNI_SME_OEM_DATA_REQ:
4679 __lim_process_sme_oem_data_req(mac_ctx,
4680 mac_ctx->lim.gpDefdSmeMsgForNOA);
4681 break;
4682#endif
4683 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4684 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4685 mac_ctx->lim.gpDefdSmeMsgForNOA);
4686 /*
4687 * lim_process_remain_on_chnl_req doesnt want us to free
4688 * the buffer since it is freed in lim_remain_on_chn_rsp.
4689 * this change is to avoid "double free"
4690 */
4691 if (false == buf_consumed)
4692 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4693 break;
4694 case eWNI_SME_JOIN_REQ:
4695 __lim_process_sme_join_req(mac_ctx,
4696 mac_ctx->lim.gpDefdSmeMsgForNOA);
4697 break;
4698 default:
4699 lim_log(mac_ctx, LOGE, FL("Unknown deferred msg type %d"),
4700 mac_ctx->lim.gDeferMsgTypeForNOA);
4701 break;
4702 }
4703 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4704}
4705
4706static void
4707__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4708{
4709 tpSirResetAPCapsChange pResetCapsChange;
4710 tpPESession psessionEntry;
4711 uint8_t sessionId = 0;
4712 if (pMsgBuf == NULL) {
4713 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4714 return;
4715 }
4716
4717 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4718 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004719 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4720 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004721 if (psessionEntry == NULL) {
4722 lim_log(pMac, LOGE,
4723 FL("Session does not exist for given BSSID"));
4724 return;
4725 }
4726
4727 psessionEntry->limSentCapsChangeNtf = false;
4728 return;
4729}
4730
4731/**
4732 * lim_process_sme_req_messages()
4733 *
4734 ***FUNCTION:
4735 * This function is called by limProcessMessageQueue(). This
4736 * function processes SME request messages from HDD or upper layer
4737 * application.
4738 *
4739 ***LOGIC:
4740 *
4741 ***ASSUMPTIONS:
4742 *
4743 ***NOTE:
4744 *
4745 * @param pMac Pointer to Global MAC structure
4746 * @param msgType Indicates the SME message type
4747 * @param *pMsgBuf A pointer to the SME message buffer
4748 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4749 * false - if pMsgBuf is not to be freed.
4750 */
4751
4752bool lim_process_sme_req_messages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4753{
4754 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
4755 uint32_t *pMsgBuf = pMsg->bodyptr;
4756 tpSirSmeScanReq pScanReq;
4757 PELOG1(lim_log
4758 (pMac, LOG1,
4759 FL
4760 ("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)"),
4761 lim_msg_str(pMsg->type), pMsg->type,
4762 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4763 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
4764 )
4765
4766 pScanReq = (tpSirSmeScanReq) pMsgBuf;
4767 /* If no insert NOA required then execute the code below */
4768
4769 switch (pMsg->type) {
4770 case eWNI_SME_SYS_READY_IND:
4771 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4772 break;
4773
4774 case eWNI_SME_START_BSS_REQ:
4775 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4776 break;
4777
4778 case eWNI_SME_SCAN_REQ:
4779 __lim_process_sme_scan_req(pMac, pMsgBuf);
4780 break;
4781
4782#ifdef FEATURE_OEM_DATA_SUPPORT
4783 case eWNI_SME_OEM_DATA_REQ:
4784 __lim_process_sme_oem_data_req(pMac, pMsgBuf);
4785 break;
4786#endif
4787 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4788 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
4789 break;
4790
4791 case eWNI_SME_UPDATE_NOA:
4792 __lim_process_sme_no_a_update(pMac, pMsgBuf);
4793 break;
4794 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4795 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4796 break;
4797 case eWNI_SME_JOIN_REQ:
4798 __lim_process_sme_join_req(pMac, pMsgBuf);
4799 break;
4800
4801 case eWNI_SME_REASSOC_REQ:
4802 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4803 break;
4804
4805 case eWNI_SME_DISASSOC_REQ:
4806 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
4807 break;
4808
4809 case eWNI_SME_DISASSOC_CNF:
4810 case eWNI_SME_DEAUTH_CNF:
4811 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
4812 break;
4813
4814 case eWNI_SME_DEAUTH_REQ:
4815 __lim_process_sme_deauth_req(pMac, pMsgBuf);
4816 break;
4817
4818 case eWNI_SME_SETCONTEXT_REQ:
4819 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4820 break;
4821
4822 case eWNI_SME_STOP_BSS_REQ:
4823 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4824 break;
4825
4826 case eWNI_SME_ASSOC_CNF:
4827 if (pMsg->type == eWNI_SME_ASSOC_CNF)
4828 PELOG1(lim_log(pMac,
4829 LOG1, FL("Received ASSOC_CNF message"));)
4830 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4831 pMsgBuf);
4832 break;
4833
4834 case eWNI_SME_ADDTS_REQ:
4835 PELOG1(lim_log(pMac, LOG1, FL("Received ADDTS_REQ message"));)
4836 __lim_process_sme_addts_req(pMac, pMsgBuf);
4837 break;
4838
4839 case eWNI_SME_DELTS_REQ:
4840 PELOG1(lim_log(pMac, LOG1, FL("Received DELTS_REQ message"));)
4841 __lim_process_sme_delts_req(pMac, pMsgBuf);
4842 break;
4843
4844 case SIR_LIM_ADDTS_RSP_TIMEOUT:
4845 PELOG1(lim_log
4846 (pMac, LOG1,
4847 FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
4848 )
4849 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4850 break;
4851
4852 case eWNI_SME_GET_STATISTICS_REQ:
4853 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4854 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4855 bufConsumed = false;
4856 break;
4857#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
4858 case eWNI_SME_GET_TSM_STATS_REQ:
4859 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4860 bufConsumed = false;
4861 break;
4862#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
4863 case eWNI_SME_GET_ASSOC_STAS_REQ:
4864 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4865 break;
4866 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
4867 lim_process_tkip_counter_measures(pMac, pMsgBuf);
4868 break;
4869
4870 case eWNI_SME_HIDE_SSID_REQ:
4871 __lim_process_sme_hide_ssid(pMac, pMsgBuf);
4872 break;
4873 case eWNI_SME_UPDATE_APWPSIE_REQ:
4874 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
4875 break;
4876 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
4877 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
4878 break;
4879
4880 case eWNI_SME_SET_APWPARSNIEs_REQ:
4881 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
4882 break;
4883
4884 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4885 /* Update the beaconInterval */
4886 __lim_process_sme_change_bi(pMac, pMsgBuf);
4887 break;
4888
4889#ifdef QCA_HT_2040_COEX
4890 case eWNI_SME_SET_HT_2040_MODE:
4891 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4892 break;
4893#endif
4894
4895#if defined WLAN_FEATURE_VOWIFI
4896 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4897 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4898 __lim_process_report_message(pMac, pMsg);
4899 break;
4900#endif
4901
4902#if defined WLAN_FEATURE_VOWIFI_11R
4903 case eWNI_SME_FT_PRE_AUTH_REQ:
4904 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4905 break;
4906 case eWNI_SME_FT_UPDATE_KEY:
4907 lim_process_ft_update_key(pMac, pMsgBuf);
4908 break;
4909
4910 case eWNI_SME_FT_AGGR_QOS_REQ:
4911 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4912 break;
4913#endif
4914
4915 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4916 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4917 break;
4918#ifdef FEATURE_WLAN_TDLS
4919 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4920 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4921 break;
4922 case eWNI_SME_TDLS_ADD_STA_REQ:
4923 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4924 break;
4925 case eWNI_SME_TDLS_DEL_STA_REQ:
4926 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4927 break;
4928 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
4929 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
4930 break;
4931#endif
4932 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4933 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4934 break;
4935
4936 case eWNI_SME_CHANNEL_CHANGE_REQ:
4937 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4938 break;
4939
4940 case eWNI_SME_START_BEACON_REQ:
4941 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4942 break;
4943
4944 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4945 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4946 break;
4947
4948 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4949 lim_process_update_add_ies(pMac, pMsgBuf);
4950 break;
4951
4952 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4953 lim_process_modify_add_ies(pMac, pMsgBuf);
4954 break;
4955 case eWNI_SME_SET_HW_MODE_REQ:
4956 lim_process_set_hw_mode(pMac, pMsgBuf);
4957 break;
4958 case eWNI_SME_NSS_UPDATE_REQ:
4959 lim_process_nss_update_request(pMac, pMsgBuf);
4960 break;
4961 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
4962 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
4963 break;
4964 case eWNI_SME_SET_IE_REQ:
4965 lim_process_set_ie_req(pMac, pMsgBuf);
4966 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05304967 case eWNI_SME_EXT_CHANGE_CHANNEL:
4968 lim_process_ext_change_channel(pMac, pMsgBuf);
4969 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004970 default:
4971 cdf_mem_free((void *)pMsg->bodyptr);
4972 pMsg->bodyptr = NULL;
4973 break;
4974 } /* switch (msgType) */
4975
4976 return bufConsumed;
4977} /*** end lim_process_sme_req_messages() ***/
4978
4979/**
4980 * lim_process_sme_start_beacon_req()
4981 *
4982 ***FUNCTION:
4983 * This function is called by limProcessMessageQueue(). This
4984 * function processes SME request messages from HDD or upper layer
4985 * application.
4986 *
4987 ***LOGIC:
4988 *
4989 ***ASSUMPTIONS:
4990 *
4991 ***NOTE:
4992 *
4993 * @param pMac Pointer to Global MAC structure
4994 * @param msgType Indicates the SME message type
4995 * @param *pMsgBuf A pointer to the SME message buffer
4996 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4997 * false - if pMsgBuf is not to be freed.
4998 */
4999static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5000{
5001 tpSirStartBeaconIndication pBeaconStartInd;
5002 tpPESession psessionEntry;
5003 uint8_t sessionId; /* PE sessionID */
5004
5005 if (pMsg == NULL) {
5006 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
5007 return;
5008 }
5009
5010 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5011 psessionEntry = pe_find_session_by_bssid(pMac,
5012 pBeaconStartInd->bssid,
5013 &sessionId);
5014 if (psessionEntry == NULL) {
5015 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
5016 lim_log(pMac, LOGE,
5017 FL("Session does not exist for given bssId"));
5018 return;
5019 }
5020
5021 if (pBeaconStartInd->beaconStartStatus == true) {
5022 /*
5023 * Currently this Indication comes from SAP
5024 * to start Beacon Tx on a DFS channel
5025 * since beaconing has to be done on DFS
5026 * channel only after CAC WAIT is completed.
5027 * On a DFS Channel LIM does not start beacon
5028 * Tx right after the WMA_ADD_BSS_RSP.
5029 */
5030 lim_apply_configuration(pMac, psessionEntry);
5031 CDF_TRACE(CDF_MODULE_ID_PE, CDF_TRACE_LEVEL_INFO,
5032 FL("Start Beacon with ssid %s Ch %d"),
5033 psessionEntry->ssId.ssId,
5034 psessionEntry->currentOperChannel);
5035 lim_send_beacon_ind(pMac, psessionEntry);
5036 } else {
5037 lim_log(pMac, LOGE, FL("Invalid Beacon Start Indication"));
5038 return;
5039 }
5040}
5041
5042/**
5043 * lim_process_sme_channel_change_request() - process sme ch change req
5044 *
5045 * @mac_ctx: Pointer to Global MAC structure
5046 * @msg_buf: pointer to the SME message buffer
5047 *
5048 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5049 *
5050 * Return: None
5051 */
5052static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5053 uint32_t *msg_buf)
5054{
5055 tpSirChanChangeRequest ch_change_req;
5056 tpPESession session_entry;
5057 uint8_t session_id; /* PE session_id */
5058 tPowerdBm max_tx_pwr;
5059 uint32_t val = 0;
5060
5061 if (msg_buf == NULL) {
5062 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5063 return;
5064 }
5065 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5066
5067 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5068 ch_change_req->targetChannel);
5069
5070 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5071 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
5072 lim_log(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5073 return;
5074 }
5075
5076 session_entry = pe_find_session_by_bssid(mac_ctx,
5077 ch_change_req->bssid, &session_id);
5078 if (session_entry == NULL) {
5079 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
5080 lim_log(mac_ctx, LOGE, FL(
5081 "Session does not exist for given bssId"));
5082 return;
5083 }
5084
5085 if (session_entry->currentOperChannel ==
5086 ch_change_req->targetChannel) {
5087 lim_log(mac_ctx, LOGE, FL("target CH is same as current CH"));
5088 return;
5089 }
5090
5091 if (LIM_IS_AP_ROLE(session_entry))
5092 session_entry->channelChangeReasonCode =
5093 LIM_SWITCH_CHANNEL_SAP_DFS;
5094 else
5095 session_entry->channelChangeReasonCode =
5096 LIM_SWITCH_CHANNEL_OPERATION;
5097
5098 lim_log(mac_ctx, LOGW, FL(
5099 "switch old chnl %d to new chnl %d, ch_bw %d"),
5100 session_entry->currentOperChannel,
5101 ch_change_req->targetChannel,
5102 ch_change_req->channel_width);
5103
5104 /* Store the New Channel Params in session_entry */
5105 session_entry->ch_width = ch_change_req->channel_width;
5106 session_entry->ch_center_freq_seg0 =
5107 ch_change_req->center_freq_seg_0;
5108 session_entry->ch_center_freq_seg1 =
5109 ch_change_req->center_freq_seg_1;
5110 session_entry->htSecondaryChannelOffset = ch_change_req->cbMode;
5111 session_entry->htSupportedChannelWidthSet =
5112 (ch_change_req->channel_width ? 1 : 0);
5113 session_entry->htRecommendedTxWidthSet =
5114 session_entry->htSupportedChannelWidthSet;
5115 session_entry->currentOperChannel =
5116 ch_change_req->targetChannel;
5117 session_entry->limRFBand =
5118 lim_get_rf_band(session_entry->currentOperChannel);
5119 /* Initialize 11h Enable Flag */
5120 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5121 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5122 eSIR_SUCCESS)
5123 lim_log(mac_ctx, LOGP,
5124 FL("Fail to get WNI_CFG_11H_ENABLED"));
5125 }
5126
5127 session_entry->lim11hEnable = val;
5128 session_entry->dot11mode = ch_change_req->dot11mode;
5129 cdf_mem_copy(&session_entry->rateSet,
5130 &ch_change_req->operational_rateset,
5131 sizeof(session_entry->rateSet));
5132 cdf_mem_copy(&session_entry->extRateSet,
5133 &ch_change_req->extended_rateset,
5134 sizeof(session_entry->extRateSet));
5135 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5136 session_entry->ch_center_freq_seg0,
5137 session_entry->ch_center_freq_seg1,
5138 session_entry->ch_width,
5139 max_tx_pwr, session_entry->peSessionId);
5140}
5141
5142/******************************************************************************
5143* lim_start_bss_update_add_ie_buffer()
5144*
5145***FUNCTION:
5146* This function checks the src buffer and its length and then malloc for
5147* dst buffer update the same
5148*
5149***LOGIC:
5150*
5151***ASSUMPTIONS:
5152*
5153***NOTE:
5154*
5155* @param pMac Pointer to Global MAC structure
5156* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5157* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5158* @param *pSrcData_buff A pointer of uint8_t src buffer
5159* @param srcDataLen src buffer length
5160******************************************************************************/
5161
5162static void
5163lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5164 uint8_t **pDstData_buff,
5165 uint16_t *pDstDataLen,
5166 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5167{
5168
5169 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5170 *pDstDataLen = srcDataLen;
5171
5172 *pDstData_buff = cdf_mem_malloc(*pDstDataLen);
5173
5174 if (NULL == *pDstData_buff) {
5175 lim_log(pMac, LOGE,
5176 FL("AllocateMemory failed for pDstData_buff"));
5177 return;
5178 }
5179 cdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
5180 } else {
5181 *pDstData_buff = NULL;
5182 *pDstDataLen = 0;
5183 }
5184}
5185
5186/******************************************************************************
5187* lim_update_add_ie_buffer()
5188*
5189***FUNCTION:
5190* This function checks the src buffer and length if src buffer length more
5191* than dst buffer length then free the dst buffer and malloc for the new src
5192* length, and update the dst buffer and length. But if dst buffer is bigger
5193* than src buffer length then it just update the dst buffer and length
5194*
5195***LOGIC:
5196*
5197***ASSUMPTIONS:
5198*
5199***NOTE:
5200*
5201* @param pMac Pointer to Global MAC structure
5202* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5203* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5204* @param *pSrcData_buff A pointer of uint8_t src buffer
5205* @param srcDataLen src buffer length
5206******************************************************************************/
5207
5208static void
5209lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5210 uint8_t **pDstData_buff,
5211 uint16_t *pDstDataLen,
5212 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5213{
5214
5215 if (NULL == pSrcData_buff) {
5216 lim_log(pMac, LOGE, FL("src buffer is null."));
5217 return;
5218 }
5219
5220 if (srcDataLen > *pDstDataLen) {
5221 *pDstDataLen = srcDataLen;
5222 /* free old buffer */
5223 cdf_mem_free(*pDstData_buff);
5224 /* allocate a new */
5225 *pDstData_buff = cdf_mem_malloc(*pDstDataLen);
5226
5227 if (NULL == *pDstData_buff) {
5228 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5229 *pDstDataLen = 0;
5230 return;
5231 }
5232 }
5233
5234 /* copy the content of buffer into dst buffer
5235 */
5236 *pDstDataLen = srcDataLen;
5237 cdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
5238
5239}
5240
5241/*
5242* lim_process_modify_add_ies() - process modify additional IE req.
5243*
5244* @mac_ctx: Pointer to Global MAC structure
5245* @msg_buf: pointer to the SME message buffer
5246*
5247* This function update the PE buffers for additional IEs.
5248*
5249* Return: None
5250*/
5251static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5252 uint32_t *msg_buf)
5253{
5254 tpSirModifyIEsInd modify_add_ies;
5255 tpPESession session_entry;
5256 uint8_t session_id;
5257 bool ret = false;
5258 tSirAddIeParams *add_ie_params;
5259
5260 if (msg_buf == NULL) {
5261 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5262 return;
5263 }
5264
5265 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5266 /* Incoming message has smeSession, use BSSID to find PE session */
5267 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005268 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005269
5270 if (NULL == session_entry) {
5271 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5272 MAC_ADDRESS_STR),
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005273 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005274 goto end;
5275 }
5276 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5277 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5278 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
5279 lim_log(mac_ctx, LOGE,
5280 FL("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d"),
5281 modify_add_ies->modifyIE.pIEBuffer,
5282 modify_add_ies->modifyIE.ieBufferlength,
5283 modify_add_ies->modifyIE.ieID,
5284 modify_add_ies->modifyIE.ieIDLen,
5285 modify_add_ies->updateType);
5286 goto end;
5287 }
5288 add_ie_params = &session_entry->addIeParams;
5289 switch (modify_add_ies->updateType) {
5290 case eUPDATE_IE_PROBE_RESP:
5291 /* Probe resp */
5292 break;
5293 case eUPDATE_IE_ASSOC_RESP:
5294 /* assoc resp IE */
5295 if (add_ie_params->assocRespDataLen == 0) {
5296 CDF_TRACE(CDF_MODULE_ID_PE,
5297 CDF_TRACE_LEVEL_ERROR, FL(
5298 "assoc resp add ie not present %d"),
5299 add_ie_params->assocRespDataLen);
5300 }
5301 /* search through the buffer and modify the IE */
5302 break;
5303 case eUPDATE_IE_PROBE_BCN:
5304 /*probe beacon IE */
5305 if (ret == true && modify_add_ies->modifyIE.notify) {
5306 lim_handle_param_update(mac_ctx,
5307 modify_add_ies->updateType);
5308 }
5309 break;
5310 default:
5311 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d"),
5312 modify_add_ies->updateType);
5313 break;
5314 }
5315end:
5316 cdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
5317 modify_add_ies->modifyIE.pIEBuffer = NULL;
5318}
5319
5320/*
5321* lim_process_update_add_ies() - process additional IE update req
5322*
5323* @mac_ctx: Pointer to Global MAC structure
5324* @msg_buf: pointer to the SME message buffer
5325*
5326* This function update the PE buffers for additional IEs.
5327*
5328* Return: None
5329*/
5330static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5331 uint32_t *msg_buf)
5332{
5333 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5334 uint8_t session_id;
5335 tpPESession session_entry;
5336 tSirAddIeParams *addn_ie;
5337 uint16_t new_length = 0;
5338 uint8_t *new_ptr = NULL;
5339 tSirUpdateIE *update_ie;
5340
5341 if (msg_buf == NULL) {
5342 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5343 return;
5344 }
5345 update_ie = &update_add_ies->updateIE;
5346 /* incoming message has smeSession, use BSSID to find PE session */
5347 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005348 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005349
5350 if (NULL == session_entry) {
5351 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5352 MAC_ADDRESS_STR),
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005353 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005354 goto end;
5355 }
5356 addn_ie = &session_entry->addIeParams;
5357 /* if len is 0, upper layer requested freeing of buffer */
5358 if (0 == update_ie->ieBufferlength) {
5359 switch (update_add_ies->updateType) {
5360 case eUPDATE_IE_PROBE_RESP:
5361 cdf_mem_free(addn_ie->probeRespData_buff);
5362 addn_ie->probeRespData_buff = NULL;
5363 addn_ie->probeRespDataLen = 0;
5364 break;
5365 case eUPDATE_IE_ASSOC_RESP:
5366 cdf_mem_free(addn_ie->assocRespData_buff);
5367 addn_ie->assocRespData_buff = NULL;
5368 addn_ie->assocRespDataLen = 0;
5369 break;
5370 case eUPDATE_IE_PROBE_BCN:
5371 cdf_mem_free(addn_ie->probeRespBCNData_buff);
5372 addn_ie->probeRespBCNData_buff = NULL;
5373 addn_ie->probeRespBCNDataLen = 0;
5374
5375 if (update_ie->notify)
5376 lim_handle_param_update(mac_ctx,
5377 update_add_ies->updateType);
5378 break;
5379 default:
5380 break;
5381 }
5382 return;
5383 }
5384 switch (update_add_ies->updateType) {
5385 case eUPDATE_IE_PROBE_RESP:
5386 if (update_ie->append) {
5387 /*
5388 * In case of append, allocate new memory
5389 * with combined length
5390 */
5391 new_length = update_ie->ieBufferlength +
5392 addn_ie->probeRespDataLen;
5393 new_ptr = cdf_mem_malloc(new_length);
5394 if (NULL == new_ptr) {
5395 lim_log(mac_ctx, LOGE, FL(
5396 "Memory allocation failed."));
5397 goto end;
5398 }
5399 /* append buffer to end of local buffers */
5400 cdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
5401 addn_ie->probeRespDataLen);
5402 cdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
5403 update_ie->pAdditionIEBuffer,
5404 update_ie->ieBufferlength);
5405 /* free old memory */
5406 cdf_mem_free(addn_ie->probeRespData_buff);
5407 /* adjust length accordingly */
5408 addn_ie->probeRespDataLen = new_length;
5409 /* save refernece of local buffer in PE session */
5410 addn_ie->probeRespData_buff = new_ptr;
5411 goto end;
5412 }
5413 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5414 &addn_ie->probeRespDataLen,
5415 update_ie->pAdditionIEBuffer,
5416 update_ie->ieBufferlength);
5417 break;
5418 case eUPDATE_IE_ASSOC_RESP:
5419 /* assoc resp IE */
5420 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5421 &addn_ie->assocRespDataLen,
5422 update_ie->pAdditionIEBuffer,
5423 update_ie->ieBufferlength);
5424 break;
5425 case eUPDATE_IE_PROBE_BCN:
5426 /* probe resp Bcn IE */
5427 lim_update_add_ie_buffer(mac_ctx,
5428 &addn_ie->probeRespBCNData_buff,
5429 &addn_ie->probeRespBCNDataLen,
5430 update_ie->pAdditionIEBuffer,
5431 update_ie->ieBufferlength);
5432 if (update_ie->notify)
5433 lim_handle_param_update(mac_ctx,
5434 update_add_ies->updateType);
5435 break;
5436 default:
5437 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d."),
5438 update_add_ies->updateType);
5439 break;
5440 }
5441end:
5442 cdf_mem_free(update_ie->pAdditionIEBuffer);
5443 update_ie->pAdditionIEBuffer = NULL;
5444}
5445
5446/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305447 * send_extended_chan_switch_action_frame()- function to send ECSA
5448 * action frame for each sta connected to SAP/GO and AP in case of
5449 * STA .
5450 * @mac_ctx: pointer to global mac structure
5451 * @new_channel: new channel to switch to.
5452 * @ch_bandwidth: BW of channel to calculate op_class
5453 * @session_entry: pe session
5454 *
5455 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5456 *
5457 * Return: void
5458 */
5459
5460static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5461 uint16_t new_channel, uint8_t ch_bandwidth,
5462 tpPESession session_entry)
5463{
5464 uint16_t op_class;
5465 uint8_t switch_mode = 0, i;
5466 tpDphHashNode psta;
5467
5468
5469 op_class = cds_regdm_get_opclass_from_channel(
5470 mac_ctx->scan.countryCodeCurrent,
5471 new_channel,
5472 ch_bandwidth);
5473
5474 if (LIM_IS_AP_ROLE(session_entry) &&
5475 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
5476 switch_mode = 1;
5477
5478 if (LIM_IS_AP_ROLE(session_entry)) {
5479 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5480 psta =
5481 session_entry->dph.dphHashTable.pDphNodeArray + i;
5482 if (psta && psta->added)
5483 lim_send_extended_chan_switch_action_frame(
5484 mac_ctx,
5485 psta->staAddr,
5486 switch_mode, op_class, new_channel,
5487 LIM_MAX_CSA_IE_UPDATES, session_entry);
5488 }
5489 } else if (LIM_IS_STA_ROLE(session_entry)) {
5490 lim_send_extended_chan_switch_action_frame(mac_ctx,
5491 session_entry->bssId,
5492 switch_mode, op_class, new_channel,
5493 LIM_MAX_CSA_IE_UPDATES, session_entry);
5494 }
5495
5496}
5497
5498/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005499 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5500 *
5501 * @mac_ctx: Pointer to Global MAC structure
5502 * @msg_buf: pointer to the SME message buffer
5503 *
5504 * This function processes SME request messages from HDD or upper layer
5505 * application.
5506 *
5507 * Return: None
5508 */
5509static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5510 uint32_t *msg_buf)
5511{
5512 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5513 tpPESession session_entry = NULL;
5514 uint32_t ch_width = 0;
5515 uint8_t session_id;
5516 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
5517
5518 if (msg_buf == NULL) {
5519 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5520 return;
5521 }
5522
5523 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5524 session_entry = pe_find_session_by_bssid(mac_ctx,
5525 dfs_csa_ie_req->bssid, &session_id);
5526 if (session_entry == NULL) {
5527 lim_log(mac_ctx, LOGE, FL(
5528 "Session not found for given BSSID" MAC_ADDRESS_STR),
5529 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5530 return;
5531 }
5532
5533 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5534 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5535 GET_LIM_SYSTEM_ROLE(session_entry));
5536 return;
5537 }
5538
5539 /* target channel */
5540 session_entry->gLimChannelSwitch.primaryChannel =
5541 dfs_csa_ie_req->targetChannel;
5542
5543 /* Channel switch announcement needs to be included in beacon */
5544 session_entry->dfsIncludeChanSwIe = true;
5545 session_entry->gLimChannelSwitch.switchCount = LIM_MAX_CSA_IE_UPDATES;
5546 session_entry->gLimChannelSwitch.ch_width =
5547 dfs_csa_ie_req->ch_bandwidth;
5548 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
5549 session_entry->gLimChannelSwitch.switchMode = 1;
5550
5551 /*
5552 * Validate if SAP is operating HT or VHT mode and set the Channel
5553 * Switch Wrapper element with the Wide Band Switch subelement.
5554 */
5555 if (true != session_entry->vhtCapability)
5556 goto skip_vht;
5557
5558 if (WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ ==
5559 session_entry->vhtTxChannelWidthSet)
5560 ch_width = eHT_CHANNEL_WIDTH_80MHZ;
5561 else if (WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ ==
5562 session_entry->vhtTxChannelWidthSet)
5563 ch_width = session_entry->htSupportedChannelWidthSet;
5564 /* Now encode the Wider Ch BW element depending on the ch width */
5565 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
5566 switch (ch_width) {
5567 case eHT_CHANNEL_WIDTH_20MHZ:
5568 /*
5569 * Wide channel BW sublement in channel wrapper element is not
5570 * required in case of 20 Mhz operation. Currently It is set
5571 * only set in case of 40/80 Mhz Operation.
5572 */
5573 session_entry->dfsIncludeChanWrapperIe = false;
5574 wider_bw_ch_switch->newChanWidth =
5575 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5576 break;
5577 case eHT_CHANNEL_WIDTH_40MHZ:
5578 session_entry->dfsIncludeChanWrapperIe = true;
5579 wider_bw_ch_switch->newChanWidth =
5580 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5581 break;
5582 case eHT_CHANNEL_WIDTH_80MHZ:
5583 session_entry->dfsIncludeChanWrapperIe = true;
5584 wider_bw_ch_switch->newChanWidth =
5585 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5586 break;
5587 case eHT_CHANNEL_WIDTH_160MHZ:
5588 session_entry->dfsIncludeChanWrapperIe = true;
5589 wider_bw_ch_switch->newChanWidth =
5590 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5591 break;
5592 default:
5593 session_entry->dfsIncludeChanWrapperIe = false;
5594 /*
5595 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5596 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5597 */
5598 lim_log(mac_ctx, LOGE, FL("Invalid Channel Width"));
5599 break;
5600 }
5601 /* Fetch the center channel based on the channel width */
5602 wider_bw_ch_switch->newCenterChanFreq0 =
5603 lim_get_center_channel(mac_ctx, dfs_csa_ie_req->targetChannel,
5604 session_entry->htSecondaryChannelOffset,
5605 wider_bw_ch_switch->newChanWidth);
5606 /*
5607 * This is not applicable for 20/40/80 Mhz.Only used when we support
5608 * 80+80 Mhz operation. In case of 80+80 Mhz, this parameter indicates
5609 * center channel frequency index of 80 Mhz channel of
5610 * frequency segment 1.
5611 */
5612 wider_bw_ch_switch->newCenterChanFreq1 = 0;
5613skip_vht:
5614 /* Send CSA IE request from here */
5615 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5616 eSIR_SUCCESS) {
5617 lim_log(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
5618 return;
5619 }
5620
5621 /*
5622 * First beacon update request is sent here, the remaining updates are
5623 * done when the FW responds back after sending the first beacon after
5624 * the template update
5625 */
5626 lim_send_beacon_ind(mac_ctx, session_entry);
5627 lim_log(mac_ctx, LOG1, FL("Updated CSA IE, IE COUNT = %d"),
5628 session_entry->gLimChannelSwitch.switchCount);
Abhishek Singh518323d2015-10-19 17:42:01 +05305629 /* Send ECSA Action frame after updating the beacon */
5630 send_extended_chan_switch_action_frame(mac_ctx,
5631 session_entry->gLimChannelSwitch.primaryChannel,
5632 session_entry->gLimChannelSwitch.ch_width,
5633 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005634 session_entry->gLimChannelSwitch.switchCount--;
5635}
5636
5637/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305638 * lim_process_ext_change_channel()- function to send ECSA
5639 * action frame for STA/CLI .
5640 * @mac_ctx: pointer to global mac structure
5641 * @msg: params from sme for new channel.
5642 *
5643 * This function is called to send ECSA frame for STA/CLI.
5644 *
5645 * Return: void
5646 */
5647
5648static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5649 uint32_t *msg)
5650{
5651 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5652 (struct sir_sme_ext_cng_chan_req *) msg;
5653 tpPESession session_entry = NULL;
5654
5655 if (NULL == msg) {
5656 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5657 return;
5658 }
5659 session_entry =
5660 pe_find_session_by_sme_session_id(mac_ctx,
5661 ext_chng_channel->session_id);
5662 if (NULL == session_entry) {
5663 lim_log(mac_ctx, LOGE,
5664 FL("Session not found for given session %d"),
5665 ext_chng_channel->session_id);
5666 return;
5667 }
5668 if (LIM_IS_AP_ROLE(session_entry)) {
5669 lim_log(mac_ctx, LOGE,
5670 FL("not an STA/CLI session"));
5671 return;
5672 }
5673 send_extended_chan_switch_action_frame(mac_ctx,
5674 ext_chng_channel->new_channel,
5675 0, session_entry);
5676}
5677
5678/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005679 * lim_process_nss_update_request() - process sme nss update req
5680 *
5681 * @mac_ctx: Pointer to Global MAC structure
5682 * @msg_buf: pointer to the SME message buffer
5683 *
5684 * This function processes SME request messages from HDD or upper layer
5685 * application.
5686 *
5687 * Return: None
5688 */
5689static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5690 uint32_t *msg_buf)
5691{
5692 struct sir_nss_update_request *nss_update_req_ptr;
5693 tpPESession session_entry = NULL;
5694
5695 if (msg_buf == NULL) {
5696 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5697 return;
5698 }
5699
5700 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
5701 session_entry = pe_find_session_by_session_id(mac_ctx,
5702 nss_update_req_ptr->vdev_id);
5703 if (session_entry == NULL) {
5704 lim_log(mac_ctx, LOGE, FL(
5705 "Session not found for given session_id %d"),
5706 nss_update_req_ptr->vdev_id);
5707 return;
5708 }
5709
5710 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5711 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5712 GET_LIM_SYSTEM_ROLE(session_entry));
5713 return;
5714 }
5715
5716 /* populate nss field in the beacon */
5717 session_entry->gLimOperatingMode.present = 1;
5718 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
5719 /* Send nss update request from here */
5720 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5721 eSIR_SUCCESS) {
5722 lim_log(mac_ctx, LOGE,
5723 FL("Unable to set op mode IE in beacon"));
5724 return;
5725 }
5726
5727 lim_send_beacon_ind(mac_ctx, session_entry);
5728}
5729
5730/**
5731 * lim_process_set_ie_req() - process sme set IE request
5732 *
5733 * @mac_ctx: Pointer to Global MAC structure
5734 * @msg_buf: pointer to the SME message buffer
5735 *
5736 * This function processes SME request messages from HDD or upper layer
5737 * application.
5738 *
5739 * Return: None
5740 */
5741static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5742{
5743 struct send_extcap_ie *msg;
5744 CDF_STATUS status;
5745
5746 if (msg_buf == NULL) {
5747 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5748 return;
5749 }
5750
5751 msg = (struct send_extcap_ie *)msg_buf;
5752 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
5753 if (CDF_STATUS_SUCCESS != status)
5754 lim_log(mac_ctx, LOGE, FL("Unable to send ExtCap to FW"));
5755
5756}