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