blob: 0ffbd88bf543134cfa0c454839d663fb6e8c6744 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Wu Gao6768d762018-12-28 16:31:08 +08002 * Copyright (c) 2012-2019 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
19/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020 * This file lim_send_sme_rspMessages.cc contains the functions
21 * for sending SME response/notification messages to applications
22 * above MAC software.
23 * Author: Chandra Modumudi
24 * Date: 02/13/02
25 * History:-
26 * Date Modified by Modification Information
27 * --------------------------------------------------------------------
28 */
29
Anurag Chouhan6d760662016-02-20 16:05:43 +053030#include "qdf_types.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080031#include "wni_api.h"
32#include "sir_common.h"
33#include "ani_global.h"
34
35#include "wni_cfg.h"
36#include "sys_def.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080037
38#include "sch_api.h"
39#include "utils_api.h"
40#include "lim_utils.h"
41#include "lim_security_utils.h"
42#include "lim_ser_des_utils.h"
43#include "lim_send_sme_rsp_messages.h"
44#include "lim_ibss_peer_mgmt.h"
45#include "lim_session_utils.h"
46#include "lim_types.h"
47#include "sir_api.h"
Naveen Rawat3b6068c2016-04-14 19:01:06 -070048#include "cds_regdomain.h"
Gupta, Kapil121bf212015-11-25 19:21:29 +053049#include "lim_send_messages.h"
Deepak Dhamdhere13983f22016-05-31 19:06:09 -070050#include "nan_datapath.h"
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -070051#include "lim_assoc_utils.h"
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070052#include "wlan_reg_services_api.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070053#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080054
Kabilan Kannanf56f9d52017-04-05 03:31:34 -070055#include "wlan_tdls_tgt_api.h"
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +053056#include "lim_process_fils.h"
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -080057#include "wma.h"
Kabilan Kannanf56f9d52017-04-05 03:31:34 -070058
Jeff Johnson9320c1e2018-12-02 13:09:20 -080059static void lim_handle_join_rsp_status(struct mac_context *mac_ctx,
Jeff Johnsond7035a32018-11-18 22:03:13 -080060 struct pe_session *session_entry, tSirResultCodes result_code,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080061 tpSirSmeJoinRsp sme_join_rsp);
62
63/**
64 * lim_send_sme_rsp() - Send Response to upper layers
65 * @mac_ctx: Pointer to Global MAC structure
66 * @msg_type: Indicates message type
67 * @result_code: Indicates the result of previously issued
68 * eWNI_SME_msg_type_REQ message
69 *
70 * This function is called by lim_process_sme_req_messages() to send
71 * eWNI_SME_START_RSP, eWNI_SME_STOP_BSS_RSP
72 * or eWNI_SME_SWITCH_CHL_RSP messages to applications above MAC
73 * Software.
74 *
75 * Return: None
76 */
77
78void
Jeff Johnson9320c1e2018-12-02 13:09:20 -080079lim_send_sme_rsp(struct mac_context *mac_ctx, uint16_t msg_type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080080 tSirResultCodes result_code, uint8_t sme_session_id,
81 uint16_t sme_transaction_id)
82{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070083 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080084 tSirSmeRsp *sme_rsp;
85
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +053086 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080087 lim_msg_str(msg_type), lim_result_code_str(result_code));
88
Anurag Chouhan600c3a02016-03-01 10:33:54 +053089 sme_rsp = qdf_mem_malloc(sizeof(tSirSmeRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -070090 if (!sme_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080091 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080092
93 sme_rsp->messageType = msg_type;
94 sme_rsp->length = sizeof(tSirSmeRsp);
95 sme_rsp->statusCode = result_code;
96
97 sme_rsp->sessionId = sme_session_id;
98 sme_rsp->transactionId = sme_transaction_id;
99
100 msg.type = msg_type;
101 msg.bodyptr = sme_rsp;
102 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530103 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG,
104 sme_session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800105
106#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
107 switch (msg_type) {
108 case eWNI_SME_STOP_BSS_RSP:
109 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_STOP_BSS_RSP_EVENT,
110 NULL, (uint16_t) result_code, 0);
111 break;
112 }
113#endif /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsona5abe272019-01-06 12:52:02 -0800114 lim_sys_process_mmh_msg_api(mac_ctx, &msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800115}
116
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800117/**
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530118 * lim_get_max_rate_flags() - Get rate flags
119 * @mac_ctx: Pointer to global MAC structure
120 * @sta_ds: Pointer to station ds structure
121 *
122 * This function is called to get the rate flags for a connection
123 * from the station ds structure depending on the ht and the vht
124 * channel width supported.
125 *
126 * Return: Returns the populated rate_flags
127 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800128uint32_t lim_get_max_rate_flags(struct mac_context *mac_ctx, tpDphHashNode sta_ds)
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530129{
130 uint32_t rate_flags = 0;
131
132 if (sta_ds == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530133 pe_err("sta_ds is NULL");
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530134 return rate_flags;
135 }
136
137 if (!sta_ds->mlmStaContext.htCapability &&
138 !sta_ds->mlmStaContext.vhtCapability) {
Naveen Rawatea1564b2018-05-17 15:56:11 -0700139 rate_flags |= TX_RATE_LEGACY;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530140 } else {
141 if (sta_ds->mlmStaContext.vhtCapability) {
142 if (WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ ==
143 sta_ds->vhtSupportedChannelWidthSet) {
Naveen Rawatea1564b2018-05-17 15:56:11 -0700144 rate_flags |= TX_RATE_VHT80;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530145 } else if (WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ ==
146 sta_ds->vhtSupportedChannelWidthSet) {
147 if (sta_ds->htSupportedChannelWidthSet)
Naveen Rawatea1564b2018-05-17 15:56:11 -0700148 rate_flags |= TX_RATE_VHT40;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530149 else
Naveen Rawatea1564b2018-05-17 15:56:11 -0700150 rate_flags |= TX_RATE_VHT20;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530151 }
152 } else if (sta_ds->mlmStaContext.htCapability) {
153 if (sta_ds->htSupportedChannelWidthSet)
Naveen Rawatea1564b2018-05-17 15:56:11 -0700154 rate_flags |= TX_RATE_HT40;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530155 else
Naveen Rawatea1564b2018-05-17 15:56:11 -0700156 rate_flags |= TX_RATE_HT20;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530157 }
158 }
159
160 if (sta_ds->htShortGI20Mhz || sta_ds->htShortGI40Mhz)
Naveen Rawatea1564b2018-05-17 15:56:11 -0700161 rate_flags |= TX_RATE_SGI;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530162
163 return rate_flags;
164}
165
166/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800167 * lim_send_sme_join_reassoc_rsp_after_resume() - Send Response to SME
168 * @mac_ctx Pointer to Global MAC structure
169 * @status Resume link status
170 * @ctx context passed while calling resmune link.
171 * (join response to be sent)
172 *
173 * This function is called to send Join/Reassoc rsp
174 * message to SME after the resume link.
175 *
176 * Return: None
177 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800178static void lim_send_sme_join_reassoc_rsp_after_resume(struct mac_context *mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530179 QDF_STATUS status, uint32_t *ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800180{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700181 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800182 tpSirSmeJoinRsp sme_join_rsp = (tpSirSmeJoinRsp) ctx;
183
184 msg.type = sme_join_rsp->messageType;
185 msg.bodyptr = sme_join_rsp;
186 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530187 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, NO_SESSION, msg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -0800188 lim_sys_process_mmh_msg_api(mac_ctx, &msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800189}
190
191/**
192 * lim_handle_join_rsp_status() - Handle the response.
193 * @mac_ctx: Pointer to Global MAC structure
194 * @session_entry: PE Session Info
195 * @result_code: Indicates the result of previously issued
196 * eWNI_SME_msgType_REQ message
197 * @sme_join_rsp The received response.
198 *
199 * This function will handle both the success and failure status
200 * of the received response.
201 *
202 * Return: None
203 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800204static void lim_handle_join_rsp_status(struct mac_context *mac_ctx,
Jeff Johnsond7035a32018-11-18 22:03:13 -0800205 struct pe_session *session_entry, tSirResultCodes result_code,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800206 tpSirSmeJoinRsp sme_join_rsp)
207{
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700208 uint16_t bss_ie_len;
209 void *bss_ies;
210 bool is_vendor_ap_1_present;
Wu Gao2968fc92017-06-19 19:18:34 +0800211 tpSirSmeJoinReq join_reassoc_req = NULL;
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700212
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800213#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
Jeff Johnson704af112019-02-02 16:11:55 -0800214 struct ht_profile *ht_profile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800215#endif
216 if (result_code == eSIR_SME_SUCCESS) {
217 if (session_entry->beacon != NULL) {
218 sme_join_rsp->beaconLength = session_entry->bcnLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530219 qdf_mem_copy(sme_join_rsp->frames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800220 session_entry->beacon,
221 sme_join_rsp->beaconLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530222 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800223 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530224 session_entry->bcnLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530225 pe_debug("Beacon: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530226 sme_join_rsp->beaconLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227 }
228 if (session_entry->assocReq != NULL) {
229 sme_join_rsp->assocReqLength =
230 session_entry->assocReqLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530231 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530232 sme_join_rsp->beaconLength,
233 session_entry->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800234 sme_join_rsp->assocReqLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530235 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800236 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530237 session_entry->assocReqLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530238 pe_debug("AssocReq: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530239 sme_join_rsp->assocReqLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800240 }
241 if (session_entry->assocRsp != NULL) {
242 sme_join_rsp->assocRspLength =
243 session_entry->assocRspLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530244 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530245 sme_join_rsp->beaconLength +
246 sme_join_rsp->assocReqLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800247 session_entry->assocRsp,
248 sme_join_rsp->assocRspLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530249 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800250 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530251 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800252 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800253 if (session_entry->ricData != NULL) {
254 sme_join_rsp->parsedRicRspLen =
255 session_entry->RICDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530256 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530257 sme_join_rsp->beaconLength +
258 sme_join_rsp->assocReqLength +
259 sme_join_rsp->assocRspLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800260 session_entry->ricData,
261 sme_join_rsp->parsedRicRspLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530262 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800263 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530264 session_entry->RICDataLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530265 pe_debug("RicLength: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800266 sme_join_rsp->parsedRicRspLen);
267 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800268#ifdef FEATURE_WLAN_ESE
269 if (session_entry->tspecIes != NULL) {
270 sme_join_rsp->tspecIeLen =
271 session_entry->tspecLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530272 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530273 sme_join_rsp->beaconLength +
274 sme_join_rsp->assocReqLength +
275 sme_join_rsp->assocRspLength +
276 sme_join_rsp->parsedRicRspLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800277 session_entry->tspecIes,
278 sme_join_rsp->tspecIeLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530279 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800280 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530281 session_entry->tspecLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530282 pe_debug("ESE-TspecLen: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530283 sme_join_rsp->tspecIeLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800284 }
285#endif
286 sme_join_rsp->aid = session_entry->limAID;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530287 pe_debug("AssocRsp: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530288 sme_join_rsp->assocRspLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800289 sme_join_rsp->vht_channel_width =
290 session_entry->ch_width;
291#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
292 if (session_entry->cc_switch_mode !=
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530293 QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800294 ht_profile = &sme_join_rsp->HTProfile;
295 ht_profile->htSupportedChannelWidthSet =
296 session_entry->htSupportedChannelWidthSet;
297 ht_profile->htRecommendedTxWidthSet =
298 session_entry->htRecommendedTxWidthSet;
299 ht_profile->htSecondaryChannelOffset =
300 session_entry->htSecondaryChannelOffset;
301 ht_profile->dot11mode = session_entry->dot11mode;
302 ht_profile->htCapability = session_entry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800303 ht_profile->vhtCapability =
304 session_entry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800305 ht_profile->apCenterChan = session_entry->ch_center_freq_seg0;
306 ht_profile->apChanWidth = session_entry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800307 }
308#endif
Jeff Johnson11bd4f32017-09-18 08:15:17 -0700309 pe_debug("pLimJoinReq:%pK, pLimReAssocReq:%pK",
Wu Gao2968fc92017-06-19 19:18:34 +0800310 session_entry->pLimJoinReq,
311 session_entry->pLimReAssocReq);
312
313 if (session_entry->pLimJoinReq)
314 join_reassoc_req = session_entry->pLimJoinReq;
315
316 if (session_entry->pLimReAssocReq)
317 join_reassoc_req = session_entry->pLimReAssocReq;
318
319 if (!join_reassoc_req) {
320 pe_err("both pLimJoinReq and pLimReAssocReq NULL");
321 return;
322 }
323
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700324 bss_ie_len = lim_get_ielen_from_bss_description(
Wu Gao2968fc92017-06-19 19:18:34 +0800325 &join_reassoc_req->bssDescription);
326 bss_ies = &join_reassoc_req->bssDescription.ieFields;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700327 is_vendor_ap_1_present = (wlan_get_vendor_ie_ptr_from_oui(
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700328 SIR_MAC_VENDOR_AP_1_OUI, SIR_MAC_VENDOR_AP_1_OUI_LEN,
329 bss_ies, bss_ie_len) != NULL);
330
331 if (mac_ctx->roam.configParam.is_force_1x1 &&
Krunal Sonie6a1cda2017-09-27 15:23:02 -0700332 is_vendor_ap_1_present && (session_entry->nss == 2) &&
333 (mac_ctx->lteCoexAntShare == 0 ||
334 IS_5G_CH(session_entry->currentOperChannel))) {
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700335 /* SET vdev param */
336 pe_debug("sending SMPS intolrent vdev_param");
337 wma_cli_set_command(session_entry->smeSessionId,
338 (int)WMI_VDEV_PARAM_SMPS_INTOLERANT,
339 1, VDEV_CMD);
340
341 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800342 } else {
343 if (session_entry->beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530344 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800345 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530346 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800347 }
348 if (session_entry->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530349 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800350 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530351 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800352 }
353 if (session_entry->assocRsp != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530354 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800355 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530356 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800357 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800358 if (session_entry->ricData != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530359 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800360 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530361 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800362 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800363#ifdef FEATURE_WLAN_ESE
364 if (session_entry->tspecIes != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530365 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800366 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530367 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800368 }
369#endif
370 }
371}
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530372
373/**
374 * lim_add_bss_info() - copy data from session entry to join rsp
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530375 * @sta_ds: Station dph entry
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530376 * @sme_join_rsp: Join response buffer to be filled up
377 *
378 * Return: None
379 */
Jeff Johnson6db011e2016-10-07 07:31:39 -0700380static void lim_add_bss_info(tpDphHashNode sta_ds, tpSirSmeJoinRsp sme_join_rsp)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530381{
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530382 struct parsed_ies *parsed_ies = &sta_ds->parsed_ies;
383
384 if (parsed_ies->hs20vendor_ie.present)
385 sme_join_rsp->hs20vendor_ie = parsed_ies->hs20vendor_ie;
386 if (parsed_ies->vht_caps.present)
387 sme_join_rsp->vht_caps = parsed_ies->vht_caps;
388 if (parsed_ies->ht_caps.present)
389 sme_join_rsp->ht_caps = parsed_ies->ht_caps;
390 if (parsed_ies->ht_operation.present)
391 sme_join_rsp->ht_operation = parsed_ies->ht_operation;
392 if (parsed_ies->vht_operation.present)
393 sme_join_rsp->vht_operation = parsed_ies->vht_operation;
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530394}
395
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530396#ifdef WLAN_FEATURE_FILS_SK
397static void lim_update_fils_seq_num(tpSirSmeJoinRsp sme_join_rsp,
Jeff Johnsond7035a32018-11-18 22:03:13 -0800398 struct pe_session *session_entry)
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530399{
400 sme_join_rsp->fils_seq_num =
401 session_entry->fils_info->sequence_number;
402}
403#else
404static inline void lim_update_fils_seq_num(tpSirSmeJoinRsp sme_join_rsp,
Jeff Johnsond7035a32018-11-18 22:03:13 -0800405 struct pe_session *session_entry)
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530406{}
407#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800408/**
409 * lim_send_sme_join_reassoc_rsp() - Send Response to Upper Layers
410 * @mac_ctx: Pointer to Global MAC structure
411 * @msg_type: Indicates message type
412 * @result_code: Indicates the result of previously issued
413 * eWNI_SME_msgType_REQ message
414 * @prot_status_code: Protocol Status Code
415 * @session_entry: PE Session Info
416 * @sme_session_id: SME Session ID
417 * @sme_transaction_id: SME Transaction ID
418 *
419 * This function is called by lim_process_sme_req_messages() to send
420 * eWNI_SME_JOIN_RSP or eWNI_SME_REASSOC_RSP messages to applications
421 * above MAC Software.
422 *
423 * Return: None
424 */
425
426void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800427lim_send_sme_join_reassoc_rsp(struct mac_context *mac_ctx, uint16_t msg_type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800428 tSirResultCodes result_code, uint16_t prot_status_code,
Jeff Johnsond7035a32018-11-18 22:03:13 -0800429 struct pe_session *session_entry, uint8_t sme_session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800430 uint16_t sme_transaction_id)
431{
432 tpSirSmeJoinRsp sme_join_rsp;
433 uint32_t rsp_len;
434 tpDphHashNode sta_ds = NULL;
435#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
436 if (msg_type == eWNI_SME_REASSOC_RSP)
437 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_RSP_EVENT,
438 session_entry, (uint16_t) result_code, 0);
439 else
440 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_RSP_EVENT,
441 session_entry, (uint16_t) result_code, 0);
442#endif /* FEATURE_WLAN_DIAG_SUPPORT */
443
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530444 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800445 lim_msg_str(msg_type), lim_result_code_str(result_code));
446
447 if (session_entry == NULL) {
448 rsp_len = sizeof(tSirSmeJoinRsp);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530449 sme_join_rsp = qdf_mem_malloc(rsp_len);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700450 if (!sme_join_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800451 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800452
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800453 sme_join_rsp->beaconLength = 0;
454 sme_join_rsp->assocReqLength = 0;
455 sme_join_rsp->assocRspLength = 0;
456 } else {
457 rsp_len = session_entry->assocReqLen +
458 session_entry->assocRspLen + session_entry->bcnLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800459 session_entry->RICDataLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800460#ifdef FEATURE_WLAN_ESE
461 session_entry->tspecLen +
462#endif
463 sizeof(tSirSmeJoinRsp) - sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530464 sme_join_rsp = qdf_mem_malloc(rsp_len);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700465 if (!sme_join_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800466 return;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530467
468 if (lim_is_fils_connection(session_entry)) {
469 sme_join_rsp->is_fils_connection = true;
470 lim_update_fils_seq_num(sme_join_rsp,
471 session_entry);
472 }
473
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800474 if (result_code == eSIR_SME_SUCCESS) {
475 sta_ds = dph_get_hash_entry(mac_ctx,
476 DPH_STA_HASH_INDEX_PEER,
477 &session_entry->dph.dphHashTable);
478 if (sta_ds == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530479 pe_err("Get Self Sta Entry fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800480 } else {
481 /* Pass the peer's staId */
482 sme_join_rsp->staId = sta_ds->staIndex;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800483 sme_join_rsp->timingMeasCap =
484 sta_ds->timingMeasCap;
485#ifdef FEATURE_WLAN_TDLS
486 sme_join_rsp->tdls_prohibited =
487 session_entry->tdls_prohibited;
488 sme_join_rsp->tdls_chan_swit_prohibited =
489 session_entry->tdls_chan_swit_prohibited;
490#endif
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530491 sme_join_rsp->nss = sta_ds->nss;
492 sme_join_rsp->max_rate_flags =
493 lim_get_max_rate_flags(mac_ctx, sta_ds);
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530494 lim_add_bss_info(sta_ds, sme_join_rsp);
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530495
496 /* Copy FILS params only for Successful join */
497 populate_fils_connect_params(mac_ctx,
498 session_entry, sme_join_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800499 }
500 }
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530501
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800502 sme_join_rsp->beaconLength = 0;
503 sme_join_rsp->assocReqLength = 0;
504 sme_join_rsp->assocRspLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800505 sme_join_rsp->parsedRicRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800506#ifdef FEATURE_WLAN_ESE
507 sme_join_rsp->tspecIeLen = 0;
508#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800509 lim_handle_join_rsp_status(mac_ctx, session_entry, result_code,
510 sme_join_rsp);
Bala Venkateshe7f79162019-01-16 16:43:59 +0530511 sme_join_rsp->uapsd_mask = session_entry->gUapsdPerAcBitmask;
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800512 /* Send supported NSS 1x1 to SME */
513 sme_join_rsp->supported_nss_1x1 =
514 session_entry->supported_nss_1x1;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530515 pe_debug("SME Join Rsp is supported NSS 1X1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800516 sme_join_rsp->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800517 }
518
519 sme_join_rsp->messageType = msg_type;
520 sme_join_rsp->length = (uint16_t) rsp_len;
521 sme_join_rsp->statusCode = result_code;
522 sme_join_rsp->protStatusCode = prot_status_code;
523
524 sme_join_rsp->sessionId = sme_session_id;
525 sme_join_rsp->transactionId = sme_transaction_id;
526
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530527 lim_send_sme_join_reassoc_rsp_after_resume(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800528 (uint32_t *)sme_join_rsp);
529}
530
531/**
532 * lim_send_sme_start_bss_rsp()
533 *
534 ***FUNCTION:
535 * This function is called to send eWNI_SME_START_BSS_RSP
536 * message to applications above MAC Software.
537 *
538 ***PARAMS:
539 *
540 ***LOGIC:
541 *
542 ***ASSUMPTIONS:
543 * NA
544 *
545 ***NOTE:
546 * NA
547 *
Jeff Johnson35c58a82018-11-22 15:04:57 -0800548 * @param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800549 * @param msgType Indicates message type
550 * @param resultCode Indicates the result of previously issued
551 * eWNI_SME_msgType_REQ message
552 *
553 * @return None
554 */
555
556void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800557lim_send_sme_start_bss_rsp(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800558 uint16_t msgType, tSirResultCodes resultCode,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800559 struct pe_session *pe_session, uint8_t smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800560 uint16_t smetransactionId)
561{
562
563 uint16_t size = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700564 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800565 tSirSmeStartBssRsp *pSirSmeRsp;
566 uint16_t ieLen;
567 uint16_t ieOffset, curLen;
568
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530569 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800570 lim_msg_str(msgType), lim_result_code_str(resultCode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800571
572 size = sizeof(tSirSmeStartBssRsp);
573
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800574 if (pe_session == NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530575 pSirSmeRsp = qdf_mem_malloc(size);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700576 if (!pSirSmeRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800577 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800578 } else {
579 /* subtract size of beaconLength + Mac Hdr + Fixed Fields before SSID */
580 ieOffset = sizeof(tAniBeaconStruct) + SIR_MAC_B_PR_SSID_OFFSET;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800581 ieLen = pe_session->schBeaconOffsetBegin
582 + pe_session->schBeaconOffsetEnd - ieOffset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800583 /* calculate the memory size to allocate */
584 size += ieLen;
585
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530586 pSirSmeRsp = qdf_mem_malloc(size);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700587 if (!pSirSmeRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800588 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800589 size = sizeof(tSirSmeStartBssRsp);
590 if (resultCode == eSIR_SME_SUCCESS) {
591
592 sir_copy_mac_addr(pSirSmeRsp->bssDescription.bssId,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800593 pe_session->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800594
595 /* Read beacon interval from session */
596 pSirSmeRsp->bssDescription.beaconInterval =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800597 (uint16_t) pe_session->beaconParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800598 beaconInterval;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800599 pSirSmeRsp->bssType = pe_session->bssType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800600
Wu Gao5c3d94b2019-01-17 21:15:54 +0800601 if (lim_get_capability_info
Jeff Johnson35c58a82018-11-22 15:04:57 -0800602 (mac, &pSirSmeRsp->bssDescription.capabilityInfo,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800603 pe_session)
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700604 != QDF_STATUS_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530605 pe_err("could not retrieve Capabilities value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800606
Jeff Johnson35c58a82018-11-22 15:04:57 -0800607 lim_get_phy_mode(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800608 (uint32_t *) &pSirSmeRsp->bssDescription.
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800609 nwType, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800610
611 pSirSmeRsp->bssDescription.channelId =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800612 pe_session->currentOperChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800613
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800614 if (!LIM_IS_NDI_ROLE(pe_session)) {
615 curLen = pe_session->schBeaconOffsetBegin - ieOffset;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530616 qdf_mem_copy((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800617 ieFields,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800618 pe_session->pSchBeaconFrameBegin +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800619 ieOffset, (uint32_t) curLen);
620
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530621 qdf_mem_copy(((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800622 ieFields) + curLen,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800623 pe_session->pSchBeaconFrameEnd,
624 (uint32_t) pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800625 schBeaconOffsetEnd);
626
Abhishek Singh34a4d862016-10-26 16:01:51 +0530627 pSirSmeRsp->bssDescription.length = (uint16_t)
628 (offsetof(tSirBssDescription, ieFields[0])
629 - sizeof(pSirSmeRsp->bssDescription.length)
630 + ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800631 /* This is the size of the message, subtracting the size of the pointer to ieFields */
632 size += ieLen - sizeof(uint32_t);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700633 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800634#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800635 if (pe_session->cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530636 != QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800637 pSirSmeRsp->HTProfile.
638 htSupportedChannelWidthSet =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800639 pe_session->htSupportedChannelWidthSet;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800640 pSirSmeRsp->HTProfile.htRecommendedTxWidthSet =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800641 pe_session->htRecommendedTxWidthSet;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800642 pSirSmeRsp->HTProfile.htSecondaryChannelOffset =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800643 pe_session->htSecondaryChannelOffset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800644 pSirSmeRsp->HTProfile.dot11mode =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800645 pe_session->dot11mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800646 pSirSmeRsp->HTProfile.htCapability =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800647 pe_session->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800648 pSirSmeRsp->HTProfile.vhtCapability =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800649 pe_session->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800650 pSirSmeRsp->HTProfile.apCenterChan =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800651 pe_session->ch_center_freq_seg0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800652 pSirSmeRsp->HTProfile.apChanWidth =
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800653 pe_session->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800654 }
655#endif
656 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800657 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800658 pSirSmeRsp->messageType = msgType;
659 pSirSmeRsp->length = size;
660
661 /* Update SME session Id and transaction Id */
662 pSirSmeRsp->sessionId = smesessionId;
663 pSirSmeRsp->transactionId = smetransactionId;
664 pSirSmeRsp->statusCode = resultCode;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800665 if (pe_session != NULL)
666 pSirSmeRsp->staId = pe_session->staId; /* else it will be always zero smeRsp StaID = 0 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800667
668 mmhMsg.type = msgType;
669 mmhMsg.bodyptr = pSirSmeRsp;
670 mmhMsg.bodyval = 0;
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800671 if (pe_session == NULL) {
Jeff Johnson35c58a82018-11-22 15:04:57 -0800672 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530673 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800674 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -0800675 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800676 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800677 }
678#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -0800679 lim_diag_event_report(mac, WLAN_PE_DIAG_START_BSS_RSP_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800680 pe_session, (uint16_t) resultCode, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800681#endif /* FEATURE_WLAN_DIAG_SUPPORT */
682
Jeff Johnsona5abe272019-01-06 12:52:02 -0800683 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800684} /*** end lim_send_sme_start_bss_rsp() ***/
685
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800686void lim_send_sme_disassoc_deauth_ntf(struct mac_context *mac,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530687 QDF_STATUS status, uint32_t *pCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800688{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700689 struct scheduler_msg mmhMsg = {0};
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800690 struct scheduler_msg *pMsg = (struct scheduler_msg *) pCtx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800691
692 mmhMsg.type = pMsg->type;
693 mmhMsg.bodyptr = pMsg;
694 mmhMsg.bodyval = 0;
695
Jeff Johnson35c58a82018-11-22 15:04:57 -0800696 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800697
Jeff Johnsona5abe272019-01-06 12:52:02 -0800698 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800699}
700
701/**
702 * lim_send_sme_disassoc_ntf()
703 *
704 ***FUNCTION:
705 * This function is called by limProcessSmeMessages() to send
706 * eWNI_SME_DISASSOC_RSP/IND message to host
707 *
708 ***PARAMS:
709 *
710 ***LOGIC:
711 *
712 ***ASSUMPTIONS:
713 * NA
714 *
715 ***NOTE:
716 * This function is used for sending eWNI_SME_DISASSOC_CNF,
717 * or eWNI_SME_DISASSOC_IND to host depending on
718 * disassociation trigger.
719 *
720 * @param peerMacAddr Indicates the peer MAC addr to which
721 * disassociate was initiated
722 * @param reasonCode Indicates the reason for Disassociation
723 * @param disassocTrigger Indicates the trigger for Disassociation
724 * @param aid Indicates the STAID. This parameter is
725 * present only on AP.
726 *
727 * @return None
728 */
729void
Jeff Johnson9320c1e2018-12-02 13:09:20 -0800730lim_send_sme_disassoc_ntf(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800731 tSirMacAddr peerMacAddr,
732 tSirResultCodes reasonCode,
733 uint16_t disassocTrigger,
734 uint16_t aid,
735 uint8_t smesessionId,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800736 uint16_t smetransactionId, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800737{
738
739 uint8_t *pBuf;
740 tSirSmeDisassocRsp *pSirSmeDisassocRsp;
741 tSirSmeDisassocInd *pSirSmeDisassocInd;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700742 uint32_t *pMsg = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800743 bool failure = false;
Jeff Johnsond7035a32018-11-18 22:03:13 -0800744 struct pe_session *session = NULL;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700745 uint16_t i, assoc_id;
746 tpDphHashNode sta_ds = NULL;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +0530747 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800748
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530749 pe_debug("Disassoc Ntf with trigger : %d reasonCode: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800750 disassocTrigger, reasonCode);
751
752 switch (disassocTrigger) {
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700753 case eLIM_DUPLICATE_ENTRY:
754 /*
755 * Duplicate entry is removed at LIM.
756 * Initiate new entry for other session
757 */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530758 pe_debug("Rcvd eLIM_DUPLICATE_ENTRY for " MAC_ADDRESS_STR,
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700759 MAC_ADDR_ARRAY(peerMacAddr));
760
Jeff Johnson35c58a82018-11-22 15:04:57 -0800761 for (i = 0; i < mac->lim.maxBssId; i++) {
762 if ((&mac->lim.gpSession[i] != NULL) &&
763 (mac->lim.gpSession[i].valid) &&
764 (mac->lim.gpSession[i].pePersona ==
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700765 QDF_SAP_MODE)) {
766 /* Find the sta ds entry in another session */
Jeff Johnson35c58a82018-11-22 15:04:57 -0800767 session = &mac->lim.gpSession[i];
768 sta_ds = dph_lookup_hash_entry(mac,
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700769 peerMacAddr, &assoc_id,
770 &session->dph.dphHashTable);
Abhishek Singh6d6e3d12017-12-04 14:16:00 +0530771 if (sta_ds)
772 break;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700773 }
774 }
775 if (sta_ds
776#ifdef WLAN_FEATURE_11W
777 && (!sta_ds->rmfEnabled)
778#endif
779 ) {
Jeff Johnson35c58a82018-11-22 15:04:57 -0800780 if (lim_add_sta(mac, sta_ds, false, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700781 QDF_STATUS_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530782 pe_err("could not Add STA with assocId: %d",
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700783 sta_ds->assocId);
784 }
Jeff Johnson35c58a82018-11-22 15:04:57 -0800785 status = lim_prepare_disconnect_done_ind(mac, &pMsg,
Pragaspathi Thilagaraj766c76f2018-08-08 16:44:40 +0530786 smesessionId,
787 reasonCode,
788 &peerMacAddr[0]);
789 if (!QDF_IS_STATUS_SUCCESS(status)) {
790 pe_err("Failed to prepare message");
791 return;
792 }
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700793 break;
794
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800795 case eLIM_HOST_DISASSOC:
796 /**
797 * Disassociation response due to
798 * host triggered disassociation
799 */
800
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530801 pSirSmeDisassocRsp = qdf_mem_malloc(sizeof(tSirSmeDisassocRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700802 if (!pSirSmeDisassocRsp) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800803 failure = true;
804 goto error;
805 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530806 pe_debug("send eWNI_SME_DISASSOC_RSP with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800807 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
808 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
809 pSirSmeDisassocRsp->length = sizeof(tSirSmeDisassocRsp);
810 /* sessionId */
811 pBuf = (uint8_t *) &pSirSmeDisassocRsp->sessionId;
812 *pBuf = smesessionId;
813 pBuf++;
814
815 /* transactionId */
816 lim_copy_u16(pBuf, smetransactionId);
817 pBuf += sizeof(uint16_t);
818
819 /* statusCode */
820 lim_copy_u32(pBuf, reasonCode);
821 pBuf += sizeof(tSirResultCodes);
822
823 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530824 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800825 pBuf += sizeof(tSirMacAddr);
826
827 /* Clear Station Stats */
828 /* for sta, it is always 1, IBSS is handled at halInitSta */
829
830#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
831
Jeff Johnson35c58a82018-11-22 15:04:57 -0800832 lim_diag_event_report(mac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800833 pe_session, (uint16_t) reasonCode, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800834#endif
835 pMsg = (uint32_t *) pSirSmeDisassocRsp;
836 break;
837
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530838 case eLIM_PEER_ENTITY_DISASSOC:
839 case eLIM_LINK_MONITORING_DISASSOC:
Jeff Johnson35c58a82018-11-22 15:04:57 -0800840 status = lim_prepare_disconnect_done_ind(mac, &pMsg,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +0530841 smesessionId,
842 reasonCode, &peerMacAddr[0]);
843 if (!QDF_IS_STATUS_SUCCESS(status)) {
844 pe_err("Failed to prepare message");
845 return;
846 }
847 break;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530848
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800849 default:
850 /**
851 * Disassociation indication due to Disassociation
852 * frame reception from peer entity or due to
853 * loss of link with peer entity.
854 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530855 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700856 if (!pSirSmeDisassocInd) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800857 failure = true;
858 goto error;
859 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530860 pe_debug("send eWNI_SME_DISASSOC_IND with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800861 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
862 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
863 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
864
865 /* Update SME session Id and Transaction Id */
866 pSirSmeDisassocInd->sessionId = smesessionId;
867 pSirSmeDisassocInd->transactionId = smetransactionId;
868 pSirSmeDisassocInd->reasonCode = reasonCode;
869 pBuf = (uint8_t *) &pSirSmeDisassocInd->statusCode;
870
871 lim_copy_u32(pBuf, reasonCode);
872 pBuf += sizeof(tSirResultCodes);
873
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800874 qdf_mem_copy(pBuf, pe_session->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800875 pBuf += sizeof(tSirMacAddr);
876
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530877 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800878
879#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -0800880 lim_diag_event_report(mac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800881 pe_session, (uint16_t) reasonCode, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800882#endif
883 pMsg = (uint32_t *) pSirSmeDisassocInd;
884
885 break;
886 }
887
888error:
889 /* Delete the PE session Created */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800890 if ((pe_session != NULL) && LIM_IS_STA_ROLE(pe_session))
891 pe_delete_session(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800892
893 if (false == failure)
Jeff Johnson35c58a82018-11-22 15:04:57 -0800894 lim_send_sme_disassoc_deauth_ntf(mac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800895 (uint32_t *) pMsg);
896} /*** end lim_send_sme_disassoc_ntf() ***/
897
898/** -----------------------------------------------------------------
899 \brief lim_send_sme_disassoc_ind() - sends SME_DISASSOC_IND
900
901 After receiving disassociation frame from peer entity, this
902 function sends a eWNI_SME_DISASSOC_IND to SME with a specific
903 reason code.
904
Jeff Johnson35c58a82018-11-22 15:04:57 -0800905 \param mac - global mac structure
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800906 \param sta - station dph hash node
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800907 \return none
908 \sa
909 ----------------------------------------------------------------- */
910void
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800911lim_send_sme_disassoc_ind(struct mac_context *mac, tpDphHashNode sta,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800912 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800913{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700914 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800915 tSirSmeDisassocInd *pSirSmeDisassocInd;
916
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530917 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700918 if (!pSirSmeDisassocInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800919 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800920
921 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
922 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
923
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800924 pSirSmeDisassocInd->sessionId = pe_session->smeSessionId;
925 pSirSmeDisassocInd->transactionId = pe_session->transactionId;
Padma, Santhosh Kumar02289212016-09-30 13:30:08 +0530926 pSirSmeDisassocInd->statusCode = eSIR_SME_DEAUTH_STATUS;
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800927 pSirSmeDisassocInd->reasonCode = sta->mlmStaContext.disassocReason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800928
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800929 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes, pe_session->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530930 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800931
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800932 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes, sta->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530933 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800934
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800935 pSirSmeDisassocInd->staId = sta->staIndex;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800936
937 mmhMsg.type = eWNI_SME_DISASSOC_IND;
938 mmhMsg.bodyptr = pSirSmeDisassocInd;
939 mmhMsg.bodyval = 0;
940
Jeff Johnson35c58a82018-11-22 15:04:57 -0800941 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800942 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800943#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800944 lim_diag_event_report(mac, WLAN_PE_DIAG_DISASSOC_IND_EVENT, pe_session,
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800945 0, (uint16_t) sta->mlmStaContext.disassocReason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800946#endif /* FEATURE_WLAN_DIAG_SUPPORT */
947
Jeff Johnsona5abe272019-01-06 12:52:02 -0800948 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800949
950} /*** end lim_send_sme_disassoc_ind() ***/
951
952/** -----------------------------------------------------------------
953 \brief lim_send_sme_deauth_ind() - sends SME_DEAUTH_IND
954
955 After receiving deauthentication frame from peer entity, this
956 function sends a eWNI_SME_DEAUTH_IND to SME with a specific
957 reason code.
958
Jeff Johnson35c58a82018-11-22 15:04:57 -0800959 \param mac - global mac structure
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800960 \param sta - station dph hash node
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800961 \return none
962 \sa
963 ----------------------------------------------------------------- */
964void
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800965lim_send_sme_deauth_ind(struct mac_context *mac, tpDphHashNode sta,
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800966 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800967{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700968 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800969 tSirSmeDeauthInd *pSirSmeDeauthInd;
970
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530971 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700972 if (!pSirSmeDeauthInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800973 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800974
975 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
976 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
977
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800978 pSirSmeDeauthInd->sessionId = pe_session->smeSessionId;
979 pSirSmeDeauthInd->transactionId = pe_session->transactionId;
980 if (eSIR_INFRA_AP_MODE == pe_session->bssType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800981 pSirSmeDeauthInd->statusCode =
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800982 (tSirResultCodes) sta->mlmStaContext.cleanupTrigger;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800983 } else {
984 /* Need to indicatet he reascon code over the air */
985 pSirSmeDeauthInd->statusCode =
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800986 (tSirResultCodes) sta->mlmStaContext.disassocReason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800987 }
988 /* BSSID */
Jeff Johnsonb5c13332018-12-03 09:54:51 -0800989 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, pe_session->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530990 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800991 /* peerMacAddr */
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800992 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, sta->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530993 QDF_MAC_ADDR_SIZE);
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800994 pSirSmeDeauthInd->reasonCode = sta->mlmStaContext.disassocReason;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800995
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800996 pSirSmeDeauthInd->staId = sta->staIndex;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -0800997 if (eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON ==
Jeff Johnsonbddc03e2019-01-17 15:37:09 -0800998 sta->mlmStaContext.disassocReason)
999 pSirSmeDeauthInd->rssi = sta->del_sta_ctx_rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001000
1001 mmhMsg.type = eWNI_SME_DEAUTH_IND;
1002 mmhMsg.bodyptr = pSirSmeDeauthInd;
1003 mmhMsg.bodyval = 0;
1004
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001005 MTRACE(mac_trace_msg_tx(mac, pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001006#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001007 lim_diag_event_report(mac, WLAN_PE_DIAG_DEAUTH_IND_EVENT, pe_session,
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08001008 0, sta->mlmStaContext.cleanupTrigger);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001009#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1010
Jeff Johnsona5abe272019-01-06 12:52:02 -08001011 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001012 return;
1013} /*** end lim_send_sme_deauth_ind() ***/
1014
1015#ifdef FEATURE_WLAN_TDLS
1016/**
1017 * lim_send_sme_tdls_del_sta_ind()
1018 *
1019 ***FUNCTION:
1020 * This function is called to send the TDLS STA context deletion to SME.
1021 *
1022 ***LOGIC:
1023 *
1024 ***ASSUMPTIONS:
1025 *
1026 ***NOTE:
1027 * NA
1028 *
Jeff Johnson35c58a82018-11-22 15:04:57 -08001029 * @param mac - Pointer to global MAC structure
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08001030 * @param sta - Pointer to internal STA Datastructure
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001031 * @param pe_session - Pointer to the session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001032 * @param reasonCode - Reason for TDLS sta deletion
1033 * @return None
1034 */
1035void
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08001036lim_send_sme_tdls_del_sta_ind(struct mac_context *mac, tpDphHashNode sta,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001037 struct pe_session *pe_session, uint16_t reasonCode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001038{
Frank Liud1a28462017-09-06 22:55:48 +08001039 struct tdls_event_info info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301041 pe_debug("Delete TDLS Peer "MAC_ADDRESS_STR "with reason code: %d",
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08001042 MAC_ADDR_ARRAY(sta->staAddr), reasonCode);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001043 info.vdev_id = pe_session->smeSessionId;
Jeff Johnsonbddc03e2019-01-17 15:37:09 -08001044 qdf_mem_copy(info.peermac.bytes, sta->staAddr, QDF_MAC_ADDR_SIZE);
Frank Liud1a28462017-09-06 22:55:48 +08001045 info.message_type = TDLS_PEER_DISCONNECTED;
1046 info.peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001047
Jeff Johnson35c58a82018-11-22 15:04:57 -08001048 tgt_tdls_event_handler(mac->psoc, &info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001049
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001050 return;
1051} /*** end lim_send_sme_tdls_del_sta_ind() ***/
1052
1053/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001054 * lim_send_sme_mgmt_tx_completion()
1055 *
1056 ***FUNCTION:
1057 * This function is called to send the eWNI_SME_MGMT_FRM_TX_COMPLETION_IND
1058 * message to SME.
1059 *
1060 ***LOGIC:
1061 *
1062 ***ASSUMPTIONS:
1063 *
1064 ***NOTE:
1065 * NA
1066 *
Jeff Johnson35c58a82018-11-22 15:04:57 -08001067 * @param mac - Pointer to global MAC structure
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001068 * @param pe_session - Pointer to the session entry
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001069 * @param txCompleteStatus - TX Complete Status of Mgmt Frames
1070 * @return None
1071 */
1072void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001073lim_send_sme_mgmt_tx_completion(struct mac_context *mac,
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301074 uint32_t sme_session_id,
1075 uint32_t txCompleteStatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001076{
Wu Gao6768d762018-12-28 16:31:08 +08001077 struct scheduler_msg msg = {0};
1078 struct tdls_mgmt_tx_completion_ind *mgmt_tx_completion_ind;
1079 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001080
Wu Gao6768d762018-12-28 16:31:08 +08001081 mgmt_tx_completion_ind =
1082 qdf_mem_malloc(sizeof(*mgmt_tx_completion_ind));
1083 if (!mgmt_tx_completion_ind)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001084 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001085
1086 /* sessionId */
Wu Gao6768d762018-12-28 16:31:08 +08001087 mgmt_tx_completion_ind->session_id = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001088
Wu Gao6768d762018-12-28 16:31:08 +08001089 mgmt_tx_completion_ind->tx_complete_status = txCompleteStatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001090
Wu Gao6768d762018-12-28 16:31:08 +08001091 msg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1092 msg.bodyptr = mgmt_tx_completion_ind;
1093 msg.bodyval = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001094
Wu Gao6768d762018-12-28 16:31:08 +08001095 mgmt_tx_completion_ind->psoc = mac->psoc;
1096 msg.callback = tgt_tdls_send_mgmt_tx_completion;
1097 status = scheduler_post_message(QDF_MODULE_ID_PE,
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05301098 QDF_MODULE_ID_TDLS,
Wu Gao6768d762018-12-28 16:31:08 +08001099 QDF_MODULE_ID_TARGET_IF, &msg);
1100 if (QDF_IS_STATUS_ERROR(status)) {
1101 pe_err("post msg fail, %d", status);
1102 qdf_mem_free(mgmt_tx_completion_ind);
1103 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001104} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1105
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001106#endif /* FEATURE_WLAN_TDLS */
1107
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001108QDF_STATUS lim_prepare_disconnect_done_ind(struct mac_context *mac_ctx,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301109 uint32_t **msg,
1110 uint8_t session_id,
1111 tSirResultCodes reason_code,
1112 uint8_t *peer_mac_addr)
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301113{
1114 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301115
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301116 sir_sme_dis_ind = qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001117 if (!sir_sme_dis_ind)
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301118 return QDF_STATUS_E_FAILURE;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301119
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301120 pe_debug("Prepare eWNI_SME_DISCONNECT_DONE_IND withretCode: %d",
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301121 reason_code);
1122
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301123 sir_sme_dis_ind->message_type = eWNI_SME_DISCONNECT_DONE_IND;
1124 sir_sme_dis_ind->length = sizeof(*sir_sme_dis_ind);
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301125 sir_sme_dis_ind->session_id = session_id;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301126 if (peer_mac_addr)
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05301127 qdf_mem_copy(sir_sme_dis_ind->peer_mac,
1128 peer_mac_addr, ETH_ALEN);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301129
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301130 /*
1131 * Instead of sending deauth reason code as 505 which is
1132 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1133 * Send reason code as zero to Supplicant
1134 */
1135 if (reason_code == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1136 sir_sme_dis_ind->reason_code = 0;
1137 else
1138 sir_sme_dis_ind->reason_code = reason_code;
1139
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301140 *msg = (uint32_t *)sir_sme_dis_ind;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301141
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301142 return QDF_STATUS_SUCCESS;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301143}
1144
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001145/**
1146 * lim_send_sme_deauth_ntf()
1147 *
1148 ***FUNCTION:
1149 * This function is called by limProcessSmeMessages() to send
1150 * eWNI_SME_DISASSOC_RSP/IND message to host
1151 *
1152 ***PARAMS:
1153 *
1154 ***LOGIC:
1155 *
1156 ***ASSUMPTIONS:
1157 * NA
1158 *
1159 ***NOTE:
1160 * This function is used for sending eWNI_SME_DEAUTH_CNF or
1161 * eWNI_SME_DEAUTH_IND to host depending on deauthentication trigger.
1162 *
1163 * @param peerMacAddr Indicates the peer MAC addr to which
1164 * deauthentication was initiated
1165 * @param reasonCode Indicates the reason for Deauthetication
1166 * @param deauthTrigger Indicates the trigger for Deauthetication
1167 * @param aid Indicates the STAID. This parameter is present
1168 * only on AP.
1169 *
1170 * @return None
1171 */
1172void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001173lim_send_sme_deauth_ntf(struct mac_context *mac, tSirMacAddr peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001174 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1175 uint16_t aid, uint8_t smesessionId,
1176 uint16_t smetransactionId)
1177{
1178 uint8_t *pBuf;
1179 tSirSmeDeauthRsp *pSirSmeDeauthRsp;
1180 tSirSmeDeauthInd *pSirSmeDeauthInd;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001181 struct pe_session *pe_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001182 uint8_t sessionId;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301183 uint32_t *pMsg = NULL;
1184 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001185
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001186 pe_session = pe_find_session_by_bssid(mac, peerMacAddr, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001187 switch (deauthTrigger) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001188 case eLIM_HOST_DEAUTH:
1189 /**
1190 * Deauthentication response to host triggered
1191 * deauthentication.
1192 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301193 pSirSmeDeauthRsp = qdf_mem_malloc(sizeof(tSirSmeDeauthRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001194 if (!pSirSmeDeauthRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001195 return;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301196 pe_debug("send eWNI_SME_DEAUTH_RSP with retCode: %d for" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001197 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1198 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
1199 pSirSmeDeauthRsp->length = sizeof(tSirSmeDeauthRsp);
1200 pSirSmeDeauthRsp->statusCode = reasonCode;
1201 pSirSmeDeauthRsp->sessionId = smesessionId;
1202 pSirSmeDeauthRsp->transactionId = smetransactionId;
1203
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -08001204 pBuf = (uint8_t *) pSirSmeDeauthRsp->peer_macaddr.bytes;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301205 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001206
1207#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -08001208 lim_diag_event_report(mac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001209 pe_session, 0, (uint16_t) reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001210#endif
1211 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1212
1213 break;
1214
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301215 case eLIM_PEER_ENTITY_DEAUTH:
1216 case eLIM_LINK_MONITORING_DEAUTH:
Jeff Johnson35c58a82018-11-22 15:04:57 -08001217 status = lim_prepare_disconnect_done_ind(mac, &pMsg,
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301218 smesessionId, reasonCode,
1219 &peerMacAddr[0]);
1220 if (!QDF_IS_STATUS_SUCCESS(status)) {
1221 pe_err("Failed to prepare message");
1222 return;
1223 }
1224 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001225 default:
1226 /**
1227 * Deauthentication indication due to Deauthentication
1228 * frame reception from peer entity or due to
1229 * loss of link with peer entity.
1230 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301231 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001232 if (!pSirSmeDeauthInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001233 return;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301234 pe_debug("send eWNI_SME_DEAUTH_IND with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001235 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1236 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1237 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1238 pSirSmeDeauthInd->reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
1239
1240 /* sessionId */
1241 pBuf = (uint8_t *) &pSirSmeDeauthInd->sessionId;
1242 *pBuf++ = smesessionId;
1243
1244 /* transaction ID */
1245 lim_copy_u16(pBuf, smetransactionId);
1246 pBuf += sizeof(uint16_t);
1247
1248 /* status code */
1249 lim_copy_u32(pBuf, reasonCode);
1250 pBuf += sizeof(tSirResultCodes);
1251
1252 /* bssId */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001253 qdf_mem_copy(pBuf, pe_session->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001254 pBuf += sizeof(tSirMacAddr);
1255
1256 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301257 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301258 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001259
1260#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -08001261 lim_diag_event_report(mac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001262 pe_session, 0, (uint16_t) reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001263#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1264 pMsg = (uint32_t *) pSirSmeDeauthInd;
1265
1266 break;
1267 }
1268
1269 /*Delete the PE session created */
Bala Venkatesh03b4f0c2019-01-28 22:00:50 +05301270 if (pe_session && LIM_IS_STA_ROLE(pe_session))
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001271 pe_delete_session(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001272
Jeff Johnson35c58a82018-11-22 15:04:57 -08001273 lim_send_sme_disassoc_deauth_ntf(mac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001274 (uint32_t *) pMsg);
1275
1276} /*** end lim_send_sme_deauth_ntf() ***/
1277
1278/**
1279 * lim_send_sme_wm_status_change_ntf() - Send Notification
1280 * @mac_ctx: Global MAC Context
1281 * @status_change_code: Indicates the change in the wireless medium.
1282 * @status_change_info: Indicates the information associated with
1283 * change in the wireless medium.
1284 * @info_len: Indicates the length of status change information
1285 * being sent.
1286 * @session_id SessionID
1287 *
1288 * This function is called by limProcessSmeMessages() to send
1289 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1290 *
1291 * Return: None
1292 */
1293void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001294lim_send_sme_wm_status_change_ntf(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001295 tSirSmeStatusChangeCode status_change_code,
1296 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1297{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001298 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001299 tSirSmeWmStatusChangeNtf *wm_status_change_ntf;
Naveen Rawate01ed172016-11-17 11:34:50 -08001300 uint32_t max_info_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001301
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301302 wm_status_change_ntf = qdf_mem_malloc(sizeof(tSirSmeWmStatusChangeNtf));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001303 if (!wm_status_change_ntf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001304 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001305
1306 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1307 msg.bodyval = 0;
1308 msg.bodyptr = wm_status_change_ntf;
1309
1310 switch (status_change_code) {
Naveen Rawate01ed172016-11-17 11:34:50 -08001311 case eSIR_SME_AP_CAPS_CHANGED:
1312 max_info_len = sizeof(tSirSmeApNewCaps);
1313 break;
1314 case eSIR_SME_JOINED_NEW_BSS:
1315 max_info_len = sizeof(tSirSmeNewBssInfo);
1316 break;
1317 default:
1318 max_info_len = sizeof(wm_status_change_ntf->statusChangeInfo);
1319 break;
1320 }
1321
1322 switch (status_change_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001323 case eSIR_SME_RADAR_DETECTED:
1324 break;
1325 default:
1326 wm_status_change_ntf->messageType =
1327 eWNI_SME_WM_STATUS_CHANGE_NTF;
1328 wm_status_change_ntf->statusChangeCode = status_change_code;
1329 wm_status_change_ntf->length = sizeof(tSirSmeWmStatusChangeNtf);
1330 wm_status_change_ntf->sessionId = session_id;
Naveen Rawate01ed172016-11-17 11:34:50 -08001331 if (info_len <= max_info_len && status_change_info) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301332 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001333 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1334 (uint8_t *) status_change_info, info_len);
1335 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301336 pe_debug("StatusChg code: 0x%x length: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001337 status_change_code, info_len);
1338 break;
1339 }
1340
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301341 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, session_id, msg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08001342 if (QDF_STATUS_SUCCESS != lim_sys_process_mmh_msg_api(mac_ctx, &msg)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301343 qdf_mem_free(wm_status_change_ntf);
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301344 pe_err("lim_sys_process_mmh_msg_api failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001345 }
1346
1347} /*** end lim_send_sme_wm_status_change_ntf() ***/
1348
1349/**
1350 * lim_send_sme_set_context_rsp()
1351 *
1352 ***FUNCTION:
1353 * This function is called by limProcessSmeMessages() to send
1354 * eWNI_SME_SETCONTEXT_RSP message to host
1355 *
1356 ***PARAMS:
1357 *
1358 ***LOGIC:
1359 *
1360 ***ASSUMPTIONS:
1361 * NA
1362 *
1363 ***NOTE:
1364 *
Jeff Johnson35c58a82018-11-22 15:04:57 -08001365 * @param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001366 * @param peerMacAddr Indicates the peer MAC addr to which
1367 * setContext was performed
1368 * @param aid Indicates the aid corresponding to the peer MAC
1369 * address
1370 * @param resultCode Indicates the result of previously issued
1371 * eWNI_SME_SETCONTEXT_RSP message
1372 *
1373 * @return None
1374 */
1375void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001376lim_send_sme_set_context_rsp(struct mac_context *mac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301377 struct qdf_mac_addr peer_macaddr, uint16_t aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001378 tSirResultCodes resultCode,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001379 struct pe_session *pe_session, uint8_t smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001380 uint16_t smetransactionId)
1381{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001382 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001383 tSirSmeSetContextRsp *pSirSmeSetContextRsp;
1384
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301385 pSirSmeSetContextRsp = qdf_mem_malloc(sizeof(tSirSmeSetContextRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001386 if (!pSirSmeSetContextRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001387 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001388
1389 pSirSmeSetContextRsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1390 pSirSmeSetContextRsp->length = sizeof(tSirSmeSetContextRsp);
1391 pSirSmeSetContextRsp->statusCode = resultCode;
1392
Anurag Chouhanc5548422016-02-24 18:33:27 +05301393 qdf_copy_macaddr(&pSirSmeSetContextRsp->peer_macaddr, &peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001394
1395 /* Update SME session and transaction Id */
1396 pSirSmeSetContextRsp->sessionId = smesessionId;
1397 pSirSmeSetContextRsp->transactionId = smetransactionId;
1398
1399 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
1400 mmhMsg.bodyptr = pSirSmeSetContextRsp;
1401 mmhMsg.bodyval = 0;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001402 if (NULL == pe_session) {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001403 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301404 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001405 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001406 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001407 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001408 }
1409
1410#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnson35c58a82018-11-22 15:04:57 -08001411 lim_diag_event_report(mac, WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001412 pe_session, (uint16_t) resultCode, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001413#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1414
Jeff Johnson35c58a82018-11-22 15:04:57 -08001415 mac->lim.sme_msg_callback(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001416} /*** end lim_send_sme_set_context_rsp() ***/
1417
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001418/** -----------------------------------------------------------------
1419 \brief lim_send_sme_addts_rsp() - sends SME ADDTS RSP
1420 \ This function sends a eWNI_SME_ADDTS_RSP to SME.
1421 \ SME only looks at rc and tspec field.
Jeff Johnson35c58a82018-11-22 15:04:57 -08001422 \param mac - global mac structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001423 \param rspReqd - is SmeAddTsRsp required
1424 \param status - status code of SME_ADD_TS_RSP
1425 \return tspec
1426 \sa
1427 ----------------------------------------------------------------- */
1428void
Jeff Johnson56471b92018-12-22 14:36:06 -08001429lim_send_sme_addts_rsp(struct mac_context *mac, uint8_t rspReqd,
1430 uint32_t status,
1431 struct pe_session *pe_session, struct mac_tspec_ie tspec,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001432 uint8_t smesessionId, uint16_t smetransactionId)
1433{
1434 tpSirAddtsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001435 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001436
1437 if (!rspReqd)
1438 return;
1439
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301440 rsp = qdf_mem_malloc(sizeof(tSirAddtsRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001441 if (!rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001442 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001443
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001444 rsp->messageType = eWNI_SME_ADDTS_RSP;
1445 rsp->rc = status;
1446 rsp->rsp.status = (enum eSirMacStatusCodes)status;
1447 rsp->rsp.tspec = tspec;
1448 /* Update SME session Id and transcation Id */
1449 rsp->sessionId = smesessionId;
1450 rsp->transactionId = smetransactionId;
1451
1452 mmhMsg.type = eWNI_SME_ADDTS_RSP;
1453 mmhMsg.bodyptr = rsp;
1454 mmhMsg.bodyval = 0;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001455 if (NULL == pe_session) {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001456 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301457 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001458 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001459 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001460 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001461 }
1462#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001463 lim_diag_event_report(mac, WLAN_PE_DIAG_ADDTS_RSP_EVENT, pe_session, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001464 0);
1465#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1466
Jeff Johnsona5abe272019-01-06 12:52:02 -08001467 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001468 return;
1469}
1470
1471void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001472lim_send_sme_delts_rsp(struct mac_context *mac, tpSirDeltsReq delts, uint32_t status,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001473 struct pe_session *pe_session, uint8_t smesessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001474 uint16_t smetransactionId)
1475{
1476 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001477 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001478
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301479 pe_debug("SendSmeDeltsRsp aid: %d tsid: %d up: %d status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001480 delts->aid,
1481 delts->req.tsinfo.traffic.tsid,
1482 delts->req.tsinfo.traffic.userPrio, status);
1483 if (!delts->rspReqd)
1484 return;
1485
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301486 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001487 if (!rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001488 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001489
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001490 if (pe_session != NULL) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001491
1492 rsp->aid = delts->aid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301493 qdf_copy_macaddr(&rsp->macaddr, &delts->macaddr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301494 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) &delts->req,
Jeff Johnsoncf2ec162018-12-22 16:46:43 -08001495 sizeof(struct delts_req_info));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001496 }
1497
1498 rsp->messageType = eWNI_SME_DELTS_RSP;
1499 rsp->rc = status;
1500
1501 /* Update SME session Id and transcation Id */
1502 rsp->sessionId = smesessionId;
1503 rsp->transactionId = smetransactionId;
1504
1505 mmhMsg.type = eWNI_SME_DELTS_RSP;
1506 mmhMsg.bodyptr = rsp;
1507 mmhMsg.bodyval = 0;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001508 if (NULL == pe_session) {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001509 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301510 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001511 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -08001512 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001513 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001514 }
1515#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001516 lim_diag_event_report(mac, WLAN_PE_DIAG_DELTS_RSP_EVENT, pe_session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001517 (uint16_t) status, 0);
1518#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1519
Jeff Johnsona5abe272019-01-06 12:52:02 -08001520 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001521}
1522
1523void
Jeff Johnsoncf2ec162018-12-22 16:46:43 -08001524lim_send_sme_delts_ind(struct mac_context *mac, struct delts_req_info *delts,
1525 uint16_t aid, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001526{
1527 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001528 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001529
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301530 pe_debug("SendSmeDeltsInd aid: %d tsid: %d up: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001531 aid, delts->tsinfo.traffic.tsid, delts->tsinfo.traffic.userPrio);
1532
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301533 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001534 if (!rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001535 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001536
1537 rsp->messageType = eWNI_SME_DELTS_IND;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001538 rsp->rc = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001539 rsp->aid = aid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301540 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) delts, sizeof(*delts));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001541
1542 /* Update SME session Id and SME transaction Id */
1543
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001544 rsp->sessionId = pe_session->smeSessionId;
1545 rsp->transactionId = pe_session->transactionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001546
1547 mmhMsg.type = eWNI_SME_DELTS_IND;
1548 mmhMsg.bodyptr = rsp;
1549 mmhMsg.bodyval = 0;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001550 MTRACE(mac_trace_msg_tx(mac, pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001551#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001552 lim_diag_event_report(mac, WLAN_PE_DIAG_DELTS_IND_EVENT, pe_session, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001553 0);
1554#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1555
Jeff Johnsona5abe272019-01-06 12:52:02 -08001556 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001557}
1558
Naveen Rawatfa2a1002018-05-17 16:06:37 -07001559#ifndef QCA_SUPPORT_CP_STATS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001560/**
1561 * lim_send_sme_pe_statistics_rsp()
1562 *
1563 ***FUNCTION:
1564 * This function is called to send 802.11 statistics response to HDD.
1565 * This function posts the result back to HDD. This is a response to
1566 * HDD's request for statistics.
1567 *
1568 ***PARAMS:
1569 *
1570 ***LOGIC:
1571 *
1572 ***ASSUMPTIONS:
1573 * NA
1574 *
1575 ***NOTE:
1576 * NA
1577 *
Jeff Johnson35c58a82018-11-22 15:04:57 -08001578 * @param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001579 * @param p80211Stats Statistics sent in response
1580 * @param resultCode TODO:
1581 *
1582 *
1583 * @return none
1584 */
1585
1586void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001587lim_send_sme_pe_statistics_rsp(struct mac_context *mac, uint16_t msgType, void *stats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001588{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001589 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001590 uint8_t sessionId;
1591 tAniGetPEStatsRsp *pPeStats = (tAniGetPEStatsRsp *) stats;
Jeff Johnsond7035a32018-11-18 22:03:13 -08001592 struct pe_session *pPeSessionEntry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001593
1594 /* Get the Session Id based on Sta Id */
1595 pPeSessionEntry =
Jeff Johnson35c58a82018-11-22 15:04:57 -08001596 pe_find_session_by_sta_id(mac, pPeStats->staId, &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001597
1598 /* Fill the Session Id */
1599 if (NULL != pPeSessionEntry) {
1600 /* Fill the Session Id */
1601 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1602 }
1603
1604 pPeStats->msgType = eWNI_SME_GET_STATISTICS_RSP;
1605
1606 /* msgType should be WMA_GET_STATISTICS_RSP */
1607 mmhMsg.type = eWNI_SME_GET_STATISTICS_RSP;
1608
1609 mmhMsg.bodyptr = stats;
1610 mmhMsg.bodyval = 0;
Jeff Johnson35c58a82018-11-22 15:04:57 -08001611 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08001612 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001613
1614 return;
1615
1616} /*** end lim_send_sme_pe_statistics_rsp() ***/
Naveen Rawatfa2a1002018-05-17 16:06:37 -07001617#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001618
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001619#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001620/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001621 * lim_send_sme_pe_ese_tsm_rsp() - send tsm response
Jeff Johnson35c58a82018-11-22 15:04:57 -08001622 * @mac: Pointer to global mac structure
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001623 * @pStats: Pointer to TSM Stats
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001624 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001625 * This function is called to send tsm stats response to HDD.
1626 * This function posts the result back to HDD. This is a response to
1627 * HDD's request to get tsm stats.
1628 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001629 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001630 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001631void lim_send_sme_pe_ese_tsm_rsp(struct mac_context *mac,
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001632 tAniGetTsmStatsRsp *pStats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001633{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001634 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001635 uint8_t sessionId;
1636 tAniGetTsmStatsRsp *pPeStats = (tAniGetTsmStatsRsp *) pStats;
Jeff Johnsond7035a32018-11-18 22:03:13 -08001637 struct pe_session *pPeSessionEntry = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001638
1639 /* Get the Session Id based on Sta Id */
Abhinav Kumaraa8f2df2019-01-11 20:02:26 +05301640 pPeSessionEntry = pe_find_session_by_bssid(mac, pPeStats->bssid.bytes,
1641 &sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001642 /* Fill the Session Id */
1643 if (NULL != pPeSessionEntry) {
1644 /* Fill the Session Id */
1645 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1646 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301647 pe_err("Session not found for the Sta id: %d",
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301648 pPeStats->staId);
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05301649 qdf_mem_free(pPeStats->tsmStatsReq);
1650 qdf_mem_free(pPeStats);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001651 return;
1652 }
1653
1654 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
1655 pPeStats->tsmMetrics.RoamingCount
1656 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
1657 pPeStats->tsmMetrics.RoamingDly
1658 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
1659
1660 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
1661 mmhMsg.bodyptr = pStats;
1662 mmhMsg.bodyval = 0;
Jeff Johnson35c58a82018-11-22 15:04:57 -08001663 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08001664 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001665
1666 return;
1667} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
1668
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001669#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001670
1671void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001672lim_send_sme_ibss_peer_ind(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001673 tSirMacAddr peerMacAddr,
1674 uint16_t staIndex,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001675 uint8_t *beacon,
1676 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
1677{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001678 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001679 tSmeIbssPeerInd *pNewPeerInd;
1680
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301681 pNewPeerInd = qdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
Arif Hussainf5b6c412018-10-10 19:41:09 -07001682 if (!pNewPeerInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001683 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001684
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301685 qdf_mem_copy((uint8_t *) pNewPeerInd->peer_addr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301686 peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001687 pNewPeerInd->staId = staIndex;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001688 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
1689 pNewPeerInd->mesgType = msgType;
1690 pNewPeerInd->sessionId = sessionId;
1691
1692 if (beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301693 qdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001694 sizeof(tSmeIbssPeerInd)), (void *)beacon,
1695 beaconLen);
1696 }
1697
1698 mmhMsg.type = msgType;
1699 mmhMsg.bodyptr = pNewPeerInd;
Jeff Johnson35c58a82018-11-22 15:04:57 -08001700 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08001701 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001702
1703}
1704
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07001705/**
1706 * lim_process_csa_wbw_ie() - Process CSA Wide BW IE
1707 * @mac_ctx: pointer to global adapter context
1708 * @csa_params: pointer to CSA parameters
1709 * @chnl_switch_info:pointer to channel switch parameters
1710 * @session_entry: session pointer
1711 *
1712 * Return: None
1713 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001714static QDF_STATUS lim_process_csa_wbw_ie(struct mac_context *mac_ctx,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001715 struct csa_offload_params *csa_params,
1716 tLimWiderBWChannelSwitchInfo *chnl_switch_info,
Jeff Johnsond7035a32018-11-18 22:03:13 -08001717 struct pe_session *session_entry)
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001718{
Amar Singhal5cccafe2017-02-15 12:42:58 -08001719 struct ch_params ch_params = {0};
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001720 uint8_t ap_new_ch_width;
1721 bool new_ch_width_dfn = false;
1722 uint8_t center_freq_diff;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001723 uint32_t fw_vht_ch_wd = wma_get_vht_ch_width() + 1;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001724
1725 ap_new_ch_width = csa_params->new_ch_width + 1;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001726
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001727 pe_debug("new channel: %d new_ch_width: %d seg0: %d seg1: %d",
1728 csa_params->channel, ap_new_ch_width,
1729 csa_params->new_ch_freq_seg1,
1730 csa_params->new_ch_freq_seg2);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001731
1732 if ((ap_new_ch_width != CH_WIDTH_80MHZ) &&
1733 (ap_new_ch_width != CH_WIDTH_160MHZ) &&
1734 (ap_new_ch_width != CH_WIDTH_80P80MHZ)) {
1735 pe_err("CSA wide BW IE has wrong ch_width %d",
1736 csa_params->new_ch_width);
1737 return QDF_STATUS_E_INVAL;
1738 }
1739
1740 if (!csa_params->new_ch_freq_seg1 && !csa_params->new_ch_freq_seg2) {
1741 pe_err("CSA wide BW IE has invalid center freq");
1742 return QDF_STATUS_E_INVAL;
1743 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001744 if ((ap_new_ch_width == CH_WIDTH_80MHZ) &&
1745 csa_params->new_ch_freq_seg2) {
1746 new_ch_width_dfn = true;
1747 if (csa_params->new_ch_freq_seg2 >
1748 csa_params->new_ch_freq_seg1)
1749 center_freq_diff = csa_params->new_ch_freq_seg2 -
1750 csa_params->new_ch_freq_seg1;
1751 else
1752 center_freq_diff = csa_params->new_ch_freq_seg1 -
1753 csa_params->new_ch_freq_seg2;
1754 if (center_freq_diff == CENTER_FREQ_DIFF_160MHz)
1755 ap_new_ch_width = CH_WIDTH_160MHZ;
1756 else if (center_freq_diff > CENTER_FREQ_DIFF_80P80MHz)
1757 ap_new_ch_width = CH_WIDTH_80P80MHZ;
1758 else
1759 ap_new_ch_width = CH_WIDTH_80MHZ;
1760 }
1761 session_entry->gLimChannelSwitch.state =
1762 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1763 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
1764 !new_ch_width_dfn) {
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001765 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1766 CH_TO_CNTR_FREQ_DIFF_160MHz) {
1767 pe_err("CSA wide BW IE has invalid center freq");
1768 return QDF_STATUS_E_INVAL;
1769 }
1770
1771 if (ap_new_ch_width > fw_vht_ch_wd) {
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001772 pe_debug("New BW is not supported, setting BW to %d",
1773 fw_vht_ch_wd);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001774 ap_new_ch_width = fw_vht_ch_wd;
1775 }
1776 ch_params.ch_width = ap_new_ch_width ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001777 wlan_reg_set_channel_params(mac_ctx->pdev,
1778 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001779 ap_new_ch_width = ch_params.ch_width;
1780 csa_params->new_ch_freq_seg1 = ch_params.center_freq_seg0;
1781 csa_params->new_ch_freq_seg2 = ch_params.center_freq_seg1;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001782 } else if (!new_ch_width_dfn) {
1783 if (ap_new_ch_width > fw_vht_ch_wd) {
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001784 pe_debug("New BW is not supported, setting BW to %d",
1785 fw_vht_ch_wd);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001786 ap_new_ch_width = fw_vht_ch_wd;
1787 }
1788 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1789 CH_TO_CNTR_FREQ_DIFF_80MHz) {
1790 pe_err("CSA wide BW IE has invalid center freq");
1791 return QDF_STATUS_E_INVAL;
1792 }
1793 csa_params->new_ch_freq_seg2 = 0;
1794 }
1795 if (new_ch_width_dfn) {
1796 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1797 CH_TO_CNTR_FREQ_DIFF_80MHz) {
1798 pe_err("CSA wide BW IE has invalid center freq");
1799 return QDF_STATUS_E_INVAL;
1800 }
1801 if (ap_new_ch_width > fw_vht_ch_wd) {
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001802 pe_debug("New width is not supported, setting BW to %d",
1803 fw_vht_ch_wd);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001804 ap_new_ch_width = fw_vht_ch_wd;
1805 }
1806 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
1807 (csa_params->new_ch_freq_seg1 !=
1808 csa_params->channel +
1809 CH_TO_CNTR_FREQ_DIFF_160MHz)) {
1810 pe_err("wide BW IE has invalid 160M center freq");
1811 csa_params->new_ch_freq_seg2 = 0;
1812 ap_new_ch_width = CH_WIDTH_80MHZ;
1813 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001814 }
1815 chnl_switch_info->newChanWidth = ap_new_ch_width;
1816 chnl_switch_info->newCenterChanFreq0 = csa_params->new_ch_freq_seg1;
1817 chnl_switch_info->newCenterChanFreq1 = csa_params->new_ch_freq_seg2;
1818
1819 if (session_entry->ch_width == ap_new_ch_width)
1820 goto prnt_log;
1821
1822 if (session_entry->ch_width == CH_WIDTH_80MHZ) {
1823 chnl_switch_info->newChanWidth = CH_WIDTH_80MHZ;
1824 chnl_switch_info->newCenterChanFreq1 = 0;
1825 } else {
1826 session_entry->ch_width = ap_new_ch_width;
1827 chnl_switch_info->newChanWidth = ap_new_ch_width;
1828 }
1829prnt_log:
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301830 pe_debug("new channel: %d new_ch_width: %d seg0: %d seg1: %d",
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001831 csa_params->channel,
1832 chnl_switch_info->newChanWidth,
1833 chnl_switch_info->newCenterChanFreq0,
1834 chnl_switch_info->newCenterChanFreq1);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001835
1836 return QDF_STATUS_SUCCESS;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001837}
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001838
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001839/**
1840 * lim_handle_csa_offload_msg() - Handle CSA offload message
1841 * @mac_ctx: pointer to global adapter context
1842 * @msg: Message pointer.
1843 *
1844 * Return: None
1845 */
Jeff Johnson9320c1e2018-12-02 13:09:20 -08001846void lim_handle_csa_offload_msg(struct mac_context *mac_ctx,
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001847 struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001848{
Jeff Johnsond7035a32018-11-18 22:03:13 -08001849 struct pe_session *session_entry;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001850 struct scheduler_msg mmh_msg = {0};
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301851 struct csa_offload_params *csa_params =
1852 (struct csa_offload_params *) (msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001853 tpSmeCsaOffloadInd csa_offload_ind;
1854 tpDphHashNode sta_ds = NULL;
1855 uint8_t session_id;
1856 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05301857 uint16_t chan_space = 0;
Krunal Sonie2c45a92018-05-03 11:51:26 -07001858 struct ch_params ch_params = {0};
Gupta, Kapil121bf212015-11-25 19:21:29 +05301859
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001860 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08001861 tLimChannelSwitchInfo *lim_ch_switch = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001862
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301863 pe_debug("handle csa offload msg");
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301864
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001865 if (!csa_params) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301866 pe_err("limMsgQ body ptr is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001867 return;
1868 }
1869
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05301870 csa_offload_ind = qdf_mem_malloc(sizeof(tSmeCsaOffloadInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001871 if (!csa_offload_ind)
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05301872 goto err;
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05301873
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001874 session_entry =
1875 pe_find_session_by_bssid(mac_ctx,
1876 csa_params->bssId, &session_id);
1877 if (!session_entry) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301878 pe_err("Session does not exists for %pM",
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301879 csa_params->bssId);
Pragaspathi Thilagaraj655db192018-06-19 17:41:37 +05301880 qdf_mem_free(csa_offload_ind);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001881 goto err;
1882 }
1883
1884 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
1885 &session_entry->dph.dphHashTable);
1886
1887 if (!sta_ds) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301888 pe_err("sta_ds does not exist");
Pragaspathi Thilagaraj655db192018-06-19 17:41:37 +05301889 qdf_mem_free(csa_offload_ind);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001890 goto err;
1891 }
1892
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001893 if (!LIM_IS_STA_ROLE(session_entry)) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301894 pe_debug("Invalid role to handle CSA");
Pragaspathi Thilagaraj655db192018-06-19 17:41:37 +05301895 qdf_mem_free(csa_offload_ind);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001896 goto err;
1897 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001898 /*
1899 * on receiving channel switch announcement from AP, delete all
1900 * TDLS peers before leaving BSS and proceed for channel switch
1901 */
Bala Venkatesh33f270b2019-01-14 16:31:29 +05301902
1903 lim_update_tdls_set_state_for_fw(session_entry, false);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001904 lim_delete_tdls_peers(mac_ctx, session_entry);
Gupta, Kapil121bf212015-11-25 19:21:29 +05301905
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001906 lim_ch_switch = &session_entry->gLimChannelSwitch;
1907 session_entry->gLimChannelSwitch.switchMode =
1908 csa_params->switch_mode;
1909 /* timer already started by firmware, switch immediately */
1910 session_entry->gLimChannelSwitch.switchCount = 0;
1911 session_entry->gLimChannelSwitch.primaryChannel =
1912 csa_params->channel;
1913 session_entry->gLimChannelSwitch.state =
1914 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
1915 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
1916 lim_ch_switch->sec_ch_offset =
1917 session_entry->htSecondaryChannelOffset;
1918 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
1919 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
1920 chnl_switch_info =
1921 &session_entry->gLimWiderBWChannelSwitch;
1922
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001923 pe_debug("vht: %d ht: %d flag: %x chan: %d, sec_ch_offset %d",
1924 session_entry->vhtCapability,
1925 session_entry->htSupportedChannelWidthSet,
1926 csa_params->ies_present_flag,
1927 csa_params->channel,
1928 csa_params->sec_chan_offset);
1929 pe_debug("seg1: %d seg2: %d width: %d country: %s class: %d",
1930 csa_params->new_ch_freq_seg1,
1931 csa_params->new_ch_freq_seg2,
1932 csa_params->new_ch_width,
1933 mac_ctx->scan.countryCodeCurrent,
1934 csa_params->new_op_class);
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05301935
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001936 if (session_entry->vhtCapability &&
1937 session_entry->htSupportedChannelWidthSet) {
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001938 if ((csa_params->ies_present_flag & lim_wbw_ie_present) &&
1939 (QDF_STATUS_SUCCESS == lim_process_csa_wbw_ie(mac_ctx,
1940 csa_params, chnl_switch_info,
1941 session_entry))) {
1942 pe_debug("CSA wide BW IE process successful");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001943 lim_ch_switch->sec_ch_offset =
Abhishek Singhaf639b42017-06-16 14:14:36 +05301944 PHY_SINGLE_CHANNEL_CENTERED;
1945 if (chnl_switch_info->newChanWidth) {
1946 if (csa_params->channel <
1947 csa_params->new_ch_freq_seg1)
1948 lim_ch_switch->sec_ch_offset =
1949 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1950 else
1951 lim_ch_switch->sec_ch_offset =
1952 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1953 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001954 } else if (csa_params->ies_present_flag
1955 & lim_xcsa_ie_present) {
1956 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001957 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001958 mac_ctx->scan.countryCodeCurrent,
1959 csa_params->channel,
1960 csa_params->new_op_class);
1961 session_entry->gLimChannelSwitch.state =
1962 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1963
1964 if (chan_space == 80) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001965 chnl_switch_info->newChanWidth =
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001966 CH_WIDTH_80MHZ;
1967 } else if (chan_space == 40) {
1968 chnl_switch_info->newChanWidth =
1969 CH_WIDTH_40MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001970 } else {
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001971 chnl_switch_info->newChanWidth =
1972 CH_WIDTH_20MHZ;
1973 lim_ch_switch->state =
1974 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
1975 }
1976
1977 ch_params.ch_width =
1978 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001979 wlan_reg_set_channel_params(mac_ctx->pdev,
1980 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001981 chnl_switch_info->newCenterChanFreq0 =
1982 ch_params.center_freq_seg0;
1983 /*
1984 * This is not applicable for 20/40/80 MHz.
1985 * Only used when we support 80+80 MHz operation.
1986 * In case of 80+80 MHz, this parameter indicates
1987 * center channel frequency index of 80 MHz
1988 * channel offrequency segment 1.
1989 */
1990 chnl_switch_info->newCenterChanFreq1 =
1991 ch_params.center_freq_seg1;
1992 lim_ch_switch->sec_ch_offset =
1993 ch_params.sec_ch_offset;
1994
Kiran Kumar Lokere47127482017-12-20 18:09:55 -08001995 } else {
1996 lim_ch_switch->state =
1997 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1998 ch_params.ch_width = CH_WIDTH_40MHZ;
1999 wlan_reg_set_channel_params(mac_ctx->pdev,
2000 csa_params->channel, 0, &ch_params);
2001 lim_ch_switch->sec_ch_offset =
2002 ch_params.sec_ch_offset;
2003 chnl_switch_info->newChanWidth = CH_WIDTH_40MHZ;
2004 chnl_switch_info->newCenterChanFreq0 =
2005 ch_params.center_freq_seg0;
2006 chnl_switch_info->newCenterChanFreq1 = 0;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002007 }
2008 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
2009 chnl_switch_info->newCenterChanFreq0;
2010 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
2011 chnl_switch_info->newCenterChanFreq1;
2012 session_entry->gLimChannelSwitch.ch_width =
2013 chnl_switch_info->newChanWidth;
2014
2015 } else if (session_entry->htSupportedChannelWidthSet) {
2016 if (csa_params->ies_present_flag
2017 & lim_xcsa_ie_present) {
2018 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002019 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002020 mac_ctx->scan.countryCodeCurrent,
2021 csa_params->channel,
2022 csa_params->new_op_class);
2023 lim_ch_switch->state =
2024 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2025 if (chan_space == 40) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002026 lim_ch_switch->ch_width =
2027 CH_WIDTH_40MHZ;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002028 chnl_switch_info->newChanWidth =
2029 CH_WIDTH_40MHZ;
2030 ch_params.ch_width =
2031 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002032 wlan_reg_set_channel_params(mac_ctx->pdev,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002033 csa_params->channel,
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07002034 0, &ch_params);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002035 lim_ch_switch->ch_center_freq_seg0 =
2036 ch_params.center_freq_seg0;
2037 lim_ch_switch->sec_ch_offset =
2038 ch_params.sec_ch_offset;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002039 } else {
2040 lim_ch_switch->ch_width =
2041 CH_WIDTH_20MHZ;
2042 chnl_switch_info->newChanWidth =
2043 CH_WIDTH_40MHZ;
2044 lim_ch_switch->state =
2045 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2046 lim_ch_switch->sec_ch_offset =
2047 PHY_SINGLE_CHANNEL_CENTERED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002048 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002049 } else {
2050 lim_ch_switch->ch_width =
2051 CH_WIDTH_40MHZ;
2052 lim_ch_switch->state =
2053 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2054 ch_params.ch_width = CH_WIDTH_40MHZ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002055 wlan_reg_set_channel_params(mac_ctx->pdev,
2056 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002057 lim_ch_switch->ch_center_freq_seg0 =
2058 ch_params.center_freq_seg0;
2059 lim_ch_switch->sec_ch_offset =
2060 ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002061 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002062
2063 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302064 pe_debug("new ch width: %d space: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302065 session_entry->gLimChannelSwitch.ch_width, chan_space);
Kiran Kumar Lokere75d636f2016-12-20 14:52:03 -08002066 if ((session_entry->currentOperChannel == csa_params->channel) &&
2067 (session_entry->ch_width ==
2068 session_entry->gLimChannelSwitch.ch_width)) {
2069 pe_debug("Ignore CSA, no change in ch and bw");
Pragaspathi Thilagaraj655db192018-06-19 17:41:37 +05302070 qdf_mem_free(csa_offload_ind);
Kiran Kumar Lokere75d636f2016-12-20 14:52:03 -08002071 goto err;
2072 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002073
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05302074 if (WLAN_REG_IS_24GHZ_CH(csa_params->channel) &&
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +05302075 (session_entry->dot11mode == MLME_DOT11_MODE_11A))
2076 session_entry->dot11mode = MLME_DOT11_MODE_11G;
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05302077 else if (WLAN_REG_IS_5GHZ_CH(csa_params->channel) &&
gaurank kathpalia0c48d3d2019-01-29 15:03:07 +05302078 ((session_entry->dot11mode == MLME_DOT11_MODE_11G) ||
2079 (session_entry->dot11mode == MLME_DOT11_MODE_11G_ONLY)))
2080 session_entry->dot11mode = MLME_DOT11_MODE_11A;
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05302081
Vignesh Viswanathan3d478032018-08-02 20:18:53 +05302082 /* Send RSO Stop to FW before triggering the vdev restart for CSA */
2083 if (mac_ctx->lim.stop_roaming_callback)
2084 mac_ctx->lim.stop_roaming_callback(mac_ctx,
2085 session_entry->smeSessionId,
2086 ecsr_driver_disabled);
2087
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002088 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002089
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002090 csa_offload_ind->mesgType = eWNI_SME_CSA_OFFLOAD_EVENT;
2091 csa_offload_ind->mesgLen = sizeof(tSmeCsaOffloadInd);
2092 qdf_mem_copy(csa_offload_ind->bssid.bytes, session_entry->bssId,
2093 QDF_MAC_ADDR_SIZE);
2094 mmh_msg.type = eWNI_SME_CSA_OFFLOAD_EVENT;
2095 mmh_msg.bodyptr = csa_offload_ind;
2096 mmh_msg.bodyval = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302097 pe_debug("Sending eWNI_SME_CSA_OFFLOAD_EVENT to SME");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002098 MTRACE(mac_trace_msg_tx
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002099 (mac_ctx, session_entry->peSessionId, mmh_msg.type));
2100#ifdef FEATURE_WLAN_DIAG_SUPPORT
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002101 lim_diag_event_report(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002102 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002103 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002104#endif
Jeff Johnsona5abe272019-01-06 12:52:02 -08002105 lim_sys_process_mmh_msg_api(mac_ctx, &mmh_msg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002106
2107err:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302108 qdf_mem_free(csa_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002109}
2110
2111/*--------------------------------------------------------------------------
2112 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
2113
Jeff Johnson35c58a82018-11-22 15:04:57 -08002114 \param mac - pointer to global adapter context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002115 \param sessionId - Message pointer.
2116
2117 \sa
2118 --------------------------------------------------------------------------*/
2119
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002120void lim_handle_delete_bss_rsp(struct mac_context *mac, struct scheduler_msg *MsgQ)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002121{
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002122 struct pe_session *pe_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002123 tpDeleteBssParams pDelBss = (tpDeleteBssParams) (MsgQ->bodyptr);
2124
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002125 pe_session =
Jeff Johnson35c58a82018-11-22 15:04:57 -08002126 pe_find_session_by_session_id(mac, pDelBss->sessionId);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002127 if (pe_session == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302128 pe_err("Session Does not exist for given sessionID: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002129 pDelBss->sessionId);
Tushnim Bhattacharyya6368a262018-10-12 09:48:45 -07002130 qdf_mem_free(MsgQ->bodyptr);
2131 MsgQ->bodyptr = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002132 return;
2133 }
Krunal Sonie50ff452017-10-11 18:23:55 -07002134
2135 /*
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002136 * During DEL BSS handling, the PE Session will be deleted, but it is
2137 * better to clear this flag if the session is hanging around due
2138 * to some error conditions so that the next DEL_BSS request does
2139 * not take the HO_FAIL path
2140 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002141 pe_session->process_ho_fail = false;
2142 if (LIM_IS_IBSS_ROLE(pe_session))
2143 lim_ibss_del_bss_rsp(mac, MsgQ->bodyptr, pe_session);
2144 else if (LIM_IS_UNKNOWN_ROLE(pe_session))
2145 lim_process_sme_del_bss_rsp(mac, MsgQ->bodyval, pe_session);
2146 else if (LIM_IS_NDI_ROLE(pe_session))
2147 lim_ndi_del_bss_rsp(mac, MsgQ->bodyptr, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002148 else
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002149 lim_process_mlm_del_bss_rsp(mac, MsgQ, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002150
2151}
2152
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002153/** -----------------------------------------------------------------
2154 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
2155 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
2156 \ SME only looks at rc and tspec field.
Jeff Johnson35c58a82018-11-22 15:04:57 -08002157 \param mac - global mac structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002158 \param rspReqd - is SmeAddTsRsp required
2159 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
2160 \return tspec
2161 \sa
2162 ----------------------------------------------------------------- */
2163void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002164lim_send_sme_aggr_qos_rsp(struct mac_context *mac, tpSirAggrQosRsp aggrQosRsp,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002165 uint8_t smesessionId)
2166{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002167 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002168
2169 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
2170 mmhMsg.bodyptr = aggrQosRsp;
2171 mmhMsg.bodyval = 0;
Jeff Johnson35c58a82018-11-22 15:04:57 -08002172 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302173 smesessionId, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08002174 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002175
2176 return;
2177}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002178
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002179void lim_send_sme_max_assoc_exceeded_ntf(struct mac_context *mac, tSirMacAddr peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002180 uint8_t smesessionId)
2181{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002182 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002183 tSmeMaxAssocInd *pSmeMaxAssocInd;
2184
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302185 pSmeMaxAssocInd = qdf_mem_malloc(sizeof(tSmeMaxAssocInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002186 if (!pSmeMaxAssocInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002187 return;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302188 qdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peer_mac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302189 (uint8_t *) peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002190 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
2191 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
2192 pSmeMaxAssocInd->sessionId = smesessionId;
2193 mmhMsg.type = pSmeMaxAssocInd->mesgType;
2194 mmhMsg.bodyptr = pSmeMaxAssocInd;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302195 pe_debug("msgType: %s peerMacAddr "MAC_ADDRESS_STR "sme session id %d",
2196 "eWNI_SME_MAX_ASSOC_EXCEEDED", MAC_ADDR_ARRAY(peerMacAddr),
2197 pSmeMaxAssocInd->sessionId);
Jeff Johnson35c58a82018-11-22 15:04:57 -08002198 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302199 smesessionId, mmhMsg.type));
Jeff Johnsona5abe272019-01-06 12:52:02 -08002200 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002201
2202 return;
2203}
2204
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002205/** -----------------------------------------------------------------
2206 \brief lim_send_sme_ap_channel_switch_resp() - sends
2207 eWNI_SME_CHANNEL_CHANGE_RSP
2208 After receiving WMA_SWITCH_CHANNEL_RSP indication this
2209 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
2210 that the Channel change has been done to the specified target
2211 channel in the Channel change request
Jeff Johnson35c58a82018-11-22 15:04:57 -08002212 \param mac - global mac structure
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002213 \param pe_session - session info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002214 \param pChnlParams - Channel switch params
2215 --------------------------------------------------------------------*/
2216void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002217lim_send_sme_ap_channel_switch_resp(struct mac_context *mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002218 struct pe_session *pe_session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002219 tpSwitchChannelParams pChnlParams)
2220{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002221 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002222 tpSwitchChannelParams pSmeSwithChnlParams;
2223 uint8_t channelId;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002224 bool is_ch_dfs = false;
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08002225 enum phy_ch_width ch_width;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002226 uint8_t ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002227
Arif Hussainf5b6c412018-10-10 19:41:09 -07002228 pSmeSwithChnlParams = qdf_mem_malloc(sizeof(tSwitchChannelParams));
2229 if (!pSmeSwithChnlParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002230 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002231
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302232 qdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002233 sizeof(tSwitchChannelParams));
2234
2235 channelId = pSmeSwithChnlParams->channelNumber;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002236 ch_width = pSmeSwithChnlParams->ch_width;
2237 ch_center_freq_seg1 = pSmeSwithChnlParams->ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002238
2239 /*
2240 * Pass the sme sessionID to SME instead
2241 * PE session ID.
2242 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002243 pSmeSwithChnlParams->peSessionId = pe_session->smeSessionId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002244
2245 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
2246 mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
2247 mmhMsg.bodyval = 0;
Jeff Johnsona5abe272019-01-06 12:52:02 -08002248 lim_sys_process_mmh_msg_api(mac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002249
2250 /*
2251 * We should start beacon transmission only if the new
2252 * channel after channel change is Non-DFS. For a DFS
2253 * channel, PE will receive an explicit request from
2254 * upper layers to start the beacon transmission .
2255 */
2256
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002257 if (ch_width == CH_WIDTH_160MHZ) {
2258 is_ch_dfs = true;
2259 } else if (ch_width == CH_WIDTH_80P80MHZ) {
Jeff Johnson35c58a82018-11-22 15:04:57 -08002260 if (wlan_reg_get_channel_state(mac->pdev, channelId) ==
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002261 CHANNEL_STATE_DFS ||
Jeff Johnson35c58a82018-11-22 15:04:57 -08002262 wlan_reg_get_channel_state(mac->pdev,
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002263 ch_center_freq_seg1 -
2264 SIR_80MHZ_START_CENTER_CH_DIFF) ==
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002265 CHANNEL_STATE_DFS)
2266 is_ch_dfs = true;
2267 } else {
Jeff Johnson35c58a82018-11-22 15:04:57 -08002268 if (wlan_reg_get_channel_state(mac->pdev, channelId) ==
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002269 CHANNEL_STATE_DFS)
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002270 is_ch_dfs = true;
2271 }
2272
2273 if (!is_ch_dfs) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002274 if (channelId == pe_session->currentOperChannel) {
2275 lim_apply_configuration(mac, pe_session);
2276 lim_send_beacon(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002277 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302278 pe_debug("Failed to Transmit Beacons on channel: %d after AP channel change response",
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002279 pe_session->bcnLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002280 }
Arif Hussain1513cb22018-01-05 19:56:31 -08002281
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002282 lim_obss_send_detection_cfg(mac, pe_session, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002283 }
2284 return;
2285}
2286
Peng Xu6363ec62017-05-15 11:06:33 -07002287#ifdef WLAN_FEATURE_11AX_BSS_COLOR
2288/**
2289 * lim_send_bss_color_change_ie_update() - update bss color change IE in
2290 * beacon template
2291 *
2292 * @mac_ctx: pointer to global adapter context
2293 * @session: session pointer
2294 *
2295 * Return: none
2296 */
2297static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002298lim_send_bss_color_change_ie_update(struct mac_context *mac_ctx,
Jeff Johnsond7035a32018-11-18 22:03:13 -08002299 struct pe_session *session)
Peng Xu6363ec62017-05-15 11:06:33 -07002300{
2301 /* Update the beacon template and send to FW */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002302 if (sch_set_fixed_beacon_fields(mac_ctx, session) != QDF_STATUS_SUCCESS) {
Peng Xu6363ec62017-05-15 11:06:33 -07002303 pe_err("Unable to set BSS color change IE in beacon");
Srinivas Girigowdaeff16d92018-09-12 14:56:29 -07002304 return;
Peng Xu6363ec62017-05-15 11:06:33 -07002305 }
2306
2307 /* Send update beacon template message */
Abhishek Singhfc740be2018-10-12 11:34:26 +05302308 lim_send_beacon_ind(mac_ctx, session, REASON_COLOR_CHANGE);
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07002309 pe_debug("Updated BSS color change countdown = %d",
2310 session->he_bss_color_change.countdown);
Peng Xu6363ec62017-05-15 11:06:33 -07002311}
2312
2313static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002314lim_handle_bss_color_change_ie(struct mac_context *mac_ctx,
Jeff Johnsond7035a32018-11-18 22:03:13 -08002315 struct pe_session *session)
Peng Xu6363ec62017-05-15 11:06:33 -07002316{
Arif Hussain2f2d3512018-03-06 12:37:03 -08002317 tUpdateBeaconParams beacon_params;
2318
Peng Xu6363ec62017-05-15 11:06:33 -07002319 /* handle bss color change IE */
2320 if (LIM_IS_AP_ROLE(session) &&
2321 session->he_op.bss_col_disabled) {
2322 if (session->he_bss_color_change.countdown > 0) {
2323 session->he_bss_color_change.countdown--;
2324 } else {
2325 session->bss_color_changing = 0;
Arif Hussain2f2d3512018-03-06 12:37:03 -08002326 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
Arif Hussain05fb4872018-01-03 16:02:55 -08002327 if (session->he_bss_color_change.new_color != 0) {
Peng Xu6363ec62017-05-15 11:06:33 -07002328 session->he_op.bss_col_disabled = 0;
Arif Hussain05fb4872018-01-03 16:02:55 -08002329 session->he_op.bss_color =
2330 session->he_bss_color_change.new_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08002331 beacon_params.paramChangeBitmap |=
2332 PARAM_BSS_COLOR_CHANGED;
2333 beacon_params.bss_color_disabled = 0;
2334 beacon_params.bss_color =
2335 session->he_op.bss_color;
2336 lim_send_beacon_params(mac_ctx,
2337 &beacon_params,
2338 session);
Arif Hussain05fb4872018-01-03 16:02:55 -08002339 lim_send_obss_color_collision_cfg(mac_ctx,
2340 session,
2341 OBSS_COLOR_COLLISION_DETECTION);
2342 }
Peng Xu6363ec62017-05-15 11:06:33 -07002343 }
2344
2345 lim_send_bss_color_change_ie_update(mac_ctx, session);
2346 }
2347}
2348
2349#else
2350static void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002351lim_handle_bss_color_change_ie(struct mac_context *mac_ctx,
Jeff Johnsond7035a32018-11-18 22:03:13 -08002352 struct pe_session *session)
Peng Xu6363ec62017-05-15 11:06:33 -07002353{
2354}
2355#endif
2356
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002357void
Jeff Johnson9320c1e2018-12-02 13:09:20 -08002358lim_process_beacon_tx_success_ind(struct mac_context *mac_ctx, uint16_t msgType,
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302359 void *event)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002360{
Jeff Johnsond7035a32018-11-18 22:03:13 -08002361 struct pe_session *session;
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302362 tpSirFirstBeaconTxCompleteInd bcn_ind =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002363 (tSirFirstBeaconTxCompleteInd *) event;
2364
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302365 session = pe_find_session_by_bss_idx(mac_ctx, bcn_ind->bssIdx);
2366 if (!session) {
2367 pe_err("Session Does not exist for given session id");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002368 return;
2369 }
2370
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302371 pe_debug("role: %d swIe: %d opIe: %d switch cnt:%d",
2372 GET_LIM_SYSTEM_ROLE(session),
2373 session->dfsIncludeChanSwIe,
2374 session->gLimOperatingMode.present,
2375 session->gLimChannelSwitch.switchCount);
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302376
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302377 if (!LIM_IS_AP_ROLE(session))
2378 return;
Ganesh Kondabattini02ec62b2018-01-24 18:22:24 +05302379
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302380 if (session->dfsIncludeChanSwIe &&
2381 (session->gLimChannelSwitch.switchCount ==
2382 mac_ctx->sap.SapDfsInfo.sap_ch_switch_beacon_cnt))
2383 lim_process_ap_ecsa_timeout(session);
Ganesh Kondabattini02ec62b2018-01-24 18:22:24 +05302384
lifeng1c16b6b2017-09-25 13:59:55 +08002385
Abhishek Singhfc740be2018-10-12 11:34:26 +05302386 if (session->gLimOperatingMode.present)
2387 /* Done with nss update */
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302388 session->gLimOperatingMode.present = 0;
Peng Xu6363ec62017-05-15 11:06:33 -07002389
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302390 lim_handle_bss_color_change_ie(mac_ctx, session);
Peng Xu6363ec62017-05-15 11:06:33 -07002391
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002392 return;
2393}