blob: b3dadbae84157e528694f3ee89e271847acd630d [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,
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301280 uint32_t sme_session_id,
1281 uint32_t txCompleteStatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001282{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001283 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001284 tSirMgmtTxCompletionInd *pSirMgmtTxCompletionInd;
1285
1286 pSirMgmtTxCompletionInd =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301287 qdf_mem_malloc(sizeof(tSirMgmtTxCompletionInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001288 if (NULL == pSirMgmtTxCompletionInd) {
1289 lim_log(pMac, LOGP,
1290 FL
1291 ("AllocateMemory failed for eWNI_SME_MGMT_FRM_TX_COMPLETION_IND"));
1292 return;
1293 }
1294 /* messageType */
1295 pSirMgmtTxCompletionInd->messageType =
1296 eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1297 pSirMgmtTxCompletionInd->length = sizeof(tSirMgmtTxCompletionInd);
1298
1299 /* sessionId */
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301300 pSirMgmtTxCompletionInd->sessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001301
1302 pSirMgmtTxCompletionInd->txCompleteStatus = txCompleteStatus;
1303
1304 mmhMsg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1305 mmhMsg.bodyptr = pSirMgmtTxCompletionInd;
1306 mmhMsg.bodyval = 0;
1307
1308 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1309 return;
1310} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1311
1312void lim_send_sme_tdls_event_notify(tpAniSirGlobal pMac, uint16_t msgType,
1313 void *events)
1314{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001315 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001316
1317 switch (msgType) {
1318 case SIR_HAL_TDLS_SHOULD_DISCOVER:
1319 mmhMsg.type = eWNI_SME_TDLS_SHOULD_DISCOVER;
1320 break;
1321 case SIR_HAL_TDLS_SHOULD_TEARDOWN:
1322 mmhMsg.type = eWNI_SME_TDLS_SHOULD_TEARDOWN;
1323 break;
1324 case SIR_HAL_TDLS_PEER_DISCONNECTED:
1325 mmhMsg.type = eWNI_SME_TDLS_PEER_DISCONNECTED;
1326 break;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07001327 case SIR_HAL_TDLS_CONNECTION_TRACKER_NOTIFICATION:
1328 mmhMsg.type = eWNI_SME_TDLS_CONNECTION_TRACKER_NOTIFICATION;
1329 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001330 }
1331
1332 mmhMsg.bodyptr = events;
1333 mmhMsg.bodyval = 0;
1334 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1335 return;
1336}
1337#endif /* FEATURE_WLAN_TDLS */
1338
1339/**
1340 * lim_send_sme_deauth_ntf()
1341 *
1342 ***FUNCTION:
1343 * This function is called by limProcessSmeMessages() to send
1344 * eWNI_SME_DISASSOC_RSP/IND message to host
1345 *
1346 ***PARAMS:
1347 *
1348 ***LOGIC:
1349 *
1350 ***ASSUMPTIONS:
1351 * NA
1352 *
1353 ***NOTE:
1354 * This function is used for sending eWNI_SME_DEAUTH_CNF or
1355 * eWNI_SME_DEAUTH_IND to host depending on deauthentication trigger.
1356 *
1357 * @param peerMacAddr Indicates the peer MAC addr to which
1358 * deauthentication was initiated
1359 * @param reasonCode Indicates the reason for Deauthetication
1360 * @param deauthTrigger Indicates the trigger for Deauthetication
1361 * @param aid Indicates the STAID. This parameter is present
1362 * only on AP.
1363 *
1364 * @return None
1365 */
1366void
1367lim_send_sme_deauth_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
1368 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1369 uint16_t aid, uint8_t smesessionId,
1370 uint16_t smetransactionId)
1371{
1372 uint8_t *pBuf;
1373 tSirSmeDeauthRsp *pSirSmeDeauthRsp;
1374 tSirSmeDeauthInd *pSirSmeDeauthInd;
1375 tpPESession psessionEntry;
1376 uint8_t sessionId;
1377 uint32_t *pMsg;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301378 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001379
1380 psessionEntry = pe_find_session_by_bssid(pMac, peerMacAddr, &sessionId);
1381 switch (deauthTrigger) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001382 case eLIM_HOST_DEAUTH:
1383 /**
1384 * Deauthentication response to host triggered
1385 * deauthentication.
1386 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301387 pSirSmeDeauthRsp = qdf_mem_malloc(sizeof(tSirSmeDeauthRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001388 if (NULL == pSirSmeDeauthRsp) {
1389 /* Log error */
1390 lim_log(pMac, LOGP,
1391 FL
1392 ("call to AllocateMemory failed for eWNI_SME_DEAUTH_RSP"));
1393
1394 return;
1395 }
1396 lim_log(pMac, LOG1, FL("send eWNI_SME_DEAUTH_RSP with "
1397 "retCode: %d for" MAC_ADDRESS_STR),
1398 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1399 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
1400 pSirSmeDeauthRsp->length = sizeof(tSirSmeDeauthRsp);
1401 pSirSmeDeauthRsp->statusCode = reasonCode;
1402 pSirSmeDeauthRsp->sessionId = smesessionId;
1403 pSirSmeDeauthRsp->transactionId = smetransactionId;
1404
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -08001405 pBuf = (uint8_t *) pSirSmeDeauthRsp->peer_macaddr.bytes;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301406 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001407
1408#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1409 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
1410 psessionEntry, 0, (uint16_t) reasonCode);
1411#endif
1412 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1413
1414 break;
1415
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301416 case eLIM_PEER_ENTITY_DEAUTH:
1417 case eLIM_LINK_MONITORING_DEAUTH:
1418 sir_sme_dis_ind =
1419 qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
1420 if (!sir_sme_dis_ind) {
1421 lim_log(pMac, LOGE,
1422 FL("call to AllocateMemory failed for disconnect indication"));
1423 return;
1424 }
1425
1426 lim_log(pMac, LOG1,
1427 FL("send eWNI_SME_DISCONNECT_DONE_IND withretCode: %d"),
1428 reasonCode);
1429
1430 sir_sme_dis_ind->message_type =
1431 eWNI_SME_DISCONNECT_DONE_IND;
1432 sir_sme_dis_ind->length =
1433 sizeof(*sir_sme_dis_ind);
1434 sir_sme_dis_ind->session_id = smesessionId;
1435 sir_sme_dis_ind->reason_code = reasonCode;
1436 qdf_mem_copy(sir_sme_dis_ind->peer_mac, peerMacAddr,
1437 ETH_ALEN);
Selvaraj, Sridharc7d80892016-09-29 11:56:45 +05301438 /*
1439 * Instead of sending deauth reason code as 505 which is
1440 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1441 * Send reason code as zero to Supplicant
1442 */
1443 if (reasonCode == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1444 sir_sme_dis_ind->reason_code = 0;
1445 else
1446 sir_sme_dis_ind->reason_code = reasonCode;
1447
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301448 pMsg = (uint32_t *)sir_sme_dis_ind;
1449
1450 break;
1451
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001452 default:
1453 /**
1454 * Deauthentication indication due to Deauthentication
1455 * frame reception from peer entity or due to
1456 * loss of link with peer entity.
1457 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301458 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001459 if (NULL == pSirSmeDeauthInd) {
1460 /* Log error */
1461 lim_log(pMac, LOGP,
1462 FL
1463 ("call to AllocateMemory failed for eWNI_SME_DEAUTH_Ind"));
1464
1465 return;
1466 }
1467 lim_log(pMac, LOG1, FL("send eWNI_SME_DEAUTH_IND with "
1468 "retCode: %d for " MAC_ADDRESS_STR),
1469 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1470 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1471 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1472 pSirSmeDeauthInd->reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
1473
1474 /* sessionId */
1475 pBuf = (uint8_t *) &pSirSmeDeauthInd->sessionId;
1476 *pBuf++ = smesessionId;
1477
1478 /* transaction ID */
1479 lim_copy_u16(pBuf, smetransactionId);
1480 pBuf += sizeof(uint16_t);
1481
1482 /* status code */
1483 lim_copy_u32(pBuf, reasonCode);
1484 pBuf += sizeof(tSirResultCodes);
1485
1486 /* bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301487 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001488 pBuf += sizeof(tSirMacAddr);
1489
1490 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301491 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301492 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001493
1494#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1495 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
1496 psessionEntry, 0, (uint16_t) reasonCode);
1497#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1498 pMsg = (uint32_t *) pSirSmeDeauthInd;
1499
1500 break;
1501 }
1502
1503 /*Delete the PE session created */
1504 if (psessionEntry != NULL) {
1505 pe_delete_session(pMac, psessionEntry);
1506 }
1507
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301508 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001509 (uint32_t *) pMsg);
1510
1511} /*** end lim_send_sme_deauth_ntf() ***/
1512
1513/**
1514 * lim_send_sme_wm_status_change_ntf() - Send Notification
1515 * @mac_ctx: Global MAC Context
1516 * @status_change_code: Indicates the change in the wireless medium.
1517 * @status_change_info: Indicates the information associated with
1518 * change in the wireless medium.
1519 * @info_len: Indicates the length of status change information
1520 * being sent.
1521 * @session_id SessionID
1522 *
1523 * This function is called by limProcessSmeMessages() to send
1524 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1525 *
1526 * Return: None
1527 */
1528void
1529lim_send_sme_wm_status_change_ntf(tpAniSirGlobal mac_ctx,
1530 tSirSmeStatusChangeCode status_change_code,
1531 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1532{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001533 struct scheduler_msg msg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001534 tSirSmeWmStatusChangeNtf *wm_status_change_ntf;
Naveen Rawate01ed172016-11-17 11:34:50 -08001535 uint32_t max_info_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001536
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301537 wm_status_change_ntf = qdf_mem_malloc(sizeof(tSirSmeWmStatusChangeNtf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001538 if (NULL == wm_status_change_ntf) {
1539 lim_log(mac_ctx, LOGE,
1540 FL("Mem Alloc failed - eWNI_SME_WM_STATUS_CHANGE_NTF"));
1541 return;
1542 }
1543
1544 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1545 msg.bodyval = 0;
1546 msg.bodyptr = wm_status_change_ntf;
1547
1548 switch (status_change_code) {
Naveen Rawate01ed172016-11-17 11:34:50 -08001549 case eSIR_SME_AP_CAPS_CHANGED:
1550 max_info_len = sizeof(tSirSmeApNewCaps);
1551 break;
1552 case eSIR_SME_JOINED_NEW_BSS:
1553 max_info_len = sizeof(tSirSmeNewBssInfo);
1554 break;
1555 default:
1556 max_info_len = sizeof(wm_status_change_ntf->statusChangeInfo);
1557 break;
1558 }
1559
1560 switch (status_change_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001561 case eSIR_SME_RADAR_DETECTED:
1562 break;
1563 default:
1564 wm_status_change_ntf->messageType =
1565 eWNI_SME_WM_STATUS_CHANGE_NTF;
1566 wm_status_change_ntf->statusChangeCode = status_change_code;
1567 wm_status_change_ntf->length = sizeof(tSirSmeWmStatusChangeNtf);
1568 wm_status_change_ntf->sessionId = session_id;
Naveen Rawate01ed172016-11-17 11:34:50 -08001569 if (info_len <= max_info_len && status_change_info) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301570 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001571 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1572 (uint8_t *) status_change_info, info_len);
1573 }
1574 lim_log(mac_ctx, LOGE,
1575 FL("**---** StatusChg: code 0x%x, length %d **---**"),
1576 status_change_code, info_len);
1577 break;
1578 }
1579
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301580 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001581 if (eSIR_SUCCESS != lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301582 qdf_mem_free(wm_status_change_ntf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001583 lim_log(mac_ctx, LOGP,
1584 FL("lim_sys_process_mmh_msg_api failed"));
1585 }
1586
1587} /*** end lim_send_sme_wm_status_change_ntf() ***/
1588
1589/**
1590 * lim_send_sme_set_context_rsp()
1591 *
1592 ***FUNCTION:
1593 * This function is called by limProcessSmeMessages() to send
1594 * eWNI_SME_SETCONTEXT_RSP message to host
1595 *
1596 ***PARAMS:
1597 *
1598 ***LOGIC:
1599 *
1600 ***ASSUMPTIONS:
1601 * NA
1602 *
1603 ***NOTE:
1604 *
1605 * @param pMac Pointer to Global MAC structure
1606 * @param peerMacAddr Indicates the peer MAC addr to which
1607 * setContext was performed
1608 * @param aid Indicates the aid corresponding to the peer MAC
1609 * address
1610 * @param resultCode Indicates the result of previously issued
1611 * eWNI_SME_SETCONTEXT_RSP message
1612 *
1613 * @return None
1614 */
1615void
1616lim_send_sme_set_context_rsp(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301617 struct qdf_mac_addr peer_macaddr, uint16_t aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001618 tSirResultCodes resultCode,
1619 tpPESession psessionEntry, uint8_t smesessionId,
1620 uint16_t smetransactionId)
1621{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001622 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001623 tSirSmeSetContextRsp *pSirSmeSetContextRsp;
1624
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301625 pSirSmeSetContextRsp = qdf_mem_malloc(sizeof(tSirSmeSetContextRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001626 if (NULL == pSirSmeSetContextRsp) {
1627 /* Log error */
1628 lim_log(pMac, LOGP,
1629 FL
1630 ("call to AllocateMemory failed for SmeSetContextRsp"));
1631
1632 return;
1633 }
1634
1635 pSirSmeSetContextRsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1636 pSirSmeSetContextRsp->length = sizeof(tSirSmeSetContextRsp);
1637 pSirSmeSetContextRsp->statusCode = resultCode;
1638
Anurag Chouhanc5548422016-02-24 18:33:27 +05301639 qdf_copy_macaddr(&pSirSmeSetContextRsp->peer_macaddr, &peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001640
1641 /* Update SME session and transaction Id */
1642 pSirSmeSetContextRsp->sessionId = smesessionId;
1643 pSirSmeSetContextRsp->transactionId = smetransactionId;
1644
1645 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
1646 mmhMsg.bodyptr = pSirSmeSetContextRsp;
1647 mmhMsg.bodyval = 0;
1648 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301649 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1650 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001651 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301652 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1653 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001654 }
1655
1656#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1657 lim_diag_event_report(pMac, WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
1658 psessionEntry, (uint16_t) resultCode, 0);
1659#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1660
1661 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1662} /*** end lim_send_sme_set_context_rsp() ***/
1663
1664/**
1665 * lim_send_sme_neighbor_bss_ind()
1666 *
1667 ***FUNCTION:
1668 * This function is called by lim_lookup_nadd_hash_entry() to send
1669 * eWNI_SME_NEIGHBOR_BSS_IND message to host
1670 *
1671 ***PARAMS:
1672 *
1673 ***LOGIC:
1674 *
1675 ***ASSUMPTIONS:
1676 * NA
1677 *
1678 ***NOTE:
1679 * This function is used for sending eWNI_SME_NEIGHBOR_BSS_IND to
1680 * host upon detecting new BSS during background scanning if CFG
1681 * option is enabled for sending such indication
1682 *
1683 * @param pMac - Pointer to Global MAC structure
1684 * @return None
1685 */
1686
1687void
1688lim_send_sme_neighbor_bss_ind(tpAniSirGlobal pMac, tLimScanResultNode *pBssDescr)
1689{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001690 struct scheduler_msg msgQ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001691 uint32_t val;
1692 tSirSmeNeighborBssInd *pNewBssInd;
1693
1694 if ((pMac->lim.gLimSmeState != eLIM_SME_LINK_EST_WT_SCAN_STATE) ||
1695 ((pMac->lim.gLimSmeState == eLIM_SME_LINK_EST_WT_SCAN_STATE) &&
1696 pMac->lim.gLimRspReqd)) {
1697 /* LIM is not in background scan state OR */
1698 /* current scan is initiated by HDD. */
1699 /* No need to send new BSS indication to HDD */
1700 return;
1701 }
1702
1703 if (wlan_cfg_get_int(pMac, WNI_CFG_NEW_BSS_FOUND_IND, &val) !=
1704 eSIR_SUCCESS) {
1705 lim_log(pMac, LOGP,
1706 FL("could not get NEIGHBOR_BSS_IND from CFG"));
1707
1708 return;
1709 }
1710
1711 if (val == 0)
1712 return;
1713
1714 /**
1715 * Need to indicate new BSSs found during
1716 * background scanning to host.
1717 * Allocate buffer for sending indication.
1718 * Length of buffer is length of BSS description
1719 * and length of header itself
1720 */
1721 val = pBssDescr->bssDescription.length + sizeof(uint16_t) +
1722 sizeof(uint32_t) + sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301723 pNewBssInd = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001724 if (NULL == pNewBssInd) {
1725 /* Log error */
1726 lim_log(pMac, LOGP,
1727 FL
1728 ("call to AllocateMemory failed for eWNI_SME_NEIGHBOR_BSS_IND"));
1729
1730 return;
1731 }
1732
1733 pNewBssInd->messageType = eWNI_SME_NEIGHBOR_BSS_IND;
1734 pNewBssInd->length = (uint16_t) val;
1735 pNewBssInd->sessionId = 0;
1736
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301737 qdf_mem_copy((uint8_t *) pNewBssInd->bssDescription,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001738 (uint8_t *) &pBssDescr->bssDescription,
1739 pBssDescr->bssDescription.length + sizeof(uint16_t));
1740
1741 msgQ.type = eWNI_SME_NEIGHBOR_BSS_IND;
1742 msgQ.bodyptr = pNewBssInd;
1743 msgQ.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301744 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, msgQ.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001745 lim_sys_process_mmh_msg_api(pMac, &msgQ, ePROT);
1746} /*** end lim_send_sme_neighbor_bss_ind() ***/
1747
1748/** -----------------------------------------------------------------
1749 \brief lim_send_sme_addts_rsp() - sends SME ADDTS RSP
1750 \ This function sends a eWNI_SME_ADDTS_RSP to SME.
1751 \ SME only looks at rc and tspec field.
1752 \param pMac - global mac structure
1753 \param rspReqd - is SmeAddTsRsp required
1754 \param status - status code of SME_ADD_TS_RSP
1755 \return tspec
1756 \sa
1757 ----------------------------------------------------------------- */
1758void
1759lim_send_sme_addts_rsp(tpAniSirGlobal pMac, uint8_t rspReqd, uint32_t status,
1760 tpPESession psessionEntry, tSirMacTspecIE tspec,
1761 uint8_t smesessionId, uint16_t smetransactionId)
1762{
1763 tpSirAddtsRsp rsp;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001764 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001765
1766 if (!rspReqd)
1767 return;
1768
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301769 rsp = qdf_mem_malloc(sizeof(tSirAddtsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001770 if (NULL == rsp) {
1771 lim_log(pMac, LOGP, FL("AllocateMemory failed for ADDTS_RSP"));
1772 return;
1773 }
1774
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001775 rsp->messageType = eWNI_SME_ADDTS_RSP;
1776 rsp->rc = status;
1777 rsp->rsp.status = (enum eSirMacStatusCodes)status;
1778 rsp->rsp.tspec = tspec;
1779 /* Update SME session Id and transcation Id */
1780 rsp->sessionId = smesessionId;
1781 rsp->transactionId = smetransactionId;
1782
1783 mmhMsg.type = eWNI_SME_ADDTS_RSP;
1784 mmhMsg.bodyptr = rsp;
1785 mmhMsg.bodyval = 0;
1786 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301787 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1788 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001789 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301790 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1791 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001792 }
1793#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1794 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_RSP_EVENT, psessionEntry, 0,
1795 0);
1796#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1797
1798 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1799 return;
1800}
1801
1802void
1803lim_send_sme_delts_rsp(tpAniSirGlobal pMac, tpSirDeltsReq delts, uint32_t status,
1804 tpPESession psessionEntry, uint8_t smesessionId,
1805 uint16_t smetransactionId)
1806{
1807 tpSirDeltsRsp rsp;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001808 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001809
1810 lim_log(pMac, LOGW, "SendSmeDeltsRsp (aid %d, tsid %d, up %d) status %d",
1811 delts->aid,
1812 delts->req.tsinfo.traffic.tsid,
1813 delts->req.tsinfo.traffic.userPrio, status);
1814 if (!delts->rspReqd)
1815 return;
1816
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301817 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001818 if (NULL == rsp) {
1819 /* Log error */
1820 lim_log(pMac, LOGP, FL("AllocateMemory failed for DELTS_RSP"));
1821 return;
1822 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001823
1824 if (psessionEntry != NULL) {
1825
1826 rsp->aid = delts->aid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301827 qdf_copy_macaddr(&rsp->macaddr, &delts->macaddr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301828 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) &delts->req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829 sizeof(tSirDeltsReqInfo));
1830 }
1831
1832 rsp->messageType = eWNI_SME_DELTS_RSP;
1833 rsp->rc = status;
1834
1835 /* Update SME session Id and transcation Id */
1836 rsp->sessionId = smesessionId;
1837 rsp->transactionId = smetransactionId;
1838
1839 mmhMsg.type = eWNI_SME_DELTS_RSP;
1840 mmhMsg.bodyptr = rsp;
1841 mmhMsg.bodyval = 0;
1842 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301843 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1844 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001845 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301846 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1847 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001848 }
1849#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1850 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_RSP_EVENT, psessionEntry,
1851 (uint16_t) status, 0);
1852#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1853
1854 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1855}
1856
1857void
1858lim_send_sme_delts_ind(tpAniSirGlobal pMac, tpSirDeltsReqInfo delts, uint16_t aid,
1859 tpPESession psessionEntry)
1860{
1861 tpSirDeltsRsp rsp;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001862 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001863
1864 lim_log(pMac, LOGW, "SendSmeDeltsInd (aid %d, tsid %d, up %d)",
1865 aid, delts->tsinfo.traffic.tsid, delts->tsinfo.traffic.userPrio);
1866
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301867 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001868 if (NULL == rsp) {
1869 /* Log error */
1870 lim_log(pMac, LOGP, FL("AllocateMemory failed for DELTS_IND"));
1871 return;
1872 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001873
1874 rsp->messageType = eWNI_SME_DELTS_IND;
1875 rsp->rc = eSIR_SUCCESS;
1876 rsp->aid = aid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301877 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) delts, sizeof(*delts));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001878
1879 /* Update SME session Id and SME transaction Id */
1880
1881 rsp->sessionId = psessionEntry->smeSessionId;
1882 rsp->transactionId = psessionEntry->transactionId;
1883
1884 mmhMsg.type = eWNI_SME_DELTS_IND;
1885 mmhMsg.bodyptr = rsp;
1886 mmhMsg.bodyval = 0;
1887 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1888#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1889 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_IND_EVENT, psessionEntry, 0,
1890 0);
1891#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1892
1893 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1894}
1895
1896/**
1897 * lim_send_sme_pe_statistics_rsp()
1898 *
1899 ***FUNCTION:
1900 * This function is called to send 802.11 statistics response to HDD.
1901 * This function posts the result back to HDD. This is a response to
1902 * HDD's request for statistics.
1903 *
1904 ***PARAMS:
1905 *
1906 ***LOGIC:
1907 *
1908 ***ASSUMPTIONS:
1909 * NA
1910 *
1911 ***NOTE:
1912 * NA
1913 *
1914 * @param pMac Pointer to Global MAC structure
1915 * @param p80211Stats Statistics sent in response
1916 * @param resultCode TODO:
1917 *
1918 *
1919 * @return none
1920 */
1921
1922void
1923lim_send_sme_pe_statistics_rsp(tpAniSirGlobal pMac, uint16_t msgType, void *stats)
1924{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001925 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001926 uint8_t sessionId;
1927 tAniGetPEStatsRsp *pPeStats = (tAniGetPEStatsRsp *) stats;
1928 tpPESession pPeSessionEntry;
1929
1930 /* Get the Session Id based on Sta Id */
1931 pPeSessionEntry =
1932 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1933
1934 /* Fill the Session Id */
1935 if (NULL != pPeSessionEntry) {
1936 /* Fill the Session Id */
1937 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1938 }
1939
1940 pPeStats->msgType = eWNI_SME_GET_STATISTICS_RSP;
1941
1942 /* msgType should be WMA_GET_STATISTICS_RSP */
1943 mmhMsg.type = eWNI_SME_GET_STATISTICS_RSP;
1944
1945 mmhMsg.bodyptr = stats;
1946 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301947 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001948 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1949
1950 return;
1951
1952} /*** end lim_send_sme_pe_statistics_rsp() ***/
1953
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001954#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001955/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001956 * lim_send_sme_pe_ese_tsm_rsp() - send tsm response
1957 * @pMac: Pointer to global pMac structure
1958 * @pStats: Pointer to TSM Stats
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001959 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001960 * This function is called to send tsm stats response to HDD.
1961 * This function posts the result back to HDD. This is a response to
1962 * HDD's request to get tsm stats.
1963 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001964 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001965 */
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001966void lim_send_sme_pe_ese_tsm_rsp(tpAniSirGlobal pMac,
1967 tAniGetTsmStatsRsp *pStats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001968{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08001969 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001970 uint8_t sessionId;
1971 tAniGetTsmStatsRsp *pPeStats = (tAniGetTsmStatsRsp *) pStats;
1972 tpPESession pPeSessionEntry = NULL;
1973
1974 /* Get the Session Id based on Sta Id */
1975 pPeSessionEntry =
1976 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1977
1978 /* Fill the Session Id */
1979 if (NULL != pPeSessionEntry) {
1980 /* Fill the Session Id */
1981 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1982 } else {
1983 PELOGE(lim_log
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001984 (pMac, LOGE, FL("Session not found for the Sta id(%d)"),
1985 pPeStats->staId);)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001986 return;
1987 }
1988
1989 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
1990 pPeStats->tsmMetrics.RoamingCount
1991 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
1992 pPeStats->tsmMetrics.RoamingDly
1993 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
1994
1995 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
1996 mmhMsg.bodyptr = pStats;
1997 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301998 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001999 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2000
2001 return;
2002} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
2003
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08002004#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002005
2006void
2007lim_send_sme_ibss_peer_ind(tpAniSirGlobal pMac,
2008 tSirMacAddr peerMacAddr,
2009 uint16_t staIndex,
2010 uint8_t ucastIdx,
2011 uint8_t bcastIdx,
2012 uint8_t *beacon,
2013 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
2014{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002015 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002016 tSmeIbssPeerInd *pNewPeerInd;
2017
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302018 pNewPeerInd = qdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002019 if (NULL == pNewPeerInd) {
2020 PELOGE(lim_log(pMac, LOGE, FL("Failed to allocate memory"));)
2021 return;
2022 }
2023
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302024 qdf_mem_copy((uint8_t *) pNewPeerInd->peer_addr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302025 peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002026 pNewPeerInd->staId = staIndex;
2027 pNewPeerInd->ucastSig = ucastIdx;
2028 pNewPeerInd->bcastSig = bcastIdx;
2029 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
2030 pNewPeerInd->mesgType = msgType;
2031 pNewPeerInd->sessionId = sessionId;
2032
2033 if (beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302034 qdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002035 sizeof(tSmeIbssPeerInd)), (void *)beacon,
2036 beaconLen);
2037 }
2038
2039 mmhMsg.type = msgType;
2040 mmhMsg.bodyptr = pNewPeerInd;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302041 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002042 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2043
2044}
2045
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07002046/**
2047 * lim_process_csa_wbw_ie() - Process CSA Wide BW IE
2048 * @mac_ctx: pointer to global adapter context
2049 * @csa_params: pointer to CSA parameters
2050 * @chnl_switch_info:pointer to channel switch parameters
2051 * @session_entry: session pointer
2052 *
2053 * Return: None
2054 */
2055static void lim_process_csa_wbw_ie(tpAniSirGlobal mac_ctx,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002056 struct csa_offload_params *csa_params,
2057 tLimWiderBWChannelSwitchInfo *chnl_switch_info,
2058 tpPESession session_entry)
2059{
2060 struct ch_params_s ch_params = {0};
2061 uint8_t ap_new_ch_width;
2062 bool new_ch_width_dfn = false;
2063 uint8_t center_freq_diff;
2064
2065 ap_new_ch_width = csa_params->new_ch_width + 1;
2066 if ((ap_new_ch_width == CH_WIDTH_80MHZ) &&
2067 csa_params->new_ch_freq_seg2) {
2068 new_ch_width_dfn = true;
2069 if (csa_params->new_ch_freq_seg2 >
2070 csa_params->new_ch_freq_seg1)
2071 center_freq_diff = csa_params->new_ch_freq_seg2 -
2072 csa_params->new_ch_freq_seg1;
2073 else
2074 center_freq_diff = csa_params->new_ch_freq_seg1 -
2075 csa_params->new_ch_freq_seg2;
2076 if (center_freq_diff == CENTER_FREQ_DIFF_160MHz)
2077 ap_new_ch_width = CH_WIDTH_160MHZ;
2078 else if (center_freq_diff > CENTER_FREQ_DIFF_80P80MHz)
2079 ap_new_ch_width = CH_WIDTH_80P80MHZ;
2080 else
2081 ap_new_ch_width = CH_WIDTH_80MHZ;
2082 }
2083 session_entry->gLimChannelSwitch.state =
2084 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2085 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
2086 !new_ch_width_dfn) {
2087 ch_params.ch_width = CH_WIDTH_160MHZ;
2088 cds_set_channel_params(csa_params->channel, 0,
2089 &ch_params);
2090 ap_new_ch_width = ch_params.ch_width;
2091 csa_params->new_ch_freq_seg1 = ch_params.center_freq_seg0;
2092 csa_params->new_ch_freq_seg2 = ch_params.center_freq_seg1;
2093 }
2094 chnl_switch_info->newChanWidth = ap_new_ch_width;
2095 chnl_switch_info->newCenterChanFreq0 = csa_params->new_ch_freq_seg1;
2096 chnl_switch_info->newCenterChanFreq1 = csa_params->new_ch_freq_seg2;
2097
2098 if (session_entry->ch_width == ap_new_ch_width)
2099 goto prnt_log;
2100
2101 if (session_entry->ch_width == CH_WIDTH_80MHZ) {
2102 chnl_switch_info->newChanWidth = CH_WIDTH_80MHZ;
2103 chnl_switch_info->newCenterChanFreq1 = 0;
2104 } else {
2105 session_entry->ch_width = ap_new_ch_width;
2106 chnl_switch_info->newChanWidth = ap_new_ch_width;
2107 }
2108prnt_log:
2109 lim_log(mac_ctx, LOG1,
2110 FL("new channel: %d new_ch_width:%d seg0:%d seg1:%d"),
2111 csa_params->channel,
2112 chnl_switch_info->newChanWidth,
2113 chnl_switch_info->newCenterChanFreq0,
2114 chnl_switch_info->newCenterChanFreq1);
2115}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002116/**
2117 * lim_handle_csa_offload_msg() - Handle CSA offload message
2118 * @mac_ctx: pointer to global adapter context
2119 * @msg: Message pointer.
2120 *
2121 * Return: None
2122 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08002123void lim_handle_csa_offload_msg(tpAniSirGlobal mac_ctx,
2124 struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002125{
2126 tpPESession session_entry;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002127 struct scheduler_msg mmh_msg;
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302128 struct csa_offload_params *csa_params =
2129 (struct csa_offload_params *) (msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002130 tpSmeCsaOffloadInd csa_offload_ind;
2131 tpDphHashNode sta_ds = NULL;
2132 uint8_t session_id;
2133 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302134 uint16_t chan_space = 0;
Amar Singhale4f28ee2015-10-21 14:36:56 -07002135 struct ch_params_s ch_params;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302136
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002137 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002138 tLimChannelSwitchInfo *lim_ch_switch = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002139
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302140 lim_log(mac_ctx, LOG1, FL("handle csa offload msg"));
2141
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002142 if (!csa_params) {
2143 lim_log(mac_ctx, LOGE, FL("limMsgQ body ptr is NULL"));
2144 return;
2145 }
2146
2147 session_entry =
2148 pe_find_session_by_bssid(mac_ctx,
2149 csa_params->bssId, &session_id);
2150 if (!session_entry) {
2151 lim_log(mac_ctx, LOGE,
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302152 FL("Session does not exists for %pM"),
2153 csa_params->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002154 goto err;
2155 }
2156
2157 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
2158 &session_entry->dph.dphHashTable);
2159
2160 if (!sta_ds) {
2161 lim_log(mac_ctx, LOGE,
2162 FL("sta_ds does not exist"));
2163 goto err;
2164 }
2165
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002166 if (!LIM_IS_STA_ROLE(session_entry)) {
2167 lim_log(mac_ctx, LOG1, FL("Invalid role to handle CSA"));
2168 goto err;
2169 }
Masti, Narayanraddi1c630442015-11-02 12:03:50 +05302170
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002171 /*
2172 * on receiving channel switch announcement from AP, delete all
2173 * TDLS peers before leaving BSS and proceed for channel switch
2174 */
2175 lim_delete_tdls_peers(mac_ctx, session_entry);
Gupta, Kapil121bf212015-11-25 19:21:29 +05302176
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002177 lim_ch_switch = &session_entry->gLimChannelSwitch;
2178 session_entry->gLimChannelSwitch.switchMode =
2179 csa_params->switch_mode;
2180 /* timer already started by firmware, switch immediately */
2181 session_entry->gLimChannelSwitch.switchCount = 0;
2182 session_entry->gLimChannelSwitch.primaryChannel =
2183 csa_params->channel;
2184 session_entry->gLimChannelSwitch.state =
2185 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2186 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
2187 lim_ch_switch->sec_ch_offset =
2188 session_entry->htSecondaryChannelOffset;
2189 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
2190 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
2191 chnl_switch_info =
2192 &session_entry->gLimWiderBWChannelSwitch;
2193
2194 lim_log(mac_ctx, LOG1,
2195 FL("vht:%d ht:%d flag:%x chan:%d"),
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302196 session_entry->vhtCapability,
2197 session_entry->htSupportedChannelWidthSet,
2198 csa_params->ies_present_flag,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002199 csa_params->channel);
2200 lim_log(mac_ctx, LOG1,
2201 FL("seg1:%d seg2:%d width:%d country:%s class:%d"),
2202 csa_params->new_ch_freq_seg1,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302203 csa_params->new_ch_freq_seg2,
2204 csa_params->new_ch_width,
2205 mac_ctx->scan.countryCodeCurrent,
2206 csa_params->new_op_class);
2207
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002208 if (session_entry->vhtCapability &&
2209 session_entry->htSupportedChannelWidthSet) {
2210 if (csa_params->ies_present_flag & lim_wbw_ie_present) {
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07002211 lim_process_csa_wbw_ie(mac_ctx, csa_params,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002212 chnl_switch_info, session_entry);
2213 lim_ch_switch->sec_ch_offset =
2214 csa_params->sec_chan_offset;
2215 } else if (csa_params->ies_present_flag
2216 & lim_xcsa_ie_present) {
2217 chan_space =
2218 cds_reg_dmn_get_chanwidth_from_opclass(
2219 mac_ctx->scan.countryCodeCurrent,
2220 csa_params->channel,
2221 csa_params->new_op_class);
2222 session_entry->gLimChannelSwitch.state =
2223 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2224
2225 if (chan_space == 80) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002226 chnl_switch_info->newChanWidth =
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002227 CH_WIDTH_80MHZ;
2228 } else if (chan_space == 40) {
2229 chnl_switch_info->newChanWidth =
2230 CH_WIDTH_40MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002231 } else {
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002232 chnl_switch_info->newChanWidth =
2233 CH_WIDTH_20MHZ;
2234 lim_ch_switch->state =
2235 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2236 }
2237
2238 ch_params.ch_width =
2239 chnl_switch_info->newChanWidth;
2240 cds_set_channel_params(csa_params->channel,
2241 0, &ch_params);
2242 chnl_switch_info->newCenterChanFreq0 =
2243 ch_params.center_freq_seg0;
2244 /*
2245 * This is not applicable for 20/40/80 MHz.
2246 * Only used when we support 80+80 MHz operation.
2247 * In case of 80+80 MHz, this parameter indicates
2248 * center channel frequency index of 80 MHz
2249 * channel offrequency segment 1.
2250 */
2251 chnl_switch_info->newCenterChanFreq1 =
2252 ch_params.center_freq_seg1;
2253 lim_ch_switch->sec_ch_offset =
2254 ch_params.sec_ch_offset;
2255
2256 }
2257 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
2258 chnl_switch_info->newCenterChanFreq0;
2259 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
2260 chnl_switch_info->newCenterChanFreq1;
2261 session_entry->gLimChannelSwitch.ch_width =
2262 chnl_switch_info->newChanWidth;
2263
2264 } else if (session_entry->htSupportedChannelWidthSet) {
2265 if (csa_params->ies_present_flag
2266 & lim_xcsa_ie_present) {
2267 chan_space =
2268 cds_reg_dmn_get_chanwidth_from_opclass(
2269 mac_ctx->scan.countryCodeCurrent,
2270 csa_params->channel,
2271 csa_params->new_op_class);
2272 lim_ch_switch->state =
2273 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2274 if (chan_space == 40) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002275 lim_ch_switch->ch_width =
2276 CH_WIDTH_40MHZ;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002277 chnl_switch_info->newChanWidth =
2278 CH_WIDTH_40MHZ;
2279 ch_params.ch_width =
2280 chnl_switch_info->newChanWidth;
2281 cds_set_channel_params(
2282 csa_params->channel,
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07002283 0, &ch_params);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002284 lim_ch_switch->ch_center_freq_seg0 =
2285 ch_params.center_freq_seg0;
2286 lim_ch_switch->sec_ch_offset =
2287 ch_params.sec_ch_offset;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002288 } else {
2289 lim_ch_switch->ch_width =
2290 CH_WIDTH_20MHZ;
2291 chnl_switch_info->newChanWidth =
2292 CH_WIDTH_40MHZ;
2293 lim_ch_switch->state =
2294 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2295 lim_ch_switch->sec_ch_offset =
2296 PHY_SINGLE_CHANNEL_CENTERED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002297 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002298 } else {
2299 lim_ch_switch->ch_width =
2300 CH_WIDTH_40MHZ;
2301 lim_ch_switch->state =
2302 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2303 ch_params.ch_width = CH_WIDTH_40MHZ;
2304 cds_set_channel_params(csa_params->channel,
2305 0, &ch_params);
2306 lim_ch_switch->ch_center_freq_seg0 =
2307 ch_params.center_freq_seg0;
2308 lim_ch_switch->sec_ch_offset =
2309 ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002310 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002311
2312 }
2313 lim_log(mac_ctx, LOG1, FL("new ch width = %d space:%d"),
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302314 session_entry->gLimChannelSwitch.ch_width, chan_space);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002315
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002316 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
2317 csa_offload_ind = qdf_mem_malloc(sizeof(tSmeCsaOffloadInd));
2318 if (NULL == csa_offload_ind) {
2319 lim_log(mac_ctx, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002320 FL("memalloc fail eWNI_SME_CSA_OFFLOAD_EVENT"));
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002321 goto err;
2322 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002323
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002324 csa_offload_ind->mesgType = eWNI_SME_CSA_OFFLOAD_EVENT;
2325 csa_offload_ind->mesgLen = sizeof(tSmeCsaOffloadInd);
2326 qdf_mem_copy(csa_offload_ind->bssid.bytes, session_entry->bssId,
2327 QDF_MAC_ADDR_SIZE);
2328 mmh_msg.type = eWNI_SME_CSA_OFFLOAD_EVENT;
2329 mmh_msg.bodyptr = csa_offload_ind;
2330 mmh_msg.bodyval = 0;
2331 lim_log(mac_ctx, LOG1,
Srinivas Girigowdac9148f72015-11-25 12:42:32 -08002332 FL("Sending eWNI_SME_CSA_OFFLOAD_EVENT to SME."));
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002333 MTRACE(mac_trace_msg_tx
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002334 (mac_ctx, session_entry->peSessionId, mmh_msg.type));
2335#ifdef FEATURE_WLAN_DIAG_SUPPORT
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002336 lim_diag_event_report(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002337 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
2338 eSIR_SUCCESS, eSIR_SUCCESS);
2339#endif
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002340 lim_sys_process_mmh_msg_api(mac_ctx, &mmh_msg, ePROT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002341
2342err:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302343 qdf_mem_free(csa_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002344}
2345
2346/*--------------------------------------------------------------------------
2347 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
2348
2349 \param pMac - pointer to global adapter context
2350 \param sessionId - Message pointer.
2351
2352 \sa
2353 --------------------------------------------------------------------------*/
2354
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002355void lim_handle_delete_bss_rsp(tpAniSirGlobal pMac, struct scheduler_msg *MsgQ)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002356{
2357 tpPESession psessionEntry;
2358 tpDeleteBssParams pDelBss = (tpDeleteBssParams) (MsgQ->bodyptr);
2359
2360 psessionEntry =
2361 pe_find_session_by_session_id(pMac, pDelBss->sessionId);
2362 if (psessionEntry == NULL) {
2363 lim_log(pMac, LOGE,
2364 FL("Session Does not exist for given sessionID %d"),
2365 pDelBss->sessionId);
Naveen Rawat0c81edc2016-06-08 10:08:30 -07002366 qdf_mem_free(MsgQ->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002367 return;
2368 }
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002369 /*
2370 * During DEL BSS handling, the PE Session will be deleted, but it is
2371 * better to clear this flag if the session is hanging around due
2372 * to some error conditions so that the next DEL_BSS request does
2373 * not take the HO_FAIL path
2374 */
2375 psessionEntry->process_ho_fail = false;
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002376 if (LIM_IS_IBSS_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002377 lim_ibss_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002378 else if (LIM_IS_UNKNOWN_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002379 lim_process_sme_del_bss_rsp(pMac, MsgQ->bodyval, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002380 else if (LIM_IS_NDI_ROLE(psessionEntry))
2381 lim_ndi_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002382 else
2383 lim_process_mlm_del_bss_rsp(pMac, MsgQ, psessionEntry);
2384
2385}
2386
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002387/** -----------------------------------------------------------------
2388 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
2389 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
2390 \ SME only looks at rc and tspec field.
2391 \param pMac - global mac structure
2392 \param rspReqd - is SmeAddTsRsp required
2393 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
2394 \return tspec
2395 \sa
2396 ----------------------------------------------------------------- */
2397void
2398lim_send_sme_aggr_qos_rsp(tpAniSirGlobal pMac, tpSirAggrQosRsp aggrQosRsp,
2399 uint8_t smesessionId)
2400{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002401 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002402
2403 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
2404 mmhMsg.bodyptr = aggrQosRsp;
2405 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302406 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2407 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002408 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2409
2410 return;
2411}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002412
2413void lim_send_sme_max_assoc_exceeded_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
2414 uint8_t smesessionId)
2415{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002416 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002417 tSmeMaxAssocInd *pSmeMaxAssocInd;
2418
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302419 pSmeMaxAssocInd = qdf_mem_malloc(sizeof(tSmeMaxAssocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002420 if (NULL == pSmeMaxAssocInd) {
2421 PELOGE(lim_log(pMac, LOGE, FL("Failed to allocate memory"));)
2422 return;
2423 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302424 qdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peer_mac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302425 (uint8_t *) peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002426 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
2427 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
2428 pSmeMaxAssocInd->sessionId = smesessionId;
2429 mmhMsg.type = pSmeMaxAssocInd->mesgType;
2430 mmhMsg.bodyptr = pSmeMaxAssocInd;
2431 PELOG1(lim_log(pMac, LOG1, FL("msgType %s peerMacAddr " MAC_ADDRESS_STR
2432 " sme session id %d"),
2433 "eWNI_SME_MAX_ASSOC_EXCEEDED",
2434 MAC_ADDR_ARRAY(peerMacAddr));
2435 )
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302436 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2437 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002438 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2439
2440 return;
2441}
2442
2443/** -----------------------------------------------------------------
2444 \brief lim_send_sme_dfs_event_notify() - sends
2445 eWNI_SME_DFS_RADAR_FOUND
2446 After receiving WMI_PHYERR_EVENTID indication frame from FW, this
2447 function sends a eWNI_SME_DFS_RADAR_FOUND to SME to notify
2448 that a RADAR is found on current operating channel and SAP-
2449 has to move to a new channel.
2450 \param pMac - global mac structure
2451 \param msgType - message type received from lower layer
2452 \param event - event data received from lower layer
2453 \return none
2454 \sa
2455 ----------------------------------------------------------------- */
2456void
2457lim_send_sme_dfs_event_notify(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2458{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002459 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002460 mmhMsg.type = eWNI_SME_DFS_RADAR_FOUND;
2461 mmhMsg.bodyptr = event;
2462 mmhMsg.bodyval = 0;
2463 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2464 return;
2465}
2466
2467/*--------------------------------------------------------------------------
2468 \brief lim_send_dfs_chan_sw_ie_update()
2469 This timer handler updates the channel switch IE in beacon template
2470
2471 \param pMac - pointer to global adapter context
2472 \return - channel to scan from valid session else zero.
2473 \sa
2474 --------------------------------------------------------------------------*/
2475static void
2476lim_send_dfs_chan_sw_ie_update(tpAniSirGlobal pMac, tpPESession psessionEntry)
2477{
2478
2479 /* Update the beacon template and send to FW */
2480 if (sch_set_fixed_beacon_fields(pMac, psessionEntry) != eSIR_SUCCESS) {
2481 PELOGE(lim_log(pMac, LOGE, FL("Unable to set CSA IE in beacon"));)
2482 return;
2483 }
2484
2485 /* Send update beacon template message */
2486 lim_send_beacon_ind(pMac, psessionEntry);
2487 PELOG1(lim_log(pMac, LOG1,
2488 FL(" Updated CSA IE, IE COUNT = %d"),
2489 psessionEntry->gLimChannelSwitch.switchCount);
2490 )
2491
2492 return;
2493}
2494
2495/** -----------------------------------------------------------------
2496 \brief lim_send_sme_ap_channel_switch_resp() - sends
2497 eWNI_SME_CHANNEL_CHANGE_RSP
2498 After receiving WMA_SWITCH_CHANNEL_RSP indication this
2499 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
2500 that the Channel change has been done to the specified target
2501 channel in the Channel change request
2502 \param pMac - global mac structure
2503 \param psessionEntry - session info
2504 \param pChnlParams - Channel switch params
2505 --------------------------------------------------------------------*/
2506void
2507lim_send_sme_ap_channel_switch_resp(tpAniSirGlobal pMac,
2508 tpPESession psessionEntry,
2509 tpSwitchChannelParams pChnlParams)
2510{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002511 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002512 tpSwitchChannelParams pSmeSwithChnlParams;
2513 uint8_t channelId;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002514 bool is_ch_dfs = false;
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08002515 enum phy_ch_width ch_width;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002516 uint8_t ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002517
2518 pSmeSwithChnlParams = (tSwitchChannelParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302519 qdf_mem_malloc(sizeof(tSwitchChannelParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002520 if (NULL == pSmeSwithChnlParams) {
2521 lim_log(pMac, LOGP,
2522 FL("AllocateMemory failed for pSmeSwithChnlParams\n"));
2523 return;
2524 }
2525
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302526 qdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002527 sizeof(tSwitchChannelParams));
2528
2529 channelId = pSmeSwithChnlParams->channelNumber;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002530 ch_width = pSmeSwithChnlParams->ch_width;
2531 ch_center_freq_seg1 = pSmeSwithChnlParams->ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002532
2533 /*
2534 * Pass the sme sessionID to SME instead
2535 * PE session ID.
2536 */
2537 pSmeSwithChnlParams->peSessionId = psessionEntry->smeSessionId;
2538
2539 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
2540 mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
2541 mmhMsg.bodyval = 0;
2542 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2543
2544 /*
2545 * We should start beacon transmission only if the new
2546 * channel after channel change is Non-DFS. For a DFS
2547 * channel, PE will receive an explicit request from
2548 * upper layers to start the beacon transmission .
2549 */
2550
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002551 if (ch_width == CH_WIDTH_160MHZ) {
2552 is_ch_dfs = true;
2553 } else if (ch_width == CH_WIDTH_80P80MHZ) {
2554 if (cds_get_channel_state(channelId) == CHANNEL_STATE_DFS ||
2555 cds_get_channel_state(ch_center_freq_seg1 -
2556 SIR_80MHZ_START_CENTER_CH_DIFF) ==
2557 CHANNEL_STATE_DFS)
2558 is_ch_dfs = true;
2559 } else {
2560 if (cds_get_channel_state(channelId) == CHANNEL_STATE_DFS)
2561 is_ch_dfs = true;
2562 }
2563
2564 if (!is_ch_dfs) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002565 if (channelId == psessionEntry->currentOperChannel) {
2566 lim_apply_configuration(pMac, psessionEntry);
2567 lim_send_beacon_ind(pMac, psessionEntry);
2568 } else {
2569 PELOG1(lim_log(pMac, LOG1,
2570 FL
2571 ("Failed to Transmit Beacons on channel = %d"
2572 "after AP channel change response"),
2573 psessionEntry->bcnLen);
2574 )
2575 }
2576 }
2577 return;
2578}
2579
2580/** -----------------------------------------------------------------
2581 \brief lim_process_beacon_tx_success_ind() - This function is used
2582 explicitely to handle successful beacon transmission indication
2583 from the FW. This is a generic event generated by the FW afer the
2584 first beacon is sent out after the beacon template update by the
2585 host
2586 \param pMac - global mac structure
2587 \param psessionEntry - session info
2588 \return none
2589 \sa
2590 ----------------------------------------------------------------- */
2591void
2592lim_process_beacon_tx_success_ind(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2593{
2594 /* Currently, this event is used only for DFS channel switch announcement
2595 * IE update in the template. If required to be used for other IE updates
2596 * add appropriate code by introducing a state variable
2597 */
2598 tpPESession psessionEntry;
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002599 struct scheduler_msg mmhMsg;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002600 tSirSmeCSAIeTxCompleteRsp *pChanSwTxResponse;
2601 struct sir_beacon_tx_complete_rsp *beacon_tx_comp_rsp_ptr;
2602 uint8_t length = sizeof(tSirSmeCSAIeTxCompleteRsp);
2603 tpSirFirstBeaconTxCompleteInd pBcnTxInd =
2604 (tSirFirstBeaconTxCompleteInd *) event;
2605
2606 psessionEntry = pe_find_session_by_bss_idx(pMac, pBcnTxInd->bssIdx);
2607 if (psessionEntry == NULL) {
2608 lim_log(pMac, LOGE,
2609 FL("Session Does not exist for given sessionID"));
2610 return;
2611 }
2612
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302613 lim_log(pMac, LOG1, FL("role:%d swIe:%d opIe:%d"),
2614 GET_LIM_SYSTEM_ROLE(psessionEntry),
2615 psessionEntry->dfsIncludeChanSwIe,
2616 psessionEntry->gLimOperatingMode.present);
2617
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002618 if (LIM_IS_AP_ROLE(psessionEntry) &&
2619 true == psessionEntry->dfsIncludeChanSwIe) {
2620 /* Send only 5 beacons with CSA IE Set in when a radar is detected */
2621 if (psessionEntry->gLimChannelSwitch.switchCount > 0) {
2622 /*
2623 * Send the next beacon with updated CSA IE count
2624 */
2625 lim_send_dfs_chan_sw_ie_update(pMac, psessionEntry);
2626 /* Decrement the IE count */
2627 psessionEntry->gLimChannelSwitch.switchCount--;
2628 } else {
2629 /* Done with CSA IE update, send response back to SME */
2630 psessionEntry->gLimChannelSwitch.switchCount = 0;
2631 if (pMac->sap.SapDfsInfo.disable_dfs_ch_switch == false)
2632 psessionEntry->gLimChannelSwitch.switchMode = 0;
2633 psessionEntry->dfsIncludeChanSwIe = false;
2634 psessionEntry->dfsIncludeChanWrapperIe = false;
2635
2636 pChanSwTxResponse = (tSirSmeCSAIeTxCompleteRsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302637 qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002638
2639 if (NULL == pChanSwTxResponse) {
2640 lim_log(pMac, LOGP,
2641 FL
2642 ("AllocateMemory failed for tSirSmeCSAIeTxCompleteRsp"));
2643 return;
2644 }
2645
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002646 pChanSwTxResponse->sessionId =
2647 psessionEntry->smeSessionId;
2648 pChanSwTxResponse->chanSwIeTxStatus =
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302649 QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002650
2651 mmhMsg.type = eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND;
2652 mmhMsg.bodyptr = pChanSwTxResponse;
2653 mmhMsg.bodyval = 0;
2654 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2655 }
2656 }
2657
2658 if (LIM_IS_AP_ROLE(psessionEntry) &&
2659 psessionEntry->gLimOperatingMode.present) {
2660 /* Done with nss update, send response back to SME */
2661 psessionEntry->gLimOperatingMode.present = 0;
2662 beacon_tx_comp_rsp_ptr = (struct sir_beacon_tx_complete_rsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302663 qdf_mem_malloc(sizeof(*beacon_tx_comp_rsp_ptr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002664 if (NULL == beacon_tx_comp_rsp_ptr) {
2665 lim_log(pMac, LOGP,
2666 FL
2667 ("AllocateMemory failed for beacon_tx_comp_rsp_ptr"));
2668 return;
2669 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002670 beacon_tx_comp_rsp_ptr->session_id =
2671 psessionEntry->smeSessionId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302672 beacon_tx_comp_rsp_ptr->tx_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002673 mmhMsg.type = eWNI_SME_NSS_UPDATE_RSP;
2674 mmhMsg.bodyptr = beacon_tx_comp_rsp_ptr;
2675 mmhMsg.bodyval = 0;
2676 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2677 }
2678 return;
2679}