blob: 6ae5d192251a2930e1c30f28ee4ea24ffc99ba96 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Wu Gao6768d762018-12-28 16:31:08 +08002 * Copyright (c) 2012-2019 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
19/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020 * This file lim_send_sme_rspMessages.cc contains the functions
21 * for sending SME response/notification messages to applications
22 * above MAC software.
23 * Author: Chandra Modumudi
24 * Date: 02/13/02
25 * History:-
26 * Date Modified by Modification Information
27 * --------------------------------------------------------------------
28 */
29
Anurag Chouhan6d760662016-02-20 16:05:43 +053030#include "qdf_types.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080031#include "wni_api.h"
32#include "sir_common.h"
33#include "ani_global.h"
34
35#include "wni_cfg.h"
36#include "sys_def.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080037
38#include "sch_api.h"
39#include "utils_api.h"
40#include "lim_utils.h"
41#include "lim_security_utils.h"
42#include "lim_ser_des_utils.h"
43#include "lim_send_sme_rsp_messages.h"
44#include "lim_ibss_peer_mgmt.h"
45#include "lim_session_utils.h"
46#include "lim_types.h"
47#include "sir_api.h"
Naveen Rawat3b6068c2016-04-14 19:01:06 -070048#include "cds_regdomain.h"
Gupta, Kapil121bf212015-11-25 19:21:29 +053049#include "lim_send_messages.h"
Deepak Dhamdhere13983f22016-05-31 19:06:09 -070050#include "nan_datapath.h"
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -070051#include "lim_assoc_utils.h"
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070052#include "wlan_reg_services_api.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070053#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080054
Kabilan Kannanf56f9d52017-04-05 03:31:34 -070055#include "wlan_tdls_tgt_api.h"
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +053056#include "lim_process_fils.h"
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -080057#include "wma.h"
Kabilan Kannanf56f9d52017-04-05 03:31:34 -070058
Jeff Johnson41485c22019-02-21 11:00:30 -080059void lim_send_sme_rsp(struct mac_context *mac_ctx, uint16_t msg_type,
60 tSirResultCodes result_code, uint8_t sme_session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080061{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070062 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080063 tSirSmeRsp *sme_rsp;
64
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +053065 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080066 lim_msg_str(msg_type), lim_result_code_str(result_code));
67
Anurag Chouhan600c3a02016-03-01 10:33:54 +053068 sme_rsp = qdf_mem_malloc(sizeof(tSirSmeRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -070069 if (!sme_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080070 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080071
72 sme_rsp->messageType = msg_type;
73 sme_rsp->length = sizeof(tSirSmeRsp);
74 sme_rsp->statusCode = result_code;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080075 sme_rsp->sessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080076
77 msg.type = msg_type;
78 msg.bodyptr = sme_rsp;
79 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +053080 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG,
81 sme_session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080082
83#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
84 switch (msg_type) {
85 case eWNI_SME_STOP_BSS_RSP:
86 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_STOP_BSS_RSP_EVENT,
87 NULL, (uint16_t) result_code, 0);
88 break;
89 }
90#endif /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsona5abe272019-01-06 12:52:02 -080091 lim_sys_process_mmh_msg_api(mac_ctx, &msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080092}
93
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080094/**
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +053095 * lim_get_max_rate_flags() - Get rate flags
96 * @mac_ctx: Pointer to global MAC structure
97 * @sta_ds: Pointer to station ds structure
98 *
99 * This function is called to get the rate flags for a connection
100 * from the station ds structure depending on the ht and the vht
101 * channel width supported.
102 *
103 * Return: Returns the populated rate_flags
104 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800105uint32_t lim_get_max_rate_flags(struct mac_context *mac_ctx, tpDphHashNode sta_ds)
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530106{
107 uint32_t rate_flags = 0;
108
109 if (sta_ds == NULL) {
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
194 if (result_code == eSIR_SME_SUCCESS) {
195 if (session_entry->beacon != NULL) {
196 sme_join_rsp->beaconLength = session_entry->bcnLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530197 qdf_mem_copy(sme_join_rsp->frames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800198 session_entry->beacon,
199 sme_join_rsp->beaconLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530200 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800201 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530202 session_entry->bcnLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530203 pe_debug("Beacon: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530204 sme_join_rsp->beaconLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800205 }
206 if (session_entry->assocReq != NULL) {
207 sme_join_rsp->assocReqLength =
208 session_entry->assocReqLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530209 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530210 sme_join_rsp->beaconLength,
211 session_entry->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800212 sme_join_rsp->assocReqLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530213 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800214 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530215 session_entry->assocReqLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530216 pe_debug("AssocReq: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530217 sme_join_rsp->assocReqLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800218 }
219 if (session_entry->assocRsp != NULL) {
220 sme_join_rsp->assocRspLength =
221 session_entry->assocRspLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530222 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530223 sme_join_rsp->beaconLength +
224 sme_join_rsp->assocReqLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800225 session_entry->assocRsp,
226 sme_join_rsp->assocRspLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530227 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800228 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530229 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800230 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800231 if (session_entry->ricData != NULL) {
232 sme_join_rsp->parsedRicRspLen =
233 session_entry->RICDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530234 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530235 sme_join_rsp->beaconLength +
236 sme_join_rsp->assocReqLength +
237 sme_join_rsp->assocRspLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800238 session_entry->ricData,
239 sme_join_rsp->parsedRicRspLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530240 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800241 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530242 session_entry->RICDataLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530243 pe_debug("RicLength: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800244 sme_join_rsp->parsedRicRspLen);
245 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800246#ifdef FEATURE_WLAN_ESE
247 if (session_entry->tspecIes != NULL) {
248 sme_join_rsp->tspecIeLen =
249 session_entry->tspecLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530250 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530251 sme_join_rsp->beaconLength +
252 sme_join_rsp->assocReqLength +
253 sme_join_rsp->assocRspLength +
254 sme_join_rsp->parsedRicRspLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800255 session_entry->tspecIes,
256 sme_join_rsp->tspecIeLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530257 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800258 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530259 session_entry->tspecLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530260 pe_debug("ESE-TspecLen: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530261 sme_join_rsp->tspecIeLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800262 }
263#endif
264 sme_join_rsp->aid = session_entry->limAID;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530265 pe_debug("AssocRsp: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530266 sme_join_rsp->assocRspLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800267 sme_join_rsp->vht_channel_width =
268 session_entry->ch_width;
269#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
270 if (session_entry->cc_switch_mode !=
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530271 QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Jeff Johnsonf6541882019-02-02 16:16:00 -0800272 ht_profile = &sme_join_rsp->ht_profile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800273 ht_profile->htSupportedChannelWidthSet =
274 session_entry->htSupportedChannelWidthSet;
275 ht_profile->htRecommendedTxWidthSet =
276 session_entry->htRecommendedTxWidthSet;
277 ht_profile->htSecondaryChannelOffset =
278 session_entry->htSecondaryChannelOffset;
279 ht_profile->dot11mode = session_entry->dot11mode;
280 ht_profile->htCapability = session_entry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800281 ht_profile->vhtCapability =
282 session_entry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800283 ht_profile->apCenterChan = session_entry->ch_center_freq_seg0;
284 ht_profile->apChanWidth = session_entry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800285 }
286#endif
Jeff Johnson11bd4f32017-09-18 08:15:17 -0700287 pe_debug("pLimJoinReq:%pK, pLimReAssocReq:%pK",
Wu Gao2968fc92017-06-19 19:18:34 +0800288 session_entry->pLimJoinReq,
289 session_entry->pLimReAssocReq);
290
291 if (session_entry->pLimJoinReq)
292 join_reassoc_req = session_entry->pLimJoinReq;
293
294 if (session_entry->pLimReAssocReq)
295 join_reassoc_req = session_entry->pLimReAssocReq;
296
297 if (!join_reassoc_req) {
298 pe_err("both pLimJoinReq and pLimReAssocReq NULL");
299 return;
300 }
301
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700302 bss_ie_len = lim_get_ielen_from_bss_description(
Wu Gao2968fc92017-06-19 19:18:34 +0800303 &join_reassoc_req->bssDescription);
304 bss_ies = &join_reassoc_req->bssDescription.ieFields;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700305 is_vendor_ap_1_present = (wlan_get_vendor_ie_ptr_from_oui(
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700306 SIR_MAC_VENDOR_AP_1_OUI, SIR_MAC_VENDOR_AP_1_OUI_LEN,
307 bss_ies, bss_ie_len) != NULL);
308
309 if (mac_ctx->roam.configParam.is_force_1x1 &&
Krunal Sonie6a1cda2017-09-27 15:23:02 -0700310 is_vendor_ap_1_present && (session_entry->nss == 2) &&
311 (mac_ctx->lteCoexAntShare == 0 ||
312 IS_5G_CH(session_entry->currentOperChannel))) {
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700313 /* SET vdev param */
314 pe_debug("sending SMPS intolrent vdev_param");
315 wma_cli_set_command(session_entry->smeSessionId,
316 (int)WMI_VDEV_PARAM_SMPS_INTOLERANT,
317 1, VDEV_CMD);
318
319 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800320 } else {
321 if (session_entry->beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530322 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800323 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530324 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800325 }
326 if (session_entry->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530327 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800328 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530329 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800330 }
331 if (session_entry->assocRsp != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530332 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800333 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530334 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800335 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800336 if (session_entry->ricData != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530337 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800338 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530339 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800340 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800341#ifdef FEATURE_WLAN_ESE
342 if (session_entry->tspecIes != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530343 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800344 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530345 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800346 }
347#endif
348 }
349}
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530350
351/**
352 * lim_add_bss_info() - copy data from session entry to join rsp
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530353 * @sta_ds: Station dph entry
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530354 * @sme_join_rsp: Join response buffer to be filled up
355 *
356 * Return: None
357 */
Jeff Johnson2df04b82019-02-02 23:30:25 -0800358static void lim_add_bss_info(tpDphHashNode sta_ds,
359 struct join_rsp *sme_join_rsp)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530360{
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530361 struct parsed_ies *parsed_ies = &sta_ds->parsed_ies;
362
363 if (parsed_ies->hs20vendor_ie.present)
364 sme_join_rsp->hs20vendor_ie = parsed_ies->hs20vendor_ie;
365 if (parsed_ies->vht_caps.present)
366 sme_join_rsp->vht_caps = parsed_ies->vht_caps;
367 if (parsed_ies->ht_caps.present)
368 sme_join_rsp->ht_caps = parsed_ies->ht_caps;
369 if (parsed_ies->ht_operation.present)
370 sme_join_rsp->ht_operation = parsed_ies->ht_operation;
371 if (parsed_ies->vht_operation.present)
372 sme_join_rsp->vht_operation = parsed_ies->vht_operation;
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530373}
374
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530375#ifdef WLAN_FEATURE_FILS_SK
Jeff Johnson2df04b82019-02-02 23:30:25 -0800376static void lim_update_fils_seq_num(struct join_rsp *sme_join_rsp,
Jeff Johnsond7035a32018-11-18 22:03:13 -0800377 struct pe_session *session_entry)
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530378{
379 sme_join_rsp->fils_seq_num =
380 session_entry->fils_info->sequence_number;
381}
382#else
Jeff Johnson2df04b82019-02-02 23:30:25 -0800383static inline void lim_update_fils_seq_num(struct join_rsp *sme_join_rsp,
Jeff Johnsond7035a32018-11-18 22:03:13 -0800384 struct pe_session *session_entry)
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530385{}
386#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800387
Jeff Johnson27b98962019-02-20 20:53:08 -0800388void lim_send_sme_join_reassoc_rsp(struct mac_context *mac_ctx,
389 uint16_t msg_type,
390 tSirResultCodes result_code,
391 uint16_t prot_status_code,
392 struct pe_session *session_entry,
393 uint8_t sme_session_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800394{
Jeff Johnson2df04b82019-02-02 23:30:25 -0800395 struct join_rsp *sme_join_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800396 uint32_t rsp_len;
397 tpDphHashNode sta_ds = NULL;
398#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
399 if (msg_type == eWNI_SME_REASSOC_RSP)
400 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_RSP_EVENT,
401 session_entry, (uint16_t) result_code, 0);
402 else
403 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_RSP_EVENT,
404 session_entry, (uint16_t) result_code, 0);
405#endif /* FEATURE_WLAN_DIAG_SUPPORT */
406
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530407 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800408 lim_msg_str(msg_type), lim_result_code_str(result_code));
409
410 if (session_entry == NULL) {
Jeff Johnson2df04b82019-02-02 23:30:25 -0800411 rsp_len = sizeof(*sme_join_rsp);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530412 sme_join_rsp = qdf_mem_malloc(rsp_len);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700413 if (!sme_join_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800414 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800415
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800416 sme_join_rsp->beaconLength = 0;
417 sme_join_rsp->assocReqLength = 0;
418 sme_join_rsp->assocRspLength = 0;
419 } else {
420 rsp_len = session_entry->assocReqLen +
421 session_entry->assocRspLen + session_entry->bcnLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800422 session_entry->RICDataLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800423#ifdef FEATURE_WLAN_ESE
424 session_entry->tspecLen +
425#endif
Jeff Johnson2df04b82019-02-02 23:30:25 -0800426 sizeof(*sme_join_rsp) - sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530427 sme_join_rsp = qdf_mem_malloc(rsp_len);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700428 if (!sme_join_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800429 return;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530430
431 if (lim_is_fils_connection(session_entry)) {
432 sme_join_rsp->is_fils_connection = true;
433 lim_update_fils_seq_num(sme_join_rsp,
434 session_entry);
435 }
436
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800437 if (result_code == eSIR_SME_SUCCESS) {
438 sta_ds = dph_get_hash_entry(mac_ctx,
439 DPH_STA_HASH_INDEX_PEER,
440 &session_entry->dph.dphHashTable);
441 if (sta_ds == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530442 pe_err("Get Self Sta Entry fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800443 } else {
444 /* Pass the peer's staId */
445 sme_join_rsp->staId = sta_ds->staIndex;
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;
484 sme_join_rsp->statusCode = result_code;
485 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 Johnsonb5c13332018-12-03 09:54:51 -0800511 if (pe_session == NULL) {
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
548 pSirSmeRsp->bssDescription.channelId =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800549 pe_session->currentOperChannel;
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)
565 (offsetof(tSirBssDescription, ieFields[0])
566 - 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;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800598 pSirSmeRsp->statusCode = resultCode;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800599 if (pe_session != NULL)
600 pSirSmeRsp->staId = pe_session->staId; /* else it will be always zero smeRsp StaID = 0 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800601
602 mmhMsg.type = msgType;
603 mmhMsg.bodyptr = pSirSmeRsp;
604 mmhMsg.bodyval = 0;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800605 if (pe_session == NULL) {
Jeff Johnson35c58a82018-11-22 15:04:57 -0800606 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530607 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800608 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -0800609 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800610 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800611 }
612#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -0800613 lim_diag_event_report(mac, WLAN_PE_DIAG_START_BSS_RSP_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800614 pe_session, (uint16_t) resultCode, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800615#endif /* FEATURE_WLAN_DIAG_SUPPORT */
616
Jeff Johnsona5abe272019-01-06 12:52:02 -0800617 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800618} /*** end lim_send_sme_start_bss_rsp() ***/
619
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800620void lim_send_sme_disassoc_deauth_ntf(struct mac_context *mac,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530621 QDF_STATUS status, uint32_t *pCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800622{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700623 struct scheduler_msg mmhMsg = {0};
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800624 struct scheduler_msg *pMsg = (struct scheduler_msg *) pCtx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800625
626 mmhMsg.type = pMsg->type;
627 mmhMsg.bodyptr = pMsg;
628 mmhMsg.bodyval = 0;
629
Jeff Johnson35c58a82018-11-22 15:04:57 -0800630 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800631
Jeff Johnsona5abe272019-01-06 12:52:02 -0800632 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800633}
634
Jeff Johnsonb82e6d72019-02-20 21:32:32 -0800635void lim_send_sme_disassoc_ntf(struct mac_context *mac,
636 tSirMacAddr peerMacAddr,
637 tSirResultCodes reasonCode,
638 uint16_t disassocTrigger,
639 uint16_t aid,
640 uint8_t smesessionId,
641 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800642{
Jeff Johnson380a1cd2019-02-03 21:43:51 -0800643 struct disassoc_rsp *pSirSmeDisassocRsp;
Jeff Johnson318a9882019-02-04 08:30:50 -0800644 struct disassoc_ind *pSirSmeDisassocInd;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700645 uint32_t *pMsg = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800646 bool failure = false;
Jeff Johnsond7035a32018-11-18 22:03:13 -0800647 struct pe_session *session = NULL;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700648 uint16_t i, assoc_id;
649 tpDphHashNode sta_ds = NULL;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +0530650 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800651
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530652 pe_debug("Disassoc Ntf with trigger : %d reasonCode: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800653 disassocTrigger, reasonCode);
654
655 switch (disassocTrigger) {
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700656 case eLIM_DUPLICATE_ENTRY:
657 /*
658 * Duplicate entry is removed at LIM.
659 * Initiate new entry for other session
660 */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530661 pe_debug("Rcvd eLIM_DUPLICATE_ENTRY for " MAC_ADDRESS_STR,
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700662 MAC_ADDR_ARRAY(peerMacAddr));
663
Jeff Johnson35c58a82018-11-22 15:04:57 -0800664 for (i = 0; i < mac->lim.maxBssId; i++) {
Jeff Johnsoneac5aad2019-03-19 12:57:04 -0700665 session = &mac->lim.gpSession[i];
666 if (session->valid &&
667 (session->pePersona == QDF_SAP_MODE)) {
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700668 /* Find the sta ds entry in another session */
Jeff Johnson35c58a82018-11-22 15:04:57 -0800669 sta_ds = dph_lookup_hash_entry(mac,
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700670 peerMacAddr, &assoc_id,
671 &session->dph.dphHashTable);
Abhishek Singh6d6e3d12017-12-04 14:16:00 +0530672 if (sta_ds)
673 break;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700674 }
675 }
676 if (sta_ds
677#ifdef WLAN_FEATURE_11W
678 && (!sta_ds->rmfEnabled)
679#endif
680 ) {
Jeff Johnson35c58a82018-11-22 15:04:57 -0800681 if (lim_add_sta(mac, sta_ds, false, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700682 QDF_STATUS_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530683 pe_err("could not Add STA with assocId: %d",
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700684 sta_ds->assocId);
685 }
Jeff Johnson35c58a82018-11-22 15:04:57 -0800686 status = lim_prepare_disconnect_done_ind(mac, &pMsg,
Pragaspathi Thilagaraj766c76f2018-08-08 16:44:40 +0530687 smesessionId,
688 reasonCode,
689 &peerMacAddr[0]);
690 if (!QDF_IS_STATUS_SUCCESS(status)) {
691 pe_err("Failed to prepare message");
692 return;
693 }
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700694 break;
695
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800696 case eLIM_HOST_DISASSOC:
697 /**
698 * Disassociation response due to
699 * host triggered disassociation
700 */
701
Jeff Johnson380a1cd2019-02-03 21:43:51 -0800702 pSirSmeDisassocRsp = qdf_mem_malloc(sizeof(struct disassoc_rsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700703 if (!pSirSmeDisassocRsp) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800704 failure = true;
705 goto error;
706 }
Jeff Johnsonff1fd432019-02-20 09:50:54 -0800707 pe_debug("send eWNI_SME_DISASSOC_RSP with retCode: %d for "
708 MAC_ADDRESS_STR,
709 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800710 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
Jeff Johnson380a1cd2019-02-03 21:43:51 -0800711 pSirSmeDisassocRsp->length = sizeof(struct disassoc_rsp);
Jeff Johnsonff1fd432019-02-20 09:50:54 -0800712 pSirSmeDisassocRsp->sessionId = smesessionId;
Jeff Johnsonff1fd432019-02-20 09:50:54 -0800713 pSirSmeDisassocRsp->statusCode = reasonCode;
714 qdf_mem_copy(pSirSmeDisassocRsp->peer_macaddr.bytes,
715 peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800716
717#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
718
Jeff Johnson35c58a82018-11-22 15:04:57 -0800719 lim_diag_event_report(mac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800720 pe_session, (uint16_t) reasonCode, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800721#endif
722 pMsg = (uint32_t *) pSirSmeDisassocRsp;
723 break;
724
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530725 case eLIM_PEER_ENTITY_DISASSOC:
726 case eLIM_LINK_MONITORING_DISASSOC:
Jeff Johnson35c58a82018-11-22 15:04:57 -0800727 status = lim_prepare_disconnect_done_ind(mac, &pMsg,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +0530728 smesessionId,
729 reasonCode, &peerMacAddr[0]);
730 if (!QDF_IS_STATUS_SUCCESS(status)) {
731 pe_err("Failed to prepare message");
732 return;
733 }
734 break;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530735
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800736 default:
737 /**
738 * Disassociation indication due to Disassociation
739 * frame reception from peer entity or due to
740 * loss of link with peer entity.
741 */
Jeff Johnson318a9882019-02-04 08:30:50 -0800742 pSirSmeDisassocInd =
743 qdf_mem_malloc(sizeof(*pSirSmeDisassocInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700744 if (!pSirSmeDisassocInd) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800745 failure = true;
746 goto error;
747 }
Jeff Johnsonff1fd432019-02-20 09:50:54 -0800748 pe_debug("send eWNI_SME_DISASSOC_IND with retCode: %d for "
749 MAC_ADDRESS_STR,
750 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800751 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
Jeff Johnson318a9882019-02-04 08:30:50 -0800752 pSirSmeDisassocInd->length = sizeof(*pSirSmeDisassocInd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800753 pSirSmeDisassocInd->sessionId = smesessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800754 pSirSmeDisassocInd->reasonCode = reasonCode;
Jeff Johnsonff1fd432019-02-20 09:50:54 -0800755 pSirSmeDisassocInd->statusCode = reasonCode;
756 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes,
757 pe_session->bssId, sizeof(tSirMacAddr));
758 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes,
759 peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800760
761#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -0800762 lim_diag_event_report(mac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800763 pe_session, (uint16_t) reasonCode, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800764#endif
765 pMsg = (uint32_t *) pSirSmeDisassocInd;
766
767 break;
768 }
769
770error:
771 /* Delete the PE session Created */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800772 if ((pe_session != NULL) && LIM_IS_STA_ROLE(pe_session))
773 pe_delete_session(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800774
775 if (false == failure)
Jeff Johnson35c58a82018-11-22 15:04:57 -0800776 lim_send_sme_disassoc_deauth_ntf(mac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800777 (uint32_t *) pMsg);
778} /*** end lim_send_sme_disassoc_ntf() ***/
779
780/** -----------------------------------------------------------------
781 \brief lim_send_sme_disassoc_ind() - sends SME_DISASSOC_IND
782
783 After receiving disassociation frame from peer entity, this
784 function sends a eWNI_SME_DISASSOC_IND to SME with a specific
785 reason code.
786
Jeff Johnson35c58a82018-11-22 15:04:57 -0800787 \param mac - global mac structure
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800788 \param sta - station dph hash node
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800789 \return none
790 \sa
791 ----------------------------------------------------------------- */
792void
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800793lim_send_sme_disassoc_ind(struct mac_context *mac, tpDphHashNode sta,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800794 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800795{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700796 struct scheduler_msg mmhMsg = {0};
Jeff Johnson318a9882019-02-04 08:30:50 -0800797 struct disassoc_ind *pSirSmeDisassocInd;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800798
Jeff Johnson318a9882019-02-04 08:30:50 -0800799 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(*pSirSmeDisassocInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700800 if (!pSirSmeDisassocInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800801 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800802
803 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
Jeff Johnson318a9882019-02-04 08:30:50 -0800804 pSirSmeDisassocInd->length = sizeof(*pSirSmeDisassocInd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800805
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800806 pSirSmeDisassocInd->sessionId = pe_session->smeSessionId;
Padma, Santhosh Kumar02289212016-09-30 13:30:08 +0530807 pSirSmeDisassocInd->statusCode = eSIR_SME_DEAUTH_STATUS;
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800808 pSirSmeDisassocInd->reasonCode = sta->mlmStaContext.disassocReason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800809
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800810 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes, pe_session->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530811 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800812
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800813 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes, sta->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530814 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800815
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800816 pSirSmeDisassocInd->staId = sta->staIndex;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800817
818 mmhMsg.type = eWNI_SME_DISASSOC_IND;
819 mmhMsg.bodyptr = pSirSmeDisassocInd;
820 mmhMsg.bodyval = 0;
821
Jeff Johnson35c58a82018-11-22 15:04:57 -0800822 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800823 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800824#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800825 lim_diag_event_report(mac, WLAN_PE_DIAG_DISASSOC_IND_EVENT, pe_session,
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800826 0, (uint16_t) sta->mlmStaContext.disassocReason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800827#endif /* FEATURE_WLAN_DIAG_SUPPORT */
828
Jeff Johnsona5abe272019-01-06 12:52:02 -0800829 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800830
831} /*** end lim_send_sme_disassoc_ind() ***/
832
833/** -----------------------------------------------------------------
834 \brief lim_send_sme_deauth_ind() - sends SME_DEAUTH_IND
835
836 After receiving deauthentication frame from peer entity, this
837 function sends a eWNI_SME_DEAUTH_IND to SME with a specific
838 reason code.
839
Jeff Johnson35c58a82018-11-22 15:04:57 -0800840 \param mac - global mac structure
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800841 \param sta - station dph hash node
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800842 \return none
843 \sa
844 ----------------------------------------------------------------- */
845void
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800846lim_send_sme_deauth_ind(struct mac_context *mac, tpDphHashNode sta,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800847 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800848{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700849 struct scheduler_msg mmhMsg = {0};
Jeff Johnsonfec08712019-02-04 13:12:08 -0800850 struct deauth_ind *pSirSmeDeauthInd;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800851
Jeff Johnsonfec08712019-02-04 13:12:08 -0800852 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(*pSirSmeDeauthInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700853 if (!pSirSmeDeauthInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800854 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800855
856 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
Jeff Johnsonfec08712019-02-04 13:12:08 -0800857 pSirSmeDeauthInd->length = sizeof(*pSirSmeDeauthInd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800858
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800859 pSirSmeDeauthInd->sessionId = pe_session->smeSessionId;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800860 if (eSIR_INFRA_AP_MODE == pe_session->bssType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800861 pSirSmeDeauthInd->statusCode =
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800862 (tSirResultCodes) sta->mlmStaContext.cleanupTrigger;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800863 } else {
Jeff Johnsonfec08712019-02-04 13:12:08 -0800864 /* Need to indicate the reason code over the air */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800865 pSirSmeDeauthInd->statusCode =
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800866 (tSirResultCodes) sta->mlmStaContext.disassocReason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800867 }
868 /* BSSID */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800869 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, pe_session->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530870 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800871 /* peerMacAddr */
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800872 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, sta->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530873 QDF_MAC_ADDR_SIZE);
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800874 pSirSmeDeauthInd->reasonCode = sta->mlmStaContext.disassocReason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800875
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800876 pSirSmeDeauthInd->staId = sta->staIndex;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -0800877 if (eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON ==
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800878 sta->mlmStaContext.disassocReason)
879 pSirSmeDeauthInd->rssi = sta->del_sta_ctx_rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800880
881 mmhMsg.type = eWNI_SME_DEAUTH_IND;
882 mmhMsg.bodyptr = pSirSmeDeauthInd;
883 mmhMsg.bodyval = 0;
884
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800885 MTRACE(mac_trace_msg_tx(mac, pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800886#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800887 lim_diag_event_report(mac, WLAN_PE_DIAG_DEAUTH_IND_EVENT, pe_session,
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800888 0, sta->mlmStaContext.cleanupTrigger);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800889#endif /* FEATURE_WLAN_DIAG_SUPPORT */
890
Jeff Johnsona5abe272019-01-06 12:52:02 -0800891 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800892 return;
893} /*** end lim_send_sme_deauth_ind() ***/
894
895#ifdef FEATURE_WLAN_TDLS
896/**
897 * lim_send_sme_tdls_del_sta_ind()
898 *
899 ***FUNCTION:
900 * This function is called to send the TDLS STA context deletion to SME.
901 *
902 ***LOGIC:
903 *
904 ***ASSUMPTIONS:
905 *
906 ***NOTE:
907 * NA
908 *
Jeff Johnson35c58a82018-11-22 15:04:57 -0800909 * @param mac - Pointer to global MAC structure
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800910 * @param sta - Pointer to internal STA Datastructure
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800911 * @param pe_session - Pointer to the session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800912 * @param reasonCode - Reason for TDLS sta deletion
913 * @return None
914 */
915void
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800916lim_send_sme_tdls_del_sta_ind(struct mac_context *mac, tpDphHashNode sta,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800917 struct pe_session *pe_session, uint16_t reasonCode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800918{
Frank Liud1a28462017-09-06 22:55:48 +0800919 struct tdls_event_info info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800920
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530921 pe_debug("Delete TDLS Peer "MAC_ADDRESS_STR "with reason code: %d",
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800922 MAC_ADDR_ARRAY(sta->staAddr), reasonCode);
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800923 info.vdev_id = pe_session->smeSessionId;
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800924 qdf_mem_copy(info.peermac.bytes, sta->staAddr, QDF_MAC_ADDR_SIZE);
Frank Liud1a28462017-09-06 22:55:48 +0800925 info.message_type = TDLS_PEER_DISCONNECTED;
926 info.peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800927
Jeff Johnson35c58a82018-11-22 15:04:57 -0800928 tgt_tdls_event_handler(mac->psoc, &info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800929
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800930 return;
931} /*** end lim_send_sme_tdls_del_sta_ind() ***/
932
933/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800934 * lim_send_sme_mgmt_tx_completion()
935 *
936 ***FUNCTION:
937 * This function is called to send the eWNI_SME_MGMT_FRM_TX_COMPLETION_IND
938 * message to SME.
939 *
940 ***LOGIC:
941 *
942 ***ASSUMPTIONS:
943 *
944 ***NOTE:
945 * NA
946 *
Jeff Johnson35c58a82018-11-22 15:04:57 -0800947 * @param mac - Pointer to global MAC structure
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800948 * @param pe_session - Pointer to the session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800949 * @param txCompleteStatus - TX Complete Status of Mgmt Frames
950 * @return None
951 */
952void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800953lim_send_sme_mgmt_tx_completion(struct mac_context *mac,
Ganesh Kondabattiniac570072016-12-21 12:45:48 +0530954 uint32_t sme_session_id,
955 uint32_t txCompleteStatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800956{
Wu Gao6768d762018-12-28 16:31:08 +0800957 struct scheduler_msg msg = {0};
958 struct tdls_mgmt_tx_completion_ind *mgmt_tx_completion_ind;
959 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800960
Wu Gao6768d762018-12-28 16:31:08 +0800961 mgmt_tx_completion_ind =
962 qdf_mem_malloc(sizeof(*mgmt_tx_completion_ind));
963 if (!mgmt_tx_completion_ind)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800964 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800965
966 /* sessionId */
Wu Gao6768d762018-12-28 16:31:08 +0800967 mgmt_tx_completion_ind->session_id = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800968
Wu Gao6768d762018-12-28 16:31:08 +0800969 mgmt_tx_completion_ind->tx_complete_status = txCompleteStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800970
Wu Gao6768d762018-12-28 16:31:08 +0800971 msg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
972 msg.bodyptr = mgmt_tx_completion_ind;
973 msg.bodyval = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800974
Wu Gao6768d762018-12-28 16:31:08 +0800975 mgmt_tx_completion_ind->psoc = mac->psoc;
976 msg.callback = tgt_tdls_send_mgmt_tx_completion;
977 status = scheduler_post_message(QDF_MODULE_ID_PE,
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +0530978 QDF_MODULE_ID_TDLS,
Wu Gao6768d762018-12-28 16:31:08 +0800979 QDF_MODULE_ID_TARGET_IF, &msg);
980 if (QDF_IS_STATUS_ERROR(status)) {
981 pe_err("post msg fail, %d", status);
982 qdf_mem_free(mgmt_tx_completion_ind);
983 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800984} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
985
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800986#endif /* FEATURE_WLAN_TDLS */
987
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800988QDF_STATUS lim_prepare_disconnect_done_ind(struct mac_context *mac_ctx,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +0530989 uint32_t **msg,
990 uint8_t session_id,
991 tSirResultCodes reason_code,
992 uint8_t *peer_mac_addr)
Himanshu Agarwald519b4a2018-03-27 15:36:09 +0530993{
994 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +0530995
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +0530996 sir_sme_dis_ind = qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700997 if (!sir_sme_dis_ind)
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +0530998 return QDF_STATUS_E_FAILURE;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +0530999
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301000 pe_debug("Prepare eWNI_SME_DISCONNECT_DONE_IND withretCode: %d",
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301001 reason_code);
1002
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301003 sir_sme_dis_ind->message_type = eWNI_SME_DISCONNECT_DONE_IND;
1004 sir_sme_dis_ind->length = sizeof(*sir_sme_dis_ind);
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301005 sir_sme_dis_ind->session_id = session_id;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301006 if (peer_mac_addr)
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05301007 qdf_mem_copy(sir_sme_dis_ind->peer_mac,
1008 peer_mac_addr, ETH_ALEN);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301009
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301010 /*
1011 * Instead of sending deauth reason code as 505 which is
1012 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1013 * Send reason code as zero to Supplicant
1014 */
1015 if (reason_code == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1016 sir_sme_dis_ind->reason_code = 0;
1017 else
1018 sir_sme_dis_ind->reason_code = reason_code;
1019
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301020 *msg = (uint32_t *)sir_sme_dis_ind;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301021
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301022 return QDF_STATUS_SUCCESS;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301023}
1024
Jeff Johnson953f99a2019-02-20 22:08:31 -08001025void lim_send_sme_deauth_ntf(struct mac_context *mac, tSirMacAddr peerMacAddr,
1026 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1027 uint16_t aid, uint8_t smesessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001028{
1029 uint8_t *pBuf;
Jeff Johnson15ae0c12019-02-04 12:55:07 -08001030 struct deauth_rsp *pSirSmeDeauthRsp;
Jeff Johnsonfec08712019-02-04 13:12:08 -08001031 struct deauth_ind *pSirSmeDeauthInd;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001032 struct pe_session *pe_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001033 uint8_t sessionId;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301034 uint32_t *pMsg = NULL;
1035 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001036
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001037 pe_session = pe_find_session_by_bssid(mac, peerMacAddr, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001038 switch (deauthTrigger) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001039 case eLIM_HOST_DEAUTH:
1040 /**
1041 * Deauthentication response to host triggered
1042 * deauthentication.
1043 */
Jeff Johnson15ae0c12019-02-04 12:55:07 -08001044 pSirSmeDeauthRsp = qdf_mem_malloc(sizeof(*pSirSmeDeauthRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001045 if (!pSirSmeDeauthRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001046 return;
Jeff Johnson15ae0c12019-02-04 12:55:07 -08001047 pe_debug("send eWNI_SME_DEAUTH_RSP with retCode: %d for "
1048 MAC_ADDRESS_STR,
1049 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001050 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
Jeff Johnson15ae0c12019-02-04 12:55:07 -08001051 pSirSmeDeauthRsp->length = sizeof(*pSirSmeDeauthRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001052 pSirSmeDeauthRsp->statusCode = reasonCode;
1053 pSirSmeDeauthRsp->sessionId = smesessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001054
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -08001055 pBuf = (uint8_t *) pSirSmeDeauthRsp->peer_macaddr.bytes;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301056 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001057
1058#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -08001059 lim_diag_event_report(mac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001060 pe_session, 0, (uint16_t) reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001061#endif
1062 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1063
1064 break;
1065
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301066 case eLIM_PEER_ENTITY_DEAUTH:
1067 case eLIM_LINK_MONITORING_DEAUTH:
Jeff Johnson35c58a82018-11-22 15:04:57 -08001068 status = lim_prepare_disconnect_done_ind(mac, &pMsg,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301069 smesessionId, reasonCode,
1070 &peerMacAddr[0]);
1071 if (!QDF_IS_STATUS_SUCCESS(status)) {
1072 pe_err("Failed to prepare message");
1073 return;
1074 }
1075 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001076 default:
1077 /**
1078 * Deauthentication indication due to Deauthentication
1079 * frame reception from peer entity or due to
1080 * loss of link with peer entity.
1081 */
Jeff Johnsonfec08712019-02-04 13:12:08 -08001082 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(*pSirSmeDeauthInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001083 if (!pSirSmeDeauthInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001084 return;
Jeff Johnsonfec08712019-02-04 13:12:08 -08001085 pe_debug("send eWNI_SME_DEAUTH_IND with retCode: %d for "
1086 MAC_ADDRESS_STR,
1087 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001088 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
Jeff Johnsonfec08712019-02-04 13:12:08 -08001089 pSirSmeDeauthInd->length = sizeof(*pSirSmeDeauthInd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001090 pSirSmeDeauthInd->reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
Jeff Johnson8ee46ef2019-02-20 18:34:17 -08001091 pSirSmeDeauthInd->sessionId = smesessionId;
Jeff Johnson8ee46ef2019-02-20 18:34:17 -08001092 pSirSmeDeauthInd->statusCode = reasonCode;
1093 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, pe_session->bssId,
1094 sizeof(tSirMacAddr));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301095 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301096 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001097
1098#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -08001099 lim_diag_event_report(mac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001100 pe_session, 0, (uint16_t) reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001101#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1102 pMsg = (uint32_t *) pSirSmeDeauthInd;
1103
1104 break;
1105 }
1106
1107 /*Delete the PE session created */
Bala Venkatesh03b4f0c2019-01-28 22:00:50 +05301108 if (pe_session && LIM_IS_STA_ROLE(pe_session))
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001109 pe_delete_session(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001110
Jeff Johnson35c58a82018-11-22 15:04:57 -08001111 lim_send_sme_disassoc_deauth_ntf(mac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001112 (uint32_t *) pMsg);
1113
1114} /*** end lim_send_sme_deauth_ntf() ***/
1115
1116/**
1117 * lim_send_sme_wm_status_change_ntf() - Send Notification
1118 * @mac_ctx: Global MAC Context
1119 * @status_change_code: Indicates the change in the wireless medium.
1120 * @status_change_info: Indicates the information associated with
1121 * change in the wireless medium.
1122 * @info_len: Indicates the length of status change information
1123 * being sent.
1124 * @session_id SessionID
1125 *
1126 * This function is called by limProcessSmeMessages() to send
1127 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1128 *
1129 * Return: None
1130 */
1131void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001132lim_send_sme_wm_status_change_ntf(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001133 tSirSmeStatusChangeCode status_change_code,
1134 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1135{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001136 struct scheduler_msg msg = {0};
Jeff Johnson53889322019-02-03 17:37:09 -08001137 struct wm_status_change_ntf *wm_status_change_ntf;
Naveen Rawate01ed172016-11-17 11:34:50 -08001138 uint32_t max_info_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001139
Jeff Johnson53889322019-02-03 17:37:09 -08001140 wm_status_change_ntf = qdf_mem_malloc(sizeof(*wm_status_change_ntf));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001141 if (!wm_status_change_ntf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001142 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001143
1144 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1145 msg.bodyval = 0;
1146 msg.bodyptr = wm_status_change_ntf;
1147
1148 switch (status_change_code) {
Naveen Rawate01ed172016-11-17 11:34:50 -08001149 case eSIR_SME_AP_CAPS_CHANGED:
Jeff Johnson9c9961c2019-02-03 17:10:53 -08001150 max_info_len = sizeof(struct ap_new_caps);
Naveen Rawate01ed172016-11-17 11:34:50 -08001151 break;
1152 case eSIR_SME_JOINED_NEW_BSS:
Jeff Johnson2e6d1732019-02-03 17:00:30 -08001153 max_info_len = sizeof(struct new_bss_info);
Naveen Rawate01ed172016-11-17 11:34:50 -08001154 break;
1155 default:
1156 max_info_len = sizeof(wm_status_change_ntf->statusChangeInfo);
1157 break;
1158 }
1159
1160 switch (status_change_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001161 case eSIR_SME_RADAR_DETECTED:
1162 break;
1163 default:
1164 wm_status_change_ntf->messageType =
1165 eWNI_SME_WM_STATUS_CHANGE_NTF;
1166 wm_status_change_ntf->statusChangeCode = status_change_code;
Jeff Johnson53889322019-02-03 17:37:09 -08001167 wm_status_change_ntf->length = sizeof(*wm_status_change_ntf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001168 wm_status_change_ntf->sessionId = session_id;
Naveen Rawate01ed172016-11-17 11:34:50 -08001169 if (info_len <= max_info_len && status_change_info) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301170 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001171 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1172 (uint8_t *) status_change_info, info_len);
1173 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301174 pe_debug("StatusChg code: 0x%x length: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001175 status_change_code, info_len);
1176 break;
1177 }
1178
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301179 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, session_id, msg.type));
Harprit Chhabadae20b5562019-03-11 14:13:42 -07001180 lim_sys_process_mmh_msg_api(mac_ctx, &msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001181
1182} /*** end lim_send_sme_wm_status_change_ntf() ***/
1183
Jeff Johnsonc80ed542019-02-21 06:24:57 -08001184void lim_send_sme_set_context_rsp(struct mac_context *mac,
1185 struct qdf_mac_addr peer_macaddr,
1186 uint16_t aid,
1187 tSirResultCodes resultCode,
1188 struct pe_session *pe_session,
1189 uint8_t smesessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001190{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001191 struct scheduler_msg mmhMsg = {0};
Jeff Johnson924ae612019-02-05 12:01:50 -08001192 struct set_context_rsp *set_context_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001193
Jeff Johnson924ae612019-02-05 12:01:50 -08001194 set_context_rsp = qdf_mem_malloc(sizeof(*set_context_rsp));
1195 if (!set_context_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001196 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001197
Jeff Johnson924ae612019-02-05 12:01:50 -08001198 set_context_rsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1199 set_context_rsp->length = sizeof(*set_context_rsp);
1200 set_context_rsp->statusCode = resultCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001201
Jeff Johnson924ae612019-02-05 12:01:50 -08001202 qdf_copy_macaddr(&set_context_rsp->peer_macaddr, &peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001203
Jeff Johnson924ae612019-02-05 12:01:50 -08001204 set_context_rsp->sessionId = smesessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001205
1206 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
Jeff Johnson924ae612019-02-05 12:01:50 -08001207 mmhMsg.bodyptr = set_context_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001208 mmhMsg.bodyval = 0;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001209 if (NULL == pe_session) {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001210 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301211 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001212 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001213 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001214 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001215 }
1216
1217#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -08001218 lim_diag_event_report(mac, WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001219 pe_session, (uint16_t) resultCode, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001220#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1221
Jeff Johnson35c58a82018-11-22 15:04:57 -08001222 mac->lim.sme_msg_callback(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001223} /*** end lim_send_sme_set_context_rsp() ***/
1224
Jeff Johnson07819492019-02-21 09:34:02 -08001225void lim_send_sme_addts_rsp(struct mac_context *mac,
1226 uint8_t rspReqd, uint32_t status,
1227 struct pe_session *pe_session,
1228 struct mac_tspec_ie tspec,
1229 uint8_t smesessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001230{
1231 tpSirAddtsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001232 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001233
1234 if (!rspReqd)
1235 return;
1236
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301237 rsp = qdf_mem_malloc(sizeof(tSirAddtsRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001238 if (!rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001239 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001240
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001241 rsp->messageType = eWNI_SME_ADDTS_RSP;
1242 rsp->rc = status;
1243 rsp->rsp.status = (enum eSirMacStatusCodes)status;
1244 rsp->rsp.tspec = tspec;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001245 rsp->sessionId = smesessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001246
1247 mmhMsg.type = eWNI_SME_ADDTS_RSP;
1248 mmhMsg.bodyptr = rsp;
1249 mmhMsg.bodyval = 0;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001250 if (NULL == pe_session) {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001251 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301252 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001253 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001254 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001255 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001256 }
1257#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001258 lim_diag_event_report(mac, WLAN_PE_DIAG_ADDTS_RSP_EVENT, pe_session, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001259 0);
1260#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1261
Jeff Johnsona5abe272019-01-06 12:52:02 -08001262 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001263 return;
1264}
1265
Jeff Johnsonb2b63e02019-02-21 09:46:03 -08001266void lim_send_sme_delts_rsp(struct mac_context *mac, tpSirDeltsReq delts,
1267 uint32_t status, struct pe_session *pe_session,
1268 uint8_t smesessionId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001269{
1270 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001271 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001272
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301273 pe_debug("SendSmeDeltsRsp aid: %d tsid: %d up: %d status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001274 delts->aid,
1275 delts->req.tsinfo.traffic.tsid,
1276 delts->req.tsinfo.traffic.userPrio, status);
1277 if (!delts->rspReqd)
1278 return;
1279
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301280 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001281 if (!rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001282 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001283
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001284 if (pe_session != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001285
1286 rsp->aid = delts->aid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301287 qdf_copy_macaddr(&rsp->macaddr, &delts->macaddr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301288 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) &delts->req,
Jeff Johnsoncf2ec162018-12-22 16:46:43 -08001289 sizeof(struct delts_req_info));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001290 }
1291
1292 rsp->messageType = eWNI_SME_DELTS_RSP;
1293 rsp->rc = status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001294 rsp->sessionId = smesessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001295
1296 mmhMsg.type = eWNI_SME_DELTS_RSP;
1297 mmhMsg.bodyptr = rsp;
1298 mmhMsg.bodyval = 0;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001299 if (NULL == pe_session) {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001300 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301301 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001302 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001303 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001304 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001305 }
1306#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001307 lim_diag_event_report(mac, WLAN_PE_DIAG_DELTS_RSP_EVENT, pe_session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001308 (uint16_t) status, 0);
1309#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1310
Jeff Johnsona5abe272019-01-06 12:52:02 -08001311 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001312}
1313
1314void
Jeff Johnsoncf2ec162018-12-22 16:46:43 -08001315lim_send_sme_delts_ind(struct mac_context *mac, struct delts_req_info *delts,
1316 uint16_t aid, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001317{
1318 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001319 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001320
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301321 pe_debug("SendSmeDeltsInd aid: %d tsid: %d up: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001322 aid, delts->tsinfo.traffic.tsid, delts->tsinfo.traffic.userPrio);
1323
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301324 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001325 if (!rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001326 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001327
1328 rsp->messageType = eWNI_SME_DELTS_IND;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001329 rsp->rc = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001330 rsp->aid = aid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301331 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) delts, sizeof(*delts));
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001332 rsp->sessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001333
1334 mmhMsg.type = eWNI_SME_DELTS_IND;
1335 mmhMsg.bodyptr = rsp;
1336 mmhMsg.bodyval = 0;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001337 MTRACE(mac_trace_msg_tx(mac, pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001338#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001339 lim_diag_event_report(mac, WLAN_PE_DIAG_DELTS_IND_EVENT, pe_session, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001340 0);
1341#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1342
Jeff Johnsona5abe272019-01-06 12:52:02 -08001343 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001344}
1345
Naveen Rawatfa2a1002018-05-17 16:06:37 -07001346#ifndef QCA_SUPPORT_CP_STATS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001347/**
1348 * lim_send_sme_pe_statistics_rsp()
1349 *
1350 ***FUNCTION:
1351 * This function is called to send 802.11 statistics response to HDD.
1352 * This function posts the result back to HDD. This is a response to
1353 * HDD's request for statistics.
1354 *
1355 ***PARAMS:
1356 *
1357 ***LOGIC:
1358 *
1359 ***ASSUMPTIONS:
1360 * NA
1361 *
1362 ***NOTE:
1363 * NA
1364 *
Jeff Johnson35c58a82018-11-22 15:04:57 -08001365 * @param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001366 * @param p80211Stats Statistics sent in response
1367 * @param resultCode TODO:
1368 *
1369 *
1370 * @return none
1371 */
1372
1373void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001374lim_send_sme_pe_statistics_rsp(struct mac_context *mac, uint16_t msgType, void *stats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001375{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001376 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001377 uint8_t sessionId;
1378 tAniGetPEStatsRsp *pPeStats = (tAniGetPEStatsRsp *) stats;
Jeff Johnsond7035a32018-11-18 22:03:13 -08001379 struct pe_session *pPeSessionEntry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001380
1381 /* Get the Session Id based on Sta Id */
1382 pPeSessionEntry =
Jeff Johnson35c58a82018-11-22 15:04:57 -08001383 pe_find_session_by_sta_id(mac, pPeStats->staId, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001384
1385 /* Fill the Session Id */
1386 if (NULL != pPeSessionEntry) {
1387 /* Fill the Session Id */
1388 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1389 }
1390
1391 pPeStats->msgType = eWNI_SME_GET_STATISTICS_RSP;
1392
1393 /* msgType should be WMA_GET_STATISTICS_RSP */
1394 mmhMsg.type = eWNI_SME_GET_STATISTICS_RSP;
1395
1396 mmhMsg.bodyptr = stats;
1397 mmhMsg.bodyval = 0;
Jeff Johnson35c58a82018-11-22 15:04:57 -08001398 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08001399 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001400
1401 return;
1402
1403} /*** end lim_send_sme_pe_statistics_rsp() ***/
Naveen Rawatfa2a1002018-05-17 16:06:37 -07001404#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001405
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001406#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001407/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001408 * lim_send_sme_pe_ese_tsm_rsp() - send tsm response
Jeff Johnson35c58a82018-11-22 15:04:57 -08001409 * @mac: Pointer to global mac structure
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001410 * @pStats: Pointer to TSM Stats
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001411 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001412 * This function is called to send tsm stats response to HDD.
1413 * This function posts the result back to HDD. This is a response to
1414 * HDD's request to get tsm stats.
1415 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001416 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001417 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001418void lim_send_sme_pe_ese_tsm_rsp(struct mac_context *mac,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001419 tAniGetTsmStatsRsp *pStats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001420{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001421 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001422 uint8_t sessionId;
1423 tAniGetTsmStatsRsp *pPeStats = (tAniGetTsmStatsRsp *) pStats;
Jeff Johnsond7035a32018-11-18 22:03:13 -08001424 struct pe_session *pPeSessionEntry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001425
1426 /* Get the Session Id based on Sta Id */
Abhinav Kumaraa8f2df2019-01-11 20:02:26 +05301427 pPeSessionEntry = pe_find_session_by_bssid(mac, pPeStats->bssid.bytes,
1428 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001429 /* Fill the Session Id */
1430 if (NULL != pPeSessionEntry) {
1431 /* Fill the Session Id */
1432 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1433 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301434 pe_err("Session not found for the Sta id: %d",
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301435 pPeStats->staId);
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05301436 qdf_mem_free(pPeStats->tsmStatsReq);
1437 qdf_mem_free(pPeStats);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001438 return;
1439 }
1440
1441 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
1442 pPeStats->tsmMetrics.RoamingCount
1443 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
1444 pPeStats->tsmMetrics.RoamingDly
1445 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
1446
1447 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
1448 mmhMsg.bodyptr = pStats;
1449 mmhMsg.bodyval = 0;
Jeff Johnson35c58a82018-11-22 15:04:57 -08001450 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08001451 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001452
1453 return;
1454} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
1455
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001456#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001457
1458void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001459lim_send_sme_ibss_peer_ind(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001460 tSirMacAddr peerMacAddr,
1461 uint16_t staIndex,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001462 uint8_t *beacon,
1463 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
1464{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001465 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001466 tSmeIbssPeerInd *pNewPeerInd;
1467
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301468 pNewPeerInd = qdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
Arif Hussainf5b6c412018-10-10 19:41:09 -07001469 if (!pNewPeerInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001470 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001471
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301472 qdf_mem_copy((uint8_t *) pNewPeerInd->peer_addr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301473 peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001474 pNewPeerInd->staId = staIndex;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001475 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
1476 pNewPeerInd->mesgType = msgType;
1477 pNewPeerInd->sessionId = sessionId;
1478
1479 if (beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301480 qdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001481 sizeof(tSmeIbssPeerInd)), (void *)beacon,
1482 beaconLen);
1483 }
1484
1485 mmhMsg.type = msgType;
1486 mmhMsg.bodyptr = pNewPeerInd;
Jeff Johnson35c58a82018-11-22 15:04:57 -08001487 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08001488 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001489
1490}
1491
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07001492/**
1493 * lim_process_csa_wbw_ie() - Process CSA Wide BW IE
1494 * @mac_ctx: pointer to global adapter context
1495 * @csa_params: pointer to CSA parameters
1496 * @chnl_switch_info:pointer to channel switch parameters
1497 * @session_entry: session pointer
1498 *
1499 * Return: None
1500 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001501static QDF_STATUS lim_process_csa_wbw_ie(struct mac_context *mac_ctx,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001502 struct csa_offload_params *csa_params,
1503 tLimWiderBWChannelSwitchInfo *chnl_switch_info,
Jeff Johnsond7035a32018-11-18 22:03:13 -08001504 struct pe_session *session_entry)
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001505{
Amar Singhal5cccafe2017-02-15 12:42:58 -08001506 struct ch_params ch_params = {0};
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001507 uint8_t ap_new_ch_width;
1508 bool new_ch_width_dfn = false;
1509 uint8_t center_freq_diff;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001510 uint32_t fw_vht_ch_wd = wma_get_vht_ch_width() + 1;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001511
1512 ap_new_ch_width = csa_params->new_ch_width + 1;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001513
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001514 pe_debug("new channel: %d new_ch_width: %d seg0: %d seg1: %d",
1515 csa_params->channel, ap_new_ch_width,
1516 csa_params->new_ch_freq_seg1,
1517 csa_params->new_ch_freq_seg2);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001518
1519 if ((ap_new_ch_width != CH_WIDTH_80MHZ) &&
1520 (ap_new_ch_width != CH_WIDTH_160MHZ) &&
1521 (ap_new_ch_width != CH_WIDTH_80P80MHZ)) {
1522 pe_err("CSA wide BW IE has wrong ch_width %d",
1523 csa_params->new_ch_width);
1524 return QDF_STATUS_E_INVAL;
1525 }
1526
1527 if (!csa_params->new_ch_freq_seg1 && !csa_params->new_ch_freq_seg2) {
1528 pe_err("CSA wide BW IE has invalid center freq");
1529 return QDF_STATUS_E_INVAL;
1530 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001531 if ((ap_new_ch_width == CH_WIDTH_80MHZ) &&
1532 csa_params->new_ch_freq_seg2) {
1533 new_ch_width_dfn = true;
1534 if (csa_params->new_ch_freq_seg2 >
1535 csa_params->new_ch_freq_seg1)
1536 center_freq_diff = csa_params->new_ch_freq_seg2 -
1537 csa_params->new_ch_freq_seg1;
1538 else
1539 center_freq_diff = csa_params->new_ch_freq_seg1 -
1540 csa_params->new_ch_freq_seg2;
1541 if (center_freq_diff == CENTER_FREQ_DIFF_160MHz)
1542 ap_new_ch_width = CH_WIDTH_160MHZ;
1543 else if (center_freq_diff > CENTER_FREQ_DIFF_80P80MHz)
1544 ap_new_ch_width = CH_WIDTH_80P80MHZ;
1545 else
1546 ap_new_ch_width = CH_WIDTH_80MHZ;
1547 }
1548 session_entry->gLimChannelSwitch.state =
1549 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1550 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
1551 !new_ch_width_dfn) {
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001552 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1553 CH_TO_CNTR_FREQ_DIFF_160MHz) {
1554 pe_err("CSA wide BW IE has invalid center freq");
1555 return QDF_STATUS_E_INVAL;
1556 }
1557
1558 if (ap_new_ch_width > fw_vht_ch_wd) {
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001559 pe_debug("New BW is not supported, setting BW to %d",
1560 fw_vht_ch_wd);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001561 ap_new_ch_width = fw_vht_ch_wd;
1562 }
1563 ch_params.ch_width = ap_new_ch_width ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001564 wlan_reg_set_channel_params(mac_ctx->pdev,
1565 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001566 ap_new_ch_width = ch_params.ch_width;
1567 csa_params->new_ch_freq_seg1 = ch_params.center_freq_seg0;
1568 csa_params->new_ch_freq_seg2 = ch_params.center_freq_seg1;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001569 } else if (!new_ch_width_dfn) {
1570 if (ap_new_ch_width > fw_vht_ch_wd) {
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001571 pe_debug("New BW is not supported, setting BW to %d",
1572 fw_vht_ch_wd);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001573 ap_new_ch_width = fw_vht_ch_wd;
1574 }
1575 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1576 CH_TO_CNTR_FREQ_DIFF_80MHz) {
1577 pe_err("CSA wide BW IE has invalid center freq");
1578 return QDF_STATUS_E_INVAL;
1579 }
1580 csa_params->new_ch_freq_seg2 = 0;
1581 }
1582 if (new_ch_width_dfn) {
1583 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1584 CH_TO_CNTR_FREQ_DIFF_80MHz) {
1585 pe_err("CSA wide BW IE has invalid center freq");
1586 return QDF_STATUS_E_INVAL;
1587 }
1588 if (ap_new_ch_width > fw_vht_ch_wd) {
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001589 pe_debug("New width is not supported, setting BW to %d",
1590 fw_vht_ch_wd);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001591 ap_new_ch_width = fw_vht_ch_wd;
1592 }
1593 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
1594 (csa_params->new_ch_freq_seg1 !=
1595 csa_params->channel +
1596 CH_TO_CNTR_FREQ_DIFF_160MHz)) {
1597 pe_err("wide BW IE has invalid 160M center freq");
1598 csa_params->new_ch_freq_seg2 = 0;
1599 ap_new_ch_width = CH_WIDTH_80MHZ;
1600 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001601 }
1602 chnl_switch_info->newChanWidth = ap_new_ch_width;
1603 chnl_switch_info->newCenterChanFreq0 = csa_params->new_ch_freq_seg1;
1604 chnl_switch_info->newCenterChanFreq1 = csa_params->new_ch_freq_seg2;
1605
1606 if (session_entry->ch_width == ap_new_ch_width)
1607 goto prnt_log;
1608
1609 if (session_entry->ch_width == CH_WIDTH_80MHZ) {
1610 chnl_switch_info->newChanWidth = CH_WIDTH_80MHZ;
1611 chnl_switch_info->newCenterChanFreq1 = 0;
1612 } else {
1613 session_entry->ch_width = ap_new_ch_width;
1614 chnl_switch_info->newChanWidth = ap_new_ch_width;
1615 }
1616prnt_log:
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301617 pe_debug("new channel: %d new_ch_width: %d seg0: %d seg1: %d",
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001618 csa_params->channel,
1619 chnl_switch_info->newChanWidth,
1620 chnl_switch_info->newCenterChanFreq0,
1621 chnl_switch_info->newCenterChanFreq1);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001622
1623 return QDF_STATUS_SUCCESS;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001624}
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001625
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001626/**
1627 * lim_handle_csa_offload_msg() - Handle CSA offload message
1628 * @mac_ctx: pointer to global adapter context
1629 * @msg: Message pointer.
1630 *
1631 * Return: None
1632 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001633void lim_handle_csa_offload_msg(struct mac_context *mac_ctx,
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001634 struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001635{
Jeff Johnsond7035a32018-11-18 22:03:13 -08001636 struct pe_session *session_entry;
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301637 struct csa_offload_params *csa_params =
1638 (struct csa_offload_params *) (msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001639 tpDphHashNode sta_ds = NULL;
1640 uint8_t session_id;
1641 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05301642 uint16_t chan_space = 0;
Krunal Sonie2c45a92018-05-03 11:51:26 -07001643 struct ch_params ch_params = {0};
Gupta, Kapil121bf212015-11-25 19:21:29 +05301644
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001645 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08001646 tLimChannelSwitchInfo *lim_ch_switch = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001647
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301648 pe_debug("handle csa offload msg");
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301649
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001650 if (!csa_params) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301651 pe_err("limMsgQ body ptr is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001652 return;
1653 }
1654
1655 session_entry =
1656 pe_find_session_by_bssid(mac_ctx,
1657 csa_params->bssId, &session_id);
1658 if (!session_entry) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301659 pe_err("Session does not exists for %pM",
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301660 csa_params->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001661 goto err;
1662 }
1663
1664 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
1665 &session_entry->dph.dphHashTable);
1666
1667 if (!sta_ds) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301668 pe_err("sta_ds does not exist");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001669 goto err;
1670 }
1671
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001672 if (!LIM_IS_STA_ROLE(session_entry)) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301673 pe_debug("Invalid role to handle CSA");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001674 goto err;
1675 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001676 /*
1677 * on receiving channel switch announcement from AP, delete all
1678 * TDLS peers before leaving BSS and proceed for channel switch
1679 */
Bala Venkatesh33f270b2019-01-14 16:31:29 +05301680
1681 lim_update_tdls_set_state_for_fw(session_entry, false);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001682 lim_delete_tdls_peers(mac_ctx, session_entry);
Gupta, Kapil121bf212015-11-25 19:21:29 +05301683
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001684 lim_ch_switch = &session_entry->gLimChannelSwitch;
1685 session_entry->gLimChannelSwitch.switchMode =
1686 csa_params->switch_mode;
1687 /* timer already started by firmware, switch immediately */
1688 session_entry->gLimChannelSwitch.switchCount = 0;
1689 session_entry->gLimChannelSwitch.primaryChannel =
1690 csa_params->channel;
1691 session_entry->gLimChannelSwitch.state =
1692 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
1693 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
1694 lim_ch_switch->sec_ch_offset =
1695 session_entry->htSecondaryChannelOffset;
1696 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
1697 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
1698 chnl_switch_info =
1699 &session_entry->gLimWiderBWChannelSwitch;
1700
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001701 pe_debug("vht: %d ht: %d flag: %x chan: %d, sec_ch_offset %d",
1702 session_entry->vhtCapability,
1703 session_entry->htSupportedChannelWidthSet,
1704 csa_params->ies_present_flag,
1705 csa_params->channel,
1706 csa_params->sec_chan_offset);
1707 pe_debug("seg1: %d seg2: %d width: %d country: %s class: %d",
1708 csa_params->new_ch_freq_seg1,
1709 csa_params->new_ch_freq_seg2,
1710 csa_params->new_ch_width,
1711 mac_ctx->scan.countryCodeCurrent,
1712 csa_params->new_op_class);
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05301713
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001714 if (session_entry->vhtCapability &&
1715 session_entry->htSupportedChannelWidthSet) {
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001716 if ((csa_params->ies_present_flag & lim_wbw_ie_present) &&
1717 (QDF_STATUS_SUCCESS == lim_process_csa_wbw_ie(mac_ctx,
1718 csa_params, chnl_switch_info,
1719 session_entry))) {
1720 pe_debug("CSA wide BW IE process successful");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001721 lim_ch_switch->sec_ch_offset =
Abhishek Singhaf639b42017-06-16 14:14:36 +05301722 PHY_SINGLE_CHANNEL_CENTERED;
1723 if (chnl_switch_info->newChanWidth) {
1724 if (csa_params->channel <
1725 csa_params->new_ch_freq_seg1)
1726 lim_ch_switch->sec_ch_offset =
1727 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1728 else
1729 lim_ch_switch->sec_ch_offset =
1730 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1731 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001732 } else if (csa_params->ies_present_flag
1733 & lim_xcsa_ie_present) {
1734 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001735 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001736 mac_ctx->scan.countryCodeCurrent,
1737 csa_params->channel,
1738 csa_params->new_op_class);
1739 session_entry->gLimChannelSwitch.state =
1740 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1741
1742 if (chan_space == 80) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001743 chnl_switch_info->newChanWidth =
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001744 CH_WIDTH_80MHZ;
1745 } else if (chan_space == 40) {
1746 chnl_switch_info->newChanWidth =
1747 CH_WIDTH_40MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001748 } else {
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001749 chnl_switch_info->newChanWidth =
1750 CH_WIDTH_20MHZ;
1751 lim_ch_switch->state =
1752 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
1753 }
1754
1755 ch_params.ch_width =
1756 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001757 wlan_reg_set_channel_params(mac_ctx->pdev,
1758 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001759 chnl_switch_info->newCenterChanFreq0 =
1760 ch_params.center_freq_seg0;
1761 /*
1762 * This is not applicable for 20/40/80 MHz.
1763 * Only used when we support 80+80 MHz operation.
1764 * In case of 80+80 MHz, this parameter indicates
1765 * center channel frequency index of 80 MHz
1766 * channel offrequency segment 1.
1767 */
1768 chnl_switch_info->newCenterChanFreq1 =
1769 ch_params.center_freq_seg1;
1770 lim_ch_switch->sec_ch_offset =
1771 ch_params.sec_ch_offset;
1772
Kiran Kumar Lokere47127482017-12-20 18:09:55 -08001773 } else {
1774 lim_ch_switch->state =
1775 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1776 ch_params.ch_width = CH_WIDTH_40MHZ;
1777 wlan_reg_set_channel_params(mac_ctx->pdev,
1778 csa_params->channel, 0, &ch_params);
1779 lim_ch_switch->sec_ch_offset =
1780 ch_params.sec_ch_offset;
1781 chnl_switch_info->newChanWidth = CH_WIDTH_40MHZ;
1782 chnl_switch_info->newCenterChanFreq0 =
1783 ch_params.center_freq_seg0;
1784 chnl_switch_info->newCenterChanFreq1 = 0;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001785 }
1786 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
1787 chnl_switch_info->newCenterChanFreq0;
1788 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
1789 chnl_switch_info->newCenterChanFreq1;
1790 session_entry->gLimChannelSwitch.ch_width =
1791 chnl_switch_info->newChanWidth;
1792
1793 } else if (session_entry->htSupportedChannelWidthSet) {
1794 if (csa_params->ies_present_flag
1795 & lim_xcsa_ie_present) {
1796 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001797 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001798 mac_ctx->scan.countryCodeCurrent,
1799 csa_params->channel,
1800 csa_params->new_op_class);
1801 lim_ch_switch->state =
1802 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1803 if (chan_space == 40) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08001804 lim_ch_switch->ch_width =
1805 CH_WIDTH_40MHZ;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001806 chnl_switch_info->newChanWidth =
1807 CH_WIDTH_40MHZ;
1808 ch_params.ch_width =
1809 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001810 wlan_reg_set_channel_params(mac_ctx->pdev,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001811 csa_params->channel,
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07001812 0, &ch_params);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08001813 lim_ch_switch->ch_center_freq_seg0 =
1814 ch_params.center_freq_seg0;
1815 lim_ch_switch->sec_ch_offset =
1816 ch_params.sec_ch_offset;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001817 } else {
1818 lim_ch_switch->ch_width =
1819 CH_WIDTH_20MHZ;
1820 chnl_switch_info->newChanWidth =
1821 CH_WIDTH_40MHZ;
1822 lim_ch_switch->state =
1823 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
1824 lim_ch_switch->sec_ch_offset =
1825 PHY_SINGLE_CHANNEL_CENTERED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001826 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001827 } else {
1828 lim_ch_switch->ch_width =
1829 CH_WIDTH_40MHZ;
1830 lim_ch_switch->state =
1831 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1832 ch_params.ch_width = CH_WIDTH_40MHZ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001833 wlan_reg_set_channel_params(mac_ctx->pdev,
1834 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001835 lim_ch_switch->ch_center_freq_seg0 =
1836 ch_params.center_freq_seg0;
1837 lim_ch_switch->sec_ch_offset =
1838 ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001839 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001840
1841 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301842 pe_debug("new ch width: %d space: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05301843 session_entry->gLimChannelSwitch.ch_width, chan_space);
Kiran Kumar Lokere75d636f2016-12-20 14:52:03 -08001844 if ((session_entry->currentOperChannel == csa_params->channel) &&
1845 (session_entry->ch_width ==
1846 session_entry->gLimChannelSwitch.ch_width)) {
1847 pe_debug("Ignore CSA, no change in ch and bw");
1848 goto err;
1849 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001850
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05301851 if (WLAN_REG_IS_24GHZ_CH(csa_params->channel) &&
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +05301852 (session_entry->dot11mode == MLME_DOT11_MODE_11A))
1853 session_entry->dot11mode = MLME_DOT11_MODE_11G;
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05301854 else if (WLAN_REG_IS_5GHZ_CH(csa_params->channel) &&
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +05301855 ((session_entry->dot11mode == MLME_DOT11_MODE_11G) ||
1856 (session_entry->dot11mode == MLME_DOT11_MODE_11G_ONLY)))
1857 session_entry->dot11mode = MLME_DOT11_MODE_11A;
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05301858
Vignesh Viswanathan3d478032018-08-02 20:18:53 +05301859 /* Send RSO Stop to FW before triggering the vdev restart for CSA */
1860 if (mac_ctx->lim.stop_roaming_callback)
1861 mac_ctx->lim.stop_roaming_callback(mac_ctx,
1862 session_entry->smeSessionId,
1863 ecsr_driver_disabled);
1864
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001865 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001866
Abhishek Singhecc2c752019-03-18 11:05:39 +05301867 lim_flush_bssid(mac_ctx, session_entry->bssId);
1868
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001869#ifdef FEATURE_WLAN_DIAG_SUPPORT
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001870 lim_diag_event_report(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001871 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001872 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001873#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001874
1875err:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301876 qdf_mem_free(csa_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001877}
1878
1879/*--------------------------------------------------------------------------
1880 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
1881
Jeff Johnson35c58a82018-11-22 15:04:57 -08001882 \param mac - pointer to global adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001883 \param sessionId - Message pointer.
1884
1885 \sa
1886 --------------------------------------------------------------------------*/
1887
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001888void lim_handle_delete_bss_rsp(struct mac_context *mac, struct scheduler_msg *MsgQ)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001889{
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001890 struct pe_session *pe_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001891 tpDeleteBssParams pDelBss = (tpDeleteBssParams) (MsgQ->bodyptr);
1892
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001893 pe_session =
Jeff Johnson35c58a82018-11-22 15:04:57 -08001894 pe_find_session_by_session_id(mac, pDelBss->sessionId);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001895 if (pe_session == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301896 pe_err("Session Does not exist for given sessionID: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001897 pDelBss->sessionId);
Tushnim Bhattacharyya6368a262018-10-12 09:48:45 -07001898 qdf_mem_free(MsgQ->bodyptr);
1899 MsgQ->bodyptr = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001900 return;
1901 }
Krunal Sonie50ff452017-10-11 18:23:55 -07001902
1903 /*
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07001904 * During DEL BSS handling, the PE Session will be deleted, but it is
1905 * better to clear this flag if the session is hanging around due
1906 * to some error conditions so that the next DEL_BSS request does
1907 * not take the HO_FAIL path
1908 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001909 pe_session->process_ho_fail = false;
1910 if (LIM_IS_IBSS_ROLE(pe_session))
1911 lim_ibss_del_bss_rsp(mac, MsgQ->bodyptr, pe_session);
1912 else if (LIM_IS_UNKNOWN_ROLE(pe_session))
1913 lim_process_sme_del_bss_rsp(mac, MsgQ->bodyval, pe_session);
1914 else if (LIM_IS_NDI_ROLE(pe_session))
1915 lim_ndi_del_bss_rsp(mac, MsgQ->bodyptr, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001916 else
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001917 lim_process_mlm_del_bss_rsp(mac, MsgQ, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001918
1919}
1920
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001921/** -----------------------------------------------------------------
1922 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
1923 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
1924 \ SME only looks at rc and tspec field.
Jeff Johnson35c58a82018-11-22 15:04:57 -08001925 \param mac - global mac structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001926 \param rspReqd - is SmeAddTsRsp required
1927 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
1928 \return tspec
1929 \sa
1930 ----------------------------------------------------------------- */
1931void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001932lim_send_sme_aggr_qos_rsp(struct mac_context *mac, tpSirAggrQosRsp aggrQosRsp,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001933 uint8_t smesessionId)
1934{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001935 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001936
1937 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
1938 mmhMsg.bodyptr = aggrQosRsp;
1939 mmhMsg.bodyval = 0;
Jeff Johnson35c58a82018-11-22 15:04:57 -08001940 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301941 smesessionId, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08001942 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001943
1944 return;
1945}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001946
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001947void lim_send_sme_max_assoc_exceeded_ntf(struct mac_context *mac, tSirMacAddr peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001948 uint8_t smesessionId)
1949{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001950 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001951 tSmeMaxAssocInd *pSmeMaxAssocInd;
1952
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301953 pSmeMaxAssocInd = qdf_mem_malloc(sizeof(tSmeMaxAssocInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001954 if (!pSmeMaxAssocInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001955 return;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301956 qdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peer_mac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301957 (uint8_t *) peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001958 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
1959 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
1960 pSmeMaxAssocInd->sessionId = smesessionId;
1961 mmhMsg.type = pSmeMaxAssocInd->mesgType;
1962 mmhMsg.bodyptr = pSmeMaxAssocInd;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301963 pe_debug("msgType: %s peerMacAddr "MAC_ADDRESS_STR "sme session id %d",
1964 "eWNI_SME_MAX_ASSOC_EXCEEDED", MAC_ADDR_ARRAY(peerMacAddr),
1965 pSmeMaxAssocInd->sessionId);
Jeff Johnson35c58a82018-11-22 15:04:57 -08001966 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301967 smesessionId, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08001968 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001969
1970 return;
1971}
1972
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001973/** -----------------------------------------------------------------
1974 \brief lim_send_sme_ap_channel_switch_resp() - sends
1975 eWNI_SME_CHANNEL_CHANGE_RSP
1976 After receiving WMA_SWITCH_CHANNEL_RSP indication this
1977 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
1978 that the Channel change has been done to the specified target
1979 channel in the Channel change request
Jeff Johnson35c58a82018-11-22 15:04:57 -08001980 \param mac - global mac structure
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001981 \param pe_session - session info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001982 \param pChnlParams - Channel switch params
1983 --------------------------------------------------------------------*/
1984void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001985lim_send_sme_ap_channel_switch_resp(struct mac_context *mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001986 struct pe_session *pe_session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001987 tpSwitchChannelParams pChnlParams)
1988{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001989 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001990 tpSwitchChannelParams pSmeSwithChnlParams;
1991 uint8_t channelId;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08001992 bool is_ch_dfs = false;
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08001993 enum phy_ch_width ch_width;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08001994 uint8_t ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001995
Arif Hussainf5b6c412018-10-10 19:41:09 -07001996 pSmeSwithChnlParams = qdf_mem_malloc(sizeof(tSwitchChannelParams));
1997 if (!pSmeSwithChnlParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001998 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001999
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302000 qdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002001 sizeof(tSwitchChannelParams));
2002
2003 channelId = pSmeSwithChnlParams->channelNumber;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002004 ch_width = pSmeSwithChnlParams->ch_width;
2005 ch_center_freq_seg1 = pSmeSwithChnlParams->ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002006
2007 /*
2008 * Pass the sme sessionID to SME instead
2009 * PE session ID.
2010 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002011 pSmeSwithChnlParams->peSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002012
2013 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
2014 mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
2015 mmhMsg.bodyval = 0;
Jeff Johnsona5abe272019-01-06 12:52:02 -08002016 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002017
2018 /*
2019 * We should start beacon transmission only if the new
2020 * channel after channel change is Non-DFS. For a DFS
2021 * channel, PE will receive an explicit request from
2022 * upper layers to start the beacon transmission .
2023 */
2024
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002025 if (ch_width == CH_WIDTH_160MHZ) {
2026 is_ch_dfs = true;
2027 } else if (ch_width == CH_WIDTH_80P80MHZ) {
Jeff Johnson35c58a82018-11-22 15:04:57 -08002028 if (wlan_reg_get_channel_state(mac->pdev, channelId) ==
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002029 CHANNEL_STATE_DFS ||
Jeff Johnson35c58a82018-11-22 15:04:57 -08002030 wlan_reg_get_channel_state(mac->pdev,
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002031 ch_center_freq_seg1 -
2032 SIR_80MHZ_START_CENTER_CH_DIFF) ==
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002033 CHANNEL_STATE_DFS)
2034 is_ch_dfs = true;
2035 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -08002036 if (wlan_reg_get_channel_state(mac->pdev, channelId) ==
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002037 CHANNEL_STATE_DFS)
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002038 is_ch_dfs = true;
2039 }
2040
2041 if (!is_ch_dfs) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002042 if (channelId == pe_session->currentOperChannel) {
2043 lim_apply_configuration(mac, pe_session);
2044 lim_send_beacon(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002045 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302046 pe_debug("Failed to Transmit Beacons on channel: %d after AP channel change response",
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002047 pe_session->bcnLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002048 }
Arif Hussain1513cb22018-01-05 19:56:31 -08002049
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002050 lim_obss_send_detection_cfg(mac, pe_session, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002051 }
2052 return;
2053}
2054
Peng Xu6363ec62017-05-15 11:06:33 -07002055#ifdef WLAN_FEATURE_11AX_BSS_COLOR
2056/**
2057 * lim_send_bss_color_change_ie_update() - update bss color change IE in
2058 * beacon template
2059 *
2060 * @mac_ctx: pointer to global adapter context
2061 * @session: session pointer
2062 *
2063 * Return: none
2064 */
2065static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002066lim_send_bss_color_change_ie_update(struct mac_context *mac_ctx,
Jeff Johnsond7035a32018-11-18 22:03:13 -08002067 struct pe_session *session)
Peng Xu6363ec62017-05-15 11:06:33 -07002068{
2069 /* Update the beacon template and send to FW */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002070 if (sch_set_fixed_beacon_fields(mac_ctx, session) != QDF_STATUS_SUCCESS) {
Peng Xu6363ec62017-05-15 11:06:33 -07002071 pe_err("Unable to set BSS color change IE in beacon");
Srinivas Girigowdaeff16d92018-09-12 14:56:29 -07002072 return;
Peng Xu6363ec62017-05-15 11:06:33 -07002073 }
2074
2075 /* Send update beacon template message */
Abhishek Singhfc740be2018-10-12 11:34:26 +05302076 lim_send_beacon_ind(mac_ctx, session, REASON_COLOR_CHANGE);
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07002077 pe_debug("Updated BSS color change countdown = %d",
2078 session->he_bss_color_change.countdown);
Peng Xu6363ec62017-05-15 11:06:33 -07002079}
2080
2081static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002082lim_handle_bss_color_change_ie(struct mac_context *mac_ctx,
Jeff Johnsond7035a32018-11-18 22:03:13 -08002083 struct pe_session *session)
Peng Xu6363ec62017-05-15 11:06:33 -07002084{
Arif Hussain2f2d3512018-03-06 12:37:03 -08002085 tUpdateBeaconParams beacon_params;
2086
Peng Xu6363ec62017-05-15 11:06:33 -07002087 /* handle bss color change IE */
2088 if (LIM_IS_AP_ROLE(session) &&
2089 session->he_op.bss_col_disabled) {
2090 if (session->he_bss_color_change.countdown > 0) {
2091 session->he_bss_color_change.countdown--;
2092 } else {
2093 session->bss_color_changing = 0;
Arif Hussain2f2d3512018-03-06 12:37:03 -08002094 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
Arif Hussain05fb4872018-01-03 16:02:55 -08002095 if (session->he_bss_color_change.new_color != 0) {
Peng Xu6363ec62017-05-15 11:06:33 -07002096 session->he_op.bss_col_disabled = 0;
Arif Hussain05fb4872018-01-03 16:02:55 -08002097 session->he_op.bss_color =
2098 session->he_bss_color_change.new_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08002099 beacon_params.paramChangeBitmap |=
2100 PARAM_BSS_COLOR_CHANGED;
2101 beacon_params.bss_color_disabled = 0;
2102 beacon_params.bss_color =
2103 session->he_op.bss_color;
2104 lim_send_beacon_params(mac_ctx,
2105 &beacon_params,
2106 session);
Arif Hussain05fb4872018-01-03 16:02:55 -08002107 lim_send_obss_color_collision_cfg(mac_ctx,
2108 session,
2109 OBSS_COLOR_COLLISION_DETECTION);
2110 }
Peng Xu6363ec62017-05-15 11:06:33 -07002111 }
2112
2113 lim_send_bss_color_change_ie_update(mac_ctx, session);
2114 }
2115}
2116
2117#else
2118static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002119lim_handle_bss_color_change_ie(struct mac_context *mac_ctx,
Jeff Johnsond7035a32018-11-18 22:03:13 -08002120 struct pe_session *session)
Peng Xu6363ec62017-05-15 11:06:33 -07002121{
2122}
2123#endif
2124
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002125void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002126lim_process_beacon_tx_success_ind(struct mac_context *mac_ctx, uint16_t msgType,
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302127 void *event)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002128{
Jeff Johnsond7035a32018-11-18 22:03:13 -08002129 struct pe_session *session;
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302130 tpSirFirstBeaconTxCompleteInd bcn_ind =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002131 (tSirFirstBeaconTxCompleteInd *) event;
2132
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302133 session = pe_find_session_by_bss_idx(mac_ctx, bcn_ind->bssIdx);
2134 if (!session) {
2135 pe_err("Session Does not exist for given session id");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002136 return;
2137 }
2138
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302139 pe_debug("role: %d swIe: %d opIe: %d switch cnt:%d",
2140 GET_LIM_SYSTEM_ROLE(session),
2141 session->dfsIncludeChanSwIe,
2142 session->gLimOperatingMode.present,
2143 session->gLimChannelSwitch.switchCount);
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302144
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302145 if (!LIM_IS_AP_ROLE(session))
2146 return;
Ganesh Kondabattini02ec62b2018-01-24 18:22:24 +05302147
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302148 if (session->dfsIncludeChanSwIe &&
2149 (session->gLimChannelSwitch.switchCount ==
2150 mac_ctx->sap.SapDfsInfo.sap_ch_switch_beacon_cnt))
2151 lim_process_ap_ecsa_timeout(session);
Ganesh Kondabattini02ec62b2018-01-24 18:22:24 +05302152
lifeng1c16b6b2017-09-25 13:59:55 +08002153
Abhishek Singhfc740be2018-10-12 11:34:26 +05302154 if (session->gLimOperatingMode.present)
2155 /* Done with nss update */
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302156 session->gLimOperatingMode.present = 0;
Peng Xu6363ec62017-05-15 11:06:33 -07002157
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302158 lim_handle_bss_color_change_ie(mac_ctx, session);
Peng Xu6363ec62017-05-15 11:06:33 -07002159
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002160 return;
2161}