blob: 26056eb4b7ce03bff8545ce76c1ae91505c93c63 [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);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +053074 sme_rsp->status_code = 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
Pragaspathi Thilagarajf812ccf2019-06-22 13:07:04 +0530206 if (session_entry->assoc_req) {
gaurank kathpaliaefb20a82019-04-18 19:17:23 +0530207 sme_join_rsp->assocReqLength =
208 session_entry->assocReqLen;
209 qdf_mem_copy(sme_join_rsp->frames +
210 sme_join_rsp->beaconLength,
Pragaspathi Thilagarajf812ccf2019-06-22 13:07:04 +0530211 session_entry->assoc_req,
gaurank kathpaliaefb20a82019-04-18 19:17:23 +0530212 sme_join_rsp->assocReqLength);
Pragaspathi Thilagarajf812ccf2019-06-22 13:07:04 +0530213 qdf_mem_free(session_entry->assoc_req);
214 session_entry->assoc_req = NULL;
gaurank kathpaliaefb20a82019-04-18 19:17:23 +0530215 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
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +0530289 pe_debug("lim_join_req:%pK, pLimReAssocReq:%pK",
290 session_entry->lim_join_req,
291 session_entry->pLimReAssocReq);
Wu Gao2968fc92017-06-19 19:18:34 +0800292
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +0530293 if (session_entry->lim_join_req)
294 join_reassoc_req = session_entry->lim_join_req;
Wu Gao2968fc92017-06-19 19:18:34 +0800295
296 if (session_entry->pLimReAssocReq)
297 join_reassoc_req = session_entry->pLimReAssocReq;
298
299 if (!join_reassoc_req) {
Pragaspathi Thilagaraj64ae59d2019-06-22 13:00:34 +0530300 pe_err("both lim_join_req and pLimReAssocReq NULL");
Wu Gao2968fc92017-06-19 19:18:34 +0800301 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 ||
Liangwei Donge0d4db22019-07-15 16:40:48 +0800314 wlan_reg_is_5ghz_ch_freq(session_entry->curr_op_freq))) {
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 }
Pragaspathi Thilagarajf812ccf2019-06-22 13:07:04 +0530328 if (session_entry->assoc_req) {
329 qdf_mem_free(session_entry->assoc_req);
330 session_entry->assoc_req = 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 {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800446 sme_join_rsp->timingMeasCap =
447 sta_ds->timingMeasCap;
448#ifdef FEATURE_WLAN_TDLS
449 sme_join_rsp->tdls_prohibited =
450 session_entry->tdls_prohibited;
451 sme_join_rsp->tdls_chan_swit_prohibited =
452 session_entry->tdls_chan_swit_prohibited;
453#endif
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530454 sme_join_rsp->nss = sta_ds->nss;
455 sme_join_rsp->max_rate_flags =
456 lim_get_max_rate_flags(mac_ctx, sta_ds);
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530457 lim_add_bss_info(sta_ds, sme_join_rsp);
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530458
459 /* Copy FILS params only for Successful join */
460 populate_fils_connect_params(mac_ctx,
461 session_entry, sme_join_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800462 }
463 }
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530464
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800465 sme_join_rsp->beaconLength = 0;
466 sme_join_rsp->assocReqLength = 0;
467 sme_join_rsp->assocRspLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800468 sme_join_rsp->parsedRicRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800469#ifdef FEATURE_WLAN_ESE
470 sme_join_rsp->tspecIeLen = 0;
471#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800472 lim_handle_join_rsp_status(mac_ctx, session_entry, result_code,
473 sme_join_rsp);
Bala Venkateshe7f79162019-01-16 16:43:59 +0530474 sme_join_rsp->uapsd_mask = session_entry->gUapsdPerAcBitmask;
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800475 /* Send supported NSS 1x1 to SME */
476 sme_join_rsp->supported_nss_1x1 =
477 session_entry->supported_nss_1x1;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530478 pe_debug("SME Join Rsp is supported NSS 1X1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800479 sme_join_rsp->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800480 }
481
482 sme_join_rsp->messageType = msg_type;
483 sme_join_rsp->length = (uint16_t) rsp_len;
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +0530484 sme_join_rsp->status_code = result_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800485 sme_join_rsp->protStatusCode = prot_status_code;
486
487 sme_join_rsp->sessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800488
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530489 lim_send_sme_join_reassoc_rsp_after_resume(mac_ctx, QDF_STATUS_SUCCESS,
Jeff Johnson2df04b82019-02-02 23:30:25 -0800490 sme_join_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800491}
492
Jeff Johnson9e3d8992019-02-20 20:11:48 -0800493void lim_send_sme_start_bss_rsp(struct mac_context *mac,
494 uint16_t msgType,
495 tSirResultCodes resultCode,
496 struct pe_session *pe_session,
497 uint8_t smesessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800498{
499
500 uint16_t size = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700501 struct scheduler_msg mmhMsg = {0};
Jeff Johnsona0d34622019-02-02 17:26:19 -0800502 struct start_bss_rsp *pSirSmeRsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800503 uint16_t ieLen;
504 uint16_t ieOffset, curLen;
505
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530506 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800507 lim_msg_str(msgType), lim_result_code_str(resultCode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800508
Jeff Johnsona0d34622019-02-02 17:26:19 -0800509 size = sizeof(struct start_bss_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800510
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700511 if (!pe_session) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530512 pSirSmeRsp = qdf_mem_malloc(size);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700513 if (!pSirSmeRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800514 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800515 } else {
516 /* subtract size of beaconLength + Mac Hdr + Fixed Fields before SSID */
517 ieOffset = sizeof(tAniBeaconStruct) + SIR_MAC_B_PR_SSID_OFFSET;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800518 ieLen = pe_session->schBeaconOffsetBegin
519 + pe_session->schBeaconOffsetEnd - ieOffset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800520 /* calculate the memory size to allocate */
521 size += ieLen;
522
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530523 pSirSmeRsp = qdf_mem_malloc(size);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700524 if (!pSirSmeRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800525 return;
Jeff Johnsona0d34622019-02-02 17:26:19 -0800526 size = sizeof(struct start_bss_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800527 if (resultCode == eSIR_SME_SUCCESS) {
528
529 sir_copy_mac_addr(pSirSmeRsp->bssDescription.bssId,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800530 pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800531
532 /* Read beacon interval from session */
533 pSirSmeRsp->bssDescription.beaconInterval =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800534 (uint16_t) pe_session->beaconParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800535 beaconInterval;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800536 pSirSmeRsp->bssType = pe_session->bssType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800537
Wu Gao5c3d94b2019-01-17 21:15:54 +0800538 if (lim_get_capability_info
Jeff Johnson35c58a82018-11-22 15:04:57 -0800539 (mac, &pSirSmeRsp->bssDescription.capabilityInfo,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800540 pe_session)
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700541 != QDF_STATUS_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530542 pe_err("could not retrieve Capabilities value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800543
Jeff Johnson35c58a82018-11-22 15:04:57 -0800544 lim_get_phy_mode(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800545 (uint32_t *) &pSirSmeRsp->bssDescription.
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800546 nwType, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800547
wadesong91a2c1b2019-07-12 12:18:06 +0800548 pSirSmeRsp->bssDescription.chan_freq =
Liangwei Donge0d4db22019-07-15 16:40:48 +0800549 pe_session->curr_op_freq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800550
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800551 if (!LIM_IS_NDI_ROLE(pe_session)) {
552 curLen = pe_session->schBeaconOffsetBegin - ieOffset;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530553 qdf_mem_copy((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800554 ieFields,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800555 pe_session->pSchBeaconFrameBegin +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800556 ieOffset, (uint32_t) curLen);
557
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530558 qdf_mem_copy(((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800559 ieFields) + curLen,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800560 pe_session->pSchBeaconFrameEnd,
561 (uint32_t) pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800562 schBeaconOffsetEnd);
563
Abhishek Singh34a4d862016-10-26 16:01:51 +0530564 pSirSmeRsp->bssDescription.length = (uint16_t)
Pragaspathi Thilagaraj1112c962019-05-23 23:45:38 +0530565 (offsetof(struct bss_description, ieFields[0])
Abhishek Singh34a4d862016-10-26 16:01:51 +0530566 - sizeof(pSirSmeRsp->bssDescription.length)
567 + ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800568 /* This is the size of the message, subtracting the size of the pointer to ieFields */
569 size += ieLen - sizeof(uint32_t);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700570 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800571#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800572 if (pe_session->cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530573 != QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Jeff Johnsonf6541882019-02-02 16:16:00 -0800574 pSirSmeRsp->ht_profile.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800575 htSupportedChannelWidthSet =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800576 pe_session->htSupportedChannelWidthSet;
Jeff Johnsonf6541882019-02-02 16:16:00 -0800577 pSirSmeRsp->ht_profile.htRecommendedTxWidthSet =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800578 pe_session->htRecommendedTxWidthSet;
Jeff Johnsonf6541882019-02-02 16:16:00 -0800579 pSirSmeRsp->ht_profile.htSecondaryChannelOffset =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800580 pe_session->htSecondaryChannelOffset;
Jeff Johnsonf6541882019-02-02 16:16:00 -0800581 pSirSmeRsp->ht_profile.dot11mode =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800582 pe_session->dot11mode;
Jeff Johnsonf6541882019-02-02 16:16:00 -0800583 pSirSmeRsp->ht_profile.htCapability =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800584 pe_session->htCapability;
Jeff Johnsonf6541882019-02-02 16:16:00 -0800585 pSirSmeRsp->ht_profile.vhtCapability =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800586 pe_session->vhtCapability;
Jeff Johnsonf6541882019-02-02 16:16:00 -0800587 pSirSmeRsp->ht_profile.apCenterChan =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800588 pe_session->ch_center_freq_seg0;
Jeff Johnsonf6541882019-02-02 16:16:00 -0800589 pSirSmeRsp->ht_profile.apChanWidth =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800590 pe_session->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800591 }
592#endif
593 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800594 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800595 pSirSmeRsp->messageType = msgType;
596 pSirSmeRsp->length = size;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800597 pSirSmeRsp->sessionId = smesessionId;
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +0530598 pSirSmeRsp->status_code = resultCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800599
600 mmhMsg.type = msgType;
601 mmhMsg.bodyptr = pSirSmeRsp;
602 mmhMsg.bodyval = 0;
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700603 if (!pe_session) {
Jeff Johnson35c58a82018-11-22 15:04:57 -0800604 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530605 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800606 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -0800607 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800608 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800609 }
610#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -0800611 lim_diag_event_report(mac, WLAN_PE_DIAG_START_BSS_RSP_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800612 pe_session, (uint16_t) resultCode, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800613#endif /* FEATURE_WLAN_DIAG_SUPPORT */
614
Jeff Johnsona5abe272019-01-06 12:52:02 -0800615 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800616} /*** end lim_send_sme_start_bss_rsp() ***/
617
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800618void lim_send_sme_disassoc_deauth_ntf(struct mac_context *mac,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530619 QDF_STATUS status, uint32_t *pCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800620{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700621 struct scheduler_msg mmhMsg = {0};
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800622 struct scheduler_msg *pMsg = (struct scheduler_msg *) pCtx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800623
624 mmhMsg.type = pMsg->type;
625 mmhMsg.bodyptr = pMsg;
626 mmhMsg.bodyval = 0;
627
Jeff Johnson35c58a82018-11-22 15:04:57 -0800628 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800629
Jeff Johnsona5abe272019-01-06 12:52:02 -0800630 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800631}
632
Jeff Johnsonb82e6d72019-02-20 21:32:32 -0800633void lim_send_sme_disassoc_ntf(struct mac_context *mac,
634 tSirMacAddr peerMacAddr,
635 tSirResultCodes reasonCode,
636 uint16_t disassocTrigger,
637 uint16_t aid,
638 uint8_t smesessionId,
639 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800640{
Jeff Johnson380a1cd2019-02-03 21:43:51 -0800641 struct disassoc_rsp *pSirSmeDisassocRsp;
Jeff Johnson318a9882019-02-04 08:30:50 -0800642 struct disassoc_ind *pSirSmeDisassocInd;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700643 uint32_t *pMsg = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800644 bool failure = false;
Jeff Johnsond7035a32018-11-18 22:03:13 -0800645 struct pe_session *session = NULL;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700646 uint16_t i, assoc_id;
647 tpDphHashNode sta_ds = NULL;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +0530648 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800649
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530650 pe_debug("Disassoc Ntf with trigger : %d reasonCode: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800651 disassocTrigger, reasonCode);
652
653 switch (disassocTrigger) {
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700654 case eLIM_DUPLICATE_ENTRY:
655 /*
656 * Duplicate entry is removed at LIM.
657 * Initiate new entry for other session
658 */
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -0700659 pe_debug("Rcvd eLIM_DUPLICATE_ENTRY for " QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -0700660 QDF_MAC_ADDR_ARRAY(peerMacAddr));
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700661
Jeff Johnson35c58a82018-11-22 15:04:57 -0800662 for (i = 0; i < mac->lim.maxBssId; i++) {
Jeff Johnsoneac5aad2019-03-19 12:57:04 -0700663 session = &mac->lim.gpSession[i];
664 if (session->valid &&
Pragaspathi Thilagaraje64714a2019-05-23 00:46:25 +0530665 (session->opmode == QDF_SAP_MODE)) {
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700666 /* Find the sta ds entry in another session */
Jeff Johnson35c58a82018-11-22 15:04:57 -0800667 sta_ds = dph_lookup_hash_entry(mac,
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700668 peerMacAddr, &assoc_id,
669 &session->dph.dphHashTable);
Abhishek Singh6d6e3d12017-12-04 14:16:00 +0530670 if (sta_ds)
671 break;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700672 }
673 }
674 if (sta_ds
675#ifdef WLAN_FEATURE_11W
676 && (!sta_ds->rmfEnabled)
677#endif
678 ) {
Jeff Johnson35c58a82018-11-22 15:04:57 -0800679 if (lim_add_sta(mac, sta_ds, false, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700680 QDF_STATUS_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530681 pe_err("could not Add STA with assocId: %d",
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700682 sta_ds->assocId);
683 }
Jeff Johnson35c58a82018-11-22 15:04:57 -0800684 status = lim_prepare_disconnect_done_ind(mac, &pMsg,
Pragaspathi Thilagaraj766c76f2018-08-08 16:44:40 +0530685 smesessionId,
686 reasonCode,
687 &peerMacAddr[0]);
688 if (!QDF_IS_STATUS_SUCCESS(status)) {
689 pe_err("Failed to prepare message");
690 return;
691 }
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700692 break;
693
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800694 case eLIM_HOST_DISASSOC:
695 /**
696 * Disassociation response due to
697 * host triggered disassociation
698 */
699
Jeff Johnson380a1cd2019-02-03 21:43:51 -0800700 pSirSmeDisassocRsp = qdf_mem_malloc(sizeof(struct disassoc_rsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700701 if (!pSirSmeDisassocRsp) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800702 failure = true;
703 goto error;
704 }
Jeff Johnsonff1fd432019-02-20 09:50:54 -0800705 pe_debug("send eWNI_SME_DISASSOC_RSP with retCode: %d for "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -0700706 QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -0700707 reasonCode, QDF_MAC_ADDR_ARRAY(peerMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800708 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
Jeff Johnson380a1cd2019-02-03 21:43:51 -0800709 pSirSmeDisassocRsp->length = sizeof(struct disassoc_rsp);
Jeff Johnsonff1fd432019-02-20 09:50:54 -0800710 pSirSmeDisassocRsp->sessionId = smesessionId;
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +0530711 pSirSmeDisassocRsp->status_code = reasonCode;
Jeff Johnsonff1fd432019-02-20 09:50:54 -0800712 qdf_mem_copy(pSirSmeDisassocRsp->peer_macaddr.bytes,
713 peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800714
715#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
716
Jeff Johnson35c58a82018-11-22 15:04:57 -0800717 lim_diag_event_report(mac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800718 pe_session, (uint16_t) reasonCode, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800719#endif
720 pMsg = (uint32_t *) pSirSmeDisassocRsp;
721 break;
722
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530723 case eLIM_PEER_ENTITY_DISASSOC:
724 case eLIM_LINK_MONITORING_DISASSOC:
Jeff Johnson35c58a82018-11-22 15:04:57 -0800725 status = lim_prepare_disconnect_done_ind(mac, &pMsg,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +0530726 smesessionId,
727 reasonCode, &peerMacAddr[0]);
728 if (!QDF_IS_STATUS_SUCCESS(status)) {
729 pe_err("Failed to prepare message");
730 return;
731 }
732 break;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530733
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800734 default:
735 /**
736 * Disassociation indication due to Disassociation
737 * frame reception from peer entity or due to
738 * loss of link with peer entity.
739 */
Jeff Johnson318a9882019-02-04 08:30:50 -0800740 pSirSmeDisassocInd =
741 qdf_mem_malloc(sizeof(*pSirSmeDisassocInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700742 if (!pSirSmeDisassocInd) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800743 failure = true;
744 goto error;
745 }
Jeff Johnsonff1fd432019-02-20 09:50:54 -0800746 pe_debug("send eWNI_SME_DISASSOC_IND with retCode: %d for "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -0700747 QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -0700748 reasonCode, QDF_MAC_ADDR_ARRAY(peerMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800749 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
Jeff Johnson318a9882019-02-04 08:30:50 -0800750 pSirSmeDisassocInd->length = sizeof(*pSirSmeDisassocInd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800751 pSirSmeDisassocInd->sessionId = smesessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800752 pSirSmeDisassocInd->reasonCode = reasonCode;
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +0530753 pSirSmeDisassocInd->status_code = reasonCode;
Jeff Johnsonff1fd432019-02-20 09:50:54 -0800754 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes,
755 pe_session->bssId, sizeof(tSirMacAddr));
756 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes,
757 peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800758
759#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -0800760 lim_diag_event_report(mac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800761 pe_session, (uint16_t) reasonCode, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800762#endif
763 pMsg = (uint32_t *) pSirSmeDisassocInd;
764
765 break;
766 }
767
768error:
769 /* Delete the PE session Created */
Jeff Johnson8e9530b2019-03-18 13:41:42 -0700770 if ((pe_session) && LIM_IS_STA_ROLE(pe_session))
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800771 pe_delete_session(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800772
773 if (false == failure)
Jeff Johnson35c58a82018-11-22 15:04:57 -0800774 lim_send_sme_disassoc_deauth_ntf(mac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800775 (uint32_t *) pMsg);
776} /*** end lim_send_sme_disassoc_ntf() ***/
777
778/** -----------------------------------------------------------------
779 \brief lim_send_sme_disassoc_ind() - sends SME_DISASSOC_IND
780
781 After receiving disassociation frame from peer entity, this
782 function sends a eWNI_SME_DISASSOC_IND to SME with a specific
783 reason code.
784
Jeff Johnson35c58a82018-11-22 15:04:57 -0800785 \param mac - global mac structure
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800786 \param sta - station dph hash node
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800787 \return none
788 \sa
789 ----------------------------------------------------------------- */
790void
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800791lim_send_sme_disassoc_ind(struct mac_context *mac, tpDphHashNode sta,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800792 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800793{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700794 struct scheduler_msg mmhMsg = {0};
Jeff Johnson318a9882019-02-04 08:30:50 -0800795 struct disassoc_ind *pSirSmeDisassocInd;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800796
Jeff Johnson318a9882019-02-04 08:30:50 -0800797 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(*pSirSmeDisassocInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700798 if (!pSirSmeDisassocInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800799 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800800
801 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
Jeff Johnson318a9882019-02-04 08:30:50 -0800802 pSirSmeDisassocInd->length = sizeof(*pSirSmeDisassocInd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800803
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800804 pSirSmeDisassocInd->sessionId = pe_session->smeSessionId;
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +0530805 pSirSmeDisassocInd->status_code = eSIR_SME_DEAUTH_STATUS;
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800806 pSirSmeDisassocInd->reasonCode = sta->mlmStaContext.disassocReason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800807
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800808 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes, pe_session->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530809 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800810
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800811 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes, sta->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530812 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800813
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800814 mmhMsg.type = eWNI_SME_DISASSOC_IND;
815 mmhMsg.bodyptr = pSirSmeDisassocInd;
816 mmhMsg.bodyval = 0;
817
Jeff Johnson35c58a82018-11-22 15:04:57 -0800818 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800819 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800820#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800821 lim_diag_event_report(mac, WLAN_PE_DIAG_DISASSOC_IND_EVENT, pe_session,
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800822 0, (uint16_t) sta->mlmStaContext.disassocReason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800823#endif /* FEATURE_WLAN_DIAG_SUPPORT */
824
Jeff Johnsona5abe272019-01-06 12:52:02 -0800825 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800826
827} /*** end lim_send_sme_disassoc_ind() ***/
828
829/** -----------------------------------------------------------------
830 \brief lim_send_sme_deauth_ind() - sends SME_DEAUTH_IND
831
832 After receiving deauthentication frame from peer entity, this
833 function sends a eWNI_SME_DEAUTH_IND to SME with a specific
834 reason code.
835
Jeff Johnson35c58a82018-11-22 15:04:57 -0800836 \param mac - global mac structure
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800837 \param sta - station dph hash node
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800838 \return none
839 \sa
840 ----------------------------------------------------------------- */
841void
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800842lim_send_sme_deauth_ind(struct mac_context *mac, tpDphHashNode sta,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800843 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800844{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700845 struct scheduler_msg mmhMsg = {0};
Jeff Johnsonfec08712019-02-04 13:12:08 -0800846 struct deauth_ind *pSirSmeDeauthInd;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800847
Jeff Johnsonfec08712019-02-04 13:12:08 -0800848 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(*pSirSmeDeauthInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700849 if (!pSirSmeDeauthInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800850 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800851
852 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
Jeff Johnsonfec08712019-02-04 13:12:08 -0800853 pSirSmeDeauthInd->length = sizeof(*pSirSmeDeauthInd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800854
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800855 pSirSmeDeauthInd->sessionId = pe_session->smeSessionId;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800856 if (eSIR_INFRA_AP_MODE == pe_session->bssType) {
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +0530857 pSirSmeDeauthInd->status_code =
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800858 (tSirResultCodes) sta->mlmStaContext.cleanupTrigger;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800859 } else {
Jeff Johnsonfec08712019-02-04 13:12:08 -0800860 /* Need to indicate the reason code over the air */
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +0530861 pSirSmeDeauthInd->status_code =
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800862 (tSirResultCodes) sta->mlmStaContext.disassocReason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800863 }
864 /* BSSID */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800865 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, pe_session->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530866 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800867 /* peerMacAddr */
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800868 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, sta->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530869 QDF_MAC_ADDR_SIZE);
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800870 pSirSmeDeauthInd->reasonCode = sta->mlmStaContext.disassocReason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800871
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -0800872 if (eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON ==
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800873 sta->mlmStaContext.disassocReason)
874 pSirSmeDeauthInd->rssi = sta->del_sta_ctx_rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800875
876 mmhMsg.type = eWNI_SME_DEAUTH_IND;
877 mmhMsg.bodyptr = pSirSmeDeauthInd;
878 mmhMsg.bodyval = 0;
879
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800880 MTRACE(mac_trace_msg_tx(mac, pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800881#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800882 lim_diag_event_report(mac, WLAN_PE_DIAG_DEAUTH_IND_EVENT, pe_session,
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800883 0, sta->mlmStaContext.cleanupTrigger);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800884#endif /* FEATURE_WLAN_DIAG_SUPPORT */
885
Jeff Johnsona5abe272019-01-06 12:52:02 -0800886 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800887 return;
888} /*** end lim_send_sme_deauth_ind() ***/
889
890#ifdef FEATURE_WLAN_TDLS
891/**
892 * lim_send_sme_tdls_del_sta_ind()
893 *
894 ***FUNCTION:
895 * This function is called to send the TDLS STA context deletion to SME.
896 *
897 ***LOGIC:
898 *
899 ***ASSUMPTIONS:
900 *
901 ***NOTE:
902 * NA
903 *
Jeff Johnson35c58a82018-11-22 15:04:57 -0800904 * @param mac - Pointer to global MAC structure
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800905 * @param sta - Pointer to internal STA Datastructure
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800906 * @param pe_session - Pointer to the session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800907 * @param reasonCode - Reason for TDLS sta deletion
908 * @return None
909 */
910void
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800911lim_send_sme_tdls_del_sta_ind(struct mac_context *mac, tpDphHashNode sta,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800912 struct pe_session *pe_session, uint16_t reasonCode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800913{
Frank Liud1a28462017-09-06 22:55:48 +0800914 struct tdls_event_info info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800915
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -0700916 pe_debug("Delete TDLS Peer "QDF_MAC_ADDR_STR "with reason code: %d",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -0700917 QDF_MAC_ADDR_ARRAY(sta->staAddr), reasonCode);
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800918 info.vdev_id = pe_session->smeSessionId;
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800919 qdf_mem_copy(info.peermac.bytes, sta->staAddr, QDF_MAC_ADDR_SIZE);
Frank Liud1a28462017-09-06 22:55:48 +0800920 info.message_type = TDLS_PEER_DISCONNECTED;
921 info.peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800922
Jeff Johnson35c58a82018-11-22 15:04:57 -0800923 tgt_tdls_event_handler(mac->psoc, &info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800924
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800925 return;
926} /*** end lim_send_sme_tdls_del_sta_ind() ***/
927
928/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800929 * lim_send_sme_mgmt_tx_completion()
930 *
931 ***FUNCTION:
932 * This function is called to send the eWNI_SME_MGMT_FRM_TX_COMPLETION_IND
933 * message to SME.
934 *
935 ***LOGIC:
936 *
937 ***ASSUMPTIONS:
938 *
939 ***NOTE:
940 * NA
941 *
Jeff Johnson35c58a82018-11-22 15:04:57 -0800942 * @param mac - Pointer to global MAC structure
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800943 * @param pe_session - Pointer to the session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800944 * @param txCompleteStatus - TX Complete Status of Mgmt Frames
945 * @return None
946 */
947void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800948lim_send_sme_mgmt_tx_completion(struct mac_context *mac,
Ganesh Kondabattiniac570072016-12-21 12:45:48 +0530949 uint32_t sme_session_id,
950 uint32_t txCompleteStatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800951{
Wu Gao6768d762018-12-28 16:31:08 +0800952 struct scheduler_msg msg = {0};
953 struct tdls_mgmt_tx_completion_ind *mgmt_tx_completion_ind;
954 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800955
Wu Gao6768d762018-12-28 16:31:08 +0800956 mgmt_tx_completion_ind =
957 qdf_mem_malloc(sizeof(*mgmt_tx_completion_ind));
958 if (!mgmt_tx_completion_ind)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800959 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800960
961 /* sessionId */
Wu Gao6768d762018-12-28 16:31:08 +0800962 mgmt_tx_completion_ind->session_id = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800963
Wu Gao6768d762018-12-28 16:31:08 +0800964 mgmt_tx_completion_ind->tx_complete_status = txCompleteStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800965
Wu Gao6768d762018-12-28 16:31:08 +0800966 msg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
967 msg.bodyptr = mgmt_tx_completion_ind;
968 msg.bodyval = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800969
Wu Gao6768d762018-12-28 16:31:08 +0800970 mgmt_tx_completion_ind->psoc = mac->psoc;
971 msg.callback = tgt_tdls_send_mgmt_tx_completion;
972 status = scheduler_post_message(QDF_MODULE_ID_PE,
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +0530973 QDF_MODULE_ID_TDLS,
Wu Gao6768d762018-12-28 16:31:08 +0800974 QDF_MODULE_ID_TARGET_IF, &msg);
975 if (QDF_IS_STATUS_ERROR(status)) {
976 pe_err("post msg fail, %d", status);
977 qdf_mem_free(mgmt_tx_completion_ind);
978 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800979} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
980
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800981#endif /* FEATURE_WLAN_TDLS */
982
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800983QDF_STATUS lim_prepare_disconnect_done_ind(struct mac_context *mac_ctx,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +0530984 uint32_t **msg,
985 uint8_t session_id,
986 tSirResultCodes reason_code,
987 uint8_t *peer_mac_addr)
Himanshu Agarwald519b4a2018-03-27 15:36:09 +0530988{
989 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +0530990
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +0530991 sir_sme_dis_ind = qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700992 if (!sir_sme_dis_ind)
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +0530993 return QDF_STATUS_E_FAILURE;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +0530994
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +0530995 pe_debug("Prepare eWNI_SME_DISCONNECT_DONE_IND withretCode: %d",
Himanshu Agarwald519b4a2018-03-27 15:36:09 +0530996 reason_code);
997
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +0530998 sir_sme_dis_ind->message_type = eWNI_SME_DISCONNECT_DONE_IND;
999 sir_sme_dis_ind->length = sizeof(*sir_sme_dis_ind);
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301000 sir_sme_dis_ind->session_id = session_id;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301001 if (peer_mac_addr)
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05301002 qdf_mem_copy(sir_sme_dis_ind->peer_mac,
1003 peer_mac_addr, ETH_ALEN);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301004
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301005 /*
1006 * Instead of sending deauth reason code as 505 which is
1007 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1008 * Send reason code as zero to Supplicant
1009 */
1010 if (reason_code == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1011 sir_sme_dis_ind->reason_code = 0;
1012 else
1013 sir_sme_dis_ind->reason_code = reason_code;
1014
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301015 *msg = (uint32_t *)sir_sme_dis_ind;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301016
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301017 return QDF_STATUS_SUCCESS;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301018}
1019
Jeff Johnson953f99a2019-02-20 22:08:31 -08001020void lim_send_sme_deauth_ntf(struct mac_context *mac, tSirMacAddr peerMacAddr,
1021 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1022 uint16_t aid, uint8_t smesessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001023{
1024 uint8_t *pBuf;
Jeff Johnson15ae0c12019-02-04 12:55:07 -08001025 struct deauth_rsp *pSirSmeDeauthRsp;
Jeff Johnsonfec08712019-02-04 13:12:08 -08001026 struct deauth_ind *pSirSmeDeauthInd;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001027 struct pe_session *pe_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001028 uint8_t sessionId;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301029 uint32_t *pMsg = NULL;
1030 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001031
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001032 pe_session = pe_find_session_by_bssid(mac, peerMacAddr, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001033 switch (deauthTrigger) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001034 case eLIM_HOST_DEAUTH:
1035 /**
1036 * Deauthentication response to host triggered
1037 * deauthentication.
1038 */
Jeff Johnson15ae0c12019-02-04 12:55:07 -08001039 pSirSmeDeauthRsp = qdf_mem_malloc(sizeof(*pSirSmeDeauthRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001040 if (!pSirSmeDeauthRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001041 return;
Jeff Johnson15ae0c12019-02-04 12:55:07 -08001042 pe_debug("send eWNI_SME_DEAUTH_RSP with retCode: %d for "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07001043 QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07001044 reasonCode, QDF_MAC_ADDR_ARRAY(peerMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001045 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
Jeff Johnson15ae0c12019-02-04 12:55:07 -08001046 pSirSmeDeauthRsp->length = sizeof(*pSirSmeDeauthRsp);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05301047 pSirSmeDeauthRsp->status_code = reasonCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001048 pSirSmeDeauthRsp->sessionId = smesessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001049
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -08001050 pBuf = (uint8_t *) pSirSmeDeauthRsp->peer_macaddr.bytes;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301051 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001052
1053#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -08001054 lim_diag_event_report(mac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001055 pe_session, 0, (uint16_t) reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001056#endif
1057 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1058
1059 break;
1060
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301061 case eLIM_PEER_ENTITY_DEAUTH:
1062 case eLIM_LINK_MONITORING_DEAUTH:
Jeff Johnson35c58a82018-11-22 15:04:57 -08001063 status = lim_prepare_disconnect_done_ind(mac, &pMsg,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301064 smesessionId, reasonCode,
1065 &peerMacAddr[0]);
1066 if (!QDF_IS_STATUS_SUCCESS(status)) {
1067 pe_err("Failed to prepare message");
1068 return;
1069 }
1070 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001071 default:
1072 /**
1073 * Deauthentication indication due to Deauthentication
1074 * frame reception from peer entity or due to
1075 * loss of link with peer entity.
1076 */
Jeff Johnsonfec08712019-02-04 13:12:08 -08001077 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(*pSirSmeDeauthInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001078 if (!pSirSmeDeauthInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001079 return;
Jeff Johnsonfec08712019-02-04 13:12:08 -08001080 pe_debug("send eWNI_SME_DEAUTH_IND with retCode: %d for "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07001081 QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07001082 reasonCode, QDF_MAC_ADDR_ARRAY(peerMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001083 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
Jeff Johnsonfec08712019-02-04 13:12:08 -08001084 pSirSmeDeauthInd->length = sizeof(*pSirSmeDeauthInd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001085 pSirSmeDeauthInd->reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
Jeff Johnson8ee46ef2019-02-20 18:34:17 -08001086 pSirSmeDeauthInd->sessionId = smesessionId;
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05301087 pSirSmeDeauthInd->status_code = reasonCode;
Jeff Johnson8ee46ef2019-02-20 18:34:17 -08001088 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, pe_session->bssId,
1089 sizeof(tSirMacAddr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301090 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301091 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001092
1093#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -08001094 lim_diag_event_report(mac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001095 pe_session, 0, (uint16_t) reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001096#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1097 pMsg = (uint32_t *) pSirSmeDeauthInd;
1098
1099 break;
1100 }
1101
1102 /*Delete the PE session created */
Bala Venkatesh03b4f0c2019-01-28 22:00:50 +05301103 if (pe_session && LIM_IS_STA_ROLE(pe_session))
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001104 pe_delete_session(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001105
Jeff Johnson35c58a82018-11-22 15:04:57 -08001106 lim_send_sme_disassoc_deauth_ntf(mac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001107 (uint32_t *) pMsg);
1108
1109} /*** end lim_send_sme_deauth_ntf() ***/
1110
1111/**
1112 * lim_send_sme_wm_status_change_ntf() - Send Notification
1113 * @mac_ctx: Global MAC Context
1114 * @status_change_code: Indicates the change in the wireless medium.
1115 * @status_change_info: Indicates the information associated with
1116 * change in the wireless medium.
1117 * @info_len: Indicates the length of status change information
1118 * being sent.
1119 * @session_id SessionID
1120 *
1121 * This function is called by limProcessSmeMessages() to send
1122 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1123 *
1124 * Return: None
1125 */
1126void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001127lim_send_sme_wm_status_change_ntf(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001128 tSirSmeStatusChangeCode status_change_code,
1129 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1130{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001131 struct scheduler_msg msg = {0};
Jeff Johnson53889322019-02-03 17:37:09 -08001132 struct wm_status_change_ntf *wm_status_change_ntf;
Naveen Rawate01ed172016-11-17 11:34:50 -08001133 uint32_t max_info_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001134
Jeff Johnson53889322019-02-03 17:37:09 -08001135 wm_status_change_ntf = qdf_mem_malloc(sizeof(*wm_status_change_ntf));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001136 if (!wm_status_change_ntf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001137 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001138
1139 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1140 msg.bodyval = 0;
1141 msg.bodyptr = wm_status_change_ntf;
1142
1143 switch (status_change_code) {
Naveen Rawate01ed172016-11-17 11:34:50 -08001144 case eSIR_SME_AP_CAPS_CHANGED:
Jeff Johnson9c9961c2019-02-03 17:10:53 -08001145 max_info_len = sizeof(struct ap_new_caps);
Naveen Rawate01ed172016-11-17 11:34:50 -08001146 break;
1147 case eSIR_SME_JOINED_NEW_BSS:
Jeff Johnson2e6d1732019-02-03 17:00:30 -08001148 max_info_len = sizeof(struct new_bss_info);
Naveen Rawate01ed172016-11-17 11:34:50 -08001149 break;
1150 default:
1151 max_info_len = sizeof(wm_status_change_ntf->statusChangeInfo);
1152 break;
1153 }
1154
1155 switch (status_change_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001156 case eSIR_SME_RADAR_DETECTED:
1157 break;
1158 default:
1159 wm_status_change_ntf->messageType =
1160 eWNI_SME_WM_STATUS_CHANGE_NTF;
1161 wm_status_change_ntf->statusChangeCode = status_change_code;
Jeff Johnson53889322019-02-03 17:37:09 -08001162 wm_status_change_ntf->length = sizeof(*wm_status_change_ntf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001163 wm_status_change_ntf->sessionId = session_id;
Naveen Rawate01ed172016-11-17 11:34:50 -08001164 if (info_len <= max_info_len && status_change_info) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301165 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001166 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1167 (uint8_t *) status_change_info, info_len);
1168 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301169 pe_debug("StatusChg code: 0x%x length: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001170 status_change_code, info_len);
1171 break;
1172 }
1173
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301174 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, session_id, msg.type));
Harprit Chhabadae20b5562019-03-11 14:13:42 -07001175 lim_sys_process_mmh_msg_api(mac_ctx, &msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001176
1177} /*** end lim_send_sme_wm_status_change_ntf() ***/
1178
Jeff Johnsonc80ed542019-02-21 06:24:57 -08001179void lim_send_sme_set_context_rsp(struct mac_context *mac,
1180 struct qdf_mac_addr peer_macaddr,
1181 uint16_t aid,
1182 tSirResultCodes resultCode,
1183 struct pe_session *pe_session,
1184 uint8_t smesessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001185{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001186 struct scheduler_msg mmhMsg = {0};
Jeff Johnson924ae612019-02-05 12:01:50 -08001187 struct set_context_rsp *set_context_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001188
Jeff Johnson924ae612019-02-05 12:01:50 -08001189 set_context_rsp = qdf_mem_malloc(sizeof(*set_context_rsp));
1190 if (!set_context_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001191 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001192
Jeff Johnson924ae612019-02-05 12:01:50 -08001193 set_context_rsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1194 set_context_rsp->length = sizeof(*set_context_rsp);
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05301195 set_context_rsp->status_code = resultCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001196
Jeff Johnson924ae612019-02-05 12:01:50 -08001197 qdf_copy_macaddr(&set_context_rsp->peer_macaddr, &peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001198
Jeff Johnson924ae612019-02-05 12:01:50 -08001199 set_context_rsp->sessionId = smesessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001200
1201 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
Jeff Johnson924ae612019-02-05 12:01:50 -08001202 mmhMsg.bodyptr = set_context_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001203 mmhMsg.bodyval = 0;
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001204 if (!pe_session) {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001205 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301206 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001207 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001208 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001209 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001210 }
1211
1212#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -08001213 lim_diag_event_report(mac, WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001214 pe_session, (uint16_t) resultCode, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001215#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1216
Jeff Johnson35c58a82018-11-22 15:04:57 -08001217 mac->lim.sme_msg_callback(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001218} /*** end lim_send_sme_set_context_rsp() ***/
1219
Jeff Johnson07819492019-02-21 09:34:02 -08001220void lim_send_sme_addts_rsp(struct mac_context *mac,
1221 uint8_t rspReqd, uint32_t status,
1222 struct pe_session *pe_session,
1223 struct mac_tspec_ie tspec,
1224 uint8_t smesessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001225{
1226 tpSirAddtsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001227 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001228
1229 if (!rspReqd)
1230 return;
1231
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301232 rsp = qdf_mem_malloc(sizeof(tSirAddtsRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001233 if (!rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001234 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001235
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001236 rsp->messageType = eWNI_SME_ADDTS_RSP;
1237 rsp->rc = status;
Pragaspathi Thilagarajcb58bbc2019-05-23 15:34:51 +05301238 rsp->rsp.status = (enum mac_status_code)status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001239 rsp->rsp.tspec = tspec;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001240 rsp->sessionId = smesessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001241
1242 mmhMsg.type = eWNI_SME_ADDTS_RSP;
1243 mmhMsg.bodyptr = rsp;
1244 mmhMsg.bodyval = 0;
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001245 if (!pe_session) {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001246 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301247 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001248 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001249 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001250 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001251 }
1252#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001253 lim_diag_event_report(mac, WLAN_PE_DIAG_ADDTS_RSP_EVENT, pe_session, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001254 0);
1255#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1256
Jeff Johnsona5abe272019-01-06 12:52:02 -08001257 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001258 return;
1259}
1260
Jeff Johnsonb2b63e02019-02-21 09:46:03 -08001261void lim_send_sme_delts_rsp(struct mac_context *mac, tpSirDeltsReq delts,
1262 uint32_t status, struct pe_session *pe_session,
1263 uint8_t smesessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001264{
1265 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001266 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001267
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301268 pe_debug("SendSmeDeltsRsp aid: %d tsid: %d up: %d status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001269 delts->aid,
1270 delts->req.tsinfo.traffic.tsid,
1271 delts->req.tsinfo.traffic.userPrio, status);
1272 if (!delts->rspReqd)
1273 return;
1274
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301275 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001276 if (!rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001277 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001278
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001279 if (pe_session) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001280
1281 rsp->aid = delts->aid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301282 qdf_copy_macaddr(&rsp->macaddr, &delts->macaddr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301283 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) &delts->req,
Jeff Johnsoncf2ec162018-12-22 16:46:43 -08001284 sizeof(struct delts_req_info));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001285 }
1286
1287 rsp->messageType = eWNI_SME_DELTS_RSP;
1288 rsp->rc = status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001289 rsp->sessionId = smesessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001290
1291 mmhMsg.type = eWNI_SME_DELTS_RSP;
1292 mmhMsg.bodyptr = rsp;
1293 mmhMsg.bodyval = 0;
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001294 if (!pe_session) {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001295 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301296 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001297 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001298 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001299 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001300 }
1301#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001302 lim_diag_event_report(mac, WLAN_PE_DIAG_DELTS_RSP_EVENT, pe_session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001303 (uint16_t) status, 0);
1304#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1305
Jeff Johnsona5abe272019-01-06 12:52:02 -08001306 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001307}
1308
1309void
Jeff Johnsoncf2ec162018-12-22 16:46:43 -08001310lim_send_sme_delts_ind(struct mac_context *mac, struct delts_req_info *delts,
1311 uint16_t aid, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001312{
1313 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001314 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001315
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301316 pe_debug("SendSmeDeltsInd aid: %d tsid: %d up: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001317 aid, delts->tsinfo.traffic.tsid, delts->tsinfo.traffic.userPrio);
1318
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301319 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001320 if (!rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001321 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001322
1323 rsp->messageType = eWNI_SME_DELTS_IND;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001324 rsp->rc = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325 rsp->aid = aid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301326 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) delts, sizeof(*delts));
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001327 rsp->sessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001328
1329 mmhMsg.type = eWNI_SME_DELTS_IND;
1330 mmhMsg.bodyptr = rsp;
1331 mmhMsg.bodyval = 0;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001332 MTRACE(mac_trace_msg_tx(mac, pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001333#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001334 lim_diag_event_report(mac, WLAN_PE_DIAG_DELTS_IND_EVENT, pe_session, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001335 0);
1336#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1337
Jeff Johnsona5abe272019-01-06 12:52:02 -08001338 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001339}
1340
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001341#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001342/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001343 * lim_send_sme_pe_ese_tsm_rsp() - send tsm response
Jeff Johnson35c58a82018-11-22 15:04:57 -08001344 * @mac: Pointer to global mac structure
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001345 * @pStats: Pointer to TSM Stats
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001346 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001347 * This function is called to send tsm stats response to HDD.
1348 * This function posts the result back to HDD. This is a response to
1349 * HDD's request to get tsm stats.
1350 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001351 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001352 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001353void lim_send_sme_pe_ese_tsm_rsp(struct mac_context *mac,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001354 tAniGetTsmStatsRsp *pStats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001355{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001356 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001357 uint8_t sessionId;
1358 tAniGetTsmStatsRsp *pPeStats = (tAniGetTsmStatsRsp *) pStats;
Jeff Johnsond7035a32018-11-18 22:03:13 -08001359 struct pe_session *pPeSessionEntry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001360
1361 /* Get the Session Id based on Sta Id */
Abhinav Kumaraa8f2df2019-01-11 20:02:26 +05301362 pPeSessionEntry = pe_find_session_by_bssid(mac, pPeStats->bssid.bytes,
1363 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001364 /* Fill the Session Id */
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001365 if (pPeSessionEntry) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001366 /* Fill the Session Id */
1367 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1368 } else {
Sourav Mohapatradcd8f8d2019-07-03 15:43:15 +05301369 pe_err("Session not found for the Sta peer:" QDF_MAC_ADDR_STR,
1370 QDF_MAC_ADDR_ARRAY(pPeStats->bssid.bytes));
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05301371 qdf_mem_free(pPeStats->tsmStatsReq);
1372 qdf_mem_free(pPeStats);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001373 return;
1374 }
1375
1376 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
1377 pPeStats->tsmMetrics.RoamingCount
1378 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
1379 pPeStats->tsmMetrics.RoamingDly
1380 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
1381
1382 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
1383 mmhMsg.bodyptr = pStats;
1384 mmhMsg.bodyval = 0;
Jeff Johnson35c58a82018-11-22 15:04:57 -08001385 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08001386 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001387
1388 return;
1389} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
1390
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001391#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001392
Abhishek Amburedddf4282019-09-27 18:54:38 +05301393#ifdef QCA_IBSS_SUPPORT
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001394void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001395lim_send_sme_ibss_peer_ind(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001396 tSirMacAddr peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001397 uint8_t *beacon,
1398 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
1399{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001400 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001401 tSmeIbssPeerInd *pNewPeerInd;
1402
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301403 pNewPeerInd = qdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
Arif Hussainf5b6c412018-10-10 19:41:09 -07001404 if (!pNewPeerInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001405 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001406
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301407 qdf_mem_copy((uint8_t *) pNewPeerInd->peer_addr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301408 peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001409 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
1410 pNewPeerInd->mesgType = msgType;
1411 pNewPeerInd->sessionId = sessionId;
1412
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001413 if (beacon) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301414 qdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001415 sizeof(tSmeIbssPeerInd)), (void *)beacon,
1416 beaconLen);
1417 }
1418
1419 mmhMsg.type = msgType;
1420 mmhMsg.bodyptr = pNewPeerInd;
Jeff Johnson35c58a82018-11-22 15:04:57 -08001421 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08001422 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001423
1424}
Abhishek Amburedddf4282019-09-27 18:54:38 +05301425#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001426
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07001427/**
1428 * lim_process_csa_wbw_ie() - Process CSA Wide BW IE
1429 * @mac_ctx: pointer to global adapter context
1430 * @csa_params: pointer to CSA parameters
1431 * @chnl_switch_info:pointer to channel switch parameters
1432 * @session_entry: session pointer
1433 *
1434 * Return: None
1435 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001436static QDF_STATUS lim_process_csa_wbw_ie(struct mac_context *mac_ctx,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001437 struct csa_offload_params *csa_params,
1438 tLimWiderBWChannelSwitchInfo *chnl_switch_info,
Jeff Johnsond7035a32018-11-18 22:03:13 -08001439 struct pe_session *session_entry)
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001440{
Amar Singhal5cccafe2017-02-15 12:42:58 -08001441 struct ch_params ch_params = {0};
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001442 uint8_t ap_new_ch_width;
1443 bool new_ch_width_dfn = false;
1444 uint8_t center_freq_diff;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001445 uint32_t fw_vht_ch_wd = wma_get_vht_ch_width() + 1;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001446
1447 ap_new_ch_width = csa_params->new_ch_width + 1;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001448
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001449 pe_debug("new channel: %d new_ch_width: %d seg0: %d seg1: %d",
1450 csa_params->channel, ap_new_ch_width,
1451 csa_params->new_ch_freq_seg1,
1452 csa_params->new_ch_freq_seg2);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001453
1454 if ((ap_new_ch_width != CH_WIDTH_80MHZ) &&
1455 (ap_new_ch_width != CH_WIDTH_160MHZ) &&
1456 (ap_new_ch_width != CH_WIDTH_80P80MHZ)) {
1457 pe_err("CSA wide BW IE has wrong ch_width %d",
1458 csa_params->new_ch_width);
1459 return QDF_STATUS_E_INVAL;
1460 }
1461
1462 if (!csa_params->new_ch_freq_seg1 && !csa_params->new_ch_freq_seg2) {
1463 pe_err("CSA wide BW IE has invalid center freq");
1464 return QDF_STATUS_E_INVAL;
1465 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001466 if ((ap_new_ch_width == CH_WIDTH_80MHZ) &&
1467 csa_params->new_ch_freq_seg2) {
1468 new_ch_width_dfn = true;
1469 if (csa_params->new_ch_freq_seg2 >
1470 csa_params->new_ch_freq_seg1)
1471 center_freq_diff = csa_params->new_ch_freq_seg2 -
1472 csa_params->new_ch_freq_seg1;
1473 else
1474 center_freq_diff = csa_params->new_ch_freq_seg1 -
1475 csa_params->new_ch_freq_seg2;
1476 if (center_freq_diff == CENTER_FREQ_DIFF_160MHz)
1477 ap_new_ch_width = CH_WIDTH_160MHZ;
1478 else if (center_freq_diff > CENTER_FREQ_DIFF_80P80MHz)
1479 ap_new_ch_width = CH_WIDTH_80P80MHZ;
1480 else
1481 ap_new_ch_width = CH_WIDTH_80MHZ;
1482 }
1483 session_entry->gLimChannelSwitch.state =
1484 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1485 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
1486 !new_ch_width_dfn) {
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001487 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1488 CH_TO_CNTR_FREQ_DIFF_160MHz) {
1489 pe_err("CSA wide BW IE has invalid center freq");
1490 return QDF_STATUS_E_INVAL;
1491 }
1492
1493 if (ap_new_ch_width > fw_vht_ch_wd) {
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001494 pe_debug("New BW is not supported, setting BW to %d",
1495 fw_vht_ch_wd);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001496 ap_new_ch_width = fw_vht_ch_wd;
1497 }
1498 ch_params.ch_width = ap_new_ch_width ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001499 wlan_reg_set_channel_params(mac_ctx->pdev,
1500 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001501 ap_new_ch_width = ch_params.ch_width;
1502 csa_params->new_ch_freq_seg1 = ch_params.center_freq_seg0;
1503 csa_params->new_ch_freq_seg2 = ch_params.center_freq_seg1;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001504 } else if (!new_ch_width_dfn) {
1505 if (ap_new_ch_width > fw_vht_ch_wd) {
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001506 pe_debug("New BW is not supported, setting BW to %d",
1507 fw_vht_ch_wd);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001508 ap_new_ch_width = fw_vht_ch_wd;
1509 }
1510 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1511 CH_TO_CNTR_FREQ_DIFF_80MHz) {
1512 pe_err("CSA wide BW IE has invalid center freq");
1513 return QDF_STATUS_E_INVAL;
1514 }
1515 csa_params->new_ch_freq_seg2 = 0;
1516 }
1517 if (new_ch_width_dfn) {
1518 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1519 CH_TO_CNTR_FREQ_DIFF_80MHz) {
1520 pe_err("CSA wide BW IE has invalid center freq");
1521 return QDF_STATUS_E_INVAL;
1522 }
1523 if (ap_new_ch_width > fw_vht_ch_wd) {
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001524 pe_debug("New width is not supported, setting BW to %d",
1525 fw_vht_ch_wd);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001526 ap_new_ch_width = fw_vht_ch_wd;
1527 }
1528 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
1529 (csa_params->new_ch_freq_seg1 !=
1530 csa_params->channel +
1531 CH_TO_CNTR_FREQ_DIFF_160MHz)) {
1532 pe_err("wide BW IE has invalid 160M center freq");
1533 csa_params->new_ch_freq_seg2 = 0;
1534 ap_new_ch_width = CH_WIDTH_80MHZ;
1535 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001536 }
1537 chnl_switch_info->newChanWidth = ap_new_ch_width;
1538 chnl_switch_info->newCenterChanFreq0 = csa_params->new_ch_freq_seg1;
1539 chnl_switch_info->newCenterChanFreq1 = csa_params->new_ch_freq_seg2;
1540
1541 if (session_entry->ch_width == ap_new_ch_width)
1542 goto prnt_log;
1543
1544 if (session_entry->ch_width == CH_WIDTH_80MHZ) {
1545 chnl_switch_info->newChanWidth = CH_WIDTH_80MHZ;
1546 chnl_switch_info->newCenterChanFreq1 = 0;
1547 } else {
1548 session_entry->ch_width = ap_new_ch_width;
1549 chnl_switch_info->newChanWidth = ap_new_ch_width;
1550 }
1551prnt_log:
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301552 pe_debug("new channel: %d new_ch_width: %d seg0: %d seg1: %d",
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001553 csa_params->channel,
1554 chnl_switch_info->newChanWidth,
1555 chnl_switch_info->newCenterChanFreq0,
1556 chnl_switch_info->newCenterChanFreq1);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001557
1558 return QDF_STATUS_SUCCESS;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001559}
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001560
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001561/**
1562 * lim_handle_csa_offload_msg() - Handle CSA offload message
1563 * @mac_ctx: pointer to global adapter context
1564 * @msg: Message pointer.
1565 *
1566 * Return: None
1567 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001568void lim_handle_csa_offload_msg(struct mac_context *mac_ctx,
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001569 struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001570{
Jeff Johnsond7035a32018-11-18 22:03:13 -08001571 struct pe_session *session_entry;
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301572 struct csa_offload_params *csa_params =
1573 (struct csa_offload_params *) (msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001574 tpDphHashNode sta_ds = NULL;
1575 uint8_t session_id;
1576 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05301577 uint16_t chan_space = 0;
Krunal Sonie2c45a92018-05-03 11:51:26 -07001578 struct ch_params ch_params = {0};
Gupta, Kapil121bf212015-11-25 19:21:29 +05301579
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001580 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08001581 tLimChannelSwitchInfo *lim_ch_switch = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001582
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301583 pe_debug("handle csa offload msg");
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301584
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001585 if (!csa_params) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301586 pe_err("limMsgQ body ptr is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001587 return;
1588 }
1589
1590 session_entry =
1591 pe_find_session_by_bssid(mac_ctx,
1592 csa_params->bssId, &session_id);
1593 if (!session_entry) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301594 pe_err("Session does not exists for %pM",
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301595 csa_params->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001596 goto err;
1597 }
1598
1599 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
1600 &session_entry->dph.dphHashTable);
1601
1602 if (!sta_ds) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301603 pe_err("sta_ds does not exist");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001604 goto err;
1605 }
1606
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001607 if (!LIM_IS_STA_ROLE(session_entry)) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301608 pe_debug("Invalid role to handle CSA");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001609 goto err;
1610 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001611 /*
1612 * on receiving channel switch announcement from AP, delete all
1613 * TDLS peers before leaving BSS and proceed for channel switch
1614 */
Bala Venkatesh33f270b2019-01-14 16:31:29 +05301615
1616 lim_update_tdls_set_state_for_fw(session_entry, false);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001617 lim_delete_tdls_peers(mac_ctx, session_entry);
Gupta, Kapil121bf212015-11-25 19:21:29 +05301618
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001619 lim_ch_switch = &session_entry->gLimChannelSwitch;
1620 session_entry->gLimChannelSwitch.switchMode =
1621 csa_params->switch_mode;
1622 /* timer already started by firmware, switch immediately */
1623 session_entry->gLimChannelSwitch.switchCount = 0;
1624 session_entry->gLimChannelSwitch.primaryChannel =
1625 csa_params->channel;
1626 session_entry->gLimChannelSwitch.state =
1627 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
1628 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
1629 lim_ch_switch->sec_ch_offset =
1630 session_entry->htSecondaryChannelOffset;
1631 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
1632 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
1633 chnl_switch_info =
1634 &session_entry->gLimWiderBWChannelSwitch;
1635
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001636 pe_debug("vht: %d ht: %d flag: %x chan: %d, sec_ch_offset %d",
1637 session_entry->vhtCapability,
1638 session_entry->htSupportedChannelWidthSet,
1639 csa_params->ies_present_flag,
1640 csa_params->channel,
1641 csa_params->sec_chan_offset);
1642 pe_debug("seg1: %d seg2: %d width: %d country: %s class: %d",
1643 csa_params->new_ch_freq_seg1,
1644 csa_params->new_ch_freq_seg2,
1645 csa_params->new_ch_width,
1646 mac_ctx->scan.countryCodeCurrent,
1647 csa_params->new_op_class);
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05301648
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001649 if (session_entry->vhtCapability &&
1650 session_entry->htSupportedChannelWidthSet) {
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001651 if ((csa_params->ies_present_flag & lim_wbw_ie_present) &&
1652 (QDF_STATUS_SUCCESS == lim_process_csa_wbw_ie(mac_ctx,
1653 csa_params, chnl_switch_info,
1654 session_entry))) {
1655 pe_debug("CSA wide BW IE process successful");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001656 lim_ch_switch->sec_ch_offset =
Abhishek Singhaf639b42017-06-16 14:14:36 +05301657 PHY_SINGLE_CHANNEL_CENTERED;
1658 if (chnl_switch_info->newChanWidth) {
1659 if (csa_params->channel <
1660 csa_params->new_ch_freq_seg1)
1661 lim_ch_switch->sec_ch_offset =
1662 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1663 else
1664 lim_ch_switch->sec_ch_offset =
1665 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1666 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001667 } else if (csa_params->ies_present_flag
1668 & lim_xcsa_ie_present) {
1669 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001670 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001671 mac_ctx->scan.countryCodeCurrent,
1672 csa_params->channel,
1673 csa_params->new_op_class);
1674 session_entry->gLimChannelSwitch.state =
1675 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1676
1677 if (chan_space == 80) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001678 chnl_switch_info->newChanWidth =
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001679 CH_WIDTH_80MHZ;
1680 } else if (chan_space == 40) {
1681 chnl_switch_info->newChanWidth =
1682 CH_WIDTH_40MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001683 } else {
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001684 chnl_switch_info->newChanWidth =
1685 CH_WIDTH_20MHZ;
1686 lim_ch_switch->state =
1687 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
1688 }
1689
1690 ch_params.ch_width =
1691 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001692 wlan_reg_set_channel_params(mac_ctx->pdev,
1693 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001694 chnl_switch_info->newCenterChanFreq0 =
1695 ch_params.center_freq_seg0;
1696 /*
1697 * This is not applicable for 20/40/80 MHz.
1698 * Only used when we support 80+80 MHz operation.
1699 * In case of 80+80 MHz, this parameter indicates
1700 * center channel frequency index of 80 MHz
1701 * channel offrequency segment 1.
1702 */
1703 chnl_switch_info->newCenterChanFreq1 =
1704 ch_params.center_freq_seg1;
1705 lim_ch_switch->sec_ch_offset =
1706 ch_params.sec_ch_offset;
1707
Kiran Kumar Lokere47127482017-12-20 18:09:55 -08001708 } else {
1709 lim_ch_switch->state =
1710 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1711 ch_params.ch_width = CH_WIDTH_40MHZ;
1712 wlan_reg_set_channel_params(mac_ctx->pdev,
1713 csa_params->channel, 0, &ch_params);
1714 lim_ch_switch->sec_ch_offset =
1715 ch_params.sec_ch_offset;
1716 chnl_switch_info->newChanWidth = CH_WIDTH_40MHZ;
1717 chnl_switch_info->newCenterChanFreq0 =
1718 ch_params.center_freq_seg0;
1719 chnl_switch_info->newCenterChanFreq1 = 0;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001720 }
1721 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
1722 chnl_switch_info->newCenterChanFreq0;
1723 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
1724 chnl_switch_info->newCenterChanFreq1;
1725 session_entry->gLimChannelSwitch.ch_width =
1726 chnl_switch_info->newChanWidth;
1727
1728 } else if (session_entry->htSupportedChannelWidthSet) {
1729 if (csa_params->ies_present_flag
1730 & lim_xcsa_ie_present) {
1731 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001732 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001733 mac_ctx->scan.countryCodeCurrent,
1734 csa_params->channel,
1735 csa_params->new_op_class);
1736 lim_ch_switch->state =
1737 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1738 if (chan_space == 40) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08001739 lim_ch_switch->ch_width =
1740 CH_WIDTH_40MHZ;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001741 chnl_switch_info->newChanWidth =
1742 CH_WIDTH_40MHZ;
1743 ch_params.ch_width =
1744 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001745 wlan_reg_set_channel_params(mac_ctx->pdev,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001746 csa_params->channel,
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07001747 0, &ch_params);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08001748 lim_ch_switch->ch_center_freq_seg0 =
1749 ch_params.center_freq_seg0;
1750 lim_ch_switch->sec_ch_offset =
1751 ch_params.sec_ch_offset;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001752 } else {
1753 lim_ch_switch->ch_width =
1754 CH_WIDTH_20MHZ;
1755 chnl_switch_info->newChanWidth =
1756 CH_WIDTH_40MHZ;
1757 lim_ch_switch->state =
1758 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
1759 lim_ch_switch->sec_ch_offset =
1760 PHY_SINGLE_CHANNEL_CENTERED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001761 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001762 } else {
1763 lim_ch_switch->ch_width =
1764 CH_WIDTH_40MHZ;
1765 lim_ch_switch->state =
1766 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1767 ch_params.ch_width = CH_WIDTH_40MHZ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001768 wlan_reg_set_channel_params(mac_ctx->pdev,
1769 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001770 lim_ch_switch->ch_center_freq_seg0 =
1771 ch_params.center_freq_seg0;
1772 lim_ch_switch->sec_ch_offset =
1773 ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001774 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001775
1776 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301777 pe_debug("new ch width: %d space: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05301778 session_entry->gLimChannelSwitch.ch_width, chan_space);
Liangwei Donge0d4db22019-07-15 16:40:48 +08001779 if ((wlan_reg_freq_to_chan(mac_ctx->pdev,
1780 session_entry->curr_op_freq) ==
1781 csa_params->channel) &&
1782 session_entry->ch_width ==
1783 session_entry->gLimChannelSwitch.ch_width) {
Kiran Kumar Lokere75d636f2016-12-20 14:52:03 -08001784 pe_debug("Ignore CSA, no change in ch and bw");
1785 goto err;
1786 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001787
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05301788 if (WLAN_REG_IS_24GHZ_CH(csa_params->channel) &&
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +05301789 (session_entry->dot11mode == MLME_DOT11_MODE_11A))
1790 session_entry->dot11mode = MLME_DOT11_MODE_11G;
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05301791 else if (WLAN_REG_IS_5GHZ_CH(csa_params->channel) &&
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +05301792 ((session_entry->dot11mode == MLME_DOT11_MODE_11G) ||
1793 (session_entry->dot11mode == MLME_DOT11_MODE_11G_ONLY)))
1794 session_entry->dot11mode = MLME_DOT11_MODE_11A;
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05301795
Vignesh Viswanathan3d478032018-08-02 20:18:53 +05301796 /* Send RSO Stop to FW before triggering the vdev restart for CSA */
1797 if (mac_ctx->lim.stop_roaming_callback)
1798 mac_ctx->lim.stop_roaming_callback(mac_ctx,
1799 session_entry->smeSessionId,
Abhinav Kumar523ca372019-08-30 16:28:19 +05301800 REASON_DRIVER_DISABLED,
1801 RSO_CHANNEL_SWITCH);
Vignesh Viswanathan3d478032018-08-02 20:18:53 +05301802
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001803 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001804
Abhishek Singhecc2c752019-03-18 11:05:39 +05301805 lim_flush_bssid(mac_ctx, session_entry->bssId);
1806
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001807#ifdef FEATURE_WLAN_DIAG_SUPPORT
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001808 lim_diag_event_report(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001809 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001810 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001811#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001812
1813err:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301814 qdf_mem_free(csa_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001815}
1816
1817/*--------------------------------------------------------------------------
1818 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
1819
Jeff Johnson35c58a82018-11-22 15:04:57 -08001820 \param mac - pointer to global adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001821 \param sessionId - Message pointer.
1822
1823 \sa
1824 --------------------------------------------------------------------------*/
1825
Abhishek Ambure2bd960b2019-08-21 16:30:53 +05301826void lim_handle_delete_bss_rsp(struct mac_context *mac,
Abhishek Ambure968f1512019-08-28 18:33:57 +05301827 struct del_bss_resp *del_bss_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001828{
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001829 struct pe_session *pe_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001830
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001831 pe_session =
Abhishek Singhefe21e62019-09-20 10:03:24 +05301832 pe_find_session_by_vdev_id(mac, del_bss_rsp->vdev_id);
Jeff Johnson8e9530b2019-03-18 13:41:42 -07001833 if (!pe_session) {
Abhishek Ambure2bd960b2019-08-21 16:30:53 +05301834 pe_err("Session Does not exist for vdev id: %d",
Abhishek Ambure968f1512019-08-28 18:33:57 +05301835 del_bss_rsp->vdev_id);
1836 qdf_mem_free(del_bss_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001837 return;
1838 }
Krunal Sonie50ff452017-10-11 18:23:55 -07001839
1840 /*
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07001841 * During DEL BSS handling, the PE Session will be deleted, but it is
1842 * better to clear this flag if the session is hanging around due
1843 * to some error conditions so that the next DEL_BSS request does
1844 * not take the HO_FAIL path
1845 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001846 pe_session->process_ho_fail = false;
1847 if (LIM_IS_IBSS_ROLE(pe_session))
Abhishek Ambure968f1512019-08-28 18:33:57 +05301848 lim_ibss_del_bss_rsp(mac, del_bss_rsp, pe_session);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001849 else if (LIM_IS_UNKNOWN_ROLE(pe_session))
Abhishek Ambure2bd960b2019-08-21 16:30:53 +05301850 lim_process_sme_del_bss_rsp(mac, pe_session);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001851 else if (LIM_IS_NDI_ROLE(pe_session))
Abhishek Ambure968f1512019-08-28 18:33:57 +05301852 lim_ndi_del_bss_rsp(mac, del_bss_rsp, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001853 else
Abhishek Ambure968f1512019-08-28 18:33:57 +05301854 lim_process_mlm_del_bss_rsp(mac, del_bss_rsp, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001855
Abhishek Ambure968f1512019-08-28 18:33:57 +05301856 qdf_mem_free(del_bss_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001857}
1858
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001859/** -----------------------------------------------------------------
1860 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
1861 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
1862 \ SME only looks at rc and tspec field.
Jeff Johnson35c58a82018-11-22 15:04:57 -08001863 \param mac - global mac structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001864 \param rspReqd - is SmeAddTsRsp required
1865 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
1866 \return tspec
1867 \sa
1868 ----------------------------------------------------------------- */
1869void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001870lim_send_sme_aggr_qos_rsp(struct mac_context *mac, tpSirAggrQosRsp aggrQosRsp,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001871 uint8_t smesessionId)
1872{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001873 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001874
1875 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
1876 mmhMsg.bodyptr = aggrQosRsp;
1877 mmhMsg.bodyval = 0;
Jeff Johnson35c58a82018-11-22 15:04:57 -08001878 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301879 smesessionId, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08001880 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001881
1882 return;
1883}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001884
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001885void lim_send_sme_max_assoc_exceeded_ntf(struct mac_context *mac, tSirMacAddr peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001886 uint8_t smesessionId)
1887{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001888 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001889 tSmeMaxAssocInd *pSmeMaxAssocInd;
1890
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301891 pSmeMaxAssocInd = qdf_mem_malloc(sizeof(tSmeMaxAssocInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001892 if (!pSmeMaxAssocInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001893 return;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301894 qdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peer_mac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301895 (uint8_t *) peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001896 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
1897 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
1898 pSmeMaxAssocInd->sessionId = smesessionId;
1899 mmhMsg.type = pSmeMaxAssocInd->mesgType;
1900 mmhMsg.bodyptr = pSmeMaxAssocInd;
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07001901 pe_debug("msgType: %s peerMacAddr "QDF_MAC_ADDR_STR "sme session id %d",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07001902 "eWNI_SME_MAX_ASSOC_EXCEEDED", QDF_MAC_ADDR_ARRAY(peerMacAddr),
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301903 pSmeMaxAssocInd->sessionId);
Jeff Johnson35c58a82018-11-22 15:04:57 -08001904 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301905 smesessionId, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08001906 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001907
1908 return;
1909}
1910
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001911/** -----------------------------------------------------------------
1912 \brief lim_send_sme_ap_channel_switch_resp() - sends
1913 eWNI_SME_CHANNEL_CHANGE_RSP
1914 After receiving WMA_SWITCH_CHANNEL_RSP indication this
1915 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
1916 that the Channel change has been done to the specified target
1917 channel in the Channel change request
Jeff Johnson35c58a82018-11-22 15:04:57 -08001918 \param mac - global mac structure
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001919 \param pe_session - session info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001920 \param pChnlParams - Channel switch params
1921 --------------------------------------------------------------------*/
1922void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001923lim_send_sme_ap_channel_switch_resp(struct mac_context *mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001924 struct pe_session *pe_session,
Jianmin Zhu160d3642019-08-19 21:27:52 +08001925 struct vdev_start_response *rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001926{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001927 struct scheduler_msg mmhMsg = {0};
Jianmin Zhue9fbc3f2019-09-18 09:55:16 +08001928 struct sSirChanChangeResponse *chan_change_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001929 uint8_t channelId;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08001930 bool is_ch_dfs = false;
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08001931 enum phy_ch_width ch_width;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08001932 uint8_t ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001933
gaurank kathpalia2fcec842019-08-05 17:22:27 +05301934 qdf_runtime_pm_allow_suspend(&pe_session->ap_ecsa_runtime_lock);
1935 qdf_wake_lock_release(&pe_session->ap_ecsa_wakelock, 0);
1936
Jianmin Zhue9fbc3f2019-09-18 09:55:16 +08001937 chan_change_rsp =
1938 qdf_mem_malloc(sizeof(struct sSirChanChangeResponse));
1939 if (!chan_change_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001940 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001941
Jianmin Zhue9fbc3f2019-09-18 09:55:16 +08001942 chan_change_rsp->new_op_freq = pe_session->curr_op_freq;
1943 chan_change_rsp->channelChangeStatus = rsp->status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001944 /*
1945 * Pass the sme sessionID to SME instead
1946 * PE session ID.
1947 */
Jianmin Zhue9fbc3f2019-09-18 09:55:16 +08001948 chan_change_rsp->sessionId = rsp->vdev_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001949
1950 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
Jianmin Zhue9fbc3f2019-09-18 09:55:16 +08001951 mmhMsg.bodyptr = (void *)chan_change_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001952 mmhMsg.bodyval = 0;
Jeff Johnsona5abe272019-01-06 12:52:02 -08001953 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001954
Jianmin Zhu160d3642019-08-19 21:27:52 +08001955 if (QDF_IS_STATUS_ERROR(rsp->status)) {
Jianmin Zhue9fbc3f2019-09-18 09:55:16 +08001956 pe_err("failed to change sap freq to %u",
1957 pe_session->curr_op_freq);
Jingxiang Geace2c3c2019-08-05 16:05:31 +08001958 return;
1959 }
1960
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001961 /*
1962 * We should start beacon transmission only if the new
1963 * channel after channel change is Non-DFS. For a DFS
1964 * channel, PE will receive an explicit request from
1965 * upper layers to start the beacon transmission .
1966 */
Jianmin Zhue9fbc3f2019-09-18 09:55:16 +08001967 ch_width = pe_session->ch_width;
1968 ch_center_freq_seg1 = pe_session->ch_center_freq_seg1;
1969 channelId = wlan_reg_freq_to_chan(mac->pdev, pe_session->curr_op_freq);
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08001970 if (ch_width == CH_WIDTH_160MHZ) {
1971 is_ch_dfs = true;
1972 } else if (ch_width == CH_WIDTH_80P80MHZ) {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001973 if (wlan_reg_get_channel_state(mac->pdev, channelId) ==
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001974 CHANNEL_STATE_DFS ||
Jeff Johnson35c58a82018-11-22 15:04:57 -08001975 wlan_reg_get_channel_state(mac->pdev,
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001976 ch_center_freq_seg1 -
1977 SIR_80MHZ_START_CENTER_CH_DIFF) ==
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08001978 CHANNEL_STATE_DFS)
1979 is_ch_dfs = true;
1980 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001981 if (wlan_reg_get_channel_state(mac->pdev, channelId) ==
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001982 CHANNEL_STATE_DFS)
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08001983 is_ch_dfs = true;
1984 }
1985
Jingxiang Geace2c3c2019-08-05 16:05:31 +08001986 if (is_ch_dfs) {
1987 lim_sap_move_to_cac_wait_state(pe_session);
1988
1989 } else {
Jianmin Zhu160d3642019-08-19 21:27:52 +08001990 lim_apply_configuration(mac, pe_session);
1991 lim_send_beacon(mac, pe_session);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001992 lim_obss_send_detection_cfg(mac, pe_session, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001993 }
1994 return;
1995}
1996
Peng Xu6363ec62017-05-15 11:06:33 -07001997#ifdef WLAN_FEATURE_11AX_BSS_COLOR
1998/**
1999 * lim_send_bss_color_change_ie_update() - update bss color change IE in
2000 * beacon template
2001 *
2002 * @mac_ctx: pointer to global adapter context
2003 * @session: session pointer
2004 *
2005 * Return: none
2006 */
2007static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002008lim_send_bss_color_change_ie_update(struct mac_context *mac_ctx,
Jeff Johnsond7035a32018-11-18 22:03:13 -08002009 struct pe_session *session)
Peng Xu6363ec62017-05-15 11:06:33 -07002010{
2011 /* Update the beacon template and send to FW */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002012 if (sch_set_fixed_beacon_fields(mac_ctx, session) != QDF_STATUS_SUCCESS) {
Peng Xu6363ec62017-05-15 11:06:33 -07002013 pe_err("Unable to set BSS color change IE in beacon");
Srinivas Girigowdaeff16d92018-09-12 14:56:29 -07002014 return;
Peng Xu6363ec62017-05-15 11:06:33 -07002015 }
2016
2017 /* Send update beacon template message */
Abhishek Singhfc740be2018-10-12 11:34:26 +05302018 lim_send_beacon_ind(mac_ctx, session, REASON_COLOR_CHANGE);
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07002019 pe_debug("Updated BSS color change countdown = %d",
2020 session->he_bss_color_change.countdown);
Peng Xu6363ec62017-05-15 11:06:33 -07002021}
2022
2023static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002024lim_handle_bss_color_change_ie(struct mac_context *mac_ctx,
Jeff Johnsond7035a32018-11-18 22:03:13 -08002025 struct pe_session *session)
Peng Xu6363ec62017-05-15 11:06:33 -07002026{
Arif Hussain2f2d3512018-03-06 12:37:03 -08002027 tUpdateBeaconParams beacon_params;
2028
Peng Xu6363ec62017-05-15 11:06:33 -07002029 /* handle bss color change IE */
2030 if (LIM_IS_AP_ROLE(session) &&
2031 session->he_op.bss_col_disabled) {
2032 if (session->he_bss_color_change.countdown > 0) {
2033 session->he_bss_color_change.countdown--;
2034 } else {
2035 session->bss_color_changing = 0;
Arif Hussain2f2d3512018-03-06 12:37:03 -08002036 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
Arif Hussain05fb4872018-01-03 16:02:55 -08002037 if (session->he_bss_color_change.new_color != 0) {
Peng Xu6363ec62017-05-15 11:06:33 -07002038 session->he_op.bss_col_disabled = 0;
Arif Hussain05fb4872018-01-03 16:02:55 -08002039 session->he_op.bss_color =
2040 session->he_bss_color_change.new_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08002041 beacon_params.paramChangeBitmap |=
2042 PARAM_BSS_COLOR_CHANGED;
2043 beacon_params.bss_color_disabled = 0;
2044 beacon_params.bss_color =
2045 session->he_op.bss_color;
2046 lim_send_beacon_params(mac_ctx,
2047 &beacon_params,
2048 session);
Arif Hussain05fb4872018-01-03 16:02:55 -08002049 lim_send_obss_color_collision_cfg(mac_ctx,
2050 session,
2051 OBSS_COLOR_COLLISION_DETECTION);
2052 }
Peng Xu6363ec62017-05-15 11:06:33 -07002053 }
2054
2055 lim_send_bss_color_change_ie_update(mac_ctx, session);
2056 }
2057}
2058
2059#else
2060static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002061lim_handle_bss_color_change_ie(struct mac_context *mac_ctx,
Jeff Johnsond7035a32018-11-18 22:03:13 -08002062 struct pe_session *session)
Peng Xu6363ec62017-05-15 11:06:33 -07002063{
2064}
2065#endif
2066
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002067void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002068lim_process_beacon_tx_success_ind(struct mac_context *mac_ctx, uint16_t msgType,
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302069 void *event)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002070{
Jeff Johnsond7035a32018-11-18 22:03:13 -08002071 struct pe_session *session;
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302072 tpSirFirstBeaconTxCompleteInd bcn_ind =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002073 (tSirFirstBeaconTxCompleteInd *) event;
2074
Abhishek Singhc70afa32019-09-19 15:17:21 +05302075 session = pe_find_session_by_vdev_id(mac_ctx, bcn_ind->bss_idx);
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302076 if (!session) {
2077 pe_err("Session Does not exist for given session id");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002078 return;
2079 }
2080
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302081 pe_debug("role: %d swIe: %d opIe: %d switch cnt:%d",
2082 GET_LIM_SYSTEM_ROLE(session),
2083 session->dfsIncludeChanSwIe,
2084 session->gLimOperatingMode.present,
2085 session->gLimChannelSwitch.switchCount);
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302086
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302087 if (!LIM_IS_AP_ROLE(session))
2088 return;
Ganesh Kondabattini02ec62b2018-01-24 18:22:24 +05302089
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302090 if (session->dfsIncludeChanSwIe &&
2091 (session->gLimChannelSwitch.switchCount ==
2092 mac_ctx->sap.SapDfsInfo.sap_ch_switch_beacon_cnt))
2093 lim_process_ap_ecsa_timeout(session);
Ganesh Kondabattini02ec62b2018-01-24 18:22:24 +05302094
lifeng1c16b6b2017-09-25 13:59:55 +08002095
Abhishek Singhfc740be2018-10-12 11:34:26 +05302096 if (session->gLimOperatingMode.present)
2097 /* Done with nss update */
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302098 session->gLimOperatingMode.present = 0;
Peng Xu6363ec62017-05-15 11:06:33 -07002099
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302100 lim_handle_bss_color_change_ie(mac_ctx, session);
Peng Xu6363ec62017-05-15 11:06:33 -07002101
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002102 return;
2103}