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