blob: f2daddfa4eff6b0b9da0d80beab4f560961387a6 [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));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080091 if (NULL == sme_rsp) {
92 /* Buffer not available. Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +053093 pe_err("call to AllocateMemory failed for eWNI_SME_*_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080094 return;
95 }
96
97 sme_rsp->messageType = msg_type;
98 sme_rsp->length = sizeof(tSirSmeRsp);
99 sme_rsp->statusCode = result_code;
100
101 sme_rsp->sessionId = sme_session_id;
102 sme_rsp->transactionId = sme_transaction_id;
103
104 msg.type = msg_type;
105 msg.bodyptr = sme_rsp;
106 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530107 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG,
108 sme_session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800109
110#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
111 switch (msg_type) {
112 case eWNI_SME_STOP_BSS_RSP:
113 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_STOP_BSS_RSP_EVENT,
114 NULL, (uint16_t) result_code, 0);
115 break;
116 }
117#endif /* FEATURE_WLAN_DIAG_SUPPORT */
118 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
119}
120
121
122
123/**
124 * lim_send_sme_roc_rsp() - Send Response to SME
125 * @mac_ctx: Pointer to Global MAC structure
126 * @status: Resume link status
127 * @result_code: Result of the ROC request
128 * @sme_session_id: SME sesson Id
129 * @scan_id: Scan Identifier
130 *
131 * This function is called to send ROC rsp
132 * message to SME.
133 *
134 * Return: None
135 */
136void
137lim_send_sme_roc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
138 tSirResultCodes result_code, uint8_t sme_session_id,
139 uint32_t scan_id)
140{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700141 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800142 struct sir_roc_rsp *sme_rsp;
143
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530144 pe_debug("Sending message: %s with reasonCode: %s scanId: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800145 lim_msg_str(msg_type), lim_result_code_str(result_code),
146 scan_id);
147
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530148 sme_rsp = qdf_mem_malloc(sizeof(struct sir_roc_rsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800149 if (NULL == sme_rsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530150 pe_err("call to AllocateMemory failed for eWNI_SME_*_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800151 return;
152 }
153
154 sme_rsp->message_type = msg_type;
155 sme_rsp->length = sizeof(struct sir_roc_rsp);
156 sme_rsp->status = result_code;
157
158 sme_rsp->session_id = sme_session_id;
159 sme_rsp->scan_id = scan_id;
160
161 msg.type = msg_type;
162 msg.bodyptr = sme_rsp;
163 msg.bodyval = 0;
164 MTRACE(mac_trace_msg_tx(mac_ctx, sme_session_id, msg.type));
165 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
166}
167
168
169/**
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530170 * lim_get_max_rate_flags() - Get rate flags
171 * @mac_ctx: Pointer to global MAC structure
172 * @sta_ds: Pointer to station ds structure
173 *
174 * This function is called to get the rate flags for a connection
175 * from the station ds structure depending on the ht and the vht
176 * channel width supported.
177 *
178 * Return: Returns the populated rate_flags
179 */
180uint32_t lim_get_max_rate_flags(tpAniSirGlobal mac_ctx, tpDphHashNode sta_ds)
181{
182 uint32_t rate_flags = 0;
183
184 if (sta_ds == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530185 pe_err("sta_ds is NULL");
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530186 return rate_flags;
187 }
188
189 if (!sta_ds->mlmStaContext.htCapability &&
190 !sta_ds->mlmStaContext.vhtCapability) {
Naveen Rawatea1564b2018-05-17 15:56:11 -0700191 rate_flags |= TX_RATE_LEGACY;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530192 } else {
193 if (sta_ds->mlmStaContext.vhtCapability) {
194 if (WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ ==
195 sta_ds->vhtSupportedChannelWidthSet) {
Naveen Rawatea1564b2018-05-17 15:56:11 -0700196 rate_flags |= TX_RATE_VHT80;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530197 } else if (WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ ==
198 sta_ds->vhtSupportedChannelWidthSet) {
199 if (sta_ds->htSupportedChannelWidthSet)
Naveen Rawatea1564b2018-05-17 15:56:11 -0700200 rate_flags |= TX_RATE_VHT40;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530201 else
Naveen Rawatea1564b2018-05-17 15:56:11 -0700202 rate_flags |= TX_RATE_VHT20;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530203 }
204 } else if (sta_ds->mlmStaContext.htCapability) {
205 if (sta_ds->htSupportedChannelWidthSet)
Naveen Rawatea1564b2018-05-17 15:56:11 -0700206 rate_flags |= TX_RATE_HT40;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530207 else
Naveen Rawatea1564b2018-05-17 15:56:11 -0700208 rate_flags |= TX_RATE_HT20;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530209 }
210 }
211
212 if (sta_ds->htShortGI20Mhz || sta_ds->htShortGI40Mhz)
Naveen Rawatea1564b2018-05-17 15:56:11 -0700213 rate_flags |= TX_RATE_SGI;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530214
215 return rate_flags;
216}
217
218/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800219 * lim_send_sme_join_reassoc_rsp_after_resume() - Send Response to SME
220 * @mac_ctx Pointer to Global MAC structure
221 * @status Resume link status
222 * @ctx context passed while calling resmune link.
223 * (join response to be sent)
224 *
225 * This function is called to send Join/Reassoc rsp
226 * message to SME after the resume link.
227 *
228 * Return: None
229 */
230static void lim_send_sme_join_reassoc_rsp_after_resume(tpAniSirGlobal mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530231 QDF_STATUS status, uint32_t *ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800232{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700233 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800234 tpSirSmeJoinRsp sme_join_rsp = (tpSirSmeJoinRsp) ctx;
235
236 msg.type = sme_join_rsp->messageType;
237 msg.bodyptr = sme_join_rsp;
238 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530239 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, NO_SESSION, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800240 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
241}
242
243/**
244 * lim_handle_join_rsp_status() - Handle the response.
245 * @mac_ctx: Pointer to Global MAC structure
246 * @session_entry: PE Session Info
247 * @result_code: Indicates the result of previously issued
248 * eWNI_SME_msgType_REQ message
249 * @sme_join_rsp The received response.
250 *
251 * This function will handle both the success and failure status
252 * of the received response.
253 *
254 * Return: None
255 */
256static void lim_handle_join_rsp_status(tpAniSirGlobal mac_ctx,
257 tpPESession session_entry, tSirResultCodes result_code,
258 tpSirSmeJoinRsp sme_join_rsp)
259{
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700260 uint16_t bss_ie_len;
261 void *bss_ies;
262 bool is_vendor_ap_1_present;
Wu Gao2968fc92017-06-19 19:18:34 +0800263 tpSirSmeJoinReq join_reassoc_req = NULL;
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700264
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800265#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
266 tSirSmeHTProfile *ht_profile;
267#endif
268 if (result_code == eSIR_SME_SUCCESS) {
269 if (session_entry->beacon != NULL) {
270 sme_join_rsp->beaconLength = session_entry->bcnLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530271 qdf_mem_copy(sme_join_rsp->frames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800272 session_entry->beacon,
273 sme_join_rsp->beaconLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530274 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800275 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530276 session_entry->bcnLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530277 pe_debug("Beacon: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530278 sme_join_rsp->beaconLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800279 }
280 if (session_entry->assocReq != NULL) {
281 sme_join_rsp->assocReqLength =
282 session_entry->assocReqLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530283 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530284 sme_join_rsp->beaconLength,
285 session_entry->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800286 sme_join_rsp->assocReqLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530287 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800288 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530289 session_entry->assocReqLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530290 pe_debug("AssocReq: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530291 sme_join_rsp->assocReqLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800292 }
293 if (session_entry->assocRsp != NULL) {
294 sme_join_rsp->assocRspLength =
295 session_entry->assocRspLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530296 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530297 sme_join_rsp->beaconLength +
298 sme_join_rsp->assocReqLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800299 session_entry->assocRsp,
300 sme_join_rsp->assocRspLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530301 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800302 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530303 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800304 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800305 if (session_entry->ricData != NULL) {
306 sme_join_rsp->parsedRicRspLen =
307 session_entry->RICDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530308 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530309 sme_join_rsp->beaconLength +
310 sme_join_rsp->assocReqLength +
311 sme_join_rsp->assocRspLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800312 session_entry->ricData,
313 sme_join_rsp->parsedRicRspLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530314 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800315 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530316 session_entry->RICDataLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530317 pe_debug("RicLength: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800318 sme_join_rsp->parsedRicRspLen);
319 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800320#ifdef FEATURE_WLAN_ESE
321 if (session_entry->tspecIes != NULL) {
322 sme_join_rsp->tspecIeLen =
323 session_entry->tspecLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530324 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530325 sme_join_rsp->beaconLength +
326 sme_join_rsp->assocReqLength +
327 sme_join_rsp->assocRspLength +
328 sme_join_rsp->parsedRicRspLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800329 session_entry->tspecIes,
330 sme_join_rsp->tspecIeLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530331 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800332 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530333 session_entry->tspecLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530334 pe_debug("ESE-TspecLen: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530335 sme_join_rsp->tspecIeLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800336 }
337#endif
338 sme_join_rsp->aid = session_entry->limAID;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530339 pe_debug("AssocRsp: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530340 sme_join_rsp->assocRspLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800341 sme_join_rsp->vht_channel_width =
342 session_entry->ch_width;
343#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
344 if (session_entry->cc_switch_mode !=
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530345 QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800346 ht_profile = &sme_join_rsp->HTProfile;
347 ht_profile->htSupportedChannelWidthSet =
348 session_entry->htSupportedChannelWidthSet;
349 ht_profile->htRecommendedTxWidthSet =
350 session_entry->htRecommendedTxWidthSet;
351 ht_profile->htSecondaryChannelOffset =
352 session_entry->htSecondaryChannelOffset;
353 ht_profile->dot11mode = session_entry->dot11mode;
354 ht_profile->htCapability = session_entry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800355 ht_profile->vhtCapability =
356 session_entry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800357 ht_profile->apCenterChan = session_entry->ch_center_freq_seg0;
358 ht_profile->apChanWidth = session_entry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800359 }
360#endif
Jeff Johnson11bd4f32017-09-18 08:15:17 -0700361 pe_debug("pLimJoinReq:%pK, pLimReAssocReq:%pK",
Wu Gao2968fc92017-06-19 19:18:34 +0800362 session_entry->pLimJoinReq,
363 session_entry->pLimReAssocReq);
364
365 if (session_entry->pLimJoinReq)
366 join_reassoc_req = session_entry->pLimJoinReq;
367
368 if (session_entry->pLimReAssocReq)
369 join_reassoc_req = session_entry->pLimReAssocReq;
370
371 if (!join_reassoc_req) {
372 pe_err("both pLimJoinReq and pLimReAssocReq NULL");
373 return;
374 }
375
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700376 bss_ie_len = lim_get_ielen_from_bss_description(
Wu Gao2968fc92017-06-19 19:18:34 +0800377 &join_reassoc_req->bssDescription);
378 bss_ies = &join_reassoc_req->bssDescription.ieFields;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700379 is_vendor_ap_1_present = (wlan_get_vendor_ie_ptr_from_oui(
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700380 SIR_MAC_VENDOR_AP_1_OUI, SIR_MAC_VENDOR_AP_1_OUI_LEN,
381 bss_ies, bss_ie_len) != NULL);
382
383 if (mac_ctx->roam.configParam.is_force_1x1 &&
Krunal Sonie6a1cda2017-09-27 15:23:02 -0700384 is_vendor_ap_1_present && (session_entry->nss == 2) &&
385 (mac_ctx->lteCoexAntShare == 0 ||
386 IS_5G_CH(session_entry->currentOperChannel))) {
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700387 /* SET vdev param */
388 pe_debug("sending SMPS intolrent vdev_param");
389 wma_cli_set_command(session_entry->smeSessionId,
390 (int)WMI_VDEV_PARAM_SMPS_INTOLERANT,
391 1, VDEV_CMD);
392
393 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800394 } else {
395 if (session_entry->beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530396 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800397 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530398 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800399 }
400 if (session_entry->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530401 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800402 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530403 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800404 }
405 if (session_entry->assocRsp != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530406 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800407 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530408 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800409 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800410 if (session_entry->ricData != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530411 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800412 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530413 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800414 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800415#ifdef FEATURE_WLAN_ESE
416 if (session_entry->tspecIes != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530417 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800418 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530419 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800420 }
421#endif
422 }
423}
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530424
425/**
426 * lim_add_bss_info() - copy data from session entry to join rsp
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530427 * @sta_ds: Station dph entry
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530428 * @sme_join_rsp: Join response buffer to be filled up
429 *
430 * Return: None
431 */
Jeff Johnson6db011e2016-10-07 07:31:39 -0700432static void lim_add_bss_info(tpDphHashNode sta_ds, tpSirSmeJoinRsp sme_join_rsp)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530433{
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530434 struct parsed_ies *parsed_ies = &sta_ds->parsed_ies;
435
436 if (parsed_ies->hs20vendor_ie.present)
437 sme_join_rsp->hs20vendor_ie = parsed_ies->hs20vendor_ie;
438 if (parsed_ies->vht_caps.present)
439 sme_join_rsp->vht_caps = parsed_ies->vht_caps;
440 if (parsed_ies->ht_caps.present)
441 sme_join_rsp->ht_caps = parsed_ies->ht_caps;
442 if (parsed_ies->ht_operation.present)
443 sme_join_rsp->ht_operation = parsed_ies->ht_operation;
444 if (parsed_ies->vht_operation.present)
445 sme_join_rsp->vht_operation = parsed_ies->vht_operation;
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530446}
447
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530448#ifdef WLAN_FEATURE_FILS_SK
449static void lim_update_fils_seq_num(tpSirSmeJoinRsp sme_join_rsp,
450 tpPESession session_entry)
451{
452 sme_join_rsp->fils_seq_num =
453 session_entry->fils_info->sequence_number;
454}
455#else
456static inline void lim_update_fils_seq_num(tpSirSmeJoinRsp sme_join_rsp,
457 tpPESession session_entry)
458{}
459#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800460/**
461 * lim_send_sme_join_reassoc_rsp() - Send Response to Upper Layers
462 * @mac_ctx: Pointer to Global MAC structure
463 * @msg_type: Indicates message type
464 * @result_code: Indicates the result of previously issued
465 * eWNI_SME_msgType_REQ message
466 * @prot_status_code: Protocol Status Code
467 * @session_entry: PE Session Info
468 * @sme_session_id: SME Session ID
469 * @sme_transaction_id: SME Transaction ID
470 *
471 * This function is called by lim_process_sme_req_messages() to send
472 * eWNI_SME_JOIN_RSP or eWNI_SME_REASSOC_RSP messages to applications
473 * above MAC Software.
474 *
475 * Return: None
476 */
477
478void
479lim_send_sme_join_reassoc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
480 tSirResultCodes result_code, uint16_t prot_status_code,
481 tpPESession session_entry, uint8_t sme_session_id,
482 uint16_t sme_transaction_id)
483{
484 tpSirSmeJoinRsp sme_join_rsp;
485 uint32_t rsp_len;
486 tpDphHashNode sta_ds = NULL;
487#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
488 if (msg_type == eWNI_SME_REASSOC_RSP)
489 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_RSP_EVENT,
490 session_entry, (uint16_t) result_code, 0);
491 else
492 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_RSP_EVENT,
493 session_entry, (uint16_t) result_code, 0);
494#endif /* FEATURE_WLAN_DIAG_SUPPORT */
495
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530496 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800497 lim_msg_str(msg_type), lim_result_code_str(result_code));
498
499 if (session_entry == NULL) {
500 rsp_len = sizeof(tSirSmeJoinRsp);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530501 sme_join_rsp = qdf_mem_malloc(rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800502 if (NULL == sme_join_rsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530503 pe_err("Mem Alloc fail - JOIN/REASSOC_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800504 return;
505 }
506
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800507 sme_join_rsp->beaconLength = 0;
508 sme_join_rsp->assocReqLength = 0;
509 sme_join_rsp->assocRspLength = 0;
510 } else {
511 rsp_len = session_entry->assocReqLen +
512 session_entry->assocRspLen + session_entry->bcnLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800513 session_entry->RICDataLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800514#ifdef FEATURE_WLAN_ESE
515 session_entry->tspecLen +
516#endif
517 sizeof(tSirSmeJoinRsp) - sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530518 sme_join_rsp = qdf_mem_malloc(rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800519 if (NULL == sme_join_rsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530520 pe_err("MemAlloc fail - JOIN/REASSOC_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800521 return;
522 }
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530523
524 if (lim_is_fils_connection(session_entry)) {
525 sme_join_rsp->is_fils_connection = true;
526 lim_update_fils_seq_num(sme_join_rsp,
527 session_entry);
528 }
529
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800530 if (result_code == eSIR_SME_SUCCESS) {
531 sta_ds = dph_get_hash_entry(mac_ctx,
532 DPH_STA_HASH_INDEX_PEER,
533 &session_entry->dph.dphHashTable);
534 if (sta_ds == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530535 pe_err("Get Self Sta Entry fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800536 } else {
537 /* Pass the peer's staId */
538 sme_join_rsp->staId = sta_ds->staIndex;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800539 sme_join_rsp->timingMeasCap =
540 sta_ds->timingMeasCap;
541#ifdef FEATURE_WLAN_TDLS
542 sme_join_rsp->tdls_prohibited =
543 session_entry->tdls_prohibited;
544 sme_join_rsp->tdls_chan_swit_prohibited =
545 session_entry->tdls_chan_swit_prohibited;
546#endif
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530547 sme_join_rsp->nss = sta_ds->nss;
548 sme_join_rsp->max_rate_flags =
549 lim_get_max_rate_flags(mac_ctx, sta_ds);
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530550 lim_add_bss_info(sta_ds, sme_join_rsp);
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530551
552 /* Copy FILS params only for Successful join */
553 populate_fils_connect_params(mac_ctx,
554 session_entry, sme_join_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800555 }
556 }
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530557
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800558 sme_join_rsp->beaconLength = 0;
559 sme_join_rsp->assocReqLength = 0;
560 sme_join_rsp->assocRspLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800561 sme_join_rsp->parsedRicRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800562#ifdef FEATURE_WLAN_ESE
563 sme_join_rsp->tspecIeLen = 0;
564#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800565 lim_handle_join_rsp_status(mac_ctx, session_entry, result_code,
566 sme_join_rsp);
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800567
568 /* Send supported NSS 1x1 to SME */
569 sme_join_rsp->supported_nss_1x1 =
570 session_entry->supported_nss_1x1;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530571 pe_debug("SME Join Rsp is supported NSS 1X1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800572 sme_join_rsp->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800573 }
574
575 sme_join_rsp->messageType = msg_type;
576 sme_join_rsp->length = (uint16_t) rsp_len;
577 sme_join_rsp->statusCode = result_code;
578 sme_join_rsp->protStatusCode = prot_status_code;
579
580 sme_join_rsp->sessionId = sme_session_id;
581 sme_join_rsp->transactionId = sme_transaction_id;
582
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530583 lim_send_sme_join_reassoc_rsp_after_resume(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800584 (uint32_t *)sme_join_rsp);
585}
586
587/**
588 * lim_send_sme_start_bss_rsp()
589 *
590 ***FUNCTION:
591 * This function is called to send eWNI_SME_START_BSS_RSP
592 * message to applications above MAC Software.
593 *
594 ***PARAMS:
595 *
596 ***LOGIC:
597 *
598 ***ASSUMPTIONS:
599 * NA
600 *
601 ***NOTE:
602 * NA
603 *
604 * @param pMac Pointer to Global MAC structure
605 * @param msgType Indicates message type
606 * @param resultCode Indicates the result of previously issued
607 * eWNI_SME_msgType_REQ message
608 *
609 * @return None
610 */
611
612void
613lim_send_sme_start_bss_rsp(tpAniSirGlobal pMac,
614 uint16_t msgType, tSirResultCodes resultCode,
615 tpPESession psessionEntry, uint8_t smesessionId,
616 uint16_t smetransactionId)
617{
618
619 uint16_t size = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700620 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800621 tSirSmeStartBssRsp *pSirSmeRsp;
622 uint16_t ieLen;
623 uint16_t ieOffset, curLen;
624
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530625 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800626 lim_msg_str(msgType), lim_result_code_str(resultCode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800627
628 size = sizeof(tSirSmeStartBssRsp);
629
630 if (psessionEntry == NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530631 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800632 if (NULL == pSirSmeRsp) {
633 /* / Buffer not available. Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530634 pe_err("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800635 return;
636 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800637 } else {
638 /* subtract size of beaconLength + Mac Hdr + Fixed Fields before SSID */
639 ieOffset = sizeof(tAniBeaconStruct) + SIR_MAC_B_PR_SSID_OFFSET;
640 ieLen = psessionEntry->schBeaconOffsetBegin
641 + psessionEntry->schBeaconOffsetEnd - ieOffset;
642 /* calculate the memory size to allocate */
643 size += ieLen;
644
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530645 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800646 if (NULL == pSirSmeRsp) {
647 /* / Buffer not available. Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530648 pe_err("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800649 return;
650 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800651 size = sizeof(tSirSmeStartBssRsp);
652 if (resultCode == eSIR_SME_SUCCESS) {
653
654 sir_copy_mac_addr(pSirSmeRsp->bssDescription.bssId,
655 psessionEntry->bssId);
656
657 /* Read beacon interval from session */
658 pSirSmeRsp->bssDescription.beaconInterval =
659 (uint16_t) psessionEntry->beaconParams.
660 beaconInterval;
661 pSirSmeRsp->bssType = psessionEntry->bssType;
662
663 if (cfg_get_capability_info
664 (pMac, &pSirSmeRsp->bssDescription.capabilityInfo,
665 psessionEntry)
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700666 != QDF_STATUS_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530667 pe_err("could not retrieve Capabilities value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800668
669 lim_get_phy_mode(pMac,
670 (uint32_t *) &pSirSmeRsp->bssDescription.
671 nwType, psessionEntry);
672
673 pSirSmeRsp->bssDescription.channelId =
674 psessionEntry->currentOperChannel;
675
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700676 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800677 curLen = psessionEntry->schBeaconOffsetBegin - ieOffset;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530678 qdf_mem_copy((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800679 ieFields,
680 psessionEntry->pSchBeaconFrameBegin +
681 ieOffset, (uint32_t) curLen);
682
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530683 qdf_mem_copy(((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800684 ieFields) + curLen,
685 psessionEntry->pSchBeaconFrameEnd,
686 (uint32_t) psessionEntry->
687 schBeaconOffsetEnd);
688
Abhishek Singh34a4d862016-10-26 16:01:51 +0530689 pSirSmeRsp->bssDescription.length = (uint16_t)
690 (offsetof(tSirBssDescription, ieFields[0])
691 - sizeof(pSirSmeRsp->bssDescription.length)
692 + ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800693 /* This is the size of the message, subtracting the size of the pointer to ieFields */
694 size += ieLen - sizeof(uint32_t);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700695 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800696#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
697 if (psessionEntry->cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530698 != QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800699 pSirSmeRsp->HTProfile.
700 htSupportedChannelWidthSet =
701 psessionEntry->htSupportedChannelWidthSet;
702 pSirSmeRsp->HTProfile.htRecommendedTxWidthSet =
703 psessionEntry->htRecommendedTxWidthSet;
704 pSirSmeRsp->HTProfile.htSecondaryChannelOffset =
705 psessionEntry->htSecondaryChannelOffset;
706 pSirSmeRsp->HTProfile.dot11mode =
707 psessionEntry->dot11mode;
708 pSirSmeRsp->HTProfile.htCapability =
709 psessionEntry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800710 pSirSmeRsp->HTProfile.vhtCapability =
711 psessionEntry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800712 pSirSmeRsp->HTProfile.apCenterChan =
713 psessionEntry->ch_center_freq_seg0;
714 pSirSmeRsp->HTProfile.apChanWidth =
715 psessionEntry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800716 }
717#endif
718 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800719 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800720 pSirSmeRsp->messageType = msgType;
721 pSirSmeRsp->length = size;
722
723 /* Update SME session Id and transaction Id */
724 pSirSmeRsp->sessionId = smesessionId;
725 pSirSmeRsp->transactionId = smetransactionId;
726 pSirSmeRsp->statusCode = resultCode;
727 if (psessionEntry != NULL)
728 pSirSmeRsp->staId = psessionEntry->staId; /* else it will be always zero smeRsp StaID = 0 */
729
730 mmhMsg.type = msgType;
731 mmhMsg.bodyptr = pSirSmeRsp;
732 mmhMsg.bodyval = 0;
733 if (psessionEntry == NULL) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530734 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
735 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800736 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530737 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
738 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800739 }
740#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
741 lim_diag_event_report(pMac, WLAN_PE_DIAG_START_BSS_RSP_EVENT,
742 psessionEntry, (uint16_t) resultCode, 0);
743#endif /* FEATURE_WLAN_DIAG_SUPPORT */
744
745 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
746} /*** end lim_send_sme_start_bss_rsp() ***/
747
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800748void lim_send_sme_disassoc_deauth_ntf(tpAniSirGlobal pMac,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530749 QDF_STATUS status, uint32_t *pCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800750{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700751 struct scheduler_msg mmhMsg = {0};
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800752 struct scheduler_msg *pMsg = (struct scheduler_msg *) pCtx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800753
754 mmhMsg.type = pMsg->type;
755 mmhMsg.bodyptr = pMsg;
756 mmhMsg.bodyval = 0;
757
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530758 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800759
760 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
761}
762
763/**
764 * lim_send_sme_disassoc_ntf()
765 *
766 ***FUNCTION:
767 * This function is called by limProcessSmeMessages() to send
768 * eWNI_SME_DISASSOC_RSP/IND message to host
769 *
770 ***PARAMS:
771 *
772 ***LOGIC:
773 *
774 ***ASSUMPTIONS:
775 * NA
776 *
777 ***NOTE:
778 * This function is used for sending eWNI_SME_DISASSOC_CNF,
779 * or eWNI_SME_DISASSOC_IND to host depending on
780 * disassociation trigger.
781 *
782 * @param peerMacAddr Indicates the peer MAC addr to which
783 * disassociate was initiated
784 * @param reasonCode Indicates the reason for Disassociation
785 * @param disassocTrigger Indicates the trigger for Disassociation
786 * @param aid Indicates the STAID. This parameter is
787 * present only on AP.
788 *
789 * @return None
790 */
791void
792lim_send_sme_disassoc_ntf(tpAniSirGlobal pMac,
793 tSirMacAddr peerMacAddr,
794 tSirResultCodes reasonCode,
795 uint16_t disassocTrigger,
796 uint16_t aid,
797 uint8_t smesessionId,
798 uint16_t smetransactionId, tpPESession psessionEntry)
799{
800
801 uint8_t *pBuf;
802 tSirSmeDisassocRsp *pSirSmeDisassocRsp;
803 tSirSmeDisassocInd *pSirSmeDisassocInd;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700804 uint32_t *pMsg = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800805 bool failure = false;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700806 tpPESession session = NULL;
807 uint16_t i, assoc_id;
808 tpDphHashNode sta_ds = NULL;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +0530809 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800810
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530811 pe_debug("Disassoc Ntf with trigger : %d reasonCode: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800812 disassocTrigger, reasonCode);
813
814 switch (disassocTrigger) {
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700815 case eLIM_DUPLICATE_ENTRY:
816 /*
817 * Duplicate entry is removed at LIM.
818 * Initiate new entry for other session
819 */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530820 pe_debug("Rcvd eLIM_DUPLICATE_ENTRY for " MAC_ADDRESS_STR,
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700821 MAC_ADDR_ARRAY(peerMacAddr));
822
823 for (i = 0; i < pMac->lim.maxBssId; i++) {
824 if ((&pMac->lim.gpSession[i] != NULL) &&
825 (pMac->lim.gpSession[i].valid) &&
826 (pMac->lim.gpSession[i].pePersona ==
827 QDF_SAP_MODE)) {
828 /* Find the sta ds entry in another session */
829 session = &pMac->lim.gpSession[i];
830 sta_ds = dph_lookup_hash_entry(pMac,
831 peerMacAddr, &assoc_id,
832 &session->dph.dphHashTable);
Abhishek Singh6d6e3d12017-12-04 14:16:00 +0530833 if (sta_ds)
834 break;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700835 }
836 }
837 if (sta_ds
838#ifdef WLAN_FEATURE_11W
839 && (!sta_ds->rmfEnabled)
840#endif
841 ) {
842 if (lim_add_sta(pMac, sta_ds, false, session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700843 QDF_STATUS_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530844 pe_err("could not Add STA with assocId: %d",
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700845 sta_ds->assocId);
846 }
Pragaspathi Thilagaraj766c76f2018-08-08 16:44:40 +0530847 status = lim_prepare_disconnect_done_ind(pMac, &pMsg,
848 smesessionId,
849 reasonCode,
850 &peerMacAddr[0]);
851 if (!QDF_IS_STATUS_SUCCESS(status)) {
852 pe_err("Failed to prepare message");
853 return;
854 }
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700855 break;
856
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800857 case eLIM_HOST_DISASSOC:
858 /**
859 * Disassociation response due to
860 * host triggered disassociation
861 */
862
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530863 pSirSmeDisassocRsp = qdf_mem_malloc(sizeof(tSirSmeDisassocRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800864 if (NULL == pSirSmeDisassocRsp) {
865 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530866 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800867 failure = true;
868 goto error;
869 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530870 pe_debug("send eWNI_SME_DISASSOC_RSP with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800871 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
872 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
873 pSirSmeDisassocRsp->length = sizeof(tSirSmeDisassocRsp);
874 /* sessionId */
875 pBuf = (uint8_t *) &pSirSmeDisassocRsp->sessionId;
876 *pBuf = smesessionId;
877 pBuf++;
878
879 /* transactionId */
880 lim_copy_u16(pBuf, smetransactionId);
881 pBuf += sizeof(uint16_t);
882
883 /* statusCode */
884 lim_copy_u32(pBuf, reasonCode);
885 pBuf += sizeof(tSirResultCodes);
886
887 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530888 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800889 pBuf += sizeof(tSirMacAddr);
890
891 /* Clear Station Stats */
892 /* for sta, it is always 1, IBSS is handled at halInitSta */
893
894#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
895
896 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
897 psessionEntry, (uint16_t) reasonCode, 0);
898#endif
899 pMsg = (uint32_t *) pSirSmeDisassocRsp;
900 break;
901
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530902 case eLIM_PEER_ENTITY_DISASSOC:
903 case eLIM_LINK_MONITORING_DISASSOC:
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +0530904 status = lim_prepare_disconnect_done_ind(pMac, &pMsg,
905 smesessionId,
906 reasonCode, &peerMacAddr[0]);
907 if (!QDF_IS_STATUS_SUCCESS(status)) {
908 pe_err("Failed to prepare message");
909 return;
910 }
911 break;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530912
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800913 default:
914 /**
915 * Disassociation indication due to Disassociation
916 * frame reception from peer entity or due to
917 * loss of link with peer entity.
918 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530919 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800920 if (NULL == pSirSmeDisassocInd) {
921 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530922 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800923 failure = true;
924 goto error;
925 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530926 pe_debug("send eWNI_SME_DISASSOC_IND with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800927 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
928 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
929 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
930
931 /* Update SME session Id and Transaction Id */
932 pSirSmeDisassocInd->sessionId = smesessionId;
933 pSirSmeDisassocInd->transactionId = smetransactionId;
934 pSirSmeDisassocInd->reasonCode = reasonCode;
935 pBuf = (uint8_t *) &pSirSmeDisassocInd->statusCode;
936
937 lim_copy_u32(pBuf, reasonCode);
938 pBuf += sizeof(tSirResultCodes);
939
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530940 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800941 pBuf += sizeof(tSirMacAddr);
942
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530943 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800944
945#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
946 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
947 psessionEntry, (uint16_t) reasonCode, 0);
948#endif
949 pMsg = (uint32_t *) pSirSmeDisassocInd;
950
951 break;
952 }
953
954error:
955 /* Delete the PE session Created */
Rajeev Kumarcf835a02016-04-15 15:01:31 -0700956 if ((psessionEntry != NULL) && LIM_IS_STA_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800957 pe_delete_session(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800958
959 if (false == failure)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530960 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800961 (uint32_t *) pMsg);
962} /*** end lim_send_sme_disassoc_ntf() ***/
963
964/** -----------------------------------------------------------------
965 \brief lim_send_sme_disassoc_ind() - sends SME_DISASSOC_IND
966
967 After receiving disassociation frame from peer entity, this
968 function sends a eWNI_SME_DISASSOC_IND to SME with a specific
969 reason code.
970
971 \param pMac - global mac structure
972 \param pStaDs - station dph hash node
973 \return none
974 \sa
975 ----------------------------------------------------------------- */
976void
977lim_send_sme_disassoc_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
978 tpPESession psessionEntry)
979{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700980 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800981 tSirSmeDisassocInd *pSirSmeDisassocInd;
982
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530983 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800984 if (NULL == pSirSmeDisassocInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530985 pe_err("AllocateMemory failed for eWNI_SME_DISASSOC_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800986 return;
987 }
988
989 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
990 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
991
992 pSirSmeDisassocInd->sessionId = psessionEntry->smeSessionId;
993 pSirSmeDisassocInd->transactionId = psessionEntry->transactionId;
Padma, Santhosh Kumar02289212016-09-30 13:30:08 +0530994 pSirSmeDisassocInd->statusCode = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800995 pSirSmeDisassocInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
996
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530997 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530998 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800999
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301000 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301001 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001002
1003 pSirSmeDisassocInd->staId = pStaDs->staIndex;
1004
1005 mmhMsg.type = eWNI_SME_DISASSOC_IND;
1006 mmhMsg.bodyptr = pSirSmeDisassocInd;
1007 mmhMsg.bodyval = 0;
1008
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301009 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1010 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001011#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1012 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT, psessionEntry,
1013 0, (uint16_t) pStaDs->mlmStaContext.disassocReason);
1014#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1015
1016 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1017
1018} /*** end lim_send_sme_disassoc_ind() ***/
1019
1020/** -----------------------------------------------------------------
1021 \brief lim_send_sme_deauth_ind() - sends SME_DEAUTH_IND
1022
1023 After receiving deauthentication frame from peer entity, this
1024 function sends a eWNI_SME_DEAUTH_IND to SME with a specific
1025 reason code.
1026
1027 \param pMac - global mac structure
1028 \param pStaDs - station dph hash node
1029 \return none
1030 \sa
1031 ----------------------------------------------------------------- */
1032void
1033lim_send_sme_deauth_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1034 tpPESession psessionEntry)
1035{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001036 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001037 tSirSmeDeauthInd *pSirSmeDeauthInd;
1038
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301039 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040 if (NULL == pSirSmeDeauthInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301041 pe_err("AllocateMemory failed for eWNI_SME_DEAUTH_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001042 return;
1043 }
1044
1045 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1046 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1047
1048 pSirSmeDeauthInd->sessionId = psessionEntry->smeSessionId;
1049 pSirSmeDeauthInd->transactionId = psessionEntry->transactionId;
1050 if (eSIR_INFRA_AP_MODE == psessionEntry->bssType) {
1051 pSirSmeDeauthInd->statusCode =
1052 (tSirResultCodes) pStaDs->mlmStaContext.cleanupTrigger;
1053 } else {
1054 /* Need to indicatet he reascon code over the air */
1055 pSirSmeDeauthInd->statusCode =
1056 (tSirResultCodes) pStaDs->mlmStaContext.disassocReason;
1057 }
1058 /* BSSID */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301059 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301060 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001061 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301062 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301063 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001064 pSirSmeDeauthInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1065
1066 pSirSmeDeauthInd->staId = pStaDs->staIndex;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001067 if (eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON ==
1068 pStaDs->mlmStaContext.disassocReason)
1069 pSirSmeDeauthInd->rssi = pStaDs->del_sta_ctx_rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001070
1071 mmhMsg.type = eWNI_SME_DEAUTH_IND;
1072 mmhMsg.bodyptr = pSirSmeDeauthInd;
1073 mmhMsg.bodyval = 0;
1074
1075 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1076#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1077 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT, psessionEntry,
1078 0, pStaDs->mlmStaContext.cleanupTrigger);
1079#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1080
1081 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1082 return;
1083} /*** end lim_send_sme_deauth_ind() ***/
1084
1085#ifdef FEATURE_WLAN_TDLS
1086/**
1087 * lim_send_sme_tdls_del_sta_ind()
1088 *
1089 ***FUNCTION:
1090 * This function is called to send the TDLS STA context deletion to SME.
1091 *
1092 ***LOGIC:
1093 *
1094 ***ASSUMPTIONS:
1095 *
1096 ***NOTE:
1097 * NA
1098 *
1099 * @param pMac - Pointer to global MAC structure
1100 * @param pStaDs - Pointer to internal STA Datastructure
1101 * @param psessionEntry - Pointer to the session entry
1102 * @param reasonCode - Reason for TDLS sta deletion
1103 * @return None
1104 */
1105void
1106lim_send_sme_tdls_del_sta_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1107 tpPESession psessionEntry, uint16_t reasonCode)
1108{
Frank Liud1a28462017-09-06 22:55:48 +08001109 struct tdls_event_info info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001110
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301111 pe_debug("Delete TDLS Peer "MAC_ADDRESS_STR "with reason code: %d",
Nitesh Shah82c52812016-12-27 12:27:51 +05301112 MAC_ADDR_ARRAY(pStaDs->staAddr), reasonCode);
Frank Liud1a28462017-09-06 22:55:48 +08001113 info.vdev_id = psessionEntry->smeSessionId;
1114 qdf_mem_copy(info.peermac.bytes, pStaDs->staAddr, QDF_MAC_ADDR_SIZE);
1115 info.message_type = TDLS_PEER_DISCONNECTED;
1116 info.peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001117
Frank Liud1a28462017-09-06 22:55:48 +08001118 tgt_tdls_event_handler(pMac->psoc, &info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001119
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001120 return;
1121} /*** end lim_send_sme_tdls_del_sta_ind() ***/
1122
1123/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001124 * lim_send_sme_mgmt_tx_completion()
1125 *
1126 ***FUNCTION:
1127 * This function is called to send the eWNI_SME_MGMT_FRM_TX_COMPLETION_IND
1128 * message to SME.
1129 *
1130 ***LOGIC:
1131 *
1132 ***ASSUMPTIONS:
1133 *
1134 ***NOTE:
1135 * NA
1136 *
1137 * @param pMac - Pointer to global MAC structure
1138 * @param psessionEntry - Pointer to the session entry
1139 * @param txCompleteStatus - TX Complete Status of Mgmt Frames
1140 * @return None
1141 */
1142void
1143lim_send_sme_mgmt_tx_completion(tpAniSirGlobal pMac,
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301144 uint32_t sme_session_id,
1145 uint32_t txCompleteStatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001146{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001147 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001148 tSirMgmtTxCompletionInd *pSirMgmtTxCompletionInd;
1149
1150 pSirMgmtTxCompletionInd =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301151 qdf_mem_malloc(sizeof(tSirMgmtTxCompletionInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001152 if (NULL == pSirMgmtTxCompletionInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301153 pe_err("AllocateMemory failed for eWNI_SME_MGMT_FRM_TX_COMPLETION_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001154 return;
1155 }
1156 /* messageType */
1157 pSirMgmtTxCompletionInd->messageType =
1158 eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1159 pSirMgmtTxCompletionInd->length = sizeof(tSirMgmtTxCompletionInd);
1160
1161 /* sessionId */
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301162 pSirMgmtTxCompletionInd->sessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001163
1164 pSirMgmtTxCompletionInd->txCompleteStatus = txCompleteStatus;
1165
1166 mmhMsg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1167 mmhMsg.bodyptr = pSirMgmtTxCompletionInd;
1168 mmhMsg.bodyval = 0;
1169
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07001170 pSirMgmtTxCompletionInd->psoc = pMac->psoc;
1171 mmhMsg.callback = tgt_tdls_send_mgmt_tx_completion;
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05301172 scheduler_post_message(QDF_MODULE_ID_PE,
1173 QDF_MODULE_ID_TDLS,
1174 QDF_MODULE_ID_TARGET_IF, &mmhMsg);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07001175 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001176} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1177
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001178#endif /* FEATURE_WLAN_TDLS */
1179
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301180QDF_STATUS lim_prepare_disconnect_done_ind(tpAniSirGlobal mac_ctx,
1181 uint32_t **msg,
1182 uint8_t session_id,
1183 tSirResultCodes reason_code,
1184 uint8_t *peer_mac_addr)
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301185{
1186 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301187
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301188 sir_sme_dis_ind = qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301189 if (!sir_sme_dis_ind) {
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301190 pe_err("Failed to allocate memory");
1191 return QDF_STATUS_E_FAILURE;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301192 }
1193
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301194 pe_debug("Prepare eWNI_SME_DISCONNECT_DONE_IND withretCode: %d",
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301195 reason_code);
1196
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301197 sir_sme_dis_ind->message_type = eWNI_SME_DISCONNECT_DONE_IND;
1198 sir_sme_dis_ind->length = sizeof(*sir_sme_dis_ind);
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301199 sir_sme_dis_ind->session_id = session_id;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301200 if (peer_mac_addr)
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05301201 qdf_mem_copy(sir_sme_dis_ind->peer_mac,
1202 peer_mac_addr, ETH_ALEN);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301203
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301204 /*
1205 * Instead of sending deauth reason code as 505 which is
1206 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1207 * Send reason code as zero to Supplicant
1208 */
1209 if (reason_code == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1210 sir_sme_dis_ind->reason_code = 0;
1211 else
1212 sir_sme_dis_ind->reason_code = reason_code;
1213
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301214 *msg = (uint32_t *)sir_sme_dis_ind;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301215
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301216 return QDF_STATUS_SUCCESS;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301217}
1218
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001219/**
1220 * lim_send_sme_deauth_ntf()
1221 *
1222 ***FUNCTION:
1223 * This function is called by limProcessSmeMessages() to send
1224 * eWNI_SME_DISASSOC_RSP/IND message to host
1225 *
1226 ***PARAMS:
1227 *
1228 ***LOGIC:
1229 *
1230 ***ASSUMPTIONS:
1231 * NA
1232 *
1233 ***NOTE:
1234 * This function is used for sending eWNI_SME_DEAUTH_CNF or
1235 * eWNI_SME_DEAUTH_IND to host depending on deauthentication trigger.
1236 *
1237 * @param peerMacAddr Indicates the peer MAC addr to which
1238 * deauthentication was initiated
1239 * @param reasonCode Indicates the reason for Deauthetication
1240 * @param deauthTrigger Indicates the trigger for Deauthetication
1241 * @param aid Indicates the STAID. This parameter is present
1242 * only on AP.
1243 *
1244 * @return None
1245 */
1246void
1247lim_send_sme_deauth_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
1248 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1249 uint16_t aid, uint8_t smesessionId,
1250 uint16_t smetransactionId)
1251{
1252 uint8_t *pBuf;
1253 tSirSmeDeauthRsp *pSirSmeDeauthRsp;
1254 tSirSmeDeauthInd *pSirSmeDeauthInd;
1255 tpPESession psessionEntry;
1256 uint8_t sessionId;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301257 uint32_t *pMsg = NULL;
1258 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001259
1260 psessionEntry = pe_find_session_by_bssid(pMac, peerMacAddr, &sessionId);
1261 switch (deauthTrigger) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001262 case eLIM_HOST_DEAUTH:
1263 /**
1264 * Deauthentication response to host triggered
1265 * deauthentication.
1266 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301267 pSirSmeDeauthRsp = qdf_mem_malloc(sizeof(tSirSmeDeauthRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001268 if (NULL == pSirSmeDeauthRsp) {
1269 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301270 pe_err("call to AllocateMemory failed for eWNI_SME_DEAUTH_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001271 return;
1272 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301273 pe_debug("send eWNI_SME_DEAUTH_RSP with retCode: %d for" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001274 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1275 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
1276 pSirSmeDeauthRsp->length = sizeof(tSirSmeDeauthRsp);
1277 pSirSmeDeauthRsp->statusCode = reasonCode;
1278 pSirSmeDeauthRsp->sessionId = smesessionId;
1279 pSirSmeDeauthRsp->transactionId = smetransactionId;
1280
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -08001281 pBuf = (uint8_t *) pSirSmeDeauthRsp->peer_macaddr.bytes;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301282 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001283
1284#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1285 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
1286 psessionEntry, 0, (uint16_t) reasonCode);
1287#endif
1288 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1289
1290 break;
1291
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301292 case eLIM_PEER_ENTITY_DEAUTH:
1293 case eLIM_LINK_MONITORING_DEAUTH:
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301294 status = lim_prepare_disconnect_done_ind(pMac, &pMsg,
1295 smesessionId, reasonCode,
1296 &peerMacAddr[0]);
1297 if (!QDF_IS_STATUS_SUCCESS(status)) {
1298 pe_err("Failed to prepare message");
1299 return;
1300 }
1301 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001302 default:
1303 /**
1304 * Deauthentication indication due to Deauthentication
1305 * frame reception from peer entity or due to
1306 * loss of link with peer entity.
1307 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301308 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001309 if (NULL == pSirSmeDeauthInd) {
1310 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301311 pe_err("call to AllocateMemory failed for eWNI_SME_DEAUTH_Ind");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001312 return;
1313 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301314 pe_debug("send eWNI_SME_DEAUTH_IND with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001315 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1316 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1317 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1318 pSirSmeDeauthInd->reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
1319
1320 /* sessionId */
1321 pBuf = (uint8_t *) &pSirSmeDeauthInd->sessionId;
1322 *pBuf++ = smesessionId;
1323
1324 /* transaction ID */
1325 lim_copy_u16(pBuf, smetransactionId);
1326 pBuf += sizeof(uint16_t);
1327
1328 /* status code */
1329 lim_copy_u32(pBuf, reasonCode);
1330 pBuf += sizeof(tSirResultCodes);
1331
1332 /* bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301333 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001334 pBuf += sizeof(tSirMacAddr);
1335
1336 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301337 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301338 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001339
1340#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1341 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
1342 psessionEntry, 0, (uint16_t) reasonCode);
1343#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1344 pMsg = (uint32_t *) pSirSmeDeauthInd;
1345
1346 break;
1347 }
1348
1349 /*Delete the PE session created */
1350 if (psessionEntry != NULL) {
1351 pe_delete_session(pMac, psessionEntry);
1352 }
1353
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301354 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001355 (uint32_t *) pMsg);
1356
1357} /*** end lim_send_sme_deauth_ntf() ***/
1358
1359/**
1360 * lim_send_sme_wm_status_change_ntf() - Send Notification
1361 * @mac_ctx: Global MAC Context
1362 * @status_change_code: Indicates the change in the wireless medium.
1363 * @status_change_info: Indicates the information associated with
1364 * change in the wireless medium.
1365 * @info_len: Indicates the length of status change information
1366 * being sent.
1367 * @session_id SessionID
1368 *
1369 * This function is called by limProcessSmeMessages() to send
1370 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1371 *
1372 * Return: None
1373 */
1374void
1375lim_send_sme_wm_status_change_ntf(tpAniSirGlobal mac_ctx,
1376 tSirSmeStatusChangeCode status_change_code,
1377 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1378{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001379 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001380 tSirSmeWmStatusChangeNtf *wm_status_change_ntf;
Naveen Rawate01ed172016-11-17 11:34:50 -08001381 uint32_t max_info_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001382
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301383 wm_status_change_ntf = qdf_mem_malloc(sizeof(tSirSmeWmStatusChangeNtf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001384 if (NULL == wm_status_change_ntf) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301385 pe_err("Mem Alloc failed - eWNI_SME_WM_STATUS_CHANGE_NTF");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001386 return;
1387 }
1388
1389 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1390 msg.bodyval = 0;
1391 msg.bodyptr = wm_status_change_ntf;
1392
1393 switch (status_change_code) {
Naveen Rawate01ed172016-11-17 11:34:50 -08001394 case eSIR_SME_AP_CAPS_CHANGED:
1395 max_info_len = sizeof(tSirSmeApNewCaps);
1396 break;
1397 case eSIR_SME_JOINED_NEW_BSS:
1398 max_info_len = sizeof(tSirSmeNewBssInfo);
1399 break;
1400 default:
1401 max_info_len = sizeof(wm_status_change_ntf->statusChangeInfo);
1402 break;
1403 }
1404
1405 switch (status_change_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001406 case eSIR_SME_RADAR_DETECTED:
1407 break;
1408 default:
1409 wm_status_change_ntf->messageType =
1410 eWNI_SME_WM_STATUS_CHANGE_NTF;
1411 wm_status_change_ntf->statusChangeCode = status_change_code;
1412 wm_status_change_ntf->length = sizeof(tSirSmeWmStatusChangeNtf);
1413 wm_status_change_ntf->sessionId = session_id;
Naveen Rawate01ed172016-11-17 11:34:50 -08001414 if (info_len <= max_info_len && status_change_info) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301415 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001416 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1417 (uint8_t *) status_change_info, info_len);
1418 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301419 pe_debug("StatusChg code: 0x%x length: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001420 status_change_code, info_len);
1421 break;
1422 }
1423
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301424 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, session_id, msg.type));
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001425 if (QDF_STATUS_SUCCESS != lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301426 qdf_mem_free(wm_status_change_ntf);
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301427 pe_err("lim_sys_process_mmh_msg_api failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001428 }
1429
1430} /*** end lim_send_sme_wm_status_change_ntf() ***/
1431
1432/**
1433 * lim_send_sme_set_context_rsp()
1434 *
1435 ***FUNCTION:
1436 * This function is called by limProcessSmeMessages() to send
1437 * eWNI_SME_SETCONTEXT_RSP message to host
1438 *
1439 ***PARAMS:
1440 *
1441 ***LOGIC:
1442 *
1443 ***ASSUMPTIONS:
1444 * NA
1445 *
1446 ***NOTE:
1447 *
1448 * @param pMac Pointer to Global MAC structure
1449 * @param peerMacAddr Indicates the peer MAC addr to which
1450 * setContext was performed
1451 * @param aid Indicates the aid corresponding to the peer MAC
1452 * address
1453 * @param resultCode Indicates the result of previously issued
1454 * eWNI_SME_SETCONTEXT_RSP message
1455 *
1456 * @return None
1457 */
1458void
1459lim_send_sme_set_context_rsp(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301460 struct qdf_mac_addr peer_macaddr, uint16_t aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001461 tSirResultCodes resultCode,
1462 tpPESession psessionEntry, uint8_t smesessionId,
1463 uint16_t smetransactionId)
1464{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001465 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001466 tSirSmeSetContextRsp *pSirSmeSetContextRsp;
1467
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301468 pSirSmeSetContextRsp = qdf_mem_malloc(sizeof(tSirSmeSetContextRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001469 if (NULL == pSirSmeSetContextRsp) {
1470 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301471 pe_err("call to AllocateMemory failed for SmeSetContextRsp");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001472 return;
1473 }
1474
1475 pSirSmeSetContextRsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1476 pSirSmeSetContextRsp->length = sizeof(tSirSmeSetContextRsp);
1477 pSirSmeSetContextRsp->statusCode = resultCode;
1478
Anurag Chouhanc5548422016-02-24 18:33:27 +05301479 qdf_copy_macaddr(&pSirSmeSetContextRsp->peer_macaddr, &peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001480
1481 /* Update SME session and transaction Id */
1482 pSirSmeSetContextRsp->sessionId = smesessionId;
1483 pSirSmeSetContextRsp->transactionId = smetransactionId;
1484
1485 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
1486 mmhMsg.bodyptr = pSirSmeSetContextRsp;
1487 mmhMsg.bodyval = 0;
1488 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301489 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1490 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001491 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301492 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1493 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001494 }
1495
1496#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1497 lim_diag_event_report(pMac, WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
1498 psessionEntry, (uint16_t) resultCode, 0);
1499#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1500
Himanshu Agarwal2785d242018-05-09 12:39:52 +05301501 pMac->lim.sme_msg_callback(pMac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001502} /*** end lim_send_sme_set_context_rsp() ***/
1503
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001504/** -----------------------------------------------------------------
1505 \brief lim_send_sme_addts_rsp() - sends SME ADDTS RSP
1506 \ This function sends a eWNI_SME_ADDTS_RSP to SME.
1507 \ SME only looks at rc and tspec field.
1508 \param pMac - global mac structure
1509 \param rspReqd - is SmeAddTsRsp required
1510 \param status - status code of SME_ADD_TS_RSP
1511 \return tspec
1512 \sa
1513 ----------------------------------------------------------------- */
1514void
1515lim_send_sme_addts_rsp(tpAniSirGlobal pMac, uint8_t rspReqd, uint32_t status,
1516 tpPESession psessionEntry, tSirMacTspecIE tspec,
1517 uint8_t smesessionId, uint16_t smetransactionId)
1518{
1519 tpSirAddtsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001520 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001521
1522 if (!rspReqd)
1523 return;
1524
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301525 rsp = qdf_mem_malloc(sizeof(tSirAddtsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001526 if (NULL == rsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301527 pe_err("AllocateMemory failed for ADDTS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001528 return;
1529 }
1530
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001531 rsp->messageType = eWNI_SME_ADDTS_RSP;
1532 rsp->rc = status;
1533 rsp->rsp.status = (enum eSirMacStatusCodes)status;
1534 rsp->rsp.tspec = tspec;
1535 /* Update SME session Id and transcation Id */
1536 rsp->sessionId = smesessionId;
1537 rsp->transactionId = smetransactionId;
1538
1539 mmhMsg.type = eWNI_SME_ADDTS_RSP;
1540 mmhMsg.bodyptr = rsp;
1541 mmhMsg.bodyval = 0;
1542 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301543 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1544 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001545 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301546 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1547 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001548 }
1549#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1550 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_RSP_EVENT, psessionEntry, 0,
1551 0);
1552#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1553
1554 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1555 return;
1556}
1557
1558void
1559lim_send_sme_delts_rsp(tpAniSirGlobal pMac, tpSirDeltsReq delts, uint32_t status,
1560 tpPESession psessionEntry, uint8_t smesessionId,
1561 uint16_t smetransactionId)
1562{
1563 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001564 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001565
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301566 pe_debug("SendSmeDeltsRsp aid: %d tsid: %d up: %d status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001567 delts->aid,
1568 delts->req.tsinfo.traffic.tsid,
1569 delts->req.tsinfo.traffic.userPrio, status);
1570 if (!delts->rspReqd)
1571 return;
1572
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301573 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001574 if (NULL == rsp) {
1575 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301576 pe_err("AllocateMemory failed for DELTS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001577 return;
1578 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001579
1580 if (psessionEntry != NULL) {
1581
1582 rsp->aid = delts->aid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301583 qdf_copy_macaddr(&rsp->macaddr, &delts->macaddr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301584 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) &delts->req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001585 sizeof(tSirDeltsReqInfo));
1586 }
1587
1588 rsp->messageType = eWNI_SME_DELTS_RSP;
1589 rsp->rc = status;
1590
1591 /* Update SME session Id and transcation Id */
1592 rsp->sessionId = smesessionId;
1593 rsp->transactionId = smetransactionId;
1594
1595 mmhMsg.type = eWNI_SME_DELTS_RSP;
1596 mmhMsg.bodyptr = rsp;
1597 mmhMsg.bodyval = 0;
1598 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301599 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1600 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001601 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301602 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1603 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001604 }
1605#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1606 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_RSP_EVENT, psessionEntry,
1607 (uint16_t) status, 0);
1608#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1609
1610 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1611}
1612
1613void
1614lim_send_sme_delts_ind(tpAniSirGlobal pMac, tpSirDeltsReqInfo delts, uint16_t aid,
1615 tpPESession psessionEntry)
1616{
1617 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001618 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001619
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301620 pe_debug("SendSmeDeltsInd aid: %d tsid: %d up: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001621 aid, delts->tsinfo.traffic.tsid, delts->tsinfo.traffic.userPrio);
1622
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301623 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001624 if (NULL == rsp) {
1625 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301626 pe_err("AllocateMemory failed for DELTS_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001627 return;
1628 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001629
1630 rsp->messageType = eWNI_SME_DELTS_IND;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001631 rsp->rc = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001632 rsp->aid = aid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301633 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) delts, sizeof(*delts));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001634
1635 /* Update SME session Id and SME transaction Id */
1636
1637 rsp->sessionId = psessionEntry->smeSessionId;
1638 rsp->transactionId = psessionEntry->transactionId;
1639
1640 mmhMsg.type = eWNI_SME_DELTS_IND;
1641 mmhMsg.bodyptr = rsp;
1642 mmhMsg.bodyval = 0;
1643 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1644#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1645 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_IND_EVENT, psessionEntry, 0,
1646 0);
1647#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1648
1649 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1650}
1651
Naveen Rawatfa2a1002018-05-17 16:06:37 -07001652#ifndef QCA_SUPPORT_CP_STATS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001653/**
1654 * lim_send_sme_pe_statistics_rsp()
1655 *
1656 ***FUNCTION:
1657 * This function is called to send 802.11 statistics response to HDD.
1658 * This function posts the result back to HDD. This is a response to
1659 * HDD's request for statistics.
1660 *
1661 ***PARAMS:
1662 *
1663 ***LOGIC:
1664 *
1665 ***ASSUMPTIONS:
1666 * NA
1667 *
1668 ***NOTE:
1669 * NA
1670 *
1671 * @param pMac Pointer to Global MAC structure
1672 * @param p80211Stats Statistics sent in response
1673 * @param resultCode TODO:
1674 *
1675 *
1676 * @return none
1677 */
1678
1679void
1680lim_send_sme_pe_statistics_rsp(tpAniSirGlobal pMac, uint16_t msgType, void *stats)
1681{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001682 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001683 uint8_t sessionId;
1684 tAniGetPEStatsRsp *pPeStats = (tAniGetPEStatsRsp *) stats;
1685 tpPESession pPeSessionEntry;
1686
1687 /* Get the Session Id based on Sta Id */
1688 pPeSessionEntry =
1689 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1690
1691 /* Fill the Session Id */
1692 if (NULL != pPeSessionEntry) {
1693 /* Fill the Session Id */
1694 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1695 }
1696
1697 pPeStats->msgType = eWNI_SME_GET_STATISTICS_RSP;
1698
1699 /* msgType should be WMA_GET_STATISTICS_RSP */
1700 mmhMsg.type = eWNI_SME_GET_STATISTICS_RSP;
1701
1702 mmhMsg.bodyptr = stats;
1703 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301704 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001705 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1706
1707 return;
1708
1709} /*** end lim_send_sme_pe_statistics_rsp() ***/
Naveen Rawatfa2a1002018-05-17 16:06:37 -07001710#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001711
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001712#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001713/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001714 * lim_send_sme_pe_ese_tsm_rsp() - send tsm response
1715 * @pMac: Pointer to global pMac structure
1716 * @pStats: Pointer to TSM Stats
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001717 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001718 * This function is called to send tsm stats response to HDD.
1719 * This function posts the result back to HDD. This is a response to
1720 * HDD's request to get tsm stats.
1721 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001722 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001723 */
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001724void lim_send_sme_pe_ese_tsm_rsp(tpAniSirGlobal pMac,
1725 tAniGetTsmStatsRsp *pStats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001726{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001727 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001728 uint8_t sessionId;
1729 tAniGetTsmStatsRsp *pPeStats = (tAniGetTsmStatsRsp *) pStats;
1730 tpPESession pPeSessionEntry = NULL;
1731
1732 /* Get the Session Id based on Sta Id */
1733 pPeSessionEntry =
1734 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1735
1736 /* Fill the Session Id */
1737 if (NULL != pPeSessionEntry) {
1738 /* Fill the Session Id */
1739 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1740 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301741 pe_err("Session not found for the Sta id: %d",
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301742 pPeStats->staId);
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05301743 qdf_mem_free(pPeStats->tsmStatsReq);
1744 qdf_mem_free(pPeStats);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001745 return;
1746 }
1747
1748 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
1749 pPeStats->tsmMetrics.RoamingCount
1750 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
1751 pPeStats->tsmMetrics.RoamingDly
1752 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
1753
1754 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
1755 mmhMsg.bodyptr = pStats;
1756 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301757 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001758 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1759
1760 return;
1761} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
1762
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001763#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001764
1765void
1766lim_send_sme_ibss_peer_ind(tpAniSirGlobal pMac,
1767 tSirMacAddr peerMacAddr,
1768 uint16_t staIndex,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001769 uint8_t *beacon,
1770 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
1771{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001772 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001773 tSmeIbssPeerInd *pNewPeerInd;
1774
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301775 pNewPeerInd = qdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001776 if (NULL == pNewPeerInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301777 pe_err("Failed to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001778 return;
1779 }
1780
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301781 qdf_mem_copy((uint8_t *) pNewPeerInd->peer_addr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301782 peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001783 pNewPeerInd->staId = staIndex;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001784 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
1785 pNewPeerInd->mesgType = msgType;
1786 pNewPeerInd->sessionId = sessionId;
1787
1788 if (beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301789 qdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001790 sizeof(tSmeIbssPeerInd)), (void *)beacon,
1791 beaconLen);
1792 }
1793
1794 mmhMsg.type = msgType;
1795 mmhMsg.bodyptr = pNewPeerInd;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301796 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001797 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1798
1799}
1800
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07001801/**
1802 * lim_process_csa_wbw_ie() - Process CSA Wide BW IE
1803 * @mac_ctx: pointer to global adapter context
1804 * @csa_params: pointer to CSA parameters
1805 * @chnl_switch_info:pointer to channel switch parameters
1806 * @session_entry: session pointer
1807 *
1808 * Return: None
1809 */
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001810static QDF_STATUS lim_process_csa_wbw_ie(tpAniSirGlobal mac_ctx,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001811 struct csa_offload_params *csa_params,
1812 tLimWiderBWChannelSwitchInfo *chnl_switch_info,
1813 tpPESession session_entry)
1814{
Amar Singhal5cccafe2017-02-15 12:42:58 -08001815 struct ch_params ch_params = {0};
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001816 uint8_t ap_new_ch_width;
1817 bool new_ch_width_dfn = false;
1818 uint8_t center_freq_diff;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001819 uint32_t fw_vht_ch_wd = wma_get_vht_ch_width() + 1;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001820
1821 ap_new_ch_width = csa_params->new_ch_width + 1;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001822
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001823 pe_debug("new channel: %d new_ch_width: %d seg0: %d seg1: %d",
1824 csa_params->channel, ap_new_ch_width,
1825 csa_params->new_ch_freq_seg1,
1826 csa_params->new_ch_freq_seg2);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001827
1828 if ((ap_new_ch_width != CH_WIDTH_80MHZ) &&
1829 (ap_new_ch_width != CH_WIDTH_160MHZ) &&
1830 (ap_new_ch_width != CH_WIDTH_80P80MHZ)) {
1831 pe_err("CSA wide BW IE has wrong ch_width %d",
1832 csa_params->new_ch_width);
1833 return QDF_STATUS_E_INVAL;
1834 }
1835
1836 if (!csa_params->new_ch_freq_seg1 && !csa_params->new_ch_freq_seg2) {
1837 pe_err("CSA wide BW IE has invalid center freq");
1838 return QDF_STATUS_E_INVAL;
1839 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001840 if ((ap_new_ch_width == CH_WIDTH_80MHZ) &&
1841 csa_params->new_ch_freq_seg2) {
1842 new_ch_width_dfn = true;
1843 if (csa_params->new_ch_freq_seg2 >
1844 csa_params->new_ch_freq_seg1)
1845 center_freq_diff = csa_params->new_ch_freq_seg2 -
1846 csa_params->new_ch_freq_seg1;
1847 else
1848 center_freq_diff = csa_params->new_ch_freq_seg1 -
1849 csa_params->new_ch_freq_seg2;
1850 if (center_freq_diff == CENTER_FREQ_DIFF_160MHz)
1851 ap_new_ch_width = CH_WIDTH_160MHZ;
1852 else if (center_freq_diff > CENTER_FREQ_DIFF_80P80MHz)
1853 ap_new_ch_width = CH_WIDTH_80P80MHZ;
1854 else
1855 ap_new_ch_width = CH_WIDTH_80MHZ;
1856 }
1857 session_entry->gLimChannelSwitch.state =
1858 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1859 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
1860 !new_ch_width_dfn) {
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001861 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1862 CH_TO_CNTR_FREQ_DIFF_160MHz) {
1863 pe_err("CSA wide BW IE has invalid center freq");
1864 return QDF_STATUS_E_INVAL;
1865 }
1866
1867 if (ap_new_ch_width > fw_vht_ch_wd) {
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001868 pe_debug("New BW is not supported, setting BW to %d",
1869 fw_vht_ch_wd);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001870 ap_new_ch_width = fw_vht_ch_wd;
1871 }
1872 ch_params.ch_width = ap_new_ch_width ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001873 wlan_reg_set_channel_params(mac_ctx->pdev,
1874 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001875 ap_new_ch_width = ch_params.ch_width;
1876 csa_params->new_ch_freq_seg1 = ch_params.center_freq_seg0;
1877 csa_params->new_ch_freq_seg2 = ch_params.center_freq_seg1;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001878 } else if (!new_ch_width_dfn) {
1879 if (ap_new_ch_width > fw_vht_ch_wd) {
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001880 pe_debug("New BW is not supported, setting BW to %d",
1881 fw_vht_ch_wd);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001882 ap_new_ch_width = fw_vht_ch_wd;
1883 }
1884 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1885 CH_TO_CNTR_FREQ_DIFF_80MHz) {
1886 pe_err("CSA wide BW IE has invalid center freq");
1887 return QDF_STATUS_E_INVAL;
1888 }
1889 csa_params->new_ch_freq_seg2 = 0;
1890 }
1891 if (new_ch_width_dfn) {
1892 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1893 CH_TO_CNTR_FREQ_DIFF_80MHz) {
1894 pe_err("CSA wide BW IE has invalid center freq");
1895 return QDF_STATUS_E_INVAL;
1896 }
1897 if (ap_new_ch_width > fw_vht_ch_wd) {
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07001898 pe_debug("New width is not supported, setting BW to %d",
1899 fw_vht_ch_wd);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001900 ap_new_ch_width = fw_vht_ch_wd;
1901 }
1902 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
1903 (csa_params->new_ch_freq_seg1 !=
1904 csa_params->channel +
1905 CH_TO_CNTR_FREQ_DIFF_160MHz)) {
1906 pe_err("wide BW IE has invalid 160M center freq");
1907 csa_params->new_ch_freq_seg2 = 0;
1908 ap_new_ch_width = CH_WIDTH_80MHZ;
1909 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001910 }
1911 chnl_switch_info->newChanWidth = ap_new_ch_width;
1912 chnl_switch_info->newCenterChanFreq0 = csa_params->new_ch_freq_seg1;
1913 chnl_switch_info->newCenterChanFreq1 = csa_params->new_ch_freq_seg2;
1914
1915 if (session_entry->ch_width == ap_new_ch_width)
1916 goto prnt_log;
1917
1918 if (session_entry->ch_width == CH_WIDTH_80MHZ) {
1919 chnl_switch_info->newChanWidth = CH_WIDTH_80MHZ;
1920 chnl_switch_info->newCenterChanFreq1 = 0;
1921 } else {
1922 session_entry->ch_width = ap_new_ch_width;
1923 chnl_switch_info->newChanWidth = ap_new_ch_width;
1924 }
1925prnt_log:
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301926 pe_debug("new channel: %d new_ch_width: %d seg0: %d seg1: %d",
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001927 csa_params->channel,
1928 chnl_switch_info->newChanWidth,
1929 chnl_switch_info->newCenterChanFreq0,
1930 chnl_switch_info->newCenterChanFreq1);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001931
1932 return QDF_STATUS_SUCCESS;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001933}
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001934
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001935/**
1936 * lim_handle_csa_offload_msg() - Handle CSA offload message
1937 * @mac_ctx: pointer to global adapter context
1938 * @msg: Message pointer.
1939 *
1940 * Return: None
1941 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001942void lim_handle_csa_offload_msg(tpAniSirGlobal mac_ctx,
1943 struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001944{
1945 tpPESession session_entry;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001946 struct scheduler_msg mmh_msg = {0};
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301947 struct csa_offload_params *csa_params =
1948 (struct csa_offload_params *) (msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001949 tpSmeCsaOffloadInd csa_offload_ind;
1950 tpDphHashNode sta_ds = NULL;
1951 uint8_t session_id;
1952 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05301953 uint16_t chan_space = 0;
Krunal Sonie2c45a92018-05-03 11:51:26 -07001954 struct ch_params ch_params = {0};
Gupta, Kapil121bf212015-11-25 19:21:29 +05301955
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001956 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08001957 tLimChannelSwitchInfo *lim_ch_switch = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001958
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301959 pe_debug("handle csa offload msg");
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301960
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001961 if (!csa_params) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301962 pe_err("limMsgQ body ptr is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001963 return;
1964 }
1965
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05301966 csa_offload_ind = qdf_mem_malloc(sizeof(tSmeCsaOffloadInd));
1967 if (NULL == csa_offload_ind) {
1968 pe_err("memalloc fail eWNI_SME_CSA_OFFLOAD_EVENT");
1969 goto err;
1970 }
1971
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001972 session_entry =
1973 pe_find_session_by_bssid(mac_ctx,
1974 csa_params->bssId, &session_id);
1975 if (!session_entry) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301976 pe_err("Session does not exists for %pM",
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301977 csa_params->bssId);
Pragaspathi Thilagaraj655db192018-06-19 17:41:37 +05301978 qdf_mem_free(csa_offload_ind);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001979 goto err;
1980 }
1981
1982 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
1983 &session_entry->dph.dphHashTable);
1984
1985 if (!sta_ds) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301986 pe_err("sta_ds does not exist");
Pragaspathi Thilagaraj655db192018-06-19 17:41:37 +05301987 qdf_mem_free(csa_offload_ind);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001988 goto err;
1989 }
1990
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001991 if (!LIM_IS_STA_ROLE(session_entry)) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301992 pe_debug("Invalid role to handle CSA");
Pragaspathi Thilagaraj655db192018-06-19 17:41:37 +05301993 qdf_mem_free(csa_offload_ind);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001994 goto err;
1995 }
Masti, Narayanraddi1c630442015-11-02 12:03:50 +05301996
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001997 /*
1998 * on receiving channel switch announcement from AP, delete all
1999 * TDLS peers before leaving BSS and proceed for channel switch
2000 */
2001 lim_delete_tdls_peers(mac_ctx, session_entry);
Gupta, Kapil121bf212015-11-25 19:21:29 +05302002
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002003 lim_ch_switch = &session_entry->gLimChannelSwitch;
2004 session_entry->gLimChannelSwitch.switchMode =
2005 csa_params->switch_mode;
2006 /* timer already started by firmware, switch immediately */
2007 session_entry->gLimChannelSwitch.switchCount = 0;
2008 session_entry->gLimChannelSwitch.primaryChannel =
2009 csa_params->channel;
2010 session_entry->gLimChannelSwitch.state =
2011 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2012 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
2013 lim_ch_switch->sec_ch_offset =
2014 session_entry->htSecondaryChannelOffset;
2015 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
2016 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
2017 chnl_switch_info =
2018 &session_entry->gLimWiderBWChannelSwitch;
2019
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07002020 pe_debug("vht: %d ht: %d flag: %x chan: %d, sec_ch_offset %d",
2021 session_entry->vhtCapability,
2022 session_entry->htSupportedChannelWidthSet,
2023 csa_params->ies_present_flag,
2024 csa_params->channel,
2025 csa_params->sec_chan_offset);
2026 pe_debug("seg1: %d seg2: %d width: %d country: %s class: %d",
2027 csa_params->new_ch_freq_seg1,
2028 csa_params->new_ch_freq_seg2,
2029 csa_params->new_ch_width,
2030 mac_ctx->scan.countryCodeCurrent,
2031 csa_params->new_op_class);
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302032
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002033 if (session_entry->vhtCapability &&
2034 session_entry->htSupportedChannelWidthSet) {
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08002035 if ((csa_params->ies_present_flag & lim_wbw_ie_present) &&
2036 (QDF_STATUS_SUCCESS == lim_process_csa_wbw_ie(mac_ctx,
2037 csa_params, chnl_switch_info,
2038 session_entry))) {
2039 pe_debug("CSA wide BW IE process successful");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002040 lim_ch_switch->sec_ch_offset =
Abhishek Singhaf639b42017-06-16 14:14:36 +05302041 PHY_SINGLE_CHANNEL_CENTERED;
2042 if (chnl_switch_info->newChanWidth) {
2043 if (csa_params->channel <
2044 csa_params->new_ch_freq_seg1)
2045 lim_ch_switch->sec_ch_offset =
2046 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
2047 else
2048 lim_ch_switch->sec_ch_offset =
2049 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
2050 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002051 } else if (csa_params->ies_present_flag
2052 & lim_xcsa_ie_present) {
2053 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002054 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002055 mac_ctx->scan.countryCodeCurrent,
2056 csa_params->channel,
2057 csa_params->new_op_class);
2058 session_entry->gLimChannelSwitch.state =
2059 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2060
2061 if (chan_space == 80) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002062 chnl_switch_info->newChanWidth =
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002063 CH_WIDTH_80MHZ;
2064 } else if (chan_space == 40) {
2065 chnl_switch_info->newChanWidth =
2066 CH_WIDTH_40MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002067 } else {
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002068 chnl_switch_info->newChanWidth =
2069 CH_WIDTH_20MHZ;
2070 lim_ch_switch->state =
2071 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2072 }
2073
2074 ch_params.ch_width =
2075 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002076 wlan_reg_set_channel_params(mac_ctx->pdev,
2077 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002078 chnl_switch_info->newCenterChanFreq0 =
2079 ch_params.center_freq_seg0;
2080 /*
2081 * This is not applicable for 20/40/80 MHz.
2082 * Only used when we support 80+80 MHz operation.
2083 * In case of 80+80 MHz, this parameter indicates
2084 * center channel frequency index of 80 MHz
2085 * channel offrequency segment 1.
2086 */
2087 chnl_switch_info->newCenterChanFreq1 =
2088 ch_params.center_freq_seg1;
2089 lim_ch_switch->sec_ch_offset =
2090 ch_params.sec_ch_offset;
2091
Kiran Kumar Lokere47127482017-12-20 18:09:55 -08002092 } else {
2093 lim_ch_switch->state =
2094 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2095 ch_params.ch_width = CH_WIDTH_40MHZ;
2096 wlan_reg_set_channel_params(mac_ctx->pdev,
2097 csa_params->channel, 0, &ch_params);
2098 lim_ch_switch->sec_ch_offset =
2099 ch_params.sec_ch_offset;
2100 chnl_switch_info->newChanWidth = CH_WIDTH_40MHZ;
2101 chnl_switch_info->newCenterChanFreq0 =
2102 ch_params.center_freq_seg0;
2103 chnl_switch_info->newCenterChanFreq1 = 0;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002104 }
2105 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
2106 chnl_switch_info->newCenterChanFreq0;
2107 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
2108 chnl_switch_info->newCenterChanFreq1;
2109 session_entry->gLimChannelSwitch.ch_width =
2110 chnl_switch_info->newChanWidth;
2111
2112 } else if (session_entry->htSupportedChannelWidthSet) {
2113 if (csa_params->ies_present_flag
2114 & lim_xcsa_ie_present) {
2115 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002116 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002117 mac_ctx->scan.countryCodeCurrent,
2118 csa_params->channel,
2119 csa_params->new_op_class);
2120 lim_ch_switch->state =
2121 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2122 if (chan_space == 40) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002123 lim_ch_switch->ch_width =
2124 CH_WIDTH_40MHZ;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002125 chnl_switch_info->newChanWidth =
2126 CH_WIDTH_40MHZ;
2127 ch_params.ch_width =
2128 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002129 wlan_reg_set_channel_params(mac_ctx->pdev,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002130 csa_params->channel,
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07002131 0, &ch_params);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002132 lim_ch_switch->ch_center_freq_seg0 =
2133 ch_params.center_freq_seg0;
2134 lim_ch_switch->sec_ch_offset =
2135 ch_params.sec_ch_offset;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002136 } else {
2137 lim_ch_switch->ch_width =
2138 CH_WIDTH_20MHZ;
2139 chnl_switch_info->newChanWidth =
2140 CH_WIDTH_40MHZ;
2141 lim_ch_switch->state =
2142 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2143 lim_ch_switch->sec_ch_offset =
2144 PHY_SINGLE_CHANNEL_CENTERED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002145 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002146 } else {
2147 lim_ch_switch->ch_width =
2148 CH_WIDTH_40MHZ;
2149 lim_ch_switch->state =
2150 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2151 ch_params.ch_width = CH_WIDTH_40MHZ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002152 wlan_reg_set_channel_params(mac_ctx->pdev,
2153 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002154 lim_ch_switch->ch_center_freq_seg0 =
2155 ch_params.center_freq_seg0;
2156 lim_ch_switch->sec_ch_offset =
2157 ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002158 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002159
2160 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302161 pe_debug("new ch width: %d space: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302162 session_entry->gLimChannelSwitch.ch_width, chan_space);
Kiran Kumar Lokere75d636f2016-12-20 14:52:03 -08002163 if ((session_entry->currentOperChannel == csa_params->channel) &&
2164 (session_entry->ch_width ==
2165 session_entry->gLimChannelSwitch.ch_width)) {
2166 pe_debug("Ignore CSA, no change in ch and bw");
Pragaspathi Thilagaraj655db192018-06-19 17:41:37 +05302167 qdf_mem_free(csa_offload_ind);
Kiran Kumar Lokere75d636f2016-12-20 14:52:03 -08002168 goto err;
2169 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002170
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05302171 if (WLAN_REG_IS_24GHZ_CH(csa_params->channel) &&
2172 (session_entry->dot11mode == WNI_CFG_DOT11_MODE_11A))
2173 session_entry->dot11mode = WNI_CFG_DOT11_MODE_11G;
2174 else if (WLAN_REG_IS_5GHZ_CH(csa_params->channel) &&
2175 ((session_entry->dot11mode == WNI_CFG_DOT11_MODE_11G) ||
2176 (session_entry->dot11mode == WNI_CFG_DOT11_MODE_11G_ONLY)))
2177 session_entry->dot11mode = WNI_CFG_DOT11_MODE_11A;
2178
Vignesh Viswanathan3d478032018-08-02 20:18:53 +05302179 /* Send RSO Stop to FW before triggering the vdev restart for CSA */
2180 if (mac_ctx->lim.stop_roaming_callback)
2181 mac_ctx->lim.stop_roaming_callback(mac_ctx,
2182 session_entry->smeSessionId,
2183 ecsr_driver_disabled);
2184
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002185 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002186
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002187 csa_offload_ind->mesgType = eWNI_SME_CSA_OFFLOAD_EVENT;
2188 csa_offload_ind->mesgLen = sizeof(tSmeCsaOffloadInd);
2189 qdf_mem_copy(csa_offload_ind->bssid.bytes, session_entry->bssId,
2190 QDF_MAC_ADDR_SIZE);
2191 mmh_msg.type = eWNI_SME_CSA_OFFLOAD_EVENT;
2192 mmh_msg.bodyptr = csa_offload_ind;
2193 mmh_msg.bodyval = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302194 pe_debug("Sending eWNI_SME_CSA_OFFLOAD_EVENT to SME");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002195 MTRACE(mac_trace_msg_tx
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002196 (mac_ctx, session_entry->peSessionId, mmh_msg.type));
2197#ifdef FEATURE_WLAN_DIAG_SUPPORT
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002198 lim_diag_event_report(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002199 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002200 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002201#endif
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002202 lim_sys_process_mmh_msg_api(mac_ctx, &mmh_msg, ePROT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002203
2204err:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302205 qdf_mem_free(csa_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002206}
2207
2208/*--------------------------------------------------------------------------
2209 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
2210
2211 \param pMac - pointer to global adapter context
2212 \param sessionId - Message pointer.
2213
2214 \sa
2215 --------------------------------------------------------------------------*/
2216
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002217void lim_handle_delete_bss_rsp(tpAniSirGlobal pMac, struct scheduler_msg *MsgQ)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002218{
2219 tpPESession psessionEntry;
2220 tpDeleteBssParams pDelBss = (tpDeleteBssParams) (MsgQ->bodyptr);
2221
2222 psessionEntry =
2223 pe_find_session_by_session_id(pMac, pDelBss->sessionId);
2224 if (psessionEntry == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302225 pe_err("Session Does not exist for given sessionID: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002226 pDelBss->sessionId);
Naveen Rawat0c81edc2016-06-08 10:08:30 -07002227 qdf_mem_free(MsgQ->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002228 return;
2229 }
Krunal Sonie50ff452017-10-11 18:23:55 -07002230
2231 /*
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002232 * During DEL BSS handling, the PE Session will be deleted, but it is
2233 * better to clear this flag if the session is hanging around due
2234 * to some error conditions so that the next DEL_BSS request does
2235 * not take the HO_FAIL path
2236 */
2237 psessionEntry->process_ho_fail = false;
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002238 if (LIM_IS_IBSS_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002239 lim_ibss_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002240 else if (LIM_IS_UNKNOWN_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002241 lim_process_sme_del_bss_rsp(pMac, MsgQ->bodyval, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002242 else if (LIM_IS_NDI_ROLE(psessionEntry))
2243 lim_ndi_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002244 else
2245 lim_process_mlm_del_bss_rsp(pMac, MsgQ, psessionEntry);
2246
2247}
2248
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002249/** -----------------------------------------------------------------
2250 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
2251 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
2252 \ SME only looks at rc and tspec field.
2253 \param pMac - global mac structure
2254 \param rspReqd - is SmeAddTsRsp required
2255 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
2256 \return tspec
2257 \sa
2258 ----------------------------------------------------------------- */
2259void
2260lim_send_sme_aggr_qos_rsp(tpAniSirGlobal pMac, tpSirAggrQosRsp aggrQosRsp,
2261 uint8_t smesessionId)
2262{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002263 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002264
2265 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
2266 mmhMsg.bodyptr = aggrQosRsp;
2267 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302268 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2269 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002270 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2271
2272 return;
2273}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002274
2275void lim_send_sme_max_assoc_exceeded_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
2276 uint8_t smesessionId)
2277{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002278 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002279 tSmeMaxAssocInd *pSmeMaxAssocInd;
2280
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302281 pSmeMaxAssocInd = qdf_mem_malloc(sizeof(tSmeMaxAssocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002282 if (NULL == pSmeMaxAssocInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302283 pe_err("Failed to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002284 return;
2285 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302286 qdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peer_mac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302287 (uint8_t *) peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002288 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
2289 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
2290 pSmeMaxAssocInd->sessionId = smesessionId;
2291 mmhMsg.type = pSmeMaxAssocInd->mesgType;
2292 mmhMsg.bodyptr = pSmeMaxAssocInd;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302293 pe_debug("msgType: %s peerMacAddr "MAC_ADDRESS_STR "sme session id %d",
2294 "eWNI_SME_MAX_ASSOC_EXCEEDED", MAC_ADDR_ARRAY(peerMacAddr),
2295 pSmeMaxAssocInd->sessionId);
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302296 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2297 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002298 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2299
2300 return;
2301}
2302
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002303/** -----------------------------------------------------------------
2304 \brief lim_send_sme_ap_channel_switch_resp() - sends
2305 eWNI_SME_CHANNEL_CHANGE_RSP
2306 After receiving WMA_SWITCH_CHANNEL_RSP indication this
2307 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
2308 that the Channel change has been done to the specified target
2309 channel in the Channel change request
2310 \param pMac - global mac structure
2311 \param psessionEntry - session info
2312 \param pChnlParams - Channel switch params
2313 --------------------------------------------------------------------*/
2314void
2315lim_send_sme_ap_channel_switch_resp(tpAniSirGlobal pMac,
2316 tpPESession psessionEntry,
2317 tpSwitchChannelParams pChnlParams)
2318{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002319 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002320 tpSwitchChannelParams pSmeSwithChnlParams;
2321 uint8_t channelId;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002322 bool is_ch_dfs = false;
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08002323 enum phy_ch_width ch_width;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002324 uint8_t ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002325
2326 pSmeSwithChnlParams = (tSwitchChannelParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302327 qdf_mem_malloc(sizeof(tSwitchChannelParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002328 if (NULL == pSmeSwithChnlParams) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302329 pe_err("AllocateMemory failed for pSmeSwithChnlParams");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002330 return;
2331 }
2332
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302333 qdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002334 sizeof(tSwitchChannelParams));
2335
2336 channelId = pSmeSwithChnlParams->channelNumber;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002337 ch_width = pSmeSwithChnlParams->ch_width;
2338 ch_center_freq_seg1 = pSmeSwithChnlParams->ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002339
2340 /*
2341 * Pass the sme sessionID to SME instead
2342 * PE session ID.
2343 */
2344 pSmeSwithChnlParams->peSessionId = psessionEntry->smeSessionId;
2345
2346 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
2347 mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
2348 mmhMsg.bodyval = 0;
2349 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2350
2351 /*
2352 * We should start beacon transmission only if the new
2353 * channel after channel change is Non-DFS. For a DFS
2354 * channel, PE will receive an explicit request from
2355 * upper layers to start the beacon transmission .
2356 */
2357
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002358 if (ch_width == CH_WIDTH_160MHZ) {
2359 is_ch_dfs = true;
2360 } else if (ch_width == CH_WIDTH_80P80MHZ) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002361 if (wlan_reg_get_channel_state(pMac->pdev, channelId) ==
2362 CHANNEL_STATE_DFS ||
2363 wlan_reg_get_channel_state(pMac->pdev,
2364 ch_center_freq_seg1 -
2365 SIR_80MHZ_START_CENTER_CH_DIFF) ==
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002366 CHANNEL_STATE_DFS)
2367 is_ch_dfs = true;
2368 } else {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002369 if (wlan_reg_get_channel_state(pMac->pdev, channelId) ==
2370 CHANNEL_STATE_DFS)
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002371 is_ch_dfs = true;
2372 }
2373
2374 if (!is_ch_dfs) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002375 if (channelId == psessionEntry->currentOperChannel) {
2376 lim_apply_configuration(pMac, psessionEntry);
2377 lim_send_beacon_ind(pMac, psessionEntry);
2378 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302379 pe_debug("Failed to Transmit Beacons on channel: %d after AP channel change response",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002380 psessionEntry->bcnLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002381 }
Arif Hussain1513cb22018-01-05 19:56:31 -08002382
2383 lim_obss_send_detection_cfg(pMac, psessionEntry, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002384 }
2385 return;
2386}
2387
Peng Xu6363ec62017-05-15 11:06:33 -07002388#ifdef WLAN_FEATURE_11AX_BSS_COLOR
2389/**
2390 * lim_send_bss_color_change_ie_update() - update bss color change IE in
2391 * beacon template
2392 *
2393 * @mac_ctx: pointer to global adapter context
2394 * @session: session pointer
2395 *
2396 * Return: none
2397 */
2398static void
2399lim_send_bss_color_change_ie_update(tpAniSirGlobal mac_ctx,
2400 tpPESession session)
2401{
2402 /* Update the beacon template and send to FW */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002403 if (sch_set_fixed_beacon_fields(mac_ctx, session) != QDF_STATUS_SUCCESS) {
Peng Xu6363ec62017-05-15 11:06:33 -07002404 pe_err("Unable to set BSS color change IE in beacon");
2405 return;
2406 }
2407
2408 /* Send update beacon template message */
2409 lim_send_beacon_ind(mac_ctx, session);
Tushnim Bhattacharyya332b74c2018-08-10 10:55:51 -07002410 pe_debug("Updated BSS color change countdown = %d",
2411 session->he_bss_color_change.countdown);
Peng Xu6363ec62017-05-15 11:06:33 -07002412}
2413
2414static void
2415lim_handle_bss_color_change_ie(tpAniSirGlobal mac_ctx,
2416 tpPESession session)
2417{
Arif Hussain2f2d3512018-03-06 12:37:03 -08002418 tUpdateBeaconParams beacon_params;
2419
Peng Xu6363ec62017-05-15 11:06:33 -07002420 /* handle bss color change IE */
2421 if (LIM_IS_AP_ROLE(session) &&
2422 session->he_op.bss_col_disabled) {
2423 if (session->he_bss_color_change.countdown > 0) {
2424 session->he_bss_color_change.countdown--;
2425 } else {
2426 session->bss_color_changing = 0;
Arif Hussain2f2d3512018-03-06 12:37:03 -08002427 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
Arif Hussain05fb4872018-01-03 16:02:55 -08002428 if (session->he_bss_color_change.new_color != 0) {
Peng Xu6363ec62017-05-15 11:06:33 -07002429 session->he_op.bss_col_disabled = 0;
Arif Hussain05fb4872018-01-03 16:02:55 -08002430 session->he_op.bss_color =
2431 session->he_bss_color_change.new_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08002432 beacon_params.paramChangeBitmap |=
2433 PARAM_BSS_COLOR_CHANGED;
2434 beacon_params.bss_color_disabled = 0;
2435 beacon_params.bss_color =
2436 session->he_op.bss_color;
2437 lim_send_beacon_params(mac_ctx,
2438 &beacon_params,
2439 session);
Arif Hussain05fb4872018-01-03 16:02:55 -08002440 lim_send_obss_color_collision_cfg(mac_ctx,
2441 session,
2442 OBSS_COLOR_COLLISION_DETECTION);
2443 }
Peng Xu6363ec62017-05-15 11:06:33 -07002444 }
2445
2446 lim_send_bss_color_change_ie_update(mac_ctx, session);
2447 }
2448}
2449
2450#else
2451static void
2452lim_handle_bss_color_change_ie(tpAniSirGlobal mac_ctx,
2453 tpPESession session)
2454{
2455}
2456#endif
2457
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002458void
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302459lim_process_beacon_tx_success_ind(tpAniSirGlobal mac_ctx, uint16_t msgType,
2460 void *event)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002461{
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302462 tpPESession session;
2463 struct scheduler_msg msg = {0};
2464 struct sir_beacon_tx_complete_rsp *bcn_tx_comp_rsp;
2465 tpSirFirstBeaconTxCompleteInd bcn_ind =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002466 (tSirFirstBeaconTxCompleteInd *) event;
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302467 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002468
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302469 session = pe_find_session_by_bss_idx(mac_ctx, bcn_ind->bssIdx);
2470 if (!session) {
2471 pe_err("Session Does not exist for given session id");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002472 return;
2473 }
2474
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302475 pe_debug("role: %d swIe: %d opIe: %d switch cnt:%d",
2476 GET_LIM_SYSTEM_ROLE(session),
2477 session->dfsIncludeChanSwIe,
2478 session->gLimOperatingMode.present,
2479 session->gLimChannelSwitch.switchCount);
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302480
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302481 if (!LIM_IS_AP_ROLE(session))
2482 return;
Ganesh Kondabattini02ec62b2018-01-24 18:22:24 +05302483
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302484 if (session->dfsIncludeChanSwIe &&
2485 (session->gLimChannelSwitch.switchCount ==
2486 mac_ctx->sap.SapDfsInfo.sap_ch_switch_beacon_cnt))
2487 lim_process_ap_ecsa_timeout(session);
Ganesh Kondabattini02ec62b2018-01-24 18:22:24 +05302488
lifeng1c16b6b2017-09-25 13:59:55 +08002489
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302490 if (session->gLimOperatingMode.present) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002491 /* Done with nss update, send response back to SME */
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302492 session->gLimOperatingMode.present = 0;
2493 bcn_tx_comp_rsp = (struct sir_beacon_tx_complete_rsp *)
2494 qdf_mem_malloc(sizeof(*bcn_tx_comp_rsp));
2495 if (NULL == bcn_tx_comp_rsp) {
2496 pe_err("AllocateMemory failed for bcn_tx_comp_rsp");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002497 return;
2498 }
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302499 bcn_tx_comp_rsp->session_id = session->smeSessionId;
2500 bcn_tx_comp_rsp->tx_status = QDF_STATUS_SUCCESS;
2501 msg.type = eWNI_SME_NSS_UPDATE_RSP;
2502 msg.bodyptr = bcn_tx_comp_rsp;
2503 msg.bodyval = 0;
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05302504 status = scheduler_post_message(QDF_MODULE_ID_PE,
2505 QDF_MODULE_ID_SME,
2506 QDF_MODULE_ID_SME, &msg);
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302507 if (QDF_IS_STATUS_ERROR(status)) {
2508 sme_err("Failed to post eWNI_SME_NSS_UPDATE_RSP");
2509 qdf_mem_free(bcn_tx_comp_rsp);
2510 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002511 }
Peng Xu6363ec62017-05-15 11:06:33 -07002512
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05302513 lim_handle_bss_color_change_ie(mac_ctx, session);
Peng Xu6363ec62017-05-15 11:06:33 -07002514
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002515 return;
2516}