blob: 7e3380d5867578cd129d3c444d7b364e7aef928e [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
1613/* FEATURE_WLAN_DIAG_SUPPORT */
1614#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1615 /*
1616 * Not sending any session, since it is not created yet.
1617 * The response whould have correct state.
1618 */
1619 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1620#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1621
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001622 /*
1623 * Expect Join request in idle state.
1624 * Reassociate request is expected in link established state.
1625 */
1626
1627 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1628 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1629 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1630 msg_buf);
1631
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301632 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001633 if (NULL == sme_join_req) {
1634 lim_log(mac_ctx, LOGP,
1635 FL("AllocateMemory failed for sme_join_req"));
1636 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301637 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001638 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301639 (void)qdf_mem_set((void *)sme_join_req, n_size, 0);
1640 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001641 n_size);
1642
1643 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1644 /* Received invalid eWNI_SME_JOIN_REQ */
1645 /* Log the event */
1646 lim_log(mac_ctx, LOGW,
1647 FL("SessionId:%d JOIN REQ with invalid data"),
1648 sme_join_req->sessionId);
1649 ret_code = eSIR_SME_INVALID_PARAMETERS;
1650 goto end;
1651 }
1652
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001653 /*
1654 * Update the capability here itself as this is used in
1655 * lim_extract_ap_capability() below. If not updated issues
1656 * like not honoring power constraint on 1st association after
1657 * driver loading might occur.
1658 */
1659 lim_update_rrm_capability(mac_ctx, sme_join_req);
1660
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001661 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001662 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001663 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001664 &session_id);
1665
1666 if (session != NULL) {
1667 lim_log(mac_ctx, LOGE,
1668 FL("Session(%d) Already exists for BSSID: "
1669 MAC_ADDRESS_STR " in limSmeState = %X"),
1670 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001671 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001672 session->limSmeState);
1673
1674 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1675 session->smeSessionId == sme_join_req->sessionId) {
1676 /*
1677 * Received eWNI_SME_JOIN_REQ for same
1678 * BSS as currently associated.
1679 * Log the event and send success
1680 */
1681 lim_log(mac_ctx, LOGW,
1682 FL("SessionId: %d"), session_id);
1683 lim_log(mac_ctx, LOGW,
1684 FL("JOIN_REQ for current joined BSS"));
1685 /* Send Join success response to host */
1686 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1687 session = NULL;
1688 goto end;
1689 } else {
1690 lim_log(mac_ctx, LOGE,
1691 FL("JOIN_REQ not for current joined BSS"));
1692 ret_code = eSIR_SME_REFUSED;
1693 session = NULL;
1694 goto end;
1695 }
1696 } else {
1697 /*
1698 * Session Entry does not exist for given BSSId
1699 * Try to Create a new session
1700 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001701 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001702 &session_id, mac_ctx->lim.maxStation,
1703 eSIR_INFRASTRUCTURE_MODE);
1704 if (session == NULL) {
1705 lim_log(mac_ctx, LOGE,
1706 FL("Session Can not be created "));
1707 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1708 goto end;
1709 } else
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301710 lim_log(mac_ctx, LOG2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001711 FL("SessionId:%d New session created"),
1712 session_id);
1713 }
1714 session->isAmsduSupportInAMPDU =
1715 sme_join_req->isAmsduSupportInAMPDU;
1716
1717 /*
1718 * Store Session related parameters
1719 * Store PE session Id in session Table
1720 */
1721 session->peSessionId = session_id;
1722
1723 /* store the smejoin req handle in session table */
1724 session->pLimJoinReq = sme_join_req;
1725
1726 /* Store SME session Id in sessionTable */
1727 session->smeSessionId = sme_join_req->sessionId;
1728
1729 /* Store SME transaction Id in session Table */
1730 session->transactionId = sme_join_req->transactionId;
1731
1732 /* Store beaconInterval */
1733 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001734 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001735
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301736 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001737 sizeof(session->htConfig));
1738
1739 /* Copying of bssId is already done, while creating session */
1740 sir_copy_mac_addr(session->selfMacAddr,
1741 sme_join_req->selfMacAddr);
1742 session->bssType = sme_join_req->bsstype;
1743
1744 session->statypeForBss = STA_ENTRY_PEER;
1745 session->limWmeEnabled = sme_join_req->isWMEenabled;
1746 session->limQosEnabled = sme_join_req->isQosEnabled;
1747
1748 /* Store vendor specfic IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001749 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001750 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1751
1752 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
1753 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001754 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001755
1756 if (NULL != vendor_ie) {
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08001757 lim_log(mac_ctx, LOG1, FL("Cisco vendor OUI present"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001758 session->isCiscoVendorAP = true;
1759 } else {
1760 session->isCiscoVendorAP = false;
1761 }
1762
1763 /* Copy the dot 11 mode in to the session table */
1764
1765 session->dot11mode = sme_join_req->dot11mode;
1766#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1767 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1768#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001769 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001770 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1771 session->enableHtSmps = sme_join_req->enableHtSmps;
1772 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001773 session->send_smps_action =
1774 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001775 /*
1776 * By default supported NSS 1x1 is set to true
1777 * and later on updated while determining session
1778 * supported rates which is the intersection of
1779 * self and peer rates
1780 */
1781 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301782 /*Store Persona */
1783 session->pePersona = sme_join_req->staPersona;
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001784 lim_log(mac_ctx, LOG1,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301785 FL("enable Smps: %d mode: %d send action: %d supported nss 1x1: %d pePersona %d cbMode %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001786 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001787 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001788 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301789 session->supported_nss_1x1,
1790 session->pePersona,
1791 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001792
1793 /*Store Persona */
1794 session->pePersona = sme_join_req->staPersona;
1795 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
1796 FL("PE PERSONA=%d cbMode %u"),
1797 session->pePersona, sme_join_req->cbMode);
1798 /* Copy The channel Id to the session Table */
1799 session->currentOperChannel = bss_desc->channelId;
1800 if (IS_5G_CH(session->currentOperChannel))
1801 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001802 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001803 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
1804 if (session->pePersona == QDF_P2P_CLIENT_MODE)
1805 session->vdev_nss = vdev_type_nss->p2p_cli;
1806 else
1807 session->vdev_nss = vdev_type_nss->sta;
1808 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001809 session->vhtCapability =
1810 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001811 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301812 if (session->pePersona == QDF_STA_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001813 session->txBFIniFeatureEnabled =
1814 sme_join_req->txBFIniFeatureEnabled;
1815 } else {
1816 session->txBFIniFeatureEnabled = 0;
1817 }
1818 session->txMuBformee = sme_join_req->txMuBformee;
1819 session->enableVhtpAid =
1820 sme_join_req->enableVhtpAid;
1821 session->enableVhtGid =
1822 sme_join_req->enableVhtGid;
1823
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001824 if (wlan_cfg_get_int(mac_ctx,
1825 WNI_CFG_VHT_SU_BEAMFORMER_CAP, &val) !=
1826 eSIR_SUCCESS)
1827 lim_log(mac_ctx, LOGE, FL(
1828 "cfg get vht su bformer failed"));
1829
1830 session->enable_su_tx_bformer = val;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001831 }
1832 if (session->vhtCapability && session->txBFIniFeatureEnabled) {
1833 if (cfg_set_int(mac_ctx, WNI_CFG_VHT_SU_BEAMFORMEE_CAP,
1834 session->txBFIniFeatureEnabled) !=
1835 eSIR_SUCCESS) {
1836 /*
1837 * Set failed for
1838 * CFG_VHT_SU_BEAMFORMEE_CAP
1839 */
1840 lim_log(mac_ctx, LOGP,
1841 FL("Failed CFG_VHT_SU_BEAMFORMEE_CAP"));
1842 ret_code = eSIR_LOGP_EXCEPTION;
1843 goto end;
1844 }
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -08001845 session->txbf_csn_value = sme_join_req->txBFCsnValue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001846 }
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301847 lim_log(mac_ctx, LOG1,
1848 FL("vhtCapability: %d txBFIniFeatureEnabled: %d txbf_csn_value: %d su_tx_bformer %d"),
1849 session->vhtCapability,
1850 session->txBFIniFeatureEnabled,
1851 session->txbf_csn_value,
1852 session->enable_su_tx_bformer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001853 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001854 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001855 handle_ht_capabilityand_ht_info(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001856 /* cbMode is already merged value of peer and self -
1857 * done by csr in csr_get_cb_mode_from_ies */
1858 session->htSupportedChannelWidthSet =
1859 (sme_join_req->cbMode) ? 1 : 0;
1860 session->htRecommendedTxWidthSet =
1861 session->htSupportedChannelWidthSet;
1862 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1863
1864 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1865 session->ch_center_freq_seg0 =
1866 session->currentOperChannel - 2;
1867 session->ch_width = CH_WIDTH_40MHZ;
1868 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1869 sme_join_req->cbMode) {
1870 session->ch_center_freq_seg0 =
1871 session->currentOperChannel + 2;
1872 session->ch_width = CH_WIDTH_40MHZ;
1873 } else {
1874 session->ch_center_freq_seg0 = 0;
1875 session->ch_width = CH_WIDTH_20MHZ;
1876 }
1877
1878 /* Record if management frames need to be protected */
1879#ifdef WLAN_FEATURE_11W
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001880 if (eSIR_ED_AES_128_CMAC == sme_join_req->MgmtEncryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001881 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001882 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001883 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001884#endif
1885
1886#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001887 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001888#endif
1889
1890 /* Copy the SSID from smejoinreq to session entry */
1891 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301892 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001893 session->ssId.length);
1894
1895 /*
1896 * Determin 11r or ESE connection based on input from SME
1897 * which inturn is dependent on the profile the user wants
1898 * to connect to, So input is coming from supplicant
1899 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001900 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001901#ifdef FEATURE_WLAN_ESE
1902 session->isESEconnection = sme_join_req->isESEconnection;
1903#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001904 session->isFastTransitionEnabled =
1905 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001906
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001907 session->isFastRoamIniFeatureEnabled =
1908 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001909 session->txLdpcIniFeatureEnabled =
1910 sme_join_req->txLdpcIniFeatureEnabled;
1911
1912 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1913 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001914 } else {
1915 /*
1916 * Throw an error and return and make
1917 * sure to delete the session.
1918 */
1919 lim_log(mac_ctx, LOGE,
1920 FL("recvd JOIN_REQ with invalid bss type %d"),
1921 session->bssType);
1922 ret_code = eSIR_SME_INVALID_PARAMETERS;
1923 goto end;
1924 }
1925
1926 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301927 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001928 &sme_join_req->addIEScan, sizeof(tSirAddie));
1929
1930 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301931 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001932 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1933
1934 val = sizeof(tLimMlmJoinReq) +
1935 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301936 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001937 if (NULL == mlm_join_req) {
1938 lim_log(mac_ctx, LOGP,
1939 FL("AllocateMemory failed for mlmJoinReq"));
Nitesh Shah0102cac2016-07-13 14:38:30 +05301940 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1941 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001942 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301943 (void)qdf_mem_set((void *)mlm_join_req, val, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001944
1945 /* PE SessionId is stored as a part of JoinReq */
1946 mlm_join_req->sessionId = session->peSessionId;
1947
1948 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1949 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1950 eSIR_SUCCESS) {
1951 lim_log(mac_ctx, LOGP,
1952 FL("couldn't retrieve JoinFailureTimer value"
1953 " setting to default value"));
1954 mlm_join_req->joinFailureTimeout =
1955 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1956 }
1957
1958 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301959 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001960 (void *)&sme_join_req->operationalRateSet,
1961 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301962 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001963 (void *)&sme_join_req->extendedRateSet,
1964 sizeof(tSirMacRateSet));
1965 /*
1966 * this may not be needed anymore now, as rateSet is now
1967 * included in the session entry and MLM has session context.
1968 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301969 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001970 (void *)&session->rateSet,
1971 sizeof(tSirMacRateSet));
1972
1973 session->encryptType = sme_join_req->UCEncryptionType;
1974
1975 mlm_join_req->bssDescription.length =
1976 session->pLimJoinReq->bssDescription.length;
1977
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301978 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001979 (uint8_t *)
1980 &session->pLimJoinReq->bssDescription.bssId,
1981 session->pLimJoinReq->bssDescription.length + 2);
1982
1983 session->limCurrentBssCaps =
1984 session->pLimJoinReq->bssDescription.capabilityInfo;
1985
1986 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1987 session->currentOperChannel);
1988 local_power_constraint = reg_max;
1989
1990 lim_extract_ap_capability(mac_ctx,
1991 (uint8_t *)
1992 session->pLimJoinReq->bssDescription.ieFields,
1993 lim_get_ielen_from_bss_description(
1994 &session->pLimJoinReq->bssDescription),
1995 &session->limCurrentBssQosCaps,
1996 &session->limCurrentBssPropCap,
1997 &session->gLimCurrentBssUapsd,
1998 &local_power_constraint, session);
1999
2000#ifdef FEATURE_WLAN_ESE
2001 session->maxTxPower = lim_get_max_tx_power(reg_max,
2002 local_power_constraint,
2003 mac_ctx->roam.configParam.nTxPowerCap);
2004#else
2005 session->maxTxPower =
Anurag Chouhan6d760662016-02-20 16:05:43 +05302006 QDF_MIN(reg_max, (local_power_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002007#endif
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302008 lim_log(mac_ctx, LOG1,
2009 FL("Reg max = %d, local power con = %d, max tx = %d"),
2010 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002011
2012 if (session->gLimCurrentBssUapsd) {
2013 session->gUapsdPerAcBitmask =
2014 session->pLimJoinReq->uapsdPerAcBitmask;
2015 lim_log(mac_ctx, LOG1,
2016 FL("UAPSD flag for all AC - 0x%2x"),
2017 session->gUapsdPerAcBitmask);
2018
2019 /* resetting the dynamic uapsd mask */
2020 session->gUapsdPerAcDeliveryEnableMask = 0;
2021 session->gUapsdPerAcTriggerEnableMask = 0;
2022 }
2023
2024 session->limRFBand =
2025 lim_get_rf_band(session->currentOperChannel);
2026
2027 /* Initialize 11h Enable Flag */
2028 if (SIR_BAND_5_GHZ == session->limRFBand) {
2029 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
2030 &val) != eSIR_SUCCESS) {
2031 lim_log(mac_ctx, LOGP,
2032 FL("Fail to get WNI_CFG_11H_ENABLED "));
2033 session->lim11hEnable =
2034 WNI_CFG_11H_ENABLED_STADEF;
2035 } else {
2036 session->lim11hEnable = val;
2037 }
2038 } else {
2039 session->lim11hEnable = 0;
2040 }
2041
2042 /*
2043 * To care of the scenario when STA transitions from
2044 * IBSS to Infrastructure mode.
2045 */
2046 mac_ctx->lim.gLimIbssCoalescingHappened = false;
2047
2048 session->limPrevSmeState = session->limSmeState;
2049 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
2050 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2051 session->peSessionId,
2052 session->limSmeState));
2053
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002054 /* Indicate whether spectrum management is enabled */
2055 session->spectrumMgtEnabled =
2056 sme_join_req->spectrumMgtIndicator;
2057
2058 /* Enable the spectrum management if this is a DFS channel */
2059 if (session->country_info_present &&
2060 lim_isconnected_on_dfs_channel(
2061 session->currentOperChannel))
2062 session->spectrumMgtEnabled = true;
2063
2064 session->isOSENConnection = sme_join_req->isOSENConnection;
2065
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002066 /* Issue LIM_MLM_JOIN_REQ to MLM */
2067 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
2068 (uint32_t *) mlm_join_req);
2069 return;
2070
2071 } else {
2072 /* Received eWNI_SME_JOIN_REQ un expected state */
2073 lim_log(mac_ctx, LOGE,
2074 FL("received unexpected SME_JOIN_REQ in state %X"),
2075 mac_ctx->lim.gLimSmeState);
2076 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
2077 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2078 session = NULL;
2079 goto end;
2080 }
2081
2082end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05302083 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2084 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002085
2086 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302087 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002088 sme_join_req = NULL;
2089 if (NULL != session)
2090 session->pLimJoinReq = NULL;
2091 }
2092 if (ret_code != eSIR_SME_SUCCESS) {
2093 if (NULL != session) {
2094 pe_delete_session(mac_ctx, session);
2095 session = NULL;
2096 }
2097 }
2098 lim_log(mac_ctx, LOG1,
2099 FL("Send failure status on sessionid: %d with ret_code = %d"),
2100 sme_session_id, ret_code);
2101 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
2102 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
2103 sme_transaction_id);
2104}
2105
Amar Singhala297bfa2015-10-15 15:07:29 -07002106uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002107 uint8_t iniTxPower)
2108{
2109 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302110 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
2111 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002112 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2113 maxTxPower = txPower;
2114 else if (txPower < MIN_TX_PWR_CAP)
2115 maxTxPower = MIN_TX_PWR_CAP;
2116 else
2117 maxTxPower = MAX_TX_PWR_CAP;
2118
2119 return maxTxPower;
2120}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002121
2122/**
2123 * __lim_process_sme_reassoc_req() - process reassoc req
2124 *
2125 * @mac_ctx: Pointer to Global MAC structure
2126 * @msg_buf: pointer to the SME message buffer
2127 *
2128 * This function is called to process SME_REASSOC_REQ message
2129 * from HDD or upper layer application.
2130 *
2131 * Return: None
2132 */
2133
2134static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2135 uint32_t *msg_buf)
2136{
2137 uint16_t caps;
2138 uint32_t val;
2139 tpSirSmeJoinReq reassoc_req = NULL;
2140 tLimMlmReassocReq *mlm_reassoc_req;
2141 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2142 tpPESession session_entry = NULL;
2143 uint8_t session_id;
2144 uint8_t sme_session_id;
2145 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002146 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002147 uint32_t tele_bcn_en = 0;
2148 uint16_t size;
2149
2150 lim_log(mac_ctx, LOG3, FL("Received REASSOC_REQ"));
2151
2152 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302153 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002154 if (NULL == reassoc_req) {
2155 lim_log(mac_ctx, LOGP,
2156 FL("call to AllocateMemory failed for reassoc_req"));
2157
2158 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2159 goto end;
2160 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302161 (void)qdf_mem_set((void *)reassoc_req, size, 0);
2162 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002163
2164 if (!lim_is_sme_join_req_valid(mac_ctx,
2165 (tpSirSmeJoinReq)reassoc_req)) {
2166 /*
2167 * Received invalid eWNI_SME_REASSOC_REQ
2168 */
2169 lim_log(mac_ctx, LOGW,
2170 FL("received SME_REASSOC_REQ with invalid data"));
2171
2172 ret_code = eSIR_SME_INVALID_PARAMETERS;
2173 goto end;
2174 }
2175
2176 session_entry = pe_find_session_by_bssid(mac_ctx,
2177 reassoc_req->bssDescription.bssId,
2178 &session_id);
2179 if (session_entry == NULL) {
2180 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2181 LOGE);
2182 lim_log(mac_ctx, LOGE,
2183 FL("Session does not exist for given bssId"));
2184 ret_code = eSIR_SME_INVALID_PARAMETERS;
2185 goto end;
2186 }
2187#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2188 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2189 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2190#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2191 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2192
2193 /* Store the reassoc handle in the session Table */
2194 session_entry->pLimReAssocReq = reassoc_req;
2195
2196 session_entry->dot11mode = reassoc_req->dot11mode;
2197 session_entry->vhtCapability =
2198 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002199
2200 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2201 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002202 session_entry->send_smps_action =
2203 reassoc_req->send_smps_action;
2204 lim_log(mac_ctx, LOG1,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002205 FL("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002206 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002207 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002208 session_entry->send_smps_action,
2209 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002210 /*
2211 * Reassociate request is expected
2212 * in link established state only.
2213 */
2214
2215 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002216 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2217 /*
2218 * May be from 11r FT pre-auth. So lets check it
2219 * before we bail out
2220 */
2221 lim_log(mac_ctx, LOG1, FL(
2222 "Session in reassoc state is %d"),
2223 session_entry->peSessionId);
2224
2225 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302226 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002227 session_entry->limReAssocbssId,
2228 6)) {
2229 lim_print_mac_addr(mac_ctx,
2230 reassoc_req->bssDescription.
2231 bssId, LOGE);
2232 lim_log(mac_ctx, LOGP,
2233 FL("Unknown bssId in reassoc state"));
2234 ret_code = eSIR_SME_INVALID_PARAMETERS;
2235 goto end;
2236 }
2237
2238 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2239 session_entry);
2240 return;
2241 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002242 /*
2243 * Should not have received eWNI_SME_REASSOC_REQ
2244 */
2245 lim_log(mac_ctx, LOGE,
2246 FL("received unexpected SME_REASSOC_REQ in state %X"),
2247 session_entry->limSmeState);
2248 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2249
2250 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2251 goto end;
2252 }
2253
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302254 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002255 session_entry->pLimReAssocReq->bssDescription.bssId,
2256 sizeof(tSirMacAddr));
2257
2258 session_entry->limReassocChannelId =
2259 session_entry->pLimReAssocReq->bssDescription.channelId;
2260
2261 session_entry->reAssocHtSupportedChannelWidthSet =
2262 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2263 session_entry->reAssocHtRecommendedTxWidthSet =
2264 session_entry->reAssocHtSupportedChannelWidthSet;
2265 session_entry->reAssocHtSecondaryChannelOffset =
2266 session_entry->pLimReAssocReq->cbMode;
2267
2268 session_entry->limReassocBssCaps =
2269 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2270 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2271 session_entry->currentOperChannel);
2272 local_pwr_constraint = reg_max;
2273
2274 lim_extract_ap_capability(mac_ctx,
2275 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2276 lim_get_ielen_from_bss_description(
2277 &session_entry->pLimReAssocReq->bssDescription),
2278 &session_entry->limReassocBssQosCaps,
2279 &session_entry->limReassocBssPropCap,
2280 &session_entry->gLimCurrentBssUapsd,
2281 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302282 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002283 lim_log(mac_ctx, LOGE,
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302284 FL("Reg max = %d, local pwr constraint = %d, max tx = %d"),
2285 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002286 /* Copy the SSID from session entry to local variable */
2287 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302288 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002289 reassoc_req->ssId.ssId,
2290 session_entry->limReassocSSID.length);
2291 if (session_entry->gLimCurrentBssUapsd) {
2292 session_entry->gUapsdPerAcBitmask =
2293 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
2294 lim_log(mac_ctx, LOG1,
2295 FL("UAPSD flag for all AC - 0x%2x"),
2296 session_entry->gUapsdPerAcBitmask);
2297 }
2298
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302299 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002300 if (NULL == mlm_reassoc_req) {
2301 lim_log(mac_ctx, LOGP,
2302 FL("call to AllocateMemory failed for mlmReassocReq"));
2303
2304 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2305 goto end;
2306 }
2307
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302308 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002309 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2310
2311 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2312 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
2313 eSIR_SUCCESS) {
2314 /*
2315 * Could not get ReassocFailureTimeout value
2316 * from CFG. Log error.
2317 */
2318 lim_log(mac_ctx, LOGP,
2319 FL("could not retrieve ReassocFailureTimeout value"));
2320 }
2321
2322 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
2323 eSIR_SUCCESS) {
2324 /*
2325 * Could not get Capabilities value
2326 * from CFG. Log error.
2327 */
2328 lim_log(mac_ctx, LOGP, FL(
2329 "could not retrieve Capabilities value"));
2330 }
2331 mlm_reassoc_req->capabilityInfo = caps;
2332
2333 /* Update PE session_id */
2334 mlm_reassoc_req->sessionId = session_id;
2335
2336 /*
2337 * If telescopic beaconing is enabled, set listen interval to
2338 * WNI_CFG_TELE_BCN_MAX_LI
2339 */
2340 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2341 &tele_bcn_en) != eSIR_SUCCESS)
2342 lim_log(mac_ctx, LOGP,
2343 FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
2344
2345 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2346
2347 if (tele_bcn_en) {
2348 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2349 eSIR_SUCCESS)
2350 /*
2351 * Could not get ListenInterval value
2352 * from CFG. Log error.
2353 */
2354 lim_log(mac_ctx, LOGP,
2355 FL("could not retrieve ListenInterval"));
2356 } else {
2357 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
2358 eSIR_SUCCESS)
2359 /*
2360 * Could not get ListenInterval value
2361 * from CFG. Log error.
2362 */
2363 lim_log(mac_ctx, LOGP,
2364 FL("could not retrieve ListenInterval"));
2365 }
2366
2367 mlm_reassoc_req->listenInterval = (uint16_t) val;
2368
2369 /* Indicate whether spectrum management is enabled */
2370 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2371
2372 /* Enable the spectrum management if this is a DFS channel */
2373 if (session_entry->country_info_present &&
2374 lim_isconnected_on_dfs_channel(
2375 session_entry->currentOperChannel))
2376 session_entry->spectrumMgtEnabled = true;
2377
2378 session_entry->limPrevSmeState = session_entry->limSmeState;
2379 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2380
2381 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2382 session_entry->peSessionId,
2383 session_entry->limSmeState));
2384
2385 lim_post_mlm_message(mac_ctx,
2386 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2387 return;
2388end:
2389 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302390 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002391 if (session_entry)
2392 session_entry->pLimReAssocReq = NULL;
2393 }
2394
2395 if (session_entry) {
2396 /*
2397 * error occurred after we determined the session so extract
2398 * session and transaction info from there
2399 */
2400 sme_session_id = session_entry->smeSessionId;
2401 transaction_id = session_entry->transactionId;
2402 } else
2403 /*
2404 * error occurred before or during the time we determined
2405 * the session so extract the session and transaction info
2406 * from the message
2407 */
2408 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2409 &sme_session_id, &transaction_id);
2410
2411 /*
2412 * Send Reassoc failure response to host
2413 * (note session_entry may be NULL, but that's OK)
2414 */
2415 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2416 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2417 session_entry, sme_session_id,
2418 transaction_id);
2419}
2420
2421bool send_disassoc_frame = 1;
2422/**
2423 * __lim_process_sme_disassoc_req()
2424 *
2425 ***FUNCTION:
2426 * This function is called to process SME_DISASSOC_REQ message
2427 * from HDD or upper layer application.
2428 *
2429 ***LOGIC:
2430 *
2431 ***ASSUMPTIONS:
2432 *
2433 ***NOTE:
2434 *
2435 * @param pMac Pointer to Global MAC structure
2436 * @param *pMsgBuf A pointer to the SME message buffer
2437 * @return None
2438 */
2439
2440static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2441{
2442 uint16_t disassocTrigger, reasonCode;
2443 tLimMlmDisassocReq *pMlmDisassocReq;
2444 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2445 tSirSmeDisassocReq smeDisassocReq;
2446 tpPESession psessionEntry = NULL;
2447 uint8_t sessionId;
2448 uint8_t smesessionId;
2449 uint16_t smetransactionId;
2450
2451 if (pMsgBuf == NULL) {
2452 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
2453 return;
2454 }
2455
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302456 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002457 smesessionId = smeDisassocReq.sessionId;
2458 smetransactionId = smeDisassocReq.transactionId;
2459 if (!lim_is_sme_disassoc_req_valid(pMac,
2460 &smeDisassocReq,
2461 psessionEntry)) {
2462 PELOGE(lim_log(pMac, LOGE,
2463 FL("received invalid SME_DISASSOC_REQ message"));)
2464 if (pMac->lim.gLimRspReqd) {
2465 pMac->lim.gLimRspReqd = false;
2466
2467 retCode = eSIR_SME_INVALID_PARAMETERS;
2468 disassocTrigger = eLIM_HOST_DISASSOC;
2469 goto sendDisassoc;
2470 }
2471
2472 return;
2473 }
2474
2475 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002476 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002477 &sessionId);
2478 if (psessionEntry == NULL) {
2479 lim_log(pMac, LOGE,
2480 FL("session does not exist for given bssId "
2481 MAC_ADDRESS_STR),
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002482 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002483 retCode = eSIR_SME_INVALID_PARAMETERS;
2484 disassocTrigger = eLIM_HOST_DISASSOC;
2485 goto sendDisassoc;
2486 }
2487 lim_log(pMac, LOG1,
2488 FL("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2489 MAC_ADDRESS_STR), smesessionId,
2490 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2491 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002492 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002493
2494#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2495 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2496 0, smeDisassocReq.reasonCode);
2497#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2498
2499 /* Update SME session Id and SME transaction ID */
2500
2501 psessionEntry->smeSessionId = smesessionId;
2502 psessionEntry->transactionId = smetransactionId;
2503
2504 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2505 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002506 switch (psessionEntry->limSmeState) {
2507 case eLIM_SME_ASSOCIATED_STATE:
2508 case eLIM_SME_LINK_EST_STATE:
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002509 lim_log(pMac, LOG1,
2510 FL("Rcvd SME_DISASSOC_REQ in limSmeState: %d "),
2511 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002512 psessionEntry->limPrevSmeState =
2513 psessionEntry->limSmeState;
2514 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2515#ifdef FEATURE_WLAN_TDLS
2516 /* Delete all TDLS peers connected before leaving BSS */
2517 lim_delete_tdls_peers(pMac, psessionEntry);
2518#endif
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002519 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2520 psessionEntry->peSessionId,
2521 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002522 break;
2523
2524 case eLIM_SME_WT_DEAUTH_STATE:
2525 /* PE shall still process the DISASSOC_REQ and proceed with
2526 * link tear down even if it had already sent a DEAUTH_IND to
2527 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2528 * its been set when PE entered WT_DEAUTH_STATE.
2529 */
2530 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2531 MTRACE(mac_trace
2532 (pMac, TRACE_CODE_SME_STATE,
2533 psessionEntry->peSessionId,
2534 psessionEntry->limSmeState));
2535 lim_log(pMac, LOG1,
2536 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE. "));
2537 break;
2538
2539 case eLIM_SME_WT_DISASSOC_STATE:
2540 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2541 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2542 * PE can continue processing DISASSOC_REQ and send the response instead
2543 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2544 * for disassoc frame.
2545 *
2546 * It will send a disassoc, which is ok. However, we can use the global flag
2547 * sendDisassoc to not send disassoc frame.
2548 */
2549 lim_log(pMac, LOG1,
2550 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE. "));
2551 break;
2552
2553 case eLIM_SME_JOIN_FAILURE_STATE: {
2554 /* Already in Disconnected State, return success */
2555 lim_log(pMac, LOG1,
2556 FL("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE. "));
2557 if (pMac->lim.gLimRspReqd) {
2558 retCode = eSIR_SME_SUCCESS;
2559 disassocTrigger = eLIM_HOST_DISASSOC;
2560 goto sendDisassoc;
2561 }
2562 }
2563 break;
2564 default:
2565 /**
2566 * STA is not currently associated.
2567 * Log error and send response to host
2568 */
2569 lim_log(pMac, LOGE,
2570 FL("received unexpected SME_DISASSOC_REQ in state %X"),
2571 psessionEntry->limSmeState);
2572 lim_print_sme_state(pMac, LOGE,
2573 psessionEntry->limSmeState);
2574
2575 if (pMac->lim.gLimRspReqd) {
2576 if (psessionEntry->limSmeState !=
2577 eLIM_SME_WT_ASSOC_STATE)
2578 pMac->lim.gLimRspReqd = false;
2579
2580 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2581 disassocTrigger = eLIM_HOST_DISASSOC;
2582 goto sendDisassoc;
2583 }
2584
2585 return;
2586 }
2587
2588 break;
2589
2590 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002591 /* Fall through */
2592 break;
2593
2594 case eLIM_STA_IN_IBSS_ROLE:
2595 default:
2596 /* eLIM_UNKNOWN_ROLE */
2597 lim_log(pMac, LOGE,
2598 FL("received unexpected SME_DISASSOC_REQ for role %d"),
2599 GET_LIM_SYSTEM_ROLE(psessionEntry));
2600
2601 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2602 disassocTrigger = eLIM_HOST_DISASSOC;
2603 goto sendDisassoc;
2604 } /* end switch (pMac->lim.gLimSystemRole) */
2605
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302606 disassocTrigger = eLIM_HOST_DISASSOC;
2607 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002608
2609 if (smeDisassocReq.doNotSendOverTheAir) {
2610 lim_log(pMac, LOG1, FL("do not send dissoc over the air"));
2611 send_disassoc_frame = 0;
2612 }
2613 /* Trigger Disassociation frame to peer MAC entity */
2614 lim_log(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2615 " : %d, reasonCode : %d"),
2616 disassocTrigger, reasonCode);
2617
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302618 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002619 if (NULL == pMlmDisassocReq) {
2620 /* Log error */
2621 lim_log(pMac, LOGP,
2622 FL("call to AllocateMemory failed for mlmDisassocReq"));
2623
2624 return;
2625 }
2626
Anurag Chouhanc5548422016-02-24 18:33:27 +05302627 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002628 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002629
2630 pMlmDisassocReq->reasonCode = reasonCode;
2631 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2632
2633 /* Update PE session ID */
2634 pMlmDisassocReq->sessionId = sessionId;
2635
2636 lim_post_mlm_message(pMac,
2637 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2638 return;
2639
2640sendDisassoc:
2641 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002642 lim_send_sme_disassoc_ntf(pMac,
2643 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002644 retCode,
2645 disassocTrigger,
2646 1, smesessionId, smetransactionId,
2647 psessionEntry);
2648 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002649 lim_send_sme_disassoc_ntf(pMac,
2650 smeDisassocReq.peer_macaddr.bytes,
2651 retCode, disassocTrigger, 1,
2652 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002653
2654} /*** end __lim_process_sme_disassoc_req() ***/
2655
2656/** -----------------------------------------------------------------
2657 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2658
2659 This function is called to process SME_DISASSOC_CNF message
2660 from HDD or upper layer application.
2661
2662 \param pMac - global mac structure
2663 \param pStaDs - station dph hash node
2664 \return none
2665 \sa
2666 ----------------------------------------------------------------- */
2667static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2668{
2669 tSirSmeDisassocCnf smeDisassocCnf;
2670 uint16_t aid;
2671 tpDphHashNode pStaDs;
2672 tpPESession psessionEntry;
2673 uint8_t sessionId;
2674
2675 PELOG1(lim_log(pMac, LOG1, FL("received DISASSOC_CNF message"));)
2676
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302677 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002678 sizeof(struct sSirSmeDisassocCnf));
2679
2680 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002681 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002682 &sessionId);
2683 if (psessionEntry == NULL) {
2684 lim_log(pMac, LOGE,
2685 FL("session does not exist for given bssId"));
2686 return;
2687 }
2688
2689 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
2690 lim_log(pMac, LOGE,
2691 FL("received invalid SME_DISASSOC_CNF message"));
2692 return;
2693 }
2694#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2695 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2696 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2697 psessionEntry,
2698 (uint16_t) smeDisassocCnf.statusCode, 0);
2699 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2700 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2701 psessionEntry,
2702 (uint16_t) smeDisassocCnf.statusCode, 0);
2703#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2704
2705 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2706 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002707 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2708 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2709 && (psessionEntry->limSmeState !=
2710 eLIM_SME_WT_DEAUTH_STATE)) {
2711 lim_log(pMac, LOGE,
2712 FL
2713 ("received unexp SME_DISASSOC_CNF in state %X"),
2714 psessionEntry->limSmeState);
2715 lim_print_sme_state(pMac, LOGE,
2716 psessionEntry->limSmeState);
2717 return;
2718 }
2719 break;
2720
2721 case eLIM_AP_ROLE:
2722 /* Fall through */
2723 break;
2724
2725 case eLIM_STA_IN_IBSS_ROLE:
2726 default: /* eLIM_UNKNOWN_ROLE */
2727 lim_log(pMac, LOGE,
2728 FL("received unexpected SME_DISASSOC_CNF role %d"),
2729 GET_LIM_SYSTEM_ROLE(psessionEntry));
2730
2731 return;
2732 }
2733
2734 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2735 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2736 LIM_IS_AP_ROLE(psessionEntry)) {
2737 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002738 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002739 &psessionEntry->dph.dphHashTable);
2740 if (pStaDs == NULL) {
2741 lim_log(pMac, LOGE,
2742 FL("DISASSOC_CNF for a STA with no context, addr= "
2743 MAC_ADDRESS_STR),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002744 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002745 return;
2746 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302747
2748 if ((pStaDs->mlmStaContext.mlmState ==
2749 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2750 (pStaDs->mlmStaContext.mlmState ==
2751 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
2752 lim_log(pMac, LOGE,
2753 FL("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d"),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002754 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302755 pStaDs->mlmStaContext.mlmState);
2756 return;
2757 }
2758
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002759 /* Delete FT session if there exists one */
2760 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002761 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2762
2763 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002764 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002765 }
2766
2767 return;
2768}
2769
2770/**
2771 * __lim_process_sme_deauth_req() - process sme deauth req
2772 * @mac_ctx: Pointer to Global MAC structure
2773 * @msg_buf: pointer to the SME message buffer
2774 *
2775 * This function is called to process SME_DEAUTH_REQ message
2776 * from HDD or upper layer application.
2777 *
2778 * Return: None
2779 */
2780
2781static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2782 uint32_t *msg_buf)
2783{
2784 uint16_t deauth_trigger, reason_code;
2785 tLimMlmDeauthReq *mlm_deauth_req;
2786 tSirSmeDeauthReq sme_deauth_req;
2787 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2788 tpPESession session_entry;
2789 uint8_t session_id; /* PE sessionId */
2790 uint8_t sme_session_id;
2791 uint16_t sme_transaction_id;
2792
2793 lim_log(mac_ctx, LOG1, FL("received DEAUTH_REQ message"));
2794
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302795 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002796 sme_session_id = sme_deauth_req.sessionId;
2797 sme_transaction_id = sme_deauth_req.transactionId;
2798
2799 /*
2800 * We need to get a session first but we don't even know
2801 * if the message is correct.
2802 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002803 session_entry = pe_find_session_by_bssid(mac_ctx,
2804 sme_deauth_req.bssid.bytes,
2805 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002806 if (session_entry == NULL) {
2807 lim_log(mac_ctx, LOGE,
2808 FL("session does not exist for given bssId"));
2809 ret_code = eSIR_SME_INVALID_PARAMETERS;
2810 deauth_trigger = eLIM_HOST_DEAUTH;
2811 goto send_deauth;
2812 }
2813
2814 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2815 session_entry)) {
2816 lim_log(mac_ctx, LOGE,
2817 FL("received invalid SME_DEAUTH_REQ message"));
2818 mac_ctx->lim.gLimRspReqd = false;
2819
2820 ret_code = eSIR_SME_INVALID_PARAMETERS;
2821 deauth_trigger = eLIM_HOST_DEAUTH;
2822 goto send_deauth;
2823 }
2824 lim_log(mac_ctx, LOG1,
2825 FL("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2826 MAC_ADDRESS_STR), sme_session_id,
2827 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2828 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002829 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002830#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2831 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2832 session_entry, 0, sme_deauth_req.reasonCode);
2833#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2834
2835 /* Update SME session ID and Transaction ID */
2836 session_entry->smeSessionId = sme_session_id;
2837 session_entry->transactionId = sme_transaction_id;
2838
2839 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2840 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002841 switch (session_entry->limSmeState) {
2842 case eLIM_SME_ASSOCIATED_STATE:
2843 case eLIM_SME_LINK_EST_STATE:
2844 case eLIM_SME_WT_ASSOC_STATE:
2845 case eLIM_SME_JOIN_FAILURE_STATE:
2846 case eLIM_SME_IDLE_STATE:
2847 session_entry->limPrevSmeState =
2848 session_entry->limSmeState;
2849 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2850 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2851 session_entry->peSessionId,
2852 session_entry->limSmeState));
2853 /* Send Deauthentication request to MLM below */
2854 break;
2855 case eLIM_SME_WT_DEAUTH_STATE:
2856 case eLIM_SME_WT_DISASSOC_STATE:
2857 /*
2858 * PE Recieved a Deauth/Disassoc frame. Normally it get
2859 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2860 * Which means host is also trying to disconnect.
2861 * PE can continue processing DEAUTH_REQ and send
2862 * the response instead of failing the request.
2863 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2864 * was sent for deauth/disassoc frame.
2865 */
2866 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2867 lim_log(mac_ctx, LOG1, FL(
2868 "Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE"));
2869 break;
2870 default:
2871 /*
2872 * STA is not in a state to deauthenticate with
2873 * peer. Log error and send response to host.
2874 */
2875 lim_log(mac_ctx, LOGE, FL(
2876 "received unexp SME_DEAUTH_REQ in state %X"),
2877 session_entry->limSmeState);
2878 lim_print_sme_state(mac_ctx, LOGE,
2879 session_entry->limSmeState);
2880
2881 if (mac_ctx->lim.gLimRspReqd) {
2882 mac_ctx->lim.gLimRspReqd = false;
2883
2884 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2885 deauth_trigger = eLIM_HOST_DEAUTH;
2886
2887 /*
2888 * here we received deauth request from AP so sme state
2889 * is eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED
2890 * delSta then mlm state should be
2891 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got delBSS
2892 * rsp then mlm state should be eLIM_MLM_IDLE_STATE
2893 * so the below condition captures the state where
2894 * delSta not done and firmware still in
2895 * connected state.
2896 */
2897 if (session_entry->limSmeState ==
2898 eLIM_SME_WT_DEAUTH_STATE &&
2899 session_entry->limMlmState !=
2900 eLIM_MLM_IDLE_STATE &&
2901 session_entry->limMlmState !=
2902 eLIM_MLM_WT_DEL_STA_RSP_STATE)
2903 ret_code = eSIR_SME_DEAUTH_STATUS;
2904 goto send_deauth;
2905 }
2906 return;
2907 }
2908 break;
2909
2910 case eLIM_STA_IN_IBSS_ROLE:
2911 lim_log(mac_ctx, LOGE, FL("Deauth not allowed in IBSS"));
2912 if (mac_ctx->lim.gLimRspReqd) {
2913 mac_ctx->lim.gLimRspReqd = false;
2914 ret_code = eSIR_SME_INVALID_PARAMETERS;
2915 deauth_trigger = eLIM_HOST_DEAUTH;
2916 goto send_deauth;
2917 }
2918 return;
2919 case eLIM_AP_ROLE:
2920 break;
2921 default:
2922 lim_log(mac_ctx, LOGE,
2923 FL("received unexpected SME_DEAUTH_REQ for role %X"),
2924 GET_LIM_SYSTEM_ROLE(session_entry));
2925 if (mac_ctx->lim.gLimRspReqd) {
2926 mac_ctx->lim.gLimRspReqd = false;
2927 ret_code = eSIR_SME_INVALID_PARAMETERS;
2928 deauth_trigger = eLIM_HOST_DEAUTH;
2929 goto send_deauth;
2930 }
2931 return;
2932 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2933
2934 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2935 /* Deauthentication is triggered by Link Monitoring */
2936 lim_log(mac_ctx, LOG1, FL("** Lost link with AP **"));
2937 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2938 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2939 } else {
2940 deauth_trigger = eLIM_HOST_DEAUTH;
2941 reason_code = sme_deauth_req.reasonCode;
2942 }
2943
2944 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302945 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002946 if (NULL == mlm_deauth_req) {
2947 lim_log(mac_ctx, LOGP,
2948 FL("call to AllocateMemory failed for mlmDeauthReq"));
2949 if (mac_ctx->lim.gLimRspReqd) {
2950 mac_ctx->lim.gLimRspReqd = false;
2951 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2952 deauth_trigger = eLIM_HOST_DEAUTH;
2953 goto send_deauth;
2954 }
2955 return;
2956 }
2957
Anurag Chouhanc5548422016-02-24 18:33:27 +05302958 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002959 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002960
2961 mlm_deauth_req->reasonCode = reason_code;
2962 mlm_deauth_req->deauthTrigger = deauth_trigger;
2963
2964 /* Update PE session Id */
2965 mlm_deauth_req->sessionId = session_id;
2966
2967 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2968 (uint32_t *)mlm_deauth_req);
2969 return;
2970
2971send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002972 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2973 ret_code, deauth_trigger, 1,
2974 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002975}
2976
2977/**
2978 * __lim_process_sme_set_context_req()
2979 *
2980 * @mac_ctx: Pointer to Global MAC structure
2981 * @msg_buf: pointer to the SME message buffer
2982 *
2983 * This function is called to process SME_SETCONTEXT_REQ message
2984 * from HDD or upper layer application.
2985 *
2986 * Return: None
2987 */
2988
2989static void
2990__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2991{
2992 tpSirSmeSetContextReq set_context_req;
2993 tLimMlmSetKeysReq *mlm_set_key_req;
2994 tpPESession session_entry;
2995 uint8_t session_id; /* PE sessionID */
2996 uint8_t sme_session_id;
2997 uint16_t sme_transaction_id;
2998
2999 lim_log(mac_ctx, LOG1, FL("received SETCONTEXT_REQ message"));
3000
3001 if (msg_buf == NULL) {
3002 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3003 return;
3004 }
3005
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303006 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003007 if (NULL == set_context_req) {
3008 lim_log(mac_ctx, LOGP, FL(
3009 "call to AllocateMemory failed for set_context_req"));
3010 return;
3011 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303012 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003013 sizeof(struct sSirSmeSetContextReq));
3014 sme_session_id = set_context_req->sessionId;
3015 sme_transaction_id = set_context_req->transactionId;
3016
3017 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
3018 lim_log(mac_ctx, LOGW,
3019 FL("received invalid SME_SETCONTEXT_REQ message"));
3020 goto end;
3021 }
3022
3023 if (set_context_req->keyMaterial.numKeys >
3024 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3025 lim_log(mac_ctx, LOGE, FL(
3026 "numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS"),
3027 set_context_req->keyMaterial.numKeys);
3028 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003029 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003030 eSIR_SME_INVALID_PARAMETERS, NULL,
3031 sme_session_id, sme_transaction_id);
3032 goto end;
3033 }
3034
3035 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003036 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003037 if (session_entry == NULL) {
3038 lim_log(mac_ctx, LOGW,
3039 FL("Session does not exist for given BSSID"));
3040 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003041 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003042 eSIR_SME_INVALID_PARAMETERS, NULL,
3043 sme_session_id, sme_transaction_id);
3044 goto end;
3045 }
3046#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3047 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
3048 session_entry, 0, 0);
3049#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3050
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003051 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003052 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3053 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003054 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003055 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
3056 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303057 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003058 if (NULL == mlm_set_key_req) {
3059 lim_log(mac_ctx, LOGP, FL(
3060 "mem alloc failed for mlmSetKeysReq"));
3061 goto end;
3062 }
3063 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
3064 mlm_set_key_req->numKeys =
3065 set_context_req->keyMaterial.numKeys;
3066 if (mlm_set_key_req->numKeys >
3067 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3068 lim_log(mac_ctx, LOGP, FL(
3069 "no.of keys exceeded max num of default keys limit"));
3070 goto end;
3071 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05303072 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003073 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003074
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303075 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003076 (uint8_t *) &set_context_req->keyMaterial.key,
3077 sizeof(tSirKeys) *
3078 (mlm_set_key_req->numKeys ? mlm_set_key_req->
3079 numKeys : 1));
3080
3081 mlm_set_key_req->sessionId = session_id;
3082 mlm_set_key_req->smesessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003083 lim_log(mac_ctx, LOG1, FL(
3084 "received SETCONTEXT_REQ message sessionId=%d"),
3085 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003086
3087 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
3088 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
3089 LIM_IS_AP_ROLE(session_entry)) {
3090 if (set_context_req->keyMaterial.key[0].keyLength) {
3091 uint8_t key_id;
3092 key_id =
3093 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303094 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003095 &session_entry->WEPKeyMaterial[key_id],
3096 (uint8_t *) &set_context_req->keyMaterial,
3097 sizeof(tSirKeyMaterial));
3098 } else {
3099 uint32_t i;
3100 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
3101 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303102 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003103 &mlm_set_key_req->key[i],
3104 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
3105 sizeof(tSirKeys));
3106 }
3107 }
3108 }
3109 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
3110 (uint32_t *) mlm_set_key_req);
3111 } else {
3112 lim_log(mac_ctx, LOGE, FL(
3113 "rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
3114 GET_LIM_SYSTEM_ROLE(session_entry),
3115 session_entry->limSmeState);
3116 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
3117
3118 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003119 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003120 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
3121 session_entry, sme_session_id,
3122 sme_transaction_id);
3123 }
3124end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303125 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003126 return;
3127}
3128
3129/**
3130 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
3131 *
3132 * @mac_ctx: Pointer to Global MAC structure
3133 * @msg_buf: pointer to the SME message buffer
3134 *
3135 * This function is called to process SME_GET_ASSOC_STAS_REQ message
3136 * from HDD or upper layer application.
3137 *
3138 * Return: None
3139 */
3140
3141void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
3142 uint32_t *msg_buf)
3143{
3144 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3145 tpDphHashNode sta_ds = NULL;
3146 tpPESession session_entry = NULL;
3147 tSap_Event sap_event;
3148 tpWLAN_SAPEventCB sap_event_cb = NULL;
3149 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3150 uint8_t session_id = CSR_SESSION_ID_INVALID;
3151 uint8_t assoc_id = 0;
3152 uint8_t sta_cnt = 0;
3153
3154 if (msg_buf == NULL) {
3155 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3156 return;
3157 }
3158
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303159 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003160 sizeof(struct sSirSmeGetAssocSTAsReq));
3161 /*
3162 * Get Associated stations from PE.
3163 * Find PE session Entry
3164 */
3165 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003166 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003167 &session_id);
3168 if (session_entry == NULL) {
3169 lim_log(mac_ctx, LOGE,
3170 FL("session does not exist for given bssId"));
3171 goto lim_assoc_sta_end;
3172 }
3173
3174 if (!LIM_IS_AP_ROLE(session_entry)) {
3175 lim_log(mac_ctx, LOGE, FL(
3176 "Received unexpected message in state %X, in role %X"),
3177 session_entry->limSmeState,
3178 GET_LIM_SYSTEM_ROLE(session_entry));
3179 goto lim_assoc_sta_end;
3180 }
3181 /* Retrieve values obtained in the request message */
3182 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3183 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3184
3185 if (NULL == assoc_sta_tmp)
3186 goto lim_assoc_sta_end;
3187 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3188 assoc_id++) {
3189 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3190 &session_entry->dph.dphHashTable);
3191 if (NULL == sta_ds)
3192 continue;
3193 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303194 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003195 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303196 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003197 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3198 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3199
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303200 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003201 (uint8_t *)&sta_ds->supportedRates,
3202 sizeof(tSirSupportedRates));
3203 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3204 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3205 assoc_sta_tmp->Support40Mhz =
3206 sta_ds->htDsssCckRate40MHzSupport;
3207
3208 lim_log(mac_ctx, LOG1, FL("dph Station Number = %d"),
3209 sta_cnt + 1);
3210 lim_log(mac_ctx, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3211 MAC_ADDR_ARRAY(sta_ds->staAddr));
3212 lim_log(mac_ctx, LOG1, FL("Association Id = %d"),
3213 sta_ds->assocId);
3214 lim_log(mac_ctx, LOG1, FL("Station Index = %d"),
3215 sta_ds->staIndex);
3216 assoc_sta_tmp++;
3217 sta_cnt++;
3218 }
3219 }
3220lim_assoc_sta_end:
3221 /*
3222 * Call hdd callback with sap event to send the list of
3223 * associated stations from PE
3224 */
3225 if (sap_event_cb != NULL) {
3226 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3227 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303228 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003229 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3230 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3231 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3232 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3233 }
3234}
3235
3236/**
3237 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3238 *
3239 * @mac_ctx: Pointer to Global MAC structure
3240 * @msg_buf: pointer to WPS PBC overlap query message
3241 *
3242 * This function parses get WPS PBC overlap information
3243 * message and call callback to pass WPS PBC overlap
3244 * information back to hdd.
3245 *
3246 * Return: None
3247 */
3248void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3249 uint32_t *msg_buf)
3250{
3251 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3252 tpPESession session_entry = NULL;
3253 tSap_Event sap_event;
3254 tpWLAN_SAPEventCB sap_event_cb = NULL;
3255 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003256 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3257
3258 if (msg_buf == NULL) {
3259 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3260 return;
3261 }
3262
3263 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303264 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003265
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303266 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003267 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3268 /*
3269 * Get Associated stations from PE
3270 * Find PE session Entry
3271 */
3272 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003273 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003274 if (session_entry == NULL) {
3275 lim_log(mac_ctx, LOGE,
3276 FL("session does not exist for given bssId"));
3277 goto lim_get_wpspbc_sessions_end;
3278 }
3279
3280 if (!LIM_IS_AP_ROLE(session_entry)) {
3281 lim_log(mac_ctx, LOGE,
3282 FL("Received unexpected message in role %X"),
3283 GET_LIM_SYSTEM_ROLE(session_entry));
3284 goto lim_get_wpspbc_sessions_end;
3285 }
3286 /*
3287 * Call hdd callback with sap event to send the
3288 * WPS PBC overlap information
3289 */
3290 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303291 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003292
Anurag Chouhanc5548422016-02-24 18:33:27 +05303293 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003294 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003295 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003296 sap_get_wpspbc_event->UUID_E,
3297 &sap_get_wpspbc_event->wpsPBCOverlap,
3298 session_entry);
3299 } else {
3300 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003301 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003302 session_entry);
3303 /* don't have to inform the HDD/Host */
3304 return;
3305 }
3306
3307 lim_log(mac_ctx, LOGE, FL("wpsPBCOverlap %d"),
3308 sap_get_wpspbc_event->wpsPBCOverlap);
3309 lim_print_mac_addr(mac_ctx,
3310 sap_get_wpspbc_event->addr.bytes, LOG4);
3311
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303312 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003313
3314lim_get_wpspbc_sessions_end:
3315 sap_event_cb =
3316 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3317 if (NULL != sap_event_cb)
3318 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3319}
3320
3321/**
3322 * __lim_counter_measures()
3323 *
3324 * FUNCTION:
3325 * This function is called to "implement" MIC counter measure
3326 * and is *temporary* only
3327 *
3328 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3329 * we don't do the proper STA disassoc sequence since the
3330 * BSS will be stoped anyway
3331 *
3332 ***ASSUMPTIONS:
3333 *
3334 ***NOTE:
3335 *
3336 * @param pMac Pointer to Global MAC structure
3337 * @return None
3338 */
3339
3340static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3341{
3342 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003343 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003344 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3345 mac, psessionEntry, false);
3346};
3347
3348void lim_process_tkip_counter_measures(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3349{
3350 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3351 tpPESession psessionEntry;
3352 uint8_t sessionId; /* PE sessionId */
3353
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303354 qdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003355 sizeof(struct sSirSmeTkipCntrMeasReq));
3356
3357 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003358 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003359 if (NULL == psessionEntry) {
3360 lim_log(pMac, LOGE,
3361 FL("session does not exist for given BSSID "));
3362 return;
3363 }
3364
3365 if (tkipCntrMeasReq.bEnable)
3366 __lim_counter_measures(pMac, psessionEntry);
3367
3368 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3369}
3370
3371static void
3372__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3373{
3374 tSirSmeStopBssReq stopBssReq;
3375 tSirRetStatus status;
3376 tLimSmeStates prevState;
3377 tpPESession psessionEntry;
3378 uint8_t smesessionId;
3379 uint8_t sessionId;
3380 uint16_t smetransactionId;
3381 uint8_t i = 0;
3382 tpDphHashNode pStaDs = NULL;
3383
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303384 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003385 smesessionId = stopBssReq.sessionId;
3386 smetransactionId = stopBssReq.transactionId;
3387
3388 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
3389 PELOGW(lim_log(pMac, LOGW,
3390 FL("received invalid SME_STOP_BSS_REQ message"));)
3391 /* Send Stop BSS response to host */
3392 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3393 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3394 smetransactionId);
3395 return;
3396 }
3397
3398 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003399 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003400 &sessionId);
3401 if (psessionEntry == NULL) {
3402 lim_log(pMac, LOGW,
3403 FL("session does not exist for given BSSID "));
3404 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3405 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3406 smetransactionId);
3407 return;
3408 }
3409#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3410 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3411 0, 0);
3412#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3413
3414 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3415 LIM_IS_STA_ROLE(psessionEntry)) {
3416 /**
3417 * Should not have received STOP_BSS_REQ in states
3418 * other than 'normal' state or on STA in Infrastructure
3419 * mode. Log error and return response to host.
3420 */
3421 lim_log(pMac, LOGE,
3422 FL
3423 ("received unexpected SME_STOP_BSS_REQ in state %X, for role %d"),
3424 psessionEntry->limSmeState,
3425 GET_LIM_SYSTEM_ROLE(psessionEntry));
3426 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3427 /* / Send Stop BSS response to host */
3428 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3429 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3430 smetransactionId);
3431 return;
3432 }
3433
3434 if (LIM_IS_AP_ROLE(psessionEntry))
3435 lim_wpspbc_close(pMac, psessionEntry);
3436
3437 lim_log(pMac, LOGW,
3438 FL("RECEIVED STOP_BSS_REQ with reason code=%d"),
3439 stopBssReq.reasonCode);
3440
3441 prevState = psessionEntry->limSmeState;
3442
3443 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3444 MTRACE(mac_trace
3445 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3446 psessionEntry->limSmeState));
3447
3448 /* Update SME session Id and Transaction Id */
3449 psessionEntry->smeSessionId = smesessionId;
3450 psessionEntry->transactionId = smetransactionId;
3451
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003452 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3453 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3454 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003455 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3456 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3457 /* Send disassoc all stations associated thru TKIP */
3458 __lim_counter_measures(pMac, psessionEntry);
3459 else
3460 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003461 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3462 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003463 }
3464
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003465 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3466 /* Free the buffer allocated in START_BSS_REQ */
3467 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3468 psessionEntry->addIeParams.probeRespDataLen = 0;
3469 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003470
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003471 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3472 psessionEntry->addIeParams.assocRespDataLen = 0;
3473 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003474
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003475 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3476 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3477 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003478
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003479 /*
3480 * lim_del_bss is also called as part of coalescing,
3481 * when we send DEL BSS followed by Add Bss msg.
3482 */
3483 pMac->lim.gLimIbssCoalescingHappened = false;
3484 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003485 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3486 pStaDs =
3487 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3488 if (NULL == pStaDs)
3489 continue;
3490 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3491 if (eSIR_SUCCESS == status) {
3492 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3493 pStaDs->assocId, psessionEntry);
3494 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3495 } else {
3496 lim_log(pMac, LOGE,
3497 FL("lim_del_sta failed with Status : %d"), status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303498 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003499 }
3500 }
3501 /* send a delBss to HAL and wait for a response */
3502 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3503
3504 if (status != eSIR_SUCCESS) {
3505 PELOGE(lim_log
3506 (pMac, LOGE, FL("delBss failed for bss %d"),
3507 psessionEntry->bssIdx);
3508 )
3509 psessionEntry->limSmeState = prevState;
3510
3511 MTRACE(mac_trace
3512 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3513 psessionEntry->limSmeState));
3514
3515 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3516 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3517 smetransactionId);
3518 }
3519}
3520
3521/**
3522 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3523 * @pMac: Global MAC context
3524 * @pMsg: Message from SME
3525 *
3526 * Wrapper for the function __lim_handle_sme_stop_bss_request
3527 * This message will be defered until softmac come out of
3528 * scan mode. Message should be handled even if we have
3529 * detected radar in the current operating channel.
3530 *
3531 * Return: true - If we consumed the buffer
3532 * false - If have defered the message.
3533 */
3534
3535static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3536{
3537 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3538 /**
3539 * If message defered, buffer is not consumed yet.
3540 * So return false
3541 */
3542 return false;
3543 }
3544 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3545 return true;
3546} /*** end __lim_process_sme_stop_bss_req() ***/
3547
3548void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3549 uint32_t body, tpPESession psessionEntry)
3550{
3551
3552 (void)body;
3553 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3554 lim_ibss_delete(pMac, psessionEntry);
3555 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3556 lim_delete_pre_auth_list(pMac);
3557 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3558 psessionEntry->smeSessionId,
3559 psessionEntry->transactionId);
3560 return;
3561}
3562
3563/**
3564 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3565 *
3566 * @mac_ctx: pointer to mac context
3567 * @msg_type: message type
3568 * @msg_buf: pointer to the SME message buffer
3569 *
3570 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3571 * in BTAMP AP.
3572 *
3573 * Return: None
3574 */
3575
3576void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3577 uint32_t *msg_buf)
3578{
3579 tSirSmeAssocCnf assoc_cnf;
3580 tpDphHashNode sta_ds = NULL;
3581 tpPESession session_entry = NULL;
3582 uint8_t session_id;
3583 tpSirAssocReq assoc_req;
3584
3585 if (msg_buf == NULL) {
3586 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL "));
3587 goto end;
3588 }
3589
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303590 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003591 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
3592 lim_log(mac_ctx, LOGE,
3593 FL("Received invalid SME_RE(ASSOC)_CNF message "));
3594 goto end;
3595 }
3596
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003597 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003598 &session_id);
3599 if (session_entry == NULL) {
3600 lim_log(mac_ctx, LOGE,
3601 FL("session does not exist for given bssId"));
3602 goto end;
3603 }
3604
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003605 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003606 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3607 (session_entry->limSmeState !=
3608 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
3609 lim_log(mac_ctx, LOGE, FL(
3610 "Rcvd unexpected msg %X in state %X, in role %X"),
3611 msg_type, session_entry->limSmeState,
3612 GET_LIM_SYSTEM_ROLE(session_entry));
3613 goto end;
3614 }
3615 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3616 &session_entry->dph.dphHashTable);
3617 if (sta_ds == NULL) {
3618 lim_log(mac_ctx, LOGE, FL(
3619 "Rcvd invalid msg %X due to no STA ctx, aid %d, peer "),
3620 msg_type, assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003621 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003622
3623 /*
3624 * send a DISASSOC_IND message to WSM to make sure
3625 * the state in WSM and LIM is the same
3626 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003627 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003628 eSIR_SME_STA_NOT_ASSOCIATED,
3629 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3630 session_entry->smeSessionId,
3631 session_entry->transactionId,
3632 session_entry);
3633 goto end;
3634 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303635 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003636 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303637 QDF_MAC_ADDR_SIZE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003638 lim_log(mac_ctx, LOG1, FL(
3639 "peerMacAddr mismatched for aid %d, peer "),
3640 assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003641 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003642 goto end;
3643 }
3644
3645 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3646 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3647 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3648 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3649 (msg_type != eWNI_SME_ASSOC_CNF))) {
3650 lim_log(mac_ctx, LOG1, FL(
3651 "not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3652 "StaD mlmState : %d"),
3653 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003654 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003655 goto end;
3656 }
3657 /*
3658 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3659 * has been received
3660 */
3661 lim_log(mac_ctx, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
3662 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3663 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3664
3665 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3666 /*
3667 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3668 * when it had received Assoc Request frame. Now, PE just needs
3669 * to send association rsp frame to the requesting BTAMP-STA.
3670 */
3671 sta_ds->mlmStaContext.mlmState =
3672 eLIM_MLM_LINK_ESTABLISHED_STATE;
3673 lim_log(mac_ctx, LOG1,
3674 FL("sending Assoc Rsp frame to STA (assoc id=%d) "),
3675 sta_ds->assocId);
3676 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3677 sta_ds->assocId, sta_ds->staAddr,
3678 sta_ds->mlmStaContext.subType, sta_ds,
3679 session_entry);
3680 goto end;
3681 } else {
3682 /*
3683 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3684 * to be associated since the HAL sta entry is created for
3685 * denied STA we need to remove this HAL entry.
3686 * So to do that set updateContext to 1
3687 */
3688 if (!sta_ds->mlmStaContext.updateContext)
3689 sta_ds->mlmStaContext.updateContext = 1;
3690 lim_log(mac_ctx, LOG1,
3691 FL("Recv Assoc Cnf, status Code : %d(assoc id=%d) "),
3692 assoc_cnf.statusCode, sta_ds->assocId);
3693 lim_reject_association(mac_ctx, sta_ds->staAddr,
3694 sta_ds->mlmStaContext.subType,
3695 true, sta_ds->mlmStaContext.authType,
3696 sta_ds->assocId, true,
3697 eSIR_MAC_UNSPEC_FAILURE_STATUS,
3698 session_entry);
3699 }
3700end:
3701 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3702 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3703 assoc_req = (tpSirAssocReq)
3704 session_entry->parsedAssocReq[sta_ds->assocId];
3705 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303706 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003707 assoc_req->assocReqFrame = NULL;
3708 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303709 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003710 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3711 }
3712}
3713
3714static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3715{
3716 tpDphHashNode pStaDs;
3717 tSirMacAddr peerMac;
3718 tpSirAddtsReq pSirAddts;
3719 uint32_t timeout;
3720 tpPESession psessionEntry;
3721 uint8_t sessionId; /* PE sessionId */
3722 uint8_t smesessionId;
3723 uint16_t smetransactionId;
3724
3725 if (pMsgBuf == NULL) {
3726 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
3727 return;
3728 }
3729
3730 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3731 &smetransactionId);
3732
3733 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3734
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003735 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3736 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003737 if (psessionEntry == NULL) {
3738 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3739 return;
3740 }
3741#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3742 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3743 0);
3744#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3745
3746 /* if sta
3747 * - verify assoc state
3748 * - send addts request to ap
3749 * - wait for addts response from ap
3750 * if ap, just ignore with error log
3751 */
3752 PELOG1(lim_log(pMac, LOG1,
3753 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
3754 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3755 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
3756 )
3757
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003758 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003759 PELOGE(lim_log(pMac, LOGE, "AddTs received on AP - ignoring");)
3760 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3761 psessionEntry, pSirAddts->req.tspec,
3762 smesessionId, smetransactionId);
3763 return;
3764 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003765
3766 pStaDs =
3767 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3768 &psessionEntry->dph.dphHashTable);
3769
3770 if (pStaDs == NULL) {
3771 PELOGE(lim_log
3772 (pMac, LOGE, "Cannot find AP context for addts req");
3773 )
3774 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3775 psessionEntry, pSirAddts->req.tspec,
3776 smesessionId, smetransactionId);
3777 return;
3778 }
3779
3780 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3781 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
3782 lim_log(pMac, LOGE, "AddTs received in invalid MLM state");
3783 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3784 psessionEntry, pSirAddts->req.tspec,
3785 smesessionId, smetransactionId);
3786 return;
3787 }
3788
3789 pSirAddts->req.wsmTspecPresent = 0;
3790 pSirAddts->req.wmeTspecPresent = 0;
3791 pSirAddts->req.lleTspecPresent = 0;
3792
3793 if ((pStaDs->wsmEnabled) &&
3794 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3795 SIR_MAC_ACCESSPOLICY_EDCA))
3796 pSirAddts->req.wsmTspecPresent = 1;
3797 else if (pStaDs->wmeEnabled)
3798 pSirAddts->req.wmeTspecPresent = 1;
3799 else if (pStaDs->lleEnabled)
3800 pSirAddts->req.lleTspecPresent = 1;
3801 else {
3802 PELOGW(lim_log
3803 (pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));
3804 )
3805 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3806 psessionEntry, pSirAddts->req.tspec,
3807 smesessionId, smetransactionId);
3808 return;
3809 }
3810
3811 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3812 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
3813 lim_log(pMac, LOGE,
3814 "AddTs received in invalid LIMsme state (%d)",
3815 psessionEntry->limSmeState);
3816 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3817 psessionEntry, pSirAddts->req.tspec,
3818 smesessionId, smetransactionId);
3819 return;
3820 }
3821
3822 if (pMac->lim.gLimAddtsSent) {
3823 lim_log(pMac, LOGE,
3824 "Addts (token %d, tsid %d, up %d) is still pending",
3825 pMac->lim.gLimAddtsReq.req.dialogToken,
3826 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3827 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3828 userPrio);
3829 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3830 psessionEntry, pSirAddts->req.tspec,
3831 smesessionId, smetransactionId);
3832 return;
3833 }
3834
3835 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3836
3837 /* save the addts request */
3838 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303839 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003840 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3841
3842 /* ship out the message now */
3843 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3844 psessionEntry);
3845 PELOG1(lim_log(pMac, LOG1, "Sent ADDTS request");)
3846 /* start a timer to wait for the response */
3847 if (pSirAddts->timeout)
3848 timeout = pSirAddts->timeout;
3849 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3850 eSIR_SUCCESS) {
3851 lim_log(pMac, LOGP,
3852 FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
3853 WNI_CFG_ADDTS_RSP_TIMEOUT);
3854 return;
3855 }
3856
3857 timeout = SYS_MS_TO_TICKS(timeout);
3858 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3859 != TX_SUCCESS) {
3860 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3861 return;
3862 }
3863 pMac->lim.gLimAddtsRspTimerCount++;
3864 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3865 pMac->lim.gLimAddtsRspTimerCount) !=
3866 TX_SUCCESS) {
3867 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3868 return;
3869 }
3870 MTRACE(mac_trace
3871 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3872 eLIM_ADDTS_RSP_TIMER));
3873
3874 /* add the sessionId to the timer object */
3875 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3876 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3877 TX_SUCCESS) {
3878 lim_log(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
3879 return;
3880 }
3881 return;
3882}
3883
3884static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3885{
3886 tSirMacAddr peerMacAddr;
3887 uint8_t ac;
3888 tSirMacTSInfo *pTsinfo;
3889 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3890 tpDphHashNode pStaDs = NULL;
3891 tpPESession psessionEntry;
3892 uint8_t sessionId;
3893 uint32_t status = eSIR_SUCCESS;
3894 uint8_t smesessionId;
3895 uint16_t smetransactionId;
3896
3897 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3898 &smetransactionId);
3899
3900 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003901 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003902 &sessionId);
3903 if (psessionEntry == NULL) {
3904 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3905 status = eSIR_FAILURE;
3906 goto end;
3907 }
3908#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3909 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3910 0);
3911#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3912
3913 if (eSIR_SUCCESS !=
3914 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
3915 PELOGE(lim_log(pMac, LOGE, FL("lim_validate_delts_req failed"));)
3916 status = eSIR_FAILURE;
3917 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3918 smesessionId, smetransactionId);
3919 return;
3920 }
3921
3922 lim_log(pMac, LOG1,
3923 FL("Sent DELTS request to station with assocId = %d MacAddr = "
3924 MAC_ADDRESS_STR),
3925 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3926
3927 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3928 pDeltsReq->req.wmeTspecPresent,
3929 &pDeltsReq->req.tsinfo,
3930 &pDeltsReq->req.tspec, psessionEntry);
3931
3932 pTsinfo =
3933 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3934 tsinfo : &pDeltsReq->req.tsinfo;
3935
3936 /* We've successfully send DELTS frame to AP. Update the
3937 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3938 * is no longer trigger enabled or delivery enabled
3939 */
3940 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3941 pTsinfo, CLEAR_UAPSD_MASK);
3942
3943 /* We're deleting the TSPEC, so this particular AC is no longer
3944 * admitted. PE needs to downgrade the EDCA
3945 * parameters(for the AC for which TS is being deleted) to the
3946 * next best AC for which ACM is not enabled, and send the
3947 * updated values to HAL.
3948 */
3949 ac = upToAc(pTsinfo->traffic.userPrio);
3950
3951 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3952 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3953 ~(1 << ac);
3954 } else if (pTsinfo->traffic.direction ==
3955 SIR_MAC_DIRECTION_DNLINK) {
3956 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3957 ~(1 << ac);
3958 } else if (pTsinfo->traffic.direction ==
3959 SIR_MAC_DIRECTION_BIDIR) {
3960 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3961 ~(1 << ac);
3962 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3963 ~(1 << ac);
3964 }
3965
3966 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3967 psessionEntry);
3968
3969 pStaDs =
3970 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3971 &psessionEntry->dph.dphHashTable);
3972 if (pStaDs != NULL) {
3973 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3974 pStaDs->bssId);
3975 status = eSIR_SUCCESS;
3976 } else {
3977 lim_log(pMac, LOGE, FL("Self entry missing in Hash Table "));
3978 status = eSIR_FAILURE;
3979 }
3980#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003981 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003982#endif
3983
3984 /* send an sme response back */
3985end:
3986 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3987 smesessionId, smetransactionId);
3988}
3989
3990void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
3991{
3992 /* fetch the sessionEntry based on the sessionId */
3993 tpPESession psessionEntry;
3994 psessionEntry = pe_find_session_by_session_id(pMac,
3995 pMac->lim.limTimers.gLimAddtsRspTimer.
3996 sessionId);
3997 if (psessionEntry == NULL) {
3998 lim_log(pMac, LOGP,
3999 FL("Session Does not exist for given sessionID"));
4000 return;
4001 }
4002
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07004003 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004004 lim_log(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)",
4005 GET_LIM_SYSTEM_ROLE(psessionEntry));
4006 pMac->lim.gLimAddtsSent = false;
4007 return;
4008 }
4009
4010 if (!pMac->lim.gLimAddtsSent) {
4011 lim_log(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");
4012 return;
4013 }
4014
4015 if (param != pMac->lim.gLimAddtsRspTimerCount) {
4016 lim_log(pMac, LOGE,
4017 FL("Invalid AddtsRsp Timer count %d (exp %d)"), param,
4018 pMac->lim.gLimAddtsRspTimerCount);
4019 return;
4020 }
4021 /* this a real response timeout */
4022 pMac->lim.gLimAddtsSent = false;
4023 pMac->lim.gLimAddtsRspTimerCount++;
4024
4025 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
4026 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
4027 psessionEntry->smeSessionId,
4028 psessionEntry->transactionId);
4029}
4030
4031/**
4032 * __lim_process_sme_get_statistics_request()
4033 *
4034 ***FUNCTION:
4035 *
4036 *
4037 ***NOTE:
4038 *
4039 * @param pMac Pointer to Global MAC structure
4040 * @param *pMsgBuf A pointer to the SME message buffer
4041 * @return None
4042 */
4043static void
4044__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4045{
4046 tpAniGetPEStatsReq pPEStatsReq;
4047 tSirMsgQ msgQ;
4048
4049 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4050
4051 msgQ.type = WMA_GET_STATISTICS_REQ;
4052
4053 msgQ.reserved = 0;
4054 msgQ.bodyptr = pMsgBuf;
4055 msgQ.bodyval = 0;
4056 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4057
4058 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304059 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004060 pMsgBuf = NULL;
4061 lim_log(pMac, LOGP, "Unable to forward request");
4062 return;
4063 }
4064
4065 return;
4066}
4067
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004068#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004069/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004070 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004071 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004072 * @pMac: Pointer to Global MAC structure
4073 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004074 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004075 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004076 */
4077static void
4078__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4079{
4080 tSirMsgQ msgQ;
4081
4082 msgQ.type = WMA_TSM_STATS_REQ;
4083 msgQ.reserved = 0;
4084 msgQ.bodyptr = pMsgBuf;
4085 msgQ.bodyval = 0;
4086 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4087
4088 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304089 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004090 pMsgBuf = NULL;
4091 lim_log(pMac, LOGP, "Unable to forward request");
4092 return;
4093 }
4094}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004095#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004096
4097static void
4098__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4099{
4100 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4101 tpPESession psessionEntry;
4102 uint8_t sessionId; /* PE sessionID */
4103
4104 PELOG1(lim_log(pMac, LOG1, FL("received UPDATE_APWPSIEs_REQ message")););
4105
4106 if (pMsgBuf == NULL) {
4107 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4108 return;
4109 }
4110
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304111 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004112 if (NULL == pUpdateAPWPSIEsReq) {
4113 lim_log(pMac, LOGP,
4114 FL
4115 ("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
4116 return;
4117 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304118 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004119 sizeof(struct sSirUpdateAPWPSIEsReq));
4120
4121 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08004122 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004123 &sessionId);
4124 if (psessionEntry == NULL) {
4125 lim_log(pMac, LOGW,
4126 FL("Session does not exist for given BSSID"));
4127 goto end;
4128 }
4129
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304130 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004131 sizeof(tSirAPWPSIEs));
4132
4133 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4134 lim_send_beacon_ind(pMac, psessionEntry);
4135
4136end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304137 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004138 return;
4139}
4140
4141void
4142lim_send_vdev_restart(tpAniSirGlobal pMac,
4143 tpPESession psessionEntry, uint8_t sessionId)
4144{
4145 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
4146 tSirMsgQ msgQ;
4147 tSirRetStatus retCode = eSIR_SUCCESS;
4148
4149 if (psessionEntry == NULL) {
4150 PELOGE(lim_log
4151 (pMac, LOGE, "%s:%d: Invalid parameters", __func__,
4152 __LINE__);
4153 )
4154 return;
4155 }
4156
4157 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304158 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004159 if (NULL == pHalHiddenSsidVdevRestart) {
4160 PELOGE(lim_log
4161 (pMac, LOGE, "%s:%d: Unable to allocate memory",
4162 __func__, __LINE__);
4163 )
4164 return;
4165 }
4166
4167 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4168 pHalHiddenSsidVdevRestart->sessionId = sessionId;
4169
4170 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4171 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4172 msgQ.bodyval = 0;
4173
4174 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4175 if (eSIR_SUCCESS != retCode) {
4176 PELOGE(lim_log
4177 (pMac, LOGE, "%s:%d: wma_post_ctrl_msg() failed", __func__,
4178 __LINE__);
4179 )
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304180 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004181 }
4182}
4183
4184static void __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4185{
4186 tpSirUpdateParams pUpdateParams;
4187 tpPESession psessionEntry;
4188
4189 PELOG1(lim_log(pMac, LOG1, FL("received HIDE_SSID message")););
4190
4191 if (pMsgBuf == NULL) {
4192 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4193 return;
4194 }
4195
4196 pUpdateParams = (tpSirUpdateParams) pMsgBuf;
4197
Naveen Rawat9e4872a2015-11-13 09:43:11 -08004198 psessionEntry = pe_find_session_by_sme_session_id(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004199 pUpdateParams->sessionId);
4200 if (psessionEntry == NULL) {
4201 lim_log(pMac, LOGW,
4202 "Session does not exist for given sessionId %d",
4203 pUpdateParams->sessionId);
4204 return;
4205 }
4206
4207 /* Update the session entry */
4208 psessionEntry->ssidHidden = pUpdateParams->ssidHidden;
4209
4210 /* Send vdev restart */
4211 lim_send_vdev_restart(pMac, psessionEntry, pUpdateParams->sessionId);
4212
4213 /* Update beacon */
4214 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4215 lim_send_beacon_ind(pMac, psessionEntry);
4216
4217 return;
4218} /*** end __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4219
4220static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4221{
4222 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4223 tpPESession psessionEntry;
4224 uint8_t sessionId; /* PE sessionID */
4225
4226 if (pMsgBuf == NULL) {
4227 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4228 return;
4229 }
4230
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304231 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004232 if (NULL == pUpdateAPWPARSNIEsReq) {
4233 lim_log(pMac, LOGP,
4234 FL
4235 ("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
4236 return;
4237 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304238 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004239 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4240
4241 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004242 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004243 &sessionId);
4244 if (psessionEntry == NULL) {
4245 lim_log(pMac, LOGW,
4246 FL("Session does not exist for given BSSID"));
4247 goto end;
4248 }
4249
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304250 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004251 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4252
4253 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4254 &psessionEntry->
4255 pLimStartBssReq->rsnIE,
4256 psessionEntry);
4257
4258 psessionEntry->pLimStartBssReq->privacy = 1;
4259 psessionEntry->privacy = 1;
4260
4261 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4262 lim_send_beacon_ind(pMac, psessionEntry);
4263
4264end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304265 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004266 return;
4267} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4268
4269/*
4270 Update the beacon Interval dynamically if beaconInterval is different in MCC
4271 */
4272static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4273{
4274 tpSirChangeBIParams pChangeBIParams;
4275 tpPESession psessionEntry;
4276 uint8_t sessionId = 0;
4277 tUpdateBeaconParams beaconParams;
4278
4279 PELOG1(lim_log(pMac, LOG1,
4280 FL("received Update Beacon Interval message"));
4281 );
4282
4283 if (pMsgBuf == NULL) {
4284 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4285 return;
4286 }
4287
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304288 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004289 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4290
4291 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004292 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004293 &sessionId);
4294 if (psessionEntry == NULL) {
4295 lim_log(pMac, LOGE,
4296 FL("Session does not exist for given BSSID"));
4297 return;
4298 }
4299
4300 /*Update sessionEntry Beacon Interval */
4301 if (psessionEntry->beaconParams.beaconInterval !=
4302 pChangeBIParams->beaconInterval) {
4303 psessionEntry->beaconParams.beaconInterval =
4304 pChangeBIParams->beaconInterval;
4305 }
4306
4307 /*Update sch beaconInterval */
4308 if (pMac->sch.schObject.gSchBeaconInterval !=
4309 pChangeBIParams->beaconInterval) {
4310 pMac->sch.schObject.gSchBeaconInterval =
4311 pChangeBIParams->beaconInterval;
4312
4313 PELOG1(lim_log(pMac, LOG1,
4314 FL
4315 ("LIM send update BeaconInterval Indication : %d"),
4316 pChangeBIParams->beaconInterval);
4317 );
4318
4319 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4320 /* Update beacon */
4321 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4322
4323 beaconParams.bssIdx = psessionEntry->bssIdx;
4324 /* Set change in beacon Interval */
4325 beaconParams.beaconInterval =
4326 pChangeBIParams->beaconInterval;
4327 beaconParams.paramChangeBitmap =
4328 PARAM_BCN_INTERVAL_CHANGED;
4329 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4330 }
4331 }
4332
4333 return;
4334} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4335
4336#ifdef QCA_HT_2040_COEX
4337static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4338 uint32_t *pMsgBuf)
4339{
4340 tpSirSetHT2040Mode pSetHT2040Mode;
4341 tpPESession psessionEntry;
4342 uint8_t sessionId = 0;
4343 cds_msg_t msg;
4344 tUpdateVHTOpMode *pHtOpMode = NULL;
4345 uint16_t staId = 0;
4346 tpDphHashNode pStaDs = NULL;
4347
4348 PELOG1(lim_log(pMac, LOG1, FL("received Set HT 20/40 mode message")););
4349 if (pMsgBuf == NULL) {
4350 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4351 return;
4352 }
4353
4354 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4355
4356 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004357 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004358 &sessionId);
4359 if (psessionEntry == NULL) {
4360 lim_log(pMac, LOG1,
4361 FL("Session does not exist for given BSSID "));
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004362 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004363 return;
4364 }
4365
4366 lim_log(pMac, LOG1, FL("Update session entry for cbMod=%d"),
4367 pSetHT2040Mode->cbMode);
4368 /*Update sessionEntry HT related fields */
4369 switch (pSetHT2040Mode->cbMode) {
4370 case PHY_SINGLE_CHANNEL_CENTERED:
4371 psessionEntry->htSecondaryChannelOffset =
4372 PHY_SINGLE_CHANNEL_CENTERED;
4373 psessionEntry->htRecommendedTxWidthSet = 0;
4374 if (pSetHT2040Mode->obssEnabled)
4375 psessionEntry->htSupportedChannelWidthSet
4376 = eHT_CHANNEL_WIDTH_40MHZ;
4377 else
4378 psessionEntry->htSupportedChannelWidthSet
4379 = eHT_CHANNEL_WIDTH_20MHZ;
4380 break;
4381 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4382 psessionEntry->htSecondaryChannelOffset =
4383 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4384 psessionEntry->htRecommendedTxWidthSet = 1;
4385 break;
4386 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4387 psessionEntry->htSecondaryChannelOffset =
4388 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4389 psessionEntry->htRecommendedTxWidthSet = 1;
4390 break;
4391 default:
4392 lim_log(pMac, LOGE, FL("Invalid cbMode"));
4393 return;
4394 }
4395
4396 /* Update beacon */
4397 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4398 lim_send_beacon_ind(pMac, psessionEntry);
4399
4400 /* update OP Mode for each associated peer */
4401 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4402 pStaDs = dph_get_hash_entry(pMac, staId,
4403 &psessionEntry->dph.dphHashTable);
4404 if (NULL == pStaDs)
4405 continue;
4406
4407 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304408 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004409 if (NULL == pHtOpMode) {
4410 lim_log(pMac, LOGE,
4411 FL
4412 ("%s: Not able to allocate memory for setting OP mode"),
4413 __func__);
4414 return;
4415 }
4416 pHtOpMode->opMode =
4417 (psessionEntry->htSecondaryChannelOffset ==
4418 PHY_SINGLE_CHANNEL_CENTERED) ?
4419 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4420 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304421 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004422 sizeof(tSirMacAddr));
4423 pHtOpMode->smesessionId = sessionId;
4424
4425 msg.type = WMA_UPDATE_OP_MODE;
4426 msg.reserved = 0;
4427 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304428 if (!QDF_IS_STATUS_SUCCESS
Anurag Chouhan6d760662016-02-20 16:05:43 +05304429 (cds_mq_post_message(QDF_MODULE_ID_WMA, &msg))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004430 lim_log(pMac, LOGE,
4431 FL
4432 ("%s: Not able to post WMA_UPDATE_OP_MODE message to WMA"),
4433 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304434 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004435 return;
4436 }
4437 lim_log(pMac, LOG1,
4438 FL
4439 ("%s: Notifed FW about OP mode: %d for staId=%d"),
4440 __func__, pHtOpMode->opMode, staId);
4441
4442 } else
4443 lim_log(pMac, LOG1,
4444 FL("%s: station %d does not support HT40\n"),
4445 __func__, staId);
4446 }
4447
4448 return;
4449}
4450#endif
4451
4452/* -------------------------------------------------------------------- */
4453/**
4454 * __lim_process_report_message
4455 *
4456 * FUNCTION: Processes the next received Radio Resource Management message
4457 *
4458 * LOGIC:
4459 *
4460 * ASSUMPTIONS:
4461 *
4462 * NOTE:
4463 *
4464 * @param None
4465 * @return None
4466 */
4467
4468void __lim_process_report_message(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4469{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004470 switch (pMsg->type) {
4471 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4472 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4473 break;
4474 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004475 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004476 break;
4477 default:
4478 lim_log(pMac, LOGE, FL("Invalid msg type:%d"), pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004479 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004480}
4481
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004482/* -------------------------------------------------------------------- */
4483/**
4484 * lim_send_set_max_tx_power_req
4485 *
4486 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4487 *
4488 * LOGIC:
4489 *
4490 * ASSUMPTIONS:
4491 *
4492 * NOTE:
4493 *
4494 * @param txPower txPower to be set.
4495 * @param pSessionEntry session entry.
4496 * @return None
4497 */
4498tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004499lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004500 tpPESession pSessionEntry)
4501{
4502 tpMaxTxPowerParams pMaxTxParams = NULL;
4503 tSirRetStatus retCode = eSIR_SUCCESS;
4504 tSirMsgQ msgQ;
4505
4506 if (pSessionEntry == NULL) {
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304507 lim_log(pMac, LOGE, FL("Inavalid parameters"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004508 return eSIR_FAILURE;
4509 }
4510
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304511 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004512 if (NULL == pMaxTxParams) {
4513 lim_log(pMac, LOGP,
4514 FL("Unable to allocate memory for pMaxTxParams "));
4515 return eSIR_MEM_ALLOC_FAILED;
4516
4517 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004518 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304519 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304520 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304521 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004522 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304523 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004524
4525 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4526 msgQ.bodyptr = pMaxTxParams;
4527 msgQ.bodyval = 0;
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304528 lim_log(pMac, LOG1, FL("Post WMA_SET_MAX_TX_POWER_REQ to WMA"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004529 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4530 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4531 if (eSIR_SUCCESS != retCode) {
4532 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304533 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004534 }
4535 return retCode;
4536}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004537
4538/**
4539 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4540 *
4541 * @mac_ctx: Pointer to Global MAC structure
4542 * @msg_buf: pointer to the SME message buffer
4543 *
4544 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4545 * from SME. It Register this information within PE.
4546 *
4547 * Return: None
4548 */
4549static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4550 uint32_t *msg_buf)
4551{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304552 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004553 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4554 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4555 struct mgmt_frm_reg_info *next = NULL;
4556 bool match = false;
4557
4558 lim_log(mac_ctx, LOG1, FL(
4559 "registerFrame %d, frameType %d, matchLen %d"),
4560 sme_req->registerFrame, sme_req->frameType,
4561 sme_req->matchLen);
4562 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304563 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304564 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4565 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304566 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004567
4568 while (lim_mgmt_regn != NULL) {
4569 if (lim_mgmt_regn->frameType != sme_req->frameType)
4570 goto skip_match;
4571 if (sme_req->matchLen) {
4572 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304573 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004574 sme_req->matchData,
4575 lim_mgmt_regn->matchLen))) {
4576 /* found match! */
4577 match = true;
4578 break;
4579 }
4580 } else {
4581 /* found match! */
4582 match = true;
4583 break;
4584 }
4585skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304586 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304587 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004588 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304589 (qdf_list_node_t *)lim_mgmt_regn,
4590 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304591 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004592 lim_mgmt_regn = next;
4593 next = NULL;
4594 }
4595 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304596 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304597 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004598 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304599 (qdf_list_node_t *)lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304600 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304601 qdf_mem_free(lim_mgmt_regn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004602 }
4603
4604 if (sme_req->registerFrame) {
4605 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304606 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004607 sme_req->matchLen);
4608 if (lim_mgmt_regn != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304609 qdf_mem_set((void *)lim_mgmt_regn,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004610 sizeof(struct mgmt_frm_reg_info) +
4611 sme_req->matchLen, 0);
4612 lim_mgmt_regn->frameType = sme_req->frameType;
4613 lim_mgmt_regn->matchLen = sme_req->matchLen;
4614 lim_mgmt_regn->sessionId = sme_req->sessionId;
4615 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304616 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004617 sme_req->matchData,
4618 sme_req->matchLen);
4619 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304620 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004621 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304622 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004623 gLimMgmtFrameRegistratinQueue,
4624 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304625 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004626 &mac_ctx->lim.lim_frame_register_lock);
4627 }
4628 }
4629 return;
4630}
4631
4632static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4633{
4634 lim_log(pMac, LOG1, FL("Dereg msgType %d"),
4635 pMac->lim.gDeferMsgTypeForNOA);
4636 pMac->lim.gDeferMsgTypeForNOA = 0;
4637 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4638 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304639 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004640 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4641 }
4642}
4643
4644/**
4645 * lim_process_regd_defd_sme_req_after_noa_start()
4646 *
4647 * mac_ctx: Pointer to Global MAC structure
4648 *
4649 * This function is called to process deferred sme req message
4650 * after noa start.
4651 *
4652 * Return: None
4653 */
4654void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4655{
4656 bool buf_consumed = true;
4657
4658 lim_log(mac_ctx, LOG1, FL("Process defd sme req %d"),
4659 mac_ctx->lim.gDeferMsgTypeForNOA);
4660
4661 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4662 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
4663 lim_log(mac_ctx, LOGW,
4664 FL("start rcvd from FW when no sme deferred msg pending. Do nothing. "));
4665 lim_log(mac_ctx, LOGW,
4666 FL("It may happen when NOA start ind and timeout happen at the same time"));
4667 return;
4668 }
4669 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4670 case eWNI_SME_SCAN_REQ:
4671 __lim_process_sme_scan_req(mac_ctx,
4672 mac_ctx->lim.gpDefdSmeMsgForNOA);
4673 break;
4674#ifdef FEATURE_OEM_DATA_SUPPORT
4675 case eWNI_SME_OEM_DATA_REQ:
4676 __lim_process_sme_oem_data_req(mac_ctx,
4677 mac_ctx->lim.gpDefdSmeMsgForNOA);
4678 break;
4679#endif
4680 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4681 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4682 mac_ctx->lim.gpDefdSmeMsgForNOA);
4683 /*
4684 * lim_process_remain_on_chnl_req doesnt want us to free
4685 * the buffer since it is freed in lim_remain_on_chn_rsp.
4686 * this change is to avoid "double free"
4687 */
4688 if (false == buf_consumed)
4689 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4690 break;
4691 case eWNI_SME_JOIN_REQ:
4692 __lim_process_sme_join_req(mac_ctx,
4693 mac_ctx->lim.gpDefdSmeMsgForNOA);
4694 break;
4695 default:
4696 lim_log(mac_ctx, LOGE, FL("Unknown deferred msg type %d"),
4697 mac_ctx->lim.gDeferMsgTypeForNOA);
4698 break;
4699 }
4700 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4701}
4702
4703static void
4704__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4705{
4706 tpSirResetAPCapsChange pResetCapsChange;
4707 tpPESession psessionEntry;
4708 uint8_t sessionId = 0;
4709 if (pMsgBuf == NULL) {
4710 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4711 return;
4712 }
4713
4714 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4715 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004716 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4717 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004718 if (psessionEntry == NULL) {
4719 lim_log(pMac, LOGE,
4720 FL("Session does not exist for given BSSID"));
4721 return;
4722 }
4723
4724 psessionEntry->limSentCapsChangeNtf = false;
4725 return;
4726}
4727
4728/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304729 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4730 * indication callback in PE.
4731 * @mac_ptr: Mac pointer
4732 * @msg_buf: Msg pointer containing the callback
4733 *
4734 * This function is used save the Management frame
4735 * indication callback in PE.
4736 *
4737 * Return: None
4738 */
4739static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4740 uint32_t *msg_buf)
4741{
4742 struct sir_sme_mgmt_frame_cb_req *sme_req =
4743 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4744
4745 if (NULL == msg_buf) {
4746 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4747 return;
4748 }
4749 if (sme_req->callback)
4750 mac_ctx->mgmt_frame_ind_cb =
4751 (sir_mgmt_frame_ind_callback)sme_req->callback;
4752 else
4753 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4754}
4755
4756/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004757 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4758 * @mac_ctx: Pointer to Global MAC structure
4759 * @pdev_id: pdev id to set the IE.
4760 * @nss: Nss values to prepare the HT IE.
4761 *
4762 * Prepares the HT IE with self capabilities for different
4763 * Nss values and sends the set HT IE req to FW.
4764 *
4765 * Return: None
4766 */
4767static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4768 uint8_t nss)
4769{
4770 struct set_ie_param *ie_params;
4771 tSirMsgQ msg;
4772 tSirRetStatus rc = eSIR_SUCCESS;
4773 uint8_t *p_ie = NULL;
4774 tHtCaps *p_ht_cap;
4775 int i;
4776
4777 for (i = nss; i > 0; i--) {
4778 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4779 if (NULL == ie_params) {
4780 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4781 return;
4782 }
4783 ie_params->nss = i;
4784 ie_params->pdev_id = pdev_id;
4785 ie_params->ie_type = DOT11_HT_IE;
4786 /* 2 for IE len and EID */
4787 ie_params->ie_len = 2 + sizeof(tHtCaps);
4788 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4789 if (NULL == ie_params->ie_ptr) {
4790 qdf_mem_free(ie_params);
4791 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4792 return;
4793 }
4794 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4795 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4796 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4797 ie_params->ie_len);
4798
4799 if (NSS_1x1_MODE == i) {
4800 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4801 ie_params->ie_len,
4802 DOT11F_EID_HTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004803 if (NULL == p_ie) {
4804 qdf_mem_free(ie_params->ie_ptr);
4805 qdf_mem_free(ie_params);
4806 lim_log(mac_ctx, LOGE,
4807 FL("failed to get IE ptr"));
4808 return;
4809 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004810 p_ht_cap = (tHtCaps *)&p_ie[2];
4811 p_ht_cap->supportedMCSSet[1] = 0;
4812 p_ht_cap->txSTBC = 0;
4813 }
4814
4815 msg.type = WMA_SET_PDEV_IE_REQ;
4816 msg.bodyptr = ie_params;
4817 msg.bodyval = 0;
4818
4819 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4820 if (rc != eSIR_SUCCESS) {
4821 lim_log(mac_ctx, LOGE,
4822 FL("wma_post_ctrl_msg() return failure"));
4823 qdf_mem_free(ie_params->ie_ptr);
4824 qdf_mem_free(ie_params);
4825 return;
4826 }
4827 }
4828}
4829
4830/**
4831 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4832 * @mac_ctx: Pointer to Global MAC structure
4833 * @pdev_id: pdev id to set the IE.
4834 * @nss: Nss values to prepare the VHT IE.
4835 *
4836 * Prepares the VHT IE with self capabilities for different
4837 * Nss values and sends the set VHT IE req to FW.
4838 *
4839 * Return: None
4840 */
4841static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4842 uint8_t nss)
4843{
4844 struct set_ie_param *ie_params;
4845 tSirMsgQ msg;
4846 tSirRetStatus rc = eSIR_SUCCESS;
4847 uint8_t *p_ie = NULL;
4848 tSirMacVHTCapabilityInfo *vht_cap;
4849 int i;
4850 tSirVhtMcsInfo *vht_mcs;
4851
4852 for (i = nss; i > 0; i--) {
4853 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4854 if (NULL == ie_params) {
4855 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4856 return;
4857 }
4858 ie_params->nss = i;
4859 ie_params->pdev_id = pdev_id;
4860 ie_params->ie_type = DOT11_VHT_IE;
4861 /* 2 for IE len and EID */
4862 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4863 sizeof(tSirVhtMcsInfo);
4864 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4865 if (NULL == ie_params->ie_ptr) {
4866 qdf_mem_free(ie_params);
4867 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4868 return;
4869 }
4870 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4871 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4872 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4873 ie_params->ie_len);
4874
4875 if (NSS_1x1_MODE == i) {
4876 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4877 ie_params->ie_len,
4878 DOT11F_EID_VHTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004879 if (NULL == p_ie) {
4880 qdf_mem_free(ie_params->ie_ptr);
4881 qdf_mem_free(ie_params);
4882 lim_log(mac_ctx, LOGE,
4883 FL("failed to get IE ptr"));
4884 return;
4885 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004886 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4887 vht_cap->txSTBC = 0;
4888 vht_mcs =
4889 (tSirVhtMcsInfo *)&p_ie[2 +
4890 sizeof(tSirMacVHTCapabilityInfo)];
4891 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4892 vht_mcs->rxHighest =
4893 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4894 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4895 vht_mcs->txHighest =
4896 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4897 }
4898 msg.type = WMA_SET_PDEV_IE_REQ;
4899 msg.bodyptr = ie_params;
4900 msg.bodyval = 0;
4901
4902 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4903 if (rc != eSIR_SUCCESS) {
4904 lim_log(mac_ctx, LOGE,
4905 FL("wma_post_ctrl_msg failure"));
4906 qdf_mem_free(ie_params->ie_ptr);
4907 qdf_mem_free(ie_params);
4908 return;
4909 }
4910 }
4911}
4912
4913/**
4914 * lim_process_set_pdev_IEs() - process the set pdev IE req
4915 * @mac_ctx: Pointer to Global MAC structure
4916 * @msg_buf: Pointer to the SME message buffer
4917 *
4918 * This function is called by limProcessMessageQueue(). This
4919 * function sets the PDEV IEs to the FW.
4920 *
4921 * Return: None
4922 */
4923static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4924{
4925 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4926
4927 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4928
4929 if (NULL == ht_vht_cfg) {
4930 lim_log(mac_ctx, LOGE, FL("NULL ht_vht_cfg"));
4931 return;
4932 }
4933
4934 lim_log(mac_ctx, LOG1, FL("rcvd set pdev ht vht ie req with nss = %d"),
4935 ht_vht_cfg->nss);
4936 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4937
4938 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4939 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4940 ht_vht_cfg->nss);
4941}
4942
4943/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004944 * lim_process_sme_req_messages()
4945 *
4946 ***FUNCTION:
4947 * This function is called by limProcessMessageQueue(). This
4948 * function processes SME request messages from HDD or upper layer
4949 * application.
4950 *
4951 ***LOGIC:
4952 *
4953 ***ASSUMPTIONS:
4954 *
4955 ***NOTE:
4956 *
4957 * @param pMac Pointer to Global MAC structure
4958 * @param msgType Indicates the SME message type
4959 * @param *pMsgBuf A pointer to the SME message buffer
4960 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4961 * false - if pMsgBuf is not to be freed.
4962 */
4963
4964bool lim_process_sme_req_messages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4965{
4966 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
4967 uint32_t *pMsgBuf = pMsg->bodyptr;
4968 tpSirSmeScanReq pScanReq;
4969 PELOG1(lim_log
4970 (pMac, LOG1,
4971 FL
4972 ("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)"),
4973 lim_msg_str(pMsg->type), pMsg->type,
4974 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4975 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
4976 )
4977
4978 pScanReq = (tpSirSmeScanReq) pMsgBuf;
4979 /* If no insert NOA required then execute the code below */
4980
4981 switch (pMsg->type) {
4982 case eWNI_SME_SYS_READY_IND:
4983 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4984 break;
4985
4986 case eWNI_SME_START_BSS_REQ:
4987 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4988 break;
4989
4990 case eWNI_SME_SCAN_REQ:
4991 __lim_process_sme_scan_req(pMac, pMsgBuf);
4992 break;
4993
4994#ifdef FEATURE_OEM_DATA_SUPPORT
4995 case eWNI_SME_OEM_DATA_REQ:
4996 __lim_process_sme_oem_data_req(pMac, pMsgBuf);
4997 break;
4998#endif
4999 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5000 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
5001 break;
5002
5003 case eWNI_SME_UPDATE_NOA:
5004 __lim_process_sme_no_a_update(pMac, pMsgBuf);
5005 break;
5006 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
5007 __lim_process_clear_dfs_channel_list(pMac, pMsg);
5008 break;
5009 case eWNI_SME_JOIN_REQ:
5010 __lim_process_sme_join_req(pMac, pMsgBuf);
5011 break;
5012
5013 case eWNI_SME_REASSOC_REQ:
5014 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
5015 break;
5016
5017 case eWNI_SME_DISASSOC_REQ:
5018 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
5019 break;
5020
5021 case eWNI_SME_DISASSOC_CNF:
5022 case eWNI_SME_DEAUTH_CNF:
5023 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
5024 break;
5025
5026 case eWNI_SME_DEAUTH_REQ:
5027 __lim_process_sme_deauth_req(pMac, pMsgBuf);
5028 break;
5029
5030 case eWNI_SME_SETCONTEXT_REQ:
5031 __lim_process_sme_set_context_req(pMac, pMsgBuf);
5032 break;
5033
5034 case eWNI_SME_STOP_BSS_REQ:
5035 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
5036 break;
5037
5038 case eWNI_SME_ASSOC_CNF:
5039 if (pMsg->type == eWNI_SME_ASSOC_CNF)
5040 PELOG1(lim_log(pMac,
5041 LOG1, FL("Received ASSOC_CNF message"));)
5042 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
5043 pMsgBuf);
5044 break;
5045
5046 case eWNI_SME_ADDTS_REQ:
5047 PELOG1(lim_log(pMac, LOG1, FL("Received ADDTS_REQ message"));)
5048 __lim_process_sme_addts_req(pMac, pMsgBuf);
5049 break;
5050
5051 case eWNI_SME_DELTS_REQ:
5052 PELOG1(lim_log(pMac, LOG1, FL("Received DELTS_REQ message"));)
5053 __lim_process_sme_delts_req(pMac, pMsgBuf);
5054 break;
5055
5056 case SIR_LIM_ADDTS_RSP_TIMEOUT:
5057 PELOG1(lim_log
5058 (pMac, LOG1,
5059 FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
5060 )
5061 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
5062 break;
5063
5064 case eWNI_SME_GET_STATISTICS_REQ:
5065 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
5066 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
5067 bufConsumed = false;
5068 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005069#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005070 case eWNI_SME_GET_TSM_STATS_REQ:
5071 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
5072 bufConsumed = false;
5073 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005074#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005075 case eWNI_SME_GET_ASSOC_STAS_REQ:
5076 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
5077 break;
5078 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5079 lim_process_tkip_counter_measures(pMac, pMsgBuf);
5080 break;
5081
5082 case eWNI_SME_HIDE_SSID_REQ:
5083 __lim_process_sme_hide_ssid(pMac, pMsgBuf);
5084 break;
5085 case eWNI_SME_UPDATE_APWPSIE_REQ:
5086 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
5087 break;
5088 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5089 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
5090 break;
5091
5092 case eWNI_SME_SET_APWPARSNIEs_REQ:
5093 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
5094 break;
5095
5096 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5097 /* Update the beaconInterval */
5098 __lim_process_sme_change_bi(pMac, pMsgBuf);
5099 break;
5100
5101#ifdef QCA_HT_2040_COEX
5102 case eWNI_SME_SET_HT_2040_MODE:
5103 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
5104 break;
5105#endif
5106
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005107 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5108 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5109 __lim_process_report_message(pMac, pMsg);
5110 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005111
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005112 case eWNI_SME_FT_PRE_AUTH_REQ:
5113 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
5114 break;
5115 case eWNI_SME_FT_UPDATE_KEY:
5116 lim_process_ft_update_key(pMac, pMsgBuf);
5117 break;
5118
5119 case eWNI_SME_FT_AGGR_QOS_REQ:
5120 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
5121 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005122
5123 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5124 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
5125 break;
5126#ifdef FEATURE_WLAN_TDLS
5127 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5128 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
5129 break;
5130 case eWNI_SME_TDLS_ADD_STA_REQ:
5131 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
5132 break;
5133 case eWNI_SME_TDLS_DEL_STA_REQ:
5134 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
5135 break;
5136 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5137 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
5138 break;
5139#endif
5140 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5141 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
5142 break;
5143
5144 case eWNI_SME_CHANNEL_CHANGE_REQ:
5145 lim_process_sme_channel_change_request(pMac, pMsgBuf);
5146 break;
5147
5148 case eWNI_SME_START_BEACON_REQ:
5149 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
5150 break;
5151
5152 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
5153 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
5154 break;
5155
5156 case eWNI_SME_UPDATE_ADDITIONAL_IES:
5157 lim_process_update_add_ies(pMac, pMsgBuf);
5158 break;
5159
5160 case eWNI_SME_MODIFY_ADDITIONAL_IES:
5161 lim_process_modify_add_ies(pMac, pMsgBuf);
5162 break;
5163 case eWNI_SME_SET_HW_MODE_REQ:
5164 lim_process_set_hw_mode(pMac, pMsgBuf);
5165 break;
5166 case eWNI_SME_NSS_UPDATE_REQ:
5167 lim_process_nss_update_request(pMac, pMsgBuf);
5168 break;
5169 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5170 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5171 break;
5172 case eWNI_SME_SET_IE_REQ:
5173 lim_process_set_ie_req(pMac, pMsgBuf);
5174 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305175 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5176 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5177 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305178 case eWNI_SME_EXT_CHANGE_CHANNEL:
5179 lim_process_ext_change_channel(pMac, pMsgBuf);
5180 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005181 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5182 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5183 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005184 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5185 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawatf28315c2016-06-29 18:06:02 -07005186 case eWNI_SME_NDP_END_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005187 case eWNI_SME_NDP_INITIATOR_REQ:
Abhishek Singh4fef7472016-06-06 11:36:03 -07005188 case eWNI_SME_NDP_RESPONDER_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005189 lim_handle_ndp_request_message(pMac, pMsg);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005190 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005191 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305192 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005193 pMsg->bodyptr = NULL;
5194 break;
5195 } /* switch (msgType) */
5196
5197 return bufConsumed;
5198} /*** end lim_process_sme_req_messages() ***/
5199
5200/**
5201 * lim_process_sme_start_beacon_req()
5202 *
5203 ***FUNCTION:
5204 * This function is called by limProcessMessageQueue(). This
5205 * function processes SME request messages from HDD or upper layer
5206 * application.
5207 *
5208 ***LOGIC:
5209 *
5210 ***ASSUMPTIONS:
5211 *
5212 ***NOTE:
5213 *
5214 * @param pMac Pointer to Global MAC structure
5215 * @param msgType Indicates the SME message type
5216 * @param *pMsgBuf A pointer to the SME message buffer
5217 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5218 * false - if pMsgBuf is not to be freed.
5219 */
5220static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5221{
5222 tpSirStartBeaconIndication pBeaconStartInd;
5223 tpPESession psessionEntry;
5224 uint8_t sessionId; /* PE sessionID */
5225
5226 if (pMsg == NULL) {
5227 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
5228 return;
5229 }
5230
5231 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5232 psessionEntry = pe_find_session_by_bssid(pMac,
5233 pBeaconStartInd->bssid,
5234 &sessionId);
5235 if (psessionEntry == NULL) {
5236 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
5237 lim_log(pMac, LOGE,
5238 FL("Session does not exist for given bssId"));
5239 return;
5240 }
5241
5242 if (pBeaconStartInd->beaconStartStatus == true) {
5243 /*
5244 * Currently this Indication comes from SAP
5245 * to start Beacon Tx on a DFS channel
5246 * since beaconing has to be done on DFS
5247 * channel only after CAC WAIT is completed.
5248 * On a DFS Channel LIM does not start beacon
5249 * Tx right after the WMA_ADD_BSS_RSP.
5250 */
5251 lim_apply_configuration(pMac, psessionEntry);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305252 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005253 FL("Start Beacon with ssid %s Ch %d"),
5254 psessionEntry->ssId.ssId,
5255 psessionEntry->currentOperChannel);
5256 lim_send_beacon_ind(pMac, psessionEntry);
5257 } else {
5258 lim_log(pMac, LOGE, FL("Invalid Beacon Start Indication"));
5259 return;
5260 }
5261}
5262
5263/**
5264 * lim_process_sme_channel_change_request() - process sme ch change req
5265 *
5266 * @mac_ctx: Pointer to Global MAC structure
5267 * @msg_buf: pointer to the SME message buffer
5268 *
5269 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5270 *
5271 * Return: None
5272 */
5273static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5274 uint32_t *msg_buf)
5275{
5276 tpSirChanChangeRequest ch_change_req;
5277 tpPESession session_entry;
5278 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005279 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005280 uint32_t val = 0;
5281
5282 if (msg_buf == NULL) {
5283 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5284 return;
5285 }
5286 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5287
5288 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5289 ch_change_req->targetChannel);
5290
5291 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5292 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
5293 lim_log(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5294 return;
5295 }
5296
5297 session_entry = pe_find_session_by_bssid(mac_ctx,
5298 ch_change_req->bssid, &session_id);
5299 if (session_entry == NULL) {
5300 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
5301 lim_log(mac_ctx, LOGE, FL(
5302 "Session does not exist for given bssId"));
5303 return;
5304 }
5305
5306 if (session_entry->currentOperChannel ==
5307 ch_change_req->targetChannel) {
5308 lim_log(mac_ctx, LOGE, FL("target CH is same as current CH"));
5309 return;
5310 }
5311
5312 if (LIM_IS_AP_ROLE(session_entry))
5313 session_entry->channelChangeReasonCode =
5314 LIM_SWITCH_CHANNEL_SAP_DFS;
5315 else
5316 session_entry->channelChangeReasonCode =
5317 LIM_SWITCH_CHANNEL_OPERATION;
5318
5319 lim_log(mac_ctx, LOGW, FL(
5320 "switch old chnl %d to new chnl %d, ch_bw %d"),
5321 session_entry->currentOperChannel,
5322 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005323 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005324
5325 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005326 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005327 session_entry->ch_center_freq_seg0 =
5328 ch_change_req->center_freq_seg_0;
5329 session_entry->ch_center_freq_seg1 =
5330 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005331 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005332 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005333 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005334 session_entry->htRecommendedTxWidthSet =
5335 session_entry->htSupportedChannelWidthSet;
5336 session_entry->currentOperChannel =
5337 ch_change_req->targetChannel;
5338 session_entry->limRFBand =
5339 lim_get_rf_band(session_entry->currentOperChannel);
5340 /* Initialize 11h Enable Flag */
5341 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5342 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5343 eSIR_SUCCESS)
5344 lim_log(mac_ctx, LOGP,
5345 FL("Fail to get WNI_CFG_11H_ENABLED"));
5346 }
5347
5348 session_entry->lim11hEnable = val;
5349 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305350 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005351 &ch_change_req->operational_rateset,
5352 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305353 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005354 &ch_change_req->extended_rateset,
5355 sizeof(session_entry->extRateSet));
5356 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5357 session_entry->ch_center_freq_seg0,
5358 session_entry->ch_center_freq_seg1,
5359 session_entry->ch_width,
5360 max_tx_pwr, session_entry->peSessionId);
5361}
5362
5363/******************************************************************************
5364* lim_start_bss_update_add_ie_buffer()
5365*
5366***FUNCTION:
5367* This function checks the src buffer and its length and then malloc for
5368* dst buffer update the same
5369*
5370***LOGIC:
5371*
5372***ASSUMPTIONS:
5373*
5374***NOTE:
5375*
5376* @param pMac Pointer to Global MAC structure
5377* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5378* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5379* @param *pSrcData_buff A pointer of uint8_t src buffer
5380* @param srcDataLen src buffer length
5381******************************************************************************/
5382
5383static void
5384lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5385 uint8_t **pDstData_buff,
5386 uint16_t *pDstDataLen,
5387 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5388{
5389
5390 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5391 *pDstDataLen = srcDataLen;
5392
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305393 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005394
5395 if (NULL == *pDstData_buff) {
5396 lim_log(pMac, LOGE,
5397 FL("AllocateMemory failed for pDstData_buff"));
5398 return;
5399 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305400 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005401 } else {
5402 *pDstData_buff = NULL;
5403 *pDstDataLen = 0;
5404 }
5405}
5406
5407/******************************************************************************
5408* lim_update_add_ie_buffer()
5409*
5410***FUNCTION:
5411* This function checks the src buffer and length if src buffer length more
5412* than dst buffer length then free the dst buffer and malloc for the new src
5413* length, and update the dst buffer and length. But if dst buffer is bigger
5414* than src buffer length then it just update the dst buffer and length
5415*
5416***LOGIC:
5417*
5418***ASSUMPTIONS:
5419*
5420***NOTE:
5421*
5422* @param pMac Pointer to Global MAC structure
5423* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5424* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5425* @param *pSrcData_buff A pointer of uint8_t src buffer
5426* @param srcDataLen src buffer length
5427******************************************************************************/
5428
5429static void
5430lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5431 uint8_t **pDstData_buff,
5432 uint16_t *pDstDataLen,
5433 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5434{
5435
5436 if (NULL == pSrcData_buff) {
5437 lim_log(pMac, LOGE, FL("src buffer is null."));
5438 return;
5439 }
5440
5441 if (srcDataLen > *pDstDataLen) {
5442 *pDstDataLen = srcDataLen;
5443 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305444 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005445 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305446 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005447
5448 if (NULL == *pDstData_buff) {
5449 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5450 *pDstDataLen = 0;
5451 return;
5452 }
5453 }
5454
5455 /* copy the content of buffer into dst buffer
5456 */
5457 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305458 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005459
5460}
5461
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005462/**
5463 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5464 * @pMac : Pointer to Global MAC structure
5465 * @pDstData_buff : A pointer to pointer of dst buffer
5466 * @pDstDataLen : A pointer to pointer of dst buffer length
5467 * @pModifyIE : A pointer to tSirModifyIE
5468 *
5469 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5470 *
5471 * Return:
5472 * True or false depending upon whether IE is updated or not
5473 */
5474static bool
5475lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5476 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5477{
5478 int32_t oui_length;
5479 uint8_t *ibss_ie = NULL;
5480
5481 ibss_ie = pModifyIE->pIEBuffer;
5482 oui_length = pModifyIE->oui_length;
5483
5484 if ((0 == oui_length) || (NULL == ibss_ie)) {
5485 PELOGE(lim_log(pMac, LOGE,
5486 FL("Invalid set IBSS vendor IE command length %d "),
5487 oui_length);)
5488 return false;
5489 }
5490
5491 lim_update_add_ie_buffer(pMac,
5492 pDstData_buff,
5493 pDstDataLen,
5494 pModifyIE->pIEBuffer,
5495 pModifyIE->ieBufferlength);
5496
5497 return true;
5498}
5499
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005500/*
5501* lim_process_modify_add_ies() - process modify additional IE req.
5502*
5503* @mac_ctx: Pointer to Global MAC structure
5504* @msg_buf: pointer to the SME message buffer
5505*
5506* This function update the PE buffers for additional IEs.
5507*
5508* Return: None
5509*/
5510static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5511 uint32_t *msg_buf)
5512{
5513 tpSirModifyIEsInd modify_add_ies;
5514 tpPESession session_entry;
5515 uint8_t session_id;
5516 bool ret = false;
5517 tSirAddIeParams *add_ie_params;
5518
5519 if (msg_buf == NULL) {
5520 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5521 return;
5522 }
5523
5524 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5525 /* Incoming message has smeSession, use BSSID to find PE session */
5526 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005527 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005528
5529 if (NULL == session_entry) {
5530 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5531 MAC_ADDRESS_STR),
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005532 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005533 goto end;
5534 }
5535 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5536 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5537 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
5538 lim_log(mac_ctx, LOGE,
5539 FL("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d"),
5540 modify_add_ies->modifyIE.pIEBuffer,
5541 modify_add_ies->modifyIE.ieBufferlength,
5542 modify_add_ies->modifyIE.ieID,
5543 modify_add_ies->modifyIE.ieIDLen,
5544 modify_add_ies->updateType);
5545 goto end;
5546 }
5547 add_ie_params = &session_entry->addIeParams;
5548 switch (modify_add_ies->updateType) {
5549 case eUPDATE_IE_PROBE_RESP:
5550 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005551 if (LIM_IS_IBSS_ROLE(session_entry)) {
5552 lim_update_ibss_prop_add_ies(mac_ctx,
5553 &add_ie_params->probeRespData_buff,
5554 &add_ie_params->probeRespDataLen,
5555 &modify_add_ies->modifyIE);
5556 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005557 break;
5558 case eUPDATE_IE_ASSOC_RESP:
5559 /* assoc resp IE */
5560 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305561 QDF_TRACE(QDF_MODULE_ID_PE,
5562 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005563 "assoc resp add ie not present %d"),
5564 add_ie_params->assocRespDataLen);
5565 }
5566 /* search through the buffer and modify the IE */
5567 break;
5568 case eUPDATE_IE_PROBE_BCN:
5569 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005570 if (LIM_IS_IBSS_ROLE(session_entry)) {
5571 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5572 &add_ie_params->probeRespBCNData_buff,
5573 &add_ie_params->probeRespBCNDataLen,
5574 &modify_add_ies->modifyIE);
5575 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005576 if (ret == true && modify_add_ies->modifyIE.notify) {
5577 lim_handle_param_update(mac_ctx,
5578 modify_add_ies->updateType);
5579 }
5580 break;
5581 default:
5582 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d"),
5583 modify_add_ies->updateType);
5584 break;
5585 }
5586end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305587 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005588 modify_add_ies->modifyIE.pIEBuffer = NULL;
5589}
5590
5591/*
5592* lim_process_update_add_ies() - process additional IE update req
5593*
5594* @mac_ctx: Pointer to Global MAC structure
5595* @msg_buf: pointer to the SME message buffer
5596*
5597* This function update the PE buffers for additional IEs.
5598*
5599* Return: None
5600*/
5601static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5602 uint32_t *msg_buf)
5603{
5604 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5605 uint8_t session_id;
5606 tpPESession session_entry;
5607 tSirAddIeParams *addn_ie;
5608 uint16_t new_length = 0;
5609 uint8_t *new_ptr = NULL;
5610 tSirUpdateIE *update_ie;
5611
5612 if (msg_buf == NULL) {
5613 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5614 return;
5615 }
5616 update_ie = &update_add_ies->updateIE;
5617 /* incoming message has smeSession, use BSSID to find PE session */
5618 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005619 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005620
5621 if (NULL == session_entry) {
5622 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5623 MAC_ADDRESS_STR),
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005624 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005625 goto end;
5626 }
5627 addn_ie = &session_entry->addIeParams;
5628 /* if len is 0, upper layer requested freeing of buffer */
5629 if (0 == update_ie->ieBufferlength) {
5630 switch (update_add_ies->updateType) {
5631 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305632 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005633 addn_ie->probeRespData_buff = NULL;
5634 addn_ie->probeRespDataLen = 0;
5635 break;
5636 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305637 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005638 addn_ie->assocRespData_buff = NULL;
5639 addn_ie->assocRespDataLen = 0;
5640 break;
5641 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305642 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005643 addn_ie->probeRespBCNData_buff = NULL;
5644 addn_ie->probeRespBCNDataLen = 0;
5645
5646 if (update_ie->notify)
5647 lim_handle_param_update(mac_ctx,
5648 update_add_ies->updateType);
5649 break;
5650 default:
5651 break;
5652 }
5653 return;
5654 }
5655 switch (update_add_ies->updateType) {
5656 case eUPDATE_IE_PROBE_RESP:
5657 if (update_ie->append) {
5658 /*
5659 * In case of append, allocate new memory
5660 * with combined length
5661 */
5662 new_length = update_ie->ieBufferlength +
5663 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305664 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005665 if (NULL == new_ptr) {
5666 lim_log(mac_ctx, LOGE, FL(
5667 "Memory allocation failed."));
5668 goto end;
5669 }
5670 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305671 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005672 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305673 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005674 update_ie->pAdditionIEBuffer,
5675 update_ie->ieBufferlength);
5676 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305677 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005678 /* adjust length accordingly */
5679 addn_ie->probeRespDataLen = new_length;
5680 /* save refernece of local buffer in PE session */
5681 addn_ie->probeRespData_buff = new_ptr;
5682 goto end;
5683 }
5684 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5685 &addn_ie->probeRespDataLen,
5686 update_ie->pAdditionIEBuffer,
5687 update_ie->ieBufferlength);
5688 break;
5689 case eUPDATE_IE_ASSOC_RESP:
5690 /* assoc resp IE */
5691 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5692 &addn_ie->assocRespDataLen,
5693 update_ie->pAdditionIEBuffer,
5694 update_ie->ieBufferlength);
5695 break;
5696 case eUPDATE_IE_PROBE_BCN:
5697 /* probe resp Bcn IE */
5698 lim_update_add_ie_buffer(mac_ctx,
5699 &addn_ie->probeRespBCNData_buff,
5700 &addn_ie->probeRespBCNDataLen,
5701 update_ie->pAdditionIEBuffer,
5702 update_ie->ieBufferlength);
5703 if (update_ie->notify)
5704 lim_handle_param_update(mac_ctx,
5705 update_add_ies->updateType);
5706 break;
5707 default:
5708 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d."),
5709 update_add_ies->updateType);
5710 break;
5711 }
5712end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305713 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005714 update_ie->pAdditionIEBuffer = NULL;
5715}
5716
5717/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305718 * send_extended_chan_switch_action_frame()- function to send ECSA
5719 * action frame for each sta connected to SAP/GO and AP in case of
5720 * STA .
5721 * @mac_ctx: pointer to global mac structure
5722 * @new_channel: new channel to switch to.
5723 * @ch_bandwidth: BW of channel to calculate op_class
5724 * @session_entry: pe session
5725 *
5726 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5727 *
5728 * Return: void
5729 */
5730
5731static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5732 uint16_t new_channel, uint8_t ch_bandwidth,
5733 tpPESession session_entry)
5734{
5735 uint16_t op_class;
5736 uint8_t switch_mode = 0, i;
5737 tpDphHashNode psta;
5738
5739
Amar Singhal22995112016-01-22 10:42:33 -08005740 op_class = cds_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305741 mac_ctx->scan.countryCodeCurrent,
5742 new_channel,
5743 ch_bandwidth);
5744
5745 if (LIM_IS_AP_ROLE(session_entry) &&
5746 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
5747 switch_mode = 1;
5748
5749 if (LIM_IS_AP_ROLE(session_entry)) {
5750 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5751 psta =
5752 session_entry->dph.dphHashTable.pDphNodeArray + i;
5753 if (psta && psta->added)
5754 lim_send_extended_chan_switch_action_frame(
5755 mac_ctx,
5756 psta->staAddr,
5757 switch_mode, op_class, new_channel,
5758 LIM_MAX_CSA_IE_UPDATES, session_entry);
5759 }
5760 } else if (LIM_IS_STA_ROLE(session_entry)) {
5761 lim_send_extended_chan_switch_action_frame(mac_ctx,
5762 session_entry->bssId,
5763 switch_mode, op_class, new_channel,
5764 LIM_MAX_CSA_IE_UPDATES, session_entry);
5765 }
5766
5767}
5768
5769/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005770 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5771 *
5772 * @mac_ctx: Pointer to Global MAC structure
5773 * @msg_buf: pointer to the SME message buffer
5774 *
5775 * This function processes SME request messages from HDD or upper layer
5776 * application.
5777 *
5778 * Return: None
5779 */
5780static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5781 uint32_t *msg_buf)
5782{
5783 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5784 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005785 uint8_t session_id;
5786 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005787 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005788
5789 if (msg_buf == NULL) {
5790 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5791 return;
5792 }
5793
5794 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5795 session_entry = pe_find_session_by_bssid(mac_ctx,
5796 dfs_csa_ie_req->bssid, &session_id);
5797 if (session_entry == NULL) {
5798 lim_log(mac_ctx, LOGE, FL(
5799 "Session not found for given BSSID" MAC_ADDRESS_STR),
5800 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5801 return;
5802 }
5803
5804 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5805 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5806 GET_LIM_SYSTEM_ROLE(session_entry));
5807 return;
5808 }
5809
5810 /* target channel */
5811 session_entry->gLimChannelSwitch.primaryChannel =
5812 dfs_csa_ie_req->targetChannel;
5813
5814 /* Channel switch announcement needs to be included in beacon */
5815 session_entry->dfsIncludeChanSwIe = true;
5816 session_entry->gLimChannelSwitch.switchCount = LIM_MAX_CSA_IE_UPDATES;
5817 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005818 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305819 session_entry->gLimChannelSwitch.sec_ch_offset =
5820 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005821 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
5822 session_entry->gLimChannelSwitch.switchMode = 1;
5823
5824 /*
5825 * Validate if SAP is operating HT or VHT mode and set the Channel
5826 * Switch Wrapper element with the Wide Band Switch subelement.
5827 */
5828 if (true != session_entry->vhtCapability)
5829 goto skip_vht;
5830
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005831 /* Now encode the Wider Ch BW element depending on the ch width */
5832 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005833 switch (dfs_csa_ie_req->ch_params.ch_width) {
5834 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005835 /*
5836 * Wide channel BW sublement in channel wrapper element is not
5837 * required in case of 20 Mhz operation. Currently It is set
5838 * only set in case of 40/80 Mhz Operation.
5839 */
5840 session_entry->dfsIncludeChanWrapperIe = false;
5841 wider_bw_ch_switch->newChanWidth =
5842 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5843 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005844 case CH_WIDTH_40MHZ:
5845 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005846 wider_bw_ch_switch->newChanWidth =
5847 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5848 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005849 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005850 session_entry->dfsIncludeChanWrapperIe = true;
5851 wider_bw_ch_switch->newChanWidth =
5852 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5853 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005854 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005855 session_entry->dfsIncludeChanWrapperIe = true;
5856 wider_bw_ch_switch->newChanWidth =
5857 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5858 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005859 case CH_WIDTH_80P80MHZ:
5860 session_entry->dfsIncludeChanWrapperIe = true;
5861 wider_bw_ch_switch->newChanWidth =
5862 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005863 /*
5864 * This is not applicable for 20/40/80 Mhz.
5865 * Only used when we support 80+80 Mhz operation.
5866 * In case of 80+80 Mhz, this parameter indicates
5867 * center channel frequency index of 80 Mhz channel of
5868 * frequency segment 1.
5869 */
5870 wider_bw_ch_switch->newCenterChanFreq1 =
5871 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005872 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005873 default:
5874 session_entry->dfsIncludeChanWrapperIe = false;
5875 /*
5876 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5877 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5878 */
5879 lim_log(mac_ctx, LOGE, FL("Invalid Channel Width"));
5880 break;
5881 }
5882 /* Fetch the center channel based on the channel width */
5883 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005884 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005885skip_vht:
5886 /* Send CSA IE request from here */
5887 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5888 eSIR_SUCCESS) {
5889 lim_log(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
5890 return;
5891 }
5892
5893 /*
5894 * First beacon update request is sent here, the remaining updates are
5895 * done when the FW responds back after sending the first beacon after
5896 * the template update
5897 */
5898 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305899
5900 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5901 ch_offset = BW80;
5902 else
5903 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5904
5905 lim_log(mac_ctx, LOG1, FL("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d"),
5906 session_entry->gLimChannelSwitch.switchCount,
5907 session_entry->gLimChannelSwitch.primaryChannel,
5908 session_entry->gLimChannelSwitch.ch_width,
5909 session_entry->dfsIncludeChanWrapperIe,
5910 ch_offset);
5911
Abhishek Singh518323d2015-10-19 17:42:01 +05305912 /* Send ECSA Action frame after updating the beacon */
5913 send_extended_chan_switch_action_frame(mac_ctx,
5914 session_entry->gLimChannelSwitch.primaryChannel,
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305915 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005916 session_entry->gLimChannelSwitch.switchCount--;
5917}
5918
5919/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305920 * lim_process_ext_change_channel()- function to send ECSA
5921 * action frame for STA/CLI .
5922 * @mac_ctx: pointer to global mac structure
5923 * @msg: params from sme for new channel.
5924 *
5925 * This function is called to send ECSA frame for STA/CLI.
5926 *
5927 * Return: void
5928 */
5929
5930static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5931 uint32_t *msg)
5932{
5933 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5934 (struct sir_sme_ext_cng_chan_req *) msg;
5935 tpPESession session_entry = NULL;
5936
5937 if (NULL == msg) {
5938 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5939 return;
5940 }
5941 session_entry =
5942 pe_find_session_by_sme_session_id(mac_ctx,
5943 ext_chng_channel->session_id);
5944 if (NULL == session_entry) {
5945 lim_log(mac_ctx, LOGE,
5946 FL("Session not found for given session %d"),
5947 ext_chng_channel->session_id);
5948 return;
5949 }
5950 if (LIM_IS_AP_ROLE(session_entry)) {
5951 lim_log(mac_ctx, LOGE,
5952 FL("not an STA/CLI session"));
5953 return;
5954 }
5955 send_extended_chan_switch_action_frame(mac_ctx,
5956 ext_chng_channel->new_channel,
5957 0, session_entry);
5958}
5959
5960/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005961 * lim_process_nss_update_request() - process sme nss update req
5962 *
5963 * @mac_ctx: Pointer to Global MAC structure
5964 * @msg_buf: pointer to the SME message buffer
5965 *
5966 * This function processes SME request messages from HDD or upper layer
5967 * application.
5968 *
5969 * Return: None
5970 */
5971static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5972 uint32_t *msg_buf)
5973{
5974 struct sir_nss_update_request *nss_update_req_ptr;
5975 tpPESession session_entry = NULL;
5976
5977 if (msg_buf == NULL) {
5978 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5979 return;
5980 }
5981
5982 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305983 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005984 nss_update_req_ptr->vdev_id);
5985 if (session_entry == NULL) {
5986 lim_log(mac_ctx, LOGE, FL(
5987 "Session not found for given session_id %d"),
5988 nss_update_req_ptr->vdev_id);
5989 return;
5990 }
5991
5992 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5993 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5994 GET_LIM_SYSTEM_ROLE(session_entry));
5995 return;
5996 }
5997
5998 /* populate nss field in the beacon */
5999 session_entry->gLimOperatingMode.present = 1;
6000 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
6001 /* Send nss update request from here */
6002 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6003 eSIR_SUCCESS) {
6004 lim_log(mac_ctx, LOGE,
6005 FL("Unable to set op mode IE in beacon"));
6006 return;
6007 }
6008
6009 lim_send_beacon_ind(mac_ctx, session_entry);
6010}
6011
6012/**
6013 * lim_process_set_ie_req() - process sme set IE request
6014 *
6015 * @mac_ctx: Pointer to Global MAC structure
6016 * @msg_buf: pointer to the SME message buffer
6017 *
6018 * This function processes SME request messages from HDD or upper layer
6019 * application.
6020 *
6021 * Return: None
6022 */
6023static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6024{
6025 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306026 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006027
6028 if (msg_buf == NULL) {
6029 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6030 return;
6031 }
6032
6033 msg = (struct send_extcap_ie *)msg_buf;
6034 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306035 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006036 lim_log(mac_ctx, LOGE, FL("Unable to send ExtCap to FW"));
6037
6038}