blob: dd1aa2e33f3bae0a0822fb1174aa7568843a5262 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Nitesh Shah82c52812016-12-27 12:27:51 +05302 * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/*
29 * This file lim_send_sme_rspMessages.cc contains the functions
30 * for sending SME response/notification messages to applications
31 * above MAC software.
32 * Author: Chandra Modumudi
33 * Date: 02/13/02
34 * History:-
35 * Date Modified by Modification Information
36 * --------------------------------------------------------------------
37 */
38
Anurag Chouhan6d760662016-02-20 16:05:43 +053039#include "qdf_types.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080040#include "wni_api.h"
41#include "sir_common.h"
42#include "ani_global.h"
43
44#include "wni_cfg.h"
45#include "sys_def.h"
46#include "cfg_api.h"
47
48#include "sch_api.h"
49#include "utils_api.h"
50#include "lim_utils.h"
51#include "lim_security_utils.h"
52#include "lim_ser_des_utils.h"
53#include "lim_send_sme_rsp_messages.h"
54#include "lim_ibss_peer_mgmt.h"
55#include "lim_session_utils.h"
56#include "lim_types.h"
57#include "sir_api.h"
Naveen Rawat3b6068c2016-04-14 19:01:06 -070058#include "cds_regdomain.h"
Gupta, Kapil121bf212015-11-25 19:21:29 +053059#include "lim_send_messages.h"
Deepak Dhamdhere13983f22016-05-31 19:06:09 -070060#include "nan_datapath.h"
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -070061#include "lim_assoc_utils.h"
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070062#include "wlan_reg_services_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080063
Kabilan Kannan1c1c4022017-04-06 22:49:26 -070064#ifdef CONVERGED_TDLS_ENABLE
Kabilan Kannanf56f9d52017-04-05 03:31:34 -070065#include "wlan_tdls_tgt_api.h"
Kabilan Kannan1c1c4022017-04-06 22:49:26 -070066#endif
Kabilan Kannanf56f9d52017-04-05 03:31:34 -070067
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080068static void lim_handle_join_rsp_status(tpAniSirGlobal mac_ctx,
69 tpPESession session_entry, tSirResultCodes result_code,
70 tpSirSmeJoinRsp sme_join_rsp);
71
72/**
73 * lim_send_sme_rsp() - Send Response to upper layers
74 * @mac_ctx: Pointer to Global MAC structure
75 * @msg_type: Indicates message type
76 * @result_code: Indicates the result of previously issued
77 * eWNI_SME_msg_type_REQ message
78 *
79 * This function is called by lim_process_sme_req_messages() to send
80 * eWNI_SME_START_RSP, eWNI_SME_STOP_BSS_RSP
81 * or eWNI_SME_SWITCH_CHL_RSP messages to applications above MAC
82 * Software.
83 *
84 * Return: None
85 */
86
87void
88lim_send_sme_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
89 tSirResultCodes result_code, uint8_t sme_session_id,
90 uint16_t sme_transaction_id)
91{
Rajeev Kumar37d478b2017-04-17 16:59:28 -070092 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080093 tSirSmeRsp *sme_rsp;
94
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +053095 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080096 lim_msg_str(msg_type), lim_result_code_str(result_code));
97
Anurag Chouhan600c3a02016-03-01 10:33:54 +053098 sme_rsp = qdf_mem_malloc(sizeof(tSirSmeRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080099 if (NULL == sme_rsp) {
100 /* Buffer not available. Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530101 pe_err("call to AllocateMemory failed for eWNI_SME_*_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800102 return;
103 }
104
105 sme_rsp->messageType = msg_type;
106 sme_rsp->length = sizeof(tSirSmeRsp);
107 sme_rsp->statusCode = result_code;
108
109 sme_rsp->sessionId = sme_session_id;
110 sme_rsp->transactionId = sme_transaction_id;
111
112 msg.type = msg_type;
113 msg.bodyptr = sme_rsp;
114 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530115 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG,
116 sme_session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800117
118#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
119 switch (msg_type) {
120 case eWNI_SME_STOP_BSS_RSP:
121 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_STOP_BSS_RSP_EVENT,
122 NULL, (uint16_t) result_code, 0);
123 break;
124 }
125#endif /* FEATURE_WLAN_DIAG_SUPPORT */
126 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
127}
128
129
130
131/**
132 * lim_send_sme_roc_rsp() - Send Response to SME
133 * @mac_ctx: Pointer to Global MAC structure
134 * @status: Resume link status
135 * @result_code: Result of the ROC request
136 * @sme_session_id: SME sesson Id
137 * @scan_id: Scan Identifier
138 *
139 * This function is called to send ROC rsp
140 * message to SME.
141 *
142 * Return: None
143 */
144void
145lim_send_sme_roc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
146 tSirResultCodes result_code, uint8_t sme_session_id,
147 uint32_t scan_id)
148{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700149 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800150 struct sir_roc_rsp *sme_rsp;
151
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530152 pe_debug("Sending message: %s with reasonCode: %s scanId: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800153 lim_msg_str(msg_type), lim_result_code_str(result_code),
154 scan_id);
155
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530156 sme_rsp = qdf_mem_malloc(sizeof(struct sir_roc_rsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800157 if (NULL == sme_rsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530158 pe_err("call to AllocateMemory failed for eWNI_SME_*_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800159 return;
160 }
161
162 sme_rsp->message_type = msg_type;
163 sme_rsp->length = sizeof(struct sir_roc_rsp);
164 sme_rsp->status = result_code;
165
166 sme_rsp->session_id = sme_session_id;
167 sme_rsp->scan_id = scan_id;
168
169 msg.type = msg_type;
170 msg.bodyptr = sme_rsp;
171 msg.bodyval = 0;
172 MTRACE(mac_trace_msg_tx(mac_ctx, sme_session_id, msg.type));
173 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
174}
175
176
177/**
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530178 * lim_get_max_rate_flags() - Get rate flags
179 * @mac_ctx: Pointer to global MAC structure
180 * @sta_ds: Pointer to station ds structure
181 *
182 * This function is called to get the rate flags for a connection
183 * from the station ds structure depending on the ht and the vht
184 * channel width supported.
185 *
186 * Return: Returns the populated rate_flags
187 */
188uint32_t lim_get_max_rate_flags(tpAniSirGlobal mac_ctx, tpDphHashNode sta_ds)
189{
190 uint32_t rate_flags = 0;
191
192 if (sta_ds == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530193 pe_err("sta_ds is NULL");
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530194 return rate_flags;
195 }
196
197 if (!sta_ds->mlmStaContext.htCapability &&
198 !sta_ds->mlmStaContext.vhtCapability) {
199 rate_flags |= eHAL_TX_RATE_LEGACY;
200 } else {
201 if (sta_ds->mlmStaContext.vhtCapability) {
202 if (WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ ==
203 sta_ds->vhtSupportedChannelWidthSet) {
204 rate_flags |= eHAL_TX_RATE_VHT80;
205 } else if (WNI_CFG_VHT_CHANNEL_WIDTH_20_40MHZ ==
206 sta_ds->vhtSupportedChannelWidthSet) {
207 if (sta_ds->htSupportedChannelWidthSet)
208 rate_flags |= eHAL_TX_RATE_VHT40;
209 else
210 rate_flags |= eHAL_TX_RATE_VHT20;
211 }
212 } else if (sta_ds->mlmStaContext.htCapability) {
213 if (sta_ds->htSupportedChannelWidthSet)
214 rate_flags |= eHAL_TX_RATE_HT40;
215 else
216 rate_flags |= eHAL_TX_RATE_HT20;
217 }
218 }
219
220 if (sta_ds->htShortGI20Mhz || sta_ds->htShortGI40Mhz)
221 rate_flags |= eHAL_TX_RATE_SGI;
222
223 return rate_flags;
224}
225
226/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227 * lim_send_sme_join_reassoc_rsp_after_resume() - Send Response to SME
228 * @mac_ctx Pointer to Global MAC structure
229 * @status Resume link status
230 * @ctx context passed while calling resmune link.
231 * (join response to be sent)
232 *
233 * This function is called to send Join/Reassoc rsp
234 * message to SME after the resume link.
235 *
236 * Return: None
237 */
238static void lim_send_sme_join_reassoc_rsp_after_resume(tpAniSirGlobal mac_ctx,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530239 QDF_STATUS status, uint32_t *ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800240{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700241 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800242 tpSirSmeJoinRsp sme_join_rsp = (tpSirSmeJoinRsp) ctx;
243
244 msg.type = sme_join_rsp->messageType;
245 msg.bodyptr = sme_join_rsp;
246 msg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530247 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, NO_SESSION, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800248 lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT);
249}
250
251/**
252 * lim_handle_join_rsp_status() - Handle the response.
253 * @mac_ctx: Pointer to Global MAC structure
254 * @session_entry: PE Session Info
255 * @result_code: Indicates the result of previously issued
256 * eWNI_SME_msgType_REQ message
257 * @sme_join_rsp The received response.
258 *
259 * This function will handle both the success and failure status
260 * of the received response.
261 *
262 * Return: None
263 */
264static void lim_handle_join_rsp_status(tpAniSirGlobal mac_ctx,
265 tpPESession session_entry, tSirResultCodes result_code,
266 tpSirSmeJoinRsp sme_join_rsp)
267{
268#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
269 tSirSmeHTProfile *ht_profile;
270#endif
271 if (result_code == eSIR_SME_SUCCESS) {
272 if (session_entry->beacon != NULL) {
273 sme_join_rsp->beaconLength = session_entry->bcnLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530274 qdf_mem_copy(sme_join_rsp->frames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800275 session_entry->beacon,
276 sme_join_rsp->beaconLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530277 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800278 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530279 session_entry->bcnLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530280 pe_debug("Beacon: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530281 sme_join_rsp->beaconLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800282 }
283 if (session_entry->assocReq != NULL) {
284 sme_join_rsp->assocReqLength =
285 session_entry->assocReqLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530286 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530287 sme_join_rsp->beaconLength,
288 session_entry->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800289 sme_join_rsp->assocReqLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530290 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800291 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530292 session_entry->assocReqLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530293 pe_debug("AssocReq: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530294 sme_join_rsp->assocReqLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800295 }
296 if (session_entry->assocRsp != NULL) {
297 sme_join_rsp->assocRspLength =
298 session_entry->assocRspLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530299 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530300 sme_join_rsp->beaconLength +
301 sme_join_rsp->assocReqLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800302 session_entry->assocRsp,
303 sme_join_rsp->assocRspLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530304 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800305 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530306 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800307 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800308 if (session_entry->ricData != NULL) {
309 sme_join_rsp->parsedRicRspLen =
310 session_entry->RICDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530311 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530312 sme_join_rsp->beaconLength +
313 sme_join_rsp->assocReqLength +
314 sme_join_rsp->assocRspLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800315 session_entry->ricData,
316 sme_join_rsp->parsedRicRspLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530317 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800318 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530319 session_entry->RICDataLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530320 pe_debug("RicLength: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800321 sme_join_rsp->parsedRicRspLen);
322 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800323#ifdef FEATURE_WLAN_ESE
324 if (session_entry->tspecIes != NULL) {
325 sme_join_rsp->tspecIeLen =
326 session_entry->tspecLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530327 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530328 sme_join_rsp->beaconLength +
329 sme_join_rsp->assocReqLength +
330 sme_join_rsp->assocRspLength +
331 sme_join_rsp->parsedRicRspLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800332 session_entry->tspecIes,
333 sme_join_rsp->tspecIeLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530334 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800335 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530336 session_entry->tspecLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530337 pe_debug("ESE-TspecLen: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530338 sme_join_rsp->tspecIeLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800339 }
340#endif
341 sme_join_rsp->aid = session_entry->limAID;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530342 pe_debug("AssocRsp: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530343 sme_join_rsp->assocRspLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800344 sme_join_rsp->vht_channel_width =
345 session_entry->ch_width;
346#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
347 if (session_entry->cc_switch_mode !=
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530348 QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800349 ht_profile = &sme_join_rsp->HTProfile;
350 ht_profile->htSupportedChannelWidthSet =
351 session_entry->htSupportedChannelWidthSet;
352 ht_profile->htRecommendedTxWidthSet =
353 session_entry->htRecommendedTxWidthSet;
354 ht_profile->htSecondaryChannelOffset =
355 session_entry->htSecondaryChannelOffset;
356 ht_profile->dot11mode = session_entry->dot11mode;
357 ht_profile->htCapability = session_entry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800358 ht_profile->vhtCapability =
359 session_entry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800360 ht_profile->apCenterChan = session_entry->ch_center_freq_seg0;
361 ht_profile->apChanWidth = session_entry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800362 }
363#endif
364 } else {
365 if (session_entry->beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530366 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800367 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530368 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800369 }
370 if (session_entry->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530371 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800372 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530373 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800374 }
375 if (session_entry->assocRsp != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530376 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800377 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530378 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800379 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800380 if (session_entry->ricData != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530381 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800382 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530383 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800384 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800385#ifdef FEATURE_WLAN_ESE
386 if (session_entry->tspecIes != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530387 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800388 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530389 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800390 }
391#endif
392 }
393}
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530394
395/**
396 * lim_add_bss_info() - copy data from session entry to join rsp
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530397 * @sta_ds: Station dph entry
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530398 * @sme_join_rsp: Join response buffer to be filled up
399 *
400 * Return: None
401 */
Jeff Johnson6db011e2016-10-07 07:31:39 -0700402static void lim_add_bss_info(tpDphHashNode sta_ds, tpSirSmeJoinRsp sme_join_rsp)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530403{
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530404 struct parsed_ies *parsed_ies = &sta_ds->parsed_ies;
405
406 if (parsed_ies->hs20vendor_ie.present)
407 sme_join_rsp->hs20vendor_ie = parsed_ies->hs20vendor_ie;
408 if (parsed_ies->vht_caps.present)
409 sme_join_rsp->vht_caps = parsed_ies->vht_caps;
410 if (parsed_ies->ht_caps.present)
411 sme_join_rsp->ht_caps = parsed_ies->ht_caps;
412 if (parsed_ies->ht_operation.present)
413 sme_join_rsp->ht_operation = parsed_ies->ht_operation;
414 if (parsed_ies->vht_operation.present)
415 sme_join_rsp->vht_operation = parsed_ies->vht_operation;
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530416}
417
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800418/**
419 * lim_send_sme_join_reassoc_rsp() - Send Response to Upper Layers
420 * @mac_ctx: Pointer to Global MAC structure
421 * @msg_type: Indicates message type
422 * @result_code: Indicates the result of previously issued
423 * eWNI_SME_msgType_REQ message
424 * @prot_status_code: Protocol Status Code
425 * @session_entry: PE Session Info
426 * @sme_session_id: SME Session ID
427 * @sme_transaction_id: SME Transaction ID
428 *
429 * This function is called by lim_process_sme_req_messages() to send
430 * eWNI_SME_JOIN_RSP or eWNI_SME_REASSOC_RSP messages to applications
431 * above MAC Software.
432 *
433 * Return: None
434 */
435
436void
437lim_send_sme_join_reassoc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
438 tSirResultCodes result_code, uint16_t prot_status_code,
439 tpPESession session_entry, uint8_t sme_session_id,
440 uint16_t sme_transaction_id)
441{
442 tpSirSmeJoinRsp sme_join_rsp;
443 uint32_t rsp_len;
444 tpDphHashNode sta_ds = NULL;
445#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
446 if (msg_type == eWNI_SME_REASSOC_RSP)
447 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_RSP_EVENT,
448 session_entry, (uint16_t) result_code, 0);
449 else
450 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_RSP_EVENT,
451 session_entry, (uint16_t) result_code, 0);
452#endif /* FEATURE_WLAN_DIAG_SUPPORT */
453
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530454 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800455 lim_msg_str(msg_type), lim_result_code_str(result_code));
456
457 if (session_entry == NULL) {
458 rsp_len = sizeof(tSirSmeJoinRsp);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530459 sme_join_rsp = qdf_mem_malloc(rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800460 if (NULL == sme_join_rsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530461 pe_err("Mem Alloc fail - JOIN/REASSOC_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800462 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) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530478 pe_err("MemAlloc fail - JOIN/REASSOC_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800479 return;
480 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800481 if (result_code == eSIR_SME_SUCCESS) {
482 sta_ds = dph_get_hash_entry(mac_ctx,
483 DPH_STA_HASH_INDEX_PEER,
484 &session_entry->dph.dphHashTable);
485 if (sta_ds == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530486 pe_err("Get Self Sta Entry fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800487 } else {
488 /* Pass the peer's staId */
489 sme_join_rsp->staId = sta_ds->staIndex;
490 sme_join_rsp->ucastSig =
491 sta_ds->ucUcastSig;
492 sme_join_rsp->bcastSig =
493 sta_ds->ucBcastSig;
494 sme_join_rsp->timingMeasCap =
495 sta_ds->timingMeasCap;
496#ifdef FEATURE_WLAN_TDLS
497 sme_join_rsp->tdls_prohibited =
498 session_entry->tdls_prohibited;
499 sme_join_rsp->tdls_chan_swit_prohibited =
500 session_entry->tdls_chan_swit_prohibited;
501#endif
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530502 sme_join_rsp->nss = sta_ds->nss;
503 sme_join_rsp->max_rate_flags =
504 lim_get_max_rate_flags(mac_ctx, sta_ds);
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530505 lim_add_bss_info(sta_ds, sme_join_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800506 }
507 }
508 sme_join_rsp->beaconLength = 0;
509 sme_join_rsp->assocReqLength = 0;
510 sme_join_rsp->assocRspLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800511 sme_join_rsp->parsedRicRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800512#ifdef FEATURE_WLAN_ESE
513 sme_join_rsp->tspecIeLen = 0;
514#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800515 lim_handle_join_rsp_status(mac_ctx, session_entry, result_code,
516 sme_join_rsp);
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800517
518 /* Send supported NSS 1x1 to SME */
519 sme_join_rsp->supported_nss_1x1 =
520 session_entry->supported_nss_1x1;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530521 pe_debug("SME Join Rsp is supported NSS 1X1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800522 sme_join_rsp->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800523 }
524
525 sme_join_rsp->messageType = msg_type;
526 sme_join_rsp->length = (uint16_t) rsp_len;
527 sme_join_rsp->statusCode = result_code;
528 sme_join_rsp->protStatusCode = prot_status_code;
529
530 sme_join_rsp->sessionId = sme_session_id;
531 sme_join_rsp->transactionId = sme_transaction_id;
532
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530533 lim_send_sme_join_reassoc_rsp_after_resume(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800534 (uint32_t *)sme_join_rsp);
535}
536
537/**
538 * lim_send_sme_start_bss_rsp()
539 *
540 ***FUNCTION:
541 * This function is called to send eWNI_SME_START_BSS_RSP
542 * message to applications above MAC Software.
543 *
544 ***PARAMS:
545 *
546 ***LOGIC:
547 *
548 ***ASSUMPTIONS:
549 * NA
550 *
551 ***NOTE:
552 * NA
553 *
554 * @param pMac Pointer to Global MAC structure
555 * @param msgType Indicates message type
556 * @param resultCode Indicates the result of previously issued
557 * eWNI_SME_msgType_REQ message
558 *
559 * @return None
560 */
561
562void
563lim_send_sme_start_bss_rsp(tpAniSirGlobal pMac,
564 uint16_t msgType, tSirResultCodes resultCode,
565 tpPESession psessionEntry, uint8_t smesessionId,
566 uint16_t smetransactionId)
567{
568
569 uint16_t size = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700570 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800571 tSirSmeStartBssRsp *pSirSmeRsp;
572 uint16_t ieLen;
573 uint16_t ieOffset, curLen;
574
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530575 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800576 lim_msg_str(msgType), lim_result_code_str(resultCode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800577
578 size = sizeof(tSirSmeStartBssRsp);
579
580 if (psessionEntry == NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530581 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800582 if (NULL == pSirSmeRsp) {
583 /* / Buffer not available. Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530584 pe_err("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800585 return;
586 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800587 } else {
588 /* subtract size of beaconLength + Mac Hdr + Fixed Fields before SSID */
589 ieOffset = sizeof(tAniBeaconStruct) + SIR_MAC_B_PR_SSID_OFFSET;
590 ieLen = psessionEntry->schBeaconOffsetBegin
591 + psessionEntry->schBeaconOffsetEnd - ieOffset;
592 /* calculate the memory size to allocate */
593 size += ieLen;
594
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530595 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800596 if (NULL == pSirSmeRsp) {
597 /* / Buffer not available. Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530598 pe_err("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800599 return;
600 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800601 size = sizeof(tSirSmeStartBssRsp);
602 if (resultCode == eSIR_SME_SUCCESS) {
603
604 sir_copy_mac_addr(pSirSmeRsp->bssDescription.bssId,
605 psessionEntry->bssId);
606
607 /* Read beacon interval from session */
608 pSirSmeRsp->bssDescription.beaconInterval =
609 (uint16_t) psessionEntry->beaconParams.
610 beaconInterval;
611 pSirSmeRsp->bssType = psessionEntry->bssType;
612
613 if (cfg_get_capability_info
614 (pMac, &pSirSmeRsp->bssDescription.capabilityInfo,
615 psessionEntry)
616 != eSIR_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530617 pe_err("could not retrieve Capabilities value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800618
619 lim_get_phy_mode(pMac,
620 (uint32_t *) &pSirSmeRsp->bssDescription.
621 nwType, psessionEntry);
622
623 pSirSmeRsp->bssDescription.channelId =
624 psessionEntry->currentOperChannel;
625
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700626 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800627 curLen = psessionEntry->schBeaconOffsetBegin - ieOffset;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530628 qdf_mem_copy((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800629 ieFields,
630 psessionEntry->pSchBeaconFrameBegin +
631 ieOffset, (uint32_t) curLen);
632
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530633 qdf_mem_copy(((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800634 ieFields) + curLen,
635 psessionEntry->pSchBeaconFrameEnd,
636 (uint32_t) psessionEntry->
637 schBeaconOffsetEnd);
638
Abhishek Singh34a4d862016-10-26 16:01:51 +0530639 pSirSmeRsp->bssDescription.length = (uint16_t)
640 (offsetof(tSirBssDescription, ieFields[0])
641 - sizeof(pSirSmeRsp->bssDescription.length)
642 + ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800643 /* This is the size of the message, subtracting the size of the pointer to ieFields */
644 size += ieLen - sizeof(uint32_t);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700645 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800646#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
647 if (psessionEntry->cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530648 != QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800649 pSirSmeRsp->HTProfile.
650 htSupportedChannelWidthSet =
651 psessionEntry->htSupportedChannelWidthSet;
652 pSirSmeRsp->HTProfile.htRecommendedTxWidthSet =
653 psessionEntry->htRecommendedTxWidthSet;
654 pSirSmeRsp->HTProfile.htSecondaryChannelOffset =
655 psessionEntry->htSecondaryChannelOffset;
656 pSirSmeRsp->HTProfile.dot11mode =
657 psessionEntry->dot11mode;
658 pSirSmeRsp->HTProfile.htCapability =
659 psessionEntry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800660 pSirSmeRsp->HTProfile.vhtCapability =
661 psessionEntry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800662 pSirSmeRsp->HTProfile.apCenterChan =
663 psessionEntry->ch_center_freq_seg0;
664 pSirSmeRsp->HTProfile.apChanWidth =
665 psessionEntry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800666 }
667#endif
668 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800669 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800670 pSirSmeRsp->messageType = msgType;
671 pSirSmeRsp->length = size;
672
673 /* Update SME session Id and transaction Id */
674 pSirSmeRsp->sessionId = smesessionId;
675 pSirSmeRsp->transactionId = smetransactionId;
676 pSirSmeRsp->statusCode = resultCode;
677 if (psessionEntry != NULL)
678 pSirSmeRsp->staId = psessionEntry->staId; /* else it will be always zero smeRsp StaID = 0 */
679
680 mmhMsg.type = msgType;
681 mmhMsg.bodyptr = pSirSmeRsp;
682 mmhMsg.bodyval = 0;
683 if (psessionEntry == NULL) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530684 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
685 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800686 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530687 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
688 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800689 }
690#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
691 lim_diag_event_report(pMac, WLAN_PE_DIAG_START_BSS_RSP_EVENT,
692 psessionEntry, (uint16_t) resultCode, 0);
693#endif /* FEATURE_WLAN_DIAG_SUPPORT */
694
695 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
696} /*** end lim_send_sme_start_bss_rsp() ***/
697
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800698/**
699 * lim_send_sme_scan_rsp() - Send scan response to SME
700 * @pMac: Pointer to Global MAC structure
701 * @length: Indicates length of message
702 * @resultCode: Indicates the result of previously issued
703 * eWNI_SME_SCAN_REQ message
704 * @scan_id: scan identifier
705 *
706 * This function is called by lim_process_sme_req_messages() to send
707 * eWNI_SME_SCAN_RSP message to applications above MAC
708 *
709 * return: None
710 */
711
712void
713lim_send_sme_scan_rsp(tpAniSirGlobal pMac, tSirResultCodes resultCode,
714 uint8_t smesessionId, uint16_t smetranscationId,
715 uint32_t scan_id)
716{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800717 lim_post_sme_scan_rsp_message(pMac, resultCode, smesessionId,
718 smetranscationId, scan_id);
719}
720
721/**
722 * lim_post_sme_scan_rsp_message()
723 *
724 ***FUNCTION:
725 * This function is called by lim_send_sme_scan_rsp() to send
726 * eWNI_SME_SCAN_RSP message with failed result code
727 *
728 ***NOTE:
729 * NA
730 *
731 * @param pMac Pointer to Global MAC structure
732 * @param length Indicates length of message
733 * @param resultCode failed result code
734 *
735 * @return None
736 */
737
738void
739lim_post_sme_scan_rsp_message(tpAniSirGlobal pMac,
740 tSirResultCodes resultCode, uint8_t smesessionId,
741 uint16_t smetransactionId,
742 uint32_t scan_id)
743{
744 tpSirSmeScanRsp pSirSmeScanRsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700745 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800746
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530747 pe_debug("send SME_SCAN_RSP reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800748 lim_result_code_str(resultCode));
749
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530750 pSirSmeScanRsp = qdf_mem_malloc(sizeof(tSirSmeScanRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800751 if (NULL == pSirSmeScanRsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530752 pe_err("AllocateMemory failed for eWNI_SME_SCAN_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800753 return;
754 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800755
756 pSirSmeScanRsp->messageType = eWNI_SME_SCAN_RSP;
757 pSirSmeScanRsp->statusCode = resultCode;
758
759 /*Update SME session Id and transaction Id */
760 pSirSmeScanRsp->sessionId = smesessionId;
761 pSirSmeScanRsp->transcationId = smetransactionId;
762 pSirSmeScanRsp->scan_id = scan_id;
763
764 mmhMsg.type = eWNI_SME_SCAN_RSP;
765 mmhMsg.bodyptr = pSirSmeScanRsp;
766 mmhMsg.bodyval = 0;
767
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530768 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800769#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
770 lim_diag_event_report(pMac, WLAN_PE_DIAG_SCAN_RSP_EVENT, NULL,
771 (uint16_t) resultCode, 0);
772#endif /* FEATURE_WLAN_DIAG_SUPPORT */
773
774 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
775 return;
776
777} /*** lim_post_sme_scan_rsp_message ***/
778
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800779void lim_send_sme_disassoc_deauth_ntf(tpAniSirGlobal pMac,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530780 QDF_STATUS status, uint32_t *pCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800781{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700782 struct scheduler_msg mmhMsg = {0};
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800783 struct scheduler_msg *pMsg = (struct scheduler_msg *) pCtx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800784
785 mmhMsg.type = pMsg->type;
786 mmhMsg.bodyptr = pMsg;
787 mmhMsg.bodyval = 0;
788
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530789 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800790
791 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
792}
793
794/**
795 * lim_send_sme_disassoc_ntf()
796 *
797 ***FUNCTION:
798 * This function is called by limProcessSmeMessages() to send
799 * eWNI_SME_DISASSOC_RSP/IND message to host
800 *
801 ***PARAMS:
802 *
803 ***LOGIC:
804 *
805 ***ASSUMPTIONS:
806 * NA
807 *
808 ***NOTE:
809 * This function is used for sending eWNI_SME_DISASSOC_CNF,
810 * or eWNI_SME_DISASSOC_IND to host depending on
811 * disassociation trigger.
812 *
813 * @param peerMacAddr Indicates the peer MAC addr to which
814 * disassociate was initiated
815 * @param reasonCode Indicates the reason for Disassociation
816 * @param disassocTrigger Indicates the trigger for Disassociation
817 * @param aid Indicates the STAID. This parameter is
818 * present only on AP.
819 *
820 * @return None
821 */
822void
823lim_send_sme_disassoc_ntf(tpAniSirGlobal pMac,
824 tSirMacAddr peerMacAddr,
825 tSirResultCodes reasonCode,
826 uint16_t disassocTrigger,
827 uint16_t aid,
828 uint8_t smesessionId,
829 uint16_t smetransactionId, tpPESession psessionEntry)
830{
831
832 uint8_t *pBuf;
833 tSirSmeDisassocRsp *pSirSmeDisassocRsp;
834 tSirSmeDisassocInd *pSirSmeDisassocInd;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700835 uint32_t *pMsg = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800836 bool failure = false;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700837 tpPESession session = NULL;
838 uint16_t i, assoc_id;
839 tpDphHashNode sta_ds = NULL;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530840 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800841
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530842 pe_debug("Disassoc Ntf with trigger : %d reasonCode: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800843 disassocTrigger, reasonCode);
844
845 switch (disassocTrigger) {
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700846 case eLIM_DUPLICATE_ENTRY:
847 /*
848 * Duplicate entry is removed at LIM.
849 * Initiate new entry for other session
850 */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530851 pe_debug("Rcvd eLIM_DUPLICATE_ENTRY for " MAC_ADDRESS_STR,
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700852 MAC_ADDR_ARRAY(peerMacAddr));
853
854 for (i = 0; i < pMac->lim.maxBssId; i++) {
855 if ((&pMac->lim.gpSession[i] != NULL) &&
856 (pMac->lim.gpSession[i].valid) &&
857 (pMac->lim.gpSession[i].pePersona ==
858 QDF_SAP_MODE)) {
859 /* Find the sta ds entry in another session */
860 session = &pMac->lim.gpSession[i];
861 sta_ds = dph_lookup_hash_entry(pMac,
862 peerMacAddr, &assoc_id,
863 &session->dph.dphHashTable);
864 }
865 }
866 if (sta_ds
867#ifdef WLAN_FEATURE_11W
868 && (!sta_ds->rmfEnabled)
869#endif
870 ) {
871 if (lim_add_sta(pMac, sta_ds, false, session) !=
872 eSIR_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530873 pe_err("could not Add STA with assocId: %d",
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700874 sta_ds->assocId);
875 }
876 failure = true;
877 break;
878
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800879 case eLIM_HOST_DISASSOC:
880 /**
881 * Disassociation response due to
882 * host triggered disassociation
883 */
884
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530885 pSirSmeDisassocRsp = qdf_mem_malloc(sizeof(tSirSmeDisassocRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800886 if (NULL == pSirSmeDisassocRsp) {
887 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530888 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800889 failure = true;
890 goto error;
891 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530892 pe_debug("send eWNI_SME_DISASSOC_RSP with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800893 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
894 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
895 pSirSmeDisassocRsp->length = sizeof(tSirSmeDisassocRsp);
896 /* sessionId */
897 pBuf = (uint8_t *) &pSirSmeDisassocRsp->sessionId;
898 *pBuf = smesessionId;
899 pBuf++;
900
901 /* transactionId */
902 lim_copy_u16(pBuf, smetransactionId);
903 pBuf += sizeof(uint16_t);
904
905 /* statusCode */
906 lim_copy_u32(pBuf, reasonCode);
907 pBuf += sizeof(tSirResultCodes);
908
909 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530910 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800911 pBuf += sizeof(tSirMacAddr);
912
913 /* Clear Station Stats */
914 /* for sta, it is always 1, IBSS is handled at halInitSta */
915
916#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
917
918 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
919 psessionEntry, (uint16_t) reasonCode, 0);
920#endif
921 pMsg = (uint32_t *) pSirSmeDisassocRsp;
922 break;
923
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530924 case eLIM_PEER_ENTITY_DISASSOC:
925 case eLIM_LINK_MONITORING_DISASSOC:
926 sir_sme_dis_ind =
927 qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
928 if (!sir_sme_dis_ind) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530929 pe_err("call to AllocateMemory failed for disconnect indication");
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530930 return;
931 }
932
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530933 pe_debug("send eWNI_SME_DISCONNECT_DONE_IND with retCode: %d",
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530934 reasonCode);
935
936 sir_sme_dis_ind->message_type =
937 eWNI_SME_DISCONNECT_DONE_IND;
938 sir_sme_dis_ind->length =
939 sizeof(*sir_sme_dis_ind);
940 qdf_mem_copy(sir_sme_dis_ind->peer_mac, peerMacAddr,
941 sizeof(tSirMacAddr));
942 sir_sme_dis_ind->session_id = smesessionId;
943 sir_sme_dis_ind->reason_code = reasonCode;
Selvaraj, Sridharc7d80892016-09-29 11:56:45 +0530944 /*
945 * Instead of sending deauth reason code as 505 which is
946 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
947 * Send reason code as zero to Supplicant
948 */
949 if (reasonCode == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
950 sir_sme_dis_ind->reason_code = 0;
951 else
952 sir_sme_dis_ind->reason_code = reasonCode;
953
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530954 pMsg = (uint32_t *)sir_sme_dis_ind;
955
956 break;
957
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800958 default:
959 /**
960 * Disassociation indication due to Disassociation
961 * frame reception from peer entity or due to
962 * loss of link with peer entity.
963 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530964 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800965 if (NULL == pSirSmeDisassocInd) {
966 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530967 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800968 failure = true;
969 goto error;
970 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530971 pe_debug("send eWNI_SME_DISASSOC_IND with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800972 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
973 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
974 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
975
976 /* Update SME session Id and Transaction Id */
977 pSirSmeDisassocInd->sessionId = smesessionId;
978 pSirSmeDisassocInd->transactionId = smetransactionId;
979 pSirSmeDisassocInd->reasonCode = reasonCode;
980 pBuf = (uint8_t *) &pSirSmeDisassocInd->statusCode;
981
982 lim_copy_u32(pBuf, reasonCode);
983 pBuf += sizeof(tSirResultCodes);
984
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530985 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800986 pBuf += sizeof(tSirMacAddr);
987
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530988 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800989
990#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
991 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
992 psessionEntry, (uint16_t) reasonCode, 0);
993#endif
994 pMsg = (uint32_t *) pSirSmeDisassocInd;
995
996 break;
997 }
998
999error:
1000 /* Delete the PE session Created */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07001001 if ((psessionEntry != NULL) && LIM_IS_STA_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001002 pe_delete_session(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001003
1004 if (false == failure)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301005 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001006 (uint32_t *) pMsg);
1007} /*** end lim_send_sme_disassoc_ntf() ***/
1008
1009/** -----------------------------------------------------------------
1010 \brief lim_send_sme_disassoc_ind() - sends SME_DISASSOC_IND
1011
1012 After receiving disassociation frame from peer entity, this
1013 function sends a eWNI_SME_DISASSOC_IND to SME with a specific
1014 reason code.
1015
1016 \param pMac - global mac structure
1017 \param pStaDs - station dph hash node
1018 \return none
1019 \sa
1020 ----------------------------------------------------------------- */
1021void
1022lim_send_sme_disassoc_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1023 tpPESession psessionEntry)
1024{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001025 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001026 tSirSmeDisassocInd *pSirSmeDisassocInd;
1027
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301028 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001029 if (NULL == pSirSmeDisassocInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301030 pe_err("AllocateMemory failed for eWNI_SME_DISASSOC_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001031 return;
1032 }
1033
1034 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
1035 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
1036
1037 pSirSmeDisassocInd->sessionId = psessionEntry->smeSessionId;
1038 pSirSmeDisassocInd->transactionId = psessionEntry->transactionId;
Padma, Santhosh Kumar02289212016-09-30 13:30:08 +05301039 pSirSmeDisassocInd->statusCode = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040 pSirSmeDisassocInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1041
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301042 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301043 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001044
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301045 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301046 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001047
1048 pSirSmeDisassocInd->staId = pStaDs->staIndex;
1049
1050 mmhMsg.type = eWNI_SME_DISASSOC_IND;
1051 mmhMsg.bodyptr = pSirSmeDisassocInd;
1052 mmhMsg.bodyval = 0;
1053
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301054 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1055 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001056#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1057 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT, psessionEntry,
1058 0, (uint16_t) pStaDs->mlmStaContext.disassocReason);
1059#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1060
1061 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1062
1063} /*** end lim_send_sme_disassoc_ind() ***/
1064
1065/** -----------------------------------------------------------------
1066 \brief lim_send_sme_deauth_ind() - sends SME_DEAUTH_IND
1067
1068 After receiving deauthentication frame from peer entity, this
1069 function sends a eWNI_SME_DEAUTH_IND to SME with a specific
1070 reason code.
1071
1072 \param pMac - global mac structure
1073 \param pStaDs - station dph hash node
1074 \return none
1075 \sa
1076 ----------------------------------------------------------------- */
1077void
1078lim_send_sme_deauth_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1079 tpPESession psessionEntry)
1080{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001081 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001082 tSirSmeDeauthInd *pSirSmeDeauthInd;
1083
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301084 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001085 if (NULL == pSirSmeDeauthInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301086 pe_err("AllocateMemory failed for eWNI_SME_DEAUTH_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001087 return;
1088 }
1089
1090 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1091 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1092
1093 pSirSmeDeauthInd->sessionId = psessionEntry->smeSessionId;
1094 pSirSmeDeauthInd->transactionId = psessionEntry->transactionId;
1095 if (eSIR_INFRA_AP_MODE == psessionEntry->bssType) {
1096 pSirSmeDeauthInd->statusCode =
1097 (tSirResultCodes) pStaDs->mlmStaContext.cleanupTrigger;
1098 } else {
1099 /* Need to indicatet he reascon code over the air */
1100 pSirSmeDeauthInd->statusCode =
1101 (tSirResultCodes) pStaDs->mlmStaContext.disassocReason;
1102 }
1103 /* BSSID */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301104 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301105 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001106 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301107 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301108 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001109 pSirSmeDeauthInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1110
1111 pSirSmeDeauthInd->staId = pStaDs->staIndex;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001112 if (eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON ==
1113 pStaDs->mlmStaContext.disassocReason)
1114 pSirSmeDeauthInd->rssi = pStaDs->del_sta_ctx_rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001115
1116 mmhMsg.type = eWNI_SME_DEAUTH_IND;
1117 mmhMsg.bodyptr = pSirSmeDeauthInd;
1118 mmhMsg.bodyval = 0;
1119
1120 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1121#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1122 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT, psessionEntry,
1123 0, pStaDs->mlmStaContext.cleanupTrigger);
1124#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1125
1126 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1127 return;
1128} /*** end lim_send_sme_deauth_ind() ***/
1129
1130#ifdef FEATURE_WLAN_TDLS
1131/**
1132 * lim_send_sme_tdls_del_sta_ind()
1133 *
1134 ***FUNCTION:
1135 * This function is called to send the TDLS STA context deletion to SME.
1136 *
1137 ***LOGIC:
1138 *
1139 ***ASSUMPTIONS:
1140 *
1141 ***NOTE:
1142 * NA
1143 *
1144 * @param pMac - Pointer to global MAC structure
1145 * @param pStaDs - Pointer to internal STA Datastructure
1146 * @param psessionEntry - Pointer to the session entry
1147 * @param reasonCode - Reason for TDLS sta deletion
1148 * @return None
1149 */
1150void
1151lim_send_sme_tdls_del_sta_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1152 tpPESession psessionEntry, uint16_t reasonCode)
1153{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001154 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001155 tSirTdlsDelStaInd *pSirTdlsDelStaInd;
1156
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301157 pSirTdlsDelStaInd = qdf_mem_malloc(sizeof(tSirTdlsDelStaInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001158 if (NULL == pSirTdlsDelStaInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301159 pe_err("AllocateMemory failed for eWNI_SME_TDLS_DEL_STA_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001160 return;
1161 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301162 pe_debug("Delete TDLS Peer "MAC_ADDRESS_STR "with reason code: %d",
Nitesh Shah82c52812016-12-27 12:27:51 +05301163 MAC_ADDR_ARRAY(pStaDs->staAddr), reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001164 /* messageType */
1165 pSirTdlsDelStaInd->messageType = eWNI_SME_TDLS_DEL_STA_IND;
1166 pSirTdlsDelStaInd->length = sizeof(tSirTdlsDelStaInd);
1167
1168 /* sessionId */
1169 pSirTdlsDelStaInd->sessionId = psessionEntry->smeSessionId;
1170
1171 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301172 qdf_mem_copy(pSirTdlsDelStaInd->peermac.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301173 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001174
1175 /* staId */
1176 lim_copy_u16((uint8_t *) (&pSirTdlsDelStaInd->staId),
1177 (uint16_t) pStaDs->staIndex);
1178
1179 /* reasonCode */
1180 lim_copy_u16((uint8_t *) (&pSirTdlsDelStaInd->reasonCode), reasonCode);
1181
1182 mmhMsg.type = eWNI_SME_TDLS_DEL_STA_IND;
1183 mmhMsg.bodyptr = pSirTdlsDelStaInd;
1184 mmhMsg.bodyval = 0;
1185
1186 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1187 return;
1188} /*** end lim_send_sme_tdls_del_sta_ind() ***/
1189
1190/**
1191 * lim_send_sme_tdls_delete_all_peer_ind()
1192 *
1193 ***FUNCTION:
1194 * This function is called to send the eWNI_SME_TDLS_DEL_ALL_PEER_IND
1195 * message to SME.
1196 *
1197 ***LOGIC:
1198 *
1199 ***ASSUMPTIONS:
1200 *
1201 ***NOTE:
1202 * NA
1203 *
1204 * @param pMac - Pointer to global MAC structure
1205 * @param psessionEntry - Pointer to the session entry
1206 * @return None
1207 */
1208void
1209lim_send_sme_tdls_delete_all_peer_ind(tpAniSirGlobal pMac, tpPESession psessionEntry)
1210{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001211 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001212 tSirTdlsDelAllPeerInd *pSirTdlsDelAllPeerInd;
1213
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301214 pSirTdlsDelAllPeerInd = qdf_mem_malloc(sizeof(tSirTdlsDelAllPeerInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001215 if (NULL == pSirTdlsDelAllPeerInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301216 pe_err("AllocateMemory failed for eWNI_SME_TDLS_DEL_ALL_PEER_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001217 return;
1218 }
1219 /* messageType */
1220 pSirTdlsDelAllPeerInd->messageType = eWNI_SME_TDLS_DEL_ALL_PEER_IND;
1221 pSirTdlsDelAllPeerInd->length = sizeof(tSirTdlsDelAllPeerInd);
1222
1223 /* sessionId */
1224 pSirTdlsDelAllPeerInd->sessionId = psessionEntry->smeSessionId;
1225
1226 mmhMsg.type = eWNI_SME_TDLS_DEL_ALL_PEER_IND;
1227 mmhMsg.bodyptr = pSirTdlsDelAllPeerInd;
1228 mmhMsg.bodyval = 0;
1229
1230 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1231 return;
1232} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1233
1234/**
1235 * lim_send_sme_mgmt_tx_completion()
1236 *
1237 ***FUNCTION:
1238 * This function is called to send the eWNI_SME_MGMT_FRM_TX_COMPLETION_IND
1239 * message to SME.
1240 *
1241 ***LOGIC:
1242 *
1243 ***ASSUMPTIONS:
1244 *
1245 ***NOTE:
1246 * NA
1247 *
1248 * @param pMac - Pointer to global MAC structure
1249 * @param psessionEntry - Pointer to the session entry
1250 * @param txCompleteStatus - TX Complete Status of Mgmt Frames
1251 * @return None
1252 */
1253void
1254lim_send_sme_mgmt_tx_completion(tpAniSirGlobal pMac,
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301255 uint32_t sme_session_id,
1256 uint32_t txCompleteStatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001257{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001258 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001259 tSirMgmtTxCompletionInd *pSirMgmtTxCompletionInd;
1260
1261 pSirMgmtTxCompletionInd =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301262 qdf_mem_malloc(sizeof(tSirMgmtTxCompletionInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001263 if (NULL == pSirMgmtTxCompletionInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301264 pe_err("AllocateMemory failed for eWNI_SME_MGMT_FRM_TX_COMPLETION_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001265 return;
1266 }
1267 /* messageType */
1268 pSirMgmtTxCompletionInd->messageType =
1269 eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1270 pSirMgmtTxCompletionInd->length = sizeof(tSirMgmtTxCompletionInd);
1271
1272 /* sessionId */
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301273 pSirMgmtTxCompletionInd->sessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001274
1275 pSirMgmtTxCompletionInd->txCompleteStatus = txCompleteStatus;
1276
1277 mmhMsg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1278 mmhMsg.bodyptr = pSirMgmtTxCompletionInd;
1279 mmhMsg.bodyval = 0;
1280
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07001281#ifdef CONVERGED_TDLS_ENABLE
1282 pSirMgmtTxCompletionInd->psoc = pMac->psoc;
1283 mmhMsg.callback = tgt_tdls_send_mgmt_tx_completion;
1284 scheduler_post_msg(QDF_MODULE_ID_TARGET_IF, &mmhMsg);
1285 return;
1286#else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001287 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1288 return;
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07001289#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001290} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1291
1292void lim_send_sme_tdls_event_notify(tpAniSirGlobal pMac, uint16_t msgType,
1293 void *events)
1294{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001295 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001296
1297 switch (msgType) {
1298 case SIR_HAL_TDLS_SHOULD_DISCOVER:
1299 mmhMsg.type = eWNI_SME_TDLS_SHOULD_DISCOVER;
1300 break;
1301 case SIR_HAL_TDLS_SHOULD_TEARDOWN:
1302 mmhMsg.type = eWNI_SME_TDLS_SHOULD_TEARDOWN;
1303 break;
1304 case SIR_HAL_TDLS_PEER_DISCONNECTED:
1305 mmhMsg.type = eWNI_SME_TDLS_PEER_DISCONNECTED;
1306 break;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07001307 case SIR_HAL_TDLS_CONNECTION_TRACKER_NOTIFICATION:
1308 mmhMsg.type = eWNI_SME_TDLS_CONNECTION_TRACKER_NOTIFICATION;
1309 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001310 }
1311
1312 mmhMsg.bodyptr = events;
1313 mmhMsg.bodyval = 0;
1314 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1315 return;
1316}
1317#endif /* FEATURE_WLAN_TDLS */
1318
1319/**
1320 * lim_send_sme_deauth_ntf()
1321 *
1322 ***FUNCTION:
1323 * This function is called by limProcessSmeMessages() to send
1324 * eWNI_SME_DISASSOC_RSP/IND message to host
1325 *
1326 ***PARAMS:
1327 *
1328 ***LOGIC:
1329 *
1330 ***ASSUMPTIONS:
1331 * NA
1332 *
1333 ***NOTE:
1334 * This function is used for sending eWNI_SME_DEAUTH_CNF or
1335 * eWNI_SME_DEAUTH_IND to host depending on deauthentication trigger.
1336 *
1337 * @param peerMacAddr Indicates the peer MAC addr to which
1338 * deauthentication was initiated
1339 * @param reasonCode Indicates the reason for Deauthetication
1340 * @param deauthTrigger Indicates the trigger for Deauthetication
1341 * @param aid Indicates the STAID. This parameter is present
1342 * only on AP.
1343 *
1344 * @return None
1345 */
1346void
1347lim_send_sme_deauth_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
1348 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1349 uint16_t aid, uint8_t smesessionId,
1350 uint16_t smetransactionId)
1351{
1352 uint8_t *pBuf;
1353 tSirSmeDeauthRsp *pSirSmeDeauthRsp;
1354 tSirSmeDeauthInd *pSirSmeDeauthInd;
1355 tpPESession psessionEntry;
1356 uint8_t sessionId;
1357 uint32_t *pMsg;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301358 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001359
1360 psessionEntry = pe_find_session_by_bssid(pMac, peerMacAddr, &sessionId);
1361 switch (deauthTrigger) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001362 case eLIM_HOST_DEAUTH:
1363 /**
1364 * Deauthentication response to host triggered
1365 * deauthentication.
1366 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301367 pSirSmeDeauthRsp = qdf_mem_malloc(sizeof(tSirSmeDeauthRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001368 if (NULL == pSirSmeDeauthRsp) {
1369 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301370 pe_err("call to AllocateMemory failed for eWNI_SME_DEAUTH_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001371 return;
1372 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301373 pe_debug("send eWNI_SME_DEAUTH_RSP with retCode: %d for" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001374 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1375 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
1376 pSirSmeDeauthRsp->length = sizeof(tSirSmeDeauthRsp);
1377 pSirSmeDeauthRsp->statusCode = reasonCode;
1378 pSirSmeDeauthRsp->sessionId = smesessionId;
1379 pSirSmeDeauthRsp->transactionId = smetransactionId;
1380
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -08001381 pBuf = (uint8_t *) pSirSmeDeauthRsp->peer_macaddr.bytes;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301382 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001383
1384#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1385 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
1386 psessionEntry, 0, (uint16_t) reasonCode);
1387#endif
1388 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1389
1390 break;
1391
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301392 case eLIM_PEER_ENTITY_DEAUTH:
1393 case eLIM_LINK_MONITORING_DEAUTH:
1394 sir_sme_dis_ind =
1395 qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
1396 if (!sir_sme_dis_ind) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301397 pe_err("call to AllocateMemory failed for disconnect indication");
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301398 return;
1399 }
1400
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301401 pe_debug("send eWNI_SME_DISCONNECT_DONE_IND withretCode: %d",
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301402 reasonCode);
1403
1404 sir_sme_dis_ind->message_type =
1405 eWNI_SME_DISCONNECT_DONE_IND;
1406 sir_sme_dis_ind->length =
1407 sizeof(*sir_sme_dis_ind);
1408 sir_sme_dis_ind->session_id = smesessionId;
1409 sir_sme_dis_ind->reason_code = reasonCode;
1410 qdf_mem_copy(sir_sme_dis_ind->peer_mac, peerMacAddr,
1411 ETH_ALEN);
Selvaraj, Sridharc7d80892016-09-29 11:56:45 +05301412 /*
1413 * Instead of sending deauth reason code as 505 which is
1414 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1415 * Send reason code as zero to Supplicant
1416 */
1417 if (reasonCode == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1418 sir_sme_dis_ind->reason_code = 0;
1419 else
1420 sir_sme_dis_ind->reason_code = reasonCode;
1421
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301422 pMsg = (uint32_t *)sir_sme_dis_ind;
1423
1424 break;
1425
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001426 default:
1427 /**
1428 * Deauthentication indication due to Deauthentication
1429 * frame reception from peer entity or due to
1430 * loss of link with peer entity.
1431 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301432 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001433 if (NULL == pSirSmeDeauthInd) {
1434 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301435 pe_err("call to AllocateMemory failed for eWNI_SME_DEAUTH_Ind");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001436 return;
1437 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301438 pe_debug("send eWNI_SME_DEAUTH_IND with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001439 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1440 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1441 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1442 pSirSmeDeauthInd->reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
1443
1444 /* sessionId */
1445 pBuf = (uint8_t *) &pSirSmeDeauthInd->sessionId;
1446 *pBuf++ = smesessionId;
1447
1448 /* transaction ID */
1449 lim_copy_u16(pBuf, smetransactionId);
1450 pBuf += sizeof(uint16_t);
1451
1452 /* status code */
1453 lim_copy_u32(pBuf, reasonCode);
1454 pBuf += sizeof(tSirResultCodes);
1455
1456 /* bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301457 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001458 pBuf += sizeof(tSirMacAddr);
1459
1460 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301461 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301462 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001463
1464#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1465 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
1466 psessionEntry, 0, (uint16_t) reasonCode);
1467#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1468 pMsg = (uint32_t *) pSirSmeDeauthInd;
1469
1470 break;
1471 }
1472
1473 /*Delete the PE session created */
1474 if (psessionEntry != NULL) {
1475 pe_delete_session(pMac, psessionEntry);
1476 }
1477
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301478 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001479 (uint32_t *) pMsg);
1480
1481} /*** end lim_send_sme_deauth_ntf() ***/
1482
1483/**
1484 * lim_send_sme_wm_status_change_ntf() - Send Notification
1485 * @mac_ctx: Global MAC Context
1486 * @status_change_code: Indicates the change in the wireless medium.
1487 * @status_change_info: Indicates the information associated with
1488 * change in the wireless medium.
1489 * @info_len: Indicates the length of status change information
1490 * being sent.
1491 * @session_id SessionID
1492 *
1493 * This function is called by limProcessSmeMessages() to send
1494 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1495 *
1496 * Return: None
1497 */
1498void
1499lim_send_sme_wm_status_change_ntf(tpAniSirGlobal mac_ctx,
1500 tSirSmeStatusChangeCode status_change_code,
1501 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1502{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001503 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001504 tSirSmeWmStatusChangeNtf *wm_status_change_ntf;
Naveen Rawate01ed172016-11-17 11:34:50 -08001505 uint32_t max_info_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001506
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301507 wm_status_change_ntf = qdf_mem_malloc(sizeof(tSirSmeWmStatusChangeNtf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001508 if (NULL == wm_status_change_ntf) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301509 pe_err("Mem Alloc failed - eWNI_SME_WM_STATUS_CHANGE_NTF");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001510 return;
1511 }
1512
1513 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1514 msg.bodyval = 0;
1515 msg.bodyptr = wm_status_change_ntf;
1516
1517 switch (status_change_code) {
Naveen Rawate01ed172016-11-17 11:34:50 -08001518 case eSIR_SME_AP_CAPS_CHANGED:
1519 max_info_len = sizeof(tSirSmeApNewCaps);
1520 break;
1521 case eSIR_SME_JOINED_NEW_BSS:
1522 max_info_len = sizeof(tSirSmeNewBssInfo);
1523 break;
1524 default:
1525 max_info_len = sizeof(wm_status_change_ntf->statusChangeInfo);
1526 break;
1527 }
1528
1529 switch (status_change_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001530 case eSIR_SME_RADAR_DETECTED:
1531 break;
1532 default:
1533 wm_status_change_ntf->messageType =
1534 eWNI_SME_WM_STATUS_CHANGE_NTF;
1535 wm_status_change_ntf->statusChangeCode = status_change_code;
1536 wm_status_change_ntf->length = sizeof(tSirSmeWmStatusChangeNtf);
1537 wm_status_change_ntf->sessionId = session_id;
Naveen Rawate01ed172016-11-17 11:34:50 -08001538 if (info_len <= max_info_len && status_change_info) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301539 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001540 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1541 (uint8_t *) status_change_info, info_len);
1542 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301543 pe_debug("StatusChg code: 0x%x length: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001544 status_change_code, info_len);
1545 break;
1546 }
1547
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301548 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001549 if (eSIR_SUCCESS != lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301550 qdf_mem_free(wm_status_change_ntf);
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301551 pe_err("lim_sys_process_mmh_msg_api failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001552 }
1553
1554} /*** end lim_send_sme_wm_status_change_ntf() ***/
1555
1556/**
1557 * lim_send_sme_set_context_rsp()
1558 *
1559 ***FUNCTION:
1560 * This function is called by limProcessSmeMessages() to send
1561 * eWNI_SME_SETCONTEXT_RSP message to host
1562 *
1563 ***PARAMS:
1564 *
1565 ***LOGIC:
1566 *
1567 ***ASSUMPTIONS:
1568 * NA
1569 *
1570 ***NOTE:
1571 *
1572 * @param pMac Pointer to Global MAC structure
1573 * @param peerMacAddr Indicates the peer MAC addr to which
1574 * setContext was performed
1575 * @param aid Indicates the aid corresponding to the peer MAC
1576 * address
1577 * @param resultCode Indicates the result of previously issued
1578 * eWNI_SME_SETCONTEXT_RSP message
1579 *
1580 * @return None
1581 */
1582void
1583lim_send_sme_set_context_rsp(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301584 struct qdf_mac_addr peer_macaddr, uint16_t aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001585 tSirResultCodes resultCode,
1586 tpPESession psessionEntry, uint8_t smesessionId,
1587 uint16_t smetransactionId)
1588{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001589 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001590 tSirSmeSetContextRsp *pSirSmeSetContextRsp;
1591
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301592 pSirSmeSetContextRsp = qdf_mem_malloc(sizeof(tSirSmeSetContextRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001593 if (NULL == pSirSmeSetContextRsp) {
1594 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301595 pe_err("call to AllocateMemory failed for SmeSetContextRsp");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001596 return;
1597 }
1598
1599 pSirSmeSetContextRsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1600 pSirSmeSetContextRsp->length = sizeof(tSirSmeSetContextRsp);
1601 pSirSmeSetContextRsp->statusCode = resultCode;
1602
Anurag Chouhanc5548422016-02-24 18:33:27 +05301603 qdf_copy_macaddr(&pSirSmeSetContextRsp->peer_macaddr, &peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001604
1605 /* Update SME session and transaction Id */
1606 pSirSmeSetContextRsp->sessionId = smesessionId;
1607 pSirSmeSetContextRsp->transactionId = smetransactionId;
1608
1609 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
1610 mmhMsg.bodyptr = pSirSmeSetContextRsp;
1611 mmhMsg.bodyval = 0;
1612 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301613 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1614 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001615 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301616 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1617 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001618 }
1619
1620#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1621 lim_diag_event_report(pMac, WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
1622 psessionEntry, (uint16_t) resultCode, 0);
1623#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1624
1625 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1626} /*** end lim_send_sme_set_context_rsp() ***/
1627
1628/**
1629 * lim_send_sme_neighbor_bss_ind()
1630 *
1631 ***FUNCTION:
1632 * This function is called by lim_lookup_nadd_hash_entry() to send
1633 * eWNI_SME_NEIGHBOR_BSS_IND message to host
1634 *
1635 ***PARAMS:
1636 *
1637 ***LOGIC:
1638 *
1639 ***ASSUMPTIONS:
1640 * NA
1641 *
1642 ***NOTE:
1643 * This function is used for sending eWNI_SME_NEIGHBOR_BSS_IND to
1644 * host upon detecting new BSS during background scanning if CFG
1645 * option is enabled for sending such indication
1646 *
1647 * @param pMac - Pointer to Global MAC structure
1648 * @return None
1649 */
1650
1651void
1652lim_send_sme_neighbor_bss_ind(tpAniSirGlobal pMac, tLimScanResultNode *pBssDescr)
1653{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001654 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001655 uint32_t val;
1656 tSirSmeNeighborBssInd *pNewBssInd;
1657
1658 if ((pMac->lim.gLimSmeState != eLIM_SME_LINK_EST_WT_SCAN_STATE) ||
1659 ((pMac->lim.gLimSmeState == eLIM_SME_LINK_EST_WT_SCAN_STATE) &&
1660 pMac->lim.gLimRspReqd)) {
1661 /* LIM is not in background scan state OR */
1662 /* current scan is initiated by HDD. */
1663 /* No need to send new BSS indication to HDD */
1664 return;
1665 }
1666
1667 if (wlan_cfg_get_int(pMac, WNI_CFG_NEW_BSS_FOUND_IND, &val) !=
1668 eSIR_SUCCESS) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301669 pe_err("could not get NEIGHBOR_BSS_IND from CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001670 return;
1671 }
1672
1673 if (val == 0)
1674 return;
1675
1676 /**
1677 * Need to indicate new BSSs found during
1678 * background scanning to host.
1679 * Allocate buffer for sending indication.
1680 * Length of buffer is length of BSS description
1681 * and length of header itself
1682 */
1683 val = pBssDescr->bssDescription.length + sizeof(uint16_t) +
1684 sizeof(uint32_t) + sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301685 pNewBssInd = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001686 if (NULL == pNewBssInd) {
1687 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301688 pe_err("call to AllocateMemory failed for eWNI_SME_NEIGHBOR_BSS_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001689 return;
1690 }
1691
1692 pNewBssInd->messageType = eWNI_SME_NEIGHBOR_BSS_IND;
1693 pNewBssInd->length = (uint16_t) val;
1694 pNewBssInd->sessionId = 0;
1695
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301696 qdf_mem_copy((uint8_t *) pNewBssInd->bssDescription,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001697 (uint8_t *) &pBssDescr->bssDescription,
1698 pBssDescr->bssDescription.length + sizeof(uint16_t));
1699
1700 msgQ.type = eWNI_SME_NEIGHBOR_BSS_IND;
1701 msgQ.bodyptr = pNewBssInd;
1702 msgQ.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301703 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, msgQ.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001704 lim_sys_process_mmh_msg_api(pMac, &msgQ, ePROT);
1705} /*** end lim_send_sme_neighbor_bss_ind() ***/
1706
1707/** -----------------------------------------------------------------
1708 \brief lim_send_sme_addts_rsp() - sends SME ADDTS RSP
1709 \ This function sends a eWNI_SME_ADDTS_RSP to SME.
1710 \ SME only looks at rc and tspec field.
1711 \param pMac - global mac structure
1712 \param rspReqd - is SmeAddTsRsp required
1713 \param status - status code of SME_ADD_TS_RSP
1714 \return tspec
1715 \sa
1716 ----------------------------------------------------------------- */
1717void
1718lim_send_sme_addts_rsp(tpAniSirGlobal pMac, uint8_t rspReqd, uint32_t status,
1719 tpPESession psessionEntry, tSirMacTspecIE tspec,
1720 uint8_t smesessionId, uint16_t smetransactionId)
1721{
1722 tpSirAddtsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001723 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001724
1725 if (!rspReqd)
1726 return;
1727
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301728 rsp = qdf_mem_malloc(sizeof(tSirAddtsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001729 if (NULL == rsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301730 pe_err("AllocateMemory failed for ADDTS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001731 return;
1732 }
1733
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001734 rsp->messageType = eWNI_SME_ADDTS_RSP;
1735 rsp->rc = status;
1736 rsp->rsp.status = (enum eSirMacStatusCodes)status;
1737 rsp->rsp.tspec = tspec;
1738 /* Update SME session Id and transcation Id */
1739 rsp->sessionId = smesessionId;
1740 rsp->transactionId = smetransactionId;
1741
1742 mmhMsg.type = eWNI_SME_ADDTS_RSP;
1743 mmhMsg.bodyptr = rsp;
1744 mmhMsg.bodyval = 0;
1745 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301746 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1747 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001748 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301749 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1750 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001751 }
1752#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1753 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_RSP_EVENT, psessionEntry, 0,
1754 0);
1755#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1756
1757 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1758 return;
1759}
1760
1761void
1762lim_send_sme_delts_rsp(tpAniSirGlobal pMac, tpSirDeltsReq delts, uint32_t status,
1763 tpPESession psessionEntry, uint8_t smesessionId,
1764 uint16_t smetransactionId)
1765{
1766 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001767 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001768
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301769 pe_debug("SendSmeDeltsRsp aid: %d tsid: %d up: %d status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001770 delts->aid,
1771 delts->req.tsinfo.traffic.tsid,
1772 delts->req.tsinfo.traffic.userPrio, status);
1773 if (!delts->rspReqd)
1774 return;
1775
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301776 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001777 if (NULL == rsp) {
1778 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301779 pe_err("AllocateMemory failed for DELTS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001780 return;
1781 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001782
1783 if (psessionEntry != NULL) {
1784
1785 rsp->aid = delts->aid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301786 qdf_copy_macaddr(&rsp->macaddr, &delts->macaddr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301787 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) &delts->req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001788 sizeof(tSirDeltsReqInfo));
1789 }
1790
1791 rsp->messageType = eWNI_SME_DELTS_RSP;
1792 rsp->rc = status;
1793
1794 /* Update SME session Id and transcation Id */
1795 rsp->sessionId = smesessionId;
1796 rsp->transactionId = smetransactionId;
1797
1798 mmhMsg.type = eWNI_SME_DELTS_RSP;
1799 mmhMsg.bodyptr = rsp;
1800 mmhMsg.bodyval = 0;
1801 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301802 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1803 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001804 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301805 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1806 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001807 }
1808#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1809 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_RSP_EVENT, psessionEntry,
1810 (uint16_t) status, 0);
1811#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1812
1813 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1814}
1815
1816void
1817lim_send_sme_delts_ind(tpAniSirGlobal pMac, tpSirDeltsReqInfo delts, uint16_t aid,
1818 tpPESession psessionEntry)
1819{
1820 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001821 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001822
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301823 pe_debug("SendSmeDeltsInd aid: %d tsid: %d up: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001824 aid, delts->tsinfo.traffic.tsid, delts->tsinfo.traffic.userPrio);
1825
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301826 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001827 if (NULL == rsp) {
1828 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301829 pe_err("AllocateMemory failed for DELTS_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001830 return;
1831 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001832
1833 rsp->messageType = eWNI_SME_DELTS_IND;
1834 rsp->rc = eSIR_SUCCESS;
1835 rsp->aid = aid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301836 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) delts, sizeof(*delts));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001837
1838 /* Update SME session Id and SME transaction Id */
1839
1840 rsp->sessionId = psessionEntry->smeSessionId;
1841 rsp->transactionId = psessionEntry->transactionId;
1842
1843 mmhMsg.type = eWNI_SME_DELTS_IND;
1844 mmhMsg.bodyptr = rsp;
1845 mmhMsg.bodyval = 0;
1846 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1847#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1848 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_IND_EVENT, psessionEntry, 0,
1849 0);
1850#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1851
1852 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1853}
1854
1855/**
1856 * lim_send_sme_pe_statistics_rsp()
1857 *
1858 ***FUNCTION:
1859 * This function is called to send 802.11 statistics response to HDD.
1860 * This function posts the result back to HDD. This is a response to
1861 * HDD's request for statistics.
1862 *
1863 ***PARAMS:
1864 *
1865 ***LOGIC:
1866 *
1867 ***ASSUMPTIONS:
1868 * NA
1869 *
1870 ***NOTE:
1871 * NA
1872 *
1873 * @param pMac Pointer to Global MAC structure
1874 * @param p80211Stats Statistics sent in response
1875 * @param resultCode TODO:
1876 *
1877 *
1878 * @return none
1879 */
1880
1881void
1882lim_send_sme_pe_statistics_rsp(tpAniSirGlobal pMac, uint16_t msgType, void *stats)
1883{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001884 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001885 uint8_t sessionId;
1886 tAniGetPEStatsRsp *pPeStats = (tAniGetPEStatsRsp *) stats;
1887 tpPESession pPeSessionEntry;
1888
1889 /* Get the Session Id based on Sta Id */
1890 pPeSessionEntry =
1891 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1892
1893 /* Fill the Session Id */
1894 if (NULL != pPeSessionEntry) {
1895 /* Fill the Session Id */
1896 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1897 }
1898
1899 pPeStats->msgType = eWNI_SME_GET_STATISTICS_RSP;
1900
1901 /* msgType should be WMA_GET_STATISTICS_RSP */
1902 mmhMsg.type = eWNI_SME_GET_STATISTICS_RSP;
1903
1904 mmhMsg.bodyptr = stats;
1905 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301906 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001907 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1908
1909 return;
1910
1911} /*** end lim_send_sme_pe_statistics_rsp() ***/
1912
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001913#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001914/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001915 * lim_send_sme_pe_ese_tsm_rsp() - send tsm response
1916 * @pMac: Pointer to global pMac structure
1917 * @pStats: Pointer to TSM Stats
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001918 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001919 * This function is called to send tsm stats response to HDD.
1920 * This function posts the result back to HDD. This is a response to
1921 * HDD's request to get tsm stats.
1922 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001923 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001924 */
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001925void lim_send_sme_pe_ese_tsm_rsp(tpAniSirGlobal pMac,
1926 tAniGetTsmStatsRsp *pStats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001927{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001928 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001929 uint8_t sessionId;
1930 tAniGetTsmStatsRsp *pPeStats = (tAniGetTsmStatsRsp *) pStats;
1931 tpPESession pPeSessionEntry = NULL;
1932
1933 /* Get the Session Id based on Sta Id */
1934 pPeSessionEntry =
1935 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1936
1937 /* Fill the Session Id */
1938 if (NULL != pPeSessionEntry) {
1939 /* Fill the Session Id */
1940 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1941 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301942 pe_err("Session not found for the Sta id: %d",
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301943 pPeStats->staId);
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05301944 qdf_mem_free(pPeStats->tsmStatsReq);
1945 qdf_mem_free(pPeStats);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001946 return;
1947 }
1948
1949 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
1950 pPeStats->tsmMetrics.RoamingCount
1951 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
1952 pPeStats->tsmMetrics.RoamingDly
1953 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
1954
1955 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
1956 mmhMsg.bodyptr = pStats;
1957 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301958 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001959 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1960
1961 return;
1962} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
1963
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001964#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001965
1966void
1967lim_send_sme_ibss_peer_ind(tpAniSirGlobal pMac,
1968 tSirMacAddr peerMacAddr,
1969 uint16_t staIndex,
1970 uint8_t ucastIdx,
1971 uint8_t bcastIdx,
1972 uint8_t *beacon,
1973 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
1974{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001975 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001976 tSmeIbssPeerInd *pNewPeerInd;
1977
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301978 pNewPeerInd = qdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001979 if (NULL == pNewPeerInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301980 pe_err("Failed to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001981 return;
1982 }
1983
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301984 qdf_mem_copy((uint8_t *) pNewPeerInd->peer_addr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301985 peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001986 pNewPeerInd->staId = staIndex;
1987 pNewPeerInd->ucastSig = ucastIdx;
1988 pNewPeerInd->bcastSig = bcastIdx;
1989 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
1990 pNewPeerInd->mesgType = msgType;
1991 pNewPeerInd->sessionId = sessionId;
1992
1993 if (beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301994 qdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001995 sizeof(tSmeIbssPeerInd)), (void *)beacon,
1996 beaconLen);
1997 }
1998
1999 mmhMsg.type = msgType;
2000 mmhMsg.bodyptr = pNewPeerInd;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302001 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002002 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2003
2004}
2005
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07002006/**
2007 * lim_process_csa_wbw_ie() - Process CSA Wide BW IE
2008 * @mac_ctx: pointer to global adapter context
2009 * @csa_params: pointer to CSA parameters
2010 * @chnl_switch_info:pointer to channel switch parameters
2011 * @session_entry: session pointer
2012 *
2013 * Return: None
2014 */
2015static void lim_process_csa_wbw_ie(tpAniSirGlobal mac_ctx,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002016 struct csa_offload_params *csa_params,
2017 tLimWiderBWChannelSwitchInfo *chnl_switch_info,
2018 tpPESession session_entry)
2019{
Amar Singhal5cccafe2017-02-15 12:42:58 -08002020 struct ch_params ch_params = {0};
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002021 uint8_t ap_new_ch_width;
2022 bool new_ch_width_dfn = false;
2023 uint8_t center_freq_diff;
2024
2025 ap_new_ch_width = csa_params->new_ch_width + 1;
2026 if ((ap_new_ch_width == CH_WIDTH_80MHZ) &&
2027 csa_params->new_ch_freq_seg2) {
2028 new_ch_width_dfn = true;
2029 if (csa_params->new_ch_freq_seg2 >
2030 csa_params->new_ch_freq_seg1)
2031 center_freq_diff = csa_params->new_ch_freq_seg2 -
2032 csa_params->new_ch_freq_seg1;
2033 else
2034 center_freq_diff = csa_params->new_ch_freq_seg1 -
2035 csa_params->new_ch_freq_seg2;
2036 if (center_freq_diff == CENTER_FREQ_DIFF_160MHz)
2037 ap_new_ch_width = CH_WIDTH_160MHZ;
2038 else if (center_freq_diff > CENTER_FREQ_DIFF_80P80MHz)
2039 ap_new_ch_width = CH_WIDTH_80P80MHZ;
2040 else
2041 ap_new_ch_width = CH_WIDTH_80MHZ;
2042 }
2043 session_entry->gLimChannelSwitch.state =
2044 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2045 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
2046 !new_ch_width_dfn) {
2047 ch_params.ch_width = CH_WIDTH_160MHZ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002048 wlan_reg_set_channel_params(mac_ctx->pdev,
2049 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002050 ap_new_ch_width = ch_params.ch_width;
2051 csa_params->new_ch_freq_seg1 = ch_params.center_freq_seg0;
2052 csa_params->new_ch_freq_seg2 = ch_params.center_freq_seg1;
2053 }
2054 chnl_switch_info->newChanWidth = ap_new_ch_width;
2055 chnl_switch_info->newCenterChanFreq0 = csa_params->new_ch_freq_seg1;
2056 chnl_switch_info->newCenterChanFreq1 = csa_params->new_ch_freq_seg2;
2057
2058 if (session_entry->ch_width == ap_new_ch_width)
2059 goto prnt_log;
2060
2061 if (session_entry->ch_width == CH_WIDTH_80MHZ) {
2062 chnl_switch_info->newChanWidth = CH_WIDTH_80MHZ;
2063 chnl_switch_info->newCenterChanFreq1 = 0;
2064 } else {
2065 session_entry->ch_width = ap_new_ch_width;
2066 chnl_switch_info->newChanWidth = ap_new_ch_width;
2067 }
2068prnt_log:
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302069 pe_debug("new channel: %d new_ch_width: %d seg0: %d seg1: %d",
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002070 csa_params->channel,
2071 chnl_switch_info->newChanWidth,
2072 chnl_switch_info->newCenterChanFreq0,
2073 chnl_switch_info->newCenterChanFreq1);
2074}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002075/**
2076 * lim_handle_csa_offload_msg() - Handle CSA offload message
2077 * @mac_ctx: pointer to global adapter context
2078 * @msg: Message pointer.
2079 *
2080 * Return: None
2081 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08002082void lim_handle_csa_offload_msg(tpAniSirGlobal mac_ctx,
2083 struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002084{
2085 tpPESession session_entry;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002086 struct scheduler_msg mmh_msg = {0};
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302087 struct csa_offload_params *csa_params =
2088 (struct csa_offload_params *) (msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002089 tpSmeCsaOffloadInd csa_offload_ind;
2090 tpDphHashNode sta_ds = NULL;
2091 uint8_t session_id;
2092 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302093 uint16_t chan_space = 0;
Amar Singhal5cccafe2017-02-15 12:42:58 -08002094 struct ch_params ch_params;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302095
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002096 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002097 tLimChannelSwitchInfo *lim_ch_switch = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002098
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302099 pe_debug("handle csa offload msg");
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302100
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002101 if (!csa_params) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302102 pe_err("limMsgQ body ptr is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002103 return;
2104 }
2105
2106 session_entry =
2107 pe_find_session_by_bssid(mac_ctx,
2108 csa_params->bssId, &session_id);
2109 if (!session_entry) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302110 pe_err("Session does not exists for %pM",
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302111 csa_params->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002112 goto err;
2113 }
2114
2115 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
2116 &session_entry->dph.dphHashTable);
2117
2118 if (!sta_ds) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302119 pe_err("sta_ds does not exist");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002120 goto err;
2121 }
2122
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002123 if (!LIM_IS_STA_ROLE(session_entry)) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302124 pe_debug("Invalid role to handle CSA");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002125 goto err;
2126 }
Masti, Narayanraddi1c630442015-11-02 12:03:50 +05302127
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002128 /*
2129 * on receiving channel switch announcement from AP, delete all
2130 * TDLS peers before leaving BSS and proceed for channel switch
2131 */
2132 lim_delete_tdls_peers(mac_ctx, session_entry);
Gupta, Kapil121bf212015-11-25 19:21:29 +05302133
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002134 lim_ch_switch = &session_entry->gLimChannelSwitch;
2135 session_entry->gLimChannelSwitch.switchMode =
2136 csa_params->switch_mode;
2137 /* timer already started by firmware, switch immediately */
2138 session_entry->gLimChannelSwitch.switchCount = 0;
2139 session_entry->gLimChannelSwitch.primaryChannel =
2140 csa_params->channel;
2141 session_entry->gLimChannelSwitch.state =
2142 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2143 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
2144 lim_ch_switch->sec_ch_offset =
2145 session_entry->htSecondaryChannelOffset;
2146 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
2147 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
2148 chnl_switch_info =
2149 &session_entry->gLimWiderBWChannelSwitch;
2150
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302151 pe_debug("vht: %d ht: %d flag: %x chan: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302152 session_entry->vhtCapability,
2153 session_entry->htSupportedChannelWidthSet,
2154 csa_params->ies_present_flag,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002155 csa_params->channel);
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302156 pe_debug("seg1: %d seg2: %d width: %d country: %s class: %d",
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002157 csa_params->new_ch_freq_seg1,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302158 csa_params->new_ch_freq_seg2,
2159 csa_params->new_ch_width,
2160 mac_ctx->scan.countryCodeCurrent,
2161 csa_params->new_op_class);
2162
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002163 if (session_entry->vhtCapability &&
2164 session_entry->htSupportedChannelWidthSet) {
2165 if (csa_params->ies_present_flag & lim_wbw_ie_present) {
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07002166 lim_process_csa_wbw_ie(mac_ctx, csa_params,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002167 chnl_switch_info, session_entry);
2168 lim_ch_switch->sec_ch_offset =
2169 csa_params->sec_chan_offset;
2170 } else if (csa_params->ies_present_flag
2171 & lim_xcsa_ie_present) {
2172 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002173 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002174 mac_ctx->scan.countryCodeCurrent,
2175 csa_params->channel,
2176 csa_params->new_op_class);
2177 session_entry->gLimChannelSwitch.state =
2178 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2179
2180 if (chan_space == 80) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002181 chnl_switch_info->newChanWidth =
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002182 CH_WIDTH_80MHZ;
2183 } else if (chan_space == 40) {
2184 chnl_switch_info->newChanWidth =
2185 CH_WIDTH_40MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002186 } else {
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002187 chnl_switch_info->newChanWidth =
2188 CH_WIDTH_20MHZ;
2189 lim_ch_switch->state =
2190 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2191 }
2192
2193 ch_params.ch_width =
2194 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002195 wlan_reg_set_channel_params(mac_ctx->pdev,
2196 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002197 chnl_switch_info->newCenterChanFreq0 =
2198 ch_params.center_freq_seg0;
2199 /*
2200 * This is not applicable for 20/40/80 MHz.
2201 * Only used when we support 80+80 MHz operation.
2202 * In case of 80+80 MHz, this parameter indicates
2203 * center channel frequency index of 80 MHz
2204 * channel offrequency segment 1.
2205 */
2206 chnl_switch_info->newCenterChanFreq1 =
2207 ch_params.center_freq_seg1;
2208 lim_ch_switch->sec_ch_offset =
2209 ch_params.sec_ch_offset;
2210
2211 }
2212 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
2213 chnl_switch_info->newCenterChanFreq0;
2214 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
2215 chnl_switch_info->newCenterChanFreq1;
2216 session_entry->gLimChannelSwitch.ch_width =
2217 chnl_switch_info->newChanWidth;
2218
2219 } else if (session_entry->htSupportedChannelWidthSet) {
2220 if (csa_params->ies_present_flag
2221 & lim_xcsa_ie_present) {
2222 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002223 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002224 mac_ctx->scan.countryCodeCurrent,
2225 csa_params->channel,
2226 csa_params->new_op_class);
2227 lim_ch_switch->state =
2228 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2229 if (chan_space == 40) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002230 lim_ch_switch->ch_width =
2231 CH_WIDTH_40MHZ;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002232 chnl_switch_info->newChanWidth =
2233 CH_WIDTH_40MHZ;
2234 ch_params.ch_width =
2235 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002236 wlan_reg_set_channel_params(mac_ctx->pdev,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002237 csa_params->channel,
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07002238 0, &ch_params);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002239 lim_ch_switch->ch_center_freq_seg0 =
2240 ch_params.center_freq_seg0;
2241 lim_ch_switch->sec_ch_offset =
2242 ch_params.sec_ch_offset;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002243 } else {
2244 lim_ch_switch->ch_width =
2245 CH_WIDTH_20MHZ;
2246 chnl_switch_info->newChanWidth =
2247 CH_WIDTH_40MHZ;
2248 lim_ch_switch->state =
2249 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2250 lim_ch_switch->sec_ch_offset =
2251 PHY_SINGLE_CHANNEL_CENTERED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002252 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002253 } else {
2254 lim_ch_switch->ch_width =
2255 CH_WIDTH_40MHZ;
2256 lim_ch_switch->state =
2257 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2258 ch_params.ch_width = CH_WIDTH_40MHZ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002259 wlan_reg_set_channel_params(mac_ctx->pdev,
2260 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002261 lim_ch_switch->ch_center_freq_seg0 =
2262 ch_params.center_freq_seg0;
2263 lim_ch_switch->sec_ch_offset =
2264 ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002265 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002266
2267 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302268 pe_debug("new ch width: %d space: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302269 session_entry->gLimChannelSwitch.ch_width, chan_space);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002270
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002271 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
2272 csa_offload_ind = qdf_mem_malloc(sizeof(tSmeCsaOffloadInd));
2273 if (NULL == csa_offload_ind) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302274 pe_err("memalloc fail eWNI_SME_CSA_OFFLOAD_EVENT");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002275 goto err;
2276 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002277
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002278 csa_offload_ind->mesgType = eWNI_SME_CSA_OFFLOAD_EVENT;
2279 csa_offload_ind->mesgLen = sizeof(tSmeCsaOffloadInd);
2280 qdf_mem_copy(csa_offload_ind->bssid.bytes, session_entry->bssId,
2281 QDF_MAC_ADDR_SIZE);
2282 mmh_msg.type = eWNI_SME_CSA_OFFLOAD_EVENT;
2283 mmh_msg.bodyptr = csa_offload_ind;
2284 mmh_msg.bodyval = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302285 pe_debug("Sending eWNI_SME_CSA_OFFLOAD_EVENT to SME");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002286 MTRACE(mac_trace_msg_tx
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002287 (mac_ctx, session_entry->peSessionId, mmh_msg.type));
2288#ifdef FEATURE_WLAN_DIAG_SUPPORT
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002289 lim_diag_event_report(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002290 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
2291 eSIR_SUCCESS, eSIR_SUCCESS);
2292#endif
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002293 lim_sys_process_mmh_msg_api(mac_ctx, &mmh_msg, ePROT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002294
2295err:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302296 qdf_mem_free(csa_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002297}
2298
2299/*--------------------------------------------------------------------------
2300 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
2301
2302 \param pMac - pointer to global adapter context
2303 \param sessionId - Message pointer.
2304
2305 \sa
2306 --------------------------------------------------------------------------*/
2307
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002308void lim_handle_delete_bss_rsp(tpAniSirGlobal pMac, struct scheduler_msg *MsgQ)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002309{
2310 tpPESession psessionEntry;
2311 tpDeleteBssParams pDelBss = (tpDeleteBssParams) (MsgQ->bodyptr);
2312
2313 psessionEntry =
2314 pe_find_session_by_session_id(pMac, pDelBss->sessionId);
2315 if (psessionEntry == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302316 pe_err("Session Does not exist for given sessionID: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002317 pDelBss->sessionId);
Naveen Rawat0c81edc2016-06-08 10:08:30 -07002318 qdf_mem_free(MsgQ->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002319 return;
2320 }
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002321 /*
2322 * During DEL BSS handling, the PE Session will be deleted, but it is
2323 * better to clear this flag if the session is hanging around due
2324 * to some error conditions so that the next DEL_BSS request does
2325 * not take the HO_FAIL path
2326 */
2327 psessionEntry->process_ho_fail = false;
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002328 if (LIM_IS_IBSS_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002329 lim_ibss_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002330 else if (LIM_IS_UNKNOWN_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002331 lim_process_sme_del_bss_rsp(pMac, MsgQ->bodyval, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002332 else if (LIM_IS_NDI_ROLE(psessionEntry))
2333 lim_ndi_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002334 else
2335 lim_process_mlm_del_bss_rsp(pMac, MsgQ, psessionEntry);
2336
2337}
2338
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002339/** -----------------------------------------------------------------
2340 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
2341 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
2342 \ SME only looks at rc and tspec field.
2343 \param pMac - global mac structure
2344 \param rspReqd - is SmeAddTsRsp required
2345 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
2346 \return tspec
2347 \sa
2348 ----------------------------------------------------------------- */
2349void
2350lim_send_sme_aggr_qos_rsp(tpAniSirGlobal pMac, tpSirAggrQosRsp aggrQosRsp,
2351 uint8_t smesessionId)
2352{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002353 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002354
2355 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
2356 mmhMsg.bodyptr = aggrQosRsp;
2357 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302358 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2359 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002360 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2361
2362 return;
2363}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002364
2365void lim_send_sme_max_assoc_exceeded_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
2366 uint8_t smesessionId)
2367{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002368 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002369 tSmeMaxAssocInd *pSmeMaxAssocInd;
2370
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302371 pSmeMaxAssocInd = qdf_mem_malloc(sizeof(tSmeMaxAssocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002372 if (NULL == pSmeMaxAssocInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302373 pe_err("Failed to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002374 return;
2375 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302376 qdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peer_mac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302377 (uint8_t *) peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002378 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
2379 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
2380 pSmeMaxAssocInd->sessionId = smesessionId;
2381 mmhMsg.type = pSmeMaxAssocInd->mesgType;
2382 mmhMsg.bodyptr = pSmeMaxAssocInd;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302383 pe_debug("msgType: %s peerMacAddr "MAC_ADDRESS_STR "sme session id %d",
2384 "eWNI_SME_MAX_ASSOC_EXCEEDED", MAC_ADDR_ARRAY(peerMacAddr),
2385 pSmeMaxAssocInd->sessionId);
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302386 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2387 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002388 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2389
2390 return;
2391}
2392
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002393/*--------------------------------------------------------------------------
2394 \brief lim_send_dfs_chan_sw_ie_update()
2395 This timer handler updates the channel switch IE in beacon template
2396
2397 \param pMac - pointer to global adapter context
2398 \return - channel to scan from valid session else zero.
2399 \sa
2400 --------------------------------------------------------------------------*/
2401static void
2402lim_send_dfs_chan_sw_ie_update(tpAniSirGlobal pMac, tpPESession psessionEntry)
2403{
2404
2405 /* Update the beacon template and send to FW */
2406 if (sch_set_fixed_beacon_fields(pMac, psessionEntry) != eSIR_SUCCESS) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302407 pe_err("Unable to set CSA IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002408 return;
2409 }
2410
2411 /* Send update beacon template message */
2412 lim_send_beacon_ind(pMac, psessionEntry);
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302413 pe_debug("Updated CSA IE, IE COUNT: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002414 psessionEntry->gLimChannelSwitch.switchCount);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002415
2416 return;
2417}
2418
2419/** -----------------------------------------------------------------
2420 \brief lim_send_sme_ap_channel_switch_resp() - sends
2421 eWNI_SME_CHANNEL_CHANGE_RSP
2422 After receiving WMA_SWITCH_CHANNEL_RSP indication this
2423 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
2424 that the Channel change has been done to the specified target
2425 channel in the Channel change request
2426 \param pMac - global mac structure
2427 \param psessionEntry - session info
2428 \param pChnlParams - Channel switch params
2429 --------------------------------------------------------------------*/
2430void
2431lim_send_sme_ap_channel_switch_resp(tpAniSirGlobal pMac,
2432 tpPESession psessionEntry,
2433 tpSwitchChannelParams pChnlParams)
2434{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002435 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002436 tpSwitchChannelParams pSmeSwithChnlParams;
2437 uint8_t channelId;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002438 bool is_ch_dfs = false;
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08002439 enum phy_ch_width ch_width;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002440 uint8_t ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002441
2442 pSmeSwithChnlParams = (tSwitchChannelParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302443 qdf_mem_malloc(sizeof(tSwitchChannelParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002444 if (NULL == pSmeSwithChnlParams) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302445 pe_err("AllocateMemory failed for pSmeSwithChnlParams");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002446 return;
2447 }
2448
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302449 qdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002450 sizeof(tSwitchChannelParams));
2451
2452 channelId = pSmeSwithChnlParams->channelNumber;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002453 ch_width = pSmeSwithChnlParams->ch_width;
2454 ch_center_freq_seg1 = pSmeSwithChnlParams->ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002455
2456 /*
2457 * Pass the sme sessionID to SME instead
2458 * PE session ID.
2459 */
2460 pSmeSwithChnlParams->peSessionId = psessionEntry->smeSessionId;
2461
2462 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
2463 mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
2464 mmhMsg.bodyval = 0;
2465 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2466
2467 /*
2468 * We should start beacon transmission only if the new
2469 * channel after channel change is Non-DFS. For a DFS
2470 * channel, PE will receive an explicit request from
2471 * upper layers to start the beacon transmission .
2472 */
2473
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002474 if (ch_width == CH_WIDTH_160MHZ) {
2475 is_ch_dfs = true;
2476 } else if (ch_width == CH_WIDTH_80P80MHZ) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002477 if (wlan_reg_get_channel_state(pMac->pdev, channelId) ==
2478 CHANNEL_STATE_DFS ||
2479 wlan_reg_get_channel_state(pMac->pdev,
2480 ch_center_freq_seg1 -
2481 SIR_80MHZ_START_CENTER_CH_DIFF) ==
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002482 CHANNEL_STATE_DFS)
2483 is_ch_dfs = true;
2484 } else {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002485 if (wlan_reg_get_channel_state(pMac->pdev, channelId) ==
2486 CHANNEL_STATE_DFS)
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002487 is_ch_dfs = true;
2488 }
2489
2490 if (!is_ch_dfs) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002491 if (channelId == psessionEntry->currentOperChannel) {
2492 lim_apply_configuration(pMac, psessionEntry);
2493 lim_send_beacon_ind(pMac, psessionEntry);
2494 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302495 pe_debug("Failed to Transmit Beacons on channel: %d after AP channel change response",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002496 psessionEntry->bcnLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002497 }
2498 }
2499 return;
2500}
2501
2502/** -----------------------------------------------------------------
2503 \brief lim_process_beacon_tx_success_ind() - This function is used
2504 explicitely to handle successful beacon transmission indication
2505 from the FW. This is a generic event generated by the FW afer the
2506 first beacon is sent out after the beacon template update by the
2507 host
2508 \param pMac - global mac structure
2509 \param psessionEntry - session info
2510 \return none
2511 \sa
2512 ----------------------------------------------------------------- */
2513void
2514lim_process_beacon_tx_success_ind(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2515{
2516 /* Currently, this event is used only for DFS channel switch announcement
2517 * IE update in the template. If required to be used for other IE updates
2518 * add appropriate code by introducing a state variable
2519 */
2520 tpPESession psessionEntry;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002521 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002522 tSirSmeCSAIeTxCompleteRsp *pChanSwTxResponse;
2523 struct sir_beacon_tx_complete_rsp *beacon_tx_comp_rsp_ptr;
2524 uint8_t length = sizeof(tSirSmeCSAIeTxCompleteRsp);
2525 tpSirFirstBeaconTxCompleteInd pBcnTxInd =
2526 (tSirFirstBeaconTxCompleteInd *) event;
2527
2528 psessionEntry = pe_find_session_by_bss_idx(pMac, pBcnTxInd->bssIdx);
2529 if (psessionEntry == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302530 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002531 return;
2532 }
2533
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302534 pe_debug("role: %d swIe: %d opIe: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302535 GET_LIM_SYSTEM_ROLE(psessionEntry),
2536 psessionEntry->dfsIncludeChanSwIe,
2537 psessionEntry->gLimOperatingMode.present);
2538
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002539 if (LIM_IS_AP_ROLE(psessionEntry) &&
2540 true == psessionEntry->dfsIncludeChanSwIe) {
2541 /* Send only 5 beacons with CSA IE Set in when a radar is detected */
2542 if (psessionEntry->gLimChannelSwitch.switchCount > 0) {
2543 /*
2544 * Send the next beacon with updated CSA IE count
2545 */
2546 lim_send_dfs_chan_sw_ie_update(pMac, psessionEntry);
2547 /* Decrement the IE count */
2548 psessionEntry->gLimChannelSwitch.switchCount--;
2549 } else {
2550 /* Done with CSA IE update, send response back to SME */
2551 psessionEntry->gLimChannelSwitch.switchCount = 0;
2552 if (pMac->sap.SapDfsInfo.disable_dfs_ch_switch == false)
2553 psessionEntry->gLimChannelSwitch.switchMode = 0;
2554 psessionEntry->dfsIncludeChanSwIe = false;
2555 psessionEntry->dfsIncludeChanWrapperIe = false;
2556
2557 pChanSwTxResponse = (tSirSmeCSAIeTxCompleteRsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302558 qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002559
2560 if (NULL == pChanSwTxResponse) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302561 pe_err("AllocateMemory failed for tSirSmeCSAIeTxCompleteRsp");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002562 return;
2563 }
2564
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002565 pChanSwTxResponse->sessionId =
2566 psessionEntry->smeSessionId;
2567 pChanSwTxResponse->chanSwIeTxStatus =
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302568 QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002569
2570 mmhMsg.type = eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND;
2571 mmhMsg.bodyptr = pChanSwTxResponse;
2572 mmhMsg.bodyval = 0;
2573 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2574 }
2575 }
2576
2577 if (LIM_IS_AP_ROLE(psessionEntry) &&
2578 psessionEntry->gLimOperatingMode.present) {
2579 /* Done with nss update, send response back to SME */
2580 psessionEntry->gLimOperatingMode.present = 0;
2581 beacon_tx_comp_rsp_ptr = (struct sir_beacon_tx_complete_rsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302582 qdf_mem_malloc(sizeof(*beacon_tx_comp_rsp_ptr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002583 if (NULL == beacon_tx_comp_rsp_ptr) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302584 pe_err("AllocateMemory failed for beacon_tx_comp_rsp_ptr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002585 return;
2586 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002587 beacon_tx_comp_rsp_ptr->session_id =
2588 psessionEntry->smeSessionId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302589 beacon_tx_comp_rsp_ptr->tx_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002590 mmhMsg.type = eWNI_SME_NSS_UPDATE_RSP;
2591 mmhMsg.bodyptr = beacon_tx_comp_rsp_ptr;
2592 mmhMsg.bodyval = 0;
2593 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2594 }
2595 return;
2596}