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