blob: 5b37358454b7794929e69c3c764c61d03d731633 [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 }
847 failure = true;
848 break;
849
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800850 case eLIM_HOST_DISASSOC:
851 /**
852 * Disassociation response due to
853 * host triggered disassociation
854 */
855
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530856 pSirSmeDisassocRsp = qdf_mem_malloc(sizeof(tSirSmeDisassocRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800857 if (NULL == pSirSmeDisassocRsp) {
858 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530859 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800860 failure = true;
861 goto error;
862 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530863 pe_debug("send eWNI_SME_DISASSOC_RSP with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800864 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
865 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
866 pSirSmeDisassocRsp->length = sizeof(tSirSmeDisassocRsp);
867 /* sessionId */
868 pBuf = (uint8_t *) &pSirSmeDisassocRsp->sessionId;
869 *pBuf = smesessionId;
870 pBuf++;
871
872 /* transactionId */
873 lim_copy_u16(pBuf, smetransactionId);
874 pBuf += sizeof(uint16_t);
875
876 /* statusCode */
877 lim_copy_u32(pBuf, reasonCode);
878 pBuf += sizeof(tSirResultCodes);
879
880 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530881 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800882 pBuf += sizeof(tSirMacAddr);
883
884 /* Clear Station Stats */
885 /* for sta, it is always 1, IBSS is handled at halInitSta */
886
887#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
888
889 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
890 psessionEntry, (uint16_t) reasonCode, 0);
891#endif
892 pMsg = (uint32_t *) pSirSmeDisassocRsp;
893 break;
894
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530895 case eLIM_PEER_ENTITY_DISASSOC:
896 case eLIM_LINK_MONITORING_DISASSOC:
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +0530897 status = lim_prepare_disconnect_done_ind(pMac, &pMsg,
898 smesessionId,
899 reasonCode, &peerMacAddr[0]);
900 if (!QDF_IS_STATUS_SUCCESS(status)) {
901 pe_err("Failed to prepare message");
902 return;
903 }
904 break;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530905
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800906 default:
907 /**
908 * Disassociation indication due to Disassociation
909 * frame reception from peer entity or due to
910 * loss of link with peer entity.
911 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530912 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800913 if (NULL == pSirSmeDisassocInd) {
914 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530915 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800916 failure = true;
917 goto error;
918 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530919 pe_debug("send eWNI_SME_DISASSOC_IND with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800920 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
921 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
922 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
923
924 /* Update SME session Id and Transaction Id */
925 pSirSmeDisassocInd->sessionId = smesessionId;
926 pSirSmeDisassocInd->transactionId = smetransactionId;
927 pSirSmeDisassocInd->reasonCode = reasonCode;
928 pBuf = (uint8_t *) &pSirSmeDisassocInd->statusCode;
929
930 lim_copy_u32(pBuf, reasonCode);
931 pBuf += sizeof(tSirResultCodes);
932
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530933 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800934 pBuf += sizeof(tSirMacAddr);
935
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530936 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800937
938#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
939 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
940 psessionEntry, (uint16_t) reasonCode, 0);
941#endif
942 pMsg = (uint32_t *) pSirSmeDisassocInd;
943
944 break;
945 }
946
947error:
948 /* Delete the PE session Created */
Rajeev Kumarcf835a02016-04-15 15:01:31 -0700949 if ((psessionEntry != NULL) && LIM_IS_STA_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800950 pe_delete_session(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800951
952 if (false == failure)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530953 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800954 (uint32_t *) pMsg);
955} /*** end lim_send_sme_disassoc_ntf() ***/
956
957/** -----------------------------------------------------------------
958 \brief lim_send_sme_disassoc_ind() - sends SME_DISASSOC_IND
959
960 After receiving disassociation frame from peer entity, this
961 function sends a eWNI_SME_DISASSOC_IND to SME with a specific
962 reason code.
963
964 \param pMac - global mac structure
965 \param pStaDs - station dph hash node
966 \return none
967 \sa
968 ----------------------------------------------------------------- */
969void
970lim_send_sme_disassoc_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
971 tpPESession psessionEntry)
972{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700973 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800974 tSirSmeDisassocInd *pSirSmeDisassocInd;
975
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530976 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800977 if (NULL == pSirSmeDisassocInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530978 pe_err("AllocateMemory failed for eWNI_SME_DISASSOC_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800979 return;
980 }
981
982 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
983 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
984
985 pSirSmeDisassocInd->sessionId = psessionEntry->smeSessionId;
986 pSirSmeDisassocInd->transactionId = psessionEntry->transactionId;
Padma, Santhosh Kumar02289212016-09-30 13:30:08 +0530987 pSirSmeDisassocInd->statusCode = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800988 pSirSmeDisassocInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
989
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530990 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530991 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800992
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530993 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +0530994 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800995
996 pSirSmeDisassocInd->staId = pStaDs->staIndex;
997
998 mmhMsg.type = eWNI_SME_DISASSOC_IND;
999 mmhMsg.bodyptr = pSirSmeDisassocInd;
1000 mmhMsg.bodyval = 0;
1001
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301002 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1003 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001004#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1005 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT, psessionEntry,
1006 0, (uint16_t) pStaDs->mlmStaContext.disassocReason);
1007#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1008
1009 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1010
1011} /*** end lim_send_sme_disassoc_ind() ***/
1012
1013/** -----------------------------------------------------------------
1014 \brief lim_send_sme_deauth_ind() - sends SME_DEAUTH_IND
1015
1016 After receiving deauthentication frame from peer entity, this
1017 function sends a eWNI_SME_DEAUTH_IND to SME with a specific
1018 reason code.
1019
1020 \param pMac - global mac structure
1021 \param pStaDs - station dph hash node
1022 \return none
1023 \sa
1024 ----------------------------------------------------------------- */
1025void
1026lim_send_sme_deauth_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1027 tpPESession psessionEntry)
1028{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001029 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001030 tSirSmeDeauthInd *pSirSmeDeauthInd;
1031
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301032 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001033 if (NULL == pSirSmeDeauthInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301034 pe_err("AllocateMemory failed for eWNI_SME_DEAUTH_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001035 return;
1036 }
1037
1038 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1039 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1040
1041 pSirSmeDeauthInd->sessionId = psessionEntry->smeSessionId;
1042 pSirSmeDeauthInd->transactionId = psessionEntry->transactionId;
1043 if (eSIR_INFRA_AP_MODE == psessionEntry->bssType) {
1044 pSirSmeDeauthInd->statusCode =
1045 (tSirResultCodes) pStaDs->mlmStaContext.cleanupTrigger;
1046 } else {
1047 /* Need to indicatet he reascon code over the air */
1048 pSirSmeDeauthInd->statusCode =
1049 (tSirResultCodes) pStaDs->mlmStaContext.disassocReason;
1050 }
1051 /* BSSID */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301052 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301053 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001054 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301055 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301056 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001057 pSirSmeDeauthInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1058
1059 pSirSmeDeauthInd->staId = pStaDs->staIndex;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001060 if (eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON ==
1061 pStaDs->mlmStaContext.disassocReason)
1062 pSirSmeDeauthInd->rssi = pStaDs->del_sta_ctx_rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001063
1064 mmhMsg.type = eWNI_SME_DEAUTH_IND;
1065 mmhMsg.bodyptr = pSirSmeDeauthInd;
1066 mmhMsg.bodyval = 0;
1067
1068 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1069#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1070 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT, psessionEntry,
1071 0, pStaDs->mlmStaContext.cleanupTrigger);
1072#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1073
1074 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1075 return;
1076} /*** end lim_send_sme_deauth_ind() ***/
1077
1078#ifdef FEATURE_WLAN_TDLS
1079/**
1080 * lim_send_sme_tdls_del_sta_ind()
1081 *
1082 ***FUNCTION:
1083 * This function is called to send the TDLS STA context deletion to SME.
1084 *
1085 ***LOGIC:
1086 *
1087 ***ASSUMPTIONS:
1088 *
1089 ***NOTE:
1090 * NA
1091 *
1092 * @param pMac - Pointer to global MAC structure
1093 * @param pStaDs - Pointer to internal STA Datastructure
1094 * @param psessionEntry - Pointer to the session entry
1095 * @param reasonCode - Reason for TDLS sta deletion
1096 * @return None
1097 */
1098void
1099lim_send_sme_tdls_del_sta_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1100 tpPESession psessionEntry, uint16_t reasonCode)
1101{
Frank Liud1a28462017-09-06 22:55:48 +08001102 struct tdls_event_info info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001103
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301104 pe_debug("Delete TDLS Peer "MAC_ADDRESS_STR "with reason code: %d",
Nitesh Shah82c52812016-12-27 12:27:51 +05301105 MAC_ADDR_ARRAY(pStaDs->staAddr), reasonCode);
Frank Liud1a28462017-09-06 22:55:48 +08001106 info.vdev_id = psessionEntry->smeSessionId;
1107 qdf_mem_copy(info.peermac.bytes, pStaDs->staAddr, QDF_MAC_ADDR_SIZE);
1108 info.message_type = TDLS_PEER_DISCONNECTED;
1109 info.peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001110
Frank Liud1a28462017-09-06 22:55:48 +08001111 tgt_tdls_event_handler(pMac->psoc, &info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001112
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001113 return;
1114} /*** end lim_send_sme_tdls_del_sta_ind() ***/
1115
1116/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001117 * lim_send_sme_mgmt_tx_completion()
1118 *
1119 ***FUNCTION:
1120 * This function is called to send the eWNI_SME_MGMT_FRM_TX_COMPLETION_IND
1121 * message to SME.
1122 *
1123 ***LOGIC:
1124 *
1125 ***ASSUMPTIONS:
1126 *
1127 ***NOTE:
1128 * NA
1129 *
1130 * @param pMac - Pointer to global MAC structure
1131 * @param psessionEntry - Pointer to the session entry
1132 * @param txCompleteStatus - TX Complete Status of Mgmt Frames
1133 * @return None
1134 */
1135void
1136lim_send_sme_mgmt_tx_completion(tpAniSirGlobal pMac,
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301137 uint32_t sme_session_id,
1138 uint32_t txCompleteStatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001139{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001140 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001141 tSirMgmtTxCompletionInd *pSirMgmtTxCompletionInd;
1142
1143 pSirMgmtTxCompletionInd =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301144 qdf_mem_malloc(sizeof(tSirMgmtTxCompletionInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001145 if (NULL == pSirMgmtTxCompletionInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301146 pe_err("AllocateMemory failed for eWNI_SME_MGMT_FRM_TX_COMPLETION_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001147 return;
1148 }
1149 /* messageType */
1150 pSirMgmtTxCompletionInd->messageType =
1151 eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1152 pSirMgmtTxCompletionInd->length = sizeof(tSirMgmtTxCompletionInd);
1153
1154 /* sessionId */
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301155 pSirMgmtTxCompletionInd->sessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001156
1157 pSirMgmtTxCompletionInd->txCompleteStatus = txCompleteStatus;
1158
1159 mmhMsg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1160 mmhMsg.bodyptr = pSirMgmtTxCompletionInd;
1161 mmhMsg.bodyval = 0;
1162
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07001163 pSirMgmtTxCompletionInd->psoc = pMac->psoc;
1164 mmhMsg.callback = tgt_tdls_send_mgmt_tx_completion;
1165 scheduler_post_msg(QDF_MODULE_ID_TARGET_IF, &mmhMsg);
1166 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001167} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1168
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001169#endif /* FEATURE_WLAN_TDLS */
1170
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301171QDF_STATUS lim_prepare_disconnect_done_ind(tpAniSirGlobal mac_ctx,
1172 uint32_t **msg,
1173 uint8_t session_id,
1174 tSirResultCodes reason_code,
1175 uint8_t *peer_mac_addr)
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301176{
1177 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301178
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301179 sir_sme_dis_ind = qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301180 if (!sir_sme_dis_ind) {
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301181 pe_err("Failed to allocate memory");
1182 return QDF_STATUS_E_FAILURE;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301183 }
1184
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301185 pe_debug("Prepare eWNI_SME_DISCONNECT_DONE_IND withretCode: %d",
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301186 reason_code);
1187
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301188 sir_sme_dis_ind->message_type = eWNI_SME_DISCONNECT_DONE_IND;
1189 sir_sme_dis_ind->length = sizeof(*sir_sme_dis_ind);
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301190 sir_sme_dis_ind->session_id = session_id;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301191 if (peer_mac_addr)
Vignesh Viswanathanb2dcdd02018-05-24 11:48:12 +05301192 qdf_mem_copy(sir_sme_dis_ind->peer_mac,
1193 peer_mac_addr, ETH_ALEN);
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301194
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301195 /*
1196 * Instead of sending deauth reason code as 505 which is
1197 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1198 * Send reason code as zero to Supplicant
1199 */
1200 if (reason_code == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1201 sir_sme_dis_ind->reason_code = 0;
1202 else
1203 sir_sme_dis_ind->reason_code = reason_code;
1204
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301205 *msg = (uint32_t *)sir_sme_dis_ind;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301206
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301207 return QDF_STATUS_SUCCESS;
Himanshu Agarwald519b4a2018-03-27 15:36:09 +05301208}
1209
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001210/**
1211 * lim_send_sme_deauth_ntf()
1212 *
1213 ***FUNCTION:
1214 * This function is called by limProcessSmeMessages() to send
1215 * eWNI_SME_DISASSOC_RSP/IND message to host
1216 *
1217 ***PARAMS:
1218 *
1219 ***LOGIC:
1220 *
1221 ***ASSUMPTIONS:
1222 * NA
1223 *
1224 ***NOTE:
1225 * This function is used for sending eWNI_SME_DEAUTH_CNF or
1226 * eWNI_SME_DEAUTH_IND to host depending on deauthentication trigger.
1227 *
1228 * @param peerMacAddr Indicates the peer MAC addr to which
1229 * deauthentication was initiated
1230 * @param reasonCode Indicates the reason for Deauthetication
1231 * @param deauthTrigger Indicates the trigger for Deauthetication
1232 * @param aid Indicates the STAID. This parameter is present
1233 * only on AP.
1234 *
1235 * @return None
1236 */
1237void
1238lim_send_sme_deauth_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
1239 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1240 uint16_t aid, uint8_t smesessionId,
1241 uint16_t smetransactionId)
1242{
1243 uint8_t *pBuf;
1244 tSirSmeDeauthRsp *pSirSmeDeauthRsp;
1245 tSirSmeDeauthInd *pSirSmeDeauthInd;
1246 tpPESession psessionEntry;
1247 uint8_t sessionId;
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301248 uint32_t *pMsg = NULL;
1249 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001250
1251 psessionEntry = pe_find_session_by_bssid(pMac, peerMacAddr, &sessionId);
1252 switch (deauthTrigger) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001253 case eLIM_HOST_DEAUTH:
1254 /**
1255 * Deauthentication response to host triggered
1256 * deauthentication.
1257 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301258 pSirSmeDeauthRsp = qdf_mem_malloc(sizeof(tSirSmeDeauthRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001259 if (NULL == pSirSmeDeauthRsp) {
1260 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301261 pe_err("call to AllocateMemory failed for eWNI_SME_DEAUTH_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001262 return;
1263 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301264 pe_debug("send eWNI_SME_DEAUTH_RSP with retCode: %d for" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001265 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1266 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
1267 pSirSmeDeauthRsp->length = sizeof(tSirSmeDeauthRsp);
1268 pSirSmeDeauthRsp->statusCode = reasonCode;
1269 pSirSmeDeauthRsp->sessionId = smesessionId;
1270 pSirSmeDeauthRsp->transactionId = smetransactionId;
1271
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -08001272 pBuf = (uint8_t *) pSirSmeDeauthRsp->peer_macaddr.bytes;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301273 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001274
1275#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1276 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
1277 psessionEntry, 0, (uint16_t) reasonCode);
1278#endif
1279 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1280
1281 break;
1282
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301283 case eLIM_PEER_ENTITY_DEAUTH:
1284 case eLIM_LINK_MONITORING_DEAUTH:
Vignesh Viswanathan5b909f52018-05-15 20:13:35 +05301285 status = lim_prepare_disconnect_done_ind(pMac, &pMsg,
1286 smesessionId, reasonCode,
1287 &peerMacAddr[0]);
1288 if (!QDF_IS_STATUS_SUCCESS(status)) {
1289 pe_err("Failed to prepare message");
1290 return;
1291 }
1292 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001293 default:
1294 /**
1295 * Deauthentication indication due to Deauthentication
1296 * frame reception from peer entity or due to
1297 * loss of link with peer entity.
1298 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301299 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001300 if (NULL == pSirSmeDeauthInd) {
1301 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301302 pe_err("call to AllocateMemory failed for eWNI_SME_DEAUTH_Ind");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001303 return;
1304 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301305 pe_debug("send eWNI_SME_DEAUTH_IND with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001306 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1307 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1308 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1309 pSirSmeDeauthInd->reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
1310
1311 /* sessionId */
1312 pBuf = (uint8_t *) &pSirSmeDeauthInd->sessionId;
1313 *pBuf++ = smesessionId;
1314
1315 /* transaction ID */
1316 lim_copy_u16(pBuf, smetransactionId);
1317 pBuf += sizeof(uint16_t);
1318
1319 /* status code */
1320 lim_copy_u32(pBuf, reasonCode);
1321 pBuf += sizeof(tSirResultCodes);
1322
1323 /* bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301324 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325 pBuf += sizeof(tSirMacAddr);
1326
1327 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301328 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301329 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001330
1331#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1332 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
1333 psessionEntry, 0, (uint16_t) reasonCode);
1334#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1335 pMsg = (uint32_t *) pSirSmeDeauthInd;
1336
1337 break;
1338 }
1339
1340 /*Delete the PE session created */
1341 if (psessionEntry != NULL) {
1342 pe_delete_session(pMac, psessionEntry);
1343 }
1344
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301345 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001346 (uint32_t *) pMsg);
1347
1348} /*** end lim_send_sme_deauth_ntf() ***/
1349
1350/**
1351 * lim_send_sme_wm_status_change_ntf() - Send Notification
1352 * @mac_ctx: Global MAC Context
1353 * @status_change_code: Indicates the change in the wireless medium.
1354 * @status_change_info: Indicates the information associated with
1355 * change in the wireless medium.
1356 * @info_len: Indicates the length of status change information
1357 * being sent.
1358 * @session_id SessionID
1359 *
1360 * This function is called by limProcessSmeMessages() to send
1361 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1362 *
1363 * Return: None
1364 */
1365void
1366lim_send_sme_wm_status_change_ntf(tpAniSirGlobal mac_ctx,
1367 tSirSmeStatusChangeCode status_change_code,
1368 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1369{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001370 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001371 tSirSmeWmStatusChangeNtf *wm_status_change_ntf;
Naveen Rawate01ed172016-11-17 11:34:50 -08001372 uint32_t max_info_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001373
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301374 wm_status_change_ntf = qdf_mem_malloc(sizeof(tSirSmeWmStatusChangeNtf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001375 if (NULL == wm_status_change_ntf) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301376 pe_err("Mem Alloc failed - eWNI_SME_WM_STATUS_CHANGE_NTF");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001377 return;
1378 }
1379
1380 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1381 msg.bodyval = 0;
1382 msg.bodyptr = wm_status_change_ntf;
1383
1384 switch (status_change_code) {
Naveen Rawate01ed172016-11-17 11:34:50 -08001385 case eSIR_SME_AP_CAPS_CHANGED:
1386 max_info_len = sizeof(tSirSmeApNewCaps);
1387 break;
1388 case eSIR_SME_JOINED_NEW_BSS:
1389 max_info_len = sizeof(tSirSmeNewBssInfo);
1390 break;
1391 default:
1392 max_info_len = sizeof(wm_status_change_ntf->statusChangeInfo);
1393 break;
1394 }
1395
1396 switch (status_change_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001397 case eSIR_SME_RADAR_DETECTED:
1398 break;
1399 default:
1400 wm_status_change_ntf->messageType =
1401 eWNI_SME_WM_STATUS_CHANGE_NTF;
1402 wm_status_change_ntf->statusChangeCode = status_change_code;
1403 wm_status_change_ntf->length = sizeof(tSirSmeWmStatusChangeNtf);
1404 wm_status_change_ntf->sessionId = session_id;
Naveen Rawate01ed172016-11-17 11:34:50 -08001405 if (info_len <= max_info_len && status_change_info) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301406 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001407 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1408 (uint8_t *) status_change_info, info_len);
1409 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301410 pe_debug("StatusChg code: 0x%x length: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001411 status_change_code, info_len);
1412 break;
1413 }
1414
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301415 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, session_id, msg.type));
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001416 if (QDF_STATUS_SUCCESS != lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301417 qdf_mem_free(wm_status_change_ntf);
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301418 pe_err("lim_sys_process_mmh_msg_api failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001419 }
1420
1421} /*** end lim_send_sme_wm_status_change_ntf() ***/
1422
1423/**
1424 * lim_send_sme_set_context_rsp()
1425 *
1426 ***FUNCTION:
1427 * This function is called by limProcessSmeMessages() to send
1428 * eWNI_SME_SETCONTEXT_RSP message to host
1429 *
1430 ***PARAMS:
1431 *
1432 ***LOGIC:
1433 *
1434 ***ASSUMPTIONS:
1435 * NA
1436 *
1437 ***NOTE:
1438 *
1439 * @param pMac Pointer to Global MAC structure
1440 * @param peerMacAddr Indicates the peer MAC addr to which
1441 * setContext was performed
1442 * @param aid Indicates the aid corresponding to the peer MAC
1443 * address
1444 * @param resultCode Indicates the result of previously issued
1445 * eWNI_SME_SETCONTEXT_RSP message
1446 *
1447 * @return None
1448 */
1449void
1450lim_send_sme_set_context_rsp(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301451 struct qdf_mac_addr peer_macaddr, uint16_t aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001452 tSirResultCodes resultCode,
1453 tpPESession psessionEntry, uint8_t smesessionId,
1454 uint16_t smetransactionId)
1455{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001456 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001457 tSirSmeSetContextRsp *pSirSmeSetContextRsp;
1458
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301459 pSirSmeSetContextRsp = qdf_mem_malloc(sizeof(tSirSmeSetContextRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001460 if (NULL == pSirSmeSetContextRsp) {
1461 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301462 pe_err("call to AllocateMemory failed for SmeSetContextRsp");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001463 return;
1464 }
1465
1466 pSirSmeSetContextRsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1467 pSirSmeSetContextRsp->length = sizeof(tSirSmeSetContextRsp);
1468 pSirSmeSetContextRsp->statusCode = resultCode;
1469
Anurag Chouhanc5548422016-02-24 18:33:27 +05301470 qdf_copy_macaddr(&pSirSmeSetContextRsp->peer_macaddr, &peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001471
1472 /* Update SME session and transaction Id */
1473 pSirSmeSetContextRsp->sessionId = smesessionId;
1474 pSirSmeSetContextRsp->transactionId = smetransactionId;
1475
1476 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
1477 mmhMsg.bodyptr = pSirSmeSetContextRsp;
1478 mmhMsg.bodyval = 0;
1479 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301480 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1481 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001482 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301483 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1484 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001485 }
1486
1487#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1488 lim_diag_event_report(pMac, WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
1489 psessionEntry, (uint16_t) resultCode, 0);
1490#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1491
Himanshu Agarwal2785d242018-05-09 12:39:52 +05301492 pMac->lim.sme_msg_callback(pMac, &mmhMsg);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001493} /*** end lim_send_sme_set_context_rsp() ***/
1494
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001495/** -----------------------------------------------------------------
1496 \brief lim_send_sme_addts_rsp() - sends SME ADDTS RSP
1497 \ This function sends a eWNI_SME_ADDTS_RSP to SME.
1498 \ SME only looks at rc and tspec field.
1499 \param pMac - global mac structure
1500 \param rspReqd - is SmeAddTsRsp required
1501 \param status - status code of SME_ADD_TS_RSP
1502 \return tspec
1503 \sa
1504 ----------------------------------------------------------------- */
1505void
1506lim_send_sme_addts_rsp(tpAniSirGlobal pMac, uint8_t rspReqd, uint32_t status,
1507 tpPESession psessionEntry, tSirMacTspecIE tspec,
1508 uint8_t smesessionId, uint16_t smetransactionId)
1509{
1510 tpSirAddtsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001511 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001512
1513 if (!rspReqd)
1514 return;
1515
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301516 rsp = qdf_mem_malloc(sizeof(tSirAddtsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001517 if (NULL == rsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301518 pe_err("AllocateMemory failed for ADDTS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001519 return;
1520 }
1521
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001522 rsp->messageType = eWNI_SME_ADDTS_RSP;
1523 rsp->rc = status;
1524 rsp->rsp.status = (enum eSirMacStatusCodes)status;
1525 rsp->rsp.tspec = tspec;
1526 /* Update SME session Id and transcation Id */
1527 rsp->sessionId = smesessionId;
1528 rsp->transactionId = smetransactionId;
1529
1530 mmhMsg.type = eWNI_SME_ADDTS_RSP;
1531 mmhMsg.bodyptr = rsp;
1532 mmhMsg.bodyval = 0;
1533 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301534 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1535 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001536 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301537 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1538 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001539 }
1540#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1541 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_RSP_EVENT, psessionEntry, 0,
1542 0);
1543#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1544
1545 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1546 return;
1547}
1548
1549void
1550lim_send_sme_delts_rsp(tpAniSirGlobal pMac, tpSirDeltsReq delts, uint32_t status,
1551 tpPESession psessionEntry, uint8_t smesessionId,
1552 uint16_t smetransactionId)
1553{
1554 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001555 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001556
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301557 pe_debug("SendSmeDeltsRsp aid: %d tsid: %d up: %d status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001558 delts->aid,
1559 delts->req.tsinfo.traffic.tsid,
1560 delts->req.tsinfo.traffic.userPrio, status);
1561 if (!delts->rspReqd)
1562 return;
1563
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301564 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001565 if (NULL == rsp) {
1566 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301567 pe_err("AllocateMemory failed for DELTS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001568 return;
1569 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001570
1571 if (psessionEntry != NULL) {
1572
1573 rsp->aid = delts->aid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301574 qdf_copy_macaddr(&rsp->macaddr, &delts->macaddr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301575 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) &delts->req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001576 sizeof(tSirDeltsReqInfo));
1577 }
1578
1579 rsp->messageType = eWNI_SME_DELTS_RSP;
1580 rsp->rc = status;
1581
1582 /* Update SME session Id and transcation Id */
1583 rsp->sessionId = smesessionId;
1584 rsp->transactionId = smetransactionId;
1585
1586 mmhMsg.type = eWNI_SME_DELTS_RSP;
1587 mmhMsg.bodyptr = rsp;
1588 mmhMsg.bodyval = 0;
1589 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301590 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1591 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001592 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301593 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1594 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001595 }
1596#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1597 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_RSP_EVENT, psessionEntry,
1598 (uint16_t) status, 0);
1599#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1600
1601 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1602}
1603
1604void
1605lim_send_sme_delts_ind(tpAniSirGlobal pMac, tpSirDeltsReqInfo delts, uint16_t aid,
1606 tpPESession psessionEntry)
1607{
1608 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001609 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001610
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301611 pe_debug("SendSmeDeltsInd aid: %d tsid: %d up: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001612 aid, delts->tsinfo.traffic.tsid, delts->tsinfo.traffic.userPrio);
1613
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301614 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001615 if (NULL == rsp) {
1616 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301617 pe_err("AllocateMemory failed for DELTS_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001618 return;
1619 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001620
1621 rsp->messageType = eWNI_SME_DELTS_IND;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001622 rsp->rc = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001623 rsp->aid = aid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301624 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) delts, sizeof(*delts));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001625
1626 /* Update SME session Id and SME transaction Id */
1627
1628 rsp->sessionId = psessionEntry->smeSessionId;
1629 rsp->transactionId = psessionEntry->transactionId;
1630
1631 mmhMsg.type = eWNI_SME_DELTS_IND;
1632 mmhMsg.bodyptr = rsp;
1633 mmhMsg.bodyval = 0;
1634 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1635#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1636 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_IND_EVENT, psessionEntry, 0,
1637 0);
1638#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1639
1640 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1641}
1642
Naveen Rawatfa2a1002018-05-17 16:06:37 -07001643#ifndef QCA_SUPPORT_CP_STATS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001644/**
1645 * lim_send_sme_pe_statistics_rsp()
1646 *
1647 ***FUNCTION:
1648 * This function is called to send 802.11 statistics response to HDD.
1649 * This function posts the result back to HDD. This is a response to
1650 * HDD's request for statistics.
1651 *
1652 ***PARAMS:
1653 *
1654 ***LOGIC:
1655 *
1656 ***ASSUMPTIONS:
1657 * NA
1658 *
1659 ***NOTE:
1660 * NA
1661 *
1662 * @param pMac Pointer to Global MAC structure
1663 * @param p80211Stats Statistics sent in response
1664 * @param resultCode TODO:
1665 *
1666 *
1667 * @return none
1668 */
1669
1670void
1671lim_send_sme_pe_statistics_rsp(tpAniSirGlobal pMac, uint16_t msgType, void *stats)
1672{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001673 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001674 uint8_t sessionId;
1675 tAniGetPEStatsRsp *pPeStats = (tAniGetPEStatsRsp *) stats;
1676 tpPESession pPeSessionEntry;
1677
1678 /* Get the Session Id based on Sta Id */
1679 pPeSessionEntry =
1680 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1681
1682 /* Fill the Session Id */
1683 if (NULL != pPeSessionEntry) {
1684 /* Fill the Session Id */
1685 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1686 }
1687
1688 pPeStats->msgType = eWNI_SME_GET_STATISTICS_RSP;
1689
1690 /* msgType should be WMA_GET_STATISTICS_RSP */
1691 mmhMsg.type = eWNI_SME_GET_STATISTICS_RSP;
1692
1693 mmhMsg.bodyptr = stats;
1694 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301695 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001696 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1697
1698 return;
1699
1700} /*** end lim_send_sme_pe_statistics_rsp() ***/
Naveen Rawatfa2a1002018-05-17 16:06:37 -07001701#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001702
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001703#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001704/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001705 * lim_send_sme_pe_ese_tsm_rsp() - send tsm response
1706 * @pMac: Pointer to global pMac structure
1707 * @pStats: Pointer to TSM Stats
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001708 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001709 * This function is called to send tsm stats response to HDD.
1710 * This function posts the result back to HDD. This is a response to
1711 * HDD's request to get tsm stats.
1712 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001713 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001714 */
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001715void lim_send_sme_pe_ese_tsm_rsp(tpAniSirGlobal pMac,
1716 tAniGetTsmStatsRsp *pStats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001717{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001718 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001719 uint8_t sessionId;
1720 tAniGetTsmStatsRsp *pPeStats = (tAniGetTsmStatsRsp *) pStats;
1721 tpPESession pPeSessionEntry = NULL;
1722
1723 /* Get the Session Id based on Sta Id */
1724 pPeSessionEntry =
1725 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1726
1727 /* Fill the Session Id */
1728 if (NULL != pPeSessionEntry) {
1729 /* Fill the Session Id */
1730 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1731 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301732 pe_err("Session not found for the Sta id: %d",
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301733 pPeStats->staId);
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05301734 qdf_mem_free(pPeStats->tsmStatsReq);
1735 qdf_mem_free(pPeStats);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001736 return;
1737 }
1738
1739 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
1740 pPeStats->tsmMetrics.RoamingCount
1741 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
1742 pPeStats->tsmMetrics.RoamingDly
1743 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
1744
1745 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
1746 mmhMsg.bodyptr = pStats;
1747 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301748 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001749 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1750
1751 return;
1752} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
1753
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001754#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001755
1756void
1757lim_send_sme_ibss_peer_ind(tpAniSirGlobal pMac,
1758 tSirMacAddr peerMacAddr,
1759 uint16_t staIndex,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001760 uint8_t *beacon,
1761 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
1762{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001763 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001764 tSmeIbssPeerInd *pNewPeerInd;
1765
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301766 pNewPeerInd = qdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001767 if (NULL == pNewPeerInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301768 pe_err("Failed to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001769 return;
1770 }
1771
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301772 qdf_mem_copy((uint8_t *) pNewPeerInd->peer_addr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301773 peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001774 pNewPeerInd->staId = staIndex;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001775 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
1776 pNewPeerInd->mesgType = msgType;
1777 pNewPeerInd->sessionId = sessionId;
1778
1779 if (beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301780 qdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001781 sizeof(tSmeIbssPeerInd)), (void *)beacon,
1782 beaconLen);
1783 }
1784
1785 mmhMsg.type = msgType;
1786 mmhMsg.bodyptr = pNewPeerInd;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301787 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001788 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1789
1790}
1791
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07001792/**
1793 * lim_process_csa_wbw_ie() - Process CSA Wide BW IE
1794 * @mac_ctx: pointer to global adapter context
1795 * @csa_params: pointer to CSA parameters
1796 * @chnl_switch_info:pointer to channel switch parameters
1797 * @session_entry: session pointer
1798 *
1799 * Return: None
1800 */
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001801static QDF_STATUS lim_process_csa_wbw_ie(tpAniSirGlobal mac_ctx,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001802 struct csa_offload_params *csa_params,
1803 tLimWiderBWChannelSwitchInfo *chnl_switch_info,
1804 tpPESession session_entry)
1805{
Amar Singhal5cccafe2017-02-15 12:42:58 -08001806 struct ch_params ch_params = {0};
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001807 uint8_t ap_new_ch_width;
1808 bool new_ch_width_dfn = false;
1809 uint8_t center_freq_diff;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001810 uint32_t fw_vht_ch_wd = wma_get_vht_ch_width() + 1;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001811
1812 ap_new_ch_width = csa_params->new_ch_width + 1;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001813
1814 pe_info("new channel: %d new_ch_width: %d seg0: %d seg1: %d",
1815 csa_params->channel, ap_new_ch_width,
1816 csa_params->new_ch_freq_seg1,
1817 csa_params->new_ch_freq_seg2);
1818
1819 if ((ap_new_ch_width != CH_WIDTH_80MHZ) &&
1820 (ap_new_ch_width != CH_WIDTH_160MHZ) &&
1821 (ap_new_ch_width != CH_WIDTH_80P80MHZ)) {
1822 pe_err("CSA wide BW IE has wrong ch_width %d",
1823 csa_params->new_ch_width);
1824 return QDF_STATUS_E_INVAL;
1825 }
1826
1827 if (!csa_params->new_ch_freq_seg1 && !csa_params->new_ch_freq_seg2) {
1828 pe_err("CSA wide BW IE has invalid center freq");
1829 return QDF_STATUS_E_INVAL;
1830 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001831 if ((ap_new_ch_width == CH_WIDTH_80MHZ) &&
1832 csa_params->new_ch_freq_seg2) {
1833 new_ch_width_dfn = true;
1834 if (csa_params->new_ch_freq_seg2 >
1835 csa_params->new_ch_freq_seg1)
1836 center_freq_diff = csa_params->new_ch_freq_seg2 -
1837 csa_params->new_ch_freq_seg1;
1838 else
1839 center_freq_diff = csa_params->new_ch_freq_seg1 -
1840 csa_params->new_ch_freq_seg2;
1841 if (center_freq_diff == CENTER_FREQ_DIFF_160MHz)
1842 ap_new_ch_width = CH_WIDTH_160MHZ;
1843 else if (center_freq_diff > CENTER_FREQ_DIFF_80P80MHz)
1844 ap_new_ch_width = CH_WIDTH_80P80MHZ;
1845 else
1846 ap_new_ch_width = CH_WIDTH_80MHZ;
1847 }
1848 session_entry->gLimChannelSwitch.state =
1849 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
1850 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
1851 !new_ch_width_dfn) {
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001852 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1853 CH_TO_CNTR_FREQ_DIFF_160MHz) {
1854 pe_err("CSA wide BW IE has invalid center freq");
1855 return QDF_STATUS_E_INVAL;
1856 }
1857
1858 if (ap_new_ch_width > fw_vht_ch_wd) {
1859 pe_info("New BW is not supported, setting BW to %d",
1860 fw_vht_ch_wd);
1861 ap_new_ch_width = fw_vht_ch_wd;
1862 }
1863 ch_params.ch_width = ap_new_ch_width ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07001864 wlan_reg_set_channel_params(mac_ctx->pdev,
1865 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001866 ap_new_ch_width = ch_params.ch_width;
1867 csa_params->new_ch_freq_seg1 = ch_params.center_freq_seg0;
1868 csa_params->new_ch_freq_seg2 = ch_params.center_freq_seg1;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001869 } else if (!new_ch_width_dfn) {
1870 if (ap_new_ch_width > fw_vht_ch_wd) {
1871 pe_info("New BW is not supported, setting BW to %d",
1872 fw_vht_ch_wd);
1873 ap_new_ch_width = fw_vht_ch_wd;
1874 }
1875 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1876 CH_TO_CNTR_FREQ_DIFF_80MHz) {
1877 pe_err("CSA wide BW IE has invalid center freq");
1878 return QDF_STATUS_E_INVAL;
1879 }
1880 csa_params->new_ch_freq_seg2 = 0;
1881 }
1882 if (new_ch_width_dfn) {
1883 if (csa_params->new_ch_freq_seg1 != csa_params->channel +
1884 CH_TO_CNTR_FREQ_DIFF_80MHz) {
1885 pe_err("CSA wide BW IE has invalid center freq");
1886 return QDF_STATUS_E_INVAL;
1887 }
1888 if (ap_new_ch_width > fw_vht_ch_wd) {
1889 pe_info("New width is not supported, setting BW to %d",
1890 fw_vht_ch_wd);
1891 ap_new_ch_width = fw_vht_ch_wd;
1892 }
1893 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
1894 (csa_params->new_ch_freq_seg1 !=
1895 csa_params->channel +
1896 CH_TO_CNTR_FREQ_DIFF_160MHz)) {
1897 pe_err("wide BW IE has invalid 160M center freq");
1898 csa_params->new_ch_freq_seg2 = 0;
1899 ap_new_ch_width = CH_WIDTH_80MHZ;
1900 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001901 }
1902 chnl_switch_info->newChanWidth = ap_new_ch_width;
1903 chnl_switch_info->newCenterChanFreq0 = csa_params->new_ch_freq_seg1;
1904 chnl_switch_info->newCenterChanFreq1 = csa_params->new_ch_freq_seg2;
1905
1906 if (session_entry->ch_width == ap_new_ch_width)
1907 goto prnt_log;
1908
1909 if (session_entry->ch_width == CH_WIDTH_80MHZ) {
1910 chnl_switch_info->newChanWidth = CH_WIDTH_80MHZ;
1911 chnl_switch_info->newCenterChanFreq1 = 0;
1912 } else {
1913 session_entry->ch_width = ap_new_ch_width;
1914 chnl_switch_info->newChanWidth = ap_new_ch_width;
1915 }
1916prnt_log:
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301917 pe_debug("new channel: %d new_ch_width: %d seg0: %d seg1: %d",
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001918 csa_params->channel,
1919 chnl_switch_info->newChanWidth,
1920 chnl_switch_info->newCenterChanFreq0,
1921 chnl_switch_info->newCenterChanFreq1);
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001922
1923 return QDF_STATUS_SUCCESS;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001924}
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08001925
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001926/**
1927 * lim_handle_csa_offload_msg() - Handle CSA offload message
1928 * @mac_ctx: pointer to global adapter context
1929 * @msg: Message pointer.
1930 *
1931 * Return: None
1932 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08001933void lim_handle_csa_offload_msg(tpAniSirGlobal mac_ctx,
1934 struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001935{
1936 tpPESession session_entry;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001937 struct scheduler_msg mmh_msg = {0};
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301938 struct csa_offload_params *csa_params =
1939 (struct csa_offload_params *) (msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001940 tpSmeCsaOffloadInd csa_offload_ind;
1941 tpDphHashNode sta_ds = NULL;
1942 uint8_t session_id;
1943 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05301944 uint16_t chan_space = 0;
Krunal Sonie2c45a92018-05-03 11:51:26 -07001945 struct ch_params ch_params = {0};
Gupta, Kapil121bf212015-11-25 19:21:29 +05301946
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001947 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08001948 tLimChannelSwitchInfo *lim_ch_switch = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001949
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301950 pe_debug("handle csa offload msg");
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301951
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001952 if (!csa_params) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301953 pe_err("limMsgQ body ptr is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001954 return;
1955 }
1956
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05301957 csa_offload_ind = qdf_mem_malloc(sizeof(tSmeCsaOffloadInd));
1958 if (NULL == csa_offload_ind) {
1959 pe_err("memalloc fail eWNI_SME_CSA_OFFLOAD_EVENT");
1960 goto err;
1961 }
1962
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001963 session_entry =
1964 pe_find_session_by_bssid(mac_ctx,
1965 csa_params->bssId, &session_id);
1966 if (!session_entry) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301967 pe_err("Session does not exists for %pM",
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05301968 csa_params->bssId);
Pragaspathi Thilagaraj655db192018-06-19 17:41:37 +05301969 qdf_mem_free(csa_offload_ind);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001970 goto err;
1971 }
1972
1973 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
1974 &session_entry->dph.dphHashTable);
1975
1976 if (!sta_ds) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301977 pe_err("sta_ds does not exist");
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
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001982 if (!LIM_IS_STA_ROLE(session_entry)) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301983 pe_debug("Invalid role to handle CSA");
Pragaspathi Thilagaraj655db192018-06-19 17:41:37 +05301984 qdf_mem_free(csa_offload_ind);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001985 goto err;
1986 }
Masti, Narayanraddi1c630442015-11-02 12:03:50 +05301987
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001988 /*
1989 * on receiving channel switch announcement from AP, delete all
1990 * TDLS peers before leaving BSS and proceed for channel switch
1991 */
1992 lim_delete_tdls_peers(mac_ctx, session_entry);
Gupta, Kapil121bf212015-11-25 19:21:29 +05301993
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001994 lim_ch_switch = &session_entry->gLimChannelSwitch;
1995 session_entry->gLimChannelSwitch.switchMode =
1996 csa_params->switch_mode;
1997 /* timer already started by firmware, switch immediately */
1998 session_entry->gLimChannelSwitch.switchCount = 0;
1999 session_entry->gLimChannelSwitch.primaryChannel =
2000 csa_params->channel;
2001 session_entry->gLimChannelSwitch.state =
2002 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2003 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
2004 lim_ch_switch->sec_ch_offset =
2005 session_entry->htSecondaryChannelOffset;
2006 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
2007 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
2008 chnl_switch_info =
2009 &session_entry->gLimWiderBWChannelSwitch;
2010
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08002011 pe_info("vht: %d ht: %d flag: %x chan: %d, sec_ch_offset %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302012 session_entry->vhtCapability,
2013 session_entry->htSupportedChannelWidthSet,
2014 csa_params->ies_present_flag,
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08002015 csa_params->channel,
2016 csa_params->sec_chan_offset);
2017 pe_info("seg1: %d seg2: %d width: %d country: %s class: %d",
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002018 csa_params->new_ch_freq_seg1,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302019 csa_params->new_ch_freq_seg2,
2020 csa_params->new_ch_width,
2021 mac_ctx->scan.countryCodeCurrent,
2022 csa_params->new_op_class);
2023
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002024 if (session_entry->vhtCapability &&
2025 session_entry->htSupportedChannelWidthSet) {
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08002026 if ((csa_params->ies_present_flag & lim_wbw_ie_present) &&
2027 (QDF_STATUS_SUCCESS == lim_process_csa_wbw_ie(mac_ctx,
2028 csa_params, chnl_switch_info,
2029 session_entry))) {
2030 pe_debug("CSA wide BW IE process successful");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002031 lim_ch_switch->sec_ch_offset =
Abhishek Singhaf639b42017-06-16 14:14:36 +05302032 PHY_SINGLE_CHANNEL_CENTERED;
2033 if (chnl_switch_info->newChanWidth) {
2034 if (csa_params->channel <
2035 csa_params->new_ch_freq_seg1)
2036 lim_ch_switch->sec_ch_offset =
2037 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
2038 else
2039 lim_ch_switch->sec_ch_offset =
2040 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
2041 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002042 } else if (csa_params->ies_present_flag
2043 & lim_xcsa_ie_present) {
2044 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002045 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002046 mac_ctx->scan.countryCodeCurrent,
2047 csa_params->channel,
2048 csa_params->new_op_class);
2049 session_entry->gLimChannelSwitch.state =
2050 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2051
2052 if (chan_space == 80) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002053 chnl_switch_info->newChanWidth =
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002054 CH_WIDTH_80MHZ;
2055 } else if (chan_space == 40) {
2056 chnl_switch_info->newChanWidth =
2057 CH_WIDTH_40MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002058 } else {
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002059 chnl_switch_info->newChanWidth =
2060 CH_WIDTH_20MHZ;
2061 lim_ch_switch->state =
2062 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2063 }
2064
2065 ch_params.ch_width =
2066 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002067 wlan_reg_set_channel_params(mac_ctx->pdev,
2068 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002069 chnl_switch_info->newCenterChanFreq0 =
2070 ch_params.center_freq_seg0;
2071 /*
2072 * This is not applicable for 20/40/80 MHz.
2073 * Only used when we support 80+80 MHz operation.
2074 * In case of 80+80 MHz, this parameter indicates
2075 * center channel frequency index of 80 MHz
2076 * channel offrequency segment 1.
2077 */
2078 chnl_switch_info->newCenterChanFreq1 =
2079 ch_params.center_freq_seg1;
2080 lim_ch_switch->sec_ch_offset =
2081 ch_params.sec_ch_offset;
2082
Kiran Kumar Lokere47127482017-12-20 18:09:55 -08002083 } else {
2084 lim_ch_switch->state =
2085 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2086 ch_params.ch_width = CH_WIDTH_40MHZ;
2087 wlan_reg_set_channel_params(mac_ctx->pdev,
2088 csa_params->channel, 0, &ch_params);
2089 lim_ch_switch->sec_ch_offset =
2090 ch_params.sec_ch_offset;
2091 chnl_switch_info->newChanWidth = CH_WIDTH_40MHZ;
2092 chnl_switch_info->newCenterChanFreq0 =
2093 ch_params.center_freq_seg0;
2094 chnl_switch_info->newCenterChanFreq1 = 0;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002095 }
2096 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
2097 chnl_switch_info->newCenterChanFreq0;
2098 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
2099 chnl_switch_info->newCenterChanFreq1;
2100 session_entry->gLimChannelSwitch.ch_width =
2101 chnl_switch_info->newChanWidth;
2102
2103 } else if (session_entry->htSupportedChannelWidthSet) {
2104 if (csa_params->ies_present_flag
2105 & lim_xcsa_ie_present) {
2106 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002107 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002108 mac_ctx->scan.countryCodeCurrent,
2109 csa_params->channel,
2110 csa_params->new_op_class);
2111 lim_ch_switch->state =
2112 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2113 if (chan_space == 40) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002114 lim_ch_switch->ch_width =
2115 CH_WIDTH_40MHZ;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002116 chnl_switch_info->newChanWidth =
2117 CH_WIDTH_40MHZ;
2118 ch_params.ch_width =
2119 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002120 wlan_reg_set_channel_params(mac_ctx->pdev,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002121 csa_params->channel,
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07002122 0, &ch_params);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002123 lim_ch_switch->ch_center_freq_seg0 =
2124 ch_params.center_freq_seg0;
2125 lim_ch_switch->sec_ch_offset =
2126 ch_params.sec_ch_offset;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002127 } else {
2128 lim_ch_switch->ch_width =
2129 CH_WIDTH_20MHZ;
2130 chnl_switch_info->newChanWidth =
2131 CH_WIDTH_40MHZ;
2132 lim_ch_switch->state =
2133 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2134 lim_ch_switch->sec_ch_offset =
2135 PHY_SINGLE_CHANNEL_CENTERED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002136 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002137 } else {
2138 lim_ch_switch->ch_width =
2139 CH_WIDTH_40MHZ;
2140 lim_ch_switch->state =
2141 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2142 ch_params.ch_width = CH_WIDTH_40MHZ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002143 wlan_reg_set_channel_params(mac_ctx->pdev,
2144 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002145 lim_ch_switch->ch_center_freq_seg0 =
2146 ch_params.center_freq_seg0;
2147 lim_ch_switch->sec_ch_offset =
2148 ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002149 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002150
2151 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302152 pe_debug("new ch width: %d space: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302153 session_entry->gLimChannelSwitch.ch_width, chan_space);
Kiran Kumar Lokere75d636f2016-12-20 14:52:03 -08002154 if ((session_entry->currentOperChannel == csa_params->channel) &&
2155 (session_entry->ch_width ==
2156 session_entry->gLimChannelSwitch.ch_width)) {
2157 pe_debug("Ignore CSA, no change in ch and bw");
Pragaspathi Thilagaraj655db192018-06-19 17:41:37 +05302158 qdf_mem_free(csa_offload_ind);
Kiran Kumar Lokere75d636f2016-12-20 14:52:03 -08002159 goto err;
2160 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002161
Pragaspathi Thilagaraj5fcd7182018-06-06 13:46:18 +05302162 if (WLAN_REG_IS_24GHZ_CH(csa_params->channel) &&
2163 (session_entry->dot11mode == WNI_CFG_DOT11_MODE_11A))
2164 session_entry->dot11mode = WNI_CFG_DOT11_MODE_11G;
2165 else if (WLAN_REG_IS_5GHZ_CH(csa_params->channel) &&
2166 ((session_entry->dot11mode == WNI_CFG_DOT11_MODE_11G) ||
2167 (session_entry->dot11mode == WNI_CFG_DOT11_MODE_11G_ONLY)))
2168 session_entry->dot11mode = WNI_CFG_DOT11_MODE_11A;
2169
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002170 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002171
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002172 csa_offload_ind->mesgType = eWNI_SME_CSA_OFFLOAD_EVENT;
2173 csa_offload_ind->mesgLen = sizeof(tSmeCsaOffloadInd);
2174 qdf_mem_copy(csa_offload_ind->bssid.bytes, session_entry->bssId,
2175 QDF_MAC_ADDR_SIZE);
2176 mmh_msg.type = eWNI_SME_CSA_OFFLOAD_EVENT;
2177 mmh_msg.bodyptr = csa_offload_ind;
2178 mmh_msg.bodyval = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302179 pe_debug("Sending eWNI_SME_CSA_OFFLOAD_EVENT to SME");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002180 MTRACE(mac_trace_msg_tx
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002181 (mac_ctx, session_entry->peSessionId, mmh_msg.type));
2182#ifdef FEATURE_WLAN_DIAG_SUPPORT
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002183 lim_diag_event_report(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002184 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002185 QDF_STATUS_SUCCESS, QDF_STATUS_SUCCESS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002186#endif
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002187 lim_sys_process_mmh_msg_api(mac_ctx, &mmh_msg, ePROT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002188
2189err:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302190 qdf_mem_free(csa_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002191}
2192
2193/*--------------------------------------------------------------------------
2194 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
2195
2196 \param pMac - pointer to global adapter context
2197 \param sessionId - Message pointer.
2198
2199 \sa
2200 --------------------------------------------------------------------------*/
2201
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002202void lim_handle_delete_bss_rsp(tpAniSirGlobal pMac, struct scheduler_msg *MsgQ)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002203{
2204 tpPESession psessionEntry;
2205 tpDeleteBssParams pDelBss = (tpDeleteBssParams) (MsgQ->bodyptr);
2206
2207 psessionEntry =
2208 pe_find_session_by_session_id(pMac, pDelBss->sessionId);
2209 if (psessionEntry == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302210 pe_err("Session Does not exist for given sessionID: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002211 pDelBss->sessionId);
Naveen Rawat0c81edc2016-06-08 10:08:30 -07002212 qdf_mem_free(MsgQ->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002213 return;
2214 }
Krunal Sonie50ff452017-10-11 18:23:55 -07002215
2216 /*
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002217 * During DEL BSS handling, the PE Session will be deleted, but it is
2218 * better to clear this flag if the session is hanging around due
2219 * to some error conditions so that the next DEL_BSS request does
2220 * not take the HO_FAIL path
2221 */
2222 psessionEntry->process_ho_fail = false;
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002223 if (LIM_IS_IBSS_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002224 lim_ibss_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002225 else if (LIM_IS_UNKNOWN_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002226 lim_process_sme_del_bss_rsp(pMac, MsgQ->bodyval, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002227 else if (LIM_IS_NDI_ROLE(psessionEntry))
2228 lim_ndi_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002229 else
2230 lim_process_mlm_del_bss_rsp(pMac, MsgQ, psessionEntry);
2231
2232}
2233
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002234/** -----------------------------------------------------------------
2235 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
2236 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
2237 \ SME only looks at rc and tspec field.
2238 \param pMac - global mac structure
2239 \param rspReqd - is SmeAddTsRsp required
2240 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
2241 \return tspec
2242 \sa
2243 ----------------------------------------------------------------- */
2244void
2245lim_send_sme_aggr_qos_rsp(tpAniSirGlobal pMac, tpSirAggrQosRsp aggrQosRsp,
2246 uint8_t smesessionId)
2247{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002248 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002249
2250 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
2251 mmhMsg.bodyptr = aggrQosRsp;
2252 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302253 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2254 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002255 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2256
2257 return;
2258}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002259
2260void lim_send_sme_max_assoc_exceeded_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
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 tSmeMaxAssocInd *pSmeMaxAssocInd;
2265
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302266 pSmeMaxAssocInd = qdf_mem_malloc(sizeof(tSmeMaxAssocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002267 if (NULL == pSmeMaxAssocInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302268 pe_err("Failed to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002269 return;
2270 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302271 qdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peer_mac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302272 (uint8_t *) peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002273 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
2274 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
2275 pSmeMaxAssocInd->sessionId = smesessionId;
2276 mmhMsg.type = pSmeMaxAssocInd->mesgType;
2277 mmhMsg.bodyptr = pSmeMaxAssocInd;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302278 pe_debug("msgType: %s peerMacAddr "MAC_ADDRESS_STR "sme session id %d",
2279 "eWNI_SME_MAX_ASSOC_EXCEEDED", MAC_ADDR_ARRAY(peerMacAddr),
2280 pSmeMaxAssocInd->sessionId);
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302281 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2282 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002283 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2284
2285 return;
2286}
2287
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002288/*--------------------------------------------------------------------------
2289 \brief lim_send_dfs_chan_sw_ie_update()
2290 This timer handler updates the channel switch IE in beacon template
2291
2292 \param pMac - pointer to global adapter context
2293 \return - channel to scan from valid session else zero.
2294 \sa
2295 --------------------------------------------------------------------------*/
2296static void
2297lim_send_dfs_chan_sw_ie_update(tpAniSirGlobal pMac, tpPESession psessionEntry)
2298{
2299
2300 /* Update the beacon template and send to FW */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002301 if (sch_set_fixed_beacon_fields(pMac, psessionEntry) != QDF_STATUS_SUCCESS) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302302 pe_err("Unable to set CSA IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002303 return;
2304 }
2305
2306 /* Send update beacon template message */
2307 lim_send_beacon_ind(pMac, psessionEntry);
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302308 pe_debug("Updated CSA IE, IE COUNT: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002309 psessionEntry->gLimChannelSwitch.switchCount);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002310
2311 return;
2312}
2313
2314/** -----------------------------------------------------------------
2315 \brief lim_send_sme_ap_channel_switch_resp() - sends
2316 eWNI_SME_CHANNEL_CHANGE_RSP
2317 After receiving WMA_SWITCH_CHANNEL_RSP indication this
2318 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
2319 that the Channel change has been done to the specified target
2320 channel in the Channel change request
2321 \param pMac - global mac structure
2322 \param psessionEntry - session info
2323 \param pChnlParams - Channel switch params
2324 --------------------------------------------------------------------*/
2325void
2326lim_send_sme_ap_channel_switch_resp(tpAniSirGlobal pMac,
2327 tpPESession psessionEntry,
2328 tpSwitchChannelParams pChnlParams)
2329{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002330 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002331 tpSwitchChannelParams pSmeSwithChnlParams;
2332 uint8_t channelId;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002333 bool is_ch_dfs = false;
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08002334 enum phy_ch_width ch_width;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002335 uint8_t ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002336
2337 pSmeSwithChnlParams = (tSwitchChannelParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302338 qdf_mem_malloc(sizeof(tSwitchChannelParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002339 if (NULL == pSmeSwithChnlParams) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302340 pe_err("AllocateMemory failed for pSmeSwithChnlParams");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002341 return;
2342 }
2343
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302344 qdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002345 sizeof(tSwitchChannelParams));
2346
2347 channelId = pSmeSwithChnlParams->channelNumber;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002348 ch_width = pSmeSwithChnlParams->ch_width;
2349 ch_center_freq_seg1 = pSmeSwithChnlParams->ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002350
2351 /*
2352 * Pass the sme sessionID to SME instead
2353 * PE session ID.
2354 */
2355 pSmeSwithChnlParams->peSessionId = psessionEntry->smeSessionId;
2356
2357 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
2358 mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
2359 mmhMsg.bodyval = 0;
2360 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2361
2362 /*
2363 * We should start beacon transmission only if the new
2364 * channel after channel change is Non-DFS. For a DFS
2365 * channel, PE will receive an explicit request from
2366 * upper layers to start the beacon transmission .
2367 */
2368
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002369 if (ch_width == CH_WIDTH_160MHZ) {
2370 is_ch_dfs = true;
2371 } else if (ch_width == CH_WIDTH_80P80MHZ) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002372 if (wlan_reg_get_channel_state(pMac->pdev, channelId) ==
2373 CHANNEL_STATE_DFS ||
2374 wlan_reg_get_channel_state(pMac->pdev,
2375 ch_center_freq_seg1 -
2376 SIR_80MHZ_START_CENTER_CH_DIFF) ==
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002377 CHANNEL_STATE_DFS)
2378 is_ch_dfs = true;
2379 } else {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002380 if (wlan_reg_get_channel_state(pMac->pdev, channelId) ==
2381 CHANNEL_STATE_DFS)
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002382 is_ch_dfs = true;
2383 }
2384
2385 if (!is_ch_dfs) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002386 if (channelId == psessionEntry->currentOperChannel) {
2387 lim_apply_configuration(pMac, psessionEntry);
2388 lim_send_beacon_ind(pMac, psessionEntry);
2389 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302390 pe_debug("Failed to Transmit Beacons on channel: %d after AP channel change response",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002391 psessionEntry->bcnLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002392 }
Arif Hussain1513cb22018-01-05 19:56:31 -08002393
2394 lim_obss_send_detection_cfg(pMac, psessionEntry, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002395 }
2396 return;
2397}
2398
Peng Xu6363ec62017-05-15 11:06:33 -07002399#ifdef WLAN_FEATURE_11AX_BSS_COLOR
2400/**
2401 * lim_send_bss_color_change_ie_update() - update bss color change IE in
2402 * beacon template
2403 *
2404 * @mac_ctx: pointer to global adapter context
2405 * @session: session pointer
2406 *
2407 * Return: none
2408 */
2409static void
2410lim_send_bss_color_change_ie_update(tpAniSirGlobal mac_ctx,
2411 tpPESession session)
2412{
2413 /* Update the beacon template and send to FW */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002414 if (sch_set_fixed_beacon_fields(mac_ctx, session) != QDF_STATUS_SUCCESS) {
Peng Xu6363ec62017-05-15 11:06:33 -07002415 pe_err("Unable to set BSS color change IE in beacon");
2416 return;
2417 }
2418
2419 /* Send update beacon template message */
2420 lim_send_beacon_ind(mac_ctx, session);
2421 pe_info("Updated BSS color change countdown = %d",
2422 session->he_bss_color_change.countdown);
2423}
2424
2425static void
2426lim_handle_bss_color_change_ie(tpAniSirGlobal mac_ctx,
2427 tpPESession session)
2428{
Arif Hussain2f2d3512018-03-06 12:37:03 -08002429 tUpdateBeaconParams beacon_params;
2430
Peng Xu6363ec62017-05-15 11:06:33 -07002431 /* handle bss color change IE */
2432 if (LIM_IS_AP_ROLE(session) &&
2433 session->he_op.bss_col_disabled) {
2434 if (session->he_bss_color_change.countdown > 0) {
2435 session->he_bss_color_change.countdown--;
2436 } else {
2437 session->bss_color_changing = 0;
Arif Hussain2f2d3512018-03-06 12:37:03 -08002438 qdf_mem_zero(&beacon_params, sizeof(beacon_params));
Arif Hussain05fb4872018-01-03 16:02:55 -08002439 if (session->he_bss_color_change.new_color != 0) {
Peng Xu6363ec62017-05-15 11:06:33 -07002440 session->he_op.bss_col_disabled = 0;
Arif Hussain05fb4872018-01-03 16:02:55 -08002441 session->he_op.bss_color =
2442 session->he_bss_color_change.new_color;
Arif Hussain2f2d3512018-03-06 12:37:03 -08002443 beacon_params.paramChangeBitmap |=
2444 PARAM_BSS_COLOR_CHANGED;
2445 beacon_params.bss_color_disabled = 0;
2446 beacon_params.bss_color =
2447 session->he_op.bss_color;
2448 lim_send_beacon_params(mac_ctx,
2449 &beacon_params,
2450 session);
Arif Hussain05fb4872018-01-03 16:02:55 -08002451 lim_send_obss_color_collision_cfg(mac_ctx,
2452 session,
2453 OBSS_COLOR_COLLISION_DETECTION);
2454 }
Peng Xu6363ec62017-05-15 11:06:33 -07002455 }
2456
2457 lim_send_bss_color_change_ie_update(mac_ctx, session);
2458 }
2459}
2460
2461#else
2462static void
2463lim_handle_bss_color_change_ie(tpAniSirGlobal mac_ctx,
2464 tpPESession session)
2465{
2466}
2467#endif
2468
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002469/** -----------------------------------------------------------------
2470 \brief lim_process_beacon_tx_success_ind() - This function is used
Jeff Johnson47d75242018-05-12 15:58:53 -07002471 explicitly to handle successful beacon transmission indication
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002472 from the FW. This is a generic event generated by the FW afer the
2473 first beacon is sent out after the beacon template update by the
2474 host
2475 \param pMac - global mac structure
2476 \param psessionEntry - session info
2477 \return none
2478 \sa
2479 ----------------------------------------------------------------- */
2480void
2481lim_process_beacon_tx_success_ind(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2482{
2483 /* Currently, this event is used only for DFS channel switch announcement
2484 * IE update in the template. If required to be used for other IE updates
2485 * add appropriate code by introducing a state variable
2486 */
2487 tpPESession psessionEntry;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002488 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002489 tSirSmeCSAIeTxCompleteRsp *pChanSwTxResponse;
2490 struct sir_beacon_tx_complete_rsp *beacon_tx_comp_rsp_ptr;
2491 uint8_t length = sizeof(tSirSmeCSAIeTxCompleteRsp);
2492 tpSirFirstBeaconTxCompleteInd pBcnTxInd =
2493 (tSirFirstBeaconTxCompleteInd *) event;
lifeng1c16b6b2017-09-25 13:59:55 +08002494 uint8_t ch, ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002495
2496 psessionEntry = pe_find_session_by_bss_idx(pMac, pBcnTxInd->bssIdx);
2497 if (psessionEntry == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302498 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002499 return;
2500 }
2501
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302502 pe_debug("role: %d swIe: %d opIe: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302503 GET_LIM_SYSTEM_ROLE(psessionEntry),
2504 psessionEntry->dfsIncludeChanSwIe,
2505 psessionEntry->gLimOperatingMode.present);
2506
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002507 if (LIM_IS_AP_ROLE(psessionEntry) &&
2508 true == psessionEntry->dfsIncludeChanSwIe) {
Ganesh Kondabattini02ec62b2018-01-24 18:22:24 +05302509
2510 if (psessionEntry->gLimChannelSwitch.switchCount) {
2511 /* Decrement the beacon switch count */
2512 psessionEntry->gLimChannelSwitch.switchCount--;
2513 pe_debug("current beacon count %d",
2514 psessionEntry->gLimChannelSwitch.switchCount);
2515 }
2516
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002517 /* Send only 5 beacons with CSA IE Set in when a radar is detected */
2518 if (psessionEntry->gLimChannelSwitch.switchCount > 0) {
2519 /*
2520 * Send the next beacon with updated CSA IE count
2521 */
2522 lim_send_dfs_chan_sw_ie_update(pMac, psessionEntry);
lifeng1c16b6b2017-09-25 13:59:55 +08002523
2524 ch = psessionEntry->gLimChannelSwitch.primaryChannel;
2525 ch_width = psessionEntry->gLimChannelSwitch.ch_width;
2526 if (pMac->sap.SapDfsInfo.dfs_beacon_tx_enhanced)
2527 /* Send Action frame after updating beacon */
2528 lim_send_chan_switch_action_frame(pMac,
2529 ch, ch_width, psessionEntry);
2530
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002531 } else {
2532 /* Done with CSA IE update, send response back to SME */
2533 psessionEntry->gLimChannelSwitch.switchCount = 0;
2534 if (pMac->sap.SapDfsInfo.disable_dfs_ch_switch == false)
2535 psessionEntry->gLimChannelSwitch.switchMode = 0;
2536 psessionEntry->dfsIncludeChanSwIe = false;
2537 psessionEntry->dfsIncludeChanWrapperIe = false;
2538
2539 pChanSwTxResponse = (tSirSmeCSAIeTxCompleteRsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302540 qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002541
2542 if (NULL == pChanSwTxResponse) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302543 pe_err("AllocateMemory failed for tSirSmeCSAIeTxCompleteRsp");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002544 return;
2545 }
2546
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002547 pChanSwTxResponse->sessionId =
2548 psessionEntry->smeSessionId;
2549 pChanSwTxResponse->chanSwIeTxStatus =
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302550 QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002551
2552 mmhMsg.type = eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND;
2553 mmhMsg.bodyptr = pChanSwTxResponse;
2554 mmhMsg.bodyval = 0;
2555 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2556 }
2557 }
2558
2559 if (LIM_IS_AP_ROLE(psessionEntry) &&
2560 psessionEntry->gLimOperatingMode.present) {
2561 /* Done with nss update, send response back to SME */
2562 psessionEntry->gLimOperatingMode.present = 0;
2563 beacon_tx_comp_rsp_ptr = (struct sir_beacon_tx_complete_rsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302564 qdf_mem_malloc(sizeof(*beacon_tx_comp_rsp_ptr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002565 if (NULL == beacon_tx_comp_rsp_ptr) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302566 pe_err("AllocateMemory failed for beacon_tx_comp_rsp_ptr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002567 return;
2568 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002569 beacon_tx_comp_rsp_ptr->session_id =
2570 psessionEntry->smeSessionId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302571 beacon_tx_comp_rsp_ptr->tx_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002572 mmhMsg.type = eWNI_SME_NSS_UPDATE_RSP;
2573 mmhMsg.bodyptr = beacon_tx_comp_rsp_ptr;
2574 mmhMsg.bodyval = 0;
2575 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2576 }
Peng Xu6363ec62017-05-15 11:06:33 -07002577
2578 lim_handle_bss_color_change_ie(pMac, psessionEntry);
2579
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002580 return;
2581}