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