blob: ac831c229ac0d3bd89adfc54c211939128bd9576 [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"
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +053067#include "lim_process_fils.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080068
69/*
70 * This overhead is time for sending NOA start to host in case of GO/sending
71 * NULL data & receiving ACK in case of P2P Client and starting actual scanning
72 * with init scan req/rsp plus in case of concurrency, taking care of sending
73 * null data and receiving ACK to/from AP/Also SetChannel with calibration
74 * is taking around 7ms .
75 */
76#define SCAN_MESSAGING_OVERHEAD 20 /* in msecs */
77#define JOIN_NOA_DURATION 2000 /* in msecs */
78#define OEM_DATA_NOA_DURATION 60 /* in msecs */
79#define DEFAULT_PASSIVE_MAX_CHANNEL_TIME 110 /* in msecs */
80
81#define CONV_MS_TO_US 1024 /* conversion factor from ms to us */
82
Paul Zhangd2315472017-02-22 10:02:50 +080083#define BEACON_INTERVAL_THRESHOLD 50 /* in msecs */
84#define STA_BURST_SCAN_DURATION 120 /* in msecs */
85
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080086/* SME REQ processing function templates */
87static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal, uint32_t *);
Rajeev Kumarfeb96382017-01-22 19:42:09 -080088static bool __lim_process_sme_start_bss_req(tpAniSirGlobal,
89 struct scheduler_msg *pMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080090static void __lim_process_sme_scan_req(tpAniSirGlobal, uint32_t *);
91static void __lim_process_sme_join_req(tpAniSirGlobal, uint32_t *);
92static void __lim_process_sme_reassoc_req(tpAniSirGlobal, uint32_t *);
93static void __lim_process_sme_disassoc_req(tpAniSirGlobal, uint32_t *);
94static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal, uint32_t *);
95static void __lim_process_sme_deauth_req(tpAniSirGlobal, uint32_t *);
96static void __lim_process_sme_set_context_req(tpAniSirGlobal, uint32_t *);
Rajeev Kumarfeb96382017-01-22 19:42:09 -080097static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal,
98 struct scheduler_msg *pMsg);
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +053099static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
100 uint32_t *msg_buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800101static void lim_process_sme_channel_change_request(tpAniSirGlobal pMac,
102 uint32_t *pMsg);
103static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg);
104static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal pMac, uint32_t *pMsg);
105static void lim_process_nss_update_request(tpAniSirGlobal pMac, uint32_t *pMsg);
106static void lim_process_set_ie_req(tpAniSirGlobal pMac, uint32_t *pMsg);
107
108static void lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
109 uint8_t **pDstData_buff,
110 uint16_t *pDstDataLen,
111 uint8_t *pSrcData_buff,
112 uint16_t srcDataLen);
113
114static void lim_update_add_ie_buffer(tpAniSirGlobal pMac,
115 uint8_t **pDstData_buff,
116 uint16_t *pDstDataLen,
117 uint8_t *pSrcData_buff, uint16_t srcDataLen);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -0800118static bool lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac,
119 uint8_t **pDstData_buff,
120 uint16_t *pDstDataLen,
121 tSirModifyIE *pModifyIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800122static void lim_process_modify_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
123
124static void lim_process_update_add_ies(tpAniSirGlobal pMac, uint32_t *pMsg);
125
Abhishek Singh518323d2015-10-19 17:42:01 +0530126static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
127 uint32_t *msg);
128
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800129/**
130 * lim_process_set_hw_mode() - Send set HW mode command to WMA
131 * @mac: Globacl MAC pointer
132 * @msg: Message containing the hw mode index
133 *
134 * Send the set HW mode command to WMA
135 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530136 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800137 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530138static QDF_STATUS lim_process_set_hw_mode(tpAniSirGlobal mac, uint32_t *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800139{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530140 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700141 struct scheduler_msg message = {0};
Tushnim Bhattacharyya66348bd2017-03-09 15:02:10 -0800142 struct policy_mgr_hw_mode *req_msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800143 uint32_t len;
144 struct s_sir_set_hw_mode *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700145 struct scheduler_msg resp_msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800146 struct sir_set_hw_mode_resp *param;
147
148 buf = (struct s_sir_set_hw_mode *) msg;
149 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700150 pe_err("Set HW mode param is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800151 /* To free the active command list */
152 goto fail;
153 }
154
155 len = sizeof(*req_msg);
156
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530157 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800158 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700159 pe_err("qdf_mem_malloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800160 /* Free the active command list
161 * Probably the malloc is going to fail there as well?!
162 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530163 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800164 }
165
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800166 req_msg->hw_mode_index = buf->set_hw.hw_mode_index;
Chandrasekaran, Manishekaref70c0d2015-10-20 19:54:55 +0530167 req_msg->reason = buf->set_hw.reason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800168 /* Other parameters are not needed for WMA */
169
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800170 message.bodyptr = req_msg;
171 message.type = SIR_HAL_PDEV_SET_HW_MODE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800172
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700173 pe_debug("Posting SIR_HAL_SOC_SET_HW_MOD to WMA");
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800174 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530175 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700176 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800177 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530178 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800179 goto fail;
180 }
181 return status;
182fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530183 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800184 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700185 pe_err("HW mode resp failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530186 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800187 }
188 param->status = SET_HW_MODE_STATUS_ECANCELED;
189 param->cfgd_hw_mode_index = 0;
190 param->num_vdev_mac_entries = 0;
191 resp_msg.type = eWNI_SME_SET_HW_MODE_RESP;
192 resp_msg.bodyptr = param;
193 resp_msg.bodyval = 0;
194 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530195 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800196}
197
198/**
199 * lim_process_set_dual_mac_cfg_req() - Set dual mac config command to WMA
200 * @mac: Global MAC pointer
201 * @msg: Message containing the dual mac config parameter
202 *
203 * Send the set dual mac config command to WMA
204 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530205 * Return: QDF_STATUS_SUCCESS if message posting is successful
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800206 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530207static QDF_STATUS lim_process_set_dual_mac_cfg_req(tpAniSirGlobal mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800208 uint32_t *msg)
209{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530210 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700211 struct scheduler_msg message = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800212 struct sir_dual_mac_config *req_msg;
213 uint32_t len;
214 struct sir_set_dual_mac_cfg *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700215 struct scheduler_msg resp_msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800216 struct sir_dual_mac_config_resp *param;
217
218 buf = (struct sir_set_dual_mac_cfg *) msg;
219 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700220 pe_err("Set Dual mac config is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800221 /* To free the active command list */
222 goto fail;
223 }
224
225 len = sizeof(*req_msg);
226
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530227 req_msg = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800228 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700229 pe_err("qdf_mem_malloc failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800230 /* Free the active command list
231 * Probably the malloc is going to fail there as well?!
232 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530233 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800234 }
235
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800236 req_msg->scan_config = buf->set_dual_mac.scan_config;
237 req_msg->fw_mode_config = buf->set_dual_mac.fw_mode_config;
238 /* Other parameters are not needed for WMA */
239
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800240 message.bodyptr = req_msg;
241 message.type = SIR_HAL_PDEV_DUAL_MAC_CFG_REQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800242
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700243 pe_debug("Post SIR_HAL_PDEV_DUAL_MAC_CFG_REQ to WMA: %x %x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800244 req_msg->scan_config, req_msg->fw_mode_config);
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800245 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &message);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530246 if (!QDF_IS_STATUS_SUCCESS(status)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700247 pe_err("scheduler_post_msg failed!(err=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800248 status);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530249 qdf_mem_free(req_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800250 goto fail;
251 }
252 return status;
253fail:
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530254 param = qdf_mem_malloc(sizeof(*param));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800255 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700256 pe_err("Dual mac config resp failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530257 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800258 }
259 param->status = SET_HW_MODE_STATUS_ECANCELED;
260 resp_msg.type = eWNI_SME_SET_DUAL_MAC_CFG_RESP;
261 resp_msg.bodyptr = param;
262 resp_msg.bodyval = 0;
263 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530264 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800265}
266
267/**
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800268 * lim_process_set_antenna_mode_req() - Set antenna mode command
269 * to WMA
270 * @mac: Global MAC pointer
271 * @msg: Message containing the antenna mode parameter
272 *
273 * Send the set antenna mode command to WMA
274 *
275 * Return: QDF_STATUS_SUCCESS if message posting is successful
276 */
277static QDF_STATUS lim_process_set_antenna_mode_req(tpAniSirGlobal mac,
278 uint32_t *msg)
279{
280 QDF_STATUS status = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700281 struct scheduler_msg message = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800282 struct sir_antenna_mode_param *req_msg;
283 struct sir_set_antenna_mode *buf;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700284 struct scheduler_msg resp_msg = {0};
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800285 struct sir_antenna_mode_resp *param;
286
287 buf = (struct sir_set_antenna_mode *) msg;
288 if (!buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700289 pe_err("Set antenna mode is NULL");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800290 /* To free the active command list */
291 goto fail;
292 }
293
294 req_msg = qdf_mem_malloc(sizeof(*req_msg));
295 if (!req_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700296 pe_err("qdf_mem_malloc failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800297 return QDF_STATUS_E_NOMEM;
298 }
299
300 req_msg->num_rx_chains = buf->set_antenna_mode.num_rx_chains;
301 req_msg->num_tx_chains = buf->set_antenna_mode.num_tx_chains;
302
Rajeev Kumarf7d84422017-01-21 15:45:44 -0800303 message.bodyptr = req_msg;
304 message.type = SIR_HAL_SOC_ANTENNA_MODE_REQ;
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800305
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700306 pe_debug("Post SIR_HAL_SOC_ANTENNA_MODE_REQ to WMA: %d %d",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800307 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)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700311 pe_err("scheduler_post_msg failed!(err=%d)",
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800312 status);
313 qdf_mem_free(req_msg);
314 goto fail;
315 }
316 return status;
317fail:
318 param = qdf_mem_malloc(sizeof(*param));
319 if (!param) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700320 pe_err("antenna mode resp failed");
Archana Ramachandrana20ef812015-11-13 16:12:13 -0800321 return QDF_STATUS_E_NOMEM;
322 }
323 param->status = SET_ANTENNA_MODE_STATUS_ECANCELED;
324 resp_msg.type = eWNI_SME_SET_ANTENNA_MODE_RESP;
325 resp_msg.bodyptr = param;
326 resp_msg.bodyval = 0;
327 lim_sys_process_mmh_msg_api(mac, &resp_msg, ePROT);
328 return QDF_STATUS_SUCCESS;
329}
330
331/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800332 * __lim_fresh_scan_reqd() - determine if a fresh scan request must be issued.
333 * @mac_ctx: Pointer to Global MAC structure
334 * @return_fresh_results: Trigger fresh scan.
335 *
336 * PE will do fresh scan, if all of the active sessions are in
337 * good state (Link Est or BSS Started). If one of the sessions
338 * is not in one of the above states, then PE does not do fresh
339 * scan. If no session exists (scanning very first time),
340 * then PE will always do fresh scan if SME asks it to do that.
341 *
342 * Return: true for fresh scan results, false if in invalid state.
343 */
344static uint8_t
345__lim_fresh_scan_reqd(tpAniSirGlobal mac_ctx, uint8_t return_fresh_results)
346{
347 uint8_t valid_state = true;
348 int i;
349
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700350
351 pe_debug("gLimSmeState: %d, returnFreshResults 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800352 mac_ctx->lim.gLimSmeState, return_fresh_results);
353
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700354 if (mac_ctx->lim.gLimSmeState != eLIM_SME_IDLE_STATE)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800355 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800356
357 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
Naveen Rawatb6a951a2016-06-21 15:02:37 -0700358
359 if (mac_ctx->lim.gpSession[i].valid == false)
360 continue;
361
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700362 pe_debug("session %d, bsstype %d, limSystemRole %d, limSmeState %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800363 i, mac_ctx->lim.gpSession[i].bssType,
364 mac_ctx->lim.gpSession[i].limSystemRole,
365 mac_ctx->lim.gpSession[i].limSmeState);
Naveen Rawatb6a951a2016-06-21 15:02:37 -0700366
367 if (mac_ctx->lim.gpSession[i].bssType == eSIR_NDI_MODE)
368 continue;
369
370 if (mac_ctx->lim.gpSession[i].bssType ==
371 eSIR_INFRASTRUCTURE_MODE &&
372 mac_ctx->lim.gpSession[i].limSmeState ==
373 eLIM_SME_LINK_EST_STATE)
374 continue;
375
376 if (mac_ctx->lim.gpSession[i].bssType == eSIR_IBSS_MODE &&
377 mac_ctx->lim.gpSession[i].limSmeState ==
378 eLIM_SME_NORMAL_STATE)
379 continue;
380
381 if (mac_ctx->lim.gpSession[i].bssType == eSIR_INFRA_AP_MODE &&
382 mac_ctx->lim.gpSession[i].pePersona ==
383 QDF_P2P_GO_MODE &&
384 mac_ctx->lim.gpSession[i].limSmeState ==
385 eLIM_SME_NORMAL_STATE)
386 continue;
387
388 if (mac_ctx->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE &&
389 mac_ctx->lim.gpSession[i].limSmeState ==
390 eLIM_SME_NORMAL_STATE)
391 continue;
392
393 valid_state = false;
394 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800395 }
396
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700397 pe_debug("valid_state: %d", valid_state);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800398
399 if ((valid_state) &&
400 (return_fresh_results & SIR_BG_SCAN_RETURN_FRESH_RESULTS))
401 return true;
402 else
403 return false;
404}
405
406/**
407 * __lim_is_sme_assoc_cnf_valid()
408 *
409 ***FUNCTION:
410 * This function is called by __lim_process_sme_assoc_cnf_new() upon
411 * receiving SME_ASSOC_CNF.
412 *
413 ***LOGIC:
414 * Message validity checks are performed in this function
415 *
416 ***ASSUMPTIONS:
417 *
418 ***NOTE:
419 *
420 * @param pMeasReq Pointer to Received ASSOC_CNF message
421 * @return true When received SME_ASSOC_CNF is formatted
422 * correctly
423 * false otherwise
424 */
425
426static inline uint8_t __lim_is_sme_assoc_cnf_valid(tpSirSmeAssocCnf pAssocCnf)
427{
Anurag Chouhanc5548422016-02-24 18:33:27 +0530428 if (qdf_is_macaddr_group(&pAssocCnf->peer_macaddr))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800429 return false;
430 else
431 return true;
432} /*** end __lim_is_sme_assoc_cnf_valid() ***/
433
434/**
435 * __lim_get_sme_join_req_size_for_alloc()
436 *
437 ***FUNCTION:
438 * This function is called in various places to get IE length
439 * from tSirBssDescription structure
440 * number being scanned.
441 *
442 ***PARAMS:
443 *
444 ***LOGIC:
445 *
446 ***ASSUMPTIONS:
447 * NA
448 *
449 ***NOTE:
450 * NA
451 *
452 * @param pBssDescr
453 * @return Total IE length
454 */
455
456static uint16_t __lim_get_sme_join_req_size_for_alloc(uint8_t *pBuf)
457{
458 uint16_t len = 0;
459
460 if (!pBuf)
461 return len;
462
463 pBuf += sizeof(uint16_t);
464 len = lim_get_u16(pBuf);
Arif Hussainc9651922017-04-16 14:08:23 -0700465 return len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800466}
467
468/**
469 * __lim_is_defered_msg_for_learn() - message handling in SME learn state
470 * @pMac: Global MAC context
471 * @pMsg: Pointer to message posted from SME to LIM.
472 *
473 * Has role only if 11h is enabled. Not used on STA side.
474 * Defers the message if SME is in learn state and brings
475 * the LIM back to normal mode.
476 *
477 * Return: true - If defered false - Otherwise
478 */
479
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800480static bool __lim_is_defered_msg_for_learn(tpAniSirGlobal pMac,
481 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800482{
483 if (lim_is_system_in_scan_state(pMac)) {
484 if (lim_defer_msg(pMac, pMsg) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700485 pe_err("Could not defer Msg: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800486 return false;
487 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700488 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800489 pMsg->type);
490 return true;
491 }
492 return false;
493}
494
495/**
496 * __lim_is_defered_msg_for_radar() - Defers the message if radar is detected
497 * @mac_ctx: Pointer to Global MAC structure
498 * @message: Pointer to message posted from SME to LIM.
499 *
500 * Has role only if 11h is enabled. Not used on STA side.
501 * Defers the message if radar is detected.
502 *
503 * Return: true, if defered otherwise return false.
504 */
505static bool
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800506__lim_is_defered_msg_for_radar(tpAniSirGlobal mac_ctx,
507 struct scheduler_msg *message)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800508{
509 /*
510 * fRadarDetCurOperChan will be set only if we
511 * detect radar in current operating channel and
512 * System Role == AP ROLE
513 *
514 * TODO: Need to take care radar detection.
515 *
516 * if (LIM_IS_RADAR_DETECTED(mac_ctx))
517 */
518 if (0) {
519 if (lim_defer_msg(mac_ctx, message) != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700520 pe_err("Could not defer Msg: %d", message->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800521 return false;
522 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700523 pe_debug("Defer the message, in learn mode type: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800524 message->type);
525 return true;
526 }
527 return false;
528}
529
530/**
531 * __lim_process_sme_sys_ready_ind () - Process ready indication from WMA
532 * @pMac: Global MAC context
533 * @pMsgBuf: Message from WMA
534 *
535 * handles the notification from HDD. PE just forwards this message to HAL.
536 *
537 * Return: true-Posting to HAL failed, so PE will consume the buffer.
538 * false-Posting to HAL successful, so HAL will consume the buffer.
539 */
540
541static bool __lim_process_sme_sys_ready_ind(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
542{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700543 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800544 tSirSmeReadyReq *ready_req = (tSirSmeReadyReq *) pMsgBuf;
545
546 msg.type = WMA_SYS_READY_IND;
547 msg.reserved = 0;
548 msg.bodyptr = pMsgBuf;
549 msg.bodyval = 0;
550
Srinivas Girigowda35b00312017-06-27 21:52:03 -0700551 if (ANI_DRIVER_TYPE(pMac) != QDF_DRIVER_TYPE_MFG) {
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800552 ready_req->pe_roam_synch_cb = pe_roam_synch_callback;
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +0530553 pe_register_mgmt_rx_frm_callback(pMac);
Naveen Rawat0fc3f692016-06-22 14:30:54 -0700554 pe_register_callbacks_with_wma(pMac, ready_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800555 pMac->lim.add_bssdescr_callback = ready_req->add_bssdescr_cb;
556 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700557
558 pe_debug("sending WMA_SYS_READY_IND msg to HAL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800559 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msg.type));
560
561 if (eSIR_SUCCESS != wma_post_ctrl_msg(pMac, &msg)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700562 pe_err("wma_post_ctrl_msg failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800563 return true;
564 }
565 return false;
566}
567
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800568/**
569 *lim_configure_ap_start_bss_session() - Configure the AP Start BSS in session.
570 *@mac_ctx: Pointer to Global MAC structure
571 *@session: A pointer to session entry
572 *@sme_start_bss_req: Start BSS Request from upper layers.
573 *
574 * This function is used to configure the start bss parameters
575 * in to the session.
576 *
577 * Return: None.
578 */
579static void
580lim_configure_ap_start_bss_session(tpAniSirGlobal mac_ctx, tpPESession session,
581 tpSirSmeStartBssReq sme_start_bss_req)
582{
583 session->limSystemRole = eLIM_AP_ROLE;
584 session->privacy = sme_start_bss_req->privacy;
585 session->fwdWPSPBCProbeReq = sme_start_bss_req->fwdWPSPBCProbeReq;
586 session->authType = sme_start_bss_req->authType;
587 /* Store the DTIM period */
588 session->dtimPeriod = (uint8_t) sme_start_bss_req->dtimPeriod;
589 /* Enable/disable UAPSD */
590 session->apUapsdEnable = sme_start_bss_req->apUapsdEnable;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530591 if (session->pePersona == QDF_P2P_GO_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800592 session->proxyProbeRspEn = 0;
593 } else {
594 /*
595 * To detect PBC overlap in SAP WPS mode,
596 * Host handles Probe Requests.
597 */
598 if (SAP_WPS_DISABLED == sme_start_bss_req->wps_state)
599 session->proxyProbeRspEn = 1;
600 else
601 session->proxyProbeRspEn = 0;
602 }
603 session->ssidHidden = sme_start_bss_req->ssidHidden;
604 session->wps_state = sme_start_bss_req->wps_state;
605 session->sap_dot11mc = sme_start_bss_req->sap_dot11mc;
Kapil Gupta4b2efbb2016-10-03 13:07:20 +0530606 session->vendor_vht_sap =
607 sme_start_bss_req->vendor_vht_sap;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800608 lim_get_short_slot_from_phy_mode(mac_ctx, session, session->gLimPhyMode,
609 &session->shortSlotTimeSupported);
610 session->isCoalesingInIBSSAllowed =
611 sme_start_bss_req->isCoalesingInIBSSAllowed;
612
613}
614
615/**
616 * __lim_handle_sme_start_bss_request() - process SME_START_BSS_REQ message
617 *@mac_ctx: Pointer to Global MAC structure
618 *@msg_buf: A pointer to the SME message buffer
619 *
620 * This function is called to process SME_START_BSS_REQ message
621 * from HDD or upper layer application.
622 *
623 * Return: None
624 */
625static void
626__lim_handle_sme_start_bss_request(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
627{
628 uint16_t size;
629 uint32_t val = 0;
630 tSirRetStatus ret_status;
631 tSirMacChanNum channel_number;
632 tLimMlmStartReq *mlm_start_req = NULL;
633 tpSirSmeStartBssReq sme_start_bss_req = NULL;
634 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
635 /* Flag Used in case of IBSS to Auto generate BSSID. */
636 uint32_t auto_gen_bssid = false;
637 uint8_t session_id;
638 tpPESession session = NULL;
Krunal Sonib37bb352016-12-20 14:12:21 -0800639 uint8_t sme_session_id = 0xFF;
640 uint16_t sme_transaction_id = 0xFF;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800641 uint32_t chanwidth;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700642 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800643 tSirRetStatus cfg_get_wmi_dfs_master_param = eSIR_SUCCESS;
644
645/* FEATURE_WLAN_DIAG_SUPPORT */
646#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
647 /*
648 * Since the session is not created yet, sending NULL.
649 * The response should have the correct state.
650 */
651 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_START_BSS_REQ_EVENT,
652 NULL, 0, 0);
653#endif /* FEATURE_WLAN_DIAG_SUPPORT */
654
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700655 pe_debug("Received START_BSS_REQ");
Krunal Sonib37bb352016-12-20 14:12:21 -0800656 size = sizeof(tSirSmeStartBssReq);
657 sme_start_bss_req = qdf_mem_malloc(size);
658 if (NULL == sme_start_bss_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700659 pe_err("Allocate Memory fail for LimStartBssReq");
Krunal Sonib37bb352016-12-20 14:12:21 -0800660 /* Send failure response to host */
661 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
662 goto free;
663 }
664 qdf_mem_copy(sme_start_bss_req, msg_buf, sizeof(tSirSmeStartBssReq));
665 sme_session_id = sme_start_bss_req->sessionId;
666 sme_transaction_id = sme_start_bss_req->transactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800667
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800668 if ((mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) ||
669 (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800670 if (!lim_is_sme_start_bss_req_valid(mac_ctx,
671 sme_start_bss_req)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700672 pe_warn("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800673 ret_code = eSIR_SME_INVALID_PARAMETERS;
674 goto free;
675 }
676
677 /*
678 * This is the place where PE is going to create a session.
679 * If session is not existed, then create a new session
680 */
681 session = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800682 sme_start_bss_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800683 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700684 pe_warn("Session Already exists for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800685 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
686 session = NULL;
687 goto free;
688 } else {
689 session = pe_create_session(mac_ctx,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800690 sme_start_bss_req->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800691 &session_id, mac_ctx->lim.maxStation,
692 sme_start_bss_req->bssType);
693 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700694 pe_warn("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800695 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
696 goto free;
697 }
698 }
699
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700700 if (QDF_NDI_MODE != sme_start_bss_req->bssPersona) {
701 /* Probe resp add ie */
702 lim_start_bss_update_add_ie_buffer(mac_ctx,
703 &session->addIeParams.probeRespData_buff,
704 &session->addIeParams.probeRespDataLen,
705 sme_start_bss_req->addIeParams.
706 probeRespData_buff,
707 sme_start_bss_req->addIeParams.
708 probeRespDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800709
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700710 /* Probe Beacon add ie */
711 lim_start_bss_update_add_ie_buffer(mac_ctx,
712 &session->addIeParams.probeRespBCNData_buff,
713 &session->addIeParams.probeRespBCNDataLen,
714 sme_start_bss_req->addIeParams.
715 probeRespBCNData_buff,
716 sme_start_bss_req->addIeParams.
717 probeRespBCNDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800718
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700719 /* Assoc resp IE */
720 lim_start_bss_update_add_ie_buffer(mac_ctx,
721 &session->addIeParams.assocRespData_buff,
722 &session->addIeParams.assocRespDataLen,
723 sme_start_bss_req->addIeParams.
724 assocRespData_buff,
725 sme_start_bss_req->addIeParams.
726 assocRespDataLen);
727 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800728 /* Store the session related params in newly created session */
729 session->pLimStartBssReq = sme_start_bss_req;
730
731 /* Store PE session_id in session Table */
732 session->peSessionId = session_id;
733
734 /* Store SME session Id in sessionTable */
735 session->smeSessionId = sme_start_bss_req->sessionId;
736
737 session->transactionId = sme_start_bss_req->transactionId;
738
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530739 qdf_mem_copy(&(session->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800740 &(sme_start_bss_req->htConfig),
741 sizeof(session->htConfig));
742
Sandeep Puligilla98917432016-06-10 13:50:28 -0700743 qdf_mem_copy(&(session->vht_config),
744 &(sme_start_bss_req->vht_config),
745 sizeof(session->vht_config));
746
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800747 sir_copy_mac_addr(session->selfMacAddr,
Srinivas Girigowdad8af4a62015-11-18 16:51:16 -0800748 sme_start_bss_req->self_macaddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800749
750 /* Copy SSID to session table */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530751 qdf_mem_copy((uint8_t *) &session->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800752 (uint8_t *) &sme_start_bss_req->ssId,
753 (sme_start_bss_req->ssId.length + 1));
754
755 session->bssType = sme_start_bss_req->bssType;
756
757 session->nwType = sme_start_bss_req->nwType;
758
759 session->beaconParams.beaconInterval =
760 sme_start_bss_req->beaconInterval;
761
762 /* Store the channel number in session Table */
763 session->currentOperChannel =
764 sme_start_bss_req->channelId;
765
766 /* Store Persona */
767 session->pePersona = sme_start_bss_req->bssPersona;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530768 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800769 FL("PE PERSONA=%d"), session->pePersona);
770
771 /* Update the phymode */
772 session->gLimPhyMode = sme_start_bss_req->nwType;
773
774 session->maxTxPower =
775 cfg_get_regulatory_max_transmit_power(mac_ctx,
776 session->currentOperChannel);
777 /* Store the dot 11 mode in to the session Table */
778 session->dot11mode = sme_start_bss_req->dot11mode;
779#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
780 session->cc_switch_mode =
781 sme_start_bss_req->cc_switch_mode;
782#endif
783 session->htCapability =
784 IS_DOT11_MODE_HT(session->dot11mode);
785 session->vhtCapability =
786 IS_DOT11_MODE_VHT(session->dot11mode);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800787
Srinivas Girigowda28fb0122017-03-26 22:21:20 -0700788 pe_debug("HT[%d], VHT[%d]",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800789 session->htCapability, session->vhtCapability);
790
791 if (IS_DOT11_MODE_HE(session->dot11mode)) {
792 lim_update_session_he_capable(mac_ctx, session);
793 lim_copy_bss_he_cap(session, sme_start_bss_req);
794 }
795
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800796 session->txLdpcIniFeatureEnabled =
797 sme_start_bss_req->txLdpcIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800798#ifdef WLAN_FEATURE_11W
799 session->limRmfEnabled =
800 sme_start_bss_req->pmfCapable ? 1 : 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700801 pe_debug("Session RMF enabled: %d", session->limRmfEnabled);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800802#endif
803
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530804 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800805 (void *)&sme_start_bss_req->operationalRateSet,
806 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530807 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800808 (void *)&sme_start_bss_req->extendedRateSet,
809 sizeof(tSirMacRateSet));
810
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700811 if (IS_5G_CH(session->currentOperChannel))
812 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
813 else
814 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
815
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800816 switch (sme_start_bss_req->bssType) {
817 case eSIR_INFRA_AP_MODE:
818 lim_configure_ap_start_bss_session(mac_ctx, session,
819 sme_start_bss_req);
Krunal Soni53993f72016-07-08 18:20:03 -0700820 if (session->pePersona == QDF_SAP_MODE)
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700821 session->vdev_nss = vdev_type_nss->sap;
Krunal Soni53993f72016-07-08 18:20:03 -0700822 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700823 session->vdev_nss = vdev_type_nss->p2p_go;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800824 break;
825 case eSIR_IBSS_MODE:
826 session->limSystemRole = eLIM_STA_IN_IBSS_ROLE;
827 lim_get_short_slot_from_phy_mode(mac_ctx, session,
828 session->gLimPhyMode,
829 &session->shortSlotTimeSupported);
830
831 /*
832 * initialize to "OPEN".
833 * will be updated upon key installation
834 */
835 session->encryptType = eSIR_ED_NONE;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700836 session->vdev_nss = vdev_type_nss->ibss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800837
838 break;
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700839 case eSIR_NDI_MODE:
840 session->limSystemRole = eLIM_NDI_ROLE;
841 break;
842
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800843
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800844 /*
845 * There is one more mode called auto mode.
846 * which is used no where
847 */
848
849 /* FORBUILD -TEMPFIX.. HOW TO use AUTO MODE????? */
850
851 default:
852 /* not used anywhere...used in scan function */
853 break;
854 }
855
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700856 pe_debug("persona - %d, nss - %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -0700857 session->pePersona, session->vdev_nss);
858 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800859 /*
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700860 * Allocate memory for the array of
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800861 * parsed (Re)Assoc request structure
862 */
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700863 if (sme_start_bss_req->bssType == eSIR_INFRA_AP_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800864 session->parsedAssocReq =
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530865 qdf_mem_malloc(session->dph.dphHashTable.
Rajeev Kumarc9a50e72016-04-15 15:18:42 -0700866 size * sizeof(tpSirAssocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800867 if (NULL == session->parsedAssocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700868 pe_warn("AllocateMemory() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800869 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
870 goto free;
871 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800872 }
873
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700874 if (!sme_start_bss_req->channelId &&
875 sme_start_bss_req->bssType != eSIR_NDI_MODE) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700876 pe_err("Received invalid eWNI_SME_START_BSS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800877 ret_code = eSIR_SME_INVALID_PARAMETERS;
878 goto free;
879 }
880 channel_number = sme_start_bss_req->channelId;
881#ifdef QCA_HT_2040_COEX
882 if (sme_start_bss_req->obssEnabled)
883 session->htSupportedChannelWidthSet =
884 session->htCapability;
885 else
886#endif
887 session->htSupportedChannelWidthSet =
888 (sme_start_bss_req->sec_ch_offset) ? 1 : 0;
889 session->htSecondaryChannelOffset =
890 sme_start_bss_req->sec_ch_offset;
891 session->htRecommendedTxWidthSet =
892 (session->htSecondaryChannelOffset) ? 1 : 0;
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530893 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800894 FL("cbMode %u"), sme_start_bss_req->cbMode);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -0800895 if (lim_is_session_he_capable(session) ||
896 session->vhtCapability || session->htCapability) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800897 chanwidth = sme_start_bss_req->vht_channel_width;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700898 pe_debug("vht_channel_width %u htSupportedChannelWidthSet %d",
Sandeep Puligillafade9b72016-02-01 12:41:54 -0800899 sme_start_bss_req->vht_channel_width,
900 session->htSupportedChannelWidthSet);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800901 session->ch_width = chanwidth;
902 if (session->htSupportedChannelWidthSet) {
903 session->ch_center_freq_seg0 =
904 sme_start_bss_req->center_freq_seg0;
905 session->ch_center_freq_seg1 =
906 sme_start_bss_req->center_freq_seg1;
907 } else {
908 session->ch_center_freq_seg0 = 0;
909 session->ch_center_freq_seg1 = 0;
910 }
911 }
912
913 if (session->vhtCapability &&
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -0800914 (session->ch_width > CH_WIDTH_80MHZ)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800915 session->nss = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700916 pe_debug("nss set to [%d]", session->nss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800917 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700918 pe_debug("vht su tx bformer %d",
Krunal Soni53993f72016-07-08 18:20:03 -0700919 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800920
921 /* Delete pre-auth list if any */
922 lim_delete_pre_auth_list(mac_ctx);
923
Krunal Soni53993f72016-07-08 18:20:03 -0700924 if (session->nss == 1) {
925 session->vht_config.su_beam_former = 0;
926 session->vht_config.tx_stbc = 0;
927 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530928 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -0700929 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800930 /*
931 * keep the RSN/WPA IE information in PE Session Entry
932 * later will be using this to check when received (Re)Assoc req
933 */
934 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(mac_ctx,
935 &sme_start_bss_req->rsnIE, session);
936
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700937 if (LIM_IS_AP_ROLE(session) ||
938 LIM_IS_IBSS_ROLE(session) ||
939 LIM_IS_NDI_ROLE(session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800940 session->gLimProtectionControl =
941 sme_start_bss_req->protEnabled;
942 /*
943 * each byte will have the following info
944 * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
945 * reserved reserved RIFS Lsig n-GF ht20 11g 11b
946 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530947 qdf_mem_copy((void *)&session->cfgProtection,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800948 (void *)&sme_start_bss_req->ht_capab,
949 sizeof(uint16_t));
950 /* Initialize WPS PBC session link list */
951 session->pAPWPSPBCSession = NULL;
952 }
953 /* Prepare and Issue LIM_MLM_START_REQ to MLM */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530954 mlm_start_req = qdf_mem_malloc(sizeof(tLimMlmStartReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800955 if (NULL == mlm_start_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700956 pe_err("Allocate Memory failed for mlmStartReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800957 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
958 goto free;
959 }
960
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800961 /* Copy SSID to the MLM start structure */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530962 qdf_mem_copy((uint8_t *) &mlm_start_req->ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800963 (uint8_t *) &sme_start_bss_req->ssId,
964 sme_start_bss_req->ssId.length + 1);
965 mlm_start_req->ssidHidden = sme_start_bss_req->ssidHidden;
966 mlm_start_req->obssProtEnabled =
967 sme_start_bss_req->obssProtEnabled;
968
969 mlm_start_req->bssType = session->bssType;
970
971 /* Fill PE session Id from the session Table */
972 mlm_start_req->sessionId = session->peSessionId;
973
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700974 if (mlm_start_req->bssType == eSIR_INFRA_AP_MODE ||
975 mlm_start_req->bssType == eSIR_NDI_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800976 /*
977 * Copy the BSSId from sessionTable to
978 * mlmStartReq struct
979 */
980 sir_copy_mac_addr(mlm_start_req->bssId, session->bssId);
981 } else {
982 /* ibss mode */
983 mac_ctx->lim.gLimIbssCoalescingHappened = false;
984
985 ret_status = wlan_cfg_get_int(mac_ctx,
986 WNI_CFG_IBSS_AUTO_BSSID,
987 &auto_gen_bssid);
988 if (ret_status != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -0700989 pe_err("Get Auto Gen BSSID fail,Status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800990 ret_status);
991 ret_code = eSIR_LOGP_EXCEPTION;
992 goto free;
993 }
994
995 if (!auto_gen_bssid) {
996 /*
997 * We're not auto generating BSSID.
998 * Instead, get it from session entry
999 */
1000 sir_copy_mac_addr(mlm_start_req->bssId,
1001 session->bssId);
1002 /*
1003 * Start IBSS group BSSID
1004 * Auto Generating BSSID.
1005 */
1006 auto_gen_bssid = ((mlm_start_req->bssId[0] &
1007 0x01) ? true : false);
1008 }
1009
1010 if (auto_gen_bssid) {
1011 /*
1012 * if BSSID is not any uc id.
1013 * then use locally generated BSSID.
1014 * Autogenerate the BSSID
1015 */
1016 lim_get_random_bssid(mac_ctx,
1017 mlm_start_req->bssId);
1018 mlm_start_req->bssId[0] = 0x02;
1019
1020 /*
1021 * Copy randomly generated BSSID
1022 * to the session Table
1023 */
1024 sir_copy_mac_addr(session->bssId,
1025 mlm_start_req->bssId);
1026 }
1027 }
1028 /* store the channel num in mlmstart req structure */
1029 mlm_start_req->channelNumber = session->currentOperChannel;
1030 mlm_start_req->cbMode = sme_start_bss_req->cbMode;
1031 mlm_start_req->beaconPeriod =
1032 session->beaconParams.beaconInterval;
Arif Hussain671a1902017-03-17 09:08:32 -07001033 mlm_start_req->cac_duration_ms =
1034 sme_start_bss_req->cac_duration_ms;
1035 mlm_start_req->dfs_regdomain =
1036 sme_start_bss_req->dfs_regdomain;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001037 if (LIM_IS_AP_ROLE(session)) {
1038 mlm_start_req->dtimPeriod = session->dtimPeriod;
1039 mlm_start_req->wps_state = session->wps_state;
1040
1041 } else {
1042 if (wlan_cfg_get_int(mac_ctx,
1043 WNI_CFG_DTIM_PERIOD, &val) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001044 pe_err("could not retrieve DTIM Period");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001045 mlm_start_req->dtimPeriod = (uint8_t) val;
1046 }
1047
1048 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_PERIOD, &val) !=
1049 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001050 pe_err("could not retrieve Beacon interval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001051 mlm_start_req->cfParamSet.cfpPeriod = (uint8_t) val;
1052
1053 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_CFP_MAX_DURATION, &val) !=
1054 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001055 pe_err("could not retrieve CFPMaxDuration");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001056 mlm_start_req->cfParamSet.cfpMaxDuration = (uint16_t) val;
1057
1058 /*
1059 * this may not be needed anymore now,
1060 * as rateSet is now included in the
1061 * session entry and MLM has session context.
1062 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301063 qdf_mem_copy((void *)&mlm_start_req->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001064 (void *)&session->rateSet,
1065 sizeof(tSirMacRateSet));
1066
1067 /* Now populate the 11n related parameters */
1068 mlm_start_req->nwType = session->nwType;
1069 mlm_start_req->htCapable = session->htCapability;
1070
1071 mlm_start_req->htOperMode = mac_ctx->lim.gHTOperMode;
1072 /* Unused */
1073 mlm_start_req->dualCTSProtection =
1074 mac_ctx->lim.gHTDualCTSProtection;
1075 mlm_start_req->txChannelWidthSet =
1076 session->htRecommendedTxWidthSet;
1077
1078 session->limRFBand = lim_get_rf_band(channel_number);
1079
1080 /* Initialize 11h Enable Flag */
1081 session->lim11hEnable = 0;
gaolez76d2a162017-03-21 19:23:58 +08001082 if (mlm_start_req->bssType != eSIR_IBSS_MODE &&
1083 (CHAN_HOP_ALL_BANDS_ENABLE ||
1084 SIR_BAND_5_GHZ == session->limRFBand)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001085 if (wlan_cfg_get_int(mac_ctx,
1086 WNI_CFG_11H_ENABLED, &val) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001087 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001088 else
1089 session->lim11hEnable = val;
1090
1091 if (session->lim11hEnable &&
1092 (eSIR_INFRA_AP_MODE ==
1093 mlm_start_req->bssType)) {
1094 cfg_get_wmi_dfs_master_param =
1095 wlan_cfg_get_int(mac_ctx,
1096 WNI_CFG_DFS_MASTER_ENABLED,
1097 &val);
1098 session->lim11hEnable = val;
1099 }
1100 if (cfg_get_wmi_dfs_master_param != eSIR_SUCCESS)
1101 /* Failed get CFG WNI_CFG_DFS_MASTER_ENABLED */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001102 pe_err("Get Fail, CFG DFS ENABLE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001103 }
1104
1105 if (!session->lim11hEnable) {
1106 if (cfg_set_int(mac_ctx,
1107 WNI_CFG_LOCAL_POWER_CONSTRAINT, 0) !=
1108 eSIR_SUCCESS)
1109 /*
1110 * Failed to set the CFG param
1111 * WNI_CFG_LOCAL_POWER_CONSTRAINT
1112 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001113 pe_err("Set LOCAL_POWER_CONSTRAINT failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001114 }
1115
1116 session->limPrevSmeState = session->limSmeState;
1117 session->limSmeState = eLIM_SME_WT_START_BSS_STATE;
1118 MTRACE(mac_trace
1119 (mac_ctx, TRACE_CODE_SME_STATE,
1120 session->peSessionId,
1121 session->limSmeState));
1122
1123 lim_post_mlm_message(mac_ctx, LIM_MLM_START_REQ,
1124 (uint32_t *) mlm_start_req);
1125 return;
1126 } else {
1127
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001128 pe_err("Received unexpected START_BSS_REQ, in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001129 mac_ctx->lim.gLimSmeState);
1130 ret_code = eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED;
Krunal Sonib37bb352016-12-20 14:12:21 -08001131 goto free;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001132 } /* if (mac_ctx->lim.gLimSmeState == eLIM_SME_OFFLINE_STATE) */
1133
1134free:
1135 if ((session != NULL) &&
Krunal Sonib37bb352016-12-20 14:12:21 -08001136 (session->pLimStartBssReq == sme_start_bss_req)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001137 session->pLimStartBssReq = NULL;
1138 }
Krunal Sonib37bb352016-12-20 14:12:21 -08001139 if (NULL != sme_start_bss_req)
1140 qdf_mem_free(sme_start_bss_req);
1141 if (NULL != mlm_start_req)
1142 qdf_mem_free(mlm_start_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001143 if (NULL != session) {
1144 pe_delete_session(mac_ctx, session);
1145 session = NULL;
1146 }
1147 lim_send_sme_start_bss_rsp(mac_ctx, eWNI_SME_START_BSS_RSP, ret_code,
1148 session, sme_session_id, sme_transaction_id);
1149}
1150
1151/**
1152 * __lim_process_sme_start_bss_req() - Call handler to start BSS
1153 *
1154 * @pMac: Global MAC context
1155 * @pMsg: Message pointer
1156 *
1157 * Wrapper for the function __lim_handle_sme_start_bss_request
1158 * This message will be defered until softmac come out of
1159 * scan mode or if we have detected radar on the current
1160 * operating channel.
1161 *
1162 * return true - If we consumed the buffer
1163 * false - If have defered the message.
1164 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001165static bool __lim_process_sme_start_bss_req(tpAniSirGlobal pMac,
1166 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001167{
1168 if (__lim_is_defered_msg_for_learn(pMac, pMsg) ||
1169 __lim_is_defered_msg_for_radar(pMac, pMsg)) {
1170 /**
1171 * If message defered, buffer is not consumed yet.
1172 * So return false
1173 */
1174 return false;
1175 }
1176
1177 __lim_handle_sme_start_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
1178 return true;
1179}
1180
1181/**
1182 * lim_get_random_bssid()
1183 *
1184 * FUNCTION:This function is called to process generate the random number for bssid
1185 * This function is called to process SME_SCAN_REQ message
1186 * from HDD or upper layer application.
1187 *
1188 * LOGIC:
1189 *
1190 * ASSUMPTIONS:
1191 *
1192 * NOTE:
1193 * 1. geneartes the unique random number for bssid in ibss
1194 *
1195 * @param pMac Pointer to Global MAC structure
1196 * @param *data Pointer to bssid buffer
1197 * @return None
1198 */
1199void lim_get_random_bssid(tpAniSirGlobal pMac, uint8_t *data)
1200{
1201 uint32_t random[2];
1202 random[0] = tx_time_get();
1203 random[0] |= (random[0] << 15);
1204 random[1] = random[0] >> 1;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301205 qdf_mem_copy(data, (uint8_t *) random, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001206}
1207
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301208static QDF_STATUS lim_send_hal_start_scan_offload_req(tpAniSirGlobal pMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001209 tpSirSmeScanReq pScanReq)
1210{
1211 tSirScanOffloadReq *pScanOffloadReq;
1212 uint8_t *p;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001213 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001214 uint16_t i, len;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001215 uint16_t addn_ie_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001216 tSirRetStatus status, rc = eSIR_SUCCESS;
1217 tDot11fIEExtCap extracted_extcap = {0};
1218 bool extcap_present = true;
1219
1220 if (pScanReq->uIEFieldLen) {
1221 status = lim_strip_extcap_update_struct(pMac,
1222 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1223 &pScanReq->uIEFieldLen, &extracted_extcap);
1224
1225 if (eSIR_SUCCESS != status) {
1226 extcap_present = false;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001227 pe_debug("Unable to Strip ExtCap IE from Scan Req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001228 }
1229
1230 if (extcap_present) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001231 pe_debug("Extcap was part of SCAN IE - Updating FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001232 lim_send_ext_cap_ie(pMac, pScanReq->sessionId,
1233 &extracted_extcap, true);
1234 }
1235 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001236 pe_debug("No IEs in the scan request from supplicant");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001237 }
1238
1239 /**
1240 * The tSirScanOffloadReq will reserve the space for first channel,
1241 * so allocate the memory for (numChannels - 1) and uIEFieldLen
1242 */
1243 len = sizeof(tSirScanOffloadReq) +
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001244 (pScanReq->channelList.numChannels - 1) +
1245 pScanReq->uIEFieldLen;
Naveen Rawat02e12662016-08-31 16:49:27 -07001246
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301247 pScanOffloadReq = qdf_mem_malloc(len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001248 if (NULL == pScanOffloadReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001249 pe_err("AllocateMemory failed for pScanOffloadReq");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301250 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001251 }
1252
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001253 msg.type = WMA_START_SCAN_OFFLOAD_REQ;
1254 msg.bodyptr = pScanOffloadReq;
1255 msg.bodyval = 0;
1256
Anurag Chouhanc5548422016-02-24 18:33:27 +05301257 qdf_copy_macaddr(&pScanOffloadReq->bssId, &pScanReq->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001258
1259 if (pScanReq->numSsid > SIR_SCAN_MAX_NUM_SSID) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001260 pe_err("Invalid value (%d) for numSsid",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001261 SIR_SCAN_MAX_NUM_SSID);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301262 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301263 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001264 }
1265
1266 pScanOffloadReq->numSsid = pScanReq->numSsid;
1267 for (i = 0; i < pScanOffloadReq->numSsid; i++) {
1268 pScanOffloadReq->ssId[i].length = pScanReq->ssId[i].length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301269 qdf_mem_copy((uint8_t *) pScanOffloadReq->ssId[i].ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001270 (uint8_t *) pScanReq->ssId[i].ssId,
1271 pScanOffloadReq->ssId[i].length);
1272 }
1273
1274 pScanOffloadReq->hiddenSsid = pScanReq->hiddenSsid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301275 qdf_copy_macaddr(&pScanOffloadReq->selfMacAddr, &pScanReq->selfMacAddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001276 pScanOffloadReq->bssType = pScanReq->bssType;
1277 pScanOffloadReq->dot11mode = pScanReq->dot11mode;
1278 pScanOffloadReq->scanType = pScanReq->scanType;
1279 pScanOffloadReq->minChannelTime = pScanReq->minChannelTime;
1280 pScanOffloadReq->maxChannelTime = pScanReq->maxChannelTime;
1281 pScanOffloadReq->restTime = pScanReq->restTime;
Agrawal Ashish17bb3902016-05-05 13:29:40 +05301282 pScanOffloadReq->min_rest_time = pScanReq->min_rest_time;
1283 pScanOffloadReq->idle_time = pScanReq->idle_time;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301284 pScanOffloadReq->scan_adaptive_dwell_mode =
1285 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001286
Paul Zhangd2315472017-02-22 10:02:50 +08001287 for (i = 0; i < pMac->lim.maxBssId; i++) {
1288 tpPESession session_entry =
1289 pe_find_session_by_sme_session_id(pMac, i);
1290 if (session_entry &&
1291 (eLIM_MLM_LINK_ESTABLISHED_STATE ==
1292 session_entry->limMlmState) &&
1293 (session_entry->beaconParams.beaconInterval
1294 < BEACON_INTERVAL_THRESHOLD)) {
1295 pScanOffloadReq->burst_scan_duration =
1296 STA_BURST_SCAN_DURATION;
1297 break;
1298 }
1299 }
1300
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001301 /* for normal scan, the value for p2pScanType should be 0
1302 always */
1303 if (pScanReq->p2pSearch)
1304 pScanOffloadReq->p2pScanType = P2P_SCAN_TYPE_SEARCH;
1305
1306 pScanOffloadReq->sessionId = pScanReq->sessionId;
1307 pScanOffloadReq->scan_id = pScanReq->scan_id;
Deepak Dhamdhered97bfb32015-10-11 15:16:18 -07001308 pScanOffloadReq->scan_requestor_id = USER_SCAN_REQUESTOR_ID;
Gupta, Kapil96c7f2f2016-04-25 19:13:41 +05301309 pScanOffloadReq->scan_adaptive_dwell_mode =
1310 pScanReq->scan_adaptive_dwell_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001311
1312 if (pScanOffloadReq->sessionId >= pMac->lim.maxBssId)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001313 pe_err("Invalid pe sessionID: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001314 pScanOffloadReq->sessionId);
1315
1316 pScanOffloadReq->channelList.numChannels =
1317 pScanReq->channelList.numChannels;
1318 p = &(pScanOffloadReq->channelList.channelNumber[0]);
1319 for (i = 0; i < pScanOffloadReq->channelList.numChannels; i++)
1320 p[i] = pScanReq->channelList.channelNumber[i];
1321
1322 pScanOffloadReq->uIEFieldLen = pScanReq->uIEFieldLen;
1323 pScanOffloadReq->uIEFieldOffset = len - addn_ie_len -
1324 pScanOffloadReq->uIEFieldLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301325 qdf_mem_copy((uint8_t *) pScanOffloadReq +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001326 pScanOffloadReq->uIEFieldOffset,
1327 (uint8_t *) pScanReq + pScanReq->uIEFieldOffset,
1328 pScanReq->uIEFieldLen);
Naveen Rawat02e12662016-08-31 16:49:27 -07001329
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001330 rc = wma_post_ctrl_msg(pMac, &msg);
1331 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001332 pe_err("wma_post_ctrl_msg() return failure");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301333 qdf_mem_free(pScanOffloadReq);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301334 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001335 }
1336
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001337 pe_debug("Processed Offload Scan Request Successfully");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001338
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301339 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001340}
1341
1342/**
1343 * __lim_process_sme_scan_req() - Process the SME Scan Request
1344 * @mac_ctx: Global MAC Context
1345 * @msg_buf: Buffer which contains the request and pertinent parameters
1346 *
1347 * This function is called to process SME_SCAN_REQ message
1348 * from HDD or upper layer application.
1349 *
1350 * Return: None
1351 */
1352
1353static void __lim_process_sme_scan_req(tpAniSirGlobal mac_ctx,
1354 uint32_t *msg_buf)
1355{
1356 tpSirSmeScanReq scan_req;
1357 uint8_t valid_req = 0;
1358
1359#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1360 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SCAN_REQ_EVENT, NULL,
1361 eSIR_SUCCESS, eSIR_SUCCESS);
1362#endif
Sreelakshmi Konamki1bb6f312016-12-08 12:32:01 +05301363 mac_ctx->lim.beacon_probe_rsp_cnt_per_scan = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001364
1365 scan_req = (tpSirSmeScanReq) msg_buf;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001366 pe_debug("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 -08001367 scan_req->scan_id, scan_req->channelList.numChannels,
1368 scan_req->minChannelTime, scan_req->maxChannelTime,
1369 scan_req->uIEFieldLen, scan_req->returnAfterFirstMatch,
1370 scan_req->returnFreshResults, scan_req->returnUniqueResults,
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05301371 lim_scan_type_to_string(scan_req->scanType),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001372 scan_req->scanType, mac_ctx->lim.gLimRspReqd ? 1 : 0);
1373 /*
1374 * Since scan req always requires a response, we will overwrite response
1375 * required here. This is added esp to take care of the condition where
1376 * in p2p go case, we hold the scan req and insert single NOA. We send
1377 * the held scan request to FW later on getting start NOA ind from FW so
1378 * we lose state of the gLimRspReqd flag for the scan req if any other
1379 * request comes by then. e.g. While unit testing, we found when insert
1380 * single NOA is done, we see a get stats request which turns the flag
1381 * gLimRspReqd to false; now when we actually start the saved scan req
1382 * for init scan after getting NOA started, the gLimRspReqd being a
1383 * global flag is showing false instead of true value for this saved
1384 * scan req. Since all scan reqs coming to lim require a response,
1385 * there is no harm in setting the global flag gLimRspReqd to true here.
1386 */
1387 mac_ctx->lim.gLimRspReqd = true;
1388
1389 /*
1390 * copy the Self MAC address from SmeReq to the globalplace,
1391 * used for sending probe req
1392 */
Srinivas Girigowda2c6bf002015-09-24 11:43:31 -07001393 sir_copy_mac_addr(mac_ctx->lim.gSelfMacAddr,
1394 scan_req->selfMacAddr.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001395 valid_req = lim_is_sme_scan_req_valid(mac_ctx, scan_req);
1396
1397 if (!valid_req || mac_ctx->lim.scan_disabled) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001398 pe_err("Scan disabled %d, Valid Scan Req %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001399 mac_ctx->lim.scan_disabled, valid_req);
1400
1401 if (mac_ctx->lim.gLimRspReqd) {
1402 mac_ctx->lim.gLimRspReqd = false;
1403
1404 lim_send_sme_scan_rsp(mac_ctx,
1405 eSIR_SME_INVALID_PARAMETERS,
1406 scan_req->sessionId,
1407 scan_req->transactionId,
1408 scan_req->scan_id);
1409 }
1410 return;
1411 }
1412
1413 /*
1414 * If scan request is received in idle, joinFailed
1415 * states or in link established state (in STA role)
1416 * or in normal state (in STA-in-IBSS/AP role) with
1417 * 'return fresh scan results' request from HDD or
1418 * it is periodic background scanning request,
1419 * trigger fresh scan request to MLM
1420 */
1421 if (__lim_fresh_scan_reqd(mac_ctx, scan_req->returnFreshResults)) {
1422
1423 mac_ctx->lim.gLim24Band11dScanDone = 0;
1424 mac_ctx->lim.gLim50Band11dScanDone = 0;
1425 mac_ctx->lim.gLimReturnAfterFirstMatch =
1426 scan_req->returnAfterFirstMatch;
1427 mac_ctx->lim.gLimReturnUniqueResults =
1428 ((scan_req->returnUniqueResults) > 0 ? true : false);
1429
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301430 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001431 lim_send_hal_start_scan_offload_req(mac_ctx,
1432 scan_req)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001433 pe_err("Couldn't send Offload scan request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001434 lim_send_sme_scan_rsp(mac_ctx,
1435 eSIR_SME_INVALID_PARAMETERS,
1436 scan_req->sessionId,
1437 scan_req->transactionId,
1438 scan_req->scan_id);
1439 return;
1440 }
Anurag Chouhanffb21542016-02-17 14:33:03 +05301441 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001442 /* In all other cases return 'cached' scan results */
1443 if (mac_ctx->lim.gLimRspReqd) {
1444 mac_ctx->lim.gLimRspReqd = false;
1445 lim_send_sme_scan_rsp(mac_ctx, eSIR_SME_SUCCESS,
1446 scan_req->sessionId,
1447 scan_req->transactionId, scan_req->scan_id);
1448 }
1449 }
1450}
1451
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001452/**
1453 * __lim_process_clear_dfs_channel_list()
1454 *
1455 ***FUNCTION:
1456 ***Clear DFS channel list when country is changed/aquired.
1457 .*This message is sent from SME.
1458 *
1459 ***LOGIC:
1460 *
1461 ***ASSUMPTIONS:
1462 *
1463 ***NOTE:
1464 *
1465 * @param pMac Pointer to Global MAC structure
1466 * @param *pMsgBuf A pointer to the SME message buffer
1467 * @return None
1468 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001469static void __lim_process_clear_dfs_channel_list(tpAniSirGlobal pMac,
1470 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001471{
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301472 qdf_mem_set(&pMac->lim.dfschannelList, sizeof(tSirDFSChannelList), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001473}
1474
1475/**
1476 * __lim_process_sme_join_req() - process SME_JOIN_REQ message
1477 * @mac_ctx: Pointer to Global MAC structure
1478 * @msg_buf: A pointer to the SME message buffer
1479 *
1480 * This function is called to process SME_JOIN_REQ message
1481 * from HDD or upper layer application.
1482 *
1483 * Return: None
1484 */
1485static void
1486__lim_process_sme_join_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
1487{
1488 tpSirSmeJoinReq sme_join_req = NULL;
1489 tLimMlmJoinReq *mlm_join_req;
1490 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
1491 uint32_t val = 0;
1492 uint16_t n_size;
1493 uint8_t session_id;
1494 tpPESession session = NULL;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301495 uint8_t sme_session_id = 0;
1496 uint16_t sme_transaction_id = 0;
Amar Singhala297bfa2015-10-15 15:07:29 -07001497 int8_t local_power_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001498 uint16_t ie_len;
1499 uint8_t *vendor_ie;
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001500 tSirBssDescription *bss_desc;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001501 struct vdev_type_nss *vdev_type_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001502
Arif Hussain995fcaf2016-07-18 11:28:22 -07001503 if (!mac_ctx || !msg_buf) {
1504 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
1505 FL("JOIN REQ with invalid data"));
1506 return;
1507 }
1508
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001509/* FEATURE_WLAN_DIAG_SUPPORT */
1510#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
1511 /*
1512 * Not sending any session, since it is not created yet.
1513 * The response whould have correct state.
1514 */
1515 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_REQ_EVENT, NULL, 0, 0);
1516#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1517
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001518 /*
1519 * Expect Join request in idle state.
1520 * Reassociate request is expected in link established state.
1521 */
1522
1523 /* Global SME and LIM states are not defined yet for BT-AMP Support */
1524 if (mac_ctx->lim.gLimSmeState == eLIM_SME_IDLE_STATE) {
1525 n_size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)
1526 msg_buf);
1527
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301528 sme_join_req = qdf_mem_malloc(n_size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001529 if (NULL == sme_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001530 pe_err("AllocateMemory failed for sme_join_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001531 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
Nitesh Shah0102cac2016-07-13 14:38:30 +05301532 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001533 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301534 (void)qdf_mem_copy((void *)sme_join_req, (void *)msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001535 n_size);
1536
1537 if (!lim_is_sme_join_req_valid(mac_ctx, sme_join_req)) {
1538 /* Received invalid eWNI_SME_JOIN_REQ */
1539 /* Log the event */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001540 pe_warn("SessionId:%d JOIN REQ with invalid data",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001541 sme_join_req->sessionId);
1542 ret_code = eSIR_SME_INVALID_PARAMETERS;
1543 goto end;
1544 }
1545
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08001546 /*
1547 * Update the capability here itself as this is used in
1548 * lim_extract_ap_capability() below. If not updated issues
1549 * like not honoring power constraint on 1st association after
1550 * driver loading might occur.
1551 */
1552 lim_update_rrm_capability(mac_ctx, sme_join_req);
1553
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001554 bss_desc = &sme_join_req->bssDescription;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001555 /* check for the existence of start BSS session */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001556 session = pe_find_session_by_bssid(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001557 &session_id);
1558
1559 if (session != NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001560 pe_err("Session(%d) Already exists for BSSID: "
1561 MAC_ADDRESS_STR " in limSmeState = %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001562 session_id,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001563 MAC_ADDR_ARRAY(bss_desc->bssId),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001564 session->limSmeState);
1565
1566 if (session->limSmeState == eLIM_SME_LINK_EST_STATE &&
1567 session->smeSessionId == sme_join_req->sessionId) {
1568 /*
1569 * Received eWNI_SME_JOIN_REQ for same
1570 * BSS as currently associated.
1571 * Log the event and send success
1572 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001573 pe_warn("SessionId: %d", session_id);
1574 pe_warn("JOIN_REQ for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001575 /* Send Join success response to host */
1576 ret_code = eSIR_SME_ALREADY_JOINED_A_BSS;
1577 session = NULL;
1578 goto end;
1579 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001580 pe_err("JOIN_REQ not for current joined BSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001581 ret_code = eSIR_SME_REFUSED;
1582 session = NULL;
1583 goto end;
1584 }
1585 } else {
1586 /*
1587 * Session Entry does not exist for given BSSId
1588 * Try to Create a new session
1589 */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001590 session = pe_create_session(mac_ctx, bss_desc->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001591 &session_id, mac_ctx->lim.maxStation,
1592 eSIR_INFRASTRUCTURE_MODE);
1593 if (session == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001594 pe_err("Session Can not be created");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001595 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1596 goto end;
1597 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001598 pe_debug("SessionId:%d New session created",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001599 session_id);
1600 }
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07001601 session->max_amsdu_num = sme_join_req->max_amsdu_num;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001602
1603 /*
1604 * Store Session related parameters
1605 * Store PE session Id in session Table
1606 */
1607 session->peSessionId = session_id;
1608
1609 /* store the smejoin req handle in session table */
1610 session->pLimJoinReq = sme_join_req;
1611
1612 /* Store SME session Id in sessionTable */
1613 session->smeSessionId = sme_join_req->sessionId;
1614
1615 /* Store SME transaction Id in session Table */
1616 session->transactionId = sme_join_req->transactionId;
1617
1618 /* Store beaconInterval */
1619 session->beaconParams.beaconInterval =
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001620 bss_desc->beaconInterval;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001621
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301622 qdf_mem_copy(&(session->htConfig), &(sme_join_req->htConfig),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001623 sizeof(session->htConfig));
1624
Sandeep Puligilla98917432016-06-10 13:50:28 -07001625 qdf_mem_copy(&(session->vht_config),
1626 &(sme_join_req->vht_config),
1627 sizeof(session->vht_config));
1628
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001629 /* Copying of bssId is already done, while creating session */
1630 sir_copy_mac_addr(session->selfMacAddr,
1631 sme_join_req->selfMacAddr);
1632 session->bssType = sme_join_req->bsstype;
1633
1634 session->statypeForBss = STA_ENTRY_PEER;
1635 session->limWmeEnabled = sme_join_req->isWMEenabled;
1636 session->limQosEnabled = sme_join_req->isQosEnabled;
Abhishek Singhf78bd2d2016-04-27 16:47:56 +05301637 session->wps_registration = sme_join_req->wps_registration;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001638
Selvaraj, Sridhar05ea0792017-05-17 12:17:03 +05301639 session->enable_bcast_probe_rsp =
1640 sme_join_req->enable_bcast_probe_rsp;
1641
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001642 /* Store vendor specfic IE for CISCO AP */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001643 ie_len = (bss_desc->length + sizeof(bss_desc->length) -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001644 GET_FIELD_OFFSET(tSirBssDescription, ieFields));
1645
1646 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
1647 SIR_MAC_CISCO_OUI, SIR_MAC_CISCO_OUI_SIZE,
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001648 ((uint8_t *)&bss_desc->ieFields), ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001649
1650 if (NULL != vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001651 pe_debug("Cisco vendor OUI present");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001652 session->isCiscoVendorAP = true;
1653 } else {
1654 session->isCiscoVendorAP = false;
1655 }
1656
1657 /* Copy the dot 11 mode in to the session table */
1658
1659 session->dot11mode = sme_join_req->dot11mode;
1660#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
1661 session->cc_switch_mode = sme_join_req->cc_switch_mode;
1662#endif
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001663 session->nwType = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001664 session->enableAmpduPs = sme_join_req->enableAmpduPs;
1665 session->enableHtSmps = sme_join_req->enableHtSmps;
1666 session->htSmpsvalue = sme_join_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08001667 session->send_smps_action =
1668 sme_join_req->send_smps_action;
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001669 /*
1670 * By default supported NSS 1x1 is set to true
1671 * and later on updated while determining session
1672 * supported rates which is the intersection of
1673 * self and peer rates
1674 */
1675 session->supported_nss_1x1 = true;
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301676 /*Store Persona */
1677 session->pePersona = sme_join_req->staPersona;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001678 pe_debug("enable Smps: %d mode: %d send action: %d supported nss 1x1: %d pePersona %d cbMode %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08001679 session->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08001680 session->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07001681 session->send_smps_action,
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301682 session->supported_nss_1x1,
1683 session->pePersona,
1684 sme_join_req->cbMode);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001685
1686 /*Store Persona */
1687 session->pePersona = sme_join_req->staPersona;
1688 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001689 FL("PE PERSONA=%d cbMode %u nwType: %d dot11mode: %d"),
1690 session->pePersona, sme_join_req->cbMode,
1691 session->nwType, session->dot11mode);
1692
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001693 /* Copy The channel Id to the session Table */
1694 session->currentOperChannel = bss_desc->channelId;
1695 if (IS_5G_CH(session->currentOperChannel))
1696 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001697 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001698 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
1699 if (session->pePersona == QDF_P2P_CLIENT_MODE)
1700 session->vdev_nss = vdev_type_nss->p2p_cli;
1701 else
1702 session->vdev_nss = vdev_type_nss->sta;
1703 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001704 session->vhtCapability =
1705 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001706 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301707 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001708 session->vht_config.su_beam_formee =
1709 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001710 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001711 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001712 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001713 session->enableVhtpAid =
1714 sme_join_req->enableVhtpAid;
1715 session->enableVhtGid =
1716 sme_join_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001717 pe_debug("vht su bformer [%d]",
Krunal Soni53993f72016-07-08 18:20:03 -07001718 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001719 }
Krunal Soni53993f72016-07-08 18:20:03 -07001720
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001721 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1722 lim_update_session_he_capable(mac_ctx, session);
1723 lim_copy_join_req_he_cap(session, sme_join_req);
1724 }
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001725
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001726 pe_debug("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301727 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001728 session->vht_config.su_beam_formee,
1729 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001730 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001731 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001732 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001733 handle_ht_capabilityand_ht_info(mac_ctx, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001734 /* cbMode is already merged value of peer and self -
1735 * done by csr in csr_get_cb_mode_from_ies */
1736 session->htSupportedChannelWidthSet =
1737 (sme_join_req->cbMode) ? 1 : 0;
1738 session->htRecommendedTxWidthSet =
1739 session->htSupportedChannelWidthSet;
1740 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1741
1742 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1743 session->ch_center_freq_seg0 =
1744 session->currentOperChannel - 2;
1745 session->ch_width = CH_WIDTH_40MHZ;
1746 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1747 sme_join_req->cbMode) {
1748 session->ch_center_freq_seg0 =
1749 session->currentOperChannel + 2;
1750 session->ch_width = CH_WIDTH_40MHZ;
1751 } else {
1752 session->ch_center_freq_seg0 = 0;
1753 session->ch_width = CH_WIDTH_20MHZ;
1754 }
1755
1756 /* Record if management frames need to be protected */
1757#ifdef WLAN_FEATURE_11W
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001758 if (eSIR_ED_AES_128_CMAC == sme_join_req->MgmtEncryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001759 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001760 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001761 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001762#endif
1763
1764#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001765 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001766#endif
1767
1768 /* Copy the SSID from smejoinreq to session entry */
1769 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301770 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001771 session->ssId.length);
1772
1773 /*
1774 * Determin 11r or ESE connection based on input from SME
1775 * which inturn is dependent on the profile the user wants
1776 * to connect to, So input is coming from supplicant
1777 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001778 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001779#ifdef FEATURE_WLAN_ESE
1780 session->isESEconnection = sme_join_req->isESEconnection;
1781#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001782 session->isFastTransitionEnabled =
1783 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001784
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001785 session->isFastRoamIniFeatureEnabled =
1786 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001787 session->txLdpcIniFeatureEnabled =
1788 sme_join_req->txLdpcIniFeatureEnabled;
1789
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05301790 lim_update_fils_config(session, sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001791 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1792 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001793 } else {
1794 /*
1795 * Throw an error and return and make
1796 * sure to delete the session.
1797 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001798 pe_err("recvd JOIN_REQ with invalid bss type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001799 session->bssType);
1800 ret_code = eSIR_SME_INVALID_PARAMETERS;
1801 goto end;
1802 }
1803
1804 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301805 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001806 &sme_join_req->addIEScan, sizeof(tSirAddie));
1807
1808 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301809 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001810 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1811
1812 val = sizeof(tLimMlmJoinReq) +
1813 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301814 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001815 if (NULL == mlm_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001816 pe_err("AllocateMemory failed for mlmJoinReq");
Nitesh Shah0102cac2016-07-13 14:38:30 +05301817 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1818 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001819 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001820
1821 /* PE SessionId is stored as a part of JoinReq */
1822 mlm_join_req->sessionId = session->peSessionId;
1823
1824 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1825 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1826 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001827 pe_err("couldn't retrieve JoinFailureTimer value"
1828 " setting to default value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829 mlm_join_req->joinFailureTimeout =
1830 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1831 }
1832
1833 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301834 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001835 (void *)&sme_join_req->operationalRateSet,
1836 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301837 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001838 (void *)&sme_join_req->extendedRateSet,
1839 sizeof(tSirMacRateSet));
1840 /*
1841 * this may not be needed anymore now, as rateSet is now
1842 * included in the session entry and MLM has session context.
1843 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301844 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001845 (void *)&session->rateSet,
1846 sizeof(tSirMacRateSet));
1847
1848 session->encryptType = sme_join_req->UCEncryptionType;
1849
1850 mlm_join_req->bssDescription.length =
1851 session->pLimJoinReq->bssDescription.length;
1852
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301853 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001854 (uint8_t *)
1855 &session->pLimJoinReq->bssDescription.bssId,
1856 session->pLimJoinReq->bssDescription.length + 2);
1857
1858 session->limCurrentBssCaps =
1859 session->pLimJoinReq->bssDescription.capabilityInfo;
1860
1861 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1862 session->currentOperChannel);
1863 local_power_constraint = reg_max;
1864
1865 lim_extract_ap_capability(mac_ctx,
1866 (uint8_t *)
1867 session->pLimJoinReq->bssDescription.ieFields,
1868 lim_get_ielen_from_bss_description(
1869 &session->pLimJoinReq->bssDescription),
1870 &session->limCurrentBssQosCaps,
1871 &session->limCurrentBssPropCap,
1872 &session->gLimCurrentBssUapsd,
1873 &local_power_constraint, session);
1874
Krunal Soni53993f72016-07-08 18:20:03 -07001875 /*
1876 * Once the AP capabilities are available then set the
1877 * beam forming capabilities accordingly.
1878 */
1879 if (session->nss == 1) {
1880 session->vht_config.su_beam_former = 0;
1881 session->vht_config.tx_stbc = 0;
1882 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +05301883 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001884 }
1885
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001886 session->maxTxPower = lim_get_max_tx_power(reg_max,
1887 local_power_constraint,
1888 mac_ctx->roam.configParam.nTxPowerCap);
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301889
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001890 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301891 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001892
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301893 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1894 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1895 pe_debug("Update MaxTxPower in join Req to %d",
1896 sme_join_req->powerCap.maxTxPower);
1897 }
1898
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001899 if (session->gLimCurrentBssUapsd) {
1900 session->gUapsdPerAcBitmask =
1901 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001902 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001903 session->gUapsdPerAcBitmask);
1904
1905 /* resetting the dynamic uapsd mask */
1906 session->gUapsdPerAcDeliveryEnableMask = 0;
1907 session->gUapsdPerAcTriggerEnableMask = 0;
1908 }
1909
1910 session->limRFBand =
1911 lim_get_rf_band(session->currentOperChannel);
1912
1913 /* Initialize 11h Enable Flag */
1914 if (SIR_BAND_5_GHZ == session->limRFBand) {
1915 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1916 &val) != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001917 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001918 session->lim11hEnable =
1919 WNI_CFG_11H_ENABLED_STADEF;
1920 } else {
1921 session->lim11hEnable = val;
1922 }
1923 } else {
1924 session->lim11hEnable = 0;
1925 }
1926
1927 /*
1928 * To care of the scenario when STA transitions from
1929 * IBSS to Infrastructure mode.
1930 */
1931 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1932
1933 session->limPrevSmeState = session->limSmeState;
1934 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1935 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1936 session->peSessionId,
1937 session->limSmeState));
1938
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001939 /* Indicate whether spectrum management is enabled */
1940 session->spectrumMgtEnabled =
1941 sme_join_req->spectrumMgtIndicator;
1942
1943 /* Enable the spectrum management if this is a DFS channel */
1944 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001945 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001946 session->currentOperChannel))
1947 session->spectrumMgtEnabled = true;
1948
1949 session->isOSENConnection = sme_join_req->isOSENConnection;
1950
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001951 /* Issue LIM_MLM_JOIN_REQ to MLM */
1952 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
1953 (uint32_t *) mlm_join_req);
1954 return;
1955
1956 } else {
1957 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001958 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001959 mac_ctx->lim.gLimSmeState);
1960 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1961 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1962 session = NULL;
1963 goto end;
1964 }
1965
1966end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301967 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1968 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001969
1970 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301971 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001972 sme_join_req = NULL;
1973 if (NULL != session)
1974 session->pLimJoinReq = NULL;
1975 }
1976 if (ret_code != eSIR_SME_SUCCESS) {
1977 if (NULL != session) {
1978 pe_delete_session(mac_ctx, session);
1979 session = NULL;
1980 }
1981 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001982 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001983 sme_session_id, ret_code);
1984 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1985 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1986 sme_transaction_id);
1987}
1988
Amar Singhala297bfa2015-10-15 15:07:29 -07001989uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001990 uint8_t iniTxPower)
1991{
1992 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301993 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
1994 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001995 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
1996 maxTxPower = txPower;
1997 else if (txPower < MIN_TX_PWR_CAP)
1998 maxTxPower = MIN_TX_PWR_CAP;
1999 else
2000 maxTxPower = MAX_TX_PWR_CAP;
2001
2002 return maxTxPower;
2003}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002004
2005/**
2006 * __lim_process_sme_reassoc_req() - process reassoc req
2007 *
2008 * @mac_ctx: Pointer to Global MAC structure
2009 * @msg_buf: pointer to the SME message buffer
2010 *
2011 * This function is called to process SME_REASSOC_REQ message
2012 * from HDD or upper layer application.
2013 *
2014 * Return: None
2015 */
2016
2017static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2018 uint32_t *msg_buf)
2019{
2020 uint16_t caps;
2021 uint32_t val;
2022 tpSirSmeJoinReq reassoc_req = NULL;
2023 tLimMlmReassocReq *mlm_reassoc_req;
2024 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2025 tpPESession session_entry = NULL;
2026 uint8_t session_id;
2027 uint8_t sme_session_id;
2028 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002029 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002030 uint32_t tele_bcn_en = 0;
2031 uint16_t size;
2032
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002033 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302034 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002035 if (NULL == reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002036 pe_err("call to AllocateMemory failed for reassoc_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002037
2038 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2039 goto end;
2040 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302041 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002042
2043 if (!lim_is_sme_join_req_valid(mac_ctx,
2044 (tpSirSmeJoinReq)reassoc_req)) {
2045 /*
2046 * Received invalid eWNI_SME_REASSOC_REQ
2047 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002048 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002049
2050 ret_code = eSIR_SME_INVALID_PARAMETERS;
2051 goto end;
2052 }
2053
2054 session_entry = pe_find_session_by_bssid(mac_ctx,
2055 reassoc_req->bssDescription.bssId,
2056 &session_id);
2057 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002058 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07002059 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2060 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002061 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07002062 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
2063 &sme_session_id, &transaction_id);
2064 session_entry =
2065 pe_find_session_by_sme_session_id(mac_ctx,
2066 sme_session_id);
2067 if (session_entry != NULL)
2068 lim_handle_sme_join_result(mac_ctx,
2069 eSIR_SME_INVALID_PARAMETERS,
2070 eSIR_MAC_UNSPEC_FAILURE_STATUS,
2071 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002072 goto end;
2073 }
2074#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2075 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2076 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2077#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2078 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2079
2080 /* Store the reassoc handle in the session Table */
2081 session_entry->pLimReAssocReq = reassoc_req;
2082
2083 session_entry->dot11mode = reassoc_req->dot11mode;
2084 session_entry->vhtCapability =
2085 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002086
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302087 if (session_entry->vhtCapability) {
2088 if (session_entry->pePersona == QDF_STA_MODE) {
2089 session_entry->vht_config.su_beam_formee =
2090 reassoc_req->vht_config.su_beam_formee;
2091 } else {
2092 reassoc_req->vht_config.su_beam_formee = 0;
2093 }
2094 session_entry->enableVhtpAid =
2095 reassoc_req->enableVhtpAid;
2096 session_entry->enableVhtGid =
2097 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002098 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302099 }
2100
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002101 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302102 session_entry->vhtCapability,
2103 session_entry->vht_config.su_beam_formee,
2104 session_entry->vht_config.su_beam_former);
2105
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002106 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2107 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002108 session_entry->send_smps_action =
2109 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002110 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002111 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002112 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002113 session_entry->send_smps_action,
2114 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002115 /*
2116 * Reassociate request is expected
2117 * in link established state only.
2118 */
2119
2120 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002121 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2122 /*
2123 * May be from 11r FT pre-auth. So lets check it
2124 * before we bail out
2125 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002126 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002127 session_entry->peSessionId);
2128
2129 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302130 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002131 session_entry->limReAssocbssId,
2132 6)) {
2133 lim_print_mac_addr(mac_ctx,
2134 reassoc_req->bssDescription.
2135 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002136 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002137 ret_code = eSIR_SME_INVALID_PARAMETERS;
2138 goto end;
2139 }
2140
2141 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2142 session_entry);
2143 return;
2144 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002145 /*
2146 * Should not have received eWNI_SME_REASSOC_REQ
2147 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002148 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002149 session_entry->limSmeState);
2150 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2151
2152 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2153 goto end;
2154 }
2155
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302156 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002157 session_entry->pLimReAssocReq->bssDescription.bssId,
2158 sizeof(tSirMacAddr));
2159
2160 session_entry->limReassocChannelId =
2161 session_entry->pLimReAssocReq->bssDescription.channelId;
2162
2163 session_entry->reAssocHtSupportedChannelWidthSet =
2164 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2165 session_entry->reAssocHtRecommendedTxWidthSet =
2166 session_entry->reAssocHtSupportedChannelWidthSet;
2167 session_entry->reAssocHtSecondaryChannelOffset =
2168 session_entry->pLimReAssocReq->cbMode;
2169
2170 session_entry->limReassocBssCaps =
2171 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2172 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2173 session_entry->currentOperChannel);
2174 local_pwr_constraint = reg_max;
2175
2176 lim_extract_ap_capability(mac_ctx,
2177 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2178 lim_get_ielen_from_bss_description(
2179 &session_entry->pLimReAssocReq->bssDescription),
2180 &session_entry->limReassocBssQosCaps,
2181 &session_entry->limReassocBssPropCap,
2182 &session_entry->gLimCurrentBssUapsd,
2183 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302184 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002185 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302186 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002187 /* Copy the SSID from session entry to local variable */
2188 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302189 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002190 reassoc_req->ssId.ssId,
2191 session_entry->limReassocSSID.length);
2192 if (session_entry->gLimCurrentBssUapsd) {
2193 session_entry->gUapsdPerAcBitmask =
2194 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002195 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002196 session_entry->gUapsdPerAcBitmask);
2197 }
2198
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302199 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002200 if (NULL == mlm_reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002201 pe_err("call to AllocateMemory failed for mlmReassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002202
2203 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2204 goto end;
2205 }
2206
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302207 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002208 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2209
2210 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2211 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002212 eSIR_SUCCESS)
2213 pe_err("could not retrieve ReassocFailureTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002214
2215 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002216 eSIR_SUCCESS)
2217 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302218
2219 lim_update_caps_info_for_bss(mac_ctx, &caps,
2220 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002221 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302222
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002223 mlm_reassoc_req->capabilityInfo = caps;
2224
2225 /* Update PE session_id */
2226 mlm_reassoc_req->sessionId = session_id;
2227
2228 /*
2229 * If telescopic beaconing is enabled, set listen interval to
2230 * WNI_CFG_TELE_BCN_MAX_LI
2231 */
2232 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2233 &tele_bcn_en) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002234 pe_err("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002235
2236 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2237
2238 if (tele_bcn_en) {
2239 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2240 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002241 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002242 } else {
2243 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
2244 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002245 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002246 }
2247
2248 mlm_reassoc_req->listenInterval = (uint16_t) val;
2249
2250 /* Indicate whether spectrum management is enabled */
2251 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2252
2253 /* Enable the spectrum management if this is a DFS channel */
2254 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002255 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002256 session_entry->currentOperChannel))
2257 session_entry->spectrumMgtEnabled = true;
2258
2259 session_entry->limPrevSmeState = session_entry->limSmeState;
2260 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2261
2262 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2263 session_entry->peSessionId,
2264 session_entry->limSmeState));
2265
2266 lim_post_mlm_message(mac_ctx,
2267 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2268 return;
2269end:
2270 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302271 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002272 if (session_entry)
2273 session_entry->pLimReAssocReq = NULL;
2274 }
2275
2276 if (session_entry) {
2277 /*
2278 * error occurred after we determined the session so extract
2279 * session and transaction info from there
2280 */
2281 sme_session_id = session_entry->smeSessionId;
2282 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002283 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002284 /*
2285 * error occurred before or during the time we determined
2286 * the session so extract the session and transaction info
2287 * from the message
2288 */
2289 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2290 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002291 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002292 /*
2293 * Send Reassoc failure response to host
2294 * (note session_entry may be NULL, but that's OK)
2295 */
2296 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2297 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2298 session_entry, sme_session_id,
2299 transaction_id);
2300}
2301
2302bool send_disassoc_frame = 1;
2303/**
2304 * __lim_process_sme_disassoc_req()
2305 *
2306 ***FUNCTION:
2307 * This function is called to process SME_DISASSOC_REQ message
2308 * from HDD or upper layer application.
2309 *
2310 ***LOGIC:
2311 *
2312 ***ASSUMPTIONS:
2313 *
2314 ***NOTE:
2315 *
2316 * @param pMac Pointer to Global MAC structure
2317 * @param *pMsgBuf A pointer to the SME message buffer
2318 * @return None
2319 */
2320
2321static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2322{
2323 uint16_t disassocTrigger, reasonCode;
2324 tLimMlmDisassocReq *pMlmDisassocReq;
2325 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2326 tSirSmeDisassocReq smeDisassocReq;
2327 tpPESession psessionEntry = NULL;
2328 uint8_t sessionId;
2329 uint8_t smesessionId;
2330 uint16_t smetransactionId;
2331
2332 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002333 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002334 return;
2335 }
2336
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302337 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002338 smesessionId = smeDisassocReq.sessionId;
2339 smetransactionId = smeDisassocReq.transactionId;
2340 if (!lim_is_sme_disassoc_req_valid(pMac,
2341 &smeDisassocReq,
2342 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002343 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002344 if (pMac->lim.gLimRspReqd) {
2345 pMac->lim.gLimRspReqd = false;
2346
2347 retCode = eSIR_SME_INVALID_PARAMETERS;
2348 disassocTrigger = eLIM_HOST_DISASSOC;
2349 goto sendDisassoc;
2350 }
2351
2352 return;
2353 }
2354
2355 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002356 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002357 &sessionId);
2358 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002359 pe_err("session does not exist for given bssId "
2360 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002361 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002362 retCode = eSIR_SME_INVALID_PARAMETERS;
2363 disassocTrigger = eLIM_HOST_DISASSOC;
2364 goto sendDisassoc;
2365 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002366 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2367 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002368 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2369 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002370 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002371
2372#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2373 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2374 0, smeDisassocReq.reasonCode);
2375#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2376
2377 /* Update SME session Id and SME transaction ID */
2378
2379 psessionEntry->smeSessionId = smesessionId;
2380 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002381 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002382 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002383
2384 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2385 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002386 switch (psessionEntry->limSmeState) {
2387 case eLIM_SME_ASSOCIATED_STATE:
2388 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002389 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002390 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002391 psessionEntry->limPrevSmeState =
2392 psessionEntry->limSmeState;
2393 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002394 /* Delete all TDLS peers connected before leaving BSS */
2395 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002396 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2397 psessionEntry->peSessionId,
2398 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002399 break;
2400
2401 case eLIM_SME_WT_DEAUTH_STATE:
2402 /* PE shall still process the DISASSOC_REQ and proceed with
2403 * link tear down even if it had already sent a DEAUTH_IND to
2404 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2405 * its been set when PE entered WT_DEAUTH_STATE.
2406 */
2407 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2408 MTRACE(mac_trace
2409 (pMac, TRACE_CODE_SME_STATE,
2410 psessionEntry->peSessionId,
2411 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002412 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002413 break;
2414
2415 case eLIM_SME_WT_DISASSOC_STATE:
2416 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2417 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2418 * PE can continue processing DISASSOC_REQ and send the response instead
2419 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2420 * for disassoc frame.
2421 *
2422 * It will send a disassoc, which is ok. However, we can use the global flag
2423 * sendDisassoc to not send disassoc frame.
2424 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002425 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002426 break;
2427
2428 case eLIM_SME_JOIN_FAILURE_STATE: {
2429 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002430 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002431 if (pMac->lim.gLimRspReqd) {
2432 retCode = eSIR_SME_SUCCESS;
2433 disassocTrigger = eLIM_HOST_DISASSOC;
2434 goto sendDisassoc;
2435 }
2436 }
2437 break;
2438 default:
2439 /**
2440 * STA is not currently associated.
2441 * Log error and send response to host
2442 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002443 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002444 psessionEntry->limSmeState);
2445 lim_print_sme_state(pMac, LOGE,
2446 psessionEntry->limSmeState);
2447
2448 if (pMac->lim.gLimRspReqd) {
2449 if (psessionEntry->limSmeState !=
2450 eLIM_SME_WT_ASSOC_STATE)
2451 pMac->lim.gLimRspReqd = false;
2452
2453 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2454 disassocTrigger = eLIM_HOST_DISASSOC;
2455 goto sendDisassoc;
2456 }
2457
2458 return;
2459 }
2460
2461 break;
2462
2463 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002464 /* Fall through */
2465 break;
2466
2467 case eLIM_STA_IN_IBSS_ROLE:
2468 default:
2469 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002470 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002471 GET_LIM_SYSTEM_ROLE(psessionEntry));
2472
2473 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2474 disassocTrigger = eLIM_HOST_DISASSOC;
2475 goto sendDisassoc;
2476 } /* end switch (pMac->lim.gLimSystemRole) */
2477
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302478 disassocTrigger = eLIM_HOST_DISASSOC;
2479 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002480
2481 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002482 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002483 send_disassoc_frame = 0;
2484 }
2485 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002486 pe_debug("Sending Disasscoc with disassoc Trigger"
2487 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002488 disassocTrigger, reasonCode);
2489
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302490 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002491 if (NULL == pMlmDisassocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002492 pe_err("call to AllocateMemory failed for mlmDisassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002493 return;
2494 }
2495
Anurag Chouhanc5548422016-02-24 18:33:27 +05302496 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002497 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002498
2499 pMlmDisassocReq->reasonCode = reasonCode;
2500 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2501
2502 /* Update PE session ID */
2503 pMlmDisassocReq->sessionId = sessionId;
2504
2505 lim_post_mlm_message(pMac,
2506 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2507 return;
2508
2509sendDisassoc:
2510 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002511 lim_send_sme_disassoc_ntf(pMac,
2512 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002513 retCode,
2514 disassocTrigger,
2515 1, smesessionId, smetransactionId,
2516 psessionEntry);
2517 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002518 lim_send_sme_disassoc_ntf(pMac,
2519 smeDisassocReq.peer_macaddr.bytes,
2520 retCode, disassocTrigger, 1,
2521 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002522
2523} /*** end __lim_process_sme_disassoc_req() ***/
2524
2525/** -----------------------------------------------------------------
2526 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2527
2528 This function is called to process SME_DISASSOC_CNF message
2529 from HDD or upper layer application.
2530
2531 \param pMac - global mac structure
2532 \param pStaDs - station dph hash node
2533 \return none
2534 \sa
2535 ----------------------------------------------------------------- */
2536static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2537{
2538 tSirSmeDisassocCnf smeDisassocCnf;
2539 uint16_t aid;
2540 tpDphHashNode pStaDs;
2541 tpPESession psessionEntry;
2542 uint8_t sessionId;
2543
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302544 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002545 sizeof(struct sSirSmeDisassocCnf));
2546
2547 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002548 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002549 &sessionId);
2550 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002551 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002552 return;
2553 }
2554
2555 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002556 pe_err("received invalid SME_DISASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002557 return;
2558 }
2559#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2560 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2561 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2562 psessionEntry,
2563 (uint16_t) smeDisassocCnf.statusCode, 0);
2564 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2565 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2566 psessionEntry,
2567 (uint16_t) smeDisassocCnf.statusCode, 0);
2568#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2569
2570 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2571 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002572 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2573 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2574 && (psessionEntry->limSmeState !=
2575 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002576 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002577 psessionEntry->limSmeState);
2578 lim_print_sme_state(pMac, LOGE,
2579 psessionEntry->limSmeState);
2580 return;
2581 }
2582 break;
2583
2584 case eLIM_AP_ROLE:
2585 /* Fall through */
2586 break;
2587
2588 case eLIM_STA_IN_IBSS_ROLE:
2589 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002590 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002591 GET_LIM_SYSTEM_ROLE(psessionEntry));
2592
2593 return;
2594 }
2595
2596 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2597 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2598 LIM_IS_AP_ROLE(psessionEntry)) {
2599 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002600 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002601 &psessionEntry->dph.dphHashTable);
2602 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002603 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2604 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002605 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002606 return;
2607 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302608
2609 if ((pStaDs->mlmStaContext.mlmState ==
2610 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2611 (pStaDs->mlmStaContext.mlmState ==
2612 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002613 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002614 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302615 pStaDs->mlmStaContext.mlmState);
2616 return;
2617 }
2618
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002619 /* Delete FT session if there exists one */
2620 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002621 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2622
2623 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002624 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002625 }
2626
2627 return;
2628}
2629
2630/**
2631 * __lim_process_sme_deauth_req() - process sme deauth req
2632 * @mac_ctx: Pointer to Global MAC structure
2633 * @msg_buf: pointer to the SME message buffer
2634 *
2635 * This function is called to process SME_DEAUTH_REQ message
2636 * from HDD or upper layer application.
2637 *
2638 * Return: None
2639 */
2640
2641static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2642 uint32_t *msg_buf)
2643{
2644 uint16_t deauth_trigger, reason_code;
2645 tLimMlmDeauthReq *mlm_deauth_req;
2646 tSirSmeDeauthReq sme_deauth_req;
2647 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2648 tpPESession session_entry;
2649 uint8_t session_id; /* PE sessionId */
2650 uint8_t sme_session_id;
2651 uint16_t sme_transaction_id;
2652
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302653 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002654 sme_session_id = sme_deauth_req.sessionId;
2655 sme_transaction_id = sme_deauth_req.transactionId;
2656
2657 /*
2658 * We need to get a session first but we don't even know
2659 * if the message is correct.
2660 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002661 session_entry = pe_find_session_by_bssid(mac_ctx,
2662 sme_deauth_req.bssid.bytes,
2663 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002664 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002665 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002666 ret_code = eSIR_SME_INVALID_PARAMETERS;
2667 deauth_trigger = eLIM_HOST_DEAUTH;
2668 goto send_deauth;
2669 }
2670
2671 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2672 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002673 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002674 mac_ctx->lim.gLimRspReqd = false;
2675
2676 ret_code = eSIR_SME_INVALID_PARAMETERS;
2677 deauth_trigger = eLIM_HOST_DEAUTH;
2678 goto send_deauth;
2679 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002680 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2681 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002682 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2683 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002684 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002685#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2686 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2687 session_entry, 0, sme_deauth_req.reasonCode);
2688#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2689
2690 /* Update SME session ID and Transaction ID */
2691 session_entry->smeSessionId = sme_session_id;
2692 session_entry->transactionId = sme_transaction_id;
2693
2694 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2695 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002696 switch (session_entry->limSmeState) {
2697 case eLIM_SME_ASSOCIATED_STATE:
2698 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302699 /* Delete all TDLS peers connected before leaving BSS */
2700 lim_delete_tdls_peers(mac_ctx, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002701 case eLIM_SME_WT_ASSOC_STATE:
2702 case eLIM_SME_JOIN_FAILURE_STATE:
2703 case eLIM_SME_IDLE_STATE:
2704 session_entry->limPrevSmeState =
2705 session_entry->limSmeState;
2706 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2707 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2708 session_entry->peSessionId,
2709 session_entry->limSmeState));
2710 /* Send Deauthentication request to MLM below */
2711 break;
2712 case eLIM_SME_WT_DEAUTH_STATE:
2713 case eLIM_SME_WT_DISASSOC_STATE:
2714 /*
2715 * PE Recieved a Deauth/Disassoc frame. Normally it get
2716 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2717 * Which means host is also trying to disconnect.
2718 * PE can continue processing DEAUTH_REQ and send
2719 * the response instead of failing the request.
2720 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2721 * was sent for deauth/disassoc frame.
2722 */
2723 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002724 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002725 break;
2726 default:
2727 /*
2728 * STA is not in a state to deauthenticate with
2729 * peer. Log error and send response to host.
2730 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002731 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002732 session_entry->limSmeState);
2733 lim_print_sme_state(mac_ctx, LOGE,
2734 session_entry->limSmeState);
2735
2736 if (mac_ctx->lim.gLimRspReqd) {
2737 mac_ctx->lim.gLimRspReqd = false;
2738
2739 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2740 deauth_trigger = eLIM_HOST_DEAUTH;
2741
wadesong42968e92017-06-08 14:11:21 +08002742 /*
2743 * here we received deauth request from AP so
2744 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2745 * have ISSUED delSta then mlm state should be
2746 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2747 * delBSS rsp then mlm state should be
2748 * eLIM_MLM_IDLE_STATE so the below condition
2749 * captures the state where delSta not done
2750 * and firmware still in connected state.
2751 */
2752 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002753 eLIM_SME_WT_DEAUTH_STATE &&
2754 session_entry->limMlmState !=
2755 eLIM_MLM_IDLE_STATE &&
2756 session_entry->limMlmState !=
2757 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002758 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002759 goto send_deauth;
2760 }
2761 return;
2762 }
2763 break;
2764
2765 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002766 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002767 if (mac_ctx->lim.gLimRspReqd) {
2768 mac_ctx->lim.gLimRspReqd = false;
2769 ret_code = eSIR_SME_INVALID_PARAMETERS;
2770 deauth_trigger = eLIM_HOST_DEAUTH;
2771 goto send_deauth;
2772 }
2773 return;
2774 case eLIM_AP_ROLE:
2775 break;
2776 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002777 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002778 GET_LIM_SYSTEM_ROLE(session_entry));
2779 if (mac_ctx->lim.gLimRspReqd) {
2780 mac_ctx->lim.gLimRspReqd = false;
2781 ret_code = eSIR_SME_INVALID_PARAMETERS;
2782 deauth_trigger = eLIM_HOST_DEAUTH;
2783 goto send_deauth;
2784 }
2785 return;
2786 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2787
2788 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2789 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002790 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002791 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2792 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2793 } else {
2794 deauth_trigger = eLIM_HOST_DEAUTH;
2795 reason_code = sme_deauth_req.reasonCode;
2796 }
2797
2798 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302799 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002800 if (NULL == mlm_deauth_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002801 pe_err("call to AllocateMemory failed for mlmDeauthReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002802 if (mac_ctx->lim.gLimRspReqd) {
2803 mac_ctx->lim.gLimRspReqd = false;
2804 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2805 deauth_trigger = eLIM_HOST_DEAUTH;
2806 goto send_deauth;
2807 }
2808 return;
2809 }
2810
Anurag Chouhanc5548422016-02-24 18:33:27 +05302811 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002812 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002813
2814 mlm_deauth_req->reasonCode = reason_code;
2815 mlm_deauth_req->deauthTrigger = deauth_trigger;
2816
2817 /* Update PE session Id */
2818 mlm_deauth_req->sessionId = session_id;
2819
2820 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2821 (uint32_t *)mlm_deauth_req);
2822 return;
2823
2824send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002825 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2826 ret_code, deauth_trigger, 1,
2827 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002828}
2829
2830/**
2831 * __lim_process_sme_set_context_req()
2832 *
2833 * @mac_ctx: Pointer to Global MAC structure
2834 * @msg_buf: pointer to the SME message buffer
2835 *
2836 * This function is called to process SME_SETCONTEXT_REQ message
2837 * from HDD or upper layer application.
2838 *
2839 * Return: None
2840 */
2841
2842static void
2843__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2844{
2845 tpSirSmeSetContextReq set_context_req;
2846 tLimMlmSetKeysReq *mlm_set_key_req;
2847 tpPESession session_entry;
2848 uint8_t session_id; /* PE sessionID */
2849 uint8_t sme_session_id;
2850 uint16_t sme_transaction_id;
2851
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002852 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002853 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002854 return;
2855 }
2856
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302857 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002858 if (NULL == set_context_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002859 pe_err("call to AllocateMemory failed for set_context_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002860 return;
2861 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302862 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002863 sizeof(struct sSirSmeSetContextReq));
2864 sme_session_id = set_context_req->sessionId;
2865 sme_transaction_id = set_context_req->transactionId;
2866
2867 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002868 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002869 goto end;
2870 }
2871
2872 if (set_context_req->keyMaterial.numKeys >
2873 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002874 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002875 set_context_req->keyMaterial.numKeys);
2876 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002877 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002878 eSIR_SME_INVALID_PARAMETERS, NULL,
2879 sme_session_id, sme_transaction_id);
2880 goto end;
2881 }
2882
2883 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002884 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002885 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002886 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002887 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002888 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002889 eSIR_SME_INVALID_PARAMETERS, NULL,
2890 sme_session_id, sme_transaction_id);
2891 goto end;
2892 }
2893#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2894 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2895 session_entry, 0, 0);
2896#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2897
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002898 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002899 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2900 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002901 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002902 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2903 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302904 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002905 if (NULL == mlm_set_key_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002906 pe_err("mem alloc failed for mlmSetKeysReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002907 goto end;
2908 }
2909 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2910 mlm_set_key_req->numKeys =
2911 set_context_req->keyMaterial.numKeys;
2912 if (mlm_set_key_req->numKeys >
2913 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002914 pe_err("no.of keys exceeded max num of default keys limit");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002915 goto end;
2916 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302917 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002918 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002919
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302920 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002921 (uint8_t *) &set_context_req->keyMaterial.key,
2922 sizeof(tSirKeys) *
2923 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2924 numKeys : 1));
2925
2926 mlm_set_key_req->sessionId = session_id;
2927 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002928 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002929 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002930
2931 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2932 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2933 LIM_IS_AP_ROLE(session_entry)) {
2934 if (set_context_req->keyMaterial.key[0].keyLength) {
2935 uint8_t key_id;
2936 key_id =
2937 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302938 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002939 &session_entry->WEPKeyMaterial[key_id],
2940 (uint8_t *) &set_context_req->keyMaterial,
2941 sizeof(tSirKeyMaterial));
2942 } else {
2943 uint32_t i;
2944 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2945 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302946 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002947 &mlm_set_key_req->key[i],
2948 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2949 sizeof(tSirKeys));
2950 }
2951 }
2952 }
2953 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2954 (uint32_t *) mlm_set_key_req);
2955 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002956 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002957 GET_LIM_SYSTEM_ROLE(session_entry),
2958 session_entry->limSmeState);
2959 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2960
2961 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002962 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002963 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2964 session_entry, sme_session_id,
2965 sme_transaction_id);
2966 }
2967end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302968 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002969 return;
2970}
2971
2972/**
2973 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2974 *
2975 * @mac_ctx: Pointer to Global MAC structure
2976 * @msg_buf: pointer to the SME message buffer
2977 *
2978 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2979 * from HDD or upper layer application.
2980 *
2981 * Return: None
2982 */
2983
Jeff Johnson801f1532016-10-07 07:54:50 -07002984static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
2985 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002986{
2987 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
2988 tpDphHashNode sta_ds = NULL;
2989 tpPESession session_entry = NULL;
2990 tSap_Event sap_event;
2991 tpWLAN_SAPEventCB sap_event_cb = NULL;
2992 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
2993 uint8_t session_id = CSR_SESSION_ID_INVALID;
2994 uint8_t assoc_id = 0;
2995 uint8_t sta_cnt = 0;
2996
2997 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002998 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002999 return;
3000 }
3001
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303002 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003003 sizeof(struct sSirSmeGetAssocSTAsReq));
3004 /*
3005 * Get Associated stations from PE.
3006 * Find PE session Entry
3007 */
3008 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003009 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003010 &session_id);
3011 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003012 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003013 goto lim_assoc_sta_end;
3014 }
3015
3016 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003017 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003018 session_entry->limSmeState,
3019 GET_LIM_SYSTEM_ROLE(session_entry));
3020 goto lim_assoc_sta_end;
3021 }
3022 /* Retrieve values obtained in the request message */
3023 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3024 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3025
3026 if (NULL == assoc_sta_tmp)
3027 goto lim_assoc_sta_end;
3028 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3029 assoc_id++) {
3030 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3031 &session_entry->dph.dphHashTable);
3032 if (NULL == sta_ds)
3033 continue;
3034 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303035 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003036 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303037 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003038 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3039 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3040
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303041 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003042 (uint8_t *)&sta_ds->supportedRates,
3043 sizeof(tSirSupportedRates));
3044 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3045 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3046 assoc_sta_tmp->Support40Mhz =
3047 sta_ds->htDsssCckRate40MHzSupport;
3048
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003049 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003050 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003051 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003052 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003053 pe_debug("Association Id: %d Station Index: %d",
3054 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003055 assoc_sta_tmp++;
3056 sta_cnt++;
3057 }
3058 }
3059lim_assoc_sta_end:
3060 /*
3061 * Call hdd callback with sap event to send the list of
3062 * associated stations from PE
3063 */
3064 if (sap_event_cb != NULL) {
3065 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3066 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303067 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003068 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3069 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3070 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3071 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3072 }
3073}
3074
3075/**
3076 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3077 *
3078 * @mac_ctx: Pointer to Global MAC structure
3079 * @msg_buf: pointer to WPS PBC overlap query message
3080 *
3081 * This function parses get WPS PBC overlap information
3082 * message and call callback to pass WPS PBC overlap
3083 * information back to hdd.
3084 *
3085 * Return: None
3086 */
Jeff Johnson801f1532016-10-07 07:54:50 -07003087static void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3088 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003089{
3090 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3091 tpPESession session_entry = NULL;
3092 tSap_Event sap_event;
3093 tpWLAN_SAPEventCB sap_event_cb = NULL;
3094 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003095 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3096
3097 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003098 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003099 return;
3100 }
3101
3102 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303103 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003104
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303105 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003106 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3107 /*
3108 * Get Associated stations from PE
3109 * Find PE session Entry
3110 */
3111 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003112 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003113 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003114 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003115 goto lim_get_wpspbc_sessions_end;
3116 }
3117
3118 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003119 pe_err("Received unexpected message in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003120 GET_LIM_SYSTEM_ROLE(session_entry));
3121 goto lim_get_wpspbc_sessions_end;
3122 }
3123 /*
3124 * Call hdd callback with sap event to send the
3125 * WPS PBC overlap information
3126 */
3127 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303128 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003129
Anurag Chouhanc5548422016-02-24 18:33:27 +05303130 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003131 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003132 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003133 sap_get_wpspbc_event->UUID_E,
3134 &sap_get_wpspbc_event->wpsPBCOverlap,
3135 session_entry);
3136 } else {
3137 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003138 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003139 session_entry);
3140 /* don't have to inform the HDD/Host */
3141 return;
3142 }
3143
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003144 pe_debug("wpsPBCOverlap %d", sap_get_wpspbc_event->wpsPBCOverlap);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003145 lim_print_mac_addr(mac_ctx,
3146 sap_get_wpspbc_event->addr.bytes, LOG4);
3147
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303148 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003149
3150lim_get_wpspbc_sessions_end:
3151 sap_event_cb =
3152 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3153 if (NULL != sap_event_cb)
3154 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3155}
3156
3157/**
3158 * __lim_counter_measures()
3159 *
3160 * FUNCTION:
3161 * This function is called to "implement" MIC counter measure
3162 * and is *temporary* only
3163 *
3164 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3165 * we don't do the proper STA disassoc sequence since the
3166 * BSS will be stoped anyway
3167 *
3168 ***ASSUMPTIONS:
3169 *
3170 ***NOTE:
3171 *
3172 * @param pMac Pointer to Global MAC structure
3173 * @return None
3174 */
3175
3176static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3177{
3178 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003179 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003180 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3181 mac, psessionEntry, false);
3182};
3183
Jeff Johnson801f1532016-10-07 07:54:50 -07003184static void lim_process_tkip_counter_measures(tpAniSirGlobal pMac,
3185 uint32_t *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003186{
3187 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3188 tpPESession psessionEntry;
3189 uint8_t sessionId; /* PE sessionId */
3190
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303191 qdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003192 sizeof(struct sSirSmeTkipCntrMeasReq));
3193
3194 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003195 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003196 if (NULL == psessionEntry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003197 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003198 return;
3199 }
3200
3201 if (tkipCntrMeasReq.bEnable)
3202 __lim_counter_measures(pMac, psessionEntry);
3203
3204 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3205}
3206
3207static void
3208__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3209{
3210 tSirSmeStopBssReq stopBssReq;
3211 tSirRetStatus status;
3212 tLimSmeStates prevState;
3213 tpPESession psessionEntry;
3214 uint8_t smesessionId;
3215 uint8_t sessionId;
3216 uint16_t smetransactionId;
3217 uint8_t i = 0;
3218 tpDphHashNode pStaDs = NULL;
3219
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303220 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003221 smesessionId = stopBssReq.sessionId;
3222 smetransactionId = stopBssReq.transactionId;
3223
3224 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003225 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003226 /* Send Stop BSS response to host */
3227 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3228 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3229 smetransactionId);
3230 return;
3231 }
3232
3233 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003234 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003235 &sessionId);
3236 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003237 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003238 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3239 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3240 smetransactionId);
3241 return;
3242 }
3243#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3244 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3245 0, 0);
3246#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3247
3248 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3249 LIM_IS_STA_ROLE(psessionEntry)) {
3250 /**
3251 * Should not have received STOP_BSS_REQ in states
3252 * other than 'normal' state or on STA in Infrastructure
3253 * mode. Log error and return response to host.
3254 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003255 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003256 psessionEntry->limSmeState,
3257 GET_LIM_SYSTEM_ROLE(psessionEntry));
3258 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3259 /* / Send Stop BSS response to host */
3260 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3261 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3262 smetransactionId);
3263 return;
3264 }
3265
3266 if (LIM_IS_AP_ROLE(psessionEntry))
3267 lim_wpspbc_close(pMac, psessionEntry);
3268
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003269 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003270 stopBssReq.reasonCode);
3271
3272 prevState = psessionEntry->limSmeState;
3273
3274 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3275 MTRACE(mac_trace
3276 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3277 psessionEntry->limSmeState));
3278
3279 /* Update SME session Id and Transaction Id */
3280 psessionEntry->smeSessionId = smesessionId;
3281 psessionEntry->transactionId = smetransactionId;
3282
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003283 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3284 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3285 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003286 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3287 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3288 /* Send disassoc all stations associated thru TKIP */
3289 __lim_counter_measures(pMac, psessionEntry);
3290 else
3291 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003292 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3293 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003294 }
3295
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003296 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3297 /* Free the buffer allocated in START_BSS_REQ */
3298 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3299 psessionEntry->addIeParams.probeRespDataLen = 0;
3300 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003301
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003302 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3303 psessionEntry->addIeParams.assocRespDataLen = 0;
3304 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003305
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003306 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3307 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3308 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003309
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003310 /*
3311 * lim_del_bss is also called as part of coalescing,
3312 * when we send DEL BSS followed by Add Bss msg.
3313 */
3314 pMac->lim.gLimIbssCoalescingHappened = false;
3315 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003316 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3317 pStaDs =
3318 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3319 if (NULL == pStaDs)
3320 continue;
3321 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3322 if (eSIR_SUCCESS == status) {
3323 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3324 pStaDs->assocId, psessionEntry);
3325 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3326 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003327 pe_err("lim_del_sta failed with Status: %d", status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303328 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003329 }
3330 }
3331 /* send a delBss to HAL and wait for a response */
3332 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3333
3334 if (status != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003335 pe_err("delBss failed for bss %d", psessionEntry->bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003336 psessionEntry->limSmeState = prevState;
3337
3338 MTRACE(mac_trace
3339 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3340 psessionEntry->limSmeState));
3341
3342 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3343 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3344 smetransactionId);
3345 }
3346}
3347
3348/**
3349 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3350 * @pMac: Global MAC context
3351 * @pMsg: Message from SME
3352 *
3353 * Wrapper for the function __lim_handle_sme_stop_bss_request
3354 * This message will be defered until softmac come out of
3355 * scan mode. Message should be handled even if we have
3356 * detected radar in the current operating channel.
3357 *
3358 * Return: true - If we consumed the buffer
3359 * false - If have defered the message.
3360 */
3361
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003362static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3363 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003364{
3365 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3366 /**
3367 * If message defered, buffer is not consumed yet.
3368 * So return false
3369 */
3370 return false;
3371 }
3372 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3373 return true;
3374} /*** end __lim_process_sme_stop_bss_req() ***/
3375
3376void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3377 uint32_t body, tpPESession psessionEntry)
3378{
3379
3380 (void)body;
3381 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3382 lim_ibss_delete(pMac, psessionEntry);
3383 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3384 lim_delete_pre_auth_list(pMac);
3385 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3386 psessionEntry->smeSessionId,
3387 psessionEntry->transactionId);
3388 return;
3389}
3390
3391/**
3392 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3393 *
3394 * @mac_ctx: pointer to mac context
3395 * @msg_type: message type
3396 * @msg_buf: pointer to the SME message buffer
3397 *
3398 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3399 * in BTAMP AP.
3400 *
3401 * Return: None
3402 */
3403
3404void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3405 uint32_t *msg_buf)
3406{
3407 tSirSmeAssocCnf assoc_cnf;
3408 tpDphHashNode sta_ds = NULL;
3409 tpPESession session_entry = NULL;
3410 uint8_t session_id;
3411 tpSirAssocReq assoc_req;
3412
3413 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003414 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003415 goto end;
3416 }
3417
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303418 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003419 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003420 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003421 goto end;
3422 }
3423
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003424 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003425 &session_id);
3426 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003427 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003428 goto end;
3429 }
3430
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003431 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003432 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3433 (session_entry->limSmeState !=
3434 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003435 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003436 msg_type, session_entry->limSmeState,
3437 GET_LIM_SYSTEM_ROLE(session_entry));
3438 goto end;
3439 }
3440 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3441 &session_entry->dph.dphHashTable);
3442 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003443 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003444 msg_type, assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003445 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003446
3447 /*
3448 * send a DISASSOC_IND message to WSM to make sure
3449 * the state in WSM and LIM is the same
3450 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003451 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003452 eSIR_SME_STA_NOT_ASSOCIATED,
3453 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3454 session_entry->smeSessionId,
3455 session_entry->transactionId,
3456 session_entry);
3457 goto end;
3458 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303459 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003460 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303461 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003462 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003463 assoc_cnf.aid);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003464 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003465 goto end;
3466 }
3467
3468 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3469 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3470 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3471 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3472 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003473 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3474 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003475 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003476 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOG1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003477 goto end;
3478 }
3479 /*
3480 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3481 * has been received
3482 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003483 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003484 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3485 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3486
3487 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3488 /*
3489 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3490 * when it had received Assoc Request frame. Now, PE just needs
3491 * to send association rsp frame to the requesting BTAMP-STA.
3492 */
3493 sta_ds->mlmStaContext.mlmState =
3494 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003495 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003496 sta_ds->assocId);
3497 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3498 sta_ds->assocId, sta_ds->staAddr,
3499 sta_ds->mlmStaContext.subType, sta_ds,
3500 session_entry);
3501 goto end;
3502 } else {
3503 /*
3504 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3505 * to be associated since the HAL sta entry is created for
3506 * denied STA we need to remove this HAL entry.
3507 * So to do that set updateContext to 1
3508 */
3509 if (!sta_ds->mlmStaContext.updateContext)
3510 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003511 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003512 assoc_cnf.statusCode, sta_ds->assocId);
3513 lim_reject_association(mac_ctx, sta_ds->staAddr,
3514 sta_ds->mlmStaContext.subType,
3515 true, sta_ds->mlmStaContext.authType,
3516 sta_ds->assocId, true,
Varun Reddy Yeturu8c68b472017-06-15 16:05:38 -07003517 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003518 session_entry);
3519 }
3520end:
3521 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3522 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3523 assoc_req = (tpSirAssocReq)
3524 session_entry->parsedAssocReq[sta_ds->assocId];
3525 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303526 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003527 assoc_req->assocReqFrame = NULL;
3528 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303529 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003530 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3531 }
3532}
3533
3534static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3535{
3536 tpDphHashNode pStaDs;
3537 tSirMacAddr peerMac;
3538 tpSirAddtsReq pSirAddts;
3539 uint32_t timeout;
3540 tpPESession psessionEntry;
3541 uint8_t sessionId; /* PE sessionId */
3542 uint8_t smesessionId;
3543 uint16_t smetransactionId;
3544
3545 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003546 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003547 return;
3548 }
3549
3550 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3551 &smetransactionId);
3552
3553 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3554
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003555 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3556 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003557 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003558 pe_err("Session Does not exist for given bssId");
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303559 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3560 NULL, pSirAddts->req.tspec,
3561 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003562 return;
3563 }
3564#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3565 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3566 0);
3567#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3568
3569 /* if sta
3570 * - verify assoc state
3571 * - send addts request to ap
3572 * - wait for addts response from ap
3573 * if ap, just ignore with error log
3574 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003575 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3576 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3577 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003578
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003579 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003580 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303581 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003582 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003583
3584 pStaDs =
3585 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3586 &psessionEntry->dph.dphHashTable);
3587
3588 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003589 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303590 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003591 }
3592
3593 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3594 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003595 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303596 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003597 }
3598
3599 pSirAddts->req.wsmTspecPresent = 0;
3600 pSirAddts->req.wmeTspecPresent = 0;
3601 pSirAddts->req.lleTspecPresent = 0;
3602
3603 if ((pStaDs->wsmEnabled) &&
3604 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3605 SIR_MAC_ACCESSPOLICY_EDCA))
3606 pSirAddts->req.wsmTspecPresent = 1;
3607 else if (pStaDs->wmeEnabled)
3608 pSirAddts->req.wmeTspecPresent = 1;
3609 else if (pStaDs->lleEnabled)
3610 pSirAddts->req.lleTspecPresent = 1;
3611 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003612 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303613 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003614 }
3615
3616 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3617 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003618 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003619 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303620 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003621 }
3622
3623 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003624 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003625 pMac->lim.gLimAddtsReq.req.dialogToken,
3626 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3627 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3628 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303629 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003630 }
3631
3632 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3633
3634 /* save the addts request */
3635 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303636 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003637 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3638
3639 /* ship out the message now */
3640 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3641 psessionEntry);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003642 pe_debug("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003643 /* start a timer to wait for the response */
3644 if (pSirAddts->timeout)
3645 timeout = pSirAddts->timeout;
3646 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3647 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003648 pe_err("Unable to get Cfg param %d (Addts Rsp Timeout)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003649 WNI_CFG_ADDTS_RSP_TIMEOUT);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303650 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003651 }
3652
3653 timeout = SYS_MS_TO_TICKS(timeout);
3654 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3655 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003656 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303657 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003658 }
3659 pMac->lim.gLimAddtsRspTimerCount++;
3660 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3661 pMac->lim.gLimAddtsRspTimerCount) !=
3662 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003663 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303664 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003665 }
3666 MTRACE(mac_trace
3667 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3668 eLIM_ADDTS_RSP_TIMER));
3669
3670 /* add the sessionId to the timer object */
3671 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3672 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3673 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003674 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303675 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003676 }
3677 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303678
3679send_failure_addts_rsp:
3680 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3681 psessionEntry, pSirAddts->req.tspec,
3682 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003683}
3684
3685static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3686{
3687 tSirMacAddr peerMacAddr;
3688 uint8_t ac;
3689 tSirMacTSInfo *pTsinfo;
3690 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3691 tpDphHashNode pStaDs = NULL;
3692 tpPESession psessionEntry;
3693 uint8_t sessionId;
3694 uint32_t status = eSIR_SUCCESS;
3695 uint8_t smesessionId;
3696 uint16_t smetransactionId;
3697
3698 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3699 &smetransactionId);
3700
3701 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003702 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003703 &sessionId);
3704 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003705 pe_err("Session Does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003706 status = eSIR_FAILURE;
3707 goto end;
3708 }
3709#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3710 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3711 0);
3712#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3713
3714 if (eSIR_SUCCESS !=
3715 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003716 pe_err("lim_validate_delts_req failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003717 status = eSIR_FAILURE;
3718 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3719 smesessionId, smetransactionId);
3720 return;
3721 }
3722
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003723 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3724 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003725 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3726
3727 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3728 pDeltsReq->req.wmeTspecPresent,
3729 &pDeltsReq->req.tsinfo,
3730 &pDeltsReq->req.tspec, psessionEntry);
3731
3732 pTsinfo =
3733 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3734 tsinfo : &pDeltsReq->req.tsinfo;
3735
3736 /* We've successfully send DELTS frame to AP. Update the
3737 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3738 * is no longer trigger enabled or delivery enabled
3739 */
3740 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3741 pTsinfo, CLEAR_UAPSD_MASK);
3742
3743 /* We're deleting the TSPEC, so this particular AC is no longer
3744 * admitted. PE needs to downgrade the EDCA
3745 * parameters(for the AC for which TS is being deleted) to the
3746 * next best AC for which ACM is not enabled, and send the
3747 * updated values to HAL.
3748 */
3749 ac = upToAc(pTsinfo->traffic.userPrio);
3750
3751 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3752 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3753 ~(1 << ac);
3754 } else if (pTsinfo->traffic.direction ==
3755 SIR_MAC_DIRECTION_DNLINK) {
3756 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3757 ~(1 << ac);
3758 } else if (pTsinfo->traffic.direction ==
3759 SIR_MAC_DIRECTION_BIDIR) {
3760 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3761 ~(1 << ac);
3762 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3763 ~(1 << ac);
3764 }
3765
3766 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3767 psessionEntry);
3768
3769 pStaDs =
3770 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3771 &psessionEntry->dph.dphHashTable);
3772 if (pStaDs != NULL) {
3773 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3774 pStaDs->bssId);
3775 status = eSIR_SUCCESS;
3776 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003777 pe_err("Self entry missing in Hash Table");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003778 status = eSIR_FAILURE;
3779 }
3780#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003781 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003782#endif
3783
3784 /* send an sme response back */
3785end:
3786 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3787 smesessionId, smetransactionId);
3788}
3789
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303790void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003791{
3792 /* fetch the sessionEntry based on the sessionId */
3793 tpPESession psessionEntry;
3794 psessionEntry = pe_find_session_by_session_id(pMac,
3795 pMac->lim.limTimers.gLimAddtsRspTimer.
3796 sessionId);
3797 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003798 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003799 return;
3800 }
3801
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003802 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003803 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003804 GET_LIM_SYSTEM_ROLE(psessionEntry));
3805 pMac->lim.gLimAddtsSent = false;
3806 return;
3807 }
3808
3809 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003810 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003811 return;
3812 }
3813
3814 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003815 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003816 pMac->lim.gLimAddtsRspTimerCount);
3817 return;
3818 }
3819 /* this a real response timeout */
3820 pMac->lim.gLimAddtsSent = false;
3821 pMac->lim.gLimAddtsRspTimerCount++;
3822
3823 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3824 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3825 psessionEntry->smeSessionId,
3826 psessionEntry->transactionId);
3827}
3828
3829/**
3830 * __lim_process_sme_get_statistics_request()
3831 *
3832 ***FUNCTION:
3833 *
3834 *
3835 ***NOTE:
3836 *
3837 * @param pMac Pointer to Global MAC structure
3838 * @param *pMsgBuf A pointer to the SME message buffer
3839 * @return None
3840 */
3841static void
3842__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3843{
3844 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003845 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003846
3847 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3848
3849 msgQ.type = WMA_GET_STATISTICS_REQ;
3850
3851 msgQ.reserved = 0;
3852 msgQ.bodyptr = pMsgBuf;
3853 msgQ.bodyval = 0;
3854 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3855
3856 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303857 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003858 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003859 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003860 return;
3861 }
3862
3863 return;
3864}
3865
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003866#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003867/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003868 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003869 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003870 * @pMac: Pointer to Global MAC structure
3871 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003872 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003873 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003874 */
3875static void
3876__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3877{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003878 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003879
3880 msgQ.type = WMA_TSM_STATS_REQ;
3881 msgQ.reserved = 0;
3882 msgQ.bodyptr = pMsgBuf;
3883 msgQ.bodyval = 0;
3884 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3885
3886 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303887 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003888 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003889 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003890 return;
3891 }
3892}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003893#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003894
3895static void
3896__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3897{
3898 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
3899 tpPESession psessionEntry;
3900 uint8_t sessionId; /* PE sessionID */
3901
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003902 pe_debug("received UPDATE_APWPSIEs_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003903
3904 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003905 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003906 return;
3907 }
3908
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303909 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003910 if (NULL == pUpdateAPWPSIEsReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003911 pe_err("call to AllocateMemory failed for pUpdateAPWPSIEsReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003912 return;
3913 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303914 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003915 sizeof(struct sSirUpdateAPWPSIEsReq));
3916
3917 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08003918 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003919 &sessionId);
3920 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003921 pe_warn("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003922 goto end;
3923 }
3924
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303925 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003926 sizeof(tSirAPWPSIEs));
3927
3928 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3929 lim_send_beacon_ind(pMac, psessionEntry);
3930
3931end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303932 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003933 return;
3934}
3935
Naveen Rawat8029a402017-06-01 10:54:19 -07003936static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3937 struct update_config *msg)
3938{
3939 tpPESession pe_session;
3940
3941 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3942 if (msg == NULL) {
3943 pe_err("Buffer is Pointing to NULL");
3944 return;
3945 }
3946
3947 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3948 msg->sme_session_id);
3949 if (pe_session == NULL) {
3950 pe_warn("Session does not exist for given BSSID");
3951 return;
3952 }
3953
3954 switch (msg->capab) {
3955 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3956 pe_session->htConfig.ht_rx_ldpc = msg->value;
3957 break;
3958 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3959 pe_session->htConfig.ht_tx_stbc = msg->value;
3960 break;
3961 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3962 pe_session->htConfig.ht_rx_stbc = msg->value;
3963 break;
3964 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3965 pe_session->htConfig.ht_sgi20 = msg->value;
3966 break;
3967 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3968 pe_session->htConfig.ht_sgi40 = msg->value;
3969 break;
3970 }
3971
3972 if (LIM_IS_AP_ROLE(pe_session)) {
3973 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
3974 lim_send_beacon_ind(mac_ctx, pe_session);
3975 }
3976}
3977
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003978void
3979lim_send_vdev_restart(tpAniSirGlobal pMac,
3980 tpPESession psessionEntry, uint8_t sessionId)
3981{
3982 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003983 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003984 tSirRetStatus retCode = eSIR_SUCCESS;
3985
3986 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003987 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003988 return;
3989 }
3990
3991 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303992 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003993 if (NULL == pHalHiddenSsidVdevRestart) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003994 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003995 return;
3996 }
3997
3998 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
3999 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07004000 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004001
4002 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4003 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4004 msgQ.bodyval = 0;
4005
4006 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4007 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004008 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304009 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004010 }
4011}
4012
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304013/**
4014 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
4015 * @mac_ctx: Pointer to Global MAC structure
4016 * @msg_buf: Pointer to SME message buffer
4017 *
4018 * Return: None
4019 */
4020static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
4021 uint32_t *msg_buf)
4022{
4023 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004024 struct scheduler_msg wma_msg = {0};
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304025 tSirRetStatus status;
4026 tSirRoamOffloadScanReq *req_buffer;
4027 uint16_t local_ie_len;
4028 uint8_t *local_ie_buf;
4029
4030 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
4031 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
4032 req_buffer->sessionId);
4033
4034 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
4035 if (!local_ie_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004036 pe_err("Mem Alloc failed for local_ie_buf");
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05304037 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304038 return;
4039 }
4040
4041 local_ie_len = req_buffer->assoc_ie.length;
4042 /* Update ext cap IE if present */
4043 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07004044 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
4045 local_ie_buf, &local_ie_len)) {
4046 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07004047 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
4048 req_buffer->assoc_ie.length = local_ie_len;
4049 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
4050 local_ie_buf, local_ie_len);
4051 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304052 }
4053 qdf_mem_free(local_ie_buf);
4054
4055 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
4056 wma_msg.bodyptr = req_buffer;
4057
4058 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
4059 if (eSIR_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004060 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304061 qdf_mem_free(req_buffer);
4062 }
4063}
4064
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304065/*
4066 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
4067 * @mac_ctx: Pointer to global mac context
4068 * @session: Pointer to PE session
4069 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
4070 * 1 - Disable broadcast SSID
4071 *
4072 * Return: None
4073 */
4074static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
4075 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004076{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07004077 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004078 session->ssidHidden, ssid_hidden);
4079
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07004080 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304081 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07004082 } else {
4083 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05304084 return;
4085 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004086
4087 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304088 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004089
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004090 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304091}
4092
4093/**
4094 * __lim_process_sme_session_update - process SME session update msg
4095 *
4096 * @mac_ctx: Pointer to global mac context
4097 * @msg_buf: Pointer to the received message buffer
4098 *
4099 * Return: None
4100 */
4101static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
4102 uint32_t *msg_buf)
4103{
4104 struct sir_update_session_param *msg;
4105 tpPESession session;
4106
4107 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004108 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304109 return;
4110 }
4111
4112 msg = (struct sir_update_session_param *) msg_buf;
4113
4114 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
4115 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004116 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304117 msg->session_id);
4118 return;
4119 }
4120
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004121 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304122 msg->param_type, msg->param_val);
4123 switch (msg->param_type) {
4124 case SIR_PARAM_SSID_HIDDEN:
4125 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
4126 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05304127 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
4128 session->ignore_assoc_disallowed = msg->param_val;
4129 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304130 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004131 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304132 break;
4133 }
4134}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004135
4136static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4137{
4138 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4139 tpPESession psessionEntry;
4140 uint8_t sessionId; /* PE sessionID */
4141
4142 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004143 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004144 return;
4145 }
4146
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304147 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004148 if (NULL == pUpdateAPWPARSNIEsReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004149 pe_err("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004150 return;
4151 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304152 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004153 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4154
4155 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004156 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004157 &sessionId);
4158 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004159 pe_warn("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004160 goto end;
4161 }
4162
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304163 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004164 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4165
4166 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4167 &psessionEntry->
4168 pLimStartBssReq->rsnIE,
4169 psessionEntry);
4170
4171 psessionEntry->pLimStartBssReq->privacy = 1;
4172 psessionEntry->privacy = 1;
4173
4174 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4175 lim_send_beacon_ind(pMac, psessionEntry);
4176
4177end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304178 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004179 return;
4180} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4181
4182/*
4183 Update the beacon Interval dynamically if beaconInterval is different in MCC
4184 */
4185static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4186{
4187 tpSirChangeBIParams pChangeBIParams;
4188 tpPESession psessionEntry;
4189 uint8_t sessionId = 0;
4190 tUpdateBeaconParams beaconParams;
4191
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004192 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004193
4194 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004195 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004196 return;
4197 }
4198
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304199 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004200 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4201
4202 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004203 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004204 &sessionId);
4205 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004206 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004207 return;
4208 }
4209
4210 /*Update sessionEntry Beacon Interval */
4211 if (psessionEntry->beaconParams.beaconInterval !=
4212 pChangeBIParams->beaconInterval) {
4213 psessionEntry->beaconParams.beaconInterval =
4214 pChangeBIParams->beaconInterval;
4215 }
4216
4217 /*Update sch beaconInterval */
4218 if (pMac->sch.schObject.gSchBeaconInterval !=
4219 pChangeBIParams->beaconInterval) {
4220 pMac->sch.schObject.gSchBeaconInterval =
4221 pChangeBIParams->beaconInterval;
4222
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004223 pe_debug("LIM send update BeaconInterval Indication: %d",
4224 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004225
4226 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4227 /* Update beacon */
4228 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4229
4230 beaconParams.bssIdx = psessionEntry->bssIdx;
4231 /* Set change in beacon Interval */
4232 beaconParams.beaconInterval =
4233 pChangeBIParams->beaconInterval;
4234 beaconParams.paramChangeBitmap =
4235 PARAM_BCN_INTERVAL_CHANGED;
4236 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4237 }
4238 }
4239
4240 return;
4241} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4242
4243#ifdef QCA_HT_2040_COEX
4244static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4245 uint32_t *pMsgBuf)
4246{
4247 tpSirSetHT2040Mode pSetHT2040Mode;
4248 tpPESession psessionEntry;
4249 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004250 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004251 tUpdateVHTOpMode *pHtOpMode = NULL;
4252 uint16_t staId = 0;
4253 tpDphHashNode pStaDs = NULL;
4254
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004255 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004256 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004257 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004258 return;
4259 }
4260
4261 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4262
4263 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004264 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004265 &sessionId);
4266 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004267 pe_debug("Session does not exist for given BSSID");
4268 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004269 return;
4270 }
4271
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004272 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004273 pSetHT2040Mode->cbMode);
4274 /*Update sessionEntry HT related fields */
4275 switch (pSetHT2040Mode->cbMode) {
4276 case PHY_SINGLE_CHANNEL_CENTERED:
4277 psessionEntry->htSecondaryChannelOffset =
4278 PHY_SINGLE_CHANNEL_CENTERED;
4279 psessionEntry->htRecommendedTxWidthSet = 0;
4280 if (pSetHT2040Mode->obssEnabled)
4281 psessionEntry->htSupportedChannelWidthSet
4282 = eHT_CHANNEL_WIDTH_40MHZ;
4283 else
4284 psessionEntry->htSupportedChannelWidthSet
4285 = eHT_CHANNEL_WIDTH_20MHZ;
4286 break;
4287 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4288 psessionEntry->htSecondaryChannelOffset =
4289 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4290 psessionEntry->htRecommendedTxWidthSet = 1;
4291 break;
4292 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4293 psessionEntry->htSecondaryChannelOffset =
4294 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4295 psessionEntry->htRecommendedTxWidthSet = 1;
4296 break;
4297 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004298 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004299 return;
4300 }
4301
4302 /* Update beacon */
4303 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4304 lim_send_beacon_ind(pMac, psessionEntry);
4305
4306 /* update OP Mode for each associated peer */
4307 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4308 pStaDs = dph_get_hash_entry(pMac, staId,
4309 &psessionEntry->dph.dphHashTable);
4310 if (NULL == pStaDs)
4311 continue;
4312
4313 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304314 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004315 if (NULL == pHtOpMode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004316 pe_err("Not able to allocate memory for setting OP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004317 return;
4318 }
4319 pHtOpMode->opMode =
4320 (psessionEntry->htSecondaryChannelOffset ==
4321 PHY_SINGLE_CHANNEL_CENTERED) ?
4322 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4323 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304324 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004325 sizeof(tSirMacAddr));
4326 pHtOpMode->smesessionId = sessionId;
4327
4328 msg.type = WMA_UPDATE_OP_MODE;
4329 msg.reserved = 0;
4330 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004331 if (!QDF_IS_STATUS_SUCCESS
4332 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
4333 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304334 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004335 return;
4336 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004337 pe_debug("Notifed FW about OP mode: %d for staId=%d",
4338 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004339
4340 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004341 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004342 }
4343
4344 return;
4345}
4346#endif
4347
4348/* -------------------------------------------------------------------- */
4349/**
4350 * __lim_process_report_message
4351 *
4352 * FUNCTION: Processes the next received Radio Resource Management message
4353 *
4354 * LOGIC:
4355 *
4356 * ASSUMPTIONS:
4357 *
4358 * NOTE:
4359 *
4360 * @param None
4361 * @return None
4362 */
4363
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004364static void __lim_process_report_message(tpAniSirGlobal pMac,
4365 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004366{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004367 switch (pMsg->type) {
4368 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4369 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4370 break;
4371 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004372 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004373 break;
4374 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004375 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004376 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004377}
4378
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004379/* -------------------------------------------------------------------- */
4380/**
4381 * lim_send_set_max_tx_power_req
4382 *
4383 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4384 *
4385 * LOGIC:
4386 *
4387 * ASSUMPTIONS:
4388 *
4389 * NOTE:
4390 *
4391 * @param txPower txPower to be set.
4392 * @param pSessionEntry session entry.
4393 * @return None
4394 */
4395tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004396lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004397 tpPESession pSessionEntry)
4398{
4399 tpMaxTxPowerParams pMaxTxParams = NULL;
4400 tSirRetStatus retCode = eSIR_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004401 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004402
4403 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004404 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004405 return eSIR_FAILURE;
4406 }
4407
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304408 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004409 if (NULL == pMaxTxParams) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004410 pe_err("Unable to allocate memory for pMaxTxParams");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004411 return eSIR_MEM_ALLOC_FAILED;
4412
4413 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004414 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304415 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304416 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304417 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004418 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304419 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004420
4421 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4422 msgQ.bodyptr = pMaxTxParams;
4423 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004424 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004425 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4426 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4427 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004428 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304429 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004430 }
4431 return retCode;
4432}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004433
4434/**
4435 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4436 *
4437 * @mac_ctx: Pointer to Global MAC structure
4438 * @msg_buf: pointer to the SME message buffer
4439 *
4440 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4441 * from SME. It Register this information within PE.
4442 *
4443 * Return: None
4444 */
4445static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4446 uint32_t *msg_buf)
4447{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304448 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004449 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4450 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4451 struct mgmt_frm_reg_info *next = NULL;
4452 bool match = false;
4453
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004454 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004455 sme_req->registerFrame, sme_req->frameType,
4456 sme_req->matchLen);
4457 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304458 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304459 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4460 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304461 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004462
4463 while (lim_mgmt_regn != NULL) {
4464 if (lim_mgmt_regn->frameType != sme_req->frameType)
4465 goto skip_match;
4466 if (sme_req->matchLen) {
4467 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304468 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004469 sme_req->matchData,
4470 lim_mgmt_regn->matchLen))) {
4471 /* found match! */
4472 match = true;
4473 break;
4474 }
4475 } else {
4476 /* found match! */
4477 match = true;
4478 break;
4479 }
4480skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304481 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304482 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004483 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304484 (qdf_list_node_t *)lim_mgmt_regn,
4485 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304486 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004487 lim_mgmt_regn = next;
4488 next = NULL;
4489 }
4490 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304491 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004492 if (QDF_STATUS_SUCCESS ==
4493 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004494 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004495 (qdf_list_node_t *)lim_mgmt_regn))
4496 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304497 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004498 }
4499
4500 if (sme_req->registerFrame) {
4501 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304502 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004503 sme_req->matchLen);
4504 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004505 lim_mgmt_regn->frameType = sme_req->frameType;
4506 lim_mgmt_regn->matchLen = sme_req->matchLen;
4507 lim_mgmt_regn->sessionId = sme_req->sessionId;
4508 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304509 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004510 sme_req->matchData,
4511 sme_req->matchLen);
4512 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304513 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004514 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304515 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004516 gLimMgmtFrameRegistratinQueue,
4517 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304518 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004519 &mac_ctx->lim.lim_frame_register_lock);
4520 }
4521 }
4522 return;
4523}
4524
4525static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4526{
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004527 pe_debug("Dereg msgType %d", pMac->lim.gDeferMsgTypeForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004528 pMac->lim.gDeferMsgTypeForNOA = 0;
4529 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4530 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304531 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004532 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4533 }
4534}
4535
4536/**
4537 * lim_process_regd_defd_sme_req_after_noa_start()
4538 *
4539 * mac_ctx: Pointer to Global MAC structure
4540 *
4541 * This function is called to process deferred sme req message
4542 * after noa start.
4543 *
4544 * Return: None
4545 */
4546void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4547{
4548 bool buf_consumed = true;
4549
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004550 pe_debug("Process defd sme req %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004551 mac_ctx->lim.gDeferMsgTypeForNOA);
4552
4553 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4554 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004555 pe_warn("start rcvd from FW when no sme deferred msg pending. Do nothing");
4556 pe_warn("It may happen when NOA start ind and timeout happen at the same time");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004557 return;
4558 }
4559 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4560 case eWNI_SME_SCAN_REQ:
4561 __lim_process_sme_scan_req(mac_ctx,
4562 mac_ctx->lim.gpDefdSmeMsgForNOA);
4563 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004564 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4565 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4566 mac_ctx->lim.gpDefdSmeMsgForNOA);
4567 /*
4568 * lim_process_remain_on_chnl_req doesnt want us to free
4569 * the buffer since it is freed in lim_remain_on_chn_rsp.
4570 * this change is to avoid "double free"
4571 */
4572 if (false == buf_consumed)
4573 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4574 break;
4575 case eWNI_SME_JOIN_REQ:
4576 __lim_process_sme_join_req(mac_ctx,
4577 mac_ctx->lim.gpDefdSmeMsgForNOA);
4578 break;
4579 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004580 pe_err("Unknown deferred msg type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004581 mac_ctx->lim.gDeferMsgTypeForNOA);
4582 break;
4583 }
4584 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4585}
4586
4587static void
4588__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4589{
4590 tpSirResetAPCapsChange pResetCapsChange;
4591 tpPESession psessionEntry;
4592 uint8_t sessionId = 0;
4593 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004594 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004595 return;
4596 }
4597
4598 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4599 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004600 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4601 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004602 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004603 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004604 return;
4605 }
4606
4607 psessionEntry->limSentCapsChangeNtf = false;
4608 return;
4609}
4610
4611/**
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304612 * lim_register_p2p_ack_ind_cb() - Save the p2p ack indication callback.
4613 * @mac_ctx: Mac pointer
4614 * @msg_buf: Msg pointer containing the callback
4615 *
4616 * This function is used to save the p2p ack indication callback in PE.
4617 *
4618 * Return: None
4619 */
4620static void lim_register_p2p_ack_ind_cb(tpAniSirGlobal mac_ctx,
4621 uint32_t *msg_buf)
4622{
4623 struct sir_sme_p2p_ack_ind_cb_req *sme_req =
4624 (struct sir_sme_p2p_ack_ind_cb_req *)msg_buf;
4625
4626 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004627 pe_err("msg_buf is null");
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304628 return;
4629 }
4630 if (sme_req->callback)
4631 mac_ctx->p2p_ack_ind_cb =
4632 sme_req->callback;
4633 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004634 pe_err("sme_req->callback is null");
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304635}
4636
4637/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304638 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4639 * indication callback in PE.
4640 * @mac_ptr: Mac pointer
4641 * @msg_buf: Msg pointer containing the callback
4642 *
4643 * This function is used save the Management frame
4644 * indication callback in PE.
4645 *
4646 * Return: None
4647 */
4648static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4649 uint32_t *msg_buf)
4650{
4651 struct sir_sme_mgmt_frame_cb_req *sme_req =
4652 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4653
4654 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004655 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304656 return;
4657 }
4658 if (sme_req->callback)
4659 mac_ctx->mgmt_frame_ind_cb =
4660 (sir_mgmt_frame_ind_callback)sme_req->callback;
4661 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004662 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304663}
4664
4665/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304666 *__lim_process_send_disassoc_frame: function processes disassoc frame
4667 * @mac_ctx: pointer to mac context
4668 * @msg_buf: message buffer
4669 *
4670 * function processes disassoc request received from SME
4671 *
4672 * return: none
4673 */
4674static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4675 uint32_t *msg_buf)
4676{
4677 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4678 tSirRetStatus status;
4679 tpPESession session_entry = NULL;
4680 uint8_t sme_session_id;
4681 uint16_t sme_trans_id;
4682
4683 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004684 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304685 return;
4686 }
4687
4688 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4689 &sme_trans_id);
4690
4691 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4692 &sme_send_disassoc_frame_req,
4693 (uint8_t *)msg_buf);
4694
4695 if ((eSIR_FAILURE == status) ||
4696 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4697 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004698 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304699 return;
4700 }
4701
4702 session_entry = pe_find_session_by_sme_session_id(
4703 mac_ctx, sme_session_id);
4704 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004705 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304706 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4707 return;
4708 }
4709
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004710 pe_debug("msg_type->%d len->%d sess_id->%d trans_id->%d mac->"MAC_ADDRESS_STR" reason->%d wait_for_ack->%d",
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304711 sme_send_disassoc_frame_req.msg_type,
4712 sme_send_disassoc_frame_req.length,
4713 sme_send_disassoc_frame_req.session_id,
4714 sme_send_disassoc_frame_req.trans_id,
4715 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4716 sme_send_disassoc_frame_req.reason,
4717 sme_send_disassoc_frame_req.wait_for_ack);
4718
4719 lim_send_disassoc_mgmt_frame(mac_ctx,
4720 sme_send_disassoc_frame_req.reason,
4721 sme_send_disassoc_frame_req.peer_mac,
4722 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4723}
4724
4725/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004726 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4727 * @mac_ctx: Pointer to Global MAC structure
4728 * @pdev_id: pdev id to set the IE.
4729 * @nss: Nss values to prepare the HT IE.
4730 *
4731 * Prepares the HT IE with self capabilities for different
4732 * Nss values and sends the set HT IE req to FW.
4733 *
4734 * Return: None
4735 */
4736static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4737 uint8_t nss)
4738{
4739 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004740 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004741 tSirRetStatus rc = eSIR_SUCCESS;
4742 uint8_t *p_ie = NULL;
4743 tHtCaps *p_ht_cap;
4744 int i;
4745
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004746 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004747 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4748 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004749 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004750 return;
4751 }
4752 ie_params->nss = i;
4753 ie_params->pdev_id = pdev_id;
4754 ie_params->ie_type = DOT11_HT_IE;
4755 /* 2 for IE len and EID */
4756 ie_params->ie_len = 2 + sizeof(tHtCaps);
4757 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4758 if (NULL == ie_params->ie_ptr) {
4759 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004760 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004761 return;
4762 }
4763 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4764 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4765 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4766 ie_params->ie_len);
4767
4768 if (NSS_1x1_MODE == i) {
4769 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4770 ie_params->ie_len,
4771 DOT11F_EID_HTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004772 if (NULL == p_ie) {
4773 qdf_mem_free(ie_params->ie_ptr);
4774 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004775 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004776 return;
4777 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004778 p_ht_cap = (tHtCaps *)&p_ie[2];
4779 p_ht_cap->supportedMCSSet[1] = 0;
4780 p_ht_cap->txSTBC = 0;
4781 }
4782
4783 msg.type = WMA_SET_PDEV_IE_REQ;
4784 msg.bodyptr = ie_params;
4785 msg.bodyval = 0;
4786
4787 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4788 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004789 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004790 qdf_mem_free(ie_params->ie_ptr);
4791 qdf_mem_free(ie_params);
4792 return;
4793 }
4794 }
4795}
4796
4797/**
4798 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4799 * @mac_ctx: Pointer to Global MAC structure
4800 * @pdev_id: pdev id to set the IE.
4801 * @nss: Nss values to prepare the VHT IE.
4802 *
4803 * Prepares the VHT IE with self capabilities for different
4804 * Nss values and sends the set VHT IE req to FW.
4805 *
4806 * Return: None
4807 */
4808static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4809 uint8_t nss)
4810{
4811 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004812 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004813 tSirRetStatus rc = eSIR_SUCCESS;
4814 uint8_t *p_ie = NULL;
4815 tSirMacVHTCapabilityInfo *vht_cap;
4816 int i;
4817 tSirVhtMcsInfo *vht_mcs;
4818
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004819 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004820 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4821 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004822 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004823 return;
4824 }
4825 ie_params->nss = i;
4826 ie_params->pdev_id = pdev_id;
4827 ie_params->ie_type = DOT11_VHT_IE;
4828 /* 2 for IE len and EID */
4829 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4830 sizeof(tSirVhtMcsInfo);
4831 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4832 if (NULL == ie_params->ie_ptr) {
4833 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004834 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004835 return;
4836 }
4837 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4838 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4839 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4840 ie_params->ie_len);
4841
4842 if (NSS_1x1_MODE == i) {
4843 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4844 ie_params->ie_len,
4845 DOT11F_EID_VHTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004846 if (NULL == p_ie) {
4847 qdf_mem_free(ie_params->ie_ptr);
4848 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004849 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004850 return;
4851 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004852 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4853 vht_cap->txSTBC = 0;
4854 vht_mcs =
4855 (tSirVhtMcsInfo *)&p_ie[2 +
4856 sizeof(tSirMacVHTCapabilityInfo)];
4857 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4858 vht_mcs->rxHighest =
4859 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4860 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4861 vht_mcs->txHighest =
4862 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4863 }
4864 msg.type = WMA_SET_PDEV_IE_REQ;
4865 msg.bodyptr = ie_params;
4866 msg.bodyval = 0;
4867
4868 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4869 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004870 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004871 qdf_mem_free(ie_params->ie_ptr);
4872 qdf_mem_free(ie_params);
4873 return;
4874 }
4875 }
4876}
4877
4878/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004879 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4880 * @mac_ctx: Pointer to Global MAC structure
4881 * @msg_buf: Pointer to the SME message buffer
4882 *
4883 * This function is called by limProcessMessageQueue(). This function sets the
4884 * VDEV IEs to the FW.
4885 *
4886 * Return: None
4887 */
4888static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4889 uint32_t *msg_buf)
4890{
4891 struct sir_set_vdev_ies_per_band *p_msg =
4892 (struct sir_set_vdev_ies_per_band *)msg_buf;
4893
4894 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004895 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004896 return;
4897 }
4898
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004899 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004900 p_msg->vdev_id);
4901 /* intentionally using NULL here so that self capabilty are sent */
4902 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4903 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004904 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004905}
4906
4907/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004908 * lim_process_set_pdev_IEs() - process the set pdev IE req
4909 * @mac_ctx: Pointer to Global MAC structure
4910 * @msg_buf: Pointer to the SME message buffer
4911 *
4912 * This function is called by limProcessMessageQueue(). This
4913 * function sets the PDEV IEs to the FW.
4914 *
4915 * Return: None
4916 */
4917static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4918{
4919 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4920
4921 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4922
4923 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004924 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004925 return;
4926 }
4927
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004928 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004929 ht_vht_cfg->nss);
4930 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4931
4932 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4933 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4934 ht_vht_cfg->nss);
4935}
4936
4937/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304938 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4939 *
4940 * access policy
4941 * @mac_ctx: pointer to mac context
4942 * @msg: message buffer
4943 *
4944 * function processes vendor IE and access policy from SME and updates PE
4945 *
4946 * session entry
4947 *
4948 * return: none
4949*/
4950static void lim_process_sme_update_access_policy_vendor_ie(
4951 tpAniSirGlobal mac_ctx,
4952 uint32_t *msg)
4953{
4954 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4955 struct sPESession *pe_session_entry;
4956 uint8_t num_bytes;
4957
4958 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004959 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304960 return;
4961 }
4962 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4963 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4964 update_vendor_ie->sme_session_id);
4965
4966 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004967 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304968 update_vendor_ie->sme_session_id);
4969 return;
4970 }
4971 if (pe_session_entry->access_policy_vendor_ie)
4972 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4973
4974 num_bytes = update_vendor_ie->ie[1] + 2;
4975 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
4976
4977 if (!pe_session_entry->access_policy_vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004978 pe_err("Failed to allocate memory for vendor ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304979 return;
4980 }
4981 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4982 &update_vendor_ie->ie[0], num_bytes);
4983
4984 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4985}
4986
4987/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004988 * lim_process_sme_req_messages()
4989 *
4990 ***FUNCTION:
4991 * This function is called by limProcessMessageQueue(). This
4992 * function processes SME request messages from HDD or upper layer
4993 * application.
4994 *
4995 ***LOGIC:
4996 *
4997 ***ASSUMPTIONS:
4998 *
4999 ***NOTE:
5000 *
5001 * @param pMac Pointer to Global MAC structure
5002 * @param msgType Indicates the SME message type
5003 * @param *pMsgBuf A pointer to the SME message buffer
5004 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5005 * false - if pMsgBuf is not to be freed.
5006 */
5007
Rajeev Kumarfeb96382017-01-22 19:42:09 -08005008bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
5009 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005010{
5011 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
5012 uint32_t *pMsgBuf = pMsg->bodyptr;
5013 tpSirSmeScanReq pScanReq;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005014
5015 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005016 lim_msg_str(pMsg->type), pMsg->type,
5017 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
5018 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005019
5020 pScanReq = (tpSirSmeScanReq) pMsgBuf;
5021 /* If no insert NOA required then execute the code below */
5022
5023 switch (pMsg->type) {
5024 case eWNI_SME_SYS_READY_IND:
5025 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
5026 break;
5027
5028 case eWNI_SME_START_BSS_REQ:
5029 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
5030 break;
5031
5032 case eWNI_SME_SCAN_REQ:
5033 __lim_process_sme_scan_req(pMac, pMsgBuf);
5034 break;
5035
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005036 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5037 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
5038 break;
5039
5040 case eWNI_SME_UPDATE_NOA:
5041 __lim_process_sme_no_a_update(pMac, pMsgBuf);
5042 break;
5043 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
5044 __lim_process_clear_dfs_channel_list(pMac, pMsg);
5045 break;
5046 case eWNI_SME_JOIN_REQ:
5047 __lim_process_sme_join_req(pMac, pMsgBuf);
5048 break;
5049
5050 case eWNI_SME_REASSOC_REQ:
5051 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
5052 break;
5053
5054 case eWNI_SME_DISASSOC_REQ:
5055 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
5056 break;
5057
5058 case eWNI_SME_DISASSOC_CNF:
5059 case eWNI_SME_DEAUTH_CNF:
5060 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
5061 break;
5062
5063 case eWNI_SME_DEAUTH_REQ:
5064 __lim_process_sme_deauth_req(pMac, pMsgBuf);
5065 break;
5066
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05305067 case eWNI_SME_SEND_DISASSOC_FRAME:
5068 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
5069 break;
5070
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005071 case eWNI_SME_SETCONTEXT_REQ:
5072 __lim_process_sme_set_context_req(pMac, pMsgBuf);
5073 break;
5074
5075 case eWNI_SME_STOP_BSS_REQ:
5076 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
5077 break;
5078
5079 case eWNI_SME_ASSOC_CNF:
5080 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005081 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005082 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
5083 pMsgBuf);
5084 break;
5085
5086 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005087 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005088 __lim_process_sme_addts_req(pMac, pMsgBuf);
5089 break;
5090
5091 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005092 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005093 __lim_process_sme_delts_req(pMac, pMsgBuf);
5094 break;
5095
5096 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005097 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005098 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
5099 break;
5100
5101 case eWNI_SME_GET_STATISTICS_REQ:
5102 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
5103 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
5104 bufConsumed = false;
5105 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005106#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005107 case eWNI_SME_GET_TSM_STATS_REQ:
5108 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
5109 bufConsumed = false;
5110 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005111#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005112 case eWNI_SME_GET_ASSOC_STAS_REQ:
5113 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
5114 break;
5115 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5116 lim_process_tkip_counter_measures(pMac, pMsgBuf);
5117 break;
5118
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05305119 case eWNI_SME_SESSION_UPDATE_PARAM:
5120 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005121 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05305122 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
5123 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
5124 bufConsumed = false;
5125 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005126 case eWNI_SME_UPDATE_APWPSIE_REQ:
5127 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
5128 break;
5129 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5130 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
5131 break;
5132
5133 case eWNI_SME_SET_APWPARSNIEs_REQ:
5134 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
5135 break;
5136
5137 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5138 /* Update the beaconInterval */
5139 __lim_process_sme_change_bi(pMac, pMsgBuf);
5140 break;
5141
5142#ifdef QCA_HT_2040_COEX
5143 case eWNI_SME_SET_HT_2040_MODE:
5144 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
5145 break;
5146#endif
5147
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005148 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5149 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5150 __lim_process_report_message(pMac, pMsg);
5151 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005152
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005153 case eWNI_SME_FT_PRE_AUTH_REQ:
5154 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
5155 break;
5156 case eWNI_SME_FT_UPDATE_KEY:
5157 lim_process_ft_update_key(pMac, pMsgBuf);
5158 break;
5159
5160 case eWNI_SME_FT_AGGR_QOS_REQ:
5161 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
5162 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005163
5164 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5165 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
5166 break;
5167#ifdef FEATURE_WLAN_TDLS
5168 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5169 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
5170 break;
5171 case eWNI_SME_TDLS_ADD_STA_REQ:
5172 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
5173 break;
5174 case eWNI_SME_TDLS_DEL_STA_REQ:
5175 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
5176 break;
5177 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5178 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
5179 break;
5180#endif
5181 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5182 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
5183 break;
5184
5185 case eWNI_SME_CHANNEL_CHANGE_REQ:
5186 lim_process_sme_channel_change_request(pMac, pMsgBuf);
5187 break;
5188
5189 case eWNI_SME_START_BEACON_REQ:
5190 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
5191 break;
5192
5193 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
5194 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
5195 break;
5196
5197 case eWNI_SME_UPDATE_ADDITIONAL_IES:
5198 lim_process_update_add_ies(pMac, pMsgBuf);
5199 break;
5200
5201 case eWNI_SME_MODIFY_ADDITIONAL_IES:
5202 lim_process_modify_add_ies(pMac, pMsgBuf);
5203 break;
5204 case eWNI_SME_SET_HW_MODE_REQ:
5205 lim_process_set_hw_mode(pMac, pMsgBuf);
5206 break;
5207 case eWNI_SME_NSS_UPDATE_REQ:
5208 lim_process_nss_update_request(pMac, pMsgBuf);
5209 break;
5210 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5211 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5212 break;
5213 case eWNI_SME_SET_IE_REQ:
5214 lim_process_set_ie_req(pMac, pMsgBuf);
5215 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305216 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5217 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5218 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305219 case eWNI_SME_EXT_CHANGE_CHANNEL:
5220 lim_process_ext_change_channel(pMac, pMsgBuf);
5221 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005222 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5223 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5224 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005225 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5226 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005227 break;
5228 case eWNI_SME_SET_VDEV_IES_PER_BAND:
5229 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
5230 break;
Naveen Rawatf28315c2016-06-29 18:06:02 -07005231 case eWNI_SME_NDP_END_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005232 case eWNI_SME_NDP_INITIATOR_REQ:
Abhishek Singh4fef7472016-06-06 11:36:03 -07005233 case eWNI_SME_NDP_RESPONDER_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005234 lim_handle_ndp_request_message(pMac, pMsg);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005235 break;
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05305236 case eWNI_SME_REGISTER_P2P_ACK_CB:
5237 lim_register_p2p_ack_ind_cb(pMac, pMsgBuf);
5238 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305239 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5240 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5241 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07005242 case eWNI_SME_UPDATE_CONFIG:
5243 lim_process_sme_update_config(pMac,
5244 (struct update_config *)pMsgBuf);
5245 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005246 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305247 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005248 pMsg->bodyptr = NULL;
5249 break;
5250 } /* switch (msgType) */
5251
5252 return bufConsumed;
5253} /*** end lim_process_sme_req_messages() ***/
5254
5255/**
5256 * lim_process_sme_start_beacon_req()
5257 *
5258 ***FUNCTION:
5259 * This function is called by limProcessMessageQueue(). This
5260 * function processes SME request messages from HDD or upper layer
5261 * application.
5262 *
5263 ***LOGIC:
5264 *
5265 ***ASSUMPTIONS:
5266 *
5267 ***NOTE:
5268 *
5269 * @param pMac Pointer to Global MAC structure
5270 * @param msgType Indicates the SME message type
5271 * @param *pMsgBuf A pointer to the SME message buffer
5272 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5273 * false - if pMsgBuf is not to be freed.
5274 */
5275static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5276{
5277 tpSirStartBeaconIndication pBeaconStartInd;
5278 tpPESession psessionEntry;
5279 uint8_t sessionId; /* PE sessionID */
5280
5281 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005282 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005283 return;
5284 }
5285
5286 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5287 psessionEntry = pe_find_session_by_bssid(pMac,
5288 pBeaconStartInd->bssid,
5289 &sessionId);
5290 if (psessionEntry == NULL) {
5291 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005292 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005293 return;
5294 }
5295
5296 if (pBeaconStartInd->beaconStartStatus == true) {
5297 /*
5298 * Currently this Indication comes from SAP
5299 * to start Beacon Tx on a DFS channel
5300 * since beaconing has to be done on DFS
5301 * channel only after CAC WAIT is completed.
5302 * On a DFS Channel LIM does not start beacon
5303 * Tx right after the WMA_ADD_BSS_RSP.
5304 */
5305 lim_apply_configuration(pMac, psessionEntry);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305306 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005307 FL("Start Beacon with ssid %s Ch %d"),
5308 psessionEntry->ssId.ssId,
5309 psessionEntry->currentOperChannel);
5310 lim_send_beacon_ind(pMac, psessionEntry);
5311 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005312 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005313 return;
5314 }
5315}
5316
5317/**
5318 * lim_process_sme_channel_change_request() - process sme ch change req
5319 *
5320 * @mac_ctx: Pointer to Global MAC structure
5321 * @msg_buf: pointer to the SME message buffer
5322 *
5323 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5324 *
5325 * Return: None
5326 */
5327static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5328 uint32_t *msg_buf)
5329{
5330 tpSirChanChangeRequest ch_change_req;
5331 tpPESession session_entry;
5332 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005333 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005334 uint32_t val = 0;
5335
5336 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005337 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005338 return;
5339 }
5340 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5341
5342 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5343 ch_change_req->targetChannel);
5344
5345 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5346 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005347 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005348 return;
5349 }
5350
5351 session_entry = pe_find_session_by_bssid(mac_ctx,
5352 ch_change_req->bssid, &session_id);
5353 if (session_entry == NULL) {
5354 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005355 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005356 return;
5357 }
5358
5359 if (session_entry->currentOperChannel ==
5360 ch_change_req->targetChannel) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005361 pe_err("target CH is same as current CH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005362 return;
5363 }
5364
5365 if (LIM_IS_AP_ROLE(session_entry))
5366 session_entry->channelChangeReasonCode =
5367 LIM_SWITCH_CHANNEL_SAP_DFS;
5368 else
5369 session_entry->channelChangeReasonCode =
5370 LIM_SWITCH_CHANNEL_OPERATION;
5371
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005372 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005373 session_entry->currentOperChannel,
5374 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005375 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005376
5377 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005378 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005379 session_entry->ch_center_freq_seg0 =
5380 ch_change_req->center_freq_seg_0;
5381 session_entry->ch_center_freq_seg1 =
5382 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005383 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005384 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005385 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005386 session_entry->htRecommendedTxWidthSet =
5387 session_entry->htSupportedChannelWidthSet;
5388 session_entry->currentOperChannel =
5389 ch_change_req->targetChannel;
5390 session_entry->limRFBand =
5391 lim_get_rf_band(session_entry->currentOperChannel);
5392 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08005393 if (CHAN_HOP_ALL_BANDS_ENABLE ||
5394 SIR_BAND_5_GHZ == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005395 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5396 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005397 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005398 }
5399
5400 session_entry->lim11hEnable = val;
5401 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305402 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005403 &ch_change_req->operational_rateset,
5404 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305405 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005406 &ch_change_req->extended_rateset,
5407 sizeof(session_entry->extRateSet));
5408 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5409 session_entry->ch_center_freq_seg0,
5410 session_entry->ch_center_freq_seg1,
5411 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07005412 max_tx_pwr, session_entry->peSessionId,
5413 ch_change_req->cac_duration_ms,
5414 ch_change_req->dfs_regdomain);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005415}
5416
5417/******************************************************************************
5418* lim_start_bss_update_add_ie_buffer()
5419*
5420***FUNCTION:
5421* This function checks the src buffer and its length and then malloc for
5422* dst buffer update the same
5423*
5424***LOGIC:
5425*
5426***ASSUMPTIONS:
5427*
5428***NOTE:
5429*
5430* @param pMac Pointer to Global MAC structure
5431* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5432* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5433* @param *pSrcData_buff A pointer of uint8_t src buffer
5434* @param srcDataLen src buffer length
5435******************************************************************************/
5436
5437static void
5438lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5439 uint8_t **pDstData_buff,
5440 uint16_t *pDstDataLen,
5441 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5442{
5443
5444 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5445 *pDstDataLen = srcDataLen;
5446
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305447 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005448
5449 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005450 pe_err("AllocateMemory failed for pDstData_buff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005451 return;
5452 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305453 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005454 } else {
5455 *pDstData_buff = NULL;
5456 *pDstDataLen = 0;
5457 }
5458}
5459
5460/******************************************************************************
5461* lim_update_add_ie_buffer()
5462*
5463***FUNCTION:
5464* This function checks the src buffer and length if src buffer length more
5465* than dst buffer length then free the dst buffer and malloc for the new src
5466* length, and update the dst buffer and length. But if dst buffer is bigger
5467* than src buffer length then it just update the dst buffer and length
5468*
5469***LOGIC:
5470*
5471***ASSUMPTIONS:
5472*
5473***NOTE:
5474*
5475* @param pMac Pointer to Global MAC structure
5476* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5477* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5478* @param *pSrcData_buff A pointer of uint8_t src buffer
5479* @param srcDataLen src buffer length
5480******************************************************************************/
5481
5482static void
5483lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5484 uint8_t **pDstData_buff,
5485 uint16_t *pDstDataLen,
5486 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5487{
5488
5489 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005490 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005491 return;
5492 }
5493
5494 if (srcDataLen > *pDstDataLen) {
5495 *pDstDataLen = srcDataLen;
5496 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305497 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005498 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305499 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005500
5501 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005502 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005503 *pDstDataLen = 0;
5504 return;
5505 }
5506 }
5507
5508 /* copy the content of buffer into dst buffer
5509 */
5510 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305511 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005512
5513}
5514
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005515/**
5516 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5517 * @pMac : Pointer to Global MAC structure
5518 * @pDstData_buff : A pointer to pointer of dst buffer
5519 * @pDstDataLen : A pointer to pointer of dst buffer length
5520 * @pModifyIE : A pointer to tSirModifyIE
5521 *
5522 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5523 *
5524 * Return:
5525 * True or false depending upon whether IE is updated or not
5526 */
5527static bool
5528lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5529 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5530{
Hong Shi1553d692016-09-28 12:16:19 +08005531 int32_t oui_length;
5532 uint8_t *ibss_ie = NULL;
5533 uint8_t *vendor_ie;
5534#define MAC_VENDOR_OUI "\x00\x16\x32"
5535#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005536
5537 ibss_ie = pModifyIE->pIEBuffer;
5538 oui_length = pModifyIE->oui_length;
5539
5540 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005541 pe_err("Invalid set IBSS vendor IE command length %d",
5542 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005543 return false;
5544 }
5545
Hong Shi1553d692016-09-28 12:16:19 +08005546 /*
5547 * Why replace only beacon OUI data here:
5548 * 1. other ie (such as wpa) shall not be overwritten here.
5549 * 2. per spec, beacon oui ie might be set twice and original one
5550 * shall be updated.
5551 */
5552 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(pMac, MAC_VENDOR_OUI,
5553 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5554 if (vendor_ie) {
5555 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5556 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5557 pModifyIE->ieBufferlength);
5558 } else {
5559 uint16_t new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5560 uint8_t *new_ptr = qdf_mem_malloc(new_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005561
Hong Shi1553d692016-09-28 12:16:19 +08005562 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005563 pe_err("Memory allocation failed");
Hong Shi1553d692016-09-28 12:16:19 +08005564 return false;
5565 }
5566 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5567 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5568 pModifyIE->ieBufferlength);
5569 qdf_mem_free(*pDstData_buff);
5570 *pDstDataLen = new_length;
5571 *pDstData_buff = new_ptr;
5572 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005573 return true;
5574}
5575
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005576/*
5577* lim_process_modify_add_ies() - process modify additional IE req.
5578*
5579* @mac_ctx: Pointer to Global MAC structure
5580* @msg_buf: pointer to the SME message buffer
5581*
5582* This function update the PE buffers for additional IEs.
5583*
5584* Return: None
5585*/
5586static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5587 uint32_t *msg_buf)
5588{
5589 tpSirModifyIEsInd modify_add_ies;
5590 tpPESession session_entry;
5591 uint8_t session_id;
5592 bool ret = false;
5593 tSirAddIeParams *add_ie_params;
5594
5595 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005596 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005597 return;
5598 }
5599
5600 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5601 /* Incoming message has smeSession, use BSSID to find PE session */
5602 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005603 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005604
5605 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005606 pe_err("Session not found for given bssid"
5607 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005608 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005609 goto end;
5610 }
5611 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5612 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5613 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005614 pe_err("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005615 modify_add_ies->modifyIE.pIEBuffer,
5616 modify_add_ies->modifyIE.ieBufferlength,
5617 modify_add_ies->modifyIE.ieID,
5618 modify_add_ies->modifyIE.ieIDLen,
5619 modify_add_ies->updateType);
5620 goto end;
5621 }
5622 add_ie_params = &session_entry->addIeParams;
5623 switch (modify_add_ies->updateType) {
5624 case eUPDATE_IE_PROBE_RESP:
5625 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005626 if (LIM_IS_IBSS_ROLE(session_entry)) {
5627 lim_update_ibss_prop_add_ies(mac_ctx,
5628 &add_ie_params->probeRespData_buff,
5629 &add_ie_params->probeRespDataLen,
5630 &modify_add_ies->modifyIE);
5631 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005632 break;
5633 case eUPDATE_IE_ASSOC_RESP:
5634 /* assoc resp IE */
5635 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305636 QDF_TRACE(QDF_MODULE_ID_PE,
5637 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005638 "assoc resp add ie not present %d"),
5639 add_ie_params->assocRespDataLen);
5640 }
5641 /* search through the buffer and modify the IE */
5642 break;
5643 case eUPDATE_IE_PROBE_BCN:
5644 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005645 if (LIM_IS_IBSS_ROLE(session_entry)) {
5646 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5647 &add_ie_params->probeRespBCNData_buff,
5648 &add_ie_params->probeRespBCNDataLen,
5649 &modify_add_ies->modifyIE);
5650 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005651 if (ret == true && modify_add_ies->modifyIE.notify) {
5652 lim_handle_param_update(mac_ctx,
5653 modify_add_ies->updateType);
5654 }
5655 break;
5656 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005657 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005658 modify_add_ies->updateType);
5659 break;
5660 }
5661end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305662 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005663 modify_add_ies->modifyIE.pIEBuffer = NULL;
5664}
5665
5666/*
5667* lim_process_update_add_ies() - process additional IE update req
5668*
5669* @mac_ctx: Pointer to Global MAC structure
5670* @msg_buf: pointer to the SME message buffer
5671*
5672* This function update the PE buffers for additional IEs.
5673*
5674* Return: None
5675*/
5676static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5677 uint32_t *msg_buf)
5678{
5679 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5680 uint8_t session_id;
5681 tpPESession session_entry;
5682 tSirAddIeParams *addn_ie;
5683 uint16_t new_length = 0;
5684 uint8_t *new_ptr = NULL;
5685 tSirUpdateIE *update_ie;
5686
5687 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005688 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005689 return;
5690 }
5691 update_ie = &update_add_ies->updateIE;
5692 /* incoming message has smeSession, use BSSID to find PE session */
5693 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005694 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005695
5696 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005697 pe_err("Session not found for given bssid"
5698 MAC_ADDRESS_STR,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005699 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005700 goto end;
5701 }
5702 addn_ie = &session_entry->addIeParams;
5703 /* if len is 0, upper layer requested freeing of buffer */
5704 if (0 == update_ie->ieBufferlength) {
5705 switch (update_add_ies->updateType) {
5706 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305707 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005708 addn_ie->probeRespData_buff = NULL;
5709 addn_ie->probeRespDataLen = 0;
5710 break;
5711 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305712 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005713 addn_ie->assocRespData_buff = NULL;
5714 addn_ie->assocRespDataLen = 0;
5715 break;
5716 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305717 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005718 addn_ie->probeRespBCNData_buff = NULL;
5719 addn_ie->probeRespBCNDataLen = 0;
5720
5721 if (update_ie->notify)
5722 lim_handle_param_update(mac_ctx,
5723 update_add_ies->updateType);
5724 break;
5725 default:
5726 break;
5727 }
5728 return;
5729 }
5730 switch (update_add_ies->updateType) {
5731 case eUPDATE_IE_PROBE_RESP:
5732 if (update_ie->append) {
5733 /*
5734 * In case of append, allocate new memory
5735 * with combined length
5736 */
5737 new_length = update_ie->ieBufferlength +
5738 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305739 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005740 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005741 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005742 goto end;
5743 }
5744 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305745 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005746 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305747 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005748 update_ie->pAdditionIEBuffer,
5749 update_ie->ieBufferlength);
5750 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305751 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005752 /* adjust length accordingly */
5753 addn_ie->probeRespDataLen = new_length;
5754 /* save refernece of local buffer in PE session */
5755 addn_ie->probeRespData_buff = new_ptr;
5756 goto end;
5757 }
5758 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5759 &addn_ie->probeRespDataLen,
5760 update_ie->pAdditionIEBuffer,
5761 update_ie->ieBufferlength);
5762 break;
5763 case eUPDATE_IE_ASSOC_RESP:
5764 /* assoc resp IE */
5765 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5766 &addn_ie->assocRespDataLen,
5767 update_ie->pAdditionIEBuffer,
5768 update_ie->ieBufferlength);
5769 break;
5770 case eUPDATE_IE_PROBE_BCN:
5771 /* probe resp Bcn IE */
5772 lim_update_add_ie_buffer(mac_ctx,
5773 &addn_ie->probeRespBCNData_buff,
5774 &addn_ie->probeRespBCNDataLen,
5775 update_ie->pAdditionIEBuffer,
5776 update_ie->ieBufferlength);
5777 if (update_ie->notify)
5778 lim_handle_param_update(mac_ctx,
5779 update_add_ies->updateType);
5780 break;
5781 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005782 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005783 break;
5784 }
5785end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305786 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005787 update_ie->pAdditionIEBuffer = NULL;
5788}
5789
5790/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305791 * send_extended_chan_switch_action_frame()- function to send ECSA
5792 * action frame for each sta connected to SAP/GO and AP in case of
5793 * STA .
5794 * @mac_ctx: pointer to global mac structure
5795 * @new_channel: new channel to switch to.
5796 * @ch_bandwidth: BW of channel to calculate op_class
5797 * @session_entry: pe session
5798 *
5799 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5800 *
5801 * Return: void
5802 */
5803
5804static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5805 uint16_t new_channel, uint8_t ch_bandwidth,
5806 tpPESession session_entry)
5807{
5808 uint16_t op_class;
5809 uint8_t switch_mode = 0, i;
5810 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005811 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305812
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005813 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305814 mac_ctx->scan.countryCodeCurrent,
5815 new_channel,
5816 ch_bandwidth);
5817
5818 if (LIM_IS_AP_ROLE(session_entry) &&
5819 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005820 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305821
gaoleze2920bd2017-03-21 17:38:42 +08005822 switch_count = session_entry->gLimChannelSwitch.switchCount;
5823
Abhishek Singh518323d2015-10-19 17:42:01 +05305824 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005825 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305826 psta =
5827 session_entry->dph.dphHashTable.pDphNodeArray + i;
5828 if (psta && psta->added)
5829 lim_send_extended_chan_switch_action_frame(
5830 mac_ctx,
5831 psta->staAddr,
5832 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005833 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305834 }
5835 } else if (LIM_IS_STA_ROLE(session_entry)) {
5836 lim_send_extended_chan_switch_action_frame(mac_ctx,
5837 session_entry->bssId,
5838 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005839 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305840 }
5841
5842}
5843
5844/**
gaolez76d2a162017-03-21 19:23:58 +08005845 * lim_send_chan_switch_action_frame()- Send an action frame
5846 * containing CSA IE or ECSA IE depending on the connected
5847 * sta capability.
5848 *
5849 * @mac_ctx: pointer to global mac structure
5850 * @new_channel: new channel to switch to.
5851 * @ch_bandwidth: BW of channel to calculate op_class
5852 * @session_entry: pe session
5853 *
5854 * Return: void
5855 */
5856static
5857void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5858 uint16_t new_channel,
5859 uint8_t ch_bandwidth,
5860 tpPESession session_entry)
5861{
5862 uint16_t op_class;
5863 uint8_t switch_mode = 0, i;
5864 uint8_t switch_count;
5865 tpDphHashNode psta;
5866 tpDphHashNode dph_node_array_ptr;
5867
5868 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5869
5870 op_class = wlan_reg_dmn_get_opclass_from_channel(
5871 mac_ctx->scan.countryCodeCurrent,
5872 new_channel, ch_bandwidth);
5873
5874 if (LIM_IS_AP_ROLE(session_entry) &&
5875 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5876 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5877
5878 switch_count = session_entry->gLimChannelSwitch.switchCount;
5879
5880 if (LIM_IS_AP_ROLE(session_entry)) {
5881 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5882 psta = dph_node_array_ptr + i;
5883 if (!(psta && psta->added))
5884 continue;
5885 if (session_entry->lim_non_ecsa_cap_num == 0)
5886 lim_send_extended_chan_switch_action_frame
5887 (mac_ctx, psta->staAddr, switch_mode,
5888 op_class, new_channel, switch_count,
5889 session_entry);
5890 else
5891 lim_send_channel_switch_mgmt_frame
5892 (mac_ctx, psta->staAddr, switch_mode,
5893 new_channel, switch_count,
5894 session_entry);
5895 }
5896 } else if (LIM_IS_STA_ROLE(session_entry)) {
5897 lim_send_extended_chan_switch_action_frame
5898 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5899 new_channel, switch_count, session_entry);
5900 }
5901}
5902
5903/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005904 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5905 *
5906 * @mac_ctx: Pointer to Global MAC structure
5907 * @msg_buf: pointer to the SME message buffer
5908 *
5909 * This function processes SME request messages from HDD or upper layer
5910 * application.
5911 *
5912 * Return: None
5913 */
5914static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5915 uint32_t *msg_buf)
5916{
5917 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5918 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005919 uint8_t session_id;
5920 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005921 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005922
5923 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005924 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005925 return;
5926 }
5927
5928 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5929 session_entry = pe_find_session_by_bssid(mac_ctx,
5930 dfs_csa_ie_req->bssid, &session_id);
5931 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005932 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005933 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5934 return;
5935 }
5936
5937 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005938 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005939 GET_LIM_SYSTEM_ROLE(session_entry));
5940 return;
5941 }
5942
5943 /* target channel */
5944 session_entry->gLimChannelSwitch.primaryChannel =
5945 dfs_csa_ie_req->targetChannel;
5946
5947 /* Channel switch announcement needs to be included in beacon */
5948 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005949 session_entry->gLimChannelSwitch.switchCount =
5950 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005951 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005952 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305953 session_entry->gLimChannelSwitch.sec_ch_offset =
5954 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005955 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005956 session_entry->gLimChannelSwitch.switchMode =
5957 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005958
5959 /*
5960 * Validate if SAP is operating HT or VHT mode and set the Channel
5961 * Switch Wrapper element with the Wide Band Switch subelement.
5962 */
5963 if (true != session_entry->vhtCapability)
5964 goto skip_vht;
5965
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005966 /* Now encode the Wider Ch BW element depending on the ch width */
5967 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005968 switch (dfs_csa_ie_req->ch_params.ch_width) {
5969 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005970 /*
5971 * Wide channel BW sublement in channel wrapper element is not
5972 * required in case of 20 Mhz operation. Currently It is set
5973 * only set in case of 40/80 Mhz Operation.
5974 */
5975 session_entry->dfsIncludeChanWrapperIe = false;
5976 wider_bw_ch_switch->newChanWidth =
5977 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5978 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005979 case CH_WIDTH_40MHZ:
5980 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005981 wider_bw_ch_switch->newChanWidth =
5982 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5983 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005984 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005985 session_entry->dfsIncludeChanWrapperIe = true;
5986 wider_bw_ch_switch->newChanWidth =
5987 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5988 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005989 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005990 session_entry->dfsIncludeChanWrapperIe = true;
5991 wider_bw_ch_switch->newChanWidth =
5992 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5993 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005994 case CH_WIDTH_80P80MHZ:
5995 session_entry->dfsIncludeChanWrapperIe = true;
5996 wider_bw_ch_switch->newChanWidth =
5997 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08005998 /*
5999 * This is not applicable for 20/40/80 Mhz.
6000 * Only used when we support 80+80 Mhz operation.
6001 * In case of 80+80 Mhz, this parameter indicates
6002 * center channel frequency index of 80 Mhz channel of
6003 * frequency segment 1.
6004 */
6005 wider_bw_ch_switch->newCenterChanFreq1 =
6006 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006007 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006008 default:
6009 session_entry->dfsIncludeChanWrapperIe = false;
6010 /*
6011 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
6012 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
6013 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006014 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006015 break;
6016 }
6017 /* Fetch the center channel based on the channel width */
6018 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006019 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006020skip_vht:
6021 /* Send CSA IE request from here */
6022 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6023 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006024 pe_err("Unable to set CSA IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006025 return;
6026 }
6027
6028 /*
6029 * First beacon update request is sent here, the remaining updates are
6030 * done when the FW responds back after sending the first beacon after
6031 * the template update
6032 */
6033 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306034
6035 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
6036 ch_offset = BW80;
6037 else
6038 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
6039
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006040 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306041 session_entry->gLimChannelSwitch.switchCount,
6042 session_entry->gLimChannelSwitch.primaryChannel,
6043 session_entry->gLimChannelSwitch.ch_width,
6044 session_entry->dfsIncludeChanWrapperIe,
6045 ch_offset);
6046
gaolez76d2a162017-03-21 19:23:58 +08006047 /* Send ECSA/CSA Action frame after updating the beacon */
6048 if (CHAN_HOP_ALL_BANDS_ENABLE)
6049 lim_send_chan_switch_action_frame(mac_ctx,
6050 session_entry->gLimChannelSwitch.primaryChannel,
6051 ch_offset, session_entry);
6052 else
6053 send_extended_chan_switch_action_frame(mac_ctx,
6054 session_entry->gLimChannelSwitch.primaryChannel,
6055 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006056 session_entry->gLimChannelSwitch.switchCount--;
6057}
6058
6059/**
Abhishek Singh518323d2015-10-19 17:42:01 +05306060 * lim_process_ext_change_channel()- function to send ECSA
6061 * action frame for STA/CLI .
6062 * @mac_ctx: pointer to global mac structure
6063 * @msg: params from sme for new channel.
6064 *
6065 * This function is called to send ECSA frame for STA/CLI.
6066 *
6067 * Return: void
6068 */
6069
6070static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
6071 uint32_t *msg)
6072{
6073 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
6074 (struct sir_sme_ext_cng_chan_req *) msg;
6075 tpPESession session_entry = NULL;
6076
6077 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006078 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05306079 return;
6080 }
6081 session_entry =
6082 pe_find_session_by_sme_session_id(mac_ctx,
6083 ext_chng_channel->session_id);
6084 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006085 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05306086 ext_chng_channel->session_id);
6087 return;
6088 }
6089 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006090 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05306091 return;
6092 }
6093 send_extended_chan_switch_action_frame(mac_ctx,
6094 ext_chng_channel->new_channel,
6095 0, session_entry);
6096}
6097
6098/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006099 * lim_process_nss_update_request() - process sme nss update req
6100 *
6101 * @mac_ctx: Pointer to Global MAC structure
6102 * @msg_buf: pointer to the SME message buffer
6103 *
6104 * This function processes SME request messages from HDD or upper layer
6105 * application.
6106 *
6107 * Return: None
6108 */
6109static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
6110 uint32_t *msg_buf)
6111{
6112 struct sir_nss_update_request *nss_update_req_ptr;
6113 tpPESession session_entry = NULL;
6114
6115 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006116 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006117 return;
6118 }
6119
6120 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05306121 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006122 nss_update_req_ptr->vdev_id);
6123 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006124 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006125 nss_update_req_ptr->vdev_id);
6126 return;
6127 }
6128
6129 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006130 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006131 GET_LIM_SYSTEM_ROLE(session_entry));
6132 return;
6133 }
6134
6135 /* populate nss field in the beacon */
6136 session_entry->gLimOperatingMode.present = 1;
6137 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05306138 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
6139
6140 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
6141 (session_entry->ch_width > CH_WIDTH_80MHZ))
6142 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
6143
6144 pe_debug("ch width %hu", session_entry->gLimOperatingMode.chanWidth);
6145
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006146 /* Send nss update request from here */
6147 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6148 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006149 pe_err("Unable to set op mode IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006150 return;
6151 }
6152
6153 lim_send_beacon_ind(mac_ctx, session_entry);
6154}
6155
6156/**
6157 * lim_process_set_ie_req() - process sme set IE request
6158 *
6159 * @mac_ctx: Pointer to Global MAC structure
6160 * @msg_buf: pointer to the SME message buffer
6161 *
6162 * This function processes SME request messages from HDD or upper layer
6163 * application.
6164 *
6165 * Return: None
6166 */
6167static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6168{
6169 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306170 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006171
6172 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006173 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006174 return;
6175 }
6176
6177 msg = (struct send_extcap_ie *)msg_buf;
6178 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306179 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006180 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006181
6182}