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