blob: 338ecb65b90dcad70ed4b6d7c22ccdeda05e3c34 [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"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080063
Kabilan Kannan1c1c4022017-04-06 22:49:26 -070064#ifdef CONVERGED_TDLS_ENABLE
Kabilan Kannanf56f9d52017-04-05 03:31:34 -070065#include "wlan_tdls_tgt_api.h"
Kabilan Kannan1c1c4022017-04-06 22:49:26 -070066#endif
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
Wu Gao2968fc92017-06-19 19:18:34 +0800369 pe_debug("pLimJoinReq:%p, pLimReAssocReq:%p",
370 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 Rawatc4a0e662017-05-19 08:06:57 -0700387 is_vendor_ap_1_present = (cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
388 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 &&
392 is_vendor_ap_1_present && (session_entry->nss == 2) &&
393 (mac_ctx->lteCoexAntShare == 0 ||
394 IS_5G_CH(session_entry->currentOperChannel))) {
395 /* 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
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800456/**
457 * lim_send_sme_join_reassoc_rsp() - Send Response to Upper Layers
458 * @mac_ctx: Pointer to Global MAC structure
459 * @msg_type: Indicates message type
460 * @result_code: Indicates the result of previously issued
461 * eWNI_SME_msgType_REQ message
462 * @prot_status_code: Protocol Status Code
463 * @session_entry: PE Session Info
464 * @sme_session_id: SME Session ID
465 * @sme_transaction_id: SME Transaction ID
466 *
467 * This function is called by lim_process_sme_req_messages() to send
468 * eWNI_SME_JOIN_RSP or eWNI_SME_REASSOC_RSP messages to applications
469 * above MAC Software.
470 *
471 * Return: None
472 */
473
474void
475lim_send_sme_join_reassoc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
476 tSirResultCodes result_code, uint16_t prot_status_code,
477 tpPESession session_entry, uint8_t sme_session_id,
478 uint16_t sme_transaction_id)
479{
480 tpSirSmeJoinRsp sme_join_rsp;
481 uint32_t rsp_len;
482 tpDphHashNode sta_ds = NULL;
483#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
484 if (msg_type == eWNI_SME_REASSOC_RSP)
485 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_RSP_EVENT,
486 session_entry, (uint16_t) result_code, 0);
487 else
488 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_RSP_EVENT,
489 session_entry, (uint16_t) result_code, 0);
490#endif /* FEATURE_WLAN_DIAG_SUPPORT */
491
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530492 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800493 lim_msg_str(msg_type), lim_result_code_str(result_code));
494
495 if (session_entry == NULL) {
496 rsp_len = sizeof(tSirSmeJoinRsp);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530497 sme_join_rsp = qdf_mem_malloc(rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800498 if (NULL == sme_join_rsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530499 pe_err("Mem Alloc fail - JOIN/REASSOC_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800500 return;
501 }
502
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800503 sme_join_rsp->beaconLength = 0;
504 sme_join_rsp->assocReqLength = 0;
505 sme_join_rsp->assocRspLength = 0;
506 } else {
507 rsp_len = session_entry->assocReqLen +
508 session_entry->assocRspLen + session_entry->bcnLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800509 session_entry->RICDataLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800510#ifdef FEATURE_WLAN_ESE
511 session_entry->tspecLen +
512#endif
513 sizeof(tSirSmeJoinRsp) - sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530514 sme_join_rsp = qdf_mem_malloc(rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800515 if (NULL == sme_join_rsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530516 pe_err("MemAlloc fail - JOIN/REASSOC_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800517 return;
518 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800519 if (result_code == eSIR_SME_SUCCESS) {
520 sta_ds = dph_get_hash_entry(mac_ctx,
521 DPH_STA_HASH_INDEX_PEER,
522 &session_entry->dph.dphHashTable);
523 if (sta_ds == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530524 pe_err("Get Self Sta Entry fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800525 } else {
526 /* Pass the peer's staId */
527 sme_join_rsp->staId = sta_ds->staIndex;
528 sme_join_rsp->ucastSig =
529 sta_ds->ucUcastSig;
530 sme_join_rsp->bcastSig =
531 sta_ds->ucBcastSig;
532 sme_join_rsp->timingMeasCap =
533 sta_ds->timingMeasCap;
534#ifdef FEATURE_WLAN_TDLS
535 sme_join_rsp->tdls_prohibited =
536 session_entry->tdls_prohibited;
537 sme_join_rsp->tdls_chan_swit_prohibited =
538 session_entry->tdls_chan_swit_prohibited;
539#endif
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530540 sme_join_rsp->nss = sta_ds->nss;
541 sme_join_rsp->max_rate_flags =
542 lim_get_max_rate_flags(mac_ctx, sta_ds);
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530543 lim_add_bss_info(sta_ds, sme_join_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800544 }
545 }
546 sme_join_rsp->beaconLength = 0;
547 sme_join_rsp->assocReqLength = 0;
548 sme_join_rsp->assocRspLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800549 sme_join_rsp->parsedRicRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800550#ifdef FEATURE_WLAN_ESE
551 sme_join_rsp->tspecIeLen = 0;
552#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800553 lim_handle_join_rsp_status(mac_ctx, session_entry, result_code,
554 sme_join_rsp);
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800555
556 /* Send supported NSS 1x1 to SME */
557 sme_join_rsp->supported_nss_1x1 =
558 session_entry->supported_nss_1x1;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530559 pe_debug("SME Join Rsp is supported NSS 1X1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800560 sme_join_rsp->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800561 }
562
563 sme_join_rsp->messageType = msg_type;
564 sme_join_rsp->length = (uint16_t) rsp_len;
565 sme_join_rsp->statusCode = result_code;
566 sme_join_rsp->protStatusCode = prot_status_code;
567
568 sme_join_rsp->sessionId = sme_session_id;
569 sme_join_rsp->transactionId = sme_transaction_id;
570
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530571 lim_send_sme_join_reassoc_rsp_after_resume(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800572 (uint32_t *)sme_join_rsp);
573}
574
575/**
576 * lim_send_sme_start_bss_rsp()
577 *
578 ***FUNCTION:
579 * This function is called to send eWNI_SME_START_BSS_RSP
580 * message to applications above MAC Software.
581 *
582 ***PARAMS:
583 *
584 ***LOGIC:
585 *
586 ***ASSUMPTIONS:
587 * NA
588 *
589 ***NOTE:
590 * NA
591 *
592 * @param pMac Pointer to Global MAC structure
593 * @param msgType Indicates message type
594 * @param resultCode Indicates the result of previously issued
595 * eWNI_SME_msgType_REQ message
596 *
597 * @return None
598 */
599
600void
601lim_send_sme_start_bss_rsp(tpAniSirGlobal pMac,
602 uint16_t msgType, tSirResultCodes resultCode,
603 tpPESession psessionEntry, uint8_t smesessionId,
604 uint16_t smetransactionId)
605{
606
607 uint16_t size = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700608 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800609 tSirSmeStartBssRsp *pSirSmeRsp;
610 uint16_t ieLen;
611 uint16_t ieOffset, curLen;
612
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530613 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800614 lim_msg_str(msgType), lim_result_code_str(resultCode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800615
616 size = sizeof(tSirSmeStartBssRsp);
617
618 if (psessionEntry == NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530619 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800620 if (NULL == pSirSmeRsp) {
621 /* / Buffer not available. Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530622 pe_err("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800623 return;
624 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800625 } else {
626 /* subtract size of beaconLength + Mac Hdr + Fixed Fields before SSID */
627 ieOffset = sizeof(tAniBeaconStruct) + SIR_MAC_B_PR_SSID_OFFSET;
628 ieLen = psessionEntry->schBeaconOffsetBegin
629 + psessionEntry->schBeaconOffsetEnd - ieOffset;
630 /* calculate the memory size to allocate */
631 size += ieLen;
632
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530633 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800634 if (NULL == pSirSmeRsp) {
635 /* / Buffer not available. Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530636 pe_err("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800637 return;
638 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800639 size = sizeof(tSirSmeStartBssRsp);
640 if (resultCode == eSIR_SME_SUCCESS) {
641
642 sir_copy_mac_addr(pSirSmeRsp->bssDescription.bssId,
643 psessionEntry->bssId);
644
645 /* Read beacon interval from session */
646 pSirSmeRsp->bssDescription.beaconInterval =
647 (uint16_t) psessionEntry->beaconParams.
648 beaconInterval;
649 pSirSmeRsp->bssType = psessionEntry->bssType;
650
651 if (cfg_get_capability_info
652 (pMac, &pSirSmeRsp->bssDescription.capabilityInfo,
653 psessionEntry)
654 != eSIR_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530655 pe_err("could not retrieve Capabilities value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800656
657 lim_get_phy_mode(pMac,
658 (uint32_t *) &pSirSmeRsp->bssDescription.
659 nwType, psessionEntry);
660
661 pSirSmeRsp->bssDescription.channelId =
662 psessionEntry->currentOperChannel;
663
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700664 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800665 curLen = psessionEntry->schBeaconOffsetBegin - ieOffset;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530666 qdf_mem_copy((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800667 ieFields,
668 psessionEntry->pSchBeaconFrameBegin +
669 ieOffset, (uint32_t) curLen);
670
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530671 qdf_mem_copy(((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800672 ieFields) + curLen,
673 psessionEntry->pSchBeaconFrameEnd,
674 (uint32_t) psessionEntry->
675 schBeaconOffsetEnd);
676
Abhishek Singh34a4d862016-10-26 16:01:51 +0530677 pSirSmeRsp->bssDescription.length = (uint16_t)
678 (offsetof(tSirBssDescription, ieFields[0])
679 - sizeof(pSirSmeRsp->bssDescription.length)
680 + ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800681 /* This is the size of the message, subtracting the size of the pointer to ieFields */
682 size += ieLen - sizeof(uint32_t);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700683 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800684#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
685 if (psessionEntry->cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530686 != QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800687 pSirSmeRsp->HTProfile.
688 htSupportedChannelWidthSet =
689 psessionEntry->htSupportedChannelWidthSet;
690 pSirSmeRsp->HTProfile.htRecommendedTxWidthSet =
691 psessionEntry->htRecommendedTxWidthSet;
692 pSirSmeRsp->HTProfile.htSecondaryChannelOffset =
693 psessionEntry->htSecondaryChannelOffset;
694 pSirSmeRsp->HTProfile.dot11mode =
695 psessionEntry->dot11mode;
696 pSirSmeRsp->HTProfile.htCapability =
697 psessionEntry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800698 pSirSmeRsp->HTProfile.vhtCapability =
699 psessionEntry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800700 pSirSmeRsp->HTProfile.apCenterChan =
701 psessionEntry->ch_center_freq_seg0;
702 pSirSmeRsp->HTProfile.apChanWidth =
703 psessionEntry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800704 }
705#endif
706 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800707 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800708 pSirSmeRsp->messageType = msgType;
709 pSirSmeRsp->length = size;
710
711 /* Update SME session Id and transaction Id */
712 pSirSmeRsp->sessionId = smesessionId;
713 pSirSmeRsp->transactionId = smetransactionId;
714 pSirSmeRsp->statusCode = resultCode;
715 if (psessionEntry != NULL)
716 pSirSmeRsp->staId = psessionEntry->staId; /* else it will be always zero smeRsp StaID = 0 */
717
718 mmhMsg.type = msgType;
719 mmhMsg.bodyptr = pSirSmeRsp;
720 mmhMsg.bodyval = 0;
721 if (psessionEntry == NULL) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530722 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
723 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800724 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530725 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
726 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800727 }
728#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
729 lim_diag_event_report(pMac, WLAN_PE_DIAG_START_BSS_RSP_EVENT,
730 psessionEntry, (uint16_t) resultCode, 0);
731#endif /* FEATURE_WLAN_DIAG_SUPPORT */
732
733 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
734} /*** end lim_send_sme_start_bss_rsp() ***/
735
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800736/**
737 * lim_send_sme_scan_rsp() - Send scan response to SME
738 * @pMac: Pointer to Global MAC structure
739 * @length: Indicates length of message
740 * @resultCode: Indicates the result of previously issued
741 * eWNI_SME_SCAN_REQ message
742 * @scan_id: scan identifier
743 *
744 * This function is called by lim_process_sme_req_messages() to send
745 * eWNI_SME_SCAN_RSP message to applications above MAC
746 *
747 * return: None
748 */
749
750void
751lim_send_sme_scan_rsp(tpAniSirGlobal pMac, tSirResultCodes resultCode,
752 uint8_t smesessionId, uint16_t smetranscationId,
753 uint32_t scan_id)
754{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800755 lim_post_sme_scan_rsp_message(pMac, resultCode, smesessionId,
756 smetranscationId, scan_id);
757}
758
759/**
760 * lim_post_sme_scan_rsp_message()
761 *
762 ***FUNCTION:
763 * This function is called by lim_send_sme_scan_rsp() to send
764 * eWNI_SME_SCAN_RSP message with failed result code
765 *
766 ***NOTE:
767 * NA
768 *
769 * @param pMac Pointer to Global MAC structure
770 * @param length Indicates length of message
771 * @param resultCode failed result code
772 *
773 * @return None
774 */
775
776void
777lim_post_sme_scan_rsp_message(tpAniSirGlobal pMac,
778 tSirResultCodes resultCode, uint8_t smesessionId,
779 uint16_t smetransactionId,
780 uint32_t scan_id)
781{
782 tpSirSmeScanRsp pSirSmeScanRsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700783 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800784
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530785 pe_debug("send SME_SCAN_RSP reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800786 lim_result_code_str(resultCode));
787
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530788 pSirSmeScanRsp = qdf_mem_malloc(sizeof(tSirSmeScanRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800789 if (NULL == pSirSmeScanRsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530790 pe_err("AllocateMemory failed for eWNI_SME_SCAN_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800791 return;
792 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800793
794 pSirSmeScanRsp->messageType = eWNI_SME_SCAN_RSP;
795 pSirSmeScanRsp->statusCode = resultCode;
796
797 /*Update SME session Id and transaction Id */
798 pSirSmeScanRsp->sessionId = smesessionId;
799 pSirSmeScanRsp->transcationId = smetransactionId;
800 pSirSmeScanRsp->scan_id = scan_id;
801
802 mmhMsg.type = eWNI_SME_SCAN_RSP;
803 mmhMsg.bodyptr = pSirSmeScanRsp;
804 mmhMsg.bodyval = 0;
805
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530806 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800807#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
808 lim_diag_event_report(pMac, WLAN_PE_DIAG_SCAN_RSP_EVENT, NULL,
809 (uint16_t) resultCode, 0);
810#endif /* FEATURE_WLAN_DIAG_SUPPORT */
811
812 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
813 return;
814
815} /*** lim_post_sme_scan_rsp_message ***/
816
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800817void lim_send_sme_disassoc_deauth_ntf(tpAniSirGlobal pMac,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530818 QDF_STATUS status, uint32_t *pCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800819{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700820 struct scheduler_msg mmhMsg = {0};
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800821 struct scheduler_msg *pMsg = (struct scheduler_msg *) pCtx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800822
823 mmhMsg.type = pMsg->type;
824 mmhMsg.bodyptr = pMsg;
825 mmhMsg.bodyval = 0;
826
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530827 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800828
829 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
830}
831
832/**
833 * lim_send_sme_disassoc_ntf()
834 *
835 ***FUNCTION:
836 * This function is called by limProcessSmeMessages() to send
837 * eWNI_SME_DISASSOC_RSP/IND message to host
838 *
839 ***PARAMS:
840 *
841 ***LOGIC:
842 *
843 ***ASSUMPTIONS:
844 * NA
845 *
846 ***NOTE:
847 * This function is used for sending eWNI_SME_DISASSOC_CNF,
848 * or eWNI_SME_DISASSOC_IND to host depending on
849 * disassociation trigger.
850 *
851 * @param peerMacAddr Indicates the peer MAC addr to which
852 * disassociate was initiated
853 * @param reasonCode Indicates the reason for Disassociation
854 * @param disassocTrigger Indicates the trigger for Disassociation
855 * @param aid Indicates the STAID. This parameter is
856 * present only on AP.
857 *
858 * @return None
859 */
860void
861lim_send_sme_disassoc_ntf(tpAniSirGlobal pMac,
862 tSirMacAddr peerMacAddr,
863 tSirResultCodes reasonCode,
864 uint16_t disassocTrigger,
865 uint16_t aid,
866 uint8_t smesessionId,
867 uint16_t smetransactionId, tpPESession psessionEntry)
868{
869
870 uint8_t *pBuf;
871 tSirSmeDisassocRsp *pSirSmeDisassocRsp;
872 tSirSmeDisassocInd *pSirSmeDisassocInd;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700873 uint32_t *pMsg = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800874 bool failure = false;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700875 tpPESession session = NULL;
876 uint16_t i, assoc_id;
877 tpDphHashNode sta_ds = NULL;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530878 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800879
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530880 pe_debug("Disassoc Ntf with trigger : %d reasonCode: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800881 disassocTrigger, reasonCode);
882
883 switch (disassocTrigger) {
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700884 case eLIM_DUPLICATE_ENTRY:
885 /*
886 * Duplicate entry is removed at LIM.
887 * Initiate new entry for other session
888 */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530889 pe_debug("Rcvd eLIM_DUPLICATE_ENTRY for " MAC_ADDRESS_STR,
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700890 MAC_ADDR_ARRAY(peerMacAddr));
891
892 for (i = 0; i < pMac->lim.maxBssId; i++) {
893 if ((&pMac->lim.gpSession[i] != NULL) &&
894 (pMac->lim.gpSession[i].valid) &&
895 (pMac->lim.gpSession[i].pePersona ==
896 QDF_SAP_MODE)) {
897 /* Find the sta ds entry in another session */
898 session = &pMac->lim.gpSession[i];
899 sta_ds = dph_lookup_hash_entry(pMac,
900 peerMacAddr, &assoc_id,
901 &session->dph.dphHashTable);
902 }
903 }
904 if (sta_ds
905#ifdef WLAN_FEATURE_11W
906 && (!sta_ds->rmfEnabled)
907#endif
908 ) {
909 if (lim_add_sta(pMac, sta_ds, false, session) !=
910 eSIR_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530911 pe_err("could not Add STA with assocId: %d",
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700912 sta_ds->assocId);
913 }
914 failure = true;
915 break;
916
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800917 case eLIM_HOST_DISASSOC:
918 /**
919 * Disassociation response due to
920 * host triggered disassociation
921 */
922
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530923 pSirSmeDisassocRsp = qdf_mem_malloc(sizeof(tSirSmeDisassocRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800924 if (NULL == pSirSmeDisassocRsp) {
925 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530926 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800927 failure = true;
928 goto error;
929 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530930 pe_debug("send eWNI_SME_DISASSOC_RSP with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800931 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
932 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
933 pSirSmeDisassocRsp->length = sizeof(tSirSmeDisassocRsp);
934 /* sessionId */
935 pBuf = (uint8_t *) &pSirSmeDisassocRsp->sessionId;
936 *pBuf = smesessionId;
937 pBuf++;
938
939 /* transactionId */
940 lim_copy_u16(pBuf, smetransactionId);
941 pBuf += sizeof(uint16_t);
942
943 /* statusCode */
944 lim_copy_u32(pBuf, reasonCode);
945 pBuf += sizeof(tSirResultCodes);
946
947 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530948 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800949 pBuf += sizeof(tSirMacAddr);
950
951 /* Clear Station Stats */
952 /* for sta, it is always 1, IBSS is handled at halInitSta */
953
954#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
955
956 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
957 psessionEntry, (uint16_t) reasonCode, 0);
958#endif
959 pMsg = (uint32_t *) pSirSmeDisassocRsp;
960 break;
961
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530962 case eLIM_PEER_ENTITY_DISASSOC:
963 case eLIM_LINK_MONITORING_DISASSOC:
964 sir_sme_dis_ind =
965 qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
966 if (!sir_sme_dis_ind) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530967 pe_err("call to AllocateMemory failed for disconnect indication");
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530968 return;
969 }
970
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530971 pe_debug("send eWNI_SME_DISCONNECT_DONE_IND with retCode: %d",
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530972 reasonCode);
973
974 sir_sme_dis_ind->message_type =
975 eWNI_SME_DISCONNECT_DONE_IND;
976 sir_sme_dis_ind->length =
977 sizeof(*sir_sme_dis_ind);
978 qdf_mem_copy(sir_sme_dis_ind->peer_mac, peerMacAddr,
979 sizeof(tSirMacAddr));
980 sir_sme_dis_ind->session_id = smesessionId;
981 sir_sme_dis_ind->reason_code = reasonCode;
Selvaraj, Sridharc7d80892016-09-29 11:56:45 +0530982 /*
983 * Instead of sending deauth reason code as 505 which is
984 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
985 * Send reason code as zero to Supplicant
986 */
987 if (reasonCode == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
988 sir_sme_dis_ind->reason_code = 0;
989 else
990 sir_sme_dis_ind->reason_code = reasonCode;
991
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530992 pMsg = (uint32_t *)sir_sme_dis_ind;
993
994 break;
995
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800996 default:
997 /**
998 * Disassociation indication due to Disassociation
999 * frame reception from peer entity or due to
1000 * loss of link with peer entity.
1001 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301002 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001003 if (NULL == pSirSmeDisassocInd) {
1004 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301005 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001006 failure = true;
1007 goto error;
1008 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301009 pe_debug("send eWNI_SME_DISASSOC_IND with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001010 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1011 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
1012 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
1013
1014 /* Update SME session Id and Transaction Id */
1015 pSirSmeDisassocInd->sessionId = smesessionId;
1016 pSirSmeDisassocInd->transactionId = smetransactionId;
1017 pSirSmeDisassocInd->reasonCode = reasonCode;
1018 pBuf = (uint8_t *) &pSirSmeDisassocInd->statusCode;
1019
1020 lim_copy_u32(pBuf, reasonCode);
1021 pBuf += sizeof(tSirResultCodes);
1022
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301023 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001024 pBuf += sizeof(tSirMacAddr);
1025
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301026 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001027
1028#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1029 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
1030 psessionEntry, (uint16_t) reasonCode, 0);
1031#endif
1032 pMsg = (uint32_t *) pSirSmeDisassocInd;
1033
1034 break;
1035 }
1036
1037error:
1038 /* Delete the PE session Created */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07001039 if ((psessionEntry != NULL) && LIM_IS_STA_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040 pe_delete_session(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001041
1042 if (false == failure)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301043 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001044 (uint32_t *) pMsg);
1045} /*** end lim_send_sme_disassoc_ntf() ***/
1046
1047/** -----------------------------------------------------------------
1048 \brief lim_send_sme_disassoc_ind() - sends SME_DISASSOC_IND
1049
1050 After receiving disassociation frame from peer entity, this
1051 function sends a eWNI_SME_DISASSOC_IND to SME with a specific
1052 reason code.
1053
1054 \param pMac - global mac structure
1055 \param pStaDs - station dph hash node
1056 \return none
1057 \sa
1058 ----------------------------------------------------------------- */
1059void
1060lim_send_sme_disassoc_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1061 tpPESession psessionEntry)
1062{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001063 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001064 tSirSmeDisassocInd *pSirSmeDisassocInd;
1065
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301066 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001067 if (NULL == pSirSmeDisassocInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301068 pe_err("AllocateMemory failed for eWNI_SME_DISASSOC_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001069 return;
1070 }
1071
1072 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
1073 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
1074
1075 pSirSmeDisassocInd->sessionId = psessionEntry->smeSessionId;
1076 pSirSmeDisassocInd->transactionId = psessionEntry->transactionId;
Padma, Santhosh Kumar02289212016-09-30 13:30:08 +05301077 pSirSmeDisassocInd->statusCode = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001078 pSirSmeDisassocInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1079
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301080 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301081 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001082
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301083 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301084 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001085
1086 pSirSmeDisassocInd->staId = pStaDs->staIndex;
1087
1088 mmhMsg.type = eWNI_SME_DISASSOC_IND;
1089 mmhMsg.bodyptr = pSirSmeDisassocInd;
1090 mmhMsg.bodyval = 0;
1091
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301092 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1093 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001094#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1095 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT, psessionEntry,
1096 0, (uint16_t) pStaDs->mlmStaContext.disassocReason);
1097#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1098
1099 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1100
1101} /*** end lim_send_sme_disassoc_ind() ***/
1102
1103/** -----------------------------------------------------------------
1104 \brief lim_send_sme_deauth_ind() - sends SME_DEAUTH_IND
1105
1106 After receiving deauthentication frame from peer entity, this
1107 function sends a eWNI_SME_DEAUTH_IND to SME with a specific
1108 reason code.
1109
1110 \param pMac - global mac structure
1111 \param pStaDs - station dph hash node
1112 \return none
1113 \sa
1114 ----------------------------------------------------------------- */
1115void
1116lim_send_sme_deauth_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1117 tpPESession psessionEntry)
1118{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001119 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001120 tSirSmeDeauthInd *pSirSmeDeauthInd;
1121
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301122 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001123 if (NULL == pSirSmeDeauthInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301124 pe_err("AllocateMemory failed for eWNI_SME_DEAUTH_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001125 return;
1126 }
1127
1128 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1129 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1130
1131 pSirSmeDeauthInd->sessionId = psessionEntry->smeSessionId;
1132 pSirSmeDeauthInd->transactionId = psessionEntry->transactionId;
1133 if (eSIR_INFRA_AP_MODE == psessionEntry->bssType) {
1134 pSirSmeDeauthInd->statusCode =
1135 (tSirResultCodes) pStaDs->mlmStaContext.cleanupTrigger;
1136 } else {
1137 /* Need to indicatet he reascon code over the air */
1138 pSirSmeDeauthInd->statusCode =
1139 (tSirResultCodes) pStaDs->mlmStaContext.disassocReason;
1140 }
1141 /* BSSID */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301142 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301143 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001144 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301145 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301146 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001147 pSirSmeDeauthInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1148
1149 pSirSmeDeauthInd->staId = pStaDs->staIndex;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001150 if (eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON ==
1151 pStaDs->mlmStaContext.disassocReason)
1152 pSirSmeDeauthInd->rssi = pStaDs->del_sta_ctx_rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001153
1154 mmhMsg.type = eWNI_SME_DEAUTH_IND;
1155 mmhMsg.bodyptr = pSirSmeDeauthInd;
1156 mmhMsg.bodyval = 0;
1157
1158 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1159#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1160 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT, psessionEntry,
1161 0, pStaDs->mlmStaContext.cleanupTrigger);
1162#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1163
1164 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1165 return;
1166} /*** end lim_send_sme_deauth_ind() ***/
1167
1168#ifdef FEATURE_WLAN_TDLS
1169/**
1170 * lim_send_sme_tdls_del_sta_ind()
1171 *
1172 ***FUNCTION:
1173 * This function is called to send the TDLS STA context deletion to SME.
1174 *
1175 ***LOGIC:
1176 *
1177 ***ASSUMPTIONS:
1178 *
1179 ***NOTE:
1180 * NA
1181 *
1182 * @param pMac - Pointer to global MAC structure
1183 * @param pStaDs - Pointer to internal STA Datastructure
1184 * @param psessionEntry - Pointer to the session entry
1185 * @param reasonCode - Reason for TDLS sta deletion
1186 * @return None
1187 */
1188void
1189lim_send_sme_tdls_del_sta_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1190 tpPESession psessionEntry, uint16_t reasonCode)
1191{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001192 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001193 tSirTdlsDelStaInd *pSirTdlsDelStaInd;
1194
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301195 pSirTdlsDelStaInd = qdf_mem_malloc(sizeof(tSirTdlsDelStaInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001196 if (NULL == pSirTdlsDelStaInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301197 pe_err("AllocateMemory failed for eWNI_SME_TDLS_DEL_STA_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001198 return;
1199 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301200 pe_debug("Delete TDLS Peer "MAC_ADDRESS_STR "with reason code: %d",
Nitesh Shah82c52812016-12-27 12:27:51 +05301201 MAC_ADDR_ARRAY(pStaDs->staAddr), reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001202 /* messageType */
1203 pSirTdlsDelStaInd->messageType = eWNI_SME_TDLS_DEL_STA_IND;
1204 pSirTdlsDelStaInd->length = sizeof(tSirTdlsDelStaInd);
1205
1206 /* sessionId */
1207 pSirTdlsDelStaInd->sessionId = psessionEntry->smeSessionId;
1208
1209 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301210 qdf_mem_copy(pSirTdlsDelStaInd->peermac.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301211 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001212
1213 /* staId */
1214 lim_copy_u16((uint8_t *) (&pSirTdlsDelStaInd->staId),
1215 (uint16_t) pStaDs->staIndex);
1216
1217 /* reasonCode */
1218 lim_copy_u16((uint8_t *) (&pSirTdlsDelStaInd->reasonCode), reasonCode);
1219
1220 mmhMsg.type = eWNI_SME_TDLS_DEL_STA_IND;
1221 mmhMsg.bodyptr = pSirTdlsDelStaInd;
1222 mmhMsg.bodyval = 0;
1223
1224 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1225 return;
1226} /*** end lim_send_sme_tdls_del_sta_ind() ***/
1227
1228/**
1229 * lim_send_sme_tdls_delete_all_peer_ind()
1230 *
1231 ***FUNCTION:
1232 * This function is called to send the eWNI_SME_TDLS_DEL_ALL_PEER_IND
1233 * message to SME.
1234 *
1235 ***LOGIC:
1236 *
1237 ***ASSUMPTIONS:
1238 *
1239 ***NOTE:
1240 * NA
1241 *
1242 * @param pMac - Pointer to global MAC structure
1243 * @param psessionEntry - Pointer to the session entry
1244 * @return None
1245 */
1246void
1247lim_send_sme_tdls_delete_all_peer_ind(tpAniSirGlobal pMac, tpPESession psessionEntry)
1248{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001249 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001250 tSirTdlsDelAllPeerInd *pSirTdlsDelAllPeerInd;
1251
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301252 pSirTdlsDelAllPeerInd = qdf_mem_malloc(sizeof(tSirTdlsDelAllPeerInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001253 if (NULL == pSirTdlsDelAllPeerInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301254 pe_err("AllocateMemory failed for eWNI_SME_TDLS_DEL_ALL_PEER_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001255 return;
1256 }
1257 /* messageType */
1258 pSirTdlsDelAllPeerInd->messageType = eWNI_SME_TDLS_DEL_ALL_PEER_IND;
1259 pSirTdlsDelAllPeerInd->length = sizeof(tSirTdlsDelAllPeerInd);
1260
1261 /* sessionId */
1262 pSirTdlsDelAllPeerInd->sessionId = psessionEntry->smeSessionId;
1263
1264 mmhMsg.type = eWNI_SME_TDLS_DEL_ALL_PEER_IND;
1265 mmhMsg.bodyptr = pSirTdlsDelAllPeerInd;
1266 mmhMsg.bodyval = 0;
1267
1268 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1269 return;
1270} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1271
1272/**
1273 * lim_send_sme_mgmt_tx_completion()
1274 *
1275 ***FUNCTION:
1276 * This function is called to send the eWNI_SME_MGMT_FRM_TX_COMPLETION_IND
1277 * message to SME.
1278 *
1279 ***LOGIC:
1280 *
1281 ***ASSUMPTIONS:
1282 *
1283 ***NOTE:
1284 * NA
1285 *
1286 * @param pMac - Pointer to global MAC structure
1287 * @param psessionEntry - Pointer to the session entry
1288 * @param txCompleteStatus - TX Complete Status of Mgmt Frames
1289 * @return None
1290 */
1291void
1292lim_send_sme_mgmt_tx_completion(tpAniSirGlobal pMac,
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301293 uint32_t sme_session_id,
1294 uint32_t txCompleteStatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001295{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001296 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001297 tSirMgmtTxCompletionInd *pSirMgmtTxCompletionInd;
1298
1299 pSirMgmtTxCompletionInd =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301300 qdf_mem_malloc(sizeof(tSirMgmtTxCompletionInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001301 if (NULL == pSirMgmtTxCompletionInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301302 pe_err("AllocateMemory failed for eWNI_SME_MGMT_FRM_TX_COMPLETION_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001303 return;
1304 }
1305 /* messageType */
1306 pSirMgmtTxCompletionInd->messageType =
1307 eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1308 pSirMgmtTxCompletionInd->length = sizeof(tSirMgmtTxCompletionInd);
1309
1310 /* sessionId */
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301311 pSirMgmtTxCompletionInd->sessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001312
1313 pSirMgmtTxCompletionInd->txCompleteStatus = txCompleteStatus;
1314
1315 mmhMsg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1316 mmhMsg.bodyptr = pSirMgmtTxCompletionInd;
1317 mmhMsg.bodyval = 0;
1318
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07001319#ifdef CONVERGED_TDLS_ENABLE
1320 pSirMgmtTxCompletionInd->psoc = pMac->psoc;
1321 mmhMsg.callback = tgt_tdls_send_mgmt_tx_completion;
1322 scheduler_post_msg(QDF_MODULE_ID_TARGET_IF, &mmhMsg);
1323 return;
1324#else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1326 return;
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07001327#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001328} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1329
1330void lim_send_sme_tdls_event_notify(tpAniSirGlobal pMac, uint16_t msgType,
1331 void *events)
1332{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001333 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001334
1335 switch (msgType) {
1336 case SIR_HAL_TDLS_SHOULD_DISCOVER:
1337 mmhMsg.type = eWNI_SME_TDLS_SHOULD_DISCOVER;
1338 break;
1339 case SIR_HAL_TDLS_SHOULD_TEARDOWN:
1340 mmhMsg.type = eWNI_SME_TDLS_SHOULD_TEARDOWN;
1341 break;
1342 case SIR_HAL_TDLS_PEER_DISCONNECTED:
1343 mmhMsg.type = eWNI_SME_TDLS_PEER_DISCONNECTED;
1344 break;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07001345 case SIR_HAL_TDLS_CONNECTION_TRACKER_NOTIFICATION:
1346 mmhMsg.type = eWNI_SME_TDLS_CONNECTION_TRACKER_NOTIFICATION;
1347 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001348 }
1349
1350 mmhMsg.bodyptr = events;
1351 mmhMsg.bodyval = 0;
1352 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1353 return;
1354}
1355#endif /* FEATURE_WLAN_TDLS */
1356
1357/**
1358 * lim_send_sme_deauth_ntf()
1359 *
1360 ***FUNCTION:
1361 * This function is called by limProcessSmeMessages() to send
1362 * eWNI_SME_DISASSOC_RSP/IND message to host
1363 *
1364 ***PARAMS:
1365 *
1366 ***LOGIC:
1367 *
1368 ***ASSUMPTIONS:
1369 * NA
1370 *
1371 ***NOTE:
1372 * This function is used for sending eWNI_SME_DEAUTH_CNF or
1373 * eWNI_SME_DEAUTH_IND to host depending on deauthentication trigger.
1374 *
1375 * @param peerMacAddr Indicates the peer MAC addr to which
1376 * deauthentication was initiated
1377 * @param reasonCode Indicates the reason for Deauthetication
1378 * @param deauthTrigger Indicates the trigger for Deauthetication
1379 * @param aid Indicates the STAID. This parameter is present
1380 * only on AP.
1381 *
1382 * @return None
1383 */
1384void
1385lim_send_sme_deauth_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
1386 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1387 uint16_t aid, uint8_t smesessionId,
1388 uint16_t smetransactionId)
1389{
1390 uint8_t *pBuf;
1391 tSirSmeDeauthRsp *pSirSmeDeauthRsp;
1392 tSirSmeDeauthInd *pSirSmeDeauthInd;
1393 tpPESession psessionEntry;
1394 uint8_t sessionId;
1395 uint32_t *pMsg;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301396 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001397
1398 psessionEntry = pe_find_session_by_bssid(pMac, peerMacAddr, &sessionId);
1399 switch (deauthTrigger) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001400 case eLIM_HOST_DEAUTH:
1401 /**
1402 * Deauthentication response to host triggered
1403 * deauthentication.
1404 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301405 pSirSmeDeauthRsp = qdf_mem_malloc(sizeof(tSirSmeDeauthRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001406 if (NULL == pSirSmeDeauthRsp) {
1407 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301408 pe_err("call to AllocateMemory failed for eWNI_SME_DEAUTH_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001409 return;
1410 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301411 pe_debug("send eWNI_SME_DEAUTH_RSP with retCode: %d for" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001412 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1413 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
1414 pSirSmeDeauthRsp->length = sizeof(tSirSmeDeauthRsp);
1415 pSirSmeDeauthRsp->statusCode = reasonCode;
1416 pSirSmeDeauthRsp->sessionId = smesessionId;
1417 pSirSmeDeauthRsp->transactionId = smetransactionId;
1418
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -08001419 pBuf = (uint8_t *) pSirSmeDeauthRsp->peer_macaddr.bytes;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301420 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001421
1422#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1423 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
1424 psessionEntry, 0, (uint16_t) reasonCode);
1425#endif
1426 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1427
1428 break;
1429
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301430 case eLIM_PEER_ENTITY_DEAUTH:
1431 case eLIM_LINK_MONITORING_DEAUTH:
1432 sir_sme_dis_ind =
1433 qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
1434 if (!sir_sme_dis_ind) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301435 pe_err("call to AllocateMemory failed for disconnect indication");
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301436 return;
1437 }
1438
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301439 pe_debug("send eWNI_SME_DISCONNECT_DONE_IND withretCode: %d",
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301440 reasonCode);
1441
1442 sir_sme_dis_ind->message_type =
1443 eWNI_SME_DISCONNECT_DONE_IND;
1444 sir_sme_dis_ind->length =
1445 sizeof(*sir_sme_dis_ind);
1446 sir_sme_dis_ind->session_id = smesessionId;
1447 sir_sme_dis_ind->reason_code = reasonCode;
1448 qdf_mem_copy(sir_sme_dis_ind->peer_mac, peerMacAddr,
1449 ETH_ALEN);
Selvaraj, Sridharc7d80892016-09-29 11:56:45 +05301450 /*
1451 * Instead of sending deauth reason code as 505 which is
1452 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1453 * Send reason code as zero to Supplicant
1454 */
1455 if (reasonCode == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1456 sir_sme_dis_ind->reason_code = 0;
1457 else
1458 sir_sme_dis_ind->reason_code = reasonCode;
1459
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301460 pMsg = (uint32_t *)sir_sme_dis_ind;
1461
1462 break;
1463
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001464 default:
1465 /**
1466 * Deauthentication indication due to Deauthentication
1467 * frame reception from peer entity or due to
1468 * loss of link with peer entity.
1469 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301470 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001471 if (NULL == pSirSmeDeauthInd) {
1472 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301473 pe_err("call to AllocateMemory failed for eWNI_SME_DEAUTH_Ind");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001474 return;
1475 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301476 pe_debug("send eWNI_SME_DEAUTH_IND with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001477 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1478 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1479 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1480 pSirSmeDeauthInd->reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
1481
1482 /* sessionId */
1483 pBuf = (uint8_t *) &pSirSmeDeauthInd->sessionId;
1484 *pBuf++ = smesessionId;
1485
1486 /* transaction ID */
1487 lim_copy_u16(pBuf, smetransactionId);
1488 pBuf += sizeof(uint16_t);
1489
1490 /* status code */
1491 lim_copy_u32(pBuf, reasonCode);
1492 pBuf += sizeof(tSirResultCodes);
1493
1494 /* bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301495 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001496 pBuf += sizeof(tSirMacAddr);
1497
1498 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301499 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301500 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001501
1502#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1503 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
1504 psessionEntry, 0, (uint16_t) reasonCode);
1505#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1506 pMsg = (uint32_t *) pSirSmeDeauthInd;
1507
1508 break;
1509 }
1510
1511 /*Delete the PE session created */
1512 if (psessionEntry != NULL) {
1513 pe_delete_session(pMac, psessionEntry);
1514 }
1515
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301516 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001517 (uint32_t *) pMsg);
1518
1519} /*** end lim_send_sme_deauth_ntf() ***/
1520
1521/**
1522 * lim_send_sme_wm_status_change_ntf() - Send Notification
1523 * @mac_ctx: Global MAC Context
1524 * @status_change_code: Indicates the change in the wireless medium.
1525 * @status_change_info: Indicates the information associated with
1526 * change in the wireless medium.
1527 * @info_len: Indicates the length of status change information
1528 * being sent.
1529 * @session_id SessionID
1530 *
1531 * This function is called by limProcessSmeMessages() to send
1532 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1533 *
1534 * Return: None
1535 */
1536void
1537lim_send_sme_wm_status_change_ntf(tpAniSirGlobal mac_ctx,
1538 tSirSmeStatusChangeCode status_change_code,
1539 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1540{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001541 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001542 tSirSmeWmStatusChangeNtf *wm_status_change_ntf;
Naveen Rawate01ed172016-11-17 11:34:50 -08001543 uint32_t max_info_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001544
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301545 wm_status_change_ntf = qdf_mem_malloc(sizeof(tSirSmeWmStatusChangeNtf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001546 if (NULL == wm_status_change_ntf) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301547 pe_err("Mem Alloc failed - eWNI_SME_WM_STATUS_CHANGE_NTF");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001548 return;
1549 }
1550
1551 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1552 msg.bodyval = 0;
1553 msg.bodyptr = wm_status_change_ntf;
1554
1555 switch (status_change_code) {
Naveen Rawate01ed172016-11-17 11:34:50 -08001556 case eSIR_SME_AP_CAPS_CHANGED:
1557 max_info_len = sizeof(tSirSmeApNewCaps);
1558 break;
1559 case eSIR_SME_JOINED_NEW_BSS:
1560 max_info_len = sizeof(tSirSmeNewBssInfo);
1561 break;
1562 default:
1563 max_info_len = sizeof(wm_status_change_ntf->statusChangeInfo);
1564 break;
1565 }
1566
1567 switch (status_change_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001568 case eSIR_SME_RADAR_DETECTED:
1569 break;
1570 default:
1571 wm_status_change_ntf->messageType =
1572 eWNI_SME_WM_STATUS_CHANGE_NTF;
1573 wm_status_change_ntf->statusChangeCode = status_change_code;
1574 wm_status_change_ntf->length = sizeof(tSirSmeWmStatusChangeNtf);
1575 wm_status_change_ntf->sessionId = session_id;
Naveen Rawate01ed172016-11-17 11:34:50 -08001576 if (info_len <= max_info_len && status_change_info) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301577 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001578 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1579 (uint8_t *) status_change_info, info_len);
1580 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301581 pe_debug("StatusChg code: 0x%x length: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001582 status_change_code, info_len);
1583 break;
1584 }
1585
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301586 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001587 if (eSIR_SUCCESS != lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301588 qdf_mem_free(wm_status_change_ntf);
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301589 pe_err("lim_sys_process_mmh_msg_api failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001590 }
1591
1592} /*** end lim_send_sme_wm_status_change_ntf() ***/
1593
1594/**
1595 * lim_send_sme_set_context_rsp()
1596 *
1597 ***FUNCTION:
1598 * This function is called by limProcessSmeMessages() to send
1599 * eWNI_SME_SETCONTEXT_RSP message to host
1600 *
1601 ***PARAMS:
1602 *
1603 ***LOGIC:
1604 *
1605 ***ASSUMPTIONS:
1606 * NA
1607 *
1608 ***NOTE:
1609 *
1610 * @param pMac Pointer to Global MAC structure
1611 * @param peerMacAddr Indicates the peer MAC addr to which
1612 * setContext was performed
1613 * @param aid Indicates the aid corresponding to the peer MAC
1614 * address
1615 * @param resultCode Indicates the result of previously issued
1616 * eWNI_SME_SETCONTEXT_RSP message
1617 *
1618 * @return None
1619 */
1620void
1621lim_send_sme_set_context_rsp(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301622 struct qdf_mac_addr peer_macaddr, uint16_t aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001623 tSirResultCodes resultCode,
1624 tpPESession psessionEntry, uint8_t smesessionId,
1625 uint16_t smetransactionId)
1626{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001627 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001628 tSirSmeSetContextRsp *pSirSmeSetContextRsp;
1629
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301630 pSirSmeSetContextRsp = qdf_mem_malloc(sizeof(tSirSmeSetContextRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001631 if (NULL == pSirSmeSetContextRsp) {
1632 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301633 pe_err("call to AllocateMemory failed for SmeSetContextRsp");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001634 return;
1635 }
1636
1637 pSirSmeSetContextRsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1638 pSirSmeSetContextRsp->length = sizeof(tSirSmeSetContextRsp);
1639 pSirSmeSetContextRsp->statusCode = resultCode;
1640
Anurag Chouhanc5548422016-02-24 18:33:27 +05301641 qdf_copy_macaddr(&pSirSmeSetContextRsp->peer_macaddr, &peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001642
1643 /* Update SME session and transaction Id */
1644 pSirSmeSetContextRsp->sessionId = smesessionId;
1645 pSirSmeSetContextRsp->transactionId = smetransactionId;
1646
1647 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
1648 mmhMsg.bodyptr = pSirSmeSetContextRsp;
1649 mmhMsg.bodyval = 0;
1650 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301651 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1652 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001653 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301654 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1655 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001656 }
1657
1658#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1659 lim_diag_event_report(pMac, WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
1660 psessionEntry, (uint16_t) resultCode, 0);
1661#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1662
1663 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1664} /*** end lim_send_sme_set_context_rsp() ***/
1665
1666/**
1667 * lim_send_sme_neighbor_bss_ind()
1668 *
1669 ***FUNCTION:
1670 * This function is called by lim_lookup_nadd_hash_entry() to send
1671 * eWNI_SME_NEIGHBOR_BSS_IND message to host
1672 *
1673 ***PARAMS:
1674 *
1675 ***LOGIC:
1676 *
1677 ***ASSUMPTIONS:
1678 * NA
1679 *
1680 ***NOTE:
1681 * This function is used for sending eWNI_SME_NEIGHBOR_BSS_IND to
1682 * host upon detecting new BSS during background scanning if CFG
1683 * option is enabled for sending such indication
1684 *
1685 * @param pMac - Pointer to Global MAC structure
1686 * @return None
1687 */
1688
1689void
1690lim_send_sme_neighbor_bss_ind(tpAniSirGlobal pMac, tLimScanResultNode *pBssDescr)
1691{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001692 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001693 uint32_t val;
1694 tSirSmeNeighborBssInd *pNewBssInd;
1695
1696 if ((pMac->lim.gLimSmeState != eLIM_SME_LINK_EST_WT_SCAN_STATE) ||
1697 ((pMac->lim.gLimSmeState == eLIM_SME_LINK_EST_WT_SCAN_STATE) &&
1698 pMac->lim.gLimRspReqd)) {
1699 /* LIM is not in background scan state OR */
1700 /* current scan is initiated by HDD. */
1701 /* No need to send new BSS indication to HDD */
1702 return;
1703 }
1704
1705 if (wlan_cfg_get_int(pMac, WNI_CFG_NEW_BSS_FOUND_IND, &val) !=
1706 eSIR_SUCCESS) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301707 pe_err("could not get NEIGHBOR_BSS_IND from CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001708 return;
1709 }
1710
1711 if (val == 0)
1712 return;
1713
1714 /**
1715 * Need to indicate new BSSs found during
1716 * background scanning to host.
1717 * Allocate buffer for sending indication.
1718 * Length of buffer is length of BSS description
1719 * and length of header itself
1720 */
1721 val = pBssDescr->bssDescription.length + sizeof(uint16_t) +
1722 sizeof(uint32_t) + sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301723 pNewBssInd = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001724 if (NULL == pNewBssInd) {
1725 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301726 pe_err("call to AllocateMemory failed for eWNI_SME_NEIGHBOR_BSS_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001727 return;
1728 }
1729
1730 pNewBssInd->messageType = eWNI_SME_NEIGHBOR_BSS_IND;
1731 pNewBssInd->length = (uint16_t) val;
1732 pNewBssInd->sessionId = 0;
1733
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301734 qdf_mem_copy((uint8_t *) pNewBssInd->bssDescription,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001735 (uint8_t *) &pBssDescr->bssDescription,
1736 pBssDescr->bssDescription.length + sizeof(uint16_t));
1737
1738 msgQ.type = eWNI_SME_NEIGHBOR_BSS_IND;
1739 msgQ.bodyptr = pNewBssInd;
1740 msgQ.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301741 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, msgQ.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001742 lim_sys_process_mmh_msg_api(pMac, &msgQ, ePROT);
1743} /*** end lim_send_sme_neighbor_bss_ind() ***/
1744
1745/** -----------------------------------------------------------------
1746 \brief lim_send_sme_addts_rsp() - sends SME ADDTS RSP
1747 \ This function sends a eWNI_SME_ADDTS_RSP to SME.
1748 \ SME only looks at rc and tspec field.
1749 \param pMac - global mac structure
1750 \param rspReqd - is SmeAddTsRsp required
1751 \param status - status code of SME_ADD_TS_RSP
1752 \return tspec
1753 \sa
1754 ----------------------------------------------------------------- */
1755void
1756lim_send_sme_addts_rsp(tpAniSirGlobal pMac, uint8_t rspReqd, uint32_t status,
1757 tpPESession psessionEntry, tSirMacTspecIE tspec,
1758 uint8_t smesessionId, uint16_t smetransactionId)
1759{
1760 tpSirAddtsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001761 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001762
1763 if (!rspReqd)
1764 return;
1765
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301766 rsp = qdf_mem_malloc(sizeof(tSirAddtsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001767 if (NULL == rsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301768 pe_err("AllocateMemory failed for ADDTS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001769 return;
1770 }
1771
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001772 rsp->messageType = eWNI_SME_ADDTS_RSP;
1773 rsp->rc = status;
1774 rsp->rsp.status = (enum eSirMacStatusCodes)status;
1775 rsp->rsp.tspec = tspec;
1776 /* Update SME session Id and transcation Id */
1777 rsp->sessionId = smesessionId;
1778 rsp->transactionId = smetransactionId;
1779
1780 mmhMsg.type = eWNI_SME_ADDTS_RSP;
1781 mmhMsg.bodyptr = rsp;
1782 mmhMsg.bodyval = 0;
1783 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301784 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1785 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001786 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301787 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1788 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001789 }
1790#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1791 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_RSP_EVENT, psessionEntry, 0,
1792 0);
1793#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1794
1795 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1796 return;
1797}
1798
1799void
1800lim_send_sme_delts_rsp(tpAniSirGlobal pMac, tpSirDeltsReq delts, uint32_t status,
1801 tpPESession psessionEntry, uint8_t smesessionId,
1802 uint16_t smetransactionId)
1803{
1804 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001805 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001806
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301807 pe_debug("SendSmeDeltsRsp aid: %d tsid: %d up: %d status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001808 delts->aid,
1809 delts->req.tsinfo.traffic.tsid,
1810 delts->req.tsinfo.traffic.userPrio, status);
1811 if (!delts->rspReqd)
1812 return;
1813
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301814 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001815 if (NULL == rsp) {
1816 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301817 pe_err("AllocateMemory failed for DELTS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001818 return;
1819 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001820
1821 if (psessionEntry != NULL) {
1822
1823 rsp->aid = delts->aid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301824 qdf_copy_macaddr(&rsp->macaddr, &delts->macaddr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301825 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) &delts->req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001826 sizeof(tSirDeltsReqInfo));
1827 }
1828
1829 rsp->messageType = eWNI_SME_DELTS_RSP;
1830 rsp->rc = status;
1831
1832 /* Update SME session Id and transcation Id */
1833 rsp->sessionId = smesessionId;
1834 rsp->transactionId = smetransactionId;
1835
1836 mmhMsg.type = eWNI_SME_DELTS_RSP;
1837 mmhMsg.bodyptr = rsp;
1838 mmhMsg.bodyval = 0;
1839 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301840 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1841 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001842 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301843 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1844 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001845 }
1846#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1847 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_RSP_EVENT, psessionEntry,
1848 (uint16_t) status, 0);
1849#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1850
1851 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1852}
1853
1854void
1855lim_send_sme_delts_ind(tpAniSirGlobal pMac, tpSirDeltsReqInfo delts, uint16_t aid,
1856 tpPESession psessionEntry)
1857{
1858 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001859 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001860
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301861 pe_debug("SendSmeDeltsInd aid: %d tsid: %d up: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001862 aid, delts->tsinfo.traffic.tsid, delts->tsinfo.traffic.userPrio);
1863
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301864 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001865 if (NULL == rsp) {
1866 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301867 pe_err("AllocateMemory failed for DELTS_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001868 return;
1869 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001870
1871 rsp->messageType = eWNI_SME_DELTS_IND;
1872 rsp->rc = eSIR_SUCCESS;
1873 rsp->aid = aid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301874 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) delts, sizeof(*delts));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001875
1876 /* Update SME session Id and SME transaction Id */
1877
1878 rsp->sessionId = psessionEntry->smeSessionId;
1879 rsp->transactionId = psessionEntry->transactionId;
1880
1881 mmhMsg.type = eWNI_SME_DELTS_IND;
1882 mmhMsg.bodyptr = rsp;
1883 mmhMsg.bodyval = 0;
1884 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1885#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1886 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_IND_EVENT, psessionEntry, 0,
1887 0);
1888#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1889
1890 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1891}
1892
1893/**
1894 * lim_send_sme_pe_statistics_rsp()
1895 *
1896 ***FUNCTION:
1897 * This function is called to send 802.11 statistics response to HDD.
1898 * This function posts the result back to HDD. This is a response to
1899 * HDD's request for statistics.
1900 *
1901 ***PARAMS:
1902 *
1903 ***LOGIC:
1904 *
1905 ***ASSUMPTIONS:
1906 * NA
1907 *
1908 ***NOTE:
1909 * NA
1910 *
1911 * @param pMac Pointer to Global MAC structure
1912 * @param p80211Stats Statistics sent in response
1913 * @param resultCode TODO:
1914 *
1915 *
1916 * @return none
1917 */
1918
1919void
1920lim_send_sme_pe_statistics_rsp(tpAniSirGlobal pMac, uint16_t msgType, void *stats)
1921{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001922 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001923 uint8_t sessionId;
1924 tAniGetPEStatsRsp *pPeStats = (tAniGetPEStatsRsp *) stats;
1925 tpPESession pPeSessionEntry;
1926
1927 /* Get the Session Id based on Sta Id */
1928 pPeSessionEntry =
1929 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1930
1931 /* Fill the Session Id */
1932 if (NULL != pPeSessionEntry) {
1933 /* Fill the Session Id */
1934 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1935 }
1936
1937 pPeStats->msgType = eWNI_SME_GET_STATISTICS_RSP;
1938
1939 /* msgType should be WMA_GET_STATISTICS_RSP */
1940 mmhMsg.type = eWNI_SME_GET_STATISTICS_RSP;
1941
1942 mmhMsg.bodyptr = stats;
1943 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301944 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001945 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1946
1947 return;
1948
1949} /*** end lim_send_sme_pe_statistics_rsp() ***/
1950
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001951#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001952/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001953 * lim_send_sme_pe_ese_tsm_rsp() - send tsm response
1954 * @pMac: Pointer to global pMac structure
1955 * @pStats: Pointer to TSM Stats
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001956 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001957 * This function is called to send tsm stats response to HDD.
1958 * This function posts the result back to HDD. This is a response to
1959 * HDD's request to get tsm stats.
1960 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001961 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001962 */
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001963void lim_send_sme_pe_ese_tsm_rsp(tpAniSirGlobal pMac,
1964 tAniGetTsmStatsRsp *pStats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001965{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001966 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001967 uint8_t sessionId;
1968 tAniGetTsmStatsRsp *pPeStats = (tAniGetTsmStatsRsp *) pStats;
1969 tpPESession pPeSessionEntry = NULL;
1970
1971 /* Get the Session Id based on Sta Id */
1972 pPeSessionEntry =
1973 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1974
1975 /* Fill the Session Id */
1976 if (NULL != pPeSessionEntry) {
1977 /* Fill the Session Id */
1978 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1979 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301980 pe_err("Session not found for the Sta id: %d",
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301981 pPeStats->staId);
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05301982 qdf_mem_free(pPeStats->tsmStatsReq);
1983 qdf_mem_free(pPeStats);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001984 return;
1985 }
1986
1987 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
1988 pPeStats->tsmMetrics.RoamingCount
1989 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
1990 pPeStats->tsmMetrics.RoamingDly
1991 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
1992
1993 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
1994 mmhMsg.bodyptr = pStats;
1995 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301996 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001997 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1998
1999 return;
2000} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
2001
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002002#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002003
2004void
2005lim_send_sme_ibss_peer_ind(tpAniSirGlobal pMac,
2006 tSirMacAddr peerMacAddr,
2007 uint16_t staIndex,
2008 uint8_t ucastIdx,
2009 uint8_t bcastIdx,
2010 uint8_t *beacon,
2011 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
2012{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002013 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002014 tSmeIbssPeerInd *pNewPeerInd;
2015
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302016 pNewPeerInd = qdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002017 if (NULL == pNewPeerInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302018 pe_err("Failed to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002019 return;
2020 }
2021
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302022 qdf_mem_copy((uint8_t *) pNewPeerInd->peer_addr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302023 peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002024 pNewPeerInd->staId = staIndex;
2025 pNewPeerInd->ucastSig = ucastIdx;
2026 pNewPeerInd->bcastSig = bcastIdx;
2027 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
2028 pNewPeerInd->mesgType = msgType;
2029 pNewPeerInd->sessionId = sessionId;
2030
2031 if (beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302032 qdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002033 sizeof(tSmeIbssPeerInd)), (void *)beacon,
2034 beaconLen);
2035 }
2036
2037 mmhMsg.type = msgType;
2038 mmhMsg.bodyptr = pNewPeerInd;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302039 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002040 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2041
2042}
2043
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07002044/**
2045 * lim_process_csa_wbw_ie() - Process CSA Wide BW IE
2046 * @mac_ctx: pointer to global adapter context
2047 * @csa_params: pointer to CSA parameters
2048 * @chnl_switch_info:pointer to channel switch parameters
2049 * @session_entry: session pointer
2050 *
2051 * Return: None
2052 */
2053static void lim_process_csa_wbw_ie(tpAniSirGlobal mac_ctx,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002054 struct csa_offload_params *csa_params,
2055 tLimWiderBWChannelSwitchInfo *chnl_switch_info,
2056 tpPESession session_entry)
2057{
Amar Singhal5cccafe2017-02-15 12:42:58 -08002058 struct ch_params ch_params = {0};
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002059 uint8_t ap_new_ch_width;
2060 bool new_ch_width_dfn = false;
2061 uint8_t center_freq_diff;
2062
2063 ap_new_ch_width = csa_params->new_ch_width + 1;
2064 if ((ap_new_ch_width == CH_WIDTH_80MHZ) &&
2065 csa_params->new_ch_freq_seg2) {
2066 new_ch_width_dfn = true;
2067 if (csa_params->new_ch_freq_seg2 >
2068 csa_params->new_ch_freq_seg1)
2069 center_freq_diff = csa_params->new_ch_freq_seg2 -
2070 csa_params->new_ch_freq_seg1;
2071 else
2072 center_freq_diff = csa_params->new_ch_freq_seg1 -
2073 csa_params->new_ch_freq_seg2;
2074 if (center_freq_diff == CENTER_FREQ_DIFF_160MHz)
2075 ap_new_ch_width = CH_WIDTH_160MHZ;
2076 else if (center_freq_diff > CENTER_FREQ_DIFF_80P80MHz)
2077 ap_new_ch_width = CH_WIDTH_80P80MHZ;
2078 else
2079 ap_new_ch_width = CH_WIDTH_80MHZ;
2080 }
2081 session_entry->gLimChannelSwitch.state =
2082 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2083 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
2084 !new_ch_width_dfn) {
2085 ch_params.ch_width = CH_WIDTH_160MHZ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002086 wlan_reg_set_channel_params(mac_ctx->pdev,
2087 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002088 ap_new_ch_width = ch_params.ch_width;
2089 csa_params->new_ch_freq_seg1 = ch_params.center_freq_seg0;
2090 csa_params->new_ch_freq_seg2 = ch_params.center_freq_seg1;
2091 }
2092 chnl_switch_info->newChanWidth = ap_new_ch_width;
2093 chnl_switch_info->newCenterChanFreq0 = csa_params->new_ch_freq_seg1;
2094 chnl_switch_info->newCenterChanFreq1 = csa_params->new_ch_freq_seg2;
2095
2096 if (session_entry->ch_width == ap_new_ch_width)
2097 goto prnt_log;
2098
2099 if (session_entry->ch_width == CH_WIDTH_80MHZ) {
2100 chnl_switch_info->newChanWidth = CH_WIDTH_80MHZ;
2101 chnl_switch_info->newCenterChanFreq1 = 0;
2102 } else {
2103 session_entry->ch_width = ap_new_ch_width;
2104 chnl_switch_info->newChanWidth = ap_new_ch_width;
2105 }
2106prnt_log:
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302107 pe_debug("new channel: %d new_ch_width: %d seg0: %d seg1: %d",
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002108 csa_params->channel,
2109 chnl_switch_info->newChanWidth,
2110 chnl_switch_info->newCenterChanFreq0,
2111 chnl_switch_info->newCenterChanFreq1);
2112}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002113/**
2114 * lim_handle_csa_offload_msg() - Handle CSA offload message
2115 * @mac_ctx: pointer to global adapter context
2116 * @msg: Message pointer.
2117 *
2118 * Return: None
2119 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08002120void lim_handle_csa_offload_msg(tpAniSirGlobal mac_ctx,
2121 struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002122{
2123 tpPESession session_entry;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002124 struct scheduler_msg mmh_msg = {0};
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302125 struct csa_offload_params *csa_params =
2126 (struct csa_offload_params *) (msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002127 tpSmeCsaOffloadInd csa_offload_ind;
2128 tpDphHashNode sta_ds = NULL;
2129 uint8_t session_id;
2130 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302131 uint16_t chan_space = 0;
Amar Singhal5cccafe2017-02-15 12:42:58 -08002132 struct ch_params ch_params;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302133
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002134 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002135 tLimChannelSwitchInfo *lim_ch_switch = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002136
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302137 pe_debug("handle csa offload msg");
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302138
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002139 if (!csa_params) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302140 pe_err("limMsgQ body ptr is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002141 return;
2142 }
2143
2144 session_entry =
2145 pe_find_session_by_bssid(mac_ctx,
2146 csa_params->bssId, &session_id);
2147 if (!session_entry) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302148 pe_err("Session does not exists for %pM",
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302149 csa_params->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002150 goto err;
2151 }
2152
2153 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
2154 &session_entry->dph.dphHashTable);
2155
2156 if (!sta_ds) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302157 pe_err("sta_ds does not exist");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002158 goto err;
2159 }
2160
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002161 if (!LIM_IS_STA_ROLE(session_entry)) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302162 pe_debug("Invalid role to handle CSA");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002163 goto err;
2164 }
Masti, Narayanraddi1c630442015-11-02 12:03:50 +05302165
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002166 /*
2167 * on receiving channel switch announcement from AP, delete all
2168 * TDLS peers before leaving BSS and proceed for channel switch
2169 */
2170 lim_delete_tdls_peers(mac_ctx, session_entry);
Gupta, Kapil121bf212015-11-25 19:21:29 +05302171
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002172 lim_ch_switch = &session_entry->gLimChannelSwitch;
2173 session_entry->gLimChannelSwitch.switchMode =
2174 csa_params->switch_mode;
2175 /* timer already started by firmware, switch immediately */
2176 session_entry->gLimChannelSwitch.switchCount = 0;
2177 session_entry->gLimChannelSwitch.primaryChannel =
2178 csa_params->channel;
2179 session_entry->gLimChannelSwitch.state =
2180 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2181 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
2182 lim_ch_switch->sec_ch_offset =
2183 session_entry->htSecondaryChannelOffset;
2184 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
2185 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
2186 chnl_switch_info =
2187 &session_entry->gLimWiderBWChannelSwitch;
2188
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302189 pe_debug("vht: %d ht: %d flag: %x chan: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302190 session_entry->vhtCapability,
2191 session_entry->htSupportedChannelWidthSet,
2192 csa_params->ies_present_flag,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002193 csa_params->channel);
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302194 pe_debug("seg1: %d seg2: %d width: %d country: %s class: %d",
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002195 csa_params->new_ch_freq_seg1,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302196 csa_params->new_ch_freq_seg2,
2197 csa_params->new_ch_width,
2198 mac_ctx->scan.countryCodeCurrent,
2199 csa_params->new_op_class);
2200
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002201 if (session_entry->vhtCapability &&
2202 session_entry->htSupportedChannelWidthSet) {
2203 if (csa_params->ies_present_flag & lim_wbw_ie_present) {
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07002204 lim_process_csa_wbw_ie(mac_ctx, csa_params,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002205 chnl_switch_info, session_entry);
2206 lim_ch_switch->sec_ch_offset =
Abhishek Singhaf639b42017-06-16 14:14:36 +05302207 PHY_SINGLE_CHANNEL_CENTERED;
2208 if (chnl_switch_info->newChanWidth) {
2209 if (csa_params->channel <
2210 csa_params->new_ch_freq_seg1)
2211 lim_ch_switch->sec_ch_offset =
2212 PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
2213 else
2214 lim_ch_switch->sec_ch_offset =
2215 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
2216 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002217 } else if (csa_params->ies_present_flag
2218 & lim_xcsa_ie_present) {
2219 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002220 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002221 mac_ctx->scan.countryCodeCurrent,
2222 csa_params->channel,
2223 csa_params->new_op_class);
2224 session_entry->gLimChannelSwitch.state =
2225 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2226
2227 if (chan_space == 80) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002228 chnl_switch_info->newChanWidth =
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002229 CH_WIDTH_80MHZ;
2230 } else if (chan_space == 40) {
2231 chnl_switch_info->newChanWidth =
2232 CH_WIDTH_40MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002233 } else {
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002234 chnl_switch_info->newChanWidth =
2235 CH_WIDTH_20MHZ;
2236 lim_ch_switch->state =
2237 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2238 }
2239
2240 ch_params.ch_width =
2241 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002242 wlan_reg_set_channel_params(mac_ctx->pdev,
2243 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002244 chnl_switch_info->newCenterChanFreq0 =
2245 ch_params.center_freq_seg0;
2246 /*
2247 * This is not applicable for 20/40/80 MHz.
2248 * Only used when we support 80+80 MHz operation.
2249 * In case of 80+80 MHz, this parameter indicates
2250 * center channel frequency index of 80 MHz
2251 * channel offrequency segment 1.
2252 */
2253 chnl_switch_info->newCenterChanFreq1 =
2254 ch_params.center_freq_seg1;
2255 lim_ch_switch->sec_ch_offset =
2256 ch_params.sec_ch_offset;
2257
2258 }
2259 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
2260 chnl_switch_info->newCenterChanFreq0;
2261 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
2262 chnl_switch_info->newCenterChanFreq1;
2263 session_entry->gLimChannelSwitch.ch_width =
2264 chnl_switch_info->newChanWidth;
2265
2266 } else if (session_entry->htSupportedChannelWidthSet) {
2267 if (csa_params->ies_present_flag
2268 & lim_xcsa_ie_present) {
2269 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002270 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002271 mac_ctx->scan.countryCodeCurrent,
2272 csa_params->channel,
2273 csa_params->new_op_class);
2274 lim_ch_switch->state =
2275 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2276 if (chan_space == 40) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002277 lim_ch_switch->ch_width =
2278 CH_WIDTH_40MHZ;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002279 chnl_switch_info->newChanWidth =
2280 CH_WIDTH_40MHZ;
2281 ch_params.ch_width =
2282 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002283 wlan_reg_set_channel_params(mac_ctx->pdev,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002284 csa_params->channel,
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07002285 0, &ch_params);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002286 lim_ch_switch->ch_center_freq_seg0 =
2287 ch_params.center_freq_seg0;
2288 lim_ch_switch->sec_ch_offset =
2289 ch_params.sec_ch_offset;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002290 } else {
2291 lim_ch_switch->ch_width =
2292 CH_WIDTH_20MHZ;
2293 chnl_switch_info->newChanWidth =
2294 CH_WIDTH_40MHZ;
2295 lim_ch_switch->state =
2296 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2297 lim_ch_switch->sec_ch_offset =
2298 PHY_SINGLE_CHANNEL_CENTERED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002299 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002300 } else {
2301 lim_ch_switch->ch_width =
2302 CH_WIDTH_40MHZ;
2303 lim_ch_switch->state =
2304 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2305 ch_params.ch_width = CH_WIDTH_40MHZ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002306 wlan_reg_set_channel_params(mac_ctx->pdev,
2307 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002308 lim_ch_switch->ch_center_freq_seg0 =
2309 ch_params.center_freq_seg0;
2310 lim_ch_switch->sec_ch_offset =
2311 ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002312 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002313
2314 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302315 pe_debug("new ch width: %d space: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302316 session_entry->gLimChannelSwitch.ch_width, chan_space);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002317
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002318 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
2319 csa_offload_ind = qdf_mem_malloc(sizeof(tSmeCsaOffloadInd));
2320 if (NULL == csa_offload_ind) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302321 pe_err("memalloc fail eWNI_SME_CSA_OFFLOAD_EVENT");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002322 goto err;
2323 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002324
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002325 csa_offload_ind->mesgType = eWNI_SME_CSA_OFFLOAD_EVENT;
2326 csa_offload_ind->mesgLen = sizeof(tSmeCsaOffloadInd);
2327 qdf_mem_copy(csa_offload_ind->bssid.bytes, session_entry->bssId,
2328 QDF_MAC_ADDR_SIZE);
2329 mmh_msg.type = eWNI_SME_CSA_OFFLOAD_EVENT;
2330 mmh_msg.bodyptr = csa_offload_ind;
2331 mmh_msg.bodyval = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302332 pe_debug("Sending eWNI_SME_CSA_OFFLOAD_EVENT to SME");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002333 MTRACE(mac_trace_msg_tx
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002334 (mac_ctx, session_entry->peSessionId, mmh_msg.type));
2335#ifdef FEATURE_WLAN_DIAG_SUPPORT
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002336 lim_diag_event_report(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002337 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
2338 eSIR_SUCCESS, eSIR_SUCCESS);
2339#endif
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002340 lim_sys_process_mmh_msg_api(mac_ctx, &mmh_msg, ePROT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002341
2342err:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302343 qdf_mem_free(csa_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002344}
2345
2346/*--------------------------------------------------------------------------
2347 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
2348
2349 \param pMac - pointer to global adapter context
2350 \param sessionId - Message pointer.
2351
2352 \sa
2353 --------------------------------------------------------------------------*/
2354
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002355void lim_handle_delete_bss_rsp(tpAniSirGlobal pMac, struct scheduler_msg *MsgQ)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002356{
2357 tpPESession psessionEntry;
2358 tpDeleteBssParams pDelBss = (tpDeleteBssParams) (MsgQ->bodyptr);
2359
2360 psessionEntry =
2361 pe_find_session_by_session_id(pMac, pDelBss->sessionId);
2362 if (psessionEntry == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302363 pe_err("Session Does not exist for given sessionID: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002364 pDelBss->sessionId);
Naveen Rawat0c81edc2016-06-08 10:08:30 -07002365 qdf_mem_free(MsgQ->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002366 return;
2367 }
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002368 /*
2369 * During DEL BSS handling, the PE Session will be deleted, but it is
2370 * better to clear this flag if the session is hanging around due
2371 * to some error conditions so that the next DEL_BSS request does
2372 * not take the HO_FAIL path
2373 */
2374 psessionEntry->process_ho_fail = false;
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002375 if (LIM_IS_IBSS_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002376 lim_ibss_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002377 else if (LIM_IS_UNKNOWN_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002378 lim_process_sme_del_bss_rsp(pMac, MsgQ->bodyval, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002379 else if (LIM_IS_NDI_ROLE(psessionEntry))
2380 lim_ndi_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002381 else
2382 lim_process_mlm_del_bss_rsp(pMac, MsgQ, psessionEntry);
2383
2384}
2385
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002386/** -----------------------------------------------------------------
2387 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
2388 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
2389 \ SME only looks at rc and tspec field.
2390 \param pMac - global mac structure
2391 \param rspReqd - is SmeAddTsRsp required
2392 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
2393 \return tspec
2394 \sa
2395 ----------------------------------------------------------------- */
2396void
2397lim_send_sme_aggr_qos_rsp(tpAniSirGlobal pMac, tpSirAggrQosRsp aggrQosRsp,
2398 uint8_t smesessionId)
2399{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002400 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002401
2402 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
2403 mmhMsg.bodyptr = aggrQosRsp;
2404 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302405 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2406 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002407 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2408
2409 return;
2410}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002411
2412void lim_send_sme_max_assoc_exceeded_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
2413 uint8_t smesessionId)
2414{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002415 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002416 tSmeMaxAssocInd *pSmeMaxAssocInd;
2417
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302418 pSmeMaxAssocInd = qdf_mem_malloc(sizeof(tSmeMaxAssocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002419 if (NULL == pSmeMaxAssocInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302420 pe_err("Failed to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002421 return;
2422 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302423 qdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peer_mac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302424 (uint8_t *) peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002425 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
2426 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
2427 pSmeMaxAssocInd->sessionId = smesessionId;
2428 mmhMsg.type = pSmeMaxAssocInd->mesgType;
2429 mmhMsg.bodyptr = pSmeMaxAssocInd;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302430 pe_debug("msgType: %s peerMacAddr "MAC_ADDRESS_STR "sme session id %d",
2431 "eWNI_SME_MAX_ASSOC_EXCEEDED", MAC_ADDR_ARRAY(peerMacAddr),
2432 pSmeMaxAssocInd->sessionId);
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302433 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2434 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002435 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2436
2437 return;
2438}
2439
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002440/*--------------------------------------------------------------------------
2441 \brief lim_send_dfs_chan_sw_ie_update()
2442 This timer handler updates the channel switch IE in beacon template
2443
2444 \param pMac - pointer to global adapter context
2445 \return - channel to scan from valid session else zero.
2446 \sa
2447 --------------------------------------------------------------------------*/
2448static void
2449lim_send_dfs_chan_sw_ie_update(tpAniSirGlobal pMac, tpPESession psessionEntry)
2450{
2451
2452 /* Update the beacon template and send to FW */
2453 if (sch_set_fixed_beacon_fields(pMac, psessionEntry) != eSIR_SUCCESS) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302454 pe_err("Unable to set CSA IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002455 return;
2456 }
2457
2458 /* Send update beacon template message */
2459 lim_send_beacon_ind(pMac, psessionEntry);
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302460 pe_debug("Updated CSA IE, IE COUNT: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002461 psessionEntry->gLimChannelSwitch.switchCount);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002462
2463 return;
2464}
2465
2466/** -----------------------------------------------------------------
2467 \brief lim_send_sme_ap_channel_switch_resp() - sends
2468 eWNI_SME_CHANNEL_CHANGE_RSP
2469 After receiving WMA_SWITCH_CHANNEL_RSP indication this
2470 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
2471 that the Channel change has been done to the specified target
2472 channel in the Channel change request
2473 \param pMac - global mac structure
2474 \param psessionEntry - session info
2475 \param pChnlParams - Channel switch params
2476 --------------------------------------------------------------------*/
2477void
2478lim_send_sme_ap_channel_switch_resp(tpAniSirGlobal pMac,
2479 tpPESession psessionEntry,
2480 tpSwitchChannelParams pChnlParams)
2481{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002482 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002483 tpSwitchChannelParams pSmeSwithChnlParams;
2484 uint8_t channelId;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002485 bool is_ch_dfs = false;
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08002486 enum phy_ch_width ch_width;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002487 uint8_t ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002488
2489 pSmeSwithChnlParams = (tSwitchChannelParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302490 qdf_mem_malloc(sizeof(tSwitchChannelParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002491 if (NULL == pSmeSwithChnlParams) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302492 pe_err("AllocateMemory failed for pSmeSwithChnlParams");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002493 return;
2494 }
2495
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302496 qdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002497 sizeof(tSwitchChannelParams));
2498
2499 channelId = pSmeSwithChnlParams->channelNumber;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002500 ch_width = pSmeSwithChnlParams->ch_width;
2501 ch_center_freq_seg1 = pSmeSwithChnlParams->ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002502
2503 /*
2504 * Pass the sme sessionID to SME instead
2505 * PE session ID.
2506 */
2507 pSmeSwithChnlParams->peSessionId = psessionEntry->smeSessionId;
2508
2509 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
2510 mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
2511 mmhMsg.bodyval = 0;
2512 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2513
2514 /*
2515 * We should start beacon transmission only if the new
2516 * channel after channel change is Non-DFS. For a DFS
2517 * channel, PE will receive an explicit request from
2518 * upper layers to start the beacon transmission .
2519 */
2520
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002521 if (ch_width == CH_WIDTH_160MHZ) {
2522 is_ch_dfs = true;
2523 } else if (ch_width == CH_WIDTH_80P80MHZ) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002524 if (wlan_reg_get_channel_state(pMac->pdev, channelId) ==
2525 CHANNEL_STATE_DFS ||
2526 wlan_reg_get_channel_state(pMac->pdev,
2527 ch_center_freq_seg1 -
2528 SIR_80MHZ_START_CENTER_CH_DIFF) ==
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002529 CHANNEL_STATE_DFS)
2530 is_ch_dfs = true;
2531 } else {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002532 if (wlan_reg_get_channel_state(pMac->pdev, channelId) ==
2533 CHANNEL_STATE_DFS)
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002534 is_ch_dfs = true;
2535 }
2536
2537 if (!is_ch_dfs) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002538 if (channelId == psessionEntry->currentOperChannel) {
2539 lim_apply_configuration(pMac, psessionEntry);
2540 lim_send_beacon_ind(pMac, psessionEntry);
2541 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302542 pe_debug("Failed to Transmit Beacons on channel: %d after AP channel change response",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002543 psessionEntry->bcnLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002544 }
2545 }
2546 return;
2547}
2548
Peng Xu6363ec62017-05-15 11:06:33 -07002549#ifdef WLAN_FEATURE_11AX_BSS_COLOR
2550/**
2551 * lim_send_bss_color_change_ie_update() - update bss color change IE in
2552 * beacon template
2553 *
2554 * @mac_ctx: pointer to global adapter context
2555 * @session: session pointer
2556 *
2557 * Return: none
2558 */
2559static void
2560lim_send_bss_color_change_ie_update(tpAniSirGlobal mac_ctx,
2561 tpPESession session)
2562{
2563 /* Update the beacon template and send to FW */
2564 if (sch_set_fixed_beacon_fields(mac_ctx, session) != eSIR_SUCCESS) {
2565 pe_err("Unable to set BSS color change IE in beacon");
2566 return;
2567 }
2568
2569 /* Send update beacon template message */
2570 lim_send_beacon_ind(mac_ctx, session);
2571 pe_info("Updated BSS color change countdown = %d",
2572 session->he_bss_color_change.countdown);
2573}
2574
2575static void
2576lim_handle_bss_color_change_ie(tpAniSirGlobal mac_ctx,
2577 tpPESession session)
2578{
2579 /* handle bss color change IE */
2580 if (LIM_IS_AP_ROLE(session) &&
2581 session->he_op.bss_col_disabled) {
2582 if (session->he_bss_color_change.countdown > 0) {
2583 session->he_bss_color_change.countdown--;
2584 } else {
2585 session->bss_color_changing = 0;
2586 if (session->he_bss_color_change.new_color != 0)
2587 session->he_op.bss_col_disabled = 0;
2588 }
2589
2590 lim_send_bss_color_change_ie_update(mac_ctx, session);
2591 }
2592}
2593
2594#else
2595static void
2596lim_handle_bss_color_change_ie(tpAniSirGlobal mac_ctx,
2597 tpPESession session)
2598{
2599}
2600#endif
2601
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002602/** -----------------------------------------------------------------
2603 \brief lim_process_beacon_tx_success_ind() - This function is used
2604 explicitely to handle successful beacon transmission indication
2605 from the FW. This is a generic event generated by the FW afer the
2606 first beacon is sent out after the beacon template update by the
2607 host
2608 \param pMac - global mac structure
2609 \param psessionEntry - session info
2610 \return none
2611 \sa
2612 ----------------------------------------------------------------- */
2613void
2614lim_process_beacon_tx_success_ind(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2615{
2616 /* Currently, this event is used only for DFS channel switch announcement
2617 * IE update in the template. If required to be used for other IE updates
2618 * add appropriate code by introducing a state variable
2619 */
2620 tpPESession psessionEntry;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002621 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002622 tSirSmeCSAIeTxCompleteRsp *pChanSwTxResponse;
2623 struct sir_beacon_tx_complete_rsp *beacon_tx_comp_rsp_ptr;
2624 uint8_t length = sizeof(tSirSmeCSAIeTxCompleteRsp);
2625 tpSirFirstBeaconTxCompleteInd pBcnTxInd =
2626 (tSirFirstBeaconTxCompleteInd *) event;
2627
2628 psessionEntry = pe_find_session_by_bss_idx(pMac, pBcnTxInd->bssIdx);
2629 if (psessionEntry == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302630 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002631 return;
2632 }
2633
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302634 pe_debug("role: %d swIe: %d opIe: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302635 GET_LIM_SYSTEM_ROLE(psessionEntry),
2636 psessionEntry->dfsIncludeChanSwIe,
2637 psessionEntry->gLimOperatingMode.present);
2638
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002639 if (LIM_IS_AP_ROLE(psessionEntry) &&
2640 true == psessionEntry->dfsIncludeChanSwIe) {
2641 /* Send only 5 beacons with CSA IE Set in when a radar is detected */
2642 if (psessionEntry->gLimChannelSwitch.switchCount > 0) {
2643 /*
2644 * Send the next beacon with updated CSA IE count
2645 */
2646 lim_send_dfs_chan_sw_ie_update(pMac, psessionEntry);
2647 /* Decrement the IE count */
2648 psessionEntry->gLimChannelSwitch.switchCount--;
2649 } else {
2650 /* Done with CSA IE update, send response back to SME */
2651 psessionEntry->gLimChannelSwitch.switchCount = 0;
2652 if (pMac->sap.SapDfsInfo.disable_dfs_ch_switch == false)
2653 psessionEntry->gLimChannelSwitch.switchMode = 0;
2654 psessionEntry->dfsIncludeChanSwIe = false;
2655 psessionEntry->dfsIncludeChanWrapperIe = false;
2656
2657 pChanSwTxResponse = (tSirSmeCSAIeTxCompleteRsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302658 qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002659
2660 if (NULL == pChanSwTxResponse) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302661 pe_err("AllocateMemory failed for tSirSmeCSAIeTxCompleteRsp");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002662 return;
2663 }
2664
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002665 pChanSwTxResponse->sessionId =
2666 psessionEntry->smeSessionId;
2667 pChanSwTxResponse->chanSwIeTxStatus =
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302668 QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002669
2670 mmhMsg.type = eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND;
2671 mmhMsg.bodyptr = pChanSwTxResponse;
2672 mmhMsg.bodyval = 0;
2673 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2674 }
2675 }
2676
2677 if (LIM_IS_AP_ROLE(psessionEntry) &&
2678 psessionEntry->gLimOperatingMode.present) {
2679 /* Done with nss update, send response back to SME */
2680 psessionEntry->gLimOperatingMode.present = 0;
2681 beacon_tx_comp_rsp_ptr = (struct sir_beacon_tx_complete_rsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302682 qdf_mem_malloc(sizeof(*beacon_tx_comp_rsp_ptr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002683 if (NULL == beacon_tx_comp_rsp_ptr) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302684 pe_err("AllocateMemory failed for beacon_tx_comp_rsp_ptr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002685 return;
2686 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002687 beacon_tx_comp_rsp_ptr->session_id =
2688 psessionEntry->smeSessionId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302689 beacon_tx_comp_rsp_ptr->tx_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002690 mmhMsg.type = eWNI_SME_NSS_UPDATE_RSP;
2691 mmhMsg.bodyptr = beacon_tx_comp_rsp_ptr;
2692 mmhMsg.bodyval = 0;
2693 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2694 }
Peng Xu6363ec62017-05-15 11:06:33 -07002695
2696 lim_handle_bss_color_change_ie(pMac, psessionEntry);
2697
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002698 return;
2699}