blob: e21fe9788b91435c3b62255073e7d2bf1e3e85e6 [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;
613 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
614 &session->shortSlotTimeSupported);
615 session->isCoalesingInIBSSAllowed =
616 sme_start_bss_req->isCoalesingInIBSSAllowed;
617
618}
619
620/**
621 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
622 *@mac_ctx: Pointer to Global MAC structure
623 *@msg_buf: A pointer to the SME message buffer
624 *
625 * This function is called to process SME_START_BSS_REQ message
626 * from HDD or upper layer application.
627 *
628 * Return: None
629 */
630static void
631__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
632{
633 uint16_t size;
634 uint32_t val = 0;
635 tSirRetStatus ret_status;
636 tSirMacChanNum channel_number;
637 tLimMlmStartReq *mlm_start_req = NULL;
638 tpSirSmeStartBssReq sme_start_bss_req = NULL;
639 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
640 /* Flag Used in case of IBSS to Auto generate BSSID. */
641 uint32_t auto_gen_bssid = false;
642 uint8_t session_id;
643 tpPESession session = NULL;
644 uint8_t sme_session_id = 0;
645 uint16_t sme_transaction_id = 0;
646 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700647 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800648 tSirRetStatus cfg_get_wmi_dfs_master_param = eSIR_SUCCESS;
649
650/* FEATURE_WLAN_DIAG_SUPPORT */
651#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
652 /*
653 * Since the session is not created yet, sending NULL.
654 * The response should have the correct state.
655 */
656 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
657 NULL, 0, 0);
658#endif /* FEATURE_WLAN_DIAG_SUPPORT */
659
660 lim_log(mac_ctx, LOG1, FL("Received START_BSS_REQ"));
661
662 /*
663 * Global Sme state and mlm states are not defined yet,
664 * for BT-AMP Suppoprt . TO BE DONE
665 */
666 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
667 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
668 size = sizeof(tSirSmeStartBssReq);
669
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530670 sme_start_bss_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800671 if (NULL == sme_start_bss_req) {
672 lim_log(mac_ctx, LOGE,
673 FL("Allocate Memory fail for LimStartBssReq"));
674 /* Send failure response to host */
675 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
676 goto end;
677 }
678
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530679 qdf_mem_set((void *)sme_start_bss_req, size, 0);
680 qdf_mem_copy(sme_start_bss_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800681 sizeof(tSirSmeStartBssReq));
682 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
683 sme_start_bss_req)) {
684 lim_log(mac_ctx, LOGW,
685 FL("Received invalid eWNI_SME_START_BSS_REQ"));
686 ret_code = eSIR_SME_INVALID_PARAMETERS;
687 goto free;
688 }
689
690 /*
691 * This is the place where PE is going to create a session.
692 * If session is not existed, then create a new session
693 */
694 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800695 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800696 if (session != NULL) {
697 lim_log(mac_ctx, LOGW,
698 FL("Session Already exists for given BSSID"));
699 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
700 session = NULL;
701 goto free;
702 } else {
703 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800704 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800705 &session_id, mac_ctx->lim.maxStation,
706 sme_start_bss_req->bssType);
707 if (session == NULL) {
708 lim_log(mac_ctx, LOGW,
709 FL("Session Can not be created "));
710 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
711 goto free;
712 }
713 }
714
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700715 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
716 /* Probe resp add ie */
717 lim_start_bss_update_add_ie_buffer(mac_ctx,
718 &session->addIeParams.probeRespData_buff,
719 &session->addIeParams.probeRespDataLen,
720 sme_start_bss_req->addIeParams.
721 probeRespData_buff,
722 sme_start_bss_req->addIeParams.
723 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800724
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700725 /* Probe Beacon add ie */
726 lim_start_bss_update_add_ie_buffer(mac_ctx,
727 &session->addIeParams.probeRespBCNData_buff,
728 &session->addIeParams.probeRespBCNDataLen,
729 sme_start_bss_req->addIeParams.
730 probeRespBCNData_buff,
731 sme_start_bss_req->addIeParams.
732 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800733
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700734 /* Assoc resp IE */
735 lim_start_bss_update_add_ie_buffer(mac_ctx,
736 &session->addIeParams.assocRespData_buff,
737 &session->addIeParams.assocRespDataLen,
738 sme_start_bss_req->addIeParams.
739 assocRespData_buff,
740 sme_start_bss_req->addIeParams.
741 assocRespDataLen);
742 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800743 /* Store the session related params in newly created session */
744 session->pLimStartBssReq = sme_start_bss_req;
745
746 /* Store PE session_id in session Table */
747 session->peSessionId = session_id;
748
749 /* Store SME session Id in sessionTable */
750 session->smeSessionId = sme_start_bss_req->sessionId;
751
752 session->transactionId = sme_start_bss_req->transactionId;
753
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530754 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800755 &(sme_start_bss_req->htConfig),
756 sizeof(session->htConfig));
757
Sandeep Puligilla98917432016-06-10 13:50:28 -0700758 qdf_mem_copy(&(session->vht_config),
759 &(sme_start_bss_req->vht_config),
760 sizeof(session->vht_config));
761
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800762 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800763 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800764
765 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530766 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800767 (uint8_t *) &sme_start_bss_req->ssId,
768 (sme_start_bss_req->ssId.length + 1));
769
770 session->bssType = sme_start_bss_req->bssType;
771
772 session->nwType = sme_start_bss_req->nwType;
773
774 session->beaconParams.beaconInterval =
775 sme_start_bss_req->beaconInterval;
776
777 /* Store the channel number in session Table */
778 session->currentOperChannel =
779 sme_start_bss_req->channelId;
780
781 /* Store Persona */
782 session->pePersona = sme_start_bss_req->bssPersona;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530783 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800784 FL("PE PERSONA=%d"), session->pePersona);
785
786 /* Update the phymode */
787 session->gLimPhyMode = sme_start_bss_req->nwType;
788
789 session->maxTxPower =
790 cfg_get_regulatory_max_transmit_power(mac_ctx,
791 session->currentOperChannel);
792 /* Store the dot 11 mode in to the session Table */
793 session->dot11mode = sme_start_bss_req->dot11mode;
794#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
795 session->cc_switch_mode =
796 sme_start_bss_req->cc_switch_mode;
797#endif
798 session->htCapability =
799 IS_DOT11_MODE_HT(session->dot11mode);
800 session->vhtCapability =
801 IS_DOT11_MODE_VHT(session->dot11mode);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530802 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800803 FL("*****session->vhtCapability = %d"),
804 session->vhtCapability);
805 session->txLdpcIniFeatureEnabled =
806 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800807#ifdef WLAN_FEATURE_11W
808 session->limRmfEnabled =
809 sme_start_bss_req->pmfCapable ? 1 : 0;
810 lim_log(mac_ctx, LOG1, FL("Session RMF enabled: %d"),
811 session->limRmfEnabled);
812#endif
813
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530814 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800815 (void *)&sme_start_bss_req->operationalRateSet,
816 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530817 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800818 (void *)&sme_start_bss_req->extendedRateSet,
819 sizeof(tSirMacRateSet));
820
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700821 if (IS_5G_CH(session->currentOperChannel))
822 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
823 else
824 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
825
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800826 switch (sme_start_bss_req->bssType) {
827 case eSIR_INFRA_AP_MODE:
828 lim_configure_ap_start_bss_session(mac_ctx, session,
829 sme_start_bss_req);
Krunal Soni53993f72016-07-08 18:20:03 -0700830 if (session->pePersona == QDF_SAP_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700831 session->vdev_nss = vdev_type_nss->sap;
Krunal Soni53993f72016-07-08 18:20:03 -0700832 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700833 session->vdev_nss = vdev_type_nss->p2p_go;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800834 break;
835 case eSIR_IBSS_MODE:
836 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
837 lim_get_short_slot_from_phy_mode(mac_ctx, session,
838 session->gLimPhyMode,
839 &session->shortSlotTimeSupported);
840
841 /*
842 * initialize to "OPEN".
843 * will be updated upon key installation
844 */
845 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700846 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800847
848 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700849 case eSIR_NDI_MODE:
850 session->limSystemRole = eLIM_NDI_ROLE;
851 break;
852
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800853
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800854 /*
855 * There is one more mode called auto mode.
856 * which is used no where
857 */
858
859 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
860
861 default:
862 /* not used anywhere...used in scan function */
863 break;
864 }
865
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700866 lim_log(mac_ctx, LOG1, FL("persona - %d, nss - %d"),
867 session->pePersona, session->vdev_nss);
868 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800869 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700870 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800871 * parsed (Re)Assoc request structure
872 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700873 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800874 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530875 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700876 size * sizeof(tpSirAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800877 if (NULL == session->parsedAssocReq) {
878 lim_log(mac_ctx, LOGW,
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700879 FL("AllocateMemory() failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800880 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
881 goto free;
882 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530883 qdf_mem_set(session->parsedAssocReq,
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700884 (session->dph.dphHashTable.size *
885 sizeof(tpSirAssocReq)), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800886 }
887
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700888 if (!sme_start_bss_req->channelId &&
889 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800890 lim_log(mac_ctx, LOGE,
891 FL("Received invalid eWNI_SME_START_BSS_REQ"));
892 ret_code = eSIR_SME_INVALID_PARAMETERS;
893 goto free;
894 }
895 channel_number = sme_start_bss_req->channelId;
896#ifdef QCA_HT_2040_COEX
897 if (sme_start_bss_req->obssEnabled)
898 session->htSupportedChannelWidthSet =
899 session->htCapability;
900 else
901#endif
902 session->htSupportedChannelWidthSet =
903 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
904 session->htSecondaryChannelOffset =
905 sme_start_bss_req->sec_ch_offset;
906 session->htRecommendedTxWidthSet =
907 (session->htSecondaryChannelOffset) ? 1 : 0;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530908 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800909 FL("cbMode %u"), sme_start_bss_req->cbMode);
910 if (session->vhtCapability || session->htCapability) {
911 chanwidth = sme_start_bss_req->vht_channel_width;
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800912 lim_log(mac_ctx, LOG1,
913 FL("vht_channel_width %u htSupportedChannelWidthSet %d"),
914 sme_start_bss_req->vht_channel_width,
915 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800916 session->ch_width = chanwidth;
917 if (session->htSupportedChannelWidthSet) {
918 session->ch_center_freq_seg0 =
919 sme_start_bss_req->center_freq_seg0;
920 session->ch_center_freq_seg1 =
921 sme_start_bss_req->center_freq_seg1;
922 } else {
923 session->ch_center_freq_seg0 = 0;
924 session->ch_center_freq_seg1 = 0;
925 }
926 }
927
928 if (session->vhtCapability &&
Krunal Soni53993f72016-07-08 18:20:03 -0700929 (session->ch_width > CH_WIDTH_80MHZ)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800930 session->nss = 1;
Krunal Soni53993f72016-07-08 18:20:03 -0700931 lim_log(mac_ctx, LOG1, FL("nss set to [%d]"),
932 session->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800933 }
Krunal Soni53993f72016-07-08 18:20:03 -0700934 lim_log(mac_ctx, LOG1, FL("vht su tx bformer %d"),
935 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800936
937 /* Delete pre-auth list if any */
938 lim_delete_pre_auth_list(mac_ctx);
939
Krunal Soni53993f72016-07-08 18:20:03 -0700940 if (session->nss == 1) {
941 session->vht_config.su_beam_former = 0;
942 session->vht_config.tx_stbc = 0;
943 session->vht_config.num_soundingdim = 0;
944 session->ht_caps.txSTBC = 0;
945 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800946 /*
947 * keep the RSN/WPA IE information in PE Session Entry
948 * later will be using this to check when received (Re)Assoc req
949 */
950 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
951 &sme_start_bss_req->rsnIE, session);
952
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700953 if (LIM_IS_AP_ROLE(session) ||
954 LIM_IS_IBSS_ROLE(session) ||
955 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800956 session->gLimProtectionControl =
957 sme_start_bss_req->protEnabled;
958 /*
959 * each byte will have the following info
960 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
961 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
962 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530963 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800964 (void *)&sme_start_bss_req->ht_capab,
965 sizeof(uint16_t));
966 /* Initialize WPS PBC session link list */
967 session->pAPWPSPBCSession = NULL;
968 }
969 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530970 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800971 if (NULL == mlm_start_req) {
972 lim_log(mac_ctx, LOGP,
973 FL("Allocate Memory failed for mlmStartReq"));
974 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
975 goto free;
976 }
977
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530978 qdf_mem_set((void *)mlm_start_req, sizeof(tLimMlmStartReq), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800979
980 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530981 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800982 (uint8_t *) &sme_start_bss_req->ssId,
983 sme_start_bss_req->ssId.length + 1);
984 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
985 mlm_start_req->obssProtEnabled =
986 sme_start_bss_req->obssProtEnabled;
987
988 mlm_start_req->bssType = session->bssType;
989
990 /* Fill PE session Id from the session Table */
991 mlm_start_req->sessionId = session->peSessionId;
992
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700993 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
994 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800995 /*
996 * Copy the BSSId from sessionTable to
997 * mlmStartReq struct
998 */
999 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
1000 } else {
1001 /* ibss mode */
1002 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1003
1004 ret_status = wlan_cfg_get_int(mac_ctx,
1005 WNI_CFG_IBSS_AUTO_BSSID,
1006 &auto_gen_bssid);
1007 if (ret_status != eSIR_SUCCESS) {
1008 lim_log(mac_ctx, LOGP,
1009 FL("Get Auto Gen BSSID fail,Status=%d"),
1010 ret_status);
1011 ret_code = eSIR_LOGP_EXCEPTION;
1012 goto free;
1013 }
1014
1015 if (!auto_gen_bssid) {
1016 /*
1017 * We're not auto generating BSSID.
1018 * Instead, get it from session entry
1019 */
1020 sir_copy_mac_addr(mlm_start_req->bssId,
1021 session->bssId);
1022 /*
1023 * Start IBSS group BSSID
1024 * Auto Generating BSSID.
1025 */
1026 auto_gen_bssid = ((mlm_start_req->bssId[0] &
1027 0x01) ? true : false);
1028 }
1029
1030 if (auto_gen_bssid) {
1031 /*
1032 * if BSSID is not any uc id.
1033 * then use locally generated BSSID.
1034 * Autogenerate the BSSID
1035 */
1036 lim_get_random_bssid(mac_ctx,
1037 mlm_start_req->bssId);
1038 mlm_start_req->bssId[0] = 0x02;
1039
1040 /*
1041 * Copy randomly generated BSSID
1042 * to the session Table
1043 */
1044 sir_copy_mac_addr(session->bssId,
1045 mlm_start_req->bssId);
1046 }
1047 }
1048 /* store the channel num in mlmstart req structure */
1049 mlm_start_req->channelNumber = session->currentOperChannel;
1050 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
1051 mlm_start_req->beaconPeriod =
1052 session->beaconParams.beaconInterval;
1053
1054 if (LIM_IS_AP_ROLE(session)) {
1055 mlm_start_req->dtimPeriod = session->dtimPeriod;
1056 mlm_start_req->wps_state = session->wps_state;
1057
1058 } else {
1059 if (wlan_cfg_get_int(mac_ctx,
1060 WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
1061 lim_log(mac_ctx, LOGP,
1062 FL("could not retrieve DTIM Period"));
1063 mlm_start_req->dtimPeriod = (uint8_t) val;
1064 }
1065
1066 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_PERIOD, &val) !=
1067 eSIR_SUCCESS)
1068 lim_log(mac_ctx, LOGP,
1069 FL("could not retrieve Beacon interval"));
1070 mlm_start_req->cfParamSet.cfpPeriod = (uint8_t) val;
1071
1072 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_MAX_DURATION, &val) !=
1073 eSIR_SUCCESS)
1074 lim_log(mac_ctx, LOGP,
1075 FL("could not retrieve CFPMaxDuration"));
1076 mlm_start_req->cfParamSet.cfpMaxDuration = (uint16_t) val;
1077
1078 /*
1079 * this may not be needed anymore now,
1080 * as rateSet is now included in the
1081 * session entry and MLM has session context.
1082 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301083 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001084 (void *)&session->rateSet,
1085 sizeof(tSirMacRateSet));
1086
1087 /* Now populate the 11n related parameters */
1088 mlm_start_req->nwType = session->nwType;
1089 mlm_start_req->htCapable = session->htCapability;
1090
1091 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1092 /* Unused */
1093 mlm_start_req->dualCTSProtection =
1094 mac_ctx->lim.gHTDualCTSProtection;
1095 mlm_start_req->txChannelWidthSet =
1096 session->htRecommendedTxWidthSet;
1097
1098 session->limRFBand = lim_get_rf_band(channel_number);
1099
1100 /* Initialize 11h Enable Flag */
1101 session->lim11hEnable = 0;
1102 if ((mlm_start_req->bssType != eSIR_IBSS_MODE) &&
1103 (SIR_BAND_5_GHZ == session->limRFBand)) {
1104 if (wlan_cfg_get_int(mac_ctx,
1105 WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
1106 lim_log(mac_ctx, LOGP,
1107 FL("Fail to get WNI_CFG_11H_ENABLED "));
1108 else
1109 session->lim11hEnable = val;
1110
1111 if (session->lim11hEnable &&
1112 (eSIR_INFRA_AP_MODE ==
1113 mlm_start_req->bssType)) {
1114 cfg_get_wmi_dfs_master_param =
1115 wlan_cfg_get_int(mac_ctx,
1116 WNI_CFG_DFS_MASTER_ENABLED,
1117 &val);
1118 session->lim11hEnable = val;
1119 }
1120 if (cfg_get_wmi_dfs_master_param != eSIR_SUCCESS)
1121 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
1122 lim_log(mac_ctx, LOGE,
1123 FL("Get Fail, CFG DFS ENABLE"));
1124 }
1125
1126 if (!session->lim11hEnable) {
1127 if (cfg_set_int(mac_ctx,
1128 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
1129 eSIR_SUCCESS)
1130 /*
1131 * Failed to set the CFG param
1132 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1133 */
1134 lim_log(mac_ctx, LOGE,
1135 FL("Set LOCAL_POWER_CONSTRAINT failed"));
1136 }
1137
1138 session->limPrevSmeState = session->limSmeState;
1139 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1140 MTRACE(mac_trace
1141 (mac_ctx, TRACE_CODE_SME_STATE,
1142 session->peSessionId,
1143 session->limSmeState));
1144
1145 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1146 (uint32_t *) mlm_start_req);
1147 return;
1148 } else {
1149
1150 lim_log(mac_ctx, LOGE,
1151 FL("Received unexpected START_BSS_REQ, in state %X"),
1152 mac_ctx->lim.gLimSmeState);
1153 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
1154 goto end;
1155 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1156
1157free:
1158 if ((session != NULL) &&
1159 (session->pLimStartBssReq == sme_start_bss_req)) {
1160 session->pLimStartBssReq = NULL;
1161 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301162 qdf_mem_free(sme_start_bss_req);
1163 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001164
1165end:
1166 if (sme_start_bss_req != NULL) {
1167 sme_session_id = sme_start_bss_req->sessionId;
1168 sme_transaction_id = sme_start_bss_req->transactionId;
1169 }
1170 if (NULL != session) {
1171 pe_delete_session(mac_ctx, session);
1172 session = NULL;
1173 }
1174 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1175 session, sme_session_id, sme_transaction_id);
1176}
1177
1178/**
1179 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1180 *
1181 * @pMac: Global MAC context
1182 * @pMsg: Message pointer
1183 *
1184 * Wrapper for the function __lim_handle_sme_start_bss_request
1185 * This message will be defered until softmac come out of
1186 * scan mode or if we have detected radar on the current
1187 * operating channel.
1188 *
1189 * return true - If we consumed the buffer
1190 * false - If have defered the message.
1191 */
1192static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1193{
1194 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1195 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1196 /**
1197 * If message defered, buffer is not consumed yet.
1198 * So return false
1199 */
1200 return false;
1201 }
1202
1203 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1204 return true;
1205}
1206
1207/**
1208 * lim_get_random_bssid()
1209 *
1210 * FUNCTION:This function is called to process generate the random number for bssid
1211 * This function is called to process SME_SCAN_REQ message
1212 * from HDD or upper layer application.
1213 *
1214 * LOGIC:
1215 *
1216 * ASSUMPTIONS:
1217 *
1218 * NOTE:
1219 * 1. geneartes the unique random number for bssid in ibss
1220 *
1221 * @param pMac Pointer to Global MAC structure
1222 * @param *data Pointer to bssid buffer
1223 * @return None
1224 */
1225void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1226{
1227 uint32_t random[2];
1228 random[0] = tx_time_get();
1229 random[0] |= (random[0] << 15);
1230 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301231 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001232}
1233
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301234static QDF_STATUS lim_send_hal_start_scan_offload_req(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001235 tpSirSmeScanReq pScanReq)
1236{
1237 tSirScanOffloadReq *pScanOffloadReq;
1238 uint8_t *p;
1239 uint8_t *ht_cap_ie;
1240 tSirMsgQ msg;
1241 uint16_t i, len;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001242 uint16_t ht_cap_len = 0;
1243 uint16_t addn_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001244 uint8_t *vht_cap_ie;
1245 uint16_t vht_cap_len = 0;
Naveen Rawat02e12662016-08-31 16:49:27 -07001246 uint8_t *vendor_tpc_ie;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001247 tSirRetStatus status, rc = eSIR_SUCCESS;
1248 tDot11fIEExtCap extracted_extcap = {0};
1249 bool extcap_present = true;
Naveen Rawat02e12662016-08-31 16:49:27 -07001250 uint32_t lim_11h_enable = WNI_CFG_11H_ENABLED_STADEF;
1251
1252 wlan_cfg_get_int(pMac, WNI_CFG_11H_ENABLED, &lim_11h_enable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001253
1254 if (pScanReq->uIEFieldLen) {
1255 status = lim_strip_extcap_update_struct(pMac,
1256 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1257 &pScanReq->uIEFieldLen, &extracted_extcap);
1258
1259 if (eSIR_SUCCESS != status) {
1260 extcap_present = false;
1261 lim_log(pMac, LOG1,
1262 FL("Unable to Strip ExtCap IE from Scan Req"));
1263 }
1264
1265 if (extcap_present) {
1266 lim_log(pMac, LOG1,
1267 FL("Extcap was part of SCAN IE - Updating FW"));
1268 lim_send_ext_cap_ie(pMac, pScanReq->sessionId,
1269 &extracted_extcap, true);
1270 }
1271 } else {
1272 lim_log(pMac, LOG1,
1273 FL("No IEs in the scan request from supplicant"));
1274 }
1275
1276 /**
1277 * The tSirScanOffloadReq will reserve the space for first channel,
1278 * so allocate the memory for (numChannels - 1) and uIEFieldLen
1279 */
1280 len = sizeof(tSirScanOffloadReq) +
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001281 (pScanReq->channelList.numChannels - 1) +
1282 pScanReq->uIEFieldLen;
1283 if (!pMac->per_band_chainmask_supp) {
1284 if (IS_DOT11_MODE_HT(pScanReq->dot11mode)) {
1285 lim_log(pMac, LOG1, FL(
1286 "Adding HT Caps IE since dot11mode=%d"),
1287 pScanReq->dot11mode);
1288 /* 2 bytes for EID and Length */
1289 ht_cap_len = 2 + sizeof(tHtCaps);
1290 len += ht_cap_len;
1291 addn_ie_len += ht_cap_len;
1292 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001293
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001294 if (IS_DOT11_MODE_VHT(pScanReq->dot11mode)) {
1295 lim_log(pMac, LOG1, FL(
1296 "Adding VHT Caps IE since dot11mode=%d"),
1297 pScanReq->dot11mode);
1298 /* 2 bytes for EID and Length */
1299 vht_cap_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
1300 sizeof(tSirVhtMcsInfo);
1301 len += vht_cap_len;
1302 addn_ie_len += vht_cap_len;
1303 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001304 }
Naveen Rawat02e12662016-08-31 16:49:27 -07001305
1306 if (lim_11h_enable) {
1307 addn_ie_len += DOT11F_IE_WFATPC_MAX_LEN + 2;
1308 len += DOT11F_IE_WFATPC_MAX_LEN + 2;
1309 }
1310
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301311 pScanOffloadReq = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001312 if (NULL == pScanOffloadReq) {
1313 lim_log(pMac, LOGE,
1314 FL("AllocateMemory failed for pScanOffloadReq"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301315 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001316 }
1317
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301318 qdf_mem_set((uint8_t *) pScanOffloadReq, len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001319
1320 msg.type = WMA_START_SCAN_OFFLOAD_REQ;
1321 msg.bodyptr = pScanOffloadReq;
1322 msg.bodyval = 0;
1323
Anurag Chouhanc5548422016-02-24 18:33:27 +05301324 qdf_copy_macaddr(&pScanOffloadReq->bssId, &pScanReq->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325
1326 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID) {
1327 lim_log(pMac, LOGE,
1328 FL("Invalid value (%d) for numSsid"),
1329 SIR_SCAN_MAX_NUM_SSID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301330 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301331 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001332 }
1333
1334 pScanOffloadReq->numSsid = pScanReq->numSsid;
1335 for (i = 0; i < pScanOffloadReq->numSsid; i++) {
1336 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301337 qdf_mem_copy((uint8_t *) pScanOffloadReq->ssId[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001338 (uint8_t *) pScanReq->ssId[i].ssId,
1339 pScanOffloadReq->ssId[i].length);
1340 }
1341
1342 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301343 qdf_copy_macaddr(&pScanOffloadReq->selfMacAddr, &pScanReq->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001344 pScanOffloadReq->bssType = pScanReq->bssType;
1345 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1346 pScanOffloadReq->scanType = pScanReq->scanType;
1347 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1348 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1349 pScanOffloadReq->restTime = pScanReq->restTime;
Agrawal Ashish17bb3902016-05-05 13:29:40 +05301350 pScanOffloadReq->min_rest_time = pScanReq->min_rest_time;
1351 pScanOffloadReq->idle_time = pScanReq->idle_time;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301352 pScanOffloadReq->scan_adaptive_dwell_mode =
1353 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001354
1355 /* for normal scan, the value for p2pScanType should be 0
1356 always */
1357 if (pScanReq->p2pSearch)
1358 pScanOffloadReq->p2pScanType = P2P_SCAN_TYPE_SEARCH;
1359
1360 pScanOffloadReq->sessionId = pScanReq->sessionId;
1361 pScanOffloadReq->scan_id = pScanReq->scan_id;
Deepak Dhamdhered97bfb32015-10-11 15:16:18 -07001362 pScanOffloadReq->scan_requestor_id = USER_SCAN_REQUESTOR_ID;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301363 pScanOffloadReq->scan_adaptive_dwell_mode =
1364 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001365
1366 if (pScanOffloadReq->sessionId >= pMac->lim.maxBssId)
1367 lim_log(pMac, LOGE, FL("Invalid pe sessionID : %d"),
1368 pScanOffloadReq->sessionId);
1369
1370 pScanOffloadReq->channelList.numChannels =
1371 pScanReq->channelList.numChannels;
1372 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1373 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1374 p[i] = pScanReq->channelList.channelNumber[i];
1375
1376 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1377 pScanOffloadReq->uIEFieldOffset = len - addn_ie_len -
1378 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301379 qdf_mem_copy((uint8_t *) pScanOffloadReq +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001380 pScanOffloadReq->uIEFieldOffset,
1381 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1382 pScanReq->uIEFieldLen);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001383 if (!pMac->per_band_chainmask_supp) {
1384 /* Copy HT Capability info if dot11mode is HT */
1385 if (IS_DOT11_MODE_HT(pScanReq->dot11mode)) {
1386 /* Populate EID and Length field here */
1387 ht_cap_ie = (uint8_t *) pScanOffloadReq +
1388 pScanOffloadReq->uIEFieldOffset +
1389 pScanOffloadReq->uIEFieldLen;
1390 qdf_mem_set(ht_cap_ie, ht_cap_len, 0);
1391 *ht_cap_ie = SIR_MAC_HT_CAPABILITIES_EID;
1392 *(ht_cap_ie + 1) = ht_cap_len - 2;
1393 lim_set_ht_caps(pMac, NULL, ht_cap_ie, ht_cap_len);
1394 pScanOffloadReq->uIEFieldLen += ht_cap_len;
1395 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001396
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001397 /* Copy VHT Capability info if dot11mode is VHT Capable */
1398 if (IS_DOT11_MODE_VHT(pScanReq->dot11mode)) {
1399 /* Populate EID and Length field here */
1400 vht_cap_ie = (uint8_t *) pScanOffloadReq +
1401 pScanOffloadReq->uIEFieldOffset +
1402 pScanOffloadReq->uIEFieldLen;
1403 qdf_mem_set(vht_cap_ie, vht_cap_len, 0);
1404 *vht_cap_ie = SIR_MAC_VHT_CAPABILITIES_EID;
1405 *(vht_cap_ie + 1) = vht_cap_len - 2;
1406 lim_set_vht_caps(pMac, NULL, vht_cap_ie, vht_cap_len);
1407 pScanOffloadReq->uIEFieldLen += vht_cap_len;
1408 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001409 }
Naveen Rawat02e12662016-08-31 16:49:27 -07001410
1411 if (lim_11h_enable) {
1412 tDot11fIEWFATPC wfa_tpc;
1413 vendor_tpc_ie = (uint8_t *) pScanOffloadReq +
1414 pScanOffloadReq->uIEFieldOffset +
1415 pScanOffloadReq->uIEFieldLen;
1416 populate_dot11f_wfatpc(pMac, &wfa_tpc,
1417 rrm_get_mgmt_tx_power(pMac, NULL), 0);
1418 vendor_tpc_ie[0] = DOT11F_EID_WFATPC;
1419 vendor_tpc_ie[1] = DOT11F_IE_WFATPC_MAX_LEN;
1420 qdf_mem_copy(&vendor_tpc_ie[2], SIR_MAC_WFA_TPC_OUI,
1421 SIR_MAC_WFA_TPC_OUI_SIZE);
1422 qdf_mem_copy(&vendor_tpc_ie[SIR_MAC_WFA_TPC_OUI_SIZE + 2],
1423 ((uint8_t *)&wfa_tpc) + 1,
1424 DOT11F_IE_WFATPC_MAX_LEN - SIR_MAC_WFA_TPC_OUI_SIZE);
1425 pScanOffloadReq->uIEFieldLen += DOT11F_IE_WFATPC_MAX_LEN + 2;
1426 }
1427
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001428 rc = wma_post_ctrl_msg(pMac, &msg);
1429 if (rc != eSIR_SUCCESS) {
1430 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() return failure"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301431 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301432 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001433 }
1434
1435 lim_log(pMac, LOG1, FL("Processed Offload Scan Request Successfully"));
1436
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301437 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001438}
1439
1440/**
1441 * __lim_process_sme_scan_req() - Process the SME Scan Request
1442 * @mac_ctx: Global MAC Context
1443 * @msg_buf: Buffer which contains the request and pertinent parameters
1444 *
1445 * This function is called to process SME_SCAN_REQ message
1446 * from HDD or upper layer application.
1447 *
1448 * Return: None
1449 */
1450
1451static void __lim_process_sme_scan_req(tpAniSirGlobal mac_ctx,
1452 uint32_t *msg_buf)
1453{
1454 tpSirSmeScanReq scan_req;
1455 uint8_t valid_req = 0;
1456
1457#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1458 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL,
1459 eSIR_SUCCESS, eSIR_SUCCESS);
1460#endif
1461
1462 scan_req = (tpSirSmeScanReq) msg_buf;
1463 lim_log(mac_ctx, LOG1,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301464 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 -08001465 scan_req->scan_id, scan_req->channelList.numChannels,
1466 scan_req->minChannelTime, scan_req->maxChannelTime,
1467 scan_req->uIEFieldLen, scan_req->returnAfterFirstMatch,
1468 scan_req->returnFreshResults, scan_req->returnUniqueResults,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301469 lim_scan_type_to_string(scan_req->scanType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001470 scan_req->scanType, mac_ctx->lim.gLimRspReqd ? 1 : 0);
1471 /*
1472 * Since scan req always requires a response, we will overwrite response
1473 * required here. This is added esp to take care of the condition where
1474 * in p2p go case, we hold the scan req and insert single NOA. We send
1475 * the held scan request to FW later on getting start NOA ind from FW so
1476 * we lose state of the gLimRspReqd flag for the scan req if any other
1477 * request comes by then. e.g. While unit testing, we found when insert
1478 * single NOA is done, we see a get stats request which turns the flag
1479 * gLimRspReqd to false; now when we actually start the saved scan req
1480 * for init scan after getting NOA started, the gLimRspReqd being a
1481 * global flag is showing false instead of true value for this saved
1482 * scan req. Since all scan reqs coming to lim require a response,
1483 * there is no harm in setting the global flag gLimRspReqd to true here.
1484 */
1485 mac_ctx->lim.gLimRspReqd = true;
1486
1487 /*
1488 * copy the Self MAC address from SmeReq to the globalplace,
1489 * used for sending probe req
1490 */
Srinivas Girigowda2c6bf002015-09-24 11:43:31 -07001491 sir_copy_mac_addr(mac_ctx->lim.gSelfMacAddr,
1492 scan_req->selfMacAddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001493 valid_req = lim_is_sme_scan_req_valid(mac_ctx, scan_req);
1494
1495 if (!valid_req || mac_ctx->lim.scan_disabled) {
1496 lim_log(mac_ctx, LOGE,
1497 FL("Scan disabled %d, Valid Scan Req %d"),
1498 mac_ctx->lim.scan_disabled, valid_req);
1499
1500 if (mac_ctx->lim.gLimRspReqd) {
1501 mac_ctx->lim.gLimRspReqd = false;
1502
1503 lim_send_sme_scan_rsp(mac_ctx,
1504 eSIR_SME_INVALID_PARAMETERS,
1505 scan_req->sessionId,
1506 scan_req->transactionId,
1507 scan_req->scan_id);
1508 }
1509 return;
1510 }
1511
1512 /*
1513 * If scan request is received in idle, joinFailed
1514 * states or in link established state (in STA role)
1515 * or in normal state (in STA-in-IBSS/AP role) with
1516 * 'return fresh scan results' request from HDD or
1517 * it is periodic background scanning request,
1518 * trigger fresh scan request to MLM
1519 */
1520 if (__lim_fresh_scan_reqd(mac_ctx, scan_req->returnFreshResults)) {
1521
1522 mac_ctx->lim.gLim24Band11dScanDone = 0;
1523 mac_ctx->lim.gLim50Band11dScanDone = 0;
1524 mac_ctx->lim.gLimReturnAfterFirstMatch =
1525 scan_req->returnAfterFirstMatch;
1526 mac_ctx->lim.gLimReturnUniqueResults =
1527 ((scan_req->returnUniqueResults) > 0 ? true : false);
1528
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301529 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001530 lim_send_hal_start_scan_offload_req(mac_ctx,
1531 scan_req)) {
1532 lim_log(mac_ctx, LOGE, FL(
1533 "Couldn't send Offload scan request"));
1534 lim_send_sme_scan_rsp(mac_ctx,
1535 eSIR_SME_INVALID_PARAMETERS,
1536 scan_req->sessionId,
1537 scan_req->transactionId,
1538 scan_req->scan_id);
1539 return;
1540 }
Anurag Chouhanffb21542016-02-17 14:33:03 +05301541 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001542 /* In all other cases return 'cached' scan results */
1543 if (mac_ctx->lim.gLimRspReqd) {
1544 mac_ctx->lim.gLimRspReqd = false;
1545 lim_send_sme_scan_rsp(mac_ctx, eSIR_SME_SUCCESS,
1546 scan_req->sessionId,
1547 scan_req->transactionId, scan_req->scan_id);
1548 }
1549 }
1550}
1551
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001552/**
1553 * __lim_process_clear_dfs_channel_list()
1554 *
1555 ***FUNCTION:
1556 ***Clear DFS channel list when country is changed/aquired.
1557 .*This message is sent from SME.
1558 *
1559 ***LOGIC:
1560 *
1561 ***ASSUMPTIONS:
1562 *
1563 ***NOTE:
1564 *
1565 * @param pMac Pointer to Global MAC structure
1566 * @param *pMsgBuf A pointer to the SME message buffer
1567 * @return None
1568 */
1569static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1570{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301571 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001572}
1573
1574/**
1575 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1576 * @mac_ctx: Pointer to Global MAC structure
1577 * @msg_buf: A pointer to the SME message buffer
1578 *
1579 * This function is called to process SME_JOIN_REQ message
1580 * from HDD or upper layer application.
1581 *
1582 * Return: None
1583 */
1584static void
1585__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1586{
1587 tpSirSmeJoinReq sme_join_req = NULL;
1588 tLimMlmJoinReq *mlm_join_req;
1589 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1590 uint32_t val = 0;
1591 uint16_t n_size;
1592 uint8_t session_id;
1593 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301594 uint8_t sme_session_id = 0;
1595 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001596 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001597 uint16_t ie_len;
1598 uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001599 tSirBssDescription *bss_desc;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001600 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001601
Arif Hussain995fcaf2016-07-18 11:28:22 -07001602 if (!mac_ctx || !msg_buf) {
1603 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1604 FL("JOIN REQ with invalid data"));
1605 return;
1606 }
1607
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001608/* FEATURE_WLAN_DIAG_SUPPORT */
1609#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1610 /*
1611 * Not sending any session, since it is not created yet.
1612 * The response whould have correct state.
1613 */
1614 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1615#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1616
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001617 /*
1618 * Expect Join request in idle state.
1619 * Reassociate request is expected in link established state.
1620 */
1621
1622 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1623 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1624 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1625 msg_buf);
1626
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301627 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001628 if (NULL == sme_join_req) {
1629 lim_log(mac_ctx, LOGP,
1630 FL("AllocateMemory failed for sme_join_req"));
1631 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301632 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001633 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301634 (void)qdf_mem_set((void *)sme_join_req, n_size, 0);
1635 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001636 n_size);
1637
1638 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1639 /* Received invalid eWNI_SME_JOIN_REQ */
1640 /* Log the event */
1641 lim_log(mac_ctx, LOGW,
1642 FL("SessionId:%d JOIN REQ with invalid data"),
1643 sme_join_req->sessionId);
1644 ret_code = eSIR_SME_INVALID_PARAMETERS;
1645 goto end;
1646 }
1647
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001648 /*
1649 * Update the capability here itself as this is used in
1650 * lim_extract_ap_capability() below. If not updated issues
1651 * like not honoring power constraint on 1st association after
1652 * driver loading might occur.
1653 */
1654 lim_update_rrm_capability(mac_ctx, sme_join_req);
1655
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001656 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001657 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001658 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001659 &session_id);
1660
1661 if (session != NULL) {
1662 lim_log(mac_ctx, LOGE,
1663 FL("Session(%d) Already exists for BSSID: "
1664 MAC_ADDRESS_STR " in limSmeState = %X"),
1665 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001666 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001667 session->limSmeState);
1668
1669 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1670 session->smeSessionId == sme_join_req->sessionId) {
1671 /*
1672 * Received eWNI_SME_JOIN_REQ for same
1673 * BSS as currently associated.
1674 * Log the event and send success
1675 */
1676 lim_log(mac_ctx, LOGW,
1677 FL("SessionId: %d"), session_id);
1678 lim_log(mac_ctx, LOGW,
1679 FL("JOIN_REQ for current joined BSS"));
1680 /* Send Join success response to host */
1681 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1682 session = NULL;
1683 goto end;
1684 } else {
1685 lim_log(mac_ctx, LOGE,
1686 FL("JOIN_REQ not for current joined BSS"));
1687 ret_code = eSIR_SME_REFUSED;
1688 session = NULL;
1689 goto end;
1690 }
1691 } else {
1692 /*
1693 * Session Entry does not exist for given BSSId
1694 * Try to Create a new session
1695 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001696 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001697 &session_id, mac_ctx->lim.maxStation,
1698 eSIR_INFRASTRUCTURE_MODE);
1699 if (session == NULL) {
1700 lim_log(mac_ctx, LOGE,
1701 FL("Session Can not be created "));
1702 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1703 goto end;
1704 } else
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301705 lim_log(mac_ctx, LOG2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001706 FL("SessionId:%d New session created"),
1707 session_id);
1708 }
1709 session->isAmsduSupportInAMPDU =
1710 sme_join_req->isAmsduSupportInAMPDU;
1711
1712 /*
1713 * Store Session related parameters
1714 * Store PE session Id in session Table
1715 */
1716 session->peSessionId = session_id;
1717
1718 /* store the smejoin req handle in session table */
1719 session->pLimJoinReq = sme_join_req;
1720
1721 /* Store SME session Id in sessionTable */
1722 session->smeSessionId = sme_join_req->sessionId;
1723
1724 /* Store SME transaction Id in session Table */
1725 session->transactionId = sme_join_req->transactionId;
1726
1727 /* Store beaconInterval */
1728 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001729 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001730
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301731 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001732 sizeof(session->htConfig));
1733
Sandeep Puligilla98917432016-06-10 13:50:28 -07001734 qdf_mem_copy(&(session->vht_config),
1735 &(sme_join_req->vht_config),
1736 sizeof(session->vht_config));
1737
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001738 /* Copying of bssId is already done, while creating session */
1739 sir_copy_mac_addr(session->selfMacAddr,
1740 sme_join_req->selfMacAddr);
1741 session->bssType = sme_join_req->bsstype;
1742
1743 session->statypeForBss = STA_ENTRY_PEER;
1744 session->limWmeEnabled = sme_join_req->isWMEenabled;
1745 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301746 session->wps_registration = sme_join_req->wps_registration;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001747
1748 /* Store vendor specfic IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001749 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001750 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1751
1752 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
1753 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001754 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001755
1756 if (NULL != vendor_ie) {
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08001757 lim_log(mac_ctx, LOG1, FL("Cisco vendor OUI present"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001758 session->isCiscoVendorAP = true;
1759 } else {
1760 session->isCiscoVendorAP = false;
1761 }
1762
1763 /* Copy the dot 11 mode in to the session table */
1764
1765 session->dot11mode = sme_join_req->dot11mode;
1766#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1767 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1768#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001769 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001770 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1771 session->enableHtSmps = sme_join_req->enableHtSmps;
1772 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001773 session->send_smps_action =
1774 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001775 /*
1776 * By default supported NSS 1x1 is set to true
1777 * and later on updated while determining session
1778 * supported rates which is the intersection of
1779 * self and peer rates
1780 */
1781 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301782 /*Store Persona */
1783 session->pePersona = sme_join_req->staPersona;
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001784 lim_log(mac_ctx, LOG1,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301785 FL("enable Smps: %d mode: %d send action: %d supported nss 1x1: %d pePersona %d cbMode %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001786 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001787 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001788 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301789 session->supported_nss_1x1,
1790 session->pePersona,
1791 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001792
1793 /*Store Persona */
1794 session->pePersona = sme_join_req->staPersona;
1795 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
1796 FL("PE PERSONA=%d cbMode %u"),
1797 session->pePersona, sme_join_req->cbMode);
1798 /* Copy The channel Id to the session Table */
1799 session->currentOperChannel = bss_desc->channelId;
1800 if (IS_5G_CH(session->currentOperChannel))
1801 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001802 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001803 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
1804 if (session->pePersona == QDF_P2P_CLIENT_MODE)
1805 session->vdev_nss = vdev_type_nss->p2p_cli;
1806 else
1807 session->vdev_nss = vdev_type_nss->sta;
1808 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001809 session->vhtCapability =
1810 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001811 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301812 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001813 session->vht_config.su_beam_formee =
1814 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001815 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001816 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001817 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001818 session->enableVhtpAid =
1819 sme_join_req->enableVhtpAid;
1820 session->enableVhtGid =
1821 sme_join_req->enableVhtGid;
Krunal Soni53993f72016-07-08 18:20:03 -07001822 lim_log(mac_ctx, LOG1, FL("vht su bformer [%d]"),
1823 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001824 }
Krunal Soni53993f72016-07-08 18:20:03 -07001825
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301826 lim_log(mac_ctx, LOG1,
Krunal Soni53993f72016-07-08 18:20:03 -07001827 FL("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d"),
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301828 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001829 session->vht_config.su_beam_formee,
1830 session->vht_config.csnof_beamformer_antSup,
1831 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001832 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001833 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001834 handle_ht_capabilityand_ht_info(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001835 /* cbMode is already merged value of peer and self -
1836 * done by csr in csr_get_cb_mode_from_ies */
1837 session->htSupportedChannelWidthSet =
1838 (sme_join_req->cbMode) ? 1 : 0;
1839 session->htRecommendedTxWidthSet =
1840 session->htSupportedChannelWidthSet;
1841 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1842
1843 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1844 session->ch_center_freq_seg0 =
1845 session->currentOperChannel - 2;
1846 session->ch_width = CH_WIDTH_40MHZ;
1847 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1848 sme_join_req->cbMode) {
1849 session->ch_center_freq_seg0 =
1850 session->currentOperChannel + 2;
1851 session->ch_width = CH_WIDTH_40MHZ;
1852 } else {
1853 session->ch_center_freq_seg0 = 0;
1854 session->ch_width = CH_WIDTH_20MHZ;
1855 }
1856
1857 /* Record if management frames need to be protected */
1858#ifdef WLAN_FEATURE_11W
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001859 if (eSIR_ED_AES_128_CMAC == sme_join_req->MgmtEncryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001860 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001861 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001862 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001863#endif
1864
1865#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001866 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001867#endif
1868
1869 /* Copy the SSID from smejoinreq to session entry */
1870 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301871 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001872 session->ssId.length);
1873
1874 /*
1875 * Determin 11r or ESE connection based on input from SME
1876 * which inturn is dependent on the profile the user wants
1877 * to connect to, So input is coming from supplicant
1878 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001879 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001880#ifdef FEATURE_WLAN_ESE
1881 session->isESEconnection = sme_join_req->isESEconnection;
1882#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001883 session->isFastTransitionEnabled =
1884 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001885
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001886 session->isFastRoamIniFeatureEnabled =
1887 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001888 session->txLdpcIniFeatureEnabled =
1889 sme_join_req->txLdpcIniFeatureEnabled;
1890
1891 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1892 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001893 } else {
1894 /*
1895 * Throw an error and return and make
1896 * sure to delete the session.
1897 */
1898 lim_log(mac_ctx, LOGE,
1899 FL("recvd JOIN_REQ with invalid bss type %d"),
1900 session->bssType);
1901 ret_code = eSIR_SME_INVALID_PARAMETERS;
1902 goto end;
1903 }
1904
1905 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301906 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001907 &sme_join_req->addIEScan, sizeof(tSirAddie));
1908
1909 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301910 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001911 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1912
1913 val = sizeof(tLimMlmJoinReq) +
1914 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301915 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001916 if (NULL == mlm_join_req) {
1917 lim_log(mac_ctx, LOGP,
1918 FL("AllocateMemory failed for mlmJoinReq"));
Nitesh Shah0102cac2016-07-13 14:38:30 +05301919 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1920 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001921 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301922 (void)qdf_mem_set((void *)mlm_join_req, val, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001923
1924 /* PE SessionId is stored as a part of JoinReq */
1925 mlm_join_req->sessionId = session->peSessionId;
1926
1927 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1928 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1929 eSIR_SUCCESS) {
1930 lim_log(mac_ctx, LOGP,
1931 FL("couldn't retrieve JoinFailureTimer value"
1932 " setting to default value"));
1933 mlm_join_req->joinFailureTimeout =
1934 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1935 }
1936
1937 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301938 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001939 (void *)&sme_join_req->operationalRateSet,
1940 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301941 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001942 (void *)&sme_join_req->extendedRateSet,
1943 sizeof(tSirMacRateSet));
1944 /*
1945 * this may not be needed anymore now, as rateSet is now
1946 * included in the session entry and MLM has session context.
1947 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301948 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001949 (void *)&session->rateSet,
1950 sizeof(tSirMacRateSet));
1951
1952 session->encryptType = sme_join_req->UCEncryptionType;
1953
1954 mlm_join_req->bssDescription.length =
1955 session->pLimJoinReq->bssDescription.length;
1956
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301957 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001958 (uint8_t *)
1959 &session->pLimJoinReq->bssDescription.bssId,
1960 session->pLimJoinReq->bssDescription.length + 2);
1961
1962 session->limCurrentBssCaps =
1963 session->pLimJoinReq->bssDescription.capabilityInfo;
1964
1965 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1966 session->currentOperChannel);
1967 local_power_constraint = reg_max;
1968
1969 lim_extract_ap_capability(mac_ctx,
1970 (uint8_t *)
1971 session->pLimJoinReq->bssDescription.ieFields,
1972 lim_get_ielen_from_bss_description(
1973 &session->pLimJoinReq->bssDescription),
1974 &session->limCurrentBssQosCaps,
1975 &session->limCurrentBssPropCap,
1976 &session->gLimCurrentBssUapsd,
1977 &local_power_constraint, session);
1978
Krunal Soni53993f72016-07-08 18:20:03 -07001979 /*
1980 * Once the AP capabilities are available then set the
1981 * beam forming capabilities accordingly.
1982 */
1983 if (session->nss == 1) {
1984 session->vht_config.su_beam_former = 0;
1985 session->vht_config.tx_stbc = 0;
1986 session->vht_config.num_soundingdim = 0;
1987 session->ht_caps.txSTBC = 0;
1988 }
1989
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001990#ifdef FEATURE_WLAN_ESE
1991 session->maxTxPower = lim_get_max_tx_power(reg_max,
1992 local_power_constraint,
1993 mac_ctx->roam.configParam.nTxPowerCap);
1994#else
1995 session->maxTxPower =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301996 QDF_MIN(reg_max, (local_power_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001997#endif
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301998 lim_log(mac_ctx, LOG1,
1999 FL("Reg max = %d, local power con = %d, max tx = %d"),
2000 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002001
2002 if (session->gLimCurrentBssUapsd) {
2003 session->gUapsdPerAcBitmask =
2004 session->pLimJoinReq->uapsdPerAcBitmask;
2005 lim_log(mac_ctx, LOG1,
2006 FL("UAPSD flag for all AC - 0x%2x"),
2007 session->gUapsdPerAcBitmask);
2008
2009 /* resetting the dynamic uapsd mask */
2010 session->gUapsdPerAcDeliveryEnableMask = 0;
2011 session->gUapsdPerAcTriggerEnableMask = 0;
2012 }
2013
2014 session->limRFBand =
2015 lim_get_rf_band(session->currentOperChannel);
2016
2017 /* Initialize 11h Enable Flag */
2018 if (SIR_BAND_5_GHZ == session->limRFBand) {
2019 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
2020 &val) != eSIR_SUCCESS) {
2021 lim_log(mac_ctx, LOGP,
2022 FL("Fail to get WNI_CFG_11H_ENABLED "));
2023 session->lim11hEnable =
2024 WNI_CFG_11H_ENABLED_STADEF;
2025 } else {
2026 session->lim11hEnable = val;
2027 }
2028 } else {
2029 session->lim11hEnable = 0;
2030 }
2031
2032 /*
2033 * To care of the scenario when STA transitions from
2034 * IBSS to Infrastructure mode.
2035 */
2036 mac_ctx->lim.gLimIbssCoalescingHappened = false;
2037
2038 session->limPrevSmeState = session->limSmeState;
2039 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
2040 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2041 session->peSessionId,
2042 session->limSmeState));
2043
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002044 /* Indicate whether spectrum management is enabled */
2045 session->spectrumMgtEnabled =
2046 sme_join_req->spectrumMgtIndicator;
2047
2048 /* Enable the spectrum management if this is a DFS channel */
2049 if (session->country_info_present &&
2050 lim_isconnected_on_dfs_channel(
2051 session->currentOperChannel))
2052 session->spectrumMgtEnabled = true;
2053
2054 session->isOSENConnection = sme_join_req->isOSENConnection;
2055
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002056 /* Issue LIM_MLM_JOIN_REQ to MLM */
2057 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
2058 (uint32_t *) mlm_join_req);
2059 return;
2060
2061 } else {
2062 /* Received eWNI_SME_JOIN_REQ un expected state */
2063 lim_log(mac_ctx, LOGE,
2064 FL("received unexpected SME_JOIN_REQ in state %X"),
2065 mac_ctx->lim.gLimSmeState);
2066 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
2067 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2068 session = NULL;
2069 goto end;
2070 }
2071
2072end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05302073 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2074 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002075
2076 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302077 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002078 sme_join_req = NULL;
2079 if (NULL != session)
2080 session->pLimJoinReq = NULL;
2081 }
2082 if (ret_code != eSIR_SME_SUCCESS) {
2083 if (NULL != session) {
2084 pe_delete_session(mac_ctx, session);
2085 session = NULL;
2086 }
2087 }
2088 lim_log(mac_ctx, LOG1,
2089 FL("Send failure status on sessionid: %d with ret_code = %d"),
2090 sme_session_id, ret_code);
2091 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
2092 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
2093 sme_transaction_id);
2094}
2095
Amar Singhala297bfa2015-10-15 15:07:29 -07002096uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002097 uint8_t iniTxPower)
2098{
2099 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302100 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
2101 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002102 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2103 maxTxPower = txPower;
2104 else if (txPower < MIN_TX_PWR_CAP)
2105 maxTxPower = MIN_TX_PWR_CAP;
2106 else
2107 maxTxPower = MAX_TX_PWR_CAP;
2108
2109 return maxTxPower;
2110}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002111
2112/**
2113 * __lim_process_sme_reassoc_req() - process reassoc req
2114 *
2115 * @mac_ctx: Pointer to Global MAC structure
2116 * @msg_buf: pointer to the SME message buffer
2117 *
2118 * This function is called to process SME_REASSOC_REQ message
2119 * from HDD or upper layer application.
2120 *
2121 * Return: None
2122 */
2123
2124static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2125 uint32_t *msg_buf)
2126{
2127 uint16_t caps;
2128 uint32_t val;
2129 tpSirSmeJoinReq reassoc_req = NULL;
2130 tLimMlmReassocReq *mlm_reassoc_req;
2131 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2132 tpPESession session_entry = NULL;
2133 uint8_t session_id;
2134 uint8_t sme_session_id;
2135 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002136 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002137 uint32_t tele_bcn_en = 0;
2138 uint16_t size;
2139
2140 lim_log(mac_ctx, LOG3, FL("Received REASSOC_REQ"));
2141
2142 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302143 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002144 if (NULL == reassoc_req) {
2145 lim_log(mac_ctx, LOGP,
2146 FL("call to AllocateMemory failed for reassoc_req"));
2147
2148 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2149 goto end;
2150 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302151 (void)qdf_mem_set((void *)reassoc_req, size, 0);
2152 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002153
2154 if (!lim_is_sme_join_req_valid(mac_ctx,
2155 (tpSirSmeJoinReq)reassoc_req)) {
2156 /*
2157 * Received invalid eWNI_SME_REASSOC_REQ
2158 */
2159 lim_log(mac_ctx, LOGW,
2160 FL("received SME_REASSOC_REQ with invalid data"));
2161
2162 ret_code = eSIR_SME_INVALID_PARAMETERS;
2163 goto end;
2164 }
2165
2166 session_entry = pe_find_session_by_bssid(mac_ctx,
2167 reassoc_req->bssDescription.bssId,
2168 &session_id);
2169 if (session_entry == NULL) {
2170 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2171 LOGE);
2172 lim_log(mac_ctx, LOGE,
2173 FL("Session does not exist for given bssId"));
2174 ret_code = eSIR_SME_INVALID_PARAMETERS;
2175 goto end;
2176 }
2177#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2178 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2179 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2180#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2181 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2182
2183 /* Store the reassoc handle in the session Table */
2184 session_entry->pLimReAssocReq = reassoc_req;
2185
2186 session_entry->dot11mode = reassoc_req->dot11mode;
2187 session_entry->vhtCapability =
2188 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002189
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302190 if (session_entry->vhtCapability) {
2191 if (session_entry->pePersona == QDF_STA_MODE) {
2192 session_entry->vht_config.su_beam_formee =
2193 reassoc_req->vht_config.su_beam_formee;
2194 } else {
2195 reassoc_req->vht_config.su_beam_formee = 0;
2196 }
2197 session_entry->enableVhtpAid =
2198 reassoc_req->enableVhtpAid;
2199 session_entry->enableVhtGid =
2200 reassoc_req->enableVhtGid;
2201 lim_log(mac_ctx, LOG1, FL("vht su bformer [%d]"),
2202 session_entry->vht_config.su_beam_former);
2203 }
2204
2205 lim_log(mac_ctx, LOG1,
2206 FL("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d"),
2207 session_entry->vhtCapability,
2208 session_entry->vht_config.su_beam_formee,
2209 session_entry->vht_config.su_beam_former);
2210
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002211 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2212 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002213 session_entry->send_smps_action =
2214 reassoc_req->send_smps_action;
2215 lim_log(mac_ctx, LOG1,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002216 FL("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002217 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002218 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002219 session_entry->send_smps_action,
2220 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002221 /*
2222 * Reassociate request is expected
2223 * in link established state only.
2224 */
2225
2226 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002227 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2228 /*
2229 * May be from 11r FT pre-auth. So lets check it
2230 * before we bail out
2231 */
2232 lim_log(mac_ctx, LOG1, FL(
2233 "Session in reassoc state is %d"),
2234 session_entry->peSessionId);
2235
2236 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302237 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002238 session_entry->limReAssocbssId,
2239 6)) {
2240 lim_print_mac_addr(mac_ctx,
2241 reassoc_req->bssDescription.
2242 bssId, LOGE);
2243 lim_log(mac_ctx, LOGP,
2244 FL("Unknown bssId in reassoc state"));
2245 ret_code = eSIR_SME_INVALID_PARAMETERS;
2246 goto end;
2247 }
2248
2249 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2250 session_entry);
2251 return;
2252 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002253 /*
2254 * Should not have received eWNI_SME_REASSOC_REQ
2255 */
2256 lim_log(mac_ctx, LOGE,
2257 FL("received unexpected SME_REASSOC_REQ in state %X"),
2258 session_entry->limSmeState);
2259 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2260
2261 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2262 goto end;
2263 }
2264
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302265 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002266 session_entry->pLimReAssocReq->bssDescription.bssId,
2267 sizeof(tSirMacAddr));
2268
2269 session_entry->limReassocChannelId =
2270 session_entry->pLimReAssocReq->bssDescription.channelId;
2271
2272 session_entry->reAssocHtSupportedChannelWidthSet =
2273 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2274 session_entry->reAssocHtRecommendedTxWidthSet =
2275 session_entry->reAssocHtSupportedChannelWidthSet;
2276 session_entry->reAssocHtSecondaryChannelOffset =
2277 session_entry->pLimReAssocReq->cbMode;
2278
2279 session_entry->limReassocBssCaps =
2280 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2281 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2282 session_entry->currentOperChannel);
2283 local_pwr_constraint = reg_max;
2284
2285 lim_extract_ap_capability(mac_ctx,
2286 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2287 lim_get_ielen_from_bss_description(
2288 &session_entry->pLimReAssocReq->bssDescription),
2289 &session_entry->limReassocBssQosCaps,
2290 &session_entry->limReassocBssPropCap,
2291 &session_entry->gLimCurrentBssUapsd,
2292 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302293 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002294 lim_log(mac_ctx, LOGE,
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302295 FL("Reg max = %d, local pwr constraint = %d, max tx = %d"),
2296 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002297 /* Copy the SSID from session entry to local variable */
2298 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302299 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002300 reassoc_req->ssId.ssId,
2301 session_entry->limReassocSSID.length);
2302 if (session_entry->gLimCurrentBssUapsd) {
2303 session_entry->gUapsdPerAcBitmask =
2304 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
2305 lim_log(mac_ctx, LOG1,
2306 FL("UAPSD flag for all AC - 0x%2x"),
2307 session_entry->gUapsdPerAcBitmask);
2308 }
2309
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302310 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002311 if (NULL == mlm_reassoc_req) {
2312 lim_log(mac_ctx, LOGP,
2313 FL("call to AllocateMemory failed for mlmReassocReq"));
2314
2315 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2316 goto end;
2317 }
2318
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302319 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002320 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2321
2322 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2323 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
2324 eSIR_SUCCESS) {
2325 /*
2326 * Could not get ReassocFailureTimeout value
2327 * from CFG. Log error.
2328 */
2329 lim_log(mac_ctx, LOGP,
2330 FL("could not retrieve ReassocFailureTimeout value"));
2331 }
2332
2333 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
2334 eSIR_SUCCESS) {
2335 /*
2336 * Could not get Capabilities value
2337 * from CFG. Log error.
2338 */
2339 lim_log(mac_ctx, LOGP, FL(
2340 "could not retrieve Capabilities value"));
2341 }
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302342
2343 lim_update_caps_info_for_bss(mac_ctx, &caps,
2344 reassoc_req->bssDescription.capabilityInfo);
2345 lim_log(mac_ctx, LOG1, FL("Capabilities info Reassoc: 0x%X"), caps);
2346
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002347 mlm_reassoc_req->capabilityInfo = caps;
2348
2349 /* Update PE session_id */
2350 mlm_reassoc_req->sessionId = session_id;
2351
2352 /*
2353 * If telescopic beaconing is enabled, set listen interval to
2354 * WNI_CFG_TELE_BCN_MAX_LI
2355 */
2356 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2357 &tele_bcn_en) != eSIR_SUCCESS)
2358 lim_log(mac_ctx, LOGP,
2359 FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
2360
2361 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2362
2363 if (tele_bcn_en) {
2364 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2365 eSIR_SUCCESS)
2366 /*
2367 * Could not get ListenInterval value
2368 * from CFG. Log error.
2369 */
2370 lim_log(mac_ctx, LOGP,
2371 FL("could not retrieve ListenInterval"));
2372 } else {
2373 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
2374 eSIR_SUCCESS)
2375 /*
2376 * Could not get ListenInterval value
2377 * from CFG. Log error.
2378 */
2379 lim_log(mac_ctx, LOGP,
2380 FL("could not retrieve ListenInterval"));
2381 }
2382
2383 mlm_reassoc_req->listenInterval = (uint16_t) val;
2384
2385 /* Indicate whether spectrum management is enabled */
2386 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2387
2388 /* Enable the spectrum management if this is a DFS channel */
2389 if (session_entry->country_info_present &&
2390 lim_isconnected_on_dfs_channel(
2391 session_entry->currentOperChannel))
2392 session_entry->spectrumMgtEnabled = true;
2393
2394 session_entry->limPrevSmeState = session_entry->limSmeState;
2395 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2396
2397 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2398 session_entry->peSessionId,
2399 session_entry->limSmeState));
2400
2401 lim_post_mlm_message(mac_ctx,
2402 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2403 return;
2404end:
2405 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302406 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002407 if (session_entry)
2408 session_entry->pLimReAssocReq = NULL;
2409 }
2410
2411 if (session_entry) {
2412 /*
2413 * error occurred after we determined the session so extract
2414 * session and transaction info from there
2415 */
2416 sme_session_id = session_entry->smeSessionId;
2417 transaction_id = session_entry->transactionId;
2418 } else
2419 /*
2420 * error occurred before or during the time we determined
2421 * the session so extract the session and transaction info
2422 * from the message
2423 */
2424 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2425 &sme_session_id, &transaction_id);
2426
2427 /*
2428 * Send Reassoc failure response to host
2429 * (note session_entry may be NULL, but that's OK)
2430 */
2431 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2432 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2433 session_entry, sme_session_id,
2434 transaction_id);
2435}
2436
2437bool send_disassoc_frame = 1;
2438/**
2439 * __lim_process_sme_disassoc_req()
2440 *
2441 ***FUNCTION:
2442 * This function is called to process SME_DISASSOC_REQ message
2443 * from HDD or upper layer application.
2444 *
2445 ***LOGIC:
2446 *
2447 ***ASSUMPTIONS:
2448 *
2449 ***NOTE:
2450 *
2451 * @param pMac Pointer to Global MAC structure
2452 * @param *pMsgBuf A pointer to the SME message buffer
2453 * @return None
2454 */
2455
2456static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2457{
2458 uint16_t disassocTrigger, reasonCode;
2459 tLimMlmDisassocReq *pMlmDisassocReq;
2460 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2461 tSirSmeDisassocReq smeDisassocReq;
2462 tpPESession psessionEntry = NULL;
2463 uint8_t sessionId;
2464 uint8_t smesessionId;
2465 uint16_t smetransactionId;
2466
2467 if (pMsgBuf == NULL) {
2468 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
2469 return;
2470 }
2471
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302472 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002473 smesessionId = smeDisassocReq.sessionId;
2474 smetransactionId = smeDisassocReq.transactionId;
2475 if (!lim_is_sme_disassoc_req_valid(pMac,
2476 &smeDisassocReq,
2477 psessionEntry)) {
2478 PELOGE(lim_log(pMac, LOGE,
2479 FL("received invalid SME_DISASSOC_REQ message"));)
2480 if (pMac->lim.gLimRspReqd) {
2481 pMac->lim.gLimRspReqd = false;
2482
2483 retCode = eSIR_SME_INVALID_PARAMETERS;
2484 disassocTrigger = eLIM_HOST_DISASSOC;
2485 goto sendDisassoc;
2486 }
2487
2488 return;
2489 }
2490
2491 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002492 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002493 &sessionId);
2494 if (psessionEntry == NULL) {
2495 lim_log(pMac, LOGE,
2496 FL("session does not exist for given bssId "
2497 MAC_ADDRESS_STR),
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002498 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002499 retCode = eSIR_SME_INVALID_PARAMETERS;
2500 disassocTrigger = eLIM_HOST_DISASSOC;
2501 goto sendDisassoc;
2502 }
2503 lim_log(pMac, LOG1,
2504 FL("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2505 MAC_ADDRESS_STR), smesessionId,
2506 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2507 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002508 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002509
2510#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2511 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2512 0, smeDisassocReq.reasonCode);
2513#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2514
2515 /* Update SME session Id and SME transaction ID */
2516
2517 psessionEntry->smeSessionId = smesessionId;
2518 psessionEntry->transactionId = smetransactionId;
2519
2520 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2521 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002522 switch (psessionEntry->limSmeState) {
2523 case eLIM_SME_ASSOCIATED_STATE:
2524 case eLIM_SME_LINK_EST_STATE:
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002525 lim_log(pMac, LOG1,
2526 FL("Rcvd SME_DISASSOC_REQ in limSmeState: %d "),
2527 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002528 psessionEntry->limPrevSmeState =
2529 psessionEntry->limSmeState;
2530 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2531#ifdef FEATURE_WLAN_TDLS
2532 /* Delete all TDLS peers connected before leaving BSS */
2533 lim_delete_tdls_peers(pMac, psessionEntry);
2534#endif
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002535 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2536 psessionEntry->peSessionId,
2537 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002538 break;
2539
2540 case eLIM_SME_WT_DEAUTH_STATE:
2541 /* PE shall still process the DISASSOC_REQ and proceed with
2542 * link tear down even if it had already sent a DEAUTH_IND to
2543 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2544 * its been set when PE entered WT_DEAUTH_STATE.
2545 */
2546 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2547 MTRACE(mac_trace
2548 (pMac, TRACE_CODE_SME_STATE,
2549 psessionEntry->peSessionId,
2550 psessionEntry->limSmeState));
2551 lim_log(pMac, LOG1,
2552 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE. "));
2553 break;
2554
2555 case eLIM_SME_WT_DISASSOC_STATE:
2556 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2557 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2558 * PE can continue processing DISASSOC_REQ and send the response instead
2559 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2560 * for disassoc frame.
2561 *
2562 * It will send a disassoc, which is ok. However, we can use the global flag
2563 * sendDisassoc to not send disassoc frame.
2564 */
2565 lim_log(pMac, LOG1,
2566 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE. "));
2567 break;
2568
2569 case eLIM_SME_JOIN_FAILURE_STATE: {
2570 /* Already in Disconnected State, return success */
2571 lim_log(pMac, LOG1,
2572 FL("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE. "));
2573 if (pMac->lim.gLimRspReqd) {
2574 retCode = eSIR_SME_SUCCESS;
2575 disassocTrigger = eLIM_HOST_DISASSOC;
2576 goto sendDisassoc;
2577 }
2578 }
2579 break;
2580 default:
2581 /**
2582 * STA is not currently associated.
2583 * Log error and send response to host
2584 */
2585 lim_log(pMac, LOGE,
2586 FL("received unexpected SME_DISASSOC_REQ in state %X"),
2587 psessionEntry->limSmeState);
2588 lim_print_sme_state(pMac, LOGE,
2589 psessionEntry->limSmeState);
2590
2591 if (pMac->lim.gLimRspReqd) {
2592 if (psessionEntry->limSmeState !=
2593 eLIM_SME_WT_ASSOC_STATE)
2594 pMac->lim.gLimRspReqd = false;
2595
2596 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2597 disassocTrigger = eLIM_HOST_DISASSOC;
2598 goto sendDisassoc;
2599 }
2600
2601 return;
2602 }
2603
2604 break;
2605
2606 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002607 /* Fall through */
2608 break;
2609
2610 case eLIM_STA_IN_IBSS_ROLE:
2611 default:
2612 /* eLIM_UNKNOWN_ROLE */
2613 lim_log(pMac, LOGE,
2614 FL("received unexpected SME_DISASSOC_REQ for role %d"),
2615 GET_LIM_SYSTEM_ROLE(psessionEntry));
2616
2617 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2618 disassocTrigger = eLIM_HOST_DISASSOC;
2619 goto sendDisassoc;
2620 } /* end switch (pMac->lim.gLimSystemRole) */
2621
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302622 disassocTrigger = eLIM_HOST_DISASSOC;
2623 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002624
2625 if (smeDisassocReq.doNotSendOverTheAir) {
2626 lim_log(pMac, LOG1, FL("do not send dissoc over the air"));
2627 send_disassoc_frame = 0;
2628 }
2629 /* Trigger Disassociation frame to peer MAC entity */
2630 lim_log(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2631 " : %d, reasonCode : %d"),
2632 disassocTrigger, reasonCode);
2633
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302634 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002635 if (NULL == pMlmDisassocReq) {
2636 /* Log error */
2637 lim_log(pMac, LOGP,
2638 FL("call to AllocateMemory failed for mlmDisassocReq"));
2639
2640 return;
2641 }
2642
Anurag Chouhanc5548422016-02-24 18:33:27 +05302643 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002644 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002645
2646 pMlmDisassocReq->reasonCode = reasonCode;
2647 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2648
2649 /* Update PE session ID */
2650 pMlmDisassocReq->sessionId = sessionId;
2651
2652 lim_post_mlm_message(pMac,
2653 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2654 return;
2655
2656sendDisassoc:
2657 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002658 lim_send_sme_disassoc_ntf(pMac,
2659 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002660 retCode,
2661 disassocTrigger,
2662 1, smesessionId, smetransactionId,
2663 psessionEntry);
2664 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002665 lim_send_sme_disassoc_ntf(pMac,
2666 smeDisassocReq.peer_macaddr.bytes,
2667 retCode, disassocTrigger, 1,
2668 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002669
2670} /*** end __lim_process_sme_disassoc_req() ***/
2671
2672/** -----------------------------------------------------------------
2673 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2674
2675 This function is called to process SME_DISASSOC_CNF message
2676 from HDD or upper layer application.
2677
2678 \param pMac - global mac structure
2679 \param pStaDs - station dph hash node
2680 \return none
2681 \sa
2682 ----------------------------------------------------------------- */
2683static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2684{
2685 tSirSmeDisassocCnf smeDisassocCnf;
2686 uint16_t aid;
2687 tpDphHashNode pStaDs;
2688 tpPESession psessionEntry;
2689 uint8_t sessionId;
2690
2691 PELOG1(lim_log(pMac, LOG1, FL("received DISASSOC_CNF message"));)
2692
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302693 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002694 sizeof(struct sSirSmeDisassocCnf));
2695
2696 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002697 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002698 &sessionId);
2699 if (psessionEntry == NULL) {
2700 lim_log(pMac, LOGE,
2701 FL("session does not exist for given bssId"));
2702 return;
2703 }
2704
2705 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
2706 lim_log(pMac, LOGE,
2707 FL("received invalid SME_DISASSOC_CNF message"));
2708 return;
2709 }
2710#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2711 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2712 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2713 psessionEntry,
2714 (uint16_t) smeDisassocCnf.statusCode, 0);
2715 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2716 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2717 psessionEntry,
2718 (uint16_t) smeDisassocCnf.statusCode, 0);
2719#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2720
2721 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2722 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002723 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2724 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2725 && (psessionEntry->limSmeState !=
2726 eLIM_SME_WT_DEAUTH_STATE)) {
2727 lim_log(pMac, LOGE,
2728 FL
2729 ("received unexp SME_DISASSOC_CNF in state %X"),
2730 psessionEntry->limSmeState);
2731 lim_print_sme_state(pMac, LOGE,
2732 psessionEntry->limSmeState);
2733 return;
2734 }
2735 break;
2736
2737 case eLIM_AP_ROLE:
2738 /* Fall through */
2739 break;
2740
2741 case eLIM_STA_IN_IBSS_ROLE:
2742 default: /* eLIM_UNKNOWN_ROLE */
2743 lim_log(pMac, LOGE,
2744 FL("received unexpected SME_DISASSOC_CNF role %d"),
2745 GET_LIM_SYSTEM_ROLE(psessionEntry));
2746
2747 return;
2748 }
2749
2750 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2751 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2752 LIM_IS_AP_ROLE(psessionEntry)) {
2753 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002754 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002755 &psessionEntry->dph.dphHashTable);
2756 if (pStaDs == NULL) {
2757 lim_log(pMac, LOGE,
2758 FL("DISASSOC_CNF for a STA with no context, addr= "
2759 MAC_ADDRESS_STR),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002760 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002761 return;
2762 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302763
2764 if ((pStaDs->mlmStaContext.mlmState ==
2765 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2766 (pStaDs->mlmStaContext.mlmState ==
2767 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
2768 lim_log(pMac, LOGE,
2769 FL("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d"),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002770 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302771 pStaDs->mlmStaContext.mlmState);
2772 return;
2773 }
2774
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002775 /* Delete FT session if there exists one */
2776 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002777 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2778
2779 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002780 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002781 }
2782
2783 return;
2784}
2785
2786/**
2787 * __lim_process_sme_deauth_req() - process sme deauth req
2788 * @mac_ctx: Pointer to Global MAC structure
2789 * @msg_buf: pointer to the SME message buffer
2790 *
2791 * This function is called to process SME_DEAUTH_REQ message
2792 * from HDD or upper layer application.
2793 *
2794 * Return: None
2795 */
2796
2797static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2798 uint32_t *msg_buf)
2799{
2800 uint16_t deauth_trigger, reason_code;
2801 tLimMlmDeauthReq *mlm_deauth_req;
2802 tSirSmeDeauthReq sme_deauth_req;
2803 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2804 tpPESession session_entry;
2805 uint8_t session_id; /* PE sessionId */
2806 uint8_t sme_session_id;
2807 uint16_t sme_transaction_id;
2808
2809 lim_log(mac_ctx, LOG1, FL("received DEAUTH_REQ message"));
2810
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302811 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002812 sme_session_id = sme_deauth_req.sessionId;
2813 sme_transaction_id = sme_deauth_req.transactionId;
2814
2815 /*
2816 * We need to get a session first but we don't even know
2817 * if the message is correct.
2818 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002819 session_entry = pe_find_session_by_bssid(mac_ctx,
2820 sme_deauth_req.bssid.bytes,
2821 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002822 if (session_entry == NULL) {
2823 lim_log(mac_ctx, LOGE,
2824 FL("session does not exist for given bssId"));
2825 ret_code = eSIR_SME_INVALID_PARAMETERS;
2826 deauth_trigger = eLIM_HOST_DEAUTH;
2827 goto send_deauth;
2828 }
2829
2830 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2831 session_entry)) {
2832 lim_log(mac_ctx, LOGE,
2833 FL("received invalid SME_DEAUTH_REQ message"));
2834 mac_ctx->lim.gLimRspReqd = false;
2835
2836 ret_code = eSIR_SME_INVALID_PARAMETERS;
2837 deauth_trigger = eLIM_HOST_DEAUTH;
2838 goto send_deauth;
2839 }
2840 lim_log(mac_ctx, LOG1,
2841 FL("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2842 MAC_ADDRESS_STR), sme_session_id,
2843 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2844 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002845 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002846#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2847 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2848 session_entry, 0, sme_deauth_req.reasonCode);
2849#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2850
2851 /* Update SME session ID and Transaction ID */
2852 session_entry->smeSessionId = sme_session_id;
2853 session_entry->transactionId = sme_transaction_id;
2854
2855 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2856 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002857 switch (session_entry->limSmeState) {
2858 case eLIM_SME_ASSOCIATED_STATE:
2859 case eLIM_SME_LINK_EST_STATE:
2860 case eLIM_SME_WT_ASSOC_STATE:
2861 case eLIM_SME_JOIN_FAILURE_STATE:
2862 case eLIM_SME_IDLE_STATE:
2863 session_entry->limPrevSmeState =
2864 session_entry->limSmeState;
2865 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2866 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2867 session_entry->peSessionId,
2868 session_entry->limSmeState));
2869 /* Send Deauthentication request to MLM below */
2870 break;
2871 case eLIM_SME_WT_DEAUTH_STATE:
2872 case eLIM_SME_WT_DISASSOC_STATE:
2873 /*
2874 * PE Recieved a Deauth/Disassoc frame. Normally it get
2875 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2876 * Which means host is also trying to disconnect.
2877 * PE can continue processing DEAUTH_REQ and send
2878 * the response instead of failing the request.
2879 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2880 * was sent for deauth/disassoc frame.
2881 */
2882 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2883 lim_log(mac_ctx, LOG1, FL(
2884 "Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE"));
2885 break;
2886 default:
2887 /*
2888 * STA is not in a state to deauthenticate with
2889 * peer. Log error and send response to host.
2890 */
2891 lim_log(mac_ctx, LOGE, FL(
2892 "received unexp SME_DEAUTH_REQ in state %X"),
2893 session_entry->limSmeState);
2894 lim_print_sme_state(mac_ctx, LOGE,
2895 session_entry->limSmeState);
2896
2897 if (mac_ctx->lim.gLimRspReqd) {
2898 mac_ctx->lim.gLimRspReqd = false;
2899
2900 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2901 deauth_trigger = eLIM_HOST_DEAUTH;
2902
2903 /*
2904 * here we received deauth request from AP so sme state
2905 * is eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED
2906 * delSta then mlm state should be
2907 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got delBSS
2908 * rsp then mlm state should be eLIM_MLM_IDLE_STATE
2909 * so the below condition captures the state where
2910 * delSta not done and firmware still in
2911 * connected state.
2912 */
2913 if (session_entry->limSmeState ==
2914 eLIM_SME_WT_DEAUTH_STATE &&
2915 session_entry->limMlmState !=
2916 eLIM_MLM_IDLE_STATE &&
2917 session_entry->limMlmState !=
2918 eLIM_MLM_WT_DEL_STA_RSP_STATE)
2919 ret_code = eSIR_SME_DEAUTH_STATUS;
2920 goto send_deauth;
2921 }
2922 return;
2923 }
2924 break;
2925
2926 case eLIM_STA_IN_IBSS_ROLE:
2927 lim_log(mac_ctx, LOGE, FL("Deauth not allowed in IBSS"));
2928 if (mac_ctx->lim.gLimRspReqd) {
2929 mac_ctx->lim.gLimRspReqd = false;
2930 ret_code = eSIR_SME_INVALID_PARAMETERS;
2931 deauth_trigger = eLIM_HOST_DEAUTH;
2932 goto send_deauth;
2933 }
2934 return;
2935 case eLIM_AP_ROLE:
2936 break;
2937 default:
2938 lim_log(mac_ctx, LOGE,
2939 FL("received unexpected SME_DEAUTH_REQ for role %X"),
2940 GET_LIM_SYSTEM_ROLE(session_entry));
2941 if (mac_ctx->lim.gLimRspReqd) {
2942 mac_ctx->lim.gLimRspReqd = false;
2943 ret_code = eSIR_SME_INVALID_PARAMETERS;
2944 deauth_trigger = eLIM_HOST_DEAUTH;
2945 goto send_deauth;
2946 }
2947 return;
2948 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2949
2950 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2951 /* Deauthentication is triggered by Link Monitoring */
2952 lim_log(mac_ctx, LOG1, FL("** Lost link with AP **"));
2953 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2954 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2955 } else {
2956 deauth_trigger = eLIM_HOST_DEAUTH;
2957 reason_code = sme_deauth_req.reasonCode;
2958 }
2959
2960 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302961 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002962 if (NULL == mlm_deauth_req) {
2963 lim_log(mac_ctx, LOGP,
2964 FL("call to AllocateMemory failed for mlmDeauthReq"));
2965 if (mac_ctx->lim.gLimRspReqd) {
2966 mac_ctx->lim.gLimRspReqd = false;
2967 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2968 deauth_trigger = eLIM_HOST_DEAUTH;
2969 goto send_deauth;
2970 }
2971 return;
2972 }
2973
Anurag Chouhanc5548422016-02-24 18:33:27 +05302974 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002975 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002976
2977 mlm_deauth_req->reasonCode = reason_code;
2978 mlm_deauth_req->deauthTrigger = deauth_trigger;
2979
2980 /* Update PE session Id */
2981 mlm_deauth_req->sessionId = session_id;
2982
2983 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2984 (uint32_t *)mlm_deauth_req);
2985 return;
2986
2987send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002988 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2989 ret_code, deauth_trigger, 1,
2990 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002991}
2992
2993/**
2994 * __lim_process_sme_set_context_req()
2995 *
2996 * @mac_ctx: Pointer to Global MAC structure
2997 * @msg_buf: pointer to the SME message buffer
2998 *
2999 * This function is called to process SME_SETCONTEXT_REQ message
3000 * from HDD or upper layer application.
3001 *
3002 * Return: None
3003 */
3004
3005static void
3006__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
3007{
3008 tpSirSmeSetContextReq set_context_req;
3009 tLimMlmSetKeysReq *mlm_set_key_req;
3010 tpPESession session_entry;
3011 uint8_t session_id; /* PE sessionID */
3012 uint8_t sme_session_id;
3013 uint16_t sme_transaction_id;
3014
3015 lim_log(mac_ctx, LOG1, FL("received SETCONTEXT_REQ message"));
3016
3017 if (msg_buf == NULL) {
3018 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3019 return;
3020 }
3021
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303022 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003023 if (NULL == set_context_req) {
3024 lim_log(mac_ctx, LOGP, FL(
3025 "call to AllocateMemory failed for set_context_req"));
3026 return;
3027 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303028 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003029 sizeof(struct sSirSmeSetContextReq));
3030 sme_session_id = set_context_req->sessionId;
3031 sme_transaction_id = set_context_req->transactionId;
3032
3033 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
3034 lim_log(mac_ctx, LOGW,
3035 FL("received invalid SME_SETCONTEXT_REQ message"));
3036 goto end;
3037 }
3038
3039 if (set_context_req->keyMaterial.numKeys >
3040 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3041 lim_log(mac_ctx, LOGE, FL(
3042 "numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS"),
3043 set_context_req->keyMaterial.numKeys);
3044 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003045 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003046 eSIR_SME_INVALID_PARAMETERS, NULL,
3047 sme_session_id, sme_transaction_id);
3048 goto end;
3049 }
3050
3051 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003052 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003053 if (session_entry == NULL) {
3054 lim_log(mac_ctx, LOGW,
3055 FL("Session does not exist for given BSSID"));
3056 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003057 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003058 eSIR_SME_INVALID_PARAMETERS, NULL,
3059 sme_session_id, sme_transaction_id);
3060 goto end;
3061 }
3062#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3063 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
3064 session_entry, 0, 0);
3065#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3066
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003067 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003068 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3069 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003070 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003071 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
3072 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303073 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003074 if (NULL == mlm_set_key_req) {
3075 lim_log(mac_ctx, LOGP, FL(
3076 "mem alloc failed for mlmSetKeysReq"));
3077 goto end;
3078 }
3079 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
3080 mlm_set_key_req->numKeys =
3081 set_context_req->keyMaterial.numKeys;
3082 if (mlm_set_key_req->numKeys >
3083 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3084 lim_log(mac_ctx, LOGP, FL(
3085 "no.of keys exceeded max num of default keys limit"));
3086 goto end;
3087 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05303088 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003089 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003090
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303091 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003092 (uint8_t *) &set_context_req->keyMaterial.key,
3093 sizeof(tSirKeys) *
3094 (mlm_set_key_req->numKeys ? mlm_set_key_req->
3095 numKeys : 1));
3096
3097 mlm_set_key_req->sessionId = session_id;
3098 mlm_set_key_req->smesessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003099 lim_log(mac_ctx, LOG1, FL(
3100 "received SETCONTEXT_REQ message sessionId=%d"),
3101 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003102
3103 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
3104 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
3105 LIM_IS_AP_ROLE(session_entry)) {
3106 if (set_context_req->keyMaterial.key[0].keyLength) {
3107 uint8_t key_id;
3108 key_id =
3109 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303110 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003111 &session_entry->WEPKeyMaterial[key_id],
3112 (uint8_t *) &set_context_req->keyMaterial,
3113 sizeof(tSirKeyMaterial));
3114 } else {
3115 uint32_t i;
3116 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
3117 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303118 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003119 &mlm_set_key_req->key[i],
3120 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
3121 sizeof(tSirKeys));
3122 }
3123 }
3124 }
3125 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
3126 (uint32_t *) mlm_set_key_req);
3127 } else {
3128 lim_log(mac_ctx, LOGE, FL(
3129 "rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
3130 GET_LIM_SYSTEM_ROLE(session_entry),
3131 session_entry->limSmeState);
3132 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
3133
3134 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003135 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003136 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
3137 session_entry, sme_session_id,
3138 sme_transaction_id);
3139 }
3140end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303141 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003142 return;
3143}
3144
3145/**
3146 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
3147 *
3148 * @mac_ctx: Pointer to Global MAC structure
3149 * @msg_buf: pointer to the SME message buffer
3150 *
3151 * This function is called to process SME_GET_ASSOC_STAS_REQ message
3152 * from HDD or upper layer application.
3153 *
3154 * Return: None
3155 */
3156
3157void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
3158 uint32_t *msg_buf)
3159{
3160 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3161 tpDphHashNode sta_ds = NULL;
3162 tpPESession session_entry = NULL;
3163 tSap_Event sap_event;
3164 tpWLAN_SAPEventCB sap_event_cb = NULL;
3165 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3166 uint8_t session_id = CSR_SESSION_ID_INVALID;
3167 uint8_t assoc_id = 0;
3168 uint8_t sta_cnt = 0;
3169
3170 if (msg_buf == NULL) {
3171 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3172 return;
3173 }
3174
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303175 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003176 sizeof(struct sSirSmeGetAssocSTAsReq));
3177 /*
3178 * Get Associated stations from PE.
3179 * Find PE session Entry
3180 */
3181 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003182 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003183 &session_id);
3184 if (session_entry == NULL) {
3185 lim_log(mac_ctx, LOGE,
3186 FL("session does not exist for given bssId"));
3187 goto lim_assoc_sta_end;
3188 }
3189
3190 if (!LIM_IS_AP_ROLE(session_entry)) {
3191 lim_log(mac_ctx, LOGE, FL(
3192 "Received unexpected message in state %X, in role %X"),
3193 session_entry->limSmeState,
3194 GET_LIM_SYSTEM_ROLE(session_entry));
3195 goto lim_assoc_sta_end;
3196 }
3197 /* Retrieve values obtained in the request message */
3198 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3199 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3200
3201 if (NULL == assoc_sta_tmp)
3202 goto lim_assoc_sta_end;
3203 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3204 assoc_id++) {
3205 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3206 &session_entry->dph.dphHashTable);
3207 if (NULL == sta_ds)
3208 continue;
3209 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303210 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003211 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303212 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003213 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3214 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3215
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303216 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003217 (uint8_t *)&sta_ds->supportedRates,
3218 sizeof(tSirSupportedRates));
3219 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3220 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3221 assoc_sta_tmp->Support40Mhz =
3222 sta_ds->htDsssCckRate40MHzSupport;
3223
3224 lim_log(mac_ctx, LOG1, FL("dph Station Number = %d"),
3225 sta_cnt + 1);
3226 lim_log(mac_ctx, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3227 MAC_ADDR_ARRAY(sta_ds->staAddr));
3228 lim_log(mac_ctx, LOG1, FL("Association Id = %d"),
3229 sta_ds->assocId);
3230 lim_log(mac_ctx, LOG1, FL("Station Index = %d"),
3231 sta_ds->staIndex);
3232 assoc_sta_tmp++;
3233 sta_cnt++;
3234 }
3235 }
3236lim_assoc_sta_end:
3237 /*
3238 * Call hdd callback with sap event to send the list of
3239 * associated stations from PE
3240 */
3241 if (sap_event_cb != NULL) {
3242 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3243 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303244 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003245 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3246 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3247 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3248 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3249 }
3250}
3251
3252/**
3253 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3254 *
3255 * @mac_ctx: Pointer to Global MAC structure
3256 * @msg_buf: pointer to WPS PBC overlap query message
3257 *
3258 * This function parses get WPS PBC overlap information
3259 * message and call callback to pass WPS PBC overlap
3260 * information back to hdd.
3261 *
3262 * Return: None
3263 */
3264void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3265 uint32_t *msg_buf)
3266{
3267 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3268 tpPESession session_entry = NULL;
3269 tSap_Event sap_event;
3270 tpWLAN_SAPEventCB sap_event_cb = NULL;
3271 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003272 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3273
3274 if (msg_buf == NULL) {
3275 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3276 return;
3277 }
3278
3279 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303280 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003281
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303282 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003283 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3284 /*
3285 * Get Associated stations from PE
3286 * Find PE session Entry
3287 */
3288 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003289 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003290 if (session_entry == NULL) {
3291 lim_log(mac_ctx, LOGE,
3292 FL("session does not exist for given bssId"));
3293 goto lim_get_wpspbc_sessions_end;
3294 }
3295
3296 if (!LIM_IS_AP_ROLE(session_entry)) {
3297 lim_log(mac_ctx, LOGE,
3298 FL("Received unexpected message in role %X"),
3299 GET_LIM_SYSTEM_ROLE(session_entry));
3300 goto lim_get_wpspbc_sessions_end;
3301 }
3302 /*
3303 * Call hdd callback with sap event to send the
3304 * WPS PBC overlap information
3305 */
3306 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303307 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003308
Anurag Chouhanc5548422016-02-24 18:33:27 +05303309 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003310 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003311 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003312 sap_get_wpspbc_event->UUID_E,
3313 &sap_get_wpspbc_event->wpsPBCOverlap,
3314 session_entry);
3315 } else {
3316 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003317 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003318 session_entry);
3319 /* don't have to inform the HDD/Host */
3320 return;
3321 }
3322
3323 lim_log(mac_ctx, LOGE, FL("wpsPBCOverlap %d"),
3324 sap_get_wpspbc_event->wpsPBCOverlap);
3325 lim_print_mac_addr(mac_ctx,
3326 sap_get_wpspbc_event->addr.bytes, LOG4);
3327
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303328 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003329
3330lim_get_wpspbc_sessions_end:
3331 sap_event_cb =
3332 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3333 if (NULL != sap_event_cb)
3334 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3335}
3336
3337/**
3338 * __lim_counter_measures()
3339 *
3340 * FUNCTION:
3341 * This function is called to "implement" MIC counter measure
3342 * and is *temporary* only
3343 *
3344 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3345 * we don't do the proper STA disassoc sequence since the
3346 * BSS will be stoped anyway
3347 *
3348 ***ASSUMPTIONS:
3349 *
3350 ***NOTE:
3351 *
3352 * @param pMac Pointer to Global MAC structure
3353 * @return None
3354 */
3355
3356static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3357{
3358 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003359 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003360 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3361 mac, psessionEntry, false);
3362};
3363
3364void lim_process_tkip_counter_measures(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3365{
3366 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3367 tpPESession psessionEntry;
3368 uint8_t sessionId; /* PE sessionId */
3369
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303370 qdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003371 sizeof(struct sSirSmeTkipCntrMeasReq));
3372
3373 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003374 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003375 if (NULL == psessionEntry) {
3376 lim_log(pMac, LOGE,
3377 FL("session does not exist for given BSSID "));
3378 return;
3379 }
3380
3381 if (tkipCntrMeasReq.bEnable)
3382 __lim_counter_measures(pMac, psessionEntry);
3383
3384 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3385}
3386
3387static void
3388__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3389{
3390 tSirSmeStopBssReq stopBssReq;
3391 tSirRetStatus status;
3392 tLimSmeStates prevState;
3393 tpPESession psessionEntry;
3394 uint8_t smesessionId;
3395 uint8_t sessionId;
3396 uint16_t smetransactionId;
3397 uint8_t i = 0;
3398 tpDphHashNode pStaDs = NULL;
3399
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303400 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003401 smesessionId = stopBssReq.sessionId;
3402 smetransactionId = stopBssReq.transactionId;
3403
3404 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
3405 PELOGW(lim_log(pMac, LOGW,
3406 FL("received invalid SME_STOP_BSS_REQ message"));)
3407 /* Send Stop BSS response to host */
3408 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3409 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3410 smetransactionId);
3411 return;
3412 }
3413
3414 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003415 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003416 &sessionId);
3417 if (psessionEntry == NULL) {
3418 lim_log(pMac, LOGW,
3419 FL("session does not exist for given BSSID "));
3420 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3421 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3422 smetransactionId);
3423 return;
3424 }
3425#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3426 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3427 0, 0);
3428#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3429
3430 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3431 LIM_IS_STA_ROLE(psessionEntry)) {
3432 /**
3433 * Should not have received STOP_BSS_REQ in states
3434 * other than 'normal' state or on STA in Infrastructure
3435 * mode. Log error and return response to host.
3436 */
3437 lim_log(pMac, LOGE,
3438 FL
3439 ("received unexpected SME_STOP_BSS_REQ in state %X, for role %d"),
3440 psessionEntry->limSmeState,
3441 GET_LIM_SYSTEM_ROLE(psessionEntry));
3442 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3443 /* / Send Stop BSS response to host */
3444 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3445 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3446 smetransactionId);
3447 return;
3448 }
3449
3450 if (LIM_IS_AP_ROLE(psessionEntry))
3451 lim_wpspbc_close(pMac, psessionEntry);
3452
3453 lim_log(pMac, LOGW,
3454 FL("RECEIVED STOP_BSS_REQ with reason code=%d"),
3455 stopBssReq.reasonCode);
3456
3457 prevState = psessionEntry->limSmeState;
3458
3459 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3460 MTRACE(mac_trace
3461 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3462 psessionEntry->limSmeState));
3463
3464 /* Update SME session Id and Transaction Id */
3465 psessionEntry->smeSessionId = smesessionId;
3466 psessionEntry->transactionId = smetransactionId;
3467
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003468 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3469 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3470 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003471 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3472 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3473 /* Send disassoc all stations associated thru TKIP */
3474 __lim_counter_measures(pMac, psessionEntry);
3475 else
3476 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003477 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3478 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003479 }
3480
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003481 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3482 /* Free the buffer allocated in START_BSS_REQ */
3483 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3484 psessionEntry->addIeParams.probeRespDataLen = 0;
3485 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003486
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003487 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3488 psessionEntry->addIeParams.assocRespDataLen = 0;
3489 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003490
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003491 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3492 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3493 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003494
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003495 /*
3496 * lim_del_bss is also called as part of coalescing,
3497 * when we send DEL BSS followed by Add Bss msg.
3498 */
3499 pMac->lim.gLimIbssCoalescingHappened = false;
3500 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003501 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3502 pStaDs =
3503 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3504 if (NULL == pStaDs)
3505 continue;
3506 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3507 if (eSIR_SUCCESS == status) {
3508 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3509 pStaDs->assocId, psessionEntry);
3510 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3511 } else {
3512 lim_log(pMac, LOGE,
3513 FL("lim_del_sta failed with Status : %d"), status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303514 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003515 }
3516 }
3517 /* send a delBss to HAL and wait for a response */
3518 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3519
3520 if (status != eSIR_SUCCESS) {
3521 PELOGE(lim_log
3522 (pMac, LOGE, FL("delBss failed for bss %d"),
3523 psessionEntry->bssIdx);
3524 )
3525 psessionEntry->limSmeState = prevState;
3526
3527 MTRACE(mac_trace
3528 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3529 psessionEntry->limSmeState));
3530
3531 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3532 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3533 smetransactionId);
3534 }
3535}
3536
3537/**
3538 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3539 * @pMac: Global MAC context
3540 * @pMsg: Message from SME
3541 *
3542 * Wrapper for the function __lim_handle_sme_stop_bss_request
3543 * This message will be defered until softmac come out of
3544 * scan mode. Message should be handled even if we have
3545 * detected radar in the current operating channel.
3546 *
3547 * Return: true - If we consumed the buffer
3548 * false - If have defered the message.
3549 */
3550
3551static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3552{
3553 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3554 /**
3555 * If message defered, buffer is not consumed yet.
3556 * So return false
3557 */
3558 return false;
3559 }
3560 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3561 return true;
3562} /*** end __lim_process_sme_stop_bss_req() ***/
3563
3564void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3565 uint32_t body, tpPESession psessionEntry)
3566{
3567
3568 (void)body;
3569 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3570 lim_ibss_delete(pMac, psessionEntry);
3571 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3572 lim_delete_pre_auth_list(pMac);
3573 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3574 psessionEntry->smeSessionId,
3575 psessionEntry->transactionId);
3576 return;
3577}
3578
3579/**
3580 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3581 *
3582 * @mac_ctx: pointer to mac context
3583 * @msg_type: message type
3584 * @msg_buf: pointer to the SME message buffer
3585 *
3586 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3587 * in BTAMP AP.
3588 *
3589 * Return: None
3590 */
3591
3592void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3593 uint32_t *msg_buf)
3594{
3595 tSirSmeAssocCnf assoc_cnf;
3596 tpDphHashNode sta_ds = NULL;
3597 tpPESession session_entry = NULL;
3598 uint8_t session_id;
3599 tpSirAssocReq assoc_req;
3600
3601 if (msg_buf == NULL) {
3602 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL "));
3603 goto end;
3604 }
3605
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303606 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003607 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
3608 lim_log(mac_ctx, LOGE,
3609 FL("Received invalid SME_RE(ASSOC)_CNF message "));
3610 goto end;
3611 }
3612
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003613 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003614 &session_id);
3615 if (session_entry == NULL) {
3616 lim_log(mac_ctx, LOGE,
3617 FL("session does not exist for given bssId"));
3618 goto end;
3619 }
3620
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003621 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003622 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3623 (session_entry->limSmeState !=
3624 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
3625 lim_log(mac_ctx, LOGE, FL(
3626 "Rcvd unexpected msg %X in state %X, in role %X"),
3627 msg_type, session_entry->limSmeState,
3628 GET_LIM_SYSTEM_ROLE(session_entry));
3629 goto end;
3630 }
3631 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3632 &session_entry->dph.dphHashTable);
3633 if (sta_ds == NULL) {
3634 lim_log(mac_ctx, LOGE, FL(
3635 "Rcvd invalid msg %X due to no STA ctx, aid %d, peer "),
3636 msg_type, assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003637 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003638
3639 /*
3640 * send a DISASSOC_IND message to WSM to make sure
3641 * the state in WSM and LIM is the same
3642 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003643 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003644 eSIR_SME_STA_NOT_ASSOCIATED,
3645 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3646 session_entry->smeSessionId,
3647 session_entry->transactionId,
3648 session_entry);
3649 goto end;
3650 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303651 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003652 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303653 QDF_MAC_ADDR_SIZE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003654 lim_log(mac_ctx, LOG1, FL(
3655 "peerMacAddr mismatched for aid %d, peer "),
3656 assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003657 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003658 goto end;
3659 }
3660
3661 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3662 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3663 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3664 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3665 (msg_type != eWNI_SME_ASSOC_CNF))) {
3666 lim_log(mac_ctx, LOG1, FL(
3667 "not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3668 "StaD mlmState : %d"),
3669 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003670 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003671 goto end;
3672 }
3673 /*
3674 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3675 * has been received
3676 */
3677 lim_log(mac_ctx, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
3678 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3679 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3680
3681 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3682 /*
3683 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3684 * when it had received Assoc Request frame. Now, PE just needs
3685 * to send association rsp frame to the requesting BTAMP-STA.
3686 */
3687 sta_ds->mlmStaContext.mlmState =
3688 eLIM_MLM_LINK_ESTABLISHED_STATE;
3689 lim_log(mac_ctx, LOG1,
3690 FL("sending Assoc Rsp frame to STA (assoc id=%d) "),
3691 sta_ds->assocId);
3692 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3693 sta_ds->assocId, sta_ds->staAddr,
3694 sta_ds->mlmStaContext.subType, sta_ds,
3695 session_entry);
3696 goto end;
3697 } else {
3698 /*
3699 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3700 * to be associated since the HAL sta entry is created for
3701 * denied STA we need to remove this HAL entry.
3702 * So to do that set updateContext to 1
3703 */
3704 if (!sta_ds->mlmStaContext.updateContext)
3705 sta_ds->mlmStaContext.updateContext = 1;
3706 lim_log(mac_ctx, LOG1,
3707 FL("Recv Assoc Cnf, status Code : %d(assoc id=%d) "),
3708 assoc_cnf.statusCode, sta_ds->assocId);
3709 lim_reject_association(mac_ctx, sta_ds->staAddr,
3710 sta_ds->mlmStaContext.subType,
3711 true, sta_ds->mlmStaContext.authType,
3712 sta_ds->assocId, true,
3713 eSIR_MAC_UNSPEC_FAILURE_STATUS,
3714 session_entry);
3715 }
3716end:
3717 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3718 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3719 assoc_req = (tpSirAssocReq)
3720 session_entry->parsedAssocReq[sta_ds->assocId];
3721 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303722 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003723 assoc_req->assocReqFrame = NULL;
3724 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303725 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003726 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3727 }
3728}
3729
3730static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3731{
3732 tpDphHashNode pStaDs;
3733 tSirMacAddr peerMac;
3734 tpSirAddtsReq pSirAddts;
3735 uint32_t timeout;
3736 tpPESession psessionEntry;
3737 uint8_t sessionId; /* PE sessionId */
3738 uint8_t smesessionId;
3739 uint16_t smetransactionId;
3740
3741 if (pMsgBuf == NULL) {
3742 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
3743 return;
3744 }
3745
3746 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3747 &smetransactionId);
3748
3749 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3750
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003751 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3752 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003753 if (psessionEntry == NULL) {
3754 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3755 return;
3756 }
3757#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3758 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3759 0);
3760#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3761
3762 /* if sta
3763 * - verify assoc state
3764 * - send addts request to ap
3765 * - wait for addts response from ap
3766 * if ap, just ignore with error log
3767 */
3768 PELOG1(lim_log(pMac, LOG1,
3769 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
3770 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3771 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
3772 )
3773
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003774 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003775 PELOGE(lim_log(pMac, LOGE, "AddTs received on AP - ignoring");)
3776 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3777 psessionEntry, pSirAddts->req.tspec,
3778 smesessionId, smetransactionId);
3779 return;
3780 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003781
3782 pStaDs =
3783 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3784 &psessionEntry->dph.dphHashTable);
3785
3786 if (pStaDs == NULL) {
3787 PELOGE(lim_log
3788 (pMac, LOGE, "Cannot find AP context for addts req");
3789 )
3790 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3791 psessionEntry, pSirAddts->req.tspec,
3792 smesessionId, smetransactionId);
3793 return;
3794 }
3795
3796 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3797 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
3798 lim_log(pMac, LOGE, "AddTs received in invalid MLM state");
3799 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3800 psessionEntry, pSirAddts->req.tspec,
3801 smesessionId, smetransactionId);
3802 return;
3803 }
3804
3805 pSirAddts->req.wsmTspecPresent = 0;
3806 pSirAddts->req.wmeTspecPresent = 0;
3807 pSirAddts->req.lleTspecPresent = 0;
3808
3809 if ((pStaDs->wsmEnabled) &&
3810 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3811 SIR_MAC_ACCESSPOLICY_EDCA))
3812 pSirAddts->req.wsmTspecPresent = 1;
3813 else if (pStaDs->wmeEnabled)
3814 pSirAddts->req.wmeTspecPresent = 1;
3815 else if (pStaDs->lleEnabled)
3816 pSirAddts->req.lleTspecPresent = 1;
3817 else {
3818 PELOGW(lim_log
3819 (pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));
3820 )
3821 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3822 psessionEntry, pSirAddts->req.tspec,
3823 smesessionId, smetransactionId);
3824 return;
3825 }
3826
3827 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3828 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
3829 lim_log(pMac, LOGE,
3830 "AddTs received in invalid LIMsme state (%d)",
3831 psessionEntry->limSmeState);
3832 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3833 psessionEntry, pSirAddts->req.tspec,
3834 smesessionId, smetransactionId);
3835 return;
3836 }
3837
3838 if (pMac->lim.gLimAddtsSent) {
3839 lim_log(pMac, LOGE,
3840 "Addts (token %d, tsid %d, up %d) is still pending",
3841 pMac->lim.gLimAddtsReq.req.dialogToken,
3842 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3843 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3844 userPrio);
3845 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3846 psessionEntry, pSirAddts->req.tspec,
3847 smesessionId, smetransactionId);
3848 return;
3849 }
3850
3851 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3852
3853 /* save the addts request */
3854 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303855 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003856 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3857
3858 /* ship out the message now */
3859 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3860 psessionEntry);
3861 PELOG1(lim_log(pMac, LOG1, "Sent ADDTS request");)
3862 /* start a timer to wait for the response */
3863 if (pSirAddts->timeout)
3864 timeout = pSirAddts->timeout;
3865 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3866 eSIR_SUCCESS) {
3867 lim_log(pMac, LOGP,
3868 FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
3869 WNI_CFG_ADDTS_RSP_TIMEOUT);
3870 return;
3871 }
3872
3873 timeout = SYS_MS_TO_TICKS(timeout);
3874 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3875 != TX_SUCCESS) {
3876 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3877 return;
3878 }
3879 pMac->lim.gLimAddtsRspTimerCount++;
3880 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3881 pMac->lim.gLimAddtsRspTimerCount) !=
3882 TX_SUCCESS) {
3883 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3884 return;
3885 }
3886 MTRACE(mac_trace
3887 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3888 eLIM_ADDTS_RSP_TIMER));
3889
3890 /* add the sessionId to the timer object */
3891 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3892 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3893 TX_SUCCESS) {
3894 lim_log(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
3895 return;
3896 }
3897 return;
3898}
3899
3900static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3901{
3902 tSirMacAddr peerMacAddr;
3903 uint8_t ac;
3904 tSirMacTSInfo *pTsinfo;
3905 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3906 tpDphHashNode pStaDs = NULL;
3907 tpPESession psessionEntry;
3908 uint8_t sessionId;
3909 uint32_t status = eSIR_SUCCESS;
3910 uint8_t smesessionId;
3911 uint16_t smetransactionId;
3912
3913 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3914 &smetransactionId);
3915
3916 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003917 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003918 &sessionId);
3919 if (psessionEntry == NULL) {
3920 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3921 status = eSIR_FAILURE;
3922 goto end;
3923 }
3924#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3925 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3926 0);
3927#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3928
3929 if (eSIR_SUCCESS !=
3930 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
3931 PELOGE(lim_log(pMac, LOGE, FL("lim_validate_delts_req failed"));)
3932 status = eSIR_FAILURE;
3933 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3934 smesessionId, smetransactionId);
3935 return;
3936 }
3937
3938 lim_log(pMac, LOG1,
3939 FL("Sent DELTS request to station with assocId = %d MacAddr = "
3940 MAC_ADDRESS_STR),
3941 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3942
3943 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3944 pDeltsReq->req.wmeTspecPresent,
3945 &pDeltsReq->req.tsinfo,
3946 &pDeltsReq->req.tspec, psessionEntry);
3947
3948 pTsinfo =
3949 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3950 tsinfo : &pDeltsReq->req.tsinfo;
3951
3952 /* We've successfully send DELTS frame to AP. Update the
3953 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3954 * is no longer trigger enabled or delivery enabled
3955 */
3956 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3957 pTsinfo, CLEAR_UAPSD_MASK);
3958
3959 /* We're deleting the TSPEC, so this particular AC is no longer
3960 * admitted. PE needs to downgrade the EDCA
3961 * parameters(for the AC for which TS is being deleted) to the
3962 * next best AC for which ACM is not enabled, and send the
3963 * updated values to HAL.
3964 */
3965 ac = upToAc(pTsinfo->traffic.userPrio);
3966
3967 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3968 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3969 ~(1 << ac);
3970 } else if (pTsinfo->traffic.direction ==
3971 SIR_MAC_DIRECTION_DNLINK) {
3972 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3973 ~(1 << ac);
3974 } else if (pTsinfo->traffic.direction ==
3975 SIR_MAC_DIRECTION_BIDIR) {
3976 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3977 ~(1 << ac);
3978 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3979 ~(1 << ac);
3980 }
3981
3982 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3983 psessionEntry);
3984
3985 pStaDs =
3986 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3987 &psessionEntry->dph.dphHashTable);
3988 if (pStaDs != NULL) {
3989 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3990 pStaDs->bssId);
3991 status = eSIR_SUCCESS;
3992 } else {
3993 lim_log(pMac, LOGE, FL("Self entry missing in Hash Table "));
3994 status = eSIR_FAILURE;
3995 }
3996#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003997 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003998#endif
3999
4000 /* send an sme response back */
4001end:
4002 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
4003 smesessionId, smetransactionId);
4004}
4005
4006void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
4007{
4008 /* fetch the sessionEntry based on the sessionId */
4009 tpPESession psessionEntry;
4010 psessionEntry = pe_find_session_by_session_id(pMac,
4011 pMac->lim.limTimers.gLimAddtsRspTimer.
4012 sessionId);
4013 if (psessionEntry == NULL) {
4014 lim_log(pMac, LOGP,
4015 FL("Session Does not exist for given sessionID"));
4016 return;
4017 }
4018
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07004019 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004020 lim_log(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)",
4021 GET_LIM_SYSTEM_ROLE(psessionEntry));
4022 pMac->lim.gLimAddtsSent = false;
4023 return;
4024 }
4025
4026 if (!pMac->lim.gLimAddtsSent) {
4027 lim_log(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");
4028 return;
4029 }
4030
4031 if (param != pMac->lim.gLimAddtsRspTimerCount) {
4032 lim_log(pMac, LOGE,
4033 FL("Invalid AddtsRsp Timer count %d (exp %d)"), param,
4034 pMac->lim.gLimAddtsRspTimerCount);
4035 return;
4036 }
4037 /* this a real response timeout */
4038 pMac->lim.gLimAddtsSent = false;
4039 pMac->lim.gLimAddtsRspTimerCount++;
4040
4041 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
4042 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
4043 psessionEntry->smeSessionId,
4044 psessionEntry->transactionId);
4045}
4046
4047/**
4048 * __lim_process_sme_get_statistics_request()
4049 *
4050 ***FUNCTION:
4051 *
4052 *
4053 ***NOTE:
4054 *
4055 * @param pMac Pointer to Global MAC structure
4056 * @param *pMsgBuf A pointer to the SME message buffer
4057 * @return None
4058 */
4059static void
4060__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4061{
4062 tpAniGetPEStatsReq pPEStatsReq;
4063 tSirMsgQ msgQ;
4064
4065 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4066
4067 msgQ.type = WMA_GET_STATISTICS_REQ;
4068
4069 msgQ.reserved = 0;
4070 msgQ.bodyptr = pMsgBuf;
4071 msgQ.bodyval = 0;
4072 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4073
4074 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304075 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004076 pMsgBuf = NULL;
4077 lim_log(pMac, LOGP, "Unable to forward request");
4078 return;
4079 }
4080
4081 return;
4082}
4083
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004084#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004085/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004086 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004087 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004088 * @pMac: Pointer to Global MAC structure
4089 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004090 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004091 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004092 */
4093static void
4094__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4095{
4096 tSirMsgQ msgQ;
4097
4098 msgQ.type = WMA_TSM_STATS_REQ;
4099 msgQ.reserved = 0;
4100 msgQ.bodyptr = pMsgBuf;
4101 msgQ.bodyval = 0;
4102 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4103
4104 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304105 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004106 pMsgBuf = NULL;
4107 lim_log(pMac, LOGP, "Unable to forward request");
4108 return;
4109 }
4110}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004111#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004112
4113static void
4114__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4115{
4116 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4117 tpPESession psessionEntry;
4118 uint8_t sessionId; /* PE sessionID */
4119
4120 PELOG1(lim_log(pMac, LOG1, FL("received UPDATE_APWPSIEs_REQ message")););
4121
4122 if (pMsgBuf == NULL) {
4123 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4124 return;
4125 }
4126
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304127 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004128 if (NULL == pUpdateAPWPSIEsReq) {
4129 lim_log(pMac, LOGP,
4130 FL
4131 ("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
4132 return;
4133 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304134 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004135 sizeof(struct sSirUpdateAPWPSIEsReq));
4136
4137 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08004138 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004139 &sessionId);
4140 if (psessionEntry == NULL) {
4141 lim_log(pMac, LOGW,
4142 FL("Session does not exist for given BSSID"));
4143 goto end;
4144 }
4145
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304146 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004147 sizeof(tSirAPWPSIEs));
4148
4149 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4150 lim_send_beacon_ind(pMac, psessionEntry);
4151
4152end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304153 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004154 return;
4155}
4156
4157void
4158lim_send_vdev_restart(tpAniSirGlobal pMac,
4159 tpPESession psessionEntry, uint8_t sessionId)
4160{
4161 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
4162 tSirMsgQ msgQ;
4163 tSirRetStatus retCode = eSIR_SUCCESS;
4164
4165 if (psessionEntry == NULL) {
4166 PELOGE(lim_log
4167 (pMac, LOGE, "%s:%d: Invalid parameters", __func__,
4168 __LINE__);
4169 )
4170 return;
4171 }
4172
4173 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304174 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004175 if (NULL == pHalHiddenSsidVdevRestart) {
4176 PELOGE(lim_log
4177 (pMac, LOGE, "%s:%d: Unable to allocate memory",
4178 __func__, __LINE__);
4179 )
4180 return;
4181 }
4182
4183 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4184 pHalHiddenSsidVdevRestart->sessionId = sessionId;
4185
4186 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4187 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4188 msgQ.bodyval = 0;
4189
4190 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4191 if (eSIR_SUCCESS != retCode) {
4192 PELOGE(lim_log
4193 (pMac, LOGE, "%s:%d: wma_post_ctrl_msg() failed", __func__,
4194 __LINE__);
4195 )
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304196 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004197 }
4198}
4199
4200static void __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4201{
4202 tpSirUpdateParams pUpdateParams;
4203 tpPESession psessionEntry;
4204
4205 PELOG1(lim_log(pMac, LOG1, FL("received HIDE_SSID message")););
4206
4207 if (pMsgBuf == NULL) {
4208 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4209 return;
4210 }
4211
4212 pUpdateParams = (tpSirUpdateParams) pMsgBuf;
4213
Naveen Rawat9e4872a2015-11-13 09:43:11 -08004214 psessionEntry = pe_find_session_by_sme_session_id(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004215 pUpdateParams->sessionId);
4216 if (psessionEntry == NULL) {
4217 lim_log(pMac, LOGW,
4218 "Session does not exist for given sessionId %d",
4219 pUpdateParams->sessionId);
4220 return;
4221 }
4222
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05304223 if (psessionEntry->ssidHidden != pUpdateParams->ssidHidden) {
4224 /* Update the session entry */
4225 psessionEntry->ssidHidden = pUpdateParams->ssidHidden;
4226 } else {
4227 lim_log(pMac, LOG1, FL("Same config already present!"));
4228 return;
4229 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004230
4231 /* Send vdev restart */
4232 lim_send_vdev_restart(pMac, psessionEntry, pUpdateParams->sessionId);
4233
4234 /* Update beacon */
4235 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4236 lim_send_beacon_ind(pMac, psessionEntry);
4237
4238 return;
4239} /*** end __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4240
4241static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4242{
4243 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4244 tpPESession psessionEntry;
4245 uint8_t sessionId; /* PE sessionID */
4246
4247 if (pMsgBuf == NULL) {
4248 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4249 return;
4250 }
4251
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304252 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004253 if (NULL == pUpdateAPWPARSNIEsReq) {
4254 lim_log(pMac, LOGP,
4255 FL
4256 ("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
4257 return;
4258 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304259 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004260 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4261
4262 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004263 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004264 &sessionId);
4265 if (psessionEntry == NULL) {
4266 lim_log(pMac, LOGW,
4267 FL("Session does not exist for given BSSID"));
4268 goto end;
4269 }
4270
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304271 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004272 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4273
4274 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4275 &psessionEntry->
4276 pLimStartBssReq->rsnIE,
4277 psessionEntry);
4278
4279 psessionEntry->pLimStartBssReq->privacy = 1;
4280 psessionEntry->privacy = 1;
4281
4282 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4283 lim_send_beacon_ind(pMac, psessionEntry);
4284
4285end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304286 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004287 return;
4288} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4289
4290/*
4291 Update the beacon Interval dynamically if beaconInterval is different in MCC
4292 */
4293static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4294{
4295 tpSirChangeBIParams pChangeBIParams;
4296 tpPESession psessionEntry;
4297 uint8_t sessionId = 0;
4298 tUpdateBeaconParams beaconParams;
4299
4300 PELOG1(lim_log(pMac, LOG1,
4301 FL("received Update Beacon Interval message"));
4302 );
4303
4304 if (pMsgBuf == NULL) {
4305 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4306 return;
4307 }
4308
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304309 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004310 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4311
4312 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004313 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004314 &sessionId);
4315 if (psessionEntry == NULL) {
4316 lim_log(pMac, LOGE,
4317 FL("Session does not exist for given BSSID"));
4318 return;
4319 }
4320
4321 /*Update sessionEntry Beacon Interval */
4322 if (psessionEntry->beaconParams.beaconInterval !=
4323 pChangeBIParams->beaconInterval) {
4324 psessionEntry->beaconParams.beaconInterval =
4325 pChangeBIParams->beaconInterval;
4326 }
4327
4328 /*Update sch beaconInterval */
4329 if (pMac->sch.schObject.gSchBeaconInterval !=
4330 pChangeBIParams->beaconInterval) {
4331 pMac->sch.schObject.gSchBeaconInterval =
4332 pChangeBIParams->beaconInterval;
4333
4334 PELOG1(lim_log(pMac, LOG1,
4335 FL
4336 ("LIM send update BeaconInterval Indication : %d"),
4337 pChangeBIParams->beaconInterval);
4338 );
4339
4340 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4341 /* Update beacon */
4342 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4343
4344 beaconParams.bssIdx = psessionEntry->bssIdx;
4345 /* Set change in beacon Interval */
4346 beaconParams.beaconInterval =
4347 pChangeBIParams->beaconInterval;
4348 beaconParams.paramChangeBitmap =
4349 PARAM_BCN_INTERVAL_CHANGED;
4350 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4351 }
4352 }
4353
4354 return;
4355} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4356
4357#ifdef QCA_HT_2040_COEX
4358static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4359 uint32_t *pMsgBuf)
4360{
4361 tpSirSetHT2040Mode pSetHT2040Mode;
4362 tpPESession psessionEntry;
4363 uint8_t sessionId = 0;
4364 cds_msg_t msg;
4365 tUpdateVHTOpMode *pHtOpMode = NULL;
4366 uint16_t staId = 0;
4367 tpDphHashNode pStaDs = NULL;
4368
4369 PELOG1(lim_log(pMac, LOG1, FL("received Set HT 20/40 mode message")););
4370 if (pMsgBuf == NULL) {
4371 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4372 return;
4373 }
4374
4375 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4376
4377 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004378 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004379 &sessionId);
4380 if (psessionEntry == NULL) {
4381 lim_log(pMac, LOG1,
4382 FL("Session does not exist for given BSSID "));
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004383 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004384 return;
4385 }
4386
4387 lim_log(pMac, LOG1, FL("Update session entry for cbMod=%d"),
4388 pSetHT2040Mode->cbMode);
4389 /*Update sessionEntry HT related fields */
4390 switch (pSetHT2040Mode->cbMode) {
4391 case PHY_SINGLE_CHANNEL_CENTERED:
4392 psessionEntry->htSecondaryChannelOffset =
4393 PHY_SINGLE_CHANNEL_CENTERED;
4394 psessionEntry->htRecommendedTxWidthSet = 0;
4395 if (pSetHT2040Mode->obssEnabled)
4396 psessionEntry->htSupportedChannelWidthSet
4397 = eHT_CHANNEL_WIDTH_40MHZ;
4398 else
4399 psessionEntry->htSupportedChannelWidthSet
4400 = eHT_CHANNEL_WIDTH_20MHZ;
4401 break;
4402 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4403 psessionEntry->htSecondaryChannelOffset =
4404 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4405 psessionEntry->htRecommendedTxWidthSet = 1;
4406 break;
4407 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4408 psessionEntry->htSecondaryChannelOffset =
4409 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4410 psessionEntry->htRecommendedTxWidthSet = 1;
4411 break;
4412 default:
4413 lim_log(pMac, LOGE, FL("Invalid cbMode"));
4414 return;
4415 }
4416
4417 /* Update beacon */
4418 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4419 lim_send_beacon_ind(pMac, psessionEntry);
4420
4421 /* update OP Mode for each associated peer */
4422 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4423 pStaDs = dph_get_hash_entry(pMac, staId,
4424 &psessionEntry->dph.dphHashTable);
4425 if (NULL == pStaDs)
4426 continue;
4427
4428 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304429 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004430 if (NULL == pHtOpMode) {
4431 lim_log(pMac, LOGE,
4432 FL
4433 ("%s: Not able to allocate memory for setting OP mode"),
4434 __func__);
4435 return;
4436 }
4437 pHtOpMode->opMode =
4438 (psessionEntry->htSecondaryChannelOffset ==
4439 PHY_SINGLE_CHANNEL_CENTERED) ?
4440 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4441 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304442 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004443 sizeof(tSirMacAddr));
4444 pHtOpMode->smesessionId = sessionId;
4445
4446 msg.type = WMA_UPDATE_OP_MODE;
4447 msg.reserved = 0;
4448 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304449 if (!QDF_IS_STATUS_SUCCESS
Anurag Chouhan6d760662016-02-20 16:05:43 +05304450 (cds_mq_post_message(QDF_MODULE_ID_WMA, &msg))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004451 lim_log(pMac, LOGE,
4452 FL
4453 ("%s: Not able to post WMA_UPDATE_OP_MODE message to WMA"),
4454 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304455 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004456 return;
4457 }
4458 lim_log(pMac, LOG1,
4459 FL
4460 ("%s: Notifed FW about OP mode: %d for staId=%d"),
4461 __func__, pHtOpMode->opMode, staId);
4462
4463 } else
4464 lim_log(pMac, LOG1,
4465 FL("%s: station %d does not support HT40\n"),
4466 __func__, staId);
4467 }
4468
4469 return;
4470}
4471#endif
4472
4473/* -------------------------------------------------------------------- */
4474/**
4475 * __lim_process_report_message
4476 *
4477 * FUNCTION: Processes the next received Radio Resource Management message
4478 *
4479 * LOGIC:
4480 *
4481 * ASSUMPTIONS:
4482 *
4483 * NOTE:
4484 *
4485 * @param None
4486 * @return None
4487 */
4488
4489void __lim_process_report_message(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4490{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004491 switch (pMsg->type) {
4492 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4493 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4494 break;
4495 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004496 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004497 break;
4498 default:
4499 lim_log(pMac, LOGE, FL("Invalid msg type:%d"), pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004500 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004501}
4502
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004503/* -------------------------------------------------------------------- */
4504/**
4505 * lim_send_set_max_tx_power_req
4506 *
4507 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4508 *
4509 * LOGIC:
4510 *
4511 * ASSUMPTIONS:
4512 *
4513 * NOTE:
4514 *
4515 * @param txPower txPower to be set.
4516 * @param pSessionEntry session entry.
4517 * @return None
4518 */
4519tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004520lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004521 tpPESession pSessionEntry)
4522{
4523 tpMaxTxPowerParams pMaxTxParams = NULL;
4524 tSirRetStatus retCode = eSIR_SUCCESS;
4525 tSirMsgQ msgQ;
4526
4527 if (pSessionEntry == NULL) {
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304528 lim_log(pMac, LOGE, FL("Inavalid parameters"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004529 return eSIR_FAILURE;
4530 }
4531
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304532 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004533 if (NULL == pMaxTxParams) {
4534 lim_log(pMac, LOGP,
4535 FL("Unable to allocate memory for pMaxTxParams "));
4536 return eSIR_MEM_ALLOC_FAILED;
4537
4538 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004539 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304540 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304541 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304542 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004543 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304544 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004545
4546 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4547 msgQ.bodyptr = pMaxTxParams;
4548 msgQ.bodyval = 0;
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304549 lim_log(pMac, LOG1, FL("Post WMA_SET_MAX_TX_POWER_REQ to WMA"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004550 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4551 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4552 if (eSIR_SUCCESS != retCode) {
4553 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304554 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004555 }
4556 return retCode;
4557}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004558
4559/**
4560 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4561 *
4562 * @mac_ctx: Pointer to Global MAC structure
4563 * @msg_buf: pointer to the SME message buffer
4564 *
4565 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4566 * from SME. It Register this information within PE.
4567 *
4568 * Return: None
4569 */
4570static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4571 uint32_t *msg_buf)
4572{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304573 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004574 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4575 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4576 struct mgmt_frm_reg_info *next = NULL;
4577 bool match = false;
4578
4579 lim_log(mac_ctx, LOG1, FL(
4580 "registerFrame %d, frameType %d, matchLen %d"),
4581 sme_req->registerFrame, sme_req->frameType,
4582 sme_req->matchLen);
4583 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304584 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304585 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4586 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304587 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004588
4589 while (lim_mgmt_regn != NULL) {
4590 if (lim_mgmt_regn->frameType != sme_req->frameType)
4591 goto skip_match;
4592 if (sme_req->matchLen) {
4593 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304594 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004595 sme_req->matchData,
4596 lim_mgmt_regn->matchLen))) {
4597 /* found match! */
4598 match = true;
4599 break;
4600 }
4601 } else {
4602 /* found match! */
4603 match = true;
4604 break;
4605 }
4606skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304607 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304608 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004609 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304610 (qdf_list_node_t *)lim_mgmt_regn,
4611 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304612 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004613 lim_mgmt_regn = next;
4614 next = NULL;
4615 }
4616 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304617 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304618 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004619 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304620 (qdf_list_node_t *)lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304621 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304622 qdf_mem_free(lim_mgmt_regn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004623 }
4624
4625 if (sme_req->registerFrame) {
4626 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304627 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004628 sme_req->matchLen);
4629 if (lim_mgmt_regn != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304630 qdf_mem_set((void *)lim_mgmt_regn,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004631 sizeof(struct mgmt_frm_reg_info) +
4632 sme_req->matchLen, 0);
4633 lim_mgmt_regn->frameType = sme_req->frameType;
4634 lim_mgmt_regn->matchLen = sme_req->matchLen;
4635 lim_mgmt_regn->sessionId = sme_req->sessionId;
4636 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304637 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004638 sme_req->matchData,
4639 sme_req->matchLen);
4640 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304641 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004642 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304643 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004644 gLimMgmtFrameRegistratinQueue,
4645 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304646 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004647 &mac_ctx->lim.lim_frame_register_lock);
4648 }
4649 }
4650 return;
4651}
4652
4653static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4654{
4655 lim_log(pMac, LOG1, FL("Dereg msgType %d"),
4656 pMac->lim.gDeferMsgTypeForNOA);
4657 pMac->lim.gDeferMsgTypeForNOA = 0;
4658 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4659 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304660 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004661 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4662 }
4663}
4664
4665/**
4666 * lim_process_regd_defd_sme_req_after_noa_start()
4667 *
4668 * mac_ctx: Pointer to Global MAC structure
4669 *
4670 * This function is called to process deferred sme req message
4671 * after noa start.
4672 *
4673 * Return: None
4674 */
4675void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4676{
4677 bool buf_consumed = true;
4678
4679 lim_log(mac_ctx, LOG1, FL("Process defd sme req %d"),
4680 mac_ctx->lim.gDeferMsgTypeForNOA);
4681
4682 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4683 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
4684 lim_log(mac_ctx, LOGW,
4685 FL("start rcvd from FW when no sme deferred msg pending. Do nothing. "));
4686 lim_log(mac_ctx, LOGW,
4687 FL("It may happen when NOA start ind and timeout happen at the same time"));
4688 return;
4689 }
4690 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4691 case eWNI_SME_SCAN_REQ:
4692 __lim_process_sme_scan_req(mac_ctx,
4693 mac_ctx->lim.gpDefdSmeMsgForNOA);
4694 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004695 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4696 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4697 mac_ctx->lim.gpDefdSmeMsgForNOA);
4698 /*
4699 * lim_process_remain_on_chnl_req doesnt want us to free
4700 * the buffer since it is freed in lim_remain_on_chn_rsp.
4701 * this change is to avoid "double free"
4702 */
4703 if (false == buf_consumed)
4704 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4705 break;
4706 case eWNI_SME_JOIN_REQ:
4707 __lim_process_sme_join_req(mac_ctx,
4708 mac_ctx->lim.gpDefdSmeMsgForNOA);
4709 break;
4710 default:
4711 lim_log(mac_ctx, LOGE, FL("Unknown deferred msg type %d"),
4712 mac_ctx->lim.gDeferMsgTypeForNOA);
4713 break;
4714 }
4715 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4716}
4717
4718static void
4719__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4720{
4721 tpSirResetAPCapsChange pResetCapsChange;
4722 tpPESession psessionEntry;
4723 uint8_t sessionId = 0;
4724 if (pMsgBuf == NULL) {
4725 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4726 return;
4727 }
4728
4729 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4730 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004731 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4732 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004733 if (psessionEntry == NULL) {
4734 lim_log(pMac, LOGE,
4735 FL("Session does not exist for given BSSID"));
4736 return;
4737 }
4738
4739 psessionEntry->limSentCapsChangeNtf = false;
4740 return;
4741}
4742
4743/**
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304744 * lim_register_p2p_ack_ind_cb() - Save the p2p ack indication callback.
4745 * @mac_ctx: Mac pointer
4746 * @msg_buf: Msg pointer containing the callback
4747 *
4748 * This function is used to save the p2p ack indication callback in PE.
4749 *
4750 * Return: None
4751 */
4752static void lim_register_p2p_ack_ind_cb(tpAniSirGlobal mac_ctx,
4753 uint32_t *msg_buf)
4754{
4755 struct sir_sme_p2p_ack_ind_cb_req *sme_req =
4756 (struct sir_sme_p2p_ack_ind_cb_req *)msg_buf;
4757
4758 if (NULL == msg_buf) {
4759 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4760 return;
4761 }
4762 if (sme_req->callback)
4763 mac_ctx->p2p_ack_ind_cb =
4764 sme_req->callback;
4765 else
4766 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4767}
4768
4769/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304770 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4771 * indication callback in PE.
4772 * @mac_ptr: Mac pointer
4773 * @msg_buf: Msg pointer containing the callback
4774 *
4775 * This function is used save the Management frame
4776 * indication callback in PE.
4777 *
4778 * Return: None
4779 */
4780static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4781 uint32_t *msg_buf)
4782{
4783 struct sir_sme_mgmt_frame_cb_req *sme_req =
4784 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4785
4786 if (NULL == msg_buf) {
4787 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4788 return;
4789 }
4790 if (sme_req->callback)
4791 mac_ctx->mgmt_frame_ind_cb =
4792 (sir_mgmt_frame_ind_callback)sme_req->callback;
4793 else
4794 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4795}
4796
4797/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304798 *__lim_process_send_disassoc_frame: function processes disassoc frame
4799 * @mac_ctx: pointer to mac context
4800 * @msg_buf: message buffer
4801 *
4802 * function processes disassoc request received from SME
4803 *
4804 * return: none
4805 */
4806static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4807 uint32_t *msg_buf)
4808{
4809 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4810 tSirRetStatus status;
4811 tpPESession session_entry = NULL;
4812 uint8_t sme_session_id;
4813 uint16_t sme_trans_id;
4814
4815 if (msg_buf == NULL) {
4816 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
4817 return;
4818 }
4819
4820 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4821 &sme_trans_id);
4822
4823 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4824 &sme_send_disassoc_frame_req,
4825 (uint8_t *)msg_buf);
4826
4827 if ((eSIR_FAILURE == status) ||
4828 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4829 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
4830 PELOGE(lim_log(mac_ctx, LOGE,
4831 FL("received invalid SME_DISASSOC_REQ message"));)
4832 return;
4833 }
4834
4835 session_entry = pe_find_session_by_sme_session_id(
4836 mac_ctx, sme_session_id);
4837 if (session_entry == NULL) {
4838 lim_log(mac_ctx, LOGE,
4839 FL("session does not exist for given bssId "MAC_ADDRESS_STR),
4840 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4841 return;
4842 }
4843
4844 lim_log(mac_ctx, LOG1,
4845 FL("msg_type->%d len->%d sess_id->%d trans_id->%d mac->"MAC_ADDRESS_STR" reason->%d wait_for_ack->%d"),
4846 sme_send_disassoc_frame_req.msg_type,
4847 sme_send_disassoc_frame_req.length,
4848 sme_send_disassoc_frame_req.session_id,
4849 sme_send_disassoc_frame_req.trans_id,
4850 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4851 sme_send_disassoc_frame_req.reason,
4852 sme_send_disassoc_frame_req.wait_for_ack);
4853
4854 lim_send_disassoc_mgmt_frame(mac_ctx,
4855 sme_send_disassoc_frame_req.reason,
4856 sme_send_disassoc_frame_req.peer_mac,
4857 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4858}
4859
4860/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004861 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4862 * @mac_ctx: Pointer to Global MAC structure
4863 * @pdev_id: pdev id to set the IE.
4864 * @nss: Nss values to prepare the HT IE.
4865 *
4866 * Prepares the HT IE with self capabilities for different
4867 * Nss values and sends the set HT IE req to FW.
4868 *
4869 * Return: None
4870 */
4871static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4872 uint8_t nss)
4873{
4874 struct set_ie_param *ie_params;
4875 tSirMsgQ msg;
4876 tSirRetStatus rc = eSIR_SUCCESS;
4877 uint8_t *p_ie = NULL;
4878 tHtCaps *p_ht_cap;
4879 int i;
4880
4881 for (i = nss; i > 0; i--) {
4882 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4883 if (NULL == ie_params) {
4884 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4885 return;
4886 }
4887 ie_params->nss = i;
4888 ie_params->pdev_id = pdev_id;
4889 ie_params->ie_type = DOT11_HT_IE;
4890 /* 2 for IE len and EID */
4891 ie_params->ie_len = 2 + sizeof(tHtCaps);
4892 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4893 if (NULL == ie_params->ie_ptr) {
4894 qdf_mem_free(ie_params);
4895 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4896 return;
4897 }
4898 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4899 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4900 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4901 ie_params->ie_len);
4902
4903 if (NSS_1x1_MODE == i) {
4904 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4905 ie_params->ie_len,
4906 DOT11F_EID_HTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004907 if (NULL == p_ie) {
4908 qdf_mem_free(ie_params->ie_ptr);
4909 qdf_mem_free(ie_params);
4910 lim_log(mac_ctx, LOGE,
4911 FL("failed to get IE ptr"));
4912 return;
4913 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004914 p_ht_cap = (tHtCaps *)&p_ie[2];
4915 p_ht_cap->supportedMCSSet[1] = 0;
4916 p_ht_cap->txSTBC = 0;
4917 }
4918
4919 msg.type = WMA_SET_PDEV_IE_REQ;
4920 msg.bodyptr = ie_params;
4921 msg.bodyval = 0;
4922
4923 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4924 if (rc != eSIR_SUCCESS) {
4925 lim_log(mac_ctx, LOGE,
4926 FL("wma_post_ctrl_msg() return failure"));
4927 qdf_mem_free(ie_params->ie_ptr);
4928 qdf_mem_free(ie_params);
4929 return;
4930 }
4931 }
4932}
4933
4934/**
4935 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4936 * @mac_ctx: Pointer to Global MAC structure
4937 * @pdev_id: pdev id to set the IE.
4938 * @nss: Nss values to prepare the VHT IE.
4939 *
4940 * Prepares the VHT IE with self capabilities for different
4941 * Nss values and sends the set VHT IE req to FW.
4942 *
4943 * Return: None
4944 */
4945static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4946 uint8_t nss)
4947{
4948 struct set_ie_param *ie_params;
4949 tSirMsgQ msg;
4950 tSirRetStatus rc = eSIR_SUCCESS;
4951 uint8_t *p_ie = NULL;
4952 tSirMacVHTCapabilityInfo *vht_cap;
4953 int i;
4954 tSirVhtMcsInfo *vht_mcs;
4955
4956 for (i = nss; i > 0; i--) {
4957 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4958 if (NULL == ie_params) {
4959 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4960 return;
4961 }
4962 ie_params->nss = i;
4963 ie_params->pdev_id = pdev_id;
4964 ie_params->ie_type = DOT11_VHT_IE;
4965 /* 2 for IE len and EID */
4966 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4967 sizeof(tSirVhtMcsInfo);
4968 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4969 if (NULL == ie_params->ie_ptr) {
4970 qdf_mem_free(ie_params);
4971 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4972 return;
4973 }
4974 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4975 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4976 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4977 ie_params->ie_len);
4978
4979 if (NSS_1x1_MODE == i) {
4980 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4981 ie_params->ie_len,
4982 DOT11F_EID_VHTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004983 if (NULL == p_ie) {
4984 qdf_mem_free(ie_params->ie_ptr);
4985 qdf_mem_free(ie_params);
4986 lim_log(mac_ctx, LOGE,
4987 FL("failed to get IE ptr"));
4988 return;
4989 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004990 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4991 vht_cap->txSTBC = 0;
4992 vht_mcs =
4993 (tSirVhtMcsInfo *)&p_ie[2 +
4994 sizeof(tSirMacVHTCapabilityInfo)];
4995 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4996 vht_mcs->rxHighest =
4997 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4998 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4999 vht_mcs->txHighest =
5000 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
5001 }
5002 msg.type = WMA_SET_PDEV_IE_REQ;
5003 msg.bodyptr = ie_params;
5004 msg.bodyval = 0;
5005
5006 rc = wma_post_ctrl_msg(mac_ctx, &msg);
5007 if (rc != eSIR_SUCCESS) {
5008 lim_log(mac_ctx, LOGE,
5009 FL("wma_post_ctrl_msg failure"));
5010 qdf_mem_free(ie_params->ie_ptr);
5011 qdf_mem_free(ie_params);
5012 return;
5013 }
5014 }
5015}
5016
5017/**
5018 * lim_process_set_pdev_IEs() - process the set pdev IE req
5019 * @mac_ctx: Pointer to Global MAC structure
5020 * @msg_buf: Pointer to the SME message buffer
5021 *
5022 * This function is called by limProcessMessageQueue(). This
5023 * function sets the PDEV IEs to the FW.
5024 *
5025 * Return: None
5026 */
5027static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5028{
5029 struct sir_set_ht_vht_cfg *ht_vht_cfg;
5030
5031 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
5032
5033 if (NULL == ht_vht_cfg) {
5034 lim_log(mac_ctx, LOGE, FL("NULL ht_vht_cfg"));
5035 return;
5036 }
5037
5038 lim_log(mac_ctx, LOG1, FL("rcvd set pdev ht vht ie req with nss = %d"),
5039 ht_vht_cfg->nss);
5040 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
5041
5042 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
5043 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
5044 ht_vht_cfg->nss);
5045}
5046
5047/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305048 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
5049 *
5050 * access policy
5051 * @mac_ctx: pointer to mac context
5052 * @msg: message buffer
5053 *
5054 * function processes vendor IE and access policy from SME and updates PE
5055 *
5056 * session entry
5057 *
5058 * return: none
5059*/
5060static void lim_process_sme_update_access_policy_vendor_ie(
5061 tpAniSirGlobal mac_ctx,
5062 uint32_t *msg)
5063{
5064 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
5065 struct sPESession *pe_session_entry;
5066 uint8_t num_bytes;
5067
5068 if (!msg) {
5069 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5070 return;
5071 }
5072 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
5073 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
5074 update_vendor_ie->sme_session_id);
5075
5076 if (!pe_session_entry) {
5077 lim_log(mac_ctx, LOGE,
5078 FL("Session does not exist for given sme session id(%hu)"),
5079 update_vendor_ie->sme_session_id);
5080 return;
5081 }
5082 if (pe_session_entry->access_policy_vendor_ie)
5083 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
5084
5085 num_bytes = update_vendor_ie->ie[1] + 2;
5086 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
5087
5088 if (!pe_session_entry->access_policy_vendor_ie) {
5089 lim_log(mac_ctx, LOGE,
5090 FL("Failed to allocate memory for vendor ie"));
5091 return;
5092 }
5093 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
5094 &update_vendor_ie->ie[0], num_bytes);
5095
5096 pe_session_entry->access_policy = update_vendor_ie->access_policy;
5097}
5098
5099/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005100 * lim_process_sme_req_messages()
5101 *
5102 ***FUNCTION:
5103 * This function is called by limProcessMessageQueue(). This
5104 * function processes SME request messages from HDD or upper layer
5105 * application.
5106 *
5107 ***LOGIC:
5108 *
5109 ***ASSUMPTIONS:
5110 *
5111 ***NOTE:
5112 *
5113 * @param pMac Pointer to Global MAC structure
5114 * @param msgType Indicates the SME message type
5115 * @param *pMsgBuf A pointer to the SME message buffer
5116 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5117 * false - if pMsgBuf is not to be freed.
5118 */
5119
5120bool lim_process_sme_req_messages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
5121{
5122 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
5123 uint32_t *pMsgBuf = pMsg->bodyptr;
5124 tpSirSmeScanReq pScanReq;
5125 PELOG1(lim_log
5126 (pMac, LOG1,
5127 FL
5128 ("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)"),
5129 lim_msg_str(pMsg->type), pMsg->type,
5130 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
5131 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
5132 )
5133
5134 pScanReq = (tpSirSmeScanReq) pMsgBuf;
5135 /* If no insert NOA required then execute the code below */
5136
5137 switch (pMsg->type) {
5138 case eWNI_SME_SYS_READY_IND:
5139 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
5140 break;
5141
5142 case eWNI_SME_START_BSS_REQ:
5143 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
5144 break;
5145
5146 case eWNI_SME_SCAN_REQ:
5147 __lim_process_sme_scan_req(pMac, pMsgBuf);
5148 break;
5149
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005150 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5151 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
5152 break;
5153
5154 case eWNI_SME_UPDATE_NOA:
5155 __lim_process_sme_no_a_update(pMac, pMsgBuf);
5156 break;
5157 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
5158 __lim_process_clear_dfs_channel_list(pMac, pMsg);
5159 break;
5160 case eWNI_SME_JOIN_REQ:
5161 __lim_process_sme_join_req(pMac, pMsgBuf);
5162 break;
5163
5164 case eWNI_SME_REASSOC_REQ:
5165 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
5166 break;
5167
5168 case eWNI_SME_DISASSOC_REQ:
5169 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
5170 break;
5171
5172 case eWNI_SME_DISASSOC_CNF:
5173 case eWNI_SME_DEAUTH_CNF:
5174 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
5175 break;
5176
5177 case eWNI_SME_DEAUTH_REQ:
5178 __lim_process_sme_deauth_req(pMac, pMsgBuf);
5179 break;
5180
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05305181 case eWNI_SME_SEND_DISASSOC_FRAME:
5182 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
5183 break;
5184
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005185 case eWNI_SME_SETCONTEXT_REQ:
5186 __lim_process_sme_set_context_req(pMac, pMsgBuf);
5187 break;
5188
5189 case eWNI_SME_STOP_BSS_REQ:
5190 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
5191 break;
5192
5193 case eWNI_SME_ASSOC_CNF:
5194 if (pMsg->type == eWNI_SME_ASSOC_CNF)
5195 PELOG1(lim_log(pMac,
5196 LOG1, FL("Received ASSOC_CNF message"));)
5197 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
5198 pMsgBuf);
5199 break;
5200
5201 case eWNI_SME_ADDTS_REQ:
5202 PELOG1(lim_log(pMac, LOG1, FL("Received ADDTS_REQ message"));)
5203 __lim_process_sme_addts_req(pMac, pMsgBuf);
5204 break;
5205
5206 case eWNI_SME_DELTS_REQ:
5207 PELOG1(lim_log(pMac, LOG1, FL("Received DELTS_REQ message"));)
5208 __lim_process_sme_delts_req(pMac, pMsgBuf);
5209 break;
5210
5211 case SIR_LIM_ADDTS_RSP_TIMEOUT:
5212 PELOG1(lim_log
5213 (pMac, LOG1,
5214 FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
5215 )
5216 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
5217 break;
5218
5219 case eWNI_SME_GET_STATISTICS_REQ:
5220 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
5221 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
5222 bufConsumed = false;
5223 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005224#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005225 case eWNI_SME_GET_TSM_STATS_REQ:
5226 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
5227 bufConsumed = false;
5228 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005229#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005230 case eWNI_SME_GET_ASSOC_STAS_REQ:
5231 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
5232 break;
5233 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5234 lim_process_tkip_counter_measures(pMac, pMsgBuf);
5235 break;
5236
5237 case eWNI_SME_HIDE_SSID_REQ:
5238 __lim_process_sme_hide_ssid(pMac, pMsgBuf);
5239 break;
5240 case eWNI_SME_UPDATE_APWPSIE_REQ:
5241 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
5242 break;
5243 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5244 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
5245 break;
5246
5247 case eWNI_SME_SET_APWPARSNIEs_REQ:
5248 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
5249 break;
5250
5251 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5252 /* Update the beaconInterval */
5253 __lim_process_sme_change_bi(pMac, pMsgBuf);
5254 break;
5255
5256#ifdef QCA_HT_2040_COEX
5257 case eWNI_SME_SET_HT_2040_MODE:
5258 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
5259 break;
5260#endif
5261
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005262 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5263 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5264 __lim_process_report_message(pMac, pMsg);
5265 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005266
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005267 case eWNI_SME_FT_PRE_AUTH_REQ:
5268 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
5269 break;
5270 case eWNI_SME_FT_UPDATE_KEY:
5271 lim_process_ft_update_key(pMac, pMsgBuf);
5272 break;
5273
5274 case eWNI_SME_FT_AGGR_QOS_REQ:
5275 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
5276 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005277
5278 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5279 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
5280 break;
5281#ifdef FEATURE_WLAN_TDLS
5282 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5283 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
5284 break;
5285 case eWNI_SME_TDLS_ADD_STA_REQ:
5286 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
5287 break;
5288 case eWNI_SME_TDLS_DEL_STA_REQ:
5289 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
5290 break;
5291 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5292 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
5293 break;
5294#endif
5295 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5296 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
5297 break;
5298
5299 case eWNI_SME_CHANNEL_CHANGE_REQ:
5300 lim_process_sme_channel_change_request(pMac, pMsgBuf);
5301 break;
5302
5303 case eWNI_SME_START_BEACON_REQ:
5304 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
5305 break;
5306
5307 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
5308 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
5309 break;
5310
5311 case eWNI_SME_UPDATE_ADDITIONAL_IES:
5312 lim_process_update_add_ies(pMac, pMsgBuf);
5313 break;
5314
5315 case eWNI_SME_MODIFY_ADDITIONAL_IES:
5316 lim_process_modify_add_ies(pMac, pMsgBuf);
5317 break;
5318 case eWNI_SME_SET_HW_MODE_REQ:
5319 lim_process_set_hw_mode(pMac, pMsgBuf);
5320 break;
5321 case eWNI_SME_NSS_UPDATE_REQ:
5322 lim_process_nss_update_request(pMac, pMsgBuf);
5323 break;
5324 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5325 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5326 break;
5327 case eWNI_SME_SET_IE_REQ:
5328 lim_process_set_ie_req(pMac, pMsgBuf);
5329 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305330 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5331 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5332 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305333 case eWNI_SME_EXT_CHANGE_CHANNEL:
5334 lim_process_ext_change_channel(pMac, pMsgBuf);
5335 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005336 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5337 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5338 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005339 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5340 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawatf28315c2016-06-29 18:06:02 -07005341 case eWNI_SME_NDP_END_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005342 case eWNI_SME_NDP_INITIATOR_REQ:
Abhishek Singh4fef7472016-06-06 11:36:03 -07005343 case eWNI_SME_NDP_RESPONDER_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005344 lim_handle_ndp_request_message(pMac, pMsg);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005345 break;
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05305346 case eWNI_SME_REGISTER_P2P_ACK_CB:
5347 lim_register_p2p_ack_ind_cb(pMac, pMsgBuf);
5348 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305349 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5350 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5351 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005352 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305353 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005354 pMsg->bodyptr = NULL;
5355 break;
5356 } /* switch (msgType) */
5357
5358 return bufConsumed;
5359} /*** end lim_process_sme_req_messages() ***/
5360
5361/**
5362 * lim_process_sme_start_beacon_req()
5363 *
5364 ***FUNCTION:
5365 * This function is called by limProcessMessageQueue(). This
5366 * function processes SME request messages from HDD or upper layer
5367 * application.
5368 *
5369 ***LOGIC:
5370 *
5371 ***ASSUMPTIONS:
5372 *
5373 ***NOTE:
5374 *
5375 * @param pMac Pointer to Global MAC structure
5376 * @param msgType Indicates the SME message type
5377 * @param *pMsgBuf A pointer to the SME message buffer
5378 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5379 * false - if pMsgBuf is not to be freed.
5380 */
5381static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5382{
5383 tpSirStartBeaconIndication pBeaconStartInd;
5384 tpPESession psessionEntry;
5385 uint8_t sessionId; /* PE sessionID */
5386
5387 if (pMsg == NULL) {
5388 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
5389 return;
5390 }
5391
5392 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5393 psessionEntry = pe_find_session_by_bssid(pMac,
5394 pBeaconStartInd->bssid,
5395 &sessionId);
5396 if (psessionEntry == NULL) {
5397 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
5398 lim_log(pMac, LOGE,
5399 FL("Session does not exist for given bssId"));
5400 return;
5401 }
5402
5403 if (pBeaconStartInd->beaconStartStatus == true) {
5404 /*
5405 * Currently this Indication comes from SAP
5406 * to start Beacon Tx on a DFS channel
5407 * since beaconing has to be done on DFS
5408 * channel only after CAC WAIT is completed.
5409 * On a DFS Channel LIM does not start beacon
5410 * Tx right after the WMA_ADD_BSS_RSP.
5411 */
5412 lim_apply_configuration(pMac, psessionEntry);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305413 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005414 FL("Start Beacon with ssid %s Ch %d"),
5415 psessionEntry->ssId.ssId,
5416 psessionEntry->currentOperChannel);
5417 lim_send_beacon_ind(pMac, psessionEntry);
5418 } else {
5419 lim_log(pMac, LOGE, FL("Invalid Beacon Start Indication"));
5420 return;
5421 }
5422}
5423
5424/**
5425 * lim_process_sme_channel_change_request() - process sme ch change req
5426 *
5427 * @mac_ctx: Pointer to Global MAC structure
5428 * @msg_buf: pointer to the SME message buffer
5429 *
5430 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5431 *
5432 * Return: None
5433 */
5434static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5435 uint32_t *msg_buf)
5436{
5437 tpSirChanChangeRequest ch_change_req;
5438 tpPESession session_entry;
5439 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005440 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005441 uint32_t val = 0;
5442
5443 if (msg_buf == NULL) {
5444 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5445 return;
5446 }
5447 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5448
5449 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5450 ch_change_req->targetChannel);
5451
5452 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5453 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
5454 lim_log(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5455 return;
5456 }
5457
5458 session_entry = pe_find_session_by_bssid(mac_ctx,
5459 ch_change_req->bssid, &session_id);
5460 if (session_entry == NULL) {
5461 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
5462 lim_log(mac_ctx, LOGE, FL(
5463 "Session does not exist for given bssId"));
5464 return;
5465 }
5466
5467 if (session_entry->currentOperChannel ==
5468 ch_change_req->targetChannel) {
5469 lim_log(mac_ctx, LOGE, FL("target CH is same as current CH"));
5470 return;
5471 }
5472
5473 if (LIM_IS_AP_ROLE(session_entry))
5474 session_entry->channelChangeReasonCode =
5475 LIM_SWITCH_CHANNEL_SAP_DFS;
5476 else
5477 session_entry->channelChangeReasonCode =
5478 LIM_SWITCH_CHANNEL_OPERATION;
5479
5480 lim_log(mac_ctx, LOGW, FL(
5481 "switch old chnl %d to new chnl %d, ch_bw %d"),
5482 session_entry->currentOperChannel,
5483 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005484 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005485
5486 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005487 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005488 session_entry->ch_center_freq_seg0 =
5489 ch_change_req->center_freq_seg_0;
5490 session_entry->ch_center_freq_seg1 =
5491 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005492 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005493 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005494 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005495 session_entry->htRecommendedTxWidthSet =
5496 session_entry->htSupportedChannelWidthSet;
5497 session_entry->currentOperChannel =
5498 ch_change_req->targetChannel;
5499 session_entry->limRFBand =
5500 lim_get_rf_band(session_entry->currentOperChannel);
5501 /* Initialize 11h Enable Flag */
5502 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5503 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5504 eSIR_SUCCESS)
5505 lim_log(mac_ctx, LOGP,
5506 FL("Fail to get WNI_CFG_11H_ENABLED"));
5507 }
5508
5509 session_entry->lim11hEnable = val;
5510 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305511 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005512 &ch_change_req->operational_rateset,
5513 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305514 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005515 &ch_change_req->extended_rateset,
5516 sizeof(session_entry->extRateSet));
5517 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5518 session_entry->ch_center_freq_seg0,
5519 session_entry->ch_center_freq_seg1,
5520 session_entry->ch_width,
5521 max_tx_pwr, session_entry->peSessionId);
5522}
5523
5524/******************************************************************************
5525* lim_start_bss_update_add_ie_buffer()
5526*
5527***FUNCTION:
5528* This function checks the src buffer and its length and then malloc for
5529* dst buffer update the same
5530*
5531***LOGIC:
5532*
5533***ASSUMPTIONS:
5534*
5535***NOTE:
5536*
5537* @param pMac Pointer to Global MAC structure
5538* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5539* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5540* @param *pSrcData_buff A pointer of uint8_t src buffer
5541* @param srcDataLen src buffer length
5542******************************************************************************/
5543
5544static void
5545lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5546 uint8_t **pDstData_buff,
5547 uint16_t *pDstDataLen,
5548 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5549{
5550
5551 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5552 *pDstDataLen = srcDataLen;
5553
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305554 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005555
5556 if (NULL == *pDstData_buff) {
5557 lim_log(pMac, LOGE,
5558 FL("AllocateMemory failed for pDstData_buff"));
5559 return;
5560 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305561 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005562 } else {
5563 *pDstData_buff = NULL;
5564 *pDstDataLen = 0;
5565 }
5566}
5567
5568/******************************************************************************
5569* lim_update_add_ie_buffer()
5570*
5571***FUNCTION:
5572* This function checks the src buffer and length if src buffer length more
5573* than dst buffer length then free the dst buffer and malloc for the new src
5574* length, and update the dst buffer and length. But if dst buffer is bigger
5575* than src buffer length then it just update the dst buffer and length
5576*
5577***LOGIC:
5578*
5579***ASSUMPTIONS:
5580*
5581***NOTE:
5582*
5583* @param pMac Pointer to Global MAC structure
5584* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5585* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5586* @param *pSrcData_buff A pointer of uint8_t src buffer
5587* @param srcDataLen src buffer length
5588******************************************************************************/
5589
5590static void
5591lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5592 uint8_t **pDstData_buff,
5593 uint16_t *pDstDataLen,
5594 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5595{
5596
5597 if (NULL == pSrcData_buff) {
5598 lim_log(pMac, LOGE, FL("src buffer is null."));
5599 return;
5600 }
5601
5602 if (srcDataLen > *pDstDataLen) {
5603 *pDstDataLen = srcDataLen;
5604 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305605 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005606 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305607 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005608
5609 if (NULL == *pDstData_buff) {
5610 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5611 *pDstDataLen = 0;
5612 return;
5613 }
5614 }
5615
5616 /* copy the content of buffer into dst buffer
5617 */
5618 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305619 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005620
5621}
5622
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005623/**
5624 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5625 * @pMac : Pointer to Global MAC structure
5626 * @pDstData_buff : A pointer to pointer of dst buffer
5627 * @pDstDataLen : A pointer to pointer of dst buffer length
5628 * @pModifyIE : A pointer to tSirModifyIE
5629 *
5630 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5631 *
5632 * Return:
5633 * True or false depending upon whether IE is updated or not
5634 */
5635static bool
5636lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5637 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5638{
5639 int32_t oui_length;
5640 uint8_t *ibss_ie = NULL;
5641
5642 ibss_ie = pModifyIE->pIEBuffer;
5643 oui_length = pModifyIE->oui_length;
5644
5645 if ((0 == oui_length) || (NULL == ibss_ie)) {
5646 PELOGE(lim_log(pMac, LOGE,
5647 FL("Invalid set IBSS vendor IE command length %d "),
5648 oui_length);)
5649 return false;
5650 }
5651
5652 lim_update_add_ie_buffer(pMac,
5653 pDstData_buff,
5654 pDstDataLen,
5655 pModifyIE->pIEBuffer,
5656 pModifyIE->ieBufferlength);
5657
5658 return true;
5659}
5660
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005661/*
5662* lim_process_modify_add_ies() - process modify additional IE req.
5663*
5664* @mac_ctx: Pointer to Global MAC structure
5665* @msg_buf: pointer to the SME message buffer
5666*
5667* This function update the PE buffers for additional IEs.
5668*
5669* Return: None
5670*/
5671static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5672 uint32_t *msg_buf)
5673{
5674 tpSirModifyIEsInd modify_add_ies;
5675 tpPESession session_entry;
5676 uint8_t session_id;
5677 bool ret = false;
5678 tSirAddIeParams *add_ie_params;
5679
5680 if (msg_buf == NULL) {
5681 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5682 return;
5683 }
5684
5685 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5686 /* Incoming message has smeSession, use BSSID to find PE session */
5687 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005688 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005689
5690 if (NULL == session_entry) {
5691 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5692 MAC_ADDRESS_STR),
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005693 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005694 goto end;
5695 }
5696 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5697 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5698 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
5699 lim_log(mac_ctx, LOGE,
5700 FL("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d"),
5701 modify_add_ies->modifyIE.pIEBuffer,
5702 modify_add_ies->modifyIE.ieBufferlength,
5703 modify_add_ies->modifyIE.ieID,
5704 modify_add_ies->modifyIE.ieIDLen,
5705 modify_add_ies->updateType);
5706 goto end;
5707 }
5708 add_ie_params = &session_entry->addIeParams;
5709 switch (modify_add_ies->updateType) {
5710 case eUPDATE_IE_PROBE_RESP:
5711 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005712 if (LIM_IS_IBSS_ROLE(session_entry)) {
5713 lim_update_ibss_prop_add_ies(mac_ctx,
5714 &add_ie_params->probeRespData_buff,
5715 &add_ie_params->probeRespDataLen,
5716 &modify_add_ies->modifyIE);
5717 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005718 break;
5719 case eUPDATE_IE_ASSOC_RESP:
5720 /* assoc resp IE */
5721 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305722 QDF_TRACE(QDF_MODULE_ID_PE,
5723 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005724 "assoc resp add ie not present %d"),
5725 add_ie_params->assocRespDataLen);
5726 }
5727 /* search through the buffer and modify the IE */
5728 break;
5729 case eUPDATE_IE_PROBE_BCN:
5730 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005731 if (LIM_IS_IBSS_ROLE(session_entry)) {
5732 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5733 &add_ie_params->probeRespBCNData_buff,
5734 &add_ie_params->probeRespBCNDataLen,
5735 &modify_add_ies->modifyIE);
5736 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005737 if (ret == true && modify_add_ies->modifyIE.notify) {
5738 lim_handle_param_update(mac_ctx,
5739 modify_add_ies->updateType);
5740 }
5741 break;
5742 default:
5743 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d"),
5744 modify_add_ies->updateType);
5745 break;
5746 }
5747end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305748 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005749 modify_add_ies->modifyIE.pIEBuffer = NULL;
5750}
5751
5752/*
5753* lim_process_update_add_ies() - process additional IE update req
5754*
5755* @mac_ctx: Pointer to Global MAC structure
5756* @msg_buf: pointer to the SME message buffer
5757*
5758* This function update the PE buffers for additional IEs.
5759*
5760* Return: None
5761*/
5762static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5763 uint32_t *msg_buf)
5764{
5765 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5766 uint8_t session_id;
5767 tpPESession session_entry;
5768 tSirAddIeParams *addn_ie;
5769 uint16_t new_length = 0;
5770 uint8_t *new_ptr = NULL;
5771 tSirUpdateIE *update_ie;
5772
5773 if (msg_buf == NULL) {
5774 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5775 return;
5776 }
5777 update_ie = &update_add_ies->updateIE;
5778 /* incoming message has smeSession, use BSSID to find PE session */
5779 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005780 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005781
5782 if (NULL == session_entry) {
5783 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5784 MAC_ADDRESS_STR),
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005785 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005786 goto end;
5787 }
5788 addn_ie = &session_entry->addIeParams;
5789 /* if len is 0, upper layer requested freeing of buffer */
5790 if (0 == update_ie->ieBufferlength) {
5791 switch (update_add_ies->updateType) {
5792 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305793 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005794 addn_ie->probeRespData_buff = NULL;
5795 addn_ie->probeRespDataLen = 0;
5796 break;
5797 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305798 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005799 addn_ie->assocRespData_buff = NULL;
5800 addn_ie->assocRespDataLen = 0;
5801 break;
5802 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305803 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005804 addn_ie->probeRespBCNData_buff = NULL;
5805 addn_ie->probeRespBCNDataLen = 0;
5806
5807 if (update_ie->notify)
5808 lim_handle_param_update(mac_ctx,
5809 update_add_ies->updateType);
5810 break;
5811 default:
5812 break;
5813 }
5814 return;
5815 }
5816 switch (update_add_ies->updateType) {
5817 case eUPDATE_IE_PROBE_RESP:
5818 if (update_ie->append) {
5819 /*
5820 * In case of append, allocate new memory
5821 * with combined length
5822 */
5823 new_length = update_ie->ieBufferlength +
5824 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305825 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005826 if (NULL == new_ptr) {
5827 lim_log(mac_ctx, LOGE, FL(
5828 "Memory allocation failed."));
5829 goto end;
5830 }
5831 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305832 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005833 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305834 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005835 update_ie->pAdditionIEBuffer,
5836 update_ie->ieBufferlength);
5837 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305838 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005839 /* adjust length accordingly */
5840 addn_ie->probeRespDataLen = new_length;
5841 /* save refernece of local buffer in PE session */
5842 addn_ie->probeRespData_buff = new_ptr;
5843 goto end;
5844 }
5845 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5846 &addn_ie->probeRespDataLen,
5847 update_ie->pAdditionIEBuffer,
5848 update_ie->ieBufferlength);
5849 break;
5850 case eUPDATE_IE_ASSOC_RESP:
5851 /* assoc resp IE */
5852 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5853 &addn_ie->assocRespDataLen,
5854 update_ie->pAdditionIEBuffer,
5855 update_ie->ieBufferlength);
5856 break;
5857 case eUPDATE_IE_PROBE_BCN:
5858 /* probe resp Bcn IE */
5859 lim_update_add_ie_buffer(mac_ctx,
5860 &addn_ie->probeRespBCNData_buff,
5861 &addn_ie->probeRespBCNDataLen,
5862 update_ie->pAdditionIEBuffer,
5863 update_ie->ieBufferlength);
5864 if (update_ie->notify)
5865 lim_handle_param_update(mac_ctx,
5866 update_add_ies->updateType);
5867 break;
5868 default:
5869 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d."),
5870 update_add_ies->updateType);
5871 break;
5872 }
5873end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305874 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005875 update_ie->pAdditionIEBuffer = NULL;
5876}
5877
5878/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305879 * send_extended_chan_switch_action_frame()- function to send ECSA
5880 * action frame for each sta connected to SAP/GO and AP in case of
5881 * STA .
5882 * @mac_ctx: pointer to global mac structure
5883 * @new_channel: new channel to switch to.
5884 * @ch_bandwidth: BW of channel to calculate op_class
5885 * @session_entry: pe session
5886 *
5887 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5888 *
5889 * Return: void
5890 */
5891
5892static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5893 uint16_t new_channel, uint8_t ch_bandwidth,
5894 tpPESession session_entry)
5895{
5896 uint16_t op_class;
5897 uint8_t switch_mode = 0, i;
5898 tpDphHashNode psta;
5899
5900
Amar Singhal22995112016-01-22 10:42:33 -08005901 op_class = cds_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305902 mac_ctx->scan.countryCodeCurrent,
5903 new_channel,
5904 ch_bandwidth);
5905
5906 if (LIM_IS_AP_ROLE(session_entry) &&
5907 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
5908 switch_mode = 1;
5909
5910 if (LIM_IS_AP_ROLE(session_entry)) {
5911 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5912 psta =
5913 session_entry->dph.dphHashTable.pDphNodeArray + i;
5914 if (psta && psta->added)
5915 lim_send_extended_chan_switch_action_frame(
5916 mac_ctx,
5917 psta->staAddr,
5918 switch_mode, op_class, new_channel,
5919 LIM_MAX_CSA_IE_UPDATES, session_entry);
5920 }
5921 } else if (LIM_IS_STA_ROLE(session_entry)) {
5922 lim_send_extended_chan_switch_action_frame(mac_ctx,
5923 session_entry->bssId,
5924 switch_mode, op_class, new_channel,
5925 LIM_MAX_CSA_IE_UPDATES, session_entry);
5926 }
5927
5928}
5929
5930/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005931 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5932 *
5933 * @mac_ctx: Pointer to Global MAC structure
5934 * @msg_buf: pointer to the SME message buffer
5935 *
5936 * This function processes SME request messages from HDD or upper layer
5937 * application.
5938 *
5939 * Return: None
5940 */
5941static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5942 uint32_t *msg_buf)
5943{
5944 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5945 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005946 uint8_t session_id;
5947 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005948 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005949
5950 if (msg_buf == NULL) {
5951 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5952 return;
5953 }
5954
5955 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5956 session_entry = pe_find_session_by_bssid(mac_ctx,
5957 dfs_csa_ie_req->bssid, &session_id);
5958 if (session_entry == NULL) {
5959 lim_log(mac_ctx, LOGE, FL(
5960 "Session not found for given BSSID" MAC_ADDRESS_STR),
5961 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5962 return;
5963 }
5964
5965 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5966 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5967 GET_LIM_SYSTEM_ROLE(session_entry));
5968 return;
5969 }
5970
5971 /* target channel */
5972 session_entry->gLimChannelSwitch.primaryChannel =
5973 dfs_csa_ie_req->targetChannel;
5974
5975 /* Channel switch announcement needs to be included in beacon */
5976 session_entry->dfsIncludeChanSwIe = true;
5977 session_entry->gLimChannelSwitch.switchCount = LIM_MAX_CSA_IE_UPDATES;
5978 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005979 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305980 session_entry->gLimChannelSwitch.sec_ch_offset =
5981 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005982 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
5983 session_entry->gLimChannelSwitch.switchMode = 1;
5984
5985 /*
5986 * Validate if SAP is operating HT or VHT mode and set the Channel
5987 * Switch Wrapper element with the Wide Band Switch subelement.
5988 */
5989 if (true != session_entry->vhtCapability)
5990 goto skip_vht;
5991
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005992 /* Now encode the Wider Ch BW element depending on the ch width */
5993 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005994 switch (dfs_csa_ie_req->ch_params.ch_width) {
5995 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005996 /*
5997 * Wide channel BW sublement in channel wrapper element is not
5998 * required in case of 20 Mhz operation. Currently It is set
5999 * only set in case of 40/80 Mhz Operation.
6000 */
6001 session_entry->dfsIncludeChanWrapperIe = false;
6002 wider_bw_ch_switch->newChanWidth =
6003 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
6004 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006005 case CH_WIDTH_40MHZ:
6006 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006007 wider_bw_ch_switch->newChanWidth =
6008 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
6009 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006010 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006011 session_entry->dfsIncludeChanWrapperIe = true;
6012 wider_bw_ch_switch->newChanWidth =
6013 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
6014 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006015 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006016 session_entry->dfsIncludeChanWrapperIe = true;
6017 wider_bw_ch_switch->newChanWidth =
6018 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
6019 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006020 case CH_WIDTH_80P80MHZ:
6021 session_entry->dfsIncludeChanWrapperIe = true;
6022 wider_bw_ch_switch->newChanWidth =
6023 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08006024 /*
6025 * This is not applicable for 20/40/80 Mhz.
6026 * Only used when we support 80+80 Mhz operation.
6027 * In case of 80+80 Mhz, this parameter indicates
6028 * center channel frequency index of 80 Mhz channel of
6029 * frequency segment 1.
6030 */
6031 wider_bw_ch_switch->newCenterChanFreq1 =
6032 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006033 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006034 default:
6035 session_entry->dfsIncludeChanWrapperIe = false;
6036 /*
6037 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
6038 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
6039 */
6040 lim_log(mac_ctx, LOGE, FL("Invalid Channel Width"));
6041 break;
6042 }
6043 /* Fetch the center channel based on the channel width */
6044 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006045 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006046skip_vht:
6047 /* Send CSA IE request from here */
6048 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6049 eSIR_SUCCESS) {
6050 lim_log(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
6051 return;
6052 }
6053
6054 /*
6055 * First beacon update request is sent here, the remaining updates are
6056 * done when the FW responds back after sending the first beacon after
6057 * the template update
6058 */
6059 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306060
6061 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
6062 ch_offset = BW80;
6063 else
6064 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
6065
6066 lim_log(mac_ctx, LOG1, FL("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d"),
6067 session_entry->gLimChannelSwitch.switchCount,
6068 session_entry->gLimChannelSwitch.primaryChannel,
6069 session_entry->gLimChannelSwitch.ch_width,
6070 session_entry->dfsIncludeChanWrapperIe,
6071 ch_offset);
6072
Abhishek Singh518323d2015-10-19 17:42:01 +05306073 /* Send ECSA Action frame after updating the beacon */
6074 send_extended_chan_switch_action_frame(mac_ctx,
6075 session_entry->gLimChannelSwitch.primaryChannel,
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306076 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006077 session_entry->gLimChannelSwitch.switchCount--;
6078}
6079
6080/**
Abhishek Singh518323d2015-10-19 17:42:01 +05306081 * lim_process_ext_change_channel()- function to send ECSA
6082 * action frame for STA/CLI .
6083 * @mac_ctx: pointer to global mac structure
6084 * @msg: params from sme for new channel.
6085 *
6086 * This function is called to send ECSA frame for STA/CLI.
6087 *
6088 * Return: void
6089 */
6090
6091static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
6092 uint32_t *msg)
6093{
6094 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
6095 (struct sir_sme_ext_cng_chan_req *) msg;
6096 tpPESession session_entry = NULL;
6097
6098 if (NULL == msg) {
6099 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6100 return;
6101 }
6102 session_entry =
6103 pe_find_session_by_sme_session_id(mac_ctx,
6104 ext_chng_channel->session_id);
6105 if (NULL == session_entry) {
6106 lim_log(mac_ctx, LOGE,
6107 FL("Session not found for given session %d"),
6108 ext_chng_channel->session_id);
6109 return;
6110 }
6111 if (LIM_IS_AP_ROLE(session_entry)) {
6112 lim_log(mac_ctx, LOGE,
6113 FL("not an STA/CLI session"));
6114 return;
6115 }
6116 send_extended_chan_switch_action_frame(mac_ctx,
6117 ext_chng_channel->new_channel,
6118 0, session_entry);
6119}
6120
6121/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006122 * lim_process_nss_update_request() - process sme nss update req
6123 *
6124 * @mac_ctx: Pointer to Global MAC structure
6125 * @msg_buf: pointer to the SME message buffer
6126 *
6127 * This function processes SME request messages from HDD or upper layer
6128 * application.
6129 *
6130 * Return: None
6131 */
6132static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
6133 uint32_t *msg_buf)
6134{
6135 struct sir_nss_update_request *nss_update_req_ptr;
6136 tpPESession session_entry = NULL;
6137
6138 if (msg_buf == NULL) {
6139 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6140 return;
6141 }
6142
6143 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05306144 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006145 nss_update_req_ptr->vdev_id);
6146 if (session_entry == NULL) {
6147 lim_log(mac_ctx, LOGE, FL(
6148 "Session not found for given session_id %d"),
6149 nss_update_req_ptr->vdev_id);
6150 return;
6151 }
6152
6153 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6154 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
6155 GET_LIM_SYSTEM_ROLE(session_entry));
6156 return;
6157 }
6158
6159 /* populate nss field in the beacon */
6160 session_entry->gLimOperatingMode.present = 1;
6161 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
6162 /* Send nss update request from here */
6163 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6164 eSIR_SUCCESS) {
6165 lim_log(mac_ctx, LOGE,
6166 FL("Unable to set op mode IE in beacon"));
6167 return;
6168 }
6169
6170 lim_send_beacon_ind(mac_ctx, session_entry);
6171}
6172
6173/**
6174 * lim_process_set_ie_req() - process sme set IE request
6175 *
6176 * @mac_ctx: Pointer to Global MAC structure
6177 * @msg_buf: pointer to the SME message buffer
6178 *
6179 * This function processes SME request messages from HDD or upper layer
6180 * application.
6181 *
6182 * Return: None
6183 */
6184static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6185{
6186 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306187 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006188
6189 if (msg_buf == NULL) {
6190 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6191 return;
6192 }
6193
6194 msg = (struct send_extcap_ie *)msg_buf;
6195 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306196 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006197 lim_log(mac_ctx, LOGE, FL("Unable to send ExtCap to FW"));
6198
6199}