blob: b1f5a45b8fdc232bb1914d6055bd677ed70cb8ac [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Krishna Kumaar Natarajan4e9cf392015-11-20 13:35:05 -08002 * Copyright (c) 2012-2016 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{
87 tSirMsgQ msg;
88 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{
145 tSirMsgQ msg;
146 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{
239 tSirMsgQ msg;
240 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;
573 tSirMsgQ mmhMsg;
574 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;
756 tSirMsgQ mmhMsg;
757
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{
794 tSirMsgQ mmhMsg;
795 tSirMsgQ *pMsg = (tSirMsgQ *) pCtx;
796
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;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800852
853 lim_log(pMac, LOG1, FL("Disassoc Ntf with trigger : %d reasonCode: %d"),
854 disassocTrigger, reasonCode);
855
856 switch (disassocTrigger) {
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700857 case eLIM_DUPLICATE_ENTRY:
858 /*
859 * Duplicate entry is removed at LIM.
860 * Initiate new entry for other session
861 */
862 lim_log(pMac, LOG1,
863 FL("Rcvd eLIM_DUPLICATE_ENTRY for " MAC_ADDRESS_STR),
864 MAC_ADDR_ARRAY(peerMacAddr));
865
866 for (i = 0; i < pMac->lim.maxBssId; i++) {
867 if ((&pMac->lim.gpSession[i] != NULL) &&
868 (pMac->lim.gpSession[i].valid) &&
869 (pMac->lim.gpSession[i].pePersona ==
870 QDF_SAP_MODE)) {
871 /* Find the sta ds entry in another session */
872 session = &pMac->lim.gpSession[i];
873 sta_ds = dph_lookup_hash_entry(pMac,
874 peerMacAddr, &assoc_id,
875 &session->dph.dphHashTable);
876 }
877 }
878 if (sta_ds
879#ifdef WLAN_FEATURE_11W
880 && (!sta_ds->rmfEnabled)
881#endif
882 ) {
883 if (lim_add_sta(pMac, sta_ds, false, session) !=
884 eSIR_SUCCESS)
885 lim_log(pMac, LOGE,
886 FL("could not Add STA with assocId=%d"),
887 sta_ds->assocId);
888 }
889 failure = true;
890 break;
891
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800892 case eLIM_PEER_ENTITY_DISASSOC:
893 if (reasonCode != eSIR_SME_STA_NOT_ASSOCIATED) {
894 failure = true;
895 goto error;
896 }
897
898 case eLIM_HOST_DISASSOC:
899 /**
900 * Disassociation response due to
901 * host triggered disassociation
902 */
903
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530904 pSirSmeDisassocRsp = qdf_mem_malloc(sizeof(tSirSmeDisassocRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800905 if (NULL == pSirSmeDisassocRsp) {
906 /* Log error */
907 lim_log(pMac, LOGP, FL("Memory allocation failed"));
908 failure = true;
909 goto error;
910 }
911 lim_log(pMac, LOG1, FL("send eWNI_SME_DISASSOC_RSP with "
912 "retCode: %d for " MAC_ADDRESS_STR),
913 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
914 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
915 pSirSmeDisassocRsp->length = sizeof(tSirSmeDisassocRsp);
916 /* sessionId */
917 pBuf = (uint8_t *) &pSirSmeDisassocRsp->sessionId;
918 *pBuf = smesessionId;
919 pBuf++;
920
921 /* transactionId */
922 lim_copy_u16(pBuf, smetransactionId);
923 pBuf += sizeof(uint16_t);
924
925 /* statusCode */
926 lim_copy_u32(pBuf, reasonCode);
927 pBuf += sizeof(tSirResultCodes);
928
929 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530930 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800931 pBuf += sizeof(tSirMacAddr);
932
933 /* Clear Station Stats */
934 /* for sta, it is always 1, IBSS is handled at halInitSta */
935
936#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
937
938 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
939 psessionEntry, (uint16_t) reasonCode, 0);
940#endif
941 pMsg = (uint32_t *) pSirSmeDisassocRsp;
942 break;
943
944 default:
945 /**
946 * Disassociation indication due to Disassociation
947 * frame reception from peer entity or due to
948 * loss of link with peer entity.
949 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530950 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800951 if (NULL == pSirSmeDisassocInd) {
952 /* Log error */
953 lim_log(pMac, LOGP, FL("Memory allocation failed"));
954 failure = true;
955 goto error;
956 }
957 lim_log(pMac, LOG1, FL("send eWNI_SME_DISASSOC_IND with "
958 "retCode: %d for " MAC_ADDRESS_STR),
959 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
960 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
961 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
962
963 /* Update SME session Id and Transaction Id */
964 pSirSmeDisassocInd->sessionId = smesessionId;
965 pSirSmeDisassocInd->transactionId = smetransactionId;
966 pSirSmeDisassocInd->reasonCode = reasonCode;
967 pBuf = (uint8_t *) &pSirSmeDisassocInd->statusCode;
968
969 lim_copy_u32(pBuf, reasonCode);
970 pBuf += sizeof(tSirResultCodes);
971
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530972 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800973 pBuf += sizeof(tSirMacAddr);
974
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530975 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800976
977#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
978 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
979 psessionEntry, (uint16_t) reasonCode, 0);
980#endif
981 pMsg = (uint32_t *) pSirSmeDisassocInd;
982
983 break;
984 }
985
986error:
987 /* Delete the PE session Created */
Rajeev Kumarcf835a02016-04-15 15:01:31 -0700988 if ((psessionEntry != NULL) && LIM_IS_STA_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800989 pe_delete_session(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800990
991 if (false == failure)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530992 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800993 (uint32_t *) pMsg);
994} /*** end lim_send_sme_disassoc_ntf() ***/
995
996/** -----------------------------------------------------------------
997 \brief lim_send_sme_disassoc_ind() - sends SME_DISASSOC_IND
998
999 After receiving disassociation frame from peer entity, this
1000 function sends a eWNI_SME_DISASSOC_IND to SME with a specific
1001 reason code.
1002
1003 \param pMac - global mac structure
1004 \param pStaDs - station dph hash node
1005 \return none
1006 \sa
1007 ----------------------------------------------------------------- */
1008void
1009lim_send_sme_disassoc_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1010 tpPESession psessionEntry)
1011{
1012 tSirMsgQ mmhMsg;
1013 tSirSmeDisassocInd *pSirSmeDisassocInd;
1014
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301015 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001016 if (NULL == pSirSmeDisassocInd) {
1017 lim_log(pMac, LOGP,
1018 FL("AllocateMemory failed for eWNI_SME_DISASSOC_IND"));
1019 return;
1020 }
1021
1022 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
1023 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
1024
1025 pSirSmeDisassocInd->sessionId = psessionEntry->smeSessionId;
1026 pSirSmeDisassocInd->transactionId = psessionEntry->transactionId;
Padma, Santhosh Kumar02289212016-09-30 13:30:08 +05301027 pSirSmeDisassocInd->statusCode = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001028 pSirSmeDisassocInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1029
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301030 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301031 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001032
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301033 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301034 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001035
1036 pSirSmeDisassocInd->staId = pStaDs->staIndex;
1037
1038 mmhMsg.type = eWNI_SME_DISASSOC_IND;
1039 mmhMsg.bodyptr = pSirSmeDisassocInd;
1040 mmhMsg.bodyval = 0;
1041
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301042 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1043 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001044#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1045 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT, psessionEntry,
1046 0, (uint16_t) pStaDs->mlmStaContext.disassocReason);
1047#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1048
1049 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1050
1051} /*** end lim_send_sme_disassoc_ind() ***/
1052
1053/** -----------------------------------------------------------------
1054 \brief lim_send_sme_deauth_ind() - sends SME_DEAUTH_IND
1055
1056 After receiving deauthentication frame from peer entity, this
1057 function sends a eWNI_SME_DEAUTH_IND to SME with a specific
1058 reason code.
1059
1060 \param pMac - global mac structure
1061 \param pStaDs - station dph hash node
1062 \return none
1063 \sa
1064 ----------------------------------------------------------------- */
1065void
1066lim_send_sme_deauth_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1067 tpPESession psessionEntry)
1068{
1069 tSirMsgQ mmhMsg;
1070 tSirSmeDeauthInd *pSirSmeDeauthInd;
1071
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301072 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001073 if (NULL == pSirSmeDeauthInd) {
1074 lim_log(pMac, LOGP,
1075 FL("AllocateMemory failed for eWNI_SME_DEAUTH_IND "));
1076 return;
1077 }
1078
1079 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1080 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1081
1082 pSirSmeDeauthInd->sessionId = psessionEntry->smeSessionId;
1083 pSirSmeDeauthInd->transactionId = psessionEntry->transactionId;
1084 if (eSIR_INFRA_AP_MODE == psessionEntry->bssType) {
1085 pSirSmeDeauthInd->statusCode =
1086 (tSirResultCodes) pStaDs->mlmStaContext.cleanupTrigger;
1087 } else {
1088 /* Need to indicatet he reascon code over the air */
1089 pSirSmeDeauthInd->statusCode =
1090 (tSirResultCodes) pStaDs->mlmStaContext.disassocReason;
1091 }
1092 /* BSSID */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301093 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301094 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001095 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301096 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301097 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001098 pSirSmeDeauthInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1099
1100 pSirSmeDeauthInd->staId = pStaDs->staIndex;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001101 if (eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON ==
1102 pStaDs->mlmStaContext.disassocReason)
1103 pSirSmeDeauthInd->rssi = pStaDs->del_sta_ctx_rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001104
1105 mmhMsg.type = eWNI_SME_DEAUTH_IND;
1106 mmhMsg.bodyptr = pSirSmeDeauthInd;
1107 mmhMsg.bodyval = 0;
1108
1109 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1110#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1111 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT, psessionEntry,
1112 0, pStaDs->mlmStaContext.cleanupTrigger);
1113#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1114
1115 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1116 return;
1117} /*** end lim_send_sme_deauth_ind() ***/
1118
1119#ifdef FEATURE_WLAN_TDLS
1120/**
1121 * lim_send_sme_tdls_del_sta_ind()
1122 *
1123 ***FUNCTION:
1124 * This function is called to send the TDLS STA context deletion to SME.
1125 *
1126 ***LOGIC:
1127 *
1128 ***ASSUMPTIONS:
1129 *
1130 ***NOTE:
1131 * NA
1132 *
1133 * @param pMac - Pointer to global MAC structure
1134 * @param pStaDs - Pointer to internal STA Datastructure
1135 * @param psessionEntry - Pointer to the session entry
1136 * @param reasonCode - Reason for TDLS sta deletion
1137 * @return None
1138 */
1139void
1140lim_send_sme_tdls_del_sta_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1141 tpPESession psessionEntry, uint16_t reasonCode)
1142{
1143 tSirMsgQ mmhMsg;
1144 tSirTdlsDelStaInd *pSirTdlsDelStaInd;
1145
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301146 pSirTdlsDelStaInd = qdf_mem_malloc(sizeof(tSirTdlsDelStaInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001147 if (NULL == pSirTdlsDelStaInd) {
1148 lim_log(pMac, LOGP,
1149 FL
1150 ("AllocateMemory failed for eWNI_SME_TDLS_DEL_STA_IND "));
1151 return;
1152 }
1153 /* messageType */
1154 pSirTdlsDelStaInd->messageType = eWNI_SME_TDLS_DEL_STA_IND;
1155 pSirTdlsDelStaInd->length = sizeof(tSirTdlsDelStaInd);
1156
1157 /* sessionId */
1158 pSirTdlsDelStaInd->sessionId = psessionEntry->smeSessionId;
1159
1160 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301161 qdf_mem_copy(pSirTdlsDelStaInd->peermac.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301162 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001163
1164 /* staId */
1165 lim_copy_u16((uint8_t *) (&pSirTdlsDelStaInd->staId),
1166 (uint16_t) pStaDs->staIndex);
1167
1168 /* reasonCode */
1169 lim_copy_u16((uint8_t *) (&pSirTdlsDelStaInd->reasonCode), reasonCode);
1170
1171 mmhMsg.type = eWNI_SME_TDLS_DEL_STA_IND;
1172 mmhMsg.bodyptr = pSirTdlsDelStaInd;
1173 mmhMsg.bodyval = 0;
1174
1175 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1176 return;
1177} /*** end lim_send_sme_tdls_del_sta_ind() ***/
1178
1179/**
1180 * lim_send_sme_tdls_delete_all_peer_ind()
1181 *
1182 ***FUNCTION:
1183 * This function is called to send the eWNI_SME_TDLS_DEL_ALL_PEER_IND
1184 * message to SME.
1185 *
1186 ***LOGIC:
1187 *
1188 ***ASSUMPTIONS:
1189 *
1190 ***NOTE:
1191 * NA
1192 *
1193 * @param pMac - Pointer to global MAC structure
1194 * @param psessionEntry - Pointer to the session entry
1195 * @return None
1196 */
1197void
1198lim_send_sme_tdls_delete_all_peer_ind(tpAniSirGlobal pMac, tpPESession psessionEntry)
1199{
1200 tSirMsgQ mmhMsg;
1201 tSirTdlsDelAllPeerInd *pSirTdlsDelAllPeerInd;
1202
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301203 pSirTdlsDelAllPeerInd = qdf_mem_malloc(sizeof(tSirTdlsDelAllPeerInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001204 if (NULL == pSirTdlsDelAllPeerInd) {
1205 lim_log(pMac, LOGP,
1206 FL
1207 ("AllocateMemory failed for eWNI_SME_TDLS_DEL_ALL_PEER_IND"));
1208 return;
1209 }
1210 /* messageType */
1211 pSirTdlsDelAllPeerInd->messageType = eWNI_SME_TDLS_DEL_ALL_PEER_IND;
1212 pSirTdlsDelAllPeerInd->length = sizeof(tSirTdlsDelAllPeerInd);
1213
1214 /* sessionId */
1215 pSirTdlsDelAllPeerInd->sessionId = psessionEntry->smeSessionId;
1216
1217 mmhMsg.type = eWNI_SME_TDLS_DEL_ALL_PEER_IND;
1218 mmhMsg.bodyptr = pSirTdlsDelAllPeerInd;
1219 mmhMsg.bodyval = 0;
1220
1221 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1222 return;
1223} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1224
1225/**
1226 * lim_send_sme_mgmt_tx_completion()
1227 *
1228 ***FUNCTION:
1229 * This function is called to send the eWNI_SME_MGMT_FRM_TX_COMPLETION_IND
1230 * message to SME.
1231 *
1232 ***LOGIC:
1233 *
1234 ***ASSUMPTIONS:
1235 *
1236 ***NOTE:
1237 * NA
1238 *
1239 * @param pMac - Pointer to global MAC structure
1240 * @param psessionEntry - Pointer to the session entry
1241 * @param txCompleteStatus - TX Complete Status of Mgmt Frames
1242 * @return None
1243 */
1244void
1245lim_send_sme_mgmt_tx_completion(tpAniSirGlobal pMac,
1246 tpPESession psessionEntry, uint32_t txCompleteStatus)
1247{
1248 tSirMsgQ mmhMsg;
1249 tSirMgmtTxCompletionInd *pSirMgmtTxCompletionInd;
1250
1251 pSirMgmtTxCompletionInd =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301252 qdf_mem_malloc(sizeof(tSirMgmtTxCompletionInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001253 if (NULL == pSirMgmtTxCompletionInd) {
1254 lim_log(pMac, LOGP,
1255 FL
1256 ("AllocateMemory failed for eWNI_SME_MGMT_FRM_TX_COMPLETION_IND"));
1257 return;
1258 }
1259 /* messageType */
1260 pSirMgmtTxCompletionInd->messageType =
1261 eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1262 pSirMgmtTxCompletionInd->length = sizeof(tSirMgmtTxCompletionInd);
1263
1264 /* sessionId */
1265 pSirMgmtTxCompletionInd->sessionId = psessionEntry->smeSessionId;
1266
1267 pSirMgmtTxCompletionInd->txCompleteStatus = txCompleteStatus;
1268
1269 mmhMsg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1270 mmhMsg.bodyptr = pSirMgmtTxCompletionInd;
1271 mmhMsg.bodyval = 0;
1272
1273 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1274 return;
1275} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1276
1277void lim_send_sme_tdls_event_notify(tpAniSirGlobal pMac, uint16_t msgType,
1278 void *events)
1279{
1280 tSirMsgQ mmhMsg;
1281
1282 switch (msgType) {
1283 case SIR_HAL_TDLS_SHOULD_DISCOVER:
1284 mmhMsg.type = eWNI_SME_TDLS_SHOULD_DISCOVER;
1285 break;
1286 case SIR_HAL_TDLS_SHOULD_TEARDOWN:
1287 mmhMsg.type = eWNI_SME_TDLS_SHOULD_TEARDOWN;
1288 break;
1289 case SIR_HAL_TDLS_PEER_DISCONNECTED:
1290 mmhMsg.type = eWNI_SME_TDLS_PEER_DISCONNECTED;
1291 break;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07001292 case SIR_HAL_TDLS_CONNECTION_TRACKER_NOTIFICATION:
1293 mmhMsg.type = eWNI_SME_TDLS_CONNECTION_TRACKER_NOTIFICATION;
1294 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001295 }
1296
1297 mmhMsg.bodyptr = events;
1298 mmhMsg.bodyval = 0;
1299 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1300 return;
1301}
1302#endif /* FEATURE_WLAN_TDLS */
1303
1304/**
1305 * lim_send_sme_deauth_ntf()
1306 *
1307 ***FUNCTION:
1308 * This function is called by limProcessSmeMessages() to send
1309 * eWNI_SME_DISASSOC_RSP/IND message to host
1310 *
1311 ***PARAMS:
1312 *
1313 ***LOGIC:
1314 *
1315 ***ASSUMPTIONS:
1316 * NA
1317 *
1318 ***NOTE:
1319 * This function is used for sending eWNI_SME_DEAUTH_CNF or
1320 * eWNI_SME_DEAUTH_IND to host depending on deauthentication trigger.
1321 *
1322 * @param peerMacAddr Indicates the peer MAC addr to which
1323 * deauthentication was initiated
1324 * @param reasonCode Indicates the reason for Deauthetication
1325 * @param deauthTrigger Indicates the trigger for Deauthetication
1326 * @param aid Indicates the STAID. This parameter is present
1327 * only on AP.
1328 *
1329 * @return None
1330 */
1331void
1332lim_send_sme_deauth_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
1333 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1334 uint16_t aid, uint8_t smesessionId,
1335 uint16_t smetransactionId)
1336{
1337 uint8_t *pBuf;
1338 tSirSmeDeauthRsp *pSirSmeDeauthRsp;
1339 tSirSmeDeauthInd *pSirSmeDeauthInd;
1340 tpPESession psessionEntry;
1341 uint8_t sessionId;
1342 uint32_t *pMsg;
1343
1344 psessionEntry = pe_find_session_by_bssid(pMac, peerMacAddr, &sessionId);
1345 switch (deauthTrigger) {
1346 case eLIM_PEER_ENTITY_DEAUTH:
1347 return;
1348
1349 case eLIM_HOST_DEAUTH:
1350 /**
1351 * Deauthentication response to host triggered
1352 * deauthentication.
1353 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301354 pSirSmeDeauthRsp = qdf_mem_malloc(sizeof(tSirSmeDeauthRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001355 if (NULL == pSirSmeDeauthRsp) {
1356 /* Log error */
1357 lim_log(pMac, LOGP,
1358 FL
1359 ("call to AllocateMemory failed for eWNI_SME_DEAUTH_RSP"));
1360
1361 return;
1362 }
1363 lim_log(pMac, LOG1, FL("send eWNI_SME_DEAUTH_RSP with "
1364 "retCode: %d for" MAC_ADDRESS_STR),
1365 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1366 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
1367 pSirSmeDeauthRsp->length = sizeof(tSirSmeDeauthRsp);
1368 pSirSmeDeauthRsp->statusCode = reasonCode;
1369 pSirSmeDeauthRsp->sessionId = smesessionId;
1370 pSirSmeDeauthRsp->transactionId = smetransactionId;
1371
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -08001372 pBuf = (uint8_t *) pSirSmeDeauthRsp->peer_macaddr.bytes;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301373 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001374
1375#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1376 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
1377 psessionEntry, 0, (uint16_t) reasonCode);
1378#endif
1379 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1380
1381 break;
1382
1383 default:
1384 /**
1385 * Deauthentication indication due to Deauthentication
1386 * frame reception from peer entity or due to
1387 * loss of link with peer entity.
1388 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301389 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001390 if (NULL == pSirSmeDeauthInd) {
1391 /* Log error */
1392 lim_log(pMac, LOGP,
1393 FL
1394 ("call to AllocateMemory failed for eWNI_SME_DEAUTH_Ind"));
1395
1396 return;
1397 }
1398 lim_log(pMac, LOG1, FL("send eWNI_SME_DEAUTH_IND with "
1399 "retCode: %d for " MAC_ADDRESS_STR),
1400 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1401 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1402 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1403 pSirSmeDeauthInd->reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
1404
1405 /* sessionId */
1406 pBuf = (uint8_t *) &pSirSmeDeauthInd->sessionId;
1407 *pBuf++ = smesessionId;
1408
1409 /* transaction ID */
1410 lim_copy_u16(pBuf, smetransactionId);
1411 pBuf += sizeof(uint16_t);
1412
1413 /* status code */
1414 lim_copy_u32(pBuf, reasonCode);
1415 pBuf += sizeof(tSirResultCodes);
1416
1417 /* bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301418 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001419 pBuf += sizeof(tSirMacAddr);
1420
1421 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301422 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301423 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001424
1425#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1426 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
1427 psessionEntry, 0, (uint16_t) reasonCode);
1428#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1429 pMsg = (uint32_t *) pSirSmeDeauthInd;
1430
1431 break;
1432 }
1433
1434 /*Delete the PE session created */
1435 if (psessionEntry != NULL) {
1436 pe_delete_session(pMac, psessionEntry);
1437 }
1438
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301439 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001440 (uint32_t *) pMsg);
1441
1442} /*** end lim_send_sme_deauth_ntf() ***/
1443
1444/**
1445 * lim_send_sme_wm_status_change_ntf() - Send Notification
1446 * @mac_ctx: Global MAC Context
1447 * @status_change_code: Indicates the change in the wireless medium.
1448 * @status_change_info: Indicates the information associated with
1449 * change in the wireless medium.
1450 * @info_len: Indicates the length of status change information
1451 * being sent.
1452 * @session_id SessionID
1453 *
1454 * This function is called by limProcessSmeMessages() to send
1455 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1456 *
1457 * Return: None
1458 */
1459void
1460lim_send_sme_wm_status_change_ntf(tpAniSirGlobal mac_ctx,
1461 tSirSmeStatusChangeCode status_change_code,
1462 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1463{
1464 tSirMsgQ msg;
1465 tSirSmeWmStatusChangeNtf *wm_status_change_ntf;
Naveen Rawate01ed172016-11-17 11:34:50 -08001466 uint32_t max_info_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001467
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301468 wm_status_change_ntf = qdf_mem_malloc(sizeof(tSirSmeWmStatusChangeNtf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001469 if (NULL == wm_status_change_ntf) {
1470 lim_log(mac_ctx, LOGE,
1471 FL("Mem Alloc failed - eWNI_SME_WM_STATUS_CHANGE_NTF"));
1472 return;
1473 }
1474
1475 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1476 msg.bodyval = 0;
1477 msg.bodyptr = wm_status_change_ntf;
1478
1479 switch (status_change_code) {
Naveen Rawate01ed172016-11-17 11:34:50 -08001480 case eSIR_SME_AP_CAPS_CHANGED:
1481 max_info_len = sizeof(tSirSmeApNewCaps);
1482 break;
1483 case eSIR_SME_JOINED_NEW_BSS:
1484 max_info_len = sizeof(tSirSmeNewBssInfo);
1485 break;
1486 default:
1487 max_info_len = sizeof(wm_status_change_ntf->statusChangeInfo);
1488 break;
1489 }
1490
1491 switch (status_change_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001492 case eSIR_SME_RADAR_DETECTED:
1493 break;
1494 default:
1495 wm_status_change_ntf->messageType =
1496 eWNI_SME_WM_STATUS_CHANGE_NTF;
1497 wm_status_change_ntf->statusChangeCode = status_change_code;
1498 wm_status_change_ntf->length = sizeof(tSirSmeWmStatusChangeNtf);
1499 wm_status_change_ntf->sessionId = session_id;
Naveen Rawate01ed172016-11-17 11:34:50 -08001500 if (info_len <= max_info_len && status_change_info) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301501 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001502 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1503 (uint8_t *) status_change_info, info_len);
1504 }
1505 lim_log(mac_ctx, LOGE,
1506 FL("**---** StatusChg: code 0x%x, length %d **---**"),
1507 status_change_code, info_len);
1508 break;
1509 }
1510
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301511 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001512 if (eSIR_SUCCESS != lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301513 qdf_mem_free(wm_status_change_ntf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001514 lim_log(mac_ctx, LOGP,
1515 FL("lim_sys_process_mmh_msg_api failed"));
1516 }
1517
1518} /*** end lim_send_sme_wm_status_change_ntf() ***/
1519
1520/**
1521 * lim_send_sme_set_context_rsp()
1522 *
1523 ***FUNCTION:
1524 * This function is called by limProcessSmeMessages() to send
1525 * eWNI_SME_SETCONTEXT_RSP message to host
1526 *
1527 ***PARAMS:
1528 *
1529 ***LOGIC:
1530 *
1531 ***ASSUMPTIONS:
1532 * NA
1533 *
1534 ***NOTE:
1535 *
1536 * @param pMac Pointer to Global MAC structure
1537 * @param peerMacAddr Indicates the peer MAC addr to which
1538 * setContext was performed
1539 * @param aid Indicates the aid corresponding to the peer MAC
1540 * address
1541 * @param resultCode Indicates the result of previously issued
1542 * eWNI_SME_SETCONTEXT_RSP message
1543 *
1544 * @return None
1545 */
1546void
1547lim_send_sme_set_context_rsp(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301548 struct qdf_mac_addr peer_macaddr, uint16_t aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001549 tSirResultCodes resultCode,
1550 tpPESession psessionEntry, uint8_t smesessionId,
1551 uint16_t smetransactionId)
1552{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001553 tSirMsgQ mmhMsg;
1554 tSirSmeSetContextRsp *pSirSmeSetContextRsp;
1555
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301556 pSirSmeSetContextRsp = qdf_mem_malloc(sizeof(tSirSmeSetContextRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001557 if (NULL == pSirSmeSetContextRsp) {
1558 /* Log error */
1559 lim_log(pMac, LOGP,
1560 FL
1561 ("call to AllocateMemory failed for SmeSetContextRsp"));
1562
1563 return;
1564 }
1565
1566 pSirSmeSetContextRsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1567 pSirSmeSetContextRsp->length = sizeof(tSirSmeSetContextRsp);
1568 pSirSmeSetContextRsp->statusCode = resultCode;
1569
Anurag Chouhanc5548422016-02-24 18:33:27 +05301570 qdf_copy_macaddr(&pSirSmeSetContextRsp->peer_macaddr, &peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001571
1572 /* Update SME session and transaction Id */
1573 pSirSmeSetContextRsp->sessionId = smesessionId;
1574 pSirSmeSetContextRsp->transactionId = smetransactionId;
1575
1576 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
1577 mmhMsg.bodyptr = pSirSmeSetContextRsp;
1578 mmhMsg.bodyval = 0;
1579 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301580 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1581 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001582 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301583 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1584 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001585 }
1586
1587#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1588 lim_diag_event_report(pMac, WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
1589 psessionEntry, (uint16_t) resultCode, 0);
1590#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1591
1592 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1593} /*** end lim_send_sme_set_context_rsp() ***/
1594
1595/**
1596 * lim_send_sme_neighbor_bss_ind()
1597 *
1598 ***FUNCTION:
1599 * This function is called by lim_lookup_nadd_hash_entry() to send
1600 * eWNI_SME_NEIGHBOR_BSS_IND message to host
1601 *
1602 ***PARAMS:
1603 *
1604 ***LOGIC:
1605 *
1606 ***ASSUMPTIONS:
1607 * NA
1608 *
1609 ***NOTE:
1610 * This function is used for sending eWNI_SME_NEIGHBOR_BSS_IND to
1611 * host upon detecting new BSS during background scanning if CFG
1612 * option is enabled for sending such indication
1613 *
1614 * @param pMac - Pointer to Global MAC structure
1615 * @return None
1616 */
1617
1618void
1619lim_send_sme_neighbor_bss_ind(tpAniSirGlobal pMac, tLimScanResultNode *pBssDescr)
1620{
1621 tSirMsgQ msgQ;
1622 uint32_t val;
1623 tSirSmeNeighborBssInd *pNewBssInd;
1624
1625 if ((pMac->lim.gLimSmeState != eLIM_SME_LINK_EST_WT_SCAN_STATE) ||
1626 ((pMac->lim.gLimSmeState == eLIM_SME_LINK_EST_WT_SCAN_STATE) &&
1627 pMac->lim.gLimRspReqd)) {
1628 /* LIM is not in background scan state OR */
1629 /* current scan is initiated by HDD. */
1630 /* No need to send new BSS indication to HDD */
1631 return;
1632 }
1633
1634 if (wlan_cfg_get_int(pMac, WNI_CFG_NEW_BSS_FOUND_IND, &val) !=
1635 eSIR_SUCCESS) {
1636 lim_log(pMac, LOGP,
1637 FL("could not get NEIGHBOR_BSS_IND from CFG"));
1638
1639 return;
1640 }
1641
1642 if (val == 0)
1643 return;
1644
1645 /**
1646 * Need to indicate new BSSs found during
1647 * background scanning to host.
1648 * Allocate buffer for sending indication.
1649 * Length of buffer is length of BSS description
1650 * and length of header itself
1651 */
1652 val = pBssDescr->bssDescription.length + sizeof(uint16_t) +
1653 sizeof(uint32_t) + sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301654 pNewBssInd = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001655 if (NULL == pNewBssInd) {
1656 /* Log error */
1657 lim_log(pMac, LOGP,
1658 FL
1659 ("call to AllocateMemory failed for eWNI_SME_NEIGHBOR_BSS_IND"));
1660
1661 return;
1662 }
1663
1664 pNewBssInd->messageType = eWNI_SME_NEIGHBOR_BSS_IND;
1665 pNewBssInd->length = (uint16_t) val;
1666 pNewBssInd->sessionId = 0;
1667
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301668 qdf_mem_copy((uint8_t *) pNewBssInd->bssDescription,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001669 (uint8_t *) &pBssDescr->bssDescription,
1670 pBssDescr->bssDescription.length + sizeof(uint16_t));
1671
1672 msgQ.type = eWNI_SME_NEIGHBOR_BSS_IND;
1673 msgQ.bodyptr = pNewBssInd;
1674 msgQ.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301675 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, msgQ.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001676 lim_sys_process_mmh_msg_api(pMac, &msgQ, ePROT);
1677} /*** end lim_send_sme_neighbor_bss_ind() ***/
1678
1679/** -----------------------------------------------------------------
1680 \brief lim_send_sme_addts_rsp() - sends SME ADDTS RSP
1681 \ This function sends a eWNI_SME_ADDTS_RSP to SME.
1682 \ SME only looks at rc and tspec field.
1683 \param pMac - global mac structure
1684 \param rspReqd - is SmeAddTsRsp required
1685 \param status - status code of SME_ADD_TS_RSP
1686 \return tspec
1687 \sa
1688 ----------------------------------------------------------------- */
1689void
1690lim_send_sme_addts_rsp(tpAniSirGlobal pMac, uint8_t rspReqd, uint32_t status,
1691 tpPESession psessionEntry, tSirMacTspecIE tspec,
1692 uint8_t smesessionId, uint16_t smetransactionId)
1693{
1694 tpSirAddtsRsp rsp;
1695 tSirMsgQ mmhMsg;
1696
1697 if (!rspReqd)
1698 return;
1699
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301700 rsp = qdf_mem_malloc(sizeof(tSirAddtsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001701 if (NULL == rsp) {
1702 lim_log(pMac, LOGP, FL("AllocateMemory failed for ADDTS_RSP"));
1703 return;
1704 }
1705
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001706 rsp->messageType = eWNI_SME_ADDTS_RSP;
1707 rsp->rc = status;
1708 rsp->rsp.status = (enum eSirMacStatusCodes)status;
1709 rsp->rsp.tspec = tspec;
1710 /* Update SME session Id and transcation Id */
1711 rsp->sessionId = smesessionId;
1712 rsp->transactionId = smetransactionId;
1713
1714 mmhMsg.type = eWNI_SME_ADDTS_RSP;
1715 mmhMsg.bodyptr = rsp;
1716 mmhMsg.bodyval = 0;
1717 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301718 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1719 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001720 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301721 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1722 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001723 }
1724#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1725 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_RSP_EVENT, psessionEntry, 0,
1726 0);
1727#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1728
1729 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1730 return;
1731}
1732
1733void
1734lim_send_sme_delts_rsp(tpAniSirGlobal pMac, tpSirDeltsReq delts, uint32_t status,
1735 tpPESession psessionEntry, uint8_t smesessionId,
1736 uint16_t smetransactionId)
1737{
1738 tpSirDeltsRsp rsp;
1739 tSirMsgQ mmhMsg;
1740
1741 lim_log(pMac, LOGW, "SendSmeDeltsRsp (aid %d, tsid %d, up %d) status %d",
1742 delts->aid,
1743 delts->req.tsinfo.traffic.tsid,
1744 delts->req.tsinfo.traffic.userPrio, status);
1745 if (!delts->rspReqd)
1746 return;
1747
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301748 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001749 if (NULL == rsp) {
1750 /* Log error */
1751 lim_log(pMac, LOGP, FL("AllocateMemory failed for DELTS_RSP"));
1752 return;
1753 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001754
1755 if (psessionEntry != NULL) {
1756
1757 rsp->aid = delts->aid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301758 qdf_copy_macaddr(&rsp->macaddr, &delts->macaddr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301759 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) &delts->req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001760 sizeof(tSirDeltsReqInfo));
1761 }
1762
1763 rsp->messageType = eWNI_SME_DELTS_RSP;
1764 rsp->rc = status;
1765
1766 /* Update SME session Id and transcation Id */
1767 rsp->sessionId = smesessionId;
1768 rsp->transactionId = smetransactionId;
1769
1770 mmhMsg.type = eWNI_SME_DELTS_RSP;
1771 mmhMsg.bodyptr = rsp;
1772 mmhMsg.bodyval = 0;
1773 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301774 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1775 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001776 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301777 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1778 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001779 }
1780#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1781 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_RSP_EVENT, psessionEntry,
1782 (uint16_t) status, 0);
1783#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1784
1785 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1786}
1787
1788void
1789lim_send_sme_delts_ind(tpAniSirGlobal pMac, tpSirDeltsReqInfo delts, uint16_t aid,
1790 tpPESession psessionEntry)
1791{
1792 tpSirDeltsRsp rsp;
1793 tSirMsgQ mmhMsg;
1794
1795 lim_log(pMac, LOGW, "SendSmeDeltsInd (aid %d, tsid %d, up %d)",
1796 aid, delts->tsinfo.traffic.tsid, delts->tsinfo.traffic.userPrio);
1797
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301798 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001799 if (NULL == rsp) {
1800 /* Log error */
1801 lim_log(pMac, LOGP, FL("AllocateMemory failed for DELTS_IND"));
1802 return;
1803 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001804
1805 rsp->messageType = eWNI_SME_DELTS_IND;
1806 rsp->rc = eSIR_SUCCESS;
1807 rsp->aid = aid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301808 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) delts, sizeof(*delts));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001809
1810 /* Update SME session Id and SME transaction Id */
1811
1812 rsp->sessionId = psessionEntry->smeSessionId;
1813 rsp->transactionId = psessionEntry->transactionId;
1814
1815 mmhMsg.type = eWNI_SME_DELTS_IND;
1816 mmhMsg.bodyptr = rsp;
1817 mmhMsg.bodyval = 0;
1818 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1819#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1820 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_IND_EVENT, psessionEntry, 0,
1821 0);
1822#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1823
1824 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1825}
1826
1827/**
1828 * lim_send_sme_pe_statistics_rsp()
1829 *
1830 ***FUNCTION:
1831 * This function is called to send 802.11 statistics response to HDD.
1832 * This function posts the result back to HDD. This is a response to
1833 * HDD's request for statistics.
1834 *
1835 ***PARAMS:
1836 *
1837 ***LOGIC:
1838 *
1839 ***ASSUMPTIONS:
1840 * NA
1841 *
1842 ***NOTE:
1843 * NA
1844 *
1845 * @param pMac Pointer to Global MAC structure
1846 * @param p80211Stats Statistics sent in response
1847 * @param resultCode TODO:
1848 *
1849 *
1850 * @return none
1851 */
1852
1853void
1854lim_send_sme_pe_statistics_rsp(tpAniSirGlobal pMac, uint16_t msgType, void *stats)
1855{
1856 tSirMsgQ mmhMsg;
1857 uint8_t sessionId;
1858 tAniGetPEStatsRsp *pPeStats = (tAniGetPEStatsRsp *) stats;
1859 tpPESession pPeSessionEntry;
1860
1861 /* Get the Session Id based on Sta Id */
1862 pPeSessionEntry =
1863 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1864
1865 /* Fill the Session Id */
1866 if (NULL != pPeSessionEntry) {
1867 /* Fill the Session Id */
1868 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1869 }
1870
1871 pPeStats->msgType = eWNI_SME_GET_STATISTICS_RSP;
1872
1873 /* msgType should be WMA_GET_STATISTICS_RSP */
1874 mmhMsg.type = eWNI_SME_GET_STATISTICS_RSP;
1875
1876 mmhMsg.bodyptr = stats;
1877 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301878 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001879 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1880
1881 return;
1882
1883} /*** end lim_send_sme_pe_statistics_rsp() ***/
1884
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001885#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001886/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001887 * lim_send_sme_pe_ese_tsm_rsp() - send tsm response
1888 * @pMac: Pointer to global pMac structure
1889 * @pStats: Pointer to TSM Stats
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001890 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001891 * This function is called to send tsm stats response to HDD.
1892 * This function posts the result back to HDD. This is a response to
1893 * HDD's request to get tsm stats.
1894 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001895 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001896 */
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001897void lim_send_sme_pe_ese_tsm_rsp(tpAniSirGlobal pMac,
1898 tAniGetTsmStatsRsp *pStats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001899{
1900 tSirMsgQ mmhMsg;
1901 uint8_t sessionId;
1902 tAniGetTsmStatsRsp *pPeStats = (tAniGetTsmStatsRsp *) pStats;
1903 tpPESession pPeSessionEntry = NULL;
1904
1905 /* Get the Session Id based on Sta Id */
1906 pPeSessionEntry =
1907 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1908
1909 /* Fill the Session Id */
1910 if (NULL != pPeSessionEntry) {
1911 /* Fill the Session Id */
1912 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1913 } else {
1914 PELOGE(lim_log
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001915 (pMac, LOGE, FL("Session not found for the Sta id(%d)"),
1916 pPeStats->staId);)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001917 return;
1918 }
1919
1920 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
1921 pPeStats->tsmMetrics.RoamingCount
1922 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
1923 pPeStats->tsmMetrics.RoamingDly
1924 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
1925
1926 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
1927 mmhMsg.bodyptr = pStats;
1928 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301929 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001930 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1931
1932 return;
1933} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
1934
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001935#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001936
1937void
1938lim_send_sme_ibss_peer_ind(tpAniSirGlobal pMac,
1939 tSirMacAddr peerMacAddr,
1940 uint16_t staIndex,
1941 uint8_t ucastIdx,
1942 uint8_t bcastIdx,
1943 uint8_t *beacon,
1944 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
1945{
1946 tSirMsgQ mmhMsg;
1947 tSmeIbssPeerInd *pNewPeerInd;
1948
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301949 pNewPeerInd = qdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001950 if (NULL == pNewPeerInd) {
1951 PELOGE(lim_log(pMac, LOGE, FL("Failed to allocate memory"));)
1952 return;
1953 }
1954
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301955 qdf_mem_copy((uint8_t *) pNewPeerInd->peer_addr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301956 peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001957 pNewPeerInd->staId = staIndex;
1958 pNewPeerInd->ucastSig = ucastIdx;
1959 pNewPeerInd->bcastSig = bcastIdx;
1960 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
1961 pNewPeerInd->mesgType = msgType;
1962 pNewPeerInd->sessionId = sessionId;
1963
1964 if (beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301965 qdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001966 sizeof(tSmeIbssPeerInd)), (void *)beacon,
1967 beaconLen);
1968 }
1969
1970 mmhMsg.type = msgType;
1971 mmhMsg.bodyptr = pNewPeerInd;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301972 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001973 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1974
1975}
1976
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07001977/**
1978 * lim_process_csa_wbw_ie() - Process CSA Wide BW IE
1979 * @mac_ctx: pointer to global adapter context
1980 * @csa_params: pointer to CSA parameters
1981 * @chnl_switch_info:pointer to channel switch parameters
1982 * @session_entry: session pointer
1983 *
1984 * Return: None
1985 */
1986static void lim_process_csa_wbw_ie(tpAniSirGlobal mac_ctx,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07001987 struct csa_offload_params *csa_params,
1988 tLimWiderBWChannelSwitchInfo *chnl_switch_info,
1989 tpPESession session_entry)
1990{
1991 struct ch_params_s ch_params = {0};
1992 uint8_t ap_new_ch_width;
1993 bool new_ch_width_dfn = false;
1994 uint8_t center_freq_diff;
1995
1996 ap_new_ch_width = csa_params->new_ch_width + 1;
1997 if ((ap_new_ch_width == CH_WIDTH_80MHZ) &&
1998 csa_params->new_ch_freq_seg2) {
1999 new_ch_width_dfn = true;
2000 if (csa_params->new_ch_freq_seg2 >
2001 csa_params->new_ch_freq_seg1)
2002 center_freq_diff = csa_params->new_ch_freq_seg2 -
2003 csa_params->new_ch_freq_seg1;
2004 else
2005 center_freq_diff = csa_params->new_ch_freq_seg1 -
2006 csa_params->new_ch_freq_seg2;
2007 if (center_freq_diff == CENTER_FREQ_DIFF_160MHz)
2008 ap_new_ch_width = CH_WIDTH_160MHZ;
2009 else if (center_freq_diff > CENTER_FREQ_DIFF_80P80MHz)
2010 ap_new_ch_width = CH_WIDTH_80P80MHZ;
2011 else
2012 ap_new_ch_width = CH_WIDTH_80MHZ;
2013 }
2014 session_entry->gLimChannelSwitch.state =
2015 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2016 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
2017 !new_ch_width_dfn) {
2018 ch_params.ch_width = CH_WIDTH_160MHZ;
2019 cds_set_channel_params(csa_params->channel, 0,
2020 &ch_params);
2021 ap_new_ch_width = ch_params.ch_width;
2022 csa_params->new_ch_freq_seg1 = ch_params.center_freq_seg0;
2023 csa_params->new_ch_freq_seg2 = ch_params.center_freq_seg1;
2024 }
2025 chnl_switch_info->newChanWidth = ap_new_ch_width;
2026 chnl_switch_info->newCenterChanFreq0 = csa_params->new_ch_freq_seg1;
2027 chnl_switch_info->newCenterChanFreq1 = csa_params->new_ch_freq_seg2;
2028
2029 if (session_entry->ch_width == ap_new_ch_width)
2030 goto prnt_log;
2031
2032 if (session_entry->ch_width == CH_WIDTH_80MHZ) {
2033 chnl_switch_info->newChanWidth = CH_WIDTH_80MHZ;
2034 chnl_switch_info->newCenterChanFreq1 = 0;
2035 } else {
2036 session_entry->ch_width = ap_new_ch_width;
2037 chnl_switch_info->newChanWidth = ap_new_ch_width;
2038 }
2039prnt_log:
2040 lim_log(mac_ctx, LOG1,
2041 FL("new channel: %d new_ch_width:%d seg0:%d seg1:%d"),
2042 csa_params->channel,
2043 chnl_switch_info->newChanWidth,
2044 chnl_switch_info->newCenterChanFreq0,
2045 chnl_switch_info->newCenterChanFreq1);
2046}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002047/**
2048 * lim_handle_csa_offload_msg() - Handle CSA offload message
2049 * @mac_ctx: pointer to global adapter context
2050 * @msg: Message pointer.
2051 *
2052 * Return: None
2053 */
2054void lim_handle_csa_offload_msg(tpAniSirGlobal mac_ctx, tpSirMsgQ msg)
2055{
2056 tpPESession session_entry;
2057 tSirMsgQ mmh_msg;
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302058 struct csa_offload_params *csa_params =
2059 (struct csa_offload_params *) (msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002060 tpSmeCsaOffloadInd csa_offload_ind;
2061 tpDphHashNode sta_ds = NULL;
2062 uint8_t session_id;
2063 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302064 uint16_t chan_space = 0;
Amar Singhale4f28ee2015-10-21 14:36:56 -07002065 struct ch_params_s ch_params;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302066
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002067 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002068 tLimChannelSwitchInfo *lim_ch_switch = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002069
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302070 lim_log(mac_ctx, LOG1, FL("handle csa offload msg"));
2071
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002072 if (!csa_params) {
2073 lim_log(mac_ctx, LOGE, FL("limMsgQ body ptr is NULL"));
2074 return;
2075 }
2076
2077 session_entry =
2078 pe_find_session_by_bssid(mac_ctx,
2079 csa_params->bssId, &session_id);
2080 if (!session_entry) {
2081 lim_log(mac_ctx, LOGE,
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302082 FL("Session does not exists for %pM"),
2083 csa_params->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002084 goto err;
2085 }
2086
2087 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
2088 &session_entry->dph.dphHashTable);
2089
2090 if (!sta_ds) {
2091 lim_log(mac_ctx, LOGE,
2092 FL("sta_ds does not exist"));
2093 goto err;
2094 }
2095
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002096 if (!LIM_IS_STA_ROLE(session_entry)) {
2097 lim_log(mac_ctx, LOG1, FL("Invalid role to handle CSA"));
2098 goto err;
2099 }
Masti, Narayanraddi1c630442015-11-02 12:03:50 +05302100
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002101 /*
2102 * on receiving channel switch announcement from AP, delete all
2103 * TDLS peers before leaving BSS and proceed for channel switch
2104 */
2105 lim_delete_tdls_peers(mac_ctx, session_entry);
Gupta, Kapil121bf212015-11-25 19:21:29 +05302106
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002107 lim_ch_switch = &session_entry->gLimChannelSwitch;
2108 session_entry->gLimChannelSwitch.switchMode =
2109 csa_params->switch_mode;
2110 /* timer already started by firmware, switch immediately */
2111 session_entry->gLimChannelSwitch.switchCount = 0;
2112 session_entry->gLimChannelSwitch.primaryChannel =
2113 csa_params->channel;
2114 session_entry->gLimChannelSwitch.state =
2115 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2116 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
2117 lim_ch_switch->sec_ch_offset =
2118 session_entry->htSecondaryChannelOffset;
2119 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
2120 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
2121 chnl_switch_info =
2122 &session_entry->gLimWiderBWChannelSwitch;
2123
2124 lim_log(mac_ctx, LOG1,
2125 FL("vht:%d ht:%d flag:%x chan:%d"),
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302126 session_entry->vhtCapability,
2127 session_entry->htSupportedChannelWidthSet,
2128 csa_params->ies_present_flag,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002129 csa_params->channel);
2130 lim_log(mac_ctx, LOG1,
2131 FL("seg1:%d seg2:%d width:%d country:%s class:%d"),
2132 csa_params->new_ch_freq_seg1,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302133 csa_params->new_ch_freq_seg2,
2134 csa_params->new_ch_width,
2135 mac_ctx->scan.countryCodeCurrent,
2136 csa_params->new_op_class);
2137
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002138 if (session_entry->vhtCapability &&
2139 session_entry->htSupportedChannelWidthSet) {
2140 if (csa_params->ies_present_flag & lim_wbw_ie_present) {
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07002141 lim_process_csa_wbw_ie(mac_ctx, csa_params,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002142 chnl_switch_info, session_entry);
2143 lim_ch_switch->sec_ch_offset =
2144 csa_params->sec_chan_offset;
2145 } else if (csa_params->ies_present_flag
2146 & lim_xcsa_ie_present) {
2147 chan_space =
2148 cds_reg_dmn_get_chanwidth_from_opclass(
2149 mac_ctx->scan.countryCodeCurrent,
2150 csa_params->channel,
2151 csa_params->new_op_class);
2152 session_entry->gLimChannelSwitch.state =
2153 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2154
2155 if (chan_space == 80) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002156 chnl_switch_info->newChanWidth =
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002157 CH_WIDTH_80MHZ;
2158 } else if (chan_space == 40) {
2159 chnl_switch_info->newChanWidth =
2160 CH_WIDTH_40MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002161 } else {
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002162 chnl_switch_info->newChanWidth =
2163 CH_WIDTH_20MHZ;
2164 lim_ch_switch->state =
2165 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2166 }
2167
2168 ch_params.ch_width =
2169 chnl_switch_info->newChanWidth;
2170 cds_set_channel_params(csa_params->channel,
2171 0, &ch_params);
2172 chnl_switch_info->newCenterChanFreq0 =
2173 ch_params.center_freq_seg0;
2174 /*
2175 * This is not applicable for 20/40/80 MHz.
2176 * Only used when we support 80+80 MHz operation.
2177 * In case of 80+80 MHz, this parameter indicates
2178 * center channel frequency index of 80 MHz
2179 * channel offrequency segment 1.
2180 */
2181 chnl_switch_info->newCenterChanFreq1 =
2182 ch_params.center_freq_seg1;
2183 lim_ch_switch->sec_ch_offset =
2184 ch_params.sec_ch_offset;
2185
2186 }
2187 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
2188 chnl_switch_info->newCenterChanFreq0;
2189 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
2190 chnl_switch_info->newCenterChanFreq1;
2191 session_entry->gLimChannelSwitch.ch_width =
2192 chnl_switch_info->newChanWidth;
2193
2194 } else if (session_entry->htSupportedChannelWidthSet) {
2195 if (csa_params->ies_present_flag
2196 & lim_xcsa_ie_present) {
2197 chan_space =
2198 cds_reg_dmn_get_chanwidth_from_opclass(
2199 mac_ctx->scan.countryCodeCurrent,
2200 csa_params->channel,
2201 csa_params->new_op_class);
2202 lim_ch_switch->state =
2203 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2204 if (chan_space == 40) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002205 lim_ch_switch->ch_width =
2206 CH_WIDTH_40MHZ;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002207 chnl_switch_info->newChanWidth =
2208 CH_WIDTH_40MHZ;
2209 ch_params.ch_width =
2210 chnl_switch_info->newChanWidth;
2211 cds_set_channel_params(
2212 csa_params->channel,
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07002213 0, &ch_params);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002214 lim_ch_switch->ch_center_freq_seg0 =
2215 ch_params.center_freq_seg0;
2216 lim_ch_switch->sec_ch_offset =
2217 ch_params.sec_ch_offset;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002218 } else {
2219 lim_ch_switch->ch_width =
2220 CH_WIDTH_20MHZ;
2221 chnl_switch_info->newChanWidth =
2222 CH_WIDTH_40MHZ;
2223 lim_ch_switch->state =
2224 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2225 lim_ch_switch->sec_ch_offset =
2226 PHY_SINGLE_CHANNEL_CENTERED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002227 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002228 } else {
2229 lim_ch_switch->ch_width =
2230 CH_WIDTH_40MHZ;
2231 lim_ch_switch->state =
2232 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2233 ch_params.ch_width = CH_WIDTH_40MHZ;
2234 cds_set_channel_params(csa_params->channel,
2235 0, &ch_params);
2236 lim_ch_switch->ch_center_freq_seg0 =
2237 ch_params.center_freq_seg0;
2238 lim_ch_switch->sec_ch_offset =
2239 ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002240 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002241
2242 }
2243 lim_log(mac_ctx, LOG1, FL("new ch width = %d space:%d"),
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302244 session_entry->gLimChannelSwitch.ch_width, chan_space);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002245
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002246 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
2247 csa_offload_ind = qdf_mem_malloc(sizeof(tSmeCsaOffloadInd));
2248 if (NULL == csa_offload_ind) {
2249 lim_log(mac_ctx, LOGE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002250 FL("memalloc fail eWNI_SME_CSA_OFFLOAD_EVENT"));
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002251 goto err;
2252 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002253
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002254 csa_offload_ind->mesgType = eWNI_SME_CSA_OFFLOAD_EVENT;
2255 csa_offload_ind->mesgLen = sizeof(tSmeCsaOffloadInd);
2256 qdf_mem_copy(csa_offload_ind->bssid.bytes, session_entry->bssId,
2257 QDF_MAC_ADDR_SIZE);
2258 mmh_msg.type = eWNI_SME_CSA_OFFLOAD_EVENT;
2259 mmh_msg.bodyptr = csa_offload_ind;
2260 mmh_msg.bodyval = 0;
2261 lim_log(mac_ctx, LOG1,
Srinivas Girigowdac9148f72015-11-25 12:42:32 -08002262 FL("Sending eWNI_SME_CSA_OFFLOAD_EVENT to SME."));
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002263 MTRACE(mac_trace_msg_tx
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002264 (mac_ctx, session_entry->peSessionId, mmh_msg.type));
2265#ifdef FEATURE_WLAN_DIAG_SUPPORT
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002266 lim_diag_event_report(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002267 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
2268 eSIR_SUCCESS, eSIR_SUCCESS);
2269#endif
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002270 lim_sys_process_mmh_msg_api(mac_ctx, &mmh_msg, ePROT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002271
2272err:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302273 qdf_mem_free(csa_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002274}
2275
2276/*--------------------------------------------------------------------------
2277 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
2278
2279 \param pMac - pointer to global adapter context
2280 \param sessionId - Message pointer.
2281
2282 \sa
2283 --------------------------------------------------------------------------*/
2284
2285void lim_handle_delete_bss_rsp(tpAniSirGlobal pMac, tpSirMsgQ MsgQ)
2286{
2287 tpPESession psessionEntry;
2288 tpDeleteBssParams pDelBss = (tpDeleteBssParams) (MsgQ->bodyptr);
2289
2290 psessionEntry =
2291 pe_find_session_by_session_id(pMac, pDelBss->sessionId);
2292 if (psessionEntry == NULL) {
2293 lim_log(pMac, LOGE,
2294 FL("Session Does not exist for given sessionID %d"),
2295 pDelBss->sessionId);
Naveen Rawat0c81edc2016-06-08 10:08:30 -07002296 qdf_mem_free(MsgQ->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002297 return;
2298 }
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002299 /*
2300 * During DEL BSS handling, the PE Session will be deleted, but it is
2301 * better to clear this flag if the session is hanging around due
2302 * to some error conditions so that the next DEL_BSS request does
2303 * not take the HO_FAIL path
2304 */
2305 psessionEntry->process_ho_fail = false;
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002306 if (LIM_IS_IBSS_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002307 lim_ibss_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002308 else if (LIM_IS_UNKNOWN_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002309 lim_process_sme_del_bss_rsp(pMac, MsgQ->bodyval, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002310 else if (LIM_IS_NDI_ROLE(psessionEntry))
2311 lim_ndi_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002312 else
2313 lim_process_mlm_del_bss_rsp(pMac, MsgQ, psessionEntry);
2314
2315}
2316
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002317/** -----------------------------------------------------------------
2318 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
2319 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
2320 \ SME only looks at rc and tspec field.
2321 \param pMac - global mac structure
2322 \param rspReqd - is SmeAddTsRsp required
2323 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
2324 \return tspec
2325 \sa
2326 ----------------------------------------------------------------- */
2327void
2328lim_send_sme_aggr_qos_rsp(tpAniSirGlobal pMac, tpSirAggrQosRsp aggrQosRsp,
2329 uint8_t smesessionId)
2330{
2331 tSirMsgQ mmhMsg;
2332
2333 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
2334 mmhMsg.bodyptr = aggrQosRsp;
2335 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302336 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2337 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002338 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2339
2340 return;
2341}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002342
2343void lim_send_sme_max_assoc_exceeded_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
2344 uint8_t smesessionId)
2345{
2346 tSirMsgQ mmhMsg;
2347 tSmeMaxAssocInd *pSmeMaxAssocInd;
2348
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302349 pSmeMaxAssocInd = qdf_mem_malloc(sizeof(tSmeMaxAssocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002350 if (NULL == pSmeMaxAssocInd) {
2351 PELOGE(lim_log(pMac, LOGE, FL("Failed to allocate memory"));)
2352 return;
2353 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302354 qdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peer_mac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302355 (uint8_t *) peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002356 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
2357 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
2358 pSmeMaxAssocInd->sessionId = smesessionId;
2359 mmhMsg.type = pSmeMaxAssocInd->mesgType;
2360 mmhMsg.bodyptr = pSmeMaxAssocInd;
2361 PELOG1(lim_log(pMac, LOG1, FL("msgType %s peerMacAddr " MAC_ADDRESS_STR
2362 " sme session id %d"),
2363 "eWNI_SME_MAX_ASSOC_EXCEEDED",
2364 MAC_ADDR_ARRAY(peerMacAddr));
2365 )
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302366 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2367 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002368 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2369
2370 return;
2371}
2372
2373/** -----------------------------------------------------------------
2374 \brief lim_send_sme_dfs_event_notify() - sends
2375 eWNI_SME_DFS_RADAR_FOUND
2376 After receiving WMI_PHYERR_EVENTID indication frame from FW, this
2377 function sends a eWNI_SME_DFS_RADAR_FOUND to SME to notify
2378 that a RADAR is found on current operating channel and SAP-
2379 has to move to a new channel.
2380 \param pMac - global mac structure
2381 \param msgType - message type received from lower layer
2382 \param event - event data received from lower layer
2383 \return none
2384 \sa
2385 ----------------------------------------------------------------- */
2386void
2387lim_send_sme_dfs_event_notify(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2388{
2389 tSirMsgQ mmhMsg;
2390 mmhMsg.type = eWNI_SME_DFS_RADAR_FOUND;
2391 mmhMsg.bodyptr = event;
2392 mmhMsg.bodyval = 0;
2393 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2394 return;
2395}
2396
2397/*--------------------------------------------------------------------------
2398 \brief lim_send_dfs_chan_sw_ie_update()
2399 This timer handler updates the channel switch IE in beacon template
2400
2401 \param pMac - pointer to global adapter context
2402 \return - channel to scan from valid session else zero.
2403 \sa
2404 --------------------------------------------------------------------------*/
2405static void
2406lim_send_dfs_chan_sw_ie_update(tpAniSirGlobal pMac, tpPESession psessionEntry)
2407{
2408
2409 /* Update the beacon template and send to FW */
2410 if (sch_set_fixed_beacon_fields(pMac, psessionEntry) != eSIR_SUCCESS) {
2411 PELOGE(lim_log(pMac, LOGE, FL("Unable to set CSA IE in beacon"));)
2412 return;
2413 }
2414
2415 /* Send update beacon template message */
2416 lim_send_beacon_ind(pMac, psessionEntry);
2417 PELOG1(lim_log(pMac, LOG1,
2418 FL(" Updated CSA IE, IE COUNT = %d"),
2419 psessionEntry->gLimChannelSwitch.switchCount);
2420 )
2421
2422 return;
2423}
2424
2425/** -----------------------------------------------------------------
2426 \brief lim_send_sme_ap_channel_switch_resp() - sends
2427 eWNI_SME_CHANNEL_CHANGE_RSP
2428 After receiving WMA_SWITCH_CHANNEL_RSP indication this
2429 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
2430 that the Channel change has been done to the specified target
2431 channel in the Channel change request
2432 \param pMac - global mac structure
2433 \param psessionEntry - session info
2434 \param pChnlParams - Channel switch params
2435 --------------------------------------------------------------------*/
2436void
2437lim_send_sme_ap_channel_switch_resp(tpAniSirGlobal pMac,
2438 tpPESession psessionEntry,
2439 tpSwitchChannelParams pChnlParams)
2440{
2441 tSirMsgQ mmhMsg;
2442 tpSwitchChannelParams pSmeSwithChnlParams;
2443 uint8_t channelId;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002444 bool is_ch_dfs = false;
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08002445 enum phy_ch_width ch_width;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002446 uint8_t ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002447
2448 pSmeSwithChnlParams = (tSwitchChannelParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302449 qdf_mem_malloc(sizeof(tSwitchChannelParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002450 if (NULL == pSmeSwithChnlParams) {
2451 lim_log(pMac, LOGP,
2452 FL("AllocateMemory failed for pSmeSwithChnlParams\n"));
2453 return;
2454 }
2455
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302456 qdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002457 sizeof(tSwitchChannelParams));
2458
2459 channelId = pSmeSwithChnlParams->channelNumber;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002460 ch_width = pSmeSwithChnlParams->ch_width;
2461 ch_center_freq_seg1 = pSmeSwithChnlParams->ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002462
2463 /*
2464 * Pass the sme sessionID to SME instead
2465 * PE session ID.
2466 */
2467 pSmeSwithChnlParams->peSessionId = psessionEntry->smeSessionId;
2468
2469 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
2470 mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
2471 mmhMsg.bodyval = 0;
2472 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2473
2474 /*
2475 * We should start beacon transmission only if the new
2476 * channel after channel change is Non-DFS. For a DFS
2477 * channel, PE will receive an explicit request from
2478 * upper layers to start the beacon transmission .
2479 */
2480
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002481 if (ch_width == CH_WIDTH_160MHZ) {
2482 is_ch_dfs = true;
2483 } else if (ch_width == CH_WIDTH_80P80MHZ) {
2484 if (cds_get_channel_state(channelId) == CHANNEL_STATE_DFS ||
2485 cds_get_channel_state(ch_center_freq_seg1 -
2486 SIR_80MHZ_START_CENTER_CH_DIFF) ==
2487 CHANNEL_STATE_DFS)
2488 is_ch_dfs = true;
2489 } else {
2490 if (cds_get_channel_state(channelId) == CHANNEL_STATE_DFS)
2491 is_ch_dfs = true;
2492 }
2493
2494 if (!is_ch_dfs) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002495 if (channelId == psessionEntry->currentOperChannel) {
2496 lim_apply_configuration(pMac, psessionEntry);
2497 lim_send_beacon_ind(pMac, psessionEntry);
2498 } else {
2499 PELOG1(lim_log(pMac, LOG1,
2500 FL
2501 ("Failed to Transmit Beacons on channel = %d"
2502 "after AP channel change response"),
2503 psessionEntry->bcnLen);
2504 )
2505 }
2506 }
2507 return;
2508}
2509
2510/** -----------------------------------------------------------------
2511 \brief lim_process_beacon_tx_success_ind() - This function is used
2512 explicitely to handle successful beacon transmission indication
2513 from the FW. This is a generic event generated by the FW afer the
2514 first beacon is sent out after the beacon template update by the
2515 host
2516 \param pMac - global mac structure
2517 \param psessionEntry - session info
2518 \return none
2519 \sa
2520 ----------------------------------------------------------------- */
2521void
2522lim_process_beacon_tx_success_ind(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2523{
2524 /* Currently, this event is used only for DFS channel switch announcement
2525 * IE update in the template. If required to be used for other IE updates
2526 * add appropriate code by introducing a state variable
2527 */
2528 tpPESession psessionEntry;
2529 tSirMsgQ mmhMsg;
2530 tSirSmeCSAIeTxCompleteRsp *pChanSwTxResponse;
2531 struct sir_beacon_tx_complete_rsp *beacon_tx_comp_rsp_ptr;
2532 uint8_t length = sizeof(tSirSmeCSAIeTxCompleteRsp);
2533 tpSirFirstBeaconTxCompleteInd pBcnTxInd =
2534 (tSirFirstBeaconTxCompleteInd *) event;
2535
2536 psessionEntry = pe_find_session_by_bss_idx(pMac, pBcnTxInd->bssIdx);
2537 if (psessionEntry == NULL) {
2538 lim_log(pMac, LOGE,
2539 FL("Session Does not exist for given sessionID"));
2540 return;
2541 }
2542
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302543 lim_log(pMac, LOG1, FL("role:%d swIe:%d opIe:%d"),
2544 GET_LIM_SYSTEM_ROLE(psessionEntry),
2545 psessionEntry->dfsIncludeChanSwIe,
2546 psessionEntry->gLimOperatingMode.present);
2547
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002548 if (LIM_IS_AP_ROLE(psessionEntry) &&
2549 true == psessionEntry->dfsIncludeChanSwIe) {
2550 /* Send only 5 beacons with CSA IE Set in when a radar is detected */
2551 if (psessionEntry->gLimChannelSwitch.switchCount > 0) {
2552 /*
2553 * Send the next beacon with updated CSA IE count
2554 */
2555 lim_send_dfs_chan_sw_ie_update(pMac, psessionEntry);
2556 /* Decrement the IE count */
2557 psessionEntry->gLimChannelSwitch.switchCount--;
2558 } else {
2559 /* Done with CSA IE update, send response back to SME */
2560 psessionEntry->gLimChannelSwitch.switchCount = 0;
2561 if (pMac->sap.SapDfsInfo.disable_dfs_ch_switch == false)
2562 psessionEntry->gLimChannelSwitch.switchMode = 0;
2563 psessionEntry->dfsIncludeChanSwIe = false;
2564 psessionEntry->dfsIncludeChanWrapperIe = false;
2565
2566 pChanSwTxResponse = (tSirSmeCSAIeTxCompleteRsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302567 qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002568
2569 if (NULL == pChanSwTxResponse) {
2570 lim_log(pMac, LOGP,
2571 FL
2572 ("AllocateMemory failed for tSirSmeCSAIeTxCompleteRsp"));
2573 return;
2574 }
2575
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002576 pChanSwTxResponse->sessionId =
2577 psessionEntry->smeSessionId;
2578 pChanSwTxResponse->chanSwIeTxStatus =
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302579 QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002580
2581 mmhMsg.type = eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND;
2582 mmhMsg.bodyptr = pChanSwTxResponse;
2583 mmhMsg.bodyval = 0;
2584 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2585 }
2586 }
2587
2588 if (LIM_IS_AP_ROLE(psessionEntry) &&
2589 psessionEntry->gLimOperatingMode.present) {
2590 /* Done with nss update, send response back to SME */
2591 psessionEntry->gLimOperatingMode.present = 0;
2592 beacon_tx_comp_rsp_ptr = (struct sir_beacon_tx_complete_rsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302593 qdf_mem_malloc(sizeof(*beacon_tx_comp_rsp_ptr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002594 if (NULL == beacon_tx_comp_rsp_ptr) {
2595 lim_log(pMac, LOGP,
2596 FL
2597 ("AllocateMemory failed for beacon_tx_comp_rsp_ptr"));
2598 return;
2599 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002600 beacon_tx_comp_rsp_ptr->session_id =
2601 psessionEntry->smeSessionId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302602 beacon_tx_comp_rsp_ptr->tx_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002603 mmhMsg.type = eWNI_SME_NSS_UPDATE_RSP;
2604 mmhMsg.bodyptr = beacon_tx_comp_rsp_ptr;
2605 mmhMsg.bodyval = 0;
2606 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2607 }
2608 return;
2609}