blob: a54ed927ce891284f677c4a8e4c839683e8a895e [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
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302594 disassocTrigger = eLIM_HOST_DISASSOC;
2595 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002596
2597 if (smeDisassocReq.doNotSendOverTheAir) {
2598 lim_log(pMac, LOG1, FL("do not send dissoc over the air"));
2599 send_disassoc_frame = 0;
2600 }
2601 /* Trigger Disassociation frame to peer MAC entity */
2602 lim_log(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2603 " : %d, reasonCode : %d"),
2604 disassocTrigger, reasonCode);
2605
2606 pMlmDisassocReq = cdf_mem_malloc(sizeof(tLimMlmDisassocReq));
2607 if (NULL == pMlmDisassocReq) {
2608 /* Log error */
2609 lim_log(pMac, LOGP,
2610 FL("call to AllocateMemory failed for mlmDisassocReq"));
2611
2612 return;
2613 }
2614
2615 cdf_mem_copy((uint8_t *) &pMlmDisassocReq->peerMacAddr,
2616 (uint8_t *) &smeDisassocReq.peerMacAddr,
2617 sizeof(tSirMacAddr));
2618
2619 pMlmDisassocReq->reasonCode = reasonCode;
2620 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2621
2622 /* Update PE session ID */
2623 pMlmDisassocReq->sessionId = sessionId;
2624
2625 lim_post_mlm_message(pMac,
2626 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2627 return;
2628
2629sendDisassoc:
2630 if (psessionEntry)
2631 lim_send_sme_disassoc_ntf(pMac, smeDisassocReq.peerMacAddr,
2632 retCode,
2633 disassocTrigger,
2634 1, smesessionId, smetransactionId,
2635 psessionEntry);
2636 else
2637 lim_send_sme_disassoc_ntf(pMac, smeDisassocReq.peerMacAddr,
2638 retCode,
2639 disassocTrigger,
2640 1, smesessionId, smetransactionId, NULL);
2641
2642} /*** end __lim_process_sme_disassoc_req() ***/
2643
2644/** -----------------------------------------------------------------
2645 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2646
2647 This function is called to process SME_DISASSOC_CNF message
2648 from HDD or upper layer application.
2649
2650 \param pMac - global mac structure
2651 \param pStaDs - station dph hash node
2652 \return none
2653 \sa
2654 ----------------------------------------------------------------- */
2655static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2656{
2657 tSirSmeDisassocCnf smeDisassocCnf;
2658 uint16_t aid;
2659 tpDphHashNode pStaDs;
2660 tpPESession psessionEntry;
2661 uint8_t sessionId;
2662
2663 PELOG1(lim_log(pMac, LOG1, FL("received DISASSOC_CNF message"));)
2664
2665 cdf_mem_copy(&smeDisassocCnf, pMsgBuf,
2666 sizeof(struct sSirSmeDisassocCnf));
2667
2668 psessionEntry = pe_find_session_by_bssid(pMac,
2669 smeDisassocCnf.bssId,
2670 &sessionId);
2671 if (psessionEntry == NULL) {
2672 lim_log(pMac, LOGE,
2673 FL("session does not exist for given bssId"));
2674 return;
2675 }
2676
2677 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
2678 lim_log(pMac, LOGE,
2679 FL("received invalid SME_DISASSOC_CNF message"));
2680 return;
2681 }
2682#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2683 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2684 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2685 psessionEntry,
2686 (uint16_t) smeDisassocCnf.statusCode, 0);
2687 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2688 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2689 psessionEntry,
2690 (uint16_t) smeDisassocCnf.statusCode, 0);
2691#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2692
2693 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2694 case eLIM_STA_ROLE:
2695 case eLIM_BT_AMP_STA_ROLE: /* To test reconn */
2696 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2697 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2698 && (psessionEntry->limSmeState !=
2699 eLIM_SME_WT_DEAUTH_STATE)) {
2700 lim_log(pMac, LOGE,
2701 FL
2702 ("received unexp SME_DISASSOC_CNF in state %X"),
2703 psessionEntry->limSmeState);
2704 lim_print_sme_state(pMac, LOGE,
2705 psessionEntry->limSmeState);
2706 return;
2707 }
2708 break;
2709
2710 case eLIM_AP_ROLE:
2711 /* Fall through */
2712 break;
2713
2714 case eLIM_STA_IN_IBSS_ROLE:
2715 default: /* eLIM_UNKNOWN_ROLE */
2716 lim_log(pMac, LOGE,
2717 FL("received unexpected SME_DISASSOC_CNF role %d"),
2718 GET_LIM_SYSTEM_ROLE(psessionEntry));
2719
2720 return;
2721 }
2722
2723 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2724 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2725 LIM_IS_AP_ROLE(psessionEntry)) {
2726 pStaDs = dph_lookup_hash_entry(pMac,
2727 smeDisassocCnf.peerMacAddr, &aid,
2728 &psessionEntry->dph.dphHashTable);
2729 if (pStaDs == NULL) {
2730 lim_log(pMac, LOGE,
2731 FL("DISASSOC_CNF for a STA with no context, addr= "
2732 MAC_ADDRESS_STR),
2733 MAC_ADDR_ARRAY(smeDisassocCnf.peerMacAddr));
2734 return;
2735 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302736
2737 if ((pStaDs->mlmStaContext.mlmState ==
2738 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2739 (pStaDs->mlmStaContext.mlmState ==
2740 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
2741 lim_log(pMac, LOGE,
2742 FL("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d"),
2743 MAC_ADDR_ARRAY(smeDisassocCnf.peerMacAddr),
2744 pStaDs->mlmStaContext.mlmState);
2745 return;
2746 }
2747
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002748#if defined WLAN_FEATURE_VOWIFI_11R
2749 /* Delete FT session if there exists one */
2750 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
2751#endif
2752 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2753
2754 lim_clean_up_disassoc_deauth_req(pMac,
2755 (char *)&smeDisassocCnf.peerMacAddr,
2756 0);
2757 }
2758
2759 return;
2760}
2761
2762/**
2763 * __lim_process_sme_deauth_req() - process sme deauth req
2764 * @mac_ctx: Pointer to Global MAC structure
2765 * @msg_buf: pointer to the SME message buffer
2766 *
2767 * This function is called to process SME_DEAUTH_REQ message
2768 * from HDD or upper layer application.
2769 *
2770 * Return: None
2771 */
2772
2773static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2774 uint32_t *msg_buf)
2775{
2776 uint16_t deauth_trigger, reason_code;
2777 tLimMlmDeauthReq *mlm_deauth_req;
2778 tSirSmeDeauthReq sme_deauth_req;
2779 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2780 tpPESession session_entry;
2781 uint8_t session_id; /* PE sessionId */
2782 uint8_t sme_session_id;
2783 uint16_t sme_transaction_id;
2784
2785 lim_log(mac_ctx, LOG1, FL("received DEAUTH_REQ message"));
2786
2787 cdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
2788 sme_session_id = sme_deauth_req.sessionId;
2789 sme_transaction_id = sme_deauth_req.transactionId;
2790
2791 /*
2792 * We need to get a session first but we don't even know
2793 * if the message is correct.
2794 */
2795 session_entry = pe_find_session_by_bssid(mac_ctx, sme_deauth_req.bssId,
2796 &session_id);
2797 if (session_entry == NULL) {
2798 lim_log(mac_ctx, LOGE,
2799 FL("session does not exist for given bssId"));
2800 ret_code = eSIR_SME_INVALID_PARAMETERS;
2801 deauth_trigger = eLIM_HOST_DEAUTH;
2802 goto send_deauth;
2803 }
2804
2805 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2806 session_entry)) {
2807 lim_log(mac_ctx, LOGE,
2808 FL("received invalid SME_DEAUTH_REQ message"));
2809 mac_ctx->lim.gLimRspReqd = false;
2810
2811 ret_code = eSIR_SME_INVALID_PARAMETERS;
2812 deauth_trigger = eLIM_HOST_DEAUTH;
2813 goto send_deauth;
2814 }
2815 lim_log(mac_ctx, LOG1,
2816 FL("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2817 MAC_ADDRESS_STR), sme_session_id,
2818 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2819 session_entry->limSmeState,
2820 MAC_ADDR_ARRAY(sme_deauth_req.peerMacAddr));
2821#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2822 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2823 session_entry, 0, sme_deauth_req.reasonCode);
2824#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2825
2826 /* Update SME session ID and Transaction ID */
2827 session_entry->smeSessionId = sme_session_id;
2828 session_entry->transactionId = sme_transaction_id;
2829
2830 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2831 case eLIM_STA_ROLE:
2832 case eLIM_BT_AMP_STA_ROLE:
2833
2834 switch (session_entry->limSmeState) {
2835 case eLIM_SME_ASSOCIATED_STATE:
2836 case eLIM_SME_LINK_EST_STATE:
2837 case eLIM_SME_WT_ASSOC_STATE:
2838 case eLIM_SME_JOIN_FAILURE_STATE:
2839 case eLIM_SME_IDLE_STATE:
2840 session_entry->limPrevSmeState =
2841 session_entry->limSmeState;
2842 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2843 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2844 session_entry->peSessionId,
2845 session_entry->limSmeState));
2846 /* Send Deauthentication request to MLM below */
2847 break;
2848 case eLIM_SME_WT_DEAUTH_STATE:
2849 case eLIM_SME_WT_DISASSOC_STATE:
2850 /*
2851 * PE Recieved a Deauth/Disassoc frame. Normally it get
2852 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2853 * Which means host is also trying to disconnect.
2854 * PE can continue processing DEAUTH_REQ and send
2855 * the response instead of failing the request.
2856 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2857 * was sent for deauth/disassoc frame.
2858 */
2859 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2860 lim_log(mac_ctx, LOG1, FL(
2861 "Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE"));
2862 break;
2863 default:
2864 /*
2865 * STA is not in a state to deauthenticate with
2866 * peer. Log error and send response to host.
2867 */
2868 lim_log(mac_ctx, LOGE, FL(
2869 "received unexp SME_DEAUTH_REQ in state %X"),
2870 session_entry->limSmeState);
2871 lim_print_sme_state(mac_ctx, LOGE,
2872 session_entry->limSmeState);
2873
2874 if (mac_ctx->lim.gLimRspReqd) {
2875 mac_ctx->lim.gLimRspReqd = false;
2876
2877 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2878 deauth_trigger = eLIM_HOST_DEAUTH;
2879
2880 /*
2881 * here we received deauth request from AP so sme state
2882 * is eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED
2883 * delSta then mlm state should be
2884 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got delBSS
2885 * rsp then mlm state should be eLIM_MLM_IDLE_STATE
2886 * so the below condition captures the state where
2887 * delSta not done and firmware still in
2888 * connected state.
2889 */
2890 if (session_entry->limSmeState ==
2891 eLIM_SME_WT_DEAUTH_STATE &&
2892 session_entry->limMlmState !=
2893 eLIM_MLM_IDLE_STATE &&
2894 session_entry->limMlmState !=
2895 eLIM_MLM_WT_DEL_STA_RSP_STATE)
2896 ret_code = eSIR_SME_DEAUTH_STATUS;
2897 goto send_deauth;
2898 }
2899 return;
2900 }
2901 break;
2902
2903 case eLIM_STA_IN_IBSS_ROLE:
2904 lim_log(mac_ctx, LOGE, FL("Deauth not allowed in IBSS"));
2905 if (mac_ctx->lim.gLimRspReqd) {
2906 mac_ctx->lim.gLimRspReqd = false;
2907 ret_code = eSIR_SME_INVALID_PARAMETERS;
2908 deauth_trigger = eLIM_HOST_DEAUTH;
2909 goto send_deauth;
2910 }
2911 return;
2912 case eLIM_AP_ROLE:
2913 break;
2914 default:
2915 lim_log(mac_ctx, LOGE,
2916 FL("received unexpected SME_DEAUTH_REQ for role %X"),
2917 GET_LIM_SYSTEM_ROLE(session_entry));
2918 if (mac_ctx->lim.gLimRspReqd) {
2919 mac_ctx->lim.gLimRspReqd = false;
2920 ret_code = eSIR_SME_INVALID_PARAMETERS;
2921 deauth_trigger = eLIM_HOST_DEAUTH;
2922 goto send_deauth;
2923 }
2924 return;
2925 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2926
2927 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2928 /* Deauthentication is triggered by Link Monitoring */
2929 lim_log(mac_ctx, LOG1, FL("** Lost link with AP **"));
2930 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2931 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2932 } else {
2933 deauth_trigger = eLIM_HOST_DEAUTH;
2934 reason_code = sme_deauth_req.reasonCode;
2935 }
2936
2937 /* Trigger Deauthentication frame to peer MAC entity */
2938 mlm_deauth_req = cdf_mem_malloc(sizeof(tLimMlmDeauthReq));
2939 if (NULL == mlm_deauth_req) {
2940 lim_log(mac_ctx, LOGP,
2941 FL("call to AllocateMemory failed for mlmDeauthReq"));
2942 if (mac_ctx->lim.gLimRspReqd) {
2943 mac_ctx->lim.gLimRspReqd = false;
2944 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2945 deauth_trigger = eLIM_HOST_DEAUTH;
2946 goto send_deauth;
2947 }
2948 return;
2949 }
2950
2951 cdf_mem_copy((uint8_t *) &mlm_deauth_req->peerMacAddr,
2952 (uint8_t *) &sme_deauth_req.peerMacAddr,
2953 sizeof(tSirMacAddr));
2954
2955 mlm_deauth_req->reasonCode = reason_code;
2956 mlm_deauth_req->deauthTrigger = deauth_trigger;
2957
2958 /* Update PE session Id */
2959 mlm_deauth_req->sessionId = session_id;
2960
2961 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2962 (uint32_t *)mlm_deauth_req);
2963 return;
2964
2965send_deauth:
2966 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peerMacAddr, ret_code,
2967 deauth_trigger, 1, sme_session_id, sme_transaction_id);
2968}
2969
2970/**
2971 * __lim_process_sme_set_context_req()
2972 *
2973 * @mac_ctx: Pointer to Global MAC structure
2974 * @msg_buf: pointer to the SME message buffer
2975 *
2976 * This function is called to process SME_SETCONTEXT_REQ message
2977 * from HDD or upper layer application.
2978 *
2979 * Return: None
2980 */
2981
2982static void
2983__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2984{
2985 tpSirSmeSetContextReq set_context_req;
2986 tLimMlmSetKeysReq *mlm_set_key_req;
2987 tpPESession session_entry;
2988 uint8_t session_id; /* PE sessionID */
2989 uint8_t sme_session_id;
2990 uint16_t sme_transaction_id;
2991
2992 lim_log(mac_ctx, LOG1, FL("received SETCONTEXT_REQ message"));
2993
2994 if (msg_buf == NULL) {
2995 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
2996 return;
2997 }
2998
2999 set_context_req = cdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
3000 if (NULL == set_context_req) {
3001 lim_log(mac_ctx, LOGP, FL(
3002 "call to AllocateMemory failed for set_context_req"));
3003 return;
3004 }
3005 cdf_mem_copy(set_context_req, msg_buf,
3006 sizeof(struct sSirSmeSetContextReq));
3007 sme_session_id = set_context_req->sessionId;
3008 sme_transaction_id = set_context_req->transactionId;
3009
3010 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
3011 lim_log(mac_ctx, LOGW,
3012 FL("received invalid SME_SETCONTEXT_REQ message"));
3013 goto end;
3014 }
3015
3016 if (set_context_req->keyMaterial.numKeys >
3017 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3018 lim_log(mac_ctx, LOGE, FL(
3019 "numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS"),
3020 set_context_req->keyMaterial.numKeys);
3021 lim_send_sme_set_context_rsp(mac_ctx,
3022 set_context_req->peerMacAddr, 1,
3023 eSIR_SME_INVALID_PARAMETERS, NULL,
3024 sme_session_id, sme_transaction_id);
3025 goto end;
3026 }
3027
3028 session_entry = pe_find_session_by_bssid(mac_ctx,
3029 set_context_req->bssId, &session_id);
3030 if (session_entry == NULL) {
3031 lim_log(mac_ctx, LOGW,
3032 FL("Session does not exist for given BSSID"));
3033 lim_send_sme_set_context_rsp(mac_ctx,
3034 set_context_req->peerMacAddr, 1,
3035 eSIR_SME_INVALID_PARAMETERS, NULL,
3036 sme_session_id, sme_transaction_id);
3037 goto end;
3038 }
3039#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3040 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
3041 session_entry, 0, 0);
3042#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3043
3044 if (((LIM_IS_STA_ROLE(session_entry) ||
3045 LIM_IS_BT_AMP_STA_ROLE(session_entry)) &&
3046 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3047 ((LIM_IS_IBSS_ROLE(session_entry) ||
3048 LIM_IS_AP_ROLE(session_entry) ||
3049 LIM_IS_BT_AMP_AP_ROLE(session_entry)) &&
3050 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
3051 /* Trigger MLM_SETKEYS_REQ */
3052 mlm_set_key_req = cdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
3053 if (NULL == mlm_set_key_req) {
3054 lim_log(mac_ctx, LOGP, FL(
3055 "mem alloc failed for mlmSetKeysReq"));
3056 goto end;
3057 }
3058 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
3059 mlm_set_key_req->numKeys =
3060 set_context_req->keyMaterial.numKeys;
3061 if (mlm_set_key_req->numKeys >
3062 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3063 lim_log(mac_ctx, LOGP, FL(
3064 "no.of keys exceeded max num of default keys limit"));
3065 goto end;
3066 }
3067 cdf_mem_copy((uint8_t *) &mlm_set_key_req->peerMacAddr,
3068 (uint8_t *) &set_context_req->peerMacAddr,
3069 sizeof(tSirMacAddr));
3070
3071 cdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
3072 (uint8_t *) &set_context_req->keyMaterial.key,
3073 sizeof(tSirKeys) *
3074 (mlm_set_key_req->numKeys ? mlm_set_key_req->
3075 numKeys : 1));
3076
3077 mlm_set_key_req->sessionId = session_id;
3078 mlm_set_key_req->smesessionId = sme_session_id;
3079#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
3080 lim_log(mac_ctx, LOG1, FL(
3081 "received SETCONTEXT_REQ message sessionId=%d"),
3082 mlm_set_key_req->sessionId);
3083#endif
3084
3085 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
3086 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
3087 LIM_IS_AP_ROLE(session_entry)) {
3088 if (set_context_req->keyMaterial.key[0].keyLength) {
3089 uint8_t key_id;
3090 key_id =
3091 set_context_req->keyMaterial.key[0].keyId;
3092 cdf_mem_copy((uint8_t *)
3093 &session_entry->WEPKeyMaterial[key_id],
3094 (uint8_t *) &set_context_req->keyMaterial,
3095 sizeof(tSirKeyMaterial));
3096 } else {
3097 uint32_t i;
3098 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
3099 i++) {
3100 cdf_mem_copy((uint8_t *)
3101 &mlm_set_key_req->key[i],
3102 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
3103 sizeof(tSirKeys));
3104 }
3105 }
3106 }
3107 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
3108 (uint32_t *) mlm_set_key_req);
3109 } else {
3110 lim_log(mac_ctx, LOGE, FL(
3111 "rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
3112 GET_LIM_SYSTEM_ROLE(session_entry),
3113 session_entry->limSmeState);
3114 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
3115
3116 lim_send_sme_set_context_rsp(mac_ctx,
3117 set_context_req->peerMacAddr, 1,
3118 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
3119 session_entry, sme_session_id,
3120 sme_transaction_id);
3121 }
3122end:
3123 cdf_mem_free(set_context_req);
3124 return;
3125}
3126
3127/**
3128 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
3129 *
3130 * @mac_ctx: Pointer to Global MAC structure
3131 * @msg_buf: pointer to the SME message buffer
3132 *
3133 * This function is called to process SME_GET_ASSOC_STAS_REQ message
3134 * from HDD or upper layer application.
3135 *
3136 * Return: None
3137 */
3138
3139void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
3140 uint32_t *msg_buf)
3141{
3142 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3143 tpDphHashNode sta_ds = NULL;
3144 tpPESession session_entry = NULL;
3145 tSap_Event sap_event;
3146 tpWLAN_SAPEventCB sap_event_cb = NULL;
3147 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3148 uint8_t session_id = CSR_SESSION_ID_INVALID;
3149 uint8_t assoc_id = 0;
3150 uint8_t sta_cnt = 0;
3151
3152 if (msg_buf == NULL) {
3153 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3154 return;
3155 }
3156
3157 cdf_mem_copy(&get_assoc_stas_req, msg_buf,
3158 sizeof(struct sSirSmeGetAssocSTAsReq));
3159 /*
3160 * Get Associated stations from PE.
3161 * Find PE session Entry
3162 */
3163 session_entry = pe_find_session_by_bssid(mac_ctx,
3164 get_assoc_stas_req.bssId,
3165 &session_id);
3166 if (session_entry == NULL) {
3167 lim_log(mac_ctx, LOGE,
3168 FL("session does not exist for given bssId"));
3169 goto lim_assoc_sta_end;
3170 }
3171
3172 if (!LIM_IS_AP_ROLE(session_entry)) {
3173 lim_log(mac_ctx, LOGE, FL(
3174 "Received unexpected message in state %X, in role %X"),
3175 session_entry->limSmeState,
3176 GET_LIM_SYSTEM_ROLE(session_entry));
3177 goto lim_assoc_sta_end;
3178 }
3179 /* Retrieve values obtained in the request message */
3180 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3181 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3182
3183 if (NULL == assoc_sta_tmp)
3184 goto lim_assoc_sta_end;
3185 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3186 assoc_id++) {
3187 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3188 &session_entry->dph.dphHashTable);
3189 if (NULL == sta_ds)
3190 continue;
3191 if (sta_ds->valid) {
3192 cdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
3193 (uint8_t *) &sta_ds->staAddr,
3194 CDF_MAC_ADDR_SIZE);
3195 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3196 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3197
3198 cdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
3199 (uint8_t *)&sta_ds->supportedRates,
3200 sizeof(tSirSupportedRates));
3201 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3202 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3203 assoc_sta_tmp->Support40Mhz =
3204 sta_ds->htDsssCckRate40MHzSupport;
3205
3206 lim_log(mac_ctx, LOG1, FL("dph Station Number = %d"),
3207 sta_cnt + 1);
3208 lim_log(mac_ctx, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3209 MAC_ADDR_ARRAY(sta_ds->staAddr));
3210 lim_log(mac_ctx, LOG1, FL("Association Id = %d"),
3211 sta_ds->assocId);
3212 lim_log(mac_ctx, LOG1, FL("Station Index = %d"),
3213 sta_ds->staIndex);
3214 assoc_sta_tmp++;
3215 sta_cnt++;
3216 }
3217 }
3218lim_assoc_sta_end:
3219 /*
3220 * Call hdd callback with sap event to send the list of
3221 * associated stations from PE
3222 */
3223 if (sap_event_cb != NULL) {
3224 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3225 sap_event.sapevt.sapAssocStaListEvent.module =
3226 CDF_MODULE_ID_PE;
3227 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3228 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3229 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3230 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3231 }
3232}
3233
3234/**
3235 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3236 *
3237 * @mac_ctx: Pointer to Global MAC structure
3238 * @msg_buf: pointer to WPS PBC overlap query message
3239 *
3240 * This function parses get WPS PBC overlap information
3241 * message and call callback to pass WPS PBC overlap
3242 * information back to hdd.
3243 *
3244 * Return: None
3245 */
3246void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3247 uint32_t *msg_buf)
3248{
3249 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3250 tpPESession session_entry = NULL;
3251 tSap_Event sap_event;
3252 tpWLAN_SAPEventCB sap_event_cb = NULL;
3253 uint8_t session_id = CSR_SESSION_ID_INVALID;
3254 tSirMacAddr zero_mac = { 0, 0, 0, 0, 0, 0 };
3255 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3256
3257 if (msg_buf == NULL) {
3258 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3259 return;
3260 }
3261
3262 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
3263 sap_get_wpspbc_event->status = CDF_STATUS_E_FAULT;
3264
3265 cdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
3266 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3267 /*
3268 * Get Associated stations from PE
3269 * Find PE session Entry
3270 */
3271 session_entry = pe_find_session_by_bssid(mac_ctx,
3272 get_wps_pbc_sessions_req.bssId, &session_id);
3273 if (session_entry == NULL) {
3274 lim_log(mac_ctx, LOGE,
3275 FL("session does not exist for given bssId"));
3276 goto lim_get_wpspbc_sessions_end;
3277 }
3278
3279 if (!LIM_IS_AP_ROLE(session_entry)) {
3280 lim_log(mac_ctx, LOGE,
3281 FL("Received unexpected message in role %X"),
3282 GET_LIM_SYSTEM_ROLE(session_entry));
3283 goto lim_get_wpspbc_sessions_end;
3284 }
3285 /*
3286 * Call hdd callback with sap event to send the
3287 * WPS PBC overlap information
3288 */
3289 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
3290 sap_get_wpspbc_event->module = CDF_MODULE_ID_PE;
3291
3292 if (cdf_mem_compare(zero_mac, get_wps_pbc_sessions_req.pRemoveMac,
3293 sizeof(tSirMacAddr))) {
3294 lim_get_wpspbc_sessions(mac_ctx,
3295 sap_get_wpspbc_event->addr.bytes,
3296 sap_get_wpspbc_event->UUID_E,
3297 &sap_get_wpspbc_event->wpsPBCOverlap,
3298 session_entry);
3299 } else {
3300 lim_remove_pbc_sessions(mac_ctx,
3301 get_wps_pbc_sessions_req.pRemoveMac,
3302 session_entry);
3303 /* don't have to inform the HDD/Host */
3304 return;
3305 }
3306
3307 lim_log(mac_ctx, LOGE, FL("wpsPBCOverlap %d"),
3308 sap_get_wpspbc_event->wpsPBCOverlap);
3309 lim_print_mac_addr(mac_ctx,
3310 sap_get_wpspbc_event->addr.bytes, LOG4);
3311
3312 sap_get_wpspbc_event->status = CDF_STATUS_SUCCESS;
3313
3314lim_get_wpspbc_sessions_end:
3315 sap_event_cb =
3316 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3317 if (NULL != sap_event_cb)
3318 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3319}
3320
3321/**
3322 * __lim_counter_measures()
3323 *
3324 * FUNCTION:
3325 * This function is called to "implement" MIC counter measure
3326 * and is *temporary* only
3327 *
3328 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3329 * we don't do the proper STA disassoc sequence since the
3330 * BSS will be stoped anyway
3331 *
3332 ***ASSUMPTIONS:
3333 *
3334 ***NOTE:
3335 *
3336 * @param pMac Pointer to Global MAC structure
3337 * @return None
3338 */
3339
3340static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3341{
3342 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3343 if (LIM_IS_AP_ROLE(psessionEntry) ||
3344 LIM_IS_BT_AMP_AP_ROLE(psessionEntry) ||
3345 LIM_IS_BT_AMP_STA_ROLE(psessionEntry))
3346 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3347 mac, psessionEntry, false);
3348};
3349
3350void lim_process_tkip_counter_measures(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3351{
3352 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3353 tpPESession psessionEntry;
3354 uint8_t sessionId; /* PE sessionId */
3355
3356 cdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
3357 sizeof(struct sSirSmeTkipCntrMeasReq));
3358
3359 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003360 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003361 if (NULL == psessionEntry) {
3362 lim_log(pMac, LOGE,
3363 FL("session does not exist for given BSSID "));
3364 return;
3365 }
3366
3367 if (tkipCntrMeasReq.bEnable)
3368 __lim_counter_measures(pMac, psessionEntry);
3369
3370 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3371}
3372
3373static void
3374__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3375{
3376 tSirSmeStopBssReq stopBssReq;
3377 tSirRetStatus status;
3378 tLimSmeStates prevState;
3379 tpPESession psessionEntry;
3380 uint8_t smesessionId;
3381 uint8_t sessionId;
3382 uint16_t smetransactionId;
3383 uint8_t i = 0;
3384 tpDphHashNode pStaDs = NULL;
3385
3386 cdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
3387 smesessionId = stopBssReq.sessionId;
3388 smetransactionId = stopBssReq.transactionId;
3389
3390 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
3391 PELOGW(lim_log(pMac, LOGW,
3392 FL("received invalid SME_STOP_BSS_REQ message"));)
3393 /* Send Stop BSS response to host */
3394 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3395 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3396 smetransactionId);
3397 return;
3398 }
3399
3400 psessionEntry = pe_find_session_by_bssid(pMac,
3401 stopBssReq.bssId,
3402 &sessionId);
3403 if (psessionEntry == NULL) {
3404 lim_log(pMac, LOGW,
3405 FL("session does not exist for given BSSID "));
3406 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3407 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3408 smetransactionId);
3409 return;
3410 }
3411#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3412 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3413 0, 0);
3414#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3415
3416 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3417 LIM_IS_STA_ROLE(psessionEntry)) {
3418 /**
3419 * Should not have received STOP_BSS_REQ in states
3420 * other than 'normal' state or on STA in Infrastructure
3421 * mode. Log error and return response to host.
3422 */
3423 lim_log(pMac, LOGE,
3424 FL
3425 ("received unexpected SME_STOP_BSS_REQ in state %X, for role %d"),
3426 psessionEntry->limSmeState,
3427 GET_LIM_SYSTEM_ROLE(psessionEntry));
3428 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3429 /* / Send Stop BSS response to host */
3430 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3431 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3432 smetransactionId);
3433 return;
3434 }
3435
3436 if (LIM_IS_AP_ROLE(psessionEntry))
3437 lim_wpspbc_close(pMac, psessionEntry);
3438
3439 lim_log(pMac, LOGW,
3440 FL("RECEIVED STOP_BSS_REQ with reason code=%d"),
3441 stopBssReq.reasonCode);
3442
3443 prevState = psessionEntry->limSmeState;
3444
3445 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3446 MTRACE(mac_trace
3447 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3448 psessionEntry->limSmeState));
3449
3450 /* Update SME session Id and Transaction Id */
3451 psessionEntry->smeSessionId = smesessionId;
3452 psessionEntry->transactionId = smetransactionId;
3453
3454 /* BTAMP_STA and STA_IN_IBSS should NOT send Disassoc frame */
3455 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3456 !LIM_IS_BT_AMP_STA_ROLE(psessionEntry)) {
3457 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3458 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3459 /* Send disassoc all stations associated thru TKIP */
3460 __lim_counter_measures(pMac, psessionEntry);
3461 else
3462 lim_send_disassoc_mgmt_frame(pMac,
3463 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3464 bcAddr, psessionEntry, false);
3465 }
3466
3467 /* Free the buffer allocated in START_BSS_REQ */
3468 cdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3469 psessionEntry->addIeParams.probeRespDataLen = 0;
3470 psessionEntry->addIeParams.probeRespData_buff = NULL;
3471
3472 cdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3473 psessionEntry->addIeParams.assocRespDataLen = 0;
3474 psessionEntry->addIeParams.assocRespData_buff = NULL;
3475
3476 cdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3477 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3478 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
3479
3480 /* lim_del_bss is also called as part of coalescing, when we send DEL BSS followed by Add Bss msg. */
3481 pMac->lim.gLimIbssCoalescingHappened = false;
3482
3483 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3484 pStaDs =
3485 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3486 if (NULL == pStaDs)
3487 continue;
3488 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3489 if (eSIR_SUCCESS == status) {
3490 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3491 pStaDs->assocId, psessionEntry);
3492 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3493 } else {
3494 lim_log(pMac, LOGE,
3495 FL("lim_del_sta failed with Status : %d"), status);
3496 CDF_ASSERT(0);
3497 }
3498 }
3499 /* send a delBss to HAL and wait for a response */
3500 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3501
3502 if (status != eSIR_SUCCESS) {
3503 PELOGE(lim_log
3504 (pMac, LOGE, FL("delBss failed for bss %d"),
3505 psessionEntry->bssIdx);
3506 )
3507 psessionEntry->limSmeState = prevState;
3508
3509 MTRACE(mac_trace
3510 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3511 psessionEntry->limSmeState));
3512
3513 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3514 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3515 smetransactionId);
3516 }
3517}
3518
3519/**
3520 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3521 * @pMac: Global MAC context
3522 * @pMsg: Message from SME
3523 *
3524 * Wrapper for the function __lim_handle_sme_stop_bss_request
3525 * This message will be defered until softmac come out of
3526 * scan mode. Message should be handled even if we have
3527 * detected radar in the current operating channel.
3528 *
3529 * Return: true - If we consumed the buffer
3530 * false - If have defered the message.
3531 */
3532
3533static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3534{
3535 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3536 /**
3537 * If message defered, buffer is not consumed yet.
3538 * So return false
3539 */
3540 return false;
3541 }
3542 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3543 return true;
3544} /*** end __lim_process_sme_stop_bss_req() ***/
3545
3546void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3547 uint32_t body, tpPESession psessionEntry)
3548{
3549
3550 (void)body;
3551 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3552 lim_ibss_delete(pMac, psessionEntry);
3553 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3554 lim_delete_pre_auth_list(pMac);
3555 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3556 psessionEntry->smeSessionId,
3557 psessionEntry->transactionId);
3558 return;
3559}
3560
3561/**
3562 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3563 *
3564 * @mac_ctx: pointer to mac context
3565 * @msg_type: message type
3566 * @msg_buf: pointer to the SME message buffer
3567 *
3568 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3569 * in BTAMP AP.
3570 *
3571 * Return: None
3572 */
3573
3574void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3575 uint32_t *msg_buf)
3576{
3577 tSirSmeAssocCnf assoc_cnf;
3578 tpDphHashNode sta_ds = NULL;
3579 tpPESession session_entry = NULL;
3580 uint8_t session_id;
3581 tpSirAssocReq assoc_req;
3582
3583 if (msg_buf == NULL) {
3584 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL "));
3585 goto end;
3586 }
3587
3588 cdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
3589 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
3590 lim_log(mac_ctx, LOGE,
3591 FL("Received invalid SME_RE(ASSOC)_CNF message "));
3592 goto end;
3593 }
3594
3595 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssId,
3596 &session_id);
3597 if (session_entry == NULL) {
3598 lim_log(mac_ctx, LOGE,
3599 FL("session does not exist for given bssId"));
3600 goto end;
3601 }
3602
3603 if ((!LIM_IS_AP_ROLE(session_entry) &&
3604 !LIM_IS_BT_AMP_AP_ROLE(session_entry)) ||
3605 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3606 (session_entry->limSmeState !=
3607 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
3608 lim_log(mac_ctx, LOGE, FL(
3609 "Rcvd unexpected msg %X in state %X, in role %X"),
3610 msg_type, session_entry->limSmeState,
3611 GET_LIM_SYSTEM_ROLE(session_entry));
3612 goto end;
3613 }
3614 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3615 &session_entry->dph.dphHashTable);
3616 if (sta_ds == NULL) {
3617 lim_log(mac_ctx, LOGE, FL(
3618 "Rcvd invalid msg %X due to no STA ctx, aid %d, peer "),
3619 msg_type, assoc_cnf.aid);
3620 lim_print_mac_addr(mac_ctx, assoc_cnf.peerMacAddr, LOG1);
3621
3622 /*
3623 * send a DISASSOC_IND message to WSM to make sure
3624 * the state in WSM and LIM is the same
3625 */
3626 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peerMacAddr,
3627 eSIR_SME_STA_NOT_ASSOCIATED,
3628 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3629 session_entry->smeSessionId,
3630 session_entry->transactionId,
3631 session_entry);
3632 goto end;
3633 }
3634 if (!cdf_mem_compare((uint8_t *)sta_ds->staAddr,
3635 (uint8_t *) assoc_cnf.peerMacAddr,
3636 sizeof(tSirMacAddr))) {
3637 lim_log(mac_ctx, LOG1, FL(
3638 "peerMacAddr mismatched for aid %d, peer "),
3639 assoc_cnf.aid);
3640 lim_print_mac_addr(mac_ctx, assoc_cnf.peerMacAddr, LOG1);
3641 goto end;
3642 }
3643
3644 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3645 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3646 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3647 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3648 (msg_type != eWNI_SME_ASSOC_CNF))) {
3649 lim_log(mac_ctx, LOG1, FL(
3650 "not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3651 "StaD mlmState : %d"),
3652 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
3653 lim_print_mac_addr(mac_ctx, assoc_cnf.peerMacAddr, LOG1);
3654 goto end;
3655 }
3656 /*
3657 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3658 * has been received
3659 */
3660 lim_log(mac_ctx, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
3661 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3662 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3663
3664 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3665 /*
3666 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3667 * when it had received Assoc Request frame. Now, PE just needs
3668 * to send association rsp frame to the requesting BTAMP-STA.
3669 */
3670 sta_ds->mlmStaContext.mlmState =
3671 eLIM_MLM_LINK_ESTABLISHED_STATE;
3672 lim_log(mac_ctx, LOG1,
3673 FL("sending Assoc Rsp frame to STA (assoc id=%d) "),
3674 sta_ds->assocId);
3675 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3676 sta_ds->assocId, sta_ds->staAddr,
3677 sta_ds->mlmStaContext.subType, sta_ds,
3678 session_entry);
3679 goto end;
3680 } else {
3681 /*
3682 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3683 * to be associated since the HAL sta entry is created for
3684 * denied STA we need to remove this HAL entry.
3685 * So to do that set updateContext to 1
3686 */
3687 if (!sta_ds->mlmStaContext.updateContext)
3688 sta_ds->mlmStaContext.updateContext = 1;
3689 lim_log(mac_ctx, LOG1,
3690 FL("Recv Assoc Cnf, status Code : %d(assoc id=%d) "),
3691 assoc_cnf.statusCode, sta_ds->assocId);
3692 lim_reject_association(mac_ctx, sta_ds->staAddr,
3693 sta_ds->mlmStaContext.subType,
3694 true, sta_ds->mlmStaContext.authType,
3695 sta_ds->assocId, true,
3696 eSIR_MAC_UNSPEC_FAILURE_STATUS,
3697 session_entry);
3698 }
3699end:
3700 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3701 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3702 assoc_req = (tpSirAssocReq)
3703 session_entry->parsedAssocReq[sta_ds->assocId];
3704 if (assoc_req->assocReqFrame) {
3705 cdf_mem_free(assoc_req->assocReqFrame);
3706 assoc_req->assocReqFrame = NULL;
3707 }
3708 cdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
3709 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3710 }
3711}
3712
3713static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3714{
3715 tpDphHashNode pStaDs;
3716 tSirMacAddr peerMac;
3717 tpSirAddtsReq pSirAddts;
3718 uint32_t timeout;
3719 tpPESession psessionEntry;
3720 uint8_t sessionId; /* PE sessionId */
3721 uint8_t smesessionId;
3722 uint16_t smetransactionId;
3723
3724 if (pMsgBuf == NULL) {
3725 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
3726 return;
3727 }
3728
3729 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3730 &smetransactionId);
3731
3732 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3733
3734 psessionEntry = pe_find_session_by_bssid(pMac,
3735 pSirAddts->bssId,
3736 &sessionId);
3737 if (psessionEntry == NULL) {
3738 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3739 return;
3740 }
3741#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3742 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3743 0);
3744#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3745
3746 /* if sta
3747 * - verify assoc state
3748 * - send addts request to ap
3749 * - wait for addts response from ap
3750 * if ap, just ignore with error log
3751 */
3752 PELOG1(lim_log(pMac, LOG1,
3753 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
3754 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3755 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
3756 )
3757
3758 if (!LIM_IS_STA_ROLE(psessionEntry) &&
3759 !LIM_IS_BT_AMP_STA_ROLE(psessionEntry)) {
3760 PELOGE(lim_log(pMac, LOGE, "AddTs received on AP - ignoring");)
3761 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3762 psessionEntry, pSirAddts->req.tspec,
3763 smesessionId, smetransactionId);
3764 return;
3765 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003766
3767 pStaDs =
3768 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3769 &psessionEntry->dph.dphHashTable);
3770
3771 if (pStaDs == NULL) {
3772 PELOGE(lim_log
3773 (pMac, LOGE, "Cannot find AP context for addts req");
3774 )
3775 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3776 psessionEntry, pSirAddts->req.tspec,
3777 smesessionId, smetransactionId);
3778 return;
3779 }
3780
3781 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3782 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
3783 lim_log(pMac, LOGE, "AddTs received in invalid MLM state");
3784 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3785 psessionEntry, pSirAddts->req.tspec,
3786 smesessionId, smetransactionId);
3787 return;
3788 }
3789
3790 pSirAddts->req.wsmTspecPresent = 0;
3791 pSirAddts->req.wmeTspecPresent = 0;
3792 pSirAddts->req.lleTspecPresent = 0;
3793
3794 if ((pStaDs->wsmEnabled) &&
3795 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3796 SIR_MAC_ACCESSPOLICY_EDCA))
3797 pSirAddts->req.wsmTspecPresent = 1;
3798 else if (pStaDs->wmeEnabled)
3799 pSirAddts->req.wmeTspecPresent = 1;
3800 else if (pStaDs->lleEnabled)
3801 pSirAddts->req.lleTspecPresent = 1;
3802 else {
3803 PELOGW(lim_log
3804 (pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));
3805 )
3806 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3807 psessionEntry, pSirAddts->req.tspec,
3808 smesessionId, smetransactionId);
3809 return;
3810 }
3811
3812 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3813 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
3814 lim_log(pMac, LOGE,
3815 "AddTs received in invalid LIMsme state (%d)",
3816 psessionEntry->limSmeState);
3817 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3818 psessionEntry, pSirAddts->req.tspec,
3819 smesessionId, smetransactionId);
3820 return;
3821 }
3822
3823 if (pMac->lim.gLimAddtsSent) {
3824 lim_log(pMac, LOGE,
3825 "Addts (token %d, tsid %d, up %d) is still pending",
3826 pMac->lim.gLimAddtsReq.req.dialogToken,
3827 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3828 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3829 userPrio);
3830 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3831 psessionEntry, pSirAddts->req.tspec,
3832 smesessionId, smetransactionId);
3833 return;
3834 }
3835
3836 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3837
3838 /* save the addts request */
3839 pMac->lim.gLimAddtsSent = true;
3840 cdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
3841 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3842
3843 /* ship out the message now */
3844 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3845 psessionEntry);
3846 PELOG1(lim_log(pMac, LOG1, "Sent ADDTS request");)
3847 /* start a timer to wait for the response */
3848 if (pSirAddts->timeout)
3849 timeout = pSirAddts->timeout;
3850 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3851 eSIR_SUCCESS) {
3852 lim_log(pMac, LOGP,
3853 FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
3854 WNI_CFG_ADDTS_RSP_TIMEOUT);
3855 return;
3856 }
3857
3858 timeout = SYS_MS_TO_TICKS(timeout);
3859 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3860 != TX_SUCCESS) {
3861 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3862 return;
3863 }
3864 pMac->lim.gLimAddtsRspTimerCount++;
3865 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3866 pMac->lim.gLimAddtsRspTimerCount) !=
3867 TX_SUCCESS) {
3868 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3869 return;
3870 }
3871 MTRACE(mac_trace
3872 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3873 eLIM_ADDTS_RSP_TIMER));
3874
3875 /* add the sessionId to the timer object */
3876 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3877 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3878 TX_SUCCESS) {
3879 lim_log(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
3880 return;
3881 }
3882 return;
3883}
3884
3885static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3886{
3887 tSirMacAddr peerMacAddr;
3888 uint8_t ac;
3889 tSirMacTSInfo *pTsinfo;
3890 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3891 tpDphHashNode pStaDs = NULL;
3892 tpPESession psessionEntry;
3893 uint8_t sessionId;
3894 uint32_t status = eSIR_SUCCESS;
3895 uint8_t smesessionId;
3896 uint16_t smetransactionId;
3897
3898 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3899 &smetransactionId);
3900
3901 psessionEntry = pe_find_session_by_bssid(pMac,
3902 pDeltsReq->bssId,
3903 &sessionId);
3904 if (psessionEntry == NULL) {
3905 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3906 status = eSIR_FAILURE;
3907 goto end;
3908 }
3909#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3910 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3911 0);
3912#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3913
3914 if (eSIR_SUCCESS !=
3915 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
3916 PELOGE(lim_log(pMac, LOGE, FL("lim_validate_delts_req failed"));)
3917 status = eSIR_FAILURE;
3918 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3919 smesessionId, smetransactionId);
3920 return;
3921 }
3922
3923 lim_log(pMac, LOG1,
3924 FL("Sent DELTS request to station with assocId = %d MacAddr = "
3925 MAC_ADDRESS_STR),
3926 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3927
3928 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3929 pDeltsReq->req.wmeTspecPresent,
3930 &pDeltsReq->req.tsinfo,
3931 &pDeltsReq->req.tspec, psessionEntry);
3932
3933 pTsinfo =
3934 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3935 tsinfo : &pDeltsReq->req.tsinfo;
3936
3937 /* We've successfully send DELTS frame to AP. Update the
3938 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3939 * is no longer trigger enabled or delivery enabled
3940 */
3941 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3942 pTsinfo, CLEAR_UAPSD_MASK);
3943
3944 /* We're deleting the TSPEC, so this particular AC is no longer
3945 * admitted. PE needs to downgrade the EDCA
3946 * parameters(for the AC for which TS is being deleted) to the
3947 * next best AC for which ACM is not enabled, and send the
3948 * updated values to HAL.
3949 */
3950 ac = upToAc(pTsinfo->traffic.userPrio);
3951
3952 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3953 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3954 ~(1 << ac);
3955 } else if (pTsinfo->traffic.direction ==
3956 SIR_MAC_DIRECTION_DNLINK) {
3957 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3958 ~(1 << ac);
3959 } else if (pTsinfo->traffic.direction ==
3960 SIR_MAC_DIRECTION_BIDIR) {
3961 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3962 ~(1 << ac);
3963 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3964 ~(1 << ac);
3965 }
3966
3967 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3968 psessionEntry);
3969
3970 pStaDs =
3971 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3972 &psessionEntry->dph.dphHashTable);
3973 if (pStaDs != NULL) {
3974 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3975 pStaDs->bssId);
3976 status = eSIR_SUCCESS;
3977 } else {
3978 lim_log(pMac, LOGE, FL("Self entry missing in Hash Table "));
3979 status = eSIR_FAILURE;
3980 }
3981#ifdef FEATURE_WLAN_ESE
3982#ifdef FEATURE_WLAN_ESE_UPLOAD
3983 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
3984#else
3985 lim_deactivate_and_change_timer(pMac, eLIM_TSM_TIMER);
3986#endif /* FEATURE_WLAN_ESE_UPLOAD */
3987#endif
3988
3989 /* send an sme response back */
3990end:
3991 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3992 smesessionId, smetransactionId);
3993}
3994
3995void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
3996{
3997 /* fetch the sessionEntry based on the sessionId */
3998 tpPESession psessionEntry;
3999 psessionEntry = pe_find_session_by_session_id(pMac,
4000 pMac->lim.limTimers.gLimAddtsRspTimer.
4001 sessionId);
4002 if (psessionEntry == NULL) {
4003 lim_log(pMac, LOGP,
4004 FL("Session Does not exist for given sessionID"));
4005 return;
4006 }
4007
4008 if (!LIM_IS_STA_ROLE(psessionEntry) &&
4009 !LIM_IS_BT_AMP_STA_ROLE(psessionEntry)) {
4010 lim_log(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)",
4011 GET_LIM_SYSTEM_ROLE(psessionEntry));
4012 pMac->lim.gLimAddtsSent = false;
4013 return;
4014 }
4015
4016 if (!pMac->lim.gLimAddtsSent) {
4017 lim_log(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");
4018 return;
4019 }
4020
4021 if (param != pMac->lim.gLimAddtsRspTimerCount) {
4022 lim_log(pMac, LOGE,
4023 FL("Invalid AddtsRsp Timer count %d (exp %d)"), param,
4024 pMac->lim.gLimAddtsRspTimerCount);
4025 return;
4026 }
4027 /* this a real response timeout */
4028 pMac->lim.gLimAddtsSent = false;
4029 pMac->lim.gLimAddtsRspTimerCount++;
4030
4031 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
4032 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
4033 psessionEntry->smeSessionId,
4034 psessionEntry->transactionId);
4035}
4036
4037/**
4038 * __lim_process_sme_get_statistics_request()
4039 *
4040 ***FUNCTION:
4041 *
4042 *
4043 ***NOTE:
4044 *
4045 * @param pMac Pointer to Global MAC structure
4046 * @param *pMsgBuf A pointer to the SME message buffer
4047 * @return None
4048 */
4049static void
4050__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4051{
4052 tpAniGetPEStatsReq pPEStatsReq;
4053 tSirMsgQ msgQ;
4054
4055 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4056
4057 msgQ.type = WMA_GET_STATISTICS_REQ;
4058
4059 msgQ.reserved = 0;
4060 msgQ.bodyptr = pMsgBuf;
4061 msgQ.bodyval = 0;
4062 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4063
4064 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
4065 cdf_mem_free(pMsgBuf);
4066 pMsgBuf = NULL;
4067 lim_log(pMac, LOGP, "Unable to forward request");
4068 return;
4069 }
4070
4071 return;
4072}
4073
4074#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
4075/**
4076 *FUNCTION: __lim_process_sme_get_tsm_stats_request()
4077 *
4078 ***NOTE:
4079 *
4080 * @param pMac Pointer to Global MAC structure
4081 * @param *pMsgBuf A pointer to the SME message buffer
4082 * @return None
4083 */
4084static void
4085__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4086{
4087 tSirMsgQ msgQ;
4088
4089 msgQ.type = WMA_TSM_STATS_REQ;
4090 msgQ.reserved = 0;
4091 msgQ.bodyptr = pMsgBuf;
4092 msgQ.bodyval = 0;
4093 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4094
4095 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
4096 cdf_mem_free(pMsgBuf);
4097 pMsgBuf = NULL;
4098 lim_log(pMac, LOGP, "Unable to forward request");
4099 return;
4100 }
4101}
4102#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
4103
4104static void
4105__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4106{
4107 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4108 tpPESession psessionEntry;
4109 uint8_t sessionId; /* PE sessionID */
4110
4111 PELOG1(lim_log(pMac, LOG1, FL("received UPDATE_APWPSIEs_REQ message")););
4112
4113 if (pMsgBuf == NULL) {
4114 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4115 return;
4116 }
4117
4118 pUpdateAPWPSIEsReq = cdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
4119 if (NULL == pUpdateAPWPSIEsReq) {
4120 lim_log(pMac, LOGP,
4121 FL
4122 ("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
4123 return;
4124 }
4125 cdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
4126 sizeof(struct sSirUpdateAPWPSIEsReq));
4127
4128 psessionEntry = pe_find_session_by_bssid(pMac,
4129 pUpdateAPWPSIEsReq->bssId,
4130 &sessionId);
4131 if (psessionEntry == NULL) {
4132 lim_log(pMac, LOGW,
4133 FL("Session does not exist for given BSSID"));
4134 goto end;
4135 }
4136
4137 cdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
4138 sizeof(tSirAPWPSIEs));
4139
4140 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4141 lim_send_beacon_ind(pMac, psessionEntry);
4142
4143end:
4144 cdf_mem_free(pUpdateAPWPSIEsReq);
4145 return;
4146}
4147
4148void
4149lim_send_vdev_restart(tpAniSirGlobal pMac,
4150 tpPESession psessionEntry, uint8_t sessionId)
4151{
4152 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
4153 tSirMsgQ msgQ;
4154 tSirRetStatus retCode = eSIR_SUCCESS;
4155
4156 if (psessionEntry == NULL) {
4157 PELOGE(lim_log
4158 (pMac, LOGE, "%s:%d: Invalid parameters", __func__,
4159 __LINE__);
4160 )
4161 return;
4162 }
4163
4164 pHalHiddenSsidVdevRestart =
4165 cdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
4166 if (NULL == pHalHiddenSsidVdevRestart) {
4167 PELOGE(lim_log
4168 (pMac, LOGE, "%s:%d: Unable to allocate memory",
4169 __func__, __LINE__);
4170 )
4171 return;
4172 }
4173
4174 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4175 pHalHiddenSsidVdevRestart->sessionId = sessionId;
4176
4177 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4178 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4179 msgQ.bodyval = 0;
4180
4181 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4182 if (eSIR_SUCCESS != retCode) {
4183 PELOGE(lim_log
4184 (pMac, LOGE, "%s:%d: wma_post_ctrl_msg() failed", __func__,
4185 __LINE__);
4186 )
4187 cdf_mem_free(pHalHiddenSsidVdevRestart);
4188 }
4189}
4190
4191static void __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4192{
4193 tpSirUpdateParams pUpdateParams;
4194 tpPESession psessionEntry;
4195
4196 PELOG1(lim_log(pMac, LOG1, FL("received HIDE_SSID message")););
4197
4198 if (pMsgBuf == NULL) {
4199 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4200 return;
4201 }
4202
4203 pUpdateParams = (tpSirUpdateParams) pMsgBuf;
4204
Naveen Rawat9e4872a2015-11-13 09:43:11 -08004205 psessionEntry = pe_find_session_by_sme_session_id(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004206 pUpdateParams->sessionId);
4207 if (psessionEntry == NULL) {
4208 lim_log(pMac, LOGW,
4209 "Session does not exist for given sessionId %d",
4210 pUpdateParams->sessionId);
4211 return;
4212 }
4213
4214 /* Update the session entry */
4215 psessionEntry->ssidHidden = pUpdateParams->ssidHidden;
4216
4217 /* Send vdev restart */
4218 lim_send_vdev_restart(pMac, psessionEntry, pUpdateParams->sessionId);
4219
4220 /* Update beacon */
4221 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4222 lim_send_beacon_ind(pMac, psessionEntry);
4223
4224 return;
4225} /*** end __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4226
4227static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4228{
4229 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4230 tpPESession psessionEntry;
4231 uint8_t sessionId; /* PE sessionID */
4232
4233 if (pMsgBuf == NULL) {
4234 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4235 return;
4236 }
4237
4238 pUpdateAPWPARSNIEsReq = cdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
4239 if (NULL == pUpdateAPWPARSNIEsReq) {
4240 lim_log(pMac, LOGP,
4241 FL
4242 ("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
4243 return;
4244 }
4245 cdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
4246 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4247
4248 psessionEntry = pe_find_session_by_bssid(pMac,
4249 pUpdateAPWPARSNIEsReq->bssId,
4250 &sessionId);
4251 if (psessionEntry == NULL) {
4252 lim_log(pMac, LOGW,
4253 FL("Session does not exist for given BSSID"));
4254 goto end;
4255 }
4256
4257 cdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
4258 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4259
4260 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4261 &psessionEntry->
4262 pLimStartBssReq->rsnIE,
4263 psessionEntry);
4264
4265 psessionEntry->pLimStartBssReq->privacy = 1;
4266 psessionEntry->privacy = 1;
4267
4268 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4269 lim_send_beacon_ind(pMac, psessionEntry);
4270
4271end:
4272 cdf_mem_free(pUpdateAPWPARSNIEsReq);
4273 return;
4274} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4275
4276/*
4277 Update the beacon Interval dynamically if beaconInterval is different in MCC
4278 */
4279static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4280{
4281 tpSirChangeBIParams pChangeBIParams;
4282 tpPESession psessionEntry;
4283 uint8_t sessionId = 0;
4284 tUpdateBeaconParams beaconParams;
4285
4286 PELOG1(lim_log(pMac, LOG1,
4287 FL("received Update Beacon Interval message"));
4288 );
4289
4290 if (pMsgBuf == NULL) {
4291 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4292 return;
4293 }
4294
4295 cdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
4296 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4297
4298 psessionEntry = pe_find_session_by_bssid(pMac,
4299 pChangeBIParams->bssId,
4300 &sessionId);
4301 if (psessionEntry == NULL) {
4302 lim_log(pMac, LOGE,
4303 FL("Session does not exist for given BSSID"));
4304 return;
4305 }
4306
4307 /*Update sessionEntry Beacon Interval */
4308 if (psessionEntry->beaconParams.beaconInterval !=
4309 pChangeBIParams->beaconInterval) {
4310 psessionEntry->beaconParams.beaconInterval =
4311 pChangeBIParams->beaconInterval;
4312 }
4313
4314 /*Update sch beaconInterval */
4315 if (pMac->sch.schObject.gSchBeaconInterval !=
4316 pChangeBIParams->beaconInterval) {
4317 pMac->sch.schObject.gSchBeaconInterval =
4318 pChangeBIParams->beaconInterval;
4319
4320 PELOG1(lim_log(pMac, LOG1,
4321 FL
4322 ("LIM send update BeaconInterval Indication : %d"),
4323 pChangeBIParams->beaconInterval);
4324 );
4325
4326 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4327 /* Update beacon */
4328 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4329
4330 beaconParams.bssIdx = psessionEntry->bssIdx;
4331 /* Set change in beacon Interval */
4332 beaconParams.beaconInterval =
4333 pChangeBIParams->beaconInterval;
4334 beaconParams.paramChangeBitmap =
4335 PARAM_BCN_INTERVAL_CHANGED;
4336 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4337 }
4338 }
4339
4340 return;
4341} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4342
4343#ifdef QCA_HT_2040_COEX
4344static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4345 uint32_t *pMsgBuf)
4346{
4347 tpSirSetHT2040Mode pSetHT2040Mode;
4348 tpPESession psessionEntry;
4349 uint8_t sessionId = 0;
4350 cds_msg_t msg;
4351 tUpdateVHTOpMode *pHtOpMode = NULL;
4352 uint16_t staId = 0;
4353 tpDphHashNode pStaDs = NULL;
4354
4355 PELOG1(lim_log(pMac, LOG1, FL("received Set HT 20/40 mode message")););
4356 if (pMsgBuf == NULL) {
4357 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4358 return;
4359 }
4360
4361 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4362
4363 psessionEntry = pe_find_session_by_bssid(pMac,
4364 pSetHT2040Mode->bssId,
4365 &sessionId);
4366 if (psessionEntry == NULL) {
4367 lim_log(pMac, LOG1,
4368 FL("Session does not exist for given BSSID "));
4369 lim_print_mac_addr(pMac, pSetHT2040Mode->bssId, LOG1);
4370 return;
4371 }
4372
4373 lim_log(pMac, LOG1, FL("Update session entry for cbMod=%d"),
4374 pSetHT2040Mode->cbMode);
4375 /*Update sessionEntry HT related fields */
4376 switch (pSetHT2040Mode->cbMode) {
4377 case PHY_SINGLE_CHANNEL_CENTERED:
4378 psessionEntry->htSecondaryChannelOffset =
4379 PHY_SINGLE_CHANNEL_CENTERED;
4380 psessionEntry->htRecommendedTxWidthSet = 0;
4381 if (pSetHT2040Mode->obssEnabled)
4382 psessionEntry->htSupportedChannelWidthSet
4383 = eHT_CHANNEL_WIDTH_40MHZ;
4384 else
4385 psessionEntry->htSupportedChannelWidthSet
4386 = eHT_CHANNEL_WIDTH_20MHZ;
4387 break;
4388 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4389 psessionEntry->htSecondaryChannelOffset =
4390 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4391 psessionEntry->htRecommendedTxWidthSet = 1;
4392 break;
4393 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4394 psessionEntry->htSecondaryChannelOffset =
4395 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4396 psessionEntry->htRecommendedTxWidthSet = 1;
4397 break;
4398 default:
4399 lim_log(pMac, LOGE, FL("Invalid cbMode"));
4400 return;
4401 }
4402
4403 /* Update beacon */
4404 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4405 lim_send_beacon_ind(pMac, psessionEntry);
4406
4407 /* update OP Mode for each associated peer */
4408 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4409 pStaDs = dph_get_hash_entry(pMac, staId,
4410 &psessionEntry->dph.dphHashTable);
4411 if (NULL == pStaDs)
4412 continue;
4413
4414 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
4415 pHtOpMode = cdf_mem_malloc(sizeof(tUpdateVHTOpMode));
4416 if (NULL == pHtOpMode) {
4417 lim_log(pMac, LOGE,
4418 FL
4419 ("%s: Not able to allocate memory for setting OP mode"),
4420 __func__);
4421 return;
4422 }
4423 pHtOpMode->opMode =
4424 (psessionEntry->htSecondaryChannelOffset ==
4425 PHY_SINGLE_CHANNEL_CENTERED) ?
4426 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4427 pHtOpMode->staId = staId;
4428 cdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
4429 sizeof(tSirMacAddr));
4430 pHtOpMode->smesessionId = sessionId;
4431
4432 msg.type = WMA_UPDATE_OP_MODE;
4433 msg.reserved = 0;
4434 msg.bodyptr = pHtOpMode;
4435 if (!CDF_IS_STATUS_SUCCESS
4436 (cds_mq_post_message(CDF_MODULE_ID_WMA, &msg))) {
4437 lim_log(pMac, LOGE,
4438 FL
4439 ("%s: Not able to post WMA_UPDATE_OP_MODE message to WMA"),
4440 __func__);
4441 cdf_mem_free(pHtOpMode);
4442 return;
4443 }
4444 lim_log(pMac, LOG1,
4445 FL
4446 ("%s: Notifed FW about OP mode: %d for staId=%d"),
4447 __func__, pHtOpMode->opMode, staId);
4448
4449 } else
4450 lim_log(pMac, LOG1,
4451 FL("%s: station %d does not support HT40\n"),
4452 __func__, staId);
4453 }
4454
4455 return;
4456}
4457#endif
4458
4459/* -------------------------------------------------------------------- */
4460/**
4461 * __lim_process_report_message
4462 *
4463 * FUNCTION: Processes the next received Radio Resource Management message
4464 *
4465 * LOGIC:
4466 *
4467 * ASSUMPTIONS:
4468 *
4469 * NOTE:
4470 *
4471 * @param None
4472 * @return None
4473 */
4474
4475void __lim_process_report_message(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4476{
4477#ifdef WLAN_FEATURE_VOWIFI
4478 switch (pMsg->type) {
4479 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4480 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4481 break;
4482 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004483 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004484 break;
4485 default:
4486 lim_log(pMac, LOGE, FL("Invalid msg type:%d"), pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004487 }
4488#endif
4489}
4490
4491#if defined(FEATURE_WLAN_ESE) || defined(WLAN_FEATURE_VOWIFI)
4492/* -------------------------------------------------------------------- */
4493/**
4494 * lim_send_set_max_tx_power_req
4495 *
4496 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4497 *
4498 * LOGIC:
4499 *
4500 * ASSUMPTIONS:
4501 *
4502 * NOTE:
4503 *
4504 * @param txPower txPower to be set.
4505 * @param pSessionEntry session entry.
4506 * @return None
4507 */
4508tSirRetStatus
4509lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, tPowerdBm txPower,
4510 tpPESession pSessionEntry)
4511{
4512 tpMaxTxPowerParams pMaxTxParams = NULL;
4513 tSirRetStatus retCode = eSIR_SUCCESS;
4514 tSirMsgQ msgQ;
4515
4516 if (pSessionEntry == NULL) {
4517 PELOGE(lim_log
4518 (pMac, LOGE, "%s:%d: Inavalid parameters", __func__,
4519 __LINE__);
4520 )
4521 return eSIR_FAILURE;
4522 }
4523
4524 pMaxTxParams = cdf_mem_malloc(sizeof(tMaxTxPowerParams));
4525 if (NULL == pMaxTxParams) {
4526 lim_log(pMac, LOGP,
4527 FL("Unable to allocate memory for pMaxTxParams "));
4528 return eSIR_MEM_ALLOC_FAILED;
4529
4530 }
4531#if defined(WLAN_VOWIFI_DEBUG) || defined(FEATURE_WLAN_ESE)
4532 lim_log(pMac, LOG1,
4533 FL("pMaxTxParams allocated...will be freed in other module"));
4534#endif
4535 if (pMaxTxParams == NULL) {
4536 lim_log(pMac, LOGE, FL("pMaxTxParams is NULL"));
4537 return eSIR_FAILURE;
4538 }
4539 pMaxTxParams->power = txPower;
Srinivas Girigowda97215232015-09-24 12:26:28 -07004540 cdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
4541 CDF_MAC_ADDR_SIZE);
4542 cdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
4543 pSessionEntry->selfMacAddr,
4544 CDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004545
4546 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4547 msgQ.bodyptr = pMaxTxParams;
4548 msgQ.bodyval = 0;
4549 PELOG1(lim_log
4550 (pMac, LOG1, FL("Posting WMA_SET_MAX_TX_POWER_REQ to WMA"));
4551 )
4552 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4553 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4554 if (eSIR_SUCCESS != retCode) {
4555 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() failed"));
4556 cdf_mem_free(pMaxTxParams);
4557 }
4558 return retCode;
4559}
4560#endif
4561
4562/**
4563 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4564 *
4565 * @mac_ctx: Pointer to Global MAC structure
4566 * @msg_buf: pointer to the SME message buffer
4567 *
4568 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4569 * from SME. It Register this information within PE.
4570 *
4571 * Return: None
4572 */
4573static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4574 uint32_t *msg_buf)
4575{
4576 CDF_STATUS cdf_status;
4577 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4578 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4579 struct mgmt_frm_reg_info *next = NULL;
4580 bool match = false;
4581
4582 lim_log(mac_ctx, LOG1, FL(
4583 "registerFrame %d, frameType %d, matchLen %d"),
4584 sme_req->registerFrame, sme_req->frameType,
4585 sme_req->matchLen);
4586 /* First check whether entry exists already */
4587 cdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
4588 cdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4589 (cdf_list_node_t **) &lim_mgmt_regn);
4590 cdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
4591
4592 while (lim_mgmt_regn != NULL) {
4593 if (lim_mgmt_regn->frameType != sme_req->frameType)
4594 goto skip_match;
4595 if (sme_req->matchLen) {
4596 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
4597 (cdf_mem_compare(lim_mgmt_regn->matchData,
4598 sme_req->matchData,
4599 lim_mgmt_regn->matchLen))) {
4600 /* found match! */
4601 match = true;
4602 break;
4603 }
4604 } else {
4605 /* found match! */
4606 match = true;
4607 break;
4608 }
4609skip_match:
4610 cdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
4611 cdf_status = cdf_list_peek_next(
4612 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4613 (cdf_list_node_t *)lim_mgmt_regn,
4614 (cdf_list_node_t **)&next);
4615 cdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
4616 lim_mgmt_regn = next;
4617 next = NULL;
4618 }
4619 if (match) {
4620 cdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
4621 cdf_list_remove_node(
4622 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4623 (cdf_list_node_t *)lim_mgmt_regn);
4624 cdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
4625 cdf_mem_free(lim_mgmt_regn);
4626 }
4627
4628 if (sme_req->registerFrame) {
4629 lim_mgmt_regn =
4630 cdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
4631 sme_req->matchLen);
4632 if (lim_mgmt_regn != NULL) {
4633 cdf_mem_set((void *)lim_mgmt_regn,
4634 sizeof(struct mgmt_frm_reg_info) +
4635 sme_req->matchLen, 0);
4636 lim_mgmt_regn->frameType = sme_req->frameType;
4637 lim_mgmt_regn->matchLen = sme_req->matchLen;
4638 lim_mgmt_regn->sessionId = sme_req->sessionId;
4639 if (sme_req->matchLen) {
4640 cdf_mem_copy(lim_mgmt_regn->matchData,
4641 sme_req->matchData,
4642 sme_req->matchLen);
4643 }
4644 cdf_mutex_acquire(
4645 &mac_ctx->lim.lim_frame_register_lock);
4646 cdf_list_insert_front(&mac_ctx->lim.
4647 gLimMgmtFrameRegistratinQueue,
4648 &lim_mgmt_regn->node);
4649 cdf_mutex_release(
4650 &mac_ctx->lim.lim_frame_register_lock);
4651 }
4652 }
4653 return;
4654}
4655
4656static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4657{
4658 lim_log(pMac, LOG1, FL("Dereg msgType %d"),
4659 pMac->lim.gDeferMsgTypeForNOA);
4660 pMac->lim.gDeferMsgTypeForNOA = 0;
4661 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4662 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
4663 cdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
4664 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4665 }
4666}
4667
4668/**
4669 * lim_process_regd_defd_sme_req_after_noa_start()
4670 *
4671 * mac_ctx: Pointer to Global MAC structure
4672 *
4673 * This function is called to process deferred sme req message
4674 * after noa start.
4675 *
4676 * Return: None
4677 */
4678void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4679{
4680 bool buf_consumed = true;
4681
4682 lim_log(mac_ctx, LOG1, FL("Process defd sme req %d"),
4683 mac_ctx->lim.gDeferMsgTypeForNOA);
4684
4685 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4686 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
4687 lim_log(mac_ctx, LOGW,
4688 FL("start rcvd from FW when no sme deferred msg pending. Do nothing. "));
4689 lim_log(mac_ctx, LOGW,
4690 FL("It may happen when NOA start ind and timeout happen at the same time"));
4691 return;
4692 }
4693 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4694 case eWNI_SME_SCAN_REQ:
4695 __lim_process_sme_scan_req(mac_ctx,
4696 mac_ctx->lim.gpDefdSmeMsgForNOA);
4697 break;
4698#ifdef FEATURE_OEM_DATA_SUPPORT
4699 case eWNI_SME_OEM_DATA_REQ:
4700 __lim_process_sme_oem_data_req(mac_ctx,
4701 mac_ctx->lim.gpDefdSmeMsgForNOA);
4702 break;
4703#endif
4704 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4705 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4706 mac_ctx->lim.gpDefdSmeMsgForNOA);
4707 /*
4708 * lim_process_remain_on_chnl_req doesnt want us to free
4709 * the buffer since it is freed in lim_remain_on_chn_rsp.
4710 * this change is to avoid "double free"
4711 */
4712 if (false == buf_consumed)
4713 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4714 break;
4715 case eWNI_SME_JOIN_REQ:
4716 __lim_process_sme_join_req(mac_ctx,
4717 mac_ctx->lim.gpDefdSmeMsgForNOA);
4718 break;
4719 default:
4720 lim_log(mac_ctx, LOGE, FL("Unknown deferred msg type %d"),
4721 mac_ctx->lim.gDeferMsgTypeForNOA);
4722 break;
4723 }
4724 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4725}
4726
4727static void
4728__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4729{
4730 tpSirResetAPCapsChange pResetCapsChange;
4731 tpPESession psessionEntry;
4732 uint8_t sessionId = 0;
4733 if (pMsgBuf == NULL) {
4734 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4735 return;
4736 }
4737
4738 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4739 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004740 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4741 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004742 if (psessionEntry == NULL) {
4743 lim_log(pMac, LOGE,
4744 FL("Session does not exist for given BSSID"));
4745 return;
4746 }
4747
4748 psessionEntry->limSentCapsChangeNtf = false;
4749 return;
4750}
4751
4752/**
4753 * lim_process_sme_req_messages()
4754 *
4755 ***FUNCTION:
4756 * This function is called by limProcessMessageQueue(). This
4757 * function processes SME request messages from HDD or upper layer
4758 * application.
4759 *
4760 ***LOGIC:
4761 *
4762 ***ASSUMPTIONS:
4763 *
4764 ***NOTE:
4765 *
4766 * @param pMac Pointer to Global MAC structure
4767 * @param msgType Indicates the SME message type
4768 * @param *pMsgBuf A pointer to the SME message buffer
4769 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4770 * false - if pMsgBuf is not to be freed.
4771 */
4772
4773bool lim_process_sme_req_messages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4774{
4775 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
4776 uint32_t *pMsgBuf = pMsg->bodyptr;
4777 tpSirSmeScanReq pScanReq;
4778 PELOG1(lim_log
4779 (pMac, LOG1,
4780 FL
4781 ("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)"),
4782 lim_msg_str(pMsg->type), pMsg->type,
4783 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4784 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
4785 )
4786
4787 pScanReq = (tpSirSmeScanReq) pMsgBuf;
4788 /* If no insert NOA required then execute the code below */
4789
4790 switch (pMsg->type) {
4791 case eWNI_SME_SYS_READY_IND:
4792 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4793 break;
4794
4795 case eWNI_SME_START_BSS_REQ:
4796 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4797 break;
4798
4799 case eWNI_SME_SCAN_REQ:
4800 __lim_process_sme_scan_req(pMac, pMsgBuf);
4801 break;
4802
4803#ifdef FEATURE_OEM_DATA_SUPPORT
4804 case eWNI_SME_OEM_DATA_REQ:
4805 __lim_process_sme_oem_data_req(pMac, pMsgBuf);
4806 break;
4807#endif
4808 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4809 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
4810 break;
4811
4812 case eWNI_SME_UPDATE_NOA:
4813 __lim_process_sme_no_a_update(pMac, pMsgBuf);
4814 break;
4815 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4816 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4817 break;
4818 case eWNI_SME_JOIN_REQ:
4819 __lim_process_sme_join_req(pMac, pMsgBuf);
4820 break;
4821
4822 case eWNI_SME_REASSOC_REQ:
4823 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
4824 break;
4825
4826 case eWNI_SME_DISASSOC_REQ:
4827 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
4828 break;
4829
4830 case eWNI_SME_DISASSOC_CNF:
4831 case eWNI_SME_DEAUTH_CNF:
4832 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
4833 break;
4834
4835 case eWNI_SME_DEAUTH_REQ:
4836 __lim_process_sme_deauth_req(pMac, pMsgBuf);
4837 break;
4838
4839 case eWNI_SME_SETCONTEXT_REQ:
4840 __lim_process_sme_set_context_req(pMac, pMsgBuf);
4841 break;
4842
4843 case eWNI_SME_STOP_BSS_REQ:
4844 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
4845 break;
4846
4847 case eWNI_SME_ASSOC_CNF:
4848 if (pMsg->type == eWNI_SME_ASSOC_CNF)
4849 PELOG1(lim_log(pMac,
4850 LOG1, FL("Received ASSOC_CNF message"));)
4851 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
4852 pMsgBuf);
4853 break;
4854
4855 case eWNI_SME_ADDTS_REQ:
4856 PELOG1(lim_log(pMac, LOG1, FL("Received ADDTS_REQ message"));)
4857 __lim_process_sme_addts_req(pMac, pMsgBuf);
4858 break;
4859
4860 case eWNI_SME_DELTS_REQ:
4861 PELOG1(lim_log(pMac, LOG1, FL("Received DELTS_REQ message"));)
4862 __lim_process_sme_delts_req(pMac, pMsgBuf);
4863 break;
4864
4865 case SIR_LIM_ADDTS_RSP_TIMEOUT:
4866 PELOG1(lim_log
4867 (pMac, LOG1,
4868 FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
4869 )
4870 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
4871 break;
4872
4873 case eWNI_SME_GET_STATISTICS_REQ:
4874 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
4875 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
4876 bufConsumed = false;
4877 break;
4878#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
4879 case eWNI_SME_GET_TSM_STATS_REQ:
4880 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
4881 bufConsumed = false;
4882 break;
4883#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
4884 case eWNI_SME_GET_ASSOC_STAS_REQ:
4885 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
4886 break;
4887 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
4888 lim_process_tkip_counter_measures(pMac, pMsgBuf);
4889 break;
4890
4891 case eWNI_SME_HIDE_SSID_REQ:
4892 __lim_process_sme_hide_ssid(pMac, pMsgBuf);
4893 break;
4894 case eWNI_SME_UPDATE_APWPSIE_REQ:
4895 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
4896 break;
4897 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
4898 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
4899 break;
4900
4901 case eWNI_SME_SET_APWPARSNIEs_REQ:
4902 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
4903 break;
4904
4905 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
4906 /* Update the beaconInterval */
4907 __lim_process_sme_change_bi(pMac, pMsgBuf);
4908 break;
4909
4910#ifdef QCA_HT_2040_COEX
4911 case eWNI_SME_SET_HT_2040_MODE:
4912 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
4913 break;
4914#endif
4915
4916#if defined WLAN_FEATURE_VOWIFI
4917 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4918 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
4919 __lim_process_report_message(pMac, pMsg);
4920 break;
4921#endif
4922
4923#if defined WLAN_FEATURE_VOWIFI_11R
4924 case eWNI_SME_FT_PRE_AUTH_REQ:
4925 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
4926 break;
4927 case eWNI_SME_FT_UPDATE_KEY:
4928 lim_process_ft_update_key(pMac, pMsgBuf);
4929 break;
4930
4931 case eWNI_SME_FT_AGGR_QOS_REQ:
4932 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
4933 break;
4934#endif
4935
4936 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
4937 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
4938 break;
4939#ifdef FEATURE_WLAN_TDLS
4940 case eWNI_SME_TDLS_SEND_MGMT_REQ:
4941 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
4942 break;
4943 case eWNI_SME_TDLS_ADD_STA_REQ:
4944 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
4945 break;
4946 case eWNI_SME_TDLS_DEL_STA_REQ:
4947 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
4948 break;
4949 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
4950 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
4951 break;
4952#endif
4953 case eWNI_SME_RESET_AP_CAPS_CHANGED:
4954 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
4955 break;
4956
4957 case eWNI_SME_CHANNEL_CHANGE_REQ:
4958 lim_process_sme_channel_change_request(pMac, pMsgBuf);
4959 break;
4960
4961 case eWNI_SME_START_BEACON_REQ:
4962 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
4963 break;
4964
4965 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
4966 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
4967 break;
4968
4969 case eWNI_SME_UPDATE_ADDITIONAL_IES:
4970 lim_process_update_add_ies(pMac, pMsgBuf);
4971 break;
4972
4973 case eWNI_SME_MODIFY_ADDITIONAL_IES:
4974 lim_process_modify_add_ies(pMac, pMsgBuf);
4975 break;
4976 case eWNI_SME_SET_HW_MODE_REQ:
4977 lim_process_set_hw_mode(pMac, pMsgBuf);
4978 break;
4979 case eWNI_SME_NSS_UPDATE_REQ:
4980 lim_process_nss_update_request(pMac, pMsgBuf);
4981 break;
4982 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
4983 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
4984 break;
4985 case eWNI_SME_SET_IE_REQ:
4986 lim_process_set_ie_req(pMac, pMsgBuf);
4987 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05304988 case eWNI_SME_EXT_CHANGE_CHANNEL:
4989 lim_process_ext_change_channel(pMac, pMsgBuf);
4990 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004991 default:
4992 cdf_mem_free((void *)pMsg->bodyptr);
4993 pMsg->bodyptr = NULL;
4994 break;
4995 } /* switch (msgType) */
4996
4997 return bufConsumed;
4998} /*** end lim_process_sme_req_messages() ***/
4999
5000/**
5001 * lim_process_sme_start_beacon_req()
5002 *
5003 ***FUNCTION:
5004 * This function is called by limProcessMessageQueue(). This
5005 * function processes SME request messages from HDD or upper layer
5006 * application.
5007 *
5008 ***LOGIC:
5009 *
5010 ***ASSUMPTIONS:
5011 *
5012 ***NOTE:
5013 *
5014 * @param pMac Pointer to Global MAC structure
5015 * @param msgType Indicates the SME message type
5016 * @param *pMsgBuf A pointer to the SME message buffer
5017 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5018 * false - if pMsgBuf is not to be freed.
5019 */
5020static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5021{
5022 tpSirStartBeaconIndication pBeaconStartInd;
5023 tpPESession psessionEntry;
5024 uint8_t sessionId; /* PE sessionID */
5025
5026 if (pMsg == NULL) {
5027 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
5028 return;
5029 }
5030
5031 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5032 psessionEntry = pe_find_session_by_bssid(pMac,
5033 pBeaconStartInd->bssid,
5034 &sessionId);
5035 if (psessionEntry == NULL) {
5036 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
5037 lim_log(pMac, LOGE,
5038 FL("Session does not exist for given bssId"));
5039 return;
5040 }
5041
5042 if (pBeaconStartInd->beaconStartStatus == true) {
5043 /*
5044 * Currently this Indication comes from SAP
5045 * to start Beacon Tx on a DFS channel
5046 * since beaconing has to be done on DFS
5047 * channel only after CAC WAIT is completed.
5048 * On a DFS Channel LIM does not start beacon
5049 * Tx right after the WMA_ADD_BSS_RSP.
5050 */
5051 lim_apply_configuration(pMac, psessionEntry);
5052 CDF_TRACE(CDF_MODULE_ID_PE, CDF_TRACE_LEVEL_INFO,
5053 FL("Start Beacon with ssid %s Ch %d"),
5054 psessionEntry->ssId.ssId,
5055 psessionEntry->currentOperChannel);
5056 lim_send_beacon_ind(pMac, psessionEntry);
5057 } else {
5058 lim_log(pMac, LOGE, FL("Invalid Beacon Start Indication"));
5059 return;
5060 }
5061}
5062
5063/**
5064 * lim_process_sme_channel_change_request() - process sme ch change req
5065 *
5066 * @mac_ctx: Pointer to Global MAC structure
5067 * @msg_buf: pointer to the SME message buffer
5068 *
5069 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5070 *
5071 * Return: None
5072 */
5073static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5074 uint32_t *msg_buf)
5075{
5076 tpSirChanChangeRequest ch_change_req;
5077 tpPESession session_entry;
5078 uint8_t session_id; /* PE session_id */
5079 tPowerdBm max_tx_pwr;
5080 uint32_t val = 0;
5081
5082 if (msg_buf == NULL) {
5083 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5084 return;
5085 }
5086 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5087
5088 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5089 ch_change_req->targetChannel);
5090
5091 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5092 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
5093 lim_log(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5094 return;
5095 }
5096
5097 session_entry = pe_find_session_by_bssid(mac_ctx,
5098 ch_change_req->bssid, &session_id);
5099 if (session_entry == NULL) {
5100 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
5101 lim_log(mac_ctx, LOGE, FL(
5102 "Session does not exist for given bssId"));
5103 return;
5104 }
5105
5106 if (session_entry->currentOperChannel ==
5107 ch_change_req->targetChannel) {
5108 lim_log(mac_ctx, LOGE, FL("target CH is same as current CH"));
5109 return;
5110 }
5111
5112 if (LIM_IS_AP_ROLE(session_entry))
5113 session_entry->channelChangeReasonCode =
5114 LIM_SWITCH_CHANNEL_SAP_DFS;
5115 else
5116 session_entry->channelChangeReasonCode =
5117 LIM_SWITCH_CHANNEL_OPERATION;
5118
5119 lim_log(mac_ctx, LOGW, FL(
5120 "switch old chnl %d to new chnl %d, ch_bw %d"),
5121 session_entry->currentOperChannel,
5122 ch_change_req->targetChannel,
5123 ch_change_req->channel_width);
5124
5125 /* Store the New Channel Params in session_entry */
5126 session_entry->ch_width = ch_change_req->channel_width;
5127 session_entry->ch_center_freq_seg0 =
5128 ch_change_req->center_freq_seg_0;
5129 session_entry->ch_center_freq_seg1 =
5130 ch_change_req->center_freq_seg_1;
5131 session_entry->htSecondaryChannelOffset = ch_change_req->cbMode;
5132 session_entry->htSupportedChannelWidthSet =
5133 (ch_change_req->channel_width ? 1 : 0);
5134 session_entry->htRecommendedTxWidthSet =
5135 session_entry->htSupportedChannelWidthSet;
5136 session_entry->currentOperChannel =
5137 ch_change_req->targetChannel;
5138 session_entry->limRFBand =
5139 lim_get_rf_band(session_entry->currentOperChannel);
5140 /* Initialize 11h Enable Flag */
5141 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5142 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5143 eSIR_SUCCESS)
5144 lim_log(mac_ctx, LOGP,
5145 FL("Fail to get WNI_CFG_11H_ENABLED"));
5146 }
5147
5148 session_entry->lim11hEnable = val;
5149 session_entry->dot11mode = ch_change_req->dot11mode;
5150 cdf_mem_copy(&session_entry->rateSet,
5151 &ch_change_req->operational_rateset,
5152 sizeof(session_entry->rateSet));
5153 cdf_mem_copy(&session_entry->extRateSet,
5154 &ch_change_req->extended_rateset,
5155 sizeof(session_entry->extRateSet));
5156 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5157 session_entry->ch_center_freq_seg0,
5158 session_entry->ch_center_freq_seg1,
5159 session_entry->ch_width,
5160 max_tx_pwr, session_entry->peSessionId);
5161}
5162
5163/******************************************************************************
5164* lim_start_bss_update_add_ie_buffer()
5165*
5166***FUNCTION:
5167* This function checks the src buffer and its length and then malloc for
5168* dst buffer update the same
5169*
5170***LOGIC:
5171*
5172***ASSUMPTIONS:
5173*
5174***NOTE:
5175*
5176* @param pMac Pointer to Global MAC structure
5177* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5178* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5179* @param *pSrcData_buff A pointer of uint8_t src buffer
5180* @param srcDataLen src buffer length
5181******************************************************************************/
5182
5183static void
5184lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5185 uint8_t **pDstData_buff,
5186 uint16_t *pDstDataLen,
5187 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5188{
5189
5190 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5191 *pDstDataLen = srcDataLen;
5192
5193 *pDstData_buff = cdf_mem_malloc(*pDstDataLen);
5194
5195 if (NULL == *pDstData_buff) {
5196 lim_log(pMac, LOGE,
5197 FL("AllocateMemory failed for pDstData_buff"));
5198 return;
5199 }
5200 cdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
5201 } else {
5202 *pDstData_buff = NULL;
5203 *pDstDataLen = 0;
5204 }
5205}
5206
5207/******************************************************************************
5208* lim_update_add_ie_buffer()
5209*
5210***FUNCTION:
5211* This function checks the src buffer and length if src buffer length more
5212* than dst buffer length then free the dst buffer and malloc for the new src
5213* length, and update the dst buffer and length. But if dst buffer is bigger
5214* than src buffer length then it just update the dst buffer and length
5215*
5216***LOGIC:
5217*
5218***ASSUMPTIONS:
5219*
5220***NOTE:
5221*
5222* @param pMac Pointer to Global MAC structure
5223* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5224* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5225* @param *pSrcData_buff A pointer of uint8_t src buffer
5226* @param srcDataLen src buffer length
5227******************************************************************************/
5228
5229static void
5230lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5231 uint8_t **pDstData_buff,
5232 uint16_t *pDstDataLen,
5233 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5234{
5235
5236 if (NULL == pSrcData_buff) {
5237 lim_log(pMac, LOGE, FL("src buffer is null."));
5238 return;
5239 }
5240
5241 if (srcDataLen > *pDstDataLen) {
5242 *pDstDataLen = srcDataLen;
5243 /* free old buffer */
5244 cdf_mem_free(*pDstData_buff);
5245 /* allocate a new */
5246 *pDstData_buff = cdf_mem_malloc(*pDstDataLen);
5247
5248 if (NULL == *pDstData_buff) {
5249 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5250 *pDstDataLen = 0;
5251 return;
5252 }
5253 }
5254
5255 /* copy the content of buffer into dst buffer
5256 */
5257 *pDstDataLen = srcDataLen;
5258 cdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
5259
5260}
5261
5262/*
5263* lim_process_modify_add_ies() - process modify additional IE req.
5264*
5265* @mac_ctx: Pointer to Global MAC structure
5266* @msg_buf: pointer to the SME message buffer
5267*
5268* This function update the PE buffers for additional IEs.
5269*
5270* Return: None
5271*/
5272static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5273 uint32_t *msg_buf)
5274{
5275 tpSirModifyIEsInd modify_add_ies;
5276 tpPESession session_entry;
5277 uint8_t session_id;
5278 bool ret = false;
5279 tSirAddIeParams *add_ie_params;
5280
5281 if (msg_buf == NULL) {
5282 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5283 return;
5284 }
5285
5286 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5287 /* Incoming message has smeSession, use BSSID to find PE session */
5288 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005289 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005290
5291 if (NULL == session_entry) {
5292 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5293 MAC_ADDRESS_STR),
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005294 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005295 goto end;
5296 }
5297 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5298 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5299 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
5300 lim_log(mac_ctx, LOGE,
5301 FL("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d"),
5302 modify_add_ies->modifyIE.pIEBuffer,
5303 modify_add_ies->modifyIE.ieBufferlength,
5304 modify_add_ies->modifyIE.ieID,
5305 modify_add_ies->modifyIE.ieIDLen,
5306 modify_add_ies->updateType);
5307 goto end;
5308 }
5309 add_ie_params = &session_entry->addIeParams;
5310 switch (modify_add_ies->updateType) {
5311 case eUPDATE_IE_PROBE_RESP:
5312 /* Probe resp */
5313 break;
5314 case eUPDATE_IE_ASSOC_RESP:
5315 /* assoc resp IE */
5316 if (add_ie_params->assocRespDataLen == 0) {
5317 CDF_TRACE(CDF_MODULE_ID_PE,
5318 CDF_TRACE_LEVEL_ERROR, FL(
5319 "assoc resp add ie not present %d"),
5320 add_ie_params->assocRespDataLen);
5321 }
5322 /* search through the buffer and modify the IE */
5323 break;
5324 case eUPDATE_IE_PROBE_BCN:
5325 /*probe beacon IE */
5326 if (ret == true && modify_add_ies->modifyIE.notify) {
5327 lim_handle_param_update(mac_ctx,
5328 modify_add_ies->updateType);
5329 }
5330 break;
5331 default:
5332 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d"),
5333 modify_add_ies->updateType);
5334 break;
5335 }
5336end:
5337 cdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
5338 modify_add_ies->modifyIE.pIEBuffer = NULL;
5339}
5340
5341/*
5342* lim_process_update_add_ies() - process additional IE update req
5343*
5344* @mac_ctx: Pointer to Global MAC structure
5345* @msg_buf: pointer to the SME message buffer
5346*
5347* This function update the PE buffers for additional IEs.
5348*
5349* Return: None
5350*/
5351static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5352 uint32_t *msg_buf)
5353{
5354 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5355 uint8_t session_id;
5356 tpPESession session_entry;
5357 tSirAddIeParams *addn_ie;
5358 uint16_t new_length = 0;
5359 uint8_t *new_ptr = NULL;
5360 tSirUpdateIE *update_ie;
5361
5362 if (msg_buf == NULL) {
5363 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5364 return;
5365 }
5366 update_ie = &update_add_ies->updateIE;
5367 /* incoming message has smeSession, use BSSID to find PE session */
5368 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005369 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005370
5371 if (NULL == session_entry) {
5372 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5373 MAC_ADDRESS_STR),
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005374 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005375 goto end;
5376 }
5377 addn_ie = &session_entry->addIeParams;
5378 /* if len is 0, upper layer requested freeing of buffer */
5379 if (0 == update_ie->ieBufferlength) {
5380 switch (update_add_ies->updateType) {
5381 case eUPDATE_IE_PROBE_RESP:
5382 cdf_mem_free(addn_ie->probeRespData_buff);
5383 addn_ie->probeRespData_buff = NULL;
5384 addn_ie->probeRespDataLen = 0;
5385 break;
5386 case eUPDATE_IE_ASSOC_RESP:
5387 cdf_mem_free(addn_ie->assocRespData_buff);
5388 addn_ie->assocRespData_buff = NULL;
5389 addn_ie->assocRespDataLen = 0;
5390 break;
5391 case eUPDATE_IE_PROBE_BCN:
5392 cdf_mem_free(addn_ie->probeRespBCNData_buff);
5393 addn_ie->probeRespBCNData_buff = NULL;
5394 addn_ie->probeRespBCNDataLen = 0;
5395
5396 if (update_ie->notify)
5397 lim_handle_param_update(mac_ctx,
5398 update_add_ies->updateType);
5399 break;
5400 default:
5401 break;
5402 }
5403 return;
5404 }
5405 switch (update_add_ies->updateType) {
5406 case eUPDATE_IE_PROBE_RESP:
5407 if (update_ie->append) {
5408 /*
5409 * In case of append, allocate new memory
5410 * with combined length
5411 */
5412 new_length = update_ie->ieBufferlength +
5413 addn_ie->probeRespDataLen;
5414 new_ptr = cdf_mem_malloc(new_length);
5415 if (NULL == new_ptr) {
5416 lim_log(mac_ctx, LOGE, FL(
5417 "Memory allocation failed."));
5418 goto end;
5419 }
5420 /* append buffer to end of local buffers */
5421 cdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
5422 addn_ie->probeRespDataLen);
5423 cdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
5424 update_ie->pAdditionIEBuffer,
5425 update_ie->ieBufferlength);
5426 /* free old memory */
5427 cdf_mem_free(addn_ie->probeRespData_buff);
5428 /* adjust length accordingly */
5429 addn_ie->probeRespDataLen = new_length;
5430 /* save refernece of local buffer in PE session */
5431 addn_ie->probeRespData_buff = new_ptr;
5432 goto end;
5433 }
5434 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5435 &addn_ie->probeRespDataLen,
5436 update_ie->pAdditionIEBuffer,
5437 update_ie->ieBufferlength);
5438 break;
5439 case eUPDATE_IE_ASSOC_RESP:
5440 /* assoc resp IE */
5441 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5442 &addn_ie->assocRespDataLen,
5443 update_ie->pAdditionIEBuffer,
5444 update_ie->ieBufferlength);
5445 break;
5446 case eUPDATE_IE_PROBE_BCN:
5447 /* probe resp Bcn IE */
5448 lim_update_add_ie_buffer(mac_ctx,
5449 &addn_ie->probeRespBCNData_buff,
5450 &addn_ie->probeRespBCNDataLen,
5451 update_ie->pAdditionIEBuffer,
5452 update_ie->ieBufferlength);
5453 if (update_ie->notify)
5454 lim_handle_param_update(mac_ctx,
5455 update_add_ies->updateType);
5456 break;
5457 default:
5458 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d."),
5459 update_add_ies->updateType);
5460 break;
5461 }
5462end:
5463 cdf_mem_free(update_ie->pAdditionIEBuffer);
5464 update_ie->pAdditionIEBuffer = NULL;
5465}
5466
5467/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305468 * send_extended_chan_switch_action_frame()- function to send ECSA
5469 * action frame for each sta connected to SAP/GO and AP in case of
5470 * STA .
5471 * @mac_ctx: pointer to global mac structure
5472 * @new_channel: new channel to switch to.
5473 * @ch_bandwidth: BW of channel to calculate op_class
5474 * @session_entry: pe session
5475 *
5476 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5477 *
5478 * Return: void
5479 */
5480
5481static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5482 uint16_t new_channel, uint8_t ch_bandwidth,
5483 tpPESession session_entry)
5484{
5485 uint16_t op_class;
5486 uint8_t switch_mode = 0, i;
5487 tpDphHashNode psta;
5488
5489
5490 op_class = cds_regdm_get_opclass_from_channel(
5491 mac_ctx->scan.countryCodeCurrent,
5492 new_channel,
5493 ch_bandwidth);
5494
5495 if (LIM_IS_AP_ROLE(session_entry) &&
5496 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
5497 switch_mode = 1;
5498
5499 if (LIM_IS_AP_ROLE(session_entry)) {
5500 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5501 psta =
5502 session_entry->dph.dphHashTable.pDphNodeArray + i;
5503 if (psta && psta->added)
5504 lim_send_extended_chan_switch_action_frame(
5505 mac_ctx,
5506 psta->staAddr,
5507 switch_mode, op_class, new_channel,
5508 LIM_MAX_CSA_IE_UPDATES, session_entry);
5509 }
5510 } else if (LIM_IS_STA_ROLE(session_entry)) {
5511 lim_send_extended_chan_switch_action_frame(mac_ctx,
5512 session_entry->bssId,
5513 switch_mode, op_class, new_channel,
5514 LIM_MAX_CSA_IE_UPDATES, session_entry);
5515 }
5516
5517}
5518
5519/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005520 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5521 *
5522 * @mac_ctx: Pointer to Global MAC structure
5523 * @msg_buf: pointer to the SME message buffer
5524 *
5525 * This function processes SME request messages from HDD or upper layer
5526 * application.
5527 *
5528 * Return: None
5529 */
5530static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5531 uint32_t *msg_buf)
5532{
5533 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5534 tpPESession session_entry = NULL;
5535 uint32_t ch_width = 0;
5536 uint8_t session_id;
5537 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
5538
5539 if (msg_buf == NULL) {
5540 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5541 return;
5542 }
5543
5544 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5545 session_entry = pe_find_session_by_bssid(mac_ctx,
5546 dfs_csa_ie_req->bssid, &session_id);
5547 if (session_entry == NULL) {
5548 lim_log(mac_ctx, LOGE, FL(
5549 "Session not found for given BSSID" MAC_ADDRESS_STR),
5550 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5551 return;
5552 }
5553
5554 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5555 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5556 GET_LIM_SYSTEM_ROLE(session_entry));
5557 return;
5558 }
5559
5560 /* target channel */
5561 session_entry->gLimChannelSwitch.primaryChannel =
5562 dfs_csa_ie_req->targetChannel;
5563
5564 /* Channel switch announcement needs to be included in beacon */
5565 session_entry->dfsIncludeChanSwIe = true;
5566 session_entry->gLimChannelSwitch.switchCount = LIM_MAX_CSA_IE_UPDATES;
5567 session_entry->gLimChannelSwitch.ch_width =
5568 dfs_csa_ie_req->ch_bandwidth;
5569 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
5570 session_entry->gLimChannelSwitch.switchMode = 1;
5571
5572 /*
5573 * Validate if SAP is operating HT or VHT mode and set the Channel
5574 * Switch Wrapper element with the Wide Band Switch subelement.
5575 */
5576 if (true != session_entry->vhtCapability)
5577 goto skip_vht;
5578
5579 if (WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ ==
5580 session_entry->vhtTxChannelWidthSet)
5581 ch_width = eHT_CHANNEL_WIDTH_80MHZ;
5582 else if (WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ ==
5583 session_entry->vhtTxChannelWidthSet)
5584 ch_width = session_entry->htSupportedChannelWidthSet;
5585 /* Now encode the Wider Ch BW element depending on the ch width */
5586 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
5587 switch (ch_width) {
5588 case eHT_CHANNEL_WIDTH_20MHZ:
5589 /*
5590 * Wide channel BW sublement in channel wrapper element is not
5591 * required in case of 20 Mhz operation. Currently It is set
5592 * only set in case of 40/80 Mhz Operation.
5593 */
5594 session_entry->dfsIncludeChanWrapperIe = false;
5595 wider_bw_ch_switch->newChanWidth =
5596 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5597 break;
5598 case eHT_CHANNEL_WIDTH_40MHZ:
5599 session_entry->dfsIncludeChanWrapperIe = true;
5600 wider_bw_ch_switch->newChanWidth =
5601 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5602 break;
5603 case eHT_CHANNEL_WIDTH_80MHZ:
5604 session_entry->dfsIncludeChanWrapperIe = true;
5605 wider_bw_ch_switch->newChanWidth =
5606 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5607 break;
5608 case eHT_CHANNEL_WIDTH_160MHZ:
5609 session_entry->dfsIncludeChanWrapperIe = true;
5610 wider_bw_ch_switch->newChanWidth =
5611 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5612 break;
5613 default:
5614 session_entry->dfsIncludeChanWrapperIe = false;
5615 /*
5616 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5617 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5618 */
5619 lim_log(mac_ctx, LOGE, FL("Invalid Channel Width"));
5620 break;
5621 }
5622 /* Fetch the center channel based on the channel width */
5623 wider_bw_ch_switch->newCenterChanFreq0 =
5624 lim_get_center_channel(mac_ctx, dfs_csa_ie_req->targetChannel,
5625 session_entry->htSecondaryChannelOffset,
5626 wider_bw_ch_switch->newChanWidth);
5627 /*
5628 * This is not applicable for 20/40/80 Mhz.Only used when we support
5629 * 80+80 Mhz operation. In case of 80+80 Mhz, this parameter indicates
5630 * center channel frequency index of 80 Mhz channel of
5631 * frequency segment 1.
5632 */
5633 wider_bw_ch_switch->newCenterChanFreq1 = 0;
5634skip_vht:
5635 /* Send CSA IE request from here */
5636 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5637 eSIR_SUCCESS) {
5638 lim_log(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
5639 return;
5640 }
5641
5642 /*
5643 * First beacon update request is sent here, the remaining updates are
5644 * done when the FW responds back after sending the first beacon after
5645 * the template update
5646 */
5647 lim_send_beacon_ind(mac_ctx, session_entry);
5648 lim_log(mac_ctx, LOG1, FL("Updated CSA IE, IE COUNT = %d"),
5649 session_entry->gLimChannelSwitch.switchCount);
Abhishek Singh518323d2015-10-19 17:42:01 +05305650 /* Send ECSA Action frame after updating the beacon */
5651 send_extended_chan_switch_action_frame(mac_ctx,
5652 session_entry->gLimChannelSwitch.primaryChannel,
5653 session_entry->gLimChannelSwitch.ch_width,
5654 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005655 session_entry->gLimChannelSwitch.switchCount--;
5656}
5657
5658/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305659 * lim_process_ext_change_channel()- function to send ECSA
5660 * action frame for STA/CLI .
5661 * @mac_ctx: pointer to global mac structure
5662 * @msg: params from sme for new channel.
5663 *
5664 * This function is called to send ECSA frame for STA/CLI.
5665 *
5666 * Return: void
5667 */
5668
5669static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5670 uint32_t *msg)
5671{
5672 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5673 (struct sir_sme_ext_cng_chan_req *) msg;
5674 tpPESession session_entry = NULL;
5675
5676 if (NULL == msg) {
5677 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5678 return;
5679 }
5680 session_entry =
5681 pe_find_session_by_sme_session_id(mac_ctx,
5682 ext_chng_channel->session_id);
5683 if (NULL == session_entry) {
5684 lim_log(mac_ctx, LOGE,
5685 FL("Session not found for given session %d"),
5686 ext_chng_channel->session_id);
5687 return;
5688 }
5689 if (LIM_IS_AP_ROLE(session_entry)) {
5690 lim_log(mac_ctx, LOGE,
5691 FL("not an STA/CLI session"));
5692 return;
5693 }
5694 send_extended_chan_switch_action_frame(mac_ctx,
5695 ext_chng_channel->new_channel,
5696 0, session_entry);
5697}
5698
5699/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005700 * lim_process_nss_update_request() - process sme nss update req
5701 *
5702 * @mac_ctx: Pointer to Global MAC structure
5703 * @msg_buf: pointer to the SME message buffer
5704 *
5705 * This function processes SME request messages from HDD or upper layer
5706 * application.
5707 *
5708 * Return: None
5709 */
5710static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5711 uint32_t *msg_buf)
5712{
5713 struct sir_nss_update_request *nss_update_req_ptr;
5714 tpPESession session_entry = NULL;
5715
5716 if (msg_buf == NULL) {
5717 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5718 return;
5719 }
5720
5721 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
5722 session_entry = pe_find_session_by_session_id(mac_ctx,
5723 nss_update_req_ptr->vdev_id);
5724 if (session_entry == NULL) {
5725 lim_log(mac_ctx, LOGE, FL(
5726 "Session not found for given session_id %d"),
5727 nss_update_req_ptr->vdev_id);
5728 return;
5729 }
5730
5731 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5732 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5733 GET_LIM_SYSTEM_ROLE(session_entry));
5734 return;
5735 }
5736
5737 /* populate nss field in the beacon */
5738 session_entry->gLimOperatingMode.present = 1;
5739 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
5740 /* Send nss update request from here */
5741 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5742 eSIR_SUCCESS) {
5743 lim_log(mac_ctx, LOGE,
5744 FL("Unable to set op mode IE in beacon"));
5745 return;
5746 }
5747
5748 lim_send_beacon_ind(mac_ctx, session_entry);
5749}
5750
5751/**
5752 * lim_process_set_ie_req() - process sme set IE request
5753 *
5754 * @mac_ctx: Pointer to Global MAC structure
5755 * @msg_buf: pointer to the SME message buffer
5756 *
5757 * This function processes SME request messages from HDD or upper layer
5758 * application.
5759 *
5760 * Return: None
5761 */
5762static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5763{
5764 struct send_extcap_ie *msg;
5765 CDF_STATUS status;
5766
5767 if (msg_buf == NULL) {
5768 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5769 return;
5770 }
5771
5772 msg = (struct send_extcap_ie *)msg_buf;
5773 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
5774 if (CDF_STATUS_SUCCESS != status)
5775 lim_log(mac_ctx, LOGE, FL("Unable to send ExtCap to FW"));
5776
5777}