blob: 9c9efb02006423e955820fd4044d020d7df32e12 [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;
Abhishek Singh4294f802017-08-10 16:37:07 +0530768 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
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;
Abhishek Singh4294f802017-08-10 16:37:07 +0530893 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
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);
Abhishek Singh4294f802017-08-10 16:37:07 +0530991 ret_code = eSIR_LOGE_EXCEPTION;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800992 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;
Abhishek Singh4294f802017-08-10 16:37:07 +05301688 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301689 FL("PE PERSONA=%d cbMode %u nwType: %d dot11mode: %d force_24ghz_in_ht20 %d"),
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001690 session->pePersona, sme_join_req->cbMode,
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301691 session->nwType, session->dot11mode,
1692 sme_join_req->force_24ghz_in_ht20);
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001693
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001694 /* Copy The channel Id to the session Table */
1695 session->currentOperChannel = bss_desc->channelId;
1696 if (IS_5G_CH(session->currentOperChannel))
1697 vdev_type_nss = &mac_ctx->vdev_type_nss_5g;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001698 else
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07001699 vdev_type_nss = &mac_ctx->vdev_type_nss_2g;
1700 if (session->pePersona == QDF_P2P_CLIENT_MODE)
1701 session->vdev_nss = vdev_type_nss->p2p_cli;
1702 else
1703 session->vdev_nss = vdev_type_nss->sta;
1704 session->nss = session->vdev_nss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001705 session->vhtCapability =
1706 IS_DOT11_MODE_VHT(session->dot11mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001707 if (session->vhtCapability) {
Anurag Chouhan6d760662016-02-20 16:05:43 +05301708 if (session->pePersona == QDF_STA_MODE) {
Krunal Soni53993f72016-07-08 18:20:03 -07001709 session->vht_config.su_beam_formee =
1710 sme_join_req->vht_config.su_beam_formee;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001711 } else {
Krunal Soni53993f72016-07-08 18:20:03 -07001712 session->vht_config.su_beam_formee = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001713 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001714 session->enableVhtpAid =
1715 sme_join_req->enableVhtpAid;
1716 session->enableVhtGid =
1717 sme_join_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001718 pe_debug("vht su bformer [%d]",
Krunal Soni53993f72016-07-08 18:20:03 -07001719 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001720 }
Krunal Soni53993f72016-07-08 18:20:03 -07001721
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001722 if (IS_DOT11_MODE_HE(session->dot11mode)) {
1723 lim_update_session_he_capable(mac_ctx, session);
1724 lim_copy_join_req_he_cap(session, sme_join_req);
1725 }
Krishna Kumaar Natarajan4f1d7722017-03-03 21:12:51 -08001726
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001727 pe_debug("vhtCapability: %d su_beam_formee: %d txbf_csn_value: %d su_tx_bformer %d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +05301728 session->vhtCapability,
Krunal Soni53993f72016-07-08 18:20:03 -07001729 session->vht_config.su_beam_formee,
1730 session->vht_config.csnof_beamformer_antSup,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08001731 session->vht_config.su_beam_former);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001732 /*Phy mode */
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001733 session->gLimPhyMode = bss_desc->nwType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001734 handle_ht_capabilityand_ht_info(mac_ctx, session);
Abhishek Singhb59f8d42017-07-31 14:42:47 +05301735 session->force_24ghz_in_ht20 =
1736 sme_join_req->force_24ghz_in_ht20;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001737 /* cbMode is already merged value of peer and self -
1738 * done by csr in csr_get_cb_mode_from_ies */
1739 session->htSupportedChannelWidthSet =
1740 (sme_join_req->cbMode) ? 1 : 0;
1741 session->htRecommendedTxWidthSet =
1742 session->htSupportedChannelWidthSet;
1743 session->htSecondaryChannelOffset = sme_join_req->cbMode;
1744
1745 if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY == sme_join_req->cbMode) {
1746 session->ch_center_freq_seg0 =
1747 session->currentOperChannel - 2;
1748 session->ch_width = CH_WIDTH_40MHZ;
1749 } else if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
1750 sme_join_req->cbMode) {
1751 session->ch_center_freq_seg0 =
1752 session->currentOperChannel + 2;
1753 session->ch_width = CH_WIDTH_40MHZ;
1754 } else {
1755 session->ch_center_freq_seg0 = 0;
1756 session->ch_width = CH_WIDTH_20MHZ;
1757 }
1758
1759 /* Record if management frames need to be protected */
1760#ifdef WLAN_FEATURE_11W
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001761 if (eSIR_ED_AES_128_CMAC == sme_join_req->MgmtEncryptionType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001762 session->limRmfEnabled = 1;
Krishna Kumaar Natarajan48de7de2015-12-08 14:43:13 -08001763 else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001764 session->limRmfEnabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001765#endif
1766
1767#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
Krunal Soni0acfdcd2016-03-09 12:03:06 -08001768 session->rssi = bss_desc->rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001769#endif
1770
1771 /* Copy the SSID from smejoinreq to session entry */
1772 session->ssId.length = sme_join_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301773 qdf_mem_copy(session->ssId.ssId, sme_join_req->ssId.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001774 session->ssId.length);
1775
1776 /*
1777 * Determin 11r or ESE connection based on input from SME
1778 * which inturn is dependent on the profile the user wants
1779 * to connect to, So input is coming from supplicant
1780 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001781 session->is11Rconnection = sme_join_req->is11Rconnection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001782#ifdef FEATURE_WLAN_ESE
1783 session->isESEconnection = sme_join_req->isESEconnection;
1784#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001785 session->isFastTransitionEnabled =
1786 sme_join_req->isFastTransitionEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001787
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001788 session->isFastRoamIniFeatureEnabled =
1789 sme_join_req->isFastRoamIniFeatureEnabled;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001790 session->txLdpcIniFeatureEnabled =
1791 sme_join_req->txLdpcIniFeatureEnabled;
1792
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05301793 lim_update_fils_config(session, sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001794 if (session->bssType == eSIR_INFRASTRUCTURE_MODE) {
1795 session->limSystemRole = eLIM_STA_ROLE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001796 } else {
1797 /*
1798 * Throw an error and return and make
1799 * sure to delete the session.
1800 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001801 pe_err("recvd JOIN_REQ with invalid bss type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001802 session->bssType);
1803 ret_code = eSIR_SME_INVALID_PARAMETERS;
1804 goto end;
1805 }
1806
1807 if (sme_join_req->addIEScan.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301808 qdf_mem_copy(&session->pLimJoinReq->addIEScan,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001809 &sme_join_req->addIEScan, sizeof(tSirAddie));
1810
1811 if (sme_join_req->addIEAssoc.length)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301812 qdf_mem_copy(&session->pLimJoinReq->addIEAssoc,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001813 &sme_join_req->addIEAssoc, sizeof(tSirAddie));
1814
1815 val = sizeof(tLimMlmJoinReq) +
1816 session->pLimJoinReq->bssDescription.length + 2;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301817 mlm_join_req = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001818 if (NULL == mlm_join_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001819 pe_err("AllocateMemory failed for mlmJoinReq");
Nitesh Shah0102cac2016-07-13 14:38:30 +05301820 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
1821 goto end;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001822 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001823
1824 /* PE SessionId is stored as a part of JoinReq */
1825 mlm_join_req->sessionId = session->peSessionId;
1826
1827 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_JOIN_FAILURE_TIMEOUT,
1828 (uint32_t *) &mlm_join_req->joinFailureTimeout) !=
1829 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001830 pe_err("couldn't retrieve JoinFailureTimer value"
1831 " setting to default value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001832 mlm_join_req->joinFailureTimeout =
1833 WNI_CFG_JOIN_FAILURE_TIMEOUT_STADEF;
1834 }
1835
1836 /* copy operational rate from session */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301837 qdf_mem_copy((void *)&session->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001838 (void *)&sme_join_req->operationalRateSet,
1839 sizeof(tSirMacRateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301840 qdf_mem_copy((void *)&session->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001841 (void *)&sme_join_req->extendedRateSet,
1842 sizeof(tSirMacRateSet));
1843 /*
1844 * this may not be needed anymore now, as rateSet is now
1845 * included in the session entry and MLM has session context.
1846 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301847 qdf_mem_copy((void *)&mlm_join_req->operationalRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001848 (void *)&session->rateSet,
1849 sizeof(tSirMacRateSet));
1850
1851 session->encryptType = sme_join_req->UCEncryptionType;
1852
1853 mlm_join_req->bssDescription.length =
1854 session->pLimJoinReq->bssDescription.length;
1855
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301856 qdf_mem_copy((uint8_t *) &mlm_join_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001857 (uint8_t *)
1858 &session->pLimJoinReq->bssDescription.bssId,
1859 session->pLimJoinReq->bssDescription.length + 2);
1860
1861 session->limCurrentBssCaps =
1862 session->pLimJoinReq->bssDescription.capabilityInfo;
1863
1864 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
1865 session->currentOperChannel);
1866 local_power_constraint = reg_max;
1867
1868 lim_extract_ap_capability(mac_ctx,
1869 (uint8_t *)
1870 session->pLimJoinReq->bssDescription.ieFields,
1871 lim_get_ielen_from_bss_description(
1872 &session->pLimJoinReq->bssDescription),
1873 &session->limCurrentBssQosCaps,
1874 &session->limCurrentBssPropCap,
1875 &session->gLimCurrentBssUapsd,
1876 &local_power_constraint, session);
1877
Krunal Soni53993f72016-07-08 18:20:03 -07001878 /*
1879 * Once the AP capabilities are available then set the
1880 * beam forming capabilities accordingly.
1881 */
1882 if (session->nss == 1) {
1883 session->vht_config.su_beam_former = 0;
1884 session->vht_config.tx_stbc = 0;
1885 session->vht_config.num_soundingdim = 0;
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +05301886 session->htConfig.ht_tx_stbc = 0;
Krunal Soni53993f72016-07-08 18:20:03 -07001887 }
1888
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001889 session->maxTxPower = lim_get_max_tx_power(reg_max,
1890 local_power_constraint,
1891 mac_ctx->roam.configParam.nTxPowerCap);
Padma, Santhosh Kumar29df3622016-08-16 19:15:16 +05301892
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001893 pe_debug("Reg max %d local power con %d max tx pwr %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05301894 reg_max, local_power_constraint, session->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001895
Agrawal Ashish1fdcbb62017-03-10 17:48:57 +05301896 if (sme_join_req->powerCap.maxTxPower > session->maxTxPower) {
1897 sme_join_req->powerCap.maxTxPower = session->maxTxPower;
1898 pe_debug("Update MaxTxPower in join Req to %d",
1899 sme_join_req->powerCap.maxTxPower);
1900 }
1901
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001902 if (session->gLimCurrentBssUapsd) {
1903 session->gUapsdPerAcBitmask =
1904 session->pLimJoinReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001905 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001906 session->gUapsdPerAcBitmask);
1907
1908 /* resetting the dynamic uapsd mask */
1909 session->gUapsdPerAcDeliveryEnableMask = 0;
1910 session->gUapsdPerAcTriggerEnableMask = 0;
1911 }
1912
1913 session->limRFBand =
1914 lim_get_rf_band(session->currentOperChannel);
1915
1916 /* Initialize 11h Enable Flag */
1917 if (SIR_BAND_5_GHZ == session->limRFBand) {
1918 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED,
1919 &val) != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001920 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001921 session->lim11hEnable =
1922 WNI_CFG_11H_ENABLED_STADEF;
1923 } else {
1924 session->lim11hEnable = val;
1925 }
1926 } else {
1927 session->lim11hEnable = 0;
1928 }
1929
1930 /*
1931 * To care of the scenario when STA transitions from
1932 * IBSS to Infrastructure mode.
1933 */
1934 mac_ctx->lim.gLimIbssCoalescingHappened = false;
1935
1936 session->limPrevSmeState = session->limSmeState;
1937 session->limSmeState = eLIM_SME_WT_JOIN_STATE;
1938 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
1939 session->peSessionId,
1940 session->limSmeState));
1941
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001942 /* Indicate whether spectrum management is enabled */
1943 session->spectrumMgtEnabled =
1944 sme_join_req->spectrumMgtIndicator;
1945
1946 /* Enable the spectrum management if this is a DFS channel */
1947 if (session->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001948 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001949 session->currentOperChannel))
1950 session->spectrumMgtEnabled = true;
1951
1952 session->isOSENConnection = sme_join_req->isOSENConnection;
1953
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001954 /* Issue LIM_MLM_JOIN_REQ to MLM */
1955 lim_post_mlm_message(mac_ctx, LIM_MLM_JOIN_REQ,
1956 (uint32_t *) mlm_join_req);
1957 return;
1958
1959 } else {
1960 /* Received eWNI_SME_JOIN_REQ un expected state */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001961 pe_err("received unexpected SME_JOIN_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001962 mac_ctx->lim.gLimSmeState);
1963 lim_print_sme_state(mac_ctx, LOGE, mac_ctx->lim.gLimSmeState);
1964 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
1965 session = NULL;
1966 goto end;
1967 }
1968
1969end:
Nitesh Shah0102cac2016-07-13 14:38:30 +05301970 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
1971 &sme_session_id, &sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001972
1973 if (sme_join_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301974 qdf_mem_free(sme_join_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001975 sme_join_req = NULL;
1976 if (NULL != session)
1977 session->pLimJoinReq = NULL;
1978 }
1979 if (ret_code != eSIR_SME_SUCCESS) {
1980 if (NULL != session) {
1981 pe_delete_session(mac_ctx, session);
1982 session = NULL;
1983 }
1984 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07001985 pe_debug("Send failure status on sessionid: %d with ret_code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001986 sme_session_id, ret_code);
1987 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_JOIN_RSP, ret_code,
1988 eSIR_MAC_UNSPEC_FAILURE_STATUS, session, sme_session_id,
1989 sme_transaction_id);
1990}
1991
Amar Singhala297bfa2015-10-15 15:07:29 -07001992uint8_t lim_get_max_tx_power(int8_t regMax, int8_t apTxPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001993 uint8_t iniTxPower)
1994{
1995 uint8_t maxTxPower = 0;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301996 uint8_t txPower = QDF_MIN(regMax, (apTxPower));
1997 txPower = QDF_MIN(txPower, iniTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001998 if ((txPower >= MIN_TX_PWR_CAP) && (txPower <= MAX_TX_PWR_CAP))
1999 maxTxPower = txPower;
2000 else if (txPower < MIN_TX_PWR_CAP)
2001 maxTxPower = MIN_TX_PWR_CAP;
2002 else
2003 maxTxPower = MAX_TX_PWR_CAP;
2004
2005 return maxTxPower;
2006}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002007
2008/**
2009 * __lim_process_sme_reassoc_req() - process reassoc req
2010 *
2011 * @mac_ctx: Pointer to Global MAC structure
2012 * @msg_buf: pointer to the SME message buffer
2013 *
2014 * This function is called to process SME_REASSOC_REQ message
2015 * from HDD or upper layer application.
2016 *
2017 * Return: None
2018 */
2019
2020static void __lim_process_sme_reassoc_req(tpAniSirGlobal mac_ctx,
2021 uint32_t *msg_buf)
2022{
2023 uint16_t caps;
2024 uint32_t val;
2025 tpSirSmeJoinReq reassoc_req = NULL;
2026 tLimMlmReassocReq *mlm_reassoc_req;
2027 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2028 tpPESession session_entry = NULL;
2029 uint8_t session_id;
2030 uint8_t sme_session_id;
2031 uint16_t transaction_id;
Amar Singhala297bfa2015-10-15 15:07:29 -07002032 int8_t local_pwr_constraint = 0, reg_max = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002033 uint32_t tele_bcn_en = 0;
2034 uint16_t size;
2035
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002036 size = __lim_get_sme_join_req_size_for_alloc((uint8_t *)msg_buf);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302037 reassoc_req = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002038 if (NULL == reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002039 pe_err("call to AllocateMemory failed for reassoc_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002040
2041 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2042 goto end;
2043 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302044 (void)qdf_mem_copy((void *)reassoc_req, (void *)msg_buf, size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002045
2046 if (!lim_is_sme_join_req_valid(mac_ctx,
2047 (tpSirSmeJoinReq)reassoc_req)) {
2048 /*
2049 * Received invalid eWNI_SME_REASSOC_REQ
2050 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002051 pe_warn("received SME_REASSOC_REQ with invalid data");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002052
2053 ret_code = eSIR_SME_INVALID_PARAMETERS;
2054 goto end;
2055 }
2056
2057 session_entry = pe_find_session_by_bssid(mac_ctx,
2058 reassoc_req->bssDescription.bssId,
2059 &session_id);
2060 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002061 pe_err("Session does not exist for given bssId");
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07002062 lim_print_mac_addr(mac_ctx, reassoc_req->bssDescription.bssId,
2063 LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002064 ret_code = eSIR_SME_INVALID_PARAMETERS;
Varun Reddy Yeturu658b8022016-09-23 11:10:42 -07002065 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf,
2066 &sme_session_id, &transaction_id);
2067 session_entry =
2068 pe_find_session_by_sme_session_id(mac_ctx,
2069 sme_session_id);
2070 if (session_entry != NULL)
2071 lim_handle_sme_join_result(mac_ctx,
2072 eSIR_SME_INVALID_PARAMETERS,
2073 eSIR_MAC_UNSPEC_FAILURE_STATUS,
2074 session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002075 goto end;
2076 }
2077#ifdef FEATURE_WLAN_DIAG_SUPPORT /* FEATURE_WLAN_DIAG_SUPPORT */
2078 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_REQ_EVENT,
2079 session_entry, eSIR_SUCCESS, eSIR_SUCCESS);
2080#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2081 /* mac_ctx->lim.gpLimReassocReq = reassoc_req;//TO SUPPORT BT-AMP */
2082
2083 /* Store the reassoc handle in the session Table */
2084 session_entry->pLimReAssocReq = reassoc_req;
2085
2086 session_entry->dot11mode = reassoc_req->dot11mode;
2087 session_entry->vhtCapability =
2088 IS_DOT11_MODE_VHT(reassoc_req->dot11mode);
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002089
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302090 if (session_entry->vhtCapability) {
2091 if (session_entry->pePersona == QDF_STA_MODE) {
2092 session_entry->vht_config.su_beam_formee =
2093 reassoc_req->vht_config.su_beam_formee;
2094 } else {
2095 reassoc_req->vht_config.su_beam_formee = 0;
2096 }
2097 session_entry->enableVhtpAid =
2098 reassoc_req->enableVhtpAid;
2099 session_entry->enableVhtGid =
2100 reassoc_req->enableVhtGid;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002101 pe_debug("vht su bformer [%d]", session_entry->vht_config.su_beam_former);
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302102 }
2103
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002104 pe_debug("vhtCapability: %d su_beam_formee: %d su_tx_bformer %d",
Padma, Santhosh Kumar429553d2016-08-08 18:49:31 +05302105 session_entry->vhtCapability,
2106 session_entry->vht_config.su_beam_formee,
2107 session_entry->vht_config.su_beam_former);
2108
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002109 session_entry->enableHtSmps = reassoc_req->enableHtSmps;
2110 session_entry->htSmpsvalue = reassoc_req->htSmps;
Archana Ramachandranfec24812016-02-16 16:31:56 -08002111 session_entry->send_smps_action =
2112 reassoc_req->send_smps_action;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002113 pe_debug("enableHtSmps: %d htSmps: %d send action: %d supported nss 1x1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -08002114 session_entry->enableHtSmps,
Archana Ramachandranfec24812016-02-16 16:31:56 -08002115 session_entry->htSmpsvalue,
Archana Ramachandran5482d6a2016-03-29 17:09:22 -07002116 session_entry->send_smps_action,
2117 session_entry->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002118 /*
2119 * Reassociate request is expected
2120 * in link established state only.
2121 */
2122
2123 if (session_entry->limSmeState != eLIM_SME_LINK_EST_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002124 if (session_entry->limSmeState == eLIM_SME_WT_REASSOC_STATE) {
2125 /*
2126 * May be from 11r FT pre-auth. So lets check it
2127 * before we bail out
2128 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002129 pe_debug("Session in reassoc state is %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002130 session_entry->peSessionId);
2131
2132 /* Make sure its our preauth bssid */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302133 if (qdf_mem_cmp(reassoc_req->bssDescription.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002134 session_entry->limReAssocbssId,
2135 6)) {
2136 lim_print_mac_addr(mac_ctx,
2137 reassoc_req->bssDescription.
2138 bssId, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002139 pe_err("Unknown bssId in reassoc state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002140 ret_code = eSIR_SME_INVALID_PARAMETERS;
2141 goto end;
2142 }
2143
2144 lim_process_mlm_ft_reassoc_req(mac_ctx, msg_buf,
2145 session_entry);
2146 return;
2147 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002148 /*
2149 * Should not have received eWNI_SME_REASSOC_REQ
2150 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002151 pe_err("received unexpected SME_REASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002152 session_entry->limSmeState);
2153 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2154
2155 ret_code = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2156 goto end;
2157 }
2158
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302159 qdf_mem_copy(session_entry->limReAssocbssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002160 session_entry->pLimReAssocReq->bssDescription.bssId,
2161 sizeof(tSirMacAddr));
2162
2163 session_entry->limReassocChannelId =
2164 session_entry->pLimReAssocReq->bssDescription.channelId;
2165
2166 session_entry->reAssocHtSupportedChannelWidthSet =
2167 (session_entry->pLimReAssocReq->cbMode) ? 1 : 0;
2168 session_entry->reAssocHtRecommendedTxWidthSet =
2169 session_entry->reAssocHtSupportedChannelWidthSet;
2170 session_entry->reAssocHtSecondaryChannelOffset =
2171 session_entry->pLimReAssocReq->cbMode;
2172
2173 session_entry->limReassocBssCaps =
2174 session_entry->pLimReAssocReq->bssDescription.capabilityInfo;
2175 reg_max = cfg_get_regulatory_max_transmit_power(mac_ctx,
2176 session_entry->currentOperChannel);
2177 local_pwr_constraint = reg_max;
2178
2179 lim_extract_ap_capability(mac_ctx,
2180 (uint8_t *)session_entry->pLimReAssocReq->bssDescription.ieFields,
2181 lim_get_ielen_from_bss_description(
2182 &session_entry->pLimReAssocReq->bssDescription),
2183 &session_entry->limReassocBssQosCaps,
2184 &session_entry->limReassocBssPropCap,
2185 &session_entry->gLimCurrentBssUapsd,
2186 &local_pwr_constraint, session_entry);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302187 session_entry->maxTxPower = QDF_MIN(reg_max, (local_pwr_constraint));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002188 pe_err("Reg max = %d, local pwr constraint = %d, max tx = %d",
Varun Reddy Yeturu0e3989a2016-04-15 13:30:42 +05302189 reg_max, local_pwr_constraint, session_entry->maxTxPower);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002190 /* Copy the SSID from session entry to local variable */
2191 session_entry->limReassocSSID.length = reassoc_req->ssId.length;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302192 qdf_mem_copy(session_entry->limReassocSSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002193 reassoc_req->ssId.ssId,
2194 session_entry->limReassocSSID.length);
2195 if (session_entry->gLimCurrentBssUapsd) {
2196 session_entry->gUapsdPerAcBitmask =
2197 session_entry->pLimReAssocReq->uapsdPerAcBitmask;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002198 pe_debug("UAPSD flag for all AC - 0x%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002199 session_entry->gUapsdPerAcBitmask);
2200 }
2201
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302202 mlm_reassoc_req = qdf_mem_malloc(sizeof(tLimMlmReassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002203 if (NULL == mlm_reassoc_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002204 pe_err("call to AllocateMemory failed for mlmReassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002205
2206 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2207 goto end;
2208 }
2209
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302210 qdf_mem_copy(mlm_reassoc_req->peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002211 session_entry->limReAssocbssId, sizeof(tSirMacAddr));
2212
2213 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_REASSOCIATION_FAILURE_TIMEOUT,
2214 (uint32_t *)&mlm_reassoc_req->reassocFailureTimeout) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002215 eSIR_SUCCESS)
2216 pe_err("could not retrieve ReassocFailureTimeout value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002217
2218 if (cfg_get_capability_info(mac_ctx, &caps, session_entry) !=
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002219 eSIR_SUCCESS)
2220 pe_err("could not retrieve Capabilities value");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302221
2222 lim_update_caps_info_for_bss(mac_ctx, &caps,
2223 reassoc_req->bssDescription.capabilityInfo);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002224 pe_debug("Capabilities info Reassoc: 0x%X", caps);
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05302225
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002226 mlm_reassoc_req->capabilityInfo = caps;
2227
2228 /* Update PE session_id */
2229 mlm_reassoc_req->sessionId = session_id;
2230
2231 /*
2232 * If telescopic beaconing is enabled, set listen interval to
2233 * WNI_CFG_TELE_BCN_MAX_LI
2234 */
2235 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_WAKEUP_EN,
2236 &tele_bcn_en) != eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002237 pe_err("Couldn't get WNI_CFG_TELE_BCN_WAKEUP_EN");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002238
2239 val = WNI_CFG_LISTEN_INTERVAL_STADEF;
2240
2241 if (tele_bcn_en) {
2242 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_TELE_BCN_MAX_LI, &val) !=
2243 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002244 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002245 } else {
2246 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_LISTEN_INTERVAL, &val) !=
2247 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002248 pe_err("could not retrieve ListenInterval");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002249 }
2250
2251 mlm_reassoc_req->listenInterval = (uint16_t) val;
2252
2253 /* Indicate whether spectrum management is enabled */
2254 session_entry->spectrumMgtEnabled = reassoc_req->spectrumMgtIndicator;
2255
2256 /* Enable the spectrum management if this is a DFS channel */
2257 if (session_entry->country_info_present &&
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002258 lim_isconnected_on_dfs_channel(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002259 session_entry->currentOperChannel))
2260 session_entry->spectrumMgtEnabled = true;
2261
2262 session_entry->limPrevSmeState = session_entry->limSmeState;
2263 session_entry->limSmeState = eLIM_SME_WT_REASSOC_STATE;
2264
2265 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2266 session_entry->peSessionId,
2267 session_entry->limSmeState));
2268
2269 lim_post_mlm_message(mac_ctx,
2270 LIM_MLM_REASSOC_REQ, (uint32_t *)mlm_reassoc_req);
2271 return;
2272end:
2273 if (reassoc_req) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302274 qdf_mem_free(reassoc_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002275 if (session_entry)
2276 session_entry->pLimReAssocReq = NULL;
2277 }
2278
2279 if (session_entry) {
2280 /*
2281 * error occurred after we determined the session so extract
2282 * session and transaction info from there
2283 */
2284 sme_session_id = session_entry->smeSessionId;
2285 transaction_id = session_entry->transactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002286 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002287 /*
2288 * error occurred before or during the time we determined
2289 * the session so extract the session and transaction info
2290 * from the message
2291 */
2292 lim_get_session_info(mac_ctx, (uint8_t *) msg_buf,
2293 &sme_session_id, &transaction_id);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002294 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002295 /*
2296 * Send Reassoc failure response to host
2297 * (note session_entry may be NULL, but that's OK)
2298 */
2299 lim_send_sme_join_reassoc_rsp(mac_ctx, eWNI_SME_REASSOC_RSP,
2300 ret_code, eSIR_MAC_UNSPEC_FAILURE_STATUS,
2301 session_entry, sme_session_id,
2302 transaction_id);
2303}
2304
2305bool send_disassoc_frame = 1;
2306/**
2307 * __lim_process_sme_disassoc_req()
2308 *
2309 ***FUNCTION:
2310 * This function is called to process SME_DISASSOC_REQ message
2311 * from HDD or upper layer application.
2312 *
2313 ***LOGIC:
2314 *
2315 ***ASSUMPTIONS:
2316 *
2317 ***NOTE:
2318 *
2319 * @param pMac Pointer to Global MAC structure
2320 * @param *pMsgBuf A pointer to the SME message buffer
2321 * @return None
2322 */
2323
2324static void __lim_process_sme_disassoc_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2325{
2326 uint16_t disassocTrigger, reasonCode;
2327 tLimMlmDisassocReq *pMlmDisassocReq;
2328 tSirResultCodes retCode = eSIR_SME_SUCCESS;
2329 tSirSmeDisassocReq smeDisassocReq;
2330 tpPESession psessionEntry = NULL;
2331 uint8_t sessionId;
2332 uint8_t smesessionId;
2333 uint16_t smetransactionId;
2334
2335 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002336 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002337 return;
2338 }
2339
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302340 qdf_mem_copy(&smeDisassocReq, pMsgBuf, sizeof(tSirSmeDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002341 smesessionId = smeDisassocReq.sessionId;
2342 smetransactionId = smeDisassocReq.transactionId;
2343 if (!lim_is_sme_disassoc_req_valid(pMac,
2344 &smeDisassocReq,
2345 psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002346 pe_err("received invalid SME_DISASSOC_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002347 if (pMac->lim.gLimRspReqd) {
2348 pMac->lim.gLimRspReqd = false;
2349
2350 retCode = eSIR_SME_INVALID_PARAMETERS;
2351 disassocTrigger = eLIM_HOST_DISASSOC;
2352 goto sendDisassoc;
2353 }
2354
2355 return;
2356 }
2357
2358 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002359 smeDisassocReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002360 &sessionId);
2361 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002362 pe_err("session does not exist for given bssId "
2363 MAC_ADDRESS_STR,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002364 MAC_ADDR_ARRAY(smeDisassocReq.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002365 retCode = eSIR_SME_INVALID_PARAMETERS;
2366 disassocTrigger = eLIM_HOST_DISASSOC;
2367 goto sendDisassoc;
2368 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002369 pe_debug("received DISASSOC_REQ message on sessionid %d Systemrole %d Reason: %u SmeState: %d from: "
2370 MAC_ADDRESS_STR, smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002371 GET_LIM_SYSTEM_ROLE(psessionEntry), smeDisassocReq.reasonCode,
2372 pMac->lim.gLimSmeState,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002373 MAC_ADDR_ARRAY(smeDisassocReq.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002374
2375#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2376 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_REQ_EVENT, psessionEntry,
2377 0, smeDisassocReq.reasonCode);
2378#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2379
2380 /* Update SME session Id and SME transaction ID */
2381
2382 psessionEntry->smeSessionId = smesessionId;
2383 psessionEntry->transactionId = smetransactionId;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002384 pe_debug("ho_fail: %d ", smeDisassocReq.process_ho_fail);
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002385 psessionEntry->process_ho_fail = smeDisassocReq.process_ho_fail;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002386
2387 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2388 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002389 switch (psessionEntry->limSmeState) {
2390 case eLIM_SME_ASSOCIATED_STATE:
2391 case eLIM_SME_LINK_EST_STATE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002392 pe_debug("Rcvd SME_DISASSOC_REQ in limSmeState: %d ",
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002393 psessionEntry->limSmeState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002394 psessionEntry->limPrevSmeState =
2395 psessionEntry->limSmeState;
2396 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002397 /* Delete all TDLS peers connected before leaving BSS */
2398 lim_delete_tdls_peers(pMac, psessionEntry);
Vidyullatha Kanchanapally3554e4e2015-08-12 12:43:18 -07002399 MTRACE(mac_trace(pMac, TRACE_CODE_SME_STATE,
2400 psessionEntry->peSessionId,
2401 psessionEntry->limSmeState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002402 break;
2403
2404 case eLIM_SME_WT_DEAUTH_STATE:
2405 /* PE shall still process the DISASSOC_REQ and proceed with
2406 * link tear down even if it had already sent a DEAUTH_IND to
2407 * to SME. pMac->lim.gLimPrevSmeState shall remain the same as
2408 * its been set when PE entered WT_DEAUTH_STATE.
2409 */
2410 psessionEntry->limSmeState = eLIM_SME_WT_DISASSOC_STATE;
2411 MTRACE(mac_trace
2412 (pMac, TRACE_CODE_SME_STATE,
2413 psessionEntry->peSessionId,
2414 psessionEntry->limSmeState));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002415 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002416 break;
2417
2418 case eLIM_SME_WT_DISASSOC_STATE:
2419 /* PE Recieved a Disassoc frame. Normally it gets DISASSOC_CNF but it
2420 * received DISASSOC_REQ. Which means host is also trying to disconnect.
2421 * PE can continue processing DISASSOC_REQ and send the response instead
2422 * of failing the request. SME will anyway ignore DEAUTH_IND that was sent
2423 * for disassoc frame.
2424 *
2425 * It will send a disassoc, which is ok. However, we can use the global flag
2426 * sendDisassoc to not send disassoc frame.
2427 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002428 pe_debug("Rcvd SME_DISASSOC_REQ while in SME_WT_DISASSOC_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002429 break;
2430
2431 case eLIM_SME_JOIN_FAILURE_STATE: {
2432 /* Already in Disconnected State, return success */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002433 pe_debug("Rcvd SME_DISASSOC_REQ while in eLIM_SME_JOIN_FAILURE_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002434 if (pMac->lim.gLimRspReqd) {
2435 retCode = eSIR_SME_SUCCESS;
2436 disassocTrigger = eLIM_HOST_DISASSOC;
2437 goto sendDisassoc;
2438 }
2439 }
2440 break;
2441 default:
2442 /**
2443 * STA is not currently associated.
2444 * Log error and send response to host
2445 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002446 pe_err("received unexpected SME_DISASSOC_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002447 psessionEntry->limSmeState);
2448 lim_print_sme_state(pMac, LOGE,
2449 psessionEntry->limSmeState);
2450
2451 if (pMac->lim.gLimRspReqd) {
2452 if (psessionEntry->limSmeState !=
2453 eLIM_SME_WT_ASSOC_STATE)
2454 pMac->lim.gLimRspReqd = false;
2455
2456 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2457 disassocTrigger = eLIM_HOST_DISASSOC;
2458 goto sendDisassoc;
2459 }
2460
2461 return;
2462 }
2463
2464 break;
2465
2466 case eLIM_AP_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002467 /* Fall through */
2468 break;
2469
2470 case eLIM_STA_IN_IBSS_ROLE:
2471 default:
2472 /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002473 pe_err("received unexpected SME_DISASSOC_REQ for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002474 GET_LIM_SYSTEM_ROLE(psessionEntry));
2475
2476 retCode = eSIR_SME_UNEXPECTED_REQ_RESULT_CODE;
2477 disassocTrigger = eLIM_HOST_DISASSOC;
2478 goto sendDisassoc;
2479 } /* end switch (pMac->lim.gLimSystemRole) */
2480
Edhar, Mahesh Kumare3c8d352015-11-16 12:03:45 +05302481 disassocTrigger = eLIM_HOST_DISASSOC;
2482 reasonCode = smeDisassocReq.reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002483
2484 if (smeDisassocReq.doNotSendOverTheAir) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002485 pe_debug("do not send dissoc over the air");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002486 send_disassoc_frame = 0;
2487 }
2488 /* Trigger Disassociation frame to peer MAC entity */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002489 pe_debug("Sending Disasscoc with disassoc Trigger"
2490 " : %d, reasonCode : %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002491 disassocTrigger, reasonCode);
2492
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302493 pMlmDisassocReq = qdf_mem_malloc(sizeof(tLimMlmDisassocReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002494 if (NULL == pMlmDisassocReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002495 pe_err("call to AllocateMemory failed for mlmDisassocReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002496 return;
2497 }
2498
Anurag Chouhanc5548422016-02-24 18:33:27 +05302499 qdf_copy_macaddr(&pMlmDisassocReq->peer_macaddr,
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002500 &smeDisassocReq.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002501
2502 pMlmDisassocReq->reasonCode = reasonCode;
2503 pMlmDisassocReq->disassocTrigger = disassocTrigger;
2504
2505 /* Update PE session ID */
2506 pMlmDisassocReq->sessionId = sessionId;
2507
2508 lim_post_mlm_message(pMac,
2509 LIM_MLM_DISASSOC_REQ, (uint32_t *) pMlmDisassocReq);
2510 return;
2511
2512sendDisassoc:
2513 if (psessionEntry)
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002514 lim_send_sme_disassoc_ntf(pMac,
2515 smeDisassocReq.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002516 retCode,
2517 disassocTrigger,
2518 1, smesessionId, smetransactionId,
2519 psessionEntry);
2520 else
Srinivas Girigowda1a245362016-01-05 22:43:30 -08002521 lim_send_sme_disassoc_ntf(pMac,
2522 smeDisassocReq.peer_macaddr.bytes,
2523 retCode, disassocTrigger, 1,
2524 smesessionId, smetransactionId, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002525
2526} /*** end __lim_process_sme_disassoc_req() ***/
2527
2528/** -----------------------------------------------------------------
2529 \brief __lim_process_sme_disassoc_cnf() - Process SME_DISASSOC_CNF
2530
2531 This function is called to process SME_DISASSOC_CNF message
2532 from HDD or upper layer application.
2533
2534 \param pMac - global mac structure
2535 \param pStaDs - station dph hash node
2536 \return none
2537 \sa
2538 ----------------------------------------------------------------- */
2539static void __lim_process_sme_disassoc_cnf(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
2540{
2541 tSirSmeDisassocCnf smeDisassocCnf;
2542 uint16_t aid;
2543 tpDphHashNode pStaDs;
2544 tpPESession psessionEntry;
2545 uint8_t sessionId;
2546
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302547 qdf_mem_copy(&smeDisassocCnf, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002548 sizeof(struct sSirSmeDisassocCnf));
2549
2550 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002551 smeDisassocCnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002552 &sessionId);
2553 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002554 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002555 return;
2556 }
2557
2558 if (!lim_is_sme_disassoc_cnf_valid(pMac, &smeDisassocCnf, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002559 pe_err("received invalid SME_DISASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002560 return;
2561 }
2562#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2563 if (smeDisassocCnf.messageType == eWNI_SME_DISASSOC_CNF)
2564 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_CNF_EVENT,
2565 psessionEntry,
2566 (uint16_t) smeDisassocCnf.statusCode, 0);
2567 else if (smeDisassocCnf.messageType == eWNI_SME_DEAUTH_CNF)
2568 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_CNF_EVENT,
2569 psessionEntry,
2570 (uint16_t) smeDisassocCnf.statusCode, 0);
2571#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2572
2573 switch (GET_LIM_SYSTEM_ROLE(psessionEntry)) {
2574 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002575 if ((psessionEntry->limSmeState != eLIM_SME_IDLE_STATE) &&
2576 (psessionEntry->limSmeState != eLIM_SME_WT_DISASSOC_STATE)
2577 && (psessionEntry->limSmeState !=
2578 eLIM_SME_WT_DEAUTH_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002579 pe_err("received unexp SME_DISASSOC_CNF in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002580 psessionEntry->limSmeState);
2581 lim_print_sme_state(pMac, LOGE,
2582 psessionEntry->limSmeState);
2583 return;
2584 }
2585 break;
2586
2587 case eLIM_AP_ROLE:
2588 /* Fall through */
2589 break;
2590
2591 case eLIM_STA_IN_IBSS_ROLE:
2592 default: /* eLIM_UNKNOWN_ROLE */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002593 pe_err("received unexpected SME_DISASSOC_CNF role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002594 GET_LIM_SYSTEM_ROLE(psessionEntry));
2595
2596 return;
2597 }
2598
2599 if ((psessionEntry->limSmeState == eLIM_SME_WT_DISASSOC_STATE) ||
2600 (psessionEntry->limSmeState == eLIM_SME_WT_DEAUTH_STATE) ||
2601 LIM_IS_AP_ROLE(psessionEntry)) {
2602 pStaDs = dph_lookup_hash_entry(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002603 smeDisassocCnf.peer_macaddr.bytes, &aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002604 &psessionEntry->dph.dphHashTable);
2605 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002606 pe_err("DISASSOC_CNF for a STA with no context, addr= "
2607 MAC_ADDRESS_STR,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002608 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002609 return;
2610 }
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302611
2612 if ((pStaDs->mlmStaContext.mlmState ==
2613 eLIM_MLM_WT_DEL_STA_RSP_STATE) ||
2614 (pStaDs->mlmStaContext.mlmState ==
2615 eLIM_MLM_WT_DEL_STA_RSP_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002616 pe_err("No need of cleanup for addr:" MAC_ADDRESS_STR "as MLM state is %d",
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002617 MAC_ADDR_ARRAY(smeDisassocCnf.peer_macaddr.bytes),
Masti, Narayanraddi21bde252015-10-09 19:39:47 +05302618 pStaDs->mlmStaContext.mlmState);
2619 return;
2620 }
2621
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002622 /* Delete FT session if there exists one */
2623 lim_ft_cleanup_pre_auth_info(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002624 lim_cleanup_rx_path(pMac, pStaDs, psessionEntry);
2625
2626 lim_clean_up_disassoc_deauth_req(pMac,
Srinivas Girigowda5f3c81a2016-01-04 21:47:19 -08002627 (char *)&smeDisassocCnf.peer_macaddr, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002628 }
2629
2630 return;
2631}
2632
2633/**
2634 * __lim_process_sme_deauth_req() - process sme deauth req
2635 * @mac_ctx: Pointer to Global MAC structure
2636 * @msg_buf: pointer to the SME message buffer
2637 *
2638 * This function is called to process SME_DEAUTH_REQ message
2639 * from HDD or upper layer application.
2640 *
2641 * Return: None
2642 */
2643
2644static void __lim_process_sme_deauth_req(tpAniSirGlobal mac_ctx,
2645 uint32_t *msg_buf)
2646{
2647 uint16_t deauth_trigger, reason_code;
2648 tLimMlmDeauthReq *mlm_deauth_req;
2649 tSirSmeDeauthReq sme_deauth_req;
2650 tSirResultCodes ret_code = eSIR_SME_SUCCESS;
2651 tpPESession session_entry;
2652 uint8_t session_id; /* PE sessionId */
2653 uint8_t sme_session_id;
2654 uint16_t sme_transaction_id;
2655
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302656 qdf_mem_copy(&sme_deauth_req, msg_buf, sizeof(tSirSmeDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002657 sme_session_id = sme_deauth_req.sessionId;
2658 sme_transaction_id = sme_deauth_req.transactionId;
2659
2660 /*
2661 * We need to get a session first but we don't even know
2662 * if the message is correct.
2663 */
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002664 session_entry = pe_find_session_by_bssid(mac_ctx,
2665 sme_deauth_req.bssid.bytes,
2666 &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002667 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002668 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002669 ret_code = eSIR_SME_INVALID_PARAMETERS;
2670 deauth_trigger = eLIM_HOST_DEAUTH;
2671 goto send_deauth;
2672 }
2673
2674 if (!lim_is_sme_deauth_req_valid(mac_ctx, &sme_deauth_req,
2675 session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002676 pe_err("received invalid SME_DEAUTH_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002677 mac_ctx->lim.gLimRspReqd = false;
2678
2679 ret_code = eSIR_SME_INVALID_PARAMETERS;
2680 deauth_trigger = eLIM_HOST_DEAUTH;
2681 goto send_deauth;
2682 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002683 pe_debug("received DEAUTH_REQ sessionid %d Systemrole %d reasoncode %u limSmestate %d from "
2684 MAC_ADDRESS_STR, sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002685 GET_LIM_SYSTEM_ROLE(session_entry), sme_deauth_req.reasonCode,
2686 session_entry->limSmeState,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002687 MAC_ADDR_ARRAY(sme_deauth_req.peer_macaddr.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002688#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2689 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_DEAUTH_REQ_EVENT,
2690 session_entry, 0, sme_deauth_req.reasonCode);
2691#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2692
2693 /* Update SME session ID and Transaction ID */
2694 session_entry->smeSessionId = sme_session_id;
2695 session_entry->transactionId = sme_transaction_id;
2696
2697 switch (GET_LIM_SYSTEM_ROLE(session_entry)) {
2698 case eLIM_STA_ROLE:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002699 switch (session_entry->limSmeState) {
2700 case eLIM_SME_ASSOCIATED_STATE:
2701 case eLIM_SME_LINK_EST_STATE:
Ganesh Kondabattini9d3d3b12017-03-15 16:20:19 +05302702 /* Delete all TDLS peers connected before leaving BSS */
2703 lim_delete_tdls_peers(mac_ctx, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002704 case eLIM_SME_WT_ASSOC_STATE:
2705 case eLIM_SME_JOIN_FAILURE_STATE:
2706 case eLIM_SME_IDLE_STATE:
2707 session_entry->limPrevSmeState =
2708 session_entry->limSmeState;
2709 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
2710 MTRACE(mac_trace(mac_ctx, TRACE_CODE_SME_STATE,
2711 session_entry->peSessionId,
2712 session_entry->limSmeState));
2713 /* Send Deauthentication request to MLM below */
2714 break;
2715 case eLIM_SME_WT_DEAUTH_STATE:
2716 case eLIM_SME_WT_DISASSOC_STATE:
2717 /*
2718 * PE Recieved a Deauth/Disassoc frame. Normally it get
2719 * DEAUTH_CNF/DISASSOC_CNF but it received DEAUTH_REQ.
2720 * Which means host is also trying to disconnect.
2721 * PE can continue processing DEAUTH_REQ and send
2722 * the response instead of failing the request.
2723 * SME will anyway ignore DEAUTH_IND/DISASSOC_IND that
2724 * was sent for deauth/disassoc frame.
2725 */
2726 session_entry->limSmeState = eLIM_SME_WT_DEAUTH_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002727 pe_debug("Rcvd SME_DEAUTH_REQ while in SME_WT_DEAUTH_STATE");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002728 break;
2729 default:
2730 /*
2731 * STA is not in a state to deauthenticate with
2732 * peer. Log error and send response to host.
2733 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002734 pe_err("received unexp SME_DEAUTH_REQ in state %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002735 session_entry->limSmeState);
2736 lim_print_sme_state(mac_ctx, LOGE,
2737 session_entry->limSmeState);
2738
2739 if (mac_ctx->lim.gLimRspReqd) {
2740 mac_ctx->lim.gLimRspReqd = false;
2741
2742 ret_code = eSIR_SME_STA_NOT_AUTHENTICATED;
2743 deauth_trigger = eLIM_HOST_DEAUTH;
2744
wadesong42968e92017-06-08 14:11:21 +08002745 /*
2746 * here we received deauth request from AP so
2747 * sme state is eLIM_SME_WT_DEAUTH_STATE.if we
2748 * have ISSUED delSta then mlm state should be
2749 * eLIM_MLM_WT_DEL_STA_RSP_STATE and ifwe got
2750 * delBSS rsp then mlm state should be
2751 * eLIM_MLM_IDLE_STATE so the below condition
2752 * captures the state where delSta not done
2753 * and firmware still in connected state.
2754 */
2755 if (session_entry->limSmeState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002756 eLIM_SME_WT_DEAUTH_STATE &&
2757 session_entry->limMlmState !=
2758 eLIM_MLM_IDLE_STATE &&
2759 session_entry->limMlmState !=
2760 eLIM_MLM_WT_DEL_STA_RSP_STATE)
wadesong42968e92017-06-08 14:11:21 +08002761 ret_code = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002762 goto send_deauth;
2763 }
2764 return;
2765 }
2766 break;
2767
2768 case eLIM_STA_IN_IBSS_ROLE:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002769 pe_err("Deauth not allowed in IBSS");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002770 if (mac_ctx->lim.gLimRspReqd) {
2771 mac_ctx->lim.gLimRspReqd = false;
2772 ret_code = eSIR_SME_INVALID_PARAMETERS;
2773 deauth_trigger = eLIM_HOST_DEAUTH;
2774 goto send_deauth;
2775 }
2776 return;
2777 case eLIM_AP_ROLE:
2778 break;
2779 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002780 pe_err("received unexpected SME_DEAUTH_REQ for role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002781 GET_LIM_SYSTEM_ROLE(session_entry));
2782 if (mac_ctx->lim.gLimRspReqd) {
2783 mac_ctx->lim.gLimRspReqd = false;
2784 ret_code = eSIR_SME_INVALID_PARAMETERS;
2785 deauth_trigger = eLIM_HOST_DEAUTH;
2786 goto send_deauth;
2787 }
2788 return;
2789 } /* end switch (mac_ctx->lim.gLimSystemRole) */
2790
2791 if (sme_deauth_req.reasonCode == eLIM_LINK_MONITORING_DEAUTH) {
2792 /* Deauthentication is triggered by Link Monitoring */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002793 pe_debug("** Lost link with AP **");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002794 deauth_trigger = eLIM_LINK_MONITORING_DEAUTH;
2795 reason_code = eSIR_MAC_UNSPEC_FAILURE_REASON;
2796 } else {
2797 deauth_trigger = eLIM_HOST_DEAUTH;
2798 reason_code = sme_deauth_req.reasonCode;
2799 }
2800
2801 /* Trigger Deauthentication frame to peer MAC entity */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302802 mlm_deauth_req = qdf_mem_malloc(sizeof(tLimMlmDeauthReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002803 if (NULL == mlm_deauth_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002804 pe_err("call to AllocateMemory failed for mlmDeauthReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002805 if (mac_ctx->lim.gLimRspReqd) {
2806 mac_ctx->lim.gLimRspReqd = false;
2807 ret_code = eSIR_SME_RESOURCES_UNAVAILABLE;
2808 deauth_trigger = eLIM_HOST_DEAUTH;
2809 goto send_deauth;
2810 }
2811 return;
2812 }
2813
Anurag Chouhanc5548422016-02-24 18:33:27 +05302814 qdf_copy_macaddr(&mlm_deauth_req->peer_macaddr,
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002815 &sme_deauth_req.peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002816
2817 mlm_deauth_req->reasonCode = reason_code;
2818 mlm_deauth_req->deauthTrigger = deauth_trigger;
2819
2820 /* Update PE session Id */
2821 mlm_deauth_req->sessionId = session_id;
2822
2823 lim_post_mlm_message(mac_ctx, LIM_MLM_DEAUTH_REQ,
2824 (uint32_t *)mlm_deauth_req);
2825 return;
2826
2827send_deauth:
Srinivas Girigowda9efa10e2016-01-04 18:49:40 -08002828 lim_send_sme_deauth_ntf(mac_ctx, sme_deauth_req.peer_macaddr.bytes,
2829 ret_code, deauth_trigger, 1,
2830 sme_session_id, sme_transaction_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002831}
2832
2833/**
2834 * __lim_process_sme_set_context_req()
2835 *
2836 * @mac_ctx: Pointer to Global MAC structure
2837 * @msg_buf: pointer to the SME message buffer
2838 *
2839 * This function is called to process SME_SETCONTEXT_REQ message
2840 * from HDD or upper layer application.
2841 *
2842 * Return: None
2843 */
2844
2845static void
2846__lim_process_sme_set_context_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
2847{
2848 tpSirSmeSetContextReq set_context_req;
2849 tLimMlmSetKeysReq *mlm_set_key_req;
2850 tpPESession session_entry;
2851 uint8_t session_id; /* PE sessionID */
2852 uint8_t sme_session_id;
2853 uint16_t sme_transaction_id;
2854
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002855 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002856 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002857 return;
2858 }
2859
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302860 set_context_req = qdf_mem_malloc(sizeof(struct sSirSmeSetContextReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002861 if (NULL == set_context_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002862 pe_err("call to AllocateMemory failed for set_context_req");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002863 return;
2864 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302865 qdf_mem_copy(set_context_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002866 sizeof(struct sSirSmeSetContextReq));
2867 sme_session_id = set_context_req->sessionId;
2868 sme_transaction_id = set_context_req->transactionId;
2869
2870 if ((!lim_is_sme_set_context_req_valid(mac_ctx, set_context_req))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002871 pe_warn("received invalid SME_SETCONTEXT_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002872 goto end;
2873 }
2874
2875 if (set_context_req->keyMaterial.numKeys >
2876 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002877 pe_err("numKeys:%d is more than SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002878 set_context_req->keyMaterial.numKeys);
2879 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002880 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002881 eSIR_SME_INVALID_PARAMETERS, NULL,
2882 sme_session_id, sme_transaction_id);
2883 goto end;
2884 }
2885
2886 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002887 set_context_req->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002888 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002889 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002890 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002891 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002892 eSIR_SME_INVALID_PARAMETERS, NULL,
2893 sme_session_id, sme_transaction_id);
2894 goto end;
2895 }
2896#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
2897 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_SETCONTEXT_REQ_EVENT,
2898 session_entry, 0, 0);
2899#endif /* FEATURE_WLAN_DIAG_SUPPORT */
2900
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002901 if ((LIM_IS_STA_ROLE(session_entry) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002902 (session_entry->limSmeState == eLIM_SME_LINK_EST_STATE)) ||
2903 ((LIM_IS_IBSS_ROLE(session_entry) ||
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07002904 LIM_IS_AP_ROLE(session_entry)) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002905 (session_entry->limSmeState == eLIM_SME_NORMAL_STATE))) {
2906 /* Trigger MLM_SETKEYS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302907 mlm_set_key_req = qdf_mem_malloc(sizeof(tLimMlmSetKeysReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002908 if (NULL == mlm_set_key_req) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002909 pe_err("mem alloc failed for mlmSetKeysReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002910 goto end;
2911 }
2912 mlm_set_key_req->edType = set_context_req->keyMaterial.edType;
2913 mlm_set_key_req->numKeys =
2914 set_context_req->keyMaterial.numKeys;
2915 if (mlm_set_key_req->numKeys >
2916 SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002917 pe_err("no.of keys exceeded max num of default keys limit");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002918 goto end;
2919 }
Anurag Chouhanc5548422016-02-24 18:33:27 +05302920 qdf_copy_macaddr(&mlm_set_key_req->peer_macaddr,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002921 &set_context_req->peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002922
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302923 qdf_mem_copy((uint8_t *) &mlm_set_key_req->key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002924 (uint8_t *) &set_context_req->keyMaterial.key,
2925 sizeof(tSirKeys) *
2926 (mlm_set_key_req->numKeys ? mlm_set_key_req->
2927 numKeys : 1));
2928
2929 mlm_set_key_req->sessionId = session_id;
2930 mlm_set_key_req->smesessionId = sme_session_id;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002931 pe_debug("received SETCONTEXT_REQ message sessionId=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002932 mlm_set_key_req->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002933
2934 if (((set_context_req->keyMaterial.edType == eSIR_ED_WEP40) ||
2935 (set_context_req->keyMaterial.edType == eSIR_ED_WEP104)) &&
2936 LIM_IS_AP_ROLE(session_entry)) {
2937 if (set_context_req->keyMaterial.key[0].keyLength) {
2938 uint8_t key_id;
2939 key_id =
2940 set_context_req->keyMaterial.key[0].keyId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302941 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002942 &session_entry->WEPKeyMaterial[key_id],
2943 (uint8_t *) &set_context_req->keyMaterial,
2944 sizeof(tSirKeyMaterial));
2945 } else {
2946 uint32_t i;
2947 for (i = 0; i < SIR_MAC_MAX_NUM_OF_DEFAULT_KEYS;
2948 i++) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302949 qdf_mem_copy((uint8_t *)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002950 &mlm_set_key_req->key[i],
2951 (uint8_t *)session_entry->WEPKeyMaterial[i].key,
2952 sizeof(tSirKeys));
2953 }
2954 }
2955 }
2956 lim_post_mlm_message(mac_ctx, LIM_MLM_SETKEYS_REQ,
2957 (uint32_t *) mlm_set_key_req);
2958 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07002959 pe_err("rcvd unexpected SME_SETCONTEXT_REQ for role %d, state=%X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002960 GET_LIM_SYSTEM_ROLE(session_entry),
2961 session_entry->limSmeState);
2962 lim_print_sme_state(mac_ctx, LOGE, session_entry->limSmeState);
2963
2964 lim_send_sme_set_context_rsp(mac_ctx,
Srinivas Girigowdad5965c42015-12-04 13:43:16 -08002965 set_context_req->peer_macaddr, 1,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002966 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
2967 session_entry, sme_session_id,
2968 sme_transaction_id);
2969 }
2970end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302971 qdf_mem_free(set_context_req);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002972 return;
2973}
2974
2975/**
2976 * lim_process_sme_get_assoc_sta_info() - process sme assoc sta req
2977 *
2978 * @mac_ctx: Pointer to Global MAC structure
2979 * @msg_buf: pointer to the SME message buffer
2980 *
2981 * This function is called to process SME_GET_ASSOC_STAS_REQ message
2982 * from HDD or upper layer application.
2983 *
2984 * Return: None
2985 */
2986
Jeff Johnson801f1532016-10-07 07:54:50 -07002987static void lim_process_sme_get_assoc_sta_info(tpAniSirGlobal mac_ctx,
2988 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002989{
2990 tSirSmeGetAssocSTAsReq get_assoc_stas_req;
2991 tpDphHashNode sta_ds = NULL;
2992 tpPESession session_entry = NULL;
2993 tSap_Event sap_event;
2994 tpWLAN_SAPEventCB sap_event_cb = NULL;
2995 tpSap_AssocMacAddr assoc_sta_tmp = NULL;
2996 uint8_t session_id = CSR_SESSION_ID_INVALID;
2997 uint8_t assoc_id = 0;
2998 uint8_t sta_cnt = 0;
2999
3000 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003001 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003002 return;
3003 }
3004
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303005 qdf_mem_copy(&get_assoc_stas_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003006 sizeof(struct sSirSmeGetAssocSTAsReq));
3007 /*
3008 * Get Associated stations from PE.
3009 * Find PE session Entry
3010 */
3011 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda61de4bb2015-11-25 15:46:41 -08003012 get_assoc_stas_req.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003013 &session_id);
3014 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003015 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003016 goto lim_assoc_sta_end;
3017 }
3018
3019 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003020 pe_err("Received unexpected message in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003021 session_entry->limSmeState,
3022 GET_LIM_SYSTEM_ROLE(session_entry));
3023 goto lim_assoc_sta_end;
3024 }
3025 /* Retrieve values obtained in the request message */
3026 sap_event_cb = (tpWLAN_SAPEventCB)get_assoc_stas_req.pSapEventCallback;
3027 assoc_sta_tmp = (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3028
3029 if (NULL == assoc_sta_tmp)
3030 goto lim_assoc_sta_end;
3031 for (assoc_id = 0; assoc_id < session_entry->dph.dphHashTable.size;
3032 assoc_id++) {
3033 sta_ds = dph_get_hash_entry(mac_ctx, assoc_id,
3034 &session_entry->dph.dphHashTable);
3035 if (NULL == sta_ds)
3036 continue;
3037 if (sta_ds->valid) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303038 qdf_mem_copy((uint8_t *) &assoc_sta_tmp->staMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003039 (uint8_t *) &sta_ds->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303040 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003041 assoc_sta_tmp->assocId = (uint8_t) sta_ds->assocId;
3042 assoc_sta_tmp->staId = (uint8_t) sta_ds->staIndex;
3043
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303044 qdf_mem_copy((uint8_t *)&assoc_sta_tmp->supportedRates,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003045 (uint8_t *)&sta_ds->supportedRates,
3046 sizeof(tSirSupportedRates));
3047 assoc_sta_tmp->ShortGI40Mhz = sta_ds->htShortGI40Mhz;
3048 assoc_sta_tmp->ShortGI20Mhz = sta_ds->htShortGI20Mhz;
3049 assoc_sta_tmp->Support40Mhz =
3050 sta_ds->htDsssCckRate40MHzSupport;
3051
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003052 pe_debug("dph Station Number = %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003053 sta_cnt + 1);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003054 pe_debug("MAC = " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003055 MAC_ADDR_ARRAY(sta_ds->staAddr));
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003056 pe_debug("Association Id: %d Station Index: %d",
3057 sta_ds->assocId, sta_ds->staIndex);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003058 assoc_sta_tmp++;
3059 sta_cnt++;
3060 }
3061 }
3062lim_assoc_sta_end:
3063 /*
3064 * Call hdd callback with sap event to send the list of
3065 * associated stations from PE
3066 */
3067 if (sap_event_cb != NULL) {
3068 sap_event.sapHddEventCode = eSAP_ASSOC_STA_CALLBACK_EVENT;
3069 sap_event.sapevt.sapAssocStaListEvent.module =
Anurag Chouhan6d760662016-02-20 16:05:43 +05303070 QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003071 sap_event.sapevt.sapAssocStaListEvent.noOfAssocSta = sta_cnt;
3072 sap_event.sapevt.sapAssocStaListEvent.pAssocStas =
3073 (tpSap_AssocMacAddr)get_assoc_stas_req.pAssocStasArray;
3074 sap_event_cb(&sap_event, get_assoc_stas_req.pUsrContext);
3075 }
3076}
3077
3078/**
3079 * lim_process_sme_get_wpspbc_sessions - process sme get wpspbc req
3080 *
3081 * @mac_ctx: Pointer to Global MAC structure
3082 * @msg_buf: pointer to WPS PBC overlap query message
3083 *
3084 * This function parses get WPS PBC overlap information
3085 * message and call callback to pass WPS PBC overlap
3086 * information back to hdd.
3087 *
3088 * Return: None
3089 */
Jeff Johnson801f1532016-10-07 07:54:50 -07003090static void lim_process_sme_get_wpspbc_sessions(tpAniSirGlobal mac_ctx,
3091 uint32_t *msg_buf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003092{
3093 tSirSmeGetWPSPBCSessionsReq get_wps_pbc_sessions_req;
3094 tpPESession session_entry = NULL;
3095 tSap_Event sap_event;
3096 tpWLAN_SAPEventCB sap_event_cb = NULL;
3097 uint8_t session_id = CSR_SESSION_ID_INVALID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003098 tSap_GetWPSPBCSessionEvent *sap_get_wpspbc_event;
3099
3100 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003101 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003102 return;
3103 }
3104
3105 sap_get_wpspbc_event = &sap_event.sapevt.sapGetWPSPBCSessionEvent;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303106 sap_get_wpspbc_event->status = QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003107
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303108 qdf_mem_copy(&get_wps_pbc_sessions_req, msg_buf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003109 sizeof(struct sSirSmeGetWPSPBCSessionsReq));
3110 /*
3111 * Get Associated stations from PE
3112 * Find PE session Entry
3113 */
3114 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003115 get_wps_pbc_sessions_req.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003116 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003117 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003118 goto lim_get_wpspbc_sessions_end;
3119 }
3120
3121 if (!LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003122 pe_err("Received unexpected message in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003123 GET_LIM_SYSTEM_ROLE(session_entry));
3124 goto lim_get_wpspbc_sessions_end;
3125 }
3126 /*
3127 * Call hdd callback with sap event to send the
3128 * WPS PBC overlap information
3129 */
3130 sap_event.sapHddEventCode = eSAP_GET_WPSPBC_SESSION_EVENT;
Anurag Chouhan6d760662016-02-20 16:05:43 +05303131 sap_get_wpspbc_event->module = QDF_MODULE_ID_PE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003132
Anurag Chouhanc5548422016-02-24 18:33:27 +05303133 if (qdf_is_macaddr_zero(&get_wps_pbc_sessions_req.remove_mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003134 lim_get_wpspbc_sessions(mac_ctx,
Srinivas Girigowda419e36b2015-11-24 15:39:54 -08003135 sap_get_wpspbc_event->addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003136 sap_get_wpspbc_event->UUID_E,
3137 &sap_get_wpspbc_event->wpsPBCOverlap,
3138 session_entry);
3139 } else {
3140 lim_remove_pbc_sessions(mac_ctx,
Srinivas Girigowdaedcfab92015-11-24 15:21:41 -08003141 get_wps_pbc_sessions_req.remove_mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003142 session_entry);
3143 /* don't have to inform the HDD/Host */
3144 return;
3145 }
3146
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003147 pe_debug("wpsPBCOverlap %d", sap_get_wpspbc_event->wpsPBCOverlap);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003148 lim_print_mac_addr(mac_ctx,
Abhishek Singh4294f802017-08-10 16:37:07 +05303149 sap_get_wpspbc_event->addr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003150
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303151 sap_get_wpspbc_event->status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003152
3153lim_get_wpspbc_sessions_end:
3154 sap_event_cb =
3155 (tpWLAN_SAPEventCB)get_wps_pbc_sessions_req.pSapEventCallback;
3156 if (NULL != sap_event_cb)
3157 sap_event_cb(&sap_event, get_wps_pbc_sessions_req.pUsrContext);
3158}
3159
3160/**
3161 * __lim_counter_measures()
3162 *
3163 * FUNCTION:
3164 * This function is called to "implement" MIC counter measure
3165 * and is *temporary* only
3166 *
3167 * LOGIC: on AP, disassoc all STA associated thru TKIP,
3168 * we don't do the proper STA disassoc sequence since the
3169 * BSS will be stoped anyway
3170 *
3171 ***ASSUMPTIONS:
3172 *
3173 ***NOTE:
3174 *
3175 * @param pMac Pointer to Global MAC structure
3176 * @return None
3177 */
3178
3179static void __lim_counter_measures(tpAniSirGlobal pMac, tpPESession psessionEntry)
3180{
3181 tSirMacAddr mac = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003182 if (LIM_IS_AP_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003183 lim_send_disassoc_mgmt_frame(pMac, eSIR_MAC_MIC_FAILURE_REASON,
3184 mac, psessionEntry, false);
3185};
3186
Jeff Johnson801f1532016-10-07 07:54:50 -07003187static void lim_process_tkip_counter_measures(tpAniSirGlobal pMac,
3188 uint32_t *pMsgBuf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003189{
3190 tSirSmeTkipCntrMeasReq tkipCntrMeasReq;
3191 tpPESession psessionEntry;
3192 uint8_t sessionId; /* PE sessionId */
3193
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303194 qdf_mem_copy(&tkipCntrMeasReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003195 sizeof(struct sSirSmeTkipCntrMeasReq));
3196
3197 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac8b79e42015-09-24 15:57:40 -07003198 tkipCntrMeasReq.bssId.bytes, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003199 if (NULL == psessionEntry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003200 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003201 return;
3202 }
3203
3204 if (tkipCntrMeasReq.bEnable)
3205 __lim_counter_measures(pMac, psessionEntry);
3206
3207 psessionEntry->bTkipCntrMeasActive = tkipCntrMeasReq.bEnable;
3208}
3209
3210static void
3211__lim_handle_sme_stop_bss_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3212{
3213 tSirSmeStopBssReq stopBssReq;
3214 tSirRetStatus status;
3215 tLimSmeStates prevState;
3216 tpPESession psessionEntry;
3217 uint8_t smesessionId;
3218 uint8_t sessionId;
3219 uint16_t smetransactionId;
3220 uint8_t i = 0;
3221 tpDphHashNode pStaDs = NULL;
3222
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303223 qdf_mem_copy(&stopBssReq, pMsgBuf, sizeof(tSirSmeStopBssReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003224 smesessionId = stopBssReq.sessionId;
3225 smetransactionId = stopBssReq.transactionId;
3226
3227 if (!lim_is_sme_stop_bss_req_valid(pMsgBuf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003228 pe_warn("received invalid SME_STOP_BSS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003229 /* Send Stop BSS response to host */
3230 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3231 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3232 smetransactionId);
3233 return;
3234 }
3235
3236 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaa2302652016-01-04 14:32:25 -08003237 stopBssReq.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003238 &sessionId);
3239 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003240 pe_err("session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003241 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3242 eSIR_SME_INVALID_PARAMETERS, smesessionId,
3243 smetransactionId);
3244 return;
3245 }
3246#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3247 lim_diag_event_report(pMac, WLAN_PE_DIAG_STOP_BSS_REQ_EVENT, psessionEntry,
3248 0, 0);
3249#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3250
3251 if (psessionEntry->limSmeState != eLIM_SME_NORMAL_STATE || /* Added For BT -AMP Support */
3252 LIM_IS_STA_ROLE(psessionEntry)) {
3253 /**
3254 * Should not have received STOP_BSS_REQ in states
3255 * other than 'normal' state or on STA in Infrastructure
3256 * mode. Log error and return response to host.
3257 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003258 pe_err("received unexpected SME_STOP_BSS_REQ in state %X, for role %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003259 psessionEntry->limSmeState,
3260 GET_LIM_SYSTEM_ROLE(psessionEntry));
3261 lim_print_sme_state(pMac, LOGE, psessionEntry->limSmeState);
3262 /* / Send Stop BSS response to host */
3263 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3264 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE, smesessionId,
3265 smetransactionId);
3266 return;
3267 }
3268
3269 if (LIM_IS_AP_ROLE(psessionEntry))
3270 lim_wpspbc_close(pMac, psessionEntry);
3271
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003272 pe_debug("RECEIVED STOP_BSS_REQ with reason code=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003273 stopBssReq.reasonCode);
3274
3275 prevState = psessionEntry->limSmeState;
3276
3277 psessionEntry->limSmeState = eLIM_SME_IDLE_STATE;
3278 MTRACE(mac_trace
3279 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3280 psessionEntry->limSmeState));
3281
3282 /* Update SME session Id and Transaction Id */
3283 psessionEntry->smeSessionId = smesessionId;
3284 psessionEntry->transactionId = smetransactionId;
3285
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003286 /* STA_IN_IBSS and NDI should NOT send Disassoc frame */
3287 if (!LIM_IS_IBSS_ROLE(psessionEntry) &&
3288 !LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003289 tSirMacAddr bcAddr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
3290 if (stopBssReq.reasonCode == eSIR_SME_MIC_COUNTER_MEASURES)
3291 /* Send disassoc all stations associated thru TKIP */
3292 __lim_counter_measures(pMac, psessionEntry);
3293 else
3294 lim_send_disassoc_mgmt_frame(pMac,
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003295 eSIR_MAC_DEAUTH_LEAVING_BSS_REASON,
3296 bcAddr, psessionEntry, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003297 }
3298
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003299 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
3300 /* Free the buffer allocated in START_BSS_REQ */
3301 qdf_mem_free(psessionEntry->addIeParams.probeRespData_buff);
3302 psessionEntry->addIeParams.probeRespDataLen = 0;
3303 psessionEntry->addIeParams.probeRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003304
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003305 qdf_mem_free(psessionEntry->addIeParams.assocRespData_buff);
3306 psessionEntry->addIeParams.assocRespDataLen = 0;
3307 psessionEntry->addIeParams.assocRespData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003308
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003309 qdf_mem_free(psessionEntry->addIeParams.probeRespBCNData_buff);
3310 psessionEntry->addIeParams.probeRespBCNDataLen = 0;
3311 psessionEntry->addIeParams.probeRespBCNData_buff = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003312
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07003313 /*
3314 * lim_del_bss is also called as part of coalescing,
3315 * when we send DEL BSS followed by Add Bss msg.
3316 */
3317 pMac->lim.gLimIbssCoalescingHappened = false;
3318 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003319 for (i = 1; i < pMac->lim.gLimAssocStaLimit; i++) {
3320 pStaDs =
3321 dph_get_hash_entry(pMac, i, &psessionEntry->dph.dphHashTable);
3322 if (NULL == pStaDs)
3323 continue;
3324 status = lim_del_sta(pMac, pStaDs, false, psessionEntry);
3325 if (eSIR_SUCCESS == status) {
3326 lim_delete_dph_hash_entry(pMac, pStaDs->staAddr,
3327 pStaDs->assocId, psessionEntry);
3328 lim_release_peer_idx(pMac, pStaDs->assocId, psessionEntry);
3329 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003330 pe_err("lim_del_sta failed with Status: %d", status);
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303331 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003332 }
3333 }
3334 /* send a delBss to HAL and wait for a response */
3335 status = lim_del_bss(pMac, NULL, psessionEntry->bssIdx, psessionEntry);
3336
3337 if (status != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003338 pe_err("delBss failed for bss %d", psessionEntry->bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003339 psessionEntry->limSmeState = prevState;
3340
3341 MTRACE(mac_trace
3342 (pMac, TRACE_CODE_SME_STATE, psessionEntry->peSessionId,
3343 psessionEntry->limSmeState));
3344
3345 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP,
3346 eSIR_SME_STOP_BSS_FAILURE, smesessionId,
3347 smetransactionId);
3348 }
3349}
3350
3351/**
3352 * __lim_process_sme_stop_bss_req() - Process STOP_BSS from SME
3353 * @pMac: Global MAC context
3354 * @pMsg: Message from SME
3355 *
3356 * Wrapper for the function __lim_handle_sme_stop_bss_request
3357 * This message will be defered until softmac come out of
3358 * scan mode. Message should be handled even if we have
3359 * detected radar in the current operating channel.
3360 *
3361 * Return: true - If we consumed the buffer
3362 * false - If have defered the message.
3363 */
3364
Rajeev Kumarfeb96382017-01-22 19:42:09 -08003365static bool __lim_process_sme_stop_bss_req(tpAniSirGlobal pMac,
3366 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003367{
3368 if (__lim_is_defered_msg_for_learn(pMac, pMsg)) {
3369 /**
3370 * If message defered, buffer is not consumed yet.
3371 * So return false
3372 */
3373 return false;
3374 }
3375 __lim_handle_sme_stop_bss_request(pMac, (uint32_t *) pMsg->bodyptr);
3376 return true;
3377} /*** end __lim_process_sme_stop_bss_req() ***/
3378
3379void lim_process_sme_del_bss_rsp(tpAniSirGlobal pMac,
3380 uint32_t body, tpPESession psessionEntry)
3381{
3382
3383 (void)body;
3384 SET_LIM_PROCESS_DEFD_MESGS(pMac, true);
3385 lim_ibss_delete(pMac, psessionEntry);
3386 dph_hash_table_class_init(pMac, &psessionEntry->dph.dphHashTable);
3387 lim_delete_pre_auth_list(pMac);
3388 lim_send_sme_rsp(pMac, eWNI_SME_STOP_BSS_RSP, eSIR_SME_SUCCESS,
3389 psessionEntry->smeSessionId,
3390 psessionEntry->transactionId);
3391 return;
3392}
3393
3394/**
3395 * __lim_process_sme_assoc_cnf_new() - process sme assoc/reassoc cnf
3396 *
3397 * @mac_ctx: pointer to mac context
3398 * @msg_type: message type
3399 * @msg_buf: pointer to the SME message buffer
3400 *
3401 * This function handles SME_ASSOC_CNF/SME_REASSOC_CNF
3402 * in BTAMP AP.
3403 *
3404 * Return: None
3405 */
3406
3407void __lim_process_sme_assoc_cnf_new(tpAniSirGlobal mac_ctx, uint32_t msg_type,
3408 uint32_t *msg_buf)
3409{
3410 tSirSmeAssocCnf assoc_cnf;
3411 tpDphHashNode sta_ds = NULL;
3412 tpPESession session_entry = NULL;
3413 uint8_t session_id;
3414 tpSirAssocReq assoc_req;
3415
3416 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003417 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003418 goto end;
3419 }
3420
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303421 qdf_mem_copy(&assoc_cnf, msg_buf, sizeof(struct sSirSmeAssocCnf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003422 if (!__lim_is_sme_assoc_cnf_valid(&assoc_cnf)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003423 pe_err("Received invalid SME_RE(ASSOC)_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003424 goto end;
3425 }
3426
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003427 session_entry = pe_find_session_by_bssid(mac_ctx, assoc_cnf.bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003428 &session_id);
3429 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003430 pe_err("session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003431 goto end;
3432 }
3433
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003434 if ((!LIM_IS_AP_ROLE(session_entry)) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003435 ((session_entry->limSmeState != eLIM_SME_NORMAL_STATE) &&
3436 (session_entry->limSmeState !=
3437 eLIM_SME_NORMAL_CHANNEL_SCAN_STATE))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003438 pe_err("Rcvd unexpected msg %X in state %X, in role %X",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003439 msg_type, session_entry->limSmeState,
3440 GET_LIM_SYSTEM_ROLE(session_entry));
3441 goto end;
3442 }
3443 sta_ds = dph_get_hash_entry(mac_ctx, assoc_cnf.aid,
3444 &session_entry->dph.dphHashTable);
3445 if (sta_ds == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003446 pe_err("Rcvd invalid msg %X due to no STA ctx, aid %d, peer",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003447 msg_type, assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303448 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003449
3450 /*
3451 * send a DISASSOC_IND message to WSM to make sure
3452 * the state in WSM and LIM is the same
3453 */
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003454 lim_send_sme_disassoc_ntf(mac_ctx, assoc_cnf.peer_macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003455 eSIR_SME_STA_NOT_ASSOCIATED,
3456 eLIM_PEER_ENTITY_DISASSOC, assoc_cnf.aid,
3457 session_entry->smeSessionId,
3458 session_entry->transactionId,
3459 session_entry);
3460 goto end;
3461 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303462 if (qdf_mem_cmp((uint8_t *)sta_ds->staAddr,
Srinivas Girigowdafb796d12016-01-05 23:04:28 -08003463 (uint8_t *) assoc_cnf.peer_macaddr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303464 QDF_MAC_ADDR_SIZE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003465 pe_debug("peerMacAddr mismatched for aid %d, peer ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003466 assoc_cnf.aid);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303467 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003468 goto end;
3469 }
3470
3471 if ((sta_ds->mlmStaContext.mlmState != eLIM_MLM_WT_ASSOC_CNF_STATE) ||
3472 ((sta_ds->mlmStaContext.subType == LIM_ASSOC) &&
3473 (msg_type != eWNI_SME_ASSOC_CNF)) ||
3474 ((sta_ds->mlmStaContext.subType == LIM_REASSOC) &&
3475 (msg_type != eWNI_SME_ASSOC_CNF))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003476 pe_debug("not in MLM_WT_ASSOC_CNF_STATE, for aid %d, peer"
3477 "StaD mlmState: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003478 assoc_cnf.aid, sta_ds->mlmStaContext.mlmState);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303479 lim_print_mac_addr(mac_ctx, assoc_cnf.peer_macaddr.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003480 goto end;
3481 }
3482 /*
3483 * Deactivate/delet CNF_WAIT timer since ASSOC_CNF
3484 * has been received
3485 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003486 pe_debug("Received SME_ASSOC_CNF. Delete Timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003487 lim_deactivate_and_change_per_sta_id_timer(mac_ctx,
3488 eLIM_CNF_WAIT_TIMER, sta_ds->assocId);
3489
3490 if (assoc_cnf.statusCode == eSIR_SME_SUCCESS) {
3491 /*
3492 * In BTAMP-AP, PE already finished the WMA_ADD_STA sequence
3493 * when it had received Assoc Request frame. Now, PE just needs
3494 * to send association rsp frame to the requesting BTAMP-STA.
3495 */
3496 sta_ds->mlmStaContext.mlmState =
3497 eLIM_MLM_LINK_ESTABLISHED_STATE;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003498 pe_debug("sending Assoc Rsp frame to STA (assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003499 sta_ds->assocId);
3500 lim_send_assoc_rsp_mgmt_frame(mac_ctx, eSIR_SUCCESS,
3501 sta_ds->assocId, sta_ds->staAddr,
3502 sta_ds->mlmStaContext.subType, sta_ds,
3503 session_entry);
3504 goto end;
3505 } else {
3506 /*
3507 * SME_ASSOC_CNF status is non-success, so STA is not allowed
3508 * to be associated since the HAL sta entry is created for
3509 * denied STA we need to remove this HAL entry.
3510 * So to do that set updateContext to 1
3511 */
3512 if (!sta_ds->mlmStaContext.updateContext)
3513 sta_ds->mlmStaContext.updateContext = 1;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003514 pe_debug("Recv Assoc Cnf, status Code : %d(assoc id=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003515 assoc_cnf.statusCode, sta_ds->assocId);
3516 lim_reject_association(mac_ctx, sta_ds->staAddr,
3517 sta_ds->mlmStaContext.subType,
3518 true, sta_ds->mlmStaContext.authType,
3519 sta_ds->assocId, true,
Varun Reddy Yeturu8c68b472017-06-15 16:05:38 -07003520 eSIR_SME_UNEXPECTED_REQ_RESULT_CODE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003521 session_entry);
3522 }
3523end:
3524 if (((session_entry != NULL) && (sta_ds != NULL)) &&
3525 (session_entry->parsedAssocReq[sta_ds->assocId] != NULL)) {
3526 assoc_req = (tpSirAssocReq)
3527 session_entry->parsedAssocReq[sta_ds->assocId];
3528 if (assoc_req->assocReqFrame) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303529 qdf_mem_free(assoc_req->assocReqFrame);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003530 assoc_req->assocReqFrame = NULL;
3531 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303532 qdf_mem_free(session_entry->parsedAssocReq[sta_ds->assocId]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003533 session_entry->parsedAssocReq[sta_ds->assocId] = NULL;
3534 }
3535}
3536
3537static void __lim_process_sme_addts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3538{
3539 tpDphHashNode pStaDs;
3540 tSirMacAddr peerMac;
3541 tpSirAddtsReq pSirAddts;
3542 uint32_t timeout;
3543 tpPESession psessionEntry;
3544 uint8_t sessionId; /* PE sessionId */
3545 uint8_t smesessionId;
3546 uint16_t smetransactionId;
3547
3548 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003549 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003550 return;
3551 }
3552
3553 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3554 &smetransactionId);
3555
3556 pSirAddts = (tpSirAddtsReq) pMsgBuf;
3557
Srinivas Girigowdaaeb33322015-12-04 10:54:07 -08003558 psessionEntry = pe_find_session_by_bssid(pMac, pSirAddts->bssid.bytes,
3559 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003560 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003561 pe_err("Session Does not exist for given bssId");
yeshwanth sriram guntuka8fa6fa32017-03-23 13:59:22 +05303562 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3563 NULL, pSirAddts->req.tspec,
3564 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003565 return;
3566 }
3567#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3568 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_REQ_EVENT, psessionEntry, 0,
3569 0);
3570#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3571
3572 /* if sta
3573 * - verify assoc state
3574 * - send addts request to ap
3575 * - wait for addts response from ap
3576 * if ap, just ignore with error log
3577 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003578 pe_debug("Received SME_ADDTS_REQ (TSid %d, UP %d)",
3579 pSirAddts->req.tspec.tsinfo.traffic.tsid,
3580 pSirAddts->req.tspec.tsinfo.traffic.userPrio);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003581
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003582 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003583 pe_err("AddTs received on AP - ignoring");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303584 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003585 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003586
3587 pStaDs =
3588 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3589 &psessionEntry->dph.dphHashTable);
3590
3591 if (pStaDs == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003592 pe_err("Cannot find AP context for addts req");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303593 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003594 }
3595
3596 if ((!pStaDs->valid) || (pStaDs->mlmStaContext.mlmState !=
3597 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003598 pe_err("AddTs received in invalid MLM state");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303599 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003600 }
3601
3602 pSirAddts->req.wsmTspecPresent = 0;
3603 pSirAddts->req.wmeTspecPresent = 0;
3604 pSirAddts->req.lleTspecPresent = 0;
3605
3606 if ((pStaDs->wsmEnabled) &&
3607 (pSirAddts->req.tspec.tsinfo.traffic.accessPolicy !=
3608 SIR_MAC_ACCESSPOLICY_EDCA))
3609 pSirAddts->req.wsmTspecPresent = 1;
3610 else if (pStaDs->wmeEnabled)
3611 pSirAddts->req.wmeTspecPresent = 1;
3612 else if (pStaDs->lleEnabled)
3613 pSirAddts->req.lleTspecPresent = 1;
3614 else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003615 pe_warn("ADDTS_REQ ignore - qos is disabled");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303616 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003617 }
3618
3619 if ((psessionEntry->limSmeState != eLIM_SME_ASSOCIATED_STATE) &&
3620 (psessionEntry->limSmeState != eLIM_SME_LINK_EST_STATE)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003621 pe_err("AddTs received in invalid LIMsme state (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003622 psessionEntry->limSmeState);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303623 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003624 }
3625
3626 if (pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003627 pe_err("Addts (token %d, tsid %d, up %d) is still pending",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003628 pMac->lim.gLimAddtsReq.req.dialogToken,
3629 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.tsid,
3630 pMac->lim.gLimAddtsReq.req.tspec.tsinfo.traffic.
3631 userPrio);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303632 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003633 }
3634
3635 sir_copy_mac_addr(peerMac, psessionEntry->bssId);
3636
3637 /* save the addts request */
3638 pMac->lim.gLimAddtsSent = true;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303639 qdf_mem_copy((uint8_t *) &pMac->lim.gLimAddtsReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003640 (uint8_t *) pSirAddts, sizeof(tSirAddtsReq));
3641
3642 /* ship out the message now */
3643 lim_send_addts_req_action_frame(pMac, peerMac, &pSirAddts->req,
3644 psessionEntry);
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303645 pe_err("Sent ADDTS request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003646 /* start a timer to wait for the response */
3647 if (pSirAddts->timeout)
3648 timeout = pSirAddts->timeout;
3649 else if (wlan_cfg_get_int(pMac, WNI_CFG_ADDTS_RSP_TIMEOUT, &timeout) !=
3650 eSIR_SUCCESS) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05303651 pe_debug("Unable to get Cfg param %d (Addts Rsp Timeout)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003652 WNI_CFG_ADDTS_RSP_TIMEOUT);
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303653 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003654 }
3655
3656 timeout = SYS_MS_TO_TICKS(timeout);
3657 if (tx_timer_change(&pMac->lim.limTimers.gLimAddtsRspTimer, timeout, 0)
3658 != TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003659 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303660 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003661 }
3662 pMac->lim.gLimAddtsRspTimerCount++;
3663 if (tx_timer_change_context(&pMac->lim.limTimers.gLimAddtsRspTimer,
3664 pMac->lim.gLimAddtsRspTimerCount) !=
3665 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003666 pe_err("AddtsRsp timer change failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303667 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003668 }
3669 MTRACE(mac_trace
3670 (pMac, TRACE_CODE_TIMER_ACTIVATE, psessionEntry->peSessionId,
3671 eLIM_ADDTS_RSP_TIMER));
3672
3673 /* add the sessionId to the timer object */
3674 pMac->lim.limTimers.gLimAddtsRspTimer.sessionId = sessionId;
3675 if (tx_timer_activate(&pMac->lim.limTimers.gLimAddtsRspTimer) !=
3676 TX_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003677 pe_err("AddtsRsp timer activation failed!");
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303678 goto send_failure_addts_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003679 }
3680 return;
Sreelakshmi Konamki2972b6e2017-07-17 12:10:36 +05303681
3682send_failure_addts_rsp:
3683 lim_send_sme_addts_rsp(pMac, pSirAddts->rspReqd, eSIR_FAILURE,
3684 psessionEntry, pSirAddts->req.tspec,
3685 smesessionId, smetransactionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003686}
3687
3688static void __lim_process_sme_delts_req(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3689{
3690 tSirMacAddr peerMacAddr;
3691 uint8_t ac;
3692 tSirMacTSInfo *pTsinfo;
3693 tpSirDeltsReq pDeltsReq = (tpSirDeltsReq) pMsgBuf;
3694 tpDphHashNode pStaDs = NULL;
3695 tpPESession psessionEntry;
3696 uint8_t sessionId;
3697 uint32_t status = eSIR_SUCCESS;
3698 uint8_t smesessionId;
3699 uint16_t smetransactionId;
3700
3701 lim_get_session_info(pMac, (uint8_t *) pMsgBuf, &smesessionId,
3702 &smetransactionId);
3703
3704 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08003705 pDeltsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003706 &sessionId);
3707 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003708 pe_err("Session Does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003709 status = eSIR_FAILURE;
3710 goto end;
3711 }
3712#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
3713 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_REQ_EVENT, psessionEntry, 0,
3714 0);
3715#endif /* FEATURE_WLAN_DIAG_SUPPORT */
3716
3717 if (eSIR_SUCCESS !=
3718 lim_validate_delts_req(pMac, pDeltsReq, peerMacAddr, psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003719 pe_err("lim_validate_delts_req failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003720 status = eSIR_FAILURE;
3721 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_FAILURE, psessionEntry,
3722 smesessionId, smetransactionId);
3723 return;
3724 }
3725
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003726 pe_debug("Sent DELTS request to station with assocId = %d MacAddr = "
3727 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003728 pDeltsReq->aid, MAC_ADDR_ARRAY(peerMacAddr));
3729
3730 lim_send_delts_req_action_frame(pMac, peerMacAddr,
3731 pDeltsReq->req.wmeTspecPresent,
3732 &pDeltsReq->req.tsinfo,
3733 &pDeltsReq->req.tspec, psessionEntry);
3734
3735 pTsinfo =
3736 pDeltsReq->req.wmeTspecPresent ? &pDeltsReq->req.tspec.
3737 tsinfo : &pDeltsReq->req.tsinfo;
3738
3739 /* We've successfully send DELTS frame to AP. Update the
3740 * dynamic UAPSD mask. The AC for this TSPEC to be deleted
3741 * is no longer trigger enabled or delivery enabled
3742 */
3743 lim_set_tspec_uapsd_mask_per_session(pMac, psessionEntry,
3744 pTsinfo, CLEAR_UAPSD_MASK);
3745
3746 /* We're deleting the TSPEC, so this particular AC is no longer
3747 * admitted. PE needs to downgrade the EDCA
3748 * parameters(for the AC for which TS is being deleted) to the
3749 * next best AC for which ACM is not enabled, and send the
3750 * updated values to HAL.
3751 */
3752 ac = upToAc(pTsinfo->traffic.userPrio);
3753
3754 if (pTsinfo->traffic.direction == SIR_MAC_DIRECTION_UPLINK) {
3755 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3756 ~(1 << ac);
3757 } else if (pTsinfo->traffic.direction ==
3758 SIR_MAC_DIRECTION_DNLINK) {
3759 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3760 ~(1 << ac);
3761 } else if (pTsinfo->traffic.direction ==
3762 SIR_MAC_DIRECTION_BIDIR) {
3763 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_UPLINK] &=
3764 ~(1 << ac);
3765 psessionEntry->gAcAdmitMask[SIR_MAC_DIRECTION_DNLINK] &=
3766 ~(1 << ac);
3767 }
3768
3769 lim_set_active_edca_params(pMac, psessionEntry->gLimEdcaParams,
3770 psessionEntry);
3771
3772 pStaDs =
3773 dph_get_hash_entry(pMac, DPH_STA_HASH_INDEX_PEER,
3774 &psessionEntry->dph.dphHashTable);
3775 if (pStaDs != NULL) {
3776 lim_send_edca_params(pMac, psessionEntry->gLimEdcaParamsActive,
3777 pStaDs->bssId);
3778 status = eSIR_SUCCESS;
3779 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003780 pe_err("Self entry missing in Hash Table");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003781 status = eSIR_FAILURE;
3782 }
3783#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003784 lim_send_sme_tsm_ie_ind(pMac, psessionEntry, 0, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003785#endif
3786
3787 /* send an sme response back */
3788end:
3789 lim_send_sme_delts_rsp(pMac, pDeltsReq, eSIR_SUCCESS, psessionEntry,
3790 smesessionId, smetransactionId);
3791}
3792
Sreelakshmi Konamkif76b4072017-03-01 10:41:05 +05303793void lim_process_sme_addts_rsp_timeout(tpAniSirGlobal pMac, uint32_t param)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003794{
3795 /* fetch the sessionEntry based on the sessionId */
3796 tpPESession psessionEntry;
3797 psessionEntry = pe_find_session_by_session_id(pMac,
3798 pMac->lim.limTimers.gLimAddtsRspTimer.
3799 sessionId);
3800 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003801 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003802 return;
3803 }
3804
Rajeev Kumarc9a50e72016-04-15 15:18:42 -07003805 if (!LIM_IS_STA_ROLE(psessionEntry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003806 pe_warn("AddtsRspTimeout in non-Sta role (%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003807 GET_LIM_SYSTEM_ROLE(psessionEntry));
3808 pMac->lim.gLimAddtsSent = false;
3809 return;
3810 }
3811
3812 if (!pMac->lim.gLimAddtsSent) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003813 pe_warn("AddtsRspTimeout but no AddtsSent");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003814 return;
3815 }
3816
3817 if (param != pMac->lim.gLimAddtsRspTimerCount) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003818 pe_err("Invalid AddtsRsp Timer count %d (exp %d)", param,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003819 pMac->lim.gLimAddtsRspTimerCount);
3820 return;
3821 }
3822 /* this a real response timeout */
3823 pMac->lim.gLimAddtsSent = false;
3824 pMac->lim.gLimAddtsRspTimerCount++;
3825
3826 lim_send_sme_addts_rsp(pMac, true, eSIR_SME_ADDTS_RSP_TIMEOUT,
3827 psessionEntry, pMac->lim.gLimAddtsReq.req.tspec,
3828 psessionEntry->smeSessionId,
3829 psessionEntry->transactionId);
3830}
3831
3832/**
3833 * __lim_process_sme_get_statistics_request()
3834 *
3835 ***FUNCTION:
3836 *
3837 *
3838 ***NOTE:
3839 *
3840 * @param pMac Pointer to Global MAC structure
3841 * @param *pMsgBuf A pointer to the SME message buffer
3842 * @return None
3843 */
3844static void
3845__lim_process_sme_get_statistics_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3846{
3847 tpAniGetPEStatsReq pPEStatsReq;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003848 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003849
3850 pPEStatsReq = (tpAniGetPEStatsReq) pMsgBuf;
3851
3852 msgQ.type = WMA_GET_STATISTICS_REQ;
3853
3854 msgQ.reserved = 0;
3855 msgQ.bodyptr = pMsgBuf;
3856 msgQ.bodyval = 0;
3857 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3858
3859 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303860 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003861 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003862 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003863 return;
3864 }
3865
3866 return;
3867}
3868
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003869#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003870/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003871 * __lim_process_sme_get_tsm_stats_request() - get tsm stats request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003872 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003873 * @pMac: Pointer to Global MAC structure
3874 * @pMsgBuf: A pointer to the SME message buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003875 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003876 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003877 */
3878static void
3879__lim_process_sme_get_tsm_stats_request(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3880{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003881 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003882
3883 msgQ.type = WMA_TSM_STATS_REQ;
3884 msgQ.reserved = 0;
3885 msgQ.bodyptr = pMsgBuf;
3886 msgQ.bodyval = 0;
3887 MTRACE(mac_trace_msg_tx(pMac, NO_SESSION, msgQ.type));
3888
3889 if (eSIR_SUCCESS != (wma_post_ctrl_msg(pMac, &msgQ))) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303890 qdf_mem_free(pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003891 pMsgBuf = NULL;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003892 pe_err("Unable to forward request");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003893 return;
3894 }
3895}
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003896#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003897
3898static void
3899__lim_process_sme_update_apwpsi_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
3900{
3901 tpSirUpdateAPWPSIEsReq pUpdateAPWPSIEsReq;
3902 tpPESession psessionEntry;
3903 uint8_t sessionId; /* PE sessionID */
3904
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003905 pe_debug("received UPDATE_APWPSIEs_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003906
3907 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003908 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003909 return;
3910 }
3911
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303912 pUpdateAPWPSIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003913 if (NULL == pUpdateAPWPSIEsReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003914 pe_err("call to AllocateMemory failed for pUpdateAPWPSIEsReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003915 return;
3916 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303917 qdf_mem_copy(pUpdateAPWPSIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003918 sizeof(struct sSirUpdateAPWPSIEsReq));
3919
3920 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda5d486002015-11-25 12:18:44 -08003921 pUpdateAPWPSIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003922 &sessionId);
3923 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003924 pe_warn("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003925 goto end;
3926 }
3927
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303928 qdf_mem_copy(&psessionEntry->APWPSIEs, &pUpdateAPWPSIEsReq->APWPSIEs,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003929 sizeof(tSirAPWPSIEs));
3930
3931 sch_set_fixed_beacon_fields(pMac, psessionEntry);
3932 lim_send_beacon_ind(pMac, psessionEntry);
3933
3934end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303935 qdf_mem_free(pUpdateAPWPSIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003936 return;
3937}
3938
Naveen Rawat8029a402017-06-01 10:54:19 -07003939static void lim_process_sme_update_config(tpAniSirGlobal mac_ctx,
3940 struct update_config *msg)
3941{
3942 tpPESession pe_session;
3943
3944 pe_debug("received eWNI_SME_UPDATE_HT_CONFIG message");
3945 if (msg == NULL) {
3946 pe_err("Buffer is Pointing to NULL");
3947 return;
3948 }
3949
3950 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
3951 msg->sme_session_id);
3952 if (pe_session == NULL) {
3953 pe_warn("Session does not exist for given BSSID");
3954 return;
3955 }
3956
3957 switch (msg->capab) {
3958 case WNI_CFG_HT_CAP_INFO_ADVANCE_CODING:
3959 pe_session->htConfig.ht_rx_ldpc = msg->value;
3960 break;
3961 case WNI_CFG_HT_CAP_INFO_TX_STBC:
3962 pe_session->htConfig.ht_tx_stbc = msg->value;
3963 break;
3964 case WNI_CFG_HT_CAP_INFO_RX_STBC:
3965 pe_session->htConfig.ht_rx_stbc = msg->value;
3966 break;
3967 case WNI_CFG_HT_CAP_INFO_SHORT_GI_20MHZ:
3968 pe_session->htConfig.ht_sgi20 = msg->value;
3969 break;
3970 case WNI_CFG_HT_CAP_INFO_SHORT_GI_40MHZ:
3971 pe_session->htConfig.ht_sgi40 = msg->value;
3972 break;
3973 }
3974
3975 if (LIM_IS_AP_ROLE(pe_session)) {
3976 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
3977 lim_send_beacon_ind(mac_ctx, pe_session);
3978 }
3979}
3980
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003981void
3982lim_send_vdev_restart(tpAniSirGlobal pMac,
3983 tpPESession psessionEntry, uint8_t sessionId)
3984{
3985 tpHalHiddenSsidVdevRestart pHalHiddenSsidVdevRestart = NULL;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07003986 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003987 tSirRetStatus retCode = eSIR_SUCCESS;
3988
3989 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003990 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003991 return;
3992 }
3993
3994 pHalHiddenSsidVdevRestart =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303995 qdf_mem_malloc(sizeof(tHalHiddenSsidVdevRestart));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003996 if (NULL == pHalHiddenSsidVdevRestart) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07003997 pe_err("Unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003998 return;
3999 }
4000
4001 pHalHiddenSsidVdevRestart->ssidHidden = psessionEntry->ssidHidden;
4002 pHalHiddenSsidVdevRestart->sessionId = sessionId;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07004003 pHalHiddenSsidVdevRestart->pe_session_id = psessionEntry->peSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004004
4005 msgQ.type = WMA_HIDDEN_SSID_VDEV_RESTART;
4006 msgQ.bodyptr = pHalHiddenSsidVdevRestart;
4007 msgQ.bodyval = 0;
4008
4009 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4010 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004011 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304012 qdf_mem_free(pHalHiddenSsidVdevRestart);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004013 }
4014}
4015
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304016/**
4017 * __lim_process_roam_scan_offload_req() - Process Roam scan offload from csr
4018 * @mac_ctx: Pointer to Global MAC structure
4019 * @msg_buf: Pointer to SME message buffer
4020 *
4021 * Return: None
4022 */
4023static void __lim_process_roam_scan_offload_req(tpAniSirGlobal mac_ctx,
4024 uint32_t *msg_buf)
4025{
4026 tpPESession pe_session;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004027 struct scheduler_msg wma_msg = {0};
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304028 tSirRetStatus status;
4029 tSirRoamOffloadScanReq *req_buffer;
4030 uint16_t local_ie_len;
4031 uint8_t *local_ie_buf;
4032
4033 req_buffer = (tSirRoamOffloadScanReq *)msg_buf;
4034 pe_session = pe_find_session_by_sme_session_id(mac_ctx,
4035 req_buffer->sessionId);
4036
4037 local_ie_buf = qdf_mem_malloc(MAX_DEFAULT_SCAN_IE_LEN);
4038 if (!local_ie_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004039 pe_err("Mem Alloc failed for local_ie_buf");
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05304040 qdf_mem_free(req_buffer);
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304041 return;
4042 }
4043
4044 local_ie_len = req_buffer->assoc_ie.length;
4045 /* Update ext cap IE if present */
4046 if (local_ie_len &&
Arif Hussain963331b2016-10-27 22:59:01 -07004047 !lim_update_ext_cap_ie(mac_ctx, req_buffer->assoc_ie.addIEdata,
4048 local_ie_buf, &local_ie_len)) {
4049 if (local_ie_len <
Arif Hussainc2bb4402016-10-25 15:24:08 -07004050 QDF_ARRAY_SIZE(req_buffer->assoc_ie.addIEdata)) {
4051 req_buffer->assoc_ie.length = local_ie_len;
4052 qdf_mem_copy(req_buffer->assoc_ie.addIEdata,
4053 local_ie_buf, local_ie_len);
4054 }
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304055 }
4056 qdf_mem_free(local_ie_buf);
4057
4058 wma_msg.type = WMA_ROAM_SCAN_OFFLOAD_REQ;
4059 wma_msg.bodyptr = req_buffer;
4060
4061 status = wma_post_ctrl_msg(mac_ctx, &wma_msg);
4062 if (eSIR_SUCCESS != status) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004063 pe_err("Posting WMA_ROAM_SCAN_OFFLOAD_REQ failed");
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05304064 qdf_mem_free(req_buffer);
4065 }
4066}
4067
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304068/*
4069 * lim_handle_update_ssid_hidden() - Processes SSID hidden update
4070 * @mac_ctx: Pointer to global mac context
4071 * @session: Pointer to PE session
4072 * @ssid_hidden: SSID hidden value to set; 0 - Broadcast SSID,
4073 * 1 - Disable broadcast SSID
4074 *
4075 * Return: None
4076 */
4077static void lim_handle_update_ssid_hidden(tpAniSirGlobal mac_ctx,
4078 tpPESession session, uint8_t ssid_hidden)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004079{
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07004080 pe_debug("rcvd HIDE_SSID message old HIDE_SSID: %d new HIDE_SSID: %d",
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004081 session->ssidHidden, ssid_hidden);
4082
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07004083 if (ssid_hidden != session->ssidHidden) {
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304084 session->ssidHidden = ssid_hidden;
Kiran Kumar Lokere5798bfa2017-04-27 20:49:39 -07004085 } else {
4086 pe_debug("Dont process HIDE_SSID msg with existing setting");
Selvaraj, Sridhara0083c42016-06-22 22:15:43 +05304087 return;
4088 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004089
4090 /* Send vdev restart */
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304091 lim_send_vdev_restart(mac_ctx, session, session->smeSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004092
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004093 return;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304094}
4095
4096/**
4097 * __lim_process_sme_session_update - process SME session update msg
4098 *
4099 * @mac_ctx: Pointer to global mac context
4100 * @msg_buf: Pointer to the received message buffer
4101 *
4102 * Return: None
4103 */
4104static void __lim_process_sme_session_update(tpAniSirGlobal mac_ctx,
4105 uint32_t *msg_buf)
4106{
4107 struct sir_update_session_param *msg;
4108 tpPESession session;
4109
4110 if (!msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004111 pe_err("Buffer is Pointing to NULL");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304112 return;
4113 }
4114
4115 msg = (struct sir_update_session_param *) msg_buf;
4116
4117 session = pe_find_session_by_sme_session_id(mac_ctx, msg->session_id);
4118 if (!session) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004119 pe_warn("Session does not exist for given sessionId %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304120 msg->session_id);
4121 return;
4122 }
4123
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004124 pe_debug("received SME Session update for %d val %d",
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304125 msg->param_type, msg->param_val);
4126 switch (msg->param_type) {
4127 case SIR_PARAM_SSID_HIDDEN:
4128 lim_handle_update_ssid_hidden(mac_ctx, session, msg->param_val);
4129 break;
Selvaraj, Sridharac4fcf32016-09-28 12:57:32 +05304130 case SIR_PARAM_IGNORE_ASSOC_DISALLOWED:
4131 session->ignore_assoc_disallowed = msg->param_val;
4132 break;
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304133 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004134 pe_err("Unknown session param");
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05304135 break;
4136 }
4137}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004138
4139static void __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4140{
4141 tpSirUpdateAPWPARSNIEsReq pUpdateAPWPARSNIEsReq;
4142 tpPESession psessionEntry;
4143 uint8_t sessionId; /* PE sessionID */
4144
4145 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004146 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004147 return;
4148 }
4149
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304150 pUpdateAPWPARSNIEsReq = qdf_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004151 if (NULL == pUpdateAPWPARSNIEsReq) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004152 pe_err("call to AllocateMemory failed for pUpdateAPWPARSNIEsReq");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004153 return;
4154 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304155 qdf_mem_copy(pUpdateAPWPARSNIEsReq, pMsgBuf,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004156 sizeof(struct sSirUpdateAPWPARSNIEsReq));
4157
4158 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdaeba9ca52015-11-24 14:09:39 -08004159 pUpdateAPWPARSNIEsReq->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004160 &sessionId);
4161 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004162 pe_warn("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004163 goto end;
4164 }
4165
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304166 qdf_mem_copy(&psessionEntry->pLimStartBssReq->rsnIE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004167 &pUpdateAPWPARSNIEsReq->APWPARSNIEs, sizeof(tSirRSNie));
4168
4169 lim_set_rs_nie_wp_aiefrom_sme_start_bss_req_message(pMac,
4170 &psessionEntry->
4171 pLimStartBssReq->rsnIE,
4172 psessionEntry);
4173
4174 psessionEntry->pLimStartBssReq->privacy = 1;
4175 psessionEntry->privacy = 1;
4176
4177 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4178 lim_send_beacon_ind(pMac, psessionEntry);
4179
4180end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304181 qdf_mem_free(pUpdateAPWPARSNIEsReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004182 return;
4183} /*** end __lim_process_sme_set_wparsni_es(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4184
4185/*
4186 Update the beacon Interval dynamically if beaconInterval is different in MCC
4187 */
4188static void __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4189{
4190 tpSirChangeBIParams pChangeBIParams;
4191 tpPESession psessionEntry;
4192 uint8_t sessionId = 0;
4193 tUpdateBeaconParams beaconParams;
4194
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004195 pe_debug("received Update Beacon Interval message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004196
4197 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004198 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004199 return;
4200 }
4201
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304202 qdf_mem_zero(&beaconParams, sizeof(tUpdateBeaconParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004203 pChangeBIParams = (tpSirChangeBIParams) pMsgBuf;
4204
4205 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowda8e717d32015-11-24 15:54:33 -08004206 pChangeBIParams->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004207 &sessionId);
4208 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004209 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004210 return;
4211 }
4212
4213 /*Update sessionEntry Beacon Interval */
4214 if (psessionEntry->beaconParams.beaconInterval !=
4215 pChangeBIParams->beaconInterval) {
4216 psessionEntry->beaconParams.beaconInterval =
4217 pChangeBIParams->beaconInterval;
4218 }
4219
4220 /*Update sch beaconInterval */
4221 if (pMac->sch.schObject.gSchBeaconInterval !=
4222 pChangeBIParams->beaconInterval) {
4223 pMac->sch.schObject.gSchBeaconInterval =
4224 pChangeBIParams->beaconInterval;
4225
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004226 pe_debug("LIM send update BeaconInterval Indication: %d",
4227 pChangeBIParams->beaconInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004228
4229 if (false == pMac->sap.SapDfsInfo.is_dfs_cac_timer_running) {
4230 /* Update beacon */
4231 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4232
4233 beaconParams.bssIdx = psessionEntry->bssIdx;
4234 /* Set change in beacon Interval */
4235 beaconParams.beaconInterval =
4236 pChangeBIParams->beaconInterval;
4237 beaconParams.paramChangeBitmap =
4238 PARAM_BCN_INTERVAL_CHANGED;
4239 lim_send_beacon_params(pMac, &beaconParams, psessionEntry);
4240 }
4241 }
4242
4243 return;
4244} /*** end __lim_process_sme_change_bi(tpAniSirGlobal pMac, uint32_t *pMsgBuf) ***/
4245
4246#ifdef QCA_HT_2040_COEX
4247static void __lim_process_sme_set_ht2040_mode(tpAniSirGlobal pMac,
4248 uint32_t *pMsgBuf)
4249{
4250 tpSirSetHT2040Mode pSetHT2040Mode;
4251 tpPESession psessionEntry;
4252 uint8_t sessionId = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004253 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004254 tUpdateVHTOpMode *pHtOpMode = NULL;
4255 uint16_t staId = 0;
4256 tpDphHashNode pStaDs = NULL;
4257
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004258 pe_debug("received Set HT 20/40 mode message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004259 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004260 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004261 return;
4262 }
4263
4264 pSetHT2040Mode = (tpSirSetHT2040Mode) pMsgBuf;
4265
4266 psessionEntry = pe_find_session_by_bssid(pMac,
Srinivas Girigowdac52474d2015-11-24 15:49:31 -08004267 pSetHT2040Mode->bssid.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004268 &sessionId);
4269 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004270 pe_debug("Session does not exist for given BSSID");
4271 lim_print_mac_addr(pMac, pSetHT2040Mode->bssid.bytes, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004272 return;
4273 }
4274
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004275 pe_debug("Update session entry for cbMod=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004276 pSetHT2040Mode->cbMode);
4277 /*Update sessionEntry HT related fields */
4278 switch (pSetHT2040Mode->cbMode) {
4279 case PHY_SINGLE_CHANNEL_CENTERED:
4280 psessionEntry->htSecondaryChannelOffset =
4281 PHY_SINGLE_CHANNEL_CENTERED;
4282 psessionEntry->htRecommendedTxWidthSet = 0;
4283 if (pSetHT2040Mode->obssEnabled)
4284 psessionEntry->htSupportedChannelWidthSet
4285 = eHT_CHANNEL_WIDTH_40MHZ;
4286 else
4287 psessionEntry->htSupportedChannelWidthSet
4288 = eHT_CHANNEL_WIDTH_20MHZ;
4289 break;
4290 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
4291 psessionEntry->htSecondaryChannelOffset =
4292 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4293 psessionEntry->htRecommendedTxWidthSet = 1;
4294 break;
4295 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
4296 psessionEntry->htSecondaryChannelOffset =
4297 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4298 psessionEntry->htRecommendedTxWidthSet = 1;
4299 break;
4300 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004301 pe_err("Invalid cbMode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004302 return;
4303 }
4304
4305 /* Update beacon */
4306 sch_set_fixed_beacon_fields(pMac, psessionEntry);
4307 lim_send_beacon_ind(pMac, psessionEntry);
4308
4309 /* update OP Mode for each associated peer */
4310 for (staId = 0; staId < psessionEntry->dph.dphHashTable.size; staId++) {
4311 pStaDs = dph_get_hash_entry(pMac, staId,
4312 &psessionEntry->dph.dphHashTable);
4313 if (NULL == pStaDs)
4314 continue;
4315
4316 if (pStaDs->valid && pStaDs->htSupportedChannelWidthSet) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304317 pHtOpMode = qdf_mem_malloc(sizeof(tUpdateVHTOpMode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004318 if (NULL == pHtOpMode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004319 pe_err("Not able to allocate memory for setting OP mode");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004320 return;
4321 }
4322 pHtOpMode->opMode =
4323 (psessionEntry->htSecondaryChannelOffset ==
4324 PHY_SINGLE_CHANNEL_CENTERED) ?
4325 eHT_CHANNEL_WIDTH_20MHZ : eHT_CHANNEL_WIDTH_40MHZ;
4326 pHtOpMode->staId = staId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304327 qdf_mem_copy(pHtOpMode->peer_mac, &pStaDs->staAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004328 sizeof(tSirMacAddr));
4329 pHtOpMode->smesessionId = sessionId;
4330
4331 msg.type = WMA_UPDATE_OP_MODE;
4332 msg.reserved = 0;
4333 msg.bodyptr = pHtOpMode;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004334 if (!QDF_IS_STATUS_SUCCESS
4335 (scheduler_post_msg(QDF_MODULE_ID_WMA, &msg))) {
4336 pe_err("Not able to post WMA_UPDATE_OP_MODE message to WMA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304337 qdf_mem_free(pHtOpMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004338 return;
4339 }
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004340 pe_debug("Notifed FW about OP mode: %d for staId=%d",
4341 pHtOpMode->opMode, staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004342
4343 } else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004344 pe_debug("station %d does not support HT40", staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004345 }
4346
4347 return;
4348}
4349#endif
4350
4351/* -------------------------------------------------------------------- */
4352/**
4353 * __lim_process_report_message
4354 *
4355 * FUNCTION: Processes the next received Radio Resource Management message
4356 *
4357 * LOGIC:
4358 *
4359 * ASSUMPTIONS:
4360 *
4361 * NOTE:
4362 *
4363 * @param None
4364 * @return None
4365 */
4366
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004367static void __lim_process_report_message(tpAniSirGlobal pMac,
4368 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004369{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004370 switch (pMsg->type) {
4371 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
4372 rrm_process_neighbor_report_req(pMac, pMsg->bodyptr);
4373 break;
4374 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004375 rrm_process_beacon_report_xmit(pMac, pMsg->bodyptr);
Krishna Kumaar Natarajanf599c6e2015-11-03 11:44:03 -08004376 break;
4377 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004378 pe_err("Invalid msg type: %d", pMsg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004379 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004380}
4381
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004382/* -------------------------------------------------------------------- */
4383/**
4384 * lim_send_set_max_tx_power_req
4385 *
4386 * FUNCTION: Send SIR_HAL_SET_MAX_TX_POWER_REQ message to change the max tx power.
4387 *
4388 * LOGIC:
4389 *
4390 * ASSUMPTIONS:
4391 *
4392 * NOTE:
4393 *
4394 * @param txPower txPower to be set.
4395 * @param pSessionEntry session entry.
4396 * @return None
4397 */
4398tSirRetStatus
Amar Singhala297bfa2015-10-15 15:07:29 -07004399lim_send_set_max_tx_power_req(tpAniSirGlobal pMac, int8_t txPower,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004400 tpPESession pSessionEntry)
4401{
4402 tpMaxTxPowerParams pMaxTxParams = NULL;
4403 tSirRetStatus retCode = eSIR_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004404 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004405
4406 if (pSessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004407 pe_err("Invalid parameters");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004408 return eSIR_FAILURE;
4409 }
4410
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304411 pMaxTxParams = qdf_mem_malloc(sizeof(tMaxTxPowerParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004412 if (NULL == pMaxTxParams) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004413 pe_err("Unable to allocate memory for pMaxTxParams");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004414 return eSIR_MEM_ALLOC_FAILED;
4415
4416 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004417 pMaxTxParams->power = txPower;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304418 qdf_mem_copy(pMaxTxParams->bssId.bytes, pSessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304419 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304420 qdf_mem_copy(pMaxTxParams->selfStaMacAddr.bytes,
Srinivas Girigowda97215232015-09-24 12:26:28 -07004421 pSessionEntry->selfMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304422 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004423
4424 msgQ.type = WMA_SET_MAX_TX_POWER_REQ;
4425 msgQ.bodyptr = pMaxTxParams;
4426 msgQ.bodyval = 0;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004427 pe_debug("Post WMA_SET_MAX_TX_POWER_REQ to WMA");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004428 MTRACE(mac_trace_msg_tx(pMac, pSessionEntry->peSessionId, msgQ.type));
4429 retCode = wma_post_ctrl_msg(pMac, &msgQ);
4430 if (eSIR_SUCCESS != retCode) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004431 pe_err("wma_post_ctrl_msg() failed");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304432 qdf_mem_free(pMaxTxParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004433 }
4434 return retCode;
4435}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004436
4437/**
4438 * __lim_process_sme_register_mgmt_frame_req() - process sme reg mgmt frame req
4439 *
4440 * @mac_ctx: Pointer to Global MAC structure
4441 * @msg_buf: pointer to the SME message buffer
4442 *
4443 * This function is called to process eWNI_SME_REGISTER_MGMT_FRAME_REQ message
4444 * from SME. It Register this information within PE.
4445 *
4446 * Return: None
4447 */
4448static void __lim_process_sme_register_mgmt_frame_req(tpAniSirGlobal mac_ctx,
4449 uint32_t *msg_buf)
4450{
Anurag Chouhanffb21542016-02-17 14:33:03 +05304451 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004452 tpSirRegisterMgmtFrame sme_req = (tpSirRegisterMgmtFrame)msg_buf;
4453 struct mgmt_frm_reg_info *lim_mgmt_regn = NULL;
4454 struct mgmt_frm_reg_info *next = NULL;
4455 bool match = false;
4456
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004457 pe_debug("registerFrame %d, frameType %d, matchLen %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004458 sme_req->registerFrame, sme_req->frameType,
4459 sme_req->matchLen);
4460 /* First check whether entry exists already */
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304461 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304462 qdf_list_peek_front(&mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
4463 (qdf_list_node_t **) &lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304464 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004465
4466 while (lim_mgmt_regn != NULL) {
4467 if (lim_mgmt_regn->frameType != sme_req->frameType)
4468 goto skip_match;
4469 if (sme_req->matchLen) {
4470 if ((lim_mgmt_regn->matchLen == sme_req->matchLen) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304471 (!qdf_mem_cmp(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004472 sme_req->matchData,
4473 lim_mgmt_regn->matchLen))) {
4474 /* found match! */
4475 match = true;
4476 break;
4477 }
4478 } else {
4479 /* found match! */
4480 match = true;
4481 break;
4482 }
4483skip_match:
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304484 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304485 qdf_status = qdf_list_peek_next(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004486 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Anurag Chouhanffb21542016-02-17 14:33:03 +05304487 (qdf_list_node_t *)lim_mgmt_regn,
4488 (qdf_list_node_t **)&next);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304489 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004490 lim_mgmt_regn = next;
4491 next = NULL;
4492 }
4493 if (match) {
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304494 qdf_mutex_acquire(&mac_ctx->lim.lim_frame_register_lock);
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004495 if (QDF_STATUS_SUCCESS ==
4496 qdf_list_remove_node(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004497 &mac_ctx->lim.gLimMgmtFrameRegistratinQueue,
Naveen Rawat1a3dac62016-10-25 12:44:57 -07004498 (qdf_list_node_t *)lim_mgmt_regn))
4499 qdf_mem_free(lim_mgmt_regn);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304500 qdf_mutex_release(&mac_ctx->lim.lim_frame_register_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004501 }
4502
4503 if (sme_req->registerFrame) {
4504 lim_mgmt_regn =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304505 qdf_mem_malloc(sizeof(struct mgmt_frm_reg_info) +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004506 sme_req->matchLen);
4507 if (lim_mgmt_regn != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004508 lim_mgmt_regn->frameType = sme_req->frameType;
4509 lim_mgmt_regn->matchLen = sme_req->matchLen;
4510 lim_mgmt_regn->sessionId = sme_req->sessionId;
4511 if (sme_req->matchLen) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304512 qdf_mem_copy(lim_mgmt_regn->matchData,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004513 sme_req->matchData,
4514 sme_req->matchLen);
4515 }
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304516 qdf_mutex_acquire(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004517 &mac_ctx->lim.lim_frame_register_lock);
Anurag Chouhanffb21542016-02-17 14:33:03 +05304518 qdf_list_insert_front(&mac_ctx->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004519 gLimMgmtFrameRegistratinQueue,
4520 &lim_mgmt_regn->node);
Anurag Chouhana37b5b72016-02-21 14:53:42 +05304521 qdf_mutex_release(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004522 &mac_ctx->lim.lim_frame_register_lock);
4523 }
4524 }
4525 return;
4526}
4527
4528static void __lim_deregister_deferred_sme_req_after_noa_start(tpAniSirGlobal pMac)
4529{
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004530 pe_debug("Dereg msgType %d", pMac->lim.gDeferMsgTypeForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004531 pMac->lim.gDeferMsgTypeForNOA = 0;
4532 if (pMac->lim.gpDefdSmeMsgForNOA != NULL) {
4533 /* __lim_process_sme_scan_req consumed the buffer. We can free it. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304534 qdf_mem_free(pMac->lim.gpDefdSmeMsgForNOA);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004535 pMac->lim.gpDefdSmeMsgForNOA = NULL;
4536 }
4537}
4538
4539/**
4540 * lim_process_regd_defd_sme_req_after_noa_start()
4541 *
4542 * mac_ctx: Pointer to Global MAC structure
4543 *
4544 * This function is called to process deferred sme req message
4545 * after noa start.
4546 *
4547 * Return: None
4548 */
4549void lim_process_regd_defd_sme_req_after_noa_start(tpAniSirGlobal mac_ctx)
4550{
4551 bool buf_consumed = true;
4552
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004553 pe_debug("Process defd sme req %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004554 mac_ctx->lim.gDeferMsgTypeForNOA);
4555
4556 if ((mac_ctx->lim.gDeferMsgTypeForNOA == 0) ||
4557 (mac_ctx->lim.gpDefdSmeMsgForNOA == NULL)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004558 pe_warn("start rcvd from FW when no sme deferred msg pending. Do nothing");
4559 pe_warn("It may happen when NOA start ind and timeout happen at the same time");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004560 return;
4561 }
4562 switch (mac_ctx->lim.gDeferMsgTypeForNOA) {
4563 case eWNI_SME_SCAN_REQ:
4564 __lim_process_sme_scan_req(mac_ctx,
4565 mac_ctx->lim.gpDefdSmeMsgForNOA);
4566 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004567 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
4568 buf_consumed = lim_process_remain_on_chnl_req(mac_ctx,
4569 mac_ctx->lim.gpDefdSmeMsgForNOA);
4570 /*
4571 * lim_process_remain_on_chnl_req doesnt want us to free
4572 * the buffer since it is freed in lim_remain_on_chn_rsp.
4573 * this change is to avoid "double free"
4574 */
4575 if (false == buf_consumed)
4576 mac_ctx->lim.gpDefdSmeMsgForNOA = NULL;
4577 break;
4578 case eWNI_SME_JOIN_REQ:
4579 __lim_process_sme_join_req(mac_ctx,
4580 mac_ctx->lim.gpDefdSmeMsgForNOA);
4581 break;
4582 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004583 pe_err("Unknown deferred msg type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004584 mac_ctx->lim.gDeferMsgTypeForNOA);
4585 break;
4586 }
4587 __lim_deregister_deferred_sme_req_after_noa_start(mac_ctx);
4588}
4589
4590static void
4591__lim_process_sme_reset_ap_caps_change(tpAniSirGlobal pMac, uint32_t *pMsgBuf)
4592{
4593 tpSirResetAPCapsChange pResetCapsChange;
4594 tpPESession psessionEntry;
4595 uint8_t sessionId = 0;
4596 if (pMsgBuf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004597 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004598 return;
4599 }
4600
4601 pResetCapsChange = (tpSirResetAPCapsChange) pMsgBuf;
4602 psessionEntry =
Srinivas Girigowda40567b92015-09-24 15:17:25 -07004603 pe_find_session_by_bssid(pMac, pResetCapsChange->bssId.bytes,
4604 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004605 if (psessionEntry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004606 pe_err("Session does not exist for given BSSID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004607 return;
4608 }
4609
4610 psessionEntry->limSentCapsChangeNtf = false;
4611 return;
4612}
4613
4614/**
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304615 * lim_register_p2p_ack_ind_cb() - Save the p2p ack indication callback.
4616 * @mac_ctx: Mac pointer
4617 * @msg_buf: Msg pointer containing the callback
4618 *
4619 * This function is used to save the p2p ack indication callback in PE.
4620 *
4621 * Return: None
4622 */
4623static void lim_register_p2p_ack_ind_cb(tpAniSirGlobal mac_ctx,
4624 uint32_t *msg_buf)
4625{
4626 struct sir_sme_p2p_ack_ind_cb_req *sme_req =
4627 (struct sir_sme_p2p_ack_ind_cb_req *)msg_buf;
4628
4629 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004630 pe_err("msg_buf is null");
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304631 return;
4632 }
4633 if (sme_req->callback)
4634 mac_ctx->p2p_ack_ind_cb =
4635 sme_req->callback;
4636 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004637 pe_err("sme_req->callback is null");
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05304638}
4639
4640/**
Abhishek Singh7996eb72015-12-30 17:24:02 +05304641 * lim_register_mgmt_frame_ind_cb() - Save the Management frame
4642 * indication callback in PE.
4643 * @mac_ptr: Mac pointer
4644 * @msg_buf: Msg pointer containing the callback
4645 *
4646 * This function is used save the Management frame
4647 * indication callback in PE.
4648 *
4649 * Return: None
4650 */
4651static void lim_register_mgmt_frame_ind_cb(tpAniSirGlobal mac_ctx,
4652 uint32_t *msg_buf)
4653{
4654 struct sir_sme_mgmt_frame_cb_req *sme_req =
4655 (struct sir_sme_mgmt_frame_cb_req *)msg_buf;
4656
4657 if (NULL == msg_buf) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004658 pe_err("msg_buf is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304659 return;
4660 }
4661 if (sme_req->callback)
4662 mac_ctx->mgmt_frame_ind_cb =
4663 (sir_mgmt_frame_ind_callback)sme_req->callback;
4664 else
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004665 pe_err("sme_req->callback is null");
Abhishek Singh7996eb72015-12-30 17:24:02 +05304666}
4667
4668/**
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304669 *__lim_process_send_disassoc_frame: function processes disassoc frame
4670 * @mac_ctx: pointer to mac context
4671 * @msg_buf: message buffer
4672 *
4673 * function processes disassoc request received from SME
4674 *
4675 * return: none
4676 */
4677static void __lim_process_send_disassoc_frame(tpAniSirGlobal mac_ctx,
4678 uint32_t *msg_buf)
4679{
4680 struct sme_send_disassoc_frm_req sme_send_disassoc_frame_req;
4681 tSirRetStatus status;
4682 tpPESession session_entry = NULL;
4683 uint8_t sme_session_id;
4684 uint16_t sme_trans_id;
4685
4686 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004687 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304688 return;
4689 }
4690
4691 lim_get_session_info(mac_ctx, (uint8_t *)msg_buf, &sme_session_id,
4692 &sme_trans_id);
4693
4694 status = lim_send_disassoc_frm_req_ser_des(mac_ctx,
4695 &sme_send_disassoc_frame_req,
4696 (uint8_t *)msg_buf);
4697
4698 if ((eSIR_FAILURE == status) ||
4699 (lim_is_group_addr(sme_send_disassoc_frame_req.peer_mac) &&
4700 !lim_is_addr_bc(sme_send_disassoc_frame_req.peer_mac))) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004701 pe_err("received invalid SME_DISASSOC_REQ message");
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304702 return;
4703 }
4704
4705 session_entry = pe_find_session_by_sme_session_id(
4706 mac_ctx, sme_session_id);
4707 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004708 pe_err("session does not exist for given bssId "MAC_ADDRESS_STR,
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05304709 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac));
4710 return;
4711 }
4712
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004713 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 +05304714 sme_send_disassoc_frame_req.msg_type,
4715 sme_send_disassoc_frame_req.length,
4716 sme_send_disassoc_frame_req.session_id,
4717 sme_send_disassoc_frame_req.trans_id,
4718 MAC_ADDR_ARRAY(sme_send_disassoc_frame_req.peer_mac),
4719 sme_send_disassoc_frame_req.reason,
4720 sme_send_disassoc_frame_req.wait_for_ack);
4721
4722 lim_send_disassoc_mgmt_frame(mac_ctx,
4723 sme_send_disassoc_frame_req.reason,
4724 sme_send_disassoc_frame_req.peer_mac,
4725 session_entry, sme_send_disassoc_frame_req.wait_for_ack);
4726}
4727
4728/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004729 * lim_set_pdev_ht_ie() - sends the set HT IE req to FW
4730 * @mac_ctx: Pointer to Global MAC structure
4731 * @pdev_id: pdev id to set the IE.
4732 * @nss: Nss values to prepare the HT IE.
4733 *
4734 * Prepares the HT IE with self capabilities for different
4735 * Nss values and sends the set HT IE req to FW.
4736 *
4737 * Return: None
4738 */
4739static void lim_set_pdev_ht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4740 uint8_t nss)
4741{
4742 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004743 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004744 tSirRetStatus rc = eSIR_SUCCESS;
4745 uint8_t *p_ie = NULL;
4746 tHtCaps *p_ht_cap;
4747 int i;
4748
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004749 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004750 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4751 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004752 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004753 return;
4754 }
4755 ie_params->nss = i;
4756 ie_params->pdev_id = pdev_id;
4757 ie_params->ie_type = DOT11_HT_IE;
4758 /* 2 for IE len and EID */
4759 ie_params->ie_len = 2 + sizeof(tHtCaps);
4760 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4761 if (NULL == ie_params->ie_ptr) {
4762 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004763 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004764 return;
4765 }
4766 *ie_params->ie_ptr = SIR_MAC_HT_CAPABILITIES_EID;
4767 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4768 lim_set_ht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4769 ie_params->ie_len);
4770
4771 if (NSS_1x1_MODE == i) {
4772 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4773 ie_params->ie_len,
4774 DOT11F_EID_HTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004775 if (NULL == p_ie) {
4776 qdf_mem_free(ie_params->ie_ptr);
4777 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004778 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004779 return;
4780 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004781 p_ht_cap = (tHtCaps *)&p_ie[2];
4782 p_ht_cap->supportedMCSSet[1] = 0;
4783 p_ht_cap->txSTBC = 0;
4784 }
4785
4786 msg.type = WMA_SET_PDEV_IE_REQ;
4787 msg.bodyptr = ie_params;
4788 msg.bodyval = 0;
4789
4790 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4791 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004792 pe_err("wma_post_ctrl_msg() return failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004793 qdf_mem_free(ie_params->ie_ptr);
4794 qdf_mem_free(ie_params);
4795 return;
4796 }
4797 }
4798}
4799
4800/**
4801 * lim_set_pdev_vht_ie() - sends the set VHT IE to req FW
4802 * @mac_ctx: Pointer to Global MAC structure
4803 * @pdev_id: pdev id to set the IE.
4804 * @nss: Nss values to prepare the VHT IE.
4805 *
4806 * Prepares the VHT IE with self capabilities for different
4807 * Nss values and sends the set VHT IE req to FW.
4808 *
4809 * Return: None
4810 */
4811static void lim_set_pdev_vht_ie(tpAniSirGlobal mac_ctx, uint8_t pdev_id,
4812 uint8_t nss)
4813{
4814 struct set_ie_param *ie_params;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004815 struct scheduler_msg msg = {0};
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004816 tSirRetStatus rc = eSIR_SUCCESS;
4817 uint8_t *p_ie = NULL;
4818 tSirMacVHTCapabilityInfo *vht_cap;
4819 int i;
4820 tSirVhtMcsInfo *vht_mcs;
4821
Kiran Kumar Lokere78790202016-09-16 14:09:50 -07004822 for (i = 1; i <= nss; i++) {
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004823 ie_params = qdf_mem_malloc(sizeof(*ie_params));
4824 if (NULL == ie_params) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004825 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004826 return;
4827 }
4828 ie_params->nss = i;
4829 ie_params->pdev_id = pdev_id;
4830 ie_params->ie_type = DOT11_VHT_IE;
4831 /* 2 for IE len and EID */
4832 ie_params->ie_len = 2 + sizeof(tSirMacVHTCapabilityInfo) +
4833 sizeof(tSirVhtMcsInfo);
4834 ie_params->ie_ptr = qdf_mem_malloc(ie_params->ie_len);
4835 if (NULL == ie_params->ie_ptr) {
4836 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004837 pe_err("mem alloc failed");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004838 return;
4839 }
4840 *ie_params->ie_ptr = SIR_MAC_VHT_CAPABILITIES_EID;
4841 *(ie_params->ie_ptr + 1) = ie_params->ie_len - 2;
4842 lim_set_vht_caps(mac_ctx, NULL, ie_params->ie_ptr,
4843 ie_params->ie_len);
4844
4845 if (NSS_1x1_MODE == i) {
4846 p_ie = lim_get_ie_ptr_new(mac_ctx, ie_params->ie_ptr,
4847 ie_params->ie_len,
4848 DOT11F_EID_VHTCAPS, ONE_BYTE);
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004849 if (NULL == p_ie) {
4850 qdf_mem_free(ie_params->ie_ptr);
4851 qdf_mem_free(ie_params);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004852 pe_err("failed to get IE ptr");
Kiran Kumar Lokere53981332016-05-02 18:12:11 -07004853 return;
4854 }
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004855 vht_cap = (tSirMacVHTCapabilityInfo *)&p_ie[2];
4856 vht_cap->txSTBC = 0;
4857 vht_mcs =
4858 (tSirVhtMcsInfo *)&p_ie[2 +
4859 sizeof(tSirMacVHTCapabilityInfo)];
4860 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
4861 vht_mcs->rxHighest =
4862 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4863 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
4864 vht_mcs->txHighest =
4865 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
4866 }
4867 msg.type = WMA_SET_PDEV_IE_REQ;
4868 msg.bodyptr = ie_params;
4869 msg.bodyval = 0;
4870
4871 rc = wma_post_ctrl_msg(mac_ctx, &msg);
4872 if (rc != eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004873 pe_err("wma_post_ctrl_msg failure");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004874 qdf_mem_free(ie_params->ie_ptr);
4875 qdf_mem_free(ie_params);
4876 return;
4877 }
4878 }
4879}
4880
4881/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07004882 * lim_process_set_vdev_ies_per_band() - process the set vdev IE req
4883 * @mac_ctx: Pointer to Global MAC structure
4884 * @msg_buf: Pointer to the SME message buffer
4885 *
4886 * This function is called by limProcessMessageQueue(). This function sets the
4887 * VDEV IEs to the FW.
4888 *
4889 * Return: None
4890 */
4891static void lim_process_set_vdev_ies_per_band(tpAniSirGlobal mac_ctx,
4892 uint32_t *msg_buf)
4893{
4894 struct sir_set_vdev_ies_per_band *p_msg =
4895 (struct sir_set_vdev_ies_per_band *)msg_buf;
4896
4897 if (NULL == p_msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004898 pe_err("NULL p_msg");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004899 return;
4900 }
4901
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004902 pe_debug("rcvd set vdev ie per band req vdev_id = %d",
Naveen Rawata410c5a2016-09-19 14:22:33 -07004903 p_msg->vdev_id);
4904 /* intentionally using NULL here so that self capabilty are sent */
4905 if (lim_send_ies_per_band(mac_ctx, NULL, p_msg->vdev_id) !=
4906 QDF_STATUS_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004907 pe_err("Unable to send HT/VHT Cap to FW");
Naveen Rawata410c5a2016-09-19 14:22:33 -07004908}
4909
4910/**
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004911 * lim_process_set_pdev_IEs() - process the set pdev IE req
4912 * @mac_ctx: Pointer to Global MAC structure
4913 * @msg_buf: Pointer to the SME message buffer
4914 *
4915 * This function is called by limProcessMessageQueue(). This
4916 * function sets the PDEV IEs to the FW.
4917 *
4918 * Return: None
4919 */
4920static void lim_process_set_pdev_IEs(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
4921{
4922 struct sir_set_ht_vht_cfg *ht_vht_cfg;
4923
4924 ht_vht_cfg = (struct sir_set_ht_vht_cfg *)msg_buf;
4925
4926 if (NULL == ht_vht_cfg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004927 pe_err("NULL ht_vht_cfg");
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004928 return;
4929 }
4930
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004931 pe_debug("rcvd set pdev ht vht ie req with nss = %d",
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07004932 ht_vht_cfg->nss);
4933 lim_set_pdev_ht_ie(mac_ctx, ht_vht_cfg->pdev_id, ht_vht_cfg->nss);
4934
4935 if (IS_DOT11_MODE_VHT(ht_vht_cfg->dot11mode))
4936 lim_set_pdev_vht_ie(mac_ctx, ht_vht_cfg->pdev_id,
4937 ht_vht_cfg->nss);
4938}
4939
4940/**
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304941 * lim_process_sme_update_access_policy_vendor_ie: function updates vendor IE
4942 *
4943 * access policy
4944 * @mac_ctx: pointer to mac context
4945 * @msg: message buffer
4946 *
4947 * function processes vendor IE and access policy from SME and updates PE
4948 *
4949 * session entry
4950 *
4951 * return: none
4952*/
4953static void lim_process_sme_update_access_policy_vendor_ie(
4954 tpAniSirGlobal mac_ctx,
4955 uint32_t *msg)
4956{
4957 struct sme_update_access_policy_vendor_ie *update_vendor_ie;
4958 struct sPESession *pe_session_entry;
4959 uint8_t num_bytes;
4960
4961 if (!msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004962 pe_err("Buffer is Pointing to NULL");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304963 return;
4964 }
4965 update_vendor_ie = (struct sme_update_access_policy_vendor_ie *) msg;
4966 pe_session_entry = pe_find_session_by_sme_session_id(mac_ctx,
4967 update_vendor_ie->sme_session_id);
4968
4969 if (!pe_session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004970 pe_err("Session does not exist for given sme session id(%hu)",
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304971 update_vendor_ie->sme_session_id);
4972 return;
4973 }
4974 if (pe_session_entry->access_policy_vendor_ie)
4975 qdf_mem_free(pe_session_entry->access_policy_vendor_ie);
4976
4977 num_bytes = update_vendor_ie->ie[1] + 2;
4978 pe_session_entry->access_policy_vendor_ie = qdf_mem_malloc(num_bytes);
4979
4980 if (!pe_session_entry->access_policy_vendor_ie) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07004981 pe_err("Failed to allocate memory for vendor ie");
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05304982 return;
4983 }
4984 qdf_mem_copy(pe_session_entry->access_policy_vendor_ie,
4985 &update_vendor_ie->ie[0], num_bytes);
4986
4987 pe_session_entry->access_policy = update_vendor_ie->access_policy;
4988}
4989
4990/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004991 * lim_process_sme_req_messages()
4992 *
4993 ***FUNCTION:
4994 * This function is called by limProcessMessageQueue(). This
4995 * function processes SME request messages from HDD or upper layer
4996 * application.
4997 *
4998 ***LOGIC:
4999 *
5000 ***ASSUMPTIONS:
5001 *
5002 ***NOTE:
5003 *
5004 * @param pMac Pointer to Global MAC structure
5005 * @param msgType Indicates the SME message type
5006 * @param *pMsgBuf A pointer to the SME message buffer
5007 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5008 * false - if pMsgBuf is not to be freed.
5009 */
5010
Rajeev Kumarfeb96382017-01-22 19:42:09 -08005011bool lim_process_sme_req_messages(tpAniSirGlobal pMac,
5012 struct scheduler_msg *pMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005013{
5014 bool bufConsumed = true; /* Set this flag to false within case block of any following message, that doesnt want pMsgBuf to be freed. */
5015 uint32_t *pMsgBuf = pMsg->bodyptr;
5016 tpSirSmeScanReq pScanReq;
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005017
5018 pe_debug("LIM Received SME Message %s(%d) Global LimSmeState:%s(%d) Global LimMlmState: %s(%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005019 lim_msg_str(pMsg->type), pMsg->type,
5020 lim_sme_state_str(pMac->lim.gLimSmeState), pMac->lim.gLimSmeState,
5021 lim_mlm_state_str(pMac->lim.gLimMlmState), pMac->lim.gLimMlmState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005022
5023 pScanReq = (tpSirSmeScanReq) pMsgBuf;
5024 /* If no insert NOA required then execute the code below */
5025
5026 switch (pMsg->type) {
5027 case eWNI_SME_SYS_READY_IND:
5028 bufConsumed = __lim_process_sme_sys_ready_ind(pMac, pMsgBuf);
5029 break;
5030
5031 case eWNI_SME_START_BSS_REQ:
5032 bufConsumed = __lim_process_sme_start_bss_req(pMac, pMsg);
5033 break;
5034
5035 case eWNI_SME_SCAN_REQ:
5036 __lim_process_sme_scan_req(pMac, pMsgBuf);
5037 break;
5038
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005039 case eWNI_SME_REMAIN_ON_CHANNEL_REQ:
5040 bufConsumed = lim_process_remain_on_chnl_req(pMac, pMsgBuf);
5041 break;
5042
5043 case eWNI_SME_UPDATE_NOA:
5044 __lim_process_sme_no_a_update(pMac, pMsgBuf);
5045 break;
5046 case eWNI_SME_CLEAR_DFS_CHANNEL_LIST:
5047 __lim_process_clear_dfs_channel_list(pMac, pMsg);
5048 break;
5049 case eWNI_SME_JOIN_REQ:
5050 __lim_process_sme_join_req(pMac, pMsgBuf);
5051 break;
5052
5053 case eWNI_SME_REASSOC_REQ:
5054 __lim_process_sme_reassoc_req(pMac, pMsgBuf);
5055 break;
5056
5057 case eWNI_SME_DISASSOC_REQ:
5058 __lim_process_sme_disassoc_req(pMac, pMsgBuf);
5059 break;
5060
5061 case eWNI_SME_DISASSOC_CNF:
5062 case eWNI_SME_DEAUTH_CNF:
5063 __lim_process_sme_disassoc_cnf(pMac, pMsgBuf);
5064 break;
5065
5066 case eWNI_SME_DEAUTH_REQ:
5067 __lim_process_sme_deauth_req(pMac, pMsgBuf);
5068 break;
5069
Kondabattini, Ganesh3f2d02c2016-09-13 12:23:47 +05305070 case eWNI_SME_SEND_DISASSOC_FRAME:
5071 __lim_process_send_disassoc_frame(pMac, pMsgBuf);
5072 break;
5073
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005074 case eWNI_SME_SETCONTEXT_REQ:
5075 __lim_process_sme_set_context_req(pMac, pMsgBuf);
5076 break;
5077
5078 case eWNI_SME_STOP_BSS_REQ:
5079 bufConsumed = __lim_process_sme_stop_bss_req(pMac, pMsg);
5080 break;
5081
5082 case eWNI_SME_ASSOC_CNF:
5083 if (pMsg->type == eWNI_SME_ASSOC_CNF)
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005084 pe_debug("Received ASSOC_CNF message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005085 __lim_process_sme_assoc_cnf_new(pMac, pMsg->type,
5086 pMsgBuf);
5087 break;
5088
5089 case eWNI_SME_ADDTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005090 pe_debug("Received ADDTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005091 __lim_process_sme_addts_req(pMac, pMsgBuf);
5092 break;
5093
5094 case eWNI_SME_DELTS_REQ:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005095 pe_debug("Received DELTS_REQ message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005096 __lim_process_sme_delts_req(pMac, pMsgBuf);
5097 break;
5098
5099 case SIR_LIM_ADDTS_RSP_TIMEOUT:
Srinivas Girigowda28fb0122017-03-26 22:21:20 -07005100 pe_debug("Received SIR_LIM_ADDTS_RSP_TIMEOUT message");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005101 lim_process_sme_addts_rsp_timeout(pMac, pMsg->bodyval);
5102 break;
5103
5104 case eWNI_SME_GET_STATISTICS_REQ:
5105 __lim_process_sme_get_statistics_request(pMac, pMsgBuf);
5106 /* HAL consumes pMsgBuf. It will be freed there. Set bufConsumed to false. */
5107 bufConsumed = false;
5108 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005109#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005110 case eWNI_SME_GET_TSM_STATS_REQ:
5111 __lim_process_sme_get_tsm_stats_request(pMac, pMsgBuf);
5112 bufConsumed = false;
5113 break;
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005114#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005115 case eWNI_SME_GET_ASSOC_STAS_REQ:
5116 lim_process_sme_get_assoc_sta_info(pMac, pMsgBuf);
5117 break;
5118 case eWNI_SME_TKIP_CNTR_MEAS_REQ:
5119 lim_process_tkip_counter_measures(pMac, pMsgBuf);
5120 break;
5121
Selvaraj, Sridhar7231c5f2016-09-28 12:42:33 +05305122 case eWNI_SME_SESSION_UPDATE_PARAM:
5123 __lim_process_sme_session_update(pMac, pMsgBuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005124 break;
Selvaraj, Sridhar01741822016-08-30 18:26:19 +05305125 case eWNI_SME_ROAM_SCAN_OFFLOAD_REQ:
5126 __lim_process_roam_scan_offload_req(pMac, pMsgBuf);
5127 bufConsumed = false;
5128 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005129 case eWNI_SME_UPDATE_APWPSIE_REQ:
5130 __lim_process_sme_update_apwpsi_es(pMac, pMsgBuf);
5131 break;
5132 case eWNI_SME_GET_WPSPBC_SESSION_REQ:
5133 lim_process_sme_get_wpspbc_sessions(pMac, pMsgBuf);
5134 break;
5135
5136 case eWNI_SME_SET_APWPARSNIEs_REQ:
5137 __lim_process_sme_set_wparsni_es(pMac, pMsgBuf);
5138 break;
5139
5140 case eWNI_SME_CHNG_MCC_BEACON_INTERVAL:
5141 /* Update the beaconInterval */
5142 __lim_process_sme_change_bi(pMac, pMsgBuf);
5143 break;
5144
5145#ifdef QCA_HT_2040_COEX
5146 case eWNI_SME_SET_HT_2040_MODE:
5147 __lim_process_sme_set_ht2040_mode(pMac, pMsgBuf);
5148 break;
5149#endif
5150
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005151 case eWNI_SME_NEIGHBOR_REPORT_REQ_IND:
5152 case eWNI_SME_BEACON_REPORT_RESP_XMIT_IND:
5153 __lim_process_report_message(pMac, pMsg);
5154 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005155
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005156 case eWNI_SME_FT_PRE_AUTH_REQ:
5157 bufConsumed = (bool) lim_process_ft_pre_auth_req(pMac, pMsg);
5158 break;
5159 case eWNI_SME_FT_UPDATE_KEY:
5160 lim_process_ft_update_key(pMac, pMsgBuf);
5161 break;
5162
5163 case eWNI_SME_FT_AGGR_QOS_REQ:
5164 lim_process_ft_aggr_qos_req(pMac, pMsgBuf);
5165 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005166
5167 case eWNI_SME_REGISTER_MGMT_FRAME_REQ:
5168 __lim_process_sme_register_mgmt_frame_req(pMac, pMsgBuf);
5169 break;
5170#ifdef FEATURE_WLAN_TDLS
5171 case eWNI_SME_TDLS_SEND_MGMT_REQ:
5172 lim_process_sme_tdls_mgmt_send_req(pMac, pMsgBuf);
5173 break;
5174 case eWNI_SME_TDLS_ADD_STA_REQ:
5175 lim_process_sme_tdls_add_sta_req(pMac, pMsgBuf);
5176 break;
5177 case eWNI_SME_TDLS_DEL_STA_REQ:
5178 lim_process_sme_tdls_del_sta_req(pMac, pMsgBuf);
5179 break;
5180 case eWNI_SME_TDLS_LINK_ESTABLISH_REQ:
5181 lim_process_sme_tdls_link_establish_req(pMac, pMsgBuf);
5182 break;
5183#endif
5184 case eWNI_SME_RESET_AP_CAPS_CHANGED:
5185 __lim_process_sme_reset_ap_caps_change(pMac, pMsgBuf);
5186 break;
5187
5188 case eWNI_SME_CHANNEL_CHANGE_REQ:
5189 lim_process_sme_channel_change_request(pMac, pMsgBuf);
5190 break;
5191
5192 case eWNI_SME_START_BEACON_REQ:
5193 lim_process_sme_start_beacon_req(pMac, pMsgBuf);
5194 break;
5195
5196 case eWNI_SME_DFS_BEACON_CHAN_SW_IE_REQ:
5197 lim_process_sme_dfs_csa_ie_request(pMac, pMsgBuf);
5198 break;
5199
5200 case eWNI_SME_UPDATE_ADDITIONAL_IES:
5201 lim_process_update_add_ies(pMac, pMsgBuf);
5202 break;
5203
5204 case eWNI_SME_MODIFY_ADDITIONAL_IES:
5205 lim_process_modify_add_ies(pMac, pMsgBuf);
5206 break;
5207 case eWNI_SME_SET_HW_MODE_REQ:
5208 lim_process_set_hw_mode(pMac, pMsgBuf);
5209 break;
5210 case eWNI_SME_NSS_UPDATE_REQ:
5211 lim_process_nss_update_request(pMac, pMsgBuf);
5212 break;
5213 case eWNI_SME_SET_DUAL_MAC_CFG_REQ:
5214 lim_process_set_dual_mac_cfg_req(pMac, pMsgBuf);
5215 break;
5216 case eWNI_SME_SET_IE_REQ:
5217 lim_process_set_ie_req(pMac, pMsgBuf);
5218 break;
Abhishek Singh7996eb72015-12-30 17:24:02 +05305219 case eWNI_SME_REGISTER_MGMT_FRAME_CB:
5220 lim_register_mgmt_frame_ind_cb(pMac, pMsgBuf);
5221 break;
Abhishek Singh518323d2015-10-19 17:42:01 +05305222 case eWNI_SME_EXT_CHANGE_CHANNEL:
5223 lim_process_ext_change_channel(pMac, pMsgBuf);
5224 break;
Archana Ramachandrana20ef812015-11-13 16:12:13 -08005225 case eWNI_SME_SET_ANTENNA_MODE_REQ:
5226 lim_process_set_antenna_mode_req(pMac, pMsgBuf);
5227 break;
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005228 case eWNI_SME_PDEV_SET_HT_VHT_IE:
5229 lim_process_set_pdev_IEs(pMac, pMsgBuf);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005230 break;
5231 case eWNI_SME_SET_VDEV_IES_PER_BAND:
5232 lim_process_set_vdev_ies_per_band(pMac, pMsgBuf);
5233 break;
Naveen Rawatf28315c2016-06-29 18:06:02 -07005234 case eWNI_SME_NDP_END_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005235 case eWNI_SME_NDP_INITIATOR_REQ:
Abhishek Singh4fef7472016-06-06 11:36:03 -07005236 case eWNI_SME_NDP_RESPONDER_REQ:
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07005237 lim_handle_ndp_request_message(pMac, pMsg);
Kiran Kumar Lokere666bf852016-05-02 12:23:02 -07005238 break;
Selvaraj, Sridhar4577a9b2016-09-04 15:17:07 +05305239 case eWNI_SME_REGISTER_P2P_ACK_CB:
5240 lim_register_p2p_ack_ind_cb(pMac, pMsgBuf);
5241 break;
Kondabattini, Ganeshe4f18e02016-09-13 13:01:22 +05305242 case eWNI_SME_UPDATE_ACCESS_POLICY_VENDOR_IE:
5243 lim_process_sme_update_access_policy_vendor_ie(pMac, pMsgBuf);
5244 break;
Naveen Rawat8029a402017-06-01 10:54:19 -07005245 case eWNI_SME_UPDATE_CONFIG:
5246 lim_process_sme_update_config(pMac,
5247 (struct update_config *)pMsgBuf);
5248 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005249 default:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305250 qdf_mem_free((void *)pMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005251 pMsg->bodyptr = NULL;
5252 break;
5253 } /* switch (msgType) */
5254
5255 return bufConsumed;
5256} /*** end lim_process_sme_req_messages() ***/
5257
5258/**
5259 * lim_process_sme_start_beacon_req()
5260 *
5261 ***FUNCTION:
5262 * This function is called by limProcessMessageQueue(). This
5263 * function processes SME request messages from HDD or upper layer
5264 * application.
5265 *
5266 ***LOGIC:
5267 *
5268 ***ASSUMPTIONS:
5269 *
5270 ***NOTE:
5271 *
5272 * @param pMac Pointer to Global MAC structure
5273 * @param msgType Indicates the SME message type
5274 * @param *pMsgBuf A pointer to the SME message buffer
5275 * @return Boolean - true - if pMsgBuf is consumed and can be freed.
5276 * false - if pMsgBuf is not to be freed.
5277 */
5278static void lim_process_sme_start_beacon_req(tpAniSirGlobal pMac, uint32_t *pMsg)
5279{
5280 tpSirStartBeaconIndication pBeaconStartInd;
5281 tpPESession psessionEntry;
5282 uint8_t sessionId; /* PE sessionID */
5283
5284 if (pMsg == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005285 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005286 return;
5287 }
5288
5289 pBeaconStartInd = (tpSirStartBeaconIndication) pMsg;
5290 psessionEntry = pe_find_session_by_bssid(pMac,
5291 pBeaconStartInd->bssid,
5292 &sessionId);
5293 if (psessionEntry == NULL) {
5294 lim_print_mac_addr(pMac, pBeaconStartInd->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005295 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005296 return;
5297 }
5298
5299 if (pBeaconStartInd->beaconStartStatus == true) {
5300 /*
5301 * Currently this Indication comes from SAP
5302 * to start Beacon Tx on a DFS channel
5303 * since beaconing has to be done on DFS
5304 * channel only after CAC WAIT is completed.
5305 * On a DFS Channel LIM does not start beacon
5306 * Tx right after the WMA_ADD_BSS_RSP.
5307 */
5308 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh4294f802017-08-10 16:37:07 +05305309 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005310 FL("Start Beacon with ssid %s Ch %d"),
5311 psessionEntry->ssId.ssId,
5312 psessionEntry->currentOperChannel);
5313 lim_send_beacon_ind(pMac, psessionEntry);
5314 } else {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005315 pe_err("Invalid Beacon Start Indication");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005316 return;
5317 }
5318}
5319
5320/**
5321 * lim_process_sme_channel_change_request() - process sme ch change req
5322 *
5323 * @mac_ctx: Pointer to Global MAC structure
5324 * @msg_buf: pointer to the SME message buffer
5325 *
5326 * This function is called to process SME_CHANNEL_CHANGE_REQ message
5327 *
5328 * Return: None
5329 */
5330static void lim_process_sme_channel_change_request(tpAniSirGlobal mac_ctx,
5331 uint32_t *msg_buf)
5332{
5333 tpSirChanChangeRequest ch_change_req;
5334 tpPESession session_entry;
5335 uint8_t session_id; /* PE session_id */
Amar Singhala297bfa2015-10-15 15:07:29 -07005336 int8_t max_tx_pwr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005337 uint32_t val = 0;
5338
5339 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005340 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005341 return;
5342 }
5343 ch_change_req = (tpSirChanChangeRequest)msg_buf;
5344
5345 max_tx_pwr = cfg_get_regulatory_max_transmit_power(mac_ctx,
5346 ch_change_req->targetChannel);
5347
5348 if ((ch_change_req->messageType != eWNI_SME_CHANNEL_CHANGE_REQ) ||
5349 (max_tx_pwr == WMA_MAX_TXPOWER_INVALID)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005350 pe_err("Invalid Request/max_tx_pwr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005351 return;
5352 }
5353
5354 session_entry = pe_find_session_by_bssid(mac_ctx,
5355 ch_change_req->bssid, &session_id);
5356 if (session_entry == NULL) {
5357 lim_print_mac_addr(mac_ctx, ch_change_req->bssid, LOGE);
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005358 pe_err("Session does not exist for given bssId");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005359 return;
5360 }
5361
5362 if (session_entry->currentOperChannel ==
5363 ch_change_req->targetChannel) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005364 pe_err("target CH is same as current CH");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005365 return;
5366 }
5367
5368 if (LIM_IS_AP_ROLE(session_entry))
5369 session_entry->channelChangeReasonCode =
5370 LIM_SWITCH_CHANNEL_SAP_DFS;
5371 else
5372 session_entry->channelChangeReasonCode =
5373 LIM_SWITCH_CHANNEL_OPERATION;
5374
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005375 pe_debug("switch old chnl %d to new chnl %d, ch_bw %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005376 session_entry->currentOperChannel,
5377 ch_change_req->targetChannel,
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005378 ch_change_req->ch_width);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005379
5380 /* Store the New Channel Params in session_entry */
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005381 session_entry->ch_width = ch_change_req->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005382 session_entry->ch_center_freq_seg0 =
5383 ch_change_req->center_freq_seg_0;
5384 session_entry->ch_center_freq_seg1 =
5385 ch_change_req->center_freq_seg_1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005386 session_entry->htSecondaryChannelOffset = ch_change_req->sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005387 session_entry->htSupportedChannelWidthSet =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005388 (ch_change_req->ch_width ? 1 : 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005389 session_entry->htRecommendedTxWidthSet =
5390 session_entry->htSupportedChannelWidthSet;
5391 session_entry->currentOperChannel =
5392 ch_change_req->targetChannel;
5393 session_entry->limRFBand =
5394 lim_get_rf_band(session_entry->currentOperChannel);
5395 /* Initialize 11h Enable Flag */
gaolez76d2a162017-03-21 19:23:58 +08005396 if (CHAN_HOP_ALL_BANDS_ENABLE ||
5397 SIR_BAND_5_GHZ == session_entry->limRFBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005398 if (wlan_cfg_get_int(mac_ctx, WNI_CFG_11H_ENABLED, &val) !=
5399 eSIR_SUCCESS)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005400 pe_err("Fail to get WNI_CFG_11H_ENABLED");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005401 }
5402
5403 session_entry->lim11hEnable = val;
5404 session_entry->dot11mode = ch_change_req->dot11mode;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305405 qdf_mem_copy(&session_entry->rateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005406 &ch_change_req->operational_rateset,
5407 sizeof(session_entry->rateSet));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305408 qdf_mem_copy(&session_entry->extRateSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005409 &ch_change_req->extended_rateset,
5410 sizeof(session_entry->extRateSet));
5411 lim_set_channel(mac_ctx, ch_change_req->targetChannel,
5412 session_entry->ch_center_freq_seg0,
5413 session_entry->ch_center_freq_seg1,
5414 session_entry->ch_width,
Arif Hussain671a1902017-03-17 09:08:32 -07005415 max_tx_pwr, session_entry->peSessionId,
5416 ch_change_req->cac_duration_ms,
5417 ch_change_req->dfs_regdomain);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005418}
5419
5420/******************************************************************************
5421* lim_start_bss_update_add_ie_buffer()
5422*
5423***FUNCTION:
5424* This function checks the src buffer and its length and then malloc for
5425* dst buffer update the same
5426*
5427***LOGIC:
5428*
5429***ASSUMPTIONS:
5430*
5431***NOTE:
5432*
5433* @param pMac Pointer to Global MAC structure
5434* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5435* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5436* @param *pSrcData_buff A pointer of uint8_t src buffer
5437* @param srcDataLen src buffer length
5438******************************************************************************/
5439
5440static void
5441lim_start_bss_update_add_ie_buffer(tpAniSirGlobal pMac,
5442 uint8_t **pDstData_buff,
5443 uint16_t *pDstDataLen,
5444 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5445{
5446
5447 if (srcDataLen > 0 && pSrcData_buff != NULL) {
5448 *pDstDataLen = srcDataLen;
5449
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305450 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005451
5452 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005453 pe_err("AllocateMemory failed for pDstData_buff");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005454 return;
5455 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305456 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005457 } else {
5458 *pDstData_buff = NULL;
5459 *pDstDataLen = 0;
5460 }
5461}
5462
5463/******************************************************************************
5464* lim_update_add_ie_buffer()
5465*
5466***FUNCTION:
5467* This function checks the src buffer and length if src buffer length more
5468* than dst buffer length then free the dst buffer and malloc for the new src
5469* length, and update the dst buffer and length. But if dst buffer is bigger
5470* than src buffer length then it just update the dst buffer and length
5471*
5472***LOGIC:
5473*
5474***ASSUMPTIONS:
5475*
5476***NOTE:
5477*
5478* @param pMac Pointer to Global MAC structure
5479* @param **pDstData_buff A pointer to pointer of uint8_t dst buffer
5480* @param *pDstDataLen A pointer to pointer of uint16_t dst buffer length
5481* @param *pSrcData_buff A pointer of uint8_t src buffer
5482* @param srcDataLen src buffer length
5483******************************************************************************/
5484
5485static void
5486lim_update_add_ie_buffer(tpAniSirGlobal pMac,
5487 uint8_t **pDstData_buff,
5488 uint16_t *pDstDataLen,
5489 uint8_t *pSrcData_buff, uint16_t srcDataLen)
5490{
5491
5492 if (NULL == pSrcData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005493 pe_err("src buffer is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005494 return;
5495 }
5496
5497 if (srcDataLen > *pDstDataLen) {
5498 *pDstDataLen = srcDataLen;
5499 /* free old buffer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305500 qdf_mem_free(*pDstData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005501 /* allocate a new */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305502 *pDstData_buff = qdf_mem_malloc(*pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005503
5504 if (NULL == *pDstData_buff) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005505 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005506 *pDstDataLen = 0;
5507 return;
5508 }
5509 }
5510
5511 /* copy the content of buffer into dst buffer
5512 */
5513 *pDstDataLen = srcDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305514 qdf_mem_copy(*pDstData_buff, pSrcData_buff, *pDstDataLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005515
5516}
5517
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005518/**
5519 * lim_update_ibss_prop_add_ies() - update IBSS prop IE
5520 * @pMac : Pointer to Global MAC structure
5521 * @pDstData_buff : A pointer to pointer of dst buffer
5522 * @pDstDataLen : A pointer to pointer of dst buffer length
5523 * @pModifyIE : A pointer to tSirModifyIE
5524 *
5525 * This function replaces previous ibss prop_ie with new ibss prop_ie.
5526 *
5527 * Return:
5528 * True or false depending upon whether IE is updated or not
5529 */
5530static bool
5531lim_update_ibss_prop_add_ies(tpAniSirGlobal pMac, uint8_t **pDstData_buff,
5532 uint16_t *pDstDataLen, tSirModifyIE *pModifyIE)
5533{
Hong Shi1553d692016-09-28 12:16:19 +08005534 int32_t oui_length;
5535 uint8_t *ibss_ie = NULL;
5536 uint8_t *vendor_ie;
5537#define MAC_VENDOR_OUI "\x00\x16\x32"
5538#define MAC_VENDOR_SIZE 3
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005539
5540 ibss_ie = pModifyIE->pIEBuffer;
5541 oui_length = pModifyIE->oui_length;
5542
5543 if ((0 == oui_length) || (NULL == ibss_ie)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005544 pe_err("Invalid set IBSS vendor IE command length %d",
5545 oui_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005546 return false;
5547 }
5548
Hong Shi1553d692016-09-28 12:16:19 +08005549 /*
5550 * Why replace only beacon OUI data here:
5551 * 1. other ie (such as wpa) shall not be overwritten here.
5552 * 2. per spec, beacon oui ie might be set twice and original one
5553 * shall be updated.
5554 */
5555 vendor_ie = cfg_get_vendor_ie_ptr_from_oui(pMac, MAC_VENDOR_OUI,
5556 MAC_VENDOR_SIZE, *pDstData_buff, *pDstDataLen);
5557 if (vendor_ie) {
5558 QDF_ASSERT((vendor_ie[1] + 2) == pModifyIE->ieBufferlength);
5559 qdf_mem_copy(vendor_ie, pModifyIE->pIEBuffer,
5560 pModifyIE->ieBufferlength);
5561 } else {
5562 uint16_t new_length = pModifyIE->ieBufferlength + *pDstDataLen;
5563 uint8_t *new_ptr = qdf_mem_malloc(new_length);
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005564
Hong Shi1553d692016-09-28 12:16:19 +08005565 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005566 pe_err("Memory allocation failed");
Hong Shi1553d692016-09-28 12:16:19 +08005567 return false;
5568 }
5569 qdf_mem_copy(new_ptr, *pDstData_buff, *pDstDataLen);
5570 qdf_mem_copy(&new_ptr[*pDstDataLen], pModifyIE->pIEBuffer,
5571 pModifyIE->ieBufferlength);
5572 qdf_mem_free(*pDstData_buff);
5573 *pDstDataLen = new_length;
5574 *pDstData_buff = new_ptr;
5575 }
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005576 return true;
5577}
5578
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005579/*
5580* lim_process_modify_add_ies() - process modify additional IE req.
5581*
5582* @mac_ctx: Pointer to Global MAC structure
5583* @msg_buf: pointer to the SME message buffer
5584*
5585* This function update the PE buffers for additional IEs.
5586*
5587* Return: None
5588*/
5589static void lim_process_modify_add_ies(tpAniSirGlobal mac_ctx,
5590 uint32_t *msg_buf)
5591{
5592 tpSirModifyIEsInd modify_add_ies;
5593 tpPESession session_entry;
5594 uint8_t session_id;
5595 bool ret = false;
5596 tSirAddIeParams *add_ie_params;
5597
5598 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005599 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005600 return;
5601 }
5602
5603 modify_add_ies = (tpSirModifyIEsInd)msg_buf;
5604 /* Incoming message has smeSession, use BSSID to find PE session */
5605 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005606 modify_add_ies->modifyIE.bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005607
5608 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005609 pe_err("Session not found for given bssid"
5610 MAC_ADDRESS_STR,
Srinivas Girigowda34b634c2015-11-18 22:22:01 -08005611 MAC_ADDR_ARRAY(modify_add_ies->modifyIE.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005612 goto end;
5613 }
5614 if ((0 == modify_add_ies->modifyIE.ieBufferlength) ||
5615 (0 == modify_add_ies->modifyIE.ieIDLen) ||
5616 (NULL == modify_add_ies->modifyIE.pIEBuffer)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005617 pe_err("Invalid request pIEBuffer %p ieBufferlength %d ieIDLen %d ieID %d. update Type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005618 modify_add_ies->modifyIE.pIEBuffer,
5619 modify_add_ies->modifyIE.ieBufferlength,
5620 modify_add_ies->modifyIE.ieID,
5621 modify_add_ies->modifyIE.ieIDLen,
5622 modify_add_ies->updateType);
5623 goto end;
5624 }
5625 add_ie_params = &session_entry->addIeParams;
5626 switch (modify_add_ies->updateType) {
5627 case eUPDATE_IE_PROBE_RESP:
5628 /* Probe resp */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005629 if (LIM_IS_IBSS_ROLE(session_entry)) {
5630 lim_update_ibss_prop_add_ies(mac_ctx,
5631 &add_ie_params->probeRespData_buff,
5632 &add_ie_params->probeRespDataLen,
5633 &modify_add_ies->modifyIE);
5634 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005635 break;
5636 case eUPDATE_IE_ASSOC_RESP:
5637 /* assoc resp IE */
5638 if (add_ie_params->assocRespDataLen == 0) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05305639 QDF_TRACE(QDF_MODULE_ID_PE,
5640 QDF_TRACE_LEVEL_ERROR, FL(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005641 "assoc resp add ie not present %d"),
5642 add_ie_params->assocRespDataLen);
5643 }
5644 /* search through the buffer and modify the IE */
5645 break;
5646 case eUPDATE_IE_PROBE_BCN:
5647 /*probe beacon IE */
Rajeev Kumar8e3e2832015-11-06 16:02:54 -08005648 if (LIM_IS_IBSS_ROLE(session_entry)) {
5649 ret = lim_update_ibss_prop_add_ies(mac_ctx,
5650 &add_ie_params->probeRespBCNData_buff,
5651 &add_ie_params->probeRespBCNDataLen,
5652 &modify_add_ies->modifyIE);
5653 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005654 if (ret == true && modify_add_ies->modifyIE.notify) {
5655 lim_handle_param_update(mac_ctx,
5656 modify_add_ies->updateType);
5657 }
5658 break;
5659 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005660 pe_err("unhandled buffer type %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005661 modify_add_ies->updateType);
5662 break;
5663 }
5664end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305665 qdf_mem_free(modify_add_ies->modifyIE.pIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005666 modify_add_ies->modifyIE.pIEBuffer = NULL;
5667}
5668
5669/*
5670* lim_process_update_add_ies() - process additional IE update req
5671*
5672* @mac_ctx: Pointer to Global MAC structure
5673* @msg_buf: pointer to the SME message buffer
5674*
5675* This function update the PE buffers for additional IEs.
5676*
5677* Return: None
5678*/
5679static void lim_process_update_add_ies(tpAniSirGlobal mac_ctx,
5680 uint32_t *msg_buf)
5681{
5682 tpSirUpdateIEsInd update_add_ies = (tpSirUpdateIEsInd)msg_buf;
5683 uint8_t session_id;
5684 tpPESession session_entry;
5685 tSirAddIeParams *addn_ie;
5686 uint16_t new_length = 0;
5687 uint8_t *new_ptr = NULL;
5688 tSirUpdateIE *update_ie;
5689
5690 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005691 pe_err("msg_buf is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005692 return;
5693 }
5694 update_ie = &update_add_ies->updateIE;
5695 /* incoming message has smeSession, use BSSID to find PE session */
5696 session_entry = pe_find_session_by_bssid(mac_ctx,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005697 update_ie->bssid.bytes, &session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005698
5699 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005700 pe_err("Session not found for given bssid"
5701 MAC_ADDRESS_STR,
Srinivas Girigowda8b983962015-11-18 22:14:34 -08005702 MAC_ADDR_ARRAY(update_ie->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005703 goto end;
5704 }
5705 addn_ie = &session_entry->addIeParams;
5706 /* if len is 0, upper layer requested freeing of buffer */
5707 if (0 == update_ie->ieBufferlength) {
5708 switch (update_add_ies->updateType) {
5709 case eUPDATE_IE_PROBE_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305710 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005711 addn_ie->probeRespData_buff = NULL;
5712 addn_ie->probeRespDataLen = 0;
5713 break;
5714 case eUPDATE_IE_ASSOC_RESP:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305715 qdf_mem_free(addn_ie->assocRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005716 addn_ie->assocRespData_buff = NULL;
5717 addn_ie->assocRespDataLen = 0;
5718 break;
5719 case eUPDATE_IE_PROBE_BCN:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305720 qdf_mem_free(addn_ie->probeRespBCNData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005721 addn_ie->probeRespBCNData_buff = NULL;
5722 addn_ie->probeRespBCNDataLen = 0;
5723
5724 if (update_ie->notify)
5725 lim_handle_param_update(mac_ctx,
5726 update_add_ies->updateType);
5727 break;
5728 default:
5729 break;
5730 }
5731 return;
5732 }
5733 switch (update_add_ies->updateType) {
5734 case eUPDATE_IE_PROBE_RESP:
5735 if (update_ie->append) {
5736 /*
5737 * In case of append, allocate new memory
5738 * with combined length
5739 */
5740 new_length = update_ie->ieBufferlength +
5741 addn_ie->probeRespDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305742 new_ptr = qdf_mem_malloc(new_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005743 if (NULL == new_ptr) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005744 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005745 goto end;
5746 }
5747 /* append buffer to end of local buffers */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305748 qdf_mem_copy(new_ptr, addn_ie->probeRespData_buff,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005749 addn_ie->probeRespDataLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305750 qdf_mem_copy(&new_ptr[addn_ie->probeRespDataLen],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005751 update_ie->pAdditionIEBuffer,
5752 update_ie->ieBufferlength);
5753 /* free old memory */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305754 qdf_mem_free(addn_ie->probeRespData_buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005755 /* adjust length accordingly */
5756 addn_ie->probeRespDataLen = new_length;
5757 /* save refernece of local buffer in PE session */
5758 addn_ie->probeRespData_buff = new_ptr;
5759 goto end;
5760 }
5761 lim_update_add_ie_buffer(mac_ctx, &addn_ie->probeRespData_buff,
5762 &addn_ie->probeRespDataLen,
5763 update_ie->pAdditionIEBuffer,
5764 update_ie->ieBufferlength);
5765 break;
5766 case eUPDATE_IE_ASSOC_RESP:
5767 /* assoc resp IE */
5768 lim_update_add_ie_buffer(mac_ctx, &addn_ie->assocRespData_buff,
5769 &addn_ie->assocRespDataLen,
5770 update_ie->pAdditionIEBuffer,
5771 update_ie->ieBufferlength);
5772 break;
5773 case eUPDATE_IE_PROBE_BCN:
5774 /* probe resp Bcn IE */
5775 lim_update_add_ie_buffer(mac_ctx,
5776 &addn_ie->probeRespBCNData_buff,
5777 &addn_ie->probeRespBCNDataLen,
5778 update_ie->pAdditionIEBuffer,
5779 update_ie->ieBufferlength);
5780 if (update_ie->notify)
5781 lim_handle_param_update(mac_ctx,
5782 update_add_ies->updateType);
5783 break;
5784 default:
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005785 pe_err("unhandled buffer type %d", update_add_ies->updateType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005786 break;
5787 }
5788end:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305789 qdf_mem_free(update_ie->pAdditionIEBuffer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005790 update_ie->pAdditionIEBuffer = NULL;
5791}
5792
5793/**
Abhishek Singh518323d2015-10-19 17:42:01 +05305794 * send_extended_chan_switch_action_frame()- function to send ECSA
5795 * action frame for each sta connected to SAP/GO and AP in case of
5796 * STA .
5797 * @mac_ctx: pointer to global mac structure
5798 * @new_channel: new channel to switch to.
5799 * @ch_bandwidth: BW of channel to calculate op_class
5800 * @session_entry: pe session
5801 *
5802 * This function is called to send ECSA frame for STA/CLI and SAP/GO.
5803 *
5804 * Return: void
5805 */
5806
5807static void send_extended_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5808 uint16_t new_channel, uint8_t ch_bandwidth,
5809 tpPESession session_entry)
5810{
5811 uint16_t op_class;
5812 uint8_t switch_mode = 0, i;
5813 tpDphHashNode psta;
gaoleze2920bd2017-03-21 17:38:42 +08005814 uint8_t switch_count;
Abhishek Singh518323d2015-10-19 17:42:01 +05305815
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005816 op_class = wlan_reg_dmn_get_opclass_from_channel(
Abhishek Singh518323d2015-10-19 17:42:01 +05305817 mac_ctx->scan.countryCodeCurrent,
5818 new_channel,
5819 ch_bandwidth);
5820
5821 if (LIM_IS_AP_ROLE(session_entry) &&
5822 (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false))
gaolez76d2a162017-03-21 19:23:58 +08005823 switch_mode = session_entry->gLimChannelSwitch.switchMode;
Abhishek Singh518323d2015-10-19 17:42:01 +05305824
gaoleze2920bd2017-03-21 17:38:42 +08005825 switch_count = session_entry->gLimChannelSwitch.switchCount;
5826
Abhishek Singh518323d2015-10-19 17:42:01 +05305827 if (LIM_IS_AP_ROLE(session_entry)) {
gaolez3b07a2c2017-03-22 12:59:17 +08005828 for (i = 0; i <= mac_ctx->lim.maxStation; i++) {
Abhishek Singh518323d2015-10-19 17:42:01 +05305829 psta =
5830 session_entry->dph.dphHashTable.pDphNodeArray + i;
5831 if (psta && psta->added)
5832 lim_send_extended_chan_switch_action_frame(
5833 mac_ctx,
5834 psta->staAddr,
5835 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005836 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305837 }
5838 } else if (LIM_IS_STA_ROLE(session_entry)) {
5839 lim_send_extended_chan_switch_action_frame(mac_ctx,
5840 session_entry->bssId,
5841 switch_mode, op_class, new_channel,
gaoleze2920bd2017-03-21 17:38:42 +08005842 switch_count, session_entry);
Abhishek Singh518323d2015-10-19 17:42:01 +05305843 }
5844
5845}
5846
5847/**
gaolez76d2a162017-03-21 19:23:58 +08005848 * lim_send_chan_switch_action_frame()- Send an action frame
5849 * containing CSA IE or ECSA IE depending on the connected
5850 * sta capability.
5851 *
5852 * @mac_ctx: pointer to global mac structure
5853 * @new_channel: new channel to switch to.
5854 * @ch_bandwidth: BW of channel to calculate op_class
5855 * @session_entry: pe session
5856 *
5857 * Return: void
5858 */
5859static
5860void lim_send_chan_switch_action_frame(tpAniSirGlobal mac_ctx,
5861 uint16_t new_channel,
5862 uint8_t ch_bandwidth,
5863 tpPESession session_entry)
5864{
5865 uint16_t op_class;
5866 uint8_t switch_mode = 0, i;
5867 uint8_t switch_count;
5868 tpDphHashNode psta;
5869 tpDphHashNode dph_node_array_ptr;
5870
5871 dph_node_array_ptr = session_entry->dph.dphHashTable.pDphNodeArray;
5872
5873 op_class = wlan_reg_dmn_get_opclass_from_channel(
5874 mac_ctx->scan.countryCodeCurrent,
5875 new_channel, ch_bandwidth);
5876
5877 if (LIM_IS_AP_ROLE(session_entry) &&
5878 (false == mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch))
5879 switch_mode = session_entry->gLimChannelSwitch.switchMode;
5880
5881 switch_count = session_entry->gLimChannelSwitch.switchCount;
5882
5883 if (LIM_IS_AP_ROLE(session_entry)) {
5884 for (i = 0; i < mac_ctx->lim.maxStation; i++) {
5885 psta = dph_node_array_ptr + i;
5886 if (!(psta && psta->added))
5887 continue;
5888 if (session_entry->lim_non_ecsa_cap_num == 0)
5889 lim_send_extended_chan_switch_action_frame
5890 (mac_ctx, psta->staAddr, switch_mode,
5891 op_class, new_channel, switch_count,
5892 session_entry);
5893 else
5894 lim_send_channel_switch_mgmt_frame
5895 (mac_ctx, psta->staAddr, switch_mode,
5896 new_channel, switch_count,
5897 session_entry);
5898 }
5899 } else if (LIM_IS_STA_ROLE(session_entry)) {
5900 lim_send_extended_chan_switch_action_frame
5901 (mac_ctx, session_entry->bssId, switch_mode, op_class,
5902 new_channel, switch_count, session_entry);
5903 }
5904}
5905
5906/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005907 * lim_process_sme_dfs_csa_ie_request() - process sme dfs csa ie req
5908 *
5909 * @mac_ctx: Pointer to Global MAC structure
5910 * @msg_buf: pointer to the SME message buffer
5911 *
5912 * This function processes SME request messages from HDD or upper layer
5913 * application.
5914 *
5915 * Return: None
5916 */
5917static void lim_process_sme_dfs_csa_ie_request(tpAniSirGlobal mac_ctx,
5918 uint32_t *msg_buf)
5919{
5920 tpSirDfsCsaIeRequest dfs_csa_ie_req;
5921 tpPESession session_entry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005922 uint8_t session_id;
5923 tLimWiderBWChannelSwitchInfo *wider_bw_ch_switch;
Amar Singhal22995112016-01-22 10:42:33 -08005924 enum offset_t ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005925
5926 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005927 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005928 return;
5929 }
5930
5931 dfs_csa_ie_req = (tSirDfsCsaIeRequest *)msg_buf;
5932 session_entry = pe_find_session_by_bssid(mac_ctx,
5933 dfs_csa_ie_req->bssid, &session_id);
5934 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005935 pe_err("Session not found for given BSSID" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005936 MAC_ADDR_ARRAY(dfs_csa_ie_req->bssid));
5937 return;
5938 }
5939
5940 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07005941 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005942 GET_LIM_SYSTEM_ROLE(session_entry));
5943 return;
5944 }
5945
5946 /* target channel */
5947 session_entry->gLimChannelSwitch.primaryChannel =
5948 dfs_csa_ie_req->targetChannel;
5949
5950 /* Channel switch announcement needs to be included in beacon */
5951 session_entry->dfsIncludeChanSwIe = true;
gaoleze2920bd2017-03-21 17:38:42 +08005952 session_entry->gLimChannelSwitch.switchCount =
5953 dfs_csa_ie_req->ch_switch_beacon_cnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005954 session_entry->gLimChannelSwitch.ch_width =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005955 dfs_csa_ie_req->ch_params.ch_width;
Chandrasekaran Manishekar4fcb7f52016-03-07 19:09:20 +05305956 session_entry->gLimChannelSwitch.sec_ch_offset =
5957 dfs_csa_ie_req->ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005958 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
gaolez76d2a162017-03-21 19:23:58 +08005959 session_entry->gLimChannelSwitch.switchMode =
5960 dfs_csa_ie_req->ch_switch_mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005961
5962 /*
5963 * Validate if SAP is operating HT or VHT mode and set the Channel
5964 * Switch Wrapper element with the Wide Band Switch subelement.
5965 */
5966 if (true != session_entry->vhtCapability)
5967 goto skip_vht;
5968
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005969 /* Now encode the Wider Ch BW element depending on the ch width */
5970 wider_bw_ch_switch = &session_entry->gLimWiderBWChannelSwitch;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005971 switch (dfs_csa_ie_req->ch_params.ch_width) {
5972 case CH_WIDTH_20MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005973 /*
5974 * Wide channel BW sublement in channel wrapper element is not
5975 * required in case of 20 Mhz operation. Currently It is set
5976 * only set in case of 40/80 Mhz Operation.
5977 */
5978 session_entry->dfsIncludeChanWrapperIe = false;
5979 wider_bw_ch_switch->newChanWidth =
5980 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5981 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005982 case CH_WIDTH_40MHZ:
5983 session_entry->dfsIncludeChanWrapperIe = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005984 wider_bw_ch_switch->newChanWidth =
5985 WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ;
5986 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005987 case CH_WIDTH_80MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005988 session_entry->dfsIncludeChanWrapperIe = true;
5989 wider_bw_ch_switch->newChanWidth =
5990 WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ;
5991 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005992 case CH_WIDTH_160MHZ:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005993 session_entry->dfsIncludeChanWrapperIe = true;
5994 wider_bw_ch_switch->newChanWidth =
5995 WNI_CFG_VHT_CHANNEL_WIDTH_160MHZ;
5996 break;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08005997 case CH_WIDTH_80P80MHZ:
5998 session_entry->dfsIncludeChanWrapperIe = true;
5999 wider_bw_ch_switch->newChanWidth =
6000 WNI_CFG_VHT_CHANNEL_WIDTH_80_PLUS_80MHZ;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08006001 /*
6002 * This is not applicable for 20/40/80 Mhz.
6003 * Only used when we support 80+80 Mhz operation.
6004 * In case of 80+80 Mhz, this parameter indicates
6005 * center channel frequency index of 80 Mhz channel of
6006 * frequency segment 1.
6007 */
6008 wider_bw_ch_switch->newCenterChanFreq1 =
6009 dfs_csa_ie_req->ch_params.center_freq_seg1;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006010 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006011 default:
6012 session_entry->dfsIncludeChanWrapperIe = false;
6013 /*
6014 * Need to handle 80+80 Mhz Scenario. When 80+80 is supported
6015 * set the gLimWiderBWChannelSwitch.newChanWidth to 3
6016 */
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006017 pe_err("Invalid Channel Width");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006018 break;
6019 }
6020 /* Fetch the center channel based on the channel width */
6021 wider_bw_ch_switch->newCenterChanFreq0 =
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08006022 dfs_csa_ie_req->ch_params.center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006023skip_vht:
6024 /* Send CSA IE request from here */
6025 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6026 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006027 pe_err("Unable to set CSA IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006028 return;
6029 }
6030
6031 /*
6032 * First beacon update request is sent here, the remaining updates are
6033 * done when the FW responds back after sending the first beacon after
6034 * the template update
6035 */
6036 lim_send_beacon_ind(mac_ctx, session_entry);
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306037
6038 if (dfs_csa_ie_req->ch_params.ch_width == CH_WIDTH_80MHZ)
6039 ch_offset = BW80;
6040 else
6041 ch_offset = dfs_csa_ie_req->ch_params.sec_ch_offset;
6042
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006043 pe_debug("IE count:%d chan:%d width:%d wrapper:%d ch_offset:%d",
Chandrasekaran, Manishekardc351562016-01-11 19:28:52 +05306044 session_entry->gLimChannelSwitch.switchCount,
6045 session_entry->gLimChannelSwitch.primaryChannel,
6046 session_entry->gLimChannelSwitch.ch_width,
6047 session_entry->dfsIncludeChanWrapperIe,
6048 ch_offset);
6049
gaolez76d2a162017-03-21 19:23:58 +08006050 /* Send ECSA/CSA Action frame after updating the beacon */
6051 if (CHAN_HOP_ALL_BANDS_ENABLE)
6052 lim_send_chan_switch_action_frame(mac_ctx,
6053 session_entry->gLimChannelSwitch.primaryChannel,
6054 ch_offset, session_entry);
6055 else
6056 send_extended_chan_switch_action_frame(mac_ctx,
6057 session_entry->gLimChannelSwitch.primaryChannel,
6058 ch_offset, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006059 session_entry->gLimChannelSwitch.switchCount--;
6060}
6061
6062/**
Abhishek Singh518323d2015-10-19 17:42:01 +05306063 * lim_process_ext_change_channel()- function to send ECSA
6064 * action frame for STA/CLI .
6065 * @mac_ctx: pointer to global mac structure
6066 * @msg: params from sme for new channel.
6067 *
6068 * This function is called to send ECSA frame for STA/CLI.
6069 *
6070 * Return: void
6071 */
6072
6073static void lim_process_ext_change_channel(tpAniSirGlobal mac_ctx,
6074 uint32_t *msg)
6075{
6076 struct sir_sme_ext_cng_chan_req *ext_chng_channel =
6077 (struct sir_sme_ext_cng_chan_req *) msg;
6078 tpPESession session_entry = NULL;
6079
6080 if (NULL == msg) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006081 pe_err("Buffer is Pointing to NULL");
Abhishek Singh518323d2015-10-19 17:42:01 +05306082 return;
6083 }
6084 session_entry =
6085 pe_find_session_by_sme_session_id(mac_ctx,
6086 ext_chng_channel->session_id);
6087 if (NULL == session_entry) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006088 pe_err("Session not found for given session %d",
Abhishek Singh518323d2015-10-19 17:42:01 +05306089 ext_chng_channel->session_id);
6090 return;
6091 }
6092 if (LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006093 pe_err("not an STA/CLI session");
Abhishek Singh518323d2015-10-19 17:42:01 +05306094 return;
6095 }
6096 send_extended_chan_switch_action_frame(mac_ctx,
6097 ext_chng_channel->new_channel,
6098 0, session_entry);
6099}
6100
6101/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006102 * lim_process_nss_update_request() - process sme nss update req
6103 *
6104 * @mac_ctx: Pointer to Global MAC structure
6105 * @msg_buf: pointer to the SME message buffer
6106 *
6107 * This function processes SME request messages from HDD or upper layer
6108 * application.
6109 *
6110 * Return: None
6111 */
6112static void lim_process_nss_update_request(tpAniSirGlobal mac_ctx,
6113 uint32_t *msg_buf)
6114{
6115 struct sir_nss_update_request *nss_update_req_ptr;
6116 tpPESession session_entry = NULL;
6117
6118 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006119 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006120 return;
6121 }
6122
6123 nss_update_req_ptr = (struct sir_nss_update_request *)msg_buf;
Chandrasekaran, Manishekar5738eb02016-02-02 12:22:00 +05306124 session_entry = pe_find_session_by_sme_session_id(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006125 nss_update_req_ptr->vdev_id);
6126 if (session_entry == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006127 pe_err("Session not found for given session_id %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006128 nss_update_req_ptr->vdev_id);
6129 return;
6130 }
6131
6132 if (session_entry->valid && !LIM_IS_AP_ROLE(session_entry)) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006133 pe_err("Invalid SystemRole %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006134 GET_LIM_SYSTEM_ROLE(session_entry));
6135 return;
6136 }
6137
6138 /* populate nss field in the beacon */
6139 session_entry->gLimOperatingMode.present = 1;
6140 session_entry->gLimOperatingMode.rxNSS = nss_update_req_ptr->new_nss;
Ganesh Kondabattini5e0ac2a2017-05-16 14:29:32 +05306141 session_entry->gLimOperatingMode.chanWidth = session_entry->ch_width;
6142
6143 if ((nss_update_req_ptr->new_nss == NSS_1x1_MODE) &&
6144 (session_entry->ch_width > CH_WIDTH_80MHZ))
6145 session_entry->gLimOperatingMode.chanWidth = CH_WIDTH_80MHZ;
6146
6147 pe_debug("ch width %hu", session_entry->gLimOperatingMode.chanWidth);
6148
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006149 /* Send nss update request from here */
6150 if (sch_set_fixed_beacon_fields(mac_ctx, session_entry) !=
6151 eSIR_SUCCESS) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006152 pe_err("Unable to set op mode IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006153 return;
6154 }
6155
6156 lim_send_beacon_ind(mac_ctx, session_entry);
6157}
6158
6159/**
6160 * lim_process_set_ie_req() - process sme set IE request
6161 *
6162 * @mac_ctx: Pointer to Global MAC structure
6163 * @msg_buf: pointer to the SME message buffer
6164 *
6165 * This function processes SME request messages from HDD or upper layer
6166 * application.
6167 *
6168 * Return: None
6169 */
6170static void lim_process_set_ie_req(tpAniSirGlobal mac_ctx, uint32_t *msg_buf)
6171{
6172 struct send_extcap_ie *msg;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306173 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006174
6175 if (msg_buf == NULL) {
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006176 pe_err("Buffer is Pointing to NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006177 return;
6178 }
6179
6180 msg = (struct send_extcap_ie *)msg_buf;
6181 status = lim_send_ext_cap_ie(mac_ctx, msg->session_id, NULL, false);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306182 if (QDF_STATUS_SUCCESS != status)
Srinivas Girigowda15b355e2017-03-26 21:51:00 -07006183 pe_err("Unable to send ExtCap to FW");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006184
6185}