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