blob: c110918919190e7b0a10d90bdf88f99cb1a7519b [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
Jeff Johnson41485c22019-02-21 11:00:30 -080059void lim_send_sme_rsp(struct mac_context *mac_ctx, uint16_t msg_type,
60 tSirResultCodes result_code, uint8_t sme_session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080061{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070062 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080063 tSirSmeRsp *sme_rsp;
64
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +053065 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080066 lim_msg_str(msg_type), lim_result_code_str(result_code));
67
Anurag Chouhan600c3a02016-03-01 10:33:54 +053068 sme_rsp = qdf_mem_malloc(sizeof(tSirSmeRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -070069 if (!sme_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080070 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080071
72 sme_rsp->messageType = msg_type;
73 sme_rsp->length = sizeof(tSirSmeRsp);
74 sme_rsp->statusCode = result_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080075 sme_rsp->sessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080076
77 msg.type = msg_type;
78 msg.bodyptr = sme_rsp;
79 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +053080 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG,
81 sme_session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080082
83#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
84 switch (msg_type) {
85 case eWNI_SME_STOP_BSS_RSP:
86 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_STOP_BSS_RSP_EVENT,
87 NULL, (uint16_t) result_code, 0);
88 break;
89 }
90#endif /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsona5abe272019-01-06 12:52:02 -080091 lim_sys_process_mmh_msg_api(mac_ctx, &msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080092}
93
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080094/**
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +053095 * lim_get_max_rate_flags() - Get rate flags
96 * @mac_ctx: Pointer to global MAC structure
97 * @sta_ds: Pointer to station ds structure
98 *
99 * This function is called to get the rate flags for a connection
100 * from the station ds structure depending on the ht and the vht
101 * channel width supported.
102 *
103 * Return: Returns the populated rate_flags
104 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800105uint32_t lim_get_max_rate_flags(struct mac_context *mac_ctx, tpDphHashNode sta_ds)
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530106{
107 uint32_t rate_flags = 0;
108
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700109 if (!sta_ds) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530110 pe_err("sta_ds is NULL");
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530111 return rate_flags;
112 }
113
114 if (!sta_ds->mlmStaContext.htCapability &&
115 !sta_ds->mlmStaContext.vhtCapability) {
Naveen Rawatea1564b2018-05-17 15:56:11 -0700116 rate_flags |= TX_RATE_LEGACY;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530117 } else {
118 if (sta_ds->mlmStaContext.vhtCapability) {
119 if (WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ ==
120 sta_ds->vhtSupportedChannelWidthSet) {
Naveen Rawatea1564b2018-05-17 15:56:11 -0700121 rate_flags |= TX_RATE_VHT80;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530122 } else if (WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ ==
123 sta_ds->vhtSupportedChannelWidthSet) {
124 if (sta_ds->htSupportedChannelWidthSet)
Naveen Rawatea1564b2018-05-17 15:56:11 -0700125 rate_flags |= TX_RATE_VHT40;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530126 else
Naveen Rawatea1564b2018-05-17 15:56:11 -0700127 rate_flags |= TX_RATE_VHT20;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530128 }
129 } else if (sta_ds->mlmStaContext.htCapability) {
130 if (sta_ds->htSupportedChannelWidthSet)
Naveen Rawatea1564b2018-05-17 15:56:11 -0700131 rate_flags |= TX_RATE_HT40;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530132 else
Naveen Rawatea1564b2018-05-17 15:56:11 -0700133 rate_flags |= TX_RATE_HT20;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530134 }
135 }
136
137 if (sta_ds->htShortGI20Mhz || sta_ds->htShortGI40Mhz)
Naveen Rawatea1564b2018-05-17 15:56:11 -0700138 rate_flags |= TX_RATE_SGI;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530139
140 return rate_flags;
141}
142
143/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800144 * lim_send_sme_join_reassoc_rsp_after_resume() - Send Response to SME
Jeff Johnson2df04b82019-02-02 23:30:25 -0800145 * @mac_ctx: Pointer to Global MAC structure
146 * @status: Resume link status
147 * @sme_join_rsp: Join response to be sent
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800148 *
149 * This function is called to send Join/Reassoc rsp
150 * message to SME after the resume link.
151 *
152 * Return: None
153 */
Jeff Johnson2df04b82019-02-02 23:30:25 -0800154static void
155lim_send_sme_join_reassoc_rsp_after_resume(struct mac_context *mac_ctx,
156 QDF_STATUS status,
157 struct join_rsp *sme_join_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800158{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700159 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800160
161 msg.type = sme_join_rsp->messageType;
162 msg.bodyptr = sme_join_rsp;
163 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530164 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, NO_SESSION, msg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -0800165 lim_sys_process_mmh_msg_api(mac_ctx, &msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800166}
167
168/**
169 * lim_handle_join_rsp_status() - Handle the response.
170 * @mac_ctx: Pointer to Global MAC structure
171 * @session_entry: PE Session Info
172 * @result_code: Indicates the result of previously issued
173 * eWNI_SME_msgType_REQ message
174 * @sme_join_rsp The received response.
175 *
176 * This function will handle both the success and failure status
177 * of the received response.
178 *
179 * Return: None
180 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800181static void lim_handle_join_rsp_status(struct mac_context *mac_ctx,
Jeff Johnson2df04b82019-02-02 23:30:25 -0800182 struct pe_session *session_entry,
183 tSirResultCodes result_code,
184 struct join_rsp *sme_join_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800185{
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700186 uint16_t bss_ie_len;
187 void *bss_ies;
188 bool is_vendor_ap_1_present;
Jeff Johnson701444f2019-02-02 22:35:13 -0800189 struct join_req *join_reassoc_req = NULL;
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700190
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800191#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
Jeff Johnson704af112019-02-02 16:11:55 -0800192 struct ht_profile *ht_profile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800193#endif
gaurank kathpaliaefb20a82019-04-18 19:17:23 +0530194 if (session_entry->beacon) {
195 sme_join_rsp->beaconLength = session_entry->bcnLen;
196 qdf_mem_copy(sme_join_rsp->frames,
197 session_entry->beacon,
198 sme_join_rsp->beaconLength);
199 qdf_mem_free(session_entry->beacon);
200 session_entry->beacon = NULL;
201 session_entry->bcnLen = 0;
202 pe_debug("Beacon: %d",
203 sme_join_rsp->beaconLength);
204 }
205
206 if (session_entry->assocReq) {
207 sme_join_rsp->assocReqLength =
208 session_entry->assocReqLen;
209 qdf_mem_copy(sme_join_rsp->frames +
210 sme_join_rsp->beaconLength,
211 session_entry->assocReq,
212 sme_join_rsp->assocReqLength);
213 qdf_mem_free(session_entry->assocReq);
214 session_entry->assocReq = NULL;
215 session_entry->assocReqLen = 0;
216 pe_debug("AssocReq: %d",
217 sme_join_rsp->assocReqLength);
218 }
219 if (session_entry->assocRsp) {
220 sme_join_rsp->assocRspLength =
221 session_entry->assocRspLen;
222 qdf_mem_copy(sme_join_rsp->frames +
223 sme_join_rsp->beaconLength +
224 sme_join_rsp->assocReqLength,
225 session_entry->assocRsp,
226 sme_join_rsp->assocRspLength);
227 qdf_mem_free(session_entry->assocRsp);
228 session_entry->assocRsp = NULL;
229 session_entry->assocRspLen = 0;
230 pe_debug("AssocRsp: %d",
231 sme_join_rsp->assocRspLength);
232 }
233
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800234 if (result_code == eSIR_SME_SUCCESS) {
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700235 if (session_entry->ricData) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800236 sme_join_rsp->parsedRicRspLen =
237 session_entry->RICDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530238 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530239 sme_join_rsp->beaconLength +
240 sme_join_rsp->assocReqLength +
241 sme_join_rsp->assocRspLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800242 session_entry->ricData,
243 sme_join_rsp->parsedRicRspLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530244 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800245 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530246 session_entry->RICDataLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530247 pe_debug("RicLength: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800248 sme_join_rsp->parsedRicRspLen);
249 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800250#ifdef FEATURE_WLAN_ESE
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700251 if (session_entry->tspecIes) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800252 sme_join_rsp->tspecIeLen =
253 session_entry->tspecLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530254 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530255 sme_join_rsp->beaconLength +
256 sme_join_rsp->assocReqLength +
257 sme_join_rsp->assocRspLength +
258 sme_join_rsp->parsedRicRspLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800259 session_entry->tspecIes,
260 sme_join_rsp->tspecIeLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530261 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800262 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530263 session_entry->tspecLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530264 pe_debug("ESE-TspecLen: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530265 sme_join_rsp->tspecIeLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800266 }
267#endif
268 sme_join_rsp->aid = session_entry->limAID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800269 sme_join_rsp->vht_channel_width =
270 session_entry->ch_width;
271#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
272 if (session_entry->cc_switch_mode !=
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530273 QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Jeff Johnsonf6541882019-02-02 16:16:00 -0800274 ht_profile = &sme_join_rsp->ht_profile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800275 ht_profile->htSupportedChannelWidthSet =
276 session_entry->htSupportedChannelWidthSet;
277 ht_profile->htRecommendedTxWidthSet =
278 session_entry->htRecommendedTxWidthSet;
279 ht_profile->htSecondaryChannelOffset =
280 session_entry->htSecondaryChannelOffset;
281 ht_profile->dot11mode = session_entry->dot11mode;
282 ht_profile->htCapability = session_entry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800283 ht_profile->vhtCapability =
284 session_entry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800285 ht_profile->apCenterChan = session_entry->ch_center_freq_seg0;
286 ht_profile->apChanWidth = session_entry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800287 }
288#endif
Jeff Johnson11bd4f32017-09-18 08:15:17 -0700289 pe_debug("pLimJoinReq:%pK, pLimReAssocReq:%pK",
Wu Gao2968fc92017-06-19 19:18:34 +0800290 session_entry->pLimJoinReq,
291 session_entry->pLimReAssocReq);
292
293 if (session_entry->pLimJoinReq)
294 join_reassoc_req = session_entry->pLimJoinReq;
295
296 if (session_entry->pLimReAssocReq)
297 join_reassoc_req = session_entry->pLimReAssocReq;
298
299 if (!join_reassoc_req) {
300 pe_err("both pLimJoinReq and pLimReAssocReq NULL");
301 return;
302 }
303
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700304 bss_ie_len = lim_get_ielen_from_bss_description(
Wu Gao2968fc92017-06-19 19:18:34 +0800305 &join_reassoc_req->bssDescription);
306 bss_ies = &join_reassoc_req->bssDescription.ieFields;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700307 is_vendor_ap_1_present = (wlan_get_vendor_ie_ptr_from_oui(
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700308 SIR_MAC_VENDOR_AP_1_OUI, SIR_MAC_VENDOR_AP_1_OUI_LEN,
309 bss_ies, bss_ie_len) != NULL);
310
311 if (mac_ctx->roam.configParam.is_force_1x1 &&
Krunal Sonie6a1cda2017-09-27 15:23:02 -0700312 is_vendor_ap_1_present && (session_entry->nss == 2) &&
313 (mac_ctx->lteCoexAntShare == 0 ||
314 IS_5G_CH(session_entry->currentOperChannel))) {
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700315 /* SET vdev param */
316 pe_debug("sending SMPS intolrent vdev_param");
317 wma_cli_set_command(session_entry->smeSessionId,
318 (int)WMI_VDEV_PARAM_SMPS_INTOLERANT,
319 1, VDEV_CMD);
320
321 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800322 } else {
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700323 if (session_entry->beacon) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530324 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800325 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530326 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800327 }
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700328 if (session_entry->assocReq) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530329 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800330 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530331 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800332 }
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700333 if (session_entry->assocRsp) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530334 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800335 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530336 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800337 }
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700338 if (session_entry->ricData) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530339 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800340 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530341 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800342 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800343#ifdef FEATURE_WLAN_ESE
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700344 if (session_entry->tspecIes) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530345 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800346 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530347 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800348 }
349#endif
350 }
351}
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530352
353/**
354 * lim_add_bss_info() - copy data from session entry to join rsp
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530355 * @sta_ds: Station dph entry
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530356 * @sme_join_rsp: Join response buffer to be filled up
357 *
358 * Return: None
359 */
Jeff Johnson2df04b82019-02-02 23:30:25 -0800360static void lim_add_bss_info(tpDphHashNode sta_ds,
361 struct join_rsp *sme_join_rsp)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530362{
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530363 struct parsed_ies *parsed_ies = &sta_ds->parsed_ies;
364
365 if (parsed_ies->hs20vendor_ie.present)
366 sme_join_rsp->hs20vendor_ie = parsed_ies->hs20vendor_ie;
367 if (parsed_ies->vht_caps.present)
368 sme_join_rsp->vht_caps = parsed_ies->vht_caps;
369 if (parsed_ies->ht_caps.present)
370 sme_join_rsp->ht_caps = parsed_ies->ht_caps;
371 if (parsed_ies->ht_operation.present)
372 sme_join_rsp->ht_operation = parsed_ies->ht_operation;
373 if (parsed_ies->vht_operation.present)
374 sme_join_rsp->vht_operation = parsed_ies->vht_operation;
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530375}
376
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530377#ifdef WLAN_FEATURE_FILS_SK
Jeff Johnson2df04b82019-02-02 23:30:25 -0800378static void lim_update_fils_seq_num(struct join_rsp *sme_join_rsp,
Jeff Johnsond7035a32018-11-18 22:03:13 -0800379 struct pe_session *session_entry)
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530380{
381 sme_join_rsp->fils_seq_num =
382 session_entry->fils_info->sequence_number;
383}
384#else
Jeff Johnson2df04b82019-02-02 23:30:25 -0800385static inline void lim_update_fils_seq_num(struct join_rsp *sme_join_rsp,
Jeff Johnsond7035a32018-11-18 22:03:13 -0800386 struct pe_session *session_entry)
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530387{}
388#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800389
Jeff Johnson27b98962019-02-20 20:53:08 -0800390void lim_send_sme_join_reassoc_rsp(struct mac_context *mac_ctx,
391 uint16_t msg_type,
392 tSirResultCodes result_code,
393 uint16_t prot_status_code,
394 struct pe_session *session_entry,
395 uint8_t sme_session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800396{
Jeff Johnson2df04b82019-02-02 23:30:25 -0800397 struct join_rsp *sme_join_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800398 uint32_t rsp_len;
399 tpDphHashNode sta_ds = NULL;
400#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
401 if (msg_type == eWNI_SME_REASSOC_RSP)
402 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_RSP_EVENT,
403 session_entry, (uint16_t) result_code, 0);
404 else
405 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_RSP_EVENT,
406 session_entry, (uint16_t) result_code, 0);
407#endif /* FEATURE_WLAN_DIAG_SUPPORT */
408
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530409 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800410 lim_msg_str(msg_type), lim_result_code_str(result_code));
411
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700412 if (!session_entry) {
Jeff Johnson2df04b82019-02-02 23:30:25 -0800413 rsp_len = sizeof(*sme_join_rsp);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530414 sme_join_rsp = qdf_mem_malloc(rsp_len);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700415 if (!sme_join_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800416 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800417
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800418 sme_join_rsp->beaconLength = 0;
419 sme_join_rsp->assocReqLength = 0;
420 sme_join_rsp->assocRspLength = 0;
421 } else {
422 rsp_len = session_entry->assocReqLen +
423 session_entry->assocRspLen + session_entry->bcnLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800424 session_entry->RICDataLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800425#ifdef FEATURE_WLAN_ESE
426 session_entry->tspecLen +
427#endif
Jeff Johnson2df04b82019-02-02 23:30:25 -0800428 sizeof(*sme_join_rsp) - sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530429 sme_join_rsp = qdf_mem_malloc(rsp_len);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700430 if (!sme_join_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800431 return;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530432
433 if (lim_is_fils_connection(session_entry)) {
434 sme_join_rsp->is_fils_connection = true;
435 lim_update_fils_seq_num(sme_join_rsp,
436 session_entry);
437 }
438
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800439 if (result_code == eSIR_SME_SUCCESS) {
440 sta_ds = dph_get_hash_entry(mac_ctx,
441 DPH_STA_HASH_INDEX_PEER,
442 &session_entry->dph.dphHashTable);
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700443 if (!sta_ds) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530444 pe_err("Get Self Sta Entry fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800445 } else {
446 /* Pass the peer's staId */
447 sme_join_rsp->staId = sta_ds->staIndex;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800448 sme_join_rsp->timingMeasCap =
449 sta_ds->timingMeasCap;
450#ifdef FEATURE_WLAN_TDLS
451 sme_join_rsp->tdls_prohibited =
452 session_entry->tdls_prohibited;
453 sme_join_rsp->tdls_chan_swit_prohibited =
454 session_entry->tdls_chan_swit_prohibited;
455#endif
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530456 sme_join_rsp->nss = sta_ds->nss;
457 sme_join_rsp->max_rate_flags =
458 lim_get_max_rate_flags(mac_ctx, sta_ds);
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530459 lim_add_bss_info(sta_ds, sme_join_rsp);
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530460
461 /* Copy FILS params only for Successful join */
462 populate_fils_connect_params(mac_ctx,
463 session_entry, sme_join_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800464 }
465 }
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530466
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800467 sme_join_rsp->beaconLength = 0;
468 sme_join_rsp->assocReqLength = 0;
469 sme_join_rsp->assocRspLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800470 sme_join_rsp->parsedRicRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800471#ifdef FEATURE_WLAN_ESE
472 sme_join_rsp->tspecIeLen = 0;
473#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800474 lim_handle_join_rsp_status(mac_ctx, session_entry, result_code,
475 sme_join_rsp);
Bala Venkateshe7f79162019-01-16 16:43:59 +0530476 sme_join_rsp->uapsd_mask = session_entry->gUapsdPerAcBitmask;
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800477 /* Send supported NSS 1x1 to SME */
478 sme_join_rsp->supported_nss_1x1 =
479 session_entry->supported_nss_1x1;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530480 pe_debug("SME Join Rsp is supported NSS 1X1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800481 sme_join_rsp->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800482 }
483
484 sme_join_rsp->messageType = msg_type;
485 sme_join_rsp->length = (uint16_t) rsp_len;
486 sme_join_rsp->statusCode = result_code;
487 sme_join_rsp->protStatusCode = prot_status_code;
488
489 sme_join_rsp->sessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800490
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530491 lim_send_sme_join_reassoc_rsp_after_resume(mac_ctx, QDF_STATUS_SUCCESS,
Jeff Johnson2df04b82019-02-02 23:30:25 -0800492 sme_join_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800493}
494
Jeff Johnson9e3d8992019-02-20 20:11:48 -0800495void lim_send_sme_start_bss_rsp(struct mac_context *mac,
496 uint16_t msgType,
497 tSirResultCodes resultCode,
498 struct pe_session *pe_session,
499 uint8_t smesessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800500{
501
502 uint16_t size = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700503 struct scheduler_msg mmhMsg = {0};
Jeff Johnsona0d34622019-02-02 17:26:19 -0800504 struct start_bss_rsp *pSirSmeRsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800505 uint16_t ieLen;
506 uint16_t ieOffset, curLen;
507
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530508 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800509 lim_msg_str(msgType), lim_result_code_str(resultCode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800510
Jeff Johnsona0d34622019-02-02 17:26:19 -0800511 size = sizeof(struct start_bss_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800512
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700513 if (!pe_session) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530514 pSirSmeRsp = qdf_mem_malloc(size);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700515 if (!pSirSmeRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800516 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800517 } else {
518 /* subtract size of beaconLength + Mac Hdr + Fixed Fields before SSID */
519 ieOffset = sizeof(tAniBeaconStruct) + SIR_MAC_B_PR_SSID_OFFSET;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800520 ieLen = pe_session->schBeaconOffsetBegin
521 + pe_session->schBeaconOffsetEnd - ieOffset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800522 /* calculate the memory size to allocate */
523 size += ieLen;
524
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530525 pSirSmeRsp = qdf_mem_malloc(size);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700526 if (!pSirSmeRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800527 return;
Jeff Johnsona0d34622019-02-02 17:26:19 -0800528 size = sizeof(struct start_bss_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800529 if (resultCode == eSIR_SME_SUCCESS) {
530
531 sir_copy_mac_addr(pSirSmeRsp->bssDescription.bssId,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800532 pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800533
534 /* Read beacon interval from session */
535 pSirSmeRsp->bssDescription.beaconInterval =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800536 (uint16_t) pe_session->beaconParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800537 beaconInterval;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800538 pSirSmeRsp->bssType = pe_session->bssType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800539
Wu Gao5c3d94b2019-01-17 21:15:54 +0800540 if (lim_get_capability_info
Jeff Johnson35c58a82018-11-22 15:04:57 -0800541 (mac, &pSirSmeRsp->bssDescription.capabilityInfo,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800542 pe_session)
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700543 != QDF_STATUS_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530544 pe_err("could not retrieve Capabilities value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800545
Jeff Johnson35c58a82018-11-22 15:04:57 -0800546 lim_get_phy_mode(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800547 (uint32_t *) &pSirSmeRsp->bssDescription.
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800548 nwType, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800549
550 pSirSmeRsp->bssDescription.channelId =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800551 pe_session->currentOperChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800552
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800553 if (!LIM_IS_NDI_ROLE(pe_session)) {
554 curLen = pe_session->schBeaconOffsetBegin - ieOffset;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530555 qdf_mem_copy((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800556 ieFields,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800557 pe_session->pSchBeaconFrameBegin +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800558 ieOffset, (uint32_t) curLen);
559
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530560 qdf_mem_copy(((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800561 ieFields) + curLen,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800562 pe_session->pSchBeaconFrameEnd,
563 (uint32_t) pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800564 schBeaconOffsetEnd);
565
Abhishek Singh34a4d862016-10-26 16:01:51 +0530566 pSirSmeRsp->bssDescription.length = (uint16_t)
567 (offsetof(tSirBssDescription, ieFields[0])
568 - sizeof(pSirSmeRsp->bssDescription.length)
569 + ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800570 /* This is the size of the message, subtracting the size of the pointer to ieFields */
571 size += ieLen - sizeof(uint32_t);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700572 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800573#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800574 if (pe_session->cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530575 != QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Jeff Johnsonf6541882019-02-02 16:16:00 -0800576 pSirSmeRsp->ht_profile.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800577 htSupportedChannelWidthSet =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800578 pe_session->htSupportedChannelWidthSet;
Jeff Johnsonf6541882019-02-02 16:16:00 -0800579 pSirSmeRsp->ht_profile.htRecommendedTxWidthSet =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800580 pe_session->htRecommendedTxWidthSet;
Jeff Johnsonf6541882019-02-02 16:16:00 -0800581 pSirSmeRsp->ht_profile.htSecondaryChannelOffset =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800582 pe_session->htSecondaryChannelOffset;
Jeff Johnsonf6541882019-02-02 16:16:00 -0800583 pSirSmeRsp->ht_profile.dot11mode =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800584 pe_session->dot11mode;
Jeff Johnsonf6541882019-02-02 16:16:00 -0800585 pSirSmeRsp->ht_profile.htCapability =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800586 pe_session->htCapability;
Jeff Johnsonf6541882019-02-02 16:16:00 -0800587 pSirSmeRsp->ht_profile.vhtCapability =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800588 pe_session->vhtCapability;
Jeff Johnsonf6541882019-02-02 16:16:00 -0800589 pSirSmeRsp->ht_profile.apCenterChan =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800590 pe_session->ch_center_freq_seg0;
Jeff Johnsonf6541882019-02-02 16:16:00 -0800591 pSirSmeRsp->ht_profile.apChanWidth =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800592 pe_session->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800593 }
594#endif
595 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800596 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800597 pSirSmeRsp->messageType = msgType;
598 pSirSmeRsp->length = size;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800599 pSirSmeRsp->sessionId = smesessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800600 pSirSmeRsp->statusCode = resultCode;
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700601 if (pe_session)
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800602 pSirSmeRsp->staId = pe_session->staId; /* else it will be always zero smeRsp StaID = 0 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800603
604 mmhMsg.type = msgType;
605 mmhMsg.bodyptr = pSirSmeRsp;
606 mmhMsg.bodyval = 0;
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700607 if (!pe_session) {
Jeff Johnson35c58a82018-11-22 15:04:57 -0800608 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530609 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800610 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -0800611 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800612 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800613 }
614#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -0800615 lim_diag_event_report(mac, WLAN_PE_DIAG_START_BSS_RSP_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800616 pe_session, (uint16_t) resultCode, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800617#endif /* FEATURE_WLAN_DIAG_SUPPORT */
618
Jeff Johnsona5abe272019-01-06 12:52:02 -0800619 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800620} /*** end lim_send_sme_start_bss_rsp() ***/
621
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800622void lim_send_sme_disassoc_deauth_ntf(struct mac_context *mac,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530623 QDF_STATUS status, uint32_t *pCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800624{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700625 struct scheduler_msg mmhMsg = {0};
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800626 struct scheduler_msg *pMsg = (struct scheduler_msg *) pCtx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800627
628 mmhMsg.type = pMsg->type;
629 mmhMsg.bodyptr = pMsg;
630 mmhMsg.bodyval = 0;
631
Jeff Johnson35c58a82018-11-22 15:04:57 -0800632 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800633
Jeff Johnsona5abe272019-01-06 12:52:02 -0800634 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800635}
636
Jeff Johnsonb82e6d72019-02-20 21:32:32 -0800637void lim_send_sme_disassoc_ntf(struct mac_context *mac,
638 tSirMacAddr peerMacAddr,
639 tSirResultCodes reasonCode,
640 uint16_t disassocTrigger,
641 uint16_t aid,
642 uint8_t smesessionId,
643 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800644{
Jeff Johnson380a1cd2019-02-03 21:43:51 -0800645 struct disassoc_rsp *pSirSmeDisassocRsp;
Jeff Johnson318a9882019-02-04 08:30:50 -0800646 struct disassoc_ind *pSirSmeDisassocInd;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700647 uint32_t *pMsg = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800648 bool failure = false;
Jeff Johnsond7035a32018-11-18 22:03:13 -0800649 struct pe_session *session = NULL;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700650 uint16_t i, assoc_id;
651 tpDphHashNode sta_ds = NULL;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +0530652 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800653
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530654 pe_debug("Disassoc Ntf with trigger : %d reasonCode: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800655 disassocTrigger, reasonCode);
656
657 switch (disassocTrigger) {
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700658 case eLIM_DUPLICATE_ENTRY:
659 /*
660 * Duplicate entry is removed at LIM.
661 * Initiate new entry for other session
662 */
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -0700663 pe_debug("Rcvd eLIM_DUPLICATE_ENTRY for " QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -0700664 QDF_MAC_ADDR_ARRAY(peerMacAddr));
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700665
Jeff Johnson35c58a82018-11-22 15:04:57 -0800666 for (i = 0; i < mac->lim.maxBssId; i++) {
Jeff Johnsoneac5aad2019-03-19 12:57:04 -0700667 session = &mac->lim.gpSession[i];
668 if (session->valid &&
669 (session->pePersona == QDF_SAP_MODE)) {
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700670 /* Find the sta ds entry in another session */
Jeff Johnson35c58a82018-11-22 15:04:57 -0800671 sta_ds = dph_lookup_hash_entry(mac,
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700672 peerMacAddr, &assoc_id,
673 &session->dph.dphHashTable);
Abhishek Singh6d6e3d12017-12-04 14:16:00 +0530674 if (sta_ds)
675 break;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700676 }
677 }
678 if (sta_ds
679#ifdef WLAN_FEATURE_11W
680 && (!sta_ds->rmfEnabled)
681#endif
682 ) {
Jeff Johnson35c58a82018-11-22 15:04:57 -0800683 if (lim_add_sta(mac, sta_ds, false, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700684 QDF_STATUS_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530685 pe_err("could not Add STA with assocId: %d",
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700686 sta_ds->assocId);
687 }
Jeff Johnson35c58a82018-11-22 15:04:57 -0800688 status = lim_prepare_disconnect_done_ind(mac, &pMsg,
Pragaspathi Thilagaraj766c76f2018-08-08 16:44:40 +0530689 smesessionId,
690 reasonCode,
691 &peerMacAddr[0]);
692 if (!QDF_IS_STATUS_SUCCESS(status)) {
693 pe_err("Failed to prepare message");
694 return;
695 }
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700696 break;
697
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800698 case eLIM_HOST_DISASSOC:
699 /**
700 * Disassociation response due to
701 * host triggered disassociation
702 */
703
Jeff Johnson380a1cd2019-02-03 21:43:51 -0800704 pSirSmeDisassocRsp = qdf_mem_malloc(sizeof(struct disassoc_rsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700705 if (!pSirSmeDisassocRsp) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800706 failure = true;
707 goto error;
708 }
Jeff Johnsonff1fd432019-02-20 09:50:54 -0800709 pe_debug("send eWNI_SME_DISASSOC_RSP with retCode: %d for "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -0700710 QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -0700711 reasonCode, QDF_MAC_ADDR_ARRAY(peerMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800712 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
Jeff Johnson380a1cd2019-02-03 21:43:51 -0800713 pSirSmeDisassocRsp->length = sizeof(struct disassoc_rsp);
Jeff Johnsonff1fd432019-02-20 09:50:54 -0800714 pSirSmeDisassocRsp->sessionId = smesessionId;
Jeff Johnsonff1fd432019-02-20 09:50:54 -0800715 pSirSmeDisassocRsp->statusCode = reasonCode;
716 qdf_mem_copy(pSirSmeDisassocRsp->peer_macaddr.bytes,
717 peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800718
719#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
720
Jeff Johnson35c58a82018-11-22 15:04:57 -0800721 lim_diag_event_report(mac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800722 pe_session, (uint16_t) reasonCode, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800723#endif
724 pMsg = (uint32_t *) pSirSmeDisassocRsp;
725 break;
726
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530727 case eLIM_PEER_ENTITY_DISASSOC:
728 case eLIM_LINK_MONITORING_DISASSOC:
Jeff Johnson35c58a82018-11-22 15:04:57 -0800729 status = lim_prepare_disconnect_done_ind(mac, &pMsg,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +0530730 smesessionId,
731 reasonCode, &peerMacAddr[0]);
732 if (!QDF_IS_STATUS_SUCCESS(status)) {
733 pe_err("Failed to prepare message");
734 return;
735 }
736 break;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530737
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800738 default:
739 /**
740 * Disassociation indication due to Disassociation
741 * frame reception from peer entity or due to
742 * loss of link with peer entity.
743 */
Jeff Johnson318a9882019-02-04 08:30:50 -0800744 pSirSmeDisassocInd =
745 qdf_mem_malloc(sizeof(*pSirSmeDisassocInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700746 if (!pSirSmeDisassocInd) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800747 failure = true;
748 goto error;
749 }
Jeff Johnsonff1fd432019-02-20 09:50:54 -0800750 pe_debug("send eWNI_SME_DISASSOC_IND with retCode: %d for "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -0700751 QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -0700752 reasonCode, QDF_MAC_ADDR_ARRAY(peerMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800753 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
Jeff Johnson318a9882019-02-04 08:30:50 -0800754 pSirSmeDisassocInd->length = sizeof(*pSirSmeDisassocInd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800755 pSirSmeDisassocInd->sessionId = smesessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800756 pSirSmeDisassocInd->reasonCode = reasonCode;
Jeff Johnsonff1fd432019-02-20 09:50:54 -0800757 pSirSmeDisassocInd->statusCode = reasonCode;
758 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes,
759 pe_session->bssId, sizeof(tSirMacAddr));
760 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes,
761 peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800762
763#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -0800764 lim_diag_event_report(mac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800765 pe_session, (uint16_t) reasonCode, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800766#endif
767 pMsg = (uint32_t *) pSirSmeDisassocInd;
768
769 break;
770 }
771
772error:
773 /* Delete the PE session Created */
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700774 if ((pe_session) && LIM_IS_STA_ROLE(pe_session))
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800775 pe_delete_session(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800776
777 if (false == failure)
Jeff Johnson35c58a82018-11-22 15:04:57 -0800778 lim_send_sme_disassoc_deauth_ntf(mac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800779 (uint32_t *) pMsg);
780} /*** end lim_send_sme_disassoc_ntf() ***/
781
782/** -----------------------------------------------------------------
783 \brief lim_send_sme_disassoc_ind() - sends SME_DISASSOC_IND
784
785 After receiving disassociation frame from peer entity, this
786 function sends a eWNI_SME_DISASSOC_IND to SME with a specific
787 reason code.
788
Jeff Johnson35c58a82018-11-22 15:04:57 -0800789 \param mac - global mac structure
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800790 \param sta - station dph hash node
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800791 \return none
792 \sa
793 ----------------------------------------------------------------- */
794void
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800795lim_send_sme_disassoc_ind(struct mac_context *mac, tpDphHashNode sta,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800796 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800797{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700798 struct scheduler_msg mmhMsg = {0};
Jeff Johnson318a9882019-02-04 08:30:50 -0800799 struct disassoc_ind *pSirSmeDisassocInd;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800800
Jeff Johnson318a9882019-02-04 08:30:50 -0800801 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(*pSirSmeDisassocInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700802 if (!pSirSmeDisassocInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800803 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800804
805 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
Jeff Johnson318a9882019-02-04 08:30:50 -0800806 pSirSmeDisassocInd->length = sizeof(*pSirSmeDisassocInd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800807
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800808 pSirSmeDisassocInd->sessionId = pe_session->smeSessionId;
Padma, Santhosh Kumar02289212016-09-30 13:30:08 +0530809 pSirSmeDisassocInd->statusCode = eSIR_SME_DEAUTH_STATUS;
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800810 pSirSmeDisassocInd->reasonCode = sta->mlmStaContext.disassocReason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800811
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800812 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes, pe_session->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530813 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800814
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800815 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes, sta->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530816 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800817
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800818 pSirSmeDisassocInd->staId = sta->staIndex;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800819
820 mmhMsg.type = eWNI_SME_DISASSOC_IND;
821 mmhMsg.bodyptr = pSirSmeDisassocInd;
822 mmhMsg.bodyval = 0;
823
Jeff Johnson35c58a82018-11-22 15:04:57 -0800824 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800825 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800826#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800827 lim_diag_event_report(mac, WLAN_PE_DIAG_DISASSOC_IND_EVENT, pe_session,
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800828 0, (uint16_t) sta->mlmStaContext.disassocReason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800829#endif /* FEATURE_WLAN_DIAG_SUPPORT */
830
Jeff Johnsona5abe272019-01-06 12:52:02 -0800831 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800832
833} /*** end lim_send_sme_disassoc_ind() ***/
834
835/** -----------------------------------------------------------------
836 \brief lim_send_sme_deauth_ind() - sends SME_DEAUTH_IND
837
838 After receiving deauthentication frame from peer entity, this
839 function sends a eWNI_SME_DEAUTH_IND to SME with a specific
840 reason code.
841
Jeff Johnson35c58a82018-11-22 15:04:57 -0800842 \param mac - global mac structure
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800843 \param sta - station dph hash node
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800844 \return none
845 \sa
846 ----------------------------------------------------------------- */
847void
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800848lim_send_sme_deauth_ind(struct mac_context *mac, tpDphHashNode sta,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800849 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800850{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700851 struct scheduler_msg mmhMsg = {0};
Jeff Johnsonfec08712019-02-04 13:12:08 -0800852 struct deauth_ind *pSirSmeDeauthInd;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800853
Jeff Johnsonfec08712019-02-04 13:12:08 -0800854 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(*pSirSmeDeauthInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700855 if (!pSirSmeDeauthInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800856 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800857
858 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
Jeff Johnsonfec08712019-02-04 13:12:08 -0800859 pSirSmeDeauthInd->length = sizeof(*pSirSmeDeauthInd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800860
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800861 pSirSmeDeauthInd->sessionId = pe_session->smeSessionId;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800862 if (eSIR_INFRA_AP_MODE == pe_session->bssType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800863 pSirSmeDeauthInd->statusCode =
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800864 (tSirResultCodes) sta->mlmStaContext.cleanupTrigger;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800865 } else {
Jeff Johnsonfec08712019-02-04 13:12:08 -0800866 /* Need to indicate the reason code over the air */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800867 pSirSmeDeauthInd->statusCode =
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800868 (tSirResultCodes) sta->mlmStaContext.disassocReason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800869 }
870 /* BSSID */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800871 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, pe_session->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530872 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800873 /* peerMacAddr */
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800874 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, sta->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530875 QDF_MAC_ADDR_SIZE);
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800876 pSirSmeDeauthInd->reasonCode = sta->mlmStaContext.disassocReason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800877
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800878 pSirSmeDeauthInd->staId = sta->staIndex;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -0800879 if (eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON ==
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800880 sta->mlmStaContext.disassocReason)
881 pSirSmeDeauthInd->rssi = sta->del_sta_ctx_rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800882
883 mmhMsg.type = eWNI_SME_DEAUTH_IND;
884 mmhMsg.bodyptr = pSirSmeDeauthInd;
885 mmhMsg.bodyval = 0;
886
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800887 MTRACE(mac_trace_msg_tx(mac, pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800888#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800889 lim_diag_event_report(mac, WLAN_PE_DIAG_DEAUTH_IND_EVENT, pe_session,
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800890 0, sta->mlmStaContext.cleanupTrigger);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800891#endif /* FEATURE_WLAN_DIAG_SUPPORT */
892
Jeff Johnsona5abe272019-01-06 12:52:02 -0800893 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800894 return;
895} /*** end lim_send_sme_deauth_ind() ***/
896
897#ifdef FEATURE_WLAN_TDLS
898/**
899 * lim_send_sme_tdls_del_sta_ind()
900 *
901 ***FUNCTION:
902 * This function is called to send the TDLS STA context deletion to SME.
903 *
904 ***LOGIC:
905 *
906 ***ASSUMPTIONS:
907 *
908 ***NOTE:
909 * NA
910 *
Jeff Johnson35c58a82018-11-22 15:04:57 -0800911 * @param mac - Pointer to global MAC structure
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800912 * @param sta - Pointer to internal STA Datastructure
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800913 * @param pe_session - Pointer to the session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800914 * @param reasonCode - Reason for TDLS sta deletion
915 * @return None
916 */
917void
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800918lim_send_sme_tdls_del_sta_ind(struct mac_context *mac, tpDphHashNode sta,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800919 struct pe_session *pe_session, uint16_t reasonCode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800920{
Frank Liud1a28462017-09-06 22:55:48 +0800921 struct tdls_event_info info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800922
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -0700923 pe_debug("Delete TDLS Peer "QDF_MAC_ADDR_STR "with reason code: %d",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -0700924 QDF_MAC_ADDR_ARRAY(sta->staAddr), reasonCode);
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800925 info.vdev_id = pe_session->smeSessionId;
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800926 qdf_mem_copy(info.peermac.bytes, sta->staAddr, QDF_MAC_ADDR_SIZE);
Frank Liud1a28462017-09-06 22:55:48 +0800927 info.message_type = TDLS_PEER_DISCONNECTED;
928 info.peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800929
Jeff Johnson35c58a82018-11-22 15:04:57 -0800930 tgt_tdls_event_handler(mac->psoc, &info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800931
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800932 return;
933} /*** end lim_send_sme_tdls_del_sta_ind() ***/
934
935/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800936 * lim_send_sme_mgmt_tx_completion()
937 *
938 ***FUNCTION:
939 * This function is called to send the eWNI_SME_MGMT_FRM_TX_COMPLETION_IND
940 * message to SME.
941 *
942 ***LOGIC:
943 *
944 ***ASSUMPTIONS:
945 *
946 ***NOTE:
947 * NA
948 *
Jeff Johnson35c58a82018-11-22 15:04:57 -0800949 * @param mac - Pointer to global MAC structure
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 txCompleteStatus - TX Complete Status of Mgmt Frames
952 * @return None
953 */
954void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800955lim_send_sme_mgmt_tx_completion(struct mac_context *mac,
Ganesh Kondabattiniac570072016-12-21 12:45:48 +0530956 uint32_t sme_session_id,
957 uint32_t txCompleteStatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800958{
Wu Gao6768d762018-12-28 16:31:08 +0800959 struct scheduler_msg msg = {0};
960 struct tdls_mgmt_tx_completion_ind *mgmt_tx_completion_ind;
961 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800962
Wu Gao6768d762018-12-28 16:31:08 +0800963 mgmt_tx_completion_ind =
964 qdf_mem_malloc(sizeof(*mgmt_tx_completion_ind));
965 if (!mgmt_tx_completion_ind)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800966 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800967
968 /* sessionId */
Wu Gao6768d762018-12-28 16:31:08 +0800969 mgmt_tx_completion_ind->session_id = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800970
Wu Gao6768d762018-12-28 16:31:08 +0800971 mgmt_tx_completion_ind->tx_complete_status = txCompleteStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800972
Wu Gao6768d762018-12-28 16:31:08 +0800973 msg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
974 msg.bodyptr = mgmt_tx_completion_ind;
975 msg.bodyval = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800976
Wu Gao6768d762018-12-28 16:31:08 +0800977 mgmt_tx_completion_ind->psoc = mac->psoc;
978 msg.callback = tgt_tdls_send_mgmt_tx_completion;
979 status = scheduler_post_message(QDF_MODULE_ID_PE,
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +0530980 QDF_MODULE_ID_TDLS,
Wu Gao6768d762018-12-28 16:31:08 +0800981 QDF_MODULE_ID_TARGET_IF, &msg);
982 if (QDF_IS_STATUS_ERROR(status)) {
983 pe_err("post msg fail, %d", status);
984 qdf_mem_free(mgmt_tx_completion_ind);
985 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800986} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
987
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800988#endif /* FEATURE_WLAN_TDLS */
989
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800990QDF_STATUS lim_prepare_disconnect_done_ind(struct mac_context *mac_ctx,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +0530991 uint32_t **msg,
992 uint8_t session_id,
993 tSirResultCodes reason_code,
994 uint8_t *peer_mac_addr)
Himanshu Agarwald519b4a2018-03-27 15:36:09 +0530995{
996 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +0530997
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +0530998 sir_sme_dis_ind = qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700999 if (!sir_sme_dis_ind)
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301000 return QDF_STATUS_E_FAILURE;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301001
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301002 pe_debug("Prepare eWNI_SME_DISCONNECT_DONE_IND withretCode: %d",
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301003 reason_code);
1004
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301005 sir_sme_dis_ind->message_type = eWNI_SME_DISCONNECT_DONE_IND;
1006 sir_sme_dis_ind->length = sizeof(*sir_sme_dis_ind);
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301007 sir_sme_dis_ind->session_id = session_id;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301008 if (peer_mac_addr)
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05301009 qdf_mem_copy(sir_sme_dis_ind->peer_mac,
1010 peer_mac_addr, ETH_ALEN);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301011
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301012 /*
1013 * Instead of sending deauth reason code as 505 which is
1014 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1015 * Send reason code as zero to Supplicant
1016 */
1017 if (reason_code == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1018 sir_sme_dis_ind->reason_code = 0;
1019 else
1020 sir_sme_dis_ind->reason_code = reason_code;
1021
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301022 *msg = (uint32_t *)sir_sme_dis_ind;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301023
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301024 return QDF_STATUS_SUCCESS;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301025}
1026
Jeff Johnson953f99a2019-02-20 22:08:31 -08001027void lim_send_sme_deauth_ntf(struct mac_context *mac, tSirMacAddr peerMacAddr,
1028 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1029 uint16_t aid, uint8_t smesessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001030{
1031 uint8_t *pBuf;
Jeff Johnson15ae0c12019-02-04 12:55:07 -08001032 struct deauth_rsp *pSirSmeDeauthRsp;
Jeff Johnsonfec08712019-02-04 13:12:08 -08001033 struct deauth_ind *pSirSmeDeauthInd;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001034 struct pe_session *pe_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001035 uint8_t sessionId;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301036 uint32_t *pMsg = NULL;
1037 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001038
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001039 pe_session = pe_find_session_by_bssid(mac, peerMacAddr, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040 switch (deauthTrigger) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001041 case eLIM_HOST_DEAUTH:
1042 /**
1043 * Deauthentication response to host triggered
1044 * deauthentication.
1045 */
Jeff Johnson15ae0c12019-02-04 12:55:07 -08001046 pSirSmeDeauthRsp = qdf_mem_malloc(sizeof(*pSirSmeDeauthRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001047 if (!pSirSmeDeauthRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001048 return;
Jeff Johnson15ae0c12019-02-04 12:55:07 -08001049 pe_debug("send eWNI_SME_DEAUTH_RSP with retCode: %d for "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07001050 QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07001051 reasonCode, QDF_MAC_ADDR_ARRAY(peerMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001052 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
Jeff Johnson15ae0c12019-02-04 12:55:07 -08001053 pSirSmeDeauthRsp->length = sizeof(*pSirSmeDeauthRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001054 pSirSmeDeauthRsp->statusCode = reasonCode;
1055 pSirSmeDeauthRsp->sessionId = smesessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001056
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -08001057 pBuf = (uint8_t *) pSirSmeDeauthRsp->peer_macaddr.bytes;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301058 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001059
1060#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -08001061 lim_diag_event_report(mac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001062 pe_session, 0, (uint16_t) reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001063#endif
1064 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1065
1066 break;
1067
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301068 case eLIM_PEER_ENTITY_DEAUTH:
1069 case eLIM_LINK_MONITORING_DEAUTH:
Jeff Johnson35c58a82018-11-22 15:04:57 -08001070 status = lim_prepare_disconnect_done_ind(mac, &pMsg,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301071 smesessionId, reasonCode,
1072 &peerMacAddr[0]);
1073 if (!QDF_IS_STATUS_SUCCESS(status)) {
1074 pe_err("Failed to prepare message");
1075 return;
1076 }
1077 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001078 default:
1079 /**
1080 * Deauthentication indication due to Deauthentication
1081 * frame reception from peer entity or due to
1082 * loss of link with peer entity.
1083 */
Jeff Johnsonfec08712019-02-04 13:12:08 -08001084 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(*pSirSmeDeauthInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001085 if (!pSirSmeDeauthInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001086 return;
Jeff Johnsonfec08712019-02-04 13:12:08 -08001087 pe_debug("send eWNI_SME_DEAUTH_IND with retCode: %d for "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07001088 QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07001089 reasonCode, QDF_MAC_ADDR_ARRAY(peerMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001090 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
Jeff Johnsonfec08712019-02-04 13:12:08 -08001091 pSirSmeDeauthInd->length = sizeof(*pSirSmeDeauthInd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001092 pSirSmeDeauthInd->reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
Jeff Johnson8ee46ef2019-02-20 18:34:17 -08001093 pSirSmeDeauthInd->sessionId = smesessionId;
Jeff Johnson8ee46ef2019-02-20 18:34:17 -08001094 pSirSmeDeauthInd->statusCode = reasonCode;
1095 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, pe_session->bssId,
1096 sizeof(tSirMacAddr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301097 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301098 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001099
1100#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -08001101 lim_diag_event_report(mac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001102 pe_session, 0, (uint16_t) reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001103#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1104 pMsg = (uint32_t *) pSirSmeDeauthInd;
1105
1106 break;
1107 }
1108
1109 /*Delete the PE session created */
Bala Venkatesh03b4f0c2019-01-28 22:00:50 +05301110 if (pe_session && LIM_IS_STA_ROLE(pe_session))
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001111 pe_delete_session(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001112
Jeff Johnson35c58a82018-11-22 15:04:57 -08001113 lim_send_sme_disassoc_deauth_ntf(mac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001114 (uint32_t *) pMsg);
1115
1116} /*** end lim_send_sme_deauth_ntf() ***/
1117
1118/**
1119 * lim_send_sme_wm_status_change_ntf() - Send Notification
1120 * @mac_ctx: Global MAC Context
1121 * @status_change_code: Indicates the change in the wireless medium.
1122 * @status_change_info: Indicates the information associated with
1123 * change in the wireless medium.
1124 * @info_len: Indicates the length of status change information
1125 * being sent.
1126 * @session_id SessionID
1127 *
1128 * This function is called by limProcessSmeMessages() to send
1129 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1130 *
1131 * Return: None
1132 */
1133void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001134lim_send_sme_wm_status_change_ntf(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001135 tSirSmeStatusChangeCode status_change_code,
1136 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1137{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001138 struct scheduler_msg msg = {0};
Jeff Johnson53889322019-02-03 17:37:09 -08001139 struct wm_status_change_ntf *wm_status_change_ntf;
Naveen Rawate01ed172016-11-17 11:34:50 -08001140 uint32_t max_info_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001141
Jeff Johnson53889322019-02-03 17:37:09 -08001142 wm_status_change_ntf = qdf_mem_malloc(sizeof(*wm_status_change_ntf));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001143 if (!wm_status_change_ntf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001144 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001145
1146 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1147 msg.bodyval = 0;
1148 msg.bodyptr = wm_status_change_ntf;
1149
1150 switch (status_change_code) {
Naveen Rawate01ed172016-11-17 11:34:50 -08001151 case eSIR_SME_AP_CAPS_CHANGED:
Jeff Johnson9c9961c2019-02-03 17:10:53 -08001152 max_info_len = sizeof(struct ap_new_caps);
Naveen Rawate01ed172016-11-17 11:34:50 -08001153 break;
1154 case eSIR_SME_JOINED_NEW_BSS:
Jeff Johnson2e6d1732019-02-03 17:00:30 -08001155 max_info_len = sizeof(struct new_bss_info);
Naveen Rawate01ed172016-11-17 11:34:50 -08001156 break;
1157 default:
1158 max_info_len = sizeof(wm_status_change_ntf->statusChangeInfo);
1159 break;
1160 }
1161
1162 switch (status_change_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001163 case eSIR_SME_RADAR_DETECTED:
1164 break;
1165 default:
1166 wm_status_change_ntf->messageType =
1167 eWNI_SME_WM_STATUS_CHANGE_NTF;
1168 wm_status_change_ntf->statusChangeCode = status_change_code;
Jeff Johnson53889322019-02-03 17:37:09 -08001169 wm_status_change_ntf->length = sizeof(*wm_status_change_ntf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001170 wm_status_change_ntf->sessionId = session_id;
Naveen Rawate01ed172016-11-17 11:34:50 -08001171 if (info_len <= max_info_len && status_change_info) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301172 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001173 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1174 (uint8_t *) status_change_info, info_len);
1175 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301176 pe_debug("StatusChg code: 0x%x length: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001177 status_change_code, info_len);
1178 break;
1179 }
1180
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301181 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, session_id, msg.type));
Harprit Chhabadae20b5562019-03-11 14:13:42 -07001182 lim_sys_process_mmh_msg_api(mac_ctx, &msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001183
1184} /*** end lim_send_sme_wm_status_change_ntf() ***/
1185
Jeff Johnsonc80ed542019-02-21 06:24:57 -08001186void lim_send_sme_set_context_rsp(struct mac_context *mac,
1187 struct qdf_mac_addr peer_macaddr,
1188 uint16_t aid,
1189 tSirResultCodes resultCode,
1190 struct pe_session *pe_session,
1191 uint8_t smesessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001192{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001193 struct scheduler_msg mmhMsg = {0};
Jeff Johnson924ae612019-02-05 12:01:50 -08001194 struct set_context_rsp *set_context_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001195
Jeff Johnson924ae612019-02-05 12:01:50 -08001196 set_context_rsp = qdf_mem_malloc(sizeof(*set_context_rsp));
1197 if (!set_context_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001198 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001199
Jeff Johnson924ae612019-02-05 12:01:50 -08001200 set_context_rsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1201 set_context_rsp->length = sizeof(*set_context_rsp);
1202 set_context_rsp->statusCode = resultCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001203
Jeff Johnson924ae612019-02-05 12:01:50 -08001204 qdf_copy_macaddr(&set_context_rsp->peer_macaddr, &peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001205
Jeff Johnson924ae612019-02-05 12:01:50 -08001206 set_context_rsp->sessionId = smesessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001207
1208 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
Jeff Johnson924ae612019-02-05 12:01:50 -08001209 mmhMsg.bodyptr = set_context_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001210 mmhMsg.bodyval = 0;
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001211 if (!pe_session) {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001212 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301213 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001214 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001215 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001216 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001217 }
1218
1219#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -08001220 lim_diag_event_report(mac, WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001221 pe_session, (uint16_t) resultCode, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001222#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1223
Jeff Johnson35c58a82018-11-22 15:04:57 -08001224 mac->lim.sme_msg_callback(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001225} /*** end lim_send_sme_set_context_rsp() ***/
1226
Jeff Johnson07819492019-02-21 09:34:02 -08001227void lim_send_sme_addts_rsp(struct mac_context *mac,
1228 uint8_t rspReqd, uint32_t status,
1229 struct pe_session *pe_session,
1230 struct mac_tspec_ie tspec,
1231 uint8_t smesessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001232{
1233 tpSirAddtsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001234 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001235
1236 if (!rspReqd)
1237 return;
1238
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301239 rsp = qdf_mem_malloc(sizeof(tSirAddtsRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001240 if (!rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001241 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001242
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001243 rsp->messageType = eWNI_SME_ADDTS_RSP;
1244 rsp->rc = status;
Pragaspathi Thilagarajcb58bbc2019-05-23 15:34:51 +05301245 rsp->rsp.status = (enum mac_status_code)status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001246 rsp->rsp.tspec = tspec;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001247 rsp->sessionId = smesessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001248
1249 mmhMsg.type = eWNI_SME_ADDTS_RSP;
1250 mmhMsg.bodyptr = rsp;
1251 mmhMsg.bodyval = 0;
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001252 if (!pe_session) {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001253 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301254 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001255 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001256 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001257 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001258 }
1259#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001260 lim_diag_event_report(mac, WLAN_PE_DIAG_ADDTS_RSP_EVENT, pe_session, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001261 0);
1262#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1263
Jeff Johnsona5abe272019-01-06 12:52:02 -08001264 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001265 return;
1266}
1267
Jeff Johnsonb2b63e02019-02-21 09:46:03 -08001268void lim_send_sme_delts_rsp(struct mac_context *mac, tpSirDeltsReq delts,
1269 uint32_t status, struct pe_session *pe_session,
1270 uint8_t smesessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001271{
1272 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001273 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001274
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301275 pe_debug("SendSmeDeltsRsp aid: %d tsid: %d up: %d status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001276 delts->aid,
1277 delts->req.tsinfo.traffic.tsid,
1278 delts->req.tsinfo.traffic.userPrio, status);
1279 if (!delts->rspReqd)
1280 return;
1281
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301282 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001283 if (!rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001284 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001285
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001286 if (pe_session) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001287
1288 rsp->aid = delts->aid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301289 qdf_copy_macaddr(&rsp->macaddr, &delts->macaddr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301290 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) &delts->req,
Jeff Johnsoncf2ec162018-12-22 16:46:43 -08001291 sizeof(struct delts_req_info));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001292 }
1293
1294 rsp->messageType = eWNI_SME_DELTS_RSP;
1295 rsp->rc = status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001296 rsp->sessionId = smesessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001297
1298 mmhMsg.type = eWNI_SME_DELTS_RSP;
1299 mmhMsg.bodyptr = rsp;
1300 mmhMsg.bodyval = 0;
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001301 if (!pe_session) {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001302 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301303 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001304 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001305 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001306 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001307 }
1308#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001309 lim_diag_event_report(mac, WLAN_PE_DIAG_DELTS_RSP_EVENT, pe_session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001310 (uint16_t) status, 0);
1311#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1312
Jeff Johnsona5abe272019-01-06 12:52:02 -08001313 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001314}
1315
1316void
Jeff Johnsoncf2ec162018-12-22 16:46:43 -08001317lim_send_sme_delts_ind(struct mac_context *mac, struct delts_req_info *delts,
1318 uint16_t aid, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001319{
1320 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001321 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001322
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301323 pe_debug("SendSmeDeltsInd aid: %d tsid: %d up: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001324 aid, delts->tsinfo.traffic.tsid, delts->tsinfo.traffic.userPrio);
1325
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301326 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001327 if (!rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001328 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001329
1330 rsp->messageType = eWNI_SME_DELTS_IND;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001331 rsp->rc = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001332 rsp->aid = aid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301333 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) delts, sizeof(*delts));
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001334 rsp->sessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001335
1336 mmhMsg.type = eWNI_SME_DELTS_IND;
1337 mmhMsg.bodyptr = rsp;
1338 mmhMsg.bodyval = 0;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001339 MTRACE(mac_trace_msg_tx(mac, pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001340#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001341 lim_diag_event_report(mac, WLAN_PE_DIAG_DELTS_IND_EVENT, pe_session, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001342 0);
1343#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1344
Jeff Johnsona5abe272019-01-06 12:52:02 -08001345 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001346}
1347
Naveen Rawatfa2a1002018-05-17 16:06:37 -07001348#ifndef QCA_SUPPORT_CP_STATS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001349/**
1350 * lim_send_sme_pe_statistics_rsp()
1351 *
1352 ***FUNCTION:
1353 * This function is called to send 802.11 statistics response to HDD.
1354 * This function posts the result back to HDD. This is a response to
1355 * HDD's request for statistics.
1356 *
1357 ***PARAMS:
1358 *
1359 ***LOGIC:
1360 *
1361 ***ASSUMPTIONS:
1362 * NA
1363 *
1364 ***NOTE:
1365 * NA
1366 *
Jeff Johnson35c58a82018-11-22 15:04:57 -08001367 * @param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001368 * @param p80211Stats Statistics sent in response
1369 * @param resultCode TODO:
1370 *
1371 *
1372 * @return none
1373 */
1374
1375void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001376lim_send_sme_pe_statistics_rsp(struct mac_context *mac, uint16_t msgType, void *stats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001377{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001378 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001379 uint8_t sessionId;
1380 tAniGetPEStatsRsp *pPeStats = (tAniGetPEStatsRsp *) stats;
Jeff Johnsond7035a32018-11-18 22:03:13 -08001381 struct pe_session *pPeSessionEntry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001382
1383 /* Get the Session Id based on Sta Id */
1384 pPeSessionEntry =
Jeff Johnson35c58a82018-11-22 15:04:57 -08001385 pe_find_session_by_sta_id(mac, pPeStats->staId, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001386
1387 /* Fill the Session Id */
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001388 if (pPeSessionEntry) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001389 /* Fill the Session Id */
1390 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1391 }
1392
1393 pPeStats->msgType = eWNI_SME_GET_STATISTICS_RSP;
1394
1395 /* msgType should be WMA_GET_STATISTICS_RSP */
1396 mmhMsg.type = eWNI_SME_GET_STATISTICS_RSP;
1397
1398 mmhMsg.bodyptr = stats;
1399 mmhMsg.bodyval = 0;
Jeff Johnson35c58a82018-11-22 15:04:57 -08001400 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08001401 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001402
1403 return;
1404
1405} /*** end lim_send_sme_pe_statistics_rsp() ***/
Naveen Rawatfa2a1002018-05-17 16:06:37 -07001406#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001407
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001408#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001409/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001410 * lim_send_sme_pe_ese_tsm_rsp() - send tsm response
Jeff Johnson35c58a82018-11-22 15:04:57 -08001411 * @mac: Pointer to global mac structure
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001412 * @pStats: Pointer to TSM Stats
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001413 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001414 * This function is called to send tsm stats response to HDD.
1415 * This function posts the result back to HDD. This is a response to
1416 * HDD's request to get tsm stats.
1417 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001418 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001419 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001420void lim_send_sme_pe_ese_tsm_rsp(struct mac_context *mac,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001421 tAniGetTsmStatsRsp *pStats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001422{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001423 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001424 uint8_t sessionId;
1425 tAniGetTsmStatsRsp *pPeStats = (tAniGetTsmStatsRsp *) pStats;
Jeff Johnsond7035a32018-11-18 22:03:13 -08001426 struct pe_session *pPeSessionEntry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001427
1428 /* Get the Session Id based on Sta Id */
Abhinav Kumaraa8f2df2019-01-11 20:02:26 +05301429 pPeSessionEntry = pe_find_session_by_bssid(mac, pPeStats->bssid.bytes,
1430 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001431 /* Fill the Session Id */
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001432 if (pPeSessionEntry) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001433 /* Fill the Session Id */
1434 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1435 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301436 pe_err("Session not found for the Sta id: %d",
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301437 pPeStats->staId);
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05301438 qdf_mem_free(pPeStats->tsmStatsReq);
1439 qdf_mem_free(pPeStats);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001440 return;
1441 }
1442
1443 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
1444 pPeStats->tsmMetrics.RoamingCount
1445 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
1446 pPeStats->tsmMetrics.RoamingDly
1447 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
1448
1449 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
1450 mmhMsg.bodyptr = pStats;
1451 mmhMsg.bodyval = 0;
Jeff Johnson35c58a82018-11-22 15:04:57 -08001452 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08001453 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001454
1455 return;
1456} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
1457
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001458#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001459
1460void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001461lim_send_sme_ibss_peer_ind(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001462 tSirMacAddr peerMacAddr,
1463 uint16_t staIndex,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001464 uint8_t *beacon,
1465 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
1466{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001467 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001468 tSmeIbssPeerInd *pNewPeerInd;
1469
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301470 pNewPeerInd = qdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
Arif Hussainf5b6c412018-10-10 19:41:09 -07001471 if (!pNewPeerInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001472 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001473
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301474 qdf_mem_copy((uint8_t *) pNewPeerInd->peer_addr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301475 peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001476 pNewPeerInd->staId = staIndex;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001477 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
1478 pNewPeerInd->mesgType = msgType;
1479 pNewPeerInd->sessionId = sessionId;
1480
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001481 if (beacon) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301482 qdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001483 sizeof(tSmeIbssPeerInd)), (void *)beacon,
1484 beaconLen);
1485 }
1486
1487 mmhMsg.type = msgType;
1488 mmhMsg.bodyptr = pNewPeerInd;
Jeff Johnson35c58a82018-11-22 15:04:57 -08001489 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08001490 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001491
1492}
1493
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07001494/**
1495 * lim_process_csa_wbw_ie() - Process CSA Wide BW IE
1496 * @mac_ctx: pointer to global adapter context
1497 * @csa_params: pointer to CSA parameters
1498 * @chnl_switch_info:pointer to channel switch parameters
1499 * @session_entry: session pointer
1500 *
1501 * Return: None
1502 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001503static QDF_STATUS lim_process_csa_wbw_ie(struct mac_context *mac_ctx,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001504 struct csa_offload_params *csa_params,
1505 tLimWiderBWChannelSwitchInfo *chnl_switch_info,
Jeff Johnsond7035a32018-11-18 22:03:13 -08001506 struct pe_session *session_entry)
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001507{
Amar Singhal5cccafe2017-02-15 12:42:58 -08001508 struct ch_params ch_params = {0};
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001509 uint8_t ap_new_ch_width;
1510 bool new_ch_width_dfn = false;
1511 uint8_t center_freq_diff;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001512 uint32_t fw_vht_ch_wd = wma_get_vht_ch_width() + 1;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001513
1514 ap_new_ch_width = csa_params->new_ch_width + 1;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001515
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001516 pe_debug("new channel: %d new_ch_width: %d seg0: %d seg1: %d",
1517 csa_params->channel, ap_new_ch_width,
1518 csa_params->new_ch_freq_seg1,
1519 csa_params->new_ch_freq_seg2);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001520
1521 if ((ap_new_ch_width != CH_WIDTH_80MHZ) &&
1522 (ap_new_ch_width != CH_WIDTH_160MHZ) &&
1523 (ap_new_ch_width != CH_WIDTH_80P80MHZ)) {
1524 pe_err("CSA wide BW IE has wrong ch_width %d",
1525 csa_params->new_ch_width);
1526 return QDF_STATUS_E_INVAL;
1527 }
1528
1529 if (!csa_params->new_ch_freq_seg1 && !csa_params->new_ch_freq_seg2) {
1530 pe_err("CSA wide BW IE has invalid center freq");
1531 return QDF_STATUS_E_INVAL;
1532 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001533 if ((ap_new_ch_width == CH_WIDTH_80MHZ) &&
1534 csa_params->new_ch_freq_seg2) {
1535 new_ch_width_dfn = true;
1536 if (csa_params->new_ch_freq_seg2 >
1537 csa_params->new_ch_freq_seg1)
1538 center_freq_diff = csa_params->new_ch_freq_seg2 -
1539 csa_params->new_ch_freq_seg1;
1540 else
1541 center_freq_diff = csa_params->new_ch_freq_seg1 -
1542 csa_params->new_ch_freq_seg2;
1543 if (center_freq_diff == CENTER_FREQ_DIFF_160MHz)
1544 ap_new_ch_width = CH_WIDTH_160MHZ;
1545 else if (center_freq_diff > CENTER_FREQ_DIFF_80P80MHz)
1546 ap_new_ch_width = CH_WIDTH_80P80MHZ;
1547 else
1548 ap_new_ch_width = CH_WIDTH_80MHZ;
1549 }
1550 session_entry->gLimChannelSwitch.state =
1551 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1552 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
1553 !new_ch_width_dfn) {
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001554 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1555 CH_TO_CNTR_FREQ_DIFF_160MHz) {
1556 pe_err("CSA wide BW IE has invalid center freq");
1557 return QDF_STATUS_E_INVAL;
1558 }
1559
1560 if (ap_new_ch_width > fw_vht_ch_wd) {
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001561 pe_debug("New BW is not supported, setting BW to %d",
1562 fw_vht_ch_wd);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001563 ap_new_ch_width = fw_vht_ch_wd;
1564 }
1565 ch_params.ch_width = ap_new_ch_width ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001566 wlan_reg_set_channel_params(mac_ctx->pdev,
1567 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001568 ap_new_ch_width = ch_params.ch_width;
1569 csa_params->new_ch_freq_seg1 = ch_params.center_freq_seg0;
1570 csa_params->new_ch_freq_seg2 = ch_params.center_freq_seg1;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001571 } else if (!new_ch_width_dfn) {
1572 if (ap_new_ch_width > fw_vht_ch_wd) {
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001573 pe_debug("New BW is not supported, setting BW to %d",
1574 fw_vht_ch_wd);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001575 ap_new_ch_width = fw_vht_ch_wd;
1576 }
1577 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1578 CH_TO_CNTR_FREQ_DIFF_80MHz) {
1579 pe_err("CSA wide BW IE has invalid center freq");
1580 return QDF_STATUS_E_INVAL;
1581 }
1582 csa_params->new_ch_freq_seg2 = 0;
1583 }
1584 if (new_ch_width_dfn) {
1585 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1586 CH_TO_CNTR_FREQ_DIFF_80MHz) {
1587 pe_err("CSA wide BW IE has invalid center freq");
1588 return QDF_STATUS_E_INVAL;
1589 }
1590 if (ap_new_ch_width > fw_vht_ch_wd) {
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001591 pe_debug("New width is not supported, setting BW to %d",
1592 fw_vht_ch_wd);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001593 ap_new_ch_width = fw_vht_ch_wd;
1594 }
1595 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
1596 (csa_params->new_ch_freq_seg1 !=
1597 csa_params->channel +
1598 CH_TO_CNTR_FREQ_DIFF_160MHz)) {
1599 pe_err("wide BW IE has invalid 160M center freq");
1600 csa_params->new_ch_freq_seg2 = 0;
1601 ap_new_ch_width = CH_WIDTH_80MHZ;
1602 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001603 }
1604 chnl_switch_info->newChanWidth = ap_new_ch_width;
1605 chnl_switch_info->newCenterChanFreq0 = csa_params->new_ch_freq_seg1;
1606 chnl_switch_info->newCenterChanFreq1 = csa_params->new_ch_freq_seg2;
1607
1608 if (session_entry->ch_width == ap_new_ch_width)
1609 goto prnt_log;
1610
1611 if (session_entry->ch_width == CH_WIDTH_80MHZ) {
1612 chnl_switch_info->newChanWidth = CH_WIDTH_80MHZ;
1613 chnl_switch_info->newCenterChanFreq1 = 0;
1614 } else {
1615 session_entry->ch_width = ap_new_ch_width;
1616 chnl_switch_info->newChanWidth = ap_new_ch_width;
1617 }
1618prnt_log:
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301619 pe_debug("new channel: %d new_ch_width: %d seg0: %d seg1: %d",
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001620 csa_params->channel,
1621 chnl_switch_info->newChanWidth,
1622 chnl_switch_info->newCenterChanFreq0,
1623 chnl_switch_info->newCenterChanFreq1);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001624
1625 return QDF_STATUS_SUCCESS;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001626}
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001627
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001628/**
1629 * lim_handle_csa_offload_msg() - Handle CSA offload message
1630 * @mac_ctx: pointer to global adapter context
1631 * @msg: Message pointer.
1632 *
1633 * Return: None
1634 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001635void lim_handle_csa_offload_msg(struct mac_context *mac_ctx,
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001636 struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001637{
Jeff Johnsond7035a32018-11-18 22:03:13 -08001638 struct pe_session *session_entry;
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301639 struct csa_offload_params *csa_params =
1640 (struct csa_offload_params *) (msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001641 tpDphHashNode sta_ds = NULL;
1642 uint8_t session_id;
1643 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05301644 uint16_t chan_space = 0;
Krunal Sonie2c45a92018-05-03 11:51:26 -07001645 struct ch_params ch_params = {0};
Gupta, Kapil121bf212015-11-25 19:21:29 +05301646
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001647 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08001648 tLimChannelSwitchInfo *lim_ch_switch = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001649
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301650 pe_debug("handle csa offload msg");
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301651
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001652 if (!csa_params) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301653 pe_err("limMsgQ body ptr is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001654 return;
1655 }
1656
1657 session_entry =
1658 pe_find_session_by_bssid(mac_ctx,
1659 csa_params->bssId, &session_id);
1660 if (!session_entry) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301661 pe_err("Session does not exists for %pM",
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301662 csa_params->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001663 goto err;
1664 }
1665
1666 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
1667 &session_entry->dph.dphHashTable);
1668
1669 if (!sta_ds) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301670 pe_err("sta_ds does not exist");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001671 goto err;
1672 }
1673
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001674 if (!LIM_IS_STA_ROLE(session_entry)) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301675 pe_debug("Invalid role to handle CSA");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001676 goto err;
1677 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001678 /*
1679 * on receiving channel switch announcement from AP, delete all
1680 * TDLS peers before leaving BSS and proceed for channel switch
1681 */
Bala Venkatesh33f270b2019-01-14 16:31:29 +05301682
1683 lim_update_tdls_set_state_for_fw(session_entry, false);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001684 lim_delete_tdls_peers(mac_ctx, session_entry);
Gupta, Kapil121bf212015-11-25 19:21:29 +05301685
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001686 lim_ch_switch = &session_entry->gLimChannelSwitch;
1687 session_entry->gLimChannelSwitch.switchMode =
1688 csa_params->switch_mode;
1689 /* timer already started by firmware, switch immediately */
1690 session_entry->gLimChannelSwitch.switchCount = 0;
1691 session_entry->gLimChannelSwitch.primaryChannel =
1692 csa_params->channel;
1693 session_entry->gLimChannelSwitch.state =
1694 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
1695 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
1696 lim_ch_switch->sec_ch_offset =
1697 session_entry->htSecondaryChannelOffset;
1698 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
1699 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
1700 chnl_switch_info =
1701 &session_entry->gLimWiderBWChannelSwitch;
1702
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001703 pe_debug("vht: %d ht: %d flag: %x chan: %d, sec_ch_offset %d",
1704 session_entry->vhtCapability,
1705 session_entry->htSupportedChannelWidthSet,
1706 csa_params->ies_present_flag,
1707 csa_params->channel,
1708 csa_params->sec_chan_offset);
1709 pe_debug("seg1: %d seg2: %d width: %d country: %s class: %d",
1710 csa_params->new_ch_freq_seg1,
1711 csa_params->new_ch_freq_seg2,
1712 csa_params->new_ch_width,
1713 mac_ctx->scan.countryCodeCurrent,
1714 csa_params->new_op_class);
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05301715
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001716 if (session_entry->vhtCapability &&
1717 session_entry->htSupportedChannelWidthSet) {
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001718 if ((csa_params->ies_present_flag & lim_wbw_ie_present) &&
1719 (QDF_STATUS_SUCCESS == lim_process_csa_wbw_ie(mac_ctx,
1720 csa_params, chnl_switch_info,
1721 session_entry))) {
1722 pe_debug("CSA wide BW IE process successful");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001723 lim_ch_switch->sec_ch_offset =
Abhishek Singhaf639b42017-06-16 14:14:36 +05301724 PHY_SINGLE_CHANNEL_CENTERED;
1725 if (chnl_switch_info->newChanWidth) {
1726 if (csa_params->channel <
1727 csa_params->new_ch_freq_seg1)
1728 lim_ch_switch->sec_ch_offset =
1729 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1730 else
1731 lim_ch_switch->sec_ch_offset =
1732 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1733 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001734 } else if (csa_params->ies_present_flag
1735 & lim_xcsa_ie_present) {
1736 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001737 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001738 mac_ctx->scan.countryCodeCurrent,
1739 csa_params->channel,
1740 csa_params->new_op_class);
1741 session_entry->gLimChannelSwitch.state =
1742 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1743
1744 if (chan_space == 80) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001745 chnl_switch_info->newChanWidth =
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001746 CH_WIDTH_80MHZ;
1747 } else if (chan_space == 40) {
1748 chnl_switch_info->newChanWidth =
1749 CH_WIDTH_40MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001750 } else {
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001751 chnl_switch_info->newChanWidth =
1752 CH_WIDTH_20MHZ;
1753 lim_ch_switch->state =
1754 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
1755 }
1756
1757 ch_params.ch_width =
1758 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001759 wlan_reg_set_channel_params(mac_ctx->pdev,
1760 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001761 chnl_switch_info->newCenterChanFreq0 =
1762 ch_params.center_freq_seg0;
1763 /*
1764 * This is not applicable for 20/40/80 MHz.
1765 * Only used when we support 80+80 MHz operation.
1766 * In case of 80+80 MHz, this parameter indicates
1767 * center channel frequency index of 80 MHz
1768 * channel offrequency segment 1.
1769 */
1770 chnl_switch_info->newCenterChanFreq1 =
1771 ch_params.center_freq_seg1;
1772 lim_ch_switch->sec_ch_offset =
1773 ch_params.sec_ch_offset;
1774
Kiran Kumar Lokere47127482017-12-20 18:09:55 -08001775 } else {
1776 lim_ch_switch->state =
1777 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1778 ch_params.ch_width = CH_WIDTH_40MHZ;
1779 wlan_reg_set_channel_params(mac_ctx->pdev,
1780 csa_params->channel, 0, &ch_params);
1781 lim_ch_switch->sec_ch_offset =
1782 ch_params.sec_ch_offset;
1783 chnl_switch_info->newChanWidth = CH_WIDTH_40MHZ;
1784 chnl_switch_info->newCenterChanFreq0 =
1785 ch_params.center_freq_seg0;
1786 chnl_switch_info->newCenterChanFreq1 = 0;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001787 }
1788 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
1789 chnl_switch_info->newCenterChanFreq0;
1790 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
1791 chnl_switch_info->newCenterChanFreq1;
1792 session_entry->gLimChannelSwitch.ch_width =
1793 chnl_switch_info->newChanWidth;
1794
1795 } else if (session_entry->htSupportedChannelWidthSet) {
1796 if (csa_params->ies_present_flag
1797 & lim_xcsa_ie_present) {
1798 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001799 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001800 mac_ctx->scan.countryCodeCurrent,
1801 csa_params->channel,
1802 csa_params->new_op_class);
1803 lim_ch_switch->state =
1804 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1805 if (chan_space == 40) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08001806 lim_ch_switch->ch_width =
1807 CH_WIDTH_40MHZ;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001808 chnl_switch_info->newChanWidth =
1809 CH_WIDTH_40MHZ;
1810 ch_params.ch_width =
1811 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001812 wlan_reg_set_channel_params(mac_ctx->pdev,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001813 csa_params->channel,
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07001814 0, &ch_params);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08001815 lim_ch_switch->ch_center_freq_seg0 =
1816 ch_params.center_freq_seg0;
1817 lim_ch_switch->sec_ch_offset =
1818 ch_params.sec_ch_offset;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001819 } else {
1820 lim_ch_switch->ch_width =
1821 CH_WIDTH_20MHZ;
1822 chnl_switch_info->newChanWidth =
1823 CH_WIDTH_40MHZ;
1824 lim_ch_switch->state =
1825 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
1826 lim_ch_switch->sec_ch_offset =
1827 PHY_SINGLE_CHANNEL_CENTERED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001828 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001829 } else {
1830 lim_ch_switch->ch_width =
1831 CH_WIDTH_40MHZ;
1832 lim_ch_switch->state =
1833 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1834 ch_params.ch_width = CH_WIDTH_40MHZ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001835 wlan_reg_set_channel_params(mac_ctx->pdev,
1836 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001837 lim_ch_switch->ch_center_freq_seg0 =
1838 ch_params.center_freq_seg0;
1839 lim_ch_switch->sec_ch_offset =
1840 ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001841 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001842
1843 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301844 pe_debug("new ch width: %d space: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05301845 session_entry->gLimChannelSwitch.ch_width, chan_space);
Kiran Kumar Lokere75d636f2016-12-20 14:52:03 -08001846 if ((session_entry->currentOperChannel == csa_params->channel) &&
1847 (session_entry->ch_width ==
1848 session_entry->gLimChannelSwitch.ch_width)) {
1849 pe_debug("Ignore CSA, no change in ch and bw");
1850 goto err;
1851 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001852
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05301853 if (WLAN_REG_IS_24GHZ_CH(csa_params->channel) &&
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +05301854 (session_entry->dot11mode == MLME_DOT11_MODE_11A))
1855 session_entry->dot11mode = MLME_DOT11_MODE_11G;
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05301856 else if (WLAN_REG_IS_5GHZ_CH(csa_params->channel) &&
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +05301857 ((session_entry->dot11mode == MLME_DOT11_MODE_11G) ||
1858 (session_entry->dot11mode == MLME_DOT11_MODE_11G_ONLY)))
1859 session_entry->dot11mode = MLME_DOT11_MODE_11A;
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05301860
Vignesh Viswanathan3d478032018-08-02 20:18:53 +05301861 /* Send RSO Stop to FW before triggering the vdev restart for CSA */
1862 if (mac_ctx->lim.stop_roaming_callback)
1863 mac_ctx->lim.stop_roaming_callback(mac_ctx,
1864 session_entry->smeSessionId,
1865 ecsr_driver_disabled);
1866
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001867 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001868
Abhishek Singhecc2c752019-03-18 11:05:39 +05301869 lim_flush_bssid(mac_ctx, session_entry->bssId);
1870
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001871#ifdef FEATURE_WLAN_DIAG_SUPPORT
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001872 lim_diag_event_report(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001873 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001874 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001875#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001876
1877err:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301878 qdf_mem_free(csa_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001879}
1880
1881/*--------------------------------------------------------------------------
1882 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
1883
Jeff Johnson35c58a82018-11-22 15:04:57 -08001884 \param mac - pointer to global adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001885 \param sessionId - Message pointer.
1886
1887 \sa
1888 --------------------------------------------------------------------------*/
1889
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001890void lim_handle_delete_bss_rsp(struct mac_context *mac, struct scheduler_msg *MsgQ)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001891{
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001892 struct pe_session *pe_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001893 tpDeleteBssParams pDelBss = (tpDeleteBssParams) (MsgQ->bodyptr);
1894
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001895 pe_session =
Jeff Johnson35c58a82018-11-22 15:04:57 -08001896 pe_find_session_by_session_id(mac, pDelBss->sessionId);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001897 if (!pe_session) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301898 pe_err("Session Does not exist for given sessionID: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001899 pDelBss->sessionId);
Tushnim Bhattacharyya6368a262018-10-12 09:48:45 -07001900 qdf_mem_free(MsgQ->bodyptr);
1901 MsgQ->bodyptr = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001902 return;
1903 }
Krunal Sonie50ff452017-10-11 18:23:55 -07001904
1905 /*
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07001906 * During DEL BSS handling, the PE Session will be deleted, but it is
1907 * better to clear this flag if the session is hanging around due
1908 * to some error conditions so that the next DEL_BSS request does
1909 * not take the HO_FAIL path
1910 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001911 pe_session->process_ho_fail = false;
1912 if (LIM_IS_IBSS_ROLE(pe_session))
1913 lim_ibss_del_bss_rsp(mac, MsgQ->bodyptr, pe_session);
1914 else if (LIM_IS_UNKNOWN_ROLE(pe_session))
1915 lim_process_sme_del_bss_rsp(mac, MsgQ->bodyval, pe_session);
1916 else if (LIM_IS_NDI_ROLE(pe_session))
1917 lim_ndi_del_bss_rsp(mac, MsgQ->bodyptr, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001918 else
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001919 lim_process_mlm_del_bss_rsp(mac, MsgQ, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001920
1921}
1922
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001923/** -----------------------------------------------------------------
1924 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
1925 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
1926 \ SME only looks at rc and tspec field.
Jeff Johnson35c58a82018-11-22 15:04:57 -08001927 \param mac - global mac structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001928 \param rspReqd - is SmeAddTsRsp required
1929 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
1930 \return tspec
1931 \sa
1932 ----------------------------------------------------------------- */
1933void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001934lim_send_sme_aggr_qos_rsp(struct mac_context *mac, tpSirAggrQosRsp aggrQosRsp,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001935 uint8_t smesessionId)
1936{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001937 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001938
1939 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
1940 mmhMsg.bodyptr = aggrQosRsp;
1941 mmhMsg.bodyval = 0;
Jeff Johnson35c58a82018-11-22 15:04:57 -08001942 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301943 smesessionId, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08001944 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001945
1946 return;
1947}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001948
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001949void lim_send_sme_max_assoc_exceeded_ntf(struct mac_context *mac, tSirMacAddr peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001950 uint8_t smesessionId)
1951{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001952 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001953 tSmeMaxAssocInd *pSmeMaxAssocInd;
1954
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301955 pSmeMaxAssocInd = qdf_mem_malloc(sizeof(tSmeMaxAssocInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001956 if (!pSmeMaxAssocInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001957 return;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301958 qdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peer_mac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301959 (uint8_t *) peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001960 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
1961 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
1962 pSmeMaxAssocInd->sessionId = smesessionId;
1963 mmhMsg.type = pSmeMaxAssocInd->mesgType;
1964 mmhMsg.bodyptr = pSmeMaxAssocInd;
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07001965 pe_debug("msgType: %s peerMacAddr "QDF_MAC_ADDR_STR "sme session id %d",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07001966 "eWNI_SME_MAX_ASSOC_EXCEEDED", QDF_MAC_ADDR_ARRAY(peerMacAddr),
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301967 pSmeMaxAssocInd->sessionId);
Jeff Johnson35c58a82018-11-22 15:04:57 -08001968 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301969 smesessionId, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08001970 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001971
1972 return;
1973}
1974
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001975/** -----------------------------------------------------------------
1976 \brief lim_send_sme_ap_channel_switch_resp() - sends
1977 eWNI_SME_CHANNEL_CHANGE_RSP
1978 After receiving WMA_SWITCH_CHANNEL_RSP indication this
1979 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
1980 that the Channel change has been done to the specified target
1981 channel in the Channel change request
Jeff Johnson35c58a82018-11-22 15:04:57 -08001982 \param mac - global mac structure
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001983 \param pe_session - session info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001984 \param pChnlParams - Channel switch params
1985 --------------------------------------------------------------------*/
1986void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001987lim_send_sme_ap_channel_switch_resp(struct mac_context *mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001988 struct pe_session *pe_session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001989 tpSwitchChannelParams pChnlParams)
1990{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001991 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001992 tpSwitchChannelParams pSmeSwithChnlParams;
1993 uint8_t channelId;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08001994 bool is_ch_dfs = false;
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08001995 enum phy_ch_width ch_width;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08001996 uint8_t ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001997
Arif Hussainf5b6c412018-10-10 19:41:09 -07001998 pSmeSwithChnlParams = qdf_mem_malloc(sizeof(tSwitchChannelParams));
1999 if (!pSmeSwithChnlParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002000 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002001
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302002 qdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002003 sizeof(tSwitchChannelParams));
2004
2005 channelId = pSmeSwithChnlParams->channelNumber;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002006 ch_width = pSmeSwithChnlParams->ch_width;
2007 ch_center_freq_seg1 = pSmeSwithChnlParams->ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002008
2009 /*
2010 * Pass the sme sessionID to SME instead
2011 * PE session ID.
2012 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002013 pSmeSwithChnlParams->peSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002014
2015 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
2016 mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
2017 mmhMsg.bodyval = 0;
Jeff Johnsona5abe272019-01-06 12:52:02 -08002018 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002019
2020 /*
2021 * We should start beacon transmission only if the new
2022 * channel after channel change is Non-DFS. For a DFS
2023 * channel, PE will receive an explicit request from
2024 * upper layers to start the beacon transmission .
2025 */
2026
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002027 if (ch_width == CH_WIDTH_160MHZ) {
2028 is_ch_dfs = true;
2029 } else if (ch_width == CH_WIDTH_80P80MHZ) {
Jeff Johnson35c58a82018-11-22 15:04:57 -08002030 if (wlan_reg_get_channel_state(mac->pdev, channelId) ==
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002031 CHANNEL_STATE_DFS ||
Jeff Johnson35c58a82018-11-22 15:04:57 -08002032 wlan_reg_get_channel_state(mac->pdev,
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002033 ch_center_freq_seg1 -
2034 SIR_80MHZ_START_CENTER_CH_DIFF) ==
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002035 CHANNEL_STATE_DFS)
2036 is_ch_dfs = true;
2037 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -08002038 if (wlan_reg_get_channel_state(mac->pdev, channelId) ==
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002039 CHANNEL_STATE_DFS)
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002040 is_ch_dfs = true;
2041 }
2042
2043 if (!is_ch_dfs) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002044 if (channelId == pe_session->currentOperChannel) {
2045 lim_apply_configuration(mac, pe_session);
2046 lim_send_beacon(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002047 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302048 pe_debug("Failed to Transmit Beacons on channel: %d after AP channel change response",
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002049 pe_session->bcnLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002050 }
Arif Hussain1513cb22018-01-05 19:56:31 -08002051
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002052 lim_obss_send_detection_cfg(mac, pe_session, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002053 }
2054 return;
2055}
2056
Peng Xu6363ec62017-05-15 11:06:33 -07002057#ifdef WLAN_FEATURE_11AX_BSS_COLOR
2058/**
2059 * lim_send_bss_color_change_ie_update() - update bss color change IE in
2060 * beacon template
2061 *
2062 * @mac_ctx: pointer to global adapter context
2063 * @session: session pointer
2064 *
2065 * Return: none
2066 */
2067static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002068lim_send_bss_color_change_ie_update(struct mac_context *mac_ctx,
Jeff Johnsond7035a32018-11-18 22:03:13 -08002069 struct pe_session *session)
Peng Xu6363ec62017-05-15 11:06:33 -07002070{
2071 /* Update the beacon template and send to FW */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002072 if (sch_set_fixed_beacon_fields(mac_ctx, session) != QDF_STATUS_SUCCESS) {
Peng Xu6363ec62017-05-15 11:06:33 -07002073 pe_err("Unable to set BSS color change IE in beacon");
Srinivas Girigowdaeff16d92018-09-12 14:56:29 -07002074 return;
Peng Xu6363ec62017-05-15 11:06:33 -07002075 }
2076
2077 /* Send update beacon template message */
Abhishek Singhfc740be2018-10-12 11:34:26 +05302078 lim_send_beacon_ind(mac_ctx, session, REASON_COLOR_CHANGE);
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07002079 pe_debug("Updated BSS color change countdown = %d",
2080 session->he_bss_color_change.countdown);
Peng Xu6363ec62017-05-15 11:06:33 -07002081}
2082
2083static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002084lim_handle_bss_color_change_ie(struct mac_context *mac_ctx,
Jeff Johnsond7035a32018-11-18 22:03:13 -08002085 struct pe_session *session)
Peng Xu6363ec62017-05-15 11:06:33 -07002086{
Arif Hussain2f2d3512018-03-06 12:37:03 -08002087 tUpdateBeaconParams beacon_params;
2088
Peng Xu6363ec62017-05-15 11:06:33 -07002089 /* handle bss color change IE */
2090 if (LIM_IS_AP_ROLE(session) &&
2091 session->he_op.bss_col_disabled) {
2092 if (session->he_bss_color_change.countdown > 0) {
2093 session->he_bss_color_change.countdown--;
2094 } else {
2095 session->bss_color_changing = 0;
Arif Hussain2f2d3512018-03-06 12:37:03 -08002096 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
Arif Hussain05fb4872018-01-03 16:02:55 -08002097 if (session->he_bss_color_change.new_color != 0) {
Peng Xu6363ec62017-05-15 11:06:33 -07002098 session->he_op.bss_col_disabled = 0;
Arif Hussain05fb4872018-01-03 16:02:55 -08002099 session->he_op.bss_color =
2100 session->he_bss_color_change.new_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08002101 beacon_params.paramChangeBitmap |=
2102 PARAM_BSS_COLOR_CHANGED;
2103 beacon_params.bss_color_disabled = 0;
2104 beacon_params.bss_color =
2105 session->he_op.bss_color;
2106 lim_send_beacon_params(mac_ctx,
2107 &beacon_params,
2108 session);
Arif Hussain05fb4872018-01-03 16:02:55 -08002109 lim_send_obss_color_collision_cfg(mac_ctx,
2110 session,
2111 OBSS_COLOR_COLLISION_DETECTION);
2112 }
Peng Xu6363ec62017-05-15 11:06:33 -07002113 }
2114
2115 lim_send_bss_color_change_ie_update(mac_ctx, session);
2116 }
2117}
2118
2119#else
2120static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002121lim_handle_bss_color_change_ie(struct mac_context *mac_ctx,
Jeff Johnsond7035a32018-11-18 22:03:13 -08002122 struct pe_session *session)
Peng Xu6363ec62017-05-15 11:06:33 -07002123{
2124}
2125#endif
2126
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002127void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002128lim_process_beacon_tx_success_ind(struct mac_context *mac_ctx, uint16_t msgType,
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302129 void *event)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002130{
Jeff Johnsond7035a32018-11-18 22:03:13 -08002131 struct pe_session *session;
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302132 tpSirFirstBeaconTxCompleteInd bcn_ind =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002133 (tSirFirstBeaconTxCompleteInd *) event;
2134
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302135 session = pe_find_session_by_bss_idx(mac_ctx, bcn_ind->bssIdx);
2136 if (!session) {
2137 pe_err("Session Does not exist for given session id");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002138 return;
2139 }
2140
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302141 pe_debug("role: %d swIe: %d opIe: %d switch cnt:%d",
2142 GET_LIM_SYSTEM_ROLE(session),
2143 session->dfsIncludeChanSwIe,
2144 session->gLimOperatingMode.present,
2145 session->gLimChannelSwitch.switchCount);
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302146
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302147 if (!LIM_IS_AP_ROLE(session))
2148 return;
Ganesh Kondabattini02ec62b2018-01-24 18:22:24 +05302149
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302150 if (session->dfsIncludeChanSwIe &&
2151 (session->gLimChannelSwitch.switchCount ==
2152 mac_ctx->sap.SapDfsInfo.sap_ch_switch_beacon_cnt))
2153 lim_process_ap_ecsa_timeout(session);
Ganesh Kondabattini02ec62b2018-01-24 18:22:24 +05302154
lifeng1c16b6b2017-09-25 13:59:55 +08002155
Abhishek Singhfc740be2018-10-12 11:34:26 +05302156 if (session->gLimOperatingMode.present)
2157 /* Done with nss update */
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302158 session->gLimOperatingMode.present = 0;
Peng Xu6363ec62017-05-15 11:06:33 -07002159
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302160 lim_handle_bss_color_change_ie(mac_ctx, session);
Peng Xu6363ec62017-05-15 11:06:33 -07002161
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002162 return;
2163}