blob: 09c9bd975ec234b6cd7f0edeb5e77046977711a5 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Kiran Kumar Lokere47127482017-12-20 18:09:55 -08002 * Copyright (c) 2012-2018 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_send_sme_rspMessages.cc contains the functions
30 * for sending SME response/notification messages to applications
31 * above MAC software.
32 * Author: Chandra Modumudi
33 * Date: 02/13/02
34 * History:-
35 * Date Modified by Modification Information
36 * --------------------------------------------------------------------
37 */
38
Anurag Chouhan6d760662016-02-20 16:05:43 +053039#include "qdf_types.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080040#include "wni_api.h"
41#include "sir_common.h"
42#include "ani_global.h"
43
44#include "wni_cfg.h"
45#include "sys_def.h"
46#include "cfg_api.h"
47
48#include "sch_api.h"
49#include "utils_api.h"
50#include "lim_utils.h"
51#include "lim_security_utils.h"
52#include "lim_ser_des_utils.h"
53#include "lim_send_sme_rsp_messages.h"
54#include "lim_ibss_peer_mgmt.h"
55#include "lim_session_utils.h"
56#include "lim_types.h"
57#include "sir_api.h"
Naveen Rawat3b6068c2016-04-14 19:01:06 -070058#include "cds_regdomain.h"
Gupta, Kapil121bf212015-11-25 19:21:29 +053059#include "lim_send_messages.h"
Deepak Dhamdhere13983f22016-05-31 19:06:09 -070060#include "nan_datapath.h"
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -070061#include "lim_assoc_utils.h"
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070062#include "wlan_reg_services_api.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070063#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080064
Kabilan Kannanf56f9d52017-04-05 03:31:34 -070065#include "wlan_tdls_tgt_api.h"
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +053066#include "lim_process_fils.h"
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -080067#include "wma.h"
Kabilan Kannanf56f9d52017-04-05 03:31:34 -070068
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080069static void lim_handle_join_rsp_status(tpAniSirGlobal mac_ctx,
70 tpPESession session_entry, tSirResultCodes result_code,
71 tpSirSmeJoinRsp sme_join_rsp);
72
73/**
74 * lim_send_sme_rsp() - Send Response to upper layers
75 * @mac_ctx: Pointer to Global MAC structure
76 * @msg_type: Indicates message type
77 * @result_code: Indicates the result of previously issued
78 * eWNI_SME_msg_type_REQ message
79 *
80 * This function is called by lim_process_sme_req_messages() to send
81 * eWNI_SME_START_RSP, eWNI_SME_STOP_BSS_RSP
82 * or eWNI_SME_SWITCH_CHL_RSP messages to applications above MAC
83 * Software.
84 *
85 * Return: None
86 */
87
88void
89lim_send_sme_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
90 tSirResultCodes result_code, uint8_t sme_session_id,
91 uint16_t sme_transaction_id)
92{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070093 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080094 tSirSmeRsp *sme_rsp;
95
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +053096 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080097 lim_msg_str(msg_type), lim_result_code_str(result_code));
98
Anurag Chouhan600c3a02016-03-01 10:33:54 +053099 sme_rsp = qdf_mem_malloc(sizeof(tSirSmeRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800100 if (NULL == sme_rsp) {
101 /* Buffer not available. Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530102 pe_err("call to AllocateMemory failed for eWNI_SME_*_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800103 return;
104 }
105
106 sme_rsp->messageType = msg_type;
107 sme_rsp->length = sizeof(tSirSmeRsp);
108 sme_rsp->statusCode = result_code;
109
110 sme_rsp->sessionId = sme_session_id;
111 sme_rsp->transactionId = sme_transaction_id;
112
113 msg.type = msg_type;
114 msg.bodyptr = sme_rsp;
115 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530116 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG,
117 sme_session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800118
119#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
120 switch (msg_type) {
121 case eWNI_SME_STOP_BSS_RSP:
122 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_STOP_BSS_RSP_EVENT,
123 NULL, (uint16_t) result_code, 0);
124 break;
125 }
126#endif /* FEATURE_WLAN_DIAG_SUPPORT */
127 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
128}
129
130
131
132/**
133 * lim_send_sme_roc_rsp() - Send Response to SME
134 * @mac_ctx: Pointer to Global MAC structure
135 * @status: Resume link status
136 * @result_code: Result of the ROC request
137 * @sme_session_id: SME sesson Id
138 * @scan_id: Scan Identifier
139 *
140 * This function is called to send ROC rsp
141 * message to SME.
142 *
143 * Return: None
144 */
145void
146lim_send_sme_roc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
147 tSirResultCodes result_code, uint8_t sme_session_id,
148 uint32_t scan_id)
149{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700150 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800151 struct sir_roc_rsp *sme_rsp;
152
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530153 pe_debug("Sending message: %s with reasonCode: %s scanId: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800154 lim_msg_str(msg_type), lim_result_code_str(result_code),
155 scan_id);
156
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530157 sme_rsp = qdf_mem_malloc(sizeof(struct sir_roc_rsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800158 if (NULL == sme_rsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530159 pe_err("call to AllocateMemory failed for eWNI_SME_*_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800160 return;
161 }
162
163 sme_rsp->message_type = msg_type;
164 sme_rsp->length = sizeof(struct sir_roc_rsp);
165 sme_rsp->status = result_code;
166
167 sme_rsp->session_id = sme_session_id;
168 sme_rsp->scan_id = scan_id;
169
170 msg.type = msg_type;
171 msg.bodyptr = sme_rsp;
172 msg.bodyval = 0;
173 MTRACE(mac_trace_msg_tx(mac_ctx, sme_session_id, msg.type));
174 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
175}
176
177
178/**
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530179 * lim_get_max_rate_flags() - Get rate flags
180 * @mac_ctx: Pointer to global MAC structure
181 * @sta_ds: Pointer to station ds structure
182 *
183 * This function is called to get the rate flags for a connection
184 * from the station ds structure depending on the ht and the vht
185 * channel width supported.
186 *
187 * Return: Returns the populated rate_flags
188 */
189uint32_t lim_get_max_rate_flags(tpAniSirGlobal mac_ctx, tpDphHashNode sta_ds)
190{
191 uint32_t rate_flags = 0;
192
193 if (sta_ds == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530194 pe_err("sta_ds is NULL");
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530195 return rate_flags;
196 }
197
198 if (!sta_ds->mlmStaContext.htCapability &&
199 !sta_ds->mlmStaContext.vhtCapability) {
200 rate_flags |= eHAL_TX_RATE_LEGACY;
201 } else {
202 if (sta_ds->mlmStaContext.vhtCapability) {
203 if (WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ ==
204 sta_ds->vhtSupportedChannelWidthSet) {
205 rate_flags |= eHAL_TX_RATE_VHT80;
206 } else if (WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ ==
207 sta_ds->vhtSupportedChannelWidthSet) {
208 if (sta_ds->htSupportedChannelWidthSet)
209 rate_flags |= eHAL_TX_RATE_VHT40;
210 else
211 rate_flags |= eHAL_TX_RATE_VHT20;
212 }
213 } else if (sta_ds->mlmStaContext.htCapability) {
214 if (sta_ds->htSupportedChannelWidthSet)
215 rate_flags |= eHAL_TX_RATE_HT40;
216 else
217 rate_flags |= eHAL_TX_RATE_HT20;
218 }
219 }
220
221 if (sta_ds->htShortGI20Mhz || sta_ds->htShortGI40Mhz)
222 rate_flags |= eHAL_TX_RATE_SGI;
223
224 return rate_flags;
225}
226
227/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800228 * lim_send_sme_join_reassoc_rsp_after_resume() - Send Response to SME
229 * @mac_ctx Pointer to Global MAC structure
230 * @status Resume link status
231 * @ctx context passed while calling resmune link.
232 * (join response to be sent)
233 *
234 * This function is called to send Join/Reassoc rsp
235 * message to SME after the resume link.
236 *
237 * Return: None
238 */
239static void lim_send_sme_join_reassoc_rsp_after_resume(tpAniSirGlobal mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530240 QDF_STATUS status, uint32_t *ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800241{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700242 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800243 tpSirSmeJoinRsp sme_join_rsp = (tpSirSmeJoinRsp) ctx;
244
245 msg.type = sme_join_rsp->messageType;
246 msg.bodyptr = sme_join_rsp;
247 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530248 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, NO_SESSION, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800249 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
250}
251
252/**
253 * lim_handle_join_rsp_status() - Handle the response.
254 * @mac_ctx: Pointer to Global MAC structure
255 * @session_entry: PE Session Info
256 * @result_code: Indicates the result of previously issued
257 * eWNI_SME_msgType_REQ message
258 * @sme_join_rsp The received response.
259 *
260 * This function will handle both the success and failure status
261 * of the received response.
262 *
263 * Return: None
264 */
265static void lim_handle_join_rsp_status(tpAniSirGlobal mac_ctx,
266 tpPESession session_entry, tSirResultCodes result_code,
267 tpSirSmeJoinRsp sme_join_rsp)
268{
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700269 uint16_t bss_ie_len;
270 void *bss_ies;
271 bool is_vendor_ap_1_present;
Wu Gao2968fc92017-06-19 19:18:34 +0800272 tpSirSmeJoinReq join_reassoc_req = NULL;
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700273
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800274#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
275 tSirSmeHTProfile *ht_profile;
276#endif
277 if (result_code == eSIR_SME_SUCCESS) {
278 if (session_entry->beacon != NULL) {
279 sme_join_rsp->beaconLength = session_entry->bcnLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530280 qdf_mem_copy(sme_join_rsp->frames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800281 session_entry->beacon,
282 sme_join_rsp->beaconLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530283 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800284 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530285 session_entry->bcnLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530286 pe_debug("Beacon: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530287 sme_join_rsp->beaconLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800288 }
289 if (session_entry->assocReq != NULL) {
290 sme_join_rsp->assocReqLength =
291 session_entry->assocReqLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530292 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530293 sme_join_rsp->beaconLength,
294 session_entry->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800295 sme_join_rsp->assocReqLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530296 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800297 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530298 session_entry->assocReqLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530299 pe_debug("AssocReq: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530300 sme_join_rsp->assocReqLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800301 }
302 if (session_entry->assocRsp != NULL) {
303 sme_join_rsp->assocRspLength =
304 session_entry->assocRspLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530305 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530306 sme_join_rsp->beaconLength +
307 sme_join_rsp->assocReqLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800308 session_entry->assocRsp,
309 sme_join_rsp->assocRspLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530310 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800311 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530312 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800313 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800314 if (session_entry->ricData != NULL) {
315 sme_join_rsp->parsedRicRspLen =
316 session_entry->RICDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530317 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530318 sme_join_rsp->beaconLength +
319 sme_join_rsp->assocReqLength +
320 sme_join_rsp->assocRspLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800321 session_entry->ricData,
322 sme_join_rsp->parsedRicRspLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530323 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800324 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530325 session_entry->RICDataLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530326 pe_debug("RicLength: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800327 sme_join_rsp->parsedRicRspLen);
328 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800329#ifdef FEATURE_WLAN_ESE
330 if (session_entry->tspecIes != NULL) {
331 sme_join_rsp->tspecIeLen =
332 session_entry->tspecLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530333 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530334 sme_join_rsp->beaconLength +
335 sme_join_rsp->assocReqLength +
336 sme_join_rsp->assocRspLength +
337 sme_join_rsp->parsedRicRspLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800338 session_entry->tspecIes,
339 sme_join_rsp->tspecIeLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530340 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800341 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530342 session_entry->tspecLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530343 pe_debug("ESE-TspecLen: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530344 sme_join_rsp->tspecIeLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800345 }
346#endif
347 sme_join_rsp->aid = session_entry->limAID;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530348 pe_debug("AssocRsp: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530349 sme_join_rsp->assocRspLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800350 sme_join_rsp->vht_channel_width =
351 session_entry->ch_width;
352#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
353 if (session_entry->cc_switch_mode !=
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530354 QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800355 ht_profile = &sme_join_rsp->HTProfile;
356 ht_profile->htSupportedChannelWidthSet =
357 session_entry->htSupportedChannelWidthSet;
358 ht_profile->htRecommendedTxWidthSet =
359 session_entry->htRecommendedTxWidthSet;
360 ht_profile->htSecondaryChannelOffset =
361 session_entry->htSecondaryChannelOffset;
362 ht_profile->dot11mode = session_entry->dot11mode;
363 ht_profile->htCapability = session_entry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800364 ht_profile->vhtCapability =
365 session_entry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800366 ht_profile->apCenterChan = session_entry->ch_center_freq_seg0;
367 ht_profile->apChanWidth = session_entry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800368 }
369#endif
Jeff Johnson11bd4f32017-09-18 08:15:17 -0700370 pe_debug("pLimJoinReq:%pK, pLimReAssocReq:%pK",
Wu Gao2968fc92017-06-19 19:18:34 +0800371 session_entry->pLimJoinReq,
372 session_entry->pLimReAssocReq);
373
374 if (session_entry->pLimJoinReq)
375 join_reassoc_req = session_entry->pLimJoinReq;
376
377 if (session_entry->pLimReAssocReq)
378 join_reassoc_req = session_entry->pLimReAssocReq;
379
380 if (!join_reassoc_req) {
381 pe_err("both pLimJoinReq and pLimReAssocReq NULL");
382 return;
383 }
384
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700385 bss_ie_len = lim_get_ielen_from_bss_description(
Wu Gao2968fc92017-06-19 19:18:34 +0800386 &join_reassoc_req->bssDescription);
387 bss_ies = &join_reassoc_req->bssDescription.ieFields;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700388 is_vendor_ap_1_present = (wlan_get_vendor_ie_ptr_from_oui(
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700389 SIR_MAC_VENDOR_AP_1_OUI, SIR_MAC_VENDOR_AP_1_OUI_LEN,
390 bss_ies, bss_ie_len) != NULL);
391
392 if (mac_ctx->roam.configParam.is_force_1x1 &&
Krunal Sonie6a1cda2017-09-27 15:23:02 -0700393 is_vendor_ap_1_present && (session_entry->nss == 2) &&
394 (mac_ctx->lteCoexAntShare == 0 ||
395 IS_5G_CH(session_entry->currentOperChannel))) {
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700396 /* SET vdev param */
397 pe_debug("sending SMPS intolrent vdev_param");
398 wma_cli_set_command(session_entry->smeSessionId,
399 (int)WMI_VDEV_PARAM_SMPS_INTOLERANT,
400 1, VDEV_CMD);
401
402 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800403 } else {
404 if (session_entry->beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530405 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800406 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530407 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800408 }
409 if (session_entry->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530410 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800411 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530412 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800413 }
414 if (session_entry->assocRsp != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530415 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800416 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530417 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800418 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800419 if (session_entry->ricData != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530420 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800421 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530422 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800423 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800424#ifdef FEATURE_WLAN_ESE
425 if (session_entry->tspecIes != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530426 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800427 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530428 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800429 }
430#endif
431 }
432}
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530433
434/**
435 * lim_add_bss_info() - copy data from session entry to join rsp
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530436 * @sta_ds: Station dph entry
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530437 * @sme_join_rsp: Join response buffer to be filled up
438 *
439 * Return: None
440 */
Jeff Johnson6db011e2016-10-07 07:31:39 -0700441static void lim_add_bss_info(tpDphHashNode sta_ds, tpSirSmeJoinRsp sme_join_rsp)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530442{
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530443 struct parsed_ies *parsed_ies = &sta_ds->parsed_ies;
444
445 if (parsed_ies->hs20vendor_ie.present)
446 sme_join_rsp->hs20vendor_ie = parsed_ies->hs20vendor_ie;
447 if (parsed_ies->vht_caps.present)
448 sme_join_rsp->vht_caps = parsed_ies->vht_caps;
449 if (parsed_ies->ht_caps.present)
450 sme_join_rsp->ht_caps = parsed_ies->ht_caps;
451 if (parsed_ies->ht_operation.present)
452 sme_join_rsp->ht_operation = parsed_ies->ht_operation;
453 if (parsed_ies->vht_operation.present)
454 sme_join_rsp->vht_operation = parsed_ies->vht_operation;
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530455}
456
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530457#ifdef WLAN_FEATURE_FILS_SK
458static void lim_update_fils_seq_num(tpSirSmeJoinRsp sme_join_rsp,
459 tpPESession session_entry)
460{
461 sme_join_rsp->fils_seq_num =
462 session_entry->fils_info->sequence_number;
463}
464#else
465static inline void lim_update_fils_seq_num(tpSirSmeJoinRsp sme_join_rsp,
466 tpPESession session_entry)
467{}
468#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800469/**
470 * lim_send_sme_join_reassoc_rsp() - Send Response to Upper Layers
471 * @mac_ctx: Pointer to Global MAC structure
472 * @msg_type: Indicates message type
473 * @result_code: Indicates the result of previously issued
474 * eWNI_SME_msgType_REQ message
475 * @prot_status_code: Protocol Status Code
476 * @session_entry: PE Session Info
477 * @sme_session_id: SME Session ID
478 * @sme_transaction_id: SME Transaction ID
479 *
480 * This function is called by lim_process_sme_req_messages() to send
481 * eWNI_SME_JOIN_RSP or eWNI_SME_REASSOC_RSP messages to applications
482 * above MAC Software.
483 *
484 * Return: None
485 */
486
487void
488lim_send_sme_join_reassoc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
489 tSirResultCodes result_code, uint16_t prot_status_code,
490 tpPESession session_entry, uint8_t sme_session_id,
491 uint16_t sme_transaction_id)
492{
493 tpSirSmeJoinRsp sme_join_rsp;
494 uint32_t rsp_len;
495 tpDphHashNode sta_ds = NULL;
496#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
497 if (msg_type == eWNI_SME_REASSOC_RSP)
498 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_RSP_EVENT,
499 session_entry, (uint16_t) result_code, 0);
500 else
501 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_RSP_EVENT,
502 session_entry, (uint16_t) result_code, 0);
503#endif /* FEATURE_WLAN_DIAG_SUPPORT */
504
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530505 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800506 lim_msg_str(msg_type), lim_result_code_str(result_code));
507
508 if (session_entry == NULL) {
509 rsp_len = sizeof(tSirSmeJoinRsp);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530510 sme_join_rsp = qdf_mem_malloc(rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800511 if (NULL == sme_join_rsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530512 pe_err("Mem Alloc fail - JOIN/REASSOC_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800513 return;
514 }
515
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800516 sme_join_rsp->beaconLength = 0;
517 sme_join_rsp->assocReqLength = 0;
518 sme_join_rsp->assocRspLength = 0;
519 } else {
520 rsp_len = session_entry->assocReqLen +
521 session_entry->assocRspLen + session_entry->bcnLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800522 session_entry->RICDataLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800523#ifdef FEATURE_WLAN_ESE
524 session_entry->tspecLen +
525#endif
526 sizeof(tSirSmeJoinRsp) - sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530527 sme_join_rsp = qdf_mem_malloc(rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800528 if (NULL == sme_join_rsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530529 pe_err("MemAlloc fail - JOIN/REASSOC_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800530 return;
531 }
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530532
533 if (lim_is_fils_connection(session_entry)) {
534 sme_join_rsp->is_fils_connection = true;
535 lim_update_fils_seq_num(sme_join_rsp,
536 session_entry);
537 }
538
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800539 if (result_code == eSIR_SME_SUCCESS) {
540 sta_ds = dph_get_hash_entry(mac_ctx,
541 DPH_STA_HASH_INDEX_PEER,
542 &session_entry->dph.dphHashTable);
543 if (sta_ds == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530544 pe_err("Get Self Sta Entry fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800545 } else {
546 /* Pass the peer's staId */
547 sme_join_rsp->staId = sta_ds->staIndex;
548 sme_join_rsp->ucastSig =
549 sta_ds->ucUcastSig;
550 sme_join_rsp->bcastSig =
551 sta_ds->ucBcastSig;
552 sme_join_rsp->timingMeasCap =
553 sta_ds->timingMeasCap;
554#ifdef FEATURE_WLAN_TDLS
555 sme_join_rsp->tdls_prohibited =
556 session_entry->tdls_prohibited;
557 sme_join_rsp->tdls_chan_swit_prohibited =
558 session_entry->tdls_chan_swit_prohibited;
559#endif
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530560 sme_join_rsp->nss = sta_ds->nss;
561 sme_join_rsp->max_rate_flags =
562 lim_get_max_rate_flags(mac_ctx, sta_ds);
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530563 lim_add_bss_info(sta_ds, sme_join_rsp);
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530564
565 /* Copy FILS params only for Successful join */
566 populate_fils_connect_params(mac_ctx,
567 session_entry, sme_join_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800568 }
569 }
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530570
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800571 sme_join_rsp->beaconLength = 0;
572 sme_join_rsp->assocReqLength = 0;
573 sme_join_rsp->assocRspLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800574 sme_join_rsp->parsedRicRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800575#ifdef FEATURE_WLAN_ESE
576 sme_join_rsp->tspecIeLen = 0;
577#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800578 lim_handle_join_rsp_status(mac_ctx, session_entry, result_code,
579 sme_join_rsp);
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800580
581 /* Send supported NSS 1x1 to SME */
582 sme_join_rsp->supported_nss_1x1 =
583 session_entry->supported_nss_1x1;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530584 pe_debug("SME Join Rsp is supported NSS 1X1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800585 sme_join_rsp->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800586 }
587
588 sme_join_rsp->messageType = msg_type;
589 sme_join_rsp->length = (uint16_t) rsp_len;
590 sme_join_rsp->statusCode = result_code;
591 sme_join_rsp->protStatusCode = prot_status_code;
592
593 sme_join_rsp->sessionId = sme_session_id;
594 sme_join_rsp->transactionId = sme_transaction_id;
595
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530596 lim_send_sme_join_reassoc_rsp_after_resume(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800597 (uint32_t *)sme_join_rsp);
598}
599
600/**
601 * lim_send_sme_start_bss_rsp()
602 *
603 ***FUNCTION:
604 * This function is called to send eWNI_SME_START_BSS_RSP
605 * message to applications above MAC Software.
606 *
607 ***PARAMS:
608 *
609 ***LOGIC:
610 *
611 ***ASSUMPTIONS:
612 * NA
613 *
614 ***NOTE:
615 * NA
616 *
617 * @param pMac Pointer to Global MAC structure
618 * @param msgType Indicates message type
619 * @param resultCode Indicates the result of previously issued
620 * eWNI_SME_msgType_REQ message
621 *
622 * @return None
623 */
624
625void
626lim_send_sme_start_bss_rsp(tpAniSirGlobal pMac,
627 uint16_t msgType, tSirResultCodes resultCode,
628 tpPESession psessionEntry, uint8_t smesessionId,
629 uint16_t smetransactionId)
630{
631
632 uint16_t size = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700633 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800634 tSirSmeStartBssRsp *pSirSmeRsp;
635 uint16_t ieLen;
636 uint16_t ieOffset, curLen;
637
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530638 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800639 lim_msg_str(msgType), lim_result_code_str(resultCode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800640
641 size = sizeof(tSirSmeStartBssRsp);
642
643 if (psessionEntry == NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530644 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800645 if (NULL == pSirSmeRsp) {
646 /* / Buffer not available. Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530647 pe_err("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800648 return;
649 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800650 } else {
651 /* subtract size of beaconLength + Mac Hdr + Fixed Fields before SSID */
652 ieOffset = sizeof(tAniBeaconStruct) + SIR_MAC_B_PR_SSID_OFFSET;
653 ieLen = psessionEntry->schBeaconOffsetBegin
654 + psessionEntry->schBeaconOffsetEnd - ieOffset;
655 /* calculate the memory size to allocate */
656 size += ieLen;
657
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530658 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800659 if (NULL == pSirSmeRsp) {
660 /* / Buffer not available. Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530661 pe_err("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800662 return;
663 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800664 size = sizeof(tSirSmeStartBssRsp);
665 if (resultCode == eSIR_SME_SUCCESS) {
666
667 sir_copy_mac_addr(pSirSmeRsp->bssDescription.bssId,
668 psessionEntry->bssId);
669
670 /* Read beacon interval from session */
671 pSirSmeRsp->bssDescription.beaconInterval =
672 (uint16_t) psessionEntry->beaconParams.
673 beaconInterval;
674 pSirSmeRsp->bssType = psessionEntry->bssType;
675
676 if (cfg_get_capability_info
677 (pMac, &pSirSmeRsp->bssDescription.capabilityInfo,
678 psessionEntry)
679 != eSIR_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530680 pe_err("could not retrieve Capabilities value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800681
682 lim_get_phy_mode(pMac,
683 (uint32_t *) &pSirSmeRsp->bssDescription.
684 nwType, psessionEntry);
685
686 pSirSmeRsp->bssDescription.channelId =
687 psessionEntry->currentOperChannel;
688
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700689 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800690 curLen = psessionEntry->schBeaconOffsetBegin - ieOffset;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530691 qdf_mem_copy((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800692 ieFields,
693 psessionEntry->pSchBeaconFrameBegin +
694 ieOffset, (uint32_t) curLen);
695
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530696 qdf_mem_copy(((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800697 ieFields) + curLen,
698 psessionEntry->pSchBeaconFrameEnd,
699 (uint32_t) psessionEntry->
700 schBeaconOffsetEnd);
701
Abhishek Singh34a4d862016-10-26 16:01:51 +0530702 pSirSmeRsp->bssDescription.length = (uint16_t)
703 (offsetof(tSirBssDescription, ieFields[0])
704 - sizeof(pSirSmeRsp->bssDescription.length)
705 + ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800706 /* This is the size of the message, subtracting the size of the pointer to ieFields */
707 size += ieLen - sizeof(uint32_t);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700708 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800709#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
710 if (psessionEntry->cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530711 != QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800712 pSirSmeRsp->HTProfile.
713 htSupportedChannelWidthSet =
714 psessionEntry->htSupportedChannelWidthSet;
715 pSirSmeRsp->HTProfile.htRecommendedTxWidthSet =
716 psessionEntry->htRecommendedTxWidthSet;
717 pSirSmeRsp->HTProfile.htSecondaryChannelOffset =
718 psessionEntry->htSecondaryChannelOffset;
719 pSirSmeRsp->HTProfile.dot11mode =
720 psessionEntry->dot11mode;
721 pSirSmeRsp->HTProfile.htCapability =
722 psessionEntry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800723 pSirSmeRsp->HTProfile.vhtCapability =
724 psessionEntry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800725 pSirSmeRsp->HTProfile.apCenterChan =
726 psessionEntry->ch_center_freq_seg0;
727 pSirSmeRsp->HTProfile.apChanWidth =
728 psessionEntry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800729 }
730#endif
731 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800732 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800733 pSirSmeRsp->messageType = msgType;
734 pSirSmeRsp->length = size;
735
736 /* Update SME session Id and transaction Id */
737 pSirSmeRsp->sessionId = smesessionId;
738 pSirSmeRsp->transactionId = smetransactionId;
739 pSirSmeRsp->statusCode = resultCode;
740 if (psessionEntry != NULL)
741 pSirSmeRsp->staId = psessionEntry->staId; /* else it will be always zero smeRsp StaID = 0 */
742
743 mmhMsg.type = msgType;
744 mmhMsg.bodyptr = pSirSmeRsp;
745 mmhMsg.bodyval = 0;
746 if (psessionEntry == NULL) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530747 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
748 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800749 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530750 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
751 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800752 }
753#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
754 lim_diag_event_report(pMac, WLAN_PE_DIAG_START_BSS_RSP_EVENT,
755 psessionEntry, (uint16_t) resultCode, 0);
756#endif /* FEATURE_WLAN_DIAG_SUPPORT */
757
758 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
759} /*** end lim_send_sme_start_bss_rsp() ***/
760
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800761void lim_send_sme_disassoc_deauth_ntf(tpAniSirGlobal pMac,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530762 QDF_STATUS status, uint32_t *pCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800763{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700764 struct scheduler_msg mmhMsg = {0};
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800765 struct scheduler_msg *pMsg = (struct scheduler_msg *) pCtx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800766
767 mmhMsg.type = pMsg->type;
768 mmhMsg.bodyptr = pMsg;
769 mmhMsg.bodyval = 0;
770
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530771 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800772
773 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
774}
775
776/**
777 * lim_send_sme_disassoc_ntf()
778 *
779 ***FUNCTION:
780 * This function is called by limProcessSmeMessages() to send
781 * eWNI_SME_DISASSOC_RSP/IND message to host
782 *
783 ***PARAMS:
784 *
785 ***LOGIC:
786 *
787 ***ASSUMPTIONS:
788 * NA
789 *
790 ***NOTE:
791 * This function is used for sending eWNI_SME_DISASSOC_CNF,
792 * or eWNI_SME_DISASSOC_IND to host depending on
793 * disassociation trigger.
794 *
795 * @param peerMacAddr Indicates the peer MAC addr to which
796 * disassociate was initiated
797 * @param reasonCode Indicates the reason for Disassociation
798 * @param disassocTrigger Indicates the trigger for Disassociation
799 * @param aid Indicates the STAID. This parameter is
800 * present only on AP.
801 *
802 * @return None
803 */
804void
805lim_send_sme_disassoc_ntf(tpAniSirGlobal pMac,
806 tSirMacAddr peerMacAddr,
807 tSirResultCodes reasonCode,
808 uint16_t disassocTrigger,
809 uint16_t aid,
810 uint8_t smesessionId,
811 uint16_t smetransactionId, tpPESession psessionEntry)
812{
813
814 uint8_t *pBuf;
815 tSirSmeDisassocRsp *pSirSmeDisassocRsp;
816 tSirSmeDisassocInd *pSirSmeDisassocInd;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700817 uint32_t *pMsg = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800818 bool failure = false;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700819 tpPESession session = NULL;
820 uint16_t i, assoc_id;
821 tpDphHashNode sta_ds = NULL;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530822 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800823
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530824 pe_debug("Disassoc Ntf with trigger : %d reasonCode: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800825 disassocTrigger, reasonCode);
826
827 switch (disassocTrigger) {
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700828 case eLIM_DUPLICATE_ENTRY:
829 /*
830 * Duplicate entry is removed at LIM.
831 * Initiate new entry for other session
832 */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530833 pe_debug("Rcvd eLIM_DUPLICATE_ENTRY for " MAC_ADDRESS_STR,
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700834 MAC_ADDR_ARRAY(peerMacAddr));
835
836 for (i = 0; i < pMac->lim.maxBssId; i++) {
837 if ((&pMac->lim.gpSession[i] != NULL) &&
838 (pMac->lim.gpSession[i].valid) &&
839 (pMac->lim.gpSession[i].pePersona ==
840 QDF_SAP_MODE)) {
841 /* Find the sta ds entry in another session */
842 session = &pMac->lim.gpSession[i];
843 sta_ds = dph_lookup_hash_entry(pMac,
844 peerMacAddr, &assoc_id,
845 &session->dph.dphHashTable);
Abhishek Singh6d6e3d12017-12-04 14:16:00 +0530846 if (sta_ds)
847 break;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700848 }
849 }
850 if (sta_ds
851#ifdef WLAN_FEATURE_11W
852 && (!sta_ds->rmfEnabled)
853#endif
854 ) {
855 if (lim_add_sta(pMac, sta_ds, false, session) !=
856 eSIR_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530857 pe_err("could not Add STA with assocId: %d",
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700858 sta_ds->assocId);
859 }
860 failure = true;
861 break;
862
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800863 case eLIM_HOST_DISASSOC:
864 /**
865 * Disassociation response due to
866 * host triggered disassociation
867 */
868
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530869 pSirSmeDisassocRsp = qdf_mem_malloc(sizeof(tSirSmeDisassocRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800870 if (NULL == pSirSmeDisassocRsp) {
871 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530872 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800873 failure = true;
874 goto error;
875 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530876 pe_debug("send eWNI_SME_DISASSOC_RSP with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800877 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
878 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
879 pSirSmeDisassocRsp->length = sizeof(tSirSmeDisassocRsp);
880 /* sessionId */
881 pBuf = (uint8_t *) &pSirSmeDisassocRsp->sessionId;
882 *pBuf = smesessionId;
883 pBuf++;
884
885 /* transactionId */
886 lim_copy_u16(pBuf, smetransactionId);
887 pBuf += sizeof(uint16_t);
888
889 /* statusCode */
890 lim_copy_u32(pBuf, reasonCode);
891 pBuf += sizeof(tSirResultCodes);
892
893 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530894 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800895 pBuf += sizeof(tSirMacAddr);
896
897 /* Clear Station Stats */
898 /* for sta, it is always 1, IBSS is handled at halInitSta */
899
900#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
901
902 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
903 psessionEntry, (uint16_t) reasonCode, 0);
904#endif
905 pMsg = (uint32_t *) pSirSmeDisassocRsp;
906 break;
907
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530908 case eLIM_PEER_ENTITY_DISASSOC:
909 case eLIM_LINK_MONITORING_DISASSOC:
910 sir_sme_dis_ind =
911 qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
912 if (!sir_sme_dis_ind) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530913 pe_err("call to AllocateMemory failed for disconnect indication");
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530914 return;
915 }
916
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530917 pe_debug("send eWNI_SME_DISCONNECT_DONE_IND with retCode: %d",
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530918 reasonCode);
919
920 sir_sme_dis_ind->message_type =
921 eWNI_SME_DISCONNECT_DONE_IND;
922 sir_sme_dis_ind->length =
923 sizeof(*sir_sme_dis_ind);
924 qdf_mem_copy(sir_sme_dis_ind->peer_mac, peerMacAddr,
925 sizeof(tSirMacAddr));
926 sir_sme_dis_ind->session_id = smesessionId;
927 sir_sme_dis_ind->reason_code = reasonCode;
Selvaraj, Sridharc7d80892016-09-29 11:56:45 +0530928 /*
929 * Instead of sending deauth reason code as 505 which is
930 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
931 * Send reason code as zero to Supplicant
932 */
933 if (reasonCode == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
934 sir_sme_dis_ind->reason_code = 0;
935 else
936 sir_sme_dis_ind->reason_code = reasonCode;
937
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530938 pMsg = (uint32_t *)sir_sme_dis_ind;
939
940 break;
941
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800942 default:
943 /**
944 * Disassociation indication due to Disassociation
945 * frame reception from peer entity or due to
946 * loss of link with peer entity.
947 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530948 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800949 if (NULL == pSirSmeDisassocInd) {
950 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530951 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800952 failure = true;
953 goto error;
954 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530955 pe_debug("send eWNI_SME_DISASSOC_IND with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800956 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
957 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
958 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
959
960 /* Update SME session Id and Transaction Id */
961 pSirSmeDisassocInd->sessionId = smesessionId;
962 pSirSmeDisassocInd->transactionId = smetransactionId;
963 pSirSmeDisassocInd->reasonCode = reasonCode;
964 pBuf = (uint8_t *) &pSirSmeDisassocInd->statusCode;
965
966 lim_copy_u32(pBuf, reasonCode);
967 pBuf += sizeof(tSirResultCodes);
968
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530969 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800970 pBuf += sizeof(tSirMacAddr);
971
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530972 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800973
974#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
975 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
976 psessionEntry, (uint16_t) reasonCode, 0);
977#endif
978 pMsg = (uint32_t *) pSirSmeDisassocInd;
979
980 break;
981 }
982
983error:
984 /* Delete the PE session Created */
Rajeev Kumarcf835a02016-04-15 15:01:31 -0700985 if ((psessionEntry != NULL) && LIM_IS_STA_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800986 pe_delete_session(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800987
988 if (false == failure)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530989 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800990 (uint32_t *) pMsg);
991} /*** end lim_send_sme_disassoc_ntf() ***/
992
993/** -----------------------------------------------------------------
994 \brief lim_send_sme_disassoc_ind() - sends SME_DISASSOC_IND
995
996 After receiving disassociation frame from peer entity, this
997 function sends a eWNI_SME_DISASSOC_IND to SME with a specific
998 reason code.
999
1000 \param pMac - global mac structure
1001 \param pStaDs - station dph hash node
1002 \return none
1003 \sa
1004 ----------------------------------------------------------------- */
1005void
1006lim_send_sme_disassoc_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1007 tpPESession psessionEntry)
1008{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001009 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001010 tSirSmeDisassocInd *pSirSmeDisassocInd;
1011
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301012 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001013 if (NULL == pSirSmeDisassocInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301014 pe_err("AllocateMemory failed for eWNI_SME_DISASSOC_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001015 return;
1016 }
1017
1018 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
1019 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
1020
1021 pSirSmeDisassocInd->sessionId = psessionEntry->smeSessionId;
1022 pSirSmeDisassocInd->transactionId = psessionEntry->transactionId;
Padma, Santhosh Kumar02289212016-09-30 13:30:08 +05301023 pSirSmeDisassocInd->statusCode = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001024 pSirSmeDisassocInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1025
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301026 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301027 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001028
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301029 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301030 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001031
1032 pSirSmeDisassocInd->staId = pStaDs->staIndex;
1033
1034 mmhMsg.type = eWNI_SME_DISASSOC_IND;
1035 mmhMsg.bodyptr = pSirSmeDisassocInd;
1036 mmhMsg.bodyval = 0;
1037
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301038 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1039 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1041 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT, psessionEntry,
1042 0, (uint16_t) pStaDs->mlmStaContext.disassocReason);
1043#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1044
1045 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1046
1047} /*** end lim_send_sme_disassoc_ind() ***/
1048
1049/** -----------------------------------------------------------------
1050 \brief lim_send_sme_deauth_ind() - sends SME_DEAUTH_IND
1051
1052 After receiving deauthentication frame from peer entity, this
1053 function sends a eWNI_SME_DEAUTH_IND to SME with a specific
1054 reason code.
1055
1056 \param pMac - global mac structure
1057 \param pStaDs - station dph hash node
1058 \return none
1059 \sa
1060 ----------------------------------------------------------------- */
1061void
1062lim_send_sme_deauth_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1063 tpPESession psessionEntry)
1064{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001065 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001066 tSirSmeDeauthInd *pSirSmeDeauthInd;
1067
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301068 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001069 if (NULL == pSirSmeDeauthInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301070 pe_err("AllocateMemory failed for eWNI_SME_DEAUTH_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001071 return;
1072 }
1073
1074 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1075 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1076
1077 pSirSmeDeauthInd->sessionId = psessionEntry->smeSessionId;
1078 pSirSmeDeauthInd->transactionId = psessionEntry->transactionId;
1079 if (eSIR_INFRA_AP_MODE == psessionEntry->bssType) {
1080 pSirSmeDeauthInd->statusCode =
1081 (tSirResultCodes) pStaDs->mlmStaContext.cleanupTrigger;
1082 } else {
1083 /* Need to indicatet he reascon code over the air */
1084 pSirSmeDeauthInd->statusCode =
1085 (tSirResultCodes) pStaDs->mlmStaContext.disassocReason;
1086 }
1087 /* BSSID */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301088 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301089 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001090 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301091 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301092 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001093 pSirSmeDeauthInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1094
1095 pSirSmeDeauthInd->staId = pStaDs->staIndex;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001096 if (eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON ==
1097 pStaDs->mlmStaContext.disassocReason)
1098 pSirSmeDeauthInd->rssi = pStaDs->del_sta_ctx_rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001099
1100 mmhMsg.type = eWNI_SME_DEAUTH_IND;
1101 mmhMsg.bodyptr = pSirSmeDeauthInd;
1102 mmhMsg.bodyval = 0;
1103
1104 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1105#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1106 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT, psessionEntry,
1107 0, pStaDs->mlmStaContext.cleanupTrigger);
1108#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1109
1110 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1111 return;
1112} /*** end lim_send_sme_deauth_ind() ***/
1113
1114#ifdef FEATURE_WLAN_TDLS
1115/**
1116 * lim_send_sme_tdls_del_sta_ind()
1117 *
1118 ***FUNCTION:
1119 * This function is called to send the TDLS STA context deletion to SME.
1120 *
1121 ***LOGIC:
1122 *
1123 ***ASSUMPTIONS:
1124 *
1125 ***NOTE:
1126 * NA
1127 *
1128 * @param pMac - Pointer to global MAC structure
1129 * @param pStaDs - Pointer to internal STA Datastructure
1130 * @param psessionEntry - Pointer to the session entry
1131 * @param reasonCode - Reason for TDLS sta deletion
1132 * @return None
1133 */
1134void
1135lim_send_sme_tdls_del_sta_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1136 tpPESession psessionEntry, uint16_t reasonCode)
1137{
Frank Liud1a28462017-09-06 22:55:48 +08001138 struct tdls_event_info info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001139
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301140 pe_debug("Delete TDLS Peer "MAC_ADDRESS_STR "with reason code: %d",
Nitesh Shah82c52812016-12-27 12:27:51 +05301141 MAC_ADDR_ARRAY(pStaDs->staAddr), reasonCode);
Frank Liud1a28462017-09-06 22:55:48 +08001142 info.vdev_id = psessionEntry->smeSessionId;
1143 qdf_mem_copy(info.peermac.bytes, pStaDs->staAddr, QDF_MAC_ADDR_SIZE);
1144 info.message_type = TDLS_PEER_DISCONNECTED;
1145 info.peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001146
Frank Liud1a28462017-09-06 22:55:48 +08001147 tgt_tdls_event_handler(pMac->psoc, &info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001148
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001149 return;
1150} /*** end lim_send_sme_tdls_del_sta_ind() ***/
1151
1152/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001153 * lim_send_sme_mgmt_tx_completion()
1154 *
1155 ***FUNCTION:
1156 * This function is called to send the eWNI_SME_MGMT_FRM_TX_COMPLETION_IND
1157 * message to SME.
1158 *
1159 ***LOGIC:
1160 *
1161 ***ASSUMPTIONS:
1162 *
1163 ***NOTE:
1164 * NA
1165 *
1166 * @param pMac - Pointer to global MAC structure
1167 * @param psessionEntry - Pointer to the session entry
1168 * @param txCompleteStatus - TX Complete Status of Mgmt Frames
1169 * @return None
1170 */
1171void
1172lim_send_sme_mgmt_tx_completion(tpAniSirGlobal pMac,
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301173 uint32_t sme_session_id,
1174 uint32_t txCompleteStatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001175{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001176 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001177 tSirMgmtTxCompletionInd *pSirMgmtTxCompletionInd;
1178
1179 pSirMgmtTxCompletionInd =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301180 qdf_mem_malloc(sizeof(tSirMgmtTxCompletionInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001181 if (NULL == pSirMgmtTxCompletionInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301182 pe_err("AllocateMemory failed for eWNI_SME_MGMT_FRM_TX_COMPLETION_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001183 return;
1184 }
1185 /* messageType */
1186 pSirMgmtTxCompletionInd->messageType =
1187 eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1188 pSirMgmtTxCompletionInd->length = sizeof(tSirMgmtTxCompletionInd);
1189
1190 /* sessionId */
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301191 pSirMgmtTxCompletionInd->sessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001192
1193 pSirMgmtTxCompletionInd->txCompleteStatus = txCompleteStatus;
1194
1195 mmhMsg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1196 mmhMsg.bodyptr = pSirMgmtTxCompletionInd;
1197 mmhMsg.bodyval = 0;
1198
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07001199 pSirMgmtTxCompletionInd->psoc = pMac->psoc;
1200 mmhMsg.callback = tgt_tdls_send_mgmt_tx_completion;
1201 scheduler_post_msg(QDF_MODULE_ID_TARGET_IF, &mmhMsg);
1202 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001203} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1204
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001205#endif /* FEATURE_WLAN_TDLS */
1206
1207/**
1208 * lim_send_sme_deauth_ntf()
1209 *
1210 ***FUNCTION:
1211 * This function is called by limProcessSmeMessages() to send
1212 * eWNI_SME_DISASSOC_RSP/IND message to host
1213 *
1214 ***PARAMS:
1215 *
1216 ***LOGIC:
1217 *
1218 ***ASSUMPTIONS:
1219 * NA
1220 *
1221 ***NOTE:
1222 * This function is used for sending eWNI_SME_DEAUTH_CNF or
1223 * eWNI_SME_DEAUTH_IND to host depending on deauthentication trigger.
1224 *
1225 * @param peerMacAddr Indicates the peer MAC addr to which
1226 * deauthentication was initiated
1227 * @param reasonCode Indicates the reason for Deauthetication
1228 * @param deauthTrigger Indicates the trigger for Deauthetication
1229 * @param aid Indicates the STAID. This parameter is present
1230 * only on AP.
1231 *
1232 * @return None
1233 */
1234void
1235lim_send_sme_deauth_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
1236 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1237 uint16_t aid, uint8_t smesessionId,
1238 uint16_t smetransactionId)
1239{
1240 uint8_t *pBuf;
1241 tSirSmeDeauthRsp *pSirSmeDeauthRsp;
1242 tSirSmeDeauthInd *pSirSmeDeauthInd;
1243 tpPESession psessionEntry;
1244 uint8_t sessionId;
1245 uint32_t *pMsg;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301246 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001247
1248 psessionEntry = pe_find_session_by_bssid(pMac, peerMacAddr, &sessionId);
1249 switch (deauthTrigger) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001250 case eLIM_HOST_DEAUTH:
1251 /**
1252 * Deauthentication response to host triggered
1253 * deauthentication.
1254 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301255 pSirSmeDeauthRsp = qdf_mem_malloc(sizeof(tSirSmeDeauthRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001256 if (NULL == pSirSmeDeauthRsp) {
1257 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301258 pe_err("call to AllocateMemory failed for eWNI_SME_DEAUTH_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001259 return;
1260 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301261 pe_debug("send eWNI_SME_DEAUTH_RSP with retCode: %d for" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001262 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1263 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
1264 pSirSmeDeauthRsp->length = sizeof(tSirSmeDeauthRsp);
1265 pSirSmeDeauthRsp->statusCode = reasonCode;
1266 pSirSmeDeauthRsp->sessionId = smesessionId;
1267 pSirSmeDeauthRsp->transactionId = smetransactionId;
1268
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -08001269 pBuf = (uint8_t *) pSirSmeDeauthRsp->peer_macaddr.bytes;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301270 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001271
1272#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1273 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
1274 psessionEntry, 0, (uint16_t) reasonCode);
1275#endif
1276 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1277
1278 break;
1279
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301280 case eLIM_PEER_ENTITY_DEAUTH:
1281 case eLIM_LINK_MONITORING_DEAUTH:
1282 sir_sme_dis_ind =
1283 qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
1284 if (!sir_sme_dis_ind) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301285 pe_err("call to AllocateMemory failed for disconnect indication");
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301286 return;
1287 }
1288
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301289 pe_debug("send eWNI_SME_DISCONNECT_DONE_IND withretCode: %d",
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301290 reasonCode);
1291
1292 sir_sme_dis_ind->message_type =
1293 eWNI_SME_DISCONNECT_DONE_IND;
1294 sir_sme_dis_ind->length =
1295 sizeof(*sir_sme_dis_ind);
1296 sir_sme_dis_ind->session_id = smesessionId;
1297 sir_sme_dis_ind->reason_code = reasonCode;
1298 qdf_mem_copy(sir_sme_dis_ind->peer_mac, peerMacAddr,
1299 ETH_ALEN);
Selvaraj, Sridharc7d80892016-09-29 11:56:45 +05301300 /*
1301 * Instead of sending deauth reason code as 505 which is
1302 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1303 * Send reason code as zero to Supplicant
1304 */
1305 if (reasonCode == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1306 sir_sme_dis_ind->reason_code = 0;
1307 else
1308 sir_sme_dis_ind->reason_code = reasonCode;
1309
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301310 pMsg = (uint32_t *)sir_sme_dis_ind;
1311
1312 break;
1313
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001314 default:
1315 /**
1316 * Deauthentication indication due to Deauthentication
1317 * frame reception from peer entity or due to
1318 * loss of link with peer entity.
1319 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301320 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001321 if (NULL == pSirSmeDeauthInd) {
1322 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301323 pe_err("call to AllocateMemory failed for eWNI_SME_DEAUTH_Ind");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001324 return;
1325 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301326 pe_debug("send eWNI_SME_DEAUTH_IND with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001327 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1328 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1329 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1330 pSirSmeDeauthInd->reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
1331
1332 /* sessionId */
1333 pBuf = (uint8_t *) &pSirSmeDeauthInd->sessionId;
1334 *pBuf++ = smesessionId;
1335
1336 /* transaction ID */
1337 lim_copy_u16(pBuf, smetransactionId);
1338 pBuf += sizeof(uint16_t);
1339
1340 /* status code */
1341 lim_copy_u32(pBuf, reasonCode);
1342 pBuf += sizeof(tSirResultCodes);
1343
1344 /* bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301345 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001346 pBuf += sizeof(tSirMacAddr);
1347
1348 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301349 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301350 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001351
1352#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1353 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
1354 psessionEntry, 0, (uint16_t) reasonCode);
1355#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1356 pMsg = (uint32_t *) pSirSmeDeauthInd;
1357
1358 break;
1359 }
1360
1361 /*Delete the PE session created */
1362 if (psessionEntry != NULL) {
1363 pe_delete_session(pMac, psessionEntry);
1364 }
1365
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301366 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001367 (uint32_t *) pMsg);
1368
1369} /*** end lim_send_sme_deauth_ntf() ***/
1370
1371/**
1372 * lim_send_sme_wm_status_change_ntf() - Send Notification
1373 * @mac_ctx: Global MAC Context
1374 * @status_change_code: Indicates the change in the wireless medium.
1375 * @status_change_info: Indicates the information associated with
1376 * change in the wireless medium.
1377 * @info_len: Indicates the length of status change information
1378 * being sent.
1379 * @session_id SessionID
1380 *
1381 * This function is called by limProcessSmeMessages() to send
1382 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1383 *
1384 * Return: None
1385 */
1386void
1387lim_send_sme_wm_status_change_ntf(tpAniSirGlobal mac_ctx,
1388 tSirSmeStatusChangeCode status_change_code,
1389 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1390{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001391 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001392 tSirSmeWmStatusChangeNtf *wm_status_change_ntf;
Naveen Rawate01ed172016-11-17 11:34:50 -08001393 uint32_t max_info_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001394
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301395 wm_status_change_ntf = qdf_mem_malloc(sizeof(tSirSmeWmStatusChangeNtf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001396 if (NULL == wm_status_change_ntf) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301397 pe_err("Mem Alloc failed - eWNI_SME_WM_STATUS_CHANGE_NTF");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001398 return;
1399 }
1400
1401 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1402 msg.bodyval = 0;
1403 msg.bodyptr = wm_status_change_ntf;
1404
1405 switch (status_change_code) {
Naveen Rawate01ed172016-11-17 11:34:50 -08001406 case eSIR_SME_AP_CAPS_CHANGED:
1407 max_info_len = sizeof(tSirSmeApNewCaps);
1408 break;
1409 case eSIR_SME_JOINED_NEW_BSS:
1410 max_info_len = sizeof(tSirSmeNewBssInfo);
1411 break;
1412 default:
1413 max_info_len = sizeof(wm_status_change_ntf->statusChangeInfo);
1414 break;
1415 }
1416
1417 switch (status_change_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001418 case eSIR_SME_RADAR_DETECTED:
1419 break;
1420 default:
1421 wm_status_change_ntf->messageType =
1422 eWNI_SME_WM_STATUS_CHANGE_NTF;
1423 wm_status_change_ntf->statusChangeCode = status_change_code;
1424 wm_status_change_ntf->length = sizeof(tSirSmeWmStatusChangeNtf);
1425 wm_status_change_ntf->sessionId = session_id;
Naveen Rawate01ed172016-11-17 11:34:50 -08001426 if (info_len <= max_info_len && status_change_info) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301427 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001428 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1429 (uint8_t *) status_change_info, info_len);
1430 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301431 pe_debug("StatusChg code: 0x%x length: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001432 status_change_code, info_len);
1433 break;
1434 }
1435
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301436 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001437 if (eSIR_SUCCESS != lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301438 qdf_mem_free(wm_status_change_ntf);
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301439 pe_err("lim_sys_process_mmh_msg_api failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001440 }
1441
1442} /*** end lim_send_sme_wm_status_change_ntf() ***/
1443
1444/**
1445 * lim_send_sme_set_context_rsp()
1446 *
1447 ***FUNCTION:
1448 * This function is called by limProcessSmeMessages() to send
1449 * eWNI_SME_SETCONTEXT_RSP message to host
1450 *
1451 ***PARAMS:
1452 *
1453 ***LOGIC:
1454 *
1455 ***ASSUMPTIONS:
1456 * NA
1457 *
1458 ***NOTE:
1459 *
1460 * @param pMac Pointer to Global MAC structure
1461 * @param peerMacAddr Indicates the peer MAC addr to which
1462 * setContext was performed
1463 * @param aid Indicates the aid corresponding to the peer MAC
1464 * address
1465 * @param resultCode Indicates the result of previously issued
1466 * eWNI_SME_SETCONTEXT_RSP message
1467 *
1468 * @return None
1469 */
1470void
1471lim_send_sme_set_context_rsp(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301472 struct qdf_mac_addr peer_macaddr, uint16_t aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001473 tSirResultCodes resultCode,
1474 tpPESession psessionEntry, uint8_t smesessionId,
1475 uint16_t smetransactionId)
1476{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001477 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001478 tSirSmeSetContextRsp *pSirSmeSetContextRsp;
1479
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301480 pSirSmeSetContextRsp = qdf_mem_malloc(sizeof(tSirSmeSetContextRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001481 if (NULL == pSirSmeSetContextRsp) {
1482 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301483 pe_err("call to AllocateMemory failed for SmeSetContextRsp");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001484 return;
1485 }
1486
1487 pSirSmeSetContextRsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1488 pSirSmeSetContextRsp->length = sizeof(tSirSmeSetContextRsp);
1489 pSirSmeSetContextRsp->statusCode = resultCode;
1490
Anurag Chouhanc5548422016-02-24 18:33:27 +05301491 qdf_copy_macaddr(&pSirSmeSetContextRsp->peer_macaddr, &peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001492
1493 /* Update SME session and transaction Id */
1494 pSirSmeSetContextRsp->sessionId = smesessionId;
1495 pSirSmeSetContextRsp->transactionId = smetransactionId;
1496
1497 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
1498 mmhMsg.bodyptr = pSirSmeSetContextRsp;
1499 mmhMsg.bodyval = 0;
1500 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301501 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1502 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001503 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301504 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1505 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001506 }
1507
1508#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1509 lim_diag_event_report(pMac, WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
1510 psessionEntry, (uint16_t) resultCode, 0);
1511#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1512
1513 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1514} /*** end lim_send_sme_set_context_rsp() ***/
1515
1516/**
1517 * lim_send_sme_neighbor_bss_ind()
1518 *
1519 ***FUNCTION:
1520 * This function is called by lim_lookup_nadd_hash_entry() to send
1521 * eWNI_SME_NEIGHBOR_BSS_IND message to host
1522 *
1523 ***PARAMS:
1524 *
1525 ***LOGIC:
1526 *
1527 ***ASSUMPTIONS:
1528 * NA
1529 *
1530 ***NOTE:
1531 * This function is used for sending eWNI_SME_NEIGHBOR_BSS_IND to
1532 * host upon detecting new BSS during background scanning if CFG
1533 * option is enabled for sending such indication
1534 *
1535 * @param pMac - Pointer to Global MAC structure
1536 * @return None
1537 */
1538
1539void
1540lim_send_sme_neighbor_bss_ind(tpAniSirGlobal pMac, tLimScanResultNode *pBssDescr)
1541{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001542 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001543 uint32_t val;
1544 tSirSmeNeighborBssInd *pNewBssInd;
1545
1546 if ((pMac->lim.gLimSmeState != eLIM_SME_LINK_EST_WT_SCAN_STATE) ||
1547 ((pMac->lim.gLimSmeState == eLIM_SME_LINK_EST_WT_SCAN_STATE) &&
1548 pMac->lim.gLimRspReqd)) {
1549 /* LIM is not in background scan state OR */
1550 /* current scan is initiated by HDD. */
1551 /* No need to send new BSS indication to HDD */
1552 return;
1553 }
1554
1555 if (wlan_cfg_get_int(pMac, WNI_CFG_NEW_BSS_FOUND_IND, &val) !=
1556 eSIR_SUCCESS) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301557 pe_err("could not get NEIGHBOR_BSS_IND from CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001558 return;
1559 }
1560
1561 if (val == 0)
1562 return;
1563
1564 /**
1565 * Need to indicate new BSSs found during
1566 * background scanning to host.
1567 * Allocate buffer for sending indication.
1568 * Length of buffer is length of BSS description
1569 * and length of header itself
1570 */
1571 val = pBssDescr->bssDescription.length + sizeof(uint16_t) +
1572 sizeof(uint32_t) + sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301573 pNewBssInd = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001574 if (NULL == pNewBssInd) {
1575 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301576 pe_err("call to AllocateMemory failed for eWNI_SME_NEIGHBOR_BSS_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001577 return;
1578 }
1579
1580 pNewBssInd->messageType = eWNI_SME_NEIGHBOR_BSS_IND;
1581 pNewBssInd->length = (uint16_t) val;
1582 pNewBssInd->sessionId = 0;
1583
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301584 qdf_mem_copy((uint8_t *) pNewBssInd->bssDescription,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001585 (uint8_t *) &pBssDescr->bssDescription,
1586 pBssDescr->bssDescription.length + sizeof(uint16_t));
1587
1588 msgQ.type = eWNI_SME_NEIGHBOR_BSS_IND;
1589 msgQ.bodyptr = pNewBssInd;
1590 msgQ.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301591 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, msgQ.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001592 lim_sys_process_mmh_msg_api(pMac, &msgQ, ePROT);
1593} /*** end lim_send_sme_neighbor_bss_ind() ***/
1594
1595/** -----------------------------------------------------------------
1596 \brief lim_send_sme_addts_rsp() - sends SME ADDTS RSP
1597 \ This function sends a eWNI_SME_ADDTS_RSP to SME.
1598 \ SME only looks at rc and tspec field.
1599 \param pMac - global mac structure
1600 \param rspReqd - is SmeAddTsRsp required
1601 \param status - status code of SME_ADD_TS_RSP
1602 \return tspec
1603 \sa
1604 ----------------------------------------------------------------- */
1605void
1606lim_send_sme_addts_rsp(tpAniSirGlobal pMac, uint8_t rspReqd, uint32_t status,
1607 tpPESession psessionEntry, tSirMacTspecIE tspec,
1608 uint8_t smesessionId, uint16_t smetransactionId)
1609{
1610 tpSirAddtsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001611 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001612
1613 if (!rspReqd)
1614 return;
1615
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301616 rsp = qdf_mem_malloc(sizeof(tSirAddtsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001617 if (NULL == rsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301618 pe_err("AllocateMemory failed for ADDTS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001619 return;
1620 }
1621
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001622 rsp->messageType = eWNI_SME_ADDTS_RSP;
1623 rsp->rc = status;
1624 rsp->rsp.status = (enum eSirMacStatusCodes)status;
1625 rsp->rsp.tspec = tspec;
1626 /* Update SME session Id and transcation Id */
1627 rsp->sessionId = smesessionId;
1628 rsp->transactionId = smetransactionId;
1629
1630 mmhMsg.type = eWNI_SME_ADDTS_RSP;
1631 mmhMsg.bodyptr = rsp;
1632 mmhMsg.bodyval = 0;
1633 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301634 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1635 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001636 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301637 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1638 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001639 }
1640#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1641 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_RSP_EVENT, psessionEntry, 0,
1642 0);
1643#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1644
1645 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1646 return;
1647}
1648
1649void
1650lim_send_sme_delts_rsp(tpAniSirGlobal pMac, tpSirDeltsReq delts, uint32_t status,
1651 tpPESession psessionEntry, uint8_t smesessionId,
1652 uint16_t smetransactionId)
1653{
1654 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001655 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001656
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301657 pe_debug("SendSmeDeltsRsp aid: %d tsid: %d up: %d status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001658 delts->aid,
1659 delts->req.tsinfo.traffic.tsid,
1660 delts->req.tsinfo.traffic.userPrio, status);
1661 if (!delts->rspReqd)
1662 return;
1663
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301664 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001665 if (NULL == rsp) {
1666 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301667 pe_err("AllocateMemory failed for DELTS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001668 return;
1669 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001670
1671 if (psessionEntry != NULL) {
1672
1673 rsp->aid = delts->aid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301674 qdf_copy_macaddr(&rsp->macaddr, &delts->macaddr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301675 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) &delts->req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001676 sizeof(tSirDeltsReqInfo));
1677 }
1678
1679 rsp->messageType = eWNI_SME_DELTS_RSP;
1680 rsp->rc = status;
1681
1682 /* Update SME session Id and transcation Id */
1683 rsp->sessionId = smesessionId;
1684 rsp->transactionId = smetransactionId;
1685
1686 mmhMsg.type = eWNI_SME_DELTS_RSP;
1687 mmhMsg.bodyptr = rsp;
1688 mmhMsg.bodyval = 0;
1689 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301690 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1691 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001692 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301693 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1694 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001695 }
1696#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1697 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_RSP_EVENT, psessionEntry,
1698 (uint16_t) status, 0);
1699#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1700
1701 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1702}
1703
1704void
1705lim_send_sme_delts_ind(tpAniSirGlobal pMac, tpSirDeltsReqInfo delts, uint16_t aid,
1706 tpPESession psessionEntry)
1707{
1708 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001709 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001710
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301711 pe_debug("SendSmeDeltsInd aid: %d tsid: %d up: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001712 aid, delts->tsinfo.traffic.tsid, delts->tsinfo.traffic.userPrio);
1713
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301714 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001715 if (NULL == rsp) {
1716 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301717 pe_err("AllocateMemory failed for DELTS_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001718 return;
1719 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001720
1721 rsp->messageType = eWNI_SME_DELTS_IND;
1722 rsp->rc = eSIR_SUCCESS;
1723 rsp->aid = aid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301724 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) delts, sizeof(*delts));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001725
1726 /* Update SME session Id and SME transaction Id */
1727
1728 rsp->sessionId = psessionEntry->smeSessionId;
1729 rsp->transactionId = psessionEntry->transactionId;
1730
1731 mmhMsg.type = eWNI_SME_DELTS_IND;
1732 mmhMsg.bodyptr = rsp;
1733 mmhMsg.bodyval = 0;
1734 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1735#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1736 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_IND_EVENT, psessionEntry, 0,
1737 0);
1738#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1739
1740 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1741}
1742
1743/**
1744 * lim_send_sme_pe_statistics_rsp()
1745 *
1746 ***FUNCTION:
1747 * This function is called to send 802.11 statistics response to HDD.
1748 * This function posts the result back to HDD. This is a response to
1749 * HDD's request for statistics.
1750 *
1751 ***PARAMS:
1752 *
1753 ***LOGIC:
1754 *
1755 ***ASSUMPTIONS:
1756 * NA
1757 *
1758 ***NOTE:
1759 * NA
1760 *
1761 * @param pMac Pointer to Global MAC structure
1762 * @param p80211Stats Statistics sent in response
1763 * @param resultCode TODO:
1764 *
1765 *
1766 * @return none
1767 */
1768
1769void
1770lim_send_sme_pe_statistics_rsp(tpAniSirGlobal pMac, uint16_t msgType, void *stats)
1771{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001772 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001773 uint8_t sessionId;
1774 tAniGetPEStatsRsp *pPeStats = (tAniGetPEStatsRsp *) stats;
1775 tpPESession pPeSessionEntry;
1776
1777 /* Get the Session Id based on Sta Id */
1778 pPeSessionEntry =
1779 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1780
1781 /* Fill the Session Id */
1782 if (NULL != pPeSessionEntry) {
1783 /* Fill the Session Id */
1784 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1785 }
1786
1787 pPeStats->msgType = eWNI_SME_GET_STATISTICS_RSP;
1788
1789 /* msgType should be WMA_GET_STATISTICS_RSP */
1790 mmhMsg.type = eWNI_SME_GET_STATISTICS_RSP;
1791
1792 mmhMsg.bodyptr = stats;
1793 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301794 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001795 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1796
1797 return;
1798
1799} /*** end lim_send_sme_pe_statistics_rsp() ***/
1800
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001801#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001802/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001803 * lim_send_sme_pe_ese_tsm_rsp() - send tsm response
1804 * @pMac: Pointer to global pMac structure
1805 * @pStats: Pointer to TSM Stats
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001806 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001807 * This function is called to send tsm stats response to HDD.
1808 * This function posts the result back to HDD. This is a response to
1809 * HDD's request to get tsm stats.
1810 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001811 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001812 */
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001813void lim_send_sme_pe_ese_tsm_rsp(tpAniSirGlobal pMac,
1814 tAniGetTsmStatsRsp *pStats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001815{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001816 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001817 uint8_t sessionId;
1818 tAniGetTsmStatsRsp *pPeStats = (tAniGetTsmStatsRsp *) pStats;
1819 tpPESession pPeSessionEntry = NULL;
1820
1821 /* Get the Session Id based on Sta Id */
1822 pPeSessionEntry =
1823 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1824
1825 /* Fill the Session Id */
1826 if (NULL != pPeSessionEntry) {
1827 /* Fill the Session Id */
1828 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1829 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301830 pe_err("Session not found for the Sta id: %d",
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301831 pPeStats->staId);
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05301832 qdf_mem_free(pPeStats->tsmStatsReq);
1833 qdf_mem_free(pPeStats);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001834 return;
1835 }
1836
1837 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
1838 pPeStats->tsmMetrics.RoamingCount
1839 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
1840 pPeStats->tsmMetrics.RoamingDly
1841 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
1842
1843 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
1844 mmhMsg.bodyptr = pStats;
1845 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301846 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001847 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1848
1849 return;
1850} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
1851
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001852#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001853
1854void
1855lim_send_sme_ibss_peer_ind(tpAniSirGlobal pMac,
1856 tSirMacAddr peerMacAddr,
1857 uint16_t staIndex,
1858 uint8_t ucastIdx,
1859 uint8_t bcastIdx,
1860 uint8_t *beacon,
1861 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
1862{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001863 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001864 tSmeIbssPeerInd *pNewPeerInd;
1865
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301866 pNewPeerInd = qdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001867 if (NULL == pNewPeerInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301868 pe_err("Failed to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001869 return;
1870 }
1871
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301872 qdf_mem_copy((uint8_t *) pNewPeerInd->peer_addr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301873 peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001874 pNewPeerInd->staId = staIndex;
1875 pNewPeerInd->ucastSig = ucastIdx;
1876 pNewPeerInd->bcastSig = bcastIdx;
1877 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
1878 pNewPeerInd->mesgType = msgType;
1879 pNewPeerInd->sessionId = sessionId;
1880
1881 if (beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301882 qdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001883 sizeof(tSmeIbssPeerInd)), (void *)beacon,
1884 beaconLen);
1885 }
1886
1887 mmhMsg.type = msgType;
1888 mmhMsg.bodyptr = pNewPeerInd;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301889 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001890 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1891
1892}
1893
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07001894/**
1895 * lim_process_csa_wbw_ie() - Process CSA Wide BW IE
1896 * @mac_ctx: pointer to global adapter context
1897 * @csa_params: pointer to CSA parameters
1898 * @chnl_switch_info:pointer to channel switch parameters
1899 * @session_entry: session pointer
1900 *
1901 * Return: None
1902 */
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001903static QDF_STATUS lim_process_csa_wbw_ie(tpAniSirGlobal mac_ctx,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001904 struct csa_offload_params *csa_params,
1905 tLimWiderBWChannelSwitchInfo *chnl_switch_info,
1906 tpPESession session_entry)
1907{
Amar Singhal5cccafe2017-02-15 12:42:58 -08001908 struct ch_params ch_params = {0};
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001909 uint8_t ap_new_ch_width;
1910 bool new_ch_width_dfn = false;
1911 uint8_t center_freq_diff;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001912 uint32_t fw_vht_ch_wd = wma_get_vht_ch_width() + 1;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001913
1914 ap_new_ch_width = csa_params->new_ch_width + 1;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001915
1916 pe_info("new channel: %d new_ch_width: %d seg0: %d seg1: %d",
1917 csa_params->channel, ap_new_ch_width,
1918 csa_params->new_ch_freq_seg1,
1919 csa_params->new_ch_freq_seg2);
1920
1921 if ((ap_new_ch_width != CH_WIDTH_80MHZ) &&
1922 (ap_new_ch_width != CH_WIDTH_160MHZ) &&
1923 (ap_new_ch_width != CH_WIDTH_80P80MHZ)) {
1924 pe_err("CSA wide BW IE has wrong ch_width %d",
1925 csa_params->new_ch_width);
1926 return QDF_STATUS_E_INVAL;
1927 }
1928
1929 if (!csa_params->new_ch_freq_seg1 && !csa_params->new_ch_freq_seg2) {
1930 pe_err("CSA wide BW IE has invalid center freq");
1931 return QDF_STATUS_E_INVAL;
1932 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001933 if ((ap_new_ch_width == CH_WIDTH_80MHZ) &&
1934 csa_params->new_ch_freq_seg2) {
1935 new_ch_width_dfn = true;
1936 if (csa_params->new_ch_freq_seg2 >
1937 csa_params->new_ch_freq_seg1)
1938 center_freq_diff = csa_params->new_ch_freq_seg2 -
1939 csa_params->new_ch_freq_seg1;
1940 else
1941 center_freq_diff = csa_params->new_ch_freq_seg1 -
1942 csa_params->new_ch_freq_seg2;
1943 if (center_freq_diff == CENTER_FREQ_DIFF_160MHz)
1944 ap_new_ch_width = CH_WIDTH_160MHZ;
1945 else if (center_freq_diff > CENTER_FREQ_DIFF_80P80MHz)
1946 ap_new_ch_width = CH_WIDTH_80P80MHZ;
1947 else
1948 ap_new_ch_width = CH_WIDTH_80MHZ;
1949 }
1950 session_entry->gLimChannelSwitch.state =
1951 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1952 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
1953 !new_ch_width_dfn) {
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001954 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1955 CH_TO_CNTR_FREQ_DIFF_160MHz) {
1956 pe_err("CSA wide BW IE has invalid center freq");
1957 return QDF_STATUS_E_INVAL;
1958 }
1959
1960 if (ap_new_ch_width > fw_vht_ch_wd) {
1961 pe_info("New BW is not supported, setting BW to %d",
1962 fw_vht_ch_wd);
1963 ap_new_ch_width = fw_vht_ch_wd;
1964 }
1965 ch_params.ch_width = ap_new_ch_width ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001966 wlan_reg_set_channel_params(mac_ctx->pdev,
1967 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001968 ap_new_ch_width = ch_params.ch_width;
1969 csa_params->new_ch_freq_seg1 = ch_params.center_freq_seg0;
1970 csa_params->new_ch_freq_seg2 = ch_params.center_freq_seg1;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001971 } else if (!new_ch_width_dfn) {
1972 if (ap_new_ch_width > fw_vht_ch_wd) {
1973 pe_info("New BW is not supported, setting BW to %d",
1974 fw_vht_ch_wd);
1975 ap_new_ch_width = fw_vht_ch_wd;
1976 }
1977 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1978 CH_TO_CNTR_FREQ_DIFF_80MHz) {
1979 pe_err("CSA wide BW IE has invalid center freq");
1980 return QDF_STATUS_E_INVAL;
1981 }
1982 csa_params->new_ch_freq_seg2 = 0;
1983 }
1984 if (new_ch_width_dfn) {
1985 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1986 CH_TO_CNTR_FREQ_DIFF_80MHz) {
1987 pe_err("CSA wide BW IE has invalid center freq");
1988 return QDF_STATUS_E_INVAL;
1989 }
1990 if (ap_new_ch_width > fw_vht_ch_wd) {
1991 pe_info("New width is not supported, setting BW to %d",
1992 fw_vht_ch_wd);
1993 ap_new_ch_width = fw_vht_ch_wd;
1994 }
1995 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
1996 (csa_params->new_ch_freq_seg1 !=
1997 csa_params->channel +
1998 CH_TO_CNTR_FREQ_DIFF_160MHz)) {
1999 pe_err("wide BW IE has invalid 160M center freq");
2000 csa_params->new_ch_freq_seg2 = 0;
2001 ap_new_ch_width = CH_WIDTH_80MHZ;
2002 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002003 }
2004 chnl_switch_info->newChanWidth = ap_new_ch_width;
2005 chnl_switch_info->newCenterChanFreq0 = csa_params->new_ch_freq_seg1;
2006 chnl_switch_info->newCenterChanFreq1 = csa_params->new_ch_freq_seg2;
2007
2008 if (session_entry->ch_width == ap_new_ch_width)
2009 goto prnt_log;
2010
2011 if (session_entry->ch_width == CH_WIDTH_80MHZ) {
2012 chnl_switch_info->newChanWidth = CH_WIDTH_80MHZ;
2013 chnl_switch_info->newCenterChanFreq1 = 0;
2014 } else {
2015 session_entry->ch_width = ap_new_ch_width;
2016 chnl_switch_info->newChanWidth = ap_new_ch_width;
2017 }
2018prnt_log:
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302019 pe_debug("new channel: %d new_ch_width: %d seg0: %d seg1: %d",
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002020 csa_params->channel,
2021 chnl_switch_info->newChanWidth,
2022 chnl_switch_info->newCenterChanFreq0,
2023 chnl_switch_info->newCenterChanFreq1);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08002024
2025 return QDF_STATUS_SUCCESS;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002026}
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08002027
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002028/**
2029 * lim_handle_csa_offload_msg() - Handle CSA offload message
2030 * @mac_ctx: pointer to global adapter context
2031 * @msg: Message pointer.
2032 *
2033 * Return: None
2034 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08002035void lim_handle_csa_offload_msg(tpAniSirGlobal mac_ctx,
2036 struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002037{
2038 tpPESession session_entry;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002039 struct scheduler_msg mmh_msg = {0};
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302040 struct csa_offload_params *csa_params =
2041 (struct csa_offload_params *) (msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002042 tpSmeCsaOffloadInd csa_offload_ind;
2043 tpDphHashNode sta_ds = NULL;
2044 uint8_t session_id;
2045 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302046 uint16_t chan_space = 0;
Amar Singhal5cccafe2017-02-15 12:42:58 -08002047 struct ch_params ch_params;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302048
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002049 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002050 tLimChannelSwitchInfo *lim_ch_switch = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002051
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302052 pe_debug("handle csa offload msg");
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302053
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002054 if (!csa_params) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302055 pe_err("limMsgQ body ptr is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002056 return;
2057 }
2058
2059 session_entry =
2060 pe_find_session_by_bssid(mac_ctx,
2061 csa_params->bssId, &session_id);
2062 if (!session_entry) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302063 pe_err("Session does not exists for %pM",
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302064 csa_params->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002065 goto err;
2066 }
2067
2068 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
2069 &session_entry->dph.dphHashTable);
2070
2071 if (!sta_ds) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302072 pe_err("sta_ds does not exist");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002073 goto err;
2074 }
2075
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002076 if (!LIM_IS_STA_ROLE(session_entry)) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302077 pe_debug("Invalid role to handle CSA");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002078 goto err;
2079 }
Masti, Narayanraddi1c630442015-11-02 12:03:50 +05302080
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002081 /*
2082 * on receiving channel switch announcement from AP, delete all
2083 * TDLS peers before leaving BSS and proceed for channel switch
2084 */
2085 lim_delete_tdls_peers(mac_ctx, session_entry);
Gupta, Kapil121bf212015-11-25 19:21:29 +05302086
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002087 lim_ch_switch = &session_entry->gLimChannelSwitch;
2088 session_entry->gLimChannelSwitch.switchMode =
2089 csa_params->switch_mode;
2090 /* timer already started by firmware, switch immediately */
2091 session_entry->gLimChannelSwitch.switchCount = 0;
2092 session_entry->gLimChannelSwitch.primaryChannel =
2093 csa_params->channel;
2094 session_entry->gLimChannelSwitch.state =
2095 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2096 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
2097 lim_ch_switch->sec_ch_offset =
2098 session_entry->htSecondaryChannelOffset;
2099 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
2100 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
2101 chnl_switch_info =
2102 &session_entry->gLimWiderBWChannelSwitch;
2103
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08002104 pe_info("vht: %d ht: %d flag: %x chan: %d, sec_ch_offset %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302105 session_entry->vhtCapability,
2106 session_entry->htSupportedChannelWidthSet,
2107 csa_params->ies_present_flag,
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08002108 csa_params->channel,
2109 csa_params->sec_chan_offset);
2110 pe_info("seg1: %d seg2: %d width: %d country: %s class: %d",
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002111 csa_params->new_ch_freq_seg1,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302112 csa_params->new_ch_freq_seg2,
2113 csa_params->new_ch_width,
2114 mac_ctx->scan.countryCodeCurrent,
2115 csa_params->new_op_class);
2116
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002117 if (session_entry->vhtCapability &&
2118 session_entry->htSupportedChannelWidthSet) {
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08002119 if ((csa_params->ies_present_flag & lim_wbw_ie_present) &&
2120 (QDF_STATUS_SUCCESS == lim_process_csa_wbw_ie(mac_ctx,
2121 csa_params, chnl_switch_info,
2122 session_entry))) {
2123 pe_debug("CSA wide BW IE process successful");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002124 lim_ch_switch->sec_ch_offset =
Abhishek Singhaf639b42017-06-16 14:14:36 +05302125 PHY_SINGLE_CHANNEL_CENTERED;
2126 if (chnl_switch_info->newChanWidth) {
2127 if (csa_params->channel <
2128 csa_params->new_ch_freq_seg1)
2129 lim_ch_switch->sec_ch_offset =
2130 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
2131 else
2132 lim_ch_switch->sec_ch_offset =
2133 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
2134 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002135 } else if (csa_params->ies_present_flag
2136 & lim_xcsa_ie_present) {
2137 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002138 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002139 mac_ctx->scan.countryCodeCurrent,
2140 csa_params->channel,
2141 csa_params->new_op_class);
2142 session_entry->gLimChannelSwitch.state =
2143 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2144
2145 if (chan_space == 80) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002146 chnl_switch_info->newChanWidth =
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002147 CH_WIDTH_80MHZ;
2148 } else if (chan_space == 40) {
2149 chnl_switch_info->newChanWidth =
2150 CH_WIDTH_40MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002151 } else {
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002152 chnl_switch_info->newChanWidth =
2153 CH_WIDTH_20MHZ;
2154 lim_ch_switch->state =
2155 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2156 }
2157
2158 ch_params.ch_width =
2159 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002160 wlan_reg_set_channel_params(mac_ctx->pdev,
2161 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002162 chnl_switch_info->newCenterChanFreq0 =
2163 ch_params.center_freq_seg0;
2164 /*
2165 * This is not applicable for 20/40/80 MHz.
2166 * Only used when we support 80+80 MHz operation.
2167 * In case of 80+80 MHz, this parameter indicates
2168 * center channel frequency index of 80 MHz
2169 * channel offrequency segment 1.
2170 */
2171 chnl_switch_info->newCenterChanFreq1 =
2172 ch_params.center_freq_seg1;
2173 lim_ch_switch->sec_ch_offset =
2174 ch_params.sec_ch_offset;
2175
Kiran Kumar Lokere47127482017-12-20 18:09:55 -08002176 } else {
2177 lim_ch_switch->state =
2178 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2179 ch_params.ch_width = CH_WIDTH_40MHZ;
2180 wlan_reg_set_channel_params(mac_ctx->pdev,
2181 csa_params->channel, 0, &ch_params);
2182 lim_ch_switch->sec_ch_offset =
2183 ch_params.sec_ch_offset;
2184 chnl_switch_info->newChanWidth = CH_WIDTH_40MHZ;
2185 chnl_switch_info->newCenterChanFreq0 =
2186 ch_params.center_freq_seg0;
2187 chnl_switch_info->newCenterChanFreq1 = 0;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002188 }
2189 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
2190 chnl_switch_info->newCenterChanFreq0;
2191 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
2192 chnl_switch_info->newCenterChanFreq1;
2193 session_entry->gLimChannelSwitch.ch_width =
2194 chnl_switch_info->newChanWidth;
2195
2196 } else if (session_entry->htSupportedChannelWidthSet) {
2197 if (csa_params->ies_present_flag
2198 & lim_xcsa_ie_present) {
2199 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002200 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002201 mac_ctx->scan.countryCodeCurrent,
2202 csa_params->channel,
2203 csa_params->new_op_class);
2204 lim_ch_switch->state =
2205 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2206 if (chan_space == 40) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002207 lim_ch_switch->ch_width =
2208 CH_WIDTH_40MHZ;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002209 chnl_switch_info->newChanWidth =
2210 CH_WIDTH_40MHZ;
2211 ch_params.ch_width =
2212 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002213 wlan_reg_set_channel_params(mac_ctx->pdev,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002214 csa_params->channel,
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07002215 0, &ch_params);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002216 lim_ch_switch->ch_center_freq_seg0 =
2217 ch_params.center_freq_seg0;
2218 lim_ch_switch->sec_ch_offset =
2219 ch_params.sec_ch_offset;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002220 } else {
2221 lim_ch_switch->ch_width =
2222 CH_WIDTH_20MHZ;
2223 chnl_switch_info->newChanWidth =
2224 CH_WIDTH_40MHZ;
2225 lim_ch_switch->state =
2226 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2227 lim_ch_switch->sec_ch_offset =
2228 PHY_SINGLE_CHANNEL_CENTERED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002229 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002230 } else {
2231 lim_ch_switch->ch_width =
2232 CH_WIDTH_40MHZ;
2233 lim_ch_switch->state =
2234 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2235 ch_params.ch_width = CH_WIDTH_40MHZ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002236 wlan_reg_set_channel_params(mac_ctx->pdev,
2237 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002238 lim_ch_switch->ch_center_freq_seg0 =
2239 ch_params.center_freq_seg0;
2240 lim_ch_switch->sec_ch_offset =
2241 ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002242 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002243
2244 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302245 pe_debug("new ch width: %d space: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302246 session_entry->gLimChannelSwitch.ch_width, chan_space);
Kiran Kumar Lokere75d636f2016-12-20 14:52:03 -08002247 if ((session_entry->currentOperChannel == csa_params->channel) &&
2248 (session_entry->ch_width ==
2249 session_entry->gLimChannelSwitch.ch_width)) {
2250 pe_debug("Ignore CSA, no change in ch and bw");
2251 goto err;
2252 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002253
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002254 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
2255 csa_offload_ind = qdf_mem_malloc(sizeof(tSmeCsaOffloadInd));
2256 if (NULL == csa_offload_ind) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302257 pe_err("memalloc fail eWNI_SME_CSA_OFFLOAD_EVENT");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002258 goto err;
2259 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002260
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002261 csa_offload_ind->mesgType = eWNI_SME_CSA_OFFLOAD_EVENT;
2262 csa_offload_ind->mesgLen = sizeof(tSmeCsaOffloadInd);
2263 qdf_mem_copy(csa_offload_ind->bssid.bytes, session_entry->bssId,
2264 QDF_MAC_ADDR_SIZE);
2265 mmh_msg.type = eWNI_SME_CSA_OFFLOAD_EVENT;
2266 mmh_msg.bodyptr = csa_offload_ind;
2267 mmh_msg.bodyval = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302268 pe_debug("Sending eWNI_SME_CSA_OFFLOAD_EVENT to SME");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002269 MTRACE(mac_trace_msg_tx
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002270 (mac_ctx, session_entry->peSessionId, mmh_msg.type));
2271#ifdef FEATURE_WLAN_DIAG_SUPPORT
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002272 lim_diag_event_report(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002273 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
2274 eSIR_SUCCESS, eSIR_SUCCESS);
2275#endif
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002276 lim_sys_process_mmh_msg_api(mac_ctx, &mmh_msg, ePROT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002277
2278err:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302279 qdf_mem_free(csa_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002280}
2281
2282/*--------------------------------------------------------------------------
2283 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
2284
2285 \param pMac - pointer to global adapter context
2286 \param sessionId - Message pointer.
2287
2288 \sa
2289 --------------------------------------------------------------------------*/
2290
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002291void lim_handle_delete_bss_rsp(tpAniSirGlobal pMac, struct scheduler_msg *MsgQ)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002292{
2293 tpPESession psessionEntry;
2294 tpDeleteBssParams pDelBss = (tpDeleteBssParams) (MsgQ->bodyptr);
2295
2296 psessionEntry =
2297 pe_find_session_by_session_id(pMac, pDelBss->sessionId);
2298 if (psessionEntry == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302299 pe_err("Session Does not exist for given sessionID: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002300 pDelBss->sessionId);
Naveen Rawat0c81edc2016-06-08 10:08:30 -07002301 qdf_mem_free(MsgQ->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002302 return;
2303 }
Krunal Sonie50ff452017-10-11 18:23:55 -07002304
2305 /*
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002306 * During DEL BSS handling, the PE Session will be deleted, but it is
2307 * better to clear this flag if the session is hanging around due
2308 * to some error conditions so that the next DEL_BSS request does
2309 * not take the HO_FAIL path
2310 */
2311 psessionEntry->process_ho_fail = false;
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002312 if (LIM_IS_IBSS_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002313 lim_ibss_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002314 else if (LIM_IS_UNKNOWN_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002315 lim_process_sme_del_bss_rsp(pMac, MsgQ->bodyval, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002316 else if (LIM_IS_NDI_ROLE(psessionEntry))
2317 lim_ndi_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002318 else
2319 lim_process_mlm_del_bss_rsp(pMac, MsgQ, psessionEntry);
2320
2321}
2322
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002323/** -----------------------------------------------------------------
2324 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
2325 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
2326 \ SME only looks at rc and tspec field.
2327 \param pMac - global mac structure
2328 \param rspReqd - is SmeAddTsRsp required
2329 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
2330 \return tspec
2331 \sa
2332 ----------------------------------------------------------------- */
2333void
2334lim_send_sme_aggr_qos_rsp(tpAniSirGlobal pMac, tpSirAggrQosRsp aggrQosRsp,
2335 uint8_t smesessionId)
2336{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002337 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002338
2339 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
2340 mmhMsg.bodyptr = aggrQosRsp;
2341 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302342 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2343 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002344 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2345
2346 return;
2347}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002348
2349void lim_send_sme_max_assoc_exceeded_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
2350 uint8_t smesessionId)
2351{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002352 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002353 tSmeMaxAssocInd *pSmeMaxAssocInd;
2354
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302355 pSmeMaxAssocInd = qdf_mem_malloc(sizeof(tSmeMaxAssocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002356 if (NULL == pSmeMaxAssocInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302357 pe_err("Failed to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002358 return;
2359 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302360 qdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peer_mac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302361 (uint8_t *) peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002362 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
2363 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
2364 pSmeMaxAssocInd->sessionId = smesessionId;
2365 mmhMsg.type = pSmeMaxAssocInd->mesgType;
2366 mmhMsg.bodyptr = pSmeMaxAssocInd;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302367 pe_debug("msgType: %s peerMacAddr "MAC_ADDRESS_STR "sme session id %d",
2368 "eWNI_SME_MAX_ASSOC_EXCEEDED", MAC_ADDR_ARRAY(peerMacAddr),
2369 pSmeMaxAssocInd->sessionId);
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302370 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2371 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002372 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2373
2374 return;
2375}
2376
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002377/*--------------------------------------------------------------------------
2378 \brief lim_send_dfs_chan_sw_ie_update()
2379 This timer handler updates the channel switch IE in beacon template
2380
2381 \param pMac - pointer to global adapter context
2382 \return - channel to scan from valid session else zero.
2383 \sa
2384 --------------------------------------------------------------------------*/
2385static void
2386lim_send_dfs_chan_sw_ie_update(tpAniSirGlobal pMac, tpPESession psessionEntry)
2387{
2388
2389 /* Update the beacon template and send to FW */
2390 if (sch_set_fixed_beacon_fields(pMac, psessionEntry) != eSIR_SUCCESS) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302391 pe_err("Unable to set CSA IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002392 return;
2393 }
2394
2395 /* Send update beacon template message */
2396 lim_send_beacon_ind(pMac, psessionEntry);
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302397 pe_debug("Updated CSA IE, IE COUNT: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002398 psessionEntry->gLimChannelSwitch.switchCount);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002399
2400 return;
2401}
2402
2403/** -----------------------------------------------------------------
2404 \brief lim_send_sme_ap_channel_switch_resp() - sends
2405 eWNI_SME_CHANNEL_CHANGE_RSP
2406 After receiving WMA_SWITCH_CHANNEL_RSP indication this
2407 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
2408 that the Channel change has been done to the specified target
2409 channel in the Channel change request
2410 \param pMac - global mac structure
2411 \param psessionEntry - session info
2412 \param pChnlParams - Channel switch params
2413 --------------------------------------------------------------------*/
2414void
2415lim_send_sme_ap_channel_switch_resp(tpAniSirGlobal pMac,
2416 tpPESession psessionEntry,
2417 tpSwitchChannelParams pChnlParams)
2418{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002419 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002420 tpSwitchChannelParams pSmeSwithChnlParams;
2421 uint8_t channelId;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002422 bool is_ch_dfs = false;
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08002423 enum phy_ch_width ch_width;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002424 uint8_t ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002425
2426 pSmeSwithChnlParams = (tSwitchChannelParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302427 qdf_mem_malloc(sizeof(tSwitchChannelParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002428 if (NULL == pSmeSwithChnlParams) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302429 pe_err("AllocateMemory failed for pSmeSwithChnlParams");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002430 return;
2431 }
2432
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302433 qdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002434 sizeof(tSwitchChannelParams));
2435
2436 channelId = pSmeSwithChnlParams->channelNumber;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002437 ch_width = pSmeSwithChnlParams->ch_width;
2438 ch_center_freq_seg1 = pSmeSwithChnlParams->ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002439
2440 /*
2441 * Pass the sme sessionID to SME instead
2442 * PE session ID.
2443 */
2444 pSmeSwithChnlParams->peSessionId = psessionEntry->smeSessionId;
2445
2446 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
2447 mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
2448 mmhMsg.bodyval = 0;
2449 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2450
2451 /*
2452 * We should start beacon transmission only if the new
2453 * channel after channel change is Non-DFS. For a DFS
2454 * channel, PE will receive an explicit request from
2455 * upper layers to start the beacon transmission .
2456 */
2457
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002458 if (ch_width == CH_WIDTH_160MHZ) {
2459 is_ch_dfs = true;
2460 } else if (ch_width == CH_WIDTH_80P80MHZ) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002461 if (wlan_reg_get_channel_state(pMac->pdev, channelId) ==
2462 CHANNEL_STATE_DFS ||
2463 wlan_reg_get_channel_state(pMac->pdev,
2464 ch_center_freq_seg1 -
2465 SIR_80MHZ_START_CENTER_CH_DIFF) ==
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002466 CHANNEL_STATE_DFS)
2467 is_ch_dfs = true;
2468 } else {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002469 if (wlan_reg_get_channel_state(pMac->pdev, channelId) ==
2470 CHANNEL_STATE_DFS)
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002471 is_ch_dfs = true;
2472 }
2473
2474 if (!is_ch_dfs) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002475 if (channelId == psessionEntry->currentOperChannel) {
2476 lim_apply_configuration(pMac, psessionEntry);
2477 lim_send_beacon_ind(pMac, psessionEntry);
2478 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302479 pe_debug("Failed to Transmit Beacons on channel: %d after AP channel change response",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002480 psessionEntry->bcnLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002481 }
Arif Hussain1513cb22018-01-05 19:56:31 -08002482
2483 lim_obss_send_detection_cfg(pMac, psessionEntry, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002484 }
2485 return;
2486}
2487
Peng Xu6363ec62017-05-15 11:06:33 -07002488#ifdef WLAN_FEATURE_11AX_BSS_COLOR
2489/**
2490 * lim_send_bss_color_change_ie_update() - update bss color change IE in
2491 * beacon template
2492 *
2493 * @mac_ctx: pointer to global adapter context
2494 * @session: session pointer
2495 *
2496 * Return: none
2497 */
2498static void
2499lim_send_bss_color_change_ie_update(tpAniSirGlobal mac_ctx,
2500 tpPESession session)
2501{
2502 /* Update the beacon template and send to FW */
2503 if (sch_set_fixed_beacon_fields(mac_ctx, session) != eSIR_SUCCESS) {
2504 pe_err("Unable to set BSS color change IE in beacon");
2505 return;
2506 }
2507
2508 /* Send update beacon template message */
2509 lim_send_beacon_ind(mac_ctx, session);
2510 pe_info("Updated BSS color change countdown = %d",
2511 session->he_bss_color_change.countdown);
2512}
2513
2514static void
2515lim_handle_bss_color_change_ie(tpAniSirGlobal mac_ctx,
2516 tpPESession session)
2517{
Arif Hussain2f2d3512018-03-06 12:37:03 -08002518 tUpdateBeaconParams beacon_params;
2519
Peng Xu6363ec62017-05-15 11:06:33 -07002520 /* handle bss color change IE */
2521 if (LIM_IS_AP_ROLE(session) &&
2522 session->he_op.bss_col_disabled) {
2523 if (session->he_bss_color_change.countdown > 0) {
2524 session->he_bss_color_change.countdown--;
2525 } else {
2526 session->bss_color_changing = 0;
Arif Hussain2f2d3512018-03-06 12:37:03 -08002527 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
Arif Hussain05fb4872018-01-03 16:02:55 -08002528 if (session->he_bss_color_change.new_color != 0) {
Peng Xu6363ec62017-05-15 11:06:33 -07002529 session->he_op.bss_col_disabled = 0;
Arif Hussain05fb4872018-01-03 16:02:55 -08002530 session->he_op.bss_color =
2531 session->he_bss_color_change.new_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08002532 beacon_params.paramChangeBitmap |=
2533 PARAM_BSS_COLOR_CHANGED;
2534 beacon_params.bss_color_disabled = 0;
2535 beacon_params.bss_color =
2536 session->he_op.bss_color;
2537 lim_send_beacon_params(mac_ctx,
2538 &beacon_params,
2539 session);
Arif Hussain05fb4872018-01-03 16:02:55 -08002540 lim_send_obss_color_collision_cfg(mac_ctx,
2541 session,
2542 OBSS_COLOR_COLLISION_DETECTION);
2543 }
Peng Xu6363ec62017-05-15 11:06:33 -07002544 }
2545
2546 lim_send_bss_color_change_ie_update(mac_ctx, session);
2547 }
2548}
2549
2550#else
2551static void
2552lim_handle_bss_color_change_ie(tpAniSirGlobal mac_ctx,
2553 tpPESession session)
2554{
2555}
2556#endif
2557
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002558/** -----------------------------------------------------------------
2559 \brief lim_process_beacon_tx_success_ind() - This function is used
2560 explicitely to handle successful beacon transmission indication
2561 from the FW. This is a generic event generated by the FW afer the
2562 first beacon is sent out after the beacon template update by the
2563 host
2564 \param pMac - global mac structure
2565 \param psessionEntry - session info
2566 \return none
2567 \sa
2568 ----------------------------------------------------------------- */
2569void
2570lim_process_beacon_tx_success_ind(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2571{
2572 /* Currently, this event is used only for DFS channel switch announcement
2573 * IE update in the template. If required to be used for other IE updates
2574 * add appropriate code by introducing a state variable
2575 */
2576 tpPESession psessionEntry;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002577 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002578 tSirSmeCSAIeTxCompleteRsp *pChanSwTxResponse;
2579 struct sir_beacon_tx_complete_rsp *beacon_tx_comp_rsp_ptr;
2580 uint8_t length = sizeof(tSirSmeCSAIeTxCompleteRsp);
2581 tpSirFirstBeaconTxCompleteInd pBcnTxInd =
2582 (tSirFirstBeaconTxCompleteInd *) event;
lifeng1c16b6b2017-09-25 13:59:55 +08002583 uint8_t ch, ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002584
2585 psessionEntry = pe_find_session_by_bss_idx(pMac, pBcnTxInd->bssIdx);
2586 if (psessionEntry == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302587 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002588 return;
2589 }
2590
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302591 pe_debug("role: %d swIe: %d opIe: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302592 GET_LIM_SYSTEM_ROLE(psessionEntry),
2593 psessionEntry->dfsIncludeChanSwIe,
2594 psessionEntry->gLimOperatingMode.present);
2595
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002596 if (LIM_IS_AP_ROLE(psessionEntry) &&
2597 true == psessionEntry->dfsIncludeChanSwIe) {
Ganesh Kondabattini02ec62b2018-01-24 18:22:24 +05302598
2599 if (psessionEntry->gLimChannelSwitch.switchCount) {
2600 /* Decrement the beacon switch count */
2601 psessionEntry->gLimChannelSwitch.switchCount--;
2602 pe_debug("current beacon count %d",
2603 psessionEntry->gLimChannelSwitch.switchCount);
2604 }
2605
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002606 /* Send only 5 beacons with CSA IE Set in when a radar is detected */
2607 if (psessionEntry->gLimChannelSwitch.switchCount > 0) {
2608 /*
2609 * Send the next beacon with updated CSA IE count
2610 */
2611 lim_send_dfs_chan_sw_ie_update(pMac, psessionEntry);
lifeng1c16b6b2017-09-25 13:59:55 +08002612
2613 ch = psessionEntry->gLimChannelSwitch.primaryChannel;
2614 ch_width = psessionEntry->gLimChannelSwitch.ch_width;
2615 if (pMac->sap.SapDfsInfo.dfs_beacon_tx_enhanced)
2616 /* Send Action frame after updating beacon */
2617 lim_send_chan_switch_action_frame(pMac,
2618 ch, ch_width, psessionEntry);
2619
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002620 } else {
2621 /* Done with CSA IE update, send response back to SME */
2622 psessionEntry->gLimChannelSwitch.switchCount = 0;
2623 if (pMac->sap.SapDfsInfo.disable_dfs_ch_switch == false)
2624 psessionEntry->gLimChannelSwitch.switchMode = 0;
2625 psessionEntry->dfsIncludeChanSwIe = false;
2626 psessionEntry->dfsIncludeChanWrapperIe = false;
2627
2628 pChanSwTxResponse = (tSirSmeCSAIeTxCompleteRsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302629 qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002630
2631 if (NULL == pChanSwTxResponse) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302632 pe_err("AllocateMemory failed for tSirSmeCSAIeTxCompleteRsp");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002633 return;
2634 }
2635
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002636 pChanSwTxResponse->sessionId =
2637 psessionEntry->smeSessionId;
2638 pChanSwTxResponse->chanSwIeTxStatus =
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302639 QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002640
2641 mmhMsg.type = eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND;
2642 mmhMsg.bodyptr = pChanSwTxResponse;
2643 mmhMsg.bodyval = 0;
2644 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2645 }
2646 }
2647
2648 if (LIM_IS_AP_ROLE(psessionEntry) &&
2649 psessionEntry->gLimOperatingMode.present) {
2650 /* Done with nss update, send response back to SME */
2651 psessionEntry->gLimOperatingMode.present = 0;
2652 beacon_tx_comp_rsp_ptr = (struct sir_beacon_tx_complete_rsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302653 qdf_mem_malloc(sizeof(*beacon_tx_comp_rsp_ptr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002654 if (NULL == beacon_tx_comp_rsp_ptr) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302655 pe_err("AllocateMemory failed for beacon_tx_comp_rsp_ptr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002656 return;
2657 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002658 beacon_tx_comp_rsp_ptr->session_id =
2659 psessionEntry->smeSessionId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302660 beacon_tx_comp_rsp_ptr->tx_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002661 mmhMsg.type = eWNI_SME_NSS_UPDATE_RSP;
2662 mmhMsg.bodyptr = beacon_tx_comp_rsp_ptr;
2663 mmhMsg.bodyval = 0;
2664 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2665 }
Peng Xu6363ec62017-05-15 11:06:33 -07002666
2667 lim_handle_bss_color_change_ie(pMac, psessionEntry);
2668
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002669 return;
2670}