blob: e1faeccac184484a74873a1c29d8abfc344417ee [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{
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700268 uint16_t bss_ie_len;
269 void *bss_ies;
270 bool is_vendor_ap_1_present;
271
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800272#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
273 tSirSmeHTProfile *ht_profile;
274#endif
275 if (result_code == eSIR_SME_SUCCESS) {
276 if (session_entry->beacon != NULL) {
277 sme_join_rsp->beaconLength = session_entry->bcnLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530278 qdf_mem_copy(sme_join_rsp->frames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800279 session_entry->beacon,
280 sme_join_rsp->beaconLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530281 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800282 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530283 session_entry->bcnLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530284 pe_debug("Beacon: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530285 sme_join_rsp->beaconLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800286 }
287 if (session_entry->assocReq != NULL) {
288 sme_join_rsp->assocReqLength =
289 session_entry->assocReqLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530290 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530291 sme_join_rsp->beaconLength,
292 session_entry->assocReq,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800293 sme_join_rsp->assocReqLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530294 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800295 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530296 session_entry->assocReqLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530297 pe_debug("AssocReq: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530298 sme_join_rsp->assocReqLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800299 }
300 if (session_entry->assocRsp != NULL) {
301 sme_join_rsp->assocRspLength =
302 session_entry->assocRspLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530303 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530304 sme_join_rsp->beaconLength +
305 sme_join_rsp->assocReqLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800306 session_entry->assocRsp,
307 sme_join_rsp->assocRspLength);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530308 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800309 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530310 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800311 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800312 if (session_entry->ricData != NULL) {
313 sme_join_rsp->parsedRicRspLen =
314 session_entry->RICDataLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530315 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530316 sme_join_rsp->beaconLength +
317 sme_join_rsp->assocReqLength +
318 sme_join_rsp->assocRspLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800319 session_entry->ricData,
320 sme_join_rsp->parsedRicRspLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530321 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800322 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530323 session_entry->RICDataLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530324 pe_debug("RicLength: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800325 sme_join_rsp->parsedRicRspLen);
326 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800327#ifdef FEATURE_WLAN_ESE
328 if (session_entry->tspecIes != NULL) {
329 sme_join_rsp->tspecIeLen =
330 session_entry->tspecLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530331 qdf_mem_copy(sme_join_rsp->frames +
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530332 sme_join_rsp->beaconLength +
333 sme_join_rsp->assocReqLength +
334 sme_join_rsp->assocRspLength +
335 sme_join_rsp->parsedRicRspLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800336 session_entry->tspecIes,
337 sme_join_rsp->tspecIeLen);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530338 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800339 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530340 session_entry->tspecLen = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530341 pe_debug("ESE-TspecLen: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530342 sme_join_rsp->tspecIeLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800343 }
344#endif
345 sme_join_rsp->aid = session_entry->limAID;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530346 pe_debug("AssocRsp: %d",
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530347 sme_join_rsp->assocRspLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800348 sme_join_rsp->vht_channel_width =
349 session_entry->ch_width;
350#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
351 if (session_entry->cc_switch_mode !=
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530352 QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800353 ht_profile = &sme_join_rsp->HTProfile;
354 ht_profile->htSupportedChannelWidthSet =
355 session_entry->htSupportedChannelWidthSet;
356 ht_profile->htRecommendedTxWidthSet =
357 session_entry->htRecommendedTxWidthSet;
358 ht_profile->htSecondaryChannelOffset =
359 session_entry->htSecondaryChannelOffset;
360 ht_profile->dot11mode = session_entry->dot11mode;
361 ht_profile->htCapability = session_entry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800362 ht_profile->vhtCapability =
363 session_entry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800364 ht_profile->apCenterChan = session_entry->ch_center_freq_seg0;
365 ht_profile->apChanWidth = session_entry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800366 }
367#endif
Naveen Rawatc4a0e662017-05-19 08:06:57 -0700368 bss_ie_len = lim_get_ielen_from_bss_description(
369 &session_entry->pLimJoinReq->bssDescription);
370 bss_ies = &session_entry->pLimJoinReq->bssDescription.ieFields;
371 is_vendor_ap_1_present = (cfg_get_vendor_ie_ptr_from_oui(mac_ctx,
372 SIR_MAC_VENDOR_AP_1_OUI, SIR_MAC_VENDOR_AP_1_OUI_LEN,
373 bss_ies, bss_ie_len) != NULL);
374
375 if (mac_ctx->roam.configParam.is_force_1x1 &&
376 is_vendor_ap_1_present && (session_entry->nss == 2) &&
377 (mac_ctx->lteCoexAntShare == 0 ||
378 IS_5G_CH(session_entry->currentOperChannel))) {
379 /* SET vdev param */
380 pe_debug("sending SMPS intolrent vdev_param");
381 wma_cli_set_command(session_entry->smeSessionId,
382 (int)WMI_VDEV_PARAM_SMPS_INTOLERANT,
383 1, VDEV_CMD);
384
385 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800386 } else {
387 if (session_entry->beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530388 qdf_mem_free(session_entry->beacon);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800389 session_entry->beacon = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530390 session_entry->bcnLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800391 }
392 if (session_entry->assocReq != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530393 qdf_mem_free(session_entry->assocReq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800394 session_entry->assocReq = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530395 session_entry->assocReqLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800396 }
397 if (session_entry->assocRsp != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530398 qdf_mem_free(session_entry->assocRsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800399 session_entry->assocRsp = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530400 session_entry->assocRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800401 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800402 if (session_entry->ricData != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530403 qdf_mem_free(session_entry->ricData);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800404 session_entry->ricData = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530405 session_entry->RICDataLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800406 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800407#ifdef FEATURE_WLAN_ESE
408 if (session_entry->tspecIes != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530409 qdf_mem_free(session_entry->tspecIes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800410 session_entry->tspecIes = NULL;
Sreelakshmi Konamki3b8ba612015-12-02 18:13:22 +0530411 session_entry->tspecLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800412 }
413#endif
414 }
415}
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530416
417/**
418 * lim_add_bss_info() - copy data from session entry to join rsp
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530419 * @sta_ds: Station dph entry
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530420 * @sme_join_rsp: Join response buffer to be filled up
421 *
422 * Return: None
423 */
Jeff Johnson6db011e2016-10-07 07:31:39 -0700424static void lim_add_bss_info(tpDphHashNode sta_ds, tpSirSmeJoinRsp sme_join_rsp)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530425{
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530426 struct parsed_ies *parsed_ies = &sta_ds->parsed_ies;
427
428 if (parsed_ies->hs20vendor_ie.present)
429 sme_join_rsp->hs20vendor_ie = parsed_ies->hs20vendor_ie;
430 if (parsed_ies->vht_caps.present)
431 sme_join_rsp->vht_caps = parsed_ies->vht_caps;
432 if (parsed_ies->ht_caps.present)
433 sme_join_rsp->ht_caps = parsed_ies->ht_caps;
434 if (parsed_ies->ht_operation.present)
435 sme_join_rsp->ht_operation = parsed_ies->ht_operation;
436 if (parsed_ies->vht_operation.present)
437 sme_join_rsp->vht_operation = parsed_ies->vht_operation;
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530438}
439
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800440/**
441 * lim_send_sme_join_reassoc_rsp() - Send Response to Upper Layers
442 * @mac_ctx: Pointer to Global MAC structure
443 * @msg_type: Indicates message type
444 * @result_code: Indicates the result of previously issued
445 * eWNI_SME_msgType_REQ message
446 * @prot_status_code: Protocol Status Code
447 * @session_entry: PE Session Info
448 * @sme_session_id: SME Session ID
449 * @sme_transaction_id: SME Transaction ID
450 *
451 * This function is called by lim_process_sme_req_messages() to send
452 * eWNI_SME_JOIN_RSP or eWNI_SME_REASSOC_RSP messages to applications
453 * above MAC Software.
454 *
455 * Return: None
456 */
457
458void
459lim_send_sme_join_reassoc_rsp(tpAniSirGlobal mac_ctx, uint16_t msg_type,
460 tSirResultCodes result_code, uint16_t prot_status_code,
461 tpPESession session_entry, uint8_t sme_session_id,
462 uint16_t sme_transaction_id)
463{
464 tpSirSmeJoinRsp sme_join_rsp;
465 uint32_t rsp_len;
466 tpDphHashNode sta_ds = NULL;
467#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
468 if (msg_type == eWNI_SME_REASSOC_RSP)
469 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_RSP_EVENT,
470 session_entry, (uint16_t) result_code, 0);
471 else
472 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_JOIN_RSP_EVENT,
473 session_entry, (uint16_t) result_code, 0);
474#endif /* FEATURE_WLAN_DIAG_SUPPORT */
475
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530476 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800477 lim_msg_str(msg_type), lim_result_code_str(result_code));
478
479 if (session_entry == NULL) {
480 rsp_len = sizeof(tSirSmeJoinRsp);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530481 sme_join_rsp = qdf_mem_malloc(rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800482 if (NULL == sme_join_rsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530483 pe_err("Mem Alloc fail - JOIN/REASSOC_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800484 return;
485 }
486
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800487 sme_join_rsp->beaconLength = 0;
488 sme_join_rsp->assocReqLength = 0;
489 sme_join_rsp->assocRspLength = 0;
490 } else {
491 rsp_len = session_entry->assocReqLen +
492 session_entry->assocRspLen + session_entry->bcnLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800493 session_entry->RICDataLen +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800494#ifdef FEATURE_WLAN_ESE
495 session_entry->tspecLen +
496#endif
497 sizeof(tSirSmeJoinRsp) - sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530498 sme_join_rsp = qdf_mem_malloc(rsp_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800499 if (NULL == sme_join_rsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530500 pe_err("MemAlloc fail - JOIN/REASSOC_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800501 return;
502 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800503 if (result_code == eSIR_SME_SUCCESS) {
504 sta_ds = dph_get_hash_entry(mac_ctx,
505 DPH_STA_HASH_INDEX_PEER,
506 &session_entry->dph.dphHashTable);
507 if (sta_ds == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530508 pe_err("Get Self Sta Entry fail");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800509 } else {
510 /* Pass the peer's staId */
511 sme_join_rsp->staId = sta_ds->staIndex;
512 sme_join_rsp->ucastSig =
513 sta_ds->ucUcastSig;
514 sme_join_rsp->bcastSig =
515 sta_ds->ucBcastSig;
516 sme_join_rsp->timingMeasCap =
517 sta_ds->timingMeasCap;
518#ifdef FEATURE_WLAN_TDLS
519 sme_join_rsp->tdls_prohibited =
520 session_entry->tdls_prohibited;
521 sme_join_rsp->tdls_chan_swit_prohibited =
522 session_entry->tdls_chan_swit_prohibited;
523#endif
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530524 sme_join_rsp->nss = sta_ds->nss;
525 sme_join_rsp->max_rate_flags =
526 lim_get_max_rate_flags(mac_ctx, sta_ds);
Selvaraj, Sridhare01e0732016-09-13 12:45:22 +0530527 lim_add_bss_info(sta_ds, sme_join_rsp);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800528 }
529 }
530 sme_join_rsp->beaconLength = 0;
531 sme_join_rsp->assocReqLength = 0;
532 sme_join_rsp->assocRspLength = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800533 sme_join_rsp->parsedRicRspLen = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800534#ifdef FEATURE_WLAN_ESE
535 sme_join_rsp->tspecIeLen = 0;
536#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800537 lim_handle_join_rsp_status(mac_ctx, session_entry, result_code,
538 sme_join_rsp);
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800539
540 /* Send supported NSS 1x1 to SME */
541 sme_join_rsp->supported_nss_1x1 =
542 session_entry->supported_nss_1x1;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530543 pe_debug("SME Join Rsp is supported NSS 1X1: %d",
Archana Ramachandran20d2e232016-02-11 16:58:40 -0800544 sme_join_rsp->supported_nss_1x1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800545 }
546
547 sme_join_rsp->messageType = msg_type;
548 sme_join_rsp->length = (uint16_t) rsp_len;
549 sme_join_rsp->statusCode = result_code;
550 sme_join_rsp->protStatusCode = prot_status_code;
551
552 sme_join_rsp->sessionId = sme_session_id;
553 sme_join_rsp->transactionId = sme_transaction_id;
554
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530555 lim_send_sme_join_reassoc_rsp_after_resume(mac_ctx, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800556 (uint32_t *)sme_join_rsp);
557}
558
559/**
560 * lim_send_sme_start_bss_rsp()
561 *
562 ***FUNCTION:
563 * This function is called to send eWNI_SME_START_BSS_RSP
564 * message to applications above MAC Software.
565 *
566 ***PARAMS:
567 *
568 ***LOGIC:
569 *
570 ***ASSUMPTIONS:
571 * NA
572 *
573 ***NOTE:
574 * NA
575 *
576 * @param pMac Pointer to Global MAC structure
577 * @param msgType Indicates message type
578 * @param resultCode Indicates the result of previously issued
579 * eWNI_SME_msgType_REQ message
580 *
581 * @return None
582 */
583
584void
585lim_send_sme_start_bss_rsp(tpAniSirGlobal pMac,
586 uint16_t msgType, tSirResultCodes resultCode,
587 tpPESession psessionEntry, uint8_t smesessionId,
588 uint16_t smetransactionId)
589{
590
591 uint16_t size = 0;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700592 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800593 tSirSmeStartBssRsp *pSirSmeRsp;
594 uint16_t ieLen;
595 uint16_t ieOffset, curLen;
596
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530597 pe_debug("Sending message: %s with reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800598 lim_msg_str(msgType), lim_result_code_str(resultCode));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800599
600 size = sizeof(tSirSmeStartBssRsp);
601
602 if (psessionEntry == NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530603 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800604 if (NULL == pSirSmeRsp) {
605 /* / Buffer not available. Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530606 pe_err("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800607 return;
608 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800609 } else {
610 /* subtract size of beaconLength + Mac Hdr + Fixed Fields before SSID */
611 ieOffset = sizeof(tAniBeaconStruct) + SIR_MAC_B_PR_SSID_OFFSET;
612 ieLen = psessionEntry->schBeaconOffsetBegin
613 + psessionEntry->schBeaconOffsetEnd - ieOffset;
614 /* calculate the memory size to allocate */
615 size += ieLen;
616
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530617 pSirSmeRsp = qdf_mem_malloc(size);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800618 if (NULL == pSirSmeRsp) {
619 /* / Buffer not available. Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530620 pe_err("call to AllocateMemory failed for eWNI_SME_START_BSS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800621 return;
622 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800623 size = sizeof(tSirSmeStartBssRsp);
624 if (resultCode == eSIR_SME_SUCCESS) {
625
626 sir_copy_mac_addr(pSirSmeRsp->bssDescription.bssId,
627 psessionEntry->bssId);
628
629 /* Read beacon interval from session */
630 pSirSmeRsp->bssDescription.beaconInterval =
631 (uint16_t) psessionEntry->beaconParams.
632 beaconInterval;
633 pSirSmeRsp->bssType = psessionEntry->bssType;
634
635 if (cfg_get_capability_info
636 (pMac, &pSirSmeRsp->bssDescription.capabilityInfo,
637 psessionEntry)
638 != eSIR_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530639 pe_err("could not retrieve Capabilities value");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800640
641 lim_get_phy_mode(pMac,
642 (uint32_t *) &pSirSmeRsp->bssDescription.
643 nwType, psessionEntry);
644
645 pSirSmeRsp->bssDescription.channelId =
646 psessionEntry->currentOperChannel;
647
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700648 if (!LIM_IS_NDI_ROLE(psessionEntry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800649 curLen = psessionEntry->schBeaconOffsetBegin - ieOffset;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530650 qdf_mem_copy((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800651 ieFields,
652 psessionEntry->pSchBeaconFrameBegin +
653 ieOffset, (uint32_t) curLen);
654
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530655 qdf_mem_copy(((uint8_t *) &pSirSmeRsp->bssDescription.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800656 ieFields) + curLen,
657 psessionEntry->pSchBeaconFrameEnd,
658 (uint32_t) psessionEntry->
659 schBeaconOffsetEnd);
660
Abhishek Singh34a4d862016-10-26 16:01:51 +0530661 pSirSmeRsp->bssDescription.length = (uint16_t)
662 (offsetof(tSirBssDescription, ieFields[0])
663 - sizeof(pSirSmeRsp->bssDescription.length)
664 + ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800665 /* This is the size of the message, subtracting the size of the pointer to ieFields */
666 size += ieLen - sizeof(uint32_t);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -0700667 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800668#ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
669 if (psessionEntry->cc_switch_mode
Anurag Chouhanf04e84f2016-03-03 10:12:12 +0530670 != QDF_MCC_TO_SCC_SWITCH_DISABLE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800671 pSirSmeRsp->HTProfile.
672 htSupportedChannelWidthSet =
673 psessionEntry->htSupportedChannelWidthSet;
674 pSirSmeRsp->HTProfile.htRecommendedTxWidthSet =
675 psessionEntry->htRecommendedTxWidthSet;
676 pSirSmeRsp->HTProfile.htSecondaryChannelOffset =
677 psessionEntry->htSecondaryChannelOffset;
678 pSirSmeRsp->HTProfile.dot11mode =
679 psessionEntry->dot11mode;
680 pSirSmeRsp->HTProfile.htCapability =
681 psessionEntry->htCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800682 pSirSmeRsp->HTProfile.vhtCapability =
683 psessionEntry->vhtCapability;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800684 pSirSmeRsp->HTProfile.apCenterChan =
685 psessionEntry->ch_center_freq_seg0;
686 pSirSmeRsp->HTProfile.apChanWidth =
687 psessionEntry->ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800688 }
689#endif
690 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800691 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800692 pSirSmeRsp->messageType = msgType;
693 pSirSmeRsp->length = size;
694
695 /* Update SME session Id and transaction Id */
696 pSirSmeRsp->sessionId = smesessionId;
697 pSirSmeRsp->transactionId = smetransactionId;
698 pSirSmeRsp->statusCode = resultCode;
699 if (psessionEntry != NULL)
700 pSirSmeRsp->staId = psessionEntry->staId; /* else it will be always zero smeRsp StaID = 0 */
701
702 mmhMsg.type = msgType;
703 mmhMsg.bodyptr = pSirSmeRsp;
704 mmhMsg.bodyval = 0;
705 if (psessionEntry == NULL) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530706 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
707 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800708 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530709 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
710 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800711 }
712#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
713 lim_diag_event_report(pMac, WLAN_PE_DIAG_START_BSS_RSP_EVENT,
714 psessionEntry, (uint16_t) resultCode, 0);
715#endif /* FEATURE_WLAN_DIAG_SUPPORT */
716
717 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
718} /*** end lim_send_sme_start_bss_rsp() ***/
719
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800720/**
721 * lim_send_sme_scan_rsp() - Send scan response to SME
722 * @pMac: Pointer to Global MAC structure
723 * @length: Indicates length of message
724 * @resultCode: Indicates the result of previously issued
725 * eWNI_SME_SCAN_REQ message
726 * @scan_id: scan identifier
727 *
728 * This function is called by lim_process_sme_req_messages() to send
729 * eWNI_SME_SCAN_RSP message to applications above MAC
730 *
731 * return: None
732 */
733
734void
735lim_send_sme_scan_rsp(tpAniSirGlobal pMac, tSirResultCodes resultCode,
736 uint8_t smesessionId, uint16_t smetranscationId,
737 uint32_t scan_id)
738{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800739 lim_post_sme_scan_rsp_message(pMac, resultCode, smesessionId,
740 smetranscationId, scan_id);
741}
742
743/**
744 * lim_post_sme_scan_rsp_message()
745 *
746 ***FUNCTION:
747 * This function is called by lim_send_sme_scan_rsp() to send
748 * eWNI_SME_SCAN_RSP message with failed result code
749 *
750 ***NOTE:
751 * NA
752 *
753 * @param pMac Pointer to Global MAC structure
754 * @param length Indicates length of message
755 * @param resultCode failed result code
756 *
757 * @return None
758 */
759
760void
761lim_post_sme_scan_rsp_message(tpAniSirGlobal pMac,
762 tSirResultCodes resultCode, uint8_t smesessionId,
763 uint16_t smetransactionId,
764 uint32_t scan_id)
765{
766 tpSirSmeScanRsp pSirSmeScanRsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700767 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800768
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530769 pe_debug("send SME_SCAN_RSP reasonCode: %s",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800770 lim_result_code_str(resultCode));
771
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530772 pSirSmeScanRsp = qdf_mem_malloc(sizeof(tSirSmeScanRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800773 if (NULL == pSirSmeScanRsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530774 pe_err("AllocateMemory failed for eWNI_SME_SCAN_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800775 return;
776 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800777
778 pSirSmeScanRsp->messageType = eWNI_SME_SCAN_RSP;
779 pSirSmeScanRsp->statusCode = resultCode;
780
781 /*Update SME session Id and transaction Id */
782 pSirSmeScanRsp->sessionId = smesessionId;
783 pSirSmeScanRsp->transcationId = smetransactionId;
784 pSirSmeScanRsp->scan_id = scan_id;
785
786 mmhMsg.type = eWNI_SME_SCAN_RSP;
787 mmhMsg.bodyptr = pSirSmeScanRsp;
788 mmhMsg.bodyval = 0;
789
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530790 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800791#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
792 lim_diag_event_report(pMac, WLAN_PE_DIAG_SCAN_RSP_EVENT, NULL,
793 (uint16_t) resultCode, 0);
794#endif /* FEATURE_WLAN_DIAG_SUPPORT */
795
796 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
797 return;
798
799} /*** lim_post_sme_scan_rsp_message ***/
800
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800801void lim_send_sme_disassoc_deauth_ntf(tpAniSirGlobal pMac,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530802 QDF_STATUS status, uint32_t *pCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800803{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700804 struct scheduler_msg mmhMsg = {0};
Rajeev Kumar416b73f2017-01-21 16:45:21 -0800805 struct scheduler_msg *pMsg = (struct scheduler_msg *) pCtx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800806
807 mmhMsg.type = pMsg->type;
808 mmhMsg.bodyptr = pMsg;
809 mmhMsg.bodyval = 0;
810
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +0530811 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800812
813 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
814}
815
816/**
817 * lim_send_sme_disassoc_ntf()
818 *
819 ***FUNCTION:
820 * This function is called by limProcessSmeMessages() to send
821 * eWNI_SME_DISASSOC_RSP/IND message to host
822 *
823 ***PARAMS:
824 *
825 ***LOGIC:
826 *
827 ***ASSUMPTIONS:
828 * NA
829 *
830 ***NOTE:
831 * This function is used for sending eWNI_SME_DISASSOC_CNF,
832 * or eWNI_SME_DISASSOC_IND to host depending on
833 * disassociation trigger.
834 *
835 * @param peerMacAddr Indicates the peer MAC addr to which
836 * disassociate was initiated
837 * @param reasonCode Indicates the reason for Disassociation
838 * @param disassocTrigger Indicates the trigger for Disassociation
839 * @param aid Indicates the STAID. This parameter is
840 * present only on AP.
841 *
842 * @return None
843 */
844void
845lim_send_sme_disassoc_ntf(tpAniSirGlobal pMac,
846 tSirMacAddr peerMacAddr,
847 tSirResultCodes reasonCode,
848 uint16_t disassocTrigger,
849 uint16_t aid,
850 uint8_t smesessionId,
851 uint16_t smetransactionId, tpPESession psessionEntry)
852{
853
854 uint8_t *pBuf;
855 tSirSmeDisassocRsp *pSirSmeDisassocRsp;
856 tSirSmeDisassocInd *pSirSmeDisassocInd;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700857 uint32_t *pMsg = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800858 bool failure = false;
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700859 tpPESession session = NULL;
860 uint16_t i, assoc_id;
861 tpDphHashNode sta_ds = NULL;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530862 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800863
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530864 pe_debug("Disassoc Ntf with trigger : %d reasonCode: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800865 disassocTrigger, reasonCode);
866
867 switch (disassocTrigger) {
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700868 case eLIM_DUPLICATE_ENTRY:
869 /*
870 * Duplicate entry is removed at LIM.
871 * Initiate new entry for other session
872 */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530873 pe_debug("Rcvd eLIM_DUPLICATE_ENTRY for " MAC_ADDRESS_STR,
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700874 MAC_ADDR_ARRAY(peerMacAddr));
875
876 for (i = 0; i < pMac->lim.maxBssId; i++) {
877 if ((&pMac->lim.gpSession[i] != NULL) &&
878 (pMac->lim.gpSession[i].valid) &&
879 (pMac->lim.gpSession[i].pePersona ==
880 QDF_SAP_MODE)) {
881 /* Find the sta ds entry in another session */
882 session = &pMac->lim.gpSession[i];
883 sta_ds = dph_lookup_hash_entry(pMac,
884 peerMacAddr, &assoc_id,
885 &session->dph.dphHashTable);
886 }
887 }
888 if (sta_ds
889#ifdef WLAN_FEATURE_11W
890 && (!sta_ds->rmfEnabled)
891#endif
892 ) {
893 if (lim_add_sta(pMac, sta_ds, false, session) !=
894 eSIR_SUCCESS)
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530895 pe_err("could not Add STA with assocId: %d",
Sandeep Puligilla7e3e3c52016-09-02 17:54:21 -0700896 sta_ds->assocId);
897 }
898 failure = true;
899 break;
900
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800901 case eLIM_HOST_DISASSOC:
902 /**
903 * Disassociation response due to
904 * host triggered disassociation
905 */
906
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530907 pSirSmeDisassocRsp = qdf_mem_malloc(sizeof(tSirSmeDisassocRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800908 if (NULL == pSirSmeDisassocRsp) {
909 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530910 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800911 failure = true;
912 goto error;
913 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530914 pe_debug("send eWNI_SME_DISASSOC_RSP with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800915 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
916 pSirSmeDisassocRsp->messageType = eWNI_SME_DISASSOC_RSP;
917 pSirSmeDisassocRsp->length = sizeof(tSirSmeDisassocRsp);
918 /* sessionId */
919 pBuf = (uint8_t *) &pSirSmeDisassocRsp->sessionId;
920 *pBuf = smesessionId;
921 pBuf++;
922
923 /* transactionId */
924 lim_copy_u16(pBuf, smetransactionId);
925 pBuf += sizeof(uint16_t);
926
927 /* statusCode */
928 lim_copy_u32(pBuf, reasonCode);
929 pBuf += sizeof(tSirResultCodes);
930
931 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530932 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800933 pBuf += sizeof(tSirMacAddr);
934
935 /* Clear Station Stats */
936 /* for sta, it is always 1, IBSS is handled at halInitSta */
937
938#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
939
940 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_RSP_EVENT,
941 psessionEntry, (uint16_t) reasonCode, 0);
942#endif
943 pMsg = (uint32_t *) pSirSmeDisassocRsp;
944 break;
945
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530946 case eLIM_PEER_ENTITY_DISASSOC:
947 case eLIM_LINK_MONITORING_DISASSOC:
948 sir_sme_dis_ind =
949 qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
950 if (!sir_sme_dis_ind) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530951 pe_err("call to AllocateMemory failed for disconnect indication");
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530952 return;
953 }
954
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530955 pe_debug("send eWNI_SME_DISCONNECT_DONE_IND with retCode: %d",
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530956 reasonCode);
957
958 sir_sme_dis_ind->message_type =
959 eWNI_SME_DISCONNECT_DONE_IND;
960 sir_sme_dis_ind->length =
961 sizeof(*sir_sme_dis_ind);
962 qdf_mem_copy(sir_sme_dis_ind->peer_mac, peerMacAddr,
963 sizeof(tSirMacAddr));
964 sir_sme_dis_ind->session_id = smesessionId;
965 sir_sme_dis_ind->reason_code = reasonCode;
Selvaraj, Sridharc7d80892016-09-29 11:56:45 +0530966 /*
967 * Instead of sending deauth reason code as 505 which is
968 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
969 * Send reason code as zero to Supplicant
970 */
971 if (reasonCode == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
972 sir_sme_dis_ind->reason_code = 0;
973 else
974 sir_sme_dis_ind->reason_code = reasonCode;
975
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +0530976 pMsg = (uint32_t *)sir_sme_dis_ind;
977
978 break;
979
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800980 default:
981 /**
982 * Disassociation indication due to Disassociation
983 * frame reception from peer entity or due to
984 * loss of link with peer entity.
985 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530986 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800987 if (NULL == pSirSmeDisassocInd) {
988 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530989 pe_err("Memory allocation failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800990 failure = true;
991 goto error;
992 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +0530993 pe_debug("send eWNI_SME_DISASSOC_IND with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800994 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
995 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
996 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
997
998 /* Update SME session Id and Transaction Id */
999 pSirSmeDisassocInd->sessionId = smesessionId;
1000 pSirSmeDisassocInd->transactionId = smetransactionId;
1001 pSirSmeDisassocInd->reasonCode = reasonCode;
1002 pBuf = (uint8_t *) &pSirSmeDisassocInd->statusCode;
1003
1004 lim_copy_u32(pBuf, reasonCode);
1005 pBuf += sizeof(tSirResultCodes);
1006
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301007 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001008 pBuf += sizeof(tSirMacAddr);
1009
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301010 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001011
1012#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1013 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT,
1014 psessionEntry, (uint16_t) reasonCode, 0);
1015#endif
1016 pMsg = (uint32_t *) pSirSmeDisassocInd;
1017
1018 break;
1019 }
1020
1021error:
1022 /* Delete the PE session Created */
Rajeev Kumarcf835a02016-04-15 15:01:31 -07001023 if ((psessionEntry != NULL) && LIM_IS_STA_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001024 pe_delete_session(pMac, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001025
1026 if (false == failure)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301027 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001028 (uint32_t *) pMsg);
1029} /*** end lim_send_sme_disassoc_ntf() ***/
1030
1031/** -----------------------------------------------------------------
1032 \brief lim_send_sme_disassoc_ind() - sends SME_DISASSOC_IND
1033
1034 After receiving disassociation frame from peer entity, this
1035 function sends a eWNI_SME_DISASSOC_IND to SME with a specific
1036 reason code.
1037
1038 \param pMac - global mac structure
1039 \param pStaDs - station dph hash node
1040 \return none
1041 \sa
1042 ----------------------------------------------------------------- */
1043void
1044lim_send_sme_disassoc_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1045 tpPESession psessionEntry)
1046{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001047 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001048 tSirSmeDisassocInd *pSirSmeDisassocInd;
1049
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301050 pSirSmeDisassocInd = qdf_mem_malloc(sizeof(tSirSmeDisassocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001051 if (NULL == pSirSmeDisassocInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301052 pe_err("AllocateMemory failed for eWNI_SME_DISASSOC_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001053 return;
1054 }
1055
1056 pSirSmeDisassocInd->messageType = eWNI_SME_DISASSOC_IND;
1057 pSirSmeDisassocInd->length = sizeof(tSirSmeDisassocInd);
1058
1059 pSirSmeDisassocInd->sessionId = psessionEntry->smeSessionId;
1060 pSirSmeDisassocInd->transactionId = psessionEntry->transactionId;
Padma, Santhosh Kumar02289212016-09-30 13:30:08 +05301061 pSirSmeDisassocInd->statusCode = eSIR_SME_DEAUTH_STATUS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001062 pSirSmeDisassocInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1063
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301064 qdf_mem_copy(pSirSmeDisassocInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301065 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001066
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301067 qdf_mem_copy(pSirSmeDisassocInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301068 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001069
1070 pSirSmeDisassocInd->staId = pStaDs->staIndex;
1071
1072 mmhMsg.type = eWNI_SME_DISASSOC_IND;
1073 mmhMsg.bodyptr = pSirSmeDisassocInd;
1074 mmhMsg.bodyval = 0;
1075
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301076 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1077 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001078#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1079 lim_diag_event_report(pMac, WLAN_PE_DIAG_DISASSOC_IND_EVENT, psessionEntry,
1080 0, (uint16_t) pStaDs->mlmStaContext.disassocReason);
1081#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1082
1083 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1084
1085} /*** end lim_send_sme_disassoc_ind() ***/
1086
1087/** -----------------------------------------------------------------
1088 \brief lim_send_sme_deauth_ind() - sends SME_DEAUTH_IND
1089
1090 After receiving deauthentication frame from peer entity, this
1091 function sends a eWNI_SME_DEAUTH_IND to SME with a specific
1092 reason code.
1093
1094 \param pMac - global mac structure
1095 \param pStaDs - station dph hash node
1096 \return none
1097 \sa
1098 ----------------------------------------------------------------- */
1099void
1100lim_send_sme_deauth_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1101 tpPESession psessionEntry)
1102{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001103 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001104 tSirSmeDeauthInd *pSirSmeDeauthInd;
1105
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301106 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001107 if (NULL == pSirSmeDeauthInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301108 pe_err("AllocateMemory failed for eWNI_SME_DEAUTH_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001109 return;
1110 }
1111
1112 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1113 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1114
1115 pSirSmeDeauthInd->sessionId = psessionEntry->smeSessionId;
1116 pSirSmeDeauthInd->transactionId = psessionEntry->transactionId;
1117 if (eSIR_INFRA_AP_MODE == psessionEntry->bssType) {
1118 pSirSmeDeauthInd->statusCode =
1119 (tSirResultCodes) pStaDs->mlmStaContext.cleanupTrigger;
1120 } else {
1121 /* Need to indicatet he reascon code over the air */
1122 pSirSmeDeauthInd->statusCode =
1123 (tSirResultCodes) pStaDs->mlmStaContext.disassocReason;
1124 }
1125 /* BSSID */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301126 qdf_mem_copy(pSirSmeDeauthInd->bssid.bytes, psessionEntry->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301127 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001128 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301129 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301130 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001131 pSirSmeDeauthInd->reasonCode = pStaDs->mlmStaContext.disassocReason;
1132
1133 pSirSmeDeauthInd->staId = pStaDs->staIndex;
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001134 if (eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON ==
1135 pStaDs->mlmStaContext.disassocReason)
1136 pSirSmeDeauthInd->rssi = pStaDs->del_sta_ctx_rssi;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001137
1138 mmhMsg.type = eWNI_SME_DEAUTH_IND;
1139 mmhMsg.bodyptr = pSirSmeDeauthInd;
1140 mmhMsg.bodyval = 0;
1141
1142 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1143#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1144 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT, psessionEntry,
1145 0, pStaDs->mlmStaContext.cleanupTrigger);
1146#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1147
1148 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1149 return;
1150} /*** end lim_send_sme_deauth_ind() ***/
1151
1152#ifdef FEATURE_WLAN_TDLS
1153/**
1154 * lim_send_sme_tdls_del_sta_ind()
1155 *
1156 ***FUNCTION:
1157 * This function is called to send the TDLS STA context deletion to SME.
1158 *
1159 ***LOGIC:
1160 *
1161 ***ASSUMPTIONS:
1162 *
1163 ***NOTE:
1164 * NA
1165 *
1166 * @param pMac - Pointer to global MAC structure
1167 * @param pStaDs - Pointer to internal STA Datastructure
1168 * @param psessionEntry - Pointer to the session entry
1169 * @param reasonCode - Reason for TDLS sta deletion
1170 * @return None
1171 */
1172void
1173lim_send_sme_tdls_del_sta_ind(tpAniSirGlobal pMac, tpDphHashNode pStaDs,
1174 tpPESession psessionEntry, uint16_t reasonCode)
1175{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001176 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001177 tSirTdlsDelStaInd *pSirTdlsDelStaInd;
1178
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301179 pSirTdlsDelStaInd = qdf_mem_malloc(sizeof(tSirTdlsDelStaInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001180 if (NULL == pSirTdlsDelStaInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301181 pe_err("AllocateMemory failed for eWNI_SME_TDLS_DEL_STA_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001182 return;
1183 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301184 pe_debug("Delete TDLS Peer "MAC_ADDRESS_STR "with reason code: %d",
Nitesh Shah82c52812016-12-27 12:27:51 +05301185 MAC_ADDR_ARRAY(pStaDs->staAddr), reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001186 /* messageType */
1187 pSirTdlsDelStaInd->messageType = eWNI_SME_TDLS_DEL_STA_IND;
1188 pSirTdlsDelStaInd->length = sizeof(tSirTdlsDelStaInd);
1189
1190 /* sessionId */
1191 pSirTdlsDelStaInd->sessionId = psessionEntry->smeSessionId;
1192
1193 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301194 qdf_mem_copy(pSirTdlsDelStaInd->peermac.bytes, pStaDs->staAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301195 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001196
1197 /* staId */
1198 lim_copy_u16((uint8_t *) (&pSirTdlsDelStaInd->staId),
1199 (uint16_t) pStaDs->staIndex);
1200
1201 /* reasonCode */
1202 lim_copy_u16((uint8_t *) (&pSirTdlsDelStaInd->reasonCode), reasonCode);
1203
1204 mmhMsg.type = eWNI_SME_TDLS_DEL_STA_IND;
1205 mmhMsg.bodyptr = pSirTdlsDelStaInd;
1206 mmhMsg.bodyval = 0;
1207
1208 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1209 return;
1210} /*** end lim_send_sme_tdls_del_sta_ind() ***/
1211
1212/**
1213 * lim_send_sme_tdls_delete_all_peer_ind()
1214 *
1215 ***FUNCTION:
1216 * This function is called to send the eWNI_SME_TDLS_DEL_ALL_PEER_IND
1217 * message to SME.
1218 *
1219 ***LOGIC:
1220 *
1221 ***ASSUMPTIONS:
1222 *
1223 ***NOTE:
1224 * NA
1225 *
1226 * @param pMac - Pointer to global MAC structure
1227 * @param psessionEntry - Pointer to the session entry
1228 * @return None
1229 */
1230void
1231lim_send_sme_tdls_delete_all_peer_ind(tpAniSirGlobal pMac, tpPESession psessionEntry)
1232{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001233 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001234 tSirTdlsDelAllPeerInd *pSirTdlsDelAllPeerInd;
1235
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301236 pSirTdlsDelAllPeerInd = qdf_mem_malloc(sizeof(tSirTdlsDelAllPeerInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001237 if (NULL == pSirTdlsDelAllPeerInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301238 pe_err("AllocateMemory failed for eWNI_SME_TDLS_DEL_ALL_PEER_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001239 return;
1240 }
1241 /* messageType */
1242 pSirTdlsDelAllPeerInd->messageType = eWNI_SME_TDLS_DEL_ALL_PEER_IND;
1243 pSirTdlsDelAllPeerInd->length = sizeof(tSirTdlsDelAllPeerInd);
1244
1245 /* sessionId */
1246 pSirTdlsDelAllPeerInd->sessionId = psessionEntry->smeSessionId;
1247
1248 mmhMsg.type = eWNI_SME_TDLS_DEL_ALL_PEER_IND;
1249 mmhMsg.bodyptr = pSirTdlsDelAllPeerInd;
1250 mmhMsg.bodyval = 0;
1251
1252 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1253 return;
1254} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1255
1256/**
1257 * lim_send_sme_mgmt_tx_completion()
1258 *
1259 ***FUNCTION:
1260 * This function is called to send the eWNI_SME_MGMT_FRM_TX_COMPLETION_IND
1261 * message to SME.
1262 *
1263 ***LOGIC:
1264 *
1265 ***ASSUMPTIONS:
1266 *
1267 ***NOTE:
1268 * NA
1269 *
1270 * @param pMac - Pointer to global MAC structure
1271 * @param psessionEntry - Pointer to the session entry
1272 * @param txCompleteStatus - TX Complete Status of Mgmt Frames
1273 * @return None
1274 */
1275void
1276lim_send_sme_mgmt_tx_completion(tpAniSirGlobal pMac,
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301277 uint32_t sme_session_id,
1278 uint32_t txCompleteStatus)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001279{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001280 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001281 tSirMgmtTxCompletionInd *pSirMgmtTxCompletionInd;
1282
1283 pSirMgmtTxCompletionInd =
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301284 qdf_mem_malloc(sizeof(tSirMgmtTxCompletionInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001285 if (NULL == pSirMgmtTxCompletionInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301286 pe_err("AllocateMemory failed for eWNI_SME_MGMT_FRM_TX_COMPLETION_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001287 return;
1288 }
1289 /* messageType */
1290 pSirMgmtTxCompletionInd->messageType =
1291 eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1292 pSirMgmtTxCompletionInd->length = sizeof(tSirMgmtTxCompletionInd);
1293
1294 /* sessionId */
Ganesh Kondabattiniac570072016-12-21 12:45:48 +05301295 pSirMgmtTxCompletionInd->sessionId = sme_session_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001296
1297 pSirMgmtTxCompletionInd->txCompleteStatus = txCompleteStatus;
1298
1299 mmhMsg.type = eWNI_SME_MGMT_FRM_TX_COMPLETION_IND;
1300 mmhMsg.bodyptr = pSirMgmtTxCompletionInd;
1301 mmhMsg.bodyval = 0;
1302
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07001303#ifdef CONVERGED_TDLS_ENABLE
1304 pSirMgmtTxCompletionInd->psoc = pMac->psoc;
1305 mmhMsg.callback = tgt_tdls_send_mgmt_tx_completion;
1306 scheduler_post_msg(QDF_MODULE_ID_TARGET_IF, &mmhMsg);
1307 return;
1308#else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001309 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1310 return;
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07001311#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001312} /*** end lim_send_sme_tdls_delete_all_peer_ind() ***/
1313
1314void lim_send_sme_tdls_event_notify(tpAniSirGlobal pMac, uint16_t msgType,
1315 void *events)
1316{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001317 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001318
1319 switch (msgType) {
1320 case SIR_HAL_TDLS_SHOULD_DISCOVER:
1321 mmhMsg.type = eWNI_SME_TDLS_SHOULD_DISCOVER;
1322 break;
1323 case SIR_HAL_TDLS_SHOULD_TEARDOWN:
1324 mmhMsg.type = eWNI_SME_TDLS_SHOULD_TEARDOWN;
1325 break;
1326 case SIR_HAL_TDLS_PEER_DISCONNECTED:
1327 mmhMsg.type = eWNI_SME_TDLS_PEER_DISCONNECTED;
1328 break;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07001329 case SIR_HAL_TDLS_CONNECTION_TRACKER_NOTIFICATION:
1330 mmhMsg.type = eWNI_SME_TDLS_CONNECTION_TRACKER_NOTIFICATION;
1331 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001332 }
1333
1334 mmhMsg.bodyptr = events;
1335 mmhMsg.bodyval = 0;
1336 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1337 return;
1338}
1339#endif /* FEATURE_WLAN_TDLS */
1340
1341/**
1342 * lim_send_sme_deauth_ntf()
1343 *
1344 ***FUNCTION:
1345 * This function is called by limProcessSmeMessages() to send
1346 * eWNI_SME_DISASSOC_RSP/IND message to host
1347 *
1348 ***PARAMS:
1349 *
1350 ***LOGIC:
1351 *
1352 ***ASSUMPTIONS:
1353 * NA
1354 *
1355 ***NOTE:
1356 * This function is used for sending eWNI_SME_DEAUTH_CNF or
1357 * eWNI_SME_DEAUTH_IND to host depending on deauthentication trigger.
1358 *
1359 * @param peerMacAddr Indicates the peer MAC addr to which
1360 * deauthentication was initiated
1361 * @param reasonCode Indicates the reason for Deauthetication
1362 * @param deauthTrigger Indicates the trigger for Deauthetication
1363 * @param aid Indicates the STAID. This parameter is present
1364 * only on AP.
1365 *
1366 * @return None
1367 */
1368void
1369lim_send_sme_deauth_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
1370 tSirResultCodes reasonCode, uint16_t deauthTrigger,
1371 uint16_t aid, uint8_t smesessionId,
1372 uint16_t smetransactionId)
1373{
1374 uint8_t *pBuf;
1375 tSirSmeDeauthRsp *pSirSmeDeauthRsp;
1376 tSirSmeDeauthInd *pSirSmeDeauthInd;
1377 tpPESession psessionEntry;
1378 uint8_t sessionId;
1379 uint32_t *pMsg;
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301380 struct sir_sme_discon_done_ind *sir_sme_dis_ind;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001381
1382 psessionEntry = pe_find_session_by_bssid(pMac, peerMacAddr, &sessionId);
1383 switch (deauthTrigger) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001384 case eLIM_HOST_DEAUTH:
1385 /**
1386 * Deauthentication response to host triggered
1387 * deauthentication.
1388 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301389 pSirSmeDeauthRsp = qdf_mem_malloc(sizeof(tSirSmeDeauthRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001390 if (NULL == pSirSmeDeauthRsp) {
1391 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301392 pe_err("call to AllocateMemory failed for eWNI_SME_DEAUTH_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001393 return;
1394 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301395 pe_debug("send eWNI_SME_DEAUTH_RSP with retCode: %d for" MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001396 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1397 pSirSmeDeauthRsp->messageType = eWNI_SME_DEAUTH_RSP;
1398 pSirSmeDeauthRsp->length = sizeof(tSirSmeDeauthRsp);
1399 pSirSmeDeauthRsp->statusCode = reasonCode;
1400 pSirSmeDeauthRsp->sessionId = smesessionId;
1401 pSirSmeDeauthRsp->transactionId = smetransactionId;
1402
Srinivas Girigowda9cf95c52016-01-04 16:17:15 -08001403 pBuf = (uint8_t *) pSirSmeDeauthRsp->peer_macaddr.bytes;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301404 qdf_mem_copy(pBuf, peerMacAddr, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001405
1406#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1407 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_RSP_EVENT,
1408 psessionEntry, 0, (uint16_t) reasonCode);
1409#endif
1410 pMsg = (uint32_t *) pSirSmeDeauthRsp;
1411
1412 break;
1413
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301414 case eLIM_PEER_ENTITY_DEAUTH:
1415 case eLIM_LINK_MONITORING_DEAUTH:
1416 sir_sme_dis_ind =
1417 qdf_mem_malloc(sizeof(*sir_sme_dis_ind));
1418 if (!sir_sme_dis_ind) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301419 pe_err("call to AllocateMemory failed for disconnect indication");
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301420 return;
1421 }
1422
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301423 pe_debug("send eWNI_SME_DISCONNECT_DONE_IND withretCode: %d",
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301424 reasonCode);
1425
1426 sir_sme_dis_ind->message_type =
1427 eWNI_SME_DISCONNECT_DONE_IND;
1428 sir_sme_dis_ind->length =
1429 sizeof(*sir_sme_dis_ind);
1430 sir_sme_dis_ind->session_id = smesessionId;
1431 sir_sme_dis_ind->reason_code = reasonCode;
1432 qdf_mem_copy(sir_sme_dis_ind->peer_mac, peerMacAddr,
1433 ETH_ALEN);
Selvaraj, Sridharc7d80892016-09-29 11:56:45 +05301434 /*
1435 * Instead of sending deauth reason code as 505 which is
1436 * internal value(eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1437 * Send reason code as zero to Supplicant
1438 */
1439 if (reasonCode == eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE)
1440 sir_sme_dis_ind->reason_code = 0;
1441 else
1442 sir_sme_dis_ind->reason_code = reasonCode;
1443
Hanumantha Reddy Pothula3e5d6aa2016-09-08 15:21:54 +05301444 pMsg = (uint32_t *)sir_sme_dis_ind;
1445
1446 break;
1447
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001448 default:
1449 /**
1450 * Deauthentication indication due to Deauthentication
1451 * frame reception from peer entity or due to
1452 * loss of link with peer entity.
1453 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301454 pSirSmeDeauthInd = qdf_mem_malloc(sizeof(tSirSmeDeauthInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001455 if (NULL == pSirSmeDeauthInd) {
1456 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301457 pe_err("call to AllocateMemory failed for eWNI_SME_DEAUTH_Ind");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001458 return;
1459 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301460 pe_debug("send eWNI_SME_DEAUTH_IND with retCode: %d for " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001461 reasonCode, MAC_ADDR_ARRAY(peerMacAddr));
1462 pSirSmeDeauthInd->messageType = eWNI_SME_DEAUTH_IND;
1463 pSirSmeDeauthInd->length = sizeof(tSirSmeDeauthInd);
1464 pSirSmeDeauthInd->reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
1465
1466 /* sessionId */
1467 pBuf = (uint8_t *) &pSirSmeDeauthInd->sessionId;
1468 *pBuf++ = smesessionId;
1469
1470 /* transaction ID */
1471 lim_copy_u16(pBuf, smetransactionId);
1472 pBuf += sizeof(uint16_t);
1473
1474 /* status code */
1475 lim_copy_u32(pBuf, reasonCode);
1476 pBuf += sizeof(tSirResultCodes);
1477
1478 /* bssId */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301479 qdf_mem_copy(pBuf, psessionEntry->bssId, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001480 pBuf += sizeof(tSirMacAddr);
1481
1482 /* peerMacAddr */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301483 qdf_mem_copy(pSirSmeDeauthInd->peer_macaddr.bytes, peerMacAddr,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301484 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001485
1486#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1487 lim_diag_event_report(pMac, WLAN_PE_DIAG_DEAUTH_IND_EVENT,
1488 psessionEntry, 0, (uint16_t) reasonCode);
1489#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1490 pMsg = (uint32_t *) pSirSmeDeauthInd;
1491
1492 break;
1493 }
1494
1495 /*Delete the PE session created */
1496 if (psessionEntry != NULL) {
1497 pe_delete_session(pMac, psessionEntry);
1498 }
1499
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301500 lim_send_sme_disassoc_deauth_ntf(pMac, QDF_STATUS_SUCCESS,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001501 (uint32_t *) pMsg);
1502
1503} /*** end lim_send_sme_deauth_ntf() ***/
1504
1505/**
1506 * lim_send_sme_wm_status_change_ntf() - Send Notification
1507 * @mac_ctx: Global MAC Context
1508 * @status_change_code: Indicates the change in the wireless medium.
1509 * @status_change_info: Indicates the information associated with
1510 * change in the wireless medium.
1511 * @info_len: Indicates the length of status change information
1512 * being sent.
1513 * @session_id SessionID
1514 *
1515 * This function is called by limProcessSmeMessages() to send
1516 * eWNI_SME_WM_STATUS_CHANGE_NTF message to host.
1517 *
1518 * Return: None
1519 */
1520void
1521lim_send_sme_wm_status_change_ntf(tpAniSirGlobal mac_ctx,
1522 tSirSmeStatusChangeCode status_change_code,
1523 uint32_t *status_change_info, uint16_t info_len, uint8_t session_id)
1524{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001525 struct scheduler_msg msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001526 tSirSmeWmStatusChangeNtf *wm_status_change_ntf;
Naveen Rawate01ed172016-11-17 11:34:50 -08001527 uint32_t max_info_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001528
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301529 wm_status_change_ntf = qdf_mem_malloc(sizeof(tSirSmeWmStatusChangeNtf));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001530 if (NULL == wm_status_change_ntf) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301531 pe_err("Mem Alloc failed - eWNI_SME_WM_STATUS_CHANGE_NTF");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001532 return;
1533 }
1534
1535 msg.type = eWNI_SME_WM_STATUS_CHANGE_NTF;
1536 msg.bodyval = 0;
1537 msg.bodyptr = wm_status_change_ntf;
1538
1539 switch (status_change_code) {
Naveen Rawate01ed172016-11-17 11:34:50 -08001540 case eSIR_SME_AP_CAPS_CHANGED:
1541 max_info_len = sizeof(tSirSmeApNewCaps);
1542 break;
1543 case eSIR_SME_JOINED_NEW_BSS:
1544 max_info_len = sizeof(tSirSmeNewBssInfo);
1545 break;
1546 default:
1547 max_info_len = sizeof(wm_status_change_ntf->statusChangeInfo);
1548 break;
1549 }
1550
1551 switch (status_change_code) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001552 case eSIR_SME_RADAR_DETECTED:
1553 break;
1554 default:
1555 wm_status_change_ntf->messageType =
1556 eWNI_SME_WM_STATUS_CHANGE_NTF;
1557 wm_status_change_ntf->statusChangeCode = status_change_code;
1558 wm_status_change_ntf->length = sizeof(tSirSmeWmStatusChangeNtf);
1559 wm_status_change_ntf->sessionId = session_id;
Naveen Rawate01ed172016-11-17 11:34:50 -08001560 if (info_len <= max_info_len && status_change_info) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301561 qdf_mem_copy(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001562 (uint8_t *) &wm_status_change_ntf->statusChangeInfo,
1563 (uint8_t *) status_change_info, info_len);
1564 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301565 pe_debug("StatusChg code: 0x%x length: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001566 status_change_code, info_len);
1567 break;
1568 }
1569
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301570 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TX_SME_MSG, session_id, msg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001571 if (eSIR_SUCCESS != lim_sys_process_mmh_msg_api(mac_ctx, &msg, ePROT)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301572 qdf_mem_free(wm_status_change_ntf);
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301573 pe_err("lim_sys_process_mmh_msg_api failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001574 }
1575
1576} /*** end lim_send_sme_wm_status_change_ntf() ***/
1577
1578/**
1579 * lim_send_sme_set_context_rsp()
1580 *
1581 ***FUNCTION:
1582 * This function is called by limProcessSmeMessages() to send
1583 * eWNI_SME_SETCONTEXT_RSP message to host
1584 *
1585 ***PARAMS:
1586 *
1587 ***LOGIC:
1588 *
1589 ***ASSUMPTIONS:
1590 * NA
1591 *
1592 ***NOTE:
1593 *
1594 * @param pMac Pointer to Global MAC structure
1595 * @param peerMacAddr Indicates the peer MAC addr to which
1596 * setContext was performed
1597 * @param aid Indicates the aid corresponding to the peer MAC
1598 * address
1599 * @param resultCode Indicates the result of previously issued
1600 * eWNI_SME_SETCONTEXT_RSP message
1601 *
1602 * @return None
1603 */
1604void
1605lim_send_sme_set_context_rsp(tpAniSirGlobal pMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301606 struct qdf_mac_addr peer_macaddr, uint16_t aid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001607 tSirResultCodes resultCode,
1608 tpPESession psessionEntry, uint8_t smesessionId,
1609 uint16_t smetransactionId)
1610{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001611 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001612 tSirSmeSetContextRsp *pSirSmeSetContextRsp;
1613
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301614 pSirSmeSetContextRsp = qdf_mem_malloc(sizeof(tSirSmeSetContextRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001615 if (NULL == pSirSmeSetContextRsp) {
1616 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301617 pe_err("call to AllocateMemory failed for SmeSetContextRsp");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001618 return;
1619 }
1620
1621 pSirSmeSetContextRsp->messageType = eWNI_SME_SETCONTEXT_RSP;
1622 pSirSmeSetContextRsp->length = sizeof(tSirSmeSetContextRsp);
1623 pSirSmeSetContextRsp->statusCode = resultCode;
1624
Anurag Chouhanc5548422016-02-24 18:33:27 +05301625 qdf_copy_macaddr(&pSirSmeSetContextRsp->peer_macaddr, &peer_macaddr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001626
1627 /* Update SME session and transaction Id */
1628 pSirSmeSetContextRsp->sessionId = smesessionId;
1629 pSirSmeSetContextRsp->transactionId = smetransactionId;
1630
1631 mmhMsg.type = eWNI_SME_SETCONTEXT_RSP;
1632 mmhMsg.bodyptr = pSirSmeSetContextRsp;
1633 mmhMsg.bodyval = 0;
1634 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301635 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1636 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001637 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301638 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1639 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001640 }
1641
1642#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1643 lim_diag_event_report(pMac, WLAN_PE_DIAG_SETCONTEXT_RSP_EVENT,
1644 psessionEntry, (uint16_t) resultCode, 0);
1645#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1646
1647 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1648} /*** end lim_send_sme_set_context_rsp() ***/
1649
1650/**
1651 * lim_send_sme_neighbor_bss_ind()
1652 *
1653 ***FUNCTION:
1654 * This function is called by lim_lookup_nadd_hash_entry() to send
1655 * eWNI_SME_NEIGHBOR_BSS_IND message to host
1656 *
1657 ***PARAMS:
1658 *
1659 ***LOGIC:
1660 *
1661 ***ASSUMPTIONS:
1662 * NA
1663 *
1664 ***NOTE:
1665 * This function is used for sending eWNI_SME_NEIGHBOR_BSS_IND to
1666 * host upon detecting new BSS during background scanning if CFG
1667 * option is enabled for sending such indication
1668 *
1669 * @param pMac - Pointer to Global MAC structure
1670 * @return None
1671 */
1672
1673void
1674lim_send_sme_neighbor_bss_ind(tpAniSirGlobal pMac, tLimScanResultNode *pBssDescr)
1675{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001676 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001677 uint32_t val;
1678 tSirSmeNeighborBssInd *pNewBssInd;
1679
1680 if ((pMac->lim.gLimSmeState != eLIM_SME_LINK_EST_WT_SCAN_STATE) ||
1681 ((pMac->lim.gLimSmeState == eLIM_SME_LINK_EST_WT_SCAN_STATE) &&
1682 pMac->lim.gLimRspReqd)) {
1683 /* LIM is not in background scan state OR */
1684 /* current scan is initiated by HDD. */
1685 /* No need to send new BSS indication to HDD */
1686 return;
1687 }
1688
1689 if (wlan_cfg_get_int(pMac, WNI_CFG_NEW_BSS_FOUND_IND, &val) !=
1690 eSIR_SUCCESS) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301691 pe_err("could not get NEIGHBOR_BSS_IND from CFG");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001692 return;
1693 }
1694
1695 if (val == 0)
1696 return;
1697
1698 /**
1699 * Need to indicate new BSSs found during
1700 * background scanning to host.
1701 * Allocate buffer for sending indication.
1702 * Length of buffer is length of BSS description
1703 * and length of header itself
1704 */
1705 val = pBssDescr->bssDescription.length + sizeof(uint16_t) +
1706 sizeof(uint32_t) + sizeof(uint8_t);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301707 pNewBssInd = qdf_mem_malloc(val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001708 if (NULL == pNewBssInd) {
1709 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301710 pe_err("call to AllocateMemory failed for eWNI_SME_NEIGHBOR_BSS_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001711 return;
1712 }
1713
1714 pNewBssInd->messageType = eWNI_SME_NEIGHBOR_BSS_IND;
1715 pNewBssInd->length = (uint16_t) val;
1716 pNewBssInd->sessionId = 0;
1717
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301718 qdf_mem_copy((uint8_t *) pNewBssInd->bssDescription,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001719 (uint8_t *) &pBssDescr->bssDescription,
1720 pBssDescr->bssDescription.length + sizeof(uint16_t));
1721
1722 msgQ.type = eWNI_SME_NEIGHBOR_BSS_IND;
1723 msgQ.bodyptr = pNewBssInd;
1724 msgQ.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301725 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, msgQ.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001726 lim_sys_process_mmh_msg_api(pMac, &msgQ, ePROT);
1727} /*** end lim_send_sme_neighbor_bss_ind() ***/
1728
1729/** -----------------------------------------------------------------
1730 \brief lim_send_sme_addts_rsp() - sends SME ADDTS RSP
1731 \ This function sends a eWNI_SME_ADDTS_RSP to SME.
1732 \ SME only looks at rc and tspec field.
1733 \param pMac - global mac structure
1734 \param rspReqd - is SmeAddTsRsp required
1735 \param status - status code of SME_ADD_TS_RSP
1736 \return tspec
1737 \sa
1738 ----------------------------------------------------------------- */
1739void
1740lim_send_sme_addts_rsp(tpAniSirGlobal pMac, uint8_t rspReqd, uint32_t status,
1741 tpPESession psessionEntry, tSirMacTspecIE tspec,
1742 uint8_t smesessionId, uint16_t smetransactionId)
1743{
1744 tpSirAddtsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001745 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001746
1747 if (!rspReqd)
1748 return;
1749
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301750 rsp = qdf_mem_malloc(sizeof(tSirAddtsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001751 if (NULL == rsp) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301752 pe_err("AllocateMemory failed for ADDTS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001753 return;
1754 }
1755
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001756 rsp->messageType = eWNI_SME_ADDTS_RSP;
1757 rsp->rc = status;
1758 rsp->rsp.status = (enum eSirMacStatusCodes)status;
1759 rsp->rsp.tspec = tspec;
1760 /* Update SME session Id and transcation Id */
1761 rsp->sessionId = smesessionId;
1762 rsp->transactionId = smetransactionId;
1763
1764 mmhMsg.type = eWNI_SME_ADDTS_RSP;
1765 mmhMsg.bodyptr = rsp;
1766 mmhMsg.bodyval = 0;
1767 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301768 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1769 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001770 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301771 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1772 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001773 }
1774#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1775 lim_diag_event_report(pMac, WLAN_PE_DIAG_ADDTS_RSP_EVENT, psessionEntry, 0,
1776 0);
1777#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1778
1779 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1780 return;
1781}
1782
1783void
1784lim_send_sme_delts_rsp(tpAniSirGlobal pMac, tpSirDeltsReq delts, uint32_t status,
1785 tpPESession psessionEntry, uint8_t smesessionId,
1786 uint16_t smetransactionId)
1787{
1788 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001789 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001790
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301791 pe_debug("SendSmeDeltsRsp aid: %d tsid: %d up: %d status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001792 delts->aid,
1793 delts->req.tsinfo.traffic.tsid,
1794 delts->req.tsinfo.traffic.userPrio, status);
1795 if (!delts->rspReqd)
1796 return;
1797
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301798 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001799 if (NULL == rsp) {
1800 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301801 pe_err("AllocateMemory failed for DELTS_RSP");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001802 return;
1803 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001804
1805 if (psessionEntry != NULL) {
1806
1807 rsp->aid = delts->aid;
Anurag Chouhanc5548422016-02-24 18:33:27 +05301808 qdf_copy_macaddr(&rsp->macaddr, &delts->macaddr);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301809 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) &delts->req,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001810 sizeof(tSirDeltsReqInfo));
1811 }
1812
1813 rsp->messageType = eWNI_SME_DELTS_RSP;
1814 rsp->rc = status;
1815
1816 /* Update SME session Id and transcation Id */
1817 rsp->sessionId = smesessionId;
1818 rsp->transactionId = smetransactionId;
1819
1820 mmhMsg.type = eWNI_SME_DELTS_RSP;
1821 mmhMsg.bodyptr = rsp;
1822 mmhMsg.bodyval = 0;
1823 if (NULL == psessionEntry) {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301824 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1825 NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001826 } else {
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301827 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
1828 psessionEntry->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829 }
1830#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1831 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_RSP_EVENT, psessionEntry,
1832 (uint16_t) status, 0);
1833#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1834
1835 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1836}
1837
1838void
1839lim_send_sme_delts_ind(tpAniSirGlobal pMac, tpSirDeltsReqInfo delts, uint16_t aid,
1840 tpPESession psessionEntry)
1841{
1842 tpSirDeltsRsp rsp;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001843 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001844
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301845 pe_debug("SendSmeDeltsInd aid: %d tsid: %d up: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001846 aid, delts->tsinfo.traffic.tsid, delts->tsinfo.traffic.userPrio);
1847
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301848 rsp = qdf_mem_malloc(sizeof(tSirDeltsRsp));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001849 if (NULL == rsp) {
1850 /* Log error */
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301851 pe_err("AllocateMemory failed for DELTS_IND");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001852 return;
1853 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001854
1855 rsp->messageType = eWNI_SME_DELTS_IND;
1856 rsp->rc = eSIR_SUCCESS;
1857 rsp->aid = aid;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301858 qdf_mem_copy((uint8_t *) &rsp->rsp, (uint8_t *) delts, sizeof(*delts));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001859
1860 /* Update SME session Id and SME transaction Id */
1861
1862 rsp->sessionId = psessionEntry->smeSessionId;
1863 rsp->transactionId = psessionEntry->transactionId;
1864
1865 mmhMsg.type = eWNI_SME_DELTS_IND;
1866 mmhMsg.bodyptr = rsp;
1867 mmhMsg.bodyval = 0;
1868 MTRACE(mac_trace_msg_tx(pMac, psessionEntry->peSessionId, mmhMsg.type));
1869#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM /* FEATURE_WLAN_DIAG_SUPPORT */
1870 lim_diag_event_report(pMac, WLAN_PE_DIAG_DELTS_IND_EVENT, psessionEntry, 0,
1871 0);
1872#endif /* FEATURE_WLAN_DIAG_SUPPORT */
1873
1874 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1875}
1876
1877/**
1878 * lim_send_sme_pe_statistics_rsp()
1879 *
1880 ***FUNCTION:
1881 * This function is called to send 802.11 statistics response to HDD.
1882 * This function posts the result back to HDD. This is a response to
1883 * HDD's request for statistics.
1884 *
1885 ***PARAMS:
1886 *
1887 ***LOGIC:
1888 *
1889 ***ASSUMPTIONS:
1890 * NA
1891 *
1892 ***NOTE:
1893 * NA
1894 *
1895 * @param pMac Pointer to Global MAC structure
1896 * @param p80211Stats Statistics sent in response
1897 * @param resultCode TODO:
1898 *
1899 *
1900 * @return none
1901 */
1902
1903void
1904lim_send_sme_pe_statistics_rsp(tpAniSirGlobal pMac, uint16_t msgType, void *stats)
1905{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001906 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001907 uint8_t sessionId;
1908 tAniGetPEStatsRsp *pPeStats = (tAniGetPEStatsRsp *) stats;
1909 tpPESession pPeSessionEntry;
1910
1911 /* Get the Session Id based on Sta Id */
1912 pPeSessionEntry =
1913 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1914
1915 /* Fill the Session Id */
1916 if (NULL != pPeSessionEntry) {
1917 /* Fill the Session Id */
1918 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1919 }
1920
1921 pPeStats->msgType = eWNI_SME_GET_STATISTICS_RSP;
1922
1923 /* msgType should be WMA_GET_STATISTICS_RSP */
1924 mmhMsg.type = eWNI_SME_GET_STATISTICS_RSP;
1925
1926 mmhMsg.bodyptr = stats;
1927 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301928 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, NO_SESSION, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001929 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1930
1931 return;
1932
1933} /*** end lim_send_sme_pe_statistics_rsp() ***/
1934
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001935#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001936/**
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001937 * lim_send_sme_pe_ese_tsm_rsp() - send tsm response
1938 * @pMac: Pointer to global pMac structure
1939 * @pStats: Pointer to TSM Stats
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001940 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001941 * This function is called to send tsm stats response to HDD.
1942 * This function posts the result back to HDD. This is a response to
1943 * HDD's request to get tsm stats.
1944 *
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001945 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001946 */
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001947void lim_send_sme_pe_ese_tsm_rsp(tpAniSirGlobal pMac,
1948 tAniGetTsmStatsRsp *pStats)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001949{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001950 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001951 uint8_t sessionId;
1952 tAniGetTsmStatsRsp *pPeStats = (tAniGetTsmStatsRsp *) pStats;
1953 tpPESession pPeSessionEntry = NULL;
1954
1955 /* Get the Session Id based on Sta Id */
1956 pPeSessionEntry =
1957 pe_find_session_by_sta_id(pMac, pPeStats->staId, &sessionId);
1958
1959 /* Fill the Session Id */
1960 if (NULL != pPeSessionEntry) {
1961 /* Fill the Session Id */
1962 pPeStats->sessionId = pPeSessionEntry->smeSessionId;
1963 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05301964 pe_err("Session not found for the Sta id: %d",
Nishank Aggarwald5941bb2017-03-11 14:41:24 +05301965 pPeStats->staId);
Manikandan Mohan41e2d6f2017-04-10 16:17:39 +05301966 qdf_mem_free(pPeStats->tsmStatsReq);
1967 qdf_mem_free(pPeStats);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001968 return;
1969 }
1970
1971 pPeStats->msgType = eWNI_SME_GET_TSM_STATS_RSP;
1972 pPeStats->tsmMetrics.RoamingCount
1973 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingCount;
1974 pPeStats->tsmMetrics.RoamingDly
1975 = pPeSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly;
1976
1977 mmhMsg.type = eWNI_SME_GET_TSM_STATS_RSP;
1978 mmhMsg.bodyptr = pStats;
1979 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05301980 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001981 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
1982
1983 return;
1984} /*** end lim_send_sme_pe_ese_tsm_rsp() ***/
1985
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08001986#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001987
1988void
1989lim_send_sme_ibss_peer_ind(tpAniSirGlobal pMac,
1990 tSirMacAddr peerMacAddr,
1991 uint16_t staIndex,
1992 uint8_t ucastIdx,
1993 uint8_t bcastIdx,
1994 uint8_t *beacon,
1995 uint16_t beaconLen, uint16_t msgType, uint8_t sessionId)
1996{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07001997 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001998 tSmeIbssPeerInd *pNewPeerInd;
1999
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302000 pNewPeerInd = qdf_mem_malloc(sizeof(tSmeIbssPeerInd) + beaconLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002001 if (NULL == pNewPeerInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302002 pe_err("Failed to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002003 return;
2004 }
2005
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302006 qdf_mem_copy((uint8_t *) pNewPeerInd->peer_addr.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302007 peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002008 pNewPeerInd->staId = staIndex;
2009 pNewPeerInd->ucastSig = ucastIdx;
2010 pNewPeerInd->bcastSig = bcastIdx;
2011 pNewPeerInd->mesgLen = sizeof(tSmeIbssPeerInd) + beaconLen;
2012 pNewPeerInd->mesgType = msgType;
2013 pNewPeerInd->sessionId = sessionId;
2014
2015 if (beacon != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302016 qdf_mem_copy((void *)((uint8_t *) pNewPeerInd +
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002017 sizeof(tSmeIbssPeerInd)), (void *)beacon,
2018 beaconLen);
2019 }
2020
2021 mmhMsg.type = msgType;
2022 mmhMsg.bodyptr = pNewPeerInd;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302023 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG, sessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002024 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2025
2026}
2027
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07002028/**
2029 * lim_process_csa_wbw_ie() - Process CSA Wide BW IE
2030 * @mac_ctx: pointer to global adapter context
2031 * @csa_params: pointer to CSA parameters
2032 * @chnl_switch_info:pointer to channel switch parameters
2033 * @session_entry: session pointer
2034 *
2035 * Return: None
2036 */
2037static void lim_process_csa_wbw_ie(tpAniSirGlobal mac_ctx,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002038 struct csa_offload_params *csa_params,
2039 tLimWiderBWChannelSwitchInfo *chnl_switch_info,
2040 tpPESession session_entry)
2041{
Amar Singhal5cccafe2017-02-15 12:42:58 -08002042 struct ch_params ch_params = {0};
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002043 uint8_t ap_new_ch_width;
2044 bool new_ch_width_dfn = false;
2045 uint8_t center_freq_diff;
2046
2047 ap_new_ch_width = csa_params->new_ch_width + 1;
2048 if ((ap_new_ch_width == CH_WIDTH_80MHZ) &&
2049 csa_params->new_ch_freq_seg2) {
2050 new_ch_width_dfn = true;
2051 if (csa_params->new_ch_freq_seg2 >
2052 csa_params->new_ch_freq_seg1)
2053 center_freq_diff = csa_params->new_ch_freq_seg2 -
2054 csa_params->new_ch_freq_seg1;
2055 else
2056 center_freq_diff = csa_params->new_ch_freq_seg1 -
2057 csa_params->new_ch_freq_seg2;
2058 if (center_freq_diff == CENTER_FREQ_DIFF_160MHz)
2059 ap_new_ch_width = CH_WIDTH_160MHZ;
2060 else if (center_freq_diff > CENTER_FREQ_DIFF_80P80MHz)
2061 ap_new_ch_width = CH_WIDTH_80P80MHZ;
2062 else
2063 ap_new_ch_width = CH_WIDTH_80MHZ;
2064 }
2065 session_entry->gLimChannelSwitch.state =
2066 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2067 if ((ap_new_ch_width == CH_WIDTH_160MHZ) &&
2068 !new_ch_width_dfn) {
2069 ch_params.ch_width = CH_WIDTH_160MHZ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002070 wlan_reg_set_channel_params(mac_ctx->pdev,
2071 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002072 ap_new_ch_width = ch_params.ch_width;
2073 csa_params->new_ch_freq_seg1 = ch_params.center_freq_seg0;
2074 csa_params->new_ch_freq_seg2 = ch_params.center_freq_seg1;
2075 }
2076 chnl_switch_info->newChanWidth = ap_new_ch_width;
2077 chnl_switch_info->newCenterChanFreq0 = csa_params->new_ch_freq_seg1;
2078 chnl_switch_info->newCenterChanFreq1 = csa_params->new_ch_freq_seg2;
2079
2080 if (session_entry->ch_width == ap_new_ch_width)
2081 goto prnt_log;
2082
2083 if (session_entry->ch_width == CH_WIDTH_80MHZ) {
2084 chnl_switch_info->newChanWidth = CH_WIDTH_80MHZ;
2085 chnl_switch_info->newCenterChanFreq1 = 0;
2086 } else {
2087 session_entry->ch_width = ap_new_ch_width;
2088 chnl_switch_info->newChanWidth = ap_new_ch_width;
2089 }
2090prnt_log:
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302091 pe_debug("new channel: %d new_ch_width: %d seg0: %d seg1: %d",
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002092 csa_params->channel,
2093 chnl_switch_info->newChanWidth,
2094 chnl_switch_info->newCenterChanFreq0,
2095 chnl_switch_info->newCenterChanFreq1);
2096}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002097/**
2098 * lim_handle_csa_offload_msg() - Handle CSA offload message
2099 * @mac_ctx: pointer to global adapter context
2100 * @msg: Message pointer.
2101 *
2102 * Return: None
2103 */
Rajeev Kumarfeb96382017-01-22 19:42:09 -08002104void lim_handle_csa_offload_msg(tpAniSirGlobal mac_ctx,
2105 struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002106{
2107 tpPESession session_entry;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002108 struct scheduler_msg mmh_msg = {0};
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302109 struct csa_offload_params *csa_params =
2110 (struct csa_offload_params *) (msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002111 tpSmeCsaOffloadInd csa_offload_ind;
2112 tpDphHashNode sta_ds = NULL;
2113 uint8_t session_id;
2114 uint16_t aid = 0;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302115 uint16_t chan_space = 0;
Amar Singhal5cccafe2017-02-15 12:42:58 -08002116 struct ch_params ch_params;
Gupta, Kapil121bf212015-11-25 19:21:29 +05302117
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002118 tLimWiderBWChannelSwitchInfo *chnl_switch_info = NULL;
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002119 tLimChannelSwitchInfo *lim_ch_switch = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002120
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302121 pe_debug("handle csa offload msg");
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302122
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002123 if (!csa_params) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302124 pe_err("limMsgQ body ptr is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002125 return;
2126 }
2127
2128 session_entry =
2129 pe_find_session_by_bssid(mac_ctx,
2130 csa_params->bssId, &session_id);
2131 if (!session_entry) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302132 pe_err("Session does not exists for %pM",
Chandrasekaran, Manishekar5c19dc52016-02-04 14:58:26 +05302133 csa_params->bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002134 goto err;
2135 }
2136
2137 sta_ds = dph_lookup_hash_entry(mac_ctx, session_entry->bssId, &aid,
2138 &session_entry->dph.dphHashTable);
2139
2140 if (!sta_ds) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302141 pe_err("sta_ds does not exist");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002142 goto err;
2143 }
2144
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002145 if (!LIM_IS_STA_ROLE(session_entry)) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302146 pe_debug("Invalid role to handle CSA");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002147 goto err;
2148 }
Masti, Narayanraddi1c630442015-11-02 12:03:50 +05302149
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002150 /*
2151 * on receiving channel switch announcement from AP, delete all
2152 * TDLS peers before leaving BSS and proceed for channel switch
2153 */
2154 lim_delete_tdls_peers(mac_ctx, session_entry);
Gupta, Kapil121bf212015-11-25 19:21:29 +05302155
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002156 lim_ch_switch = &session_entry->gLimChannelSwitch;
2157 session_entry->gLimChannelSwitch.switchMode =
2158 csa_params->switch_mode;
2159 /* timer already started by firmware, switch immediately */
2160 session_entry->gLimChannelSwitch.switchCount = 0;
2161 session_entry->gLimChannelSwitch.primaryChannel =
2162 csa_params->channel;
2163 session_entry->gLimChannelSwitch.state =
2164 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2165 session_entry->gLimChannelSwitch.ch_width = CH_WIDTH_20MHZ;
2166 lim_ch_switch->sec_ch_offset =
2167 session_entry->htSecondaryChannelOffset;
2168 session_entry->gLimChannelSwitch.ch_center_freq_seg0 = 0;
2169 session_entry->gLimChannelSwitch.ch_center_freq_seg1 = 0;
2170 chnl_switch_info =
2171 &session_entry->gLimWiderBWChannelSwitch;
2172
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302173 pe_debug("vht: %d ht: %d flag: %x chan: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302174 session_entry->vhtCapability,
2175 session_entry->htSupportedChannelWidthSet,
2176 csa_params->ies_present_flag,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002177 csa_params->channel);
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302178 pe_debug("seg1: %d seg2: %d width: %d country: %s class: %d",
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002179 csa_params->new_ch_freq_seg1,
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302180 csa_params->new_ch_freq_seg2,
2181 csa_params->new_ch_width,
2182 mac_ctx->scan.countryCodeCurrent,
2183 csa_params->new_op_class);
2184
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002185 if (session_entry->vhtCapability &&
2186 session_entry->htSupportedChannelWidthSet) {
2187 if (csa_params->ies_present_flag & lim_wbw_ie_present) {
Kiran Kumar Lokerefc8feea2016-10-27 17:07:00 -07002188 lim_process_csa_wbw_ie(mac_ctx, csa_params,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002189 chnl_switch_info, session_entry);
2190 lim_ch_switch->sec_ch_offset =
2191 csa_params->sec_chan_offset;
2192 } else if (csa_params->ies_present_flag
2193 & lim_xcsa_ie_present) {
2194 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002195 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002196 mac_ctx->scan.countryCodeCurrent,
2197 csa_params->channel,
2198 csa_params->new_op_class);
2199 session_entry->gLimChannelSwitch.state =
2200 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2201
2202 if (chan_space == 80) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002203 chnl_switch_info->newChanWidth =
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002204 CH_WIDTH_80MHZ;
2205 } else if (chan_space == 40) {
2206 chnl_switch_info->newChanWidth =
2207 CH_WIDTH_40MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002208 } else {
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002209 chnl_switch_info->newChanWidth =
2210 CH_WIDTH_20MHZ;
2211 lim_ch_switch->state =
2212 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2213 }
2214
2215 ch_params.ch_width =
2216 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002217 wlan_reg_set_channel_params(mac_ctx->pdev,
2218 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002219 chnl_switch_info->newCenterChanFreq0 =
2220 ch_params.center_freq_seg0;
2221 /*
2222 * This is not applicable for 20/40/80 MHz.
2223 * Only used when we support 80+80 MHz operation.
2224 * In case of 80+80 MHz, this parameter indicates
2225 * center channel frequency index of 80 MHz
2226 * channel offrequency segment 1.
2227 */
2228 chnl_switch_info->newCenterChanFreq1 =
2229 ch_params.center_freq_seg1;
2230 lim_ch_switch->sec_ch_offset =
2231 ch_params.sec_ch_offset;
2232
2233 }
2234 session_entry->gLimChannelSwitch.ch_center_freq_seg0 =
2235 chnl_switch_info->newCenterChanFreq0;
2236 session_entry->gLimChannelSwitch.ch_center_freq_seg1 =
2237 chnl_switch_info->newCenterChanFreq1;
2238 session_entry->gLimChannelSwitch.ch_width =
2239 chnl_switch_info->newChanWidth;
2240
2241 } else if (session_entry->htSupportedChannelWidthSet) {
2242 if (csa_params->ies_present_flag
2243 & lim_xcsa_ie_present) {
2244 chan_space =
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002245 wlan_reg_dmn_get_chanwidth_from_opclass(
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002246 mac_ctx->scan.countryCodeCurrent,
2247 csa_params->channel,
2248 csa_params->new_op_class);
2249 lim_ch_switch->state =
2250 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2251 if (chan_space == 40) {
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002252 lim_ch_switch->ch_width =
2253 CH_WIDTH_40MHZ;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002254 chnl_switch_info->newChanWidth =
2255 CH_WIDTH_40MHZ;
2256 ch_params.ch_width =
2257 chnl_switch_info->newChanWidth;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002258 wlan_reg_set_channel_params(mac_ctx->pdev,
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002259 csa_params->channel,
Sandeep Puligilla1cc23f62016-04-27 16:52:49 -07002260 0, &ch_params);
Kiran Kumar Lokere999e58c2016-01-07 02:18:39 -08002261 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;
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002265 } else {
2266 lim_ch_switch->ch_width =
2267 CH_WIDTH_20MHZ;
2268 chnl_switch_info->newChanWidth =
2269 CH_WIDTH_40MHZ;
2270 lim_ch_switch->state =
2271 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2272 lim_ch_switch->sec_ch_offset =
2273 PHY_SINGLE_CHANNEL_CENTERED;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002274 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002275 } else {
2276 lim_ch_switch->ch_width =
2277 CH_WIDTH_40MHZ;
2278 lim_ch_switch->state =
2279 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2280 ch_params.ch_width = CH_WIDTH_40MHZ;
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002281 wlan_reg_set_channel_params(mac_ctx->pdev,
2282 csa_params->channel, 0, &ch_params);
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002283 lim_ch_switch->ch_center_freq_seg0 =
2284 ch_params.center_freq_seg0;
2285 lim_ch_switch->sec_ch_offset =
2286 ch_params.sec_ch_offset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002287 }
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002288
2289 }
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302290 pe_debug("new ch width: %d space: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302291 session_entry->gLimChannelSwitch.ch_width, chan_space);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002292
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002293 lim_prepare_for11h_channel_switch(mac_ctx, session_entry);
2294 csa_offload_ind = qdf_mem_malloc(sizeof(tSmeCsaOffloadInd));
2295 if (NULL == csa_offload_ind) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302296 pe_err("memalloc fail eWNI_SME_CSA_OFFLOAD_EVENT");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002297 goto err;
2298 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002299
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002300 csa_offload_ind->mesgType = eWNI_SME_CSA_OFFLOAD_EVENT;
2301 csa_offload_ind->mesgLen = sizeof(tSmeCsaOffloadInd);
2302 qdf_mem_copy(csa_offload_ind->bssid.bytes, session_entry->bssId,
2303 QDF_MAC_ADDR_SIZE);
2304 mmh_msg.type = eWNI_SME_CSA_OFFLOAD_EVENT;
2305 mmh_msg.bodyptr = csa_offload_ind;
2306 mmh_msg.bodyval = 0;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302307 pe_debug("Sending eWNI_SME_CSA_OFFLOAD_EVENT to SME");
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002308 MTRACE(mac_trace_msg_tx
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002309 (mac_ctx, session_entry->peSessionId, mmh_msg.type));
2310#ifdef FEATURE_WLAN_DIAG_SUPPORT
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002311 lim_diag_event_report(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002312 WLAN_PE_DIAG_SWITCH_CHL_IND_EVENT, session_entry,
2313 eSIR_SUCCESS, eSIR_SUCCESS);
2314#endif
Kiran Kumar Lokeree38f4d22016-10-20 17:30:59 -07002315 lim_sys_process_mmh_msg_api(mac_ctx, &mmh_msg, ePROT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002316
2317err:
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302318 qdf_mem_free(csa_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002319}
2320
2321/*--------------------------------------------------------------------------
2322 \brief pe_delete_session() - Handle the Delete BSS Response from HAL.
2323
2324 \param pMac - pointer to global adapter context
2325 \param sessionId - Message pointer.
2326
2327 \sa
2328 --------------------------------------------------------------------------*/
2329
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002330void lim_handle_delete_bss_rsp(tpAniSirGlobal pMac, struct scheduler_msg *MsgQ)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002331{
2332 tpPESession psessionEntry;
2333 tpDeleteBssParams pDelBss = (tpDeleteBssParams) (MsgQ->bodyptr);
2334
2335 psessionEntry =
2336 pe_find_session_by_session_id(pMac, pDelBss->sessionId);
2337 if (psessionEntry == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302338 pe_err("Session Does not exist for given sessionID: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002339 pDelBss->sessionId);
Naveen Rawat0c81edc2016-06-08 10:08:30 -07002340 qdf_mem_free(MsgQ->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002341 return;
2342 }
Deepak Dhamdhere2dae1bd2016-10-27 10:58:29 -07002343 /*
2344 * During DEL BSS handling, the PE Session will be deleted, but it is
2345 * better to clear this flag if the session is hanging around due
2346 * to some error conditions so that the next DEL_BSS request does
2347 * not take the HO_FAIL path
2348 */
2349 psessionEntry->process_ho_fail = false;
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002350 if (LIM_IS_IBSS_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002351 lim_ibss_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002352 else if (LIM_IS_UNKNOWN_ROLE(psessionEntry))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002353 lim_process_sme_del_bss_rsp(pMac, MsgQ->bodyval, psessionEntry);
Deepak Dhamdhere13983f22016-05-31 19:06:09 -07002354 else if (LIM_IS_NDI_ROLE(psessionEntry))
2355 lim_ndi_del_bss_rsp(pMac, MsgQ->bodyptr, psessionEntry);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002356 else
2357 lim_process_mlm_del_bss_rsp(pMac, MsgQ, psessionEntry);
2358
2359}
2360
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002361/** -----------------------------------------------------------------
2362 \brief lim_send_sme_aggr_qos_rsp() - sends SME FT AGGR QOS RSP
2363 \ This function sends a eWNI_SME_FT_AGGR_QOS_RSP to SME.
2364 \ SME only looks at rc and tspec field.
2365 \param pMac - global mac structure
2366 \param rspReqd - is SmeAddTsRsp required
2367 \param status - status code of eWNI_SME_FT_AGGR_QOS_RSP
2368 \return tspec
2369 \sa
2370 ----------------------------------------------------------------- */
2371void
2372lim_send_sme_aggr_qos_rsp(tpAniSirGlobal pMac, tpSirAggrQosRsp aggrQosRsp,
2373 uint8_t smesessionId)
2374{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002375 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002376
2377 mmhMsg.type = eWNI_SME_FT_AGGR_QOS_RSP;
2378 mmhMsg.bodyptr = aggrQosRsp;
2379 mmhMsg.bodyval = 0;
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302380 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2381 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002382 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2383
2384 return;
2385}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002386
2387void lim_send_sme_max_assoc_exceeded_ntf(tpAniSirGlobal pMac, tSirMacAddr peerMacAddr,
2388 uint8_t smesessionId)
2389{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002390 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002391 tSmeMaxAssocInd *pSmeMaxAssocInd;
2392
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302393 pSmeMaxAssocInd = qdf_mem_malloc(sizeof(tSmeMaxAssocInd));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002394 if (NULL == pSmeMaxAssocInd) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302395 pe_err("Failed to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002396 return;
2397 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302398 qdf_mem_copy((uint8_t *) pSmeMaxAssocInd->peer_mac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302399 (uint8_t *) peerMacAddr, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002400 pSmeMaxAssocInd->mesgType = eWNI_SME_MAX_ASSOC_EXCEEDED;
2401 pSmeMaxAssocInd->mesgLen = sizeof(tSmeMaxAssocInd);
2402 pSmeMaxAssocInd->sessionId = smesessionId;
2403 mmhMsg.type = pSmeMaxAssocInd->mesgType;
2404 mmhMsg.bodyptr = pSmeMaxAssocInd;
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302405 pe_debug("msgType: %s peerMacAddr "MAC_ADDRESS_STR "sme session id %d",
2406 "eWNI_SME_MAX_ASSOC_EXCEEDED", MAC_ADDR_ARRAY(peerMacAddr),
2407 pSmeMaxAssocInd->sessionId);
Sreelakshmi Konamkibeacc2e2016-09-01 16:14:56 +05302408 MTRACE(mac_trace(pMac, TRACE_CODE_TX_SME_MSG,
2409 smesessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002410 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2411
2412 return;
2413}
2414
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002415/*--------------------------------------------------------------------------
2416 \brief lim_send_dfs_chan_sw_ie_update()
2417 This timer handler updates the channel switch IE in beacon template
2418
2419 \param pMac - pointer to global adapter context
2420 \return - channel to scan from valid session else zero.
2421 \sa
2422 --------------------------------------------------------------------------*/
2423static void
2424lim_send_dfs_chan_sw_ie_update(tpAniSirGlobal pMac, tpPESession psessionEntry)
2425{
2426
2427 /* Update the beacon template and send to FW */
2428 if (sch_set_fixed_beacon_fields(pMac, psessionEntry) != eSIR_SUCCESS) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302429 pe_err("Unable to set CSA IE in beacon");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002430 return;
2431 }
2432
2433 /* Send update beacon template message */
2434 lim_send_beacon_ind(pMac, psessionEntry);
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302435 pe_debug("Updated CSA IE, IE COUNT: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002436 psessionEntry->gLimChannelSwitch.switchCount);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002437
2438 return;
2439}
2440
2441/** -----------------------------------------------------------------
2442 \brief lim_send_sme_ap_channel_switch_resp() - sends
2443 eWNI_SME_CHANNEL_CHANGE_RSP
2444 After receiving WMA_SWITCH_CHANNEL_RSP indication this
2445 function sends a eWNI_SME_CHANNEL_CHANGE_RSP to SME to notify
2446 that the Channel change has been done to the specified target
2447 channel in the Channel change request
2448 \param pMac - global mac structure
2449 \param psessionEntry - session info
2450 \param pChnlParams - Channel switch params
2451 --------------------------------------------------------------------*/
2452void
2453lim_send_sme_ap_channel_switch_resp(tpAniSirGlobal pMac,
2454 tpPESession psessionEntry,
2455 tpSwitchChannelParams pChnlParams)
2456{
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002457 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002458 tpSwitchChannelParams pSmeSwithChnlParams;
2459 uint8_t channelId;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002460 bool is_ch_dfs = false;
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08002461 enum phy_ch_width ch_width;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002462 uint8_t ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002463
2464 pSmeSwithChnlParams = (tSwitchChannelParams *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302465 qdf_mem_malloc(sizeof(tSwitchChannelParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002466 if (NULL == pSmeSwithChnlParams) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302467 pe_err("AllocateMemory failed for pSmeSwithChnlParams");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002468 return;
2469 }
2470
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302471 qdf_mem_copy(pSmeSwithChnlParams, pChnlParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002472 sizeof(tSwitchChannelParams));
2473
2474 channelId = pSmeSwithChnlParams->channelNumber;
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002475 ch_width = pSmeSwithChnlParams->ch_width;
2476 ch_center_freq_seg1 = pSmeSwithChnlParams->ch_center_freq_seg1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002477
2478 /*
2479 * Pass the sme sessionID to SME instead
2480 * PE session ID.
2481 */
2482 pSmeSwithChnlParams->peSessionId = psessionEntry->smeSessionId;
2483
2484 mmhMsg.type = eWNI_SME_CHANNEL_CHANGE_RSP;
2485 mmhMsg.bodyptr = (void *)pSmeSwithChnlParams;
2486 mmhMsg.bodyval = 0;
2487 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2488
2489 /*
2490 * We should start beacon transmission only if the new
2491 * channel after channel change is Non-DFS. For a DFS
2492 * channel, PE will receive an explicit request from
2493 * upper layers to start the beacon transmission .
2494 */
2495
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002496 if (ch_width == CH_WIDTH_160MHZ) {
2497 is_ch_dfs = true;
2498 } else if (ch_width == CH_WIDTH_80P80MHZ) {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002499 if (wlan_reg_get_channel_state(pMac->pdev, channelId) ==
2500 CHANNEL_STATE_DFS ||
2501 wlan_reg_get_channel_state(pMac->pdev,
2502 ch_center_freq_seg1 -
2503 SIR_80MHZ_START_CENTER_CH_DIFF) ==
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002504 CHANNEL_STATE_DFS)
2505 is_ch_dfs = true;
2506 } else {
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07002507 if (wlan_reg_get_channel_state(pMac->pdev, channelId) ==
2508 CHANNEL_STATE_DFS)
Sandeep Puligilla2111d3c2016-02-03 01:46:15 -08002509 is_ch_dfs = true;
2510 }
2511
2512 if (!is_ch_dfs) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002513 if (channelId == psessionEntry->currentOperChannel) {
2514 lim_apply_configuration(pMac, psessionEntry);
2515 lim_send_beacon_ind(pMac, psessionEntry);
2516 } else {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302517 pe_debug("Failed to Transmit Beacons on channel: %d after AP channel change response",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002518 psessionEntry->bcnLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002519 }
2520 }
2521 return;
2522}
2523
Peng Xu6363ec62017-05-15 11:06:33 -07002524#ifdef WLAN_FEATURE_11AX_BSS_COLOR
2525/**
2526 * lim_send_bss_color_change_ie_update() - update bss color change IE in
2527 * beacon template
2528 *
2529 * @mac_ctx: pointer to global adapter context
2530 * @session: session pointer
2531 *
2532 * Return: none
2533 */
2534static void
2535lim_send_bss_color_change_ie_update(tpAniSirGlobal mac_ctx,
2536 tpPESession session)
2537{
2538 /* Update the beacon template and send to FW */
2539 if (sch_set_fixed_beacon_fields(mac_ctx, session) != eSIR_SUCCESS) {
2540 pe_err("Unable to set BSS color change IE in beacon");
2541 return;
2542 }
2543
2544 /* Send update beacon template message */
2545 lim_send_beacon_ind(mac_ctx, session);
2546 pe_info("Updated BSS color change countdown = %d",
2547 session->he_bss_color_change.countdown);
2548}
2549
2550static void
2551lim_handle_bss_color_change_ie(tpAniSirGlobal mac_ctx,
2552 tpPESession session)
2553{
2554 /* handle bss color change IE */
2555 if (LIM_IS_AP_ROLE(session) &&
2556 session->he_op.bss_col_disabled) {
2557 if (session->he_bss_color_change.countdown > 0) {
2558 session->he_bss_color_change.countdown--;
2559 } else {
2560 session->bss_color_changing = 0;
2561 if (session->he_bss_color_change.new_color != 0)
2562 session->he_op.bss_col_disabled = 0;
2563 }
2564
2565 lim_send_bss_color_change_ie_update(mac_ctx, session);
2566 }
2567}
2568
2569#else
2570static void
2571lim_handle_bss_color_change_ie(tpAniSirGlobal mac_ctx,
2572 tpPESession session)
2573{
2574}
2575#endif
2576
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002577/** -----------------------------------------------------------------
2578 \brief lim_process_beacon_tx_success_ind() - This function is used
2579 explicitely to handle successful beacon transmission indication
2580 from the FW. This is a generic event generated by the FW afer the
2581 first beacon is sent out after the beacon template update by the
2582 host
2583 \param pMac - global mac structure
2584 \param psessionEntry - session info
2585 \return none
2586 \sa
2587 ----------------------------------------------------------------- */
2588void
2589lim_process_beacon_tx_success_ind(tpAniSirGlobal pMac, uint16_t msgType, void *event)
2590{
2591 /* Currently, this event is used only for DFS channel switch announcement
2592 * IE update in the template. If required to be used for other IE updates
2593 * add appropriate code by introducing a state variable
2594 */
2595 tpPESession psessionEntry;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07002596 struct scheduler_msg mmhMsg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002597 tSirSmeCSAIeTxCompleteRsp *pChanSwTxResponse;
2598 struct sir_beacon_tx_complete_rsp *beacon_tx_comp_rsp_ptr;
2599 uint8_t length = sizeof(tSirSmeCSAIeTxCompleteRsp);
2600 tpSirFirstBeaconTxCompleteInd pBcnTxInd =
2601 (tSirFirstBeaconTxCompleteInd *) event;
2602
2603 psessionEntry = pe_find_session_by_bss_idx(pMac, pBcnTxInd->bssIdx);
2604 if (psessionEntry == NULL) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302605 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002606 return;
2607 }
2608
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302609 pe_debug("role: %d swIe: %d opIe: %d",
Chandrasekaran, Manishekarce2172e2016-02-18 16:12:43 +05302610 GET_LIM_SYSTEM_ROLE(psessionEntry),
2611 psessionEntry->dfsIncludeChanSwIe,
2612 psessionEntry->gLimOperatingMode.present);
2613
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002614 if (LIM_IS_AP_ROLE(psessionEntry) &&
2615 true == psessionEntry->dfsIncludeChanSwIe) {
2616 /* Send only 5 beacons with CSA IE Set in when a radar is detected */
2617 if (psessionEntry->gLimChannelSwitch.switchCount > 0) {
2618 /*
2619 * Send the next beacon with updated CSA IE count
2620 */
2621 lim_send_dfs_chan_sw_ie_update(pMac, psessionEntry);
2622 /* Decrement the IE count */
2623 psessionEntry->gLimChannelSwitch.switchCount--;
2624 } else {
2625 /* Done with CSA IE update, send response back to SME */
2626 psessionEntry->gLimChannelSwitch.switchCount = 0;
2627 if (pMac->sap.SapDfsInfo.disable_dfs_ch_switch == false)
2628 psessionEntry->gLimChannelSwitch.switchMode = 0;
2629 psessionEntry->dfsIncludeChanSwIe = false;
2630 psessionEntry->dfsIncludeChanWrapperIe = false;
2631
2632 pChanSwTxResponse = (tSirSmeCSAIeTxCompleteRsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302633 qdf_mem_malloc(length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002634
2635 if (NULL == pChanSwTxResponse) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302636 pe_err("AllocateMemory failed for tSirSmeCSAIeTxCompleteRsp");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002637 return;
2638 }
2639
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002640 pChanSwTxResponse->sessionId =
2641 psessionEntry->smeSessionId;
2642 pChanSwTxResponse->chanSwIeTxStatus =
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302643 QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002644
2645 mmhMsg.type = eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND;
2646 mmhMsg.bodyptr = pChanSwTxResponse;
2647 mmhMsg.bodyval = 0;
2648 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2649 }
2650 }
2651
2652 if (LIM_IS_AP_ROLE(psessionEntry) &&
2653 psessionEntry->gLimOperatingMode.present) {
2654 /* Done with nss update, send response back to SME */
2655 psessionEntry->gLimOperatingMode.present = 0;
2656 beacon_tx_comp_rsp_ptr = (struct sir_beacon_tx_complete_rsp *)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302657 qdf_mem_malloc(sizeof(*beacon_tx_comp_rsp_ptr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002658 if (NULL == beacon_tx_comp_rsp_ptr) {
Nishank Aggarwal2d6162b2017-03-24 17:38:12 +05302659 pe_err("AllocateMemory failed for beacon_tx_comp_rsp_ptr");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002660 return;
2661 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002662 beacon_tx_comp_rsp_ptr->session_id =
2663 psessionEntry->smeSessionId;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302664 beacon_tx_comp_rsp_ptr->tx_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002665 mmhMsg.type = eWNI_SME_NSS_UPDATE_RSP;
2666 mmhMsg.bodyptr = beacon_tx_comp_rsp_ptr;
2667 mmhMsg.bodyval = 0;
2668 lim_sys_process_mmh_msg_api(pMac, &mmhMsg, ePROT);
2669 }
Peng Xu6363ec62017-05-15 11:06:33 -07002670
2671 lim_handle_bss_color_change_ie(pMac, psessionEntry);
2672
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002673 return;
2674}