blob: ce4d45fdd2cb2f06bb0e48f93744313e339085ae [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 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/*
29 * This file lim_send_sme_rspMessages.cc contains the functions
30 * for sending SME response/notification messages to applications
31 * above MAC software.
32 * Author: Chandra Modumudi
33 * Date: 02/13/02
34 * History:-
35 * Date Modified by Modification Information
36 * --------------------------------------------------------------------
37 */
38
Anurag Chouhan6d760662016-02-20 16:05:43 +053039#include "qdf_types.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080040#include "wni_api.h"
41#include "sir_common.h"
42#include "ani_global.h"
43
44#include "wni_cfg.h"
45#include "sys_def.h"
46#include "cfg_api.h"
47
48#include "sch_api.h"
49#include "utils_api.h"
50#include "lim_utils.h"
51#include "lim_security_utils.h"
52#include "lim_ser_des_utils.h"
53#include "lim_send_sme_rsp_messages.h"
54#include "lim_ibss_peer_mgmt.h"
55#include "lim_session_utils.h"
56#include "lim_types.h"
57#include "sir_api.h"
Naveen Rawat3b6068c2016-04-14 19:01:06 -070058#include "cds_regdomain.h"
Gupta, Kapil121bf212015-11-25 19:21:29 +053059#include "lim_send_messages.h"
Deepak Dhamdhere13983f22016-05-31 19:06:09 -070060#include "nan_datapath.h"
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -070061#include "lim_assoc_utils.h"
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070062#include "wlan_reg_services_api.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070063#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080064
Kabilan Kannanf56f9d52017-04-05 03:31:34 -070065#include "wlan_tdls_tgt_api.h"
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +053066#include "lim_process_fils.h"
Kabilan Kannanf56f9d52017-04-05 03:31:34 -070067
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080068static void lim_handle_join_rsp_status(tpAniSirGlobal mac_ctx,
69 tpPESession session_entry, tSirResultCodes result_code,
70 tpSirSmeJoinRsp sme_join_rsp);
71
72/**
73 * lim_send_sme_rsp() - Send Response to upper layers
74 * @mac_ctx: Pointer to Global MAC structure
75 * @msg_type: Indicates message type
76 * @result_code: Indicates the result of previously issued
77 * eWNI_SME_msg_type_REQ message
78 *
79 * This function is called by lim_process_sme_req_messages() to send
80 * eWNI_SME_START_RSP, eWNI_SME_STOP_BSS_RSP
81 * or eWNI_SME_SWITCH_CHL_RSP messages to applications above MAC
82 * Software.
83 *
84 * Return: None
85 */
86
87void
88lim_send_sme_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
89 tSirResultCodes result_code, uint8_t sme_session_id,
90 uint16_t sme_transaction_id)
91{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070092 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080093 tSirSmeRsp *sme_rsp;
94
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +053095 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080096 lim_msg_str(msg_type), lim_result_code_str(result_code));
97
Anurag Chouhan600c3a02016-03-01 10:33:54 +053098 sme_rsp = qdf_mem_malloc(sizeof(tSirSmeRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080099 if (NULL == sme_rsp) {
100 /* Buffer not available. Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530101 pe_err("call to AllocateMemory failed for eWNI_SME_*_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800102 return;
103 }
104
105 sme_rsp->messageType = msg_type;
106 sme_rsp->length = sizeof(tSirSmeRsp);
107 sme_rsp->statusCode = result_code;
108
109 sme_rsp->sessionId = sme_session_id;
110 sme_rsp->transactionId = sme_transaction_id;
111
112 msg.type = msg_type;
113 msg.bodyptr = sme_rsp;
114 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530115 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG,
116 sme_session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800117
118#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
119 switch (msg_type) {
120 case eWNI_SME_STOP_BSS_RSP:
121 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_STOP_BSS_RSP_EVENT,
122 NULL, (uint16_t) result_code, 0);
123 break;
124 }
125#endif /* FEATURE_WLAN_DIAG_SUPPORT */
126 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
127}
128
129
130
131/**
132 * lim_send_sme_roc_rsp() - Send Response to SME
133 * @mac_ctx: Pointer to Global MAC structure
134 * @status: Resume link status
135 * @result_code: Result of the ROC request
136 * @sme_session_id: SME sesson Id
137 * @scan_id: Scan Identifier
138 *
139 * This function is called to send ROC rsp
140 * message to SME.
141 *
142 * Return: None
143 */
144void
145lim_send_sme_roc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
146 tSirResultCodes result_code, uint8_t sme_session_id,
147 uint32_t scan_id)
148{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700149 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800150 struct sir_roc_rsp *sme_rsp;
151
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530152 pe_debug("Sending message: %s with reasonCode: %s scanId: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800153 lim_msg_str(msg_type), lim_result_code_str(result_code),
154 scan_id);
155
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530156 sme_rsp = qdf_mem_malloc(sizeof(struct sir_roc_rsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800157 if (NULL == sme_rsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530158 pe_err("call to AllocateMemory failed for eWNI_SME_*_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800159 return;
160 }
161
162 sme_rsp->message_type = msg_type;
163 sme_rsp->length = sizeof(struct sir_roc_rsp);
164 sme_rsp->status = result_code;
165
166 sme_rsp->session_id = sme_session_id;
167 sme_rsp->scan_id = scan_id;
168
169 msg.type = msg_type;
170 msg.bodyptr = sme_rsp;
171 msg.bodyval = 0;
172 MTRACE(mac_trace_msg_tx(mac_ctx, sme_session_id, msg.type));
173 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
174}
175
176
177/**
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530178 * lim_get_max_rate_flags() - Get rate flags
179 * @mac_ctx: Pointer to global MAC structure
180 * @sta_ds: Pointer to station ds structure
181 *
182 * This function is called to get the rate flags for a connection
183 * from the station ds structure depending on the ht and the vht
184 * channel width supported.
185 *
186 * Return: Returns the populated rate_flags
187 */
188uint32_t lim_get_max_rate_flags(tpAniSirGlobal mac_ctx, tpDphHashNode sta_ds)
189{
190 uint32_t rate_flags = 0;
191
192 if (sta_ds == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530193 pe_err("sta_ds is NULL");
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530194 return rate_flags;
195 }
196
197 if (!sta_ds->mlmStaContext.htCapability &&
198 !sta_ds->mlmStaContext.vhtCapability) {
199 rate_flags |= eHAL_TX_RATE_LEGACY;
200 } else {
201 if (sta_ds->mlmStaContext.vhtCapability) {
202 if (WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ ==
203 sta_ds->vhtSupportedChannelWidthSet) {
204 rate_flags |= eHAL_TX_RATE_VHT80;
205 } else if (WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ ==
206 sta_ds->vhtSupportedChannelWidthSet) {
207 if (sta_ds->htSupportedChannelWidthSet)
208 rate_flags |= eHAL_TX_RATE_VHT40;
209 else
210 rate_flags |= eHAL_TX_RATE_VHT20;
211 }
212 } else if (sta_ds->mlmStaContext.htCapability) {
213 if (sta_ds->htSupportedChannelWidthSet)
214 rate_flags |= eHAL_TX_RATE_HT40;
215 else
216 rate_flags |= eHAL_TX_RATE_HT20;
217 }
218 }
219
220 if (sta_ds->htShortGI20Mhz || sta_ds->htShortGI40Mhz)
221 rate_flags |= eHAL_TX_RATE_SGI;
222
223 return rate_flags;
224}
225
226/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227 * lim_send_sme_join_reassoc_rsp_after_resume() - Send Response to SME
228 * @mac_ctx Pointer to Global MAC structure
229 * @status Resume link status
230 * @ctx context passed while calling resmune link.
231 * (join response to be sent)
232 *
233 * This function is called to send Join/Reassoc rsp
234 * message to SME after the resume link.
235 *
236 * Return: None
237 */
238static void lim_send_sme_join_reassoc_rsp_after_resume(tpAniSirGlobal mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530239 QDF_STATUS status, uint32_t *ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800240{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700241 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800242 tpSirSmeJoinRsp sme_join_rsp = (tpSirSmeJoinRsp) ctx;
243
244 msg.type = sme_join_rsp->messageType;
245 msg.bodyptr = sme_join_rsp;
246 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530247 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, NO_SESSION, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800248 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
249}
250
251/**
252 * lim_handle_join_rsp_status() - Handle the response.
253 * @mac_ctx: Pointer to Global MAC structure
254 * @session_entry: PE Session Info
255 * @result_code: Indicates the result of previously issued
256 * eWNI_SME_msgType_REQ message
257 * @sme_join_rsp The received response.
258 *
259 * This function will handle both the success and failure status
260 * of the received response.
261 *
262 * Return: None
263 */
264static void lim_handle_join_rsp_status(tpAniSirGlobal mac_ctx,
265 tpPESession session_entry, tSirResultCodes result_code,
266 tpSirSmeJoinRsp sme_join_rsp)
267{
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700268 uint16_t bss_ie_len;
269 void *bss_ies;
270 bool is_vendor_ap_1_present;
Wu Gao2968fc92017-06-19 19:18:34 +0800271 tpSirSmeJoinReq join_reassoc_req = NULL;
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700272
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800273#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
274 tSirSmeHTProfile *ht_profile;
275#endif
276 if (result_code == eSIR_SME_SUCCESS) {
277 if (session_entry->beacon != NULL) {
278 sme_join_rsp->beaconLength = session_entry->bcnLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530279 qdf_mem_copy(sme_join_rsp->frames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800280 session_entry->beacon,
281 sme_join_rsp->beaconLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530282 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800283 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530284 session_entry->bcnLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530285 pe_debug("Beacon: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530286 sme_join_rsp->beaconLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800287 }
288 if (session_entry->assocReq != NULL) {
289 sme_join_rsp->assocReqLength =
290 session_entry->assocReqLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530291 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530292 sme_join_rsp->beaconLength,
293 session_entry->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800294 sme_join_rsp->assocReqLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530295 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800296 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530297 session_entry->assocReqLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530298 pe_debug("AssocReq: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530299 sme_join_rsp->assocReqLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800300 }
301 if (session_entry->assocRsp != NULL) {
302 sme_join_rsp->assocRspLength =
303 session_entry->assocRspLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530304 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530305 sme_join_rsp->beaconLength +
306 sme_join_rsp->assocReqLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800307 session_entry->assocRsp,
308 sme_join_rsp->assocRspLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530309 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800310 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530311 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800312 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800313 if (session_entry->ricData != NULL) {
314 sme_join_rsp->parsedRicRspLen =
315 session_entry->RICDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530316 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530317 sme_join_rsp->beaconLength +
318 sme_join_rsp->assocReqLength +
319 sme_join_rsp->assocRspLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800320 session_entry->ricData,
321 sme_join_rsp->parsedRicRspLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530322 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800323 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530324 session_entry->RICDataLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530325 pe_debug("RicLength: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800326 sme_join_rsp->parsedRicRspLen);
327 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800328#ifdef FEATURE_WLAN_ESE
329 if (session_entry->tspecIes != NULL) {
330 sme_join_rsp->tspecIeLen =
331 session_entry->tspecLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530332 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530333 sme_join_rsp->beaconLength +
334 sme_join_rsp->assocReqLength +
335 sme_join_rsp->assocRspLength +
336 sme_join_rsp->parsedRicRspLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800337 session_entry->tspecIes,
338 sme_join_rsp->tspecIeLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530339 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800340 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530341 session_entry->tspecLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530342 pe_debug("ESE-TspecLen: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530343 sme_join_rsp->tspecIeLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800344 }
345#endif
346 sme_join_rsp->aid = session_entry->limAID;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530347 pe_debug("AssocRsp: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530348 sme_join_rsp->assocRspLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800349 sme_join_rsp->vht_channel_width =
350 session_entry->ch_width;
351#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
352 if (session_entry->cc_switch_mode !=
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530353 QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800354 ht_profile = &sme_join_rsp->HTProfile;
355 ht_profile->htSupportedChannelWidthSet =
356 session_entry->htSupportedChannelWidthSet;
357 ht_profile->htRecommendedTxWidthSet =
358 session_entry->htRecommendedTxWidthSet;
359 ht_profile->htSecondaryChannelOffset =
360 session_entry->htSecondaryChannelOffset;
361 ht_profile->dot11mode = session_entry->dot11mode;
362 ht_profile->htCapability = session_entry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800363 ht_profile->vhtCapability =
364 session_entry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800365 ht_profile->apCenterChan = session_entry->ch_center_freq_seg0;
366 ht_profile->apChanWidth = session_entry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800367 }
368#endif
Jeff Johnson11bd4f32017-09-18 08:15:17 -0700369 pe_debug("pLimJoinReq:%pK, pLimReAssocReq:%pK",
Wu Gao2968fc92017-06-19 19:18:34 +0800370 session_entry->pLimJoinReq,
371 session_entry->pLimReAssocReq);
372
373 if (session_entry->pLimJoinReq)
374 join_reassoc_req = session_entry->pLimJoinReq;
375
376 if (session_entry->pLimReAssocReq)
377 join_reassoc_req = session_entry->pLimReAssocReq;
378
379 if (!join_reassoc_req) {
380 pe_err("both pLimJoinReq and pLimReAssocReq NULL");
381 return;
382 }
383
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700384 bss_ie_len = lim_get_ielen_from_bss_description(
Wu Gao2968fc92017-06-19 19:18:34 +0800385 &join_reassoc_req->bssDescription);
386 bss_ies = &join_reassoc_req->bssDescription.ieFields;
Naveen Rawat08db88f2017-09-08 15:07:48 -0700387 is_vendor_ap_1_present = (wlan_get_vendor_ie_ptr_from_oui(
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700388 SIR_MAC_VENDOR_AP_1_OUI, SIR_MAC_VENDOR_AP_1_OUI_LEN,
389 bss_ies, bss_ie_len) != NULL);
390
391 if (mac_ctx->roam.configParam.is_force_1x1 &&
Krunal Sonie6a1cda2017-09-27 15:23:02 -0700392 is_vendor_ap_1_present && (session_entry->nss == 2) &&
393 (mac_ctx->lteCoexAntShare == 0 ||
394 IS_5G_CH(session_entry->currentOperChannel))) {
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700395 /* SET vdev param */
396 pe_debug("sending SMPS intolrent vdev_param");
397 wma_cli_set_command(session_entry->smeSessionId,
398 (int)WMI_VDEV_PARAM_SMPS_INTOLERANT,
399 1, VDEV_CMD);
400
401 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800402 } else {
403 if (session_entry->beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530404 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800405 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530406 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800407 }
408 if (session_entry->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530409 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800410 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530411 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800412 }
413 if (session_entry->assocRsp != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530414 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800415 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530416 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800417 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800418 if (session_entry->ricData != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530419 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800420 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530421 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800422 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800423#ifdef FEATURE_WLAN_ESE
424 if (session_entry->tspecIes != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530425 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800426 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530427 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800428 }
429#endif
430 }
431}
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530432
433/**
434 * lim_add_bss_info() - copy data from session entry to join rsp
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530435 * @sta_ds: Station dph entry
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530436 * @sme_join_rsp: Join response buffer to be filled up
437 *
438 * Return: None
439 */
Jeff Johnson6db011e2016-10-07 07:31:39 -0700440static void lim_add_bss_info(tpDphHashNode sta_ds, tpSirSmeJoinRsp sme_join_rsp)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530441{
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530442 struct parsed_ies *parsed_ies = &sta_ds->parsed_ies;
443
444 if (parsed_ies->hs20vendor_ie.present)
445 sme_join_rsp->hs20vendor_ie = parsed_ies->hs20vendor_ie;
446 if (parsed_ies->vht_caps.present)
447 sme_join_rsp->vht_caps = parsed_ies->vht_caps;
448 if (parsed_ies->ht_caps.present)
449 sme_join_rsp->ht_caps = parsed_ies->ht_caps;
450 if (parsed_ies->ht_operation.present)
451 sme_join_rsp->ht_operation = parsed_ies->ht_operation;
452 if (parsed_ies->vht_operation.present)
453 sme_join_rsp->vht_operation = parsed_ies->vht_operation;
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530454}
455
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530456#ifdef WLAN_FEATURE_FILS_SK
457static void lim_update_fils_seq_num(tpSirSmeJoinRsp sme_join_rsp,
458 tpPESession session_entry)
459{
460 sme_join_rsp->fils_seq_num =
461 session_entry->fils_info->sequence_number;
462}
463#else
464static inline void lim_update_fils_seq_num(tpSirSmeJoinRsp sme_join_rsp,
465 tpPESession session_entry)
466{}
467#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800468/**
469 * lim_send_sme_join_reassoc_rsp() - Send Response to Upper Layers
470 * @mac_ctx: Pointer to Global MAC structure
471 * @msg_type: Indicates message type
472 * @result_code: Indicates the result of previously issued
473 * eWNI_SME_msgType_REQ message
474 * @prot_status_code: Protocol Status Code
475 * @session_entry: PE Session Info
476 * @sme_session_id: SME Session ID
477 * @sme_transaction_id: SME Transaction ID
478 *
479 * This function is called by lim_process_sme_req_messages() to send
480 * eWNI_SME_JOIN_RSP or eWNI_SME_REASSOC_RSP messages to applications
481 * above MAC Software.
482 *
483 * Return: None
484 */
485
486void
487lim_send_sme_join_reassoc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
488 tSirResultCodes result_code, uint16_t prot_status_code,
489 tpPESession session_entry, uint8_t sme_session_id,
490 uint16_t sme_transaction_id)
491{
492 tpSirSmeJoinRsp sme_join_rsp;
493 uint32_t rsp_len;
494 tpDphHashNode sta_ds = NULL;
495#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
496 if (msg_type == eWNI_SME_REASSOC_RSP)
497 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_RSP_EVENT,
498 session_entry, (uint16_t) result_code, 0);
499 else
500 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_RSP_EVENT,
501 session_entry, (uint16_t) result_code, 0);
502#endif /* FEATURE_WLAN_DIAG_SUPPORT */
503
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530504 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800505 lim_msg_str(msg_type), lim_result_code_str(result_code));
506
507 if (session_entry == NULL) {
508 rsp_len = sizeof(tSirSmeJoinRsp);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530509 sme_join_rsp = qdf_mem_malloc(rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800510 if (NULL == sme_join_rsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530511 pe_err("Mem Alloc fail - JOIN/REASSOC_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800512 return;
513 }
514
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800515 sme_join_rsp->beaconLength = 0;
516 sme_join_rsp->assocReqLength = 0;
517 sme_join_rsp->assocRspLength = 0;
518 } else {
519 rsp_len = session_entry->assocReqLen +
520 session_entry->assocRspLen + session_entry->bcnLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800521 session_entry->RICDataLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800522#ifdef FEATURE_WLAN_ESE
523 session_entry->tspecLen +
524#endif
525 sizeof(tSirSmeJoinRsp) - sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530526 sme_join_rsp = qdf_mem_malloc(rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800527 if (NULL == sme_join_rsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530528 pe_err("MemAlloc fail - JOIN/REASSOC_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800529 return;
530 }
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530531
532 if (lim_is_fils_connection(session_entry)) {
533 sme_join_rsp->is_fils_connection = true;
534 lim_update_fils_seq_num(sme_join_rsp,
535 session_entry);
536 }
537
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800538 if (result_code == eSIR_SME_SUCCESS) {
539 sta_ds = dph_get_hash_entry(mac_ctx,
540 DPH_STA_HASH_INDEX_PEER,
541 &session_entry->dph.dphHashTable);
542 if (sta_ds == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530543 pe_err("Get Self Sta Entry fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800544 } else {
545 /* Pass the peer's staId */
546 sme_join_rsp->staId = sta_ds->staIndex;
547 sme_join_rsp->ucastSig =
548 sta_ds->ucUcastSig;
549 sme_join_rsp->bcastSig =
550 sta_ds->ucBcastSig;
551 sme_join_rsp->timingMeasCap =
552 sta_ds->timingMeasCap;
553#ifdef FEATURE_WLAN_TDLS
554 sme_join_rsp->tdls_prohibited =
555 session_entry->tdls_prohibited;
556 sme_join_rsp->tdls_chan_swit_prohibited =
557 session_entry->tdls_chan_swit_prohibited;
558#endif
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530559 sme_join_rsp->nss = sta_ds->nss;
560 sme_join_rsp->max_rate_flags =
561 lim_get_max_rate_flags(mac_ctx, sta_ds);
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530562 lim_add_bss_info(sta_ds, sme_join_rsp);
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530563
564 /* Copy FILS params only for Successful join */
565 populate_fils_connect_params(mac_ctx,
566 session_entry, sme_join_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800567 }
568 }
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +0530569
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800570 sme_join_rsp->beaconLength = 0;
571 sme_join_rsp->assocReqLength = 0;
572 sme_join_rsp->assocRspLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800573 sme_join_rsp->parsedRicRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800574#ifdef FEATURE_WLAN_ESE
575 sme_join_rsp->tspecIeLen = 0;
576#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800577 lim_handle_join_rsp_status(mac_ctx, session_entry, result_code,
578 sme_join_rsp);
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800579
580 /* Send supported NSS 1x1 to SME */
581 sme_join_rsp->supported_nss_1x1 =
582 session_entry->supported_nss_1x1;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530583 pe_debug("SME Join Rsp is supported NSS 1X1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800584 sme_join_rsp->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800585 }
586
587 sme_join_rsp->messageType = msg_type;
588 sme_join_rsp->length = (uint16_t) rsp_len;
589 sme_join_rsp->statusCode = result_code;
590 sme_join_rsp->protStatusCode = prot_status_code;
591
592 sme_join_rsp->sessionId = sme_session_id;
593 sme_join_rsp->transactionId = sme_transaction_id;
594
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530595 lim_send_sme_join_reassoc_rsp_after_resume(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800596 (uint32_t *)sme_join_rsp);
597}
598
599/**
600 * lim_send_sme_start_bss_rsp()
601 *
602 ***FUNCTION:
603 * This function is called to send eWNI_SME_START_BSS_RSP
604 * message to applications above MAC Software.
605 *
606 ***PARAMS:
607 *
608 ***LOGIC:
609 *
610 ***ASSUMPTIONS:
611 * NA
612 *
613 ***NOTE:
614 * NA
615 *
616 * @param pMac Pointer to Global MAC structure
617 * @param msgType Indicates message type
618 * @param resultCode Indicates the result of previously issued
619 * eWNI_SME_msgType_REQ message
620 *
621 * @return None
622 */
623
624void
625lim_send_sme_start_bss_rsp(tpAniSirGlobal pMac,
626 uint16_t msgType, tSirResultCodes resultCode,
627 tpPESession psessionEntry, uint8_t smesessionId,
628 uint16_t smetransactionId)
629{
630
631 uint16_t size = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700632 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800633 tSirSmeStartBssRsp *pSirSmeRsp;
634 uint16_t ieLen;
635 uint16_t ieOffset, curLen;
636
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530637 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800638 lim_msg_str(msgType), lim_result_code_str(resultCode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800639
640 size = sizeof(tSirSmeStartBssRsp);
641
642 if (psessionEntry == NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530643 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800644 if (NULL == pSirSmeRsp) {
645 /* / Buffer not available. Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530646 pe_err("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800647 return;
648 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800649 } else {
650 /* subtract size of beaconLength + Mac Hdr + Fixed Fields before SSID */
651 ieOffset = sizeof(tAniBeaconStruct) + SIR_MAC_B_PR_SSID_OFFSET;
652 ieLen = psessionEntry->schBeaconOffsetBegin
653 + psessionEntry->schBeaconOffsetEnd - ieOffset;
654 /* calculate the memory size to allocate */
655 size += ieLen;
656
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530657 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800658 if (NULL == pSirSmeRsp) {
659 /* / Buffer not available. Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530660 pe_err("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800661 return;
662 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800663 size = sizeof(tSirSmeStartBssRsp);
664 if (resultCode == eSIR_SME_SUCCESS) {
665
666 sir_copy_mac_addr(pSirSmeRsp->bssDescription.bssId,
667 psessionEntry->bssId);
668
669 /* Read beacon interval from session */
670 pSirSmeRsp->bssDescription.beaconInterval =
671 (uint16_t) psessionEntry->beaconParams.
672 beaconInterval;
673 pSirSmeRsp->bssType = psessionEntry->bssType;
674
675 if (cfg_get_capability_info
676 (pMac, &pSirSmeRsp->bssDescription.capabilityInfo,
677 psessionEntry)
678 != eSIR_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530679 pe_err("could not retrieve Capabilities value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800680
681 lim_get_phy_mode(pMac,
682 (uint32_t *) &pSirSmeRsp->bssDescription.
683 nwType, psessionEntry);
684
685 pSirSmeRsp->bssDescription.channelId =
686 psessionEntry->currentOperChannel;
687
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700688 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800689 curLen = psessionEntry->schBeaconOffsetBegin - ieOffset;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530690 qdf_mem_copy((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800691 ieFields,
692 psessionEntry->pSchBeaconFrameBegin +
693 ieOffset, (uint32_t) curLen);
694
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530695 qdf_mem_copy(((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800696 ieFields) + curLen,
697 psessionEntry->pSchBeaconFrameEnd,
698 (uint32_t) psessionEntry->
699 schBeaconOffsetEnd);
700
Abhishek Singh34a4d862016-10-26 16:01:51 +0530701 pSirSmeRsp->bssDescription.length = (uint16_t)
702 (offsetof(tSirBssDescription, ieFields[0])
703 - sizeof(pSirSmeRsp->bssDescription.length)
704 + ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800705 /* This is the size of the message, subtracting the size of the pointer to ieFields */
706 size += ieLen - sizeof(uint32_t);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700707 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800708#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
709 if (psessionEntry->cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530710 != QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800711 pSirSmeRsp->HTProfile.
712 htSupportedChannelWidthSet =
713 psessionEntry->htSupportedChannelWidthSet;
714 pSirSmeRsp->HTProfile.htRecommendedTxWidthSet =
715 psessionEntry->htRecommendedTxWidthSet;
716 pSirSmeRsp->HTProfile.htSecondaryChannelOffset =
717 psessionEntry->htSecondaryChannelOffset;
718 pSirSmeRsp->HTProfile.dot11mode =
719 psessionEntry->dot11mode;
720 pSirSmeRsp->HTProfile.htCapability =
721 psessionEntry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800722 pSirSmeRsp->HTProfile.vhtCapability =
723 psessionEntry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800724 pSirSmeRsp->HTProfile.apCenterChan =
725 psessionEntry->ch_center_freq_seg0;
726 pSirSmeRsp->HTProfile.apChanWidth =
727 psessionEntry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800728 }
729#endif
730 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800731 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800732 pSirSmeRsp->messageType = msgType;
733 pSirSmeRsp->length = size;
734
735 /* Update SME session Id and transaction Id */
736 pSirSmeRsp->sessionId = smesessionId;
737 pSirSmeRsp->transactionId = smetransactionId;
738 pSirSmeRsp->statusCode = resultCode;
739 if (psessionEntry != NULL)
740 pSirSmeRsp->staId = psessionEntry->staId; /* else it will be always zero smeRsp StaID = 0 */
741
742 mmhMsg.type = msgType;
743 mmhMsg.bodyptr = pSirSmeRsp;
744 mmhMsg.bodyval = 0;
745 if (psessionEntry == NULL) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530746 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
747 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800748 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530749 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
750 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800751 }
752#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
753 lim_diag_event_report(pMac, WLAN_PE_DIAG_START_BSS_RSP_EVENT,
754 psessionEntry, (uint16_t) resultCode, 0);
755#endif /* FEATURE_WLAN_DIAG_SUPPORT */
756
757 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
758} /*** end lim_send_sme_start_bss_rsp() ***/
759
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800760/**
761 * lim_send_sme_scan_rsp() - Send scan response to SME
762 * @pMac: Pointer to Global MAC structure
763 * @length: Indicates length of message
764 * @resultCode: Indicates the result of previously issued
765 * eWNI_SME_SCAN_REQ message
766 * @scan_id: scan identifier
767 *
768 * This function is called by lim_process_sme_req_messages() to send
769 * eWNI_SME_SCAN_RSP message to applications above MAC
770 *
771 * return: None
772 */
773
774void
775lim_send_sme_scan_rsp(tpAniSirGlobal pMac, tSirResultCodes resultCode,
776 uint8_t smesessionId, uint16_t smetranscationId,
777 uint32_t scan_id)
778{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800779 lim_post_sme_scan_rsp_message(pMac, resultCode, smesessionId,
780 smetranscationId, scan_id);
781}
782
783/**
784 * lim_post_sme_scan_rsp_message()
785 *
786 ***FUNCTION:
787 * This function is called by lim_send_sme_scan_rsp() to send
788 * eWNI_SME_SCAN_RSP message with failed result code
789 *
790 ***NOTE:
791 * NA
792 *
793 * @param pMac Pointer to Global MAC structure
794 * @param length Indicates length of message
795 * @param resultCode failed result code
796 *
797 * @return None
798 */
799
800void
801lim_post_sme_scan_rsp_message(tpAniSirGlobal pMac,
802 tSirResultCodes resultCode, uint8_t smesessionId,
803 uint16_t smetransactionId,
804 uint32_t scan_id)
805{
806 tpSirSmeScanRsp pSirSmeScanRsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700807 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800808
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530809 pe_debug("send SME_SCAN_RSP reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800810 lim_result_code_str(resultCode));
811
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530812 pSirSmeScanRsp = qdf_mem_malloc(sizeof(tSirSmeScanRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800813 if (NULL == pSirSmeScanRsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530814 pe_err("AllocateMemory failed for eWNI_SME_SCAN_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800815 return;
816 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800817
818 pSirSmeScanRsp->messageType = eWNI_SME_SCAN_RSP;
819 pSirSmeScanRsp->statusCode = resultCode;
820
821 /*Update SME session Id and transaction Id */
822 pSirSmeScanRsp->sessionId = smesessionId;
823 pSirSmeScanRsp->transcationId = smetransactionId;
824 pSirSmeScanRsp->scan_id = scan_id;
825
826 mmhMsg.type = eWNI_SME_SCAN_RSP;
827 mmhMsg.bodyptr = pSirSmeScanRsp;
828 mmhMsg.bodyval = 0;
829
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530830 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800831#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
832 lim_diag_event_report(pMac, WLAN_PE_DIAG_SCAN_RSP_EVENT, NULL,
833 (uint16_t) resultCode, 0);
834#endif /* FEATURE_WLAN_DIAG_SUPPORT */
835
836 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
837 return;
838
839} /*** lim_post_sme_scan_rsp_message ***/
840
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800841void lim_send_sme_disassoc_deauth_ntf(tpAniSirGlobal pMac,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530842 QDF_STATUS status, uint32_t *pCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800843{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700844 struct scheduler_msg mmhMsg = {0};
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800845 struct scheduler_msg *pMsg = (struct scheduler_msg *) pCtx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800846
847 mmhMsg.type = pMsg->type;
848 mmhMsg.bodyptr = pMsg;
849 mmhMsg.bodyval = 0;
850
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530851 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800852
853 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
854}
855
856/**
857 * lim_send_sme_disassoc_ntf()
858 *
859 ***FUNCTION:
860 * This function is called by limProcessSmeMessages() to send
861 * eWNI_SME_DISASSOC_RSP/IND message to host
862 *
863 ***PARAMS:
864 *
865 ***LOGIC:
866 *
867 ***ASSUMPTIONS:
868 * NA
869 *
870 ***NOTE:
871 * This function is used for sending eWNI_SME_DISASSOC_CNF,
872 * or eWNI_SME_DISASSOC_IND to host depending on
873 * disassociation trigger.
874 *
875 * @param peerMacAddr Indicates the peer MAC addr to which
876 * disassociate was initiated
877 * @param reasonCode Indicates the reason for Disassociation
878 * @param disassocTrigger Indicates the trigger for Disassociation
879 * @param aid Indicates the STAID. This parameter is
880 * present only on AP.
881 *
882 * @return None
883 */
884void
885lim_send_sme_disassoc_ntf(tpAniSirGlobal pMac,
886 tSirMacAddr peerMacAddr,
887 tSirResultCodes reasonCode,
888 uint16_t disassocTrigger,
889 uint16_t aid,
890 uint8_t smesessionId,
891 uint16_t smetransactionId, tpPESession psessionEntry)
892{
893
894 uint8_t *pBuf;
895 tSirSmeDisassocRsp *pSirSmeDisassocRsp;
896 tSirSmeDisassocInd *pSirSmeDisassocInd;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700897 uint32_t *pMsg = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800898 bool failure = false;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700899 tpPESession session = NULL;
900 uint16_t i, assoc_id;
901 tpDphHashNode sta_ds = NULL;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530902 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800903
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530904 pe_debug("Disassoc Ntf with trigger : %d reasonCode: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800905 disassocTrigger, reasonCode);
906
907 switch (disassocTrigger) {
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700908 case eLIM_DUPLICATE_ENTRY:
909 /*
910 * Duplicate entry is removed at LIM.
911 * Initiate new entry for other session
912 */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530913 pe_debug("Rcvd eLIM_DUPLICATE_ENTRY for " MAC_ADDRESS_STR,
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700914 MAC_ADDR_ARRAY(peerMacAddr));
915
916 for (i = 0; i < pMac->lim.maxBssId; i++) {
917 if ((&pMac->lim.gpSession[i] != NULL) &&
918 (pMac->lim.gpSession[i].valid) &&
919 (pMac->lim.gpSession[i].pePersona ==
920 QDF_SAP_MODE)) {
921 /* Find the sta ds entry in another session */
922 session = &pMac->lim.gpSession[i];
923 sta_ds = dph_lookup_hash_entry(pMac,
924 peerMacAddr, &assoc_id,
925 &session->dph.dphHashTable);
Abhishek Singh6d6e3d12017-12-04 14:16:00 +0530926 if (sta_ds)
927 break;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700928 }
929 }
930 if (sta_ds
931#ifdef WLAN_FEATURE_11W
932 && (!sta_ds->rmfEnabled)
933#endif
934 ) {
935 if (lim_add_sta(pMac, sta_ds, false, session) !=
936 eSIR_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530937 pe_err("could not Add STA with assocId: %d",
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700938 sta_ds->assocId);
939 }
940 failure = true;
941 break;
942
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800943 case eLIM_HOST_DISASSOC:
944 /**
945 * Disassociation response due to
946 * host triggered disassociation
947 */
948
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530949 pSirSmeDisassocRsp = qdf_mem_malloc(sizeof(tSirSmeDisassocRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800950 if (NULL == pSirSmeDisassocRsp) {
951 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530952 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800953 failure = true;
954 goto error;
955 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530956 pe_debug("send eWNI_SME_DISASSOC_RSP with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800957 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
958 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
959 pSirSmeDisassocRsp->length = sizeof(tSirSmeDisassocRsp);
960 /* sessionId */
961 pBuf = (uint8_t *) &pSirSmeDisassocRsp->sessionId;
962 *pBuf = smesessionId;
963 pBuf++;
964
965 /* transactionId */
966 lim_copy_u16(pBuf, smetransactionId);
967 pBuf += sizeof(uint16_t);
968
969 /* statusCode */
970 lim_copy_u32(pBuf, reasonCode);
971 pBuf += sizeof(tSirResultCodes);
972
973 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530974 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800975 pBuf += sizeof(tSirMacAddr);
976
977 /* Clear Station Stats */
978 /* for sta, it is always 1, IBSS is handled at halInitSta */
979
980#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
981
982 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
983 psessionEntry, (uint16_t) reasonCode, 0);
984#endif
985 pMsg = (uint32_t *) pSirSmeDisassocRsp;
986 break;
987
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530988 case eLIM_PEER_ENTITY_DISASSOC:
989 case eLIM_LINK_MONITORING_DISASSOC:
990 sir_sme_dis_ind =
991 qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
992 if (!sir_sme_dis_ind) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530993 pe_err("call to AllocateMemory failed for disconnect indication");
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530994 return;
995 }
996
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530997 pe_debug("send eWNI_SME_DISCONNECT_DONE_IND with retCode: %d",
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530998 reasonCode);
999
1000 sir_sme_dis_ind->message_type =
1001 eWNI_SME_DISCONNECT_DONE_IND;
1002 sir_sme_dis_ind->length =
1003 sizeof(*sir_sme_dis_ind);
1004 qdf_mem_copy(sir_sme_dis_ind->peer_mac, peerMacAddr,
1005 sizeof(tSirMacAddr));
1006 sir_sme_dis_ind->session_id = smesessionId;
1007 sir_sme_dis_ind->reason_code = reasonCode;
Selvaraj, Sridharc7d80892016-09-29 11:56:45 +05301008 /*
1009 * Instead of sending deauth reason code as 505 which is
1010 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1011 * Send reason code as zero to Supplicant
1012 */
1013 if (reasonCode == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1014 sir_sme_dis_ind->reason_code = 0;
1015 else
1016 sir_sme_dis_ind->reason_code = reasonCode;
1017
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301018 pMsg = (uint32_t *)sir_sme_dis_ind;
1019
1020 break;
1021
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001022 default:
1023 /**
1024 * Disassociation indication due to Disassociation
1025 * frame reception from peer entity or due to
1026 * loss of link with peer entity.
1027 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301028 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001029 if (NULL == pSirSmeDisassocInd) {
1030 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301031 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001032 failure = true;
1033 goto error;
1034 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301035 pe_debug("send eWNI_SME_DISASSOC_IND with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001036 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1037 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
1038 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
1039
1040 /* Update SME session Id and Transaction Id */
1041 pSirSmeDisassocInd->sessionId = smesessionId;
1042 pSirSmeDisassocInd->transactionId = smetransactionId;
1043 pSirSmeDisassocInd->reasonCode = reasonCode;
1044 pBuf = (uint8_t *) &pSirSmeDisassocInd->statusCode;
1045
1046 lim_copy_u32(pBuf, reasonCode);
1047 pBuf += sizeof(tSirResultCodes);
1048
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301049 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001050 pBuf += sizeof(tSirMacAddr);
1051
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301052 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001053
1054#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1055 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
1056 psessionEntry, (uint16_t) reasonCode, 0);
1057#endif
1058 pMsg = (uint32_t *) pSirSmeDisassocInd;
1059
1060 break;
1061 }
1062
1063error:
1064 /* Delete the PE session Created */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07001065 if ((psessionEntry != NULL) && LIM_IS_STA_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001066 pe_delete_session(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001067
1068 if (false == failure)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301069 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001070 (uint32_t *) pMsg);
1071} /*** end lim_send_sme_disassoc_ntf() ***/
1072
1073/** -----------------------------------------------------------------
1074 \brief lim_send_sme_disassoc_ind() - sends SME_DISASSOC_IND
1075
1076 After receiving disassociation frame from peer entity, this
1077 function sends a eWNI_SME_DISASSOC_IND to SME with a specific
1078 reason code.
1079
1080 \param pMac - global mac structure
1081 \param pStaDs - station dph hash node
1082 \return none
1083 \sa
1084 ----------------------------------------------------------------- */
1085void
1086lim_send_sme_disassoc_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1087 tpPESession psessionEntry)
1088{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001089 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001090 tSirSmeDisassocInd *pSirSmeDisassocInd;
1091
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301092 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001093 if (NULL == pSirSmeDisassocInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301094 pe_err("AllocateMemory failed for eWNI_SME_DISASSOC_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001095 return;
1096 }
1097
1098 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
1099 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
1100
1101 pSirSmeDisassocInd->sessionId = psessionEntry->smeSessionId;
1102 pSirSmeDisassocInd->transactionId = psessionEntry->transactionId;
Padma, Santhosh Kumar02289212016-09-30 13:30:08 +05301103 pSirSmeDisassocInd->statusCode = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001104 pSirSmeDisassocInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1105
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301106 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301107 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001108
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301109 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301110 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001111
1112 pSirSmeDisassocInd->staId = pStaDs->staIndex;
1113
1114 mmhMsg.type = eWNI_SME_DISASSOC_IND;
1115 mmhMsg.bodyptr = pSirSmeDisassocInd;
1116 mmhMsg.bodyval = 0;
1117
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301118 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1119 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001120#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1121 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT, psessionEntry,
1122 0, (uint16_t) pStaDs->mlmStaContext.disassocReason);
1123#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1124
1125 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1126
1127} /*** end lim_send_sme_disassoc_ind() ***/
1128
1129/** -----------------------------------------------------------------
1130 \brief lim_send_sme_deauth_ind() - sends SME_DEAUTH_IND
1131
1132 After receiving deauthentication frame from peer entity, this
1133 function sends a eWNI_SME_DEAUTH_IND to SME with a specific
1134 reason code.
1135
1136 \param pMac - global mac structure
1137 \param pStaDs - station dph hash node
1138 \return none
1139 \sa
1140 ----------------------------------------------------------------- */
1141void
1142lim_send_sme_deauth_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1143 tpPESession psessionEntry)
1144{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001145 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001146 tSirSmeDeauthInd *pSirSmeDeauthInd;
1147
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301148 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001149 if (NULL == pSirSmeDeauthInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301150 pe_err("AllocateMemory failed for eWNI_SME_DEAUTH_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001151 return;
1152 }
1153
1154 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1155 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1156
1157 pSirSmeDeauthInd->sessionId = psessionEntry->smeSessionId;
1158 pSirSmeDeauthInd->transactionId = psessionEntry->transactionId;
1159 if (eSIR_INFRA_AP_MODE == psessionEntry->bssType) {
1160 pSirSmeDeauthInd->statusCode =
1161 (tSirResultCodes) pStaDs->mlmStaContext.cleanupTrigger;
1162 } else {
1163 /* Need to indicatet he reascon code over the air */
1164 pSirSmeDeauthInd->statusCode =
1165 (tSirResultCodes) pStaDs->mlmStaContext.disassocReason;
1166 }
1167 /* BSSID */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301168 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301169 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001170 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301171 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301172 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001173 pSirSmeDeauthInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1174
1175 pSirSmeDeauthInd->staId = pStaDs->staIndex;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001176 if (eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON ==
1177 pStaDs->mlmStaContext.disassocReason)
1178 pSirSmeDeauthInd->rssi = pStaDs->del_sta_ctx_rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001179
1180 mmhMsg.type = eWNI_SME_DEAUTH_IND;
1181 mmhMsg.bodyptr = pSirSmeDeauthInd;
1182 mmhMsg.bodyval = 0;
1183
1184 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1185#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1186 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT, psessionEntry,
1187 0, pStaDs->mlmStaContext.cleanupTrigger);
1188#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1189
1190 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1191 return;
1192} /*** end lim_send_sme_deauth_ind() ***/
1193
1194#ifdef FEATURE_WLAN_TDLS
1195/**
1196 * lim_send_sme_tdls_del_sta_ind()
1197 *
1198 ***FUNCTION:
1199 * This function is called to send the TDLS STA context deletion to SME.
1200 *
1201 ***LOGIC:
1202 *
1203 ***ASSUMPTIONS:
1204 *
1205 ***NOTE:
1206 * NA
1207 *
1208 * @param pMac - Pointer to global MAC structure
1209 * @param pStaDs - Pointer to internal STA Datastructure
1210 * @param psessionEntry - Pointer to the session entry
1211 * @param reasonCode - Reason for TDLS sta deletion
1212 * @return None
1213 */
1214void
1215lim_send_sme_tdls_del_sta_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1216 tpPESession psessionEntry, uint16_t reasonCode)
1217{
Frank Liud1a28462017-09-06 22:55:48 +08001218 struct tdls_event_info info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001219
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301220 pe_debug("Delete TDLS Peer "MAC_ADDRESS_STR "with reason code: %d",
Nitesh Shah82c52812016-12-27 12:27:51 +05301221 MAC_ADDR_ARRAY(pStaDs->staAddr), reasonCode);
Frank Liud1a28462017-09-06 22:55:48 +08001222 info.vdev_id = psessionEntry->smeSessionId;
1223 qdf_mem_copy(info.peermac.bytes, pStaDs->staAddr, QDF_MAC_ADDR_SIZE);
1224 info.message_type = TDLS_PEER_DISCONNECTED;
1225 info.peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001226
Frank Liud1a28462017-09-06 22:55:48 +08001227 tgt_tdls_event_handler(pMac->psoc, &info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001228
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001229 return;
1230} /*** end lim_send_sme_tdls_del_sta_ind() ***/
1231
1232/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001233 * lim_send_sme_mgmt_tx_completion()
1234 *
1235 ***FUNCTION:
1236 * This function is called to send the eWNI_SME_MGMT_FRM_TX_COMPLETION_IND
1237 * message to SME.
1238 *
1239 ***LOGIC:
1240 *
1241 ***ASSUMPTIONS:
1242 *
1243 ***NOTE:
1244 * NA
1245 *
1246 * @param pMac - Pointer to global MAC structure
1247 * @param psessionEntry - Pointer to the session entry
1248 * @param txCompleteStatus - TX Complete Status of Mgmt Frames
1249 * @return None
1250 */
1251void
1252lim_send_sme_mgmt_tx_completion(tpAniSirGlobal pMac,
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301253 uint32_t sme_session_id,
1254 uint32_t txCompleteStatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001255{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001256 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001257 tSirMgmtTxCompletionInd *pSirMgmtTxCompletionInd;
1258
1259 pSirMgmtTxCompletionInd =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301260 qdf_mem_malloc(sizeof(tSirMgmtTxCompletionInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001261 if (NULL == pSirMgmtTxCompletionInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301262 pe_err("AllocateMemory failed for eWNI_SME_MGMT_FRM_TX_COMPLETION_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001263 return;
1264 }
1265 /* messageType */
1266 pSirMgmtTxCompletionInd->messageType =
1267 eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1268 pSirMgmtTxCompletionInd->length = sizeof(tSirMgmtTxCompletionInd);
1269
1270 /* sessionId */
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301271 pSirMgmtTxCompletionInd->sessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001272
1273 pSirMgmtTxCompletionInd->txCompleteStatus = txCompleteStatus;
1274
1275 mmhMsg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1276 mmhMsg.bodyptr = pSirMgmtTxCompletionInd;
1277 mmhMsg.bodyval = 0;
1278
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07001279 pSirMgmtTxCompletionInd->psoc = pMac->psoc;
1280 mmhMsg.callback = tgt_tdls_send_mgmt_tx_completion;
1281 scheduler_post_msg(QDF_MODULE_ID_TARGET_IF, &mmhMsg);
1282 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001283} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1284
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001285#endif /* FEATURE_WLAN_TDLS */
1286
1287/**
1288 * lim_send_sme_deauth_ntf()
1289 *
1290 ***FUNCTION:
1291 * This function is called by limProcessSmeMessages() to send
1292 * eWNI_SME_DISASSOC_RSP/IND message to host
1293 *
1294 ***PARAMS:
1295 *
1296 ***LOGIC:
1297 *
1298 ***ASSUMPTIONS:
1299 * NA
1300 *
1301 ***NOTE:
1302 * This function is used for sending eWNI_SME_DEAUTH_CNF or
1303 * eWNI_SME_DEAUTH_IND to host depending on deauthentication trigger.
1304 *
1305 * @param peerMacAddr Indicates the peer MAC addr to which
1306 * deauthentication was initiated
1307 * @param reasonCode Indicates the reason for Deauthetication
1308 * @param deauthTrigger Indicates the trigger for Deauthetication
1309 * @param aid Indicates the STAID. This parameter is present
1310 * only on AP.
1311 *
1312 * @return None
1313 */
1314void
1315lim_send_sme_deauth_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
1316 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1317 uint16_t aid, uint8_t smesessionId,
1318 uint16_t smetransactionId)
1319{
1320 uint8_t *pBuf;
1321 tSirSmeDeauthRsp *pSirSmeDeauthRsp;
1322 tSirSmeDeauthInd *pSirSmeDeauthInd;
1323 tpPESession psessionEntry;
1324 uint8_t sessionId;
1325 uint32_t *pMsg;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301326 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001327
1328 psessionEntry = pe_find_session_by_bssid(pMac, peerMacAddr, &sessionId);
1329 switch (deauthTrigger) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001330 case eLIM_HOST_DEAUTH:
1331 /**
1332 * Deauthentication response to host triggered
1333 * deauthentication.
1334 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301335 pSirSmeDeauthRsp = qdf_mem_malloc(sizeof(tSirSmeDeauthRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001336 if (NULL == pSirSmeDeauthRsp) {
1337 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301338 pe_err("call to AllocateMemory failed for eWNI_SME_DEAUTH_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001339 return;
1340 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301341 pe_debug("send eWNI_SME_DEAUTH_RSP with retCode: %d for" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001342 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1343 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
1344 pSirSmeDeauthRsp->length = sizeof(tSirSmeDeauthRsp);
1345 pSirSmeDeauthRsp->statusCode = reasonCode;
1346 pSirSmeDeauthRsp->sessionId = smesessionId;
1347 pSirSmeDeauthRsp->transactionId = smetransactionId;
1348
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -08001349 pBuf = (uint8_t *) pSirSmeDeauthRsp->peer_macaddr.bytes;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301350 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001351
1352#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1353 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
1354 psessionEntry, 0, (uint16_t) reasonCode);
1355#endif
1356 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1357
1358 break;
1359
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301360 case eLIM_PEER_ENTITY_DEAUTH:
1361 case eLIM_LINK_MONITORING_DEAUTH:
1362 sir_sme_dis_ind =
1363 qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
1364 if (!sir_sme_dis_ind) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301365 pe_err("call to AllocateMemory failed for disconnect indication");
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301366 return;
1367 }
1368
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301369 pe_debug("send eWNI_SME_DISCONNECT_DONE_IND withretCode: %d",
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301370 reasonCode);
1371
1372 sir_sme_dis_ind->message_type =
1373 eWNI_SME_DISCONNECT_DONE_IND;
1374 sir_sme_dis_ind->length =
1375 sizeof(*sir_sme_dis_ind);
1376 sir_sme_dis_ind->session_id = smesessionId;
1377 sir_sme_dis_ind->reason_code = reasonCode;
1378 qdf_mem_copy(sir_sme_dis_ind->peer_mac, peerMacAddr,
1379 ETH_ALEN);
Selvaraj, Sridharc7d80892016-09-29 11:56:45 +05301380 /*
1381 * Instead of sending deauth reason code as 505 which is
1382 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1383 * Send reason code as zero to Supplicant
1384 */
1385 if (reasonCode == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1386 sir_sme_dis_ind->reason_code = 0;
1387 else
1388 sir_sme_dis_ind->reason_code = reasonCode;
1389
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301390 pMsg = (uint32_t *)sir_sme_dis_ind;
1391
1392 break;
1393
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001394 default:
1395 /**
1396 * Deauthentication indication due to Deauthentication
1397 * frame reception from peer entity or due to
1398 * loss of link with peer entity.
1399 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301400 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001401 if (NULL == pSirSmeDeauthInd) {
1402 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301403 pe_err("call to AllocateMemory failed for eWNI_SME_DEAUTH_Ind");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001404 return;
1405 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301406 pe_debug("send eWNI_SME_DEAUTH_IND with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001407 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1408 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1409 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1410 pSirSmeDeauthInd->reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
1411
1412 /* sessionId */
1413 pBuf = (uint8_t *) &pSirSmeDeauthInd->sessionId;
1414 *pBuf++ = smesessionId;
1415
1416 /* transaction ID */
1417 lim_copy_u16(pBuf, smetransactionId);
1418 pBuf += sizeof(uint16_t);
1419
1420 /* status code */
1421 lim_copy_u32(pBuf, reasonCode);
1422 pBuf += sizeof(tSirResultCodes);
1423
1424 /* bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301425 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001426 pBuf += sizeof(tSirMacAddr);
1427
1428 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301429 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301430 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001431
1432#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1433 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
1434 psessionEntry, 0, (uint16_t) reasonCode);
1435#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1436 pMsg = (uint32_t *) pSirSmeDeauthInd;
1437
1438 break;
1439 }
1440
1441 /*Delete the PE session created */
1442 if (psessionEntry != NULL) {
1443 pe_delete_session(pMac, psessionEntry);
1444 }
1445
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301446 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001447 (uint32_t *) pMsg);
1448
1449} /*** end lim_send_sme_deauth_ntf() ***/
1450
1451/**
1452 * lim_send_sme_wm_status_change_ntf() - Send Notification
1453 * @mac_ctx: Global MAC Context
1454 * @status_change_code: Indicates the change in the wireless medium.
1455 * @status_change_info: Indicates the information associated with
1456 * change in the wireless medium.
1457 * @info_len: Indicates the length of status change information
1458 * being sent.
1459 * @session_id SessionID
1460 *
1461 * This function is called by limProcessSmeMessages() to send
1462 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1463 *
1464 * Return: None
1465 */
1466void
1467lim_send_sme_wm_status_change_ntf(tpAniSirGlobal mac_ctx,
1468 tSirSmeStatusChangeCode status_change_code,
1469 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1470{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001471 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001472 tSirSmeWmStatusChangeNtf *wm_status_change_ntf;
Naveen Rawate01ed172016-11-17 11:34:50 -08001473 uint32_t max_info_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001474
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301475 wm_status_change_ntf = qdf_mem_malloc(sizeof(tSirSmeWmStatusChangeNtf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001476 if (NULL == wm_status_change_ntf) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301477 pe_err("Mem Alloc failed - eWNI_SME_WM_STATUS_CHANGE_NTF");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001478 return;
1479 }
1480
1481 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1482 msg.bodyval = 0;
1483 msg.bodyptr = wm_status_change_ntf;
1484
1485 switch (status_change_code) {
Naveen Rawate01ed172016-11-17 11:34:50 -08001486 case eSIR_SME_AP_CAPS_CHANGED:
1487 max_info_len = sizeof(tSirSmeApNewCaps);
1488 break;
1489 case eSIR_SME_JOINED_NEW_BSS:
1490 max_info_len = sizeof(tSirSmeNewBssInfo);
1491 break;
1492 default:
1493 max_info_len = sizeof(wm_status_change_ntf->statusChangeInfo);
1494 break;
1495 }
1496
1497 switch (status_change_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001498 case eSIR_SME_RADAR_DETECTED:
1499 break;
1500 default:
1501 wm_status_change_ntf->messageType =
1502 eWNI_SME_WM_STATUS_CHANGE_NTF;
1503 wm_status_change_ntf->statusChangeCode = status_change_code;
1504 wm_status_change_ntf->length = sizeof(tSirSmeWmStatusChangeNtf);
1505 wm_status_change_ntf->sessionId = session_id;
Naveen Rawate01ed172016-11-17 11:34:50 -08001506 if (info_len <= max_info_len && status_change_info) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301507 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001508 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1509 (uint8_t *) status_change_info, info_len);
1510 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301511 pe_debug("StatusChg code: 0x%x length: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001512 status_change_code, info_len);
1513 break;
1514 }
1515
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301516 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001517 if (eSIR_SUCCESS != lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301518 qdf_mem_free(wm_status_change_ntf);
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301519 pe_err("lim_sys_process_mmh_msg_api failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001520 }
1521
1522} /*** end lim_send_sme_wm_status_change_ntf() ***/
1523
1524/**
1525 * lim_send_sme_set_context_rsp()
1526 *
1527 ***FUNCTION:
1528 * This function is called by limProcessSmeMessages() to send
1529 * eWNI_SME_SETCONTEXT_RSP message to host
1530 *
1531 ***PARAMS:
1532 *
1533 ***LOGIC:
1534 *
1535 ***ASSUMPTIONS:
1536 * NA
1537 *
1538 ***NOTE:
1539 *
1540 * @param pMac Pointer to Global MAC structure
1541 * @param peerMacAddr Indicates the peer MAC addr to which
1542 * setContext was performed
1543 * @param aid Indicates the aid corresponding to the peer MAC
1544 * address
1545 * @param resultCode Indicates the result of previously issued
1546 * eWNI_SME_SETCONTEXT_RSP message
1547 *
1548 * @return None
1549 */
1550void
1551lim_send_sme_set_context_rsp(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301552 struct qdf_mac_addr peer_macaddr, uint16_t aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001553 tSirResultCodes resultCode,
1554 tpPESession psessionEntry, uint8_t smesessionId,
1555 uint16_t smetransactionId)
1556{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001557 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001558 tSirSmeSetContextRsp *pSirSmeSetContextRsp;
1559
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301560 pSirSmeSetContextRsp = qdf_mem_malloc(sizeof(tSirSmeSetContextRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001561 if (NULL == pSirSmeSetContextRsp) {
1562 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301563 pe_err("call to AllocateMemory failed for SmeSetContextRsp");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001564 return;
1565 }
1566
1567 pSirSmeSetContextRsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1568 pSirSmeSetContextRsp->length = sizeof(tSirSmeSetContextRsp);
1569 pSirSmeSetContextRsp->statusCode = resultCode;
1570
Anurag Chouhanc5548422016-02-24 18:33:27 +05301571 qdf_copy_macaddr(&pSirSmeSetContextRsp->peer_macaddr, &peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001572
1573 /* Update SME session and transaction Id */
1574 pSirSmeSetContextRsp->sessionId = smesessionId;
1575 pSirSmeSetContextRsp->transactionId = smetransactionId;
1576
1577 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
1578 mmhMsg.bodyptr = pSirSmeSetContextRsp;
1579 mmhMsg.bodyval = 0;
1580 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301581 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1582 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001583 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301584 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1585 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001586 }
1587
1588#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1589 lim_diag_event_report(pMac, WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
1590 psessionEntry, (uint16_t) resultCode, 0);
1591#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1592
1593 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1594} /*** end lim_send_sme_set_context_rsp() ***/
1595
1596/**
1597 * lim_send_sme_neighbor_bss_ind()
1598 *
1599 ***FUNCTION:
1600 * This function is called by lim_lookup_nadd_hash_entry() to send
1601 * eWNI_SME_NEIGHBOR_BSS_IND message to host
1602 *
1603 ***PARAMS:
1604 *
1605 ***LOGIC:
1606 *
1607 ***ASSUMPTIONS:
1608 * NA
1609 *
1610 ***NOTE:
1611 * This function is used for sending eWNI_SME_NEIGHBOR_BSS_IND to
1612 * host upon detecting new BSS during background scanning if CFG
1613 * option is enabled for sending such indication
1614 *
1615 * @param pMac - Pointer to Global MAC structure
1616 * @return None
1617 */
1618
1619void
1620lim_send_sme_neighbor_bss_ind(tpAniSirGlobal pMac, tLimScanResultNode *pBssDescr)
1621{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001622 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001623 uint32_t val;
1624 tSirSmeNeighborBssInd *pNewBssInd;
1625
1626 if ((pMac->lim.gLimSmeState != eLIM_SME_LINK_EST_WT_SCAN_STATE) ||
1627 ((pMac->lim.gLimSmeState == eLIM_SME_LINK_EST_WT_SCAN_STATE) &&
1628 pMac->lim.gLimRspReqd)) {
1629 /* LIM is not in background scan state OR */
1630 /* current scan is initiated by HDD. */
1631 /* No need to send new BSS indication to HDD */
1632 return;
1633 }
1634
1635 if (wlan_cfg_get_int(pMac, WNI_CFG_NEW_BSS_FOUND_IND, &val) !=
1636 eSIR_SUCCESS) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301637 pe_err("could not get NEIGHBOR_BSS_IND from CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001638 return;
1639 }
1640
1641 if (val == 0)
1642 return;
1643
1644 /**
1645 * Need to indicate new BSSs found during
1646 * background scanning to host.
1647 * Allocate buffer for sending indication.
1648 * Length of buffer is length of BSS description
1649 * and length of header itself
1650 */
1651 val = pBssDescr->bssDescription.length + sizeof(uint16_t) +
1652 sizeof(uint32_t) + sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301653 pNewBssInd = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001654 if (NULL == pNewBssInd) {
1655 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301656 pe_err("call to AllocateMemory failed for eWNI_SME_NEIGHBOR_BSS_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001657 return;
1658 }
1659
1660 pNewBssInd->messageType = eWNI_SME_NEIGHBOR_BSS_IND;
1661 pNewBssInd->length = (uint16_t) val;
1662 pNewBssInd->sessionId = 0;
1663
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301664 qdf_mem_copy((uint8_t *) pNewBssInd->bssDescription,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001665 (uint8_t *) &pBssDescr->bssDescription,
1666 pBssDescr->bssDescription.length + sizeof(uint16_t));
1667
1668 msgQ.type = eWNI_SME_NEIGHBOR_BSS_IND;
1669 msgQ.bodyptr = pNewBssInd;
1670 msgQ.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301671 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, msgQ.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001672 lim_sys_process_mmh_msg_api(pMac, &msgQ, ePROT);
1673} /*** end lim_send_sme_neighbor_bss_ind() ***/
1674
1675/** -----------------------------------------------------------------
1676 \brief lim_send_sme_addts_rsp() - sends SME ADDTS RSP
1677 \ This function sends a eWNI_SME_ADDTS_RSP to SME.
1678 \ SME only looks at rc and tspec field.
1679 \param pMac - global mac structure
1680 \param rspReqd - is SmeAddTsRsp required
1681 \param status - status code of SME_ADD_TS_RSP
1682 \return tspec
1683 \sa
1684 ----------------------------------------------------------------- */
1685void
1686lim_send_sme_addts_rsp(tpAniSirGlobal pMac, uint8_t rspReqd, uint32_t status,
1687 tpPESession psessionEntry, tSirMacTspecIE tspec,
1688 uint8_t smesessionId, uint16_t smetransactionId)
1689{
1690 tpSirAddtsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001691 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001692
1693 if (!rspReqd)
1694 return;
1695
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301696 rsp = qdf_mem_malloc(sizeof(tSirAddtsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001697 if (NULL == rsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301698 pe_err("AllocateMemory failed for ADDTS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001699 return;
1700 }
1701
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001702 rsp->messageType = eWNI_SME_ADDTS_RSP;
1703 rsp->rc = status;
1704 rsp->rsp.status = (enum eSirMacStatusCodes)status;
1705 rsp->rsp.tspec = tspec;
1706 /* Update SME session Id and transcation Id */
1707 rsp->sessionId = smesessionId;
1708 rsp->transactionId = smetransactionId;
1709
1710 mmhMsg.type = eWNI_SME_ADDTS_RSP;
1711 mmhMsg.bodyptr = rsp;
1712 mmhMsg.bodyval = 0;
1713 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301714 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1715 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001716 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301717 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1718 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001719 }
1720#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1721 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_RSP_EVENT, psessionEntry, 0,
1722 0);
1723#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1724
1725 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1726 return;
1727}
1728
1729void
1730lim_send_sme_delts_rsp(tpAniSirGlobal pMac, tpSirDeltsReq delts, uint32_t status,
1731 tpPESession psessionEntry, uint8_t smesessionId,
1732 uint16_t smetransactionId)
1733{
1734 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001735 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001736
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301737 pe_debug("SendSmeDeltsRsp aid: %d tsid: %d up: %d status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001738 delts->aid,
1739 delts->req.tsinfo.traffic.tsid,
1740 delts->req.tsinfo.traffic.userPrio, status);
1741 if (!delts->rspReqd)
1742 return;
1743
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301744 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001745 if (NULL == rsp) {
1746 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301747 pe_err("AllocateMemory failed for DELTS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001748 return;
1749 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001750
1751 if (psessionEntry != NULL) {
1752
1753 rsp->aid = delts->aid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301754 qdf_copy_macaddr(&rsp->macaddr, &delts->macaddr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301755 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) &delts->req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001756 sizeof(tSirDeltsReqInfo));
1757 }
1758
1759 rsp->messageType = eWNI_SME_DELTS_RSP;
1760 rsp->rc = status;
1761
1762 /* Update SME session Id and transcation Id */
1763 rsp->sessionId = smesessionId;
1764 rsp->transactionId = smetransactionId;
1765
1766 mmhMsg.type = eWNI_SME_DELTS_RSP;
1767 mmhMsg.bodyptr = rsp;
1768 mmhMsg.bodyval = 0;
1769 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301770 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1771 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001772 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301773 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1774 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001775 }
1776#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1777 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_RSP_EVENT, psessionEntry,
1778 (uint16_t) status, 0);
1779#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1780
1781 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1782}
1783
1784void
1785lim_send_sme_delts_ind(tpAniSirGlobal pMac, tpSirDeltsReqInfo delts, uint16_t aid,
1786 tpPESession psessionEntry)
1787{
1788 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001789 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001790
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301791 pe_debug("SendSmeDeltsInd aid: %d tsid: %d up: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001792 aid, delts->tsinfo.traffic.tsid, delts->tsinfo.traffic.userPrio);
1793
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301794 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001795 if (NULL == rsp) {
1796 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301797 pe_err("AllocateMemory failed for DELTS_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001798 return;
1799 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001800
1801 rsp->messageType = eWNI_SME_DELTS_IND;
1802 rsp->rc = eSIR_SUCCESS;
1803 rsp->aid = aid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301804 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) delts, sizeof(*delts));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001805
1806 /* Update SME session Id and SME transaction Id */
1807
1808 rsp->sessionId = psessionEntry->smeSessionId;
1809 rsp->transactionId = psessionEntry->transactionId;
1810
1811 mmhMsg.type = eWNI_SME_DELTS_IND;
1812 mmhMsg.bodyptr = rsp;
1813 mmhMsg.bodyval = 0;
1814 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1815#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1816 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_IND_EVENT, psessionEntry, 0,
1817 0);
1818#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1819
1820 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1821}
1822
1823/**
1824 * lim_send_sme_pe_statistics_rsp()
1825 *
1826 ***FUNCTION:
1827 * This function is called to send 802.11 statistics response to HDD.
1828 * This function posts the result back to HDD. This is a response to
1829 * HDD's request for statistics.
1830 *
1831 ***PARAMS:
1832 *
1833 ***LOGIC:
1834 *
1835 ***ASSUMPTIONS:
1836 * NA
1837 *
1838 ***NOTE:
1839 * NA
1840 *
1841 * @param pMac Pointer to Global MAC structure
1842 * @param p80211Stats Statistics sent in response
1843 * @param resultCode TODO:
1844 *
1845 *
1846 * @return none
1847 */
1848
1849void
1850lim_send_sme_pe_statistics_rsp(tpAniSirGlobal pMac, uint16_t msgType, void *stats)
1851{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001852 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001853 uint8_t sessionId;
1854 tAniGetPEStatsRsp *pPeStats = (tAniGetPEStatsRsp *) stats;
1855 tpPESession pPeSessionEntry;
1856
1857 /* Get the Session Id based on Sta Id */
1858 pPeSessionEntry =
1859 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1860
1861 /* Fill the Session Id */
1862 if (NULL != pPeSessionEntry) {
1863 /* Fill the Session Id */
1864 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1865 }
1866
1867 pPeStats->msgType = eWNI_SME_GET_STATISTICS_RSP;
1868
1869 /* msgType should be WMA_GET_STATISTICS_RSP */
1870 mmhMsg.type = eWNI_SME_GET_STATISTICS_RSP;
1871
1872 mmhMsg.bodyptr = stats;
1873 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301874 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001875 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1876
1877 return;
1878
1879} /*** end lim_send_sme_pe_statistics_rsp() ***/
1880
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001881#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001882/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001883 * lim_send_sme_pe_ese_tsm_rsp() - send tsm response
1884 * @pMac: Pointer to global pMac structure
1885 * @pStats: Pointer to TSM Stats
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001886 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001887 * This function is called to send tsm stats response to HDD.
1888 * This function posts the result back to HDD. This is a response to
1889 * HDD's request to get tsm stats.
1890 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001891 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001892 */
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001893void lim_send_sme_pe_ese_tsm_rsp(tpAniSirGlobal pMac,
1894 tAniGetTsmStatsRsp *pStats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001895{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001896 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001897 uint8_t sessionId;
1898 tAniGetTsmStatsRsp *pPeStats = (tAniGetTsmStatsRsp *) pStats;
1899 tpPESession pPeSessionEntry = NULL;
1900
1901 /* Get the Session Id based on Sta Id */
1902 pPeSessionEntry =
1903 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1904
1905 /* Fill the Session Id */
1906 if (NULL != pPeSessionEntry) {
1907 /* Fill the Session Id */
1908 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1909 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301910 pe_err("Session not found for the Sta id: %d",
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301911 pPeStats->staId);
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05301912 qdf_mem_free(pPeStats->tsmStatsReq);
1913 qdf_mem_free(pPeStats);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001914 return;
1915 }
1916
1917 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
1918 pPeStats->tsmMetrics.RoamingCount
1919 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
1920 pPeStats->tsmMetrics.RoamingDly
1921 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
1922
1923 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
1924 mmhMsg.bodyptr = pStats;
1925 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301926 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001927 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1928
1929 return;
1930} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
1931
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001932#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001933
1934void
1935lim_send_sme_ibss_peer_ind(tpAniSirGlobal pMac,
1936 tSirMacAddr peerMacAddr,
1937 uint16_t staIndex,
1938 uint8_t ucastIdx,
1939 uint8_t bcastIdx,
1940 uint8_t *beacon,
1941 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
1942{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001943 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001944 tSmeIbssPeerInd *pNewPeerInd;
1945
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301946 pNewPeerInd = qdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001947 if (NULL == pNewPeerInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301948 pe_err("Failed to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001949 return;
1950 }
1951
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301952 qdf_mem_copy((uint8_t *) pNewPeerInd->peer_addr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301953 peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001954 pNewPeerInd->staId = staIndex;
1955 pNewPeerInd->ucastSig = ucastIdx;
1956 pNewPeerInd->bcastSig = bcastIdx;
1957 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
1958 pNewPeerInd->mesgType = msgType;
1959 pNewPeerInd->sessionId = sessionId;
1960
1961 if (beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301962 qdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001963 sizeof(tSmeIbssPeerInd)), (void *)beacon,
1964 beaconLen);
1965 }
1966
1967 mmhMsg.type = msgType;
1968 mmhMsg.bodyptr = pNewPeerInd;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301969 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001970 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1971
1972}
1973
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07001974/**
1975 * lim_process_csa_wbw_ie() - Process CSA Wide BW IE
1976 * @mac_ctx: pointer to global adapter context
1977 * @csa_params: pointer to CSA parameters
1978 * @chnl_switch_info:pointer to channel switch parameters
1979 * @session_entry: session pointer
1980 *
1981 * Return: None
1982 */
1983static void lim_process_csa_wbw_ie(tpAniSirGlobal mac_ctx,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001984 struct csa_offload_params *csa_params,
1985 tLimWiderBWChannelSwitchInfo *chnl_switch_info,
1986 tpPESession session_entry)
1987{
Amar Singhal5cccafe2017-02-15 12:42:58 -08001988 struct ch_params ch_params = {0};
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001989 uint8_t ap_new_ch_width;
1990 bool new_ch_width_dfn = false;
1991 uint8_t center_freq_diff;
1992
1993 ap_new_ch_width = csa_params->new_ch_width + 1;
1994 if ((ap_new_ch_width == CH_WIDTH_80MHZ) &&
1995 csa_params->new_ch_freq_seg2) {
1996 new_ch_width_dfn = true;
1997 if (csa_params->new_ch_freq_seg2 >
1998 csa_params->new_ch_freq_seg1)
1999 center_freq_diff = csa_params->new_ch_freq_seg2 -
2000 csa_params->new_ch_freq_seg1;
2001 else
2002 center_freq_diff = csa_params->new_ch_freq_seg1 -
2003 csa_params->new_ch_freq_seg2;
2004 if (center_freq_diff == CENTER_FREQ_DIFF_160MHz)
2005 ap_new_ch_width = CH_WIDTH_160MHZ;
2006 else if (center_freq_diff > CENTER_FREQ_DIFF_80P80MHz)
2007 ap_new_ch_width = CH_WIDTH_80P80MHZ;
2008 else
2009 ap_new_ch_width = CH_WIDTH_80MHZ;
2010 }
2011 session_entry->gLimChannelSwitch.state =
2012 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2013 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
2014 !new_ch_width_dfn) {
2015 ch_params.ch_width = CH_WIDTH_160MHZ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002016 wlan_reg_set_channel_params(mac_ctx->pdev,
2017 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002018 ap_new_ch_width = ch_params.ch_width;
2019 csa_params->new_ch_freq_seg1 = ch_params.center_freq_seg0;
2020 csa_params->new_ch_freq_seg2 = ch_params.center_freq_seg1;
2021 }
2022 chnl_switch_info->newChanWidth = ap_new_ch_width;
2023 chnl_switch_info->newCenterChanFreq0 = csa_params->new_ch_freq_seg1;
2024 chnl_switch_info->newCenterChanFreq1 = csa_params->new_ch_freq_seg2;
2025
2026 if (session_entry->ch_width == ap_new_ch_width)
2027 goto prnt_log;
2028
2029 if (session_entry->ch_width == CH_WIDTH_80MHZ) {
2030 chnl_switch_info->newChanWidth = CH_WIDTH_80MHZ;
2031 chnl_switch_info->newCenterChanFreq1 = 0;
2032 } else {
2033 session_entry->ch_width = ap_new_ch_width;
2034 chnl_switch_info->newChanWidth = ap_new_ch_width;
2035 }
2036prnt_log:
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302037 pe_debug("new channel: %d new_ch_width: %d seg0: %d seg1: %d",
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002038 csa_params->channel,
2039 chnl_switch_info->newChanWidth,
2040 chnl_switch_info->newCenterChanFreq0,
2041 chnl_switch_info->newCenterChanFreq1);
2042}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002043/**
2044 * lim_handle_csa_offload_msg() - Handle CSA offload message
2045 * @mac_ctx: pointer to global adapter context
2046 * @msg: Message pointer.
2047 *
2048 * Return: None
2049 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08002050void lim_handle_csa_offload_msg(tpAniSirGlobal mac_ctx,
2051 struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002052{
2053 tpPESession session_entry;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002054 struct scheduler_msg mmh_msg = {0};
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302055 struct csa_offload_params *csa_params =
2056 (struct csa_offload_params *) (msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002057 tpSmeCsaOffloadInd csa_offload_ind;
2058 tpDphHashNode sta_ds = NULL;
2059 uint8_t session_id;
2060 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302061 uint16_t chan_space = 0;
Amar Singhal5cccafe2017-02-15 12:42:58 -08002062 struct ch_params ch_params;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302063
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002064 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002065 tLimChannelSwitchInfo *lim_ch_switch = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002066
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302067 pe_debug("handle csa offload msg");
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302068
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002069 if (!csa_params) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302070 pe_err("limMsgQ body ptr is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002071 return;
2072 }
2073
2074 session_entry =
2075 pe_find_session_by_bssid(mac_ctx,
2076 csa_params->bssId, &session_id);
2077 if (!session_entry) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302078 pe_err("Session does not exists for %pM",
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302079 csa_params->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002080 goto err;
2081 }
2082
2083 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
2084 &session_entry->dph.dphHashTable);
2085
2086 if (!sta_ds) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302087 pe_err("sta_ds does not exist");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002088 goto err;
2089 }
2090
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002091 if (!LIM_IS_STA_ROLE(session_entry)) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302092 pe_debug("Invalid role to handle CSA");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002093 goto err;
2094 }
Masti, Narayanraddi1c630442015-11-02 12:03:50 +05302095
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002096 /*
2097 * on receiving channel switch announcement from AP, delete all
2098 * TDLS peers before leaving BSS and proceed for channel switch
2099 */
2100 lim_delete_tdls_peers(mac_ctx, session_entry);
Gupta, Kapil121bf212015-11-25 19:21:29 +05302101
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002102 lim_ch_switch = &session_entry->gLimChannelSwitch;
2103 session_entry->gLimChannelSwitch.switchMode =
2104 csa_params->switch_mode;
2105 /* timer already started by firmware, switch immediately */
2106 session_entry->gLimChannelSwitch.switchCount = 0;
2107 session_entry->gLimChannelSwitch.primaryChannel =
2108 csa_params->channel;
2109 session_entry->gLimChannelSwitch.state =
2110 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2111 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
2112 lim_ch_switch->sec_ch_offset =
2113 session_entry->htSecondaryChannelOffset;
2114 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
2115 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
2116 chnl_switch_info =
2117 &session_entry->gLimWiderBWChannelSwitch;
2118
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302119 pe_debug("vht: %d ht: %d flag: %x chan: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302120 session_entry->vhtCapability,
2121 session_entry->htSupportedChannelWidthSet,
2122 csa_params->ies_present_flag,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002123 csa_params->channel);
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302124 pe_debug("seg1: %d seg2: %d width: %d country: %s class: %d",
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002125 csa_params->new_ch_freq_seg1,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302126 csa_params->new_ch_freq_seg2,
2127 csa_params->new_ch_width,
2128 mac_ctx->scan.countryCodeCurrent,
2129 csa_params->new_op_class);
2130
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002131 if (session_entry->vhtCapability &&
2132 session_entry->htSupportedChannelWidthSet) {
Kiran Kumar Lokere47127482017-12-20 18:09:55 -08002133 if (csa_params->ies_present_flag & lim_wbw_ie_present &&
2134 csa_params->new_ch_width) {
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07002135 lim_process_csa_wbw_ie(mac_ctx, csa_params,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002136 chnl_switch_info, session_entry);
2137 lim_ch_switch->sec_ch_offset =
Abhishek Singhaf639b42017-06-16 14:14:36 +05302138 PHY_SINGLE_CHANNEL_CENTERED;
2139 if (chnl_switch_info->newChanWidth) {
2140 if (csa_params->channel <
2141 csa_params->new_ch_freq_seg1)
2142 lim_ch_switch->sec_ch_offset =
2143 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
2144 else
2145 lim_ch_switch->sec_ch_offset =
2146 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
2147 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002148 } else if (csa_params->ies_present_flag
2149 & lim_xcsa_ie_present) {
2150 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002151 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002152 mac_ctx->scan.countryCodeCurrent,
2153 csa_params->channel,
2154 csa_params->new_op_class);
2155 session_entry->gLimChannelSwitch.state =
2156 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2157
2158 if (chan_space == 80) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002159 chnl_switch_info->newChanWidth =
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002160 CH_WIDTH_80MHZ;
2161 } else if (chan_space == 40) {
2162 chnl_switch_info->newChanWidth =
2163 CH_WIDTH_40MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002164 } else {
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002165 chnl_switch_info->newChanWidth =
2166 CH_WIDTH_20MHZ;
2167 lim_ch_switch->state =
2168 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2169 }
2170
2171 ch_params.ch_width =
2172 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002173 wlan_reg_set_channel_params(mac_ctx->pdev,
2174 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002175 chnl_switch_info->newCenterChanFreq0 =
2176 ch_params.center_freq_seg0;
2177 /*
2178 * This is not applicable for 20/40/80 MHz.
2179 * Only used when we support 80+80 MHz operation.
2180 * In case of 80+80 MHz, this parameter indicates
2181 * center channel frequency index of 80 MHz
2182 * channel offrequency segment 1.
2183 */
2184 chnl_switch_info->newCenterChanFreq1 =
2185 ch_params.center_freq_seg1;
2186 lim_ch_switch->sec_ch_offset =
2187 ch_params.sec_ch_offset;
2188
Kiran Kumar Lokere47127482017-12-20 18:09:55 -08002189 } else {
2190 lim_ch_switch->state =
2191 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2192 ch_params.ch_width = CH_WIDTH_40MHZ;
2193 wlan_reg_set_channel_params(mac_ctx->pdev,
2194 csa_params->channel, 0, &ch_params);
2195 lim_ch_switch->sec_ch_offset =
2196 ch_params.sec_ch_offset;
2197 chnl_switch_info->newChanWidth = CH_WIDTH_40MHZ;
2198 chnl_switch_info->newCenterChanFreq0 =
2199 ch_params.center_freq_seg0;
2200 chnl_switch_info->newCenterChanFreq1 = 0;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002201 }
2202 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
2203 chnl_switch_info->newCenterChanFreq0;
2204 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
2205 chnl_switch_info->newCenterChanFreq1;
2206 session_entry->gLimChannelSwitch.ch_width =
2207 chnl_switch_info->newChanWidth;
2208
2209 } else if (session_entry->htSupportedChannelWidthSet) {
2210 if (csa_params->ies_present_flag
2211 & lim_xcsa_ie_present) {
2212 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002213 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002214 mac_ctx->scan.countryCodeCurrent,
2215 csa_params->channel,
2216 csa_params->new_op_class);
2217 lim_ch_switch->state =
2218 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2219 if (chan_space == 40) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002220 lim_ch_switch->ch_width =
2221 CH_WIDTH_40MHZ;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002222 chnl_switch_info->newChanWidth =
2223 CH_WIDTH_40MHZ;
2224 ch_params.ch_width =
2225 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002226 wlan_reg_set_channel_params(mac_ctx->pdev,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002227 csa_params->channel,
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07002228 0, &ch_params);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002229 lim_ch_switch->ch_center_freq_seg0 =
2230 ch_params.center_freq_seg0;
2231 lim_ch_switch->sec_ch_offset =
2232 ch_params.sec_ch_offset;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002233 } else {
2234 lim_ch_switch->ch_width =
2235 CH_WIDTH_20MHZ;
2236 chnl_switch_info->newChanWidth =
2237 CH_WIDTH_40MHZ;
2238 lim_ch_switch->state =
2239 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2240 lim_ch_switch->sec_ch_offset =
2241 PHY_SINGLE_CHANNEL_CENTERED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002242 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002243 } else {
2244 lim_ch_switch->ch_width =
2245 CH_WIDTH_40MHZ;
2246 lim_ch_switch->state =
2247 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2248 ch_params.ch_width = CH_WIDTH_40MHZ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002249 wlan_reg_set_channel_params(mac_ctx->pdev,
2250 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002251 lim_ch_switch->ch_center_freq_seg0 =
2252 ch_params.center_freq_seg0;
2253 lim_ch_switch->sec_ch_offset =
2254 ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002255 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002256
2257 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302258 pe_debug("new ch width: %d space: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302259 session_entry->gLimChannelSwitch.ch_width, chan_space);
Kiran Kumar Lokere75d636f2016-12-20 14:52:03 -08002260 if ((session_entry->currentOperChannel == csa_params->channel) &&
2261 (session_entry->ch_width ==
2262 session_entry->gLimChannelSwitch.ch_width)) {
2263 pe_debug("Ignore CSA, no change in ch and bw");
2264 goto err;
2265 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002266
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002267 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
2268 csa_offload_ind = qdf_mem_malloc(sizeof(tSmeCsaOffloadInd));
2269 if (NULL == csa_offload_ind) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302270 pe_err("memalloc fail eWNI_SME_CSA_OFFLOAD_EVENT");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002271 goto err;
2272 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002273
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002274 csa_offload_ind->mesgType = eWNI_SME_CSA_OFFLOAD_EVENT;
2275 csa_offload_ind->mesgLen = sizeof(tSmeCsaOffloadInd);
2276 qdf_mem_copy(csa_offload_ind->bssid.bytes, session_entry->bssId,
2277 QDF_MAC_ADDR_SIZE);
2278 mmh_msg.type = eWNI_SME_CSA_OFFLOAD_EVENT;
2279 mmh_msg.bodyptr = csa_offload_ind;
2280 mmh_msg.bodyval = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302281 pe_debug("Sending eWNI_SME_CSA_OFFLOAD_EVENT to SME");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002282 MTRACE(mac_trace_msg_tx
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002283 (mac_ctx, session_entry->peSessionId, mmh_msg.type));
2284#ifdef FEATURE_WLAN_DIAG_SUPPORT
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002285 lim_diag_event_report(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002286 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
2287 eSIR_SUCCESS, eSIR_SUCCESS);
2288#endif
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002289 lim_sys_process_mmh_msg_api(mac_ctx, &mmh_msg, ePROT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002290
2291err:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302292 qdf_mem_free(csa_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002293}
2294
2295/*--------------------------------------------------------------------------
2296 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
2297
2298 \param pMac - pointer to global adapter context
2299 \param sessionId - Message pointer.
2300
2301 \sa
2302 --------------------------------------------------------------------------*/
2303
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002304void lim_handle_delete_bss_rsp(tpAniSirGlobal pMac, struct scheduler_msg *MsgQ)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002305{
2306 tpPESession psessionEntry;
2307 tpDeleteBssParams pDelBss = (tpDeleteBssParams) (MsgQ->bodyptr);
2308
2309 psessionEntry =
2310 pe_find_session_by_session_id(pMac, pDelBss->sessionId);
2311 if (psessionEntry == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302312 pe_err("Session Does not exist for given sessionID: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002313 pDelBss->sessionId);
Naveen Rawat0c81edc2016-06-08 10:08:30 -07002314 qdf_mem_free(MsgQ->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002315 return;
2316 }
Krunal Sonie50ff452017-10-11 18:23:55 -07002317
2318 /*
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002319 * During DEL BSS handling, the PE Session will be deleted, but it is
2320 * better to clear this flag if the session is hanging around due
2321 * to some error conditions so that the next DEL_BSS request does
2322 * not take the HO_FAIL path
2323 */
2324 psessionEntry->process_ho_fail = false;
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002325 if (LIM_IS_IBSS_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002326 lim_ibss_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002327 else if (LIM_IS_UNKNOWN_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002328 lim_process_sme_del_bss_rsp(pMac, MsgQ->bodyval, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002329 else if (LIM_IS_NDI_ROLE(psessionEntry))
2330 lim_ndi_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002331 else
2332 lim_process_mlm_del_bss_rsp(pMac, MsgQ, psessionEntry);
2333
2334}
2335
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002336/** -----------------------------------------------------------------
2337 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
2338 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
2339 \ SME only looks at rc and tspec field.
2340 \param pMac - global mac structure
2341 \param rspReqd - is SmeAddTsRsp required
2342 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
2343 \return tspec
2344 \sa
2345 ----------------------------------------------------------------- */
2346void
2347lim_send_sme_aggr_qos_rsp(tpAniSirGlobal pMac, tpSirAggrQosRsp aggrQosRsp,
2348 uint8_t smesessionId)
2349{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002350 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002351
2352 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
2353 mmhMsg.bodyptr = aggrQosRsp;
2354 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302355 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2356 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002357 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2358
2359 return;
2360}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002361
2362void lim_send_sme_max_assoc_exceeded_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
2363 uint8_t smesessionId)
2364{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002365 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002366 tSmeMaxAssocInd *pSmeMaxAssocInd;
2367
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302368 pSmeMaxAssocInd = qdf_mem_malloc(sizeof(tSmeMaxAssocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002369 if (NULL == pSmeMaxAssocInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302370 pe_err("Failed to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002371 return;
2372 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302373 qdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peer_mac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302374 (uint8_t *) peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002375 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
2376 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
2377 pSmeMaxAssocInd->sessionId = smesessionId;
2378 mmhMsg.type = pSmeMaxAssocInd->mesgType;
2379 mmhMsg.bodyptr = pSmeMaxAssocInd;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302380 pe_debug("msgType: %s peerMacAddr "MAC_ADDRESS_STR "sme session id %d",
2381 "eWNI_SME_MAX_ASSOC_EXCEEDED", MAC_ADDR_ARRAY(peerMacAddr),
2382 pSmeMaxAssocInd->sessionId);
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302383 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2384 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002385 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2386
2387 return;
2388}
2389
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002390/*--------------------------------------------------------------------------
2391 \brief lim_send_dfs_chan_sw_ie_update()
2392 This timer handler updates the channel switch IE in beacon template
2393
2394 \param pMac - pointer to global adapter context
2395 \return - channel to scan from valid session else zero.
2396 \sa
2397 --------------------------------------------------------------------------*/
2398static void
2399lim_send_dfs_chan_sw_ie_update(tpAniSirGlobal pMac, tpPESession psessionEntry)
2400{
2401
2402 /* Update the beacon template and send to FW */
2403 if (sch_set_fixed_beacon_fields(pMac, psessionEntry) != eSIR_SUCCESS) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302404 pe_err("Unable to set CSA IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002405 return;
2406 }
2407
2408 /* Send update beacon template message */
2409 lim_send_beacon_ind(pMac, psessionEntry);
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302410 pe_debug("Updated CSA IE, IE COUNT: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002411 psessionEntry->gLimChannelSwitch.switchCount);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002412
2413 return;
2414}
2415
2416/** -----------------------------------------------------------------
2417 \brief lim_send_sme_ap_channel_switch_resp() - sends
2418 eWNI_SME_CHANNEL_CHANGE_RSP
2419 After receiving WMA_SWITCH_CHANNEL_RSP indication this
2420 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
2421 that the Channel change has been done to the specified target
2422 channel in the Channel change request
2423 \param pMac - global mac structure
2424 \param psessionEntry - session info
2425 \param pChnlParams - Channel switch params
2426 --------------------------------------------------------------------*/
2427void
2428lim_send_sme_ap_channel_switch_resp(tpAniSirGlobal pMac,
2429 tpPESession psessionEntry,
2430 tpSwitchChannelParams pChnlParams)
2431{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002432 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002433 tpSwitchChannelParams pSmeSwithChnlParams;
2434 uint8_t channelId;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002435 bool is_ch_dfs = false;
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08002436 enum phy_ch_width ch_width;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002437 uint8_t ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002438
2439 pSmeSwithChnlParams = (tSwitchChannelParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302440 qdf_mem_malloc(sizeof(tSwitchChannelParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002441 if (NULL == pSmeSwithChnlParams) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302442 pe_err("AllocateMemory failed for pSmeSwithChnlParams");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002443 return;
2444 }
2445
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302446 qdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002447 sizeof(tSwitchChannelParams));
2448
2449 channelId = pSmeSwithChnlParams->channelNumber;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002450 ch_width = pSmeSwithChnlParams->ch_width;
2451 ch_center_freq_seg1 = pSmeSwithChnlParams->ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002452
2453 /*
2454 * Pass the sme sessionID to SME instead
2455 * PE session ID.
2456 */
2457 pSmeSwithChnlParams->peSessionId = psessionEntry->smeSessionId;
2458
2459 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
2460 mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
2461 mmhMsg.bodyval = 0;
2462 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2463
2464 /*
2465 * We should start beacon transmission only if the new
2466 * channel after channel change is Non-DFS. For a DFS
2467 * channel, PE will receive an explicit request from
2468 * upper layers to start the beacon transmission .
2469 */
2470
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002471 if (ch_width == CH_WIDTH_160MHZ) {
2472 is_ch_dfs = true;
2473 } else if (ch_width == CH_WIDTH_80P80MHZ) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002474 if (wlan_reg_get_channel_state(pMac->pdev, channelId) ==
2475 CHANNEL_STATE_DFS ||
2476 wlan_reg_get_channel_state(pMac->pdev,
2477 ch_center_freq_seg1 -
2478 SIR_80MHZ_START_CENTER_CH_DIFF) ==
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002479 CHANNEL_STATE_DFS)
2480 is_ch_dfs = true;
2481 } else {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002482 if (wlan_reg_get_channel_state(pMac->pdev, channelId) ==
2483 CHANNEL_STATE_DFS)
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002484 is_ch_dfs = true;
2485 }
2486
2487 if (!is_ch_dfs) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002488 if (channelId == psessionEntry->currentOperChannel) {
2489 lim_apply_configuration(pMac, psessionEntry);
2490 lim_send_beacon_ind(pMac, psessionEntry);
2491 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302492 pe_debug("Failed to Transmit Beacons on channel: %d after AP channel change response",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002493 psessionEntry->bcnLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002494 }
Arif Hussain1513cb22018-01-05 19:56:31 -08002495
2496 lim_obss_send_detection_cfg(pMac, psessionEntry, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002497 }
2498 return;
2499}
2500
Peng Xu6363ec62017-05-15 11:06:33 -07002501#ifdef WLAN_FEATURE_11AX_BSS_COLOR
2502/**
2503 * lim_send_bss_color_change_ie_update() - update bss color change IE in
2504 * beacon template
2505 *
2506 * @mac_ctx: pointer to global adapter context
2507 * @session: session pointer
2508 *
2509 * Return: none
2510 */
2511static void
2512lim_send_bss_color_change_ie_update(tpAniSirGlobal mac_ctx,
2513 tpPESession session)
2514{
2515 /* Update the beacon template and send to FW */
2516 if (sch_set_fixed_beacon_fields(mac_ctx, session) != eSIR_SUCCESS) {
2517 pe_err("Unable to set BSS color change IE in beacon");
2518 return;
2519 }
2520
2521 /* Send update beacon template message */
2522 lim_send_beacon_ind(mac_ctx, session);
2523 pe_info("Updated BSS color change countdown = %d",
2524 session->he_bss_color_change.countdown);
2525}
2526
2527static void
2528lim_handle_bss_color_change_ie(tpAniSirGlobal mac_ctx,
2529 tpPESession session)
2530{
2531 /* handle bss color change IE */
2532 if (LIM_IS_AP_ROLE(session) &&
2533 session->he_op.bss_col_disabled) {
2534 if (session->he_bss_color_change.countdown > 0) {
2535 session->he_bss_color_change.countdown--;
2536 } else {
2537 session->bss_color_changing = 0;
Arif Hussain05fb4872018-01-03 16:02:55 -08002538 if (session->he_bss_color_change.new_color != 0) {
Peng Xu6363ec62017-05-15 11:06:33 -07002539 session->he_op.bss_col_disabled = 0;
Arif Hussain05fb4872018-01-03 16:02:55 -08002540 session->he_op.bss_color =
2541 session->he_bss_color_change.new_color;
2542 lim_send_obss_color_collision_cfg(mac_ctx,
2543 session,
2544 OBSS_COLOR_COLLISION_DETECTION);
2545 }
Peng Xu6363ec62017-05-15 11:06:33 -07002546 }
2547
2548 lim_send_bss_color_change_ie_update(mac_ctx, session);
2549 }
2550}
2551
2552#else
2553static void
2554lim_handle_bss_color_change_ie(tpAniSirGlobal mac_ctx,
2555 tpPESession session)
2556{
2557}
2558#endif
2559
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002560/** -----------------------------------------------------------------
2561 \brief lim_process_beacon_tx_success_ind() - This function is used
2562 explicitely to handle successful beacon transmission indication
2563 from the FW. This is a generic event generated by the FW afer the
2564 first beacon is sent out after the beacon template update by the
2565 host
2566 \param pMac - global mac structure
2567 \param psessionEntry - session info
2568 \return none
2569 \sa
2570 ----------------------------------------------------------------- */
2571void
2572lim_process_beacon_tx_success_ind(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2573{
2574 /* Currently, this event is used only for DFS channel switch announcement
2575 * IE update in the template. If required to be used for other IE updates
2576 * add appropriate code by introducing a state variable
2577 */
2578 tpPESession psessionEntry;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002579 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002580 tSirSmeCSAIeTxCompleteRsp *pChanSwTxResponse;
2581 struct sir_beacon_tx_complete_rsp *beacon_tx_comp_rsp_ptr;
2582 uint8_t length = sizeof(tSirSmeCSAIeTxCompleteRsp);
2583 tpSirFirstBeaconTxCompleteInd pBcnTxInd =
2584 (tSirFirstBeaconTxCompleteInd *) event;
lifeng1c16b6b2017-09-25 13:59:55 +08002585 uint8_t ch, ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002586
2587 psessionEntry = pe_find_session_by_bss_idx(pMac, pBcnTxInd->bssIdx);
2588 if (psessionEntry == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302589 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002590 return;
2591 }
2592
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302593 pe_debug("role: %d swIe: %d opIe: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302594 GET_LIM_SYSTEM_ROLE(psessionEntry),
2595 psessionEntry->dfsIncludeChanSwIe,
2596 psessionEntry->gLimOperatingMode.present);
2597
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002598 if (LIM_IS_AP_ROLE(psessionEntry) &&
2599 true == psessionEntry->dfsIncludeChanSwIe) {
Ganesh Kondabattini02ec62b2018-01-24 18:22:24 +05302600
2601 if (psessionEntry->gLimChannelSwitch.switchCount) {
2602 /* Decrement the beacon switch count */
2603 psessionEntry->gLimChannelSwitch.switchCount--;
2604 pe_debug("current beacon count %d",
2605 psessionEntry->gLimChannelSwitch.switchCount);
2606 }
2607
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002608 /* Send only 5 beacons with CSA IE Set in when a radar is detected */
2609 if (psessionEntry->gLimChannelSwitch.switchCount > 0) {
2610 /*
2611 * Send the next beacon with updated CSA IE count
2612 */
2613 lim_send_dfs_chan_sw_ie_update(pMac, psessionEntry);
lifeng1c16b6b2017-09-25 13:59:55 +08002614
2615 ch = psessionEntry->gLimChannelSwitch.primaryChannel;
2616 ch_width = psessionEntry->gLimChannelSwitch.ch_width;
2617 if (pMac->sap.SapDfsInfo.dfs_beacon_tx_enhanced)
2618 /* Send Action frame after updating beacon */
2619 lim_send_chan_switch_action_frame(pMac,
2620 ch, ch_width, psessionEntry);
2621
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002622 } else {
2623 /* Done with CSA IE update, send response back to SME */
2624 psessionEntry->gLimChannelSwitch.switchCount = 0;
2625 if (pMac->sap.SapDfsInfo.disable_dfs_ch_switch == false)
2626 psessionEntry->gLimChannelSwitch.switchMode = 0;
2627 psessionEntry->dfsIncludeChanSwIe = false;
2628 psessionEntry->dfsIncludeChanWrapperIe = false;
2629
2630 pChanSwTxResponse = (tSirSmeCSAIeTxCompleteRsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302631 qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002632
2633 if (NULL == pChanSwTxResponse) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302634 pe_err("AllocateMemory failed for tSirSmeCSAIeTxCompleteRsp");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002635 return;
2636 }
2637
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002638 pChanSwTxResponse->sessionId =
2639 psessionEntry->smeSessionId;
2640 pChanSwTxResponse->chanSwIeTxStatus =
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302641 QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002642
2643 mmhMsg.type = eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND;
2644 mmhMsg.bodyptr = pChanSwTxResponse;
2645 mmhMsg.bodyval = 0;
2646 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2647 }
2648 }
2649
2650 if (LIM_IS_AP_ROLE(psessionEntry) &&
2651 psessionEntry->gLimOperatingMode.present) {
2652 /* Done with nss update, send response back to SME */
2653 psessionEntry->gLimOperatingMode.present = 0;
2654 beacon_tx_comp_rsp_ptr = (struct sir_beacon_tx_complete_rsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302655 qdf_mem_malloc(sizeof(*beacon_tx_comp_rsp_ptr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002656 if (NULL == beacon_tx_comp_rsp_ptr) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302657 pe_err("AllocateMemory failed for beacon_tx_comp_rsp_ptr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002658 return;
2659 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002660 beacon_tx_comp_rsp_ptr->session_id =
2661 psessionEntry->smeSessionId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302662 beacon_tx_comp_rsp_ptr->tx_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002663 mmhMsg.type = eWNI_SME_NSS_UPDATE_RSP;
2664 mmhMsg.bodyptr = beacon_tx_comp_rsp_ptr;
2665 mmhMsg.bodyval = 0;
2666 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2667 }
Peng Xu6363ec62017-05-15 11:06:33 -07002668
2669 lim_handle_bss_color_change_ie(pMac, psessionEntry);
2670
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002671 return;
2672}