blob: 5426882858e6982d17edcf7d4009dd0f7a87bfcd [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"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080062
Kabilan Kannanf56f9d52017-04-05 03:31:34 -070063#include "wlan_tdls_tgt_api.h"
64
65
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080066static void lim_handle_join_rsp_status(tpAniSirGlobal mac_ctx,
67 tpPESession session_entry, tSirResultCodes result_code,
68 tpSirSmeJoinRsp sme_join_rsp);
69
70/**
71 * lim_send_sme_rsp() - Send Response to upper layers
72 * @mac_ctx: Pointer to Global MAC structure
73 * @msg_type: Indicates message type
74 * @result_code: Indicates the result of previously issued
75 * eWNI_SME_msg_type_REQ message
76 *
77 * This function is called by lim_process_sme_req_messages() to send
78 * eWNI_SME_START_RSP, eWNI_SME_STOP_BSS_RSP
79 * or eWNI_SME_SWITCH_CHL_RSP messages to applications above MAC
80 * Software.
81 *
82 * Return: None
83 */
84
85void
86lim_send_sme_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
87 tSirResultCodes result_code, uint8_t sme_session_id,
88 uint16_t sme_transaction_id)
89{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070090 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080091 tSirSmeRsp *sme_rsp;
92
93 lim_log(mac_ctx, LOG1, FL("Sending message %s with reasonCode %s"),
94 lim_msg_str(msg_type), lim_result_code_str(result_code));
95
Anurag Chouhan600c3a02016-03-01 10:33:54 +053096 sme_rsp = qdf_mem_malloc(sizeof(tSirSmeRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080097 if (NULL == sme_rsp) {
98 /* Buffer not available. Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +053099 QDF_TRACE(QDF_MODULE_ID_PE, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800100 FL("call to AllocateMemory failed for eWNI_SME_*_RSP"));
101 return;
102 }
103
104 sme_rsp->messageType = msg_type;
105 sme_rsp->length = sizeof(tSirSmeRsp);
106 sme_rsp->statusCode = result_code;
107
108 sme_rsp->sessionId = sme_session_id;
109 sme_rsp->transactionId = sme_transaction_id;
110
111 msg.type = msg_type;
112 msg.bodyptr = sme_rsp;
113 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530114 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG,
115 sme_session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800116
117#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
118 switch (msg_type) {
119 case eWNI_SME_STOP_BSS_RSP:
120 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_STOP_BSS_RSP_EVENT,
121 NULL, (uint16_t) result_code, 0);
122 break;
123 }
124#endif /* FEATURE_WLAN_DIAG_SUPPORT */
125 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
126}
127
128
129
130/**
131 * lim_send_sme_roc_rsp() - Send Response to SME
132 * @mac_ctx: Pointer to Global MAC structure
133 * @status: Resume link status
134 * @result_code: Result of the ROC request
135 * @sme_session_id: SME sesson Id
136 * @scan_id: Scan Identifier
137 *
138 * This function is called to send ROC rsp
139 * message to SME.
140 *
141 * Return: None
142 */
143void
144lim_send_sme_roc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
145 tSirResultCodes result_code, uint8_t sme_session_id,
146 uint32_t scan_id)
147{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700148 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800149 struct sir_roc_rsp *sme_rsp;
150
151 lim_log(mac_ctx, LOG1,
152 FL("Sending message %s with reasonCode %s scanId %d"),
153 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 Aggarwald5941bb2017-03-11 14:41:24 +0530158 QDF_TRACE(QDF_MODULE_ID_PE, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800159 FL("call to AllocateMemory failed for eWNI_SME_*_RSP"));
160 return;
161 }
162
163 sme_rsp->message_type = msg_type;
164 sme_rsp->length = sizeof(struct sir_roc_rsp);
165 sme_rsp->status = result_code;
166
167 sme_rsp->session_id = sme_session_id;
168 sme_rsp->scan_id = scan_id;
169
170 msg.type = msg_type;
171 msg.bodyptr = sme_rsp;
172 msg.bodyval = 0;
173 MTRACE(mac_trace_msg_tx(mac_ctx, sme_session_id, msg.type));
174 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
175}
176
177
178/**
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530179 * lim_get_max_rate_flags() - Get rate flags
180 * @mac_ctx: Pointer to global MAC structure
181 * @sta_ds: Pointer to station ds structure
182 *
183 * This function is called to get the rate flags for a connection
184 * from the station ds structure depending on the ht and the vht
185 * channel width supported.
186 *
187 * Return: Returns the populated rate_flags
188 */
189uint32_t lim_get_max_rate_flags(tpAniSirGlobal mac_ctx, tpDphHashNode sta_ds)
190{
191 uint32_t rate_flags = 0;
192
193 if (sta_ds == NULL) {
194 lim_log(mac_ctx, LOGE, FL("sta_ds is NULL"));
195 return rate_flags;
196 }
197
198 if (!sta_ds->mlmStaContext.htCapability &&
199 !sta_ds->mlmStaContext.vhtCapability) {
200 rate_flags |= eHAL_TX_RATE_LEGACY;
201 } else {
202 if (sta_ds->mlmStaContext.vhtCapability) {
203 if (WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ ==
204 sta_ds->vhtSupportedChannelWidthSet) {
205 rate_flags |= eHAL_TX_RATE_VHT80;
206 } else if (WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ ==
207 sta_ds->vhtSupportedChannelWidthSet) {
208 if (sta_ds->htSupportedChannelWidthSet)
209 rate_flags |= eHAL_TX_RATE_VHT40;
210 else
211 rate_flags |= eHAL_TX_RATE_VHT20;
212 }
213 } else if (sta_ds->mlmStaContext.htCapability) {
214 if (sta_ds->htSupportedChannelWidthSet)
215 rate_flags |= eHAL_TX_RATE_HT40;
216 else
217 rate_flags |= eHAL_TX_RATE_HT20;
218 }
219 }
220
221 if (sta_ds->htShortGI20Mhz || sta_ds->htShortGI40Mhz)
222 rate_flags |= eHAL_TX_RATE_SGI;
223
224 return rate_flags;
225}
226
227/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800228 * lim_send_sme_join_reassoc_rsp_after_resume() - Send Response to SME
229 * @mac_ctx Pointer to Global MAC structure
230 * @status Resume link status
231 * @ctx context passed while calling resmune link.
232 * (join response to be sent)
233 *
234 * This function is called to send Join/Reassoc rsp
235 * message to SME after the resume link.
236 *
237 * Return: None
238 */
239static void lim_send_sme_join_reassoc_rsp_after_resume(tpAniSirGlobal mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530240 QDF_STATUS status, uint32_t *ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800241{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700242 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800243 tpSirSmeJoinRsp sme_join_rsp = (tpSirSmeJoinRsp) ctx;
244
245 msg.type = sme_join_rsp->messageType;
246 msg.bodyptr = sme_join_rsp;
247 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530248 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, NO_SESSION, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800249 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
250}
251
252/**
253 * lim_handle_join_rsp_status() - Handle the response.
254 * @mac_ctx: Pointer to Global MAC structure
255 * @session_entry: PE Session Info
256 * @result_code: Indicates the result of previously issued
257 * eWNI_SME_msgType_REQ message
258 * @sme_join_rsp The received response.
259 *
260 * This function will handle both the success and failure status
261 * of the received response.
262 *
263 * Return: None
264 */
265static void lim_handle_join_rsp_status(tpAniSirGlobal mac_ctx,
266 tpPESession session_entry, tSirResultCodes result_code,
267 tpSirSmeJoinRsp sme_join_rsp)
268{
269#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
270 tSirSmeHTProfile *ht_profile;
271#endif
272 if (result_code == eSIR_SME_SUCCESS) {
273 if (session_entry->beacon != NULL) {
274 sme_join_rsp->beaconLength = session_entry->bcnLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530275 qdf_mem_copy(sme_join_rsp->frames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800276 session_entry->beacon,
277 sme_join_rsp->beaconLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530278 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800279 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530280 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800281 lim_log(mac_ctx, LOG1, FL("Beacon=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530282 sme_join_rsp->beaconLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800283 }
284 if (session_entry->assocReq != NULL) {
285 sme_join_rsp->assocReqLength =
286 session_entry->assocReqLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530287 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530288 sme_join_rsp->beaconLength,
289 session_entry->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800290 sme_join_rsp->assocReqLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530291 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800292 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530293 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800294 lim_log(mac_ctx,
295 LOG1, FL("AssocReq=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530296 sme_join_rsp->assocReqLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800297 }
298 if (session_entry->assocRsp != NULL) {
299 sme_join_rsp->assocRspLength =
300 session_entry->assocRspLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530301 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530302 sme_join_rsp->beaconLength +
303 sme_join_rsp->assocReqLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800304 session_entry->assocRsp,
305 sme_join_rsp->assocRspLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530306 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800307 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530308 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800309 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800310 if (session_entry->ricData != NULL) {
311 sme_join_rsp->parsedRicRspLen =
312 session_entry->RICDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530313 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530314 sme_join_rsp->beaconLength +
315 sme_join_rsp->assocReqLength +
316 sme_join_rsp->assocRspLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800317 session_entry->ricData,
318 sme_join_rsp->parsedRicRspLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530319 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800320 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530321 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800322 lim_log(mac_ctx, LOG1, FL("RicLength=%d"),
323 sme_join_rsp->parsedRicRspLen);
324 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800325#ifdef FEATURE_WLAN_ESE
326 if (session_entry->tspecIes != NULL) {
327 sme_join_rsp->tspecIeLen =
328 session_entry->tspecLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530329 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530330 sme_join_rsp->beaconLength +
331 sme_join_rsp->assocReqLength +
332 sme_join_rsp->assocRspLength +
333 sme_join_rsp->parsedRicRspLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800334 session_entry->tspecIes,
335 sme_join_rsp->tspecIeLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530336 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800337 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530338 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800339 lim_log(mac_ctx, LOG1, FL("ESE-TspecLen=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530340 sme_join_rsp->tspecIeLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800341 }
342#endif
343 sme_join_rsp->aid = session_entry->limAID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800344 lim_log(mac_ctx, LOG1, FL("AssocRsp=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530345 sme_join_rsp->assocRspLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800346 sme_join_rsp->vht_channel_width =
347 session_entry->ch_width;
348#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
349 if (session_entry->cc_switch_mode !=
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530350 QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800351 ht_profile = &sme_join_rsp->HTProfile;
352 ht_profile->htSupportedChannelWidthSet =
353 session_entry->htSupportedChannelWidthSet;
354 ht_profile->htRecommendedTxWidthSet =
355 session_entry->htRecommendedTxWidthSet;
356 ht_profile->htSecondaryChannelOffset =
357 session_entry->htSecondaryChannelOffset;
358 ht_profile->dot11mode = session_entry->dot11mode;
359 ht_profile->htCapability = session_entry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800360 ht_profile->vhtCapability =
361 session_entry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800362 ht_profile->apCenterChan = session_entry->ch_center_freq_seg0;
363 ht_profile->apChanWidth = session_entry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800364 }
365#endif
366 } else {
367 if (session_entry->beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530368 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800369 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530370 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800371 }
372 if (session_entry->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530373 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800374 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530375 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800376 }
377 if (session_entry->assocRsp != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530378 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800379 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530380 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800381 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800382 if (session_entry->ricData != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530383 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800384 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530385 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800386 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800387#ifdef FEATURE_WLAN_ESE
388 if (session_entry->tspecIes != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530389 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800390 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530391 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800392 }
393#endif
394 }
395}
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530396
397/**
398 * lim_add_bss_info() - copy data from session entry to join rsp
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530399 * @sta_ds: Station dph entry
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530400 * @sme_join_rsp: Join response buffer to be filled up
401 *
402 * Return: None
403 */
Jeff Johnson6db011e2016-10-07 07:31:39 -0700404static void lim_add_bss_info(tpDphHashNode sta_ds, tpSirSmeJoinRsp sme_join_rsp)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530405{
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530406 struct parsed_ies *parsed_ies = &sta_ds->parsed_ies;
407
408 if (parsed_ies->hs20vendor_ie.present)
409 sme_join_rsp->hs20vendor_ie = parsed_ies->hs20vendor_ie;
410 if (parsed_ies->vht_caps.present)
411 sme_join_rsp->vht_caps = parsed_ies->vht_caps;
412 if (parsed_ies->ht_caps.present)
413 sme_join_rsp->ht_caps = parsed_ies->ht_caps;
414 if (parsed_ies->ht_operation.present)
415 sme_join_rsp->ht_operation = parsed_ies->ht_operation;
416 if (parsed_ies->vht_operation.present)
417 sme_join_rsp->vht_operation = parsed_ies->vht_operation;
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530418}
419
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800420/**
421 * lim_send_sme_join_reassoc_rsp() - Send Response to Upper Layers
422 * @mac_ctx: Pointer to Global MAC structure
423 * @msg_type: Indicates message type
424 * @result_code: Indicates the result of previously issued
425 * eWNI_SME_msgType_REQ message
426 * @prot_status_code: Protocol Status Code
427 * @session_entry: PE Session Info
428 * @sme_session_id: SME Session ID
429 * @sme_transaction_id: SME Transaction ID
430 *
431 * This function is called by lim_process_sme_req_messages() to send
432 * eWNI_SME_JOIN_RSP or eWNI_SME_REASSOC_RSP messages to applications
433 * above MAC Software.
434 *
435 * Return: None
436 */
437
438void
439lim_send_sme_join_reassoc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
440 tSirResultCodes result_code, uint16_t prot_status_code,
441 tpPESession session_entry, uint8_t sme_session_id,
442 uint16_t sme_transaction_id)
443{
444 tpSirSmeJoinRsp sme_join_rsp;
445 uint32_t rsp_len;
446 tpDphHashNode sta_ds = NULL;
447#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
448 if (msg_type == eWNI_SME_REASSOC_RSP)
449 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_RSP_EVENT,
450 session_entry, (uint16_t) result_code, 0);
451 else
452 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_RSP_EVENT,
453 session_entry, (uint16_t) result_code, 0);
454#endif /* FEATURE_WLAN_DIAG_SUPPORT */
455
456 lim_log(mac_ctx, LOG1, FL("Sending message %s with reasonCode %s"),
457 lim_msg_str(msg_type), lim_result_code_str(result_code));
458
459 if (session_entry == NULL) {
460 rsp_len = sizeof(tSirSmeJoinRsp);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530461 sme_join_rsp = qdf_mem_malloc(rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800462 if (NULL == sme_join_rsp) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +0530463 lim_log(mac_ctx, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800464 FL("Mem Alloc fail - JOIN/REASSOC_RSP"));
465 return;
466 }
467
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800468 sme_join_rsp->beaconLength = 0;
469 sme_join_rsp->assocReqLength = 0;
470 sme_join_rsp->assocRspLength = 0;
471 } else {
472 rsp_len = session_entry->assocReqLen +
473 session_entry->assocRspLen + session_entry->bcnLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800474 session_entry->RICDataLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800475#ifdef FEATURE_WLAN_ESE
476 session_entry->tspecLen +
477#endif
478 sizeof(tSirSmeJoinRsp) - sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530479 sme_join_rsp = qdf_mem_malloc(rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800480 if (NULL == sme_join_rsp) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +0530481 lim_log(mac_ctx, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800482 FL("MemAlloc fail - JOIN/REASSOC_RSP"));
483 return;
484 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800485 if (result_code == eSIR_SME_SUCCESS) {
486 sta_ds = dph_get_hash_entry(mac_ctx,
487 DPH_STA_HASH_INDEX_PEER,
488 &session_entry->dph.dphHashTable);
489 if (sta_ds == NULL) {
490 lim_log(mac_ctx, LOGE,
491 FL("Get Self Sta Entry fail"));
492 } else {
493 /* Pass the peer's staId */
494 sme_join_rsp->staId = sta_ds->staIndex;
495 sme_join_rsp->ucastSig =
496 sta_ds->ucUcastSig;
497 sme_join_rsp->bcastSig =
498 sta_ds->ucBcastSig;
499 sme_join_rsp->timingMeasCap =
500 sta_ds->timingMeasCap;
501#ifdef FEATURE_WLAN_TDLS
502 sme_join_rsp->tdls_prohibited =
503 session_entry->tdls_prohibited;
504 sme_join_rsp->tdls_chan_swit_prohibited =
505 session_entry->tdls_chan_swit_prohibited;
506#endif
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530507 sme_join_rsp->nss = sta_ds->nss;
508 sme_join_rsp->max_rate_flags =
509 lim_get_max_rate_flags(mac_ctx, sta_ds);
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530510 lim_add_bss_info(sta_ds, sme_join_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800511 }
512 }
513 sme_join_rsp->beaconLength = 0;
514 sme_join_rsp->assocReqLength = 0;
515 sme_join_rsp->assocRspLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800516 sme_join_rsp->parsedRicRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800517#ifdef FEATURE_WLAN_ESE
518 sme_join_rsp->tspecIeLen = 0;
519#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800520 lim_handle_join_rsp_status(mac_ctx, session_entry, result_code,
521 sme_join_rsp);
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800522
523 /* Send supported NSS 1x1 to SME */
524 sme_join_rsp->supported_nss_1x1 =
525 session_entry->supported_nss_1x1;
526 lim_log(mac_ctx, LOG1,
527 FL("SME Join Rsp is supported NSS 1X1: %d"),
528 sme_join_rsp->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800529 }
530
531 sme_join_rsp->messageType = msg_type;
532 sme_join_rsp->length = (uint16_t) rsp_len;
533 sme_join_rsp->statusCode = result_code;
534 sme_join_rsp->protStatusCode = prot_status_code;
535
536 sme_join_rsp->sessionId = sme_session_id;
537 sme_join_rsp->transactionId = sme_transaction_id;
538
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530539 lim_send_sme_join_reassoc_rsp_after_resume(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800540 (uint32_t *)sme_join_rsp);
541}
542
543/**
544 * lim_send_sme_start_bss_rsp()
545 *
546 ***FUNCTION:
547 * This function is called to send eWNI_SME_START_BSS_RSP
548 * message to applications above MAC Software.
549 *
550 ***PARAMS:
551 *
552 ***LOGIC:
553 *
554 ***ASSUMPTIONS:
555 * NA
556 *
557 ***NOTE:
558 * NA
559 *
560 * @param pMac Pointer to Global MAC structure
561 * @param msgType Indicates message type
562 * @param resultCode Indicates the result of previously issued
563 * eWNI_SME_msgType_REQ message
564 *
565 * @return None
566 */
567
568void
569lim_send_sme_start_bss_rsp(tpAniSirGlobal pMac,
570 uint16_t msgType, tSirResultCodes resultCode,
571 tpPESession psessionEntry, uint8_t smesessionId,
572 uint16_t smetransactionId)
573{
574
575 uint16_t size = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700576 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800577 tSirSmeStartBssRsp *pSirSmeRsp;
578 uint16_t ieLen;
579 uint16_t ieOffset, curLen;
580
581 PELOG1(lim_log(pMac, LOG1, FL("Sending message %s with reasonCode %s"),
582 lim_msg_str(msgType), lim_result_code_str(resultCode));
583 )
584
585 size = sizeof(tSirSmeStartBssRsp);
586
587 if (psessionEntry == NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530588 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800589 if (NULL == pSirSmeRsp) {
590 /* / Buffer not available. Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +0530591 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800592 FL
593 ("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP"));
594 return;
595 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800596 } else {
597 /* subtract size of beaconLength + Mac Hdr + Fixed Fields before SSID */
598 ieOffset = sizeof(tAniBeaconStruct) + SIR_MAC_B_PR_SSID_OFFSET;
599 ieLen = psessionEntry->schBeaconOffsetBegin
600 + psessionEntry->schBeaconOffsetEnd - ieOffset;
601 /* calculate the memory size to allocate */
602 size += ieLen;
603
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530604 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800605 if (NULL == pSirSmeRsp) {
606 /* / Buffer not available. Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +0530607 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800608 FL
609 ("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP"));
610
611 return;
612 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800613 size = sizeof(tSirSmeStartBssRsp);
614 if (resultCode == eSIR_SME_SUCCESS) {
615
616 sir_copy_mac_addr(pSirSmeRsp->bssDescription.bssId,
617 psessionEntry->bssId);
618
619 /* Read beacon interval from session */
620 pSirSmeRsp->bssDescription.beaconInterval =
621 (uint16_t) psessionEntry->beaconParams.
622 beaconInterval;
623 pSirSmeRsp->bssType = psessionEntry->bssType;
624
625 if (cfg_get_capability_info
626 (pMac, &pSirSmeRsp->bssDescription.capabilityInfo,
627 psessionEntry)
628 != eSIR_SUCCESS)
Nishank Aggarwald5941bb2017-03-11 14:41:24 +0530629 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800630 FL
631 ("could not retrieve Capabilities value"));
632
633 lim_get_phy_mode(pMac,
634 (uint32_t *) &pSirSmeRsp->bssDescription.
635 nwType, psessionEntry);
636
637 pSirSmeRsp->bssDescription.channelId =
638 psessionEntry->currentOperChannel;
639
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700640 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800641 curLen = psessionEntry->schBeaconOffsetBegin - ieOffset;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530642 qdf_mem_copy((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800643 ieFields,
644 psessionEntry->pSchBeaconFrameBegin +
645 ieOffset, (uint32_t) curLen);
646
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530647 qdf_mem_copy(((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800648 ieFields) + curLen,
649 psessionEntry->pSchBeaconFrameEnd,
650 (uint32_t) psessionEntry->
651 schBeaconOffsetEnd);
652
Abhishek Singh34a4d862016-10-26 16:01:51 +0530653 pSirSmeRsp->bssDescription.length = (uint16_t)
654 (offsetof(tSirBssDescription, ieFields[0])
655 - sizeof(pSirSmeRsp->bssDescription.length)
656 + ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800657 /* This is the size of the message, subtracting the size of the pointer to ieFields */
658 size += ieLen - sizeof(uint32_t);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700659 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800660#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
661 if (psessionEntry->cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530662 != QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800663 pSirSmeRsp->HTProfile.
664 htSupportedChannelWidthSet =
665 psessionEntry->htSupportedChannelWidthSet;
666 pSirSmeRsp->HTProfile.htRecommendedTxWidthSet =
667 psessionEntry->htRecommendedTxWidthSet;
668 pSirSmeRsp->HTProfile.htSecondaryChannelOffset =
669 psessionEntry->htSecondaryChannelOffset;
670 pSirSmeRsp->HTProfile.dot11mode =
671 psessionEntry->dot11mode;
672 pSirSmeRsp->HTProfile.htCapability =
673 psessionEntry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800674 pSirSmeRsp->HTProfile.vhtCapability =
675 psessionEntry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800676 pSirSmeRsp->HTProfile.apCenterChan =
677 psessionEntry->ch_center_freq_seg0;
678 pSirSmeRsp->HTProfile.apChanWidth =
679 psessionEntry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800680 }
681#endif
682 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800683 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800684 pSirSmeRsp->messageType = msgType;
685 pSirSmeRsp->length = size;
686
687 /* Update SME session Id and transaction Id */
688 pSirSmeRsp->sessionId = smesessionId;
689 pSirSmeRsp->transactionId = smetransactionId;
690 pSirSmeRsp->statusCode = resultCode;
691 if (psessionEntry != NULL)
692 pSirSmeRsp->staId = psessionEntry->staId; /* else it will be always zero smeRsp StaID = 0 */
693
694 mmhMsg.type = msgType;
695 mmhMsg.bodyptr = pSirSmeRsp;
696 mmhMsg.bodyval = 0;
697 if (psessionEntry == NULL) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530698 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
699 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800700 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530701 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
702 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800703 }
704#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
705 lim_diag_event_report(pMac, WLAN_PE_DIAG_START_BSS_RSP_EVENT,
706 psessionEntry, (uint16_t) resultCode, 0);
707#endif /* FEATURE_WLAN_DIAG_SUPPORT */
708
709 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
710} /*** end lim_send_sme_start_bss_rsp() ***/
711
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800712/**
713 * lim_send_sme_scan_rsp() - Send scan response to SME
714 * @pMac: Pointer to Global MAC structure
715 * @length: Indicates length of message
716 * @resultCode: Indicates the result of previously issued
717 * eWNI_SME_SCAN_REQ message
718 * @scan_id: scan identifier
719 *
720 * This function is called by lim_process_sme_req_messages() to send
721 * eWNI_SME_SCAN_RSP message to applications above MAC
722 *
723 * return: None
724 */
725
726void
727lim_send_sme_scan_rsp(tpAniSirGlobal pMac, tSirResultCodes resultCode,
728 uint8_t smesessionId, uint16_t smetranscationId,
729 uint32_t scan_id)
730{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800731 lim_post_sme_scan_rsp_message(pMac, resultCode, smesessionId,
732 smetranscationId, scan_id);
733}
734
735/**
736 * lim_post_sme_scan_rsp_message()
737 *
738 ***FUNCTION:
739 * This function is called by lim_send_sme_scan_rsp() to send
740 * eWNI_SME_SCAN_RSP message with failed result code
741 *
742 ***NOTE:
743 * NA
744 *
745 * @param pMac Pointer to Global MAC structure
746 * @param length Indicates length of message
747 * @param resultCode failed result code
748 *
749 * @return None
750 */
751
752void
753lim_post_sme_scan_rsp_message(tpAniSirGlobal pMac,
754 tSirResultCodes resultCode, uint8_t smesessionId,
755 uint16_t smetransactionId,
756 uint32_t scan_id)
757{
758 tpSirSmeScanRsp pSirSmeScanRsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700759 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800760
761 lim_log(pMac, LOG1, FL("send SME_SCAN_RSP (reasonCode %s)."),
762 lim_result_code_str(resultCode));
763
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530764 pSirSmeScanRsp = qdf_mem_malloc(sizeof(tSirSmeScanRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800765 if (NULL == pSirSmeScanRsp) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +0530766 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800767 FL("AllocateMemory failed for eWNI_SME_SCAN_RSP"));
768 return;
769 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800770
771 pSirSmeScanRsp->messageType = eWNI_SME_SCAN_RSP;
772 pSirSmeScanRsp->statusCode = resultCode;
773
774 /*Update SME session Id and transaction Id */
775 pSirSmeScanRsp->sessionId = smesessionId;
776 pSirSmeScanRsp->transcationId = smetransactionId;
777 pSirSmeScanRsp->scan_id = scan_id;
778
779 mmhMsg.type = eWNI_SME_SCAN_RSP;
780 mmhMsg.bodyptr = pSirSmeScanRsp;
781 mmhMsg.bodyval = 0;
782
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530783 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800784#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
785 lim_diag_event_report(pMac, WLAN_PE_DIAG_SCAN_RSP_EVENT, NULL,
786 (uint16_t) resultCode, 0);
787#endif /* FEATURE_WLAN_DIAG_SUPPORT */
788
789 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
790 return;
791
792} /*** lim_post_sme_scan_rsp_message ***/
793
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800794void lim_send_sme_disassoc_deauth_ntf(tpAniSirGlobal pMac,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530795 QDF_STATUS status, uint32_t *pCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800796{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700797 struct scheduler_msg mmhMsg = {0};
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800798 struct scheduler_msg *pMsg = (struct scheduler_msg *) pCtx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800799
800 mmhMsg.type = pMsg->type;
801 mmhMsg.bodyptr = pMsg;
802 mmhMsg.bodyval = 0;
803
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530804 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800805
806 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
807}
808
809/**
810 * lim_send_sme_disassoc_ntf()
811 *
812 ***FUNCTION:
813 * This function is called by limProcessSmeMessages() to send
814 * eWNI_SME_DISASSOC_RSP/IND message to host
815 *
816 ***PARAMS:
817 *
818 ***LOGIC:
819 *
820 ***ASSUMPTIONS:
821 * NA
822 *
823 ***NOTE:
824 * This function is used for sending eWNI_SME_DISASSOC_CNF,
825 * or eWNI_SME_DISASSOC_IND to host depending on
826 * disassociation trigger.
827 *
828 * @param peerMacAddr Indicates the peer MAC addr to which
829 * disassociate was initiated
830 * @param reasonCode Indicates the reason for Disassociation
831 * @param disassocTrigger Indicates the trigger for Disassociation
832 * @param aid Indicates the STAID. This parameter is
833 * present only on AP.
834 *
835 * @return None
836 */
837void
838lim_send_sme_disassoc_ntf(tpAniSirGlobal pMac,
839 tSirMacAddr peerMacAddr,
840 tSirResultCodes reasonCode,
841 uint16_t disassocTrigger,
842 uint16_t aid,
843 uint8_t smesessionId,
844 uint16_t smetransactionId, tpPESession psessionEntry)
845{
846
847 uint8_t *pBuf;
848 tSirSmeDisassocRsp *pSirSmeDisassocRsp;
849 tSirSmeDisassocInd *pSirSmeDisassocInd;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700850 uint32_t *pMsg = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800851 bool failure = false;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700852 tpPESession session = NULL;
853 uint16_t i, assoc_id;
854 tpDphHashNode sta_ds = NULL;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530855 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800856
857 lim_log(pMac, LOG1, FL("Disassoc Ntf with trigger : %d reasonCode: %d"),
858 disassocTrigger, reasonCode);
859
860 switch (disassocTrigger) {
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700861 case eLIM_DUPLICATE_ENTRY:
862 /*
863 * Duplicate entry is removed at LIM.
864 * Initiate new entry for other session
865 */
866 lim_log(pMac, LOG1,
867 FL("Rcvd eLIM_DUPLICATE_ENTRY for " MAC_ADDRESS_STR),
868 MAC_ADDR_ARRAY(peerMacAddr));
869
870 for (i = 0; i < pMac->lim.maxBssId; i++) {
871 if ((&pMac->lim.gpSession[i] != NULL) &&
872 (pMac->lim.gpSession[i].valid) &&
873 (pMac->lim.gpSession[i].pePersona ==
874 QDF_SAP_MODE)) {
875 /* Find the sta ds entry in another session */
876 session = &pMac->lim.gpSession[i];
877 sta_ds = dph_lookup_hash_entry(pMac,
878 peerMacAddr, &assoc_id,
879 &session->dph.dphHashTable);
880 }
881 }
882 if (sta_ds
883#ifdef WLAN_FEATURE_11W
884 && (!sta_ds->rmfEnabled)
885#endif
886 ) {
887 if (lim_add_sta(pMac, sta_ds, false, session) !=
888 eSIR_SUCCESS)
889 lim_log(pMac, LOGE,
890 FL("could not Add STA with assocId=%d"),
891 sta_ds->assocId);
892 }
893 failure = true;
894 break;
895
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800896 case eLIM_HOST_DISASSOC:
897 /**
898 * Disassociation response due to
899 * host triggered disassociation
900 */
901
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530902 pSirSmeDisassocRsp = qdf_mem_malloc(sizeof(tSirSmeDisassocRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800903 if (NULL == pSirSmeDisassocRsp) {
904 /* Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +0530905 lim_log(pMac, LOGE, FL("Memory allocation failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800906 failure = true;
907 goto error;
908 }
909 lim_log(pMac, LOG1, FL("send eWNI_SME_DISASSOC_RSP with "
910 "retCode: %d for " MAC_ADDRESS_STR),
911 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
912 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
913 pSirSmeDisassocRsp->length = sizeof(tSirSmeDisassocRsp);
914 /* sessionId */
915 pBuf = (uint8_t *) &pSirSmeDisassocRsp->sessionId;
916 *pBuf = smesessionId;
917 pBuf++;
918
919 /* transactionId */
920 lim_copy_u16(pBuf, smetransactionId);
921 pBuf += sizeof(uint16_t);
922
923 /* statusCode */
924 lim_copy_u32(pBuf, reasonCode);
925 pBuf += sizeof(tSirResultCodes);
926
927 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530928 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800929 pBuf += sizeof(tSirMacAddr);
930
931 /* Clear Station Stats */
932 /* for sta, it is always 1, IBSS is handled at halInitSta */
933
934#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
935
936 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
937 psessionEntry, (uint16_t) reasonCode, 0);
938#endif
939 pMsg = (uint32_t *) pSirSmeDisassocRsp;
940 break;
941
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530942 case eLIM_PEER_ENTITY_DISASSOC:
943 case eLIM_LINK_MONITORING_DISASSOC:
944 sir_sme_dis_ind =
945 qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
946 if (!sir_sme_dis_ind) {
947 lim_log(pMac, LOGE,
948 FL("call to AllocateMemory failed for disconnect indication"));
949 return;
950 }
951
952 lim_log(pMac, LOG1,
953 FL("send eWNI_SME_DISCONNECT_DONE_IND with retCode: %d"),
954 reasonCode);
955
956 sir_sme_dis_ind->message_type =
957 eWNI_SME_DISCONNECT_DONE_IND;
958 sir_sme_dis_ind->length =
959 sizeof(*sir_sme_dis_ind);
960 qdf_mem_copy(sir_sme_dis_ind->peer_mac, peerMacAddr,
961 sizeof(tSirMacAddr));
962 sir_sme_dis_ind->session_id = smesessionId;
963 sir_sme_dis_ind->reason_code = reasonCode;
Selvaraj, Sridharc7d80892016-09-29 11:56:45 +0530964 /*
965 * Instead of sending deauth reason code as 505 which is
966 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
967 * Send reason code as zero to Supplicant
968 */
969 if (reasonCode == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
970 sir_sme_dis_ind->reason_code = 0;
971 else
972 sir_sme_dis_ind->reason_code = reasonCode;
973
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530974 pMsg = (uint32_t *)sir_sme_dis_ind;
975
976 break;
977
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800978 default:
979 /**
980 * Disassociation indication due to Disassociation
981 * frame reception from peer entity or due to
982 * loss of link with peer entity.
983 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530984 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800985 if (NULL == pSirSmeDisassocInd) {
986 /* Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +0530987 lim_log(pMac, LOGE, FL("Memory allocation failed"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800988 failure = true;
989 goto error;
990 }
991 lim_log(pMac, LOG1, FL("send eWNI_SME_DISASSOC_IND with "
992 "retCode: %d for " MAC_ADDRESS_STR),
993 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
994 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
995 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
996
997 /* Update SME session Id and Transaction Id */
998 pSirSmeDisassocInd->sessionId = smesessionId;
999 pSirSmeDisassocInd->transactionId = smetransactionId;
1000 pSirSmeDisassocInd->reasonCode = reasonCode;
1001 pBuf = (uint8_t *) &pSirSmeDisassocInd->statusCode;
1002
1003 lim_copy_u32(pBuf, reasonCode);
1004 pBuf += sizeof(tSirResultCodes);
1005
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301006 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001007 pBuf += sizeof(tSirMacAddr);
1008
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301009 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001010
1011#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1012 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
1013 psessionEntry, (uint16_t) reasonCode, 0);
1014#endif
1015 pMsg = (uint32_t *) pSirSmeDisassocInd;
1016
1017 break;
1018 }
1019
1020error:
1021 /* Delete the PE session Created */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07001022 if ((psessionEntry != NULL) && LIM_IS_STA_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001023 pe_delete_session(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001024
1025 if (false == failure)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301026 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001027 (uint32_t *) pMsg);
1028} /*** end lim_send_sme_disassoc_ntf() ***/
1029
1030/** -----------------------------------------------------------------
1031 \brief lim_send_sme_disassoc_ind() - sends SME_DISASSOC_IND
1032
1033 After receiving disassociation frame from peer entity, this
1034 function sends a eWNI_SME_DISASSOC_IND to SME with a specific
1035 reason code.
1036
1037 \param pMac - global mac structure
1038 \param pStaDs - station dph hash node
1039 \return none
1040 \sa
1041 ----------------------------------------------------------------- */
1042void
1043lim_send_sme_disassoc_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1044 tpPESession psessionEntry)
1045{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001046 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001047 tSirSmeDisassocInd *pSirSmeDisassocInd;
1048
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301049 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001050 if (NULL == pSirSmeDisassocInd) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301051 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001052 FL("AllocateMemory failed for eWNI_SME_DISASSOC_IND"));
1053 return;
1054 }
1055
1056 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
1057 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
1058
1059 pSirSmeDisassocInd->sessionId = psessionEntry->smeSessionId;
1060 pSirSmeDisassocInd->transactionId = psessionEntry->transactionId;
Padma, Santhosh Kumar02289212016-09-30 13:30:08 +05301061 pSirSmeDisassocInd->statusCode = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001062 pSirSmeDisassocInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1063
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301064 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301065 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001066
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301067 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301068 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001069
1070 pSirSmeDisassocInd->staId = pStaDs->staIndex;
1071
1072 mmhMsg.type = eWNI_SME_DISASSOC_IND;
1073 mmhMsg.bodyptr = pSirSmeDisassocInd;
1074 mmhMsg.bodyval = 0;
1075
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301076 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1077 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001078#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1079 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT, psessionEntry,
1080 0, (uint16_t) pStaDs->mlmStaContext.disassocReason);
1081#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1082
1083 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1084
1085} /*** end lim_send_sme_disassoc_ind() ***/
1086
1087/** -----------------------------------------------------------------
1088 \brief lim_send_sme_deauth_ind() - sends SME_DEAUTH_IND
1089
1090 After receiving deauthentication frame from peer entity, this
1091 function sends a eWNI_SME_DEAUTH_IND to SME with a specific
1092 reason code.
1093
1094 \param pMac - global mac structure
1095 \param pStaDs - station dph hash node
1096 \return none
1097 \sa
1098 ----------------------------------------------------------------- */
1099void
1100lim_send_sme_deauth_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1101 tpPESession psessionEntry)
1102{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001103 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001104 tSirSmeDeauthInd *pSirSmeDeauthInd;
1105
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301106 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001107 if (NULL == pSirSmeDeauthInd) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301108 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001109 FL("AllocateMemory failed for eWNI_SME_DEAUTH_IND "));
1110 return;
1111 }
1112
1113 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1114 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1115
1116 pSirSmeDeauthInd->sessionId = psessionEntry->smeSessionId;
1117 pSirSmeDeauthInd->transactionId = psessionEntry->transactionId;
1118 if (eSIR_INFRA_AP_MODE == psessionEntry->bssType) {
1119 pSirSmeDeauthInd->statusCode =
1120 (tSirResultCodes) pStaDs->mlmStaContext.cleanupTrigger;
1121 } else {
1122 /* Need to indicatet he reascon code over the air */
1123 pSirSmeDeauthInd->statusCode =
1124 (tSirResultCodes) pStaDs->mlmStaContext.disassocReason;
1125 }
1126 /* BSSID */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301127 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301128 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001129 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301130 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301131 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001132 pSirSmeDeauthInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1133
1134 pSirSmeDeauthInd->staId = pStaDs->staIndex;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001135 if (eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON ==
1136 pStaDs->mlmStaContext.disassocReason)
1137 pSirSmeDeauthInd->rssi = pStaDs->del_sta_ctx_rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001138
1139 mmhMsg.type = eWNI_SME_DEAUTH_IND;
1140 mmhMsg.bodyptr = pSirSmeDeauthInd;
1141 mmhMsg.bodyval = 0;
1142
1143 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1144#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1145 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT, psessionEntry,
1146 0, pStaDs->mlmStaContext.cleanupTrigger);
1147#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1148
1149 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1150 return;
1151} /*** end lim_send_sme_deauth_ind() ***/
1152
1153#ifdef FEATURE_WLAN_TDLS
1154/**
1155 * lim_send_sme_tdls_del_sta_ind()
1156 *
1157 ***FUNCTION:
1158 * This function is called to send the TDLS STA context deletion to SME.
1159 *
1160 ***LOGIC:
1161 *
1162 ***ASSUMPTIONS:
1163 *
1164 ***NOTE:
1165 * NA
1166 *
1167 * @param pMac - Pointer to global MAC structure
1168 * @param pStaDs - Pointer to internal STA Datastructure
1169 * @param psessionEntry - Pointer to the session entry
1170 * @param reasonCode - Reason for TDLS sta deletion
1171 * @return None
1172 */
1173void
1174lim_send_sme_tdls_del_sta_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1175 tpPESession psessionEntry, uint16_t reasonCode)
1176{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001177 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001178 tSirTdlsDelStaInd *pSirTdlsDelStaInd;
1179
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301180 pSirTdlsDelStaInd = qdf_mem_malloc(sizeof(tSirTdlsDelStaInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001181 if (NULL == pSirTdlsDelStaInd) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301182 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001183 FL
1184 ("AllocateMemory failed for eWNI_SME_TDLS_DEL_STA_IND "));
1185 return;
1186 }
Nitesh Shah82c52812016-12-27 12:27:51 +05301187 lim_log(pMac, LOG1, FL("Delete TDLS Peer "MAC_ADDRESS_STR
1188 "with reason code %d"),
1189 MAC_ADDR_ARRAY(pStaDs->staAddr), reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001190 /* messageType */
1191 pSirTdlsDelStaInd->messageType = eWNI_SME_TDLS_DEL_STA_IND;
1192 pSirTdlsDelStaInd->length = sizeof(tSirTdlsDelStaInd);
1193
1194 /* sessionId */
1195 pSirTdlsDelStaInd->sessionId = psessionEntry->smeSessionId;
1196
1197 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301198 qdf_mem_copy(pSirTdlsDelStaInd->peermac.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301199 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001200
1201 /* staId */
1202 lim_copy_u16((uint8_t *) (&pSirTdlsDelStaInd->staId),
1203 (uint16_t) pStaDs->staIndex);
1204
1205 /* reasonCode */
1206 lim_copy_u16((uint8_t *) (&pSirTdlsDelStaInd->reasonCode), reasonCode);
1207
1208 mmhMsg.type = eWNI_SME_TDLS_DEL_STA_IND;
1209 mmhMsg.bodyptr = pSirTdlsDelStaInd;
1210 mmhMsg.bodyval = 0;
1211
1212 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1213 return;
1214} /*** end lim_send_sme_tdls_del_sta_ind() ***/
1215
1216/**
1217 * lim_send_sme_tdls_delete_all_peer_ind()
1218 *
1219 ***FUNCTION:
1220 * This function is called to send the eWNI_SME_TDLS_DEL_ALL_PEER_IND
1221 * message to SME.
1222 *
1223 ***LOGIC:
1224 *
1225 ***ASSUMPTIONS:
1226 *
1227 ***NOTE:
1228 * NA
1229 *
1230 * @param pMac - Pointer to global MAC structure
1231 * @param psessionEntry - Pointer to the session entry
1232 * @return None
1233 */
1234void
1235lim_send_sme_tdls_delete_all_peer_ind(tpAniSirGlobal pMac, tpPESession psessionEntry)
1236{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001237 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001238 tSirTdlsDelAllPeerInd *pSirTdlsDelAllPeerInd;
1239
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301240 pSirTdlsDelAllPeerInd = qdf_mem_malloc(sizeof(tSirTdlsDelAllPeerInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001241 if (NULL == pSirTdlsDelAllPeerInd) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301242 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001243 FL
1244 ("AllocateMemory failed for eWNI_SME_TDLS_DEL_ALL_PEER_IND"));
1245 return;
1246 }
1247 /* messageType */
1248 pSirTdlsDelAllPeerInd->messageType = eWNI_SME_TDLS_DEL_ALL_PEER_IND;
1249 pSirTdlsDelAllPeerInd->length = sizeof(tSirTdlsDelAllPeerInd);
1250
1251 /* sessionId */
1252 pSirTdlsDelAllPeerInd->sessionId = psessionEntry->smeSessionId;
1253
1254 mmhMsg.type = eWNI_SME_TDLS_DEL_ALL_PEER_IND;
1255 mmhMsg.bodyptr = pSirTdlsDelAllPeerInd;
1256 mmhMsg.bodyval = 0;
1257
1258 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1259 return;
1260} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1261
1262/**
1263 * lim_send_sme_mgmt_tx_completion()
1264 *
1265 ***FUNCTION:
1266 * This function is called to send the eWNI_SME_MGMT_FRM_TX_COMPLETION_IND
1267 * message to SME.
1268 *
1269 ***LOGIC:
1270 *
1271 ***ASSUMPTIONS:
1272 *
1273 ***NOTE:
1274 * NA
1275 *
1276 * @param pMac - Pointer to global MAC structure
1277 * @param psessionEntry - Pointer to the session entry
1278 * @param txCompleteStatus - TX Complete Status of Mgmt Frames
1279 * @return None
1280 */
1281void
1282lim_send_sme_mgmt_tx_completion(tpAniSirGlobal pMac,
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301283 uint32_t sme_session_id,
1284 uint32_t txCompleteStatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001285{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001286 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001287 tSirMgmtTxCompletionInd *pSirMgmtTxCompletionInd;
1288
1289 pSirMgmtTxCompletionInd =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301290 qdf_mem_malloc(sizeof(tSirMgmtTxCompletionInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001291 if (NULL == pSirMgmtTxCompletionInd) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301292 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001293 FL
1294 ("AllocateMemory failed for eWNI_SME_MGMT_FRM_TX_COMPLETION_IND"));
1295 return;
1296 }
1297 /* messageType */
1298 pSirMgmtTxCompletionInd->messageType =
1299 eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1300 pSirMgmtTxCompletionInd->length = sizeof(tSirMgmtTxCompletionInd);
1301
1302 /* sessionId */
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301303 pSirMgmtTxCompletionInd->sessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001304
1305 pSirMgmtTxCompletionInd->txCompleteStatus = txCompleteStatus;
1306
1307 mmhMsg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1308 mmhMsg.bodyptr = pSirMgmtTxCompletionInd;
1309 mmhMsg.bodyval = 0;
1310
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07001311#ifdef CONVERGED_TDLS_ENABLE
1312 pSirMgmtTxCompletionInd->psoc = pMac->psoc;
1313 mmhMsg.callback = tgt_tdls_send_mgmt_tx_completion;
1314 scheduler_post_msg(QDF_MODULE_ID_TARGET_IF, &mmhMsg);
1315 return;
1316#else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001317 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1318 return;
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07001319#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001320} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1321
1322void lim_send_sme_tdls_event_notify(tpAniSirGlobal pMac, uint16_t msgType,
1323 void *events)
1324{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001325 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001326
1327 switch (msgType) {
1328 case SIR_HAL_TDLS_SHOULD_DISCOVER:
1329 mmhMsg.type = eWNI_SME_TDLS_SHOULD_DISCOVER;
1330 break;
1331 case SIR_HAL_TDLS_SHOULD_TEARDOWN:
1332 mmhMsg.type = eWNI_SME_TDLS_SHOULD_TEARDOWN;
1333 break;
1334 case SIR_HAL_TDLS_PEER_DISCONNECTED:
1335 mmhMsg.type = eWNI_SME_TDLS_PEER_DISCONNECTED;
1336 break;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07001337 case SIR_HAL_TDLS_CONNECTION_TRACKER_NOTIFICATION:
1338 mmhMsg.type = eWNI_SME_TDLS_CONNECTION_TRACKER_NOTIFICATION;
1339 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001340 }
1341
1342 mmhMsg.bodyptr = events;
1343 mmhMsg.bodyval = 0;
1344 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1345 return;
1346}
1347#endif /* FEATURE_WLAN_TDLS */
1348
1349/**
1350 * lim_send_sme_deauth_ntf()
1351 *
1352 ***FUNCTION:
1353 * This function is called by limProcessSmeMessages() to send
1354 * eWNI_SME_DISASSOC_RSP/IND message to host
1355 *
1356 ***PARAMS:
1357 *
1358 ***LOGIC:
1359 *
1360 ***ASSUMPTIONS:
1361 * NA
1362 *
1363 ***NOTE:
1364 * This function is used for sending eWNI_SME_DEAUTH_CNF or
1365 * eWNI_SME_DEAUTH_IND to host depending on deauthentication trigger.
1366 *
1367 * @param peerMacAddr Indicates the peer MAC addr to which
1368 * deauthentication was initiated
1369 * @param reasonCode Indicates the reason for Deauthetication
1370 * @param deauthTrigger Indicates the trigger for Deauthetication
1371 * @param aid Indicates the STAID. This parameter is present
1372 * only on AP.
1373 *
1374 * @return None
1375 */
1376void
1377lim_send_sme_deauth_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
1378 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1379 uint16_t aid, uint8_t smesessionId,
1380 uint16_t smetransactionId)
1381{
1382 uint8_t *pBuf;
1383 tSirSmeDeauthRsp *pSirSmeDeauthRsp;
1384 tSirSmeDeauthInd *pSirSmeDeauthInd;
1385 tpPESession psessionEntry;
1386 uint8_t sessionId;
1387 uint32_t *pMsg;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301388 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001389
1390 psessionEntry = pe_find_session_by_bssid(pMac, peerMacAddr, &sessionId);
1391 switch (deauthTrigger) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001392 case eLIM_HOST_DEAUTH:
1393 /**
1394 * Deauthentication response to host triggered
1395 * deauthentication.
1396 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301397 pSirSmeDeauthRsp = qdf_mem_malloc(sizeof(tSirSmeDeauthRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001398 if (NULL == pSirSmeDeauthRsp) {
1399 /* Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301400 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001401 FL
1402 ("call to AllocateMemory failed for eWNI_SME_DEAUTH_RSP"));
1403
1404 return;
1405 }
1406 lim_log(pMac, LOG1, FL("send eWNI_SME_DEAUTH_RSP with "
1407 "retCode: %d for" MAC_ADDRESS_STR),
1408 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1409 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
1410 pSirSmeDeauthRsp->length = sizeof(tSirSmeDeauthRsp);
1411 pSirSmeDeauthRsp->statusCode = reasonCode;
1412 pSirSmeDeauthRsp->sessionId = smesessionId;
1413 pSirSmeDeauthRsp->transactionId = smetransactionId;
1414
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -08001415 pBuf = (uint8_t *) pSirSmeDeauthRsp->peer_macaddr.bytes;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301416 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001417
1418#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1419 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
1420 psessionEntry, 0, (uint16_t) reasonCode);
1421#endif
1422 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1423
1424 break;
1425
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301426 case eLIM_PEER_ENTITY_DEAUTH:
1427 case eLIM_LINK_MONITORING_DEAUTH:
1428 sir_sme_dis_ind =
1429 qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
1430 if (!sir_sme_dis_ind) {
1431 lim_log(pMac, LOGE,
1432 FL("call to AllocateMemory failed for disconnect indication"));
1433 return;
1434 }
1435
1436 lim_log(pMac, LOG1,
1437 FL("send eWNI_SME_DISCONNECT_DONE_IND withretCode: %d"),
1438 reasonCode);
1439
1440 sir_sme_dis_ind->message_type =
1441 eWNI_SME_DISCONNECT_DONE_IND;
1442 sir_sme_dis_ind->length =
1443 sizeof(*sir_sme_dis_ind);
1444 sir_sme_dis_ind->session_id = smesessionId;
1445 sir_sme_dis_ind->reason_code = reasonCode;
1446 qdf_mem_copy(sir_sme_dis_ind->peer_mac, peerMacAddr,
1447 ETH_ALEN);
Selvaraj, Sridharc7d80892016-09-29 11:56:45 +05301448 /*
1449 * Instead of sending deauth reason code as 505 which is
1450 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1451 * Send reason code as zero to Supplicant
1452 */
1453 if (reasonCode == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1454 sir_sme_dis_ind->reason_code = 0;
1455 else
1456 sir_sme_dis_ind->reason_code = reasonCode;
1457
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301458 pMsg = (uint32_t *)sir_sme_dis_ind;
1459
1460 break;
1461
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001462 default:
1463 /**
1464 * Deauthentication indication due to Deauthentication
1465 * frame reception from peer entity or due to
1466 * loss of link with peer entity.
1467 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301468 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001469 if (NULL == pSirSmeDeauthInd) {
1470 /* Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301471 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001472 FL
1473 ("call to AllocateMemory failed for eWNI_SME_DEAUTH_Ind"));
1474
1475 return;
1476 }
1477 lim_log(pMac, LOG1, FL("send eWNI_SME_DEAUTH_IND with "
1478 "retCode: %d for " MAC_ADDRESS_STR),
1479 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1480 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1481 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1482 pSirSmeDeauthInd->reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
1483
1484 /* sessionId */
1485 pBuf = (uint8_t *) &pSirSmeDeauthInd->sessionId;
1486 *pBuf++ = smesessionId;
1487
1488 /* transaction ID */
1489 lim_copy_u16(pBuf, smetransactionId);
1490 pBuf += sizeof(uint16_t);
1491
1492 /* status code */
1493 lim_copy_u32(pBuf, reasonCode);
1494 pBuf += sizeof(tSirResultCodes);
1495
1496 /* bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301497 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001498 pBuf += sizeof(tSirMacAddr);
1499
1500 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301501 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301502 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001503
1504#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1505 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
1506 psessionEntry, 0, (uint16_t) reasonCode);
1507#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1508 pMsg = (uint32_t *) pSirSmeDeauthInd;
1509
1510 break;
1511 }
1512
1513 /*Delete the PE session created */
1514 if (psessionEntry != NULL) {
1515 pe_delete_session(pMac, psessionEntry);
1516 }
1517
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301518 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001519 (uint32_t *) pMsg);
1520
1521} /*** end lim_send_sme_deauth_ntf() ***/
1522
1523/**
1524 * lim_send_sme_wm_status_change_ntf() - Send Notification
1525 * @mac_ctx: Global MAC Context
1526 * @status_change_code: Indicates the change in the wireless medium.
1527 * @status_change_info: Indicates the information associated with
1528 * change in the wireless medium.
1529 * @info_len: Indicates the length of status change information
1530 * being sent.
1531 * @session_id SessionID
1532 *
1533 * This function is called by limProcessSmeMessages() to send
1534 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1535 *
1536 * Return: None
1537 */
1538void
1539lim_send_sme_wm_status_change_ntf(tpAniSirGlobal mac_ctx,
1540 tSirSmeStatusChangeCode status_change_code,
1541 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1542{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001543 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001544 tSirSmeWmStatusChangeNtf *wm_status_change_ntf;
Naveen Rawate01ed172016-11-17 11:34:50 -08001545 uint32_t max_info_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001546
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301547 wm_status_change_ntf = qdf_mem_malloc(sizeof(tSirSmeWmStatusChangeNtf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001548 if (NULL == wm_status_change_ntf) {
1549 lim_log(mac_ctx, LOGE,
1550 FL("Mem Alloc failed - eWNI_SME_WM_STATUS_CHANGE_NTF"));
1551 return;
1552 }
1553
1554 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1555 msg.bodyval = 0;
1556 msg.bodyptr = wm_status_change_ntf;
1557
1558 switch (status_change_code) {
Naveen Rawate01ed172016-11-17 11:34:50 -08001559 case eSIR_SME_AP_CAPS_CHANGED:
1560 max_info_len = sizeof(tSirSmeApNewCaps);
1561 break;
1562 case eSIR_SME_JOINED_NEW_BSS:
1563 max_info_len = sizeof(tSirSmeNewBssInfo);
1564 break;
1565 default:
1566 max_info_len = sizeof(wm_status_change_ntf->statusChangeInfo);
1567 break;
1568 }
1569
1570 switch (status_change_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001571 case eSIR_SME_RADAR_DETECTED:
1572 break;
1573 default:
1574 wm_status_change_ntf->messageType =
1575 eWNI_SME_WM_STATUS_CHANGE_NTF;
1576 wm_status_change_ntf->statusChangeCode = status_change_code;
1577 wm_status_change_ntf->length = sizeof(tSirSmeWmStatusChangeNtf);
1578 wm_status_change_ntf->sessionId = session_id;
Naveen Rawate01ed172016-11-17 11:34:50 -08001579 if (info_len <= max_info_len && status_change_info) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301580 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001581 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1582 (uint8_t *) status_change_info, info_len);
1583 }
1584 lim_log(mac_ctx, LOGE,
1585 FL("**---** StatusChg: code 0x%x, length %d **---**"),
1586 status_change_code, info_len);
1587 break;
1588 }
1589
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301590 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001591 if (eSIR_SUCCESS != lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301592 qdf_mem_free(wm_status_change_ntf);
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301593 lim_log(mac_ctx, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001594 FL("lim_sys_process_mmh_msg_api failed"));
1595 }
1596
1597} /*** end lim_send_sme_wm_status_change_ntf() ***/
1598
1599/**
1600 * lim_send_sme_set_context_rsp()
1601 *
1602 ***FUNCTION:
1603 * This function is called by limProcessSmeMessages() to send
1604 * eWNI_SME_SETCONTEXT_RSP message to host
1605 *
1606 ***PARAMS:
1607 *
1608 ***LOGIC:
1609 *
1610 ***ASSUMPTIONS:
1611 * NA
1612 *
1613 ***NOTE:
1614 *
1615 * @param pMac Pointer to Global MAC structure
1616 * @param peerMacAddr Indicates the peer MAC addr to which
1617 * setContext was performed
1618 * @param aid Indicates the aid corresponding to the peer MAC
1619 * address
1620 * @param resultCode Indicates the result of previously issued
1621 * eWNI_SME_SETCONTEXT_RSP message
1622 *
1623 * @return None
1624 */
1625void
1626lim_send_sme_set_context_rsp(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301627 struct qdf_mac_addr peer_macaddr, uint16_t aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001628 tSirResultCodes resultCode,
1629 tpPESession psessionEntry, uint8_t smesessionId,
1630 uint16_t smetransactionId)
1631{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001632 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001633 tSirSmeSetContextRsp *pSirSmeSetContextRsp;
1634
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301635 pSirSmeSetContextRsp = qdf_mem_malloc(sizeof(tSirSmeSetContextRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001636 if (NULL == pSirSmeSetContextRsp) {
1637 /* Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301638 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001639 FL
1640 ("call to AllocateMemory failed for SmeSetContextRsp"));
1641
1642 return;
1643 }
1644
1645 pSirSmeSetContextRsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1646 pSirSmeSetContextRsp->length = sizeof(tSirSmeSetContextRsp);
1647 pSirSmeSetContextRsp->statusCode = resultCode;
1648
Anurag Chouhanc5548422016-02-24 18:33:27 +05301649 qdf_copy_macaddr(&pSirSmeSetContextRsp->peer_macaddr, &peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001650
1651 /* Update SME session and transaction Id */
1652 pSirSmeSetContextRsp->sessionId = smesessionId;
1653 pSirSmeSetContextRsp->transactionId = smetransactionId;
1654
1655 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
1656 mmhMsg.bodyptr = pSirSmeSetContextRsp;
1657 mmhMsg.bodyval = 0;
1658 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301659 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1660 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001661 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301662 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1663 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001664 }
1665
1666#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1667 lim_diag_event_report(pMac, WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
1668 psessionEntry, (uint16_t) resultCode, 0);
1669#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1670
1671 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1672} /*** end lim_send_sme_set_context_rsp() ***/
1673
1674/**
1675 * lim_send_sme_neighbor_bss_ind()
1676 *
1677 ***FUNCTION:
1678 * This function is called by lim_lookup_nadd_hash_entry() to send
1679 * eWNI_SME_NEIGHBOR_BSS_IND message to host
1680 *
1681 ***PARAMS:
1682 *
1683 ***LOGIC:
1684 *
1685 ***ASSUMPTIONS:
1686 * NA
1687 *
1688 ***NOTE:
1689 * This function is used for sending eWNI_SME_NEIGHBOR_BSS_IND to
1690 * host upon detecting new BSS during background scanning if CFG
1691 * option is enabled for sending such indication
1692 *
1693 * @param pMac - Pointer to Global MAC structure
1694 * @return None
1695 */
1696
1697void
1698lim_send_sme_neighbor_bss_ind(tpAniSirGlobal pMac, tLimScanResultNode *pBssDescr)
1699{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001700 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001701 uint32_t val;
1702 tSirSmeNeighborBssInd *pNewBssInd;
1703
1704 if ((pMac->lim.gLimSmeState != eLIM_SME_LINK_EST_WT_SCAN_STATE) ||
1705 ((pMac->lim.gLimSmeState == eLIM_SME_LINK_EST_WT_SCAN_STATE) &&
1706 pMac->lim.gLimRspReqd)) {
1707 /* LIM is not in background scan state OR */
1708 /* current scan is initiated by HDD. */
1709 /* No need to send new BSS indication to HDD */
1710 return;
1711 }
1712
1713 if (wlan_cfg_get_int(pMac, WNI_CFG_NEW_BSS_FOUND_IND, &val) !=
1714 eSIR_SUCCESS) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301715 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001716 FL("could not get NEIGHBOR_BSS_IND from CFG"));
1717
1718 return;
1719 }
1720
1721 if (val == 0)
1722 return;
1723
1724 /**
1725 * Need to indicate new BSSs found during
1726 * background scanning to host.
1727 * Allocate buffer for sending indication.
1728 * Length of buffer is length of BSS description
1729 * and length of header itself
1730 */
1731 val = pBssDescr->bssDescription.length + sizeof(uint16_t) +
1732 sizeof(uint32_t) + sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301733 pNewBssInd = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001734 if (NULL == pNewBssInd) {
1735 /* Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301736 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001737 FL
1738 ("call to AllocateMemory failed for eWNI_SME_NEIGHBOR_BSS_IND"));
1739
1740 return;
1741 }
1742
1743 pNewBssInd->messageType = eWNI_SME_NEIGHBOR_BSS_IND;
1744 pNewBssInd->length = (uint16_t) val;
1745 pNewBssInd->sessionId = 0;
1746
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301747 qdf_mem_copy((uint8_t *) pNewBssInd->bssDescription,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001748 (uint8_t *) &pBssDescr->bssDescription,
1749 pBssDescr->bssDescription.length + sizeof(uint16_t));
1750
1751 msgQ.type = eWNI_SME_NEIGHBOR_BSS_IND;
1752 msgQ.bodyptr = pNewBssInd;
1753 msgQ.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301754 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, msgQ.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001755 lim_sys_process_mmh_msg_api(pMac, &msgQ, ePROT);
1756} /*** end lim_send_sme_neighbor_bss_ind() ***/
1757
1758/** -----------------------------------------------------------------
1759 \brief lim_send_sme_addts_rsp() - sends SME ADDTS RSP
1760 \ This function sends a eWNI_SME_ADDTS_RSP to SME.
1761 \ SME only looks at rc and tspec field.
1762 \param pMac - global mac structure
1763 \param rspReqd - is SmeAddTsRsp required
1764 \param status - status code of SME_ADD_TS_RSP
1765 \return tspec
1766 \sa
1767 ----------------------------------------------------------------- */
1768void
1769lim_send_sme_addts_rsp(tpAniSirGlobal pMac, uint8_t rspReqd, uint32_t status,
1770 tpPESession psessionEntry, tSirMacTspecIE tspec,
1771 uint8_t smesessionId, uint16_t smetransactionId)
1772{
1773 tpSirAddtsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001774 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001775
1776 if (!rspReqd)
1777 return;
1778
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301779 rsp = qdf_mem_malloc(sizeof(tSirAddtsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001780 if (NULL == rsp) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301781 lim_log(pMac, LOGE, FL("AllocateMemory failed for ADDTS_RSP"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001782 return;
1783 }
1784
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001785 rsp->messageType = eWNI_SME_ADDTS_RSP;
1786 rsp->rc = status;
1787 rsp->rsp.status = (enum eSirMacStatusCodes)status;
1788 rsp->rsp.tspec = tspec;
1789 /* Update SME session Id and transcation Id */
1790 rsp->sessionId = smesessionId;
1791 rsp->transactionId = smetransactionId;
1792
1793 mmhMsg.type = eWNI_SME_ADDTS_RSP;
1794 mmhMsg.bodyptr = rsp;
1795 mmhMsg.bodyval = 0;
1796 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301797 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1798 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001799 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301800 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1801 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001802 }
1803#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1804 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_RSP_EVENT, psessionEntry, 0,
1805 0);
1806#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1807
1808 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1809 return;
1810}
1811
1812void
1813lim_send_sme_delts_rsp(tpAniSirGlobal pMac, tpSirDeltsReq delts, uint32_t status,
1814 tpPESession psessionEntry, uint8_t smesessionId,
1815 uint16_t smetransactionId)
1816{
1817 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001818 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001819
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301820 lim_log(pMac, LOGD, "SendSmeDeltsRsp (aid %d, tsid %d, up %d) status %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001821 delts->aid,
1822 delts->req.tsinfo.traffic.tsid,
1823 delts->req.tsinfo.traffic.userPrio, status);
1824 if (!delts->rspReqd)
1825 return;
1826
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301827 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001828 if (NULL == rsp) {
1829 /* Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301830 lim_log(pMac, LOGE, FL("AllocateMemory failed for DELTS_RSP"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001831 return;
1832 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001833
1834 if (psessionEntry != NULL) {
1835
1836 rsp->aid = delts->aid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301837 qdf_copy_macaddr(&rsp->macaddr, &delts->macaddr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301838 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) &delts->req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001839 sizeof(tSirDeltsReqInfo));
1840 }
1841
1842 rsp->messageType = eWNI_SME_DELTS_RSP;
1843 rsp->rc = status;
1844
1845 /* Update SME session Id and transcation Id */
1846 rsp->sessionId = smesessionId;
1847 rsp->transactionId = smetransactionId;
1848
1849 mmhMsg.type = eWNI_SME_DELTS_RSP;
1850 mmhMsg.bodyptr = rsp;
1851 mmhMsg.bodyval = 0;
1852 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301853 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1854 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001855 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301856 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1857 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001858 }
1859#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1860 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_RSP_EVENT, psessionEntry,
1861 (uint16_t) status, 0);
1862#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1863
1864 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1865}
1866
1867void
1868lim_send_sme_delts_ind(tpAniSirGlobal pMac, tpSirDeltsReqInfo delts, uint16_t aid,
1869 tpPESession psessionEntry)
1870{
1871 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001872 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001873
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301874 lim_log(pMac, LOGD, "SendSmeDeltsInd (aid %d, tsid %d, up %d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001875 aid, delts->tsinfo.traffic.tsid, delts->tsinfo.traffic.userPrio);
1876
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301877 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001878 if (NULL == rsp) {
1879 /* Log error */
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301880 lim_log(pMac, LOGE, FL("AllocateMemory failed for DELTS_IND"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001881 return;
1882 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001883
1884 rsp->messageType = eWNI_SME_DELTS_IND;
1885 rsp->rc = eSIR_SUCCESS;
1886 rsp->aid = aid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301887 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) delts, sizeof(*delts));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001888
1889 /* Update SME session Id and SME transaction Id */
1890
1891 rsp->sessionId = psessionEntry->smeSessionId;
1892 rsp->transactionId = psessionEntry->transactionId;
1893
1894 mmhMsg.type = eWNI_SME_DELTS_IND;
1895 mmhMsg.bodyptr = rsp;
1896 mmhMsg.bodyval = 0;
1897 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1898#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1899 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_IND_EVENT, psessionEntry, 0,
1900 0);
1901#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1902
1903 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1904}
1905
1906/**
1907 * lim_send_sme_pe_statistics_rsp()
1908 *
1909 ***FUNCTION:
1910 * This function is called to send 802.11 statistics response to HDD.
1911 * This function posts the result back to HDD. This is a response to
1912 * HDD's request for statistics.
1913 *
1914 ***PARAMS:
1915 *
1916 ***LOGIC:
1917 *
1918 ***ASSUMPTIONS:
1919 * NA
1920 *
1921 ***NOTE:
1922 * NA
1923 *
1924 * @param pMac Pointer to Global MAC structure
1925 * @param p80211Stats Statistics sent in response
1926 * @param resultCode TODO:
1927 *
1928 *
1929 * @return none
1930 */
1931
1932void
1933lim_send_sme_pe_statistics_rsp(tpAniSirGlobal pMac, uint16_t msgType, void *stats)
1934{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001935 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001936 uint8_t sessionId;
1937 tAniGetPEStatsRsp *pPeStats = (tAniGetPEStatsRsp *) stats;
1938 tpPESession pPeSessionEntry;
1939
1940 /* Get the Session Id based on Sta Id */
1941 pPeSessionEntry =
1942 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1943
1944 /* Fill the Session Id */
1945 if (NULL != pPeSessionEntry) {
1946 /* Fill the Session Id */
1947 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1948 }
1949
1950 pPeStats->msgType = eWNI_SME_GET_STATISTICS_RSP;
1951
1952 /* msgType should be WMA_GET_STATISTICS_RSP */
1953 mmhMsg.type = eWNI_SME_GET_STATISTICS_RSP;
1954
1955 mmhMsg.bodyptr = stats;
1956 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301957 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001958 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1959
1960 return;
1961
1962} /*** end lim_send_sme_pe_statistics_rsp() ***/
1963
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001964#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001965/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001966 * lim_send_sme_pe_ese_tsm_rsp() - send tsm response
1967 * @pMac: Pointer to global pMac structure
1968 * @pStats: Pointer to TSM Stats
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001969 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001970 * This function is called to send tsm stats response to HDD.
1971 * This function posts the result back to HDD. This is a response to
1972 * HDD's request to get tsm stats.
1973 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001974 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001975 */
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001976void lim_send_sme_pe_ese_tsm_rsp(tpAniSirGlobal pMac,
1977 tAniGetTsmStatsRsp *pStats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001978{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001979 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001980 uint8_t sessionId;
1981 tAniGetTsmStatsRsp *pPeStats = (tAniGetTsmStatsRsp *) pStats;
1982 tpPESession pPeSessionEntry = NULL;
1983
1984 /* Get the Session Id based on Sta Id */
1985 pPeSessionEntry =
1986 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1987
1988 /* Fill the Session Id */
1989 if (NULL != pPeSessionEntry) {
1990 /* Fill the Session Id */
1991 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1992 } else {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301993 lim_log(pMac, LOGE, FL("Session not found for the Sta id(%d)"),
1994 pPeStats->staId);
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05301995 qdf_mem_free(pPeStats->tsmStatsReq);
1996 qdf_mem_free(pPeStats);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001997 return;
1998 }
1999
2000 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
2001 pPeStats->tsmMetrics.RoamingCount
2002 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
2003 pPeStats->tsmMetrics.RoamingDly
2004 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
2005
2006 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
2007 mmhMsg.bodyptr = pStats;
2008 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302009 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002010 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2011
2012 return;
2013} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
2014
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002015#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002016
2017void
2018lim_send_sme_ibss_peer_ind(tpAniSirGlobal pMac,
2019 tSirMacAddr peerMacAddr,
2020 uint16_t staIndex,
2021 uint8_t ucastIdx,
2022 uint8_t bcastIdx,
2023 uint8_t *beacon,
2024 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
2025{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002026 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002027 tSmeIbssPeerInd *pNewPeerInd;
2028
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302029 pNewPeerInd = qdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002030 if (NULL == pNewPeerInd) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05302031 lim_log(pMac, LOGE, FL("Failed to allocate memory"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002032 return;
2033 }
2034
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302035 qdf_mem_copy((uint8_t *) pNewPeerInd->peer_addr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302036 peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002037 pNewPeerInd->staId = staIndex;
2038 pNewPeerInd->ucastSig = ucastIdx;
2039 pNewPeerInd->bcastSig = bcastIdx;
2040 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
2041 pNewPeerInd->mesgType = msgType;
2042 pNewPeerInd->sessionId = sessionId;
2043
2044 if (beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302045 qdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002046 sizeof(tSmeIbssPeerInd)), (void *)beacon,
2047 beaconLen);
2048 }
2049
2050 mmhMsg.type = msgType;
2051 mmhMsg.bodyptr = pNewPeerInd;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302052 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002053 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2054
2055}
2056
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07002057/**
2058 * lim_process_csa_wbw_ie() - Process CSA Wide BW IE
2059 * @mac_ctx: pointer to global adapter context
2060 * @csa_params: pointer to CSA parameters
2061 * @chnl_switch_info:pointer to channel switch parameters
2062 * @session_entry: session pointer
2063 *
2064 * Return: None
2065 */
2066static void lim_process_csa_wbw_ie(tpAniSirGlobal mac_ctx,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002067 struct csa_offload_params *csa_params,
2068 tLimWiderBWChannelSwitchInfo *chnl_switch_info,
2069 tpPESession session_entry)
2070{
Amar Singhal5cccafe2017-02-15 12:42:58 -08002071 struct ch_params ch_params = {0};
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002072 uint8_t ap_new_ch_width;
2073 bool new_ch_width_dfn = false;
2074 uint8_t center_freq_diff;
2075
2076 ap_new_ch_width = csa_params->new_ch_width + 1;
2077 if ((ap_new_ch_width == CH_WIDTH_80MHZ) &&
2078 csa_params->new_ch_freq_seg2) {
2079 new_ch_width_dfn = true;
2080 if (csa_params->new_ch_freq_seg2 >
2081 csa_params->new_ch_freq_seg1)
2082 center_freq_diff = csa_params->new_ch_freq_seg2 -
2083 csa_params->new_ch_freq_seg1;
2084 else
2085 center_freq_diff = csa_params->new_ch_freq_seg1 -
2086 csa_params->new_ch_freq_seg2;
2087 if (center_freq_diff == CENTER_FREQ_DIFF_160MHz)
2088 ap_new_ch_width = CH_WIDTH_160MHZ;
2089 else if (center_freq_diff > CENTER_FREQ_DIFF_80P80MHz)
2090 ap_new_ch_width = CH_WIDTH_80P80MHZ;
2091 else
2092 ap_new_ch_width = CH_WIDTH_80MHZ;
2093 }
2094 session_entry->gLimChannelSwitch.state =
2095 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2096 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
2097 !new_ch_width_dfn) {
2098 ch_params.ch_width = CH_WIDTH_160MHZ;
2099 cds_set_channel_params(csa_params->channel, 0,
2100 &ch_params);
2101 ap_new_ch_width = ch_params.ch_width;
2102 csa_params->new_ch_freq_seg1 = ch_params.center_freq_seg0;
2103 csa_params->new_ch_freq_seg2 = ch_params.center_freq_seg1;
2104 }
2105 chnl_switch_info->newChanWidth = ap_new_ch_width;
2106 chnl_switch_info->newCenterChanFreq0 = csa_params->new_ch_freq_seg1;
2107 chnl_switch_info->newCenterChanFreq1 = csa_params->new_ch_freq_seg2;
2108
2109 if (session_entry->ch_width == ap_new_ch_width)
2110 goto prnt_log;
2111
2112 if (session_entry->ch_width == CH_WIDTH_80MHZ) {
2113 chnl_switch_info->newChanWidth = CH_WIDTH_80MHZ;
2114 chnl_switch_info->newCenterChanFreq1 = 0;
2115 } else {
2116 session_entry->ch_width = ap_new_ch_width;
2117 chnl_switch_info->newChanWidth = ap_new_ch_width;
2118 }
2119prnt_log:
2120 lim_log(mac_ctx, LOG1,
2121 FL("new channel: %d new_ch_width:%d seg0:%d seg1:%d"),
2122 csa_params->channel,
2123 chnl_switch_info->newChanWidth,
2124 chnl_switch_info->newCenterChanFreq0,
2125 chnl_switch_info->newCenterChanFreq1);
2126}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002127/**
2128 * lim_handle_csa_offload_msg() - Handle CSA offload message
2129 * @mac_ctx: pointer to global adapter context
2130 * @msg: Message pointer.
2131 *
2132 * Return: None
2133 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08002134void lim_handle_csa_offload_msg(tpAniSirGlobal mac_ctx,
2135 struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002136{
2137 tpPESession session_entry;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002138 struct scheduler_msg mmh_msg = {0};
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302139 struct csa_offload_params *csa_params =
2140 (struct csa_offload_params *) (msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002141 tpSmeCsaOffloadInd csa_offload_ind;
2142 tpDphHashNode sta_ds = NULL;
2143 uint8_t session_id;
2144 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302145 uint16_t chan_space = 0;
Amar Singhal5cccafe2017-02-15 12:42:58 -08002146 struct ch_params ch_params;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302147
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002148 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002149 tLimChannelSwitchInfo *lim_ch_switch = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002150
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302151 lim_log(mac_ctx, LOG1, FL("handle csa offload msg"));
2152
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002153 if (!csa_params) {
2154 lim_log(mac_ctx, LOGE, FL("limMsgQ body ptr is NULL"));
2155 return;
2156 }
2157
2158 session_entry =
2159 pe_find_session_by_bssid(mac_ctx,
2160 csa_params->bssId, &session_id);
2161 if (!session_entry) {
2162 lim_log(mac_ctx, LOGE,
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302163 FL("Session does not exists for %pM"),
2164 csa_params->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002165 goto err;
2166 }
2167
2168 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
2169 &session_entry->dph.dphHashTable);
2170
2171 if (!sta_ds) {
2172 lim_log(mac_ctx, LOGE,
2173 FL("sta_ds does not exist"));
2174 goto err;
2175 }
2176
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002177 if (!LIM_IS_STA_ROLE(session_entry)) {
2178 lim_log(mac_ctx, LOG1, FL("Invalid role to handle CSA"));
2179 goto err;
2180 }
Masti, Narayanraddi1c630442015-11-02 12:03:50 +05302181
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002182 /*
2183 * on receiving channel switch announcement from AP, delete all
2184 * TDLS peers before leaving BSS and proceed for channel switch
2185 */
2186 lim_delete_tdls_peers(mac_ctx, session_entry);
Gupta, Kapil121bf212015-11-25 19:21:29 +05302187
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002188 lim_ch_switch = &session_entry->gLimChannelSwitch;
2189 session_entry->gLimChannelSwitch.switchMode =
2190 csa_params->switch_mode;
2191 /* timer already started by firmware, switch immediately */
2192 session_entry->gLimChannelSwitch.switchCount = 0;
2193 session_entry->gLimChannelSwitch.primaryChannel =
2194 csa_params->channel;
2195 session_entry->gLimChannelSwitch.state =
2196 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2197 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
2198 lim_ch_switch->sec_ch_offset =
2199 session_entry->htSecondaryChannelOffset;
2200 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
2201 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
2202 chnl_switch_info =
2203 &session_entry->gLimWiderBWChannelSwitch;
2204
2205 lim_log(mac_ctx, LOG1,
2206 FL("vht:%d ht:%d flag:%x chan:%d"),
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302207 session_entry->vhtCapability,
2208 session_entry->htSupportedChannelWidthSet,
2209 csa_params->ies_present_flag,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002210 csa_params->channel);
2211 lim_log(mac_ctx, LOG1,
2212 FL("seg1:%d seg2:%d width:%d country:%s class:%d"),
2213 csa_params->new_ch_freq_seg1,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302214 csa_params->new_ch_freq_seg2,
2215 csa_params->new_ch_width,
2216 mac_ctx->scan.countryCodeCurrent,
2217 csa_params->new_op_class);
2218
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002219 if (session_entry->vhtCapability &&
2220 session_entry->htSupportedChannelWidthSet) {
2221 if (csa_params->ies_present_flag & lim_wbw_ie_present) {
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07002222 lim_process_csa_wbw_ie(mac_ctx, csa_params,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002223 chnl_switch_info, session_entry);
2224 lim_ch_switch->sec_ch_offset =
2225 csa_params->sec_chan_offset;
2226 } else if (csa_params->ies_present_flag
2227 & lim_xcsa_ie_present) {
2228 chan_space =
2229 cds_reg_dmn_get_chanwidth_from_opclass(
2230 mac_ctx->scan.countryCodeCurrent,
2231 csa_params->channel,
2232 csa_params->new_op_class);
2233 session_entry->gLimChannelSwitch.state =
2234 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2235
2236 if (chan_space == 80) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002237 chnl_switch_info->newChanWidth =
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002238 CH_WIDTH_80MHZ;
2239 } else if (chan_space == 40) {
2240 chnl_switch_info->newChanWidth =
2241 CH_WIDTH_40MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002242 } else {
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002243 chnl_switch_info->newChanWidth =
2244 CH_WIDTH_20MHZ;
2245 lim_ch_switch->state =
2246 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2247 }
2248
2249 ch_params.ch_width =
2250 chnl_switch_info->newChanWidth;
2251 cds_set_channel_params(csa_params->channel,
2252 0, &ch_params);
2253 chnl_switch_info->newCenterChanFreq0 =
2254 ch_params.center_freq_seg0;
2255 /*
2256 * This is not applicable for 20/40/80 MHz.
2257 * Only used when we support 80+80 MHz operation.
2258 * In case of 80+80 MHz, this parameter indicates
2259 * center channel frequency index of 80 MHz
2260 * channel offrequency segment 1.
2261 */
2262 chnl_switch_info->newCenterChanFreq1 =
2263 ch_params.center_freq_seg1;
2264 lim_ch_switch->sec_ch_offset =
2265 ch_params.sec_ch_offset;
2266
2267 }
2268 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
2269 chnl_switch_info->newCenterChanFreq0;
2270 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
2271 chnl_switch_info->newCenterChanFreq1;
2272 session_entry->gLimChannelSwitch.ch_width =
2273 chnl_switch_info->newChanWidth;
2274
2275 } else if (session_entry->htSupportedChannelWidthSet) {
2276 if (csa_params->ies_present_flag
2277 & lim_xcsa_ie_present) {
2278 chan_space =
2279 cds_reg_dmn_get_chanwidth_from_opclass(
2280 mac_ctx->scan.countryCodeCurrent,
2281 csa_params->channel,
2282 csa_params->new_op_class);
2283 lim_ch_switch->state =
2284 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2285 if (chan_space == 40) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002286 lim_ch_switch->ch_width =
2287 CH_WIDTH_40MHZ;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002288 chnl_switch_info->newChanWidth =
2289 CH_WIDTH_40MHZ;
2290 ch_params.ch_width =
2291 chnl_switch_info->newChanWidth;
2292 cds_set_channel_params(
2293 csa_params->channel,
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07002294 0, &ch_params);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002295 lim_ch_switch->ch_center_freq_seg0 =
2296 ch_params.center_freq_seg0;
2297 lim_ch_switch->sec_ch_offset =
2298 ch_params.sec_ch_offset;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002299 } else {
2300 lim_ch_switch->ch_width =
2301 CH_WIDTH_20MHZ;
2302 chnl_switch_info->newChanWidth =
2303 CH_WIDTH_40MHZ;
2304 lim_ch_switch->state =
2305 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2306 lim_ch_switch->sec_ch_offset =
2307 PHY_SINGLE_CHANNEL_CENTERED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002308 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002309 } else {
2310 lim_ch_switch->ch_width =
2311 CH_WIDTH_40MHZ;
2312 lim_ch_switch->state =
2313 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2314 ch_params.ch_width = CH_WIDTH_40MHZ;
2315 cds_set_channel_params(csa_params->channel,
2316 0, &ch_params);
2317 lim_ch_switch->ch_center_freq_seg0 =
2318 ch_params.center_freq_seg0;
2319 lim_ch_switch->sec_ch_offset =
2320 ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002321 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002322
2323 }
2324 lim_log(mac_ctx, LOG1, FL("new ch width = %d space:%d"),
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302325 session_entry->gLimChannelSwitch.ch_width, chan_space);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002326
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002327 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
2328 csa_offload_ind = qdf_mem_malloc(sizeof(tSmeCsaOffloadInd));
2329 if (NULL == csa_offload_ind) {
2330 lim_log(mac_ctx, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002331 FL("memalloc fail eWNI_SME_CSA_OFFLOAD_EVENT"));
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002332 goto err;
2333 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002334
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002335 csa_offload_ind->mesgType = eWNI_SME_CSA_OFFLOAD_EVENT;
2336 csa_offload_ind->mesgLen = sizeof(tSmeCsaOffloadInd);
2337 qdf_mem_copy(csa_offload_ind->bssid.bytes, session_entry->bssId,
2338 QDF_MAC_ADDR_SIZE);
2339 mmh_msg.type = eWNI_SME_CSA_OFFLOAD_EVENT;
2340 mmh_msg.bodyptr = csa_offload_ind;
2341 mmh_msg.bodyval = 0;
2342 lim_log(mac_ctx, LOG1,
Srinivas Girigowdac9148f72015-11-25 12:42:32 -08002343 FL("Sending eWNI_SME_CSA_OFFLOAD_EVENT to SME."));
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002344 MTRACE(mac_trace_msg_tx
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002345 (mac_ctx, session_entry->peSessionId, mmh_msg.type));
2346#ifdef FEATURE_WLAN_DIAG_SUPPORT
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002347 lim_diag_event_report(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002348 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
2349 eSIR_SUCCESS, eSIR_SUCCESS);
2350#endif
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002351 lim_sys_process_mmh_msg_api(mac_ctx, &mmh_msg, ePROT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002352
2353err:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302354 qdf_mem_free(csa_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002355}
2356
2357/*--------------------------------------------------------------------------
2358 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
2359
2360 \param pMac - pointer to global adapter context
2361 \param sessionId - Message pointer.
2362
2363 \sa
2364 --------------------------------------------------------------------------*/
2365
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002366void lim_handle_delete_bss_rsp(tpAniSirGlobal pMac, struct scheduler_msg *MsgQ)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002367{
2368 tpPESession psessionEntry;
2369 tpDeleteBssParams pDelBss = (tpDeleteBssParams) (MsgQ->bodyptr);
2370
2371 psessionEntry =
2372 pe_find_session_by_session_id(pMac, pDelBss->sessionId);
2373 if (psessionEntry == NULL) {
2374 lim_log(pMac, LOGE,
2375 FL("Session Does not exist for given sessionID %d"),
2376 pDelBss->sessionId);
Naveen Rawat0c81edc2016-06-08 10:08:30 -07002377 qdf_mem_free(MsgQ->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002378 return;
2379 }
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002380 /*
2381 * During DEL BSS handling, the PE Session will be deleted, but it is
2382 * better to clear this flag if the session is hanging around due
2383 * to some error conditions so that the next DEL_BSS request does
2384 * not take the HO_FAIL path
2385 */
2386 psessionEntry->process_ho_fail = false;
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002387 if (LIM_IS_IBSS_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002388 lim_ibss_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002389 else if (LIM_IS_UNKNOWN_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002390 lim_process_sme_del_bss_rsp(pMac, MsgQ->bodyval, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002391 else if (LIM_IS_NDI_ROLE(psessionEntry))
2392 lim_ndi_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002393 else
2394 lim_process_mlm_del_bss_rsp(pMac, MsgQ, psessionEntry);
2395
2396}
2397
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002398/** -----------------------------------------------------------------
2399 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
2400 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
2401 \ SME only looks at rc and tspec field.
2402 \param pMac - global mac structure
2403 \param rspReqd - is SmeAddTsRsp required
2404 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
2405 \return tspec
2406 \sa
2407 ----------------------------------------------------------------- */
2408void
2409lim_send_sme_aggr_qos_rsp(tpAniSirGlobal pMac, tpSirAggrQosRsp aggrQosRsp,
2410 uint8_t smesessionId)
2411{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002412 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002413
2414 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
2415 mmhMsg.bodyptr = aggrQosRsp;
2416 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302417 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2418 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002419 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2420
2421 return;
2422}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002423
2424void lim_send_sme_max_assoc_exceeded_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
2425 uint8_t smesessionId)
2426{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002427 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002428 tSmeMaxAssocInd *pSmeMaxAssocInd;
2429
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302430 pSmeMaxAssocInd = qdf_mem_malloc(sizeof(tSmeMaxAssocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002431 if (NULL == pSmeMaxAssocInd) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05302432 lim_log(pMac, LOGE, FL("Failed to allocate memory"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002433 return;
2434 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302435 qdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peer_mac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302436 (uint8_t *) peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002437 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
2438 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
2439 pSmeMaxAssocInd->sessionId = smesessionId;
2440 mmhMsg.type = pSmeMaxAssocInd->mesgType;
2441 mmhMsg.bodyptr = pSmeMaxAssocInd;
2442 PELOG1(lim_log(pMac, LOG1, FL("msgType %s peerMacAddr " MAC_ADDRESS_STR
2443 " sme session id %d"),
2444 "eWNI_SME_MAX_ASSOC_EXCEEDED",
2445 MAC_ADDR_ARRAY(peerMacAddr));
2446 )
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302447 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2448 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002449 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2450
2451 return;
2452}
2453
2454/** -----------------------------------------------------------------
2455 \brief lim_send_sme_dfs_event_notify() - sends
2456 eWNI_SME_DFS_RADAR_FOUND
2457 After receiving WMI_PHYERR_EVENTID indication frame from FW, this
2458 function sends a eWNI_SME_DFS_RADAR_FOUND to SME to notify
2459 that a RADAR is found on current operating channel and SAP-
2460 has to move to a new channel.
2461 \param pMac - global mac structure
2462 \param msgType - message type received from lower layer
2463 \param event - event data received from lower layer
2464 \return none
2465 \sa
2466 ----------------------------------------------------------------- */
2467void
2468lim_send_sme_dfs_event_notify(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2469{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002470 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002471 mmhMsg.type = eWNI_SME_DFS_RADAR_FOUND;
2472 mmhMsg.bodyptr = event;
2473 mmhMsg.bodyval = 0;
2474 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2475 return;
2476}
2477
2478/*--------------------------------------------------------------------------
2479 \brief lim_send_dfs_chan_sw_ie_update()
2480 This timer handler updates the channel switch IE in beacon template
2481
2482 \param pMac - pointer to global adapter context
2483 \return - channel to scan from valid session else zero.
2484 \sa
2485 --------------------------------------------------------------------------*/
2486static void
2487lim_send_dfs_chan_sw_ie_update(tpAniSirGlobal pMac, tpPESession psessionEntry)
2488{
2489
2490 /* Update the beacon template and send to FW */
2491 if (sch_set_fixed_beacon_fields(pMac, psessionEntry) != eSIR_SUCCESS) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05302492 lim_log(pMac, LOGE, FL("Unable to set CSA IE in beacon"));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002493 return;
2494 }
2495
2496 /* Send update beacon template message */
2497 lim_send_beacon_ind(pMac, psessionEntry);
2498 PELOG1(lim_log(pMac, LOG1,
2499 FL(" Updated CSA IE, IE COUNT = %d"),
2500 psessionEntry->gLimChannelSwitch.switchCount);
2501 )
2502
2503 return;
2504}
2505
2506/** -----------------------------------------------------------------
2507 \brief lim_send_sme_ap_channel_switch_resp() - sends
2508 eWNI_SME_CHANNEL_CHANGE_RSP
2509 After receiving WMA_SWITCH_CHANNEL_RSP indication this
2510 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
2511 that the Channel change has been done to the specified target
2512 channel in the Channel change request
2513 \param pMac - global mac structure
2514 \param psessionEntry - session info
2515 \param pChnlParams - Channel switch params
2516 --------------------------------------------------------------------*/
2517void
2518lim_send_sme_ap_channel_switch_resp(tpAniSirGlobal pMac,
2519 tpPESession psessionEntry,
2520 tpSwitchChannelParams pChnlParams)
2521{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002522 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002523 tpSwitchChannelParams pSmeSwithChnlParams;
2524 uint8_t channelId;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002525 bool is_ch_dfs = false;
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08002526 enum phy_ch_width ch_width;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002527 uint8_t ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002528
2529 pSmeSwithChnlParams = (tSwitchChannelParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302530 qdf_mem_malloc(sizeof(tSwitchChannelParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002531 if (NULL == pSmeSwithChnlParams) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05302532 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002533 FL("AllocateMemory failed for pSmeSwithChnlParams\n"));
2534 return;
2535 }
2536
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302537 qdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002538 sizeof(tSwitchChannelParams));
2539
2540 channelId = pSmeSwithChnlParams->channelNumber;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002541 ch_width = pSmeSwithChnlParams->ch_width;
2542 ch_center_freq_seg1 = pSmeSwithChnlParams->ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002543
2544 /*
2545 * Pass the sme sessionID to SME instead
2546 * PE session ID.
2547 */
2548 pSmeSwithChnlParams->peSessionId = psessionEntry->smeSessionId;
2549
2550 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
2551 mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
2552 mmhMsg.bodyval = 0;
2553 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2554
2555 /*
2556 * We should start beacon transmission only if the new
2557 * channel after channel change is Non-DFS. For a DFS
2558 * channel, PE will receive an explicit request from
2559 * upper layers to start the beacon transmission .
2560 */
2561
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002562 if (ch_width == CH_WIDTH_160MHZ) {
2563 is_ch_dfs = true;
2564 } else if (ch_width == CH_WIDTH_80P80MHZ) {
2565 if (cds_get_channel_state(channelId) == CHANNEL_STATE_DFS ||
2566 cds_get_channel_state(ch_center_freq_seg1 -
2567 SIR_80MHZ_START_CENTER_CH_DIFF) ==
2568 CHANNEL_STATE_DFS)
2569 is_ch_dfs = true;
2570 } else {
2571 if (cds_get_channel_state(channelId) == CHANNEL_STATE_DFS)
2572 is_ch_dfs = true;
2573 }
2574
2575 if (!is_ch_dfs) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002576 if (channelId == psessionEntry->currentOperChannel) {
2577 lim_apply_configuration(pMac, psessionEntry);
2578 lim_send_beacon_ind(pMac, psessionEntry);
2579 } else {
2580 PELOG1(lim_log(pMac, LOG1,
2581 FL
2582 ("Failed to Transmit Beacons on channel = %d"
2583 "after AP channel change response"),
2584 psessionEntry->bcnLen);
2585 )
2586 }
2587 }
2588 return;
2589}
2590
2591/** -----------------------------------------------------------------
2592 \brief lim_process_beacon_tx_success_ind() - This function is used
2593 explicitely to handle successful beacon transmission indication
2594 from the FW. This is a generic event generated by the FW afer the
2595 first beacon is sent out after the beacon template update by the
2596 host
2597 \param pMac - global mac structure
2598 \param psessionEntry - session info
2599 \return none
2600 \sa
2601 ----------------------------------------------------------------- */
2602void
2603lim_process_beacon_tx_success_ind(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2604{
2605 /* Currently, this event is used only for DFS channel switch announcement
2606 * IE update in the template. If required to be used for other IE updates
2607 * add appropriate code by introducing a state variable
2608 */
2609 tpPESession psessionEntry;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002610 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002611 tSirSmeCSAIeTxCompleteRsp *pChanSwTxResponse;
2612 struct sir_beacon_tx_complete_rsp *beacon_tx_comp_rsp_ptr;
2613 uint8_t length = sizeof(tSirSmeCSAIeTxCompleteRsp);
2614 tpSirFirstBeaconTxCompleteInd pBcnTxInd =
2615 (tSirFirstBeaconTxCompleteInd *) event;
2616
2617 psessionEntry = pe_find_session_by_bss_idx(pMac, pBcnTxInd->bssIdx);
2618 if (psessionEntry == NULL) {
2619 lim_log(pMac, LOGE,
2620 FL("Session Does not exist for given sessionID"));
2621 return;
2622 }
2623
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302624 lim_log(pMac, LOG1, FL("role:%d swIe:%d opIe:%d"),
2625 GET_LIM_SYSTEM_ROLE(psessionEntry),
2626 psessionEntry->dfsIncludeChanSwIe,
2627 psessionEntry->gLimOperatingMode.present);
2628
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002629 if (LIM_IS_AP_ROLE(psessionEntry) &&
2630 true == psessionEntry->dfsIncludeChanSwIe) {
2631 /* Send only 5 beacons with CSA IE Set in when a radar is detected */
2632 if (psessionEntry->gLimChannelSwitch.switchCount > 0) {
2633 /*
2634 * Send the next beacon with updated CSA IE count
2635 */
2636 lim_send_dfs_chan_sw_ie_update(pMac, psessionEntry);
2637 /* Decrement the IE count */
2638 psessionEntry->gLimChannelSwitch.switchCount--;
2639 } else {
2640 /* Done with CSA IE update, send response back to SME */
2641 psessionEntry->gLimChannelSwitch.switchCount = 0;
2642 if (pMac->sap.SapDfsInfo.disable_dfs_ch_switch == false)
2643 psessionEntry->gLimChannelSwitch.switchMode = 0;
2644 psessionEntry->dfsIncludeChanSwIe = false;
2645 psessionEntry->dfsIncludeChanWrapperIe = false;
2646
2647 pChanSwTxResponse = (tSirSmeCSAIeTxCompleteRsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302648 qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002649
2650 if (NULL == pChanSwTxResponse) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05302651 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002652 FL
2653 ("AllocateMemory failed for tSirSmeCSAIeTxCompleteRsp"));
2654 return;
2655 }
2656
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002657 pChanSwTxResponse->sessionId =
2658 psessionEntry->smeSessionId;
2659 pChanSwTxResponse->chanSwIeTxStatus =
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302660 QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002661
2662 mmhMsg.type = eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND;
2663 mmhMsg.bodyptr = pChanSwTxResponse;
2664 mmhMsg.bodyval = 0;
2665 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2666 }
2667 }
2668
2669 if (LIM_IS_AP_ROLE(psessionEntry) &&
2670 psessionEntry->gLimOperatingMode.present) {
2671 /* Done with nss update, send response back to SME */
2672 psessionEntry->gLimOperatingMode.present = 0;
2673 beacon_tx_comp_rsp_ptr = (struct sir_beacon_tx_complete_rsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302674 qdf_mem_malloc(sizeof(*beacon_tx_comp_rsp_ptr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002675 if (NULL == beacon_tx_comp_rsp_ptr) {
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05302676 lim_log(pMac, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002677 FL
2678 ("AllocateMemory failed for beacon_tx_comp_rsp_ptr"));
2679 return;
2680 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002681 beacon_tx_comp_rsp_ptr->session_id =
2682 psessionEntry->smeSessionId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302683 beacon_tx_comp_rsp_ptr->tx_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002684 mmhMsg.type = eWNI_SME_NSS_UPDATE_RSP;
2685 mmhMsg.bodyptr = beacon_tx_comp_rsp_ptr;
2686 mmhMsg.bodyval = 0;
2687 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2688 }
2689 return;
2690}