blob: 8133c321b1a6e5b6f98b5696b324a4bcb7222336 [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"
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070060#include "nan_datapath.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080061
62#include "sap_api.h"
63
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080064
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080065#include <lim_ft.h>
Naveen Rawat3b6068c2016-04-14 19:01:06 -070066#include "cds_regdomain.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080067
68/*
69 * This overhead is time for sending NOA start to host in case of GO/sending
70 * NULL data & receiving ACK in case of P2P Client and starting actual scanning
71 * with init scan req/rsp plus in case of concurrency, taking care of sending
72 * null data and receiving ACK to/from AP/Also SetChannel with calibration
73 * is taking around 7ms .
74 */
75#define SCAN_MESSAGING_OVERHEAD 20 /* in msecs */
76#define JOIN_NOA_DURATION 2000 /* in msecs */
77#define OEM_DATA_NOA_DURATION 60 /* in msecs */
78#define DEFAULT_PASSIVE_MAX_CHANNEL_TIME 110 /* in msecs */
79
80#define CONV_MS_TO_US 1024 /* conversion factor from ms to us */
81
82/* SME REQ processing function templates */
83static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal, uint32_t *);
84static bool __lim_process_sme_start_bss_req(tpAniSirGlobal, tpSirMsgQ pMsg);
85static void __lim_process_sme_scan_req(tpAniSirGlobal, uint32_t *);
86static void __lim_process_sme_join_req(tpAniSirGlobal, uint32_t *);
87static void __lim_process_sme_reassoc_req(tpAniSirGlobal, uint32_t *);
88static void __lim_process_sme_disassoc_req(tpAniSirGlobal, uint32_t *);
89static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal, uint32_t *);
90static void __lim_process_sme_deauth_req(tpAniSirGlobal, uint32_t *);
91static void __lim_process_sme_set_context_req(tpAniSirGlobal, uint32_t *);
92static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal, tpSirMsgQ pMsg);
93static void lim_process_sme_channel_change_request(tpAniSirGlobal pMac,
94 uint32_t *pMsg);
95static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg);
96static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal pMac, uint32_t *pMsg);
97static void lim_process_nss_update_request(tpAniSirGlobal pMac, uint32_t *pMsg);
98static void lim_process_set_ie_req(tpAniSirGlobal pMac, uint32_t *pMsg);
99
100static void lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
101 uint8_t **pDstData_buff,
102 uint16_t *pDstDataLen,
103 uint8_t *pSrcData_buff,
104 uint16_t srcDataLen);
105
106static void lim_update_add_ie_buffer(tpAniSirGlobal pMac,
107 uint8_t **pDstData_buff,
108 uint16_t *pDstDataLen,
109 uint8_t *pSrcData_buff, uint16_t srcDataLen);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800110static bool lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac,
111 uint8_t **pDstData_buff,
112 uint16_t *pDstDataLen,
113 tSirModifyIE *pModifyIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800114static void lim_process_modify_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
115
116static void lim_process_update_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
117
Naveen Rawat0fc3f692016-06-22 14:30:54 -0700118extern void pe_register_callbacks_with_wma(tpAniSirGlobal pMac,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800119 tSirSmeReadyReq *ready_req);
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;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +0530168 cds_message.type = SIR_HAL_PDEV_SET_HW_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800169
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,
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -0700174 FL("cds_mq_post_message failed!(err=%d)"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800175 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) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700227 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800228 /* 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;
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +0530241 cds_message.type = SIR_HAL_PDEV_DUAL_MAC_CFG_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800242
243 lim_log(mac, LOG1,
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +0530244 FL("Post SIR_HAL_PDEV_DUAL_MAC_CFG_REQ to WMA: %x %x"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800245 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,
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -0700249 FL("cds_mq_post_message failed!(err=%d)"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800250 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/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800270 * lim_process_set_antenna_mode_req() - Set antenna mode command
271 * to WMA
272 * @mac: Global MAC pointer
273 * @msg: Message containing the antenna mode parameter
274 *
275 * Send the set antenna mode command to WMA
276 *
277 * Return: QDF_STATUS_SUCCESS if message posting is successful
278 */
279static QDF_STATUS lim_process_set_antenna_mode_req(tpAniSirGlobal mac,
280 uint32_t *msg)
281{
282 QDF_STATUS status = QDF_STATUS_SUCCESS;
283 cds_msg_t cds_message;
284 struct sir_antenna_mode_param *req_msg;
285 struct sir_set_antenna_mode *buf;
286 tSirMsgQ resp_msg;
287 struct sir_antenna_mode_resp *param;
288
289 buf = (struct sir_set_antenna_mode *) msg;
290 if (!buf) {
291 lim_log(mac, LOGE, FL("Set antenna mode is NULL"));
292 /* To free the active command list */
293 goto fail;
294 }
295
296 req_msg = qdf_mem_malloc(sizeof(*req_msg));
297 if (!req_msg) {
298 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
299 return QDF_STATUS_E_NOMEM;
300 }
301
302 req_msg->num_rx_chains = buf->set_antenna_mode.num_rx_chains;
303 req_msg->num_tx_chains = buf->set_antenna_mode.num_tx_chains;
304
305 cds_message.bodyptr = req_msg;
306 cds_message.type = SIR_HAL_SOC_ANTENNA_MODE_REQ;
307
308 lim_log(mac, LOG1,
309 FL("Post SIR_HAL_SOC_ANTENNA_MODE_REQ to WMA: %d %d"),
310 req_msg->num_rx_chains,
311 req_msg->num_tx_chains);
312 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
313 if (!QDF_IS_STATUS_SUCCESS(status)) {
314 lim_log(mac, LOGE,
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -0700315 FL("cds_mq_post_message failed!(err=%d)"),
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800316 status);
317 qdf_mem_free(req_msg);
318 goto fail;
319 }
320 return status;
321fail:
322 param = qdf_mem_malloc(sizeof(*param));
323 if (!param) {
324 lim_log(mac, LOGE, FL("antenna mode resp failed"));
325 return QDF_STATUS_E_NOMEM;
326 }
327 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
328 resp_msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
329 resp_msg.bodyptr = param;
330 resp_msg.bodyval = 0;
331 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
332 return QDF_STATUS_SUCCESS;
333}
334
335/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800336 * __lim_fresh_scan_reqd() - determine if a fresh scan request must be issued.
337 * @mac_ctx: Pointer to Global MAC structure
338 * @return_fresh_results: Trigger fresh scan.
339 *
340 * PE will do fresh scan, if all of the active sessions are in
341 * good state (Link Est or BSS Started). If one of the sessions
342 * is not in one of the above states, then PE does not do fresh
343 * scan. If no session exists (scanning very first time),
344 * then PE will always do fresh scan if SME asks it to do that.
345 *
346 * Return: true for fresh scan results, false if in invalid state.
347 */
348static uint8_t
349__lim_fresh_scan_reqd(tpAniSirGlobal mac_ctx, uint8_t return_fresh_results)
350{
351 uint8_t valid_state = true;
352 int i;
353
354 lim_log(mac_ctx, LOG1, FL("gLimSmeState: %d, returnFreshResults 0x%x"),
355 mac_ctx->lim.gLimSmeState, return_fresh_results);
356
357 if (mac_ctx->lim.gLimSmeState != eLIM_SME_IDLE_STATE) {
358 lim_log(mac_ctx, LOG1, FL("return FALSE"));
359 return false;
360 }
361
362 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
Naveen Rawatb6a951a2016-06-21 15:02:37 -0700363
364 if (mac_ctx->lim.gpSession[i].valid == false)
365 continue;
366
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800367 lim_log(mac_ctx, LOG1,
368 FL("session %d, bsstype %d, limSystemRole %d, limSmeState %d"),
369 i, mac_ctx->lim.gpSession[i].bssType,
370 mac_ctx->lim.gpSession[i].limSystemRole,
371 mac_ctx->lim.gpSession[i].limSmeState);
Naveen Rawatb6a951a2016-06-21 15:02:37 -0700372
373 if (mac_ctx->lim.gpSession[i].bssType == eSIR_NDI_MODE)
374 continue;
375
376 if (mac_ctx->lim.gpSession[i].bssType ==
377 eSIR_INFRASTRUCTURE_MODE &&
378 mac_ctx->lim.gpSession[i].limSmeState ==
379 eLIM_SME_LINK_EST_STATE)
380 continue;
381
382 if (mac_ctx->lim.gpSession[i].bssType == eSIR_IBSS_MODE &&
383 mac_ctx->lim.gpSession[i].limSmeState ==
384 eLIM_SME_NORMAL_STATE)
385 continue;
386
387 if (mac_ctx->lim.gpSession[i].bssType == eSIR_INFRA_AP_MODE &&
388 mac_ctx->lim.gpSession[i].pePersona ==
389 QDF_P2P_GO_MODE &&
390 mac_ctx->lim.gpSession[i].limSmeState ==
391 eLIM_SME_NORMAL_STATE)
392 continue;
393
394 if (mac_ctx->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE &&
395 mac_ctx->lim.gpSession[i].limSmeState ==
396 eLIM_SME_NORMAL_STATE)
397 continue;
398
399 valid_state = false;
400 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800401 }
402
403 lim_log(mac_ctx, LOG1, FL("valid_state: %d"), valid_state);
404
405 if ((valid_state) &&
406 (return_fresh_results & SIR_BG_SCAN_RETURN_FRESH_RESULTS))
407 return true;
408 else
409 return false;
410}
411
412/**
413 * __lim_is_sme_assoc_cnf_valid()
414 *
415 ***FUNCTION:
416 * This function is called by __lim_process_sme_assoc_cnf_new() upon
417 * receiving SME_ASSOC_CNF.
418 *
419 ***LOGIC:
420 * Message validity checks are performed in this function
421 *
422 ***ASSUMPTIONS:
423 *
424 ***NOTE:
425 *
426 * @param pMeasReq Pointer to Received ASSOC_CNF message
427 * @return true When received SME_ASSOC_CNF is formatted
428 * correctly
429 * false otherwise
430 */
431
432static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
433{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530434 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800435 return false;
436 else
437 return true;
438} /*** end __lim_is_sme_assoc_cnf_valid() ***/
439
440/**
441 * __lim_get_sme_join_req_size_for_alloc()
442 *
443 ***FUNCTION:
444 * This function is called in various places to get IE length
445 * from tSirBssDescription structure
446 * number being scanned.
447 *
448 ***PARAMS:
449 *
450 ***LOGIC:
451 *
452 ***ASSUMPTIONS:
453 * NA
454 *
455 ***NOTE:
456 * NA
457 *
458 * @param pBssDescr
459 * @return Total IE length
460 */
461
462static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
463{
464 uint16_t len = 0;
465
466 if (!pBuf)
467 return len;
468
469 pBuf += sizeof(uint16_t);
470 len = lim_get_u16(pBuf);
471 return len + sizeof(uint16_t);
472}
473
474/**
475 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
476 * @pMac: Global MAC context
477 * @pMsg: Pointer to message posted from SME to LIM.
478 *
479 * Has role only if 11h is enabled. Not used on STA side.
480 * Defers the message if SME is in learn state and brings
481 * the LIM back to normal mode.
482 *
483 * Return: true - If defered false - Otherwise
484 */
485
486static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
487{
488 if (lim_is_system_in_scan_state(pMac)) {
489 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
490 lim_log(pMac, LOGE, FL("Could not defer Msg = %d"),
491 pMsg->type);
492 return false;
493 }
494 lim_log(pMac, LOG1,
495 FL("Defer the message, in learn mode type = %d"),
496 pMsg->type);
497 return true;
498 }
499 return false;
500}
501
502/**
503 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
504 * @mac_ctx: Pointer to Global MAC structure
505 * @message: Pointer to message posted from SME to LIM.
506 *
507 * Has role only if 11h is enabled. Not used on STA side.
508 * Defers the message if radar is detected.
509 *
510 * Return: true, if defered otherwise return false.
511 */
512static bool
513__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx, tpSirMsgQ message)
514{
515 /*
516 * fRadarDetCurOperChan will be set only if we
517 * detect radar in current operating channel and
518 * System Role == AP ROLE
519 *
520 * TODO: Need to take care radar detection.
521 *
522 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
523 */
524 if (0) {
525 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
526 lim_log(mac_ctx, LOGE, FL("Could not defer Msg = %d"),
527 message->type);
528 return false;
529 }
530 lim_log(mac_ctx, LOG1,
531 FL("Defer the message, in learn mode type = %d"),
532 message->type);
533 return true;
534 }
535 return false;
536}
537
538/**
539 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
540 * @pMac: Global MAC context
541 * @pMsgBuf: Message from WMA
542 *
543 * handles the notification from HDD. PE just forwards this message to HAL.
544 *
545 * Return: true-Posting to HAL failed, so PE will consume the buffer.
546 * false-Posting to HAL successful, so HAL will consume the buffer.
547 */
548
549static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
550{
551 tSirMsgQ msg;
552 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
553
554 msg.type = WMA_SYS_READY_IND;
555 msg.reserved = 0;
556 msg.bodyptr = pMsgBuf;
557 msg.bodyval = 0;
558
559 if (ANI_DRIVER_TYPE(pMac) != eDRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800560 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
Naveen Rawat0fc3f692016-06-22 14:30:54 -0700561 pe_register_callbacks_with_wma(pMac, ready_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800562 pMac->lim.add_bssdescr_callback = ready_req->add_bssdescr_cb;
563 }
564 PELOGW(lim_log(pMac, LOGW, FL("sending WMA_SYS_READY_IND msg to HAL"));)
565 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
566
567 if (eSIR_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
568 lim_log(pMac, LOGP, FL("wma_post_ctrl_msg failed"));
569 return true;
570 }
571 return false;
572}
573
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800574/**
575 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
576 *@mac_ctx: Pointer to Global MAC structure
577 *@session: A pointer to session entry
578 *@sme_start_bss_req: Start BSS Request from upper layers.
579 *
580 * This function is used to configure the start bss parameters
581 * in to the session.
582 *
583 * Return: None.
584 */
585static void
586lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
587 tpSirSmeStartBssReq sme_start_bss_req)
588{
589 session->limSystemRole = eLIM_AP_ROLE;
590 session->privacy = sme_start_bss_req->privacy;
591 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
592 session->authType = sme_start_bss_req->authType;
593 /* Store the DTIM period */
594 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
595 /* Enable/disable UAPSD */
596 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530597 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800598 session->proxyProbeRspEn = 0;
599 } else {
600 /*
601 * To detect PBC overlap in SAP WPS mode,
602 * Host handles Probe Requests.
603 */
604 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
605 session->proxyProbeRspEn = 1;
606 else
607 session->proxyProbeRspEn = 0;
608 }
609 session->ssidHidden = sme_start_bss_req->ssidHidden;
610 session->wps_state = sme_start_bss_req->wps_state;
611 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
612 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
613 &session->shortSlotTimeSupported);
614 session->isCoalesingInIBSSAllowed =
615 sme_start_bss_req->isCoalesingInIBSSAllowed;
616
617}
618
619/**
620 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
621 *@mac_ctx: Pointer to Global MAC structure
622 *@msg_buf: A pointer to the SME message buffer
623 *
624 * This function is called to process SME_START_BSS_REQ message
625 * from HDD or upper layer application.
626 *
627 * Return: None
628 */
629static void
630__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
631{
632 uint16_t size;
633 uint32_t val = 0;
634 tSirRetStatus ret_status;
635 tSirMacChanNum channel_number;
636 tLimMlmStartReq *mlm_start_req = NULL;
637 tpSirSmeStartBssReq sme_start_bss_req = NULL;
638 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
639 /* Flag Used in case of IBSS to Auto generate BSSID. */
640 uint32_t auto_gen_bssid = false;
641 uint8_t session_id;
642 tpPESession session = NULL;
643 uint8_t sme_session_id = 0;
644 uint16_t sme_transaction_id = 0;
645 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700646 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800647 tSirRetStatus cfg_get_wmi_dfs_master_param = eSIR_SUCCESS;
648
649/* FEATURE_WLAN_DIAG_SUPPORT */
650#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
651 /*
652 * Since the session is not created yet, sending NULL.
653 * The response should have the correct state.
654 */
655 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
656 NULL, 0, 0);
657#endif /* FEATURE_WLAN_DIAG_SUPPORT */
658
659 lim_log(mac_ctx, LOG1, FL("Received START_BSS_REQ"));
660
661 /*
662 * Global Sme state and mlm states are not defined yet,
663 * for BT-AMP Suppoprt . TO BE DONE
664 */
665 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
666 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
667 size = sizeof(tSirSmeStartBssReq);
668
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530669 sme_start_bss_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800670 if (NULL == sme_start_bss_req) {
671 lim_log(mac_ctx, LOGE,
672 FL("Allocate Memory fail for LimStartBssReq"));
673 /* Send failure response to host */
674 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
675 goto end;
676 }
677
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530678 qdf_mem_set((void *)sme_start_bss_req, size, 0);
679 qdf_mem_copy(sme_start_bss_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800680 sizeof(tSirSmeStartBssReq));
681 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
682 sme_start_bss_req)) {
683 lim_log(mac_ctx, LOGW,
684 FL("Received invalid eWNI_SME_START_BSS_REQ"));
685 ret_code = eSIR_SME_INVALID_PARAMETERS;
686 goto free;
687 }
688
689 /*
690 * This is the place where PE is going to create a session.
691 * If session is not existed, then create a new session
692 */
693 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800694 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800695 if (session != NULL) {
696 lim_log(mac_ctx, LOGW,
697 FL("Session Already exists for given BSSID"));
698 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
699 session = NULL;
700 goto free;
701 } else {
702 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800703 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800704 &session_id, mac_ctx->lim.maxStation,
705 sme_start_bss_req->bssType);
706 if (session == NULL) {
707 lim_log(mac_ctx, LOGW,
708 FL("Session Can not be created "));
709 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
710 goto free;
711 }
712 }
713
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700714 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
715 /* Probe resp add ie */
716 lim_start_bss_update_add_ie_buffer(mac_ctx,
717 &session->addIeParams.probeRespData_buff,
718 &session->addIeParams.probeRespDataLen,
719 sme_start_bss_req->addIeParams.
720 probeRespData_buff,
721 sme_start_bss_req->addIeParams.
722 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800723
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700724 /* Probe Beacon add ie */
725 lim_start_bss_update_add_ie_buffer(mac_ctx,
726 &session->addIeParams.probeRespBCNData_buff,
727 &session->addIeParams.probeRespBCNDataLen,
728 sme_start_bss_req->addIeParams.
729 probeRespBCNData_buff,
730 sme_start_bss_req->addIeParams.
731 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800732
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700733 /* Assoc resp IE */
734 lim_start_bss_update_add_ie_buffer(mac_ctx,
735 &session->addIeParams.assocRespData_buff,
736 &session->addIeParams.assocRespDataLen,
737 sme_start_bss_req->addIeParams.
738 assocRespData_buff,
739 sme_start_bss_req->addIeParams.
740 assocRespDataLen);
741 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800742 /* Store the session related params in newly created session */
743 session->pLimStartBssReq = sme_start_bss_req;
744
745 /* Store PE session_id in session Table */
746 session->peSessionId = session_id;
747
748 /* Store SME session Id in sessionTable */
749 session->smeSessionId = sme_start_bss_req->sessionId;
750
751 session->transactionId = sme_start_bss_req->transactionId;
752
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530753 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800754 &(sme_start_bss_req->htConfig),
755 sizeof(session->htConfig));
756
757 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800758 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800759
760 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530761 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800762 (uint8_t *) &sme_start_bss_req->ssId,
763 (sme_start_bss_req->ssId.length + 1));
764
765 session->bssType = sme_start_bss_req->bssType;
766
767 session->nwType = sme_start_bss_req->nwType;
768
769 session->beaconParams.beaconInterval =
770 sme_start_bss_req->beaconInterval;
771
772 /* Store the channel number in session Table */
773 session->currentOperChannel =
774 sme_start_bss_req->channelId;
775
776 /* Store Persona */
777 session->pePersona = sme_start_bss_req->bssPersona;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530778 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800779 FL("PE PERSONA=%d"), session->pePersona);
780
781 /* Update the phymode */
782 session->gLimPhyMode = sme_start_bss_req->nwType;
783
784 session->maxTxPower =
785 cfg_get_regulatory_max_transmit_power(mac_ctx,
786 session->currentOperChannel);
787 /* Store the dot 11 mode in to the session Table */
788 session->dot11mode = sme_start_bss_req->dot11mode;
789#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
790 session->cc_switch_mode =
791 sme_start_bss_req->cc_switch_mode;
792#endif
793 session->htCapability =
794 IS_DOT11_MODE_HT(session->dot11mode);
795 session->vhtCapability =
796 IS_DOT11_MODE_VHT(session->dot11mode);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530797 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800798 FL("*****session->vhtCapability = %d"),
799 session->vhtCapability);
800 session->txLdpcIniFeatureEnabled =
801 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800802#ifdef WLAN_FEATURE_11W
803 session->limRmfEnabled =
804 sme_start_bss_req->pmfCapable ? 1 : 0;
805 lim_log(mac_ctx, LOG1, FL("Session RMF enabled: %d"),
806 session->limRmfEnabled);
807#endif
808
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530809 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800810 (void *)&sme_start_bss_req->operationalRateSet,
811 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530812 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800813 (void *)&sme_start_bss_req->extendedRateSet,
814 sizeof(tSirMacRateSet));
815
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700816 if (IS_5G_CH(session->currentOperChannel))
817 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
818 else
819 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
820
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800821 switch (sme_start_bss_req->bssType) {
822 case eSIR_INFRA_AP_MODE:
823 lim_configure_ap_start_bss_session(mac_ctx, session,
824 sme_start_bss_req);
Anurag Chouhan6d760662016-02-20 16:05:43 +0530825 if (session->pePersona == QDF_SAP_MODE) {
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -0800826 session->txBFIniFeatureEnabled =
827 sme_start_bss_req->txbf_ini_enabled;
828 session->txbf_csn_value =
829 sme_start_bss_req->txbf_csn_val;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700830 session->vdev_nss = vdev_type_nss->sap;
831 } else {
832 session->vdev_nss = vdev_type_nss->p2p_go;
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -0800833 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800834 break;
835 case eSIR_IBSS_MODE:
836 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
837 lim_get_short_slot_from_phy_mode(mac_ctx, session,
838 session->gLimPhyMode,
839 &session->shortSlotTimeSupported);
840
841 /*
842 * initialize to "OPEN".
843 * will be updated upon key installation
844 */
845 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700846 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800847
848 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700849 case eSIR_NDI_MODE:
850 session->limSystemRole = eLIM_NDI_ROLE;
851 break;
852
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800853
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800854 /*
855 * There is one more mode called auto mode.
856 * which is used no where
857 */
858
859 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
860
861 default:
862 /* not used anywhere...used in scan function */
863 break;
864 }
865
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700866 lim_log(mac_ctx, LOG1, FL("persona - %d, nss - %d"),
867 session->pePersona, session->vdev_nss);
868 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800869 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700870 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800871 * parsed (Re)Assoc request structure
872 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700873 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800874 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530875 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700876 size * sizeof(tpSirAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800877 if (NULL == session->parsedAssocReq) {
878 lim_log(mac_ctx, LOGW,
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700879 FL("AllocateMemory() failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800880 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
881 goto free;
882 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530883 qdf_mem_set(session->parsedAssocReq,
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700884 (session->dph.dphHashTable.size *
885 sizeof(tpSirAssocReq)), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800886 }
887
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700888 if (!sme_start_bss_req->channelId &&
889 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800890 lim_log(mac_ctx, LOGE,
891 FL("Received invalid eWNI_SME_START_BSS_REQ"));
892 ret_code = eSIR_SME_INVALID_PARAMETERS;
893 goto free;
894 }
895 channel_number = sme_start_bss_req->channelId;
896#ifdef QCA_HT_2040_COEX
897 if (sme_start_bss_req->obssEnabled)
898 session->htSupportedChannelWidthSet =
899 session->htCapability;
900 else
901#endif
902 session->htSupportedChannelWidthSet =
903 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
904 session->htSecondaryChannelOffset =
905 sme_start_bss_req->sec_ch_offset;
906 session->htRecommendedTxWidthSet =
907 (session->htSecondaryChannelOffset) ? 1 : 0;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530908 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800909 FL("cbMode %u"), sme_start_bss_req->cbMode);
910 if (session->vhtCapability || session->htCapability) {
911 chanwidth = sme_start_bss_req->vht_channel_width;
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800912 lim_log(mac_ctx, LOG1,
913 FL("vht_channel_width %u htSupportedChannelWidthSet %d"),
914 sme_start_bss_req->vht_channel_width,
915 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800916 session->ch_width = chanwidth;
917 if (session->htSupportedChannelWidthSet) {
918 session->ch_center_freq_seg0 =
919 sme_start_bss_req->center_freq_seg0;
920 session->ch_center_freq_seg1 =
921 sme_start_bss_req->center_freq_seg1;
922 } else {
923 session->ch_center_freq_seg0 = 0;
924 session->ch_center_freq_seg1 = 0;
925 }
926 }
927
928 if (session->vhtCapability &&
929 (CH_WIDTH_160MHZ > session->ch_width)) {
930 if (wlan_cfg_get_int(mac_ctx,
931 WNI_CFG_VHT_SU_BEAMFORMER_CAP, &val) !=
932 eSIR_SUCCESS)
933 lim_log(mac_ctx, LOGE, FL(
934 "cfg get vht su bformer failed"));
935
936 session->enable_su_tx_bformer = val;
937 } else {
938 session->nss = 1;
939 }
940 lim_log(mac_ctx, LOG1, FL("vht su tx bformer %d"), val);
941
942 /* Delete pre-auth list if any */
943 lim_delete_pre_auth_list(mac_ctx);
944
945 /*
946 * keep the RSN/WPA IE information in PE Session Entry
947 * later will be using this to check when received (Re)Assoc req
948 */
949 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
950 &sme_start_bss_req->rsnIE, session);
951
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700952 if (LIM_IS_AP_ROLE(session) ||
953 LIM_IS_IBSS_ROLE(session) ||
954 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800955 session->gLimProtectionControl =
956 sme_start_bss_req->protEnabled;
957 /*
958 * each byte will have the following info
959 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
960 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
961 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530962 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800963 (void *)&sme_start_bss_req->ht_capab,
964 sizeof(uint16_t));
965 /* Initialize WPS PBC session link list */
966 session->pAPWPSPBCSession = NULL;
967 }
968 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530969 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800970 if (NULL == mlm_start_req) {
971 lim_log(mac_ctx, LOGP,
972 FL("Allocate Memory failed for mlmStartReq"));
973 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
974 goto free;
975 }
976
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530977 qdf_mem_set((void *)mlm_start_req, sizeof(tLimMlmStartReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800978
979 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530980 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800981 (uint8_t *) &sme_start_bss_req->ssId,
982 sme_start_bss_req->ssId.length + 1);
983 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
984 mlm_start_req->obssProtEnabled =
985 sme_start_bss_req->obssProtEnabled;
986
987 mlm_start_req->bssType = session->bssType;
988
989 /* Fill PE session Id from the session Table */
990 mlm_start_req->sessionId = session->peSessionId;
991
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700992 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
993 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800994 /*
995 * Copy the BSSId from sessionTable to
996 * mlmStartReq struct
997 */
998 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
999 } else {
1000 /* ibss mode */
1001 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1002
1003 ret_status = wlan_cfg_get_int(mac_ctx,
1004 WNI_CFG_IBSS_AUTO_BSSID,
1005 &auto_gen_bssid);
1006 if (ret_status != eSIR_SUCCESS) {
1007 lim_log(mac_ctx, LOGP,
1008 FL("Get Auto Gen BSSID fail,Status=%d"),
1009 ret_status);
1010 ret_code = eSIR_LOGP_EXCEPTION;
1011 goto free;
1012 }
1013
1014 if (!auto_gen_bssid) {
1015 /*
1016 * We're not auto generating BSSID.
1017 * Instead, get it from session entry
1018 */
1019 sir_copy_mac_addr(mlm_start_req->bssId,
1020 session->bssId);
1021 /*
1022 * Start IBSS group BSSID
1023 * Auto Generating BSSID.
1024 */
1025 auto_gen_bssid = ((mlm_start_req->bssId[0] &
1026 0x01) ? true : false);
1027 }
1028
1029 if (auto_gen_bssid) {
1030 /*
1031 * if BSSID is not any uc id.
1032 * then use locally generated BSSID.
1033 * Autogenerate the BSSID
1034 */
1035 lim_get_random_bssid(mac_ctx,
1036 mlm_start_req->bssId);
1037 mlm_start_req->bssId[0] = 0x02;
1038
1039 /*
1040 * Copy randomly generated BSSID
1041 * to the session Table
1042 */
1043 sir_copy_mac_addr(session->bssId,
1044 mlm_start_req->bssId);
1045 }
1046 }
1047 /* store the channel num in mlmstart req structure */
1048 mlm_start_req->channelNumber = session->currentOperChannel;
1049 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
1050 mlm_start_req->beaconPeriod =
1051 session->beaconParams.beaconInterval;
1052
1053 if (LIM_IS_AP_ROLE(session)) {
1054 mlm_start_req->dtimPeriod = session->dtimPeriod;
1055 mlm_start_req->wps_state = session->wps_state;
1056
1057 } else {
1058 if (wlan_cfg_get_int(mac_ctx,
1059 WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
1060 lim_log(mac_ctx, LOGP,
1061 FL("could not retrieve DTIM Period"));
1062 mlm_start_req->dtimPeriod = (uint8_t) val;
1063 }
1064
1065 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_PERIOD, &val) !=
1066 eSIR_SUCCESS)
1067 lim_log(mac_ctx, LOGP,
1068 FL("could not retrieve Beacon interval"));
1069 mlm_start_req->cfParamSet.cfpPeriod = (uint8_t) val;
1070
1071 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_MAX_DURATION, &val) !=
1072 eSIR_SUCCESS)
1073 lim_log(mac_ctx, LOGP,
1074 FL("could not retrieve CFPMaxDuration"));
1075 mlm_start_req->cfParamSet.cfpMaxDuration = (uint16_t) val;
1076
1077 /*
1078 * this may not be needed anymore now,
1079 * as rateSet is now included in the
1080 * session entry and MLM has session context.
1081 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301082 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001083 (void *)&session->rateSet,
1084 sizeof(tSirMacRateSet));
1085
1086 /* Now populate the 11n related parameters */
1087 mlm_start_req->nwType = session->nwType;
1088 mlm_start_req->htCapable = session->htCapability;
1089
1090 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1091 /* Unused */
1092 mlm_start_req->dualCTSProtection =
1093 mac_ctx->lim.gHTDualCTSProtection;
1094 mlm_start_req->txChannelWidthSet =
1095 session->htRecommendedTxWidthSet;
1096
1097 session->limRFBand = lim_get_rf_band(channel_number);
1098
1099 /* Initialize 11h Enable Flag */
1100 session->lim11hEnable = 0;
1101 if ((mlm_start_req->bssType != eSIR_IBSS_MODE) &&
1102 (SIR_BAND_5_GHZ == session->limRFBand)) {
1103 if (wlan_cfg_get_int(mac_ctx,
1104 WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
1105 lim_log(mac_ctx, LOGP,
1106 FL("Fail to get WNI_CFG_11H_ENABLED "));
1107 else
1108 session->lim11hEnable = val;
1109
1110 if (session->lim11hEnable &&
1111 (eSIR_INFRA_AP_MODE ==
1112 mlm_start_req->bssType)) {
1113 cfg_get_wmi_dfs_master_param =
1114 wlan_cfg_get_int(mac_ctx,
1115 WNI_CFG_DFS_MASTER_ENABLED,
1116 &val);
1117 session->lim11hEnable = val;
1118 }
1119 if (cfg_get_wmi_dfs_master_param != eSIR_SUCCESS)
1120 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
1121 lim_log(mac_ctx, LOGE,
1122 FL("Get Fail, CFG DFS ENABLE"));
1123 }
1124
1125 if (!session->lim11hEnable) {
1126 if (cfg_set_int(mac_ctx,
1127 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
1128 eSIR_SUCCESS)
1129 /*
1130 * Failed to set the CFG param
1131 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1132 */
1133 lim_log(mac_ctx, LOGE,
1134 FL("Set LOCAL_POWER_CONSTRAINT failed"));
1135 }
1136
1137 session->limPrevSmeState = session->limSmeState;
1138 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1139 MTRACE(mac_trace
1140 (mac_ctx, TRACE_CODE_SME_STATE,
1141 session->peSessionId,
1142 session->limSmeState));
1143
1144 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1145 (uint32_t *) mlm_start_req);
1146 return;
1147 } else {
1148
1149 lim_log(mac_ctx, LOGE,
1150 FL("Received unexpected START_BSS_REQ, in state %X"),
1151 mac_ctx->lim.gLimSmeState);
1152 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
1153 goto end;
1154 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1155
1156free:
1157 if ((session != NULL) &&
1158 (session->pLimStartBssReq == sme_start_bss_req)) {
1159 session->pLimStartBssReq = NULL;
1160 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301161 qdf_mem_free(sme_start_bss_req);
1162 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001163
1164end:
1165 if (sme_start_bss_req != NULL) {
1166 sme_session_id = sme_start_bss_req->sessionId;
1167 sme_transaction_id = sme_start_bss_req->transactionId;
1168 }
1169 if (NULL != session) {
1170 pe_delete_session(mac_ctx, session);
1171 session = NULL;
1172 }
1173 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1174 session, sme_session_id, sme_transaction_id);
1175}
1176
1177/**
1178 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1179 *
1180 * @pMac: Global MAC context
1181 * @pMsg: Message pointer
1182 *
1183 * Wrapper for the function __lim_handle_sme_start_bss_request
1184 * This message will be defered until softmac come out of
1185 * scan mode or if we have detected radar on the current
1186 * operating channel.
1187 *
1188 * return true - If we consumed the buffer
1189 * false - If have defered the message.
1190 */
1191static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1192{
1193 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1194 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1195 /**
1196 * If message defered, buffer is not consumed yet.
1197 * So return false
1198 */
1199 return false;
1200 }
1201
1202 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1203 return true;
1204}
1205
1206/**
1207 * lim_get_random_bssid()
1208 *
1209 * FUNCTION:This function is called to process generate the random number for bssid
1210 * This function is called to process SME_SCAN_REQ message
1211 * from HDD or upper layer application.
1212 *
1213 * LOGIC:
1214 *
1215 * ASSUMPTIONS:
1216 *
1217 * NOTE:
1218 * 1. geneartes the unique random number for bssid in ibss
1219 *
1220 * @param pMac Pointer to Global MAC structure
1221 * @param *data Pointer to bssid buffer
1222 * @return None
1223 */
1224void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1225{
1226 uint32_t random[2];
1227 random[0] = tx_time_get();
1228 random[0] |= (random[0] << 15);
1229 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301230 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001231}
1232
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301233static QDF_STATUS lim_send_hal_start_scan_offload_req(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001234 tpSirSmeScanReq pScanReq)
1235{
1236 tSirScanOffloadReq *pScanOffloadReq;
1237 uint8_t *p;
1238 uint8_t *ht_cap_ie;
1239 tSirMsgQ msg;
1240 uint16_t i, len;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001241 uint16_t ht_cap_len = 0;
1242 uint16_t addn_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001243 uint8_t *vht_cap_ie;
1244 uint16_t vht_cap_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001245 tSirRetStatus status, rc = eSIR_SUCCESS;
1246 tDot11fIEExtCap extracted_extcap = {0};
1247 bool extcap_present = true;
1248
1249 if (pScanReq->uIEFieldLen) {
1250 status = lim_strip_extcap_update_struct(pMac,
1251 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1252 &pScanReq->uIEFieldLen, &extracted_extcap);
1253
1254 if (eSIR_SUCCESS != status) {
1255 extcap_present = false;
1256 lim_log(pMac, LOG1,
1257 FL("Unable to Strip ExtCap IE from Scan Req"));
1258 }
1259
1260 if (extcap_present) {
1261 lim_log(pMac, LOG1,
1262 FL("Extcap was part of SCAN IE - Updating FW"));
1263 lim_send_ext_cap_ie(pMac, pScanReq->sessionId,
1264 &extracted_extcap, true);
1265 }
1266 } else {
1267 lim_log(pMac, LOG1,
1268 FL("No IEs in the scan request from supplicant"));
1269 }
1270
1271 /**
1272 * The tSirScanOffloadReq will reserve the space for first channel,
1273 * so allocate the memory for (numChannels - 1) and uIEFieldLen
1274 */
1275 len = sizeof(tSirScanOffloadReq) +
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001276 (pScanReq->channelList.numChannels - 1) +
1277 pScanReq->uIEFieldLen;
1278 if (!pMac->per_band_chainmask_supp) {
1279 if (IS_DOT11_MODE_HT(pScanReq->dot11mode)) {
1280 lim_log(pMac, LOG1, FL(
1281 "Adding HT Caps IE since dot11mode=%d"),
1282 pScanReq->dot11mode);
1283 /* 2 bytes for EID and Length */
1284 ht_cap_len = 2 + sizeof(tHtCaps);
1285 len += ht_cap_len;
1286 addn_ie_len += ht_cap_len;
1287 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001288
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001289 if (IS_DOT11_MODE_VHT(pScanReq->dot11mode)) {
1290 lim_log(pMac, LOG1, FL(
1291 "Adding VHT Caps IE since dot11mode=%d"),
1292 pScanReq->dot11mode);
1293 /* 2 bytes for EID and Length */
1294 vht_cap_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
1295 sizeof(tSirVhtMcsInfo);
1296 len += vht_cap_len;
1297 addn_ie_len += vht_cap_len;
1298 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001299 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301300 pScanOffloadReq = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001301 if (NULL == pScanOffloadReq) {
1302 lim_log(pMac, LOGE,
1303 FL("AllocateMemory failed for pScanOffloadReq"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301304 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001305 }
1306
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301307 qdf_mem_set((uint8_t *) pScanOffloadReq, len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001308
1309 msg.type = WMA_START_SCAN_OFFLOAD_REQ;
1310 msg.bodyptr = pScanOffloadReq;
1311 msg.bodyval = 0;
1312
Anurag Chouhanc5548422016-02-24 18:33:27 +05301313 qdf_copy_macaddr(&pScanOffloadReq->bssId, &pScanReq->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001314
1315 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID) {
1316 lim_log(pMac, LOGE,
1317 FL("Invalid value (%d) for numSsid"),
1318 SIR_SCAN_MAX_NUM_SSID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301319 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301320 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001321 }
1322
1323 pScanOffloadReq->numSsid = pScanReq->numSsid;
1324 for (i = 0; i < pScanOffloadReq->numSsid; i++) {
1325 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301326 qdf_mem_copy((uint8_t *) pScanOffloadReq->ssId[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001327 (uint8_t *) pScanReq->ssId[i].ssId,
1328 pScanOffloadReq->ssId[i].length);
1329 }
1330
1331 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301332 qdf_copy_macaddr(&pScanOffloadReq->selfMacAddr, &pScanReq->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001333 pScanOffloadReq->bssType = pScanReq->bssType;
1334 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1335 pScanOffloadReq->scanType = pScanReq->scanType;
1336 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1337 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1338 pScanOffloadReq->restTime = pScanReq->restTime;
Agrawal Ashish17bb3902016-05-05 13:29:40 +05301339 pScanOffloadReq->min_rest_time = pScanReq->min_rest_time;
1340 pScanOffloadReq->idle_time = pScanReq->idle_time;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301341 pScanOffloadReq->scan_adaptive_dwell_mode =
1342 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001343
1344 /* for normal scan, the value for p2pScanType should be 0
1345 always */
1346 if (pScanReq->p2pSearch)
1347 pScanOffloadReq->p2pScanType = P2P_SCAN_TYPE_SEARCH;
1348
1349 pScanOffloadReq->sessionId = pScanReq->sessionId;
1350 pScanOffloadReq->scan_id = pScanReq->scan_id;
Deepak Dhamdhered97bfb32015-10-11 15:16:18 -07001351 pScanOffloadReq->scan_requestor_id = USER_SCAN_REQUESTOR_ID;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301352 pScanOffloadReq->scan_adaptive_dwell_mode =
1353 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001354
1355 if (pScanOffloadReq->sessionId >= pMac->lim.maxBssId)
1356 lim_log(pMac, LOGE, FL("Invalid pe sessionID : %d"),
1357 pScanOffloadReq->sessionId);
1358
1359 pScanOffloadReq->channelList.numChannels =
1360 pScanReq->channelList.numChannels;
1361 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1362 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1363 p[i] = pScanReq->channelList.channelNumber[i];
1364
1365 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1366 pScanOffloadReq->uIEFieldOffset = len - addn_ie_len -
1367 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301368 qdf_mem_copy((uint8_t *) pScanOffloadReq +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001369 pScanOffloadReq->uIEFieldOffset,
1370 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1371 pScanReq->uIEFieldLen);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001372 if (!pMac->per_band_chainmask_supp) {
1373 /* Copy HT Capability info if dot11mode is HT */
1374 if (IS_DOT11_MODE_HT(pScanReq->dot11mode)) {
1375 /* Populate EID and Length field here */
1376 ht_cap_ie = (uint8_t *) pScanOffloadReq +
1377 pScanOffloadReq->uIEFieldOffset +
1378 pScanOffloadReq->uIEFieldLen;
1379 qdf_mem_set(ht_cap_ie, ht_cap_len, 0);
1380 *ht_cap_ie = SIR_MAC_HT_CAPABILITIES_EID;
1381 *(ht_cap_ie + 1) = ht_cap_len - 2;
1382 lim_set_ht_caps(pMac, NULL, ht_cap_ie, ht_cap_len);
1383 pScanOffloadReq->uIEFieldLen += ht_cap_len;
1384 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001385
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001386 /* Copy VHT Capability info if dot11mode is VHT Capable */
1387 if (IS_DOT11_MODE_VHT(pScanReq->dot11mode)) {
1388 /* Populate EID and Length field here */
1389 vht_cap_ie = (uint8_t *) pScanOffloadReq +
1390 pScanOffloadReq->uIEFieldOffset +
1391 pScanOffloadReq->uIEFieldLen;
1392 qdf_mem_set(vht_cap_ie, vht_cap_len, 0);
1393 *vht_cap_ie = SIR_MAC_VHT_CAPABILITIES_EID;
1394 *(vht_cap_ie + 1) = vht_cap_len - 2;
1395 lim_set_vht_caps(pMac, NULL, vht_cap_ie, vht_cap_len);
1396 pScanOffloadReq->uIEFieldLen += vht_cap_len;
1397 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001398 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001399 rc = wma_post_ctrl_msg(pMac, &msg);
1400 if (rc != eSIR_SUCCESS) {
1401 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() return failure"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301402 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301403 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001404 }
1405
1406 lim_log(pMac, LOG1, FL("Processed Offload Scan Request Successfully"));
1407
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301408 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001409}
1410
1411/**
1412 * __lim_process_sme_scan_req() - Process the SME Scan Request
1413 * @mac_ctx: Global MAC Context
1414 * @msg_buf: Buffer which contains the request and pertinent parameters
1415 *
1416 * This function is called to process SME_SCAN_REQ message
1417 * from HDD or upper layer application.
1418 *
1419 * Return: None
1420 */
1421
1422static void __lim_process_sme_scan_req(tpAniSirGlobal mac_ctx,
1423 uint32_t *msg_buf)
1424{
1425 tpSirSmeScanReq scan_req;
1426 uint8_t valid_req = 0;
1427
1428#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1429 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL,
1430 eSIR_SUCCESS, eSIR_SUCCESS);
1431#endif
1432
1433 scan_req = (tpSirSmeScanReq) msg_buf;
1434 lim_log(mac_ctx, LOG1,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301435 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 -08001436 scan_req->scan_id, scan_req->channelList.numChannels,
1437 scan_req->minChannelTime, scan_req->maxChannelTime,
1438 scan_req->uIEFieldLen, scan_req->returnAfterFirstMatch,
1439 scan_req->returnFreshResults, scan_req->returnUniqueResults,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301440 lim_scan_type_to_string(scan_req->scanType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001441 scan_req->scanType, mac_ctx->lim.gLimRspReqd ? 1 : 0);
1442 /*
1443 * Since scan req always requires a response, we will overwrite response
1444 * required here. This is added esp to take care of the condition where
1445 * in p2p go case, we hold the scan req and insert single NOA. We send
1446 * the held scan request to FW later on getting start NOA ind from FW so
1447 * we lose state of the gLimRspReqd flag for the scan req if any other
1448 * request comes by then. e.g. While unit testing, we found when insert
1449 * single NOA is done, we see a get stats request which turns the flag
1450 * gLimRspReqd to false; now when we actually start the saved scan req
1451 * for init scan after getting NOA started, the gLimRspReqd being a
1452 * global flag is showing false instead of true value for this saved
1453 * scan req. Since all scan reqs coming to lim require a response,
1454 * there is no harm in setting the global flag gLimRspReqd to true here.
1455 */
1456 mac_ctx->lim.gLimRspReqd = true;
1457
1458 /*
1459 * copy the Self MAC address from SmeReq to the globalplace,
1460 * used for sending probe req
1461 */
Srinivas Girigowda2c6bf002015-09-24 11:43:31 -07001462 sir_copy_mac_addr(mac_ctx->lim.gSelfMacAddr,
1463 scan_req->selfMacAddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001464 valid_req = lim_is_sme_scan_req_valid(mac_ctx, scan_req);
1465
1466 if (!valid_req || mac_ctx->lim.scan_disabled) {
1467 lim_log(mac_ctx, LOGE,
1468 FL("Scan disabled %d, Valid Scan Req %d"),
1469 mac_ctx->lim.scan_disabled, valid_req);
1470
1471 if (mac_ctx->lim.gLimRspReqd) {
1472 mac_ctx->lim.gLimRspReqd = false;
1473
1474 lim_send_sme_scan_rsp(mac_ctx,
1475 eSIR_SME_INVALID_PARAMETERS,
1476 scan_req->sessionId,
1477 scan_req->transactionId,
1478 scan_req->scan_id);
1479 }
1480 return;
1481 }
1482
1483 /*
1484 * If scan request is received in idle, joinFailed
1485 * states or in link established state (in STA role)
1486 * or in normal state (in STA-in-IBSS/AP role) with
1487 * 'return fresh scan results' request from HDD or
1488 * it is periodic background scanning request,
1489 * trigger fresh scan request to MLM
1490 */
1491 if (__lim_fresh_scan_reqd(mac_ctx, scan_req->returnFreshResults)) {
1492
1493 mac_ctx->lim.gLim24Band11dScanDone = 0;
1494 mac_ctx->lim.gLim50Band11dScanDone = 0;
1495 mac_ctx->lim.gLimReturnAfterFirstMatch =
1496 scan_req->returnAfterFirstMatch;
1497 mac_ctx->lim.gLimReturnUniqueResults =
1498 ((scan_req->returnUniqueResults) > 0 ? true : false);
1499
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301500 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001501 lim_send_hal_start_scan_offload_req(mac_ctx,
1502 scan_req)) {
1503 lim_log(mac_ctx, LOGE, FL(
1504 "Couldn't send Offload scan request"));
1505 lim_send_sme_scan_rsp(mac_ctx,
1506 eSIR_SME_INVALID_PARAMETERS,
1507 scan_req->sessionId,
1508 scan_req->transactionId,
1509 scan_req->scan_id);
1510 return;
1511 }
Anurag Chouhanffb21542016-02-17 14:33:03 +05301512 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001513 /* In all other cases return 'cached' scan results */
1514 if (mac_ctx->lim.gLimRspReqd) {
1515 mac_ctx->lim.gLimRspReqd = false;
1516 lim_send_sme_scan_rsp(mac_ctx, eSIR_SME_SUCCESS,
1517 scan_req->sessionId,
1518 scan_req->transactionId, scan_req->scan_id);
1519 }
1520 }
1521}
1522
1523#ifdef FEATURE_OEM_DATA_SUPPORT
1524
1525static void __lim_process_sme_oem_data_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
1526{
1527 tpSirOemDataReq pOemDataReq;
1528 tLimMlmOemDataReq *pMlmOemDataReq;
1529
1530 pOemDataReq = (tpSirOemDataReq) pMsgBuf;
1531
1532 /* post the lim mlm message now */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301533 pMlmOemDataReq = qdf_mem_malloc(sizeof(*pMlmOemDataReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001534 if (NULL == pMlmOemDataReq) {
1535 lim_log(pMac, LOGP,
1536 FL("AllocateMemory failed for mlmOemDataReq"));
1537 return;
1538 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301539 pMlmOemDataReq->data = qdf_mem_malloc(pOemDataReq->data_len);
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08001540 if (!pMlmOemDataReq->data) {
1541 lim_log(pMac, LOGP, FL("memory allocation failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301542 qdf_mem_free(pMlmOemDataReq);
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08001543 return;
1544 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001545
Anurag Chouhanc5548422016-02-24 18:33:27 +05301546 qdf_copy_macaddr(&pMlmOemDataReq->selfMacAddr,
Srinivas Girigowda0ee66862015-09-24 14:03:29 -07001547 &pOemDataReq->selfMacAddr);
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08001548 pMlmOemDataReq->data_len = pOemDataReq->data_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301549 qdf_mem_copy(pMlmOemDataReq->data, pOemDataReq->data,
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08001550 pOemDataReq->data_len);
Naveen Rawat504adce2016-01-19 17:26:00 -08001551 /* buffer from SME copied, free it now */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301552 qdf_mem_free(pOemDataReq->data);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001553 /* Issue LIM_MLM_OEM_DATA_REQ to MLM */
1554 lim_post_mlm_message(pMac, LIM_MLM_OEM_DATA_REQ,
1555 (uint32_t *) pMlmOemDataReq);
1556
1557 return;
1558
1559} /*** end __lim_process_sme_oem_data_req() ***/
1560
1561#endif /* FEATURE_OEM_DATA_SUPPORT */
1562
1563/**
1564 * __lim_process_clear_dfs_channel_list()
1565 *
1566 ***FUNCTION:
1567 ***Clear DFS channel list when country is changed/aquired.
1568 .*This message is sent from SME.
1569 *
1570 ***LOGIC:
1571 *
1572 ***ASSUMPTIONS:
1573 *
1574 ***NOTE:
1575 *
1576 * @param pMac Pointer to Global MAC structure
1577 * @param *pMsgBuf A pointer to the SME message buffer
1578 * @return None
1579 */
1580static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1581{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301582 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001583}
1584
1585/**
1586 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1587 * @mac_ctx: Pointer to Global MAC structure
1588 * @msg_buf: A pointer to the SME message buffer
1589 *
1590 * This function is called to process SME_JOIN_REQ message
1591 * from HDD or upper layer application.
1592 *
1593 * Return: None
1594 */
1595static void
1596__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1597{
1598 tpSirSmeJoinReq sme_join_req = NULL;
1599 tLimMlmJoinReq *mlm_join_req;
1600 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1601 uint32_t val = 0;
1602 uint16_t n_size;
1603 uint8_t session_id;
1604 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301605 uint8_t sme_session_id = 0;
1606 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001607 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001608 uint16_t ie_len;
1609 uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001610 tSirBssDescription *bss_desc;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001611 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001612
Arif Hussain995fcaf2016-07-18 11:28:22 -07001613 if (!mac_ctx || !msg_buf) {
1614 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1615 FL("JOIN REQ with invalid data"));
1616 return;
1617 }
1618
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001619/* FEATURE_WLAN_DIAG_SUPPORT */
1620#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1621 /*
1622 * Not sending any session, since it is not created yet.
1623 * The response whould have correct state.
1624 */
1625 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1626#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1627
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001628 /*
1629 * Expect Join request in idle state.
1630 * Reassociate request is expected in link established state.
1631 */
1632
1633 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1634 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1635 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1636 msg_buf);
1637
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301638 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001639 if (NULL == sme_join_req) {
1640 lim_log(mac_ctx, LOGP,
1641 FL("AllocateMemory failed for sme_join_req"));
1642 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301643 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001644 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301645 (void)qdf_mem_set((void *)sme_join_req, n_size, 0);
1646 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001647 n_size);
1648
1649 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1650 /* Received invalid eWNI_SME_JOIN_REQ */
1651 /* Log the event */
1652 lim_log(mac_ctx, LOGW,
1653 FL("SessionId:%d JOIN REQ with invalid data"),
1654 sme_join_req->sessionId);
1655 ret_code = eSIR_SME_INVALID_PARAMETERS;
1656 goto end;
1657 }
1658
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001659 /*
1660 * Update the capability here itself as this is used in
1661 * lim_extract_ap_capability() below. If not updated issues
1662 * like not honoring power constraint on 1st association after
1663 * driver loading might occur.
1664 */
1665 lim_update_rrm_capability(mac_ctx, sme_join_req);
1666
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001667 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001668 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001669 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001670 &session_id);
1671
1672 if (session != NULL) {
1673 lim_log(mac_ctx, LOGE,
1674 FL("Session(%d) Already exists for BSSID: "
1675 MAC_ADDRESS_STR " in limSmeState = %X"),
1676 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001677 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001678 session->limSmeState);
1679
1680 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1681 session->smeSessionId == sme_join_req->sessionId) {
1682 /*
1683 * Received eWNI_SME_JOIN_REQ for same
1684 * BSS as currently associated.
1685 * Log the event and send success
1686 */
1687 lim_log(mac_ctx, LOGW,
1688 FL("SessionId: %d"), session_id);
1689 lim_log(mac_ctx, LOGW,
1690 FL("JOIN_REQ for current joined BSS"));
1691 /* Send Join success response to host */
1692 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1693 session = NULL;
1694 goto end;
1695 } else {
1696 lim_log(mac_ctx, LOGE,
1697 FL("JOIN_REQ not for current joined BSS"));
1698 ret_code = eSIR_SME_REFUSED;
1699 session = NULL;
1700 goto end;
1701 }
1702 } else {
1703 /*
1704 * Session Entry does not exist for given BSSId
1705 * Try to Create a new session
1706 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001707 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001708 &session_id, mac_ctx->lim.maxStation,
1709 eSIR_INFRASTRUCTURE_MODE);
1710 if (session == NULL) {
1711 lim_log(mac_ctx, LOGE,
1712 FL("Session Can not be created "));
1713 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1714 goto end;
1715 } else
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301716 lim_log(mac_ctx, LOG2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001717 FL("SessionId:%d New session created"),
1718 session_id);
1719 }
1720 session->isAmsduSupportInAMPDU =
1721 sme_join_req->isAmsduSupportInAMPDU;
1722
1723 /*
1724 * Store Session related parameters
1725 * Store PE session Id in session Table
1726 */
1727 session->peSessionId = session_id;
1728
1729 /* store the smejoin req handle in session table */
1730 session->pLimJoinReq = sme_join_req;
1731
1732 /* Store SME session Id in sessionTable */
1733 session->smeSessionId = sme_join_req->sessionId;
1734
1735 /* Store SME transaction Id in session Table */
1736 session->transactionId = sme_join_req->transactionId;
1737
1738 /* Store beaconInterval */
1739 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001740 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001741
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301742 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001743 sizeof(session->htConfig));
1744
1745 /* Copying of bssId is already done, while creating session */
1746 sir_copy_mac_addr(session->selfMacAddr,
1747 sme_join_req->selfMacAddr);
1748 session->bssType = sme_join_req->bsstype;
1749
1750 session->statypeForBss = STA_ENTRY_PEER;
1751 session->limWmeEnabled = sme_join_req->isWMEenabled;
1752 session->limQosEnabled = sme_join_req->isQosEnabled;
1753
1754 /* Store vendor specfic IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001755 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001756 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1757
1758 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
1759 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001760 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001761
1762 if (NULL != vendor_ie) {
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08001763 lim_log(mac_ctx, LOG1, FL("Cisco vendor OUI present"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001764 session->isCiscoVendorAP = true;
1765 } else {
1766 session->isCiscoVendorAP = false;
1767 }
1768
1769 /* Copy the dot 11 mode in to the session table */
1770
1771 session->dot11mode = sme_join_req->dot11mode;
1772#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1773 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1774#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001775 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001776 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1777 session->enableHtSmps = sme_join_req->enableHtSmps;
1778 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001779 session->send_smps_action =
1780 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001781 /*
1782 * By default supported NSS 1x1 is set to true
1783 * and later on updated while determining session
1784 * supported rates which is the intersection of
1785 * self and peer rates
1786 */
1787 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301788 /*Store Persona */
1789 session->pePersona = sme_join_req->staPersona;
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001790 lim_log(mac_ctx, LOG1,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301791 FL("enable Smps: %d mode: %d send action: %d supported nss 1x1: %d pePersona %d cbMode %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001792 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001793 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001794 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301795 session->supported_nss_1x1,
1796 session->pePersona,
1797 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001798
1799 /*Store Persona */
1800 session->pePersona = sme_join_req->staPersona;
1801 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
1802 FL("PE PERSONA=%d cbMode %u"),
1803 session->pePersona, sme_join_req->cbMode);
1804 /* Copy The channel Id to the session Table */
1805 session->currentOperChannel = bss_desc->channelId;
1806 if (IS_5G_CH(session->currentOperChannel))
1807 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001808 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001809 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
1810 if (session->pePersona == QDF_P2P_CLIENT_MODE)
1811 session->vdev_nss = vdev_type_nss->p2p_cli;
1812 else
1813 session->vdev_nss = vdev_type_nss->sta;
1814 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001815 session->vhtCapability =
1816 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001817 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301818 if (session->pePersona == QDF_STA_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001819 session->txBFIniFeatureEnabled =
1820 sme_join_req->txBFIniFeatureEnabled;
1821 } else {
1822 session->txBFIniFeatureEnabled = 0;
1823 }
1824 session->txMuBformee = sme_join_req->txMuBformee;
1825 session->enableVhtpAid =
1826 sme_join_req->enableVhtpAid;
1827 session->enableVhtGid =
1828 sme_join_req->enableVhtGid;
1829
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001830 if (wlan_cfg_get_int(mac_ctx,
1831 WNI_CFG_VHT_SU_BEAMFORMER_CAP, &val) !=
1832 eSIR_SUCCESS)
1833 lim_log(mac_ctx, LOGE, FL(
1834 "cfg get vht su bformer failed"));
1835
1836 session->enable_su_tx_bformer = val;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001837 }
1838 if (session->vhtCapability && session->txBFIniFeatureEnabled) {
1839 if (cfg_set_int(mac_ctx, WNI_CFG_VHT_SU_BEAMFORMEE_CAP,
1840 session->txBFIniFeatureEnabled) !=
1841 eSIR_SUCCESS) {
1842 /*
1843 * Set failed for
1844 * CFG_VHT_SU_BEAMFORMEE_CAP
1845 */
1846 lim_log(mac_ctx, LOGP,
1847 FL("Failed CFG_VHT_SU_BEAMFORMEE_CAP"));
1848 ret_code = eSIR_LOGP_EXCEPTION;
1849 goto end;
1850 }
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -08001851 session->txbf_csn_value = sme_join_req->txBFCsnValue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001852 }
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301853 lim_log(mac_ctx, LOG1,
1854 FL("vhtCapability: %d txBFIniFeatureEnabled: %d txbf_csn_value: %d su_tx_bformer %d"),
1855 session->vhtCapability,
1856 session->txBFIniFeatureEnabled,
1857 session->txbf_csn_value,
1858 session->enable_su_tx_bformer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001859 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001860 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001861 handle_ht_capabilityand_ht_info(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001862 /* cbMode is already merged value of peer and self -
1863 * done by csr in csr_get_cb_mode_from_ies */
1864 session->htSupportedChannelWidthSet =
1865 (sme_join_req->cbMode) ? 1 : 0;
1866 session->htRecommendedTxWidthSet =
1867 session->htSupportedChannelWidthSet;
1868 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1869
1870 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1871 session->ch_center_freq_seg0 =
1872 session->currentOperChannel - 2;
1873 session->ch_width = CH_WIDTH_40MHZ;
1874 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1875 sme_join_req->cbMode) {
1876 session->ch_center_freq_seg0 =
1877 session->currentOperChannel + 2;
1878 session->ch_width = CH_WIDTH_40MHZ;
1879 } else {
1880 session->ch_center_freq_seg0 = 0;
1881 session->ch_width = CH_WIDTH_20MHZ;
1882 }
1883
1884 /* Record if management frames need to be protected */
1885#ifdef WLAN_FEATURE_11W
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001886 if (eSIR_ED_AES_128_CMAC == sme_join_req->MgmtEncryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001887 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001888 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001889 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001890#endif
1891
1892#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001893 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001894#endif
1895
1896 /* Copy the SSID from smejoinreq to session entry */
1897 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301898 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001899 session->ssId.length);
1900
1901 /*
1902 * Determin 11r or ESE connection based on input from SME
1903 * which inturn is dependent on the profile the user wants
1904 * to connect to, So input is coming from supplicant
1905 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001906 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001907#ifdef FEATURE_WLAN_ESE
1908 session->isESEconnection = sme_join_req->isESEconnection;
1909#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001910 session->isFastTransitionEnabled =
1911 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001912
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001913 session->isFastRoamIniFeatureEnabled =
1914 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001915 session->txLdpcIniFeatureEnabled =
1916 sme_join_req->txLdpcIniFeatureEnabled;
1917
1918 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1919 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001920 } else {
1921 /*
1922 * Throw an error and return and make
1923 * sure to delete the session.
1924 */
1925 lim_log(mac_ctx, LOGE,
1926 FL("recvd JOIN_REQ with invalid bss type %d"),
1927 session->bssType);
1928 ret_code = eSIR_SME_INVALID_PARAMETERS;
1929 goto end;
1930 }
1931
1932 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301933 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001934 &sme_join_req->addIEScan, sizeof(tSirAddie));
1935
1936 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301937 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001938 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1939
1940 val = sizeof(tLimMlmJoinReq) +
1941 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301942 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001943 if (NULL == mlm_join_req) {
1944 lim_log(mac_ctx, LOGP,
1945 FL("AllocateMemory failed for mlmJoinReq"));
Nitesh Shah0102cac2016-07-13 14:38:30 +05301946 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1947 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001948 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301949 (void)qdf_mem_set((void *)mlm_join_req, val, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001950
1951 /* PE SessionId is stored as a part of JoinReq */
1952 mlm_join_req->sessionId = session->peSessionId;
1953
1954 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1955 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1956 eSIR_SUCCESS) {
1957 lim_log(mac_ctx, LOGP,
1958 FL("couldn't retrieve JoinFailureTimer value"
1959 " setting to default value"));
1960 mlm_join_req->joinFailureTimeout =
1961 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1962 }
1963
1964 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301965 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001966 (void *)&sme_join_req->operationalRateSet,
1967 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301968 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001969 (void *)&sme_join_req->extendedRateSet,
1970 sizeof(tSirMacRateSet));
1971 /*
1972 * this may not be needed anymore now, as rateSet is now
1973 * included in the session entry and MLM has session context.
1974 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301975 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001976 (void *)&session->rateSet,
1977 sizeof(tSirMacRateSet));
1978
1979 session->encryptType = sme_join_req->UCEncryptionType;
1980
1981 mlm_join_req->bssDescription.length =
1982 session->pLimJoinReq->bssDescription.length;
1983
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301984 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001985 (uint8_t *)
1986 &session->pLimJoinReq->bssDescription.bssId,
1987 session->pLimJoinReq->bssDescription.length + 2);
1988
1989 session->limCurrentBssCaps =
1990 session->pLimJoinReq->bssDescription.capabilityInfo;
1991
1992 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1993 session->currentOperChannel);
1994 local_power_constraint = reg_max;
1995
1996 lim_extract_ap_capability(mac_ctx,
1997 (uint8_t *)
1998 session->pLimJoinReq->bssDescription.ieFields,
1999 lim_get_ielen_from_bss_description(
2000 &session->pLimJoinReq->bssDescription),
2001 &session->limCurrentBssQosCaps,
2002 &session->limCurrentBssPropCap,
2003 &session->gLimCurrentBssUapsd,
2004 &local_power_constraint, session);
2005
2006#ifdef FEATURE_WLAN_ESE
2007 session->maxTxPower = lim_get_max_tx_power(reg_max,
2008 local_power_constraint,
2009 mac_ctx->roam.configParam.nTxPowerCap);
2010#else
2011 session->maxTxPower =
Anurag Chouhan6d760662016-02-20 16:05:43 +05302012 QDF_MIN(reg_max, (local_power_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002013#endif
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302014 lim_log(mac_ctx, LOG1,
2015 FL("Reg max = %d, local power con = %d, max tx = %d"),
2016 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002017
2018 if (session->gLimCurrentBssUapsd) {
2019 session->gUapsdPerAcBitmask =
2020 session->pLimJoinReq->uapsdPerAcBitmask;
2021 lim_log(mac_ctx, LOG1,
2022 FL("UAPSD flag for all AC - 0x%2x"),
2023 session->gUapsdPerAcBitmask);
2024
2025 /* resetting the dynamic uapsd mask */
2026 session->gUapsdPerAcDeliveryEnableMask = 0;
2027 session->gUapsdPerAcTriggerEnableMask = 0;
2028 }
2029
2030 session->limRFBand =
2031 lim_get_rf_band(session->currentOperChannel);
2032
2033 /* Initialize 11h Enable Flag */
2034 if (SIR_BAND_5_GHZ == session->limRFBand) {
2035 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
2036 &val) != eSIR_SUCCESS) {
2037 lim_log(mac_ctx, LOGP,
2038 FL("Fail to get WNI_CFG_11H_ENABLED "));
2039 session->lim11hEnable =
2040 WNI_CFG_11H_ENABLED_STADEF;
2041 } else {
2042 session->lim11hEnable = val;
2043 }
2044 } else {
2045 session->lim11hEnable = 0;
2046 }
2047
2048 /*
2049 * To care of the scenario when STA transitions from
2050 * IBSS to Infrastructure mode.
2051 */
2052 mac_ctx->lim.gLimIbssCoalescingHappened = false;
2053
2054 session->limPrevSmeState = session->limSmeState;
2055 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
2056 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2057 session->peSessionId,
2058 session->limSmeState));
2059
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002060 /* Indicate whether spectrum management is enabled */
2061 session->spectrumMgtEnabled =
2062 sme_join_req->spectrumMgtIndicator;
2063
2064 /* Enable the spectrum management if this is a DFS channel */
2065 if (session->country_info_present &&
2066 lim_isconnected_on_dfs_channel(
2067 session->currentOperChannel))
2068 session->spectrumMgtEnabled = true;
2069
2070 session->isOSENConnection = sme_join_req->isOSENConnection;
2071
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002072 /* Issue LIM_MLM_JOIN_REQ to MLM */
2073 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
2074 (uint32_t *) mlm_join_req);
2075 return;
2076
2077 } else {
2078 /* Received eWNI_SME_JOIN_REQ un expected state */
2079 lim_log(mac_ctx, LOGE,
2080 FL("received unexpected SME_JOIN_REQ in state %X"),
2081 mac_ctx->lim.gLimSmeState);
2082 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
2083 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2084 session = NULL;
2085 goto end;
2086 }
2087
2088end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05302089 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2090 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002091
2092 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302093 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002094 sme_join_req = NULL;
2095 if (NULL != session)
2096 session->pLimJoinReq = NULL;
2097 }
2098 if (ret_code != eSIR_SME_SUCCESS) {
2099 if (NULL != session) {
2100 pe_delete_session(mac_ctx, session);
2101 session = NULL;
2102 }
2103 }
2104 lim_log(mac_ctx, LOG1,
2105 FL("Send failure status on sessionid: %d with ret_code = %d"),
2106 sme_session_id, ret_code);
2107 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
2108 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
2109 sme_transaction_id);
2110}
2111
Amar Singhala297bfa2015-10-15 15:07:29 -07002112uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002113 uint8_t iniTxPower)
2114{
2115 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302116 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
2117 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002118 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2119 maxTxPower = txPower;
2120 else if (txPower < MIN_TX_PWR_CAP)
2121 maxTxPower = MIN_TX_PWR_CAP;
2122 else
2123 maxTxPower = MAX_TX_PWR_CAP;
2124
2125 return maxTxPower;
2126}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002127
2128/**
2129 * __lim_process_sme_reassoc_req() - process reassoc req
2130 *
2131 * @mac_ctx: Pointer to Global MAC structure
2132 * @msg_buf: pointer to the SME message buffer
2133 *
2134 * This function is called to process SME_REASSOC_REQ message
2135 * from HDD or upper layer application.
2136 *
2137 * Return: None
2138 */
2139
2140static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2141 uint32_t *msg_buf)
2142{
2143 uint16_t caps;
2144 uint32_t val;
2145 tpSirSmeJoinReq reassoc_req = NULL;
2146 tLimMlmReassocReq *mlm_reassoc_req;
2147 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2148 tpPESession session_entry = NULL;
2149 uint8_t session_id;
2150 uint8_t sme_session_id;
2151 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002152 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002153 uint32_t tele_bcn_en = 0;
2154 uint16_t size;
2155
2156 lim_log(mac_ctx, LOG3, FL("Received REASSOC_REQ"));
2157
2158 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302159 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002160 if (NULL == reassoc_req) {
2161 lim_log(mac_ctx, LOGP,
2162 FL("call to AllocateMemory failed for reassoc_req"));
2163
2164 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2165 goto end;
2166 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302167 (void)qdf_mem_set((void *)reassoc_req, size, 0);
2168 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002169
2170 if (!lim_is_sme_join_req_valid(mac_ctx,
2171 (tpSirSmeJoinReq)reassoc_req)) {
2172 /*
2173 * Received invalid eWNI_SME_REASSOC_REQ
2174 */
2175 lim_log(mac_ctx, LOGW,
2176 FL("received SME_REASSOC_REQ with invalid data"));
2177
2178 ret_code = eSIR_SME_INVALID_PARAMETERS;
2179 goto end;
2180 }
2181
2182 session_entry = pe_find_session_by_bssid(mac_ctx,
2183 reassoc_req->bssDescription.bssId,
2184 &session_id);
2185 if (session_entry == NULL) {
2186 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2187 LOGE);
2188 lim_log(mac_ctx, LOGE,
2189 FL("Session does not exist for given bssId"));
2190 ret_code = eSIR_SME_INVALID_PARAMETERS;
2191 goto end;
2192 }
2193#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2194 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2195 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2196#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2197 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2198
2199 /* Store the reassoc handle in the session Table */
2200 session_entry->pLimReAssocReq = reassoc_req;
2201
2202 session_entry->dot11mode = reassoc_req->dot11mode;
2203 session_entry->vhtCapability =
2204 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002205
2206 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2207 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002208 session_entry->send_smps_action =
2209 reassoc_req->send_smps_action;
2210 lim_log(mac_ctx, LOG1,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002211 FL("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002212 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002213 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002214 session_entry->send_smps_action,
2215 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002216 /*
2217 * Reassociate request is expected
2218 * in link established state only.
2219 */
2220
2221 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002222 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2223 /*
2224 * May be from 11r FT pre-auth. So lets check it
2225 * before we bail out
2226 */
2227 lim_log(mac_ctx, LOG1, FL(
2228 "Session in reassoc state is %d"),
2229 session_entry->peSessionId);
2230
2231 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302232 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002233 session_entry->limReAssocbssId,
2234 6)) {
2235 lim_print_mac_addr(mac_ctx,
2236 reassoc_req->bssDescription.
2237 bssId, LOGE);
2238 lim_log(mac_ctx, LOGP,
2239 FL("Unknown bssId in reassoc state"));
2240 ret_code = eSIR_SME_INVALID_PARAMETERS;
2241 goto end;
2242 }
2243
2244 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2245 session_entry);
2246 return;
2247 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002248 /*
2249 * Should not have received eWNI_SME_REASSOC_REQ
2250 */
2251 lim_log(mac_ctx, LOGE,
2252 FL("received unexpected SME_REASSOC_REQ in state %X"),
2253 session_entry->limSmeState);
2254 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2255
2256 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2257 goto end;
2258 }
2259
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302260 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002261 session_entry->pLimReAssocReq->bssDescription.bssId,
2262 sizeof(tSirMacAddr));
2263
2264 session_entry->limReassocChannelId =
2265 session_entry->pLimReAssocReq->bssDescription.channelId;
2266
2267 session_entry->reAssocHtSupportedChannelWidthSet =
2268 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2269 session_entry->reAssocHtRecommendedTxWidthSet =
2270 session_entry->reAssocHtSupportedChannelWidthSet;
2271 session_entry->reAssocHtSecondaryChannelOffset =
2272 session_entry->pLimReAssocReq->cbMode;
2273
2274 session_entry->limReassocBssCaps =
2275 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2276 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2277 session_entry->currentOperChannel);
2278 local_pwr_constraint = reg_max;
2279
2280 lim_extract_ap_capability(mac_ctx,
2281 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2282 lim_get_ielen_from_bss_description(
2283 &session_entry->pLimReAssocReq->bssDescription),
2284 &session_entry->limReassocBssQosCaps,
2285 &session_entry->limReassocBssPropCap,
2286 &session_entry->gLimCurrentBssUapsd,
2287 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302288 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002289 lim_log(mac_ctx, LOGE,
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302290 FL("Reg max = %d, local pwr constraint = %d, max tx = %d"),
2291 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002292 /* Copy the SSID from session entry to local variable */
2293 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302294 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002295 reassoc_req->ssId.ssId,
2296 session_entry->limReassocSSID.length);
2297 if (session_entry->gLimCurrentBssUapsd) {
2298 session_entry->gUapsdPerAcBitmask =
2299 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
2300 lim_log(mac_ctx, LOG1,
2301 FL("UAPSD flag for all AC - 0x%2x"),
2302 session_entry->gUapsdPerAcBitmask);
2303 }
2304
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302305 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002306 if (NULL == mlm_reassoc_req) {
2307 lim_log(mac_ctx, LOGP,
2308 FL("call to AllocateMemory failed for mlmReassocReq"));
2309
2310 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2311 goto end;
2312 }
2313
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302314 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002315 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2316
2317 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2318 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
2319 eSIR_SUCCESS) {
2320 /*
2321 * Could not get ReassocFailureTimeout value
2322 * from CFG. Log error.
2323 */
2324 lim_log(mac_ctx, LOGP,
2325 FL("could not retrieve ReassocFailureTimeout value"));
2326 }
2327
2328 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
2329 eSIR_SUCCESS) {
2330 /*
2331 * Could not get Capabilities value
2332 * from CFG. Log error.
2333 */
2334 lim_log(mac_ctx, LOGP, FL(
2335 "could not retrieve Capabilities value"));
2336 }
2337 mlm_reassoc_req->capabilityInfo = caps;
2338
2339 /* Update PE session_id */
2340 mlm_reassoc_req->sessionId = session_id;
2341
2342 /*
2343 * If telescopic beaconing is enabled, set listen interval to
2344 * WNI_CFG_TELE_BCN_MAX_LI
2345 */
2346 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2347 &tele_bcn_en) != eSIR_SUCCESS)
2348 lim_log(mac_ctx, LOGP,
2349 FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
2350
2351 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2352
2353 if (tele_bcn_en) {
2354 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2355 eSIR_SUCCESS)
2356 /*
2357 * Could not get ListenInterval value
2358 * from CFG. Log error.
2359 */
2360 lim_log(mac_ctx, LOGP,
2361 FL("could not retrieve ListenInterval"));
2362 } else {
2363 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
2364 eSIR_SUCCESS)
2365 /*
2366 * Could not get ListenInterval value
2367 * from CFG. Log error.
2368 */
2369 lim_log(mac_ctx, LOGP,
2370 FL("could not retrieve ListenInterval"));
2371 }
2372
2373 mlm_reassoc_req->listenInterval = (uint16_t) val;
2374
2375 /* Indicate whether spectrum management is enabled */
2376 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2377
2378 /* Enable the spectrum management if this is a DFS channel */
2379 if (session_entry->country_info_present &&
2380 lim_isconnected_on_dfs_channel(
2381 session_entry->currentOperChannel))
2382 session_entry->spectrumMgtEnabled = true;
2383
2384 session_entry->limPrevSmeState = session_entry->limSmeState;
2385 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2386
2387 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2388 session_entry->peSessionId,
2389 session_entry->limSmeState));
2390
2391 lim_post_mlm_message(mac_ctx,
2392 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2393 return;
2394end:
2395 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302396 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002397 if (session_entry)
2398 session_entry->pLimReAssocReq = NULL;
2399 }
2400
2401 if (session_entry) {
2402 /*
2403 * error occurred after we determined the session so extract
2404 * session and transaction info from there
2405 */
2406 sme_session_id = session_entry->smeSessionId;
2407 transaction_id = session_entry->transactionId;
2408 } else
2409 /*
2410 * error occurred before or during the time we determined
2411 * the session so extract the session and transaction info
2412 * from the message
2413 */
2414 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2415 &sme_session_id, &transaction_id);
2416
2417 /*
2418 * Send Reassoc failure response to host
2419 * (note session_entry may be NULL, but that's OK)
2420 */
2421 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2422 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2423 session_entry, sme_session_id,
2424 transaction_id);
2425}
2426
2427bool send_disassoc_frame = 1;
2428/**
2429 * __lim_process_sme_disassoc_req()
2430 *
2431 ***FUNCTION:
2432 * This function is called to process SME_DISASSOC_REQ message
2433 * from HDD or upper layer application.
2434 *
2435 ***LOGIC:
2436 *
2437 ***ASSUMPTIONS:
2438 *
2439 ***NOTE:
2440 *
2441 * @param pMac Pointer to Global MAC structure
2442 * @param *pMsgBuf A pointer to the SME message buffer
2443 * @return None
2444 */
2445
2446static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2447{
2448 uint16_t disassocTrigger, reasonCode;
2449 tLimMlmDisassocReq *pMlmDisassocReq;
2450 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2451 tSirSmeDisassocReq smeDisassocReq;
2452 tpPESession psessionEntry = NULL;
2453 uint8_t sessionId;
2454 uint8_t smesessionId;
2455 uint16_t smetransactionId;
2456
2457 if (pMsgBuf == NULL) {
2458 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
2459 return;
2460 }
2461
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302462 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002463 smesessionId = smeDisassocReq.sessionId;
2464 smetransactionId = smeDisassocReq.transactionId;
2465 if (!lim_is_sme_disassoc_req_valid(pMac,
2466 &smeDisassocReq,
2467 psessionEntry)) {
2468 PELOGE(lim_log(pMac, LOGE,
2469 FL("received invalid SME_DISASSOC_REQ message"));)
2470 if (pMac->lim.gLimRspReqd) {
2471 pMac->lim.gLimRspReqd = false;
2472
2473 retCode = eSIR_SME_INVALID_PARAMETERS;
2474 disassocTrigger = eLIM_HOST_DISASSOC;
2475 goto sendDisassoc;
2476 }
2477
2478 return;
2479 }
2480
2481 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002482 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002483 &sessionId);
2484 if (psessionEntry == NULL) {
2485 lim_log(pMac, LOGE,
2486 FL("session does not exist for given bssId "
2487 MAC_ADDRESS_STR),
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002488 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002489 retCode = eSIR_SME_INVALID_PARAMETERS;
2490 disassocTrigger = eLIM_HOST_DISASSOC;
2491 goto sendDisassoc;
2492 }
2493 lim_log(pMac, LOG1,
2494 FL("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2495 MAC_ADDRESS_STR), smesessionId,
2496 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2497 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002498 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002499
2500#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2501 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2502 0, smeDisassocReq.reasonCode);
2503#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2504
2505 /* Update SME session Id and SME transaction ID */
2506
2507 psessionEntry->smeSessionId = smesessionId;
2508 psessionEntry->transactionId = smetransactionId;
2509
2510 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2511 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002512 switch (psessionEntry->limSmeState) {
2513 case eLIM_SME_ASSOCIATED_STATE:
2514 case eLIM_SME_LINK_EST_STATE:
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002515 lim_log(pMac, LOG1,
2516 FL("Rcvd SME_DISASSOC_REQ in limSmeState: %d "),
2517 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002518 psessionEntry->limPrevSmeState =
2519 psessionEntry->limSmeState;
2520 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2521#ifdef FEATURE_WLAN_TDLS
2522 /* Delete all TDLS peers connected before leaving BSS */
2523 lim_delete_tdls_peers(pMac, psessionEntry);
2524#endif
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002525 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2526 psessionEntry->peSessionId,
2527 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002528 break;
2529
2530 case eLIM_SME_WT_DEAUTH_STATE:
2531 /* PE shall still process the DISASSOC_REQ and proceed with
2532 * link tear down even if it had already sent a DEAUTH_IND to
2533 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2534 * its been set when PE entered WT_DEAUTH_STATE.
2535 */
2536 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2537 MTRACE(mac_trace
2538 (pMac, TRACE_CODE_SME_STATE,
2539 psessionEntry->peSessionId,
2540 psessionEntry->limSmeState));
2541 lim_log(pMac, LOG1,
2542 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE. "));
2543 break;
2544
2545 case eLIM_SME_WT_DISASSOC_STATE:
2546 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2547 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2548 * PE can continue processing DISASSOC_REQ and send the response instead
2549 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2550 * for disassoc frame.
2551 *
2552 * It will send a disassoc, which is ok. However, we can use the global flag
2553 * sendDisassoc to not send disassoc frame.
2554 */
2555 lim_log(pMac, LOG1,
2556 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE. "));
2557 break;
2558
2559 case eLIM_SME_JOIN_FAILURE_STATE: {
2560 /* Already in Disconnected State, return success */
2561 lim_log(pMac, LOG1,
2562 FL("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE. "));
2563 if (pMac->lim.gLimRspReqd) {
2564 retCode = eSIR_SME_SUCCESS;
2565 disassocTrigger = eLIM_HOST_DISASSOC;
2566 goto sendDisassoc;
2567 }
2568 }
2569 break;
2570 default:
2571 /**
2572 * STA is not currently associated.
2573 * Log error and send response to host
2574 */
2575 lim_log(pMac, LOGE,
2576 FL("received unexpected SME_DISASSOC_REQ in state %X"),
2577 psessionEntry->limSmeState);
2578 lim_print_sme_state(pMac, LOGE,
2579 psessionEntry->limSmeState);
2580
2581 if (pMac->lim.gLimRspReqd) {
2582 if (psessionEntry->limSmeState !=
2583 eLIM_SME_WT_ASSOC_STATE)
2584 pMac->lim.gLimRspReqd = false;
2585
2586 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2587 disassocTrigger = eLIM_HOST_DISASSOC;
2588 goto sendDisassoc;
2589 }
2590
2591 return;
2592 }
2593
2594 break;
2595
2596 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002597 /* Fall through */
2598 break;
2599
2600 case eLIM_STA_IN_IBSS_ROLE:
2601 default:
2602 /* eLIM_UNKNOWN_ROLE */
2603 lim_log(pMac, LOGE,
2604 FL("received unexpected SME_DISASSOC_REQ for role %d"),
2605 GET_LIM_SYSTEM_ROLE(psessionEntry));
2606
2607 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2608 disassocTrigger = eLIM_HOST_DISASSOC;
2609 goto sendDisassoc;
2610 } /* end switch (pMac->lim.gLimSystemRole) */
2611
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302612 disassocTrigger = eLIM_HOST_DISASSOC;
2613 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002614
2615 if (smeDisassocReq.doNotSendOverTheAir) {
2616 lim_log(pMac, LOG1, FL("do not send dissoc over the air"));
2617 send_disassoc_frame = 0;
2618 }
2619 /* Trigger Disassociation frame to peer MAC entity */
2620 lim_log(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2621 " : %d, reasonCode : %d"),
2622 disassocTrigger, reasonCode);
2623
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302624 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002625 if (NULL == pMlmDisassocReq) {
2626 /* Log error */
2627 lim_log(pMac, LOGP,
2628 FL("call to AllocateMemory failed for mlmDisassocReq"));
2629
2630 return;
2631 }
2632
Anurag Chouhanc5548422016-02-24 18:33:27 +05302633 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002634 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002635
2636 pMlmDisassocReq->reasonCode = reasonCode;
2637 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2638
2639 /* Update PE session ID */
2640 pMlmDisassocReq->sessionId = sessionId;
2641
2642 lim_post_mlm_message(pMac,
2643 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2644 return;
2645
2646sendDisassoc:
2647 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002648 lim_send_sme_disassoc_ntf(pMac,
2649 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002650 retCode,
2651 disassocTrigger,
2652 1, smesessionId, smetransactionId,
2653 psessionEntry);
2654 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002655 lim_send_sme_disassoc_ntf(pMac,
2656 smeDisassocReq.peer_macaddr.bytes,
2657 retCode, disassocTrigger, 1,
2658 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002659
2660} /*** end __lim_process_sme_disassoc_req() ***/
2661
2662/** -----------------------------------------------------------------
2663 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2664
2665 This function is called to process SME_DISASSOC_CNF message
2666 from HDD or upper layer application.
2667
2668 \param pMac - global mac structure
2669 \param pStaDs - station dph hash node
2670 \return none
2671 \sa
2672 ----------------------------------------------------------------- */
2673static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2674{
2675 tSirSmeDisassocCnf smeDisassocCnf;
2676 uint16_t aid;
2677 tpDphHashNode pStaDs;
2678 tpPESession psessionEntry;
2679 uint8_t sessionId;
2680
2681 PELOG1(lim_log(pMac, LOG1, FL("received DISASSOC_CNF message"));)
2682
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302683 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002684 sizeof(struct sSirSmeDisassocCnf));
2685
2686 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002687 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002688 &sessionId);
2689 if (psessionEntry == NULL) {
2690 lim_log(pMac, LOGE,
2691 FL("session does not exist for given bssId"));
2692 return;
2693 }
2694
2695 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
2696 lim_log(pMac, LOGE,
2697 FL("received invalid SME_DISASSOC_CNF message"));
2698 return;
2699 }
2700#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2701 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2702 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2703 psessionEntry,
2704 (uint16_t) smeDisassocCnf.statusCode, 0);
2705 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2706 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2707 psessionEntry,
2708 (uint16_t) smeDisassocCnf.statusCode, 0);
2709#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2710
2711 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2712 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002713 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2714 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2715 && (psessionEntry->limSmeState !=
2716 eLIM_SME_WT_DEAUTH_STATE)) {
2717 lim_log(pMac, LOGE,
2718 FL
2719 ("received unexp SME_DISASSOC_CNF in state %X"),
2720 psessionEntry->limSmeState);
2721 lim_print_sme_state(pMac, LOGE,
2722 psessionEntry->limSmeState);
2723 return;
2724 }
2725 break;
2726
2727 case eLIM_AP_ROLE:
2728 /* Fall through */
2729 break;
2730
2731 case eLIM_STA_IN_IBSS_ROLE:
2732 default: /* eLIM_UNKNOWN_ROLE */
2733 lim_log(pMac, LOGE,
2734 FL("received unexpected SME_DISASSOC_CNF role %d"),
2735 GET_LIM_SYSTEM_ROLE(psessionEntry));
2736
2737 return;
2738 }
2739
2740 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2741 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2742 LIM_IS_AP_ROLE(psessionEntry)) {
2743 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002744 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002745 &psessionEntry->dph.dphHashTable);
2746 if (pStaDs == NULL) {
2747 lim_log(pMac, LOGE,
2748 FL("DISASSOC_CNF for a STA with no context, addr= "
2749 MAC_ADDRESS_STR),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002750 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002751 return;
2752 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302753
2754 if ((pStaDs->mlmStaContext.mlmState ==
2755 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2756 (pStaDs->mlmStaContext.mlmState ==
2757 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
2758 lim_log(pMac, LOGE,
2759 FL("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d"),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002760 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302761 pStaDs->mlmStaContext.mlmState);
2762 return;
2763 }
2764
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002765 /* Delete FT session if there exists one */
2766 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002767 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2768
2769 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002770 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002771 }
2772
2773 return;
2774}
2775
2776/**
2777 * __lim_process_sme_deauth_req() - process sme deauth req
2778 * @mac_ctx: Pointer to Global MAC structure
2779 * @msg_buf: pointer to the SME message buffer
2780 *
2781 * This function is called to process SME_DEAUTH_REQ message
2782 * from HDD or upper layer application.
2783 *
2784 * Return: None
2785 */
2786
2787static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2788 uint32_t *msg_buf)
2789{
2790 uint16_t deauth_trigger, reason_code;
2791 tLimMlmDeauthReq *mlm_deauth_req;
2792 tSirSmeDeauthReq sme_deauth_req;
2793 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2794 tpPESession session_entry;
2795 uint8_t session_id; /* PE sessionId */
2796 uint8_t sme_session_id;
2797 uint16_t sme_transaction_id;
2798
2799 lim_log(mac_ctx, LOG1, FL("received DEAUTH_REQ message"));
2800
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302801 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002802 sme_session_id = sme_deauth_req.sessionId;
2803 sme_transaction_id = sme_deauth_req.transactionId;
2804
2805 /*
2806 * We need to get a session first but we don't even know
2807 * if the message is correct.
2808 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002809 session_entry = pe_find_session_by_bssid(mac_ctx,
2810 sme_deauth_req.bssid.bytes,
2811 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002812 if (session_entry == NULL) {
2813 lim_log(mac_ctx, LOGE,
2814 FL("session does not exist for given bssId"));
2815 ret_code = eSIR_SME_INVALID_PARAMETERS;
2816 deauth_trigger = eLIM_HOST_DEAUTH;
2817 goto send_deauth;
2818 }
2819
2820 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2821 session_entry)) {
2822 lim_log(mac_ctx, LOGE,
2823 FL("received invalid SME_DEAUTH_REQ message"));
2824 mac_ctx->lim.gLimRspReqd = false;
2825
2826 ret_code = eSIR_SME_INVALID_PARAMETERS;
2827 deauth_trigger = eLIM_HOST_DEAUTH;
2828 goto send_deauth;
2829 }
2830 lim_log(mac_ctx, LOG1,
2831 FL("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2832 MAC_ADDRESS_STR), sme_session_id,
2833 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2834 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002835 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002836#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2837 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2838 session_entry, 0, sme_deauth_req.reasonCode);
2839#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2840
2841 /* Update SME session ID and Transaction ID */
2842 session_entry->smeSessionId = sme_session_id;
2843 session_entry->transactionId = sme_transaction_id;
2844
2845 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2846 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002847 switch (session_entry->limSmeState) {
2848 case eLIM_SME_ASSOCIATED_STATE:
2849 case eLIM_SME_LINK_EST_STATE:
2850 case eLIM_SME_WT_ASSOC_STATE:
2851 case eLIM_SME_JOIN_FAILURE_STATE:
2852 case eLIM_SME_IDLE_STATE:
2853 session_entry->limPrevSmeState =
2854 session_entry->limSmeState;
2855 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2856 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2857 session_entry->peSessionId,
2858 session_entry->limSmeState));
2859 /* Send Deauthentication request to MLM below */
2860 break;
2861 case eLIM_SME_WT_DEAUTH_STATE:
2862 case eLIM_SME_WT_DISASSOC_STATE:
2863 /*
2864 * PE Recieved a Deauth/Disassoc frame. Normally it get
2865 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2866 * Which means host is also trying to disconnect.
2867 * PE can continue processing DEAUTH_REQ and send
2868 * the response instead of failing the request.
2869 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2870 * was sent for deauth/disassoc frame.
2871 */
2872 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2873 lim_log(mac_ctx, LOG1, FL(
2874 "Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE"));
2875 break;
2876 default:
2877 /*
2878 * STA is not in a state to deauthenticate with
2879 * peer. Log error and send response to host.
2880 */
2881 lim_log(mac_ctx, LOGE, FL(
2882 "received unexp SME_DEAUTH_REQ in state %X"),
2883 session_entry->limSmeState);
2884 lim_print_sme_state(mac_ctx, LOGE,
2885 session_entry->limSmeState);
2886
2887 if (mac_ctx->lim.gLimRspReqd) {
2888 mac_ctx->lim.gLimRspReqd = false;
2889
2890 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2891 deauth_trigger = eLIM_HOST_DEAUTH;
2892
2893 /*
2894 * here we received deauth request from AP so sme state
2895 * is eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED
2896 * delSta then mlm state should be
2897 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got delBSS
2898 * rsp then mlm state should be eLIM_MLM_IDLE_STATE
2899 * so the below condition captures the state where
2900 * delSta not done and firmware still in
2901 * connected state.
2902 */
2903 if (session_entry->limSmeState ==
2904 eLIM_SME_WT_DEAUTH_STATE &&
2905 session_entry->limMlmState !=
2906 eLIM_MLM_IDLE_STATE &&
2907 session_entry->limMlmState !=
2908 eLIM_MLM_WT_DEL_STA_RSP_STATE)
2909 ret_code = eSIR_SME_DEAUTH_STATUS;
2910 goto send_deauth;
2911 }
2912 return;
2913 }
2914 break;
2915
2916 case eLIM_STA_IN_IBSS_ROLE:
2917 lim_log(mac_ctx, LOGE, FL("Deauth not allowed in IBSS"));
2918 if (mac_ctx->lim.gLimRspReqd) {
2919 mac_ctx->lim.gLimRspReqd = false;
2920 ret_code = eSIR_SME_INVALID_PARAMETERS;
2921 deauth_trigger = eLIM_HOST_DEAUTH;
2922 goto send_deauth;
2923 }
2924 return;
2925 case eLIM_AP_ROLE:
2926 break;
2927 default:
2928 lim_log(mac_ctx, LOGE,
2929 FL("received unexpected SME_DEAUTH_REQ for role %X"),
2930 GET_LIM_SYSTEM_ROLE(session_entry));
2931 if (mac_ctx->lim.gLimRspReqd) {
2932 mac_ctx->lim.gLimRspReqd = false;
2933 ret_code = eSIR_SME_INVALID_PARAMETERS;
2934 deauth_trigger = eLIM_HOST_DEAUTH;
2935 goto send_deauth;
2936 }
2937 return;
2938 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2939
2940 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2941 /* Deauthentication is triggered by Link Monitoring */
2942 lim_log(mac_ctx, LOG1, FL("** Lost link with AP **"));
2943 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2944 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2945 } else {
2946 deauth_trigger = eLIM_HOST_DEAUTH;
2947 reason_code = sme_deauth_req.reasonCode;
2948 }
2949
2950 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302951 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002952 if (NULL == mlm_deauth_req) {
2953 lim_log(mac_ctx, LOGP,
2954 FL("call to AllocateMemory failed for mlmDeauthReq"));
2955 if (mac_ctx->lim.gLimRspReqd) {
2956 mac_ctx->lim.gLimRspReqd = false;
2957 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2958 deauth_trigger = eLIM_HOST_DEAUTH;
2959 goto send_deauth;
2960 }
2961 return;
2962 }
2963
Anurag Chouhanc5548422016-02-24 18:33:27 +05302964 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002965 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002966
2967 mlm_deauth_req->reasonCode = reason_code;
2968 mlm_deauth_req->deauthTrigger = deauth_trigger;
2969
2970 /* Update PE session Id */
2971 mlm_deauth_req->sessionId = session_id;
2972
2973 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2974 (uint32_t *)mlm_deauth_req);
2975 return;
2976
2977send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002978 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2979 ret_code, deauth_trigger, 1,
2980 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002981}
2982
2983/**
2984 * __lim_process_sme_set_context_req()
2985 *
2986 * @mac_ctx: Pointer to Global MAC structure
2987 * @msg_buf: pointer to the SME message buffer
2988 *
2989 * This function is called to process SME_SETCONTEXT_REQ message
2990 * from HDD or upper layer application.
2991 *
2992 * Return: None
2993 */
2994
2995static void
2996__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2997{
2998 tpSirSmeSetContextReq set_context_req;
2999 tLimMlmSetKeysReq *mlm_set_key_req;
3000 tpPESession session_entry;
3001 uint8_t session_id; /* PE sessionID */
3002 uint8_t sme_session_id;
3003 uint16_t sme_transaction_id;
3004
3005 lim_log(mac_ctx, LOG1, FL("received SETCONTEXT_REQ message"));
3006
3007 if (msg_buf == NULL) {
3008 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3009 return;
3010 }
3011
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303012 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003013 if (NULL == set_context_req) {
3014 lim_log(mac_ctx, LOGP, FL(
3015 "call to AllocateMemory failed for set_context_req"));
3016 return;
3017 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303018 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003019 sizeof(struct sSirSmeSetContextReq));
3020 sme_session_id = set_context_req->sessionId;
3021 sme_transaction_id = set_context_req->transactionId;
3022
3023 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
3024 lim_log(mac_ctx, LOGW,
3025 FL("received invalid SME_SETCONTEXT_REQ message"));
3026 goto end;
3027 }
3028
3029 if (set_context_req->keyMaterial.numKeys >
3030 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3031 lim_log(mac_ctx, LOGE, FL(
3032 "numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS"),
3033 set_context_req->keyMaterial.numKeys);
3034 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003035 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003036 eSIR_SME_INVALID_PARAMETERS, NULL,
3037 sme_session_id, sme_transaction_id);
3038 goto end;
3039 }
3040
3041 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003042 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003043 if (session_entry == NULL) {
3044 lim_log(mac_ctx, LOGW,
3045 FL("Session does not exist for given BSSID"));
3046 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003047 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003048 eSIR_SME_INVALID_PARAMETERS, NULL,
3049 sme_session_id, sme_transaction_id);
3050 goto end;
3051 }
3052#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3053 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
3054 session_entry, 0, 0);
3055#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3056
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003057 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003058 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3059 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003060 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003061 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
3062 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303063 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003064 if (NULL == mlm_set_key_req) {
3065 lim_log(mac_ctx, LOGP, FL(
3066 "mem alloc failed for mlmSetKeysReq"));
3067 goto end;
3068 }
3069 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
3070 mlm_set_key_req->numKeys =
3071 set_context_req->keyMaterial.numKeys;
3072 if (mlm_set_key_req->numKeys >
3073 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3074 lim_log(mac_ctx, LOGP, FL(
3075 "no.of keys exceeded max num of default keys limit"));
3076 goto end;
3077 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05303078 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003079 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003080
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303081 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003082 (uint8_t *) &set_context_req->keyMaterial.key,
3083 sizeof(tSirKeys) *
3084 (mlm_set_key_req->numKeys ? mlm_set_key_req->
3085 numKeys : 1));
3086
3087 mlm_set_key_req->sessionId = session_id;
3088 mlm_set_key_req->smesessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003089 lim_log(mac_ctx, LOG1, FL(
3090 "received SETCONTEXT_REQ message sessionId=%d"),
3091 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003092
3093 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
3094 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
3095 LIM_IS_AP_ROLE(session_entry)) {
3096 if (set_context_req->keyMaterial.key[0].keyLength) {
3097 uint8_t key_id;
3098 key_id =
3099 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303100 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003101 &session_entry->WEPKeyMaterial[key_id],
3102 (uint8_t *) &set_context_req->keyMaterial,
3103 sizeof(tSirKeyMaterial));
3104 } else {
3105 uint32_t i;
3106 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
3107 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303108 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003109 &mlm_set_key_req->key[i],
3110 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
3111 sizeof(tSirKeys));
3112 }
3113 }
3114 }
3115 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
3116 (uint32_t *) mlm_set_key_req);
3117 } else {
3118 lim_log(mac_ctx, LOGE, FL(
3119 "rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
3120 GET_LIM_SYSTEM_ROLE(session_entry),
3121 session_entry->limSmeState);
3122 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
3123
3124 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003125 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003126 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
3127 session_entry, sme_session_id,
3128 sme_transaction_id);
3129 }
3130end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303131 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003132 return;
3133}
3134
3135/**
3136 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
3137 *
3138 * @mac_ctx: Pointer to Global MAC structure
3139 * @msg_buf: pointer to the SME message buffer
3140 *
3141 * This function is called to process SME_GET_ASSOC_STAS_REQ message
3142 * from HDD or upper layer application.
3143 *
3144 * Return: None
3145 */
3146
3147void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
3148 uint32_t *msg_buf)
3149{
3150 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3151 tpDphHashNode sta_ds = NULL;
3152 tpPESession session_entry = NULL;
3153 tSap_Event sap_event;
3154 tpWLAN_SAPEventCB sap_event_cb = NULL;
3155 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3156 uint8_t session_id = CSR_SESSION_ID_INVALID;
3157 uint8_t assoc_id = 0;
3158 uint8_t sta_cnt = 0;
3159
3160 if (msg_buf == NULL) {
3161 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3162 return;
3163 }
3164
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303165 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003166 sizeof(struct sSirSmeGetAssocSTAsReq));
3167 /*
3168 * Get Associated stations from PE.
3169 * Find PE session Entry
3170 */
3171 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003172 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003173 &session_id);
3174 if (session_entry == NULL) {
3175 lim_log(mac_ctx, LOGE,
3176 FL("session does not exist for given bssId"));
3177 goto lim_assoc_sta_end;
3178 }
3179
3180 if (!LIM_IS_AP_ROLE(session_entry)) {
3181 lim_log(mac_ctx, LOGE, FL(
3182 "Received unexpected message in state %X, in role %X"),
3183 session_entry->limSmeState,
3184 GET_LIM_SYSTEM_ROLE(session_entry));
3185 goto lim_assoc_sta_end;
3186 }
3187 /* Retrieve values obtained in the request message */
3188 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3189 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3190
3191 if (NULL == assoc_sta_tmp)
3192 goto lim_assoc_sta_end;
3193 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3194 assoc_id++) {
3195 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3196 &session_entry->dph.dphHashTable);
3197 if (NULL == sta_ds)
3198 continue;
3199 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303200 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003201 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303202 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003203 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3204 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3205
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303206 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003207 (uint8_t *)&sta_ds->supportedRates,
3208 sizeof(tSirSupportedRates));
3209 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3210 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3211 assoc_sta_tmp->Support40Mhz =
3212 sta_ds->htDsssCckRate40MHzSupport;
3213
3214 lim_log(mac_ctx, LOG1, FL("dph Station Number = %d"),
3215 sta_cnt + 1);
3216 lim_log(mac_ctx, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3217 MAC_ADDR_ARRAY(sta_ds->staAddr));
3218 lim_log(mac_ctx, LOG1, FL("Association Id = %d"),
3219 sta_ds->assocId);
3220 lim_log(mac_ctx, LOG1, FL("Station Index = %d"),
3221 sta_ds->staIndex);
3222 assoc_sta_tmp++;
3223 sta_cnt++;
3224 }
3225 }
3226lim_assoc_sta_end:
3227 /*
3228 * Call hdd callback with sap event to send the list of
3229 * associated stations from PE
3230 */
3231 if (sap_event_cb != NULL) {
3232 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3233 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303234 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003235 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3236 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3237 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3238 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3239 }
3240}
3241
3242/**
3243 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3244 *
3245 * @mac_ctx: Pointer to Global MAC structure
3246 * @msg_buf: pointer to WPS PBC overlap query message
3247 *
3248 * This function parses get WPS PBC overlap information
3249 * message and call callback to pass WPS PBC overlap
3250 * information back to hdd.
3251 *
3252 * Return: None
3253 */
3254void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3255 uint32_t *msg_buf)
3256{
3257 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3258 tpPESession session_entry = NULL;
3259 tSap_Event sap_event;
3260 tpWLAN_SAPEventCB sap_event_cb = NULL;
3261 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003262 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3263
3264 if (msg_buf == NULL) {
3265 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3266 return;
3267 }
3268
3269 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303270 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003271
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303272 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003273 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3274 /*
3275 * Get Associated stations from PE
3276 * Find PE session Entry
3277 */
3278 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003279 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003280 if (session_entry == NULL) {
3281 lim_log(mac_ctx, LOGE,
3282 FL("session does not exist for given bssId"));
3283 goto lim_get_wpspbc_sessions_end;
3284 }
3285
3286 if (!LIM_IS_AP_ROLE(session_entry)) {
3287 lim_log(mac_ctx, LOGE,
3288 FL("Received unexpected message in role %X"),
3289 GET_LIM_SYSTEM_ROLE(session_entry));
3290 goto lim_get_wpspbc_sessions_end;
3291 }
3292 /*
3293 * Call hdd callback with sap event to send the
3294 * WPS PBC overlap information
3295 */
3296 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303297 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003298
Anurag Chouhanc5548422016-02-24 18:33:27 +05303299 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003300 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003301 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003302 sap_get_wpspbc_event->UUID_E,
3303 &sap_get_wpspbc_event->wpsPBCOverlap,
3304 session_entry);
3305 } else {
3306 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003307 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003308 session_entry);
3309 /* don't have to inform the HDD/Host */
3310 return;
3311 }
3312
3313 lim_log(mac_ctx, LOGE, FL("wpsPBCOverlap %d"),
3314 sap_get_wpspbc_event->wpsPBCOverlap);
3315 lim_print_mac_addr(mac_ctx,
3316 sap_get_wpspbc_event->addr.bytes, LOG4);
3317
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303318 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003319
3320lim_get_wpspbc_sessions_end:
3321 sap_event_cb =
3322 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3323 if (NULL != sap_event_cb)
3324 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3325}
3326
3327/**
3328 * __lim_counter_measures()
3329 *
3330 * FUNCTION:
3331 * This function is called to "implement" MIC counter measure
3332 * and is *temporary* only
3333 *
3334 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3335 * we don't do the proper STA disassoc sequence since the
3336 * BSS will be stoped anyway
3337 *
3338 ***ASSUMPTIONS:
3339 *
3340 ***NOTE:
3341 *
3342 * @param pMac Pointer to Global MAC structure
3343 * @return None
3344 */
3345
3346static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3347{
3348 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003349 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003350 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3351 mac, psessionEntry, false);
3352};
3353
3354void lim_process_tkip_counter_measures(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3355{
3356 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3357 tpPESession psessionEntry;
3358 uint8_t sessionId; /* PE sessionId */
3359
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303360 qdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003361 sizeof(struct sSirSmeTkipCntrMeasReq));
3362
3363 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003364 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003365 if (NULL == psessionEntry) {
3366 lim_log(pMac, LOGE,
3367 FL("session does not exist for given BSSID "));
3368 return;
3369 }
3370
3371 if (tkipCntrMeasReq.bEnable)
3372 __lim_counter_measures(pMac, psessionEntry);
3373
3374 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3375}
3376
3377static void
3378__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3379{
3380 tSirSmeStopBssReq stopBssReq;
3381 tSirRetStatus status;
3382 tLimSmeStates prevState;
3383 tpPESession psessionEntry;
3384 uint8_t smesessionId;
3385 uint8_t sessionId;
3386 uint16_t smetransactionId;
3387 uint8_t i = 0;
3388 tpDphHashNode pStaDs = NULL;
3389
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303390 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003391 smesessionId = stopBssReq.sessionId;
3392 smetransactionId = stopBssReq.transactionId;
3393
3394 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
3395 PELOGW(lim_log(pMac, LOGW,
3396 FL("received invalid SME_STOP_BSS_REQ message"));)
3397 /* Send Stop BSS response to host */
3398 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3399 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3400 smetransactionId);
3401 return;
3402 }
3403
3404 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003405 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003406 &sessionId);
3407 if (psessionEntry == NULL) {
3408 lim_log(pMac, LOGW,
3409 FL("session does not exist for given BSSID "));
3410 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3411 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3412 smetransactionId);
3413 return;
3414 }
3415#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3416 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3417 0, 0);
3418#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3419
3420 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3421 LIM_IS_STA_ROLE(psessionEntry)) {
3422 /**
3423 * Should not have received STOP_BSS_REQ in states
3424 * other than 'normal' state or on STA in Infrastructure
3425 * mode. Log error and return response to host.
3426 */
3427 lim_log(pMac, LOGE,
3428 FL
3429 ("received unexpected SME_STOP_BSS_REQ in state %X, for role %d"),
3430 psessionEntry->limSmeState,
3431 GET_LIM_SYSTEM_ROLE(psessionEntry));
3432 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3433 /* / Send Stop BSS response to host */
3434 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3435 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3436 smetransactionId);
3437 return;
3438 }
3439
3440 if (LIM_IS_AP_ROLE(psessionEntry))
3441 lim_wpspbc_close(pMac, psessionEntry);
3442
3443 lim_log(pMac, LOGW,
3444 FL("RECEIVED STOP_BSS_REQ with reason code=%d"),
3445 stopBssReq.reasonCode);
3446
3447 prevState = psessionEntry->limSmeState;
3448
3449 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3450 MTRACE(mac_trace
3451 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3452 psessionEntry->limSmeState));
3453
3454 /* Update SME session Id and Transaction Id */
3455 psessionEntry->smeSessionId = smesessionId;
3456 psessionEntry->transactionId = smetransactionId;
3457
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003458 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3459 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3460 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003461 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3462 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3463 /* Send disassoc all stations associated thru TKIP */
3464 __lim_counter_measures(pMac, psessionEntry);
3465 else
3466 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003467 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3468 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003469 }
3470
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003471 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3472 /* Free the buffer allocated in START_BSS_REQ */
3473 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3474 psessionEntry->addIeParams.probeRespDataLen = 0;
3475 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003476
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003477 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3478 psessionEntry->addIeParams.assocRespDataLen = 0;
3479 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003480
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003481 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3482 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3483 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003484
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003485 /*
3486 * lim_del_bss is also called as part of coalescing,
3487 * when we send DEL BSS followed by Add Bss msg.
3488 */
3489 pMac->lim.gLimIbssCoalescingHappened = false;
3490 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003491 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3492 pStaDs =
3493 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3494 if (NULL == pStaDs)
3495 continue;
3496 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3497 if (eSIR_SUCCESS == status) {
3498 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3499 pStaDs->assocId, psessionEntry);
3500 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3501 } else {
3502 lim_log(pMac, LOGE,
3503 FL("lim_del_sta failed with Status : %d"), status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303504 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003505 }
3506 }
3507 /* send a delBss to HAL and wait for a response */
3508 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3509
3510 if (status != eSIR_SUCCESS) {
3511 PELOGE(lim_log
3512 (pMac, LOGE, FL("delBss failed for bss %d"),
3513 psessionEntry->bssIdx);
3514 )
3515 psessionEntry->limSmeState = prevState;
3516
3517 MTRACE(mac_trace
3518 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3519 psessionEntry->limSmeState));
3520
3521 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3522 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3523 smetransactionId);
3524 }
3525}
3526
3527/**
3528 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3529 * @pMac: Global MAC context
3530 * @pMsg: Message from SME
3531 *
3532 * Wrapper for the function __lim_handle_sme_stop_bss_request
3533 * This message will be defered until softmac come out of
3534 * scan mode. Message should be handled even if we have
3535 * detected radar in the current operating channel.
3536 *
3537 * Return: true - If we consumed the buffer
3538 * false - If have defered the message.
3539 */
3540
3541static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3542{
3543 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3544 /**
3545 * If message defered, buffer is not consumed yet.
3546 * So return false
3547 */
3548 return false;
3549 }
3550 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3551 return true;
3552} /*** end __lim_process_sme_stop_bss_req() ***/
3553
3554void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3555 uint32_t body, tpPESession psessionEntry)
3556{
3557
3558 (void)body;
3559 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3560 lim_ibss_delete(pMac, psessionEntry);
3561 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3562 lim_delete_pre_auth_list(pMac);
3563 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3564 psessionEntry->smeSessionId,
3565 psessionEntry->transactionId);
3566 return;
3567}
3568
3569/**
3570 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3571 *
3572 * @mac_ctx: pointer to mac context
3573 * @msg_type: message type
3574 * @msg_buf: pointer to the SME message buffer
3575 *
3576 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3577 * in BTAMP AP.
3578 *
3579 * Return: None
3580 */
3581
3582void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3583 uint32_t *msg_buf)
3584{
3585 tSirSmeAssocCnf assoc_cnf;
3586 tpDphHashNode sta_ds = NULL;
3587 tpPESession session_entry = NULL;
3588 uint8_t session_id;
3589 tpSirAssocReq assoc_req;
3590
3591 if (msg_buf == NULL) {
3592 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL "));
3593 goto end;
3594 }
3595
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303596 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003597 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
3598 lim_log(mac_ctx, LOGE,
3599 FL("Received invalid SME_RE(ASSOC)_CNF message "));
3600 goto end;
3601 }
3602
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003603 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003604 &session_id);
3605 if (session_entry == NULL) {
3606 lim_log(mac_ctx, LOGE,
3607 FL("session does not exist for given bssId"));
3608 goto end;
3609 }
3610
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003611 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003612 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3613 (session_entry->limSmeState !=
3614 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
3615 lim_log(mac_ctx, LOGE, FL(
3616 "Rcvd unexpected msg %X in state %X, in role %X"),
3617 msg_type, session_entry->limSmeState,
3618 GET_LIM_SYSTEM_ROLE(session_entry));
3619 goto end;
3620 }
3621 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3622 &session_entry->dph.dphHashTable);
3623 if (sta_ds == NULL) {
3624 lim_log(mac_ctx, LOGE, FL(
3625 "Rcvd invalid msg %X due to no STA ctx, aid %d, peer "),
3626 msg_type, assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003627 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003628
3629 /*
3630 * send a DISASSOC_IND message to WSM to make sure
3631 * the state in WSM and LIM is the same
3632 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003633 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003634 eSIR_SME_STA_NOT_ASSOCIATED,
3635 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3636 session_entry->smeSessionId,
3637 session_entry->transactionId,
3638 session_entry);
3639 goto end;
3640 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303641 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003642 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303643 QDF_MAC_ADDR_SIZE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003644 lim_log(mac_ctx, LOG1, FL(
3645 "peerMacAddr mismatched for aid %d, peer "),
3646 assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003647 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003648 goto end;
3649 }
3650
3651 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3652 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3653 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3654 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3655 (msg_type != eWNI_SME_ASSOC_CNF))) {
3656 lim_log(mac_ctx, LOG1, FL(
3657 "not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3658 "StaD mlmState : %d"),
3659 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003660 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003661 goto end;
3662 }
3663 /*
3664 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3665 * has been received
3666 */
3667 lim_log(mac_ctx, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
3668 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3669 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3670
3671 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3672 /*
3673 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3674 * when it had received Assoc Request frame. Now, PE just needs
3675 * to send association rsp frame to the requesting BTAMP-STA.
3676 */
3677 sta_ds->mlmStaContext.mlmState =
3678 eLIM_MLM_LINK_ESTABLISHED_STATE;
3679 lim_log(mac_ctx, LOG1,
3680 FL("sending Assoc Rsp frame to STA (assoc id=%d) "),
3681 sta_ds->assocId);
3682 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3683 sta_ds->assocId, sta_ds->staAddr,
3684 sta_ds->mlmStaContext.subType, sta_ds,
3685 session_entry);
3686 goto end;
3687 } else {
3688 /*
3689 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3690 * to be associated since the HAL sta entry is created for
3691 * denied STA we need to remove this HAL entry.
3692 * So to do that set updateContext to 1
3693 */
3694 if (!sta_ds->mlmStaContext.updateContext)
3695 sta_ds->mlmStaContext.updateContext = 1;
3696 lim_log(mac_ctx, LOG1,
3697 FL("Recv Assoc Cnf, status Code : %d(assoc id=%d) "),
3698 assoc_cnf.statusCode, sta_ds->assocId);
3699 lim_reject_association(mac_ctx, sta_ds->staAddr,
3700 sta_ds->mlmStaContext.subType,
3701 true, sta_ds->mlmStaContext.authType,
3702 sta_ds->assocId, true,
3703 eSIR_MAC_UNSPEC_FAILURE_STATUS,
3704 session_entry);
3705 }
3706end:
3707 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3708 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3709 assoc_req = (tpSirAssocReq)
3710 session_entry->parsedAssocReq[sta_ds->assocId];
3711 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303712 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003713 assoc_req->assocReqFrame = NULL;
3714 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303715 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003716 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3717 }
3718}
3719
3720static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3721{
3722 tpDphHashNode pStaDs;
3723 tSirMacAddr peerMac;
3724 tpSirAddtsReq pSirAddts;
3725 uint32_t timeout;
3726 tpPESession psessionEntry;
3727 uint8_t sessionId; /* PE sessionId */
3728 uint8_t smesessionId;
3729 uint16_t smetransactionId;
3730
3731 if (pMsgBuf == NULL) {
3732 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
3733 return;
3734 }
3735
3736 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3737 &smetransactionId);
3738
3739 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3740
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003741 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3742 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003743 if (psessionEntry == NULL) {
3744 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3745 return;
3746 }
3747#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3748 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3749 0);
3750#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3751
3752 /* if sta
3753 * - verify assoc state
3754 * - send addts request to ap
3755 * - wait for addts response from ap
3756 * if ap, just ignore with error log
3757 */
3758 PELOG1(lim_log(pMac, LOG1,
3759 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
3760 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3761 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
3762 )
3763
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003764 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003765 PELOGE(lim_log(pMac, LOGE, "AddTs received on AP - ignoring");)
3766 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3767 psessionEntry, pSirAddts->req.tspec,
3768 smesessionId, smetransactionId);
3769 return;
3770 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003771
3772 pStaDs =
3773 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3774 &psessionEntry->dph.dphHashTable);
3775
3776 if (pStaDs == NULL) {
3777 PELOGE(lim_log
3778 (pMac, LOGE, "Cannot find AP context for addts req");
3779 )
3780 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3781 psessionEntry, pSirAddts->req.tspec,
3782 smesessionId, smetransactionId);
3783 return;
3784 }
3785
3786 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3787 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
3788 lim_log(pMac, LOGE, "AddTs received in invalid MLM state");
3789 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3790 psessionEntry, pSirAddts->req.tspec,
3791 smesessionId, smetransactionId);
3792 return;
3793 }
3794
3795 pSirAddts->req.wsmTspecPresent = 0;
3796 pSirAddts->req.wmeTspecPresent = 0;
3797 pSirAddts->req.lleTspecPresent = 0;
3798
3799 if ((pStaDs->wsmEnabled) &&
3800 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3801 SIR_MAC_ACCESSPOLICY_EDCA))
3802 pSirAddts->req.wsmTspecPresent = 1;
3803 else if (pStaDs->wmeEnabled)
3804 pSirAddts->req.wmeTspecPresent = 1;
3805 else if (pStaDs->lleEnabled)
3806 pSirAddts->req.lleTspecPresent = 1;
3807 else {
3808 PELOGW(lim_log
3809 (pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));
3810 )
3811 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3812 psessionEntry, pSirAddts->req.tspec,
3813 smesessionId, smetransactionId);
3814 return;
3815 }
3816
3817 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3818 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
3819 lim_log(pMac, LOGE,
3820 "AddTs received in invalid LIMsme state (%d)",
3821 psessionEntry->limSmeState);
3822 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3823 psessionEntry, pSirAddts->req.tspec,
3824 smesessionId, smetransactionId);
3825 return;
3826 }
3827
3828 if (pMac->lim.gLimAddtsSent) {
3829 lim_log(pMac, LOGE,
3830 "Addts (token %d, tsid %d, up %d) is still pending",
3831 pMac->lim.gLimAddtsReq.req.dialogToken,
3832 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3833 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3834 userPrio);
3835 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3836 psessionEntry, pSirAddts->req.tspec,
3837 smesessionId, smetransactionId);
3838 return;
3839 }
3840
3841 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3842
3843 /* save the addts request */
3844 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303845 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003846 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3847
3848 /* ship out the message now */
3849 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3850 psessionEntry);
3851 PELOG1(lim_log(pMac, LOG1, "Sent ADDTS request");)
3852 /* start a timer to wait for the response */
3853 if (pSirAddts->timeout)
3854 timeout = pSirAddts->timeout;
3855 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3856 eSIR_SUCCESS) {
3857 lim_log(pMac, LOGP,
3858 FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
3859 WNI_CFG_ADDTS_RSP_TIMEOUT);
3860 return;
3861 }
3862
3863 timeout = SYS_MS_TO_TICKS(timeout);
3864 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3865 != TX_SUCCESS) {
3866 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3867 return;
3868 }
3869 pMac->lim.gLimAddtsRspTimerCount++;
3870 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3871 pMac->lim.gLimAddtsRspTimerCount) !=
3872 TX_SUCCESS) {
3873 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3874 return;
3875 }
3876 MTRACE(mac_trace
3877 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3878 eLIM_ADDTS_RSP_TIMER));
3879
3880 /* add the sessionId to the timer object */
3881 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3882 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3883 TX_SUCCESS) {
3884 lim_log(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
3885 return;
3886 }
3887 return;
3888}
3889
3890static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3891{
3892 tSirMacAddr peerMacAddr;
3893 uint8_t ac;
3894 tSirMacTSInfo *pTsinfo;
3895 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3896 tpDphHashNode pStaDs = NULL;
3897 tpPESession psessionEntry;
3898 uint8_t sessionId;
3899 uint32_t status = eSIR_SUCCESS;
3900 uint8_t smesessionId;
3901 uint16_t smetransactionId;
3902
3903 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3904 &smetransactionId);
3905
3906 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003907 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003908 &sessionId);
3909 if (psessionEntry == NULL) {
3910 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3911 status = eSIR_FAILURE;
3912 goto end;
3913 }
3914#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3915 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3916 0);
3917#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3918
3919 if (eSIR_SUCCESS !=
3920 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
3921 PELOGE(lim_log(pMac, LOGE, FL("lim_validate_delts_req failed"));)
3922 status = eSIR_FAILURE;
3923 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3924 smesessionId, smetransactionId);
3925 return;
3926 }
3927
3928 lim_log(pMac, LOG1,
3929 FL("Sent DELTS request to station with assocId = %d MacAddr = "
3930 MAC_ADDRESS_STR),
3931 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3932
3933 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3934 pDeltsReq->req.wmeTspecPresent,
3935 &pDeltsReq->req.tsinfo,
3936 &pDeltsReq->req.tspec, psessionEntry);
3937
3938 pTsinfo =
3939 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3940 tsinfo : &pDeltsReq->req.tsinfo;
3941
3942 /* We've successfully send DELTS frame to AP. Update the
3943 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3944 * is no longer trigger enabled or delivery enabled
3945 */
3946 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3947 pTsinfo, CLEAR_UAPSD_MASK);
3948
3949 /* We're deleting the TSPEC, so this particular AC is no longer
3950 * admitted. PE needs to downgrade the EDCA
3951 * parameters(for the AC for which TS is being deleted) to the
3952 * next best AC for which ACM is not enabled, and send the
3953 * updated values to HAL.
3954 */
3955 ac = upToAc(pTsinfo->traffic.userPrio);
3956
3957 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3958 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3959 ~(1 << ac);
3960 } else if (pTsinfo->traffic.direction ==
3961 SIR_MAC_DIRECTION_DNLINK) {
3962 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3963 ~(1 << ac);
3964 } else if (pTsinfo->traffic.direction ==
3965 SIR_MAC_DIRECTION_BIDIR) {
3966 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3967 ~(1 << ac);
3968 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3969 ~(1 << ac);
3970 }
3971
3972 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3973 psessionEntry);
3974
3975 pStaDs =
3976 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3977 &psessionEntry->dph.dphHashTable);
3978 if (pStaDs != NULL) {
3979 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3980 pStaDs->bssId);
3981 status = eSIR_SUCCESS;
3982 } else {
3983 lim_log(pMac, LOGE, FL("Self entry missing in Hash Table "));
3984 status = eSIR_FAILURE;
3985 }
3986#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003987 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003988#endif
3989
3990 /* send an sme response back */
3991end:
3992 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3993 smesessionId, smetransactionId);
3994}
3995
3996void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
3997{
3998 /* fetch the sessionEntry based on the sessionId */
3999 tpPESession psessionEntry;
4000 psessionEntry = pe_find_session_by_session_id(pMac,
4001 pMac->lim.limTimers.gLimAddtsRspTimer.
4002 sessionId);
4003 if (psessionEntry == NULL) {
4004 lim_log(pMac, LOGP,
4005 FL("Session Does not exist for given sessionID"));
4006 return;
4007 }
4008
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07004009 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004010 lim_log(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)",
4011 GET_LIM_SYSTEM_ROLE(psessionEntry));
4012 pMac->lim.gLimAddtsSent = false;
4013 return;
4014 }
4015
4016 if (!pMac->lim.gLimAddtsSent) {
4017 lim_log(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");
4018 return;
4019 }
4020
4021 if (param != pMac->lim.gLimAddtsRspTimerCount) {
4022 lim_log(pMac, LOGE,
4023 FL("Invalid AddtsRsp Timer count %d (exp %d)"), param,
4024 pMac->lim.gLimAddtsRspTimerCount);
4025 return;
4026 }
4027 /* this a real response timeout */
4028 pMac->lim.gLimAddtsSent = false;
4029 pMac->lim.gLimAddtsRspTimerCount++;
4030
4031 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
4032 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
4033 psessionEntry->smeSessionId,
4034 psessionEntry->transactionId);
4035}
4036
4037/**
4038 * __lim_process_sme_get_statistics_request()
4039 *
4040 ***FUNCTION:
4041 *
4042 *
4043 ***NOTE:
4044 *
4045 * @param pMac Pointer to Global MAC structure
4046 * @param *pMsgBuf A pointer to the SME message buffer
4047 * @return None
4048 */
4049static void
4050__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4051{
4052 tpAniGetPEStatsReq pPEStatsReq;
4053 tSirMsgQ msgQ;
4054
4055 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4056
4057 msgQ.type = WMA_GET_STATISTICS_REQ;
4058
4059 msgQ.reserved = 0;
4060 msgQ.bodyptr = pMsgBuf;
4061 msgQ.bodyval = 0;
4062 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4063
4064 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304065 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004066 pMsgBuf = NULL;
4067 lim_log(pMac, LOGP, "Unable to forward request");
4068 return;
4069 }
4070
4071 return;
4072}
4073
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004074#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004075/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004076 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004077 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004078 * @pMac: Pointer to Global MAC structure
4079 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004080 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004081 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004082 */
4083static void
4084__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4085{
4086 tSirMsgQ msgQ;
4087
4088 msgQ.type = WMA_TSM_STATS_REQ;
4089 msgQ.reserved = 0;
4090 msgQ.bodyptr = pMsgBuf;
4091 msgQ.bodyval = 0;
4092 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4093
4094 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304095 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004096 pMsgBuf = NULL;
4097 lim_log(pMac, LOGP, "Unable to forward request");
4098 return;
4099 }
4100}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004101#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004102
4103static void
4104__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4105{
4106 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4107 tpPESession psessionEntry;
4108 uint8_t sessionId; /* PE sessionID */
4109
4110 PELOG1(lim_log(pMac, LOG1, FL("received UPDATE_APWPSIEs_REQ message")););
4111
4112 if (pMsgBuf == NULL) {
4113 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4114 return;
4115 }
4116
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304117 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004118 if (NULL == pUpdateAPWPSIEsReq) {
4119 lim_log(pMac, LOGP,
4120 FL
4121 ("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
4122 return;
4123 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304124 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004125 sizeof(struct sSirUpdateAPWPSIEsReq));
4126
4127 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08004128 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004129 &sessionId);
4130 if (psessionEntry == NULL) {
4131 lim_log(pMac, LOGW,
4132 FL("Session does not exist for given BSSID"));
4133 goto end;
4134 }
4135
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304136 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004137 sizeof(tSirAPWPSIEs));
4138
4139 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4140 lim_send_beacon_ind(pMac, psessionEntry);
4141
4142end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304143 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004144 return;
4145}
4146
4147void
4148lim_send_vdev_restart(tpAniSirGlobal pMac,
4149 tpPESession psessionEntry, uint8_t sessionId)
4150{
4151 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
4152 tSirMsgQ msgQ;
4153 tSirRetStatus retCode = eSIR_SUCCESS;
4154
4155 if (psessionEntry == NULL) {
4156 PELOGE(lim_log
4157 (pMac, LOGE, "%s:%d: Invalid parameters", __func__,
4158 __LINE__);
4159 )
4160 return;
4161 }
4162
4163 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304164 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004165 if (NULL == pHalHiddenSsidVdevRestart) {
4166 PELOGE(lim_log
4167 (pMac, LOGE, "%s:%d: Unable to allocate memory",
4168 __func__, __LINE__);
4169 )
4170 return;
4171 }
4172
4173 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4174 pHalHiddenSsidVdevRestart->sessionId = sessionId;
4175
4176 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4177 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4178 msgQ.bodyval = 0;
4179
4180 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4181 if (eSIR_SUCCESS != retCode) {
4182 PELOGE(lim_log
4183 (pMac, LOGE, "%s:%d: wma_post_ctrl_msg() failed", __func__,
4184 __LINE__);
4185 )
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304186 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004187 }
4188}
4189
4190static void __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4191{
4192 tpSirUpdateParams pUpdateParams;
4193 tpPESession psessionEntry;
4194
4195 PELOG1(lim_log(pMac, LOG1, FL("received HIDE_SSID message")););
4196
4197 if (pMsgBuf == NULL) {
4198 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4199 return;
4200 }
4201
4202 pUpdateParams = (tpSirUpdateParams) pMsgBuf;
4203
Naveen Rawat9e4872a2015-11-13 09:43:11 -08004204 psessionEntry = pe_find_session_by_sme_session_id(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004205 pUpdateParams->sessionId);
4206 if (psessionEntry == NULL) {
4207 lim_log(pMac, LOGW,
4208 "Session does not exist for given sessionId %d",
4209 pUpdateParams->sessionId);
4210 return;
4211 }
4212
4213 /* Update the session entry */
4214 psessionEntry->ssidHidden = pUpdateParams->ssidHidden;
4215
4216 /* Send vdev restart */
4217 lim_send_vdev_restart(pMac, psessionEntry, pUpdateParams->sessionId);
4218
4219 /* Update beacon */
4220 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4221 lim_send_beacon_ind(pMac, psessionEntry);
4222
4223 return;
4224} /*** end __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4225
4226static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4227{
4228 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4229 tpPESession psessionEntry;
4230 uint8_t sessionId; /* PE sessionID */
4231
4232 if (pMsgBuf == NULL) {
4233 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4234 return;
4235 }
4236
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304237 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004238 if (NULL == pUpdateAPWPARSNIEsReq) {
4239 lim_log(pMac, LOGP,
4240 FL
4241 ("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
4242 return;
4243 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304244 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004245 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4246
4247 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004248 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004249 &sessionId);
4250 if (psessionEntry == NULL) {
4251 lim_log(pMac, LOGW,
4252 FL("Session does not exist for given BSSID"));
4253 goto end;
4254 }
4255
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304256 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004257 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4258
4259 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4260 &psessionEntry->
4261 pLimStartBssReq->rsnIE,
4262 psessionEntry);
4263
4264 psessionEntry->pLimStartBssReq->privacy = 1;
4265 psessionEntry->privacy = 1;
4266
4267 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4268 lim_send_beacon_ind(pMac, psessionEntry);
4269
4270end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304271 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004272 return;
4273} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4274
4275/*
4276 Update the beacon Interval dynamically if beaconInterval is different in MCC
4277 */
4278static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4279{
4280 tpSirChangeBIParams pChangeBIParams;
4281 tpPESession psessionEntry;
4282 uint8_t sessionId = 0;
4283 tUpdateBeaconParams beaconParams;
4284
4285 PELOG1(lim_log(pMac, LOG1,
4286 FL("received Update Beacon Interval message"));
4287 );
4288
4289 if (pMsgBuf == NULL) {
4290 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4291 return;
4292 }
4293
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304294 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004295 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4296
4297 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004298 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004299 &sessionId);
4300 if (psessionEntry == NULL) {
4301 lim_log(pMac, LOGE,
4302 FL("Session does not exist for given BSSID"));
4303 return;
4304 }
4305
4306 /*Update sessionEntry Beacon Interval */
4307 if (psessionEntry->beaconParams.beaconInterval !=
4308 pChangeBIParams->beaconInterval) {
4309 psessionEntry->beaconParams.beaconInterval =
4310 pChangeBIParams->beaconInterval;
4311 }
4312
4313 /*Update sch beaconInterval */
4314 if (pMac->sch.schObject.gSchBeaconInterval !=
4315 pChangeBIParams->beaconInterval) {
4316 pMac->sch.schObject.gSchBeaconInterval =
4317 pChangeBIParams->beaconInterval;
4318
4319 PELOG1(lim_log(pMac, LOG1,
4320 FL
4321 ("LIM send update BeaconInterval Indication : %d"),
4322 pChangeBIParams->beaconInterval);
4323 );
4324
4325 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4326 /* Update beacon */
4327 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4328
4329 beaconParams.bssIdx = psessionEntry->bssIdx;
4330 /* Set change in beacon Interval */
4331 beaconParams.beaconInterval =
4332 pChangeBIParams->beaconInterval;
4333 beaconParams.paramChangeBitmap =
4334 PARAM_BCN_INTERVAL_CHANGED;
4335 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4336 }
4337 }
4338
4339 return;
4340} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4341
4342#ifdef QCA_HT_2040_COEX
4343static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4344 uint32_t *pMsgBuf)
4345{
4346 tpSirSetHT2040Mode pSetHT2040Mode;
4347 tpPESession psessionEntry;
4348 uint8_t sessionId = 0;
4349 cds_msg_t msg;
4350 tUpdateVHTOpMode *pHtOpMode = NULL;
4351 uint16_t staId = 0;
4352 tpDphHashNode pStaDs = NULL;
4353
4354 PELOG1(lim_log(pMac, LOG1, FL("received Set HT 20/40 mode message")););
4355 if (pMsgBuf == NULL) {
4356 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4357 return;
4358 }
4359
4360 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4361
4362 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004363 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004364 &sessionId);
4365 if (psessionEntry == NULL) {
4366 lim_log(pMac, LOG1,
4367 FL("Session does not exist for given BSSID "));
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004368 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004369 return;
4370 }
4371
4372 lim_log(pMac, LOG1, FL("Update session entry for cbMod=%d"),
4373 pSetHT2040Mode->cbMode);
4374 /*Update sessionEntry HT related fields */
4375 switch (pSetHT2040Mode->cbMode) {
4376 case PHY_SINGLE_CHANNEL_CENTERED:
4377 psessionEntry->htSecondaryChannelOffset =
4378 PHY_SINGLE_CHANNEL_CENTERED;
4379 psessionEntry->htRecommendedTxWidthSet = 0;
4380 if (pSetHT2040Mode->obssEnabled)
4381 psessionEntry->htSupportedChannelWidthSet
4382 = eHT_CHANNEL_WIDTH_40MHZ;
4383 else
4384 psessionEntry->htSupportedChannelWidthSet
4385 = eHT_CHANNEL_WIDTH_20MHZ;
4386 break;
4387 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4388 psessionEntry->htSecondaryChannelOffset =
4389 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4390 psessionEntry->htRecommendedTxWidthSet = 1;
4391 break;
4392 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4393 psessionEntry->htSecondaryChannelOffset =
4394 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4395 psessionEntry->htRecommendedTxWidthSet = 1;
4396 break;
4397 default:
4398 lim_log(pMac, LOGE, FL("Invalid cbMode"));
4399 return;
4400 }
4401
4402 /* Update beacon */
4403 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4404 lim_send_beacon_ind(pMac, psessionEntry);
4405
4406 /* update OP Mode for each associated peer */
4407 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4408 pStaDs = dph_get_hash_entry(pMac, staId,
4409 &psessionEntry->dph.dphHashTable);
4410 if (NULL == pStaDs)
4411 continue;
4412
4413 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304414 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004415 if (NULL == pHtOpMode) {
4416 lim_log(pMac, LOGE,
4417 FL
4418 ("%s: Not able to allocate memory for setting OP mode"),
4419 __func__);
4420 return;
4421 }
4422 pHtOpMode->opMode =
4423 (psessionEntry->htSecondaryChannelOffset ==
4424 PHY_SINGLE_CHANNEL_CENTERED) ?
4425 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4426 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304427 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004428 sizeof(tSirMacAddr));
4429 pHtOpMode->smesessionId = sessionId;
4430
4431 msg.type = WMA_UPDATE_OP_MODE;
4432 msg.reserved = 0;
4433 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304434 if (!QDF_IS_STATUS_SUCCESS
Anurag Chouhan6d760662016-02-20 16:05:43 +05304435 (cds_mq_post_message(QDF_MODULE_ID_WMA, &msg))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004436 lim_log(pMac, LOGE,
4437 FL
4438 ("%s: Not able to post WMA_UPDATE_OP_MODE message to WMA"),
4439 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304440 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004441 return;
4442 }
4443 lim_log(pMac, LOG1,
4444 FL
4445 ("%s: Notifed FW about OP mode: %d for staId=%d"),
4446 __func__, pHtOpMode->opMode, staId);
4447
4448 } else
4449 lim_log(pMac, LOG1,
4450 FL("%s: station %d does not support HT40\n"),
4451 __func__, staId);
4452 }
4453
4454 return;
4455}
4456#endif
4457
4458/* -------------------------------------------------------------------- */
4459/**
4460 * __lim_process_report_message
4461 *
4462 * FUNCTION: Processes the next received Radio Resource Management message
4463 *
4464 * LOGIC:
4465 *
4466 * ASSUMPTIONS:
4467 *
4468 * NOTE:
4469 *
4470 * @param None
4471 * @return None
4472 */
4473
4474void __lim_process_report_message(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4475{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004476 switch (pMsg->type) {
4477 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4478 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4479 break;
4480 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004481 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004482 break;
4483 default:
4484 lim_log(pMac, LOGE, FL("Invalid msg type:%d"), pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004485 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004486}
4487
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004488/* -------------------------------------------------------------------- */
4489/**
4490 * lim_send_set_max_tx_power_req
4491 *
4492 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4493 *
4494 * LOGIC:
4495 *
4496 * ASSUMPTIONS:
4497 *
4498 * NOTE:
4499 *
4500 * @param txPower txPower to be set.
4501 * @param pSessionEntry session entry.
4502 * @return None
4503 */
4504tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004505lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004506 tpPESession pSessionEntry)
4507{
4508 tpMaxTxPowerParams pMaxTxParams = NULL;
4509 tSirRetStatus retCode = eSIR_SUCCESS;
4510 tSirMsgQ msgQ;
4511
4512 if (pSessionEntry == NULL) {
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304513 lim_log(pMac, LOGE, FL("Inavalid parameters"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004514 return eSIR_FAILURE;
4515 }
4516
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304517 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004518 if (NULL == pMaxTxParams) {
4519 lim_log(pMac, LOGP,
4520 FL("Unable to allocate memory for pMaxTxParams "));
4521 return eSIR_MEM_ALLOC_FAILED;
4522
4523 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004524 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304525 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304526 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304527 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004528 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304529 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004530
4531 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4532 msgQ.bodyptr = pMaxTxParams;
4533 msgQ.bodyval = 0;
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304534 lim_log(pMac, LOG1, FL("Post WMA_SET_MAX_TX_POWER_REQ to WMA"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004535 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4536 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4537 if (eSIR_SUCCESS != retCode) {
4538 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304539 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004540 }
4541 return retCode;
4542}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004543
4544/**
4545 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4546 *
4547 * @mac_ctx: Pointer to Global MAC structure
4548 * @msg_buf: pointer to the SME message buffer
4549 *
4550 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4551 * from SME. It Register this information within PE.
4552 *
4553 * Return: None
4554 */
4555static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4556 uint32_t *msg_buf)
4557{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304558 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004559 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4560 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4561 struct mgmt_frm_reg_info *next = NULL;
4562 bool match = false;
4563
4564 lim_log(mac_ctx, LOG1, FL(
4565 "registerFrame %d, frameType %d, matchLen %d"),
4566 sme_req->registerFrame, sme_req->frameType,
4567 sme_req->matchLen);
4568 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304569 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304570 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4571 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304572 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004573
4574 while (lim_mgmt_regn != NULL) {
4575 if (lim_mgmt_regn->frameType != sme_req->frameType)
4576 goto skip_match;
4577 if (sme_req->matchLen) {
4578 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304579 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004580 sme_req->matchData,
4581 lim_mgmt_regn->matchLen))) {
4582 /* found match! */
4583 match = true;
4584 break;
4585 }
4586 } else {
4587 /* found match! */
4588 match = true;
4589 break;
4590 }
4591skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304592 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304593 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004594 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304595 (qdf_list_node_t *)lim_mgmt_regn,
4596 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304597 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004598 lim_mgmt_regn = next;
4599 next = NULL;
4600 }
4601 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304602 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304603 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004604 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304605 (qdf_list_node_t *)lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304606 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304607 qdf_mem_free(lim_mgmt_regn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004608 }
4609
4610 if (sme_req->registerFrame) {
4611 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304612 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004613 sme_req->matchLen);
4614 if (lim_mgmt_regn != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304615 qdf_mem_set((void *)lim_mgmt_regn,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004616 sizeof(struct mgmt_frm_reg_info) +
4617 sme_req->matchLen, 0);
4618 lim_mgmt_regn->frameType = sme_req->frameType;
4619 lim_mgmt_regn->matchLen = sme_req->matchLen;
4620 lim_mgmt_regn->sessionId = sme_req->sessionId;
4621 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304622 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004623 sme_req->matchData,
4624 sme_req->matchLen);
4625 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304626 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004627 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304628 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004629 gLimMgmtFrameRegistratinQueue,
4630 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304631 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004632 &mac_ctx->lim.lim_frame_register_lock);
4633 }
4634 }
4635 return;
4636}
4637
4638static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4639{
4640 lim_log(pMac, LOG1, FL("Dereg msgType %d"),
4641 pMac->lim.gDeferMsgTypeForNOA);
4642 pMac->lim.gDeferMsgTypeForNOA = 0;
4643 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4644 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304645 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004646 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4647 }
4648}
4649
4650/**
4651 * lim_process_regd_defd_sme_req_after_noa_start()
4652 *
4653 * mac_ctx: Pointer to Global MAC structure
4654 *
4655 * This function is called to process deferred sme req message
4656 * after noa start.
4657 *
4658 * Return: None
4659 */
4660void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4661{
4662 bool buf_consumed = true;
4663
4664 lim_log(mac_ctx, LOG1, FL("Process defd sme req %d"),
4665 mac_ctx->lim.gDeferMsgTypeForNOA);
4666
4667 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4668 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
4669 lim_log(mac_ctx, LOGW,
4670 FL("start rcvd from FW when no sme deferred msg pending. Do nothing. "));
4671 lim_log(mac_ctx, LOGW,
4672 FL("It may happen when NOA start ind and timeout happen at the same time"));
4673 return;
4674 }
4675 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4676 case eWNI_SME_SCAN_REQ:
4677 __lim_process_sme_scan_req(mac_ctx,
4678 mac_ctx->lim.gpDefdSmeMsgForNOA);
4679 break;
4680#ifdef FEATURE_OEM_DATA_SUPPORT
4681 case eWNI_SME_OEM_DATA_REQ:
4682 __lim_process_sme_oem_data_req(mac_ctx,
4683 mac_ctx->lim.gpDefdSmeMsgForNOA);
4684 break;
4685#endif
4686 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4687 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4688 mac_ctx->lim.gpDefdSmeMsgForNOA);
4689 /*
4690 * lim_process_remain_on_chnl_req doesnt want us to free
4691 * the buffer since it is freed in lim_remain_on_chn_rsp.
4692 * this change is to avoid "double free"
4693 */
4694 if (false == buf_consumed)
4695 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4696 break;
4697 case eWNI_SME_JOIN_REQ:
4698 __lim_process_sme_join_req(mac_ctx,
4699 mac_ctx->lim.gpDefdSmeMsgForNOA);
4700 break;
4701 default:
4702 lim_log(mac_ctx, LOGE, FL("Unknown deferred msg type %d"),
4703 mac_ctx->lim.gDeferMsgTypeForNOA);
4704 break;
4705 }
4706 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4707}
4708
4709static void
4710__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4711{
4712 tpSirResetAPCapsChange pResetCapsChange;
4713 tpPESession psessionEntry;
4714 uint8_t sessionId = 0;
4715 if (pMsgBuf == NULL) {
4716 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4717 return;
4718 }
4719
4720 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4721 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004722 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4723 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004724 if (psessionEntry == NULL) {
4725 lim_log(pMac, LOGE,
4726 FL("Session does not exist for given BSSID"));
4727 return;
4728 }
4729
4730 psessionEntry->limSentCapsChangeNtf = false;
4731 return;
4732}
4733
4734/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304735 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4736 * indication callback in PE.
4737 * @mac_ptr: Mac pointer
4738 * @msg_buf: Msg pointer containing the callback
4739 *
4740 * This function is used save the Management frame
4741 * indication callback in PE.
4742 *
4743 * Return: None
4744 */
4745static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4746 uint32_t *msg_buf)
4747{
4748 struct sir_sme_mgmt_frame_cb_req *sme_req =
4749 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4750
4751 if (NULL == msg_buf) {
4752 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4753 return;
4754 }
4755 if (sme_req->callback)
4756 mac_ctx->mgmt_frame_ind_cb =
4757 (sir_mgmt_frame_ind_callback)sme_req->callback;
4758 else
4759 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4760}
4761
4762/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004763 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4764 * @mac_ctx: Pointer to Global MAC structure
4765 * @pdev_id: pdev id to set the IE.
4766 * @nss: Nss values to prepare the HT IE.
4767 *
4768 * Prepares the HT IE with self capabilities for different
4769 * Nss values and sends the set HT IE req to FW.
4770 *
4771 * Return: None
4772 */
4773static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4774 uint8_t nss)
4775{
4776 struct set_ie_param *ie_params;
4777 tSirMsgQ msg;
4778 tSirRetStatus rc = eSIR_SUCCESS;
4779 uint8_t *p_ie = NULL;
4780 tHtCaps *p_ht_cap;
4781 int i;
4782
4783 for (i = nss; i > 0; i--) {
4784 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4785 if (NULL == ie_params) {
4786 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4787 return;
4788 }
4789 ie_params->nss = i;
4790 ie_params->pdev_id = pdev_id;
4791 ie_params->ie_type = DOT11_HT_IE;
4792 /* 2 for IE len and EID */
4793 ie_params->ie_len = 2 + sizeof(tHtCaps);
4794 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4795 if (NULL == ie_params->ie_ptr) {
4796 qdf_mem_free(ie_params);
4797 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4798 return;
4799 }
4800 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4801 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4802 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4803 ie_params->ie_len);
4804
4805 if (NSS_1x1_MODE == i) {
4806 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4807 ie_params->ie_len,
4808 DOT11F_EID_HTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004809 if (NULL == p_ie) {
4810 qdf_mem_free(ie_params->ie_ptr);
4811 qdf_mem_free(ie_params);
4812 lim_log(mac_ctx, LOGE,
4813 FL("failed to get IE ptr"));
4814 return;
4815 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004816 p_ht_cap = (tHtCaps *)&p_ie[2];
4817 p_ht_cap->supportedMCSSet[1] = 0;
4818 p_ht_cap->txSTBC = 0;
4819 }
4820
4821 msg.type = WMA_SET_PDEV_IE_REQ;
4822 msg.bodyptr = ie_params;
4823 msg.bodyval = 0;
4824
4825 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4826 if (rc != eSIR_SUCCESS) {
4827 lim_log(mac_ctx, LOGE,
4828 FL("wma_post_ctrl_msg() return failure"));
4829 qdf_mem_free(ie_params->ie_ptr);
4830 qdf_mem_free(ie_params);
4831 return;
4832 }
4833 }
4834}
4835
4836/**
4837 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4838 * @mac_ctx: Pointer to Global MAC structure
4839 * @pdev_id: pdev id to set the IE.
4840 * @nss: Nss values to prepare the VHT IE.
4841 *
4842 * Prepares the VHT IE with self capabilities for different
4843 * Nss values and sends the set VHT IE req to FW.
4844 *
4845 * Return: None
4846 */
4847static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4848 uint8_t nss)
4849{
4850 struct set_ie_param *ie_params;
4851 tSirMsgQ msg;
4852 tSirRetStatus rc = eSIR_SUCCESS;
4853 uint8_t *p_ie = NULL;
4854 tSirMacVHTCapabilityInfo *vht_cap;
4855 int i;
4856 tSirVhtMcsInfo *vht_mcs;
4857
4858 for (i = nss; i > 0; i--) {
4859 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4860 if (NULL == ie_params) {
4861 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4862 return;
4863 }
4864 ie_params->nss = i;
4865 ie_params->pdev_id = pdev_id;
4866 ie_params->ie_type = DOT11_VHT_IE;
4867 /* 2 for IE len and EID */
4868 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4869 sizeof(tSirVhtMcsInfo);
4870 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4871 if (NULL == ie_params->ie_ptr) {
4872 qdf_mem_free(ie_params);
4873 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4874 return;
4875 }
4876 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4877 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4878 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4879 ie_params->ie_len);
4880
4881 if (NSS_1x1_MODE == i) {
4882 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4883 ie_params->ie_len,
4884 DOT11F_EID_VHTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004885 if (NULL == p_ie) {
4886 qdf_mem_free(ie_params->ie_ptr);
4887 qdf_mem_free(ie_params);
4888 lim_log(mac_ctx, LOGE,
4889 FL("failed to get IE ptr"));
4890 return;
4891 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004892 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4893 vht_cap->txSTBC = 0;
4894 vht_mcs =
4895 (tSirVhtMcsInfo *)&p_ie[2 +
4896 sizeof(tSirMacVHTCapabilityInfo)];
4897 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4898 vht_mcs->rxHighest =
4899 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4900 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4901 vht_mcs->txHighest =
4902 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4903 }
4904 msg.type = WMA_SET_PDEV_IE_REQ;
4905 msg.bodyptr = ie_params;
4906 msg.bodyval = 0;
4907
4908 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4909 if (rc != eSIR_SUCCESS) {
4910 lim_log(mac_ctx, LOGE,
4911 FL("wma_post_ctrl_msg failure"));
4912 qdf_mem_free(ie_params->ie_ptr);
4913 qdf_mem_free(ie_params);
4914 return;
4915 }
4916 }
4917}
4918
4919/**
4920 * lim_process_set_pdev_IEs() - process the set pdev IE req
4921 * @mac_ctx: Pointer to Global MAC structure
4922 * @msg_buf: Pointer to the SME message buffer
4923 *
4924 * This function is called by limProcessMessageQueue(). This
4925 * function sets the PDEV IEs to the FW.
4926 *
4927 * Return: None
4928 */
4929static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4930{
4931 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4932
4933 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4934
4935 if (NULL == ht_vht_cfg) {
4936 lim_log(mac_ctx, LOGE, FL("NULL ht_vht_cfg"));
4937 return;
4938 }
4939
4940 lim_log(mac_ctx, LOG1, FL("rcvd set pdev ht vht ie req with nss = %d"),
4941 ht_vht_cfg->nss);
4942 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4943
4944 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4945 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4946 ht_vht_cfg->nss);
4947}
4948
4949/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004950 * lim_process_sme_req_messages()
4951 *
4952 ***FUNCTION:
4953 * This function is called by limProcessMessageQueue(). This
4954 * function processes SME request messages from HDD or upper layer
4955 * application.
4956 *
4957 ***LOGIC:
4958 *
4959 ***ASSUMPTIONS:
4960 *
4961 ***NOTE:
4962 *
4963 * @param pMac Pointer to Global MAC structure
4964 * @param msgType Indicates the SME message type
4965 * @param *pMsgBuf A pointer to the SME message buffer
4966 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4967 * false - if pMsgBuf is not to be freed.
4968 */
4969
4970bool lim_process_sme_req_messages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4971{
4972 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
4973 uint32_t *pMsgBuf = pMsg->bodyptr;
4974 tpSirSmeScanReq pScanReq;
4975 PELOG1(lim_log
4976 (pMac, LOG1,
4977 FL
4978 ("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)"),
4979 lim_msg_str(pMsg->type), pMsg->type,
4980 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4981 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
4982 )
4983
4984 pScanReq = (tpSirSmeScanReq) pMsgBuf;
4985 /* If no insert NOA required then execute the code below */
4986
4987 switch (pMsg->type) {
4988 case eWNI_SME_SYS_READY_IND:
4989 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4990 break;
4991
4992 case eWNI_SME_START_BSS_REQ:
4993 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4994 break;
4995
4996 case eWNI_SME_SCAN_REQ:
4997 __lim_process_sme_scan_req(pMac, pMsgBuf);
4998 break;
4999
5000#ifdef FEATURE_OEM_DATA_SUPPORT
5001 case eWNI_SME_OEM_DATA_REQ:
5002 __lim_process_sme_oem_data_req(pMac, pMsgBuf);
5003 break;
5004#endif
5005 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5006 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
5007 break;
5008
5009 case eWNI_SME_UPDATE_NOA:
5010 __lim_process_sme_no_a_update(pMac, pMsgBuf);
5011 break;
5012 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
5013 __lim_process_clear_dfs_channel_list(pMac, pMsg);
5014 break;
5015 case eWNI_SME_JOIN_REQ:
5016 __lim_process_sme_join_req(pMac, pMsgBuf);
5017 break;
5018
5019 case eWNI_SME_REASSOC_REQ:
5020 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
5021 break;
5022
5023 case eWNI_SME_DISASSOC_REQ:
5024 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
5025 break;
5026
5027 case eWNI_SME_DISASSOC_CNF:
5028 case eWNI_SME_DEAUTH_CNF:
5029 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
5030 break;
5031
5032 case eWNI_SME_DEAUTH_REQ:
5033 __lim_process_sme_deauth_req(pMac, pMsgBuf);
5034 break;
5035
5036 case eWNI_SME_SETCONTEXT_REQ:
5037 __lim_process_sme_set_context_req(pMac, pMsgBuf);
5038 break;
5039
5040 case eWNI_SME_STOP_BSS_REQ:
5041 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
5042 break;
5043
5044 case eWNI_SME_ASSOC_CNF:
5045 if (pMsg->type == eWNI_SME_ASSOC_CNF)
5046 PELOG1(lim_log(pMac,
5047 LOG1, FL("Received ASSOC_CNF message"));)
5048 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
5049 pMsgBuf);
5050 break;
5051
5052 case eWNI_SME_ADDTS_REQ:
5053 PELOG1(lim_log(pMac, LOG1, FL("Received ADDTS_REQ message"));)
5054 __lim_process_sme_addts_req(pMac, pMsgBuf);
5055 break;
5056
5057 case eWNI_SME_DELTS_REQ:
5058 PELOG1(lim_log(pMac, LOG1, FL("Received DELTS_REQ message"));)
5059 __lim_process_sme_delts_req(pMac, pMsgBuf);
5060 break;
5061
5062 case SIR_LIM_ADDTS_RSP_TIMEOUT:
5063 PELOG1(lim_log
5064 (pMac, LOG1,
5065 FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
5066 )
5067 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
5068 break;
5069
5070 case eWNI_SME_GET_STATISTICS_REQ:
5071 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
5072 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
5073 bufConsumed = false;
5074 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005075#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005076 case eWNI_SME_GET_TSM_STATS_REQ:
5077 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
5078 bufConsumed = false;
5079 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005080#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005081 case eWNI_SME_GET_ASSOC_STAS_REQ:
5082 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
5083 break;
5084 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5085 lim_process_tkip_counter_measures(pMac, pMsgBuf);
5086 break;
5087
5088 case eWNI_SME_HIDE_SSID_REQ:
5089 __lim_process_sme_hide_ssid(pMac, pMsgBuf);
5090 break;
5091 case eWNI_SME_UPDATE_APWPSIE_REQ:
5092 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
5093 break;
5094 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5095 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
5096 break;
5097
5098 case eWNI_SME_SET_APWPARSNIEs_REQ:
5099 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
5100 break;
5101
5102 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5103 /* Update the beaconInterval */
5104 __lim_process_sme_change_bi(pMac, pMsgBuf);
5105 break;
5106
5107#ifdef QCA_HT_2040_COEX
5108 case eWNI_SME_SET_HT_2040_MODE:
5109 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
5110 break;
5111#endif
5112
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005113 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5114 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5115 __lim_process_report_message(pMac, pMsg);
5116 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005117
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005118 case eWNI_SME_FT_PRE_AUTH_REQ:
5119 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
5120 break;
5121 case eWNI_SME_FT_UPDATE_KEY:
5122 lim_process_ft_update_key(pMac, pMsgBuf);
5123 break;
5124
5125 case eWNI_SME_FT_AGGR_QOS_REQ:
5126 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
5127 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005128
5129 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5130 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
5131 break;
5132#ifdef FEATURE_WLAN_TDLS
5133 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5134 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
5135 break;
5136 case eWNI_SME_TDLS_ADD_STA_REQ:
5137 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
5138 break;
5139 case eWNI_SME_TDLS_DEL_STA_REQ:
5140 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
5141 break;
5142 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5143 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
5144 break;
5145#endif
5146 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5147 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
5148 break;
5149
5150 case eWNI_SME_CHANNEL_CHANGE_REQ:
5151 lim_process_sme_channel_change_request(pMac, pMsgBuf);
5152 break;
5153
5154 case eWNI_SME_START_BEACON_REQ:
5155 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
5156 break;
5157
5158 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
5159 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
5160 break;
5161
5162 case eWNI_SME_UPDATE_ADDITIONAL_IES:
5163 lim_process_update_add_ies(pMac, pMsgBuf);
5164 break;
5165
5166 case eWNI_SME_MODIFY_ADDITIONAL_IES:
5167 lim_process_modify_add_ies(pMac, pMsgBuf);
5168 break;
5169 case eWNI_SME_SET_HW_MODE_REQ:
5170 lim_process_set_hw_mode(pMac, pMsgBuf);
5171 break;
5172 case eWNI_SME_NSS_UPDATE_REQ:
5173 lim_process_nss_update_request(pMac, pMsgBuf);
5174 break;
5175 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5176 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5177 break;
5178 case eWNI_SME_SET_IE_REQ:
5179 lim_process_set_ie_req(pMac, pMsgBuf);
5180 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305181 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5182 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5183 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305184 case eWNI_SME_EXT_CHANGE_CHANNEL:
5185 lim_process_ext_change_channel(pMac, pMsgBuf);
5186 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005187 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5188 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5189 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005190 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5191 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawatf28315c2016-06-29 18:06:02 -07005192 case eWNI_SME_NDP_END_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005193 case eWNI_SME_NDP_INITIATOR_REQ:
Abhishek Singh4fef7472016-06-06 11:36:03 -07005194 case eWNI_SME_NDP_RESPONDER_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005195 lim_handle_ndp_request_message(pMac, pMsg);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005196 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005197 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305198 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005199 pMsg->bodyptr = NULL;
5200 break;
5201 } /* switch (msgType) */
5202
5203 return bufConsumed;
5204} /*** end lim_process_sme_req_messages() ***/
5205
5206/**
5207 * lim_process_sme_start_beacon_req()
5208 *
5209 ***FUNCTION:
5210 * This function is called by limProcessMessageQueue(). This
5211 * function processes SME request messages from HDD or upper layer
5212 * application.
5213 *
5214 ***LOGIC:
5215 *
5216 ***ASSUMPTIONS:
5217 *
5218 ***NOTE:
5219 *
5220 * @param pMac Pointer to Global MAC structure
5221 * @param msgType Indicates the SME message type
5222 * @param *pMsgBuf A pointer to the SME message buffer
5223 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5224 * false - if pMsgBuf is not to be freed.
5225 */
5226static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5227{
5228 tpSirStartBeaconIndication pBeaconStartInd;
5229 tpPESession psessionEntry;
5230 uint8_t sessionId; /* PE sessionID */
5231
5232 if (pMsg == NULL) {
5233 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
5234 return;
5235 }
5236
5237 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5238 psessionEntry = pe_find_session_by_bssid(pMac,
5239 pBeaconStartInd->bssid,
5240 &sessionId);
5241 if (psessionEntry == NULL) {
5242 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
5243 lim_log(pMac, LOGE,
5244 FL("Session does not exist for given bssId"));
5245 return;
5246 }
5247
5248 if (pBeaconStartInd->beaconStartStatus == true) {
5249 /*
5250 * Currently this Indication comes from SAP
5251 * to start Beacon Tx on a DFS channel
5252 * since beaconing has to be done on DFS
5253 * channel only after CAC WAIT is completed.
5254 * On a DFS Channel LIM does not start beacon
5255 * Tx right after the WMA_ADD_BSS_RSP.
5256 */
5257 lim_apply_configuration(pMac, psessionEntry);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305258 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005259 FL("Start Beacon with ssid %s Ch %d"),
5260 psessionEntry->ssId.ssId,
5261 psessionEntry->currentOperChannel);
5262 lim_send_beacon_ind(pMac, psessionEntry);
5263 } else {
5264 lim_log(pMac, LOGE, FL("Invalid Beacon Start Indication"));
5265 return;
5266 }
5267}
5268
5269/**
5270 * lim_process_sme_channel_change_request() - process sme ch change req
5271 *
5272 * @mac_ctx: Pointer to Global MAC structure
5273 * @msg_buf: pointer to the SME message buffer
5274 *
5275 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5276 *
5277 * Return: None
5278 */
5279static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5280 uint32_t *msg_buf)
5281{
5282 tpSirChanChangeRequest ch_change_req;
5283 tpPESession session_entry;
5284 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005285 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005286 uint32_t val = 0;
5287
5288 if (msg_buf == NULL) {
5289 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5290 return;
5291 }
5292 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5293
5294 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5295 ch_change_req->targetChannel);
5296
5297 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5298 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
5299 lim_log(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5300 return;
5301 }
5302
5303 session_entry = pe_find_session_by_bssid(mac_ctx,
5304 ch_change_req->bssid, &session_id);
5305 if (session_entry == NULL) {
5306 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
5307 lim_log(mac_ctx, LOGE, FL(
5308 "Session does not exist for given bssId"));
5309 return;
5310 }
5311
5312 if (session_entry->currentOperChannel ==
5313 ch_change_req->targetChannel) {
5314 lim_log(mac_ctx, LOGE, FL("target CH is same as current CH"));
5315 return;
5316 }
5317
5318 if (LIM_IS_AP_ROLE(session_entry))
5319 session_entry->channelChangeReasonCode =
5320 LIM_SWITCH_CHANNEL_SAP_DFS;
5321 else
5322 session_entry->channelChangeReasonCode =
5323 LIM_SWITCH_CHANNEL_OPERATION;
5324
5325 lim_log(mac_ctx, LOGW, FL(
5326 "switch old chnl %d to new chnl %d, ch_bw %d"),
5327 session_entry->currentOperChannel,
5328 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005329 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005330
5331 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005332 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005333 session_entry->ch_center_freq_seg0 =
5334 ch_change_req->center_freq_seg_0;
5335 session_entry->ch_center_freq_seg1 =
5336 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005337 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005338 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005339 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005340 session_entry->htRecommendedTxWidthSet =
5341 session_entry->htSupportedChannelWidthSet;
5342 session_entry->currentOperChannel =
5343 ch_change_req->targetChannel;
5344 session_entry->limRFBand =
5345 lim_get_rf_band(session_entry->currentOperChannel);
5346 /* Initialize 11h Enable Flag */
5347 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5348 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5349 eSIR_SUCCESS)
5350 lim_log(mac_ctx, LOGP,
5351 FL("Fail to get WNI_CFG_11H_ENABLED"));
5352 }
5353
5354 session_entry->lim11hEnable = val;
5355 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305356 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005357 &ch_change_req->operational_rateset,
5358 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305359 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005360 &ch_change_req->extended_rateset,
5361 sizeof(session_entry->extRateSet));
5362 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5363 session_entry->ch_center_freq_seg0,
5364 session_entry->ch_center_freq_seg1,
5365 session_entry->ch_width,
5366 max_tx_pwr, session_entry->peSessionId);
5367}
5368
5369/******************************************************************************
5370* lim_start_bss_update_add_ie_buffer()
5371*
5372***FUNCTION:
5373* This function checks the src buffer and its length and then malloc for
5374* dst buffer update the same
5375*
5376***LOGIC:
5377*
5378***ASSUMPTIONS:
5379*
5380***NOTE:
5381*
5382* @param pMac Pointer to Global MAC structure
5383* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5384* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5385* @param *pSrcData_buff A pointer of uint8_t src buffer
5386* @param srcDataLen src buffer length
5387******************************************************************************/
5388
5389static void
5390lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5391 uint8_t **pDstData_buff,
5392 uint16_t *pDstDataLen,
5393 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5394{
5395
5396 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5397 *pDstDataLen = srcDataLen;
5398
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305399 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005400
5401 if (NULL == *pDstData_buff) {
5402 lim_log(pMac, LOGE,
5403 FL("AllocateMemory failed for pDstData_buff"));
5404 return;
5405 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305406 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005407 } else {
5408 *pDstData_buff = NULL;
5409 *pDstDataLen = 0;
5410 }
5411}
5412
5413/******************************************************************************
5414* lim_update_add_ie_buffer()
5415*
5416***FUNCTION:
5417* This function checks the src buffer and length if src buffer length more
5418* than dst buffer length then free the dst buffer and malloc for the new src
5419* length, and update the dst buffer and length. But if dst buffer is bigger
5420* than src buffer length then it just update the dst buffer and length
5421*
5422***LOGIC:
5423*
5424***ASSUMPTIONS:
5425*
5426***NOTE:
5427*
5428* @param pMac Pointer to Global MAC structure
5429* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5430* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5431* @param *pSrcData_buff A pointer of uint8_t src buffer
5432* @param srcDataLen src buffer length
5433******************************************************************************/
5434
5435static void
5436lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5437 uint8_t **pDstData_buff,
5438 uint16_t *pDstDataLen,
5439 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5440{
5441
5442 if (NULL == pSrcData_buff) {
5443 lim_log(pMac, LOGE, FL("src buffer is null."));
5444 return;
5445 }
5446
5447 if (srcDataLen > *pDstDataLen) {
5448 *pDstDataLen = srcDataLen;
5449 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305450 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005451 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305452 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005453
5454 if (NULL == *pDstData_buff) {
5455 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5456 *pDstDataLen = 0;
5457 return;
5458 }
5459 }
5460
5461 /* copy the content of buffer into dst buffer
5462 */
5463 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305464 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005465
5466}
5467
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005468/**
5469 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5470 * @pMac : Pointer to Global MAC structure
5471 * @pDstData_buff : A pointer to pointer of dst buffer
5472 * @pDstDataLen : A pointer to pointer of dst buffer length
5473 * @pModifyIE : A pointer to tSirModifyIE
5474 *
5475 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5476 *
5477 * Return:
5478 * True or false depending upon whether IE is updated or not
5479 */
5480static bool
5481lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5482 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5483{
5484 int32_t oui_length;
5485 uint8_t *ibss_ie = NULL;
5486
5487 ibss_ie = pModifyIE->pIEBuffer;
5488 oui_length = pModifyIE->oui_length;
5489
5490 if ((0 == oui_length) || (NULL == ibss_ie)) {
5491 PELOGE(lim_log(pMac, LOGE,
5492 FL("Invalid set IBSS vendor IE command length %d "),
5493 oui_length);)
5494 return false;
5495 }
5496
5497 lim_update_add_ie_buffer(pMac,
5498 pDstData_buff,
5499 pDstDataLen,
5500 pModifyIE->pIEBuffer,
5501 pModifyIE->ieBufferlength);
5502
5503 return true;
5504}
5505
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005506/*
5507* lim_process_modify_add_ies() - process modify additional IE req.
5508*
5509* @mac_ctx: Pointer to Global MAC structure
5510* @msg_buf: pointer to the SME message buffer
5511*
5512* This function update the PE buffers for additional IEs.
5513*
5514* Return: None
5515*/
5516static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5517 uint32_t *msg_buf)
5518{
5519 tpSirModifyIEsInd modify_add_ies;
5520 tpPESession session_entry;
5521 uint8_t session_id;
5522 bool ret = false;
5523 tSirAddIeParams *add_ie_params;
5524
5525 if (msg_buf == NULL) {
5526 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5527 return;
5528 }
5529
5530 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5531 /* Incoming message has smeSession, use BSSID to find PE session */
5532 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005533 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005534
5535 if (NULL == session_entry) {
5536 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5537 MAC_ADDRESS_STR),
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005538 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005539 goto end;
5540 }
5541 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5542 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5543 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
5544 lim_log(mac_ctx, LOGE,
5545 FL("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d"),
5546 modify_add_ies->modifyIE.pIEBuffer,
5547 modify_add_ies->modifyIE.ieBufferlength,
5548 modify_add_ies->modifyIE.ieID,
5549 modify_add_ies->modifyIE.ieIDLen,
5550 modify_add_ies->updateType);
5551 goto end;
5552 }
5553 add_ie_params = &session_entry->addIeParams;
5554 switch (modify_add_ies->updateType) {
5555 case eUPDATE_IE_PROBE_RESP:
5556 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005557 if (LIM_IS_IBSS_ROLE(session_entry)) {
5558 lim_update_ibss_prop_add_ies(mac_ctx,
5559 &add_ie_params->probeRespData_buff,
5560 &add_ie_params->probeRespDataLen,
5561 &modify_add_ies->modifyIE);
5562 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005563 break;
5564 case eUPDATE_IE_ASSOC_RESP:
5565 /* assoc resp IE */
5566 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305567 QDF_TRACE(QDF_MODULE_ID_PE,
5568 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005569 "assoc resp add ie not present %d"),
5570 add_ie_params->assocRespDataLen);
5571 }
5572 /* search through the buffer and modify the IE */
5573 break;
5574 case eUPDATE_IE_PROBE_BCN:
5575 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005576 if (LIM_IS_IBSS_ROLE(session_entry)) {
5577 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5578 &add_ie_params->probeRespBCNData_buff,
5579 &add_ie_params->probeRespBCNDataLen,
5580 &modify_add_ies->modifyIE);
5581 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005582 if (ret == true && modify_add_ies->modifyIE.notify) {
5583 lim_handle_param_update(mac_ctx,
5584 modify_add_ies->updateType);
5585 }
5586 break;
5587 default:
5588 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d"),
5589 modify_add_ies->updateType);
5590 break;
5591 }
5592end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305593 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005594 modify_add_ies->modifyIE.pIEBuffer = NULL;
5595}
5596
5597/*
5598* lim_process_update_add_ies() - process additional IE update req
5599*
5600* @mac_ctx: Pointer to Global MAC structure
5601* @msg_buf: pointer to the SME message buffer
5602*
5603* This function update the PE buffers for additional IEs.
5604*
5605* Return: None
5606*/
5607static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5608 uint32_t *msg_buf)
5609{
5610 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5611 uint8_t session_id;
5612 tpPESession session_entry;
5613 tSirAddIeParams *addn_ie;
5614 uint16_t new_length = 0;
5615 uint8_t *new_ptr = NULL;
5616 tSirUpdateIE *update_ie;
5617
5618 if (msg_buf == NULL) {
5619 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5620 return;
5621 }
5622 update_ie = &update_add_ies->updateIE;
5623 /* incoming message has smeSession, use BSSID to find PE session */
5624 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005625 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005626
5627 if (NULL == session_entry) {
5628 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5629 MAC_ADDRESS_STR),
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005630 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005631 goto end;
5632 }
5633 addn_ie = &session_entry->addIeParams;
5634 /* if len is 0, upper layer requested freeing of buffer */
5635 if (0 == update_ie->ieBufferlength) {
5636 switch (update_add_ies->updateType) {
5637 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305638 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005639 addn_ie->probeRespData_buff = NULL;
5640 addn_ie->probeRespDataLen = 0;
5641 break;
5642 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305643 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005644 addn_ie->assocRespData_buff = NULL;
5645 addn_ie->assocRespDataLen = 0;
5646 break;
5647 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305648 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005649 addn_ie->probeRespBCNData_buff = NULL;
5650 addn_ie->probeRespBCNDataLen = 0;
5651
5652 if (update_ie->notify)
5653 lim_handle_param_update(mac_ctx,
5654 update_add_ies->updateType);
5655 break;
5656 default:
5657 break;
5658 }
5659 return;
5660 }
5661 switch (update_add_ies->updateType) {
5662 case eUPDATE_IE_PROBE_RESP:
5663 if (update_ie->append) {
5664 /*
5665 * In case of append, allocate new memory
5666 * with combined length
5667 */
5668 new_length = update_ie->ieBufferlength +
5669 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305670 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005671 if (NULL == new_ptr) {
5672 lim_log(mac_ctx, LOGE, FL(
5673 "Memory allocation failed."));
5674 goto end;
5675 }
5676 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305677 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005678 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305679 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005680 update_ie->pAdditionIEBuffer,
5681 update_ie->ieBufferlength);
5682 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305683 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005684 /* adjust length accordingly */
5685 addn_ie->probeRespDataLen = new_length;
5686 /* save refernece of local buffer in PE session */
5687 addn_ie->probeRespData_buff = new_ptr;
5688 goto end;
5689 }
5690 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5691 &addn_ie->probeRespDataLen,
5692 update_ie->pAdditionIEBuffer,
5693 update_ie->ieBufferlength);
5694 break;
5695 case eUPDATE_IE_ASSOC_RESP:
5696 /* assoc resp IE */
5697 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5698 &addn_ie->assocRespDataLen,
5699 update_ie->pAdditionIEBuffer,
5700 update_ie->ieBufferlength);
5701 break;
5702 case eUPDATE_IE_PROBE_BCN:
5703 /* probe resp Bcn IE */
5704 lim_update_add_ie_buffer(mac_ctx,
5705 &addn_ie->probeRespBCNData_buff,
5706 &addn_ie->probeRespBCNDataLen,
5707 update_ie->pAdditionIEBuffer,
5708 update_ie->ieBufferlength);
5709 if (update_ie->notify)
5710 lim_handle_param_update(mac_ctx,
5711 update_add_ies->updateType);
5712 break;
5713 default:
5714 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d."),
5715 update_add_ies->updateType);
5716 break;
5717 }
5718end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305719 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005720 update_ie->pAdditionIEBuffer = NULL;
5721}
5722
5723/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305724 * send_extended_chan_switch_action_frame()- function to send ECSA
5725 * action frame for each sta connected to SAP/GO and AP in case of
5726 * STA .
5727 * @mac_ctx: pointer to global mac structure
5728 * @new_channel: new channel to switch to.
5729 * @ch_bandwidth: BW of channel to calculate op_class
5730 * @session_entry: pe session
5731 *
5732 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5733 *
5734 * Return: void
5735 */
5736
5737static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5738 uint16_t new_channel, uint8_t ch_bandwidth,
5739 tpPESession session_entry)
5740{
5741 uint16_t op_class;
5742 uint8_t switch_mode = 0, i;
5743 tpDphHashNode psta;
5744
5745
Amar Singhal22995112016-01-22 10:42:33 -08005746 op_class = cds_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305747 mac_ctx->scan.countryCodeCurrent,
5748 new_channel,
5749 ch_bandwidth);
5750
5751 if (LIM_IS_AP_ROLE(session_entry) &&
5752 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
5753 switch_mode = 1;
5754
5755 if (LIM_IS_AP_ROLE(session_entry)) {
5756 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5757 psta =
5758 session_entry->dph.dphHashTable.pDphNodeArray + i;
5759 if (psta && psta->added)
5760 lim_send_extended_chan_switch_action_frame(
5761 mac_ctx,
5762 psta->staAddr,
5763 switch_mode, op_class, new_channel,
5764 LIM_MAX_CSA_IE_UPDATES, session_entry);
5765 }
5766 } else if (LIM_IS_STA_ROLE(session_entry)) {
5767 lim_send_extended_chan_switch_action_frame(mac_ctx,
5768 session_entry->bssId,
5769 switch_mode, op_class, new_channel,
5770 LIM_MAX_CSA_IE_UPDATES, session_entry);
5771 }
5772
5773}
5774
5775/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005776 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5777 *
5778 * @mac_ctx: Pointer to Global MAC structure
5779 * @msg_buf: pointer to the SME message buffer
5780 *
5781 * This function processes SME request messages from HDD or upper layer
5782 * application.
5783 *
5784 * Return: None
5785 */
5786static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5787 uint32_t *msg_buf)
5788{
5789 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5790 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005791 uint8_t session_id;
5792 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005793 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005794
5795 if (msg_buf == NULL) {
5796 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5797 return;
5798 }
5799
5800 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5801 session_entry = pe_find_session_by_bssid(mac_ctx,
5802 dfs_csa_ie_req->bssid, &session_id);
5803 if (session_entry == NULL) {
5804 lim_log(mac_ctx, LOGE, FL(
5805 "Session not found for given BSSID" MAC_ADDRESS_STR),
5806 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5807 return;
5808 }
5809
5810 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5811 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5812 GET_LIM_SYSTEM_ROLE(session_entry));
5813 return;
5814 }
5815
5816 /* target channel */
5817 session_entry->gLimChannelSwitch.primaryChannel =
5818 dfs_csa_ie_req->targetChannel;
5819
5820 /* Channel switch announcement needs to be included in beacon */
5821 session_entry->dfsIncludeChanSwIe = true;
5822 session_entry->gLimChannelSwitch.switchCount = LIM_MAX_CSA_IE_UPDATES;
5823 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005824 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305825 session_entry->gLimChannelSwitch.sec_ch_offset =
5826 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005827 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
5828 session_entry->gLimChannelSwitch.switchMode = 1;
5829
5830 /*
5831 * Validate if SAP is operating HT or VHT mode and set the Channel
5832 * Switch Wrapper element with the Wide Band Switch subelement.
5833 */
5834 if (true != session_entry->vhtCapability)
5835 goto skip_vht;
5836
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005837 /* Now encode the Wider Ch BW element depending on the ch width */
5838 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005839 switch (dfs_csa_ie_req->ch_params.ch_width) {
5840 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005841 /*
5842 * Wide channel BW sublement in channel wrapper element is not
5843 * required in case of 20 Mhz operation. Currently It is set
5844 * only set in case of 40/80 Mhz Operation.
5845 */
5846 session_entry->dfsIncludeChanWrapperIe = false;
5847 wider_bw_ch_switch->newChanWidth =
5848 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5849 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005850 case CH_WIDTH_40MHZ:
5851 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005852 wider_bw_ch_switch->newChanWidth =
5853 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5854 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005855 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005856 session_entry->dfsIncludeChanWrapperIe = true;
5857 wider_bw_ch_switch->newChanWidth =
5858 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5859 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005860 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005861 session_entry->dfsIncludeChanWrapperIe = true;
5862 wider_bw_ch_switch->newChanWidth =
5863 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5864 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005865 case CH_WIDTH_80P80MHZ:
5866 session_entry->dfsIncludeChanWrapperIe = true;
5867 wider_bw_ch_switch->newChanWidth =
5868 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005869 /*
5870 * This is not applicable for 20/40/80 Mhz.
5871 * Only used when we support 80+80 Mhz operation.
5872 * In case of 80+80 Mhz, this parameter indicates
5873 * center channel frequency index of 80 Mhz channel of
5874 * frequency segment 1.
5875 */
5876 wider_bw_ch_switch->newCenterChanFreq1 =
5877 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005878 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005879 default:
5880 session_entry->dfsIncludeChanWrapperIe = false;
5881 /*
5882 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5883 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5884 */
5885 lim_log(mac_ctx, LOGE, FL("Invalid Channel Width"));
5886 break;
5887 }
5888 /* Fetch the center channel based on the channel width */
5889 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005890 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005891skip_vht:
5892 /* Send CSA IE request from here */
5893 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5894 eSIR_SUCCESS) {
5895 lim_log(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
5896 return;
5897 }
5898
5899 /*
5900 * First beacon update request is sent here, the remaining updates are
5901 * done when the FW responds back after sending the first beacon after
5902 * the template update
5903 */
5904 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305905
5906 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5907 ch_offset = BW80;
5908 else
5909 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5910
5911 lim_log(mac_ctx, LOG1, FL("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d"),
5912 session_entry->gLimChannelSwitch.switchCount,
5913 session_entry->gLimChannelSwitch.primaryChannel,
5914 session_entry->gLimChannelSwitch.ch_width,
5915 session_entry->dfsIncludeChanWrapperIe,
5916 ch_offset);
5917
Abhishek Singh518323d2015-10-19 17:42:01 +05305918 /* Send ECSA Action frame after updating the beacon */
5919 send_extended_chan_switch_action_frame(mac_ctx,
5920 session_entry->gLimChannelSwitch.primaryChannel,
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305921 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005922 session_entry->gLimChannelSwitch.switchCount--;
5923}
5924
5925/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305926 * lim_process_ext_change_channel()- function to send ECSA
5927 * action frame for STA/CLI .
5928 * @mac_ctx: pointer to global mac structure
5929 * @msg: params from sme for new channel.
5930 *
5931 * This function is called to send ECSA frame for STA/CLI.
5932 *
5933 * Return: void
5934 */
5935
5936static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5937 uint32_t *msg)
5938{
5939 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5940 (struct sir_sme_ext_cng_chan_req *) msg;
5941 tpPESession session_entry = NULL;
5942
5943 if (NULL == msg) {
5944 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5945 return;
5946 }
5947 session_entry =
5948 pe_find_session_by_sme_session_id(mac_ctx,
5949 ext_chng_channel->session_id);
5950 if (NULL == session_entry) {
5951 lim_log(mac_ctx, LOGE,
5952 FL("Session not found for given session %d"),
5953 ext_chng_channel->session_id);
5954 return;
5955 }
5956 if (LIM_IS_AP_ROLE(session_entry)) {
5957 lim_log(mac_ctx, LOGE,
5958 FL("not an STA/CLI session"));
5959 return;
5960 }
5961 send_extended_chan_switch_action_frame(mac_ctx,
5962 ext_chng_channel->new_channel,
5963 0, session_entry);
5964}
5965
5966/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005967 * lim_process_nss_update_request() - process sme nss update req
5968 *
5969 * @mac_ctx: Pointer to Global MAC structure
5970 * @msg_buf: pointer to the SME message buffer
5971 *
5972 * This function processes SME request messages from HDD or upper layer
5973 * application.
5974 *
5975 * Return: None
5976 */
5977static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5978 uint32_t *msg_buf)
5979{
5980 struct sir_nss_update_request *nss_update_req_ptr;
5981 tpPESession session_entry = NULL;
5982
5983 if (msg_buf == NULL) {
5984 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5985 return;
5986 }
5987
5988 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305989 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005990 nss_update_req_ptr->vdev_id);
5991 if (session_entry == NULL) {
5992 lim_log(mac_ctx, LOGE, FL(
5993 "Session not found for given session_id %d"),
5994 nss_update_req_ptr->vdev_id);
5995 return;
5996 }
5997
5998 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5999 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
6000 GET_LIM_SYSTEM_ROLE(session_entry));
6001 return;
6002 }
6003
6004 /* populate nss field in the beacon */
6005 session_entry->gLimOperatingMode.present = 1;
6006 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
6007 /* Send nss update request from here */
6008 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6009 eSIR_SUCCESS) {
6010 lim_log(mac_ctx, LOGE,
6011 FL("Unable to set op mode IE in beacon"));
6012 return;
6013 }
6014
6015 lim_send_beacon_ind(mac_ctx, session_entry);
6016}
6017
6018/**
6019 * lim_process_set_ie_req() - process sme set IE request
6020 *
6021 * @mac_ctx: Pointer to Global MAC structure
6022 * @msg_buf: pointer to the SME message buffer
6023 *
6024 * This function processes SME request messages from HDD or upper layer
6025 * application.
6026 *
6027 * Return: None
6028 */
6029static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6030{
6031 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306032 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006033
6034 if (msg_buf == NULL) {
6035 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6036 return;
6037 }
6038
6039 msg = (struct send_extcap_ie *)msg_buf;
6040 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306041 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006042 lim_log(mac_ctx, LOGE, FL("Unable to send ExtCap to FW"));
6043
6044}