blob: c654b91d6983a06f92790db254fb338795397485 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05302 * Copyright (c) 2012-2017 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 *);
Rajeev Kumarfeb96382017-01-22 19:42:09 -080084static bool __lim_process_sme_start_bss_req(tpAniSirGlobal,
85 struct scheduler_msg *pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080086static void __lim_process_sme_scan_req(tpAniSirGlobal, uint32_t *);
87static void __lim_process_sme_join_req(tpAniSirGlobal, uint32_t *);
88static void __lim_process_sme_reassoc_req(tpAniSirGlobal, uint32_t *);
89static void __lim_process_sme_disassoc_req(tpAniSirGlobal, uint32_t *);
90static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal, uint32_t *);
91static void __lim_process_sme_deauth_req(tpAniSirGlobal, uint32_t *);
92static void __lim_process_sme_set_context_req(tpAniSirGlobal, uint32_t *);
Rajeev Kumarfeb96382017-01-22 19:42:09 -080093static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal,
94 struct scheduler_msg *pMsg);
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053095static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
96 uint32_t *msg_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080097static void lim_process_sme_channel_change_request(tpAniSirGlobal pMac,
98 uint32_t *pMsg);
99static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg);
100static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal pMac, uint32_t *pMsg);
101static void lim_process_nss_update_request(tpAniSirGlobal pMac, uint32_t *pMsg);
102static void lim_process_set_ie_req(tpAniSirGlobal pMac, uint32_t *pMsg);
103
104static void lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
105 uint8_t **pDstData_buff,
106 uint16_t *pDstDataLen,
107 uint8_t *pSrcData_buff,
108 uint16_t srcDataLen);
109
110static void lim_update_add_ie_buffer(tpAniSirGlobal pMac,
111 uint8_t **pDstData_buff,
112 uint16_t *pDstDataLen,
113 uint8_t *pSrcData_buff, uint16_t srcDataLen);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800114static bool lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac,
115 uint8_t **pDstData_buff,
116 uint16_t *pDstDataLen,
117 tSirModifyIE *pModifyIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800118static void lim_process_modify_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
119
120static void lim_process_update_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
121
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;
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800137 struct scheduler_msg message;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800138 struct sir_hw_mode *req_msg;
139 uint32_t len;
140 struct s_sir_set_hw_mode *buf;
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800141 struct scheduler_msg resp_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800142 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
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800162 req_msg->hw_mode_index = buf->set_hw.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530163 req_msg->reason = buf->set_hw.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800164 /* Other parameters are not needed for WMA */
165
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800166 message.bodyptr = req_msg;
167 message.type = SIR_HAL_PDEV_SET_HW_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800168
169 lim_log(mac, LOG1, FL("Posting SIR_HAL_SOC_SET_HW_MOD to WMA"));
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800170 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530171 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800172 lim_log(mac, LOGE,
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800173 FL("scheduler_post_msg failed!(err=%d)"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800174 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530175 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800176 goto fail;
177 }
178 return status;
179fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530180 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800181 if (!param) {
182 lim_log(mac, LOGE, FL("HW mode resp failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530183 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800184 }
185 param->status = SET_HW_MODE_STATUS_ECANCELED;
186 param->cfgd_hw_mode_index = 0;
187 param->num_vdev_mac_entries = 0;
188 resp_msg.type = eWNI_SME_SET_HW_MODE_RESP;
189 resp_msg.bodyptr = param;
190 resp_msg.bodyval = 0;
191 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530192 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800193}
194
195/**
196 * lim_process_set_dual_mac_cfg_req() - Set dual mac config command to WMA
197 * @mac: Global MAC pointer
198 * @msg: Message containing the dual mac config parameter
199 *
200 * Send the set dual mac config command to WMA
201 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530202 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800203 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530204static QDF_STATUS lim_process_set_dual_mac_cfg_req(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800205 uint32_t *msg)
206{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530207 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800208 struct scheduler_msg message;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800209 struct sir_dual_mac_config *req_msg;
210 uint32_t len;
211 struct sir_set_dual_mac_cfg *buf;
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800212 struct scheduler_msg resp_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800213 struct sir_dual_mac_config_resp *param;
214
215 buf = (struct sir_set_dual_mac_cfg *) msg;
216 if (!buf) {
217 lim_log(mac, LOGE, FL("Set Dual mac config is NULL"));
218 /* To free the active command list */
219 goto fail;
220 }
221
222 len = sizeof(*req_msg);
223
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530224 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800225 if (!req_msg) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700226 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227 /* Free the active command list
228 * Probably the malloc is going to fail there as well?!
229 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530230 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800231 }
232
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800233 req_msg->scan_config = buf->set_dual_mac.scan_config;
234 req_msg->fw_mode_config = buf->set_dual_mac.fw_mode_config;
235 /* Other parameters are not needed for WMA */
236
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800237 message.bodyptr = req_msg;
238 message.type = SIR_HAL_PDEV_DUAL_MAC_CFG_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800239
240 lim_log(mac, LOG1,
Manishekar Chandrasekaran5d46f702016-04-27 12:50:52 +0530241 FL("Post SIR_HAL_PDEV_DUAL_MAC_CFG_REQ to WMA: %x %x"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800242 req_msg->scan_config, req_msg->fw_mode_config);
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800243 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530244 if (!QDF_IS_STATUS_SUCCESS(status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800245 lim_log(mac, LOGE,
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800246 FL("scheduler_post_msg failed!(err=%d)"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800247 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530248 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800249 goto fail;
250 }
251 return status;
252fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530253 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800254 if (!param) {
255 lim_log(mac, LOGE, FL("Dual mac config resp failed"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530256 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800257 }
258 param->status = SET_HW_MODE_STATUS_ECANCELED;
259 resp_msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
260 resp_msg.bodyptr = param;
261 resp_msg.bodyval = 0;
262 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530263 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800264}
265
266/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800267 * lim_process_set_antenna_mode_req() - Set antenna mode command
268 * to WMA
269 * @mac: Global MAC pointer
270 * @msg: Message containing the antenna mode parameter
271 *
272 * Send the set antenna mode command to WMA
273 *
274 * Return: QDF_STATUS_SUCCESS if message posting is successful
275 */
276static QDF_STATUS lim_process_set_antenna_mode_req(tpAniSirGlobal mac,
277 uint32_t *msg)
278{
279 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800280 struct scheduler_msg message;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800281 struct sir_antenna_mode_param *req_msg;
282 struct sir_set_antenna_mode *buf;
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800283 struct scheduler_msg resp_msg;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800284 struct sir_antenna_mode_resp *param;
285
286 buf = (struct sir_set_antenna_mode *) msg;
287 if (!buf) {
288 lim_log(mac, LOGE, FL("Set antenna mode is NULL"));
289 /* To free the active command list */
290 goto fail;
291 }
292
293 req_msg = qdf_mem_malloc(sizeof(*req_msg));
294 if (!req_msg) {
295 lim_log(mac, LOGE, FL("qdf_mem_malloc failed"));
296 return QDF_STATUS_E_NOMEM;
297 }
298
299 req_msg->num_rx_chains = buf->set_antenna_mode.num_rx_chains;
300 req_msg->num_tx_chains = buf->set_antenna_mode.num_tx_chains;
301
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800302 message.bodyptr = req_msg;
303 message.type = SIR_HAL_SOC_ANTENNA_MODE_REQ;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800304
305 lim_log(mac, LOG1,
306 FL("Post SIR_HAL_SOC_ANTENNA_MODE_REQ to WMA: %d %d"),
307 req_msg->num_rx_chains,
308 req_msg->num_tx_chains);
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800309 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800310 if (!QDF_IS_STATUS_SUCCESS(status)) {
311 lim_log(mac, LOGE,
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800312 FL("scheduler_post_msg failed!(err=%d)"),
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800313 status);
314 qdf_mem_free(req_msg);
315 goto fail;
316 }
317 return status;
318fail:
319 param = qdf_mem_malloc(sizeof(*param));
320 if (!param) {
321 lim_log(mac, LOGE, FL("antenna mode resp failed"));
322 return QDF_STATUS_E_NOMEM;
323 }
324 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
325 resp_msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
326 resp_msg.bodyptr = param;
327 resp_msg.bodyval = 0;
328 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
329 return QDF_STATUS_SUCCESS;
330}
331
332/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800333 * __lim_fresh_scan_reqd() - determine if a fresh scan request must be issued.
334 * @mac_ctx: Pointer to Global MAC structure
335 * @return_fresh_results: Trigger fresh scan.
336 *
337 * PE will do fresh scan, if all of the active sessions are in
338 * good state (Link Est or BSS Started). If one of the sessions
339 * is not in one of the above states, then PE does not do fresh
340 * scan. If no session exists (scanning very first time),
341 * then PE will always do fresh scan if SME asks it to do that.
342 *
343 * Return: true for fresh scan results, false if in invalid state.
344 */
345static uint8_t
346__lim_fresh_scan_reqd(tpAniSirGlobal mac_ctx, uint8_t return_fresh_results)
347{
348 uint8_t valid_state = true;
349 int i;
350
351 lim_log(mac_ctx, LOG1, FL("gLimSmeState: %d, returnFreshResults 0x%x"),
352 mac_ctx->lim.gLimSmeState, return_fresh_results);
353
354 if (mac_ctx->lim.gLimSmeState != eLIM_SME_IDLE_STATE) {
355 lim_log(mac_ctx, LOG1, FL("return FALSE"));
356 return false;
357 }
358
359 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
Naveen Rawatb6a951a2016-06-21 15:02:37 -0700360
361 if (mac_ctx->lim.gpSession[i].valid == false)
362 continue;
363
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800364 lim_log(mac_ctx, LOG1,
365 FL("session %d, bsstype %d, limSystemRole %d, limSmeState %d"),
366 i, mac_ctx->lim.gpSession[i].bssType,
367 mac_ctx->lim.gpSession[i].limSystemRole,
368 mac_ctx->lim.gpSession[i].limSmeState);
Naveen Rawatb6a951a2016-06-21 15:02:37 -0700369
370 if (mac_ctx->lim.gpSession[i].bssType == eSIR_NDI_MODE)
371 continue;
372
373 if (mac_ctx->lim.gpSession[i].bssType ==
374 eSIR_INFRASTRUCTURE_MODE &&
375 mac_ctx->lim.gpSession[i].limSmeState ==
376 eLIM_SME_LINK_EST_STATE)
377 continue;
378
379 if (mac_ctx->lim.gpSession[i].bssType == eSIR_IBSS_MODE &&
380 mac_ctx->lim.gpSession[i].limSmeState ==
381 eLIM_SME_NORMAL_STATE)
382 continue;
383
384 if (mac_ctx->lim.gpSession[i].bssType == eSIR_INFRA_AP_MODE &&
385 mac_ctx->lim.gpSession[i].pePersona ==
386 QDF_P2P_GO_MODE &&
387 mac_ctx->lim.gpSession[i].limSmeState ==
388 eLIM_SME_NORMAL_STATE)
389 continue;
390
391 if (mac_ctx->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE &&
392 mac_ctx->lim.gpSession[i].limSmeState ==
393 eLIM_SME_NORMAL_STATE)
394 continue;
395
396 valid_state = false;
397 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800398 }
399
400 lim_log(mac_ctx, LOG1, FL("valid_state: %d"), valid_state);
401
402 if ((valid_state) &&
403 (return_fresh_results & SIR_BG_SCAN_RETURN_FRESH_RESULTS))
404 return true;
405 else
406 return false;
407}
408
409/**
410 * __lim_is_sme_assoc_cnf_valid()
411 *
412 ***FUNCTION:
413 * This function is called by __lim_process_sme_assoc_cnf_new() upon
414 * receiving SME_ASSOC_CNF.
415 *
416 ***LOGIC:
417 * Message validity checks are performed in this function
418 *
419 ***ASSUMPTIONS:
420 *
421 ***NOTE:
422 *
423 * @param pMeasReq Pointer to Received ASSOC_CNF message
424 * @return true When received SME_ASSOC_CNF is formatted
425 * correctly
426 * false otherwise
427 */
428
429static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
430{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530431 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800432 return false;
433 else
434 return true;
435} /*** end __lim_is_sme_assoc_cnf_valid() ***/
436
437/**
438 * __lim_get_sme_join_req_size_for_alloc()
439 *
440 ***FUNCTION:
441 * This function is called in various places to get IE length
442 * from tSirBssDescription structure
443 * number being scanned.
444 *
445 ***PARAMS:
446 *
447 ***LOGIC:
448 *
449 ***ASSUMPTIONS:
450 * NA
451 *
452 ***NOTE:
453 * NA
454 *
455 * @param pBssDescr
456 * @return Total IE length
457 */
458
459static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
460{
461 uint16_t len = 0;
462
463 if (!pBuf)
464 return len;
465
466 pBuf += sizeof(uint16_t);
467 len = lim_get_u16(pBuf);
468 return len + sizeof(uint16_t);
469}
470
471/**
472 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
473 * @pMac: Global MAC context
474 * @pMsg: Pointer to message posted from SME to LIM.
475 *
476 * Has role only if 11h is enabled. Not used on STA side.
477 * Defers the message if SME is in learn state and brings
478 * the LIM back to normal mode.
479 *
480 * Return: true - If defered false - Otherwise
481 */
482
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800483static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac,
484 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800485{
486 if (lim_is_system_in_scan_state(pMac)) {
487 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
488 lim_log(pMac, LOGE, FL("Could not defer Msg = %d"),
489 pMsg->type);
490 return false;
491 }
492 lim_log(pMac, LOG1,
493 FL("Defer the message, in learn mode type = %d"),
494 pMsg->type);
495 return true;
496 }
497 return false;
498}
499
500/**
501 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
502 * @mac_ctx: Pointer to Global MAC structure
503 * @message: Pointer to message posted from SME to LIM.
504 *
505 * Has role only if 11h is enabled. Not used on STA side.
506 * Defers the message if radar is detected.
507 *
508 * Return: true, if defered otherwise return false.
509 */
510static bool
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800511__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx,
512 struct scheduler_msg *message)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800513{
514 /*
515 * fRadarDetCurOperChan will be set only if we
516 * detect radar in current operating channel and
517 * System Role == AP ROLE
518 *
519 * TODO: Need to take care radar detection.
520 *
521 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
522 */
523 if (0) {
524 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
525 lim_log(mac_ctx, LOGE, FL("Could not defer Msg = %d"),
526 message->type);
527 return false;
528 }
529 lim_log(mac_ctx, LOG1,
530 FL("Defer the message, in learn mode type = %d"),
531 message->type);
532 return true;
533 }
534 return false;
535}
536
537/**
538 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
539 * @pMac: Global MAC context
540 * @pMsgBuf: Message from WMA
541 *
542 * handles the notification from HDD. PE just forwards this message to HAL.
543 *
544 * Return: true-Posting to HAL failed, so PE will consume the buffer.
545 * false-Posting to HAL successful, so HAL will consume the buffer.
546 */
547
548static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
549{
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800550 struct scheduler_msg msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800551 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
552
553 msg.type = WMA_SYS_READY_IND;
554 msg.reserved = 0;
555 msg.bodyptr = pMsgBuf;
556 msg.bodyval = 0;
557
558 if (ANI_DRIVER_TYPE(pMac) != eDRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800559 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +0530560 pe_register_mgmt_rx_frm_callback(pMac);
Naveen Rawat0fc3f692016-06-22 14:30:54 -0700561 pe_register_callbacks_with_wma(pMac, ready_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800562 pMac->lim.add_bssdescr_callback = ready_req->add_bssdescr_cb;
563 }
564 PELOGW(lim_log(pMac, LOGW, FL("sending WMA_SYS_READY_IND msg to HAL"));)
565 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
566
567 if (eSIR_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
568 lim_log(pMac, LOGP, FL("wma_post_ctrl_msg failed"));
569 return true;
570 }
571 return false;
572}
573
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800574/**
575 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
576 *@mac_ctx: Pointer to Global MAC structure
577 *@session: A pointer to session entry
578 *@sme_start_bss_req: Start BSS Request from upper layers.
579 *
580 * This function is used to configure the start bss parameters
581 * in to the session.
582 *
583 * Return: None.
584 */
585static void
586lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
587 tpSirSmeStartBssReq sme_start_bss_req)
588{
589 session->limSystemRole = eLIM_AP_ROLE;
590 session->privacy = sme_start_bss_req->privacy;
591 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
592 session->authType = sme_start_bss_req->authType;
593 /* Store the DTIM period */
594 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
595 /* Enable/disable UAPSD */
596 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530597 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800598 session->proxyProbeRspEn = 0;
599 } else {
600 /*
601 * To detect PBC overlap in SAP WPS mode,
602 * Host handles Probe Requests.
603 */
604 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
605 session->proxyProbeRspEn = 1;
606 else
607 session->proxyProbeRspEn = 0;
608 }
609 session->ssidHidden = sme_start_bss_req->ssidHidden;
610 session->wps_state = sme_start_bss_req->wps_state;
611 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +0530612 session->vendor_vht_sap =
613 sme_start_bss_req->vendor_vht_sap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800614 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
615 &session->shortSlotTimeSupported);
616 session->isCoalesingInIBSSAllowed =
617 sme_start_bss_req->isCoalesingInIBSSAllowed;
618
619}
620
621/**
622 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
623 *@mac_ctx: Pointer to Global MAC structure
624 *@msg_buf: A pointer to the SME message buffer
625 *
626 * This function is called to process SME_START_BSS_REQ message
627 * from HDD or upper layer application.
628 *
629 * Return: None
630 */
631static void
632__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
633{
634 uint16_t size;
635 uint32_t val = 0;
636 tSirRetStatus ret_status;
637 tSirMacChanNum channel_number;
638 tLimMlmStartReq *mlm_start_req = NULL;
639 tpSirSmeStartBssReq sme_start_bss_req = NULL;
640 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
641 /* Flag Used in case of IBSS to Auto generate BSSID. */
642 uint32_t auto_gen_bssid = false;
643 uint8_t session_id;
644 tpPESession session = NULL;
Krunal Sonib37bb352016-12-20 14:12:21 -0800645 uint8_t sme_session_id = 0xFF;
646 uint16_t sme_transaction_id = 0xFF;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800647 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700648 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800649 tSirRetStatus cfg_get_wmi_dfs_master_param = eSIR_SUCCESS;
650
651/* FEATURE_WLAN_DIAG_SUPPORT */
652#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
653 /*
654 * Since the session is not created yet, sending NULL.
655 * The response should have the correct state.
656 */
657 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
658 NULL, 0, 0);
659#endif /* FEATURE_WLAN_DIAG_SUPPORT */
660
661 lim_log(mac_ctx, LOG1, FL("Received START_BSS_REQ"));
Krunal Sonib37bb352016-12-20 14:12:21 -0800662 size = sizeof(tSirSmeStartBssReq);
663 sme_start_bss_req = qdf_mem_malloc(size);
664 if (NULL == sme_start_bss_req) {
665 lim_log(mac_ctx, LOGE,
666 FL("Allocate Memory fail for LimStartBssReq"));
667 /* Send failure response to host */
668 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
669 goto free;
670 }
671 qdf_mem_copy(sme_start_bss_req, msg_buf, sizeof(tSirSmeStartBssReq));
672 sme_session_id = sme_start_bss_req->sessionId;
673 sme_transaction_id = sme_start_bss_req->transactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800674
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800675 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
676 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800677 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
678 sme_start_bss_req)) {
679 lim_log(mac_ctx, LOGW,
680 FL("Received invalid eWNI_SME_START_BSS_REQ"));
681 ret_code = eSIR_SME_INVALID_PARAMETERS;
682 goto free;
683 }
684
685 /*
686 * This is the place where PE is going to create a session.
687 * If session is not existed, then create a new session
688 */
689 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800690 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800691 if (session != NULL) {
692 lim_log(mac_ctx, LOGW,
693 FL("Session Already exists for given BSSID"));
694 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
695 session = NULL;
696 goto free;
697 } else {
698 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800699 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800700 &session_id, mac_ctx->lim.maxStation,
701 sme_start_bss_req->bssType);
702 if (session == NULL) {
703 lim_log(mac_ctx, LOGW,
704 FL("Session Can not be created "));
705 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
706 goto free;
707 }
708 }
709
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700710 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
711 /* Probe resp add ie */
712 lim_start_bss_update_add_ie_buffer(mac_ctx,
713 &session->addIeParams.probeRespData_buff,
714 &session->addIeParams.probeRespDataLen,
715 sme_start_bss_req->addIeParams.
716 probeRespData_buff,
717 sme_start_bss_req->addIeParams.
718 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800719
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700720 /* Probe Beacon add ie */
721 lim_start_bss_update_add_ie_buffer(mac_ctx,
722 &session->addIeParams.probeRespBCNData_buff,
723 &session->addIeParams.probeRespBCNDataLen,
724 sme_start_bss_req->addIeParams.
725 probeRespBCNData_buff,
726 sme_start_bss_req->addIeParams.
727 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800728
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700729 /* Assoc resp IE */
730 lim_start_bss_update_add_ie_buffer(mac_ctx,
731 &session->addIeParams.assocRespData_buff,
732 &session->addIeParams.assocRespDataLen,
733 sme_start_bss_req->addIeParams.
734 assocRespData_buff,
735 sme_start_bss_req->addIeParams.
736 assocRespDataLen);
737 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800738 /* Store the session related params in newly created session */
739 session->pLimStartBssReq = sme_start_bss_req;
740
741 /* Store PE session_id in session Table */
742 session->peSessionId = session_id;
743
744 /* Store SME session Id in sessionTable */
745 session->smeSessionId = sme_start_bss_req->sessionId;
746
747 session->transactionId = sme_start_bss_req->transactionId;
748
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530749 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800750 &(sme_start_bss_req->htConfig),
751 sizeof(session->htConfig));
752
Sandeep Puligilla98917432016-06-10 13:50:28 -0700753 qdf_mem_copy(&(session->vht_config),
754 &(sme_start_bss_req->vht_config),
755 sizeof(session->vht_config));
756
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800757 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800758 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800759
760 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530761 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800762 (uint8_t *) &sme_start_bss_req->ssId,
763 (sme_start_bss_req->ssId.length + 1));
764
765 session->bssType = sme_start_bss_req->bssType;
766
767 session->nwType = sme_start_bss_req->nwType;
768
769 session->beaconParams.beaconInterval =
770 sme_start_bss_req->beaconInterval;
771
772 /* Store the channel number in session Table */
773 session->currentOperChannel =
774 sme_start_bss_req->channelId;
775
776 /* Store Persona */
777 session->pePersona = sme_start_bss_req->bssPersona;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530778 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800779 FL("PE PERSONA=%d"), session->pePersona);
780
781 /* Update the phymode */
782 session->gLimPhyMode = sme_start_bss_req->nwType;
783
784 session->maxTxPower =
785 cfg_get_regulatory_max_transmit_power(mac_ctx,
786 session->currentOperChannel);
787 /* Store the dot 11 mode in to the session Table */
788 session->dot11mode = sme_start_bss_req->dot11mode;
789#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
790 session->cc_switch_mode =
791 sme_start_bss_req->cc_switch_mode;
792#endif
793 session->htCapability =
794 IS_DOT11_MODE_HT(session->dot11mode);
795 session->vhtCapability =
796 IS_DOT11_MODE_VHT(session->dot11mode);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530797 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800798 FL("*****session->vhtCapability = %d"),
799 session->vhtCapability);
800 session->txLdpcIniFeatureEnabled =
801 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800802#ifdef WLAN_FEATURE_11W
803 session->limRmfEnabled =
804 sme_start_bss_req->pmfCapable ? 1 : 0;
805 lim_log(mac_ctx, LOG1, FL("Session RMF enabled: %d"),
806 session->limRmfEnabled);
807#endif
808
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530809 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800810 (void *)&sme_start_bss_req->operationalRateSet,
811 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530812 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800813 (void *)&sme_start_bss_req->extendedRateSet,
814 sizeof(tSirMacRateSet));
815
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700816 if (IS_5G_CH(session->currentOperChannel))
817 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
818 else
819 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
820
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800821 switch (sme_start_bss_req->bssType) {
822 case eSIR_INFRA_AP_MODE:
823 lim_configure_ap_start_bss_session(mac_ctx, session,
824 sme_start_bss_req);
Krunal Soni53993f72016-07-08 18:20:03 -0700825 if (session->pePersona == QDF_SAP_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700826 session->vdev_nss = vdev_type_nss->sap;
Krunal Soni53993f72016-07-08 18:20:03 -0700827 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700828 session->vdev_nss = vdev_type_nss->p2p_go;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800829 break;
830 case eSIR_IBSS_MODE:
831 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
832 lim_get_short_slot_from_phy_mode(mac_ctx, session,
833 session->gLimPhyMode,
834 &session->shortSlotTimeSupported);
835
836 /*
837 * initialize to "OPEN".
838 * will be updated upon key installation
839 */
840 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700841 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800842
843 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700844 case eSIR_NDI_MODE:
845 session->limSystemRole = eLIM_NDI_ROLE;
846 break;
847
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800848
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800849 /*
850 * There is one more mode called auto mode.
851 * which is used no where
852 */
853
854 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
855
856 default:
857 /* not used anywhere...used in scan function */
858 break;
859 }
860
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700861 lim_log(mac_ctx, LOG1, FL("persona - %d, nss - %d"),
862 session->pePersona, session->vdev_nss);
863 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800864 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700865 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800866 * parsed (Re)Assoc request structure
867 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700868 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800869 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530870 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700871 size * sizeof(tpSirAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800872 if (NULL == session->parsedAssocReq) {
873 lim_log(mac_ctx, LOGW,
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700874 FL("AllocateMemory() failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800875 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
876 goto free;
877 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800878 }
879
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700880 if (!sme_start_bss_req->channelId &&
881 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800882 lim_log(mac_ctx, LOGE,
883 FL("Received invalid eWNI_SME_START_BSS_REQ"));
884 ret_code = eSIR_SME_INVALID_PARAMETERS;
885 goto free;
886 }
887 channel_number = sme_start_bss_req->channelId;
888#ifdef QCA_HT_2040_COEX
889 if (sme_start_bss_req->obssEnabled)
890 session->htSupportedChannelWidthSet =
891 session->htCapability;
892 else
893#endif
894 session->htSupportedChannelWidthSet =
895 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
896 session->htSecondaryChannelOffset =
897 sme_start_bss_req->sec_ch_offset;
898 session->htRecommendedTxWidthSet =
899 (session->htSecondaryChannelOffset) ? 1 : 0;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530900 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800901 FL("cbMode %u"), sme_start_bss_req->cbMode);
902 if (session->vhtCapability || session->htCapability) {
903 chanwidth = sme_start_bss_req->vht_channel_width;
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800904 lim_log(mac_ctx, LOG1,
905 FL("vht_channel_width %u htSupportedChannelWidthSet %d"),
906 sme_start_bss_req->vht_channel_width,
907 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800908 session->ch_width = chanwidth;
909 if (session->htSupportedChannelWidthSet) {
910 session->ch_center_freq_seg0 =
911 sme_start_bss_req->center_freq_seg0;
912 session->ch_center_freq_seg1 =
913 sme_start_bss_req->center_freq_seg1;
914 } else {
915 session->ch_center_freq_seg0 = 0;
916 session->ch_center_freq_seg1 = 0;
917 }
918 }
919
920 if (session->vhtCapability &&
Krunal Soni53993f72016-07-08 18:20:03 -0700921 (session->ch_width > CH_WIDTH_80MHZ)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800922 session->nss = 1;
Krunal Soni53993f72016-07-08 18:20:03 -0700923 lim_log(mac_ctx, LOG1, FL("nss set to [%d]"),
924 session->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800925 }
Krunal Soni53993f72016-07-08 18:20:03 -0700926 lim_log(mac_ctx, LOG1, FL("vht su tx bformer %d"),
927 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800928
929 /* Delete pre-auth list if any */
930 lim_delete_pre_auth_list(mac_ctx);
931
Krunal Soni53993f72016-07-08 18:20:03 -0700932 if (session->nss == 1) {
933 session->vht_config.su_beam_former = 0;
934 session->vht_config.tx_stbc = 0;
935 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530936 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -0700937 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800938 /*
939 * keep the RSN/WPA IE information in PE Session Entry
940 * later will be using this to check when received (Re)Assoc req
941 */
942 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
943 &sme_start_bss_req->rsnIE, session);
944
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700945 if (LIM_IS_AP_ROLE(session) ||
946 LIM_IS_IBSS_ROLE(session) ||
947 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800948 session->gLimProtectionControl =
949 sme_start_bss_req->protEnabled;
950 /*
951 * each byte will have the following info
952 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
953 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
954 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530955 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800956 (void *)&sme_start_bss_req->ht_capab,
957 sizeof(uint16_t));
958 /* Initialize WPS PBC session link list */
959 session->pAPWPSPBCSession = NULL;
960 }
961 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530962 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800963 if (NULL == mlm_start_req) {
964 lim_log(mac_ctx, LOGP,
965 FL("Allocate Memory failed for mlmStartReq"));
966 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
967 goto free;
968 }
969
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800970 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530971 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800972 (uint8_t *) &sme_start_bss_req->ssId,
973 sme_start_bss_req->ssId.length + 1);
974 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
975 mlm_start_req->obssProtEnabled =
976 sme_start_bss_req->obssProtEnabled;
977
978 mlm_start_req->bssType = session->bssType;
979
980 /* Fill PE session Id from the session Table */
981 mlm_start_req->sessionId = session->peSessionId;
982
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700983 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
984 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800985 /*
986 * Copy the BSSId from sessionTable to
987 * mlmStartReq struct
988 */
989 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
990 } else {
991 /* ibss mode */
992 mac_ctx->lim.gLimIbssCoalescingHappened = false;
993
994 ret_status = wlan_cfg_get_int(mac_ctx,
995 WNI_CFG_IBSS_AUTO_BSSID,
996 &auto_gen_bssid);
997 if (ret_status != eSIR_SUCCESS) {
998 lim_log(mac_ctx, LOGP,
999 FL("Get Auto Gen BSSID fail,Status=%d"),
1000 ret_status);
1001 ret_code = eSIR_LOGP_EXCEPTION;
1002 goto free;
1003 }
1004
1005 if (!auto_gen_bssid) {
1006 /*
1007 * We're not auto generating BSSID.
1008 * Instead, get it from session entry
1009 */
1010 sir_copy_mac_addr(mlm_start_req->bssId,
1011 session->bssId);
1012 /*
1013 * Start IBSS group BSSID
1014 * Auto Generating BSSID.
1015 */
1016 auto_gen_bssid = ((mlm_start_req->bssId[0] &
1017 0x01) ? true : false);
1018 }
1019
1020 if (auto_gen_bssid) {
1021 /*
1022 * if BSSID is not any uc id.
1023 * then use locally generated BSSID.
1024 * Autogenerate the BSSID
1025 */
1026 lim_get_random_bssid(mac_ctx,
1027 mlm_start_req->bssId);
1028 mlm_start_req->bssId[0] = 0x02;
1029
1030 /*
1031 * Copy randomly generated BSSID
1032 * to the session Table
1033 */
1034 sir_copy_mac_addr(session->bssId,
1035 mlm_start_req->bssId);
1036 }
1037 }
1038 /* store the channel num in mlmstart req structure */
1039 mlm_start_req->channelNumber = session->currentOperChannel;
1040 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
1041 mlm_start_req->beaconPeriod =
1042 session->beaconParams.beaconInterval;
1043
1044 if (LIM_IS_AP_ROLE(session)) {
1045 mlm_start_req->dtimPeriod = session->dtimPeriod;
1046 mlm_start_req->wps_state = session->wps_state;
1047
1048 } else {
1049 if (wlan_cfg_get_int(mac_ctx,
1050 WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
1051 lim_log(mac_ctx, LOGP,
1052 FL("could not retrieve DTIM Period"));
1053 mlm_start_req->dtimPeriod = (uint8_t) val;
1054 }
1055
1056 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_PERIOD, &val) !=
1057 eSIR_SUCCESS)
1058 lim_log(mac_ctx, LOGP,
1059 FL("could not retrieve Beacon interval"));
1060 mlm_start_req->cfParamSet.cfpPeriod = (uint8_t) val;
1061
1062 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_MAX_DURATION, &val) !=
1063 eSIR_SUCCESS)
1064 lim_log(mac_ctx, LOGP,
1065 FL("could not retrieve CFPMaxDuration"));
1066 mlm_start_req->cfParamSet.cfpMaxDuration = (uint16_t) val;
1067
1068 /*
1069 * this may not be needed anymore now,
1070 * as rateSet is now included in the
1071 * session entry and MLM has session context.
1072 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301073 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001074 (void *)&session->rateSet,
1075 sizeof(tSirMacRateSet));
1076
1077 /* Now populate the 11n related parameters */
1078 mlm_start_req->nwType = session->nwType;
1079 mlm_start_req->htCapable = session->htCapability;
1080
1081 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1082 /* Unused */
1083 mlm_start_req->dualCTSProtection =
1084 mac_ctx->lim.gHTDualCTSProtection;
1085 mlm_start_req->txChannelWidthSet =
1086 session->htRecommendedTxWidthSet;
1087
1088 session->limRFBand = lim_get_rf_band(channel_number);
1089
1090 /* Initialize 11h Enable Flag */
1091 session->lim11hEnable = 0;
1092 if ((mlm_start_req->bssType != eSIR_IBSS_MODE) &&
1093 (SIR_BAND_5_GHZ == session->limRFBand)) {
1094 if (wlan_cfg_get_int(mac_ctx,
1095 WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
1096 lim_log(mac_ctx, LOGP,
1097 FL("Fail to get WNI_CFG_11H_ENABLED "));
1098 else
1099 session->lim11hEnable = val;
1100
1101 if (session->lim11hEnable &&
1102 (eSIR_INFRA_AP_MODE ==
1103 mlm_start_req->bssType)) {
1104 cfg_get_wmi_dfs_master_param =
1105 wlan_cfg_get_int(mac_ctx,
1106 WNI_CFG_DFS_MASTER_ENABLED,
1107 &val);
1108 session->lim11hEnable = val;
1109 }
1110 if (cfg_get_wmi_dfs_master_param != eSIR_SUCCESS)
1111 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
1112 lim_log(mac_ctx, LOGE,
1113 FL("Get Fail, CFG DFS ENABLE"));
1114 }
1115
1116 if (!session->lim11hEnable) {
1117 if (cfg_set_int(mac_ctx,
1118 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
1119 eSIR_SUCCESS)
1120 /*
1121 * Failed to set the CFG param
1122 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1123 */
1124 lim_log(mac_ctx, LOGE,
1125 FL("Set LOCAL_POWER_CONSTRAINT failed"));
1126 }
1127
1128 session->limPrevSmeState = session->limSmeState;
1129 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1130 MTRACE(mac_trace
1131 (mac_ctx, TRACE_CODE_SME_STATE,
1132 session->peSessionId,
1133 session->limSmeState));
1134
1135 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1136 (uint32_t *) mlm_start_req);
1137 return;
1138 } else {
1139
1140 lim_log(mac_ctx, LOGE,
1141 FL("Received unexpected START_BSS_REQ, in state %X"),
1142 mac_ctx->lim.gLimSmeState);
1143 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
Krunal Sonib37bb352016-12-20 14:12:21 -08001144 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001145 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1146
1147free:
1148 if ((session != NULL) &&
Krunal Sonib37bb352016-12-20 14:12:21 -08001149 (session->pLimStartBssReq == sme_start_bss_req)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001150 session->pLimStartBssReq = NULL;
1151 }
Krunal Sonib37bb352016-12-20 14:12:21 -08001152 if (NULL != sme_start_bss_req)
1153 qdf_mem_free(sme_start_bss_req);
1154 if (NULL != mlm_start_req)
1155 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001156 if (NULL != session) {
1157 pe_delete_session(mac_ctx, session);
1158 session = NULL;
1159 }
1160 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1161 session, sme_session_id, sme_transaction_id);
1162}
1163
1164/**
1165 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1166 *
1167 * @pMac: Global MAC context
1168 * @pMsg: Message pointer
1169 *
1170 * Wrapper for the function __lim_handle_sme_start_bss_request
1171 * This message will be defered until softmac come out of
1172 * scan mode or if we have detected radar on the current
1173 * operating channel.
1174 *
1175 * return true - If we consumed the buffer
1176 * false - If have defered the message.
1177 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001178static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac,
1179 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001180{
1181 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1182 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1183 /**
1184 * If message defered, buffer is not consumed yet.
1185 * So return false
1186 */
1187 return false;
1188 }
1189
1190 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1191 return true;
1192}
1193
1194/**
1195 * lim_get_random_bssid()
1196 *
1197 * FUNCTION:This function is called to process generate the random number for bssid
1198 * This function is called to process SME_SCAN_REQ message
1199 * from HDD or upper layer application.
1200 *
1201 * LOGIC:
1202 *
1203 * ASSUMPTIONS:
1204 *
1205 * NOTE:
1206 * 1. geneartes the unique random number for bssid in ibss
1207 *
1208 * @param pMac Pointer to Global MAC structure
1209 * @param *data Pointer to bssid buffer
1210 * @return None
1211 */
1212void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1213{
1214 uint32_t random[2];
1215 random[0] = tx_time_get();
1216 random[0] |= (random[0] << 15);
1217 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301218 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001219}
1220
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301221static QDF_STATUS lim_send_hal_start_scan_offload_req(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001222 tpSirSmeScanReq pScanReq)
1223{
1224 tSirScanOffloadReq *pScanOffloadReq;
1225 uint8_t *p;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001226 struct scheduler_msg msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001227 uint16_t i, len;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001228 uint16_t addn_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001229 tSirRetStatus status, rc = eSIR_SUCCESS;
1230 tDot11fIEExtCap extracted_extcap = {0};
1231 bool extcap_present = true;
1232
1233 if (pScanReq->uIEFieldLen) {
1234 status = lim_strip_extcap_update_struct(pMac,
1235 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1236 &pScanReq->uIEFieldLen, &extracted_extcap);
1237
1238 if (eSIR_SUCCESS != status) {
1239 extcap_present = false;
1240 lim_log(pMac, LOG1,
1241 FL("Unable to Strip ExtCap IE from Scan Req"));
1242 }
1243
1244 if (extcap_present) {
1245 lim_log(pMac, LOG1,
1246 FL("Extcap was part of SCAN IE - Updating FW"));
1247 lim_send_ext_cap_ie(pMac, pScanReq->sessionId,
1248 &extracted_extcap, true);
1249 }
1250 } else {
1251 lim_log(pMac, LOG1,
1252 FL("No IEs in the scan request from supplicant"));
1253 }
1254
1255 /**
1256 * The tSirScanOffloadReq will reserve the space for first channel,
1257 * so allocate the memory for (numChannels - 1) and uIEFieldLen
1258 */
1259 len = sizeof(tSirScanOffloadReq) +
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001260 (pScanReq->channelList.numChannels - 1) +
1261 pScanReq->uIEFieldLen;
Naveen Rawat02e12662016-08-31 16:49:27 -07001262
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301263 pScanOffloadReq = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001264 if (NULL == pScanOffloadReq) {
1265 lim_log(pMac, LOGE,
1266 FL("AllocateMemory failed for pScanOffloadReq"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301267 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001268 }
1269
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001270 msg.type = WMA_START_SCAN_OFFLOAD_REQ;
1271 msg.bodyptr = pScanOffloadReq;
1272 msg.bodyval = 0;
1273
Anurag Chouhanc5548422016-02-24 18:33:27 +05301274 qdf_copy_macaddr(&pScanOffloadReq->bssId, &pScanReq->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001275
1276 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID) {
1277 lim_log(pMac, LOGE,
1278 FL("Invalid value (%d) for numSsid"),
1279 SIR_SCAN_MAX_NUM_SSID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301280 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301281 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001282 }
1283
1284 pScanOffloadReq->numSsid = pScanReq->numSsid;
1285 for (i = 0; i < pScanOffloadReq->numSsid; i++) {
1286 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301287 qdf_mem_copy((uint8_t *) pScanOffloadReq->ssId[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001288 (uint8_t *) pScanReq->ssId[i].ssId,
1289 pScanOffloadReq->ssId[i].length);
1290 }
1291
1292 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301293 qdf_copy_macaddr(&pScanOffloadReq->selfMacAddr, &pScanReq->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001294 pScanOffloadReq->bssType = pScanReq->bssType;
1295 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1296 pScanOffloadReq->scanType = pScanReq->scanType;
1297 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1298 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1299 pScanOffloadReq->restTime = pScanReq->restTime;
Agrawal Ashish17bb3902016-05-05 13:29:40 +05301300 pScanOffloadReq->min_rest_time = pScanReq->min_rest_time;
1301 pScanOffloadReq->idle_time = pScanReq->idle_time;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301302 pScanOffloadReq->scan_adaptive_dwell_mode =
1303 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001304
1305 /* for normal scan, the value for p2pScanType should be 0
1306 always */
1307 if (pScanReq->p2pSearch)
1308 pScanOffloadReq->p2pScanType = P2P_SCAN_TYPE_SEARCH;
1309
1310 pScanOffloadReq->sessionId = pScanReq->sessionId;
1311 pScanOffloadReq->scan_id = pScanReq->scan_id;
Deepak Dhamdhered97bfb32015-10-11 15:16:18 -07001312 pScanOffloadReq->scan_requestor_id = USER_SCAN_REQUESTOR_ID;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301313 pScanOffloadReq->scan_adaptive_dwell_mode =
1314 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001315
1316 if (pScanOffloadReq->sessionId >= pMac->lim.maxBssId)
1317 lim_log(pMac, LOGE, FL("Invalid pe sessionID : %d"),
1318 pScanOffloadReq->sessionId);
1319
1320 pScanOffloadReq->channelList.numChannels =
1321 pScanReq->channelList.numChannels;
1322 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1323 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1324 p[i] = pScanReq->channelList.channelNumber[i];
1325
1326 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1327 pScanOffloadReq->uIEFieldOffset = len - addn_ie_len -
1328 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301329 qdf_mem_copy((uint8_t *) pScanOffloadReq +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001330 pScanOffloadReq->uIEFieldOffset,
1331 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1332 pScanReq->uIEFieldLen);
Naveen Rawat02e12662016-08-31 16:49:27 -07001333
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001334 rc = wma_post_ctrl_msg(pMac, &msg);
1335 if (rc != eSIR_SUCCESS) {
1336 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() return failure"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301337 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301338 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001339 }
1340
1341 lim_log(pMac, LOG1, FL("Processed Offload Scan Request Successfully"));
1342
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301343 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001344}
1345
1346/**
1347 * __lim_process_sme_scan_req() - Process the SME Scan Request
1348 * @mac_ctx: Global MAC Context
1349 * @msg_buf: Buffer which contains the request and pertinent parameters
1350 *
1351 * This function is called to process SME_SCAN_REQ message
1352 * from HDD or upper layer application.
1353 *
1354 * Return: None
1355 */
1356
1357static void __lim_process_sme_scan_req(tpAniSirGlobal mac_ctx,
1358 uint32_t *msg_buf)
1359{
1360 tpSirSmeScanReq scan_req;
1361 uint8_t valid_req = 0;
1362
1363#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1364 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL,
1365 eSIR_SUCCESS, eSIR_SUCCESS);
1366#endif
Sreelakshmi Konamki1bb6f312016-12-08 12:32:01 +05301367 mac_ctx->lim.beacon_probe_rsp_cnt_per_scan = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001368
1369 scan_req = (tpSirSmeScanReq) msg_buf;
1370 lim_log(mac_ctx, LOG1,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301371 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 -08001372 scan_req->scan_id, scan_req->channelList.numChannels,
1373 scan_req->minChannelTime, scan_req->maxChannelTime,
1374 scan_req->uIEFieldLen, scan_req->returnAfterFirstMatch,
1375 scan_req->returnFreshResults, scan_req->returnUniqueResults,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301376 lim_scan_type_to_string(scan_req->scanType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001377 scan_req->scanType, mac_ctx->lim.gLimRspReqd ? 1 : 0);
1378 /*
1379 * Since scan req always requires a response, we will overwrite response
1380 * required here. This is added esp to take care of the condition where
1381 * in p2p go case, we hold the scan req and insert single NOA. We send
1382 * the held scan request to FW later on getting start NOA ind from FW so
1383 * we lose state of the gLimRspReqd flag for the scan req if any other
1384 * request comes by then. e.g. While unit testing, we found when insert
1385 * single NOA is done, we see a get stats request which turns the flag
1386 * gLimRspReqd to false; now when we actually start the saved scan req
1387 * for init scan after getting NOA started, the gLimRspReqd being a
1388 * global flag is showing false instead of true value for this saved
1389 * scan req. Since all scan reqs coming to lim require a response,
1390 * there is no harm in setting the global flag gLimRspReqd to true here.
1391 */
1392 mac_ctx->lim.gLimRspReqd = true;
1393
1394 /*
1395 * copy the Self MAC address from SmeReq to the globalplace,
1396 * used for sending probe req
1397 */
Srinivas Girigowda2c6bf002015-09-24 11:43:31 -07001398 sir_copy_mac_addr(mac_ctx->lim.gSelfMacAddr,
1399 scan_req->selfMacAddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001400 valid_req = lim_is_sme_scan_req_valid(mac_ctx, scan_req);
1401
1402 if (!valid_req || mac_ctx->lim.scan_disabled) {
1403 lim_log(mac_ctx, LOGE,
1404 FL("Scan disabled %d, Valid Scan Req %d"),
1405 mac_ctx->lim.scan_disabled, valid_req);
1406
1407 if (mac_ctx->lim.gLimRspReqd) {
1408 mac_ctx->lim.gLimRspReqd = false;
1409
1410 lim_send_sme_scan_rsp(mac_ctx,
1411 eSIR_SME_INVALID_PARAMETERS,
1412 scan_req->sessionId,
1413 scan_req->transactionId,
1414 scan_req->scan_id);
1415 }
1416 return;
1417 }
1418
1419 /*
1420 * If scan request is received in idle, joinFailed
1421 * states or in link established state (in STA role)
1422 * or in normal state (in STA-in-IBSS/AP role) with
1423 * 'return fresh scan results' request from HDD or
1424 * it is periodic background scanning request,
1425 * trigger fresh scan request to MLM
1426 */
1427 if (__lim_fresh_scan_reqd(mac_ctx, scan_req->returnFreshResults)) {
1428
1429 mac_ctx->lim.gLim24Band11dScanDone = 0;
1430 mac_ctx->lim.gLim50Band11dScanDone = 0;
1431 mac_ctx->lim.gLimReturnAfterFirstMatch =
1432 scan_req->returnAfterFirstMatch;
1433 mac_ctx->lim.gLimReturnUniqueResults =
1434 ((scan_req->returnUniqueResults) > 0 ? true : false);
1435
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301436 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001437 lim_send_hal_start_scan_offload_req(mac_ctx,
1438 scan_req)) {
1439 lim_log(mac_ctx, LOGE, FL(
1440 "Couldn't send Offload scan request"));
1441 lim_send_sme_scan_rsp(mac_ctx,
1442 eSIR_SME_INVALID_PARAMETERS,
1443 scan_req->sessionId,
1444 scan_req->transactionId,
1445 scan_req->scan_id);
1446 return;
1447 }
Anurag Chouhanffb21542016-02-17 14:33:03 +05301448 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001449 /* In all other cases return 'cached' scan results */
1450 if (mac_ctx->lim.gLimRspReqd) {
1451 mac_ctx->lim.gLimRspReqd = false;
1452 lim_send_sme_scan_rsp(mac_ctx, eSIR_SME_SUCCESS,
1453 scan_req->sessionId,
1454 scan_req->transactionId, scan_req->scan_id);
1455 }
1456 }
1457}
1458
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001459/**
1460 * __lim_process_clear_dfs_channel_list()
1461 *
1462 ***FUNCTION:
1463 ***Clear DFS channel list when country is changed/aquired.
1464 .*This message is sent from SME.
1465 *
1466 ***LOGIC:
1467 *
1468 ***ASSUMPTIONS:
1469 *
1470 ***NOTE:
1471 *
1472 * @param pMac Pointer to Global MAC structure
1473 * @param *pMsgBuf A pointer to the SME message buffer
1474 * @return None
1475 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001476static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac,
1477 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001478{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301479 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001480}
1481
1482/**
1483 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1484 * @mac_ctx: Pointer to Global MAC structure
1485 * @msg_buf: A pointer to the SME message buffer
1486 *
1487 * This function is called to process SME_JOIN_REQ message
1488 * from HDD or upper layer application.
1489 *
1490 * Return: None
1491 */
1492static void
1493__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1494{
1495 tpSirSmeJoinReq sme_join_req = NULL;
1496 tLimMlmJoinReq *mlm_join_req;
1497 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1498 uint32_t val = 0;
1499 uint16_t n_size;
1500 uint8_t session_id;
1501 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301502 uint8_t sme_session_id = 0;
1503 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001504 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001505 uint16_t ie_len;
1506 uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001507 tSirBssDescription *bss_desc;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001508 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001509
Arif Hussain995fcaf2016-07-18 11:28:22 -07001510 if (!mac_ctx || !msg_buf) {
1511 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1512 FL("JOIN REQ with invalid data"));
1513 return;
1514 }
1515
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001516/* FEATURE_WLAN_DIAG_SUPPORT */
1517#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1518 /*
1519 * Not sending any session, since it is not created yet.
1520 * The response whould have correct state.
1521 */
1522 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1523#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1524
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001525 /*
1526 * Expect Join request in idle state.
1527 * Reassociate request is expected in link established state.
1528 */
1529
1530 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1531 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1532 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1533 msg_buf);
1534
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301535 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001536 if (NULL == sme_join_req) {
1537 lim_log(mac_ctx, LOGP,
1538 FL("AllocateMemory failed for sme_join_req"));
1539 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301540 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001541 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301542 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001543 n_size);
1544
1545 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1546 /* Received invalid eWNI_SME_JOIN_REQ */
1547 /* Log the event */
1548 lim_log(mac_ctx, LOGW,
1549 FL("SessionId:%d JOIN REQ with invalid data"),
1550 sme_join_req->sessionId);
1551 ret_code = eSIR_SME_INVALID_PARAMETERS;
1552 goto end;
1553 }
1554
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001555 /*
1556 * Update the capability here itself as this is used in
1557 * lim_extract_ap_capability() below. If not updated issues
1558 * like not honoring power constraint on 1st association after
1559 * driver loading might occur.
1560 */
1561 lim_update_rrm_capability(mac_ctx, sme_join_req);
1562
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001563 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001564 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001565 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001566 &session_id);
1567
1568 if (session != NULL) {
1569 lim_log(mac_ctx, LOGE,
1570 FL("Session(%d) Already exists for BSSID: "
1571 MAC_ADDRESS_STR " in limSmeState = %X"),
1572 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001573 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001574 session->limSmeState);
1575
1576 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1577 session->smeSessionId == sme_join_req->sessionId) {
1578 /*
1579 * Received eWNI_SME_JOIN_REQ for same
1580 * BSS as currently associated.
1581 * Log the event and send success
1582 */
1583 lim_log(mac_ctx, LOGW,
1584 FL("SessionId: %d"), session_id);
1585 lim_log(mac_ctx, LOGW,
1586 FL("JOIN_REQ for current joined BSS"));
1587 /* Send Join success response to host */
1588 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1589 session = NULL;
1590 goto end;
1591 } else {
1592 lim_log(mac_ctx, LOGE,
1593 FL("JOIN_REQ not for current joined BSS"));
1594 ret_code = eSIR_SME_REFUSED;
1595 session = NULL;
1596 goto end;
1597 }
1598 } else {
1599 /*
1600 * Session Entry does not exist for given BSSId
1601 * Try to Create a new session
1602 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001603 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001604 &session_id, mac_ctx->lim.maxStation,
1605 eSIR_INFRASTRUCTURE_MODE);
1606 if (session == NULL) {
1607 lim_log(mac_ctx, LOGE,
1608 FL("Session Can not be created "));
1609 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1610 goto end;
1611 } else
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301612 lim_log(mac_ctx, LOG2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001613 FL("SessionId:%d New session created"),
1614 session_id);
1615 }
1616 session->isAmsduSupportInAMPDU =
1617 sme_join_req->isAmsduSupportInAMPDU;
1618
1619 /*
1620 * Store Session related parameters
1621 * Store PE session Id in session Table
1622 */
1623 session->peSessionId = session_id;
1624
1625 /* store the smejoin req handle in session table */
1626 session->pLimJoinReq = sme_join_req;
1627
1628 /* Store SME session Id in sessionTable */
1629 session->smeSessionId = sme_join_req->sessionId;
1630
1631 /* Store SME transaction Id in session Table */
1632 session->transactionId = sme_join_req->transactionId;
1633
1634 /* Store beaconInterval */
1635 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001636 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001637
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301638 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001639 sizeof(session->htConfig));
1640
Sandeep Puligilla98917432016-06-10 13:50:28 -07001641 qdf_mem_copy(&(session->vht_config),
1642 &(sme_join_req->vht_config),
1643 sizeof(session->vht_config));
1644
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001645 /* Copying of bssId is already done, while creating session */
1646 sir_copy_mac_addr(session->selfMacAddr,
1647 sme_join_req->selfMacAddr);
1648 session->bssType = sme_join_req->bsstype;
1649
1650 session->statypeForBss = STA_ENTRY_PEER;
1651 session->limWmeEnabled = sme_join_req->isWMEenabled;
1652 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301653 session->wps_registration = sme_join_req->wps_registration;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001654
1655 /* Store vendor specfic IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001656 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001657 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1658
1659 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
1660 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001661 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001662
1663 if (NULL != vendor_ie) {
Srinivas Girigowdaf2599dd2015-11-16 18:20:46 -08001664 lim_log(mac_ctx, LOG1, FL("Cisco vendor OUI present"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001665 session->isCiscoVendorAP = true;
1666 } else {
1667 session->isCiscoVendorAP = false;
1668 }
1669
1670 /* Copy the dot 11 mode in to the session table */
1671
1672 session->dot11mode = sme_join_req->dot11mode;
1673#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1674 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1675#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001676 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001677 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1678 session->enableHtSmps = sme_join_req->enableHtSmps;
1679 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001680 session->send_smps_action =
1681 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001682 /*
1683 * By default supported NSS 1x1 is set to true
1684 * and later on updated while determining session
1685 * supported rates which is the intersection of
1686 * self and peer rates
1687 */
1688 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301689 /*Store Persona */
1690 session->pePersona = sme_join_req->staPersona;
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001691 lim_log(mac_ctx, LOG1,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301692 FL("enable Smps: %d mode: %d send action: %d supported nss 1x1: %d pePersona %d cbMode %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001693 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001694 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001695 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301696 session->supported_nss_1x1,
1697 session->pePersona,
1698 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001699
1700 /*Store Persona */
1701 session->pePersona = sme_join_req->staPersona;
1702 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
1703 FL("PE PERSONA=%d cbMode %u"),
1704 session->pePersona, sme_join_req->cbMode);
1705 /* Copy The channel Id to the session Table */
1706 session->currentOperChannel = bss_desc->channelId;
1707 if (IS_5G_CH(session->currentOperChannel))
1708 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001709 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001710 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
1711 if (session->pePersona == QDF_P2P_CLIENT_MODE)
1712 session->vdev_nss = vdev_type_nss->p2p_cli;
1713 else
1714 session->vdev_nss = vdev_type_nss->sta;
1715 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001716 session->vhtCapability =
1717 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001718 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301719 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001720 session->vht_config.su_beam_formee =
1721 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001722 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001723 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001724 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001725 session->enableVhtpAid =
1726 sme_join_req->enableVhtpAid;
1727 session->enableVhtGid =
1728 sme_join_req->enableVhtGid;
Krunal Soni53993f72016-07-08 18:20:03 -07001729 lim_log(mac_ctx, LOG1, FL("vht su bformer [%d]"),
1730 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001731 }
Krunal Soni53993f72016-07-08 18:20:03 -07001732
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301733 lim_log(mac_ctx, LOG1,
Krunal Soni53993f72016-07-08 18:20:03 -07001734 FL("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d"),
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301735 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001736 session->vht_config.su_beam_formee,
1737 session->vht_config.csnof_beamformer_antSup,
1738 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001739 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001740 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001741 handle_ht_capabilityand_ht_info(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001742 /* cbMode is already merged value of peer and self -
1743 * done by csr in csr_get_cb_mode_from_ies */
1744 session->htSupportedChannelWidthSet =
1745 (sme_join_req->cbMode) ? 1 : 0;
1746 session->htRecommendedTxWidthSet =
1747 session->htSupportedChannelWidthSet;
1748 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1749
1750 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1751 session->ch_center_freq_seg0 =
1752 session->currentOperChannel - 2;
1753 session->ch_width = CH_WIDTH_40MHZ;
1754 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1755 sme_join_req->cbMode) {
1756 session->ch_center_freq_seg0 =
1757 session->currentOperChannel + 2;
1758 session->ch_width = CH_WIDTH_40MHZ;
1759 } else {
1760 session->ch_center_freq_seg0 = 0;
1761 session->ch_width = CH_WIDTH_20MHZ;
1762 }
1763
1764 /* Record if management frames need to be protected */
1765#ifdef WLAN_FEATURE_11W
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001766 if (eSIR_ED_AES_128_CMAC == sme_join_req->MgmtEncryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001767 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001768 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001769 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001770#endif
1771
1772#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001773 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001774#endif
1775
1776 /* Copy the SSID from smejoinreq to session entry */
1777 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301778 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001779 session->ssId.length);
1780
1781 /*
1782 * Determin 11r or ESE connection based on input from SME
1783 * which inturn is dependent on the profile the user wants
1784 * to connect to, So input is coming from supplicant
1785 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001786 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001787#ifdef FEATURE_WLAN_ESE
1788 session->isESEconnection = sme_join_req->isESEconnection;
1789#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001790 session->isFastTransitionEnabled =
1791 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001792
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001793 session->isFastRoamIniFeatureEnabled =
1794 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001795 session->txLdpcIniFeatureEnabled =
1796 sme_join_req->txLdpcIniFeatureEnabled;
1797
1798 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1799 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001800 } else {
1801 /*
1802 * Throw an error and return and make
1803 * sure to delete the session.
1804 */
1805 lim_log(mac_ctx, LOGE,
1806 FL("recvd JOIN_REQ with invalid bss type %d"),
1807 session->bssType);
1808 ret_code = eSIR_SME_INVALID_PARAMETERS;
1809 goto end;
1810 }
1811
1812 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301813 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001814 &sme_join_req->addIEScan, sizeof(tSirAddie));
1815
1816 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301817 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001818 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1819
1820 val = sizeof(tLimMlmJoinReq) +
1821 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301822 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001823 if (NULL == mlm_join_req) {
1824 lim_log(mac_ctx, LOGP,
1825 FL("AllocateMemory failed for mlmJoinReq"));
Nitesh Shah0102cac2016-07-13 14:38:30 +05301826 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1827 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001828 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829
1830 /* PE SessionId is stored as a part of JoinReq */
1831 mlm_join_req->sessionId = session->peSessionId;
1832
1833 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1834 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1835 eSIR_SUCCESS) {
1836 lim_log(mac_ctx, LOGP,
1837 FL("couldn't retrieve JoinFailureTimer value"
1838 " setting to default value"));
1839 mlm_join_req->joinFailureTimeout =
1840 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1841 }
1842
1843 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301844 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001845 (void *)&sme_join_req->operationalRateSet,
1846 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301847 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001848 (void *)&sme_join_req->extendedRateSet,
1849 sizeof(tSirMacRateSet));
1850 /*
1851 * this may not be needed anymore now, as rateSet is now
1852 * included in the session entry and MLM has session context.
1853 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301854 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001855 (void *)&session->rateSet,
1856 sizeof(tSirMacRateSet));
1857
1858 session->encryptType = sme_join_req->UCEncryptionType;
1859
1860 mlm_join_req->bssDescription.length =
1861 session->pLimJoinReq->bssDescription.length;
1862
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301863 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001864 (uint8_t *)
1865 &session->pLimJoinReq->bssDescription.bssId,
1866 session->pLimJoinReq->bssDescription.length + 2);
1867
1868 session->limCurrentBssCaps =
1869 session->pLimJoinReq->bssDescription.capabilityInfo;
1870
1871 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1872 session->currentOperChannel);
1873 local_power_constraint = reg_max;
1874
1875 lim_extract_ap_capability(mac_ctx,
1876 (uint8_t *)
1877 session->pLimJoinReq->bssDescription.ieFields,
1878 lim_get_ielen_from_bss_description(
1879 &session->pLimJoinReq->bssDescription),
1880 &session->limCurrentBssQosCaps,
1881 &session->limCurrentBssPropCap,
1882 &session->gLimCurrentBssUapsd,
1883 &local_power_constraint, session);
1884
Krunal Soni53993f72016-07-08 18:20:03 -07001885 /*
1886 * Once the AP capabilities are available then set the
1887 * beam forming capabilities accordingly.
1888 */
1889 if (session->nss == 1) {
1890 session->vht_config.su_beam_former = 0;
1891 session->vht_config.tx_stbc = 0;
1892 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +05301893 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001894 }
1895
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001896 session->maxTxPower = lim_get_max_tx_power(reg_max,
1897 local_power_constraint,
1898 mac_ctx->roam.configParam.nTxPowerCap);
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301899
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301900 lim_log(mac_ctx, LOG1,
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301901 FL("Reg max %d local power con %d max tx pwr %d"),
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301902 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001903
1904 if (session->gLimCurrentBssUapsd) {
1905 session->gUapsdPerAcBitmask =
1906 session->pLimJoinReq->uapsdPerAcBitmask;
1907 lim_log(mac_ctx, LOG1,
1908 FL("UAPSD flag for all AC - 0x%2x"),
1909 session->gUapsdPerAcBitmask);
1910
1911 /* resetting the dynamic uapsd mask */
1912 session->gUapsdPerAcDeliveryEnableMask = 0;
1913 session->gUapsdPerAcTriggerEnableMask = 0;
1914 }
1915
1916 session->limRFBand =
1917 lim_get_rf_band(session->currentOperChannel);
1918
1919 /* Initialize 11h Enable Flag */
1920 if (SIR_BAND_5_GHZ == session->limRFBand) {
1921 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1922 &val) != eSIR_SUCCESS) {
1923 lim_log(mac_ctx, LOGP,
1924 FL("Fail to get WNI_CFG_11H_ENABLED "));
1925 session->lim11hEnable =
1926 WNI_CFG_11H_ENABLED_STADEF;
1927 } else {
1928 session->lim11hEnable = val;
1929 }
1930 } else {
1931 session->lim11hEnable = 0;
1932 }
1933
1934 /*
1935 * To care of the scenario when STA transitions from
1936 * IBSS to Infrastructure mode.
1937 */
1938 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1939
1940 session->limPrevSmeState = session->limSmeState;
1941 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1942 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1943 session->peSessionId,
1944 session->limSmeState));
1945
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001946 /* Indicate whether spectrum management is enabled */
1947 session->spectrumMgtEnabled =
1948 sme_join_req->spectrumMgtIndicator;
1949
1950 /* Enable the spectrum management if this is a DFS channel */
1951 if (session->country_info_present &&
1952 lim_isconnected_on_dfs_channel(
1953 session->currentOperChannel))
1954 session->spectrumMgtEnabled = true;
1955
1956 session->isOSENConnection = sme_join_req->isOSENConnection;
1957
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001958 /* Issue LIM_MLM_JOIN_REQ to MLM */
1959 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
1960 (uint32_t *) mlm_join_req);
1961 return;
1962
1963 } else {
1964 /* Received eWNI_SME_JOIN_REQ un expected state */
1965 lim_log(mac_ctx, LOGE,
1966 FL("received unexpected SME_JOIN_REQ in state %X"),
1967 mac_ctx->lim.gLimSmeState);
1968 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1969 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1970 session = NULL;
1971 goto end;
1972 }
1973
1974end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301975 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1976 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001977
1978 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301979 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001980 sme_join_req = NULL;
1981 if (NULL != session)
1982 session->pLimJoinReq = NULL;
1983 }
1984 if (ret_code != eSIR_SME_SUCCESS) {
1985 if (NULL != session) {
1986 pe_delete_session(mac_ctx, session);
1987 session = NULL;
1988 }
1989 }
1990 lim_log(mac_ctx, LOG1,
1991 FL("Send failure status on sessionid: %d with ret_code = %d"),
1992 sme_session_id, ret_code);
1993 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1994 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1995 sme_transaction_id);
1996}
1997
Amar Singhala297bfa2015-10-15 15:07:29 -07001998uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001999 uint8_t iniTxPower)
2000{
2001 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05302002 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
2003 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002004 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
2005 maxTxPower = txPower;
2006 else if (txPower < MIN_TX_PWR_CAP)
2007 maxTxPower = MIN_TX_PWR_CAP;
2008 else
2009 maxTxPower = MAX_TX_PWR_CAP;
2010
2011 return maxTxPower;
2012}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002013
2014/**
2015 * __lim_process_sme_reassoc_req() - process reassoc req
2016 *
2017 * @mac_ctx: Pointer to Global MAC structure
2018 * @msg_buf: pointer to the SME message buffer
2019 *
2020 * This function is called to process SME_REASSOC_REQ message
2021 * from HDD or upper layer application.
2022 *
2023 * Return: None
2024 */
2025
2026static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2027 uint32_t *msg_buf)
2028{
2029 uint16_t caps;
2030 uint32_t val;
2031 tpSirSmeJoinReq reassoc_req = NULL;
2032 tLimMlmReassocReq *mlm_reassoc_req;
2033 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2034 tpPESession session_entry = NULL;
2035 uint8_t session_id;
2036 uint8_t sme_session_id;
2037 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002038 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002039 uint32_t tele_bcn_en = 0;
2040 uint16_t size;
2041
2042 lim_log(mac_ctx, LOG3, FL("Received REASSOC_REQ"));
2043
2044 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302045 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002046 if (NULL == reassoc_req) {
2047 lim_log(mac_ctx, LOGP,
2048 FL("call to AllocateMemory failed for reassoc_req"));
2049
2050 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2051 goto end;
2052 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302053 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002054
2055 if (!lim_is_sme_join_req_valid(mac_ctx,
2056 (tpSirSmeJoinReq)reassoc_req)) {
2057 /*
2058 * Received invalid eWNI_SME_REASSOC_REQ
2059 */
2060 lim_log(mac_ctx, LOGW,
2061 FL("received SME_REASSOC_REQ with invalid data"));
2062
2063 ret_code = eSIR_SME_INVALID_PARAMETERS;
2064 goto end;
2065 }
2066
2067 session_entry = pe_find_session_by_bssid(mac_ctx,
2068 reassoc_req->bssDescription.bssId,
2069 &session_id);
2070 if (session_entry == NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002071 lim_log(mac_ctx, LOGE,
2072 FL("Session does not exist for given bssId"));
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07002073 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2074 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002075 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07002076 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
2077 &sme_session_id, &transaction_id);
2078 session_entry =
2079 pe_find_session_by_sme_session_id(mac_ctx,
2080 sme_session_id);
2081 if (session_entry != NULL)
2082 lim_handle_sme_join_result(mac_ctx,
2083 eSIR_SME_INVALID_PARAMETERS,
2084 eSIR_MAC_UNSPEC_FAILURE_STATUS,
2085 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002086 goto end;
2087 }
2088#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2089 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2090 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2091#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2092 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2093
2094 /* Store the reassoc handle in the session Table */
2095 session_entry->pLimReAssocReq = reassoc_req;
2096
2097 session_entry->dot11mode = reassoc_req->dot11mode;
2098 session_entry->vhtCapability =
2099 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002100
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302101 if (session_entry->vhtCapability) {
2102 if (session_entry->pePersona == QDF_STA_MODE) {
2103 session_entry->vht_config.su_beam_formee =
2104 reassoc_req->vht_config.su_beam_formee;
2105 } else {
2106 reassoc_req->vht_config.su_beam_formee = 0;
2107 }
2108 session_entry->enableVhtpAid =
2109 reassoc_req->enableVhtpAid;
2110 session_entry->enableVhtGid =
2111 reassoc_req->enableVhtGid;
2112 lim_log(mac_ctx, LOG1, FL("vht su bformer [%d]"),
2113 session_entry->vht_config.su_beam_former);
2114 }
2115
2116 lim_log(mac_ctx, LOG1,
2117 FL("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d"),
2118 session_entry->vhtCapability,
2119 session_entry->vht_config.su_beam_formee,
2120 session_entry->vht_config.su_beam_former);
2121
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002122 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2123 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002124 session_entry->send_smps_action =
2125 reassoc_req->send_smps_action;
2126 lim_log(mac_ctx, LOG1,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002127 FL("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d"),
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002128 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002129 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002130 session_entry->send_smps_action,
2131 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002132 /*
2133 * Reassociate request is expected
2134 * in link established state only.
2135 */
2136
2137 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002138 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2139 /*
2140 * May be from 11r FT pre-auth. So lets check it
2141 * before we bail out
2142 */
2143 lim_log(mac_ctx, LOG1, FL(
2144 "Session in reassoc state is %d"),
2145 session_entry->peSessionId);
2146
2147 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302148 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002149 session_entry->limReAssocbssId,
2150 6)) {
2151 lim_print_mac_addr(mac_ctx,
2152 reassoc_req->bssDescription.
2153 bssId, LOGE);
2154 lim_log(mac_ctx, LOGP,
2155 FL("Unknown bssId in reassoc state"));
2156 ret_code = eSIR_SME_INVALID_PARAMETERS;
2157 goto end;
2158 }
2159
2160 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2161 session_entry);
2162 return;
2163 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002164 /*
2165 * Should not have received eWNI_SME_REASSOC_REQ
2166 */
2167 lim_log(mac_ctx, LOGE,
2168 FL("received unexpected SME_REASSOC_REQ in state %X"),
2169 session_entry->limSmeState);
2170 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2171
2172 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2173 goto end;
2174 }
2175
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302176 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002177 session_entry->pLimReAssocReq->bssDescription.bssId,
2178 sizeof(tSirMacAddr));
2179
2180 session_entry->limReassocChannelId =
2181 session_entry->pLimReAssocReq->bssDescription.channelId;
2182
2183 session_entry->reAssocHtSupportedChannelWidthSet =
2184 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2185 session_entry->reAssocHtRecommendedTxWidthSet =
2186 session_entry->reAssocHtSupportedChannelWidthSet;
2187 session_entry->reAssocHtSecondaryChannelOffset =
2188 session_entry->pLimReAssocReq->cbMode;
2189
2190 session_entry->limReassocBssCaps =
2191 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2192 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2193 session_entry->currentOperChannel);
2194 local_pwr_constraint = reg_max;
2195
2196 lim_extract_ap_capability(mac_ctx,
2197 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2198 lim_get_ielen_from_bss_description(
2199 &session_entry->pLimReAssocReq->bssDescription),
2200 &session_entry->limReassocBssQosCaps,
2201 &session_entry->limReassocBssPropCap,
2202 &session_entry->gLimCurrentBssUapsd,
2203 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302204 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002205 lim_log(mac_ctx, LOGE,
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302206 FL("Reg max = %d, local pwr constraint = %d, max tx = %d"),
2207 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002208 /* Copy the SSID from session entry to local variable */
2209 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302210 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002211 reassoc_req->ssId.ssId,
2212 session_entry->limReassocSSID.length);
2213 if (session_entry->gLimCurrentBssUapsd) {
2214 session_entry->gUapsdPerAcBitmask =
2215 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
2216 lim_log(mac_ctx, LOG1,
2217 FL("UAPSD flag for all AC - 0x%2x"),
2218 session_entry->gUapsdPerAcBitmask);
2219 }
2220
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302221 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002222 if (NULL == mlm_reassoc_req) {
2223 lim_log(mac_ctx, LOGP,
2224 FL("call to AllocateMemory failed for mlmReassocReq"));
2225
2226 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2227 goto end;
2228 }
2229
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302230 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002231 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2232
2233 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2234 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
2235 eSIR_SUCCESS) {
2236 /*
2237 * Could not get ReassocFailureTimeout value
2238 * from CFG. Log error.
2239 */
2240 lim_log(mac_ctx, LOGP,
2241 FL("could not retrieve ReassocFailureTimeout value"));
2242 }
2243
2244 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
2245 eSIR_SUCCESS) {
2246 /*
2247 * Could not get Capabilities value
2248 * from CFG. Log error.
2249 */
2250 lim_log(mac_ctx, LOGP, FL(
2251 "could not retrieve Capabilities value"));
2252 }
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302253
2254 lim_update_caps_info_for_bss(mac_ctx, &caps,
2255 reassoc_req->bssDescription.capabilityInfo);
2256 lim_log(mac_ctx, LOG1, FL("Capabilities info Reassoc: 0x%X"), caps);
2257
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002258 mlm_reassoc_req->capabilityInfo = caps;
2259
2260 /* Update PE session_id */
2261 mlm_reassoc_req->sessionId = session_id;
2262
2263 /*
2264 * If telescopic beaconing is enabled, set listen interval to
2265 * WNI_CFG_TELE_BCN_MAX_LI
2266 */
2267 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2268 &tele_bcn_en) != eSIR_SUCCESS)
2269 lim_log(mac_ctx, LOGP,
2270 FL("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN"));
2271
2272 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2273
2274 if (tele_bcn_en) {
2275 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2276 eSIR_SUCCESS)
2277 /*
2278 * Could not get ListenInterval value
2279 * from CFG. Log error.
2280 */
2281 lim_log(mac_ctx, LOGP,
2282 FL("could not retrieve ListenInterval"));
2283 } else {
2284 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
2285 eSIR_SUCCESS)
2286 /*
2287 * Could not get ListenInterval value
2288 * from CFG. Log error.
2289 */
2290 lim_log(mac_ctx, LOGP,
2291 FL("could not retrieve ListenInterval"));
2292 }
2293
2294 mlm_reassoc_req->listenInterval = (uint16_t) val;
2295
2296 /* Indicate whether spectrum management is enabled */
2297 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2298
2299 /* Enable the spectrum management if this is a DFS channel */
2300 if (session_entry->country_info_present &&
2301 lim_isconnected_on_dfs_channel(
2302 session_entry->currentOperChannel))
2303 session_entry->spectrumMgtEnabled = true;
2304
2305 session_entry->limPrevSmeState = session_entry->limSmeState;
2306 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2307
2308 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2309 session_entry->peSessionId,
2310 session_entry->limSmeState));
2311
2312 lim_post_mlm_message(mac_ctx,
2313 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2314 return;
2315end:
2316 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302317 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002318 if (session_entry)
2319 session_entry->pLimReAssocReq = NULL;
2320 }
2321
2322 if (session_entry) {
2323 /*
2324 * error occurred after we determined the session so extract
2325 * session and transaction info from there
2326 */
2327 sme_session_id = session_entry->smeSessionId;
2328 transaction_id = session_entry->transactionId;
2329 } else
2330 /*
2331 * error occurred before or during the time we determined
2332 * the session so extract the session and transaction info
2333 * from the message
2334 */
2335 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2336 &sme_session_id, &transaction_id);
2337
2338 /*
2339 * Send Reassoc failure response to host
2340 * (note session_entry may be NULL, but that's OK)
2341 */
2342 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2343 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2344 session_entry, sme_session_id,
2345 transaction_id);
2346}
2347
2348bool send_disassoc_frame = 1;
2349/**
2350 * __lim_process_sme_disassoc_req()
2351 *
2352 ***FUNCTION:
2353 * This function is called to process SME_DISASSOC_REQ message
2354 * from HDD or upper layer application.
2355 *
2356 ***LOGIC:
2357 *
2358 ***ASSUMPTIONS:
2359 *
2360 ***NOTE:
2361 *
2362 * @param pMac Pointer to Global MAC structure
2363 * @param *pMsgBuf A pointer to the SME message buffer
2364 * @return None
2365 */
2366
2367static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2368{
2369 uint16_t disassocTrigger, reasonCode;
2370 tLimMlmDisassocReq *pMlmDisassocReq;
2371 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2372 tSirSmeDisassocReq smeDisassocReq;
2373 tpPESession psessionEntry = NULL;
2374 uint8_t sessionId;
2375 uint8_t smesessionId;
2376 uint16_t smetransactionId;
2377
2378 if (pMsgBuf == NULL) {
2379 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
2380 return;
2381 }
2382
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302383 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002384 smesessionId = smeDisassocReq.sessionId;
2385 smetransactionId = smeDisassocReq.transactionId;
2386 if (!lim_is_sme_disassoc_req_valid(pMac,
2387 &smeDisassocReq,
2388 psessionEntry)) {
2389 PELOGE(lim_log(pMac, LOGE,
2390 FL("received invalid SME_DISASSOC_REQ message"));)
2391 if (pMac->lim.gLimRspReqd) {
2392 pMac->lim.gLimRspReqd = false;
2393
2394 retCode = eSIR_SME_INVALID_PARAMETERS;
2395 disassocTrigger = eLIM_HOST_DISASSOC;
2396 goto sendDisassoc;
2397 }
2398
2399 return;
2400 }
2401
2402 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002403 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002404 &sessionId);
2405 if (psessionEntry == NULL) {
2406 lim_log(pMac, LOGE,
2407 FL("session does not exist for given bssId "
2408 MAC_ADDRESS_STR),
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002409 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002410 retCode = eSIR_SME_INVALID_PARAMETERS;
2411 disassocTrigger = eLIM_HOST_DISASSOC;
2412 goto sendDisassoc;
2413 }
2414 lim_log(pMac, LOG1,
2415 FL("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2416 MAC_ADDRESS_STR), smesessionId,
2417 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2418 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002419 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002420
2421#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2422 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2423 0, smeDisassocReq.reasonCode);
2424#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2425
2426 /* Update SME session Id and SME transaction ID */
2427
2428 psessionEntry->smeSessionId = smesessionId;
2429 psessionEntry->transactionId = smetransactionId;
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002430 lim_log(pMac, LOGW, FL("ho_fail: %d "), smeDisassocReq.process_ho_fail);
2431 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002432
2433 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2434 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002435 switch (psessionEntry->limSmeState) {
2436 case eLIM_SME_ASSOCIATED_STATE:
2437 case eLIM_SME_LINK_EST_STATE:
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002438 lim_log(pMac, LOG1,
2439 FL("Rcvd SME_DISASSOC_REQ in limSmeState: %d "),
2440 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002441 psessionEntry->limPrevSmeState =
2442 psessionEntry->limSmeState;
2443 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2444#ifdef FEATURE_WLAN_TDLS
2445 /* Delete all TDLS peers connected before leaving BSS */
2446 lim_delete_tdls_peers(pMac, psessionEntry);
2447#endif
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002448 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2449 psessionEntry->peSessionId,
2450 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002451 break;
2452
2453 case eLIM_SME_WT_DEAUTH_STATE:
2454 /* PE shall still process the DISASSOC_REQ and proceed with
2455 * link tear down even if it had already sent a DEAUTH_IND to
2456 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2457 * its been set when PE entered WT_DEAUTH_STATE.
2458 */
2459 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2460 MTRACE(mac_trace
2461 (pMac, TRACE_CODE_SME_STATE,
2462 psessionEntry->peSessionId,
2463 psessionEntry->limSmeState));
2464 lim_log(pMac, LOG1,
2465 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE. "));
2466 break;
2467
2468 case eLIM_SME_WT_DISASSOC_STATE:
2469 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2470 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2471 * PE can continue processing DISASSOC_REQ and send the response instead
2472 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2473 * for disassoc frame.
2474 *
2475 * It will send a disassoc, which is ok. However, we can use the global flag
2476 * sendDisassoc to not send disassoc frame.
2477 */
2478 lim_log(pMac, LOG1,
2479 FL("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE. "));
2480 break;
2481
2482 case eLIM_SME_JOIN_FAILURE_STATE: {
2483 /* Already in Disconnected State, return success */
2484 lim_log(pMac, LOG1,
2485 FL("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE. "));
2486 if (pMac->lim.gLimRspReqd) {
2487 retCode = eSIR_SME_SUCCESS;
2488 disassocTrigger = eLIM_HOST_DISASSOC;
2489 goto sendDisassoc;
2490 }
2491 }
2492 break;
2493 default:
2494 /**
2495 * STA is not currently associated.
2496 * Log error and send response to host
2497 */
2498 lim_log(pMac, LOGE,
2499 FL("received unexpected SME_DISASSOC_REQ in state %X"),
2500 psessionEntry->limSmeState);
2501 lim_print_sme_state(pMac, LOGE,
2502 psessionEntry->limSmeState);
2503
2504 if (pMac->lim.gLimRspReqd) {
2505 if (psessionEntry->limSmeState !=
2506 eLIM_SME_WT_ASSOC_STATE)
2507 pMac->lim.gLimRspReqd = false;
2508
2509 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2510 disassocTrigger = eLIM_HOST_DISASSOC;
2511 goto sendDisassoc;
2512 }
2513
2514 return;
2515 }
2516
2517 break;
2518
2519 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002520 /* Fall through */
2521 break;
2522
2523 case eLIM_STA_IN_IBSS_ROLE:
2524 default:
2525 /* eLIM_UNKNOWN_ROLE */
2526 lim_log(pMac, LOGE,
2527 FL("received unexpected SME_DISASSOC_REQ for role %d"),
2528 GET_LIM_SYSTEM_ROLE(psessionEntry));
2529
2530 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2531 disassocTrigger = eLIM_HOST_DISASSOC;
2532 goto sendDisassoc;
2533 } /* end switch (pMac->lim.gLimSystemRole) */
2534
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302535 disassocTrigger = eLIM_HOST_DISASSOC;
2536 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002537
2538 if (smeDisassocReq.doNotSendOverTheAir) {
2539 lim_log(pMac, LOG1, FL("do not send dissoc over the air"));
2540 send_disassoc_frame = 0;
2541 }
2542 /* Trigger Disassociation frame to peer MAC entity */
2543 lim_log(pMac, LOG1, FL("Sending Disasscoc with disassoc Trigger"
2544 " : %d, reasonCode : %d"),
2545 disassocTrigger, reasonCode);
2546
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302547 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002548 if (NULL == pMlmDisassocReq) {
2549 /* Log error */
2550 lim_log(pMac, LOGP,
2551 FL("call to AllocateMemory failed for mlmDisassocReq"));
2552
2553 return;
2554 }
2555
Anurag Chouhanc5548422016-02-24 18:33:27 +05302556 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002557 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002558
2559 pMlmDisassocReq->reasonCode = reasonCode;
2560 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2561
2562 /* Update PE session ID */
2563 pMlmDisassocReq->sessionId = sessionId;
2564
2565 lim_post_mlm_message(pMac,
2566 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2567 return;
2568
2569sendDisassoc:
2570 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002571 lim_send_sme_disassoc_ntf(pMac,
2572 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002573 retCode,
2574 disassocTrigger,
2575 1, smesessionId, smetransactionId,
2576 psessionEntry);
2577 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002578 lim_send_sme_disassoc_ntf(pMac,
2579 smeDisassocReq.peer_macaddr.bytes,
2580 retCode, disassocTrigger, 1,
2581 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002582
2583} /*** end __lim_process_sme_disassoc_req() ***/
2584
2585/** -----------------------------------------------------------------
2586 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2587
2588 This function is called to process SME_DISASSOC_CNF message
2589 from HDD or upper layer application.
2590
2591 \param pMac - global mac structure
2592 \param pStaDs - station dph hash node
2593 \return none
2594 \sa
2595 ----------------------------------------------------------------- */
2596static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2597{
2598 tSirSmeDisassocCnf smeDisassocCnf;
2599 uint16_t aid;
2600 tpDphHashNode pStaDs;
2601 tpPESession psessionEntry;
2602 uint8_t sessionId;
2603
2604 PELOG1(lim_log(pMac, LOG1, FL("received DISASSOC_CNF message"));)
2605
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302606 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002607 sizeof(struct sSirSmeDisassocCnf));
2608
2609 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002610 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002611 &sessionId);
2612 if (psessionEntry == NULL) {
2613 lim_log(pMac, LOGE,
2614 FL("session does not exist for given bssId"));
2615 return;
2616 }
2617
2618 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
2619 lim_log(pMac, LOGE,
2620 FL("received invalid SME_DISASSOC_CNF message"));
2621 return;
2622 }
2623#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2624 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2625 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2626 psessionEntry,
2627 (uint16_t) smeDisassocCnf.statusCode, 0);
2628 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2629 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2630 psessionEntry,
2631 (uint16_t) smeDisassocCnf.statusCode, 0);
2632#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2633
2634 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2635 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002636 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2637 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2638 && (psessionEntry->limSmeState !=
2639 eLIM_SME_WT_DEAUTH_STATE)) {
2640 lim_log(pMac, LOGE,
2641 FL
2642 ("received unexp SME_DISASSOC_CNF in state %X"),
2643 psessionEntry->limSmeState);
2644 lim_print_sme_state(pMac, LOGE,
2645 psessionEntry->limSmeState);
2646 return;
2647 }
2648 break;
2649
2650 case eLIM_AP_ROLE:
2651 /* Fall through */
2652 break;
2653
2654 case eLIM_STA_IN_IBSS_ROLE:
2655 default: /* eLIM_UNKNOWN_ROLE */
2656 lim_log(pMac, LOGE,
2657 FL("received unexpected SME_DISASSOC_CNF role %d"),
2658 GET_LIM_SYSTEM_ROLE(psessionEntry));
2659
2660 return;
2661 }
2662
2663 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2664 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2665 LIM_IS_AP_ROLE(psessionEntry)) {
2666 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002667 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002668 &psessionEntry->dph.dphHashTable);
2669 if (pStaDs == NULL) {
2670 lim_log(pMac, LOGE,
2671 FL("DISASSOC_CNF for a STA with no context, addr= "
2672 MAC_ADDRESS_STR),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002673 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002674 return;
2675 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302676
2677 if ((pStaDs->mlmStaContext.mlmState ==
2678 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2679 (pStaDs->mlmStaContext.mlmState ==
2680 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
2681 lim_log(pMac, LOGE,
2682 FL("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d"),
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002683 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302684 pStaDs->mlmStaContext.mlmState);
2685 return;
2686 }
2687
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002688 /* Delete FT session if there exists one */
2689 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002690 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2691
2692 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002693 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002694 }
2695
2696 return;
2697}
2698
2699/**
2700 * __lim_process_sme_deauth_req() - process sme deauth req
2701 * @mac_ctx: Pointer to Global MAC structure
2702 * @msg_buf: pointer to the SME message buffer
2703 *
2704 * This function is called to process SME_DEAUTH_REQ message
2705 * from HDD or upper layer application.
2706 *
2707 * Return: None
2708 */
2709
2710static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2711 uint32_t *msg_buf)
2712{
2713 uint16_t deauth_trigger, reason_code;
2714 tLimMlmDeauthReq *mlm_deauth_req;
2715 tSirSmeDeauthReq sme_deauth_req;
2716 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2717 tpPESession session_entry;
2718 uint8_t session_id; /* PE sessionId */
2719 uint8_t sme_session_id;
2720 uint16_t sme_transaction_id;
2721
2722 lim_log(mac_ctx, LOG1, FL("received DEAUTH_REQ message"));
2723
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302724 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002725 sme_session_id = sme_deauth_req.sessionId;
2726 sme_transaction_id = sme_deauth_req.transactionId;
2727
2728 /*
2729 * We need to get a session first but we don't even know
2730 * if the message is correct.
2731 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002732 session_entry = pe_find_session_by_bssid(mac_ctx,
2733 sme_deauth_req.bssid.bytes,
2734 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002735 if (session_entry == NULL) {
2736 lim_log(mac_ctx, LOGE,
2737 FL("session does not exist for given bssId"));
2738 ret_code = eSIR_SME_INVALID_PARAMETERS;
2739 deauth_trigger = eLIM_HOST_DEAUTH;
2740 goto send_deauth;
2741 }
2742
2743 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2744 session_entry)) {
2745 lim_log(mac_ctx, LOGE,
2746 FL("received invalid SME_DEAUTH_REQ message"));
2747 mac_ctx->lim.gLimRspReqd = false;
2748
2749 ret_code = eSIR_SME_INVALID_PARAMETERS;
2750 deauth_trigger = eLIM_HOST_DEAUTH;
2751 goto send_deauth;
2752 }
2753 lim_log(mac_ctx, LOG1,
2754 FL("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2755 MAC_ADDRESS_STR), sme_session_id,
2756 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2757 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002758 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002759#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2760 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2761 session_entry, 0, sme_deauth_req.reasonCode);
2762#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2763
2764 /* Update SME session ID and Transaction ID */
2765 session_entry->smeSessionId = sme_session_id;
2766 session_entry->transactionId = sme_transaction_id;
2767
2768 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2769 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002770 switch (session_entry->limSmeState) {
2771 case eLIM_SME_ASSOCIATED_STATE:
2772 case eLIM_SME_LINK_EST_STATE:
2773 case eLIM_SME_WT_ASSOC_STATE:
2774 case eLIM_SME_JOIN_FAILURE_STATE:
2775 case eLIM_SME_IDLE_STATE:
2776 session_entry->limPrevSmeState =
2777 session_entry->limSmeState;
2778 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2779 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2780 session_entry->peSessionId,
2781 session_entry->limSmeState));
2782 /* Send Deauthentication request to MLM below */
2783 break;
2784 case eLIM_SME_WT_DEAUTH_STATE:
2785 case eLIM_SME_WT_DISASSOC_STATE:
2786 /*
2787 * PE Recieved a Deauth/Disassoc frame. Normally it get
2788 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2789 * Which means host is also trying to disconnect.
2790 * PE can continue processing DEAUTH_REQ and send
2791 * the response instead of failing the request.
2792 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2793 * was sent for deauth/disassoc frame.
2794 */
2795 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2796 lim_log(mac_ctx, LOG1, FL(
2797 "Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE"));
2798 break;
2799 default:
2800 /*
2801 * STA is not in a state to deauthenticate with
2802 * peer. Log error and send response to host.
2803 */
2804 lim_log(mac_ctx, LOGE, FL(
2805 "received unexp SME_DEAUTH_REQ in state %X"),
2806 session_entry->limSmeState);
2807 lim_print_sme_state(mac_ctx, LOGE,
2808 session_entry->limSmeState);
2809
2810 if (mac_ctx->lim.gLimRspReqd) {
2811 mac_ctx->lim.gLimRspReqd = false;
2812
2813 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2814 deauth_trigger = eLIM_HOST_DEAUTH;
2815
2816 /*
2817 * here we received deauth request from AP so sme state
2818 * is eLIM_SME_WT_DEAUTH_STATE.if we have ISSUED
2819 * delSta then mlm state should be
2820 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got delBSS
2821 * rsp then mlm state should be eLIM_MLM_IDLE_STATE
2822 * so the below condition captures the state where
2823 * delSta not done and firmware still in
2824 * connected state.
2825 */
2826 if (session_entry->limSmeState ==
2827 eLIM_SME_WT_DEAUTH_STATE &&
2828 session_entry->limMlmState !=
2829 eLIM_MLM_IDLE_STATE &&
2830 session_entry->limMlmState !=
2831 eLIM_MLM_WT_DEL_STA_RSP_STATE)
2832 ret_code = eSIR_SME_DEAUTH_STATUS;
2833 goto send_deauth;
2834 }
2835 return;
2836 }
2837 break;
2838
2839 case eLIM_STA_IN_IBSS_ROLE:
2840 lim_log(mac_ctx, LOGE, FL("Deauth not allowed in IBSS"));
2841 if (mac_ctx->lim.gLimRspReqd) {
2842 mac_ctx->lim.gLimRspReqd = false;
2843 ret_code = eSIR_SME_INVALID_PARAMETERS;
2844 deauth_trigger = eLIM_HOST_DEAUTH;
2845 goto send_deauth;
2846 }
2847 return;
2848 case eLIM_AP_ROLE:
2849 break;
2850 default:
2851 lim_log(mac_ctx, LOGE,
2852 FL("received unexpected SME_DEAUTH_REQ for role %X"),
2853 GET_LIM_SYSTEM_ROLE(session_entry));
2854 if (mac_ctx->lim.gLimRspReqd) {
2855 mac_ctx->lim.gLimRspReqd = false;
2856 ret_code = eSIR_SME_INVALID_PARAMETERS;
2857 deauth_trigger = eLIM_HOST_DEAUTH;
2858 goto send_deauth;
2859 }
2860 return;
2861 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2862
2863 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2864 /* Deauthentication is triggered by Link Monitoring */
2865 lim_log(mac_ctx, LOG1, FL("** Lost link with AP **"));
2866 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2867 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2868 } else {
2869 deauth_trigger = eLIM_HOST_DEAUTH;
2870 reason_code = sme_deauth_req.reasonCode;
2871 }
2872
2873 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302874 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002875 if (NULL == mlm_deauth_req) {
2876 lim_log(mac_ctx, LOGP,
2877 FL("call to AllocateMemory failed for mlmDeauthReq"));
2878 if (mac_ctx->lim.gLimRspReqd) {
2879 mac_ctx->lim.gLimRspReqd = false;
2880 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2881 deauth_trigger = eLIM_HOST_DEAUTH;
2882 goto send_deauth;
2883 }
2884 return;
2885 }
2886
Anurag Chouhanc5548422016-02-24 18:33:27 +05302887 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002888 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002889
2890 mlm_deauth_req->reasonCode = reason_code;
2891 mlm_deauth_req->deauthTrigger = deauth_trigger;
2892
2893 /* Update PE session Id */
2894 mlm_deauth_req->sessionId = session_id;
2895
2896 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2897 (uint32_t *)mlm_deauth_req);
2898 return;
2899
2900send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002901 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2902 ret_code, deauth_trigger, 1,
2903 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002904}
2905
2906/**
2907 * __lim_process_sme_set_context_req()
2908 *
2909 * @mac_ctx: Pointer to Global MAC structure
2910 * @msg_buf: pointer to the SME message buffer
2911 *
2912 * This function is called to process SME_SETCONTEXT_REQ message
2913 * from HDD or upper layer application.
2914 *
2915 * Return: None
2916 */
2917
2918static void
2919__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2920{
2921 tpSirSmeSetContextReq set_context_req;
2922 tLimMlmSetKeysReq *mlm_set_key_req;
2923 tpPESession session_entry;
2924 uint8_t session_id; /* PE sessionID */
2925 uint8_t sme_session_id;
2926 uint16_t sme_transaction_id;
2927
2928 lim_log(mac_ctx, LOG1, FL("received SETCONTEXT_REQ message"));
2929
2930 if (msg_buf == NULL) {
2931 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
2932 return;
2933 }
2934
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302935 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002936 if (NULL == set_context_req) {
2937 lim_log(mac_ctx, LOGP, FL(
2938 "call to AllocateMemory failed for set_context_req"));
2939 return;
2940 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302941 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002942 sizeof(struct sSirSmeSetContextReq));
2943 sme_session_id = set_context_req->sessionId;
2944 sme_transaction_id = set_context_req->transactionId;
2945
2946 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
2947 lim_log(mac_ctx, LOGW,
2948 FL("received invalid SME_SETCONTEXT_REQ message"));
2949 goto end;
2950 }
2951
2952 if (set_context_req->keyMaterial.numKeys >
2953 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
2954 lim_log(mac_ctx, LOGE, FL(
2955 "numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS"),
2956 set_context_req->keyMaterial.numKeys);
2957 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002958 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002959 eSIR_SME_INVALID_PARAMETERS, NULL,
2960 sme_session_id, sme_transaction_id);
2961 goto end;
2962 }
2963
2964 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002965 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002966 if (session_entry == NULL) {
2967 lim_log(mac_ctx, LOGW,
2968 FL("Session does not exist for given BSSID"));
2969 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002970 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002971 eSIR_SME_INVALID_PARAMETERS, NULL,
2972 sme_session_id, sme_transaction_id);
2973 goto end;
2974 }
2975#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2976 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2977 session_entry, 0, 0);
2978#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2979
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002980 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002981 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2982 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002983 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002984 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2985 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302986 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002987 if (NULL == mlm_set_key_req) {
2988 lim_log(mac_ctx, LOGP, FL(
2989 "mem alloc failed for mlmSetKeysReq"));
2990 goto end;
2991 }
2992 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2993 mlm_set_key_req->numKeys =
2994 set_context_req->keyMaterial.numKeys;
2995 if (mlm_set_key_req->numKeys >
2996 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
2997 lim_log(mac_ctx, LOGP, FL(
2998 "no.of keys exceeded max num of default keys limit"));
2999 goto end;
3000 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05303001 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003002 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003003
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303004 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003005 (uint8_t *) &set_context_req->keyMaterial.key,
3006 sizeof(tSirKeys) *
3007 (mlm_set_key_req->numKeys ? mlm_set_key_req->
3008 numKeys : 1));
3009
3010 mlm_set_key_req->sessionId = session_id;
3011 mlm_set_key_req->smesessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003012 lim_log(mac_ctx, LOG1, FL(
3013 "received SETCONTEXT_REQ message sessionId=%d"),
3014 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003015
3016 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
3017 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
3018 LIM_IS_AP_ROLE(session_entry)) {
3019 if (set_context_req->keyMaterial.key[0].keyLength) {
3020 uint8_t key_id;
3021 key_id =
3022 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303023 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003024 &session_entry->WEPKeyMaterial[key_id],
3025 (uint8_t *) &set_context_req->keyMaterial,
3026 sizeof(tSirKeyMaterial));
3027 } else {
3028 uint32_t i;
3029 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
3030 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303031 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003032 &mlm_set_key_req->key[i],
3033 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
3034 sizeof(tSirKeys));
3035 }
3036 }
3037 }
3038 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
3039 (uint32_t *) mlm_set_key_req);
3040 } else {
3041 lim_log(mac_ctx, LOGE, FL(
3042 "rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X"),
3043 GET_LIM_SYSTEM_ROLE(session_entry),
3044 session_entry->limSmeState);
3045 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
3046
3047 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08003048 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003049 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
3050 session_entry, sme_session_id,
3051 sme_transaction_id);
3052 }
3053end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303054 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003055 return;
3056}
3057
3058/**
3059 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
3060 *
3061 * @mac_ctx: Pointer to Global MAC structure
3062 * @msg_buf: pointer to the SME message buffer
3063 *
3064 * This function is called to process SME_GET_ASSOC_STAS_REQ message
3065 * from HDD or upper layer application.
3066 *
3067 * Return: None
3068 */
3069
Jeff Johnson801f1532016-10-07 07:54:50 -07003070static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
3071 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003072{
3073 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
3074 tpDphHashNode sta_ds = NULL;
3075 tpPESession session_entry = NULL;
3076 tSap_Event sap_event;
3077 tpWLAN_SAPEventCB sap_event_cb = NULL;
3078 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
3079 uint8_t session_id = CSR_SESSION_ID_INVALID;
3080 uint8_t assoc_id = 0;
3081 uint8_t sta_cnt = 0;
3082
3083 if (msg_buf == NULL) {
3084 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3085 return;
3086 }
3087
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303088 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003089 sizeof(struct sSirSmeGetAssocSTAsReq));
3090 /*
3091 * Get Associated stations from PE.
3092 * Find PE session Entry
3093 */
3094 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003095 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003096 &session_id);
3097 if (session_entry == NULL) {
3098 lim_log(mac_ctx, LOGE,
3099 FL("session does not exist for given bssId"));
3100 goto lim_assoc_sta_end;
3101 }
3102
3103 if (!LIM_IS_AP_ROLE(session_entry)) {
3104 lim_log(mac_ctx, LOGE, FL(
3105 "Received unexpected message in state %X, in role %X"),
3106 session_entry->limSmeState,
3107 GET_LIM_SYSTEM_ROLE(session_entry));
3108 goto lim_assoc_sta_end;
3109 }
3110 /* Retrieve values obtained in the request message */
3111 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3112 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3113
3114 if (NULL == assoc_sta_tmp)
3115 goto lim_assoc_sta_end;
3116 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3117 assoc_id++) {
3118 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3119 &session_entry->dph.dphHashTable);
3120 if (NULL == sta_ds)
3121 continue;
3122 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303123 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003124 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303125 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003126 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3127 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3128
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303129 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003130 (uint8_t *)&sta_ds->supportedRates,
3131 sizeof(tSirSupportedRates));
3132 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3133 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3134 assoc_sta_tmp->Support40Mhz =
3135 sta_ds->htDsssCckRate40MHzSupport;
3136
3137 lim_log(mac_ctx, LOG1, FL("dph Station Number = %d"),
3138 sta_cnt + 1);
3139 lim_log(mac_ctx, LOG1, FL("MAC = " MAC_ADDRESS_STR),
3140 MAC_ADDR_ARRAY(sta_ds->staAddr));
3141 lim_log(mac_ctx, LOG1, FL("Association Id = %d"),
3142 sta_ds->assocId);
3143 lim_log(mac_ctx, LOG1, FL("Station Index = %d"),
3144 sta_ds->staIndex);
3145 assoc_sta_tmp++;
3146 sta_cnt++;
3147 }
3148 }
3149lim_assoc_sta_end:
3150 /*
3151 * Call hdd callback with sap event to send the list of
3152 * associated stations from PE
3153 */
3154 if (sap_event_cb != NULL) {
3155 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3156 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303157 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003158 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3159 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3160 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3161 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3162 }
3163}
3164
3165/**
3166 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3167 *
3168 * @mac_ctx: Pointer to Global MAC structure
3169 * @msg_buf: pointer to WPS PBC overlap query message
3170 *
3171 * This function parses get WPS PBC overlap information
3172 * message and call callback to pass WPS PBC overlap
3173 * information back to hdd.
3174 *
3175 * Return: None
3176 */
Jeff Johnson801f1532016-10-07 07:54:50 -07003177static void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3178 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003179{
3180 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3181 tpPESession session_entry = NULL;
3182 tSap_Event sap_event;
3183 tpWLAN_SAPEventCB sap_event_cb = NULL;
3184 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003185 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3186
3187 if (msg_buf == NULL) {
3188 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
3189 return;
3190 }
3191
3192 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303193 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003194
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303195 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003196 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3197 /*
3198 * Get Associated stations from PE
3199 * Find PE session Entry
3200 */
3201 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003202 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003203 if (session_entry == NULL) {
3204 lim_log(mac_ctx, LOGE,
3205 FL("session does not exist for given bssId"));
3206 goto lim_get_wpspbc_sessions_end;
3207 }
3208
3209 if (!LIM_IS_AP_ROLE(session_entry)) {
3210 lim_log(mac_ctx, LOGE,
3211 FL("Received unexpected message in role %X"),
3212 GET_LIM_SYSTEM_ROLE(session_entry));
3213 goto lim_get_wpspbc_sessions_end;
3214 }
3215 /*
3216 * Call hdd callback with sap event to send the
3217 * WPS PBC overlap information
3218 */
3219 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303220 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003221
Anurag Chouhanc5548422016-02-24 18:33:27 +05303222 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003223 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003224 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003225 sap_get_wpspbc_event->UUID_E,
3226 &sap_get_wpspbc_event->wpsPBCOverlap,
3227 session_entry);
3228 } else {
3229 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003230 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003231 session_entry);
3232 /* don't have to inform the HDD/Host */
3233 return;
3234 }
3235
3236 lim_log(mac_ctx, LOGE, FL("wpsPBCOverlap %d"),
3237 sap_get_wpspbc_event->wpsPBCOverlap);
3238 lim_print_mac_addr(mac_ctx,
3239 sap_get_wpspbc_event->addr.bytes, LOG4);
3240
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303241 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003242
3243lim_get_wpspbc_sessions_end:
3244 sap_event_cb =
3245 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3246 if (NULL != sap_event_cb)
3247 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3248}
3249
3250/**
3251 * __lim_counter_measures()
3252 *
3253 * FUNCTION:
3254 * This function is called to "implement" MIC counter measure
3255 * and is *temporary* only
3256 *
3257 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3258 * we don't do the proper STA disassoc sequence since the
3259 * BSS will be stoped anyway
3260 *
3261 ***ASSUMPTIONS:
3262 *
3263 ***NOTE:
3264 *
3265 * @param pMac Pointer to Global MAC structure
3266 * @return None
3267 */
3268
3269static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3270{
3271 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003272 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003273 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3274 mac, psessionEntry, false);
3275};
3276
Jeff Johnson801f1532016-10-07 07:54:50 -07003277static void lim_process_tkip_counter_measures(tpAniSirGlobal pMac,
3278 uint32_t *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003279{
3280 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3281 tpPESession psessionEntry;
3282 uint8_t sessionId; /* PE sessionId */
3283
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303284 qdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003285 sizeof(struct sSirSmeTkipCntrMeasReq));
3286
3287 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003288 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003289 if (NULL == psessionEntry) {
3290 lim_log(pMac, LOGE,
3291 FL("session does not exist for given BSSID "));
3292 return;
3293 }
3294
3295 if (tkipCntrMeasReq.bEnable)
3296 __lim_counter_measures(pMac, psessionEntry);
3297
3298 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3299}
3300
3301static void
3302__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3303{
3304 tSirSmeStopBssReq stopBssReq;
3305 tSirRetStatus status;
3306 tLimSmeStates prevState;
3307 tpPESession psessionEntry;
3308 uint8_t smesessionId;
3309 uint8_t sessionId;
3310 uint16_t smetransactionId;
3311 uint8_t i = 0;
3312 tpDphHashNode pStaDs = NULL;
3313
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303314 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003315 smesessionId = stopBssReq.sessionId;
3316 smetransactionId = stopBssReq.transactionId;
3317
3318 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
3319 PELOGW(lim_log(pMac, LOGW,
3320 FL("received invalid SME_STOP_BSS_REQ message"));)
3321 /* Send Stop BSS response to host */
3322 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3323 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3324 smetransactionId);
3325 return;
3326 }
3327
3328 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003329 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003330 &sessionId);
3331 if (psessionEntry == NULL) {
3332 lim_log(pMac, LOGW,
3333 FL("session does not exist for given BSSID "));
3334 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3335 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3336 smetransactionId);
3337 return;
3338 }
3339#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3340 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3341 0, 0);
3342#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3343
3344 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3345 LIM_IS_STA_ROLE(psessionEntry)) {
3346 /**
3347 * Should not have received STOP_BSS_REQ in states
3348 * other than 'normal' state or on STA in Infrastructure
3349 * mode. Log error and return response to host.
3350 */
3351 lim_log(pMac, LOGE,
3352 FL
3353 ("received unexpected SME_STOP_BSS_REQ in state %X, for role %d"),
3354 psessionEntry->limSmeState,
3355 GET_LIM_SYSTEM_ROLE(psessionEntry));
3356 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3357 /* / Send Stop BSS response to host */
3358 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3359 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3360 smetransactionId);
3361 return;
3362 }
3363
3364 if (LIM_IS_AP_ROLE(psessionEntry))
3365 lim_wpspbc_close(pMac, psessionEntry);
3366
3367 lim_log(pMac, LOGW,
3368 FL("RECEIVED STOP_BSS_REQ with reason code=%d"),
3369 stopBssReq.reasonCode);
3370
3371 prevState = psessionEntry->limSmeState;
3372
3373 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3374 MTRACE(mac_trace
3375 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3376 psessionEntry->limSmeState));
3377
3378 /* Update SME session Id and Transaction Id */
3379 psessionEntry->smeSessionId = smesessionId;
3380 psessionEntry->transactionId = smetransactionId;
3381
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003382 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3383 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3384 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003385 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3386 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3387 /* Send disassoc all stations associated thru TKIP */
3388 __lim_counter_measures(pMac, psessionEntry);
3389 else
3390 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003391 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3392 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003393 }
3394
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003395 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3396 /* Free the buffer allocated in START_BSS_REQ */
3397 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3398 psessionEntry->addIeParams.probeRespDataLen = 0;
3399 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003400
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003401 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3402 psessionEntry->addIeParams.assocRespDataLen = 0;
3403 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003404
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003405 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3406 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3407 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003408
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003409 /*
3410 * lim_del_bss is also called as part of coalescing,
3411 * when we send DEL BSS followed by Add Bss msg.
3412 */
3413 pMac->lim.gLimIbssCoalescingHappened = false;
3414 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003415 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3416 pStaDs =
3417 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3418 if (NULL == pStaDs)
3419 continue;
3420 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3421 if (eSIR_SUCCESS == status) {
3422 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3423 pStaDs->assocId, psessionEntry);
3424 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3425 } else {
3426 lim_log(pMac, LOGE,
3427 FL("lim_del_sta failed with Status : %d"), status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303428 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003429 }
3430 }
3431 /* send a delBss to HAL and wait for a response */
3432 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3433
3434 if (status != eSIR_SUCCESS) {
3435 PELOGE(lim_log
3436 (pMac, LOGE, FL("delBss failed for bss %d"),
3437 psessionEntry->bssIdx);
3438 )
3439 psessionEntry->limSmeState = prevState;
3440
3441 MTRACE(mac_trace
3442 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3443 psessionEntry->limSmeState));
3444
3445 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3446 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3447 smetransactionId);
3448 }
3449}
3450
3451/**
3452 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3453 * @pMac: Global MAC context
3454 * @pMsg: Message from SME
3455 *
3456 * Wrapper for the function __lim_handle_sme_stop_bss_request
3457 * This message will be defered until softmac come out of
3458 * scan mode. Message should be handled even if we have
3459 * detected radar in the current operating channel.
3460 *
3461 * Return: true - If we consumed the buffer
3462 * false - If have defered the message.
3463 */
3464
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003465static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3466 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003467{
3468 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3469 /**
3470 * If message defered, buffer is not consumed yet.
3471 * So return false
3472 */
3473 return false;
3474 }
3475 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3476 return true;
3477} /*** end __lim_process_sme_stop_bss_req() ***/
3478
3479void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3480 uint32_t body, tpPESession psessionEntry)
3481{
3482
3483 (void)body;
3484 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3485 lim_ibss_delete(pMac, psessionEntry);
3486 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3487 lim_delete_pre_auth_list(pMac);
3488 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3489 psessionEntry->smeSessionId,
3490 psessionEntry->transactionId);
3491 return;
3492}
3493
3494/**
3495 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3496 *
3497 * @mac_ctx: pointer to mac context
3498 * @msg_type: message type
3499 * @msg_buf: pointer to the SME message buffer
3500 *
3501 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3502 * in BTAMP AP.
3503 *
3504 * Return: None
3505 */
3506
3507void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3508 uint32_t *msg_buf)
3509{
3510 tSirSmeAssocCnf assoc_cnf;
3511 tpDphHashNode sta_ds = NULL;
3512 tpPESession session_entry = NULL;
3513 uint8_t session_id;
3514 tpSirAssocReq assoc_req;
3515
3516 if (msg_buf == NULL) {
3517 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL "));
3518 goto end;
3519 }
3520
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303521 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003522 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
3523 lim_log(mac_ctx, LOGE,
3524 FL("Received invalid SME_RE(ASSOC)_CNF message "));
3525 goto end;
3526 }
3527
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003528 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003529 &session_id);
3530 if (session_entry == NULL) {
3531 lim_log(mac_ctx, LOGE,
3532 FL("session does not exist for given bssId"));
3533 goto end;
3534 }
3535
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003536 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003537 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3538 (session_entry->limSmeState !=
3539 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
3540 lim_log(mac_ctx, LOGE, FL(
3541 "Rcvd unexpected msg %X in state %X, in role %X"),
3542 msg_type, session_entry->limSmeState,
3543 GET_LIM_SYSTEM_ROLE(session_entry));
3544 goto end;
3545 }
3546 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3547 &session_entry->dph.dphHashTable);
3548 if (sta_ds == NULL) {
3549 lim_log(mac_ctx, LOGE, FL(
3550 "Rcvd invalid msg %X due to no STA ctx, aid %d, peer "),
3551 msg_type, assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003552 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003553
3554 /*
3555 * send a DISASSOC_IND message to WSM to make sure
3556 * the state in WSM and LIM is the same
3557 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003558 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003559 eSIR_SME_STA_NOT_ASSOCIATED,
3560 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3561 session_entry->smeSessionId,
3562 session_entry->transactionId,
3563 session_entry);
3564 goto end;
3565 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303566 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003567 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303568 QDF_MAC_ADDR_SIZE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003569 lim_log(mac_ctx, LOG1, FL(
3570 "peerMacAddr mismatched for aid %d, peer "),
3571 assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003572 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003573 goto end;
3574 }
3575
3576 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3577 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3578 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3579 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3580 (msg_type != eWNI_SME_ASSOC_CNF))) {
3581 lim_log(mac_ctx, LOG1, FL(
3582 "not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3583 "StaD mlmState : %d"),
3584 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003585 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003586 goto end;
3587 }
3588 /*
3589 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3590 * has been received
3591 */
3592 lim_log(mac_ctx, LOG1, FL("Received SME_ASSOC_CNF. Delete Timer"));
3593 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3594 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3595
3596 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3597 /*
3598 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3599 * when it had received Assoc Request frame. Now, PE just needs
3600 * to send association rsp frame to the requesting BTAMP-STA.
3601 */
3602 sta_ds->mlmStaContext.mlmState =
3603 eLIM_MLM_LINK_ESTABLISHED_STATE;
3604 lim_log(mac_ctx, LOG1,
3605 FL("sending Assoc Rsp frame to STA (assoc id=%d) "),
3606 sta_ds->assocId);
3607 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3608 sta_ds->assocId, sta_ds->staAddr,
3609 sta_ds->mlmStaContext.subType, sta_ds,
3610 session_entry);
3611 goto end;
3612 } else {
3613 /*
3614 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3615 * to be associated since the HAL sta entry is created for
3616 * denied STA we need to remove this HAL entry.
3617 * So to do that set updateContext to 1
3618 */
3619 if (!sta_ds->mlmStaContext.updateContext)
3620 sta_ds->mlmStaContext.updateContext = 1;
3621 lim_log(mac_ctx, LOG1,
3622 FL("Recv Assoc Cnf, status Code : %d(assoc id=%d) "),
3623 assoc_cnf.statusCode, sta_ds->assocId);
3624 lim_reject_association(mac_ctx, sta_ds->staAddr,
3625 sta_ds->mlmStaContext.subType,
3626 true, sta_ds->mlmStaContext.authType,
3627 sta_ds->assocId, true,
3628 eSIR_MAC_UNSPEC_FAILURE_STATUS,
3629 session_entry);
3630 }
3631end:
3632 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3633 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3634 assoc_req = (tpSirAssocReq)
3635 session_entry->parsedAssocReq[sta_ds->assocId];
3636 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303637 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003638 assoc_req->assocReqFrame = NULL;
3639 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303640 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003641 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3642 }
3643}
3644
3645static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3646{
3647 tpDphHashNode pStaDs;
3648 tSirMacAddr peerMac;
3649 tpSirAddtsReq pSirAddts;
3650 uint32_t timeout;
3651 tpPESession psessionEntry;
3652 uint8_t sessionId; /* PE sessionId */
3653 uint8_t smesessionId;
3654 uint16_t smetransactionId;
3655
3656 if (pMsgBuf == NULL) {
3657 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
3658 return;
3659 }
3660
3661 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3662 &smetransactionId);
3663
3664 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3665
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003666 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3667 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003668 if (psessionEntry == NULL) {
3669 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3670 return;
3671 }
3672#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3673 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3674 0);
3675#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3676
3677 /* if sta
3678 * - verify assoc state
3679 * - send addts request to ap
3680 * - wait for addts response from ap
3681 * if ap, just ignore with error log
3682 */
3683 PELOG1(lim_log(pMac, LOG1,
3684 FL("Received SME_ADDTS_REQ (TSid %d, UP %d)"),
3685 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3686 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
3687 )
3688
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003689 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003690 PELOGE(lim_log(pMac, LOGE, "AddTs received on AP - ignoring");)
3691 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3692 psessionEntry, pSirAddts->req.tspec,
3693 smesessionId, smetransactionId);
3694 return;
3695 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003696
3697 pStaDs =
3698 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3699 &psessionEntry->dph.dphHashTable);
3700
3701 if (pStaDs == NULL) {
3702 PELOGE(lim_log
3703 (pMac, LOGE, "Cannot find AP context for addts req");
3704 )
3705 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3706 psessionEntry, pSirAddts->req.tspec,
3707 smesessionId, smetransactionId);
3708 return;
3709 }
3710
3711 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3712 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
3713 lim_log(pMac, LOGE, "AddTs received in invalid MLM state");
3714 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3715 psessionEntry, pSirAddts->req.tspec,
3716 smesessionId, smetransactionId);
3717 return;
3718 }
3719
3720 pSirAddts->req.wsmTspecPresent = 0;
3721 pSirAddts->req.wmeTspecPresent = 0;
3722 pSirAddts->req.lleTspecPresent = 0;
3723
3724 if ((pStaDs->wsmEnabled) &&
3725 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3726 SIR_MAC_ACCESSPOLICY_EDCA))
3727 pSirAddts->req.wsmTspecPresent = 1;
3728 else if (pStaDs->wmeEnabled)
3729 pSirAddts->req.wmeTspecPresent = 1;
3730 else if (pStaDs->lleEnabled)
3731 pSirAddts->req.lleTspecPresent = 1;
3732 else {
3733 PELOGW(lim_log
3734 (pMac, LOGW, FL("ADDTS_REQ ignore - qos is disabled"));
3735 )
3736 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3737 psessionEntry, pSirAddts->req.tspec,
3738 smesessionId, smetransactionId);
3739 return;
3740 }
3741
3742 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3743 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
3744 lim_log(pMac, LOGE,
3745 "AddTs received in invalid LIMsme state (%d)",
3746 psessionEntry->limSmeState);
3747 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3748 psessionEntry, pSirAddts->req.tspec,
3749 smesessionId, smetransactionId);
3750 return;
3751 }
3752
3753 if (pMac->lim.gLimAddtsSent) {
3754 lim_log(pMac, LOGE,
3755 "Addts (token %d, tsid %d, up %d) is still pending",
3756 pMac->lim.gLimAddtsReq.req.dialogToken,
3757 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3758 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3759 userPrio);
3760 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3761 psessionEntry, pSirAddts->req.tspec,
3762 smesessionId, smetransactionId);
3763 return;
3764 }
3765
3766 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3767
3768 /* save the addts request */
3769 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303770 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003771 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3772
3773 /* ship out the message now */
3774 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3775 psessionEntry);
3776 PELOG1(lim_log(pMac, LOG1, "Sent ADDTS request");)
3777 /* start a timer to wait for the response */
3778 if (pSirAddts->timeout)
3779 timeout = pSirAddts->timeout;
3780 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3781 eSIR_SUCCESS) {
3782 lim_log(pMac, LOGP,
3783 FL("Unable to get Cfg param %d (Addts Rsp Timeout)"),
3784 WNI_CFG_ADDTS_RSP_TIMEOUT);
3785 return;
3786 }
3787
3788 timeout = SYS_MS_TO_TICKS(timeout);
3789 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3790 != TX_SUCCESS) {
3791 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3792 return;
3793 }
3794 pMac->lim.gLimAddtsRspTimerCount++;
3795 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3796 pMac->lim.gLimAddtsRspTimerCount) !=
3797 TX_SUCCESS) {
3798 lim_log(pMac, LOGP, FL("AddtsRsp timer change failed!"));
3799 return;
3800 }
3801 MTRACE(mac_trace
3802 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3803 eLIM_ADDTS_RSP_TIMER));
3804
3805 /* add the sessionId to the timer object */
3806 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3807 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3808 TX_SUCCESS) {
3809 lim_log(pMac, LOGP, FL("AddtsRsp timer activation failed!"));
3810 return;
3811 }
3812 return;
3813}
3814
3815static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3816{
3817 tSirMacAddr peerMacAddr;
3818 uint8_t ac;
3819 tSirMacTSInfo *pTsinfo;
3820 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3821 tpDphHashNode pStaDs = NULL;
3822 tpPESession psessionEntry;
3823 uint8_t sessionId;
3824 uint32_t status = eSIR_SUCCESS;
3825 uint8_t smesessionId;
3826 uint16_t smetransactionId;
3827
3828 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3829 &smetransactionId);
3830
3831 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003832 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003833 &sessionId);
3834 if (psessionEntry == NULL) {
3835 lim_log(pMac, LOGE, "Session Does not exist for given bssId");
3836 status = eSIR_FAILURE;
3837 goto end;
3838 }
3839#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3840 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3841 0);
3842#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3843
3844 if (eSIR_SUCCESS !=
3845 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
3846 PELOGE(lim_log(pMac, LOGE, FL("lim_validate_delts_req failed"));)
3847 status = eSIR_FAILURE;
3848 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3849 smesessionId, smetransactionId);
3850 return;
3851 }
3852
3853 lim_log(pMac, LOG1,
3854 FL("Sent DELTS request to station with assocId = %d MacAddr = "
3855 MAC_ADDRESS_STR),
3856 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3857
3858 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3859 pDeltsReq->req.wmeTspecPresent,
3860 &pDeltsReq->req.tsinfo,
3861 &pDeltsReq->req.tspec, psessionEntry);
3862
3863 pTsinfo =
3864 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3865 tsinfo : &pDeltsReq->req.tsinfo;
3866
3867 /* We've successfully send DELTS frame to AP. Update the
3868 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3869 * is no longer trigger enabled or delivery enabled
3870 */
3871 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3872 pTsinfo, CLEAR_UAPSD_MASK);
3873
3874 /* We're deleting the TSPEC, so this particular AC is no longer
3875 * admitted. PE needs to downgrade the EDCA
3876 * parameters(for the AC for which TS is being deleted) to the
3877 * next best AC for which ACM is not enabled, and send the
3878 * updated values to HAL.
3879 */
3880 ac = upToAc(pTsinfo->traffic.userPrio);
3881
3882 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3883 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3884 ~(1 << ac);
3885 } else if (pTsinfo->traffic.direction ==
3886 SIR_MAC_DIRECTION_DNLINK) {
3887 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3888 ~(1 << ac);
3889 } else if (pTsinfo->traffic.direction ==
3890 SIR_MAC_DIRECTION_BIDIR) {
3891 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3892 ~(1 << ac);
3893 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3894 ~(1 << ac);
3895 }
3896
3897 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3898 psessionEntry);
3899
3900 pStaDs =
3901 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3902 &psessionEntry->dph.dphHashTable);
3903 if (pStaDs != NULL) {
3904 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3905 pStaDs->bssId);
3906 status = eSIR_SUCCESS;
3907 } else {
3908 lim_log(pMac, LOGE, FL("Self entry missing in Hash Table "));
3909 status = eSIR_FAILURE;
3910 }
3911#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003912 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003913#endif
3914
3915 /* send an sme response back */
3916end:
3917 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3918 smesessionId, smetransactionId);
3919}
3920
Jeff Johnson801f1532016-10-07 07:54:50 -07003921static void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac,
3922 uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003923{
3924 /* fetch the sessionEntry based on the sessionId */
3925 tpPESession psessionEntry;
3926 psessionEntry = pe_find_session_by_session_id(pMac,
3927 pMac->lim.limTimers.gLimAddtsRspTimer.
3928 sessionId);
3929 if (psessionEntry == NULL) {
3930 lim_log(pMac, LOGP,
3931 FL("Session Does not exist for given sessionID"));
3932 return;
3933 }
3934
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003935 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003936 lim_log(pMac, LOGW, "AddtsRspTimeout in non-Sta role (%d)",
3937 GET_LIM_SYSTEM_ROLE(psessionEntry));
3938 pMac->lim.gLimAddtsSent = false;
3939 return;
3940 }
3941
3942 if (!pMac->lim.gLimAddtsSent) {
3943 lim_log(pMac, LOGW, "AddtsRspTimeout but no AddtsSent");
3944 return;
3945 }
3946
3947 if (param != pMac->lim.gLimAddtsRspTimerCount) {
3948 lim_log(pMac, LOGE,
3949 FL("Invalid AddtsRsp Timer count %d (exp %d)"), param,
3950 pMac->lim.gLimAddtsRspTimerCount);
3951 return;
3952 }
3953 /* this a real response timeout */
3954 pMac->lim.gLimAddtsSent = false;
3955 pMac->lim.gLimAddtsRspTimerCount++;
3956
3957 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3958 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3959 psessionEntry->smeSessionId,
3960 psessionEntry->transactionId);
3961}
3962
3963/**
3964 * __lim_process_sme_get_statistics_request()
3965 *
3966 ***FUNCTION:
3967 *
3968 *
3969 ***NOTE:
3970 *
3971 * @param pMac Pointer to Global MAC structure
3972 * @param *pMsgBuf A pointer to the SME message buffer
3973 * @return None
3974 */
3975static void
3976__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3977{
3978 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08003979 struct scheduler_msg msgQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003980
3981 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3982
3983 msgQ.type = WMA_GET_STATISTICS_REQ;
3984
3985 msgQ.reserved = 0;
3986 msgQ.bodyptr = pMsgBuf;
3987 msgQ.bodyval = 0;
3988 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3989
3990 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303991 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003992 pMsgBuf = NULL;
3993 lim_log(pMac, LOGP, "Unable to forward request");
3994 return;
3995 }
3996
3997 return;
3998}
3999
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004000#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004001/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004002 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004003 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004004 * @pMac: Pointer to Global MAC structure
4005 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004006 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004007 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004008 */
4009static void
4010__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4011{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08004012 struct scheduler_msg msgQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004013
4014 msgQ.type = WMA_TSM_STATS_REQ;
4015 msgQ.reserved = 0;
4016 msgQ.bodyptr = pMsgBuf;
4017 msgQ.bodyval = 0;
4018 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
4019
4020 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304021 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004022 pMsgBuf = NULL;
4023 lim_log(pMac, LOGP, "Unable to forward request");
4024 return;
4025 }
4026}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004027#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004028
4029static void
4030__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4031{
4032 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
4033 tpPESession psessionEntry;
4034 uint8_t sessionId; /* PE sessionID */
4035
4036 PELOG1(lim_log(pMac, LOG1, FL("received UPDATE_APWPSIEs_REQ message")););
4037
4038 if (pMsgBuf == NULL) {
4039 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4040 return;
4041 }
4042
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304043 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004044 if (NULL == pUpdateAPWPSIEsReq) {
4045 lim_log(pMac, LOGP,
4046 FL
4047 ("call to AllocateMemory failed for pUpdateAPWPSIEsReq"));
4048 return;
4049 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304050 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004051 sizeof(struct sSirUpdateAPWPSIEsReq));
4052
4053 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08004054 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004055 &sessionId);
4056 if (psessionEntry == NULL) {
4057 lim_log(pMac, LOGW,
4058 FL("Session does not exist for given BSSID"));
4059 goto end;
4060 }
4061
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304062 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004063 sizeof(tSirAPWPSIEs));
4064
4065 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4066 lim_send_beacon_ind(pMac, psessionEntry);
4067
4068end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304069 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004070 return;
4071}
4072
4073void
4074lim_send_vdev_restart(tpAniSirGlobal pMac,
4075 tpPESession psessionEntry, uint8_t sessionId)
4076{
4077 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08004078 struct scheduler_msg msgQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004079 tSirRetStatus retCode = eSIR_SUCCESS;
4080
4081 if (psessionEntry == NULL) {
4082 PELOGE(lim_log
4083 (pMac, LOGE, "%s:%d: Invalid parameters", __func__,
4084 __LINE__);
4085 )
4086 return;
4087 }
4088
4089 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304090 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004091 if (NULL == pHalHiddenSsidVdevRestart) {
4092 PELOGE(lim_log
4093 (pMac, LOGE, "%s:%d: Unable to allocate memory",
4094 __func__, __LINE__);
4095 )
4096 return;
4097 }
4098
4099 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4100 pHalHiddenSsidVdevRestart->sessionId = sessionId;
4101
4102 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4103 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4104 msgQ.bodyval = 0;
4105
4106 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4107 if (eSIR_SUCCESS != retCode) {
4108 PELOGE(lim_log
4109 (pMac, LOGE, "%s:%d: wma_post_ctrl_msg() failed", __func__,
4110 __LINE__);
4111 )
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304112 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004113 }
4114}
4115
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304116/**
4117 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
4118 * @mac_ctx: Pointer to Global MAC structure
4119 * @msg_buf: Pointer to SME message buffer
4120 *
4121 * Return: None
4122 */
4123static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
4124 uint32_t *msg_buf)
4125{
4126 tpPESession pe_session;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08004127 struct scheduler_msg wma_msg;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304128 tSirRetStatus status;
4129 tSirRoamOffloadScanReq *req_buffer;
4130 uint16_t local_ie_len;
4131 uint8_t *local_ie_buf;
4132
4133 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
4134 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
4135 req_buffer->sessionId);
4136
4137 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
4138 if (!local_ie_buf) {
Arif Hussain963331b2016-10-27 22:59:01 -07004139 lim_log(mac_ctx, LOGE,
4140 FL("Mem Alloc failed for local_ie_buf"));
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304141 return;
4142 }
4143
4144 local_ie_len = req_buffer->assoc_ie.length;
4145 /* Update ext cap IE if present */
4146 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07004147 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
4148 local_ie_buf, &local_ie_len)) {
4149 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07004150 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
4151 req_buffer->assoc_ie.length = local_ie_len;
4152 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
4153 local_ie_buf, local_ie_len);
4154 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304155 }
4156 qdf_mem_free(local_ie_buf);
4157
4158 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
4159 wma_msg.bodyptr = req_buffer;
4160
4161 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
4162 if (eSIR_SUCCESS != status) {
4163 lim_log(mac_ctx, LOGE,
4164 FL("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed"));
4165 qdf_mem_free(req_buffer);
4166 }
4167}
4168
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304169/*
4170 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
4171 * @mac_ctx: Pointer to global mac context
4172 * @session: Pointer to PE session
4173 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
4174 * 1 - Disable broadcast SSID
4175 *
4176 * Return: None
4177 */
4178static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
4179 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004180{
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304181 lim_log(mac_ctx, LOG1, FL("received HIDE_SSID message"));
4182 if (ssid_hidden != session->ssidHidden)
4183 session->ssidHidden = ssid_hidden;
4184 else {
4185 lim_log(mac_ctx, LOG1, FL("Same config already present!"));
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05304186 return;
4187 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004188
4189 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304190 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004191
4192 /* Update beacon */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304193 sch_set_fixed_beacon_fields(mac_ctx, session);
4194 lim_send_beacon_ind(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004195
4196 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304197}
4198
4199/**
4200 * __lim_process_sme_session_update - process SME session update msg
4201 *
4202 * @mac_ctx: Pointer to global mac context
4203 * @msg_buf: Pointer to the received message buffer
4204 *
4205 * Return: None
4206 */
4207static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
4208 uint32_t *msg_buf)
4209{
4210 struct sir_update_session_param *msg;
4211 tpPESession session;
4212
4213 if (!msg_buf) {
4214 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
4215 return;
4216 }
4217
4218 msg = (struct sir_update_session_param *) msg_buf;
4219
4220 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
4221 if (!session) {
4222 lim_log(mac_ctx, LOGW,
4223 "Session does not exist for given sessionId %d",
4224 msg->session_id);
4225 return;
4226 }
4227
4228 lim_log(mac_ctx, LOG1, FL("received SME Session update for %d val %d"),
4229 msg->param_type, msg->param_val);
4230 switch (msg->param_type) {
4231 case SIR_PARAM_SSID_HIDDEN:
4232 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
4233 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05304234 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
4235 session->ignore_assoc_disallowed = msg->param_val;
4236 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304237 default:
4238 lim_log(mac_ctx, LOGE, FL("Unknown session param"));
4239 break;
4240 }
4241}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004242
4243static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4244{
4245 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4246 tpPESession psessionEntry;
4247 uint8_t sessionId; /* PE sessionID */
4248
4249 if (pMsgBuf == NULL) {
4250 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4251 return;
4252 }
4253
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304254 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004255 if (NULL == pUpdateAPWPARSNIEsReq) {
4256 lim_log(pMac, LOGP,
4257 FL
4258 ("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq"));
4259 return;
4260 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304261 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004262 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4263
4264 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004265 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004266 &sessionId);
4267 if (psessionEntry == NULL) {
4268 lim_log(pMac, LOGW,
4269 FL("Session does not exist for given BSSID"));
4270 goto end;
4271 }
4272
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304273 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004274 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4275
4276 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4277 &psessionEntry->
4278 pLimStartBssReq->rsnIE,
4279 psessionEntry);
4280
4281 psessionEntry->pLimStartBssReq->privacy = 1;
4282 psessionEntry->privacy = 1;
4283
4284 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4285 lim_send_beacon_ind(pMac, psessionEntry);
4286
4287end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304288 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004289 return;
4290} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4291
4292/*
4293 Update the beacon Interval dynamically if beaconInterval is different in MCC
4294 */
4295static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4296{
4297 tpSirChangeBIParams pChangeBIParams;
4298 tpPESession psessionEntry;
4299 uint8_t sessionId = 0;
4300 tUpdateBeaconParams beaconParams;
4301
4302 PELOG1(lim_log(pMac, LOG1,
4303 FL("received Update Beacon Interval message"));
4304 );
4305
4306 if (pMsgBuf == NULL) {
4307 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4308 return;
4309 }
4310
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304311 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004312 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4313
4314 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004315 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004316 &sessionId);
4317 if (psessionEntry == NULL) {
4318 lim_log(pMac, LOGE,
4319 FL("Session does not exist for given BSSID"));
4320 return;
4321 }
4322
4323 /*Update sessionEntry Beacon Interval */
4324 if (psessionEntry->beaconParams.beaconInterval !=
4325 pChangeBIParams->beaconInterval) {
4326 psessionEntry->beaconParams.beaconInterval =
4327 pChangeBIParams->beaconInterval;
4328 }
4329
4330 /*Update sch beaconInterval */
4331 if (pMac->sch.schObject.gSchBeaconInterval !=
4332 pChangeBIParams->beaconInterval) {
4333 pMac->sch.schObject.gSchBeaconInterval =
4334 pChangeBIParams->beaconInterval;
4335
4336 PELOG1(lim_log(pMac, LOG1,
4337 FL
4338 ("LIM send update BeaconInterval Indication : %d"),
4339 pChangeBIParams->beaconInterval);
4340 );
4341
4342 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4343 /* Update beacon */
4344 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4345
4346 beaconParams.bssIdx = psessionEntry->bssIdx;
4347 /* Set change in beacon Interval */
4348 beaconParams.beaconInterval =
4349 pChangeBIParams->beaconInterval;
4350 beaconParams.paramChangeBitmap =
4351 PARAM_BCN_INTERVAL_CHANGED;
4352 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4353 }
4354 }
4355
4356 return;
4357} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4358
4359#ifdef QCA_HT_2040_COEX
4360static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4361 uint32_t *pMsgBuf)
4362{
4363 tpSirSetHT2040Mode pSetHT2040Mode;
4364 tpPESession psessionEntry;
4365 uint8_t sessionId = 0;
Rajeev Kumarf7d84422017-01-21 15:45:44 -08004366 struct scheduler_msg msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004367 tUpdateVHTOpMode *pHtOpMode = NULL;
4368 uint16_t staId = 0;
4369 tpDphHashNode pStaDs = NULL;
4370
4371 PELOG1(lim_log(pMac, LOG1, FL("received Set HT 20/40 mode message")););
4372 if (pMsgBuf == NULL) {
4373 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4374 return;
4375 }
4376
4377 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4378
4379 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004380 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004381 &sessionId);
4382 if (psessionEntry == NULL) {
4383 lim_log(pMac, LOG1,
4384 FL("Session does not exist for given BSSID "));
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004385 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004386 return;
4387 }
4388
4389 lim_log(pMac, LOG1, FL("Update session entry for cbMod=%d"),
4390 pSetHT2040Mode->cbMode);
4391 /*Update sessionEntry HT related fields */
4392 switch (pSetHT2040Mode->cbMode) {
4393 case PHY_SINGLE_CHANNEL_CENTERED:
4394 psessionEntry->htSecondaryChannelOffset =
4395 PHY_SINGLE_CHANNEL_CENTERED;
4396 psessionEntry->htRecommendedTxWidthSet = 0;
4397 if (pSetHT2040Mode->obssEnabled)
4398 psessionEntry->htSupportedChannelWidthSet
4399 = eHT_CHANNEL_WIDTH_40MHZ;
4400 else
4401 psessionEntry->htSupportedChannelWidthSet
4402 = eHT_CHANNEL_WIDTH_20MHZ;
4403 break;
4404 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4405 psessionEntry->htSecondaryChannelOffset =
4406 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4407 psessionEntry->htRecommendedTxWidthSet = 1;
4408 break;
4409 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4410 psessionEntry->htSecondaryChannelOffset =
4411 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4412 psessionEntry->htRecommendedTxWidthSet = 1;
4413 break;
4414 default:
4415 lim_log(pMac, LOGE, FL("Invalid cbMode"));
4416 return;
4417 }
4418
4419 /* Update beacon */
4420 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4421 lim_send_beacon_ind(pMac, psessionEntry);
4422
4423 /* update OP Mode for each associated peer */
4424 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4425 pStaDs = dph_get_hash_entry(pMac, staId,
4426 &psessionEntry->dph.dphHashTable);
4427 if (NULL == pStaDs)
4428 continue;
4429
4430 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304431 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004432 if (NULL == pHtOpMode) {
4433 lim_log(pMac, LOGE,
4434 FL
4435 ("%s: Not able to allocate memory for setting OP mode"),
4436 __func__);
4437 return;
4438 }
4439 pHtOpMode->opMode =
4440 (psessionEntry->htSecondaryChannelOffset ==
4441 PHY_SINGLE_CHANNEL_CENTERED) ?
4442 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4443 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304444 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004445 sizeof(tSirMacAddr));
4446 pHtOpMode->smesessionId = sessionId;
4447
4448 msg.type = WMA_UPDATE_OP_MODE;
4449 msg.reserved = 0;
4450 msg.bodyptr = pHtOpMode;
Krunal Soni66c113f2016-12-21 16:46:47 -08004451 if (!QDF_IS_STATUS_SUCCESS(
Rajeev Kumarf7d84422017-01-21 15:45:44 -08004452 scheduler_post_msg(QDF_MODULE_ID_WMA,
Krunal Soni66c113f2016-12-21 16:46:47 -08004453 &msg))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004454 lim_log(pMac, LOGE,
4455 FL
4456 ("%s: Not able to post WMA_UPDATE_OP_MODE message to WMA"),
4457 __func__);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304458 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004459 return;
4460 }
4461 lim_log(pMac, LOG1,
4462 FL
4463 ("%s: Notifed FW about OP mode: %d for staId=%d"),
4464 __func__, pHtOpMode->opMode, staId);
4465
4466 } else
4467 lim_log(pMac, LOG1,
4468 FL("%s: station %d does not support HT40\n"),
4469 __func__, staId);
4470 }
4471
4472 return;
4473}
4474#endif
4475
4476/* -------------------------------------------------------------------- */
4477/**
4478 * __lim_process_report_message
4479 *
4480 * FUNCTION: Processes the next received Radio Resource Management message
4481 *
4482 * LOGIC:
4483 *
4484 * ASSUMPTIONS:
4485 *
4486 * NOTE:
4487 *
4488 * @param None
4489 * @return None
4490 */
4491
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004492static void __lim_process_report_message(tpAniSirGlobal pMac,
4493 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004494{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004495 switch (pMsg->type) {
4496 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4497 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4498 break;
4499 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004500 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004501 break;
4502 default:
4503 lim_log(pMac, LOGE, FL("Invalid msg type:%d"), pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004504 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004505}
4506
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004507/* -------------------------------------------------------------------- */
4508/**
4509 * lim_send_set_max_tx_power_req
4510 *
4511 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4512 *
4513 * LOGIC:
4514 *
4515 * ASSUMPTIONS:
4516 *
4517 * NOTE:
4518 *
4519 * @param txPower txPower to be set.
4520 * @param pSessionEntry session entry.
4521 * @return None
4522 */
4523tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004524lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004525 tpPESession pSessionEntry)
4526{
4527 tpMaxTxPowerParams pMaxTxParams = NULL;
4528 tSirRetStatus retCode = eSIR_SUCCESS;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08004529 struct scheduler_msg msgQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004530
4531 if (pSessionEntry == NULL) {
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304532 lim_log(pMac, LOGE, FL("Inavalid parameters"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004533 return eSIR_FAILURE;
4534 }
4535
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304536 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004537 if (NULL == pMaxTxParams) {
4538 lim_log(pMac, LOGP,
4539 FL("Unable to allocate memory for pMaxTxParams "));
4540 return eSIR_MEM_ALLOC_FAILED;
4541
4542 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004543 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304544 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304545 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304546 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004547 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304548 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004549
4550 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4551 msgQ.bodyptr = pMaxTxParams;
4552 msgQ.bodyval = 0;
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05304553 lim_log(pMac, LOG1, FL("Post WMA_SET_MAX_TX_POWER_REQ to WMA"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004554 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4555 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4556 if (eSIR_SUCCESS != retCode) {
4557 lim_log(pMac, LOGE, FL("wma_post_ctrl_msg() failed"));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304558 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004559 }
4560 return retCode;
4561}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004562
4563/**
4564 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4565 *
4566 * @mac_ctx: Pointer to Global MAC structure
4567 * @msg_buf: pointer to the SME message buffer
4568 *
4569 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4570 * from SME. It Register this information within PE.
4571 *
4572 * Return: None
4573 */
4574static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4575 uint32_t *msg_buf)
4576{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304577 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004578 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4579 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4580 struct mgmt_frm_reg_info *next = NULL;
4581 bool match = false;
4582
4583 lim_log(mac_ctx, LOG1, FL(
4584 "registerFrame %d, frameType %d, matchLen %d"),
4585 sme_req->registerFrame, sme_req->frameType,
4586 sme_req->matchLen);
4587 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304588 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304589 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4590 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304591 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004592
4593 while (lim_mgmt_regn != NULL) {
4594 if (lim_mgmt_regn->frameType != sme_req->frameType)
4595 goto skip_match;
4596 if (sme_req->matchLen) {
4597 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304598 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004599 sme_req->matchData,
4600 lim_mgmt_regn->matchLen))) {
4601 /* found match! */
4602 match = true;
4603 break;
4604 }
4605 } else {
4606 /* found match! */
4607 match = true;
4608 break;
4609 }
4610skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304611 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304612 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004613 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304614 (qdf_list_node_t *)lim_mgmt_regn,
4615 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304616 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004617 lim_mgmt_regn = next;
4618 next = NULL;
4619 }
4620 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304621 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004622 if (QDF_STATUS_SUCCESS ==
4623 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004624 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004625 (qdf_list_node_t *)lim_mgmt_regn))
4626 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304627 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004628 }
4629
4630 if (sme_req->registerFrame) {
4631 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304632 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004633 sme_req->matchLen);
4634 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004635 lim_mgmt_regn->frameType = sme_req->frameType;
4636 lim_mgmt_regn->matchLen = sme_req->matchLen;
4637 lim_mgmt_regn->sessionId = sme_req->sessionId;
4638 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304639 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004640 sme_req->matchData,
4641 sme_req->matchLen);
4642 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304643 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004644 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304645 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004646 gLimMgmtFrameRegistratinQueue,
4647 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304648 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004649 &mac_ctx->lim.lim_frame_register_lock);
4650 }
4651 }
4652 return;
4653}
4654
4655static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4656{
4657 lim_log(pMac, LOG1, FL("Dereg msgType %d"),
4658 pMac->lim.gDeferMsgTypeForNOA);
4659 pMac->lim.gDeferMsgTypeForNOA = 0;
4660 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4661 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304662 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004663 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4664 }
4665}
4666
4667/**
4668 * lim_process_regd_defd_sme_req_after_noa_start()
4669 *
4670 * mac_ctx: Pointer to Global MAC structure
4671 *
4672 * This function is called to process deferred sme req message
4673 * after noa start.
4674 *
4675 * Return: None
4676 */
4677void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4678{
4679 bool buf_consumed = true;
4680
4681 lim_log(mac_ctx, LOG1, FL("Process defd sme req %d"),
4682 mac_ctx->lim.gDeferMsgTypeForNOA);
4683
4684 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4685 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
4686 lim_log(mac_ctx, LOGW,
4687 FL("start rcvd from FW when no sme deferred msg pending. Do nothing. "));
4688 lim_log(mac_ctx, LOGW,
4689 FL("It may happen when NOA start ind and timeout happen at the same time"));
4690 return;
4691 }
4692 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4693 case eWNI_SME_SCAN_REQ:
4694 __lim_process_sme_scan_req(mac_ctx,
4695 mac_ctx->lim.gpDefdSmeMsgForNOA);
4696 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004697 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4698 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4699 mac_ctx->lim.gpDefdSmeMsgForNOA);
4700 /*
4701 * lim_process_remain_on_chnl_req doesnt want us to free
4702 * the buffer since it is freed in lim_remain_on_chn_rsp.
4703 * this change is to avoid "double free"
4704 */
4705 if (false == buf_consumed)
4706 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4707 break;
4708 case eWNI_SME_JOIN_REQ:
4709 __lim_process_sme_join_req(mac_ctx,
4710 mac_ctx->lim.gpDefdSmeMsgForNOA);
4711 break;
4712 default:
4713 lim_log(mac_ctx, LOGE, FL("Unknown deferred msg type %d"),
4714 mac_ctx->lim.gDeferMsgTypeForNOA);
4715 break;
4716 }
4717 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4718}
4719
4720static void
4721__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4722{
4723 tpSirResetAPCapsChange pResetCapsChange;
4724 tpPESession psessionEntry;
4725 uint8_t sessionId = 0;
4726 if (pMsgBuf == NULL) {
4727 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
4728 return;
4729 }
4730
4731 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4732 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004733 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4734 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004735 if (psessionEntry == NULL) {
4736 lim_log(pMac, LOGE,
4737 FL("Session does not exist for given BSSID"));
4738 return;
4739 }
4740
4741 psessionEntry->limSentCapsChangeNtf = false;
4742 return;
4743}
4744
4745/**
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304746 * lim_register_p2p_ack_ind_cb() - Save the p2p ack indication callback.
4747 * @mac_ctx: Mac pointer
4748 * @msg_buf: Msg pointer containing the callback
4749 *
4750 * This function is used to save the p2p ack indication callback in PE.
4751 *
4752 * Return: None
4753 */
4754static void lim_register_p2p_ack_ind_cb(tpAniSirGlobal mac_ctx,
4755 uint32_t *msg_buf)
4756{
4757 struct sir_sme_p2p_ack_ind_cb_req *sme_req =
4758 (struct sir_sme_p2p_ack_ind_cb_req *)msg_buf;
4759
4760 if (NULL == msg_buf) {
4761 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4762 return;
4763 }
4764 if (sme_req->callback)
4765 mac_ctx->p2p_ack_ind_cb =
4766 sme_req->callback;
4767 else
4768 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4769}
4770
4771/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304772 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4773 * indication callback in PE.
4774 * @mac_ptr: Mac pointer
4775 * @msg_buf: Msg pointer containing the callback
4776 *
4777 * This function is used save the Management frame
4778 * indication callback in PE.
4779 *
4780 * Return: None
4781 */
4782static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4783 uint32_t *msg_buf)
4784{
4785 struct sir_sme_mgmt_frame_cb_req *sme_req =
4786 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4787
4788 if (NULL == msg_buf) {
4789 lim_log(mac_ctx, LOGE, FL("msg_buf is null"));
4790 return;
4791 }
4792 if (sme_req->callback)
4793 mac_ctx->mgmt_frame_ind_cb =
4794 (sir_mgmt_frame_ind_callback)sme_req->callback;
4795 else
4796 lim_log(mac_ctx, LOGE, FL("sme_req->callback is null"));
4797}
4798
4799/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304800 *__lim_process_send_disassoc_frame: function processes disassoc frame
4801 * @mac_ctx: pointer to mac context
4802 * @msg_buf: message buffer
4803 *
4804 * function processes disassoc request received from SME
4805 *
4806 * return: none
4807 */
4808static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4809 uint32_t *msg_buf)
4810{
4811 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4812 tSirRetStatus status;
4813 tpPESession session_entry = NULL;
4814 uint8_t sme_session_id;
4815 uint16_t sme_trans_id;
4816
4817 if (msg_buf == NULL) {
4818 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
4819 return;
4820 }
4821
4822 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4823 &sme_trans_id);
4824
4825 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4826 &sme_send_disassoc_frame_req,
4827 (uint8_t *)msg_buf);
4828
4829 if ((eSIR_FAILURE == status) ||
4830 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4831 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
4832 PELOGE(lim_log(mac_ctx, LOGE,
4833 FL("received invalid SME_DISASSOC_REQ message"));)
4834 return;
4835 }
4836
4837 session_entry = pe_find_session_by_sme_session_id(
4838 mac_ctx, sme_session_id);
4839 if (session_entry == NULL) {
4840 lim_log(mac_ctx, LOGE,
4841 FL("session does not exist for given bssId "MAC_ADDRESS_STR),
4842 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4843 return;
4844 }
4845
4846 lim_log(mac_ctx, LOG1,
4847 FL("msg_type->%d len->%d sess_id->%d trans_id->%d mac->"MAC_ADDRESS_STR" reason->%d wait_for_ack->%d"),
4848 sme_send_disassoc_frame_req.msg_type,
4849 sme_send_disassoc_frame_req.length,
4850 sme_send_disassoc_frame_req.session_id,
4851 sme_send_disassoc_frame_req.trans_id,
4852 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4853 sme_send_disassoc_frame_req.reason,
4854 sme_send_disassoc_frame_req.wait_for_ack);
4855
4856 lim_send_disassoc_mgmt_frame(mac_ctx,
4857 sme_send_disassoc_frame_req.reason,
4858 sme_send_disassoc_frame_req.peer_mac,
4859 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4860}
4861
4862/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004863 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4864 * @mac_ctx: Pointer to Global MAC structure
4865 * @pdev_id: pdev id to set the IE.
4866 * @nss: Nss values to prepare the HT IE.
4867 *
4868 * Prepares the HT IE with self capabilities for different
4869 * Nss values and sends the set HT IE req to FW.
4870 *
4871 * Return: None
4872 */
4873static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4874 uint8_t nss)
4875{
4876 struct set_ie_param *ie_params;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08004877 struct scheduler_msg msg;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004878 tSirRetStatus rc = eSIR_SUCCESS;
4879 uint8_t *p_ie = NULL;
4880 tHtCaps *p_ht_cap;
4881 int i;
4882
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004883 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004884 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4885 if (NULL == ie_params) {
4886 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4887 return;
4888 }
4889 ie_params->nss = i;
4890 ie_params->pdev_id = pdev_id;
4891 ie_params->ie_type = DOT11_HT_IE;
4892 /* 2 for IE len and EID */
4893 ie_params->ie_len = 2 + sizeof(tHtCaps);
4894 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4895 if (NULL == ie_params->ie_ptr) {
4896 qdf_mem_free(ie_params);
4897 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4898 return;
4899 }
4900 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4901 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4902 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4903 ie_params->ie_len);
4904
4905 if (NSS_1x1_MODE == i) {
4906 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4907 ie_params->ie_len,
4908 DOT11F_EID_HTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004909 if (NULL == p_ie) {
4910 qdf_mem_free(ie_params->ie_ptr);
4911 qdf_mem_free(ie_params);
4912 lim_log(mac_ctx, LOGE,
4913 FL("failed to get IE ptr"));
4914 return;
4915 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004916 p_ht_cap = (tHtCaps *)&p_ie[2];
4917 p_ht_cap->supportedMCSSet[1] = 0;
4918 p_ht_cap->txSTBC = 0;
4919 }
4920
4921 msg.type = WMA_SET_PDEV_IE_REQ;
4922 msg.bodyptr = ie_params;
4923 msg.bodyval = 0;
4924
4925 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4926 if (rc != eSIR_SUCCESS) {
4927 lim_log(mac_ctx, LOGE,
4928 FL("wma_post_ctrl_msg() return failure"));
4929 qdf_mem_free(ie_params->ie_ptr);
4930 qdf_mem_free(ie_params);
4931 return;
4932 }
4933 }
4934}
4935
4936/**
4937 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4938 * @mac_ctx: Pointer to Global MAC structure
4939 * @pdev_id: pdev id to set the IE.
4940 * @nss: Nss values to prepare the VHT IE.
4941 *
4942 * Prepares the VHT IE with self capabilities for different
4943 * Nss values and sends the set VHT IE req to FW.
4944 *
4945 * Return: None
4946 */
4947static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4948 uint8_t nss)
4949{
4950 struct set_ie_param *ie_params;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08004951 struct scheduler_msg msg;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004952 tSirRetStatus rc = eSIR_SUCCESS;
4953 uint8_t *p_ie = NULL;
4954 tSirMacVHTCapabilityInfo *vht_cap;
4955 int i;
4956 tSirVhtMcsInfo *vht_mcs;
4957
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004958 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004959 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4960 if (NULL == ie_params) {
4961 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4962 return;
4963 }
4964 ie_params->nss = i;
4965 ie_params->pdev_id = pdev_id;
4966 ie_params->ie_type = DOT11_VHT_IE;
4967 /* 2 for IE len and EID */
4968 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4969 sizeof(tSirVhtMcsInfo);
4970 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4971 if (NULL == ie_params->ie_ptr) {
4972 qdf_mem_free(ie_params);
4973 lim_log(mac_ctx, LOGE, FL("mem alloc failed"));
4974 return;
4975 }
4976 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4977 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4978 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4979 ie_params->ie_len);
4980
4981 if (NSS_1x1_MODE == i) {
4982 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4983 ie_params->ie_len,
4984 DOT11F_EID_VHTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004985 if (NULL == p_ie) {
4986 qdf_mem_free(ie_params->ie_ptr);
4987 qdf_mem_free(ie_params);
4988 lim_log(mac_ctx, LOGE,
4989 FL("failed to get IE ptr"));
4990 return;
4991 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004992 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4993 vht_cap->txSTBC = 0;
4994 vht_mcs =
4995 (tSirVhtMcsInfo *)&p_ie[2 +
4996 sizeof(tSirMacVHTCapabilityInfo)];
4997 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4998 vht_mcs->rxHighest =
4999 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
5000 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
5001 vht_mcs->txHighest =
5002 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
5003 }
5004 msg.type = WMA_SET_PDEV_IE_REQ;
5005 msg.bodyptr = ie_params;
5006 msg.bodyval = 0;
5007
5008 rc = wma_post_ctrl_msg(mac_ctx, &msg);
5009 if (rc != eSIR_SUCCESS) {
5010 lim_log(mac_ctx, LOGE,
5011 FL("wma_post_ctrl_msg failure"));
5012 qdf_mem_free(ie_params->ie_ptr);
5013 qdf_mem_free(ie_params);
5014 return;
5015 }
5016 }
5017}
5018
5019/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07005020 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
5021 * @mac_ctx: Pointer to Global MAC structure
5022 * @msg_buf: Pointer to the SME message buffer
5023 *
5024 * This function is called by limProcessMessageQueue(). This function sets the
5025 * VDEV IEs to the FW.
5026 *
5027 * Return: None
5028 */
5029static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
5030 uint32_t *msg_buf)
5031{
5032 struct sir_set_vdev_ies_per_band *p_msg =
5033 (struct sir_set_vdev_ies_per_band *)msg_buf;
5034
5035 if (NULL == p_msg) {
5036 lim_log(mac_ctx, LOGE, FL("NULL p_msg"));
5037 return;
5038 }
5039
5040 lim_log(mac_ctx, LOG1, FL("rcvd set vdev ie per band req vdev_id = %d"),
5041 p_msg->vdev_id);
5042 /* intentionally using NULL here so that self capabilty are sent */
5043 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
5044 QDF_STATUS_SUCCESS)
5045 lim_log(mac_ctx, LOGE, FL("Unable to send HT/VHT Cap to FW"));
5046}
5047
5048/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005049 * lim_process_set_pdev_IEs() - process the set pdev IE req
5050 * @mac_ctx: Pointer to Global MAC structure
5051 * @msg_buf: Pointer to the SME message buffer
5052 *
5053 * This function is called by limProcessMessageQueue(). This
5054 * function sets the PDEV IEs to the FW.
5055 *
5056 * Return: None
5057 */
5058static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
5059{
5060 struct sir_set_ht_vht_cfg *ht_vht_cfg;
5061
5062 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
5063
5064 if (NULL == ht_vht_cfg) {
5065 lim_log(mac_ctx, LOGE, FL("NULL ht_vht_cfg"));
5066 return;
5067 }
5068
5069 lim_log(mac_ctx, LOG1, FL("rcvd set pdev ht vht ie req with nss = %d"),
5070 ht_vht_cfg->nss);
5071 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
5072
5073 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
5074 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
5075 ht_vht_cfg->nss);
5076}
5077
5078/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305079 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
5080 *
5081 * access policy
5082 * @mac_ctx: pointer to mac context
5083 * @msg: message buffer
5084 *
5085 * function processes vendor IE and access policy from SME and updates PE
5086 *
5087 * session entry
5088 *
5089 * return: none
5090*/
5091static void lim_process_sme_update_access_policy_vendor_ie(
5092 tpAniSirGlobal mac_ctx,
5093 uint32_t *msg)
5094{
5095 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
5096 struct sPESession *pe_session_entry;
5097 uint8_t num_bytes;
5098
5099 if (!msg) {
5100 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
5101 return;
5102 }
5103 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
5104 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
5105 update_vendor_ie->sme_session_id);
5106
5107 if (!pe_session_entry) {
5108 lim_log(mac_ctx, LOGE,
5109 FL("Session does not exist for given sme session id(%hu)"),
5110 update_vendor_ie->sme_session_id);
5111 return;
5112 }
5113 if (pe_session_entry->access_policy_vendor_ie)
5114 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
5115
5116 num_bytes = update_vendor_ie->ie[1] + 2;
5117 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
5118
5119 if (!pe_session_entry->access_policy_vendor_ie) {
5120 lim_log(mac_ctx, LOGE,
5121 FL("Failed to allocate memory for vendor ie"));
5122 return;
5123 }
5124 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
5125 &update_vendor_ie->ie[0], num_bytes);
5126
5127 pe_session_entry->access_policy = update_vendor_ie->access_policy;
5128}
5129
5130/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005131 * lim_process_sme_req_messages()
5132 *
5133 ***FUNCTION:
5134 * This function is called by limProcessMessageQueue(). This
5135 * function processes SME request messages from HDD or upper layer
5136 * application.
5137 *
5138 ***LOGIC:
5139 *
5140 ***ASSUMPTIONS:
5141 *
5142 ***NOTE:
5143 *
5144 * @param pMac Pointer to Global MAC structure
5145 * @param msgType Indicates the SME message type
5146 * @param *pMsgBuf A pointer to the SME message buffer
5147 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5148 * false - if pMsgBuf is not to be freed.
5149 */
5150
Rajeev Kumarfeb96382017-01-22 19:42:09 -08005151bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
5152 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005153{
5154 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
5155 uint32_t *pMsgBuf = pMsg->bodyptr;
5156 tpSirSmeScanReq pScanReq;
5157 PELOG1(lim_log
5158 (pMac, LOG1,
5159 FL
5160 ("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)"),
5161 lim_msg_str(pMsg->type), pMsg->type,
5162 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
5163 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
5164 )
5165
5166 pScanReq = (tpSirSmeScanReq) pMsgBuf;
5167 /* If no insert NOA required then execute the code below */
5168
5169 switch (pMsg->type) {
5170 case eWNI_SME_SYS_READY_IND:
5171 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
5172 break;
5173
5174 case eWNI_SME_START_BSS_REQ:
5175 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
5176 break;
5177
5178 case eWNI_SME_SCAN_REQ:
5179 __lim_process_sme_scan_req(pMac, pMsgBuf);
5180 break;
5181
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005182 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5183 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
5184 break;
5185
5186 case eWNI_SME_UPDATE_NOA:
5187 __lim_process_sme_no_a_update(pMac, pMsgBuf);
5188 break;
5189 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
5190 __lim_process_clear_dfs_channel_list(pMac, pMsg);
5191 break;
5192 case eWNI_SME_JOIN_REQ:
5193 __lim_process_sme_join_req(pMac, pMsgBuf);
5194 break;
5195
5196 case eWNI_SME_REASSOC_REQ:
5197 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
5198 break;
5199
5200 case eWNI_SME_DISASSOC_REQ:
5201 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
5202 break;
5203
5204 case eWNI_SME_DISASSOC_CNF:
5205 case eWNI_SME_DEAUTH_CNF:
5206 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
5207 break;
5208
5209 case eWNI_SME_DEAUTH_REQ:
5210 __lim_process_sme_deauth_req(pMac, pMsgBuf);
5211 break;
5212
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05305213 case eWNI_SME_SEND_DISASSOC_FRAME:
5214 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
5215 break;
5216
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005217 case eWNI_SME_SETCONTEXT_REQ:
5218 __lim_process_sme_set_context_req(pMac, pMsgBuf);
5219 break;
5220
5221 case eWNI_SME_STOP_BSS_REQ:
5222 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
5223 break;
5224
5225 case eWNI_SME_ASSOC_CNF:
5226 if (pMsg->type == eWNI_SME_ASSOC_CNF)
5227 PELOG1(lim_log(pMac,
5228 LOG1, FL("Received ASSOC_CNF message"));)
5229 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
5230 pMsgBuf);
5231 break;
5232
5233 case eWNI_SME_ADDTS_REQ:
5234 PELOG1(lim_log(pMac, LOG1, FL("Received ADDTS_REQ message"));)
5235 __lim_process_sme_addts_req(pMac, pMsgBuf);
5236 break;
5237
5238 case eWNI_SME_DELTS_REQ:
5239 PELOG1(lim_log(pMac, LOG1, FL("Received DELTS_REQ message"));)
5240 __lim_process_sme_delts_req(pMac, pMsgBuf);
5241 break;
5242
5243 case SIR_LIM_ADDTS_RSP_TIMEOUT:
5244 PELOG1(lim_log
5245 (pMac, LOG1,
5246 FL("Received SIR_LIM_ADDTS_RSP_TIMEOUT message "));
5247 )
5248 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
5249 break;
5250
5251 case eWNI_SME_GET_STATISTICS_REQ:
5252 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
5253 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
5254 bufConsumed = false;
5255 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005256#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005257 case eWNI_SME_GET_TSM_STATS_REQ:
5258 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
5259 bufConsumed = false;
5260 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005261#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005262 case eWNI_SME_GET_ASSOC_STAS_REQ:
5263 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
5264 break;
5265 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5266 lim_process_tkip_counter_measures(pMac, pMsgBuf);
5267 break;
5268
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05305269 case eWNI_SME_SESSION_UPDATE_PARAM:
5270 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005271 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05305272 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
5273 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
5274 bufConsumed = false;
5275 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005276 case eWNI_SME_UPDATE_APWPSIE_REQ:
5277 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
5278 break;
5279 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5280 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
5281 break;
5282
5283 case eWNI_SME_SET_APWPARSNIEs_REQ:
5284 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
5285 break;
5286
5287 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5288 /* Update the beaconInterval */
5289 __lim_process_sme_change_bi(pMac, pMsgBuf);
5290 break;
5291
5292#ifdef QCA_HT_2040_COEX
5293 case eWNI_SME_SET_HT_2040_MODE:
5294 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
5295 break;
5296#endif
5297
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005298 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5299 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5300 __lim_process_report_message(pMac, pMsg);
5301 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005302
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005303 case eWNI_SME_FT_PRE_AUTH_REQ:
5304 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
5305 break;
5306 case eWNI_SME_FT_UPDATE_KEY:
5307 lim_process_ft_update_key(pMac, pMsgBuf);
5308 break;
5309
5310 case eWNI_SME_FT_AGGR_QOS_REQ:
5311 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
5312 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005313
5314 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5315 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
5316 break;
5317#ifdef FEATURE_WLAN_TDLS
5318 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5319 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
5320 break;
5321 case eWNI_SME_TDLS_ADD_STA_REQ:
5322 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
5323 break;
5324 case eWNI_SME_TDLS_DEL_STA_REQ:
5325 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
5326 break;
5327 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5328 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
5329 break;
5330#endif
5331 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5332 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
5333 break;
5334
5335 case eWNI_SME_CHANNEL_CHANGE_REQ:
5336 lim_process_sme_channel_change_request(pMac, pMsgBuf);
5337 break;
5338
5339 case eWNI_SME_START_BEACON_REQ:
5340 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
5341 break;
5342
5343 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
5344 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
5345 break;
5346
5347 case eWNI_SME_UPDATE_ADDITIONAL_IES:
5348 lim_process_update_add_ies(pMac, pMsgBuf);
5349 break;
5350
5351 case eWNI_SME_MODIFY_ADDITIONAL_IES:
5352 lim_process_modify_add_ies(pMac, pMsgBuf);
5353 break;
5354 case eWNI_SME_SET_HW_MODE_REQ:
5355 lim_process_set_hw_mode(pMac, pMsgBuf);
5356 break;
5357 case eWNI_SME_NSS_UPDATE_REQ:
5358 lim_process_nss_update_request(pMac, pMsgBuf);
5359 break;
5360 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5361 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5362 break;
5363 case eWNI_SME_SET_IE_REQ:
5364 lim_process_set_ie_req(pMac, pMsgBuf);
5365 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305366 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5367 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5368 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305369 case eWNI_SME_EXT_CHANGE_CHANNEL:
5370 lim_process_ext_change_channel(pMac, pMsgBuf);
5371 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005372 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5373 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5374 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005375 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5376 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005377 break;
5378 case eWNI_SME_SET_VDEV_IES_PER_BAND:
5379 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
5380 break;
Naveen Rawatf28315c2016-06-29 18:06:02 -07005381 case eWNI_SME_NDP_END_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005382 case eWNI_SME_NDP_INITIATOR_REQ:
Abhishek Singh4fef7472016-06-06 11:36:03 -07005383 case eWNI_SME_NDP_RESPONDER_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005384 lim_handle_ndp_request_message(pMac, pMsg);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005385 break;
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05305386 case eWNI_SME_REGISTER_P2P_ACK_CB:
5387 lim_register_p2p_ack_ind_cb(pMac, pMsgBuf);
5388 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305389 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5390 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5391 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005392 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305393 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005394 pMsg->bodyptr = NULL;
5395 break;
5396 } /* switch (msgType) */
5397
5398 return bufConsumed;
5399} /*** end lim_process_sme_req_messages() ***/
5400
5401/**
5402 * lim_process_sme_start_beacon_req()
5403 *
5404 ***FUNCTION:
5405 * This function is called by limProcessMessageQueue(). This
5406 * function processes SME request messages from HDD or upper layer
5407 * application.
5408 *
5409 ***LOGIC:
5410 *
5411 ***ASSUMPTIONS:
5412 *
5413 ***NOTE:
5414 *
5415 * @param pMac Pointer to Global MAC structure
5416 * @param msgType Indicates the SME message type
5417 * @param *pMsgBuf A pointer to the SME message buffer
5418 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5419 * false - if pMsgBuf is not to be freed.
5420 */
5421static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5422{
5423 tpSirStartBeaconIndication pBeaconStartInd;
5424 tpPESession psessionEntry;
5425 uint8_t sessionId; /* PE sessionID */
5426
5427 if (pMsg == NULL) {
5428 lim_log(pMac, LOGE, FL("Buffer is Pointing to NULL"));
5429 return;
5430 }
5431
5432 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5433 psessionEntry = pe_find_session_by_bssid(pMac,
5434 pBeaconStartInd->bssid,
5435 &sessionId);
5436 if (psessionEntry == NULL) {
5437 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
5438 lim_log(pMac, LOGE,
5439 FL("Session does not exist for given bssId"));
5440 return;
5441 }
5442
5443 if (pBeaconStartInd->beaconStartStatus == true) {
5444 /*
5445 * Currently this Indication comes from SAP
5446 * to start Beacon Tx on a DFS channel
5447 * since beaconing has to be done on DFS
5448 * channel only after CAC WAIT is completed.
5449 * On a DFS Channel LIM does not start beacon
5450 * Tx right after the WMA_ADD_BSS_RSP.
5451 */
5452 lim_apply_configuration(pMac, psessionEntry);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305453 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005454 FL("Start Beacon with ssid %s Ch %d"),
5455 psessionEntry->ssId.ssId,
5456 psessionEntry->currentOperChannel);
5457 lim_send_beacon_ind(pMac, psessionEntry);
5458 } else {
5459 lim_log(pMac, LOGE, FL("Invalid Beacon Start Indication"));
5460 return;
5461 }
5462}
5463
5464/**
5465 * lim_process_sme_channel_change_request() - process sme ch change req
5466 *
5467 * @mac_ctx: Pointer to Global MAC structure
5468 * @msg_buf: pointer to the SME message buffer
5469 *
5470 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5471 *
5472 * Return: None
5473 */
5474static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5475 uint32_t *msg_buf)
5476{
5477 tpSirChanChangeRequest ch_change_req;
5478 tpPESession session_entry;
5479 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005480 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005481 uint32_t val = 0;
5482
5483 if (msg_buf == NULL) {
5484 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5485 return;
5486 }
5487 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5488
5489 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5490 ch_change_req->targetChannel);
5491
5492 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5493 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
5494 lim_log(mac_ctx, LOGE, FL("Invalid Request/max_tx_pwr"));
5495 return;
5496 }
5497
5498 session_entry = pe_find_session_by_bssid(mac_ctx,
5499 ch_change_req->bssid, &session_id);
5500 if (session_entry == NULL) {
5501 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
5502 lim_log(mac_ctx, LOGE, FL(
5503 "Session does not exist for given bssId"));
5504 return;
5505 }
5506
5507 if (session_entry->currentOperChannel ==
5508 ch_change_req->targetChannel) {
5509 lim_log(mac_ctx, LOGE, FL("target CH is same as current CH"));
5510 return;
5511 }
5512
5513 if (LIM_IS_AP_ROLE(session_entry))
5514 session_entry->channelChangeReasonCode =
5515 LIM_SWITCH_CHANNEL_SAP_DFS;
5516 else
5517 session_entry->channelChangeReasonCode =
5518 LIM_SWITCH_CHANNEL_OPERATION;
5519
5520 lim_log(mac_ctx, LOGW, FL(
5521 "switch old chnl %d to new chnl %d, ch_bw %d"),
5522 session_entry->currentOperChannel,
5523 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005524 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005525
5526 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005527 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005528 session_entry->ch_center_freq_seg0 =
5529 ch_change_req->center_freq_seg_0;
5530 session_entry->ch_center_freq_seg1 =
5531 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005532 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005533 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005534 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005535 session_entry->htRecommendedTxWidthSet =
5536 session_entry->htSupportedChannelWidthSet;
5537 session_entry->currentOperChannel =
5538 ch_change_req->targetChannel;
5539 session_entry->limRFBand =
5540 lim_get_rf_band(session_entry->currentOperChannel);
5541 /* Initialize 11h Enable Flag */
5542 if (SIR_BAND_5_GHZ == session_entry->limRFBand) {
5543 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5544 eSIR_SUCCESS)
5545 lim_log(mac_ctx, LOGP,
5546 FL("Fail to get WNI_CFG_11H_ENABLED"));
5547 }
5548
5549 session_entry->lim11hEnable = val;
5550 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305551 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005552 &ch_change_req->operational_rateset,
5553 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305554 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005555 &ch_change_req->extended_rateset,
5556 sizeof(session_entry->extRateSet));
5557 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5558 session_entry->ch_center_freq_seg0,
5559 session_entry->ch_center_freq_seg1,
5560 session_entry->ch_width,
5561 max_tx_pwr, session_entry->peSessionId);
5562}
5563
5564/******************************************************************************
5565* lim_start_bss_update_add_ie_buffer()
5566*
5567***FUNCTION:
5568* This function checks the src buffer and its length and then malloc for
5569* dst buffer update the same
5570*
5571***LOGIC:
5572*
5573***ASSUMPTIONS:
5574*
5575***NOTE:
5576*
5577* @param pMac Pointer to Global MAC structure
5578* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5579* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5580* @param *pSrcData_buff A pointer of uint8_t src buffer
5581* @param srcDataLen src buffer length
5582******************************************************************************/
5583
5584static void
5585lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5586 uint8_t **pDstData_buff,
5587 uint16_t *pDstDataLen,
5588 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5589{
5590
5591 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5592 *pDstDataLen = srcDataLen;
5593
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305594 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005595
5596 if (NULL == *pDstData_buff) {
5597 lim_log(pMac, LOGE,
5598 FL("AllocateMemory failed for pDstData_buff"));
5599 return;
5600 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305601 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005602 } else {
5603 *pDstData_buff = NULL;
5604 *pDstDataLen = 0;
5605 }
5606}
5607
5608/******************************************************************************
5609* lim_update_add_ie_buffer()
5610*
5611***FUNCTION:
5612* This function checks the src buffer and length if src buffer length more
5613* than dst buffer length then free the dst buffer and malloc for the new src
5614* length, and update the dst buffer and length. But if dst buffer is bigger
5615* than src buffer length then it just update the dst buffer and length
5616*
5617***LOGIC:
5618*
5619***ASSUMPTIONS:
5620*
5621***NOTE:
5622*
5623* @param pMac Pointer to Global MAC structure
5624* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5625* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5626* @param *pSrcData_buff A pointer of uint8_t src buffer
5627* @param srcDataLen src buffer length
5628******************************************************************************/
5629
5630static void
5631lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5632 uint8_t **pDstData_buff,
5633 uint16_t *pDstDataLen,
5634 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5635{
5636
5637 if (NULL == pSrcData_buff) {
5638 lim_log(pMac, LOGE, FL("src buffer is null."));
5639 return;
5640 }
5641
5642 if (srcDataLen > *pDstDataLen) {
5643 *pDstDataLen = srcDataLen;
5644 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305645 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005646 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305647 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005648
5649 if (NULL == *pDstData_buff) {
5650 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5651 *pDstDataLen = 0;
5652 return;
5653 }
5654 }
5655
5656 /* copy the content of buffer into dst buffer
5657 */
5658 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305659 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005660
5661}
5662
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005663/**
5664 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5665 * @pMac : Pointer to Global MAC structure
5666 * @pDstData_buff : A pointer to pointer of dst buffer
5667 * @pDstDataLen : A pointer to pointer of dst buffer length
5668 * @pModifyIE : A pointer to tSirModifyIE
5669 *
5670 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5671 *
5672 * Return:
5673 * True or false depending upon whether IE is updated or not
5674 */
5675static bool
5676lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5677 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5678{
Hong Shi1553d692016-09-28 12:16:19 +08005679 int32_t oui_length;
5680 uint8_t *ibss_ie = NULL;
5681 uint8_t *vendor_ie;
5682#define MAC_VENDOR_OUI "\x00\x16\x32"
5683#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005684
5685 ibss_ie = pModifyIE->pIEBuffer;
5686 oui_length = pModifyIE->oui_length;
5687
5688 if ((0 == oui_length) || (NULL == ibss_ie)) {
5689 PELOGE(lim_log(pMac, LOGE,
5690 FL("Invalid set IBSS vendor IE command length %d "),
5691 oui_length);)
5692 return false;
5693 }
5694
Hong Shi1553d692016-09-28 12:16:19 +08005695 /*
5696 * Why replace only beacon OUI data here:
5697 * 1. other ie (such as wpa) shall not be overwritten here.
5698 * 2. per spec, beacon oui ie might be set twice and original one
5699 * shall be updated.
5700 */
5701 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(pMac, MAC_VENDOR_OUI,
5702 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5703 if (vendor_ie) {
5704 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5705 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5706 pModifyIE->ieBufferlength);
5707 } else {
5708 uint16_t new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5709 uint8_t *new_ptr = qdf_mem_malloc(new_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005710
Hong Shi1553d692016-09-28 12:16:19 +08005711 if (NULL == new_ptr) {
5712 lim_log(pMac, LOGE, FL("Memory allocation failed."));
5713 return false;
5714 }
5715 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5716 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5717 pModifyIE->ieBufferlength);
5718 qdf_mem_free(*pDstData_buff);
5719 *pDstDataLen = new_length;
5720 *pDstData_buff = new_ptr;
5721 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005722 return true;
5723}
5724
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005725/*
5726* lim_process_modify_add_ies() - process modify additional IE req.
5727*
5728* @mac_ctx: Pointer to Global MAC structure
5729* @msg_buf: pointer to the SME message buffer
5730*
5731* This function update the PE buffers for additional IEs.
5732*
5733* Return: None
5734*/
5735static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5736 uint32_t *msg_buf)
5737{
5738 tpSirModifyIEsInd modify_add_ies;
5739 tpPESession session_entry;
5740 uint8_t session_id;
5741 bool ret = false;
5742 tSirAddIeParams *add_ie_params;
5743
5744 if (msg_buf == NULL) {
5745 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5746 return;
5747 }
5748
5749 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5750 /* Incoming message has smeSession, use BSSID to find PE session */
5751 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005752 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005753
5754 if (NULL == session_entry) {
5755 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5756 MAC_ADDRESS_STR),
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005757 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005758 goto end;
5759 }
5760 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5761 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5762 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
5763 lim_log(mac_ctx, LOGE,
5764 FL("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d"),
5765 modify_add_ies->modifyIE.pIEBuffer,
5766 modify_add_ies->modifyIE.ieBufferlength,
5767 modify_add_ies->modifyIE.ieID,
5768 modify_add_ies->modifyIE.ieIDLen,
5769 modify_add_ies->updateType);
5770 goto end;
5771 }
5772 add_ie_params = &session_entry->addIeParams;
5773 switch (modify_add_ies->updateType) {
5774 case eUPDATE_IE_PROBE_RESP:
5775 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005776 if (LIM_IS_IBSS_ROLE(session_entry)) {
5777 lim_update_ibss_prop_add_ies(mac_ctx,
5778 &add_ie_params->probeRespData_buff,
5779 &add_ie_params->probeRespDataLen,
5780 &modify_add_ies->modifyIE);
5781 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005782 break;
5783 case eUPDATE_IE_ASSOC_RESP:
5784 /* assoc resp IE */
5785 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305786 QDF_TRACE(QDF_MODULE_ID_PE,
5787 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005788 "assoc resp add ie not present %d"),
5789 add_ie_params->assocRespDataLen);
5790 }
5791 /* search through the buffer and modify the IE */
5792 break;
5793 case eUPDATE_IE_PROBE_BCN:
5794 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005795 if (LIM_IS_IBSS_ROLE(session_entry)) {
5796 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5797 &add_ie_params->probeRespBCNData_buff,
5798 &add_ie_params->probeRespBCNDataLen,
5799 &modify_add_ies->modifyIE);
5800 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005801 if (ret == true && modify_add_ies->modifyIE.notify) {
5802 lim_handle_param_update(mac_ctx,
5803 modify_add_ies->updateType);
5804 }
5805 break;
5806 default:
5807 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d"),
5808 modify_add_ies->updateType);
5809 break;
5810 }
5811end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305812 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005813 modify_add_ies->modifyIE.pIEBuffer = NULL;
5814}
5815
5816/*
5817* lim_process_update_add_ies() - process additional IE update req
5818*
5819* @mac_ctx: Pointer to Global MAC structure
5820* @msg_buf: pointer to the SME message buffer
5821*
5822* This function update the PE buffers for additional IEs.
5823*
5824* Return: None
5825*/
5826static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5827 uint32_t *msg_buf)
5828{
5829 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5830 uint8_t session_id;
5831 tpPESession session_entry;
5832 tSirAddIeParams *addn_ie;
5833 uint16_t new_length = 0;
5834 uint8_t *new_ptr = NULL;
5835 tSirUpdateIE *update_ie;
5836
5837 if (msg_buf == NULL) {
5838 lim_log(mac_ctx, LOGE, FL("msg_buf is NULL"));
5839 return;
5840 }
5841 update_ie = &update_add_ies->updateIE;
5842 /* incoming message has smeSession, use BSSID to find PE session */
5843 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005844 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005845
5846 if (NULL == session_entry) {
5847 lim_log(mac_ctx, LOGE, FL("Session not found for given bssid. "
5848 MAC_ADDRESS_STR),
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005849 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005850 goto end;
5851 }
5852 addn_ie = &session_entry->addIeParams;
5853 /* if len is 0, upper layer requested freeing of buffer */
5854 if (0 == update_ie->ieBufferlength) {
5855 switch (update_add_ies->updateType) {
5856 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305857 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005858 addn_ie->probeRespData_buff = NULL;
5859 addn_ie->probeRespDataLen = 0;
5860 break;
5861 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305862 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005863 addn_ie->assocRespData_buff = NULL;
5864 addn_ie->assocRespDataLen = 0;
5865 break;
5866 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305867 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005868 addn_ie->probeRespBCNData_buff = NULL;
5869 addn_ie->probeRespBCNDataLen = 0;
5870
5871 if (update_ie->notify)
5872 lim_handle_param_update(mac_ctx,
5873 update_add_ies->updateType);
5874 break;
5875 default:
5876 break;
5877 }
5878 return;
5879 }
5880 switch (update_add_ies->updateType) {
5881 case eUPDATE_IE_PROBE_RESP:
5882 if (update_ie->append) {
5883 /*
5884 * In case of append, allocate new memory
5885 * with combined length
5886 */
5887 new_length = update_ie->ieBufferlength +
5888 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305889 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005890 if (NULL == new_ptr) {
5891 lim_log(mac_ctx, LOGE, FL(
5892 "Memory allocation failed."));
5893 goto end;
5894 }
5895 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305896 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005897 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305898 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005899 update_ie->pAdditionIEBuffer,
5900 update_ie->ieBufferlength);
5901 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305902 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005903 /* adjust length accordingly */
5904 addn_ie->probeRespDataLen = new_length;
5905 /* save refernece of local buffer in PE session */
5906 addn_ie->probeRespData_buff = new_ptr;
5907 goto end;
5908 }
5909 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5910 &addn_ie->probeRespDataLen,
5911 update_ie->pAdditionIEBuffer,
5912 update_ie->ieBufferlength);
5913 break;
5914 case eUPDATE_IE_ASSOC_RESP:
5915 /* assoc resp IE */
5916 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5917 &addn_ie->assocRespDataLen,
5918 update_ie->pAdditionIEBuffer,
5919 update_ie->ieBufferlength);
5920 break;
5921 case eUPDATE_IE_PROBE_BCN:
5922 /* probe resp Bcn IE */
5923 lim_update_add_ie_buffer(mac_ctx,
5924 &addn_ie->probeRespBCNData_buff,
5925 &addn_ie->probeRespBCNDataLen,
5926 update_ie->pAdditionIEBuffer,
5927 update_ie->ieBufferlength);
5928 if (update_ie->notify)
5929 lim_handle_param_update(mac_ctx,
5930 update_add_ies->updateType);
5931 break;
5932 default:
5933 lim_log(mac_ctx, LOGE, FL("unhandled buffer type %d."),
5934 update_add_ies->updateType);
5935 break;
5936 }
5937end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305938 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005939 update_ie->pAdditionIEBuffer = NULL;
5940}
5941
5942/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305943 * send_extended_chan_switch_action_frame()- function to send ECSA
5944 * action frame for each sta connected to SAP/GO and AP in case of
5945 * STA .
5946 * @mac_ctx: pointer to global mac structure
5947 * @new_channel: new channel to switch to.
5948 * @ch_bandwidth: BW of channel to calculate op_class
5949 * @session_entry: pe session
5950 *
5951 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5952 *
5953 * Return: void
5954 */
5955
5956static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5957 uint16_t new_channel, uint8_t ch_bandwidth,
5958 tpPESession session_entry)
5959{
5960 uint16_t op_class;
5961 uint8_t switch_mode = 0, i;
5962 tpDphHashNode psta;
5963
5964
Amar Singhal22995112016-01-22 10:42:33 -08005965 op_class = cds_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305966 mac_ctx->scan.countryCodeCurrent,
5967 new_channel,
5968 ch_bandwidth);
5969
5970 if (LIM_IS_AP_ROLE(session_entry) &&
5971 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
5972 switch_mode = 1;
5973
5974 if (LIM_IS_AP_ROLE(session_entry)) {
5975 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5976 psta =
5977 session_entry->dph.dphHashTable.pDphNodeArray + i;
5978 if (psta && psta->added)
5979 lim_send_extended_chan_switch_action_frame(
5980 mac_ctx,
5981 psta->staAddr,
5982 switch_mode, op_class, new_channel,
5983 LIM_MAX_CSA_IE_UPDATES, session_entry);
5984 }
5985 } else if (LIM_IS_STA_ROLE(session_entry)) {
5986 lim_send_extended_chan_switch_action_frame(mac_ctx,
5987 session_entry->bssId,
5988 switch_mode, op_class, new_channel,
5989 LIM_MAX_CSA_IE_UPDATES, session_entry);
5990 }
5991
5992}
5993
5994/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005995 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5996 *
5997 * @mac_ctx: Pointer to Global MAC structure
5998 * @msg_buf: pointer to the SME message buffer
5999 *
6000 * This function processes SME request messages from HDD or upper layer
6001 * application.
6002 *
6003 * Return: None
6004 */
6005static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
6006 uint32_t *msg_buf)
6007{
6008 tpSirDfsCsaIeRequest dfs_csa_ie_req;
6009 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006010 uint8_t session_id;
6011 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08006012 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006013
6014 if (msg_buf == NULL) {
6015 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6016 return;
6017 }
6018
6019 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
6020 session_entry = pe_find_session_by_bssid(mac_ctx,
6021 dfs_csa_ie_req->bssid, &session_id);
6022 if (session_entry == NULL) {
6023 lim_log(mac_ctx, LOGE, FL(
6024 "Session not found for given BSSID" MAC_ADDRESS_STR),
6025 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
6026 return;
6027 }
6028
6029 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6030 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
6031 GET_LIM_SYSTEM_ROLE(session_entry));
6032 return;
6033 }
6034
6035 /* target channel */
6036 session_entry->gLimChannelSwitch.primaryChannel =
6037 dfs_csa_ie_req->targetChannel;
6038
6039 /* Channel switch announcement needs to be included in beacon */
6040 session_entry->dfsIncludeChanSwIe = true;
6041 session_entry->gLimChannelSwitch.switchCount = LIM_MAX_CSA_IE_UPDATES;
6042 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006043 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05306044 session_entry->gLimChannelSwitch.sec_ch_offset =
6045 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006046 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
6047 session_entry->gLimChannelSwitch.switchMode = 1;
6048
6049 /*
6050 * Validate if SAP is operating HT or VHT mode and set the Channel
6051 * Switch Wrapper element with the Wide Band Switch subelement.
6052 */
6053 if (true != session_entry->vhtCapability)
6054 goto skip_vht;
6055
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006056 /* Now encode the Wider Ch BW element depending on the ch width */
6057 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006058 switch (dfs_csa_ie_req->ch_params.ch_width) {
6059 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006060 /*
6061 * Wide channel BW sublement in channel wrapper element is not
6062 * required in case of 20 Mhz operation. Currently It is set
6063 * only set in case of 40/80 Mhz Operation.
6064 */
6065 session_entry->dfsIncludeChanWrapperIe = false;
6066 wider_bw_ch_switch->newChanWidth =
6067 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
6068 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006069 case CH_WIDTH_40MHZ:
6070 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006071 wider_bw_ch_switch->newChanWidth =
6072 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
6073 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006074 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006075 session_entry->dfsIncludeChanWrapperIe = true;
6076 wider_bw_ch_switch->newChanWidth =
6077 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
6078 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006079 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006080 session_entry->dfsIncludeChanWrapperIe = true;
6081 wider_bw_ch_switch->newChanWidth =
6082 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
6083 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006084 case CH_WIDTH_80P80MHZ:
6085 session_entry->dfsIncludeChanWrapperIe = true;
6086 wider_bw_ch_switch->newChanWidth =
6087 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08006088 /*
6089 * This is not applicable for 20/40/80 Mhz.
6090 * Only used when we support 80+80 Mhz operation.
6091 * In case of 80+80 Mhz, this parameter indicates
6092 * center channel frequency index of 80 Mhz channel of
6093 * frequency segment 1.
6094 */
6095 wider_bw_ch_switch->newCenterChanFreq1 =
6096 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006097 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006098 default:
6099 session_entry->dfsIncludeChanWrapperIe = false;
6100 /*
6101 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
6102 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
6103 */
6104 lim_log(mac_ctx, LOGE, FL("Invalid Channel Width"));
6105 break;
6106 }
6107 /* Fetch the center channel based on the channel width */
6108 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006109 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006110skip_vht:
6111 /* Send CSA IE request from here */
6112 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6113 eSIR_SUCCESS) {
6114 lim_log(mac_ctx, LOGE, FL("Unable to set CSA IE in beacon"));
6115 return;
6116 }
6117
6118 /*
6119 * First beacon update request is sent here, the remaining updates are
6120 * done when the FW responds back after sending the first beacon after
6121 * the template update
6122 */
6123 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306124
6125 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
6126 ch_offset = BW80;
6127 else
6128 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
6129
6130 lim_log(mac_ctx, LOG1, FL("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d"),
6131 session_entry->gLimChannelSwitch.switchCount,
6132 session_entry->gLimChannelSwitch.primaryChannel,
6133 session_entry->gLimChannelSwitch.ch_width,
6134 session_entry->dfsIncludeChanWrapperIe,
6135 ch_offset);
6136
Abhishek Singh518323d2015-10-19 17:42:01 +05306137 /* Send ECSA Action frame after updating the beacon */
6138 send_extended_chan_switch_action_frame(mac_ctx,
6139 session_entry->gLimChannelSwitch.primaryChannel,
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306140 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006141 session_entry->gLimChannelSwitch.switchCount--;
6142}
6143
6144/**
Abhishek Singh518323d2015-10-19 17:42:01 +05306145 * lim_process_ext_change_channel()- function to send ECSA
6146 * action frame for STA/CLI .
6147 * @mac_ctx: pointer to global mac structure
6148 * @msg: params from sme for new channel.
6149 *
6150 * This function is called to send ECSA frame for STA/CLI.
6151 *
6152 * Return: void
6153 */
6154
6155static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
6156 uint32_t *msg)
6157{
6158 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
6159 (struct sir_sme_ext_cng_chan_req *) msg;
6160 tpPESession session_entry = NULL;
6161
6162 if (NULL == msg) {
6163 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6164 return;
6165 }
6166 session_entry =
6167 pe_find_session_by_sme_session_id(mac_ctx,
6168 ext_chng_channel->session_id);
6169 if (NULL == session_entry) {
6170 lim_log(mac_ctx, LOGE,
6171 FL("Session not found for given session %d"),
6172 ext_chng_channel->session_id);
6173 return;
6174 }
6175 if (LIM_IS_AP_ROLE(session_entry)) {
6176 lim_log(mac_ctx, LOGE,
6177 FL("not an STA/CLI session"));
6178 return;
6179 }
6180 send_extended_chan_switch_action_frame(mac_ctx,
6181 ext_chng_channel->new_channel,
6182 0, session_entry);
6183}
6184
6185/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006186 * lim_process_nss_update_request() - process sme nss update req
6187 *
6188 * @mac_ctx: Pointer to Global MAC structure
6189 * @msg_buf: pointer to the SME message buffer
6190 *
6191 * This function processes SME request messages from HDD or upper layer
6192 * application.
6193 *
6194 * Return: None
6195 */
6196static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
6197 uint32_t *msg_buf)
6198{
6199 struct sir_nss_update_request *nss_update_req_ptr;
6200 tpPESession session_entry = NULL;
6201
6202 if (msg_buf == NULL) {
6203 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6204 return;
6205 }
6206
6207 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05306208 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006209 nss_update_req_ptr->vdev_id);
6210 if (session_entry == NULL) {
6211 lim_log(mac_ctx, LOGE, FL(
6212 "Session not found for given session_id %d"),
6213 nss_update_req_ptr->vdev_id);
6214 return;
6215 }
6216
6217 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
6218 lim_log(mac_ctx, LOGE, FL("Invalid SystemRole %d"),
6219 GET_LIM_SYSTEM_ROLE(session_entry));
6220 return;
6221 }
6222
6223 /* populate nss field in the beacon */
6224 session_entry->gLimOperatingMode.present = 1;
6225 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
6226 /* Send nss update request from here */
6227 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6228 eSIR_SUCCESS) {
6229 lim_log(mac_ctx, LOGE,
6230 FL("Unable to set op mode IE in beacon"));
6231 return;
6232 }
6233
6234 lim_send_beacon_ind(mac_ctx, session_entry);
6235}
6236
6237/**
6238 * lim_process_set_ie_req() - process sme set IE request
6239 *
6240 * @mac_ctx: Pointer to Global MAC structure
6241 * @msg_buf: pointer to the SME message buffer
6242 *
6243 * This function processes SME request messages from HDD or upper layer
6244 * application.
6245 *
6246 * Return: None
6247 */
6248static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6249{
6250 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306251 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006252
6253 if (msg_buf == NULL) {
6254 lim_log(mac_ctx, LOGE, FL("Buffer is Pointing to NULL"));
6255 return;
6256 }
6257
6258 msg = (struct send_extcap_ie *)msg_buf;
6259 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306260 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006261 lim_log(mac_ctx, LOGE, FL("Unable to send ExtCap to FW"));
6262
6263}