blob: f8702b72c7f77e35deb0a35b51576f9dcb8b2a61 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Wu Gao6768d762018-12-28 16:31:08 +08002 * Copyright (c) 2012-2019 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
19/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020 * This file lim_send_sme_rspMessages.cc contains the functions
21 * for sending SME response/notification messages to applications
22 * above MAC software.
23 * Author: Chandra Modumudi
24 * Date: 02/13/02
25 * History:-
26 * Date Modified by Modification Information
27 * --------------------------------------------------------------------
28 */
29
Anurag Chouhan6d760662016-02-20 16:05:43 +053030#include "qdf_types.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080031#include "wni_api.h"
32#include "sir_common.h"
33#include "ani_global.h"
34
35#include "wni_cfg.h"
36#include "sys_def.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080037
38#include "sch_api.h"
39#include "utils_api.h"
40#include "lim_utils.h"
41#include "lim_security_utils.h"
42#include "lim_ser_des_utils.h"
43#include "lim_send_sme_rsp_messages.h"
44#include "lim_ibss_peer_mgmt.h"
45#include "lim_session_utils.h"
46#include "lim_types.h"
47#include "sir_api.h"
Naveen Rawat3b6068c2016-04-14 19:01:06 -070048#include "cds_regdomain.h"
Gupta, Kapil121bf212015-11-25 19:21:29 +053049#include "lim_send_messages.h"
Deepak Dhamdhere13983f22016-05-31 19:06:09 -070050#include "nan_datapath.h"
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -070051#include "lim_assoc_utils.h"
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070052#include "wlan_reg_services_api.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070053#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080054
Kabilan Kannanf56f9d52017-04-05 03:31:34 -070055#include "wlan_tdls_tgt_api.h"
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +053056#include "lim_process_fils.h"
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -080057#include "wma.h"
Kabilan Kannanf56f9d52017-04-05 03:31:34 -070058
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080059/**
60 * lim_send_sme_rsp() - Send Response to upper layers
61 * @mac_ctx: Pointer to Global MAC structure
62 * @msg_type: Indicates message type
63 * @result_code: Indicates the result of previously issued
64 * eWNI_SME_msg_type_REQ message
65 *
66 * This function is called by lim_process_sme_req_messages() to send
67 * eWNI_SME_START_RSP, eWNI_SME_STOP_BSS_RSP
68 * or eWNI_SME_SWITCH_CHL_RSP messages to applications above MAC
69 * Software.
70 *
71 * Return: None
72 */
73
74void
Jeff Johnson9320c1e2018-12-02 13:09:20 -080075lim_send_sme_rsp(struct mac_context *mac_ctx, uint16_t msg_type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080076 tSirResultCodes result_code, uint8_t sme_session_id,
77 uint16_t sme_transaction_id)
78{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070079 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080080 tSirSmeRsp *sme_rsp;
81
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +053082 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080083 lim_msg_str(msg_type), lim_result_code_str(result_code));
84
Anurag Chouhan600c3a02016-03-01 10:33:54 +053085 sme_rsp = qdf_mem_malloc(sizeof(tSirSmeRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -070086 if (!sme_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080087 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080088
89 sme_rsp->messageType = msg_type;
90 sme_rsp->length = sizeof(tSirSmeRsp);
91 sme_rsp->statusCode = result_code;
92
93 sme_rsp->sessionId = sme_session_id;
94 sme_rsp->transactionId = sme_transaction_id;
95
96 msg.type = msg_type;
97 msg.bodyptr = sme_rsp;
98 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +053099 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG,
100 sme_session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800101
102#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
103 switch (msg_type) {
104 case eWNI_SME_STOP_BSS_RSP:
105 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_STOP_BSS_RSP_EVENT,
106 NULL, (uint16_t) result_code, 0);
107 break;
108 }
109#endif /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsona5abe272019-01-06 12:52:02 -0800110 lim_sys_process_mmh_msg_api(mac_ctx, &msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800111}
112
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800113/**
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530114 * lim_get_max_rate_flags() - Get rate flags
115 * @mac_ctx: Pointer to global MAC structure
116 * @sta_ds: Pointer to station ds structure
117 *
118 * This function is called to get the rate flags for a connection
119 * from the station ds structure depending on the ht and the vht
120 * channel width supported.
121 *
122 * Return: Returns the populated rate_flags
123 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800124uint32_t lim_get_max_rate_flags(struct mac_context *mac_ctx, tpDphHashNode sta_ds)
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530125{
126 uint32_t rate_flags = 0;
127
128 if (sta_ds == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530129 pe_err("sta_ds is NULL");
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530130 return rate_flags;
131 }
132
133 if (!sta_ds->mlmStaContext.htCapability &&
134 !sta_ds->mlmStaContext.vhtCapability) {
Naveen Rawatea1564b2018-05-17 15:56:11 -0700135 rate_flags |= TX_RATE_LEGACY;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530136 } else {
137 if (sta_ds->mlmStaContext.vhtCapability) {
138 if (WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ ==
139 sta_ds->vhtSupportedChannelWidthSet) {
Naveen Rawatea1564b2018-05-17 15:56:11 -0700140 rate_flags |= TX_RATE_VHT80;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530141 } else if (WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ ==
142 sta_ds->vhtSupportedChannelWidthSet) {
143 if (sta_ds->htSupportedChannelWidthSet)
Naveen Rawatea1564b2018-05-17 15:56:11 -0700144 rate_flags |= TX_RATE_VHT40;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530145 else
Naveen Rawatea1564b2018-05-17 15:56:11 -0700146 rate_flags |= TX_RATE_VHT20;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530147 }
148 } else if (sta_ds->mlmStaContext.htCapability) {
149 if (sta_ds->htSupportedChannelWidthSet)
Naveen Rawatea1564b2018-05-17 15:56:11 -0700150 rate_flags |= TX_RATE_HT40;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530151 else
Naveen Rawatea1564b2018-05-17 15:56:11 -0700152 rate_flags |= TX_RATE_HT20;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530153 }
154 }
155
156 if (sta_ds->htShortGI20Mhz || sta_ds->htShortGI40Mhz)
Naveen Rawatea1564b2018-05-17 15:56:11 -0700157 rate_flags |= TX_RATE_SGI;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530158
159 return rate_flags;
160}
161
162/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800163 * lim_send_sme_join_reassoc_rsp_after_resume() - Send Response to SME
Jeff Johnson2df04b82019-02-02 23:30:25 -0800164 * @mac_ctx: Pointer to Global MAC structure
165 * @status: Resume link status
166 * @sme_join_rsp: Join response to be sent
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800167 *
168 * This function is called to send Join/Reassoc rsp
169 * message to SME after the resume link.
170 *
171 * Return: None
172 */
Jeff Johnson2df04b82019-02-02 23:30:25 -0800173static void
174lim_send_sme_join_reassoc_rsp_after_resume(struct mac_context *mac_ctx,
175 QDF_STATUS status,
176 struct join_rsp *sme_join_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800177{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700178 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800179
180 msg.type = sme_join_rsp->messageType;
181 msg.bodyptr = sme_join_rsp;
182 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530183 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, NO_SESSION, msg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -0800184 lim_sys_process_mmh_msg_api(mac_ctx, &msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800185}
186
187/**
188 * lim_handle_join_rsp_status() - Handle the response.
189 * @mac_ctx: Pointer to Global MAC structure
190 * @session_entry: PE Session Info
191 * @result_code: Indicates the result of previously issued
192 * eWNI_SME_msgType_REQ message
193 * @sme_join_rsp The received response.
194 *
195 * This function will handle both the success and failure status
196 * of the received response.
197 *
198 * Return: None
199 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800200static void lim_handle_join_rsp_status(struct mac_context *mac_ctx,
Jeff Johnson2df04b82019-02-02 23:30:25 -0800201 struct pe_session *session_entry,
202 tSirResultCodes result_code,
203 struct join_rsp *sme_join_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800204{
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700205 uint16_t bss_ie_len;
206 void *bss_ies;
207 bool is_vendor_ap_1_present;
Jeff Johnson701444f2019-02-02 22:35:13 -0800208 struct join_req *join_reassoc_req = NULL;
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700209
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800210#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
Jeff Johnson704af112019-02-02 16:11:55 -0800211 struct ht_profile *ht_profile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800212#endif
213 if (result_code == eSIR_SME_SUCCESS) {
214 if (session_entry->beacon != NULL) {
215 sme_join_rsp->beaconLength = session_entry->bcnLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530216 qdf_mem_copy(sme_join_rsp->frames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800217 session_entry->beacon,
218 sme_join_rsp->beaconLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530219 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800220 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530221 session_entry->bcnLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530222 pe_debug("Beacon: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530223 sme_join_rsp->beaconLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800224 }
225 if (session_entry->assocReq != NULL) {
226 sme_join_rsp->assocReqLength =
227 session_entry->assocReqLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530228 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530229 sme_join_rsp->beaconLength,
230 session_entry->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800231 sme_join_rsp->assocReqLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530232 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800233 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530234 session_entry->assocReqLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530235 pe_debug("AssocReq: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530236 sme_join_rsp->assocReqLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800237 }
238 if (session_entry->assocRsp != NULL) {
239 sme_join_rsp->assocRspLength =
240 session_entry->assocRspLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530241 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530242 sme_join_rsp->beaconLength +
243 sme_join_rsp->assocReqLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800244 session_entry->assocRsp,
245 sme_join_rsp->assocRspLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530246 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800247 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530248 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800249 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800250 if (session_entry->ricData != NULL) {
251 sme_join_rsp->parsedRicRspLen =
252 session_entry->RICDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530253 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530254 sme_join_rsp->beaconLength +
255 sme_join_rsp->assocReqLength +
256 sme_join_rsp->assocRspLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800257 session_entry->ricData,
258 sme_join_rsp->parsedRicRspLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530259 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800260 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530261 session_entry->RICDataLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530262 pe_debug("RicLength: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800263 sme_join_rsp->parsedRicRspLen);
264 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800265#ifdef FEATURE_WLAN_ESE
266 if (session_entry->tspecIes != NULL) {
267 sme_join_rsp->tspecIeLen =
268 session_entry->tspecLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530269 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530270 sme_join_rsp->beaconLength +
271 sme_join_rsp->assocReqLength +
272 sme_join_rsp->assocRspLength +
273 sme_join_rsp->parsedRicRspLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800274 session_entry->tspecIes,
275 sme_join_rsp->tspecIeLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530276 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800277 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530278 session_entry->tspecLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530279 pe_debug("ESE-TspecLen: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530280 sme_join_rsp->tspecIeLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800281 }
282#endif
283 sme_join_rsp->aid = session_entry->limAID;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530284 pe_debug("AssocRsp: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530285 sme_join_rsp->assocRspLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800286 sme_join_rsp->vht_channel_width =
287 session_entry->ch_width;
288#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
289 if (session_entry->cc_switch_mode !=
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530290 QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Jeff Johnsonf6541882019-02-02 16:16:00 -0800291 ht_profile = &sme_join_rsp->ht_profile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800292 ht_profile->htSupportedChannelWidthSet =
293 session_entry->htSupportedChannelWidthSet;
294 ht_profile->htRecommendedTxWidthSet =
295 session_entry->htRecommendedTxWidthSet;
296 ht_profile->htSecondaryChannelOffset =
297 session_entry->htSecondaryChannelOffset;
298 ht_profile->dot11mode = session_entry->dot11mode;
299 ht_profile->htCapability = session_entry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800300 ht_profile->vhtCapability =
301 session_entry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800302 ht_profile->apCenterChan = session_entry->ch_center_freq_seg0;
303 ht_profile->apChanWidth = session_entry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800304 }
305#endif
Jeff Johnson11bd4f32017-09-18 08:15:17 -0700306 pe_debug("pLimJoinReq:%pK, pLimReAssocReq:%pK",
Wu Gao2968fc92017-06-19 19:18:34 +0800307 session_entry->pLimJoinReq,
308 session_entry->pLimReAssocReq);
309
310 if (session_entry->pLimJoinReq)
311 join_reassoc_req = session_entry->pLimJoinReq;
312
313 if (session_entry->pLimReAssocReq)
314 join_reassoc_req = session_entry->pLimReAssocReq;
315
316 if (!join_reassoc_req) {
317 pe_err("both pLimJoinReq and pLimReAssocReq NULL");
318 return;
319 }
320
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700321 bss_ie_len = lim_get_ielen_from_bss_description(
Wu Gao2968fc92017-06-19 19:18:34 +0800322 &join_reassoc_req->bssDescription);
323 bss_ies = &join_reassoc_req->bssDescription.ieFields;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700324 is_vendor_ap_1_present = (wlan_get_vendor_ie_ptr_from_oui(
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700325 SIR_MAC_VENDOR_AP_1_OUI, SIR_MAC_VENDOR_AP_1_OUI_LEN,
326 bss_ies, bss_ie_len) != NULL);
327
328 if (mac_ctx->roam.configParam.is_force_1x1 &&
Krunal Sonie6a1cda2017-09-27 15:23:02 -0700329 is_vendor_ap_1_present && (session_entry->nss == 2) &&
330 (mac_ctx->lteCoexAntShare == 0 ||
331 IS_5G_CH(session_entry->currentOperChannel))) {
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700332 /* SET vdev param */
333 pe_debug("sending SMPS intolrent vdev_param");
334 wma_cli_set_command(session_entry->smeSessionId,
335 (int)WMI_VDEV_PARAM_SMPS_INTOLERANT,
336 1, VDEV_CMD);
337
338 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800339 } else {
340 if (session_entry->beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530341 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800342 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530343 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800344 }
345 if (session_entry->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530346 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800347 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530348 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800349 }
350 if (session_entry->assocRsp != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530351 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800352 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530353 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800354 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800355 if (session_entry->ricData != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530356 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800357 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530358 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800359 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800360#ifdef FEATURE_WLAN_ESE
361 if (session_entry->tspecIes != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530362 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800363 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530364 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800365 }
366#endif
367 }
368}
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530369
370/**
371 * lim_add_bss_info() - copy data from session entry to join rsp
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530372 * @sta_ds: Station dph entry
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530373 * @sme_join_rsp: Join response buffer to be filled up
374 *
375 * Return: None
376 */
Jeff Johnson2df04b82019-02-02 23:30:25 -0800377static void lim_add_bss_info(tpDphHashNode sta_ds,
378 struct join_rsp *sme_join_rsp)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530379{
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530380 struct parsed_ies *parsed_ies = &sta_ds->parsed_ies;
381
382 if (parsed_ies->hs20vendor_ie.present)
383 sme_join_rsp->hs20vendor_ie = parsed_ies->hs20vendor_ie;
384 if (parsed_ies->vht_caps.present)
385 sme_join_rsp->vht_caps = parsed_ies->vht_caps;
386 if (parsed_ies->ht_caps.present)
387 sme_join_rsp->ht_caps = parsed_ies->ht_caps;
388 if (parsed_ies->ht_operation.present)
389 sme_join_rsp->ht_operation = parsed_ies->ht_operation;
390 if (parsed_ies->vht_operation.present)
391 sme_join_rsp->vht_operation = parsed_ies->vht_operation;
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530392}
393
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530394#ifdef WLAN_FEATURE_FILS_SK
Jeff Johnson2df04b82019-02-02 23:30:25 -0800395static void lim_update_fils_seq_num(struct join_rsp *sme_join_rsp,
Jeff Johnsond7035a32018-11-18 22:03:13 -0800396 struct pe_session *session_entry)
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530397{
398 sme_join_rsp->fils_seq_num =
399 session_entry->fils_info->sequence_number;
400}
401#else
Jeff Johnson2df04b82019-02-02 23:30:25 -0800402static inline void lim_update_fils_seq_num(struct join_rsp *sme_join_rsp,
Jeff Johnsond7035a32018-11-18 22:03:13 -0800403 struct pe_session *session_entry)
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530404{}
405#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800406/**
407 * lim_send_sme_join_reassoc_rsp() - Send Response to Upper Layers
408 * @mac_ctx: Pointer to Global MAC structure
409 * @msg_type: Indicates message type
410 * @result_code: Indicates the result of previously issued
411 * eWNI_SME_msgType_REQ message
412 * @prot_status_code: Protocol Status Code
413 * @session_entry: PE Session Info
414 * @sme_session_id: SME Session ID
415 * @sme_transaction_id: SME Transaction ID
416 *
417 * This function is called by lim_process_sme_req_messages() to send
418 * eWNI_SME_JOIN_RSP or eWNI_SME_REASSOC_RSP messages to applications
419 * above MAC Software.
420 *
421 * Return: None
422 */
423
424void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800425lim_send_sme_join_reassoc_rsp(struct mac_context *mac_ctx, uint16_t msg_type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800426 tSirResultCodes result_code, uint16_t prot_status_code,
Jeff Johnsond7035a32018-11-18 22:03:13 -0800427 struct pe_session *session_entry, uint8_t sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800428 uint16_t sme_transaction_id)
429{
Jeff Johnson2df04b82019-02-02 23:30:25 -0800430 struct join_rsp *sme_join_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800431 uint32_t rsp_len;
432 tpDphHashNode sta_ds = NULL;
433#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
434 if (msg_type == eWNI_SME_REASSOC_RSP)
435 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_RSP_EVENT,
436 session_entry, (uint16_t) result_code, 0);
437 else
438 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_RSP_EVENT,
439 session_entry, (uint16_t) result_code, 0);
440#endif /* FEATURE_WLAN_DIAG_SUPPORT */
441
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530442 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800443 lim_msg_str(msg_type), lim_result_code_str(result_code));
444
445 if (session_entry == NULL) {
Jeff Johnson2df04b82019-02-02 23:30:25 -0800446 rsp_len = sizeof(*sme_join_rsp);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530447 sme_join_rsp = qdf_mem_malloc(rsp_len);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700448 if (!sme_join_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800449 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800450
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800451 sme_join_rsp->beaconLength = 0;
452 sme_join_rsp->assocReqLength = 0;
453 sme_join_rsp->assocRspLength = 0;
454 } else {
455 rsp_len = session_entry->assocReqLen +
456 session_entry->assocRspLen + session_entry->bcnLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800457 session_entry->RICDataLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800458#ifdef FEATURE_WLAN_ESE
459 session_entry->tspecLen +
460#endif
Jeff Johnson2df04b82019-02-02 23:30:25 -0800461 sizeof(*sme_join_rsp) - sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530462 sme_join_rsp = qdf_mem_malloc(rsp_len);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700463 if (!sme_join_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800464 return;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530465
466 if (lim_is_fils_connection(session_entry)) {
467 sme_join_rsp->is_fils_connection = true;
468 lim_update_fils_seq_num(sme_join_rsp,
469 session_entry);
470 }
471
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800472 if (result_code == eSIR_SME_SUCCESS) {
473 sta_ds = dph_get_hash_entry(mac_ctx,
474 DPH_STA_HASH_INDEX_PEER,
475 &session_entry->dph.dphHashTable);
476 if (sta_ds == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530477 pe_err("Get Self Sta Entry fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800478 } else {
479 /* Pass the peer's staId */
480 sme_join_rsp->staId = sta_ds->staIndex;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800481 sme_join_rsp->timingMeasCap =
482 sta_ds->timingMeasCap;
483#ifdef FEATURE_WLAN_TDLS
484 sme_join_rsp->tdls_prohibited =
485 session_entry->tdls_prohibited;
486 sme_join_rsp->tdls_chan_swit_prohibited =
487 session_entry->tdls_chan_swit_prohibited;
488#endif
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530489 sme_join_rsp->nss = sta_ds->nss;
490 sme_join_rsp->max_rate_flags =
491 lim_get_max_rate_flags(mac_ctx, sta_ds);
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530492 lim_add_bss_info(sta_ds, sme_join_rsp);
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530493
494 /* Copy FILS params only for Successful join */
495 populate_fils_connect_params(mac_ctx,
496 session_entry, sme_join_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800497 }
498 }
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530499
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800500 sme_join_rsp->beaconLength = 0;
501 sme_join_rsp->assocReqLength = 0;
502 sme_join_rsp->assocRspLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800503 sme_join_rsp->parsedRicRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800504#ifdef FEATURE_WLAN_ESE
505 sme_join_rsp->tspecIeLen = 0;
506#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800507 lim_handle_join_rsp_status(mac_ctx, session_entry, result_code,
508 sme_join_rsp);
Bala Venkateshe7f79162019-01-16 16:43:59 +0530509 sme_join_rsp->uapsd_mask = session_entry->gUapsdPerAcBitmask;
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800510 /* Send supported NSS 1x1 to SME */
511 sme_join_rsp->supported_nss_1x1 =
512 session_entry->supported_nss_1x1;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530513 pe_debug("SME Join Rsp is supported NSS 1X1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800514 sme_join_rsp->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800515 }
516
517 sme_join_rsp->messageType = msg_type;
518 sme_join_rsp->length = (uint16_t) rsp_len;
519 sme_join_rsp->statusCode = result_code;
520 sme_join_rsp->protStatusCode = prot_status_code;
521
522 sme_join_rsp->sessionId = sme_session_id;
523 sme_join_rsp->transactionId = sme_transaction_id;
524
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530525 lim_send_sme_join_reassoc_rsp_after_resume(mac_ctx, QDF_STATUS_SUCCESS,
Jeff Johnson2df04b82019-02-02 23:30:25 -0800526 sme_join_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800527}
528
Jeff Johnson9e3d8992019-02-20 20:11:48 -0800529void lim_send_sme_start_bss_rsp(struct mac_context *mac,
530 uint16_t msgType,
531 tSirResultCodes resultCode,
532 struct pe_session *pe_session,
533 uint8_t smesessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800534{
535
536 uint16_t size = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700537 struct scheduler_msg mmhMsg = {0};
Jeff Johnsona0d34622019-02-02 17:26:19 -0800538 struct start_bss_rsp *pSirSmeRsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800539 uint16_t ieLen;
540 uint16_t ieOffset, curLen;
541
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530542 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800543 lim_msg_str(msgType), lim_result_code_str(resultCode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800544
Jeff Johnsona0d34622019-02-02 17:26:19 -0800545 size = sizeof(struct start_bss_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800546
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800547 if (pe_session == NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530548 pSirSmeRsp = qdf_mem_malloc(size);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700549 if (!pSirSmeRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800550 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800551 } else {
552 /* subtract size of beaconLength + Mac Hdr + Fixed Fields before SSID */
553 ieOffset = sizeof(tAniBeaconStruct) + SIR_MAC_B_PR_SSID_OFFSET;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800554 ieLen = pe_session->schBeaconOffsetBegin
555 + pe_session->schBeaconOffsetEnd - ieOffset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800556 /* calculate the memory size to allocate */
557 size += ieLen;
558
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530559 pSirSmeRsp = qdf_mem_malloc(size);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700560 if (!pSirSmeRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800561 return;
Jeff Johnsona0d34622019-02-02 17:26:19 -0800562 size = sizeof(struct start_bss_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800563 if (resultCode == eSIR_SME_SUCCESS) {
564
565 sir_copy_mac_addr(pSirSmeRsp->bssDescription.bssId,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800566 pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800567
568 /* Read beacon interval from session */
569 pSirSmeRsp->bssDescription.beaconInterval =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800570 (uint16_t) pe_session->beaconParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800571 beaconInterval;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800572 pSirSmeRsp->bssType = pe_session->bssType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800573
Wu Gao5c3d94b2019-01-17 21:15:54 +0800574 if (lim_get_capability_info
Jeff Johnson35c58a82018-11-22 15:04:57 -0800575 (mac, &pSirSmeRsp->bssDescription.capabilityInfo,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800576 pe_session)
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700577 != QDF_STATUS_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530578 pe_err("could not retrieve Capabilities value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800579
Jeff Johnson35c58a82018-11-22 15:04:57 -0800580 lim_get_phy_mode(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800581 (uint32_t *) &pSirSmeRsp->bssDescription.
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800582 nwType, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800583
584 pSirSmeRsp->bssDescription.channelId =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800585 pe_session->currentOperChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800586
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800587 if (!LIM_IS_NDI_ROLE(pe_session)) {
588 curLen = pe_session->schBeaconOffsetBegin - ieOffset;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530589 qdf_mem_copy((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800590 ieFields,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800591 pe_session->pSchBeaconFrameBegin +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800592 ieOffset, (uint32_t) curLen);
593
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530594 qdf_mem_copy(((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800595 ieFields) + curLen,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800596 pe_session->pSchBeaconFrameEnd,
597 (uint32_t) pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800598 schBeaconOffsetEnd);
599
Abhishek Singh34a4d862016-10-26 16:01:51 +0530600 pSirSmeRsp->bssDescription.length = (uint16_t)
601 (offsetof(tSirBssDescription, ieFields[0])
602 - sizeof(pSirSmeRsp->bssDescription.length)
603 + ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800604 /* This is the size of the message, subtracting the size of the pointer to ieFields */
605 size += ieLen - sizeof(uint32_t);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700606 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800607#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800608 if (pe_session->cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530609 != QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Jeff Johnsonf6541882019-02-02 16:16:00 -0800610 pSirSmeRsp->ht_profile.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800611 htSupportedChannelWidthSet =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800612 pe_session->htSupportedChannelWidthSet;
Jeff Johnsonf6541882019-02-02 16:16:00 -0800613 pSirSmeRsp->ht_profile.htRecommendedTxWidthSet =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800614 pe_session->htRecommendedTxWidthSet;
Jeff Johnsonf6541882019-02-02 16:16:00 -0800615 pSirSmeRsp->ht_profile.htSecondaryChannelOffset =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800616 pe_session->htSecondaryChannelOffset;
Jeff Johnsonf6541882019-02-02 16:16:00 -0800617 pSirSmeRsp->ht_profile.dot11mode =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800618 pe_session->dot11mode;
Jeff Johnsonf6541882019-02-02 16:16:00 -0800619 pSirSmeRsp->ht_profile.htCapability =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800620 pe_session->htCapability;
Jeff Johnsonf6541882019-02-02 16:16:00 -0800621 pSirSmeRsp->ht_profile.vhtCapability =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800622 pe_session->vhtCapability;
Jeff Johnsonf6541882019-02-02 16:16:00 -0800623 pSirSmeRsp->ht_profile.apCenterChan =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800624 pe_session->ch_center_freq_seg0;
Jeff Johnsonf6541882019-02-02 16:16:00 -0800625 pSirSmeRsp->ht_profile.apChanWidth =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800626 pe_session->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800627 }
628#endif
629 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800630 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800631 pSirSmeRsp->messageType = msgType;
632 pSirSmeRsp->length = size;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800633 pSirSmeRsp->sessionId = smesessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800634 pSirSmeRsp->statusCode = resultCode;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800635 if (pe_session != NULL)
636 pSirSmeRsp->staId = pe_session->staId; /* else it will be always zero smeRsp StaID = 0 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800637
638 mmhMsg.type = msgType;
639 mmhMsg.bodyptr = pSirSmeRsp;
640 mmhMsg.bodyval = 0;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800641 if (pe_session == NULL) {
Jeff Johnson35c58a82018-11-22 15:04:57 -0800642 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530643 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800644 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -0800645 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800646 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800647 }
648#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -0800649 lim_diag_event_report(mac, WLAN_PE_DIAG_START_BSS_RSP_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800650 pe_session, (uint16_t) resultCode, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800651#endif /* FEATURE_WLAN_DIAG_SUPPORT */
652
Jeff Johnsona5abe272019-01-06 12:52:02 -0800653 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800654} /*** end lim_send_sme_start_bss_rsp() ***/
655
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800656void lim_send_sme_disassoc_deauth_ntf(struct mac_context *mac,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530657 QDF_STATUS status, uint32_t *pCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800658{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700659 struct scheduler_msg mmhMsg = {0};
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800660 struct scheduler_msg *pMsg = (struct scheduler_msg *) pCtx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800661
662 mmhMsg.type = pMsg->type;
663 mmhMsg.bodyptr = pMsg;
664 mmhMsg.bodyval = 0;
665
Jeff Johnson35c58a82018-11-22 15:04:57 -0800666 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800667
Jeff Johnsona5abe272019-01-06 12:52:02 -0800668 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800669}
670
Jeff Johnsonb82e6d72019-02-20 21:32:32 -0800671void lim_send_sme_disassoc_ntf(struct mac_context *mac,
672 tSirMacAddr peerMacAddr,
673 tSirResultCodes reasonCode,
674 uint16_t disassocTrigger,
675 uint16_t aid,
676 uint8_t smesessionId,
677 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800678{
Jeff Johnson380a1cd2019-02-03 21:43:51 -0800679 struct disassoc_rsp *pSirSmeDisassocRsp;
Jeff Johnson318a9882019-02-04 08:30:50 -0800680 struct disassoc_ind *pSirSmeDisassocInd;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700681 uint32_t *pMsg = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800682 bool failure = false;
Jeff Johnsond7035a32018-11-18 22:03:13 -0800683 struct pe_session *session = NULL;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700684 uint16_t i, assoc_id;
685 tpDphHashNode sta_ds = NULL;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +0530686 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800687
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530688 pe_debug("Disassoc Ntf with trigger : %d reasonCode: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800689 disassocTrigger, reasonCode);
690
691 switch (disassocTrigger) {
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700692 case eLIM_DUPLICATE_ENTRY:
693 /*
694 * Duplicate entry is removed at LIM.
695 * Initiate new entry for other session
696 */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530697 pe_debug("Rcvd eLIM_DUPLICATE_ENTRY for " MAC_ADDRESS_STR,
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700698 MAC_ADDR_ARRAY(peerMacAddr));
699
Jeff Johnson35c58a82018-11-22 15:04:57 -0800700 for (i = 0; i < mac->lim.maxBssId; i++) {
701 if ((&mac->lim.gpSession[i] != NULL) &&
702 (mac->lim.gpSession[i].valid) &&
703 (mac->lim.gpSession[i].pePersona ==
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700704 QDF_SAP_MODE)) {
705 /* Find the sta ds entry in another session */
Jeff Johnson35c58a82018-11-22 15:04:57 -0800706 session = &mac->lim.gpSession[i];
707 sta_ds = dph_lookup_hash_entry(mac,
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700708 peerMacAddr, &assoc_id,
709 &session->dph.dphHashTable);
Abhishek Singh6d6e3d12017-12-04 14:16:00 +0530710 if (sta_ds)
711 break;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700712 }
713 }
714 if (sta_ds
715#ifdef WLAN_FEATURE_11W
716 && (!sta_ds->rmfEnabled)
717#endif
718 ) {
Jeff Johnson35c58a82018-11-22 15:04:57 -0800719 if (lim_add_sta(mac, sta_ds, false, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700720 QDF_STATUS_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530721 pe_err("could not Add STA with assocId: %d",
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700722 sta_ds->assocId);
723 }
Jeff Johnson35c58a82018-11-22 15:04:57 -0800724 status = lim_prepare_disconnect_done_ind(mac, &pMsg,
Pragaspathi Thilagaraj766c76f2018-08-08 16:44:40 +0530725 smesessionId,
726 reasonCode,
727 &peerMacAddr[0]);
728 if (!QDF_IS_STATUS_SUCCESS(status)) {
729 pe_err("Failed to prepare message");
730 return;
731 }
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700732 break;
733
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800734 case eLIM_HOST_DISASSOC:
735 /**
736 * Disassociation response due to
737 * host triggered disassociation
738 */
739
Jeff Johnson380a1cd2019-02-03 21:43:51 -0800740 pSirSmeDisassocRsp = qdf_mem_malloc(sizeof(struct disassoc_rsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700741 if (!pSirSmeDisassocRsp) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800742 failure = true;
743 goto error;
744 }
Jeff Johnsonff1fd432019-02-20 09:50:54 -0800745 pe_debug("send eWNI_SME_DISASSOC_RSP with retCode: %d for "
746 MAC_ADDRESS_STR,
747 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800748 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
Jeff Johnson380a1cd2019-02-03 21:43:51 -0800749 pSirSmeDisassocRsp->length = sizeof(struct disassoc_rsp);
Jeff Johnsonff1fd432019-02-20 09:50:54 -0800750 pSirSmeDisassocRsp->sessionId = smesessionId;
Jeff Johnsonff1fd432019-02-20 09:50:54 -0800751 pSirSmeDisassocRsp->statusCode = reasonCode;
752 qdf_mem_copy(pSirSmeDisassocRsp->peer_macaddr.bytes,
753 peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800754
755#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
756
Jeff Johnson35c58a82018-11-22 15:04:57 -0800757 lim_diag_event_report(mac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800758 pe_session, (uint16_t) reasonCode, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800759#endif
760 pMsg = (uint32_t *) pSirSmeDisassocRsp;
761 break;
762
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530763 case eLIM_PEER_ENTITY_DISASSOC:
764 case eLIM_LINK_MONITORING_DISASSOC:
Jeff Johnson35c58a82018-11-22 15:04:57 -0800765 status = lim_prepare_disconnect_done_ind(mac, &pMsg,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +0530766 smesessionId,
767 reasonCode, &peerMacAddr[0]);
768 if (!QDF_IS_STATUS_SUCCESS(status)) {
769 pe_err("Failed to prepare message");
770 return;
771 }
772 break;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530773
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800774 default:
775 /**
776 * Disassociation indication due to Disassociation
777 * frame reception from peer entity or due to
778 * loss of link with peer entity.
779 */
Jeff Johnson318a9882019-02-04 08:30:50 -0800780 pSirSmeDisassocInd =
781 qdf_mem_malloc(sizeof(*pSirSmeDisassocInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700782 if (!pSirSmeDisassocInd) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800783 failure = true;
784 goto error;
785 }
Jeff Johnsonff1fd432019-02-20 09:50:54 -0800786 pe_debug("send eWNI_SME_DISASSOC_IND with retCode: %d for "
787 MAC_ADDRESS_STR,
788 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800789 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
Jeff Johnson318a9882019-02-04 08:30:50 -0800790 pSirSmeDisassocInd->length = sizeof(*pSirSmeDisassocInd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800791 pSirSmeDisassocInd->sessionId = smesessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800792 pSirSmeDisassocInd->reasonCode = reasonCode;
Jeff Johnsonff1fd432019-02-20 09:50:54 -0800793 pSirSmeDisassocInd->statusCode = reasonCode;
794 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes,
795 pe_session->bssId, sizeof(tSirMacAddr));
796 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes,
797 peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800798
799#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -0800800 lim_diag_event_report(mac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800801 pe_session, (uint16_t) reasonCode, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800802#endif
803 pMsg = (uint32_t *) pSirSmeDisassocInd;
804
805 break;
806 }
807
808error:
809 /* Delete the PE session Created */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800810 if ((pe_session != NULL) && LIM_IS_STA_ROLE(pe_session))
811 pe_delete_session(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800812
813 if (false == failure)
Jeff Johnson35c58a82018-11-22 15:04:57 -0800814 lim_send_sme_disassoc_deauth_ntf(mac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800815 (uint32_t *) pMsg);
816} /*** end lim_send_sme_disassoc_ntf() ***/
817
818/** -----------------------------------------------------------------
819 \brief lim_send_sme_disassoc_ind() - sends SME_DISASSOC_IND
820
821 After receiving disassociation frame from peer entity, this
822 function sends a eWNI_SME_DISASSOC_IND to SME with a specific
823 reason code.
824
Jeff Johnson35c58a82018-11-22 15:04:57 -0800825 \param mac - global mac structure
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800826 \param sta - station dph hash node
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800827 \return none
828 \sa
829 ----------------------------------------------------------------- */
830void
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800831lim_send_sme_disassoc_ind(struct mac_context *mac, tpDphHashNode sta,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800832 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800833{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700834 struct scheduler_msg mmhMsg = {0};
Jeff Johnson318a9882019-02-04 08:30:50 -0800835 struct disassoc_ind *pSirSmeDisassocInd;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800836
Jeff Johnson318a9882019-02-04 08:30:50 -0800837 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(*pSirSmeDisassocInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700838 if (!pSirSmeDisassocInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800839 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800840
841 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
Jeff Johnson318a9882019-02-04 08:30:50 -0800842 pSirSmeDisassocInd->length = sizeof(*pSirSmeDisassocInd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800843
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800844 pSirSmeDisassocInd->sessionId = pe_session->smeSessionId;
Padma, Santhosh Kumar02289212016-09-30 13:30:08 +0530845 pSirSmeDisassocInd->statusCode = eSIR_SME_DEAUTH_STATUS;
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800846 pSirSmeDisassocInd->reasonCode = sta->mlmStaContext.disassocReason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800847
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800848 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes, pe_session->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530849 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800850
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800851 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes, sta->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530852 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800853
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800854 pSirSmeDisassocInd->staId = sta->staIndex;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800855
856 mmhMsg.type = eWNI_SME_DISASSOC_IND;
857 mmhMsg.bodyptr = pSirSmeDisassocInd;
858 mmhMsg.bodyval = 0;
859
Jeff Johnson35c58a82018-11-22 15:04:57 -0800860 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800861 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800862#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800863 lim_diag_event_report(mac, WLAN_PE_DIAG_DISASSOC_IND_EVENT, pe_session,
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800864 0, (uint16_t) sta->mlmStaContext.disassocReason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800865#endif /* FEATURE_WLAN_DIAG_SUPPORT */
866
Jeff Johnsona5abe272019-01-06 12:52:02 -0800867 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800868
869} /*** end lim_send_sme_disassoc_ind() ***/
870
871/** -----------------------------------------------------------------
872 \brief lim_send_sme_deauth_ind() - sends SME_DEAUTH_IND
873
874 After receiving deauthentication frame from peer entity, this
875 function sends a eWNI_SME_DEAUTH_IND to SME with a specific
876 reason code.
877
Jeff Johnson35c58a82018-11-22 15:04:57 -0800878 \param mac - global mac structure
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800879 \param sta - station dph hash node
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800880 \return none
881 \sa
882 ----------------------------------------------------------------- */
883void
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800884lim_send_sme_deauth_ind(struct mac_context *mac, tpDphHashNode sta,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800885 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800886{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700887 struct scheduler_msg mmhMsg = {0};
Jeff Johnsonfec08712019-02-04 13:12:08 -0800888 struct deauth_ind *pSirSmeDeauthInd;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800889
Jeff Johnsonfec08712019-02-04 13:12:08 -0800890 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(*pSirSmeDeauthInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700891 if (!pSirSmeDeauthInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800892 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800893
894 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
Jeff Johnsonfec08712019-02-04 13:12:08 -0800895 pSirSmeDeauthInd->length = sizeof(*pSirSmeDeauthInd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800896
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800897 pSirSmeDeauthInd->sessionId = pe_session->smeSessionId;
898 pSirSmeDeauthInd->transactionId = pe_session->transactionId;
899 if (eSIR_INFRA_AP_MODE == pe_session->bssType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800900 pSirSmeDeauthInd->statusCode =
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800901 (tSirResultCodes) sta->mlmStaContext.cleanupTrigger;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800902 } else {
Jeff Johnsonfec08712019-02-04 13:12:08 -0800903 /* Need to indicate the reason code over the air */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800904 pSirSmeDeauthInd->statusCode =
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800905 (tSirResultCodes) sta->mlmStaContext.disassocReason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800906 }
907 /* BSSID */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800908 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, pe_session->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530909 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800910 /* peerMacAddr */
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800911 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, sta->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530912 QDF_MAC_ADDR_SIZE);
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800913 pSirSmeDeauthInd->reasonCode = sta->mlmStaContext.disassocReason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800914
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800915 pSirSmeDeauthInd->staId = sta->staIndex;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -0800916 if (eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON ==
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800917 sta->mlmStaContext.disassocReason)
918 pSirSmeDeauthInd->rssi = sta->del_sta_ctx_rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800919
920 mmhMsg.type = eWNI_SME_DEAUTH_IND;
921 mmhMsg.bodyptr = pSirSmeDeauthInd;
922 mmhMsg.bodyval = 0;
923
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800924 MTRACE(mac_trace_msg_tx(mac, pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800925#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800926 lim_diag_event_report(mac, WLAN_PE_DIAG_DEAUTH_IND_EVENT, pe_session,
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800927 0, sta->mlmStaContext.cleanupTrigger);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800928#endif /* FEATURE_WLAN_DIAG_SUPPORT */
929
Jeff Johnsona5abe272019-01-06 12:52:02 -0800930 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800931 return;
932} /*** end lim_send_sme_deauth_ind() ***/
933
934#ifdef FEATURE_WLAN_TDLS
935/**
936 * lim_send_sme_tdls_del_sta_ind()
937 *
938 ***FUNCTION:
939 * This function is called to send the TDLS STA context deletion to SME.
940 *
941 ***LOGIC:
942 *
943 ***ASSUMPTIONS:
944 *
945 ***NOTE:
946 * NA
947 *
Jeff Johnson35c58a82018-11-22 15:04:57 -0800948 * @param mac - Pointer to global MAC structure
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800949 * @param sta - Pointer to internal STA Datastructure
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800950 * @param pe_session - Pointer to the session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800951 * @param reasonCode - Reason for TDLS sta deletion
952 * @return None
953 */
954void
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800955lim_send_sme_tdls_del_sta_ind(struct mac_context *mac, tpDphHashNode sta,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800956 struct pe_session *pe_session, uint16_t reasonCode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800957{
Frank Liud1a28462017-09-06 22:55:48 +0800958 struct tdls_event_info info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800959
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530960 pe_debug("Delete TDLS Peer "MAC_ADDRESS_STR "with reason code: %d",
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800961 MAC_ADDR_ARRAY(sta->staAddr), reasonCode);
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800962 info.vdev_id = pe_session->smeSessionId;
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800963 qdf_mem_copy(info.peermac.bytes, sta->staAddr, QDF_MAC_ADDR_SIZE);
Frank Liud1a28462017-09-06 22:55:48 +0800964 info.message_type = TDLS_PEER_DISCONNECTED;
965 info.peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800966
Jeff Johnson35c58a82018-11-22 15:04:57 -0800967 tgt_tdls_event_handler(mac->psoc, &info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800968
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800969 return;
970} /*** end lim_send_sme_tdls_del_sta_ind() ***/
971
972/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800973 * lim_send_sme_mgmt_tx_completion()
974 *
975 ***FUNCTION:
976 * This function is called to send the eWNI_SME_MGMT_FRM_TX_COMPLETION_IND
977 * message to SME.
978 *
979 ***LOGIC:
980 *
981 ***ASSUMPTIONS:
982 *
983 ***NOTE:
984 * NA
985 *
Jeff Johnson35c58a82018-11-22 15:04:57 -0800986 * @param mac - Pointer to global MAC structure
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800987 * @param pe_session - Pointer to the session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800988 * @param txCompleteStatus - TX Complete Status of Mgmt Frames
989 * @return None
990 */
991void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800992lim_send_sme_mgmt_tx_completion(struct mac_context *mac,
Ganesh Kondabattiniac570072016-12-21 12:45:48 +0530993 uint32_t sme_session_id,
994 uint32_t txCompleteStatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800995{
Wu Gao6768d762018-12-28 16:31:08 +0800996 struct scheduler_msg msg = {0};
997 struct tdls_mgmt_tx_completion_ind *mgmt_tx_completion_ind;
998 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800999
Wu Gao6768d762018-12-28 16:31:08 +08001000 mgmt_tx_completion_ind =
1001 qdf_mem_malloc(sizeof(*mgmt_tx_completion_ind));
1002 if (!mgmt_tx_completion_ind)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001003 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001004
1005 /* sessionId */
Wu Gao6768d762018-12-28 16:31:08 +08001006 mgmt_tx_completion_ind->session_id = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001007
Wu Gao6768d762018-12-28 16:31:08 +08001008 mgmt_tx_completion_ind->tx_complete_status = txCompleteStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001009
Wu Gao6768d762018-12-28 16:31:08 +08001010 msg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1011 msg.bodyptr = mgmt_tx_completion_ind;
1012 msg.bodyval = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001013
Wu Gao6768d762018-12-28 16:31:08 +08001014 mgmt_tx_completion_ind->psoc = mac->psoc;
1015 msg.callback = tgt_tdls_send_mgmt_tx_completion;
1016 status = scheduler_post_message(QDF_MODULE_ID_PE,
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05301017 QDF_MODULE_ID_TDLS,
Wu Gao6768d762018-12-28 16:31:08 +08001018 QDF_MODULE_ID_TARGET_IF, &msg);
1019 if (QDF_IS_STATUS_ERROR(status)) {
1020 pe_err("post msg fail, %d", status);
1021 qdf_mem_free(mgmt_tx_completion_ind);
1022 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001023} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1024
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001025#endif /* FEATURE_WLAN_TDLS */
1026
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001027QDF_STATUS lim_prepare_disconnect_done_ind(struct mac_context *mac_ctx,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301028 uint32_t **msg,
1029 uint8_t session_id,
1030 tSirResultCodes reason_code,
1031 uint8_t *peer_mac_addr)
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301032{
1033 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301034
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301035 sir_sme_dis_ind = qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001036 if (!sir_sme_dis_ind)
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301037 return QDF_STATUS_E_FAILURE;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301038
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301039 pe_debug("Prepare eWNI_SME_DISCONNECT_DONE_IND withretCode: %d",
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301040 reason_code);
1041
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301042 sir_sme_dis_ind->message_type = eWNI_SME_DISCONNECT_DONE_IND;
1043 sir_sme_dis_ind->length = sizeof(*sir_sme_dis_ind);
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301044 sir_sme_dis_ind->session_id = session_id;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301045 if (peer_mac_addr)
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05301046 qdf_mem_copy(sir_sme_dis_ind->peer_mac,
1047 peer_mac_addr, ETH_ALEN);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301048
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301049 /*
1050 * Instead of sending deauth reason code as 505 which is
1051 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1052 * Send reason code as zero to Supplicant
1053 */
1054 if (reason_code == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1055 sir_sme_dis_ind->reason_code = 0;
1056 else
1057 sir_sme_dis_ind->reason_code = reason_code;
1058
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301059 *msg = (uint32_t *)sir_sme_dis_ind;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301060
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301061 return QDF_STATUS_SUCCESS;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301062}
1063
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001064/**
1065 * lim_send_sme_deauth_ntf()
1066 *
1067 ***FUNCTION:
1068 * This function is called by limProcessSmeMessages() to send
1069 * eWNI_SME_DISASSOC_RSP/IND message to host
1070 *
1071 ***PARAMS:
1072 *
1073 ***LOGIC:
1074 *
1075 ***ASSUMPTIONS:
1076 * NA
1077 *
1078 ***NOTE:
1079 * This function is used for sending eWNI_SME_DEAUTH_CNF or
1080 * eWNI_SME_DEAUTH_IND to host depending on deauthentication trigger.
1081 *
1082 * @param peerMacAddr Indicates the peer MAC addr to which
1083 * deauthentication was initiated
1084 * @param reasonCode Indicates the reason for Deauthetication
1085 * @param deauthTrigger Indicates the trigger for Deauthetication
1086 * @param aid Indicates the STAID. This parameter is present
1087 * only on AP.
1088 *
1089 * @return None
1090 */
1091void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001092lim_send_sme_deauth_ntf(struct mac_context *mac, tSirMacAddr peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001093 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1094 uint16_t aid, uint8_t smesessionId,
1095 uint16_t smetransactionId)
1096{
1097 uint8_t *pBuf;
Jeff Johnson15ae0c12019-02-04 12:55:07 -08001098 struct deauth_rsp *pSirSmeDeauthRsp;
Jeff Johnsonfec08712019-02-04 13:12:08 -08001099 struct deauth_ind *pSirSmeDeauthInd;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001100 struct pe_session *pe_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001101 uint8_t sessionId;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301102 uint32_t *pMsg = NULL;
1103 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001104
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001105 pe_session = pe_find_session_by_bssid(mac, peerMacAddr, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001106 switch (deauthTrigger) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001107 case eLIM_HOST_DEAUTH:
1108 /**
1109 * Deauthentication response to host triggered
1110 * deauthentication.
1111 */
Jeff Johnson15ae0c12019-02-04 12:55:07 -08001112 pSirSmeDeauthRsp = qdf_mem_malloc(sizeof(*pSirSmeDeauthRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001113 if (!pSirSmeDeauthRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001114 return;
Jeff Johnson15ae0c12019-02-04 12:55:07 -08001115 pe_debug("send eWNI_SME_DEAUTH_RSP with retCode: %d for "
1116 MAC_ADDRESS_STR,
1117 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001118 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
Jeff Johnson15ae0c12019-02-04 12:55:07 -08001119 pSirSmeDeauthRsp->length = sizeof(*pSirSmeDeauthRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001120 pSirSmeDeauthRsp->statusCode = reasonCode;
1121 pSirSmeDeauthRsp->sessionId = smesessionId;
1122 pSirSmeDeauthRsp->transactionId = smetransactionId;
1123
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -08001124 pBuf = (uint8_t *) pSirSmeDeauthRsp->peer_macaddr.bytes;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301125 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001126
1127#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -08001128 lim_diag_event_report(mac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001129 pe_session, 0, (uint16_t) reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001130#endif
1131 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1132
1133 break;
1134
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301135 case eLIM_PEER_ENTITY_DEAUTH:
1136 case eLIM_LINK_MONITORING_DEAUTH:
Jeff Johnson35c58a82018-11-22 15:04:57 -08001137 status = lim_prepare_disconnect_done_ind(mac, &pMsg,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301138 smesessionId, reasonCode,
1139 &peerMacAddr[0]);
1140 if (!QDF_IS_STATUS_SUCCESS(status)) {
1141 pe_err("Failed to prepare message");
1142 return;
1143 }
1144 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001145 default:
1146 /**
1147 * Deauthentication indication due to Deauthentication
1148 * frame reception from peer entity or due to
1149 * loss of link with peer entity.
1150 */
Jeff Johnsonfec08712019-02-04 13:12:08 -08001151 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(*pSirSmeDeauthInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001152 if (!pSirSmeDeauthInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001153 return;
Jeff Johnsonfec08712019-02-04 13:12:08 -08001154 pe_debug("send eWNI_SME_DEAUTH_IND with retCode: %d for "
1155 MAC_ADDRESS_STR,
1156 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001157 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
Jeff Johnsonfec08712019-02-04 13:12:08 -08001158 pSirSmeDeauthInd->length = sizeof(*pSirSmeDeauthInd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001159 pSirSmeDeauthInd->reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
Jeff Johnson8ee46ef2019-02-20 18:34:17 -08001160 pSirSmeDeauthInd->sessionId = smesessionId;
1161 pSirSmeDeauthInd->transactionId = smetransactionId;
1162 pSirSmeDeauthInd->statusCode = reasonCode;
1163 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, pe_session->bssId,
1164 sizeof(tSirMacAddr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301165 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301166 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001167
1168#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -08001169 lim_diag_event_report(mac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001170 pe_session, 0, (uint16_t) reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001171#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1172 pMsg = (uint32_t *) pSirSmeDeauthInd;
1173
1174 break;
1175 }
1176
1177 /*Delete the PE session created */
Bala Venkatesh03b4f0c2019-01-28 22:00:50 +05301178 if (pe_session && LIM_IS_STA_ROLE(pe_session))
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001179 pe_delete_session(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001180
Jeff Johnson35c58a82018-11-22 15:04:57 -08001181 lim_send_sme_disassoc_deauth_ntf(mac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001182 (uint32_t *) pMsg);
1183
1184} /*** end lim_send_sme_deauth_ntf() ***/
1185
1186/**
1187 * lim_send_sme_wm_status_change_ntf() - Send Notification
1188 * @mac_ctx: Global MAC Context
1189 * @status_change_code: Indicates the change in the wireless medium.
1190 * @status_change_info: Indicates the information associated with
1191 * change in the wireless medium.
1192 * @info_len: Indicates the length of status change information
1193 * being sent.
1194 * @session_id SessionID
1195 *
1196 * This function is called by limProcessSmeMessages() to send
1197 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1198 *
1199 * Return: None
1200 */
1201void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001202lim_send_sme_wm_status_change_ntf(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001203 tSirSmeStatusChangeCode status_change_code,
1204 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1205{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001206 struct scheduler_msg msg = {0};
Jeff Johnson53889322019-02-03 17:37:09 -08001207 struct wm_status_change_ntf *wm_status_change_ntf;
Naveen Rawate01ed172016-11-17 11:34:50 -08001208 uint32_t max_info_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001209
Jeff Johnson53889322019-02-03 17:37:09 -08001210 wm_status_change_ntf = qdf_mem_malloc(sizeof(*wm_status_change_ntf));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001211 if (!wm_status_change_ntf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001212 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001213
1214 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1215 msg.bodyval = 0;
1216 msg.bodyptr = wm_status_change_ntf;
1217
1218 switch (status_change_code) {
Naveen Rawate01ed172016-11-17 11:34:50 -08001219 case eSIR_SME_AP_CAPS_CHANGED:
Jeff Johnson9c9961c2019-02-03 17:10:53 -08001220 max_info_len = sizeof(struct ap_new_caps);
Naveen Rawate01ed172016-11-17 11:34:50 -08001221 break;
1222 case eSIR_SME_JOINED_NEW_BSS:
Jeff Johnson2e6d1732019-02-03 17:00:30 -08001223 max_info_len = sizeof(struct new_bss_info);
Naveen Rawate01ed172016-11-17 11:34:50 -08001224 break;
1225 default:
1226 max_info_len = sizeof(wm_status_change_ntf->statusChangeInfo);
1227 break;
1228 }
1229
1230 switch (status_change_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001231 case eSIR_SME_RADAR_DETECTED:
1232 break;
1233 default:
1234 wm_status_change_ntf->messageType =
1235 eWNI_SME_WM_STATUS_CHANGE_NTF;
1236 wm_status_change_ntf->statusChangeCode = status_change_code;
Jeff Johnson53889322019-02-03 17:37:09 -08001237 wm_status_change_ntf->length = sizeof(*wm_status_change_ntf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001238 wm_status_change_ntf->sessionId = session_id;
Naveen Rawate01ed172016-11-17 11:34:50 -08001239 if (info_len <= max_info_len && status_change_info) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301240 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001241 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1242 (uint8_t *) status_change_info, info_len);
1243 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301244 pe_debug("StatusChg code: 0x%x length: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001245 status_change_code, info_len);
1246 break;
1247 }
1248
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301249 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, session_id, msg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08001250 if (QDF_STATUS_SUCCESS != lim_sys_process_mmh_msg_api(mac_ctx, &msg)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301251 qdf_mem_free(wm_status_change_ntf);
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301252 pe_err("lim_sys_process_mmh_msg_api failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001253 }
1254
1255} /*** end lim_send_sme_wm_status_change_ntf() ***/
1256
1257/**
1258 * lim_send_sme_set_context_rsp()
1259 *
1260 ***FUNCTION:
1261 * This function is called by limProcessSmeMessages() to send
1262 * eWNI_SME_SETCONTEXT_RSP message to host
1263 *
1264 ***PARAMS:
1265 *
1266 ***LOGIC:
1267 *
1268 ***ASSUMPTIONS:
1269 * NA
1270 *
1271 ***NOTE:
1272 *
Jeff Johnson35c58a82018-11-22 15:04:57 -08001273 * @param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001274 * @param peerMacAddr Indicates the peer MAC addr to which
1275 * setContext was performed
1276 * @param aid Indicates the aid corresponding to the peer MAC
1277 * address
1278 * @param resultCode Indicates the result of previously issued
1279 * eWNI_SME_SETCONTEXT_RSP message
1280 *
1281 * @return None
1282 */
1283void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001284lim_send_sme_set_context_rsp(struct mac_context *mac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301285 struct qdf_mac_addr peer_macaddr, uint16_t aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001286 tSirResultCodes resultCode,
Jeff Johnson924ae612019-02-05 12:01:50 -08001287 struct pe_session *pe_session,
1288 uint8_t smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001289 uint16_t smetransactionId)
1290{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001291 struct scheduler_msg mmhMsg = {0};
Jeff Johnson924ae612019-02-05 12:01:50 -08001292 struct set_context_rsp *set_context_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001293
Jeff Johnson924ae612019-02-05 12:01:50 -08001294 set_context_rsp = qdf_mem_malloc(sizeof(*set_context_rsp));
1295 if (!set_context_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001296 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001297
Jeff Johnson924ae612019-02-05 12:01:50 -08001298 set_context_rsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1299 set_context_rsp->length = sizeof(*set_context_rsp);
1300 set_context_rsp->statusCode = resultCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001301
Jeff Johnson924ae612019-02-05 12:01:50 -08001302 qdf_copy_macaddr(&set_context_rsp->peer_macaddr, &peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001303
1304 /* Update SME session and transaction Id */
Jeff Johnson924ae612019-02-05 12:01:50 -08001305 set_context_rsp->sessionId = smesessionId;
1306 set_context_rsp->transactionId = smetransactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001307
1308 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
Jeff Johnson924ae612019-02-05 12:01:50 -08001309 mmhMsg.bodyptr = set_context_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001310 mmhMsg.bodyval = 0;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001311 if (NULL == pe_session) {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001312 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301313 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001314 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001315 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001316 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001317 }
1318
1319#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -08001320 lim_diag_event_report(mac, WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001321 pe_session, (uint16_t) resultCode, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001322#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1323
Jeff Johnson35c58a82018-11-22 15:04:57 -08001324 mac->lim.sme_msg_callback(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325} /*** end lim_send_sme_set_context_rsp() ***/
1326
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001327/** -----------------------------------------------------------------
1328 \brief lim_send_sme_addts_rsp() - sends SME ADDTS RSP
1329 \ This function sends a eWNI_SME_ADDTS_RSP to SME.
1330 \ SME only looks at rc and tspec field.
Jeff Johnson35c58a82018-11-22 15:04:57 -08001331 \param mac - global mac structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001332 \param rspReqd - is SmeAddTsRsp required
1333 \param status - status code of SME_ADD_TS_RSP
1334 \return tspec
1335 \sa
1336 ----------------------------------------------------------------- */
1337void
Jeff Johnson56471b92018-12-22 14:36:06 -08001338lim_send_sme_addts_rsp(struct mac_context *mac, uint8_t rspReqd,
1339 uint32_t status,
1340 struct pe_session *pe_session, struct mac_tspec_ie tspec,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001341 uint8_t smesessionId, uint16_t smetransactionId)
1342{
1343 tpSirAddtsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001344 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001345
1346 if (!rspReqd)
1347 return;
1348
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301349 rsp = qdf_mem_malloc(sizeof(tSirAddtsRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001350 if (!rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001351 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001352
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001353 rsp->messageType = eWNI_SME_ADDTS_RSP;
1354 rsp->rc = status;
1355 rsp->rsp.status = (enum eSirMacStatusCodes)status;
1356 rsp->rsp.tspec = tspec;
1357 /* Update SME session Id and transcation Id */
1358 rsp->sessionId = smesessionId;
1359 rsp->transactionId = smetransactionId;
1360
1361 mmhMsg.type = eWNI_SME_ADDTS_RSP;
1362 mmhMsg.bodyptr = rsp;
1363 mmhMsg.bodyval = 0;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001364 if (NULL == pe_session) {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001365 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301366 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001367 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001368 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001369 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001370 }
1371#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001372 lim_diag_event_report(mac, WLAN_PE_DIAG_ADDTS_RSP_EVENT, pe_session, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001373 0);
1374#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1375
Jeff Johnsona5abe272019-01-06 12:52:02 -08001376 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001377 return;
1378}
1379
1380void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001381lim_send_sme_delts_rsp(struct mac_context *mac, tpSirDeltsReq delts, uint32_t status,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001382 struct pe_session *pe_session, uint8_t smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001383 uint16_t smetransactionId)
1384{
1385 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001386 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001387
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301388 pe_debug("SendSmeDeltsRsp aid: %d tsid: %d up: %d status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001389 delts->aid,
1390 delts->req.tsinfo.traffic.tsid,
1391 delts->req.tsinfo.traffic.userPrio, status);
1392 if (!delts->rspReqd)
1393 return;
1394
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301395 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001396 if (!rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001397 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001398
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001399 if (pe_session != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001400
1401 rsp->aid = delts->aid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301402 qdf_copy_macaddr(&rsp->macaddr, &delts->macaddr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301403 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) &delts->req,
Jeff Johnsoncf2ec162018-12-22 16:46:43 -08001404 sizeof(struct delts_req_info));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001405 }
1406
1407 rsp->messageType = eWNI_SME_DELTS_RSP;
1408 rsp->rc = status;
1409
1410 /* Update SME session Id and transcation Id */
1411 rsp->sessionId = smesessionId;
1412 rsp->transactionId = smetransactionId;
1413
1414 mmhMsg.type = eWNI_SME_DELTS_RSP;
1415 mmhMsg.bodyptr = rsp;
1416 mmhMsg.bodyval = 0;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001417 if (NULL == pe_session) {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001418 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301419 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001420 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001421 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001422 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001423 }
1424#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001425 lim_diag_event_report(mac, WLAN_PE_DIAG_DELTS_RSP_EVENT, pe_session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001426 (uint16_t) status, 0);
1427#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1428
Jeff Johnsona5abe272019-01-06 12:52:02 -08001429 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001430}
1431
1432void
Jeff Johnsoncf2ec162018-12-22 16:46:43 -08001433lim_send_sme_delts_ind(struct mac_context *mac, struct delts_req_info *delts,
1434 uint16_t aid, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001435{
1436 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001437 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001438
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301439 pe_debug("SendSmeDeltsInd aid: %d tsid: %d up: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001440 aid, delts->tsinfo.traffic.tsid, delts->tsinfo.traffic.userPrio);
1441
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301442 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001443 if (!rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001444 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001445
1446 rsp->messageType = eWNI_SME_DELTS_IND;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001447 rsp->rc = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001448 rsp->aid = aid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301449 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) delts, sizeof(*delts));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001450
1451 /* Update SME session Id and SME transaction Id */
1452
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001453 rsp->sessionId = pe_session->smeSessionId;
1454 rsp->transactionId = pe_session->transactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001455
1456 mmhMsg.type = eWNI_SME_DELTS_IND;
1457 mmhMsg.bodyptr = rsp;
1458 mmhMsg.bodyval = 0;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001459 MTRACE(mac_trace_msg_tx(mac, pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001460#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001461 lim_diag_event_report(mac, WLAN_PE_DIAG_DELTS_IND_EVENT, pe_session, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001462 0);
1463#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1464
Jeff Johnsona5abe272019-01-06 12:52:02 -08001465 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001466}
1467
Naveen Rawatfa2a1002018-05-17 16:06:37 -07001468#ifndef QCA_SUPPORT_CP_STATS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001469/**
1470 * lim_send_sme_pe_statistics_rsp()
1471 *
1472 ***FUNCTION:
1473 * This function is called to send 802.11 statistics response to HDD.
1474 * This function posts the result back to HDD. This is a response to
1475 * HDD's request for statistics.
1476 *
1477 ***PARAMS:
1478 *
1479 ***LOGIC:
1480 *
1481 ***ASSUMPTIONS:
1482 * NA
1483 *
1484 ***NOTE:
1485 * NA
1486 *
Jeff Johnson35c58a82018-11-22 15:04:57 -08001487 * @param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001488 * @param p80211Stats Statistics sent in response
1489 * @param resultCode TODO:
1490 *
1491 *
1492 * @return none
1493 */
1494
1495void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001496lim_send_sme_pe_statistics_rsp(struct mac_context *mac, uint16_t msgType, void *stats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001497{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001498 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001499 uint8_t sessionId;
1500 tAniGetPEStatsRsp *pPeStats = (tAniGetPEStatsRsp *) stats;
Jeff Johnsond7035a32018-11-18 22:03:13 -08001501 struct pe_session *pPeSessionEntry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001502
1503 /* Get the Session Id based on Sta Id */
1504 pPeSessionEntry =
Jeff Johnson35c58a82018-11-22 15:04:57 -08001505 pe_find_session_by_sta_id(mac, pPeStats->staId, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001506
1507 /* Fill the Session Id */
1508 if (NULL != pPeSessionEntry) {
1509 /* Fill the Session Id */
1510 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1511 }
1512
1513 pPeStats->msgType = eWNI_SME_GET_STATISTICS_RSP;
1514
1515 /* msgType should be WMA_GET_STATISTICS_RSP */
1516 mmhMsg.type = eWNI_SME_GET_STATISTICS_RSP;
1517
1518 mmhMsg.bodyptr = stats;
1519 mmhMsg.bodyval = 0;
Jeff Johnson35c58a82018-11-22 15:04:57 -08001520 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08001521 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001522
1523 return;
1524
1525} /*** end lim_send_sme_pe_statistics_rsp() ***/
Naveen Rawatfa2a1002018-05-17 16:06:37 -07001526#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001527
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001528#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001529/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001530 * lim_send_sme_pe_ese_tsm_rsp() - send tsm response
Jeff Johnson35c58a82018-11-22 15:04:57 -08001531 * @mac: Pointer to global mac structure
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001532 * @pStats: Pointer to TSM Stats
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001533 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001534 * This function is called to send tsm stats response to HDD.
1535 * This function posts the result back to HDD. This is a response to
1536 * HDD's request to get tsm stats.
1537 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001538 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001539 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001540void lim_send_sme_pe_ese_tsm_rsp(struct mac_context *mac,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001541 tAniGetTsmStatsRsp *pStats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001542{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001543 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001544 uint8_t sessionId;
1545 tAniGetTsmStatsRsp *pPeStats = (tAniGetTsmStatsRsp *) pStats;
Jeff Johnsond7035a32018-11-18 22:03:13 -08001546 struct pe_session *pPeSessionEntry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001547
1548 /* Get the Session Id based on Sta Id */
Abhinav Kumaraa8f2df2019-01-11 20:02:26 +05301549 pPeSessionEntry = pe_find_session_by_bssid(mac, pPeStats->bssid.bytes,
1550 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001551 /* Fill the Session Id */
1552 if (NULL != pPeSessionEntry) {
1553 /* Fill the Session Id */
1554 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1555 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301556 pe_err("Session not found for the Sta id: %d",
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301557 pPeStats->staId);
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05301558 qdf_mem_free(pPeStats->tsmStatsReq);
1559 qdf_mem_free(pPeStats);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001560 return;
1561 }
1562
1563 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
1564 pPeStats->tsmMetrics.RoamingCount
1565 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
1566 pPeStats->tsmMetrics.RoamingDly
1567 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
1568
1569 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
1570 mmhMsg.bodyptr = pStats;
1571 mmhMsg.bodyval = 0;
Jeff Johnson35c58a82018-11-22 15:04:57 -08001572 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08001573 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001574
1575 return;
1576} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
1577
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001578#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001579
1580void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001581lim_send_sme_ibss_peer_ind(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001582 tSirMacAddr peerMacAddr,
1583 uint16_t staIndex,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001584 uint8_t *beacon,
1585 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
1586{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001587 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001588 tSmeIbssPeerInd *pNewPeerInd;
1589
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301590 pNewPeerInd = qdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
Arif Hussainf5b6c412018-10-10 19:41:09 -07001591 if (!pNewPeerInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001592 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001593
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301594 qdf_mem_copy((uint8_t *) pNewPeerInd->peer_addr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301595 peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001596 pNewPeerInd->staId = staIndex;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001597 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
1598 pNewPeerInd->mesgType = msgType;
1599 pNewPeerInd->sessionId = sessionId;
1600
1601 if (beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301602 qdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001603 sizeof(tSmeIbssPeerInd)), (void *)beacon,
1604 beaconLen);
1605 }
1606
1607 mmhMsg.type = msgType;
1608 mmhMsg.bodyptr = pNewPeerInd;
Jeff Johnson35c58a82018-11-22 15:04:57 -08001609 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08001610 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001611
1612}
1613
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07001614/**
1615 * lim_process_csa_wbw_ie() - Process CSA Wide BW IE
1616 * @mac_ctx: pointer to global adapter context
1617 * @csa_params: pointer to CSA parameters
1618 * @chnl_switch_info:pointer to channel switch parameters
1619 * @session_entry: session pointer
1620 *
1621 * Return: None
1622 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001623static QDF_STATUS lim_process_csa_wbw_ie(struct mac_context *mac_ctx,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001624 struct csa_offload_params *csa_params,
1625 tLimWiderBWChannelSwitchInfo *chnl_switch_info,
Jeff Johnsond7035a32018-11-18 22:03:13 -08001626 struct pe_session *session_entry)
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001627{
Amar Singhal5cccafe2017-02-15 12:42:58 -08001628 struct ch_params ch_params = {0};
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001629 uint8_t ap_new_ch_width;
1630 bool new_ch_width_dfn = false;
1631 uint8_t center_freq_diff;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001632 uint32_t fw_vht_ch_wd = wma_get_vht_ch_width() + 1;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001633
1634 ap_new_ch_width = csa_params->new_ch_width + 1;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001635
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001636 pe_debug("new channel: %d new_ch_width: %d seg0: %d seg1: %d",
1637 csa_params->channel, ap_new_ch_width,
1638 csa_params->new_ch_freq_seg1,
1639 csa_params->new_ch_freq_seg2);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001640
1641 if ((ap_new_ch_width != CH_WIDTH_80MHZ) &&
1642 (ap_new_ch_width != CH_WIDTH_160MHZ) &&
1643 (ap_new_ch_width != CH_WIDTH_80P80MHZ)) {
1644 pe_err("CSA wide BW IE has wrong ch_width %d",
1645 csa_params->new_ch_width);
1646 return QDF_STATUS_E_INVAL;
1647 }
1648
1649 if (!csa_params->new_ch_freq_seg1 && !csa_params->new_ch_freq_seg2) {
1650 pe_err("CSA wide BW IE has invalid center freq");
1651 return QDF_STATUS_E_INVAL;
1652 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001653 if ((ap_new_ch_width == CH_WIDTH_80MHZ) &&
1654 csa_params->new_ch_freq_seg2) {
1655 new_ch_width_dfn = true;
1656 if (csa_params->new_ch_freq_seg2 >
1657 csa_params->new_ch_freq_seg1)
1658 center_freq_diff = csa_params->new_ch_freq_seg2 -
1659 csa_params->new_ch_freq_seg1;
1660 else
1661 center_freq_diff = csa_params->new_ch_freq_seg1 -
1662 csa_params->new_ch_freq_seg2;
1663 if (center_freq_diff == CENTER_FREQ_DIFF_160MHz)
1664 ap_new_ch_width = CH_WIDTH_160MHZ;
1665 else if (center_freq_diff > CENTER_FREQ_DIFF_80P80MHz)
1666 ap_new_ch_width = CH_WIDTH_80P80MHZ;
1667 else
1668 ap_new_ch_width = CH_WIDTH_80MHZ;
1669 }
1670 session_entry->gLimChannelSwitch.state =
1671 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1672 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
1673 !new_ch_width_dfn) {
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001674 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1675 CH_TO_CNTR_FREQ_DIFF_160MHz) {
1676 pe_err("CSA wide BW IE has invalid center freq");
1677 return QDF_STATUS_E_INVAL;
1678 }
1679
1680 if (ap_new_ch_width > fw_vht_ch_wd) {
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001681 pe_debug("New BW is not supported, setting BW to %d",
1682 fw_vht_ch_wd);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001683 ap_new_ch_width = fw_vht_ch_wd;
1684 }
1685 ch_params.ch_width = ap_new_ch_width ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001686 wlan_reg_set_channel_params(mac_ctx->pdev,
1687 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001688 ap_new_ch_width = ch_params.ch_width;
1689 csa_params->new_ch_freq_seg1 = ch_params.center_freq_seg0;
1690 csa_params->new_ch_freq_seg2 = ch_params.center_freq_seg1;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001691 } else if (!new_ch_width_dfn) {
1692 if (ap_new_ch_width > fw_vht_ch_wd) {
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001693 pe_debug("New BW is not supported, setting BW to %d",
1694 fw_vht_ch_wd);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001695 ap_new_ch_width = fw_vht_ch_wd;
1696 }
1697 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1698 CH_TO_CNTR_FREQ_DIFF_80MHz) {
1699 pe_err("CSA wide BW IE has invalid center freq");
1700 return QDF_STATUS_E_INVAL;
1701 }
1702 csa_params->new_ch_freq_seg2 = 0;
1703 }
1704 if (new_ch_width_dfn) {
1705 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1706 CH_TO_CNTR_FREQ_DIFF_80MHz) {
1707 pe_err("CSA wide BW IE has invalid center freq");
1708 return QDF_STATUS_E_INVAL;
1709 }
1710 if (ap_new_ch_width > fw_vht_ch_wd) {
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001711 pe_debug("New width is not supported, setting BW to %d",
1712 fw_vht_ch_wd);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001713 ap_new_ch_width = fw_vht_ch_wd;
1714 }
1715 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
1716 (csa_params->new_ch_freq_seg1 !=
1717 csa_params->channel +
1718 CH_TO_CNTR_FREQ_DIFF_160MHz)) {
1719 pe_err("wide BW IE has invalid 160M center freq");
1720 csa_params->new_ch_freq_seg2 = 0;
1721 ap_new_ch_width = CH_WIDTH_80MHZ;
1722 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001723 }
1724 chnl_switch_info->newChanWidth = ap_new_ch_width;
1725 chnl_switch_info->newCenterChanFreq0 = csa_params->new_ch_freq_seg1;
1726 chnl_switch_info->newCenterChanFreq1 = csa_params->new_ch_freq_seg2;
1727
1728 if (session_entry->ch_width == ap_new_ch_width)
1729 goto prnt_log;
1730
1731 if (session_entry->ch_width == CH_WIDTH_80MHZ) {
1732 chnl_switch_info->newChanWidth = CH_WIDTH_80MHZ;
1733 chnl_switch_info->newCenterChanFreq1 = 0;
1734 } else {
1735 session_entry->ch_width = ap_new_ch_width;
1736 chnl_switch_info->newChanWidth = ap_new_ch_width;
1737 }
1738prnt_log:
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301739 pe_debug("new channel: %d new_ch_width: %d seg0: %d seg1: %d",
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001740 csa_params->channel,
1741 chnl_switch_info->newChanWidth,
1742 chnl_switch_info->newCenterChanFreq0,
1743 chnl_switch_info->newCenterChanFreq1);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001744
1745 return QDF_STATUS_SUCCESS;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001746}
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001747
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001748/**
1749 * lim_handle_csa_offload_msg() - Handle CSA offload message
1750 * @mac_ctx: pointer to global adapter context
1751 * @msg: Message pointer.
1752 *
1753 * Return: None
1754 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001755void lim_handle_csa_offload_msg(struct mac_context *mac_ctx,
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001756 struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001757{
Jeff Johnsond7035a32018-11-18 22:03:13 -08001758 struct pe_session *session_entry;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001759 struct scheduler_msg mmh_msg = {0};
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301760 struct csa_offload_params *csa_params =
1761 (struct csa_offload_params *) (msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001762 tpSmeCsaOffloadInd csa_offload_ind;
1763 tpDphHashNode sta_ds = NULL;
1764 uint8_t session_id;
1765 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05301766 uint16_t chan_space = 0;
Krunal Sonie2c45a92018-05-03 11:51:26 -07001767 struct ch_params ch_params = {0};
Gupta, Kapil121bf212015-11-25 19:21:29 +05301768
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001769 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08001770 tLimChannelSwitchInfo *lim_ch_switch = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001771
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301772 pe_debug("handle csa offload msg");
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301773
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001774 if (!csa_params) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301775 pe_err("limMsgQ body ptr is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001776 return;
1777 }
1778
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05301779 csa_offload_ind = qdf_mem_malloc(sizeof(tSmeCsaOffloadInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001780 if (!csa_offload_ind)
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05301781 goto err;
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05301782
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001783 session_entry =
1784 pe_find_session_by_bssid(mac_ctx,
1785 csa_params->bssId, &session_id);
1786 if (!session_entry) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301787 pe_err("Session does not exists for %pM",
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301788 csa_params->bssId);
Pragaspathi Thilagaraj655db192018-06-19 17:41:37 +05301789 qdf_mem_free(csa_offload_ind);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001790 goto err;
1791 }
1792
1793 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
1794 &session_entry->dph.dphHashTable);
1795
1796 if (!sta_ds) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301797 pe_err("sta_ds does not exist");
Pragaspathi Thilagaraj655db192018-06-19 17:41:37 +05301798 qdf_mem_free(csa_offload_ind);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001799 goto err;
1800 }
1801
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001802 if (!LIM_IS_STA_ROLE(session_entry)) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301803 pe_debug("Invalid role to handle CSA");
Pragaspathi Thilagaraj655db192018-06-19 17:41:37 +05301804 qdf_mem_free(csa_offload_ind);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001805 goto err;
1806 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001807 /*
1808 * on receiving channel switch announcement from AP, delete all
1809 * TDLS peers before leaving BSS and proceed for channel switch
1810 */
Bala Venkatesh33f270b2019-01-14 16:31:29 +05301811
1812 lim_update_tdls_set_state_for_fw(session_entry, false);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001813 lim_delete_tdls_peers(mac_ctx, session_entry);
Gupta, Kapil121bf212015-11-25 19:21:29 +05301814
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001815 lim_ch_switch = &session_entry->gLimChannelSwitch;
1816 session_entry->gLimChannelSwitch.switchMode =
1817 csa_params->switch_mode;
1818 /* timer already started by firmware, switch immediately */
1819 session_entry->gLimChannelSwitch.switchCount = 0;
1820 session_entry->gLimChannelSwitch.primaryChannel =
1821 csa_params->channel;
1822 session_entry->gLimChannelSwitch.state =
1823 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
1824 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
1825 lim_ch_switch->sec_ch_offset =
1826 session_entry->htSecondaryChannelOffset;
1827 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
1828 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
1829 chnl_switch_info =
1830 &session_entry->gLimWiderBWChannelSwitch;
1831
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001832 pe_debug("vht: %d ht: %d flag: %x chan: %d, sec_ch_offset %d",
1833 session_entry->vhtCapability,
1834 session_entry->htSupportedChannelWidthSet,
1835 csa_params->ies_present_flag,
1836 csa_params->channel,
1837 csa_params->sec_chan_offset);
1838 pe_debug("seg1: %d seg2: %d width: %d country: %s class: %d",
1839 csa_params->new_ch_freq_seg1,
1840 csa_params->new_ch_freq_seg2,
1841 csa_params->new_ch_width,
1842 mac_ctx->scan.countryCodeCurrent,
1843 csa_params->new_op_class);
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05301844
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001845 if (session_entry->vhtCapability &&
1846 session_entry->htSupportedChannelWidthSet) {
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001847 if ((csa_params->ies_present_flag & lim_wbw_ie_present) &&
1848 (QDF_STATUS_SUCCESS == lim_process_csa_wbw_ie(mac_ctx,
1849 csa_params, chnl_switch_info,
1850 session_entry))) {
1851 pe_debug("CSA wide BW IE process successful");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001852 lim_ch_switch->sec_ch_offset =
Abhishek Singhaf639b42017-06-16 14:14:36 +05301853 PHY_SINGLE_CHANNEL_CENTERED;
1854 if (chnl_switch_info->newChanWidth) {
1855 if (csa_params->channel <
1856 csa_params->new_ch_freq_seg1)
1857 lim_ch_switch->sec_ch_offset =
1858 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1859 else
1860 lim_ch_switch->sec_ch_offset =
1861 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1862 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001863 } else if (csa_params->ies_present_flag
1864 & lim_xcsa_ie_present) {
1865 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001866 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001867 mac_ctx->scan.countryCodeCurrent,
1868 csa_params->channel,
1869 csa_params->new_op_class);
1870 session_entry->gLimChannelSwitch.state =
1871 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1872
1873 if (chan_space == 80) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001874 chnl_switch_info->newChanWidth =
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001875 CH_WIDTH_80MHZ;
1876 } else if (chan_space == 40) {
1877 chnl_switch_info->newChanWidth =
1878 CH_WIDTH_40MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001879 } else {
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001880 chnl_switch_info->newChanWidth =
1881 CH_WIDTH_20MHZ;
1882 lim_ch_switch->state =
1883 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
1884 }
1885
1886 ch_params.ch_width =
1887 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001888 wlan_reg_set_channel_params(mac_ctx->pdev,
1889 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001890 chnl_switch_info->newCenterChanFreq0 =
1891 ch_params.center_freq_seg0;
1892 /*
1893 * This is not applicable for 20/40/80 MHz.
1894 * Only used when we support 80+80 MHz operation.
1895 * In case of 80+80 MHz, this parameter indicates
1896 * center channel frequency index of 80 MHz
1897 * channel offrequency segment 1.
1898 */
1899 chnl_switch_info->newCenterChanFreq1 =
1900 ch_params.center_freq_seg1;
1901 lim_ch_switch->sec_ch_offset =
1902 ch_params.sec_ch_offset;
1903
Kiran Kumar Lokere47127482017-12-20 18:09:55 -08001904 } else {
1905 lim_ch_switch->state =
1906 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1907 ch_params.ch_width = CH_WIDTH_40MHZ;
1908 wlan_reg_set_channel_params(mac_ctx->pdev,
1909 csa_params->channel, 0, &ch_params);
1910 lim_ch_switch->sec_ch_offset =
1911 ch_params.sec_ch_offset;
1912 chnl_switch_info->newChanWidth = CH_WIDTH_40MHZ;
1913 chnl_switch_info->newCenterChanFreq0 =
1914 ch_params.center_freq_seg0;
1915 chnl_switch_info->newCenterChanFreq1 = 0;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001916 }
1917 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
1918 chnl_switch_info->newCenterChanFreq0;
1919 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
1920 chnl_switch_info->newCenterChanFreq1;
1921 session_entry->gLimChannelSwitch.ch_width =
1922 chnl_switch_info->newChanWidth;
1923
1924 } else if (session_entry->htSupportedChannelWidthSet) {
1925 if (csa_params->ies_present_flag
1926 & lim_xcsa_ie_present) {
1927 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001928 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001929 mac_ctx->scan.countryCodeCurrent,
1930 csa_params->channel,
1931 csa_params->new_op_class);
1932 lim_ch_switch->state =
1933 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1934 if (chan_space == 40) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08001935 lim_ch_switch->ch_width =
1936 CH_WIDTH_40MHZ;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001937 chnl_switch_info->newChanWidth =
1938 CH_WIDTH_40MHZ;
1939 ch_params.ch_width =
1940 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001941 wlan_reg_set_channel_params(mac_ctx->pdev,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001942 csa_params->channel,
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07001943 0, &ch_params);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08001944 lim_ch_switch->ch_center_freq_seg0 =
1945 ch_params.center_freq_seg0;
1946 lim_ch_switch->sec_ch_offset =
1947 ch_params.sec_ch_offset;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001948 } else {
1949 lim_ch_switch->ch_width =
1950 CH_WIDTH_20MHZ;
1951 chnl_switch_info->newChanWidth =
1952 CH_WIDTH_40MHZ;
1953 lim_ch_switch->state =
1954 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
1955 lim_ch_switch->sec_ch_offset =
1956 PHY_SINGLE_CHANNEL_CENTERED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001957 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001958 } else {
1959 lim_ch_switch->ch_width =
1960 CH_WIDTH_40MHZ;
1961 lim_ch_switch->state =
1962 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1963 ch_params.ch_width = CH_WIDTH_40MHZ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001964 wlan_reg_set_channel_params(mac_ctx->pdev,
1965 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001966 lim_ch_switch->ch_center_freq_seg0 =
1967 ch_params.center_freq_seg0;
1968 lim_ch_switch->sec_ch_offset =
1969 ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001970 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001971
1972 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301973 pe_debug("new ch width: %d space: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05301974 session_entry->gLimChannelSwitch.ch_width, chan_space);
Kiran Kumar Lokere75d636f2016-12-20 14:52:03 -08001975 if ((session_entry->currentOperChannel == csa_params->channel) &&
1976 (session_entry->ch_width ==
1977 session_entry->gLimChannelSwitch.ch_width)) {
1978 pe_debug("Ignore CSA, no change in ch and bw");
Pragaspathi Thilagaraj655db192018-06-19 17:41:37 +05301979 qdf_mem_free(csa_offload_ind);
Kiran Kumar Lokere75d636f2016-12-20 14:52:03 -08001980 goto err;
1981 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001982
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05301983 if (WLAN_REG_IS_24GHZ_CH(csa_params->channel) &&
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +05301984 (session_entry->dot11mode == MLME_DOT11_MODE_11A))
1985 session_entry->dot11mode = MLME_DOT11_MODE_11G;
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05301986 else if (WLAN_REG_IS_5GHZ_CH(csa_params->channel) &&
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +05301987 ((session_entry->dot11mode == MLME_DOT11_MODE_11G) ||
1988 (session_entry->dot11mode == MLME_DOT11_MODE_11G_ONLY)))
1989 session_entry->dot11mode = MLME_DOT11_MODE_11A;
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05301990
Vignesh Viswanathan3d478032018-08-02 20:18:53 +05301991 /* Send RSO Stop to FW before triggering the vdev restart for CSA */
1992 if (mac_ctx->lim.stop_roaming_callback)
1993 mac_ctx->lim.stop_roaming_callback(mac_ctx,
1994 session_entry->smeSessionId,
1995 ecsr_driver_disabled);
1996
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001997 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001998
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001999 csa_offload_ind->mesgType = eWNI_SME_CSA_OFFLOAD_EVENT;
2000 csa_offload_ind->mesgLen = sizeof(tSmeCsaOffloadInd);
2001 qdf_mem_copy(csa_offload_ind->bssid.bytes, session_entry->bssId,
2002 QDF_MAC_ADDR_SIZE);
2003 mmh_msg.type = eWNI_SME_CSA_OFFLOAD_EVENT;
2004 mmh_msg.bodyptr = csa_offload_ind;
2005 mmh_msg.bodyval = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302006 pe_debug("Sending eWNI_SME_CSA_OFFLOAD_EVENT to SME");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002007 MTRACE(mac_trace_msg_tx
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002008 (mac_ctx, session_entry->peSessionId, mmh_msg.type));
2009#ifdef FEATURE_WLAN_DIAG_SUPPORT
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002010 lim_diag_event_report(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002011 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002012 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002013#endif
Jeff Johnsona5abe272019-01-06 12:52:02 -08002014 lim_sys_process_mmh_msg_api(mac_ctx, &mmh_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002015
2016err:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302017 qdf_mem_free(csa_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002018}
2019
2020/*--------------------------------------------------------------------------
2021 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
2022
Jeff Johnson35c58a82018-11-22 15:04:57 -08002023 \param mac - pointer to global adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002024 \param sessionId - Message pointer.
2025
2026 \sa
2027 --------------------------------------------------------------------------*/
2028
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002029void lim_handle_delete_bss_rsp(struct mac_context *mac, struct scheduler_msg *MsgQ)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002030{
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002031 struct pe_session *pe_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002032 tpDeleteBssParams pDelBss = (tpDeleteBssParams) (MsgQ->bodyptr);
2033
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002034 pe_session =
Jeff Johnson35c58a82018-11-22 15:04:57 -08002035 pe_find_session_by_session_id(mac, pDelBss->sessionId);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002036 if (pe_session == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302037 pe_err("Session Does not exist for given sessionID: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002038 pDelBss->sessionId);
Tushnim Bhattacharyya6368a262018-10-12 09:48:45 -07002039 qdf_mem_free(MsgQ->bodyptr);
2040 MsgQ->bodyptr = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002041 return;
2042 }
Krunal Sonie50ff452017-10-11 18:23:55 -07002043
2044 /*
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002045 * During DEL BSS handling, the PE Session will be deleted, but it is
2046 * better to clear this flag if the session is hanging around due
2047 * to some error conditions so that the next DEL_BSS request does
2048 * not take the HO_FAIL path
2049 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002050 pe_session->process_ho_fail = false;
2051 if (LIM_IS_IBSS_ROLE(pe_session))
2052 lim_ibss_del_bss_rsp(mac, MsgQ->bodyptr, pe_session);
2053 else if (LIM_IS_UNKNOWN_ROLE(pe_session))
2054 lim_process_sme_del_bss_rsp(mac, MsgQ->bodyval, pe_session);
2055 else if (LIM_IS_NDI_ROLE(pe_session))
2056 lim_ndi_del_bss_rsp(mac, MsgQ->bodyptr, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002057 else
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002058 lim_process_mlm_del_bss_rsp(mac, MsgQ, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002059
2060}
2061
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002062/** -----------------------------------------------------------------
2063 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
2064 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
2065 \ SME only looks at rc and tspec field.
Jeff Johnson35c58a82018-11-22 15:04:57 -08002066 \param mac - global mac structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002067 \param rspReqd - is SmeAddTsRsp required
2068 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
2069 \return tspec
2070 \sa
2071 ----------------------------------------------------------------- */
2072void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002073lim_send_sme_aggr_qos_rsp(struct mac_context *mac, tpSirAggrQosRsp aggrQosRsp,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002074 uint8_t smesessionId)
2075{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002076 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002077
2078 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
2079 mmhMsg.bodyptr = aggrQosRsp;
2080 mmhMsg.bodyval = 0;
Jeff Johnson35c58a82018-11-22 15:04:57 -08002081 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302082 smesessionId, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08002083 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002084
2085 return;
2086}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002087
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002088void lim_send_sme_max_assoc_exceeded_ntf(struct mac_context *mac, tSirMacAddr peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002089 uint8_t smesessionId)
2090{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002091 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002092 tSmeMaxAssocInd *pSmeMaxAssocInd;
2093
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302094 pSmeMaxAssocInd = qdf_mem_malloc(sizeof(tSmeMaxAssocInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002095 if (!pSmeMaxAssocInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002096 return;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302097 qdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peer_mac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302098 (uint8_t *) peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002099 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
2100 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
2101 pSmeMaxAssocInd->sessionId = smesessionId;
2102 mmhMsg.type = pSmeMaxAssocInd->mesgType;
2103 mmhMsg.bodyptr = pSmeMaxAssocInd;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302104 pe_debug("msgType: %s peerMacAddr "MAC_ADDRESS_STR "sme session id %d",
2105 "eWNI_SME_MAX_ASSOC_EXCEEDED", MAC_ADDR_ARRAY(peerMacAddr),
2106 pSmeMaxAssocInd->sessionId);
Jeff Johnson35c58a82018-11-22 15:04:57 -08002107 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302108 smesessionId, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08002109 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002110
2111 return;
2112}
2113
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002114/** -----------------------------------------------------------------
2115 \brief lim_send_sme_ap_channel_switch_resp() - sends
2116 eWNI_SME_CHANNEL_CHANGE_RSP
2117 After receiving WMA_SWITCH_CHANNEL_RSP indication this
2118 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
2119 that the Channel change has been done to the specified target
2120 channel in the Channel change request
Jeff Johnson35c58a82018-11-22 15:04:57 -08002121 \param mac - global mac structure
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002122 \param pe_session - session info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002123 \param pChnlParams - Channel switch params
2124 --------------------------------------------------------------------*/
2125void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002126lim_send_sme_ap_channel_switch_resp(struct mac_context *mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002127 struct pe_session *pe_session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002128 tpSwitchChannelParams pChnlParams)
2129{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002130 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002131 tpSwitchChannelParams pSmeSwithChnlParams;
2132 uint8_t channelId;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002133 bool is_ch_dfs = false;
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08002134 enum phy_ch_width ch_width;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002135 uint8_t ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002136
Arif Hussainf5b6c412018-10-10 19:41:09 -07002137 pSmeSwithChnlParams = qdf_mem_malloc(sizeof(tSwitchChannelParams));
2138 if (!pSmeSwithChnlParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002139 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002140
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302141 qdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002142 sizeof(tSwitchChannelParams));
2143
2144 channelId = pSmeSwithChnlParams->channelNumber;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002145 ch_width = pSmeSwithChnlParams->ch_width;
2146 ch_center_freq_seg1 = pSmeSwithChnlParams->ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002147
2148 /*
2149 * Pass the sme sessionID to SME instead
2150 * PE session ID.
2151 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002152 pSmeSwithChnlParams->peSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002153
2154 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
2155 mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
2156 mmhMsg.bodyval = 0;
Jeff Johnsona5abe272019-01-06 12:52:02 -08002157 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002158
2159 /*
2160 * We should start beacon transmission only if the new
2161 * channel after channel change is Non-DFS. For a DFS
2162 * channel, PE will receive an explicit request from
2163 * upper layers to start the beacon transmission .
2164 */
2165
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002166 if (ch_width == CH_WIDTH_160MHZ) {
2167 is_ch_dfs = true;
2168 } else if (ch_width == CH_WIDTH_80P80MHZ) {
Jeff Johnson35c58a82018-11-22 15:04:57 -08002169 if (wlan_reg_get_channel_state(mac->pdev, channelId) ==
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002170 CHANNEL_STATE_DFS ||
Jeff Johnson35c58a82018-11-22 15:04:57 -08002171 wlan_reg_get_channel_state(mac->pdev,
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002172 ch_center_freq_seg1 -
2173 SIR_80MHZ_START_CENTER_CH_DIFF) ==
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002174 CHANNEL_STATE_DFS)
2175 is_ch_dfs = true;
2176 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -08002177 if (wlan_reg_get_channel_state(mac->pdev, channelId) ==
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002178 CHANNEL_STATE_DFS)
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002179 is_ch_dfs = true;
2180 }
2181
2182 if (!is_ch_dfs) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002183 if (channelId == pe_session->currentOperChannel) {
2184 lim_apply_configuration(mac, pe_session);
2185 lim_send_beacon(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002186 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302187 pe_debug("Failed to Transmit Beacons on channel: %d after AP channel change response",
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002188 pe_session->bcnLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002189 }
Arif Hussain1513cb22018-01-05 19:56:31 -08002190
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002191 lim_obss_send_detection_cfg(mac, pe_session, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002192 }
2193 return;
2194}
2195
Peng Xu6363ec62017-05-15 11:06:33 -07002196#ifdef WLAN_FEATURE_11AX_BSS_COLOR
2197/**
2198 * lim_send_bss_color_change_ie_update() - update bss color change IE in
2199 * beacon template
2200 *
2201 * @mac_ctx: pointer to global adapter context
2202 * @session: session pointer
2203 *
2204 * Return: none
2205 */
2206static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002207lim_send_bss_color_change_ie_update(struct mac_context *mac_ctx,
Jeff Johnsond7035a32018-11-18 22:03:13 -08002208 struct pe_session *session)
Peng Xu6363ec62017-05-15 11:06:33 -07002209{
2210 /* Update the beacon template and send to FW */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002211 if (sch_set_fixed_beacon_fields(mac_ctx, session) != QDF_STATUS_SUCCESS) {
Peng Xu6363ec62017-05-15 11:06:33 -07002212 pe_err("Unable to set BSS color change IE in beacon");
Srinivas Girigowdaeff16d92018-09-12 14:56:29 -07002213 return;
Peng Xu6363ec62017-05-15 11:06:33 -07002214 }
2215
2216 /* Send update beacon template message */
Abhishek Singhfc740be2018-10-12 11:34:26 +05302217 lim_send_beacon_ind(mac_ctx, session, REASON_COLOR_CHANGE);
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07002218 pe_debug("Updated BSS color change countdown = %d",
2219 session->he_bss_color_change.countdown);
Peng Xu6363ec62017-05-15 11:06:33 -07002220}
2221
2222static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002223lim_handle_bss_color_change_ie(struct mac_context *mac_ctx,
Jeff Johnsond7035a32018-11-18 22:03:13 -08002224 struct pe_session *session)
Peng Xu6363ec62017-05-15 11:06:33 -07002225{
Arif Hussain2f2d3512018-03-06 12:37:03 -08002226 tUpdateBeaconParams beacon_params;
2227
Peng Xu6363ec62017-05-15 11:06:33 -07002228 /* handle bss color change IE */
2229 if (LIM_IS_AP_ROLE(session) &&
2230 session->he_op.bss_col_disabled) {
2231 if (session->he_bss_color_change.countdown > 0) {
2232 session->he_bss_color_change.countdown--;
2233 } else {
2234 session->bss_color_changing = 0;
Arif Hussain2f2d3512018-03-06 12:37:03 -08002235 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
Arif Hussain05fb4872018-01-03 16:02:55 -08002236 if (session->he_bss_color_change.new_color != 0) {
Peng Xu6363ec62017-05-15 11:06:33 -07002237 session->he_op.bss_col_disabled = 0;
Arif Hussain05fb4872018-01-03 16:02:55 -08002238 session->he_op.bss_color =
2239 session->he_bss_color_change.new_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08002240 beacon_params.paramChangeBitmap |=
2241 PARAM_BSS_COLOR_CHANGED;
2242 beacon_params.bss_color_disabled = 0;
2243 beacon_params.bss_color =
2244 session->he_op.bss_color;
2245 lim_send_beacon_params(mac_ctx,
2246 &beacon_params,
2247 session);
Arif Hussain05fb4872018-01-03 16:02:55 -08002248 lim_send_obss_color_collision_cfg(mac_ctx,
2249 session,
2250 OBSS_COLOR_COLLISION_DETECTION);
2251 }
Peng Xu6363ec62017-05-15 11:06:33 -07002252 }
2253
2254 lim_send_bss_color_change_ie_update(mac_ctx, session);
2255 }
2256}
2257
2258#else
2259static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002260lim_handle_bss_color_change_ie(struct mac_context *mac_ctx,
Jeff Johnsond7035a32018-11-18 22:03:13 -08002261 struct pe_session *session)
Peng Xu6363ec62017-05-15 11:06:33 -07002262{
2263}
2264#endif
2265
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002266void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002267lim_process_beacon_tx_success_ind(struct mac_context *mac_ctx, uint16_t msgType,
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302268 void *event)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002269{
Jeff Johnsond7035a32018-11-18 22:03:13 -08002270 struct pe_session *session;
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302271 tpSirFirstBeaconTxCompleteInd bcn_ind =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002272 (tSirFirstBeaconTxCompleteInd *) event;
2273
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302274 session = pe_find_session_by_bss_idx(mac_ctx, bcn_ind->bssIdx);
2275 if (!session) {
2276 pe_err("Session Does not exist for given session id");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002277 return;
2278 }
2279
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302280 pe_debug("role: %d swIe: %d opIe: %d switch cnt:%d",
2281 GET_LIM_SYSTEM_ROLE(session),
2282 session->dfsIncludeChanSwIe,
2283 session->gLimOperatingMode.present,
2284 session->gLimChannelSwitch.switchCount);
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302285
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302286 if (!LIM_IS_AP_ROLE(session))
2287 return;
Ganesh Kondabattini02ec62b2018-01-24 18:22:24 +05302288
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302289 if (session->dfsIncludeChanSwIe &&
2290 (session->gLimChannelSwitch.switchCount ==
2291 mac_ctx->sap.SapDfsInfo.sap_ch_switch_beacon_cnt))
2292 lim_process_ap_ecsa_timeout(session);
Ganesh Kondabattini02ec62b2018-01-24 18:22:24 +05302293
lifeng1c16b6b2017-09-25 13:59:55 +08002294
Abhishek Singhfc740be2018-10-12 11:34:26 +05302295 if (session->gLimOperatingMode.present)
2296 /* Done with nss update */
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302297 session->gLimOperatingMode.present = 0;
Peng Xu6363ec62017-05-15 11:06:33 -07002298
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302299 lim_handle_bss_color_change_ie(mac_ctx, session);
Peng Xu6363ec62017-05-15 11:06:33 -07002300
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002301 return;
2302}