blob: 9f53b3ca59e4cd406ceedba6280a8b28c90ac667 [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++) {
363 lim_log(mac_ctx, LOG1,
364 FL("session %d, bsstype %d, limSystemRole %d, limSmeState %d"),
365 i, mac_ctx->lim.gpSession[i].bssType,
366 mac_ctx->lim.gpSession[i].limSystemRole,
367 mac_ctx->lim.gpSession[i].limSmeState);
368 if (mac_ctx->lim.gpSession[i].valid == true) {
369 if (!((((mac_ctx->lim.gpSession[i].bssType ==
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700370 eSIR_INFRASTRUCTURE_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800371 (mac_ctx->lim.gpSession[i].limSmeState ==
372 eLIM_SME_LINK_EST_STATE)) ||
373 (((mac_ctx->lim.gpSession[i].bssType ==
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700374 eSIR_IBSS_MODE)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800375 (mac_ctx->lim.gpSession[i].limSmeState ==
376 eLIM_SME_NORMAL_STATE)) ||
377 ((((mac_ctx->lim.gpSession[i].bssType ==
378 eSIR_INFRA_AP_MODE) &&
379 (mac_ctx->lim.gpSession[i].pePersona ==
Anurag Chouhan6d760662016-02-20 16:05:43 +0530380 QDF_P2P_GO_MODE)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800381 (mac_ctx->lim.gpSession[i].limSystemRole ==
382 eLIM_AP_ROLE)) &&
383 (mac_ctx->lim.gpSession[i].limSmeState ==
384 eLIM_SME_NORMAL_STATE)))) {
385 valid_state = false;
386 break;
387 }
388 }
389 }
390
391 lim_log(mac_ctx, LOG1, FL("valid_state: %d"), valid_state);
392
393 if ((valid_state) &&
394 (return_fresh_results & SIR_BG_SCAN_RETURN_FRESH_RESULTS))
395 return true;
396 else
397 return false;
398}
399
400/**
401 * __lim_is_sme_assoc_cnf_valid()
402 *
403 ***FUNCTION:
404 * This function is called by __lim_process_sme_assoc_cnf_new() upon
405 * receiving SME_ASSOC_CNF.
406 *
407 ***LOGIC:
408 * Message validity checks are performed in this function
409 *
410 ***ASSUMPTIONS:
411 *
412 ***NOTE:
413 *
414 * @param pMeasReq Pointer to Received ASSOC_CNF message
415 * @return true When received SME_ASSOC_CNF is formatted
416 * correctly
417 * false otherwise
418 */
419
420static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
421{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530422 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800423 return false;
424 else
425 return true;
426} /*** end __lim_is_sme_assoc_cnf_valid() ***/
427
428/**
429 * __lim_get_sme_join_req_size_for_alloc()
430 *
431 ***FUNCTION:
432 * This function is called in various places to get IE length
433 * from tSirBssDescription structure
434 * number being scanned.
435 *
436 ***PARAMS:
437 *
438 ***LOGIC:
439 *
440 ***ASSUMPTIONS:
441 * NA
442 *
443 ***NOTE:
444 * NA
445 *
446 * @param pBssDescr
447 * @return Total IE length
448 */
449
450static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
451{
452 uint16_t len = 0;
453
454 if (!pBuf)
455 return len;
456
457 pBuf += sizeof(uint16_t);
458 len = lim_get_u16(pBuf);
459 return len + sizeof(uint16_t);
460}
461
462/**
463 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
464 * @pMac: Global MAC context
465 * @pMsg: Pointer to message posted from SME to LIM.
466 *
467 * Has role only if 11h is enabled. Not used on STA side.
468 * Defers the message if SME is in learn state and brings
469 * the LIM back to normal mode.
470 *
471 * Return: true - If defered false - Otherwise
472 */
473
474static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
475{
476 if (lim_is_system_in_scan_state(pMac)) {
477 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
478 lim_log(pMac, LOGE, FL("Could not defer Msg = %d"),
479 pMsg->type);
480 return false;
481 }
482 lim_log(pMac, LOG1,
483 FL("Defer the message, in learn mode type = %d"),
484 pMsg->type);
485 return true;
486 }
487 return false;
488}
489
490/**
491 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
492 * @mac_ctx: Pointer to Global MAC structure
493 * @message: Pointer to message posted from SME to LIM.
494 *
495 * Has role only if 11h is enabled. Not used on STA side.
496 * Defers the message if radar is detected.
497 *
498 * Return: true, if defered otherwise return false.
499 */
500static bool
501__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx, tpSirMsgQ message)
502{
503 /*
504 * fRadarDetCurOperChan will be set only if we
505 * detect radar in current operating channel and
506 * System Role == AP ROLE
507 *
508 * TODO: Need to take care radar detection.
509 *
510 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
511 */
512 if (0) {
513 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
514 lim_log(mac_ctx, LOGE, FL("Could not defer Msg = %d"),
515 message->type);
516 return false;
517 }
518 lim_log(mac_ctx, LOG1,
519 FL("Defer the message, in learn mode type = %d"),
520 message->type);
521 return true;
522 }
523 return false;
524}
525
526/**
527 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
528 * @pMac: Global MAC context
529 * @pMsgBuf: Message from WMA
530 *
531 * handles the notification from HDD. PE just forwards this message to HAL.
532 *
533 * Return: true-Posting to HAL failed, so PE will consume the buffer.
534 * false-Posting to HAL successful, so HAL will consume the buffer.
535 */
536
537static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
538{
539 tSirMsgQ msg;
540 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
541
542 msg.type = WMA_SYS_READY_IND;
543 msg.reserved = 0;
544 msg.bodyptr = pMsgBuf;
545 msg.bodyval = 0;
546
547 if (ANI_DRIVER_TYPE(pMac) != eDRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800548 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
Naveen Rawat0fc3f692016-06-22 14:30:54 -0700549 pe_register_callbacks_with_wma(pMac, ready_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800550 pMac->lim.add_bssdescr_callback = ready_req->add_bssdescr_cb;
551 }
552 PELOGW(lim_log(pMac, LOGW, FL("sending WMA_SYS_READY_IND msg to HAL"));)
553 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
554
555 if (eSIR_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
556 lim_log(pMac, LOGP, FL("wma_post_ctrl_msg failed"));
557 return true;
558 }
559 return false;
560}
561
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800562/**
563 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
564 *@mac_ctx: Pointer to Global MAC structure
565 *@session: A pointer to session entry
566 *@sme_start_bss_req: Start BSS Request from upper layers.
567 *
568 * This function is used to configure the start bss parameters
569 * in to the session.
570 *
571 * Return: None.
572 */
573static void
574lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
575 tpSirSmeStartBssReq sme_start_bss_req)
576{
577 session->limSystemRole = eLIM_AP_ROLE;
578 session->privacy = sme_start_bss_req->privacy;
579 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
580 session->authType = sme_start_bss_req->authType;
581 /* Store the DTIM period */
582 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
583 /* Enable/disable UAPSD */
584 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530585 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800586 session->proxyProbeRspEn = 0;
587 } else {
588 /*
589 * To detect PBC overlap in SAP WPS mode,
590 * Host handles Probe Requests.
591 */
592 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
593 session->proxyProbeRspEn = 1;
594 else
595 session->proxyProbeRspEn = 0;
596 }
597 session->ssidHidden = sme_start_bss_req->ssidHidden;
598 session->wps_state = sme_start_bss_req->wps_state;
599 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
600 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
601 &session->shortSlotTimeSupported);
602 session->isCoalesingInIBSSAllowed =
603 sme_start_bss_req->isCoalesingInIBSSAllowed;
604
605}
606
607/**
608 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
609 *@mac_ctx: Pointer to Global MAC structure
610 *@msg_buf: A pointer to the SME message buffer
611 *
612 * This function is called to process SME_START_BSS_REQ message
613 * from HDD or upper layer application.
614 *
615 * Return: None
616 */
617static void
618__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
619{
620 uint16_t size;
621 uint32_t val = 0;
622 tSirRetStatus ret_status;
623 tSirMacChanNum channel_number;
624 tLimMlmStartReq *mlm_start_req = NULL;
625 tpSirSmeStartBssReq sme_start_bss_req = NULL;
626 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
627 /* Flag Used in case of IBSS to Auto generate BSSID. */
628 uint32_t auto_gen_bssid = false;
629 uint8_t session_id;
630 tpPESession session = NULL;
631 uint8_t sme_session_id = 0;
632 uint16_t sme_transaction_id = 0;
633 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700634 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800635 tSirRetStatus cfg_get_wmi_dfs_master_param = eSIR_SUCCESS;
636
637/* FEATURE_WLAN_DIAG_SUPPORT */
638#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
639 /*
640 * Since the session is not created yet, sending NULL.
641 * The response should have the correct state.
642 */
643 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
644 NULL, 0, 0);
645#endif /* FEATURE_WLAN_DIAG_SUPPORT */
646
647 lim_log(mac_ctx, LOG1, FL("Received START_BSS_REQ"));
648
649 /*
650 * Global Sme state and mlm states are not defined yet,
651 * for BT-AMP Suppoprt . TO BE DONE
652 */
653 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
654 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
655 size = sizeof(tSirSmeStartBssReq);
656
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530657 sme_start_bss_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800658 if (NULL == sme_start_bss_req) {
659 lim_log(mac_ctx, LOGE,
660 FL("Allocate Memory fail for LimStartBssReq"));
661 /* Send failure response to host */
662 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
663 goto end;
664 }
665
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530666 qdf_mem_set((void *)sme_start_bss_req, size, 0);
667 qdf_mem_copy(sme_start_bss_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800668 sizeof(tSirSmeStartBssReq));
669 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
670 sme_start_bss_req)) {
671 lim_log(mac_ctx, LOGW,
672 FL("Received invalid eWNI_SME_START_BSS_REQ"));
673 ret_code = eSIR_SME_INVALID_PARAMETERS;
674 goto free;
675 }
676
677 /*
678 * This is the place where PE is going to create a session.
679 * If session is not existed, then create a new session
680 */
681 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800682 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800683 if (session != NULL) {
684 lim_log(mac_ctx, LOGW,
685 FL("Session Already exists for given BSSID"));
686 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
687 session = NULL;
688 goto free;
689 } else {
690 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800691 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800692 &session_id, mac_ctx->lim.maxStation,
693 sme_start_bss_req->bssType);
694 if (session == NULL) {
695 lim_log(mac_ctx, LOGW,
696 FL("Session Can not be created "));
697 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
698 goto free;
699 }
700 }
701
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700702 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
703 /* Probe resp add ie */
704 lim_start_bss_update_add_ie_buffer(mac_ctx,
705 &session->addIeParams.probeRespData_buff,
706 &session->addIeParams.probeRespDataLen,
707 sme_start_bss_req->addIeParams.
708 probeRespData_buff,
709 sme_start_bss_req->addIeParams.
710 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800711
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700712 /* Probe Beacon add ie */
713 lim_start_bss_update_add_ie_buffer(mac_ctx,
714 &session->addIeParams.probeRespBCNData_buff,
715 &session->addIeParams.probeRespBCNDataLen,
716 sme_start_bss_req->addIeParams.
717 probeRespBCNData_buff,
718 sme_start_bss_req->addIeParams.
719 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800720
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700721 /* Assoc resp IE */
722 lim_start_bss_update_add_ie_buffer(mac_ctx,
723 &session->addIeParams.assocRespData_buff,
724 &session->addIeParams.assocRespDataLen,
725 sme_start_bss_req->addIeParams.
726 assocRespData_buff,
727 sme_start_bss_req->addIeParams.
728 assocRespDataLen);
729 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800730 /* Store the session related params in newly created session */
731 session->pLimStartBssReq = sme_start_bss_req;
732
733 /* Store PE session_id in session Table */
734 session->peSessionId = session_id;
735
736 /* Store SME session Id in sessionTable */
737 session->smeSessionId = sme_start_bss_req->sessionId;
738
739 session->transactionId = sme_start_bss_req->transactionId;
740
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530741 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800742 &(sme_start_bss_req->htConfig),
743 sizeof(session->htConfig));
744
745 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800746 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800747
748 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530749 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800750 (uint8_t *) &sme_start_bss_req->ssId,
751 (sme_start_bss_req->ssId.length + 1));
752
753 session->bssType = sme_start_bss_req->bssType;
754
755 session->nwType = sme_start_bss_req->nwType;
756
757 session->beaconParams.beaconInterval =
758 sme_start_bss_req->beaconInterval;
759
760 /* Store the channel number in session Table */
761 session->currentOperChannel =
762 sme_start_bss_req->channelId;
763
764 /* Store Persona */
765 session->pePersona = sme_start_bss_req->bssPersona;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530766 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800767 FL("PE PERSONA=%d"), session->pePersona);
768
769 /* Update the phymode */
770 session->gLimPhyMode = sme_start_bss_req->nwType;
771
772 session->maxTxPower =
773 cfg_get_regulatory_max_transmit_power(mac_ctx,
774 session->currentOperChannel);
775 /* Store the dot 11 mode in to the session Table */
776 session->dot11mode = sme_start_bss_req->dot11mode;
777#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
778 session->cc_switch_mode =
779 sme_start_bss_req->cc_switch_mode;
780#endif
781 session->htCapability =
782 IS_DOT11_MODE_HT(session->dot11mode);
783 session->vhtCapability =
784 IS_DOT11_MODE_VHT(session->dot11mode);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530785 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800786 FL("*****session->vhtCapability = %d"),
787 session->vhtCapability);
788 session->txLdpcIniFeatureEnabled =
789 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800790#ifdef WLAN_FEATURE_11W
791 session->limRmfEnabled =
792 sme_start_bss_req->pmfCapable ? 1 : 0;
793 lim_log(mac_ctx, LOG1, FL("Session RMF enabled: %d"),
794 session->limRmfEnabled);
795#endif
796
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530797 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800798 (void *)&sme_start_bss_req->operationalRateSet,
799 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530800 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800801 (void *)&sme_start_bss_req->extendedRateSet,
802 sizeof(tSirMacRateSet));
803
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700804 if (IS_5G_CH(session->currentOperChannel))
805 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
806 else
807 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
808
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800809 switch (sme_start_bss_req->bssType) {
810 case eSIR_INFRA_AP_MODE:
811 lim_configure_ap_start_bss_session(mac_ctx, session,
812 sme_start_bss_req);
Anurag Chouhan6d760662016-02-20 16:05:43 +0530813 if (session->pePersona == QDF_SAP_MODE) {
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -0800814 session->txBFIniFeatureEnabled =
815 sme_start_bss_req->txbf_ini_enabled;
816 session->txbf_csn_value =
817 sme_start_bss_req->txbf_csn_val;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700818 session->vdev_nss = vdev_type_nss->sap;
819 } else {
820 session->vdev_nss = vdev_type_nss->p2p_go;
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -0800821 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800822 break;
823 case eSIR_IBSS_MODE:
824 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
825 lim_get_short_slot_from_phy_mode(mac_ctx, session,
826 session->gLimPhyMode,
827 &session->shortSlotTimeSupported);
828
829 /*
830 * initialize to "OPEN".
831 * will be updated upon key installation
832 */
833 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700834 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800835
836 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700837 case eSIR_NDI_MODE:
838 session->limSystemRole = eLIM_NDI_ROLE;
839 break;
840
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800841
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800842 /*
843 * There is one more mode called auto mode.
844 * which is used no where
845 */
846
847 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
848
849 default:
850 /* not used anywhere...used in scan function */
851 break;
852 }
853
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700854 lim_log(mac_ctx, LOG1, FL("persona - %d, nss - %d"),
855 session->pePersona, session->vdev_nss);
856 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800857 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700858 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800859 * parsed (Re)Assoc request structure
860 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700861 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800862 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530863 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700864 size * sizeof(tpSirAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800865 if (NULL == session->parsedAssocReq) {
866 lim_log(mac_ctx, LOGW,
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700867 FL("AllocateMemory() failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800868 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
869 goto free;
870 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530871 qdf_mem_set(session->parsedAssocReq,
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700872 (session->dph.dphHashTable.size *
873 sizeof(tpSirAssocReq)), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800874 }
875
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700876 if (!sme_start_bss_req->channelId &&
877 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800878 lim_log(mac_ctx, LOGE,
879 FL("Received invalid eWNI_SME_START_BSS_REQ"));
880 ret_code = eSIR_SME_INVALID_PARAMETERS;
881 goto free;
882 }
883 channel_number = sme_start_bss_req->channelId;
884#ifdef QCA_HT_2040_COEX
885 if (sme_start_bss_req->obssEnabled)
886 session->htSupportedChannelWidthSet =
887 session->htCapability;
888 else
889#endif
890 session->htSupportedChannelWidthSet =
891 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
892 session->htSecondaryChannelOffset =
893 sme_start_bss_req->sec_ch_offset;
894 session->htRecommendedTxWidthSet =
895 (session->htSecondaryChannelOffset) ? 1 : 0;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530896 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800897 FL("cbMode %u"), sme_start_bss_req->cbMode);
898 if (session->vhtCapability || session->htCapability) {
899 chanwidth = sme_start_bss_req->vht_channel_width;
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800900 lim_log(mac_ctx, LOG1,
901 FL("vht_channel_width %u htSupportedChannelWidthSet %d"),
902 sme_start_bss_req->vht_channel_width,
903 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800904 session->ch_width = chanwidth;
905 if (session->htSupportedChannelWidthSet) {
906 session->ch_center_freq_seg0 =
907 sme_start_bss_req->center_freq_seg0;
908 session->ch_center_freq_seg1 =
909 sme_start_bss_req->center_freq_seg1;
910 } else {
911 session->ch_center_freq_seg0 = 0;
912 session->ch_center_freq_seg1 = 0;
913 }
914 }
915
916 if (session->vhtCapability &&
917 (CH_WIDTH_160MHZ > session->ch_width)) {
918 if (wlan_cfg_get_int(mac_ctx,
919 WNI_CFG_VHT_SU_BEAMFORMER_CAP, &val) !=
920 eSIR_SUCCESS)
921 lim_log(mac_ctx, LOGE, FL(
922 "cfg get vht su bformer failed"));
923
924 session->enable_su_tx_bformer = val;
925 } else {
926 session->nss = 1;
927 }
928 lim_log(mac_ctx, LOG1, FL("vht su tx bformer %d"), val);
929
930 /* Delete pre-auth list if any */
931 lim_delete_pre_auth_list(mac_ctx);
932
933 /*
934 * keep the RSN/WPA IE information in PE Session Entry
935 * later will be using this to check when received (Re)Assoc req
936 */
937 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
938 &sme_start_bss_req->rsnIE, session);
939
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700940 if (LIM_IS_AP_ROLE(session) ||
941 LIM_IS_IBSS_ROLE(session) ||
942 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800943 session->gLimProtectionControl =
944 sme_start_bss_req->protEnabled;
945 /*
946 * each byte will have the following info
947 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
948 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
949 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530950 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800951 (void *)&sme_start_bss_req->ht_capab,
952 sizeof(uint16_t));
953 /* Initialize WPS PBC session link list */
954 session->pAPWPSPBCSession = NULL;
955 }
956 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530957 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800958 if (NULL == mlm_start_req) {
959 lim_log(mac_ctx, LOGP,
960 FL("Allocate Memory failed for mlmStartReq"));
961 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
962 goto free;
963 }
964
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530965 qdf_mem_set((void *)mlm_start_req, sizeof(tLimMlmStartReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800966
967 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530968 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800969 (uint8_t *) &sme_start_bss_req->ssId,
970 sme_start_bss_req->ssId.length + 1);
971 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
972 mlm_start_req->obssProtEnabled =
973 sme_start_bss_req->obssProtEnabled;
974
975 mlm_start_req->bssType = session->bssType;
976
977 /* Fill PE session Id from the session Table */
978 mlm_start_req->sessionId = session->peSessionId;
979
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700980 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
981 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800982 /*
983 * Copy the BSSId from sessionTable to
984 * mlmStartReq struct
985 */
986 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
987 } else {
988 /* ibss mode */
989 mac_ctx->lim.gLimIbssCoalescingHappened = false;
990
991 ret_status = wlan_cfg_get_int(mac_ctx,
992 WNI_CFG_IBSS_AUTO_BSSID,
993 &auto_gen_bssid);
994 if (ret_status != eSIR_SUCCESS) {
995 lim_log(mac_ctx, LOGP,
996 FL("Get Auto Gen BSSID fail,Status=%d"),
997 ret_status);
998 ret_code = eSIR_LOGP_EXCEPTION;
999 goto free;
1000 }
1001
1002 if (!auto_gen_bssid) {
1003 /*
1004 * We're not auto generating BSSID.
1005 * Instead, get it from session entry
1006 */
1007 sir_copy_mac_addr(mlm_start_req->bssId,
1008 session->bssId);
1009 /*
1010 * Start IBSS group BSSID
1011 * Auto Generating BSSID.
1012 */
1013 auto_gen_bssid = ((mlm_start_req->bssId[0] &
1014 0x01) ? true : false);
1015 }
1016
1017 if (auto_gen_bssid) {
1018 /*
1019 * if BSSID is not any uc id.
1020 * then use locally generated BSSID.
1021 * Autogenerate the BSSID
1022 */
1023 lim_get_random_bssid(mac_ctx,
1024 mlm_start_req->bssId);
1025 mlm_start_req->bssId[0] = 0x02;
1026
1027 /*
1028 * Copy randomly generated BSSID
1029 * to the session Table
1030 */
1031 sir_copy_mac_addr(session->bssId,
1032 mlm_start_req->bssId);
1033 }
1034 }
1035 /* store the channel num in mlmstart req structure */
1036 mlm_start_req->channelNumber = session->currentOperChannel;
1037 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
1038 mlm_start_req->beaconPeriod =
1039 session->beaconParams.beaconInterval;
1040
1041 if (LIM_IS_AP_ROLE(session)) {
1042 mlm_start_req->dtimPeriod = session->dtimPeriod;
1043 mlm_start_req->wps_state = session->wps_state;
1044
1045 } else {
1046 if (wlan_cfg_get_int(mac_ctx,
1047 WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
1048 lim_log(mac_ctx, LOGP,
1049 FL("could not retrieve DTIM Period"));
1050 mlm_start_req->dtimPeriod = (uint8_t) val;
1051 }
1052
1053 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_PERIOD, &val) !=
1054 eSIR_SUCCESS)
1055 lim_log(mac_ctx, LOGP,
1056 FL("could not retrieve Beacon interval"));
1057 mlm_start_req->cfParamSet.cfpPeriod = (uint8_t) val;
1058
1059 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_MAX_DURATION, &val) !=
1060 eSIR_SUCCESS)
1061 lim_log(mac_ctx, LOGP,
1062 FL("could not retrieve CFPMaxDuration"));
1063 mlm_start_req->cfParamSet.cfpMaxDuration = (uint16_t) val;
1064
1065 /*
1066 * this may not be needed anymore now,
1067 * as rateSet is now included in the
1068 * session entry and MLM has session context.
1069 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301070 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001071 (void *)&session->rateSet,
1072 sizeof(tSirMacRateSet));
1073
1074 /* Now populate the 11n related parameters */
1075 mlm_start_req->nwType = session->nwType;
1076 mlm_start_req->htCapable = session->htCapability;
1077
1078 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1079 /* Unused */
1080 mlm_start_req->dualCTSProtection =
1081 mac_ctx->lim.gHTDualCTSProtection;
1082 mlm_start_req->txChannelWidthSet =
1083 session->htRecommendedTxWidthSet;
1084
1085 session->limRFBand = lim_get_rf_band(channel_number);
1086
1087 /* Initialize 11h Enable Flag */
1088 session->lim11hEnable = 0;
1089 if ((mlm_start_req->bssType != eSIR_IBSS_MODE) &&
1090 (SIR_BAND_5_GHZ == session->limRFBand)) {
1091 if (wlan_cfg_get_int(mac_ctx,
1092 WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
1093 lim_log(mac_ctx, LOGP,
1094 FL("Fail to get WNI_CFG_11H_ENABLED "));
1095 else
1096 session->lim11hEnable = val;
1097
1098 if (session->lim11hEnable &&
1099 (eSIR_INFRA_AP_MODE ==
1100 mlm_start_req->bssType)) {
1101 cfg_get_wmi_dfs_master_param =
1102 wlan_cfg_get_int(mac_ctx,
1103 WNI_CFG_DFS_MASTER_ENABLED,
1104 &val);
1105 session->lim11hEnable = val;
1106 }
1107 if (cfg_get_wmi_dfs_master_param != eSIR_SUCCESS)
1108 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
1109 lim_log(mac_ctx, LOGE,
1110 FL("Get Fail, CFG DFS ENABLE"));
1111 }
1112
1113 if (!session->lim11hEnable) {
1114 if (cfg_set_int(mac_ctx,
1115 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
1116 eSIR_SUCCESS)
1117 /*
1118 * Failed to set the CFG param
1119 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1120 */
1121 lim_log(mac_ctx, LOGE,
1122 FL("Set LOCAL_POWER_CONSTRAINT failed"));
1123 }
1124
1125 session->limPrevSmeState = session->limSmeState;
1126 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1127 MTRACE(mac_trace
1128 (mac_ctx, TRACE_CODE_SME_STATE,
1129 session->peSessionId,
1130 session->limSmeState));
1131
1132 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1133 (uint32_t *) mlm_start_req);
1134 return;
1135 } else {
1136
1137 lim_log(mac_ctx, LOGE,
1138 FL("Received unexpected START_BSS_REQ, in state %X"),
1139 mac_ctx->lim.gLimSmeState);
1140 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
1141 goto end;
1142 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1143
1144free:
1145 if ((session != NULL) &&
1146 (session->pLimStartBssReq == sme_start_bss_req)) {
1147 session->pLimStartBssReq = NULL;
1148 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301149 qdf_mem_free(sme_start_bss_req);
1150 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001151
1152end:
1153 if (sme_start_bss_req != NULL) {
1154 sme_session_id = sme_start_bss_req->sessionId;
1155 sme_transaction_id = sme_start_bss_req->transactionId;
1156 }
1157 if (NULL != session) {
1158 pe_delete_session(mac_ctx, session);
1159 session = NULL;
1160 }
1161 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1162 session, sme_session_id, sme_transaction_id);
1163}
1164
1165/**
1166 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1167 *
1168 * @pMac: Global MAC context
1169 * @pMsg: Message pointer
1170 *
1171 * Wrapper for the function __lim_handle_sme_start_bss_request
1172 * This message will be defered until softmac come out of
1173 * scan mode or if we have detected radar on the current
1174 * operating channel.
1175 *
1176 * return true - If we consumed the buffer
1177 * false - If have defered the message.
1178 */
1179static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1180{
1181 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1182 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1183 /**
1184 * If message defered, buffer is not consumed yet.
1185 * So return false
1186 */
1187 return false;
1188 }
1189
1190 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1191 return true;
1192}
1193
1194/**
1195 * lim_get_random_bssid()
1196 *
1197 * FUNCTION:This function is called to process generate the random number for bssid
1198 * This function is called to process SME_SCAN_REQ message
1199 * from HDD or upper layer application.
1200 *
1201 * LOGIC:
1202 *
1203 * ASSUMPTIONS:
1204 *
1205 * NOTE:
1206 * 1. geneartes the unique random number for bssid in ibss
1207 *
1208 * @param pMac Pointer to Global MAC structure
1209 * @param *data Pointer to bssid buffer
1210 * @return None
1211 */
1212void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1213{
1214 uint32_t random[2];
1215 random[0] = tx_time_get();
1216 random[0] |= (random[0] << 15);
1217 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301218 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001219}
1220
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301221static QDF_STATUS lim_send_hal_start_scan_offload_req(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001222 tpSirSmeScanReq pScanReq)
1223{
1224 tSirScanOffloadReq *pScanOffloadReq;
1225 uint8_t *p;
1226 uint8_t *ht_cap_ie;
1227 tSirMsgQ msg;
1228 uint16_t i, len;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001229 uint16_t ht_cap_len = 0;
1230 uint16_t addn_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001231 uint8_t *vht_cap_ie;
1232 uint16_t vht_cap_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001233 tSirRetStatus status, rc = eSIR_SUCCESS;
1234 tDot11fIEExtCap extracted_extcap = {0};
1235 bool extcap_present = true;
1236
1237 if (pScanReq->uIEFieldLen) {
1238 status = lim_strip_extcap_update_struct(pMac,
1239 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1240 &pScanReq->uIEFieldLen, &extracted_extcap);
1241
1242 if (eSIR_SUCCESS != status) {
1243 extcap_present = false;
1244 lim_log(pMac, LOG1,
1245 FL("Unable to Strip ExtCap IE from Scan Req"));
1246 }
1247
1248 if (extcap_present) {
1249 lim_log(pMac, LOG1,
1250 FL("Extcap was part of SCAN IE - Updating FW"));
1251 lim_send_ext_cap_ie(pMac, pScanReq->sessionId,
1252 &extracted_extcap, true);
1253 }
1254 } else {
1255 lim_log(pMac, LOG1,
1256 FL("No IEs in the scan request from supplicant"));
1257 }
1258
1259 /**
1260 * The tSirScanOffloadReq will reserve the space for first channel,
1261 * so allocate the memory for (numChannels - 1) and uIEFieldLen
1262 */
1263 len = sizeof(tSirScanOffloadReq) +
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001264 (pScanReq->channelList.numChannels - 1) +
1265 pScanReq->uIEFieldLen;
1266 if (!pMac->per_band_chainmask_supp) {
1267 if (IS_DOT11_MODE_HT(pScanReq->dot11mode)) {
1268 lim_log(pMac, LOG1, FL(
1269 "Adding HT Caps IE since dot11mode=%d"),
1270 pScanReq->dot11mode);
1271 /* 2 bytes for EID and Length */
1272 ht_cap_len = 2 + sizeof(tHtCaps);
1273 len += ht_cap_len;
1274 addn_ie_len += ht_cap_len;
1275 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001276
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001277 if (IS_DOT11_MODE_VHT(pScanReq->dot11mode)) {
1278 lim_log(pMac, LOG1, FL(
1279 "Adding VHT Caps IE since dot11mode=%d"),
1280 pScanReq->dot11mode);
1281 /* 2 bytes for EID and Length */
1282 vht_cap_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
1283 sizeof(tSirVhtMcsInfo);
1284 len += vht_cap_len;
1285 addn_ie_len += vht_cap_len;
1286 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001287 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301288 pScanOffloadReq = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001289 if (NULL == pScanOffloadReq) {
1290 lim_log(pMac, LOGE,
1291 FL("AllocateMemory failed for pScanOffloadReq"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301292 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001293 }
1294
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301295 qdf_mem_set((uint8_t *) pScanOffloadReq, len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001296
1297 msg.type = WMA_START_SCAN_OFFLOAD_REQ;
1298 msg.bodyptr = pScanOffloadReq;
1299 msg.bodyval = 0;
1300
Anurag Chouhanc5548422016-02-24 18:33:27 +05301301 qdf_copy_macaddr(&pScanOffloadReq->bssId, &pScanReq->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001302
1303 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID) {
1304 lim_log(pMac, LOGE,
1305 FL("Invalid value (%d) for numSsid"),
1306 SIR_SCAN_MAX_NUM_SSID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301307 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301308 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001309 }
1310
1311 pScanOffloadReq->numSsid = pScanReq->numSsid;
1312 for (i = 0; i < pScanOffloadReq->numSsid; i++) {
1313 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301314 qdf_mem_copy((uint8_t *) pScanOffloadReq->ssId[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001315 (uint8_t *) pScanReq->ssId[i].ssId,
1316 pScanOffloadReq->ssId[i].length);
1317 }
1318
1319 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301320 qdf_copy_macaddr(&pScanOffloadReq->selfMacAddr, &pScanReq->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001321 pScanOffloadReq->bssType = pScanReq->bssType;
1322 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1323 pScanOffloadReq->scanType = pScanReq->scanType;
1324 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1325 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1326 pScanOffloadReq->restTime = pScanReq->restTime;
Agrawal Ashish17bb3902016-05-05 13:29:40 +05301327 pScanOffloadReq->min_rest_time = pScanReq->min_rest_time;
1328 pScanOffloadReq->idle_time = pScanReq->idle_time;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301329 pScanOffloadReq->scan_adaptive_dwell_mode =
1330 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001331
1332 /* for normal scan, the value for p2pScanType should be 0
1333 always */
1334 if (pScanReq->p2pSearch)
1335 pScanOffloadReq->p2pScanType = P2P_SCAN_TYPE_SEARCH;
1336
1337 pScanOffloadReq->sessionId = pScanReq->sessionId;
1338 pScanOffloadReq->scan_id = pScanReq->scan_id;
Deepak Dhamdhered97bfb32015-10-11 15:16:18 -07001339 pScanOffloadReq->scan_requestor_id = USER_SCAN_REQUESTOR_ID;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301340 pScanOffloadReq->scan_adaptive_dwell_mode =
1341 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001342
1343 if (pScanOffloadReq->sessionId >= pMac->lim.maxBssId)
1344 lim_log(pMac, LOGE, FL("Invalid pe sessionID : %d"),
1345 pScanOffloadReq->sessionId);
1346
1347 pScanOffloadReq->channelList.numChannels =
1348 pScanReq->channelList.numChannels;
1349 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1350 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1351 p[i] = pScanReq->channelList.channelNumber[i];
1352
1353 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1354 pScanOffloadReq->uIEFieldOffset = len - addn_ie_len -
1355 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301356 qdf_mem_copy((uint8_t *) pScanOffloadReq +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001357 pScanOffloadReq->uIEFieldOffset,
1358 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1359 pScanReq->uIEFieldLen);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001360 if (!pMac->per_band_chainmask_supp) {
1361 /* Copy HT Capability info if dot11mode is HT */
1362 if (IS_DOT11_MODE_HT(pScanReq->dot11mode)) {
1363 /* Populate EID and Length field here */
1364 ht_cap_ie = (uint8_t *) pScanOffloadReq +
1365 pScanOffloadReq->uIEFieldOffset +
1366 pScanOffloadReq->uIEFieldLen;
1367 qdf_mem_set(ht_cap_ie, ht_cap_len, 0);
1368 *ht_cap_ie = SIR_MAC_HT_CAPABILITIES_EID;
1369 *(ht_cap_ie + 1) = ht_cap_len - 2;
1370 lim_set_ht_caps(pMac, NULL, ht_cap_ie, ht_cap_len);
1371 pScanOffloadReq->uIEFieldLen += ht_cap_len;
1372 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001373
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001374 /* Copy VHT Capability info if dot11mode is VHT Capable */
1375 if (IS_DOT11_MODE_VHT(pScanReq->dot11mode)) {
1376 /* Populate EID and Length field here */
1377 vht_cap_ie = (uint8_t *) pScanOffloadReq +
1378 pScanOffloadReq->uIEFieldOffset +
1379 pScanOffloadReq->uIEFieldLen;
1380 qdf_mem_set(vht_cap_ie, vht_cap_len, 0);
1381 *vht_cap_ie = SIR_MAC_VHT_CAPABILITIES_EID;
1382 *(vht_cap_ie + 1) = vht_cap_len - 2;
1383 lim_set_vht_caps(pMac, NULL, vht_cap_ie, vht_cap_len);
1384 pScanOffloadReq->uIEFieldLen += vht_cap_len;
1385 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001386 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001387 rc = wma_post_ctrl_msg(pMac, &msg);
1388 if (rc != eSIR_SUCCESS) {
1389 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() return failure"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301390 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301391 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001392 }
1393
1394 lim_log(pMac, LOG1, FL("Processed Offload Scan Request Successfully"));
1395
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301396 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001397}
1398
1399/**
1400 * __lim_process_sme_scan_req() - Process the SME Scan Request
1401 * @mac_ctx: Global MAC Context
1402 * @msg_buf: Buffer which contains the request and pertinent parameters
1403 *
1404 * This function is called to process SME_SCAN_REQ message
1405 * from HDD or upper layer application.
1406 *
1407 * Return: None
1408 */
1409
1410static void __lim_process_sme_scan_req(tpAniSirGlobal mac_ctx,
1411 uint32_t *msg_buf)
1412{
1413 tpSirSmeScanReq scan_req;
1414 uint8_t valid_req = 0;
1415
1416#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1417 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL,
1418 eSIR_SUCCESS, eSIR_SUCCESS);
1419#endif
1420
1421 scan_req = (tpSirSmeScanReq) msg_buf;
1422 lim_log(mac_ctx, LOG1,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301423 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 -08001424 scan_req->scan_id, scan_req->channelList.numChannels,
1425 scan_req->minChannelTime, scan_req->maxChannelTime,
1426 scan_req->uIEFieldLen, scan_req->returnAfterFirstMatch,
1427 scan_req->returnFreshResults, scan_req->returnUniqueResults,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301428 lim_scan_type_to_string(scan_req->scanType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001429 scan_req->scanType, mac_ctx->lim.gLimRspReqd ? 1 : 0);
1430 /*
1431 * Since scan req always requires a response, we will overwrite response
1432 * required here. This is added esp to take care of the condition where
1433 * in p2p go case, we hold the scan req and insert single NOA. We send
1434 * the held scan request to FW later on getting start NOA ind from FW so
1435 * we lose state of the gLimRspReqd flag for the scan req if any other
1436 * request comes by then. e.g. While unit testing, we found when insert
1437 * single NOA is done, we see a get stats request which turns the flag
1438 * gLimRspReqd to false; now when we actually start the saved scan req
1439 * for init scan after getting NOA started, the gLimRspReqd being a
1440 * global flag is showing false instead of true value for this saved
1441 * scan req. Since all scan reqs coming to lim require a response,
1442 * there is no harm in setting the global flag gLimRspReqd to true here.
1443 */
1444 mac_ctx->lim.gLimRspReqd = true;
1445
1446 /*
1447 * copy the Self MAC address from SmeReq to the globalplace,
1448 * used for sending probe req
1449 */
Srinivas Girigowda2c6bf002015-09-24 11:43:31 -07001450 sir_copy_mac_addr(mac_ctx->lim.gSelfMacAddr,
1451 scan_req->selfMacAddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001452 valid_req = lim_is_sme_scan_req_valid(mac_ctx, scan_req);
1453
1454 if (!valid_req || mac_ctx->lim.scan_disabled) {
1455 lim_log(mac_ctx, LOGE,
1456 FL("Scan disabled %d, Valid Scan Req %d"),
1457 mac_ctx->lim.scan_disabled, valid_req);
1458
1459 if (mac_ctx->lim.gLimRspReqd) {
1460 mac_ctx->lim.gLimRspReqd = false;
1461
1462 lim_send_sme_scan_rsp(mac_ctx,
1463 eSIR_SME_INVALID_PARAMETERS,
1464 scan_req->sessionId,
1465 scan_req->transactionId,
1466 scan_req->scan_id);
1467 }
1468 return;
1469 }
1470
1471 /*
1472 * If scan request is received in idle, joinFailed
1473 * states or in link established state (in STA role)
1474 * or in normal state (in STA-in-IBSS/AP role) with
1475 * 'return fresh scan results' request from HDD or
1476 * it is periodic background scanning request,
1477 * trigger fresh scan request to MLM
1478 */
1479 if (__lim_fresh_scan_reqd(mac_ctx, scan_req->returnFreshResults)) {
1480
1481 mac_ctx->lim.gLim24Band11dScanDone = 0;
1482 mac_ctx->lim.gLim50Band11dScanDone = 0;
1483 mac_ctx->lim.gLimReturnAfterFirstMatch =
1484 scan_req->returnAfterFirstMatch;
1485 mac_ctx->lim.gLimReturnUniqueResults =
1486 ((scan_req->returnUniqueResults) > 0 ? true : false);
1487
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301488 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001489 lim_send_hal_start_scan_offload_req(mac_ctx,
1490 scan_req)) {
1491 lim_log(mac_ctx, LOGE, FL(
1492 "Couldn't send Offload scan request"));
1493 lim_send_sme_scan_rsp(mac_ctx,
1494 eSIR_SME_INVALID_PARAMETERS,
1495 scan_req->sessionId,
1496 scan_req->transactionId,
1497 scan_req->scan_id);
1498 return;
1499 }
Anurag Chouhanffb21542016-02-17 14:33:03 +05301500 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001501 /* In all other cases return 'cached' scan results */
1502 if (mac_ctx->lim.gLimRspReqd) {
1503 mac_ctx->lim.gLimRspReqd = false;
1504 lim_send_sme_scan_rsp(mac_ctx, eSIR_SME_SUCCESS,
1505 scan_req->sessionId,
1506 scan_req->transactionId, scan_req->scan_id);
1507 }
1508 }
1509}
1510
1511#ifdef FEATURE_OEM_DATA_SUPPORT
1512
1513static void __lim_process_sme_oem_data_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
1514{
1515 tpSirOemDataReq pOemDataReq;
1516 tLimMlmOemDataReq *pMlmOemDataReq;
1517
1518 pOemDataReq = (tpSirOemDataReq) pMsgBuf;
1519
1520 /* post the lim mlm message now */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301521 pMlmOemDataReq = qdf_mem_malloc(sizeof(*pMlmOemDataReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001522 if (NULL == pMlmOemDataReq) {
1523 lim_log(pMac, LOGP,
1524 FL("AllocateMemory failed for mlmOemDataReq"));
1525 return;
1526 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301527 pMlmOemDataReq->data = qdf_mem_malloc(pOemDataReq->data_len);
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08001528 if (!pMlmOemDataReq->data) {
1529 lim_log(pMac, LOGP, FL("memory allocation failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301530 qdf_mem_free(pMlmOemDataReq);
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08001531 return;
1532 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001533
Anurag Chouhanc5548422016-02-24 18:33:27 +05301534 qdf_copy_macaddr(&pMlmOemDataReq->selfMacAddr,
Srinivas Girigowda0ee66862015-09-24 14:03:29 -07001535 &pOemDataReq->selfMacAddr);
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08001536 pMlmOemDataReq->data_len = pOemDataReq->data_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301537 qdf_mem_copy(pMlmOemDataReq->data, pOemDataReq->data,
Krishna Kumaar Natarajan9ac8efd2015-11-20 13:40:24 -08001538 pOemDataReq->data_len);
Naveen Rawat504adce2016-01-19 17:26:00 -08001539 /* buffer from SME copied, free it now */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301540 qdf_mem_free(pOemDataReq->data);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001541 /* Issue LIM_MLM_OEM_DATA_REQ to MLM */
1542 lim_post_mlm_message(pMac, LIM_MLM_OEM_DATA_REQ,
1543 (uint32_t *) pMlmOemDataReq);
1544
1545 return;
1546
1547} /*** end __lim_process_sme_oem_data_req() ***/
1548
1549#endif /* FEATURE_OEM_DATA_SUPPORT */
1550
1551/**
1552 * __lim_process_clear_dfs_channel_list()
1553 *
1554 ***FUNCTION:
1555 ***Clear DFS channel list when country is changed/aquired.
1556 .*This message is sent from SME.
1557 *
1558 ***LOGIC:
1559 *
1560 ***ASSUMPTIONS:
1561 *
1562 ***NOTE:
1563 *
1564 * @param pMac Pointer to Global MAC structure
1565 * @param *pMsgBuf A pointer to the SME message buffer
1566 * @return None
1567 */
1568static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1569{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301570 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001571}
1572
1573/**
1574 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1575 * @mac_ctx: Pointer to Global MAC structure
1576 * @msg_buf: A pointer to the SME message buffer
1577 *
1578 * This function is called to process SME_JOIN_REQ message
1579 * from HDD or upper layer application.
1580 *
1581 * Return: None
1582 */
1583static void
1584__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1585{
1586 tpSirSmeJoinReq sme_join_req = NULL;
1587 tLimMlmJoinReq *mlm_join_req;
1588 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1589 uint32_t val = 0;
1590 uint16_t n_size;
1591 uint8_t session_id;
1592 tpPESession session = NULL;
1593 uint8_t sme_session_id;
1594 uint16_t sme_transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07001595 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001596 uint16_t ie_len;
1597 uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001598 tSirBssDescription *bss_desc;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001599 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001600
1601/* FEATURE_WLAN_DIAG_SUPPORT */
1602#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1603 /*
1604 * Not sending any session, since it is not created yet.
1605 * The response whould have correct state.
1606 */
1607 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1608#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1609
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001610 /*
1611 * Expect Join request in idle state.
1612 * Reassociate request is expected in link established state.
1613 */
1614
1615 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1616 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1617 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1618 msg_buf);
1619
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301620 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001621 if (NULL == sme_join_req) {
1622 lim_log(mac_ctx, LOGP,
1623 FL("AllocateMemory failed for sme_join_req"));
1624 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1625 return;
1626 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301627 (void)qdf_mem_set((void *)sme_join_req, n_size, 0);
1628 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001629 n_size);
1630
1631 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1632 /* Received invalid eWNI_SME_JOIN_REQ */
1633 /* Log the event */
1634 lim_log(mac_ctx, LOGW,
1635 FL("SessionId:%d JOIN REQ with invalid data"),
1636 sme_join_req->sessionId);
1637 ret_code = eSIR_SME_INVALID_PARAMETERS;
1638 goto end;
1639 }
1640
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001641 /*
1642 * Update the capability here itself as this is used in
1643 * lim_extract_ap_capability() below. If not updated issues
1644 * like not honoring power constraint on 1st association after
1645 * driver loading might occur.
1646 */
1647 lim_update_rrm_capability(mac_ctx, sme_join_req);
1648
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001649 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001650 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001651 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001652 &session_id);
1653
1654 if (session != NULL) {
1655 lim_log(mac_ctx, LOGE,
1656 FL("Session(%d) Already exists for BSSID: "
1657 MAC_ADDRESS_STR " in limSmeState = %X"),
1658 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001659 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001660 session->limSmeState);
1661
1662 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1663 session->smeSessionId == sme_join_req->sessionId) {
1664 /*
1665 * Received eWNI_SME_JOIN_REQ for same
1666 * BSS as currently associated.
1667 * Log the event and send success
1668 */
1669 lim_log(mac_ctx, LOGW,
1670 FL("SessionId: %d"), session_id);
1671 lim_log(mac_ctx, LOGW,
1672 FL("JOIN_REQ for current joined BSS"));
1673 /* Send Join success response to host */
1674 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1675 session = NULL;
1676 goto end;
1677 } else {
1678 lim_log(mac_ctx, LOGE,
1679 FL("JOIN_REQ not for current joined BSS"));
1680 ret_code = eSIR_SME_REFUSED;
1681 session = NULL;
1682 goto end;
1683 }
1684 } else {
1685 /*
1686 * Session Entry does not exist for given BSSId
1687 * Try to Create a new session
1688 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001689 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001690 &session_id, mac_ctx->lim.maxStation,
1691 eSIR_INFRASTRUCTURE_MODE);
1692 if (session == NULL) {
1693 lim_log(mac_ctx, LOGE,
1694 FL("Session Can not be created "));
1695 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1696 goto end;
1697 } else
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301698 lim_log(mac_ctx, LOG2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001699 FL("SessionId:%d New session created"),
1700 session_id);
1701 }
1702 session->isAmsduSupportInAMPDU =
1703 sme_join_req->isAmsduSupportInAMPDU;
1704
1705 /*
1706 * Store Session related parameters
1707 * Store PE session Id in session Table
1708 */
1709 session->peSessionId = session_id;
1710
1711 /* store the smejoin req handle in session table */
1712 session->pLimJoinReq = sme_join_req;
1713
1714 /* Store SME session Id in sessionTable */
1715 session->smeSessionId = sme_join_req->sessionId;
1716
1717 /* Store SME transaction Id in session Table */
1718 session->transactionId = sme_join_req->transactionId;
1719
1720 /* Store beaconInterval */
1721 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001722 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001723
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301724 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001725 sizeof(session->htConfig));
1726
1727 /* Copying of bssId is already done, while creating session */
1728 sir_copy_mac_addr(session->selfMacAddr,
1729 sme_join_req->selfMacAddr);
1730 session->bssType = sme_join_req->bsstype;
1731
1732 session->statypeForBss = STA_ENTRY_PEER;
1733 session->limWmeEnabled = sme_join_req->isWMEenabled;
1734 session->limQosEnabled = sme_join_req->isQosEnabled;
1735
1736 /* Store vendor specfic IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001737 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001738 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1739
1740 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
1741 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001742 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001743
1744 if (NULL != vendor_ie) {
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08001745 lim_log(mac_ctx, LOG1, FL("Cisco vendor OUI present"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001746 session->isCiscoVendorAP = true;
1747 } else {
1748 session->isCiscoVendorAP = false;
1749 }
1750
1751 /* Copy the dot 11 mode in to the session table */
1752
1753 session->dot11mode = sme_join_req->dot11mode;
1754#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1755 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1756#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001757 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001758 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1759 session->enableHtSmps = sme_join_req->enableHtSmps;
1760 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001761 session->send_smps_action =
1762 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001763 /*
1764 * By default supported NSS 1x1 is set to true
1765 * and later on updated while determining session
1766 * supported rates which is the intersection of
1767 * self and peer rates
1768 */
1769 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301770 /*Store Persona */
1771 session->pePersona = sme_join_req->staPersona;
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001772 lim_log(mac_ctx, LOG1,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301773 FL("enable Smps: %d mode: %d send action: %d supported nss 1x1: %d pePersona %d cbMode %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001774 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001775 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001776 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301777 session->supported_nss_1x1,
1778 session->pePersona,
1779 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001780
1781 /*Store Persona */
1782 session->pePersona = sme_join_req->staPersona;
1783 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
1784 FL("PE PERSONA=%d cbMode %u"),
1785 session->pePersona, sme_join_req->cbMode);
1786 /* Copy The channel Id to the session Table */
1787 session->currentOperChannel = bss_desc->channelId;
1788 if (IS_5G_CH(session->currentOperChannel))
1789 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001790 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001791 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
1792 if (session->pePersona == QDF_P2P_CLIENT_MODE)
1793 session->vdev_nss = vdev_type_nss->p2p_cli;
1794 else
1795 session->vdev_nss = vdev_type_nss->sta;
1796 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001797 session->vhtCapability =
1798 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001799 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301800 if (session->pePersona == QDF_STA_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001801 session->txBFIniFeatureEnabled =
1802 sme_join_req->txBFIniFeatureEnabled;
1803 } else {
1804 session->txBFIniFeatureEnabled = 0;
1805 }
1806 session->txMuBformee = sme_join_req->txMuBformee;
1807 session->enableVhtpAid =
1808 sme_join_req->enableVhtpAid;
1809 session->enableVhtGid =
1810 sme_join_req->enableVhtGid;
1811
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001812 if (wlan_cfg_get_int(mac_ctx,
1813 WNI_CFG_VHT_SU_BEAMFORMER_CAP, &val) !=
1814 eSIR_SUCCESS)
1815 lim_log(mac_ctx, LOGE, FL(
1816 "cfg get vht su bformer failed"));
1817
1818 session->enable_su_tx_bformer = val;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001819 }
1820 if (session->vhtCapability && session->txBFIniFeatureEnabled) {
1821 if (cfg_set_int(mac_ctx, WNI_CFG_VHT_SU_BEAMFORMEE_CAP,
1822 session->txBFIniFeatureEnabled) !=
1823 eSIR_SUCCESS) {
1824 /*
1825 * Set failed for
1826 * CFG_VHT_SU_BEAMFORMEE_CAP
1827 */
1828 lim_log(mac_ctx, LOGP,
1829 FL("Failed CFG_VHT_SU_BEAMFORMEE_CAP"));
1830 ret_code = eSIR_LOGP_EXCEPTION;
1831 goto end;
1832 }
Kiran Kumar Lokere5302ab62015-12-16 16:03:16 -08001833 session->txbf_csn_value = sme_join_req->txBFCsnValue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001834 }
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301835 lim_log(mac_ctx, LOG1,
1836 FL("vhtCapability: %d txBFIniFeatureEnabled: %d txbf_csn_value: %d su_tx_bformer %d"),
1837 session->vhtCapability,
1838 session->txBFIniFeatureEnabled,
1839 session->txbf_csn_value,
1840 session->enable_su_tx_bformer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001841 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001842 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001843 handle_ht_capabilityand_ht_info(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001844 /* cbMode is already merged value of peer and self -
1845 * done by csr in csr_get_cb_mode_from_ies */
1846 session->htSupportedChannelWidthSet =
1847 (sme_join_req->cbMode) ? 1 : 0;
1848 session->htRecommendedTxWidthSet =
1849 session->htSupportedChannelWidthSet;
1850 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1851
1852 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1853 session->ch_center_freq_seg0 =
1854 session->currentOperChannel - 2;
1855 session->ch_width = CH_WIDTH_40MHZ;
1856 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1857 sme_join_req->cbMode) {
1858 session->ch_center_freq_seg0 =
1859 session->currentOperChannel + 2;
1860 session->ch_width = CH_WIDTH_40MHZ;
1861 } else {
1862 session->ch_center_freq_seg0 = 0;
1863 session->ch_width = CH_WIDTH_20MHZ;
1864 }
1865
1866 /* Record if management frames need to be protected */
1867#ifdef WLAN_FEATURE_11W
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001868 if (eSIR_ED_AES_128_CMAC == sme_join_req->MgmtEncryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001869 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001870 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001871 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001872#endif
1873
1874#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001875 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001876#endif
1877
1878 /* Copy the SSID from smejoinreq to session entry */
1879 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301880 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001881 session->ssId.length);
1882
1883 /*
1884 * Determin 11r or ESE connection based on input from SME
1885 * which inturn is dependent on the profile the user wants
1886 * to connect to, So input is coming from supplicant
1887 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001888 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001889#ifdef FEATURE_WLAN_ESE
1890 session->isESEconnection = sme_join_req->isESEconnection;
1891#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001892 session->isFastTransitionEnabled =
1893 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001894
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001895 session->isFastRoamIniFeatureEnabled =
1896 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001897 session->txLdpcIniFeatureEnabled =
1898 sme_join_req->txLdpcIniFeatureEnabled;
1899
1900 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1901 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001902 } else {
1903 /*
1904 * Throw an error and return and make
1905 * sure to delete the session.
1906 */
1907 lim_log(mac_ctx, LOGE,
1908 FL("recvd JOIN_REQ with invalid bss type %d"),
1909 session->bssType);
1910 ret_code = eSIR_SME_INVALID_PARAMETERS;
1911 goto end;
1912 }
1913
1914 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301915 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001916 &sme_join_req->addIEScan, sizeof(tSirAddie));
1917
1918 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301919 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001920 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1921
1922 val = sizeof(tLimMlmJoinReq) +
1923 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301924 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001925 if (NULL == mlm_join_req) {
1926 lim_log(mac_ctx, LOGP,
1927 FL("AllocateMemory failed for mlmJoinReq"));
1928 return;
1929 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301930 (void)qdf_mem_set((void *)mlm_join_req, val, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001931
1932 /* PE SessionId is stored as a part of JoinReq */
1933 mlm_join_req->sessionId = session->peSessionId;
1934
1935 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1936 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1937 eSIR_SUCCESS) {
1938 lim_log(mac_ctx, LOGP,
1939 FL("couldn't retrieve JoinFailureTimer value"
1940 " setting to default value"));
1941 mlm_join_req->joinFailureTimeout =
1942 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1943 }
1944
1945 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301946 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001947 (void *)&sme_join_req->operationalRateSet,
1948 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301949 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001950 (void *)&sme_join_req->extendedRateSet,
1951 sizeof(tSirMacRateSet));
1952 /*
1953 * this may not be needed anymore now, as rateSet is now
1954 * included in the session entry and MLM has session context.
1955 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301956 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001957 (void *)&session->rateSet,
1958 sizeof(tSirMacRateSet));
1959
1960 session->encryptType = sme_join_req->UCEncryptionType;
1961
1962 mlm_join_req->bssDescription.length =
1963 session->pLimJoinReq->bssDescription.length;
1964
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301965 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001966 (uint8_t *)
1967 &session->pLimJoinReq->bssDescription.bssId,
1968 session->pLimJoinReq->bssDescription.length + 2);
1969
1970 session->limCurrentBssCaps =
1971 session->pLimJoinReq->bssDescription.capabilityInfo;
1972
1973 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1974 session->currentOperChannel);
1975 local_power_constraint = reg_max;
1976
1977 lim_extract_ap_capability(mac_ctx,
1978 (uint8_t *)
1979 session->pLimJoinReq->bssDescription.ieFields,
1980 lim_get_ielen_from_bss_description(
1981 &session->pLimJoinReq->bssDescription),
1982 &session->limCurrentBssQosCaps,
1983 &session->limCurrentBssPropCap,
1984 &session->gLimCurrentBssUapsd,
1985 &local_power_constraint, session);
1986
1987#ifdef FEATURE_WLAN_ESE
1988 session->maxTxPower = lim_get_max_tx_power(reg_max,
1989 local_power_constraint,
1990 mac_ctx->roam.configParam.nTxPowerCap);
1991#else
1992 session->maxTxPower =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301993 QDF_MIN(reg_max, (local_power_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001994#endif
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301995 lim_log(mac_ctx, LOG1,
1996 FL("Reg max = %d, local power con = %d, max tx = %d"),
1997 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001998
1999 if (session->gLimCurrentBssUapsd) {
2000 session->gUapsdPerAcBitmask =
2001 session->pLimJoinReq->uapsdPerAcBitmask;
2002 lim_log(mac_ctx, LOG1,
2003 FL("UAPSD flag for all AC - 0x%2x"),
2004 session->gUapsdPerAcBitmask);
2005
2006 /* resetting the dynamic uapsd mask */
2007 session->gUapsdPerAcDeliveryEnableMask = 0;
2008 session->gUapsdPerAcTriggerEnableMask = 0;
2009 }
2010
2011 session->limRFBand =
2012 lim_get_rf_band(session->currentOperChannel);
2013
2014 /* Initialize 11h Enable Flag */
2015 if (SIR_BAND_5_GHZ == session->limRFBand) {
2016 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
2017 &val) != eSIR_SUCCESS) {
2018 lim_log(mac_ctx, LOGP,
2019 FL("Fail to get WNI_CFG_11H_ENABLED "));
2020 session->lim11hEnable =
2021 WNI_CFG_11H_ENABLED_STADEF;
2022 } else {
2023 session->lim11hEnable = val;
2024 }
2025 } else {
2026 session->lim11hEnable = 0;
2027 }
2028
2029 /*
2030 * To care of the scenario when STA transitions from
2031 * IBSS to Infrastructure mode.
2032 */
2033 mac_ctx->lim.gLimIbssCoalescingHappened = false;
2034
2035 session->limPrevSmeState = session->limSmeState;
2036 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
2037 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2038 session->peSessionId,
2039 session->limSmeState));
2040
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002041 /* Indicate whether spectrum management is enabled */
2042 session->spectrumMgtEnabled =
2043 sme_join_req->spectrumMgtIndicator;
2044
2045 /* Enable the spectrum management if this is a DFS channel */
2046 if (session->country_info_present &&
2047 lim_isconnected_on_dfs_channel(
2048 session->currentOperChannel))
2049 session->spectrumMgtEnabled = true;
2050
2051 session->isOSENConnection = sme_join_req->isOSENConnection;
2052
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002053 /* Issue LIM_MLM_JOIN_REQ to MLM */
2054 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
2055 (uint32_t *) mlm_join_req);
2056 return;
2057
2058 } else {
2059 /* Received eWNI_SME_JOIN_REQ un expected state */
2060 lim_log(mac_ctx, LOGE,
2061 FL("received unexpected SME_JOIN_REQ in state %X"),
2062 mac_ctx->lim.gLimSmeState);
2063 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
2064 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2065 session = NULL;
2066 goto end;
2067 }
2068
2069end:
Naveen Rawat9ea74702016-06-27 15:24:29 -07002070 sme_session_id = ((tpSirSmeJoinReq)msg_buf)->sessionId;
2071 sme_transaction_id = ((tpSirSmeJoinReq)msg_buf)->transactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002072
2073 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302074 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002075 sme_join_req = NULL;
2076 if (NULL != session)
2077 session->pLimJoinReq = NULL;
2078 }
2079 if (ret_code != eSIR_SME_SUCCESS) {
2080 if (NULL != session) {
2081 pe_delete_session(mac_ctx, session);
2082 session = NULL;
2083 }
2084 }
2085 lim_log(mac_ctx, LOG1,
2086 FL("Send failure status on sessionid: %d with ret_code = %d"),
2087 sme_session_id, ret_code);
2088 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
2089 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
2090 sme_transaction_id);
2091}
2092
Amar Singhala297bfa2015-10-15 15:07:29 -07002093uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002094 uint8_t iniTxPower)
2095{
2096 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302097 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
2098 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002099 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2100 maxTxPower = txPower;
2101 else if (txPower < MIN_TX_PWR_CAP)
2102 maxTxPower = MIN_TX_PWR_CAP;
2103 else
2104 maxTxPower = MAX_TX_PWR_CAP;
2105
2106 return maxTxPower;
2107}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002108
2109/**
2110 * __lim_process_sme_reassoc_req() - process reassoc req
2111 *
2112 * @mac_ctx: Pointer to Global MAC structure
2113 * @msg_buf: pointer to the SME message buffer
2114 *
2115 * This function is called to process SME_REASSOC_REQ message
2116 * from HDD or upper layer application.
2117 *
2118 * Return: None
2119 */
2120
2121static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2122 uint32_t *msg_buf)
2123{
2124 uint16_t caps;
2125 uint32_t val;
2126 tpSirSmeJoinReq reassoc_req = NULL;
2127 tLimMlmReassocReq *mlm_reassoc_req;
2128 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2129 tpPESession session_entry = NULL;
2130 uint8_t session_id;
2131 uint8_t sme_session_id;
2132 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002133 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002134 uint32_t tele_bcn_en = 0;
2135 uint16_t size;
2136
2137 lim_log(mac_ctx, LOG3, FL("Received REASSOC_REQ"));
2138
2139 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302140 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002141 if (NULL == reassoc_req) {
2142 lim_log(mac_ctx, LOGP,
2143 FL("call to AllocateMemory failed for reassoc_req"));
2144
2145 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2146 goto end;
2147 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302148 (void)qdf_mem_set((void *)reassoc_req, size, 0);
2149 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002150
2151 if (!lim_is_sme_join_req_valid(mac_ctx,
2152 (tpSirSmeJoinReq)reassoc_req)) {
2153 /*
2154 * Received invalid eWNI_SME_REASSOC_REQ
2155 */
2156 lim_log(mac_ctx, LOGW,
2157 FL("received SME_REASSOC_REQ with invalid data"));
2158
2159 ret_code = eSIR_SME_INVALID_PARAMETERS;
2160 goto end;
2161 }
2162
2163 session_entry = pe_find_session_by_bssid(mac_ctx,
2164 reassoc_req->bssDescription.bssId,
2165 &session_id);
2166 if (session_entry == NULL) {
2167 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2168 LOGE);
2169 lim_log(mac_ctx, LOGE,
2170 FL("Session does not exist for given bssId"));
2171 ret_code = eSIR_SME_INVALID_PARAMETERS;
2172 goto end;
2173 }
2174#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2175 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2176 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2177#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2178 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2179
2180 /* Store the reassoc handle in the session Table */
2181 session_entry->pLimReAssocReq = reassoc_req;
2182
2183 session_entry->dot11mode = reassoc_req->dot11mode;
2184 session_entry->vhtCapability =
2185 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002186
2187 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2188 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002189 session_entry->send_smps_action =
2190 reassoc_req->send_smps_action;
2191 lim_log(mac_ctx, LOG1,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002192 FL("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002193 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002194 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002195 session_entry->send_smps_action,
2196 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002197 /*
2198 * Reassociate request is expected
2199 * in link established state only.
2200 */
2201
2202 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002203 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2204 /*
2205 * May be from 11r FT pre-auth. So lets check it
2206 * before we bail out
2207 */
2208 lim_log(mac_ctx, LOG1, FL(
2209 "Session in reassoc state is %d"),
2210 session_entry->peSessionId);
2211
2212 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302213 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002214 session_entry->limReAssocbssId,
2215 6)) {
2216 lim_print_mac_addr(mac_ctx,
2217 reassoc_req->bssDescription.
2218 bssId, LOGE);
2219 lim_log(mac_ctx, LOGP,
2220 FL("Unknown bssId in reassoc state"));
2221 ret_code = eSIR_SME_INVALID_PARAMETERS;
2222 goto end;
2223 }
2224
2225 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2226 session_entry);
2227 return;
2228 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002229 /*
2230 * Should not have received eWNI_SME_REASSOC_REQ
2231 */
2232 lim_log(mac_ctx, LOGE,
2233 FL("received unexpected SME_REASSOC_REQ in state %X"),
2234 session_entry->limSmeState);
2235 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2236
2237 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2238 goto end;
2239 }
2240
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302241 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002242 session_entry->pLimReAssocReq->bssDescription.bssId,
2243 sizeof(tSirMacAddr));
2244
2245 session_entry->limReassocChannelId =
2246 session_entry->pLimReAssocReq->bssDescription.channelId;
2247
2248 session_entry->reAssocHtSupportedChannelWidthSet =
2249 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2250 session_entry->reAssocHtRecommendedTxWidthSet =
2251 session_entry->reAssocHtSupportedChannelWidthSet;
2252 session_entry->reAssocHtSecondaryChannelOffset =
2253 session_entry->pLimReAssocReq->cbMode;
2254
2255 session_entry->limReassocBssCaps =
2256 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2257 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2258 session_entry->currentOperChannel);
2259 local_pwr_constraint = reg_max;
2260
2261 lim_extract_ap_capability(mac_ctx,
2262 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2263 lim_get_ielen_from_bss_description(
2264 &session_entry->pLimReAssocReq->bssDescription),
2265 &session_entry->limReassocBssQosCaps,
2266 &session_entry->limReassocBssPropCap,
2267 &session_entry->gLimCurrentBssUapsd,
2268 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302269 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002270 lim_log(mac_ctx, LOGE,
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302271 FL("Reg max = %d, local pwr constraint = %d, max tx = %d"),
2272 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002273 /* Copy the SSID from session entry to local variable */
2274 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302275 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002276 reassoc_req->ssId.ssId,
2277 session_entry->limReassocSSID.length);
2278 if (session_entry->gLimCurrentBssUapsd) {
2279 session_entry->gUapsdPerAcBitmask =
2280 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
2281 lim_log(mac_ctx, LOG1,
2282 FL("UAPSD flag for all AC - 0x%2x"),
2283 session_entry->gUapsdPerAcBitmask);
2284 }
2285
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302286 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002287 if (NULL == mlm_reassoc_req) {
2288 lim_log(mac_ctx, LOGP,
2289 FL("call to AllocateMemory failed for mlmReassocReq"));
2290
2291 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2292 goto end;
2293 }
2294
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302295 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002296 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2297
2298 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2299 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
2300 eSIR_SUCCESS) {
2301 /*
2302 * Could not get ReassocFailureTimeout value
2303 * from CFG. Log error.
2304 */
2305 lim_log(mac_ctx, LOGP,
2306 FL("could not retrieve ReassocFailureTimeout value"));
2307 }
2308
2309 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
2310 eSIR_SUCCESS) {
2311 /*
2312 * Could not get Capabilities value
2313 * from CFG. Log error.
2314 */
2315 lim_log(mac_ctx, LOGP, FL(
2316 "could not retrieve Capabilities value"));
2317 }
2318 mlm_reassoc_req->capabilityInfo = caps;
2319
2320 /* Update PE session_id */
2321 mlm_reassoc_req->sessionId = session_id;
2322
2323 /*
2324 * If telescopic beaconing is enabled, set listen interval to
2325 * WNI_CFG_TELE_BCN_MAX_LI
2326 */
2327 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2328 &tele_bcn_en) != eSIR_SUCCESS)
2329 lim_log(mac_ctx, LOGP,
2330 FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
2331
2332 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2333
2334 if (tele_bcn_en) {
2335 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2336 eSIR_SUCCESS)
2337 /*
2338 * Could not get ListenInterval value
2339 * from CFG. Log error.
2340 */
2341 lim_log(mac_ctx, LOGP,
2342 FL("could not retrieve ListenInterval"));
2343 } else {
2344 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
2345 eSIR_SUCCESS)
2346 /*
2347 * Could not get ListenInterval value
2348 * from CFG. Log error.
2349 */
2350 lim_log(mac_ctx, LOGP,
2351 FL("could not retrieve ListenInterval"));
2352 }
2353
2354 mlm_reassoc_req->listenInterval = (uint16_t) val;
2355
2356 /* Indicate whether spectrum management is enabled */
2357 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2358
2359 /* Enable the spectrum management if this is a DFS channel */
2360 if (session_entry->country_info_present &&
2361 lim_isconnected_on_dfs_channel(
2362 session_entry->currentOperChannel))
2363 session_entry->spectrumMgtEnabled = true;
2364
2365 session_entry->limPrevSmeState = session_entry->limSmeState;
2366 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2367
2368 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2369 session_entry->peSessionId,
2370 session_entry->limSmeState));
2371
2372 lim_post_mlm_message(mac_ctx,
2373 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2374 return;
2375end:
2376 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302377 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002378 if (session_entry)
2379 session_entry->pLimReAssocReq = NULL;
2380 }
2381
2382 if (session_entry) {
2383 /*
2384 * error occurred after we determined the session so extract
2385 * session and transaction info from there
2386 */
2387 sme_session_id = session_entry->smeSessionId;
2388 transaction_id = session_entry->transactionId;
2389 } else
2390 /*
2391 * error occurred before or during the time we determined
2392 * the session so extract the session and transaction info
2393 * from the message
2394 */
2395 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2396 &sme_session_id, &transaction_id);
2397
2398 /*
2399 * Send Reassoc failure response to host
2400 * (note session_entry may be NULL, but that's OK)
2401 */
2402 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2403 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2404 session_entry, sme_session_id,
2405 transaction_id);
2406}
2407
2408bool send_disassoc_frame = 1;
2409/**
2410 * __lim_process_sme_disassoc_req()
2411 *
2412 ***FUNCTION:
2413 * This function is called to process SME_DISASSOC_REQ message
2414 * from HDD or upper layer application.
2415 *
2416 ***LOGIC:
2417 *
2418 ***ASSUMPTIONS:
2419 *
2420 ***NOTE:
2421 *
2422 * @param pMac Pointer to Global MAC structure
2423 * @param *pMsgBuf A pointer to the SME message buffer
2424 * @return None
2425 */
2426
2427static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2428{
2429 uint16_t disassocTrigger, reasonCode;
2430 tLimMlmDisassocReq *pMlmDisassocReq;
2431 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2432 tSirSmeDisassocReq smeDisassocReq;
2433 tpPESession psessionEntry = NULL;
2434 uint8_t sessionId;
2435 uint8_t smesessionId;
2436 uint16_t smetransactionId;
2437
2438 if (pMsgBuf == NULL) {
2439 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
2440 return;
2441 }
2442
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302443 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002444 smesessionId = smeDisassocReq.sessionId;
2445 smetransactionId = smeDisassocReq.transactionId;
2446 if (!lim_is_sme_disassoc_req_valid(pMac,
2447 &smeDisassocReq,
2448 psessionEntry)) {
2449 PELOGE(lim_log(pMac, LOGE,
2450 FL("received invalid SME_DISASSOC_REQ message"));)
2451 if (pMac->lim.gLimRspReqd) {
2452 pMac->lim.gLimRspReqd = false;
2453
2454 retCode = eSIR_SME_INVALID_PARAMETERS;
2455 disassocTrigger = eLIM_HOST_DISASSOC;
2456 goto sendDisassoc;
2457 }
2458
2459 return;
2460 }
2461
2462 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002463 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002464 &sessionId);
2465 if (psessionEntry == NULL) {
2466 lim_log(pMac, LOGE,
2467 FL("session does not exist for given bssId "
2468 MAC_ADDRESS_STR),
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002469 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002470 retCode = eSIR_SME_INVALID_PARAMETERS;
2471 disassocTrigger = eLIM_HOST_DISASSOC;
2472 goto sendDisassoc;
2473 }
2474 lim_log(pMac, LOG1,
2475 FL("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2476 MAC_ADDRESS_STR), smesessionId,
2477 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2478 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002479 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002480
2481#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2482 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2483 0, smeDisassocReq.reasonCode);
2484#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2485
2486 /* Update SME session Id and SME transaction ID */
2487
2488 psessionEntry->smeSessionId = smesessionId;
2489 psessionEntry->transactionId = smetransactionId;
2490
2491 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2492 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002493 switch (psessionEntry->limSmeState) {
2494 case eLIM_SME_ASSOCIATED_STATE:
2495 case eLIM_SME_LINK_EST_STATE:
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002496 lim_log(pMac, LOG1,
2497 FL("Rcvd SME_DISASSOC_REQ in limSmeState: %d "),
2498 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002499 psessionEntry->limPrevSmeState =
2500 psessionEntry->limSmeState;
2501 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2502#ifdef FEATURE_WLAN_TDLS
2503 /* Delete all TDLS peers connected before leaving BSS */
2504 lim_delete_tdls_peers(pMac, psessionEntry);
2505#endif
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002506 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2507 psessionEntry->peSessionId,
2508 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002509 break;
2510
2511 case eLIM_SME_WT_DEAUTH_STATE:
2512 /* PE shall still process the DISASSOC_REQ and proceed with
2513 * link tear down even if it had already sent a DEAUTH_IND to
2514 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2515 * its been set when PE entered WT_DEAUTH_STATE.
2516 */
2517 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2518 MTRACE(mac_trace
2519 (pMac, TRACE_CODE_SME_STATE,
2520 psessionEntry->peSessionId,
2521 psessionEntry->limSmeState));
2522 lim_log(pMac, LOG1,
2523 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE. "));
2524 break;
2525
2526 case eLIM_SME_WT_DISASSOC_STATE:
2527 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2528 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2529 * PE can continue processing DISASSOC_REQ and send the response instead
2530 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2531 * for disassoc frame.
2532 *
2533 * It will send a disassoc, which is ok. However, we can use the global flag
2534 * sendDisassoc to not send disassoc frame.
2535 */
2536 lim_log(pMac, LOG1,
2537 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE. "));
2538 break;
2539
2540 case eLIM_SME_JOIN_FAILURE_STATE: {
2541 /* Already in Disconnected State, return success */
2542 lim_log(pMac, LOG1,
2543 FL("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE. "));
2544 if (pMac->lim.gLimRspReqd) {
2545 retCode = eSIR_SME_SUCCESS;
2546 disassocTrigger = eLIM_HOST_DISASSOC;
2547 goto sendDisassoc;
2548 }
2549 }
2550 break;
2551 default:
2552 /**
2553 * STA is not currently associated.
2554 * Log error and send response to host
2555 */
2556 lim_log(pMac, LOGE,
2557 FL("received unexpected SME_DISASSOC_REQ in state %X"),
2558 psessionEntry->limSmeState);
2559 lim_print_sme_state(pMac, LOGE,
2560 psessionEntry->limSmeState);
2561
2562 if (pMac->lim.gLimRspReqd) {
2563 if (psessionEntry->limSmeState !=
2564 eLIM_SME_WT_ASSOC_STATE)
2565 pMac->lim.gLimRspReqd = false;
2566
2567 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2568 disassocTrigger = eLIM_HOST_DISASSOC;
2569 goto sendDisassoc;
2570 }
2571
2572 return;
2573 }
2574
2575 break;
2576
2577 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002578 /* Fall through */
2579 break;
2580
2581 case eLIM_STA_IN_IBSS_ROLE:
2582 default:
2583 /* eLIM_UNKNOWN_ROLE */
2584 lim_log(pMac, LOGE,
2585 FL("received unexpected SME_DISASSOC_REQ for role %d"),
2586 GET_LIM_SYSTEM_ROLE(psessionEntry));
2587
2588 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2589 disassocTrigger = eLIM_HOST_DISASSOC;
2590 goto sendDisassoc;
2591 } /* end switch (pMac->lim.gLimSystemRole) */
2592
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302593 disassocTrigger = eLIM_HOST_DISASSOC;
2594 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002595
2596 if (smeDisassocReq.doNotSendOverTheAir) {
2597 lim_log(pMac, LOG1, FL("do not send dissoc over the air"));
2598 send_disassoc_frame = 0;
2599 }
2600 /* Trigger Disassociation frame to peer MAC entity */
2601 lim_log(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2602 " : %d, reasonCode : %d"),
2603 disassocTrigger, reasonCode);
2604
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302605 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002606 if (NULL == pMlmDisassocReq) {
2607 /* Log error */
2608 lim_log(pMac, LOGP,
2609 FL("call to AllocateMemory failed for mlmDisassocReq"));
2610
2611 return;
2612 }
2613
Anurag Chouhanc5548422016-02-24 18:33:27 +05302614 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002615 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002616
2617 pMlmDisassocReq->reasonCode = reasonCode;
2618 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2619
2620 /* Update PE session ID */
2621 pMlmDisassocReq->sessionId = sessionId;
2622
2623 lim_post_mlm_message(pMac,
2624 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2625 return;
2626
2627sendDisassoc:
2628 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002629 lim_send_sme_disassoc_ntf(pMac,
2630 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002631 retCode,
2632 disassocTrigger,
2633 1, smesessionId, smetransactionId,
2634 psessionEntry);
2635 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002636 lim_send_sme_disassoc_ntf(pMac,
2637 smeDisassocReq.peer_macaddr.bytes,
2638 retCode, disassocTrigger, 1,
2639 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002640
2641} /*** end __lim_process_sme_disassoc_req() ***/
2642
2643/** -----------------------------------------------------------------
2644 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2645
2646 This function is called to process SME_DISASSOC_CNF message
2647 from HDD or upper layer application.
2648
2649 \param pMac - global mac structure
2650 \param pStaDs - station dph hash node
2651 \return none
2652 \sa
2653 ----------------------------------------------------------------- */
2654static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2655{
2656 tSirSmeDisassocCnf smeDisassocCnf;
2657 uint16_t aid;
2658 tpDphHashNode pStaDs;
2659 tpPESession psessionEntry;
2660 uint8_t sessionId;
2661
2662 PELOG1(lim_log(pMac, LOG1, FL("received DISASSOC_CNF message"));)
2663
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302664 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002665 sizeof(struct sSirSmeDisassocCnf));
2666
2667 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002668 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002669 &sessionId);
2670 if (psessionEntry == NULL) {
2671 lim_log(pMac, LOGE,
2672 FL("session does not exist for given bssId"));
2673 return;
2674 }
2675
2676 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
2677 lim_log(pMac, LOGE,
2678 FL("received invalid SME_DISASSOC_CNF message"));
2679 return;
2680 }
2681#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2682 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2683 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2684 psessionEntry,
2685 (uint16_t) smeDisassocCnf.statusCode, 0);
2686 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2687 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2688 psessionEntry,
2689 (uint16_t) smeDisassocCnf.statusCode, 0);
2690#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2691
2692 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2693 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002694 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2695 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2696 && (psessionEntry->limSmeState !=
2697 eLIM_SME_WT_DEAUTH_STATE)) {
2698 lim_log(pMac, LOGE,
2699 FL
2700 ("received unexp SME_DISASSOC_CNF in state %X"),
2701 psessionEntry->limSmeState);
2702 lim_print_sme_state(pMac, LOGE,
2703 psessionEntry->limSmeState);
2704 return;
2705 }
2706 break;
2707
2708 case eLIM_AP_ROLE:
2709 /* Fall through */
2710 break;
2711
2712 case eLIM_STA_IN_IBSS_ROLE:
2713 default: /* eLIM_UNKNOWN_ROLE */
2714 lim_log(pMac, LOGE,
2715 FL("received unexpected SME_DISASSOC_CNF role %d"),
2716 GET_LIM_SYSTEM_ROLE(psessionEntry));
2717
2718 return;
2719 }
2720
2721 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2722 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2723 LIM_IS_AP_ROLE(psessionEntry)) {
2724 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002725 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002726 &psessionEntry->dph.dphHashTable);
2727 if (pStaDs == NULL) {
2728 lim_log(pMac, LOGE,
2729 FL("DISASSOC_CNF for a STA with no context, addr= "
2730 MAC_ADDRESS_STR),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002731 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002732 return;
2733 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302734
2735 if ((pStaDs->mlmStaContext.mlmState ==
2736 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2737 (pStaDs->mlmStaContext.mlmState ==
2738 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
2739 lim_log(pMac, LOGE,
2740 FL("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d"),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002741 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302742 pStaDs->mlmStaContext.mlmState);
2743 return;
2744 }
2745
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002746 /* Delete FT session if there exists one */
2747 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002748 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2749
2750 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002751 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002752 }
2753
2754 return;
2755}
2756
2757/**
2758 * __lim_process_sme_deauth_req() - process sme deauth req
2759 * @mac_ctx: Pointer to Global MAC structure
2760 * @msg_buf: pointer to the SME message buffer
2761 *
2762 * This function is called to process SME_DEAUTH_REQ message
2763 * from HDD or upper layer application.
2764 *
2765 * Return: None
2766 */
2767
2768static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2769 uint32_t *msg_buf)
2770{
2771 uint16_t deauth_trigger, reason_code;
2772 tLimMlmDeauthReq *mlm_deauth_req;
2773 tSirSmeDeauthReq sme_deauth_req;
2774 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2775 tpPESession session_entry;
2776 uint8_t session_id; /* PE sessionId */
2777 uint8_t sme_session_id;
2778 uint16_t sme_transaction_id;
2779
2780 lim_log(mac_ctx, LOG1, FL("received DEAUTH_REQ message"));
2781
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302782 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002783 sme_session_id = sme_deauth_req.sessionId;
2784 sme_transaction_id = sme_deauth_req.transactionId;
2785
2786 /*
2787 * We need to get a session first but we don't even know
2788 * if the message is correct.
2789 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002790 session_entry = pe_find_session_by_bssid(mac_ctx,
2791 sme_deauth_req.bssid.bytes,
2792 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002793 if (session_entry == NULL) {
2794 lim_log(mac_ctx, LOGE,
2795 FL("session does not exist for given bssId"));
2796 ret_code = eSIR_SME_INVALID_PARAMETERS;
2797 deauth_trigger = eLIM_HOST_DEAUTH;
2798 goto send_deauth;
2799 }
2800
2801 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2802 session_entry)) {
2803 lim_log(mac_ctx, LOGE,
2804 FL("received invalid SME_DEAUTH_REQ message"));
2805 mac_ctx->lim.gLimRspReqd = false;
2806
2807 ret_code = eSIR_SME_INVALID_PARAMETERS;
2808 deauth_trigger = eLIM_HOST_DEAUTH;
2809 goto send_deauth;
2810 }
2811 lim_log(mac_ctx, LOG1,
2812 FL("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2813 MAC_ADDRESS_STR), sme_session_id,
2814 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2815 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002816 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002817#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2818 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2819 session_entry, 0, sme_deauth_req.reasonCode);
2820#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2821
2822 /* Update SME session ID and Transaction ID */
2823 session_entry->smeSessionId = sme_session_id;
2824 session_entry->transactionId = sme_transaction_id;
2825
2826 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2827 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002828 switch (session_entry->limSmeState) {
2829 case eLIM_SME_ASSOCIATED_STATE:
2830 case eLIM_SME_LINK_EST_STATE:
2831 case eLIM_SME_WT_ASSOC_STATE:
2832 case eLIM_SME_JOIN_FAILURE_STATE:
2833 case eLIM_SME_IDLE_STATE:
2834 session_entry->limPrevSmeState =
2835 session_entry->limSmeState;
2836 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2837 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2838 session_entry->peSessionId,
2839 session_entry->limSmeState));
2840 /* Send Deauthentication request to MLM below */
2841 break;
2842 case eLIM_SME_WT_DEAUTH_STATE:
2843 case eLIM_SME_WT_DISASSOC_STATE:
2844 /*
2845 * PE Recieved a Deauth/Disassoc frame. Normally it get
2846 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2847 * Which means host is also trying to disconnect.
2848 * PE can continue processing DEAUTH_REQ and send
2849 * the response instead of failing the request.
2850 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2851 * was sent for deauth/disassoc frame.
2852 */
2853 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2854 lim_log(mac_ctx, LOG1, FL(
2855 "Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE"));
2856 break;
2857 default:
2858 /*
2859 * STA is not in a state to deauthenticate with
2860 * peer. Log error and send response to host.
2861 */
2862 lim_log(mac_ctx, LOGE, FL(
2863 "received unexp SME_DEAUTH_REQ in state %X"),
2864 session_entry->limSmeState);
2865 lim_print_sme_state(mac_ctx, LOGE,
2866 session_entry->limSmeState);
2867
2868 if (mac_ctx->lim.gLimRspReqd) {
2869 mac_ctx->lim.gLimRspReqd = false;
2870
2871 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2872 deauth_trigger = eLIM_HOST_DEAUTH;
2873
2874 /*
2875 * here we received deauth request from AP so sme state
2876 * is eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED
2877 * delSta then mlm state should be
2878 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got delBSS
2879 * rsp then mlm state should be eLIM_MLM_IDLE_STATE
2880 * so the below condition captures the state where
2881 * delSta not done and firmware still in
2882 * connected state.
2883 */
2884 if (session_entry->limSmeState ==
2885 eLIM_SME_WT_DEAUTH_STATE &&
2886 session_entry->limMlmState !=
2887 eLIM_MLM_IDLE_STATE &&
2888 session_entry->limMlmState !=
2889 eLIM_MLM_WT_DEL_STA_RSP_STATE)
2890 ret_code = eSIR_SME_DEAUTH_STATUS;
2891 goto send_deauth;
2892 }
2893 return;
2894 }
2895 break;
2896
2897 case eLIM_STA_IN_IBSS_ROLE:
2898 lim_log(mac_ctx, LOGE, FL("Deauth not allowed in IBSS"));
2899 if (mac_ctx->lim.gLimRspReqd) {
2900 mac_ctx->lim.gLimRspReqd = false;
2901 ret_code = eSIR_SME_INVALID_PARAMETERS;
2902 deauth_trigger = eLIM_HOST_DEAUTH;
2903 goto send_deauth;
2904 }
2905 return;
2906 case eLIM_AP_ROLE:
2907 break;
2908 default:
2909 lim_log(mac_ctx, LOGE,
2910 FL("received unexpected SME_DEAUTH_REQ for role %X"),
2911 GET_LIM_SYSTEM_ROLE(session_entry));
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 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2920
2921 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2922 /* Deauthentication is triggered by Link Monitoring */
2923 lim_log(mac_ctx, LOG1, FL("** Lost link with AP **"));
2924 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2925 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2926 } else {
2927 deauth_trigger = eLIM_HOST_DEAUTH;
2928 reason_code = sme_deauth_req.reasonCode;
2929 }
2930
2931 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302932 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002933 if (NULL == mlm_deauth_req) {
2934 lim_log(mac_ctx, LOGP,
2935 FL("call to AllocateMemory failed for mlmDeauthReq"));
2936 if (mac_ctx->lim.gLimRspReqd) {
2937 mac_ctx->lim.gLimRspReqd = false;
2938 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2939 deauth_trigger = eLIM_HOST_DEAUTH;
2940 goto send_deauth;
2941 }
2942 return;
2943 }
2944
Anurag Chouhanc5548422016-02-24 18:33:27 +05302945 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002946 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002947
2948 mlm_deauth_req->reasonCode = reason_code;
2949 mlm_deauth_req->deauthTrigger = deauth_trigger;
2950
2951 /* Update PE session Id */
2952 mlm_deauth_req->sessionId = session_id;
2953
2954 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2955 (uint32_t *)mlm_deauth_req);
2956 return;
2957
2958send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002959 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2960 ret_code, deauth_trigger, 1,
2961 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002962}
2963
2964/**
2965 * __lim_process_sme_set_context_req()
2966 *
2967 * @mac_ctx: Pointer to Global MAC structure
2968 * @msg_buf: pointer to the SME message buffer
2969 *
2970 * This function is called to process SME_SETCONTEXT_REQ message
2971 * from HDD or upper layer application.
2972 *
2973 * Return: None
2974 */
2975
2976static void
2977__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2978{
2979 tpSirSmeSetContextReq set_context_req;
2980 tLimMlmSetKeysReq *mlm_set_key_req;
2981 tpPESession session_entry;
2982 uint8_t session_id; /* PE sessionID */
2983 uint8_t sme_session_id;
2984 uint16_t sme_transaction_id;
2985
2986 lim_log(mac_ctx, LOG1, FL("received SETCONTEXT_REQ message"));
2987
2988 if (msg_buf == NULL) {
2989 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
2990 return;
2991 }
2992
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302993 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002994 if (NULL == set_context_req) {
2995 lim_log(mac_ctx, LOGP, FL(
2996 "call to AllocateMemory failed for set_context_req"));
2997 return;
2998 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302999 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003000 sizeof(struct sSirSmeSetContextReq));
3001 sme_session_id = set_context_req->sessionId;
3002 sme_transaction_id = set_context_req->transactionId;
3003
3004 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
3005 lim_log(mac_ctx, LOGW,
3006 FL("received invalid SME_SETCONTEXT_REQ message"));
3007 goto end;
3008 }
3009
3010 if (set_context_req->keyMaterial.numKeys >
3011 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3012 lim_log(mac_ctx, LOGE, FL(
3013 "numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS"),
3014 set_context_req->keyMaterial.numKeys);
3015 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003016 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003017 eSIR_SME_INVALID_PARAMETERS, NULL,
3018 sme_session_id, sme_transaction_id);
3019 goto end;
3020 }
3021
3022 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003023 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003024 if (session_entry == NULL) {
3025 lim_log(mac_ctx, LOGW,
3026 FL("Session does not exist for given BSSID"));
3027 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003028 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003029 eSIR_SME_INVALID_PARAMETERS, NULL,
3030 sme_session_id, sme_transaction_id);
3031 goto end;
3032 }
3033#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3034 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
3035 session_entry, 0, 0);
3036#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3037
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003038 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003039 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3040 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003041 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003042 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
3043 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303044 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003045 if (NULL == mlm_set_key_req) {
3046 lim_log(mac_ctx, LOGP, FL(
3047 "mem alloc failed for mlmSetKeysReq"));
3048 goto end;
3049 }
3050 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
3051 mlm_set_key_req->numKeys =
3052 set_context_req->keyMaterial.numKeys;
3053 if (mlm_set_key_req->numKeys >
3054 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3055 lim_log(mac_ctx, LOGP, FL(
3056 "no.of keys exceeded max num of default keys limit"));
3057 goto end;
3058 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05303059 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003060 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003061
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303062 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003063 (uint8_t *) &set_context_req->keyMaterial.key,
3064 sizeof(tSirKeys) *
3065 (mlm_set_key_req->numKeys ? mlm_set_key_req->
3066 numKeys : 1));
3067
3068 mlm_set_key_req->sessionId = session_id;
3069 mlm_set_key_req->smesessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003070 lim_log(mac_ctx, LOG1, FL(
3071 "received SETCONTEXT_REQ message sessionId=%d"),
3072 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003073
3074 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
3075 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
3076 LIM_IS_AP_ROLE(session_entry)) {
3077 if (set_context_req->keyMaterial.key[0].keyLength) {
3078 uint8_t key_id;
3079 key_id =
3080 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303081 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003082 &session_entry->WEPKeyMaterial[key_id],
3083 (uint8_t *) &set_context_req->keyMaterial,
3084 sizeof(tSirKeyMaterial));
3085 } else {
3086 uint32_t i;
3087 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
3088 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303089 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003090 &mlm_set_key_req->key[i],
3091 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
3092 sizeof(tSirKeys));
3093 }
3094 }
3095 }
3096 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
3097 (uint32_t *) mlm_set_key_req);
3098 } else {
3099 lim_log(mac_ctx, LOGE, FL(
3100 "rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
3101 GET_LIM_SYSTEM_ROLE(session_entry),
3102 session_entry->limSmeState);
3103 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
3104
3105 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003106 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003107 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
3108 session_entry, sme_session_id,
3109 sme_transaction_id);
3110 }
3111end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303112 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003113 return;
3114}
3115
3116/**
3117 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
3118 *
3119 * @mac_ctx: Pointer to Global MAC structure
3120 * @msg_buf: pointer to the SME message buffer
3121 *
3122 * This function is called to process SME_GET_ASSOC_STAS_REQ message
3123 * from HDD or upper layer application.
3124 *
3125 * Return: None
3126 */
3127
3128void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
3129 uint32_t *msg_buf)
3130{
3131 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3132 tpDphHashNode sta_ds = NULL;
3133 tpPESession session_entry = NULL;
3134 tSap_Event sap_event;
3135 tpWLAN_SAPEventCB sap_event_cb = NULL;
3136 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3137 uint8_t session_id = CSR_SESSION_ID_INVALID;
3138 uint8_t assoc_id = 0;
3139 uint8_t sta_cnt = 0;
3140
3141 if (msg_buf == NULL) {
3142 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3143 return;
3144 }
3145
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303146 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003147 sizeof(struct sSirSmeGetAssocSTAsReq));
3148 /*
3149 * Get Associated stations from PE.
3150 * Find PE session Entry
3151 */
3152 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003153 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003154 &session_id);
3155 if (session_entry == NULL) {
3156 lim_log(mac_ctx, LOGE,
3157 FL("session does not exist for given bssId"));
3158 goto lim_assoc_sta_end;
3159 }
3160
3161 if (!LIM_IS_AP_ROLE(session_entry)) {
3162 lim_log(mac_ctx, LOGE, FL(
3163 "Received unexpected message in state %X, in role %X"),
3164 session_entry->limSmeState,
3165 GET_LIM_SYSTEM_ROLE(session_entry));
3166 goto lim_assoc_sta_end;
3167 }
3168 /* Retrieve values obtained in the request message */
3169 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3170 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3171
3172 if (NULL == assoc_sta_tmp)
3173 goto lim_assoc_sta_end;
3174 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3175 assoc_id++) {
3176 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3177 &session_entry->dph.dphHashTable);
3178 if (NULL == sta_ds)
3179 continue;
3180 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303181 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003182 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303183 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003184 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3185 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3186
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303187 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003188 (uint8_t *)&sta_ds->supportedRates,
3189 sizeof(tSirSupportedRates));
3190 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3191 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3192 assoc_sta_tmp->Support40Mhz =
3193 sta_ds->htDsssCckRate40MHzSupport;
3194
3195 lim_log(mac_ctx, LOG1, FL("dph Station Number = %d"),
3196 sta_cnt + 1);
3197 lim_log(mac_ctx, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3198 MAC_ADDR_ARRAY(sta_ds->staAddr));
3199 lim_log(mac_ctx, LOG1, FL("Association Id = %d"),
3200 sta_ds->assocId);
3201 lim_log(mac_ctx, LOG1, FL("Station Index = %d"),
3202 sta_ds->staIndex);
3203 assoc_sta_tmp++;
3204 sta_cnt++;
3205 }
3206 }
3207lim_assoc_sta_end:
3208 /*
3209 * Call hdd callback with sap event to send the list of
3210 * associated stations from PE
3211 */
3212 if (sap_event_cb != NULL) {
3213 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3214 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303215 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003216 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3217 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3218 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3219 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3220 }
3221}
3222
3223/**
3224 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3225 *
3226 * @mac_ctx: Pointer to Global MAC structure
3227 * @msg_buf: pointer to WPS PBC overlap query message
3228 *
3229 * This function parses get WPS PBC overlap information
3230 * message and call callback to pass WPS PBC overlap
3231 * information back to hdd.
3232 *
3233 * Return: None
3234 */
3235void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3236 uint32_t *msg_buf)
3237{
3238 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3239 tpPESession session_entry = NULL;
3240 tSap_Event sap_event;
3241 tpWLAN_SAPEventCB sap_event_cb = NULL;
3242 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003243 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3244
3245 if (msg_buf == NULL) {
3246 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3247 return;
3248 }
3249
3250 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303251 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003252
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303253 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003254 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3255 /*
3256 * Get Associated stations from PE
3257 * Find PE session Entry
3258 */
3259 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003260 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003261 if (session_entry == NULL) {
3262 lim_log(mac_ctx, LOGE,
3263 FL("session does not exist for given bssId"));
3264 goto lim_get_wpspbc_sessions_end;
3265 }
3266
3267 if (!LIM_IS_AP_ROLE(session_entry)) {
3268 lim_log(mac_ctx, LOGE,
3269 FL("Received unexpected message in role %X"),
3270 GET_LIM_SYSTEM_ROLE(session_entry));
3271 goto lim_get_wpspbc_sessions_end;
3272 }
3273 /*
3274 * Call hdd callback with sap event to send the
3275 * WPS PBC overlap information
3276 */
3277 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303278 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003279
Anurag Chouhanc5548422016-02-24 18:33:27 +05303280 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003281 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003282 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003283 sap_get_wpspbc_event->UUID_E,
3284 &sap_get_wpspbc_event->wpsPBCOverlap,
3285 session_entry);
3286 } else {
3287 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003288 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003289 session_entry);
3290 /* don't have to inform the HDD/Host */
3291 return;
3292 }
3293
3294 lim_log(mac_ctx, LOGE, FL("wpsPBCOverlap %d"),
3295 sap_get_wpspbc_event->wpsPBCOverlap);
3296 lim_print_mac_addr(mac_ctx,
3297 sap_get_wpspbc_event->addr.bytes, LOG4);
3298
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303299 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003300
3301lim_get_wpspbc_sessions_end:
3302 sap_event_cb =
3303 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3304 if (NULL != sap_event_cb)
3305 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3306}
3307
3308/**
3309 * __lim_counter_measures()
3310 *
3311 * FUNCTION:
3312 * This function is called to "implement" MIC counter measure
3313 * and is *temporary* only
3314 *
3315 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3316 * we don't do the proper STA disassoc sequence since the
3317 * BSS will be stoped anyway
3318 *
3319 ***ASSUMPTIONS:
3320 *
3321 ***NOTE:
3322 *
3323 * @param pMac Pointer to Global MAC structure
3324 * @return None
3325 */
3326
3327static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3328{
3329 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003330 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003331 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3332 mac, psessionEntry, false);
3333};
3334
3335void lim_process_tkip_counter_measures(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3336{
3337 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3338 tpPESession psessionEntry;
3339 uint8_t sessionId; /* PE sessionId */
3340
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303341 qdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003342 sizeof(struct sSirSmeTkipCntrMeasReq));
3343
3344 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003345 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003346 if (NULL == psessionEntry) {
3347 lim_log(pMac, LOGE,
3348 FL("session does not exist for given BSSID "));
3349 return;
3350 }
3351
3352 if (tkipCntrMeasReq.bEnable)
3353 __lim_counter_measures(pMac, psessionEntry);
3354
3355 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3356}
3357
3358static void
3359__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3360{
3361 tSirSmeStopBssReq stopBssReq;
3362 tSirRetStatus status;
3363 tLimSmeStates prevState;
3364 tpPESession psessionEntry;
3365 uint8_t smesessionId;
3366 uint8_t sessionId;
3367 uint16_t smetransactionId;
3368 uint8_t i = 0;
3369 tpDphHashNode pStaDs = NULL;
3370
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303371 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003372 smesessionId = stopBssReq.sessionId;
3373 smetransactionId = stopBssReq.transactionId;
3374
3375 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
3376 PELOGW(lim_log(pMac, LOGW,
3377 FL("received invalid SME_STOP_BSS_REQ message"));)
3378 /* Send Stop BSS response to host */
3379 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3380 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3381 smetransactionId);
3382 return;
3383 }
3384
3385 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003386 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003387 &sessionId);
3388 if (psessionEntry == NULL) {
3389 lim_log(pMac, LOGW,
3390 FL("session does not exist for given BSSID "));
3391 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3392 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3393 smetransactionId);
3394 return;
3395 }
3396#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3397 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3398 0, 0);
3399#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3400
3401 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3402 LIM_IS_STA_ROLE(psessionEntry)) {
3403 /**
3404 * Should not have received STOP_BSS_REQ in states
3405 * other than 'normal' state or on STA in Infrastructure
3406 * mode. Log error and return response to host.
3407 */
3408 lim_log(pMac, LOGE,
3409 FL
3410 ("received unexpected SME_STOP_BSS_REQ in state %X, for role %d"),
3411 psessionEntry->limSmeState,
3412 GET_LIM_SYSTEM_ROLE(psessionEntry));
3413 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3414 /* / Send Stop BSS response to host */
3415 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3416 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3417 smetransactionId);
3418 return;
3419 }
3420
3421 if (LIM_IS_AP_ROLE(psessionEntry))
3422 lim_wpspbc_close(pMac, psessionEntry);
3423
3424 lim_log(pMac, LOGW,
3425 FL("RECEIVED STOP_BSS_REQ with reason code=%d"),
3426 stopBssReq.reasonCode);
3427
3428 prevState = psessionEntry->limSmeState;
3429
3430 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3431 MTRACE(mac_trace
3432 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3433 psessionEntry->limSmeState));
3434
3435 /* Update SME session Id and Transaction Id */
3436 psessionEntry->smeSessionId = smesessionId;
3437 psessionEntry->transactionId = smetransactionId;
3438
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003439 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3440 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3441 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003442 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3443 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3444 /* Send disassoc all stations associated thru TKIP */
3445 __lim_counter_measures(pMac, psessionEntry);
3446 else
3447 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003448 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3449 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003450 }
3451
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003452 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3453 /* Free the buffer allocated in START_BSS_REQ */
3454 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3455 psessionEntry->addIeParams.probeRespDataLen = 0;
3456 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003457
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003458 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3459 psessionEntry->addIeParams.assocRespDataLen = 0;
3460 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003461
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003462 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3463 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3464 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003465
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003466 /*
3467 * lim_del_bss is also called as part of coalescing,
3468 * when we send DEL BSS followed by Add Bss msg.
3469 */
3470 pMac->lim.gLimIbssCoalescingHappened = false;
3471 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003472 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3473 pStaDs =
3474 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3475 if (NULL == pStaDs)
3476 continue;
3477 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3478 if (eSIR_SUCCESS == status) {
3479 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3480 pStaDs->assocId, psessionEntry);
3481 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3482 } else {
3483 lim_log(pMac, LOGE,
3484 FL("lim_del_sta failed with Status : %d"), status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303485 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003486 }
3487 }
3488 /* send a delBss to HAL and wait for a response */
3489 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3490
3491 if (status != eSIR_SUCCESS) {
3492 PELOGE(lim_log
3493 (pMac, LOGE, FL("delBss failed for bss %d"),
3494 psessionEntry->bssIdx);
3495 )
3496 psessionEntry->limSmeState = prevState;
3497
3498 MTRACE(mac_trace
3499 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3500 psessionEntry->limSmeState));
3501
3502 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3503 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3504 smetransactionId);
3505 }
3506}
3507
3508/**
3509 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3510 * @pMac: Global MAC context
3511 * @pMsg: Message from SME
3512 *
3513 * Wrapper for the function __lim_handle_sme_stop_bss_request
3514 * This message will be defered until softmac come out of
3515 * scan mode. Message should be handled even if we have
3516 * detected radar in the current operating channel.
3517 *
3518 * Return: true - If we consumed the buffer
3519 * false - If have defered the message.
3520 */
3521
3522static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3523{
3524 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3525 /**
3526 * If message defered, buffer is not consumed yet.
3527 * So return false
3528 */
3529 return false;
3530 }
3531 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3532 return true;
3533} /*** end __lim_process_sme_stop_bss_req() ***/
3534
3535void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3536 uint32_t body, tpPESession psessionEntry)
3537{
3538
3539 (void)body;
3540 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3541 lim_ibss_delete(pMac, psessionEntry);
3542 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3543 lim_delete_pre_auth_list(pMac);
3544 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3545 psessionEntry->smeSessionId,
3546 psessionEntry->transactionId);
3547 return;
3548}
3549
3550/**
3551 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3552 *
3553 * @mac_ctx: pointer to mac context
3554 * @msg_type: message type
3555 * @msg_buf: pointer to the SME message buffer
3556 *
3557 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3558 * in BTAMP AP.
3559 *
3560 * Return: None
3561 */
3562
3563void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3564 uint32_t *msg_buf)
3565{
3566 tSirSmeAssocCnf assoc_cnf;
3567 tpDphHashNode sta_ds = NULL;
3568 tpPESession session_entry = NULL;
3569 uint8_t session_id;
3570 tpSirAssocReq assoc_req;
3571
3572 if (msg_buf == NULL) {
3573 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL "));
3574 goto end;
3575 }
3576
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303577 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003578 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
3579 lim_log(mac_ctx, LOGE,
3580 FL("Received invalid SME_RE(ASSOC)_CNF message "));
3581 goto end;
3582 }
3583
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003584 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003585 &session_id);
3586 if (session_entry == NULL) {
3587 lim_log(mac_ctx, LOGE,
3588 FL("session does not exist for given bssId"));
3589 goto end;
3590 }
3591
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003592 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003593 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3594 (session_entry->limSmeState !=
3595 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
3596 lim_log(mac_ctx, LOGE, FL(
3597 "Rcvd unexpected msg %X in state %X, in role %X"),
3598 msg_type, session_entry->limSmeState,
3599 GET_LIM_SYSTEM_ROLE(session_entry));
3600 goto end;
3601 }
3602 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3603 &session_entry->dph.dphHashTable);
3604 if (sta_ds == NULL) {
3605 lim_log(mac_ctx, LOGE, FL(
3606 "Rcvd invalid msg %X due to no STA ctx, aid %d, peer "),
3607 msg_type, assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003608 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003609
3610 /*
3611 * send a DISASSOC_IND message to WSM to make sure
3612 * the state in WSM and LIM is the same
3613 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003614 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003615 eSIR_SME_STA_NOT_ASSOCIATED,
3616 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3617 session_entry->smeSessionId,
3618 session_entry->transactionId,
3619 session_entry);
3620 goto end;
3621 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303622 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003623 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303624 QDF_MAC_ADDR_SIZE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003625 lim_log(mac_ctx, LOG1, FL(
3626 "peerMacAddr mismatched for aid %d, peer "),
3627 assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003628 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003629 goto end;
3630 }
3631
3632 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3633 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3634 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3635 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3636 (msg_type != eWNI_SME_ASSOC_CNF))) {
3637 lim_log(mac_ctx, LOG1, FL(
3638 "not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3639 "StaD mlmState : %d"),
3640 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
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 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3646 * has been received
3647 */
3648 lim_log(mac_ctx, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
3649 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3650 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3651
3652 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3653 /*
3654 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3655 * when it had received Assoc Request frame. Now, PE just needs
3656 * to send association rsp frame to the requesting BTAMP-STA.
3657 */
3658 sta_ds->mlmStaContext.mlmState =
3659 eLIM_MLM_LINK_ESTABLISHED_STATE;
3660 lim_log(mac_ctx, LOG1,
3661 FL("sending Assoc Rsp frame to STA (assoc id=%d) "),
3662 sta_ds->assocId);
3663 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3664 sta_ds->assocId, sta_ds->staAddr,
3665 sta_ds->mlmStaContext.subType, sta_ds,
3666 session_entry);
3667 goto end;
3668 } else {
3669 /*
3670 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3671 * to be associated since the HAL sta entry is created for
3672 * denied STA we need to remove this HAL entry.
3673 * So to do that set updateContext to 1
3674 */
3675 if (!sta_ds->mlmStaContext.updateContext)
3676 sta_ds->mlmStaContext.updateContext = 1;
3677 lim_log(mac_ctx, LOG1,
3678 FL("Recv Assoc Cnf, status Code : %d(assoc id=%d) "),
3679 assoc_cnf.statusCode, sta_ds->assocId);
3680 lim_reject_association(mac_ctx, sta_ds->staAddr,
3681 sta_ds->mlmStaContext.subType,
3682 true, sta_ds->mlmStaContext.authType,
3683 sta_ds->assocId, true,
3684 eSIR_MAC_UNSPEC_FAILURE_STATUS,
3685 session_entry);
3686 }
3687end:
3688 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3689 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3690 assoc_req = (tpSirAssocReq)
3691 session_entry->parsedAssocReq[sta_ds->assocId];
3692 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303693 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003694 assoc_req->assocReqFrame = NULL;
3695 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303696 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003697 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3698 }
3699}
3700
3701static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3702{
3703 tpDphHashNode pStaDs;
3704 tSirMacAddr peerMac;
3705 tpSirAddtsReq pSirAddts;
3706 uint32_t timeout;
3707 tpPESession psessionEntry;
3708 uint8_t sessionId; /* PE sessionId */
3709 uint8_t smesessionId;
3710 uint16_t smetransactionId;
3711
3712 if (pMsgBuf == NULL) {
3713 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
3714 return;
3715 }
3716
3717 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3718 &smetransactionId);
3719
3720 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3721
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003722 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3723 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003724 if (psessionEntry == NULL) {
3725 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3726 return;
3727 }
3728#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3729 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3730 0);
3731#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3732
3733 /* if sta
3734 * - verify assoc state
3735 * - send addts request to ap
3736 * - wait for addts response from ap
3737 * if ap, just ignore with error log
3738 */
3739 PELOG1(lim_log(pMac, LOG1,
3740 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
3741 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3742 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
3743 )
3744
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003745 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003746 PELOGE(lim_log(pMac, LOGE, "AddTs received on AP - ignoring");)
3747 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3748 psessionEntry, pSirAddts->req.tspec,
3749 smesessionId, smetransactionId);
3750 return;
3751 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003752
3753 pStaDs =
3754 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3755 &psessionEntry->dph.dphHashTable);
3756
3757 if (pStaDs == NULL) {
3758 PELOGE(lim_log
3759 (pMac, LOGE, "Cannot find AP context for addts req");
3760 )
3761 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3762 psessionEntry, pSirAddts->req.tspec,
3763 smesessionId, smetransactionId);
3764 return;
3765 }
3766
3767 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3768 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
3769 lim_log(pMac, LOGE, "AddTs received in invalid MLM state");
3770 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3771 psessionEntry, pSirAddts->req.tspec,
3772 smesessionId, smetransactionId);
3773 return;
3774 }
3775
3776 pSirAddts->req.wsmTspecPresent = 0;
3777 pSirAddts->req.wmeTspecPresent = 0;
3778 pSirAddts->req.lleTspecPresent = 0;
3779
3780 if ((pStaDs->wsmEnabled) &&
3781 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3782 SIR_MAC_ACCESSPOLICY_EDCA))
3783 pSirAddts->req.wsmTspecPresent = 1;
3784 else if (pStaDs->wmeEnabled)
3785 pSirAddts->req.wmeTspecPresent = 1;
3786 else if (pStaDs->lleEnabled)
3787 pSirAddts->req.lleTspecPresent = 1;
3788 else {
3789 PELOGW(lim_log
3790 (pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));
3791 )
3792 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3793 psessionEntry, pSirAddts->req.tspec,
3794 smesessionId, smetransactionId);
3795 return;
3796 }
3797
3798 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3799 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
3800 lim_log(pMac, LOGE,
3801 "AddTs received in invalid LIMsme state (%d)",
3802 psessionEntry->limSmeState);
3803 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3804 psessionEntry, pSirAddts->req.tspec,
3805 smesessionId, smetransactionId);
3806 return;
3807 }
3808
3809 if (pMac->lim.gLimAddtsSent) {
3810 lim_log(pMac, LOGE,
3811 "Addts (token %d, tsid %d, up %d) is still pending",
3812 pMac->lim.gLimAddtsReq.req.dialogToken,
3813 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3814 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3815 userPrio);
3816 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3817 psessionEntry, pSirAddts->req.tspec,
3818 smesessionId, smetransactionId);
3819 return;
3820 }
3821
3822 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3823
3824 /* save the addts request */
3825 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303826 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003827 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3828
3829 /* ship out the message now */
3830 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3831 psessionEntry);
3832 PELOG1(lim_log(pMac, LOG1, "Sent ADDTS request");)
3833 /* start a timer to wait for the response */
3834 if (pSirAddts->timeout)
3835 timeout = pSirAddts->timeout;
3836 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3837 eSIR_SUCCESS) {
3838 lim_log(pMac, LOGP,
3839 FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
3840 WNI_CFG_ADDTS_RSP_TIMEOUT);
3841 return;
3842 }
3843
3844 timeout = SYS_MS_TO_TICKS(timeout);
3845 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3846 != TX_SUCCESS) {
3847 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3848 return;
3849 }
3850 pMac->lim.gLimAddtsRspTimerCount++;
3851 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3852 pMac->lim.gLimAddtsRspTimerCount) !=
3853 TX_SUCCESS) {
3854 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3855 return;
3856 }
3857 MTRACE(mac_trace
3858 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3859 eLIM_ADDTS_RSP_TIMER));
3860
3861 /* add the sessionId to the timer object */
3862 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3863 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3864 TX_SUCCESS) {
3865 lim_log(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
3866 return;
3867 }
3868 return;
3869}
3870
3871static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3872{
3873 tSirMacAddr peerMacAddr;
3874 uint8_t ac;
3875 tSirMacTSInfo *pTsinfo;
3876 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3877 tpDphHashNode pStaDs = NULL;
3878 tpPESession psessionEntry;
3879 uint8_t sessionId;
3880 uint32_t status = eSIR_SUCCESS;
3881 uint8_t smesessionId;
3882 uint16_t smetransactionId;
3883
3884 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3885 &smetransactionId);
3886
3887 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003888 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003889 &sessionId);
3890 if (psessionEntry == NULL) {
3891 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3892 status = eSIR_FAILURE;
3893 goto end;
3894 }
3895#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3896 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3897 0);
3898#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3899
3900 if (eSIR_SUCCESS !=
3901 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
3902 PELOGE(lim_log(pMac, LOGE, FL("lim_validate_delts_req failed"));)
3903 status = eSIR_FAILURE;
3904 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3905 smesessionId, smetransactionId);
3906 return;
3907 }
3908
3909 lim_log(pMac, LOG1,
3910 FL("Sent DELTS request to station with assocId = %d MacAddr = "
3911 MAC_ADDRESS_STR),
3912 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3913
3914 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3915 pDeltsReq->req.wmeTspecPresent,
3916 &pDeltsReq->req.tsinfo,
3917 &pDeltsReq->req.tspec, psessionEntry);
3918
3919 pTsinfo =
3920 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3921 tsinfo : &pDeltsReq->req.tsinfo;
3922
3923 /* We've successfully send DELTS frame to AP. Update the
3924 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3925 * is no longer trigger enabled or delivery enabled
3926 */
3927 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3928 pTsinfo, CLEAR_UAPSD_MASK);
3929
3930 /* We're deleting the TSPEC, so this particular AC is no longer
3931 * admitted. PE needs to downgrade the EDCA
3932 * parameters(for the AC for which TS is being deleted) to the
3933 * next best AC for which ACM is not enabled, and send the
3934 * updated values to HAL.
3935 */
3936 ac = upToAc(pTsinfo->traffic.userPrio);
3937
3938 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3939 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3940 ~(1 << ac);
3941 } else if (pTsinfo->traffic.direction ==
3942 SIR_MAC_DIRECTION_DNLINK) {
3943 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3944 ~(1 << ac);
3945 } else if (pTsinfo->traffic.direction ==
3946 SIR_MAC_DIRECTION_BIDIR) {
3947 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3948 ~(1 << ac);
3949 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3950 ~(1 << ac);
3951 }
3952
3953 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3954 psessionEntry);
3955
3956 pStaDs =
3957 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3958 &psessionEntry->dph.dphHashTable);
3959 if (pStaDs != NULL) {
3960 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3961 pStaDs->bssId);
3962 status = eSIR_SUCCESS;
3963 } else {
3964 lim_log(pMac, LOGE, FL("Self entry missing in Hash Table "));
3965 status = eSIR_FAILURE;
3966 }
3967#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003968 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003969#endif
3970
3971 /* send an sme response back */
3972end:
3973 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3974 smesessionId, smetransactionId);
3975}
3976
3977void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
3978{
3979 /* fetch the sessionEntry based on the sessionId */
3980 tpPESession psessionEntry;
3981 psessionEntry = pe_find_session_by_session_id(pMac,
3982 pMac->lim.limTimers.gLimAddtsRspTimer.
3983 sessionId);
3984 if (psessionEntry == NULL) {
3985 lim_log(pMac, LOGP,
3986 FL("Session Does not exist for given sessionID"));
3987 return;
3988 }
3989
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003990 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003991 lim_log(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)",
3992 GET_LIM_SYSTEM_ROLE(psessionEntry));
3993 pMac->lim.gLimAddtsSent = false;
3994 return;
3995 }
3996
3997 if (!pMac->lim.gLimAddtsSent) {
3998 lim_log(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");
3999 return;
4000 }
4001
4002 if (param != pMac->lim.gLimAddtsRspTimerCount) {
4003 lim_log(pMac, LOGE,
4004 FL("Invalid AddtsRsp Timer count %d (exp %d)"), param,
4005 pMac->lim.gLimAddtsRspTimerCount);
4006 return;
4007 }
4008 /* this a real response timeout */
4009 pMac->lim.gLimAddtsSent = false;
4010 pMac->lim.gLimAddtsRspTimerCount++;
4011
4012 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
4013 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
4014 psessionEntry->smeSessionId,
4015 psessionEntry->transactionId);
4016}
4017
4018/**
4019 * __lim_process_sme_get_statistics_request()
4020 *
4021 ***FUNCTION:
4022 *
4023 *
4024 ***NOTE:
4025 *
4026 * @param pMac Pointer to Global MAC structure
4027 * @param *pMsgBuf A pointer to the SME message buffer
4028 * @return None
4029 */
4030static void
4031__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4032{
4033 tpAniGetPEStatsReq pPEStatsReq;
4034 tSirMsgQ msgQ;
4035
4036 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4037
4038 msgQ.type = WMA_GET_STATISTICS_REQ;
4039
4040 msgQ.reserved = 0;
4041 msgQ.bodyptr = pMsgBuf;
4042 msgQ.bodyval = 0;
4043 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4044
4045 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304046 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004047 pMsgBuf = NULL;
4048 lim_log(pMac, LOGP, "Unable to forward request");
4049 return;
4050 }
4051
4052 return;
4053}
4054
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004055#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004056/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004057 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004058 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004059 * @pMac: Pointer to Global MAC structure
4060 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004061 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004062 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004063 */
4064static void
4065__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4066{
4067 tSirMsgQ msgQ;
4068
4069 msgQ.type = WMA_TSM_STATS_REQ;
4070 msgQ.reserved = 0;
4071 msgQ.bodyptr = pMsgBuf;
4072 msgQ.bodyval = 0;
4073 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4074
4075 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304076 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004077 pMsgBuf = NULL;
4078 lim_log(pMac, LOGP, "Unable to forward request");
4079 return;
4080 }
4081}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004082#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004083
4084static void
4085__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4086{
4087 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4088 tpPESession psessionEntry;
4089 uint8_t sessionId; /* PE sessionID */
4090
4091 PELOG1(lim_log(pMac, LOG1, FL("received UPDATE_APWPSIEs_REQ message")););
4092
4093 if (pMsgBuf == NULL) {
4094 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4095 return;
4096 }
4097
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304098 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004099 if (NULL == pUpdateAPWPSIEsReq) {
4100 lim_log(pMac, LOGP,
4101 FL
4102 ("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
4103 return;
4104 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304105 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004106 sizeof(struct sSirUpdateAPWPSIEsReq));
4107
4108 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08004109 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004110 &sessionId);
4111 if (psessionEntry == NULL) {
4112 lim_log(pMac, LOGW,
4113 FL("Session does not exist for given BSSID"));
4114 goto end;
4115 }
4116
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304117 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004118 sizeof(tSirAPWPSIEs));
4119
4120 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4121 lim_send_beacon_ind(pMac, psessionEntry);
4122
4123end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304124 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004125 return;
4126}
4127
4128void
4129lim_send_vdev_restart(tpAniSirGlobal pMac,
4130 tpPESession psessionEntry, uint8_t sessionId)
4131{
4132 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
4133 tSirMsgQ msgQ;
4134 tSirRetStatus retCode = eSIR_SUCCESS;
4135
4136 if (psessionEntry == NULL) {
4137 PELOGE(lim_log
4138 (pMac, LOGE, "%s:%d: Invalid parameters", __func__,
4139 __LINE__);
4140 )
4141 return;
4142 }
4143
4144 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304145 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004146 if (NULL == pHalHiddenSsidVdevRestart) {
4147 PELOGE(lim_log
4148 (pMac, LOGE, "%s:%d: Unable to allocate memory",
4149 __func__, __LINE__);
4150 )
4151 return;
4152 }
4153
4154 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4155 pHalHiddenSsidVdevRestart->sessionId = sessionId;
4156
4157 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4158 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4159 msgQ.bodyval = 0;
4160
4161 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4162 if (eSIR_SUCCESS != retCode) {
4163 PELOGE(lim_log
4164 (pMac, LOGE, "%s:%d: wma_post_ctrl_msg() failed", __func__,
4165 __LINE__);
4166 )
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304167 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004168 }
4169}
4170
4171static void __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4172{
4173 tpSirUpdateParams pUpdateParams;
4174 tpPESession psessionEntry;
4175
4176 PELOG1(lim_log(pMac, LOG1, FL("received HIDE_SSID message")););
4177
4178 if (pMsgBuf == NULL) {
4179 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4180 return;
4181 }
4182
4183 pUpdateParams = (tpSirUpdateParams) pMsgBuf;
4184
Naveen Rawat9e4872a2015-11-13 09:43:11 -08004185 psessionEntry = pe_find_session_by_sme_session_id(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004186 pUpdateParams->sessionId);
4187 if (psessionEntry == NULL) {
4188 lim_log(pMac, LOGW,
4189 "Session does not exist for given sessionId %d",
4190 pUpdateParams->sessionId);
4191 return;
4192 }
4193
4194 /* Update the session entry */
4195 psessionEntry->ssidHidden = pUpdateParams->ssidHidden;
4196
4197 /* Send vdev restart */
4198 lim_send_vdev_restart(pMac, psessionEntry, pUpdateParams->sessionId);
4199
4200 /* Update beacon */
4201 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4202 lim_send_beacon_ind(pMac, psessionEntry);
4203
4204 return;
4205} /*** end __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4206
4207static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4208{
4209 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4210 tpPESession psessionEntry;
4211 uint8_t sessionId; /* PE sessionID */
4212
4213 if (pMsgBuf == NULL) {
4214 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4215 return;
4216 }
4217
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304218 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004219 if (NULL == pUpdateAPWPARSNIEsReq) {
4220 lim_log(pMac, LOGP,
4221 FL
4222 ("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
4223 return;
4224 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304225 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004226 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4227
4228 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004229 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004230 &sessionId);
4231 if (psessionEntry == NULL) {
4232 lim_log(pMac, LOGW,
4233 FL("Session does not exist for given BSSID"));
4234 goto end;
4235 }
4236
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304237 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004238 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4239
4240 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4241 &psessionEntry->
4242 pLimStartBssReq->rsnIE,
4243 psessionEntry);
4244
4245 psessionEntry->pLimStartBssReq->privacy = 1;
4246 psessionEntry->privacy = 1;
4247
4248 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4249 lim_send_beacon_ind(pMac, psessionEntry);
4250
4251end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304252 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004253 return;
4254} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4255
4256/*
4257 Update the beacon Interval dynamically if beaconInterval is different in MCC
4258 */
4259static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4260{
4261 tpSirChangeBIParams pChangeBIParams;
4262 tpPESession psessionEntry;
4263 uint8_t sessionId = 0;
4264 tUpdateBeaconParams beaconParams;
4265
4266 PELOG1(lim_log(pMac, LOG1,
4267 FL("received Update Beacon Interval message"));
4268 );
4269
4270 if (pMsgBuf == NULL) {
4271 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4272 return;
4273 }
4274
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304275 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004276 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4277
4278 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004279 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004280 &sessionId);
4281 if (psessionEntry == NULL) {
4282 lim_log(pMac, LOGE,
4283 FL("Session does not exist for given BSSID"));
4284 return;
4285 }
4286
4287 /*Update sessionEntry Beacon Interval */
4288 if (psessionEntry->beaconParams.beaconInterval !=
4289 pChangeBIParams->beaconInterval) {
4290 psessionEntry->beaconParams.beaconInterval =
4291 pChangeBIParams->beaconInterval;
4292 }
4293
4294 /*Update sch beaconInterval */
4295 if (pMac->sch.schObject.gSchBeaconInterval !=
4296 pChangeBIParams->beaconInterval) {
4297 pMac->sch.schObject.gSchBeaconInterval =
4298 pChangeBIParams->beaconInterval;
4299
4300 PELOG1(lim_log(pMac, LOG1,
4301 FL
4302 ("LIM send update BeaconInterval Indication : %d"),
4303 pChangeBIParams->beaconInterval);
4304 );
4305
4306 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4307 /* Update beacon */
4308 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4309
4310 beaconParams.bssIdx = psessionEntry->bssIdx;
4311 /* Set change in beacon Interval */
4312 beaconParams.beaconInterval =
4313 pChangeBIParams->beaconInterval;
4314 beaconParams.paramChangeBitmap =
4315 PARAM_BCN_INTERVAL_CHANGED;
4316 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4317 }
4318 }
4319
4320 return;
4321} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4322
4323#ifdef QCA_HT_2040_COEX
4324static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4325 uint32_t *pMsgBuf)
4326{
4327 tpSirSetHT2040Mode pSetHT2040Mode;
4328 tpPESession psessionEntry;
4329 uint8_t sessionId = 0;
4330 cds_msg_t msg;
4331 tUpdateVHTOpMode *pHtOpMode = NULL;
4332 uint16_t staId = 0;
4333 tpDphHashNode pStaDs = NULL;
4334
4335 PELOG1(lim_log(pMac, LOG1, FL("received Set HT 20/40 mode message")););
4336 if (pMsgBuf == NULL) {
4337 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4338 return;
4339 }
4340
4341 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4342
4343 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004344 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004345 &sessionId);
4346 if (psessionEntry == NULL) {
4347 lim_log(pMac, LOG1,
4348 FL("Session does not exist for given BSSID "));
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004349 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004350 return;
4351 }
4352
4353 lim_log(pMac, LOG1, FL("Update session entry for cbMod=%d"),
4354 pSetHT2040Mode->cbMode);
4355 /*Update sessionEntry HT related fields */
4356 switch (pSetHT2040Mode->cbMode) {
4357 case PHY_SINGLE_CHANNEL_CENTERED:
4358 psessionEntry->htSecondaryChannelOffset =
4359 PHY_SINGLE_CHANNEL_CENTERED;
4360 psessionEntry->htRecommendedTxWidthSet = 0;
4361 if (pSetHT2040Mode->obssEnabled)
4362 psessionEntry->htSupportedChannelWidthSet
4363 = eHT_CHANNEL_WIDTH_40MHZ;
4364 else
4365 psessionEntry->htSupportedChannelWidthSet
4366 = eHT_CHANNEL_WIDTH_20MHZ;
4367 break;
4368 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4369 psessionEntry->htSecondaryChannelOffset =
4370 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4371 psessionEntry->htRecommendedTxWidthSet = 1;
4372 break;
4373 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4374 psessionEntry->htSecondaryChannelOffset =
4375 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4376 psessionEntry->htRecommendedTxWidthSet = 1;
4377 break;
4378 default:
4379 lim_log(pMac, LOGE, FL("Invalid cbMode"));
4380 return;
4381 }
4382
4383 /* Update beacon */
4384 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4385 lim_send_beacon_ind(pMac, psessionEntry);
4386
4387 /* update OP Mode for each associated peer */
4388 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4389 pStaDs = dph_get_hash_entry(pMac, staId,
4390 &psessionEntry->dph.dphHashTable);
4391 if (NULL == pStaDs)
4392 continue;
4393
4394 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304395 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004396 if (NULL == pHtOpMode) {
4397 lim_log(pMac, LOGE,
4398 FL
4399 ("%s: Not able to allocate memory for setting OP mode"),
4400 __func__);
4401 return;
4402 }
4403 pHtOpMode->opMode =
4404 (psessionEntry->htSecondaryChannelOffset ==
4405 PHY_SINGLE_CHANNEL_CENTERED) ?
4406 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4407 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304408 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004409 sizeof(tSirMacAddr));
4410 pHtOpMode->smesessionId = sessionId;
4411
4412 msg.type = WMA_UPDATE_OP_MODE;
4413 msg.reserved = 0;
4414 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304415 if (!QDF_IS_STATUS_SUCCESS
Anurag Chouhan6d760662016-02-20 16:05:43 +05304416 (cds_mq_post_message(QDF_MODULE_ID_WMA, &msg))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004417 lim_log(pMac, LOGE,
4418 FL
4419 ("%s: Not able to post WMA_UPDATE_OP_MODE message to WMA"),
4420 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304421 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004422 return;
4423 }
4424 lim_log(pMac, LOG1,
4425 FL
4426 ("%s: Notifed FW about OP mode: %d for staId=%d"),
4427 __func__, pHtOpMode->opMode, staId);
4428
4429 } else
4430 lim_log(pMac, LOG1,
4431 FL("%s: station %d does not support HT40\n"),
4432 __func__, staId);
4433 }
4434
4435 return;
4436}
4437#endif
4438
4439/* -------------------------------------------------------------------- */
4440/**
4441 * __lim_process_report_message
4442 *
4443 * FUNCTION: Processes the next received Radio Resource Management message
4444 *
4445 * LOGIC:
4446 *
4447 * ASSUMPTIONS:
4448 *
4449 * NOTE:
4450 *
4451 * @param None
4452 * @return None
4453 */
4454
4455void __lim_process_report_message(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4456{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004457 switch (pMsg->type) {
4458 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4459 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4460 break;
4461 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004462 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004463 break;
4464 default:
4465 lim_log(pMac, LOGE, FL("Invalid msg type:%d"), pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004466 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004467}
4468
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004469/* -------------------------------------------------------------------- */
4470/**
4471 * lim_send_set_max_tx_power_req
4472 *
4473 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4474 *
4475 * LOGIC:
4476 *
4477 * ASSUMPTIONS:
4478 *
4479 * NOTE:
4480 *
4481 * @param txPower txPower to be set.
4482 * @param pSessionEntry session entry.
4483 * @return None
4484 */
4485tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004486lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004487 tpPESession pSessionEntry)
4488{
4489 tpMaxTxPowerParams pMaxTxParams = NULL;
4490 tSirRetStatus retCode = eSIR_SUCCESS;
4491 tSirMsgQ msgQ;
4492
4493 if (pSessionEntry == NULL) {
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304494 lim_log(pMac, LOGE, FL("Inavalid parameters"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004495 return eSIR_FAILURE;
4496 }
4497
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304498 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004499 if (NULL == pMaxTxParams) {
4500 lim_log(pMac, LOGP,
4501 FL("Unable to allocate memory for pMaxTxParams "));
4502 return eSIR_MEM_ALLOC_FAILED;
4503
4504 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004505 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304506 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304507 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304508 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004509 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304510 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004511
4512 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4513 msgQ.bodyptr = pMaxTxParams;
4514 msgQ.bodyval = 0;
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304515 lim_log(pMac, LOG1, FL("Post WMA_SET_MAX_TX_POWER_REQ to WMA"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004516 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4517 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4518 if (eSIR_SUCCESS != retCode) {
4519 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304520 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004521 }
4522 return retCode;
4523}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004524
4525/**
4526 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4527 *
4528 * @mac_ctx: Pointer to Global MAC structure
4529 * @msg_buf: pointer to the SME message buffer
4530 *
4531 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4532 * from SME. It Register this information within PE.
4533 *
4534 * Return: None
4535 */
4536static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4537 uint32_t *msg_buf)
4538{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304539 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004540 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4541 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4542 struct mgmt_frm_reg_info *next = NULL;
4543 bool match = false;
4544
4545 lim_log(mac_ctx, LOG1, FL(
4546 "registerFrame %d, frameType %d, matchLen %d"),
4547 sme_req->registerFrame, sme_req->frameType,
4548 sme_req->matchLen);
4549 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304550 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304551 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4552 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304553 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004554
4555 while (lim_mgmt_regn != NULL) {
4556 if (lim_mgmt_regn->frameType != sme_req->frameType)
4557 goto skip_match;
4558 if (sme_req->matchLen) {
4559 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304560 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004561 sme_req->matchData,
4562 lim_mgmt_regn->matchLen))) {
4563 /* found match! */
4564 match = true;
4565 break;
4566 }
4567 } else {
4568 /* found match! */
4569 match = true;
4570 break;
4571 }
4572skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304573 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304574 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004575 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304576 (qdf_list_node_t *)lim_mgmt_regn,
4577 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304578 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004579 lim_mgmt_regn = next;
4580 next = NULL;
4581 }
4582 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304583 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304584 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004585 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304586 (qdf_list_node_t *)lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304587 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304588 qdf_mem_free(lim_mgmt_regn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004589 }
4590
4591 if (sme_req->registerFrame) {
4592 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304593 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004594 sme_req->matchLen);
4595 if (lim_mgmt_regn != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304596 qdf_mem_set((void *)lim_mgmt_regn,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004597 sizeof(struct mgmt_frm_reg_info) +
4598 sme_req->matchLen, 0);
4599 lim_mgmt_regn->frameType = sme_req->frameType;
4600 lim_mgmt_regn->matchLen = sme_req->matchLen;
4601 lim_mgmt_regn->sessionId = sme_req->sessionId;
4602 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304603 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004604 sme_req->matchData,
4605 sme_req->matchLen);
4606 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304607 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004608 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304609 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004610 gLimMgmtFrameRegistratinQueue,
4611 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304612 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004613 &mac_ctx->lim.lim_frame_register_lock);
4614 }
4615 }
4616 return;
4617}
4618
4619static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4620{
4621 lim_log(pMac, LOG1, FL("Dereg msgType %d"),
4622 pMac->lim.gDeferMsgTypeForNOA);
4623 pMac->lim.gDeferMsgTypeForNOA = 0;
4624 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4625 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304626 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004627 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4628 }
4629}
4630
4631/**
4632 * lim_process_regd_defd_sme_req_after_noa_start()
4633 *
4634 * mac_ctx: Pointer to Global MAC structure
4635 *
4636 * This function is called to process deferred sme req message
4637 * after noa start.
4638 *
4639 * Return: None
4640 */
4641void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4642{
4643 bool buf_consumed = true;
4644
4645 lim_log(mac_ctx, LOG1, FL("Process defd sme req %d"),
4646 mac_ctx->lim.gDeferMsgTypeForNOA);
4647
4648 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4649 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
4650 lim_log(mac_ctx, LOGW,
4651 FL("start rcvd from FW when no sme deferred msg pending. Do nothing. "));
4652 lim_log(mac_ctx, LOGW,
4653 FL("It may happen when NOA start ind and timeout happen at the same time"));
4654 return;
4655 }
4656 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4657 case eWNI_SME_SCAN_REQ:
4658 __lim_process_sme_scan_req(mac_ctx,
4659 mac_ctx->lim.gpDefdSmeMsgForNOA);
4660 break;
4661#ifdef FEATURE_OEM_DATA_SUPPORT
4662 case eWNI_SME_OEM_DATA_REQ:
4663 __lim_process_sme_oem_data_req(mac_ctx,
4664 mac_ctx->lim.gpDefdSmeMsgForNOA);
4665 break;
4666#endif
4667 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4668 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4669 mac_ctx->lim.gpDefdSmeMsgForNOA);
4670 /*
4671 * lim_process_remain_on_chnl_req doesnt want us to free
4672 * the buffer since it is freed in lim_remain_on_chn_rsp.
4673 * this change is to avoid "double free"
4674 */
4675 if (false == buf_consumed)
4676 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4677 break;
4678 case eWNI_SME_JOIN_REQ:
4679 __lim_process_sme_join_req(mac_ctx,
4680 mac_ctx->lim.gpDefdSmeMsgForNOA);
4681 break;
4682 default:
4683 lim_log(mac_ctx, LOGE, FL("Unknown deferred msg type %d"),
4684 mac_ctx->lim.gDeferMsgTypeForNOA);
4685 break;
4686 }
4687 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4688}
4689
4690static void
4691__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4692{
4693 tpSirResetAPCapsChange pResetCapsChange;
4694 tpPESession psessionEntry;
4695 uint8_t sessionId = 0;
4696 if (pMsgBuf == NULL) {
4697 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4698 return;
4699 }
4700
4701 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4702 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004703 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4704 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004705 if (psessionEntry == NULL) {
4706 lim_log(pMac, LOGE,
4707 FL("Session does not exist for given BSSID"));
4708 return;
4709 }
4710
4711 psessionEntry->limSentCapsChangeNtf = false;
4712 return;
4713}
4714
4715/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304716 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4717 * indication callback in PE.
4718 * @mac_ptr: Mac pointer
4719 * @msg_buf: Msg pointer containing the callback
4720 *
4721 * This function is used save the Management frame
4722 * indication callback in PE.
4723 *
4724 * Return: None
4725 */
4726static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4727 uint32_t *msg_buf)
4728{
4729 struct sir_sme_mgmt_frame_cb_req *sme_req =
4730 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4731
4732 if (NULL == msg_buf) {
4733 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4734 return;
4735 }
4736 if (sme_req->callback)
4737 mac_ctx->mgmt_frame_ind_cb =
4738 (sir_mgmt_frame_ind_callback)sme_req->callback;
4739 else
4740 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4741}
4742
4743/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004744 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4745 * @mac_ctx: Pointer to Global MAC structure
4746 * @pdev_id: pdev id to set the IE.
4747 * @nss: Nss values to prepare the HT IE.
4748 *
4749 * Prepares the HT IE with self capabilities for different
4750 * Nss values and sends the set HT IE req to FW.
4751 *
4752 * Return: None
4753 */
4754static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4755 uint8_t nss)
4756{
4757 struct set_ie_param *ie_params;
4758 tSirMsgQ msg;
4759 tSirRetStatus rc = eSIR_SUCCESS;
4760 uint8_t *p_ie = NULL;
4761 tHtCaps *p_ht_cap;
4762 int i;
4763
4764 for (i = nss; i > 0; i--) {
4765 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4766 if (NULL == ie_params) {
4767 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4768 return;
4769 }
4770 ie_params->nss = i;
4771 ie_params->pdev_id = pdev_id;
4772 ie_params->ie_type = DOT11_HT_IE;
4773 /* 2 for IE len and EID */
4774 ie_params->ie_len = 2 + sizeof(tHtCaps);
4775 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4776 if (NULL == ie_params->ie_ptr) {
4777 qdf_mem_free(ie_params);
4778 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4779 return;
4780 }
4781 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4782 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4783 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4784 ie_params->ie_len);
4785
4786 if (NSS_1x1_MODE == i) {
4787 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4788 ie_params->ie_len,
4789 DOT11F_EID_HTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004790 if (NULL == p_ie) {
4791 qdf_mem_free(ie_params->ie_ptr);
4792 qdf_mem_free(ie_params);
4793 lim_log(mac_ctx, LOGE,
4794 FL("failed to get IE ptr"));
4795 return;
4796 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004797 p_ht_cap = (tHtCaps *)&p_ie[2];
4798 p_ht_cap->supportedMCSSet[1] = 0;
4799 p_ht_cap->txSTBC = 0;
4800 }
4801
4802 msg.type = WMA_SET_PDEV_IE_REQ;
4803 msg.bodyptr = ie_params;
4804 msg.bodyval = 0;
4805
4806 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4807 if (rc != eSIR_SUCCESS) {
4808 lim_log(mac_ctx, LOGE,
4809 FL("wma_post_ctrl_msg() return failure"));
4810 qdf_mem_free(ie_params->ie_ptr);
4811 qdf_mem_free(ie_params);
4812 return;
4813 }
4814 }
4815}
4816
4817/**
4818 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4819 * @mac_ctx: Pointer to Global MAC structure
4820 * @pdev_id: pdev id to set the IE.
4821 * @nss: Nss values to prepare the VHT IE.
4822 *
4823 * Prepares the VHT IE with self capabilities for different
4824 * Nss values and sends the set VHT IE req to FW.
4825 *
4826 * Return: None
4827 */
4828static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4829 uint8_t nss)
4830{
4831 struct set_ie_param *ie_params;
4832 tSirMsgQ msg;
4833 tSirRetStatus rc = eSIR_SUCCESS;
4834 uint8_t *p_ie = NULL;
4835 tSirMacVHTCapabilityInfo *vht_cap;
4836 int i;
4837 tSirVhtMcsInfo *vht_mcs;
4838
4839 for (i = nss; i > 0; i--) {
4840 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4841 if (NULL == ie_params) {
4842 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4843 return;
4844 }
4845 ie_params->nss = i;
4846 ie_params->pdev_id = pdev_id;
4847 ie_params->ie_type = DOT11_VHT_IE;
4848 /* 2 for IE len and EID */
4849 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4850 sizeof(tSirVhtMcsInfo);
4851 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4852 if (NULL == ie_params->ie_ptr) {
4853 qdf_mem_free(ie_params);
4854 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4855 return;
4856 }
4857 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4858 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4859 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4860 ie_params->ie_len);
4861
4862 if (NSS_1x1_MODE == i) {
4863 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4864 ie_params->ie_len,
4865 DOT11F_EID_VHTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004866 if (NULL == p_ie) {
4867 qdf_mem_free(ie_params->ie_ptr);
4868 qdf_mem_free(ie_params);
4869 lim_log(mac_ctx, LOGE,
4870 FL("failed to get IE ptr"));
4871 return;
4872 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004873 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4874 vht_cap->txSTBC = 0;
4875 vht_mcs =
4876 (tSirVhtMcsInfo *)&p_ie[2 +
4877 sizeof(tSirMacVHTCapabilityInfo)];
4878 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4879 vht_mcs->rxHighest =
4880 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4881 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4882 vht_mcs->txHighest =
4883 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4884 }
4885 msg.type = WMA_SET_PDEV_IE_REQ;
4886 msg.bodyptr = ie_params;
4887 msg.bodyval = 0;
4888
4889 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4890 if (rc != eSIR_SUCCESS) {
4891 lim_log(mac_ctx, LOGE,
4892 FL("wma_post_ctrl_msg failure"));
4893 qdf_mem_free(ie_params->ie_ptr);
4894 qdf_mem_free(ie_params);
4895 return;
4896 }
4897 }
4898}
4899
4900/**
4901 * lim_process_set_pdev_IEs() - process the set pdev IE req
4902 * @mac_ctx: Pointer to Global MAC structure
4903 * @msg_buf: Pointer to the SME message buffer
4904 *
4905 * This function is called by limProcessMessageQueue(). This
4906 * function sets the PDEV IEs to the FW.
4907 *
4908 * Return: None
4909 */
4910static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4911{
4912 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4913
4914 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4915
4916 if (NULL == ht_vht_cfg) {
4917 lim_log(mac_ctx, LOGE, FL("NULL ht_vht_cfg"));
4918 return;
4919 }
4920
4921 lim_log(mac_ctx, LOG1, FL("rcvd set pdev ht vht ie req with nss = %d"),
4922 ht_vht_cfg->nss);
4923 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4924
4925 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4926 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4927 ht_vht_cfg->nss);
4928}
4929
4930/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004931 * lim_process_sme_req_messages()
4932 *
4933 ***FUNCTION:
4934 * This function is called by limProcessMessageQueue(). This
4935 * function processes SME request messages from HDD or upper layer
4936 * application.
4937 *
4938 ***LOGIC:
4939 *
4940 ***ASSUMPTIONS:
4941 *
4942 ***NOTE:
4943 *
4944 * @param pMac Pointer to Global MAC structure
4945 * @param msgType Indicates the SME message type
4946 * @param *pMsgBuf A pointer to the SME message buffer
4947 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
4948 * false - if pMsgBuf is not to be freed.
4949 */
4950
4951bool lim_process_sme_req_messages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4952{
4953 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
4954 uint32_t *pMsgBuf = pMsg->bodyptr;
4955 tpSirSmeScanReq pScanReq;
4956 PELOG1(lim_log
4957 (pMac, LOG1,
4958 FL
4959 ("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)"),
4960 lim_msg_str(pMsg->type), pMsg->type,
4961 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
4962 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
4963 )
4964
4965 pScanReq = (tpSirSmeScanReq) pMsgBuf;
4966 /* If no insert NOA required then execute the code below */
4967
4968 switch (pMsg->type) {
4969 case eWNI_SME_SYS_READY_IND:
4970 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
4971 break;
4972
4973 case eWNI_SME_START_BSS_REQ:
4974 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
4975 break;
4976
4977 case eWNI_SME_SCAN_REQ:
4978 __lim_process_sme_scan_req(pMac, pMsgBuf);
4979 break;
4980
4981#ifdef FEATURE_OEM_DATA_SUPPORT
4982 case eWNI_SME_OEM_DATA_REQ:
4983 __lim_process_sme_oem_data_req(pMac, pMsgBuf);
4984 break;
4985#endif
4986 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4987 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
4988 break;
4989
4990 case eWNI_SME_UPDATE_NOA:
4991 __lim_process_sme_no_a_update(pMac, pMsgBuf);
4992 break;
4993 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
4994 __lim_process_clear_dfs_channel_list(pMac, pMsg);
4995 break;
4996 case eWNI_SME_JOIN_REQ:
4997 __lim_process_sme_join_req(pMac, pMsgBuf);
4998 break;
4999
5000 case eWNI_SME_REASSOC_REQ:
5001 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
5002 break;
5003
5004 case eWNI_SME_DISASSOC_REQ:
5005 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
5006 break;
5007
5008 case eWNI_SME_DISASSOC_CNF:
5009 case eWNI_SME_DEAUTH_CNF:
5010 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
5011 break;
5012
5013 case eWNI_SME_DEAUTH_REQ:
5014 __lim_process_sme_deauth_req(pMac, pMsgBuf);
5015 break;
5016
5017 case eWNI_SME_SETCONTEXT_REQ:
5018 __lim_process_sme_set_context_req(pMac, pMsgBuf);
5019 break;
5020
5021 case eWNI_SME_STOP_BSS_REQ:
5022 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
5023 break;
5024
5025 case eWNI_SME_ASSOC_CNF:
5026 if (pMsg->type == eWNI_SME_ASSOC_CNF)
5027 PELOG1(lim_log(pMac,
5028 LOG1, FL("Received ASSOC_CNF message"));)
5029 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
5030 pMsgBuf);
5031 break;
5032
5033 case eWNI_SME_ADDTS_REQ:
5034 PELOG1(lim_log(pMac, LOG1, FL("Received ADDTS_REQ message"));)
5035 __lim_process_sme_addts_req(pMac, pMsgBuf);
5036 break;
5037
5038 case eWNI_SME_DELTS_REQ:
5039 PELOG1(lim_log(pMac, LOG1, FL("Received DELTS_REQ message"));)
5040 __lim_process_sme_delts_req(pMac, pMsgBuf);
5041 break;
5042
5043 case SIR_LIM_ADDTS_RSP_TIMEOUT:
5044 PELOG1(lim_log
5045 (pMac, LOG1,
5046 FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
5047 )
5048 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
5049 break;
5050
5051 case eWNI_SME_GET_STATISTICS_REQ:
5052 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
5053 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
5054 bufConsumed = false;
5055 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005056#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005057 case eWNI_SME_GET_TSM_STATS_REQ:
5058 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
5059 bufConsumed = false;
5060 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005061#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005062 case eWNI_SME_GET_ASSOC_STAS_REQ:
5063 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
5064 break;
5065 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5066 lim_process_tkip_counter_measures(pMac, pMsgBuf);
5067 break;
5068
5069 case eWNI_SME_HIDE_SSID_REQ:
5070 __lim_process_sme_hide_ssid(pMac, pMsgBuf);
5071 break;
5072 case eWNI_SME_UPDATE_APWPSIE_REQ:
5073 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
5074 break;
5075 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5076 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
5077 break;
5078
5079 case eWNI_SME_SET_APWPARSNIEs_REQ:
5080 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
5081 break;
5082
5083 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5084 /* Update the beaconInterval */
5085 __lim_process_sme_change_bi(pMac, pMsgBuf);
5086 break;
5087
5088#ifdef QCA_HT_2040_COEX
5089 case eWNI_SME_SET_HT_2040_MODE:
5090 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
5091 break;
5092#endif
5093
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005094 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5095 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5096 __lim_process_report_message(pMac, pMsg);
5097 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005098
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005099 case eWNI_SME_FT_PRE_AUTH_REQ:
5100 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
5101 break;
5102 case eWNI_SME_FT_UPDATE_KEY:
5103 lim_process_ft_update_key(pMac, pMsgBuf);
5104 break;
5105
5106 case eWNI_SME_FT_AGGR_QOS_REQ:
5107 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
5108 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005109
5110 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5111 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
5112 break;
5113#ifdef FEATURE_WLAN_TDLS
5114 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5115 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
5116 break;
5117 case eWNI_SME_TDLS_ADD_STA_REQ:
5118 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
5119 break;
5120 case eWNI_SME_TDLS_DEL_STA_REQ:
5121 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
5122 break;
5123 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5124 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
5125 break;
5126#endif
5127 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5128 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
5129 break;
5130
5131 case eWNI_SME_CHANNEL_CHANGE_REQ:
5132 lim_process_sme_channel_change_request(pMac, pMsgBuf);
5133 break;
5134
5135 case eWNI_SME_START_BEACON_REQ:
5136 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
5137 break;
5138
5139 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
5140 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
5141 break;
5142
5143 case eWNI_SME_UPDATE_ADDITIONAL_IES:
5144 lim_process_update_add_ies(pMac, pMsgBuf);
5145 break;
5146
5147 case eWNI_SME_MODIFY_ADDITIONAL_IES:
5148 lim_process_modify_add_ies(pMac, pMsgBuf);
5149 break;
5150 case eWNI_SME_SET_HW_MODE_REQ:
5151 lim_process_set_hw_mode(pMac, pMsgBuf);
5152 break;
5153 case eWNI_SME_NSS_UPDATE_REQ:
5154 lim_process_nss_update_request(pMac, pMsgBuf);
5155 break;
5156 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5157 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5158 break;
5159 case eWNI_SME_SET_IE_REQ:
5160 lim_process_set_ie_req(pMac, pMsgBuf);
5161 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305162 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5163 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5164 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305165 case eWNI_SME_EXT_CHANGE_CHANNEL:
5166 lim_process_ext_change_channel(pMac, pMsgBuf);
5167 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005168 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5169 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5170 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005171 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5172 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005173 case eWNI_SME_NDP_INITIATOR_REQ:
5174 lim_handle_ndp_request_message(pMac, pMsg);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005175 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005176 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305177 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005178 pMsg->bodyptr = NULL;
5179 break;
5180 } /* switch (msgType) */
5181
5182 return bufConsumed;
5183} /*** end lim_process_sme_req_messages() ***/
5184
5185/**
5186 * lim_process_sme_start_beacon_req()
5187 *
5188 ***FUNCTION:
5189 * This function is called by limProcessMessageQueue(). This
5190 * function processes SME request messages from HDD or upper layer
5191 * application.
5192 *
5193 ***LOGIC:
5194 *
5195 ***ASSUMPTIONS:
5196 *
5197 ***NOTE:
5198 *
5199 * @param pMac Pointer to Global MAC structure
5200 * @param msgType Indicates the SME message type
5201 * @param *pMsgBuf A pointer to the SME message buffer
5202 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5203 * false - if pMsgBuf is not to be freed.
5204 */
5205static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5206{
5207 tpSirStartBeaconIndication pBeaconStartInd;
5208 tpPESession psessionEntry;
5209 uint8_t sessionId; /* PE sessionID */
5210
5211 if (pMsg == NULL) {
5212 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
5213 return;
5214 }
5215
5216 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5217 psessionEntry = pe_find_session_by_bssid(pMac,
5218 pBeaconStartInd->bssid,
5219 &sessionId);
5220 if (psessionEntry == NULL) {
5221 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
5222 lim_log(pMac, LOGE,
5223 FL("Session does not exist for given bssId"));
5224 return;
5225 }
5226
5227 if (pBeaconStartInd->beaconStartStatus == true) {
5228 /*
5229 * Currently this Indication comes from SAP
5230 * to start Beacon Tx on a DFS channel
5231 * since beaconing has to be done on DFS
5232 * channel only after CAC WAIT is completed.
5233 * On a DFS Channel LIM does not start beacon
5234 * Tx right after the WMA_ADD_BSS_RSP.
5235 */
5236 lim_apply_configuration(pMac, psessionEntry);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305237 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005238 FL("Start Beacon with ssid %s Ch %d"),
5239 psessionEntry->ssId.ssId,
5240 psessionEntry->currentOperChannel);
5241 lim_send_beacon_ind(pMac, psessionEntry);
5242 } else {
5243 lim_log(pMac, LOGE, FL("Invalid Beacon Start Indication"));
5244 return;
5245 }
5246}
5247
5248/**
5249 * lim_process_sme_channel_change_request() - process sme ch change req
5250 *
5251 * @mac_ctx: Pointer to Global MAC structure
5252 * @msg_buf: pointer to the SME message buffer
5253 *
5254 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5255 *
5256 * Return: None
5257 */
5258static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5259 uint32_t *msg_buf)
5260{
5261 tpSirChanChangeRequest ch_change_req;
5262 tpPESession session_entry;
5263 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005264 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005265 uint32_t val = 0;
5266
5267 if (msg_buf == NULL) {
5268 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5269 return;
5270 }
5271 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5272
5273 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5274 ch_change_req->targetChannel);
5275
5276 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5277 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
5278 lim_log(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5279 return;
5280 }
5281
5282 session_entry = pe_find_session_by_bssid(mac_ctx,
5283 ch_change_req->bssid, &session_id);
5284 if (session_entry == NULL) {
5285 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
5286 lim_log(mac_ctx, LOGE, FL(
5287 "Session does not exist for given bssId"));
5288 return;
5289 }
5290
5291 if (session_entry->currentOperChannel ==
5292 ch_change_req->targetChannel) {
5293 lim_log(mac_ctx, LOGE, FL("target CH is same as current CH"));
5294 return;
5295 }
5296
5297 if (LIM_IS_AP_ROLE(session_entry))
5298 session_entry->channelChangeReasonCode =
5299 LIM_SWITCH_CHANNEL_SAP_DFS;
5300 else
5301 session_entry->channelChangeReasonCode =
5302 LIM_SWITCH_CHANNEL_OPERATION;
5303
5304 lim_log(mac_ctx, LOGW, FL(
5305 "switch old chnl %d to new chnl %d, ch_bw %d"),
5306 session_entry->currentOperChannel,
5307 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005308 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005309
5310 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005311 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005312 session_entry->ch_center_freq_seg0 =
5313 ch_change_req->center_freq_seg_0;
5314 session_entry->ch_center_freq_seg1 =
5315 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005316 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005317 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005318 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005319 session_entry->htRecommendedTxWidthSet =
5320 session_entry->htSupportedChannelWidthSet;
5321 session_entry->currentOperChannel =
5322 ch_change_req->targetChannel;
5323 session_entry->limRFBand =
5324 lim_get_rf_band(session_entry->currentOperChannel);
5325 /* Initialize 11h Enable Flag */
5326 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5327 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5328 eSIR_SUCCESS)
5329 lim_log(mac_ctx, LOGP,
5330 FL("Fail to get WNI_CFG_11H_ENABLED"));
5331 }
5332
5333 session_entry->lim11hEnable = val;
5334 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305335 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005336 &ch_change_req->operational_rateset,
5337 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305338 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005339 &ch_change_req->extended_rateset,
5340 sizeof(session_entry->extRateSet));
5341 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5342 session_entry->ch_center_freq_seg0,
5343 session_entry->ch_center_freq_seg1,
5344 session_entry->ch_width,
5345 max_tx_pwr, session_entry->peSessionId);
5346}
5347
5348/******************************************************************************
5349* lim_start_bss_update_add_ie_buffer()
5350*
5351***FUNCTION:
5352* This function checks the src buffer and its length and then malloc for
5353* dst buffer update the same
5354*
5355***LOGIC:
5356*
5357***ASSUMPTIONS:
5358*
5359***NOTE:
5360*
5361* @param pMac Pointer to Global MAC structure
5362* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5363* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5364* @param *pSrcData_buff A pointer of uint8_t src buffer
5365* @param srcDataLen src buffer length
5366******************************************************************************/
5367
5368static void
5369lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5370 uint8_t **pDstData_buff,
5371 uint16_t *pDstDataLen,
5372 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5373{
5374
5375 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5376 *pDstDataLen = srcDataLen;
5377
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305378 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005379
5380 if (NULL == *pDstData_buff) {
5381 lim_log(pMac, LOGE,
5382 FL("AllocateMemory failed for pDstData_buff"));
5383 return;
5384 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305385 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005386 } else {
5387 *pDstData_buff = NULL;
5388 *pDstDataLen = 0;
5389 }
5390}
5391
5392/******************************************************************************
5393* lim_update_add_ie_buffer()
5394*
5395***FUNCTION:
5396* This function checks the src buffer and length if src buffer length more
5397* than dst buffer length then free the dst buffer and malloc for the new src
5398* length, and update the dst buffer and length. But if dst buffer is bigger
5399* than src buffer length then it just update the dst buffer and length
5400*
5401***LOGIC:
5402*
5403***ASSUMPTIONS:
5404*
5405***NOTE:
5406*
5407* @param pMac Pointer to Global MAC structure
5408* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5409* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5410* @param *pSrcData_buff A pointer of uint8_t src buffer
5411* @param srcDataLen src buffer length
5412******************************************************************************/
5413
5414static void
5415lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5416 uint8_t **pDstData_buff,
5417 uint16_t *pDstDataLen,
5418 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5419{
5420
5421 if (NULL == pSrcData_buff) {
5422 lim_log(pMac, LOGE, FL("src buffer is null."));
5423 return;
5424 }
5425
5426 if (srcDataLen > *pDstDataLen) {
5427 *pDstDataLen = srcDataLen;
5428 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305429 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005430 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305431 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005432
5433 if (NULL == *pDstData_buff) {
5434 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5435 *pDstDataLen = 0;
5436 return;
5437 }
5438 }
5439
5440 /* copy the content of buffer into dst buffer
5441 */
5442 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305443 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005444
5445}
5446
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005447/**
5448 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5449 * @pMac : Pointer to Global MAC structure
5450 * @pDstData_buff : A pointer to pointer of dst buffer
5451 * @pDstDataLen : A pointer to pointer of dst buffer length
5452 * @pModifyIE : A pointer to tSirModifyIE
5453 *
5454 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5455 *
5456 * Return:
5457 * True or false depending upon whether IE is updated or not
5458 */
5459static bool
5460lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5461 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5462{
5463 int32_t oui_length;
5464 uint8_t *ibss_ie = NULL;
5465
5466 ibss_ie = pModifyIE->pIEBuffer;
5467 oui_length = pModifyIE->oui_length;
5468
5469 if ((0 == oui_length) || (NULL == ibss_ie)) {
5470 PELOGE(lim_log(pMac, LOGE,
5471 FL("Invalid set IBSS vendor IE command length %d "),
5472 oui_length);)
5473 return false;
5474 }
5475
5476 lim_update_add_ie_buffer(pMac,
5477 pDstData_buff,
5478 pDstDataLen,
5479 pModifyIE->pIEBuffer,
5480 pModifyIE->ieBufferlength);
5481
5482 return true;
5483}
5484
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005485/*
5486* lim_process_modify_add_ies() - process modify additional IE req.
5487*
5488* @mac_ctx: Pointer to Global MAC structure
5489* @msg_buf: pointer to the SME message buffer
5490*
5491* This function update the PE buffers for additional IEs.
5492*
5493* Return: None
5494*/
5495static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5496 uint32_t *msg_buf)
5497{
5498 tpSirModifyIEsInd modify_add_ies;
5499 tpPESession session_entry;
5500 uint8_t session_id;
5501 bool ret = false;
5502 tSirAddIeParams *add_ie_params;
5503
5504 if (msg_buf == NULL) {
5505 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5506 return;
5507 }
5508
5509 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5510 /* Incoming message has smeSession, use BSSID to find PE session */
5511 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005512 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005513
5514 if (NULL == session_entry) {
5515 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5516 MAC_ADDRESS_STR),
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005517 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005518 goto end;
5519 }
5520 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5521 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5522 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
5523 lim_log(mac_ctx, LOGE,
5524 FL("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d"),
5525 modify_add_ies->modifyIE.pIEBuffer,
5526 modify_add_ies->modifyIE.ieBufferlength,
5527 modify_add_ies->modifyIE.ieID,
5528 modify_add_ies->modifyIE.ieIDLen,
5529 modify_add_ies->updateType);
5530 goto end;
5531 }
5532 add_ie_params = &session_entry->addIeParams;
5533 switch (modify_add_ies->updateType) {
5534 case eUPDATE_IE_PROBE_RESP:
5535 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005536 if (LIM_IS_IBSS_ROLE(session_entry)) {
5537 lim_update_ibss_prop_add_ies(mac_ctx,
5538 &add_ie_params->probeRespData_buff,
5539 &add_ie_params->probeRespDataLen,
5540 &modify_add_ies->modifyIE);
5541 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005542 break;
5543 case eUPDATE_IE_ASSOC_RESP:
5544 /* assoc resp IE */
5545 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305546 QDF_TRACE(QDF_MODULE_ID_PE,
5547 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005548 "assoc resp add ie not present %d"),
5549 add_ie_params->assocRespDataLen);
5550 }
5551 /* search through the buffer and modify the IE */
5552 break;
5553 case eUPDATE_IE_PROBE_BCN:
5554 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005555 if (LIM_IS_IBSS_ROLE(session_entry)) {
5556 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5557 &add_ie_params->probeRespBCNData_buff,
5558 &add_ie_params->probeRespBCNDataLen,
5559 &modify_add_ies->modifyIE);
5560 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005561 if (ret == true && modify_add_ies->modifyIE.notify) {
5562 lim_handle_param_update(mac_ctx,
5563 modify_add_ies->updateType);
5564 }
5565 break;
5566 default:
5567 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d"),
5568 modify_add_ies->updateType);
5569 break;
5570 }
5571end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305572 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005573 modify_add_ies->modifyIE.pIEBuffer = NULL;
5574}
5575
5576/*
5577* lim_process_update_add_ies() - process additional IE update req
5578*
5579* @mac_ctx: Pointer to Global MAC structure
5580* @msg_buf: pointer to the SME message buffer
5581*
5582* This function update the PE buffers for additional IEs.
5583*
5584* Return: None
5585*/
5586static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5587 uint32_t *msg_buf)
5588{
5589 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5590 uint8_t session_id;
5591 tpPESession session_entry;
5592 tSirAddIeParams *addn_ie;
5593 uint16_t new_length = 0;
5594 uint8_t *new_ptr = NULL;
5595 tSirUpdateIE *update_ie;
5596
5597 if (msg_buf == NULL) {
5598 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5599 return;
5600 }
5601 update_ie = &update_add_ies->updateIE;
5602 /* incoming message has smeSession, use BSSID to find PE session */
5603 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005604 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005605
5606 if (NULL == session_entry) {
5607 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5608 MAC_ADDRESS_STR),
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005609 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005610 goto end;
5611 }
5612 addn_ie = &session_entry->addIeParams;
5613 /* if len is 0, upper layer requested freeing of buffer */
5614 if (0 == update_ie->ieBufferlength) {
5615 switch (update_add_ies->updateType) {
5616 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305617 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005618 addn_ie->probeRespData_buff = NULL;
5619 addn_ie->probeRespDataLen = 0;
5620 break;
5621 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305622 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005623 addn_ie->assocRespData_buff = NULL;
5624 addn_ie->assocRespDataLen = 0;
5625 break;
5626 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305627 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005628 addn_ie->probeRespBCNData_buff = NULL;
5629 addn_ie->probeRespBCNDataLen = 0;
5630
5631 if (update_ie->notify)
5632 lim_handle_param_update(mac_ctx,
5633 update_add_ies->updateType);
5634 break;
5635 default:
5636 break;
5637 }
5638 return;
5639 }
5640 switch (update_add_ies->updateType) {
5641 case eUPDATE_IE_PROBE_RESP:
5642 if (update_ie->append) {
5643 /*
5644 * In case of append, allocate new memory
5645 * with combined length
5646 */
5647 new_length = update_ie->ieBufferlength +
5648 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305649 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005650 if (NULL == new_ptr) {
5651 lim_log(mac_ctx, LOGE, FL(
5652 "Memory allocation failed."));
5653 goto end;
5654 }
5655 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305656 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005657 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305658 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005659 update_ie->pAdditionIEBuffer,
5660 update_ie->ieBufferlength);
5661 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305662 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005663 /* adjust length accordingly */
5664 addn_ie->probeRespDataLen = new_length;
5665 /* save refernece of local buffer in PE session */
5666 addn_ie->probeRespData_buff = new_ptr;
5667 goto end;
5668 }
5669 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5670 &addn_ie->probeRespDataLen,
5671 update_ie->pAdditionIEBuffer,
5672 update_ie->ieBufferlength);
5673 break;
5674 case eUPDATE_IE_ASSOC_RESP:
5675 /* assoc resp IE */
5676 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5677 &addn_ie->assocRespDataLen,
5678 update_ie->pAdditionIEBuffer,
5679 update_ie->ieBufferlength);
5680 break;
5681 case eUPDATE_IE_PROBE_BCN:
5682 /* probe resp Bcn IE */
5683 lim_update_add_ie_buffer(mac_ctx,
5684 &addn_ie->probeRespBCNData_buff,
5685 &addn_ie->probeRespBCNDataLen,
5686 update_ie->pAdditionIEBuffer,
5687 update_ie->ieBufferlength);
5688 if (update_ie->notify)
5689 lim_handle_param_update(mac_ctx,
5690 update_add_ies->updateType);
5691 break;
5692 default:
5693 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d."),
5694 update_add_ies->updateType);
5695 break;
5696 }
5697end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305698 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005699 update_ie->pAdditionIEBuffer = NULL;
5700}
5701
5702/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305703 * send_extended_chan_switch_action_frame()- function to send ECSA
5704 * action frame for each sta connected to SAP/GO and AP in case of
5705 * STA .
5706 * @mac_ctx: pointer to global mac structure
5707 * @new_channel: new channel to switch to.
5708 * @ch_bandwidth: BW of channel to calculate op_class
5709 * @session_entry: pe session
5710 *
5711 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5712 *
5713 * Return: void
5714 */
5715
5716static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5717 uint16_t new_channel, uint8_t ch_bandwidth,
5718 tpPESession session_entry)
5719{
5720 uint16_t op_class;
5721 uint8_t switch_mode = 0, i;
5722 tpDphHashNode psta;
5723
5724
Amar Singhal22995112016-01-22 10:42:33 -08005725 op_class = cds_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305726 mac_ctx->scan.countryCodeCurrent,
5727 new_channel,
5728 ch_bandwidth);
5729
5730 if (LIM_IS_AP_ROLE(session_entry) &&
5731 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
5732 switch_mode = 1;
5733
5734 if (LIM_IS_AP_ROLE(session_entry)) {
5735 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5736 psta =
5737 session_entry->dph.dphHashTable.pDphNodeArray + i;
5738 if (psta && psta->added)
5739 lim_send_extended_chan_switch_action_frame(
5740 mac_ctx,
5741 psta->staAddr,
5742 switch_mode, op_class, new_channel,
5743 LIM_MAX_CSA_IE_UPDATES, session_entry);
5744 }
5745 } else if (LIM_IS_STA_ROLE(session_entry)) {
5746 lim_send_extended_chan_switch_action_frame(mac_ctx,
5747 session_entry->bssId,
5748 switch_mode, op_class, new_channel,
5749 LIM_MAX_CSA_IE_UPDATES, session_entry);
5750 }
5751
5752}
5753
5754/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005755 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5756 *
5757 * @mac_ctx: Pointer to Global MAC structure
5758 * @msg_buf: pointer to the SME message buffer
5759 *
5760 * This function processes SME request messages from HDD or upper layer
5761 * application.
5762 *
5763 * Return: None
5764 */
5765static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5766 uint32_t *msg_buf)
5767{
5768 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5769 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005770 uint8_t session_id;
5771 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005772 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005773
5774 if (msg_buf == NULL) {
5775 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5776 return;
5777 }
5778
5779 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5780 session_entry = pe_find_session_by_bssid(mac_ctx,
5781 dfs_csa_ie_req->bssid, &session_id);
5782 if (session_entry == NULL) {
5783 lim_log(mac_ctx, LOGE, FL(
5784 "Session not found for given BSSID" MAC_ADDRESS_STR),
5785 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5786 return;
5787 }
5788
5789 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5790 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5791 GET_LIM_SYSTEM_ROLE(session_entry));
5792 return;
5793 }
5794
5795 /* target channel */
5796 session_entry->gLimChannelSwitch.primaryChannel =
5797 dfs_csa_ie_req->targetChannel;
5798
5799 /* Channel switch announcement needs to be included in beacon */
5800 session_entry->dfsIncludeChanSwIe = true;
5801 session_entry->gLimChannelSwitch.switchCount = LIM_MAX_CSA_IE_UPDATES;
5802 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005803 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305804 session_entry->gLimChannelSwitch.sec_ch_offset =
5805 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005806 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
5807 session_entry->gLimChannelSwitch.switchMode = 1;
5808
5809 /*
5810 * Validate if SAP is operating HT or VHT mode and set the Channel
5811 * Switch Wrapper element with the Wide Band Switch subelement.
5812 */
5813 if (true != session_entry->vhtCapability)
5814 goto skip_vht;
5815
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005816 /* Now encode the Wider Ch BW element depending on the ch width */
5817 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005818 switch (dfs_csa_ie_req->ch_params.ch_width) {
5819 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005820 /*
5821 * Wide channel BW sublement in channel wrapper element is not
5822 * required in case of 20 Mhz operation. Currently It is set
5823 * only set in case of 40/80 Mhz Operation.
5824 */
5825 session_entry->dfsIncludeChanWrapperIe = false;
5826 wider_bw_ch_switch->newChanWidth =
5827 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5828 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005829 case CH_WIDTH_40MHZ:
5830 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005831 wider_bw_ch_switch->newChanWidth =
5832 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5833 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005834 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005835 session_entry->dfsIncludeChanWrapperIe = true;
5836 wider_bw_ch_switch->newChanWidth =
5837 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5838 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005839 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005840 session_entry->dfsIncludeChanWrapperIe = true;
5841 wider_bw_ch_switch->newChanWidth =
5842 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5843 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005844 case CH_WIDTH_80P80MHZ:
5845 session_entry->dfsIncludeChanWrapperIe = true;
5846 wider_bw_ch_switch->newChanWidth =
5847 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005848 /*
5849 * This is not applicable for 20/40/80 Mhz.
5850 * Only used when we support 80+80 Mhz operation.
5851 * In case of 80+80 Mhz, this parameter indicates
5852 * center channel frequency index of 80 Mhz channel of
5853 * frequency segment 1.
5854 */
5855 wider_bw_ch_switch->newCenterChanFreq1 =
5856 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005857 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005858 default:
5859 session_entry->dfsIncludeChanWrapperIe = false;
5860 /*
5861 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
5862 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
5863 */
5864 lim_log(mac_ctx, LOGE, FL("Invalid Channel Width"));
5865 break;
5866 }
5867 /* Fetch the center channel based on the channel width */
5868 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005869 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005870skip_vht:
5871 /* Send CSA IE request from here */
5872 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5873 eSIR_SUCCESS) {
5874 lim_log(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
5875 return;
5876 }
5877
5878 /*
5879 * First beacon update request is sent here, the remaining updates are
5880 * done when the FW responds back after sending the first beacon after
5881 * the template update
5882 */
5883 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305884
5885 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
5886 ch_offset = BW80;
5887 else
5888 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
5889
5890 lim_log(mac_ctx, LOG1, FL("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d"),
5891 session_entry->gLimChannelSwitch.switchCount,
5892 session_entry->gLimChannelSwitch.primaryChannel,
5893 session_entry->gLimChannelSwitch.ch_width,
5894 session_entry->dfsIncludeChanWrapperIe,
5895 ch_offset);
5896
Abhishek Singh518323d2015-10-19 17:42:01 +05305897 /* Send ECSA Action frame after updating the beacon */
5898 send_extended_chan_switch_action_frame(mac_ctx,
5899 session_entry->gLimChannelSwitch.primaryChannel,
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05305900 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005901 session_entry->gLimChannelSwitch.switchCount--;
5902}
5903
5904/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305905 * lim_process_ext_change_channel()- function to send ECSA
5906 * action frame for STA/CLI .
5907 * @mac_ctx: pointer to global mac structure
5908 * @msg: params from sme for new channel.
5909 *
5910 * This function is called to send ECSA frame for STA/CLI.
5911 *
5912 * Return: void
5913 */
5914
5915static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
5916 uint32_t *msg)
5917{
5918 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
5919 (struct sir_sme_ext_cng_chan_req *) msg;
5920 tpPESession session_entry = NULL;
5921
5922 if (NULL == msg) {
5923 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5924 return;
5925 }
5926 session_entry =
5927 pe_find_session_by_sme_session_id(mac_ctx,
5928 ext_chng_channel->session_id);
5929 if (NULL == session_entry) {
5930 lim_log(mac_ctx, LOGE,
5931 FL("Session not found for given session %d"),
5932 ext_chng_channel->session_id);
5933 return;
5934 }
5935 if (LIM_IS_AP_ROLE(session_entry)) {
5936 lim_log(mac_ctx, LOGE,
5937 FL("not an STA/CLI session"));
5938 return;
5939 }
5940 send_extended_chan_switch_action_frame(mac_ctx,
5941 ext_chng_channel->new_channel,
5942 0, session_entry);
5943}
5944
5945/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005946 * lim_process_nss_update_request() - process sme nss update req
5947 *
5948 * @mac_ctx: Pointer to Global MAC structure
5949 * @msg_buf: pointer to the SME message buffer
5950 *
5951 * This function processes SME request messages from HDD or upper layer
5952 * application.
5953 *
5954 * Return: None
5955 */
5956static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
5957 uint32_t *msg_buf)
5958{
5959 struct sir_nss_update_request *nss_update_req_ptr;
5960 tpPESession session_entry = NULL;
5961
5962 if (msg_buf == NULL) {
5963 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5964 return;
5965 }
5966
5967 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05305968 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005969 nss_update_req_ptr->vdev_id);
5970 if (session_entry == NULL) {
5971 lim_log(mac_ctx, LOGE, FL(
5972 "Session not found for given session_id %d"),
5973 nss_update_req_ptr->vdev_id);
5974 return;
5975 }
5976
5977 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5978 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5979 GET_LIM_SYSTEM_ROLE(session_entry));
5980 return;
5981 }
5982
5983 /* populate nss field in the beacon */
5984 session_entry->gLimOperatingMode.present = 1;
5985 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
5986 /* Send nss update request from here */
5987 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
5988 eSIR_SUCCESS) {
5989 lim_log(mac_ctx, LOGE,
5990 FL("Unable to set op mode IE in beacon"));
5991 return;
5992 }
5993
5994 lim_send_beacon_ind(mac_ctx, session_entry);
5995}
5996
5997/**
5998 * lim_process_set_ie_req() - process sme set IE request
5999 *
6000 * @mac_ctx: Pointer to Global MAC structure
6001 * @msg_buf: pointer to the SME message buffer
6002 *
6003 * This function processes SME request messages from HDD or upper layer
6004 * application.
6005 *
6006 * Return: None
6007 */
6008static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6009{
6010 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306011 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006012
6013 if (msg_buf == NULL) {
6014 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6015 return;
6016 }
6017
6018 msg = (struct send_extcap_ie *)msg_buf;
6019 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306020 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006021 lim_log(mac_ctx, LOGE, FL("Unable to send ExtCap to FW"));
6022
6023}