blob: 92ea73c9ba48d74896cb5bd4e32a8f70c148b0a3 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Kiran Kumar Lokere47127482017-12-20 18:09:55 -08002 * Copyright (c) 2012-2018 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
19/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020 * This file lim_send_sme_rspMessages.cc contains the functions
21 * for sending SME response/notification messages to applications
22 * above MAC software.
23 * Author: Chandra Modumudi
24 * Date: 02/13/02
25 * History:-
26 * Date Modified by Modification Information
27 * --------------------------------------------------------------------
28 */
29
Anurag Chouhan6d760662016-02-20 16:05:43 +053030#include "qdf_types.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080031#include "wni_api.h"
32#include "sir_common.h"
33#include "ani_global.h"
34
35#include "wni_cfg.h"
36#include "sys_def.h"
37#include "cfg_api.h"
38
39#include "sch_api.h"
40#include "utils_api.h"
41#include "lim_utils.h"
42#include "lim_security_utils.h"
43#include "lim_ser_des_utils.h"
44#include "lim_send_sme_rsp_messages.h"
45#include "lim_ibss_peer_mgmt.h"
46#include "lim_session_utils.h"
47#include "lim_types.h"
48#include "sir_api.h"
Naveen Rawat3b6068c2016-04-14 19:01:06 -070049#include "cds_regdomain.h"
Gupta, Kapil121bf212015-11-25 19:21:29 +053050#include "lim_send_messages.h"
Deepak Dhamdhere13983f22016-05-31 19:06:09 -070051#include "nan_datapath.h"
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -070052#include "lim_assoc_utils.h"
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070053#include "wlan_reg_services_api.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070054#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080055
Kabilan Kannanf56f9d52017-04-05 03:31:34 -070056#include "wlan_tdls_tgt_api.h"
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +053057#include "lim_process_fils.h"
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -080058#include "wma.h"
Kabilan Kannanf56f9d52017-04-05 03:31:34 -070059
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080060static void lim_handle_join_rsp_status(tpAniSirGlobal mac_ctx,
61 tpPESession session_entry, tSirResultCodes result_code,
62 tpSirSmeJoinRsp sme_join_rsp);
63
64/**
65 * lim_send_sme_rsp() - Send Response to upper layers
66 * @mac_ctx: Pointer to Global MAC structure
67 * @msg_type: Indicates message type
68 * @result_code: Indicates the result of previously issued
69 * eWNI_SME_msg_type_REQ message
70 *
71 * This function is called by lim_process_sme_req_messages() to send
72 * eWNI_SME_START_RSP, eWNI_SME_STOP_BSS_RSP
73 * or eWNI_SME_SWITCH_CHL_RSP messages to applications above MAC
74 * Software.
75 *
76 * Return: None
77 */
78
79void
80lim_send_sme_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
81 tSirResultCodes result_code, uint8_t sme_session_id,
82 uint16_t sme_transaction_id)
83{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070084 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080085 tSirSmeRsp *sme_rsp;
86
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +053087 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080088 lim_msg_str(msg_type), lim_result_code_str(result_code));
89
Anurag Chouhan600c3a02016-03-01 10:33:54 +053090 sme_rsp = qdf_mem_malloc(sizeof(tSirSmeRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -070091 if (!sme_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080092 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080093
94 sme_rsp->messageType = msg_type;
95 sme_rsp->length = sizeof(tSirSmeRsp);
96 sme_rsp->statusCode = result_code;
97
98 sme_rsp->sessionId = sme_session_id;
99 sme_rsp->transactionId = sme_transaction_id;
100
101 msg.type = msg_type;
102 msg.bodyptr = sme_rsp;
103 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530104 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG,
105 sme_session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800106
107#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
108 switch (msg_type) {
109 case eWNI_SME_STOP_BSS_RSP:
110 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_STOP_BSS_RSP_EVENT,
111 NULL, (uint16_t) result_code, 0);
112 break;
113 }
114#endif /* FEATURE_WLAN_DIAG_SUPPORT */
115 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
116}
117
118
119
120/**
121 * lim_send_sme_roc_rsp() - Send Response to SME
122 * @mac_ctx: Pointer to Global MAC structure
123 * @status: Resume link status
124 * @result_code: Result of the ROC request
125 * @sme_session_id: SME sesson Id
126 * @scan_id: Scan Identifier
127 *
128 * This function is called to send ROC rsp
129 * message to SME.
130 *
131 * Return: None
132 */
133void
134lim_send_sme_roc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
135 tSirResultCodes result_code, uint8_t sme_session_id,
136 uint32_t scan_id)
137{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700138 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800139 struct sir_roc_rsp *sme_rsp;
140
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530141 pe_debug("Sending message: %s with reasonCode: %s scanId: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800142 lim_msg_str(msg_type), lim_result_code_str(result_code),
143 scan_id);
144
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530145 sme_rsp = qdf_mem_malloc(sizeof(struct sir_roc_rsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700146 if (!sme_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800147 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800148
149 sme_rsp->message_type = msg_type;
150 sme_rsp->length = sizeof(struct sir_roc_rsp);
151 sme_rsp->status = result_code;
152
153 sme_rsp->session_id = sme_session_id;
154 sme_rsp->scan_id = scan_id;
155
156 msg.type = msg_type;
157 msg.bodyptr = sme_rsp;
158 msg.bodyval = 0;
159 MTRACE(mac_trace_msg_tx(mac_ctx, sme_session_id, msg.type));
160 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
161}
162
163
164/**
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530165 * lim_get_max_rate_flags() - Get rate flags
166 * @mac_ctx: Pointer to global MAC structure
167 * @sta_ds: Pointer to station ds structure
168 *
169 * This function is called to get the rate flags for a connection
170 * from the station ds structure depending on the ht and the vht
171 * channel width supported.
172 *
173 * Return: Returns the populated rate_flags
174 */
175uint32_t lim_get_max_rate_flags(tpAniSirGlobal mac_ctx, tpDphHashNode sta_ds)
176{
177 uint32_t rate_flags = 0;
178
179 if (sta_ds == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530180 pe_err("sta_ds is NULL");
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530181 return rate_flags;
182 }
183
184 if (!sta_ds->mlmStaContext.htCapability &&
185 !sta_ds->mlmStaContext.vhtCapability) {
Naveen Rawatea1564b2018-05-17 15:56:11 -0700186 rate_flags |= TX_RATE_LEGACY;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530187 } else {
188 if (sta_ds->mlmStaContext.vhtCapability) {
189 if (WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ ==
190 sta_ds->vhtSupportedChannelWidthSet) {
Naveen Rawatea1564b2018-05-17 15:56:11 -0700191 rate_flags |= TX_RATE_VHT80;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530192 } else if (WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ ==
193 sta_ds->vhtSupportedChannelWidthSet) {
194 if (sta_ds->htSupportedChannelWidthSet)
Naveen Rawatea1564b2018-05-17 15:56:11 -0700195 rate_flags |= TX_RATE_VHT40;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530196 else
Naveen Rawatea1564b2018-05-17 15:56:11 -0700197 rate_flags |= TX_RATE_VHT20;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530198 }
199 } else if (sta_ds->mlmStaContext.htCapability) {
200 if (sta_ds->htSupportedChannelWidthSet)
Naveen Rawatea1564b2018-05-17 15:56:11 -0700201 rate_flags |= TX_RATE_HT40;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530202 else
Naveen Rawatea1564b2018-05-17 15:56:11 -0700203 rate_flags |= TX_RATE_HT20;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530204 }
205 }
206
207 if (sta_ds->htShortGI20Mhz || sta_ds->htShortGI40Mhz)
Naveen Rawatea1564b2018-05-17 15:56:11 -0700208 rate_flags |= TX_RATE_SGI;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530209
210 return rate_flags;
211}
212
213/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800214 * lim_send_sme_join_reassoc_rsp_after_resume() - Send Response to SME
215 * @mac_ctx Pointer to Global MAC structure
216 * @status Resume link status
217 * @ctx context passed while calling resmune link.
218 * (join response to be sent)
219 *
220 * This function is called to send Join/Reassoc rsp
221 * message to SME after the resume link.
222 *
223 * Return: None
224 */
225static void lim_send_sme_join_reassoc_rsp_after_resume(tpAniSirGlobal mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530226 QDF_STATUS status, uint32_t *ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700228 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800229 tpSirSmeJoinRsp sme_join_rsp = (tpSirSmeJoinRsp) ctx;
230
231 msg.type = sme_join_rsp->messageType;
232 msg.bodyptr = sme_join_rsp;
233 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530234 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, NO_SESSION, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800235 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
236}
237
238/**
239 * lim_handle_join_rsp_status() - Handle the response.
240 * @mac_ctx: Pointer to Global MAC structure
241 * @session_entry: PE Session Info
242 * @result_code: Indicates the result of previously issued
243 * eWNI_SME_msgType_REQ message
244 * @sme_join_rsp The received response.
245 *
246 * This function will handle both the success and failure status
247 * of the received response.
248 *
249 * Return: None
250 */
251static void lim_handle_join_rsp_status(tpAniSirGlobal mac_ctx,
252 tpPESession session_entry, tSirResultCodes result_code,
253 tpSirSmeJoinRsp sme_join_rsp)
254{
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700255 uint16_t bss_ie_len;
256 void *bss_ies;
257 bool is_vendor_ap_1_present;
Wu Gao2968fc92017-06-19 19:18:34 +0800258 tpSirSmeJoinReq join_reassoc_req = NULL;
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700259
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800260#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
261 tSirSmeHTProfile *ht_profile;
262#endif
263 if (result_code == eSIR_SME_SUCCESS) {
264 if (session_entry->beacon != NULL) {
265 sme_join_rsp->beaconLength = session_entry->bcnLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530266 qdf_mem_copy(sme_join_rsp->frames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800267 session_entry->beacon,
268 sme_join_rsp->beaconLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530269 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800270 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530271 session_entry->bcnLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530272 pe_debug("Beacon: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530273 sme_join_rsp->beaconLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800274 }
275 if (session_entry->assocReq != NULL) {
276 sme_join_rsp->assocReqLength =
277 session_entry->assocReqLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530278 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530279 sme_join_rsp->beaconLength,
280 session_entry->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800281 sme_join_rsp->assocReqLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530282 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800283 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530284 session_entry->assocReqLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530285 pe_debug("AssocReq: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530286 sme_join_rsp->assocReqLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800287 }
288 if (session_entry->assocRsp != NULL) {
289 sme_join_rsp->assocRspLength =
290 session_entry->assocRspLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530291 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530292 sme_join_rsp->beaconLength +
293 sme_join_rsp->assocReqLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800294 session_entry->assocRsp,
295 sme_join_rsp->assocRspLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530296 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800297 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530298 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800299 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800300 if (session_entry->ricData != NULL) {
301 sme_join_rsp->parsedRicRspLen =
302 session_entry->RICDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530303 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530304 sme_join_rsp->beaconLength +
305 sme_join_rsp->assocReqLength +
306 sme_join_rsp->assocRspLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800307 session_entry->ricData,
308 sme_join_rsp->parsedRicRspLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530309 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800310 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530311 session_entry->RICDataLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530312 pe_debug("RicLength: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800313 sme_join_rsp->parsedRicRspLen);
314 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800315#ifdef FEATURE_WLAN_ESE
316 if (session_entry->tspecIes != NULL) {
317 sme_join_rsp->tspecIeLen =
318 session_entry->tspecLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530319 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530320 sme_join_rsp->beaconLength +
321 sme_join_rsp->assocReqLength +
322 sme_join_rsp->assocRspLength +
323 sme_join_rsp->parsedRicRspLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800324 session_entry->tspecIes,
325 sme_join_rsp->tspecIeLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530326 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800327 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530328 session_entry->tspecLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530329 pe_debug("ESE-TspecLen: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530330 sme_join_rsp->tspecIeLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800331 }
332#endif
333 sme_join_rsp->aid = session_entry->limAID;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530334 pe_debug("AssocRsp: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530335 sme_join_rsp->assocRspLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800336 sme_join_rsp->vht_channel_width =
337 session_entry->ch_width;
338#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
339 if (session_entry->cc_switch_mode !=
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530340 QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800341 ht_profile = &sme_join_rsp->HTProfile;
342 ht_profile->htSupportedChannelWidthSet =
343 session_entry->htSupportedChannelWidthSet;
344 ht_profile->htRecommendedTxWidthSet =
345 session_entry->htRecommendedTxWidthSet;
346 ht_profile->htSecondaryChannelOffset =
347 session_entry->htSecondaryChannelOffset;
348 ht_profile->dot11mode = session_entry->dot11mode;
349 ht_profile->htCapability = session_entry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800350 ht_profile->vhtCapability =
351 session_entry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800352 ht_profile->apCenterChan = session_entry->ch_center_freq_seg0;
353 ht_profile->apChanWidth = session_entry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800354 }
355#endif
Jeff Johnson11bd4f32017-09-18 08:15:17 -0700356 pe_debug("pLimJoinReq:%pK, pLimReAssocReq:%pK",
Wu Gao2968fc92017-06-19 19:18:34 +0800357 session_entry->pLimJoinReq,
358 session_entry->pLimReAssocReq);
359
360 if (session_entry->pLimJoinReq)
361 join_reassoc_req = session_entry->pLimJoinReq;
362
363 if (session_entry->pLimReAssocReq)
364 join_reassoc_req = session_entry->pLimReAssocReq;
365
366 if (!join_reassoc_req) {
367 pe_err("both pLimJoinReq and pLimReAssocReq NULL");
368 return;
369 }
370
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700371 bss_ie_len = lim_get_ielen_from_bss_description(
Wu Gao2968fc92017-06-19 19:18:34 +0800372 &join_reassoc_req->bssDescription);
373 bss_ies = &join_reassoc_req->bssDescription.ieFields;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700374 is_vendor_ap_1_present = (wlan_get_vendor_ie_ptr_from_oui(
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700375 SIR_MAC_VENDOR_AP_1_OUI, SIR_MAC_VENDOR_AP_1_OUI_LEN,
376 bss_ies, bss_ie_len) != NULL);
377
378 if (mac_ctx->roam.configParam.is_force_1x1 &&
Krunal Sonie6a1cda2017-09-27 15:23:02 -0700379 is_vendor_ap_1_present && (session_entry->nss == 2) &&
380 (mac_ctx->lteCoexAntShare == 0 ||
381 IS_5G_CH(session_entry->currentOperChannel))) {
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700382 /* SET vdev param */
383 pe_debug("sending SMPS intolrent vdev_param");
384 wma_cli_set_command(session_entry->smeSessionId,
385 (int)WMI_VDEV_PARAM_SMPS_INTOLERANT,
386 1, VDEV_CMD);
387
388 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800389 } else {
390 if (session_entry->beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530391 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800392 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530393 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800394 }
395 if (session_entry->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530396 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800397 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530398 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800399 }
400 if (session_entry->assocRsp != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530401 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800402 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530403 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800404 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800405 if (session_entry->ricData != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530406 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800407 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530408 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800409 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800410#ifdef FEATURE_WLAN_ESE
411 if (session_entry->tspecIes != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530412 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800413 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530414 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800415 }
416#endif
417 }
418}
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530419
420/**
421 * lim_add_bss_info() - copy data from session entry to join rsp
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530422 * @sta_ds: Station dph entry
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530423 * @sme_join_rsp: Join response buffer to be filled up
424 *
425 * Return: None
426 */
Jeff Johnson6db011e2016-10-07 07:31:39 -0700427static void lim_add_bss_info(tpDphHashNode sta_ds, tpSirSmeJoinRsp sme_join_rsp)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530428{
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530429 struct parsed_ies *parsed_ies = &sta_ds->parsed_ies;
430
431 if (parsed_ies->hs20vendor_ie.present)
432 sme_join_rsp->hs20vendor_ie = parsed_ies->hs20vendor_ie;
433 if (parsed_ies->vht_caps.present)
434 sme_join_rsp->vht_caps = parsed_ies->vht_caps;
435 if (parsed_ies->ht_caps.present)
436 sme_join_rsp->ht_caps = parsed_ies->ht_caps;
437 if (parsed_ies->ht_operation.present)
438 sme_join_rsp->ht_operation = parsed_ies->ht_operation;
439 if (parsed_ies->vht_operation.present)
440 sme_join_rsp->vht_operation = parsed_ies->vht_operation;
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530441}
442
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530443#ifdef WLAN_FEATURE_FILS_SK
444static void lim_update_fils_seq_num(tpSirSmeJoinRsp sme_join_rsp,
445 tpPESession session_entry)
446{
447 sme_join_rsp->fils_seq_num =
448 session_entry->fils_info->sequence_number;
449}
450#else
451static inline void lim_update_fils_seq_num(tpSirSmeJoinRsp sme_join_rsp,
452 tpPESession session_entry)
453{}
454#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800455/**
456 * lim_send_sme_join_reassoc_rsp() - Send Response to Upper Layers
457 * @mac_ctx: Pointer to Global MAC structure
458 * @msg_type: Indicates message type
459 * @result_code: Indicates the result of previously issued
460 * eWNI_SME_msgType_REQ message
461 * @prot_status_code: Protocol Status Code
462 * @session_entry: PE Session Info
463 * @sme_session_id: SME Session ID
464 * @sme_transaction_id: SME Transaction ID
465 *
466 * This function is called by lim_process_sme_req_messages() to send
467 * eWNI_SME_JOIN_RSP or eWNI_SME_REASSOC_RSP messages to applications
468 * above MAC Software.
469 *
470 * Return: None
471 */
472
473void
474lim_send_sme_join_reassoc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
475 tSirResultCodes result_code, uint16_t prot_status_code,
476 tpPESession session_entry, uint8_t sme_session_id,
477 uint16_t sme_transaction_id)
478{
479 tpSirSmeJoinRsp sme_join_rsp;
480 uint32_t rsp_len;
481 tpDphHashNode sta_ds = NULL;
482#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
483 if (msg_type == eWNI_SME_REASSOC_RSP)
484 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_RSP_EVENT,
485 session_entry, (uint16_t) result_code, 0);
486 else
487 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_RSP_EVENT,
488 session_entry, (uint16_t) result_code, 0);
489#endif /* FEATURE_WLAN_DIAG_SUPPORT */
490
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530491 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800492 lim_msg_str(msg_type), lim_result_code_str(result_code));
493
494 if (session_entry == NULL) {
495 rsp_len = sizeof(tSirSmeJoinRsp);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530496 sme_join_rsp = qdf_mem_malloc(rsp_len);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700497 if (!sme_join_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800498 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800499
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800500 sme_join_rsp->beaconLength = 0;
501 sme_join_rsp->assocReqLength = 0;
502 sme_join_rsp->assocRspLength = 0;
503 } else {
504 rsp_len = session_entry->assocReqLen +
505 session_entry->assocRspLen + session_entry->bcnLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800506 session_entry->RICDataLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800507#ifdef FEATURE_WLAN_ESE
508 session_entry->tspecLen +
509#endif
510 sizeof(tSirSmeJoinRsp) - sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530511 sme_join_rsp = qdf_mem_malloc(rsp_len);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700512 if (!sme_join_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800513 return;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530514
515 if (lim_is_fils_connection(session_entry)) {
516 sme_join_rsp->is_fils_connection = true;
517 lim_update_fils_seq_num(sme_join_rsp,
518 session_entry);
519 }
520
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800521 if (result_code == eSIR_SME_SUCCESS) {
522 sta_ds = dph_get_hash_entry(mac_ctx,
523 DPH_STA_HASH_INDEX_PEER,
524 &session_entry->dph.dphHashTable);
525 if (sta_ds == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530526 pe_err("Get Self Sta Entry fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800527 } else {
528 /* Pass the peer's staId */
529 sme_join_rsp->staId = sta_ds->staIndex;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800530 sme_join_rsp->timingMeasCap =
531 sta_ds->timingMeasCap;
532#ifdef FEATURE_WLAN_TDLS
533 sme_join_rsp->tdls_prohibited =
534 session_entry->tdls_prohibited;
535 sme_join_rsp->tdls_chan_swit_prohibited =
536 session_entry->tdls_chan_swit_prohibited;
537#endif
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530538 sme_join_rsp->nss = sta_ds->nss;
539 sme_join_rsp->max_rate_flags =
540 lim_get_max_rate_flags(mac_ctx, sta_ds);
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530541 lim_add_bss_info(sta_ds, sme_join_rsp);
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530542
543 /* Copy FILS params only for Successful join */
544 populate_fils_connect_params(mac_ctx,
545 session_entry, sme_join_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800546 }
547 }
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530548
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800549 sme_join_rsp->beaconLength = 0;
550 sme_join_rsp->assocReqLength = 0;
551 sme_join_rsp->assocRspLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800552 sme_join_rsp->parsedRicRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800553#ifdef FEATURE_WLAN_ESE
554 sme_join_rsp->tspecIeLen = 0;
555#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800556 lim_handle_join_rsp_status(mac_ctx, session_entry, result_code,
557 sme_join_rsp);
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800558
559 /* Send supported NSS 1x1 to SME */
560 sme_join_rsp->supported_nss_1x1 =
561 session_entry->supported_nss_1x1;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530562 pe_debug("SME Join Rsp is supported NSS 1X1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800563 sme_join_rsp->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800564 }
565
566 sme_join_rsp->messageType = msg_type;
567 sme_join_rsp->length = (uint16_t) rsp_len;
568 sme_join_rsp->statusCode = result_code;
569 sme_join_rsp->protStatusCode = prot_status_code;
570
571 sme_join_rsp->sessionId = sme_session_id;
572 sme_join_rsp->transactionId = sme_transaction_id;
573
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530574 lim_send_sme_join_reassoc_rsp_after_resume(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800575 (uint32_t *)sme_join_rsp);
576}
577
578/**
579 * lim_send_sme_start_bss_rsp()
580 *
581 ***FUNCTION:
582 * This function is called to send eWNI_SME_START_BSS_RSP
583 * message to applications above MAC Software.
584 *
585 ***PARAMS:
586 *
587 ***LOGIC:
588 *
589 ***ASSUMPTIONS:
590 * NA
591 *
592 ***NOTE:
593 * NA
594 *
595 * @param pMac Pointer to Global MAC structure
596 * @param msgType Indicates message type
597 * @param resultCode Indicates the result of previously issued
598 * eWNI_SME_msgType_REQ message
599 *
600 * @return None
601 */
602
603void
604lim_send_sme_start_bss_rsp(tpAniSirGlobal pMac,
605 uint16_t msgType, tSirResultCodes resultCode,
606 tpPESession psessionEntry, uint8_t smesessionId,
607 uint16_t smetransactionId)
608{
609
610 uint16_t size = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700611 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800612 tSirSmeStartBssRsp *pSirSmeRsp;
613 uint16_t ieLen;
614 uint16_t ieOffset, curLen;
615
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530616 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800617 lim_msg_str(msgType), lim_result_code_str(resultCode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800618
619 size = sizeof(tSirSmeStartBssRsp);
620
621 if (psessionEntry == NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530622 pSirSmeRsp = qdf_mem_malloc(size);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700623 if (!pSirSmeRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800624 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800625 } else {
626 /* subtract size of beaconLength + Mac Hdr + Fixed Fields before SSID */
627 ieOffset = sizeof(tAniBeaconStruct) + SIR_MAC_B_PR_SSID_OFFSET;
628 ieLen = psessionEntry->schBeaconOffsetBegin
629 + psessionEntry->schBeaconOffsetEnd - ieOffset;
630 /* calculate the memory size to allocate */
631 size += ieLen;
632
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530633 pSirSmeRsp = qdf_mem_malloc(size);
Arif Hussainf5b6c412018-10-10 19:41:09 -0700634 if (!pSirSmeRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800635 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800636 size = sizeof(tSirSmeStartBssRsp);
637 if (resultCode == eSIR_SME_SUCCESS) {
638
639 sir_copy_mac_addr(pSirSmeRsp->bssDescription.bssId,
640 psessionEntry->bssId);
641
642 /* Read beacon interval from session */
643 pSirSmeRsp->bssDescription.beaconInterval =
644 (uint16_t) psessionEntry->beaconParams.
645 beaconInterval;
646 pSirSmeRsp->bssType = psessionEntry->bssType;
647
648 if (cfg_get_capability_info
649 (pMac, &pSirSmeRsp->bssDescription.capabilityInfo,
650 psessionEntry)
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700651 != QDF_STATUS_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530652 pe_err("could not retrieve Capabilities value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800653
654 lim_get_phy_mode(pMac,
655 (uint32_t *) &pSirSmeRsp->bssDescription.
656 nwType, psessionEntry);
657
658 pSirSmeRsp->bssDescription.channelId =
659 psessionEntry->currentOperChannel;
660
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700661 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800662 curLen = psessionEntry->schBeaconOffsetBegin - ieOffset;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530663 qdf_mem_copy((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800664 ieFields,
665 psessionEntry->pSchBeaconFrameBegin +
666 ieOffset, (uint32_t) curLen);
667
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530668 qdf_mem_copy(((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800669 ieFields) + curLen,
670 psessionEntry->pSchBeaconFrameEnd,
671 (uint32_t) psessionEntry->
672 schBeaconOffsetEnd);
673
Abhishek Singh34a4d862016-10-26 16:01:51 +0530674 pSirSmeRsp->bssDescription.length = (uint16_t)
675 (offsetof(tSirBssDescription, ieFields[0])
676 - sizeof(pSirSmeRsp->bssDescription.length)
677 + ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800678 /* This is the size of the message, subtracting the size of the pointer to ieFields */
679 size += ieLen - sizeof(uint32_t);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700680 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800681#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
682 if (psessionEntry->cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530683 != QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800684 pSirSmeRsp->HTProfile.
685 htSupportedChannelWidthSet =
686 psessionEntry->htSupportedChannelWidthSet;
687 pSirSmeRsp->HTProfile.htRecommendedTxWidthSet =
688 psessionEntry->htRecommendedTxWidthSet;
689 pSirSmeRsp->HTProfile.htSecondaryChannelOffset =
690 psessionEntry->htSecondaryChannelOffset;
691 pSirSmeRsp->HTProfile.dot11mode =
692 psessionEntry->dot11mode;
693 pSirSmeRsp->HTProfile.htCapability =
694 psessionEntry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800695 pSirSmeRsp->HTProfile.vhtCapability =
696 psessionEntry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800697 pSirSmeRsp->HTProfile.apCenterChan =
698 psessionEntry->ch_center_freq_seg0;
699 pSirSmeRsp->HTProfile.apChanWidth =
700 psessionEntry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800701 }
702#endif
703 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800704 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800705 pSirSmeRsp->messageType = msgType;
706 pSirSmeRsp->length = size;
707
708 /* Update SME session Id and transaction Id */
709 pSirSmeRsp->sessionId = smesessionId;
710 pSirSmeRsp->transactionId = smetransactionId;
711 pSirSmeRsp->statusCode = resultCode;
712 if (psessionEntry != NULL)
713 pSirSmeRsp->staId = psessionEntry->staId; /* else it will be always zero smeRsp StaID = 0 */
714
715 mmhMsg.type = msgType;
716 mmhMsg.bodyptr = pSirSmeRsp;
717 mmhMsg.bodyval = 0;
718 if (psessionEntry == NULL) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530719 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
720 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800721 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530722 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
723 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800724 }
725#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
726 lim_diag_event_report(pMac, WLAN_PE_DIAG_START_BSS_RSP_EVENT,
727 psessionEntry, (uint16_t) resultCode, 0);
728#endif /* FEATURE_WLAN_DIAG_SUPPORT */
729
730 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
731} /*** end lim_send_sme_start_bss_rsp() ***/
732
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800733void lim_send_sme_disassoc_deauth_ntf(tpAniSirGlobal pMac,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530734 QDF_STATUS status, uint32_t *pCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800735{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700736 struct scheduler_msg mmhMsg = {0};
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800737 struct scheduler_msg *pMsg = (struct scheduler_msg *) pCtx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800738
739 mmhMsg.type = pMsg->type;
740 mmhMsg.bodyptr = pMsg;
741 mmhMsg.bodyval = 0;
742
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530743 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800744
745 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
746}
747
748/**
749 * lim_send_sme_disassoc_ntf()
750 *
751 ***FUNCTION:
752 * This function is called by limProcessSmeMessages() to send
753 * eWNI_SME_DISASSOC_RSP/IND message to host
754 *
755 ***PARAMS:
756 *
757 ***LOGIC:
758 *
759 ***ASSUMPTIONS:
760 * NA
761 *
762 ***NOTE:
763 * This function is used for sending eWNI_SME_DISASSOC_CNF,
764 * or eWNI_SME_DISASSOC_IND to host depending on
765 * disassociation trigger.
766 *
767 * @param peerMacAddr Indicates the peer MAC addr to which
768 * disassociate was initiated
769 * @param reasonCode Indicates the reason for Disassociation
770 * @param disassocTrigger Indicates the trigger for Disassociation
771 * @param aid Indicates the STAID. This parameter is
772 * present only on AP.
773 *
774 * @return None
775 */
776void
777lim_send_sme_disassoc_ntf(tpAniSirGlobal pMac,
778 tSirMacAddr peerMacAddr,
779 tSirResultCodes reasonCode,
780 uint16_t disassocTrigger,
781 uint16_t aid,
782 uint8_t smesessionId,
783 uint16_t smetransactionId, tpPESession psessionEntry)
784{
785
786 uint8_t *pBuf;
787 tSirSmeDisassocRsp *pSirSmeDisassocRsp;
788 tSirSmeDisassocInd *pSirSmeDisassocInd;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700789 uint32_t *pMsg = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800790 bool failure = false;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700791 tpPESession session = NULL;
792 uint16_t i, assoc_id;
793 tpDphHashNode sta_ds = NULL;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +0530794 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800795
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530796 pe_debug("Disassoc Ntf with trigger : %d reasonCode: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800797 disassocTrigger, reasonCode);
798
799 switch (disassocTrigger) {
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700800 case eLIM_DUPLICATE_ENTRY:
801 /*
802 * Duplicate entry is removed at LIM.
803 * Initiate new entry for other session
804 */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530805 pe_debug("Rcvd eLIM_DUPLICATE_ENTRY for " MAC_ADDRESS_STR,
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700806 MAC_ADDR_ARRAY(peerMacAddr));
807
808 for (i = 0; i < pMac->lim.maxBssId; i++) {
809 if ((&pMac->lim.gpSession[i] != NULL) &&
810 (pMac->lim.gpSession[i].valid) &&
811 (pMac->lim.gpSession[i].pePersona ==
812 QDF_SAP_MODE)) {
813 /* Find the sta ds entry in another session */
814 session = &pMac->lim.gpSession[i];
815 sta_ds = dph_lookup_hash_entry(pMac,
816 peerMacAddr, &assoc_id,
817 &session->dph.dphHashTable);
Abhishek Singh6d6e3d12017-12-04 14:16:00 +0530818 if (sta_ds)
819 break;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700820 }
821 }
822 if (sta_ds
823#ifdef WLAN_FEATURE_11W
824 && (!sta_ds->rmfEnabled)
825#endif
826 ) {
827 if (lim_add_sta(pMac, sta_ds, false, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700828 QDF_STATUS_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530829 pe_err("could not Add STA with assocId: %d",
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700830 sta_ds->assocId);
831 }
Pragaspathi Thilagaraj766c76f2018-08-08 16:44:40 +0530832 status = lim_prepare_disconnect_done_ind(pMac, &pMsg,
833 smesessionId,
834 reasonCode,
835 &peerMacAddr[0]);
836 if (!QDF_IS_STATUS_SUCCESS(status)) {
837 pe_err("Failed to prepare message");
838 return;
839 }
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700840 break;
841
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800842 case eLIM_HOST_DISASSOC:
843 /**
844 * Disassociation response due to
845 * host triggered disassociation
846 */
847
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530848 pSirSmeDisassocRsp = qdf_mem_malloc(sizeof(tSirSmeDisassocRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700849 if (!pSirSmeDisassocRsp) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800850 failure = true;
851 goto error;
852 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530853 pe_debug("send eWNI_SME_DISASSOC_RSP with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800854 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
855 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
856 pSirSmeDisassocRsp->length = sizeof(tSirSmeDisassocRsp);
857 /* sessionId */
858 pBuf = (uint8_t *) &pSirSmeDisassocRsp->sessionId;
859 *pBuf = smesessionId;
860 pBuf++;
861
862 /* transactionId */
863 lim_copy_u16(pBuf, smetransactionId);
864 pBuf += sizeof(uint16_t);
865
866 /* statusCode */
867 lim_copy_u32(pBuf, reasonCode);
868 pBuf += sizeof(tSirResultCodes);
869
870 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530871 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800872 pBuf += sizeof(tSirMacAddr);
873
874 /* Clear Station Stats */
875 /* for sta, it is always 1, IBSS is handled at halInitSta */
876
877#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
878
879 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
880 psessionEntry, (uint16_t) reasonCode, 0);
881#endif
882 pMsg = (uint32_t *) pSirSmeDisassocRsp;
883 break;
884
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530885 case eLIM_PEER_ENTITY_DISASSOC:
886 case eLIM_LINK_MONITORING_DISASSOC:
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +0530887 status = lim_prepare_disconnect_done_ind(pMac, &pMsg,
888 smesessionId,
889 reasonCode, &peerMacAddr[0]);
890 if (!QDF_IS_STATUS_SUCCESS(status)) {
891 pe_err("Failed to prepare message");
892 return;
893 }
894 break;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530895
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800896 default:
897 /**
898 * Disassociation indication due to Disassociation
899 * frame reception from peer entity or due to
900 * loss of link with peer entity.
901 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530902 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700903 if (!pSirSmeDisassocInd) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800904 failure = true;
905 goto error;
906 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530907 pe_debug("send eWNI_SME_DISASSOC_IND with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800908 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
909 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
910 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
911
912 /* Update SME session Id and Transaction Id */
913 pSirSmeDisassocInd->sessionId = smesessionId;
914 pSirSmeDisassocInd->transactionId = smetransactionId;
915 pSirSmeDisassocInd->reasonCode = reasonCode;
916 pBuf = (uint8_t *) &pSirSmeDisassocInd->statusCode;
917
918 lim_copy_u32(pBuf, reasonCode);
919 pBuf += sizeof(tSirResultCodes);
920
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530921 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800922 pBuf += sizeof(tSirMacAddr);
923
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530924 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800925
926#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
927 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
928 psessionEntry, (uint16_t) reasonCode, 0);
929#endif
930 pMsg = (uint32_t *) pSirSmeDisassocInd;
931
932 break;
933 }
934
935error:
936 /* Delete the PE session Created */
Rajeev Kumarcf835a02016-04-15 15:01:31 -0700937 if ((psessionEntry != NULL) && LIM_IS_STA_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800938 pe_delete_session(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800939
940 if (false == failure)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530941 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800942 (uint32_t *) pMsg);
943} /*** end lim_send_sme_disassoc_ntf() ***/
944
945/** -----------------------------------------------------------------
946 \brief lim_send_sme_disassoc_ind() - sends SME_DISASSOC_IND
947
948 After receiving disassociation frame from peer entity, this
949 function sends a eWNI_SME_DISASSOC_IND to SME with a specific
950 reason code.
951
952 \param pMac - global mac structure
953 \param pStaDs - station dph hash node
954 \return none
955 \sa
956 ----------------------------------------------------------------- */
957void
958lim_send_sme_disassoc_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
959 tpPESession psessionEntry)
960{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700961 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800962 tSirSmeDisassocInd *pSirSmeDisassocInd;
963
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530964 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -0700965 if (!pSirSmeDisassocInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800966 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800967
968 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
969 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
970
971 pSirSmeDisassocInd->sessionId = psessionEntry->smeSessionId;
972 pSirSmeDisassocInd->transactionId = psessionEntry->transactionId;
Padma, Santhosh Kumar02289212016-09-30 13:30:08 +0530973 pSirSmeDisassocInd->statusCode = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800974 pSirSmeDisassocInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
975
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530976 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530977 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800978
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530979 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530980 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800981
982 pSirSmeDisassocInd->staId = pStaDs->staIndex;
983
984 mmhMsg.type = eWNI_SME_DISASSOC_IND;
985 mmhMsg.bodyptr = pSirSmeDisassocInd;
986 mmhMsg.bodyval = 0;
987
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530988 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
989 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800990#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
991 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT, psessionEntry,
992 0, (uint16_t) pStaDs->mlmStaContext.disassocReason);
993#endif /* FEATURE_WLAN_DIAG_SUPPORT */
994
995 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
996
997} /*** end lim_send_sme_disassoc_ind() ***/
998
999/** -----------------------------------------------------------------
1000 \brief lim_send_sme_deauth_ind() - sends SME_DEAUTH_IND
1001
1002 After receiving deauthentication frame from peer entity, this
1003 function sends a eWNI_SME_DEAUTH_IND to SME with a specific
1004 reason code.
1005
1006 \param pMac - global mac structure
1007 \param pStaDs - station dph hash node
1008 \return none
1009 \sa
1010 ----------------------------------------------------------------- */
1011void
1012lim_send_sme_deauth_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1013 tpPESession psessionEntry)
1014{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001015 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001016 tSirSmeDeauthInd *pSirSmeDeauthInd;
1017
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301018 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001019 if (!pSirSmeDeauthInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001020 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001021
1022 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1023 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1024
1025 pSirSmeDeauthInd->sessionId = psessionEntry->smeSessionId;
1026 pSirSmeDeauthInd->transactionId = psessionEntry->transactionId;
1027 if (eSIR_INFRA_AP_MODE == psessionEntry->bssType) {
1028 pSirSmeDeauthInd->statusCode =
1029 (tSirResultCodes) pStaDs->mlmStaContext.cleanupTrigger;
1030 } else {
1031 /* Need to indicatet he reascon code over the air */
1032 pSirSmeDeauthInd->statusCode =
1033 (tSirResultCodes) pStaDs->mlmStaContext.disassocReason;
1034 }
1035 /* BSSID */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301036 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301037 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001038 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301039 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301040 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001041 pSirSmeDeauthInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1042
1043 pSirSmeDeauthInd->staId = pStaDs->staIndex;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001044 if (eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON ==
1045 pStaDs->mlmStaContext.disassocReason)
1046 pSirSmeDeauthInd->rssi = pStaDs->del_sta_ctx_rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001047
1048 mmhMsg.type = eWNI_SME_DEAUTH_IND;
1049 mmhMsg.bodyptr = pSirSmeDeauthInd;
1050 mmhMsg.bodyval = 0;
1051
1052 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1053#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1054 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT, psessionEntry,
1055 0, pStaDs->mlmStaContext.cleanupTrigger);
1056#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1057
1058 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1059 return;
1060} /*** end lim_send_sme_deauth_ind() ***/
1061
1062#ifdef FEATURE_WLAN_TDLS
1063/**
1064 * lim_send_sme_tdls_del_sta_ind()
1065 *
1066 ***FUNCTION:
1067 * This function is called to send the TDLS STA context deletion to SME.
1068 *
1069 ***LOGIC:
1070 *
1071 ***ASSUMPTIONS:
1072 *
1073 ***NOTE:
1074 * NA
1075 *
1076 * @param pMac - Pointer to global MAC structure
1077 * @param pStaDs - Pointer to internal STA Datastructure
1078 * @param psessionEntry - Pointer to the session entry
1079 * @param reasonCode - Reason for TDLS sta deletion
1080 * @return None
1081 */
1082void
1083lim_send_sme_tdls_del_sta_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1084 tpPESession psessionEntry, uint16_t reasonCode)
1085{
Frank Liud1a28462017-09-06 22:55:48 +08001086 struct tdls_event_info info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001087
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301088 pe_debug("Delete TDLS Peer "MAC_ADDRESS_STR "with reason code: %d",
Nitesh Shah82c52812016-12-27 12:27:51 +05301089 MAC_ADDR_ARRAY(pStaDs->staAddr), reasonCode);
Frank Liud1a28462017-09-06 22:55:48 +08001090 info.vdev_id = psessionEntry->smeSessionId;
1091 qdf_mem_copy(info.peermac.bytes, pStaDs->staAddr, QDF_MAC_ADDR_SIZE);
1092 info.message_type = TDLS_PEER_DISCONNECTED;
1093 info.peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001094
Frank Liud1a28462017-09-06 22:55:48 +08001095 tgt_tdls_event_handler(pMac->psoc, &info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001096
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001097 return;
1098} /*** end lim_send_sme_tdls_del_sta_ind() ***/
1099
1100/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001101 * lim_send_sme_mgmt_tx_completion()
1102 *
1103 ***FUNCTION:
1104 * This function is called to send the eWNI_SME_MGMT_FRM_TX_COMPLETION_IND
1105 * message to SME.
1106 *
1107 ***LOGIC:
1108 *
1109 ***ASSUMPTIONS:
1110 *
1111 ***NOTE:
1112 * NA
1113 *
1114 * @param pMac - Pointer to global MAC structure
1115 * @param psessionEntry - Pointer to the session entry
1116 * @param txCompleteStatus - TX Complete Status of Mgmt Frames
1117 * @return None
1118 */
1119void
1120lim_send_sme_mgmt_tx_completion(tpAniSirGlobal pMac,
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301121 uint32_t sme_session_id,
1122 uint32_t txCompleteStatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001123{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001124 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001125 tSirMgmtTxCompletionInd *pSirMgmtTxCompletionInd;
1126
1127 pSirMgmtTxCompletionInd =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301128 qdf_mem_malloc(sizeof(tSirMgmtTxCompletionInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001129 if (!pSirMgmtTxCompletionInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001130 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001131 /* messageType */
1132 pSirMgmtTxCompletionInd->messageType =
1133 eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1134 pSirMgmtTxCompletionInd->length = sizeof(tSirMgmtTxCompletionInd);
1135
1136 /* sessionId */
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301137 pSirMgmtTxCompletionInd->sessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001138
1139 pSirMgmtTxCompletionInd->txCompleteStatus = txCompleteStatus;
1140
1141 mmhMsg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1142 mmhMsg.bodyptr = pSirMgmtTxCompletionInd;
1143 mmhMsg.bodyval = 0;
1144
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07001145 pSirMgmtTxCompletionInd->psoc = pMac->psoc;
1146 mmhMsg.callback = tgt_tdls_send_mgmt_tx_completion;
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05301147 scheduler_post_message(QDF_MODULE_ID_PE,
1148 QDF_MODULE_ID_TDLS,
1149 QDF_MODULE_ID_TARGET_IF, &mmhMsg);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07001150 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001151} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1152
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001153#endif /* FEATURE_WLAN_TDLS */
1154
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301155QDF_STATUS lim_prepare_disconnect_done_ind(tpAniSirGlobal mac_ctx,
1156 uint32_t **msg,
1157 uint8_t session_id,
1158 tSirResultCodes reason_code,
1159 uint8_t *peer_mac_addr)
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301160{
1161 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301162
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301163 sir_sme_dis_ind = qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001164 if (!sir_sme_dis_ind)
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301165 return QDF_STATUS_E_FAILURE;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301166
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301167 pe_debug("Prepare eWNI_SME_DISCONNECT_DONE_IND withretCode: %d",
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301168 reason_code);
1169
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301170 sir_sme_dis_ind->message_type = eWNI_SME_DISCONNECT_DONE_IND;
1171 sir_sme_dis_ind->length = sizeof(*sir_sme_dis_ind);
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301172 sir_sme_dis_ind->session_id = session_id;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301173 if (peer_mac_addr)
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05301174 qdf_mem_copy(sir_sme_dis_ind->peer_mac,
1175 peer_mac_addr, ETH_ALEN);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301176
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301177 /*
1178 * Instead of sending deauth reason code as 505 which is
1179 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1180 * Send reason code as zero to Supplicant
1181 */
1182 if (reason_code == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1183 sir_sme_dis_ind->reason_code = 0;
1184 else
1185 sir_sme_dis_ind->reason_code = reason_code;
1186
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301187 *msg = (uint32_t *)sir_sme_dis_ind;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301188
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301189 return QDF_STATUS_SUCCESS;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301190}
1191
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001192/**
1193 * lim_send_sme_deauth_ntf()
1194 *
1195 ***FUNCTION:
1196 * This function is called by limProcessSmeMessages() to send
1197 * eWNI_SME_DISASSOC_RSP/IND message to host
1198 *
1199 ***PARAMS:
1200 *
1201 ***LOGIC:
1202 *
1203 ***ASSUMPTIONS:
1204 * NA
1205 *
1206 ***NOTE:
1207 * This function is used for sending eWNI_SME_DEAUTH_CNF or
1208 * eWNI_SME_DEAUTH_IND to host depending on deauthentication trigger.
1209 *
1210 * @param peerMacAddr Indicates the peer MAC addr to which
1211 * deauthentication was initiated
1212 * @param reasonCode Indicates the reason for Deauthetication
1213 * @param deauthTrigger Indicates the trigger for Deauthetication
1214 * @param aid Indicates the STAID. This parameter is present
1215 * only on AP.
1216 *
1217 * @return None
1218 */
1219void
1220lim_send_sme_deauth_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
1221 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1222 uint16_t aid, uint8_t smesessionId,
1223 uint16_t smetransactionId)
1224{
1225 uint8_t *pBuf;
1226 tSirSmeDeauthRsp *pSirSmeDeauthRsp;
1227 tSirSmeDeauthInd *pSirSmeDeauthInd;
1228 tpPESession psessionEntry;
1229 uint8_t sessionId;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301230 uint32_t *pMsg = NULL;
1231 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001232
1233 psessionEntry = pe_find_session_by_bssid(pMac, peerMacAddr, &sessionId);
1234 switch (deauthTrigger) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001235 case eLIM_HOST_DEAUTH:
1236 /**
1237 * Deauthentication response to host triggered
1238 * deauthentication.
1239 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301240 pSirSmeDeauthRsp = qdf_mem_malloc(sizeof(tSirSmeDeauthRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001241 if (!pSirSmeDeauthRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001242 return;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301243 pe_debug("send eWNI_SME_DEAUTH_RSP with retCode: %d for" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001244 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1245 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
1246 pSirSmeDeauthRsp->length = sizeof(tSirSmeDeauthRsp);
1247 pSirSmeDeauthRsp->statusCode = reasonCode;
1248 pSirSmeDeauthRsp->sessionId = smesessionId;
1249 pSirSmeDeauthRsp->transactionId = smetransactionId;
1250
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -08001251 pBuf = (uint8_t *) pSirSmeDeauthRsp->peer_macaddr.bytes;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301252 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001253
1254#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1255 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
1256 psessionEntry, 0, (uint16_t) reasonCode);
1257#endif
1258 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1259
1260 break;
1261
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301262 case eLIM_PEER_ENTITY_DEAUTH:
1263 case eLIM_LINK_MONITORING_DEAUTH:
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301264 status = lim_prepare_disconnect_done_ind(pMac, &pMsg,
1265 smesessionId, reasonCode,
1266 &peerMacAddr[0]);
1267 if (!QDF_IS_STATUS_SUCCESS(status)) {
1268 pe_err("Failed to prepare message");
1269 return;
1270 }
1271 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001272 default:
1273 /**
1274 * Deauthentication indication due to Deauthentication
1275 * frame reception from peer entity or due to
1276 * loss of link with peer entity.
1277 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301278 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001279 if (!pSirSmeDeauthInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001280 return;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301281 pe_debug("send eWNI_SME_DEAUTH_IND with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001282 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1283 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1284 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1285 pSirSmeDeauthInd->reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
1286
1287 /* sessionId */
1288 pBuf = (uint8_t *) &pSirSmeDeauthInd->sessionId;
1289 *pBuf++ = smesessionId;
1290
1291 /* transaction ID */
1292 lim_copy_u16(pBuf, smetransactionId);
1293 pBuf += sizeof(uint16_t);
1294
1295 /* status code */
1296 lim_copy_u32(pBuf, reasonCode);
1297 pBuf += sizeof(tSirResultCodes);
1298
1299 /* bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301300 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001301 pBuf += sizeof(tSirMacAddr);
1302
1303 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301304 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301305 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001306
1307#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1308 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
1309 psessionEntry, 0, (uint16_t) reasonCode);
1310#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1311 pMsg = (uint32_t *) pSirSmeDeauthInd;
1312
1313 break;
1314 }
1315
1316 /*Delete the PE session created */
1317 if (psessionEntry != NULL) {
1318 pe_delete_session(pMac, psessionEntry);
1319 }
1320
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301321 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001322 (uint32_t *) pMsg);
1323
1324} /*** end lim_send_sme_deauth_ntf() ***/
1325
1326/**
1327 * lim_send_sme_wm_status_change_ntf() - Send Notification
1328 * @mac_ctx: Global MAC Context
1329 * @status_change_code: Indicates the change in the wireless medium.
1330 * @status_change_info: Indicates the information associated with
1331 * change in the wireless medium.
1332 * @info_len: Indicates the length of status change information
1333 * being sent.
1334 * @session_id SessionID
1335 *
1336 * This function is called by limProcessSmeMessages() to send
1337 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1338 *
1339 * Return: None
1340 */
1341void
1342lim_send_sme_wm_status_change_ntf(tpAniSirGlobal mac_ctx,
1343 tSirSmeStatusChangeCode status_change_code,
1344 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1345{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001346 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001347 tSirSmeWmStatusChangeNtf *wm_status_change_ntf;
Naveen Rawate01ed172016-11-17 11:34:50 -08001348 uint32_t max_info_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001349
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301350 wm_status_change_ntf = qdf_mem_malloc(sizeof(tSirSmeWmStatusChangeNtf));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001351 if (!wm_status_change_ntf)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001352 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001353
1354 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1355 msg.bodyval = 0;
1356 msg.bodyptr = wm_status_change_ntf;
1357
1358 switch (status_change_code) {
Naveen Rawate01ed172016-11-17 11:34:50 -08001359 case eSIR_SME_AP_CAPS_CHANGED:
1360 max_info_len = sizeof(tSirSmeApNewCaps);
1361 break;
1362 case eSIR_SME_JOINED_NEW_BSS:
1363 max_info_len = sizeof(tSirSmeNewBssInfo);
1364 break;
1365 default:
1366 max_info_len = sizeof(wm_status_change_ntf->statusChangeInfo);
1367 break;
1368 }
1369
1370 switch (status_change_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001371 case eSIR_SME_RADAR_DETECTED:
1372 break;
1373 default:
1374 wm_status_change_ntf->messageType =
1375 eWNI_SME_WM_STATUS_CHANGE_NTF;
1376 wm_status_change_ntf->statusChangeCode = status_change_code;
1377 wm_status_change_ntf->length = sizeof(tSirSmeWmStatusChangeNtf);
1378 wm_status_change_ntf->sessionId = session_id;
Naveen Rawate01ed172016-11-17 11:34:50 -08001379 if (info_len <= max_info_len && status_change_info) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301380 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001381 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1382 (uint8_t *) status_change_info, info_len);
1383 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301384 pe_debug("StatusChg code: 0x%x length: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001385 status_change_code, info_len);
1386 break;
1387 }
1388
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301389 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, session_id, msg.type));
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001390 if (QDF_STATUS_SUCCESS != lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301391 qdf_mem_free(wm_status_change_ntf);
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301392 pe_err("lim_sys_process_mmh_msg_api failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001393 }
1394
1395} /*** end lim_send_sme_wm_status_change_ntf() ***/
1396
1397/**
1398 * lim_send_sme_set_context_rsp()
1399 *
1400 ***FUNCTION:
1401 * This function is called by limProcessSmeMessages() to send
1402 * eWNI_SME_SETCONTEXT_RSP message to host
1403 *
1404 ***PARAMS:
1405 *
1406 ***LOGIC:
1407 *
1408 ***ASSUMPTIONS:
1409 * NA
1410 *
1411 ***NOTE:
1412 *
1413 * @param pMac Pointer to Global MAC structure
1414 * @param peerMacAddr Indicates the peer MAC addr to which
1415 * setContext was performed
1416 * @param aid Indicates the aid corresponding to the peer MAC
1417 * address
1418 * @param resultCode Indicates the result of previously issued
1419 * eWNI_SME_SETCONTEXT_RSP message
1420 *
1421 * @return None
1422 */
1423void
1424lim_send_sme_set_context_rsp(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301425 struct qdf_mac_addr peer_macaddr, uint16_t aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001426 tSirResultCodes resultCode,
1427 tpPESession psessionEntry, uint8_t smesessionId,
1428 uint16_t smetransactionId)
1429{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001430 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001431 tSirSmeSetContextRsp *pSirSmeSetContextRsp;
1432
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301433 pSirSmeSetContextRsp = qdf_mem_malloc(sizeof(tSirSmeSetContextRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001434 if (!pSirSmeSetContextRsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001435 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001436
1437 pSirSmeSetContextRsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1438 pSirSmeSetContextRsp->length = sizeof(tSirSmeSetContextRsp);
1439 pSirSmeSetContextRsp->statusCode = resultCode;
1440
Anurag Chouhanc5548422016-02-24 18:33:27 +05301441 qdf_copy_macaddr(&pSirSmeSetContextRsp->peer_macaddr, &peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001442
1443 /* Update SME session and transaction Id */
1444 pSirSmeSetContextRsp->sessionId = smesessionId;
1445 pSirSmeSetContextRsp->transactionId = smetransactionId;
1446
1447 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
1448 mmhMsg.bodyptr = pSirSmeSetContextRsp;
1449 mmhMsg.bodyval = 0;
1450 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301451 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1452 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001453 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301454 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1455 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001456 }
1457
1458#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1459 lim_diag_event_report(pMac, WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
1460 psessionEntry, (uint16_t) resultCode, 0);
1461#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1462
Himanshu Agarwal2785d242018-05-09 12:39:52 +05301463 pMac->lim.sme_msg_callback(pMac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001464} /*** end lim_send_sme_set_context_rsp() ***/
1465
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001466/** -----------------------------------------------------------------
1467 \brief lim_send_sme_addts_rsp() - sends SME ADDTS RSP
1468 \ This function sends a eWNI_SME_ADDTS_RSP to SME.
1469 \ SME only looks at rc and tspec field.
1470 \param pMac - global mac structure
1471 \param rspReqd - is SmeAddTsRsp required
1472 \param status - status code of SME_ADD_TS_RSP
1473 \return tspec
1474 \sa
1475 ----------------------------------------------------------------- */
1476void
1477lim_send_sme_addts_rsp(tpAniSirGlobal pMac, uint8_t rspReqd, uint32_t status,
1478 tpPESession psessionEntry, tSirMacTspecIE tspec,
1479 uint8_t smesessionId, uint16_t smetransactionId)
1480{
1481 tpSirAddtsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001482 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001483
1484 if (!rspReqd)
1485 return;
1486
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301487 rsp = qdf_mem_malloc(sizeof(tSirAddtsRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001488 if (!rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001489 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001490
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001491 rsp->messageType = eWNI_SME_ADDTS_RSP;
1492 rsp->rc = status;
1493 rsp->rsp.status = (enum eSirMacStatusCodes)status;
1494 rsp->rsp.tspec = tspec;
1495 /* Update SME session Id and transcation Id */
1496 rsp->sessionId = smesessionId;
1497 rsp->transactionId = smetransactionId;
1498
1499 mmhMsg.type = eWNI_SME_ADDTS_RSP;
1500 mmhMsg.bodyptr = rsp;
1501 mmhMsg.bodyval = 0;
1502 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301503 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1504 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001505 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301506 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1507 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001508 }
1509#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1510 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_RSP_EVENT, psessionEntry, 0,
1511 0);
1512#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1513
1514 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1515 return;
1516}
1517
1518void
1519lim_send_sme_delts_rsp(tpAniSirGlobal pMac, tpSirDeltsReq delts, uint32_t status,
1520 tpPESession psessionEntry, uint8_t smesessionId,
1521 uint16_t smetransactionId)
1522{
1523 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001524 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001525
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301526 pe_debug("SendSmeDeltsRsp aid: %d tsid: %d up: %d status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001527 delts->aid,
1528 delts->req.tsinfo.traffic.tsid,
1529 delts->req.tsinfo.traffic.userPrio, status);
1530 if (!delts->rspReqd)
1531 return;
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 if (psessionEntry != NULL) {
1538
1539 rsp->aid = delts->aid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301540 qdf_copy_macaddr(&rsp->macaddr, &delts->macaddr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301541 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) &delts->req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001542 sizeof(tSirDeltsReqInfo));
1543 }
1544
1545 rsp->messageType = eWNI_SME_DELTS_RSP;
1546 rsp->rc = status;
1547
1548 /* Update SME session Id and transcation Id */
1549 rsp->sessionId = smesessionId;
1550 rsp->transactionId = smetransactionId;
1551
1552 mmhMsg.type = eWNI_SME_DELTS_RSP;
1553 mmhMsg.bodyptr = rsp;
1554 mmhMsg.bodyval = 0;
1555 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301556 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1557 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001558 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301559 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1560 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001561 }
1562#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1563 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_RSP_EVENT, psessionEntry,
1564 (uint16_t) status, 0);
1565#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1566
1567 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1568}
1569
1570void
1571lim_send_sme_delts_ind(tpAniSirGlobal pMac, tpSirDeltsReqInfo delts, uint16_t aid,
1572 tpPESession psessionEntry)
1573{
1574 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001575 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001576
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301577 pe_debug("SendSmeDeltsInd aid: %d tsid: %d up: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001578 aid, delts->tsinfo.traffic.tsid, delts->tsinfo.traffic.userPrio);
1579
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301580 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001581 if (!rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001582 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001583
1584 rsp->messageType = eWNI_SME_DELTS_IND;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001585 rsp->rc = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001586 rsp->aid = aid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301587 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) delts, sizeof(*delts));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001588
1589 /* Update SME session Id and SME transaction Id */
1590
1591 rsp->sessionId = psessionEntry->smeSessionId;
1592 rsp->transactionId = psessionEntry->transactionId;
1593
1594 mmhMsg.type = eWNI_SME_DELTS_IND;
1595 mmhMsg.bodyptr = rsp;
1596 mmhMsg.bodyval = 0;
1597 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1598#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1599 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_IND_EVENT, psessionEntry, 0,
1600 0);
1601#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1602
1603 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1604}
1605
Naveen Rawatfa2a1002018-05-17 16:06:37 -07001606#ifndef QCA_SUPPORT_CP_STATS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001607/**
1608 * lim_send_sme_pe_statistics_rsp()
1609 *
1610 ***FUNCTION:
1611 * This function is called to send 802.11 statistics response to HDD.
1612 * This function posts the result back to HDD. This is a response to
1613 * HDD's request for statistics.
1614 *
1615 ***PARAMS:
1616 *
1617 ***LOGIC:
1618 *
1619 ***ASSUMPTIONS:
1620 * NA
1621 *
1622 ***NOTE:
1623 * NA
1624 *
1625 * @param pMac Pointer to Global MAC structure
1626 * @param p80211Stats Statistics sent in response
1627 * @param resultCode TODO:
1628 *
1629 *
1630 * @return none
1631 */
1632
1633void
1634lim_send_sme_pe_statistics_rsp(tpAniSirGlobal pMac, uint16_t msgType, void *stats)
1635{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001636 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001637 uint8_t sessionId;
1638 tAniGetPEStatsRsp *pPeStats = (tAniGetPEStatsRsp *) stats;
1639 tpPESession pPeSessionEntry;
1640
1641 /* Get the Session Id based on Sta Id */
1642 pPeSessionEntry =
1643 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1644
1645 /* Fill the Session Id */
1646 if (NULL != pPeSessionEntry) {
1647 /* Fill the Session Id */
1648 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1649 }
1650
1651 pPeStats->msgType = eWNI_SME_GET_STATISTICS_RSP;
1652
1653 /* msgType should be WMA_GET_STATISTICS_RSP */
1654 mmhMsg.type = eWNI_SME_GET_STATISTICS_RSP;
1655
1656 mmhMsg.bodyptr = stats;
1657 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301658 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001659 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1660
1661 return;
1662
1663} /*** end lim_send_sme_pe_statistics_rsp() ***/
Naveen Rawatfa2a1002018-05-17 16:06:37 -07001664#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001665
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001666#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001667/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001668 * lim_send_sme_pe_ese_tsm_rsp() - send tsm response
1669 * @pMac: Pointer to global pMac structure
1670 * @pStats: Pointer to TSM Stats
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001671 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001672 * This function is called to send tsm stats response to HDD.
1673 * This function posts the result back to HDD. This is a response to
1674 * HDD's request to get tsm stats.
1675 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001676 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001677 */
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001678void lim_send_sme_pe_ese_tsm_rsp(tpAniSirGlobal pMac,
1679 tAniGetTsmStatsRsp *pStats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001680{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001681 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001682 uint8_t sessionId;
1683 tAniGetTsmStatsRsp *pPeStats = (tAniGetTsmStatsRsp *) pStats;
1684 tpPESession pPeSessionEntry = NULL;
1685
1686 /* Get the Session Id based on Sta Id */
1687 pPeSessionEntry =
1688 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1689
1690 /* Fill the Session Id */
1691 if (NULL != pPeSessionEntry) {
1692 /* Fill the Session Id */
1693 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1694 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301695 pe_err("Session not found for the Sta id: %d",
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301696 pPeStats->staId);
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05301697 qdf_mem_free(pPeStats->tsmStatsReq);
1698 qdf_mem_free(pPeStats);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001699 return;
1700 }
1701
1702 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
1703 pPeStats->tsmMetrics.RoamingCount
1704 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
1705 pPeStats->tsmMetrics.RoamingDly
1706 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
1707
1708 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
1709 mmhMsg.bodyptr = pStats;
1710 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301711 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001712 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1713
1714 return;
1715} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
1716
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001717#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001718
1719void
1720lim_send_sme_ibss_peer_ind(tpAniSirGlobal pMac,
1721 tSirMacAddr peerMacAddr,
1722 uint16_t staIndex,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001723 uint8_t *beacon,
1724 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
1725{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001726 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001727 tSmeIbssPeerInd *pNewPeerInd;
1728
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301729 pNewPeerInd = qdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
Arif Hussainf5b6c412018-10-10 19:41:09 -07001730 if (!pNewPeerInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001731 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001732
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301733 qdf_mem_copy((uint8_t *) pNewPeerInd->peer_addr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301734 peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001735 pNewPeerInd->staId = staIndex;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001736 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
1737 pNewPeerInd->mesgType = msgType;
1738 pNewPeerInd->sessionId = sessionId;
1739
1740 if (beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301741 qdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001742 sizeof(tSmeIbssPeerInd)), (void *)beacon,
1743 beaconLen);
1744 }
1745
1746 mmhMsg.type = msgType;
1747 mmhMsg.bodyptr = pNewPeerInd;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301748 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001749 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1750
1751}
1752
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07001753/**
1754 * lim_process_csa_wbw_ie() - Process CSA Wide BW IE
1755 * @mac_ctx: pointer to global adapter context
1756 * @csa_params: pointer to CSA parameters
1757 * @chnl_switch_info:pointer to channel switch parameters
1758 * @session_entry: session pointer
1759 *
1760 * Return: None
1761 */
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001762static QDF_STATUS lim_process_csa_wbw_ie(tpAniSirGlobal mac_ctx,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001763 struct csa_offload_params *csa_params,
1764 tLimWiderBWChannelSwitchInfo *chnl_switch_info,
1765 tpPESession session_entry)
1766{
Amar Singhal5cccafe2017-02-15 12:42:58 -08001767 struct ch_params ch_params = {0};
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001768 uint8_t ap_new_ch_width;
1769 bool new_ch_width_dfn = false;
1770 uint8_t center_freq_diff;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001771 uint32_t fw_vht_ch_wd = wma_get_vht_ch_width() + 1;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001772
1773 ap_new_ch_width = csa_params->new_ch_width + 1;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001774
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001775 pe_debug("new channel: %d new_ch_width: %d seg0: %d seg1: %d",
1776 csa_params->channel, ap_new_ch_width,
1777 csa_params->new_ch_freq_seg1,
1778 csa_params->new_ch_freq_seg2);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001779
1780 if ((ap_new_ch_width != CH_WIDTH_80MHZ) &&
1781 (ap_new_ch_width != CH_WIDTH_160MHZ) &&
1782 (ap_new_ch_width != CH_WIDTH_80P80MHZ)) {
1783 pe_err("CSA wide BW IE has wrong ch_width %d",
1784 csa_params->new_ch_width);
1785 return QDF_STATUS_E_INVAL;
1786 }
1787
1788 if (!csa_params->new_ch_freq_seg1 && !csa_params->new_ch_freq_seg2) {
1789 pe_err("CSA wide BW IE has invalid center freq");
1790 return QDF_STATUS_E_INVAL;
1791 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001792 if ((ap_new_ch_width == CH_WIDTH_80MHZ) &&
1793 csa_params->new_ch_freq_seg2) {
1794 new_ch_width_dfn = true;
1795 if (csa_params->new_ch_freq_seg2 >
1796 csa_params->new_ch_freq_seg1)
1797 center_freq_diff = csa_params->new_ch_freq_seg2 -
1798 csa_params->new_ch_freq_seg1;
1799 else
1800 center_freq_diff = csa_params->new_ch_freq_seg1 -
1801 csa_params->new_ch_freq_seg2;
1802 if (center_freq_diff == CENTER_FREQ_DIFF_160MHz)
1803 ap_new_ch_width = CH_WIDTH_160MHZ;
1804 else if (center_freq_diff > CENTER_FREQ_DIFF_80P80MHz)
1805 ap_new_ch_width = CH_WIDTH_80P80MHZ;
1806 else
1807 ap_new_ch_width = CH_WIDTH_80MHZ;
1808 }
1809 session_entry->gLimChannelSwitch.state =
1810 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1811 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
1812 !new_ch_width_dfn) {
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001813 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1814 CH_TO_CNTR_FREQ_DIFF_160MHz) {
1815 pe_err("CSA wide BW IE has invalid center freq");
1816 return QDF_STATUS_E_INVAL;
1817 }
1818
1819 if (ap_new_ch_width > fw_vht_ch_wd) {
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001820 pe_debug("New BW is not supported, setting BW to %d",
1821 fw_vht_ch_wd);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001822 ap_new_ch_width = fw_vht_ch_wd;
1823 }
1824 ch_params.ch_width = ap_new_ch_width ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001825 wlan_reg_set_channel_params(mac_ctx->pdev,
1826 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001827 ap_new_ch_width = ch_params.ch_width;
1828 csa_params->new_ch_freq_seg1 = ch_params.center_freq_seg0;
1829 csa_params->new_ch_freq_seg2 = ch_params.center_freq_seg1;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001830 } else if (!new_ch_width_dfn) {
1831 if (ap_new_ch_width > fw_vht_ch_wd) {
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001832 pe_debug("New BW is not supported, setting BW to %d",
1833 fw_vht_ch_wd);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001834 ap_new_ch_width = fw_vht_ch_wd;
1835 }
1836 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1837 CH_TO_CNTR_FREQ_DIFF_80MHz) {
1838 pe_err("CSA wide BW IE has invalid center freq");
1839 return QDF_STATUS_E_INVAL;
1840 }
1841 csa_params->new_ch_freq_seg2 = 0;
1842 }
1843 if (new_ch_width_dfn) {
1844 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1845 CH_TO_CNTR_FREQ_DIFF_80MHz) {
1846 pe_err("CSA wide BW IE has invalid center freq");
1847 return QDF_STATUS_E_INVAL;
1848 }
1849 if (ap_new_ch_width > fw_vht_ch_wd) {
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001850 pe_debug("New width is not supported, setting BW to %d",
1851 fw_vht_ch_wd);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001852 ap_new_ch_width = fw_vht_ch_wd;
1853 }
1854 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
1855 (csa_params->new_ch_freq_seg1 !=
1856 csa_params->channel +
1857 CH_TO_CNTR_FREQ_DIFF_160MHz)) {
1858 pe_err("wide BW IE has invalid 160M center freq");
1859 csa_params->new_ch_freq_seg2 = 0;
1860 ap_new_ch_width = CH_WIDTH_80MHZ;
1861 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001862 }
1863 chnl_switch_info->newChanWidth = ap_new_ch_width;
1864 chnl_switch_info->newCenterChanFreq0 = csa_params->new_ch_freq_seg1;
1865 chnl_switch_info->newCenterChanFreq1 = csa_params->new_ch_freq_seg2;
1866
1867 if (session_entry->ch_width == ap_new_ch_width)
1868 goto prnt_log;
1869
1870 if (session_entry->ch_width == CH_WIDTH_80MHZ) {
1871 chnl_switch_info->newChanWidth = CH_WIDTH_80MHZ;
1872 chnl_switch_info->newCenterChanFreq1 = 0;
1873 } else {
1874 session_entry->ch_width = ap_new_ch_width;
1875 chnl_switch_info->newChanWidth = ap_new_ch_width;
1876 }
1877prnt_log:
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301878 pe_debug("new channel: %d new_ch_width: %d seg0: %d seg1: %d",
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001879 csa_params->channel,
1880 chnl_switch_info->newChanWidth,
1881 chnl_switch_info->newCenterChanFreq0,
1882 chnl_switch_info->newCenterChanFreq1);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001883
1884 return QDF_STATUS_SUCCESS;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001885}
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001886
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001887/**
1888 * lim_handle_csa_offload_msg() - Handle CSA offload message
1889 * @mac_ctx: pointer to global adapter context
1890 * @msg: Message pointer.
1891 *
1892 * Return: None
1893 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001894void lim_handle_csa_offload_msg(tpAniSirGlobal mac_ctx,
1895 struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001896{
1897 tpPESession session_entry;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001898 struct scheduler_msg mmh_msg = {0};
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301899 struct csa_offload_params *csa_params =
1900 (struct csa_offload_params *) (msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001901 tpSmeCsaOffloadInd csa_offload_ind;
1902 tpDphHashNode sta_ds = NULL;
1903 uint8_t session_id;
1904 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05301905 uint16_t chan_space = 0;
Krunal Sonie2c45a92018-05-03 11:51:26 -07001906 struct ch_params ch_params = {0};
Gupta, Kapil121bf212015-11-25 19:21:29 +05301907
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001908 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08001909 tLimChannelSwitchInfo *lim_ch_switch = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001910
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301911 pe_debug("handle csa offload msg");
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301912
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001913 if (!csa_params) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301914 pe_err("limMsgQ body ptr is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001915 return;
1916 }
1917
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05301918 csa_offload_ind = qdf_mem_malloc(sizeof(tSmeCsaOffloadInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -07001919 if (!csa_offload_ind)
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05301920 goto err;
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05301921
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001922 session_entry =
1923 pe_find_session_by_bssid(mac_ctx,
1924 csa_params->bssId, &session_id);
1925 if (!session_entry) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301926 pe_err("Session does not exists for %pM",
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301927 csa_params->bssId);
Pragaspathi Thilagaraj655db192018-06-19 17:41:37 +05301928 qdf_mem_free(csa_offload_ind);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001929 goto err;
1930 }
1931
1932 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
1933 &session_entry->dph.dphHashTable);
1934
1935 if (!sta_ds) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301936 pe_err("sta_ds does not exist");
Pragaspathi Thilagaraj655db192018-06-19 17:41:37 +05301937 qdf_mem_free(csa_offload_ind);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001938 goto err;
1939 }
1940
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001941 if (!LIM_IS_STA_ROLE(session_entry)) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301942 pe_debug("Invalid role to handle CSA");
Pragaspathi Thilagaraj655db192018-06-19 17:41:37 +05301943 qdf_mem_free(csa_offload_ind);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001944 goto err;
1945 }
Masti, Narayanraddi1c630442015-11-02 12:03:50 +05301946
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001947 /*
1948 * on receiving channel switch announcement from AP, delete all
1949 * TDLS peers before leaving BSS and proceed for channel switch
1950 */
1951 lim_delete_tdls_peers(mac_ctx, session_entry);
Gupta, Kapil121bf212015-11-25 19:21:29 +05301952
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001953 lim_ch_switch = &session_entry->gLimChannelSwitch;
1954 session_entry->gLimChannelSwitch.switchMode =
1955 csa_params->switch_mode;
1956 /* timer already started by firmware, switch immediately */
1957 session_entry->gLimChannelSwitch.switchCount = 0;
1958 session_entry->gLimChannelSwitch.primaryChannel =
1959 csa_params->channel;
1960 session_entry->gLimChannelSwitch.state =
1961 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
1962 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
1963 lim_ch_switch->sec_ch_offset =
1964 session_entry->htSecondaryChannelOffset;
1965 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
1966 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
1967 chnl_switch_info =
1968 &session_entry->gLimWiderBWChannelSwitch;
1969
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001970 pe_debug("vht: %d ht: %d flag: %x chan: %d, sec_ch_offset %d",
1971 session_entry->vhtCapability,
1972 session_entry->htSupportedChannelWidthSet,
1973 csa_params->ies_present_flag,
1974 csa_params->channel,
1975 csa_params->sec_chan_offset);
1976 pe_debug("seg1: %d seg2: %d width: %d country: %s class: %d",
1977 csa_params->new_ch_freq_seg1,
1978 csa_params->new_ch_freq_seg2,
1979 csa_params->new_ch_width,
1980 mac_ctx->scan.countryCodeCurrent,
1981 csa_params->new_op_class);
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05301982
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001983 if (session_entry->vhtCapability &&
1984 session_entry->htSupportedChannelWidthSet) {
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001985 if ((csa_params->ies_present_flag & lim_wbw_ie_present) &&
1986 (QDF_STATUS_SUCCESS == lim_process_csa_wbw_ie(mac_ctx,
1987 csa_params, chnl_switch_info,
1988 session_entry))) {
1989 pe_debug("CSA wide BW IE process successful");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001990 lim_ch_switch->sec_ch_offset =
Abhishek Singhaf639b42017-06-16 14:14:36 +05301991 PHY_SINGLE_CHANNEL_CENTERED;
1992 if (chnl_switch_info->newChanWidth) {
1993 if (csa_params->channel <
1994 csa_params->new_ch_freq_seg1)
1995 lim_ch_switch->sec_ch_offset =
1996 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1997 else
1998 lim_ch_switch->sec_ch_offset =
1999 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
2000 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002001 } else if (csa_params->ies_present_flag
2002 & lim_xcsa_ie_present) {
2003 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002004 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002005 mac_ctx->scan.countryCodeCurrent,
2006 csa_params->channel,
2007 csa_params->new_op_class);
2008 session_entry->gLimChannelSwitch.state =
2009 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2010
2011 if (chan_space == 80) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002012 chnl_switch_info->newChanWidth =
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002013 CH_WIDTH_80MHZ;
2014 } else if (chan_space == 40) {
2015 chnl_switch_info->newChanWidth =
2016 CH_WIDTH_40MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002017 } else {
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002018 chnl_switch_info->newChanWidth =
2019 CH_WIDTH_20MHZ;
2020 lim_ch_switch->state =
2021 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2022 }
2023
2024 ch_params.ch_width =
2025 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002026 wlan_reg_set_channel_params(mac_ctx->pdev,
2027 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002028 chnl_switch_info->newCenterChanFreq0 =
2029 ch_params.center_freq_seg0;
2030 /*
2031 * This is not applicable for 20/40/80 MHz.
2032 * Only used when we support 80+80 MHz operation.
2033 * In case of 80+80 MHz, this parameter indicates
2034 * center channel frequency index of 80 MHz
2035 * channel offrequency segment 1.
2036 */
2037 chnl_switch_info->newCenterChanFreq1 =
2038 ch_params.center_freq_seg1;
2039 lim_ch_switch->sec_ch_offset =
2040 ch_params.sec_ch_offset;
2041
Kiran Kumar Lokere47127482017-12-20 18:09:55 -08002042 } else {
2043 lim_ch_switch->state =
2044 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2045 ch_params.ch_width = CH_WIDTH_40MHZ;
2046 wlan_reg_set_channel_params(mac_ctx->pdev,
2047 csa_params->channel, 0, &ch_params);
2048 lim_ch_switch->sec_ch_offset =
2049 ch_params.sec_ch_offset;
2050 chnl_switch_info->newChanWidth = CH_WIDTH_40MHZ;
2051 chnl_switch_info->newCenterChanFreq0 =
2052 ch_params.center_freq_seg0;
2053 chnl_switch_info->newCenterChanFreq1 = 0;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002054 }
2055 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
2056 chnl_switch_info->newCenterChanFreq0;
2057 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
2058 chnl_switch_info->newCenterChanFreq1;
2059 session_entry->gLimChannelSwitch.ch_width =
2060 chnl_switch_info->newChanWidth;
2061
2062 } else if (session_entry->htSupportedChannelWidthSet) {
2063 if (csa_params->ies_present_flag
2064 & lim_xcsa_ie_present) {
2065 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002066 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002067 mac_ctx->scan.countryCodeCurrent,
2068 csa_params->channel,
2069 csa_params->new_op_class);
2070 lim_ch_switch->state =
2071 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2072 if (chan_space == 40) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002073 lim_ch_switch->ch_width =
2074 CH_WIDTH_40MHZ;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002075 chnl_switch_info->newChanWidth =
2076 CH_WIDTH_40MHZ;
2077 ch_params.ch_width =
2078 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002079 wlan_reg_set_channel_params(mac_ctx->pdev,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002080 csa_params->channel,
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07002081 0, &ch_params);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002082 lim_ch_switch->ch_center_freq_seg0 =
2083 ch_params.center_freq_seg0;
2084 lim_ch_switch->sec_ch_offset =
2085 ch_params.sec_ch_offset;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002086 } else {
2087 lim_ch_switch->ch_width =
2088 CH_WIDTH_20MHZ;
2089 chnl_switch_info->newChanWidth =
2090 CH_WIDTH_40MHZ;
2091 lim_ch_switch->state =
2092 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2093 lim_ch_switch->sec_ch_offset =
2094 PHY_SINGLE_CHANNEL_CENTERED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002095 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002096 } else {
2097 lim_ch_switch->ch_width =
2098 CH_WIDTH_40MHZ;
2099 lim_ch_switch->state =
2100 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2101 ch_params.ch_width = CH_WIDTH_40MHZ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002102 wlan_reg_set_channel_params(mac_ctx->pdev,
2103 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002104 lim_ch_switch->ch_center_freq_seg0 =
2105 ch_params.center_freq_seg0;
2106 lim_ch_switch->sec_ch_offset =
2107 ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002108 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002109
2110 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302111 pe_debug("new ch width: %d space: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302112 session_entry->gLimChannelSwitch.ch_width, chan_space);
Kiran Kumar Lokere75d636f2016-12-20 14:52:03 -08002113 if ((session_entry->currentOperChannel == csa_params->channel) &&
2114 (session_entry->ch_width ==
2115 session_entry->gLimChannelSwitch.ch_width)) {
2116 pe_debug("Ignore CSA, no change in ch and bw");
Pragaspathi Thilagaraj655db192018-06-19 17:41:37 +05302117 qdf_mem_free(csa_offload_ind);
Kiran Kumar Lokere75d636f2016-12-20 14:52:03 -08002118 goto err;
2119 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002120
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05302121 if (WLAN_REG_IS_24GHZ_CH(csa_params->channel) &&
2122 (session_entry->dot11mode == WNI_CFG_DOT11_MODE_11A))
2123 session_entry->dot11mode = WNI_CFG_DOT11_MODE_11G;
2124 else if (WLAN_REG_IS_5GHZ_CH(csa_params->channel) &&
2125 ((session_entry->dot11mode == WNI_CFG_DOT11_MODE_11G) ||
2126 (session_entry->dot11mode == WNI_CFG_DOT11_MODE_11G_ONLY)))
2127 session_entry->dot11mode = WNI_CFG_DOT11_MODE_11A;
2128
Vignesh Viswanathan3d478032018-08-02 20:18:53 +05302129 /* Send RSO Stop to FW before triggering the vdev restart for CSA */
2130 if (mac_ctx->lim.stop_roaming_callback)
2131 mac_ctx->lim.stop_roaming_callback(mac_ctx,
2132 session_entry->smeSessionId,
2133 ecsr_driver_disabled);
2134
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002135 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002136
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002137 csa_offload_ind->mesgType = eWNI_SME_CSA_OFFLOAD_EVENT;
2138 csa_offload_ind->mesgLen = sizeof(tSmeCsaOffloadInd);
2139 qdf_mem_copy(csa_offload_ind->bssid.bytes, session_entry->bssId,
2140 QDF_MAC_ADDR_SIZE);
2141 mmh_msg.type = eWNI_SME_CSA_OFFLOAD_EVENT;
2142 mmh_msg.bodyptr = csa_offload_ind;
2143 mmh_msg.bodyval = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302144 pe_debug("Sending eWNI_SME_CSA_OFFLOAD_EVENT to SME");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002145 MTRACE(mac_trace_msg_tx
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002146 (mac_ctx, session_entry->peSessionId, mmh_msg.type));
2147#ifdef FEATURE_WLAN_DIAG_SUPPORT
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002148 lim_diag_event_report(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002149 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002150 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002151#endif
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002152 lim_sys_process_mmh_msg_api(mac_ctx, &mmh_msg, ePROT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002153
2154err:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302155 qdf_mem_free(csa_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002156}
2157
2158/*--------------------------------------------------------------------------
2159 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
2160
2161 \param pMac - pointer to global adapter context
2162 \param sessionId - Message pointer.
2163
2164 \sa
2165 --------------------------------------------------------------------------*/
2166
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002167void lim_handle_delete_bss_rsp(tpAniSirGlobal pMac, struct scheduler_msg *MsgQ)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002168{
2169 tpPESession psessionEntry;
2170 tpDeleteBssParams pDelBss = (tpDeleteBssParams) (MsgQ->bodyptr);
2171
2172 psessionEntry =
2173 pe_find_session_by_session_id(pMac, pDelBss->sessionId);
2174 if (psessionEntry == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302175 pe_err("Session Does not exist for given sessionID: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002176 pDelBss->sessionId);
Tushnim Bhattacharyya6368a262018-10-12 09:48:45 -07002177 qdf_mem_free(MsgQ->bodyptr);
2178 MsgQ->bodyptr = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002179 return;
2180 }
Krunal Sonie50ff452017-10-11 18:23:55 -07002181
2182 /*
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002183 * During DEL BSS handling, the PE Session will be deleted, but it is
2184 * better to clear this flag if the session is hanging around due
2185 * to some error conditions so that the next DEL_BSS request does
2186 * not take the HO_FAIL path
2187 */
2188 psessionEntry->process_ho_fail = false;
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002189 if (LIM_IS_IBSS_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002190 lim_ibss_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002191 else if (LIM_IS_UNKNOWN_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002192 lim_process_sme_del_bss_rsp(pMac, MsgQ->bodyval, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002193 else if (LIM_IS_NDI_ROLE(psessionEntry))
2194 lim_ndi_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002195 else
2196 lim_process_mlm_del_bss_rsp(pMac, MsgQ, psessionEntry);
2197
2198}
2199
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002200/** -----------------------------------------------------------------
2201 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
2202 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
2203 \ SME only looks at rc and tspec field.
2204 \param pMac - global mac structure
2205 \param rspReqd - is SmeAddTsRsp required
2206 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
2207 \return tspec
2208 \sa
2209 ----------------------------------------------------------------- */
2210void
2211lim_send_sme_aggr_qos_rsp(tpAniSirGlobal pMac, tpSirAggrQosRsp aggrQosRsp,
2212 uint8_t smesessionId)
2213{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002214 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002215
2216 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
2217 mmhMsg.bodyptr = aggrQosRsp;
2218 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302219 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2220 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002221 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2222
2223 return;
2224}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002225
2226void lim_send_sme_max_assoc_exceeded_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
2227 uint8_t smesessionId)
2228{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002229 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002230 tSmeMaxAssocInd *pSmeMaxAssocInd;
2231
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302232 pSmeMaxAssocInd = qdf_mem_malloc(sizeof(tSmeMaxAssocInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002233 if (!pSmeMaxAssocInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002234 return;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302235 qdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peer_mac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302236 (uint8_t *) peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002237 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
2238 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
2239 pSmeMaxAssocInd->sessionId = smesessionId;
2240 mmhMsg.type = pSmeMaxAssocInd->mesgType;
2241 mmhMsg.bodyptr = pSmeMaxAssocInd;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302242 pe_debug("msgType: %s peerMacAddr "MAC_ADDRESS_STR "sme session id %d",
2243 "eWNI_SME_MAX_ASSOC_EXCEEDED", MAC_ADDR_ARRAY(peerMacAddr),
2244 pSmeMaxAssocInd->sessionId);
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302245 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2246 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002247 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2248
2249 return;
2250}
2251
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002252/** -----------------------------------------------------------------
2253 \brief lim_send_sme_ap_channel_switch_resp() - sends
2254 eWNI_SME_CHANNEL_CHANGE_RSP
2255 After receiving WMA_SWITCH_CHANNEL_RSP indication this
2256 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
2257 that the Channel change has been done to the specified target
2258 channel in the Channel change request
2259 \param pMac - global mac structure
2260 \param psessionEntry - session info
2261 \param pChnlParams - Channel switch params
2262 --------------------------------------------------------------------*/
2263void
2264lim_send_sme_ap_channel_switch_resp(tpAniSirGlobal pMac,
2265 tpPESession psessionEntry,
2266 tpSwitchChannelParams pChnlParams)
2267{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002268 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002269 tpSwitchChannelParams pSmeSwithChnlParams;
2270 uint8_t channelId;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002271 bool is_ch_dfs = false;
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08002272 enum phy_ch_width ch_width;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002273 uint8_t ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002274
Arif Hussainf5b6c412018-10-10 19:41:09 -07002275 pSmeSwithChnlParams = qdf_mem_malloc(sizeof(tSwitchChannelParams));
2276 if (!pSmeSwithChnlParams)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002277 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002278
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302279 qdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002280 sizeof(tSwitchChannelParams));
2281
2282 channelId = pSmeSwithChnlParams->channelNumber;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002283 ch_width = pSmeSwithChnlParams->ch_width;
2284 ch_center_freq_seg1 = pSmeSwithChnlParams->ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002285
2286 /*
2287 * Pass the sme sessionID to SME instead
2288 * PE session ID.
2289 */
2290 pSmeSwithChnlParams->peSessionId = psessionEntry->smeSessionId;
2291
2292 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
2293 mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
2294 mmhMsg.bodyval = 0;
2295 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2296
2297 /*
2298 * We should start beacon transmission only if the new
2299 * channel after channel change is Non-DFS. For a DFS
2300 * channel, PE will receive an explicit request from
2301 * upper layers to start the beacon transmission .
2302 */
2303
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002304 if (ch_width == CH_WIDTH_160MHZ) {
2305 is_ch_dfs = true;
2306 } else if (ch_width == CH_WIDTH_80P80MHZ) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002307 if (wlan_reg_get_channel_state(pMac->pdev, channelId) ==
2308 CHANNEL_STATE_DFS ||
2309 wlan_reg_get_channel_state(pMac->pdev,
2310 ch_center_freq_seg1 -
2311 SIR_80MHZ_START_CENTER_CH_DIFF) ==
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002312 CHANNEL_STATE_DFS)
2313 is_ch_dfs = true;
2314 } else {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002315 if (wlan_reg_get_channel_state(pMac->pdev, channelId) ==
2316 CHANNEL_STATE_DFS)
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002317 is_ch_dfs = true;
2318 }
2319
2320 if (!is_ch_dfs) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002321 if (channelId == psessionEntry->currentOperChannel) {
2322 lim_apply_configuration(pMac, psessionEntry);
Abhishek Singh20a8e442018-09-12 15:50:44 +05302323 lim_send_beacon(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002324 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302325 pe_debug("Failed to Transmit Beacons on channel: %d after AP channel change response",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002326 psessionEntry->bcnLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002327 }
Arif Hussain1513cb22018-01-05 19:56:31 -08002328
2329 lim_obss_send_detection_cfg(pMac, psessionEntry, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002330 }
2331 return;
2332}
2333
Peng Xu6363ec62017-05-15 11:06:33 -07002334#ifdef WLAN_FEATURE_11AX_BSS_COLOR
2335/**
2336 * lim_send_bss_color_change_ie_update() - update bss color change IE in
2337 * beacon template
2338 *
2339 * @mac_ctx: pointer to global adapter context
2340 * @session: session pointer
2341 *
2342 * Return: none
2343 */
2344static void
2345lim_send_bss_color_change_ie_update(tpAniSirGlobal mac_ctx,
2346 tpPESession session)
2347{
2348 /* Update the beacon template and send to FW */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002349 if (sch_set_fixed_beacon_fields(mac_ctx, session) != QDF_STATUS_SUCCESS) {
Peng Xu6363ec62017-05-15 11:06:33 -07002350 pe_err("Unable to set BSS color change IE in beacon");
Srinivas Girigowdaeff16d92018-09-12 14:56:29 -07002351 return;
Peng Xu6363ec62017-05-15 11:06:33 -07002352 }
2353
2354 /* Send update beacon template message */
Abhishek Singhfc740be2018-10-12 11:34:26 +05302355 lim_send_beacon_ind(mac_ctx, session, REASON_COLOR_CHANGE);
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07002356 pe_debug("Updated BSS color change countdown = %d",
2357 session->he_bss_color_change.countdown);
Peng Xu6363ec62017-05-15 11:06:33 -07002358}
2359
2360static void
2361lim_handle_bss_color_change_ie(tpAniSirGlobal mac_ctx,
2362 tpPESession session)
2363{
Arif Hussain2f2d3512018-03-06 12:37:03 -08002364 tUpdateBeaconParams beacon_params;
2365
Peng Xu6363ec62017-05-15 11:06:33 -07002366 /* handle bss color change IE */
2367 if (LIM_IS_AP_ROLE(session) &&
2368 session->he_op.bss_col_disabled) {
2369 if (session->he_bss_color_change.countdown > 0) {
2370 session->he_bss_color_change.countdown--;
2371 } else {
2372 session->bss_color_changing = 0;
Arif Hussain2f2d3512018-03-06 12:37:03 -08002373 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
Arif Hussain05fb4872018-01-03 16:02:55 -08002374 if (session->he_bss_color_change.new_color != 0) {
Peng Xu6363ec62017-05-15 11:06:33 -07002375 session->he_op.bss_col_disabled = 0;
Arif Hussain05fb4872018-01-03 16:02:55 -08002376 session->he_op.bss_color =
2377 session->he_bss_color_change.new_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08002378 beacon_params.paramChangeBitmap |=
2379 PARAM_BSS_COLOR_CHANGED;
2380 beacon_params.bss_color_disabled = 0;
2381 beacon_params.bss_color =
2382 session->he_op.bss_color;
2383 lim_send_beacon_params(mac_ctx,
2384 &beacon_params,
2385 session);
Arif Hussain05fb4872018-01-03 16:02:55 -08002386 lim_send_obss_color_collision_cfg(mac_ctx,
2387 session,
2388 OBSS_COLOR_COLLISION_DETECTION);
2389 }
Peng Xu6363ec62017-05-15 11:06:33 -07002390 }
2391
2392 lim_send_bss_color_change_ie_update(mac_ctx, session);
2393 }
2394}
2395
2396#else
2397static void
2398lim_handle_bss_color_change_ie(tpAniSirGlobal mac_ctx,
2399 tpPESession session)
2400{
2401}
2402#endif
2403
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002404void
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302405lim_process_beacon_tx_success_ind(tpAniSirGlobal mac_ctx, uint16_t msgType,
2406 void *event)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002407{
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302408 tpPESession session;
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302409 tpSirFirstBeaconTxCompleteInd bcn_ind =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002410 (tSirFirstBeaconTxCompleteInd *) event;
2411
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302412 session = pe_find_session_by_bss_idx(mac_ctx, bcn_ind->bssIdx);
2413 if (!session) {
2414 pe_err("Session Does not exist for given session id");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002415 return;
2416 }
2417
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302418 pe_debug("role: %d swIe: %d opIe: %d switch cnt:%d",
2419 GET_LIM_SYSTEM_ROLE(session),
2420 session->dfsIncludeChanSwIe,
2421 session->gLimOperatingMode.present,
2422 session->gLimChannelSwitch.switchCount);
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302423
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302424 if (!LIM_IS_AP_ROLE(session))
2425 return;
Ganesh Kondabattini02ec62b2018-01-24 18:22:24 +05302426
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302427 if (session->dfsIncludeChanSwIe &&
2428 (session->gLimChannelSwitch.switchCount ==
2429 mac_ctx->sap.SapDfsInfo.sap_ch_switch_beacon_cnt))
2430 lim_process_ap_ecsa_timeout(session);
Ganesh Kondabattini02ec62b2018-01-24 18:22:24 +05302431
lifeng1c16b6b2017-09-25 13:59:55 +08002432
Abhishek Singhfc740be2018-10-12 11:34:26 +05302433 if (session->gLimOperatingMode.present)
2434 /* Done with nss update */
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302435 session->gLimOperatingMode.present = 0;
Peng Xu6363ec62017-05-15 11:06:33 -07002436
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302437 lim_handle_bss_color_change_ie(mac_ctx, session);
Peng Xu6363ec62017-05-15 11:06:33 -07002438
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002439 return;
2440}