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