blob: 9aea67ee03705a34e2de5cf2debc396154419a62 [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;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530944 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -0700945 }
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;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001239 tSirMsgQ msg;
1240 uint16_t i, len;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001241 uint16_t addn_ie_len = 0;
Naveen Rawat02e12662016-08-31 16:49:27 -07001242 uint8_t *vendor_tpc_ie;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001243 tSirRetStatus status, rc = eSIR_SUCCESS;
1244 tDot11fIEExtCap extracted_extcap = {0};
1245 bool extcap_present = true;
Naveen Rawat02e12662016-08-31 16:49:27 -07001246 uint32_t lim_11h_enable = WNI_CFG_11H_ENABLED_STADEF;
1247
1248 wlan_cfg_get_int(pMac, WNI_CFG_11H_ENABLED, &lim_11h_enable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001249
1250 if (pScanReq->uIEFieldLen) {
1251 status = lim_strip_extcap_update_struct(pMac,
1252 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1253 &pScanReq->uIEFieldLen, &extracted_extcap);
1254
1255 if (eSIR_SUCCESS != status) {
1256 extcap_present = false;
1257 lim_log(pMac, LOG1,
1258 FL("Unable to Strip ExtCap IE from Scan Req"));
1259 }
1260
1261 if (extcap_present) {
1262 lim_log(pMac, LOG1,
1263 FL("Extcap was part of SCAN IE - Updating FW"));
1264 lim_send_ext_cap_ie(pMac, pScanReq->sessionId,
1265 &extracted_extcap, true);
1266 }
1267 } else {
1268 lim_log(pMac, LOG1,
1269 FL("No IEs in the scan request from supplicant"));
1270 }
1271
1272 /**
1273 * The tSirScanOffloadReq will reserve the space for first channel,
1274 * so allocate the memory for (numChannels - 1) and uIEFieldLen
1275 */
1276 len = sizeof(tSirScanOffloadReq) +
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001277 (pScanReq->channelList.numChannels - 1) +
1278 pScanReq->uIEFieldLen;
Naveen Rawat02e12662016-08-31 16:49:27 -07001279
1280 if (lim_11h_enable) {
1281 addn_ie_len += DOT11F_IE_WFATPC_MAX_LEN + 2;
1282 len += DOT11F_IE_WFATPC_MAX_LEN + 2;
1283 }
1284
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301285 pScanOffloadReq = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001286 if (NULL == pScanOffloadReq) {
1287 lim_log(pMac, LOGE,
1288 FL("AllocateMemory failed for pScanOffloadReq"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301289 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001290 }
1291
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301292 qdf_mem_set((uint8_t *) pScanOffloadReq, len, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001293
1294 msg.type = WMA_START_SCAN_OFFLOAD_REQ;
1295 msg.bodyptr = pScanOffloadReq;
1296 msg.bodyval = 0;
1297
Anurag Chouhanc5548422016-02-24 18:33:27 +05301298 qdf_copy_macaddr(&pScanOffloadReq->bssId, &pScanReq->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001299
1300 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID) {
1301 lim_log(pMac, LOGE,
1302 FL("Invalid value (%d) for numSsid"),
1303 SIR_SCAN_MAX_NUM_SSID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301304 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301305 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001306 }
1307
1308 pScanOffloadReq->numSsid = pScanReq->numSsid;
1309 for (i = 0; i < pScanOffloadReq->numSsid; i++) {
1310 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301311 qdf_mem_copy((uint8_t *) pScanOffloadReq->ssId[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001312 (uint8_t *) pScanReq->ssId[i].ssId,
1313 pScanOffloadReq->ssId[i].length);
1314 }
1315
1316 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301317 qdf_copy_macaddr(&pScanOffloadReq->selfMacAddr, &pScanReq->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001318 pScanOffloadReq->bssType = pScanReq->bssType;
1319 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1320 pScanOffloadReq->scanType = pScanReq->scanType;
1321 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1322 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1323 pScanOffloadReq->restTime = pScanReq->restTime;
Agrawal Ashish17bb3902016-05-05 13:29:40 +05301324 pScanOffloadReq->min_rest_time = pScanReq->min_rest_time;
1325 pScanOffloadReq->idle_time = pScanReq->idle_time;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301326 pScanOffloadReq->scan_adaptive_dwell_mode =
1327 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001328
1329 /* for normal scan, the value for p2pScanType should be 0
1330 always */
1331 if (pScanReq->p2pSearch)
1332 pScanOffloadReq->p2pScanType = P2P_SCAN_TYPE_SEARCH;
1333
1334 pScanOffloadReq->sessionId = pScanReq->sessionId;
1335 pScanOffloadReq->scan_id = pScanReq->scan_id;
Deepak Dhamdhered97bfb32015-10-11 15:16:18 -07001336 pScanOffloadReq->scan_requestor_id = USER_SCAN_REQUESTOR_ID;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301337 pScanOffloadReq->scan_adaptive_dwell_mode =
1338 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001339
1340 if (pScanOffloadReq->sessionId >= pMac->lim.maxBssId)
1341 lim_log(pMac, LOGE, FL("Invalid pe sessionID : %d"),
1342 pScanOffloadReq->sessionId);
1343
1344 pScanOffloadReq->channelList.numChannels =
1345 pScanReq->channelList.numChannels;
1346 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1347 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1348 p[i] = pScanReq->channelList.channelNumber[i];
1349
1350 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1351 pScanOffloadReq->uIEFieldOffset = len - addn_ie_len -
1352 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301353 qdf_mem_copy((uint8_t *) pScanOffloadReq +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001354 pScanOffloadReq->uIEFieldOffset,
1355 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1356 pScanReq->uIEFieldLen);
Naveen Rawat02e12662016-08-31 16:49:27 -07001357
1358 if (lim_11h_enable) {
1359 tDot11fIEWFATPC wfa_tpc;
1360 vendor_tpc_ie = (uint8_t *) pScanOffloadReq +
1361 pScanOffloadReq->uIEFieldOffset +
1362 pScanOffloadReq->uIEFieldLen;
1363 populate_dot11f_wfatpc(pMac, &wfa_tpc,
1364 rrm_get_mgmt_tx_power(pMac, NULL), 0);
1365 vendor_tpc_ie[0] = DOT11F_EID_WFATPC;
1366 vendor_tpc_ie[1] = DOT11F_IE_WFATPC_MAX_LEN;
1367 qdf_mem_copy(&vendor_tpc_ie[2], SIR_MAC_WFA_TPC_OUI,
1368 SIR_MAC_WFA_TPC_OUI_SIZE);
1369 qdf_mem_copy(&vendor_tpc_ie[SIR_MAC_WFA_TPC_OUI_SIZE + 2],
1370 ((uint8_t *)&wfa_tpc) + 1,
1371 DOT11F_IE_WFATPC_MAX_LEN - SIR_MAC_WFA_TPC_OUI_SIZE);
1372 pScanOffloadReq->uIEFieldLen += DOT11F_IE_WFATPC_MAX_LEN + 2;
1373 }
1374
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001375 rc = wma_post_ctrl_msg(pMac, &msg);
1376 if (rc != eSIR_SUCCESS) {
1377 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() return failure"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301378 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301379 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001380 }
1381
1382 lim_log(pMac, LOG1, FL("Processed Offload Scan Request Successfully"));
1383
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301384 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001385}
1386
1387/**
1388 * __lim_process_sme_scan_req() - Process the SME Scan Request
1389 * @mac_ctx: Global MAC Context
1390 * @msg_buf: Buffer which contains the request and pertinent parameters
1391 *
1392 * This function is called to process SME_SCAN_REQ message
1393 * from HDD or upper layer application.
1394 *
1395 * Return: None
1396 */
1397
1398static void __lim_process_sme_scan_req(tpAniSirGlobal mac_ctx,
1399 uint32_t *msg_buf)
1400{
1401 tpSirSmeScanReq scan_req;
1402 uint8_t valid_req = 0;
1403
1404#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1405 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL,
1406 eSIR_SUCCESS, eSIR_SUCCESS);
1407#endif
1408
1409 scan_req = (tpSirSmeScanReq) msg_buf;
1410 lim_log(mac_ctx, LOG1,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301411 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 -08001412 scan_req->scan_id, scan_req->channelList.numChannels,
1413 scan_req->minChannelTime, scan_req->maxChannelTime,
1414 scan_req->uIEFieldLen, scan_req->returnAfterFirstMatch,
1415 scan_req->returnFreshResults, scan_req->returnUniqueResults,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301416 lim_scan_type_to_string(scan_req->scanType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001417 scan_req->scanType, mac_ctx->lim.gLimRspReqd ? 1 : 0);
1418 /*
1419 * Since scan req always requires a response, we will overwrite response
1420 * required here. This is added esp to take care of the condition where
1421 * in p2p go case, we hold the scan req and insert single NOA. We send
1422 * the held scan request to FW later on getting start NOA ind from FW so
1423 * we lose state of the gLimRspReqd flag for the scan req if any other
1424 * request comes by then. e.g. While unit testing, we found when insert
1425 * single NOA is done, we see a get stats request which turns the flag
1426 * gLimRspReqd to false; now when we actually start the saved scan req
1427 * for init scan after getting NOA started, the gLimRspReqd being a
1428 * global flag is showing false instead of true value for this saved
1429 * scan req. Since all scan reqs coming to lim require a response,
1430 * there is no harm in setting the global flag gLimRspReqd to true here.
1431 */
1432 mac_ctx->lim.gLimRspReqd = true;
1433
1434 /*
1435 * copy the Self MAC address from SmeReq to the globalplace,
1436 * used for sending probe req
1437 */
Srinivas Girigowda2c6bf002015-09-24 11:43:31 -07001438 sir_copy_mac_addr(mac_ctx->lim.gSelfMacAddr,
1439 scan_req->selfMacAddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001440 valid_req = lim_is_sme_scan_req_valid(mac_ctx, scan_req);
1441
1442 if (!valid_req || mac_ctx->lim.scan_disabled) {
1443 lim_log(mac_ctx, LOGE,
1444 FL("Scan disabled %d, Valid Scan Req %d"),
1445 mac_ctx->lim.scan_disabled, valid_req);
1446
1447 if (mac_ctx->lim.gLimRspReqd) {
1448 mac_ctx->lim.gLimRspReqd = false;
1449
1450 lim_send_sme_scan_rsp(mac_ctx,
1451 eSIR_SME_INVALID_PARAMETERS,
1452 scan_req->sessionId,
1453 scan_req->transactionId,
1454 scan_req->scan_id);
1455 }
1456 return;
1457 }
1458
1459 /*
1460 * If scan request is received in idle, joinFailed
1461 * states or in link established state (in STA role)
1462 * or in normal state (in STA-in-IBSS/AP role) with
1463 * 'return fresh scan results' request from HDD or
1464 * it is periodic background scanning request,
1465 * trigger fresh scan request to MLM
1466 */
1467 if (__lim_fresh_scan_reqd(mac_ctx, scan_req->returnFreshResults)) {
1468
1469 mac_ctx->lim.gLim24Band11dScanDone = 0;
1470 mac_ctx->lim.gLim50Band11dScanDone = 0;
1471 mac_ctx->lim.gLimReturnAfterFirstMatch =
1472 scan_req->returnAfterFirstMatch;
1473 mac_ctx->lim.gLimReturnUniqueResults =
1474 ((scan_req->returnUniqueResults) > 0 ? true : false);
1475
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301476 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001477 lim_send_hal_start_scan_offload_req(mac_ctx,
1478 scan_req)) {
1479 lim_log(mac_ctx, LOGE, FL(
1480 "Couldn't send Offload scan request"));
1481 lim_send_sme_scan_rsp(mac_ctx,
1482 eSIR_SME_INVALID_PARAMETERS,
1483 scan_req->sessionId,
1484 scan_req->transactionId,
1485 scan_req->scan_id);
1486 return;
1487 }
Anurag Chouhanffb21542016-02-17 14:33:03 +05301488 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001489 /* In all other cases return 'cached' scan results */
1490 if (mac_ctx->lim.gLimRspReqd) {
1491 mac_ctx->lim.gLimRspReqd = false;
1492 lim_send_sme_scan_rsp(mac_ctx, eSIR_SME_SUCCESS,
1493 scan_req->sessionId,
1494 scan_req->transactionId, scan_req->scan_id);
1495 }
1496 }
1497}
1498
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001499/**
1500 * __lim_process_clear_dfs_channel_list()
1501 *
1502 ***FUNCTION:
1503 ***Clear DFS channel list when country is changed/aquired.
1504 .*This message is sent from SME.
1505 *
1506 ***LOGIC:
1507 *
1508 ***ASSUMPTIONS:
1509 *
1510 ***NOTE:
1511 *
1512 * @param pMac Pointer to Global MAC structure
1513 * @param *pMsgBuf A pointer to the SME message buffer
1514 * @return None
1515 */
1516static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
1517{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301518 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001519}
1520
1521/**
1522 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1523 * @mac_ctx: Pointer to Global MAC structure
1524 * @msg_buf: A pointer to the SME message buffer
1525 *
1526 * This function is called to process SME_JOIN_REQ message
1527 * from HDD or upper layer application.
1528 *
1529 * Return: None
1530 */
1531static void
1532__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1533{
1534 tpSirSmeJoinReq sme_join_req = NULL;
1535 tLimMlmJoinReq *mlm_join_req;
1536 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1537 uint32_t val = 0;
1538 uint16_t n_size;
1539 uint8_t session_id;
1540 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301541 uint8_t sme_session_id = 0;
1542 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001543 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001544 uint16_t ie_len;
1545 uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001546 tSirBssDescription *bss_desc;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001547 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001548
Arif Hussain995fcaf2016-07-18 11:28:22 -07001549 if (!mac_ctx || !msg_buf) {
1550 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1551 FL("JOIN REQ with invalid data"));
1552 return;
1553 }
1554
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001555/* FEATURE_WLAN_DIAG_SUPPORT */
1556#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1557 /*
1558 * Not sending any session, since it is not created yet.
1559 * The response whould have correct state.
1560 */
1561 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1562#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1563
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001564 /*
1565 * Expect Join request in idle state.
1566 * Reassociate request is expected in link established state.
1567 */
1568
1569 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1570 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1571 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1572 msg_buf);
1573
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301574 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001575 if (NULL == sme_join_req) {
1576 lim_log(mac_ctx, LOGP,
1577 FL("AllocateMemory failed for sme_join_req"));
1578 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301579 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001580 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301581 (void)qdf_mem_set((void *)sme_join_req, n_size, 0);
1582 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001583 n_size);
1584
1585 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1586 /* Received invalid eWNI_SME_JOIN_REQ */
1587 /* Log the event */
1588 lim_log(mac_ctx, LOGW,
1589 FL("SessionId:%d JOIN REQ with invalid data"),
1590 sme_join_req->sessionId);
1591 ret_code = eSIR_SME_INVALID_PARAMETERS;
1592 goto end;
1593 }
1594
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001595 /*
1596 * Update the capability here itself as this is used in
1597 * lim_extract_ap_capability() below. If not updated issues
1598 * like not honoring power constraint on 1st association after
1599 * driver loading might occur.
1600 */
1601 lim_update_rrm_capability(mac_ctx, sme_join_req);
1602
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001603 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001604 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001605 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001606 &session_id);
1607
1608 if (session != NULL) {
1609 lim_log(mac_ctx, LOGE,
1610 FL("Session(%d) Already exists for BSSID: "
1611 MAC_ADDRESS_STR " in limSmeState = %X"),
1612 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001613 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001614 session->limSmeState);
1615
1616 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1617 session->smeSessionId == sme_join_req->sessionId) {
1618 /*
1619 * Received eWNI_SME_JOIN_REQ for same
1620 * BSS as currently associated.
1621 * Log the event and send success
1622 */
1623 lim_log(mac_ctx, LOGW,
1624 FL("SessionId: %d"), session_id);
1625 lim_log(mac_ctx, LOGW,
1626 FL("JOIN_REQ for current joined BSS"));
1627 /* Send Join success response to host */
1628 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1629 session = NULL;
1630 goto end;
1631 } else {
1632 lim_log(mac_ctx, LOGE,
1633 FL("JOIN_REQ not for current joined BSS"));
1634 ret_code = eSIR_SME_REFUSED;
1635 session = NULL;
1636 goto end;
1637 }
1638 } else {
1639 /*
1640 * Session Entry does not exist for given BSSId
1641 * Try to Create a new session
1642 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001643 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001644 &session_id, mac_ctx->lim.maxStation,
1645 eSIR_INFRASTRUCTURE_MODE);
1646 if (session == NULL) {
1647 lim_log(mac_ctx, LOGE,
1648 FL("Session Can not be created "));
1649 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1650 goto end;
1651 } else
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301652 lim_log(mac_ctx, LOG2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001653 FL("SessionId:%d New session created"),
1654 session_id);
1655 }
1656 session->isAmsduSupportInAMPDU =
1657 sme_join_req->isAmsduSupportInAMPDU;
1658
1659 /*
1660 * Store Session related parameters
1661 * Store PE session Id in session Table
1662 */
1663 session->peSessionId = session_id;
1664
1665 /* store the smejoin req handle in session table */
1666 session->pLimJoinReq = sme_join_req;
1667
1668 /* Store SME session Id in sessionTable */
1669 session->smeSessionId = sme_join_req->sessionId;
1670
1671 /* Store SME transaction Id in session Table */
1672 session->transactionId = sme_join_req->transactionId;
1673
1674 /* Store beaconInterval */
1675 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001676 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001677
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301678 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001679 sizeof(session->htConfig));
1680
Sandeep Puligilla98917432016-06-10 13:50:28 -07001681 qdf_mem_copy(&(session->vht_config),
1682 &(sme_join_req->vht_config),
1683 sizeof(session->vht_config));
1684
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001685 /* Copying of bssId is already done, while creating session */
1686 sir_copy_mac_addr(session->selfMacAddr,
1687 sme_join_req->selfMacAddr);
1688 session->bssType = sme_join_req->bsstype;
1689
1690 session->statypeForBss = STA_ENTRY_PEER;
1691 session->limWmeEnabled = sme_join_req->isWMEenabled;
1692 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301693 session->wps_registration = sme_join_req->wps_registration;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001694
1695 /* Store vendor specfic IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001696 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001697 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1698
1699 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
1700 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001701 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001702
1703 if (NULL != vendor_ie) {
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08001704 lim_log(mac_ctx, LOG1, FL("Cisco vendor OUI present"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001705 session->isCiscoVendorAP = true;
1706 } else {
1707 session->isCiscoVendorAP = false;
1708 }
1709
1710 /* Copy the dot 11 mode in to the session table */
1711
1712 session->dot11mode = sme_join_req->dot11mode;
1713#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1714 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1715#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001716 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001717 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1718 session->enableHtSmps = sme_join_req->enableHtSmps;
1719 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001720 session->send_smps_action =
1721 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001722 /*
1723 * By default supported NSS 1x1 is set to true
1724 * and later on updated while determining session
1725 * supported rates which is the intersection of
1726 * self and peer rates
1727 */
1728 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301729 /*Store Persona */
1730 session->pePersona = sme_join_req->staPersona;
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001731 lim_log(mac_ctx, LOG1,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301732 FL("enable Smps: %d mode: %d send action: %d supported nss 1x1: %d pePersona %d cbMode %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001733 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001734 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001735 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301736 session->supported_nss_1x1,
1737 session->pePersona,
1738 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001739
1740 /*Store Persona */
1741 session->pePersona = sme_join_req->staPersona;
1742 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
1743 FL("PE PERSONA=%d cbMode %u"),
1744 session->pePersona, sme_join_req->cbMode);
1745 /* Copy The channel Id to the session Table */
1746 session->currentOperChannel = bss_desc->channelId;
1747 if (IS_5G_CH(session->currentOperChannel))
1748 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001749 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001750 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
1751 if (session->pePersona == QDF_P2P_CLIENT_MODE)
1752 session->vdev_nss = vdev_type_nss->p2p_cli;
1753 else
1754 session->vdev_nss = vdev_type_nss->sta;
1755 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001756 session->vhtCapability =
1757 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001758 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301759 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001760 session->vht_config.su_beam_formee =
1761 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001762 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001763 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001764 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001765 session->enableVhtpAid =
1766 sme_join_req->enableVhtpAid;
1767 session->enableVhtGid =
1768 sme_join_req->enableVhtGid;
Krunal Soni53993f72016-07-08 18:20:03 -07001769 lim_log(mac_ctx, LOG1, FL("vht su bformer [%d]"),
1770 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001771 }
Krunal Soni53993f72016-07-08 18:20:03 -07001772
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301773 lim_log(mac_ctx, LOG1,
Krunal Soni53993f72016-07-08 18:20:03 -07001774 FL("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d"),
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301775 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001776 session->vht_config.su_beam_formee,
1777 session->vht_config.csnof_beamformer_antSup,
1778 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001779 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001780 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001781 handle_ht_capabilityand_ht_info(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001782 /* cbMode is already merged value of peer and self -
1783 * done by csr in csr_get_cb_mode_from_ies */
1784 session->htSupportedChannelWidthSet =
1785 (sme_join_req->cbMode) ? 1 : 0;
1786 session->htRecommendedTxWidthSet =
1787 session->htSupportedChannelWidthSet;
1788 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1789
1790 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1791 session->ch_center_freq_seg0 =
1792 session->currentOperChannel - 2;
1793 session->ch_width = CH_WIDTH_40MHZ;
1794 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1795 sme_join_req->cbMode) {
1796 session->ch_center_freq_seg0 =
1797 session->currentOperChannel + 2;
1798 session->ch_width = CH_WIDTH_40MHZ;
1799 } else {
1800 session->ch_center_freq_seg0 = 0;
1801 session->ch_width = CH_WIDTH_20MHZ;
1802 }
1803
1804 /* Record if management frames need to be protected */
1805#ifdef WLAN_FEATURE_11W
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001806 if (eSIR_ED_AES_128_CMAC == sme_join_req->MgmtEncryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001807 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001808 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001809 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001810#endif
1811
1812#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001813 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001814#endif
1815
1816 /* Copy the SSID from smejoinreq to session entry */
1817 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301818 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001819 session->ssId.length);
1820
1821 /*
1822 * Determin 11r or ESE connection based on input from SME
1823 * which inturn is dependent on the profile the user wants
1824 * to connect to, So input is coming from supplicant
1825 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001826 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001827#ifdef FEATURE_WLAN_ESE
1828 session->isESEconnection = sme_join_req->isESEconnection;
1829#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001830 session->isFastTransitionEnabled =
1831 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001832
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001833 session->isFastRoamIniFeatureEnabled =
1834 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001835 session->txLdpcIniFeatureEnabled =
1836 sme_join_req->txLdpcIniFeatureEnabled;
1837
1838 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1839 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001840 } else {
1841 /*
1842 * Throw an error and return and make
1843 * sure to delete the session.
1844 */
1845 lim_log(mac_ctx, LOGE,
1846 FL("recvd JOIN_REQ with invalid bss type %d"),
1847 session->bssType);
1848 ret_code = eSIR_SME_INVALID_PARAMETERS;
1849 goto end;
1850 }
1851
1852 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301853 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001854 &sme_join_req->addIEScan, sizeof(tSirAddie));
1855
1856 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301857 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001858 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1859
1860 val = sizeof(tLimMlmJoinReq) +
1861 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301862 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001863 if (NULL == mlm_join_req) {
1864 lim_log(mac_ctx, LOGP,
1865 FL("AllocateMemory failed for mlmJoinReq"));
Nitesh Shah0102cac2016-07-13 14:38:30 +05301866 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1867 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001868 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301869 (void)qdf_mem_set((void *)mlm_join_req, val, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001870
1871 /* PE SessionId is stored as a part of JoinReq */
1872 mlm_join_req->sessionId = session->peSessionId;
1873
1874 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1875 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1876 eSIR_SUCCESS) {
1877 lim_log(mac_ctx, LOGP,
1878 FL("couldn't retrieve JoinFailureTimer value"
1879 " setting to default value"));
1880 mlm_join_req->joinFailureTimeout =
1881 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1882 }
1883
1884 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301885 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001886 (void *)&sme_join_req->operationalRateSet,
1887 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301888 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001889 (void *)&sme_join_req->extendedRateSet,
1890 sizeof(tSirMacRateSet));
1891 /*
1892 * this may not be needed anymore now, as rateSet is now
1893 * included in the session entry and MLM has session context.
1894 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301895 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001896 (void *)&session->rateSet,
1897 sizeof(tSirMacRateSet));
1898
1899 session->encryptType = sme_join_req->UCEncryptionType;
1900
1901 mlm_join_req->bssDescription.length =
1902 session->pLimJoinReq->bssDescription.length;
1903
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301904 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001905 (uint8_t *)
1906 &session->pLimJoinReq->bssDescription.bssId,
1907 session->pLimJoinReq->bssDescription.length + 2);
1908
1909 session->limCurrentBssCaps =
1910 session->pLimJoinReq->bssDescription.capabilityInfo;
1911
1912 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1913 session->currentOperChannel);
1914 local_power_constraint = reg_max;
1915
1916 lim_extract_ap_capability(mac_ctx,
1917 (uint8_t *)
1918 session->pLimJoinReq->bssDescription.ieFields,
1919 lim_get_ielen_from_bss_description(
1920 &session->pLimJoinReq->bssDescription),
1921 &session->limCurrentBssQosCaps,
1922 &session->limCurrentBssPropCap,
1923 &session->gLimCurrentBssUapsd,
1924 &local_power_constraint, session);
1925
Krunal Soni53993f72016-07-08 18:20:03 -07001926 /*
1927 * Once the AP capabilities are available then set the
1928 * beam forming capabilities accordingly.
1929 */
1930 if (session->nss == 1) {
1931 session->vht_config.su_beam_former = 0;
1932 session->vht_config.tx_stbc = 0;
1933 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +05301934 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001935 }
1936
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001937#ifdef FEATURE_WLAN_ESE
1938 session->maxTxPower = lim_get_max_tx_power(reg_max,
1939 local_power_constraint,
1940 mac_ctx->roam.configParam.nTxPowerCap);
1941#else
1942 session->maxTxPower =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301943 QDF_MIN(reg_max, (local_power_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001944#endif
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301945 lim_log(mac_ctx, LOG1,
1946 FL("Reg max = %d, local power con = %d, max tx = %d"),
1947 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001948
1949 if (session->gLimCurrentBssUapsd) {
1950 session->gUapsdPerAcBitmask =
1951 session->pLimJoinReq->uapsdPerAcBitmask;
1952 lim_log(mac_ctx, LOG1,
1953 FL("UAPSD flag for all AC - 0x%2x"),
1954 session->gUapsdPerAcBitmask);
1955
1956 /* resetting the dynamic uapsd mask */
1957 session->gUapsdPerAcDeliveryEnableMask = 0;
1958 session->gUapsdPerAcTriggerEnableMask = 0;
1959 }
1960
1961 session->limRFBand =
1962 lim_get_rf_band(session->currentOperChannel);
1963
1964 /* Initialize 11h Enable Flag */
1965 if (SIR_BAND_5_GHZ == session->limRFBand) {
1966 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1967 &val) != eSIR_SUCCESS) {
1968 lim_log(mac_ctx, LOGP,
1969 FL("Fail to get WNI_CFG_11H_ENABLED "));
1970 session->lim11hEnable =
1971 WNI_CFG_11H_ENABLED_STADEF;
1972 } else {
1973 session->lim11hEnable = val;
1974 }
1975 } else {
1976 session->lim11hEnable = 0;
1977 }
1978
1979 /*
1980 * To care of the scenario when STA transitions from
1981 * IBSS to Infrastructure mode.
1982 */
1983 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1984
1985 session->limPrevSmeState = session->limSmeState;
1986 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1987 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1988 session->peSessionId,
1989 session->limSmeState));
1990
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001991 /* Indicate whether spectrum management is enabled */
1992 session->spectrumMgtEnabled =
1993 sme_join_req->spectrumMgtIndicator;
1994
1995 /* Enable the spectrum management if this is a DFS channel */
1996 if (session->country_info_present &&
1997 lim_isconnected_on_dfs_channel(
1998 session->currentOperChannel))
1999 session->spectrumMgtEnabled = true;
2000
2001 session->isOSENConnection = sme_join_req->isOSENConnection;
2002
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002003 /* Issue LIM_MLM_JOIN_REQ to MLM */
2004 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
2005 (uint32_t *) mlm_join_req);
2006 return;
2007
2008 } else {
2009 /* Received eWNI_SME_JOIN_REQ un expected state */
2010 lim_log(mac_ctx, LOGE,
2011 FL("received unexpected SME_JOIN_REQ in state %X"),
2012 mac_ctx->lim.gLimSmeState);
2013 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
2014 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2015 session = NULL;
2016 goto end;
2017 }
2018
2019end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05302020 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2021 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002022
2023 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302024 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002025 sme_join_req = NULL;
2026 if (NULL != session)
2027 session->pLimJoinReq = NULL;
2028 }
2029 if (ret_code != eSIR_SME_SUCCESS) {
2030 if (NULL != session) {
2031 pe_delete_session(mac_ctx, session);
2032 session = NULL;
2033 }
2034 }
2035 lim_log(mac_ctx, LOG1,
2036 FL("Send failure status on sessionid: %d with ret_code = %d"),
2037 sme_session_id, ret_code);
2038 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
2039 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
2040 sme_transaction_id);
2041}
2042
Amar Singhala297bfa2015-10-15 15:07:29 -07002043uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002044 uint8_t iniTxPower)
2045{
2046 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302047 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
2048 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002049 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2050 maxTxPower = txPower;
2051 else if (txPower < MIN_TX_PWR_CAP)
2052 maxTxPower = MIN_TX_PWR_CAP;
2053 else
2054 maxTxPower = MAX_TX_PWR_CAP;
2055
2056 return maxTxPower;
2057}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002058
2059/**
2060 * __lim_process_sme_reassoc_req() - process reassoc req
2061 *
2062 * @mac_ctx: Pointer to Global MAC structure
2063 * @msg_buf: pointer to the SME message buffer
2064 *
2065 * This function is called to process SME_REASSOC_REQ message
2066 * from HDD or upper layer application.
2067 *
2068 * Return: None
2069 */
2070
2071static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2072 uint32_t *msg_buf)
2073{
2074 uint16_t caps;
2075 uint32_t val;
2076 tpSirSmeJoinReq reassoc_req = NULL;
2077 tLimMlmReassocReq *mlm_reassoc_req;
2078 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2079 tpPESession session_entry = NULL;
2080 uint8_t session_id;
2081 uint8_t sme_session_id;
2082 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002083 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002084 uint32_t tele_bcn_en = 0;
2085 uint16_t size;
2086
2087 lim_log(mac_ctx, LOG3, FL("Received REASSOC_REQ"));
2088
2089 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302090 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002091 if (NULL == reassoc_req) {
2092 lim_log(mac_ctx, LOGP,
2093 FL("call to AllocateMemory failed for reassoc_req"));
2094
2095 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2096 goto end;
2097 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302098 (void)qdf_mem_set((void *)reassoc_req, size, 0);
2099 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002100
2101 if (!lim_is_sme_join_req_valid(mac_ctx,
2102 (tpSirSmeJoinReq)reassoc_req)) {
2103 /*
2104 * Received invalid eWNI_SME_REASSOC_REQ
2105 */
2106 lim_log(mac_ctx, LOGW,
2107 FL("received SME_REASSOC_REQ with invalid data"));
2108
2109 ret_code = eSIR_SME_INVALID_PARAMETERS;
2110 goto end;
2111 }
2112
2113 session_entry = pe_find_session_by_bssid(mac_ctx,
2114 reassoc_req->bssDescription.bssId,
2115 &session_id);
2116 if (session_entry == NULL) {
2117 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2118 LOGE);
2119 lim_log(mac_ctx, LOGE,
2120 FL("Session does not exist for given bssId"));
2121 ret_code = eSIR_SME_INVALID_PARAMETERS;
2122 goto end;
2123 }
2124#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2125 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2126 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2127#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2128 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2129
2130 /* Store the reassoc handle in the session Table */
2131 session_entry->pLimReAssocReq = reassoc_req;
2132
2133 session_entry->dot11mode = reassoc_req->dot11mode;
2134 session_entry->vhtCapability =
2135 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002136
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302137 if (session_entry->vhtCapability) {
2138 if (session_entry->pePersona == QDF_STA_MODE) {
2139 session_entry->vht_config.su_beam_formee =
2140 reassoc_req->vht_config.su_beam_formee;
2141 } else {
2142 reassoc_req->vht_config.su_beam_formee = 0;
2143 }
2144 session_entry->enableVhtpAid =
2145 reassoc_req->enableVhtpAid;
2146 session_entry->enableVhtGid =
2147 reassoc_req->enableVhtGid;
2148 lim_log(mac_ctx, LOG1, FL("vht su bformer [%d]"),
2149 session_entry->vht_config.su_beam_former);
2150 }
2151
2152 lim_log(mac_ctx, LOG1,
2153 FL("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d"),
2154 session_entry->vhtCapability,
2155 session_entry->vht_config.su_beam_formee,
2156 session_entry->vht_config.su_beam_former);
2157
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002158 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2159 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002160 session_entry->send_smps_action =
2161 reassoc_req->send_smps_action;
2162 lim_log(mac_ctx, LOG1,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002163 FL("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002164 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002165 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002166 session_entry->send_smps_action,
2167 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002168 /*
2169 * Reassociate request is expected
2170 * in link established state only.
2171 */
2172
2173 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002174 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2175 /*
2176 * May be from 11r FT pre-auth. So lets check it
2177 * before we bail out
2178 */
2179 lim_log(mac_ctx, LOG1, FL(
2180 "Session in reassoc state is %d"),
2181 session_entry->peSessionId);
2182
2183 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302184 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002185 session_entry->limReAssocbssId,
2186 6)) {
2187 lim_print_mac_addr(mac_ctx,
2188 reassoc_req->bssDescription.
2189 bssId, LOGE);
2190 lim_log(mac_ctx, LOGP,
2191 FL("Unknown bssId in reassoc state"));
2192 ret_code = eSIR_SME_INVALID_PARAMETERS;
2193 goto end;
2194 }
2195
2196 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2197 session_entry);
2198 return;
2199 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002200 /*
2201 * Should not have received eWNI_SME_REASSOC_REQ
2202 */
2203 lim_log(mac_ctx, LOGE,
2204 FL("received unexpected SME_REASSOC_REQ in state %X"),
2205 session_entry->limSmeState);
2206 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2207
2208 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2209 goto end;
2210 }
2211
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302212 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002213 session_entry->pLimReAssocReq->bssDescription.bssId,
2214 sizeof(tSirMacAddr));
2215
2216 session_entry->limReassocChannelId =
2217 session_entry->pLimReAssocReq->bssDescription.channelId;
2218
2219 session_entry->reAssocHtSupportedChannelWidthSet =
2220 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2221 session_entry->reAssocHtRecommendedTxWidthSet =
2222 session_entry->reAssocHtSupportedChannelWidthSet;
2223 session_entry->reAssocHtSecondaryChannelOffset =
2224 session_entry->pLimReAssocReq->cbMode;
2225
2226 session_entry->limReassocBssCaps =
2227 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2228 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2229 session_entry->currentOperChannel);
2230 local_pwr_constraint = reg_max;
2231
2232 lim_extract_ap_capability(mac_ctx,
2233 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2234 lim_get_ielen_from_bss_description(
2235 &session_entry->pLimReAssocReq->bssDescription),
2236 &session_entry->limReassocBssQosCaps,
2237 &session_entry->limReassocBssPropCap,
2238 &session_entry->gLimCurrentBssUapsd,
2239 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302240 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002241 lim_log(mac_ctx, LOGE,
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302242 FL("Reg max = %d, local pwr constraint = %d, max tx = %d"),
2243 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002244 /* Copy the SSID from session entry to local variable */
2245 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302246 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002247 reassoc_req->ssId.ssId,
2248 session_entry->limReassocSSID.length);
2249 if (session_entry->gLimCurrentBssUapsd) {
2250 session_entry->gUapsdPerAcBitmask =
2251 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
2252 lim_log(mac_ctx, LOG1,
2253 FL("UAPSD flag for all AC - 0x%2x"),
2254 session_entry->gUapsdPerAcBitmask);
2255 }
2256
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302257 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002258 if (NULL == mlm_reassoc_req) {
2259 lim_log(mac_ctx, LOGP,
2260 FL("call to AllocateMemory failed for mlmReassocReq"));
2261
2262 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2263 goto end;
2264 }
2265
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302266 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002267 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2268
2269 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2270 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
2271 eSIR_SUCCESS) {
2272 /*
2273 * Could not get ReassocFailureTimeout value
2274 * from CFG. Log error.
2275 */
2276 lim_log(mac_ctx, LOGP,
2277 FL("could not retrieve ReassocFailureTimeout value"));
2278 }
2279
2280 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
2281 eSIR_SUCCESS) {
2282 /*
2283 * Could not get Capabilities value
2284 * from CFG. Log error.
2285 */
2286 lim_log(mac_ctx, LOGP, FL(
2287 "could not retrieve Capabilities value"));
2288 }
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302289
2290 lim_update_caps_info_for_bss(mac_ctx, &caps,
2291 reassoc_req->bssDescription.capabilityInfo);
2292 lim_log(mac_ctx, LOG1, FL("Capabilities info Reassoc: 0x%X"), caps);
2293
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002294 mlm_reassoc_req->capabilityInfo = caps;
2295
2296 /* Update PE session_id */
2297 mlm_reassoc_req->sessionId = session_id;
2298
2299 /*
2300 * If telescopic beaconing is enabled, set listen interval to
2301 * WNI_CFG_TELE_BCN_MAX_LI
2302 */
2303 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2304 &tele_bcn_en) != eSIR_SUCCESS)
2305 lim_log(mac_ctx, LOGP,
2306 FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
2307
2308 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2309
2310 if (tele_bcn_en) {
2311 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2312 eSIR_SUCCESS)
2313 /*
2314 * Could not get ListenInterval value
2315 * from CFG. Log error.
2316 */
2317 lim_log(mac_ctx, LOGP,
2318 FL("could not retrieve ListenInterval"));
2319 } else {
2320 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
2321 eSIR_SUCCESS)
2322 /*
2323 * Could not get ListenInterval value
2324 * from CFG. Log error.
2325 */
2326 lim_log(mac_ctx, LOGP,
2327 FL("could not retrieve ListenInterval"));
2328 }
2329
2330 mlm_reassoc_req->listenInterval = (uint16_t) val;
2331
2332 /* Indicate whether spectrum management is enabled */
2333 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2334
2335 /* Enable the spectrum management if this is a DFS channel */
2336 if (session_entry->country_info_present &&
2337 lim_isconnected_on_dfs_channel(
2338 session_entry->currentOperChannel))
2339 session_entry->spectrumMgtEnabled = true;
2340
2341 session_entry->limPrevSmeState = session_entry->limSmeState;
2342 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2343
2344 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2345 session_entry->peSessionId,
2346 session_entry->limSmeState));
2347
2348 lim_post_mlm_message(mac_ctx,
2349 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2350 return;
2351end:
2352 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302353 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002354 if (session_entry)
2355 session_entry->pLimReAssocReq = NULL;
2356 }
2357
2358 if (session_entry) {
2359 /*
2360 * error occurred after we determined the session so extract
2361 * session and transaction info from there
2362 */
2363 sme_session_id = session_entry->smeSessionId;
2364 transaction_id = session_entry->transactionId;
2365 } else
2366 /*
2367 * error occurred before or during the time we determined
2368 * the session so extract the session and transaction info
2369 * from the message
2370 */
2371 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2372 &sme_session_id, &transaction_id);
2373
2374 /*
2375 * Send Reassoc failure response to host
2376 * (note session_entry may be NULL, but that's OK)
2377 */
2378 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2379 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2380 session_entry, sme_session_id,
2381 transaction_id);
2382}
2383
2384bool send_disassoc_frame = 1;
2385/**
2386 * __lim_process_sme_disassoc_req()
2387 *
2388 ***FUNCTION:
2389 * This function is called to process SME_DISASSOC_REQ message
2390 * from HDD or upper layer application.
2391 *
2392 ***LOGIC:
2393 *
2394 ***ASSUMPTIONS:
2395 *
2396 ***NOTE:
2397 *
2398 * @param pMac Pointer to Global MAC structure
2399 * @param *pMsgBuf A pointer to the SME message buffer
2400 * @return None
2401 */
2402
2403static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2404{
2405 uint16_t disassocTrigger, reasonCode;
2406 tLimMlmDisassocReq *pMlmDisassocReq;
2407 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2408 tSirSmeDisassocReq smeDisassocReq;
2409 tpPESession psessionEntry = NULL;
2410 uint8_t sessionId;
2411 uint8_t smesessionId;
2412 uint16_t smetransactionId;
2413
2414 if (pMsgBuf == NULL) {
2415 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
2416 return;
2417 }
2418
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302419 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002420 smesessionId = smeDisassocReq.sessionId;
2421 smetransactionId = smeDisassocReq.transactionId;
2422 if (!lim_is_sme_disassoc_req_valid(pMac,
2423 &smeDisassocReq,
2424 psessionEntry)) {
2425 PELOGE(lim_log(pMac, LOGE,
2426 FL("received invalid SME_DISASSOC_REQ message"));)
2427 if (pMac->lim.gLimRspReqd) {
2428 pMac->lim.gLimRspReqd = false;
2429
2430 retCode = eSIR_SME_INVALID_PARAMETERS;
2431 disassocTrigger = eLIM_HOST_DISASSOC;
2432 goto sendDisassoc;
2433 }
2434
2435 return;
2436 }
2437
2438 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002439 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002440 &sessionId);
2441 if (psessionEntry == NULL) {
2442 lim_log(pMac, LOGE,
2443 FL("session does not exist for given bssId "
2444 MAC_ADDRESS_STR),
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002445 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002446 retCode = eSIR_SME_INVALID_PARAMETERS;
2447 disassocTrigger = eLIM_HOST_DISASSOC;
2448 goto sendDisassoc;
2449 }
2450 lim_log(pMac, LOG1,
2451 FL("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2452 MAC_ADDRESS_STR), smesessionId,
2453 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2454 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002455 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002456
2457#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2458 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2459 0, smeDisassocReq.reasonCode);
2460#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2461
2462 /* Update SME session Id and SME transaction ID */
2463
2464 psessionEntry->smeSessionId = smesessionId;
2465 psessionEntry->transactionId = smetransactionId;
2466
2467 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2468 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002469 switch (psessionEntry->limSmeState) {
2470 case eLIM_SME_ASSOCIATED_STATE:
2471 case eLIM_SME_LINK_EST_STATE:
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002472 lim_log(pMac, LOG1,
2473 FL("Rcvd SME_DISASSOC_REQ in limSmeState: %d "),
2474 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002475 psessionEntry->limPrevSmeState =
2476 psessionEntry->limSmeState;
2477 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2478#ifdef FEATURE_WLAN_TDLS
2479 /* Delete all TDLS peers connected before leaving BSS */
2480 lim_delete_tdls_peers(pMac, psessionEntry);
2481#endif
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002482 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2483 psessionEntry->peSessionId,
2484 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002485 break;
2486
2487 case eLIM_SME_WT_DEAUTH_STATE:
2488 /* PE shall still process the DISASSOC_REQ and proceed with
2489 * link tear down even if it had already sent a DEAUTH_IND to
2490 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2491 * its been set when PE entered WT_DEAUTH_STATE.
2492 */
2493 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2494 MTRACE(mac_trace
2495 (pMac, TRACE_CODE_SME_STATE,
2496 psessionEntry->peSessionId,
2497 psessionEntry->limSmeState));
2498 lim_log(pMac, LOG1,
2499 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE. "));
2500 break;
2501
2502 case eLIM_SME_WT_DISASSOC_STATE:
2503 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2504 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2505 * PE can continue processing DISASSOC_REQ and send the response instead
2506 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2507 * for disassoc frame.
2508 *
2509 * It will send a disassoc, which is ok. However, we can use the global flag
2510 * sendDisassoc to not send disassoc frame.
2511 */
2512 lim_log(pMac, LOG1,
2513 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE. "));
2514 break;
2515
2516 case eLIM_SME_JOIN_FAILURE_STATE: {
2517 /* Already in Disconnected State, return success */
2518 lim_log(pMac, LOG1,
2519 FL("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE. "));
2520 if (pMac->lim.gLimRspReqd) {
2521 retCode = eSIR_SME_SUCCESS;
2522 disassocTrigger = eLIM_HOST_DISASSOC;
2523 goto sendDisassoc;
2524 }
2525 }
2526 break;
2527 default:
2528 /**
2529 * STA is not currently associated.
2530 * Log error and send response to host
2531 */
2532 lim_log(pMac, LOGE,
2533 FL("received unexpected SME_DISASSOC_REQ in state %X"),
2534 psessionEntry->limSmeState);
2535 lim_print_sme_state(pMac, LOGE,
2536 psessionEntry->limSmeState);
2537
2538 if (pMac->lim.gLimRspReqd) {
2539 if (psessionEntry->limSmeState !=
2540 eLIM_SME_WT_ASSOC_STATE)
2541 pMac->lim.gLimRspReqd = false;
2542
2543 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2544 disassocTrigger = eLIM_HOST_DISASSOC;
2545 goto sendDisassoc;
2546 }
2547
2548 return;
2549 }
2550
2551 break;
2552
2553 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002554 /* Fall through */
2555 break;
2556
2557 case eLIM_STA_IN_IBSS_ROLE:
2558 default:
2559 /* eLIM_UNKNOWN_ROLE */
2560 lim_log(pMac, LOGE,
2561 FL("received unexpected SME_DISASSOC_REQ for role %d"),
2562 GET_LIM_SYSTEM_ROLE(psessionEntry));
2563
2564 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2565 disassocTrigger = eLIM_HOST_DISASSOC;
2566 goto sendDisassoc;
2567 } /* end switch (pMac->lim.gLimSystemRole) */
2568
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302569 disassocTrigger = eLIM_HOST_DISASSOC;
2570 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002571
2572 if (smeDisassocReq.doNotSendOverTheAir) {
2573 lim_log(pMac, LOG1, FL("do not send dissoc over the air"));
2574 send_disassoc_frame = 0;
2575 }
2576 /* Trigger Disassociation frame to peer MAC entity */
2577 lim_log(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2578 " : %d, reasonCode : %d"),
2579 disassocTrigger, reasonCode);
2580
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302581 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002582 if (NULL == pMlmDisassocReq) {
2583 /* Log error */
2584 lim_log(pMac, LOGP,
2585 FL("call to AllocateMemory failed for mlmDisassocReq"));
2586
2587 return;
2588 }
2589
Anurag Chouhanc5548422016-02-24 18:33:27 +05302590 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002591 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002592
2593 pMlmDisassocReq->reasonCode = reasonCode;
2594 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2595
2596 /* Update PE session ID */
2597 pMlmDisassocReq->sessionId = sessionId;
2598
2599 lim_post_mlm_message(pMac,
2600 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2601 return;
2602
2603sendDisassoc:
2604 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002605 lim_send_sme_disassoc_ntf(pMac,
2606 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002607 retCode,
2608 disassocTrigger,
2609 1, smesessionId, smetransactionId,
2610 psessionEntry);
2611 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002612 lim_send_sme_disassoc_ntf(pMac,
2613 smeDisassocReq.peer_macaddr.bytes,
2614 retCode, disassocTrigger, 1,
2615 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002616
2617} /*** end __lim_process_sme_disassoc_req() ***/
2618
2619/** -----------------------------------------------------------------
2620 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2621
2622 This function is called to process SME_DISASSOC_CNF message
2623 from HDD or upper layer application.
2624
2625 \param pMac - global mac structure
2626 \param pStaDs - station dph hash node
2627 \return none
2628 \sa
2629 ----------------------------------------------------------------- */
2630static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2631{
2632 tSirSmeDisassocCnf smeDisassocCnf;
2633 uint16_t aid;
2634 tpDphHashNode pStaDs;
2635 tpPESession psessionEntry;
2636 uint8_t sessionId;
2637
2638 PELOG1(lim_log(pMac, LOG1, FL("received DISASSOC_CNF message"));)
2639
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302640 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002641 sizeof(struct sSirSmeDisassocCnf));
2642
2643 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002644 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002645 &sessionId);
2646 if (psessionEntry == NULL) {
2647 lim_log(pMac, LOGE,
2648 FL("session does not exist for given bssId"));
2649 return;
2650 }
2651
2652 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
2653 lim_log(pMac, LOGE,
2654 FL("received invalid SME_DISASSOC_CNF message"));
2655 return;
2656 }
2657#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2658 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2659 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2660 psessionEntry,
2661 (uint16_t) smeDisassocCnf.statusCode, 0);
2662 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2663 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2664 psessionEntry,
2665 (uint16_t) smeDisassocCnf.statusCode, 0);
2666#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2667
2668 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2669 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002670 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2671 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2672 && (psessionEntry->limSmeState !=
2673 eLIM_SME_WT_DEAUTH_STATE)) {
2674 lim_log(pMac, LOGE,
2675 FL
2676 ("received unexp SME_DISASSOC_CNF in state %X"),
2677 psessionEntry->limSmeState);
2678 lim_print_sme_state(pMac, LOGE,
2679 psessionEntry->limSmeState);
2680 return;
2681 }
2682 break;
2683
2684 case eLIM_AP_ROLE:
2685 /* Fall through */
2686 break;
2687
2688 case eLIM_STA_IN_IBSS_ROLE:
2689 default: /* eLIM_UNKNOWN_ROLE */
2690 lim_log(pMac, LOGE,
2691 FL("received unexpected SME_DISASSOC_CNF role %d"),
2692 GET_LIM_SYSTEM_ROLE(psessionEntry));
2693
2694 return;
2695 }
2696
2697 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2698 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2699 LIM_IS_AP_ROLE(psessionEntry)) {
2700 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002701 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002702 &psessionEntry->dph.dphHashTable);
2703 if (pStaDs == NULL) {
2704 lim_log(pMac, LOGE,
2705 FL("DISASSOC_CNF for a STA with no context, addr= "
2706 MAC_ADDRESS_STR),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002707 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002708 return;
2709 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302710
2711 if ((pStaDs->mlmStaContext.mlmState ==
2712 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2713 (pStaDs->mlmStaContext.mlmState ==
2714 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
2715 lim_log(pMac, LOGE,
2716 FL("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d"),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002717 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302718 pStaDs->mlmStaContext.mlmState);
2719 return;
2720 }
2721
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002722 /* Delete FT session if there exists one */
2723 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002724 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2725
2726 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002727 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002728 }
2729
2730 return;
2731}
2732
2733/**
2734 * __lim_process_sme_deauth_req() - process sme deauth req
2735 * @mac_ctx: Pointer to Global MAC structure
2736 * @msg_buf: pointer to the SME message buffer
2737 *
2738 * This function is called to process SME_DEAUTH_REQ message
2739 * from HDD or upper layer application.
2740 *
2741 * Return: None
2742 */
2743
2744static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2745 uint32_t *msg_buf)
2746{
2747 uint16_t deauth_trigger, reason_code;
2748 tLimMlmDeauthReq *mlm_deauth_req;
2749 tSirSmeDeauthReq sme_deauth_req;
2750 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2751 tpPESession session_entry;
2752 uint8_t session_id; /* PE sessionId */
2753 uint8_t sme_session_id;
2754 uint16_t sme_transaction_id;
2755
2756 lim_log(mac_ctx, LOG1, FL("received DEAUTH_REQ message"));
2757
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302758 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002759 sme_session_id = sme_deauth_req.sessionId;
2760 sme_transaction_id = sme_deauth_req.transactionId;
2761
2762 /*
2763 * We need to get a session first but we don't even know
2764 * if the message is correct.
2765 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002766 session_entry = pe_find_session_by_bssid(mac_ctx,
2767 sme_deauth_req.bssid.bytes,
2768 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002769 if (session_entry == NULL) {
2770 lim_log(mac_ctx, LOGE,
2771 FL("session does not exist for given bssId"));
2772 ret_code = eSIR_SME_INVALID_PARAMETERS;
2773 deauth_trigger = eLIM_HOST_DEAUTH;
2774 goto send_deauth;
2775 }
2776
2777 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2778 session_entry)) {
2779 lim_log(mac_ctx, LOGE,
2780 FL("received invalid SME_DEAUTH_REQ message"));
2781 mac_ctx->lim.gLimRspReqd = false;
2782
2783 ret_code = eSIR_SME_INVALID_PARAMETERS;
2784 deauth_trigger = eLIM_HOST_DEAUTH;
2785 goto send_deauth;
2786 }
2787 lim_log(mac_ctx, LOG1,
2788 FL("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2789 MAC_ADDRESS_STR), sme_session_id,
2790 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2791 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002792 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002793#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2794 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2795 session_entry, 0, sme_deauth_req.reasonCode);
2796#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2797
2798 /* Update SME session ID and Transaction ID */
2799 session_entry->smeSessionId = sme_session_id;
2800 session_entry->transactionId = sme_transaction_id;
2801
2802 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2803 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002804 switch (session_entry->limSmeState) {
2805 case eLIM_SME_ASSOCIATED_STATE:
2806 case eLIM_SME_LINK_EST_STATE:
2807 case eLIM_SME_WT_ASSOC_STATE:
2808 case eLIM_SME_JOIN_FAILURE_STATE:
2809 case eLIM_SME_IDLE_STATE:
2810 session_entry->limPrevSmeState =
2811 session_entry->limSmeState;
2812 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2813 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2814 session_entry->peSessionId,
2815 session_entry->limSmeState));
2816 /* Send Deauthentication request to MLM below */
2817 break;
2818 case eLIM_SME_WT_DEAUTH_STATE:
2819 case eLIM_SME_WT_DISASSOC_STATE:
2820 /*
2821 * PE Recieved a Deauth/Disassoc frame. Normally it get
2822 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2823 * Which means host is also trying to disconnect.
2824 * PE can continue processing DEAUTH_REQ and send
2825 * the response instead of failing the request.
2826 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2827 * was sent for deauth/disassoc frame.
2828 */
2829 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2830 lim_log(mac_ctx, LOG1, FL(
2831 "Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE"));
2832 break;
2833 default:
2834 /*
2835 * STA is not in a state to deauthenticate with
2836 * peer. Log error and send response to host.
2837 */
2838 lim_log(mac_ctx, LOGE, FL(
2839 "received unexp SME_DEAUTH_REQ in state %X"),
2840 session_entry->limSmeState);
2841 lim_print_sme_state(mac_ctx, LOGE,
2842 session_entry->limSmeState);
2843
2844 if (mac_ctx->lim.gLimRspReqd) {
2845 mac_ctx->lim.gLimRspReqd = false;
2846
2847 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2848 deauth_trigger = eLIM_HOST_DEAUTH;
2849
2850 /*
2851 * here we received deauth request from AP so sme state
2852 * is eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED
2853 * delSta then mlm state should be
2854 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got delBSS
2855 * rsp then mlm state should be eLIM_MLM_IDLE_STATE
2856 * so the below condition captures the state where
2857 * delSta not done and firmware still in
2858 * connected state.
2859 */
2860 if (session_entry->limSmeState ==
2861 eLIM_SME_WT_DEAUTH_STATE &&
2862 session_entry->limMlmState !=
2863 eLIM_MLM_IDLE_STATE &&
2864 session_entry->limMlmState !=
2865 eLIM_MLM_WT_DEL_STA_RSP_STATE)
2866 ret_code = eSIR_SME_DEAUTH_STATUS;
2867 goto send_deauth;
2868 }
2869 return;
2870 }
2871 break;
2872
2873 case eLIM_STA_IN_IBSS_ROLE:
2874 lim_log(mac_ctx, LOGE, FL("Deauth not allowed in IBSS"));
2875 if (mac_ctx->lim.gLimRspReqd) {
2876 mac_ctx->lim.gLimRspReqd = false;
2877 ret_code = eSIR_SME_INVALID_PARAMETERS;
2878 deauth_trigger = eLIM_HOST_DEAUTH;
2879 goto send_deauth;
2880 }
2881 return;
2882 case eLIM_AP_ROLE:
2883 break;
2884 default:
2885 lim_log(mac_ctx, LOGE,
2886 FL("received unexpected SME_DEAUTH_REQ for role %X"),
2887 GET_LIM_SYSTEM_ROLE(session_entry));
2888 if (mac_ctx->lim.gLimRspReqd) {
2889 mac_ctx->lim.gLimRspReqd = false;
2890 ret_code = eSIR_SME_INVALID_PARAMETERS;
2891 deauth_trigger = eLIM_HOST_DEAUTH;
2892 goto send_deauth;
2893 }
2894 return;
2895 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2896
2897 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2898 /* Deauthentication is triggered by Link Monitoring */
2899 lim_log(mac_ctx, LOG1, FL("** Lost link with AP **"));
2900 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2901 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2902 } else {
2903 deauth_trigger = eLIM_HOST_DEAUTH;
2904 reason_code = sme_deauth_req.reasonCode;
2905 }
2906
2907 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302908 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002909 if (NULL == mlm_deauth_req) {
2910 lim_log(mac_ctx, LOGP,
2911 FL("call to AllocateMemory failed for mlmDeauthReq"));
2912 if (mac_ctx->lim.gLimRspReqd) {
2913 mac_ctx->lim.gLimRspReqd = false;
2914 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2915 deauth_trigger = eLIM_HOST_DEAUTH;
2916 goto send_deauth;
2917 }
2918 return;
2919 }
2920
Anurag Chouhanc5548422016-02-24 18:33:27 +05302921 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002922 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002923
2924 mlm_deauth_req->reasonCode = reason_code;
2925 mlm_deauth_req->deauthTrigger = deauth_trigger;
2926
2927 /* Update PE session Id */
2928 mlm_deauth_req->sessionId = session_id;
2929
2930 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2931 (uint32_t *)mlm_deauth_req);
2932 return;
2933
2934send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002935 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2936 ret_code, deauth_trigger, 1,
2937 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002938}
2939
2940/**
2941 * __lim_process_sme_set_context_req()
2942 *
2943 * @mac_ctx: Pointer to Global MAC structure
2944 * @msg_buf: pointer to the SME message buffer
2945 *
2946 * This function is called to process SME_SETCONTEXT_REQ message
2947 * from HDD or upper layer application.
2948 *
2949 * Return: None
2950 */
2951
2952static void
2953__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2954{
2955 tpSirSmeSetContextReq set_context_req;
2956 tLimMlmSetKeysReq *mlm_set_key_req;
2957 tpPESession session_entry;
2958 uint8_t session_id; /* PE sessionID */
2959 uint8_t sme_session_id;
2960 uint16_t sme_transaction_id;
2961
2962 lim_log(mac_ctx, LOG1, FL("received SETCONTEXT_REQ message"));
2963
2964 if (msg_buf == NULL) {
2965 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
2966 return;
2967 }
2968
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302969 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002970 if (NULL == set_context_req) {
2971 lim_log(mac_ctx, LOGP, FL(
2972 "call to AllocateMemory failed for set_context_req"));
2973 return;
2974 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302975 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002976 sizeof(struct sSirSmeSetContextReq));
2977 sme_session_id = set_context_req->sessionId;
2978 sme_transaction_id = set_context_req->transactionId;
2979
2980 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
2981 lim_log(mac_ctx, LOGW,
2982 FL("received invalid SME_SETCONTEXT_REQ message"));
2983 goto end;
2984 }
2985
2986 if (set_context_req->keyMaterial.numKeys >
2987 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
2988 lim_log(mac_ctx, LOGE, FL(
2989 "numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS"),
2990 set_context_req->keyMaterial.numKeys);
2991 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002992 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002993 eSIR_SME_INVALID_PARAMETERS, NULL,
2994 sme_session_id, sme_transaction_id);
2995 goto end;
2996 }
2997
2998 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002999 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003000 if (session_entry == NULL) {
3001 lim_log(mac_ctx, LOGW,
3002 FL("Session does not exist for given BSSID"));
3003 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003004 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003005 eSIR_SME_INVALID_PARAMETERS, NULL,
3006 sme_session_id, sme_transaction_id);
3007 goto end;
3008 }
3009#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3010 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
3011 session_entry, 0, 0);
3012#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3013
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003014 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003015 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
3016 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003017 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003018 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
3019 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303020 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003021 if (NULL == mlm_set_key_req) {
3022 lim_log(mac_ctx, LOGP, FL(
3023 "mem alloc failed for mlmSetKeysReq"));
3024 goto end;
3025 }
3026 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
3027 mlm_set_key_req->numKeys =
3028 set_context_req->keyMaterial.numKeys;
3029 if (mlm_set_key_req->numKeys >
3030 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
3031 lim_log(mac_ctx, LOGP, FL(
3032 "no.of keys exceeded max num of default keys limit"));
3033 goto end;
3034 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05303035 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003036 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003037
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303038 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003039 (uint8_t *) &set_context_req->keyMaterial.key,
3040 sizeof(tSirKeys) *
3041 (mlm_set_key_req->numKeys ? mlm_set_key_req->
3042 numKeys : 1));
3043
3044 mlm_set_key_req->sessionId = session_id;
3045 mlm_set_key_req->smesessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003046 lim_log(mac_ctx, LOG1, FL(
3047 "received SETCONTEXT_REQ message sessionId=%d"),
3048 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003049
3050 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
3051 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
3052 LIM_IS_AP_ROLE(session_entry)) {
3053 if (set_context_req->keyMaterial.key[0].keyLength) {
3054 uint8_t key_id;
3055 key_id =
3056 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303057 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003058 &session_entry->WEPKeyMaterial[key_id],
3059 (uint8_t *) &set_context_req->keyMaterial,
3060 sizeof(tSirKeyMaterial));
3061 } else {
3062 uint32_t i;
3063 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
3064 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303065 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003066 &mlm_set_key_req->key[i],
3067 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
3068 sizeof(tSirKeys));
3069 }
3070 }
3071 }
3072 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
3073 (uint32_t *) mlm_set_key_req);
3074 } else {
3075 lim_log(mac_ctx, LOGE, FL(
3076 "rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
3077 GET_LIM_SYSTEM_ROLE(session_entry),
3078 session_entry->limSmeState);
3079 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
3080
3081 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003082 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003083 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
3084 session_entry, sme_session_id,
3085 sme_transaction_id);
3086 }
3087end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303088 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003089 return;
3090}
3091
3092/**
3093 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
3094 *
3095 * @mac_ctx: Pointer to Global MAC structure
3096 * @msg_buf: pointer to the SME message buffer
3097 *
3098 * This function is called to process SME_GET_ASSOC_STAS_REQ message
3099 * from HDD or upper layer application.
3100 *
3101 * Return: None
3102 */
3103
3104void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
3105 uint32_t *msg_buf)
3106{
3107 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3108 tpDphHashNode sta_ds = NULL;
3109 tpPESession session_entry = NULL;
3110 tSap_Event sap_event;
3111 tpWLAN_SAPEventCB sap_event_cb = NULL;
3112 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3113 uint8_t session_id = CSR_SESSION_ID_INVALID;
3114 uint8_t assoc_id = 0;
3115 uint8_t sta_cnt = 0;
3116
3117 if (msg_buf == NULL) {
3118 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3119 return;
3120 }
3121
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303122 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003123 sizeof(struct sSirSmeGetAssocSTAsReq));
3124 /*
3125 * Get Associated stations from PE.
3126 * Find PE session Entry
3127 */
3128 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003129 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003130 &session_id);
3131 if (session_entry == NULL) {
3132 lim_log(mac_ctx, LOGE,
3133 FL("session does not exist for given bssId"));
3134 goto lim_assoc_sta_end;
3135 }
3136
3137 if (!LIM_IS_AP_ROLE(session_entry)) {
3138 lim_log(mac_ctx, LOGE, FL(
3139 "Received unexpected message in state %X, in role %X"),
3140 session_entry->limSmeState,
3141 GET_LIM_SYSTEM_ROLE(session_entry));
3142 goto lim_assoc_sta_end;
3143 }
3144 /* Retrieve values obtained in the request message */
3145 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3146 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3147
3148 if (NULL == assoc_sta_tmp)
3149 goto lim_assoc_sta_end;
3150 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3151 assoc_id++) {
3152 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3153 &session_entry->dph.dphHashTable);
3154 if (NULL == sta_ds)
3155 continue;
3156 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303157 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003158 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303159 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003160 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3161 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3162
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303163 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003164 (uint8_t *)&sta_ds->supportedRates,
3165 sizeof(tSirSupportedRates));
3166 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3167 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3168 assoc_sta_tmp->Support40Mhz =
3169 sta_ds->htDsssCckRate40MHzSupport;
3170
3171 lim_log(mac_ctx, LOG1, FL("dph Station Number = %d"),
3172 sta_cnt + 1);
3173 lim_log(mac_ctx, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3174 MAC_ADDR_ARRAY(sta_ds->staAddr));
3175 lim_log(mac_ctx, LOG1, FL("Association Id = %d"),
3176 sta_ds->assocId);
3177 lim_log(mac_ctx, LOG1, FL("Station Index = %d"),
3178 sta_ds->staIndex);
3179 assoc_sta_tmp++;
3180 sta_cnt++;
3181 }
3182 }
3183lim_assoc_sta_end:
3184 /*
3185 * Call hdd callback with sap event to send the list of
3186 * associated stations from PE
3187 */
3188 if (sap_event_cb != NULL) {
3189 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3190 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303191 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003192 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3193 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3194 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3195 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3196 }
3197}
3198
3199/**
3200 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3201 *
3202 * @mac_ctx: Pointer to Global MAC structure
3203 * @msg_buf: pointer to WPS PBC overlap query message
3204 *
3205 * This function parses get WPS PBC overlap information
3206 * message and call callback to pass WPS PBC overlap
3207 * information back to hdd.
3208 *
3209 * Return: None
3210 */
3211void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3212 uint32_t *msg_buf)
3213{
3214 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3215 tpPESession session_entry = NULL;
3216 tSap_Event sap_event;
3217 tpWLAN_SAPEventCB sap_event_cb = NULL;
3218 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003219 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3220
3221 if (msg_buf == NULL) {
3222 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3223 return;
3224 }
3225
3226 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303227 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003228
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303229 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003230 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3231 /*
3232 * Get Associated stations from PE
3233 * Find PE session Entry
3234 */
3235 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003236 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003237 if (session_entry == NULL) {
3238 lim_log(mac_ctx, LOGE,
3239 FL("session does not exist for given bssId"));
3240 goto lim_get_wpspbc_sessions_end;
3241 }
3242
3243 if (!LIM_IS_AP_ROLE(session_entry)) {
3244 lim_log(mac_ctx, LOGE,
3245 FL("Received unexpected message in role %X"),
3246 GET_LIM_SYSTEM_ROLE(session_entry));
3247 goto lim_get_wpspbc_sessions_end;
3248 }
3249 /*
3250 * Call hdd callback with sap event to send the
3251 * WPS PBC overlap information
3252 */
3253 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303254 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003255
Anurag Chouhanc5548422016-02-24 18:33:27 +05303256 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003257 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003258 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003259 sap_get_wpspbc_event->UUID_E,
3260 &sap_get_wpspbc_event->wpsPBCOverlap,
3261 session_entry);
3262 } else {
3263 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003264 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003265 session_entry);
3266 /* don't have to inform the HDD/Host */
3267 return;
3268 }
3269
3270 lim_log(mac_ctx, LOGE, FL("wpsPBCOverlap %d"),
3271 sap_get_wpspbc_event->wpsPBCOverlap);
3272 lim_print_mac_addr(mac_ctx,
3273 sap_get_wpspbc_event->addr.bytes, LOG4);
3274
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303275 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003276
3277lim_get_wpspbc_sessions_end:
3278 sap_event_cb =
3279 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3280 if (NULL != sap_event_cb)
3281 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3282}
3283
3284/**
3285 * __lim_counter_measures()
3286 *
3287 * FUNCTION:
3288 * This function is called to "implement" MIC counter measure
3289 * and is *temporary* only
3290 *
3291 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3292 * we don't do the proper STA disassoc sequence since the
3293 * BSS will be stoped anyway
3294 *
3295 ***ASSUMPTIONS:
3296 *
3297 ***NOTE:
3298 *
3299 * @param pMac Pointer to Global MAC structure
3300 * @return None
3301 */
3302
3303static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3304{
3305 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003306 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003307 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3308 mac, psessionEntry, false);
3309};
3310
3311void lim_process_tkip_counter_measures(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3312{
3313 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3314 tpPESession psessionEntry;
3315 uint8_t sessionId; /* PE sessionId */
3316
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303317 qdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003318 sizeof(struct sSirSmeTkipCntrMeasReq));
3319
3320 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003321 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003322 if (NULL == psessionEntry) {
3323 lim_log(pMac, LOGE,
3324 FL("session does not exist for given BSSID "));
3325 return;
3326 }
3327
3328 if (tkipCntrMeasReq.bEnable)
3329 __lim_counter_measures(pMac, psessionEntry);
3330
3331 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3332}
3333
3334static void
3335__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3336{
3337 tSirSmeStopBssReq stopBssReq;
3338 tSirRetStatus status;
3339 tLimSmeStates prevState;
3340 tpPESession psessionEntry;
3341 uint8_t smesessionId;
3342 uint8_t sessionId;
3343 uint16_t smetransactionId;
3344 uint8_t i = 0;
3345 tpDphHashNode pStaDs = NULL;
3346
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303347 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003348 smesessionId = stopBssReq.sessionId;
3349 smetransactionId = stopBssReq.transactionId;
3350
3351 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
3352 PELOGW(lim_log(pMac, LOGW,
3353 FL("received invalid SME_STOP_BSS_REQ message"));)
3354 /* Send Stop BSS response to host */
3355 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3356 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3357 smetransactionId);
3358 return;
3359 }
3360
3361 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003362 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003363 &sessionId);
3364 if (psessionEntry == NULL) {
3365 lim_log(pMac, LOGW,
3366 FL("session does not exist for given BSSID "));
3367 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3368 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3369 smetransactionId);
3370 return;
3371 }
3372#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3373 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3374 0, 0);
3375#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3376
3377 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3378 LIM_IS_STA_ROLE(psessionEntry)) {
3379 /**
3380 * Should not have received STOP_BSS_REQ in states
3381 * other than 'normal' state or on STA in Infrastructure
3382 * mode. Log error and return response to host.
3383 */
3384 lim_log(pMac, LOGE,
3385 FL
3386 ("received unexpected SME_STOP_BSS_REQ in state %X, for role %d"),
3387 psessionEntry->limSmeState,
3388 GET_LIM_SYSTEM_ROLE(psessionEntry));
3389 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3390 /* / Send Stop BSS response to host */
3391 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3392 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3393 smetransactionId);
3394 return;
3395 }
3396
3397 if (LIM_IS_AP_ROLE(psessionEntry))
3398 lim_wpspbc_close(pMac, psessionEntry);
3399
3400 lim_log(pMac, LOGW,
3401 FL("RECEIVED STOP_BSS_REQ with reason code=%d"),
3402 stopBssReq.reasonCode);
3403
3404 prevState = psessionEntry->limSmeState;
3405
3406 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3407 MTRACE(mac_trace
3408 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3409 psessionEntry->limSmeState));
3410
3411 /* Update SME session Id and Transaction Id */
3412 psessionEntry->smeSessionId = smesessionId;
3413 psessionEntry->transactionId = smetransactionId;
3414
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003415 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3416 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3417 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003418 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3419 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3420 /* Send disassoc all stations associated thru TKIP */
3421 __lim_counter_measures(pMac, psessionEntry);
3422 else
3423 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003424 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3425 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003426 }
3427
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003428 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3429 /* Free the buffer allocated in START_BSS_REQ */
3430 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3431 psessionEntry->addIeParams.probeRespDataLen = 0;
3432 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003433
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003434 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3435 psessionEntry->addIeParams.assocRespDataLen = 0;
3436 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003437
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003438 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3439 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3440 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003441
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003442 /*
3443 * lim_del_bss is also called as part of coalescing,
3444 * when we send DEL BSS followed by Add Bss msg.
3445 */
3446 pMac->lim.gLimIbssCoalescingHappened = false;
3447 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003448 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3449 pStaDs =
3450 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3451 if (NULL == pStaDs)
3452 continue;
3453 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3454 if (eSIR_SUCCESS == status) {
3455 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3456 pStaDs->assocId, psessionEntry);
3457 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3458 } else {
3459 lim_log(pMac, LOGE,
3460 FL("lim_del_sta failed with Status : %d"), status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303461 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003462 }
3463 }
3464 /* send a delBss to HAL and wait for a response */
3465 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3466
3467 if (status != eSIR_SUCCESS) {
3468 PELOGE(lim_log
3469 (pMac, LOGE, FL("delBss failed for bss %d"),
3470 psessionEntry->bssIdx);
3471 )
3472 psessionEntry->limSmeState = prevState;
3473
3474 MTRACE(mac_trace
3475 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3476 psessionEntry->limSmeState));
3477
3478 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3479 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3480 smetransactionId);
3481 }
3482}
3483
3484/**
3485 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3486 * @pMac: Global MAC context
3487 * @pMsg: Message from SME
3488 *
3489 * Wrapper for the function __lim_handle_sme_stop_bss_request
3490 * This message will be defered until softmac come out of
3491 * scan mode. Message should be handled even if we have
3492 * detected radar in the current operating channel.
3493 *
3494 * Return: true - If we consumed the buffer
3495 * false - If have defered the message.
3496 */
3497
3498static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
3499{
3500 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3501 /**
3502 * If message defered, buffer is not consumed yet.
3503 * So return false
3504 */
3505 return false;
3506 }
3507 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3508 return true;
3509} /*** end __lim_process_sme_stop_bss_req() ***/
3510
3511void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3512 uint32_t body, tpPESession psessionEntry)
3513{
3514
3515 (void)body;
3516 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3517 lim_ibss_delete(pMac, psessionEntry);
3518 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3519 lim_delete_pre_auth_list(pMac);
3520 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3521 psessionEntry->smeSessionId,
3522 psessionEntry->transactionId);
3523 return;
3524}
3525
3526/**
3527 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3528 *
3529 * @mac_ctx: pointer to mac context
3530 * @msg_type: message type
3531 * @msg_buf: pointer to the SME message buffer
3532 *
3533 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3534 * in BTAMP AP.
3535 *
3536 * Return: None
3537 */
3538
3539void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3540 uint32_t *msg_buf)
3541{
3542 tSirSmeAssocCnf assoc_cnf;
3543 tpDphHashNode sta_ds = NULL;
3544 tpPESession session_entry = NULL;
3545 uint8_t session_id;
3546 tpSirAssocReq assoc_req;
3547
3548 if (msg_buf == NULL) {
3549 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL "));
3550 goto end;
3551 }
3552
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303553 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003554 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
3555 lim_log(mac_ctx, LOGE,
3556 FL("Received invalid SME_RE(ASSOC)_CNF message "));
3557 goto end;
3558 }
3559
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003560 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003561 &session_id);
3562 if (session_entry == NULL) {
3563 lim_log(mac_ctx, LOGE,
3564 FL("session does not exist for given bssId"));
3565 goto end;
3566 }
3567
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003568 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003569 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3570 (session_entry->limSmeState !=
3571 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
3572 lim_log(mac_ctx, LOGE, FL(
3573 "Rcvd unexpected msg %X in state %X, in role %X"),
3574 msg_type, session_entry->limSmeState,
3575 GET_LIM_SYSTEM_ROLE(session_entry));
3576 goto end;
3577 }
3578 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3579 &session_entry->dph.dphHashTable);
3580 if (sta_ds == NULL) {
3581 lim_log(mac_ctx, LOGE, FL(
3582 "Rcvd invalid msg %X due to no STA ctx, aid %d, peer "),
3583 msg_type, assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003584 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003585
3586 /*
3587 * send a DISASSOC_IND message to WSM to make sure
3588 * the state in WSM and LIM is the same
3589 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003590 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003591 eSIR_SME_STA_NOT_ASSOCIATED,
3592 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3593 session_entry->smeSessionId,
3594 session_entry->transactionId,
3595 session_entry);
3596 goto end;
3597 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303598 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003599 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303600 QDF_MAC_ADDR_SIZE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003601 lim_log(mac_ctx, LOG1, FL(
3602 "peerMacAddr mismatched for aid %d, peer "),
3603 assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003604 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003605 goto end;
3606 }
3607
3608 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3609 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3610 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3611 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3612 (msg_type != eWNI_SME_ASSOC_CNF))) {
3613 lim_log(mac_ctx, LOG1, FL(
3614 "not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3615 "StaD mlmState : %d"),
3616 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003617 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003618 goto end;
3619 }
3620 /*
3621 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3622 * has been received
3623 */
3624 lim_log(mac_ctx, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
3625 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3626 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3627
3628 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3629 /*
3630 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3631 * when it had received Assoc Request frame. Now, PE just needs
3632 * to send association rsp frame to the requesting BTAMP-STA.
3633 */
3634 sta_ds->mlmStaContext.mlmState =
3635 eLIM_MLM_LINK_ESTABLISHED_STATE;
3636 lim_log(mac_ctx, LOG1,
3637 FL("sending Assoc Rsp frame to STA (assoc id=%d) "),
3638 sta_ds->assocId);
3639 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3640 sta_ds->assocId, sta_ds->staAddr,
3641 sta_ds->mlmStaContext.subType, sta_ds,
3642 session_entry);
3643 goto end;
3644 } else {
3645 /*
3646 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3647 * to be associated since the HAL sta entry is created for
3648 * denied STA we need to remove this HAL entry.
3649 * So to do that set updateContext to 1
3650 */
3651 if (!sta_ds->mlmStaContext.updateContext)
3652 sta_ds->mlmStaContext.updateContext = 1;
3653 lim_log(mac_ctx, LOG1,
3654 FL("Recv Assoc Cnf, status Code : %d(assoc id=%d) "),
3655 assoc_cnf.statusCode, sta_ds->assocId);
3656 lim_reject_association(mac_ctx, sta_ds->staAddr,
3657 sta_ds->mlmStaContext.subType,
3658 true, sta_ds->mlmStaContext.authType,
3659 sta_ds->assocId, true,
3660 eSIR_MAC_UNSPEC_FAILURE_STATUS,
3661 session_entry);
3662 }
3663end:
3664 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3665 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3666 assoc_req = (tpSirAssocReq)
3667 session_entry->parsedAssocReq[sta_ds->assocId];
3668 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303669 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003670 assoc_req->assocReqFrame = NULL;
3671 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303672 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003673 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3674 }
3675}
3676
3677static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3678{
3679 tpDphHashNode pStaDs;
3680 tSirMacAddr peerMac;
3681 tpSirAddtsReq pSirAddts;
3682 uint32_t timeout;
3683 tpPESession psessionEntry;
3684 uint8_t sessionId; /* PE sessionId */
3685 uint8_t smesessionId;
3686 uint16_t smetransactionId;
3687
3688 if (pMsgBuf == NULL) {
3689 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
3690 return;
3691 }
3692
3693 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3694 &smetransactionId);
3695
3696 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3697
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003698 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3699 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003700 if (psessionEntry == NULL) {
3701 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3702 return;
3703 }
3704#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3705 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3706 0);
3707#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3708
3709 /* if sta
3710 * - verify assoc state
3711 * - send addts request to ap
3712 * - wait for addts response from ap
3713 * if ap, just ignore with error log
3714 */
3715 PELOG1(lim_log(pMac, LOG1,
3716 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
3717 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3718 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
3719 )
3720
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003721 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003722 PELOGE(lim_log(pMac, LOGE, "AddTs received on AP - ignoring");)
3723 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3724 psessionEntry, pSirAddts->req.tspec,
3725 smesessionId, smetransactionId);
3726 return;
3727 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003728
3729 pStaDs =
3730 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3731 &psessionEntry->dph.dphHashTable);
3732
3733 if (pStaDs == NULL) {
3734 PELOGE(lim_log
3735 (pMac, LOGE, "Cannot find AP context for addts req");
3736 )
3737 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3738 psessionEntry, pSirAddts->req.tspec,
3739 smesessionId, smetransactionId);
3740 return;
3741 }
3742
3743 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3744 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
3745 lim_log(pMac, LOGE, "AddTs received in invalid MLM state");
3746 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3747 psessionEntry, pSirAddts->req.tspec,
3748 smesessionId, smetransactionId);
3749 return;
3750 }
3751
3752 pSirAddts->req.wsmTspecPresent = 0;
3753 pSirAddts->req.wmeTspecPresent = 0;
3754 pSirAddts->req.lleTspecPresent = 0;
3755
3756 if ((pStaDs->wsmEnabled) &&
3757 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3758 SIR_MAC_ACCESSPOLICY_EDCA))
3759 pSirAddts->req.wsmTspecPresent = 1;
3760 else if (pStaDs->wmeEnabled)
3761 pSirAddts->req.wmeTspecPresent = 1;
3762 else if (pStaDs->lleEnabled)
3763 pSirAddts->req.lleTspecPresent = 1;
3764 else {
3765 PELOGW(lim_log
3766 (pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));
3767 )
3768 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3769 psessionEntry, pSirAddts->req.tspec,
3770 smesessionId, smetransactionId);
3771 return;
3772 }
3773
3774 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3775 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
3776 lim_log(pMac, LOGE,
3777 "AddTs received in invalid LIMsme state (%d)",
3778 psessionEntry->limSmeState);
3779 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3780 psessionEntry, pSirAddts->req.tspec,
3781 smesessionId, smetransactionId);
3782 return;
3783 }
3784
3785 if (pMac->lim.gLimAddtsSent) {
3786 lim_log(pMac, LOGE,
3787 "Addts (token %d, tsid %d, up %d) is still pending",
3788 pMac->lim.gLimAddtsReq.req.dialogToken,
3789 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3790 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3791 userPrio);
3792 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3793 psessionEntry, pSirAddts->req.tspec,
3794 smesessionId, smetransactionId);
3795 return;
3796 }
3797
3798 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3799
3800 /* save the addts request */
3801 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303802 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003803 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3804
3805 /* ship out the message now */
3806 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3807 psessionEntry);
3808 PELOG1(lim_log(pMac, LOG1, "Sent ADDTS request");)
3809 /* start a timer to wait for the response */
3810 if (pSirAddts->timeout)
3811 timeout = pSirAddts->timeout;
3812 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3813 eSIR_SUCCESS) {
3814 lim_log(pMac, LOGP,
3815 FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
3816 WNI_CFG_ADDTS_RSP_TIMEOUT);
3817 return;
3818 }
3819
3820 timeout = SYS_MS_TO_TICKS(timeout);
3821 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3822 != TX_SUCCESS) {
3823 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3824 return;
3825 }
3826 pMac->lim.gLimAddtsRspTimerCount++;
3827 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3828 pMac->lim.gLimAddtsRspTimerCount) !=
3829 TX_SUCCESS) {
3830 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3831 return;
3832 }
3833 MTRACE(mac_trace
3834 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3835 eLIM_ADDTS_RSP_TIMER));
3836
3837 /* add the sessionId to the timer object */
3838 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3839 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3840 TX_SUCCESS) {
3841 lim_log(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
3842 return;
3843 }
3844 return;
3845}
3846
3847static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3848{
3849 tSirMacAddr peerMacAddr;
3850 uint8_t ac;
3851 tSirMacTSInfo *pTsinfo;
3852 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3853 tpDphHashNode pStaDs = NULL;
3854 tpPESession psessionEntry;
3855 uint8_t sessionId;
3856 uint32_t status = eSIR_SUCCESS;
3857 uint8_t smesessionId;
3858 uint16_t smetransactionId;
3859
3860 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3861 &smetransactionId);
3862
3863 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003864 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003865 &sessionId);
3866 if (psessionEntry == NULL) {
3867 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3868 status = eSIR_FAILURE;
3869 goto end;
3870 }
3871#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3872 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3873 0);
3874#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3875
3876 if (eSIR_SUCCESS !=
3877 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
3878 PELOGE(lim_log(pMac, LOGE, FL("lim_validate_delts_req failed"));)
3879 status = eSIR_FAILURE;
3880 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3881 smesessionId, smetransactionId);
3882 return;
3883 }
3884
3885 lim_log(pMac, LOG1,
3886 FL("Sent DELTS request to station with assocId = %d MacAddr = "
3887 MAC_ADDRESS_STR),
3888 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3889
3890 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3891 pDeltsReq->req.wmeTspecPresent,
3892 &pDeltsReq->req.tsinfo,
3893 &pDeltsReq->req.tspec, psessionEntry);
3894
3895 pTsinfo =
3896 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3897 tsinfo : &pDeltsReq->req.tsinfo;
3898
3899 /* We've successfully send DELTS frame to AP. Update the
3900 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3901 * is no longer trigger enabled or delivery enabled
3902 */
3903 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3904 pTsinfo, CLEAR_UAPSD_MASK);
3905
3906 /* We're deleting the TSPEC, so this particular AC is no longer
3907 * admitted. PE needs to downgrade the EDCA
3908 * parameters(for the AC for which TS is being deleted) to the
3909 * next best AC for which ACM is not enabled, and send the
3910 * updated values to HAL.
3911 */
3912 ac = upToAc(pTsinfo->traffic.userPrio);
3913
3914 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3915 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3916 ~(1 << ac);
3917 } else if (pTsinfo->traffic.direction ==
3918 SIR_MAC_DIRECTION_DNLINK) {
3919 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3920 ~(1 << ac);
3921 } else if (pTsinfo->traffic.direction ==
3922 SIR_MAC_DIRECTION_BIDIR) {
3923 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3924 ~(1 << ac);
3925 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3926 ~(1 << ac);
3927 }
3928
3929 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3930 psessionEntry);
3931
3932 pStaDs =
3933 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3934 &psessionEntry->dph.dphHashTable);
3935 if (pStaDs != NULL) {
3936 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3937 pStaDs->bssId);
3938 status = eSIR_SUCCESS;
3939 } else {
3940 lim_log(pMac, LOGE, FL("Self entry missing in Hash Table "));
3941 status = eSIR_FAILURE;
3942 }
3943#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003944 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003945#endif
3946
3947 /* send an sme response back */
3948end:
3949 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3950 smesessionId, smetransactionId);
3951}
3952
3953void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
3954{
3955 /* fetch the sessionEntry based on the sessionId */
3956 tpPESession psessionEntry;
3957 psessionEntry = pe_find_session_by_session_id(pMac,
3958 pMac->lim.limTimers.gLimAddtsRspTimer.
3959 sessionId);
3960 if (psessionEntry == NULL) {
3961 lim_log(pMac, LOGP,
3962 FL("Session Does not exist for given sessionID"));
3963 return;
3964 }
3965
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003966 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003967 lim_log(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)",
3968 GET_LIM_SYSTEM_ROLE(psessionEntry));
3969 pMac->lim.gLimAddtsSent = false;
3970 return;
3971 }
3972
3973 if (!pMac->lim.gLimAddtsSent) {
3974 lim_log(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");
3975 return;
3976 }
3977
3978 if (param != pMac->lim.gLimAddtsRspTimerCount) {
3979 lim_log(pMac, LOGE,
3980 FL("Invalid AddtsRsp Timer count %d (exp %d)"), param,
3981 pMac->lim.gLimAddtsRspTimerCount);
3982 return;
3983 }
3984 /* this a real response timeout */
3985 pMac->lim.gLimAddtsSent = false;
3986 pMac->lim.gLimAddtsRspTimerCount++;
3987
3988 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3989 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3990 psessionEntry->smeSessionId,
3991 psessionEntry->transactionId);
3992}
3993
3994/**
3995 * __lim_process_sme_get_statistics_request()
3996 *
3997 ***FUNCTION:
3998 *
3999 *
4000 ***NOTE:
4001 *
4002 * @param pMac Pointer to Global MAC structure
4003 * @param *pMsgBuf A pointer to the SME message buffer
4004 * @return None
4005 */
4006static void
4007__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4008{
4009 tpAniGetPEStatsReq pPEStatsReq;
4010 tSirMsgQ msgQ;
4011
4012 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
4013
4014 msgQ.type = WMA_GET_STATISTICS_REQ;
4015
4016 msgQ.reserved = 0;
4017 msgQ.bodyptr = pMsgBuf;
4018 msgQ.bodyval = 0;
4019 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4020
4021 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304022 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004023 pMsgBuf = NULL;
4024 lim_log(pMac, LOGP, "Unable to forward request");
4025 return;
4026 }
4027
4028 return;
4029}
4030
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004031#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004032/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004033 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004034 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004035 * @pMac: Pointer to Global MAC structure
4036 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004037 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004038 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004039 */
4040static void
4041__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4042{
4043 tSirMsgQ msgQ;
4044
4045 msgQ.type = WMA_TSM_STATS_REQ;
4046 msgQ.reserved = 0;
4047 msgQ.bodyptr = pMsgBuf;
4048 msgQ.bodyval = 0;
4049 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4050
4051 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304052 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004053 pMsgBuf = NULL;
4054 lim_log(pMac, LOGP, "Unable to forward request");
4055 return;
4056 }
4057}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004058#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004059
4060static void
4061__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4062{
4063 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4064 tpPESession psessionEntry;
4065 uint8_t sessionId; /* PE sessionID */
4066
4067 PELOG1(lim_log(pMac, LOG1, FL("received UPDATE_APWPSIEs_REQ message")););
4068
4069 if (pMsgBuf == NULL) {
4070 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4071 return;
4072 }
4073
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304074 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004075 if (NULL == pUpdateAPWPSIEsReq) {
4076 lim_log(pMac, LOGP,
4077 FL
4078 ("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
4079 return;
4080 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304081 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004082 sizeof(struct sSirUpdateAPWPSIEsReq));
4083
4084 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08004085 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004086 &sessionId);
4087 if (psessionEntry == NULL) {
4088 lim_log(pMac, LOGW,
4089 FL("Session does not exist for given BSSID"));
4090 goto end;
4091 }
4092
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304093 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004094 sizeof(tSirAPWPSIEs));
4095
4096 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4097 lim_send_beacon_ind(pMac, psessionEntry);
4098
4099end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304100 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004101 return;
4102}
4103
4104void
4105lim_send_vdev_restart(tpAniSirGlobal pMac,
4106 tpPESession psessionEntry, uint8_t sessionId)
4107{
4108 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
4109 tSirMsgQ msgQ;
4110 tSirRetStatus retCode = eSIR_SUCCESS;
4111
4112 if (psessionEntry == NULL) {
4113 PELOGE(lim_log
4114 (pMac, LOGE, "%s:%d: Invalid parameters", __func__,
4115 __LINE__);
4116 )
4117 return;
4118 }
4119
4120 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304121 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004122 if (NULL == pHalHiddenSsidVdevRestart) {
4123 PELOGE(lim_log
4124 (pMac, LOGE, "%s:%d: Unable to allocate memory",
4125 __func__, __LINE__);
4126 )
4127 return;
4128 }
4129
4130 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4131 pHalHiddenSsidVdevRestart->sessionId = sessionId;
4132
4133 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4134 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4135 msgQ.bodyval = 0;
4136
4137 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4138 if (eSIR_SUCCESS != retCode) {
4139 PELOGE(lim_log
4140 (pMac, LOGE, "%s:%d: wma_post_ctrl_msg() failed", __func__,
4141 __LINE__);
4142 )
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304143 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004144 }
4145}
4146
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304147/**
4148 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
4149 * @mac_ctx: Pointer to Global MAC structure
4150 * @msg_buf: Pointer to SME message buffer
4151 *
4152 * Return: None
4153 */
4154static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
4155 uint32_t *msg_buf)
4156{
4157 tpPESession pe_session;
4158 tSirMsgQ wma_msg;
4159 tSirRetStatus status;
4160 tSirRoamOffloadScanReq *req_buffer;
4161 uint16_t local_ie_len;
4162 uint8_t *local_ie_buf;
4163
4164 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
4165 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
4166 req_buffer->sessionId);
4167
4168 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
4169 if (!local_ie_buf) {
4170 lim_log(mac_ctx, LOGE, FL("Mem Alloc failed for local_ie_buf"));
4171 return;
4172 }
4173
4174 local_ie_len = req_buffer->assoc_ie.length;
4175 /* Update ext cap IE if present */
4176 if (local_ie_len &&
4177 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
4178 local_ie_buf, &local_ie_len)) {
4179 req_buffer->assoc_ie.length = local_ie_len;
4180 qdf_mem_copy(req_buffer->assoc_ie.addIEdata, local_ie_buf,
4181 local_ie_len);
4182 }
4183 qdf_mem_free(local_ie_buf);
4184
4185 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
4186 wma_msg.bodyptr = req_buffer;
4187
4188 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
4189 if (eSIR_SUCCESS != status) {
4190 lim_log(mac_ctx, LOGE,
4191 FL("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed"));
4192 qdf_mem_free(req_buffer);
4193 }
4194}
4195
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004196static void __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4197{
4198 tpSirUpdateParams pUpdateParams;
4199 tpPESession psessionEntry;
4200
4201 PELOG1(lim_log(pMac, LOG1, FL("received HIDE_SSID message")););
4202
4203 if (pMsgBuf == NULL) {
4204 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4205 return;
4206 }
4207
4208 pUpdateParams = (tpSirUpdateParams) pMsgBuf;
4209
Naveen Rawat9e4872a2015-11-13 09:43:11 -08004210 psessionEntry = pe_find_session_by_sme_session_id(pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004211 pUpdateParams->sessionId);
4212 if (psessionEntry == NULL) {
4213 lim_log(pMac, LOGW,
4214 "Session does not exist for given sessionId %d",
4215 pUpdateParams->sessionId);
4216 return;
4217 }
4218
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05304219 if (psessionEntry->ssidHidden != pUpdateParams->ssidHidden) {
4220 /* Update the session entry */
4221 psessionEntry->ssidHidden = pUpdateParams->ssidHidden;
4222 } else {
4223 lim_log(pMac, LOG1, FL("Same config already present!"));
4224 return;
4225 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004226
4227 /* Send vdev restart */
4228 lim_send_vdev_restart(pMac, psessionEntry, pUpdateParams->sessionId);
4229
4230 /* Update beacon */
4231 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4232 lim_send_beacon_ind(pMac, psessionEntry);
4233
4234 return;
4235} /*** end __lim_process_sme_hide_ssid(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4236
4237static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4238{
4239 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4240 tpPESession psessionEntry;
4241 uint8_t sessionId; /* PE sessionID */
4242
4243 if (pMsgBuf == NULL) {
4244 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4245 return;
4246 }
4247
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304248 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004249 if (NULL == pUpdateAPWPARSNIEsReq) {
4250 lim_log(pMac, LOGP,
4251 FL
4252 ("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
4253 return;
4254 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304255 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004256 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4257
4258 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004259 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004260 &sessionId);
4261 if (psessionEntry == NULL) {
4262 lim_log(pMac, LOGW,
4263 FL("Session does not exist for given BSSID"));
4264 goto end;
4265 }
4266
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304267 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004268 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4269
4270 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4271 &psessionEntry->
4272 pLimStartBssReq->rsnIE,
4273 psessionEntry);
4274
4275 psessionEntry->pLimStartBssReq->privacy = 1;
4276 psessionEntry->privacy = 1;
4277
4278 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4279 lim_send_beacon_ind(pMac, psessionEntry);
4280
4281end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304282 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004283 return;
4284} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4285
4286/*
4287 Update the beacon Interval dynamically if beaconInterval is different in MCC
4288 */
4289static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4290{
4291 tpSirChangeBIParams pChangeBIParams;
4292 tpPESession psessionEntry;
4293 uint8_t sessionId = 0;
4294 tUpdateBeaconParams beaconParams;
4295
4296 PELOG1(lim_log(pMac, LOG1,
4297 FL("received Update Beacon Interval message"));
4298 );
4299
4300 if (pMsgBuf == NULL) {
4301 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4302 return;
4303 }
4304
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304305 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004306 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4307
4308 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004309 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004310 &sessionId);
4311 if (psessionEntry == NULL) {
4312 lim_log(pMac, LOGE,
4313 FL("Session does not exist for given BSSID"));
4314 return;
4315 }
4316
4317 /*Update sessionEntry Beacon Interval */
4318 if (psessionEntry->beaconParams.beaconInterval !=
4319 pChangeBIParams->beaconInterval) {
4320 psessionEntry->beaconParams.beaconInterval =
4321 pChangeBIParams->beaconInterval;
4322 }
4323
4324 /*Update sch beaconInterval */
4325 if (pMac->sch.schObject.gSchBeaconInterval !=
4326 pChangeBIParams->beaconInterval) {
4327 pMac->sch.schObject.gSchBeaconInterval =
4328 pChangeBIParams->beaconInterval;
4329
4330 PELOG1(lim_log(pMac, LOG1,
4331 FL
4332 ("LIM send update BeaconInterval Indication : %d"),
4333 pChangeBIParams->beaconInterval);
4334 );
4335
4336 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4337 /* Update beacon */
4338 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4339
4340 beaconParams.bssIdx = psessionEntry->bssIdx;
4341 /* Set change in beacon Interval */
4342 beaconParams.beaconInterval =
4343 pChangeBIParams->beaconInterval;
4344 beaconParams.paramChangeBitmap =
4345 PARAM_BCN_INTERVAL_CHANGED;
4346 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4347 }
4348 }
4349
4350 return;
4351} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4352
4353#ifdef QCA_HT_2040_COEX
4354static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4355 uint32_t *pMsgBuf)
4356{
4357 tpSirSetHT2040Mode pSetHT2040Mode;
4358 tpPESession psessionEntry;
4359 uint8_t sessionId = 0;
4360 cds_msg_t msg;
4361 tUpdateVHTOpMode *pHtOpMode = NULL;
4362 uint16_t staId = 0;
4363 tpDphHashNode pStaDs = NULL;
4364
4365 PELOG1(lim_log(pMac, LOG1, FL("received Set HT 20/40 mode message")););
4366 if (pMsgBuf == NULL) {
4367 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4368 return;
4369 }
4370
4371 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4372
4373 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004374 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004375 &sessionId);
4376 if (psessionEntry == NULL) {
4377 lim_log(pMac, LOG1,
4378 FL("Session does not exist for given BSSID "));
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004379 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004380 return;
4381 }
4382
4383 lim_log(pMac, LOG1, FL("Update session entry for cbMod=%d"),
4384 pSetHT2040Mode->cbMode);
4385 /*Update sessionEntry HT related fields */
4386 switch (pSetHT2040Mode->cbMode) {
4387 case PHY_SINGLE_CHANNEL_CENTERED:
4388 psessionEntry->htSecondaryChannelOffset =
4389 PHY_SINGLE_CHANNEL_CENTERED;
4390 psessionEntry->htRecommendedTxWidthSet = 0;
4391 if (pSetHT2040Mode->obssEnabled)
4392 psessionEntry->htSupportedChannelWidthSet
4393 = eHT_CHANNEL_WIDTH_40MHZ;
4394 else
4395 psessionEntry->htSupportedChannelWidthSet
4396 = eHT_CHANNEL_WIDTH_20MHZ;
4397 break;
4398 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4399 psessionEntry->htSecondaryChannelOffset =
4400 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4401 psessionEntry->htRecommendedTxWidthSet = 1;
4402 break;
4403 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4404 psessionEntry->htSecondaryChannelOffset =
4405 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4406 psessionEntry->htRecommendedTxWidthSet = 1;
4407 break;
4408 default:
4409 lim_log(pMac, LOGE, FL("Invalid cbMode"));
4410 return;
4411 }
4412
4413 /* Update beacon */
4414 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4415 lim_send_beacon_ind(pMac, psessionEntry);
4416
4417 /* update OP Mode for each associated peer */
4418 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4419 pStaDs = dph_get_hash_entry(pMac, staId,
4420 &psessionEntry->dph.dphHashTable);
4421 if (NULL == pStaDs)
4422 continue;
4423
4424 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304425 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004426 if (NULL == pHtOpMode) {
4427 lim_log(pMac, LOGE,
4428 FL
4429 ("%s: Not able to allocate memory for setting OP mode"),
4430 __func__);
4431 return;
4432 }
4433 pHtOpMode->opMode =
4434 (psessionEntry->htSecondaryChannelOffset ==
4435 PHY_SINGLE_CHANNEL_CENTERED) ?
4436 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4437 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304438 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004439 sizeof(tSirMacAddr));
4440 pHtOpMode->smesessionId = sessionId;
4441
4442 msg.type = WMA_UPDATE_OP_MODE;
4443 msg.reserved = 0;
4444 msg.bodyptr = pHtOpMode;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304445 if (!QDF_IS_STATUS_SUCCESS
Anurag Chouhan6d760662016-02-20 16:05:43 +05304446 (cds_mq_post_message(QDF_MODULE_ID_WMA, &msg))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004447 lim_log(pMac, LOGE,
4448 FL
4449 ("%s: Not able to post WMA_UPDATE_OP_MODE message to WMA"),
4450 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304451 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004452 return;
4453 }
4454 lim_log(pMac, LOG1,
4455 FL
4456 ("%s: Notifed FW about OP mode: %d for staId=%d"),
4457 __func__, pHtOpMode->opMode, staId);
4458
4459 } else
4460 lim_log(pMac, LOG1,
4461 FL("%s: station %d does not support HT40\n"),
4462 __func__, staId);
4463 }
4464
4465 return;
4466}
4467#endif
4468
4469/* -------------------------------------------------------------------- */
4470/**
4471 * __lim_process_report_message
4472 *
4473 * FUNCTION: Processes the next received Radio Resource Management message
4474 *
4475 * LOGIC:
4476 *
4477 * ASSUMPTIONS:
4478 *
4479 * NOTE:
4480 *
4481 * @param None
4482 * @return None
4483 */
4484
4485void __lim_process_report_message(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
4486{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004487 switch (pMsg->type) {
4488 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4489 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4490 break;
4491 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004492 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004493 break;
4494 default:
4495 lim_log(pMac, LOGE, FL("Invalid msg type:%d"), pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004496 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004497}
4498
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004499/* -------------------------------------------------------------------- */
4500/**
4501 * lim_send_set_max_tx_power_req
4502 *
4503 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4504 *
4505 * LOGIC:
4506 *
4507 * ASSUMPTIONS:
4508 *
4509 * NOTE:
4510 *
4511 * @param txPower txPower to be set.
4512 * @param pSessionEntry session entry.
4513 * @return None
4514 */
4515tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004516lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004517 tpPESession pSessionEntry)
4518{
4519 tpMaxTxPowerParams pMaxTxParams = NULL;
4520 tSirRetStatus retCode = eSIR_SUCCESS;
4521 tSirMsgQ msgQ;
4522
4523 if (pSessionEntry == NULL) {
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304524 lim_log(pMac, LOGE, FL("Inavalid parameters"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004525 return eSIR_FAILURE;
4526 }
4527
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304528 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004529 if (NULL == pMaxTxParams) {
4530 lim_log(pMac, LOGP,
4531 FL("Unable to allocate memory for pMaxTxParams "));
4532 return eSIR_MEM_ALLOC_FAILED;
4533
4534 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004535 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304536 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304537 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304538 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004539 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304540 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004541
4542 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4543 msgQ.bodyptr = pMaxTxParams;
4544 msgQ.bodyval = 0;
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304545 lim_log(pMac, LOG1, FL("Post WMA_SET_MAX_TX_POWER_REQ to WMA"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004546 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4547 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4548 if (eSIR_SUCCESS != retCode) {
4549 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304550 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004551 }
4552 return retCode;
4553}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004554
4555/**
4556 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4557 *
4558 * @mac_ctx: Pointer to Global MAC structure
4559 * @msg_buf: pointer to the SME message buffer
4560 *
4561 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4562 * from SME. It Register this information within PE.
4563 *
4564 * Return: None
4565 */
4566static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4567 uint32_t *msg_buf)
4568{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304569 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004570 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4571 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4572 struct mgmt_frm_reg_info *next = NULL;
4573 bool match = false;
4574
4575 lim_log(mac_ctx, LOG1, FL(
4576 "registerFrame %d, frameType %d, matchLen %d"),
4577 sme_req->registerFrame, sme_req->frameType,
4578 sme_req->matchLen);
4579 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304580 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304581 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4582 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304583 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004584
4585 while (lim_mgmt_regn != NULL) {
4586 if (lim_mgmt_regn->frameType != sme_req->frameType)
4587 goto skip_match;
4588 if (sme_req->matchLen) {
4589 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304590 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004591 sme_req->matchData,
4592 lim_mgmt_regn->matchLen))) {
4593 /* found match! */
4594 match = true;
4595 break;
4596 }
4597 } else {
4598 /* found match! */
4599 match = true;
4600 break;
4601 }
4602skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304603 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304604 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004605 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304606 (qdf_list_node_t *)lim_mgmt_regn,
4607 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304608 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004609 lim_mgmt_regn = next;
4610 next = NULL;
4611 }
4612 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304613 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304614 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004615 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304616 (qdf_list_node_t *)lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304617 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304618 qdf_mem_free(lim_mgmt_regn);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004619 }
4620
4621 if (sme_req->registerFrame) {
4622 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304623 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004624 sme_req->matchLen);
4625 if (lim_mgmt_regn != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304626 qdf_mem_set((void *)lim_mgmt_regn,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004627 sizeof(struct mgmt_frm_reg_info) +
4628 sme_req->matchLen, 0);
4629 lim_mgmt_regn->frameType = sme_req->frameType;
4630 lim_mgmt_regn->matchLen = sme_req->matchLen;
4631 lim_mgmt_regn->sessionId = sme_req->sessionId;
4632 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304633 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004634 sme_req->matchData,
4635 sme_req->matchLen);
4636 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304637 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004638 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304639 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004640 gLimMgmtFrameRegistratinQueue,
4641 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304642 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004643 &mac_ctx->lim.lim_frame_register_lock);
4644 }
4645 }
4646 return;
4647}
4648
4649static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4650{
4651 lim_log(pMac, LOG1, FL("Dereg msgType %d"),
4652 pMac->lim.gDeferMsgTypeForNOA);
4653 pMac->lim.gDeferMsgTypeForNOA = 0;
4654 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4655 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304656 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004657 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4658 }
4659}
4660
4661/**
4662 * lim_process_regd_defd_sme_req_after_noa_start()
4663 *
4664 * mac_ctx: Pointer to Global MAC structure
4665 *
4666 * This function is called to process deferred sme req message
4667 * after noa start.
4668 *
4669 * Return: None
4670 */
4671void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4672{
4673 bool buf_consumed = true;
4674
4675 lim_log(mac_ctx, LOG1, FL("Process defd sme req %d"),
4676 mac_ctx->lim.gDeferMsgTypeForNOA);
4677
4678 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4679 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
4680 lim_log(mac_ctx, LOGW,
4681 FL("start rcvd from FW when no sme deferred msg pending. Do nothing. "));
4682 lim_log(mac_ctx, LOGW,
4683 FL("It may happen when NOA start ind and timeout happen at the same time"));
4684 return;
4685 }
4686 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4687 case eWNI_SME_SCAN_REQ:
4688 __lim_process_sme_scan_req(mac_ctx,
4689 mac_ctx->lim.gpDefdSmeMsgForNOA);
4690 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004691 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4692 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4693 mac_ctx->lim.gpDefdSmeMsgForNOA);
4694 /*
4695 * lim_process_remain_on_chnl_req doesnt want us to free
4696 * the buffer since it is freed in lim_remain_on_chn_rsp.
4697 * this change is to avoid "double free"
4698 */
4699 if (false == buf_consumed)
4700 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4701 break;
4702 case eWNI_SME_JOIN_REQ:
4703 __lim_process_sme_join_req(mac_ctx,
4704 mac_ctx->lim.gpDefdSmeMsgForNOA);
4705 break;
4706 default:
4707 lim_log(mac_ctx, LOGE, FL("Unknown deferred msg type %d"),
4708 mac_ctx->lim.gDeferMsgTypeForNOA);
4709 break;
4710 }
4711 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4712}
4713
4714static void
4715__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4716{
4717 tpSirResetAPCapsChange pResetCapsChange;
4718 tpPESession psessionEntry;
4719 uint8_t sessionId = 0;
4720 if (pMsgBuf == NULL) {
4721 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4722 return;
4723 }
4724
4725 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4726 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004727 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4728 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004729 if (psessionEntry == NULL) {
4730 lim_log(pMac, LOGE,
4731 FL("Session does not exist for given BSSID"));
4732 return;
4733 }
4734
4735 psessionEntry->limSentCapsChangeNtf = false;
4736 return;
4737}
4738
4739/**
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304740 * lim_register_p2p_ack_ind_cb() - Save the p2p ack indication callback.
4741 * @mac_ctx: Mac pointer
4742 * @msg_buf: Msg pointer containing the callback
4743 *
4744 * This function is used to save the p2p ack indication callback in PE.
4745 *
4746 * Return: None
4747 */
4748static void lim_register_p2p_ack_ind_cb(tpAniSirGlobal mac_ctx,
4749 uint32_t *msg_buf)
4750{
4751 struct sir_sme_p2p_ack_ind_cb_req *sme_req =
4752 (struct sir_sme_p2p_ack_ind_cb_req *)msg_buf;
4753
4754 if (NULL == msg_buf) {
4755 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4756 return;
4757 }
4758 if (sme_req->callback)
4759 mac_ctx->p2p_ack_ind_cb =
4760 sme_req->callback;
4761 else
4762 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4763}
4764
4765/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304766 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4767 * indication callback in PE.
4768 * @mac_ptr: Mac pointer
4769 * @msg_buf: Msg pointer containing the callback
4770 *
4771 * This function is used save the Management frame
4772 * indication callback in PE.
4773 *
4774 * Return: None
4775 */
4776static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4777 uint32_t *msg_buf)
4778{
4779 struct sir_sme_mgmt_frame_cb_req *sme_req =
4780 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4781
4782 if (NULL == msg_buf) {
4783 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4784 return;
4785 }
4786 if (sme_req->callback)
4787 mac_ctx->mgmt_frame_ind_cb =
4788 (sir_mgmt_frame_ind_callback)sme_req->callback;
4789 else
4790 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4791}
4792
4793/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304794 *__lim_process_send_disassoc_frame: function processes disassoc frame
4795 * @mac_ctx: pointer to mac context
4796 * @msg_buf: message buffer
4797 *
4798 * function processes disassoc request received from SME
4799 *
4800 * return: none
4801 */
4802static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4803 uint32_t *msg_buf)
4804{
4805 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4806 tSirRetStatus status;
4807 tpPESession session_entry = NULL;
4808 uint8_t sme_session_id;
4809 uint16_t sme_trans_id;
4810
4811 if (msg_buf == NULL) {
4812 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
4813 return;
4814 }
4815
4816 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4817 &sme_trans_id);
4818
4819 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4820 &sme_send_disassoc_frame_req,
4821 (uint8_t *)msg_buf);
4822
4823 if ((eSIR_FAILURE == status) ||
4824 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4825 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
4826 PELOGE(lim_log(mac_ctx, LOGE,
4827 FL("received invalid SME_DISASSOC_REQ message"));)
4828 return;
4829 }
4830
4831 session_entry = pe_find_session_by_sme_session_id(
4832 mac_ctx, sme_session_id);
4833 if (session_entry == NULL) {
4834 lim_log(mac_ctx, LOGE,
4835 FL("session does not exist for given bssId "MAC_ADDRESS_STR),
4836 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4837 return;
4838 }
4839
4840 lim_log(mac_ctx, LOG1,
4841 FL("msg_type->%d len->%d sess_id->%d trans_id->%d mac->"MAC_ADDRESS_STR" reason->%d wait_for_ack->%d"),
4842 sme_send_disassoc_frame_req.msg_type,
4843 sme_send_disassoc_frame_req.length,
4844 sme_send_disassoc_frame_req.session_id,
4845 sme_send_disassoc_frame_req.trans_id,
4846 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4847 sme_send_disassoc_frame_req.reason,
4848 sme_send_disassoc_frame_req.wait_for_ack);
4849
4850 lim_send_disassoc_mgmt_frame(mac_ctx,
4851 sme_send_disassoc_frame_req.reason,
4852 sme_send_disassoc_frame_req.peer_mac,
4853 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4854}
4855
4856/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004857 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4858 * @mac_ctx: Pointer to Global MAC structure
4859 * @pdev_id: pdev id to set the IE.
4860 * @nss: Nss values to prepare the HT IE.
4861 *
4862 * Prepares the HT IE with self capabilities for different
4863 * Nss values and sends the set HT IE req to FW.
4864 *
4865 * Return: None
4866 */
4867static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4868 uint8_t nss)
4869{
4870 struct set_ie_param *ie_params;
4871 tSirMsgQ msg;
4872 tSirRetStatus rc = eSIR_SUCCESS;
4873 uint8_t *p_ie = NULL;
4874 tHtCaps *p_ht_cap;
4875 int i;
4876
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004877 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004878 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4879 if (NULL == ie_params) {
4880 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4881 return;
4882 }
4883 ie_params->nss = i;
4884 ie_params->pdev_id = pdev_id;
4885 ie_params->ie_type = DOT11_HT_IE;
4886 /* 2 for IE len and EID */
4887 ie_params->ie_len = 2 + sizeof(tHtCaps);
4888 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4889 if (NULL == ie_params->ie_ptr) {
4890 qdf_mem_free(ie_params);
4891 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4892 return;
4893 }
4894 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4895 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4896 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4897 ie_params->ie_len);
4898
4899 if (NSS_1x1_MODE == i) {
4900 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4901 ie_params->ie_len,
4902 DOT11F_EID_HTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004903 if (NULL == p_ie) {
4904 qdf_mem_free(ie_params->ie_ptr);
4905 qdf_mem_free(ie_params);
4906 lim_log(mac_ctx, LOGE,
4907 FL("failed to get IE ptr"));
4908 return;
4909 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004910 p_ht_cap = (tHtCaps *)&p_ie[2];
4911 p_ht_cap->supportedMCSSet[1] = 0;
4912 p_ht_cap->txSTBC = 0;
4913 }
4914
4915 msg.type = WMA_SET_PDEV_IE_REQ;
4916 msg.bodyptr = ie_params;
4917 msg.bodyval = 0;
4918
4919 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4920 if (rc != eSIR_SUCCESS) {
4921 lim_log(mac_ctx, LOGE,
4922 FL("wma_post_ctrl_msg() return failure"));
4923 qdf_mem_free(ie_params->ie_ptr);
4924 qdf_mem_free(ie_params);
4925 return;
4926 }
4927 }
4928}
4929
4930/**
4931 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4932 * @mac_ctx: Pointer to Global MAC structure
4933 * @pdev_id: pdev id to set the IE.
4934 * @nss: Nss values to prepare the VHT IE.
4935 *
4936 * Prepares the VHT IE with self capabilities for different
4937 * Nss values and sends the set VHT IE req to FW.
4938 *
4939 * Return: None
4940 */
4941static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4942 uint8_t nss)
4943{
4944 struct set_ie_param *ie_params;
4945 tSirMsgQ msg;
4946 tSirRetStatus rc = eSIR_SUCCESS;
4947 uint8_t *p_ie = NULL;
4948 tSirMacVHTCapabilityInfo *vht_cap;
4949 int i;
4950 tSirVhtMcsInfo *vht_mcs;
4951
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004952 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004953 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4954 if (NULL == ie_params) {
4955 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4956 return;
4957 }
4958 ie_params->nss = i;
4959 ie_params->pdev_id = pdev_id;
4960 ie_params->ie_type = DOT11_VHT_IE;
4961 /* 2 for IE len and EID */
4962 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4963 sizeof(tSirVhtMcsInfo);
4964 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4965 if (NULL == ie_params->ie_ptr) {
4966 qdf_mem_free(ie_params);
4967 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4968 return;
4969 }
4970 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4971 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4972 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4973 ie_params->ie_len);
4974
4975 if (NSS_1x1_MODE == i) {
4976 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4977 ie_params->ie_len,
4978 DOT11F_EID_VHTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004979 if (NULL == p_ie) {
4980 qdf_mem_free(ie_params->ie_ptr);
4981 qdf_mem_free(ie_params);
4982 lim_log(mac_ctx, LOGE,
4983 FL("failed to get IE ptr"));
4984 return;
4985 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004986 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4987 vht_cap->txSTBC = 0;
4988 vht_mcs =
4989 (tSirVhtMcsInfo *)&p_ie[2 +
4990 sizeof(tSirMacVHTCapabilityInfo)];
4991 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4992 vht_mcs->rxHighest =
4993 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4994 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4995 vht_mcs->txHighest =
4996 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4997 }
4998 msg.type = WMA_SET_PDEV_IE_REQ;
4999 msg.bodyptr = ie_params;
5000 msg.bodyval = 0;
5001
5002 rc = wma_post_ctrl_msg(mac_ctx, &msg);
5003 if (rc != eSIR_SUCCESS) {
5004 lim_log(mac_ctx, LOGE,
5005 FL("wma_post_ctrl_msg failure"));
5006 qdf_mem_free(ie_params->ie_ptr);
5007 qdf_mem_free(ie_params);
5008 return;
5009 }
5010 }
5011}
5012
5013/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07005014 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
5015 * @mac_ctx: Pointer to Global MAC structure
5016 * @msg_buf: Pointer to the SME message buffer
5017 *
5018 * This function is called by limProcessMessageQueue(). This function sets the
5019 * VDEV IEs to the FW.
5020 *
5021 * Return: None
5022 */
5023static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
5024 uint32_t *msg_buf)
5025{
5026 struct sir_set_vdev_ies_per_band *p_msg =
5027 (struct sir_set_vdev_ies_per_band *)msg_buf;
5028
5029 if (NULL == p_msg) {
5030 lim_log(mac_ctx, LOGE, FL("NULL p_msg"));
5031 return;
5032 }
5033
5034 lim_log(mac_ctx, LOG1, FL("rcvd set vdev ie per band req vdev_id = %d"),
5035 p_msg->vdev_id);
5036 /* intentionally using NULL here so that self capabilty are sent */
5037 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
5038 QDF_STATUS_SUCCESS)
5039 lim_log(mac_ctx, LOGE, FL("Unable to send HT/VHT Cap to FW"));
5040}
5041
5042/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005043 * lim_process_set_pdev_IEs() - process the set pdev IE req
5044 * @mac_ctx: Pointer to Global MAC structure
5045 * @msg_buf: Pointer to the SME message buffer
5046 *
5047 * This function is called by limProcessMessageQueue(). This
5048 * function sets the PDEV IEs to the FW.
5049 *
5050 * Return: None
5051 */
5052static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5053{
5054 struct sir_set_ht_vht_cfg *ht_vht_cfg;
5055
5056 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
5057
5058 if (NULL == ht_vht_cfg) {
5059 lim_log(mac_ctx, LOGE, FL("NULL ht_vht_cfg"));
5060 return;
5061 }
5062
5063 lim_log(mac_ctx, LOG1, FL("rcvd set pdev ht vht ie req with nss = %d"),
5064 ht_vht_cfg->nss);
5065 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
5066
5067 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
5068 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
5069 ht_vht_cfg->nss);
5070}
5071
5072/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305073 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
5074 *
5075 * access policy
5076 * @mac_ctx: pointer to mac context
5077 * @msg: message buffer
5078 *
5079 * function processes vendor IE and access policy from SME and updates PE
5080 *
5081 * session entry
5082 *
5083 * return: none
5084*/
5085static void lim_process_sme_update_access_policy_vendor_ie(
5086 tpAniSirGlobal mac_ctx,
5087 uint32_t *msg)
5088{
5089 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
5090 struct sPESession *pe_session_entry;
5091 uint8_t num_bytes;
5092
5093 if (!msg) {
5094 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5095 return;
5096 }
5097 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
5098 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
5099 update_vendor_ie->sme_session_id);
5100
5101 if (!pe_session_entry) {
5102 lim_log(mac_ctx, LOGE,
5103 FL("Session does not exist for given sme session id(%hu)"),
5104 update_vendor_ie->sme_session_id);
5105 return;
5106 }
5107 if (pe_session_entry->access_policy_vendor_ie)
5108 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
5109
5110 num_bytes = update_vendor_ie->ie[1] + 2;
5111 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
5112
5113 if (!pe_session_entry->access_policy_vendor_ie) {
5114 lim_log(mac_ctx, LOGE,
5115 FL("Failed to allocate memory for vendor ie"));
5116 return;
5117 }
5118 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
5119 &update_vendor_ie->ie[0], num_bytes);
5120
5121 pe_session_entry->access_policy = update_vendor_ie->access_policy;
5122}
5123
5124/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005125 * lim_process_sme_req_messages()
5126 *
5127 ***FUNCTION:
5128 * This function is called by limProcessMessageQueue(). This
5129 * function processes SME request messages from HDD or upper layer
5130 * application.
5131 *
5132 ***LOGIC:
5133 *
5134 ***ASSUMPTIONS:
5135 *
5136 ***NOTE:
5137 *
5138 * @param pMac Pointer to Global MAC structure
5139 * @param msgType Indicates the SME message type
5140 * @param *pMsgBuf A pointer to the SME message buffer
5141 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5142 * false - if pMsgBuf is not to be freed.
5143 */
5144
5145bool lim_process_sme_req_messages(tpAniSirGlobal pMac, tpSirMsgQ pMsg)
5146{
5147 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
5148 uint32_t *pMsgBuf = pMsg->bodyptr;
5149 tpSirSmeScanReq pScanReq;
5150 PELOG1(lim_log
5151 (pMac, LOG1,
5152 FL
5153 ("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)"),
5154 lim_msg_str(pMsg->type), pMsg->type,
5155 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
5156 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
5157 )
5158
5159 pScanReq = (tpSirSmeScanReq) pMsgBuf;
5160 /* If no insert NOA required then execute the code below */
5161
5162 switch (pMsg->type) {
5163 case eWNI_SME_SYS_READY_IND:
5164 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
5165 break;
5166
5167 case eWNI_SME_START_BSS_REQ:
5168 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
5169 break;
5170
5171 case eWNI_SME_SCAN_REQ:
5172 __lim_process_sme_scan_req(pMac, pMsgBuf);
5173 break;
5174
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005175 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5176 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
5177 break;
5178
5179 case eWNI_SME_UPDATE_NOA:
5180 __lim_process_sme_no_a_update(pMac, pMsgBuf);
5181 break;
5182 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
5183 __lim_process_clear_dfs_channel_list(pMac, pMsg);
5184 break;
5185 case eWNI_SME_JOIN_REQ:
5186 __lim_process_sme_join_req(pMac, pMsgBuf);
5187 break;
5188
5189 case eWNI_SME_REASSOC_REQ:
5190 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
5191 break;
5192
5193 case eWNI_SME_DISASSOC_REQ:
5194 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
5195 break;
5196
5197 case eWNI_SME_DISASSOC_CNF:
5198 case eWNI_SME_DEAUTH_CNF:
5199 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
5200 break;
5201
5202 case eWNI_SME_DEAUTH_REQ:
5203 __lim_process_sme_deauth_req(pMac, pMsgBuf);
5204 break;
5205
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05305206 case eWNI_SME_SEND_DISASSOC_FRAME:
5207 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
5208 break;
5209
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005210 case eWNI_SME_SETCONTEXT_REQ:
5211 __lim_process_sme_set_context_req(pMac, pMsgBuf);
5212 break;
5213
5214 case eWNI_SME_STOP_BSS_REQ:
5215 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
5216 break;
5217
5218 case eWNI_SME_ASSOC_CNF:
5219 if (pMsg->type == eWNI_SME_ASSOC_CNF)
5220 PELOG1(lim_log(pMac,
5221 LOG1, FL("Received ASSOC_CNF message"));)
5222 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
5223 pMsgBuf);
5224 break;
5225
5226 case eWNI_SME_ADDTS_REQ:
5227 PELOG1(lim_log(pMac, LOG1, FL("Received ADDTS_REQ message"));)
5228 __lim_process_sme_addts_req(pMac, pMsgBuf);
5229 break;
5230
5231 case eWNI_SME_DELTS_REQ:
5232 PELOG1(lim_log(pMac, LOG1, FL("Received DELTS_REQ message"));)
5233 __lim_process_sme_delts_req(pMac, pMsgBuf);
5234 break;
5235
5236 case SIR_LIM_ADDTS_RSP_TIMEOUT:
5237 PELOG1(lim_log
5238 (pMac, LOG1,
5239 FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
5240 )
5241 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
5242 break;
5243
5244 case eWNI_SME_GET_STATISTICS_REQ:
5245 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
5246 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
5247 bufConsumed = false;
5248 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005249#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005250 case eWNI_SME_GET_TSM_STATS_REQ:
5251 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
5252 bufConsumed = false;
5253 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005254#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005255 case eWNI_SME_GET_ASSOC_STAS_REQ:
5256 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
5257 break;
5258 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5259 lim_process_tkip_counter_measures(pMac, pMsgBuf);
5260 break;
5261
5262 case eWNI_SME_HIDE_SSID_REQ:
5263 __lim_process_sme_hide_ssid(pMac, pMsgBuf);
5264 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05305265 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
5266 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
5267 bufConsumed = false;
5268 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005269 case eWNI_SME_UPDATE_APWPSIE_REQ:
5270 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
5271 break;
5272 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5273 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
5274 break;
5275
5276 case eWNI_SME_SET_APWPARSNIEs_REQ:
5277 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
5278 break;
5279
5280 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5281 /* Update the beaconInterval */
5282 __lim_process_sme_change_bi(pMac, pMsgBuf);
5283 break;
5284
5285#ifdef QCA_HT_2040_COEX
5286 case eWNI_SME_SET_HT_2040_MODE:
5287 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
5288 break;
5289#endif
5290
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005291 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5292 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5293 __lim_process_report_message(pMac, pMsg);
5294 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005295
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005296 case eWNI_SME_FT_PRE_AUTH_REQ:
5297 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
5298 break;
5299 case eWNI_SME_FT_UPDATE_KEY:
5300 lim_process_ft_update_key(pMac, pMsgBuf);
5301 break;
5302
5303 case eWNI_SME_FT_AGGR_QOS_REQ:
5304 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
5305 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005306
5307 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5308 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
5309 break;
5310#ifdef FEATURE_WLAN_TDLS
5311 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5312 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
5313 break;
5314 case eWNI_SME_TDLS_ADD_STA_REQ:
5315 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
5316 break;
5317 case eWNI_SME_TDLS_DEL_STA_REQ:
5318 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
5319 break;
5320 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5321 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
5322 break;
5323#endif
5324 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5325 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
5326 break;
5327
5328 case eWNI_SME_CHANNEL_CHANGE_REQ:
5329 lim_process_sme_channel_change_request(pMac, pMsgBuf);
5330 break;
5331
5332 case eWNI_SME_START_BEACON_REQ:
5333 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
5334 break;
5335
5336 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
5337 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
5338 break;
5339
5340 case eWNI_SME_UPDATE_ADDITIONAL_IES:
5341 lim_process_update_add_ies(pMac, pMsgBuf);
5342 break;
5343
5344 case eWNI_SME_MODIFY_ADDITIONAL_IES:
5345 lim_process_modify_add_ies(pMac, pMsgBuf);
5346 break;
5347 case eWNI_SME_SET_HW_MODE_REQ:
5348 lim_process_set_hw_mode(pMac, pMsgBuf);
5349 break;
5350 case eWNI_SME_NSS_UPDATE_REQ:
5351 lim_process_nss_update_request(pMac, pMsgBuf);
5352 break;
5353 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5354 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5355 break;
5356 case eWNI_SME_SET_IE_REQ:
5357 lim_process_set_ie_req(pMac, pMsgBuf);
5358 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305359 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5360 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5361 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305362 case eWNI_SME_EXT_CHANGE_CHANNEL:
5363 lim_process_ext_change_channel(pMac, pMsgBuf);
5364 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005365 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5366 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5367 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005368 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5369 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005370 break;
5371 case eWNI_SME_SET_VDEV_IES_PER_BAND:
5372 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
5373 break;
Naveen Rawatf28315c2016-06-29 18:06:02 -07005374 case eWNI_SME_NDP_END_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005375 case eWNI_SME_NDP_INITIATOR_REQ:
Abhishek Singh4fef7472016-06-06 11:36:03 -07005376 case eWNI_SME_NDP_RESPONDER_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005377 lim_handle_ndp_request_message(pMac, pMsg);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005378 break;
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05305379 case eWNI_SME_REGISTER_P2P_ACK_CB:
5380 lim_register_p2p_ack_ind_cb(pMac, pMsgBuf);
5381 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305382 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5383 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5384 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005385 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305386 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005387 pMsg->bodyptr = NULL;
5388 break;
5389 } /* switch (msgType) */
5390
5391 return bufConsumed;
5392} /*** end lim_process_sme_req_messages() ***/
5393
5394/**
5395 * lim_process_sme_start_beacon_req()
5396 *
5397 ***FUNCTION:
5398 * This function is called by limProcessMessageQueue(). This
5399 * function processes SME request messages from HDD or upper layer
5400 * application.
5401 *
5402 ***LOGIC:
5403 *
5404 ***ASSUMPTIONS:
5405 *
5406 ***NOTE:
5407 *
5408 * @param pMac Pointer to Global MAC structure
5409 * @param msgType Indicates the SME message type
5410 * @param *pMsgBuf A pointer to the SME message buffer
5411 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5412 * false - if pMsgBuf is not to be freed.
5413 */
5414static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5415{
5416 tpSirStartBeaconIndication pBeaconStartInd;
5417 tpPESession psessionEntry;
5418 uint8_t sessionId; /* PE sessionID */
5419
5420 if (pMsg == NULL) {
5421 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
5422 return;
5423 }
5424
5425 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5426 psessionEntry = pe_find_session_by_bssid(pMac,
5427 pBeaconStartInd->bssid,
5428 &sessionId);
5429 if (psessionEntry == NULL) {
5430 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
5431 lim_log(pMac, LOGE,
5432 FL("Session does not exist for given bssId"));
5433 return;
5434 }
5435
5436 if (pBeaconStartInd->beaconStartStatus == true) {
5437 /*
5438 * Currently this Indication comes from SAP
5439 * to start Beacon Tx on a DFS channel
5440 * since beaconing has to be done on DFS
5441 * channel only after CAC WAIT is completed.
5442 * On a DFS Channel LIM does not start beacon
5443 * Tx right after the WMA_ADD_BSS_RSP.
5444 */
5445 lim_apply_configuration(pMac, psessionEntry);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305446 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005447 FL("Start Beacon with ssid %s Ch %d"),
5448 psessionEntry->ssId.ssId,
5449 psessionEntry->currentOperChannel);
5450 lim_send_beacon_ind(pMac, psessionEntry);
5451 } else {
5452 lim_log(pMac, LOGE, FL("Invalid Beacon Start Indication"));
5453 return;
5454 }
5455}
5456
5457/**
5458 * lim_process_sme_channel_change_request() - process sme ch change req
5459 *
5460 * @mac_ctx: Pointer to Global MAC structure
5461 * @msg_buf: pointer to the SME message buffer
5462 *
5463 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5464 *
5465 * Return: None
5466 */
5467static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5468 uint32_t *msg_buf)
5469{
5470 tpSirChanChangeRequest ch_change_req;
5471 tpPESession session_entry;
5472 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005473 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005474 uint32_t val = 0;
5475
5476 if (msg_buf == NULL) {
5477 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5478 return;
5479 }
5480 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5481
5482 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5483 ch_change_req->targetChannel);
5484
5485 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5486 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
5487 lim_log(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5488 return;
5489 }
5490
5491 session_entry = pe_find_session_by_bssid(mac_ctx,
5492 ch_change_req->bssid, &session_id);
5493 if (session_entry == NULL) {
5494 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
5495 lim_log(mac_ctx, LOGE, FL(
5496 "Session does not exist for given bssId"));
5497 return;
5498 }
5499
5500 if (session_entry->currentOperChannel ==
5501 ch_change_req->targetChannel) {
5502 lim_log(mac_ctx, LOGE, FL("target CH is same as current CH"));
5503 return;
5504 }
5505
5506 if (LIM_IS_AP_ROLE(session_entry))
5507 session_entry->channelChangeReasonCode =
5508 LIM_SWITCH_CHANNEL_SAP_DFS;
5509 else
5510 session_entry->channelChangeReasonCode =
5511 LIM_SWITCH_CHANNEL_OPERATION;
5512
5513 lim_log(mac_ctx, LOGW, FL(
5514 "switch old chnl %d to new chnl %d, ch_bw %d"),
5515 session_entry->currentOperChannel,
5516 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005517 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005518
5519 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005520 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005521 session_entry->ch_center_freq_seg0 =
5522 ch_change_req->center_freq_seg_0;
5523 session_entry->ch_center_freq_seg1 =
5524 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005525 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005526 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005527 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005528 session_entry->htRecommendedTxWidthSet =
5529 session_entry->htSupportedChannelWidthSet;
5530 session_entry->currentOperChannel =
5531 ch_change_req->targetChannel;
5532 session_entry->limRFBand =
5533 lim_get_rf_band(session_entry->currentOperChannel);
5534 /* Initialize 11h Enable Flag */
5535 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5536 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5537 eSIR_SUCCESS)
5538 lim_log(mac_ctx, LOGP,
5539 FL("Fail to get WNI_CFG_11H_ENABLED"));
5540 }
5541
5542 session_entry->lim11hEnable = val;
5543 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305544 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005545 &ch_change_req->operational_rateset,
5546 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305547 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005548 &ch_change_req->extended_rateset,
5549 sizeof(session_entry->extRateSet));
5550 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5551 session_entry->ch_center_freq_seg0,
5552 session_entry->ch_center_freq_seg1,
5553 session_entry->ch_width,
5554 max_tx_pwr, session_entry->peSessionId);
5555}
5556
5557/******************************************************************************
5558* lim_start_bss_update_add_ie_buffer()
5559*
5560***FUNCTION:
5561* This function checks the src buffer and its length and then malloc for
5562* dst buffer update the same
5563*
5564***LOGIC:
5565*
5566***ASSUMPTIONS:
5567*
5568***NOTE:
5569*
5570* @param pMac Pointer to Global MAC structure
5571* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5572* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5573* @param *pSrcData_buff A pointer of uint8_t src buffer
5574* @param srcDataLen src buffer length
5575******************************************************************************/
5576
5577static void
5578lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5579 uint8_t **pDstData_buff,
5580 uint16_t *pDstDataLen,
5581 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5582{
5583
5584 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5585 *pDstDataLen = srcDataLen;
5586
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305587 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005588
5589 if (NULL == *pDstData_buff) {
5590 lim_log(pMac, LOGE,
5591 FL("AllocateMemory failed for pDstData_buff"));
5592 return;
5593 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305594 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005595 } else {
5596 *pDstData_buff = NULL;
5597 *pDstDataLen = 0;
5598 }
5599}
5600
5601/******************************************************************************
5602* lim_update_add_ie_buffer()
5603*
5604***FUNCTION:
5605* This function checks the src buffer and length if src buffer length more
5606* than dst buffer length then free the dst buffer and malloc for the new src
5607* length, and update the dst buffer and length. But if dst buffer is bigger
5608* than src buffer length then it just update the dst buffer and length
5609*
5610***LOGIC:
5611*
5612***ASSUMPTIONS:
5613*
5614***NOTE:
5615*
5616* @param pMac Pointer to Global MAC structure
5617* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5618* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5619* @param *pSrcData_buff A pointer of uint8_t src buffer
5620* @param srcDataLen src buffer length
5621******************************************************************************/
5622
5623static void
5624lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5625 uint8_t **pDstData_buff,
5626 uint16_t *pDstDataLen,
5627 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5628{
5629
5630 if (NULL == pSrcData_buff) {
5631 lim_log(pMac, LOGE, FL("src buffer is null."));
5632 return;
5633 }
5634
5635 if (srcDataLen > *pDstDataLen) {
5636 *pDstDataLen = srcDataLen;
5637 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305638 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005639 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305640 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005641
5642 if (NULL == *pDstData_buff) {
5643 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5644 *pDstDataLen = 0;
5645 return;
5646 }
5647 }
5648
5649 /* copy the content of buffer into dst buffer
5650 */
5651 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305652 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005653
5654}
5655
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005656/**
5657 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5658 * @pMac : Pointer to Global MAC structure
5659 * @pDstData_buff : A pointer to pointer of dst buffer
5660 * @pDstDataLen : A pointer to pointer of dst buffer length
5661 * @pModifyIE : A pointer to tSirModifyIE
5662 *
5663 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5664 *
5665 * Return:
5666 * True or false depending upon whether IE is updated or not
5667 */
5668static bool
5669lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5670 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5671{
5672 int32_t oui_length;
5673 uint8_t *ibss_ie = NULL;
5674
5675 ibss_ie = pModifyIE->pIEBuffer;
5676 oui_length = pModifyIE->oui_length;
5677
5678 if ((0 == oui_length) || (NULL == ibss_ie)) {
5679 PELOGE(lim_log(pMac, LOGE,
5680 FL("Invalid set IBSS vendor IE command length %d "),
5681 oui_length);)
5682 return false;
5683 }
5684
5685 lim_update_add_ie_buffer(pMac,
5686 pDstData_buff,
5687 pDstDataLen,
5688 pModifyIE->pIEBuffer,
5689 pModifyIE->ieBufferlength);
5690
5691 return true;
5692}
5693
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005694/*
5695* lim_process_modify_add_ies() - process modify additional IE req.
5696*
5697* @mac_ctx: Pointer to Global MAC structure
5698* @msg_buf: pointer to the SME message buffer
5699*
5700* This function update the PE buffers for additional IEs.
5701*
5702* Return: None
5703*/
5704static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5705 uint32_t *msg_buf)
5706{
5707 tpSirModifyIEsInd modify_add_ies;
5708 tpPESession session_entry;
5709 uint8_t session_id;
5710 bool ret = false;
5711 tSirAddIeParams *add_ie_params;
5712
5713 if (msg_buf == NULL) {
5714 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5715 return;
5716 }
5717
5718 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5719 /* Incoming message has smeSession, use BSSID to find PE session */
5720 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005721 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005722
5723 if (NULL == session_entry) {
5724 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5725 MAC_ADDRESS_STR),
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005726 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005727 goto end;
5728 }
5729 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5730 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5731 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
5732 lim_log(mac_ctx, LOGE,
5733 FL("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d"),
5734 modify_add_ies->modifyIE.pIEBuffer,
5735 modify_add_ies->modifyIE.ieBufferlength,
5736 modify_add_ies->modifyIE.ieID,
5737 modify_add_ies->modifyIE.ieIDLen,
5738 modify_add_ies->updateType);
5739 goto end;
5740 }
5741 add_ie_params = &session_entry->addIeParams;
5742 switch (modify_add_ies->updateType) {
5743 case eUPDATE_IE_PROBE_RESP:
5744 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005745 if (LIM_IS_IBSS_ROLE(session_entry)) {
5746 lim_update_ibss_prop_add_ies(mac_ctx,
5747 &add_ie_params->probeRespData_buff,
5748 &add_ie_params->probeRespDataLen,
5749 &modify_add_ies->modifyIE);
5750 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005751 break;
5752 case eUPDATE_IE_ASSOC_RESP:
5753 /* assoc resp IE */
5754 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305755 QDF_TRACE(QDF_MODULE_ID_PE,
5756 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005757 "assoc resp add ie not present %d"),
5758 add_ie_params->assocRespDataLen);
5759 }
5760 /* search through the buffer and modify the IE */
5761 break;
5762 case eUPDATE_IE_PROBE_BCN:
5763 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005764 if (LIM_IS_IBSS_ROLE(session_entry)) {
5765 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5766 &add_ie_params->probeRespBCNData_buff,
5767 &add_ie_params->probeRespBCNDataLen,
5768 &modify_add_ies->modifyIE);
5769 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005770 if (ret == true && modify_add_ies->modifyIE.notify) {
5771 lim_handle_param_update(mac_ctx,
5772 modify_add_ies->updateType);
5773 }
5774 break;
5775 default:
5776 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d"),
5777 modify_add_ies->updateType);
5778 break;
5779 }
5780end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305781 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005782 modify_add_ies->modifyIE.pIEBuffer = NULL;
5783}
5784
5785/*
5786* lim_process_update_add_ies() - process additional IE update req
5787*
5788* @mac_ctx: Pointer to Global MAC structure
5789* @msg_buf: pointer to the SME message buffer
5790*
5791* This function update the PE buffers for additional IEs.
5792*
5793* Return: None
5794*/
5795static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5796 uint32_t *msg_buf)
5797{
5798 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5799 uint8_t session_id;
5800 tpPESession session_entry;
5801 tSirAddIeParams *addn_ie;
5802 uint16_t new_length = 0;
5803 uint8_t *new_ptr = NULL;
5804 tSirUpdateIE *update_ie;
5805
5806 if (msg_buf == NULL) {
5807 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5808 return;
5809 }
5810 update_ie = &update_add_ies->updateIE;
5811 /* incoming message has smeSession, use BSSID to find PE session */
5812 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005813 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005814
5815 if (NULL == session_entry) {
5816 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5817 MAC_ADDRESS_STR),
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005818 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005819 goto end;
5820 }
5821 addn_ie = &session_entry->addIeParams;
5822 /* if len is 0, upper layer requested freeing of buffer */
5823 if (0 == update_ie->ieBufferlength) {
5824 switch (update_add_ies->updateType) {
5825 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305826 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005827 addn_ie->probeRespData_buff = NULL;
5828 addn_ie->probeRespDataLen = 0;
5829 break;
5830 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305831 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005832 addn_ie->assocRespData_buff = NULL;
5833 addn_ie->assocRespDataLen = 0;
5834 break;
5835 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305836 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005837 addn_ie->probeRespBCNData_buff = NULL;
5838 addn_ie->probeRespBCNDataLen = 0;
5839
5840 if (update_ie->notify)
5841 lim_handle_param_update(mac_ctx,
5842 update_add_ies->updateType);
5843 break;
5844 default:
5845 break;
5846 }
5847 return;
5848 }
5849 switch (update_add_ies->updateType) {
5850 case eUPDATE_IE_PROBE_RESP:
5851 if (update_ie->append) {
5852 /*
5853 * In case of append, allocate new memory
5854 * with combined length
5855 */
5856 new_length = update_ie->ieBufferlength +
5857 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305858 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005859 if (NULL == new_ptr) {
5860 lim_log(mac_ctx, LOGE, FL(
5861 "Memory allocation failed."));
5862 goto end;
5863 }
5864 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305865 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005866 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305867 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005868 update_ie->pAdditionIEBuffer,
5869 update_ie->ieBufferlength);
5870 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305871 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005872 /* adjust length accordingly */
5873 addn_ie->probeRespDataLen = new_length;
5874 /* save refernece of local buffer in PE session */
5875 addn_ie->probeRespData_buff = new_ptr;
5876 goto end;
5877 }
5878 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5879 &addn_ie->probeRespDataLen,
5880 update_ie->pAdditionIEBuffer,
5881 update_ie->ieBufferlength);
5882 break;
5883 case eUPDATE_IE_ASSOC_RESP:
5884 /* assoc resp IE */
5885 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5886 &addn_ie->assocRespDataLen,
5887 update_ie->pAdditionIEBuffer,
5888 update_ie->ieBufferlength);
5889 break;
5890 case eUPDATE_IE_PROBE_BCN:
5891 /* probe resp Bcn IE */
5892 lim_update_add_ie_buffer(mac_ctx,
5893 &addn_ie->probeRespBCNData_buff,
5894 &addn_ie->probeRespBCNDataLen,
5895 update_ie->pAdditionIEBuffer,
5896 update_ie->ieBufferlength);
5897 if (update_ie->notify)
5898 lim_handle_param_update(mac_ctx,
5899 update_add_ies->updateType);
5900 break;
5901 default:
5902 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d."),
5903 update_add_ies->updateType);
5904 break;
5905 }
5906end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305907 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005908 update_ie->pAdditionIEBuffer = NULL;
5909}
5910
5911/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305912 * send_extended_chan_switch_action_frame()- function to send ECSA
5913 * action frame for each sta connected to SAP/GO and AP in case of
5914 * STA .
5915 * @mac_ctx: pointer to global mac structure
5916 * @new_channel: new channel to switch to.
5917 * @ch_bandwidth: BW of channel to calculate op_class
5918 * @session_entry: pe session
5919 *
5920 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5921 *
5922 * Return: void
5923 */
5924
5925static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5926 uint16_t new_channel, uint8_t ch_bandwidth,
5927 tpPESession session_entry)
5928{
5929 uint16_t op_class;
5930 uint8_t switch_mode = 0, i;
5931 tpDphHashNode psta;
5932
5933
Amar Singhal22995112016-01-22 10:42:33 -08005934 op_class = cds_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305935 mac_ctx->scan.countryCodeCurrent,
5936 new_channel,
5937 ch_bandwidth);
5938
5939 if (LIM_IS_AP_ROLE(session_entry) &&
5940 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
5941 switch_mode = 1;
5942
5943 if (LIM_IS_AP_ROLE(session_entry)) {
5944 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5945 psta =
5946 session_entry->dph.dphHashTable.pDphNodeArray + i;
5947 if (psta && psta->added)
5948 lim_send_extended_chan_switch_action_frame(
5949 mac_ctx,
5950 psta->staAddr,
5951 switch_mode, op_class, new_channel,
5952 LIM_MAX_CSA_IE_UPDATES, session_entry);
5953 }
5954 } else if (LIM_IS_STA_ROLE(session_entry)) {
5955 lim_send_extended_chan_switch_action_frame(mac_ctx,
5956 session_entry->bssId,
5957 switch_mode, op_class, new_channel,
5958 LIM_MAX_CSA_IE_UPDATES, session_entry);
5959 }
5960
5961}
5962
5963/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005964 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5965 *
5966 * @mac_ctx: Pointer to Global MAC structure
5967 * @msg_buf: pointer to the SME message buffer
5968 *
5969 * This function processes SME request messages from HDD or upper layer
5970 * application.
5971 *
5972 * Return: None
5973 */
5974static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5975 uint32_t *msg_buf)
5976{
5977 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5978 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005979 uint8_t session_id;
5980 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005981 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005982
5983 if (msg_buf == NULL) {
5984 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5985 return;
5986 }
5987
5988 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5989 session_entry = pe_find_session_by_bssid(mac_ctx,
5990 dfs_csa_ie_req->bssid, &session_id);
5991 if (session_entry == NULL) {
5992 lim_log(mac_ctx, LOGE, FL(
5993 "Session not found for given BSSID" MAC_ADDRESS_STR),
5994 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5995 return;
5996 }
5997
5998 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
5999 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
6000 GET_LIM_SYSTEM_ROLE(session_entry));
6001 return;
6002 }
6003
6004 /* target channel */
6005 session_entry->gLimChannelSwitch.primaryChannel =
6006 dfs_csa_ie_req->targetChannel;
6007
6008 /* Channel switch announcement needs to be included in beacon */
6009 session_entry->dfsIncludeChanSwIe = true;
6010 session_entry->gLimChannelSwitch.switchCount = LIM_MAX_CSA_IE_UPDATES;
6011 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006012 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05306013 session_entry->gLimChannelSwitch.sec_ch_offset =
6014 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006015 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
6016 session_entry->gLimChannelSwitch.switchMode = 1;
6017
6018 /*
6019 * Validate if SAP is operating HT or VHT mode and set the Channel
6020 * Switch Wrapper element with the Wide Band Switch subelement.
6021 */
6022 if (true != session_entry->vhtCapability)
6023 goto skip_vht;
6024
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006025 /* Now encode the Wider Ch BW element depending on the ch width */
6026 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006027 switch (dfs_csa_ie_req->ch_params.ch_width) {
6028 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006029 /*
6030 * Wide channel BW sublement in channel wrapper element is not
6031 * required in case of 20 Mhz operation. Currently It is set
6032 * only set in case of 40/80 Mhz Operation.
6033 */
6034 session_entry->dfsIncludeChanWrapperIe = false;
6035 wider_bw_ch_switch->newChanWidth =
6036 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
6037 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006038 case CH_WIDTH_40MHZ:
6039 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006040 wider_bw_ch_switch->newChanWidth =
6041 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
6042 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006043 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006044 session_entry->dfsIncludeChanWrapperIe = true;
6045 wider_bw_ch_switch->newChanWidth =
6046 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
6047 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006048 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006049 session_entry->dfsIncludeChanWrapperIe = true;
6050 wider_bw_ch_switch->newChanWidth =
6051 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
6052 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006053 case CH_WIDTH_80P80MHZ:
6054 session_entry->dfsIncludeChanWrapperIe = true;
6055 wider_bw_ch_switch->newChanWidth =
6056 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08006057 /*
6058 * This is not applicable for 20/40/80 Mhz.
6059 * Only used when we support 80+80 Mhz operation.
6060 * In case of 80+80 Mhz, this parameter indicates
6061 * center channel frequency index of 80 Mhz channel of
6062 * frequency segment 1.
6063 */
6064 wider_bw_ch_switch->newCenterChanFreq1 =
6065 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006066 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006067 default:
6068 session_entry->dfsIncludeChanWrapperIe = false;
6069 /*
6070 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
6071 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
6072 */
6073 lim_log(mac_ctx, LOGE, FL("Invalid Channel Width"));
6074 break;
6075 }
6076 /* Fetch the center channel based on the channel width */
6077 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006078 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006079skip_vht:
6080 /* Send CSA IE request from here */
6081 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6082 eSIR_SUCCESS) {
6083 lim_log(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
6084 return;
6085 }
6086
6087 /*
6088 * First beacon update request is sent here, the remaining updates are
6089 * done when the FW responds back after sending the first beacon after
6090 * the template update
6091 */
6092 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306093
6094 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
6095 ch_offset = BW80;
6096 else
6097 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
6098
6099 lim_log(mac_ctx, LOG1, FL("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d"),
6100 session_entry->gLimChannelSwitch.switchCount,
6101 session_entry->gLimChannelSwitch.primaryChannel,
6102 session_entry->gLimChannelSwitch.ch_width,
6103 session_entry->dfsIncludeChanWrapperIe,
6104 ch_offset);
6105
Abhishek Singh518323d2015-10-19 17:42:01 +05306106 /* Send ECSA Action frame after updating the beacon */
6107 send_extended_chan_switch_action_frame(mac_ctx,
6108 session_entry->gLimChannelSwitch.primaryChannel,
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306109 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006110 session_entry->gLimChannelSwitch.switchCount--;
6111}
6112
6113/**
Abhishek Singh518323d2015-10-19 17:42:01 +05306114 * lim_process_ext_change_channel()- function to send ECSA
6115 * action frame for STA/CLI .
6116 * @mac_ctx: pointer to global mac structure
6117 * @msg: params from sme for new channel.
6118 *
6119 * This function is called to send ECSA frame for STA/CLI.
6120 *
6121 * Return: void
6122 */
6123
6124static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
6125 uint32_t *msg)
6126{
6127 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
6128 (struct sir_sme_ext_cng_chan_req *) msg;
6129 tpPESession session_entry = NULL;
6130
6131 if (NULL == msg) {
6132 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6133 return;
6134 }
6135 session_entry =
6136 pe_find_session_by_sme_session_id(mac_ctx,
6137 ext_chng_channel->session_id);
6138 if (NULL == session_entry) {
6139 lim_log(mac_ctx, LOGE,
6140 FL("Session not found for given session %d"),
6141 ext_chng_channel->session_id);
6142 return;
6143 }
6144 if (LIM_IS_AP_ROLE(session_entry)) {
6145 lim_log(mac_ctx, LOGE,
6146 FL("not an STA/CLI session"));
6147 return;
6148 }
6149 send_extended_chan_switch_action_frame(mac_ctx,
6150 ext_chng_channel->new_channel,
6151 0, session_entry);
6152}
6153
6154/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006155 * lim_process_nss_update_request() - process sme nss update req
6156 *
6157 * @mac_ctx: Pointer to Global MAC structure
6158 * @msg_buf: pointer to the SME message buffer
6159 *
6160 * This function processes SME request messages from HDD or upper layer
6161 * application.
6162 *
6163 * Return: None
6164 */
6165static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
6166 uint32_t *msg_buf)
6167{
6168 struct sir_nss_update_request *nss_update_req_ptr;
6169 tpPESession session_entry = NULL;
6170
6171 if (msg_buf == NULL) {
6172 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6173 return;
6174 }
6175
6176 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05306177 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006178 nss_update_req_ptr->vdev_id);
6179 if (session_entry == NULL) {
6180 lim_log(mac_ctx, LOGE, FL(
6181 "Session not found for given session_id %d"),
6182 nss_update_req_ptr->vdev_id);
6183 return;
6184 }
6185
6186 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6187 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
6188 GET_LIM_SYSTEM_ROLE(session_entry));
6189 return;
6190 }
6191
6192 /* populate nss field in the beacon */
6193 session_entry->gLimOperatingMode.present = 1;
6194 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
6195 /* Send nss update request from here */
6196 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6197 eSIR_SUCCESS) {
6198 lim_log(mac_ctx, LOGE,
6199 FL("Unable to set op mode IE in beacon"));
6200 return;
6201 }
6202
6203 lim_send_beacon_ind(mac_ctx, session_entry);
6204}
6205
6206/**
6207 * lim_process_set_ie_req() - process sme set IE request
6208 *
6209 * @mac_ctx: Pointer to Global MAC structure
6210 * @msg_buf: pointer to the SME message buffer
6211 *
6212 * This function processes SME request messages from HDD or upper layer
6213 * application.
6214 *
6215 * Return: None
6216 */
6217static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6218{
6219 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306220 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006221
6222 if (msg_buf == NULL) {
6223 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6224 return;
6225 }
6226
6227 msg = (struct send_extcap_ie *)msg_buf;
6228 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306229 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006230 lim_log(mac_ctx, LOGE, FL("Unable to send ExtCap to FW"));
6231
6232}