blob: 146bfb1ccce48f461f783b86211650762111c7dd [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
63static void lim_handle_join_rsp_status(tpAniSirGlobal mac_ctx,
64 tpPESession session_entry, tSirResultCodes result_code,
65 tpSirSmeJoinRsp sme_join_rsp);
66
67/**
68 * lim_send_sme_rsp() - Send Response to upper layers
69 * @mac_ctx: Pointer to Global MAC structure
70 * @msg_type: Indicates message type
71 * @result_code: Indicates the result of previously issued
72 * eWNI_SME_msg_type_REQ message
73 *
74 * This function is called by lim_process_sme_req_messages() to send
75 * eWNI_SME_START_RSP, eWNI_SME_STOP_BSS_RSP
76 * or eWNI_SME_SWITCH_CHL_RSP messages to applications above MAC
77 * Software.
78 *
79 * Return: None
80 */
81
82void
83lim_send_sme_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
84 tSirResultCodes result_code, uint8_t sme_session_id,
85 uint16_t sme_transaction_id)
86{
Rajeev Kumar416b73f2017-01-21 16:45:21 -080087 struct scheduler_msg msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080088 tSirSmeRsp *sme_rsp;
89
90 lim_log(mac_ctx, LOG1, FL("Sending message %s with reasonCode %s"),
91 lim_msg_str(msg_type), lim_result_code_str(result_code));
92
Anurag Chouhan600c3a02016-03-01 10:33:54 +053093 sme_rsp = qdf_mem_malloc(sizeof(tSirSmeRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080094 if (NULL == sme_rsp) {
95 /* Buffer not available. Log error */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +053096 QDF_TRACE(QDF_MODULE_ID_PE, LOGP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080097 FL("call to AllocateMemory failed for eWNI_SME_*_RSP"));
98 return;
99 }
100
101 sme_rsp->messageType = msg_type;
102 sme_rsp->length = sizeof(tSirSmeRsp);
103 sme_rsp->statusCode = result_code;
104
105 sme_rsp->sessionId = sme_session_id;
106 sme_rsp->transactionId = sme_transaction_id;
107
108 msg.type = msg_type;
109 msg.bodyptr = sme_rsp;
110 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530111 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG,
112 sme_session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800113
114#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
115 switch (msg_type) {
116 case eWNI_SME_STOP_BSS_RSP:
117 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_STOP_BSS_RSP_EVENT,
118 NULL, (uint16_t) result_code, 0);
119 break;
120 }
121#endif /* FEATURE_WLAN_DIAG_SUPPORT */
122 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
123}
124
125
126
127/**
128 * lim_send_sme_roc_rsp() - Send Response to SME
129 * @mac_ctx: Pointer to Global MAC structure
130 * @status: Resume link status
131 * @result_code: Result of the ROC request
132 * @sme_session_id: SME sesson Id
133 * @scan_id: Scan Identifier
134 *
135 * This function is called to send ROC rsp
136 * message to SME.
137 *
138 * Return: None
139 */
140void
141lim_send_sme_roc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
142 tSirResultCodes result_code, uint8_t sme_session_id,
143 uint32_t scan_id)
144{
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800145 struct scheduler_msg msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800146 struct sir_roc_rsp *sme_rsp;
147
148 lim_log(mac_ctx, LOG1,
149 FL("Sending message %s with reasonCode %s scanId %d"),
150 lim_msg_str(msg_type), lim_result_code_str(result_code),
151 scan_id);
152
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530153 sme_rsp = qdf_mem_malloc(sizeof(struct sir_roc_rsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800154 if (NULL == sme_rsp) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530155 QDF_TRACE(QDF_MODULE_ID_PE, LOGP,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800156 FL("call to AllocateMemory failed for eWNI_SME_*_RSP"));
157 return;
158 }
159
160 sme_rsp->message_type = msg_type;
161 sme_rsp->length = sizeof(struct sir_roc_rsp);
162 sme_rsp->status = result_code;
163
164 sme_rsp->session_id = sme_session_id;
165 sme_rsp->scan_id = scan_id;
166
167 msg.type = msg_type;
168 msg.bodyptr = sme_rsp;
169 msg.bodyval = 0;
170 MTRACE(mac_trace_msg_tx(mac_ctx, sme_session_id, msg.type));
171 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
172}
173
174
175/**
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530176 * lim_get_max_rate_flags() - Get rate flags
177 * @mac_ctx: Pointer to global MAC structure
178 * @sta_ds: Pointer to station ds structure
179 *
180 * This function is called to get the rate flags for a connection
181 * from the station ds structure depending on the ht and the vht
182 * channel width supported.
183 *
184 * Return: Returns the populated rate_flags
185 */
186uint32_t lim_get_max_rate_flags(tpAniSirGlobal mac_ctx, tpDphHashNode sta_ds)
187{
188 uint32_t rate_flags = 0;
189
190 if (sta_ds == NULL) {
191 lim_log(mac_ctx, LOGE, FL("sta_ds is NULL"));
192 return rate_flags;
193 }
194
195 if (!sta_ds->mlmStaContext.htCapability &&
196 !sta_ds->mlmStaContext.vhtCapability) {
197 rate_flags |= eHAL_TX_RATE_LEGACY;
198 } else {
199 if (sta_ds->mlmStaContext.vhtCapability) {
200 if (WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ ==
201 sta_ds->vhtSupportedChannelWidthSet) {
202 rate_flags |= eHAL_TX_RATE_VHT80;
203 } else if (WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ ==
204 sta_ds->vhtSupportedChannelWidthSet) {
205 if (sta_ds->htSupportedChannelWidthSet)
206 rate_flags |= eHAL_TX_RATE_VHT40;
207 else
208 rate_flags |= eHAL_TX_RATE_VHT20;
209 }
210 } else if (sta_ds->mlmStaContext.htCapability) {
211 if (sta_ds->htSupportedChannelWidthSet)
212 rate_flags |= eHAL_TX_RATE_HT40;
213 else
214 rate_flags |= eHAL_TX_RATE_HT20;
215 }
216 }
217
218 if (sta_ds->htShortGI20Mhz || sta_ds->htShortGI40Mhz)
219 rate_flags |= eHAL_TX_RATE_SGI;
220
221 return rate_flags;
222}
223
224/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800225 * lim_send_sme_join_reassoc_rsp_after_resume() - Send Response to SME
226 * @mac_ctx Pointer to Global MAC structure
227 * @status Resume link status
228 * @ctx context passed while calling resmune link.
229 * (join response to be sent)
230 *
231 * This function is called to send Join/Reassoc rsp
232 * message to SME after the resume link.
233 *
234 * Return: None
235 */
236static void lim_send_sme_join_reassoc_rsp_after_resume(tpAniSirGlobal mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530237 QDF_STATUS status, uint32_t *ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800238{
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800239 struct scheduler_msg msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800240 tpSirSmeJoinRsp sme_join_rsp = (tpSirSmeJoinRsp) ctx;
241
242 msg.type = sme_join_rsp->messageType;
243 msg.bodyptr = sme_join_rsp;
244 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530245 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, NO_SESSION, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800246 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
247}
248
249/**
250 * lim_handle_join_rsp_status() - Handle the response.
251 * @mac_ctx: Pointer to Global MAC structure
252 * @session_entry: PE Session Info
253 * @result_code: Indicates the result of previously issued
254 * eWNI_SME_msgType_REQ message
255 * @sme_join_rsp The received response.
256 *
257 * This function will handle both the success and failure status
258 * of the received response.
259 *
260 * Return: None
261 */
262static void lim_handle_join_rsp_status(tpAniSirGlobal mac_ctx,
263 tpPESession session_entry, tSirResultCodes result_code,
264 tpSirSmeJoinRsp sme_join_rsp)
265{
266#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
267 tSirSmeHTProfile *ht_profile;
268#endif
269 if (result_code == eSIR_SME_SUCCESS) {
270 if (session_entry->beacon != NULL) {
271 sme_join_rsp->beaconLength = session_entry->bcnLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530272 qdf_mem_copy(sme_join_rsp->frames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800273 session_entry->beacon,
274 sme_join_rsp->beaconLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530275 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800276 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530277 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800278 lim_log(mac_ctx, LOG1, FL("Beacon=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530279 sme_join_rsp->beaconLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800280 }
281 if (session_entry->assocReq != NULL) {
282 sme_join_rsp->assocReqLength =
283 session_entry->assocReqLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530284 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530285 sme_join_rsp->beaconLength,
286 session_entry->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800287 sme_join_rsp->assocReqLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530288 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800289 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530290 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800291 lim_log(mac_ctx,
292 LOG1, FL("AssocReq=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530293 sme_join_rsp->assocReqLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800294 }
295 if (session_entry->assocRsp != NULL) {
296 sme_join_rsp->assocRspLength =
297 session_entry->assocRspLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530298 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530299 sme_join_rsp->beaconLength +
300 sme_join_rsp->assocReqLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800301 session_entry->assocRsp,
302 sme_join_rsp->assocRspLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530303 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800304 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530305 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800306 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800307 if (session_entry->ricData != NULL) {
308 sme_join_rsp->parsedRicRspLen =
309 session_entry->RICDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530310 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530311 sme_join_rsp->beaconLength +
312 sme_join_rsp->assocReqLength +
313 sme_join_rsp->assocRspLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800314 session_entry->ricData,
315 sme_join_rsp->parsedRicRspLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530316 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800317 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530318 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800319 lim_log(mac_ctx, LOG1, FL("RicLength=%d"),
320 sme_join_rsp->parsedRicRspLen);
321 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800322#ifdef FEATURE_WLAN_ESE
323 if (session_entry->tspecIes != NULL) {
324 sme_join_rsp->tspecIeLen =
325 session_entry->tspecLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530326 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530327 sme_join_rsp->beaconLength +
328 sme_join_rsp->assocReqLength +
329 sme_join_rsp->assocRspLength +
330 sme_join_rsp->parsedRicRspLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800331 session_entry->tspecIes,
332 sme_join_rsp->tspecIeLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530333 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800334 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530335 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800336 lim_log(mac_ctx, LOG1, FL("ESE-TspecLen=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530337 sme_join_rsp->tspecIeLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800338 }
339#endif
340 sme_join_rsp->aid = session_entry->limAID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800341 lim_log(mac_ctx, LOG1, FL("AssocRsp=%d"),
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530342 sme_join_rsp->assocRspLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800343 sme_join_rsp->vht_channel_width =
344 session_entry->ch_width;
345#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
346 if (session_entry->cc_switch_mode !=
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530347 QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800348 ht_profile = &sme_join_rsp->HTProfile;
349 ht_profile->htSupportedChannelWidthSet =
350 session_entry->htSupportedChannelWidthSet;
351 ht_profile->htRecommendedTxWidthSet =
352 session_entry->htRecommendedTxWidthSet;
353 ht_profile->htSecondaryChannelOffset =
354 session_entry->htSecondaryChannelOffset;
355 ht_profile->dot11mode = session_entry->dot11mode;
356 ht_profile->htCapability = session_entry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800357 ht_profile->vhtCapability =
358 session_entry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800359 ht_profile->apCenterChan = session_entry->ch_center_freq_seg0;
360 ht_profile->apChanWidth = session_entry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800361 }
362#endif
363 } else {
364 if (session_entry->beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530365 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800366 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530367 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800368 }
369 if (session_entry->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530370 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800371 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530372 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800373 }
374 if (session_entry->assocRsp != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530375 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800376 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530377 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800378 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800379 if (session_entry->ricData != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530380 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800381 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530382 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800383 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800384#ifdef FEATURE_WLAN_ESE
385 if (session_entry->tspecIes != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530386 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800387 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530388 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800389 }
390#endif
391 }
392}
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530393
394/**
395 * lim_add_bss_info() - copy data from session entry to join rsp
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530396 * @sta_ds: Station dph entry
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530397 * @sme_join_rsp: Join response buffer to be filled up
398 *
399 * Return: None
400 */
Jeff Johnson6db011e2016-10-07 07:31:39 -0700401static void lim_add_bss_info(tpDphHashNode sta_ds, tpSirSmeJoinRsp sme_join_rsp)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530402{
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530403 struct parsed_ies *parsed_ies = &sta_ds->parsed_ies;
404
405 if (parsed_ies->hs20vendor_ie.present)
406 sme_join_rsp->hs20vendor_ie = parsed_ies->hs20vendor_ie;
407 if (parsed_ies->vht_caps.present)
408 sme_join_rsp->vht_caps = parsed_ies->vht_caps;
409 if (parsed_ies->ht_caps.present)
410 sme_join_rsp->ht_caps = parsed_ies->ht_caps;
411 if (parsed_ies->ht_operation.present)
412 sme_join_rsp->ht_operation = parsed_ies->ht_operation;
413 if (parsed_ies->vht_operation.present)
414 sme_join_rsp->vht_operation = parsed_ies->vht_operation;
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530415}
416
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800417/**
418 * lim_send_sme_join_reassoc_rsp() - Send Response to Upper Layers
419 * @mac_ctx: Pointer to Global MAC structure
420 * @msg_type: Indicates message type
421 * @result_code: Indicates the result of previously issued
422 * eWNI_SME_msgType_REQ message
423 * @prot_status_code: Protocol Status Code
424 * @session_entry: PE Session Info
425 * @sme_session_id: SME Session ID
426 * @sme_transaction_id: SME Transaction ID
427 *
428 * This function is called by lim_process_sme_req_messages() to send
429 * eWNI_SME_JOIN_RSP or eWNI_SME_REASSOC_RSP messages to applications
430 * above MAC Software.
431 *
432 * Return: None
433 */
434
435void
436lim_send_sme_join_reassoc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
437 tSirResultCodes result_code, uint16_t prot_status_code,
438 tpPESession session_entry, uint8_t sme_session_id,
439 uint16_t sme_transaction_id)
440{
441 tpSirSmeJoinRsp sme_join_rsp;
442 uint32_t rsp_len;
443 tpDphHashNode sta_ds = NULL;
444#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
445 if (msg_type == eWNI_SME_REASSOC_RSP)
446 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_RSP_EVENT,
447 session_entry, (uint16_t) result_code, 0);
448 else
449 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_RSP_EVENT,
450 session_entry, (uint16_t) result_code, 0);
451#endif /* FEATURE_WLAN_DIAG_SUPPORT */
452
453 lim_log(mac_ctx, LOG1, FL("Sending message %s with reasonCode %s"),
454 lim_msg_str(msg_type), lim_result_code_str(result_code));
455
456 if (session_entry == NULL) {
457 rsp_len = sizeof(tSirSmeJoinRsp);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530458 sme_join_rsp = qdf_mem_malloc(rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800459 if (NULL == sme_join_rsp) {
460 lim_log(mac_ctx, LOGP,
461 FL("Mem Alloc fail - JOIN/REASSOC_RSP"));
462 return;
463 }
464
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800465 sme_join_rsp->beaconLength = 0;
466 sme_join_rsp->assocReqLength = 0;
467 sme_join_rsp->assocRspLength = 0;
468 } else {
469 rsp_len = session_entry->assocReqLen +
470 session_entry->assocRspLen + session_entry->bcnLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800471 session_entry->RICDataLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800472#ifdef FEATURE_WLAN_ESE
473 session_entry->tspecLen +
474#endif
475 sizeof(tSirSmeJoinRsp) - sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530476 sme_join_rsp = qdf_mem_malloc(rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800477 if (NULL == sme_join_rsp) {
478 lim_log(mac_ctx, LOGP,
479 FL("MemAlloc fail - JOIN/REASSOC_RSP"));
480 return;
481 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800482 if (result_code == eSIR_SME_SUCCESS) {
483 sta_ds = dph_get_hash_entry(mac_ctx,
484 DPH_STA_HASH_INDEX_PEER,
485 &session_entry->dph.dphHashTable);
486 if (sta_ds == NULL) {
487 lim_log(mac_ctx, LOGE,
488 FL("Get Self Sta Entry fail"));
489 } else {
490 /* Pass the peer's staId */
491 sme_join_rsp->staId = sta_ds->staIndex;
492 sme_join_rsp->ucastSig =
493 sta_ds->ucUcastSig;
494 sme_join_rsp->bcastSig =
495 sta_ds->ucBcastSig;
496 sme_join_rsp->timingMeasCap =
497 sta_ds->timingMeasCap;
498#ifdef FEATURE_WLAN_TDLS
499 sme_join_rsp->tdls_prohibited =
500 session_entry->tdls_prohibited;
501 sme_join_rsp->tdls_chan_swit_prohibited =
502 session_entry->tdls_chan_swit_prohibited;
503#endif
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530504 sme_join_rsp->nss = sta_ds->nss;
505 sme_join_rsp->max_rate_flags =
506 lim_get_max_rate_flags(mac_ctx, sta_ds);
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530507 lim_add_bss_info(sta_ds, sme_join_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800508 }
509 }
510 sme_join_rsp->beaconLength = 0;
511 sme_join_rsp->assocReqLength = 0;
512 sme_join_rsp->assocRspLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800513 sme_join_rsp->parsedRicRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800514#ifdef FEATURE_WLAN_ESE
515 sme_join_rsp->tspecIeLen = 0;
516#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800517 lim_handle_join_rsp_status(mac_ctx, session_entry, result_code,
518 sme_join_rsp);
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800519
520 /* Send supported NSS 1x1 to SME */
521 sme_join_rsp->supported_nss_1x1 =
522 session_entry->supported_nss_1x1;
523 lim_log(mac_ctx, LOG1,
524 FL("SME Join Rsp is supported NSS 1X1: %d"),
525 sme_join_rsp->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800526 }
527
528 sme_join_rsp->messageType = msg_type;
529 sme_join_rsp->length = (uint16_t) rsp_len;
530 sme_join_rsp->statusCode = result_code;
531 sme_join_rsp->protStatusCode = prot_status_code;
532
533 sme_join_rsp->sessionId = sme_session_id;
534 sme_join_rsp->transactionId = sme_transaction_id;
535
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530536 lim_send_sme_join_reassoc_rsp_after_resume(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800537 (uint32_t *)sme_join_rsp);
538}
539
540/**
541 * lim_send_sme_start_bss_rsp()
542 *
543 ***FUNCTION:
544 * This function is called to send eWNI_SME_START_BSS_RSP
545 * message to applications above MAC Software.
546 *
547 ***PARAMS:
548 *
549 ***LOGIC:
550 *
551 ***ASSUMPTIONS:
552 * NA
553 *
554 ***NOTE:
555 * NA
556 *
557 * @param pMac Pointer to Global MAC structure
558 * @param msgType Indicates message type
559 * @param resultCode Indicates the result of previously issued
560 * eWNI_SME_msgType_REQ message
561 *
562 * @return None
563 */
564
565void
566lim_send_sme_start_bss_rsp(tpAniSirGlobal pMac,
567 uint16_t msgType, tSirResultCodes resultCode,
568 tpPESession psessionEntry, uint8_t smesessionId,
569 uint16_t smetransactionId)
570{
571
572 uint16_t size = 0;
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800573 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800574 tSirSmeStartBssRsp *pSirSmeRsp;
575 uint16_t ieLen;
576 uint16_t ieOffset, curLen;
577
578 PELOG1(lim_log(pMac, LOG1, FL("Sending message %s with reasonCode %s"),
579 lim_msg_str(msgType), lim_result_code_str(resultCode));
580 )
581
582 size = sizeof(tSirSmeStartBssRsp);
583
584 if (psessionEntry == NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530585 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800586 if (NULL == pSirSmeRsp) {
587 /* / Buffer not available. Log error */
588 lim_log(pMac, LOGP,
589 FL
590 ("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP"));
591 return;
592 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800593 } else {
594 /* subtract size of beaconLength + Mac Hdr + Fixed Fields before SSID */
595 ieOffset = sizeof(tAniBeaconStruct) + SIR_MAC_B_PR_SSID_OFFSET;
596 ieLen = psessionEntry->schBeaconOffsetBegin
597 + psessionEntry->schBeaconOffsetEnd - ieOffset;
598 /* calculate the memory size to allocate */
599 size += ieLen;
600
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530601 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800602 if (NULL == pSirSmeRsp) {
603 /* / Buffer not available. Log error */
604 lim_log(pMac, LOGP,
605 FL
606 ("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP"));
607
608 return;
609 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800610 size = sizeof(tSirSmeStartBssRsp);
611 if (resultCode == eSIR_SME_SUCCESS) {
612
613 sir_copy_mac_addr(pSirSmeRsp->bssDescription.bssId,
614 psessionEntry->bssId);
615
616 /* Read beacon interval from session */
617 pSirSmeRsp->bssDescription.beaconInterval =
618 (uint16_t) psessionEntry->beaconParams.
619 beaconInterval;
620 pSirSmeRsp->bssType = psessionEntry->bssType;
621
622 if (cfg_get_capability_info
623 (pMac, &pSirSmeRsp->bssDescription.capabilityInfo,
624 psessionEntry)
625 != eSIR_SUCCESS)
626 lim_log(pMac, LOGP,
627 FL
628 ("could not retrieve Capabilities value"));
629
630 lim_get_phy_mode(pMac,
631 (uint32_t *) &pSirSmeRsp->bssDescription.
632 nwType, psessionEntry);
633
634 pSirSmeRsp->bssDescription.channelId =
635 psessionEntry->currentOperChannel;
636
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700637 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800638 curLen = psessionEntry->schBeaconOffsetBegin - ieOffset;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530639 qdf_mem_copy((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800640 ieFields,
641 psessionEntry->pSchBeaconFrameBegin +
642 ieOffset, (uint32_t) curLen);
643
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530644 qdf_mem_copy(((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800645 ieFields) + curLen,
646 psessionEntry->pSchBeaconFrameEnd,
647 (uint32_t) psessionEntry->
648 schBeaconOffsetEnd);
649
Abhishek Singh34a4d862016-10-26 16:01:51 +0530650 pSirSmeRsp->bssDescription.length = (uint16_t)
651 (offsetof(tSirBssDescription, ieFields[0])
652 - sizeof(pSirSmeRsp->bssDescription.length)
653 + ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800654 /* This is the size of the message, subtracting the size of the pointer to ieFields */
655 size += ieLen - sizeof(uint32_t);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700656 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800657#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
658 if (psessionEntry->cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530659 != QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800660 pSirSmeRsp->HTProfile.
661 htSupportedChannelWidthSet =
662 psessionEntry->htSupportedChannelWidthSet;
663 pSirSmeRsp->HTProfile.htRecommendedTxWidthSet =
664 psessionEntry->htRecommendedTxWidthSet;
665 pSirSmeRsp->HTProfile.htSecondaryChannelOffset =
666 psessionEntry->htSecondaryChannelOffset;
667 pSirSmeRsp->HTProfile.dot11mode =
668 psessionEntry->dot11mode;
669 pSirSmeRsp->HTProfile.htCapability =
670 psessionEntry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800671 pSirSmeRsp->HTProfile.vhtCapability =
672 psessionEntry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800673 pSirSmeRsp->HTProfile.apCenterChan =
674 psessionEntry->ch_center_freq_seg0;
675 pSirSmeRsp->HTProfile.apChanWidth =
676 psessionEntry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800677 }
678#endif
679 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800680 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800681 pSirSmeRsp->messageType = msgType;
682 pSirSmeRsp->length = size;
683
684 /* Update SME session Id and transaction Id */
685 pSirSmeRsp->sessionId = smesessionId;
686 pSirSmeRsp->transactionId = smetransactionId;
687 pSirSmeRsp->statusCode = resultCode;
688 if (psessionEntry != NULL)
689 pSirSmeRsp->staId = psessionEntry->staId; /* else it will be always zero smeRsp StaID = 0 */
690
691 mmhMsg.type = msgType;
692 mmhMsg.bodyptr = pSirSmeRsp;
693 mmhMsg.bodyval = 0;
694 if (psessionEntry == NULL) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530695 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
696 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800697 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530698 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
699 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800700 }
701#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
702 lim_diag_event_report(pMac, WLAN_PE_DIAG_START_BSS_RSP_EVENT,
703 psessionEntry, (uint16_t) resultCode, 0);
704#endif /* FEATURE_WLAN_DIAG_SUPPORT */
705
706 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
707} /*** end lim_send_sme_start_bss_rsp() ***/
708
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800709/**
710 * lim_send_sme_scan_rsp() - Send scan response to SME
711 * @pMac: Pointer to Global MAC structure
712 * @length: Indicates length of message
713 * @resultCode: Indicates the result of previously issued
714 * eWNI_SME_SCAN_REQ message
715 * @scan_id: scan identifier
716 *
717 * This function is called by lim_process_sme_req_messages() to send
718 * eWNI_SME_SCAN_RSP message to applications above MAC
719 *
720 * return: None
721 */
722
723void
724lim_send_sme_scan_rsp(tpAniSirGlobal pMac, tSirResultCodes resultCode,
725 uint8_t smesessionId, uint16_t smetranscationId,
726 uint32_t scan_id)
727{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800728 lim_post_sme_scan_rsp_message(pMac, resultCode, smesessionId,
729 smetranscationId, scan_id);
730}
731
732/**
733 * lim_post_sme_scan_rsp_message()
734 *
735 ***FUNCTION:
736 * This function is called by lim_send_sme_scan_rsp() to send
737 * eWNI_SME_SCAN_RSP message with failed result code
738 *
739 ***NOTE:
740 * NA
741 *
742 * @param pMac Pointer to Global MAC structure
743 * @param length Indicates length of message
744 * @param resultCode failed result code
745 *
746 * @return None
747 */
748
749void
750lim_post_sme_scan_rsp_message(tpAniSirGlobal pMac,
751 tSirResultCodes resultCode, uint8_t smesessionId,
752 uint16_t smetransactionId,
753 uint32_t scan_id)
754{
755 tpSirSmeScanRsp pSirSmeScanRsp;
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800756 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800757
758 lim_log(pMac, LOG1, FL("send SME_SCAN_RSP (reasonCode %s)."),
759 lim_result_code_str(resultCode));
760
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530761 pSirSmeScanRsp = qdf_mem_malloc(sizeof(tSirSmeScanRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800762 if (NULL == pSirSmeScanRsp) {
763 lim_log(pMac, LOGP,
764 FL("AllocateMemory failed for eWNI_SME_SCAN_RSP"));
765 return;
766 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800767
768 pSirSmeScanRsp->messageType = eWNI_SME_SCAN_RSP;
769 pSirSmeScanRsp->statusCode = resultCode;
770
771 /*Update SME session Id and transaction Id */
772 pSirSmeScanRsp->sessionId = smesessionId;
773 pSirSmeScanRsp->transcationId = smetransactionId;
774 pSirSmeScanRsp->scan_id = scan_id;
775
776 mmhMsg.type = eWNI_SME_SCAN_RSP;
777 mmhMsg.bodyptr = pSirSmeScanRsp;
778 mmhMsg.bodyval = 0;
779
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530780 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800781#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
782 lim_diag_event_report(pMac, WLAN_PE_DIAG_SCAN_RSP_EVENT, NULL,
783 (uint16_t) resultCode, 0);
784#endif /* FEATURE_WLAN_DIAG_SUPPORT */
785
786 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
787 return;
788
789} /*** lim_post_sme_scan_rsp_message ***/
790
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800791void lim_send_sme_disassoc_deauth_ntf(tpAniSirGlobal pMac,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530792 QDF_STATUS status, uint32_t *pCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800793{
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800794 struct scheduler_msg mmhMsg;
795 struct scheduler_msg *pMsg = (struct scheduler_msg *) pCtx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800796
797 mmhMsg.type = pMsg->type;
798 mmhMsg.bodyptr = pMsg;
799 mmhMsg.bodyval = 0;
800
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530801 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800802
803 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
804}
805
806/**
807 * lim_send_sme_disassoc_ntf()
808 *
809 ***FUNCTION:
810 * This function is called by limProcessSmeMessages() to send
811 * eWNI_SME_DISASSOC_RSP/IND message to host
812 *
813 ***PARAMS:
814 *
815 ***LOGIC:
816 *
817 ***ASSUMPTIONS:
818 * NA
819 *
820 ***NOTE:
821 * This function is used for sending eWNI_SME_DISASSOC_CNF,
822 * or eWNI_SME_DISASSOC_IND to host depending on
823 * disassociation trigger.
824 *
825 * @param peerMacAddr Indicates the peer MAC addr to which
826 * disassociate was initiated
827 * @param reasonCode Indicates the reason for Disassociation
828 * @param disassocTrigger Indicates the trigger for Disassociation
829 * @param aid Indicates the STAID. This parameter is
830 * present only on AP.
831 *
832 * @return None
833 */
834void
835lim_send_sme_disassoc_ntf(tpAniSirGlobal pMac,
836 tSirMacAddr peerMacAddr,
837 tSirResultCodes reasonCode,
838 uint16_t disassocTrigger,
839 uint16_t aid,
840 uint8_t smesessionId,
841 uint16_t smetransactionId, tpPESession psessionEntry)
842{
843
844 uint8_t *pBuf;
845 tSirSmeDisassocRsp *pSirSmeDisassocRsp;
846 tSirSmeDisassocInd *pSirSmeDisassocInd;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700847 uint32_t *pMsg = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800848 bool failure = false;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700849 tpPESession session = NULL;
850 uint16_t i, assoc_id;
851 tpDphHashNode sta_ds = NULL;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530852 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800853
854 lim_log(pMac, LOG1, FL("Disassoc Ntf with trigger : %d reasonCode: %d"),
855 disassocTrigger, reasonCode);
856
857 switch (disassocTrigger) {
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700858 case eLIM_DUPLICATE_ENTRY:
859 /*
860 * Duplicate entry is removed at LIM.
861 * Initiate new entry for other session
862 */
863 lim_log(pMac, LOG1,
864 FL("Rcvd eLIM_DUPLICATE_ENTRY for " MAC_ADDRESS_STR),
865 MAC_ADDR_ARRAY(peerMacAddr));
866
867 for (i = 0; i < pMac->lim.maxBssId; i++) {
868 if ((&pMac->lim.gpSession[i] != NULL) &&
869 (pMac->lim.gpSession[i].valid) &&
870 (pMac->lim.gpSession[i].pePersona ==
871 QDF_SAP_MODE)) {
872 /* Find the sta ds entry in another session */
873 session = &pMac->lim.gpSession[i];
874 sta_ds = dph_lookup_hash_entry(pMac,
875 peerMacAddr, &assoc_id,
876 &session->dph.dphHashTable);
877 }
878 }
879 if (sta_ds
880#ifdef WLAN_FEATURE_11W
881 && (!sta_ds->rmfEnabled)
882#endif
883 ) {
884 if (lim_add_sta(pMac, sta_ds, false, session) !=
885 eSIR_SUCCESS)
886 lim_log(pMac, LOGE,
887 FL("could not Add STA with assocId=%d"),
888 sta_ds->assocId);
889 }
890 failure = true;
891 break;
892
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800893 case eLIM_HOST_DISASSOC:
894 /**
895 * Disassociation response due to
896 * host triggered disassociation
897 */
898
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530899 pSirSmeDisassocRsp = qdf_mem_malloc(sizeof(tSirSmeDisassocRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800900 if (NULL == pSirSmeDisassocRsp) {
901 /* Log error */
902 lim_log(pMac, LOGP, FL("Memory allocation failed"));
903 failure = true;
904 goto error;
905 }
906 lim_log(pMac, LOG1, FL("send eWNI_SME_DISASSOC_RSP with "
907 "retCode: %d for " MAC_ADDRESS_STR),
908 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
909 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
910 pSirSmeDisassocRsp->length = sizeof(tSirSmeDisassocRsp);
911 /* sessionId */
912 pBuf = (uint8_t *) &pSirSmeDisassocRsp->sessionId;
913 *pBuf = smesessionId;
914 pBuf++;
915
916 /* transactionId */
917 lim_copy_u16(pBuf, smetransactionId);
918 pBuf += sizeof(uint16_t);
919
920 /* statusCode */
921 lim_copy_u32(pBuf, reasonCode);
922 pBuf += sizeof(tSirResultCodes);
923
924 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530925 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800926 pBuf += sizeof(tSirMacAddr);
927
928 /* Clear Station Stats */
929 /* for sta, it is always 1, IBSS is handled at halInitSta */
930
931#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
932
933 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
934 psessionEntry, (uint16_t) reasonCode, 0);
935#endif
936 pMsg = (uint32_t *) pSirSmeDisassocRsp;
937 break;
938
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530939 case eLIM_PEER_ENTITY_DISASSOC:
940 case eLIM_LINK_MONITORING_DISASSOC:
941 sir_sme_dis_ind =
942 qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
943 if (!sir_sme_dis_ind) {
944 lim_log(pMac, LOGE,
945 FL("call to AllocateMemory failed for disconnect indication"));
946 return;
947 }
948
949 lim_log(pMac, LOG1,
950 FL("send eWNI_SME_DISCONNECT_DONE_IND with retCode: %d"),
951 reasonCode);
952
953 sir_sme_dis_ind->message_type =
954 eWNI_SME_DISCONNECT_DONE_IND;
955 sir_sme_dis_ind->length =
956 sizeof(*sir_sme_dis_ind);
957 qdf_mem_copy(sir_sme_dis_ind->peer_mac, peerMacAddr,
958 sizeof(tSirMacAddr));
959 sir_sme_dis_ind->session_id = smesessionId;
960 sir_sme_dis_ind->reason_code = reasonCode;
Selvaraj, Sridharc7d80892016-09-29 11:56:45 +0530961 /*
962 * Instead of sending deauth reason code as 505 which is
963 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
964 * Send reason code as zero to Supplicant
965 */
966 if (reasonCode == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
967 sir_sme_dis_ind->reason_code = 0;
968 else
969 sir_sme_dis_ind->reason_code = reasonCode;
970
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530971 pMsg = (uint32_t *)sir_sme_dis_ind;
972
973 break;
974
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800975 default:
976 /**
977 * Disassociation indication due to Disassociation
978 * frame reception from peer entity or due to
979 * loss of link with peer entity.
980 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530981 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800982 if (NULL == pSirSmeDisassocInd) {
983 /* Log error */
984 lim_log(pMac, LOGP, FL("Memory allocation failed"));
985 failure = true;
986 goto error;
987 }
988 lim_log(pMac, LOG1, FL("send eWNI_SME_DISASSOC_IND with "
989 "retCode: %d for " MAC_ADDRESS_STR),
990 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
991 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
992 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
993
994 /* Update SME session Id and Transaction Id */
995 pSirSmeDisassocInd->sessionId = smesessionId;
996 pSirSmeDisassocInd->transactionId = smetransactionId;
997 pSirSmeDisassocInd->reasonCode = reasonCode;
998 pBuf = (uint8_t *) &pSirSmeDisassocInd->statusCode;
999
1000 lim_copy_u32(pBuf, reasonCode);
1001 pBuf += sizeof(tSirResultCodes);
1002
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301003 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001004 pBuf += sizeof(tSirMacAddr);
1005
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301006 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001007
1008#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1009 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
1010 psessionEntry, (uint16_t) reasonCode, 0);
1011#endif
1012 pMsg = (uint32_t *) pSirSmeDisassocInd;
1013
1014 break;
1015 }
1016
1017error:
1018 /* Delete the PE session Created */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07001019 if ((psessionEntry != NULL) && LIM_IS_STA_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001020 pe_delete_session(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001021
1022 if (false == failure)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301023 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001024 (uint32_t *) pMsg);
1025} /*** end lim_send_sme_disassoc_ntf() ***/
1026
1027/** -----------------------------------------------------------------
1028 \brief lim_send_sme_disassoc_ind() - sends SME_DISASSOC_IND
1029
1030 After receiving disassociation frame from peer entity, this
1031 function sends a eWNI_SME_DISASSOC_IND to SME with a specific
1032 reason code.
1033
1034 \param pMac - global mac structure
1035 \param pStaDs - station dph hash node
1036 \return none
1037 \sa
1038 ----------------------------------------------------------------- */
1039void
1040lim_send_sme_disassoc_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1041 tpPESession psessionEntry)
1042{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001043 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001044 tSirSmeDisassocInd *pSirSmeDisassocInd;
1045
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301046 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001047 if (NULL == pSirSmeDisassocInd) {
1048 lim_log(pMac, LOGP,
1049 FL("AllocateMemory failed for eWNI_SME_DISASSOC_IND"));
1050 return;
1051 }
1052
1053 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
1054 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
1055
1056 pSirSmeDisassocInd->sessionId = psessionEntry->smeSessionId;
1057 pSirSmeDisassocInd->transactionId = psessionEntry->transactionId;
Padma, Santhosh Kumar02289212016-09-30 13:30:08 +05301058 pSirSmeDisassocInd->statusCode = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001059 pSirSmeDisassocInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1060
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301061 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301062 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001063
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301064 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301065 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001066
1067 pSirSmeDisassocInd->staId = pStaDs->staIndex;
1068
1069 mmhMsg.type = eWNI_SME_DISASSOC_IND;
1070 mmhMsg.bodyptr = pSirSmeDisassocInd;
1071 mmhMsg.bodyval = 0;
1072
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301073 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1074 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001075#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1076 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT, psessionEntry,
1077 0, (uint16_t) pStaDs->mlmStaContext.disassocReason);
1078#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1079
1080 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1081
1082} /*** end lim_send_sme_disassoc_ind() ***/
1083
1084/** -----------------------------------------------------------------
1085 \brief lim_send_sme_deauth_ind() - sends SME_DEAUTH_IND
1086
1087 After receiving deauthentication frame from peer entity, this
1088 function sends a eWNI_SME_DEAUTH_IND to SME with a specific
1089 reason code.
1090
1091 \param pMac - global mac structure
1092 \param pStaDs - station dph hash node
1093 \return none
1094 \sa
1095 ----------------------------------------------------------------- */
1096void
1097lim_send_sme_deauth_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1098 tpPESession psessionEntry)
1099{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001100 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001101 tSirSmeDeauthInd *pSirSmeDeauthInd;
1102
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301103 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001104 if (NULL == pSirSmeDeauthInd) {
1105 lim_log(pMac, LOGP,
1106 FL("AllocateMemory failed for eWNI_SME_DEAUTH_IND "));
1107 return;
1108 }
1109
1110 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1111 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1112
1113 pSirSmeDeauthInd->sessionId = psessionEntry->smeSessionId;
1114 pSirSmeDeauthInd->transactionId = psessionEntry->transactionId;
1115 if (eSIR_INFRA_AP_MODE == psessionEntry->bssType) {
1116 pSirSmeDeauthInd->statusCode =
1117 (tSirResultCodes) pStaDs->mlmStaContext.cleanupTrigger;
1118 } else {
1119 /* Need to indicatet he reascon code over the air */
1120 pSirSmeDeauthInd->statusCode =
1121 (tSirResultCodes) pStaDs->mlmStaContext.disassocReason;
1122 }
1123 /* BSSID */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301124 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301125 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001126 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301127 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301128 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001129 pSirSmeDeauthInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1130
1131 pSirSmeDeauthInd->staId = pStaDs->staIndex;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001132 if (eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON ==
1133 pStaDs->mlmStaContext.disassocReason)
1134 pSirSmeDeauthInd->rssi = pStaDs->del_sta_ctx_rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001135
1136 mmhMsg.type = eWNI_SME_DEAUTH_IND;
1137 mmhMsg.bodyptr = pSirSmeDeauthInd;
1138 mmhMsg.bodyval = 0;
1139
1140 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1141#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1142 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT, psessionEntry,
1143 0, pStaDs->mlmStaContext.cleanupTrigger);
1144#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1145
1146 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1147 return;
1148} /*** end lim_send_sme_deauth_ind() ***/
1149
1150#ifdef FEATURE_WLAN_TDLS
1151/**
1152 * lim_send_sme_tdls_del_sta_ind()
1153 *
1154 ***FUNCTION:
1155 * This function is called to send the TDLS STA context deletion to SME.
1156 *
1157 ***LOGIC:
1158 *
1159 ***ASSUMPTIONS:
1160 *
1161 ***NOTE:
1162 * NA
1163 *
1164 * @param pMac - Pointer to global MAC structure
1165 * @param pStaDs - Pointer to internal STA Datastructure
1166 * @param psessionEntry - Pointer to the session entry
1167 * @param reasonCode - Reason for TDLS sta deletion
1168 * @return None
1169 */
1170void
1171lim_send_sme_tdls_del_sta_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1172 tpPESession psessionEntry, uint16_t reasonCode)
1173{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001174 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001175 tSirTdlsDelStaInd *pSirTdlsDelStaInd;
1176
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301177 pSirTdlsDelStaInd = qdf_mem_malloc(sizeof(tSirTdlsDelStaInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001178 if (NULL == pSirTdlsDelStaInd) {
1179 lim_log(pMac, LOGP,
1180 FL
1181 ("AllocateMemory failed for eWNI_SME_TDLS_DEL_STA_IND "));
1182 return;
1183 }
Nitesh Shah82c52812016-12-27 12:27:51 +05301184 lim_log(pMac, LOG1, FL("Delete TDLS Peer "MAC_ADDRESS_STR
1185 "with reason code %d"),
1186 MAC_ADDR_ARRAY(pStaDs->staAddr), reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001187 /* messageType */
1188 pSirTdlsDelStaInd->messageType = eWNI_SME_TDLS_DEL_STA_IND;
1189 pSirTdlsDelStaInd->length = sizeof(tSirTdlsDelStaInd);
1190
1191 /* sessionId */
1192 pSirTdlsDelStaInd->sessionId = psessionEntry->smeSessionId;
1193
1194 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301195 qdf_mem_copy(pSirTdlsDelStaInd->peermac.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301196 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001197
1198 /* staId */
1199 lim_copy_u16((uint8_t *) (&pSirTdlsDelStaInd->staId),
1200 (uint16_t) pStaDs->staIndex);
1201
1202 /* reasonCode */
1203 lim_copy_u16((uint8_t *) (&pSirTdlsDelStaInd->reasonCode), reasonCode);
1204
1205 mmhMsg.type = eWNI_SME_TDLS_DEL_STA_IND;
1206 mmhMsg.bodyptr = pSirTdlsDelStaInd;
1207 mmhMsg.bodyval = 0;
1208
1209 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1210 return;
1211} /*** end lim_send_sme_tdls_del_sta_ind() ***/
1212
1213/**
1214 * lim_send_sme_tdls_delete_all_peer_ind()
1215 *
1216 ***FUNCTION:
1217 * This function is called to send the eWNI_SME_TDLS_DEL_ALL_PEER_IND
1218 * message to SME.
1219 *
1220 ***LOGIC:
1221 *
1222 ***ASSUMPTIONS:
1223 *
1224 ***NOTE:
1225 * NA
1226 *
1227 * @param pMac - Pointer to global MAC structure
1228 * @param psessionEntry - Pointer to the session entry
1229 * @return None
1230 */
1231void
1232lim_send_sme_tdls_delete_all_peer_ind(tpAniSirGlobal pMac, tpPESession psessionEntry)
1233{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001234 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001235 tSirTdlsDelAllPeerInd *pSirTdlsDelAllPeerInd;
1236
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301237 pSirTdlsDelAllPeerInd = qdf_mem_malloc(sizeof(tSirTdlsDelAllPeerInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001238 if (NULL == pSirTdlsDelAllPeerInd) {
1239 lim_log(pMac, LOGP,
1240 FL
1241 ("AllocateMemory failed for eWNI_SME_TDLS_DEL_ALL_PEER_IND"));
1242 return;
1243 }
1244 /* messageType */
1245 pSirTdlsDelAllPeerInd->messageType = eWNI_SME_TDLS_DEL_ALL_PEER_IND;
1246 pSirTdlsDelAllPeerInd->length = sizeof(tSirTdlsDelAllPeerInd);
1247
1248 /* sessionId */
1249 pSirTdlsDelAllPeerInd->sessionId = psessionEntry->smeSessionId;
1250
1251 mmhMsg.type = eWNI_SME_TDLS_DEL_ALL_PEER_IND;
1252 mmhMsg.bodyptr = pSirTdlsDelAllPeerInd;
1253 mmhMsg.bodyval = 0;
1254
1255 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1256 return;
1257} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1258
1259/**
1260 * lim_send_sme_mgmt_tx_completion()
1261 *
1262 ***FUNCTION:
1263 * This function is called to send the eWNI_SME_MGMT_FRM_TX_COMPLETION_IND
1264 * message to SME.
1265 *
1266 ***LOGIC:
1267 *
1268 ***ASSUMPTIONS:
1269 *
1270 ***NOTE:
1271 * NA
1272 *
1273 * @param pMac - Pointer to global MAC structure
1274 * @param psessionEntry - Pointer to the session entry
1275 * @param txCompleteStatus - TX Complete Status of Mgmt Frames
1276 * @return None
1277 */
1278void
1279lim_send_sme_mgmt_tx_completion(tpAniSirGlobal pMac,
1280 tpPESession psessionEntry, uint32_t txCompleteStatus)
1281{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001282 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001283 tSirMgmtTxCompletionInd *pSirMgmtTxCompletionInd;
1284
1285 pSirMgmtTxCompletionInd =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301286 qdf_mem_malloc(sizeof(tSirMgmtTxCompletionInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001287 if (NULL == pSirMgmtTxCompletionInd) {
1288 lim_log(pMac, LOGP,
1289 FL
1290 ("AllocateMemory failed for eWNI_SME_MGMT_FRM_TX_COMPLETION_IND"));
1291 return;
1292 }
1293 /* messageType */
1294 pSirMgmtTxCompletionInd->messageType =
1295 eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1296 pSirMgmtTxCompletionInd->length = sizeof(tSirMgmtTxCompletionInd);
1297
1298 /* sessionId */
1299 pSirMgmtTxCompletionInd->sessionId = psessionEntry->smeSessionId;
1300
1301 pSirMgmtTxCompletionInd->txCompleteStatus = txCompleteStatus;
1302
1303 mmhMsg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1304 mmhMsg.bodyptr = pSirMgmtTxCompletionInd;
1305 mmhMsg.bodyval = 0;
1306
1307 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1308 return;
1309} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1310
1311void lim_send_sme_tdls_event_notify(tpAniSirGlobal pMac, uint16_t msgType,
1312 void *events)
1313{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001314 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001315
1316 switch (msgType) {
1317 case SIR_HAL_TDLS_SHOULD_DISCOVER:
1318 mmhMsg.type = eWNI_SME_TDLS_SHOULD_DISCOVER;
1319 break;
1320 case SIR_HAL_TDLS_SHOULD_TEARDOWN:
1321 mmhMsg.type = eWNI_SME_TDLS_SHOULD_TEARDOWN;
1322 break;
1323 case SIR_HAL_TDLS_PEER_DISCONNECTED:
1324 mmhMsg.type = eWNI_SME_TDLS_PEER_DISCONNECTED;
1325 break;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07001326 case SIR_HAL_TDLS_CONNECTION_TRACKER_NOTIFICATION:
1327 mmhMsg.type = eWNI_SME_TDLS_CONNECTION_TRACKER_NOTIFICATION;
1328 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001329 }
1330
1331 mmhMsg.bodyptr = events;
1332 mmhMsg.bodyval = 0;
1333 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1334 return;
1335}
1336#endif /* FEATURE_WLAN_TDLS */
1337
1338/**
1339 * lim_send_sme_deauth_ntf()
1340 *
1341 ***FUNCTION:
1342 * This function is called by limProcessSmeMessages() to send
1343 * eWNI_SME_DISASSOC_RSP/IND message to host
1344 *
1345 ***PARAMS:
1346 *
1347 ***LOGIC:
1348 *
1349 ***ASSUMPTIONS:
1350 * NA
1351 *
1352 ***NOTE:
1353 * This function is used for sending eWNI_SME_DEAUTH_CNF or
1354 * eWNI_SME_DEAUTH_IND to host depending on deauthentication trigger.
1355 *
1356 * @param peerMacAddr Indicates the peer MAC addr to which
1357 * deauthentication was initiated
1358 * @param reasonCode Indicates the reason for Deauthetication
1359 * @param deauthTrigger Indicates the trigger for Deauthetication
1360 * @param aid Indicates the STAID. This parameter is present
1361 * only on AP.
1362 *
1363 * @return None
1364 */
1365void
1366lim_send_sme_deauth_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
1367 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1368 uint16_t aid, uint8_t smesessionId,
1369 uint16_t smetransactionId)
1370{
1371 uint8_t *pBuf;
1372 tSirSmeDeauthRsp *pSirSmeDeauthRsp;
1373 tSirSmeDeauthInd *pSirSmeDeauthInd;
1374 tpPESession psessionEntry;
1375 uint8_t sessionId;
1376 uint32_t *pMsg;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301377 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001378
1379 psessionEntry = pe_find_session_by_bssid(pMac, peerMacAddr, &sessionId);
1380 switch (deauthTrigger) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001381 case eLIM_HOST_DEAUTH:
1382 /**
1383 * Deauthentication response to host triggered
1384 * deauthentication.
1385 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301386 pSirSmeDeauthRsp = qdf_mem_malloc(sizeof(tSirSmeDeauthRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001387 if (NULL == pSirSmeDeauthRsp) {
1388 /* Log error */
1389 lim_log(pMac, LOGP,
1390 FL
1391 ("call to AllocateMemory failed for eWNI_SME_DEAUTH_RSP"));
1392
1393 return;
1394 }
1395 lim_log(pMac, LOG1, FL("send eWNI_SME_DEAUTH_RSP with "
1396 "retCode: %d for" MAC_ADDRESS_STR),
1397 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1398 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
1399 pSirSmeDeauthRsp->length = sizeof(tSirSmeDeauthRsp);
1400 pSirSmeDeauthRsp->statusCode = reasonCode;
1401 pSirSmeDeauthRsp->sessionId = smesessionId;
1402 pSirSmeDeauthRsp->transactionId = smetransactionId;
1403
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -08001404 pBuf = (uint8_t *) pSirSmeDeauthRsp->peer_macaddr.bytes;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301405 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001406
1407#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1408 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
1409 psessionEntry, 0, (uint16_t) reasonCode);
1410#endif
1411 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1412
1413 break;
1414
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301415 case eLIM_PEER_ENTITY_DEAUTH:
1416 case eLIM_LINK_MONITORING_DEAUTH:
1417 sir_sme_dis_ind =
1418 qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
1419 if (!sir_sme_dis_ind) {
1420 lim_log(pMac, LOGE,
1421 FL("call to AllocateMemory failed for disconnect indication"));
1422 return;
1423 }
1424
1425 lim_log(pMac, LOG1,
1426 FL("send eWNI_SME_DISCONNECT_DONE_IND withretCode: %d"),
1427 reasonCode);
1428
1429 sir_sme_dis_ind->message_type =
1430 eWNI_SME_DISCONNECT_DONE_IND;
1431 sir_sme_dis_ind->length =
1432 sizeof(*sir_sme_dis_ind);
1433 sir_sme_dis_ind->session_id = smesessionId;
1434 sir_sme_dis_ind->reason_code = reasonCode;
1435 qdf_mem_copy(sir_sme_dis_ind->peer_mac, peerMacAddr,
1436 ETH_ALEN);
Selvaraj, Sridharc7d80892016-09-29 11:56:45 +05301437 /*
1438 * Instead of sending deauth reason code as 505 which is
1439 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1440 * Send reason code as zero to Supplicant
1441 */
1442 if (reasonCode == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1443 sir_sme_dis_ind->reason_code = 0;
1444 else
1445 sir_sme_dis_ind->reason_code = reasonCode;
1446
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301447 pMsg = (uint32_t *)sir_sme_dis_ind;
1448
1449 break;
1450
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001451 default:
1452 /**
1453 * Deauthentication indication due to Deauthentication
1454 * frame reception from peer entity or due to
1455 * loss of link with peer entity.
1456 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301457 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001458 if (NULL == pSirSmeDeauthInd) {
1459 /* Log error */
1460 lim_log(pMac, LOGP,
1461 FL
1462 ("call to AllocateMemory failed for eWNI_SME_DEAUTH_Ind"));
1463
1464 return;
1465 }
1466 lim_log(pMac, LOG1, FL("send eWNI_SME_DEAUTH_IND with "
1467 "retCode: %d for " MAC_ADDRESS_STR),
1468 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1469 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1470 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1471 pSirSmeDeauthInd->reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
1472
1473 /* sessionId */
1474 pBuf = (uint8_t *) &pSirSmeDeauthInd->sessionId;
1475 *pBuf++ = smesessionId;
1476
1477 /* transaction ID */
1478 lim_copy_u16(pBuf, smetransactionId);
1479 pBuf += sizeof(uint16_t);
1480
1481 /* status code */
1482 lim_copy_u32(pBuf, reasonCode);
1483 pBuf += sizeof(tSirResultCodes);
1484
1485 /* bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301486 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001487 pBuf += sizeof(tSirMacAddr);
1488
1489 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301490 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301491 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001492
1493#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1494 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
1495 psessionEntry, 0, (uint16_t) reasonCode);
1496#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1497 pMsg = (uint32_t *) pSirSmeDeauthInd;
1498
1499 break;
1500 }
1501
1502 /*Delete the PE session created */
1503 if (psessionEntry != NULL) {
1504 pe_delete_session(pMac, psessionEntry);
1505 }
1506
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301507 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001508 (uint32_t *) pMsg);
1509
1510} /*** end lim_send_sme_deauth_ntf() ***/
1511
1512/**
1513 * lim_send_sme_wm_status_change_ntf() - Send Notification
1514 * @mac_ctx: Global MAC Context
1515 * @status_change_code: Indicates the change in the wireless medium.
1516 * @status_change_info: Indicates the information associated with
1517 * change in the wireless medium.
1518 * @info_len: Indicates the length of status change information
1519 * being sent.
1520 * @session_id SessionID
1521 *
1522 * This function is called by limProcessSmeMessages() to send
1523 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1524 *
1525 * Return: None
1526 */
1527void
1528lim_send_sme_wm_status_change_ntf(tpAniSirGlobal mac_ctx,
1529 tSirSmeStatusChangeCode status_change_code,
1530 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1531{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001532 struct scheduler_msg msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001533 tSirSmeWmStatusChangeNtf *wm_status_change_ntf;
Naveen Rawate01ed172016-11-17 11:34:50 -08001534 uint32_t max_info_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001535
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301536 wm_status_change_ntf = qdf_mem_malloc(sizeof(tSirSmeWmStatusChangeNtf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001537 if (NULL == wm_status_change_ntf) {
1538 lim_log(mac_ctx, LOGE,
1539 FL("Mem Alloc failed - eWNI_SME_WM_STATUS_CHANGE_NTF"));
1540 return;
1541 }
1542
1543 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1544 msg.bodyval = 0;
1545 msg.bodyptr = wm_status_change_ntf;
1546
1547 switch (status_change_code) {
Naveen Rawate01ed172016-11-17 11:34:50 -08001548 case eSIR_SME_AP_CAPS_CHANGED:
1549 max_info_len = sizeof(tSirSmeApNewCaps);
1550 break;
1551 case eSIR_SME_JOINED_NEW_BSS:
1552 max_info_len = sizeof(tSirSmeNewBssInfo);
1553 break;
1554 default:
1555 max_info_len = sizeof(wm_status_change_ntf->statusChangeInfo);
1556 break;
1557 }
1558
1559 switch (status_change_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001560 case eSIR_SME_RADAR_DETECTED:
1561 break;
1562 default:
1563 wm_status_change_ntf->messageType =
1564 eWNI_SME_WM_STATUS_CHANGE_NTF;
1565 wm_status_change_ntf->statusChangeCode = status_change_code;
1566 wm_status_change_ntf->length = sizeof(tSirSmeWmStatusChangeNtf);
1567 wm_status_change_ntf->sessionId = session_id;
Naveen Rawate01ed172016-11-17 11:34:50 -08001568 if (info_len <= max_info_len && status_change_info) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301569 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001570 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1571 (uint8_t *) status_change_info, info_len);
1572 }
1573 lim_log(mac_ctx, LOGE,
1574 FL("**---** StatusChg: code 0x%x, length %d **---**"),
1575 status_change_code, info_len);
1576 break;
1577 }
1578
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301579 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001580 if (eSIR_SUCCESS != lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301581 qdf_mem_free(wm_status_change_ntf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001582 lim_log(mac_ctx, LOGP,
1583 FL("lim_sys_process_mmh_msg_api failed"));
1584 }
1585
1586} /*** end lim_send_sme_wm_status_change_ntf() ***/
1587
1588/**
1589 * lim_send_sme_set_context_rsp()
1590 *
1591 ***FUNCTION:
1592 * This function is called by limProcessSmeMessages() to send
1593 * eWNI_SME_SETCONTEXT_RSP message to host
1594 *
1595 ***PARAMS:
1596 *
1597 ***LOGIC:
1598 *
1599 ***ASSUMPTIONS:
1600 * NA
1601 *
1602 ***NOTE:
1603 *
1604 * @param pMac Pointer to Global MAC structure
1605 * @param peerMacAddr Indicates the peer MAC addr to which
1606 * setContext was performed
1607 * @param aid Indicates the aid corresponding to the peer MAC
1608 * address
1609 * @param resultCode Indicates the result of previously issued
1610 * eWNI_SME_SETCONTEXT_RSP message
1611 *
1612 * @return None
1613 */
1614void
1615lim_send_sme_set_context_rsp(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301616 struct qdf_mac_addr peer_macaddr, uint16_t aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001617 tSirResultCodes resultCode,
1618 tpPESession psessionEntry, uint8_t smesessionId,
1619 uint16_t smetransactionId)
1620{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001621 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001622 tSirSmeSetContextRsp *pSirSmeSetContextRsp;
1623
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301624 pSirSmeSetContextRsp = qdf_mem_malloc(sizeof(tSirSmeSetContextRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001625 if (NULL == pSirSmeSetContextRsp) {
1626 /* Log error */
1627 lim_log(pMac, LOGP,
1628 FL
1629 ("call to AllocateMemory failed for SmeSetContextRsp"));
1630
1631 return;
1632 }
1633
1634 pSirSmeSetContextRsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1635 pSirSmeSetContextRsp->length = sizeof(tSirSmeSetContextRsp);
1636 pSirSmeSetContextRsp->statusCode = resultCode;
1637
Anurag Chouhanc5548422016-02-24 18:33:27 +05301638 qdf_copy_macaddr(&pSirSmeSetContextRsp->peer_macaddr, &peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001639
1640 /* Update SME session and transaction Id */
1641 pSirSmeSetContextRsp->sessionId = smesessionId;
1642 pSirSmeSetContextRsp->transactionId = smetransactionId;
1643
1644 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
1645 mmhMsg.bodyptr = pSirSmeSetContextRsp;
1646 mmhMsg.bodyval = 0;
1647 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301648 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1649 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001650 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301651 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1652 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001653 }
1654
1655#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1656 lim_diag_event_report(pMac, WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
1657 psessionEntry, (uint16_t) resultCode, 0);
1658#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1659
1660 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1661} /*** end lim_send_sme_set_context_rsp() ***/
1662
1663/**
1664 * lim_send_sme_neighbor_bss_ind()
1665 *
1666 ***FUNCTION:
1667 * This function is called by lim_lookup_nadd_hash_entry() to send
1668 * eWNI_SME_NEIGHBOR_BSS_IND message to host
1669 *
1670 ***PARAMS:
1671 *
1672 ***LOGIC:
1673 *
1674 ***ASSUMPTIONS:
1675 * NA
1676 *
1677 ***NOTE:
1678 * This function is used for sending eWNI_SME_NEIGHBOR_BSS_IND to
1679 * host upon detecting new BSS during background scanning if CFG
1680 * option is enabled for sending such indication
1681 *
1682 * @param pMac - Pointer to Global MAC structure
1683 * @return None
1684 */
1685
1686void
1687lim_send_sme_neighbor_bss_ind(tpAniSirGlobal pMac, tLimScanResultNode *pBssDescr)
1688{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001689 struct scheduler_msg msgQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001690 uint32_t val;
1691 tSirSmeNeighborBssInd *pNewBssInd;
1692
1693 if ((pMac->lim.gLimSmeState != eLIM_SME_LINK_EST_WT_SCAN_STATE) ||
1694 ((pMac->lim.gLimSmeState == eLIM_SME_LINK_EST_WT_SCAN_STATE) &&
1695 pMac->lim.gLimRspReqd)) {
1696 /* LIM is not in background scan state OR */
1697 /* current scan is initiated by HDD. */
1698 /* No need to send new BSS indication to HDD */
1699 return;
1700 }
1701
1702 if (wlan_cfg_get_int(pMac, WNI_CFG_NEW_BSS_FOUND_IND, &val) !=
1703 eSIR_SUCCESS) {
1704 lim_log(pMac, LOGP,
1705 FL("could not get NEIGHBOR_BSS_IND from CFG"));
1706
1707 return;
1708 }
1709
1710 if (val == 0)
1711 return;
1712
1713 /**
1714 * Need to indicate new BSSs found during
1715 * background scanning to host.
1716 * Allocate buffer for sending indication.
1717 * Length of buffer is length of BSS description
1718 * and length of header itself
1719 */
1720 val = pBssDescr->bssDescription.length + sizeof(uint16_t) +
1721 sizeof(uint32_t) + sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301722 pNewBssInd = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001723 if (NULL == pNewBssInd) {
1724 /* Log error */
1725 lim_log(pMac, LOGP,
1726 FL
1727 ("call to AllocateMemory failed for eWNI_SME_NEIGHBOR_BSS_IND"));
1728
1729 return;
1730 }
1731
1732 pNewBssInd->messageType = eWNI_SME_NEIGHBOR_BSS_IND;
1733 pNewBssInd->length = (uint16_t) val;
1734 pNewBssInd->sessionId = 0;
1735
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301736 qdf_mem_copy((uint8_t *) pNewBssInd->bssDescription,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001737 (uint8_t *) &pBssDescr->bssDescription,
1738 pBssDescr->bssDescription.length + sizeof(uint16_t));
1739
1740 msgQ.type = eWNI_SME_NEIGHBOR_BSS_IND;
1741 msgQ.bodyptr = pNewBssInd;
1742 msgQ.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301743 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, msgQ.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001744 lim_sys_process_mmh_msg_api(pMac, &msgQ, ePROT);
1745} /*** end lim_send_sme_neighbor_bss_ind() ***/
1746
1747/** -----------------------------------------------------------------
1748 \brief lim_send_sme_addts_rsp() - sends SME ADDTS RSP
1749 \ This function sends a eWNI_SME_ADDTS_RSP to SME.
1750 \ SME only looks at rc and tspec field.
1751 \param pMac - global mac structure
1752 \param rspReqd - is SmeAddTsRsp required
1753 \param status - status code of SME_ADD_TS_RSP
1754 \return tspec
1755 \sa
1756 ----------------------------------------------------------------- */
1757void
1758lim_send_sme_addts_rsp(tpAniSirGlobal pMac, uint8_t rspReqd, uint32_t status,
1759 tpPESession psessionEntry, tSirMacTspecIE tspec,
1760 uint8_t smesessionId, uint16_t smetransactionId)
1761{
1762 tpSirAddtsRsp rsp;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001763 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001764
1765 if (!rspReqd)
1766 return;
1767
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301768 rsp = qdf_mem_malloc(sizeof(tSirAddtsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001769 if (NULL == rsp) {
1770 lim_log(pMac, LOGP, FL("AllocateMemory failed for ADDTS_RSP"));
1771 return;
1772 }
1773
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001774 rsp->messageType = eWNI_SME_ADDTS_RSP;
1775 rsp->rc = status;
1776 rsp->rsp.status = (enum eSirMacStatusCodes)status;
1777 rsp->rsp.tspec = tspec;
1778 /* Update SME session Id and transcation Id */
1779 rsp->sessionId = smesessionId;
1780 rsp->transactionId = smetransactionId;
1781
1782 mmhMsg.type = eWNI_SME_ADDTS_RSP;
1783 mmhMsg.bodyptr = rsp;
1784 mmhMsg.bodyval = 0;
1785 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301786 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1787 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001788 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301789 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1790 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001791 }
1792#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1793 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_RSP_EVENT, psessionEntry, 0,
1794 0);
1795#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1796
1797 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1798 return;
1799}
1800
1801void
1802lim_send_sme_delts_rsp(tpAniSirGlobal pMac, tpSirDeltsReq delts, uint32_t status,
1803 tpPESession psessionEntry, uint8_t smesessionId,
1804 uint16_t smetransactionId)
1805{
1806 tpSirDeltsRsp rsp;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001807 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001808
1809 lim_log(pMac, LOGW, "SendSmeDeltsRsp (aid %d, tsid %d, up %d) status %d",
1810 delts->aid,
1811 delts->req.tsinfo.traffic.tsid,
1812 delts->req.tsinfo.traffic.userPrio, status);
1813 if (!delts->rspReqd)
1814 return;
1815
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301816 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001817 if (NULL == rsp) {
1818 /* Log error */
1819 lim_log(pMac, LOGP, FL("AllocateMemory failed for DELTS_RSP"));
1820 return;
1821 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001822
1823 if (psessionEntry != NULL) {
1824
1825 rsp->aid = delts->aid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301826 qdf_copy_macaddr(&rsp->macaddr, &delts->macaddr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301827 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) &delts->req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001828 sizeof(tSirDeltsReqInfo));
1829 }
1830
1831 rsp->messageType = eWNI_SME_DELTS_RSP;
1832 rsp->rc = status;
1833
1834 /* Update SME session Id and transcation Id */
1835 rsp->sessionId = smesessionId;
1836 rsp->transactionId = smetransactionId;
1837
1838 mmhMsg.type = eWNI_SME_DELTS_RSP;
1839 mmhMsg.bodyptr = rsp;
1840 mmhMsg.bodyval = 0;
1841 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301842 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1843 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001844 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301845 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1846 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001847 }
1848#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1849 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_RSP_EVENT, psessionEntry,
1850 (uint16_t) status, 0);
1851#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1852
1853 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1854}
1855
1856void
1857lim_send_sme_delts_ind(tpAniSirGlobal pMac, tpSirDeltsReqInfo delts, uint16_t aid,
1858 tpPESession psessionEntry)
1859{
1860 tpSirDeltsRsp rsp;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001861 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001862
1863 lim_log(pMac, LOGW, "SendSmeDeltsInd (aid %d, tsid %d, up %d)",
1864 aid, delts->tsinfo.traffic.tsid, delts->tsinfo.traffic.userPrio);
1865
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301866 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001867 if (NULL == rsp) {
1868 /* Log error */
1869 lim_log(pMac, LOGP, FL("AllocateMemory failed for DELTS_IND"));
1870 return;
1871 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001872
1873 rsp->messageType = eWNI_SME_DELTS_IND;
1874 rsp->rc = eSIR_SUCCESS;
1875 rsp->aid = aid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301876 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) delts, sizeof(*delts));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001877
1878 /* Update SME session Id and SME transaction Id */
1879
1880 rsp->sessionId = psessionEntry->smeSessionId;
1881 rsp->transactionId = psessionEntry->transactionId;
1882
1883 mmhMsg.type = eWNI_SME_DELTS_IND;
1884 mmhMsg.bodyptr = rsp;
1885 mmhMsg.bodyval = 0;
1886 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1887#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1888 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_IND_EVENT, psessionEntry, 0,
1889 0);
1890#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1891
1892 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1893}
1894
1895/**
1896 * lim_send_sme_pe_statistics_rsp()
1897 *
1898 ***FUNCTION:
1899 * This function is called to send 802.11 statistics response to HDD.
1900 * This function posts the result back to HDD. This is a response to
1901 * HDD's request for statistics.
1902 *
1903 ***PARAMS:
1904 *
1905 ***LOGIC:
1906 *
1907 ***ASSUMPTIONS:
1908 * NA
1909 *
1910 ***NOTE:
1911 * NA
1912 *
1913 * @param pMac Pointer to Global MAC structure
1914 * @param p80211Stats Statistics sent in response
1915 * @param resultCode TODO:
1916 *
1917 *
1918 * @return none
1919 */
1920
1921void
1922lim_send_sme_pe_statistics_rsp(tpAniSirGlobal pMac, uint16_t msgType, void *stats)
1923{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001924 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001925 uint8_t sessionId;
1926 tAniGetPEStatsRsp *pPeStats = (tAniGetPEStatsRsp *) stats;
1927 tpPESession pPeSessionEntry;
1928
1929 /* Get the Session Id based on Sta Id */
1930 pPeSessionEntry =
1931 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1932
1933 /* Fill the Session Id */
1934 if (NULL != pPeSessionEntry) {
1935 /* Fill the Session Id */
1936 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1937 }
1938
1939 pPeStats->msgType = eWNI_SME_GET_STATISTICS_RSP;
1940
1941 /* msgType should be WMA_GET_STATISTICS_RSP */
1942 mmhMsg.type = eWNI_SME_GET_STATISTICS_RSP;
1943
1944 mmhMsg.bodyptr = stats;
1945 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301946 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001947 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1948
1949 return;
1950
1951} /*** end lim_send_sme_pe_statistics_rsp() ***/
1952
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001953#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001954/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001955 * lim_send_sme_pe_ese_tsm_rsp() - send tsm response
1956 * @pMac: Pointer to global pMac structure
1957 * @pStats: Pointer to TSM Stats
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001958 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001959 * This function is called to send tsm stats response to HDD.
1960 * This function posts the result back to HDD. This is a response to
1961 * HDD's request to get tsm stats.
1962 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001963 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001964 */
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001965void lim_send_sme_pe_ese_tsm_rsp(tpAniSirGlobal pMac,
1966 tAniGetTsmStatsRsp *pStats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001967{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001968 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001969 uint8_t sessionId;
1970 tAniGetTsmStatsRsp *pPeStats = (tAniGetTsmStatsRsp *) pStats;
1971 tpPESession pPeSessionEntry = NULL;
1972
1973 /* Get the Session Id based on Sta Id */
1974 pPeSessionEntry =
1975 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1976
1977 /* Fill the Session Id */
1978 if (NULL != pPeSessionEntry) {
1979 /* Fill the Session Id */
1980 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1981 } else {
1982 PELOGE(lim_log
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001983 (pMac, LOGE, FL("Session not found for the Sta id(%d)"),
1984 pPeStats->staId);)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001985 return;
1986 }
1987
1988 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
1989 pPeStats->tsmMetrics.RoamingCount
1990 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
1991 pPeStats->tsmMetrics.RoamingDly
1992 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
1993
1994 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
1995 mmhMsg.bodyptr = pStats;
1996 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301997 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001998 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1999
2000 return;
2001} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
2002
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002003#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002004
2005void
2006lim_send_sme_ibss_peer_ind(tpAniSirGlobal pMac,
2007 tSirMacAddr peerMacAddr,
2008 uint16_t staIndex,
2009 uint8_t ucastIdx,
2010 uint8_t bcastIdx,
2011 uint8_t *beacon,
2012 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
2013{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002014 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002015 tSmeIbssPeerInd *pNewPeerInd;
2016
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302017 pNewPeerInd = qdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002018 if (NULL == pNewPeerInd) {
2019 PELOGE(lim_log(pMac, LOGE, FL("Failed to allocate memory"));)
2020 return;
2021 }
2022
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302023 qdf_mem_copy((uint8_t *) pNewPeerInd->peer_addr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302024 peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002025 pNewPeerInd->staId = staIndex;
2026 pNewPeerInd->ucastSig = ucastIdx;
2027 pNewPeerInd->bcastSig = bcastIdx;
2028 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
2029 pNewPeerInd->mesgType = msgType;
2030 pNewPeerInd->sessionId = sessionId;
2031
2032 if (beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302033 qdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002034 sizeof(tSmeIbssPeerInd)), (void *)beacon,
2035 beaconLen);
2036 }
2037
2038 mmhMsg.type = msgType;
2039 mmhMsg.bodyptr = pNewPeerInd;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302040 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002041 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2042
2043}
2044
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07002045/**
2046 * lim_process_csa_wbw_ie() - Process CSA Wide BW IE
2047 * @mac_ctx: pointer to global adapter context
2048 * @csa_params: pointer to CSA parameters
2049 * @chnl_switch_info:pointer to channel switch parameters
2050 * @session_entry: session pointer
2051 *
2052 * Return: None
2053 */
2054static void lim_process_csa_wbw_ie(tpAniSirGlobal mac_ctx,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002055 struct csa_offload_params *csa_params,
2056 tLimWiderBWChannelSwitchInfo *chnl_switch_info,
2057 tpPESession session_entry)
2058{
2059 struct ch_params_s ch_params = {0};
2060 uint8_t ap_new_ch_width;
2061 bool new_ch_width_dfn = false;
2062 uint8_t center_freq_diff;
2063
2064 ap_new_ch_width = csa_params->new_ch_width + 1;
2065 if ((ap_new_ch_width == CH_WIDTH_80MHZ) &&
2066 csa_params->new_ch_freq_seg2) {
2067 new_ch_width_dfn = true;
2068 if (csa_params->new_ch_freq_seg2 >
2069 csa_params->new_ch_freq_seg1)
2070 center_freq_diff = csa_params->new_ch_freq_seg2 -
2071 csa_params->new_ch_freq_seg1;
2072 else
2073 center_freq_diff = csa_params->new_ch_freq_seg1 -
2074 csa_params->new_ch_freq_seg2;
2075 if (center_freq_diff == CENTER_FREQ_DIFF_160MHz)
2076 ap_new_ch_width = CH_WIDTH_160MHZ;
2077 else if (center_freq_diff > CENTER_FREQ_DIFF_80P80MHz)
2078 ap_new_ch_width = CH_WIDTH_80P80MHZ;
2079 else
2080 ap_new_ch_width = CH_WIDTH_80MHZ;
2081 }
2082 session_entry->gLimChannelSwitch.state =
2083 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2084 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
2085 !new_ch_width_dfn) {
2086 ch_params.ch_width = CH_WIDTH_160MHZ;
2087 cds_set_channel_params(csa_params->channel, 0,
2088 &ch_params);
2089 ap_new_ch_width = ch_params.ch_width;
2090 csa_params->new_ch_freq_seg1 = ch_params.center_freq_seg0;
2091 csa_params->new_ch_freq_seg2 = ch_params.center_freq_seg1;
2092 }
2093 chnl_switch_info->newChanWidth = ap_new_ch_width;
2094 chnl_switch_info->newCenterChanFreq0 = csa_params->new_ch_freq_seg1;
2095 chnl_switch_info->newCenterChanFreq1 = csa_params->new_ch_freq_seg2;
2096
2097 if (session_entry->ch_width == ap_new_ch_width)
2098 goto prnt_log;
2099
2100 if (session_entry->ch_width == CH_WIDTH_80MHZ) {
2101 chnl_switch_info->newChanWidth = CH_WIDTH_80MHZ;
2102 chnl_switch_info->newCenterChanFreq1 = 0;
2103 } else {
2104 session_entry->ch_width = ap_new_ch_width;
2105 chnl_switch_info->newChanWidth = ap_new_ch_width;
2106 }
2107prnt_log:
2108 lim_log(mac_ctx, LOG1,
2109 FL("new channel: %d new_ch_width:%d seg0:%d seg1:%d"),
2110 csa_params->channel,
2111 chnl_switch_info->newChanWidth,
2112 chnl_switch_info->newCenterChanFreq0,
2113 chnl_switch_info->newCenterChanFreq1);
2114}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002115/**
2116 * lim_handle_csa_offload_msg() - Handle CSA offload message
2117 * @mac_ctx: pointer to global adapter context
2118 * @msg: Message pointer.
2119 *
2120 * Return: None
2121 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08002122void lim_handle_csa_offload_msg(tpAniSirGlobal mac_ctx,
2123 struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002124{
2125 tpPESession session_entry;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002126 struct scheduler_msg mmh_msg;
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302127 struct csa_offload_params *csa_params =
2128 (struct csa_offload_params *) (msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002129 tpSmeCsaOffloadInd csa_offload_ind;
2130 tpDphHashNode sta_ds = NULL;
2131 uint8_t session_id;
2132 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302133 uint16_t chan_space = 0;
Amar Singhale4f28ee2015-10-21 14:36:56 -07002134 struct ch_params_s ch_params;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302135
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002136 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002137 tLimChannelSwitchInfo *lim_ch_switch = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002138
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302139 lim_log(mac_ctx, LOG1, FL("handle csa offload msg"));
2140
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002141 if (!csa_params) {
2142 lim_log(mac_ctx, LOGE, FL("limMsgQ body ptr is NULL"));
2143 return;
2144 }
2145
2146 session_entry =
2147 pe_find_session_by_bssid(mac_ctx,
2148 csa_params->bssId, &session_id);
2149 if (!session_entry) {
2150 lim_log(mac_ctx, LOGE,
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302151 FL("Session does not exists for %pM"),
2152 csa_params->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002153 goto err;
2154 }
2155
2156 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
2157 &session_entry->dph.dphHashTable);
2158
2159 if (!sta_ds) {
2160 lim_log(mac_ctx, LOGE,
2161 FL("sta_ds does not exist"));
2162 goto err;
2163 }
2164
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002165 if (!LIM_IS_STA_ROLE(session_entry)) {
2166 lim_log(mac_ctx, LOG1, FL("Invalid role to handle CSA"));
2167 goto err;
2168 }
Masti, Narayanraddi1c630442015-11-02 12:03:50 +05302169
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002170 /*
2171 * on receiving channel switch announcement from AP, delete all
2172 * TDLS peers before leaving BSS and proceed for channel switch
2173 */
2174 lim_delete_tdls_peers(mac_ctx, session_entry);
Gupta, Kapil121bf212015-11-25 19:21:29 +05302175
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002176 lim_ch_switch = &session_entry->gLimChannelSwitch;
2177 session_entry->gLimChannelSwitch.switchMode =
2178 csa_params->switch_mode;
2179 /* timer already started by firmware, switch immediately */
2180 session_entry->gLimChannelSwitch.switchCount = 0;
2181 session_entry->gLimChannelSwitch.primaryChannel =
2182 csa_params->channel;
2183 session_entry->gLimChannelSwitch.state =
2184 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2185 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
2186 lim_ch_switch->sec_ch_offset =
2187 session_entry->htSecondaryChannelOffset;
2188 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
2189 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
2190 chnl_switch_info =
2191 &session_entry->gLimWiderBWChannelSwitch;
2192
2193 lim_log(mac_ctx, LOG1,
2194 FL("vht:%d ht:%d flag:%x chan:%d"),
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302195 session_entry->vhtCapability,
2196 session_entry->htSupportedChannelWidthSet,
2197 csa_params->ies_present_flag,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002198 csa_params->channel);
2199 lim_log(mac_ctx, LOG1,
2200 FL("seg1:%d seg2:%d width:%d country:%s class:%d"),
2201 csa_params->new_ch_freq_seg1,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302202 csa_params->new_ch_freq_seg2,
2203 csa_params->new_ch_width,
2204 mac_ctx->scan.countryCodeCurrent,
2205 csa_params->new_op_class);
2206
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002207 if (session_entry->vhtCapability &&
2208 session_entry->htSupportedChannelWidthSet) {
2209 if (csa_params->ies_present_flag & lim_wbw_ie_present) {
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07002210 lim_process_csa_wbw_ie(mac_ctx, csa_params,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002211 chnl_switch_info, session_entry);
2212 lim_ch_switch->sec_ch_offset =
2213 csa_params->sec_chan_offset;
2214 } else if (csa_params->ies_present_flag
2215 & lim_xcsa_ie_present) {
2216 chan_space =
2217 cds_reg_dmn_get_chanwidth_from_opclass(
2218 mac_ctx->scan.countryCodeCurrent,
2219 csa_params->channel,
2220 csa_params->new_op_class);
2221 session_entry->gLimChannelSwitch.state =
2222 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2223
2224 if (chan_space == 80) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002225 chnl_switch_info->newChanWidth =
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002226 CH_WIDTH_80MHZ;
2227 } else if (chan_space == 40) {
2228 chnl_switch_info->newChanWidth =
2229 CH_WIDTH_40MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002230 } else {
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002231 chnl_switch_info->newChanWidth =
2232 CH_WIDTH_20MHZ;
2233 lim_ch_switch->state =
2234 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2235 }
2236
2237 ch_params.ch_width =
2238 chnl_switch_info->newChanWidth;
2239 cds_set_channel_params(csa_params->channel,
2240 0, &ch_params);
2241 chnl_switch_info->newCenterChanFreq0 =
2242 ch_params.center_freq_seg0;
2243 /*
2244 * This is not applicable for 20/40/80 MHz.
2245 * Only used when we support 80+80 MHz operation.
2246 * In case of 80+80 MHz, this parameter indicates
2247 * center channel frequency index of 80 MHz
2248 * channel offrequency segment 1.
2249 */
2250 chnl_switch_info->newCenterChanFreq1 =
2251 ch_params.center_freq_seg1;
2252 lim_ch_switch->sec_ch_offset =
2253 ch_params.sec_ch_offset;
2254
2255 }
2256 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
2257 chnl_switch_info->newCenterChanFreq0;
2258 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
2259 chnl_switch_info->newCenterChanFreq1;
2260 session_entry->gLimChannelSwitch.ch_width =
2261 chnl_switch_info->newChanWidth;
2262
2263 } else if (session_entry->htSupportedChannelWidthSet) {
2264 if (csa_params->ies_present_flag
2265 & lim_xcsa_ie_present) {
2266 chan_space =
2267 cds_reg_dmn_get_chanwidth_from_opclass(
2268 mac_ctx->scan.countryCodeCurrent,
2269 csa_params->channel,
2270 csa_params->new_op_class);
2271 lim_ch_switch->state =
2272 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2273 if (chan_space == 40) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002274 lim_ch_switch->ch_width =
2275 CH_WIDTH_40MHZ;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002276 chnl_switch_info->newChanWidth =
2277 CH_WIDTH_40MHZ;
2278 ch_params.ch_width =
2279 chnl_switch_info->newChanWidth;
2280 cds_set_channel_params(
2281 csa_params->channel,
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07002282 0, &ch_params);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002283 lim_ch_switch->ch_center_freq_seg0 =
2284 ch_params.center_freq_seg0;
2285 lim_ch_switch->sec_ch_offset =
2286 ch_params.sec_ch_offset;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002287 } else {
2288 lim_ch_switch->ch_width =
2289 CH_WIDTH_20MHZ;
2290 chnl_switch_info->newChanWidth =
2291 CH_WIDTH_40MHZ;
2292 lim_ch_switch->state =
2293 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2294 lim_ch_switch->sec_ch_offset =
2295 PHY_SINGLE_CHANNEL_CENTERED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002296 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002297 } else {
2298 lim_ch_switch->ch_width =
2299 CH_WIDTH_40MHZ;
2300 lim_ch_switch->state =
2301 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2302 ch_params.ch_width = CH_WIDTH_40MHZ;
2303 cds_set_channel_params(csa_params->channel,
2304 0, &ch_params);
2305 lim_ch_switch->ch_center_freq_seg0 =
2306 ch_params.center_freq_seg0;
2307 lim_ch_switch->sec_ch_offset =
2308 ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002309 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002310
2311 }
2312 lim_log(mac_ctx, LOG1, FL("new ch width = %d space:%d"),
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302313 session_entry->gLimChannelSwitch.ch_width, chan_space);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002314
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002315 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
2316 csa_offload_ind = qdf_mem_malloc(sizeof(tSmeCsaOffloadInd));
2317 if (NULL == csa_offload_ind) {
2318 lim_log(mac_ctx, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002319 FL("memalloc fail eWNI_SME_CSA_OFFLOAD_EVENT"));
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002320 goto err;
2321 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002322
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002323 csa_offload_ind->mesgType = eWNI_SME_CSA_OFFLOAD_EVENT;
2324 csa_offload_ind->mesgLen = sizeof(tSmeCsaOffloadInd);
2325 qdf_mem_copy(csa_offload_ind->bssid.bytes, session_entry->bssId,
2326 QDF_MAC_ADDR_SIZE);
2327 mmh_msg.type = eWNI_SME_CSA_OFFLOAD_EVENT;
2328 mmh_msg.bodyptr = csa_offload_ind;
2329 mmh_msg.bodyval = 0;
2330 lim_log(mac_ctx, LOG1,
Srinivas Girigowdac9148f72015-11-25 12:42:32 -08002331 FL("Sending eWNI_SME_CSA_OFFLOAD_EVENT to SME."));
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002332 MTRACE(mac_trace_msg_tx
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002333 (mac_ctx, session_entry->peSessionId, mmh_msg.type));
2334#ifdef FEATURE_WLAN_DIAG_SUPPORT
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002335 lim_diag_event_report(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002336 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
2337 eSIR_SUCCESS, eSIR_SUCCESS);
2338#endif
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002339 lim_sys_process_mmh_msg_api(mac_ctx, &mmh_msg, ePROT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002340
2341err:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302342 qdf_mem_free(csa_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002343}
2344
2345/*--------------------------------------------------------------------------
2346 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
2347
2348 \param pMac - pointer to global adapter context
2349 \param sessionId - Message pointer.
2350
2351 \sa
2352 --------------------------------------------------------------------------*/
2353
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002354void lim_handle_delete_bss_rsp(tpAniSirGlobal pMac, struct scheduler_msg *MsgQ)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002355{
2356 tpPESession psessionEntry;
2357 tpDeleteBssParams pDelBss = (tpDeleteBssParams) (MsgQ->bodyptr);
2358
2359 psessionEntry =
2360 pe_find_session_by_session_id(pMac, pDelBss->sessionId);
2361 if (psessionEntry == NULL) {
2362 lim_log(pMac, LOGE,
2363 FL("Session Does not exist for given sessionID %d"),
2364 pDelBss->sessionId);
Naveen Rawat0c81edc2016-06-08 10:08:30 -07002365 qdf_mem_free(MsgQ->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002366 return;
2367 }
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002368 /*
2369 * During DEL BSS handling, the PE Session will be deleted, but it is
2370 * better to clear this flag if the session is hanging around due
2371 * to some error conditions so that the next DEL_BSS request does
2372 * not take the HO_FAIL path
2373 */
2374 psessionEntry->process_ho_fail = false;
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002375 if (LIM_IS_IBSS_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002376 lim_ibss_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002377 else if (LIM_IS_UNKNOWN_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002378 lim_process_sme_del_bss_rsp(pMac, MsgQ->bodyval, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002379 else if (LIM_IS_NDI_ROLE(psessionEntry))
2380 lim_ndi_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002381 else
2382 lim_process_mlm_del_bss_rsp(pMac, MsgQ, psessionEntry);
2383
2384}
2385
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002386/** -----------------------------------------------------------------
2387 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
2388 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
2389 \ SME only looks at rc and tspec field.
2390 \param pMac - global mac structure
2391 \param rspReqd - is SmeAddTsRsp required
2392 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
2393 \return tspec
2394 \sa
2395 ----------------------------------------------------------------- */
2396void
2397lim_send_sme_aggr_qos_rsp(tpAniSirGlobal pMac, tpSirAggrQosRsp aggrQosRsp,
2398 uint8_t smesessionId)
2399{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002400 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002401
2402 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
2403 mmhMsg.bodyptr = aggrQosRsp;
2404 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302405 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2406 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002407 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2408
2409 return;
2410}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002411
2412void lim_send_sme_max_assoc_exceeded_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
2413 uint8_t smesessionId)
2414{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002415 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002416 tSmeMaxAssocInd *pSmeMaxAssocInd;
2417
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302418 pSmeMaxAssocInd = qdf_mem_malloc(sizeof(tSmeMaxAssocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002419 if (NULL == pSmeMaxAssocInd) {
2420 PELOGE(lim_log(pMac, LOGE, FL("Failed to allocate memory"));)
2421 return;
2422 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302423 qdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peer_mac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302424 (uint8_t *) peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002425 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
2426 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
2427 pSmeMaxAssocInd->sessionId = smesessionId;
2428 mmhMsg.type = pSmeMaxAssocInd->mesgType;
2429 mmhMsg.bodyptr = pSmeMaxAssocInd;
2430 PELOG1(lim_log(pMac, LOG1, FL("msgType %s peerMacAddr " MAC_ADDRESS_STR
2431 " sme session id %d"),
2432 "eWNI_SME_MAX_ASSOC_EXCEEDED",
2433 MAC_ADDR_ARRAY(peerMacAddr));
2434 )
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302435 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2436 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002437 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2438
2439 return;
2440}
2441
2442/** -----------------------------------------------------------------
2443 \brief lim_send_sme_dfs_event_notify() - sends
2444 eWNI_SME_DFS_RADAR_FOUND
2445 After receiving WMI_PHYERR_EVENTID indication frame from FW, this
2446 function sends a eWNI_SME_DFS_RADAR_FOUND to SME to notify
2447 that a RADAR is found on current operating channel and SAP-
2448 has to move to a new channel.
2449 \param pMac - global mac structure
2450 \param msgType - message type received from lower layer
2451 \param event - event data received from lower layer
2452 \return none
2453 \sa
2454 ----------------------------------------------------------------- */
2455void
2456lim_send_sme_dfs_event_notify(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2457{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002458 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002459 mmhMsg.type = eWNI_SME_DFS_RADAR_FOUND;
2460 mmhMsg.bodyptr = event;
2461 mmhMsg.bodyval = 0;
2462 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2463 return;
2464}
2465
2466/*--------------------------------------------------------------------------
2467 \brief lim_send_dfs_chan_sw_ie_update()
2468 This timer handler updates the channel switch IE in beacon template
2469
2470 \param pMac - pointer to global adapter context
2471 \return - channel to scan from valid session else zero.
2472 \sa
2473 --------------------------------------------------------------------------*/
2474static void
2475lim_send_dfs_chan_sw_ie_update(tpAniSirGlobal pMac, tpPESession psessionEntry)
2476{
2477
2478 /* Update the beacon template and send to FW */
2479 if (sch_set_fixed_beacon_fields(pMac, psessionEntry) != eSIR_SUCCESS) {
2480 PELOGE(lim_log(pMac, LOGE, FL("Unable to set CSA IE in beacon"));)
2481 return;
2482 }
2483
2484 /* Send update beacon template message */
2485 lim_send_beacon_ind(pMac, psessionEntry);
2486 PELOG1(lim_log(pMac, LOG1,
2487 FL(" Updated CSA IE, IE COUNT = %d"),
2488 psessionEntry->gLimChannelSwitch.switchCount);
2489 )
2490
2491 return;
2492}
2493
2494/** -----------------------------------------------------------------
2495 \brief lim_send_sme_ap_channel_switch_resp() - sends
2496 eWNI_SME_CHANNEL_CHANGE_RSP
2497 After receiving WMA_SWITCH_CHANNEL_RSP indication this
2498 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
2499 that the Channel change has been done to the specified target
2500 channel in the Channel change request
2501 \param pMac - global mac structure
2502 \param psessionEntry - session info
2503 \param pChnlParams - Channel switch params
2504 --------------------------------------------------------------------*/
2505void
2506lim_send_sme_ap_channel_switch_resp(tpAniSirGlobal pMac,
2507 tpPESession psessionEntry,
2508 tpSwitchChannelParams pChnlParams)
2509{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002510 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002511 tpSwitchChannelParams pSmeSwithChnlParams;
2512 uint8_t channelId;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002513 bool is_ch_dfs = false;
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08002514 enum phy_ch_width ch_width;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002515 uint8_t ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002516
2517 pSmeSwithChnlParams = (tSwitchChannelParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302518 qdf_mem_malloc(sizeof(tSwitchChannelParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002519 if (NULL == pSmeSwithChnlParams) {
2520 lim_log(pMac, LOGP,
2521 FL("AllocateMemory failed for pSmeSwithChnlParams\n"));
2522 return;
2523 }
2524
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302525 qdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002526 sizeof(tSwitchChannelParams));
2527
2528 channelId = pSmeSwithChnlParams->channelNumber;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002529 ch_width = pSmeSwithChnlParams->ch_width;
2530 ch_center_freq_seg1 = pSmeSwithChnlParams->ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002531
2532 /*
2533 * Pass the sme sessionID to SME instead
2534 * PE session ID.
2535 */
2536 pSmeSwithChnlParams->peSessionId = psessionEntry->smeSessionId;
2537
2538 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
2539 mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
2540 mmhMsg.bodyval = 0;
2541 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2542
2543 /*
2544 * We should start beacon transmission only if the new
2545 * channel after channel change is Non-DFS. For a DFS
2546 * channel, PE will receive an explicit request from
2547 * upper layers to start the beacon transmission .
2548 */
2549
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002550 if (ch_width == CH_WIDTH_160MHZ) {
2551 is_ch_dfs = true;
2552 } else if (ch_width == CH_WIDTH_80P80MHZ) {
2553 if (cds_get_channel_state(channelId) == CHANNEL_STATE_DFS ||
2554 cds_get_channel_state(ch_center_freq_seg1 -
2555 SIR_80MHZ_START_CENTER_CH_DIFF) ==
2556 CHANNEL_STATE_DFS)
2557 is_ch_dfs = true;
2558 } else {
2559 if (cds_get_channel_state(channelId) == CHANNEL_STATE_DFS)
2560 is_ch_dfs = true;
2561 }
2562
2563 if (!is_ch_dfs) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002564 if (channelId == psessionEntry->currentOperChannel) {
2565 lim_apply_configuration(pMac, psessionEntry);
2566 lim_send_beacon_ind(pMac, psessionEntry);
2567 } else {
2568 PELOG1(lim_log(pMac, LOG1,
2569 FL
2570 ("Failed to Transmit Beacons on channel = %d"
2571 "after AP channel change response"),
2572 psessionEntry->bcnLen);
2573 )
2574 }
2575 }
2576 return;
2577}
2578
2579/** -----------------------------------------------------------------
2580 \brief lim_process_beacon_tx_success_ind() - This function is used
2581 explicitely to handle successful beacon transmission indication
2582 from the FW. This is a generic event generated by the FW afer the
2583 first beacon is sent out after the beacon template update by the
2584 host
2585 \param pMac - global mac structure
2586 \param psessionEntry - session info
2587 \return none
2588 \sa
2589 ----------------------------------------------------------------- */
2590void
2591lim_process_beacon_tx_success_ind(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2592{
2593 /* Currently, this event is used only for DFS channel switch announcement
2594 * IE update in the template. If required to be used for other IE updates
2595 * add appropriate code by introducing a state variable
2596 */
2597 tpPESession psessionEntry;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002598 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002599 tSirSmeCSAIeTxCompleteRsp *pChanSwTxResponse;
2600 struct sir_beacon_tx_complete_rsp *beacon_tx_comp_rsp_ptr;
2601 uint8_t length = sizeof(tSirSmeCSAIeTxCompleteRsp);
2602 tpSirFirstBeaconTxCompleteInd pBcnTxInd =
2603 (tSirFirstBeaconTxCompleteInd *) event;
2604
2605 psessionEntry = pe_find_session_by_bss_idx(pMac, pBcnTxInd->bssIdx);
2606 if (psessionEntry == NULL) {
2607 lim_log(pMac, LOGE,
2608 FL("Session Does not exist for given sessionID"));
2609 return;
2610 }
2611
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302612 lim_log(pMac, LOG1, FL("role:%d swIe:%d opIe:%d"),
2613 GET_LIM_SYSTEM_ROLE(psessionEntry),
2614 psessionEntry->dfsIncludeChanSwIe,
2615 psessionEntry->gLimOperatingMode.present);
2616
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002617 if (LIM_IS_AP_ROLE(psessionEntry) &&
2618 true == psessionEntry->dfsIncludeChanSwIe) {
2619 /* Send only 5 beacons with CSA IE Set in when a radar is detected */
2620 if (psessionEntry->gLimChannelSwitch.switchCount > 0) {
2621 /*
2622 * Send the next beacon with updated CSA IE count
2623 */
2624 lim_send_dfs_chan_sw_ie_update(pMac, psessionEntry);
2625 /* Decrement the IE count */
2626 psessionEntry->gLimChannelSwitch.switchCount--;
2627 } else {
2628 /* Done with CSA IE update, send response back to SME */
2629 psessionEntry->gLimChannelSwitch.switchCount = 0;
2630 if (pMac->sap.SapDfsInfo.disable_dfs_ch_switch == false)
2631 psessionEntry->gLimChannelSwitch.switchMode = 0;
2632 psessionEntry->dfsIncludeChanSwIe = false;
2633 psessionEntry->dfsIncludeChanWrapperIe = false;
2634
2635 pChanSwTxResponse = (tSirSmeCSAIeTxCompleteRsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302636 qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002637
2638 if (NULL == pChanSwTxResponse) {
2639 lim_log(pMac, LOGP,
2640 FL
2641 ("AllocateMemory failed for tSirSmeCSAIeTxCompleteRsp"));
2642 return;
2643 }
2644
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002645 pChanSwTxResponse->sessionId =
2646 psessionEntry->smeSessionId;
2647 pChanSwTxResponse->chanSwIeTxStatus =
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302648 QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002649
2650 mmhMsg.type = eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND;
2651 mmhMsg.bodyptr = pChanSwTxResponse;
2652 mmhMsg.bodyval = 0;
2653 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2654 }
2655 }
2656
2657 if (LIM_IS_AP_ROLE(psessionEntry) &&
2658 psessionEntry->gLimOperatingMode.present) {
2659 /* Done with nss update, send response back to SME */
2660 psessionEntry->gLimOperatingMode.present = 0;
2661 beacon_tx_comp_rsp_ptr = (struct sir_beacon_tx_complete_rsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302662 qdf_mem_malloc(sizeof(*beacon_tx_comp_rsp_ptr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002663 if (NULL == beacon_tx_comp_rsp_ptr) {
2664 lim_log(pMac, LOGP,
2665 FL
2666 ("AllocateMemory failed for beacon_tx_comp_rsp_ptr"));
2667 return;
2668 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002669 beacon_tx_comp_rsp_ptr->session_id =
2670 psessionEntry->smeSessionId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302671 beacon_tx_comp_rsp_ptr->tx_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002672 mmhMsg.type = eWNI_SME_NSS_UPDATE_RSP;
2673 mmhMsg.bodyptr = beacon_tx_comp_rsp_ptr;
2674 mmhMsg.bodyval = 0;
2675 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2676 }
2677 return;
2678}