blob: b976f0ab24aa1c51461c7dc99a732d0888188582 [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
2190 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2191 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002192 session_entry->send_smps_action =
2193 reassoc_req->send_smps_action;
2194 lim_log(mac_ctx, LOG1,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002195 FL("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002196 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002197 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002198 session_entry->send_smps_action,
2199 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002200 /*
2201 * Reassociate request is expected
2202 * in link established state only.
2203 */
2204
2205 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002206 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2207 /*
2208 * May be from 11r FT pre-auth. So lets check it
2209 * before we bail out
2210 */
2211 lim_log(mac_ctx, LOG1, FL(
2212 "Session in reassoc state is %d"),
2213 session_entry->peSessionId);
2214
2215 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302216 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002217 session_entry->limReAssocbssId,
2218 6)) {
2219 lim_print_mac_addr(mac_ctx,
2220 reassoc_req->bssDescription.
2221 bssId, LOGE);
2222 lim_log(mac_ctx, LOGP,
2223 FL("Unknown bssId in reassoc state"));
2224 ret_code = eSIR_SME_INVALID_PARAMETERS;
2225 goto end;
2226 }
2227
2228 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2229 session_entry);
2230 return;
2231 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002232 /*
2233 * Should not have received eWNI_SME_REASSOC_REQ
2234 */
2235 lim_log(mac_ctx, LOGE,
2236 FL("received unexpected SME_REASSOC_REQ in state %X"),
2237 session_entry->limSmeState);
2238 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2239
2240 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2241 goto end;
2242 }
2243
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302244 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002245 session_entry->pLimReAssocReq->bssDescription.bssId,
2246 sizeof(tSirMacAddr));
2247
2248 session_entry->limReassocChannelId =
2249 session_entry->pLimReAssocReq->bssDescription.channelId;
2250
2251 session_entry->reAssocHtSupportedChannelWidthSet =
2252 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2253 session_entry->reAssocHtRecommendedTxWidthSet =
2254 session_entry->reAssocHtSupportedChannelWidthSet;
2255 session_entry->reAssocHtSecondaryChannelOffset =
2256 session_entry->pLimReAssocReq->cbMode;
2257
2258 session_entry->limReassocBssCaps =
2259 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2260 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2261 session_entry->currentOperChannel);
2262 local_pwr_constraint = reg_max;
2263
2264 lim_extract_ap_capability(mac_ctx,
2265 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2266 lim_get_ielen_from_bss_description(
2267 &session_entry->pLimReAssocReq->bssDescription),
2268 &session_entry->limReassocBssQosCaps,
2269 &session_entry->limReassocBssPropCap,
2270 &session_entry->gLimCurrentBssUapsd,
2271 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302272 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002273 lim_log(mac_ctx, LOGE,
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302274 FL("Reg max = %d, local pwr constraint = %d, max tx = %d"),
2275 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002276 /* Copy the SSID from session entry to local variable */
2277 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302278 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002279 reassoc_req->ssId.ssId,
2280 session_entry->limReassocSSID.length);
2281 if (session_entry->gLimCurrentBssUapsd) {
2282 session_entry->gUapsdPerAcBitmask =
2283 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
2284 lim_log(mac_ctx, LOG1,
2285 FL("UAPSD flag for all AC - 0x%2x"),
2286 session_entry->gUapsdPerAcBitmask);
2287 }
2288
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302289 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002290 if (NULL == mlm_reassoc_req) {
2291 lim_log(mac_ctx, LOGP,
2292 FL("call to AllocateMemory failed for mlmReassocReq"));
2293
2294 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2295 goto end;
2296 }
2297
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302298 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002299 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2300
2301 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2302 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
2303 eSIR_SUCCESS) {
2304 /*
2305 * Could not get ReassocFailureTimeout value
2306 * from CFG. Log error.
2307 */
2308 lim_log(mac_ctx, LOGP,
2309 FL("could not retrieve ReassocFailureTimeout value"));
2310 }
2311
2312 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
2313 eSIR_SUCCESS) {
2314 /*
2315 * Could not get Capabilities value
2316 * from CFG. Log error.
2317 */
2318 lim_log(mac_ctx, LOGP, FL(
2319 "could not retrieve Capabilities value"));
2320 }
2321 mlm_reassoc_req->capabilityInfo = caps;
2322
2323 /* Update PE session_id */
2324 mlm_reassoc_req->sessionId = session_id;
2325
2326 /*
2327 * If telescopic beaconing is enabled, set listen interval to
2328 * WNI_CFG_TELE_BCN_MAX_LI
2329 */
2330 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2331 &tele_bcn_en) != eSIR_SUCCESS)
2332 lim_log(mac_ctx, LOGP,
2333 FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
2334
2335 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2336
2337 if (tele_bcn_en) {
2338 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2339 eSIR_SUCCESS)
2340 /*
2341 * Could not get ListenInterval value
2342 * from CFG. Log error.
2343 */
2344 lim_log(mac_ctx, LOGP,
2345 FL("could not retrieve ListenInterval"));
2346 } else {
2347 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
2348 eSIR_SUCCESS)
2349 /*
2350 * Could not get ListenInterval value
2351 * from CFG. Log error.
2352 */
2353 lim_log(mac_ctx, LOGP,
2354 FL("could not retrieve ListenInterval"));
2355 }
2356
2357 mlm_reassoc_req->listenInterval = (uint16_t) val;
2358
2359 /* Indicate whether spectrum management is enabled */
2360 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2361
2362 /* Enable the spectrum management if this is a DFS channel */
2363 if (session_entry->country_info_present &&
2364 lim_isconnected_on_dfs_channel(
2365 session_entry->currentOperChannel))
2366 session_entry->spectrumMgtEnabled = true;
2367
2368 session_entry->limPrevSmeState = session_entry->limSmeState;
2369 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2370
2371 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2372 session_entry->peSessionId,
2373 session_entry->limSmeState));
2374
2375 lim_post_mlm_message(mac_ctx,
2376 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2377 return;
2378end:
2379 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302380 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002381 if (session_entry)
2382 session_entry->pLimReAssocReq = NULL;
2383 }
2384
2385 if (session_entry) {
2386 /*
2387 * error occurred after we determined the session so extract
2388 * session and transaction info from there
2389 */
2390 sme_session_id = session_entry->smeSessionId;
2391 transaction_id = session_entry->transactionId;
2392 } else
2393 /*
2394 * error occurred before or during the time we determined
2395 * the session so extract the session and transaction info
2396 * from the message
2397 */
2398 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2399 &sme_session_id, &transaction_id);
2400
2401 /*
2402 * Send Reassoc failure response to host
2403 * (note session_entry may be NULL, but that's OK)
2404 */
2405 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2406 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2407 session_entry, sme_session_id,
2408 transaction_id);
2409}
2410
2411bool send_disassoc_frame = 1;
2412/**
2413 * __lim_process_sme_disassoc_req()
2414 *
2415 ***FUNCTION:
2416 * This function is called to process SME_DISASSOC_REQ message
2417 * from HDD or upper layer application.
2418 *
2419 ***LOGIC:
2420 *
2421 ***ASSUMPTIONS:
2422 *
2423 ***NOTE:
2424 *
2425 * @param pMac Pointer to Global MAC structure
2426 * @param *pMsgBuf A pointer to the SME message buffer
2427 * @return None
2428 */
2429
2430static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2431{
2432 uint16_t disassocTrigger, reasonCode;
2433 tLimMlmDisassocReq *pMlmDisassocReq;
2434 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2435 tSirSmeDisassocReq smeDisassocReq;
2436 tpPESession psessionEntry = NULL;
2437 uint8_t sessionId;
2438 uint8_t smesessionId;
2439 uint16_t smetransactionId;
2440
2441 if (pMsgBuf == NULL) {
2442 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
2443 return;
2444 }
2445
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302446 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002447 smesessionId = smeDisassocReq.sessionId;
2448 smetransactionId = smeDisassocReq.transactionId;
2449 if (!lim_is_sme_disassoc_req_valid(pMac,
2450 &smeDisassocReq,
2451 psessionEntry)) {
2452 PELOGE(lim_log(pMac, LOGE,
2453 FL("received invalid SME_DISASSOC_REQ message"));)
2454 if (pMac->lim.gLimRspReqd) {
2455 pMac->lim.gLimRspReqd = false;
2456
2457 retCode = eSIR_SME_INVALID_PARAMETERS;
2458 disassocTrigger = eLIM_HOST_DISASSOC;
2459 goto sendDisassoc;
2460 }
2461
2462 return;
2463 }
2464
2465 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002466 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002467 &sessionId);
2468 if (psessionEntry == NULL) {
2469 lim_log(pMac, LOGE,
2470 FL("session does not exist for given bssId "
2471 MAC_ADDRESS_STR),
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002472 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002473 retCode = eSIR_SME_INVALID_PARAMETERS;
2474 disassocTrigger = eLIM_HOST_DISASSOC;
2475 goto sendDisassoc;
2476 }
2477 lim_log(pMac, LOG1,
2478 FL("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2479 MAC_ADDRESS_STR), smesessionId,
2480 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2481 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002482 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002483
2484#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2485 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2486 0, smeDisassocReq.reasonCode);
2487#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2488
2489 /* Update SME session Id and SME transaction ID */
2490
2491 psessionEntry->smeSessionId = smesessionId;
2492 psessionEntry->transactionId = smetransactionId;
2493
2494 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2495 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002496 switch (psessionEntry->limSmeState) {
2497 case eLIM_SME_ASSOCIATED_STATE:
2498 case eLIM_SME_LINK_EST_STATE:
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002499 lim_log(pMac, LOG1,
2500 FL("Rcvd SME_DISASSOC_REQ in limSmeState: %d "),
2501 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002502 psessionEntry->limPrevSmeState =
2503 psessionEntry->limSmeState;
2504 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2505#ifdef FEATURE_WLAN_TDLS
2506 /* Delete all TDLS peers connected before leaving BSS */
2507 lim_delete_tdls_peers(pMac, psessionEntry);
2508#endif
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002509 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2510 psessionEntry->peSessionId,
2511 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002512 break;
2513
2514 case eLIM_SME_WT_DEAUTH_STATE:
2515 /* PE shall still process the DISASSOC_REQ and proceed with
2516 * link tear down even if it had already sent a DEAUTH_IND to
2517 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2518 * its been set when PE entered WT_DEAUTH_STATE.
2519 */
2520 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2521 MTRACE(mac_trace
2522 (pMac, TRACE_CODE_SME_STATE,
2523 psessionEntry->peSessionId,
2524 psessionEntry->limSmeState));
2525 lim_log(pMac, LOG1,
2526 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE. "));
2527 break;
2528
2529 case eLIM_SME_WT_DISASSOC_STATE:
2530 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2531 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2532 * PE can continue processing DISASSOC_REQ and send the response instead
2533 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2534 * for disassoc frame.
2535 *
2536 * It will send a disassoc, which is ok. However, we can use the global flag
2537 * sendDisassoc to not send disassoc frame.
2538 */
2539 lim_log(pMac, LOG1,
2540 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE. "));
2541 break;
2542
2543 case eLIM_SME_JOIN_FAILURE_STATE: {
2544 /* Already in Disconnected State, return success */
2545 lim_log(pMac, LOG1,
2546 FL("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE. "));
2547 if (pMac->lim.gLimRspReqd) {
2548 retCode = eSIR_SME_SUCCESS;
2549 disassocTrigger = eLIM_HOST_DISASSOC;
2550 goto sendDisassoc;
2551 }
2552 }
2553 break;
2554 default:
2555 /**
2556 * STA is not currently associated.
2557 * Log error and send response to host
2558 */
2559 lim_log(pMac, LOGE,
2560 FL("received unexpected SME_DISASSOC_REQ in state %X"),
2561 psessionEntry->limSmeState);
2562 lim_print_sme_state(pMac, LOGE,
2563 psessionEntry->limSmeState);
2564
2565 if (pMac->lim.gLimRspReqd) {
2566 if (psessionEntry->limSmeState !=
2567 eLIM_SME_WT_ASSOC_STATE)
2568 pMac->lim.gLimRspReqd = false;
2569
2570 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2571 disassocTrigger = eLIM_HOST_DISASSOC;
2572 goto sendDisassoc;
2573 }
2574
2575 return;
2576 }
2577
2578 break;
2579
2580 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002581 /* Fall through */
2582 break;
2583
2584 case eLIM_STA_IN_IBSS_ROLE:
2585 default:
2586 /* eLIM_UNKNOWN_ROLE */
2587 lim_log(pMac, LOGE,
2588 FL("received unexpected SME_DISASSOC_REQ for role %d"),
2589 GET_LIM_SYSTEM_ROLE(psessionEntry));
2590
2591 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2592 disassocTrigger = eLIM_HOST_DISASSOC;
2593 goto sendDisassoc;
2594 } /* end switch (pMac->lim.gLimSystemRole) */
2595
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302596 disassocTrigger = eLIM_HOST_DISASSOC;
2597 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002598
2599 if (smeDisassocReq.doNotSendOverTheAir) {
2600 lim_log(pMac, LOG1, FL("do not send dissoc over the air"));
2601 send_disassoc_frame = 0;
2602 }
2603 /* Trigger Disassociation frame to peer MAC entity */
2604 lim_log(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2605 " : %d, reasonCode : %d"),
2606 disassocTrigger, reasonCode);
2607
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302608 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002609 if (NULL == pMlmDisassocReq) {
2610 /* Log error */
2611 lim_log(pMac, LOGP,
2612 FL("call to AllocateMemory failed for mlmDisassocReq"));
2613
2614 return;
2615 }
2616
Anurag Chouhanc5548422016-02-24 18:33:27 +05302617 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002618 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002619
2620 pMlmDisassocReq->reasonCode = reasonCode;
2621 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2622
2623 /* Update PE session ID */
2624 pMlmDisassocReq->sessionId = sessionId;
2625
2626 lim_post_mlm_message(pMac,
2627 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2628 return;
2629
2630sendDisassoc:
2631 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002632 lim_send_sme_disassoc_ntf(pMac,
2633 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002634 retCode,
2635 disassocTrigger,
2636 1, smesessionId, smetransactionId,
2637 psessionEntry);
2638 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002639 lim_send_sme_disassoc_ntf(pMac,
2640 smeDisassocReq.peer_macaddr.bytes,
2641 retCode, disassocTrigger, 1,
2642 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002643
2644} /*** end __lim_process_sme_disassoc_req() ***/
2645
2646/** -----------------------------------------------------------------
2647 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2648
2649 This function is called to process SME_DISASSOC_CNF message
2650 from HDD or upper layer application.
2651
2652 \param pMac - global mac structure
2653 \param pStaDs - station dph hash node
2654 \return none
2655 \sa
2656 ----------------------------------------------------------------- */
2657static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2658{
2659 tSirSmeDisassocCnf smeDisassocCnf;
2660 uint16_t aid;
2661 tpDphHashNode pStaDs;
2662 tpPESession psessionEntry;
2663 uint8_t sessionId;
2664
2665 PELOG1(lim_log(pMac, LOG1, FL("received DISASSOC_CNF message"));)
2666
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302667 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002668 sizeof(struct sSirSmeDisassocCnf));
2669
2670 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002671 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002672 &sessionId);
2673 if (psessionEntry == NULL) {
2674 lim_log(pMac, LOGE,
2675 FL("session does not exist for given bssId"));
2676 return;
2677 }
2678
2679 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
2680 lim_log(pMac, LOGE,
2681 FL("received invalid SME_DISASSOC_CNF message"));
2682 return;
2683 }
2684#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2685 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2686 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2687 psessionEntry,
2688 (uint16_t) smeDisassocCnf.statusCode, 0);
2689 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2690 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2691 psessionEntry,
2692 (uint16_t) smeDisassocCnf.statusCode, 0);
2693#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2694
2695 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2696 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002697 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2698 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2699 && (psessionEntry->limSmeState !=
2700 eLIM_SME_WT_DEAUTH_STATE)) {
2701 lim_log(pMac, LOGE,
2702 FL
2703 ("received unexp SME_DISASSOC_CNF in state %X"),
2704 psessionEntry->limSmeState);
2705 lim_print_sme_state(pMac, LOGE,
2706 psessionEntry->limSmeState);
2707 return;
2708 }
2709 break;
2710
2711 case eLIM_AP_ROLE:
2712 /* Fall through */
2713 break;
2714
2715 case eLIM_STA_IN_IBSS_ROLE:
2716 default: /* eLIM_UNKNOWN_ROLE */
2717 lim_log(pMac, LOGE,
2718 FL("received unexpected SME_DISASSOC_CNF role %d"),
2719 GET_LIM_SYSTEM_ROLE(psessionEntry));
2720
2721 return;
2722 }
2723
2724 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2725 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2726 LIM_IS_AP_ROLE(psessionEntry)) {
2727 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002728 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002729 &psessionEntry->dph.dphHashTable);
2730 if (pStaDs == NULL) {
2731 lim_log(pMac, LOGE,
2732 FL("DISASSOC_CNF for a STA with no context, addr= "
2733 MAC_ADDRESS_STR),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002734 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002735 return;
2736 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302737
2738 if ((pStaDs->mlmStaContext.mlmState ==
2739 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2740 (pStaDs->mlmStaContext.mlmState ==
2741 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
2742 lim_log(pMac, LOGE,
2743 FL("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d"),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002744 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302745 pStaDs->mlmStaContext.mlmState);
2746 return;
2747 }
2748
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002749 /* Delete FT session if there exists one */
2750 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002751 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2752
2753 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002754 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002755 }
2756
2757 return;
2758}
2759
2760/**
2761 * __lim_process_sme_deauth_req() - process sme deauth req
2762 * @mac_ctx: Pointer to Global MAC structure
2763 * @msg_buf: pointer to the SME message buffer
2764 *
2765 * This function is called to process SME_DEAUTH_REQ message
2766 * from HDD or upper layer application.
2767 *
2768 * Return: None
2769 */
2770
2771static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2772 uint32_t *msg_buf)
2773{
2774 uint16_t deauth_trigger, reason_code;
2775 tLimMlmDeauthReq *mlm_deauth_req;
2776 tSirSmeDeauthReq sme_deauth_req;
2777 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2778 tpPESession session_entry;
2779 uint8_t session_id; /* PE sessionId */
2780 uint8_t sme_session_id;
2781 uint16_t sme_transaction_id;
2782
2783 lim_log(mac_ctx, LOG1, FL("received DEAUTH_REQ message"));
2784
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302785 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002786 sme_session_id = sme_deauth_req.sessionId;
2787 sme_transaction_id = sme_deauth_req.transactionId;
2788
2789 /*
2790 * We need to get a session first but we don't even know
2791 * if the message is correct.
2792 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002793 session_entry = pe_find_session_by_bssid(mac_ctx,
2794 sme_deauth_req.bssid.bytes,
2795 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002796 if (session_entry == NULL) {
2797 lim_log(mac_ctx, LOGE,
2798 FL("session does not exist for given bssId"));
2799 ret_code = eSIR_SME_INVALID_PARAMETERS;
2800 deauth_trigger = eLIM_HOST_DEAUTH;
2801 goto send_deauth;
2802 }
2803
2804 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2805 session_entry)) {
2806 lim_log(mac_ctx, LOGE,
2807 FL("received invalid SME_DEAUTH_REQ message"));
2808 mac_ctx->lim.gLimRspReqd = false;
2809
2810 ret_code = eSIR_SME_INVALID_PARAMETERS;
2811 deauth_trigger = eLIM_HOST_DEAUTH;
2812 goto send_deauth;
2813 }
2814 lim_log(mac_ctx, LOG1,
2815 FL("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2816 MAC_ADDRESS_STR), sme_session_id,
2817 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2818 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002819 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002820#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2821 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2822 session_entry, 0, sme_deauth_req.reasonCode);
2823#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2824
2825 /* Update SME session ID and Transaction ID */
2826 session_entry->smeSessionId = sme_session_id;
2827 session_entry->transactionId = sme_transaction_id;
2828
2829 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2830 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002831 switch (session_entry->limSmeState) {
2832 case eLIM_SME_ASSOCIATED_STATE:
2833 case eLIM_SME_LINK_EST_STATE:
2834 case eLIM_SME_WT_ASSOC_STATE:
2835 case eLIM_SME_JOIN_FAILURE_STATE:
2836 case eLIM_SME_IDLE_STATE:
2837 session_entry->limPrevSmeState =
2838 session_entry->limSmeState;
2839 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2840 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2841 session_entry->peSessionId,
2842 session_entry->limSmeState));
2843 /* Send Deauthentication request to MLM below */
2844 break;
2845 case eLIM_SME_WT_DEAUTH_STATE:
2846 case eLIM_SME_WT_DISASSOC_STATE:
2847 /*
2848 * PE Recieved a Deauth/Disassoc frame. Normally it get
2849 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2850 * Which means host is also trying to disconnect.
2851 * PE can continue processing DEAUTH_REQ and send
2852 * the response instead of failing the request.
2853 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2854 * was sent for deauth/disassoc frame.
2855 */
2856 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2857 lim_log(mac_ctx, LOG1, FL(
2858 "Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE"));
2859 break;
2860 default:
2861 /*
2862 * STA is not in a state to deauthenticate with
2863 * peer. Log error and send response to host.
2864 */
2865 lim_log(mac_ctx, LOGE, FL(
2866 "received unexp SME_DEAUTH_REQ in state %X"),
2867 session_entry->limSmeState);
2868 lim_print_sme_state(mac_ctx, LOGE,
2869 session_entry->limSmeState);
2870
2871 if (mac_ctx->lim.gLimRspReqd) {
2872 mac_ctx->lim.gLimRspReqd = false;
2873
2874 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2875 deauth_trigger = eLIM_HOST_DEAUTH;
2876
2877 /*
2878 * here we received deauth request from AP so sme state
2879 * is eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED
2880 * delSta then mlm state should be
2881 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got delBSS
2882 * rsp then mlm state should be eLIM_MLM_IDLE_STATE
2883 * so the below condition captures the state where
2884 * delSta not done and firmware still in
2885 * connected state.
2886 */
2887 if (session_entry->limSmeState ==
2888 eLIM_SME_WT_DEAUTH_STATE &&
2889 session_entry->limMlmState !=
2890 eLIM_MLM_IDLE_STATE &&
2891 session_entry->limMlmState !=
2892 eLIM_MLM_WT_DEL_STA_RSP_STATE)
2893 ret_code = eSIR_SME_DEAUTH_STATUS;
2894 goto send_deauth;
2895 }
2896 return;
2897 }
2898 break;
2899
2900 case eLIM_STA_IN_IBSS_ROLE:
2901 lim_log(mac_ctx, LOGE, FL("Deauth not allowed in IBSS"));
2902 if (mac_ctx->lim.gLimRspReqd) {
2903 mac_ctx->lim.gLimRspReqd = false;
2904 ret_code = eSIR_SME_INVALID_PARAMETERS;
2905 deauth_trigger = eLIM_HOST_DEAUTH;
2906 goto send_deauth;
2907 }
2908 return;
2909 case eLIM_AP_ROLE:
2910 break;
2911 default:
2912 lim_log(mac_ctx, LOGE,
2913 FL("received unexpected SME_DEAUTH_REQ for role %X"),
2914 GET_LIM_SYSTEM_ROLE(session_entry));
2915 if (mac_ctx->lim.gLimRspReqd) {
2916 mac_ctx->lim.gLimRspReqd = false;
2917 ret_code = eSIR_SME_INVALID_PARAMETERS;
2918 deauth_trigger = eLIM_HOST_DEAUTH;
2919 goto send_deauth;
2920 }
2921 return;
2922 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2923
2924 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2925 /* Deauthentication is triggered by Link Monitoring */
2926 lim_log(mac_ctx, LOG1, FL("** Lost link with AP **"));
2927 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2928 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2929 } else {
2930 deauth_trigger = eLIM_HOST_DEAUTH;
2931 reason_code = sme_deauth_req.reasonCode;
2932 }
2933
2934 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302935 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002936 if (NULL == mlm_deauth_req) {
2937 lim_log(mac_ctx, LOGP,
2938 FL("call to AllocateMemory failed for mlmDeauthReq"));
2939 if (mac_ctx->lim.gLimRspReqd) {
2940 mac_ctx->lim.gLimRspReqd = false;
2941 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2942 deauth_trigger = eLIM_HOST_DEAUTH;
2943 goto send_deauth;
2944 }
2945 return;
2946 }
2947
Anurag Chouhanc5548422016-02-24 18:33:27 +05302948 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002949 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002950
2951 mlm_deauth_req->reasonCode = reason_code;
2952 mlm_deauth_req->deauthTrigger = deauth_trigger;
2953
2954 /* Update PE session Id */
2955 mlm_deauth_req->sessionId = session_id;
2956
2957 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2958 (uint32_t *)mlm_deauth_req);
2959 return;
2960
2961send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002962 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2963 ret_code, deauth_trigger, 1,
2964 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002965}
2966
2967/**
2968 * __lim_process_sme_set_context_req()
2969 *
2970 * @mac_ctx: Pointer to Global MAC structure
2971 * @msg_buf: pointer to the SME message buffer
2972 *
2973 * This function is called to process SME_SETCONTEXT_REQ message
2974 * from HDD or upper layer application.
2975 *
2976 * Return: None
2977 */
2978
2979static void
2980__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2981{
2982 tpSirSmeSetContextReq set_context_req;
2983 tLimMlmSetKeysReq *mlm_set_key_req;
2984 tpPESession session_entry;
2985 uint8_t session_id; /* PE sessionID */
2986 uint8_t sme_session_id;
2987 uint16_t sme_transaction_id;
2988
2989 lim_log(mac_ctx, LOG1, FL("received SETCONTEXT_REQ message"));
2990
2991 if (msg_buf == NULL) {
2992 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
2993 return;
2994 }
2995
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302996 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002997 if (NULL == set_context_req) {
2998 lim_log(mac_ctx, LOGP, FL(
2999 "call to AllocateMemory failed for set_context_req"));
3000 return;
3001 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303002 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003003 sizeof(struct sSirSmeSetContextReq));
3004 sme_session_id = set_context_req->sessionId;
3005 sme_transaction_id = set_context_req->transactionId;
3006
3007 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
3008 lim_log(mac_ctx, LOGW,
3009 FL("received invalid SME_SETCONTEXT_REQ message"));
3010 goto end;
3011 }
3012
3013 if (set_context_req->keyMaterial.numKeys >
3014 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3015 lim_log(mac_ctx, LOGE, FL(
3016 "numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS"),
3017 set_context_req->keyMaterial.numKeys);
3018 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003019 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003020 eSIR_SME_INVALID_PARAMETERS, NULL,
3021 sme_session_id, sme_transaction_id);
3022 goto end;
3023 }
3024
3025 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003026 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003027 if (session_entry == NULL) {
3028 lim_log(mac_ctx, LOGW,
3029 FL("Session does not exist for given BSSID"));
3030 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003031 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003032 eSIR_SME_INVALID_PARAMETERS, NULL,
3033 sme_session_id, sme_transaction_id);
3034 goto end;
3035 }
3036#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3037 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
3038 session_entry, 0, 0);
3039#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3040
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003041 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003042 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3043 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003044 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003045 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
3046 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303047 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003048 if (NULL == mlm_set_key_req) {
3049 lim_log(mac_ctx, LOGP, FL(
3050 "mem alloc failed for mlmSetKeysReq"));
3051 goto end;
3052 }
3053 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
3054 mlm_set_key_req->numKeys =
3055 set_context_req->keyMaterial.numKeys;
3056 if (mlm_set_key_req->numKeys >
3057 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3058 lim_log(mac_ctx, LOGP, FL(
3059 "no.of keys exceeded max num of default keys limit"));
3060 goto end;
3061 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05303062 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003063 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003064
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303065 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003066 (uint8_t *) &set_context_req->keyMaterial.key,
3067 sizeof(tSirKeys) *
3068 (mlm_set_key_req->numKeys ? mlm_set_key_req->
3069 numKeys : 1));
3070
3071 mlm_set_key_req->sessionId = session_id;
3072 mlm_set_key_req->smesessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003073 lim_log(mac_ctx, LOG1, FL(
3074 "received SETCONTEXT_REQ message sessionId=%d"),
3075 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003076
3077 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
3078 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
3079 LIM_IS_AP_ROLE(session_entry)) {
3080 if (set_context_req->keyMaterial.key[0].keyLength) {
3081 uint8_t key_id;
3082 key_id =
3083 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303084 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003085 &session_entry->WEPKeyMaterial[key_id],
3086 (uint8_t *) &set_context_req->keyMaterial,
3087 sizeof(tSirKeyMaterial));
3088 } else {
3089 uint32_t i;
3090 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
3091 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303092 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003093 &mlm_set_key_req->key[i],
3094 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
3095 sizeof(tSirKeys));
3096 }
3097 }
3098 }
3099 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
3100 (uint32_t *) mlm_set_key_req);
3101 } else {
3102 lim_log(mac_ctx, LOGE, FL(
3103 "rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
3104 GET_LIM_SYSTEM_ROLE(session_entry),
3105 session_entry->limSmeState);
3106 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
3107
3108 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003109 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003110 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
3111 session_entry, sme_session_id,
3112 sme_transaction_id);
3113 }
3114end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303115 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003116 return;
3117}
3118
3119/**
3120 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
3121 *
3122 * @mac_ctx: Pointer to Global MAC structure
3123 * @msg_buf: pointer to the SME message buffer
3124 *
3125 * This function is called to process SME_GET_ASSOC_STAS_REQ message
3126 * from HDD or upper layer application.
3127 *
3128 * Return: None
3129 */
3130
3131void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
3132 uint32_t *msg_buf)
3133{
3134 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3135 tpDphHashNode sta_ds = NULL;
3136 tpPESession session_entry = NULL;
3137 tSap_Event sap_event;
3138 tpWLAN_SAPEventCB sap_event_cb = NULL;
3139 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3140 uint8_t session_id = CSR_SESSION_ID_INVALID;
3141 uint8_t assoc_id = 0;
3142 uint8_t sta_cnt = 0;
3143
3144 if (msg_buf == NULL) {
3145 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3146 return;
3147 }
3148
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303149 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003150 sizeof(struct sSirSmeGetAssocSTAsReq));
3151 /*
3152 * Get Associated stations from PE.
3153 * Find PE session Entry
3154 */
3155 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003156 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003157 &session_id);
3158 if (session_entry == NULL) {
3159 lim_log(mac_ctx, LOGE,
3160 FL("session does not exist for given bssId"));
3161 goto lim_assoc_sta_end;
3162 }
3163
3164 if (!LIM_IS_AP_ROLE(session_entry)) {
3165 lim_log(mac_ctx, LOGE, FL(
3166 "Received unexpected message in state %X, in role %X"),
3167 session_entry->limSmeState,
3168 GET_LIM_SYSTEM_ROLE(session_entry));
3169 goto lim_assoc_sta_end;
3170 }
3171 /* Retrieve values obtained in the request message */
3172 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3173 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3174
3175 if (NULL == assoc_sta_tmp)
3176 goto lim_assoc_sta_end;
3177 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3178 assoc_id++) {
3179 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3180 &session_entry->dph.dphHashTable);
3181 if (NULL == sta_ds)
3182 continue;
3183 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303184 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003185 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303186 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003187 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3188 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3189
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303190 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003191 (uint8_t *)&sta_ds->supportedRates,
3192 sizeof(tSirSupportedRates));
3193 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3194 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3195 assoc_sta_tmp->Support40Mhz =
3196 sta_ds->htDsssCckRate40MHzSupport;
3197
3198 lim_log(mac_ctx, LOG1, FL("dph Station Number = %d"),
3199 sta_cnt + 1);
3200 lim_log(mac_ctx, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3201 MAC_ADDR_ARRAY(sta_ds->staAddr));
3202 lim_log(mac_ctx, LOG1, FL("Association Id = %d"),
3203 sta_ds->assocId);
3204 lim_log(mac_ctx, LOG1, FL("Station Index = %d"),
3205 sta_ds->staIndex);
3206 assoc_sta_tmp++;
3207 sta_cnt++;
3208 }
3209 }
3210lim_assoc_sta_end:
3211 /*
3212 * Call hdd callback with sap event to send the list of
3213 * associated stations from PE
3214 */
3215 if (sap_event_cb != NULL) {
3216 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3217 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303218 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003219 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3220 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3221 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3222 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3223 }
3224}
3225
3226/**
3227 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3228 *
3229 * @mac_ctx: Pointer to Global MAC structure
3230 * @msg_buf: pointer to WPS PBC overlap query message
3231 *
3232 * This function parses get WPS PBC overlap information
3233 * message and call callback to pass WPS PBC overlap
3234 * information back to hdd.
3235 *
3236 * Return: None
3237 */
3238void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3239 uint32_t *msg_buf)
3240{
3241 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3242 tpPESession session_entry = NULL;
3243 tSap_Event sap_event;
3244 tpWLAN_SAPEventCB sap_event_cb = NULL;
3245 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003246 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3247
3248 if (msg_buf == NULL) {
3249 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3250 return;
3251 }
3252
3253 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303254 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003255
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303256 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003257 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3258 /*
3259 * Get Associated stations from PE
3260 * Find PE session Entry
3261 */
3262 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003263 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003264 if (session_entry == NULL) {
3265 lim_log(mac_ctx, LOGE,
3266 FL("session does not exist for given bssId"));
3267 goto lim_get_wpspbc_sessions_end;
3268 }
3269
3270 if (!LIM_IS_AP_ROLE(session_entry)) {
3271 lim_log(mac_ctx, LOGE,
3272 FL("Received unexpected message in role %X"),
3273 GET_LIM_SYSTEM_ROLE(session_entry));
3274 goto lim_get_wpspbc_sessions_end;
3275 }
3276 /*
3277 * Call hdd callback with sap event to send the
3278 * WPS PBC overlap information
3279 */
3280 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303281 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003282
Anurag Chouhanc5548422016-02-24 18:33:27 +05303283 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003284 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003285 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003286 sap_get_wpspbc_event->UUID_E,
3287 &sap_get_wpspbc_event->wpsPBCOverlap,
3288 session_entry);
3289 } else {
3290 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003291 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003292 session_entry);
3293 /* don't have to inform the HDD/Host */
3294 return;
3295 }
3296
3297 lim_log(mac_ctx, LOGE, FL("wpsPBCOverlap %d"),
3298 sap_get_wpspbc_event->wpsPBCOverlap);
3299 lim_print_mac_addr(mac_ctx,
3300 sap_get_wpspbc_event->addr.bytes, LOG4);
3301
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303302 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003303
3304lim_get_wpspbc_sessions_end:
3305 sap_event_cb =
3306 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3307 if (NULL != sap_event_cb)
3308 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3309}
3310
3311/**
3312 * __lim_counter_measures()
3313 *
3314 * FUNCTION:
3315 * This function is called to "implement" MIC counter measure
3316 * and is *temporary* only
3317 *
3318 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3319 * we don't do the proper STA disassoc sequence since the
3320 * BSS will be stoped anyway
3321 *
3322 ***ASSUMPTIONS:
3323 *
3324 ***NOTE:
3325 *
3326 * @param pMac Pointer to Global MAC structure
3327 * @return None
3328 */
3329
3330static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3331{
3332 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003333 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003334 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3335 mac, psessionEntry, false);
3336};
3337
3338void lim_process_tkip_counter_measures(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3339{
3340 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3341 tpPESession psessionEntry;
3342 uint8_t sessionId; /* PE sessionId */
3343
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303344 qdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003345 sizeof(struct sSirSmeTkipCntrMeasReq));
3346
3347 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003348 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003349 if (NULL == psessionEntry) {
3350 lim_log(pMac, LOGE,
3351 FL("session does not exist for given BSSID "));
3352 return;
3353 }
3354
3355 if (tkipCntrMeasReq.bEnable)
3356 __lim_counter_measures(pMac, psessionEntry);
3357
3358 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3359}
3360
3361static void
3362__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3363{
3364 tSirSmeStopBssReq stopBssReq;
3365 tSirRetStatus status;
3366 tLimSmeStates prevState;
3367 tpPESession psessionEntry;
3368 uint8_t smesessionId;
3369 uint8_t sessionId;
3370 uint16_t smetransactionId;
3371 uint8_t i = 0;
3372 tpDphHashNode pStaDs = NULL;
3373
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303374 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003375 smesessionId = stopBssReq.sessionId;
3376 smetransactionId = stopBssReq.transactionId;
3377
3378 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
3379 PELOGW(lim_log(pMac, LOGW,
3380 FL("received invalid SME_STOP_BSS_REQ message"));)
3381 /* Send Stop BSS response to host */
3382 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3383 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3384 smetransactionId);
3385 return;
3386 }
3387
3388 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003389 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003390 &sessionId);
3391 if (psessionEntry == NULL) {
3392 lim_log(pMac, LOGW,
3393 FL("session does not exist for given BSSID "));
3394 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3395 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3396 smetransactionId);
3397 return;
3398 }
3399#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3400 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3401 0, 0);
3402#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3403
3404 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3405 LIM_IS_STA_ROLE(psessionEntry)) {
3406 /**
3407 * Should not have received STOP_BSS_REQ in states
3408 * other than 'normal' state or on STA in Infrastructure
3409 * mode. Log error and return response to host.
3410 */
3411 lim_log(pMac, LOGE,
3412 FL
3413 ("received unexpected SME_STOP_BSS_REQ in state %X, for role %d"),
3414 psessionEntry->limSmeState,
3415 GET_LIM_SYSTEM_ROLE(psessionEntry));
3416 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3417 /* / Send Stop BSS response to host */
3418 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3419 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3420 smetransactionId);
3421 return;
3422 }
3423
3424 if (LIM_IS_AP_ROLE(psessionEntry))
3425 lim_wpspbc_close(pMac, psessionEntry);
3426
3427 lim_log(pMac, LOGW,
3428 FL("RECEIVED STOP_BSS_REQ with reason code=%d"),
3429 stopBssReq.reasonCode);
3430
3431 prevState = psessionEntry->limSmeState;
3432
3433 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3434 MTRACE(mac_trace
3435 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3436 psessionEntry->limSmeState));
3437
3438 /* Update SME session Id and Transaction Id */
3439 psessionEntry->smeSessionId = smesessionId;
3440 psessionEntry->transactionId = smetransactionId;
3441
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003442 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3443 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3444 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003445 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3446 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3447 /* Send disassoc all stations associated thru TKIP */
3448 __lim_counter_measures(pMac, psessionEntry);
3449 else
3450 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003451 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3452 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003453 }
3454
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003455 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3456 /* Free the buffer allocated in START_BSS_REQ */
3457 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3458 psessionEntry->addIeParams.probeRespDataLen = 0;
3459 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003460
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003461 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3462 psessionEntry->addIeParams.assocRespDataLen = 0;
3463 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003464
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003465 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3466 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3467 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003468
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003469 /*
3470 * lim_del_bss is also called as part of coalescing,
3471 * when we send DEL BSS followed by Add Bss msg.
3472 */
3473 pMac->lim.gLimIbssCoalescingHappened = false;
3474 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003475 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3476 pStaDs =
3477 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3478 if (NULL == pStaDs)
3479 continue;
3480 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3481 if (eSIR_SUCCESS == status) {
3482 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3483 pStaDs->assocId, psessionEntry);
3484 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3485 } else {
3486 lim_log(pMac, LOGE,
3487 FL("lim_del_sta failed with Status : %d"), status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303488 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003489 }
3490 }
3491 /* send a delBss to HAL and wait for a response */
3492 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3493
3494 if (status != eSIR_SUCCESS) {
3495 PELOGE(lim_log
3496 (pMac, LOGE, FL("delBss failed for bss %d"),
3497 psessionEntry->bssIdx);
3498 )
3499 psessionEntry->limSmeState = prevState;
3500
3501 MTRACE(mac_trace
3502 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3503 psessionEntry->limSmeState));
3504
3505 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3506 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3507 smetransactionId);
3508 }
3509}
3510
3511/**
3512 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3513 * @pMac: Global MAC context
3514 * @pMsg: Message from SME
3515 *
3516 * Wrapper for the function __lim_handle_sme_stop_bss_request
3517 * This message will be defered until softmac come out of
3518 * scan mode. Message should be handled even if we have
3519 * detected radar in the current operating channel.
3520 *
3521 * Return: true - If we consumed the buffer
3522 * false - If have defered the message.
3523 */
3524
3525static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3526{
3527 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3528 /**
3529 * If message defered, buffer is not consumed yet.
3530 * So return false
3531 */
3532 return false;
3533 }
3534 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3535 return true;
3536} /*** end __lim_process_sme_stop_bss_req() ***/
3537
3538void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3539 uint32_t body, tpPESession psessionEntry)
3540{
3541
3542 (void)body;
3543 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3544 lim_ibss_delete(pMac, psessionEntry);
3545 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3546 lim_delete_pre_auth_list(pMac);
3547 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3548 psessionEntry->smeSessionId,
3549 psessionEntry->transactionId);
3550 return;
3551}
3552
3553/**
3554 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3555 *
3556 * @mac_ctx: pointer to mac context
3557 * @msg_type: message type
3558 * @msg_buf: pointer to the SME message buffer
3559 *
3560 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3561 * in BTAMP AP.
3562 *
3563 * Return: None
3564 */
3565
3566void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3567 uint32_t *msg_buf)
3568{
3569 tSirSmeAssocCnf assoc_cnf;
3570 tpDphHashNode sta_ds = NULL;
3571 tpPESession session_entry = NULL;
3572 uint8_t session_id;
3573 tpSirAssocReq assoc_req;
3574
3575 if (msg_buf == NULL) {
3576 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL "));
3577 goto end;
3578 }
3579
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303580 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003581 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
3582 lim_log(mac_ctx, LOGE,
3583 FL("Received invalid SME_RE(ASSOC)_CNF message "));
3584 goto end;
3585 }
3586
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003587 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003588 &session_id);
3589 if (session_entry == NULL) {
3590 lim_log(mac_ctx, LOGE,
3591 FL("session does not exist for given bssId"));
3592 goto end;
3593 }
3594
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003595 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003596 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3597 (session_entry->limSmeState !=
3598 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
3599 lim_log(mac_ctx, LOGE, FL(
3600 "Rcvd unexpected msg %X in state %X, in role %X"),
3601 msg_type, session_entry->limSmeState,
3602 GET_LIM_SYSTEM_ROLE(session_entry));
3603 goto end;
3604 }
3605 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3606 &session_entry->dph.dphHashTable);
3607 if (sta_ds == NULL) {
3608 lim_log(mac_ctx, LOGE, FL(
3609 "Rcvd invalid msg %X due to no STA ctx, aid %d, peer "),
3610 msg_type, assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003611 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003612
3613 /*
3614 * send a DISASSOC_IND message to WSM to make sure
3615 * the state in WSM and LIM is the same
3616 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003617 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003618 eSIR_SME_STA_NOT_ASSOCIATED,
3619 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3620 session_entry->smeSessionId,
3621 session_entry->transactionId,
3622 session_entry);
3623 goto end;
3624 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303625 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003626 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303627 QDF_MAC_ADDR_SIZE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003628 lim_log(mac_ctx, LOG1, FL(
3629 "peerMacAddr mismatched for aid %d, peer "),
3630 assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003631 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003632 goto end;
3633 }
3634
3635 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3636 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3637 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3638 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3639 (msg_type != eWNI_SME_ASSOC_CNF))) {
3640 lim_log(mac_ctx, LOG1, FL(
3641 "not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3642 "StaD mlmState : %d"),
3643 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003644 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003645 goto end;
3646 }
3647 /*
3648 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3649 * has been received
3650 */
3651 lim_log(mac_ctx, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
3652 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3653 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3654
3655 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3656 /*
3657 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3658 * when it had received Assoc Request frame. Now, PE just needs
3659 * to send association rsp frame to the requesting BTAMP-STA.
3660 */
3661 sta_ds->mlmStaContext.mlmState =
3662 eLIM_MLM_LINK_ESTABLISHED_STATE;
3663 lim_log(mac_ctx, LOG1,
3664 FL("sending Assoc Rsp frame to STA (assoc id=%d) "),
3665 sta_ds->assocId);
3666 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3667 sta_ds->assocId, sta_ds->staAddr,
3668 sta_ds->mlmStaContext.subType, sta_ds,
3669 session_entry);
3670 goto end;
3671 } else {
3672 /*
3673 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3674 * to be associated since the HAL sta entry is created for
3675 * denied STA we need to remove this HAL entry.
3676 * So to do that set updateContext to 1
3677 */
3678 if (!sta_ds->mlmStaContext.updateContext)
3679 sta_ds->mlmStaContext.updateContext = 1;
3680 lim_log(mac_ctx, LOG1,
3681 FL("Recv Assoc Cnf, status Code : %d(assoc id=%d) "),
3682 assoc_cnf.statusCode, sta_ds->assocId);
3683 lim_reject_association(mac_ctx, sta_ds->staAddr,
3684 sta_ds->mlmStaContext.subType,
3685 true, sta_ds->mlmStaContext.authType,
3686 sta_ds->assocId, true,
3687 eSIR_MAC_UNSPEC_FAILURE_STATUS,
3688 session_entry);
3689 }
3690end:
3691 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3692 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3693 assoc_req = (tpSirAssocReq)
3694 session_entry->parsedAssocReq[sta_ds->assocId];
3695 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303696 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003697 assoc_req->assocReqFrame = NULL;
3698 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303699 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003700 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3701 }
3702}
3703
3704static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3705{
3706 tpDphHashNode pStaDs;
3707 tSirMacAddr peerMac;
3708 tpSirAddtsReq pSirAddts;
3709 uint32_t timeout;
3710 tpPESession psessionEntry;
3711 uint8_t sessionId; /* PE sessionId */
3712 uint8_t smesessionId;
3713 uint16_t smetransactionId;
3714
3715 if (pMsgBuf == NULL) {
3716 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
3717 return;
3718 }
3719
3720 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3721 &smetransactionId);
3722
3723 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3724
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003725 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3726 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003727 if (psessionEntry == NULL) {
3728 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3729 return;
3730 }
3731#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3732 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3733 0);
3734#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3735
3736 /* if sta
3737 * - verify assoc state
3738 * - send addts request to ap
3739 * - wait for addts response from ap
3740 * if ap, just ignore with error log
3741 */
3742 PELOG1(lim_log(pMac, LOG1,
3743 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
3744 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3745 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
3746 )
3747
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003748 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003749 PELOGE(lim_log(pMac, LOGE, "AddTs received on AP - ignoring");)
3750 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3751 psessionEntry, pSirAddts->req.tspec,
3752 smesessionId, smetransactionId);
3753 return;
3754 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003755
3756 pStaDs =
3757 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3758 &psessionEntry->dph.dphHashTable);
3759
3760 if (pStaDs == NULL) {
3761 PELOGE(lim_log
3762 (pMac, LOGE, "Cannot find AP context for addts req");
3763 )
3764 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3765 psessionEntry, pSirAddts->req.tspec,
3766 smesessionId, smetransactionId);
3767 return;
3768 }
3769
3770 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3771 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
3772 lim_log(pMac, LOGE, "AddTs received in invalid MLM state");
3773 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3774 psessionEntry, pSirAddts->req.tspec,
3775 smesessionId, smetransactionId);
3776 return;
3777 }
3778
3779 pSirAddts->req.wsmTspecPresent = 0;
3780 pSirAddts->req.wmeTspecPresent = 0;
3781 pSirAddts->req.lleTspecPresent = 0;
3782
3783 if ((pStaDs->wsmEnabled) &&
3784 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3785 SIR_MAC_ACCESSPOLICY_EDCA))
3786 pSirAddts->req.wsmTspecPresent = 1;
3787 else if (pStaDs->wmeEnabled)
3788 pSirAddts->req.wmeTspecPresent = 1;
3789 else if (pStaDs->lleEnabled)
3790 pSirAddts->req.lleTspecPresent = 1;
3791 else {
3792 PELOGW(lim_log
3793 (pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));
3794 )
3795 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3796 psessionEntry, pSirAddts->req.tspec,
3797 smesessionId, smetransactionId);
3798 return;
3799 }
3800
3801 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3802 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
3803 lim_log(pMac, LOGE,
3804 "AddTs received in invalid LIMsme state (%d)",
3805 psessionEntry->limSmeState);
3806 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3807 psessionEntry, pSirAddts->req.tspec,
3808 smesessionId, smetransactionId);
3809 return;
3810 }
3811
3812 if (pMac->lim.gLimAddtsSent) {
3813 lim_log(pMac, LOGE,
3814 "Addts (token %d, tsid %d, up %d) is still pending",
3815 pMac->lim.gLimAddtsReq.req.dialogToken,
3816 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3817 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3818 userPrio);
3819 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3820 psessionEntry, pSirAddts->req.tspec,
3821 smesessionId, smetransactionId);
3822 return;
3823 }
3824
3825 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3826
3827 /* save the addts request */
3828 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303829 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003830 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3831
3832 /* ship out the message now */
3833 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3834 psessionEntry);
3835 PELOG1(lim_log(pMac, LOG1, "Sent ADDTS request");)
3836 /* start a timer to wait for the response */
3837 if (pSirAddts->timeout)
3838 timeout = pSirAddts->timeout;
3839 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3840 eSIR_SUCCESS) {
3841 lim_log(pMac, LOGP,
3842 FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
3843 WNI_CFG_ADDTS_RSP_TIMEOUT);
3844 return;
3845 }
3846
3847 timeout = SYS_MS_TO_TICKS(timeout);
3848 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3849 != TX_SUCCESS) {
3850 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3851 return;
3852 }
3853 pMac->lim.gLimAddtsRspTimerCount++;
3854 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3855 pMac->lim.gLimAddtsRspTimerCount) !=
3856 TX_SUCCESS) {
3857 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3858 return;
3859 }
3860 MTRACE(mac_trace
3861 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3862 eLIM_ADDTS_RSP_TIMER));
3863
3864 /* add the sessionId to the timer object */
3865 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3866 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3867 TX_SUCCESS) {
3868 lim_log(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
3869 return;
3870 }
3871 return;
3872}
3873
3874static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3875{
3876 tSirMacAddr peerMacAddr;
3877 uint8_t ac;
3878 tSirMacTSInfo *pTsinfo;
3879 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3880 tpDphHashNode pStaDs = NULL;
3881 tpPESession psessionEntry;
3882 uint8_t sessionId;
3883 uint32_t status = eSIR_SUCCESS;
3884 uint8_t smesessionId;
3885 uint16_t smetransactionId;
3886
3887 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3888 &smetransactionId);
3889
3890 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003891 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003892 &sessionId);
3893 if (psessionEntry == NULL) {
3894 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3895 status = eSIR_FAILURE;
3896 goto end;
3897 }
3898#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3899 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3900 0);
3901#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3902
3903 if (eSIR_SUCCESS !=
3904 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
3905 PELOGE(lim_log(pMac, LOGE, FL("lim_validate_delts_req failed"));)
3906 status = eSIR_FAILURE;
3907 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3908 smesessionId, smetransactionId);
3909 return;
3910 }
3911
3912 lim_log(pMac, LOG1,
3913 FL("Sent DELTS request to station with assocId = %d MacAddr = "
3914 MAC_ADDRESS_STR),
3915 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3916
3917 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3918 pDeltsReq->req.wmeTspecPresent,
3919 &pDeltsReq->req.tsinfo,
3920 &pDeltsReq->req.tspec, psessionEntry);
3921
3922 pTsinfo =
3923 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3924 tsinfo : &pDeltsReq->req.tsinfo;
3925
3926 /* We've successfully send DELTS frame to AP. Update the
3927 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3928 * is no longer trigger enabled or delivery enabled
3929 */
3930 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3931 pTsinfo, CLEAR_UAPSD_MASK);
3932
3933 /* We're deleting the TSPEC, so this particular AC is no longer
3934 * admitted. PE needs to downgrade the EDCA
3935 * parameters(for the AC for which TS is being deleted) to the
3936 * next best AC for which ACM is not enabled, and send the
3937 * updated values to HAL.
3938 */
3939 ac = upToAc(pTsinfo->traffic.userPrio);
3940
3941 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3942 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3943 ~(1 << ac);
3944 } else if (pTsinfo->traffic.direction ==
3945 SIR_MAC_DIRECTION_DNLINK) {
3946 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3947 ~(1 << ac);
3948 } else if (pTsinfo->traffic.direction ==
3949 SIR_MAC_DIRECTION_BIDIR) {
3950 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3951 ~(1 << ac);
3952 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3953 ~(1 << ac);
3954 }
3955
3956 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3957 psessionEntry);
3958
3959 pStaDs =
3960 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3961 &psessionEntry->dph.dphHashTable);
3962 if (pStaDs != NULL) {
3963 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3964 pStaDs->bssId);
3965 status = eSIR_SUCCESS;
3966 } else {
3967 lim_log(pMac, LOGE, FL("Self entry missing in Hash Table "));
3968 status = eSIR_FAILURE;
3969 }
3970#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003971 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003972#endif
3973
3974 /* send an sme response back */
3975end:
3976 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3977 smesessionId, smetransactionId);
3978}
3979
3980void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
3981{
3982 /* fetch the sessionEntry based on the sessionId */
3983 tpPESession psessionEntry;
3984 psessionEntry = pe_find_session_by_session_id(pMac,
3985 pMac->lim.limTimers.gLimAddtsRspTimer.
3986 sessionId);
3987 if (psessionEntry == NULL) {
3988 lim_log(pMac, LOGP,
3989 FL("Session Does not exist for given sessionID"));
3990 return;
3991 }
3992
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003993 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003994 lim_log(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)",
3995 GET_LIM_SYSTEM_ROLE(psessionEntry));
3996 pMac->lim.gLimAddtsSent = false;
3997 return;
3998 }
3999
4000 if (!pMac->lim.gLimAddtsSent) {
4001 lim_log(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");
4002 return;
4003 }
4004
4005 if (param != pMac->lim.gLimAddtsRspTimerCount) {
4006 lim_log(pMac, LOGE,
4007 FL("Invalid AddtsRsp Timer count %d (exp %d)"), param,
4008 pMac->lim.gLimAddtsRspTimerCount);
4009 return;
4010 }
4011 /* this a real response timeout */
4012 pMac->lim.gLimAddtsSent = false;
4013 pMac->lim.gLimAddtsRspTimerCount++;
4014
4015 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
4016 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
4017 psessionEntry->smeSessionId,
4018 psessionEntry->transactionId);
4019}
4020
4021/**
4022 * __lim_process_sme_get_statistics_request()
4023 *
4024 ***FUNCTION:
4025 *
4026 *
4027 ***NOTE:
4028 *
4029 * @param pMac Pointer to Global MAC structure
4030 * @param *pMsgBuf A pointer to the SME message buffer
4031 * @return None
4032 */
4033static void
4034__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4035{
4036 tpAniGetPEStatsReq pPEStatsReq;
4037 tSirMsgQ msgQ;
4038
4039 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4040
4041 msgQ.type = WMA_GET_STATISTICS_REQ;
4042
4043 msgQ.reserved = 0;
4044 msgQ.bodyptr = pMsgBuf;
4045 msgQ.bodyval = 0;
4046 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4047
4048 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304049 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004050 pMsgBuf = NULL;
4051 lim_log(pMac, LOGP, "Unable to forward request");
4052 return;
4053 }
4054
4055 return;
4056}
4057
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004058#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004059/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004060 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004061 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004062 * @pMac: Pointer to Global MAC structure
4063 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004064 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004065 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004066 */
4067static void
4068__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4069{
4070 tSirMsgQ msgQ;
4071
4072 msgQ.type = WMA_TSM_STATS_REQ;
4073 msgQ.reserved = 0;
4074 msgQ.bodyptr = pMsgBuf;
4075 msgQ.bodyval = 0;
4076 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4077
4078 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304079 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004080 pMsgBuf = NULL;
4081 lim_log(pMac, LOGP, "Unable to forward request");
4082 return;
4083 }
4084}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004085#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004086
4087static void
4088__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4089{
4090 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4091 tpPESession psessionEntry;
4092 uint8_t sessionId; /* PE sessionID */
4093
4094 PELOG1(lim_log(pMac, LOG1, FL("received UPDATE_APWPSIEs_REQ message")););
4095
4096 if (pMsgBuf == NULL) {
4097 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4098 return;
4099 }
4100
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304101 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004102 if (NULL == pUpdateAPWPSIEsReq) {
4103 lim_log(pMac, LOGP,
4104 FL
4105 ("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
4106 return;
4107 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304108 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004109 sizeof(struct sSirUpdateAPWPSIEsReq));
4110
4111 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08004112 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004113 &sessionId);
4114 if (psessionEntry == NULL) {
4115 lim_log(pMac, LOGW,
4116 FL("Session does not exist for given BSSID"));
4117 goto end;
4118 }
4119
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304120 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004121 sizeof(tSirAPWPSIEs));
4122
4123 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4124 lim_send_beacon_ind(pMac, psessionEntry);
4125
4126end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304127 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004128 return;
4129}
4130
4131void
4132lim_send_vdev_restart(tpAniSirGlobal pMac,
4133 tpPESession psessionEntry, uint8_t sessionId)
4134{
4135 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
4136 tSirMsgQ msgQ;
4137 tSirRetStatus retCode = eSIR_SUCCESS;
4138
4139 if (psessionEntry == NULL) {
4140 PELOGE(lim_log
4141 (pMac, LOGE, "%s:%d: Invalid parameters", __func__,
4142 __LINE__);
4143 )
4144 return;
4145 }
4146
4147 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304148 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004149 if (NULL == pHalHiddenSsidVdevRestart) {
4150 PELOGE(lim_log
4151 (pMac, LOGE, "%s:%d: Unable to allocate memory",
4152 __func__, __LINE__);
4153 )
4154 return;
4155 }
4156
4157 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4158 pHalHiddenSsidVdevRestart->sessionId = sessionId;
4159
4160 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4161 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4162 msgQ.bodyval = 0;
4163
4164 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4165 if (eSIR_SUCCESS != retCode) {
4166 PELOGE(lim_log
4167 (pMac, LOGE, "%s:%d: wma_post_ctrl_msg() failed", __func__,
4168 __LINE__);
4169 )
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304170 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004171 }
4172}
4173
4174static void __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4175{
4176 tpSirUpdateParams pUpdateParams;
4177 tpPESession psessionEntry;
4178
4179 PELOG1(lim_log(pMac, LOG1, FL("received HIDE_SSID message")););
4180
4181 if (pMsgBuf == NULL) {
4182 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4183 return;
4184 }
4185
4186 pUpdateParams = (tpSirUpdateParams) pMsgBuf;
4187
Naveen Rawat9e4872a2015-11-13 09:43:11 -08004188 psessionEntry = pe_find_session_by_sme_session_id(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004189 pUpdateParams->sessionId);
4190 if (psessionEntry == NULL) {
4191 lim_log(pMac, LOGW,
4192 "Session does not exist for given sessionId %d",
4193 pUpdateParams->sessionId);
4194 return;
4195 }
4196
4197 /* Update the session entry */
4198 psessionEntry->ssidHidden = pUpdateParams->ssidHidden;
4199
4200 /* Send vdev restart */
4201 lim_send_vdev_restart(pMac, psessionEntry, pUpdateParams->sessionId);
4202
4203 /* Update beacon */
4204 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4205 lim_send_beacon_ind(pMac, psessionEntry);
4206
4207 return;
4208} /*** end __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4209
4210static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4211{
4212 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4213 tpPESession psessionEntry;
4214 uint8_t sessionId; /* PE sessionID */
4215
4216 if (pMsgBuf == NULL) {
4217 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4218 return;
4219 }
4220
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304221 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004222 if (NULL == pUpdateAPWPARSNIEsReq) {
4223 lim_log(pMac, LOGP,
4224 FL
4225 ("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
4226 return;
4227 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304228 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004229 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4230
4231 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004232 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004233 &sessionId);
4234 if (psessionEntry == NULL) {
4235 lim_log(pMac, LOGW,
4236 FL("Session does not exist for given BSSID"));
4237 goto end;
4238 }
4239
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304240 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004241 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4242
4243 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4244 &psessionEntry->
4245 pLimStartBssReq->rsnIE,
4246 psessionEntry);
4247
4248 psessionEntry->pLimStartBssReq->privacy = 1;
4249 psessionEntry->privacy = 1;
4250
4251 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4252 lim_send_beacon_ind(pMac, psessionEntry);
4253
4254end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304255 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004256 return;
4257} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4258
4259/*
4260 Update the beacon Interval dynamically if beaconInterval is different in MCC
4261 */
4262static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4263{
4264 tpSirChangeBIParams pChangeBIParams;
4265 tpPESession psessionEntry;
4266 uint8_t sessionId = 0;
4267 tUpdateBeaconParams beaconParams;
4268
4269 PELOG1(lim_log(pMac, LOG1,
4270 FL("received Update Beacon Interval message"));
4271 );
4272
4273 if (pMsgBuf == NULL) {
4274 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4275 return;
4276 }
4277
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304278 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004279 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4280
4281 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004282 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004283 &sessionId);
4284 if (psessionEntry == NULL) {
4285 lim_log(pMac, LOGE,
4286 FL("Session does not exist for given BSSID"));
4287 return;
4288 }
4289
4290 /*Update sessionEntry Beacon Interval */
4291 if (psessionEntry->beaconParams.beaconInterval !=
4292 pChangeBIParams->beaconInterval) {
4293 psessionEntry->beaconParams.beaconInterval =
4294 pChangeBIParams->beaconInterval;
4295 }
4296
4297 /*Update sch beaconInterval */
4298 if (pMac->sch.schObject.gSchBeaconInterval !=
4299 pChangeBIParams->beaconInterval) {
4300 pMac->sch.schObject.gSchBeaconInterval =
4301 pChangeBIParams->beaconInterval;
4302
4303 PELOG1(lim_log(pMac, LOG1,
4304 FL
4305 ("LIM send update BeaconInterval Indication : %d"),
4306 pChangeBIParams->beaconInterval);
4307 );
4308
4309 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4310 /* Update beacon */
4311 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4312
4313 beaconParams.bssIdx = psessionEntry->bssIdx;
4314 /* Set change in beacon Interval */
4315 beaconParams.beaconInterval =
4316 pChangeBIParams->beaconInterval;
4317 beaconParams.paramChangeBitmap =
4318 PARAM_BCN_INTERVAL_CHANGED;
4319 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4320 }
4321 }
4322
4323 return;
4324} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4325
4326#ifdef QCA_HT_2040_COEX
4327static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4328 uint32_t *pMsgBuf)
4329{
4330 tpSirSetHT2040Mode pSetHT2040Mode;
4331 tpPESession psessionEntry;
4332 uint8_t sessionId = 0;
4333 cds_msg_t msg;
4334 tUpdateVHTOpMode *pHtOpMode = NULL;
4335 uint16_t staId = 0;
4336 tpDphHashNode pStaDs = NULL;
4337
4338 PELOG1(lim_log(pMac, LOG1, FL("received Set HT 20/40 mode message")););
4339 if (pMsgBuf == NULL) {
4340 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4341 return;
4342 }
4343
4344 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4345
4346 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004347 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004348 &sessionId);
4349 if (psessionEntry == NULL) {
4350 lim_log(pMac, LOG1,
4351 FL("Session does not exist for given BSSID "));
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004352 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004353 return;
4354 }
4355
4356 lim_log(pMac, LOG1, FL("Update session entry for cbMod=%d"),
4357 pSetHT2040Mode->cbMode);
4358 /*Update sessionEntry HT related fields */
4359 switch (pSetHT2040Mode->cbMode) {
4360 case PHY_SINGLE_CHANNEL_CENTERED:
4361 psessionEntry->htSecondaryChannelOffset =
4362 PHY_SINGLE_CHANNEL_CENTERED;
4363 psessionEntry->htRecommendedTxWidthSet = 0;
4364 if (pSetHT2040Mode->obssEnabled)
4365 psessionEntry->htSupportedChannelWidthSet
4366 = eHT_CHANNEL_WIDTH_40MHZ;
4367 else
4368 psessionEntry->htSupportedChannelWidthSet
4369 = eHT_CHANNEL_WIDTH_20MHZ;
4370 break;
4371 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4372 psessionEntry->htSecondaryChannelOffset =
4373 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4374 psessionEntry->htRecommendedTxWidthSet = 1;
4375 break;
4376 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4377 psessionEntry->htSecondaryChannelOffset =
4378 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4379 psessionEntry->htRecommendedTxWidthSet = 1;
4380 break;
4381 default:
4382 lim_log(pMac, LOGE, FL("Invalid cbMode"));
4383 return;
4384 }
4385
4386 /* Update beacon */
4387 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4388 lim_send_beacon_ind(pMac, psessionEntry);
4389
4390 /* update OP Mode for each associated peer */
4391 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4392 pStaDs = dph_get_hash_entry(pMac, staId,
4393 &psessionEntry->dph.dphHashTable);
4394 if (NULL == pStaDs)
4395 continue;
4396
4397 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304398 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004399 if (NULL == pHtOpMode) {
4400 lim_log(pMac, LOGE,
4401 FL
4402 ("%s: Not able to allocate memory for setting OP mode"),
4403 __func__);
4404 return;
4405 }
4406 pHtOpMode->opMode =
4407 (psessionEntry->htSecondaryChannelOffset ==
4408 PHY_SINGLE_CHANNEL_CENTERED) ?
4409 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4410 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304411 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004412 sizeof(tSirMacAddr));
4413 pHtOpMode->smesessionId = sessionId;
4414
4415 msg.type = WMA_UPDATE_OP_MODE;
4416 msg.reserved = 0;
4417 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304418 if (!QDF_IS_STATUS_SUCCESS
Anurag Chouhan6d760662016-02-20 16:05:43 +05304419 (cds_mq_post_message(QDF_MODULE_ID_WMA, &msg))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004420 lim_log(pMac, LOGE,
4421 FL
4422 ("%s: Not able to post WMA_UPDATE_OP_MODE message to WMA"),
4423 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304424 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004425 return;
4426 }
4427 lim_log(pMac, LOG1,
4428 FL
4429 ("%s: Notifed FW about OP mode: %d for staId=%d"),
4430 __func__, pHtOpMode->opMode, staId);
4431
4432 } else
4433 lim_log(pMac, LOG1,
4434 FL("%s: station %d does not support HT40\n"),
4435 __func__, staId);
4436 }
4437
4438 return;
4439}
4440#endif
4441
4442/* -------------------------------------------------------------------- */
4443/**
4444 * __lim_process_report_message
4445 *
4446 * FUNCTION: Processes the next received Radio Resource Management message
4447 *
4448 * LOGIC:
4449 *
4450 * ASSUMPTIONS:
4451 *
4452 * NOTE:
4453 *
4454 * @param None
4455 * @return None
4456 */
4457
4458void __lim_process_report_message(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4459{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004460 switch (pMsg->type) {
4461 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4462 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4463 break;
4464 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004465 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004466 break;
4467 default:
4468 lim_log(pMac, LOGE, FL("Invalid msg type:%d"), pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004469 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004470}
4471
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004472/* -------------------------------------------------------------------- */
4473/**
4474 * lim_send_set_max_tx_power_req
4475 *
4476 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4477 *
4478 * LOGIC:
4479 *
4480 * ASSUMPTIONS:
4481 *
4482 * NOTE:
4483 *
4484 * @param txPower txPower to be set.
4485 * @param pSessionEntry session entry.
4486 * @return None
4487 */
4488tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004489lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004490 tpPESession pSessionEntry)
4491{
4492 tpMaxTxPowerParams pMaxTxParams = NULL;
4493 tSirRetStatus retCode = eSIR_SUCCESS;
4494 tSirMsgQ msgQ;
4495
4496 if (pSessionEntry == NULL) {
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304497 lim_log(pMac, LOGE, FL("Inavalid parameters"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004498 return eSIR_FAILURE;
4499 }
4500
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304501 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004502 if (NULL == pMaxTxParams) {
4503 lim_log(pMac, LOGP,
4504 FL("Unable to allocate memory for pMaxTxParams "));
4505 return eSIR_MEM_ALLOC_FAILED;
4506
4507 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004508 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304509 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304510 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304511 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004512 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304513 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004514
4515 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4516 msgQ.bodyptr = pMaxTxParams;
4517 msgQ.bodyval = 0;
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304518 lim_log(pMac, LOG1, FL("Post WMA_SET_MAX_TX_POWER_REQ to WMA"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004519 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4520 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4521 if (eSIR_SUCCESS != retCode) {
4522 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304523 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004524 }
4525 return retCode;
4526}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004527
4528/**
4529 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4530 *
4531 * @mac_ctx: Pointer to Global MAC structure
4532 * @msg_buf: pointer to the SME message buffer
4533 *
4534 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4535 * from SME. It Register this information within PE.
4536 *
4537 * Return: None
4538 */
4539static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4540 uint32_t *msg_buf)
4541{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304542 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004543 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4544 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4545 struct mgmt_frm_reg_info *next = NULL;
4546 bool match = false;
4547
4548 lim_log(mac_ctx, LOG1, FL(
4549 "registerFrame %d, frameType %d, matchLen %d"),
4550 sme_req->registerFrame, sme_req->frameType,
4551 sme_req->matchLen);
4552 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304553 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304554 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4555 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304556 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004557
4558 while (lim_mgmt_regn != NULL) {
4559 if (lim_mgmt_regn->frameType != sme_req->frameType)
4560 goto skip_match;
4561 if (sme_req->matchLen) {
4562 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304563 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004564 sme_req->matchData,
4565 lim_mgmt_regn->matchLen))) {
4566 /* found match! */
4567 match = true;
4568 break;
4569 }
4570 } else {
4571 /* found match! */
4572 match = true;
4573 break;
4574 }
4575skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304576 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304577 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004578 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304579 (qdf_list_node_t *)lim_mgmt_regn,
4580 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304581 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004582 lim_mgmt_regn = next;
4583 next = NULL;
4584 }
4585 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304586 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304587 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004588 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304589 (qdf_list_node_t *)lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304590 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304591 qdf_mem_free(lim_mgmt_regn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004592 }
4593
4594 if (sme_req->registerFrame) {
4595 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304596 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004597 sme_req->matchLen);
4598 if (lim_mgmt_regn != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304599 qdf_mem_set((void *)lim_mgmt_regn,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004600 sizeof(struct mgmt_frm_reg_info) +
4601 sme_req->matchLen, 0);
4602 lim_mgmt_regn->frameType = sme_req->frameType;
4603 lim_mgmt_regn->matchLen = sme_req->matchLen;
4604 lim_mgmt_regn->sessionId = sme_req->sessionId;
4605 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304606 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004607 sme_req->matchData,
4608 sme_req->matchLen);
4609 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304610 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004611 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304612 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004613 gLimMgmtFrameRegistratinQueue,
4614 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304615 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004616 &mac_ctx->lim.lim_frame_register_lock);
4617 }
4618 }
4619 return;
4620}
4621
4622static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4623{
4624 lim_log(pMac, LOG1, FL("Dereg msgType %d"),
4625 pMac->lim.gDeferMsgTypeForNOA);
4626 pMac->lim.gDeferMsgTypeForNOA = 0;
4627 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4628 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304629 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004630 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4631 }
4632}
4633
4634/**
4635 * lim_process_regd_defd_sme_req_after_noa_start()
4636 *
4637 * mac_ctx: Pointer to Global MAC structure
4638 *
4639 * This function is called to process deferred sme req message
4640 * after noa start.
4641 *
4642 * Return: None
4643 */
4644void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4645{
4646 bool buf_consumed = true;
4647
4648 lim_log(mac_ctx, LOG1, FL("Process defd sme req %d"),
4649 mac_ctx->lim.gDeferMsgTypeForNOA);
4650
4651 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4652 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
4653 lim_log(mac_ctx, LOGW,
4654 FL("start rcvd from FW when no sme deferred msg pending. Do nothing. "));
4655 lim_log(mac_ctx, LOGW,
4656 FL("It may happen when NOA start ind and timeout happen at the same time"));
4657 return;
4658 }
4659 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4660 case eWNI_SME_SCAN_REQ:
4661 __lim_process_sme_scan_req(mac_ctx,
4662 mac_ctx->lim.gpDefdSmeMsgForNOA);
4663 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004664 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4665 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4666 mac_ctx->lim.gpDefdSmeMsgForNOA);
4667 /*
4668 * lim_process_remain_on_chnl_req doesnt want us to free
4669 * the buffer since it is freed in lim_remain_on_chn_rsp.
4670 * this change is to avoid "double free"
4671 */
4672 if (false == buf_consumed)
4673 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4674 break;
4675 case eWNI_SME_JOIN_REQ:
4676 __lim_process_sme_join_req(mac_ctx,
4677 mac_ctx->lim.gpDefdSmeMsgForNOA);
4678 break;
4679 default:
4680 lim_log(mac_ctx, LOGE, FL("Unknown deferred msg type %d"),
4681 mac_ctx->lim.gDeferMsgTypeForNOA);
4682 break;
4683 }
4684 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4685}
4686
4687static void
4688__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4689{
4690 tpSirResetAPCapsChange pResetCapsChange;
4691 tpPESession psessionEntry;
4692 uint8_t sessionId = 0;
4693 if (pMsgBuf == NULL) {
4694 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4695 return;
4696 }
4697
4698 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4699 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004700 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4701 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004702 if (psessionEntry == NULL) {
4703 lim_log(pMac, LOGE,
4704 FL("Session does not exist for given BSSID"));
4705 return;
4706 }
4707
4708 psessionEntry->limSentCapsChangeNtf = false;
4709 return;
4710}
4711
4712/**
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304713 * lim_register_p2p_ack_ind_cb() - Save the p2p ack indication callback.
4714 * @mac_ctx: Mac pointer
4715 * @msg_buf: Msg pointer containing the callback
4716 *
4717 * This function is used to save the p2p ack indication callback in PE.
4718 *
4719 * Return: None
4720 */
4721static void lim_register_p2p_ack_ind_cb(tpAniSirGlobal mac_ctx,
4722 uint32_t *msg_buf)
4723{
4724 struct sir_sme_p2p_ack_ind_cb_req *sme_req =
4725 (struct sir_sme_p2p_ack_ind_cb_req *)msg_buf;
4726
4727 if (NULL == msg_buf) {
4728 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4729 return;
4730 }
4731 if (sme_req->callback)
4732 mac_ctx->p2p_ack_ind_cb =
4733 sme_req->callback;
4734 else
4735 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4736}
4737
4738/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304739 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4740 * indication callback in PE.
4741 * @mac_ptr: Mac pointer
4742 * @msg_buf: Msg pointer containing the callback
4743 *
4744 * This function is used save the Management frame
4745 * indication callback in PE.
4746 *
4747 * Return: None
4748 */
4749static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4750 uint32_t *msg_buf)
4751{
4752 struct sir_sme_mgmt_frame_cb_req *sme_req =
4753 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4754
4755 if (NULL == msg_buf) {
4756 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4757 return;
4758 }
4759 if (sme_req->callback)
4760 mac_ctx->mgmt_frame_ind_cb =
4761 (sir_mgmt_frame_ind_callback)sme_req->callback;
4762 else
4763 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4764}
4765
4766/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304767 *__lim_process_send_disassoc_frame: function processes disassoc frame
4768 * @mac_ctx: pointer to mac context
4769 * @msg_buf: message buffer
4770 *
4771 * function processes disassoc request received from SME
4772 *
4773 * return: none
4774 */
4775static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4776 uint32_t *msg_buf)
4777{
4778 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4779 tSirRetStatus status;
4780 tpPESession session_entry = NULL;
4781 uint8_t sme_session_id;
4782 uint16_t sme_trans_id;
4783
4784 if (msg_buf == NULL) {
4785 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
4786 return;
4787 }
4788
4789 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4790 &sme_trans_id);
4791
4792 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4793 &sme_send_disassoc_frame_req,
4794 (uint8_t *)msg_buf);
4795
4796 if ((eSIR_FAILURE == status) ||
4797 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4798 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
4799 PELOGE(lim_log(mac_ctx, LOGE,
4800 FL("received invalid SME_DISASSOC_REQ message"));)
4801 return;
4802 }
4803
4804 session_entry = pe_find_session_by_sme_session_id(
4805 mac_ctx, sme_session_id);
4806 if (session_entry == NULL) {
4807 lim_log(mac_ctx, LOGE,
4808 FL("session does not exist for given bssId "MAC_ADDRESS_STR),
4809 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4810 return;
4811 }
4812
4813 lim_log(mac_ctx, LOG1,
4814 FL("msg_type->%d len->%d sess_id->%d trans_id->%d mac->"MAC_ADDRESS_STR" reason->%d wait_for_ack->%d"),
4815 sme_send_disassoc_frame_req.msg_type,
4816 sme_send_disassoc_frame_req.length,
4817 sme_send_disassoc_frame_req.session_id,
4818 sme_send_disassoc_frame_req.trans_id,
4819 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4820 sme_send_disassoc_frame_req.reason,
4821 sme_send_disassoc_frame_req.wait_for_ack);
4822
4823 lim_send_disassoc_mgmt_frame(mac_ctx,
4824 sme_send_disassoc_frame_req.reason,
4825 sme_send_disassoc_frame_req.peer_mac,
4826 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4827}
4828
4829/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004830 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4831 * @mac_ctx: Pointer to Global MAC structure
4832 * @pdev_id: pdev id to set the IE.
4833 * @nss: Nss values to prepare the HT IE.
4834 *
4835 * Prepares the HT IE with self capabilities for different
4836 * Nss values and sends the set HT IE req to FW.
4837 *
4838 * Return: None
4839 */
4840static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4841 uint8_t nss)
4842{
4843 struct set_ie_param *ie_params;
4844 tSirMsgQ msg;
4845 tSirRetStatus rc = eSIR_SUCCESS;
4846 uint8_t *p_ie = NULL;
4847 tHtCaps *p_ht_cap;
4848 int i;
4849
4850 for (i = nss; i > 0; i--) {
4851 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4852 if (NULL == ie_params) {
4853 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4854 return;
4855 }
4856 ie_params->nss = i;
4857 ie_params->pdev_id = pdev_id;
4858 ie_params->ie_type = DOT11_HT_IE;
4859 /* 2 for IE len and EID */
4860 ie_params->ie_len = 2 + sizeof(tHtCaps);
4861 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4862 if (NULL == ie_params->ie_ptr) {
4863 qdf_mem_free(ie_params);
4864 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4865 return;
4866 }
4867 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4868 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4869 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4870 ie_params->ie_len);
4871
4872 if (NSS_1x1_MODE == i) {
4873 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4874 ie_params->ie_len,
4875 DOT11F_EID_HTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004876 if (NULL == p_ie) {
4877 qdf_mem_free(ie_params->ie_ptr);
4878 qdf_mem_free(ie_params);
4879 lim_log(mac_ctx, LOGE,
4880 FL("failed to get IE ptr"));
4881 return;
4882 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004883 p_ht_cap = (tHtCaps *)&p_ie[2];
4884 p_ht_cap->supportedMCSSet[1] = 0;
4885 p_ht_cap->txSTBC = 0;
4886 }
4887
4888 msg.type = WMA_SET_PDEV_IE_REQ;
4889 msg.bodyptr = ie_params;
4890 msg.bodyval = 0;
4891
4892 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4893 if (rc != eSIR_SUCCESS) {
4894 lim_log(mac_ctx, LOGE,
4895 FL("wma_post_ctrl_msg() return failure"));
4896 qdf_mem_free(ie_params->ie_ptr);
4897 qdf_mem_free(ie_params);
4898 return;
4899 }
4900 }
4901}
4902
4903/**
4904 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4905 * @mac_ctx: Pointer to Global MAC structure
4906 * @pdev_id: pdev id to set the IE.
4907 * @nss: Nss values to prepare the VHT IE.
4908 *
4909 * Prepares the VHT IE with self capabilities for different
4910 * Nss values and sends the set VHT IE req to FW.
4911 *
4912 * Return: None
4913 */
4914static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4915 uint8_t nss)
4916{
4917 struct set_ie_param *ie_params;
4918 tSirMsgQ msg;
4919 tSirRetStatus rc = eSIR_SUCCESS;
4920 uint8_t *p_ie = NULL;
4921 tSirMacVHTCapabilityInfo *vht_cap;
4922 int i;
4923 tSirVhtMcsInfo *vht_mcs;
4924
4925 for (i = nss; i > 0; i--) {
4926 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4927 if (NULL == ie_params) {
4928 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4929 return;
4930 }
4931 ie_params->nss = i;
4932 ie_params->pdev_id = pdev_id;
4933 ie_params->ie_type = DOT11_VHT_IE;
4934 /* 2 for IE len and EID */
4935 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4936 sizeof(tSirVhtMcsInfo);
4937 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4938 if (NULL == ie_params->ie_ptr) {
4939 qdf_mem_free(ie_params);
4940 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4941 return;
4942 }
4943 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4944 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4945 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4946 ie_params->ie_len);
4947
4948 if (NSS_1x1_MODE == i) {
4949 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4950 ie_params->ie_len,
4951 DOT11F_EID_VHTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004952 if (NULL == p_ie) {
4953 qdf_mem_free(ie_params->ie_ptr);
4954 qdf_mem_free(ie_params);
4955 lim_log(mac_ctx, LOGE,
4956 FL("failed to get IE ptr"));
4957 return;
4958 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004959 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4960 vht_cap->txSTBC = 0;
4961 vht_mcs =
4962 (tSirVhtMcsInfo *)&p_ie[2 +
4963 sizeof(tSirMacVHTCapabilityInfo)];
4964 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4965 vht_mcs->rxHighest =
4966 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4967 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4968 vht_mcs->txHighest =
4969 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4970 }
4971 msg.type = WMA_SET_PDEV_IE_REQ;
4972 msg.bodyptr = ie_params;
4973 msg.bodyval = 0;
4974
4975 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4976 if (rc != eSIR_SUCCESS) {
4977 lim_log(mac_ctx, LOGE,
4978 FL("wma_post_ctrl_msg failure"));
4979 qdf_mem_free(ie_params->ie_ptr);
4980 qdf_mem_free(ie_params);
4981 return;
4982 }
4983 }
4984}
4985
4986/**
4987 * lim_process_set_pdev_IEs() - process the set pdev IE req
4988 * @mac_ctx: Pointer to Global MAC structure
4989 * @msg_buf: Pointer to the SME message buffer
4990 *
4991 * This function is called by limProcessMessageQueue(). This
4992 * function sets the PDEV IEs to the FW.
4993 *
4994 * Return: None
4995 */
4996static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4997{
4998 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4999
5000 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
5001
5002 if (NULL == ht_vht_cfg) {
5003 lim_log(mac_ctx, LOGE, FL("NULL ht_vht_cfg"));
5004 return;
5005 }
5006
5007 lim_log(mac_ctx, LOG1, FL("rcvd set pdev ht vht ie req with nss = %d"),
5008 ht_vht_cfg->nss);
5009 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
5010
5011 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
5012 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
5013 ht_vht_cfg->nss);
5014}
5015
5016/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305017 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
5018 *
5019 * access policy
5020 * @mac_ctx: pointer to mac context
5021 * @msg: message buffer
5022 *
5023 * function processes vendor IE and access policy from SME and updates PE
5024 *
5025 * session entry
5026 *
5027 * return: none
5028*/
5029static void lim_process_sme_update_access_policy_vendor_ie(
5030 tpAniSirGlobal mac_ctx,
5031 uint32_t *msg)
5032{
5033 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
5034 struct sPESession *pe_session_entry;
5035 uint8_t num_bytes;
5036
5037 if (!msg) {
5038 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5039 return;
5040 }
5041 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
5042 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
5043 update_vendor_ie->sme_session_id);
5044
5045 if (!pe_session_entry) {
5046 lim_log(mac_ctx, LOGE,
5047 FL("Session does not exist for given sme session id(%hu)"),
5048 update_vendor_ie->sme_session_id);
5049 return;
5050 }
5051 if (pe_session_entry->access_policy_vendor_ie)
5052 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
5053
5054 num_bytes = update_vendor_ie->ie[1] + 2;
5055 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
5056
5057 if (!pe_session_entry->access_policy_vendor_ie) {
5058 lim_log(mac_ctx, LOGE,
5059 FL("Failed to allocate memory for vendor ie"));
5060 return;
5061 }
5062 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
5063 &update_vendor_ie->ie[0], num_bytes);
5064
5065 pe_session_entry->access_policy = update_vendor_ie->access_policy;
5066}
5067
5068/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005069 * lim_process_sme_req_messages()
5070 *
5071 ***FUNCTION:
5072 * This function is called by limProcessMessageQueue(). This
5073 * function processes SME request messages from HDD or upper layer
5074 * application.
5075 *
5076 ***LOGIC:
5077 *
5078 ***ASSUMPTIONS:
5079 *
5080 ***NOTE:
5081 *
5082 * @param pMac Pointer to Global MAC structure
5083 * @param msgType Indicates the SME message type
5084 * @param *pMsgBuf A pointer to the SME message buffer
5085 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5086 * false - if pMsgBuf is not to be freed.
5087 */
5088
5089bool lim_process_sme_req_messages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
5090{
5091 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
5092 uint32_t *pMsgBuf = pMsg->bodyptr;
5093 tpSirSmeScanReq pScanReq;
5094 PELOG1(lim_log
5095 (pMac, LOG1,
5096 FL
5097 ("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)"),
5098 lim_msg_str(pMsg->type), pMsg->type,
5099 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
5100 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
5101 )
5102
5103 pScanReq = (tpSirSmeScanReq) pMsgBuf;
5104 /* If no insert NOA required then execute the code below */
5105
5106 switch (pMsg->type) {
5107 case eWNI_SME_SYS_READY_IND:
5108 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
5109 break;
5110
5111 case eWNI_SME_START_BSS_REQ:
5112 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
5113 break;
5114
5115 case eWNI_SME_SCAN_REQ:
5116 __lim_process_sme_scan_req(pMac, pMsgBuf);
5117 break;
5118
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005119 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5120 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
5121 break;
5122
5123 case eWNI_SME_UPDATE_NOA:
5124 __lim_process_sme_no_a_update(pMac, pMsgBuf);
5125 break;
5126 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
5127 __lim_process_clear_dfs_channel_list(pMac, pMsg);
5128 break;
5129 case eWNI_SME_JOIN_REQ:
5130 __lim_process_sme_join_req(pMac, pMsgBuf);
5131 break;
5132
5133 case eWNI_SME_REASSOC_REQ:
5134 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
5135 break;
5136
5137 case eWNI_SME_DISASSOC_REQ:
5138 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
5139 break;
5140
5141 case eWNI_SME_DISASSOC_CNF:
5142 case eWNI_SME_DEAUTH_CNF:
5143 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
5144 break;
5145
5146 case eWNI_SME_DEAUTH_REQ:
5147 __lim_process_sme_deauth_req(pMac, pMsgBuf);
5148 break;
5149
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05305150 case eWNI_SME_SEND_DISASSOC_FRAME:
5151 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
5152 break;
5153
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005154 case eWNI_SME_SETCONTEXT_REQ:
5155 __lim_process_sme_set_context_req(pMac, pMsgBuf);
5156 break;
5157
5158 case eWNI_SME_STOP_BSS_REQ:
5159 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
5160 break;
5161
5162 case eWNI_SME_ASSOC_CNF:
5163 if (pMsg->type == eWNI_SME_ASSOC_CNF)
5164 PELOG1(lim_log(pMac,
5165 LOG1, FL("Received ASSOC_CNF message"));)
5166 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
5167 pMsgBuf);
5168 break;
5169
5170 case eWNI_SME_ADDTS_REQ:
5171 PELOG1(lim_log(pMac, LOG1, FL("Received ADDTS_REQ message"));)
5172 __lim_process_sme_addts_req(pMac, pMsgBuf);
5173 break;
5174
5175 case eWNI_SME_DELTS_REQ:
5176 PELOG1(lim_log(pMac, LOG1, FL("Received DELTS_REQ message"));)
5177 __lim_process_sme_delts_req(pMac, pMsgBuf);
5178 break;
5179
5180 case SIR_LIM_ADDTS_RSP_TIMEOUT:
5181 PELOG1(lim_log
5182 (pMac, LOG1,
5183 FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
5184 )
5185 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
5186 break;
5187
5188 case eWNI_SME_GET_STATISTICS_REQ:
5189 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
5190 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
5191 bufConsumed = false;
5192 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005193#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005194 case eWNI_SME_GET_TSM_STATS_REQ:
5195 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
5196 bufConsumed = false;
5197 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005198#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005199 case eWNI_SME_GET_ASSOC_STAS_REQ:
5200 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
5201 break;
5202 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5203 lim_process_tkip_counter_measures(pMac, pMsgBuf);
5204 break;
5205
5206 case eWNI_SME_HIDE_SSID_REQ:
5207 __lim_process_sme_hide_ssid(pMac, pMsgBuf);
5208 break;
5209 case eWNI_SME_UPDATE_APWPSIE_REQ:
5210 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
5211 break;
5212 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5213 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
5214 break;
5215
5216 case eWNI_SME_SET_APWPARSNIEs_REQ:
5217 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
5218 break;
5219
5220 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5221 /* Update the beaconInterval */
5222 __lim_process_sme_change_bi(pMac, pMsgBuf);
5223 break;
5224
5225#ifdef QCA_HT_2040_COEX
5226 case eWNI_SME_SET_HT_2040_MODE:
5227 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
5228 break;
5229#endif
5230
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005231 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5232 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5233 __lim_process_report_message(pMac, pMsg);
5234 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005235
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005236 case eWNI_SME_FT_PRE_AUTH_REQ:
5237 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
5238 break;
5239 case eWNI_SME_FT_UPDATE_KEY:
5240 lim_process_ft_update_key(pMac, pMsgBuf);
5241 break;
5242
5243 case eWNI_SME_FT_AGGR_QOS_REQ:
5244 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
5245 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005246
5247 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5248 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
5249 break;
5250#ifdef FEATURE_WLAN_TDLS
5251 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5252 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
5253 break;
5254 case eWNI_SME_TDLS_ADD_STA_REQ:
5255 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
5256 break;
5257 case eWNI_SME_TDLS_DEL_STA_REQ:
5258 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
5259 break;
5260 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5261 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
5262 break;
5263#endif
5264 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5265 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
5266 break;
5267
5268 case eWNI_SME_CHANNEL_CHANGE_REQ:
5269 lim_process_sme_channel_change_request(pMac, pMsgBuf);
5270 break;
5271
5272 case eWNI_SME_START_BEACON_REQ:
5273 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
5274 break;
5275
5276 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
5277 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
5278 break;
5279
5280 case eWNI_SME_UPDATE_ADDITIONAL_IES:
5281 lim_process_update_add_ies(pMac, pMsgBuf);
5282 break;
5283
5284 case eWNI_SME_MODIFY_ADDITIONAL_IES:
5285 lim_process_modify_add_ies(pMac, pMsgBuf);
5286 break;
5287 case eWNI_SME_SET_HW_MODE_REQ:
5288 lim_process_set_hw_mode(pMac, pMsgBuf);
5289 break;
5290 case eWNI_SME_NSS_UPDATE_REQ:
5291 lim_process_nss_update_request(pMac, pMsgBuf);
5292 break;
5293 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5294 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5295 break;
5296 case eWNI_SME_SET_IE_REQ:
5297 lim_process_set_ie_req(pMac, pMsgBuf);
5298 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305299 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5300 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5301 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305302 case eWNI_SME_EXT_CHANGE_CHANNEL:
5303 lim_process_ext_change_channel(pMac, pMsgBuf);
5304 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005305 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5306 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5307 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005308 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5309 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawatf28315c2016-06-29 18:06:02 -07005310 case eWNI_SME_NDP_END_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005311 case eWNI_SME_NDP_INITIATOR_REQ:
Abhishek Singh4fef7472016-06-06 11:36:03 -07005312 case eWNI_SME_NDP_RESPONDER_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005313 lim_handle_ndp_request_message(pMac, pMsg);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005314 break;
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05305315 case eWNI_SME_REGISTER_P2P_ACK_CB:
5316 lim_register_p2p_ack_ind_cb(pMac, pMsgBuf);
5317 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305318 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5319 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5320 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005321 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305322 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005323 pMsg->bodyptr = NULL;
5324 break;
5325 } /* switch (msgType) */
5326
5327 return bufConsumed;
5328} /*** end lim_process_sme_req_messages() ***/
5329
5330/**
5331 * lim_process_sme_start_beacon_req()
5332 *
5333 ***FUNCTION:
5334 * This function is called by limProcessMessageQueue(). This
5335 * function processes SME request messages from HDD or upper layer
5336 * application.
5337 *
5338 ***LOGIC:
5339 *
5340 ***ASSUMPTIONS:
5341 *
5342 ***NOTE:
5343 *
5344 * @param pMac Pointer to Global MAC structure
5345 * @param msgType Indicates the SME message type
5346 * @param *pMsgBuf A pointer to the SME message buffer
5347 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5348 * false - if pMsgBuf is not to be freed.
5349 */
5350static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5351{
5352 tpSirStartBeaconIndication pBeaconStartInd;
5353 tpPESession psessionEntry;
5354 uint8_t sessionId; /* PE sessionID */
5355
5356 if (pMsg == NULL) {
5357 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
5358 return;
5359 }
5360
5361 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5362 psessionEntry = pe_find_session_by_bssid(pMac,
5363 pBeaconStartInd->bssid,
5364 &sessionId);
5365 if (psessionEntry == NULL) {
5366 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
5367 lim_log(pMac, LOGE,
5368 FL("Session does not exist for given bssId"));
5369 return;
5370 }
5371
5372 if (pBeaconStartInd->beaconStartStatus == true) {
5373 /*
5374 * Currently this Indication comes from SAP
5375 * to start Beacon Tx on a DFS channel
5376 * since beaconing has to be done on DFS
5377 * channel only after CAC WAIT is completed.
5378 * On a DFS Channel LIM does not start beacon
5379 * Tx right after the WMA_ADD_BSS_RSP.
5380 */
5381 lim_apply_configuration(pMac, psessionEntry);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305382 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005383 FL("Start Beacon with ssid %s Ch %d"),
5384 psessionEntry->ssId.ssId,
5385 psessionEntry->currentOperChannel);
5386 lim_send_beacon_ind(pMac, psessionEntry);
5387 } else {
5388 lim_log(pMac, LOGE, FL("Invalid Beacon Start Indication"));
5389 return;
5390 }
5391}
5392
5393/**
5394 * lim_process_sme_channel_change_request() - process sme ch change req
5395 *
5396 * @mac_ctx: Pointer to Global MAC structure
5397 * @msg_buf: pointer to the SME message buffer
5398 *
5399 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5400 *
5401 * Return: None
5402 */
5403static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5404 uint32_t *msg_buf)
5405{
5406 tpSirChanChangeRequest ch_change_req;
5407 tpPESession session_entry;
5408 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005409 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005410 uint32_t val = 0;
5411
5412 if (msg_buf == NULL) {
5413 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5414 return;
5415 }
5416 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5417
5418 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5419 ch_change_req->targetChannel);
5420
5421 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5422 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
5423 lim_log(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5424 return;
5425 }
5426
5427 session_entry = pe_find_session_by_bssid(mac_ctx,
5428 ch_change_req->bssid, &session_id);
5429 if (session_entry == NULL) {
5430 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
5431 lim_log(mac_ctx, LOGE, FL(
5432 "Session does not exist for given bssId"));
5433 return;
5434 }
5435
5436 if (session_entry->currentOperChannel ==
5437 ch_change_req->targetChannel) {
5438 lim_log(mac_ctx, LOGE, FL("target CH is same as current CH"));
5439 return;
5440 }
5441
5442 if (LIM_IS_AP_ROLE(session_entry))
5443 session_entry->channelChangeReasonCode =
5444 LIM_SWITCH_CHANNEL_SAP_DFS;
5445 else
5446 session_entry->channelChangeReasonCode =
5447 LIM_SWITCH_CHANNEL_OPERATION;
5448
5449 lim_log(mac_ctx, LOGW, FL(
5450 "switch old chnl %d to new chnl %d, ch_bw %d"),
5451 session_entry->currentOperChannel,
5452 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005453 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005454
5455 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005456 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005457 session_entry->ch_center_freq_seg0 =
5458 ch_change_req->center_freq_seg_0;
5459 session_entry->ch_center_freq_seg1 =
5460 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005461 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005462 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005463 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005464 session_entry->htRecommendedTxWidthSet =
5465 session_entry->htSupportedChannelWidthSet;
5466 session_entry->currentOperChannel =
5467 ch_change_req->targetChannel;
5468 session_entry->limRFBand =
5469 lim_get_rf_band(session_entry->currentOperChannel);
5470 /* Initialize 11h Enable Flag */
5471 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5472 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5473 eSIR_SUCCESS)
5474 lim_log(mac_ctx, LOGP,
5475 FL("Fail to get WNI_CFG_11H_ENABLED"));
5476 }
5477
5478 session_entry->lim11hEnable = val;
5479 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305480 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005481 &ch_change_req->operational_rateset,
5482 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305483 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005484 &ch_change_req->extended_rateset,
5485 sizeof(session_entry->extRateSet));
5486 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5487 session_entry->ch_center_freq_seg0,
5488 session_entry->ch_center_freq_seg1,
5489 session_entry->ch_width,
5490 max_tx_pwr, session_entry->peSessionId);
5491}
5492
5493/******************************************************************************
5494* lim_start_bss_update_add_ie_buffer()
5495*
5496***FUNCTION:
5497* This function checks the src buffer and its length and then malloc for
5498* dst buffer update the same
5499*
5500***LOGIC:
5501*
5502***ASSUMPTIONS:
5503*
5504***NOTE:
5505*
5506* @param pMac Pointer to Global MAC structure
5507* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5508* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5509* @param *pSrcData_buff A pointer of uint8_t src buffer
5510* @param srcDataLen src buffer length
5511******************************************************************************/
5512
5513static void
5514lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5515 uint8_t **pDstData_buff,
5516 uint16_t *pDstDataLen,
5517 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5518{
5519
5520 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5521 *pDstDataLen = srcDataLen;
5522
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305523 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005524
5525 if (NULL == *pDstData_buff) {
5526 lim_log(pMac, LOGE,
5527 FL("AllocateMemory failed for pDstData_buff"));
5528 return;
5529 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305530 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005531 } else {
5532 *pDstData_buff = NULL;
5533 *pDstDataLen = 0;
5534 }
5535}
5536
5537/******************************************************************************
5538* lim_update_add_ie_buffer()
5539*
5540***FUNCTION:
5541* This function checks the src buffer and length if src buffer length more
5542* than dst buffer length then free the dst buffer and malloc for the new src
5543* length, and update the dst buffer and length. But if dst buffer is bigger
5544* than src buffer length then it just update the dst buffer and length
5545*
5546***LOGIC:
5547*
5548***ASSUMPTIONS:
5549*
5550***NOTE:
5551*
5552* @param pMac Pointer to Global MAC structure
5553* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5554* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5555* @param *pSrcData_buff A pointer of uint8_t src buffer
5556* @param srcDataLen src buffer length
5557******************************************************************************/
5558
5559static void
5560lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5561 uint8_t **pDstData_buff,
5562 uint16_t *pDstDataLen,
5563 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5564{
5565
5566 if (NULL == pSrcData_buff) {
5567 lim_log(pMac, LOGE, FL("src buffer is null."));
5568 return;
5569 }
5570
5571 if (srcDataLen > *pDstDataLen) {
5572 *pDstDataLen = srcDataLen;
5573 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305574 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005575 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305576 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005577
5578 if (NULL == *pDstData_buff) {
5579 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5580 *pDstDataLen = 0;
5581 return;
5582 }
5583 }
5584
5585 /* copy the content of buffer into dst buffer
5586 */
5587 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305588 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005589
5590}
5591
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005592/**
5593 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5594 * @pMac : Pointer to Global MAC structure
5595 * @pDstData_buff : A pointer to pointer of dst buffer
5596 * @pDstDataLen : A pointer to pointer of dst buffer length
5597 * @pModifyIE : A pointer to tSirModifyIE
5598 *
5599 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5600 *
5601 * Return:
5602 * True or false depending upon whether IE is updated or not
5603 */
5604static bool
5605lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5606 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5607{
5608 int32_t oui_length;
5609 uint8_t *ibss_ie = NULL;
5610
5611 ibss_ie = pModifyIE->pIEBuffer;
5612 oui_length = pModifyIE->oui_length;
5613
5614 if ((0 == oui_length) || (NULL == ibss_ie)) {
5615 PELOGE(lim_log(pMac, LOGE,
5616 FL("Invalid set IBSS vendor IE command length %d "),
5617 oui_length);)
5618 return false;
5619 }
5620
5621 lim_update_add_ie_buffer(pMac,
5622 pDstData_buff,
5623 pDstDataLen,
5624 pModifyIE->pIEBuffer,
5625 pModifyIE->ieBufferlength);
5626
5627 return true;
5628}
5629
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005630/*
5631* lim_process_modify_add_ies() - process modify additional IE req.
5632*
5633* @mac_ctx: Pointer to Global MAC structure
5634* @msg_buf: pointer to the SME message buffer
5635*
5636* This function update the PE buffers for additional IEs.
5637*
5638* Return: None
5639*/
5640static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5641 uint32_t *msg_buf)
5642{
5643 tpSirModifyIEsInd modify_add_ies;
5644 tpPESession session_entry;
5645 uint8_t session_id;
5646 bool ret = false;
5647 tSirAddIeParams *add_ie_params;
5648
5649 if (msg_buf == NULL) {
5650 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5651 return;
5652 }
5653
5654 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5655 /* Incoming message has smeSession, use BSSID to find PE session */
5656 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005657 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005658
5659 if (NULL == session_entry) {
5660 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5661 MAC_ADDRESS_STR),
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005662 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005663 goto end;
5664 }
5665 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5666 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5667 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
5668 lim_log(mac_ctx, LOGE,
5669 FL("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d"),
5670 modify_add_ies->modifyIE.pIEBuffer,
5671 modify_add_ies->modifyIE.ieBufferlength,
5672 modify_add_ies->modifyIE.ieID,
5673 modify_add_ies->modifyIE.ieIDLen,
5674 modify_add_ies->updateType);
5675 goto end;
5676 }
5677 add_ie_params = &session_entry->addIeParams;
5678 switch (modify_add_ies->updateType) {
5679 case eUPDATE_IE_PROBE_RESP:
5680 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005681 if (LIM_IS_IBSS_ROLE(session_entry)) {
5682 lim_update_ibss_prop_add_ies(mac_ctx,
5683 &add_ie_params->probeRespData_buff,
5684 &add_ie_params->probeRespDataLen,
5685 &modify_add_ies->modifyIE);
5686 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005687 break;
5688 case eUPDATE_IE_ASSOC_RESP:
5689 /* assoc resp IE */
5690 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305691 QDF_TRACE(QDF_MODULE_ID_PE,
5692 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005693 "assoc resp add ie not present %d"),
5694 add_ie_params->assocRespDataLen);
5695 }
5696 /* search through the buffer and modify the IE */
5697 break;
5698 case eUPDATE_IE_PROBE_BCN:
5699 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005700 if (LIM_IS_IBSS_ROLE(session_entry)) {
5701 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5702 &add_ie_params->probeRespBCNData_buff,
5703 &add_ie_params->probeRespBCNDataLen,
5704 &modify_add_ies->modifyIE);
5705 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005706 if (ret == true && modify_add_ies->modifyIE.notify) {
5707 lim_handle_param_update(mac_ctx,
5708 modify_add_ies->updateType);
5709 }
5710 break;
5711 default:
5712 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d"),
5713 modify_add_ies->updateType);
5714 break;
5715 }
5716end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305717 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005718 modify_add_ies->modifyIE.pIEBuffer = NULL;
5719}
5720
5721/*
5722* lim_process_update_add_ies() - process additional IE update req
5723*
5724* @mac_ctx: Pointer to Global MAC structure
5725* @msg_buf: pointer to the SME message buffer
5726*
5727* This function update the PE buffers for additional IEs.
5728*
5729* Return: None
5730*/
5731static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5732 uint32_t *msg_buf)
5733{
5734 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5735 uint8_t session_id;
5736 tpPESession session_entry;
5737 tSirAddIeParams *addn_ie;
5738 uint16_t new_length = 0;
5739 uint8_t *new_ptr = NULL;
5740 tSirUpdateIE *update_ie;
5741
5742 if (msg_buf == NULL) {
5743 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5744 return;
5745 }
5746 update_ie = &update_add_ies->updateIE;
5747 /* incoming message has smeSession, use BSSID to find PE session */
5748 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005749 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005750
5751 if (NULL == session_entry) {
5752 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5753 MAC_ADDRESS_STR),
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005754 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005755 goto end;
5756 }
5757 addn_ie = &session_entry->addIeParams;
5758 /* if len is 0, upper layer requested freeing of buffer */
5759 if (0 == update_ie->ieBufferlength) {
5760 switch (update_add_ies->updateType) {
5761 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305762 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005763 addn_ie->probeRespData_buff = NULL;
5764 addn_ie->probeRespDataLen = 0;
5765 break;
5766 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305767 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005768 addn_ie->assocRespData_buff = NULL;
5769 addn_ie->assocRespDataLen = 0;
5770 break;
5771 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305772 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005773 addn_ie->probeRespBCNData_buff = NULL;
5774 addn_ie->probeRespBCNDataLen = 0;
5775
5776 if (update_ie->notify)
5777 lim_handle_param_update(mac_ctx,
5778 update_add_ies->updateType);
5779 break;
5780 default:
5781 break;
5782 }
5783 return;
5784 }
5785 switch (update_add_ies->updateType) {
5786 case eUPDATE_IE_PROBE_RESP:
5787 if (update_ie->append) {
5788 /*
5789 * In case of append, allocate new memory
5790 * with combined length
5791 */
5792 new_length = update_ie->ieBufferlength +
5793 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305794 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005795 if (NULL == new_ptr) {
5796 lim_log(mac_ctx, LOGE, FL(
5797 "Memory allocation failed."));
5798 goto end;
5799 }
5800 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305801 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005802 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305803 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005804 update_ie->pAdditionIEBuffer,
5805 update_ie->ieBufferlength);
5806 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305807 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005808 /* adjust length accordingly */
5809 addn_ie->probeRespDataLen = new_length;
5810 /* save refernece of local buffer in PE session */
5811 addn_ie->probeRespData_buff = new_ptr;
5812 goto end;
5813 }
5814 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5815 &addn_ie->probeRespDataLen,
5816 update_ie->pAdditionIEBuffer,
5817 update_ie->ieBufferlength);
5818 break;
5819 case eUPDATE_IE_ASSOC_RESP:
5820 /* assoc resp IE */
5821 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5822 &addn_ie->assocRespDataLen,
5823 update_ie->pAdditionIEBuffer,
5824 update_ie->ieBufferlength);
5825 break;
5826 case eUPDATE_IE_PROBE_BCN:
5827 /* probe resp Bcn IE */
5828 lim_update_add_ie_buffer(mac_ctx,
5829 &addn_ie->probeRespBCNData_buff,
5830 &addn_ie->probeRespBCNDataLen,
5831 update_ie->pAdditionIEBuffer,
5832 update_ie->ieBufferlength);
5833 if (update_ie->notify)
5834 lim_handle_param_update(mac_ctx,
5835 update_add_ies->updateType);
5836 break;
5837 default:
5838 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d."),
5839 update_add_ies->updateType);
5840 break;
5841 }
5842end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305843 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005844 update_ie->pAdditionIEBuffer = NULL;
5845}
5846
5847/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305848 * send_extended_chan_switch_action_frame()- function to send ECSA
5849 * action frame for each sta connected to SAP/GO and AP in case of
5850 * STA .
5851 * @mac_ctx: pointer to global mac structure
5852 * @new_channel: new channel to switch to.
5853 * @ch_bandwidth: BW of channel to calculate op_class
5854 * @session_entry: pe session
5855 *
5856 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5857 *
5858 * Return: void
5859 */
5860
5861static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5862 uint16_t new_channel, uint8_t ch_bandwidth,
5863 tpPESession session_entry)
5864{
5865 uint16_t op_class;
5866 uint8_t switch_mode = 0, i;
5867 tpDphHashNode psta;
5868
5869
Amar Singhal22995112016-01-22 10:42:33 -08005870 op_class = cds_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305871 mac_ctx->scan.countryCodeCurrent,
5872 new_channel,
5873 ch_bandwidth);
5874
5875 if (LIM_IS_AP_ROLE(session_entry) &&
5876 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
5877 switch_mode = 1;
5878
5879 if (LIM_IS_AP_ROLE(session_entry)) {
5880 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5881 psta =
5882 session_entry->dph.dphHashTable.pDphNodeArray + i;
5883 if (psta && psta->added)
5884 lim_send_extended_chan_switch_action_frame(
5885 mac_ctx,
5886 psta->staAddr,
5887 switch_mode, op_class, new_channel,
5888 LIM_MAX_CSA_IE_UPDATES, session_entry);
5889 }
5890 } else if (LIM_IS_STA_ROLE(session_entry)) {
5891 lim_send_extended_chan_switch_action_frame(mac_ctx,
5892 session_entry->bssId,
5893 switch_mode, op_class, new_channel,
5894 LIM_MAX_CSA_IE_UPDATES, session_entry);
5895 }
5896
5897}
5898
5899/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005900 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5901 *
5902 * @mac_ctx: Pointer to Global MAC structure
5903 * @msg_buf: pointer to the SME message buffer
5904 *
5905 * This function processes SME request messages from HDD or upper layer
5906 * application.
5907 *
5908 * Return: None
5909 */
5910static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5911 uint32_t *msg_buf)
5912{
5913 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5914 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005915 uint8_t session_id;
5916 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005917 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005918
5919 if (msg_buf == NULL) {
5920 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5921 return;
5922 }
5923
5924 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5925 session_entry = pe_find_session_by_bssid(mac_ctx,
5926 dfs_csa_ie_req->bssid, &session_id);
5927 if (session_entry == NULL) {
5928 lim_log(mac_ctx, LOGE, FL(
5929 "Session not found for given BSSID" MAC_ADDRESS_STR),
5930 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5931 return;
5932 }
5933
5934 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5935 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
5936 GET_LIM_SYSTEM_ROLE(session_entry));
5937 return;
5938 }
5939
5940 /* target channel */
5941 session_entry->gLimChannelSwitch.primaryChannel =
5942 dfs_csa_ie_req->targetChannel;
5943
5944 /* Channel switch announcement needs to be included in beacon */
5945 session_entry->dfsIncludeChanSwIe = true;
5946 session_entry->gLimChannelSwitch.switchCount = LIM_MAX_CSA_IE_UPDATES;
5947 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005948 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305949 session_entry->gLimChannelSwitch.sec_ch_offset =
5950 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005951 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
5952 session_entry->gLimChannelSwitch.switchMode = 1;
5953
5954 /*
5955 * Validate if SAP is operating HT or VHT mode and set the Channel
5956 * Switch Wrapper element with the Wide Band Switch subelement.
5957 */
5958 if (true != session_entry->vhtCapability)
5959 goto skip_vht;
5960
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005961 /* Now encode the Wider Ch BW element depending on the ch width */
5962 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005963 switch (dfs_csa_ie_req->ch_params.ch_width) {
5964 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005965 /*
5966 * Wide channel BW sublement in channel wrapper element is not
5967 * required in case of 20 Mhz operation. Currently It is set
5968 * only set in case of 40/80 Mhz Operation.
5969 */
5970 session_entry->dfsIncludeChanWrapperIe = false;
5971 wider_bw_ch_switch->newChanWidth =
5972 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5973 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005974 case CH_WIDTH_40MHZ:
5975 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005976 wider_bw_ch_switch->newChanWidth =
5977 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5978 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005979 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005980 session_entry->dfsIncludeChanWrapperIe = true;
5981 wider_bw_ch_switch->newChanWidth =
5982 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5983 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005984 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005985 session_entry->dfsIncludeChanWrapperIe = true;
5986 wider_bw_ch_switch->newChanWidth =
5987 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5988 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005989 case CH_WIDTH_80P80MHZ:
5990 session_entry->dfsIncludeChanWrapperIe = true;
5991 wider_bw_ch_switch->newChanWidth =
5992 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005993 /*
5994 * This is not applicable for 20/40/80 Mhz.
5995 * Only used when we support 80+80 Mhz operation.
5996 * In case of 80+80 Mhz, this parameter indicates
5997 * center channel frequency index of 80 Mhz channel of
5998 * frequency segment 1.
5999 */
6000 wider_bw_ch_switch->newCenterChanFreq1 =
6001 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006002 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006003 default:
6004 session_entry->dfsIncludeChanWrapperIe = false;
6005 /*
6006 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
6007 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
6008 */
6009 lim_log(mac_ctx, LOGE, FL("Invalid Channel Width"));
6010 break;
6011 }
6012 /* Fetch the center channel based on the channel width */
6013 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006014 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006015skip_vht:
6016 /* Send CSA IE request from here */
6017 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6018 eSIR_SUCCESS) {
6019 lim_log(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
6020 return;
6021 }
6022
6023 /*
6024 * First beacon update request is sent here, the remaining updates are
6025 * done when the FW responds back after sending the first beacon after
6026 * the template update
6027 */
6028 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306029
6030 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
6031 ch_offset = BW80;
6032 else
6033 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
6034
6035 lim_log(mac_ctx, LOG1, FL("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d"),
6036 session_entry->gLimChannelSwitch.switchCount,
6037 session_entry->gLimChannelSwitch.primaryChannel,
6038 session_entry->gLimChannelSwitch.ch_width,
6039 session_entry->dfsIncludeChanWrapperIe,
6040 ch_offset);
6041
Abhishek Singh518323d2015-10-19 17:42:01 +05306042 /* Send ECSA Action frame after updating the beacon */
6043 send_extended_chan_switch_action_frame(mac_ctx,
6044 session_entry->gLimChannelSwitch.primaryChannel,
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306045 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006046 session_entry->gLimChannelSwitch.switchCount--;
6047}
6048
6049/**
Abhishek Singh518323d2015-10-19 17:42:01 +05306050 * lim_process_ext_change_channel()- function to send ECSA
6051 * action frame for STA/CLI .
6052 * @mac_ctx: pointer to global mac structure
6053 * @msg: params from sme for new channel.
6054 *
6055 * This function is called to send ECSA frame for STA/CLI.
6056 *
6057 * Return: void
6058 */
6059
6060static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
6061 uint32_t *msg)
6062{
6063 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
6064 (struct sir_sme_ext_cng_chan_req *) msg;
6065 tpPESession session_entry = NULL;
6066
6067 if (NULL == msg) {
6068 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6069 return;
6070 }
6071 session_entry =
6072 pe_find_session_by_sme_session_id(mac_ctx,
6073 ext_chng_channel->session_id);
6074 if (NULL == session_entry) {
6075 lim_log(mac_ctx, LOGE,
6076 FL("Session not found for given session %d"),
6077 ext_chng_channel->session_id);
6078 return;
6079 }
6080 if (LIM_IS_AP_ROLE(session_entry)) {
6081 lim_log(mac_ctx, LOGE,
6082 FL("not an STA/CLI session"));
6083 return;
6084 }
6085 send_extended_chan_switch_action_frame(mac_ctx,
6086 ext_chng_channel->new_channel,
6087 0, session_entry);
6088}
6089
6090/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006091 * lim_process_nss_update_request() - process sme nss update req
6092 *
6093 * @mac_ctx: Pointer to Global MAC structure
6094 * @msg_buf: pointer to the SME message buffer
6095 *
6096 * This function processes SME request messages from HDD or upper layer
6097 * application.
6098 *
6099 * Return: None
6100 */
6101static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
6102 uint32_t *msg_buf)
6103{
6104 struct sir_nss_update_request *nss_update_req_ptr;
6105 tpPESession session_entry = NULL;
6106
6107 if (msg_buf == NULL) {
6108 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6109 return;
6110 }
6111
6112 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05306113 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006114 nss_update_req_ptr->vdev_id);
6115 if (session_entry == NULL) {
6116 lim_log(mac_ctx, LOGE, FL(
6117 "Session not found for given session_id %d"),
6118 nss_update_req_ptr->vdev_id);
6119 return;
6120 }
6121
6122 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6123 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
6124 GET_LIM_SYSTEM_ROLE(session_entry));
6125 return;
6126 }
6127
6128 /* populate nss field in the beacon */
6129 session_entry->gLimOperatingMode.present = 1;
6130 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
6131 /* Send nss update request from here */
6132 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6133 eSIR_SUCCESS) {
6134 lim_log(mac_ctx, LOGE,
6135 FL("Unable to set op mode IE in beacon"));
6136 return;
6137 }
6138
6139 lim_send_beacon_ind(mac_ctx, session_entry);
6140}
6141
6142/**
6143 * lim_process_set_ie_req() - process sme set IE request
6144 *
6145 * @mac_ctx: Pointer to Global MAC structure
6146 * @msg_buf: pointer to the SME message buffer
6147 *
6148 * This function processes SME request messages from HDD or upper layer
6149 * application.
6150 *
6151 * Return: None
6152 */
6153static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6154{
6155 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306156 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006157
6158 if (msg_buf == NULL) {
6159 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6160 return;
6161 }
6162
6163 msg = (struct send_extcap_ie *)msg_buf;
6164 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306165 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006166 lim_log(mac_ctx, LOGE, FL("Unable to send ExtCap to FW"));
6167
6168}