blob: 666f6e0ce4462a5c0c4b437fecea7da4995b28af [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Nitesh Shah82c52812016-12-27 12:27:51 +05302 * Copyright (c) 2012-2017 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);
926 }
927 }
928 if (sta_ds
929#ifdef WLAN_FEATURE_11W
930 && (!sta_ds->rmfEnabled)
931#endif
932 ) {
933 if (lim_add_sta(pMac, sta_ds, false, session) !=
934 eSIR_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530935 pe_err("could not Add STA with assocId: %d",
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700936 sta_ds->assocId);
937 }
938 failure = true;
939 break;
940
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800941 case eLIM_HOST_DISASSOC:
942 /**
943 * Disassociation response due to
944 * host triggered disassociation
945 */
946
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530947 pSirSmeDisassocRsp = qdf_mem_malloc(sizeof(tSirSmeDisassocRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800948 if (NULL == pSirSmeDisassocRsp) {
949 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530950 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800951 failure = true;
952 goto error;
953 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530954 pe_debug("send eWNI_SME_DISASSOC_RSP with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800955 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
956 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
957 pSirSmeDisassocRsp->length = sizeof(tSirSmeDisassocRsp);
958 /* sessionId */
959 pBuf = (uint8_t *) &pSirSmeDisassocRsp->sessionId;
960 *pBuf = smesessionId;
961 pBuf++;
962
963 /* transactionId */
964 lim_copy_u16(pBuf, smetransactionId);
965 pBuf += sizeof(uint16_t);
966
967 /* statusCode */
968 lim_copy_u32(pBuf, reasonCode);
969 pBuf += sizeof(tSirResultCodes);
970
971 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530972 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800973 pBuf += sizeof(tSirMacAddr);
974
975 /* Clear Station Stats */
976 /* for sta, it is always 1, IBSS is handled at halInitSta */
977
978#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
979
980 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
981 psessionEntry, (uint16_t) reasonCode, 0);
982#endif
983 pMsg = (uint32_t *) pSirSmeDisassocRsp;
984 break;
985
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530986 case eLIM_PEER_ENTITY_DISASSOC:
987 case eLIM_LINK_MONITORING_DISASSOC:
988 sir_sme_dis_ind =
989 qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
990 if (!sir_sme_dis_ind) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530991 pe_err("call to AllocateMemory failed for disconnect indication");
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530992 return;
993 }
994
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530995 pe_debug("send eWNI_SME_DISCONNECT_DONE_IND with retCode: %d",
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530996 reasonCode);
997
998 sir_sme_dis_ind->message_type =
999 eWNI_SME_DISCONNECT_DONE_IND;
1000 sir_sme_dis_ind->length =
1001 sizeof(*sir_sme_dis_ind);
1002 qdf_mem_copy(sir_sme_dis_ind->peer_mac, peerMacAddr,
1003 sizeof(tSirMacAddr));
1004 sir_sme_dis_ind->session_id = smesessionId;
1005 sir_sme_dis_ind->reason_code = reasonCode;
Selvaraj, Sridharc7d80892016-09-29 11:56:45 +05301006 /*
1007 * Instead of sending deauth reason code as 505 which is
1008 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1009 * Send reason code as zero to Supplicant
1010 */
1011 if (reasonCode == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1012 sir_sme_dis_ind->reason_code = 0;
1013 else
1014 sir_sme_dis_ind->reason_code = reasonCode;
1015
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301016 pMsg = (uint32_t *)sir_sme_dis_ind;
1017
1018 break;
1019
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001020 default:
1021 /**
1022 * Disassociation indication due to Disassociation
1023 * frame reception from peer entity or due to
1024 * loss of link with peer entity.
1025 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301026 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001027 if (NULL == pSirSmeDisassocInd) {
1028 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301029 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001030 failure = true;
1031 goto error;
1032 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301033 pe_debug("send eWNI_SME_DISASSOC_IND with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001034 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1035 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
1036 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
1037
1038 /* Update SME session Id and Transaction Id */
1039 pSirSmeDisassocInd->sessionId = smesessionId;
1040 pSirSmeDisassocInd->transactionId = smetransactionId;
1041 pSirSmeDisassocInd->reasonCode = reasonCode;
1042 pBuf = (uint8_t *) &pSirSmeDisassocInd->statusCode;
1043
1044 lim_copy_u32(pBuf, reasonCode);
1045 pBuf += sizeof(tSirResultCodes);
1046
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301047 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001048 pBuf += sizeof(tSirMacAddr);
1049
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301050 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001051
1052#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1053 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
1054 psessionEntry, (uint16_t) reasonCode, 0);
1055#endif
1056 pMsg = (uint32_t *) pSirSmeDisassocInd;
1057
1058 break;
1059 }
1060
1061error:
1062 /* Delete the PE session Created */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07001063 if ((psessionEntry != NULL) && LIM_IS_STA_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001064 pe_delete_session(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001065
1066 if (false == failure)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301067 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001068 (uint32_t *) pMsg);
1069} /*** end lim_send_sme_disassoc_ntf() ***/
1070
1071/** -----------------------------------------------------------------
1072 \brief lim_send_sme_disassoc_ind() - sends SME_DISASSOC_IND
1073
1074 After receiving disassociation frame from peer entity, this
1075 function sends a eWNI_SME_DISASSOC_IND to SME with a specific
1076 reason code.
1077
1078 \param pMac - global mac structure
1079 \param pStaDs - station dph hash node
1080 \return none
1081 \sa
1082 ----------------------------------------------------------------- */
1083void
1084lim_send_sme_disassoc_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1085 tpPESession psessionEntry)
1086{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001087 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001088 tSirSmeDisassocInd *pSirSmeDisassocInd;
1089
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301090 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001091 if (NULL == pSirSmeDisassocInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301092 pe_err("AllocateMemory failed for eWNI_SME_DISASSOC_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001093 return;
1094 }
1095
1096 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
1097 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
1098
1099 pSirSmeDisassocInd->sessionId = psessionEntry->smeSessionId;
1100 pSirSmeDisassocInd->transactionId = psessionEntry->transactionId;
Padma, Santhosh Kumar02289212016-09-30 13:30:08 +05301101 pSirSmeDisassocInd->statusCode = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001102 pSirSmeDisassocInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1103
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301104 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301105 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001106
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301107 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301108 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001109
1110 pSirSmeDisassocInd->staId = pStaDs->staIndex;
1111
1112 mmhMsg.type = eWNI_SME_DISASSOC_IND;
1113 mmhMsg.bodyptr = pSirSmeDisassocInd;
1114 mmhMsg.bodyval = 0;
1115
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301116 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1117 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001118#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1119 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT, psessionEntry,
1120 0, (uint16_t) pStaDs->mlmStaContext.disassocReason);
1121#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1122
1123 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1124
1125} /*** end lim_send_sme_disassoc_ind() ***/
1126
1127/** -----------------------------------------------------------------
1128 \brief lim_send_sme_deauth_ind() - sends SME_DEAUTH_IND
1129
1130 After receiving deauthentication frame from peer entity, this
1131 function sends a eWNI_SME_DEAUTH_IND to SME with a specific
1132 reason code.
1133
1134 \param pMac - global mac structure
1135 \param pStaDs - station dph hash node
1136 \return none
1137 \sa
1138 ----------------------------------------------------------------- */
1139void
1140lim_send_sme_deauth_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1141 tpPESession psessionEntry)
1142{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001143 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001144 tSirSmeDeauthInd *pSirSmeDeauthInd;
1145
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301146 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001147 if (NULL == pSirSmeDeauthInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301148 pe_err("AllocateMemory failed for eWNI_SME_DEAUTH_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001149 return;
1150 }
1151
1152 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1153 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1154
1155 pSirSmeDeauthInd->sessionId = psessionEntry->smeSessionId;
1156 pSirSmeDeauthInd->transactionId = psessionEntry->transactionId;
1157 if (eSIR_INFRA_AP_MODE == psessionEntry->bssType) {
1158 pSirSmeDeauthInd->statusCode =
1159 (tSirResultCodes) pStaDs->mlmStaContext.cleanupTrigger;
1160 } else {
1161 /* Need to indicatet he reascon code over the air */
1162 pSirSmeDeauthInd->statusCode =
1163 (tSirResultCodes) pStaDs->mlmStaContext.disassocReason;
1164 }
1165 /* BSSID */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301166 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301167 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001168 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301169 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301170 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001171 pSirSmeDeauthInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1172
1173 pSirSmeDeauthInd->staId = pStaDs->staIndex;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001174 if (eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON ==
1175 pStaDs->mlmStaContext.disassocReason)
1176 pSirSmeDeauthInd->rssi = pStaDs->del_sta_ctx_rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001177
1178 mmhMsg.type = eWNI_SME_DEAUTH_IND;
1179 mmhMsg.bodyptr = pSirSmeDeauthInd;
1180 mmhMsg.bodyval = 0;
1181
1182 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1183#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1184 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT, psessionEntry,
1185 0, pStaDs->mlmStaContext.cleanupTrigger);
1186#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1187
1188 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1189 return;
1190} /*** end lim_send_sme_deauth_ind() ***/
1191
1192#ifdef FEATURE_WLAN_TDLS
1193/**
1194 * lim_send_sme_tdls_del_sta_ind()
1195 *
1196 ***FUNCTION:
1197 * This function is called to send the TDLS STA context deletion to SME.
1198 *
1199 ***LOGIC:
1200 *
1201 ***ASSUMPTIONS:
1202 *
1203 ***NOTE:
1204 * NA
1205 *
1206 * @param pMac - Pointer to global MAC structure
1207 * @param pStaDs - Pointer to internal STA Datastructure
1208 * @param psessionEntry - Pointer to the session entry
1209 * @param reasonCode - Reason for TDLS sta deletion
1210 * @return None
1211 */
1212void
1213lim_send_sme_tdls_del_sta_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1214 tpPESession psessionEntry, uint16_t reasonCode)
1215{
Frank Liud1a28462017-09-06 22:55:48 +08001216 struct tdls_event_info info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001217
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301218 pe_debug("Delete TDLS Peer "MAC_ADDRESS_STR "with reason code: %d",
Nitesh Shah82c52812016-12-27 12:27:51 +05301219 MAC_ADDR_ARRAY(pStaDs->staAddr), reasonCode);
Frank Liud1a28462017-09-06 22:55:48 +08001220 info.vdev_id = psessionEntry->smeSessionId;
1221 qdf_mem_copy(info.peermac.bytes, pStaDs->staAddr, QDF_MAC_ADDR_SIZE);
1222 info.message_type = TDLS_PEER_DISCONNECTED;
1223 info.peer_reason = TDLS_DISCONNECTED_PEER_DELETE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001224
Frank Liud1a28462017-09-06 22:55:48 +08001225 tgt_tdls_event_handler(pMac->psoc, &info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001226
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001227 return;
1228} /*** end lim_send_sme_tdls_del_sta_ind() ***/
1229
1230/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001231 * lim_send_sme_mgmt_tx_completion()
1232 *
1233 ***FUNCTION:
1234 * This function is called to send the eWNI_SME_MGMT_FRM_TX_COMPLETION_IND
1235 * message to SME.
1236 *
1237 ***LOGIC:
1238 *
1239 ***ASSUMPTIONS:
1240 *
1241 ***NOTE:
1242 * NA
1243 *
1244 * @param pMac - Pointer to global MAC structure
1245 * @param psessionEntry - Pointer to the session entry
1246 * @param txCompleteStatus - TX Complete Status of Mgmt Frames
1247 * @return None
1248 */
1249void
1250lim_send_sme_mgmt_tx_completion(tpAniSirGlobal pMac,
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301251 uint32_t sme_session_id,
1252 uint32_t txCompleteStatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001253{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001254 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001255 tSirMgmtTxCompletionInd *pSirMgmtTxCompletionInd;
1256
1257 pSirMgmtTxCompletionInd =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301258 qdf_mem_malloc(sizeof(tSirMgmtTxCompletionInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001259 if (NULL == pSirMgmtTxCompletionInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301260 pe_err("AllocateMemory failed for eWNI_SME_MGMT_FRM_TX_COMPLETION_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001261 return;
1262 }
1263 /* messageType */
1264 pSirMgmtTxCompletionInd->messageType =
1265 eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1266 pSirMgmtTxCompletionInd->length = sizeof(tSirMgmtTxCompletionInd);
1267
1268 /* sessionId */
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301269 pSirMgmtTxCompletionInd->sessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001270
1271 pSirMgmtTxCompletionInd->txCompleteStatus = txCompleteStatus;
1272
1273 mmhMsg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1274 mmhMsg.bodyptr = pSirMgmtTxCompletionInd;
1275 mmhMsg.bodyval = 0;
1276
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07001277 pSirMgmtTxCompletionInd->psoc = pMac->psoc;
1278 mmhMsg.callback = tgt_tdls_send_mgmt_tx_completion;
1279 scheduler_post_msg(QDF_MODULE_ID_TARGET_IF, &mmhMsg);
1280 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001281} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1282
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001283#endif /* FEATURE_WLAN_TDLS */
1284
1285/**
1286 * lim_send_sme_deauth_ntf()
1287 *
1288 ***FUNCTION:
1289 * This function is called by limProcessSmeMessages() to send
1290 * eWNI_SME_DISASSOC_RSP/IND message to host
1291 *
1292 ***PARAMS:
1293 *
1294 ***LOGIC:
1295 *
1296 ***ASSUMPTIONS:
1297 * NA
1298 *
1299 ***NOTE:
1300 * This function is used for sending eWNI_SME_DEAUTH_CNF or
1301 * eWNI_SME_DEAUTH_IND to host depending on deauthentication trigger.
1302 *
1303 * @param peerMacAddr Indicates the peer MAC addr to which
1304 * deauthentication was initiated
1305 * @param reasonCode Indicates the reason for Deauthetication
1306 * @param deauthTrigger Indicates the trigger for Deauthetication
1307 * @param aid Indicates the STAID. This parameter is present
1308 * only on AP.
1309 *
1310 * @return None
1311 */
1312void
1313lim_send_sme_deauth_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
1314 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1315 uint16_t aid, uint8_t smesessionId,
1316 uint16_t smetransactionId)
1317{
1318 uint8_t *pBuf;
1319 tSirSmeDeauthRsp *pSirSmeDeauthRsp;
1320 tSirSmeDeauthInd *pSirSmeDeauthInd;
1321 tpPESession psessionEntry;
1322 uint8_t sessionId;
1323 uint32_t *pMsg;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301324 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325
1326 psessionEntry = pe_find_session_by_bssid(pMac, peerMacAddr, &sessionId);
1327 switch (deauthTrigger) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001328 case eLIM_HOST_DEAUTH:
1329 /**
1330 * Deauthentication response to host triggered
1331 * deauthentication.
1332 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301333 pSirSmeDeauthRsp = qdf_mem_malloc(sizeof(tSirSmeDeauthRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001334 if (NULL == pSirSmeDeauthRsp) {
1335 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301336 pe_err("call to AllocateMemory failed for eWNI_SME_DEAUTH_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001337 return;
1338 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301339 pe_debug("send eWNI_SME_DEAUTH_RSP with retCode: %d for" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001340 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1341 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
1342 pSirSmeDeauthRsp->length = sizeof(tSirSmeDeauthRsp);
1343 pSirSmeDeauthRsp->statusCode = reasonCode;
1344 pSirSmeDeauthRsp->sessionId = smesessionId;
1345 pSirSmeDeauthRsp->transactionId = smetransactionId;
1346
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -08001347 pBuf = (uint8_t *) pSirSmeDeauthRsp->peer_macaddr.bytes;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301348 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001349
1350#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1351 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
1352 psessionEntry, 0, (uint16_t) reasonCode);
1353#endif
1354 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1355
1356 break;
1357
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301358 case eLIM_PEER_ENTITY_DEAUTH:
1359 case eLIM_LINK_MONITORING_DEAUTH:
1360 sir_sme_dis_ind =
1361 qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
1362 if (!sir_sme_dis_ind) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301363 pe_err("call to AllocateMemory failed for disconnect indication");
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301364 return;
1365 }
1366
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301367 pe_debug("send eWNI_SME_DISCONNECT_DONE_IND withretCode: %d",
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301368 reasonCode);
1369
1370 sir_sme_dis_ind->message_type =
1371 eWNI_SME_DISCONNECT_DONE_IND;
1372 sir_sme_dis_ind->length =
1373 sizeof(*sir_sme_dis_ind);
1374 sir_sme_dis_ind->session_id = smesessionId;
1375 sir_sme_dis_ind->reason_code = reasonCode;
1376 qdf_mem_copy(sir_sme_dis_ind->peer_mac, peerMacAddr,
1377 ETH_ALEN);
Selvaraj, Sridharc7d80892016-09-29 11:56:45 +05301378 /*
1379 * Instead of sending deauth reason code as 505 which is
1380 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1381 * Send reason code as zero to Supplicant
1382 */
1383 if (reasonCode == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1384 sir_sme_dis_ind->reason_code = 0;
1385 else
1386 sir_sme_dis_ind->reason_code = reasonCode;
1387
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301388 pMsg = (uint32_t *)sir_sme_dis_ind;
1389
1390 break;
1391
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001392 default:
1393 /**
1394 * Deauthentication indication due to Deauthentication
1395 * frame reception from peer entity or due to
1396 * loss of link with peer entity.
1397 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301398 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001399 if (NULL == pSirSmeDeauthInd) {
1400 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301401 pe_err("call to AllocateMemory failed for eWNI_SME_DEAUTH_Ind");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001402 return;
1403 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301404 pe_debug("send eWNI_SME_DEAUTH_IND with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001405 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1406 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1407 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1408 pSirSmeDeauthInd->reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
1409
1410 /* sessionId */
1411 pBuf = (uint8_t *) &pSirSmeDeauthInd->sessionId;
1412 *pBuf++ = smesessionId;
1413
1414 /* transaction ID */
1415 lim_copy_u16(pBuf, smetransactionId);
1416 pBuf += sizeof(uint16_t);
1417
1418 /* status code */
1419 lim_copy_u32(pBuf, reasonCode);
1420 pBuf += sizeof(tSirResultCodes);
1421
1422 /* bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301423 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001424 pBuf += sizeof(tSirMacAddr);
1425
1426 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301427 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301428 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001429
1430#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1431 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
1432 psessionEntry, 0, (uint16_t) reasonCode);
1433#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1434 pMsg = (uint32_t *) pSirSmeDeauthInd;
1435
1436 break;
1437 }
1438
1439 /*Delete the PE session created */
1440 if (psessionEntry != NULL) {
1441 pe_delete_session(pMac, psessionEntry);
1442 }
1443
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301444 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001445 (uint32_t *) pMsg);
1446
1447} /*** end lim_send_sme_deauth_ntf() ***/
1448
1449/**
1450 * lim_send_sme_wm_status_change_ntf() - Send Notification
1451 * @mac_ctx: Global MAC Context
1452 * @status_change_code: Indicates the change in the wireless medium.
1453 * @status_change_info: Indicates the information associated with
1454 * change in the wireless medium.
1455 * @info_len: Indicates the length of status change information
1456 * being sent.
1457 * @session_id SessionID
1458 *
1459 * This function is called by limProcessSmeMessages() to send
1460 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1461 *
1462 * Return: None
1463 */
1464void
1465lim_send_sme_wm_status_change_ntf(tpAniSirGlobal mac_ctx,
1466 tSirSmeStatusChangeCode status_change_code,
1467 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1468{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001469 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001470 tSirSmeWmStatusChangeNtf *wm_status_change_ntf;
Naveen Rawate01ed172016-11-17 11:34:50 -08001471 uint32_t max_info_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001472
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301473 wm_status_change_ntf = qdf_mem_malloc(sizeof(tSirSmeWmStatusChangeNtf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001474 if (NULL == wm_status_change_ntf) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301475 pe_err("Mem Alloc failed - eWNI_SME_WM_STATUS_CHANGE_NTF");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001476 return;
1477 }
1478
1479 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1480 msg.bodyval = 0;
1481 msg.bodyptr = wm_status_change_ntf;
1482
1483 switch (status_change_code) {
Naveen Rawate01ed172016-11-17 11:34:50 -08001484 case eSIR_SME_AP_CAPS_CHANGED:
1485 max_info_len = sizeof(tSirSmeApNewCaps);
1486 break;
1487 case eSIR_SME_JOINED_NEW_BSS:
1488 max_info_len = sizeof(tSirSmeNewBssInfo);
1489 break;
1490 default:
1491 max_info_len = sizeof(wm_status_change_ntf->statusChangeInfo);
1492 break;
1493 }
1494
1495 switch (status_change_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001496 case eSIR_SME_RADAR_DETECTED:
1497 break;
1498 default:
1499 wm_status_change_ntf->messageType =
1500 eWNI_SME_WM_STATUS_CHANGE_NTF;
1501 wm_status_change_ntf->statusChangeCode = status_change_code;
1502 wm_status_change_ntf->length = sizeof(tSirSmeWmStatusChangeNtf);
1503 wm_status_change_ntf->sessionId = session_id;
Naveen Rawate01ed172016-11-17 11:34:50 -08001504 if (info_len <= max_info_len && status_change_info) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301505 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001506 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1507 (uint8_t *) status_change_info, info_len);
1508 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301509 pe_debug("StatusChg code: 0x%x length: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001510 status_change_code, info_len);
1511 break;
1512 }
1513
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301514 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001515 if (eSIR_SUCCESS != lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301516 qdf_mem_free(wm_status_change_ntf);
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301517 pe_err("lim_sys_process_mmh_msg_api failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001518 }
1519
1520} /*** end lim_send_sme_wm_status_change_ntf() ***/
1521
1522/**
1523 * lim_send_sme_set_context_rsp()
1524 *
1525 ***FUNCTION:
1526 * This function is called by limProcessSmeMessages() to send
1527 * eWNI_SME_SETCONTEXT_RSP message to host
1528 *
1529 ***PARAMS:
1530 *
1531 ***LOGIC:
1532 *
1533 ***ASSUMPTIONS:
1534 * NA
1535 *
1536 ***NOTE:
1537 *
1538 * @param pMac Pointer to Global MAC structure
1539 * @param peerMacAddr Indicates the peer MAC addr to which
1540 * setContext was performed
1541 * @param aid Indicates the aid corresponding to the peer MAC
1542 * address
1543 * @param resultCode Indicates the result of previously issued
1544 * eWNI_SME_SETCONTEXT_RSP message
1545 *
1546 * @return None
1547 */
1548void
1549lim_send_sme_set_context_rsp(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301550 struct qdf_mac_addr peer_macaddr, uint16_t aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001551 tSirResultCodes resultCode,
1552 tpPESession psessionEntry, uint8_t smesessionId,
1553 uint16_t smetransactionId)
1554{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001555 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001556 tSirSmeSetContextRsp *pSirSmeSetContextRsp;
1557
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301558 pSirSmeSetContextRsp = qdf_mem_malloc(sizeof(tSirSmeSetContextRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001559 if (NULL == pSirSmeSetContextRsp) {
1560 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301561 pe_err("call to AllocateMemory failed for SmeSetContextRsp");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001562 return;
1563 }
1564
1565 pSirSmeSetContextRsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1566 pSirSmeSetContextRsp->length = sizeof(tSirSmeSetContextRsp);
1567 pSirSmeSetContextRsp->statusCode = resultCode;
1568
Anurag Chouhanc5548422016-02-24 18:33:27 +05301569 qdf_copy_macaddr(&pSirSmeSetContextRsp->peer_macaddr, &peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001570
1571 /* Update SME session and transaction Id */
1572 pSirSmeSetContextRsp->sessionId = smesessionId;
1573 pSirSmeSetContextRsp->transactionId = smetransactionId;
1574
1575 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
1576 mmhMsg.bodyptr = pSirSmeSetContextRsp;
1577 mmhMsg.bodyval = 0;
1578 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301579 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1580 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001581 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301582 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1583 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001584 }
1585
1586#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1587 lim_diag_event_report(pMac, WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
1588 psessionEntry, (uint16_t) resultCode, 0);
1589#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1590
1591 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1592} /*** end lim_send_sme_set_context_rsp() ***/
1593
1594/**
1595 * lim_send_sme_neighbor_bss_ind()
1596 *
1597 ***FUNCTION:
1598 * This function is called by lim_lookup_nadd_hash_entry() to send
1599 * eWNI_SME_NEIGHBOR_BSS_IND message to host
1600 *
1601 ***PARAMS:
1602 *
1603 ***LOGIC:
1604 *
1605 ***ASSUMPTIONS:
1606 * NA
1607 *
1608 ***NOTE:
1609 * This function is used for sending eWNI_SME_NEIGHBOR_BSS_IND to
1610 * host upon detecting new BSS during background scanning if CFG
1611 * option is enabled for sending such indication
1612 *
1613 * @param pMac - Pointer to Global MAC structure
1614 * @return None
1615 */
1616
1617void
1618lim_send_sme_neighbor_bss_ind(tpAniSirGlobal pMac, tLimScanResultNode *pBssDescr)
1619{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001620 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001621 uint32_t val;
1622 tSirSmeNeighborBssInd *pNewBssInd;
1623
1624 if ((pMac->lim.gLimSmeState != eLIM_SME_LINK_EST_WT_SCAN_STATE) ||
1625 ((pMac->lim.gLimSmeState == eLIM_SME_LINK_EST_WT_SCAN_STATE) &&
1626 pMac->lim.gLimRspReqd)) {
1627 /* LIM is not in background scan state OR */
1628 /* current scan is initiated by HDD. */
1629 /* No need to send new BSS indication to HDD */
1630 return;
1631 }
1632
1633 if (wlan_cfg_get_int(pMac, WNI_CFG_NEW_BSS_FOUND_IND, &val) !=
1634 eSIR_SUCCESS) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301635 pe_err("could not get NEIGHBOR_BSS_IND from CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001636 return;
1637 }
1638
1639 if (val == 0)
1640 return;
1641
1642 /**
1643 * Need to indicate new BSSs found during
1644 * background scanning to host.
1645 * Allocate buffer for sending indication.
1646 * Length of buffer is length of BSS description
1647 * and length of header itself
1648 */
1649 val = pBssDescr->bssDescription.length + sizeof(uint16_t) +
1650 sizeof(uint32_t) + sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301651 pNewBssInd = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001652 if (NULL == pNewBssInd) {
1653 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301654 pe_err("call to AllocateMemory failed for eWNI_SME_NEIGHBOR_BSS_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001655 return;
1656 }
1657
1658 pNewBssInd->messageType = eWNI_SME_NEIGHBOR_BSS_IND;
1659 pNewBssInd->length = (uint16_t) val;
1660 pNewBssInd->sessionId = 0;
1661
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301662 qdf_mem_copy((uint8_t *) pNewBssInd->bssDescription,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001663 (uint8_t *) &pBssDescr->bssDescription,
1664 pBssDescr->bssDescription.length + sizeof(uint16_t));
1665
1666 msgQ.type = eWNI_SME_NEIGHBOR_BSS_IND;
1667 msgQ.bodyptr = pNewBssInd;
1668 msgQ.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301669 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, msgQ.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001670 lim_sys_process_mmh_msg_api(pMac, &msgQ, ePROT);
1671} /*** end lim_send_sme_neighbor_bss_ind() ***/
1672
1673/** -----------------------------------------------------------------
1674 \brief lim_send_sme_addts_rsp() - sends SME ADDTS RSP
1675 \ This function sends a eWNI_SME_ADDTS_RSP to SME.
1676 \ SME only looks at rc and tspec field.
1677 \param pMac - global mac structure
1678 \param rspReqd - is SmeAddTsRsp required
1679 \param status - status code of SME_ADD_TS_RSP
1680 \return tspec
1681 \sa
1682 ----------------------------------------------------------------- */
1683void
1684lim_send_sme_addts_rsp(tpAniSirGlobal pMac, uint8_t rspReqd, uint32_t status,
1685 tpPESession psessionEntry, tSirMacTspecIE tspec,
1686 uint8_t smesessionId, uint16_t smetransactionId)
1687{
1688 tpSirAddtsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001689 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001690
1691 if (!rspReqd)
1692 return;
1693
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301694 rsp = qdf_mem_malloc(sizeof(tSirAddtsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001695 if (NULL == rsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301696 pe_err("AllocateMemory failed for ADDTS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001697 return;
1698 }
1699
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001700 rsp->messageType = eWNI_SME_ADDTS_RSP;
1701 rsp->rc = status;
1702 rsp->rsp.status = (enum eSirMacStatusCodes)status;
1703 rsp->rsp.tspec = tspec;
1704 /* Update SME session Id and transcation Id */
1705 rsp->sessionId = smesessionId;
1706 rsp->transactionId = smetransactionId;
1707
1708 mmhMsg.type = eWNI_SME_ADDTS_RSP;
1709 mmhMsg.bodyptr = rsp;
1710 mmhMsg.bodyval = 0;
1711 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301712 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1713 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001714 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301715 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1716 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001717 }
1718#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1719 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_RSP_EVENT, psessionEntry, 0,
1720 0);
1721#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1722
1723 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1724 return;
1725}
1726
1727void
1728lim_send_sme_delts_rsp(tpAniSirGlobal pMac, tpSirDeltsReq delts, uint32_t status,
1729 tpPESession psessionEntry, uint8_t smesessionId,
1730 uint16_t smetransactionId)
1731{
1732 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001733 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001734
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301735 pe_debug("SendSmeDeltsRsp aid: %d tsid: %d up: %d status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001736 delts->aid,
1737 delts->req.tsinfo.traffic.tsid,
1738 delts->req.tsinfo.traffic.userPrio, status);
1739 if (!delts->rspReqd)
1740 return;
1741
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301742 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001743 if (NULL == rsp) {
1744 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301745 pe_err("AllocateMemory failed for DELTS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001746 return;
1747 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001748
1749 if (psessionEntry != NULL) {
1750
1751 rsp->aid = delts->aid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301752 qdf_copy_macaddr(&rsp->macaddr, &delts->macaddr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301753 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) &delts->req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001754 sizeof(tSirDeltsReqInfo));
1755 }
1756
1757 rsp->messageType = eWNI_SME_DELTS_RSP;
1758 rsp->rc = status;
1759
1760 /* Update SME session Id and transcation Id */
1761 rsp->sessionId = smesessionId;
1762 rsp->transactionId = smetransactionId;
1763
1764 mmhMsg.type = eWNI_SME_DELTS_RSP;
1765 mmhMsg.bodyptr = rsp;
1766 mmhMsg.bodyval = 0;
1767 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301768 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1769 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001770 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301771 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1772 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001773 }
1774#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1775 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_RSP_EVENT, psessionEntry,
1776 (uint16_t) status, 0);
1777#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1778
1779 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1780}
1781
1782void
1783lim_send_sme_delts_ind(tpAniSirGlobal pMac, tpSirDeltsReqInfo delts, uint16_t aid,
1784 tpPESession psessionEntry)
1785{
1786 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001787 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001788
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301789 pe_debug("SendSmeDeltsInd aid: %d tsid: %d up: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001790 aid, delts->tsinfo.traffic.tsid, delts->tsinfo.traffic.userPrio);
1791
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301792 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001793 if (NULL == rsp) {
1794 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301795 pe_err("AllocateMemory failed for DELTS_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001796 return;
1797 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001798
1799 rsp->messageType = eWNI_SME_DELTS_IND;
1800 rsp->rc = eSIR_SUCCESS;
1801 rsp->aid = aid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301802 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) delts, sizeof(*delts));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001803
1804 /* Update SME session Id and SME transaction Id */
1805
1806 rsp->sessionId = psessionEntry->smeSessionId;
1807 rsp->transactionId = psessionEntry->transactionId;
1808
1809 mmhMsg.type = eWNI_SME_DELTS_IND;
1810 mmhMsg.bodyptr = rsp;
1811 mmhMsg.bodyval = 0;
1812 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1813#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1814 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_IND_EVENT, psessionEntry, 0,
1815 0);
1816#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1817
1818 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1819}
1820
1821/**
1822 * lim_send_sme_pe_statistics_rsp()
1823 *
1824 ***FUNCTION:
1825 * This function is called to send 802.11 statistics response to HDD.
1826 * This function posts the result back to HDD. This is a response to
1827 * HDD's request for statistics.
1828 *
1829 ***PARAMS:
1830 *
1831 ***LOGIC:
1832 *
1833 ***ASSUMPTIONS:
1834 * NA
1835 *
1836 ***NOTE:
1837 * NA
1838 *
1839 * @param pMac Pointer to Global MAC structure
1840 * @param p80211Stats Statistics sent in response
1841 * @param resultCode TODO:
1842 *
1843 *
1844 * @return none
1845 */
1846
1847void
1848lim_send_sme_pe_statistics_rsp(tpAniSirGlobal pMac, uint16_t msgType, void *stats)
1849{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001850 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001851 uint8_t sessionId;
1852 tAniGetPEStatsRsp *pPeStats = (tAniGetPEStatsRsp *) stats;
1853 tpPESession pPeSessionEntry;
1854
1855 /* Get the Session Id based on Sta Id */
1856 pPeSessionEntry =
1857 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1858
1859 /* Fill the Session Id */
1860 if (NULL != pPeSessionEntry) {
1861 /* Fill the Session Id */
1862 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1863 }
1864
1865 pPeStats->msgType = eWNI_SME_GET_STATISTICS_RSP;
1866
1867 /* msgType should be WMA_GET_STATISTICS_RSP */
1868 mmhMsg.type = eWNI_SME_GET_STATISTICS_RSP;
1869
1870 mmhMsg.bodyptr = stats;
1871 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301872 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001873 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1874
1875 return;
1876
1877} /*** end lim_send_sme_pe_statistics_rsp() ***/
1878
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001879#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001880/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001881 * lim_send_sme_pe_ese_tsm_rsp() - send tsm response
1882 * @pMac: Pointer to global pMac structure
1883 * @pStats: Pointer to TSM Stats
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001884 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001885 * This function is called to send tsm stats response to HDD.
1886 * This function posts the result back to HDD. This is a response to
1887 * HDD's request to get tsm stats.
1888 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001889 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001890 */
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001891void lim_send_sme_pe_ese_tsm_rsp(tpAniSirGlobal pMac,
1892 tAniGetTsmStatsRsp *pStats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001893{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001894 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001895 uint8_t sessionId;
1896 tAniGetTsmStatsRsp *pPeStats = (tAniGetTsmStatsRsp *) pStats;
1897 tpPESession pPeSessionEntry = NULL;
1898
1899 /* Get the Session Id based on Sta Id */
1900 pPeSessionEntry =
1901 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1902
1903 /* Fill the Session Id */
1904 if (NULL != pPeSessionEntry) {
1905 /* Fill the Session Id */
1906 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1907 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301908 pe_err("Session not found for the Sta id: %d",
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301909 pPeStats->staId);
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05301910 qdf_mem_free(pPeStats->tsmStatsReq);
1911 qdf_mem_free(pPeStats);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001912 return;
1913 }
1914
1915 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
1916 pPeStats->tsmMetrics.RoamingCount
1917 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
1918 pPeStats->tsmMetrics.RoamingDly
1919 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
1920
1921 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
1922 mmhMsg.bodyptr = pStats;
1923 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301924 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001925 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1926
1927 return;
1928} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
1929
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001930#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001931
1932void
1933lim_send_sme_ibss_peer_ind(tpAniSirGlobal pMac,
1934 tSirMacAddr peerMacAddr,
1935 uint16_t staIndex,
1936 uint8_t ucastIdx,
1937 uint8_t bcastIdx,
1938 uint8_t *beacon,
1939 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
1940{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001941 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001942 tSmeIbssPeerInd *pNewPeerInd;
1943
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301944 pNewPeerInd = qdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001945 if (NULL == pNewPeerInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301946 pe_err("Failed to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001947 return;
1948 }
1949
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301950 qdf_mem_copy((uint8_t *) pNewPeerInd->peer_addr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301951 peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001952 pNewPeerInd->staId = staIndex;
1953 pNewPeerInd->ucastSig = ucastIdx;
1954 pNewPeerInd->bcastSig = bcastIdx;
1955 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
1956 pNewPeerInd->mesgType = msgType;
1957 pNewPeerInd->sessionId = sessionId;
1958
1959 if (beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301960 qdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001961 sizeof(tSmeIbssPeerInd)), (void *)beacon,
1962 beaconLen);
1963 }
1964
1965 mmhMsg.type = msgType;
1966 mmhMsg.bodyptr = pNewPeerInd;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301967 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001968 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1969
1970}
1971
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07001972/**
1973 * lim_process_csa_wbw_ie() - Process CSA Wide BW IE
1974 * @mac_ctx: pointer to global adapter context
1975 * @csa_params: pointer to CSA parameters
1976 * @chnl_switch_info:pointer to channel switch parameters
1977 * @session_entry: session pointer
1978 *
1979 * Return: None
1980 */
1981static void lim_process_csa_wbw_ie(tpAniSirGlobal mac_ctx,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001982 struct csa_offload_params *csa_params,
1983 tLimWiderBWChannelSwitchInfo *chnl_switch_info,
1984 tpPESession session_entry)
1985{
Amar Singhal5cccafe2017-02-15 12:42:58 -08001986 struct ch_params ch_params = {0};
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001987 uint8_t ap_new_ch_width;
1988 bool new_ch_width_dfn = false;
1989 uint8_t center_freq_diff;
1990
1991 ap_new_ch_width = csa_params->new_ch_width + 1;
1992 if ((ap_new_ch_width == CH_WIDTH_80MHZ) &&
1993 csa_params->new_ch_freq_seg2) {
1994 new_ch_width_dfn = true;
1995 if (csa_params->new_ch_freq_seg2 >
1996 csa_params->new_ch_freq_seg1)
1997 center_freq_diff = csa_params->new_ch_freq_seg2 -
1998 csa_params->new_ch_freq_seg1;
1999 else
2000 center_freq_diff = csa_params->new_ch_freq_seg1 -
2001 csa_params->new_ch_freq_seg2;
2002 if (center_freq_diff == CENTER_FREQ_DIFF_160MHz)
2003 ap_new_ch_width = CH_WIDTH_160MHZ;
2004 else if (center_freq_diff > CENTER_FREQ_DIFF_80P80MHz)
2005 ap_new_ch_width = CH_WIDTH_80P80MHZ;
2006 else
2007 ap_new_ch_width = CH_WIDTH_80MHZ;
2008 }
2009 session_entry->gLimChannelSwitch.state =
2010 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2011 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
2012 !new_ch_width_dfn) {
2013 ch_params.ch_width = CH_WIDTH_160MHZ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002014 wlan_reg_set_channel_params(mac_ctx->pdev,
2015 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002016 ap_new_ch_width = ch_params.ch_width;
2017 csa_params->new_ch_freq_seg1 = ch_params.center_freq_seg0;
2018 csa_params->new_ch_freq_seg2 = ch_params.center_freq_seg1;
2019 }
2020 chnl_switch_info->newChanWidth = ap_new_ch_width;
2021 chnl_switch_info->newCenterChanFreq0 = csa_params->new_ch_freq_seg1;
2022 chnl_switch_info->newCenterChanFreq1 = csa_params->new_ch_freq_seg2;
2023
2024 if (session_entry->ch_width == ap_new_ch_width)
2025 goto prnt_log;
2026
2027 if (session_entry->ch_width == CH_WIDTH_80MHZ) {
2028 chnl_switch_info->newChanWidth = CH_WIDTH_80MHZ;
2029 chnl_switch_info->newCenterChanFreq1 = 0;
2030 } else {
2031 session_entry->ch_width = ap_new_ch_width;
2032 chnl_switch_info->newChanWidth = ap_new_ch_width;
2033 }
2034prnt_log:
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302035 pe_debug("new channel: %d new_ch_width: %d seg0: %d seg1: %d",
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002036 csa_params->channel,
2037 chnl_switch_info->newChanWidth,
2038 chnl_switch_info->newCenterChanFreq0,
2039 chnl_switch_info->newCenterChanFreq1);
2040}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002041/**
2042 * lim_handle_csa_offload_msg() - Handle CSA offload message
2043 * @mac_ctx: pointer to global adapter context
2044 * @msg: Message pointer.
2045 *
2046 * Return: None
2047 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08002048void lim_handle_csa_offload_msg(tpAniSirGlobal mac_ctx,
2049 struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002050{
2051 tpPESession session_entry;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002052 struct scheduler_msg mmh_msg = {0};
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302053 struct csa_offload_params *csa_params =
2054 (struct csa_offload_params *) (msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002055 tpSmeCsaOffloadInd csa_offload_ind;
2056 tpDphHashNode sta_ds = NULL;
2057 uint8_t session_id;
2058 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302059 uint16_t chan_space = 0;
Amar Singhal5cccafe2017-02-15 12:42:58 -08002060 struct ch_params ch_params;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302061
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002062 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002063 tLimChannelSwitchInfo *lim_ch_switch = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002064
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302065 pe_debug("handle csa offload msg");
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302066
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002067 if (!csa_params) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302068 pe_err("limMsgQ body ptr is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002069 return;
2070 }
2071
2072 session_entry =
2073 pe_find_session_by_bssid(mac_ctx,
2074 csa_params->bssId, &session_id);
2075 if (!session_entry) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302076 pe_err("Session does not exists for %pM",
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302077 csa_params->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002078 goto err;
2079 }
2080
2081 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
2082 &session_entry->dph.dphHashTable);
2083
2084 if (!sta_ds) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302085 pe_err("sta_ds does not exist");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002086 goto err;
2087 }
2088
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002089 if (!LIM_IS_STA_ROLE(session_entry)) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302090 pe_debug("Invalid role to handle CSA");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002091 goto err;
2092 }
Masti, Narayanraddi1c630442015-11-02 12:03:50 +05302093
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002094 /*
2095 * on receiving channel switch announcement from AP, delete all
2096 * TDLS peers before leaving BSS and proceed for channel switch
2097 */
2098 lim_delete_tdls_peers(mac_ctx, session_entry);
Gupta, Kapil121bf212015-11-25 19:21:29 +05302099
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002100 lim_ch_switch = &session_entry->gLimChannelSwitch;
2101 session_entry->gLimChannelSwitch.switchMode =
2102 csa_params->switch_mode;
2103 /* timer already started by firmware, switch immediately */
2104 session_entry->gLimChannelSwitch.switchCount = 0;
2105 session_entry->gLimChannelSwitch.primaryChannel =
2106 csa_params->channel;
2107 session_entry->gLimChannelSwitch.state =
2108 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2109 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
2110 lim_ch_switch->sec_ch_offset =
2111 session_entry->htSecondaryChannelOffset;
2112 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
2113 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
2114 chnl_switch_info =
2115 &session_entry->gLimWiderBWChannelSwitch;
2116
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302117 pe_debug("vht: %d ht: %d flag: %x chan: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302118 session_entry->vhtCapability,
2119 session_entry->htSupportedChannelWidthSet,
2120 csa_params->ies_present_flag,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002121 csa_params->channel);
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302122 pe_debug("seg1: %d seg2: %d width: %d country: %s class: %d",
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002123 csa_params->new_ch_freq_seg1,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302124 csa_params->new_ch_freq_seg2,
2125 csa_params->new_ch_width,
2126 mac_ctx->scan.countryCodeCurrent,
2127 csa_params->new_op_class);
2128
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002129 if (session_entry->vhtCapability &&
2130 session_entry->htSupportedChannelWidthSet) {
2131 if (csa_params->ies_present_flag & lim_wbw_ie_present) {
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07002132 lim_process_csa_wbw_ie(mac_ctx, csa_params,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002133 chnl_switch_info, session_entry);
2134 lim_ch_switch->sec_ch_offset =
Abhishek Singhaf639b42017-06-16 14:14:36 +05302135 PHY_SINGLE_CHANNEL_CENTERED;
2136 if (chnl_switch_info->newChanWidth) {
2137 if (csa_params->channel <
2138 csa_params->new_ch_freq_seg1)
2139 lim_ch_switch->sec_ch_offset =
2140 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
2141 else
2142 lim_ch_switch->sec_ch_offset =
2143 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
2144 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002145 } else if (csa_params->ies_present_flag
2146 & lim_xcsa_ie_present) {
2147 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002148 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002149 mac_ctx->scan.countryCodeCurrent,
2150 csa_params->channel,
2151 csa_params->new_op_class);
2152 session_entry->gLimChannelSwitch.state =
2153 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2154
2155 if (chan_space == 80) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002156 chnl_switch_info->newChanWidth =
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002157 CH_WIDTH_80MHZ;
2158 } else if (chan_space == 40) {
2159 chnl_switch_info->newChanWidth =
2160 CH_WIDTH_40MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002161 } else {
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002162 chnl_switch_info->newChanWidth =
2163 CH_WIDTH_20MHZ;
2164 lim_ch_switch->state =
2165 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2166 }
2167
2168 ch_params.ch_width =
2169 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002170 wlan_reg_set_channel_params(mac_ctx->pdev,
2171 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002172 chnl_switch_info->newCenterChanFreq0 =
2173 ch_params.center_freq_seg0;
2174 /*
2175 * This is not applicable for 20/40/80 MHz.
2176 * Only used when we support 80+80 MHz operation.
2177 * In case of 80+80 MHz, this parameter indicates
2178 * center channel frequency index of 80 MHz
2179 * channel offrequency segment 1.
2180 */
2181 chnl_switch_info->newCenterChanFreq1 =
2182 ch_params.center_freq_seg1;
2183 lim_ch_switch->sec_ch_offset =
2184 ch_params.sec_ch_offset;
2185
2186 }
2187 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
2188 chnl_switch_info->newCenterChanFreq0;
2189 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
2190 chnl_switch_info->newCenterChanFreq1;
2191 session_entry->gLimChannelSwitch.ch_width =
2192 chnl_switch_info->newChanWidth;
2193
2194 } else if (session_entry->htSupportedChannelWidthSet) {
2195 if (csa_params->ies_present_flag
2196 & lim_xcsa_ie_present) {
2197 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002198 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002199 mac_ctx->scan.countryCodeCurrent,
2200 csa_params->channel,
2201 csa_params->new_op_class);
2202 lim_ch_switch->state =
2203 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2204 if (chan_space == 40) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002205 lim_ch_switch->ch_width =
2206 CH_WIDTH_40MHZ;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002207 chnl_switch_info->newChanWidth =
2208 CH_WIDTH_40MHZ;
2209 ch_params.ch_width =
2210 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002211 wlan_reg_set_channel_params(mac_ctx->pdev,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002212 csa_params->channel,
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07002213 0, &ch_params);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002214 lim_ch_switch->ch_center_freq_seg0 =
2215 ch_params.center_freq_seg0;
2216 lim_ch_switch->sec_ch_offset =
2217 ch_params.sec_ch_offset;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002218 } else {
2219 lim_ch_switch->ch_width =
2220 CH_WIDTH_20MHZ;
2221 chnl_switch_info->newChanWidth =
2222 CH_WIDTH_40MHZ;
2223 lim_ch_switch->state =
2224 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2225 lim_ch_switch->sec_ch_offset =
2226 PHY_SINGLE_CHANNEL_CENTERED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002227 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002228 } else {
2229 lim_ch_switch->ch_width =
2230 CH_WIDTH_40MHZ;
2231 lim_ch_switch->state =
2232 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2233 ch_params.ch_width = CH_WIDTH_40MHZ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002234 wlan_reg_set_channel_params(mac_ctx->pdev,
2235 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002236 lim_ch_switch->ch_center_freq_seg0 =
2237 ch_params.center_freq_seg0;
2238 lim_ch_switch->sec_ch_offset =
2239 ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002240 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002241
2242 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302243 pe_debug("new ch width: %d space: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302244 session_entry->gLimChannelSwitch.ch_width, chan_space);
Kiran Kumar Lokere75d636f2016-12-20 14:52:03 -08002245 if ((session_entry->currentOperChannel == csa_params->channel) &&
2246 (session_entry->ch_width ==
2247 session_entry->gLimChannelSwitch.ch_width)) {
2248 pe_debug("Ignore CSA, no change in ch and bw");
2249 goto err;
2250 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002251
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002252 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
2253 csa_offload_ind = qdf_mem_malloc(sizeof(tSmeCsaOffloadInd));
2254 if (NULL == csa_offload_ind) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302255 pe_err("memalloc fail eWNI_SME_CSA_OFFLOAD_EVENT");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002256 goto err;
2257 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002258
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002259 csa_offload_ind->mesgType = eWNI_SME_CSA_OFFLOAD_EVENT;
2260 csa_offload_ind->mesgLen = sizeof(tSmeCsaOffloadInd);
2261 qdf_mem_copy(csa_offload_ind->bssid.bytes, session_entry->bssId,
2262 QDF_MAC_ADDR_SIZE);
2263 mmh_msg.type = eWNI_SME_CSA_OFFLOAD_EVENT;
2264 mmh_msg.bodyptr = csa_offload_ind;
2265 mmh_msg.bodyval = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302266 pe_debug("Sending eWNI_SME_CSA_OFFLOAD_EVENT to SME");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002267 MTRACE(mac_trace_msg_tx
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002268 (mac_ctx, session_entry->peSessionId, mmh_msg.type));
2269#ifdef FEATURE_WLAN_DIAG_SUPPORT
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002270 lim_diag_event_report(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002271 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
2272 eSIR_SUCCESS, eSIR_SUCCESS);
2273#endif
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002274 lim_sys_process_mmh_msg_api(mac_ctx, &mmh_msg, ePROT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002275
2276err:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302277 qdf_mem_free(csa_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002278}
2279
2280/*--------------------------------------------------------------------------
2281 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
2282
2283 \param pMac - pointer to global adapter context
2284 \param sessionId - Message pointer.
2285
2286 \sa
2287 --------------------------------------------------------------------------*/
2288
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002289void lim_handle_delete_bss_rsp(tpAniSirGlobal pMac, struct scheduler_msg *MsgQ)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002290{
2291 tpPESession psessionEntry;
2292 tpDeleteBssParams pDelBss = (tpDeleteBssParams) (MsgQ->bodyptr);
2293
2294 psessionEntry =
2295 pe_find_session_by_session_id(pMac, pDelBss->sessionId);
2296 if (psessionEntry == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302297 pe_err("Session Does not exist for given sessionID: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002298 pDelBss->sessionId);
Naveen Rawat0c81edc2016-06-08 10:08:30 -07002299 qdf_mem_free(MsgQ->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002300 return;
2301 }
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002302 /*
2303 * During DEL BSS handling, the PE Session will be deleted, but it is
2304 * better to clear this flag if the session is hanging around due
2305 * to some error conditions so that the next DEL_BSS request does
2306 * not take the HO_FAIL path
2307 */
2308 psessionEntry->process_ho_fail = false;
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002309 if (LIM_IS_IBSS_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002310 lim_ibss_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002311 else if (LIM_IS_UNKNOWN_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002312 lim_process_sme_del_bss_rsp(pMac, MsgQ->bodyval, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002313 else if (LIM_IS_NDI_ROLE(psessionEntry))
2314 lim_ndi_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002315 else
2316 lim_process_mlm_del_bss_rsp(pMac, MsgQ, psessionEntry);
2317
2318}
2319
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002320/** -----------------------------------------------------------------
2321 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
2322 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
2323 \ SME only looks at rc and tspec field.
2324 \param pMac - global mac structure
2325 \param rspReqd - is SmeAddTsRsp required
2326 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
2327 \return tspec
2328 \sa
2329 ----------------------------------------------------------------- */
2330void
2331lim_send_sme_aggr_qos_rsp(tpAniSirGlobal pMac, tpSirAggrQosRsp aggrQosRsp,
2332 uint8_t smesessionId)
2333{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002334 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002335
2336 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
2337 mmhMsg.bodyptr = aggrQosRsp;
2338 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302339 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2340 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002341 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2342
2343 return;
2344}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002345
2346void lim_send_sme_max_assoc_exceeded_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
2347 uint8_t smesessionId)
2348{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002349 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002350 tSmeMaxAssocInd *pSmeMaxAssocInd;
2351
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302352 pSmeMaxAssocInd = qdf_mem_malloc(sizeof(tSmeMaxAssocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002353 if (NULL == pSmeMaxAssocInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302354 pe_err("Failed to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002355 return;
2356 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302357 qdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peer_mac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302358 (uint8_t *) peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002359 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
2360 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
2361 pSmeMaxAssocInd->sessionId = smesessionId;
2362 mmhMsg.type = pSmeMaxAssocInd->mesgType;
2363 mmhMsg.bodyptr = pSmeMaxAssocInd;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302364 pe_debug("msgType: %s peerMacAddr "MAC_ADDRESS_STR "sme session id %d",
2365 "eWNI_SME_MAX_ASSOC_EXCEEDED", MAC_ADDR_ARRAY(peerMacAddr),
2366 pSmeMaxAssocInd->sessionId);
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302367 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2368 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002369 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2370
2371 return;
2372}
2373
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002374/*--------------------------------------------------------------------------
2375 \brief lim_send_dfs_chan_sw_ie_update()
2376 This timer handler updates the channel switch IE in beacon template
2377
2378 \param pMac - pointer to global adapter context
2379 \return - channel to scan from valid session else zero.
2380 \sa
2381 --------------------------------------------------------------------------*/
2382static void
2383lim_send_dfs_chan_sw_ie_update(tpAniSirGlobal pMac, tpPESession psessionEntry)
2384{
2385
2386 /* Update the beacon template and send to FW */
2387 if (sch_set_fixed_beacon_fields(pMac, psessionEntry) != eSIR_SUCCESS) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302388 pe_err("Unable to set CSA IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002389 return;
2390 }
2391
2392 /* Send update beacon template message */
2393 lim_send_beacon_ind(pMac, psessionEntry);
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302394 pe_debug("Updated CSA IE, IE COUNT: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002395 psessionEntry->gLimChannelSwitch.switchCount);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002396
2397 return;
2398}
2399
2400/** -----------------------------------------------------------------
2401 \brief lim_send_sme_ap_channel_switch_resp() - sends
2402 eWNI_SME_CHANNEL_CHANGE_RSP
2403 After receiving WMA_SWITCH_CHANNEL_RSP indication this
2404 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
2405 that the Channel change has been done to the specified target
2406 channel in the Channel change request
2407 \param pMac - global mac structure
2408 \param psessionEntry - session info
2409 \param pChnlParams - Channel switch params
2410 --------------------------------------------------------------------*/
2411void
2412lim_send_sme_ap_channel_switch_resp(tpAniSirGlobal pMac,
2413 tpPESession psessionEntry,
2414 tpSwitchChannelParams pChnlParams)
2415{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002416 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002417 tpSwitchChannelParams pSmeSwithChnlParams;
2418 uint8_t channelId;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002419 bool is_ch_dfs = false;
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08002420 enum phy_ch_width ch_width;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002421 uint8_t ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002422
2423 pSmeSwithChnlParams = (tSwitchChannelParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302424 qdf_mem_malloc(sizeof(tSwitchChannelParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002425 if (NULL == pSmeSwithChnlParams) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302426 pe_err("AllocateMemory failed for pSmeSwithChnlParams");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002427 return;
2428 }
2429
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302430 qdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002431 sizeof(tSwitchChannelParams));
2432
2433 channelId = pSmeSwithChnlParams->channelNumber;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002434 ch_width = pSmeSwithChnlParams->ch_width;
2435 ch_center_freq_seg1 = pSmeSwithChnlParams->ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002436
2437 /*
2438 * Pass the sme sessionID to SME instead
2439 * PE session ID.
2440 */
2441 pSmeSwithChnlParams->peSessionId = psessionEntry->smeSessionId;
2442
2443 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
2444 mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
2445 mmhMsg.bodyval = 0;
2446 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2447
2448 /*
2449 * We should start beacon transmission only if the new
2450 * channel after channel change is Non-DFS. For a DFS
2451 * channel, PE will receive an explicit request from
2452 * upper layers to start the beacon transmission .
2453 */
2454
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002455 if (ch_width == CH_WIDTH_160MHZ) {
2456 is_ch_dfs = true;
2457 } else if (ch_width == CH_WIDTH_80P80MHZ) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002458 if (wlan_reg_get_channel_state(pMac->pdev, channelId) ==
2459 CHANNEL_STATE_DFS ||
2460 wlan_reg_get_channel_state(pMac->pdev,
2461 ch_center_freq_seg1 -
2462 SIR_80MHZ_START_CENTER_CH_DIFF) ==
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002463 CHANNEL_STATE_DFS)
2464 is_ch_dfs = true;
2465 } else {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002466 if (wlan_reg_get_channel_state(pMac->pdev, channelId) ==
2467 CHANNEL_STATE_DFS)
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002468 is_ch_dfs = true;
2469 }
2470
2471 if (!is_ch_dfs) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002472 if (channelId == psessionEntry->currentOperChannel) {
2473 lim_apply_configuration(pMac, psessionEntry);
2474 lim_send_beacon_ind(pMac, psessionEntry);
2475 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302476 pe_debug("Failed to Transmit Beacons on channel: %d after AP channel change response",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002477 psessionEntry->bcnLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002478 }
2479 }
2480 return;
2481}
2482
Peng Xu6363ec62017-05-15 11:06:33 -07002483#ifdef WLAN_FEATURE_11AX_BSS_COLOR
2484/**
2485 * lim_send_bss_color_change_ie_update() - update bss color change IE in
2486 * beacon template
2487 *
2488 * @mac_ctx: pointer to global adapter context
2489 * @session: session pointer
2490 *
2491 * Return: none
2492 */
2493static void
2494lim_send_bss_color_change_ie_update(tpAniSirGlobal mac_ctx,
2495 tpPESession session)
2496{
2497 /* Update the beacon template and send to FW */
2498 if (sch_set_fixed_beacon_fields(mac_ctx, session) != eSIR_SUCCESS) {
2499 pe_err("Unable to set BSS color change IE in beacon");
2500 return;
2501 }
2502
2503 /* Send update beacon template message */
2504 lim_send_beacon_ind(mac_ctx, session);
2505 pe_info("Updated BSS color change countdown = %d",
2506 session->he_bss_color_change.countdown);
2507}
2508
2509static void
2510lim_handle_bss_color_change_ie(tpAniSirGlobal mac_ctx,
2511 tpPESession session)
2512{
2513 /* handle bss color change IE */
2514 if (LIM_IS_AP_ROLE(session) &&
2515 session->he_op.bss_col_disabled) {
2516 if (session->he_bss_color_change.countdown > 0) {
2517 session->he_bss_color_change.countdown--;
2518 } else {
2519 session->bss_color_changing = 0;
2520 if (session->he_bss_color_change.new_color != 0)
2521 session->he_op.bss_col_disabled = 0;
2522 }
2523
2524 lim_send_bss_color_change_ie_update(mac_ctx, session);
2525 }
2526}
2527
2528#else
2529static void
2530lim_handle_bss_color_change_ie(tpAniSirGlobal mac_ctx,
2531 tpPESession session)
2532{
2533}
2534#endif
2535
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002536/** -----------------------------------------------------------------
2537 \brief lim_process_beacon_tx_success_ind() - This function is used
2538 explicitely to handle successful beacon transmission indication
2539 from the FW. This is a generic event generated by the FW afer the
2540 first beacon is sent out after the beacon template update by the
2541 host
2542 \param pMac - global mac structure
2543 \param psessionEntry - session info
2544 \return none
2545 \sa
2546 ----------------------------------------------------------------- */
2547void
2548lim_process_beacon_tx_success_ind(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2549{
2550 /* Currently, this event is used only for DFS channel switch announcement
2551 * IE update in the template. If required to be used for other IE updates
2552 * add appropriate code by introducing a state variable
2553 */
2554 tpPESession psessionEntry;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002555 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002556 tSirSmeCSAIeTxCompleteRsp *pChanSwTxResponse;
2557 struct sir_beacon_tx_complete_rsp *beacon_tx_comp_rsp_ptr;
2558 uint8_t length = sizeof(tSirSmeCSAIeTxCompleteRsp);
2559 tpSirFirstBeaconTxCompleteInd pBcnTxInd =
2560 (tSirFirstBeaconTxCompleteInd *) event;
2561
2562 psessionEntry = pe_find_session_by_bss_idx(pMac, pBcnTxInd->bssIdx);
2563 if (psessionEntry == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302564 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002565 return;
2566 }
2567
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302568 pe_debug("role: %d swIe: %d opIe: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302569 GET_LIM_SYSTEM_ROLE(psessionEntry),
2570 psessionEntry->dfsIncludeChanSwIe,
2571 psessionEntry->gLimOperatingMode.present);
2572
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002573 if (LIM_IS_AP_ROLE(psessionEntry) &&
2574 true == psessionEntry->dfsIncludeChanSwIe) {
2575 /* Send only 5 beacons with CSA IE Set in when a radar is detected */
2576 if (psessionEntry->gLimChannelSwitch.switchCount > 0) {
2577 /*
2578 * Send the next beacon with updated CSA IE count
2579 */
2580 lim_send_dfs_chan_sw_ie_update(pMac, psessionEntry);
2581 /* Decrement the IE count */
2582 psessionEntry->gLimChannelSwitch.switchCount--;
2583 } else {
2584 /* Done with CSA IE update, send response back to SME */
2585 psessionEntry->gLimChannelSwitch.switchCount = 0;
2586 if (pMac->sap.SapDfsInfo.disable_dfs_ch_switch == false)
2587 psessionEntry->gLimChannelSwitch.switchMode = 0;
2588 psessionEntry->dfsIncludeChanSwIe = false;
2589 psessionEntry->dfsIncludeChanWrapperIe = false;
2590
2591 pChanSwTxResponse = (tSirSmeCSAIeTxCompleteRsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302592 qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002593
2594 if (NULL == pChanSwTxResponse) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302595 pe_err("AllocateMemory failed for tSirSmeCSAIeTxCompleteRsp");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002596 return;
2597 }
2598
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002599 pChanSwTxResponse->sessionId =
2600 psessionEntry->smeSessionId;
2601 pChanSwTxResponse->chanSwIeTxStatus =
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302602 QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002603
2604 mmhMsg.type = eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND;
2605 mmhMsg.bodyptr = pChanSwTxResponse;
2606 mmhMsg.bodyval = 0;
2607 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2608 }
2609 }
2610
2611 if (LIM_IS_AP_ROLE(psessionEntry) &&
2612 psessionEntry->gLimOperatingMode.present) {
2613 /* Done with nss update, send response back to SME */
2614 psessionEntry->gLimOperatingMode.present = 0;
2615 beacon_tx_comp_rsp_ptr = (struct sir_beacon_tx_complete_rsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302616 qdf_mem_malloc(sizeof(*beacon_tx_comp_rsp_ptr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002617 if (NULL == beacon_tx_comp_rsp_ptr) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302618 pe_err("AllocateMemory failed for beacon_tx_comp_rsp_ptr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002619 return;
2620 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002621 beacon_tx_comp_rsp_ptr->session_id =
2622 psessionEntry->smeSessionId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302623 beacon_tx_comp_rsp_ptr->tx_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002624 mmhMsg.type = eWNI_SME_NSS_UPDATE_RSP;
2625 mmhMsg.bodyptr = beacon_tx_comp_rsp_ptr;
2626 mmhMsg.bodyval = 0;
2627 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2628 }
Peng Xu6363ec62017-05-15 11:06:33 -07002629
2630 lim_handle_bss_color_change_ie(pMac, psessionEntry);
2631
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002632 return;
2633}