blob: 9739487e56ef0c0932addbd29b7418591995cd99 [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);
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053093static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
94 uint32_t *msg_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080095static void lim_process_sme_channel_change_request(tpAniSirGlobal pMac,
96 uint32_t *pMsg);
97static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg);
98static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal pMac, uint32_t *pMsg);
99static void lim_process_nss_update_request(tpAniSirGlobal pMac, uint32_t *pMsg);
100static void lim_process_set_ie_req(tpAniSirGlobal pMac, uint32_t *pMsg);
101
102static void lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
103 uint8_t **pDstData_buff,
104 uint16_t *pDstDataLen,
105 uint8_t *pSrcData_buff,
106 uint16_t srcDataLen);
107
108static void lim_update_add_ie_buffer(tpAniSirGlobal pMac,
109 uint8_t **pDstData_buff,
110 uint16_t *pDstDataLen,
111 uint8_t *pSrcData_buff, uint16_t srcDataLen);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800112static bool lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac,
113 uint8_t **pDstData_buff,
114 uint16_t *pDstDataLen,
115 tSirModifyIE *pModifyIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800116static void lim_process_modify_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
117
118static void lim_process_update_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
119
Naveen Rawat0fc3f692016-06-22 14:30:54 -0700120extern void pe_register_callbacks_with_wma(tpAniSirGlobal pMac,
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800121 tSirSmeReadyReq *ready_req);
Abhishek Singh518323d2015-10-19 17:42:01 +0530122static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
123 uint32_t *msg);
124
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800125/**
126 * lim_process_set_hw_mode() - Send set HW mode command to WMA
127 * @mac: Globacl MAC pointer
128 * @msg: Message containing the hw mode index
129 *
130 * Send the set HW mode command to WMA
131 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530132 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800133 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530134static QDF_STATUS lim_process_set_hw_mode(tpAniSirGlobal mac, uint32_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800135{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530136 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800137 cds_msg_t cds_message;
138 struct sir_hw_mode *req_msg;
139 uint32_t len;
140 struct s_sir_set_hw_mode *buf;
141 tSirMsgQ resp_msg;
142 struct sir_set_hw_mode_resp *param;
143
144 buf = (struct s_sir_set_hw_mode *) msg;
145 if (!buf) {
146 lim_log(mac, LOGE, FL("Set HW mode param is NULL"));
147 /* To free the active command list */
148 goto fail;
149 }
150
151 len = sizeof(*req_msg);
152
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530153 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800154 if (!req_msg) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530155 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800156 /* Free the active command list
157 * Probably the malloc is going to fail there as well?!
158 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530159 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800160 }
161
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530162 qdf_mem_zero(req_msg, len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800163
164 req_msg->hw_mode_index = buf->set_hw.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530165 req_msg->reason = buf->set_hw.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800166 /* Other parameters are not needed for WMA */
167
168 cds_message.bodyptr = req_msg;
Manishekar Chandrasekarand9640342016-04-27 12:28:26 +0530169 cds_message.type = SIR_HAL_PDEV_SET_HW_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800170
171 lim_log(mac, LOG1, FL("Posting SIR_HAL_SOC_SET_HW_MOD to WMA"));
172 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530173 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800174 lim_log(mac, LOGE,
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -0700175 FL("cds_mq_post_message failed!(err=%d)"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800176 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530177 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800178 goto fail;
179 }
180 return status;
181fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530182 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800183 if (!param) {
184 lim_log(mac, LOGE, FL("HW mode resp failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530185 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800186 }
187 param->status = SET_HW_MODE_STATUS_ECANCELED;
188 param->cfgd_hw_mode_index = 0;
189 param->num_vdev_mac_entries = 0;
190 resp_msg.type = eWNI_SME_SET_HW_MODE_RESP;
191 resp_msg.bodyptr = param;
192 resp_msg.bodyval = 0;
193 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530194 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800195}
196
197/**
198 * lim_process_set_dual_mac_cfg_req() - Set dual mac config command to WMA
199 * @mac: Global MAC pointer
200 * @msg: Message containing the dual mac config parameter
201 *
202 * Send the set dual mac config command to WMA
203 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530204 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800205 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530206static QDF_STATUS lim_process_set_dual_mac_cfg_req(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800207 uint32_t *msg)
208{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530209 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800210 cds_msg_t cds_message;
211 struct sir_dual_mac_config *req_msg;
212 uint32_t len;
213 struct sir_set_dual_mac_cfg *buf;
214 tSirMsgQ resp_msg;
215 struct sir_dual_mac_config_resp *param;
216
217 buf = (struct sir_set_dual_mac_cfg *) msg;
218 if (!buf) {
219 lim_log(mac, LOGE, FL("Set Dual mac config is NULL"));
220 /* To free the active command list */
221 goto fail;
222 }
223
224 len = sizeof(*req_msg);
225
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530226 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227 if (!req_msg) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700228 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800229 /* Free the active command list
230 * Probably the malloc is going to fail there as well?!
231 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530232 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800233 }
234
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530235 qdf_mem_zero(req_msg, len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800236
237 req_msg->scan_config = buf->set_dual_mac.scan_config;
238 req_msg->fw_mode_config = buf->set_dual_mac.fw_mode_config;
239 /* Other parameters are not needed for WMA */
240
241 cds_message.bodyptr = req_msg;
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +0530242 cds_message.type = SIR_HAL_PDEV_DUAL_MAC_CFG_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800243
244 lim_log(mac, LOG1,
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +0530245 FL("Post SIR_HAL_PDEV_DUAL_MAC_CFG_REQ to WMA: %x %x"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800246 req_msg->scan_config, req_msg->fw_mode_config);
247 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530248 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800249 lim_log(mac, LOGE,
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -0700250 FL("cds_mq_post_message failed!(err=%d)"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800251 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530252 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800253 goto fail;
254 }
255 return status;
256fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530257 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800258 if (!param) {
259 lim_log(mac, LOGE, FL("Dual mac config resp failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530260 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800261 }
262 param->status = SET_HW_MODE_STATUS_ECANCELED;
263 resp_msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
264 resp_msg.bodyptr = param;
265 resp_msg.bodyval = 0;
266 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530267 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800268}
269
270/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800271 * lim_process_set_antenna_mode_req() - Set antenna mode command
272 * to WMA
273 * @mac: Global MAC pointer
274 * @msg: Message containing the antenna mode parameter
275 *
276 * Send the set antenna mode command to WMA
277 *
278 * Return: QDF_STATUS_SUCCESS if message posting is successful
279 */
280static QDF_STATUS lim_process_set_antenna_mode_req(tpAniSirGlobal mac,
281 uint32_t *msg)
282{
283 QDF_STATUS status = QDF_STATUS_SUCCESS;
284 cds_msg_t cds_message;
285 struct sir_antenna_mode_param *req_msg;
286 struct sir_set_antenna_mode *buf;
287 tSirMsgQ resp_msg;
288 struct sir_antenna_mode_resp *param;
289
290 buf = (struct sir_set_antenna_mode *) msg;
291 if (!buf) {
292 lim_log(mac, LOGE, FL("Set antenna mode is NULL"));
293 /* To free the active command list */
294 goto fail;
295 }
296
297 req_msg = qdf_mem_malloc(sizeof(*req_msg));
298 if (!req_msg) {
299 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
300 return QDF_STATUS_E_NOMEM;
301 }
302
303 req_msg->num_rx_chains = buf->set_antenna_mode.num_rx_chains;
304 req_msg->num_tx_chains = buf->set_antenna_mode.num_tx_chains;
305
306 cds_message.bodyptr = req_msg;
307 cds_message.type = SIR_HAL_SOC_ANTENNA_MODE_REQ;
308
309 lim_log(mac, LOG1,
310 FL("Post SIR_HAL_SOC_ANTENNA_MODE_REQ to WMA: %d %d"),
311 req_msg->num_rx_chains,
312 req_msg->num_tx_chains);
313 status = cds_mq_post_message(CDS_MQ_ID_WMA, &cds_message);
314 if (!QDF_IS_STATUS_SUCCESS(status)) {
315 lim_log(mac, LOGE,
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -0700316 FL("cds_mq_post_message failed!(err=%d)"),
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800317 status);
318 qdf_mem_free(req_msg);
319 goto fail;
320 }
321 return status;
322fail:
323 param = qdf_mem_malloc(sizeof(*param));
324 if (!param) {
325 lim_log(mac, LOGE, FL("antenna mode resp failed"));
326 return QDF_STATUS_E_NOMEM;
327 }
328 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
329 resp_msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
330 resp_msg.bodyptr = param;
331 resp_msg.bodyval = 0;
332 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
333 return QDF_STATUS_SUCCESS;
334}
335
336/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800337 * __lim_fresh_scan_reqd() - determine if a fresh scan request must be issued.
338 * @mac_ctx: Pointer to Global MAC structure
339 * @return_fresh_results: Trigger fresh scan.
340 *
341 * PE will do fresh scan, if all of the active sessions are in
342 * good state (Link Est or BSS Started). If one of the sessions
343 * is not in one of the above states, then PE does not do fresh
344 * scan. If no session exists (scanning very first time),
345 * then PE will always do fresh scan if SME asks it to do that.
346 *
347 * Return: true for fresh scan results, false if in invalid state.
348 */
349static uint8_t
350__lim_fresh_scan_reqd(tpAniSirGlobal mac_ctx, uint8_t return_fresh_results)
351{
352 uint8_t valid_state = true;
353 int i;
354
355 lim_log(mac_ctx, LOG1, FL("gLimSmeState: %d, returnFreshResults 0x%x"),
356 mac_ctx->lim.gLimSmeState, return_fresh_results);
357
358 if (mac_ctx->lim.gLimSmeState != eLIM_SME_IDLE_STATE) {
359 lim_log(mac_ctx, LOG1, FL("return FALSE"));
360 return false;
361 }
362
363 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
Naveen Rawatb6a951a2016-06-21 15:02:37 -0700364
365 if (mac_ctx->lim.gpSession[i].valid == false)
366 continue;
367
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800368 lim_log(mac_ctx, LOG1,
369 FL("session %d, bsstype %d, limSystemRole %d, limSmeState %d"),
370 i, mac_ctx->lim.gpSession[i].bssType,
371 mac_ctx->lim.gpSession[i].limSystemRole,
372 mac_ctx->lim.gpSession[i].limSmeState);
Naveen Rawatb6a951a2016-06-21 15:02:37 -0700373
374 if (mac_ctx->lim.gpSession[i].bssType == eSIR_NDI_MODE)
375 continue;
376
377 if (mac_ctx->lim.gpSession[i].bssType ==
378 eSIR_INFRASTRUCTURE_MODE &&
379 mac_ctx->lim.gpSession[i].limSmeState ==
380 eLIM_SME_LINK_EST_STATE)
381 continue;
382
383 if (mac_ctx->lim.gpSession[i].bssType == eSIR_IBSS_MODE &&
384 mac_ctx->lim.gpSession[i].limSmeState ==
385 eLIM_SME_NORMAL_STATE)
386 continue;
387
388 if (mac_ctx->lim.gpSession[i].bssType == eSIR_INFRA_AP_MODE &&
389 mac_ctx->lim.gpSession[i].pePersona ==
390 QDF_P2P_GO_MODE &&
391 mac_ctx->lim.gpSession[i].limSmeState ==
392 eLIM_SME_NORMAL_STATE)
393 continue;
394
395 if (mac_ctx->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE &&
396 mac_ctx->lim.gpSession[i].limSmeState ==
397 eLIM_SME_NORMAL_STATE)
398 continue;
399
400 valid_state = false;
401 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800402 }
403
404 lim_log(mac_ctx, LOG1, FL("valid_state: %d"), valid_state);
405
406 if ((valid_state) &&
407 (return_fresh_results & SIR_BG_SCAN_RETURN_FRESH_RESULTS))
408 return true;
409 else
410 return false;
411}
412
413/**
414 * __lim_is_sme_assoc_cnf_valid()
415 *
416 ***FUNCTION:
417 * This function is called by __lim_process_sme_assoc_cnf_new() upon
418 * receiving SME_ASSOC_CNF.
419 *
420 ***LOGIC:
421 * Message validity checks are performed in this function
422 *
423 ***ASSUMPTIONS:
424 *
425 ***NOTE:
426 *
427 * @param pMeasReq Pointer to Received ASSOC_CNF message
428 * @return true When received SME_ASSOC_CNF is formatted
429 * correctly
430 * false otherwise
431 */
432
433static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
434{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530435 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800436 return false;
437 else
438 return true;
439} /*** end __lim_is_sme_assoc_cnf_valid() ***/
440
441/**
442 * __lim_get_sme_join_req_size_for_alloc()
443 *
444 ***FUNCTION:
445 * This function is called in various places to get IE length
446 * from tSirBssDescription structure
447 * number being scanned.
448 *
449 ***PARAMS:
450 *
451 ***LOGIC:
452 *
453 ***ASSUMPTIONS:
454 * NA
455 *
456 ***NOTE:
457 * NA
458 *
459 * @param pBssDescr
460 * @return Total IE length
461 */
462
463static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
464{
465 uint16_t len = 0;
466
467 if (!pBuf)
468 return len;
469
470 pBuf += sizeof(uint16_t);
471 len = lim_get_u16(pBuf);
472 return len + sizeof(uint16_t);
473}
474
475/**
476 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
477 * @pMac: Global MAC context
478 * @pMsg: Pointer to message posted from SME to LIM.
479 *
480 * Has role only if 11h is enabled. Not used on STA side.
481 * Defers the message if SME is in learn state and brings
482 * the LIM back to normal mode.
483 *
484 * Return: true - If defered false - Otherwise
485 */
486
487static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
488{
489 if (lim_is_system_in_scan_state(pMac)) {
490 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
491 lim_log(pMac, LOGE, FL("Could not defer Msg = %d"),
492 pMsg->type);
493 return false;
494 }
495 lim_log(pMac, LOG1,
496 FL("Defer the message, in learn mode type = %d"),
497 pMsg->type);
498 return true;
499 }
500 return false;
501}
502
503/**
504 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
505 * @mac_ctx: Pointer to Global MAC structure
506 * @message: Pointer to message posted from SME to LIM.
507 *
508 * Has role only if 11h is enabled. Not used on STA side.
509 * Defers the message if radar is detected.
510 *
511 * Return: true, if defered otherwise return false.
512 */
513static bool
514__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx, tpSirMsgQ message)
515{
516 /*
517 * fRadarDetCurOperChan will be set only if we
518 * detect radar in current operating channel and
519 * System Role == AP ROLE
520 *
521 * TODO: Need to take care radar detection.
522 *
523 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
524 */
525 if (0) {
526 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
527 lim_log(mac_ctx, LOGE, FL("Could not defer Msg = %d"),
528 message->type);
529 return false;
530 }
531 lim_log(mac_ctx, LOG1,
532 FL("Defer the message, in learn mode type = %d"),
533 message->type);
534 return true;
535 }
536 return false;
537}
538
539/**
540 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
541 * @pMac: Global MAC context
542 * @pMsgBuf: Message from WMA
543 *
544 * handles the notification from HDD. PE just forwards this message to HAL.
545 *
546 * Return: true-Posting to HAL failed, so PE will consume the buffer.
547 * false-Posting to HAL successful, so HAL will consume the buffer.
548 */
549
550static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
551{
552 tSirMsgQ msg;
553 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
554
555 msg.type = WMA_SYS_READY_IND;
556 msg.reserved = 0;
557 msg.bodyptr = pMsgBuf;
558 msg.bodyval = 0;
559
560 if (ANI_DRIVER_TYPE(pMac) != eDRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800561 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
Naveen Rawat0fc3f692016-06-22 14:30:54 -0700562 pe_register_callbacks_with_wma(pMac, ready_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800563 pMac->lim.add_bssdescr_callback = ready_req->add_bssdescr_cb;
564 }
565 PELOGW(lim_log(pMac, LOGW, FL("sending WMA_SYS_READY_IND msg to HAL"));)
566 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
567
568 if (eSIR_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
569 lim_log(pMac, LOGP, FL("wma_post_ctrl_msg failed"));
570 return true;
571 }
572 return false;
573}
574
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800575/**
576 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
577 *@mac_ctx: Pointer to Global MAC structure
578 *@session: A pointer to session entry
579 *@sme_start_bss_req: Start BSS Request from upper layers.
580 *
581 * This function is used to configure the start bss parameters
582 * in to the session.
583 *
584 * Return: None.
585 */
586static void
587lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
588 tpSirSmeStartBssReq sme_start_bss_req)
589{
590 session->limSystemRole = eLIM_AP_ROLE;
591 session->privacy = sme_start_bss_req->privacy;
592 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
593 session->authType = sme_start_bss_req->authType;
594 /* Store the DTIM period */
595 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
596 /* Enable/disable UAPSD */
597 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530598 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800599 session->proxyProbeRspEn = 0;
600 } else {
601 /*
602 * To detect PBC overlap in SAP WPS mode,
603 * Host handles Probe Requests.
604 */
605 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
606 session->proxyProbeRspEn = 1;
607 else
608 session->proxyProbeRspEn = 0;
609 }
610 session->ssidHidden = sme_start_bss_req->ssidHidden;
611 session->wps_state = sme_start_bss_req->wps_state;
612 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +0530613 session->vendor_vht_sap =
614 sme_start_bss_req->vendor_vht_sap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800615 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
616 &session->shortSlotTimeSupported);
617 session->isCoalesingInIBSSAllowed =
618 sme_start_bss_req->isCoalesingInIBSSAllowed;
619
620}
621
622/**
623 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
624 *@mac_ctx: Pointer to Global MAC structure
625 *@msg_buf: A pointer to the SME message buffer
626 *
627 * This function is called to process SME_START_BSS_REQ message
628 * from HDD or upper layer application.
629 *
630 * Return: None
631 */
632static void
633__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
634{
635 uint16_t size;
636 uint32_t val = 0;
637 tSirRetStatus ret_status;
638 tSirMacChanNum channel_number;
639 tLimMlmStartReq *mlm_start_req = NULL;
640 tpSirSmeStartBssReq sme_start_bss_req = NULL;
641 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
642 /* Flag Used in case of IBSS to Auto generate BSSID. */
643 uint32_t auto_gen_bssid = false;
644 uint8_t session_id;
645 tpPESession session = NULL;
646 uint8_t sme_session_id = 0;
647 uint16_t sme_transaction_id = 0;
648 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700649 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800650 tSirRetStatus cfg_get_wmi_dfs_master_param = eSIR_SUCCESS;
651
652/* FEATURE_WLAN_DIAG_SUPPORT */
653#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
654 /*
655 * Since the session is not created yet, sending NULL.
656 * The response should have the correct state.
657 */
658 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
659 NULL, 0, 0);
660#endif /* FEATURE_WLAN_DIAG_SUPPORT */
661
662 lim_log(mac_ctx, LOG1, FL("Received START_BSS_REQ"));
663
664 /*
665 * Global Sme state and mlm states are not defined yet,
666 * for BT-AMP Suppoprt . TO BE DONE
667 */
668 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
669 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
670 size = sizeof(tSirSmeStartBssReq);
671
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530672 sme_start_bss_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800673 if (NULL == sme_start_bss_req) {
674 lim_log(mac_ctx, LOGE,
675 FL("Allocate Memory fail for LimStartBssReq"));
676 /* Send failure response to host */
677 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
678 goto end;
679 }
680
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530681 qdf_mem_set((void *)sme_start_bss_req, size, 0);
682 qdf_mem_copy(sme_start_bss_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800683 sizeof(tSirSmeStartBssReq));
684 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
685 sme_start_bss_req)) {
686 lim_log(mac_ctx, LOGW,
687 FL("Received invalid eWNI_SME_START_BSS_REQ"));
688 ret_code = eSIR_SME_INVALID_PARAMETERS;
689 goto free;
690 }
691
692 /*
693 * This is the place where PE is going to create a session.
694 * If session is not existed, then create a new session
695 */
696 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800697 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800698 if (session != NULL) {
699 lim_log(mac_ctx, LOGW,
700 FL("Session Already exists for given BSSID"));
701 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
702 session = NULL;
703 goto free;
704 } else {
705 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800706 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800707 &session_id, mac_ctx->lim.maxStation,
708 sme_start_bss_req->bssType);
709 if (session == NULL) {
710 lim_log(mac_ctx, LOGW,
711 FL("Session Can not be created "));
712 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
713 goto free;
714 }
715 }
716
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700717 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
718 /* Probe resp add ie */
719 lim_start_bss_update_add_ie_buffer(mac_ctx,
720 &session->addIeParams.probeRespData_buff,
721 &session->addIeParams.probeRespDataLen,
722 sme_start_bss_req->addIeParams.
723 probeRespData_buff,
724 sme_start_bss_req->addIeParams.
725 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800726
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700727 /* Probe Beacon add ie */
728 lim_start_bss_update_add_ie_buffer(mac_ctx,
729 &session->addIeParams.probeRespBCNData_buff,
730 &session->addIeParams.probeRespBCNDataLen,
731 sme_start_bss_req->addIeParams.
732 probeRespBCNData_buff,
733 sme_start_bss_req->addIeParams.
734 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800735
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700736 /* Assoc resp IE */
737 lim_start_bss_update_add_ie_buffer(mac_ctx,
738 &session->addIeParams.assocRespData_buff,
739 &session->addIeParams.assocRespDataLen,
740 sme_start_bss_req->addIeParams.
741 assocRespData_buff,
742 sme_start_bss_req->addIeParams.
743 assocRespDataLen);
744 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800745 /* Store the session related params in newly created session */
746 session->pLimStartBssReq = sme_start_bss_req;
747
748 /* Store PE session_id in session Table */
749 session->peSessionId = session_id;
750
751 /* Store SME session Id in sessionTable */
752 session->smeSessionId = sme_start_bss_req->sessionId;
753
754 session->transactionId = sme_start_bss_req->transactionId;
755
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530756 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800757 &(sme_start_bss_req->htConfig),
758 sizeof(session->htConfig));
759
Sandeep Puligilla98917432016-06-10 13:50:28 -0700760 qdf_mem_copy(&(session->vht_config),
761 &(sme_start_bss_req->vht_config),
762 sizeof(session->vht_config));
763
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800764 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800765 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800766
767 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530768 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800769 (uint8_t *) &sme_start_bss_req->ssId,
770 (sme_start_bss_req->ssId.length + 1));
771
772 session->bssType = sme_start_bss_req->bssType;
773
774 session->nwType = sme_start_bss_req->nwType;
775
776 session->beaconParams.beaconInterval =
777 sme_start_bss_req->beaconInterval;
778
779 /* Store the channel number in session Table */
780 session->currentOperChannel =
781 sme_start_bss_req->channelId;
782
783 /* Store Persona */
784 session->pePersona = sme_start_bss_req->bssPersona;
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("PE PERSONA=%d"), session->pePersona);
787
788 /* Update the phymode */
789 session->gLimPhyMode = sme_start_bss_req->nwType;
790
791 session->maxTxPower =
792 cfg_get_regulatory_max_transmit_power(mac_ctx,
793 session->currentOperChannel);
794 /* Store the dot 11 mode in to the session Table */
795 session->dot11mode = sme_start_bss_req->dot11mode;
796#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
797 session->cc_switch_mode =
798 sme_start_bss_req->cc_switch_mode;
799#endif
800 session->htCapability =
801 IS_DOT11_MODE_HT(session->dot11mode);
802 session->vhtCapability =
803 IS_DOT11_MODE_VHT(session->dot11mode);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530804 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800805 FL("*****session->vhtCapability = %d"),
806 session->vhtCapability);
807 session->txLdpcIniFeatureEnabled =
808 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800809#ifdef WLAN_FEATURE_11W
810 session->limRmfEnabled =
811 sme_start_bss_req->pmfCapable ? 1 : 0;
812 lim_log(mac_ctx, LOG1, FL("Session RMF enabled: %d"),
813 session->limRmfEnabled);
814#endif
815
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530816 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800817 (void *)&sme_start_bss_req->operationalRateSet,
818 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530819 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800820 (void *)&sme_start_bss_req->extendedRateSet,
821 sizeof(tSirMacRateSet));
822
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700823 if (IS_5G_CH(session->currentOperChannel))
824 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
825 else
826 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
827
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800828 switch (sme_start_bss_req->bssType) {
829 case eSIR_INFRA_AP_MODE:
830 lim_configure_ap_start_bss_session(mac_ctx, session,
831 sme_start_bss_req);
Krunal Soni53993f72016-07-08 18:20:03 -0700832 if (session->pePersona == QDF_SAP_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700833 session->vdev_nss = vdev_type_nss->sap;
Krunal Soni53993f72016-07-08 18:20:03 -0700834 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700835 session->vdev_nss = vdev_type_nss->p2p_go;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800836 break;
837 case eSIR_IBSS_MODE:
838 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
839 lim_get_short_slot_from_phy_mode(mac_ctx, session,
840 session->gLimPhyMode,
841 &session->shortSlotTimeSupported);
842
843 /*
844 * initialize to "OPEN".
845 * will be updated upon key installation
846 */
847 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700848 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800849
850 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700851 case eSIR_NDI_MODE:
852 session->limSystemRole = eLIM_NDI_ROLE;
853 break;
854
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800855
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800856 /*
857 * There is one more mode called auto mode.
858 * which is used no where
859 */
860
861 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
862
863 default:
864 /* not used anywhere...used in scan function */
865 break;
866 }
867
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700868 lim_log(mac_ctx, LOG1, FL("persona - %d, nss - %d"),
869 session->pePersona, session->vdev_nss);
870 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800871 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700872 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800873 * parsed (Re)Assoc request structure
874 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700875 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800876 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530877 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700878 size * sizeof(tpSirAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800879 if (NULL == session->parsedAssocReq) {
880 lim_log(mac_ctx, LOGW,
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700881 FL("AllocateMemory() failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800882 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
883 goto free;
884 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530885 qdf_mem_set(session->parsedAssocReq,
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700886 (session->dph.dphHashTable.size *
887 sizeof(tpSirAssocReq)), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800888 }
889
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700890 if (!sme_start_bss_req->channelId &&
891 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800892 lim_log(mac_ctx, LOGE,
893 FL("Received invalid eWNI_SME_START_BSS_REQ"));
894 ret_code = eSIR_SME_INVALID_PARAMETERS;
895 goto free;
896 }
897 channel_number = sme_start_bss_req->channelId;
898#ifdef QCA_HT_2040_COEX
899 if (sme_start_bss_req->obssEnabled)
900 session->htSupportedChannelWidthSet =
901 session->htCapability;
902 else
903#endif
904 session->htSupportedChannelWidthSet =
905 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
906 session->htSecondaryChannelOffset =
907 sme_start_bss_req->sec_ch_offset;
908 session->htRecommendedTxWidthSet =
909 (session->htSecondaryChannelOffset) ? 1 : 0;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530910 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800911 FL("cbMode %u"), sme_start_bss_req->cbMode);
912 if (session->vhtCapability || session->htCapability) {
913 chanwidth = sme_start_bss_req->vht_channel_width;
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800914 lim_log(mac_ctx, LOG1,
915 FL("vht_channel_width %u htSupportedChannelWidthSet %d"),
916 sme_start_bss_req->vht_channel_width,
917 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800918 session->ch_width = chanwidth;
919 if (session->htSupportedChannelWidthSet) {
920 session->ch_center_freq_seg0 =
921 sme_start_bss_req->center_freq_seg0;
922 session->ch_center_freq_seg1 =
923 sme_start_bss_req->center_freq_seg1;
924 } else {
925 session->ch_center_freq_seg0 = 0;
926 session->ch_center_freq_seg1 = 0;
927 }
928 }
929
930 if (session->vhtCapability &&
Krunal Soni53993f72016-07-08 18:20:03 -0700931 (session->ch_width > CH_WIDTH_80MHZ)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800932 session->nss = 1;
Krunal Soni53993f72016-07-08 18:20:03 -0700933 lim_log(mac_ctx, LOG1, FL("nss set to [%d]"),
934 session->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800935 }
Krunal Soni53993f72016-07-08 18:20:03 -0700936 lim_log(mac_ctx, LOG1, FL("vht su tx bformer %d"),
937 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800938
939 /* Delete pre-auth list if any */
940 lim_delete_pre_auth_list(mac_ctx);
941
Krunal Soni53993f72016-07-08 18:20:03 -0700942 if (session->nss == 1) {
943 session->vht_config.su_beam_former = 0;
944 session->vht_config.tx_stbc = 0;
945 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530946 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -0700947 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800948 /*
949 * keep the RSN/WPA IE information in PE Session Entry
950 * later will be using this to check when received (Re)Assoc req
951 */
952 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
953 &sme_start_bss_req->rsnIE, session);
954
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700955 if (LIM_IS_AP_ROLE(session) ||
956 LIM_IS_IBSS_ROLE(session) ||
957 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800958 session->gLimProtectionControl =
959 sme_start_bss_req->protEnabled;
960 /*
961 * each byte will have the following info
962 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
963 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
964 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530965 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800966 (void *)&sme_start_bss_req->ht_capab,
967 sizeof(uint16_t));
968 /* Initialize WPS PBC session link list */
969 session->pAPWPSPBCSession = NULL;
970 }
971 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530972 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800973 if (NULL == mlm_start_req) {
974 lim_log(mac_ctx, LOGP,
975 FL("Allocate Memory failed for mlmStartReq"));
976 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
977 goto free;
978 }
979
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530980 qdf_mem_set((void *)mlm_start_req, sizeof(tLimMlmStartReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800981
982 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530983 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800984 (uint8_t *) &sme_start_bss_req->ssId,
985 sme_start_bss_req->ssId.length + 1);
986 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
987 mlm_start_req->obssProtEnabled =
988 sme_start_bss_req->obssProtEnabled;
989
990 mlm_start_req->bssType = session->bssType;
991
992 /* Fill PE session Id from the session Table */
993 mlm_start_req->sessionId = session->peSessionId;
994
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700995 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
996 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800997 /*
998 * Copy the BSSId from sessionTable to
999 * mlmStartReq struct
1000 */
1001 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
1002 } else {
1003 /* ibss mode */
1004 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1005
1006 ret_status = wlan_cfg_get_int(mac_ctx,
1007 WNI_CFG_IBSS_AUTO_BSSID,
1008 &auto_gen_bssid);
1009 if (ret_status != eSIR_SUCCESS) {
1010 lim_log(mac_ctx, LOGP,
1011 FL("Get Auto Gen BSSID fail,Status=%d"),
1012 ret_status);
1013 ret_code = eSIR_LOGP_EXCEPTION;
1014 goto free;
1015 }
1016
1017 if (!auto_gen_bssid) {
1018 /*
1019 * We're not auto generating BSSID.
1020 * Instead, get it from session entry
1021 */
1022 sir_copy_mac_addr(mlm_start_req->bssId,
1023 session->bssId);
1024 /*
1025 * Start IBSS group BSSID
1026 * Auto Generating BSSID.
1027 */
1028 auto_gen_bssid = ((mlm_start_req->bssId[0] &
1029 0x01) ? true : false);
1030 }
1031
1032 if (auto_gen_bssid) {
1033 /*
1034 * if BSSID is not any uc id.
1035 * then use locally generated BSSID.
1036 * Autogenerate the BSSID
1037 */
1038 lim_get_random_bssid(mac_ctx,
1039 mlm_start_req->bssId);
1040 mlm_start_req->bssId[0] = 0x02;
1041
1042 /*
1043 * Copy randomly generated BSSID
1044 * to the session Table
1045 */
1046 sir_copy_mac_addr(session->bssId,
1047 mlm_start_req->bssId);
1048 }
1049 }
1050 /* store the channel num in mlmstart req structure */
1051 mlm_start_req->channelNumber = session->currentOperChannel;
1052 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
1053 mlm_start_req->beaconPeriod =
1054 session->beaconParams.beaconInterval;
1055
1056 if (LIM_IS_AP_ROLE(session)) {
1057 mlm_start_req->dtimPeriod = session->dtimPeriod;
1058 mlm_start_req->wps_state = session->wps_state;
1059
1060 } else {
1061 if (wlan_cfg_get_int(mac_ctx,
1062 WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
1063 lim_log(mac_ctx, LOGP,
1064 FL("could not retrieve DTIM Period"));
1065 mlm_start_req->dtimPeriod = (uint8_t) val;
1066 }
1067
1068 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_PERIOD, &val) !=
1069 eSIR_SUCCESS)
1070 lim_log(mac_ctx, LOGP,
1071 FL("could not retrieve Beacon interval"));
1072 mlm_start_req->cfParamSet.cfpPeriod = (uint8_t) val;
1073
1074 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_MAX_DURATION, &val) !=
1075 eSIR_SUCCESS)
1076 lim_log(mac_ctx, LOGP,
1077 FL("could not retrieve CFPMaxDuration"));
1078 mlm_start_req->cfParamSet.cfpMaxDuration = (uint16_t) val;
1079
1080 /*
1081 * this may not be needed anymore now,
1082 * as rateSet is now included in the
1083 * session entry and MLM has session context.
1084 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301085 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001086 (void *)&session->rateSet,
1087 sizeof(tSirMacRateSet));
1088
1089 /* Now populate the 11n related parameters */
1090 mlm_start_req->nwType = session->nwType;
1091 mlm_start_req->htCapable = session->htCapability;
1092
1093 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1094 /* Unused */
1095 mlm_start_req->dualCTSProtection =
1096 mac_ctx->lim.gHTDualCTSProtection;
1097 mlm_start_req->txChannelWidthSet =
1098 session->htRecommendedTxWidthSet;
1099
1100 session->limRFBand = lim_get_rf_band(channel_number);
1101
1102 /* Initialize 11h Enable Flag */
1103 session->lim11hEnable = 0;
1104 if ((mlm_start_req->bssType != eSIR_IBSS_MODE) &&
1105 (SIR_BAND_5_GHZ == session->limRFBand)) {
1106 if (wlan_cfg_get_int(mac_ctx,
1107 WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
1108 lim_log(mac_ctx, LOGP,
1109 FL("Fail to get WNI_CFG_11H_ENABLED "));
1110 else
1111 session->lim11hEnable = val;
1112
1113 if (session->lim11hEnable &&
1114 (eSIR_INFRA_AP_MODE ==
1115 mlm_start_req->bssType)) {
1116 cfg_get_wmi_dfs_master_param =
1117 wlan_cfg_get_int(mac_ctx,
1118 WNI_CFG_DFS_MASTER_ENABLED,
1119 &val);
1120 session->lim11hEnable = val;
1121 }
1122 if (cfg_get_wmi_dfs_master_param != eSIR_SUCCESS)
1123 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
1124 lim_log(mac_ctx, LOGE,
1125 FL("Get Fail, CFG DFS ENABLE"));
1126 }
1127
1128 if (!session->lim11hEnable) {
1129 if (cfg_set_int(mac_ctx,
1130 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
1131 eSIR_SUCCESS)
1132 /*
1133 * Failed to set the CFG param
1134 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1135 */
1136 lim_log(mac_ctx, LOGE,
1137 FL("Set LOCAL_POWER_CONSTRAINT failed"));
1138 }
1139
1140 session->limPrevSmeState = session->limSmeState;
1141 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1142 MTRACE(mac_trace
1143 (mac_ctx, TRACE_CODE_SME_STATE,
1144 session->peSessionId,
1145 session->limSmeState));
1146
1147 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1148 (uint32_t *) mlm_start_req);
1149 return;
1150 } else {
1151
1152 lim_log(mac_ctx, LOGE,
1153 FL("Received unexpected START_BSS_REQ, in state %X"),
1154 mac_ctx->lim.gLimSmeState);
1155 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
1156 goto end;
1157 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1158
1159free:
1160 if ((session != NULL) &&
1161 (session->pLimStartBssReq == sme_start_bss_req)) {
1162 session->pLimStartBssReq = NULL;
1163 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301164 qdf_mem_free(sme_start_bss_req);
1165 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001166
1167end:
1168 if (sme_start_bss_req != NULL) {
1169 sme_session_id = sme_start_bss_req->sessionId;
1170 sme_transaction_id = sme_start_bss_req->transactionId;
1171 }
1172 if (NULL != session) {
1173 pe_delete_session(mac_ctx, session);
1174 session = NULL;
1175 }
1176 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1177 session, sme_session_id, sme_transaction_id);
1178}
1179
1180/**
1181 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1182 *
1183 * @pMac: Global MAC context
1184 * @pMsg: Message pointer
1185 *
1186 * Wrapper for the function __lim_handle_sme_start_bss_request
1187 * This message will be defered until softmac come out of
1188 * scan mode or if we have detected radar on the current
1189 * operating channel.
1190 *
1191 * return true - If we consumed the buffer
1192 * false - If have defered the message.
1193 */
1194static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1195{
1196 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1197 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1198 /**
1199 * If message defered, buffer is not consumed yet.
1200 * So return false
1201 */
1202 return false;
1203 }
1204
1205 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1206 return true;
1207}
1208
1209/**
1210 * lim_get_random_bssid()
1211 *
1212 * FUNCTION:This function is called to process generate the random number for bssid
1213 * This function is called to process SME_SCAN_REQ message
1214 * from HDD or upper layer application.
1215 *
1216 * LOGIC:
1217 *
1218 * ASSUMPTIONS:
1219 *
1220 * NOTE:
1221 * 1. geneartes the unique random number for bssid in ibss
1222 *
1223 * @param pMac Pointer to Global MAC structure
1224 * @param *data Pointer to bssid buffer
1225 * @return None
1226 */
1227void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1228{
1229 uint32_t random[2];
1230 random[0] = tx_time_get();
1231 random[0] |= (random[0] << 15);
1232 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301233 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001234}
1235
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301236static QDF_STATUS lim_send_hal_start_scan_offload_req(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001237 tpSirSmeScanReq pScanReq)
1238{
1239 tSirScanOffloadReq *pScanOffloadReq;
1240 uint8_t *p;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001241 tSirMsgQ msg;
1242 uint16_t i, len;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001243 uint16_t addn_ie_len = 0;
Naveen Rawat02e12662016-08-31 16:49:27 -07001244 uint8_t *vendor_tpc_ie;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001245 tSirRetStatus status, rc = eSIR_SUCCESS;
1246 tDot11fIEExtCap extracted_extcap = {0};
1247 bool extcap_present = true;
Naveen Rawat02e12662016-08-31 16:49:27 -07001248 uint32_t lim_11h_enable = WNI_CFG_11H_ENABLED_STADEF;
1249
1250 wlan_cfg_get_int(pMac, WNI_CFG_11H_ENABLED, &lim_11h_enable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001251
1252 if (pScanReq->uIEFieldLen) {
1253 status = lim_strip_extcap_update_struct(pMac,
1254 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1255 &pScanReq->uIEFieldLen, &extracted_extcap);
1256
1257 if (eSIR_SUCCESS != status) {
1258 extcap_present = false;
1259 lim_log(pMac, LOG1,
1260 FL("Unable to Strip ExtCap IE from Scan Req"));
1261 }
1262
1263 if (extcap_present) {
1264 lim_log(pMac, LOG1,
1265 FL("Extcap was part of SCAN IE - Updating FW"));
1266 lim_send_ext_cap_ie(pMac, pScanReq->sessionId,
1267 &extracted_extcap, true);
1268 }
1269 } else {
1270 lim_log(pMac, LOG1,
1271 FL("No IEs in the scan request from supplicant"));
1272 }
1273
1274 /**
1275 * The tSirScanOffloadReq will reserve the space for first channel,
1276 * so allocate the memory for (numChannels - 1) and uIEFieldLen
1277 */
1278 len = sizeof(tSirScanOffloadReq) +
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001279 (pScanReq->channelList.numChannels - 1) +
1280 pScanReq->uIEFieldLen;
Naveen Rawat02e12662016-08-31 16:49:27 -07001281
1282 if (lim_11h_enable) {
1283 addn_ie_len += DOT11F_IE_WFATPC_MAX_LEN + 2;
1284 len += DOT11F_IE_WFATPC_MAX_LEN + 2;
1285 }
1286
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301287 pScanOffloadReq = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001288 if (NULL == pScanOffloadReq) {
1289 lim_log(pMac, LOGE,
1290 FL("AllocateMemory failed for pScanOffloadReq"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301291 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001292 }
1293
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301294 qdf_mem_set((uint8_t *) pScanOffloadReq, len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001295
1296 msg.type = WMA_START_SCAN_OFFLOAD_REQ;
1297 msg.bodyptr = pScanOffloadReq;
1298 msg.bodyval = 0;
1299
Anurag Chouhanc5548422016-02-24 18:33:27 +05301300 qdf_copy_macaddr(&pScanOffloadReq->bssId, &pScanReq->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001301
1302 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID) {
1303 lim_log(pMac, LOGE,
1304 FL("Invalid value (%d) for numSsid"),
1305 SIR_SCAN_MAX_NUM_SSID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301306 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301307 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001308 }
1309
1310 pScanOffloadReq->numSsid = pScanReq->numSsid;
1311 for (i = 0; i < pScanOffloadReq->numSsid; i++) {
1312 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301313 qdf_mem_copy((uint8_t *) pScanOffloadReq->ssId[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001314 (uint8_t *) pScanReq->ssId[i].ssId,
1315 pScanOffloadReq->ssId[i].length);
1316 }
1317
1318 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301319 qdf_copy_macaddr(&pScanOffloadReq->selfMacAddr, &pScanReq->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001320 pScanOffloadReq->bssType = pScanReq->bssType;
1321 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1322 pScanOffloadReq->scanType = pScanReq->scanType;
1323 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1324 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1325 pScanOffloadReq->restTime = pScanReq->restTime;
Agrawal Ashish17bb3902016-05-05 13:29:40 +05301326 pScanOffloadReq->min_rest_time = pScanReq->min_rest_time;
1327 pScanOffloadReq->idle_time = pScanReq->idle_time;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301328 pScanOffloadReq->scan_adaptive_dwell_mode =
1329 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001330
1331 /* for normal scan, the value for p2pScanType should be 0
1332 always */
1333 if (pScanReq->p2pSearch)
1334 pScanOffloadReq->p2pScanType = P2P_SCAN_TYPE_SEARCH;
1335
1336 pScanOffloadReq->sessionId = pScanReq->sessionId;
1337 pScanOffloadReq->scan_id = pScanReq->scan_id;
Deepak Dhamdhered97bfb32015-10-11 15:16:18 -07001338 pScanOffloadReq->scan_requestor_id = USER_SCAN_REQUESTOR_ID;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301339 pScanOffloadReq->scan_adaptive_dwell_mode =
1340 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001341
1342 if (pScanOffloadReq->sessionId >= pMac->lim.maxBssId)
1343 lim_log(pMac, LOGE, FL("Invalid pe sessionID : %d"),
1344 pScanOffloadReq->sessionId);
1345
1346 pScanOffloadReq->channelList.numChannels =
1347 pScanReq->channelList.numChannels;
1348 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1349 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1350 p[i] = pScanReq->channelList.channelNumber[i];
1351
1352 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1353 pScanOffloadReq->uIEFieldOffset = len - addn_ie_len -
1354 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301355 qdf_mem_copy((uint8_t *) pScanOffloadReq +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001356 pScanOffloadReq->uIEFieldOffset,
1357 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1358 pScanReq->uIEFieldLen);
Naveen Rawat02e12662016-08-31 16:49:27 -07001359
1360 if (lim_11h_enable) {
1361 tDot11fIEWFATPC wfa_tpc;
1362 vendor_tpc_ie = (uint8_t *) pScanOffloadReq +
1363 pScanOffloadReq->uIEFieldOffset +
1364 pScanOffloadReq->uIEFieldLen;
1365 populate_dot11f_wfatpc(pMac, &wfa_tpc,
1366 rrm_get_mgmt_tx_power(pMac, NULL), 0);
1367 vendor_tpc_ie[0] = DOT11F_EID_WFATPC;
1368 vendor_tpc_ie[1] = DOT11F_IE_WFATPC_MAX_LEN;
1369 qdf_mem_copy(&vendor_tpc_ie[2], SIR_MAC_WFA_TPC_OUI,
1370 SIR_MAC_WFA_TPC_OUI_SIZE);
1371 qdf_mem_copy(&vendor_tpc_ie[SIR_MAC_WFA_TPC_OUI_SIZE + 2],
1372 ((uint8_t *)&wfa_tpc) + 1,
1373 DOT11F_IE_WFATPC_MAX_LEN - SIR_MAC_WFA_TPC_OUI_SIZE);
1374 pScanOffloadReq->uIEFieldLen += DOT11F_IE_WFATPC_MAX_LEN + 2;
1375 }
1376
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001377 rc = wma_post_ctrl_msg(pMac, &msg);
1378 if (rc != eSIR_SUCCESS) {
1379 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() return failure"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301380 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301381 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001382 }
1383
1384 lim_log(pMac, LOG1, FL("Processed Offload Scan Request Successfully"));
1385
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301386 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001387}
1388
1389/**
1390 * __lim_process_sme_scan_req() - Process the SME Scan Request
1391 * @mac_ctx: Global MAC Context
1392 * @msg_buf: Buffer which contains the request and pertinent parameters
1393 *
1394 * This function is called to process SME_SCAN_REQ message
1395 * from HDD or upper layer application.
1396 *
1397 * Return: None
1398 */
1399
1400static void __lim_process_sme_scan_req(tpAniSirGlobal mac_ctx,
1401 uint32_t *msg_buf)
1402{
1403 tpSirSmeScanReq scan_req;
1404 uint8_t valid_req = 0;
1405
1406#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1407 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL,
1408 eSIR_SUCCESS, eSIR_SUCCESS);
1409#endif
1410
1411 scan_req = (tpSirSmeScanReq) msg_buf;
1412 lim_log(mac_ctx, LOG1,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301413 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 -08001414 scan_req->scan_id, scan_req->channelList.numChannels,
1415 scan_req->minChannelTime, scan_req->maxChannelTime,
1416 scan_req->uIEFieldLen, scan_req->returnAfterFirstMatch,
1417 scan_req->returnFreshResults, scan_req->returnUniqueResults,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301418 lim_scan_type_to_string(scan_req->scanType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001419 scan_req->scanType, mac_ctx->lim.gLimRspReqd ? 1 : 0);
1420 /*
1421 * Since scan req always requires a response, we will overwrite response
1422 * required here. This is added esp to take care of the condition where
1423 * in p2p go case, we hold the scan req and insert single NOA. We send
1424 * the held scan request to FW later on getting start NOA ind from FW so
1425 * we lose state of the gLimRspReqd flag for the scan req if any other
1426 * request comes by then. e.g. While unit testing, we found when insert
1427 * single NOA is done, we see a get stats request which turns the flag
1428 * gLimRspReqd to false; now when we actually start the saved scan req
1429 * for init scan after getting NOA started, the gLimRspReqd being a
1430 * global flag is showing false instead of true value for this saved
1431 * scan req. Since all scan reqs coming to lim require a response,
1432 * there is no harm in setting the global flag gLimRspReqd to true here.
1433 */
1434 mac_ctx->lim.gLimRspReqd = true;
1435
1436 /*
1437 * copy the Self MAC address from SmeReq to the globalplace,
1438 * used for sending probe req
1439 */
Srinivas Girigowda2c6bf002015-09-24 11:43:31 -07001440 sir_copy_mac_addr(mac_ctx->lim.gSelfMacAddr,
1441 scan_req->selfMacAddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001442 valid_req = lim_is_sme_scan_req_valid(mac_ctx, scan_req);
1443
1444 if (!valid_req || mac_ctx->lim.scan_disabled) {
1445 lim_log(mac_ctx, LOGE,
1446 FL("Scan disabled %d, Valid Scan Req %d"),
1447 mac_ctx->lim.scan_disabled, valid_req);
1448
1449 if (mac_ctx->lim.gLimRspReqd) {
1450 mac_ctx->lim.gLimRspReqd = false;
1451
1452 lim_send_sme_scan_rsp(mac_ctx,
1453 eSIR_SME_INVALID_PARAMETERS,
1454 scan_req->sessionId,
1455 scan_req->transactionId,
1456 scan_req->scan_id);
1457 }
1458 return;
1459 }
1460
1461 /*
1462 * If scan request is received in idle, joinFailed
1463 * states or in link established state (in STA role)
1464 * or in normal state (in STA-in-IBSS/AP role) with
1465 * 'return fresh scan results' request from HDD or
1466 * it is periodic background scanning request,
1467 * trigger fresh scan request to MLM
1468 */
1469 if (__lim_fresh_scan_reqd(mac_ctx, scan_req->returnFreshResults)) {
1470
1471 mac_ctx->lim.gLim24Band11dScanDone = 0;
1472 mac_ctx->lim.gLim50Band11dScanDone = 0;
1473 mac_ctx->lim.gLimReturnAfterFirstMatch =
1474 scan_req->returnAfterFirstMatch;
1475 mac_ctx->lim.gLimReturnUniqueResults =
1476 ((scan_req->returnUniqueResults) > 0 ? true : false);
1477
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301478 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001479 lim_send_hal_start_scan_offload_req(mac_ctx,
1480 scan_req)) {
1481 lim_log(mac_ctx, LOGE, FL(
1482 "Couldn't send Offload scan request"));
1483 lim_send_sme_scan_rsp(mac_ctx,
1484 eSIR_SME_INVALID_PARAMETERS,
1485 scan_req->sessionId,
1486 scan_req->transactionId,
1487 scan_req->scan_id);
1488 return;
1489 }
Anurag Chouhanffb21542016-02-17 14:33:03 +05301490 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001491 /* In all other cases return 'cached' scan results */
1492 if (mac_ctx->lim.gLimRspReqd) {
1493 mac_ctx->lim.gLimRspReqd = false;
1494 lim_send_sme_scan_rsp(mac_ctx, eSIR_SME_SUCCESS,
1495 scan_req->sessionId,
1496 scan_req->transactionId, scan_req->scan_id);
1497 }
1498 }
1499}
1500
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001501/**
1502 * __lim_process_clear_dfs_channel_list()
1503 *
1504 ***FUNCTION:
1505 ***Clear DFS channel list when country is changed/aquired.
1506 .*This message is sent from SME.
1507 *
1508 ***LOGIC:
1509 *
1510 ***ASSUMPTIONS:
1511 *
1512 ***NOTE:
1513 *
1514 * @param pMac Pointer to Global MAC structure
1515 * @param *pMsgBuf A pointer to the SME message buffer
1516 * @return None
1517 */
1518static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1519{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301520 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001521}
1522
1523/**
1524 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1525 * @mac_ctx: Pointer to Global MAC structure
1526 * @msg_buf: A pointer to the SME message buffer
1527 *
1528 * This function is called to process SME_JOIN_REQ message
1529 * from HDD or upper layer application.
1530 *
1531 * Return: None
1532 */
1533static void
1534__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1535{
1536 tpSirSmeJoinReq sme_join_req = NULL;
1537 tLimMlmJoinReq *mlm_join_req;
1538 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1539 uint32_t val = 0;
1540 uint16_t n_size;
1541 uint8_t session_id;
1542 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301543 uint8_t sme_session_id = 0;
1544 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001545 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001546 uint16_t ie_len;
1547 uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001548 tSirBssDescription *bss_desc;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001549 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001550
Arif Hussain995fcaf2016-07-18 11:28:22 -07001551 if (!mac_ctx || !msg_buf) {
1552 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1553 FL("JOIN REQ with invalid data"));
1554 return;
1555 }
1556
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001557/* FEATURE_WLAN_DIAG_SUPPORT */
1558#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1559 /*
1560 * Not sending any session, since it is not created yet.
1561 * The response whould have correct state.
1562 */
1563 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1564#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1565
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001566 /*
1567 * Expect Join request in idle state.
1568 * Reassociate request is expected in link established state.
1569 */
1570
1571 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1572 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1573 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1574 msg_buf);
1575
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301576 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001577 if (NULL == sme_join_req) {
1578 lim_log(mac_ctx, LOGP,
1579 FL("AllocateMemory failed for sme_join_req"));
1580 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301581 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001582 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301583 (void)qdf_mem_set((void *)sme_join_req, n_size, 0);
1584 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001585 n_size);
1586
1587 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1588 /* Received invalid eWNI_SME_JOIN_REQ */
1589 /* Log the event */
1590 lim_log(mac_ctx, LOGW,
1591 FL("SessionId:%d JOIN REQ with invalid data"),
1592 sme_join_req->sessionId);
1593 ret_code = eSIR_SME_INVALID_PARAMETERS;
1594 goto end;
1595 }
1596
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001597 /*
1598 * Update the capability here itself as this is used in
1599 * lim_extract_ap_capability() below. If not updated issues
1600 * like not honoring power constraint on 1st association after
1601 * driver loading might occur.
1602 */
1603 lim_update_rrm_capability(mac_ctx, sme_join_req);
1604
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001605 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001606 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001607 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001608 &session_id);
1609
1610 if (session != NULL) {
1611 lim_log(mac_ctx, LOGE,
1612 FL("Session(%d) Already exists for BSSID: "
1613 MAC_ADDRESS_STR " in limSmeState = %X"),
1614 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001615 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001616 session->limSmeState);
1617
1618 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1619 session->smeSessionId == sme_join_req->sessionId) {
1620 /*
1621 * Received eWNI_SME_JOIN_REQ for same
1622 * BSS as currently associated.
1623 * Log the event and send success
1624 */
1625 lim_log(mac_ctx, LOGW,
1626 FL("SessionId: %d"), session_id);
1627 lim_log(mac_ctx, LOGW,
1628 FL("JOIN_REQ for current joined BSS"));
1629 /* Send Join success response to host */
1630 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1631 session = NULL;
1632 goto end;
1633 } else {
1634 lim_log(mac_ctx, LOGE,
1635 FL("JOIN_REQ not for current joined BSS"));
1636 ret_code = eSIR_SME_REFUSED;
1637 session = NULL;
1638 goto end;
1639 }
1640 } else {
1641 /*
1642 * Session Entry does not exist for given BSSId
1643 * Try to Create a new session
1644 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001645 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001646 &session_id, mac_ctx->lim.maxStation,
1647 eSIR_INFRASTRUCTURE_MODE);
1648 if (session == NULL) {
1649 lim_log(mac_ctx, LOGE,
1650 FL("Session Can not be created "));
1651 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1652 goto end;
1653 } else
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301654 lim_log(mac_ctx, LOG2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001655 FL("SessionId:%d New session created"),
1656 session_id);
1657 }
1658 session->isAmsduSupportInAMPDU =
1659 sme_join_req->isAmsduSupportInAMPDU;
1660
1661 /*
1662 * Store Session related parameters
1663 * Store PE session Id in session Table
1664 */
1665 session->peSessionId = session_id;
1666
1667 /* store the smejoin req handle in session table */
1668 session->pLimJoinReq = sme_join_req;
1669
1670 /* Store SME session Id in sessionTable */
1671 session->smeSessionId = sme_join_req->sessionId;
1672
1673 /* Store SME transaction Id in session Table */
1674 session->transactionId = sme_join_req->transactionId;
1675
1676 /* Store beaconInterval */
1677 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001678 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001679
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301680 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001681 sizeof(session->htConfig));
1682
Sandeep Puligilla98917432016-06-10 13:50:28 -07001683 qdf_mem_copy(&(session->vht_config),
1684 &(sme_join_req->vht_config),
1685 sizeof(session->vht_config));
1686
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001687 /* Copying of bssId is already done, while creating session */
1688 sir_copy_mac_addr(session->selfMacAddr,
1689 sme_join_req->selfMacAddr);
1690 session->bssType = sme_join_req->bsstype;
1691
1692 session->statypeForBss = STA_ENTRY_PEER;
1693 session->limWmeEnabled = sme_join_req->isWMEenabled;
1694 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301695 session->wps_registration = sme_join_req->wps_registration;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001696
1697 /* Store vendor specfic IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001698 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001699 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1700
1701 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
1702 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001703 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001704
1705 if (NULL != vendor_ie) {
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08001706 lim_log(mac_ctx, LOG1, FL("Cisco vendor OUI present"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001707 session->isCiscoVendorAP = true;
1708 } else {
1709 session->isCiscoVendorAP = false;
1710 }
1711
1712 /* Copy the dot 11 mode in to the session table */
1713
1714 session->dot11mode = sme_join_req->dot11mode;
1715#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1716 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1717#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001718 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001719 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1720 session->enableHtSmps = sme_join_req->enableHtSmps;
1721 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001722 session->send_smps_action =
1723 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001724 /*
1725 * By default supported NSS 1x1 is set to true
1726 * and later on updated while determining session
1727 * supported rates which is the intersection of
1728 * self and peer rates
1729 */
1730 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301731 /*Store Persona */
1732 session->pePersona = sme_join_req->staPersona;
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001733 lim_log(mac_ctx, LOG1,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301734 FL("enable Smps: %d mode: %d send action: %d supported nss 1x1: %d pePersona %d cbMode %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001735 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001736 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001737 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301738 session->supported_nss_1x1,
1739 session->pePersona,
1740 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001741
1742 /*Store Persona */
1743 session->pePersona = sme_join_req->staPersona;
1744 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
1745 FL("PE PERSONA=%d cbMode %u"),
1746 session->pePersona, sme_join_req->cbMode);
1747 /* Copy The channel Id to the session Table */
1748 session->currentOperChannel = bss_desc->channelId;
1749 if (IS_5G_CH(session->currentOperChannel))
1750 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001751 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001752 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
1753 if (session->pePersona == QDF_P2P_CLIENT_MODE)
1754 session->vdev_nss = vdev_type_nss->p2p_cli;
1755 else
1756 session->vdev_nss = vdev_type_nss->sta;
1757 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001758 session->vhtCapability =
1759 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001760 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301761 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001762 session->vht_config.su_beam_formee =
1763 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001764 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001765 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001766 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001767 session->enableVhtpAid =
1768 sme_join_req->enableVhtpAid;
1769 session->enableVhtGid =
1770 sme_join_req->enableVhtGid;
Krunal Soni53993f72016-07-08 18:20:03 -07001771 lim_log(mac_ctx, LOG1, FL("vht su bformer [%d]"),
1772 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001773 }
Krunal Soni53993f72016-07-08 18:20:03 -07001774
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301775 lim_log(mac_ctx, LOG1,
Krunal Soni53993f72016-07-08 18:20:03 -07001776 FL("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d"),
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301777 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001778 session->vht_config.su_beam_formee,
1779 session->vht_config.csnof_beamformer_antSup,
1780 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001781 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001782 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001783 handle_ht_capabilityand_ht_info(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001784 /* cbMode is already merged value of peer and self -
1785 * done by csr in csr_get_cb_mode_from_ies */
1786 session->htSupportedChannelWidthSet =
1787 (sme_join_req->cbMode) ? 1 : 0;
1788 session->htRecommendedTxWidthSet =
1789 session->htSupportedChannelWidthSet;
1790 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1791
1792 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1793 session->ch_center_freq_seg0 =
1794 session->currentOperChannel - 2;
1795 session->ch_width = CH_WIDTH_40MHZ;
1796 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1797 sme_join_req->cbMode) {
1798 session->ch_center_freq_seg0 =
1799 session->currentOperChannel + 2;
1800 session->ch_width = CH_WIDTH_40MHZ;
1801 } else {
1802 session->ch_center_freq_seg0 = 0;
1803 session->ch_width = CH_WIDTH_20MHZ;
1804 }
1805
1806 /* Record if management frames need to be protected */
1807#ifdef WLAN_FEATURE_11W
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001808 if (eSIR_ED_AES_128_CMAC == sme_join_req->MgmtEncryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001809 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001810 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001811 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001812#endif
1813
1814#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001815 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001816#endif
1817
1818 /* Copy the SSID from smejoinreq to session entry */
1819 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301820 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001821 session->ssId.length);
1822
1823 /*
1824 * Determin 11r or ESE connection based on input from SME
1825 * which inturn is dependent on the profile the user wants
1826 * to connect to, So input is coming from supplicant
1827 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001828 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829#ifdef FEATURE_WLAN_ESE
1830 session->isESEconnection = sme_join_req->isESEconnection;
1831#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001832 session->isFastTransitionEnabled =
1833 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001834
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001835 session->isFastRoamIniFeatureEnabled =
1836 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001837 session->txLdpcIniFeatureEnabled =
1838 sme_join_req->txLdpcIniFeatureEnabled;
1839
1840 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1841 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001842 } else {
1843 /*
1844 * Throw an error and return and make
1845 * sure to delete the session.
1846 */
1847 lim_log(mac_ctx, LOGE,
1848 FL("recvd JOIN_REQ with invalid bss type %d"),
1849 session->bssType);
1850 ret_code = eSIR_SME_INVALID_PARAMETERS;
1851 goto end;
1852 }
1853
1854 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301855 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001856 &sme_join_req->addIEScan, sizeof(tSirAddie));
1857
1858 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301859 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001860 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1861
1862 val = sizeof(tLimMlmJoinReq) +
1863 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301864 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001865 if (NULL == mlm_join_req) {
1866 lim_log(mac_ctx, LOGP,
1867 FL("AllocateMemory failed for mlmJoinReq"));
Nitesh Shah0102cac2016-07-13 14:38:30 +05301868 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1869 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001870 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301871 (void)qdf_mem_set((void *)mlm_join_req, val, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001872
1873 /* PE SessionId is stored as a part of JoinReq */
1874 mlm_join_req->sessionId = session->peSessionId;
1875
1876 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1877 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1878 eSIR_SUCCESS) {
1879 lim_log(mac_ctx, LOGP,
1880 FL("couldn't retrieve JoinFailureTimer value"
1881 " setting to default value"));
1882 mlm_join_req->joinFailureTimeout =
1883 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1884 }
1885
1886 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301887 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001888 (void *)&sme_join_req->operationalRateSet,
1889 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301890 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001891 (void *)&sme_join_req->extendedRateSet,
1892 sizeof(tSirMacRateSet));
1893 /*
1894 * this may not be needed anymore now, as rateSet is now
1895 * included in the session entry and MLM has session context.
1896 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301897 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001898 (void *)&session->rateSet,
1899 sizeof(tSirMacRateSet));
1900
1901 session->encryptType = sme_join_req->UCEncryptionType;
1902
1903 mlm_join_req->bssDescription.length =
1904 session->pLimJoinReq->bssDescription.length;
1905
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301906 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001907 (uint8_t *)
1908 &session->pLimJoinReq->bssDescription.bssId,
1909 session->pLimJoinReq->bssDescription.length + 2);
1910
1911 session->limCurrentBssCaps =
1912 session->pLimJoinReq->bssDescription.capabilityInfo;
1913
1914 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1915 session->currentOperChannel);
1916 local_power_constraint = reg_max;
1917
1918 lim_extract_ap_capability(mac_ctx,
1919 (uint8_t *)
1920 session->pLimJoinReq->bssDescription.ieFields,
1921 lim_get_ielen_from_bss_description(
1922 &session->pLimJoinReq->bssDescription),
1923 &session->limCurrentBssQosCaps,
1924 &session->limCurrentBssPropCap,
1925 &session->gLimCurrentBssUapsd,
1926 &local_power_constraint, session);
1927
Krunal Soni53993f72016-07-08 18:20:03 -07001928 /*
1929 * Once the AP capabilities are available then set the
1930 * beam forming capabilities accordingly.
1931 */
1932 if (session->nss == 1) {
1933 session->vht_config.su_beam_former = 0;
1934 session->vht_config.tx_stbc = 0;
1935 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +05301936 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001937 }
1938
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001939 session->maxTxPower = lim_get_max_tx_power(reg_max,
1940 local_power_constraint,
1941 mac_ctx->roam.configParam.nTxPowerCap);
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301942
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301943 lim_log(mac_ctx, LOG1,
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301944 FL("Reg max %d local power con %d max tx pwr %d"),
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301945 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001946
1947 if (session->gLimCurrentBssUapsd) {
1948 session->gUapsdPerAcBitmask =
1949 session->pLimJoinReq->uapsdPerAcBitmask;
1950 lim_log(mac_ctx, LOG1,
1951 FL("UAPSD flag for all AC - 0x%2x"),
1952 session->gUapsdPerAcBitmask);
1953
1954 /* resetting the dynamic uapsd mask */
1955 session->gUapsdPerAcDeliveryEnableMask = 0;
1956 session->gUapsdPerAcTriggerEnableMask = 0;
1957 }
1958
1959 session->limRFBand =
1960 lim_get_rf_band(session->currentOperChannel);
1961
1962 /* Initialize 11h Enable Flag */
1963 if (SIR_BAND_5_GHZ == session->limRFBand) {
1964 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1965 &val) != eSIR_SUCCESS) {
1966 lim_log(mac_ctx, LOGP,
1967 FL("Fail to get WNI_CFG_11H_ENABLED "));
1968 session->lim11hEnable =
1969 WNI_CFG_11H_ENABLED_STADEF;
1970 } else {
1971 session->lim11hEnable = val;
1972 }
1973 } else {
1974 session->lim11hEnable = 0;
1975 }
1976
1977 /*
1978 * To care of the scenario when STA transitions from
1979 * IBSS to Infrastructure mode.
1980 */
1981 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1982
1983 session->limPrevSmeState = session->limSmeState;
1984 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1985 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1986 session->peSessionId,
1987 session->limSmeState));
1988
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001989 /* Indicate whether spectrum management is enabled */
1990 session->spectrumMgtEnabled =
1991 sme_join_req->spectrumMgtIndicator;
1992
1993 /* Enable the spectrum management if this is a DFS channel */
1994 if (session->country_info_present &&
1995 lim_isconnected_on_dfs_channel(
1996 session->currentOperChannel))
1997 session->spectrumMgtEnabled = true;
1998
1999 session->isOSENConnection = sme_join_req->isOSENConnection;
2000
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002001 /* Issue LIM_MLM_JOIN_REQ to MLM */
2002 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
2003 (uint32_t *) mlm_join_req);
2004 return;
2005
2006 } else {
2007 /* Received eWNI_SME_JOIN_REQ un expected state */
2008 lim_log(mac_ctx, LOGE,
2009 FL("received unexpected SME_JOIN_REQ in state %X"),
2010 mac_ctx->lim.gLimSmeState);
2011 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
2012 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2013 session = NULL;
2014 goto end;
2015 }
2016
2017end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05302018 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2019 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002020
2021 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302022 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002023 sme_join_req = NULL;
2024 if (NULL != session)
2025 session->pLimJoinReq = NULL;
2026 }
2027 if (ret_code != eSIR_SME_SUCCESS) {
2028 if (NULL != session) {
2029 pe_delete_session(mac_ctx, session);
2030 session = NULL;
2031 }
2032 }
2033 lim_log(mac_ctx, LOG1,
2034 FL("Send failure status on sessionid: %d with ret_code = %d"),
2035 sme_session_id, ret_code);
2036 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
2037 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
2038 sme_transaction_id);
2039}
2040
Amar Singhala297bfa2015-10-15 15:07:29 -07002041uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002042 uint8_t iniTxPower)
2043{
2044 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302045 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
2046 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002047 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2048 maxTxPower = txPower;
2049 else if (txPower < MIN_TX_PWR_CAP)
2050 maxTxPower = MIN_TX_PWR_CAP;
2051 else
2052 maxTxPower = MAX_TX_PWR_CAP;
2053
2054 return maxTxPower;
2055}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002056
2057/**
2058 * __lim_process_sme_reassoc_req() - process reassoc req
2059 *
2060 * @mac_ctx: Pointer to Global MAC structure
2061 * @msg_buf: pointer to the SME message buffer
2062 *
2063 * This function is called to process SME_REASSOC_REQ message
2064 * from HDD or upper layer application.
2065 *
2066 * Return: None
2067 */
2068
2069static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2070 uint32_t *msg_buf)
2071{
2072 uint16_t caps;
2073 uint32_t val;
2074 tpSirSmeJoinReq reassoc_req = NULL;
2075 tLimMlmReassocReq *mlm_reassoc_req;
2076 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2077 tpPESession session_entry = NULL;
2078 uint8_t session_id;
2079 uint8_t sme_session_id;
2080 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002081 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002082 uint32_t tele_bcn_en = 0;
2083 uint16_t size;
2084
2085 lim_log(mac_ctx, LOG3, FL("Received REASSOC_REQ"));
2086
2087 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302088 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002089 if (NULL == reassoc_req) {
2090 lim_log(mac_ctx, LOGP,
2091 FL("call to AllocateMemory failed for reassoc_req"));
2092
2093 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2094 goto end;
2095 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302096 (void)qdf_mem_set((void *)reassoc_req, size, 0);
2097 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002098
2099 if (!lim_is_sme_join_req_valid(mac_ctx,
2100 (tpSirSmeJoinReq)reassoc_req)) {
2101 /*
2102 * Received invalid eWNI_SME_REASSOC_REQ
2103 */
2104 lim_log(mac_ctx, LOGW,
2105 FL("received SME_REASSOC_REQ with invalid data"));
2106
2107 ret_code = eSIR_SME_INVALID_PARAMETERS;
2108 goto end;
2109 }
2110
2111 session_entry = pe_find_session_by_bssid(mac_ctx,
2112 reassoc_req->bssDescription.bssId,
2113 &session_id);
2114 if (session_entry == NULL) {
2115 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2116 LOGE);
2117 lim_log(mac_ctx, LOGE,
2118 FL("Session does not exist for given bssId"));
2119 ret_code = eSIR_SME_INVALID_PARAMETERS;
2120 goto end;
2121 }
2122#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2123 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2124 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2125#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2126 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2127
2128 /* Store the reassoc handle in the session Table */
2129 session_entry->pLimReAssocReq = reassoc_req;
2130
2131 session_entry->dot11mode = reassoc_req->dot11mode;
2132 session_entry->vhtCapability =
2133 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002134
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302135 if (session_entry->vhtCapability) {
2136 if (session_entry->pePersona == QDF_STA_MODE) {
2137 session_entry->vht_config.su_beam_formee =
2138 reassoc_req->vht_config.su_beam_formee;
2139 } else {
2140 reassoc_req->vht_config.su_beam_formee = 0;
2141 }
2142 session_entry->enableVhtpAid =
2143 reassoc_req->enableVhtpAid;
2144 session_entry->enableVhtGid =
2145 reassoc_req->enableVhtGid;
2146 lim_log(mac_ctx, LOG1, FL("vht su bformer [%d]"),
2147 session_entry->vht_config.su_beam_former);
2148 }
2149
2150 lim_log(mac_ctx, LOG1,
2151 FL("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d"),
2152 session_entry->vhtCapability,
2153 session_entry->vht_config.su_beam_formee,
2154 session_entry->vht_config.su_beam_former);
2155
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002156 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2157 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002158 session_entry->send_smps_action =
2159 reassoc_req->send_smps_action;
2160 lim_log(mac_ctx, LOG1,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002161 FL("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002162 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002163 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002164 session_entry->send_smps_action,
2165 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002166 /*
2167 * Reassociate request is expected
2168 * in link established state only.
2169 */
2170
2171 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002172 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2173 /*
2174 * May be from 11r FT pre-auth. So lets check it
2175 * before we bail out
2176 */
2177 lim_log(mac_ctx, LOG1, FL(
2178 "Session in reassoc state is %d"),
2179 session_entry->peSessionId);
2180
2181 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302182 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002183 session_entry->limReAssocbssId,
2184 6)) {
2185 lim_print_mac_addr(mac_ctx,
2186 reassoc_req->bssDescription.
2187 bssId, LOGE);
2188 lim_log(mac_ctx, LOGP,
2189 FL("Unknown bssId in reassoc state"));
2190 ret_code = eSIR_SME_INVALID_PARAMETERS;
2191 goto end;
2192 }
2193
2194 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2195 session_entry);
2196 return;
2197 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002198 /*
2199 * Should not have received eWNI_SME_REASSOC_REQ
2200 */
2201 lim_log(mac_ctx, LOGE,
2202 FL("received unexpected SME_REASSOC_REQ in state %X"),
2203 session_entry->limSmeState);
2204 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2205
2206 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2207 goto end;
2208 }
2209
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302210 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002211 session_entry->pLimReAssocReq->bssDescription.bssId,
2212 sizeof(tSirMacAddr));
2213
2214 session_entry->limReassocChannelId =
2215 session_entry->pLimReAssocReq->bssDescription.channelId;
2216
2217 session_entry->reAssocHtSupportedChannelWidthSet =
2218 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2219 session_entry->reAssocHtRecommendedTxWidthSet =
2220 session_entry->reAssocHtSupportedChannelWidthSet;
2221 session_entry->reAssocHtSecondaryChannelOffset =
2222 session_entry->pLimReAssocReq->cbMode;
2223
2224 session_entry->limReassocBssCaps =
2225 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2226 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2227 session_entry->currentOperChannel);
2228 local_pwr_constraint = reg_max;
2229
2230 lim_extract_ap_capability(mac_ctx,
2231 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2232 lim_get_ielen_from_bss_description(
2233 &session_entry->pLimReAssocReq->bssDescription),
2234 &session_entry->limReassocBssQosCaps,
2235 &session_entry->limReassocBssPropCap,
2236 &session_entry->gLimCurrentBssUapsd,
2237 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302238 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002239 lim_log(mac_ctx, LOGE,
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302240 FL("Reg max = %d, local pwr constraint = %d, max tx = %d"),
2241 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002242 /* Copy the SSID from session entry to local variable */
2243 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302244 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002245 reassoc_req->ssId.ssId,
2246 session_entry->limReassocSSID.length);
2247 if (session_entry->gLimCurrentBssUapsd) {
2248 session_entry->gUapsdPerAcBitmask =
2249 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
2250 lim_log(mac_ctx, LOG1,
2251 FL("UAPSD flag for all AC - 0x%2x"),
2252 session_entry->gUapsdPerAcBitmask);
2253 }
2254
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302255 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002256 if (NULL == mlm_reassoc_req) {
2257 lim_log(mac_ctx, LOGP,
2258 FL("call to AllocateMemory failed for mlmReassocReq"));
2259
2260 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2261 goto end;
2262 }
2263
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302264 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002265 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2266
2267 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2268 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
2269 eSIR_SUCCESS) {
2270 /*
2271 * Could not get ReassocFailureTimeout value
2272 * from CFG. Log error.
2273 */
2274 lim_log(mac_ctx, LOGP,
2275 FL("could not retrieve ReassocFailureTimeout value"));
2276 }
2277
2278 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
2279 eSIR_SUCCESS) {
2280 /*
2281 * Could not get Capabilities value
2282 * from CFG. Log error.
2283 */
2284 lim_log(mac_ctx, LOGP, FL(
2285 "could not retrieve Capabilities value"));
2286 }
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302287
2288 lim_update_caps_info_for_bss(mac_ctx, &caps,
2289 reassoc_req->bssDescription.capabilityInfo);
2290 lim_log(mac_ctx, LOG1, FL("Capabilities info Reassoc: 0x%X"), caps);
2291
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002292 mlm_reassoc_req->capabilityInfo = caps;
2293
2294 /* Update PE session_id */
2295 mlm_reassoc_req->sessionId = session_id;
2296
2297 /*
2298 * If telescopic beaconing is enabled, set listen interval to
2299 * WNI_CFG_TELE_BCN_MAX_LI
2300 */
2301 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2302 &tele_bcn_en) != eSIR_SUCCESS)
2303 lim_log(mac_ctx, LOGP,
2304 FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
2305
2306 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2307
2308 if (tele_bcn_en) {
2309 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2310 eSIR_SUCCESS)
2311 /*
2312 * Could not get ListenInterval value
2313 * from CFG. Log error.
2314 */
2315 lim_log(mac_ctx, LOGP,
2316 FL("could not retrieve ListenInterval"));
2317 } else {
2318 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
2319 eSIR_SUCCESS)
2320 /*
2321 * Could not get ListenInterval value
2322 * from CFG. Log error.
2323 */
2324 lim_log(mac_ctx, LOGP,
2325 FL("could not retrieve ListenInterval"));
2326 }
2327
2328 mlm_reassoc_req->listenInterval = (uint16_t) val;
2329
2330 /* Indicate whether spectrum management is enabled */
2331 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2332
2333 /* Enable the spectrum management if this is a DFS channel */
2334 if (session_entry->country_info_present &&
2335 lim_isconnected_on_dfs_channel(
2336 session_entry->currentOperChannel))
2337 session_entry->spectrumMgtEnabled = true;
2338
2339 session_entry->limPrevSmeState = session_entry->limSmeState;
2340 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2341
2342 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2343 session_entry->peSessionId,
2344 session_entry->limSmeState));
2345
2346 lim_post_mlm_message(mac_ctx,
2347 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2348 return;
2349end:
2350 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302351 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002352 if (session_entry)
2353 session_entry->pLimReAssocReq = NULL;
2354 }
2355
2356 if (session_entry) {
2357 /*
2358 * error occurred after we determined the session so extract
2359 * session and transaction info from there
2360 */
2361 sme_session_id = session_entry->smeSessionId;
2362 transaction_id = session_entry->transactionId;
2363 } else
2364 /*
2365 * error occurred before or during the time we determined
2366 * the session so extract the session and transaction info
2367 * from the message
2368 */
2369 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2370 &sme_session_id, &transaction_id);
2371
2372 /*
2373 * Send Reassoc failure response to host
2374 * (note session_entry may be NULL, but that's OK)
2375 */
2376 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2377 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2378 session_entry, sme_session_id,
2379 transaction_id);
2380}
2381
2382bool send_disassoc_frame = 1;
2383/**
2384 * __lim_process_sme_disassoc_req()
2385 *
2386 ***FUNCTION:
2387 * This function is called to process SME_DISASSOC_REQ message
2388 * from HDD or upper layer application.
2389 *
2390 ***LOGIC:
2391 *
2392 ***ASSUMPTIONS:
2393 *
2394 ***NOTE:
2395 *
2396 * @param pMac Pointer to Global MAC structure
2397 * @param *pMsgBuf A pointer to the SME message buffer
2398 * @return None
2399 */
2400
2401static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2402{
2403 uint16_t disassocTrigger, reasonCode;
2404 tLimMlmDisassocReq *pMlmDisassocReq;
2405 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2406 tSirSmeDisassocReq smeDisassocReq;
2407 tpPESession psessionEntry = NULL;
2408 uint8_t sessionId;
2409 uint8_t smesessionId;
2410 uint16_t smetransactionId;
2411
2412 if (pMsgBuf == NULL) {
2413 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
2414 return;
2415 }
2416
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302417 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002418 smesessionId = smeDisassocReq.sessionId;
2419 smetransactionId = smeDisassocReq.transactionId;
2420 if (!lim_is_sme_disassoc_req_valid(pMac,
2421 &smeDisassocReq,
2422 psessionEntry)) {
2423 PELOGE(lim_log(pMac, LOGE,
2424 FL("received invalid SME_DISASSOC_REQ message"));)
2425 if (pMac->lim.gLimRspReqd) {
2426 pMac->lim.gLimRspReqd = false;
2427
2428 retCode = eSIR_SME_INVALID_PARAMETERS;
2429 disassocTrigger = eLIM_HOST_DISASSOC;
2430 goto sendDisassoc;
2431 }
2432
2433 return;
2434 }
2435
2436 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002437 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002438 &sessionId);
2439 if (psessionEntry == NULL) {
2440 lim_log(pMac, LOGE,
2441 FL("session does not exist for given bssId "
2442 MAC_ADDRESS_STR),
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002443 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002444 retCode = eSIR_SME_INVALID_PARAMETERS;
2445 disassocTrigger = eLIM_HOST_DISASSOC;
2446 goto sendDisassoc;
2447 }
2448 lim_log(pMac, LOG1,
2449 FL("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2450 MAC_ADDRESS_STR), smesessionId,
2451 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2452 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002453 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002454
2455#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2456 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2457 0, smeDisassocReq.reasonCode);
2458#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2459
2460 /* Update SME session Id and SME transaction ID */
2461
2462 psessionEntry->smeSessionId = smesessionId;
2463 psessionEntry->transactionId = smetransactionId;
2464
2465 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2466 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002467 switch (psessionEntry->limSmeState) {
2468 case eLIM_SME_ASSOCIATED_STATE:
2469 case eLIM_SME_LINK_EST_STATE:
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002470 lim_log(pMac, LOG1,
2471 FL("Rcvd SME_DISASSOC_REQ in limSmeState: %d "),
2472 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002473 psessionEntry->limPrevSmeState =
2474 psessionEntry->limSmeState;
2475 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2476#ifdef FEATURE_WLAN_TDLS
2477 /* Delete all TDLS peers connected before leaving BSS */
2478 lim_delete_tdls_peers(pMac, psessionEntry);
2479#endif
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002480 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2481 psessionEntry->peSessionId,
2482 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002483 break;
2484
2485 case eLIM_SME_WT_DEAUTH_STATE:
2486 /* PE shall still process the DISASSOC_REQ and proceed with
2487 * link tear down even if it had already sent a DEAUTH_IND to
2488 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2489 * its been set when PE entered WT_DEAUTH_STATE.
2490 */
2491 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2492 MTRACE(mac_trace
2493 (pMac, TRACE_CODE_SME_STATE,
2494 psessionEntry->peSessionId,
2495 psessionEntry->limSmeState));
2496 lim_log(pMac, LOG1,
2497 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE. "));
2498 break;
2499
2500 case eLIM_SME_WT_DISASSOC_STATE:
2501 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2502 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2503 * PE can continue processing DISASSOC_REQ and send the response instead
2504 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2505 * for disassoc frame.
2506 *
2507 * It will send a disassoc, which is ok. However, we can use the global flag
2508 * sendDisassoc to not send disassoc frame.
2509 */
2510 lim_log(pMac, LOG1,
2511 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE. "));
2512 break;
2513
2514 case eLIM_SME_JOIN_FAILURE_STATE: {
2515 /* Already in Disconnected State, return success */
2516 lim_log(pMac, LOG1,
2517 FL("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE. "));
2518 if (pMac->lim.gLimRspReqd) {
2519 retCode = eSIR_SME_SUCCESS;
2520 disassocTrigger = eLIM_HOST_DISASSOC;
2521 goto sendDisassoc;
2522 }
2523 }
2524 break;
2525 default:
2526 /**
2527 * STA is not currently associated.
2528 * Log error and send response to host
2529 */
2530 lim_log(pMac, LOGE,
2531 FL("received unexpected SME_DISASSOC_REQ in state %X"),
2532 psessionEntry->limSmeState);
2533 lim_print_sme_state(pMac, LOGE,
2534 psessionEntry->limSmeState);
2535
2536 if (pMac->lim.gLimRspReqd) {
2537 if (psessionEntry->limSmeState !=
2538 eLIM_SME_WT_ASSOC_STATE)
2539 pMac->lim.gLimRspReqd = false;
2540
2541 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2542 disassocTrigger = eLIM_HOST_DISASSOC;
2543 goto sendDisassoc;
2544 }
2545
2546 return;
2547 }
2548
2549 break;
2550
2551 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002552 /* Fall through */
2553 break;
2554
2555 case eLIM_STA_IN_IBSS_ROLE:
2556 default:
2557 /* eLIM_UNKNOWN_ROLE */
2558 lim_log(pMac, LOGE,
2559 FL("received unexpected SME_DISASSOC_REQ for role %d"),
2560 GET_LIM_SYSTEM_ROLE(psessionEntry));
2561
2562 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2563 disassocTrigger = eLIM_HOST_DISASSOC;
2564 goto sendDisassoc;
2565 } /* end switch (pMac->lim.gLimSystemRole) */
2566
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302567 disassocTrigger = eLIM_HOST_DISASSOC;
2568 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002569
2570 if (smeDisassocReq.doNotSendOverTheAir) {
2571 lim_log(pMac, LOG1, FL("do not send dissoc over the air"));
2572 send_disassoc_frame = 0;
2573 }
2574 /* Trigger Disassociation frame to peer MAC entity */
2575 lim_log(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2576 " : %d, reasonCode : %d"),
2577 disassocTrigger, reasonCode);
2578
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302579 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002580 if (NULL == pMlmDisassocReq) {
2581 /* Log error */
2582 lim_log(pMac, LOGP,
2583 FL("call to AllocateMemory failed for mlmDisassocReq"));
2584
2585 return;
2586 }
2587
Anurag Chouhanc5548422016-02-24 18:33:27 +05302588 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002589 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002590
2591 pMlmDisassocReq->reasonCode = reasonCode;
2592 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2593
2594 /* Update PE session ID */
2595 pMlmDisassocReq->sessionId = sessionId;
2596
2597 lim_post_mlm_message(pMac,
2598 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2599 return;
2600
2601sendDisassoc:
2602 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002603 lim_send_sme_disassoc_ntf(pMac,
2604 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002605 retCode,
2606 disassocTrigger,
2607 1, smesessionId, smetransactionId,
2608 psessionEntry);
2609 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002610 lim_send_sme_disassoc_ntf(pMac,
2611 smeDisassocReq.peer_macaddr.bytes,
2612 retCode, disassocTrigger, 1,
2613 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002614
2615} /*** end __lim_process_sme_disassoc_req() ***/
2616
2617/** -----------------------------------------------------------------
2618 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2619
2620 This function is called to process SME_DISASSOC_CNF message
2621 from HDD or upper layer application.
2622
2623 \param pMac - global mac structure
2624 \param pStaDs - station dph hash node
2625 \return none
2626 \sa
2627 ----------------------------------------------------------------- */
2628static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2629{
2630 tSirSmeDisassocCnf smeDisassocCnf;
2631 uint16_t aid;
2632 tpDphHashNode pStaDs;
2633 tpPESession psessionEntry;
2634 uint8_t sessionId;
2635
2636 PELOG1(lim_log(pMac, LOG1, FL("received DISASSOC_CNF message"));)
2637
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302638 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002639 sizeof(struct sSirSmeDisassocCnf));
2640
2641 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002642 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002643 &sessionId);
2644 if (psessionEntry == NULL) {
2645 lim_log(pMac, LOGE,
2646 FL("session does not exist for given bssId"));
2647 return;
2648 }
2649
2650 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
2651 lim_log(pMac, LOGE,
2652 FL("received invalid SME_DISASSOC_CNF message"));
2653 return;
2654 }
2655#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2656 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2657 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2658 psessionEntry,
2659 (uint16_t) smeDisassocCnf.statusCode, 0);
2660 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2661 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2662 psessionEntry,
2663 (uint16_t) smeDisassocCnf.statusCode, 0);
2664#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2665
2666 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2667 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002668 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2669 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2670 && (psessionEntry->limSmeState !=
2671 eLIM_SME_WT_DEAUTH_STATE)) {
2672 lim_log(pMac, LOGE,
2673 FL
2674 ("received unexp SME_DISASSOC_CNF in state %X"),
2675 psessionEntry->limSmeState);
2676 lim_print_sme_state(pMac, LOGE,
2677 psessionEntry->limSmeState);
2678 return;
2679 }
2680 break;
2681
2682 case eLIM_AP_ROLE:
2683 /* Fall through */
2684 break;
2685
2686 case eLIM_STA_IN_IBSS_ROLE:
2687 default: /* eLIM_UNKNOWN_ROLE */
2688 lim_log(pMac, LOGE,
2689 FL("received unexpected SME_DISASSOC_CNF role %d"),
2690 GET_LIM_SYSTEM_ROLE(psessionEntry));
2691
2692 return;
2693 }
2694
2695 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2696 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2697 LIM_IS_AP_ROLE(psessionEntry)) {
2698 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002699 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002700 &psessionEntry->dph.dphHashTable);
2701 if (pStaDs == NULL) {
2702 lim_log(pMac, LOGE,
2703 FL("DISASSOC_CNF for a STA with no context, addr= "
2704 MAC_ADDRESS_STR),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002705 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002706 return;
2707 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302708
2709 if ((pStaDs->mlmStaContext.mlmState ==
2710 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2711 (pStaDs->mlmStaContext.mlmState ==
2712 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
2713 lim_log(pMac, LOGE,
2714 FL("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d"),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002715 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302716 pStaDs->mlmStaContext.mlmState);
2717 return;
2718 }
2719
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002720 /* Delete FT session if there exists one */
2721 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002722 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2723
2724 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002725 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002726 }
2727
2728 return;
2729}
2730
2731/**
2732 * __lim_process_sme_deauth_req() - process sme deauth req
2733 * @mac_ctx: Pointer to Global MAC structure
2734 * @msg_buf: pointer to the SME message buffer
2735 *
2736 * This function is called to process SME_DEAUTH_REQ message
2737 * from HDD or upper layer application.
2738 *
2739 * Return: None
2740 */
2741
2742static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2743 uint32_t *msg_buf)
2744{
2745 uint16_t deauth_trigger, reason_code;
2746 tLimMlmDeauthReq *mlm_deauth_req;
2747 tSirSmeDeauthReq sme_deauth_req;
2748 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2749 tpPESession session_entry;
2750 uint8_t session_id; /* PE sessionId */
2751 uint8_t sme_session_id;
2752 uint16_t sme_transaction_id;
2753
2754 lim_log(mac_ctx, LOG1, FL("received DEAUTH_REQ message"));
2755
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302756 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002757 sme_session_id = sme_deauth_req.sessionId;
2758 sme_transaction_id = sme_deauth_req.transactionId;
2759
2760 /*
2761 * We need to get a session first but we don't even know
2762 * if the message is correct.
2763 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002764 session_entry = pe_find_session_by_bssid(mac_ctx,
2765 sme_deauth_req.bssid.bytes,
2766 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002767 if (session_entry == NULL) {
2768 lim_log(mac_ctx, LOGE,
2769 FL("session does not exist for given bssId"));
2770 ret_code = eSIR_SME_INVALID_PARAMETERS;
2771 deauth_trigger = eLIM_HOST_DEAUTH;
2772 goto send_deauth;
2773 }
2774
2775 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2776 session_entry)) {
2777 lim_log(mac_ctx, LOGE,
2778 FL("received invalid SME_DEAUTH_REQ message"));
2779 mac_ctx->lim.gLimRspReqd = false;
2780
2781 ret_code = eSIR_SME_INVALID_PARAMETERS;
2782 deauth_trigger = eLIM_HOST_DEAUTH;
2783 goto send_deauth;
2784 }
2785 lim_log(mac_ctx, LOG1,
2786 FL("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2787 MAC_ADDRESS_STR), sme_session_id,
2788 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2789 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002790 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002791#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2792 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2793 session_entry, 0, sme_deauth_req.reasonCode);
2794#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2795
2796 /* Update SME session ID and Transaction ID */
2797 session_entry->smeSessionId = sme_session_id;
2798 session_entry->transactionId = sme_transaction_id;
2799
2800 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2801 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002802 switch (session_entry->limSmeState) {
2803 case eLIM_SME_ASSOCIATED_STATE:
2804 case eLIM_SME_LINK_EST_STATE:
2805 case eLIM_SME_WT_ASSOC_STATE:
2806 case eLIM_SME_JOIN_FAILURE_STATE:
2807 case eLIM_SME_IDLE_STATE:
2808 session_entry->limPrevSmeState =
2809 session_entry->limSmeState;
2810 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2811 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2812 session_entry->peSessionId,
2813 session_entry->limSmeState));
2814 /* Send Deauthentication request to MLM below */
2815 break;
2816 case eLIM_SME_WT_DEAUTH_STATE:
2817 case eLIM_SME_WT_DISASSOC_STATE:
2818 /*
2819 * PE Recieved a Deauth/Disassoc frame. Normally it get
2820 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2821 * Which means host is also trying to disconnect.
2822 * PE can continue processing DEAUTH_REQ and send
2823 * the response instead of failing the request.
2824 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2825 * was sent for deauth/disassoc frame.
2826 */
2827 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2828 lim_log(mac_ctx, LOG1, FL(
2829 "Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE"));
2830 break;
2831 default:
2832 /*
2833 * STA is not in a state to deauthenticate with
2834 * peer. Log error and send response to host.
2835 */
2836 lim_log(mac_ctx, LOGE, FL(
2837 "received unexp SME_DEAUTH_REQ in state %X"),
2838 session_entry->limSmeState);
2839 lim_print_sme_state(mac_ctx, LOGE,
2840 session_entry->limSmeState);
2841
2842 if (mac_ctx->lim.gLimRspReqd) {
2843 mac_ctx->lim.gLimRspReqd = false;
2844
2845 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2846 deauth_trigger = eLIM_HOST_DEAUTH;
2847
2848 /*
2849 * here we received deauth request from AP so sme state
2850 * is eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED
2851 * delSta then mlm state should be
2852 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got delBSS
2853 * rsp then mlm state should be eLIM_MLM_IDLE_STATE
2854 * so the below condition captures the state where
2855 * delSta not done and firmware still in
2856 * connected state.
2857 */
2858 if (session_entry->limSmeState ==
2859 eLIM_SME_WT_DEAUTH_STATE &&
2860 session_entry->limMlmState !=
2861 eLIM_MLM_IDLE_STATE &&
2862 session_entry->limMlmState !=
2863 eLIM_MLM_WT_DEL_STA_RSP_STATE)
2864 ret_code = eSIR_SME_DEAUTH_STATUS;
2865 goto send_deauth;
2866 }
2867 return;
2868 }
2869 break;
2870
2871 case eLIM_STA_IN_IBSS_ROLE:
2872 lim_log(mac_ctx, LOGE, FL("Deauth not allowed in IBSS"));
2873 if (mac_ctx->lim.gLimRspReqd) {
2874 mac_ctx->lim.gLimRspReqd = false;
2875 ret_code = eSIR_SME_INVALID_PARAMETERS;
2876 deauth_trigger = eLIM_HOST_DEAUTH;
2877 goto send_deauth;
2878 }
2879 return;
2880 case eLIM_AP_ROLE:
2881 break;
2882 default:
2883 lim_log(mac_ctx, LOGE,
2884 FL("received unexpected SME_DEAUTH_REQ for role %X"),
2885 GET_LIM_SYSTEM_ROLE(session_entry));
2886 if (mac_ctx->lim.gLimRspReqd) {
2887 mac_ctx->lim.gLimRspReqd = false;
2888 ret_code = eSIR_SME_INVALID_PARAMETERS;
2889 deauth_trigger = eLIM_HOST_DEAUTH;
2890 goto send_deauth;
2891 }
2892 return;
2893 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2894
2895 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2896 /* Deauthentication is triggered by Link Monitoring */
2897 lim_log(mac_ctx, LOG1, FL("** Lost link with AP **"));
2898 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2899 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2900 } else {
2901 deauth_trigger = eLIM_HOST_DEAUTH;
2902 reason_code = sme_deauth_req.reasonCode;
2903 }
2904
2905 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302906 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002907 if (NULL == mlm_deauth_req) {
2908 lim_log(mac_ctx, LOGP,
2909 FL("call to AllocateMemory failed for mlmDeauthReq"));
2910 if (mac_ctx->lim.gLimRspReqd) {
2911 mac_ctx->lim.gLimRspReqd = false;
2912 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2913 deauth_trigger = eLIM_HOST_DEAUTH;
2914 goto send_deauth;
2915 }
2916 return;
2917 }
2918
Anurag Chouhanc5548422016-02-24 18:33:27 +05302919 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002920 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002921
2922 mlm_deauth_req->reasonCode = reason_code;
2923 mlm_deauth_req->deauthTrigger = deauth_trigger;
2924
2925 /* Update PE session Id */
2926 mlm_deauth_req->sessionId = session_id;
2927
2928 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2929 (uint32_t *)mlm_deauth_req);
2930 return;
2931
2932send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002933 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2934 ret_code, deauth_trigger, 1,
2935 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002936}
2937
2938/**
2939 * __lim_process_sme_set_context_req()
2940 *
2941 * @mac_ctx: Pointer to Global MAC structure
2942 * @msg_buf: pointer to the SME message buffer
2943 *
2944 * This function is called to process SME_SETCONTEXT_REQ message
2945 * from HDD or upper layer application.
2946 *
2947 * Return: None
2948 */
2949
2950static void
2951__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2952{
2953 tpSirSmeSetContextReq set_context_req;
2954 tLimMlmSetKeysReq *mlm_set_key_req;
2955 tpPESession session_entry;
2956 uint8_t session_id; /* PE sessionID */
2957 uint8_t sme_session_id;
2958 uint16_t sme_transaction_id;
2959
2960 lim_log(mac_ctx, LOG1, FL("received SETCONTEXT_REQ message"));
2961
2962 if (msg_buf == NULL) {
2963 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
2964 return;
2965 }
2966
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302967 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002968 if (NULL == set_context_req) {
2969 lim_log(mac_ctx, LOGP, FL(
2970 "call to AllocateMemory failed for set_context_req"));
2971 return;
2972 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302973 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002974 sizeof(struct sSirSmeSetContextReq));
2975 sme_session_id = set_context_req->sessionId;
2976 sme_transaction_id = set_context_req->transactionId;
2977
2978 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
2979 lim_log(mac_ctx, LOGW,
2980 FL("received invalid SME_SETCONTEXT_REQ message"));
2981 goto end;
2982 }
2983
2984 if (set_context_req->keyMaterial.numKeys >
2985 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
2986 lim_log(mac_ctx, LOGE, FL(
2987 "numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS"),
2988 set_context_req->keyMaterial.numKeys);
2989 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002990 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002991 eSIR_SME_INVALID_PARAMETERS, NULL,
2992 sme_session_id, sme_transaction_id);
2993 goto end;
2994 }
2995
2996 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002997 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002998 if (session_entry == NULL) {
2999 lim_log(mac_ctx, LOGW,
3000 FL("Session does not exist for given BSSID"));
3001 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003002 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003003 eSIR_SME_INVALID_PARAMETERS, NULL,
3004 sme_session_id, sme_transaction_id);
3005 goto end;
3006 }
3007#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3008 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
3009 session_entry, 0, 0);
3010#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3011
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003012 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003013 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3014 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003015 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003016 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
3017 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303018 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003019 if (NULL == mlm_set_key_req) {
3020 lim_log(mac_ctx, LOGP, FL(
3021 "mem alloc failed for mlmSetKeysReq"));
3022 goto end;
3023 }
3024 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
3025 mlm_set_key_req->numKeys =
3026 set_context_req->keyMaterial.numKeys;
3027 if (mlm_set_key_req->numKeys >
3028 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3029 lim_log(mac_ctx, LOGP, FL(
3030 "no.of keys exceeded max num of default keys limit"));
3031 goto end;
3032 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05303033 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003034 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003035
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303036 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003037 (uint8_t *) &set_context_req->keyMaterial.key,
3038 sizeof(tSirKeys) *
3039 (mlm_set_key_req->numKeys ? mlm_set_key_req->
3040 numKeys : 1));
3041
3042 mlm_set_key_req->sessionId = session_id;
3043 mlm_set_key_req->smesessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003044 lim_log(mac_ctx, LOG1, FL(
3045 "received SETCONTEXT_REQ message sessionId=%d"),
3046 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003047
3048 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
3049 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
3050 LIM_IS_AP_ROLE(session_entry)) {
3051 if (set_context_req->keyMaterial.key[0].keyLength) {
3052 uint8_t key_id;
3053 key_id =
3054 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303055 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003056 &session_entry->WEPKeyMaterial[key_id],
3057 (uint8_t *) &set_context_req->keyMaterial,
3058 sizeof(tSirKeyMaterial));
3059 } else {
3060 uint32_t i;
3061 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
3062 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303063 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003064 &mlm_set_key_req->key[i],
3065 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
3066 sizeof(tSirKeys));
3067 }
3068 }
3069 }
3070 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
3071 (uint32_t *) mlm_set_key_req);
3072 } else {
3073 lim_log(mac_ctx, LOGE, FL(
3074 "rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
3075 GET_LIM_SYSTEM_ROLE(session_entry),
3076 session_entry->limSmeState);
3077 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
3078
3079 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003080 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003081 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
3082 session_entry, sme_session_id,
3083 sme_transaction_id);
3084 }
3085end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303086 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003087 return;
3088}
3089
3090/**
3091 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
3092 *
3093 * @mac_ctx: Pointer to Global MAC structure
3094 * @msg_buf: pointer to the SME message buffer
3095 *
3096 * This function is called to process SME_GET_ASSOC_STAS_REQ message
3097 * from HDD or upper layer application.
3098 *
3099 * Return: None
3100 */
3101
3102void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
3103 uint32_t *msg_buf)
3104{
3105 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3106 tpDphHashNode sta_ds = NULL;
3107 tpPESession session_entry = NULL;
3108 tSap_Event sap_event;
3109 tpWLAN_SAPEventCB sap_event_cb = NULL;
3110 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3111 uint8_t session_id = CSR_SESSION_ID_INVALID;
3112 uint8_t assoc_id = 0;
3113 uint8_t sta_cnt = 0;
3114
3115 if (msg_buf == NULL) {
3116 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3117 return;
3118 }
3119
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303120 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003121 sizeof(struct sSirSmeGetAssocSTAsReq));
3122 /*
3123 * Get Associated stations from PE.
3124 * Find PE session Entry
3125 */
3126 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003127 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003128 &session_id);
3129 if (session_entry == NULL) {
3130 lim_log(mac_ctx, LOGE,
3131 FL("session does not exist for given bssId"));
3132 goto lim_assoc_sta_end;
3133 }
3134
3135 if (!LIM_IS_AP_ROLE(session_entry)) {
3136 lim_log(mac_ctx, LOGE, FL(
3137 "Received unexpected message in state %X, in role %X"),
3138 session_entry->limSmeState,
3139 GET_LIM_SYSTEM_ROLE(session_entry));
3140 goto lim_assoc_sta_end;
3141 }
3142 /* Retrieve values obtained in the request message */
3143 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3144 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3145
3146 if (NULL == assoc_sta_tmp)
3147 goto lim_assoc_sta_end;
3148 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3149 assoc_id++) {
3150 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3151 &session_entry->dph.dphHashTable);
3152 if (NULL == sta_ds)
3153 continue;
3154 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303155 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003156 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303157 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003158 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3159 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3160
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303161 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003162 (uint8_t *)&sta_ds->supportedRates,
3163 sizeof(tSirSupportedRates));
3164 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3165 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3166 assoc_sta_tmp->Support40Mhz =
3167 sta_ds->htDsssCckRate40MHzSupport;
3168
3169 lim_log(mac_ctx, LOG1, FL("dph Station Number = %d"),
3170 sta_cnt + 1);
3171 lim_log(mac_ctx, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3172 MAC_ADDR_ARRAY(sta_ds->staAddr));
3173 lim_log(mac_ctx, LOG1, FL("Association Id = %d"),
3174 sta_ds->assocId);
3175 lim_log(mac_ctx, LOG1, FL("Station Index = %d"),
3176 sta_ds->staIndex);
3177 assoc_sta_tmp++;
3178 sta_cnt++;
3179 }
3180 }
3181lim_assoc_sta_end:
3182 /*
3183 * Call hdd callback with sap event to send the list of
3184 * associated stations from PE
3185 */
3186 if (sap_event_cb != NULL) {
3187 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3188 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303189 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003190 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3191 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3192 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3193 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3194 }
3195}
3196
3197/**
3198 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3199 *
3200 * @mac_ctx: Pointer to Global MAC structure
3201 * @msg_buf: pointer to WPS PBC overlap query message
3202 *
3203 * This function parses get WPS PBC overlap information
3204 * message and call callback to pass WPS PBC overlap
3205 * information back to hdd.
3206 *
3207 * Return: None
3208 */
3209void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3210 uint32_t *msg_buf)
3211{
3212 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3213 tpPESession session_entry = NULL;
3214 tSap_Event sap_event;
3215 tpWLAN_SAPEventCB sap_event_cb = NULL;
3216 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003217 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3218
3219 if (msg_buf == NULL) {
3220 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3221 return;
3222 }
3223
3224 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303225 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003226
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303227 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003228 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3229 /*
3230 * Get Associated stations from PE
3231 * Find PE session Entry
3232 */
3233 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003234 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003235 if (session_entry == NULL) {
3236 lim_log(mac_ctx, LOGE,
3237 FL("session does not exist for given bssId"));
3238 goto lim_get_wpspbc_sessions_end;
3239 }
3240
3241 if (!LIM_IS_AP_ROLE(session_entry)) {
3242 lim_log(mac_ctx, LOGE,
3243 FL("Received unexpected message in role %X"),
3244 GET_LIM_SYSTEM_ROLE(session_entry));
3245 goto lim_get_wpspbc_sessions_end;
3246 }
3247 /*
3248 * Call hdd callback with sap event to send the
3249 * WPS PBC overlap information
3250 */
3251 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303252 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003253
Anurag Chouhanc5548422016-02-24 18:33:27 +05303254 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003255 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003256 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003257 sap_get_wpspbc_event->UUID_E,
3258 &sap_get_wpspbc_event->wpsPBCOverlap,
3259 session_entry);
3260 } else {
3261 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003262 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003263 session_entry);
3264 /* don't have to inform the HDD/Host */
3265 return;
3266 }
3267
3268 lim_log(mac_ctx, LOGE, FL("wpsPBCOverlap %d"),
3269 sap_get_wpspbc_event->wpsPBCOverlap);
3270 lim_print_mac_addr(mac_ctx,
3271 sap_get_wpspbc_event->addr.bytes, LOG4);
3272
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303273 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003274
3275lim_get_wpspbc_sessions_end:
3276 sap_event_cb =
3277 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3278 if (NULL != sap_event_cb)
3279 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3280}
3281
3282/**
3283 * __lim_counter_measures()
3284 *
3285 * FUNCTION:
3286 * This function is called to "implement" MIC counter measure
3287 * and is *temporary* only
3288 *
3289 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3290 * we don't do the proper STA disassoc sequence since the
3291 * BSS will be stoped anyway
3292 *
3293 ***ASSUMPTIONS:
3294 *
3295 ***NOTE:
3296 *
3297 * @param pMac Pointer to Global MAC structure
3298 * @return None
3299 */
3300
3301static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3302{
3303 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003304 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003305 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3306 mac, psessionEntry, false);
3307};
3308
3309void lim_process_tkip_counter_measures(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3310{
3311 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3312 tpPESession psessionEntry;
3313 uint8_t sessionId; /* PE sessionId */
3314
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303315 qdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003316 sizeof(struct sSirSmeTkipCntrMeasReq));
3317
3318 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003319 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003320 if (NULL == psessionEntry) {
3321 lim_log(pMac, LOGE,
3322 FL("session does not exist for given BSSID "));
3323 return;
3324 }
3325
3326 if (tkipCntrMeasReq.bEnable)
3327 __lim_counter_measures(pMac, psessionEntry);
3328
3329 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3330}
3331
3332static void
3333__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3334{
3335 tSirSmeStopBssReq stopBssReq;
3336 tSirRetStatus status;
3337 tLimSmeStates prevState;
3338 tpPESession psessionEntry;
3339 uint8_t smesessionId;
3340 uint8_t sessionId;
3341 uint16_t smetransactionId;
3342 uint8_t i = 0;
3343 tpDphHashNode pStaDs = NULL;
3344
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303345 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003346 smesessionId = stopBssReq.sessionId;
3347 smetransactionId = stopBssReq.transactionId;
3348
3349 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
3350 PELOGW(lim_log(pMac, LOGW,
3351 FL("received invalid SME_STOP_BSS_REQ message"));)
3352 /* Send Stop BSS response to host */
3353 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3354 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3355 smetransactionId);
3356 return;
3357 }
3358
3359 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003360 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003361 &sessionId);
3362 if (psessionEntry == NULL) {
3363 lim_log(pMac, LOGW,
3364 FL("session does not exist for given BSSID "));
3365 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3366 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3367 smetransactionId);
3368 return;
3369 }
3370#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3371 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3372 0, 0);
3373#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3374
3375 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3376 LIM_IS_STA_ROLE(psessionEntry)) {
3377 /**
3378 * Should not have received STOP_BSS_REQ in states
3379 * other than 'normal' state or on STA in Infrastructure
3380 * mode. Log error and return response to host.
3381 */
3382 lim_log(pMac, LOGE,
3383 FL
3384 ("received unexpected SME_STOP_BSS_REQ in state %X, for role %d"),
3385 psessionEntry->limSmeState,
3386 GET_LIM_SYSTEM_ROLE(psessionEntry));
3387 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3388 /* / Send Stop BSS response to host */
3389 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3390 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3391 smetransactionId);
3392 return;
3393 }
3394
3395 if (LIM_IS_AP_ROLE(psessionEntry))
3396 lim_wpspbc_close(pMac, psessionEntry);
3397
3398 lim_log(pMac, LOGW,
3399 FL("RECEIVED STOP_BSS_REQ with reason code=%d"),
3400 stopBssReq.reasonCode);
3401
3402 prevState = psessionEntry->limSmeState;
3403
3404 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3405 MTRACE(mac_trace
3406 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3407 psessionEntry->limSmeState));
3408
3409 /* Update SME session Id and Transaction Id */
3410 psessionEntry->smeSessionId = smesessionId;
3411 psessionEntry->transactionId = smetransactionId;
3412
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003413 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3414 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3415 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003416 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3417 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3418 /* Send disassoc all stations associated thru TKIP */
3419 __lim_counter_measures(pMac, psessionEntry);
3420 else
3421 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003422 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3423 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003424 }
3425
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003426 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3427 /* Free the buffer allocated in START_BSS_REQ */
3428 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3429 psessionEntry->addIeParams.probeRespDataLen = 0;
3430 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003431
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003432 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3433 psessionEntry->addIeParams.assocRespDataLen = 0;
3434 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003435
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003436 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3437 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3438 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003439
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003440 /*
3441 * lim_del_bss is also called as part of coalescing,
3442 * when we send DEL BSS followed by Add Bss msg.
3443 */
3444 pMac->lim.gLimIbssCoalescingHappened = false;
3445 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003446 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3447 pStaDs =
3448 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3449 if (NULL == pStaDs)
3450 continue;
3451 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3452 if (eSIR_SUCCESS == status) {
3453 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3454 pStaDs->assocId, psessionEntry);
3455 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3456 } else {
3457 lim_log(pMac, LOGE,
3458 FL("lim_del_sta failed with Status : %d"), status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303459 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003460 }
3461 }
3462 /* send a delBss to HAL and wait for a response */
3463 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3464
3465 if (status != eSIR_SUCCESS) {
3466 PELOGE(lim_log
3467 (pMac, LOGE, FL("delBss failed for bss %d"),
3468 psessionEntry->bssIdx);
3469 )
3470 psessionEntry->limSmeState = prevState;
3471
3472 MTRACE(mac_trace
3473 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3474 psessionEntry->limSmeState));
3475
3476 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3477 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3478 smetransactionId);
3479 }
3480}
3481
3482/**
3483 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3484 * @pMac: Global MAC context
3485 * @pMsg: Message from SME
3486 *
3487 * Wrapper for the function __lim_handle_sme_stop_bss_request
3488 * This message will be defered until softmac come out of
3489 * scan mode. Message should be handled even if we have
3490 * detected radar in the current operating channel.
3491 *
3492 * Return: true - If we consumed the buffer
3493 * false - If have defered the message.
3494 */
3495
3496static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3497{
3498 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3499 /**
3500 * If message defered, buffer is not consumed yet.
3501 * So return false
3502 */
3503 return false;
3504 }
3505 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3506 return true;
3507} /*** end __lim_process_sme_stop_bss_req() ***/
3508
3509void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3510 uint32_t body, tpPESession psessionEntry)
3511{
3512
3513 (void)body;
3514 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3515 lim_ibss_delete(pMac, psessionEntry);
3516 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3517 lim_delete_pre_auth_list(pMac);
3518 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3519 psessionEntry->smeSessionId,
3520 psessionEntry->transactionId);
3521 return;
3522}
3523
3524/**
3525 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3526 *
3527 * @mac_ctx: pointer to mac context
3528 * @msg_type: message type
3529 * @msg_buf: pointer to the SME message buffer
3530 *
3531 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3532 * in BTAMP AP.
3533 *
3534 * Return: None
3535 */
3536
3537void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3538 uint32_t *msg_buf)
3539{
3540 tSirSmeAssocCnf assoc_cnf;
3541 tpDphHashNode sta_ds = NULL;
3542 tpPESession session_entry = NULL;
3543 uint8_t session_id;
3544 tpSirAssocReq assoc_req;
3545
3546 if (msg_buf == NULL) {
3547 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL "));
3548 goto end;
3549 }
3550
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303551 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003552 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
3553 lim_log(mac_ctx, LOGE,
3554 FL("Received invalid SME_RE(ASSOC)_CNF message "));
3555 goto end;
3556 }
3557
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003558 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003559 &session_id);
3560 if (session_entry == NULL) {
3561 lim_log(mac_ctx, LOGE,
3562 FL("session does not exist for given bssId"));
3563 goto end;
3564 }
3565
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003566 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003567 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3568 (session_entry->limSmeState !=
3569 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
3570 lim_log(mac_ctx, LOGE, FL(
3571 "Rcvd unexpected msg %X in state %X, in role %X"),
3572 msg_type, session_entry->limSmeState,
3573 GET_LIM_SYSTEM_ROLE(session_entry));
3574 goto end;
3575 }
3576 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3577 &session_entry->dph.dphHashTable);
3578 if (sta_ds == NULL) {
3579 lim_log(mac_ctx, LOGE, FL(
3580 "Rcvd invalid msg %X due to no STA ctx, aid %d, peer "),
3581 msg_type, assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003582 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003583
3584 /*
3585 * send a DISASSOC_IND message to WSM to make sure
3586 * the state in WSM and LIM is the same
3587 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003588 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003589 eSIR_SME_STA_NOT_ASSOCIATED,
3590 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3591 session_entry->smeSessionId,
3592 session_entry->transactionId,
3593 session_entry);
3594 goto end;
3595 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303596 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003597 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303598 QDF_MAC_ADDR_SIZE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003599 lim_log(mac_ctx, LOG1, FL(
3600 "peerMacAddr mismatched for aid %d, peer "),
3601 assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003602 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003603 goto end;
3604 }
3605
3606 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3607 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3608 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3609 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3610 (msg_type != eWNI_SME_ASSOC_CNF))) {
3611 lim_log(mac_ctx, LOG1, FL(
3612 "not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3613 "StaD mlmState : %d"),
3614 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003615 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003616 goto end;
3617 }
3618 /*
3619 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3620 * has been received
3621 */
3622 lim_log(mac_ctx, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
3623 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3624 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3625
3626 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3627 /*
3628 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3629 * when it had received Assoc Request frame. Now, PE just needs
3630 * to send association rsp frame to the requesting BTAMP-STA.
3631 */
3632 sta_ds->mlmStaContext.mlmState =
3633 eLIM_MLM_LINK_ESTABLISHED_STATE;
3634 lim_log(mac_ctx, LOG1,
3635 FL("sending Assoc Rsp frame to STA (assoc id=%d) "),
3636 sta_ds->assocId);
3637 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3638 sta_ds->assocId, sta_ds->staAddr,
3639 sta_ds->mlmStaContext.subType, sta_ds,
3640 session_entry);
3641 goto end;
3642 } else {
3643 /*
3644 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3645 * to be associated since the HAL sta entry is created for
3646 * denied STA we need to remove this HAL entry.
3647 * So to do that set updateContext to 1
3648 */
3649 if (!sta_ds->mlmStaContext.updateContext)
3650 sta_ds->mlmStaContext.updateContext = 1;
3651 lim_log(mac_ctx, LOG1,
3652 FL("Recv Assoc Cnf, status Code : %d(assoc id=%d) "),
3653 assoc_cnf.statusCode, sta_ds->assocId);
3654 lim_reject_association(mac_ctx, sta_ds->staAddr,
3655 sta_ds->mlmStaContext.subType,
3656 true, sta_ds->mlmStaContext.authType,
3657 sta_ds->assocId, true,
3658 eSIR_MAC_UNSPEC_FAILURE_STATUS,
3659 session_entry);
3660 }
3661end:
3662 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3663 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3664 assoc_req = (tpSirAssocReq)
3665 session_entry->parsedAssocReq[sta_ds->assocId];
3666 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303667 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003668 assoc_req->assocReqFrame = NULL;
3669 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303670 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003671 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3672 }
3673}
3674
3675static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3676{
3677 tpDphHashNode pStaDs;
3678 tSirMacAddr peerMac;
3679 tpSirAddtsReq pSirAddts;
3680 uint32_t timeout;
3681 tpPESession psessionEntry;
3682 uint8_t sessionId; /* PE sessionId */
3683 uint8_t smesessionId;
3684 uint16_t smetransactionId;
3685
3686 if (pMsgBuf == NULL) {
3687 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
3688 return;
3689 }
3690
3691 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3692 &smetransactionId);
3693
3694 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3695
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003696 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3697 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003698 if (psessionEntry == NULL) {
3699 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3700 return;
3701 }
3702#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3703 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3704 0);
3705#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3706
3707 /* if sta
3708 * - verify assoc state
3709 * - send addts request to ap
3710 * - wait for addts response from ap
3711 * if ap, just ignore with error log
3712 */
3713 PELOG1(lim_log(pMac, LOG1,
3714 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
3715 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3716 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
3717 )
3718
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003719 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003720 PELOGE(lim_log(pMac, LOGE, "AddTs received on AP - ignoring");)
3721 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3722 psessionEntry, pSirAddts->req.tspec,
3723 smesessionId, smetransactionId);
3724 return;
3725 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003726
3727 pStaDs =
3728 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3729 &psessionEntry->dph.dphHashTable);
3730
3731 if (pStaDs == NULL) {
3732 PELOGE(lim_log
3733 (pMac, LOGE, "Cannot find AP context for addts req");
3734 )
3735 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3736 psessionEntry, pSirAddts->req.tspec,
3737 smesessionId, smetransactionId);
3738 return;
3739 }
3740
3741 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3742 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
3743 lim_log(pMac, LOGE, "AddTs received in invalid MLM state");
3744 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3745 psessionEntry, pSirAddts->req.tspec,
3746 smesessionId, smetransactionId);
3747 return;
3748 }
3749
3750 pSirAddts->req.wsmTspecPresent = 0;
3751 pSirAddts->req.wmeTspecPresent = 0;
3752 pSirAddts->req.lleTspecPresent = 0;
3753
3754 if ((pStaDs->wsmEnabled) &&
3755 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3756 SIR_MAC_ACCESSPOLICY_EDCA))
3757 pSirAddts->req.wsmTspecPresent = 1;
3758 else if (pStaDs->wmeEnabled)
3759 pSirAddts->req.wmeTspecPresent = 1;
3760 else if (pStaDs->lleEnabled)
3761 pSirAddts->req.lleTspecPresent = 1;
3762 else {
3763 PELOGW(lim_log
3764 (pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));
3765 )
3766 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3767 psessionEntry, pSirAddts->req.tspec,
3768 smesessionId, smetransactionId);
3769 return;
3770 }
3771
3772 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3773 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
3774 lim_log(pMac, LOGE,
3775 "AddTs received in invalid LIMsme state (%d)",
3776 psessionEntry->limSmeState);
3777 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3778 psessionEntry, pSirAddts->req.tspec,
3779 smesessionId, smetransactionId);
3780 return;
3781 }
3782
3783 if (pMac->lim.gLimAddtsSent) {
3784 lim_log(pMac, LOGE,
3785 "Addts (token %d, tsid %d, up %d) is still pending",
3786 pMac->lim.gLimAddtsReq.req.dialogToken,
3787 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3788 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3789 userPrio);
3790 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3791 psessionEntry, pSirAddts->req.tspec,
3792 smesessionId, smetransactionId);
3793 return;
3794 }
3795
3796 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3797
3798 /* save the addts request */
3799 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303800 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003801 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3802
3803 /* ship out the message now */
3804 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3805 psessionEntry);
3806 PELOG1(lim_log(pMac, LOG1, "Sent ADDTS request");)
3807 /* start a timer to wait for the response */
3808 if (pSirAddts->timeout)
3809 timeout = pSirAddts->timeout;
3810 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3811 eSIR_SUCCESS) {
3812 lim_log(pMac, LOGP,
3813 FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
3814 WNI_CFG_ADDTS_RSP_TIMEOUT);
3815 return;
3816 }
3817
3818 timeout = SYS_MS_TO_TICKS(timeout);
3819 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3820 != TX_SUCCESS) {
3821 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3822 return;
3823 }
3824 pMac->lim.gLimAddtsRspTimerCount++;
3825 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3826 pMac->lim.gLimAddtsRspTimerCount) !=
3827 TX_SUCCESS) {
3828 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3829 return;
3830 }
3831 MTRACE(mac_trace
3832 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3833 eLIM_ADDTS_RSP_TIMER));
3834
3835 /* add the sessionId to the timer object */
3836 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3837 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3838 TX_SUCCESS) {
3839 lim_log(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
3840 return;
3841 }
3842 return;
3843}
3844
3845static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3846{
3847 tSirMacAddr peerMacAddr;
3848 uint8_t ac;
3849 tSirMacTSInfo *pTsinfo;
3850 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3851 tpDphHashNode pStaDs = NULL;
3852 tpPESession psessionEntry;
3853 uint8_t sessionId;
3854 uint32_t status = eSIR_SUCCESS;
3855 uint8_t smesessionId;
3856 uint16_t smetransactionId;
3857
3858 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3859 &smetransactionId);
3860
3861 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003862 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003863 &sessionId);
3864 if (psessionEntry == NULL) {
3865 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3866 status = eSIR_FAILURE;
3867 goto end;
3868 }
3869#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3870 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3871 0);
3872#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3873
3874 if (eSIR_SUCCESS !=
3875 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
3876 PELOGE(lim_log(pMac, LOGE, FL("lim_validate_delts_req failed"));)
3877 status = eSIR_FAILURE;
3878 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3879 smesessionId, smetransactionId);
3880 return;
3881 }
3882
3883 lim_log(pMac, LOG1,
3884 FL("Sent DELTS request to station with assocId = %d MacAddr = "
3885 MAC_ADDRESS_STR),
3886 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3887
3888 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3889 pDeltsReq->req.wmeTspecPresent,
3890 &pDeltsReq->req.tsinfo,
3891 &pDeltsReq->req.tspec, psessionEntry);
3892
3893 pTsinfo =
3894 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3895 tsinfo : &pDeltsReq->req.tsinfo;
3896
3897 /* We've successfully send DELTS frame to AP. Update the
3898 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3899 * is no longer trigger enabled or delivery enabled
3900 */
3901 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3902 pTsinfo, CLEAR_UAPSD_MASK);
3903
3904 /* We're deleting the TSPEC, so this particular AC is no longer
3905 * admitted. PE needs to downgrade the EDCA
3906 * parameters(for the AC for which TS is being deleted) to the
3907 * next best AC for which ACM is not enabled, and send the
3908 * updated values to HAL.
3909 */
3910 ac = upToAc(pTsinfo->traffic.userPrio);
3911
3912 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3913 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3914 ~(1 << ac);
3915 } else if (pTsinfo->traffic.direction ==
3916 SIR_MAC_DIRECTION_DNLINK) {
3917 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3918 ~(1 << ac);
3919 } else if (pTsinfo->traffic.direction ==
3920 SIR_MAC_DIRECTION_BIDIR) {
3921 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3922 ~(1 << ac);
3923 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3924 ~(1 << ac);
3925 }
3926
3927 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3928 psessionEntry);
3929
3930 pStaDs =
3931 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3932 &psessionEntry->dph.dphHashTable);
3933 if (pStaDs != NULL) {
3934 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3935 pStaDs->bssId);
3936 status = eSIR_SUCCESS;
3937 } else {
3938 lim_log(pMac, LOGE, FL("Self entry missing in Hash Table "));
3939 status = eSIR_FAILURE;
3940 }
3941#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003942 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003943#endif
3944
3945 /* send an sme response back */
3946end:
3947 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3948 smesessionId, smetransactionId);
3949}
3950
3951void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
3952{
3953 /* fetch the sessionEntry based on the sessionId */
3954 tpPESession psessionEntry;
3955 psessionEntry = pe_find_session_by_session_id(pMac,
3956 pMac->lim.limTimers.gLimAddtsRspTimer.
3957 sessionId);
3958 if (psessionEntry == NULL) {
3959 lim_log(pMac, LOGP,
3960 FL("Session Does not exist for given sessionID"));
3961 return;
3962 }
3963
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003964 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003965 lim_log(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)",
3966 GET_LIM_SYSTEM_ROLE(psessionEntry));
3967 pMac->lim.gLimAddtsSent = false;
3968 return;
3969 }
3970
3971 if (!pMac->lim.gLimAddtsSent) {
3972 lim_log(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");
3973 return;
3974 }
3975
3976 if (param != pMac->lim.gLimAddtsRspTimerCount) {
3977 lim_log(pMac, LOGE,
3978 FL("Invalid AddtsRsp Timer count %d (exp %d)"), param,
3979 pMac->lim.gLimAddtsRspTimerCount);
3980 return;
3981 }
3982 /* this a real response timeout */
3983 pMac->lim.gLimAddtsSent = false;
3984 pMac->lim.gLimAddtsRspTimerCount++;
3985
3986 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3987 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3988 psessionEntry->smeSessionId,
3989 psessionEntry->transactionId);
3990}
3991
3992/**
3993 * __lim_process_sme_get_statistics_request()
3994 *
3995 ***FUNCTION:
3996 *
3997 *
3998 ***NOTE:
3999 *
4000 * @param pMac Pointer to Global MAC structure
4001 * @param *pMsgBuf A pointer to the SME message buffer
4002 * @return None
4003 */
4004static void
4005__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4006{
4007 tpAniGetPEStatsReq pPEStatsReq;
4008 tSirMsgQ msgQ;
4009
4010 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4011
4012 msgQ.type = WMA_GET_STATISTICS_REQ;
4013
4014 msgQ.reserved = 0;
4015 msgQ.bodyptr = pMsgBuf;
4016 msgQ.bodyval = 0;
4017 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4018
4019 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304020 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004021 pMsgBuf = NULL;
4022 lim_log(pMac, LOGP, "Unable to forward request");
4023 return;
4024 }
4025
4026 return;
4027}
4028
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004029#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004030/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004031 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004032 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004033 * @pMac: Pointer to Global MAC structure
4034 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004035 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004036 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004037 */
4038static void
4039__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4040{
4041 tSirMsgQ msgQ;
4042
4043 msgQ.type = WMA_TSM_STATS_REQ;
4044 msgQ.reserved = 0;
4045 msgQ.bodyptr = pMsgBuf;
4046 msgQ.bodyval = 0;
4047 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4048
4049 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304050 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004051 pMsgBuf = NULL;
4052 lim_log(pMac, LOGP, "Unable to forward request");
4053 return;
4054 }
4055}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004056#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004057
4058static void
4059__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4060{
4061 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4062 tpPESession psessionEntry;
4063 uint8_t sessionId; /* PE sessionID */
4064
4065 PELOG1(lim_log(pMac, LOG1, FL("received UPDATE_APWPSIEs_REQ message")););
4066
4067 if (pMsgBuf == NULL) {
4068 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4069 return;
4070 }
4071
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304072 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004073 if (NULL == pUpdateAPWPSIEsReq) {
4074 lim_log(pMac, LOGP,
4075 FL
4076 ("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
4077 return;
4078 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304079 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004080 sizeof(struct sSirUpdateAPWPSIEsReq));
4081
4082 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08004083 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004084 &sessionId);
4085 if (psessionEntry == NULL) {
4086 lim_log(pMac, LOGW,
4087 FL("Session does not exist for given BSSID"));
4088 goto end;
4089 }
4090
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304091 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004092 sizeof(tSirAPWPSIEs));
4093
4094 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4095 lim_send_beacon_ind(pMac, psessionEntry);
4096
4097end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304098 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004099 return;
4100}
4101
4102void
4103lim_send_vdev_restart(tpAniSirGlobal pMac,
4104 tpPESession psessionEntry, uint8_t sessionId)
4105{
4106 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
4107 tSirMsgQ msgQ;
4108 tSirRetStatus retCode = eSIR_SUCCESS;
4109
4110 if (psessionEntry == NULL) {
4111 PELOGE(lim_log
4112 (pMac, LOGE, "%s:%d: Invalid parameters", __func__,
4113 __LINE__);
4114 )
4115 return;
4116 }
4117
4118 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304119 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004120 if (NULL == pHalHiddenSsidVdevRestart) {
4121 PELOGE(lim_log
4122 (pMac, LOGE, "%s:%d: Unable to allocate memory",
4123 __func__, __LINE__);
4124 )
4125 return;
4126 }
4127
4128 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4129 pHalHiddenSsidVdevRestart->sessionId = sessionId;
4130
4131 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4132 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4133 msgQ.bodyval = 0;
4134
4135 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4136 if (eSIR_SUCCESS != retCode) {
4137 PELOGE(lim_log
4138 (pMac, LOGE, "%s:%d: wma_post_ctrl_msg() failed", __func__,
4139 __LINE__);
4140 )
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304141 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004142 }
4143}
4144
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304145/**
4146 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
4147 * @mac_ctx: Pointer to Global MAC structure
4148 * @msg_buf: Pointer to SME message buffer
4149 *
4150 * Return: None
4151 */
4152static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
4153 uint32_t *msg_buf)
4154{
4155 tpPESession pe_session;
4156 tSirMsgQ wma_msg;
4157 tSirRetStatus status;
4158 tSirRoamOffloadScanReq *req_buffer;
4159 uint16_t local_ie_len;
4160 uint8_t *local_ie_buf;
4161
4162 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
4163 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
4164 req_buffer->sessionId);
4165
4166 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
4167 if (!local_ie_buf) {
4168 lim_log(mac_ctx, LOGE, FL("Mem Alloc failed for local_ie_buf"));
4169 return;
4170 }
4171
4172 local_ie_len = req_buffer->assoc_ie.length;
4173 /* Update ext cap IE if present */
4174 if (local_ie_len &&
4175 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
4176 local_ie_buf, &local_ie_len)) {
4177 req_buffer->assoc_ie.length = local_ie_len;
4178 qdf_mem_copy(req_buffer->assoc_ie.addIEdata, local_ie_buf,
4179 local_ie_len);
4180 }
4181 qdf_mem_free(local_ie_buf);
4182
4183 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
4184 wma_msg.bodyptr = req_buffer;
4185
4186 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
4187 if (eSIR_SUCCESS != status) {
4188 lim_log(mac_ctx, LOGE,
4189 FL("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed"));
4190 qdf_mem_free(req_buffer);
4191 }
4192}
4193
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304194/*
4195 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
4196 * @mac_ctx: Pointer to global mac context
4197 * @session: Pointer to PE session
4198 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
4199 * 1 - Disable broadcast SSID
4200 *
4201 * Return: None
4202 */
4203static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
4204 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004205{
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304206 lim_log(mac_ctx, LOG1, FL("received HIDE_SSID message"));
4207 if (ssid_hidden != session->ssidHidden)
4208 session->ssidHidden = ssid_hidden;
4209 else {
4210 lim_log(mac_ctx, LOG1, FL("Same config already present!"));
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05304211 return;
4212 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004213
4214 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304215 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004216
4217 /* Update beacon */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304218 sch_set_fixed_beacon_fields(mac_ctx, session);
4219 lim_send_beacon_ind(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004220
4221 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304222}
4223
4224/**
4225 * __lim_process_sme_session_update - process SME session update msg
4226 *
4227 * @mac_ctx: Pointer to global mac context
4228 * @msg_buf: Pointer to the received message buffer
4229 *
4230 * Return: None
4231 */
4232static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
4233 uint32_t *msg_buf)
4234{
4235 struct sir_update_session_param *msg;
4236 tpPESession session;
4237
4238 if (!msg_buf) {
4239 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
4240 return;
4241 }
4242
4243 msg = (struct sir_update_session_param *) msg_buf;
4244
4245 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
4246 if (!session) {
4247 lim_log(mac_ctx, LOGW,
4248 "Session does not exist for given sessionId %d",
4249 msg->session_id);
4250 return;
4251 }
4252
4253 lim_log(mac_ctx, LOG1, FL("received SME Session update for %d val %d"),
4254 msg->param_type, msg->param_val);
4255 switch (msg->param_type) {
4256 case SIR_PARAM_SSID_HIDDEN:
4257 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
4258 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05304259 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
4260 session->ignore_assoc_disallowed = msg->param_val;
4261 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304262 default:
4263 lim_log(mac_ctx, LOGE, FL("Unknown session param"));
4264 break;
4265 }
4266}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004267
4268static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4269{
4270 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4271 tpPESession psessionEntry;
4272 uint8_t sessionId; /* PE sessionID */
4273
4274 if (pMsgBuf == NULL) {
4275 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4276 return;
4277 }
4278
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304279 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004280 if (NULL == pUpdateAPWPARSNIEsReq) {
4281 lim_log(pMac, LOGP,
4282 FL
4283 ("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
4284 return;
4285 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304286 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004287 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4288
4289 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004290 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004291 &sessionId);
4292 if (psessionEntry == NULL) {
4293 lim_log(pMac, LOGW,
4294 FL("Session does not exist for given BSSID"));
4295 goto end;
4296 }
4297
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304298 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004299 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4300
4301 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4302 &psessionEntry->
4303 pLimStartBssReq->rsnIE,
4304 psessionEntry);
4305
4306 psessionEntry->pLimStartBssReq->privacy = 1;
4307 psessionEntry->privacy = 1;
4308
4309 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4310 lim_send_beacon_ind(pMac, psessionEntry);
4311
4312end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304313 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004314 return;
4315} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4316
4317/*
4318 Update the beacon Interval dynamically if beaconInterval is different in MCC
4319 */
4320static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4321{
4322 tpSirChangeBIParams pChangeBIParams;
4323 tpPESession psessionEntry;
4324 uint8_t sessionId = 0;
4325 tUpdateBeaconParams beaconParams;
4326
4327 PELOG1(lim_log(pMac, LOG1,
4328 FL("received Update Beacon Interval message"));
4329 );
4330
4331 if (pMsgBuf == NULL) {
4332 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4333 return;
4334 }
4335
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304336 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004337 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4338
4339 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004340 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004341 &sessionId);
4342 if (psessionEntry == NULL) {
4343 lim_log(pMac, LOGE,
4344 FL("Session does not exist for given BSSID"));
4345 return;
4346 }
4347
4348 /*Update sessionEntry Beacon Interval */
4349 if (psessionEntry->beaconParams.beaconInterval !=
4350 pChangeBIParams->beaconInterval) {
4351 psessionEntry->beaconParams.beaconInterval =
4352 pChangeBIParams->beaconInterval;
4353 }
4354
4355 /*Update sch beaconInterval */
4356 if (pMac->sch.schObject.gSchBeaconInterval !=
4357 pChangeBIParams->beaconInterval) {
4358 pMac->sch.schObject.gSchBeaconInterval =
4359 pChangeBIParams->beaconInterval;
4360
4361 PELOG1(lim_log(pMac, LOG1,
4362 FL
4363 ("LIM send update BeaconInterval Indication : %d"),
4364 pChangeBIParams->beaconInterval);
4365 );
4366
4367 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4368 /* Update beacon */
4369 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4370
4371 beaconParams.bssIdx = psessionEntry->bssIdx;
4372 /* Set change in beacon Interval */
4373 beaconParams.beaconInterval =
4374 pChangeBIParams->beaconInterval;
4375 beaconParams.paramChangeBitmap =
4376 PARAM_BCN_INTERVAL_CHANGED;
4377 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4378 }
4379 }
4380
4381 return;
4382} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4383
4384#ifdef QCA_HT_2040_COEX
4385static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4386 uint32_t *pMsgBuf)
4387{
4388 tpSirSetHT2040Mode pSetHT2040Mode;
4389 tpPESession psessionEntry;
4390 uint8_t sessionId = 0;
4391 cds_msg_t msg;
4392 tUpdateVHTOpMode *pHtOpMode = NULL;
4393 uint16_t staId = 0;
4394 tpDphHashNode pStaDs = NULL;
4395
4396 PELOG1(lim_log(pMac, LOG1, FL("received Set HT 20/40 mode message")););
4397 if (pMsgBuf == NULL) {
4398 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4399 return;
4400 }
4401
4402 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4403
4404 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004405 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004406 &sessionId);
4407 if (psessionEntry == NULL) {
4408 lim_log(pMac, LOG1,
4409 FL("Session does not exist for given BSSID "));
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004410 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004411 return;
4412 }
4413
4414 lim_log(pMac, LOG1, FL("Update session entry for cbMod=%d"),
4415 pSetHT2040Mode->cbMode);
4416 /*Update sessionEntry HT related fields */
4417 switch (pSetHT2040Mode->cbMode) {
4418 case PHY_SINGLE_CHANNEL_CENTERED:
4419 psessionEntry->htSecondaryChannelOffset =
4420 PHY_SINGLE_CHANNEL_CENTERED;
4421 psessionEntry->htRecommendedTxWidthSet = 0;
4422 if (pSetHT2040Mode->obssEnabled)
4423 psessionEntry->htSupportedChannelWidthSet
4424 = eHT_CHANNEL_WIDTH_40MHZ;
4425 else
4426 psessionEntry->htSupportedChannelWidthSet
4427 = eHT_CHANNEL_WIDTH_20MHZ;
4428 break;
4429 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4430 psessionEntry->htSecondaryChannelOffset =
4431 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4432 psessionEntry->htRecommendedTxWidthSet = 1;
4433 break;
4434 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4435 psessionEntry->htSecondaryChannelOffset =
4436 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4437 psessionEntry->htRecommendedTxWidthSet = 1;
4438 break;
4439 default:
4440 lim_log(pMac, LOGE, FL("Invalid cbMode"));
4441 return;
4442 }
4443
4444 /* Update beacon */
4445 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4446 lim_send_beacon_ind(pMac, psessionEntry);
4447
4448 /* update OP Mode for each associated peer */
4449 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4450 pStaDs = dph_get_hash_entry(pMac, staId,
4451 &psessionEntry->dph.dphHashTable);
4452 if (NULL == pStaDs)
4453 continue;
4454
4455 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304456 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004457 if (NULL == pHtOpMode) {
4458 lim_log(pMac, LOGE,
4459 FL
4460 ("%s: Not able to allocate memory for setting OP mode"),
4461 __func__);
4462 return;
4463 }
4464 pHtOpMode->opMode =
4465 (psessionEntry->htSecondaryChannelOffset ==
4466 PHY_SINGLE_CHANNEL_CENTERED) ?
4467 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4468 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304469 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004470 sizeof(tSirMacAddr));
4471 pHtOpMode->smesessionId = sessionId;
4472
4473 msg.type = WMA_UPDATE_OP_MODE;
4474 msg.reserved = 0;
4475 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304476 if (!QDF_IS_STATUS_SUCCESS
Anurag Chouhan6d760662016-02-20 16:05:43 +05304477 (cds_mq_post_message(QDF_MODULE_ID_WMA, &msg))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004478 lim_log(pMac, LOGE,
4479 FL
4480 ("%s: Not able to post WMA_UPDATE_OP_MODE message to WMA"),
4481 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304482 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004483 return;
4484 }
4485 lim_log(pMac, LOG1,
4486 FL
4487 ("%s: Notifed FW about OP mode: %d for staId=%d"),
4488 __func__, pHtOpMode->opMode, staId);
4489
4490 } else
4491 lim_log(pMac, LOG1,
4492 FL("%s: station %d does not support HT40\n"),
4493 __func__, staId);
4494 }
4495
4496 return;
4497}
4498#endif
4499
4500/* -------------------------------------------------------------------- */
4501/**
4502 * __lim_process_report_message
4503 *
4504 * FUNCTION: Processes the next received Radio Resource Management message
4505 *
4506 * LOGIC:
4507 *
4508 * ASSUMPTIONS:
4509 *
4510 * NOTE:
4511 *
4512 * @param None
4513 * @return None
4514 */
4515
4516void __lim_process_report_message(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4517{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004518 switch (pMsg->type) {
4519 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4520 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4521 break;
4522 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004523 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004524 break;
4525 default:
4526 lim_log(pMac, LOGE, FL("Invalid msg type:%d"), pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004527 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004528}
4529
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004530/* -------------------------------------------------------------------- */
4531/**
4532 * lim_send_set_max_tx_power_req
4533 *
4534 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4535 *
4536 * LOGIC:
4537 *
4538 * ASSUMPTIONS:
4539 *
4540 * NOTE:
4541 *
4542 * @param txPower txPower to be set.
4543 * @param pSessionEntry session entry.
4544 * @return None
4545 */
4546tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004547lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004548 tpPESession pSessionEntry)
4549{
4550 tpMaxTxPowerParams pMaxTxParams = NULL;
4551 tSirRetStatus retCode = eSIR_SUCCESS;
4552 tSirMsgQ msgQ;
4553
4554 if (pSessionEntry == NULL) {
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304555 lim_log(pMac, LOGE, FL("Inavalid parameters"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004556 return eSIR_FAILURE;
4557 }
4558
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304559 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004560 if (NULL == pMaxTxParams) {
4561 lim_log(pMac, LOGP,
4562 FL("Unable to allocate memory for pMaxTxParams "));
4563 return eSIR_MEM_ALLOC_FAILED;
4564
4565 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004566 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304567 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304568 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304569 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004570 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304571 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004572
4573 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4574 msgQ.bodyptr = pMaxTxParams;
4575 msgQ.bodyval = 0;
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304576 lim_log(pMac, LOG1, FL("Post WMA_SET_MAX_TX_POWER_REQ to WMA"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004577 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4578 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4579 if (eSIR_SUCCESS != retCode) {
4580 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304581 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004582 }
4583 return retCode;
4584}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004585
4586/**
4587 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4588 *
4589 * @mac_ctx: Pointer to Global MAC structure
4590 * @msg_buf: pointer to the SME message buffer
4591 *
4592 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4593 * from SME. It Register this information within PE.
4594 *
4595 * Return: None
4596 */
4597static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4598 uint32_t *msg_buf)
4599{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304600 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004601 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4602 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4603 struct mgmt_frm_reg_info *next = NULL;
4604 bool match = false;
4605
4606 lim_log(mac_ctx, LOG1, FL(
4607 "registerFrame %d, frameType %d, matchLen %d"),
4608 sme_req->registerFrame, sme_req->frameType,
4609 sme_req->matchLen);
4610 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304611 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304612 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4613 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304614 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004615
4616 while (lim_mgmt_regn != NULL) {
4617 if (lim_mgmt_regn->frameType != sme_req->frameType)
4618 goto skip_match;
4619 if (sme_req->matchLen) {
4620 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304621 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004622 sme_req->matchData,
4623 lim_mgmt_regn->matchLen))) {
4624 /* found match! */
4625 match = true;
4626 break;
4627 }
4628 } else {
4629 /* found match! */
4630 match = true;
4631 break;
4632 }
4633skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304634 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304635 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004636 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304637 (qdf_list_node_t *)lim_mgmt_regn,
4638 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304639 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004640 lim_mgmt_regn = next;
4641 next = NULL;
4642 }
4643 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304644 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304645 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004646 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304647 (qdf_list_node_t *)lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304648 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304649 qdf_mem_free(lim_mgmt_regn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004650 }
4651
4652 if (sme_req->registerFrame) {
4653 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304654 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004655 sme_req->matchLen);
4656 if (lim_mgmt_regn != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304657 qdf_mem_set((void *)lim_mgmt_regn,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004658 sizeof(struct mgmt_frm_reg_info) +
4659 sme_req->matchLen, 0);
4660 lim_mgmt_regn->frameType = sme_req->frameType;
4661 lim_mgmt_regn->matchLen = sme_req->matchLen;
4662 lim_mgmt_regn->sessionId = sme_req->sessionId;
4663 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304664 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004665 sme_req->matchData,
4666 sme_req->matchLen);
4667 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304668 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004669 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304670 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004671 gLimMgmtFrameRegistratinQueue,
4672 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304673 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004674 &mac_ctx->lim.lim_frame_register_lock);
4675 }
4676 }
4677 return;
4678}
4679
4680static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4681{
4682 lim_log(pMac, LOG1, FL("Dereg msgType %d"),
4683 pMac->lim.gDeferMsgTypeForNOA);
4684 pMac->lim.gDeferMsgTypeForNOA = 0;
4685 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4686 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304687 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004688 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4689 }
4690}
4691
4692/**
4693 * lim_process_regd_defd_sme_req_after_noa_start()
4694 *
4695 * mac_ctx: Pointer to Global MAC structure
4696 *
4697 * This function is called to process deferred sme req message
4698 * after noa start.
4699 *
4700 * Return: None
4701 */
4702void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4703{
4704 bool buf_consumed = true;
4705
4706 lim_log(mac_ctx, LOG1, FL("Process defd sme req %d"),
4707 mac_ctx->lim.gDeferMsgTypeForNOA);
4708
4709 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4710 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
4711 lim_log(mac_ctx, LOGW,
4712 FL("start rcvd from FW when no sme deferred msg pending. Do nothing. "));
4713 lim_log(mac_ctx, LOGW,
4714 FL("It may happen when NOA start ind and timeout happen at the same time"));
4715 return;
4716 }
4717 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4718 case eWNI_SME_SCAN_REQ:
4719 __lim_process_sme_scan_req(mac_ctx,
4720 mac_ctx->lim.gpDefdSmeMsgForNOA);
4721 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004722 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4723 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4724 mac_ctx->lim.gpDefdSmeMsgForNOA);
4725 /*
4726 * lim_process_remain_on_chnl_req doesnt want us to free
4727 * the buffer since it is freed in lim_remain_on_chn_rsp.
4728 * this change is to avoid "double free"
4729 */
4730 if (false == buf_consumed)
4731 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4732 break;
4733 case eWNI_SME_JOIN_REQ:
4734 __lim_process_sme_join_req(mac_ctx,
4735 mac_ctx->lim.gpDefdSmeMsgForNOA);
4736 break;
4737 default:
4738 lim_log(mac_ctx, LOGE, FL("Unknown deferred msg type %d"),
4739 mac_ctx->lim.gDeferMsgTypeForNOA);
4740 break;
4741 }
4742 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4743}
4744
4745static void
4746__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4747{
4748 tpSirResetAPCapsChange pResetCapsChange;
4749 tpPESession psessionEntry;
4750 uint8_t sessionId = 0;
4751 if (pMsgBuf == NULL) {
4752 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4753 return;
4754 }
4755
4756 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4757 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004758 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4759 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004760 if (psessionEntry == NULL) {
4761 lim_log(pMac, LOGE,
4762 FL("Session does not exist for given BSSID"));
4763 return;
4764 }
4765
4766 psessionEntry->limSentCapsChangeNtf = false;
4767 return;
4768}
4769
4770/**
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304771 * lim_register_p2p_ack_ind_cb() - Save the p2p ack indication callback.
4772 * @mac_ctx: Mac pointer
4773 * @msg_buf: Msg pointer containing the callback
4774 *
4775 * This function is used to save the p2p ack indication callback in PE.
4776 *
4777 * Return: None
4778 */
4779static void lim_register_p2p_ack_ind_cb(tpAniSirGlobal mac_ctx,
4780 uint32_t *msg_buf)
4781{
4782 struct sir_sme_p2p_ack_ind_cb_req *sme_req =
4783 (struct sir_sme_p2p_ack_ind_cb_req *)msg_buf;
4784
4785 if (NULL == msg_buf) {
4786 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4787 return;
4788 }
4789 if (sme_req->callback)
4790 mac_ctx->p2p_ack_ind_cb =
4791 sme_req->callback;
4792 else
4793 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4794}
4795
4796/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304797 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4798 * indication callback in PE.
4799 * @mac_ptr: Mac pointer
4800 * @msg_buf: Msg pointer containing the callback
4801 *
4802 * This function is used save the Management frame
4803 * indication callback in PE.
4804 *
4805 * Return: None
4806 */
4807static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4808 uint32_t *msg_buf)
4809{
4810 struct sir_sme_mgmt_frame_cb_req *sme_req =
4811 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4812
4813 if (NULL == msg_buf) {
4814 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4815 return;
4816 }
4817 if (sme_req->callback)
4818 mac_ctx->mgmt_frame_ind_cb =
4819 (sir_mgmt_frame_ind_callback)sme_req->callback;
4820 else
4821 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4822}
4823
4824/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304825 *__lim_process_send_disassoc_frame: function processes disassoc frame
4826 * @mac_ctx: pointer to mac context
4827 * @msg_buf: message buffer
4828 *
4829 * function processes disassoc request received from SME
4830 *
4831 * return: none
4832 */
4833static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4834 uint32_t *msg_buf)
4835{
4836 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4837 tSirRetStatus status;
4838 tpPESession session_entry = NULL;
4839 uint8_t sme_session_id;
4840 uint16_t sme_trans_id;
4841
4842 if (msg_buf == NULL) {
4843 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
4844 return;
4845 }
4846
4847 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4848 &sme_trans_id);
4849
4850 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4851 &sme_send_disassoc_frame_req,
4852 (uint8_t *)msg_buf);
4853
4854 if ((eSIR_FAILURE == status) ||
4855 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4856 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
4857 PELOGE(lim_log(mac_ctx, LOGE,
4858 FL("received invalid SME_DISASSOC_REQ message"));)
4859 return;
4860 }
4861
4862 session_entry = pe_find_session_by_sme_session_id(
4863 mac_ctx, sme_session_id);
4864 if (session_entry == NULL) {
4865 lim_log(mac_ctx, LOGE,
4866 FL("session does not exist for given bssId "MAC_ADDRESS_STR),
4867 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4868 return;
4869 }
4870
4871 lim_log(mac_ctx, LOG1,
4872 FL("msg_type->%d len->%d sess_id->%d trans_id->%d mac->"MAC_ADDRESS_STR" reason->%d wait_for_ack->%d"),
4873 sme_send_disassoc_frame_req.msg_type,
4874 sme_send_disassoc_frame_req.length,
4875 sme_send_disassoc_frame_req.session_id,
4876 sme_send_disassoc_frame_req.trans_id,
4877 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4878 sme_send_disassoc_frame_req.reason,
4879 sme_send_disassoc_frame_req.wait_for_ack);
4880
4881 lim_send_disassoc_mgmt_frame(mac_ctx,
4882 sme_send_disassoc_frame_req.reason,
4883 sme_send_disassoc_frame_req.peer_mac,
4884 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4885}
4886
4887/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004888 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4889 * @mac_ctx: Pointer to Global MAC structure
4890 * @pdev_id: pdev id to set the IE.
4891 * @nss: Nss values to prepare the HT IE.
4892 *
4893 * Prepares the HT IE with self capabilities for different
4894 * Nss values and sends the set HT IE req to FW.
4895 *
4896 * Return: None
4897 */
4898static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4899 uint8_t nss)
4900{
4901 struct set_ie_param *ie_params;
4902 tSirMsgQ msg;
4903 tSirRetStatus rc = eSIR_SUCCESS;
4904 uint8_t *p_ie = NULL;
4905 tHtCaps *p_ht_cap;
4906 int i;
4907
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004908 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004909 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4910 if (NULL == ie_params) {
4911 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4912 return;
4913 }
4914 ie_params->nss = i;
4915 ie_params->pdev_id = pdev_id;
4916 ie_params->ie_type = DOT11_HT_IE;
4917 /* 2 for IE len and EID */
4918 ie_params->ie_len = 2 + sizeof(tHtCaps);
4919 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4920 if (NULL == ie_params->ie_ptr) {
4921 qdf_mem_free(ie_params);
4922 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4923 return;
4924 }
4925 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4926 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4927 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4928 ie_params->ie_len);
4929
4930 if (NSS_1x1_MODE == i) {
4931 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4932 ie_params->ie_len,
4933 DOT11F_EID_HTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004934 if (NULL == p_ie) {
4935 qdf_mem_free(ie_params->ie_ptr);
4936 qdf_mem_free(ie_params);
4937 lim_log(mac_ctx, LOGE,
4938 FL("failed to get IE ptr"));
4939 return;
4940 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004941 p_ht_cap = (tHtCaps *)&p_ie[2];
4942 p_ht_cap->supportedMCSSet[1] = 0;
4943 p_ht_cap->txSTBC = 0;
4944 }
4945
4946 msg.type = WMA_SET_PDEV_IE_REQ;
4947 msg.bodyptr = ie_params;
4948 msg.bodyval = 0;
4949
4950 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4951 if (rc != eSIR_SUCCESS) {
4952 lim_log(mac_ctx, LOGE,
4953 FL("wma_post_ctrl_msg() return failure"));
4954 qdf_mem_free(ie_params->ie_ptr);
4955 qdf_mem_free(ie_params);
4956 return;
4957 }
4958 }
4959}
4960
4961/**
4962 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4963 * @mac_ctx: Pointer to Global MAC structure
4964 * @pdev_id: pdev id to set the IE.
4965 * @nss: Nss values to prepare the VHT IE.
4966 *
4967 * Prepares the VHT IE with self capabilities for different
4968 * Nss values and sends the set VHT IE req to FW.
4969 *
4970 * Return: None
4971 */
4972static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4973 uint8_t nss)
4974{
4975 struct set_ie_param *ie_params;
4976 tSirMsgQ msg;
4977 tSirRetStatus rc = eSIR_SUCCESS;
4978 uint8_t *p_ie = NULL;
4979 tSirMacVHTCapabilityInfo *vht_cap;
4980 int i;
4981 tSirVhtMcsInfo *vht_mcs;
4982
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004983 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004984 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4985 if (NULL == ie_params) {
4986 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4987 return;
4988 }
4989 ie_params->nss = i;
4990 ie_params->pdev_id = pdev_id;
4991 ie_params->ie_type = DOT11_VHT_IE;
4992 /* 2 for IE len and EID */
4993 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4994 sizeof(tSirVhtMcsInfo);
4995 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4996 if (NULL == ie_params->ie_ptr) {
4997 qdf_mem_free(ie_params);
4998 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4999 return;
5000 }
5001 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
5002 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
5003 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
5004 ie_params->ie_len);
5005
5006 if (NSS_1x1_MODE == i) {
5007 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
5008 ie_params->ie_len,
5009 DOT11F_EID_VHTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07005010 if (NULL == p_ie) {
5011 qdf_mem_free(ie_params->ie_ptr);
5012 qdf_mem_free(ie_params);
5013 lim_log(mac_ctx, LOGE,
5014 FL("failed to get IE ptr"));
5015 return;
5016 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005017 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
5018 vht_cap->txSTBC = 0;
5019 vht_mcs =
5020 (tSirVhtMcsInfo *)&p_ie[2 +
5021 sizeof(tSirMacVHTCapabilityInfo)];
5022 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
5023 vht_mcs->rxHighest =
5024 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
5025 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
5026 vht_mcs->txHighest =
5027 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
5028 }
5029 msg.type = WMA_SET_PDEV_IE_REQ;
5030 msg.bodyptr = ie_params;
5031 msg.bodyval = 0;
5032
5033 rc = wma_post_ctrl_msg(mac_ctx, &msg);
5034 if (rc != eSIR_SUCCESS) {
5035 lim_log(mac_ctx, LOGE,
5036 FL("wma_post_ctrl_msg failure"));
5037 qdf_mem_free(ie_params->ie_ptr);
5038 qdf_mem_free(ie_params);
5039 return;
5040 }
5041 }
5042}
5043
5044/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07005045 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
5046 * @mac_ctx: Pointer to Global MAC structure
5047 * @msg_buf: Pointer to the SME message buffer
5048 *
5049 * This function is called by limProcessMessageQueue(). This function sets the
5050 * VDEV IEs to the FW.
5051 *
5052 * Return: None
5053 */
5054static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
5055 uint32_t *msg_buf)
5056{
5057 struct sir_set_vdev_ies_per_band *p_msg =
5058 (struct sir_set_vdev_ies_per_band *)msg_buf;
5059
5060 if (NULL == p_msg) {
5061 lim_log(mac_ctx, LOGE, FL("NULL p_msg"));
5062 return;
5063 }
5064
5065 lim_log(mac_ctx, LOG1, FL("rcvd set vdev ie per band req vdev_id = %d"),
5066 p_msg->vdev_id);
5067 /* intentionally using NULL here so that self capabilty are sent */
5068 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
5069 QDF_STATUS_SUCCESS)
5070 lim_log(mac_ctx, LOGE, FL("Unable to send HT/VHT Cap to FW"));
5071}
5072
5073/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005074 * lim_process_set_pdev_IEs() - process the set pdev IE req
5075 * @mac_ctx: Pointer to Global MAC structure
5076 * @msg_buf: Pointer to the SME message buffer
5077 *
5078 * This function is called by limProcessMessageQueue(). This
5079 * function sets the PDEV IEs to the FW.
5080 *
5081 * Return: None
5082 */
5083static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5084{
5085 struct sir_set_ht_vht_cfg *ht_vht_cfg;
5086
5087 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
5088
5089 if (NULL == ht_vht_cfg) {
5090 lim_log(mac_ctx, LOGE, FL("NULL ht_vht_cfg"));
5091 return;
5092 }
5093
5094 lim_log(mac_ctx, LOG1, FL("rcvd set pdev ht vht ie req with nss = %d"),
5095 ht_vht_cfg->nss);
5096 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
5097
5098 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
5099 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
5100 ht_vht_cfg->nss);
5101}
5102
5103/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305104 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
5105 *
5106 * access policy
5107 * @mac_ctx: pointer to mac context
5108 * @msg: message buffer
5109 *
5110 * function processes vendor IE and access policy from SME and updates PE
5111 *
5112 * session entry
5113 *
5114 * return: none
5115*/
5116static void lim_process_sme_update_access_policy_vendor_ie(
5117 tpAniSirGlobal mac_ctx,
5118 uint32_t *msg)
5119{
5120 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
5121 struct sPESession *pe_session_entry;
5122 uint8_t num_bytes;
5123
5124 if (!msg) {
5125 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5126 return;
5127 }
5128 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
5129 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
5130 update_vendor_ie->sme_session_id);
5131
5132 if (!pe_session_entry) {
5133 lim_log(mac_ctx, LOGE,
5134 FL("Session does not exist for given sme session id(%hu)"),
5135 update_vendor_ie->sme_session_id);
5136 return;
5137 }
5138 if (pe_session_entry->access_policy_vendor_ie)
5139 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
5140
5141 num_bytes = update_vendor_ie->ie[1] + 2;
5142 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
5143
5144 if (!pe_session_entry->access_policy_vendor_ie) {
5145 lim_log(mac_ctx, LOGE,
5146 FL("Failed to allocate memory for vendor ie"));
5147 return;
5148 }
5149 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
5150 &update_vendor_ie->ie[0], num_bytes);
5151
5152 pe_session_entry->access_policy = update_vendor_ie->access_policy;
5153}
5154
5155/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005156 * lim_process_sme_req_messages()
5157 *
5158 ***FUNCTION:
5159 * This function is called by limProcessMessageQueue(). This
5160 * function processes SME request messages from HDD or upper layer
5161 * application.
5162 *
5163 ***LOGIC:
5164 *
5165 ***ASSUMPTIONS:
5166 *
5167 ***NOTE:
5168 *
5169 * @param pMac Pointer to Global MAC structure
5170 * @param msgType Indicates the SME message type
5171 * @param *pMsgBuf A pointer to the SME message buffer
5172 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5173 * false - if pMsgBuf is not to be freed.
5174 */
5175
5176bool lim_process_sme_req_messages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
5177{
5178 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
5179 uint32_t *pMsgBuf = pMsg->bodyptr;
5180 tpSirSmeScanReq pScanReq;
5181 PELOG1(lim_log
5182 (pMac, LOG1,
5183 FL
5184 ("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)"),
5185 lim_msg_str(pMsg->type), pMsg->type,
5186 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
5187 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
5188 )
5189
5190 pScanReq = (tpSirSmeScanReq) pMsgBuf;
5191 /* If no insert NOA required then execute the code below */
5192
5193 switch (pMsg->type) {
5194 case eWNI_SME_SYS_READY_IND:
5195 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
5196 break;
5197
5198 case eWNI_SME_START_BSS_REQ:
5199 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
5200 break;
5201
5202 case eWNI_SME_SCAN_REQ:
5203 __lim_process_sme_scan_req(pMac, pMsgBuf);
5204 break;
5205
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005206 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5207 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
5208 break;
5209
5210 case eWNI_SME_UPDATE_NOA:
5211 __lim_process_sme_no_a_update(pMac, pMsgBuf);
5212 break;
5213 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
5214 __lim_process_clear_dfs_channel_list(pMac, pMsg);
5215 break;
5216 case eWNI_SME_JOIN_REQ:
5217 __lim_process_sme_join_req(pMac, pMsgBuf);
5218 break;
5219
5220 case eWNI_SME_REASSOC_REQ:
5221 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
5222 break;
5223
5224 case eWNI_SME_DISASSOC_REQ:
5225 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
5226 break;
5227
5228 case eWNI_SME_DISASSOC_CNF:
5229 case eWNI_SME_DEAUTH_CNF:
5230 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
5231 break;
5232
5233 case eWNI_SME_DEAUTH_REQ:
5234 __lim_process_sme_deauth_req(pMac, pMsgBuf);
5235 break;
5236
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05305237 case eWNI_SME_SEND_DISASSOC_FRAME:
5238 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
5239 break;
5240
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005241 case eWNI_SME_SETCONTEXT_REQ:
5242 __lim_process_sme_set_context_req(pMac, pMsgBuf);
5243 break;
5244
5245 case eWNI_SME_STOP_BSS_REQ:
5246 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
5247 break;
5248
5249 case eWNI_SME_ASSOC_CNF:
5250 if (pMsg->type == eWNI_SME_ASSOC_CNF)
5251 PELOG1(lim_log(pMac,
5252 LOG1, FL("Received ASSOC_CNF message"));)
5253 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
5254 pMsgBuf);
5255 break;
5256
5257 case eWNI_SME_ADDTS_REQ:
5258 PELOG1(lim_log(pMac, LOG1, FL("Received ADDTS_REQ message"));)
5259 __lim_process_sme_addts_req(pMac, pMsgBuf);
5260 break;
5261
5262 case eWNI_SME_DELTS_REQ:
5263 PELOG1(lim_log(pMac, LOG1, FL("Received DELTS_REQ message"));)
5264 __lim_process_sme_delts_req(pMac, pMsgBuf);
5265 break;
5266
5267 case SIR_LIM_ADDTS_RSP_TIMEOUT:
5268 PELOG1(lim_log
5269 (pMac, LOG1,
5270 FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
5271 )
5272 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
5273 break;
5274
5275 case eWNI_SME_GET_STATISTICS_REQ:
5276 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
5277 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
5278 bufConsumed = false;
5279 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005280#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005281 case eWNI_SME_GET_TSM_STATS_REQ:
5282 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
5283 bufConsumed = false;
5284 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005285#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005286 case eWNI_SME_GET_ASSOC_STAS_REQ:
5287 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
5288 break;
5289 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5290 lim_process_tkip_counter_measures(pMac, pMsgBuf);
5291 break;
5292
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05305293 case eWNI_SME_SESSION_UPDATE_PARAM:
5294 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005295 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05305296 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
5297 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
5298 bufConsumed = false;
5299 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005300 case eWNI_SME_UPDATE_APWPSIE_REQ:
5301 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
5302 break;
5303 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5304 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
5305 break;
5306
5307 case eWNI_SME_SET_APWPARSNIEs_REQ:
5308 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
5309 break;
5310
5311 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5312 /* Update the beaconInterval */
5313 __lim_process_sme_change_bi(pMac, pMsgBuf);
5314 break;
5315
5316#ifdef QCA_HT_2040_COEX
5317 case eWNI_SME_SET_HT_2040_MODE:
5318 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
5319 break;
5320#endif
5321
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005322 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5323 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5324 __lim_process_report_message(pMac, pMsg);
5325 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005326
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005327 case eWNI_SME_FT_PRE_AUTH_REQ:
5328 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
5329 break;
5330 case eWNI_SME_FT_UPDATE_KEY:
5331 lim_process_ft_update_key(pMac, pMsgBuf);
5332 break;
5333
5334 case eWNI_SME_FT_AGGR_QOS_REQ:
5335 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
5336 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005337
5338 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5339 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
5340 break;
5341#ifdef FEATURE_WLAN_TDLS
5342 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5343 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
5344 break;
5345 case eWNI_SME_TDLS_ADD_STA_REQ:
5346 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
5347 break;
5348 case eWNI_SME_TDLS_DEL_STA_REQ:
5349 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
5350 break;
5351 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5352 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
5353 break;
5354#endif
5355 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5356 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
5357 break;
5358
5359 case eWNI_SME_CHANNEL_CHANGE_REQ:
5360 lim_process_sme_channel_change_request(pMac, pMsgBuf);
5361 break;
5362
5363 case eWNI_SME_START_BEACON_REQ:
5364 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
5365 break;
5366
5367 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
5368 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
5369 break;
5370
5371 case eWNI_SME_UPDATE_ADDITIONAL_IES:
5372 lim_process_update_add_ies(pMac, pMsgBuf);
5373 break;
5374
5375 case eWNI_SME_MODIFY_ADDITIONAL_IES:
5376 lim_process_modify_add_ies(pMac, pMsgBuf);
5377 break;
5378 case eWNI_SME_SET_HW_MODE_REQ:
5379 lim_process_set_hw_mode(pMac, pMsgBuf);
5380 break;
5381 case eWNI_SME_NSS_UPDATE_REQ:
5382 lim_process_nss_update_request(pMac, pMsgBuf);
5383 break;
5384 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5385 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5386 break;
5387 case eWNI_SME_SET_IE_REQ:
5388 lim_process_set_ie_req(pMac, pMsgBuf);
5389 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305390 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5391 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5392 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305393 case eWNI_SME_EXT_CHANGE_CHANNEL:
5394 lim_process_ext_change_channel(pMac, pMsgBuf);
5395 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005396 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5397 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5398 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005399 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5400 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005401 break;
5402 case eWNI_SME_SET_VDEV_IES_PER_BAND:
5403 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
5404 break;
Naveen Rawatf28315c2016-06-29 18:06:02 -07005405 case eWNI_SME_NDP_END_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005406 case eWNI_SME_NDP_INITIATOR_REQ:
Abhishek Singh4fef7472016-06-06 11:36:03 -07005407 case eWNI_SME_NDP_RESPONDER_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005408 lim_handle_ndp_request_message(pMac, pMsg);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005409 break;
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05305410 case eWNI_SME_REGISTER_P2P_ACK_CB:
5411 lim_register_p2p_ack_ind_cb(pMac, pMsgBuf);
5412 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305413 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5414 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5415 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005416 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305417 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005418 pMsg->bodyptr = NULL;
5419 break;
5420 } /* switch (msgType) */
5421
5422 return bufConsumed;
5423} /*** end lim_process_sme_req_messages() ***/
5424
5425/**
5426 * lim_process_sme_start_beacon_req()
5427 *
5428 ***FUNCTION:
5429 * This function is called by limProcessMessageQueue(). This
5430 * function processes SME request messages from HDD or upper layer
5431 * application.
5432 *
5433 ***LOGIC:
5434 *
5435 ***ASSUMPTIONS:
5436 *
5437 ***NOTE:
5438 *
5439 * @param pMac Pointer to Global MAC structure
5440 * @param msgType Indicates the SME message type
5441 * @param *pMsgBuf A pointer to the SME message buffer
5442 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5443 * false - if pMsgBuf is not to be freed.
5444 */
5445static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5446{
5447 tpSirStartBeaconIndication pBeaconStartInd;
5448 tpPESession psessionEntry;
5449 uint8_t sessionId; /* PE sessionID */
5450
5451 if (pMsg == NULL) {
5452 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
5453 return;
5454 }
5455
5456 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5457 psessionEntry = pe_find_session_by_bssid(pMac,
5458 pBeaconStartInd->bssid,
5459 &sessionId);
5460 if (psessionEntry == NULL) {
5461 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
5462 lim_log(pMac, LOGE,
5463 FL("Session does not exist for given bssId"));
5464 return;
5465 }
5466
5467 if (pBeaconStartInd->beaconStartStatus == true) {
5468 /*
5469 * Currently this Indication comes from SAP
5470 * to start Beacon Tx on a DFS channel
5471 * since beaconing has to be done on DFS
5472 * channel only after CAC WAIT is completed.
5473 * On a DFS Channel LIM does not start beacon
5474 * Tx right after the WMA_ADD_BSS_RSP.
5475 */
5476 lim_apply_configuration(pMac, psessionEntry);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305477 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005478 FL("Start Beacon with ssid %s Ch %d"),
5479 psessionEntry->ssId.ssId,
5480 psessionEntry->currentOperChannel);
5481 lim_send_beacon_ind(pMac, psessionEntry);
5482 } else {
5483 lim_log(pMac, LOGE, FL("Invalid Beacon Start Indication"));
5484 return;
5485 }
5486}
5487
5488/**
5489 * lim_process_sme_channel_change_request() - process sme ch change req
5490 *
5491 * @mac_ctx: Pointer to Global MAC structure
5492 * @msg_buf: pointer to the SME message buffer
5493 *
5494 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5495 *
5496 * Return: None
5497 */
5498static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5499 uint32_t *msg_buf)
5500{
5501 tpSirChanChangeRequest ch_change_req;
5502 tpPESession session_entry;
5503 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005504 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005505 uint32_t val = 0;
5506
5507 if (msg_buf == NULL) {
5508 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5509 return;
5510 }
5511 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5512
5513 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5514 ch_change_req->targetChannel);
5515
5516 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5517 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
5518 lim_log(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5519 return;
5520 }
5521
5522 session_entry = pe_find_session_by_bssid(mac_ctx,
5523 ch_change_req->bssid, &session_id);
5524 if (session_entry == NULL) {
5525 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
5526 lim_log(mac_ctx, LOGE, FL(
5527 "Session does not exist for given bssId"));
5528 return;
5529 }
5530
5531 if (session_entry->currentOperChannel ==
5532 ch_change_req->targetChannel) {
5533 lim_log(mac_ctx, LOGE, FL("target CH is same as current CH"));
5534 return;
5535 }
5536
5537 if (LIM_IS_AP_ROLE(session_entry))
5538 session_entry->channelChangeReasonCode =
5539 LIM_SWITCH_CHANNEL_SAP_DFS;
5540 else
5541 session_entry->channelChangeReasonCode =
5542 LIM_SWITCH_CHANNEL_OPERATION;
5543
5544 lim_log(mac_ctx, LOGW, FL(
5545 "switch old chnl %d to new chnl %d, ch_bw %d"),
5546 session_entry->currentOperChannel,
5547 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005548 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005549
5550 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005551 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005552 session_entry->ch_center_freq_seg0 =
5553 ch_change_req->center_freq_seg_0;
5554 session_entry->ch_center_freq_seg1 =
5555 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005556 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005557 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005558 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005559 session_entry->htRecommendedTxWidthSet =
5560 session_entry->htSupportedChannelWidthSet;
5561 session_entry->currentOperChannel =
5562 ch_change_req->targetChannel;
5563 session_entry->limRFBand =
5564 lim_get_rf_band(session_entry->currentOperChannel);
5565 /* Initialize 11h Enable Flag */
5566 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5567 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5568 eSIR_SUCCESS)
5569 lim_log(mac_ctx, LOGP,
5570 FL("Fail to get WNI_CFG_11H_ENABLED"));
5571 }
5572
5573 session_entry->lim11hEnable = val;
5574 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305575 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005576 &ch_change_req->operational_rateset,
5577 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305578 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005579 &ch_change_req->extended_rateset,
5580 sizeof(session_entry->extRateSet));
5581 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5582 session_entry->ch_center_freq_seg0,
5583 session_entry->ch_center_freq_seg1,
5584 session_entry->ch_width,
5585 max_tx_pwr, session_entry->peSessionId);
5586}
5587
5588/******************************************************************************
5589* lim_start_bss_update_add_ie_buffer()
5590*
5591***FUNCTION:
5592* This function checks the src buffer and its length and then malloc for
5593* dst buffer update the same
5594*
5595***LOGIC:
5596*
5597***ASSUMPTIONS:
5598*
5599***NOTE:
5600*
5601* @param pMac Pointer to Global MAC structure
5602* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5603* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5604* @param *pSrcData_buff A pointer of uint8_t src buffer
5605* @param srcDataLen src buffer length
5606******************************************************************************/
5607
5608static void
5609lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5610 uint8_t **pDstData_buff,
5611 uint16_t *pDstDataLen,
5612 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5613{
5614
5615 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5616 *pDstDataLen = srcDataLen;
5617
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305618 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005619
5620 if (NULL == *pDstData_buff) {
5621 lim_log(pMac, LOGE,
5622 FL("AllocateMemory failed for pDstData_buff"));
5623 return;
5624 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305625 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005626 } else {
5627 *pDstData_buff = NULL;
5628 *pDstDataLen = 0;
5629 }
5630}
5631
5632/******************************************************************************
5633* lim_update_add_ie_buffer()
5634*
5635***FUNCTION:
5636* This function checks the src buffer and length if src buffer length more
5637* than dst buffer length then free the dst buffer and malloc for the new src
5638* length, and update the dst buffer and length. But if dst buffer is bigger
5639* than src buffer length then it just update the dst buffer and length
5640*
5641***LOGIC:
5642*
5643***ASSUMPTIONS:
5644*
5645***NOTE:
5646*
5647* @param pMac Pointer to Global MAC structure
5648* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5649* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5650* @param *pSrcData_buff A pointer of uint8_t src buffer
5651* @param srcDataLen src buffer length
5652******************************************************************************/
5653
5654static void
5655lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5656 uint8_t **pDstData_buff,
5657 uint16_t *pDstDataLen,
5658 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5659{
5660
5661 if (NULL == pSrcData_buff) {
5662 lim_log(pMac, LOGE, FL("src buffer is null."));
5663 return;
5664 }
5665
5666 if (srcDataLen > *pDstDataLen) {
5667 *pDstDataLen = srcDataLen;
5668 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305669 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005670 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305671 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005672
5673 if (NULL == *pDstData_buff) {
5674 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5675 *pDstDataLen = 0;
5676 return;
5677 }
5678 }
5679
5680 /* copy the content of buffer into dst buffer
5681 */
5682 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305683 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005684
5685}
5686
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005687/**
5688 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5689 * @pMac : Pointer to Global MAC structure
5690 * @pDstData_buff : A pointer to pointer of dst buffer
5691 * @pDstDataLen : A pointer to pointer of dst buffer length
5692 * @pModifyIE : A pointer to tSirModifyIE
5693 *
5694 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5695 *
5696 * Return:
5697 * True or false depending upon whether IE is updated or not
5698 */
5699static bool
5700lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5701 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5702{
5703 int32_t oui_length;
5704 uint8_t *ibss_ie = NULL;
5705
5706 ibss_ie = pModifyIE->pIEBuffer;
5707 oui_length = pModifyIE->oui_length;
5708
5709 if ((0 == oui_length) || (NULL == ibss_ie)) {
5710 PELOGE(lim_log(pMac, LOGE,
5711 FL("Invalid set IBSS vendor IE command length %d "),
5712 oui_length);)
5713 return false;
5714 }
5715
5716 lim_update_add_ie_buffer(pMac,
5717 pDstData_buff,
5718 pDstDataLen,
5719 pModifyIE->pIEBuffer,
5720 pModifyIE->ieBufferlength);
5721
5722 return true;
5723}
5724
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005725/*
5726* lim_process_modify_add_ies() - process modify additional IE req.
5727*
5728* @mac_ctx: Pointer to Global MAC structure
5729* @msg_buf: pointer to the SME message buffer
5730*
5731* This function update the PE buffers for additional IEs.
5732*
5733* Return: None
5734*/
5735static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5736 uint32_t *msg_buf)
5737{
5738 tpSirModifyIEsInd modify_add_ies;
5739 tpPESession session_entry;
5740 uint8_t session_id;
5741 bool ret = false;
5742 tSirAddIeParams *add_ie_params;
5743
5744 if (msg_buf == NULL) {
5745 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5746 return;
5747 }
5748
5749 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5750 /* Incoming message has smeSession, use BSSID to find PE session */
5751 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005752 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005753
5754 if (NULL == session_entry) {
5755 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5756 MAC_ADDRESS_STR),
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005757 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005758 goto end;
5759 }
5760 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5761 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5762 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
5763 lim_log(mac_ctx, LOGE,
5764 FL("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d"),
5765 modify_add_ies->modifyIE.pIEBuffer,
5766 modify_add_ies->modifyIE.ieBufferlength,
5767 modify_add_ies->modifyIE.ieID,
5768 modify_add_ies->modifyIE.ieIDLen,
5769 modify_add_ies->updateType);
5770 goto end;
5771 }
5772 add_ie_params = &session_entry->addIeParams;
5773 switch (modify_add_ies->updateType) {
5774 case eUPDATE_IE_PROBE_RESP:
5775 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005776 if (LIM_IS_IBSS_ROLE(session_entry)) {
5777 lim_update_ibss_prop_add_ies(mac_ctx,
5778 &add_ie_params->probeRespData_buff,
5779 &add_ie_params->probeRespDataLen,
5780 &modify_add_ies->modifyIE);
5781 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005782 break;
5783 case eUPDATE_IE_ASSOC_RESP:
5784 /* assoc resp IE */
5785 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305786 QDF_TRACE(QDF_MODULE_ID_PE,
5787 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005788 "assoc resp add ie not present %d"),
5789 add_ie_params->assocRespDataLen);
5790 }
5791 /* search through the buffer and modify the IE */
5792 break;
5793 case eUPDATE_IE_PROBE_BCN:
5794 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005795 if (LIM_IS_IBSS_ROLE(session_entry)) {
5796 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5797 &add_ie_params->probeRespBCNData_buff,
5798 &add_ie_params->probeRespBCNDataLen,
5799 &modify_add_ies->modifyIE);
5800 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005801 if (ret == true && modify_add_ies->modifyIE.notify) {
5802 lim_handle_param_update(mac_ctx,
5803 modify_add_ies->updateType);
5804 }
5805 break;
5806 default:
5807 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d"),
5808 modify_add_ies->updateType);
5809 break;
5810 }
5811end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305812 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005813 modify_add_ies->modifyIE.pIEBuffer = NULL;
5814}
5815
5816/*
5817* lim_process_update_add_ies() - process additional IE update req
5818*
5819* @mac_ctx: Pointer to Global MAC structure
5820* @msg_buf: pointer to the SME message buffer
5821*
5822* This function update the PE buffers for additional IEs.
5823*
5824* Return: None
5825*/
5826static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5827 uint32_t *msg_buf)
5828{
5829 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5830 uint8_t session_id;
5831 tpPESession session_entry;
5832 tSirAddIeParams *addn_ie;
5833 uint16_t new_length = 0;
5834 uint8_t *new_ptr = NULL;
5835 tSirUpdateIE *update_ie;
5836
5837 if (msg_buf == NULL) {
5838 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5839 return;
5840 }
5841 update_ie = &update_add_ies->updateIE;
5842 /* incoming message has smeSession, use BSSID to find PE session */
5843 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005844 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005845
5846 if (NULL == session_entry) {
5847 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5848 MAC_ADDRESS_STR),
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005849 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005850 goto end;
5851 }
5852 addn_ie = &session_entry->addIeParams;
5853 /* if len is 0, upper layer requested freeing of buffer */
5854 if (0 == update_ie->ieBufferlength) {
5855 switch (update_add_ies->updateType) {
5856 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305857 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005858 addn_ie->probeRespData_buff = NULL;
5859 addn_ie->probeRespDataLen = 0;
5860 break;
5861 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305862 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005863 addn_ie->assocRespData_buff = NULL;
5864 addn_ie->assocRespDataLen = 0;
5865 break;
5866 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305867 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005868 addn_ie->probeRespBCNData_buff = NULL;
5869 addn_ie->probeRespBCNDataLen = 0;
5870
5871 if (update_ie->notify)
5872 lim_handle_param_update(mac_ctx,
5873 update_add_ies->updateType);
5874 break;
5875 default:
5876 break;
5877 }
5878 return;
5879 }
5880 switch (update_add_ies->updateType) {
5881 case eUPDATE_IE_PROBE_RESP:
5882 if (update_ie->append) {
5883 /*
5884 * In case of append, allocate new memory
5885 * with combined length
5886 */
5887 new_length = update_ie->ieBufferlength +
5888 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305889 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005890 if (NULL == new_ptr) {
5891 lim_log(mac_ctx, LOGE, FL(
5892 "Memory allocation failed."));
5893 goto end;
5894 }
5895 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305896 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005897 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305898 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005899 update_ie->pAdditionIEBuffer,
5900 update_ie->ieBufferlength);
5901 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305902 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005903 /* adjust length accordingly */
5904 addn_ie->probeRespDataLen = new_length;
5905 /* save refernece of local buffer in PE session */
5906 addn_ie->probeRespData_buff = new_ptr;
5907 goto end;
5908 }
5909 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5910 &addn_ie->probeRespDataLen,
5911 update_ie->pAdditionIEBuffer,
5912 update_ie->ieBufferlength);
5913 break;
5914 case eUPDATE_IE_ASSOC_RESP:
5915 /* assoc resp IE */
5916 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5917 &addn_ie->assocRespDataLen,
5918 update_ie->pAdditionIEBuffer,
5919 update_ie->ieBufferlength);
5920 break;
5921 case eUPDATE_IE_PROBE_BCN:
5922 /* probe resp Bcn IE */
5923 lim_update_add_ie_buffer(mac_ctx,
5924 &addn_ie->probeRespBCNData_buff,
5925 &addn_ie->probeRespBCNDataLen,
5926 update_ie->pAdditionIEBuffer,
5927 update_ie->ieBufferlength);
5928 if (update_ie->notify)
5929 lim_handle_param_update(mac_ctx,
5930 update_add_ies->updateType);
5931 break;
5932 default:
5933 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d."),
5934 update_add_ies->updateType);
5935 break;
5936 }
5937end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305938 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005939 update_ie->pAdditionIEBuffer = NULL;
5940}
5941
5942/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305943 * send_extended_chan_switch_action_frame()- function to send ECSA
5944 * action frame for each sta connected to SAP/GO and AP in case of
5945 * STA .
5946 * @mac_ctx: pointer to global mac structure
5947 * @new_channel: new channel to switch to.
5948 * @ch_bandwidth: BW of channel to calculate op_class
5949 * @session_entry: pe session
5950 *
5951 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5952 *
5953 * Return: void
5954 */
5955
5956static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5957 uint16_t new_channel, uint8_t ch_bandwidth,
5958 tpPESession session_entry)
5959{
5960 uint16_t op_class;
5961 uint8_t switch_mode = 0, i;
5962 tpDphHashNode psta;
5963
5964
Amar Singhal22995112016-01-22 10:42:33 -08005965 op_class = cds_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305966 mac_ctx->scan.countryCodeCurrent,
5967 new_channel,
5968 ch_bandwidth);
5969
5970 if (LIM_IS_AP_ROLE(session_entry) &&
5971 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
5972 switch_mode = 1;
5973
5974 if (LIM_IS_AP_ROLE(session_entry)) {
5975 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5976 psta =
5977 session_entry->dph.dphHashTable.pDphNodeArray + i;
5978 if (psta && psta->added)
5979 lim_send_extended_chan_switch_action_frame(
5980 mac_ctx,
5981 psta->staAddr,
5982 switch_mode, op_class, new_channel,
5983 LIM_MAX_CSA_IE_UPDATES, session_entry);
5984 }
5985 } else if (LIM_IS_STA_ROLE(session_entry)) {
5986 lim_send_extended_chan_switch_action_frame(mac_ctx,
5987 session_entry->bssId,
5988 switch_mode, op_class, new_channel,
5989 LIM_MAX_CSA_IE_UPDATES, session_entry);
5990 }
5991
5992}
5993
5994/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005995 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5996 *
5997 * @mac_ctx: Pointer to Global MAC structure
5998 * @msg_buf: pointer to the SME message buffer
5999 *
6000 * This function processes SME request messages from HDD or upper layer
6001 * application.
6002 *
6003 * Return: None
6004 */
6005static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
6006 uint32_t *msg_buf)
6007{
6008 tpSirDfsCsaIeRequest dfs_csa_ie_req;
6009 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006010 uint8_t session_id;
6011 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08006012 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006013
6014 if (msg_buf == NULL) {
6015 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6016 return;
6017 }
6018
6019 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
6020 session_entry = pe_find_session_by_bssid(mac_ctx,
6021 dfs_csa_ie_req->bssid, &session_id);
6022 if (session_entry == NULL) {
6023 lim_log(mac_ctx, LOGE, FL(
6024 "Session not found for given BSSID" MAC_ADDRESS_STR),
6025 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
6026 return;
6027 }
6028
6029 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6030 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
6031 GET_LIM_SYSTEM_ROLE(session_entry));
6032 return;
6033 }
6034
6035 /* target channel */
6036 session_entry->gLimChannelSwitch.primaryChannel =
6037 dfs_csa_ie_req->targetChannel;
6038
6039 /* Channel switch announcement needs to be included in beacon */
6040 session_entry->dfsIncludeChanSwIe = true;
6041 session_entry->gLimChannelSwitch.switchCount = LIM_MAX_CSA_IE_UPDATES;
6042 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006043 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05306044 session_entry->gLimChannelSwitch.sec_ch_offset =
6045 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006046 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
6047 session_entry->gLimChannelSwitch.switchMode = 1;
6048
6049 /*
6050 * Validate if SAP is operating HT or VHT mode and set the Channel
6051 * Switch Wrapper element with the Wide Band Switch subelement.
6052 */
6053 if (true != session_entry->vhtCapability)
6054 goto skip_vht;
6055
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006056 /* Now encode the Wider Ch BW element depending on the ch width */
6057 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006058 switch (dfs_csa_ie_req->ch_params.ch_width) {
6059 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006060 /*
6061 * Wide channel BW sublement in channel wrapper element is not
6062 * required in case of 20 Mhz operation. Currently It is set
6063 * only set in case of 40/80 Mhz Operation.
6064 */
6065 session_entry->dfsIncludeChanWrapperIe = false;
6066 wider_bw_ch_switch->newChanWidth =
6067 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
6068 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006069 case CH_WIDTH_40MHZ:
6070 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006071 wider_bw_ch_switch->newChanWidth =
6072 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
6073 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006074 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006075 session_entry->dfsIncludeChanWrapperIe = true;
6076 wider_bw_ch_switch->newChanWidth =
6077 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
6078 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006079 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006080 session_entry->dfsIncludeChanWrapperIe = true;
6081 wider_bw_ch_switch->newChanWidth =
6082 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
6083 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006084 case CH_WIDTH_80P80MHZ:
6085 session_entry->dfsIncludeChanWrapperIe = true;
6086 wider_bw_ch_switch->newChanWidth =
6087 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08006088 /*
6089 * This is not applicable for 20/40/80 Mhz.
6090 * Only used when we support 80+80 Mhz operation.
6091 * In case of 80+80 Mhz, this parameter indicates
6092 * center channel frequency index of 80 Mhz channel of
6093 * frequency segment 1.
6094 */
6095 wider_bw_ch_switch->newCenterChanFreq1 =
6096 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006097 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006098 default:
6099 session_entry->dfsIncludeChanWrapperIe = false;
6100 /*
6101 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
6102 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
6103 */
6104 lim_log(mac_ctx, LOGE, FL("Invalid Channel Width"));
6105 break;
6106 }
6107 /* Fetch the center channel based on the channel width */
6108 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006109 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006110skip_vht:
6111 /* Send CSA IE request from here */
6112 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6113 eSIR_SUCCESS) {
6114 lim_log(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
6115 return;
6116 }
6117
6118 /*
6119 * First beacon update request is sent here, the remaining updates are
6120 * done when the FW responds back after sending the first beacon after
6121 * the template update
6122 */
6123 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306124
6125 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
6126 ch_offset = BW80;
6127 else
6128 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
6129
6130 lim_log(mac_ctx, LOG1, FL("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d"),
6131 session_entry->gLimChannelSwitch.switchCount,
6132 session_entry->gLimChannelSwitch.primaryChannel,
6133 session_entry->gLimChannelSwitch.ch_width,
6134 session_entry->dfsIncludeChanWrapperIe,
6135 ch_offset);
6136
Abhishek Singh518323d2015-10-19 17:42:01 +05306137 /* Send ECSA Action frame after updating the beacon */
6138 send_extended_chan_switch_action_frame(mac_ctx,
6139 session_entry->gLimChannelSwitch.primaryChannel,
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306140 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006141 session_entry->gLimChannelSwitch.switchCount--;
6142}
6143
6144/**
Abhishek Singh518323d2015-10-19 17:42:01 +05306145 * lim_process_ext_change_channel()- function to send ECSA
6146 * action frame for STA/CLI .
6147 * @mac_ctx: pointer to global mac structure
6148 * @msg: params from sme for new channel.
6149 *
6150 * This function is called to send ECSA frame for STA/CLI.
6151 *
6152 * Return: void
6153 */
6154
6155static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
6156 uint32_t *msg)
6157{
6158 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
6159 (struct sir_sme_ext_cng_chan_req *) msg;
6160 tpPESession session_entry = NULL;
6161
6162 if (NULL == msg) {
6163 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6164 return;
6165 }
6166 session_entry =
6167 pe_find_session_by_sme_session_id(mac_ctx,
6168 ext_chng_channel->session_id);
6169 if (NULL == session_entry) {
6170 lim_log(mac_ctx, LOGE,
6171 FL("Session not found for given session %d"),
6172 ext_chng_channel->session_id);
6173 return;
6174 }
6175 if (LIM_IS_AP_ROLE(session_entry)) {
6176 lim_log(mac_ctx, LOGE,
6177 FL("not an STA/CLI session"));
6178 return;
6179 }
6180 send_extended_chan_switch_action_frame(mac_ctx,
6181 ext_chng_channel->new_channel,
6182 0, session_entry);
6183}
6184
6185/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006186 * lim_process_nss_update_request() - process sme nss update req
6187 *
6188 * @mac_ctx: Pointer to Global MAC structure
6189 * @msg_buf: pointer to the SME message buffer
6190 *
6191 * This function processes SME request messages from HDD or upper layer
6192 * application.
6193 *
6194 * Return: None
6195 */
6196static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
6197 uint32_t *msg_buf)
6198{
6199 struct sir_nss_update_request *nss_update_req_ptr;
6200 tpPESession session_entry = NULL;
6201
6202 if (msg_buf == NULL) {
6203 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6204 return;
6205 }
6206
6207 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05306208 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006209 nss_update_req_ptr->vdev_id);
6210 if (session_entry == NULL) {
6211 lim_log(mac_ctx, LOGE, FL(
6212 "Session not found for given session_id %d"),
6213 nss_update_req_ptr->vdev_id);
6214 return;
6215 }
6216
6217 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6218 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
6219 GET_LIM_SYSTEM_ROLE(session_entry));
6220 return;
6221 }
6222
6223 /* populate nss field in the beacon */
6224 session_entry->gLimOperatingMode.present = 1;
6225 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
6226 /* Send nss update request from here */
6227 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6228 eSIR_SUCCESS) {
6229 lim_log(mac_ctx, LOGE,
6230 FL("Unable to set op mode IE in beacon"));
6231 return;
6232 }
6233
6234 lim_send_beacon_ind(mac_ctx, session_entry);
6235}
6236
6237/**
6238 * lim_process_set_ie_req() - process sme set IE request
6239 *
6240 * @mac_ctx: Pointer to Global MAC structure
6241 * @msg_buf: pointer to the SME message buffer
6242 *
6243 * This function processes SME request messages from HDD or upper layer
6244 * application.
6245 *
6246 * Return: None
6247 */
6248static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6249{
6250 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306251 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006252
6253 if (msg_buf == NULL) {
6254 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6255 return;
6256 }
6257
6258 msg = (struct send_extcap_ie *)msg_buf;
6259 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306260 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006261 lim_log(mac_ctx, LOGE, FL("Unable to send ExtCap to FW"));
6262
6263}