blob: 1b8680fbafb7a31269cd82f2d6f0968e5eb51b96 [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"
37#include "cfg_api.h"
38
39#include "sch_api.h"
40#include "utils_api.h"
41#include "lim_utils.h"
42#include "lim_security_utils.h"
43#include "lim_ser_des_utils.h"
44#include "lim_send_sme_rsp_messages.h"
45#include "lim_ibss_peer_mgmt.h"
46#include "lim_session_utils.h"
47#include "lim_types.h"
48#include "sir_api.h"
Naveen Rawat3b6068c2016-04-14 19:01:06 -070049#include "cds_regdomain.h"
Gupta, Kapil121bf212015-11-25 19:21:29 +053050#include "lim_send_messages.h"
Deepak Dhamdhere13983f22016-05-31 19:06:09 -070051#include "nan_datapath.h"
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -070052#include "lim_assoc_utils.h"
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070053#include "wlan_reg_services_api.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070054#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080055
Kabilan Kannanf56f9d52017-04-05 03:31:34 -070056#include "wlan_tdls_tgt_api.h"
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +053057#include "lim_process_fils.h"
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -080058#include "wma.h"
Kabilan Kannanf56f9d52017-04-05 03:31:34 -070059
Jeff Johnson9320c1e2018-12-02 13:09:20 -080060static void lim_handle_join_rsp_status(struct mac_context *mac_ctx,
Jeff Johnsond7035a32018-11-18 22:03:13 -080061 struct pe_session *session_entry, tSirResultCodes result_code,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080062 tpSirSmeJoinRsp sme_join_rsp);
63
64/**
65 * lim_send_sme_rsp() - Send Response to upper layers
66 * @mac_ctx: Pointer to Global MAC structure
67 * @msg_type: Indicates message type
68 * @result_code: Indicates the result of previously issued
69 * eWNI_SME_msg_type_REQ message
70 *
71 * This function is called by lim_process_sme_req_messages() to send
72 * eWNI_SME_START_RSP, eWNI_SME_STOP_BSS_RSP
73 * or eWNI_SME_SWITCH_CHL_RSP messages to applications above MAC
74 * Software.
75 *
76 * Return: None
77 */
78
79void
Jeff Johnson9320c1e2018-12-02 13:09:20 -080080lim_send_sme_rsp(struct mac_context *mac_ctx, uint16_t msg_type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080081 tSirResultCodes result_code, uint8_t sme_session_id,
82 uint16_t sme_transaction_id)
83{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070084 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080085 tSirSmeRsp *sme_rsp;
86
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +053087 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080088 lim_msg_str(msg_type), lim_result_code_str(result_code));
89
Anurag Chouhan600c3a02016-03-01 10:33:54 +053090 sme_rsp = qdf_mem_malloc(sizeof(tSirSmeRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -070091 if (!sme_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080092 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080093
94 sme_rsp->messageType = msg_type;
95 sme_rsp->length = sizeof(tSirSmeRsp);
96 sme_rsp->statusCode = result_code;
97
98 sme_rsp->sessionId = sme_session_id;
99 sme_rsp->transactionId = sme_transaction_id;
100
101 msg.type = msg_type;
102 msg.bodyptr = sme_rsp;
103 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530104 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG,
105 sme_session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800106
107#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
108 switch (msg_type) {
109 case eWNI_SME_STOP_BSS_RSP:
110 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_STOP_BSS_RSP_EVENT,
111 NULL, (uint16_t) result_code, 0);
112 break;
113 }
114#endif /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsona5abe272019-01-06 12:52:02 -0800115 lim_sys_process_mmh_msg_api(mac_ctx, &msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800116}
117
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800118/**
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530119 * lim_get_max_rate_flags() - Get rate flags
120 * @mac_ctx: Pointer to global MAC structure
121 * @sta_ds: Pointer to station ds structure
122 *
123 * This function is called to get the rate flags for a connection
124 * from the station ds structure depending on the ht and the vht
125 * channel width supported.
126 *
127 * Return: Returns the populated rate_flags
128 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800129uint32_t lim_get_max_rate_flags(struct mac_context *mac_ctx, tpDphHashNode sta_ds)
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530130{
131 uint32_t rate_flags = 0;
132
133 if (sta_ds == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530134 pe_err("sta_ds is NULL");
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530135 return rate_flags;
136 }
137
138 if (!sta_ds->mlmStaContext.htCapability &&
139 !sta_ds->mlmStaContext.vhtCapability) {
Naveen Rawatea1564b2018-05-17 15:56:11 -0700140 rate_flags |= TX_RATE_LEGACY;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530141 } else {
142 if (sta_ds->mlmStaContext.vhtCapability) {
143 if (WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ ==
144 sta_ds->vhtSupportedChannelWidthSet) {
Naveen Rawatea1564b2018-05-17 15:56:11 -0700145 rate_flags |= TX_RATE_VHT80;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530146 } else if (WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ ==
147 sta_ds->vhtSupportedChannelWidthSet) {
148 if (sta_ds->htSupportedChannelWidthSet)
Naveen Rawatea1564b2018-05-17 15:56:11 -0700149 rate_flags |= TX_RATE_VHT40;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530150 else
Naveen Rawatea1564b2018-05-17 15:56:11 -0700151 rate_flags |= TX_RATE_VHT20;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530152 }
153 } else if (sta_ds->mlmStaContext.htCapability) {
154 if (sta_ds->htSupportedChannelWidthSet)
Naveen Rawatea1564b2018-05-17 15:56:11 -0700155 rate_flags |= TX_RATE_HT40;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530156 else
Naveen Rawatea1564b2018-05-17 15:56:11 -0700157 rate_flags |= TX_RATE_HT20;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530158 }
159 }
160
161 if (sta_ds->htShortGI20Mhz || sta_ds->htShortGI40Mhz)
Naveen Rawatea1564b2018-05-17 15:56:11 -0700162 rate_flags |= TX_RATE_SGI;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530163
164 return rate_flags;
165}
166
167/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800168 * lim_send_sme_join_reassoc_rsp_after_resume() - Send Response to SME
169 * @mac_ctx Pointer to Global MAC structure
170 * @status Resume link status
171 * @ctx context passed while calling resmune link.
172 * (join response to be sent)
173 *
174 * This function is called to send Join/Reassoc rsp
175 * message to SME after the resume link.
176 *
177 * Return: None
178 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800179static void lim_send_sme_join_reassoc_rsp_after_resume(struct mac_context *mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530180 QDF_STATUS status, uint32_t *ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800181{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700182 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800183 tpSirSmeJoinRsp sme_join_rsp = (tpSirSmeJoinRsp) ctx;
184
185 msg.type = sme_join_rsp->messageType;
186 msg.bodyptr = sme_join_rsp;
187 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530188 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, NO_SESSION, msg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -0800189 lim_sys_process_mmh_msg_api(mac_ctx, &msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800190}
191
192/**
193 * lim_handle_join_rsp_status() - Handle the response.
194 * @mac_ctx: Pointer to Global MAC structure
195 * @session_entry: PE Session Info
196 * @result_code: Indicates the result of previously issued
197 * eWNI_SME_msgType_REQ message
198 * @sme_join_rsp The received response.
199 *
200 * This function will handle both the success and failure status
201 * of the received response.
202 *
203 * Return: None
204 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800205static void lim_handle_join_rsp_status(struct mac_context *mac_ctx,
Jeff Johnsond7035a32018-11-18 22:03:13 -0800206 struct pe_session *session_entry, tSirResultCodes result_code,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800207 tpSirSmeJoinRsp sme_join_rsp)
208{
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700209 uint16_t bss_ie_len;
210 void *bss_ies;
211 bool is_vendor_ap_1_present;
Wu Gao2968fc92017-06-19 19:18:34 +0800212 tpSirSmeJoinReq join_reassoc_req = NULL;
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700213
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800214#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
215 tSirSmeHTProfile *ht_profile;
216#endif
217 if (result_code == eSIR_SME_SUCCESS) {
218 if (session_entry->beacon != NULL) {
219 sme_join_rsp->beaconLength = session_entry->bcnLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530220 qdf_mem_copy(sme_join_rsp->frames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800221 session_entry->beacon,
222 sme_join_rsp->beaconLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530223 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800224 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530225 session_entry->bcnLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530226 pe_debug("Beacon: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530227 sme_join_rsp->beaconLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800228 }
229 if (session_entry->assocReq != NULL) {
230 sme_join_rsp->assocReqLength =
231 session_entry->assocReqLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530232 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530233 sme_join_rsp->beaconLength,
234 session_entry->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800235 sme_join_rsp->assocReqLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530236 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800237 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530238 session_entry->assocReqLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530239 pe_debug("AssocReq: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530240 sme_join_rsp->assocReqLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800241 }
242 if (session_entry->assocRsp != NULL) {
243 sme_join_rsp->assocRspLength =
244 session_entry->assocRspLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530245 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530246 sme_join_rsp->beaconLength +
247 sme_join_rsp->assocReqLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800248 session_entry->assocRsp,
249 sme_join_rsp->assocRspLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530250 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800251 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530252 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800253 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800254 if (session_entry->ricData != NULL) {
255 sme_join_rsp->parsedRicRspLen =
256 session_entry->RICDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530257 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530258 sme_join_rsp->beaconLength +
259 sme_join_rsp->assocReqLength +
260 sme_join_rsp->assocRspLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800261 session_entry->ricData,
262 sme_join_rsp->parsedRicRspLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530263 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800264 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530265 session_entry->RICDataLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530266 pe_debug("RicLength: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800267 sme_join_rsp->parsedRicRspLen);
268 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800269#ifdef FEATURE_WLAN_ESE
270 if (session_entry->tspecIes != NULL) {
271 sme_join_rsp->tspecIeLen =
272 session_entry->tspecLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530273 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530274 sme_join_rsp->beaconLength +
275 sme_join_rsp->assocReqLength +
276 sme_join_rsp->assocRspLength +
277 sme_join_rsp->parsedRicRspLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800278 session_entry->tspecIes,
279 sme_join_rsp->tspecIeLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530280 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800281 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530282 session_entry->tspecLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530283 pe_debug("ESE-TspecLen: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530284 sme_join_rsp->tspecIeLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800285 }
286#endif
287 sme_join_rsp->aid = session_entry->limAID;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530288 pe_debug("AssocRsp: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530289 sme_join_rsp->assocRspLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800290 sme_join_rsp->vht_channel_width =
291 session_entry->ch_width;
292#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
293 if (session_entry->cc_switch_mode !=
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530294 QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800295 ht_profile = &sme_join_rsp->HTProfile;
296 ht_profile->htSupportedChannelWidthSet =
297 session_entry->htSupportedChannelWidthSet;
298 ht_profile->htRecommendedTxWidthSet =
299 session_entry->htRecommendedTxWidthSet;
300 ht_profile->htSecondaryChannelOffset =
301 session_entry->htSecondaryChannelOffset;
302 ht_profile->dot11mode = session_entry->dot11mode;
303 ht_profile->htCapability = session_entry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800304 ht_profile->vhtCapability =
305 session_entry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800306 ht_profile->apCenterChan = session_entry->ch_center_freq_seg0;
307 ht_profile->apChanWidth = session_entry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800308 }
309#endif
Jeff Johnson11bd4f32017-09-18 08:15:17 -0700310 pe_debug("pLimJoinReq:%pK, pLimReAssocReq:%pK",
Wu Gao2968fc92017-06-19 19:18:34 +0800311 session_entry->pLimJoinReq,
312 session_entry->pLimReAssocReq);
313
314 if (session_entry->pLimJoinReq)
315 join_reassoc_req = session_entry->pLimJoinReq;
316
317 if (session_entry->pLimReAssocReq)
318 join_reassoc_req = session_entry->pLimReAssocReq;
319
320 if (!join_reassoc_req) {
321 pe_err("both pLimJoinReq and pLimReAssocReq NULL");
322 return;
323 }
324
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700325 bss_ie_len = lim_get_ielen_from_bss_description(
Wu Gao2968fc92017-06-19 19:18:34 +0800326 &join_reassoc_req->bssDescription);
327 bss_ies = &join_reassoc_req->bssDescription.ieFields;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700328 is_vendor_ap_1_present = (wlan_get_vendor_ie_ptr_from_oui(
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700329 SIR_MAC_VENDOR_AP_1_OUI, SIR_MAC_VENDOR_AP_1_OUI_LEN,
330 bss_ies, bss_ie_len) != NULL);
331
332 if (mac_ctx->roam.configParam.is_force_1x1 &&
Krunal Sonie6a1cda2017-09-27 15:23:02 -0700333 is_vendor_ap_1_present && (session_entry->nss == 2) &&
334 (mac_ctx->lteCoexAntShare == 0 ||
335 IS_5G_CH(session_entry->currentOperChannel))) {
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700336 /* SET vdev param */
337 pe_debug("sending SMPS intolrent vdev_param");
338 wma_cli_set_command(session_entry->smeSessionId,
339 (int)WMI_VDEV_PARAM_SMPS_INTOLERANT,
340 1, VDEV_CMD);
341
342 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800343 } else {
344 if (session_entry->beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530345 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800346 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530347 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800348 }
349 if (session_entry->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530350 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800351 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530352 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800353 }
354 if (session_entry->assocRsp != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530355 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800356 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530357 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800358 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800359 if (session_entry->ricData != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530360 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800361 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530362 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800363 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800364#ifdef FEATURE_WLAN_ESE
365 if (session_entry->tspecIes != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530366 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800367 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530368 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800369 }
370#endif
371 }
372}
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530373
374/**
375 * lim_add_bss_info() - copy data from session entry to join rsp
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530376 * @sta_ds: Station dph entry
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530377 * @sme_join_rsp: Join response buffer to be filled up
378 *
379 * Return: None
380 */
Jeff Johnson6db011e2016-10-07 07:31:39 -0700381static void lim_add_bss_info(tpDphHashNode sta_ds, tpSirSmeJoinRsp sme_join_rsp)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530382{
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530383 struct parsed_ies *parsed_ies = &sta_ds->parsed_ies;
384
385 if (parsed_ies->hs20vendor_ie.present)
386 sme_join_rsp->hs20vendor_ie = parsed_ies->hs20vendor_ie;
387 if (parsed_ies->vht_caps.present)
388 sme_join_rsp->vht_caps = parsed_ies->vht_caps;
389 if (parsed_ies->ht_caps.present)
390 sme_join_rsp->ht_caps = parsed_ies->ht_caps;
391 if (parsed_ies->ht_operation.present)
392 sme_join_rsp->ht_operation = parsed_ies->ht_operation;
393 if (parsed_ies->vht_operation.present)
394 sme_join_rsp->vht_operation = parsed_ies->vht_operation;
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530395}
396
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530397#ifdef WLAN_FEATURE_FILS_SK
398static void lim_update_fils_seq_num(tpSirSmeJoinRsp sme_join_rsp,
Jeff Johnsond7035a32018-11-18 22:03:13 -0800399 struct pe_session *session_entry)
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530400{
401 sme_join_rsp->fils_seq_num =
402 session_entry->fils_info->sequence_number;
403}
404#else
405static inline void lim_update_fils_seq_num(tpSirSmeJoinRsp sme_join_rsp,
Jeff Johnsond7035a32018-11-18 22:03:13 -0800406 struct pe_session *session_entry)
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530407{}
408#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800409/**
410 * lim_send_sme_join_reassoc_rsp() - Send Response to Upper Layers
411 * @mac_ctx: Pointer to Global MAC structure
412 * @msg_type: Indicates message type
413 * @result_code: Indicates the result of previously issued
414 * eWNI_SME_msgType_REQ message
415 * @prot_status_code: Protocol Status Code
416 * @session_entry: PE Session Info
417 * @sme_session_id: SME Session ID
418 * @sme_transaction_id: SME Transaction ID
419 *
420 * This function is called by lim_process_sme_req_messages() to send
421 * eWNI_SME_JOIN_RSP or eWNI_SME_REASSOC_RSP messages to applications
422 * above MAC Software.
423 *
424 * Return: None
425 */
426
427void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800428lim_send_sme_join_reassoc_rsp(struct mac_context *mac_ctx, uint16_t msg_type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800429 tSirResultCodes result_code, uint16_t prot_status_code,
Jeff Johnsond7035a32018-11-18 22:03:13 -0800430 struct pe_session *session_entry, uint8_t sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800431 uint16_t sme_transaction_id)
432{
433 tpSirSmeJoinRsp sme_join_rsp;
434 uint32_t rsp_len;
435 tpDphHashNode sta_ds = NULL;
436#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
437 if (msg_type == eWNI_SME_REASSOC_RSP)
438 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_RSP_EVENT,
439 session_entry, (uint16_t) result_code, 0);
440 else
441 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_RSP_EVENT,
442 session_entry, (uint16_t) result_code, 0);
443#endif /* FEATURE_WLAN_DIAG_SUPPORT */
444
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530445 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800446 lim_msg_str(msg_type), lim_result_code_str(result_code));
447
448 if (session_entry == NULL) {
449 rsp_len = sizeof(tSirSmeJoinRsp);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530450 sme_join_rsp = qdf_mem_malloc(rsp_len);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700451 if (!sme_join_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800452 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800453
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800454 sme_join_rsp->beaconLength = 0;
455 sme_join_rsp->assocReqLength = 0;
456 sme_join_rsp->assocRspLength = 0;
457 } else {
458 rsp_len = session_entry->assocReqLen +
459 session_entry->assocRspLen + session_entry->bcnLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800460 session_entry->RICDataLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800461#ifdef FEATURE_WLAN_ESE
462 session_entry->tspecLen +
463#endif
464 sizeof(tSirSmeJoinRsp) - sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530465 sme_join_rsp = qdf_mem_malloc(rsp_len);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700466 if (!sme_join_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800467 return;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530468
469 if (lim_is_fils_connection(session_entry)) {
470 sme_join_rsp->is_fils_connection = true;
471 lim_update_fils_seq_num(sme_join_rsp,
472 session_entry);
473 }
474
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800475 if (result_code == eSIR_SME_SUCCESS) {
476 sta_ds = dph_get_hash_entry(mac_ctx,
477 DPH_STA_HASH_INDEX_PEER,
478 &session_entry->dph.dphHashTable);
479 if (sta_ds == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530480 pe_err("Get Self Sta Entry fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800481 } else {
482 /* Pass the peer's staId */
483 sme_join_rsp->staId = sta_ds->staIndex;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800484 sme_join_rsp->timingMeasCap =
485 sta_ds->timingMeasCap;
486#ifdef FEATURE_WLAN_TDLS
487 sme_join_rsp->tdls_prohibited =
488 session_entry->tdls_prohibited;
489 sme_join_rsp->tdls_chan_swit_prohibited =
490 session_entry->tdls_chan_swit_prohibited;
491#endif
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530492 sme_join_rsp->nss = sta_ds->nss;
493 sme_join_rsp->max_rate_flags =
494 lim_get_max_rate_flags(mac_ctx, sta_ds);
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530495 lim_add_bss_info(sta_ds, sme_join_rsp);
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530496
497 /* Copy FILS params only for Successful join */
498 populate_fils_connect_params(mac_ctx,
499 session_entry, sme_join_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800500 }
501 }
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530502
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800503 sme_join_rsp->beaconLength = 0;
504 sme_join_rsp->assocReqLength = 0;
505 sme_join_rsp->assocRspLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800506 sme_join_rsp->parsedRicRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800507#ifdef FEATURE_WLAN_ESE
508 sme_join_rsp->tspecIeLen = 0;
509#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800510 lim_handle_join_rsp_status(mac_ctx, session_entry, result_code,
511 sme_join_rsp);
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800512
513 /* Send supported NSS 1x1 to SME */
514 sme_join_rsp->supported_nss_1x1 =
515 session_entry->supported_nss_1x1;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530516 pe_debug("SME Join Rsp is supported NSS 1X1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800517 sme_join_rsp->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800518 }
519
520 sme_join_rsp->messageType = msg_type;
521 sme_join_rsp->length = (uint16_t) rsp_len;
522 sme_join_rsp->statusCode = result_code;
523 sme_join_rsp->protStatusCode = prot_status_code;
524
525 sme_join_rsp->sessionId = sme_session_id;
526 sme_join_rsp->transactionId = sme_transaction_id;
527
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530528 lim_send_sme_join_reassoc_rsp_after_resume(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800529 (uint32_t *)sme_join_rsp);
530}
531
532/**
533 * lim_send_sme_start_bss_rsp()
534 *
535 ***FUNCTION:
536 * This function is called to send eWNI_SME_START_BSS_RSP
537 * message to applications above MAC Software.
538 *
539 ***PARAMS:
540 *
541 ***LOGIC:
542 *
543 ***ASSUMPTIONS:
544 * NA
545 *
546 ***NOTE:
547 * NA
548 *
Jeff Johnson35c58a82018-11-22 15:04:57 -0800549 * @param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800550 * @param msgType Indicates message type
551 * @param resultCode Indicates the result of previously issued
552 * eWNI_SME_msgType_REQ message
553 *
554 * @return None
555 */
556
557void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800558lim_send_sme_start_bss_rsp(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800559 uint16_t msgType, tSirResultCodes resultCode,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800560 struct pe_session *pe_session, uint8_t smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800561 uint16_t smetransactionId)
562{
563
564 uint16_t size = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700565 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800566 tSirSmeStartBssRsp *pSirSmeRsp;
567 uint16_t ieLen;
568 uint16_t ieOffset, curLen;
569
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530570 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800571 lim_msg_str(msgType), lim_result_code_str(resultCode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800572
573 size = sizeof(tSirSmeStartBssRsp);
574
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800575 if (pe_session == NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530576 pSirSmeRsp = qdf_mem_malloc(size);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700577 if (!pSirSmeRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800578 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800579 } else {
580 /* subtract size of beaconLength + Mac Hdr + Fixed Fields before SSID */
581 ieOffset = sizeof(tAniBeaconStruct) + SIR_MAC_B_PR_SSID_OFFSET;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800582 ieLen = pe_session->schBeaconOffsetBegin
583 + pe_session->schBeaconOffsetEnd - ieOffset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800584 /* calculate the memory size to allocate */
585 size += ieLen;
586
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530587 pSirSmeRsp = qdf_mem_malloc(size);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700588 if (!pSirSmeRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800589 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800590 size = sizeof(tSirSmeStartBssRsp);
591 if (resultCode == eSIR_SME_SUCCESS) {
592
593 sir_copy_mac_addr(pSirSmeRsp->bssDescription.bssId,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800594 pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800595
596 /* Read beacon interval from session */
597 pSirSmeRsp->bssDescription.beaconInterval =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800598 (uint16_t) pe_session->beaconParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800599 beaconInterval;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800600 pSirSmeRsp->bssType = pe_session->bssType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800601
602 if (cfg_get_capability_info
Jeff Johnson35c58a82018-11-22 15:04:57 -0800603 (mac, &pSirSmeRsp->bssDescription.capabilityInfo,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800604 pe_session)
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700605 != QDF_STATUS_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530606 pe_err("could not retrieve Capabilities value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800607
Jeff Johnson35c58a82018-11-22 15:04:57 -0800608 lim_get_phy_mode(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800609 (uint32_t *) &pSirSmeRsp->bssDescription.
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800610 nwType, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800611
612 pSirSmeRsp->bssDescription.channelId =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800613 pe_session->currentOperChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800614
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800615 if (!LIM_IS_NDI_ROLE(pe_session)) {
616 curLen = pe_session->schBeaconOffsetBegin - ieOffset;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530617 qdf_mem_copy((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800618 ieFields,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800619 pe_session->pSchBeaconFrameBegin +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800620 ieOffset, (uint32_t) curLen);
621
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530622 qdf_mem_copy(((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800623 ieFields) + curLen,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800624 pe_session->pSchBeaconFrameEnd,
625 (uint32_t) pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800626 schBeaconOffsetEnd);
627
Abhishek Singh34a4d862016-10-26 16:01:51 +0530628 pSirSmeRsp->bssDescription.length = (uint16_t)
629 (offsetof(tSirBssDescription, ieFields[0])
630 - sizeof(pSirSmeRsp->bssDescription.length)
631 + ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800632 /* This is the size of the message, subtracting the size of the pointer to ieFields */
633 size += ieLen - sizeof(uint32_t);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700634 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800635#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800636 if (pe_session->cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530637 != QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800638 pSirSmeRsp->HTProfile.
639 htSupportedChannelWidthSet =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800640 pe_session->htSupportedChannelWidthSet;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800641 pSirSmeRsp->HTProfile.htRecommendedTxWidthSet =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800642 pe_session->htRecommendedTxWidthSet;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800643 pSirSmeRsp->HTProfile.htSecondaryChannelOffset =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800644 pe_session->htSecondaryChannelOffset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800645 pSirSmeRsp->HTProfile.dot11mode =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800646 pe_session->dot11mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800647 pSirSmeRsp->HTProfile.htCapability =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800648 pe_session->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800649 pSirSmeRsp->HTProfile.vhtCapability =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800650 pe_session->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800651 pSirSmeRsp->HTProfile.apCenterChan =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800652 pe_session->ch_center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800653 pSirSmeRsp->HTProfile.apChanWidth =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800654 pe_session->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800655 }
656#endif
657 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800658 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800659 pSirSmeRsp->messageType = msgType;
660 pSirSmeRsp->length = size;
661
662 /* Update SME session Id and transaction Id */
663 pSirSmeRsp->sessionId = smesessionId;
664 pSirSmeRsp->transactionId = smetransactionId;
665 pSirSmeRsp->statusCode = resultCode;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800666 if (pe_session != NULL)
667 pSirSmeRsp->staId = pe_session->staId; /* else it will be always zero smeRsp StaID = 0 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800668
669 mmhMsg.type = msgType;
670 mmhMsg.bodyptr = pSirSmeRsp;
671 mmhMsg.bodyval = 0;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800672 if (pe_session == NULL) {
Jeff Johnson35c58a82018-11-22 15:04:57 -0800673 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530674 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800675 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -0800676 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800677 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800678 }
679#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -0800680 lim_diag_event_report(mac, WLAN_PE_DIAG_START_BSS_RSP_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800681 pe_session, (uint16_t) resultCode, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800682#endif /* FEATURE_WLAN_DIAG_SUPPORT */
683
Jeff Johnsona5abe272019-01-06 12:52:02 -0800684 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800685} /*** end lim_send_sme_start_bss_rsp() ***/
686
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800687void lim_send_sme_disassoc_deauth_ntf(struct mac_context *mac,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530688 QDF_STATUS status, uint32_t *pCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800689{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700690 struct scheduler_msg mmhMsg = {0};
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800691 struct scheduler_msg *pMsg = (struct scheduler_msg *) pCtx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800692
693 mmhMsg.type = pMsg->type;
694 mmhMsg.bodyptr = pMsg;
695 mmhMsg.bodyval = 0;
696
Jeff Johnson35c58a82018-11-22 15:04:57 -0800697 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800698
Jeff Johnsona5abe272019-01-06 12:52:02 -0800699 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800700}
701
702/**
703 * lim_send_sme_disassoc_ntf()
704 *
705 ***FUNCTION:
706 * This function is called by limProcessSmeMessages() to send
707 * eWNI_SME_DISASSOC_RSP/IND message to host
708 *
709 ***PARAMS:
710 *
711 ***LOGIC:
712 *
713 ***ASSUMPTIONS:
714 * NA
715 *
716 ***NOTE:
717 * This function is used for sending eWNI_SME_DISASSOC_CNF,
718 * or eWNI_SME_DISASSOC_IND to host depending on
719 * disassociation trigger.
720 *
721 * @param peerMacAddr Indicates the peer MAC addr to which
722 * disassociate was initiated
723 * @param reasonCode Indicates the reason for Disassociation
724 * @param disassocTrigger Indicates the trigger for Disassociation
725 * @param aid Indicates the STAID. This parameter is
726 * present only on AP.
727 *
728 * @return None
729 */
730void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800731lim_send_sme_disassoc_ntf(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800732 tSirMacAddr peerMacAddr,
733 tSirResultCodes reasonCode,
734 uint16_t disassocTrigger,
735 uint16_t aid,
736 uint8_t smesessionId,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800737 uint16_t smetransactionId, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800738{
739
740 uint8_t *pBuf;
741 tSirSmeDisassocRsp *pSirSmeDisassocRsp;
742 tSirSmeDisassocInd *pSirSmeDisassocInd;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700743 uint32_t *pMsg = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800744 bool failure = false;
Jeff Johnsond7035a32018-11-18 22:03:13 -0800745 struct pe_session *session = NULL;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700746 uint16_t i, assoc_id;
747 tpDphHashNode sta_ds = NULL;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +0530748 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800749
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530750 pe_debug("Disassoc Ntf with trigger : %d reasonCode: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800751 disassocTrigger, reasonCode);
752
753 switch (disassocTrigger) {
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700754 case eLIM_DUPLICATE_ENTRY:
755 /*
756 * Duplicate entry is removed at LIM.
757 * Initiate new entry for other session
758 */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530759 pe_debug("Rcvd eLIM_DUPLICATE_ENTRY for " MAC_ADDRESS_STR,
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700760 MAC_ADDR_ARRAY(peerMacAddr));
761
Jeff Johnson35c58a82018-11-22 15:04:57 -0800762 for (i = 0; i < mac->lim.maxBssId; i++) {
763 if ((&mac->lim.gpSession[i] != NULL) &&
764 (mac->lim.gpSession[i].valid) &&
765 (mac->lim.gpSession[i].pePersona ==
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700766 QDF_SAP_MODE)) {
767 /* Find the sta ds entry in another session */
Jeff Johnson35c58a82018-11-22 15:04:57 -0800768 session = &mac->lim.gpSession[i];
769 sta_ds = dph_lookup_hash_entry(mac,
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700770 peerMacAddr, &assoc_id,
771 &session->dph.dphHashTable);
Abhishek Singh6d6e3d12017-12-04 14:16:00 +0530772 if (sta_ds)
773 break;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700774 }
775 }
776 if (sta_ds
777#ifdef WLAN_FEATURE_11W
778 && (!sta_ds->rmfEnabled)
779#endif
780 ) {
Jeff Johnson35c58a82018-11-22 15:04:57 -0800781 if (lim_add_sta(mac, sta_ds, false, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700782 QDF_STATUS_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530783 pe_err("could not Add STA with assocId: %d",
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700784 sta_ds->assocId);
785 }
Jeff Johnson35c58a82018-11-22 15:04:57 -0800786 status = lim_prepare_disconnect_done_ind(mac, &pMsg,
Pragaspathi Thilagaraj766c76f2018-08-08 16:44:40 +0530787 smesessionId,
788 reasonCode,
789 &peerMacAddr[0]);
790 if (!QDF_IS_STATUS_SUCCESS(status)) {
791 pe_err("Failed to prepare message");
792 return;
793 }
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700794 break;
795
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800796 case eLIM_HOST_DISASSOC:
797 /**
798 * Disassociation response due to
799 * host triggered disassociation
800 */
801
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530802 pSirSmeDisassocRsp = qdf_mem_malloc(sizeof(tSirSmeDisassocRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700803 if (!pSirSmeDisassocRsp) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800804 failure = true;
805 goto error;
806 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530807 pe_debug("send eWNI_SME_DISASSOC_RSP with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800808 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
809 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
810 pSirSmeDisassocRsp->length = sizeof(tSirSmeDisassocRsp);
811 /* sessionId */
812 pBuf = (uint8_t *) &pSirSmeDisassocRsp->sessionId;
813 *pBuf = smesessionId;
814 pBuf++;
815
816 /* transactionId */
817 lim_copy_u16(pBuf, smetransactionId);
818 pBuf += sizeof(uint16_t);
819
820 /* statusCode */
821 lim_copy_u32(pBuf, reasonCode);
822 pBuf += sizeof(tSirResultCodes);
823
824 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530825 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800826 pBuf += sizeof(tSirMacAddr);
827
828 /* Clear Station Stats */
829 /* for sta, it is always 1, IBSS is handled at halInitSta */
830
831#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
832
Jeff Johnson35c58a82018-11-22 15:04:57 -0800833 lim_diag_event_report(mac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800834 pe_session, (uint16_t) reasonCode, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800835#endif
836 pMsg = (uint32_t *) pSirSmeDisassocRsp;
837 break;
838
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530839 case eLIM_PEER_ENTITY_DISASSOC:
840 case eLIM_LINK_MONITORING_DISASSOC:
Jeff Johnson35c58a82018-11-22 15:04:57 -0800841 status = lim_prepare_disconnect_done_ind(mac, &pMsg,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +0530842 smesessionId,
843 reasonCode, &peerMacAddr[0]);
844 if (!QDF_IS_STATUS_SUCCESS(status)) {
845 pe_err("Failed to prepare message");
846 return;
847 }
848 break;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530849
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800850 default:
851 /**
852 * Disassociation indication due to Disassociation
853 * frame reception from peer entity or due to
854 * loss of link with peer entity.
855 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530856 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700857 if (!pSirSmeDisassocInd) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800858 failure = true;
859 goto error;
860 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530861 pe_debug("send eWNI_SME_DISASSOC_IND with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800862 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
863 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
864 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
865
866 /* Update SME session Id and Transaction Id */
867 pSirSmeDisassocInd->sessionId = smesessionId;
868 pSirSmeDisassocInd->transactionId = smetransactionId;
869 pSirSmeDisassocInd->reasonCode = reasonCode;
870 pBuf = (uint8_t *) &pSirSmeDisassocInd->statusCode;
871
872 lim_copy_u32(pBuf, reasonCode);
873 pBuf += sizeof(tSirResultCodes);
874
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800875 qdf_mem_copy(pBuf, pe_session->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800876 pBuf += sizeof(tSirMacAddr);
877
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530878 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800879
880#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -0800881 lim_diag_event_report(mac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800882 pe_session, (uint16_t) reasonCode, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800883#endif
884 pMsg = (uint32_t *) pSirSmeDisassocInd;
885
886 break;
887 }
888
889error:
890 /* Delete the PE session Created */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800891 if ((pe_session != NULL) && LIM_IS_STA_ROLE(pe_session))
892 pe_delete_session(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800893
894 if (false == failure)
Jeff Johnson35c58a82018-11-22 15:04:57 -0800895 lim_send_sme_disassoc_deauth_ntf(mac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800896 (uint32_t *) pMsg);
897} /*** end lim_send_sme_disassoc_ntf() ***/
898
899/** -----------------------------------------------------------------
900 \brief lim_send_sme_disassoc_ind() - sends SME_DISASSOC_IND
901
902 After receiving disassociation frame from peer entity, this
903 function sends a eWNI_SME_DISASSOC_IND to SME with a specific
904 reason code.
905
Jeff Johnson35c58a82018-11-22 15:04:57 -0800906 \param mac - global mac structure
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800907 \param sta - station dph hash node
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800908 \return none
909 \sa
910 ----------------------------------------------------------------- */
911void
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800912lim_send_sme_disassoc_ind(struct mac_context *mac, tpDphHashNode sta,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800913 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800914{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700915 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800916 tSirSmeDisassocInd *pSirSmeDisassocInd;
917
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530918 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700919 if (!pSirSmeDisassocInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800920 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800921
922 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
923 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
924
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800925 pSirSmeDisassocInd->sessionId = pe_session->smeSessionId;
926 pSirSmeDisassocInd->transactionId = pe_session->transactionId;
Padma, Santhosh Kumar02289212016-09-30 13:30:08 +0530927 pSirSmeDisassocInd->statusCode = eSIR_SME_DEAUTH_STATUS;
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800928 pSirSmeDisassocInd->reasonCode = sta->mlmStaContext.disassocReason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800929
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800930 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes, pe_session->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530931 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800932
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800933 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes, sta->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530934 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800935
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800936 pSirSmeDisassocInd->staId = sta->staIndex;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800937
938 mmhMsg.type = eWNI_SME_DISASSOC_IND;
939 mmhMsg.bodyptr = pSirSmeDisassocInd;
940 mmhMsg.bodyval = 0;
941
Jeff Johnson35c58a82018-11-22 15:04:57 -0800942 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800943 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800944#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800945 lim_diag_event_report(mac, WLAN_PE_DIAG_DISASSOC_IND_EVENT, pe_session,
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800946 0, (uint16_t) sta->mlmStaContext.disassocReason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800947#endif /* FEATURE_WLAN_DIAG_SUPPORT */
948
Jeff Johnsona5abe272019-01-06 12:52:02 -0800949 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800950
951} /*** end lim_send_sme_disassoc_ind() ***/
952
953/** -----------------------------------------------------------------
954 \brief lim_send_sme_deauth_ind() - sends SME_DEAUTH_IND
955
956 After receiving deauthentication frame from peer entity, this
957 function sends a eWNI_SME_DEAUTH_IND to SME with a specific
958 reason code.
959
Jeff Johnson35c58a82018-11-22 15:04:57 -0800960 \param mac - global mac structure
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800961 \param sta - station dph hash node
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800962 \return none
963 \sa
964 ----------------------------------------------------------------- */
965void
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800966lim_send_sme_deauth_ind(struct mac_context *mac, tpDphHashNode sta,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800967 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800968{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700969 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800970 tSirSmeDeauthInd *pSirSmeDeauthInd;
971
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530972 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700973 if (!pSirSmeDeauthInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800974 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800975
976 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
977 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
978
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800979 pSirSmeDeauthInd->sessionId = pe_session->smeSessionId;
980 pSirSmeDeauthInd->transactionId = pe_session->transactionId;
981 if (eSIR_INFRA_AP_MODE == pe_session->bssType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800982 pSirSmeDeauthInd->statusCode =
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800983 (tSirResultCodes) sta->mlmStaContext.cleanupTrigger;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800984 } else {
985 /* Need to indicatet he reascon code over the air */
986 pSirSmeDeauthInd->statusCode =
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800987 (tSirResultCodes) sta->mlmStaContext.disassocReason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800988 }
989 /* BSSID */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800990 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, pe_session->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530991 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800992 /* peerMacAddr */
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800993 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, sta->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530994 QDF_MAC_ADDR_SIZE);
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800995 pSirSmeDeauthInd->reasonCode = sta->mlmStaContext.disassocReason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800996
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800997 pSirSmeDeauthInd->staId = sta->staIndex;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -0800998 if (eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON ==
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800999 sta->mlmStaContext.disassocReason)
1000 pSirSmeDeauthInd->rssi = sta->del_sta_ctx_rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001001
1002 mmhMsg.type = eWNI_SME_DEAUTH_IND;
1003 mmhMsg.bodyptr = pSirSmeDeauthInd;
1004 mmhMsg.bodyval = 0;
1005
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001006 MTRACE(mac_trace_msg_tx(mac, pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001007#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001008 lim_diag_event_report(mac, WLAN_PE_DIAG_DEAUTH_IND_EVENT, pe_session,
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08001009 0, sta->mlmStaContext.cleanupTrigger);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001010#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1011
Jeff Johnsona5abe272019-01-06 12:52:02 -08001012 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001013 return;
1014} /*** end lim_send_sme_deauth_ind() ***/
1015
1016#ifdef FEATURE_WLAN_TDLS
1017/**
1018 * lim_send_sme_tdls_del_sta_ind()
1019 *
1020 ***FUNCTION:
1021 * This function is called to send the TDLS STA context deletion to SME.
1022 *
1023 ***LOGIC:
1024 *
1025 ***ASSUMPTIONS:
1026 *
1027 ***NOTE:
1028 * NA
1029 *
Jeff Johnson35c58a82018-11-22 15:04:57 -08001030 * @param mac - Pointer to global MAC structure
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08001031 * @param sta - Pointer to internal STA Datastructure
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001032 * @param pe_session - Pointer to the session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001033 * @param reasonCode - Reason for TDLS sta deletion
1034 * @return None
1035 */
1036void
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08001037lim_send_sme_tdls_del_sta_ind(struct mac_context *mac, tpDphHashNode sta,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001038 struct pe_session *pe_session, uint16_t reasonCode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001039{
Frank Liud1a28462017-09-06 22:55:48 +08001040 struct tdls_event_info info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001041
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301042 pe_debug("Delete TDLS Peer "MAC_ADDRESS_STR "with reason code: %d",
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08001043 MAC_ADDR_ARRAY(sta->staAddr), reasonCode);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001044 info.vdev_id = pe_session->smeSessionId;
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08001045 qdf_mem_copy(info.peermac.bytes, sta->staAddr, QDF_MAC_ADDR_SIZE);
Frank Liud1a28462017-09-06 22:55:48 +08001046 info.message_type = TDLS_PEER_DISCONNECTED;
1047 info.peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001048
Jeff Johnson35c58a82018-11-22 15:04:57 -08001049 tgt_tdls_event_handler(mac->psoc, &info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001050
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001051 return;
1052} /*** end lim_send_sme_tdls_del_sta_ind() ***/
1053
1054/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001055 * lim_send_sme_mgmt_tx_completion()
1056 *
1057 ***FUNCTION:
1058 * This function is called to send the eWNI_SME_MGMT_FRM_TX_COMPLETION_IND
1059 * message to SME.
1060 *
1061 ***LOGIC:
1062 *
1063 ***ASSUMPTIONS:
1064 *
1065 ***NOTE:
1066 * NA
1067 *
Jeff Johnson35c58a82018-11-22 15:04:57 -08001068 * @param mac - Pointer to global MAC structure
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001069 * @param pe_session - Pointer to the session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001070 * @param txCompleteStatus - TX Complete Status of Mgmt Frames
1071 * @return None
1072 */
1073void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001074lim_send_sme_mgmt_tx_completion(struct mac_context *mac,
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301075 uint32_t sme_session_id,
1076 uint32_t txCompleteStatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001077{
Wu Gao6768d762018-12-28 16:31:08 +08001078 struct scheduler_msg msg = {0};
1079 struct tdls_mgmt_tx_completion_ind *mgmt_tx_completion_ind;
1080 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001081
Wu Gao6768d762018-12-28 16:31:08 +08001082 mgmt_tx_completion_ind =
1083 qdf_mem_malloc(sizeof(*mgmt_tx_completion_ind));
1084 if (!mgmt_tx_completion_ind)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001085 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001086
1087 /* sessionId */
Wu Gao6768d762018-12-28 16:31:08 +08001088 mgmt_tx_completion_ind->session_id = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001089
Wu Gao6768d762018-12-28 16:31:08 +08001090 mgmt_tx_completion_ind->tx_complete_status = txCompleteStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001091
Wu Gao6768d762018-12-28 16:31:08 +08001092 msg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1093 msg.bodyptr = mgmt_tx_completion_ind;
1094 msg.bodyval = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001095
Wu Gao6768d762018-12-28 16:31:08 +08001096 mgmt_tx_completion_ind->psoc = mac->psoc;
1097 msg.callback = tgt_tdls_send_mgmt_tx_completion;
1098 status = scheduler_post_message(QDF_MODULE_ID_PE,
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05301099 QDF_MODULE_ID_TDLS,
Wu Gao6768d762018-12-28 16:31:08 +08001100 QDF_MODULE_ID_TARGET_IF, &msg);
1101 if (QDF_IS_STATUS_ERROR(status)) {
1102 pe_err("post msg fail, %d", status);
1103 qdf_mem_free(mgmt_tx_completion_ind);
1104 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001105} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1106
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001107#endif /* FEATURE_WLAN_TDLS */
1108
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001109QDF_STATUS lim_prepare_disconnect_done_ind(struct mac_context *mac_ctx,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301110 uint32_t **msg,
1111 uint8_t session_id,
1112 tSirResultCodes reason_code,
1113 uint8_t *peer_mac_addr)
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301114{
1115 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301116
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301117 sir_sme_dis_ind = qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001118 if (!sir_sme_dis_ind)
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301119 return QDF_STATUS_E_FAILURE;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301120
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301121 pe_debug("Prepare eWNI_SME_DISCONNECT_DONE_IND withretCode: %d",
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301122 reason_code);
1123
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301124 sir_sme_dis_ind->message_type = eWNI_SME_DISCONNECT_DONE_IND;
1125 sir_sme_dis_ind->length = sizeof(*sir_sme_dis_ind);
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301126 sir_sme_dis_ind->session_id = session_id;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301127 if (peer_mac_addr)
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05301128 qdf_mem_copy(sir_sme_dis_ind->peer_mac,
1129 peer_mac_addr, ETH_ALEN);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301130
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301131 /*
1132 * Instead of sending deauth reason code as 505 which is
1133 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1134 * Send reason code as zero to Supplicant
1135 */
1136 if (reason_code == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1137 sir_sme_dis_ind->reason_code = 0;
1138 else
1139 sir_sme_dis_ind->reason_code = reason_code;
1140
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301141 *msg = (uint32_t *)sir_sme_dis_ind;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301142
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301143 return QDF_STATUS_SUCCESS;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301144}
1145
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001146/**
1147 * lim_send_sme_deauth_ntf()
1148 *
1149 ***FUNCTION:
1150 * This function is called by limProcessSmeMessages() to send
1151 * eWNI_SME_DISASSOC_RSP/IND message to host
1152 *
1153 ***PARAMS:
1154 *
1155 ***LOGIC:
1156 *
1157 ***ASSUMPTIONS:
1158 * NA
1159 *
1160 ***NOTE:
1161 * This function is used for sending eWNI_SME_DEAUTH_CNF or
1162 * eWNI_SME_DEAUTH_IND to host depending on deauthentication trigger.
1163 *
1164 * @param peerMacAddr Indicates the peer MAC addr to which
1165 * deauthentication was initiated
1166 * @param reasonCode Indicates the reason for Deauthetication
1167 * @param deauthTrigger Indicates the trigger for Deauthetication
1168 * @param aid Indicates the STAID. This parameter is present
1169 * only on AP.
1170 *
1171 * @return None
1172 */
1173void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001174lim_send_sme_deauth_ntf(struct mac_context *mac, tSirMacAddr peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001175 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1176 uint16_t aid, uint8_t smesessionId,
1177 uint16_t smetransactionId)
1178{
1179 uint8_t *pBuf;
1180 tSirSmeDeauthRsp *pSirSmeDeauthRsp;
1181 tSirSmeDeauthInd *pSirSmeDeauthInd;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001182 struct pe_session *pe_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001183 uint8_t sessionId;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301184 uint32_t *pMsg = NULL;
1185 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001186
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001187 pe_session = pe_find_session_by_bssid(mac, peerMacAddr, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001188 switch (deauthTrigger) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001189 case eLIM_HOST_DEAUTH:
1190 /**
1191 * Deauthentication response to host triggered
1192 * deauthentication.
1193 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301194 pSirSmeDeauthRsp = qdf_mem_malloc(sizeof(tSirSmeDeauthRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001195 if (!pSirSmeDeauthRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001196 return;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301197 pe_debug("send eWNI_SME_DEAUTH_RSP with retCode: %d for" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001198 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1199 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
1200 pSirSmeDeauthRsp->length = sizeof(tSirSmeDeauthRsp);
1201 pSirSmeDeauthRsp->statusCode = reasonCode;
1202 pSirSmeDeauthRsp->sessionId = smesessionId;
1203 pSirSmeDeauthRsp->transactionId = smetransactionId;
1204
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -08001205 pBuf = (uint8_t *) pSirSmeDeauthRsp->peer_macaddr.bytes;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301206 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001207
1208#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -08001209 lim_diag_event_report(mac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001210 pe_session, 0, (uint16_t) reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001211#endif
1212 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1213
1214 break;
1215
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301216 case eLIM_PEER_ENTITY_DEAUTH:
1217 case eLIM_LINK_MONITORING_DEAUTH:
Jeff Johnson35c58a82018-11-22 15:04:57 -08001218 status = lim_prepare_disconnect_done_ind(mac, &pMsg,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301219 smesessionId, reasonCode,
1220 &peerMacAddr[0]);
1221 if (!QDF_IS_STATUS_SUCCESS(status)) {
1222 pe_err("Failed to prepare message");
1223 return;
1224 }
1225 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001226 default:
1227 /**
1228 * Deauthentication indication due to Deauthentication
1229 * frame reception from peer entity or due to
1230 * loss of link with peer entity.
1231 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301232 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001233 if (!pSirSmeDeauthInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001234 return;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301235 pe_debug("send eWNI_SME_DEAUTH_IND with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001236 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1237 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1238 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1239 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 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001271 if (pe_session != NULL) {
1272 pe_delete_session(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001273 }
1274
Jeff Johnson35c58a82018-11-22 15:04:57 -08001275 lim_send_sme_disassoc_deauth_ntf(mac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001276 (uint32_t *) pMsg);
1277
1278} /*** end lim_send_sme_deauth_ntf() ***/
1279
1280/**
1281 * lim_send_sme_wm_status_change_ntf() - Send Notification
1282 * @mac_ctx: Global MAC Context
1283 * @status_change_code: Indicates the change in the wireless medium.
1284 * @status_change_info: Indicates the information associated with
1285 * change in the wireless medium.
1286 * @info_len: Indicates the length of status change information
1287 * being sent.
1288 * @session_id SessionID
1289 *
1290 * This function is called by limProcessSmeMessages() to send
1291 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1292 *
1293 * Return: None
1294 */
1295void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001296lim_send_sme_wm_status_change_ntf(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001297 tSirSmeStatusChangeCode status_change_code,
1298 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1299{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001300 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001301 tSirSmeWmStatusChangeNtf *wm_status_change_ntf;
Naveen Rawate01ed172016-11-17 11:34:50 -08001302 uint32_t max_info_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001303
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301304 wm_status_change_ntf = qdf_mem_malloc(sizeof(tSirSmeWmStatusChangeNtf));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001305 if (!wm_status_change_ntf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001306 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001307
1308 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1309 msg.bodyval = 0;
1310 msg.bodyptr = wm_status_change_ntf;
1311
1312 switch (status_change_code) {
Naveen Rawate01ed172016-11-17 11:34:50 -08001313 case eSIR_SME_AP_CAPS_CHANGED:
1314 max_info_len = sizeof(tSirSmeApNewCaps);
1315 break;
1316 case eSIR_SME_JOINED_NEW_BSS:
1317 max_info_len = sizeof(tSirSmeNewBssInfo);
1318 break;
1319 default:
1320 max_info_len = sizeof(wm_status_change_ntf->statusChangeInfo);
1321 break;
1322 }
1323
1324 switch (status_change_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325 case eSIR_SME_RADAR_DETECTED:
1326 break;
1327 default:
1328 wm_status_change_ntf->messageType =
1329 eWNI_SME_WM_STATUS_CHANGE_NTF;
1330 wm_status_change_ntf->statusChangeCode = status_change_code;
1331 wm_status_change_ntf->length = sizeof(tSirSmeWmStatusChangeNtf);
1332 wm_status_change_ntf->sessionId = session_id;
Naveen Rawate01ed172016-11-17 11:34:50 -08001333 if (info_len <= max_info_len && status_change_info) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301334 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001335 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1336 (uint8_t *) status_change_info, info_len);
1337 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301338 pe_debug("StatusChg code: 0x%x length: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001339 status_change_code, info_len);
1340 break;
1341 }
1342
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301343 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, session_id, msg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08001344 if (QDF_STATUS_SUCCESS != lim_sys_process_mmh_msg_api(mac_ctx, &msg)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301345 qdf_mem_free(wm_status_change_ntf);
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301346 pe_err("lim_sys_process_mmh_msg_api failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001347 }
1348
1349} /*** end lim_send_sme_wm_status_change_ntf() ***/
1350
1351/**
1352 * lim_send_sme_set_context_rsp()
1353 *
1354 ***FUNCTION:
1355 * This function is called by limProcessSmeMessages() to send
1356 * eWNI_SME_SETCONTEXT_RSP message to host
1357 *
1358 ***PARAMS:
1359 *
1360 ***LOGIC:
1361 *
1362 ***ASSUMPTIONS:
1363 * NA
1364 *
1365 ***NOTE:
1366 *
Jeff Johnson35c58a82018-11-22 15:04:57 -08001367 * @param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001368 * @param peerMacAddr Indicates the peer MAC addr to which
1369 * setContext was performed
1370 * @param aid Indicates the aid corresponding to the peer MAC
1371 * address
1372 * @param resultCode Indicates the result of previously issued
1373 * eWNI_SME_SETCONTEXT_RSP message
1374 *
1375 * @return None
1376 */
1377void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001378lim_send_sme_set_context_rsp(struct mac_context *mac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301379 struct qdf_mac_addr peer_macaddr, uint16_t aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001380 tSirResultCodes resultCode,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001381 struct pe_session *pe_session, 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};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001385 tSirSmeSetContextRsp *pSirSmeSetContextRsp;
1386
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301387 pSirSmeSetContextRsp = qdf_mem_malloc(sizeof(tSirSmeSetContextRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001388 if (!pSirSmeSetContextRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001389 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001390
1391 pSirSmeSetContextRsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1392 pSirSmeSetContextRsp->length = sizeof(tSirSmeSetContextRsp);
1393 pSirSmeSetContextRsp->statusCode = resultCode;
1394
Anurag Chouhanc5548422016-02-24 18:33:27 +05301395 qdf_copy_macaddr(&pSirSmeSetContextRsp->peer_macaddr, &peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001396
1397 /* Update SME session and transaction Id */
1398 pSirSmeSetContextRsp->sessionId = smesessionId;
1399 pSirSmeSetContextRsp->transactionId = smetransactionId;
1400
1401 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
1402 mmhMsg.bodyptr = pSirSmeSetContextRsp;
1403 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 */
1642 pPeSessionEntry =
Jeff Johnson35c58a82018-11-22 15:04:57 -08001643 pe_find_session_by_sta_id(mac, pPeStats->staId, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001644
1645 /* Fill the Session Id */
1646 if (NULL != pPeSessionEntry) {
1647 /* Fill the Session Id */
1648 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1649 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301650 pe_err("Session not found for the Sta id: %d",
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301651 pPeStats->staId);
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05301652 qdf_mem_free(pPeStats->tsmStatsReq);
1653 qdf_mem_free(pPeStats);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001654 return;
1655 }
1656
1657 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
1658 pPeStats->tsmMetrics.RoamingCount
1659 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
1660 pPeStats->tsmMetrics.RoamingDly
1661 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
1662
1663 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
1664 mmhMsg.bodyptr = pStats;
1665 mmhMsg.bodyval = 0;
Jeff Johnson35c58a82018-11-22 15:04:57 -08001666 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08001667 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001668
1669 return;
1670} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
1671
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001672#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001673
1674void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001675lim_send_sme_ibss_peer_ind(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001676 tSirMacAddr peerMacAddr,
1677 uint16_t staIndex,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001678 uint8_t *beacon,
1679 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
1680{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001681 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001682 tSmeIbssPeerInd *pNewPeerInd;
1683
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301684 pNewPeerInd = qdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
Arif Hussainf5b6c412018-10-10 19:41:09 -07001685 if (!pNewPeerInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001686 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001687
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301688 qdf_mem_copy((uint8_t *) pNewPeerInd->peer_addr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301689 peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001690 pNewPeerInd->staId = staIndex;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001691 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
1692 pNewPeerInd->mesgType = msgType;
1693 pNewPeerInd->sessionId = sessionId;
1694
1695 if (beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301696 qdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001697 sizeof(tSmeIbssPeerInd)), (void *)beacon,
1698 beaconLen);
1699 }
1700
1701 mmhMsg.type = msgType;
1702 mmhMsg.bodyptr = pNewPeerInd;
Jeff Johnson35c58a82018-11-22 15:04:57 -08001703 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08001704 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001705
1706}
1707
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07001708/**
1709 * lim_process_csa_wbw_ie() - Process CSA Wide BW IE
1710 * @mac_ctx: pointer to global adapter context
1711 * @csa_params: pointer to CSA parameters
1712 * @chnl_switch_info:pointer to channel switch parameters
1713 * @session_entry: session pointer
1714 *
1715 * Return: None
1716 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001717static QDF_STATUS lim_process_csa_wbw_ie(struct mac_context *mac_ctx,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001718 struct csa_offload_params *csa_params,
1719 tLimWiderBWChannelSwitchInfo *chnl_switch_info,
Jeff Johnsond7035a32018-11-18 22:03:13 -08001720 struct pe_session *session_entry)
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001721{
Amar Singhal5cccafe2017-02-15 12:42:58 -08001722 struct ch_params ch_params = {0};
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001723 uint8_t ap_new_ch_width;
1724 bool new_ch_width_dfn = false;
1725 uint8_t center_freq_diff;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001726 uint32_t fw_vht_ch_wd = wma_get_vht_ch_width() + 1;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001727
1728 ap_new_ch_width = csa_params->new_ch_width + 1;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001729
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001730 pe_debug("new channel: %d new_ch_width: %d seg0: %d seg1: %d",
1731 csa_params->channel, ap_new_ch_width,
1732 csa_params->new_ch_freq_seg1,
1733 csa_params->new_ch_freq_seg2);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001734
1735 if ((ap_new_ch_width != CH_WIDTH_80MHZ) &&
1736 (ap_new_ch_width != CH_WIDTH_160MHZ) &&
1737 (ap_new_ch_width != CH_WIDTH_80P80MHZ)) {
1738 pe_err("CSA wide BW IE has wrong ch_width %d",
1739 csa_params->new_ch_width);
1740 return QDF_STATUS_E_INVAL;
1741 }
1742
1743 if (!csa_params->new_ch_freq_seg1 && !csa_params->new_ch_freq_seg2) {
1744 pe_err("CSA wide BW IE has invalid center freq");
1745 return QDF_STATUS_E_INVAL;
1746 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001747 if ((ap_new_ch_width == CH_WIDTH_80MHZ) &&
1748 csa_params->new_ch_freq_seg2) {
1749 new_ch_width_dfn = true;
1750 if (csa_params->new_ch_freq_seg2 >
1751 csa_params->new_ch_freq_seg1)
1752 center_freq_diff = csa_params->new_ch_freq_seg2 -
1753 csa_params->new_ch_freq_seg1;
1754 else
1755 center_freq_diff = csa_params->new_ch_freq_seg1 -
1756 csa_params->new_ch_freq_seg2;
1757 if (center_freq_diff == CENTER_FREQ_DIFF_160MHz)
1758 ap_new_ch_width = CH_WIDTH_160MHZ;
1759 else if (center_freq_diff > CENTER_FREQ_DIFF_80P80MHz)
1760 ap_new_ch_width = CH_WIDTH_80P80MHZ;
1761 else
1762 ap_new_ch_width = CH_WIDTH_80MHZ;
1763 }
1764 session_entry->gLimChannelSwitch.state =
1765 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1766 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
1767 !new_ch_width_dfn) {
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001768 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1769 CH_TO_CNTR_FREQ_DIFF_160MHz) {
1770 pe_err("CSA wide BW IE has invalid center freq");
1771 return QDF_STATUS_E_INVAL;
1772 }
1773
1774 if (ap_new_ch_width > fw_vht_ch_wd) {
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001775 pe_debug("New BW is not supported, setting BW to %d",
1776 fw_vht_ch_wd);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001777 ap_new_ch_width = fw_vht_ch_wd;
1778 }
1779 ch_params.ch_width = ap_new_ch_width ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001780 wlan_reg_set_channel_params(mac_ctx->pdev,
1781 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001782 ap_new_ch_width = ch_params.ch_width;
1783 csa_params->new_ch_freq_seg1 = ch_params.center_freq_seg0;
1784 csa_params->new_ch_freq_seg2 = ch_params.center_freq_seg1;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001785 } else if (!new_ch_width_dfn) {
1786 if (ap_new_ch_width > fw_vht_ch_wd) {
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001787 pe_debug("New BW is not supported, setting BW to %d",
1788 fw_vht_ch_wd);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001789 ap_new_ch_width = fw_vht_ch_wd;
1790 }
1791 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1792 CH_TO_CNTR_FREQ_DIFF_80MHz) {
1793 pe_err("CSA wide BW IE has invalid center freq");
1794 return QDF_STATUS_E_INVAL;
1795 }
1796 csa_params->new_ch_freq_seg2 = 0;
1797 }
1798 if (new_ch_width_dfn) {
1799 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1800 CH_TO_CNTR_FREQ_DIFF_80MHz) {
1801 pe_err("CSA wide BW IE has invalid center freq");
1802 return QDF_STATUS_E_INVAL;
1803 }
1804 if (ap_new_ch_width > fw_vht_ch_wd) {
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001805 pe_debug("New width is not supported, setting BW to %d",
1806 fw_vht_ch_wd);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001807 ap_new_ch_width = fw_vht_ch_wd;
1808 }
1809 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
1810 (csa_params->new_ch_freq_seg1 !=
1811 csa_params->channel +
1812 CH_TO_CNTR_FREQ_DIFF_160MHz)) {
1813 pe_err("wide BW IE has invalid 160M center freq");
1814 csa_params->new_ch_freq_seg2 = 0;
1815 ap_new_ch_width = CH_WIDTH_80MHZ;
1816 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001817 }
1818 chnl_switch_info->newChanWidth = ap_new_ch_width;
1819 chnl_switch_info->newCenterChanFreq0 = csa_params->new_ch_freq_seg1;
1820 chnl_switch_info->newCenterChanFreq1 = csa_params->new_ch_freq_seg2;
1821
1822 if (session_entry->ch_width == ap_new_ch_width)
1823 goto prnt_log;
1824
1825 if (session_entry->ch_width == CH_WIDTH_80MHZ) {
1826 chnl_switch_info->newChanWidth = CH_WIDTH_80MHZ;
1827 chnl_switch_info->newCenterChanFreq1 = 0;
1828 } else {
1829 session_entry->ch_width = ap_new_ch_width;
1830 chnl_switch_info->newChanWidth = ap_new_ch_width;
1831 }
1832prnt_log:
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301833 pe_debug("new channel: %d new_ch_width: %d seg0: %d seg1: %d",
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001834 csa_params->channel,
1835 chnl_switch_info->newChanWidth,
1836 chnl_switch_info->newCenterChanFreq0,
1837 chnl_switch_info->newCenterChanFreq1);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001838
1839 return QDF_STATUS_SUCCESS;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001840}
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001841
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001842/**
1843 * lim_handle_csa_offload_msg() - Handle CSA offload message
1844 * @mac_ctx: pointer to global adapter context
1845 * @msg: Message pointer.
1846 *
1847 * Return: None
1848 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001849void lim_handle_csa_offload_msg(struct mac_context *mac_ctx,
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001850 struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001851{
Jeff Johnsond7035a32018-11-18 22:03:13 -08001852 struct pe_session *session_entry;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001853 struct scheduler_msg mmh_msg = {0};
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301854 struct csa_offload_params *csa_params =
1855 (struct csa_offload_params *) (msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001856 tpSmeCsaOffloadInd csa_offload_ind;
1857 tpDphHashNode sta_ds = NULL;
1858 uint8_t session_id;
1859 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05301860 uint16_t chan_space = 0;
Krunal Sonie2c45a92018-05-03 11:51:26 -07001861 struct ch_params ch_params = {0};
Gupta, Kapil121bf212015-11-25 19:21:29 +05301862
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001863 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08001864 tLimChannelSwitchInfo *lim_ch_switch = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001865
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301866 pe_debug("handle csa offload msg");
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301867
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001868 if (!csa_params) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301869 pe_err("limMsgQ body ptr is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001870 return;
1871 }
1872
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05301873 csa_offload_ind = qdf_mem_malloc(sizeof(tSmeCsaOffloadInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001874 if (!csa_offload_ind)
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05301875 goto err;
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05301876
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001877 session_entry =
1878 pe_find_session_by_bssid(mac_ctx,
1879 csa_params->bssId, &session_id);
1880 if (!session_entry) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301881 pe_err("Session does not exists for %pM",
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301882 csa_params->bssId);
Pragaspathi Thilagaraj655db192018-06-19 17:41:37 +05301883 qdf_mem_free(csa_offload_ind);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001884 goto err;
1885 }
1886
1887 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
1888 &session_entry->dph.dphHashTable);
1889
1890 if (!sta_ds) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301891 pe_err("sta_ds does not exist");
Pragaspathi Thilagaraj655db192018-06-19 17:41:37 +05301892 qdf_mem_free(csa_offload_ind);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001893 goto err;
1894 }
1895
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001896 if (!LIM_IS_STA_ROLE(session_entry)) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301897 pe_debug("Invalid role to handle CSA");
Pragaspathi Thilagaraj655db192018-06-19 17:41:37 +05301898 qdf_mem_free(csa_offload_ind);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001899 goto err;
1900 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001901 /*
1902 * on receiving channel switch announcement from AP, delete all
1903 * TDLS peers before leaving BSS and proceed for channel switch
1904 */
Bala Venkatesh33f270b2019-01-14 16:31:29 +05301905
1906 lim_update_tdls_set_state_for_fw(session_entry, false);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001907 lim_delete_tdls_peers(mac_ctx, session_entry);
Gupta, Kapil121bf212015-11-25 19:21:29 +05301908
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001909 lim_ch_switch = &session_entry->gLimChannelSwitch;
1910 session_entry->gLimChannelSwitch.switchMode =
1911 csa_params->switch_mode;
1912 /* timer already started by firmware, switch immediately */
1913 session_entry->gLimChannelSwitch.switchCount = 0;
1914 session_entry->gLimChannelSwitch.primaryChannel =
1915 csa_params->channel;
1916 session_entry->gLimChannelSwitch.state =
1917 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
1918 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
1919 lim_ch_switch->sec_ch_offset =
1920 session_entry->htSecondaryChannelOffset;
1921 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
1922 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
1923 chnl_switch_info =
1924 &session_entry->gLimWiderBWChannelSwitch;
1925
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001926 pe_debug("vht: %d ht: %d flag: %x chan: %d, sec_ch_offset %d",
1927 session_entry->vhtCapability,
1928 session_entry->htSupportedChannelWidthSet,
1929 csa_params->ies_present_flag,
1930 csa_params->channel,
1931 csa_params->sec_chan_offset);
1932 pe_debug("seg1: %d seg2: %d width: %d country: %s class: %d",
1933 csa_params->new_ch_freq_seg1,
1934 csa_params->new_ch_freq_seg2,
1935 csa_params->new_ch_width,
1936 mac_ctx->scan.countryCodeCurrent,
1937 csa_params->new_op_class);
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05301938
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001939 if (session_entry->vhtCapability &&
1940 session_entry->htSupportedChannelWidthSet) {
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001941 if ((csa_params->ies_present_flag & lim_wbw_ie_present) &&
1942 (QDF_STATUS_SUCCESS == lim_process_csa_wbw_ie(mac_ctx,
1943 csa_params, chnl_switch_info,
1944 session_entry))) {
1945 pe_debug("CSA wide BW IE process successful");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001946 lim_ch_switch->sec_ch_offset =
Abhishek Singhaf639b42017-06-16 14:14:36 +05301947 PHY_SINGLE_CHANNEL_CENTERED;
1948 if (chnl_switch_info->newChanWidth) {
1949 if (csa_params->channel <
1950 csa_params->new_ch_freq_seg1)
1951 lim_ch_switch->sec_ch_offset =
1952 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1953 else
1954 lim_ch_switch->sec_ch_offset =
1955 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1956 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001957 } else if (csa_params->ies_present_flag
1958 & lim_xcsa_ie_present) {
1959 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001960 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001961 mac_ctx->scan.countryCodeCurrent,
1962 csa_params->channel,
1963 csa_params->new_op_class);
1964 session_entry->gLimChannelSwitch.state =
1965 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1966
1967 if (chan_space == 80) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001968 chnl_switch_info->newChanWidth =
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001969 CH_WIDTH_80MHZ;
1970 } else if (chan_space == 40) {
1971 chnl_switch_info->newChanWidth =
1972 CH_WIDTH_40MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001973 } else {
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001974 chnl_switch_info->newChanWidth =
1975 CH_WIDTH_20MHZ;
1976 lim_ch_switch->state =
1977 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
1978 }
1979
1980 ch_params.ch_width =
1981 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001982 wlan_reg_set_channel_params(mac_ctx->pdev,
1983 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001984 chnl_switch_info->newCenterChanFreq0 =
1985 ch_params.center_freq_seg0;
1986 /*
1987 * This is not applicable for 20/40/80 MHz.
1988 * Only used when we support 80+80 MHz operation.
1989 * In case of 80+80 MHz, this parameter indicates
1990 * center channel frequency index of 80 MHz
1991 * channel offrequency segment 1.
1992 */
1993 chnl_switch_info->newCenterChanFreq1 =
1994 ch_params.center_freq_seg1;
1995 lim_ch_switch->sec_ch_offset =
1996 ch_params.sec_ch_offset;
1997
Kiran Kumar Lokere47127482017-12-20 18:09:55 -08001998 } else {
1999 lim_ch_switch->state =
2000 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2001 ch_params.ch_width = CH_WIDTH_40MHZ;
2002 wlan_reg_set_channel_params(mac_ctx->pdev,
2003 csa_params->channel, 0, &ch_params);
2004 lim_ch_switch->sec_ch_offset =
2005 ch_params.sec_ch_offset;
2006 chnl_switch_info->newChanWidth = CH_WIDTH_40MHZ;
2007 chnl_switch_info->newCenterChanFreq0 =
2008 ch_params.center_freq_seg0;
2009 chnl_switch_info->newCenterChanFreq1 = 0;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002010 }
2011 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
2012 chnl_switch_info->newCenterChanFreq0;
2013 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
2014 chnl_switch_info->newCenterChanFreq1;
2015 session_entry->gLimChannelSwitch.ch_width =
2016 chnl_switch_info->newChanWidth;
2017
2018 } else if (session_entry->htSupportedChannelWidthSet) {
2019 if (csa_params->ies_present_flag
2020 & lim_xcsa_ie_present) {
2021 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002022 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002023 mac_ctx->scan.countryCodeCurrent,
2024 csa_params->channel,
2025 csa_params->new_op_class);
2026 lim_ch_switch->state =
2027 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2028 if (chan_space == 40) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002029 lim_ch_switch->ch_width =
2030 CH_WIDTH_40MHZ;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002031 chnl_switch_info->newChanWidth =
2032 CH_WIDTH_40MHZ;
2033 ch_params.ch_width =
2034 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002035 wlan_reg_set_channel_params(mac_ctx->pdev,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002036 csa_params->channel,
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07002037 0, &ch_params);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002038 lim_ch_switch->ch_center_freq_seg0 =
2039 ch_params.center_freq_seg0;
2040 lim_ch_switch->sec_ch_offset =
2041 ch_params.sec_ch_offset;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002042 } else {
2043 lim_ch_switch->ch_width =
2044 CH_WIDTH_20MHZ;
2045 chnl_switch_info->newChanWidth =
2046 CH_WIDTH_40MHZ;
2047 lim_ch_switch->state =
2048 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2049 lim_ch_switch->sec_ch_offset =
2050 PHY_SINGLE_CHANNEL_CENTERED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002051 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002052 } else {
2053 lim_ch_switch->ch_width =
2054 CH_WIDTH_40MHZ;
2055 lim_ch_switch->state =
2056 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2057 ch_params.ch_width = CH_WIDTH_40MHZ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002058 wlan_reg_set_channel_params(mac_ctx->pdev,
2059 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002060 lim_ch_switch->ch_center_freq_seg0 =
2061 ch_params.center_freq_seg0;
2062 lim_ch_switch->sec_ch_offset =
2063 ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002064 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002065
2066 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302067 pe_debug("new ch width: %d space: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302068 session_entry->gLimChannelSwitch.ch_width, chan_space);
Kiran Kumar Lokere75d636f2016-12-20 14:52:03 -08002069 if ((session_entry->currentOperChannel == csa_params->channel) &&
2070 (session_entry->ch_width ==
2071 session_entry->gLimChannelSwitch.ch_width)) {
2072 pe_debug("Ignore CSA, no change in ch and bw");
Pragaspathi Thilagaraj655db192018-06-19 17:41:37 +05302073 qdf_mem_free(csa_offload_ind);
Kiran Kumar Lokere75d636f2016-12-20 14:52:03 -08002074 goto err;
2075 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002076
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05302077 if (WLAN_REG_IS_24GHZ_CH(csa_params->channel) &&
2078 (session_entry->dot11mode == WNI_CFG_DOT11_MODE_11A))
2079 session_entry->dot11mode = WNI_CFG_DOT11_MODE_11G;
2080 else if (WLAN_REG_IS_5GHZ_CH(csa_params->channel) &&
2081 ((session_entry->dot11mode == WNI_CFG_DOT11_MODE_11G) ||
2082 (session_entry->dot11mode == WNI_CFG_DOT11_MODE_11G_ONLY)))
2083 session_entry->dot11mode = WNI_CFG_DOT11_MODE_11A;
2084
Vignesh Viswanathan3d478032018-08-02 20:18:53 +05302085 /* Send RSO Stop to FW before triggering the vdev restart for CSA */
2086 if (mac_ctx->lim.stop_roaming_callback)
2087 mac_ctx->lim.stop_roaming_callback(mac_ctx,
2088 session_entry->smeSessionId,
2089 ecsr_driver_disabled);
2090
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002091 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002092
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002093 csa_offload_ind->mesgType = eWNI_SME_CSA_OFFLOAD_EVENT;
2094 csa_offload_ind->mesgLen = sizeof(tSmeCsaOffloadInd);
2095 qdf_mem_copy(csa_offload_ind->bssid.bytes, session_entry->bssId,
2096 QDF_MAC_ADDR_SIZE);
2097 mmh_msg.type = eWNI_SME_CSA_OFFLOAD_EVENT;
2098 mmh_msg.bodyptr = csa_offload_ind;
2099 mmh_msg.bodyval = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302100 pe_debug("Sending eWNI_SME_CSA_OFFLOAD_EVENT to SME");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002101 MTRACE(mac_trace_msg_tx
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002102 (mac_ctx, session_entry->peSessionId, mmh_msg.type));
2103#ifdef FEATURE_WLAN_DIAG_SUPPORT
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002104 lim_diag_event_report(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002105 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002106 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002107#endif
Jeff Johnsona5abe272019-01-06 12:52:02 -08002108 lim_sys_process_mmh_msg_api(mac_ctx, &mmh_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002109
2110err:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302111 qdf_mem_free(csa_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002112}
2113
2114/*--------------------------------------------------------------------------
2115 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
2116
Jeff Johnson35c58a82018-11-22 15:04:57 -08002117 \param mac - pointer to global adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002118 \param sessionId - Message pointer.
2119
2120 \sa
2121 --------------------------------------------------------------------------*/
2122
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002123void lim_handle_delete_bss_rsp(struct mac_context *mac, struct scheduler_msg *MsgQ)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002124{
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002125 struct pe_session *pe_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002126 tpDeleteBssParams pDelBss = (tpDeleteBssParams) (MsgQ->bodyptr);
2127
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002128 pe_session =
Jeff Johnson35c58a82018-11-22 15:04:57 -08002129 pe_find_session_by_session_id(mac, pDelBss->sessionId);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002130 if (pe_session == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302131 pe_err("Session Does not exist for given sessionID: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002132 pDelBss->sessionId);
Tushnim Bhattacharyya6368a262018-10-12 09:48:45 -07002133 qdf_mem_free(MsgQ->bodyptr);
2134 MsgQ->bodyptr = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002135 return;
2136 }
Krunal Sonie50ff452017-10-11 18:23:55 -07002137
2138 /*
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002139 * During DEL BSS handling, the PE Session will be deleted, but it is
2140 * better to clear this flag if the session is hanging around due
2141 * to some error conditions so that the next DEL_BSS request does
2142 * not take the HO_FAIL path
2143 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002144 pe_session->process_ho_fail = false;
2145 if (LIM_IS_IBSS_ROLE(pe_session))
2146 lim_ibss_del_bss_rsp(mac, MsgQ->bodyptr, pe_session);
2147 else if (LIM_IS_UNKNOWN_ROLE(pe_session))
2148 lim_process_sme_del_bss_rsp(mac, MsgQ->bodyval, pe_session);
2149 else if (LIM_IS_NDI_ROLE(pe_session))
2150 lim_ndi_del_bss_rsp(mac, MsgQ->bodyptr, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002151 else
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002152 lim_process_mlm_del_bss_rsp(mac, MsgQ, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002153
2154}
2155
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002156/** -----------------------------------------------------------------
2157 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
2158 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
2159 \ SME only looks at rc and tspec field.
Jeff Johnson35c58a82018-11-22 15:04:57 -08002160 \param mac - global mac structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002161 \param rspReqd - is SmeAddTsRsp required
2162 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
2163 \return tspec
2164 \sa
2165 ----------------------------------------------------------------- */
2166void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002167lim_send_sme_aggr_qos_rsp(struct mac_context *mac, tpSirAggrQosRsp aggrQosRsp,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002168 uint8_t smesessionId)
2169{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002170 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002171
2172 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
2173 mmhMsg.bodyptr = aggrQosRsp;
2174 mmhMsg.bodyval = 0;
Jeff Johnson35c58a82018-11-22 15:04:57 -08002175 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302176 smesessionId, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08002177 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002178
2179 return;
2180}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002181
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002182void lim_send_sme_max_assoc_exceeded_ntf(struct mac_context *mac, tSirMacAddr peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002183 uint8_t smesessionId)
2184{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002185 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002186 tSmeMaxAssocInd *pSmeMaxAssocInd;
2187
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302188 pSmeMaxAssocInd = qdf_mem_malloc(sizeof(tSmeMaxAssocInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002189 if (!pSmeMaxAssocInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002190 return;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302191 qdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peer_mac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302192 (uint8_t *) peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002193 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
2194 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
2195 pSmeMaxAssocInd->sessionId = smesessionId;
2196 mmhMsg.type = pSmeMaxAssocInd->mesgType;
2197 mmhMsg.bodyptr = pSmeMaxAssocInd;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302198 pe_debug("msgType: %s peerMacAddr "MAC_ADDRESS_STR "sme session id %d",
2199 "eWNI_SME_MAX_ASSOC_EXCEEDED", MAC_ADDR_ARRAY(peerMacAddr),
2200 pSmeMaxAssocInd->sessionId);
Jeff Johnson35c58a82018-11-22 15:04:57 -08002201 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302202 smesessionId, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08002203 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002204
2205 return;
2206}
2207
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002208/** -----------------------------------------------------------------
2209 \brief lim_send_sme_ap_channel_switch_resp() - sends
2210 eWNI_SME_CHANNEL_CHANGE_RSP
2211 After receiving WMA_SWITCH_CHANNEL_RSP indication this
2212 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
2213 that the Channel change has been done to the specified target
2214 channel in the Channel change request
Jeff Johnson35c58a82018-11-22 15:04:57 -08002215 \param mac - global mac structure
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002216 \param pe_session - session info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002217 \param pChnlParams - Channel switch params
2218 --------------------------------------------------------------------*/
2219void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002220lim_send_sme_ap_channel_switch_resp(struct mac_context *mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002221 struct pe_session *pe_session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002222 tpSwitchChannelParams pChnlParams)
2223{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002224 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002225 tpSwitchChannelParams pSmeSwithChnlParams;
2226 uint8_t channelId;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002227 bool is_ch_dfs = false;
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08002228 enum phy_ch_width ch_width;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002229 uint8_t ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002230
Arif Hussainf5b6c412018-10-10 19:41:09 -07002231 pSmeSwithChnlParams = qdf_mem_malloc(sizeof(tSwitchChannelParams));
2232 if (!pSmeSwithChnlParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002233 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002234
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302235 qdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002236 sizeof(tSwitchChannelParams));
2237
2238 channelId = pSmeSwithChnlParams->channelNumber;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002239 ch_width = pSmeSwithChnlParams->ch_width;
2240 ch_center_freq_seg1 = pSmeSwithChnlParams->ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002241
2242 /*
2243 * Pass the sme sessionID to SME instead
2244 * PE session ID.
2245 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002246 pSmeSwithChnlParams->peSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002247
2248 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
2249 mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
2250 mmhMsg.bodyval = 0;
Jeff Johnsona5abe272019-01-06 12:52:02 -08002251 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002252
2253 /*
2254 * We should start beacon transmission only if the new
2255 * channel after channel change is Non-DFS. For a DFS
2256 * channel, PE will receive an explicit request from
2257 * upper layers to start the beacon transmission .
2258 */
2259
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002260 if (ch_width == CH_WIDTH_160MHZ) {
2261 is_ch_dfs = true;
2262 } else if (ch_width == CH_WIDTH_80P80MHZ) {
Jeff Johnson35c58a82018-11-22 15:04:57 -08002263 if (wlan_reg_get_channel_state(mac->pdev, channelId) ==
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002264 CHANNEL_STATE_DFS ||
Jeff Johnson35c58a82018-11-22 15:04:57 -08002265 wlan_reg_get_channel_state(mac->pdev,
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002266 ch_center_freq_seg1 -
2267 SIR_80MHZ_START_CENTER_CH_DIFF) ==
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002268 CHANNEL_STATE_DFS)
2269 is_ch_dfs = true;
2270 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -08002271 if (wlan_reg_get_channel_state(mac->pdev, channelId) ==
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002272 CHANNEL_STATE_DFS)
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002273 is_ch_dfs = true;
2274 }
2275
2276 if (!is_ch_dfs) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002277 if (channelId == pe_session->currentOperChannel) {
2278 lim_apply_configuration(mac, pe_session);
2279 lim_send_beacon(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002280 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302281 pe_debug("Failed to Transmit Beacons on channel: %d after AP channel change response",
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002282 pe_session->bcnLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002283 }
Arif Hussain1513cb22018-01-05 19:56:31 -08002284
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002285 lim_obss_send_detection_cfg(mac, pe_session, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002286 }
2287 return;
2288}
2289
Peng Xu6363ec62017-05-15 11:06:33 -07002290#ifdef WLAN_FEATURE_11AX_BSS_COLOR
2291/**
2292 * lim_send_bss_color_change_ie_update() - update bss color change IE in
2293 * beacon template
2294 *
2295 * @mac_ctx: pointer to global adapter context
2296 * @session: session pointer
2297 *
2298 * Return: none
2299 */
2300static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002301lim_send_bss_color_change_ie_update(struct mac_context *mac_ctx,
Jeff Johnsond7035a32018-11-18 22:03:13 -08002302 struct pe_session *session)
Peng Xu6363ec62017-05-15 11:06:33 -07002303{
2304 /* Update the beacon template and send to FW */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002305 if (sch_set_fixed_beacon_fields(mac_ctx, session) != QDF_STATUS_SUCCESS) {
Peng Xu6363ec62017-05-15 11:06:33 -07002306 pe_err("Unable to set BSS color change IE in beacon");
Srinivas Girigowdaeff16d92018-09-12 14:56:29 -07002307 return;
Peng Xu6363ec62017-05-15 11:06:33 -07002308 }
2309
2310 /* Send update beacon template message */
Abhishek Singhfc740be2018-10-12 11:34:26 +05302311 lim_send_beacon_ind(mac_ctx, session, REASON_COLOR_CHANGE);
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07002312 pe_debug("Updated BSS color change countdown = %d",
2313 session->he_bss_color_change.countdown);
Peng Xu6363ec62017-05-15 11:06:33 -07002314}
2315
2316static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002317lim_handle_bss_color_change_ie(struct mac_context *mac_ctx,
Jeff Johnsond7035a32018-11-18 22:03:13 -08002318 struct pe_session *session)
Peng Xu6363ec62017-05-15 11:06:33 -07002319{
Arif Hussain2f2d3512018-03-06 12:37:03 -08002320 tUpdateBeaconParams beacon_params;
2321
Peng Xu6363ec62017-05-15 11:06:33 -07002322 /* handle bss color change IE */
2323 if (LIM_IS_AP_ROLE(session) &&
2324 session->he_op.bss_col_disabled) {
2325 if (session->he_bss_color_change.countdown > 0) {
2326 session->he_bss_color_change.countdown--;
2327 } else {
2328 session->bss_color_changing = 0;
Arif Hussain2f2d3512018-03-06 12:37:03 -08002329 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
Arif Hussain05fb4872018-01-03 16:02:55 -08002330 if (session->he_bss_color_change.new_color != 0) {
Peng Xu6363ec62017-05-15 11:06:33 -07002331 session->he_op.bss_col_disabled = 0;
Arif Hussain05fb4872018-01-03 16:02:55 -08002332 session->he_op.bss_color =
2333 session->he_bss_color_change.new_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08002334 beacon_params.paramChangeBitmap |=
2335 PARAM_BSS_COLOR_CHANGED;
2336 beacon_params.bss_color_disabled = 0;
2337 beacon_params.bss_color =
2338 session->he_op.bss_color;
2339 lim_send_beacon_params(mac_ctx,
2340 &beacon_params,
2341 session);
Arif Hussain05fb4872018-01-03 16:02:55 -08002342 lim_send_obss_color_collision_cfg(mac_ctx,
2343 session,
2344 OBSS_COLOR_COLLISION_DETECTION);
2345 }
Peng Xu6363ec62017-05-15 11:06:33 -07002346 }
2347
2348 lim_send_bss_color_change_ie_update(mac_ctx, session);
2349 }
2350}
2351
2352#else
2353static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002354lim_handle_bss_color_change_ie(struct mac_context *mac_ctx,
Jeff Johnsond7035a32018-11-18 22:03:13 -08002355 struct pe_session *session)
Peng Xu6363ec62017-05-15 11:06:33 -07002356{
2357}
2358#endif
2359
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002360void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002361lim_process_beacon_tx_success_ind(struct mac_context *mac_ctx, uint16_t msgType,
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302362 void *event)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002363{
Jeff Johnsond7035a32018-11-18 22:03:13 -08002364 struct pe_session *session;
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302365 tpSirFirstBeaconTxCompleteInd bcn_ind =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002366 (tSirFirstBeaconTxCompleteInd *) event;
2367
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302368 session = pe_find_session_by_bss_idx(mac_ctx, bcn_ind->bssIdx);
2369 if (!session) {
2370 pe_err("Session Does not exist for given session id");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002371 return;
2372 }
2373
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302374 pe_debug("role: %d swIe: %d opIe: %d switch cnt:%d",
2375 GET_LIM_SYSTEM_ROLE(session),
2376 session->dfsIncludeChanSwIe,
2377 session->gLimOperatingMode.present,
2378 session->gLimChannelSwitch.switchCount);
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302379
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302380 if (!LIM_IS_AP_ROLE(session))
2381 return;
Ganesh Kondabattini02ec62b2018-01-24 18:22:24 +05302382
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302383 if (session->dfsIncludeChanSwIe &&
2384 (session->gLimChannelSwitch.switchCount ==
2385 mac_ctx->sap.SapDfsInfo.sap_ch_switch_beacon_cnt))
2386 lim_process_ap_ecsa_timeout(session);
Ganesh Kondabattini02ec62b2018-01-24 18:22:24 +05302387
lifeng1c16b6b2017-09-25 13:59:55 +08002388
Abhishek Singhfc740be2018-10-12 11:34:26 +05302389 if (session->gLimOperatingMode.present)
2390 /* Done with nss update */
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302391 session->gLimOperatingMode.present = 0;
Peng Xu6363ec62017-05-15 11:06:33 -07002392
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302393 lim_handle_bss_color_change_ie(mac_ctx, session);
Peng Xu6363ec62017-05-15 11:06:33 -07002394
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002395 return;
2396}