blob: e896072bcfe79aacaf6dd434f3ea60af12b1df45 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Wu Gao6768d762018-12-28 16:31:08 +08002 * Copyright (c) 2012-2019 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
19/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020 * This file lim_send_sme_rspMessages.cc contains the functions
21 * for sending SME response/notification messages to applications
22 * above MAC software.
23 * Author: Chandra Modumudi
24 * Date: 02/13/02
25 * History:-
26 * Date Modified by Modification Information
27 * --------------------------------------------------------------------
28 */
29
Anurag Chouhan6d760662016-02-20 16:05:43 +053030#include "qdf_types.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080031#include "wni_api.h"
32#include "sir_common.h"
33#include "ani_global.h"
34
35#include "wni_cfg.h"
36#include "sys_def.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080037
38#include "sch_api.h"
39#include "utils_api.h"
40#include "lim_utils.h"
41#include "lim_security_utils.h"
42#include "lim_ser_des_utils.h"
43#include "lim_send_sme_rsp_messages.h"
44#include "lim_ibss_peer_mgmt.h"
45#include "lim_session_utils.h"
46#include "lim_types.h"
47#include "sir_api.h"
Naveen Rawat3b6068c2016-04-14 19:01:06 -070048#include "cds_regdomain.h"
Gupta, Kapil121bf212015-11-25 19:21:29 +053049#include "lim_send_messages.h"
Deepak Dhamdhere13983f22016-05-31 19:06:09 -070050#include "nan_datapath.h"
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -070051#include "lim_assoc_utils.h"
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070052#include "wlan_reg_services_api.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070053#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080054
Kabilan Kannanf56f9d52017-04-05 03:31:34 -070055#include "wlan_tdls_tgt_api.h"
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +053056#include "lim_process_fils.h"
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -080057#include "wma.h"
Kabilan Kannanf56f9d52017-04-05 03:31:34 -070058
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080059/**
60 * lim_send_sme_rsp() - Send Response to upper layers
61 * @mac_ctx: Pointer to Global MAC structure
62 * @msg_type: Indicates message type
63 * @result_code: Indicates the result of previously issued
64 * eWNI_SME_msg_type_REQ message
65 *
66 * This function is called by lim_process_sme_req_messages() to send
67 * eWNI_SME_START_RSP, eWNI_SME_STOP_BSS_RSP
68 * or eWNI_SME_SWITCH_CHL_RSP messages to applications above MAC
69 * Software.
70 *
71 * Return: None
72 */
73
74void
Jeff Johnson9320c1e2018-12-02 13:09:20 -080075lim_send_sme_rsp(struct mac_context *mac_ctx, uint16_t msg_type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080076 tSirResultCodes result_code, uint8_t sme_session_id,
77 uint16_t sme_transaction_id)
78{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070079 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080080 tSirSmeRsp *sme_rsp;
81
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +053082 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080083 lim_msg_str(msg_type), lim_result_code_str(result_code));
84
Anurag Chouhan600c3a02016-03-01 10:33:54 +053085 sme_rsp = qdf_mem_malloc(sizeof(tSirSmeRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -070086 if (!sme_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080087 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080088
89 sme_rsp->messageType = msg_type;
90 sme_rsp->length = sizeof(tSirSmeRsp);
91 sme_rsp->statusCode = result_code;
92
93 sme_rsp->sessionId = sme_session_id;
94 sme_rsp->transactionId = sme_transaction_id;
95
96 msg.type = msg_type;
97 msg.bodyptr = sme_rsp;
98 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +053099 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG,
100 sme_session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800101
102#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
103 switch (msg_type) {
104 case eWNI_SME_STOP_BSS_RSP:
105 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_STOP_BSS_RSP_EVENT,
106 NULL, (uint16_t) result_code, 0);
107 break;
108 }
109#endif /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsona5abe272019-01-06 12:52:02 -0800110 lim_sys_process_mmh_msg_api(mac_ctx, &msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800111}
112
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800113/**
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530114 * lim_get_max_rate_flags() - Get rate flags
115 * @mac_ctx: Pointer to global MAC structure
116 * @sta_ds: Pointer to station ds structure
117 *
118 * This function is called to get the rate flags for a connection
119 * from the station ds structure depending on the ht and the vht
120 * channel width supported.
121 *
122 * Return: Returns the populated rate_flags
123 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800124uint32_t lim_get_max_rate_flags(struct mac_context *mac_ctx, tpDphHashNode sta_ds)
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530125{
126 uint32_t rate_flags = 0;
127
128 if (sta_ds == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530129 pe_err("sta_ds is NULL");
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530130 return rate_flags;
131 }
132
133 if (!sta_ds->mlmStaContext.htCapability &&
134 !sta_ds->mlmStaContext.vhtCapability) {
Naveen Rawatea1564b2018-05-17 15:56:11 -0700135 rate_flags |= TX_RATE_LEGACY;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530136 } else {
137 if (sta_ds->mlmStaContext.vhtCapability) {
138 if (WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ ==
139 sta_ds->vhtSupportedChannelWidthSet) {
Naveen Rawatea1564b2018-05-17 15:56:11 -0700140 rate_flags |= TX_RATE_VHT80;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530141 } else if (WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ ==
142 sta_ds->vhtSupportedChannelWidthSet) {
143 if (sta_ds->htSupportedChannelWidthSet)
Naveen Rawatea1564b2018-05-17 15:56:11 -0700144 rate_flags |= TX_RATE_VHT40;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530145 else
Naveen Rawatea1564b2018-05-17 15:56:11 -0700146 rate_flags |= TX_RATE_VHT20;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530147 }
148 } else if (sta_ds->mlmStaContext.htCapability) {
149 if (sta_ds->htSupportedChannelWidthSet)
Naveen Rawatea1564b2018-05-17 15:56:11 -0700150 rate_flags |= TX_RATE_HT40;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530151 else
Naveen Rawatea1564b2018-05-17 15:56:11 -0700152 rate_flags |= TX_RATE_HT20;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530153 }
154 }
155
156 if (sta_ds->htShortGI20Mhz || sta_ds->htShortGI40Mhz)
Naveen Rawatea1564b2018-05-17 15:56:11 -0700157 rate_flags |= TX_RATE_SGI;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530158
159 return rate_flags;
160}
161
162/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800163 * lim_send_sme_join_reassoc_rsp_after_resume() - Send Response to SME
Jeff Johnson2df04b82019-02-02 23:30:25 -0800164 * @mac_ctx: Pointer to Global MAC structure
165 * @status: Resume link status
166 * @sme_join_rsp: Join response to be sent
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800167 *
168 * This function is called to send Join/Reassoc rsp
169 * message to SME after the resume link.
170 *
171 * Return: None
172 */
Jeff Johnson2df04b82019-02-02 23:30:25 -0800173static void
174lim_send_sme_join_reassoc_rsp_after_resume(struct mac_context *mac_ctx,
175 QDF_STATUS status,
176 struct join_rsp *sme_join_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800177{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700178 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800179
180 msg.type = sme_join_rsp->messageType;
181 msg.bodyptr = sme_join_rsp;
182 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530183 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, NO_SESSION, msg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -0800184 lim_sys_process_mmh_msg_api(mac_ctx, &msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800185}
186
187/**
188 * lim_handle_join_rsp_status() - Handle the response.
189 * @mac_ctx: Pointer to Global MAC structure
190 * @session_entry: PE Session Info
191 * @result_code: Indicates the result of previously issued
192 * eWNI_SME_msgType_REQ message
193 * @sme_join_rsp The received response.
194 *
195 * This function will handle both the success and failure status
196 * of the received response.
197 *
198 * Return: None
199 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800200static void lim_handle_join_rsp_status(struct mac_context *mac_ctx,
Jeff Johnson2df04b82019-02-02 23:30:25 -0800201 struct pe_session *session_entry,
202 tSirResultCodes result_code,
203 struct join_rsp *sme_join_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800204{
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700205 uint16_t bss_ie_len;
206 void *bss_ies;
207 bool is_vendor_ap_1_present;
Jeff Johnson701444f2019-02-02 22:35:13 -0800208 struct join_req *join_reassoc_req = NULL;
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700209
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800210#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
Jeff Johnson704af112019-02-02 16:11:55 -0800211 struct ht_profile *ht_profile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800212#endif
213 if (result_code == eSIR_SME_SUCCESS) {
214 if (session_entry->beacon != NULL) {
215 sme_join_rsp->beaconLength = session_entry->bcnLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530216 qdf_mem_copy(sme_join_rsp->frames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800217 session_entry->beacon,
218 sme_join_rsp->beaconLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530219 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800220 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530221 session_entry->bcnLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530222 pe_debug("Beacon: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530223 sme_join_rsp->beaconLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800224 }
225 if (session_entry->assocReq != NULL) {
226 sme_join_rsp->assocReqLength =
227 session_entry->assocReqLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530228 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530229 sme_join_rsp->beaconLength,
230 session_entry->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800231 sme_join_rsp->assocReqLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530232 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800233 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530234 session_entry->assocReqLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530235 pe_debug("AssocReq: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530236 sme_join_rsp->assocReqLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800237 }
238 if (session_entry->assocRsp != NULL) {
239 sme_join_rsp->assocRspLength =
240 session_entry->assocRspLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530241 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530242 sme_join_rsp->beaconLength +
243 sme_join_rsp->assocReqLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800244 session_entry->assocRsp,
245 sme_join_rsp->assocRspLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530246 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800247 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530248 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800249 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800250 if (session_entry->ricData != NULL) {
251 sme_join_rsp->parsedRicRspLen =
252 session_entry->RICDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530253 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530254 sme_join_rsp->beaconLength +
255 sme_join_rsp->assocReqLength +
256 sme_join_rsp->assocRspLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800257 session_entry->ricData,
258 sme_join_rsp->parsedRicRspLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530259 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800260 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530261 session_entry->RICDataLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530262 pe_debug("RicLength: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800263 sme_join_rsp->parsedRicRspLen);
264 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800265#ifdef FEATURE_WLAN_ESE
266 if (session_entry->tspecIes != NULL) {
267 sme_join_rsp->tspecIeLen =
268 session_entry->tspecLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530269 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530270 sme_join_rsp->beaconLength +
271 sme_join_rsp->assocReqLength +
272 sme_join_rsp->assocRspLength +
273 sme_join_rsp->parsedRicRspLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800274 session_entry->tspecIes,
275 sme_join_rsp->tspecIeLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530276 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800277 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530278 session_entry->tspecLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530279 pe_debug("ESE-TspecLen: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530280 sme_join_rsp->tspecIeLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800281 }
282#endif
283 sme_join_rsp->aid = session_entry->limAID;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530284 pe_debug("AssocRsp: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530285 sme_join_rsp->assocRspLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800286 sme_join_rsp->vht_channel_width =
287 session_entry->ch_width;
288#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
289 if (session_entry->cc_switch_mode !=
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530290 QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Jeff Johnsonf6541882019-02-02 16:16:00 -0800291 ht_profile = &sme_join_rsp->ht_profile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800292 ht_profile->htSupportedChannelWidthSet =
293 session_entry->htSupportedChannelWidthSet;
294 ht_profile->htRecommendedTxWidthSet =
295 session_entry->htRecommendedTxWidthSet;
296 ht_profile->htSecondaryChannelOffset =
297 session_entry->htSecondaryChannelOffset;
298 ht_profile->dot11mode = session_entry->dot11mode;
299 ht_profile->htCapability = session_entry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800300 ht_profile->vhtCapability =
301 session_entry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800302 ht_profile->apCenterChan = session_entry->ch_center_freq_seg0;
303 ht_profile->apChanWidth = session_entry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800304 }
305#endif
Jeff Johnson11bd4f32017-09-18 08:15:17 -0700306 pe_debug("pLimJoinReq:%pK, pLimReAssocReq:%pK",
Wu Gao2968fc92017-06-19 19:18:34 +0800307 session_entry->pLimJoinReq,
308 session_entry->pLimReAssocReq);
309
310 if (session_entry->pLimJoinReq)
311 join_reassoc_req = session_entry->pLimJoinReq;
312
313 if (session_entry->pLimReAssocReq)
314 join_reassoc_req = session_entry->pLimReAssocReq;
315
316 if (!join_reassoc_req) {
317 pe_err("both pLimJoinReq and pLimReAssocReq NULL");
318 return;
319 }
320
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700321 bss_ie_len = lim_get_ielen_from_bss_description(
Wu Gao2968fc92017-06-19 19:18:34 +0800322 &join_reassoc_req->bssDescription);
323 bss_ies = &join_reassoc_req->bssDescription.ieFields;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700324 is_vendor_ap_1_present = (wlan_get_vendor_ie_ptr_from_oui(
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700325 SIR_MAC_VENDOR_AP_1_OUI, SIR_MAC_VENDOR_AP_1_OUI_LEN,
326 bss_ies, bss_ie_len) != NULL);
327
328 if (mac_ctx->roam.configParam.is_force_1x1 &&
Krunal Sonie6a1cda2017-09-27 15:23:02 -0700329 is_vendor_ap_1_present && (session_entry->nss == 2) &&
330 (mac_ctx->lteCoexAntShare == 0 ||
331 IS_5G_CH(session_entry->currentOperChannel))) {
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700332 /* SET vdev param */
333 pe_debug("sending SMPS intolrent vdev_param");
334 wma_cli_set_command(session_entry->smeSessionId,
335 (int)WMI_VDEV_PARAM_SMPS_INTOLERANT,
336 1, VDEV_CMD);
337
338 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800339 } else {
340 if (session_entry->beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530341 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800342 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530343 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800344 }
345 if (session_entry->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530346 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800347 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530348 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800349 }
350 if (session_entry->assocRsp != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530351 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800352 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530353 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800354 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800355 if (session_entry->ricData != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530356 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800357 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530358 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800359 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800360#ifdef FEATURE_WLAN_ESE
361 if (session_entry->tspecIes != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530362 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800363 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530364 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800365 }
366#endif
367 }
368}
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530369
370/**
371 * lim_add_bss_info() - copy data from session entry to join rsp
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530372 * @sta_ds: Station dph entry
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530373 * @sme_join_rsp: Join response buffer to be filled up
374 *
375 * Return: None
376 */
Jeff Johnson2df04b82019-02-02 23:30:25 -0800377static void lim_add_bss_info(tpDphHashNode sta_ds,
378 struct join_rsp *sme_join_rsp)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530379{
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530380 struct parsed_ies *parsed_ies = &sta_ds->parsed_ies;
381
382 if (parsed_ies->hs20vendor_ie.present)
383 sme_join_rsp->hs20vendor_ie = parsed_ies->hs20vendor_ie;
384 if (parsed_ies->vht_caps.present)
385 sme_join_rsp->vht_caps = parsed_ies->vht_caps;
386 if (parsed_ies->ht_caps.present)
387 sme_join_rsp->ht_caps = parsed_ies->ht_caps;
388 if (parsed_ies->ht_operation.present)
389 sme_join_rsp->ht_operation = parsed_ies->ht_operation;
390 if (parsed_ies->vht_operation.present)
391 sme_join_rsp->vht_operation = parsed_ies->vht_operation;
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530392}
393
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530394#ifdef WLAN_FEATURE_FILS_SK
Jeff Johnson2df04b82019-02-02 23:30:25 -0800395static void lim_update_fils_seq_num(struct join_rsp *sme_join_rsp,
Jeff Johnsond7035a32018-11-18 22:03:13 -0800396 struct pe_session *session_entry)
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530397{
398 sme_join_rsp->fils_seq_num =
399 session_entry->fils_info->sequence_number;
400}
401#else
Jeff Johnson2df04b82019-02-02 23:30:25 -0800402static inline void lim_update_fils_seq_num(struct join_rsp *sme_join_rsp,
Jeff Johnsond7035a32018-11-18 22:03:13 -0800403 struct pe_session *session_entry)
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530404{}
405#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800406/**
407 * lim_send_sme_join_reassoc_rsp() - Send Response to Upper Layers
408 * @mac_ctx: Pointer to Global MAC structure
409 * @msg_type: Indicates message type
410 * @result_code: Indicates the result of previously issued
411 * eWNI_SME_msgType_REQ message
412 * @prot_status_code: Protocol Status Code
413 * @session_entry: PE Session Info
414 * @sme_session_id: SME Session ID
415 * @sme_transaction_id: SME Transaction ID
416 *
417 * This function is called by lim_process_sme_req_messages() to send
418 * eWNI_SME_JOIN_RSP or eWNI_SME_REASSOC_RSP messages to applications
419 * above MAC Software.
420 *
421 * Return: None
422 */
423
424void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800425lim_send_sme_join_reassoc_rsp(struct mac_context *mac_ctx, uint16_t msg_type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800426 tSirResultCodes result_code, uint16_t prot_status_code,
Jeff Johnsond7035a32018-11-18 22:03:13 -0800427 struct pe_session *session_entry, uint8_t sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800428 uint16_t sme_transaction_id)
429{
Jeff Johnson2df04b82019-02-02 23:30:25 -0800430 struct join_rsp *sme_join_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800431 uint32_t rsp_len;
432 tpDphHashNode sta_ds = NULL;
433#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
434 if (msg_type == eWNI_SME_REASSOC_RSP)
435 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_RSP_EVENT,
436 session_entry, (uint16_t) result_code, 0);
437 else
438 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_RSP_EVENT,
439 session_entry, (uint16_t) result_code, 0);
440#endif /* FEATURE_WLAN_DIAG_SUPPORT */
441
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530442 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800443 lim_msg_str(msg_type), lim_result_code_str(result_code));
444
445 if (session_entry == NULL) {
Jeff Johnson2df04b82019-02-02 23:30:25 -0800446 rsp_len = sizeof(*sme_join_rsp);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530447 sme_join_rsp = qdf_mem_malloc(rsp_len);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700448 if (!sme_join_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800449 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800450
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800451 sme_join_rsp->beaconLength = 0;
452 sme_join_rsp->assocReqLength = 0;
453 sme_join_rsp->assocRspLength = 0;
454 } else {
455 rsp_len = session_entry->assocReqLen +
456 session_entry->assocRspLen + session_entry->bcnLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800457 session_entry->RICDataLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800458#ifdef FEATURE_WLAN_ESE
459 session_entry->tspecLen +
460#endif
Jeff Johnson2df04b82019-02-02 23:30:25 -0800461 sizeof(*sme_join_rsp) - sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530462 sme_join_rsp = qdf_mem_malloc(rsp_len);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700463 if (!sme_join_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800464 return;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530465
466 if (lim_is_fils_connection(session_entry)) {
467 sme_join_rsp->is_fils_connection = true;
468 lim_update_fils_seq_num(sme_join_rsp,
469 session_entry);
470 }
471
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800472 if (result_code == eSIR_SME_SUCCESS) {
473 sta_ds = dph_get_hash_entry(mac_ctx,
474 DPH_STA_HASH_INDEX_PEER,
475 &session_entry->dph.dphHashTable);
476 if (sta_ds == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530477 pe_err("Get Self Sta Entry fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800478 } else {
479 /* Pass the peer's staId */
480 sme_join_rsp->staId = sta_ds->staIndex;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800481 sme_join_rsp->timingMeasCap =
482 sta_ds->timingMeasCap;
483#ifdef FEATURE_WLAN_TDLS
484 sme_join_rsp->tdls_prohibited =
485 session_entry->tdls_prohibited;
486 sme_join_rsp->tdls_chan_swit_prohibited =
487 session_entry->tdls_chan_swit_prohibited;
488#endif
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530489 sme_join_rsp->nss = sta_ds->nss;
490 sme_join_rsp->max_rate_flags =
491 lim_get_max_rate_flags(mac_ctx, sta_ds);
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530492 lim_add_bss_info(sta_ds, sme_join_rsp);
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530493
494 /* Copy FILS params only for Successful join */
495 populate_fils_connect_params(mac_ctx,
496 session_entry, sme_join_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800497 }
498 }
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530499
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800500 sme_join_rsp->beaconLength = 0;
501 sme_join_rsp->assocReqLength = 0;
502 sme_join_rsp->assocRspLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800503 sme_join_rsp->parsedRicRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800504#ifdef FEATURE_WLAN_ESE
505 sme_join_rsp->tspecIeLen = 0;
506#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800507 lim_handle_join_rsp_status(mac_ctx, session_entry, result_code,
508 sme_join_rsp);
Bala Venkateshe7f79162019-01-16 16:43:59 +0530509 sme_join_rsp->uapsd_mask = session_entry->gUapsdPerAcBitmask;
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800510 /* Send supported NSS 1x1 to SME */
511 sme_join_rsp->supported_nss_1x1 =
512 session_entry->supported_nss_1x1;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530513 pe_debug("SME Join Rsp is supported NSS 1X1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800514 sme_join_rsp->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800515 }
516
517 sme_join_rsp->messageType = msg_type;
518 sme_join_rsp->length = (uint16_t) rsp_len;
519 sme_join_rsp->statusCode = result_code;
520 sme_join_rsp->protStatusCode = prot_status_code;
521
522 sme_join_rsp->sessionId = sme_session_id;
523 sme_join_rsp->transactionId = sme_transaction_id;
524
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530525 lim_send_sme_join_reassoc_rsp_after_resume(mac_ctx, QDF_STATUS_SUCCESS,
Jeff Johnson2df04b82019-02-02 23:30:25 -0800526 sme_join_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800527}
528
529/**
530 * lim_send_sme_start_bss_rsp()
531 *
532 ***FUNCTION:
533 * This function is called to send eWNI_SME_START_BSS_RSP
534 * message to applications above MAC Software.
535 *
536 ***PARAMS:
537 *
538 ***LOGIC:
539 *
540 ***ASSUMPTIONS:
541 * NA
542 *
543 ***NOTE:
544 * NA
545 *
Jeff Johnson35c58a82018-11-22 15:04:57 -0800546 * @param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800547 * @param msgType Indicates message type
548 * @param resultCode Indicates the result of previously issued
549 * eWNI_SME_msgType_REQ message
550 *
551 * @return None
552 */
553
554void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800555lim_send_sme_start_bss_rsp(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800556 uint16_t msgType, tSirResultCodes resultCode,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800557 struct pe_session *pe_session, uint8_t smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800558 uint16_t smetransactionId)
559{
560
561 uint16_t size = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700562 struct scheduler_msg mmhMsg = {0};
Jeff Johnsona0d34622019-02-02 17:26:19 -0800563 struct start_bss_rsp *pSirSmeRsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800564 uint16_t ieLen;
565 uint16_t ieOffset, curLen;
566
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530567 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800568 lim_msg_str(msgType), lim_result_code_str(resultCode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800569
Jeff Johnsona0d34622019-02-02 17:26:19 -0800570 size = sizeof(struct start_bss_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800571
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800572 if (pe_session == NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530573 pSirSmeRsp = qdf_mem_malloc(size);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700574 if (!pSirSmeRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800575 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800576 } else {
577 /* subtract size of beaconLength + Mac Hdr + Fixed Fields before SSID */
578 ieOffset = sizeof(tAniBeaconStruct) + SIR_MAC_B_PR_SSID_OFFSET;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800579 ieLen = pe_session->schBeaconOffsetBegin
580 + pe_session->schBeaconOffsetEnd - ieOffset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800581 /* calculate the memory size to allocate */
582 size += ieLen;
583
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530584 pSirSmeRsp = qdf_mem_malloc(size);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700585 if (!pSirSmeRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800586 return;
Jeff Johnsona0d34622019-02-02 17:26:19 -0800587 size = sizeof(struct start_bss_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800588 if (resultCode == eSIR_SME_SUCCESS) {
589
590 sir_copy_mac_addr(pSirSmeRsp->bssDescription.bssId,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800591 pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800592
593 /* Read beacon interval from session */
594 pSirSmeRsp->bssDescription.beaconInterval =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800595 (uint16_t) pe_session->beaconParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800596 beaconInterval;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800597 pSirSmeRsp->bssType = pe_session->bssType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800598
Wu Gao5c3d94b2019-01-17 21:15:54 +0800599 if (lim_get_capability_info
Jeff Johnson35c58a82018-11-22 15:04:57 -0800600 (mac, &pSirSmeRsp->bssDescription.capabilityInfo,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800601 pe_session)
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700602 != QDF_STATUS_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530603 pe_err("could not retrieve Capabilities value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800604
Jeff Johnson35c58a82018-11-22 15:04:57 -0800605 lim_get_phy_mode(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800606 (uint32_t *) &pSirSmeRsp->bssDescription.
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800607 nwType, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800608
609 pSirSmeRsp->bssDescription.channelId =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800610 pe_session->currentOperChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800611
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800612 if (!LIM_IS_NDI_ROLE(pe_session)) {
613 curLen = pe_session->schBeaconOffsetBegin - ieOffset;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530614 qdf_mem_copy((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800615 ieFields,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800616 pe_session->pSchBeaconFrameBegin +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800617 ieOffset, (uint32_t) curLen);
618
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530619 qdf_mem_copy(((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800620 ieFields) + curLen,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800621 pe_session->pSchBeaconFrameEnd,
622 (uint32_t) pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800623 schBeaconOffsetEnd);
624
Abhishek Singh34a4d862016-10-26 16:01:51 +0530625 pSirSmeRsp->bssDescription.length = (uint16_t)
626 (offsetof(tSirBssDescription, ieFields[0])
627 - sizeof(pSirSmeRsp->bssDescription.length)
628 + ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800629 /* This is the size of the message, subtracting the size of the pointer to ieFields */
630 size += ieLen - sizeof(uint32_t);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700631 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800632#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800633 if (pe_session->cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530634 != QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Jeff Johnsonf6541882019-02-02 16:16:00 -0800635 pSirSmeRsp->ht_profile.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800636 htSupportedChannelWidthSet =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800637 pe_session->htSupportedChannelWidthSet;
Jeff Johnsonf6541882019-02-02 16:16:00 -0800638 pSirSmeRsp->ht_profile.htRecommendedTxWidthSet =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800639 pe_session->htRecommendedTxWidthSet;
Jeff Johnsonf6541882019-02-02 16:16:00 -0800640 pSirSmeRsp->ht_profile.htSecondaryChannelOffset =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800641 pe_session->htSecondaryChannelOffset;
Jeff Johnsonf6541882019-02-02 16:16:00 -0800642 pSirSmeRsp->ht_profile.dot11mode =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800643 pe_session->dot11mode;
Jeff Johnsonf6541882019-02-02 16:16:00 -0800644 pSirSmeRsp->ht_profile.htCapability =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800645 pe_session->htCapability;
Jeff Johnsonf6541882019-02-02 16:16:00 -0800646 pSirSmeRsp->ht_profile.vhtCapability =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800647 pe_session->vhtCapability;
Jeff Johnsonf6541882019-02-02 16:16:00 -0800648 pSirSmeRsp->ht_profile.apCenterChan =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800649 pe_session->ch_center_freq_seg0;
Jeff Johnsonf6541882019-02-02 16:16:00 -0800650 pSirSmeRsp->ht_profile.apChanWidth =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800651 pe_session->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800652 }
653#endif
654 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800655 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800656 pSirSmeRsp->messageType = msgType;
657 pSirSmeRsp->length = size;
658
659 /* Update SME session Id and transaction Id */
660 pSirSmeRsp->sessionId = smesessionId;
661 pSirSmeRsp->transactionId = smetransactionId;
662 pSirSmeRsp->statusCode = resultCode;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800663 if (pe_session != NULL)
664 pSirSmeRsp->staId = pe_session->staId; /* else it will be always zero smeRsp StaID = 0 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800665
666 mmhMsg.type = msgType;
667 mmhMsg.bodyptr = pSirSmeRsp;
668 mmhMsg.bodyval = 0;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800669 if (pe_session == NULL) {
Jeff Johnson35c58a82018-11-22 15:04:57 -0800670 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530671 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800672 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -0800673 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800674 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800675 }
676#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -0800677 lim_diag_event_report(mac, WLAN_PE_DIAG_START_BSS_RSP_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800678 pe_session, (uint16_t) resultCode, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800679#endif /* FEATURE_WLAN_DIAG_SUPPORT */
680
Jeff Johnsona5abe272019-01-06 12:52:02 -0800681 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800682} /*** end lim_send_sme_start_bss_rsp() ***/
683
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800684void lim_send_sme_disassoc_deauth_ntf(struct mac_context *mac,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530685 QDF_STATUS status, uint32_t *pCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800686{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700687 struct scheduler_msg mmhMsg = {0};
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800688 struct scheduler_msg *pMsg = (struct scheduler_msg *) pCtx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800689
690 mmhMsg.type = pMsg->type;
691 mmhMsg.bodyptr = pMsg;
692 mmhMsg.bodyval = 0;
693
Jeff Johnson35c58a82018-11-22 15:04:57 -0800694 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800695
Jeff Johnsona5abe272019-01-06 12:52:02 -0800696 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800697}
698
699/**
700 * lim_send_sme_disassoc_ntf()
701 *
702 ***FUNCTION:
703 * This function is called by limProcessSmeMessages() to send
704 * eWNI_SME_DISASSOC_RSP/IND message to host
705 *
706 ***PARAMS:
707 *
708 ***LOGIC:
709 *
710 ***ASSUMPTIONS:
711 * NA
712 *
713 ***NOTE:
714 * This function is used for sending eWNI_SME_DISASSOC_CNF,
715 * or eWNI_SME_DISASSOC_IND to host depending on
716 * disassociation trigger.
717 *
718 * @param peerMacAddr Indicates the peer MAC addr to which
719 * disassociate was initiated
720 * @param reasonCode Indicates the reason for Disassociation
721 * @param disassocTrigger Indicates the trigger for Disassociation
722 * @param aid Indicates the STAID. This parameter is
723 * present only on AP.
724 *
725 * @return None
726 */
727void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800728lim_send_sme_disassoc_ntf(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800729 tSirMacAddr peerMacAddr,
730 tSirResultCodes reasonCode,
731 uint16_t disassocTrigger,
732 uint16_t aid,
733 uint8_t smesessionId,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800734 uint16_t smetransactionId, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800735{
736
737 uint8_t *pBuf;
Jeff Johnson380a1cd2019-02-03 21:43:51 -0800738 struct disassoc_rsp *pSirSmeDisassocRsp;
Jeff Johnson318a9882019-02-04 08:30:50 -0800739 struct disassoc_ind *pSirSmeDisassocInd;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700740 uint32_t *pMsg = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800741 bool failure = false;
Jeff Johnsond7035a32018-11-18 22:03:13 -0800742 struct pe_session *session = NULL;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700743 uint16_t i, assoc_id;
744 tpDphHashNode sta_ds = NULL;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +0530745 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800746
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530747 pe_debug("Disassoc Ntf with trigger : %d reasonCode: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800748 disassocTrigger, reasonCode);
749
750 switch (disassocTrigger) {
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700751 case eLIM_DUPLICATE_ENTRY:
752 /*
753 * Duplicate entry is removed at LIM.
754 * Initiate new entry for other session
755 */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530756 pe_debug("Rcvd eLIM_DUPLICATE_ENTRY for " MAC_ADDRESS_STR,
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700757 MAC_ADDR_ARRAY(peerMacAddr));
758
Jeff Johnson35c58a82018-11-22 15:04:57 -0800759 for (i = 0; i < mac->lim.maxBssId; i++) {
760 if ((&mac->lim.gpSession[i] != NULL) &&
761 (mac->lim.gpSession[i].valid) &&
762 (mac->lim.gpSession[i].pePersona ==
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700763 QDF_SAP_MODE)) {
764 /* Find the sta ds entry in another session */
Jeff Johnson35c58a82018-11-22 15:04:57 -0800765 session = &mac->lim.gpSession[i];
766 sta_ds = dph_lookup_hash_entry(mac,
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700767 peerMacAddr, &assoc_id,
768 &session->dph.dphHashTable);
Abhishek Singh6d6e3d12017-12-04 14:16:00 +0530769 if (sta_ds)
770 break;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700771 }
772 }
773 if (sta_ds
774#ifdef WLAN_FEATURE_11W
775 && (!sta_ds->rmfEnabled)
776#endif
777 ) {
Jeff Johnson35c58a82018-11-22 15:04:57 -0800778 if (lim_add_sta(mac, sta_ds, false, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700779 QDF_STATUS_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530780 pe_err("could not Add STA with assocId: %d",
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700781 sta_ds->assocId);
782 }
Jeff Johnson35c58a82018-11-22 15:04:57 -0800783 status = lim_prepare_disconnect_done_ind(mac, &pMsg,
Pragaspathi Thilagaraj766c76f2018-08-08 16:44:40 +0530784 smesessionId,
785 reasonCode,
786 &peerMacAddr[0]);
787 if (!QDF_IS_STATUS_SUCCESS(status)) {
788 pe_err("Failed to prepare message");
789 return;
790 }
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700791 break;
792
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800793 case eLIM_HOST_DISASSOC:
794 /**
795 * Disassociation response due to
796 * host triggered disassociation
797 */
798
Jeff Johnson380a1cd2019-02-03 21:43:51 -0800799 pSirSmeDisassocRsp = qdf_mem_malloc(sizeof(struct disassoc_rsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700800 if (!pSirSmeDisassocRsp) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800801 failure = true;
802 goto error;
803 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530804 pe_debug("send eWNI_SME_DISASSOC_RSP with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800805 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
806 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
Jeff Johnson380a1cd2019-02-03 21:43:51 -0800807 pSirSmeDisassocRsp->length = sizeof(struct disassoc_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800808 /* sessionId */
809 pBuf = (uint8_t *) &pSirSmeDisassocRsp->sessionId;
810 *pBuf = smesessionId;
811 pBuf++;
812
813 /* transactionId */
814 lim_copy_u16(pBuf, smetransactionId);
815 pBuf += sizeof(uint16_t);
816
817 /* statusCode */
818 lim_copy_u32(pBuf, reasonCode);
819 pBuf += sizeof(tSirResultCodes);
820
821 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530822 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800823 pBuf += sizeof(tSirMacAddr);
824
825 /* Clear Station Stats */
826 /* for sta, it is always 1, IBSS is handled at halInitSta */
827
828#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
829
Jeff Johnson35c58a82018-11-22 15:04:57 -0800830 lim_diag_event_report(mac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800831 pe_session, (uint16_t) reasonCode, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800832#endif
833 pMsg = (uint32_t *) pSirSmeDisassocRsp;
834 break;
835
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530836 case eLIM_PEER_ENTITY_DISASSOC:
837 case eLIM_LINK_MONITORING_DISASSOC:
Jeff Johnson35c58a82018-11-22 15:04:57 -0800838 status = lim_prepare_disconnect_done_ind(mac, &pMsg,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +0530839 smesessionId,
840 reasonCode, &peerMacAddr[0]);
841 if (!QDF_IS_STATUS_SUCCESS(status)) {
842 pe_err("Failed to prepare message");
843 return;
844 }
845 break;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530846
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800847 default:
848 /**
849 * Disassociation indication due to Disassociation
850 * frame reception from peer entity or due to
851 * loss of link with peer entity.
852 */
Jeff Johnson318a9882019-02-04 08:30:50 -0800853 pSirSmeDisassocInd =
854 qdf_mem_malloc(sizeof(*pSirSmeDisassocInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700855 if (!pSirSmeDisassocInd) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800856 failure = true;
857 goto error;
858 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530859 pe_debug("send eWNI_SME_DISASSOC_IND with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800860 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
861 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
Jeff Johnson318a9882019-02-04 08:30:50 -0800862 pSirSmeDisassocInd->length = sizeof(*pSirSmeDisassocInd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800863
864 /* Update SME session Id and Transaction Id */
865 pSirSmeDisassocInd->sessionId = smesessionId;
866 pSirSmeDisassocInd->transactionId = smetransactionId;
867 pSirSmeDisassocInd->reasonCode = reasonCode;
868 pBuf = (uint8_t *) &pSirSmeDisassocInd->statusCode;
869
870 lim_copy_u32(pBuf, reasonCode);
871 pBuf += sizeof(tSirResultCodes);
872
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800873 qdf_mem_copy(pBuf, pe_session->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800874 pBuf += sizeof(tSirMacAddr);
875
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530876 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800877
878#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -0800879 lim_diag_event_report(mac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800880 pe_session, (uint16_t) reasonCode, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800881#endif
882 pMsg = (uint32_t *) pSirSmeDisassocInd;
883
884 break;
885 }
886
887error:
888 /* Delete the PE session Created */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800889 if ((pe_session != NULL) && LIM_IS_STA_ROLE(pe_session))
890 pe_delete_session(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800891
892 if (false == failure)
Jeff Johnson35c58a82018-11-22 15:04:57 -0800893 lim_send_sme_disassoc_deauth_ntf(mac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800894 (uint32_t *) pMsg);
895} /*** end lim_send_sme_disassoc_ntf() ***/
896
897/** -----------------------------------------------------------------
898 \brief lim_send_sme_disassoc_ind() - sends SME_DISASSOC_IND
899
900 After receiving disassociation frame from peer entity, this
901 function sends a eWNI_SME_DISASSOC_IND to SME with a specific
902 reason code.
903
Jeff Johnson35c58a82018-11-22 15:04:57 -0800904 \param mac - global mac structure
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800905 \param sta - station dph hash node
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800906 \return none
907 \sa
908 ----------------------------------------------------------------- */
909void
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800910lim_send_sme_disassoc_ind(struct mac_context *mac, tpDphHashNode sta,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800911 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800912{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700913 struct scheduler_msg mmhMsg = {0};
Jeff Johnson318a9882019-02-04 08:30:50 -0800914 struct disassoc_ind *pSirSmeDisassocInd;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800915
Jeff Johnson318a9882019-02-04 08:30:50 -0800916 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(*pSirSmeDisassocInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700917 if (!pSirSmeDisassocInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800918 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800919
920 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
Jeff Johnson318a9882019-02-04 08:30:50 -0800921 pSirSmeDisassocInd->length = sizeof(*pSirSmeDisassocInd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800922
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800923 pSirSmeDisassocInd->sessionId = pe_session->smeSessionId;
924 pSirSmeDisassocInd->transactionId = pe_session->transactionId;
Padma, Santhosh Kumar02289212016-09-30 13:30:08 +0530925 pSirSmeDisassocInd->statusCode = eSIR_SME_DEAUTH_STATUS;
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800926 pSirSmeDisassocInd->reasonCode = sta->mlmStaContext.disassocReason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800927
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800928 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes, pe_session->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530929 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800930
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800931 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes, sta->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530932 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800933
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800934 pSirSmeDisassocInd->staId = sta->staIndex;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800935
936 mmhMsg.type = eWNI_SME_DISASSOC_IND;
937 mmhMsg.bodyptr = pSirSmeDisassocInd;
938 mmhMsg.bodyval = 0;
939
Jeff Johnson35c58a82018-11-22 15:04:57 -0800940 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800941 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800942#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800943 lim_diag_event_report(mac, WLAN_PE_DIAG_DISASSOC_IND_EVENT, pe_session,
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800944 0, (uint16_t) sta->mlmStaContext.disassocReason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800945#endif /* FEATURE_WLAN_DIAG_SUPPORT */
946
Jeff Johnsona5abe272019-01-06 12:52:02 -0800947 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800948
949} /*** end lim_send_sme_disassoc_ind() ***/
950
951/** -----------------------------------------------------------------
952 \brief lim_send_sme_deauth_ind() - sends SME_DEAUTH_IND
953
954 After receiving deauthentication frame from peer entity, this
955 function sends a eWNI_SME_DEAUTH_IND to SME with a specific
956 reason code.
957
Jeff Johnson35c58a82018-11-22 15:04:57 -0800958 \param mac - global mac structure
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800959 \param sta - station dph hash node
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800960 \return none
961 \sa
962 ----------------------------------------------------------------- */
963void
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800964lim_send_sme_deauth_ind(struct mac_context *mac, tpDphHashNode sta,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800965 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800966{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700967 struct scheduler_msg mmhMsg = {0};
Jeff Johnsonfec08712019-02-04 13:12:08 -0800968 struct deauth_ind *pSirSmeDeauthInd;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800969
Jeff Johnsonfec08712019-02-04 13:12:08 -0800970 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(*pSirSmeDeauthInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700971 if (!pSirSmeDeauthInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800972 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800973
974 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
Jeff Johnsonfec08712019-02-04 13:12:08 -0800975 pSirSmeDeauthInd->length = sizeof(*pSirSmeDeauthInd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800976
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800977 pSirSmeDeauthInd->sessionId = pe_session->smeSessionId;
978 pSirSmeDeauthInd->transactionId = pe_session->transactionId;
979 if (eSIR_INFRA_AP_MODE == pe_session->bssType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800980 pSirSmeDeauthInd->statusCode =
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800981 (tSirResultCodes) sta->mlmStaContext.cleanupTrigger;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800982 } else {
Jeff Johnsonfec08712019-02-04 13:12:08 -0800983 /* Need to indicate the reason code over the air */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800984 pSirSmeDeauthInd->statusCode =
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800985 (tSirResultCodes) sta->mlmStaContext.disassocReason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800986 }
987 /* BSSID */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800988 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, pe_session->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530989 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800990 /* peerMacAddr */
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800991 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, sta->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530992 QDF_MAC_ADDR_SIZE);
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800993 pSirSmeDeauthInd->reasonCode = sta->mlmStaContext.disassocReason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800994
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800995 pSirSmeDeauthInd->staId = sta->staIndex;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -0800996 if (eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON ==
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800997 sta->mlmStaContext.disassocReason)
998 pSirSmeDeauthInd->rssi = sta->del_sta_ctx_rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800999
1000 mmhMsg.type = eWNI_SME_DEAUTH_IND;
1001 mmhMsg.bodyptr = pSirSmeDeauthInd;
1002 mmhMsg.bodyval = 0;
1003
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001004 MTRACE(mac_trace_msg_tx(mac, pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001005#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001006 lim_diag_event_report(mac, WLAN_PE_DIAG_DEAUTH_IND_EVENT, pe_session,
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08001007 0, sta->mlmStaContext.cleanupTrigger);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001008#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1009
Jeff Johnsona5abe272019-01-06 12:52:02 -08001010 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001011 return;
1012} /*** end lim_send_sme_deauth_ind() ***/
1013
1014#ifdef FEATURE_WLAN_TDLS
1015/**
1016 * lim_send_sme_tdls_del_sta_ind()
1017 *
1018 ***FUNCTION:
1019 * This function is called to send the TDLS STA context deletion to SME.
1020 *
1021 ***LOGIC:
1022 *
1023 ***ASSUMPTIONS:
1024 *
1025 ***NOTE:
1026 * NA
1027 *
Jeff Johnson35c58a82018-11-22 15:04:57 -08001028 * @param mac - Pointer to global MAC structure
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08001029 * @param sta - Pointer to internal STA Datastructure
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001030 * @param pe_session - Pointer to the session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001031 * @param reasonCode - Reason for TDLS sta deletion
1032 * @return None
1033 */
1034void
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08001035lim_send_sme_tdls_del_sta_ind(struct mac_context *mac, tpDphHashNode sta,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001036 struct pe_session *pe_session, uint16_t reasonCode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001037{
Frank Liud1a28462017-09-06 22:55:48 +08001038 struct tdls_event_info info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001039
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301040 pe_debug("Delete TDLS Peer "MAC_ADDRESS_STR "with reason code: %d",
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08001041 MAC_ADDR_ARRAY(sta->staAddr), reasonCode);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001042 info.vdev_id = pe_session->smeSessionId;
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08001043 qdf_mem_copy(info.peermac.bytes, sta->staAddr, QDF_MAC_ADDR_SIZE);
Frank Liud1a28462017-09-06 22:55:48 +08001044 info.message_type = TDLS_PEER_DISCONNECTED;
1045 info.peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001046
Jeff Johnson35c58a82018-11-22 15:04:57 -08001047 tgt_tdls_event_handler(mac->psoc, &info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001048
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001049 return;
1050} /*** end lim_send_sme_tdls_del_sta_ind() ***/
1051
1052/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001053 * lim_send_sme_mgmt_tx_completion()
1054 *
1055 ***FUNCTION:
1056 * This function is called to send the eWNI_SME_MGMT_FRM_TX_COMPLETION_IND
1057 * message to SME.
1058 *
1059 ***LOGIC:
1060 *
1061 ***ASSUMPTIONS:
1062 *
1063 ***NOTE:
1064 * NA
1065 *
Jeff Johnson35c58a82018-11-22 15:04:57 -08001066 * @param mac - Pointer to global MAC structure
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001067 * @param pe_session - Pointer to the session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001068 * @param txCompleteStatus - TX Complete Status of Mgmt Frames
1069 * @return None
1070 */
1071void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001072lim_send_sme_mgmt_tx_completion(struct mac_context *mac,
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301073 uint32_t sme_session_id,
1074 uint32_t txCompleteStatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001075{
Wu Gao6768d762018-12-28 16:31:08 +08001076 struct scheduler_msg msg = {0};
1077 struct tdls_mgmt_tx_completion_ind *mgmt_tx_completion_ind;
1078 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001079
Wu Gao6768d762018-12-28 16:31:08 +08001080 mgmt_tx_completion_ind =
1081 qdf_mem_malloc(sizeof(*mgmt_tx_completion_ind));
1082 if (!mgmt_tx_completion_ind)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001083 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001084
1085 /* sessionId */
Wu Gao6768d762018-12-28 16:31:08 +08001086 mgmt_tx_completion_ind->session_id = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001087
Wu Gao6768d762018-12-28 16:31:08 +08001088 mgmt_tx_completion_ind->tx_complete_status = txCompleteStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001089
Wu Gao6768d762018-12-28 16:31:08 +08001090 msg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1091 msg.bodyptr = mgmt_tx_completion_ind;
1092 msg.bodyval = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001093
Wu Gao6768d762018-12-28 16:31:08 +08001094 mgmt_tx_completion_ind->psoc = mac->psoc;
1095 msg.callback = tgt_tdls_send_mgmt_tx_completion;
1096 status = scheduler_post_message(QDF_MODULE_ID_PE,
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05301097 QDF_MODULE_ID_TDLS,
Wu Gao6768d762018-12-28 16:31:08 +08001098 QDF_MODULE_ID_TARGET_IF, &msg);
1099 if (QDF_IS_STATUS_ERROR(status)) {
1100 pe_err("post msg fail, %d", status);
1101 qdf_mem_free(mgmt_tx_completion_ind);
1102 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001103} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1104
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001105#endif /* FEATURE_WLAN_TDLS */
1106
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001107QDF_STATUS lim_prepare_disconnect_done_ind(struct mac_context *mac_ctx,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301108 uint32_t **msg,
1109 uint8_t session_id,
1110 tSirResultCodes reason_code,
1111 uint8_t *peer_mac_addr)
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301112{
1113 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301114
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301115 sir_sme_dis_ind = qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001116 if (!sir_sme_dis_ind)
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301117 return QDF_STATUS_E_FAILURE;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301118
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301119 pe_debug("Prepare eWNI_SME_DISCONNECT_DONE_IND withretCode: %d",
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301120 reason_code);
1121
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301122 sir_sme_dis_ind->message_type = eWNI_SME_DISCONNECT_DONE_IND;
1123 sir_sme_dis_ind->length = sizeof(*sir_sme_dis_ind);
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301124 sir_sme_dis_ind->session_id = session_id;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301125 if (peer_mac_addr)
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05301126 qdf_mem_copy(sir_sme_dis_ind->peer_mac,
1127 peer_mac_addr, ETH_ALEN);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301128
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301129 /*
1130 * Instead of sending deauth reason code as 505 which is
1131 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1132 * Send reason code as zero to Supplicant
1133 */
1134 if (reason_code == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1135 sir_sme_dis_ind->reason_code = 0;
1136 else
1137 sir_sme_dis_ind->reason_code = reason_code;
1138
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301139 *msg = (uint32_t *)sir_sme_dis_ind;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301140
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301141 return QDF_STATUS_SUCCESS;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301142}
1143
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001144/**
1145 * lim_send_sme_deauth_ntf()
1146 *
1147 ***FUNCTION:
1148 * This function is called by limProcessSmeMessages() to send
1149 * eWNI_SME_DISASSOC_RSP/IND message to host
1150 *
1151 ***PARAMS:
1152 *
1153 ***LOGIC:
1154 *
1155 ***ASSUMPTIONS:
1156 * NA
1157 *
1158 ***NOTE:
1159 * This function is used for sending eWNI_SME_DEAUTH_CNF or
1160 * eWNI_SME_DEAUTH_IND to host depending on deauthentication trigger.
1161 *
1162 * @param peerMacAddr Indicates the peer MAC addr to which
1163 * deauthentication was initiated
1164 * @param reasonCode Indicates the reason for Deauthetication
1165 * @param deauthTrigger Indicates the trigger for Deauthetication
1166 * @param aid Indicates the STAID. This parameter is present
1167 * only on AP.
1168 *
1169 * @return None
1170 */
1171void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001172lim_send_sme_deauth_ntf(struct mac_context *mac, tSirMacAddr peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001173 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1174 uint16_t aid, uint8_t smesessionId,
1175 uint16_t smetransactionId)
1176{
1177 uint8_t *pBuf;
Jeff Johnson15ae0c12019-02-04 12:55:07 -08001178 struct deauth_rsp *pSirSmeDeauthRsp;
Jeff Johnsonfec08712019-02-04 13:12:08 -08001179 struct deauth_ind *pSirSmeDeauthInd;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001180 struct pe_session *pe_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001181 uint8_t sessionId;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301182 uint32_t *pMsg = NULL;
1183 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001184
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001185 pe_session = pe_find_session_by_bssid(mac, peerMacAddr, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001186 switch (deauthTrigger) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001187 case eLIM_HOST_DEAUTH:
1188 /**
1189 * Deauthentication response to host triggered
1190 * deauthentication.
1191 */
Jeff Johnson15ae0c12019-02-04 12:55:07 -08001192 pSirSmeDeauthRsp = qdf_mem_malloc(sizeof(*pSirSmeDeauthRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001193 if (!pSirSmeDeauthRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001194 return;
Jeff Johnson15ae0c12019-02-04 12:55:07 -08001195 pe_debug("send eWNI_SME_DEAUTH_RSP with retCode: %d for "
1196 MAC_ADDRESS_STR,
1197 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001198 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
Jeff Johnson15ae0c12019-02-04 12:55:07 -08001199 pSirSmeDeauthRsp->length = sizeof(*pSirSmeDeauthRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001200 pSirSmeDeauthRsp->statusCode = reasonCode;
1201 pSirSmeDeauthRsp->sessionId = smesessionId;
1202 pSirSmeDeauthRsp->transactionId = smetransactionId;
1203
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -08001204 pBuf = (uint8_t *) pSirSmeDeauthRsp->peer_macaddr.bytes;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301205 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001206
1207#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -08001208 lim_diag_event_report(mac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001209 pe_session, 0, (uint16_t) reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001210#endif
1211 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1212
1213 break;
1214
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301215 case eLIM_PEER_ENTITY_DEAUTH:
1216 case eLIM_LINK_MONITORING_DEAUTH:
Jeff Johnson35c58a82018-11-22 15:04:57 -08001217 status = lim_prepare_disconnect_done_ind(mac, &pMsg,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301218 smesessionId, reasonCode,
1219 &peerMacAddr[0]);
1220 if (!QDF_IS_STATUS_SUCCESS(status)) {
1221 pe_err("Failed to prepare message");
1222 return;
1223 }
1224 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001225 default:
1226 /**
1227 * Deauthentication indication due to Deauthentication
1228 * frame reception from peer entity or due to
1229 * loss of link with peer entity.
1230 */
Jeff Johnsonfec08712019-02-04 13:12:08 -08001231 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(*pSirSmeDeauthInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001232 if (!pSirSmeDeauthInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001233 return;
Jeff Johnsonfec08712019-02-04 13:12:08 -08001234 pe_debug("send eWNI_SME_DEAUTH_IND with retCode: %d for "
1235 MAC_ADDRESS_STR,
1236 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001237 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
Jeff Johnsonfec08712019-02-04 13:12:08 -08001238 pSirSmeDeauthInd->length = sizeof(*pSirSmeDeauthInd);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001239 pSirSmeDeauthInd->reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
1240
1241 /* sessionId */
1242 pBuf = (uint8_t *) &pSirSmeDeauthInd->sessionId;
1243 *pBuf++ = smesessionId;
1244
1245 /* transaction ID */
1246 lim_copy_u16(pBuf, smetransactionId);
1247 pBuf += sizeof(uint16_t);
1248
1249 /* status code */
1250 lim_copy_u32(pBuf, reasonCode);
1251 pBuf += sizeof(tSirResultCodes);
1252
1253 /* bssId */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001254 qdf_mem_copy(pBuf, pe_session->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001255 pBuf += sizeof(tSirMacAddr);
1256
1257 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301258 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301259 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001260
1261#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -08001262 lim_diag_event_report(mac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001263 pe_session, 0, (uint16_t) reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001264#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1265 pMsg = (uint32_t *) pSirSmeDeauthInd;
1266
1267 break;
1268 }
1269
1270 /*Delete the PE session created */
Bala Venkatesh03b4f0c2019-01-28 22:00:50 +05301271 if (pe_session && LIM_IS_STA_ROLE(pe_session))
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001272 pe_delete_session(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001273
Jeff Johnson35c58a82018-11-22 15:04:57 -08001274 lim_send_sme_disassoc_deauth_ntf(mac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001275 (uint32_t *) pMsg);
1276
1277} /*** end lim_send_sme_deauth_ntf() ***/
1278
1279/**
1280 * lim_send_sme_wm_status_change_ntf() - Send Notification
1281 * @mac_ctx: Global MAC Context
1282 * @status_change_code: Indicates the change in the wireless medium.
1283 * @status_change_info: Indicates the information associated with
1284 * change in the wireless medium.
1285 * @info_len: Indicates the length of status change information
1286 * being sent.
1287 * @session_id SessionID
1288 *
1289 * This function is called by limProcessSmeMessages() to send
1290 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1291 *
1292 * Return: None
1293 */
1294void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001295lim_send_sme_wm_status_change_ntf(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001296 tSirSmeStatusChangeCode status_change_code,
1297 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1298{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001299 struct scheduler_msg msg = {0};
Jeff Johnson53889322019-02-03 17:37:09 -08001300 struct wm_status_change_ntf *wm_status_change_ntf;
Naveen Rawate01ed172016-11-17 11:34:50 -08001301 uint32_t max_info_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001302
Jeff Johnson53889322019-02-03 17:37:09 -08001303 wm_status_change_ntf = qdf_mem_malloc(sizeof(*wm_status_change_ntf));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001304 if (!wm_status_change_ntf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001305 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001306
1307 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1308 msg.bodyval = 0;
1309 msg.bodyptr = wm_status_change_ntf;
1310
1311 switch (status_change_code) {
Naveen Rawate01ed172016-11-17 11:34:50 -08001312 case eSIR_SME_AP_CAPS_CHANGED:
Jeff Johnson9c9961c2019-02-03 17:10:53 -08001313 max_info_len = sizeof(struct ap_new_caps);
Naveen Rawate01ed172016-11-17 11:34:50 -08001314 break;
1315 case eSIR_SME_JOINED_NEW_BSS:
Jeff Johnson2e6d1732019-02-03 17:00:30 -08001316 max_info_len = sizeof(struct new_bss_info);
Naveen Rawate01ed172016-11-17 11:34:50 -08001317 break;
1318 default:
1319 max_info_len = sizeof(wm_status_change_ntf->statusChangeInfo);
1320 break;
1321 }
1322
1323 switch (status_change_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001324 case eSIR_SME_RADAR_DETECTED:
1325 break;
1326 default:
1327 wm_status_change_ntf->messageType =
1328 eWNI_SME_WM_STATUS_CHANGE_NTF;
1329 wm_status_change_ntf->statusChangeCode = status_change_code;
Jeff Johnson53889322019-02-03 17:37:09 -08001330 wm_status_change_ntf->length = sizeof(*wm_status_change_ntf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001331 wm_status_change_ntf->sessionId = session_id;
Naveen Rawate01ed172016-11-17 11:34:50 -08001332 if (info_len <= max_info_len && status_change_info) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301333 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001334 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1335 (uint8_t *) status_change_info, info_len);
1336 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301337 pe_debug("StatusChg code: 0x%x length: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001338 status_change_code, info_len);
1339 break;
1340 }
1341
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301342 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, session_id, msg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08001343 if (QDF_STATUS_SUCCESS != lim_sys_process_mmh_msg_api(mac_ctx, &msg)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301344 qdf_mem_free(wm_status_change_ntf);
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301345 pe_err("lim_sys_process_mmh_msg_api failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001346 }
1347
1348} /*** end lim_send_sme_wm_status_change_ntf() ***/
1349
1350/**
1351 * lim_send_sme_set_context_rsp()
1352 *
1353 ***FUNCTION:
1354 * This function is called by limProcessSmeMessages() to send
1355 * eWNI_SME_SETCONTEXT_RSP message to host
1356 *
1357 ***PARAMS:
1358 *
1359 ***LOGIC:
1360 *
1361 ***ASSUMPTIONS:
1362 * NA
1363 *
1364 ***NOTE:
1365 *
Jeff Johnson35c58a82018-11-22 15:04:57 -08001366 * @param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001367 * @param peerMacAddr Indicates the peer MAC addr to which
1368 * setContext was performed
1369 * @param aid Indicates the aid corresponding to the peer MAC
1370 * address
1371 * @param resultCode Indicates the result of previously issued
1372 * eWNI_SME_SETCONTEXT_RSP message
1373 *
1374 * @return None
1375 */
1376void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001377lim_send_sme_set_context_rsp(struct mac_context *mac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301378 struct qdf_mac_addr peer_macaddr, uint16_t aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001379 tSirResultCodes resultCode,
Jeff Johnson924ae612019-02-05 12:01:50 -08001380 struct pe_session *pe_session,
1381 uint8_t smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001382 uint16_t smetransactionId)
1383{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001384 struct scheduler_msg mmhMsg = {0};
Jeff Johnson924ae612019-02-05 12:01:50 -08001385 struct set_context_rsp *set_context_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001386
Jeff Johnson924ae612019-02-05 12:01:50 -08001387 set_context_rsp = qdf_mem_malloc(sizeof(*set_context_rsp));
1388 if (!set_context_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001389 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001390
Jeff Johnson924ae612019-02-05 12:01:50 -08001391 set_context_rsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1392 set_context_rsp->length = sizeof(*set_context_rsp);
1393 set_context_rsp->statusCode = resultCode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001394
Jeff Johnson924ae612019-02-05 12:01:50 -08001395 qdf_copy_macaddr(&set_context_rsp->peer_macaddr, &peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001396
1397 /* Update SME session and transaction Id */
Jeff Johnson924ae612019-02-05 12:01:50 -08001398 set_context_rsp->sessionId = smesessionId;
1399 set_context_rsp->transactionId = smetransactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001400
1401 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
Jeff Johnson924ae612019-02-05 12:01:50 -08001402 mmhMsg.bodyptr = set_context_rsp;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001403 mmhMsg.bodyval = 0;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001404 if (NULL == pe_session) {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001405 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301406 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001407 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001408 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001409 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001410 }
1411
1412#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -08001413 lim_diag_event_report(mac, WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001414 pe_session, (uint16_t) resultCode, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001415#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1416
Jeff Johnson35c58a82018-11-22 15:04:57 -08001417 mac->lim.sme_msg_callback(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001418} /*** end lim_send_sme_set_context_rsp() ***/
1419
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001420/** -----------------------------------------------------------------
1421 \brief lim_send_sme_addts_rsp() - sends SME ADDTS RSP
1422 \ This function sends a eWNI_SME_ADDTS_RSP to SME.
1423 \ SME only looks at rc and tspec field.
Jeff Johnson35c58a82018-11-22 15:04:57 -08001424 \param mac - global mac structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001425 \param rspReqd - is SmeAddTsRsp required
1426 \param status - status code of SME_ADD_TS_RSP
1427 \return tspec
1428 \sa
1429 ----------------------------------------------------------------- */
1430void
Jeff Johnson56471b92018-12-22 14:36:06 -08001431lim_send_sme_addts_rsp(struct mac_context *mac, uint8_t rspReqd,
1432 uint32_t status,
1433 struct pe_session *pe_session, struct mac_tspec_ie tspec,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001434 uint8_t smesessionId, uint16_t smetransactionId)
1435{
1436 tpSirAddtsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001437 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001438
1439 if (!rspReqd)
1440 return;
1441
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301442 rsp = qdf_mem_malloc(sizeof(tSirAddtsRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001443 if (!rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001444 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001445
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001446 rsp->messageType = eWNI_SME_ADDTS_RSP;
1447 rsp->rc = status;
1448 rsp->rsp.status = (enum eSirMacStatusCodes)status;
1449 rsp->rsp.tspec = tspec;
1450 /* Update SME session Id and transcation Id */
1451 rsp->sessionId = smesessionId;
1452 rsp->transactionId = smetransactionId;
1453
1454 mmhMsg.type = eWNI_SME_ADDTS_RSP;
1455 mmhMsg.bodyptr = rsp;
1456 mmhMsg.bodyval = 0;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001457 if (NULL == pe_session) {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001458 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301459 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001460 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001461 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001462 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001463 }
1464#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001465 lim_diag_event_report(mac, WLAN_PE_DIAG_ADDTS_RSP_EVENT, pe_session, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001466 0);
1467#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1468
Jeff Johnsona5abe272019-01-06 12:52:02 -08001469 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001470 return;
1471}
1472
1473void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001474lim_send_sme_delts_rsp(struct mac_context *mac, tpSirDeltsReq delts, uint32_t status,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001475 struct pe_session *pe_session, uint8_t smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001476 uint16_t smetransactionId)
1477{
1478 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001479 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001480
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301481 pe_debug("SendSmeDeltsRsp aid: %d tsid: %d up: %d status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001482 delts->aid,
1483 delts->req.tsinfo.traffic.tsid,
1484 delts->req.tsinfo.traffic.userPrio, status);
1485 if (!delts->rspReqd)
1486 return;
1487
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301488 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001489 if (!rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001490 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001491
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001492 if (pe_session != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001493
1494 rsp->aid = delts->aid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301495 qdf_copy_macaddr(&rsp->macaddr, &delts->macaddr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301496 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) &delts->req,
Jeff Johnsoncf2ec162018-12-22 16:46:43 -08001497 sizeof(struct delts_req_info));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001498 }
1499
1500 rsp->messageType = eWNI_SME_DELTS_RSP;
1501 rsp->rc = status;
1502
1503 /* Update SME session Id and transcation Id */
1504 rsp->sessionId = smesessionId;
1505 rsp->transactionId = smetransactionId;
1506
1507 mmhMsg.type = eWNI_SME_DELTS_RSP;
1508 mmhMsg.bodyptr = rsp;
1509 mmhMsg.bodyval = 0;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001510 if (NULL == pe_session) {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001511 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301512 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001513 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001514 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001515 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001516 }
1517#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001518 lim_diag_event_report(mac, WLAN_PE_DIAG_DELTS_RSP_EVENT, pe_session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001519 (uint16_t) status, 0);
1520#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1521
Jeff Johnsona5abe272019-01-06 12:52:02 -08001522 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001523}
1524
1525void
Jeff Johnsoncf2ec162018-12-22 16:46:43 -08001526lim_send_sme_delts_ind(struct mac_context *mac, struct delts_req_info *delts,
1527 uint16_t aid, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001528{
1529 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001530 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001531
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301532 pe_debug("SendSmeDeltsInd aid: %d tsid: %d up: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001533 aid, delts->tsinfo.traffic.tsid, delts->tsinfo.traffic.userPrio);
1534
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301535 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001536 if (!rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001537 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001538
1539 rsp->messageType = eWNI_SME_DELTS_IND;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001540 rsp->rc = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001541 rsp->aid = aid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301542 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) delts, sizeof(*delts));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001543
1544 /* Update SME session Id and SME transaction Id */
1545
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001546 rsp->sessionId = pe_session->smeSessionId;
1547 rsp->transactionId = pe_session->transactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001548
1549 mmhMsg.type = eWNI_SME_DELTS_IND;
1550 mmhMsg.bodyptr = rsp;
1551 mmhMsg.bodyval = 0;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001552 MTRACE(mac_trace_msg_tx(mac, pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001553#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001554 lim_diag_event_report(mac, WLAN_PE_DIAG_DELTS_IND_EVENT, pe_session, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001555 0);
1556#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1557
Jeff Johnsona5abe272019-01-06 12:52:02 -08001558 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001559}
1560
Naveen Rawatfa2a1002018-05-17 16:06:37 -07001561#ifndef QCA_SUPPORT_CP_STATS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001562/**
1563 * lim_send_sme_pe_statistics_rsp()
1564 *
1565 ***FUNCTION:
1566 * This function is called to send 802.11 statistics response to HDD.
1567 * This function posts the result back to HDD. This is a response to
1568 * HDD's request for statistics.
1569 *
1570 ***PARAMS:
1571 *
1572 ***LOGIC:
1573 *
1574 ***ASSUMPTIONS:
1575 * NA
1576 *
1577 ***NOTE:
1578 * NA
1579 *
Jeff Johnson35c58a82018-11-22 15:04:57 -08001580 * @param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001581 * @param p80211Stats Statistics sent in response
1582 * @param resultCode TODO:
1583 *
1584 *
1585 * @return none
1586 */
1587
1588void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001589lim_send_sme_pe_statistics_rsp(struct mac_context *mac, uint16_t msgType, void *stats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001590{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001591 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001592 uint8_t sessionId;
1593 tAniGetPEStatsRsp *pPeStats = (tAniGetPEStatsRsp *) stats;
Jeff Johnsond7035a32018-11-18 22:03:13 -08001594 struct pe_session *pPeSessionEntry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001595
1596 /* Get the Session Id based on Sta Id */
1597 pPeSessionEntry =
Jeff Johnson35c58a82018-11-22 15:04:57 -08001598 pe_find_session_by_sta_id(mac, pPeStats->staId, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001599
1600 /* Fill the Session Id */
1601 if (NULL != pPeSessionEntry) {
1602 /* Fill the Session Id */
1603 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1604 }
1605
1606 pPeStats->msgType = eWNI_SME_GET_STATISTICS_RSP;
1607
1608 /* msgType should be WMA_GET_STATISTICS_RSP */
1609 mmhMsg.type = eWNI_SME_GET_STATISTICS_RSP;
1610
1611 mmhMsg.bodyptr = stats;
1612 mmhMsg.bodyval = 0;
Jeff Johnson35c58a82018-11-22 15:04:57 -08001613 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08001614 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001615
1616 return;
1617
1618} /*** end lim_send_sme_pe_statistics_rsp() ***/
Naveen Rawatfa2a1002018-05-17 16:06:37 -07001619#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001620
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001621#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001622/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001623 * lim_send_sme_pe_ese_tsm_rsp() - send tsm response
Jeff Johnson35c58a82018-11-22 15:04:57 -08001624 * @mac: Pointer to global mac structure
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001625 * @pStats: Pointer to TSM Stats
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001626 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001627 * This function is called to send tsm stats response to HDD.
1628 * This function posts the result back to HDD. This is a response to
1629 * HDD's request to get tsm stats.
1630 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001631 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001632 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001633void lim_send_sme_pe_ese_tsm_rsp(struct mac_context *mac,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001634 tAniGetTsmStatsRsp *pStats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001635{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001636 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001637 uint8_t sessionId;
1638 tAniGetTsmStatsRsp *pPeStats = (tAniGetTsmStatsRsp *) pStats;
Jeff Johnsond7035a32018-11-18 22:03:13 -08001639 struct pe_session *pPeSessionEntry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001640
1641 /* Get the Session Id based on Sta Id */
Abhinav Kumaraa8f2df2019-01-11 20:02:26 +05301642 pPeSessionEntry = pe_find_session_by_bssid(mac, pPeStats->bssid.bytes,
1643 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001644 /* Fill the Session Id */
1645 if (NULL != pPeSessionEntry) {
1646 /* Fill the Session Id */
1647 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1648 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301649 pe_err("Session not found for the Sta id: %d",
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301650 pPeStats->staId);
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05301651 qdf_mem_free(pPeStats->tsmStatsReq);
1652 qdf_mem_free(pPeStats);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001653 return;
1654 }
1655
1656 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
1657 pPeStats->tsmMetrics.RoamingCount
1658 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
1659 pPeStats->tsmMetrics.RoamingDly
1660 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
1661
1662 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
1663 mmhMsg.bodyptr = pStats;
1664 mmhMsg.bodyval = 0;
Jeff Johnson35c58a82018-11-22 15:04:57 -08001665 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08001666 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001667
1668 return;
1669} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
1670
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001671#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001672
1673void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001674lim_send_sme_ibss_peer_ind(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001675 tSirMacAddr peerMacAddr,
1676 uint16_t staIndex,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001677 uint8_t *beacon,
1678 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
1679{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001680 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001681 tSmeIbssPeerInd *pNewPeerInd;
1682
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301683 pNewPeerInd = qdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
Arif Hussainf5b6c412018-10-10 19:41:09 -07001684 if (!pNewPeerInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001685 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001686
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301687 qdf_mem_copy((uint8_t *) pNewPeerInd->peer_addr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301688 peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001689 pNewPeerInd->staId = staIndex;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001690 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
1691 pNewPeerInd->mesgType = msgType;
1692 pNewPeerInd->sessionId = sessionId;
1693
1694 if (beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301695 qdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001696 sizeof(tSmeIbssPeerInd)), (void *)beacon,
1697 beaconLen);
1698 }
1699
1700 mmhMsg.type = msgType;
1701 mmhMsg.bodyptr = pNewPeerInd;
Jeff Johnson35c58a82018-11-22 15:04:57 -08001702 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08001703 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001704
1705}
1706
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07001707/**
1708 * lim_process_csa_wbw_ie() - Process CSA Wide BW IE
1709 * @mac_ctx: pointer to global adapter context
1710 * @csa_params: pointer to CSA parameters
1711 * @chnl_switch_info:pointer to channel switch parameters
1712 * @session_entry: session pointer
1713 *
1714 * Return: None
1715 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001716static QDF_STATUS lim_process_csa_wbw_ie(struct mac_context *mac_ctx,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001717 struct csa_offload_params *csa_params,
1718 tLimWiderBWChannelSwitchInfo *chnl_switch_info,
Jeff Johnsond7035a32018-11-18 22:03:13 -08001719 struct pe_session *session_entry)
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001720{
Amar Singhal5cccafe2017-02-15 12:42:58 -08001721 struct ch_params ch_params = {0};
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001722 uint8_t ap_new_ch_width;
1723 bool new_ch_width_dfn = false;
1724 uint8_t center_freq_diff;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001725 uint32_t fw_vht_ch_wd = wma_get_vht_ch_width() + 1;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001726
1727 ap_new_ch_width = csa_params->new_ch_width + 1;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001728
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001729 pe_debug("new channel: %d new_ch_width: %d seg0: %d seg1: %d",
1730 csa_params->channel, ap_new_ch_width,
1731 csa_params->new_ch_freq_seg1,
1732 csa_params->new_ch_freq_seg2);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001733
1734 if ((ap_new_ch_width != CH_WIDTH_80MHZ) &&
1735 (ap_new_ch_width != CH_WIDTH_160MHZ) &&
1736 (ap_new_ch_width != CH_WIDTH_80P80MHZ)) {
1737 pe_err("CSA wide BW IE has wrong ch_width %d",
1738 csa_params->new_ch_width);
1739 return QDF_STATUS_E_INVAL;
1740 }
1741
1742 if (!csa_params->new_ch_freq_seg1 && !csa_params->new_ch_freq_seg2) {
1743 pe_err("CSA wide BW IE has invalid center freq");
1744 return QDF_STATUS_E_INVAL;
1745 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001746 if ((ap_new_ch_width == CH_WIDTH_80MHZ) &&
1747 csa_params->new_ch_freq_seg2) {
1748 new_ch_width_dfn = true;
1749 if (csa_params->new_ch_freq_seg2 >
1750 csa_params->new_ch_freq_seg1)
1751 center_freq_diff = csa_params->new_ch_freq_seg2 -
1752 csa_params->new_ch_freq_seg1;
1753 else
1754 center_freq_diff = csa_params->new_ch_freq_seg1 -
1755 csa_params->new_ch_freq_seg2;
1756 if (center_freq_diff == CENTER_FREQ_DIFF_160MHz)
1757 ap_new_ch_width = CH_WIDTH_160MHZ;
1758 else if (center_freq_diff > CENTER_FREQ_DIFF_80P80MHz)
1759 ap_new_ch_width = CH_WIDTH_80P80MHZ;
1760 else
1761 ap_new_ch_width = CH_WIDTH_80MHZ;
1762 }
1763 session_entry->gLimChannelSwitch.state =
1764 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1765 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
1766 !new_ch_width_dfn) {
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001767 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1768 CH_TO_CNTR_FREQ_DIFF_160MHz) {
1769 pe_err("CSA wide BW IE has invalid center freq");
1770 return QDF_STATUS_E_INVAL;
1771 }
1772
1773 if (ap_new_ch_width > fw_vht_ch_wd) {
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001774 pe_debug("New BW is not supported, setting BW to %d",
1775 fw_vht_ch_wd);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001776 ap_new_ch_width = fw_vht_ch_wd;
1777 }
1778 ch_params.ch_width = ap_new_ch_width ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001779 wlan_reg_set_channel_params(mac_ctx->pdev,
1780 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001781 ap_new_ch_width = ch_params.ch_width;
1782 csa_params->new_ch_freq_seg1 = ch_params.center_freq_seg0;
1783 csa_params->new_ch_freq_seg2 = ch_params.center_freq_seg1;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001784 } else if (!new_ch_width_dfn) {
1785 if (ap_new_ch_width > fw_vht_ch_wd) {
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001786 pe_debug("New BW is not supported, setting BW to %d",
1787 fw_vht_ch_wd);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001788 ap_new_ch_width = fw_vht_ch_wd;
1789 }
1790 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1791 CH_TO_CNTR_FREQ_DIFF_80MHz) {
1792 pe_err("CSA wide BW IE has invalid center freq");
1793 return QDF_STATUS_E_INVAL;
1794 }
1795 csa_params->new_ch_freq_seg2 = 0;
1796 }
1797 if (new_ch_width_dfn) {
1798 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1799 CH_TO_CNTR_FREQ_DIFF_80MHz) {
1800 pe_err("CSA wide BW IE has invalid center freq");
1801 return QDF_STATUS_E_INVAL;
1802 }
1803 if (ap_new_ch_width > fw_vht_ch_wd) {
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001804 pe_debug("New width is not supported, setting BW to %d",
1805 fw_vht_ch_wd);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001806 ap_new_ch_width = fw_vht_ch_wd;
1807 }
1808 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
1809 (csa_params->new_ch_freq_seg1 !=
1810 csa_params->channel +
1811 CH_TO_CNTR_FREQ_DIFF_160MHz)) {
1812 pe_err("wide BW IE has invalid 160M center freq");
1813 csa_params->new_ch_freq_seg2 = 0;
1814 ap_new_ch_width = CH_WIDTH_80MHZ;
1815 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001816 }
1817 chnl_switch_info->newChanWidth = ap_new_ch_width;
1818 chnl_switch_info->newCenterChanFreq0 = csa_params->new_ch_freq_seg1;
1819 chnl_switch_info->newCenterChanFreq1 = csa_params->new_ch_freq_seg2;
1820
1821 if (session_entry->ch_width == ap_new_ch_width)
1822 goto prnt_log;
1823
1824 if (session_entry->ch_width == CH_WIDTH_80MHZ) {
1825 chnl_switch_info->newChanWidth = CH_WIDTH_80MHZ;
1826 chnl_switch_info->newCenterChanFreq1 = 0;
1827 } else {
1828 session_entry->ch_width = ap_new_ch_width;
1829 chnl_switch_info->newChanWidth = ap_new_ch_width;
1830 }
1831prnt_log:
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301832 pe_debug("new channel: %d new_ch_width: %d seg0: %d seg1: %d",
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001833 csa_params->channel,
1834 chnl_switch_info->newChanWidth,
1835 chnl_switch_info->newCenterChanFreq0,
1836 chnl_switch_info->newCenterChanFreq1);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001837
1838 return QDF_STATUS_SUCCESS;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001839}
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001840
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001841/**
1842 * lim_handle_csa_offload_msg() - Handle CSA offload message
1843 * @mac_ctx: pointer to global adapter context
1844 * @msg: Message pointer.
1845 *
1846 * Return: None
1847 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001848void lim_handle_csa_offload_msg(struct mac_context *mac_ctx,
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001849 struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001850{
Jeff Johnsond7035a32018-11-18 22:03:13 -08001851 struct pe_session *session_entry;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001852 struct scheduler_msg mmh_msg = {0};
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301853 struct csa_offload_params *csa_params =
1854 (struct csa_offload_params *) (msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001855 tpSmeCsaOffloadInd csa_offload_ind;
1856 tpDphHashNode sta_ds = NULL;
1857 uint8_t session_id;
1858 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05301859 uint16_t chan_space = 0;
Krunal Sonie2c45a92018-05-03 11:51:26 -07001860 struct ch_params ch_params = {0};
Gupta, Kapil121bf212015-11-25 19:21:29 +05301861
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001862 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08001863 tLimChannelSwitchInfo *lim_ch_switch = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001864
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301865 pe_debug("handle csa offload msg");
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301866
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001867 if (!csa_params) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301868 pe_err("limMsgQ body ptr is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001869 return;
1870 }
1871
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05301872 csa_offload_ind = qdf_mem_malloc(sizeof(tSmeCsaOffloadInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001873 if (!csa_offload_ind)
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05301874 goto err;
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05301875
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001876 session_entry =
1877 pe_find_session_by_bssid(mac_ctx,
1878 csa_params->bssId, &session_id);
1879 if (!session_entry) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301880 pe_err("Session does not exists for %pM",
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301881 csa_params->bssId);
Pragaspathi Thilagaraj655db192018-06-19 17:41:37 +05301882 qdf_mem_free(csa_offload_ind);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001883 goto err;
1884 }
1885
1886 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
1887 &session_entry->dph.dphHashTable);
1888
1889 if (!sta_ds) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301890 pe_err("sta_ds does not exist");
Pragaspathi Thilagaraj655db192018-06-19 17:41:37 +05301891 qdf_mem_free(csa_offload_ind);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001892 goto err;
1893 }
1894
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001895 if (!LIM_IS_STA_ROLE(session_entry)) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301896 pe_debug("Invalid role to handle CSA");
Pragaspathi Thilagaraj655db192018-06-19 17:41:37 +05301897 qdf_mem_free(csa_offload_ind);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001898 goto err;
1899 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001900 /*
1901 * on receiving channel switch announcement from AP, delete all
1902 * TDLS peers before leaving BSS and proceed for channel switch
1903 */
Bala Venkatesh33f270b2019-01-14 16:31:29 +05301904
1905 lim_update_tdls_set_state_for_fw(session_entry, false);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001906 lim_delete_tdls_peers(mac_ctx, session_entry);
Gupta, Kapil121bf212015-11-25 19:21:29 +05301907
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001908 lim_ch_switch = &session_entry->gLimChannelSwitch;
1909 session_entry->gLimChannelSwitch.switchMode =
1910 csa_params->switch_mode;
1911 /* timer already started by firmware, switch immediately */
1912 session_entry->gLimChannelSwitch.switchCount = 0;
1913 session_entry->gLimChannelSwitch.primaryChannel =
1914 csa_params->channel;
1915 session_entry->gLimChannelSwitch.state =
1916 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
1917 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
1918 lim_ch_switch->sec_ch_offset =
1919 session_entry->htSecondaryChannelOffset;
1920 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
1921 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
1922 chnl_switch_info =
1923 &session_entry->gLimWiderBWChannelSwitch;
1924
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001925 pe_debug("vht: %d ht: %d flag: %x chan: %d, sec_ch_offset %d",
1926 session_entry->vhtCapability,
1927 session_entry->htSupportedChannelWidthSet,
1928 csa_params->ies_present_flag,
1929 csa_params->channel,
1930 csa_params->sec_chan_offset);
1931 pe_debug("seg1: %d seg2: %d width: %d country: %s class: %d",
1932 csa_params->new_ch_freq_seg1,
1933 csa_params->new_ch_freq_seg2,
1934 csa_params->new_ch_width,
1935 mac_ctx->scan.countryCodeCurrent,
1936 csa_params->new_op_class);
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05301937
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001938 if (session_entry->vhtCapability &&
1939 session_entry->htSupportedChannelWidthSet) {
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001940 if ((csa_params->ies_present_flag & lim_wbw_ie_present) &&
1941 (QDF_STATUS_SUCCESS == lim_process_csa_wbw_ie(mac_ctx,
1942 csa_params, chnl_switch_info,
1943 session_entry))) {
1944 pe_debug("CSA wide BW IE process successful");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001945 lim_ch_switch->sec_ch_offset =
Abhishek Singhaf639b42017-06-16 14:14:36 +05301946 PHY_SINGLE_CHANNEL_CENTERED;
1947 if (chnl_switch_info->newChanWidth) {
1948 if (csa_params->channel <
1949 csa_params->new_ch_freq_seg1)
1950 lim_ch_switch->sec_ch_offset =
1951 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1952 else
1953 lim_ch_switch->sec_ch_offset =
1954 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1955 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001956 } else if (csa_params->ies_present_flag
1957 & lim_xcsa_ie_present) {
1958 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001959 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001960 mac_ctx->scan.countryCodeCurrent,
1961 csa_params->channel,
1962 csa_params->new_op_class);
1963 session_entry->gLimChannelSwitch.state =
1964 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1965
1966 if (chan_space == 80) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001967 chnl_switch_info->newChanWidth =
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001968 CH_WIDTH_80MHZ;
1969 } else if (chan_space == 40) {
1970 chnl_switch_info->newChanWidth =
1971 CH_WIDTH_40MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001972 } else {
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001973 chnl_switch_info->newChanWidth =
1974 CH_WIDTH_20MHZ;
1975 lim_ch_switch->state =
1976 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
1977 }
1978
1979 ch_params.ch_width =
1980 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001981 wlan_reg_set_channel_params(mac_ctx->pdev,
1982 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001983 chnl_switch_info->newCenterChanFreq0 =
1984 ch_params.center_freq_seg0;
1985 /*
1986 * This is not applicable for 20/40/80 MHz.
1987 * Only used when we support 80+80 MHz operation.
1988 * In case of 80+80 MHz, this parameter indicates
1989 * center channel frequency index of 80 MHz
1990 * channel offrequency segment 1.
1991 */
1992 chnl_switch_info->newCenterChanFreq1 =
1993 ch_params.center_freq_seg1;
1994 lim_ch_switch->sec_ch_offset =
1995 ch_params.sec_ch_offset;
1996
Kiran Kumar Lokere47127482017-12-20 18:09:55 -08001997 } else {
1998 lim_ch_switch->state =
1999 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2000 ch_params.ch_width = CH_WIDTH_40MHZ;
2001 wlan_reg_set_channel_params(mac_ctx->pdev,
2002 csa_params->channel, 0, &ch_params);
2003 lim_ch_switch->sec_ch_offset =
2004 ch_params.sec_ch_offset;
2005 chnl_switch_info->newChanWidth = CH_WIDTH_40MHZ;
2006 chnl_switch_info->newCenterChanFreq0 =
2007 ch_params.center_freq_seg0;
2008 chnl_switch_info->newCenterChanFreq1 = 0;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002009 }
2010 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
2011 chnl_switch_info->newCenterChanFreq0;
2012 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
2013 chnl_switch_info->newCenterChanFreq1;
2014 session_entry->gLimChannelSwitch.ch_width =
2015 chnl_switch_info->newChanWidth;
2016
2017 } else if (session_entry->htSupportedChannelWidthSet) {
2018 if (csa_params->ies_present_flag
2019 & lim_xcsa_ie_present) {
2020 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002021 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002022 mac_ctx->scan.countryCodeCurrent,
2023 csa_params->channel,
2024 csa_params->new_op_class);
2025 lim_ch_switch->state =
2026 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2027 if (chan_space == 40) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002028 lim_ch_switch->ch_width =
2029 CH_WIDTH_40MHZ;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002030 chnl_switch_info->newChanWidth =
2031 CH_WIDTH_40MHZ;
2032 ch_params.ch_width =
2033 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002034 wlan_reg_set_channel_params(mac_ctx->pdev,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002035 csa_params->channel,
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07002036 0, &ch_params);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002037 lim_ch_switch->ch_center_freq_seg0 =
2038 ch_params.center_freq_seg0;
2039 lim_ch_switch->sec_ch_offset =
2040 ch_params.sec_ch_offset;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002041 } else {
2042 lim_ch_switch->ch_width =
2043 CH_WIDTH_20MHZ;
2044 chnl_switch_info->newChanWidth =
2045 CH_WIDTH_40MHZ;
2046 lim_ch_switch->state =
2047 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2048 lim_ch_switch->sec_ch_offset =
2049 PHY_SINGLE_CHANNEL_CENTERED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002050 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002051 } else {
2052 lim_ch_switch->ch_width =
2053 CH_WIDTH_40MHZ;
2054 lim_ch_switch->state =
2055 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2056 ch_params.ch_width = CH_WIDTH_40MHZ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002057 wlan_reg_set_channel_params(mac_ctx->pdev,
2058 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002059 lim_ch_switch->ch_center_freq_seg0 =
2060 ch_params.center_freq_seg0;
2061 lim_ch_switch->sec_ch_offset =
2062 ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002063 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002064
2065 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302066 pe_debug("new ch width: %d space: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302067 session_entry->gLimChannelSwitch.ch_width, chan_space);
Kiran Kumar Lokere75d636f2016-12-20 14:52:03 -08002068 if ((session_entry->currentOperChannel == csa_params->channel) &&
2069 (session_entry->ch_width ==
2070 session_entry->gLimChannelSwitch.ch_width)) {
2071 pe_debug("Ignore CSA, no change in ch and bw");
Pragaspathi Thilagaraj655db192018-06-19 17:41:37 +05302072 qdf_mem_free(csa_offload_ind);
Kiran Kumar Lokere75d636f2016-12-20 14:52:03 -08002073 goto err;
2074 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002075
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05302076 if (WLAN_REG_IS_24GHZ_CH(csa_params->channel) &&
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +05302077 (session_entry->dot11mode == MLME_DOT11_MODE_11A))
2078 session_entry->dot11mode = MLME_DOT11_MODE_11G;
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05302079 else if (WLAN_REG_IS_5GHZ_CH(csa_params->channel) &&
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +05302080 ((session_entry->dot11mode == MLME_DOT11_MODE_11G) ||
2081 (session_entry->dot11mode == MLME_DOT11_MODE_11G_ONLY)))
2082 session_entry->dot11mode = MLME_DOT11_MODE_11A;
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05302083
Vignesh Viswanathan3d478032018-08-02 20:18:53 +05302084 /* Send RSO Stop to FW before triggering the vdev restart for CSA */
2085 if (mac_ctx->lim.stop_roaming_callback)
2086 mac_ctx->lim.stop_roaming_callback(mac_ctx,
2087 session_entry->smeSessionId,
2088 ecsr_driver_disabled);
2089
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002090 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002091
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002092 csa_offload_ind->mesgType = eWNI_SME_CSA_OFFLOAD_EVENT;
2093 csa_offload_ind->mesgLen = sizeof(tSmeCsaOffloadInd);
2094 qdf_mem_copy(csa_offload_ind->bssid.bytes, session_entry->bssId,
2095 QDF_MAC_ADDR_SIZE);
2096 mmh_msg.type = eWNI_SME_CSA_OFFLOAD_EVENT;
2097 mmh_msg.bodyptr = csa_offload_ind;
2098 mmh_msg.bodyval = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302099 pe_debug("Sending eWNI_SME_CSA_OFFLOAD_EVENT to SME");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002100 MTRACE(mac_trace_msg_tx
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002101 (mac_ctx, session_entry->peSessionId, mmh_msg.type));
2102#ifdef FEATURE_WLAN_DIAG_SUPPORT
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002103 lim_diag_event_report(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002104 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002105 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002106#endif
Jeff Johnsona5abe272019-01-06 12:52:02 -08002107 lim_sys_process_mmh_msg_api(mac_ctx, &mmh_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002108
2109err:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302110 qdf_mem_free(csa_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002111}
2112
2113/*--------------------------------------------------------------------------
2114 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
2115
Jeff Johnson35c58a82018-11-22 15:04:57 -08002116 \param mac - pointer to global adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002117 \param sessionId - Message pointer.
2118
2119 \sa
2120 --------------------------------------------------------------------------*/
2121
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002122void lim_handle_delete_bss_rsp(struct mac_context *mac, struct scheduler_msg *MsgQ)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002123{
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002124 struct pe_session *pe_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002125 tpDeleteBssParams pDelBss = (tpDeleteBssParams) (MsgQ->bodyptr);
2126
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002127 pe_session =
Jeff Johnson35c58a82018-11-22 15:04:57 -08002128 pe_find_session_by_session_id(mac, pDelBss->sessionId);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002129 if (pe_session == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302130 pe_err("Session Does not exist for given sessionID: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002131 pDelBss->sessionId);
Tushnim Bhattacharyya6368a262018-10-12 09:48:45 -07002132 qdf_mem_free(MsgQ->bodyptr);
2133 MsgQ->bodyptr = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002134 return;
2135 }
Krunal Sonie50ff452017-10-11 18:23:55 -07002136
2137 /*
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002138 * During DEL BSS handling, the PE Session will be deleted, but it is
2139 * better to clear this flag if the session is hanging around due
2140 * to some error conditions so that the next DEL_BSS request does
2141 * not take the HO_FAIL path
2142 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002143 pe_session->process_ho_fail = false;
2144 if (LIM_IS_IBSS_ROLE(pe_session))
2145 lim_ibss_del_bss_rsp(mac, MsgQ->bodyptr, pe_session);
2146 else if (LIM_IS_UNKNOWN_ROLE(pe_session))
2147 lim_process_sme_del_bss_rsp(mac, MsgQ->bodyval, pe_session);
2148 else if (LIM_IS_NDI_ROLE(pe_session))
2149 lim_ndi_del_bss_rsp(mac, MsgQ->bodyptr, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002150 else
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002151 lim_process_mlm_del_bss_rsp(mac, MsgQ, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002152
2153}
2154
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002155/** -----------------------------------------------------------------
2156 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
2157 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
2158 \ SME only looks at rc and tspec field.
Jeff Johnson35c58a82018-11-22 15:04:57 -08002159 \param mac - global mac structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002160 \param rspReqd - is SmeAddTsRsp required
2161 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
2162 \return tspec
2163 \sa
2164 ----------------------------------------------------------------- */
2165void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002166lim_send_sme_aggr_qos_rsp(struct mac_context *mac, tpSirAggrQosRsp aggrQosRsp,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002167 uint8_t smesessionId)
2168{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002169 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002170
2171 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
2172 mmhMsg.bodyptr = aggrQosRsp;
2173 mmhMsg.bodyval = 0;
Jeff Johnson35c58a82018-11-22 15:04:57 -08002174 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302175 smesessionId, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08002176 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002177
2178 return;
2179}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002180
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002181void lim_send_sme_max_assoc_exceeded_ntf(struct mac_context *mac, tSirMacAddr peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002182 uint8_t smesessionId)
2183{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002184 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002185 tSmeMaxAssocInd *pSmeMaxAssocInd;
2186
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302187 pSmeMaxAssocInd = qdf_mem_malloc(sizeof(tSmeMaxAssocInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002188 if (!pSmeMaxAssocInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002189 return;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302190 qdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peer_mac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302191 (uint8_t *) peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002192 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
2193 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
2194 pSmeMaxAssocInd->sessionId = smesessionId;
2195 mmhMsg.type = pSmeMaxAssocInd->mesgType;
2196 mmhMsg.bodyptr = pSmeMaxAssocInd;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302197 pe_debug("msgType: %s peerMacAddr "MAC_ADDRESS_STR "sme session id %d",
2198 "eWNI_SME_MAX_ASSOC_EXCEEDED", MAC_ADDR_ARRAY(peerMacAddr),
2199 pSmeMaxAssocInd->sessionId);
Jeff Johnson35c58a82018-11-22 15:04:57 -08002200 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302201 smesessionId, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08002202 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002203
2204 return;
2205}
2206
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002207/** -----------------------------------------------------------------
2208 \brief lim_send_sme_ap_channel_switch_resp() - sends
2209 eWNI_SME_CHANNEL_CHANGE_RSP
2210 After receiving WMA_SWITCH_CHANNEL_RSP indication this
2211 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
2212 that the Channel change has been done to the specified target
2213 channel in the Channel change request
Jeff Johnson35c58a82018-11-22 15:04:57 -08002214 \param mac - global mac structure
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002215 \param pe_session - session info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002216 \param pChnlParams - Channel switch params
2217 --------------------------------------------------------------------*/
2218void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002219lim_send_sme_ap_channel_switch_resp(struct mac_context *mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002220 struct pe_session *pe_session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002221 tpSwitchChannelParams pChnlParams)
2222{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002223 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002224 tpSwitchChannelParams pSmeSwithChnlParams;
2225 uint8_t channelId;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002226 bool is_ch_dfs = false;
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08002227 enum phy_ch_width ch_width;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002228 uint8_t ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002229
Arif Hussainf5b6c412018-10-10 19:41:09 -07002230 pSmeSwithChnlParams = qdf_mem_malloc(sizeof(tSwitchChannelParams));
2231 if (!pSmeSwithChnlParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002232 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002233
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302234 qdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002235 sizeof(tSwitchChannelParams));
2236
2237 channelId = pSmeSwithChnlParams->channelNumber;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002238 ch_width = pSmeSwithChnlParams->ch_width;
2239 ch_center_freq_seg1 = pSmeSwithChnlParams->ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002240
2241 /*
2242 * Pass the sme sessionID to SME instead
2243 * PE session ID.
2244 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002245 pSmeSwithChnlParams->peSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002246
2247 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
2248 mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
2249 mmhMsg.bodyval = 0;
Jeff Johnsona5abe272019-01-06 12:52:02 -08002250 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002251
2252 /*
2253 * We should start beacon transmission only if the new
2254 * channel after channel change is Non-DFS. For a DFS
2255 * channel, PE will receive an explicit request from
2256 * upper layers to start the beacon transmission .
2257 */
2258
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002259 if (ch_width == CH_WIDTH_160MHZ) {
2260 is_ch_dfs = true;
2261 } else if (ch_width == CH_WIDTH_80P80MHZ) {
Jeff Johnson35c58a82018-11-22 15:04:57 -08002262 if (wlan_reg_get_channel_state(mac->pdev, channelId) ==
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002263 CHANNEL_STATE_DFS ||
Jeff Johnson35c58a82018-11-22 15:04:57 -08002264 wlan_reg_get_channel_state(mac->pdev,
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002265 ch_center_freq_seg1 -
2266 SIR_80MHZ_START_CENTER_CH_DIFF) ==
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002267 CHANNEL_STATE_DFS)
2268 is_ch_dfs = true;
2269 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -08002270 if (wlan_reg_get_channel_state(mac->pdev, channelId) ==
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002271 CHANNEL_STATE_DFS)
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002272 is_ch_dfs = true;
2273 }
2274
2275 if (!is_ch_dfs) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002276 if (channelId == pe_session->currentOperChannel) {
2277 lim_apply_configuration(mac, pe_session);
2278 lim_send_beacon(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002279 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302280 pe_debug("Failed to Transmit Beacons on channel: %d after AP channel change response",
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002281 pe_session->bcnLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002282 }
Arif Hussain1513cb22018-01-05 19:56:31 -08002283
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002284 lim_obss_send_detection_cfg(mac, pe_session, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002285 }
2286 return;
2287}
2288
Peng Xu6363ec62017-05-15 11:06:33 -07002289#ifdef WLAN_FEATURE_11AX_BSS_COLOR
2290/**
2291 * lim_send_bss_color_change_ie_update() - update bss color change IE in
2292 * beacon template
2293 *
2294 * @mac_ctx: pointer to global adapter context
2295 * @session: session pointer
2296 *
2297 * Return: none
2298 */
2299static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002300lim_send_bss_color_change_ie_update(struct mac_context *mac_ctx,
Jeff Johnsond7035a32018-11-18 22:03:13 -08002301 struct pe_session *session)
Peng Xu6363ec62017-05-15 11:06:33 -07002302{
2303 /* Update the beacon template and send to FW */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002304 if (sch_set_fixed_beacon_fields(mac_ctx, session) != QDF_STATUS_SUCCESS) {
Peng Xu6363ec62017-05-15 11:06:33 -07002305 pe_err("Unable to set BSS color change IE in beacon");
Srinivas Girigowdaeff16d92018-09-12 14:56:29 -07002306 return;
Peng Xu6363ec62017-05-15 11:06:33 -07002307 }
2308
2309 /* Send update beacon template message */
Abhishek Singhfc740be2018-10-12 11:34:26 +05302310 lim_send_beacon_ind(mac_ctx, session, REASON_COLOR_CHANGE);
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07002311 pe_debug("Updated BSS color change countdown = %d",
2312 session->he_bss_color_change.countdown);
Peng Xu6363ec62017-05-15 11:06:33 -07002313}
2314
2315static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002316lim_handle_bss_color_change_ie(struct mac_context *mac_ctx,
Jeff Johnsond7035a32018-11-18 22:03:13 -08002317 struct pe_session *session)
Peng Xu6363ec62017-05-15 11:06:33 -07002318{
Arif Hussain2f2d3512018-03-06 12:37:03 -08002319 tUpdateBeaconParams beacon_params;
2320
Peng Xu6363ec62017-05-15 11:06:33 -07002321 /* handle bss color change IE */
2322 if (LIM_IS_AP_ROLE(session) &&
2323 session->he_op.bss_col_disabled) {
2324 if (session->he_bss_color_change.countdown > 0) {
2325 session->he_bss_color_change.countdown--;
2326 } else {
2327 session->bss_color_changing = 0;
Arif Hussain2f2d3512018-03-06 12:37:03 -08002328 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
Arif Hussain05fb4872018-01-03 16:02:55 -08002329 if (session->he_bss_color_change.new_color != 0) {
Peng Xu6363ec62017-05-15 11:06:33 -07002330 session->he_op.bss_col_disabled = 0;
Arif Hussain05fb4872018-01-03 16:02:55 -08002331 session->he_op.bss_color =
2332 session->he_bss_color_change.new_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08002333 beacon_params.paramChangeBitmap |=
2334 PARAM_BSS_COLOR_CHANGED;
2335 beacon_params.bss_color_disabled = 0;
2336 beacon_params.bss_color =
2337 session->he_op.bss_color;
2338 lim_send_beacon_params(mac_ctx,
2339 &beacon_params,
2340 session);
Arif Hussain05fb4872018-01-03 16:02:55 -08002341 lim_send_obss_color_collision_cfg(mac_ctx,
2342 session,
2343 OBSS_COLOR_COLLISION_DETECTION);
2344 }
Peng Xu6363ec62017-05-15 11:06:33 -07002345 }
2346
2347 lim_send_bss_color_change_ie_update(mac_ctx, session);
2348 }
2349}
2350
2351#else
2352static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002353lim_handle_bss_color_change_ie(struct mac_context *mac_ctx,
Jeff Johnsond7035a32018-11-18 22:03:13 -08002354 struct pe_session *session)
Peng Xu6363ec62017-05-15 11:06:33 -07002355{
2356}
2357#endif
2358
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002359void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002360lim_process_beacon_tx_success_ind(struct mac_context *mac_ctx, uint16_t msgType,
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302361 void *event)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002362{
Jeff Johnsond7035a32018-11-18 22:03:13 -08002363 struct pe_session *session;
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302364 tpSirFirstBeaconTxCompleteInd bcn_ind =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002365 (tSirFirstBeaconTxCompleteInd *) event;
2366
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302367 session = pe_find_session_by_bss_idx(mac_ctx, bcn_ind->bssIdx);
2368 if (!session) {
2369 pe_err("Session Does not exist for given session id");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002370 return;
2371 }
2372
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302373 pe_debug("role: %d swIe: %d opIe: %d switch cnt:%d",
2374 GET_LIM_SYSTEM_ROLE(session),
2375 session->dfsIncludeChanSwIe,
2376 session->gLimOperatingMode.present,
2377 session->gLimChannelSwitch.switchCount);
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302378
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302379 if (!LIM_IS_AP_ROLE(session))
2380 return;
Ganesh Kondabattini02ec62b2018-01-24 18:22:24 +05302381
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302382 if (session->dfsIncludeChanSwIe &&
2383 (session->gLimChannelSwitch.switchCount ==
2384 mac_ctx->sap.SapDfsInfo.sap_ch_switch_beacon_cnt))
2385 lim_process_ap_ecsa_timeout(session);
Ganesh Kondabattini02ec62b2018-01-24 18:22:24 +05302386
lifeng1c16b6b2017-09-25 13:59:55 +08002387
Abhishek Singhfc740be2018-10-12 11:34:26 +05302388 if (session->gLimOperatingMode.present)
2389 /* Done with nss update */
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302390 session->gLimOperatingMode.present = 0;
Peng Xu6363ec62017-05-15 11:06:33 -07002391
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302392 lim_handle_bss_color_change_ie(mac_ctx, session);
Peng Xu6363ec62017-05-15 11:06:33 -07002393
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002394 return;
2395}