blob: 2db97873b9d1eb252295fdffa6d1face99726122 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Himanshu Agarwala79c6762017-12-28 21:25:00 +05302 * Copyright (c) 2011-2018 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
19/*
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080020 * This file lim_utils.cc contains the utility functions
21 * LIM uses.
22 * Author: Chandra Modumudi
23 * Date: 02/13/02
24 * History:-
25 * Date Modified by Modification Information
26 * --------------------------------------------------------------------
27 */
28
29#include "sch_api.h"
30#include "lim_utils.h"
31#include "lim_types.h"
32#include "lim_security_utils.h"
33#include "lim_prop_exts_utils.h"
34#include "lim_send_messages.h"
35#include "lim_ser_des_utils.h"
36#include "lim_admit_control.h"
37#include "lim_sta_hash_api.h"
38#include "dot11f.h"
39#include "dot11fdefs.h"
40#include "wmm_apsd.h"
41#include "lim_trace.h"
Abhinav Kumar49d08a72018-02-14 17:36:12 +053042
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080043#ifdef FEATURE_WLAN_DIAG_SUPPORT
44#include "host_diag_core_event.h"
45#endif /* FEATURE_WLAN_DIAG_SUPPORT */
46#include "lim_ibss_peer_mgmt.h"
47#include "lim_session_utils.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080048#include "lim_ft_defs.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080049#include "lim_session.h"
50#include "cds_reg_service.h"
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -070051#include "nan_datapath.h"
Naveen Rawat03e8d952016-08-01 15:22:20 -070052#include "wma.h"
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -070053#include "wlan_reg_services_api.h"
Ajit Pal Singh7ae88fb2017-09-06 16:14:35 +053054#include "wlan_policy_mgr_api.h"
Vignesh Viswanathan21c58cb2018-05-24 15:53:58 +053055#include "wlan_mlme_public_struct.h"
Krunal Sonib7f20432017-04-27 13:01:02 -070056#ifdef WLAN_FEATURE_11AX_BSS_COLOR
57#include "wma_he.h"
58#endif
Naveen Rawat08db88f2017-09-08 15:07:48 -070059#include "wlan_utility.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080060
61#ifdef WLAN_FEATURE_11W
62#include "wni_cfg.h"
63#endif
Wu Gaod8f3db02018-07-24 19:18:45 +080064#include "cfg_mlme_obss_ht40.h"
65#include "cfg_ucfg_api.h"
Jianmin Zhu09236602018-10-15 15:36:10 +080066#include "lim_ft.h"
gaurank kathpalia24ed0f42018-11-13 15:37:49 +053067#include "wlan_mlme_main.h"
Wu Gaod8f3db02018-07-24 19:18:45 +080068
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080069#define ASCII_SPACE_CHARACTER 0x20
70
Abhinav Kumar49d08a72018-02-14 17:36:12 +053071/* A DFS channel can be ACTIVE for max 9000 msec, from the last
72 received Beacon/Prpbe Resp. */
73#define MAX_TIME_TO_BE_ACTIVE_CHANNEL 9000
74
75
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080076/** -------------------------------------------------------------
77 \fn lim_delete_dialogue_token_list
78 \brief deletes the complete lim dialogue token linked list.
Jeff Johnsond01da6b2018-12-02 12:10:22 -080079 \param struct mac_context * mac
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080080 \return None
81 -------------------------------------------------------------*/
Jeff Johnsond01da6b2018-12-02 12:10:22 -080082void lim_delete_dialogue_token_list(struct mac_context *mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080083{
Jeff Johnson0a0f42a2018-11-21 20:42:36 -080084 tpDialogueToken pCurrNode = mac->lim.pDialogueTokenHead;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080085
Jeff Johnson0a0f42a2018-11-21 20:42:36 -080086 while (NULL != mac->lim.pDialogueTokenHead) {
87 pCurrNode = mac->lim.pDialogueTokenHead;
88 mac->lim.pDialogueTokenHead =
89 mac->lim.pDialogueTokenHead->next;
Anurag Chouhan600c3a02016-03-01 10:33:54 +053090 qdf_mem_free(pCurrNode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080091 pCurrNode = NULL;
92 }
Jeff Johnson0a0f42a2018-11-21 20:42:36 -080093 mac->lim.pDialogueTokenTail = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080094}
95
96char *lim_dot11_reason_str(uint16_t reasonCode)
97{
98 switch (reasonCode) {
99 case 0:
100 return " ";
101 CASE_RETURN_STRING(eSIR_MAC_UNSPEC_FAILURE_REASON);
102 CASE_RETURN_STRING(eSIR_MAC_PREV_AUTH_NOT_VALID_REASON);
103 CASE_RETURN_STRING(eSIR_MAC_DEAUTH_LEAVING_BSS_REASON);
104 CASE_RETURN_STRING(eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON);
105 CASE_RETURN_STRING(eSIR_MAC_DISASSOC_DUE_TO_DISABILITY_REASON);
106 CASE_RETURN_STRING
107 (eSIR_MAC_CLASS2_FRAME_FROM_NON_AUTH_STA_REASON);
108 CASE_RETURN_STRING
109 (eSIR_MAC_CLASS3_FRAME_FROM_NON_ASSOC_STA_REASON);
110 CASE_RETURN_STRING(eSIR_MAC_DISASSOC_LEAVING_BSS_REASON);
111 CASE_RETURN_STRING(eSIR_MAC_STA_NOT_PRE_AUTHENTICATED_REASON);
112 CASE_RETURN_STRING(eSIR_MAC_PWR_CAPABILITY_BAD_REASON);
113 CASE_RETURN_STRING(eSIR_MAC_SPRTD_CHANNELS_BAD_REASON);
114
115 CASE_RETURN_STRING(eSIR_MAC_INVALID_IE_REASON);
116 CASE_RETURN_STRING(eSIR_MAC_MIC_FAILURE_REASON);
117 CASE_RETURN_STRING(eSIR_MAC_4WAY_HANDSHAKE_TIMEOUT_REASON);
118 CASE_RETURN_STRING(eSIR_MAC_GR_KEY_UPDATE_TIMEOUT_REASON);
119 CASE_RETURN_STRING(eSIR_MAC_RSN_IE_MISMATCH_REASON);
120
121 CASE_RETURN_STRING(eSIR_MAC_INVALID_MC_CIPHER_REASON);
122 CASE_RETURN_STRING(eSIR_MAC_INVALID_UC_CIPHER_REASON);
123 CASE_RETURN_STRING(eSIR_MAC_INVALID_AKMP_REASON);
124 CASE_RETURN_STRING(eSIR_MAC_UNSUPPORTED_RSN_IE_VER_REASON);
125 CASE_RETURN_STRING(eSIR_MAC_INVALID_RSN_CAPABILITIES_REASON);
126 CASE_RETURN_STRING(eSIR_MAC_1X_AUTH_FAILURE_REASON);
127 CASE_RETURN_STRING(eSIR_MAC_CIPHER_SUITE_REJECTED_REASON);
128#ifdef FEATURE_WLAN_TDLS
129 CASE_RETURN_STRING(eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE);
130 CASE_RETURN_STRING(eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON);
131#endif
132 /* Reserved 27 - 30 */
133#ifdef WLAN_FEATURE_11W
134 CASE_RETURN_STRING
135 (eSIR_MAC_ROBUST_MGMT_FRAMES_POLICY_VIOLATION);
136#endif
137 CASE_RETURN_STRING(eSIR_MAC_QOS_UNSPECIFIED_REASON);
138 CASE_RETURN_STRING(eSIR_MAC_QAP_NO_BANDWIDTH_REASON);
139 CASE_RETURN_STRING(eSIR_MAC_XS_UNACKED_FRAMES_REASON);
140 CASE_RETURN_STRING(eSIR_MAC_BAD_TXOP_USE_REASON);
141 CASE_RETURN_STRING(eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON);
142 CASE_RETURN_STRING(eSIR_MAC_PEER_REJECT_MECHANISIM_REASON);
143 CASE_RETURN_STRING(eSIR_MAC_MECHANISM_NOT_SETUP_REASON);
144
145 CASE_RETURN_STRING(eSIR_MAC_PEER_TIMEDOUT_REASON);
146 CASE_RETURN_STRING(eSIR_MAC_CIPHER_NOT_SUPPORTED_REASON);
147 CASE_RETURN_STRING(eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON);
148 /* Reserved 47 - 65535 */
149 default:
150 return "Unknown";
151 }
152}
153
154char *lim_mlm_state_str(tLimMlmStates state)
155{
156 switch (state) {
157 case eLIM_MLM_OFFLINE_STATE:
158 return "eLIM_MLM_OFFLINE_STATE";
159 case eLIM_MLM_IDLE_STATE:
160 return "eLIM_MLM_IDLE_STATE";
161 case eLIM_MLM_WT_PROBE_RESP_STATE:
162 return "eLIM_MLM_WT_PROBE_RESP_STATE";
163 case eLIM_MLM_PASSIVE_SCAN_STATE:
164 return "eLIM_MLM_PASSIVE_SCAN_STATE";
165 case eLIM_MLM_WT_JOIN_BEACON_STATE:
166 return "eLIM_MLM_WT_JOIN_BEACON_STATE";
167 case eLIM_MLM_JOINED_STATE:
168 return "eLIM_MLM_JOINED_STATE";
169 case eLIM_MLM_BSS_STARTED_STATE:
170 return "eLIM_MLM_BSS_STARTED_STATE";
171 case eLIM_MLM_WT_AUTH_FRAME2_STATE:
172 return "eLIM_MLM_WT_AUTH_FRAME2_STATE";
173 case eLIM_MLM_WT_AUTH_FRAME3_STATE:
174 return "eLIM_MLM_WT_AUTH_FRAME3_STATE";
175 case eLIM_MLM_WT_AUTH_FRAME4_STATE:
176 return "eLIM_MLM_WT_AUTH_FRAME4_STATE";
177 case eLIM_MLM_AUTH_RSP_TIMEOUT_STATE:
178 return "eLIM_MLM_AUTH_RSP_TIMEOUT_STATE";
179 case eLIM_MLM_AUTHENTICATED_STATE:
180 return "eLIM_MLM_AUTHENTICATED_STATE";
181 case eLIM_MLM_WT_ASSOC_RSP_STATE:
182 return "eLIM_MLM_WT_ASSOC_RSP_STATE";
183 case eLIM_MLM_WT_REASSOC_RSP_STATE:
184 return "eLIM_MLM_WT_REASSOC_RSP_STATE";
185 case eLIM_MLM_WT_FT_REASSOC_RSP_STATE:
186 return "eLIM_MLM_WT_FT_REASSOC_RSP_STATE";
187 case eLIM_MLM_WT_DEL_STA_RSP_STATE:
188 return "eLIM_MLM_WT_DEL_STA_RSP_STATE";
189 case eLIM_MLM_WT_DEL_BSS_RSP_STATE:
190 return "eLIM_MLM_WT_DEL_BSS_RSP_STATE";
191 case eLIM_MLM_WT_ADD_STA_RSP_STATE:
192 return "eLIM_MLM_WT_ADD_STA_RSP_STATE";
193 case eLIM_MLM_WT_ADD_BSS_RSP_STATE:
194 return "eLIM_MLM_WT_ADD_BSS_RSP_STATE";
195 case eLIM_MLM_REASSOCIATED_STATE:
196 return "eLIM_MLM_REASSOCIATED_STATE";
197 case eLIM_MLM_LINK_ESTABLISHED_STATE:
198 return "eLIM_MLM_LINK_ESTABLISHED_STATE";
199 case eLIM_MLM_WT_ASSOC_CNF_STATE:
200 return "eLIM_MLM_WT_ASSOC_CNF_STATE";
201 case eLIM_MLM_WT_ADD_BSS_RSP_ASSOC_STATE:
202 return "eLIM_MLM_WT_ADD_BSS_RSP_ASSOC_STATE";
203 case eLIM_MLM_WT_ADD_BSS_RSP_REASSOC_STATE:
204 return "eLIM_MLM_WT_ADD_BSS_RSP_REASSOC_STATE";
205 case eLIM_MLM_WT_ADD_BSS_RSP_FT_REASSOC_STATE:
206 return "eLIM_MLM_WT_ADD_BSS_RSP_FT_REASSOC_STATE";
207 case eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE:
208 return "eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE";
209 case eLIM_MLM_WT_SET_BSS_KEY_STATE:
210 return "eLIM_MLM_WT_SET_BSS_KEY_STATE";
211 case eLIM_MLM_WT_SET_STA_KEY_STATE:
212 return "eLIM_MLM_WT_SET_STA_KEY_STATE";
213 default:
214 return "INVALID MLM state";
215 }
216}
217
218void
Jeff Johnsond01da6b2018-12-02 12:10:22 -0800219lim_print_mlm_state(struct mac_context *mac, uint16_t logLevel, tLimMlmStates state)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800220{
Srinivas Girigowda4bc512b2017-03-26 22:12:58 -0700221 pe_debug("Mlm state: %s", lim_mlm_state_str(state));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800222}
223
224char *lim_sme_state_str(tLimSmeStates state)
225{
226 switch (state) {
227 case eLIM_SME_OFFLINE_STATE:
228 return "eLIM_SME_OFFLINE_STATE";
229 case eLIM_SME_IDLE_STATE:
230 return "eLIM_SME_OFFLINE_STATE";
231 case eLIM_SME_SUSPEND_STATE:
232 return "eLIM_SME_SUSPEND_STATE";
233 case eLIM_SME_WT_SCAN_STATE:
234 return "eLIM_SME_WT_SCAN_STATE";
235 case eLIM_SME_WT_JOIN_STATE:
236 return "eLIM_SME_WT_JOIN_STATE";
237 case eLIM_SME_WT_AUTH_STATE:
238 return "eLIM_SME_WT_AUTH_STATE";
239 case eLIM_SME_WT_ASSOC_STATE:
240 return "eLIM_SME_WT_ASSOC_STATE";
241 case eLIM_SME_WT_REASSOC_STATE:
242 return "eLIM_SME_WT_REASSOC_STATE";
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800243 case eLIM_SME_JOIN_FAILURE_STATE:
244 return "eLIM_SME_JOIN_FAILURE_STATE";
245 case eLIM_SME_ASSOCIATED_STATE:
246 return "eLIM_SME_ASSOCIATED_STATE";
247 case eLIM_SME_REASSOCIATED_STATE:
248 return "eLIM_SME_REASSOCIATED_STATE";
249 case eLIM_SME_LINK_EST_STATE:
250 return "eLIM_SME_LINK_EST_STATE";
251 case eLIM_SME_LINK_EST_WT_SCAN_STATE:
252 return "eLIM_SME_LINK_EST_WT_SCAN_STATE";
253 case eLIM_SME_WT_PRE_AUTH_STATE:
254 return "eLIM_SME_WT_PRE_AUTH_STATE";
255 case eLIM_SME_WT_DISASSOC_STATE:
256 return "eLIM_SME_WT_DISASSOC_STATE";
257 case eLIM_SME_WT_DEAUTH_STATE:
258 return "eLIM_SME_WT_DEAUTH_STATE";
259 case eLIM_SME_WT_START_BSS_STATE:
260 return "eLIM_SME_WT_START_BSS_STATE";
261 case eLIM_SME_WT_STOP_BSS_STATE:
262 return "eLIM_SME_WT_STOP_BSS_STATE";
263 case eLIM_SME_NORMAL_STATE:
264 return "eLIM_SME_NORMAL_STATE";
265 case eLIM_SME_CHANNEL_SCAN_STATE:
266 return "eLIM_SME_CHANNEL_SCAN_STATE";
267 case eLIM_SME_NORMAL_CHANNEL_SCAN_STATE:
268 return "eLIM_SME_NORMAL_CHANNEL_SCAN_STATE";
269 default:
270 return "INVALID SME STATE";
271 }
272}
273
274void
Jeff Johnsond01da6b2018-12-02 12:10:22 -0800275lim_print_sme_state(struct mac_context *mac, uint16_t logLevel, tLimSmeStates state)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800276{
Srinivas Girigowda4bc512b2017-03-26 22:12:58 -0700277 pe_debug("SME state: %s", lim_sme_state_str(state));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800278}
279
280char *lim_msg_str(uint32_t msgType)
281{
282#ifdef FIXME_GEN6
283 switch (msgType) {
284 case eWNI_SME_SYS_READY_IND:
285 return "eWNI_SME_SYS_READY_IND";
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800286 case eWNI_SME_JOIN_REQ:
287 return "eWNI_SME_JOIN_REQ";
288 case eWNI_SME_JOIN_RSP:
289 return "eWNI_SME_JOIN_RSP";
290 case eWNI_SME_SETCONTEXT_REQ:
291 return "eWNI_SME_SETCONTEXT_REQ";
292 case eWNI_SME_SETCONTEXT_RSP:
293 return "eWNI_SME_SETCONTEXT_RSP";
294 case eWNI_SME_REASSOC_REQ:
295 return "eWNI_SME_REASSOC_REQ";
296 case eWNI_SME_REASSOC_RSP:
297 return "eWNI_SME_REASSOC_RSP";
298 case eWNI_SME_DISASSOC_REQ:
299 return "eWNI_SME_DISASSOC_REQ";
300 case eWNI_SME_DISASSOC_RSP:
301 return "eWNI_SME_DISASSOC_RSP";
302 case eWNI_SME_DISASSOC_IND:
303 return "eWNI_SME_DISASSOC_IND";
304 case eWNI_SME_DISASSOC_CNF:
305 return "eWNI_SME_DISASSOC_CNF";
306 case eWNI_SME_DEAUTH_REQ:
307 return "eWNI_SME_DEAUTH_REQ";
308 case eWNI_SME_DEAUTH_RSP:
309 return "eWNI_SME_DEAUTH_RSP";
310 case eWNI_SME_DEAUTH_IND:
311 return "eWNI_SME_DEAUTH_IND";
312 case eWNI_SME_WM_STATUS_CHANGE_NTF:
313 return "eWNI_SME_WM_STATUS_CHANGE_NTF";
314 case eWNI_SME_START_BSS_REQ:
315 return "eWNI_SME_START_BSS_REQ";
316 case eWNI_SME_START_BSS_RSP:
317 return "eWNI_SME_START_BSS_RSP";
318 case eWNI_SME_ASSOC_IND:
319 return "eWNI_SME_ASSOC_IND";
320 case eWNI_SME_ASSOC_CNF:
321 return "eWNI_SME_ASSOC_CNF";
322 case eWNI_SME_SWITCH_CHL_IND:
323 return "eWNI_SME_SWITCH_CHL_IND";
324 case eWNI_SME_STOP_BSS_REQ:
325 return "eWNI_SME_STOP_BSS_REQ";
326 case eWNI_SME_STOP_BSS_RSP:
327 return "eWNI_SME_STOP_BSS_RSP";
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800328 case eWNI_SME_DEAUTH_CNF:
329 return "eWNI_SME_DEAUTH_CNF";
330 case eWNI_SME_ADDTS_REQ:
331 return "eWNI_SME_ADDTS_REQ";
332 case eWNI_SME_ADDTS_RSP:
333 return "eWNI_SME_ADDTS_RSP";
334 case eWNI_SME_DELTS_REQ:
335 return "eWNI_SME_DELTS_REQ";
336 case eWNI_SME_DELTS_RSP:
337 return "eWNI_SME_DELTS_RSP";
338 case eWNI_SME_DELTS_IND:
339 return "eWNI_SME_DELTS_IND";
340 case WMA_SUSPEND_ACTIVITY_RSP:
341 return "WMA_SUSPEND_ACTIVITY_RSP";
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800342 case SIR_BB_XPORT_MGMT_MSG:
343 return "SIR_BB_XPORT_MGMT_MSG";
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800344 case SIR_LIM_JOIN_FAIL_TIMEOUT:
345 return "SIR_LIM_JOIN_FAIL_TIMEOUT";
346 case SIR_LIM_AUTH_FAIL_TIMEOUT:
347 return "SIR_LIM_AUTH_FAIL_TIMEOUT";
348 case SIR_LIM_AUTH_RSP_TIMEOUT:
349 return "SIR_LIM_AUTH_RSP_TIMEOUT";
350 case SIR_LIM_ASSOC_FAIL_TIMEOUT:
351 return "SIR_LIM_ASSOC_FAIL_TIMEOUT";
352 case SIR_LIM_REASSOC_FAIL_TIMEOUT:
353 return "SIR_LIM_REASSOC_FAIL_TIMEOUT";
354 case SIR_LIM_HEART_BEAT_TIMEOUT:
355 return "SIR_LIM_HEART_BEAT_TIMEOUT";
356 case SIR_LIM_ADDTS_RSP_TIMEOUT:
357 return "SIR_LIM_ADDTS_RSP_TIMEOUT";
358 case SIR_LIM_LINK_TEST_DURATION_TIMEOUT:
359 return "SIR_LIM_LINK_TEST_DURATION_TIMEOUT";
360 case SIR_LIM_HASH_MISS_THRES_TIMEOUT:
361 return "SIR_LIM_HASH_MISS_THRES_TIMEOUT";
362 case SIR_LIM_UPDATE_OLBC_CACHEL_TIMEOUT:
363 return "SIR_LIM_UPDATE_OLBC_CACHEL_TIMEOUT";
364 case SIR_LIM_CNF_WAIT_TIMEOUT:
365 return "SIR_LIM_CNF_WAIT_TIMEOUT";
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800366 case SIR_LIM_FT_PREAUTH_RSP_TIMEOUT:
367 return "SIR_LIM_FT_PREAUTH_RSP_TIMEOUT";
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800368 case WNI_CFG_PARAM_UPDATE_IND:
369 return "WNI_CFG_PARAM_UPDATE_IND";
370 case WNI_CFG_DNLD_REQ:
371 return "WNI_CFG_DNLD_REQ";
372 case WNI_CFG_DNLD_CNF:
373 return "WNI_CFG_DNLD_CNF";
374 case WNI_CFG_GET_RSP:
375 return "WNI_CFG_GET_RSP";
376 case WNI_CFG_SET_CNF:
377 return "WNI_CFG_SET_CNF";
378 case WNI_CFG_GET_ATTRIB_RSP:
379 return "WNI_CFG_GET_ATTRIB_RSP";
380 case WNI_CFG_ADD_GRP_ADDR_CNF:
381 return "WNI_CFG_ADD_GRP_ADDR_CNF";
382 case WNI_CFG_DEL_GRP_ADDR_CNF:
383 return "WNI_CFG_DEL_GRP_ADDR_CNF";
384 case ANI_CFG_GET_RADIO_STAT_RSP:
385 return "ANI_CFG_GET_RADIO_STAT_RSP";
386 case ANI_CFG_GET_PER_STA_STAT_RSP:
387 return "ANI_CFG_GET_PER_STA_STAT_RSP";
388 case ANI_CFG_GET_AGG_STA_STAT_RSP:
389 return "ANI_CFG_GET_AGG_STA_STAT_RSP";
390 case ANI_CFG_CLEAR_STAT_RSP:
391 return "ANI_CFG_CLEAR_STAT_RSP";
392 case WNI_CFG_DNLD_RSP:
393 return "WNI_CFG_DNLD_RSP";
394 case WNI_CFG_GET_REQ:
395 return "WNI_CFG_GET_REQ";
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800396 case eWNI_PMC_ENTER_IMPS_RSP:
397 return "eWNI_PMC_ENTER_IMPS_RSP";
398 case eWNI_PMC_EXIT_IMPS_RSP:
399 return "eWNI_PMC_EXIT_IMPS_RSP";
400 case eWNI_PMC_ENTER_BMPS_RSP:
401 return "eWNI_PMC_ENTER_BMPS_RSP";
402 case eWNI_PMC_EXIT_BMPS_RSP:
403 return "eWNI_PMC_EXIT_BMPS_RSP";
404 case eWNI_PMC_EXIT_BMPS_IND:
405 return "eWNI_PMC_EXIT_BMPS_IND";
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -0800406#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800407 case eWNI_SME_GET_TSM_STATS_REQ:
408 return "eWNI_SME_GET_TSM_STATS_REQ";
409 case eWNI_SME_GET_TSM_STATS_RSP:
410 return "eWNI_SME_GET_TSM_STATS_RSP";
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -0800411#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800412 case eWNI_SME_CSA_OFFLOAD_EVENT:
413 return "eWNI_SME_CSA_OFFLOAD_EVENT";
414 case eWNI_SME_SET_HW_MODE_REQ:
415 return "eWNI_SME_SET_HW_MODE_REQ";
416 case eWNI_SME_SET_HW_MODE_RESP:
417 return "eWNI_SME_SET_HW_MODE_RESP";
418 case eWNI_SME_HW_MODE_TRANS_IND:
419 return "eWNI_SME_HW_MODE_TRANS_IND";
420 default:
421 return "INVALID SME message";
422 }
423#endif
424 return "";
425}
426
427char *lim_result_code_str(tSirResultCodes resultCode)
428{
429 switch (resultCode) {
430 case eSIR_SME_SUCCESS:
431 return "eSIR_SME_SUCCESS";
Abhishek Singh4294f802017-08-10 16:37:07 +0530432 case eSIR_LOGE_EXCEPTION:
433 return "eSIR_LOGE_EXCEPTION";
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800434 case eSIR_SME_INVALID_PARAMETERS:
435 return "eSIR_SME_INVALID_PARAMETERS";
436 case eSIR_SME_UNEXPECTED_REQ_RESULT_CODE:
437 return "eSIR_SME_UNEXPECTED_REQ_RESULT_CODE";
438 case eSIR_SME_RESOURCES_UNAVAILABLE:
439 return "eSIR_SME_RESOURCES_UNAVAILABLE";
440 case eSIR_SME_SCAN_FAILED:
441 return "eSIR_SME_SCAN_FAILED";
442 case eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED:
443 return "eSIR_SME_BSS_ALREADY_STARTED_OR_JOINED";
444 case eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE:
445 return "eSIR_SME_LOST_LINK_WITH_PEER_RESULT_CODE";
446 case eSIR_SME_REFUSED:
447 return "eSIR_SME_REFUSED";
448 case eSIR_SME_JOIN_TIMEOUT_RESULT_CODE:
449 return "eSIR_SME_JOIN_TIMEOUT_RESULT_CODE";
450 case eSIR_SME_AUTH_TIMEOUT_RESULT_CODE:
451 return "eSIR_SME_AUTH_TIMEOUT_RESULT_CODE";
452 case eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE:
453 return "eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE";
454 case eSIR_SME_REASSOC_TIMEOUT_RESULT_CODE:
455 return "eSIR_SME_REASSOC_TIMEOUT_RESULT_CODE";
456 case eSIR_SME_MAX_NUM_OF_PRE_AUTH_REACHED:
457 return "eSIR_SME_MAX_NUM_OF_PRE_AUTH_REACHED";
458 case eSIR_SME_AUTH_REFUSED:
459 return "eSIR_SME_AUTH_REFUSED";
460 case eSIR_SME_INVALID_WEP_DEFAULT_KEY:
461 return "eSIR_SME_INVALID_WEP_DEFAULT_KEY";
462 case eSIR_SME_ASSOC_REFUSED:
463 return "eSIR_SME_ASSOC_REFUSED";
464 case eSIR_SME_REASSOC_REFUSED:
465 return "eSIR_SME_REASSOC_REFUSED";
466 case eSIR_SME_STA_NOT_AUTHENTICATED:
467 return "eSIR_SME_STA_NOT_AUTHENTICATED";
468 case eSIR_SME_STA_NOT_ASSOCIATED:
469 return "eSIR_SME_STA_NOT_ASSOCIATED";
470 case eSIR_SME_ALREADY_JOINED_A_BSS:
471 return "eSIR_SME_ALREADY_JOINED_A_BSS";
472 case eSIR_SME_MORE_SCAN_RESULTS_FOLLOW:
473 return "eSIR_SME_MORE_SCAN_RESULTS_FOLLOW";
474 case eSIR_SME_INVALID_ASSOC_RSP_RXED:
475 return "eSIR_SME_INVALID_ASSOC_RSP_RXED";
476 case eSIR_SME_MIC_COUNTER_MEASURES:
477 return "eSIR_SME_MIC_COUNTER_MEASURES";
478 case eSIR_SME_ADDTS_RSP_TIMEOUT:
479 return "eSIR_SME_ADDTS_RSP_TIMEOUT";
480 case eSIR_SME_CHANNEL_SWITCH_FAIL:
481 return "eSIR_SME_CHANNEL_SWITCH_FAIL";
482 case eSIR_SME_HAL_SCAN_INIT_FAILED:
483 return "eSIR_SME_HAL_SCAN_INIT_FAILED";
484 case eSIR_SME_HAL_SCAN_END_FAILED:
485 return "eSIR_SME_HAL_SCAN_END_FAILED";
486 case eSIR_SME_HAL_SCAN_FINISH_FAILED:
487 return "eSIR_SME_HAL_SCAN_FINISH_FAILED";
488 case eSIR_SME_HAL_SEND_MESSAGE_FAIL:
489 return "eSIR_SME_HAL_SEND_MESSAGE_FAIL";
490
491 default:
492 return "INVALID resultCode";
493 }
494}
495
Jeff Johnsond01da6b2018-12-02 12:10:22 -0800496void lim_print_msg_name(struct mac_context *mac, uint16_t logLevel, uint32_t msgType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800497{
Srinivas Girigowda4bc512b2017-03-26 22:12:58 -0700498 pe_debug("Msg: %s", lim_msg_str(msgType));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800499}
500
501/**
Naveen Rawate6ddcaa2016-02-05 16:50:18 -0800502 * lim_init_mlm() - This function is called by limProcessSmeMessages() to
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800503 * initialize MLM state machine on STA
Jeff Johnson0a0f42a2018-11-21 20:42:36 -0800504 * @mac: Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800505 *
Naveen Rawate6ddcaa2016-02-05 16:50:18 -0800506 * @Return: Status of operation
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800507 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -0800508QDF_STATUS lim_init_mlm(struct mac_context *mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800509{
510 uint32_t retVal;
511
Jeff Johnson0a0f42a2018-11-21 20:42:36 -0800512 mac->lim.gLimTimersCreated = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800513
Jeff Johnson0a0f42a2018-11-21 20:42:36 -0800514 MTRACE(mac_trace(mac, TRACE_CODE_MLM_STATE, NO_SESSION,
515 mac->lim.gLimMlmState));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800516
Naveen Rawate6ddcaa2016-02-05 16:50:18 -0800517 /* Initialize number of pre-auth contexts */
Jeff Johnson0a0f42a2018-11-21 20:42:36 -0800518 mac->lim.gLimNumPreAuthContexts = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800519
Naveen Rawate6ddcaa2016-02-05 16:50:18 -0800520 /* Initialize MAC based Authentication STA list */
Jeff Johnson0a0f42a2018-11-21 20:42:36 -0800521 lim_init_pre_auth_list(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800522
523 /* Create timers used by LIM */
Jeff Johnson0a0f42a2018-11-21 20:42:36 -0800524 retVal = lim_create_timers(mac);
Naveen Rawate6ddcaa2016-02-05 16:50:18 -0800525 if (retVal != TX_SUCCESS) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +0530526 pe_err("lim_create_timers Failed");
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700527 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800528 }
Naveen Rawate6ddcaa2016-02-05 16:50:18 -0800529
Jeff Johnson0a0f42a2018-11-21 20:42:36 -0800530 mac->lim.gLimTimersCreated = 1;
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700531 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800532} /*** end lim_init_mlm() ***/
533
Jeff Johnsond01da6b2018-12-02 12:10:22 -0800534void lim_deactivate_timers(struct mac_context *mac_ctx)
yeshwanth sriram guntuka7112fad2017-07-27 19:00:08 +0530535{
536 uint32_t n;
537 tLimTimers *lim_timer = &mac_ctx->lim.limTimers;
538
Abhishek Singh748d8a22017-08-21 15:19:37 +0530539 lim_deactivate_timers_host_roam(mac_ctx);
yeshwanth sriram guntuka7112fad2017-07-27 19:00:08 +0530540
yeshwanth sriram guntuka7112fad2017-07-27 19:00:08 +0530541 /* Deactivate channel switch timer. */
542 tx_timer_deactivate(&lim_timer->gLimChannelSwitchTimer);
543
544 /* Deactivate addts response timer. */
545 tx_timer_deactivate(&lim_timer->gLimAddtsRspTimer);
546
Abhishek Singh6a730172017-12-29 14:07:21 +0530547 if (tx_timer_running(&lim_timer->gLimJoinFailureTimer)) {
548 pe_err("Join failure timer running call the timeout API");
549 /* Cleanup as if join timer expired */
Abhishek Singh99c70a02018-02-05 11:59:53 +0530550 lim_timer_handler(mac_ctx, SIR_LIM_JOIN_FAIL_TIMEOUT);
Abhishek Singh6a730172017-12-29 14:07:21 +0530551 }
yeshwanth sriram guntuka7112fad2017-07-27 19:00:08 +0530552 /* Deactivate Join failure timer. */
553 tx_timer_deactivate(&lim_timer->gLimJoinFailureTimer);
554
555 /* Deactivate Periodic Join Probe Request timer. */
556 tx_timer_deactivate(&lim_timer->gLimPeriodicJoinProbeReqTimer);
557
558 /* Deactivate Auth Retry timer. */
559 tx_timer_deactivate
560 (&lim_timer->g_lim_periodic_auth_retry_timer);
561
Abhishek Singh6a730172017-12-29 14:07:21 +0530562 if (tx_timer_running(&lim_timer->gLimAssocFailureTimer)) {
563 pe_err("Assoc failure timer running call the timeout API");
564 /* Cleanup as if assoc timer expired */
Abhishek Singh99c70a02018-02-05 11:59:53 +0530565 lim_assoc_failure_timer_handler(mac_ctx, LIM_ASSOC);
Abhishek Singh6a730172017-12-29 14:07:21 +0530566 }
yeshwanth sriram guntuka7112fad2017-07-27 19:00:08 +0530567 /* Deactivate Association failure timer. */
568 tx_timer_deactivate(&lim_timer->gLimAssocFailureTimer);
569
Abhishek Singh6a730172017-12-29 14:07:21 +0530570 if (tx_timer_running(&mac_ctx->lim.limTimers.gLimAuthFailureTimer)) {
571 pe_err("Auth failure timer running call the timeout API");
572 /* Cleanup as if auth timer expired */
Abhishek Singh99c70a02018-02-05 11:59:53 +0530573 lim_timer_handler(mac_ctx, SIR_LIM_AUTH_FAIL_TIMEOUT);
Abhishek Singh6a730172017-12-29 14:07:21 +0530574 }
yeshwanth sriram guntuka7112fad2017-07-27 19:00:08 +0530575 /* Deactivate Authentication failure timer. */
576 tx_timer_deactivate(&lim_timer->gLimAuthFailureTimer);
577
578 /* Deactivate wait-for-probe-after-Heartbeat timer. */
579 tx_timer_deactivate(&lim_timer->gLimProbeAfterHBTimer);
580
yeshwanth sriram guntuka7112fad2017-07-27 19:00:08 +0530581 /* Deactivate cnf wait timer */
582 for (n = 0; n < (mac_ctx->lim.maxStation + 1); n++) {
583 tx_timer_deactivate(&lim_timer->gpLimCnfWaitTimer[n]);
584 }
585
586 /* Deactivate any Authentication response timers */
587 lim_delete_pre_auth_list(mac_ctx);
588
589 tx_timer_deactivate(&lim_timer->gLimUpdateOlbcCacheTimer);
590 tx_timer_deactivate(&lim_timer->gLimPreAuthClnupTimer);
591
Yeshwanth Sriram Guntuka0e5b1eb2018-11-01 14:25:40 +0530592 if (tx_timer_running(&lim_timer->gLimDisassocAckTimer)) {
593 pe_err("Disassoc timer running call the timeout API");
594 lim_timer_handler(mac_ctx, SIR_LIM_DISASSOC_ACK_TIMEOUT);
595 }
yeshwanth sriram guntuka7112fad2017-07-27 19:00:08 +0530596 tx_timer_deactivate(&lim_timer->gLimDisassocAckTimer);
597
Yeshwanth Sriram Guntuka0e5b1eb2018-11-01 14:25:40 +0530598 if (tx_timer_running(&lim_timer->gLimDeauthAckTimer)) {
599 pe_err("Deauth timer running call the timeout API");
600 lim_timer_handler(mac_ctx, SIR_LIM_DEAUTH_ACK_TIMEOUT);
601 }
yeshwanth sriram guntuka7112fad2017-07-27 19:00:08 +0530602 tx_timer_deactivate(&lim_timer->gLimDeauthAckTimer);
603
yeshwanth sriram guntuka7112fad2017-07-27 19:00:08 +0530604 tx_timer_deactivate(&lim_timer->
yeshwanth sriram guntuka7112fad2017-07-27 19:00:08 +0530605 gLimActiveToPassiveChannelTimer);
Padma, Santhosh Kumarc56735f2017-09-13 18:14:26 +0530606
607 tx_timer_deactivate(&lim_timer->sae_auth_timer);
yeshwanth sriram guntuka7112fad2017-07-27 19:00:08 +0530608}
609
610
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800611/**
612 * lim_cleanup_mlm() - This function is called to cleanup
613 * @mac_ctx: Pointer to Global MAC structure
614 *
615 * Function is called to cleanup any resources allocated by the MLM
616 * state machine.
617 *
618 * Return: none
619 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -0800620void lim_cleanup_mlm(struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800621{
622 uint32_t n;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -0700623
Naveen Rawate6ddcaa2016-02-05 16:50:18 -0800624 tLimPreAuthNode **pAuthNode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800625 tLimTimers *lim_timer = NULL;
626
627 if (mac_ctx->lim.gLimTimersCreated == 1) {
628 lim_timer = &mac_ctx->lim.limTimers;
629
yeshwanth sriram guntuka7112fad2017-07-27 19:00:08 +0530630 lim_deactivate_timers(mac_ctx);
Abhishek Singh748d8a22017-08-21 15:19:37 +0530631
632 lim_delete_timers_host_roam(mac_ctx);
yeshwanth sriram guntuka7112fad2017-07-27 19:00:08 +0530633 /* Delete channel switch timer. */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800634 tx_timer_delete(&lim_timer->gLimChannelSwitchTimer);
635
yeshwanth sriram guntuka7112fad2017-07-27 19:00:08 +0530636 /* Delete addts response timer. */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800637 tx_timer_delete(&lim_timer->gLimAddtsRspTimer);
638
yeshwanth sriram guntuka7112fad2017-07-27 19:00:08 +0530639 /* Delete Join failure timer. */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800640 tx_timer_delete(&lim_timer->gLimJoinFailureTimer);
641
yeshwanth sriram guntuka7112fad2017-07-27 19:00:08 +0530642 /* Delete Periodic Join Probe Request timer. */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800643 tx_timer_delete(&lim_timer->gLimPeriodicJoinProbeReqTimer);
644
yeshwanth sriram guntuka7112fad2017-07-27 19:00:08 +0530645 /* Delete Auth Retry timer. */
Abhishek Singh7d3bc3e2016-02-03 17:45:01 +0530646 tx_timer_delete(&lim_timer->g_lim_periodic_auth_retry_timer);
647
yeshwanth sriram guntuka7112fad2017-07-27 19:00:08 +0530648 /* Delete Association failure timer. */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800649 tx_timer_delete(&lim_timer->gLimAssocFailureTimer);
650
yeshwanth sriram guntuka7112fad2017-07-27 19:00:08 +0530651 /* Delete Authentication failure timer. */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800652 tx_timer_delete(&lim_timer->gLimAuthFailureTimer);
653
yeshwanth sriram guntuka7112fad2017-07-27 19:00:08 +0530654 /* Delete wait-for-probe-after-Heartbeat timer. */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800655 tx_timer_delete(&lim_timer->gLimProbeAfterHBTimer);
656
yeshwanth sriram guntuka7112fad2017-07-27 19:00:08 +0530657 /* Delete cnf wait timer */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800658 for (n = 0; n < (mac_ctx->lim.maxStation + 1); n++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800659 tx_timer_delete(&lim_timer->gpLimCnfWaitTimer[n]);
660 }
661
662 pAuthNode = mac_ctx->lim.gLimPreAuthTimerTable.pTable;
663
Naveen Rawate6ddcaa2016-02-05 16:50:18 -0800664 /* Delete any Auth rsp timers, which might have been started */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800665 for (n = 0; n < mac_ctx->lim.gLimPreAuthTimerTable.numEntry;
Naveen Rawate6ddcaa2016-02-05 16:50:18 -0800666 n++)
667 tx_timer_delete(&pAuthNode[n]->timer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800668
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800669 tx_timer_delete(&lim_timer->gLimUpdateOlbcCacheTimer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800670 tx_timer_delete(&lim_timer->gLimPreAuthClnupTimer);
671
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800672 tx_timer_delete(&lim_timer->gLimDisassocAckTimer);
673
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800674 tx_timer_delete(&lim_timer->gLimDeauthAckTimer);
675
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800676 tx_timer_delete(&lim_timer->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800677 gLimActiveToPassiveChannelTimer);
678
Padma, Santhosh Kumarc56735f2017-09-13 18:14:26 +0530679 tx_timer_delete(&lim_timer->sae_auth_timer);
680
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800681 mac_ctx->lim.gLimTimersCreated = 0;
682 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800683} /*** end lim_cleanup_mlm() ***/
684
685/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800686 * lim_is_addr_bc()
687 *
688 ***FUNCTION:
689 * This function is called in various places within LIM code
690 * to determine whether passed MAC address is a broadcast or not
691 *
692 ***LOGIC:
693 *
694 ***ASSUMPTIONS:
695 * NA
696 *
697 ***NOTE:
698 * NA
699 *
700 * @param macAddr Indicates MAC address that need to be determined
701 * whether it is Broadcast address or not
702 *
703 * @return true if passed address is Broadcast address else false
704 */
705
706uint8_t lim_is_addr_bc(tSirMacAddr macAddr)
707{
708 int i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -0700709
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800710 for (i = 0; i < 6; i++) {
711 if ((macAddr[i] & 0xFF) != 0xFF)
712 return false;
713 }
714
715 return true;
716} /****** end lim_is_addr_bc() ******/
717
718/**
719 * lim_is_group_addr()
720 *
721 ***FUNCTION:
722 * This function is called in various places within LIM code
723 * to determine whether passed MAC address is a group address or not
724 *
725 ***LOGIC:
726 * If least significant bit of first octet of the MAC address is
727 * set to 1, it is a Group address.
728 *
729 ***ASSUMPTIONS:
730 * NA
731 *
732 ***NOTE:
733 * NA
734 *
735 * @param macAddr Indicates MAC address that need to be determined
736 * whether it is Group address or not
737 *
738 * @return true if passed address is Group address else false
739 */
740
741uint8_t lim_is_group_addr(tSirMacAddr macAddr)
742{
743 if ((macAddr[0] & 0x01) == 0x01)
744 return true;
745 else
746 return false;
747} /****** end lim_is_group_addr() ******/
748
749/**
750 * lim_print_mac_addr()
751 *
752 ***FUNCTION:
753 * This function is called to print passed MAC address
754 * in : format.
755 *
756 ***LOGIC:
757 *
758 ***ASSUMPTIONS:
759 * NA
760 *
761 ***NOTE:
762 * @param macAddr - MacAddr to be printed
763 * @param logLevel - Loglevel to be used
764 *
765 * @return None.
766 */
767
Jeff Johnsond01da6b2018-12-02 12:10:22 -0800768void lim_print_mac_addr(struct mac_context *mac, tSirMacAddr macAddr, uint8_t logLevel)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800769{
Srinivas Girigowda4bc512b2017-03-26 22:12:58 -0700770 pe_debug(MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800771} /****** end lim_print_mac_addr() ******/
772
773/*
774 * lim_reset_deferred_msg_q()
775 *
776 ***FUNCTION:
777 * This function resets the deferred message queue parameters.
778 *
779 ***PARAMS:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -0800780 * @param mac - Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800781 *
782 ***LOGIC:
783 *
784 ***ASSUMPTIONS:
785 * NA
786 *
787 ***NOTE:
788 * NA
789 *
790 ***RETURNS:
791 * None
792 */
793
Jeff Johnsond01da6b2018-12-02 12:10:22 -0800794void lim_reset_deferred_msg_q(struct mac_context *mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800795{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700796 struct scheduler_msg *read_msg = {0};
Nirav Shah9bf81572016-04-19 16:42:52 +0530797
Jeff Johnson0a0f42a2018-11-21 20:42:36 -0800798 if (mac->lim.gLimDeferredMsgQ.size > 0) {
799 while ((read_msg = lim_read_deferred_msg_q(mac)) != NULL) {
800 pe_free_msg(mac, read_msg);
Nirav Shah9bf81572016-04-19 16:42:52 +0530801 }
802 }
803
Jeff Johnson0a0f42a2018-11-21 20:42:36 -0800804 mac->lim.gLimDeferredMsgQ.size =
805 mac->lim.gLimDeferredMsgQ.write =
806 mac->lim.gLimDeferredMsgQ.read = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800807
808}
809
810#define LIM_DEFERRED_Q_CHECK_THRESHOLD (MAX_DEFERRED_QUEUE_LEN/2)
811#define LIM_MAX_NUM_MGMT_FRAME_DEFERRED (MAX_DEFERRED_QUEUE_LEN/2)
812
813/**
814 * lim_write_deferred_msg_q() - This function queues up a deferred message
815 *
816 * @mac_ctx: Pointer to Global MAC structure
817 * @lim_msg: a LIM message
818 *
819 * Function queues up a deferred message for later processing on the
820 * STA side.
821 *
822 * Return: none
823 */
824
Jeff Johnsond01da6b2018-12-02 12:10:22 -0800825uint8_t lim_write_deferred_msg_q(struct mac_context *mac_ctx,
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800826 struct scheduler_msg *lim_msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800827{
Nirav Shah99923a82018-06-23 14:35:49 +0530828 uint8_t type = 0, subtype = 0;
Sandeep Puligillad9f88ce2017-04-11 19:41:57 -0700829
Nishank Aggarwal0402b432017-03-24 19:17:36 +0530830 pe_debug("Queue a deferred message size: %d write: %d - type: 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800831 mac_ctx->lim.gLimDeferredMsgQ.size,
832 mac_ctx->lim.gLimDeferredMsgQ.write,
833 lim_msg->type);
834
835 /* check if the deferred message queue is full */
836 if (mac_ctx->lim.gLimDeferredMsgQ.size >= MAX_DEFERRED_QUEUE_LEN) {
837 if (!(mac_ctx->lim.deferredMsgCnt & 0xF)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +0530838 pe_err("queue->MsgQ full Msg: %d Msgs Failed: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800839 lim_msg->type,
840 ++mac_ctx->lim.deferredMsgCnt);
Abhishek Singh5ea86532016-04-27 14:10:53 +0530841 cds_flush_logs(WLAN_LOG_TYPE_NON_FATAL,
842 WLAN_LOG_INDICATOR_HOST_DRIVER,
843 WLAN_LOG_REASON_QUEUE_FULL,
844 true, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800845 } else {
846 mac_ctx->lim.deferredMsgCnt++;
847 }
848 return TX_QUEUE_FULL;
849 }
850
851 /*
852 * In the application, there should not be more than 1 message get
853 * queued up. If happens, flags a warning. In the future, this can
854 * happen.
855 */
856 if (mac_ctx->lim.gLimDeferredMsgQ.size > 0)
Nishank Aggarwal0402b432017-03-24 19:17:36 +0530857 pe_debug("%d Deferred Msg type: 0x%x scan: %d global sme: %d global mlme: %d addts: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800858 mac_ctx->lim.gLimDeferredMsgQ.size,
859 lim_msg->type,
860 lim_is_system_in_scan_state(mac_ctx),
861 mac_ctx->lim.gLimSmeState,
862 mac_ctx->lim.gLimMlmState,
863 mac_ctx->lim.gLimAddtsSent);
864
Sandeep Puligillad9f88ce2017-04-11 19:41:57 -0700865 if (SIR_BB_XPORT_MGMT_MSG == lim_msg->type) {
866 lim_util_get_type_subtype(lim_msg->bodyptr,
867 &type, &subtype);
Jeff Johnson47d75242018-05-12 15:58:53 -0700868 pe_debug(" Deferred management type %d subtype %d ",
Sandeep Puligillad9f88ce2017-04-11 19:41:57 -0700869 type, subtype);
870 }
871
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800872 /*
873 * To prevent the deferred Q is full of management frames, only give
874 * them certain space
875 */
876 if ((SIR_BB_XPORT_MGMT_MSG == lim_msg->type) &&
877 (LIM_DEFERRED_Q_CHECK_THRESHOLD <
878 mac_ctx->lim.gLimDeferredMsgQ.size)) {
879 uint16_t idx, count = 0;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -0700880
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800881 for (idx = 0; idx < mac_ctx->lim.gLimDeferredMsgQ.size;
882 idx++) {
883 if (SIR_BB_XPORT_MGMT_MSG ==
884 mac_ctx->lim.gLimDeferredMsgQ.
885 deferredQueue[idx].type) {
886 count++;
887 }
888 }
889 if (LIM_MAX_NUM_MGMT_FRAME_DEFERRED < count) {
890 /*
891 * We reach the quota for management frames,
892 * drop this one
893 */
Nishank Aggarwal0402b432017-03-24 19:17:36 +0530894 pe_warn("Too many queue->MsgQ Msg: %d count: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800895 lim_msg->type, count);
896 /* Return error, caller knows what to do */
897 return TX_QUEUE_FULL;
898 }
899 }
900
901 ++mac_ctx->lim.gLimDeferredMsgQ.size;
902
903 /* reset the count here since we are able to defer the message */
904 if (mac_ctx->lim.deferredMsgCnt != 0)
905 mac_ctx->lim.deferredMsgCnt = 0;
906
907 /* if the write pointer hits the end of the queue, rewind it */
908 if (mac_ctx->lim.gLimDeferredMsgQ.write >= MAX_DEFERRED_QUEUE_LEN)
909 mac_ctx->lim.gLimDeferredMsgQ.write = 0;
910
911 /* save the message to the queue and advanced the write pointer */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530912 qdf_mem_copy((uint8_t *) &mac_ctx->lim.gLimDeferredMsgQ.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800913 deferredQueue[mac_ctx->lim.gLimDeferredMsgQ.write++],
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800914 (uint8_t *) lim_msg,
915 sizeof(struct scheduler_msg));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800916 return TX_SUCCESS;
917
918}
919
920/*
921 * lim_read_deferred_msg_q()
922 *
923 ***FUNCTION:
924 * This function dequeues a deferred message for processing on the
925 * STA side.
926 *
927 ***PARAMS:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -0800928 * @param mac - Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800929 *
930 ***LOGIC:
931 *
932 ***ASSUMPTIONS:
933 * NA
934 *
935 ***NOTE:
936 *
937 *
938 ***RETURNS:
939 * Returns the message at the head of the deferred message queue
940 */
941
Jeff Johnsond01da6b2018-12-02 12:10:22 -0800942struct scheduler_msg *lim_read_deferred_msg_q(struct mac_context *mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800943{
Rajeev Kumar37d478b2017-04-17 16:59:28 -0700944 struct scheduler_msg *msg = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800945
946 /*
947 ** check any messages left. If no, return
948 **/
Jeff Johnson0a0f42a2018-11-21 20:42:36 -0800949 if (mac->lim.gLimDeferredMsgQ.size <= 0)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800950 return NULL;
951
952 /*
953 ** decrement the queue size
954 **/
Jeff Johnson0a0f42a2018-11-21 20:42:36 -0800955 mac->lim.gLimDeferredMsgQ.size--;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800956
957 /*
958 ** retrieve the message from the head of the queue
959 **/
960 msg =
Jeff Johnson0a0f42a2018-11-21 20:42:36 -0800961 &mac->lim.gLimDeferredMsgQ.deferredQueue[mac->lim.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800962 gLimDeferredMsgQ.read];
963
964 /*
965 ** advance the read pointer
966 **/
Jeff Johnson0a0f42a2018-11-21 20:42:36 -0800967 mac->lim.gLimDeferredMsgQ.read++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800968
969 /*
970 ** if the read pointer hits the end of the queue, rewind it
971 **/
Jeff Johnson0a0f42a2018-11-21 20:42:36 -0800972 if (mac->lim.gLimDeferredMsgQ.read >= MAX_DEFERRED_QUEUE_LEN)
973 mac->lim.gLimDeferredMsgQ.read = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800974
Nishank Aggarwal0402b432017-03-24 19:17:36 +0530975 pe_debug("DeQueue a deferred message size: %d read: %d - type: 0x%x",
Jeff Johnson0a0f42a2018-11-21 20:42:36 -0800976 mac->lim.gLimDeferredMsgQ.size,
977 mac->lim.gLimDeferredMsgQ.read, msg->type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800978
Nishank Aggarwal0402b432017-03-24 19:17:36 +0530979 pe_debug("DQ msg -- scan: %d global sme: %d global mlme: %d addts: %d",
Jeff Johnson0a0f42a2018-11-21 20:42:36 -0800980 lim_is_system_in_scan_state(mac), mac->lim.gLimSmeState,
981 mac->lim.gLimMlmState, mac->lim.gLimAddtsSent);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800982
983 return msg;
984}
985
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700986QDF_STATUS
Jeff Johnsond01da6b2018-12-02 12:10:22 -0800987lim_sys_process_mmh_msg_api(struct mac_context *mac,
Rajeev Kumarfeb96382017-01-22 19:42:09 -0800988 struct scheduler_msg *pMsg, uint8_t qType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800989{
990 /* FIXME */
Jeff Johnson0a0f42a2018-11-21 20:42:36 -0800991 sys_process_mmh_msg(mac, pMsg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -0700992 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800993}
994
995/*
996 * lim_handle_update_olbc_cache() - This function update olbc cache
997 *
998 * @mac_ctx: Pointer to Global MAC structure
999 *
1000 * Function updates olbc cache
1001 *
1002 * Return: none
1003 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08001004void lim_handle_update_olbc_cache(struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001005{
1006 int i;
1007 static int enable;
1008 tUpdateBeaconParams beaconParams;
1009
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001010 struct pe_session *pe_session = lim_is_ap_session_active(mac_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001011
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001012 if (pe_session == NULL) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301013 pe_err(" Session not found");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001014 return;
1015 }
1016
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001017 if (pe_session->is_session_obss_offload_enabled) {
Arif Hussain1513cb22018-01-05 19:56:31 -08001018 pe_debug("protection offloaded");
1019 return;
1020 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301021 qdf_mem_set((uint8_t *) &beaconParams, sizeof(tUpdateBeaconParams), 0);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001022 beaconParams.bssIdx = pe_session->bssIdx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001023
1024 beaconParams.paramChangeBitmap = 0;
1025 /*
1026 * This is doing a 2 pass check. The first pass is to invalidate
1027 * all the cache entries. The second pass is to decide whether to
1028 * disable protection.
1029 */
1030 if (!enable) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301031 pe_debug("Resetting OLBC cache");
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001032 pe_session->gLimOlbcParams.numSta = 0;
1033 pe_session->gLimOverlap11gParams.numSta = 0;
1034 pe_session->gLimOverlapHt20Params.numSta = 0;
1035 pe_session->gLimNonGfParams.numSta = 0;
1036 pe_session->gLimLsigTxopParams.numSta = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001037
1038 for (i = 0; i < LIM_PROT_STA_OVERLAP_CACHE_SIZE; i++)
1039 mac_ctx->lim.protStaOverlapCache[i].active = false;
1040
1041 enable = 1;
1042 } else {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001043 if ((!pe_session->gLimOlbcParams.numSta) &&
1044 (pe_session->gLimOlbcParams.protectionEnabled) &&
1045 (!pe_session->gLim11bParams.protectionEnabled)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301046 pe_debug("Overlap cache clear and no 11B STA set");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001047 lim_enable11g_protection(mac_ctx, false, true,
1048 &beaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001049 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001050 }
1051
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001052 if ((!pe_session->gLimOverlap11gParams.numSta) &&
1053 (pe_session->gLimOverlap11gParams.protectionEnabled)
1054 && (!pe_session->gLim11gParams.protectionEnabled)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301055 pe_debug("Overlap cache clear and no 11G STA set");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001056 lim_enable_ht_protection_from11g(mac_ctx, false, true,
1057 &beaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001058 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001059 }
1060
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001061 if ((!pe_session->gLimOverlapHt20Params.numSta) &&
1062 (pe_session->gLimOverlapHt20Params.protectionEnabled)
1063 && (!pe_session->gLimHt20Params.protectionEnabled)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301064 pe_debug("Overlap cache clear and no HT20 STA set");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001065 lim_enable11g_protection(mac_ctx, false, true,
1066 &beaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001067 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001068 }
1069
1070 enable = 0;
1071 }
1072
1073 if ((false == mac_ctx->sap.SapDfsInfo.is_dfs_cac_timer_running)
1074 && beaconParams.paramChangeBitmap) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001075 sch_set_fixed_beacon_fields(mac_ctx, pe_session);
1076 lim_send_beacon_params(mac_ctx, &beaconParams, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001077 }
1078 /* Start OLBC timer */
1079 if (tx_timer_activate(&mac_ctx->lim.limTimers.gLimUpdateOlbcCacheTimer)
1080 != TX_SUCCESS)
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301081 pe_err("tx_timer_activate failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001082}
1083
1084/**
1085 * lim_is_null_ssid() - This function checks if ssid supplied is Null SSID
1086 * @ssid: pointer to tSirMacSSid
1087 *
1088 * Function checks if ssid supplied is Null SSID
1089 *
1090 * Return: none
1091 */
1092
1093uint8_t lim_is_null_ssid(tSirMacSSid *ssid)
1094{
1095 uint8_t fnull_ssid = false;
1096 uint32_t ssid_len;
1097 uint8_t *ssid_str;
1098
1099 if (0 == ssid->length) {
1100 fnull_ssid = true;
1101 return fnull_ssid;
1102 }
1103 /* If the first charactes is space, then check if all
1104 * characters in SSID are spaces to consider it as NULL SSID
1105 */
1106 if ((ASCII_SPACE_CHARACTER == ssid->ssId[0]) &&
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301107 (ssid->length == 1)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001108 fnull_ssid = true;
1109 return fnull_ssid;
1110 } else {
1111 /* check if all the charactes in SSID are NULL */
1112 ssid_len = ssid->length;
1113 ssid_str = ssid->ssId;
1114
1115 while (ssid_len) {
1116 if (*ssid_str)
1117 return fnull_ssid;
1118
1119 ssid_str++;
1120 ssid_len--;
1121 }
1122
1123 if (0 == ssid_len) {
1124 fnull_ssid = true;
1125 return fnull_ssid;
1126 }
1127 }
1128
1129 return fnull_ssid;
1130}
1131
1132/** -------------------------------------------------------------
1133 \fn lim_update_prot_sta_params
1134 \brief updates protection related counters.
Jeff Johnsond01da6b2018-12-02 12:10:22 -08001135 \param struct mac_context * mac
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001136 \param tSirMacAddr peerMacAddr
1137 \param tLimProtStaCacheType protStaCacheType
1138 \param tHalBitVal gfSupported
1139 \param tHalBitVal lsigTxopSupported
1140 \return None
1141 -------------------------------------------------------------*/
Jeff Johnson22496442016-10-07 07:34:46 -07001142static void
Jeff Johnsond01da6b2018-12-02 12:10:22 -08001143lim_update_prot_sta_params(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001144 tSirMacAddr peerMacAddr,
1145 tLimProtStaCacheType protStaCacheType,
1146 tHalBitVal gfSupported, tHalBitVal lsigTxopSupported,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001147 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001148{
1149 uint32_t i;
1150
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301151 pe_debug("Associated STA addr is:");
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08001152 lim_print_mac_addr(mac, peerMacAddr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001153
1154 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001155 if (pe_session->protStaCache[i].active) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301156 pe_debug("Addr:");
1157 lim_print_mac_addr
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001158 (mac, pe_session->protStaCache[i].addr,
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301159 LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001160
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301161 if (!qdf_mem_cmp
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001162 (pe_session->protStaCache[i].addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001163 peerMacAddr, sizeof(tSirMacAddr))) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301164 pe_debug("matching cache entry at: %d already active",
1165 i);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001166 return;
1167 }
1168 }
1169 }
1170
1171 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001172 if (!pe_session->protStaCache[i].active)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001173 break;
1174 }
1175
1176 if (i >= LIM_PROT_STA_CACHE_SIZE) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301177 pe_err("No space in ProtStaCache");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001178 return;
1179 }
1180
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001181 qdf_mem_copy(pe_session->protStaCache[i].addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001182 peerMacAddr, sizeof(tSirMacAddr));
1183
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001184 pe_session->protStaCache[i].protStaCacheType = protStaCacheType;
1185 pe_session->protStaCache[i].active = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001186 if (eLIM_PROT_STA_CACHE_TYPE_llB == protStaCacheType) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001187 pe_session->gLim11bParams.numSta++;
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301188 pe_debug("11B,");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001189 } else if (eLIM_PROT_STA_CACHE_TYPE_llG == protStaCacheType) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001190 pe_session->gLim11gParams.numSta++;
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301191 pe_debug("11G,");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001192 } else if (eLIM_PROT_STA_CACHE_TYPE_HT20 == protStaCacheType) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001193 pe_session->gLimHt20Params.numSta++;
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301194 pe_debug("HT20,");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001195 }
1196
1197 if (!gfSupported) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001198 pe_session->gLimNonGfParams.numSta++;
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301199 pe_debug("NonGf,");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001200 }
1201 if (!lsigTxopSupported) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001202 pe_session->gLimLsigTxopParams.numSta++;
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301203 pe_debug("!lsigTxopSupported");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001204 }
1205} /* --------------------------------------------------------------------- */
1206
1207/** -------------------------------------------------------------
1208 \fn lim_decide_ap_protection
1209 \brief Decides all the protection related staiton coexistence and also sets
1210 \ short preamble and short slot appropriately. This function will be called
1211 \ when AP is ready to send assocRsp tp the station joining right now.
Jeff Johnsond01da6b2018-12-02 12:10:22 -08001212 \param struct mac_context * mac
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001213 \param tSirMacAddr peerMacAddr
1214 \return None
1215 -------------------------------------------------------------*/
1216void
Jeff Johnsond01da6b2018-12-02 12:10:22 -08001217lim_decide_ap_protection(struct mac_context *mac, tSirMacAddr peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001218 tpUpdateBeaconParams pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001219 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001220{
1221 uint16_t tmpAid;
1222 tpDphHashNode pStaDs;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001223 enum band_info rfBand = BAND_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001224 uint32_t phyMode;
1225 tLimProtStaCacheType protStaCacheType =
1226 eLIM_PROT_STA_CACHE_TYPE_INVALID;
1227 tHalBitVal gfSupported = eHAL_SET, lsigTxopSupported = eHAL_SET;
1228
1229 pBeaconParams->paramChangeBitmap = 0;
1230 /* check whether to enable protection or not */
1231 pStaDs =
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08001232 dph_lookup_hash_entry(mac, peerMacAddr, &tmpAid,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001233 &pe_session->dph.dphHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001234 if (NULL == pStaDs) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301235 pe_err("pStaDs is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001236 return;
1237 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001238 lim_get_rf_band_new(mac, &rfBand, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001239 /* if we are in 5 GHZ band */
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001240 if (BAND_5G == rfBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001241 /* We are 11N. we need to protect from 11A and Ht20. we don't need any other protection in 5 GHZ. */
1242 /* HT20 case is common between both the bands and handled down as common code. */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001243 if (true == pe_session->htCapability) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001244 /* we are 11N and 11A station is joining. */
1245 /* protection from 11A required. */
1246 if (false == pStaDs->mlmStaContext.htCapability) {
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08001247 lim_update_11a_protection(mac, true, false,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001248 pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001249 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001250 return;
1251 }
1252 }
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001253 } else if (BAND_2G == rfBand) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001254 lim_get_phy_mode(mac, &phyMode, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001255
1256 /* We are 11G. Check if we need protection from 11b Stations. */
1257 if ((phyMode == WNI_CFG_PHY_MODE_11G) &&
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001258 (false == pe_session->htCapability)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001259
1260 if (pStaDs->erpEnabled == eHAL_CLEAR) {
1261 protStaCacheType = eLIM_PROT_STA_CACHE_TYPE_llB;
1262 /* enable protection */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301263 pe_debug("Enabling protection from 11B");
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08001264 lim_enable11g_protection(mac, true, false,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001265 pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001266 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001267 }
1268 }
1269 /* HT station. */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001270 if (true == pe_session->htCapability) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001271 /* check if we need protection from 11b station */
1272 if ((pStaDs->erpEnabled == eHAL_CLEAR) &&
1273 (!pStaDs->mlmStaContext.htCapability)) {
1274 protStaCacheType = eLIM_PROT_STA_CACHE_TYPE_llB;
1275 /* enable protection */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301276 pe_debug("Enabling protection from 11B");
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08001277 lim_enable11g_protection(mac, true, false,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001278 pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001279 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001280 }
1281 /* station being joined is non-11b and non-ht ==> 11g device */
1282 else if (!pStaDs->mlmStaContext.htCapability) {
1283 protStaCacheType = eLIM_PROT_STA_CACHE_TYPE_llG;
1284 /* enable protection */
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08001285 lim_enable_ht_protection_from11g(mac, true, false,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001286 pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001287 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001288 }
1289 /* ERP mode is enabled for the latest station joined */
1290 /* latest station joined is HT capable */
1291 /* This case is being handled in common code (commn between both the bands) below. */
1292 }
1293 }
1294 /* we are HT and HT station is joining. This code is common for both the bands. */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001295 if ((true == pe_session->htCapability) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001296 (true == pStaDs->mlmStaContext.htCapability)) {
1297 if (!pStaDs->htGreenfield) {
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08001298 lim_enable_ht_non_gf_protection(mac, true, false,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001299 pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001300 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001301 gfSupported = eHAL_CLEAR;
1302 }
1303 /* Station joining is HT 20Mhz */
1304 if ((eHT_CHANNEL_WIDTH_20MHZ ==
1305 pStaDs->htSupportedChannelWidthSet) &&
1306 (eHT_CHANNEL_WIDTH_20MHZ !=
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001307 pe_session->htSupportedChannelWidthSet)){
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001308 protStaCacheType = eLIM_PROT_STA_CACHE_TYPE_HT20;
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08001309 lim_enable_ht20_protection(mac, true, false,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001310 pBeaconParams, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001311 }
1312 /* Station joining does not support LSIG TXOP Protection */
1313 if (!pStaDs->htLsigTXOPProtection) {
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08001314 lim_enable_ht_lsig_txop_protection(mac, false, false,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001315 pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001316 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001317 lsigTxopSupported = eHAL_CLEAR;
1318 }
1319 }
1320
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08001321 lim_update_prot_sta_params(mac, peerMacAddr, protStaCacheType,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001322 gfSupported, lsigTxopSupported, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001323
1324 return;
1325}
1326
1327/** -------------------------------------------------------------
1328 \fn lim_enable_overlap11g_protection
1329 \brief wrapper function for setting overlap 11g protection.
Jeff Johnsond01da6b2018-12-02 12:10:22 -08001330 \param struct mac_context * mac
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001331 \param tpUpdateBeaconParams pBeaconParams
1332 \param tpSirMacMgmtHdr pMh
1333 \return None
1334 -------------------------------------------------------------*/
1335void
Jeff Johnsond01da6b2018-12-02 12:10:22 -08001336lim_enable_overlap11g_protection(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001337 tpUpdateBeaconParams pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001338 tpSirMacMgmtHdr pMh, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001339{
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08001340 lim_update_overlap_sta_param(mac, pMh->bssId,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001341 &(pe_session->gLimOlbcParams));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001342
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001343 if (pe_session->gLimOlbcParams.numSta &&
1344 !pe_session->gLimOlbcParams.protectionEnabled) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001345 /* enable protection */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301346 pe_debug("OLBC happens!!!");
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08001347 lim_enable11g_protection(mac, true, true, pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001348 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001349 }
1350}
1351
1352/**
1353 * lim_update_short_preamble() - This function Updates short preamble
1354 * @mac_ctx: pointer to Global MAC structure
1355 * @peer_mac_addr: pointer to tSirMacAddr
1356 * @pbeaconparams: pointer to tpUpdateBeaconParams
Jeff Johnsonc8baa902018-11-18 21:59:07 -08001357 * @psession_entry: pointer to struct pe_session *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001358 *
1359 * Function Updates short preamble if needed when a new station joins
1360 *
1361 * Return: none
1362 */
1363void
Jeff Johnsond01da6b2018-12-02 12:10:22 -08001364lim_update_short_preamble(struct mac_context *mac_ctx, tSirMacAddr peer_mac_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001365 tpUpdateBeaconParams beaconparams,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08001366 struct pe_session *psession_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001367{
1368 uint16_t aid;
1369 tpDphHashNode sta_ds;
1370 uint32_t phy_mode;
1371 uint16_t i;
1372
1373 /* check whether to enable protection or not */
1374 sta_ds =
1375 dph_lookup_hash_entry(mac_ctx, peer_mac_addr, &aid,
1376 &psession_entry->dph.dphHashTable);
1377
1378 lim_get_phy_mode(mac_ctx, &phy_mode, psession_entry);
1379
1380 if (sta_ds == NULL || phy_mode != WNI_CFG_PHY_MODE_11G)
1381 return;
1382
1383 if (sta_ds->shortPreambleEnabled != eHAL_CLEAR)
1384 return;
1385
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301386 pe_debug("Short Preamble is not enabled in Assoc Req from");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001387
Abhishek Singh5d8d7332017-08-10 15:15:24 +05301388 lim_print_mac_addr(mac_ctx, peer_mac_addr, LOGD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001389
1390 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
1391 if (LIM_IS_AP_ROLE(psession_entry) &&
1392 (psession_entry->gLimNoShortParams.
1393 staNoShortCache[i].active) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301394 (!qdf_mem_cmp
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001395 (psession_entry->gLimNoShortParams.
1396 staNoShortCache[i].addr,
1397 peer_mac_addr, sizeof(tSirMacAddr))))
1398 return;
1399 else if (!LIM_IS_AP_ROLE(psession_entry) &&
1400 (mac_ctx->lim.gLimNoShortParams.
1401 staNoShortCache[i].active) &&
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301402 (!qdf_mem_cmp(mac_ctx->lim.gLimNoShortParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001403 staNoShortCache[i].addr,
1404 peer_mac_addr,
1405 sizeof(tSirMacAddr))))
1406 return;
1407 }
1408
1409 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
1410 if (LIM_IS_AP_ROLE(psession_entry) &&
1411 !psession_entry->gLimNoShortParams.
1412 staNoShortCache[i].active)
1413 break;
1414 else if (!mac_ctx->lim.gLimNoShortParams.
1415 staNoShortCache[i].active)
1416 break;
1417 }
1418
1419 if (i >= LIM_PROT_STA_CACHE_SIZE) {
1420 tLimNoShortParams *lim_params =
1421 &psession_entry->gLimNoShortParams;
1422 if (LIM_IS_AP_ROLE(psession_entry)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301423 pe_err("No space in Short cache active: %d sta: %d for sta",
1424 i, lim_params->numNonShortPreambleSta);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001425 lim_print_mac_addr(mac_ctx, peer_mac_addr, LOGE);
1426 return;
1427 } else {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301428 pe_err("No space in Short cache active: %d sta: %d for sta",
1429 i, lim_params->numNonShortPreambleSta);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001430 lim_print_mac_addr(mac_ctx, peer_mac_addr, LOGE);
1431 return;
1432 }
1433
1434 }
1435
1436 if (LIM_IS_AP_ROLE(psession_entry)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301437 qdf_mem_copy(psession_entry->gLimNoShortParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001438 staNoShortCache[i].addr,
1439 peer_mac_addr, sizeof(tSirMacAddr));
1440 psession_entry->gLimNoShortParams.staNoShortCache[i].
1441 active = true;
1442 psession_entry->gLimNoShortParams.numNonShortPreambleSta++;
1443 } else {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301444 qdf_mem_copy(mac_ctx->lim.gLimNoShortParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001445 staNoShortCache[i].addr,
1446 peer_mac_addr, sizeof(tSirMacAddr));
1447 mac_ctx->lim.gLimNoShortParams.staNoShortCache[i].active = true;
1448 mac_ctx->lim.gLimNoShortParams.numNonShortPreambleSta++;
1449 }
1450
1451 /* enable long preamble */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301452 pe_debug("Disabling short preamble");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001453
1454 if (lim_enable_short_preamble(mac_ctx, false, beaconparams,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001455 psession_entry) != QDF_STATUS_SUCCESS)
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301456 pe_err("Cannot enable long preamble");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001457}
1458
1459/**
1460 * lim_update_short_slot_time() - This function Updates short slot time
1461 * @mac_ctx: pointer to Global MAC structure
1462 * @peer_mac_addr: pointer to tSirMacAddr
Sreelakshmi Konamkif611d1a2016-02-19 17:47:42 +05301463 * @beacon_params: pointer to tpUpdateBeaconParams
Jeff Johnsonc8baa902018-11-18 21:59:07 -08001464 * @psession_entry: pointer to struct pe_session *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001465 *
1466 * Function Updates short slot time if needed when a new station joins
1467 *
1468 * Return: None
1469 */
1470void
Jeff Johnsond01da6b2018-12-02 12:10:22 -08001471lim_update_short_slot_time(struct mac_context *mac_ctx, tSirMacAddr peer_mac_addr,
Sreelakshmi Konamkif611d1a2016-02-19 17:47:42 +05301472 tpUpdateBeaconParams beacon_params,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08001473 struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001474{
1475 uint16_t aid;
1476 tpDphHashNode sta_ds;
1477 uint32_t phy_mode;
1478 uint32_t val;
1479 uint16_t i;
1480
1481 /* check whether to enable protection or not */
Sreelakshmi Konamkif611d1a2016-02-19 17:47:42 +05301482 sta_ds = dph_lookup_hash_entry(mac_ctx, peer_mac_addr, &aid,
1483 &session_entry->dph.dphHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001484 lim_get_phy_mode(mac_ctx, &phy_mode, session_entry);
1485
1486 if (sta_ds == NULL || phy_mode != WNI_CFG_PHY_MODE_11G)
1487 return;
1488
1489 /*
1490 * Only in case of softap in 11g mode, slot time might change
1491 * depending on the STA being added. In 11a case, it should
1492 * be always 1 and in 11b case, it should be always 0.
1493 * Only when the new STA has short slot time disabled, we need to
1494 * change softap's overall slot time settings else the default for
1495 * softap is always short slot enabled. When the last long slot STA
1496 * leaves softAP, we take care of it in lim_decide_short_slot
1497 */
Sreelakshmi Konamkif611d1a2016-02-19 17:47:42 +05301498 if (sta_ds->shortSlotTimeEnabled != eHAL_CLEAR)
1499 return;
1500
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301501 pe_debug("Short Slot Time is not enabled in Assoc Req from");
1502 lim_print_mac_addr(mac_ctx, peer_mac_addr, LOGD);
Sreelakshmi Konamkif611d1a2016-02-19 17:47:42 +05301503 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
1504 if (LIM_IS_AP_ROLE(session_entry) &&
1505 session_entry->gLimNoShortSlotParams.
1506 staNoShortSlotCache[i].active) {
1507 if (!qdf_mem_cmp(session_entry->
1508 gLimNoShortSlotParams.staNoShortSlotCache[i].addr,
1509 peer_mac_addr, sizeof(tSirMacAddr)))
1510 return;
1511 } else if (!LIM_IS_AP_ROLE(session_entry)) {
1512 if (mac_ctx->lim.gLimNoShortSlotParams.
1513 staNoShortSlotCache[i].active) {
1514 if (!qdf_mem_cmp(mac_ctx->
1515 lim.gLimNoShortSlotParams.
1516 staNoShortSlotCache[i].addr,
1517 peer_mac_addr, sizeof(tSirMacAddr)))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001518 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001519 }
1520 }
Sreelakshmi Konamkif611d1a2016-02-19 17:47:42 +05301521 }
1522 for (i = 0; i < LIM_PROT_STA_CACHE_SIZE; i++) {
1523 if (LIM_IS_AP_ROLE(session_entry) &&
1524 !session_entry->gLimNoShortSlotParams.
1525 staNoShortSlotCache[i].active)
1526 break;
1527 else
1528 if (!mac_ctx->lim.gLimNoShortSlotParams.
1529 staNoShortSlotCache[i].active)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001530 break;
Sreelakshmi Konamkif611d1a2016-02-19 17:47:42 +05301531 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001532
Sreelakshmi Konamkif611d1a2016-02-19 17:47:42 +05301533 if (i >= LIM_PROT_STA_CACHE_SIZE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001534 if (LIM_IS_AP_ROLE(session_entry)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301535 pe_err("No space in ShortSlot cache active: %d sta: %d for sta",
Sreelakshmi Konamkif611d1a2016-02-19 17:47:42 +05301536 i, session_entry->gLimNoShortSlotParams.
1537 numNonShortSlotSta);
1538 lim_print_mac_addr(mac_ctx, peer_mac_addr, LOGE);
1539 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001540 } else {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301541 pe_err("No space in ShortSlot cache active: %d sta: %d for sta",
1542 i, mac_ctx->lim.gLimNoShortSlotParams.
Sreelakshmi Konamkif611d1a2016-02-19 17:47:42 +05301543 numNonShortSlotSta);
1544 lim_print_mac_addr(mac_ctx, peer_mac_addr, LOGE);
1545 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001546 }
Sreelakshmi Konamkif611d1a2016-02-19 17:47:42 +05301547 }
1548
1549 if (LIM_IS_AP_ROLE(session_entry)) {
1550 qdf_mem_copy(session_entry->gLimNoShortSlotParams.
1551 staNoShortSlotCache[i].addr,
1552 peer_mac_addr, sizeof(tSirMacAddr));
1553 session_entry->gLimNoShortSlotParams.
1554 staNoShortSlotCache[i].active = true;
1555 session_entry->gLimNoShortSlotParams.numNonShortSlotSta++;
1556 } else {
1557 qdf_mem_copy(mac_ctx->lim.gLimNoShortSlotParams.
1558 staNoShortSlotCache[i].addr,
1559 peer_mac_addr, sizeof(tSirMacAddr));
1560 mac_ctx->lim.gLimNoShortSlotParams.
1561 staNoShortSlotCache[i].active = true;
1562 mac_ctx->lim.gLimNoShortSlotParams.
1563 numNonShortSlotSta++;
1564 }
gaurank kathpaliae5a17e42018-09-10 10:05:25 +05301565 val = mac_ctx->mlme_cfg->feature_flags.enable_short_slot_time_11g;
Sreelakshmi Konamkif611d1a2016-02-19 17:47:42 +05301566 /*
1567 * Here we check if we are AP role and short slot enabled
1568 * (both admin and oper modes) but we have atleast one STA
1569 * connected with only long slot enabled, we need to change
1570 * our beacon/pb rsp to broadcast short slot disabled
1571 */
1572 if ((LIM_IS_AP_ROLE(session_entry)) && (val &&
1573 session_entry->gLimNoShortSlotParams.numNonShortSlotSta
1574 && session_entry->shortSlotTimeSupported)) {
1575 /* enable long slot time */
1576 beacon_params->fShortSlotTime = false;
1577 beacon_params->paramChangeBitmap |=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001578 PARAM_SHORT_SLOT_TIME_CHANGED;
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301579 pe_debug("Disable short slot time. Enable long slot time");
Sreelakshmi Konamkif611d1a2016-02-19 17:47:42 +05301580 session_entry->shortSlotTimeSupported = false;
1581 } else if (!LIM_IS_AP_ROLE(session_entry) &&
1582 (val && mac_ctx->lim.gLimNoShortSlotParams.
1583 numNonShortSlotSta &&
1584 session_entry->shortSlotTimeSupported)) {
1585 /* enable long slot time */
1586 beacon_params->fShortSlotTime = false;
1587 beacon_params->paramChangeBitmap |=
1588 PARAM_SHORT_SLOT_TIME_CHANGED;
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301589 pe_debug("Disable short slot time. Enable long slot time");
Sreelakshmi Konamkif611d1a2016-02-19 17:47:42 +05301590 session_entry->shortSlotTimeSupported = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001591 }
1592}
1593
1594/** -------------------------------------------------------------
1595 \fn lim_decide_sta_protection_on_assoc
1596 \brief Decide protection related settings on Sta while association.
Jeff Johnsond01da6b2018-12-02 12:10:22 -08001597 \param struct mac_context * mac
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001598 \param tpSchBeaconStruct pBeaconStruct
1599 \return None
1600 -------------------------------------------------------------*/
1601void
Jeff Johnsond01da6b2018-12-02 12:10:22 -08001602lim_decide_sta_protection_on_assoc(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001603 tpSchBeaconStruct pBeaconStruct,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001604 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001605{
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001606 enum band_info rfBand = BAND_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001607 uint32_t phyMode = WNI_CFG_PHY_MODE_NONE;
1608
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001609 lim_get_rf_band_new(mac, &rfBand, pe_session);
1610 lim_get_phy_mode(mac, &phyMode, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001611
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001612 if (BAND_5G == rfBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001613 if ((eSIR_HT_OP_MODE_MIXED == pBeaconStruct->HTInfo.opMode) ||
1614 (eSIR_HT_OP_MODE_OVERLAP_LEGACY ==
1615 pBeaconStruct->HTInfo.opMode)) {
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08001616 if (mac->lim.cfgProtection.fromlla)
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001617 pe_session->beaconParams.llaCoexist = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001618 } else if (eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT ==
1619 pBeaconStruct->HTInfo.opMode) {
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08001620 if (mac->lim.cfgProtection.ht20)
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001621 pe_session->beaconParams.ht20Coexist = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001622 }
1623
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001624 } else if (BAND_2G == rfBand) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001625 /* spec 7.3.2.13 */
1626 /* UseProtection will be set when nonERP STA is associated. */
1627 /* NonERPPresent bit will be set when: */
1628 /* --nonERP Sta is associated OR */
1629 /* --nonERP Sta exists in overlapping BSS */
1630 /* when useProtection is not set then protection from nonERP stations is optional. */
1631
1632 /* CFG protection from 11b is enabled and */
1633 /* 11B device in the BSS */
1634 /* TODO, This is not sessionized */
1635 if (phyMode != WNI_CFG_PHY_MODE_11B) {
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08001636 if (mac->lim.cfgProtection.fromllb &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001637 pBeaconStruct->erpPresent &&
1638 (pBeaconStruct->erpIEInfo.useProtection ||
1639 pBeaconStruct->erpIEInfo.nonErpPresent)) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001640 pe_session->beaconParams.llbCoexist = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001641 }
1642 /* AP has no 11b station associated. */
1643 else {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001644 pe_session->beaconParams.llbCoexist = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001645 }
1646 }
1647 /* following code block is only for HT station. */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001648 if ((pe_session->htCapability) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001649 (pBeaconStruct->HTInfo.present)) {
1650 tDot11fIEHTInfo htInfo = pBeaconStruct->HTInfo;
1651
1652 /* Obss Non HT STA present mode */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001653 pe_session->beaconParams.gHTObssMode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001654 (uint8_t) htInfo.obssNonHTStaPresent;
1655
1656 /* CFG protection from 11G is enabled and */
1657 /* our AP has at least one 11G station associated. */
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08001658 if (mac->lim.cfgProtection.fromllg &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001659 ((eSIR_HT_OP_MODE_MIXED == htInfo.opMode) ||
1660 (eSIR_HT_OP_MODE_OVERLAP_LEGACY == htInfo.opMode))
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001661 && (!pe_session->beaconParams.llbCoexist)) {
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08001662 if (mac->lim.cfgProtection.fromllg)
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001663 pe_session->beaconParams.llgCoexist =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001664 true;
1665 }
1666 /* AP has only HT stations associated and at least one station is HT 20 */
1667 /* disable protection from any non-HT devices. */
1668 /* decision for disabling protection from 11b has already been taken above. */
1669 if (eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT == htInfo.opMode) {
1670 /* Disable protection from 11G station. */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001671 pe_session->beaconParams.llgCoexist = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001672 /* CFG protection from HT 20 is enabled. */
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08001673 if (mac->lim.cfgProtection.ht20)
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001674 pe_session->beaconParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001675 ht20Coexist = true;
1676 }
1677 /* Disable protection from non-HT and HT20 devices. */
1678 /* decision for disabling protection from 11b has already been taken above. */
1679 if (eSIR_HT_OP_MODE_PURE == htInfo.opMode) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001680 pe_session->beaconParams.llgCoexist = false;
1681 pe_session->beaconParams.ht20Coexist = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001682 }
1683
1684 }
1685 }
1686 /* protection related factors other than HT operating mode. Applies to 2.4 GHZ as well as 5 GHZ. */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001687 if ((pe_session->htCapability) && (pBeaconStruct->HTInfo.present)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001688 tDot11fIEHTInfo htInfo = pBeaconStruct->HTInfo;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07001689
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001690 pe_session->beaconParams.fRIFSMode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001691 (uint8_t) htInfo.rifsMode;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001692 pe_session->beaconParams.llnNonGFCoexist =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001693 (uint8_t) htInfo.nonGFDevicesPresent;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001694 pe_session->beaconParams.fLsigTXOPProtectionFullSupport =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001695 (uint8_t) htInfo.lsigTXOPProtectionFullSupport;
1696 }
1697}
1698
1699
1700/**
1701 * lim_decide_sta_11bg_protection() - decides protection related settings on sta
1702 * @mac_ctx: pointer to global mac structure
1703 * @beacon_struct: pointer to tpschbeaconstruct
1704 * @beaconparams: pointer to tpupdatebeaconparams
1705 * @psession_entry: pointer to tppesession
1706 * @phy_mode: phy mode index
1707 *
1708 * decides 11bg protection related settings on sta while processing beacon
1709 *
1710 * Return: none
1711 */
1712static void
Jeff Johnsond01da6b2018-12-02 12:10:22 -08001713lim_decide_sta_11bg_protection(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001714 tpSchBeaconStruct beacon_struct,
1715 tpUpdateBeaconParams beaconparams,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08001716 struct pe_session *psession_entry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001717 uint32_t phy_mode)
1718{
1719
1720 tDot11fIEHTInfo htInfo;
1721
1722 /*
1723 * spec 7.3.2.13
1724 * UseProtection will be set when nonERP STA is associated.
1725 * NonERPPresent bit will be set when:
1726 * --nonERP Sta is associated OR
1727 * --nonERP Sta exists in overlapping BSS
1728 * when useProtection is not set then protection from
1729 * nonERP stations is optional.
1730 */
1731 if (phy_mode != WNI_CFG_PHY_MODE_11B) {
1732 if (beacon_struct->erpPresent &&
1733 (beacon_struct->erpIEInfo.useProtection ||
1734 beacon_struct->erpIEInfo.nonErpPresent)) {
1735 lim_enable11g_protection(mac_ctx, true, false,
1736 beaconparams,
1737 psession_entry);
1738 }
1739 /* AP has no 11b station associated. */
1740 else {
1741 /* disable protection from 11b station */
1742 lim_enable11g_protection(mac_ctx, false, false,
1743 beaconparams,
1744 psession_entry);
1745 }
1746 }
1747
1748 if (!(psession_entry->htCapability) ||
1749 !(beacon_struct->HTInfo.present))
1750 return;
1751
1752 /* following code is only for HT station. */
1753
1754 htInfo = beacon_struct->HTInfo;
1755 /* AP has at least one 11G station associated. */
1756 if (((eSIR_HT_OP_MODE_MIXED == htInfo.opMode) ||
1757 (eSIR_HT_OP_MODE_OVERLAP_LEGACY == htInfo.opMode)) &&
1758 (!psession_entry->beaconParams.llbCoexist)) {
1759 lim_enable_ht_protection_from11g(mac_ctx, true, false,
1760 beaconparams, psession_entry);
1761
1762 }
1763 /*
1764 * no HT operating mode change ==> no change in
1765 * protection settings except for MIXED_MODE/Legacy
1766 * Mode.
1767 */
1768 /*
1769 * in Mixed mode/legacy Mode even if there is no
1770 * change in HT operating mode, there might be
1771 * change in 11bCoexist or 11gCoexist. Hence this
1772 * check is being done after mixed/legacy mode
1773 * check.
1774 */
1775 if (mac_ctx->lim.gHTOperMode !=
1776 (tSirMacHTOperatingMode)htInfo.opMode) {
1777 mac_ctx->lim.gHTOperMode =
1778 (tSirMacHTOperatingMode) htInfo.opMode;
1779 /*
1780 * AP has only HT stations associated and
1781 * at least one station is HT 20
1782 */
1783
1784 /* disable protection from any non-HT devices. */
1785
1786 /*
1787 * decision for disabling protection from
1788 * 11b has already been taken above.
1789 */
1790 if (eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT ==
1791 htInfo.opMode) {
1792 /* Disable protection from 11G station. */
1793 lim_enable_ht_protection_from11g(mac_ctx, false,
1794 false, beaconparams,
1795 psession_entry);
1796
1797 lim_enable_ht20_protection(mac_ctx, true, false,
1798 beaconparams,
1799 psession_entry);
1800 }
1801 /*
1802 * Disable protection from non-HT and
1803 * HT20 devices.
1804 */
1805 /*
1806 * decision for disabling protection from
1807 * 11b has already been taken above.
1808 */
1809 else if (eSIR_HT_OP_MODE_PURE == htInfo.opMode) {
1810 lim_enable_ht_protection_from11g(mac_ctx, false,
1811 false, beaconparams,
1812 psession_entry);
1813
1814 lim_enable_ht20_protection(mac_ctx, false,
1815 false, beaconparams,
1816 psession_entry);
1817
1818 }
1819 }
1820
1821}
1822
1823/**
1824 * lim_decide_sta_protection() - decides protection related settings on sta
1825 * @mac_ctx: pointer to global mac structure
1826 * @beacon_struct: pointer to tpschbeaconstruct
1827 * @beaconparams: pointer to tpupdatebeaconparams
1828 * @psession_entry: pointer to tppesession
1829 *
1830 * decides protection related settings on sta while processing beacon
1831 *
1832 * Return: none
1833 */
1834void
Jeff Johnsond01da6b2018-12-02 12:10:22 -08001835lim_decide_sta_protection(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001836 tpSchBeaconStruct beacon_struct,
1837 tpUpdateBeaconParams beaconparams,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08001838 struct pe_session *psession_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001839{
1840
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001841 enum band_info rfband = BAND_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001842 uint32_t phy_mode = WNI_CFG_PHY_MODE_NONE;
1843
1844 lim_get_rf_band_new(mac_ctx, &rfband, psession_entry);
1845 lim_get_phy_mode(mac_ctx, &phy_mode, psession_entry);
1846
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001847 if ((BAND_5G == rfband) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001848 /* we are HT capable. */
1849 (true == psession_entry->htCapability) &&
1850 (beacon_struct->HTInfo.present)) {
1851 /*
1852 * we are HT capable, AP's HT OPMode is
1853 * mixed / overlap legacy ==> need protection
1854 * from 11A.
1855 */
1856 if ((eSIR_HT_OP_MODE_MIXED ==
1857 beacon_struct->HTInfo.opMode) ||
1858 (eSIR_HT_OP_MODE_OVERLAP_LEGACY ==
1859 beacon_struct->HTInfo.opMode)) {
1860 lim_update_11a_protection(mac_ctx, true, false,
1861 beaconparams, psession_entry);
1862 }
1863 /*
1864 * we are HT capable, AP's HT OPMode is
1865 * HT20 ==> disable protection from 11A if
1866 * enabled.
1867 */
1868 /* protection from HT20 if needed. */
1869 else if (eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT ==
1870 beacon_struct->HTInfo.opMode) {
1871 lim_update_11a_protection(mac_ctx, false, false,
1872 beaconparams, psession_entry);
1873 lim_enable_ht20_protection(mac_ctx, true, false,
1874 beaconparams, psession_entry);
1875 } else if (eSIR_HT_OP_MODE_PURE ==
1876 beacon_struct->HTInfo.opMode) {
1877 lim_update_11a_protection(mac_ctx, false, false,
1878 beaconparams, psession_entry);
1879 lim_enable_ht20_protection(mac_ctx, false,
1880 false, beaconparams,
1881 psession_entry);
1882 }
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -08001883 } else if (BAND_2G == rfband) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001884 lim_decide_sta_11bg_protection(mac_ctx, beacon_struct,
1885 beaconparams, psession_entry, phy_mode);
1886 }
1887 /*
1888 * following code block is only for HT station.
1889 * (2.4 GHZ as well as 5 GHZ)
1890 */
1891 if ((psession_entry->htCapability) && (beacon_struct->HTInfo.present)) {
1892 tDot11fIEHTInfo htInfo = beacon_struct->HTInfo;
1893 /*
1894 * Check for changes in protection related factors other
1895 * than HT operating mode.
1896 */
1897 /*
1898 * Check for changes in RIFS mode, nonGFDevicesPresent,
1899 * lsigTXOPProtectionFullSupport.
1900 */
1901 if (psession_entry->beaconParams.fRIFSMode !=
1902 (uint8_t) htInfo.rifsMode) {
1903 beaconparams->fRIFSMode =
1904 psession_entry->beaconParams.fRIFSMode =
1905 (uint8_t) htInfo.rifsMode;
1906 beaconparams->paramChangeBitmap |=
1907 PARAM_RIFS_MODE_CHANGED;
1908 }
1909
1910 if (psession_entry->beaconParams.llnNonGFCoexist !=
1911 htInfo.nonGFDevicesPresent) {
1912 beaconparams->llnNonGFCoexist =
1913 psession_entry->beaconParams.llnNonGFCoexist =
1914 (uint8_t) htInfo.nonGFDevicesPresent;
1915 beaconparams->paramChangeBitmap |=
1916 PARAM_NON_GF_DEVICES_PRESENT_CHANGED;
1917 }
1918
1919 if (psession_entry->beaconParams.
1920 fLsigTXOPProtectionFullSupport !=
1921 (uint8_t) htInfo.lsigTXOPProtectionFullSupport) {
1922 beaconparams->fLsigTXOPProtectionFullSupport =
1923 psession_entry->beaconParams.
1924 fLsigTXOPProtectionFullSupport =
1925 (uint8_t) htInfo.
1926 lsigTXOPProtectionFullSupport;
1927 beaconparams->paramChangeBitmap |=
1928 PARAM_LSIG_TXOP_FULL_SUPPORT_CHANGED;
1929 }
1930 /*
1931 * For Station just update the global lim variable,
1932 * no need to send message to HAL since Station already
1933 * taking care of HT OPR Mode=01,
1934 * meaning AP is seeing legacy
1935 */
1936 /* stations in overlapping BSS. */
1937 if (psession_entry->beaconParams.gHTObssMode !=
1938 (uint8_t) htInfo.obssNonHTStaPresent)
1939 psession_entry->beaconParams.gHTObssMode =
1940 (uint8_t) htInfo.obssNonHTStaPresent;
1941
1942 }
1943}
1944
1945/**
Jianmin Zhu69e7bf32018-11-22 11:56:10 +08001946 * __lim_process_channel_switch_timeout()
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001947 *
1948 ***FUNCTION:
1949 * This function is invoked when Channel Switch Timer expires at
1950 * the STA. Now, STA must stop traffic, and then change/disable
1951 * primary or secondary channel.
1952 *
1953 *
1954 ***NOTE:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08001955 * @param mac - Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001956 * @return None
1957 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08001958static void __lim_process_channel_switch_timeout(struct mac_context *mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001959{
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001960 struct pe_session *pe_session = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001961 uint8_t channel; /* This is received and stored from channelSwitch Action frame */
1962
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001963 pe_session = pe_find_session_by_session_id(mac,
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08001964 mac->lim.limTimers.gLimChannelSwitchTimer.sessionId);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001965 if (pe_session == NULL) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301966 pe_err("Session Does not exist for given sessionID");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001967 return;
1968 }
1969
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001970 if (!LIM_IS_STA_ROLE(pe_session)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301971 pe_warn("Channel switch can be done only in STA role, Current Role: %d",
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001972 GET_LIM_SYSTEM_ROLE(pe_session));
Abhishek Singh49275562016-09-13 12:35:22 +05301973 return;
1974 }
1975
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001976 if (pe_session->gLimSpecMgmt.dot11hChanSwState !=
Abhishek Singh49275562016-09-13 12:35:22 +05301977 eLIM_11H_CHANSW_RUNNING) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301978 pe_warn("Channel switch timer should not have been running in state: %d",
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001979 pe_session->gLimSpecMgmt.dot11hChanSwState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001980 return;
1981 }
1982
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001983 channel = pe_session->gLimChannelSwitch.primaryChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001984 /* Restore Channel Switch parameters to default */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001985 pe_session->gLimChannelSwitch.switchTimeoutValue = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001986
1987 /* Channel-switch timeout has occurred. reset the state */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001988 pe_session->gLimSpecMgmt.dot11hChanSwState = eLIM_11H_CHANSW_END;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001989
1990 /* Check if the AP is switching to a channel that we support.
1991 * Else, just don't bother to switch. Indicate HDD to look for a
1992 * better AP to associate
1993 */
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08001994 if (!lim_is_channel_valid_for_channel_switch(mac, channel)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001995 /* We need to restore pre-channelSwitch state on the STA */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08001996 if (lim_restore_pre_channel_switch_state(mac, pe_session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07001997 QDF_STATUS_SUCCESS) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05301998 pe_err("Could not restore pre-channelSwitch (11h) state, resetting the system");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001999 return;
2000 }
2001
Abhishek Singh49275562016-09-13 12:35:22 +05302002 /*
2003 * If the channel-list that AP is asking us to switch is invalid
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002004 * then we cannot switch the channel. Just disassociate from AP.
2005 * We will find a better AP !!!
2006 */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002007 if ((pe_session->limMlmState ==
Abhishek Singh49275562016-09-13 12:35:22 +05302008 eLIM_MLM_LINK_ESTABLISHED_STATE) &&
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002009 (pe_session->limSmeState != eLIM_SME_WT_DISASSOC_STATE) &&
2010 (pe_session->limSmeState != eLIM_SME_WT_DEAUTH_STATE)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05302011 pe_err("Invalid channel! Disconnect");
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002012 lim_tear_down_link_with_ap(mac,
2013 mac->lim.limTimers.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002014 gLimChannelSwitchTimer.sessionId,
2015 eSIR_MAC_UNSPEC_FAILURE_REASON);
Abhishek Singh49275562016-09-13 12:35:22 +05302016 return;
2017 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002018 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002019 lim_covert_channel_scan_type(mac, pe_session->currentOperChannel,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002020 false);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002021 mac->lim.dfschannelList.timeStamp[pe_session->currentOperChannel] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002022 0;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002023 switch (pe_session->gLimChannelSwitch.state) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002024 case eLIM_CHANNEL_SWITCH_PRIMARY_ONLY:
Nishank Aggarwal0402b432017-03-24 19:17:36 +05302025 pe_warn("CHANNEL_SWITCH_PRIMARY_ONLY");
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002026 lim_switch_primary_channel(mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002027 pe_session->gLimChannelSwitch.
2028 primaryChannel, pe_session);
2029 pe_session->gLimChannelSwitch.state =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002030 eLIM_CHANNEL_SWITCH_IDLE;
2031 break;
2032 case eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY:
Nishank Aggarwal0402b432017-03-24 19:17:36 +05302033 pe_warn("CHANNEL_SWITCH_PRIMARY_AND_SECONDARY");
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002034 lim_switch_primary_secondary_channel(mac, pe_session,
2035 pe_session->gLimChannelSwitch.primaryChannel,
2036 pe_session->gLimChannelSwitch.ch_center_freq_seg0,
2037 pe_session->gLimChannelSwitch.ch_center_freq_seg1,
2038 pe_session->gLimChannelSwitch.ch_width);
2039 pe_session->gLimChannelSwitch.state =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002040 eLIM_CHANNEL_SWITCH_IDLE;
2041 break;
2042
2043 case eLIM_CHANNEL_SWITCH_IDLE:
2044 default:
Nishank Aggarwal0402b432017-03-24 19:17:36 +05302045 pe_err("incorrect state");
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002046 if (lim_restore_pre_channel_switch_state(mac, pe_session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002047 QDF_STATUS_SUCCESS) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05302048 pe_err("Could not restore pre-channelSwitch (11h) state, resetting the system");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002049 }
2050 return; /* Please note, this is 'return' and not 'break' */
2051 }
2052}
2053
Jianmin Zhu69e7bf32018-11-22 11:56:10 +08002054#ifdef CONFIG_VDEV_SM
Jeff Johnsond01da6b2018-12-02 12:10:22 -08002055void lim_process_channel_switch_timeout(struct mac_context *mac_ctx)
Jianmin Zhu69e7bf32018-11-22 11:56:10 +08002056{
2057 tpPESession session_entry = NULL;
2058 QDF_STATUS status;
2059
2060 session_entry = pe_find_session_by_session_id(
2061 mac_ctx,
2062 mac_ctx->lim.limTimers.gLimChannelSwitchTimer.sessionId);
2063 mlme_set_chan_switch_in_progress(session_entry->vdev, true);
2064 status = wlan_vdev_mlme_sm_deliver_evt(
2065 session_entry->vdev,
2066 WLAN_VDEV_SM_EV_FW_VDEV_RESTART,
2067 sizeof(*mac_ctx),
2068 mac_ctx);
2069 if (QDF_IS_STATUS_ERROR(status)) {
2070 pe_err("Failed to post WLAN_VDEV_SM_EV_FW_VDEV_RESTART for vdevid %d",
2071 session_entry->smeSessionId);
2072 mlme_set_chan_switch_in_progress(session_entry->vdev, false);
2073 }
2074}
2075#else
Jeff Johnsond01da6b2018-12-02 12:10:22 -08002076void lim_process_channel_switch_timeout(struct mac_context *mac)
Jianmin Zhu69e7bf32018-11-22 11:56:10 +08002077{
2078 __lim_process_channel_switch_timeout(mac);
2079}
2080#endif
2081
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002082/**
2083 * lim_update_channel_switch() - This Function updates channel switch
2084 * @mac_ctx: pointer to Global MAC structure
2085 * @beacon: pointer to tpSirProbeRespBeacon
Jeff Johnsonc8baa902018-11-18 21:59:07 -08002086 * @psessionentry: pointer to struct pe_session *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002087 *
2088 * This function is invoked whenever Station receives
2089 * either 802.11h channel switch IE or airgo proprietary
2090 * channel switch IE.
2091 *
2092 * Return: none
2093 */
2094void
Jeff Johnson009c40f2018-11-05 09:54:37 -08002095lim_update_channel_switch(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002096 tpSirProbeRespBeacon beacon,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08002097 struct pe_session *psession_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002098{
2099 uint16_t beacon_period;
2100 tDot11fIEChanSwitchAnn *chnl_switch;
2101 tLimChannelSwitchInfo *ch_switch_params;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002102 tDot11fIEWiderBWChanSwitchAnn *widerchnl_switch;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002103
2104 beacon_period = psession_entry->beaconParams.beaconInterval;
2105
2106 /* 802.11h standard channel switch IE */
2107 chnl_switch = &(beacon->channelSwitchIE);
2108 ch_switch_params = &psession_entry->gLimChannelSwitch;
2109 ch_switch_params->primaryChannel =
2110 chnl_switch->newChannel;
2111 ch_switch_params->switchCount = chnl_switch->switchCount;
2112 ch_switch_params->switchTimeoutValue =
2113 SYS_MS_TO_TICKS(beacon_period) * (chnl_switch->switchCount);
2114 ch_switch_params->switchMode = chnl_switch->switchMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002115 widerchnl_switch = &(beacon->WiderBWChanSwitchAnn);
2116 if (beacon->WiderBWChanSwitchAnnPresent) {
2117 psession_entry->gLimWiderBWChannelSwitch.newChanWidth =
2118 widerchnl_switch->newChanWidth;
2119 psession_entry->gLimWiderBWChannelSwitch.newCenterChanFreq0 =
2120 widerchnl_switch->newCenterChanFreq0;
2121 psession_entry->gLimWiderBWChannelSwitch.newCenterChanFreq1 =
2122 widerchnl_switch->newCenterChanFreq1;
2123 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002124 /* Only primary channel switch element is present */
2125 ch_switch_params->state =
2126 eLIM_CHANNEL_SWITCH_PRIMARY_ONLY;
2127 ch_switch_params->ch_width = CH_WIDTH_20MHZ;
2128
2129 /*
2130 * Do not bother to look and operate on extended channel switch element
2131 * if our own channel-bonding state is not enabled
2132 */
2133 if (psession_entry->htSupportedChannelWidthSet &&
2134 beacon->sec_chan_offset_present) {
2135 if (beacon->sec_chan_offset.secondaryChannelOffset ==
2136 PHY_DOUBLE_CHANNEL_LOW_PRIMARY) {
2137 ch_switch_params->state =
2138 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2139 ch_switch_params->ch_width = CH_WIDTH_40MHZ;
2140 ch_switch_params->ch_center_freq_seg0 =
2141 ch_switch_params->primaryChannel + 2;
2142 } else if (beacon->sec_chan_offset.secondaryChannelOffset ==
2143 PHY_DOUBLE_CHANNEL_HIGH_PRIMARY) {
2144 ch_switch_params->state =
2145 eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY;
2146 ch_switch_params->ch_width = CH_WIDTH_40MHZ;
2147 ch_switch_params->ch_center_freq_seg0 =
2148 ch_switch_params->primaryChannel - 2;
2149 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002150 if (psession_entry->vhtCapability &&
2151 beacon->WiderBWChanSwitchAnnPresent) {
2152 ch_switch_params->ch_width =
2153 widerchnl_switch->newChanWidth + 1;
2154 ch_switch_params->ch_center_freq_seg0 =
2155 psession_entry->gLimWiderBWChannelSwitch.
2156 newCenterChanFreq0;
2157 ch_switch_params->ch_center_freq_seg1 =
2158 psession_entry->gLimWiderBWChannelSwitch.
2159 newCenterChanFreq1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002160 }
2161 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002162 if (QDF_STATUS_SUCCESS != lim_start_channel_switch(mac_ctx, psession_entry))
Nishank Aggarwal0402b432017-03-24 19:17:36 +05302163 pe_warn("Could not start Channel Switch");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002164
Nishank Aggarwal0402b432017-03-24 19:17:36 +05302165 pe_debug("session: %d primary chl: %d ch_width: %d count: %d (%d ticks)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002166 psession_entry->peSessionId,
2167 psession_entry->gLimChannelSwitch.primaryChannel,
2168 psession_entry->gLimChannelSwitch.ch_width,
2169 psession_entry->gLimChannelSwitch.switchCount,
2170 psession_entry->gLimChannelSwitch.switchTimeoutValue);
2171 return;
2172}
2173
2174/**
2175 * lim_cancel_dot11h_channel_switch
2176 *
2177 ***FUNCTION:
2178 * This function is called when STA does not send updated channel-swith IE
2179 * after indicating channel-switch start. This will cancel the channel-swith
2180 * timer which is already running.
2181 *
2182 ***LOGIC:
2183 *
2184 ***ASSUMPTIONS:
2185 *
2186 ***NOTE:
2187 *
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002188 * @param mac - Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002189 *
2190 * @return None
2191 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08002192void lim_cancel_dot11h_channel_switch(struct mac_context *mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002193 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002194{
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002195 if (!LIM_IS_STA_ROLE(pe_session))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002196 return;
2197
Nishank Aggarwal0402b432017-03-24 19:17:36 +05302198 pe_debug("Received a beacon without channel switch IE");
Nishank Aggarwale59eb392017-03-10 17:34:42 +05302199
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002200 MTRACE(mac_trace
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002201 (mac, TRACE_CODE_TIMER_DEACTIVATE,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002202 pe_session->peSessionId, eLIM_CHANNEL_SWITCH_TIMER));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002203
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002204 if (tx_timer_deactivate(&mac->lim.limTimers.gLimChannelSwitchTimer) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002205 QDF_STATUS_SUCCESS) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05302206 pe_err("tx_timer_deactivate failed!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002207 }
2208
2209 /* We need to restore pre-channelSwitch state on the STA */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002210 if (lim_restore_pre_channel_switch_state(mac, pe_session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002211 QDF_STATUS_SUCCESS) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05302212 pe_err("LIM: Could not restore pre-channelSwitch (11h) state, resetting the system");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002213 }
2214}
2215
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002216/** ------------------------------------------------------------------------ **/
2217/**
2218 * keep track of the number of ANI peers associated in the BSS
2219 * For the first and last ANI peer, we have to update EDCA params as needed
2220 *
2221 * When the first ANI peer joins the BSS, we notify SCH
2222 * When the last ANI peer leaves the BSS, we notfiy SCH
2223 */
2224void
Jeff Johnsond01da6b2018-12-02 12:10:22 -08002225lim_util_count_sta_add(struct mac_context *mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002226 tpDphHashNode pSta, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002227{
2228
2229 if ((!pSta) || (!pSta->valid) || (pSta->fAniCount))
2230 return;
2231
2232 pSta->fAniCount = 1;
2233
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002234 if (mac->lim.gLimNumOfAniSTAs++ != 0)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002235 return;
2236
2237 /* get here only if this is the first ANI peer in the BSS */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002238 sch_edca_profile_update(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002239}
2240
2241void
Jeff Johnsond01da6b2018-12-02 12:10:22 -08002242lim_util_count_sta_del(struct mac_context *mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002243 tpDphHashNode pSta, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002244{
2245
2246 if ((pSta == NULL) || (!pSta->fAniCount))
2247 return;
2248
2249 /* Only if sta is invalid and the validInDummyState bit is set to 1,
2250 * then go ahead and update the count and profiles. This ensures
2251 * that the "number of ani station" count is properly incremented/decremented.
2252 */
2253 if (pSta->valid == 1)
2254 return;
2255
2256 pSta->fAniCount = 0;
2257
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002258 if (mac->lim.gLimNumOfAniSTAs <= 0) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05302259 pe_err("CountStaDel: ignoring Delete Req when AniPeer count: %d",
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002260 mac->lim.gLimNumOfAniSTAs);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002261 return;
2262 }
2263
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002264 mac->lim.gLimNumOfAniSTAs--;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002265
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002266 if (mac->lim.gLimNumOfAniSTAs != 0)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002267 return;
2268
2269 /* get here only if this is the last ANI peer in the BSS */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002270 sch_edca_profile_update(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002271}
2272
2273/**
2274 * lim_switch_channel_cback()
2275 *
2276 ***FUNCTION:
2277 * This is the callback function registered while requesting to switch channel
2278 * after AP indicates a channel switch for spectrum management (11h).
2279 *
2280 ***NOTE:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002281 * @param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002282 * @param status Status of channel switch request
2283 * @param data User data
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002284 * @param pe_session Session information
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002285 * @return NONE
2286 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08002287void lim_switch_channel_cback(struct mac_context *mac, QDF_STATUS status,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002288 uint32_t *data, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002289{
Rajeev Kumar416b73f2017-01-21 16:45:21 -08002290 struct scheduler_msg mmhMsg = { 0 };
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002291 tSirSmeSwitchChannelInd *pSirSmeSwitchChInd;
Jianmin Zhu69e7bf32018-11-22 11:56:10 +08002292#ifdef CONFIG_VDEV_SM
2293 QDF_STATUS evt_status;
2294#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002295
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002296 pe_session->currentOperChannel = pe_session->currentReqChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002297
2298 /* We need to restore pre-channelSwitch state on the STA */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002299 if (lim_restore_pre_channel_switch_state(mac, pe_session) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002300 QDF_STATUS_SUCCESS) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05302301 pe_err("Could not restore pre-channelSwitch (11h) state, resetting the system");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002302 return;
2303 }
2304
2305 mmhMsg.type = eWNI_SME_SWITCH_CHL_IND;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302306 pSirSmeSwitchChInd = qdf_mem_malloc(sizeof(tSirSmeSwitchChannelInd));
Arif Hussainf5b6c412018-10-10 19:41:09 -07002307 if (!pSirSmeSwitchChInd)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002308 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002309
2310 pSirSmeSwitchChInd->messageType = eWNI_SME_SWITCH_CHL_IND;
2311 pSirSmeSwitchChInd->length = sizeof(tSirSmeSwitchChannelInd);
2312 pSirSmeSwitchChInd->newChannelId =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002313 pe_session->gLimChannelSwitch.primaryChannel;
2314 pSirSmeSwitchChInd->sessionId = pe_session->smeSessionId;
Manishekar Chandrasekaranec267592016-05-26 19:10:04 +05302315 pSirSmeSwitchChInd->chan_params.ch_width =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002316 pe_session->gLimChannelSwitch.ch_width;
Manishekar Chandrasekaranec267592016-05-26 19:10:04 +05302317 pSirSmeSwitchChInd->chan_params.sec_ch_offset =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002318 pe_session->gLimChannelSwitch.sec_ch_offset;
Manishekar Chandrasekaranec267592016-05-26 19:10:04 +05302319 pSirSmeSwitchChInd->chan_params.center_freq_seg0 =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002320 pe_session->gLimChannelSwitch.ch_center_freq_seg0;
Manishekar Chandrasekaranec267592016-05-26 19:10:04 +05302321 pSirSmeSwitchChInd->chan_params.center_freq_seg1 =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002322 pe_session->gLimChannelSwitch.ch_center_freq_seg1;
Manishekar Chandrasekaranec267592016-05-26 19:10:04 +05302323
Nishank Aggarwal0402b432017-03-24 19:17:36 +05302324 pe_debug("session: %d chan: %d width: %d sec offset: %d seg0: %d seg1: %d",
Manishekar Chandrasekaranec267592016-05-26 19:10:04 +05302325 pSirSmeSwitchChInd->sessionId,
2326 pSirSmeSwitchChInd->newChannelId,
2327 pSirSmeSwitchChInd->chan_params.ch_width,
2328 pSirSmeSwitchChInd->chan_params.sec_ch_offset,
2329 pSirSmeSwitchChInd->chan_params.center_freq_seg0,
2330 pSirSmeSwitchChInd->chan_params.center_freq_seg1);
2331
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002332 qdf_mem_copy(pSirSmeSwitchChInd->bssid.bytes, pe_session->bssId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302333 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002334 mmhMsg.bodyptr = pSirSmeSwitchChInd;
2335 mmhMsg.bodyval = 0;
2336
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002337 MTRACE(mac_trace(mac, TRACE_CODE_TX_SME_MSG,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002338 pe_session->peSessionId, mmhMsg.type));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002339
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002340 sys_process_mmh_msg(mac, &mmhMsg);
Jianmin Zhu69e7bf32018-11-22 11:56:10 +08002341#ifdef CONFIG_VDEV_SM
2342 evt_status = wlan_vdev_mlme_sm_deliver_evt(
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002343 pe_session->vdev,
Jianmin Zhu69e7bf32018-11-22 11:56:10 +08002344 WLAN_VDEV_SM_EV_START_SUCCESS,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002345 sizeof(*pe_session), pe_session);
Jianmin Zhu69e7bf32018-11-22 11:56:10 +08002346 if (QDF_IS_STATUS_ERROR(evt_status)) {
2347 pe_err("Failed to post WLAN_VDEV_SM_EV_START_SUCCESS for vdevid %d",
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002348 pe_session->smeSessionId);
Jianmin Zhu69e7bf32018-11-22 11:56:10 +08002349 }
2350#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002351}
2352
2353/**
2354 * lim_switch_primary_channel()
2355 *
2356 ***FUNCTION:
2357 * This function changes the current operating channel
2358 * and sets the new new channel ID in WNI_CFG_CURRENT_CHANNEL.
2359 *
2360 ***NOTE:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002361 * @param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002362 * @param newChannel new chnannel ID
2363 * @return NONE
2364 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08002365void lim_switch_primary_channel(struct mac_context *mac, uint8_t newChannel,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002366 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002367{
Nishank Aggarwal0402b432017-03-24 19:17:36 +05302368 pe_debug("old chnl: %d --> new chnl: %d",
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002369 pe_session->currentOperChannel, newChannel);
Nishank Aggarwale59eb392017-03-10 17:34:42 +05302370
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002371 pe_session->currentReqChannel = newChannel;
2372 pe_session->limRFBand = lim_get_rf_band(newChannel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002373
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002374 pe_session->channelChangeReasonCode = LIM_SWITCH_CHANNEL_OPERATION;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002375
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002376 mac->lim.gpchangeChannelCallback = lim_switch_channel_cback;
2377 mac->lim.gpchangeChannelData = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002378
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002379 lim_send_switch_chnl_params(mac, newChannel, 0, 0, CH_WIDTH_20MHZ,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002380 pe_session->maxTxPower,
2381 pe_session->peSessionId, false, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002382 return;
2383}
2384
2385/**
2386 * lim_switch_primary_secondary_channel()
2387 *
2388 ***FUNCTION:
2389 * This function changes the primary and secondary channel.
2390 * If 11h is enabled and user provides a "new channel ID"
2391 * that is different from the current operating channel,
2392 * then we must set this new channel in WNI_CFG_CURRENT_CHANNEL,
2393 * assign notify LIM of such change.
2394 *
2395 ***NOTE:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002396 * @param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002397 * @param newChannel New chnannel ID (or current channel ID)
2398 * @param subband CB secondary info:
2399 * - eANI_CB_SECONDARY_NONE
2400 * - eANI_CB_SECONDARY_UP
2401 * - eANI_CB_SECONDARY_DOWN
2402 * @return NONE
2403 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08002404void lim_switch_primary_secondary_channel(struct mac_context *mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002405 struct pe_session *pe_session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002406 uint8_t newChannel,
2407 uint8_t ch_center_freq_seg0,
2408 uint8_t ch_center_freq_seg1,
Kiran Kumar Lokere13644672016-02-29 15:40:10 -08002409 enum phy_ch_width ch_width)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002410{
Deepak Dhamdhere641bf322016-01-06 15:19:03 -08002411
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002412 /* Assign the callback to resume TX once channel is changed. */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002413 pe_session->currentReqChannel = newChannel;
2414 pe_session->limRFBand = lim_get_rf_band(newChannel);
2415 pe_session->channelChangeReasonCode = LIM_SWITCH_CHANNEL_OPERATION;
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002416 mac->lim.gpchangeChannelCallback = lim_switch_channel_cback;
2417 mac->lim.gpchangeChannelData = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002418
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002419 lim_send_switch_chnl_params(mac, newChannel, ch_center_freq_seg0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002420 ch_center_freq_seg1, ch_width,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002421 pe_session->maxTxPower,
2422 pe_session->peSessionId,
Arif Hussain671a1902017-03-17 09:08:32 -07002423 false, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002424
2425 /* Store the new primary and secondary channel in session entries if different */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002426 if (pe_session->currentOperChannel != newChannel) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05302427 pe_warn("switch old chnl: %d --> new chnl: %d",
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002428 pe_session->currentOperChannel, newChannel);
2429 pe_session->currentOperChannel = newChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002430 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002431 if (pe_session->htSecondaryChannelOffset !=
2432 pe_session->gLimChannelSwitch.sec_ch_offset) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05302433 pe_warn("switch old sec chnl: %d --> new sec chnl: %d",
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002434 pe_session->htSecondaryChannelOffset,
2435 pe_session->gLimChannelSwitch.sec_ch_offset);
2436 pe_session->htSecondaryChannelOffset =
2437 pe_session->gLimChannelSwitch.sec_ch_offset;
2438 if (pe_session->htSecondaryChannelOffset ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002439 PHY_SINGLE_CHANNEL_CENTERED) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002440 pe_session->htSupportedChannelWidthSet =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002441 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
2442 } else {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002443 pe_session->htSupportedChannelWidthSet =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002444 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
2445 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002446 pe_session->htRecommendedTxWidthSet =
2447 pe_session->htSupportedChannelWidthSet;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002448 }
2449
2450 return;
2451}
2452
2453/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002454 * lim_get_ht_capability()
2455 *
2456 ***FUNCTION:
2457 * A utility function that returns the "current HT capability state" for the HT
2458 * capability of interest (as requested in the API)
2459 *
2460 ***LOGIC:
2461 * This routine will return with the "current" setting of a requested HT
2462 * capability. This state info could be retrieved from -
2463 * a) CFG (for static entries)
2464 * b) Run time info
2465 * - Dynamic state maintained by LIM
2466 * - Configured at radio init time by SME
2467 *
2468 *
2469 ***ASSUMPTIONS:
2470 * NA
2471 *
2472 ***NOTE:
2473 *
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002474 * @param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002475 * @param htCap The HT capability being queried
2476 * @return uint8_t The current state of the requested HT capability is returned in a
2477 * uint8_t variable
2478 */
2479
Jeff Johnsond01da6b2018-12-02 12:10:22 -08002480uint8_t lim_get_ht_capability(struct mac_context *mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002481 uint32_t htCap, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002482{
2483 uint8_t retVal = 0;
2484 uint8_t *ptr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002485 tSirMacTxBFCapabilityInfo macTxBFCapabilityInfo = { 0 };
2486 tSirMacASCapabilityInfo macASCapabilityInfo = { 0 };
Abhinav Kumard4d6eb72018-12-04 20:30:37 +05302487 struct mlme_vht_capabilities_info *vht_cap_info;
2488
2489 vht_cap_info = &mac->mlme_cfg->vht_caps.vht_cap_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002490
2491 /* */
2492 /* Determine which CFG to read from. Not ALL of the HT */
2493 /* related CFG's need to be read each time this API is */
2494 /* accessed */
2495 /* */
2496 if (htCap >= eHT_ANTENNA_SELECTION && htCap < eHT_SI_GRANULARITY) {
2497 /* Get Antenna Seletion HT Capabilities */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002498 ptr = (uint8_t *) &macASCapabilityInfo;
Abhinav Kumard4d6eb72018-12-04 20:30:37 +05302499 *((uint8_t *)ptr) = (uint8_t)(vht_cap_info->as_cap & 0xff);
Vignesh Viswanathanddc89e52018-11-02 18:43:42 +05302500 } else if (htCap >= eHT_TX_BEAMFORMING &&
2501 htCap < eHT_ANTENNA_SELECTION) {
2502 /* Get Transmit Beam Forming HT Capabilities */
Vignesh Viswanathanddc89e52018-11-02 18:43:42 +05302503 ptr = (uint8_t *)&macTxBFCapabilityInfo;
Abhinav Kumard4d6eb72018-12-04 20:30:37 +05302504 *((uint32_t *)ptr) = (uint32_t)(vht_cap_info->tx_bf_cap);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002505 }
2506
2507 switch (htCap) {
2508 case eHT_LSIG_TXOP_PROTECTION:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002509 retVal = mac->lim.gHTLsigTXOPProtection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002510 break;
2511
2512 case eHT_STBC_CONTROL_FRAME:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002513 retVal = (uint8_t)mac->mlme_cfg->ht_caps.ht_cap_info.
Vignesh Viswanathanddc89e52018-11-02 18:43:42 +05302514 stbc_control_frame;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002515 break;
2516
2517 case eHT_PSMP:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002518 retVal = mac->lim.gHTPSMPSupport;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002519 break;
2520
2521 case eHT_DSSS_CCK_MODE_40MHZ:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002522 retVal = mac->lim.gHTDsssCckRate40MHzSupport;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002523 break;
2524
2525 case eHT_MAX_AMSDU_LENGTH:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002526 retVal = (uint8_t)mac->mlme_cfg->ht_caps.ht_cap_info.
Vignesh Viswanathanddc89e52018-11-02 18:43:42 +05302527 maximal_amsdu_size;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002528 break;
2529
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07002530 case eHT_MAX_AMSDU_NUM:
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002531 retVal = (uint8_t) pe_session->max_amsdu_num;
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07002532 break;
2533
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002534 case eHT_RX_STBC:
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002535 retVal = (uint8_t) pe_session->htConfig.ht_rx_stbc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002536 break;
2537
2538 case eHT_TX_STBC:
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002539 retVal = (uint8_t) pe_session->htConfig.ht_tx_stbc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002540 break;
2541
2542 case eHT_SHORT_GI_40MHZ:
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002543 retVal = (uint8_t)(pe_session->htConfig.ht_sgi40) ?
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002544 mac->mlme_cfg->ht_caps.ht_cap_info.short_gi_40_mhz : 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002545 break;
2546
2547 case eHT_SHORT_GI_20MHZ:
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002548 retVal = (uint8_t)(pe_session->htConfig.ht_sgi20) ?
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002549 mac->mlme_cfg->ht_caps.ht_cap_info.short_gi_20_mhz : 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002550 break;
2551
2552 case eHT_GREENFIELD:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002553 retVal = (uint8_t)mac->mlme_cfg->ht_caps.ht_cap_info.
Vignesh Viswanathanddc89e52018-11-02 18:43:42 +05302554 green_field;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002555 break;
2556
2557 case eHT_MIMO_POWER_SAVE:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002558 retVal = (uint8_t) mac->lim.gHTMIMOPSState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002559 break;
2560
2561 case eHT_SUPPORTED_CHANNEL_WIDTH_SET:
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002562 retVal = (uint8_t) pe_session->htSupportedChannelWidthSet;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002563 break;
2564
2565 case eHT_ADVANCED_CODING:
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002566 retVal = (uint8_t) pe_session->htConfig.ht_rx_ldpc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002567 break;
2568
2569 case eHT_MAX_RX_AMPDU_FACTOR:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002570 retVal = mac->lim.gHTMaxRxAMpduFactor;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002571 break;
2572
2573 case eHT_MPDU_DENSITY:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002574 retVal = mac->lim.gHTAMpduDensity;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002575 break;
2576
2577 case eHT_PCO:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002578 retVal = (uint8_t)mac->mlme_cfg->ht_caps.ext_cap_info.pco;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002579 break;
2580
2581 case eHT_TRANSITION_TIME:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002582 retVal = (uint8_t)mac->mlme_cfg->ht_caps.ext_cap_info.
Vignesh Viswanathanddc89e52018-11-02 18:43:42 +05302583 transition_time;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002584 break;
2585
2586 case eHT_MCS_FEEDBACK:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002587 retVal = (uint8_t)mac->mlme_cfg->ht_caps.ext_cap_info.
Vignesh Viswanathanddc89e52018-11-02 18:43:42 +05302588 mcs_feedback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002589 break;
2590
2591 case eHT_TX_BEAMFORMING:
2592 retVal = (uint8_t) macTxBFCapabilityInfo.txBF;
2593 break;
2594
2595 case eHT_ANTENNA_SELECTION:
2596 retVal = (uint8_t) macASCapabilityInfo.antennaSelection;
2597 break;
2598
2599 case eHT_SI_GRANULARITY:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002600 retVal = mac->lim.gHTServiceIntervalGranularity;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002601 break;
2602
2603 case eHT_CONTROLLED_ACCESS:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002604 retVal = mac->lim.gHTControlledAccessOnly;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002605 break;
2606
2607 case eHT_RIFS_MODE:
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002608 retVal = pe_session->beaconParams.fRIFSMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002609 break;
2610
2611 case eHT_RECOMMENDED_TX_WIDTH_SET:
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002612 retVal = pe_session->htRecommendedTxWidthSet;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002613 break;
2614
2615 case eHT_EXTENSION_CHANNEL_OFFSET:
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002616 retVal = pe_session->htSecondaryChannelOffset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002617 break;
2618
2619 case eHT_OP_MODE:
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002620 if (LIM_IS_AP_ROLE(pe_session))
2621 retVal = pe_session->htOperMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002622 else
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002623 retVal = mac->lim.gHTOperMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002624 break;
2625
2626 case eHT_BASIC_STBC_MCS:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002627 retVal = mac->lim.gHTSTBCBasicMCS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002628 break;
2629
2630 case eHT_DUAL_CTS_PROTECTION:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002631 retVal = mac->lim.gHTDualCTSProtection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002632 break;
2633
2634 case eHT_LSIG_TXOP_PROTECTION_FULL_SUPPORT:
2635 retVal =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002636 pe_session->beaconParams.fLsigTXOPProtectionFullSupport;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002637 break;
2638
2639 case eHT_PCO_ACTIVE:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002640 retVal = mac->lim.gHTPCOActive;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002641 break;
2642
2643 case eHT_PCO_PHASE:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002644 retVal = mac->lim.gHTPCOPhase;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002645 break;
2646
2647 default:
2648 break;
2649 }
2650
2651 return retVal;
2652}
2653
2654/**
2655 * lim_enable_11a_protection() - updates protection params for enable 11a
2656 * protection request
2657 * @mac_ctx: pointer to Global MAC structure
2658 * @overlap: 1=> called from overlap context, 0 => called from assoc context.
2659 * @bcn_prms: beacon parameters
2660 * @pe_session: pe session entry
2661 *
Jeff Johnson47d75242018-05-12 15:58:53 -07002662 * This function updates protection params for enable 11a protection request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002663 *
2664 * @Return: void
2665 */
2666static void
Jeff Johnsond01da6b2018-12-02 12:10:22 -08002667lim_enable_11a_protection(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002668 uint8_t overlap,
2669 tpUpdateBeaconParams bcn_prms,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08002670 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002671{
2672 /*
2673 * If we are AP and HT capable, we need to set the HT OP mode
2674 * appropriately.
2675 */
Rajeev Kumar0ac9f2a2016-04-15 15:54:18 -07002676 if (LIM_IS_AP_ROLE(pe_session) && (true == pe_session->htCapability)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002677 if (overlap) {
Arif Hussain1cd8abf2017-12-17 19:37:50 -08002678 pe_session->gLimOverlap11aParams.protectionEnabled =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002679 true;
2680 if ((eSIR_HT_OP_MODE_OVERLAP_LEGACY !=
2681 mac_ctx->lim.gHTOperMode)
2682 && (eSIR_HT_OP_MODE_MIXED !=
2683 mac_ctx->lim.gHTOperMode)) {
2684 mac_ctx->lim.gHTOperMode =
2685 eSIR_HT_OP_MODE_OVERLAP_LEGACY;
2686 pe_session->htOperMode =
2687 eSIR_HT_OP_MODE_OVERLAP_LEGACY;
2688 lim_enable_ht_rifs_protection(mac_ctx, true,
2689 overlap, bcn_prms, pe_session);
2690 lim_enable_ht_obss_protection(mac_ctx, true,
2691 overlap, bcn_prms, pe_session);
2692 }
2693 } else {
2694 pe_session->gLim11aParams.protectionEnabled = true;
2695 if (eSIR_HT_OP_MODE_MIXED != pe_session->htOperMode) {
2696 mac_ctx->lim.gHTOperMode =
2697 eSIR_HT_OP_MODE_MIXED;
2698 pe_session->htOperMode = eSIR_HT_OP_MODE_MIXED;
2699 lim_enable_ht_rifs_protection(mac_ctx, true,
2700 overlap, bcn_prms, pe_session);
2701 lim_enable_ht_obss_protection(mac_ctx, true,
2702 overlap, bcn_prms, pe_session);
2703 }
2704 }
2705 }
2706 /* This part is common for station as well. */
2707 if (false == pe_session->beaconParams.llaCoexist) {
Yeshwanth Sriram Guntukacbe61442018-08-23 18:08:44 +05302708 pe_debug(" => protection from 11A Enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002709 bcn_prms->llaCoexist = true;
2710 pe_session->beaconParams.llaCoexist = true;
2711 bcn_prms->paramChangeBitmap |= PARAM_llACOEXIST_CHANGED;
2712 }
2713}
2714
2715/**
2716 * lim_disable_11a_protection() - updates protection params for disable 11a
2717 * protection request
2718 * @mac_ctx: pointer to Global MAC structure
2719 * @overlap: 1=> called from overlap context, 0 => called from assoc context.
2720 * @bcn_prms: beacon parameters
2721 * @pe_session: pe session entry
2722 *
Jeff Johnson47d75242018-05-12 15:58:53 -07002723 * This function updates protection params for disable 11a protection request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002724 *
2725 * @Return: void
2726 */
2727static void
Jeff Johnsond01da6b2018-12-02 12:10:22 -08002728lim_disable_11a_protection(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002729 uint8_t overlap,
2730 tpUpdateBeaconParams bcn_prms,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08002731 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002732{
2733 if (false == pe_session->beaconParams.llaCoexist)
2734 return;
2735
2736 /* for station role */
2737 if (!LIM_IS_AP_ROLE(pe_session)) {
yeshwanth sriram guntukaca71d032017-07-20 18:26:35 +05302738 pe_debug("===> Protection from 11A Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002739 bcn_prms->llaCoexist = false;
2740 pe_session->beaconParams.llaCoexist = false;
2741 bcn_prms->paramChangeBitmap |= PARAM_llACOEXIST_CHANGED;
2742 return;
2743 }
2744 /*
2745 * for AP role.
2746 * we need to take care of HT OP mode change if needed.
2747 * We need to take care of Overlap cases.
2748 */
2749 if (overlap) {
2750 /* Overlap Legacy protection disabled. */
Arif Hussain1cd8abf2017-12-17 19:37:50 -08002751 pe_session->gLimOverlap11aParams.protectionEnabled = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002752
2753 /*
2754 * We need to take care of HT OP mode iff we are HT AP.
2755 * OR no HT op-mode change is needed if any of the overlap
2756 * protection enabled.
2757 */
2758 if (!pe_session->htCapability ||
Arif Hussain1cd8abf2017-12-17 19:37:50 -08002759 (pe_session->gLimOverlap11aParams.protectionEnabled
2760 || pe_session->gLimOverlapHt20Params.protectionEnabled
2761 || pe_session->gLimOverlapNonGfParams.protectionEnabled))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002762 goto disable_11a_end;
2763
2764 /* Check if there is a need to change HT OP mode. */
2765 if (eSIR_HT_OP_MODE_OVERLAP_LEGACY ==
2766 mac_ctx->lim.gHTOperMode) {
2767 lim_enable_ht_rifs_protection(mac_ctx, false, overlap,
2768 bcn_prms, pe_session);
2769 lim_enable_ht_obss_protection(mac_ctx, false, overlap,
2770 bcn_prms, pe_session);
2771
2772 if (pe_session->gLimHt20Params.protectionEnabled)
2773 mac_ctx->lim.gHTOperMode =
2774 eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
2775 else
2776 mac_ctx->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
2777 }
2778 } else {
2779 /* Disable protection from 11A stations. */
2780 pe_session->gLim11aParams.protectionEnabled = false;
2781 lim_enable_ht_obss_protection(mac_ctx, false, overlap,
2782 bcn_prms, pe_session);
2783
2784 /*
2785 * Check if any other non-HT protection enabled. Right now we
2786 * are in HT OP Mixed mode. Change HT op mode appropriately.
2787 */
2788
2789 /* Change HT OP mode to 01 if any overlap protection enabled */
Arif Hussain1cd8abf2017-12-17 19:37:50 -08002790 if (pe_session->gLimOverlap11aParams.protectionEnabled
2791 || pe_session->gLimOverlapHt20Params.protectionEnabled
2792 || pe_session->gLimOverlapNonGfParams.protectionEnabled) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002793 mac_ctx->lim.gHTOperMode =
2794 eSIR_HT_OP_MODE_OVERLAP_LEGACY;
2795 pe_session->htOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
2796 lim_enable_ht_rifs_protection(mac_ctx, true, overlap,
2797 bcn_prms, pe_session);
2798 } else if (pe_session->gLimHt20Params.protectionEnabled) {
2799 mac_ctx->lim.gHTOperMode =
2800 eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
2801 pe_session->htOperMode =
2802 eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
2803 lim_enable_ht_rifs_protection(mac_ctx, false, overlap,
2804 bcn_prms, pe_session);
2805 } else {
2806 mac_ctx->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
2807 pe_session->htOperMode = eSIR_HT_OP_MODE_PURE;
2808 lim_enable_ht_rifs_protection(mac_ctx, false, overlap,
2809 bcn_prms, pe_session);
2810 }
2811 }
2812
2813disable_11a_end:
Arif Hussain1cd8abf2017-12-17 19:37:50 -08002814 if (!pe_session->gLimOverlap11aParams.protectionEnabled &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002815 !pe_session->gLim11aParams.protectionEnabled) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05302816 pe_warn("===> Protection from 11A Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002817 bcn_prms->llaCoexist = false;
2818 pe_session->beaconParams.llaCoexist = false;
2819 bcn_prms->paramChangeBitmap |= PARAM_llACOEXIST_CHANGED;
2820 }
2821}
2822
2823/**
2824 * lim_update_11a_protection() - based on config setting enables\disables 11a
2825 * protection.
2826 * @mac_ctx: pointer to Global MAC structure
2827 * @enable: 1=> enable protection, 0=> disable protection.
2828 * @overlap: 1=> called from overlap context, 0 => called from assoc context.
2829 * @bcn_prms: beacon parameters
2830 * @session: pe session entry
2831 *
2832 * This based on config setting enables\disables 11a protection.
2833 *
2834 * @Return: success of failure of operation
2835 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002836QDF_STATUS
Jeff Johnsond01da6b2018-12-02 12:10:22 -08002837lim_update_11a_protection(struct mac_context *mac_ctx, uint8_t enable,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002838 uint8_t overlap, tpUpdateBeaconParams bcn_prms,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08002839 struct pe_session *session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002840{
2841 if (NULL == session) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05302842 pe_err("session is NULL");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002843 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002844 }
2845 /* overlapping protection configuration check. */
2846 if (!overlap) {
2847 /* normal protection config check */
2848 if ((LIM_IS_AP_ROLE(session)) &&
2849 (!session->cfgProtection.fromlla)) {
2850 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05302851 pe_warn("protection from 11a is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002852 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002853 }
2854 }
2855
2856 if (enable)
2857 lim_enable_11a_protection(mac_ctx, overlap, bcn_prms, session);
2858 else
2859 lim_disable_11a_protection(mac_ctx, overlap, bcn_prms, session);
2860
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002861 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002862}
2863
2864/**
2865 * lim_handle_enable11g_protection_enabled() - handle 11g protection enabled
2866 * @mac_ctx: pointer to Globale Mac structure
2867 * @beaconparams: pointer to tpUpdateBeaconParams
2868 * @overlap: 1=> called from overlap context, 0 => called from assoc context.
Jeff Johnsonc8baa902018-11-18 21:59:07 -08002869 * @session_entry: pointer to struct pe_session *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002870 *
2871 * Function handles 11g protection enaled case
2872 *
2873 * Return: none
2874 */
2875static void
Jeff Johnsond01da6b2018-12-02 12:10:22 -08002876lim_handle_enable11g_protection_enabled(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002877 tpUpdateBeaconParams beaconparams,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08002878 uint8_t overlap, struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002879{
2880 /*
2881 * If we are AP and HT capable, we need to set the HT OP mode
2882 * appropriately.
2883 */
2884 if (LIM_IS_AP_ROLE(session_entry) && overlap) {
2885 session_entry->gLimOlbcParams.protectionEnabled = true;
2886
Nishank Aggarwal0402b432017-03-24 19:17:36 +05302887 pe_debug("protection from olbc is enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002888
2889 if (true == session_entry->htCapability) {
2890 if ((eSIR_HT_OP_MODE_OVERLAP_LEGACY !=
2891 session_entry->htOperMode) &&
2892 (eSIR_HT_OP_MODE_MIXED !=
2893 session_entry->htOperMode)) {
2894 session_entry->htOperMode =
2895 eSIR_HT_OP_MODE_OVERLAP_LEGACY;
2896 }
2897 /*
2898 * CR-263021: OBSS bit is not switching back to 0 after
2899 * disabling the overlapping legacy BSS
2900 */
2901 /*
2902 * This fixes issue of OBSS bit not set after 11b, 11g
2903 * station leaves
2904 */
2905 lim_enable_ht_rifs_protection(mac_ctx, true,
2906 overlap, beaconparams, session_entry);
2907 /*
2908 * Not processing OBSS bit from other APs, as we are
2909 * already taking care of Protection from overlapping
2910 * BSS based on erp IE or useProtection bit
2911 */
2912 lim_enable_ht_obss_protection(mac_ctx, true,
2913 overlap, beaconparams, session_entry);
2914 }
2915 } else if (LIM_IS_AP_ROLE(session_entry) && !overlap) {
2916 session_entry->gLim11bParams.protectionEnabled = true;
Nishank Aggarwal0402b432017-03-24 19:17:36 +05302917 pe_debug("protection from 11b is enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002918 if (true == session_entry->htCapability) {
2919 if (eSIR_HT_OP_MODE_MIXED !=
2920 session_entry->htOperMode) {
2921 session_entry->htOperMode =
2922 eSIR_HT_OP_MODE_MIXED;
2923 lim_enable_ht_rifs_protection(mac_ctx,
2924 true, overlap, beaconparams,
2925 session_entry);
2926 lim_enable_ht_obss_protection(mac_ctx,
2927 true, overlap, beaconparams,
2928 session_entry);
2929 }
2930 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002931 }
Rajeev Kumar0ac9f2a2016-04-15 15:54:18 -07002932
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002933 /* This part is common for staiton as well. */
2934 if (false == session_entry->beaconParams.llbCoexist) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05302935 pe_debug("=> 11G Protection Enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002936 beaconparams->llbCoexist =
2937 session_entry->beaconParams.llbCoexist = true;
2938 beaconparams->paramChangeBitmap |=
2939 PARAM_llBCOEXIST_CHANGED;
2940 }
2941}
2942
2943/**
2944 * lim_handle_11g_protection_for_11bcoexist() - 11g protection for 11b co-ex
2945 * @mac_ctx: pointer to Globale Mac structure
2946 * @beaconparams: pointer to tpUpdateBeaconParams
2947 * @overlap: 1=> called from overlap context, 0 => called from assoc context.
Jeff Johnsonc8baa902018-11-18 21:59:07 -08002948 * @session_entry: pointer to struct pe_session *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002949 *
2950 * Function handles 11g protection for 11b co-exist
2951 *
2952 * Return: none
2953 */
2954static void
Jeff Johnsond01da6b2018-12-02 12:10:22 -08002955lim_handle_11g_protection_for_11bcoexist(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002956 tpUpdateBeaconParams beaconparams,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08002957 uint8_t overlap, struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002958{
2959 /*
2960 * For AP role:
2961 * we need to take care of HT OP mode change if needed.
2962 * We need to take care of Overlap cases.
2963 */
2964 if (LIM_IS_AP_ROLE(session_entry) && overlap) {
2965 /* Overlap Legacy protection disabled. */
2966 session_entry->gLimOlbcParams.protectionEnabled = false;
2967
2968 /* We need to take care of HT OP mode if we are HT AP. */
2969 if (session_entry->htCapability) {
2970 /*
2971 * no HT op mode change if any of the overlap
2972 * protection enabled.
2973 */
2974 if (!(session_entry->gLimOverlap11gParams.
2975 protectionEnabled ||
2976 session_entry->gLimOverlapHt20Params.
2977 protectionEnabled ||
2978 session_entry->gLimOverlapNonGfParams.
2979 protectionEnabled) &&
2980 /*
2981 * Check if there is a need to change HT
2982 * OP mode.
2983 */
2984 (eSIR_HT_OP_MODE_OVERLAP_LEGACY ==
2985 session_entry->htOperMode)) {
2986 lim_enable_ht_rifs_protection(mac_ctx, false,
2987 overlap, beaconparams, session_entry);
2988 lim_enable_ht_obss_protection(mac_ctx, false,
2989 overlap, beaconparams, session_entry);
2990 if (session_entry->gLimHt20Params.
2991 protectionEnabled) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302992 if (eHT_CHANNEL_WIDTH_20MHZ ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002993 session_entry->htSupportedChannelWidthSet)
2994 session_entry->htOperMode =
2995 eSIR_HT_OP_MODE_PURE;
2996 else
2997 session_entry->htOperMode =
2998 eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
2999 } else
3000 session_entry->htOperMode =
3001 eSIR_HT_OP_MODE_PURE;
3002 }
3003 }
3004 } else if (LIM_IS_AP_ROLE(session_entry) && !overlap) {
3005 /* Disable protection from 11B stations. */
3006 session_entry->gLim11bParams.protectionEnabled = false;
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303007 pe_debug("===> 11B Protection Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003008 /* Check if any other non-HT protection enabled. */
3009 if (!session_entry->gLim11gParams.protectionEnabled) {
3010 /* Right now we are in HT OP Mixed mode. */
3011 /* Change HT op mode appropriately. */
3012 lim_enable_ht_obss_protection(mac_ctx, false, overlap,
3013 beaconparams, session_entry);
3014 /*
3015 * Change HT OP mode to 01 if any overlap protection
3016 * enabled
3017 */
3018 if (session_entry->gLimOlbcParams.protectionEnabled ||
3019 session_entry->gLimOverlap11gParams.
3020 protectionEnabled ||
3021 session_entry->gLimOverlapHt20Params.
3022 protectionEnabled ||
3023 session_entry->gLimOverlapNonGfParams.
3024 protectionEnabled) {
3025 session_entry->htOperMode =
3026 eSIR_HT_OP_MODE_OVERLAP_LEGACY;
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303027 pe_debug("===> 11G Protection Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003028 lim_enable_ht_rifs_protection(mac_ctx, true,
3029 overlap, beaconparams,
3030 session_entry);
3031 } else if (session_entry->gLimHt20Params.
3032 protectionEnabled) {
3033 /* Commenting because of CR 258588 WFA cert */
3034 /* session_entry->htOperMode =
3035 eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT; */
3036 session_entry->htOperMode =
3037 eSIR_HT_OP_MODE_PURE;
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303038 pe_debug("===> 11G Protection Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003039 lim_enable_ht_rifs_protection(mac_ctx, false,
3040 overlap, beaconparams,
3041 session_entry);
3042 } else {
3043 session_entry->htOperMode =
3044 eSIR_HT_OP_MODE_PURE;
3045 lim_enable_ht_rifs_protection(mac_ctx, false,
3046 overlap, beaconparams,
3047 session_entry);
3048 }
3049 }
3050 }
3051 if (LIM_IS_AP_ROLE(session_entry)) {
3052 if (!session_entry->gLimOlbcParams.protectionEnabled &&
3053 !session_entry->gLim11bParams.protectionEnabled) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303054 pe_debug("===> 11G Protection Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003055 beaconparams->llbCoexist =
3056 session_entry->beaconParams.llbCoexist =
3057 false;
3058 beaconparams->paramChangeBitmap |=
3059 PARAM_llBCOEXIST_CHANGED;
3060 }
3061 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003062 /* For station role */
Rajeev Kumar0ac9f2a2016-04-15 15:54:18 -07003063 if (!LIM_IS_AP_ROLE(session_entry)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303064 pe_debug("===> 11G Protection Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003065 beaconparams->llbCoexist =
3066 session_entry->beaconParams.llbCoexist = false;
3067 beaconparams->paramChangeBitmap |=
3068 PARAM_llBCOEXIST_CHANGED;
3069 }
3070}
3071
3072/**
3073 * lim_enable11g_protection() - Function to enable 11g protection
3074 * @mac_ctx: pointer to Global Mac structure
3075 * @enable: 1=> enable protection, 0=> disable protection.
3076 * @overlap: 1=> called from overlap context, 0 => called from assoc context.
3077 * @beaconparams: pointer to tpUpdateBeaconParams
Jeff Johnsonc8baa902018-11-18 21:59:07 -08003078 * @session_entry: pointer to struct pe_session *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003079 *
3080 * based on config setting enables\disables 11g protection.
3081 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003082 * Return: Success - QDF_STATUS_SUCCESS - Success, Error number - Failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003083 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003084QDF_STATUS
Jeff Johnsond01da6b2018-12-02 12:10:22 -08003085lim_enable11g_protection(struct mac_context *mac_ctx, uint8_t enable,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003086 uint8_t overlap, tpUpdateBeaconParams beaconparams,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08003087 struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003088{
3089
3090 /* overlapping protection configuration check. */
3091 if (!overlap) {
3092 /* normal protection config check */
3093 if ((LIM_IS_AP_ROLE(session_entry)) &&
3094 !session_entry->cfgProtection.fromllb) {
3095 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303096 pe_debug("protection from 11b is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003097 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003098 } else if (!LIM_IS_AP_ROLE(session_entry)) {
3099 if (!mac_ctx->lim.cfgProtection.fromllb) {
3100 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303101 pe_debug("protection from 11b is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003102 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003103 }
3104 }
3105 }
3106
3107 if (enable) {
3108 lim_handle_enable11g_protection_enabled(mac_ctx, beaconparams,
3109 overlap, session_entry);
3110 } else if (true == session_entry->beaconParams.llbCoexist) {
3111 lim_handle_11g_protection_for_11bcoexist(mac_ctx, beaconparams,
3112 overlap, session_entry);
3113 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003114 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003115}
3116
3117/** -------------------------------------------------------------
3118 \fn lim_enable_ht_protection_from11g
3119 \brief based on cofig enables\disables protection from 11g.
3120 \param uint8_t enable : 1=> enable protection, 0=> disable protection.
3121 \param uint8_t overlap: 1=> called from overlap context, 0 => called from assoc context.
3122 \param tpUpdateBeaconParams pBeaconParams
3123 \return None
3124 -------------------------------------------------------------*/
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003125QDF_STATUS
Jeff Johnsond01da6b2018-12-02 12:10:22 -08003126lim_enable_ht_protection_from11g(struct mac_context *mac, uint8_t enable,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003127 uint8_t overlap,
3128 tpUpdateBeaconParams pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003129 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003130{
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003131 if (!pe_session->htCapability)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003132 return QDF_STATUS_SUCCESS; /* protection from 11g is only for HT stations. */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003133
3134 /* overlapping protection configuration check. */
3135 if (overlap) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003136 if ((LIM_IS_AP_ROLE(pe_session))
3137 && (!pe_session->cfgProtection.overlapFromllg)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003138 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303139 pe_debug("overlap protection from 11g is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003140 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003141 }
3142 } else {
3143 /* normal protection config check */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003144 if (LIM_IS_AP_ROLE(pe_session) &&
3145 !pe_session->cfgProtection.fromllg) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003146 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303147 pe_debug("protection from 11g is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003148 return QDF_STATUS_SUCCESS;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003149 } else if (!LIM_IS_AP_ROLE(pe_session)) {
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003150 if (!mac->lim.cfgProtection.fromllg) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003151 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303152 pe_debug("protection from 11g is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003153 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003154 }
3155 }
3156 }
3157 if (enable) {
3158 /* If we are AP and HT capable, we need to set the HT OP mode */
3159 /* appropriately. */
3160
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003161 if (LIM_IS_AP_ROLE(pe_session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003162 if (overlap) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003163 pe_session->gLimOverlap11gParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003164 protectionEnabled = true;
3165 /* 11g exists in overlap BSS. */
3166 /* need not to change the operating mode to overlap_legacy */
3167 /* if higher or same protection operating mode is enabled right now. */
3168 if ((eSIR_HT_OP_MODE_OVERLAP_LEGACY !=
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003169 pe_session->htOperMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003170 && (eSIR_HT_OP_MODE_MIXED !=
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003171 pe_session->htOperMode)) {
3172 pe_session->htOperMode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003173 eSIR_HT_OP_MODE_OVERLAP_LEGACY;
3174 }
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003175 lim_enable_ht_rifs_protection(mac, true, overlap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003176 pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003177 pe_session);
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003178 lim_enable_ht_obss_protection(mac, true, overlap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003179 pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003180 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003181 } else {
3182 /* 11g is associated to an AP operating in 11n mode. */
3183 /* Change the HT operating mode to 'mixed mode'. */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003184 pe_session->gLim11gParams.protectionEnabled =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003185 true;
3186 if (eSIR_HT_OP_MODE_MIXED !=
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003187 pe_session->htOperMode) {
3188 pe_session->htOperMode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003189 eSIR_HT_OP_MODE_MIXED;
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003190 lim_enable_ht_rifs_protection(mac, true,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003191 overlap,
3192 pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003193 pe_session);
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003194 lim_enable_ht_obss_protection(mac, true,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003195 overlap,
3196 pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003197 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003198 }
3199 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003200 }
3201 /* This part is common for staiton as well. */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003202 if (false == pe_session->beaconParams.llgCoexist) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003203 pBeaconParams->llgCoexist =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003204 pe_session->beaconParams.llgCoexist = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003205 pBeaconParams->paramChangeBitmap |=
3206 PARAM_llGCOEXIST_CHANGED;
3207 } else if (true ==
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003208 pe_session->gLimOverlap11gParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003209 protectionEnabled) {
3210 /* As operating mode changed after G station assoc some way to update beacon */
3211 /* This addresses the issue of mode not changing to - 11 in beacon when OBSS overlap is enabled */
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003212 /* mac->sch.schObject.fBeaconChanged = 1; */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003213 pBeaconParams->paramChangeBitmap |=
3214 PARAM_llGCOEXIST_CHANGED;
3215 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003216 } else if (true == pe_session->beaconParams.llgCoexist) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003217 /* for AP role. */
3218 /* we need to take care of HT OP mode change if needed. */
3219 /* We need to take care of Overlap cases. */
3220
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003221 if (LIM_IS_AP_ROLE(pe_session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003222 if (overlap) {
3223 /* Overlap Legacy protection disabled. */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003224 if (pe_session->gLim11gParams.numSta == 0)
3225 pe_session->gLimOverlap11gParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003226 protectionEnabled = false;
3227
3228 /* no HT op mode change if any of the overlap protection enabled. */
3229 if (!
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003230 (pe_session->gLimOlbcParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003231 protectionEnabled
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003232 || pe_session->gLimOverlapHt20Params.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003233 protectionEnabled
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003234 || pe_session->gLimOverlapNonGfParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003235 protectionEnabled)) {
3236 /* Check if there is a need to change HT OP mode. */
3237 if (eSIR_HT_OP_MODE_OVERLAP_LEGACY ==
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003238 pe_session->htOperMode) {
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003239 lim_enable_ht_rifs_protection(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003240 false,
3241 overlap,
3242 pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003243 pe_session);
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003244 lim_enable_ht_obss_protection(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003245 false,
3246 overlap,
3247 pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003248 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003249
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003250 if (pe_session->gLimHt20Params.protectionEnabled) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303251 if (eHT_CHANNEL_WIDTH_20MHZ ==
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003252 pe_session->htSupportedChannelWidthSet)
3253 pe_session->htOperMode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003254 eSIR_HT_OP_MODE_PURE;
3255 else
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003256 pe_session->htOperMode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003257 eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
3258 } else
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003259 pe_session->htOperMode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003260 eSIR_HT_OP_MODE_PURE;
3261 }
3262 }
3263 } else {
3264 /* Disable protection from 11G stations. */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003265 pe_session->gLim11gParams.protectionEnabled =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003266 false;
3267 /* Check if any other non-HT protection enabled. */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003268 if (!pe_session->gLim11bParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003269 protectionEnabled) {
3270
3271 /* Right now we are in HT OP Mixed mode. */
3272 /* Change HT op mode appropriately. */
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003273 lim_enable_ht_obss_protection(mac, false,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003274 overlap,
3275 pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003276 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003277
3278 /* Change HT OP mode to 01 if any overlap protection enabled */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003279 if (pe_session->gLimOlbcParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003280 protectionEnabled
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003281 || pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003282 gLimOverlap11gParams.
3283 protectionEnabled
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003284 || pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003285 gLimOverlapHt20Params.
3286 protectionEnabled
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003287 || pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003288 gLimOverlapNonGfParams.
3289 protectionEnabled) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003290 pe_session->htOperMode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003291 eSIR_HT_OP_MODE_OVERLAP_LEGACY;
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003292 lim_enable_ht_rifs_protection(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003293 true,
3294 overlap,
3295 pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003296 pe_session);
3297 } else if (pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003298 gLimHt20Params.
3299 protectionEnabled) {
3300 /* Commenting because of CR 258588 WFA cert */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003301 /* pe_session->htOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT; */
3302 pe_session->htOperMode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003303 eSIR_HT_OP_MODE_PURE;
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003304 lim_enable_ht_rifs_protection(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003305 false,
3306 overlap,
3307 pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003308 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003309 } else {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003310 pe_session->htOperMode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003311 eSIR_HT_OP_MODE_PURE;
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003312 lim_enable_ht_rifs_protection(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003313 false,
3314 overlap,
3315 pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003316 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003317 }
3318 }
3319 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003320 if (!pe_session->gLimOverlap11gParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003321 protectionEnabled
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003322 && !pe_session->gLim11gParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003323 protectionEnabled) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303324 pe_debug("===> Protection from 11G Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003325 pBeaconParams->llgCoexist =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003326 pe_session->beaconParams.llgCoexist =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003327 false;
3328 pBeaconParams->paramChangeBitmap |=
3329 PARAM_llGCOEXIST_CHANGED;
3330 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003331 }
3332 /* for station role */
3333 else {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303334 pe_debug("===> Protection from 11G Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003335 pBeaconParams->llgCoexist =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003336 pe_session->beaconParams.llgCoexist = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003337 pBeaconParams->paramChangeBitmap |=
3338 PARAM_llGCOEXIST_CHANGED;
3339 }
3340 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003341 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003342}
3343
3344/* FIXME_PROTECTION : need to check for no APSD whenever we want to enable this protection. */
3345/* This check will be done at the caller. */
3346
3347/** -------------------------------------------------------------
3348 \fn limEnableHtObssProtection
3349 \brief based on cofig enables\disables obss protection.
3350 \param uint8_t enable : 1=> enable protection, 0=> disable protection.
3351 \param uint8_t overlap: 1=> called from overlap context, 0 => called from assoc context.
3352 \param tpUpdateBeaconParams pBeaconParams
3353 \return None
3354 -------------------------------------------------------------*/
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003355QDF_STATUS
Jeff Johnsond01da6b2018-12-02 12:10:22 -08003356lim_enable_ht_obss_protection(struct mac_context *mac, uint8_t enable,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003357 uint8_t overlap, tpUpdateBeaconParams pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003358 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003359{
3360
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003361 if (!pe_session->htCapability)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003362 return QDF_STATUS_SUCCESS; /* this protection is only for HT stations. */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003363
3364 /* overlapping protection configuration check. */
3365 if (overlap) {
3366 /* overlapping protection configuration check. */
3367 } else {
3368 /* normal protection config check */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003369 if ((LIM_IS_AP_ROLE(pe_session)) &&
3370 !pe_session->cfgProtection.obss) { /* ToDo Update this field */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003371 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303372 pe_debug("protection from Obss is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003373 return QDF_STATUS_SUCCESS;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003374 } else if (!LIM_IS_AP_ROLE(pe_session)) {
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003375 if (!mac->lim.cfgProtection.obss) { /* ToDo Update this field */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003376 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303377 pe_debug("protection from Obss is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003378 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003379 }
3380 }
3381 }
3382
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003383 if (LIM_IS_AP_ROLE(pe_session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003384 if ((enable)
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003385 && (false == pe_session->beaconParams.gHTObssMode)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303386 pe_debug("=>obss protection enabled");
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003387 pe_session->beaconParams.gHTObssMode = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003388 pBeaconParams->paramChangeBitmap |= PARAM_OBSS_MODE_CHANGED; /* UPDATE AN ENUM FOR OBSS MODE <todo> */
3389
3390 } else if (!enable
3391 && (true ==
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003392 pe_session->beaconParams.gHTObssMode)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303393 pe_debug("===> obss Protection disabled");
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003394 pe_session->beaconParams.gHTObssMode = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003395 pBeaconParams->paramChangeBitmap |=
3396 PARAM_OBSS_MODE_CHANGED;
3397
3398 }
3399/* CR-263021: OBSS bit is not switching back to 0 after disabling the overlapping legacy BSS */
3400 if (!enable && !overlap) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003401 pe_session->gLimOverlap11gParams.protectionEnabled =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003402 false;
3403 }
3404 } else {
3405 if ((enable)
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003406 && (false == pe_session->beaconParams.gHTObssMode)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303407 pe_debug("=>obss protection enabled");
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003408 pe_session->beaconParams.gHTObssMode = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003409 pBeaconParams->paramChangeBitmap |= PARAM_OBSS_MODE_CHANGED; /* UPDATE AN ENUM FOR OBSS MODE <todo> */
3410
3411 } else if (!enable
3412 && (true ==
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003413 pe_session->beaconParams.gHTObssMode)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303414 pe_debug("===> obss Protection disabled");
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003415 pe_session->beaconParams.gHTObssMode = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003416 pBeaconParams->paramChangeBitmap |=
3417 PARAM_OBSS_MODE_CHANGED;
3418
3419 }
3420 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003421 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003422}
3423
3424/**
3425 * lim_handle_ht20protection_enabled() - Handle ht20 protection enabled
3426 * @mac_ctx: pointer to Gloal Mac Structure
3427 * @overlap: variable for overlap detection
3428 * @beaconparams: pointer to tpUpdateBeaconParams
Jeff Johnsonc8baa902018-11-18 21:59:07 -08003429 * @session_entry: pointer to struct pe_session *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003430 *
3431 * Function handles ht20 protection enabled
3432 *
3433 * Return: none
3434 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08003435static void lim_handle_ht20protection_enabled(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003436 uint8_t overlap, tpUpdateBeaconParams beaconparams,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08003437 struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003438{
3439 /*
3440 * If we are AP and HT capable, we need to set the HT OP mode
3441 * appropriately.
3442 */
3443 if (LIM_IS_AP_ROLE(session_entry) && overlap) {
3444 session_entry->gLimOverlapHt20Params.protectionEnabled = true;
3445 if ((eSIR_HT_OP_MODE_OVERLAP_LEGACY !=
3446 session_entry->htOperMode) &&
3447 (eSIR_HT_OP_MODE_MIXED !=
3448 session_entry->htOperMode)) {
3449 session_entry->htOperMode =
3450 eSIR_HT_OP_MODE_OVERLAP_LEGACY;
3451 lim_enable_ht_rifs_protection(mac_ctx, true,
3452 overlap, beaconparams, session_entry);
3453 }
3454 } else if (LIM_IS_AP_ROLE(session_entry) && !overlap) {
3455 session_entry->gLimHt20Params.protectionEnabled = true;
3456 if (eSIR_HT_OP_MODE_PURE == session_entry->htOperMode) {
Naveen Rawate702e9b2015-11-17 11:50:40 -08003457 if (session_entry->htSupportedChannelWidthSet !=
3458 eHT_CHANNEL_WIDTH_20MHZ)
3459 session_entry->htOperMode =
3460 eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003461 lim_enable_ht_rifs_protection(mac_ctx, false,
3462 overlap, beaconparams, session_entry);
3463 lim_enable_ht_obss_protection(mac_ctx, false,
3464 overlap, beaconparams, session_entry);
3465 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003466 }
3467 /* This part is common for staiton as well. */
3468 if (false == session_entry->beaconParams.ht20Coexist) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303469 pe_debug("=> Protection from HT20 Enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003470 beaconparams->ht20MhzCoexist =
3471 session_entry->beaconParams.ht20Coexist = true;
3472 beaconparams->paramChangeBitmap |=
3473 PARAM_HT20MHZCOEXIST_CHANGED;
3474 }
3475}
3476
3477/**
3478 * lim_handle_ht20coexist_ht20protection() - ht20 protection for ht20 coexist
3479 * @mac_ctx: pointer to Gloal Mac Structure
3480 * @beaconparams: pointer to tpUpdateBeaconParams
Jeff Johnsonc8baa902018-11-18 21:59:07 -08003481 * @session_entry: pointer to struct pe_session *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003482 * @overlap: variable for overlap detection
3483 *
3484 * Function handles ht20 protection for ht20 coexist
3485 *
3486 * Return: none
3487 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08003488static void lim_handle_ht20coexist_ht20protection(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003489 tpUpdateBeaconParams beaconparams,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08003490 struct pe_session *session_entry, uint8_t overlap)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003491{
3492 /*
3493 * For AP role:
3494 * we need to take care of HT OP mode change if needed.
3495 * We need to take care of Overlap cases.
3496 */
3497 if (LIM_IS_AP_ROLE(session_entry) && overlap) {
3498 /* Overlap Legacy protection disabled. */
3499 session_entry->gLimOverlapHt20Params.protectionEnabled =
3500 false;
3501 /*
3502 * no HT op mode change if any of the overlap
3503 * protection enabled.
3504 */
3505 if (!(session_entry->gLimOlbcParams.protectionEnabled ||
3506 session_entry->gLimOverlap11gParams.protectionEnabled ||
3507 session_entry->gLimOverlapHt20Params.protectionEnabled
3508 || session_entry->gLimOverlapNonGfParams.
3509 protectionEnabled) &&
3510 /*
3511 * Check if there is a need to change HT
3512 * OP mode.
3513 */
3514 (eSIR_HT_OP_MODE_OVERLAP_LEGACY ==
3515 session_entry->htOperMode)) {
wadesong42968e92017-06-08 14:11:21 +08003516 if (session_entry->gLimHt20Params.
3517 protectionEnabled) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303518 if (eHT_CHANNEL_WIDTH_20MHZ ==
wadesong42968e92017-06-08 14:11:21 +08003519 session_entry->
3520 htSupportedChannelWidthSet)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003521 session_entry->htOperMode =
3522 eSIR_HT_OP_MODE_PURE;
3523 else
3524 session_entry->htOperMode =
3525 eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
3526
wadesong42968e92017-06-08 14:11:21 +08003527 lim_enable_ht_rifs_protection(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003528 false, overlap, beaconparams,
3529 session_entry);
wadesong42968e92017-06-08 14:11:21 +08003530 lim_enable_ht_obss_protection(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003531 false, overlap, beaconparams,
3532 session_entry);
wadesong42968e92017-06-08 14:11:21 +08003533 } else {
3534 session_entry->htOperMode =
3535 eSIR_HT_OP_MODE_PURE;
3536 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003537 }
3538 } else if (LIM_IS_AP_ROLE(session_entry) && !overlap) {
3539 /* Disable protection from 11G stations. */
3540 session_entry->gLimHt20Params.protectionEnabled = false;
3541 /* Change HT op mode appropriately. */
3542 if (eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT ==
3543 session_entry->htOperMode) {
3544 session_entry->htOperMode =
3545 eSIR_HT_OP_MODE_PURE;
3546 lim_enable_ht_rifs_protection(mac_ctx, false,
3547 overlap, beaconparams, session_entry);
3548 lim_enable_ht_obss_protection(mac_ctx, false,
3549 overlap, beaconparams, session_entry);
3550 }
3551 }
3552 if (LIM_IS_AP_ROLE(session_entry)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303553 pe_debug("===> Protection from HT 20 Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003554 beaconparams->ht20MhzCoexist =
3555 session_entry->beaconParams.ht20Coexist = false;
3556 beaconparams->paramChangeBitmap |=
3557 PARAM_HT20MHZCOEXIST_CHANGED;
3558 }
Rajeev Kumar0ac9f2a2016-04-15 15:54:18 -07003559 if (!LIM_IS_AP_ROLE(session_entry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003560 /* For station role */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303561 pe_debug("===> Protection from HT20 Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003562 beaconparams->ht20MhzCoexist =
3563 session_entry->beaconParams.ht20Coexist = false;
3564 beaconparams->paramChangeBitmap |=
3565 PARAM_HT20MHZCOEXIST_CHANGED;
3566 }
3567}
3568
3569/**
3570 * lim_enable_ht20_protection() - Function to enable ht20 protection
3571 * @mac_ctx: pointer to Global Mac structure
3572 * @enable: 1=> enable protection, 0=> disable protection.
3573 * @overlap: 1=> called from overlap context, 0 => called from assoc context.
3574 * @beaconparams: pointer to tpUpdateBeaconParams
Jeff Johnsonc8baa902018-11-18 21:59:07 -08003575 * @session_entry: pointer to struct pe_session *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003576 *
3577 * based on cofig enables\disables protection from Ht20
3578 *
3579 * Return: 0 - success
3580 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08003581QDF_STATUS lim_enable_ht20_protection(struct mac_context *mac_ctx, uint8_t enable,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003582 uint8_t overlap, tpUpdateBeaconParams beaconparams,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08003583 struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003584{
3585 /* This protection is only for HT stations. */
3586 if (!session_entry->htCapability)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003587 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003588
3589 /* overlapping protection configuration check. */
3590 if (!overlap) {
3591 /* normal protection config check */
3592 if ((LIM_IS_AP_ROLE(session_entry)) &&
3593 !session_entry->cfgProtection.ht20) {
3594 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303595 pe_debug("protection from HT20 is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003596 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003597 } else if (!LIM_IS_AP_ROLE(session_entry)) {
3598 if (!mac_ctx->lim.cfgProtection.ht20) {
3599 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303600 pe_debug("protection from HT20 is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003601 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003602 }
3603 }
3604 }
3605
3606 if (enable)
3607 lim_handle_ht20protection_enabled(mac_ctx, overlap,
3608 beaconparams, session_entry);
3609 else if (true == session_entry->beaconParams.ht20Coexist)
3610 lim_handle_ht20coexist_ht20protection(mac_ctx, beaconparams,
3611 session_entry, overlap);
3612
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003613 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003614}
3615
3616/** -------------------------------------------------------------
3617 \fn lim_enable_ht_non_gf_protection
3618 \brief based on cofig enables\disables protection from NonGf.
3619 \param uint8_t enable : 1=> enable protection, 0=> disable protection.
3620 \param uint8_t overlap: 1=> called from overlap context, 0 => called from assoc context.
3621 \param tpUpdateBeaconParams pBeaconParams
3622 \return None
3623 -------------------------------------------------------------*/
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003624QDF_STATUS
Jeff Johnsond01da6b2018-12-02 12:10:22 -08003625lim_enable_ht_non_gf_protection(struct mac_context *mac, uint8_t enable,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003626 uint8_t overlap, tpUpdateBeaconParams pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003627 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003628{
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003629 if (!pe_session->htCapability)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003630 return QDF_STATUS_SUCCESS; /* this protection is only for HT stations. */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003631
3632 /* overlapping protection configuration check. */
3633 if (overlap) {
3634 } else {
3635 /* normal protection config check */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003636 if (LIM_IS_AP_ROLE(pe_session) &&
3637 !pe_session->cfgProtection.nonGf) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003638 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303639 pe_debug("protection from NonGf is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003640 return QDF_STATUS_SUCCESS;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003641 } else if (!LIM_IS_AP_ROLE(pe_session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003642 /* normal protection config check */
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003643 if (!mac->lim.cfgProtection.nonGf) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003644 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303645 pe_debug("protection from NonGf is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003646 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003647 }
3648 }
3649 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003650 if (LIM_IS_AP_ROLE(pe_session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003651 if ((enable)
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003652 && (false == pe_session->beaconParams.llnNonGFCoexist)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303653 pe_debug(" => Protection from non GF Enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003654 pBeaconParams->llnNonGFCoexist =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003655 pe_session->beaconParams.llnNonGFCoexist = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003656 pBeaconParams->paramChangeBitmap |=
3657 PARAM_NON_GF_DEVICES_PRESENT_CHANGED;
3658 } else if (!enable
3659 && (true ==
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003660 pe_session->beaconParams.llnNonGFCoexist)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303661 pe_debug("===> Protection from Non GF Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003662 pBeaconParams->llnNonGFCoexist =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003663 pe_session->beaconParams.llnNonGFCoexist = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003664 pBeaconParams->paramChangeBitmap |=
3665 PARAM_NON_GF_DEVICES_PRESENT_CHANGED;
3666 }
3667 } else {
3668 if ((enable)
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003669 && (false == pe_session->beaconParams.llnNonGFCoexist)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303670 pe_debug(" => Protection from non GF Enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003671 pBeaconParams->llnNonGFCoexist =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003672 pe_session->beaconParams.llnNonGFCoexist = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003673 pBeaconParams->paramChangeBitmap |=
3674 PARAM_NON_GF_DEVICES_PRESENT_CHANGED;
3675 } else if (!enable
3676 && (true ==
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003677 pe_session->beaconParams.llnNonGFCoexist)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303678 pe_debug("===> Protection from Non GF Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003679 pBeaconParams->llnNonGFCoexist =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003680 pe_session->beaconParams.llnNonGFCoexist = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003681 pBeaconParams->paramChangeBitmap |=
3682 PARAM_NON_GF_DEVICES_PRESENT_CHANGED;
3683 }
3684 }
3685
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003686 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003687}
3688
3689/** -------------------------------------------------------------
3690 \fn lim_enable_ht_lsig_txop_protection
3691 \brief based on cofig enables\disables LsigTxop protection.
3692 \param uint8_t enable : 1=> enable protection, 0=> disable protection.
3693 \param uint8_t overlap: 1=> called from overlap context, 0 => called from assoc context.
3694 \param tpUpdateBeaconParams pBeaconParams
3695 \return None
3696 -------------------------------------------------------------*/
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003697QDF_STATUS
Jeff Johnsond01da6b2018-12-02 12:10:22 -08003698lim_enable_ht_lsig_txop_protection(struct mac_context *mac, uint8_t enable,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003699 uint8_t overlap,
3700 tpUpdateBeaconParams pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003701 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003702{
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003703 if (!pe_session->htCapability)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003704 return QDF_STATUS_SUCCESS; /* this protection is only for HT stations. */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003705
3706 /* overlapping protection configuration check. */
3707 if (overlap) {
3708 } else {
3709 /* normal protection config check */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003710 if (LIM_IS_AP_ROLE(pe_session) &&
3711 !pe_session->cfgProtection.lsigTxop) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003712 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303713 pe_debug("protection from LsigTxop not supported is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003714 return QDF_STATUS_SUCCESS;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003715 } else if (!LIM_IS_AP_ROLE(pe_session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003716 /* normal protection config check */
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003717 if (!mac->lim.cfgProtection.lsigTxop) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003718 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303719 pe_debug("protection from LsigTxop not supported is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003720 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003721 }
3722 }
3723 }
3724
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003725 if (LIM_IS_AP_ROLE(pe_session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003726 if ((enable)
3727 && (false ==
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003728 pe_session->beaconParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003729 fLsigTXOPProtectionFullSupport)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303730 pe_debug(" => Protection from LsigTxop Enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003731 pBeaconParams->fLsigTXOPProtectionFullSupport =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003732 pe_session->beaconParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003733 fLsigTXOPProtectionFullSupport = true;
3734 pBeaconParams->paramChangeBitmap |=
3735 PARAM_LSIG_TXOP_FULL_SUPPORT_CHANGED;
3736 } else if (!enable
3737 && (true ==
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003738 pe_session->beaconParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003739 fLsigTXOPProtectionFullSupport)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303740 pe_debug("===> Protection from LsigTxop Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003741 pBeaconParams->fLsigTXOPProtectionFullSupport =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003742 pe_session->beaconParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003743 fLsigTXOPProtectionFullSupport = false;
3744 pBeaconParams->paramChangeBitmap |=
3745 PARAM_LSIG_TXOP_FULL_SUPPORT_CHANGED;
3746 }
3747 } else {
3748 if ((enable)
3749 && (false ==
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003750 pe_session->beaconParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003751 fLsigTXOPProtectionFullSupport)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303752 pe_debug(" => Protection from LsigTxop Enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003753 pBeaconParams->fLsigTXOPProtectionFullSupport =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003754 pe_session->beaconParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003755 fLsigTXOPProtectionFullSupport = true;
3756 pBeaconParams->paramChangeBitmap |=
3757 PARAM_LSIG_TXOP_FULL_SUPPORT_CHANGED;
3758 } else if (!enable
3759 && (true ==
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003760 pe_session->beaconParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003761 fLsigTXOPProtectionFullSupport)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303762 pe_debug("===> Protection from LsigTxop Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003763 pBeaconParams->fLsigTXOPProtectionFullSupport =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003764 pe_session->beaconParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003765 fLsigTXOPProtectionFullSupport = false;
3766 pBeaconParams->paramChangeBitmap |=
3767 PARAM_LSIG_TXOP_FULL_SUPPORT_CHANGED;
3768 }
3769 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003770 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003771}
3772
3773/* FIXME_PROTECTION : need to check for no APSD whenever we want to enable this protection. */
3774/* This check will be done at the caller. */
3775/** -------------------------------------------------------------
3776 \fn lim_enable_ht_rifs_protection
3777 \brief based on cofig enables\disables Rifs protection.
3778 \param uint8_t enable : 1=> enable protection, 0=> disable protection.
3779 \param uint8_t overlap: 1=> called from overlap context, 0 => called from assoc context.
3780 \param tpUpdateBeaconParams pBeaconParams
3781 \return None
3782 -------------------------------------------------------------*/
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003783QDF_STATUS
Jeff Johnsond01da6b2018-12-02 12:10:22 -08003784lim_enable_ht_rifs_protection(struct mac_context *mac, uint8_t enable,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003785 uint8_t overlap, tpUpdateBeaconParams pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003786 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003787{
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003788 if (!pe_session->htCapability)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003789 return QDF_STATUS_SUCCESS; /* this protection is only for HT stations. */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003790
3791 /* overlapping protection configuration check. */
3792 if (overlap) {
3793 } else {
3794 /* normal protection config check */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003795 if (LIM_IS_AP_ROLE(pe_session) &&
3796 !pe_session->cfgProtection.rifs) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003797 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303798 pe_debug("protection from Rifs is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003799 return QDF_STATUS_SUCCESS;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003800 } else if (!LIM_IS_AP_ROLE(pe_session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003801 /* normal protection config check */
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003802 if (!mac->lim.cfgProtection.rifs) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003803 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303804 pe_debug("protection from Rifs is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003805 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003806 }
3807 }
3808 }
3809
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003810 if (LIM_IS_AP_ROLE(pe_session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003811 /* Disabling the RIFS Protection means Enable the RIFS mode of operation in the BSS */
3812 if ((!enable)
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003813 && (false == pe_session->beaconParams.fRIFSMode)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303814 pe_debug(" => Rifs protection Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003815 pBeaconParams->fRIFSMode =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003816 pe_session->beaconParams.fRIFSMode = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003817 pBeaconParams->paramChangeBitmap |=
3818 PARAM_RIFS_MODE_CHANGED;
3819 }
3820 /* Enabling the RIFS Protection means Disable the RIFS mode of operation in the BSS */
3821 else if (enable
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003822 && (true == pe_session->beaconParams.fRIFSMode)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303823 pe_debug("===> Rifs Protection Enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003824 pBeaconParams->fRIFSMode =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003825 pe_session->beaconParams.fRIFSMode = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003826 pBeaconParams->paramChangeBitmap |=
3827 PARAM_RIFS_MODE_CHANGED;
3828 }
3829 } else {
3830 /* Disabling the RIFS Protection means Enable the RIFS mode of operation in the BSS */
3831 if ((!enable)
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003832 && (false == pe_session->beaconParams.fRIFSMode)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303833 pe_debug(" => Rifs protection Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003834 pBeaconParams->fRIFSMode =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003835 pe_session->beaconParams.fRIFSMode = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003836 pBeaconParams->paramChangeBitmap |=
3837 PARAM_RIFS_MODE_CHANGED;
3838 }
3839 /* Enabling the RIFS Protection means Disable the RIFS mode of operation in the BSS */
3840 else if (enable
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003841 && (true == pe_session->beaconParams.fRIFSMode)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303842 pe_debug("===> Rifs Protection Enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003843 pBeaconParams->fRIFSMode =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003844 pe_session->beaconParams.fRIFSMode = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003845 pBeaconParams->paramChangeBitmap |=
3846 PARAM_RIFS_MODE_CHANGED;
3847 }
3848 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003849 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003850}
3851
3852/* --------------------------------------------------------------------- */
3853/**
3854 * lim_enable_short_preamble
3855 *
3856 * FUNCTION:
3857 * Enable/Disable short preamble
3858 *
3859 * LOGIC:
3860 *
3861 * ASSUMPTIONS:
3862 *
3863 * NOTE:
3864 *
3865 * @param enable Flag to enable/disable short preamble
3866 * @return None
3867 */
3868
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003869QDF_STATUS
Jeff Johnsond01da6b2018-12-02 12:10:22 -08003870lim_enable_short_preamble(struct mac_context *mac, uint8_t enable,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003871 tpUpdateBeaconParams pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003872 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003873{
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003874 if (!mac->mlme_cfg->ht_caps.short_preamble)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003875 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003876
gaurank kathpaliae5a17e42018-09-10 10:05:25 +05303877 /* 11G short preamble switching is disabled. */
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003878 if (!mac->mlme_cfg->feature_flags.enable_short_preamble_11g)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003879 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003880
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003881 if (LIM_IS_AP_ROLE(pe_session)) {
3882 if (enable && (pe_session->beaconParams.fShortPreamble == 0)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303883 pe_debug("===> Short Preamble Enabled");
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003884 pe_session->beaconParams.fShortPreamble = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003885 pBeaconParams->fShortPreamble =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003886 (uint8_t) pe_session->beaconParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003887 fShortPreamble;
3888 pBeaconParams->paramChangeBitmap |=
3889 PARAM_SHORT_PREAMBLE_CHANGED;
3890 } else if (!enable
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003891 && (pe_session->beaconParams.fShortPreamble ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003892 1)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303893 pe_debug("===> Short Preamble Disabled");
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003894 pe_session->beaconParams.fShortPreamble = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003895 pBeaconParams->fShortPreamble =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003896 (uint8_t) pe_session->beaconParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003897 fShortPreamble;
3898 pBeaconParams->paramChangeBitmap |=
3899 PARAM_SHORT_PREAMBLE_CHANGED;
3900 }
3901 }
3902
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003903 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003904}
3905
3906/**
3907 * lim_tx_complete
3908 *
3909 * Function:
3910 * This is LIM's very own "TX MGMT frame complete" completion routine.
3911 *
3912 * Logic:
3913 * LIM wants to send a MGMT frame (broadcast or unicast)
3914 * LIM allocates memory using cds_packet_alloc( ..., **pData, **pPacket )
3915 * LIM transmits the MGMT frame using the API:
3916 * wma_tx_frame( ... pPacket, ..., (void *) lim_tx_complete, pData )
3917 * HDD, via wma_tx_frame/DXE, "transfers" the packet over to BMU
3918 * HDD, if it determines that a TX completion routine (in this case
3919 * lim_tx_complete) has been provided, will invoke this callback
3920 * LIM will try to free the TX MGMT packet that was earlier allocated, in order
3921 * to send this MGMT frame, using the PAL API cds_packet_free( ... pData, pPacket )
3922 *
3923 * Assumptions:
3924 * Presently, this is ONLY being used for MGMT frames/packets
3925 * TODO:
3926 * Would it do good for LIM to have some sort of "signature" validation to
3927 * ensure that the pData argument passed in was a buffer that was actually
3928 * allocated by LIM and/or is not corrupted?
3929 *
3930 * Note: FIXME and TODO
3931 * Looks like cds_packet_free() is interested in pPacket. But, when this completion
3932 * routine is called, only pData is made available to LIM!!
3933 *
3934 * @param void A pointer to pData. Shouldn't it be pPacket?!
3935 *
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303936 * @return QDF_STATUS_SUCCESS - in case of success
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003937 */
Jeff Johnson8390fe22018-06-09 21:59:32 -07003938QDF_STATUS lim_tx_complete(void *context, qdf_nbuf_t buf, bool free)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003939{
3940 if (free)
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303941 cds_packet_free((void *)buf);
3942
3943 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003944}
3945
3946/**
3947 * \brief This function updates lim global structure, if CB parameters in the BSS
3948 * have changed, and sends an indication to HAL also with the
3949 * updated HT Parameters.
3950 * This function does not detect the change in the primary channel, that is done as part
3951 * of channel Swtich IE processing.
3952 * If STA is configured with '20Mhz only' mode, then this function does not do anything
3953 * This function changes the CB mode, only if the self capability is set to '20 as well as 40Mhz'
3954 *
3955 *
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003956 * \param mac Pointer to global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003957 *
3958 * \param pRcvdHTInfo Pointer to HT Info IE obtained from a Beacon or
3959 * Probe Response
3960 *
3961 * \param bssIdx BSS Index of the Bss to which Station is associated.
3962 *
3963 *
3964 */
3965
Jeff Johnsond01da6b2018-12-02 12:10:22 -08003966void lim_update_sta_run_time_ht_switch_chnl_params(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003967 tDot11fIEHTInfo *pHTInfo,
3968 uint8_t bssIdx,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003969 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003970{
3971 uint8_t center_freq = 0;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08003972 enum phy_ch_width ch_width = CH_WIDTH_20MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003973
3974 /* If self capability is set to '20Mhz only', then do not change the CB mode. */
3975 if (!lim_get_ht_capability
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003976 (mac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, pe_session))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003977 return;
3978
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003979 if (WLAN_REG_IS_24GHZ_CH(pe_session->currentOperChannel) &&
3980 pe_session->force_24ghz_in_ht20) {
Abhishek Singhb59f8d42017-07-31 14:42:47 +05303981 pe_debug("force_24ghz_in_ht20 is set and channel is 2.4 Ghz");
3982 return;
3983 }
3984
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003985 if (pe_session->ftPEContext.ftPreAuthSession) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303986 pe_err("FT PREAUTH channel change is in progress");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003987 return;
3988 }
3989
Kiran Kumar Lokerea3e5e0b2015-11-03 14:17:26 -08003990 /*
3991 * Do not try to switch channel if RoC is in progress. RoC code path
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003992 * uses mac->lim.gpLimRemainOnChanReq to notify the upper layers that
Kiran Kumar Lokerea3e5e0b2015-11-03 14:17:26 -08003993 * the device has started listening on the channel requested as part of
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003994 * RoC, if we set mac->lim.gpLimRemainOnChanReq to NULL as we do below
Kiran Kumar Lokerea3e5e0b2015-11-03 14:17:26 -08003995 * then the upper layers will think that the channel change is not
3996 * successful and the RoC from the upper layer perspective will never
3997 * end...
3998 */
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003999 if (mac->lim.gpLimRemainOnChanReq) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304000 pe_debug("RoC is in progress");
Kiran Kumar Lokerea3e5e0b2015-11-03 14:17:26 -08004001 return;
4002 }
4003
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004004 if (pe_session->ch_switch_in_progress == true) {
Kiran Kumar Lokeref9dc7912017-06-28 18:10:58 -07004005 pe_debug("ch switch is in progress, ignore HT IE BW update");
4006 return;
4007 }
4008
Abhishek Singh7889a7e2017-06-23 14:58:02 +05304009 if (!pHTInfo->primaryChannel) {
4010 pe_debug("Ignore as primary channel is 0 in HT info");
4011 return;
4012 }
4013
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004014 if (pe_session->htSecondaryChannelOffset !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004015 (uint8_t) pHTInfo->secondaryChannelOffset
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004016 || pe_session->htRecommendedTxWidthSet !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004017 (uint8_t) pHTInfo->recommendedTxWidthSet) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004018 pe_session->htSecondaryChannelOffset =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004019 (ePhyChanBondState) pHTInfo->secondaryChannelOffset;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004020 pe_session->htRecommendedTxWidthSet =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004021 (uint8_t) pHTInfo->recommendedTxWidthSet;
4022 if (eHT_CHANNEL_WIDTH_40MHZ ==
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004023 pe_session->htRecommendedTxWidthSet) {
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08004024 ch_width = CH_WIDTH_40MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004025 if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
4026 pHTInfo->secondaryChannelOffset)
4027 center_freq = pHTInfo->primaryChannel + 2;
4028 else if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY ==
4029 pHTInfo->secondaryChannelOffset)
4030 center_freq = pHTInfo->primaryChannel - 2;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08004031 else
4032 ch_width = CH_WIDTH_20MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004033 }
4034
4035 /* notify HAL */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304036 pe_debug("Channel Information in HT IE change"
4037 "d; sending notification to HAL.");
4038 pe_debug("Primary Channel: %d Secondary Chan"
4039 "nel Offset: %d Channel Width: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004040 pHTInfo->primaryChannel, center_freq,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004041 pe_session->htRecommendedTxWidthSet);
4042 pe_session->channelChangeReasonCode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004043 LIM_SWITCH_CHANNEL_OPERATION;
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004044 mac->lim.gpchangeChannelCallback = NULL;
4045 mac->lim.gpchangeChannelData = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004046
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004047 lim_send_switch_chnl_params(mac, (uint8_t) pHTInfo->primaryChannel,
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08004048 center_freq, 0, ch_width,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004049 pe_session->maxTxPower,
4050 pe_session->peSessionId,
Arif Hussain671a1902017-03-17 09:08:32 -07004051 true, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004052
4053 /* In case of IBSS, if STA should update HT Info IE in its beacons. */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004054 if (LIM_IS_IBSS_ROLE(pe_session)) {
4055 sch_set_fixed_beacon_fields(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004056 }
4057
4058 }
4059} /* End limUpdateStaRunTimeHTParams. */
4060
4061/**
4062 * \brief This function updates the lim global structure, if any of the
4063 * HT Capabilities have changed.
4064 *
4065 *
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004066 * \param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004067 *
4068 * \param pHTCapability Pointer to HT Capability Information Element
4069 * obtained from a Beacon or Probe Response
4070 *
4071 *
4072 *
4073 */
4074
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004075void lim_update_sta_run_time_ht_capability(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004076 tDot11fIEHTCaps *pHTCaps)
4077{
4078
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004079 if (mac->lim.gHTLsigTXOPProtection !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004080 (uint8_t) pHTCaps->lsigTXOPProtection) {
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004081 mac->lim.gHTLsigTXOPProtection =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004082 (uint8_t) pHTCaps->lsigTXOPProtection;
4083 /* Send change notification to HAL */
4084 }
4085
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004086 if (mac->lim.gHTAMpduDensity != (uint8_t) pHTCaps->mpduDensity) {
4087 mac->lim.gHTAMpduDensity = (uint8_t) pHTCaps->mpduDensity;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004088 /* Send change notification to HAL */
4089 }
4090
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004091 if (mac->lim.gHTMaxRxAMpduFactor !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004092 (uint8_t) pHTCaps->maxRxAMPDUFactor) {
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004093 mac->lim.gHTMaxRxAMpduFactor =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004094 (uint8_t) pHTCaps->maxRxAMPDUFactor;
4095 /* Send change notification to HAL */
4096 }
4097
4098} /* End lim_update_sta_run_time_ht_capability. */
4099
4100/**
4101 * \brief This function updates lim global structure, if any of the HT
4102 * Info Parameters have changed.
4103 *
4104 *
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004105 * \param mac Pointer to the global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004106 *
4107 * \param pHTInfo Pointer to the HT Info IE obtained from a Beacon or
4108 * Probe Response
4109 *
4110 *
4111 */
4112
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004113void lim_update_sta_run_time_ht_info(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004114 tDot11fIEHTInfo *pHTInfo,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004115 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004116{
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004117 if (pe_session->htRecommendedTxWidthSet !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004118 (uint8_t) pHTInfo->recommendedTxWidthSet) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004119 pe_session->htRecommendedTxWidthSet =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004120 (uint8_t) pHTInfo->recommendedTxWidthSet;
4121 /* Send change notification to HAL */
4122 }
4123
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004124 if (pe_session->beaconParams.fRIFSMode !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004125 (uint8_t) pHTInfo->rifsMode) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004126 pe_session->beaconParams.fRIFSMode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004127 (uint8_t) pHTInfo->rifsMode;
4128 /* Send change notification to HAL */
4129 }
4130
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004131 if (mac->lim.gHTServiceIntervalGranularity !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004132 (uint8_t) pHTInfo->serviceIntervalGranularity) {
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004133 mac->lim.gHTServiceIntervalGranularity =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004134 (uint8_t) pHTInfo->serviceIntervalGranularity;
4135 /* Send change notification to HAL */
4136 }
4137
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004138 if (mac->lim.gHTOperMode != (tSirMacHTOperatingMode) pHTInfo->opMode) {
4139 mac->lim.gHTOperMode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004140 (tSirMacHTOperatingMode) pHTInfo->opMode;
4141 /* Send change notification to HAL */
4142 }
4143
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004144 if (pe_session->beaconParams.llnNonGFCoexist !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004145 pHTInfo->nonGFDevicesPresent) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004146 pe_session->beaconParams.llnNonGFCoexist =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004147 (uint8_t) pHTInfo->nonGFDevicesPresent;
4148 }
4149
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004150 if (mac->lim.gHTSTBCBasicMCS != (uint8_t) pHTInfo->basicSTBCMCS) {
4151 mac->lim.gHTSTBCBasicMCS = (uint8_t) pHTInfo->basicSTBCMCS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004152 /* Send change notification to HAL */
4153 }
4154
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004155 if (mac->lim.gHTDualCTSProtection !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004156 (uint8_t) pHTInfo->dualCTSProtection) {
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004157 mac->lim.gHTDualCTSProtection =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004158 (uint8_t) pHTInfo->dualCTSProtection;
4159 /* Send change notification to HAL */
4160 }
4161
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004162 if (mac->lim.gHTSecondaryBeacon != (uint8_t) pHTInfo->secondaryBeacon) {
4163 mac->lim.gHTSecondaryBeacon =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004164 (uint8_t) pHTInfo->secondaryBeacon;
4165 /* Send change notification to HAL */
4166 }
4167
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004168 if (pe_session->beaconParams.fLsigTXOPProtectionFullSupport !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004169 (uint8_t) pHTInfo->lsigTXOPProtectionFullSupport) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004170 pe_session->beaconParams.fLsigTXOPProtectionFullSupport =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004171 (uint8_t) pHTInfo->lsigTXOPProtectionFullSupport;
4172 /* Send change notification to HAL */
4173 }
4174
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004175 if (mac->lim.gHTPCOActive != (uint8_t) pHTInfo->pcoActive) {
4176 mac->lim.gHTPCOActive = (uint8_t) pHTInfo->pcoActive;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004177 /* Send change notification to HAL */
4178 }
4179
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004180 if (mac->lim.gHTPCOPhase != (uint8_t) pHTInfo->pcoPhase) {
4181 mac->lim.gHTPCOPhase = (uint8_t) pHTInfo->pcoPhase;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004182 /* Send change notification to HAL */
4183 }
4184
4185} /* End lim_update_sta_run_time_ht_info. */
4186
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004187/**
4188 * lim_validate_delts_req() - This function validates DelTs req
4189 * @mac_ctx: pointer to Global Mac structure
4190 * @delts_req: pointer to delete traffic stream structure
4191 * @peer_mac_addr: variable for peer mac address
4192 *
4193 * Function validates DelTs req originated by SME or by HAL and also
4194 * sends halMsg_DelTs to HAL
4195 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004196 * Return: QDF_STATUS_SUCCESS - Success, QDF_STATUS_E_FAILURE - Failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004197 */
4198
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004199QDF_STATUS
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004200lim_validate_delts_req(struct mac_context *mac_ctx, tpSirDeltsReq delts_req,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08004201 tSirMacAddr peer_mac_addr, struct pe_session *psession_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004202{
4203 tpDphHashNode sta;
4204 uint8_t ts_status;
4205 tSirMacTSInfo *tsinfo;
4206 uint32_t i;
4207 uint8_t tspec_idx;
4208
4209 /*
4210 * if sta
4211 * - verify assoc state
4212 * - del tspec locally
4213 * if ap
4214 * - verify sta is in assoc state
4215 * - del sta tspec locally
4216 */
4217 if (delts_req == NULL) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304218 pe_err("Delete TS request pointer is NULL");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004219 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004220 }
4221
Rajeev Kumar0ac9f2a2016-04-15 15:54:18 -07004222 if (LIM_IS_STA_ROLE(psession_entry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004223 uint32_t val;
4224
4225 /* station always talks to the AP */
4226 sta = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
4227 &psession_entry->dph.dphHashTable);
4228
4229 val = sizeof(tSirMacAddr);
4230 sir_copy_mac_addr(peer_mac_addr, psession_entry->bssId);
4231
4232 } else {
4233 uint16_t associd;
4234 uint8_t *macaddr = (uint8_t *) peer_mac_addr;
4235
4236 associd = delts_req->aid;
4237 if (associd != 0)
4238 sta = dph_get_hash_entry(mac_ctx, associd,
4239 &psession_entry->dph.dphHashTable);
4240 else
4241 sta = dph_lookup_hash_entry(mac_ctx,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08004242 delts_req->macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004243 &associd,
4244 &psession_entry->dph.
4245 dphHashTable);
4246
4247 if (sta != NULL)
4248 /* TBD: check sta assoc state as well */
4249 for (i = 0; i < sizeof(tSirMacAddr); i++)
4250 macaddr[i] = sta->staAddr[i];
4251 }
4252
4253 if (sta == NULL) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304254 pe_err("Cannot find station context for delts req");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004255 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004256 }
4257
4258 if ((!sta->valid) ||
4259 (sta->mlmStaContext.mlmState !=
4260 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304261 pe_err("Invalid Sta (or state) for DelTsReq");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004262 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004263 }
4264
4265 delts_req->req.wsmTspecPresent = 0;
4266 delts_req->req.wmeTspecPresent = 0;
4267 delts_req->req.lleTspecPresent = 0;
4268
4269 if ((sta->wsmEnabled) &&
4270 (delts_req->req.tspec.tsinfo.traffic.accessPolicy !=
4271 SIR_MAC_ACCESSPOLICY_EDCA))
4272 delts_req->req.wsmTspecPresent = 1;
4273 else if (sta->wmeEnabled)
4274 delts_req->req.wmeTspecPresent = 1;
4275 else if (sta->lleEnabled)
4276 delts_req->req.lleTspecPresent = 1;
4277 else {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304278 pe_warn("DELTS_REQ ignore - qos is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004279 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004280 }
4281
4282 tsinfo = delts_req->req.wmeTspecPresent ? &delts_req->req.tspec.tsinfo
4283 : &delts_req->req.tsinfo;
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304284 pe_debug("received DELTS_REQ message wmeTspecPresent: %d lleTspecPresent: %d wsmTspecPresent: %d tsid: %d up: %d direction: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004285 delts_req->req.wmeTspecPresent,
4286 delts_req->req.lleTspecPresent,
4287 delts_req->req.wsmTspecPresent, tsinfo->traffic.tsid,
4288 tsinfo->traffic.userPrio, tsinfo->traffic.direction);
4289
4290 /* if no Access Control, ignore the request */
4291 if (lim_admit_control_delete_ts(mac_ctx, sta->assocId, tsinfo,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004292 &ts_status, &tspec_idx) != QDF_STATUS_SUCCESS) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304293 pe_err("DELTS request for sta assocId: %d tsid: %d up: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004294 sta->assocId, tsinfo->traffic.tsid,
4295 tsinfo->traffic.userPrio);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004296 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004297 } else if ((tsinfo->traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA)
4298 || (tsinfo->traffic.accessPolicy ==
4299 SIR_MAC_ACCESSPOLICY_BOTH)) {
4300 /* edca only now. */
4301 } else if (tsinfo->traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_EDCA) {
4302 /* send message to HAL to delete TS */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004303 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004304 lim_send_hal_msg_del_ts(mac_ctx, sta->staIndex,
4305 tspec_idx, delts_req->req,
4306 psession_entry->peSessionId,
4307 psession_entry->bssId)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304308 pe_warn("DelTs with UP: %d failed in lim_send_hal_msg_del_ts - ignoring request",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004309 tsinfo->traffic.userPrio);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004310 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004311 }
4312 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004313 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004314}
4315
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004316/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004317 * @function : lim_post_sm_state_update()
4318 *
4319 * @brief : This function Updates the HAL and Softmac about the change in the STA's SMPS state.
4320 *
4321 * LOGIC:
4322 *
4323 * ASSUMPTIONS:
4324 * NA
4325 *
4326 * NOTE:
4327 * NA
4328 *
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004329 * @param mac - Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004330 * @param limMsg - Lim Message structure object with the MimoPSparam in body
4331 * @return None
4332 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004333QDF_STATUS
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004334lim_post_sm_state_update(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004335 uint16_t staIdx, tSirMacHTMIMOPowerSaveState state,
4336 uint8_t *pPeerStaMac, uint8_t sessionId)
4337{
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004338 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004339 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004340 tpSetMIMOPS pMIMO_PSParams;
4341
4342 msgQ.reserved = 0;
4343 msgQ.type = WMA_SET_MIMOPS_REQ;
4344
4345 /* Allocate for WMA_SET_MIMOPS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304346 pMIMO_PSParams = qdf_mem_malloc(sizeof(tSetMIMOPS));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004347 if (!pMIMO_PSParams)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004348 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004349
4350 pMIMO_PSParams->htMIMOPSState = state;
4351 pMIMO_PSParams->staIdx = staIdx;
4352 pMIMO_PSParams->fsendRsp = true;
4353 pMIMO_PSParams->sessionId = sessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304354 qdf_mem_copy(pMIMO_PSParams->peerMac, pPeerStaMac, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004355
4356 msgQ.bodyptr = pMIMO_PSParams;
4357 msgQ.bodyval = 0;
4358
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304359 pe_debug("Sending WMA_SET_MIMOPS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004360
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004361 MTRACE(mac_trace_msg_tx(mac, NO_SESSION, msgQ.type));
4362 retCode = wma_post_ctrl_msg(mac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004363 if (QDF_STATUS_SUCCESS != retCode) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304364 pe_err("Posting WMA_SET_MIMOPS_REQ to HAL failed! Reason: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004365 retCode);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304366 qdf_mem_free(pMIMO_PSParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004367 return retCode;
4368 }
4369
4370 return retCode;
4371}
4372
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004373void lim_pkt_free(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004374 eFrameType frmType, uint8_t *pRxPacketInfo, void *pBody)
4375{
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004376 (void)mac;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004377 (void)frmType;
4378 (void)pRxPacketInfo;
4379 (void)pBody;
4380}
4381
4382/**
4383 * lim_get_b_dfrom_rx_packet()
4384 *
4385 ***FUNCTION:
4386 * This function is called to get pointer to Polaris
4387 * Buffer Descriptor containing MAC header & other control
4388 * info from the body of the message posted to LIM.
4389 *
4390 ***LOGIC:
4391 * NA
4392 *
4393 ***ASSUMPTIONS:
4394 * NA
4395 *
4396 ***NOTE:
4397 * NA
4398 *
4399 * @param body - Received message body
4400 * @param pRxPacketInfo - Pointer to received BD
4401 * @return None
4402 */
4403
4404void
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004405lim_get_b_dfrom_rx_packet(struct mac_context *mac, void *body, uint32_t **pRxPacketInfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004406{
4407 *pRxPacketInfo = (uint32_t *) body;
4408} /*** end lim_get_b_dfrom_rx_packet() ***/
4409
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004410void lim_add_channel_status_info(struct mac_context *p_mac,
gaoleze5108942017-03-31 16:56:42 +08004411 struct lim_channel_status *channel_stat,
4412 uint8_t channel_id)
4413{
4414 uint8_t i;
4415 bool found = false;
4416 struct lim_scan_channel_status *channel_info =
4417 &p_mac->lim.scan_channel_status;
4418 struct lim_channel_status *channel_status_list =
4419 channel_info->channel_status_list;
4420 uint8_t total_channel = channel_info->total_channel;
4421
4422 if (!p_mac->sap.acs_with_more_param)
4423 return;
4424
4425 for (i = 0; i < total_channel; i++) {
4426 if (channel_status_list[i].channel_id == channel_id) {
4427 if (channel_stat->cmd_flags ==
4428 WMI_CHAN_InFO_END_RESP &&
4429 channel_status_list[i].cmd_flags ==
4430 WMI_CHAN_InFO_START_RESP) {
4431 /* adjust to delta value for counts */
4432 channel_stat->rx_clear_count -=
4433 channel_status_list[i].rx_clear_count;
4434 channel_stat->cycle_count -=
4435 channel_status_list[i].cycle_count;
4436 channel_stat->rx_frame_count -=
4437 channel_status_list[i].rx_frame_count;
4438 channel_stat->tx_frame_count -=
4439 channel_status_list[i].tx_frame_count;
4440 channel_stat->bss_rx_cycle_count -=
4441 channel_status_list[i].bss_rx_cycle_count;
4442 }
4443 qdf_mem_copy(&channel_status_list[i], channel_stat,
4444 sizeof(*channel_status_list));
4445 found = true;
4446 break;
4447 }
4448 }
4449
4450 if (!found) {
4451 if (total_channel < SIR_MAX_SUPPORTED_CHANNEL_LIST) {
4452 qdf_mem_copy(&channel_status_list[total_channel++],
4453 channel_stat,
4454 sizeof(*channel_status_list));
4455 channel_info->total_channel = total_channel;
4456 } else {
4457 pe_warn("Chan cnt exceed, channel_id=%d", channel_id);
4458 }
4459 }
4460
4461 return;
4462}
4463
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004464/**
4465 * @function : lim_is_channel_valid_for_channel_switch()
4466 *
4467 * @brief : This function checks if the channel to which AP
4468 * is expecting us to switch, is a valid channel for us.
4469 * LOGIC:
4470 *
4471 * ASSUMPTIONS:
4472 * NA
4473 *
4474 * NOTE:
4475 * NA
4476 *
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004477 * @param mac - Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004478 * @param channel - New channel to which we are expected to move
4479 * @return None
4480 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004481bool lim_is_channel_valid_for_channel_switch(struct mac_context *mac, uint8_t channel)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004482{
4483 uint8_t index;
4484 uint32_t validChannelListLen = WNI_CFG_VALID_CHANNEL_LIST_LEN;
4485 tSirMacChanNum validChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN];
Bala Venkatesh867d4112018-06-08 12:53:31 +05304486 bool ok = false;
Ajit Pal Singh7ae88fb2017-09-06 16:14:35 +05304487
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004488 if (policy_mgr_is_chan_ok_for_dnbs(mac->psoc, channel, &ok)) {
Ajit Pal Singh7ae88fb2017-09-06 16:14:35 +05304489 pe_err("policy_mgr_is_chan_ok_for_dnbs() returned error");
4490 return false;
4491 }
4492
4493 if (!ok) {
4494 pe_debug("channel not ok for DNBS");
4495 return false;
4496 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004497
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004498 if (wlan_cfg_get_str(mac, WNI_CFG_VALID_CHANNEL_LIST,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004499 (uint8_t *) validChannelList,
4500 (uint32_t *) &validChannelListLen) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004501 QDF_STATUS_SUCCESS) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304502 pe_err("could not retrieve valid channel list");
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07004503 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004504 }
4505
4506 for (index = 0; index < validChannelListLen; index++) {
Bala Venkatesh867d4112018-06-08 12:53:31 +05304507 if (validChannelList[index] != channel)
4508 continue;
4509
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004510 ok = policy_mgr_is_valid_for_channel_switch(mac->psoc,
Bala Venkatesh867d4112018-06-08 12:53:31 +05304511 channel);
4512 return ok;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004513 }
4514
4515 /* channel does not belong to list of valid channels */
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07004516 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004517}
4518
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004519/**
4520 * @function : lim_restore_pre_channel_switch_state()
4521 *
4522 * @brief : This API is called by the user to undo any
4523 * specific changes done on the device during
4524 * channel switch.
4525 * LOGIC:
4526 *
4527 * ASSUMPTIONS:
4528 * NA
4529 *
4530 * NOTE:
4531 * NA
4532 *
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004533 * @param mac - Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004534 * @return None
4535 */
4536
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004537QDF_STATUS
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004538lim_restore_pre_channel_switch_state(struct mac_context *mac, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004539{
4540
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004541 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004542
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004543 if (!LIM_IS_STA_ROLE(pe_session))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004544 return retCode;
4545
4546 /* Channel switch should be ready for the next time */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004547 pe_session->gLimSpecMgmt.dot11hChanSwState = eLIM_11H_CHANSW_INIT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004548
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004549 return retCode;
4550}
4551
4552/**
4553 * @function: lim_prepare_for11h_channel_switch()
4554 *
4555 * @brief : This API is called by the user to prepare for
4556 * 11h channel switch. As of now, the API does
4557 * very minimal work. User can add more into the
4558 * same API if needed.
4559 * LOGIC:
4560 *
4561 * ASSUMPTIONS:
4562 * NA
4563 *
4564 * NOTE:
4565 * NA
4566 *
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004567 * @param mac - Pointer to Global MAC structure
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004568 * @param pe_session
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004569 * @return None
4570 */
4571void
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004572lim_prepare_for11h_channel_switch(struct mac_context *mac, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004573{
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004574 if (!LIM_IS_STA_ROLE(pe_session))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004575 return;
4576
4577 /* Flag to indicate 11h channel switch in progress */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004578 pe_session->gLimSpecMgmt.dot11hChanSwState = eLIM_11H_CHANSW_RUNNING;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004579
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004580 if (mac->lim.gLimSmeState == eLIM_SME_LINK_EST_WT_SCAN_STATE ||
4581 mac->lim.gLimSmeState == eLIM_SME_CHANNEL_SCAN_STATE) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304582 pe_debug("Posting finish scan as we are in scan state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004583 /* Stop ongoing scanning if any */
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004584 if (GET_LIM_PROCESS_DEFD_MESGS(mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004585 /* Set the resume channel to Any valid channel (invalid). */
4586 /* This will instruct HAL to set it to any previous valid channel. */
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004587 pe_set_resume_channel(mac, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004588 } else {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004589 lim_restore_pre_channel_switch_state(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004590 }
4591 return;
4592 } else {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304593 pe_debug("Not in scan state, start channel switch timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004594 /** We are safe to switch channel at this point */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004595 lim_stop_tx_and_switch_channel(mac, pe_session->peSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004596 }
4597}
4598
4599/**----------------------------------------------------
4600 \fn lim_get_nw_type
4601
4602 \brief Get type of the network from data packet or beacon
Jeff Johnson982fe962018-11-28 17:07:01 -08004603 \param mac
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004604 \param channelNum - Channel number
4605 \param type - Type of packet.
4606 \param pBeacon - Pointer to beacon or probe response
4607
4608 \return Network type a/b/g.
4609 -----------------------------------------------------*/
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004610tSirNwType lim_get_nw_type(struct mac_context *mac, uint8_t channelNum, uint32_t type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004611 tpSchBeaconStruct pBeacon)
4612{
4613 tSirNwType nwType = eSIR_11B_NW_TYPE;
4614
4615 if (type == SIR_MAC_DATA_FRAME) {
4616 if ((channelNum > 0) && (channelNum < 15)) {
4617 nwType = eSIR_11G_NW_TYPE;
4618 } else {
4619 nwType = eSIR_11A_NW_TYPE;
4620 }
4621 } else {
4622 if ((channelNum > 0) && (channelNum < 15)) {
4623 int i;
4624 /* 11b or 11g packet */
4625 /* 11g iff extended Rate IE is present or */
4626 /* if there is an A rate in suppRate IE */
4627 for (i = 0; i < pBeacon->supportedRates.numRates; i++) {
4628 if (sirIsArate
4629 (pBeacon->supportedRates.rate[i] & 0x7f)) {
4630 nwType = eSIR_11G_NW_TYPE;
4631 break;
4632 }
4633 }
4634 if (pBeacon->extendedRatesPresent) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004635 nwType = eSIR_11G_NW_TYPE;
yeshwanth sriram guntuka47f26e62017-03-07 12:43:02 +05304636 } else if (pBeacon->HTInfo.present ||
4637 IS_BSS_VHT_CAPABLE(pBeacon->VHTCaps)) {
4638 nwType = eSIR_11G_NW_TYPE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004639 }
4640 } else {
4641 /* 11a packet */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004642 nwType = eSIR_11A_NW_TYPE;
4643 }
4644 }
4645 return nwType;
4646}
4647
4648/**---------------------------------------------------------
4649 \fn lim_get_channel_from_beacon
4650 \brief To extract channel number from beacon
4651
Jeff Johnson982fe962018-11-28 17:07:01 -08004652 \param mac
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004653 \param pBeacon - Pointer to beacon or probe rsp
4654 \return channel number
4655 -----------------------------------------------------------*/
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004656uint8_t lim_get_channel_from_beacon(struct mac_context *mac, tpSchBeaconStruct pBeacon)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004657{
4658 uint8_t channelNum = 0;
4659
4660 if (pBeacon->dsParamsPresent)
4661 channelNum = pBeacon->channelNumber;
4662 else if (pBeacon->HTInfo.present)
4663 channelNum = pBeacon->HTInfo.primaryChannel;
4664 else
4665 channelNum = pBeacon->channelNumber;
4666
4667 return channelNum;
4668}
4669
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004670void lim_set_tspec_uapsd_mask_per_session(struct mac_context *mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004671 struct pe_session *pe_session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004672 tSirMacTSInfo *pTsInfo, uint32_t action)
4673{
4674 uint8_t userPrio = (uint8_t) pTsInfo->traffic.userPrio;
4675 uint16_t direction = pTsInfo->traffic.direction;
4676 uint8_t ac = upToAc(userPrio);
4677
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304678 pe_debug("Set UAPSD mask for AC: %d dir: %d action: %d"
4679 , ac, direction, action);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004680
4681 /* Converting AC to appropriate Uapsd Bit Mask
4682 * AC_BE(0) --> UAPSD_BITOFFSET_ACVO(3)
4683 * AC_BK(1) --> UAPSD_BITOFFSET_ACVO(2)
4684 * AC_VI(2) --> UAPSD_BITOFFSET_ACVO(1)
4685 * AC_VO(3) --> UAPSD_BITOFFSET_ACVO(0)
4686 */
4687 ac = ((~ac) & 0x3);
4688
4689 if (action == CLEAR_UAPSD_MASK) {
4690 if (direction == SIR_MAC_DIRECTION_UPLINK)
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004691 pe_session->gUapsdPerAcTriggerEnableMask &=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004692 ~(1 << ac);
4693 else if (direction == SIR_MAC_DIRECTION_DNLINK)
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004694 pe_session->gUapsdPerAcDeliveryEnableMask &=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004695 ~(1 << ac);
4696 else if (direction == SIR_MAC_DIRECTION_BIDIR) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004697 pe_session->gUapsdPerAcTriggerEnableMask &=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004698 ~(1 << ac);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004699 pe_session->gUapsdPerAcDeliveryEnableMask &=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004700 ~(1 << ac);
4701 }
4702 } else if (action == SET_UAPSD_MASK) {
4703 if (direction == SIR_MAC_DIRECTION_UPLINK)
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004704 pe_session->gUapsdPerAcTriggerEnableMask |=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004705 (1 << ac);
4706 else if (direction == SIR_MAC_DIRECTION_DNLINK)
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004707 pe_session->gUapsdPerAcDeliveryEnableMask |=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004708 (1 << ac);
4709 else if (direction == SIR_MAC_DIRECTION_BIDIR) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004710 pe_session->gUapsdPerAcTriggerEnableMask |=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004711 (1 << ac);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004712 pe_session->gUapsdPerAcDeliveryEnableMask |=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004713 (1 << ac);
4714 }
4715 }
4716
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004717 pe_debug("New pe_session->gUapsdPerAcTriggerEnableMask 0x%x pe_session->gUapsdPerAcDeliveryEnableMask 0x%x",
4718 pe_session->gUapsdPerAcTriggerEnableMask,
4719 pe_session->gUapsdPerAcDeliveryEnableMask);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004720
4721 return;
4722}
4723
4724/**
4725 * lim_handle_heart_beat_timeout_for_session() - Handle heart beat time out
4726 * @mac_ctx: pointer to Global Mac Structure
Jeff Johnsonc8baa902018-11-18 21:59:07 -08004727 * @psession_entry: pointer to struct pe_session *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004728 *
4729 * Function handles heart beat time out for session
4730 *
4731 * Return: none
4732 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004733void lim_handle_heart_beat_timeout_for_session(struct mac_context *mac_ctx,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08004734 struct pe_session *psession_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004735{
4736 if (psession_entry->valid == true) {
4737 if (psession_entry->bssType == eSIR_IBSS_MODE)
4738 lim_ibss_heart_beat_handle(mac_ctx, psession_entry);
4739
4740 if ((psession_entry->bssType == eSIR_INFRASTRUCTURE_MODE) &&
4741 (LIM_IS_STA_ROLE(psession_entry)))
4742 lim_handle_heart_beat_failure(mac_ctx, psession_entry);
4743 }
4744 /*
4745 * In the function lim_handle_heart_beat_failure things can change
4746 * so check for the session entry valid and the other things
4747 * again
4748 */
4749 if ((psession_entry->valid == true) &&
4750 (psession_entry->bssType == eSIR_INFRASTRUCTURE_MODE) &&
4751 (LIM_IS_STA_ROLE(psession_entry)) &&
4752 (psession_entry->LimHBFailureStatus == true)) {
4753 tLimTimers *lim_timer = &mac_ctx->lim.limTimers;
4754 /*
4755 * Activate Probe After HeartBeat Timer incase HB
4756 * Failure detected
4757 */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304758 pe_debug("Sending Probe for Session: %d",
4759 psession_entry->bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004760 lim_deactivate_and_change_timer(mac_ctx,
4761 eLIM_PROBE_AFTER_HB_TIMER);
4762 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TIMER_ACTIVATE, 0,
4763 eLIM_PROBE_AFTER_HB_TIMER));
4764 if (tx_timer_activate(&lim_timer->gLimProbeAfterHBTimer)
4765 != TX_SUCCESS)
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304766 pe_err("Fail to re-activate Probe-after-hb timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004767 }
4768}
4769
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004770uint8_t lim_get_current_operating_channel(struct mac_context *mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004771{
4772 uint8_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004773
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004774 for (i = 0; i < mac->lim.maxBssId; i++) {
4775 if (mac->lim.gpSession[i].valid == true) {
4776 if ((mac->lim.gpSession[i].bssType ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004777 eSIR_INFRASTRUCTURE_MODE)
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004778 && (mac->lim.gpSession[i].limSystemRole ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004779 eLIM_STA_ROLE)) {
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004780 return mac->lim.gpSession[i].
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004781 currentOperChannel;
4782 }
4783 }
4784 }
4785 return 0;
4786}
4787
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07004788/**
4789 * lim_process_add_sta_rsp() - process WDA_ADD_STA_RSP from WMA
4790 * @mac_ctx: Pointer to Global MAC structure
4791 * @msg: msg from WMA
4792 *
4793 * @Return: void
4794 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004795void lim_process_add_sta_rsp(struct mac_context *mac_ctx, struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004796{
Jeff Johnsonc8baa902018-11-18 21:59:07 -08004797 struct pe_session *session;
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07004798 tpAddStaParams add_sta_params;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004799
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07004800 add_sta_params = (tpAddStaParams) msg->bodyptr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004801
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07004802 session = pe_find_session_by_session_id(mac_ctx,
4803 add_sta_params->sessionId);
4804 if (session == NULL) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304805 pe_err("Session Does not exist for given sessionID");
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07004806 qdf_mem_free(add_sta_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004807 return;
4808 }
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07004809 session->csaOffloadEnable = add_sta_params->csaOffloadEnable;
4810 if (LIM_IS_IBSS_ROLE(session))
4811 (void)lim_ibss_add_sta_rsp(mac_ctx, msg->bodyptr, session);
4812 else if (LIM_IS_NDI_ROLE(session))
4813 lim_ndp_add_sta_rsp(mac_ctx, session, msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004814#ifdef FEATURE_WLAN_TDLS
Bala Venkatesh6e3925b2018-07-19 12:31:21 +05304815 else if (add_sta_params->staType == STA_ENTRY_TDLS_PEER)
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07004816 lim_process_tdls_add_sta_rsp(mac_ctx, msg->bodyptr, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004817#endif
4818 else
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07004819 lim_process_mlm_add_sta_rsp(mac_ctx, msg, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004820
4821}
4822
4823/**
4824 * lim_update_beacon() - This function updates beacon
4825 * @mac_ctx: pointer to Global Mac Structure
4826 *
4827 * This Function is invoked to update the beacon
4828 *
4829 * Return: none
4830 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004831void lim_update_beacon(struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004832{
4833 uint8_t i;
4834
4835 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
4836 if (mac_ctx->lim.gpSession[i].valid != true)
4837 continue;
4838 if (((mac_ctx->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE)
4839 || (mac_ctx->lim.gpSession[i].limSystemRole ==
4840 eLIM_STA_IN_IBSS_ROLE))
4841 && (eLIM_SME_NORMAL_STATE ==
4842 mac_ctx->lim.gpSession[i].limSmeState)) {
4843
4844 sch_set_fixed_beacon_fields(mac_ctx,
4845 &mac_ctx->lim.gpSession[i]);
4846
4847 if (false == mac_ctx->sap.SapDfsInfo.
4848 is_dfs_cac_timer_running)
4849 lim_send_beacon_ind(mac_ctx,
Abhishek Singhfc740be2018-10-12 11:34:26 +05304850 &mac_ctx->lim.gpSession[i],
4851 REASON_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004852 }
4853 }
4854}
4855
4856/**
4857 * lim_handle_heart_beat_failure_timeout - handle heart beat failure
4858 * @mac_ctx: pointer to Global Mac Structure
4859 *
4860 * Function handle heart beat failure timeout
4861 *
4862 * Return: none
4863 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004864void lim_handle_heart_beat_failure_timeout(struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004865{
4866 uint8_t i;
Jeff Johnsonc8baa902018-11-18 21:59:07 -08004867 struct pe_session *psession_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004868 /*
4869 * Probe response is not received after HB failure.
4870 * This is handled by LMM sub module.
4871 */
4872 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
4873 if (mac_ctx->lim.gpSession[i].valid != true)
4874 continue;
4875 psession_entry = &mac_ctx->lim.gpSession[i];
4876 if (psession_entry->LimHBFailureStatus != true)
4877 continue;
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304878 pe_debug("SME: %d MLME: %d HB-Count: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004879 psession_entry->limSmeState,
4880 psession_entry->limMlmState,
4881 psession_entry->LimRxedBeaconCntDuringHB);
4882
4883#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
4884 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_HB_FAILURE_TIMEOUT,
4885 psession_entry, 0, 0);
4886#endif
4887 if ((psession_entry->limMlmState ==
4888 eLIM_MLM_LINK_ESTABLISHED_STATE) &&
4889 (psession_entry->limSmeState !=
4890 eLIM_SME_WT_DISASSOC_STATE) &&
4891 (psession_entry->limSmeState !=
4892 eLIM_SME_WT_DEAUTH_STATE) &&
4893 ((!LIM_IS_CONNECTION_ACTIVE(psession_entry)) ||
4894 /*
4895 * Disconnect even if we have not received a single
4896 * beacon after connection.
4897 */
4898 (psession_entry->currentBssBeaconCnt == 0))) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304899 pe_debug("for session: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004900 psession_entry->peSessionId);
Paul Zhange73d1a32017-05-09 23:08:17 +08004901
4902 lim_send_deauth_mgmt_frame(mac_ctx,
4903 eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON,
4904 psession_entry->bssId, psession_entry, false);
4905
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004906 /*
4907 * AP did not respond to Probe Request.
4908 * Tear down link with it.
4909 */
4910 lim_tear_down_link_with_ap(mac_ctx,
4911 psession_entry->peSessionId,
4912 eSIR_BEACON_MISSED);
4913 mac_ctx->lim.gLimProbeFailureAfterHBfailedCnt++;
4914 } else {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304915 pe_err("Unexpected wt-probe-timeout in state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004916 lim_print_mlm_state(mac_ctx, LOGE,
4917 psession_entry->limMlmState);
Varun Reddy Yeturu076eaa82018-01-16 12:16:14 -08004918 if (mac_ctx->sme.tx_queue_cb)
Jeff Johnson6aaaa992018-06-30 10:43:04 -07004919 mac_ctx->sme.tx_queue_cb(mac_ctx->hdd_handle,
Varun Reddy Yeturu076eaa82018-01-16 12:16:14 -08004920 psession_entry->smeSessionId,
4921 WLAN_WAKE_ALL_NETIF_QUEUE,
4922 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004923 }
4924 }
4925 /*
4926 * Deactivate Timer ProbeAfterHB Timer -> As its a oneshot timer,
4927 * need not deactivate the timer
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004928 * tx_timer_deactivate(&mac->lim.limTimers.gLimProbeAfterHBTimer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004929 */
4930}
4931
4932/*
4933 * This function assumes there will not be more than one IBSS session active at any time.
4934 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004935struct pe_session *lim_is_ibss_session_active(struct mac_context *mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004936{
4937 uint8_t i;
4938
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004939 for (i = 0; i < mac->lim.maxBssId; i++) {
4940 if ((mac->lim.gpSession[i].valid) &&
4941 (mac->lim.gpSession[i].limSystemRole ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004942 eLIM_STA_IN_IBSS_ROLE))
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004943 return &mac->lim.gpSession[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004944 }
4945
4946 return NULL;
4947}
4948
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004949struct pe_session *lim_is_ap_session_active(struct mac_context *mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004950{
4951 uint8_t i;
4952
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004953 for (i = 0; i < mac->lim.maxBssId; i++) {
4954 if (mac->lim.gpSession[i].valid &&
4955 (mac->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE))
4956 return &mac->lim.gpSession[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004957 }
4958
4959 return NULL;
4960}
4961
4962/**---------------------------------------------------------
4963 \fn lim_handle_defer_msg_error
4964 \brief handles error scenario, when the msg can not be deferred.
Jeff Johnson982fe962018-11-28 17:07:01 -08004965 \param mac
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004966 \param pLimMsg LIM msg, which could not be deferred.
4967 \return void
4968 -----------------------------------------------------------*/
4969
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004970void lim_handle_defer_msg_error(struct mac_context *mac,
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004971 struct scheduler_msg *pLimMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004972{
4973 if (SIR_BB_XPORT_MGMT_MSG == pLimMsg->type) {
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004974 lim_decrement_pending_mgmt_count(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004975 cds_pkt_return_packet((cds_pkt_t *) pLimMsg->bodyptr);
4976 pLimMsg->bodyptr = NULL;
4977 } else if (pLimMsg->bodyptr != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304978 qdf_mem_free(pLimMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004979 pLimMsg->bodyptr = NULL;
4980 }
4981
4982}
4983
4984#ifdef FEATURE_WLAN_DIAG_SUPPORT
4985/**---------------------------------------------------------
4986 \fn lim_diag_event_report
4987 \brief This function reports Diag event
Jeff Johnson982fe962018-11-28 17:07:01 -08004988 \param mac
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004989 \param eventType
4990 \param bssid
4991 \param status
4992 \param reasonCode
4993 \return void
4994 -----------------------------------------------------------*/
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004995void lim_diag_event_report(struct mac_context *mac, uint16_t eventType,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004996 struct pe_session *pe_session, uint16_t status,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004997 uint16_t reasonCode)
4998{
4999 tSirMacAddr nullBssid = { 0, 0, 0, 0, 0, 0 };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07005000
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005001 WLAN_HOST_DIAG_EVENT_DEF(peEvent, host_event_wlan_pe_payload_type);
5002
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305003 qdf_mem_set(&peEvent, sizeof(host_event_wlan_pe_payload_type), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005004
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005005 if (NULL == pe_session) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305006 qdf_mem_copy(peEvent.bssid, nullBssid, sizeof(tSirMacAddr));
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08005007 peEvent.sme_state = (uint16_t) mac->lim.gLimSmeState;
5008 peEvent.mlm_state = (uint16_t) mac->lim.gLimMlmState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005009
5010 } else {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005011 qdf_mem_copy(peEvent.bssid, pe_session->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005012 sizeof(tSirMacAddr));
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005013 peEvent.sme_state = (uint16_t) pe_session->limSmeState;
5014 peEvent.mlm_state = (uint16_t) pe_session->limMlmState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005015 }
5016 peEvent.event_type = eventType;
5017 peEvent.status = status;
5018 peEvent.reason_code = reasonCode;
5019
5020 WLAN_HOST_DIAG_EVENT_REPORT(&peEvent, EVENT_WLAN_PE);
5021 return;
5022}
5023
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005024static void lim_diag_fill_mgmt_event_report(struct mac_context *mac_ctx,
Krunal Sonic65fc492018-03-09 15:53:28 -08005025 tpSirMacMgmtHdr mac_hdr,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08005026 struct pe_session *session, uint16_t result_code,
Krunal Sonic65fc492018-03-09 15:53:28 -08005027 uint16_t reason_code,
5028 struct host_event_wlan_mgmt_payload_type *mgmt_event)
5029{
5030 uint8_t length;
5031
5032 qdf_mem_set(mgmt_event, sizeof(*mgmt_event), 0);
5033 mgmt_event->mgmt_type = mac_hdr->fc.type;
5034 mgmt_event->mgmt_subtype = mac_hdr->fc.subType;
5035 qdf_mem_copy(mgmt_event->self_mac_addr, session->selfMacAddr,
5036 QDF_MAC_ADDR_SIZE);
5037 qdf_mem_copy(mgmt_event->bssid, session->bssId,
5038 QDF_MAC_ADDR_SIZE);
5039 length = session->ssId.length;
5040 if (length > SIR_MAC_MAX_SSID_LENGTH)
5041 length = SIR_MAC_MAX_SSID_LENGTH;
5042 qdf_mem_copy(mgmt_event->ssid, session->ssId.ssId, length);
5043 mgmt_event->ssid_len = length;
5044 mgmt_event->operating_channel = session->currentOperChannel;
5045 mgmt_event->result_code = result_code;
5046 mgmt_event->reason_code = reason_code;
5047}
5048
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005049void lim_diag_mgmt_tx_event_report(struct mac_context *mac_ctx, void *mgmt_hdr,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08005050 struct pe_session *session, uint16_t result_code,
Krunal Sonic65fc492018-03-09 15:53:28 -08005051 uint16_t reason_code)
5052{
5053 tpSirMacMgmtHdr mac_hdr = mgmt_hdr;
5054
5055 WLAN_HOST_DIAG_EVENT_DEF(mgmt_event,
5056 struct host_event_wlan_mgmt_payload_type);
5057 if (!session || !mac_hdr) {
5058 pe_err("not valid input");
5059 return;
5060 }
5061 lim_diag_fill_mgmt_event_report(mac_ctx, mac_hdr, session,
5062 result_code, reason_code, &mgmt_event);
5063
5064 pe_debug("TX frame: type:%d sub_type:%d seq_num:%d ssid:%.*s selfmacaddr:%pM bssid:%pM channel:%d",
5065 mgmt_event.mgmt_type, mgmt_event.mgmt_subtype,
5066 ((mac_hdr->seqControl.seqNumHi << 4) |
5067 mac_hdr->seqControl.seqNumLo),
5068 mgmt_event.ssid_len, mgmt_event.ssid,
5069 mgmt_event.self_mac_addr, mgmt_event.bssid,
5070 mgmt_event.operating_channel);
5071 WLAN_HOST_DIAG_EVENT_REPORT(&mgmt_event, EVENT_WLAN_HOST_MGMT_TX_V2);
5072}
5073
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005074void lim_diag_mgmt_rx_event_report(struct mac_context *mac_ctx, void *mgmt_hdr,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08005075 struct pe_session *session, uint16_t result_code,
Krunal Sonic65fc492018-03-09 15:53:28 -08005076 uint16_t reason_code)
5077{
5078 tpSirMacMgmtHdr mac_hdr = mgmt_hdr;
5079
5080 WLAN_HOST_DIAG_EVENT_DEF(mgmt_event,
5081 struct host_event_wlan_mgmt_payload_type);
5082 if (!session || !mac_hdr) {
Yeshwanth Sriram Guntukacbe61442018-08-23 18:08:44 +05305083 pe_debug("not valid input");
Krunal Sonic65fc492018-03-09 15:53:28 -08005084 return;
5085 }
5086 lim_diag_fill_mgmt_event_report(mac_ctx, mac_hdr, session,
5087 result_code, reason_code, &mgmt_event);
5088 pe_debug("RX frame: type:%d sub_type:%d seq_num:%d ssid:%.*s selfmacaddr:%pM bssid:%pM channel:%d",
5089 mgmt_event.mgmt_type, mgmt_event.mgmt_subtype,
5090 ((mac_hdr->seqControl.seqNumHi << 4) |
5091 mac_hdr->seqControl.seqNumLo),
5092 mgmt_event.ssid_len, mgmt_event.ssid,
5093 mgmt_event.self_mac_addr, mgmt_event.bssid,
5094 mgmt_event.operating_channel);
5095 WLAN_HOST_DIAG_EVENT_REPORT(&mgmt_event, EVENT_WLAN_HOST_MGMT_RX_V2);
5096}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005097#endif /* FEATURE_WLAN_DIAG_SUPPORT */
5098
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005099/* Returns length of P2P stream and Pointer ie passed to this function is filled with noa stream */
5100
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005101uint8_t lim_build_p2p_ie(struct mac_context *mac, uint8_t *ie, uint8_t *data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005102 uint8_t ie_len)
5103{
5104 int length = 0;
5105 uint8_t *ptr = ie;
5106
5107 ptr[length++] = SIR_MAC_EID_VENDOR;
5108 ptr[length++] = ie_len + SIR_MAC_P2P_OUI_SIZE;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305109 qdf_mem_copy(&ptr[length], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE);
5110 qdf_mem_copy(&ptr[length + SIR_MAC_P2P_OUI_SIZE], data, ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005111 return ie_len + SIR_P2P_IE_HEADER_LEN;
5112}
5113
5114/* Returns length of NoA stream and Pointer pNoaStream passed to this function is filled with noa stream */
5115
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005116uint8_t lim_get_noa_attr_stream_in_mult_p2p_ies(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005117 uint8_t *noaStream, uint8_t noaLen,
5118 uint8_t overFlowLen)
5119{
5120 uint8_t overFlowP2pStream[SIR_MAX_NOA_ATTR_LEN];
5121
5122 if ((noaLen <= (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN)) &&
5123 (noaLen >= overFlowLen) && (overFlowLen <= SIR_MAX_NOA_ATTR_LEN)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305124 qdf_mem_copy(overFlowP2pStream,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005125 noaStream + noaLen - overFlowLen, overFlowLen);
5126 noaStream[noaLen - overFlowLen] = SIR_MAC_EID_VENDOR;
5127 noaStream[noaLen - overFlowLen + 1] =
5128 overFlowLen + SIR_MAC_P2P_OUI_SIZE;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305129 qdf_mem_copy(noaStream + noaLen - overFlowLen + 2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005130 SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305131 qdf_mem_copy(noaStream + noaLen + 2 + SIR_MAC_P2P_OUI_SIZE -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005132 overFlowLen, overFlowP2pStream, overFlowLen);
5133 }
5134
5135 return noaLen + SIR_P2P_IE_HEADER_LEN;
5136
5137}
5138
5139/* Returns length of NoA stream and Pointer pNoaStream passed to this function is filled with noa stream */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005140uint8_t lim_get_noa_attr_stream(struct mac_context *mac, uint8_t *pNoaStream,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005141 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005142{
5143 uint8_t len = 0;
5144
5145 uint8_t *pBody = pNoaStream;
5146
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005147 if ((pe_session != NULL) && (pe_session->valid) &&
5148 (pe_session->pePersona == QDF_P2P_GO_MODE)) {
5149 if ((!(pe_session->p2pGoPsUpdate.uNoa1Duration))
5150 && (!(pe_session->p2pGoPsUpdate.uNoa2Duration))
5151 && (!pe_session->p2pGoPsUpdate.oppPsFlag)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005152 )
5153 return 0; /* No NoA Descriptor then return 0 */
5154
5155 pBody[0] = SIR_P2P_NOA_ATTR;
5156
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005157 pBody[3] = pe_session->p2pGoPsUpdate.index;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005158 pBody[4] =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005159 pe_session->p2pGoPsUpdate.ctWin | (pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005160 p2pGoPsUpdate.
5161 oppPsFlag << 7);
5162 len = 5;
5163 pBody += len;
5164
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005165 if (pe_session->p2pGoPsUpdate.uNoa1Duration) {
5166 *pBody = pe_session->p2pGoPsUpdate.uNoa1IntervalCnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005167 pBody += 1;
5168 len += 1;
5169
5170 *((uint32_t *) (pBody)) =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005171 sir_swap_u32if_needed(pe_session->p2pGoPsUpdate.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005172 uNoa1Duration);
5173 pBody += sizeof(uint32_t);
5174 len += 4;
5175
5176 *((uint32_t *) (pBody)) =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005177 sir_swap_u32if_needed(pe_session->p2pGoPsUpdate.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005178 uNoa1Interval);
5179 pBody += sizeof(uint32_t);
5180 len += 4;
5181
5182 *((uint32_t *) (pBody)) =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005183 sir_swap_u32if_needed(pe_session->p2pGoPsUpdate.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005184 uNoa1StartTime);
5185 pBody += sizeof(uint32_t);
5186 len += 4;
5187
5188 }
5189
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005190 if (pe_session->p2pGoPsUpdate.uNoa2Duration) {
5191 *pBody = pe_session->p2pGoPsUpdate.uNoa2IntervalCnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005192 pBody += 1;
5193 len += 1;
5194
5195 *((uint32_t *) (pBody)) =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005196 sir_swap_u32if_needed(pe_session->p2pGoPsUpdate.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005197 uNoa2Duration);
5198 pBody += sizeof(uint32_t);
5199 len += 4;
5200
5201 *((uint32_t *) (pBody)) =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005202 sir_swap_u32if_needed(pe_session->p2pGoPsUpdate.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005203 uNoa2Interval);
5204 pBody += sizeof(uint32_t);
5205 len += 4;
5206
5207 *((uint32_t *) (pBody)) =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005208 sir_swap_u32if_needed(pe_session->p2pGoPsUpdate.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005209 uNoa2StartTime);
5210 pBody += sizeof(uint32_t);
5211 len += 4;
5212
5213 }
5214
5215 pBody = pNoaStream + 1;
5216 *((uint16_t *) (pBody)) = sir_swap_u16if_needed(len - 3); /*one byte for Attr and 2 bytes for length */
5217
5218 return len;
5219
5220 }
5221 return 0;
5222
5223}
5224
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005225void pe_set_resume_channel(struct mac_context *mac, uint16_t channel,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005226 ePhyChanBondState phyCbState)
5227{
5228
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08005229 mac->lim.gResumeChannel = channel;
5230 mac->lim.gResumePhyCbState = phyCbState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005231}
5232
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005233bool lim_is_noa_insert_reqd(struct mac_context *mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005234{
5235 uint8_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07005236
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08005237 for (i = 0; i < mac->lim.maxBssId; i++) {
5238 if (mac->lim.gpSession[i].valid == true) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005239 if ((eLIM_AP_ROLE ==
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08005240 mac->lim.gpSession[i].limSystemRole)
Anurag Chouhan6d760662016-02-20 16:05:43 +05305241 && (QDF_P2P_GO_MODE ==
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08005242 mac->lim.gpSession[i].pePersona)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005243 ) {
5244 return true;
5245 }
5246 }
5247 }
5248 return false;
5249}
5250
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005251bool lim_isconnected_on_dfs_channel(struct mac_context *mac_ctx,
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005252 uint8_t currentChannel)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005253{
5254 if (CHANNEL_STATE_DFS ==
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005255 wlan_reg_get_channel_state(mac_ctx->pdev, currentChannel)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005256 return true;
5257 } else {
5258 return false;
5259 }
5260}
5261
5262#ifdef WLAN_FEATURE_11W
5263void lim_pmf_sa_query_timer_handler(void *pMacGlobal, uint32_t param)
5264{
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005265 struct mac_context *mac = (struct mac_context *) pMacGlobal;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005266 tPmfSaQueryTimerId timerId;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005267 struct pe_session *pe_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005268 tpDphHashNode pSta;
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05305269 uint8_t maxretries;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005270
Nishank Aggarwal0402b432017-03-24 19:17:36 +05305271 pe_debug("SA Query timer fires");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005272 timerId.value = param;
5273
5274 /* Check that SA Query is in progress */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005275 pe_session = pe_find_session_by_session_id(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005276 timerId.fields.sessionId);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005277 if (pe_session == NULL) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05305278 pe_err("Session does not exist for given session ID: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005279 timerId.fields.sessionId);
5280 return;
5281 }
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08005282 pSta = dph_get_hash_entry(mac, timerId.fields.peerIdx,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005283 &pe_session->dph.dphHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005284 if (pSta == NULL) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05305285 pe_err("Entry does not exist for given peer index: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005286 timerId.fields.peerIdx);
5287 return;
5288 }
5289 if (DPH_SA_QUERY_IN_PROGRESS != pSta->pmfSaQueryState)
5290 return;
5291
5292 /* Increment the retry count, check if reached maximum */
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08005293 maxretries = mac->mlme_cfg->gen.pmf_sa_query_max_retries;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005294 pSta->pmfSaQueryRetryCount++;
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05305295 if (pSta->pmfSaQueryRetryCount >= maxretries) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05305296 pe_err("SA Query timed out,Deleting STA");
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08005297 lim_print_mac_addr(mac, pSta->staAddr, LOGE);
5298 lim_send_disassoc_mgmt_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005299 eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005300 pSta->staAddr, pe_session, false);
5301 lim_trigger_sta_deletion(mac, pSta, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005302 pSta->pmfSaQueryState = DPH_SA_QUERY_TIMED_OUT;
5303 return;
5304 }
5305 /* Retry SA Query */
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08005306 lim_send_sa_query_request_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005307 (uint8_t *) &(pSta->
5308 pmfSaQueryCurrentTransId),
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005309 pSta->staAddr, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005310 pSta->pmfSaQueryCurrentTransId++;
Nishank Aggarwal0402b432017-03-24 19:17:36 +05305311 pe_debug("Starting SA Query retry: %d", pSta->pmfSaQueryRetryCount);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005312 if (tx_timer_activate(&pSta->pmfSaQueryTimer) != TX_SUCCESS) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05305313 pe_err("PMF SA Query timer activation failed!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005314 pSta->pmfSaQueryState = DPH_SA_QUERY_NOT_IN_PROGRESS;
5315 }
5316}
5317#endif
5318
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005319bool lim_check_vht_op_mode_change(struct mac_context *mac, struct pe_session *pe_session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005320 uint8_t chanWidth, uint8_t staId,
5321 uint8_t *peerMac)
5322{
5323 tUpdateVHTOpMode tempParam;
5324
5325 tempParam.opMode = chanWidth;
5326 tempParam.staId = staId;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005327 tempParam.smesessionId = pe_session->smeSessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305328 qdf_mem_copy(tempParam.peer_mac, peerMac, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005329
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005330 lim_send_mode_update(mac, &tempParam, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005331
5332 return true;
5333}
5334
Krunal Sonib7f20432017-04-27 13:01:02 -07005335#ifdef WLAN_FEATURE_11AX_BSS_COLOR
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005336bool lim_send_he_ie_update(struct mac_context *mac_ctx, struct pe_session *pe_session)
Krunal Sonib7f20432017-04-27 13:01:02 -07005337{
Krunal Sonib7f20432017-04-27 13:01:02 -07005338 QDF_STATUS status;
5339
Krunal Sonib7f20432017-04-27 13:01:02 -07005340 status = wma_update_he_ops_ie(cds_get_context(QDF_MODULE_ID_WMA),
Naveen Rawatdf221b72017-11-15 11:32:31 -08005341 pe_session->smeSessionId,
5342 &pe_session->he_op);
5343 if (QDF_IS_STATUS_ERROR(status))
Krunal Sonib7f20432017-04-27 13:01:02 -07005344 return false;
Krunal Sonib7f20432017-04-27 13:01:02 -07005345
5346 return true;
Krunal Sonib7f20432017-04-27 13:01:02 -07005347}
5348#endif
5349
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005350bool lim_set_nss_change(struct mac_context *mac, struct pe_session *pe_session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005351 uint8_t rxNss, uint8_t staId, uint8_t *peerMac)
5352{
5353 tUpdateRxNss tempParam;
5354
Himanshu Agarwala79c6762017-12-28 21:25:00 +05305355 if (!rxNss) {
5356 pe_err("Invalid rxNss value: %u", rxNss);
Dustin Brown83044c22018-08-13 15:00:44 -07005357 cds_trigger_recovery(QDF_REASON_UNSPECIFIED);
Himanshu Agarwala79c6762017-12-28 21:25:00 +05305358 }
5359
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005360 tempParam.rxNss = rxNss;
5361 tempParam.staId = staId;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005362 tempParam.smesessionId = pe_session->smeSessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305363 qdf_mem_copy(tempParam.peer_mac, peerMac, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005364
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005365 lim_send_rx_nss_update(mac, &tempParam, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005366
5367 return true;
5368}
5369
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005370bool lim_check_membership_user_position(struct mac_context *mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005371 struct pe_session *pe_session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005372 uint32_t membership, uint32_t userPosition,
5373 uint8_t staId)
5374{
5375 tUpdateMembership tempParamMembership;
5376 tUpdateUserPos tempParamUserPosition;
5377
5378 tempParamMembership.membership = membership;
5379 tempParamMembership.staId = staId;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005380 tempParamMembership.smesessionId = pe_session->smeSessionId;
5381 qdf_mem_copy(tempParamMembership.peer_mac, pe_session->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005382 sizeof(tSirMacAddr));
5383
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005384 lim_set_membership(mac, &tempParamMembership, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005385
5386 tempParamUserPosition.userPos = userPosition;
5387 tempParamUserPosition.staId = staId;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005388 tempParamUserPosition.smesessionId = pe_session->smeSessionId;
5389 qdf_mem_copy(tempParamUserPosition.peer_mac, pe_session->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005390 sizeof(tSirMacAddr));
5391
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005392 lim_set_user_pos(mac, &tempParamUserPosition, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005393
5394 return true;
5395}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005396
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005397void lim_get_short_slot_from_phy_mode(struct mac_context *mac, struct pe_session *pe_session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005398 uint32_t phyMode, uint8_t *pShortSlotEnabled)
5399{
5400 uint8_t val = 0;
5401
5402 /* only 2.4G band should have short slot enable, rest it should be default */
5403 if (phyMode == WNI_CFG_PHY_MODE_11G) {
5404 /* short slot is default in all other modes */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005405 if ((pe_session->pePersona == QDF_SAP_MODE) ||
5406 (pe_session->pePersona == QDF_IBSS_MODE) ||
5407 (pe_session->pePersona == QDF_P2P_GO_MODE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005408 val = true;
5409 }
5410 /* Program Polaris based on AP capability */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005411 if (pe_session->limMlmState == eLIM_MLM_WT_JOIN_BEACON_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005412 /* Joining BSS. */
5413 val =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005414 SIR_MAC_GET_SHORT_SLOT_TIME(pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005415 limCurrentBssCaps);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005416 } else if (pe_session->limMlmState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005417 eLIM_MLM_WT_REASSOC_RSP_STATE) {
5418 /* Reassociating with AP. */
5419 val =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005420 SIR_MAC_GET_SHORT_SLOT_TIME(pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005421 limReassocBssCaps);
5422 }
5423 } else {
5424 /*
5425 * 11B does not short slot and short slot is default
5426 * for 11A mode. Hence, not need to set this bit
5427 */
5428 val = false;
5429 }
5430
Nishank Aggarwal0402b432017-03-24 19:17:36 +05305431 pe_debug("phyMode: %u shortslotsupported: %u", phyMode, val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005432 *pShortSlotEnabled = val;
5433}
5434
5435#ifdef WLAN_FEATURE_11W
5436/**
5437 *
5438 * \brief This function is called by various LIM modules to correctly set
5439 * the Protected bit in the Frame Control Field of the 802.11 frame MAC header
5440 *
5441 *
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08005442 * \param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005443 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005444 * \param pe_session Pointer to session corresponding to the connection
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005445 *
5446 * \param peer Peer address of the STA to which the frame is to be sent
5447 *
5448 * \param pMacHdr Pointer to the frame MAC header
5449 *
5450 * \return nothing
5451 *
5452 *
5453 */
5454void
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005455lim_set_protected_bit(struct mac_context *mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005456 struct pe_session *pe_session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005457 tSirMacAddr peer, tpSirMacMgmtHdr pMacHdr)
5458{
5459 uint16_t aid;
5460 tpDphHashNode pStaDs;
5461
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005462 if (LIM_IS_AP_ROLE(pe_session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005463
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08005464 pStaDs = dph_lookup_hash_entry(mac, peer, &aid,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005465 &pe_session->dph.dphHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005466 if (pStaDs != NULL) {
5467 /* rmfenabled will be set at the time of addbss.
5468 * but sometimes EAP auth fails and keys are not
5469 * installed then if we send any management frame
5470 * like deauth/disassoc with this bit set then
5471 * firmware crashes. so check for keys are
5472 * installed or not also before setting the bit
5473 */
5474 if (pStaDs->rmfEnabled && pStaDs->is_key_installed)
5475 pMacHdr->fc.wep = 1;
5476 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005477 } else if (pe_session->limRmfEnabled &&
5478 pe_session->is_key_installed) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005479 pMacHdr->fc.wep = 1;
5480 }
5481} /*** end lim_set_protected_bit() ***/
5482#endif
5483
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005484void lim_set_ht_caps(struct mac_context *p_mac, struct pe_session *p_session_entry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005485 uint8_t *p_ie_start, uint32_t num_bytes)
5486{
Naveen Rawat08db88f2017-09-08 15:07:48 -07005487 const uint8_t *p_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005488 tDot11fIEHTCaps dot11_ht_cap = {0,};
5489
5490 populate_dot11f_ht_caps(p_mac, p_session_entry, &dot11_ht_cap);
Naveen Rawat08db88f2017-09-08 15:07:48 -07005491 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
5492 p_ie_start, num_bytes);
Jeff Johnson11bd4f32017-09-18 08:15:17 -07005493 pe_debug("p_ie: %pK dot11_ht_cap.supportedMCSSet[0]: 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005494 p_ie, dot11_ht_cap.supportedMCSSet[0]);
5495 if (p_ie) {
5496 /* convert from unpacked to packed structure */
5497 tHtCaps *p_ht_cap = (tHtCaps *) &p_ie[2];
5498
5499 p_ht_cap->advCodingCap = dot11_ht_cap.advCodingCap;
5500 p_ht_cap->supportedChannelWidthSet =
5501 dot11_ht_cap.supportedChannelWidthSet;
5502 p_ht_cap->mimoPowerSave = dot11_ht_cap.mimoPowerSave;
5503 p_ht_cap->greenField = dot11_ht_cap.greenField;
5504 p_ht_cap->shortGI20MHz = dot11_ht_cap.shortGI20MHz;
5505 p_ht_cap->shortGI40MHz = dot11_ht_cap.shortGI40MHz;
5506 p_ht_cap->txSTBC = dot11_ht_cap.txSTBC;
5507 p_ht_cap->rxSTBC = dot11_ht_cap.rxSTBC;
5508 p_ht_cap->delayedBA = dot11_ht_cap.delayedBA;
5509 p_ht_cap->maximalAMSDUsize = dot11_ht_cap.maximalAMSDUsize;
5510 p_ht_cap->dsssCckMode40MHz = dot11_ht_cap.dsssCckMode40MHz;
5511 p_ht_cap->psmp = dot11_ht_cap.psmp;
5512 p_ht_cap->stbcControlFrame = dot11_ht_cap.stbcControlFrame;
5513 p_ht_cap->lsigTXOPProtection = dot11_ht_cap.lsigTXOPProtection;
5514 p_ht_cap->maxRxAMPDUFactor = dot11_ht_cap.maxRxAMPDUFactor;
5515 p_ht_cap->mpduDensity = dot11_ht_cap.mpduDensity;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305516 qdf_mem_copy((void *)p_ht_cap->supportedMCSSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005517 (void *)(dot11_ht_cap.supportedMCSSet),
5518 sizeof(p_ht_cap->supportedMCSSet));
5519 p_ht_cap->pco = dot11_ht_cap.pco;
5520 p_ht_cap->transitionTime = dot11_ht_cap.transitionTime;
5521 p_ht_cap->mcsFeedback = dot11_ht_cap.mcsFeedback;
5522 p_ht_cap->txBF = dot11_ht_cap.txBF;
5523 p_ht_cap->rxStaggeredSounding =
5524 dot11_ht_cap.rxStaggeredSounding;
5525 p_ht_cap->txStaggeredSounding =
5526 dot11_ht_cap.txStaggeredSounding;
5527 p_ht_cap->rxZLF = dot11_ht_cap.rxZLF;
5528 p_ht_cap->txZLF = dot11_ht_cap.txZLF;
5529 p_ht_cap->implicitTxBF = dot11_ht_cap.implicitTxBF;
5530 p_ht_cap->calibration = dot11_ht_cap.calibration;
5531 p_ht_cap->explicitCSITxBF = dot11_ht_cap.explicitCSITxBF;
5532 p_ht_cap->explicitUncompressedSteeringMatrix =
5533 dot11_ht_cap.explicitUncompressedSteeringMatrix;
5534 p_ht_cap->explicitBFCSIFeedback =
5535 dot11_ht_cap.explicitBFCSIFeedback;
5536 p_ht_cap->explicitUncompressedSteeringMatrixFeedback =
5537 dot11_ht_cap.explicitUncompressedSteeringMatrixFeedback;
5538 p_ht_cap->explicitCompressedSteeringMatrixFeedback =
5539 dot11_ht_cap.explicitCompressedSteeringMatrixFeedback;
5540 p_ht_cap->csiNumBFAntennae = dot11_ht_cap.csiNumBFAntennae;
5541 p_ht_cap->uncompressedSteeringMatrixBFAntennae =
5542 dot11_ht_cap.uncompressedSteeringMatrixBFAntennae;
5543 p_ht_cap->compressedSteeringMatrixBFAntennae =
5544 dot11_ht_cap.compressedSteeringMatrixBFAntennae;
5545 p_ht_cap->antennaSelection = dot11_ht_cap.antennaSelection;
5546 p_ht_cap->explicitCSIFeedbackTx =
5547 dot11_ht_cap.explicitCSIFeedbackTx;
5548 p_ht_cap->antennaIndicesFeedbackTx =
5549 dot11_ht_cap.antennaIndicesFeedbackTx;
5550 p_ht_cap->explicitCSIFeedback =
5551 dot11_ht_cap.explicitCSIFeedback;
5552 p_ht_cap->antennaIndicesFeedback =
5553 dot11_ht_cap.antennaIndicesFeedback;
5554 p_ht_cap->rxAS = dot11_ht_cap.rxAS;
5555 p_ht_cap->txSoundingPPDUs = dot11_ht_cap.txSoundingPPDUs;
5556 }
5557}
5558
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005559void lim_set_vht_caps(struct mac_context *p_mac, struct pe_session *p_session_entry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005560 uint8_t *p_ie_start, uint32_t num_bytes)
5561{
Naveen Rawat08db88f2017-09-08 15:07:48 -07005562 const uint8_t *p_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005563 tDot11fIEVHTCaps dot11_vht_cap;
5564
5565 populate_dot11f_vht_caps(p_mac, p_session_entry, &dot11_vht_cap);
Naveen Rawat08db88f2017-09-08 15:07:48 -07005566 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS, p_ie_start,
5567 num_bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005568 if (p_ie) {
5569 tSirMacVHTCapabilityInfo *vht_cap =
5570 (tSirMacVHTCapabilityInfo *) &p_ie[2];
5571 tSirVhtMcsInfo *vht_mcs = (tSirVhtMcsInfo *) &p_ie[2 +
5572 sizeof(tSirMacVHTCapabilityInfo)];
5573
5574 union {
5575 uint16_t u_value;
5576 tSirMacVHTRxSupDataRateInfo vht_rx_supp_rate;
5577 tSirMacVHTTxSupDataRateInfo vht_tx_supp_rate;
5578 } u_vht_data_rate_info;
5579
5580 vht_cap->maxMPDULen = dot11_vht_cap.maxMPDULen;
5581 vht_cap->supportedChannelWidthSet =
5582 dot11_vht_cap.supportedChannelWidthSet;
5583 vht_cap->ldpcCodingCap = dot11_vht_cap.ldpcCodingCap;
5584 vht_cap->shortGI80MHz = dot11_vht_cap.shortGI80MHz;
5585 vht_cap->shortGI160and80plus80MHz =
5586 dot11_vht_cap.shortGI160and80plus80MHz;
5587 vht_cap->txSTBC = dot11_vht_cap.txSTBC;
5588 vht_cap->rxSTBC = dot11_vht_cap.rxSTBC;
5589 vht_cap->suBeamFormerCap = dot11_vht_cap.suBeamFormerCap;
5590 vht_cap->suBeamformeeCap = dot11_vht_cap.suBeamformeeCap;
5591 vht_cap->csnofBeamformerAntSup =
5592 dot11_vht_cap.csnofBeamformerAntSup;
5593 vht_cap->numSoundingDim = dot11_vht_cap.numSoundingDim;
5594 vht_cap->muBeamformerCap = dot11_vht_cap.muBeamformerCap;
5595 vht_cap->muBeamformeeCap = dot11_vht_cap.muBeamformeeCap;
5596 vht_cap->vhtTXOPPS = dot11_vht_cap.vhtTXOPPS;
5597 vht_cap->htcVHTCap = dot11_vht_cap.htcVHTCap;
5598 vht_cap->maxAMPDULenExp = dot11_vht_cap.maxAMPDULenExp;
5599 vht_cap->vhtLinkAdaptCap = dot11_vht_cap.vhtLinkAdaptCap;
5600 vht_cap->rxAntPattern = dot11_vht_cap.rxAntPattern;
5601 vht_cap->txAntPattern = dot11_vht_cap.txAntPattern;
5602 vht_cap->reserved1 = dot11_vht_cap.reserved1;
5603
5604 /* Populate VHT MCS Information */
5605 vht_mcs->rxMcsMap = dot11_vht_cap.rxMCSMap;
5606 u_vht_data_rate_info.vht_rx_supp_rate.rxSupDataRate =
5607 dot11_vht_cap.rxHighSupDataRate;
5608 u_vht_data_rate_info.vht_rx_supp_rate.reserved =
5609 dot11_vht_cap.reserved2;
5610 vht_mcs->rxHighest = u_vht_data_rate_info.u_value;
5611
5612 vht_mcs->txMcsMap = dot11_vht_cap.txMCSMap;
5613 u_vht_data_rate_info.vht_tx_supp_rate.txSupDataRate =
5614 dot11_vht_cap.txSupDataRate;
5615 u_vht_data_rate_info.vht_tx_supp_rate.reserved =
5616 dot11_vht_cap.reserved3;
5617 vht_mcs->txHighest = u_vht_data_rate_info.u_value;
5618 }
5619}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005620
5621/**
5622 * lim_validate_received_frame_a1_addr() - To validate received frame's A1 addr
5623 * @mac_ctx: pointer to mac context
5624 * @a1: received frame's a1 address which is nothing but our self address
5625 * @session: PE session pointer
5626 *
Jeff Johnsonbe7f4fd2018-05-11 21:05:54 -07005627 * This routine will validate, A1 address of the received frame
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005628 *
5629 * Return: true or false
5630 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005631bool lim_validate_received_frame_a1_addr(struct mac_context *mac_ctx,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08005632 tSirMacAddr a1, struct pe_session *session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005633{
5634 if (mac_ctx == NULL || session == NULL) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05305635 pe_err("mac or session context is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005636 /* let main routine handle it */
5637 return true;
5638 }
5639 if (lim_is_group_addr(a1) || lim_is_addr_bc(a1)) {
5640 /* just for fail safe, don't handle MC/BC a1 in this routine */
5641 return true;
5642 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305643 if (qdf_mem_cmp(a1, session->selfMacAddr, 6)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05305644 pe_err("Invalid A1 address in received frame");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005645 return false;
5646 }
5647 return true;
5648}
5649
5650/**
5651 * lim_check_and_reset_protection_params() - reset protection related parameters
5652 *
5653 * @mac_ctx: pointer to global mac structure
5654 *
5655 * resets protection related global parameters if the pe active session count
5656 * is zero.
5657 *
5658 * Return: None
5659 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005660void lim_check_and_reset_protection_params(struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005661{
5662 if (!pe_get_active_session_count(mac_ctx)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005663 mac_ctx->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
5664 }
5665}
5666
5667/**
5668 * lim_set_stads_rtt_cap() - update station node RTT capability
5669 * @sta_ds: Station hash node
5670 * @ext_cap: Pointer to extended capability
5671 * @mac_ctx: global MAC context
5672 *
5673 * This funciton update hash node's RTT capability based on received
5674 * Extended capability IE.
5675 *
5676 * Return: None
5677 */
5678void lim_set_stads_rtt_cap(tpDphHashNode sta_ds, struct s_ext_cap *ext_cap,
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005679 struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005680{
5681 sta_ds->timingMeasCap = 0;
5682 sta_ds->timingMeasCap |= (ext_cap->timing_meas) ?
5683 RTT_TIMING_MEAS_CAPABILITY :
5684 RTT_INVALID;
5685 sta_ds->timingMeasCap |= (ext_cap->fine_time_meas_initiator) ?
5686 RTT_FINE_TIME_MEAS_INITIATOR_CAPABILITY :
5687 RTT_INVALID;
5688 sta_ds->timingMeasCap |= (ext_cap->fine_time_meas_responder) ?
5689 RTT_FINE_TIME_MEAS_RESPONDER_CAPABILITY :
5690 RTT_INVALID;
5691
Nishank Aggarwal0402b432017-03-24 19:17:36 +05305692 pe_debug("ExtCap present, timingMeas: %d Initiator: %d Responder: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005693 ext_cap->timing_meas, ext_cap->fine_time_meas_initiator,
5694 ext_cap->fine_time_meas_responder);
5695}
5696
Varun Reddy Yeturu4f849e52018-06-15 18:08:37 -07005697#ifdef WLAN_SUPPORT_TWT
Jeff Johnsonc8baa902018-11-18 21:59:07 -08005698void lim_set_peer_twt_cap(struct pe_session *session, struct s_ext_cap *ext_cap)
Varun Reddy Yeturu4f849e52018-06-15 18:08:37 -07005699{
Arif Hussain6686c0b2018-08-21 18:21:05 -07005700 if (session->enable_session_twt_support) {
5701 session->peer_twt_requestor = ext_cap->twt_requestor_support;
5702 session->peer_twt_responder = ext_cap->twt_responder_support;
5703 }
Varun Reddy Yeturu4f849e52018-06-15 18:08:37 -07005704
Arif Hussain6686c0b2018-08-21 18:21:05 -07005705 pe_debug("Ext Cap peer TWT requestor: %d, responder: %d, enable_twt %d",
Varun Reddy Yeturu4f849e52018-06-15 18:08:37 -07005706 ext_cap->twt_requestor_support,
Arif Hussain6686c0b2018-08-21 18:21:05 -07005707 ext_cap->twt_responder_support,
5708 session->enable_session_twt_support);
Varun Reddy Yeturu4f849e52018-06-15 18:08:37 -07005709}
5710#endif
5711
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005712/**
Naveen Rawat03e8d952016-08-01 15:22:20 -07005713 * lim_send_ie() - sends IE to wma
5714 * @mac_ctx: global MAC context
5715 * @sme_session_id: sme session id
5716 * @eid: IE id
5717 * @band: band for which IE is intended
5718 * @buf: buffer containing IE
5719 * @len: length of buffer
5720 *
5721 * This funciton sends the IE data to WMA.
5722 *
5723 * Return: status of operation
5724 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005725static QDF_STATUS lim_send_ie(struct mac_context *mac_ctx, uint32_t sme_session_id,
Jeff Johnson22496442016-10-07 07:34:46 -07005726 uint8_t eid, enum cds_band_type band,
5727 uint8_t *buf, uint32_t len)
Naveen Rawat03e8d952016-08-01 15:22:20 -07005728{
5729 struct vdev_ie_info *ie_msg;
Rajeev Kumarf7d84422017-01-21 15:45:44 -08005730 struct scheduler_msg msg = {0};
Naveen Rawat03e8d952016-08-01 15:22:20 -07005731 QDF_STATUS status;
5732
5733 /* Allocate memory for the WMI request */
5734 ie_msg = qdf_mem_malloc(sizeof(*ie_msg) + len);
Arif Hussainf5b6c412018-10-10 19:41:09 -07005735 if (!ie_msg)
Naveen Rawat03e8d952016-08-01 15:22:20 -07005736 return QDF_STATUS_E_NOMEM;
Naveen Rawat03e8d952016-08-01 15:22:20 -07005737
5738 ie_msg->vdev_id = sme_session_id;
5739 ie_msg->ie_id = eid;
5740 ie_msg->length = len;
5741 ie_msg->band = band;
5742 /* IE data buffer starts at end of the struct */
5743 ie_msg->data = (uint8_t *)&ie_msg[1];
5744
5745 qdf_mem_copy(ie_msg->data, buf, len);
5746 msg.type = WMA_SET_IE_INFO;
5747 msg.bodyptr = ie_msg;
5748 msg.reserved = 0;
5749
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05305750 status = scheduler_post_message(QDF_MODULE_ID_PE,
5751 QDF_MODULE_ID_WMA,
5752 QDF_MODULE_ID_WMA, &msg);
Naveen Rawat03e8d952016-08-01 15:22:20 -07005753 if (QDF_STATUS_SUCCESS != status) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05305754 pe_err("Not able to post WMA_SET_IE_INFO to WMA");
Naveen Rawat03e8d952016-08-01 15:22:20 -07005755 qdf_mem_free(ie_msg);
5756 return status;
5757 }
5758
5759 return status;
5760}
5761
5762/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07005763 * lim_get_rx_ldpc() - gets ldpc setting for given channel(band)
5764 * @mac_ctx: global mac context
Krunal Soni3512f6b2017-06-30 12:43:40 -07005765 * @ch: channel enum for which ldpc setting is required
5766 * Note: ch param is not absolute channel number rather it is
5767 * channel number enum.
Naveen Rawat03e8d952016-08-01 15:22:20 -07005768 *
Naveen Rawata410c5a2016-09-19 14:22:33 -07005769 * Return: true if enabled and false otherwise
Naveen Rawat03e8d952016-08-01 15:22:20 -07005770 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005771static inline bool lim_get_rx_ldpc(struct mac_context *mac_ctx, enum channel_enum ch)
Naveen Rawat03e8d952016-08-01 15:22:20 -07005772{
Vignesh Viswanathanecd4de72018-11-22 13:02:20 +05305773 if (mac_ctx->mlme_cfg->ht_caps.ht_cap_info.adv_coding_cap &&
5774 wma_is_rx_ldpc_supported_for_channel(WLAN_REG_CH_NUM(ch)))
Naveen Rawata410c5a2016-09-19 14:22:33 -07005775 return true;
5776 else
5777 return false;
Naveen Rawat03e8d952016-08-01 15:22:20 -07005778}
5779
5780/**
gaurank kathpaliaad980492018-10-31 19:22:30 +05305781 * lim_populate_mcs_set_ht_per_vdev() - update the MCS set according to vdev nss
5782 * @mac_ctx: global mac context
5783 * @ht_cap: pointer to ht caps
5784 * @vdev_id: vdev for which IE is targeted
5785 * @band: band for which the MCS set has to be updated
5786 *
gaurank kathpaliab414bce2018-11-09 18:44:46 +05305787 * This function updates the MCS set according to vdev nss
gaurank kathpaliaad980492018-10-31 19:22:30 +05305788 *
5789 * Return: None
5790 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005791static void lim_populate_mcs_set_ht_per_vdev(struct mac_context *mac_ctx,
gaurank kathpaliaad980492018-10-31 19:22:30 +05305792 struct sHtCaps *ht_cap,
5793 uint8_t vdev_id,
5794 uint8_t band)
5795{
5796 struct wlan_mlme_nss_chains *nss_chains_ini_cfg;
5797 struct wlan_objmgr_vdev *vdev =
5798 wlan_objmgr_get_vdev_by_id_from_psoc(mac_ctx->psoc,
5799 vdev_id,
5800 WLAN_MLME_SB_ID);
5801 if (!vdev) {
5802 pe_err("Got NULL vdev obj, returning");
5803 return;
5804 }
5805 if (!ht_cap->supportedMCSSet[1])
5806 goto end;
5807 nss_chains_ini_cfg = mlme_get_ini_vdev_config(vdev);
5808 if (!nss_chains_ini_cfg) {
5809 pe_err("nss chain dynamic config NULL");
5810 goto end;
5811 }
5812
5813 /* convert from unpacked to packed structure */
5814 if (nss_chains_ini_cfg->rx_nss[band] == 1)
5815 ht_cap->supportedMCSSet[1] = 0;
5816
5817end:
5818 wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_SB_ID);
5819}
5820
5821/**
5822 * lim_populate_mcs_set_vht_per_vdev() - update MCS set according to vdev nss
5823 * @mac_ctx: global mac context
5824 * @vht_caps: pointer to vht_caps
5825 * @vdev_id: vdev for which IE is targeted
5826 * @band: band for which the MCS set has to be updated
5827 *
gaurank kathpaliab414bce2018-11-09 18:44:46 +05305828 * This function updates the MCS set according to vdev nss
gaurank kathpaliaad980492018-10-31 19:22:30 +05305829 *
5830 * Return: None
5831 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005832static void lim_populate_mcs_set_vht_per_vdev(struct mac_context *mac_ctx,
gaurank kathpaliaad980492018-10-31 19:22:30 +05305833 uint8_t *vht_caps,
5834 uint8_t vdev_id,
5835 uint8_t band)
5836{
5837 struct wlan_mlme_nss_chains *nss_chains_ini_cfg;
5838 tSirVhtMcsInfo *vht_mcs;
5839 struct wlan_objmgr_vdev *vdev =
5840 wlan_objmgr_get_vdev_by_id_from_psoc(mac_ctx->psoc,
5841 vdev_id,
5842 WLAN_MLME_SB_ID);
5843 if (!vdev) {
5844 pe_err("Got NULL vdev obj, returning");
5845 return;
5846 }
5847
5848 nss_chains_ini_cfg = mlme_get_ini_vdev_config(vdev);
5849 if (!nss_chains_ini_cfg) {
5850 pe_err("nss chain dynamic config NULL");
5851 goto end;
5852 }
5853
5854 vht_mcs = (tSirVhtMcsInfo *)&vht_caps[2 +
5855 sizeof(tSirMacVHTCapabilityInfo)];
5856 if (nss_chains_ini_cfg->tx_nss[band] == 1) {
5857 /* Populate VHT MCS Information */
5858 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
5859 vht_mcs->txHighest =
5860 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
5861 }
5862
5863 if (nss_chains_ini_cfg->rx_nss[band] == 1) {
5864 /* Populate VHT MCS Information */
5865 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
5866 vht_mcs->rxHighest =
5867 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
5868 }
5869
5870end:
5871 wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_SB_ID);
5872}
5873
5874/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07005875 * lim_send_ies_per_band() - gets ht and vht capability and send to firmware via
Naveen Rawat03e8d952016-08-01 15:22:20 -07005876 * wma
Naveen Rawata410c5a2016-09-19 14:22:33 -07005877 * @mac_ctx: global mac context
5878 * @session: pe session. This can be NULL. In that case self cap will be sent
5879 * @vdev_id: vdev for which IE is targeted
Naveen Rawat03e8d952016-08-01 15:22:20 -07005880 *
5881 * This funciton gets ht and vht capability and send to firmware via wma
5882 *
5883 * Return: status of operation
5884 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005885QDF_STATUS lim_send_ies_per_band(struct mac_context *mac_ctx,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08005886 struct pe_session *session,
Naveen Rawata410c5a2016-09-19 14:22:33 -07005887 uint8_t vdev_id)
Naveen Rawat03e8d952016-08-01 15:22:20 -07005888{
Naveen Rawata410c5a2016-09-19 14:22:33 -07005889 uint8_t ht_caps[DOT11F_IE_HTCAPS_MIN_LEN + 2] = {0};
5890 uint8_t vht_caps[DOT11F_IE_VHTCAPS_MAX_LEN + 2] = {0};
Naveen Rawat1620ecb2016-10-10 15:25:50 -07005891 tHtCaps *p_ht_cap = (tHtCaps *)(&ht_caps[2]);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005892 tSirMacVHTCapabilityInfo *p_vht_cap =
Naveen Rawat1620ecb2016-10-10 15:25:50 -07005893 (tSirMacVHTCapabilityInfo *)(&vht_caps[2]);
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08005894 QDF_STATUS status;
Naveen Rawat03e8d952016-08-01 15:22:20 -07005895
Naveen Rawata410c5a2016-09-19 14:22:33 -07005896 /*
5897 * Note: Do not use Dot11f VHT structure, since 1 byte present flag in
5898 * it is causing weird padding errors. Instead use Sir Mac VHT struct
5899 * to send IE to wma.
5900 */
5901 ht_caps[0] = DOT11F_EID_HTCAPS;
5902 ht_caps[1] = DOT11F_IE_HTCAPS_MIN_LEN;
5903 lim_set_ht_caps(mac_ctx, session, ht_caps,
5904 DOT11F_IE_HTCAPS_MIN_LEN + 2);
5905 /* Get LDPC and over write for 2G */
5906 p_ht_cap->advCodingCap = lim_get_rx_ldpc(mac_ctx, CHAN_ENUM_6);
Naveen Rawat1620ecb2016-10-10 15:25:50 -07005907 /* Get self cap for HT40 support in 2G */
5908 if (mac_ctx->roam.configParam.channelBondingMode24GHz) {
5909 p_ht_cap->supportedChannelWidthSet = 1;
5910 p_ht_cap->shortGI40MHz = 1;
5911 } else {
5912 p_ht_cap->supportedChannelWidthSet = 0;
5913 p_ht_cap->shortGI40MHz = 0;
5914 }
gaurank kathpaliab414bce2018-11-09 18:44:46 +05305915 lim_populate_mcs_set_ht_per_vdev(mac_ctx, p_ht_cap, vdev_id,
5916 NSS_CHAINS_BAND_2GHZ);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005917 lim_send_ie(mac_ctx, vdev_id, DOT11F_EID_HTCAPS,
5918 CDS_BAND_2GHZ, &ht_caps[2], DOT11F_IE_HTCAPS_MIN_LEN);
5919 /*
5920 * Get LDPC and over write for 5G - using channel 64 because it
5921 * is available in all reg domains.
5922 */
5923 p_ht_cap->advCodingCap = lim_get_rx_ldpc(mac_ctx, CHAN_ENUM_64);
Naveen Rawat1620ecb2016-10-10 15:25:50 -07005924 /* Get self cap for HT40 support in 5G */
5925 if (mac_ctx->roam.configParam.channelBondingMode5GHz) {
5926 p_ht_cap->supportedChannelWidthSet = 1;
5927 p_ht_cap->shortGI40MHz = 1;
5928 } else {
5929 p_ht_cap->supportedChannelWidthSet = 0;
5930 p_ht_cap->shortGI40MHz = 0;
5931 }
gaurank kathpaliab414bce2018-11-09 18:44:46 +05305932 lim_populate_mcs_set_ht_per_vdev(mac_ctx, p_ht_cap, vdev_id,
5933 NSS_CHAINS_BAND_5GHZ);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005934 lim_send_ie(mac_ctx, vdev_id, DOT11F_EID_HTCAPS,
5935 CDS_BAND_5GHZ, &ht_caps[2], DOT11F_IE_HTCAPS_MIN_LEN);
Naveen Rawat03e8d952016-08-01 15:22:20 -07005936
Naveen Rawata410c5a2016-09-19 14:22:33 -07005937 vht_caps[0] = DOT11F_EID_VHTCAPS;
5938 vht_caps[1] = DOT11F_IE_VHTCAPS_MAX_LEN;
Naveen Rawata410c5a2016-09-19 14:22:33 -07005939 lim_set_vht_caps(mac_ctx, session, vht_caps,
5940 DOT11F_IE_VHTCAPS_MIN_LEN + 2);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005941 /*
5942 * Get LDPC and over write for 5G - using channel 64 because it
5943 * is available in all reg domains.
5944 */
5945 p_vht_cap->ldpcCodingCap = lim_get_rx_ldpc(mac_ctx, CHAN_ENUM_64);
gaurank kathpaliaad980492018-10-31 19:22:30 +05305946 lim_populate_mcs_set_vht_per_vdev(mac_ctx, vht_caps,
gaurank kathpaliab414bce2018-11-09 18:44:46 +05305947 vdev_id, NSS_CHAINS_BAND_5GHZ);
gaurank kathpaliaad980492018-10-31 19:22:30 +05305948
Naveen Rawat1620ecb2016-10-10 15:25:50 -07005949 /* Self VHT channel width for 5G is already negotiated with FW */
Naveen Rawata410c5a2016-09-19 14:22:33 -07005950 lim_send_ie(mac_ctx, vdev_id, DOT11F_EID_VHTCAPS,
5951 CDS_BAND_5GHZ, &vht_caps[2], DOT11F_IE_VHTCAPS_MIN_LEN);
Naveen Rawat03e8d952016-08-01 15:22:20 -07005952
Naveen Rawat2347f9d2016-11-21 12:55:12 -08005953 /* Get LDPC and over write for 2G */
5954 p_vht_cap->ldpcCodingCap = lim_get_rx_ldpc(mac_ctx, CHAN_ENUM_6);
5955 /* Self VHT 80/160/80+80 channel width for 2G is 0 */
5956 p_vht_cap->supportedChannelWidthSet = 0;
5957 p_vht_cap->shortGI80MHz = 0;
5958 p_vht_cap->shortGI160and80plus80MHz = 0;
gaurank kathpaliaad980492018-10-31 19:22:30 +05305959 lim_populate_mcs_set_vht_per_vdev(mac_ctx, vht_caps,
gaurank kathpaliab414bce2018-11-09 18:44:46 +05305960 vdev_id, NSS_CHAINS_BAND_2GHZ);
Naveen Rawat2347f9d2016-11-21 12:55:12 -08005961 lim_send_ie(mac_ctx, vdev_id, DOT11F_EID_VHTCAPS,
5962 CDS_BAND_2GHZ, &vht_caps[2], DOT11F_IE_VHTCAPS_MIN_LEN);
5963
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08005964 status = lim_send_he_caps_ie(mac_ctx, session, vdev_id);
5965
5966 return status;
Naveen Rawat03e8d952016-08-01 15:22:20 -07005967}
5968
5969/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005970 * lim_send_ext_cap_ie() - send ext cap IE to FW
5971 * @mac_ctx: global MAC context
5972 * @session_entry: PE session
5973 * @extra_extcap: extracted ext cap
5974 * @merge: merge extra ext cap
5975 *
5976 * This function is invoked after VDEV is created to update firmware
5977 * about the extended capabilities that the corresponding VDEV is capable
5978 * of. Since STA/SAP can have different Extended capabilities set, this function
5979 * is called per vdev creation.
5980 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305981 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005982 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005983QDF_STATUS lim_send_ext_cap_ie(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005984 uint32_t session_id,
5985 tDot11fIEExtCap *extra_extcap, bool merge)
5986{
5987 tDot11fIEExtCap ext_cap_data = {0};
5988 uint32_t dot11mode, num_bytes;
5989 bool vht_enabled = false;
5990 struct vdev_ie_info *vdev_ie;
Rajeev Kumarf7d84422017-01-21 15:45:44 -08005991 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005992 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005993
5994 wlan_cfg_get_int(mac_ctx, WNI_CFG_DOT11_MODE, &dot11mode);
5995 if (IS_DOT11_MODE_VHT(dot11mode))
5996 vht_enabled = true;
5997
5998 status = populate_dot11f_ext_cap(mac_ctx, vht_enabled, &ext_cap_data,
5999 NULL);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006000 if (QDF_STATUS_SUCCESS != status) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306001 pe_err("Failed to populate ext cap IE");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306002 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006003 }
6004
6005 num_bytes = ext_cap_data.num_bytes;
6006
6007 if (merge && NULL != extra_extcap && extra_extcap->num_bytes > 0) {
6008 if (extra_extcap->num_bytes > ext_cap_data.num_bytes)
6009 num_bytes = extra_extcap->num_bytes;
Hu Wangfbd279d2016-10-31 18:24:34 +08006010 lim_merge_extcap_struct(&ext_cap_data, extra_extcap, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006011 }
6012
6013 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306014 vdev_ie = qdf_mem_malloc(sizeof(*vdev_ie) + num_bytes);
Arif Hussainf5b6c412018-10-10 19:41:09 -07006015 if (!vdev_ie)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306016 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006017
6018 vdev_ie->vdev_id = session_id;
6019 vdev_ie->ie_id = DOT11F_EID_EXTCAP;
6020 vdev_ie->length = num_bytes;
Naveen Rawat03e8d952016-08-01 15:22:20 -07006021 vdev_ie->band = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006022
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006023 vdev_ie->data = (uint8_t *)vdev_ie + sizeof(*vdev_ie);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306024 qdf_mem_copy(vdev_ie->data, ext_cap_data.bytes, num_bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006025
6026 msg.type = WMA_SET_IE_INFO;
6027 msg.bodyptr = vdev_ie;
6028 msg.reserved = 0;
6029
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306030 if (QDF_STATUS_SUCCESS !=
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05306031 scheduler_post_message(QDF_MODULE_ID_PE,
6032 QDF_MODULE_ID_WMA,
6033 QDF_MODULE_ID_WMA, &msg)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306034 pe_err("Not able to post WMA_SET_IE_INFO to WDA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306035 qdf_mem_free(vdev_ie);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306036 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006037 }
6038
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306039 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006040}
6041
6042/**
Naveen Rawat30b84502016-10-13 17:44:48 -07006043 * lim_strip_ie() - strip requested IE from IE buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006044 * @mac_ctx: global MAC context
6045 * @addn_ie: Additional IE buffer
6046 * @addn_ielen: Length of additional IE
Naveen Rawat30b84502016-10-13 17:44:48 -07006047 * @eid: EID of IE to strip
Jeff Johnsonfe8e9492018-05-06 15:40:52 -07006048 * @size_of_len_field: length of IE length field
Naveen Rawat30b84502016-10-13 17:44:48 -07006049 * @oui: if present matches OUI also
6050 * @oui_length: if previous present, this is length of oui
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006051 * @extracted_ie: if not NULL, copy the stripped IE to this buffer
6052 *
Naveen Rawat30b84502016-10-13 17:44:48 -07006053 * This utility function is used to strip of the requested IE if present
6054 * in IE buffer.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006055 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006056 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006057 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08006058QDF_STATUS lim_strip_ie(struct mac_context *mac_ctx,
Naveen Rawat30b84502016-10-13 17:44:48 -07006059 uint8_t *addn_ie, uint16_t *addn_ielen,
6060 uint8_t eid, eSizeOfLenField size_of_len_field,
Arif Hussain6cec6bc2017-02-14 13:46:26 -08006061 uint8_t *oui, uint8_t oui_length, uint8_t *extracted_ie,
6062 uint32_t eid_max_len)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006063{
6064 uint8_t *tempbuf = NULL;
6065 uint16_t templen = 0;
6066 int left = *addn_ielen;
6067 uint8_t *ptr = addn_ie;
Naveen Rawat30b84502016-10-13 17:44:48 -07006068 uint8_t elem_id;
6069 uint16_t elem_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006070
6071 if (NULL == addn_ie) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05306072 pe_debug("NULL addn_ie pointer");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006073 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006074 }
6075
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306076 tempbuf = qdf_mem_malloc(left);
Arif Hussainf5b6c412018-10-10 19:41:09 -07006077 if (!tempbuf)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006078 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006079
6080 while (left >= 2) {
6081 elem_id = ptr[0];
Naveen Rawat30b84502016-10-13 17:44:48 -07006082 left -= 1;
6083 if (size_of_len_field == TWO_BYTE) {
6084 elem_len = *((uint16_t *)&ptr[1]);
6085 left -= 2;
6086 } else {
6087 elem_len = ptr[1];
6088 left -= 1;
6089 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006090 if (elem_len > left) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306091 pe_err("Invalid IEs eid: %d elem_len: %d left: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006092 elem_id, elem_len, left);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306093 qdf_mem_free(tempbuf);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006094 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006095 }
Naveen Rawat30b84502016-10-13 17:44:48 -07006096
6097 if (eid != elem_id ||
6098 (oui && qdf_mem_cmp(oui,
6099 &ptr[size_of_len_field + 1],
6100 oui_length))) {
6101 qdf_mem_copy(tempbuf + templen, &ptr[0],
6102 elem_len + size_of_len_field + 1);
6103 templen += (elem_len + size_of_len_field + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006104 } else {
Naveen Rawat30b84502016-10-13 17:44:48 -07006105 /*
6106 * eid matched and if provided OUI also matched
6107 * take oui IE and store in provided buffer.
6108 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006109 if (NULL != extracted_ie) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306110 qdf_mem_set(extracted_ie,
Arif Hussain6cec6bc2017-02-14 13:46:26 -08006111 eid_max_len + size_of_len_field + 1,
6112 0);
6113 if (elem_len <= eid_max_len)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306114 qdf_mem_copy(extracted_ie, &ptr[0],
Arif Hussain6cec6bc2017-02-14 13:46:26 -08006115 elem_len + size_of_len_field + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006116 }
6117 }
6118 left -= elem_len;
Naveen Rawat30b84502016-10-13 17:44:48 -07006119 ptr += (elem_len + size_of_len_field + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006120 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306121 qdf_mem_copy(addn_ie, tempbuf, templen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006122
6123 *addn_ielen = templen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306124 qdf_mem_free(tempbuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006125
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006126 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006127}
6128
Krunal Sonid3c86d42017-10-19 12:12:21 -07006129#ifdef WLAN_FEATURE_11W
Jeff Johnsond01da6b2018-12-02 12:10:22 -08006130void lim_del_pmf_sa_query_timer(struct mac_context *mac_ctx, struct pe_session *pe_session)
Krunal Sonid3c86d42017-10-19 12:12:21 -07006131{
6132 uint32_t associated_sta;
6133 tpDphHashNode sta_ds = NULL;
6134
6135 for (associated_sta = 1;
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05306136 associated_sta <
6137 mac_ctx->mlme_cfg->sap_cfg.assoc_sta_limit;
Krunal Sonid3c86d42017-10-19 12:12:21 -07006138 associated_sta++) {
6139 sta_ds = dph_get_hash_entry(mac_ctx, associated_sta,
6140 &pe_session->dph.dphHashTable);
6141 if (NULL == sta_ds)
6142 continue;
Krunal Sonia59e8a42017-11-19 09:00:56 -08006143 if (!sta_ds->rmfEnabled) {
6144 pe_debug("no PMF timer for sta-idx:%d assoc-id:%d",
6145 sta_ds->staIndex, sta_ds->assocId);
6146 continue;
6147 }
Krunal Sonid3c86d42017-10-19 12:12:21 -07006148
Krunal Sonia59e8a42017-11-19 09:00:56 -08006149 pe_debug("Deleting pmfSaQueryTimer for sta-idx:%d assoc-id:%d",
6150 sta_ds->staIndex, sta_ds->assocId);
Krunal Sonid3c86d42017-10-19 12:12:21 -07006151 tx_timer_deactivate(&sta_ds->pmfSaQueryTimer);
6152 tx_timer_delete(&sta_ds->pmfSaQueryTimer);
6153 }
6154}
6155#endif
6156
Jeff Johnsond01da6b2018-12-02 12:10:22 -08006157QDF_STATUS lim_strip_supp_op_class_update_struct(struct mac_context *mac_ctx,
Arif Hussain6cec6bc2017-02-14 13:46:26 -08006158 uint8_t *addn_ie, uint16_t *addn_ielen,
6159 tDot11fIESuppOperatingClasses *dst)
6160{
6161 uint8_t extracted_buff[DOT11F_IE_SUPPOPERATINGCLASSES_MAX_LEN + 2];
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006162 QDF_STATUS status;
Arif Hussain6cec6bc2017-02-14 13:46:26 -08006163
6164 qdf_mem_set((uint8_t *)&extracted_buff[0],
6165 DOT11F_IE_SUPPOPERATINGCLASSES_MAX_LEN + 2,
6166 0);
6167 status = lim_strip_ie(mac_ctx, addn_ie, addn_ielen,
6168 DOT11F_EID_SUPPOPERATINGCLASSES, ONE_BYTE,
6169 NULL, 0, extracted_buff,
6170 DOT11F_IE_SUPPOPERATINGCLASSES_MAX_LEN);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006171 if (QDF_STATUS_SUCCESS != status) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306172 pe_warn("Failed to strip supp_op_mode IE status: %d",
Arif Hussain6cec6bc2017-02-14 13:46:26 -08006173 status);
6174 return status;
6175 }
6176
6177 if (DOT11F_EID_SUPPOPERATINGCLASSES != extracted_buff[0] ||
6178 extracted_buff[1] > DOT11F_IE_SUPPOPERATINGCLASSES_MAX_LEN) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306179 pe_warn("Invalid IEs eid: %d elem_len: %d",
Arif Hussain6cec6bc2017-02-14 13:46:26 -08006180 extracted_buff[0], extracted_buff[1]);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006181 return QDF_STATUS_E_FAILURE;
Arif Hussain6cec6bc2017-02-14 13:46:26 -08006182 }
6183
6184 /* update the extracted supp op class to struct*/
6185 if (DOT11F_PARSE_SUCCESS != dot11f_unpack_ie_supp_operating_classes(
Selvaraj, Sridhar75afbeb2017-04-03 17:08:59 +05306186 mac_ctx, &extracted_buff[2], extracted_buff[1], dst, false)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306187 pe_err("dot11f_unpack Parse Error");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006188 return QDF_STATUS_E_FAILURE;
Arif Hussain6cec6bc2017-02-14 13:46:26 -08006189 }
6190
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006191 return QDF_STATUS_SUCCESS;
Arif Hussain6cec6bc2017-02-14 13:46:26 -08006192}
6193
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006194/**
6195 * lim_update_extcap_struct() - poputlate the dot11f structure
6196 * @mac_ctx: global MAC context
6197 * @buf: extracted IE buffer
6198 * @dst: extended capability IE structure to be updated
6199 *
6200 * This function is used to update the extended capability structure
6201 * with @buf.
6202 *
6203 * Return: None
6204 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08006205void lim_update_extcap_struct(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006206 uint8_t *buf, tDot11fIEExtCap *dst)
6207{
6208 uint8_t out[DOT11F_IE_EXTCAP_MAX_LEN];
Padma, Santhosh Kumar92234472017-04-19 18:20:02 +05306209 uint32_t status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006210
6211 if (NULL == buf) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306212 pe_err("Invalid Buffer Address");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006213 return;
6214 }
6215
6216 if (NULL == dst) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306217 pe_err("NULL dst pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006218 return;
6219 }
6220
6221 if (DOT11F_EID_EXTCAP != buf[0] || buf[1] > DOT11F_IE_EXTCAP_MAX_LEN) {
Dustin Brown897dae42018-03-13 17:08:47 -07006222 pe_debug_rl("Invalid IEs eid: %d elem_len: %d", buf[0], buf[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006223 return;
6224 }
6225
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306226 qdf_mem_set((uint8_t *)&out[0], DOT11F_IE_EXTCAP_MAX_LEN, 0);
Hu Wang411e0cc2016-10-28 14:56:01 +08006227 qdf_mem_copy(&out[0], &buf[2], buf[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006228
Padma, Santhosh Kumar92234472017-04-19 18:20:02 +05306229 status = dot11f_unpack_ie_ext_cap(mac_ctx, &out[0],
6230 buf[1], dst, false);
6231 if (DOT11F_PARSE_SUCCESS != status)
6232 pe_err("dot11f_unpack Parse Error %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006233}
6234
6235/**
6236 * lim_strip_extcap_update_struct - strip extended capability IE and populate
6237 * the dot11f structure
6238 * @mac_ctx: global MAC context
6239 * @addn_ie: Additional IE buffer
6240 * @addn_ielen: Length of additional IE
6241 * @dst: extended capability IE structure to be updated
6242 *
6243 * This function is used to strip extended capability IE from IE buffer and
6244 * update the passed structure.
6245 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006246 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006247 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08006248QDF_STATUS lim_strip_extcap_update_struct(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006249 uint8_t *addn_ie, uint16_t *addn_ielen, tDot11fIEExtCap *dst)
6250{
6251 uint8_t extracted_buff[DOT11F_IE_EXTCAP_MAX_LEN + 2];
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006252 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006253
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306254 qdf_mem_set((uint8_t *)&extracted_buff[0], DOT11F_IE_EXTCAP_MAX_LEN + 2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006255 0);
Naveen Rawat30b84502016-10-13 17:44:48 -07006256 status = lim_strip_ie(mac_ctx, addn_ie, addn_ielen,
6257 DOT11F_EID_EXTCAP, ONE_BYTE,
Arif Hussain6cec6bc2017-02-14 13:46:26 -08006258 NULL, 0, extracted_buff,
6259 DOT11F_IE_EXTCAP_MAX_LEN);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006260 if (QDF_STATUS_SUCCESS != status) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05306261 pe_debug("Failed to strip extcap IE status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006262 return status;
6263 }
6264
6265 /* update the extracted ExtCap to struct*/
6266 lim_update_extcap_struct(mac_ctx, extracted_buff, dst);
6267 return status;
6268}
6269
6270/**
6271 * lim_merge_extcap_struct() - merge extended capabilities info
6272 * @dst: destination extended capabilities
6273 * @src: source extended capabilities
Jeff Johnson118a4a02018-05-06 00:14:15 -07006274 * @add: true if add the capabilities, false if strip the capabilities.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006275 *
Hu Wangfbd279d2016-10-31 18:24:34 +08006276 * This function is used to take @src info and add/strip it to/from
6277 * @dst extended capabilities info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006278 *
6279 * Return: None
6280 */
6281void lim_merge_extcap_struct(tDot11fIEExtCap *dst,
Hu Wangfbd279d2016-10-31 18:24:34 +08006282 tDot11fIEExtCap *src,
6283 bool add)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006284{
6285 uint8_t *tempdst = (uint8_t *)dst->bytes;
6286 uint8_t *tempsrc = (uint8_t *)src->bytes;
6287 uint8_t structlen = member_size(tDot11fIEExtCap, bytes);
6288
Hu Wangfbd279d2016-10-31 18:24:34 +08006289 /* Return if @src not present */
6290 if (!src->present)
6291 return;
6292
Jeff Johnson118a4a02018-05-06 00:14:15 -07006293 /* Return if strip the capabilities from @dst which not present */
Hu Wangfbd279d2016-10-31 18:24:34 +08006294 if (!dst->present && !add)
6295 return;
6296
Jeff Johnson118a4a02018-05-06 00:14:15 -07006297 /* Merge the capabilities info in other cases */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006298 while (tempdst && tempsrc && structlen--) {
Hu Wangfbd279d2016-10-31 18:24:34 +08006299 if (add)
6300 *tempdst |= *tempsrc;
6301 else
6302 *tempdst &= *tempsrc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006303 tempdst++;
6304 tempsrc++;
6305 }
Hu Wang411e0cc2016-10-28 14:56:01 +08006306 dst->num_bytes = lim_compute_ext_cap_ie_length(dst);
Hu Wangfbd279d2016-10-31 18:24:34 +08006307 if (dst->num_bytes == 0)
6308 dst->present = 0;
6309 else
6310 dst->present = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006311}
6312
Naveen Rawatc0c91cd2015-11-05 14:27:37 -08006313/**
Kiran Kumar Lokereee205772018-09-27 00:27:27 -07006314 * lim_send_action_frm_tb_ppdu_cfg_flush_cb() - flush TB PPDU cfg msg
6315 * @msg: Message pointer
6316 *
6317 * Flushes the send action frame in HE TB PPDU configuration message.
6318 *
6319 * Return: None
6320 */
6321static void lim_send_action_frm_tb_ppdu_cfg_flush_cb(struct scheduler_msg *msg)
6322{
6323 if (msg->bodyptr) {
6324 qdf_mem_free(msg->bodyptr);
6325 msg->bodyptr = NULL;
6326 }
6327}
6328
6329/**
6330 * lim_send_action_frm_tb_ppdu_cfg() - sets action frame in TB PPDU cfg to FW
6331 * @mac_ctx: global MAC context
6332 * @session_id: SME session id
6333 * @cfg: config setting
6334 *
6335 * Preapres the vendor action frame and send action frame in HE TB PPDU
6336 * configuration to FW.
6337 *
6338 * Return: QDF_STATUS
6339 */
6340QDF_STATUS lim_send_action_frm_tb_ppdu_cfg(struct mac_context *mac_ctx,
6341 uint32_t session_id,
6342 uint8_t cfg)
6343{
6344 tDot11fvendor_action_frame *frm;
6345 uint8_t frm_len = sizeof(*frm);
Jeff Johnsonc8baa902018-11-18 21:59:07 -08006346 struct pe_session *session;
Kiran Kumar Lokereee205772018-09-27 00:27:27 -07006347 struct cfg_action_frm_tb_ppdu *cfg_msg;
6348 struct scheduler_msg msg = {0};
6349 uint8_t *data_buf;
6350
6351 session = pe_find_session_by_sme_session_id(mac_ctx, session_id);
6352
6353 if (!session) {
6354 pe_err("pe session does not exist for sme session id %d",
6355 session_id);
6356 return QDF_STATUS_E_FAILURE;
6357 }
6358
6359 data_buf = qdf_mem_malloc(frm_len + sizeof(*cfg_msg));
6360 if (!data_buf)
6361 return QDF_STATUS_E_FAILURE;
6362
6363 cfg_msg = (struct cfg_action_frm_tb_ppdu *)data_buf;
6364
6365 frm = (tDot11fvendor_action_frame *)(data_buf + sizeof(*cfg_msg));
6366
6367 frm->Category.category = SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY;
6368
6369 frm->vendor_oui.oui_data[0] = 0x00;
6370 frm->vendor_oui.oui_data[1] = 0xA0;
6371 frm->vendor_oui.oui_data[2] = 0xC6;
6372
6373 frm->vendor_action_subtype.subtype = 0xFF;
6374
6375 cfg_msg->vdev_id = session_id;
6376 cfg_msg->cfg = cfg;
6377 cfg_msg->frm_len = frm_len;
6378 cfg_msg->data = (uint8_t *)frm;
6379
6380 msg.type = WMA_CFG_VENDOR_ACTION_TB_PPDU;
6381 msg.bodyptr = cfg_msg;
6382 msg.reserved = 0;
6383 msg.flush_callback = lim_send_action_frm_tb_ppdu_cfg_flush_cb;
6384
6385 if (QDF_STATUS_SUCCESS !=
6386 scheduler_post_message(QDF_MODULE_ID_PE,
6387 QDF_MODULE_ID_WMA,
6388 QDF_MODULE_ID_WMA, &msg)) {
6389 pe_err("Not able to post WMA_SET_IE_INFO to WDA");
6390 qdf_mem_free(data_buf);
6391 return QDF_STATUS_E_FAILURE;
6392 }
6393
6394 return QDF_STATUS_SUCCESS;
6395}
6396
6397/**
Naveen Rawatc0c91cd2015-11-05 14:27:37 -08006398 * lim_get_80Mhz_center_channel - finds 80 Mhz center channel
6399 *
6400 * @primary_channel: Primary channel for given 80 MHz band
6401 *
6402 * There are fixed 80MHz band and for each fixed band there is only one center
6403 * valid channel. Also location of primary channel decides what 80 MHz band will
6404 * it use, hence it decides what center channel will be used. This function
6405 * does thus calculation and returns the center channel.
6406 *
6407 * Return: center channel
6408 */
6409uint8_t
6410lim_get_80Mhz_center_channel(uint8_t primary_channel)
6411{
6412 if (primary_channel >= 36 && primary_channel <= 48)
6413 return (36+48)/2;
6414 if (primary_channel >= 52 && primary_channel <= 64)
6415 return (52+64)/2;
6416 if (primary_channel >= 100 && primary_channel <= 112)
6417 return (100+112)/2;
6418 if (primary_channel >= 116 && primary_channel <= 128)
6419 return (116+128)/2;
6420 if (primary_channel >= 132 && primary_channel <= 144)
6421 return (132+144)/2;
6422 if (primary_channel >= 149 && primary_channel <= 161)
6423 return (149+161)/2;
6424
6425 return INVALID_CHANNEL_ID;
6426}
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05306427
6428/**
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05306429 * lim_bss_type_to_string(): converts bss type enum to string.
6430 * @bss_type: enum value of bss_type.
6431 *
6432 * Return: Printable string for bss_type
6433 */
6434const char *lim_bss_type_to_string(const uint16_t bss_type)
6435{
6436 switch (bss_type) {
6437 CASE_RETURN_STRING(eSIR_INFRASTRUCTURE_MODE);
6438 CASE_RETURN_STRING(eSIR_INFRA_AP_MODE);
6439 CASE_RETURN_STRING(eSIR_IBSS_MODE);
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05306440 CASE_RETURN_STRING(eSIR_AUTO_MODE);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07006441 CASE_RETURN_STRING(eSIR_NDI_MODE);
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05306442 default:
6443 return "Unknown bss_type";
6444 }
6445}
Sandeep Puligillae0875662016-02-12 16:09:21 -08006446
6447/**
6448 * lim_init_obss_params(): Initializes the OBSS Scan Parameters
6449 * @sesssion: LIM session
6450 * @mac_ctx: Mac context
6451 *
6452 * Return: None
6453 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08006454void lim_init_obss_params(struct mac_context *mac_ctx, struct pe_session *session)
Sandeep Puligillae0875662016-02-12 16:09:21 -08006455{
Wu Gaod8f3db02018-07-24 19:18:45 +08006456 struct wlan_mlme_obss_ht40 *obss_ht40;
Sandeep Puligillae0875662016-02-12 16:09:21 -08006457
Wu Gaod8f3db02018-07-24 19:18:45 +08006458 if (!(mac_ctx->mlme_cfg)) {
6459 pe_err("invalid mlme cfg");
Sandeep Puligillae0875662016-02-12 16:09:21 -08006460 return;
6461 }
Sandeep Puligillae0875662016-02-12 16:09:21 -08006462
Wu Gaod8f3db02018-07-24 19:18:45 +08006463 obss_ht40 = &mac_ctx->mlme_cfg->obss_ht40;
Sandeep Puligillae0875662016-02-12 16:09:21 -08006464
Wu Gaod8f3db02018-07-24 19:18:45 +08006465 session->obss_ht40_scanparam.obss_active_dwelltime =
6466 obss_ht40->active_dwelltime;
Sandeep Puligillae0875662016-02-12 16:09:21 -08006467
Wu Gaod8f3db02018-07-24 19:18:45 +08006468 session->obss_ht40_scanparam.obss_passive_dwelltime =
6469 obss_ht40->passive_dwelltime;
6470
6471 session->obss_ht40_scanparam.obss_width_trigger_interval =
6472 obss_ht40->width_trigger_interval;
6473
6474 session->obss_ht40_scanparam.obss_active_total_per_channel =
6475 obss_ht40->active_per_channel;
6476
6477 session->obss_ht40_scanparam.obss_passive_total_per_channel =
6478 obss_ht40->passive_per_channel;
6479
Sandeep Puligillae0875662016-02-12 16:09:21 -08006480 session->obss_ht40_scanparam.bsswidth_ch_trans_delay =
Wu Gaod8f3db02018-07-24 19:18:45 +08006481 obss_ht40->width_trans_delay;
Sandeep Puligillae0875662016-02-12 16:09:21 -08006482
Wu Gaod8f3db02018-07-24 19:18:45 +08006483 session->obss_ht40_scanparam.obss_activity_threshold =
6484 obss_ht40->scan_activity_threshold;
Sandeep Puligillae0875662016-02-12 16:09:21 -08006485}
6486
6487/**
6488 * lim_update_obss_scanparams(): Updates OBSS SCAN IE parameters to session
6489 * @sesssion: LIM session
6490 * @scan_params: Scan parameters
6491 *
6492 * Return: None
6493 */
Jeff Johnsonc8baa902018-11-18 21:59:07 -08006494void lim_update_obss_scanparams(struct pe_session *session,
Sandeep Puligillae0875662016-02-12 16:09:21 -08006495 tDot11fIEOBSSScanParameters *scan_params)
6496{
6497 /*
Jeff Johnson4ceed382018-05-06 16:24:57 -07006498 * If the received value is not in the range specified
Sandeep Puligillae0875662016-02-12 16:09:21 -08006499 * by the Specification then it will be the default value
6500 * configured through cfg
6501 */
6502 if ((scan_params->obssScanActiveDwell >
Wu Gaod8f3db02018-07-24 19:18:45 +08006503 cfg_min(CFG_OBSS_HT40_SCAN_ACTIVE_DWELL_TIME)) &&
Sandeep Puligillae0875662016-02-12 16:09:21 -08006504 (scan_params->obssScanActiveDwell <
Wu Gaod8f3db02018-07-24 19:18:45 +08006505 cfg_max(CFG_OBSS_HT40_SCAN_ACTIVE_DWELL_TIME)))
Sandeep Puligillae0875662016-02-12 16:09:21 -08006506 session->obss_ht40_scanparam.obss_active_dwelltime =
6507 scan_params->obssScanActiveDwell;
6508
6509 if ((scan_params->obssScanPassiveDwell >
Wu Gaod8f3db02018-07-24 19:18:45 +08006510 cfg_min(CFG_OBSS_HT40_SCAN_PASSIVE_DWELL_TIME)) &&
Sandeep Puligillae0875662016-02-12 16:09:21 -08006511 (scan_params->obssScanPassiveDwell <
Wu Gaod8f3db02018-07-24 19:18:45 +08006512 cfg_max(CFG_OBSS_HT40_SCAN_PASSIVE_DWELL_TIME)))
Will Huang1655c222018-05-14 15:27:56 +08006513 session->obss_ht40_scanparam.obss_passive_dwelltime =
Sandeep Puligillae0875662016-02-12 16:09:21 -08006514 scan_params->obssScanPassiveDwell;
6515
6516 if ((scan_params->bssWidthChannelTransitionDelayFactor >
Wu Gaod8f3db02018-07-24 19:18:45 +08006517 cfg_min(CFG_OBSS_HT40_WIDTH_CH_TRANSITION_DELAY)) &&
Sandeep Puligillae0875662016-02-12 16:09:21 -08006518 (scan_params->bssWidthChannelTransitionDelayFactor <
Wu Gaod8f3db02018-07-24 19:18:45 +08006519 cfg_max(CFG_OBSS_HT40_WIDTH_CH_TRANSITION_DELAY)))
Sandeep Puligillae0875662016-02-12 16:09:21 -08006520 session->obss_ht40_scanparam.bsswidth_ch_trans_delay =
6521 scan_params->bssWidthChannelTransitionDelayFactor;
6522
6523 if ((scan_params->obssScanActiveTotalPerChannel >
Wu Gaod8f3db02018-07-24 19:18:45 +08006524 cfg_min(CFG_OBSS_HT40_SCAN_ACTIVE_TOTAL_PER_CHANNEL)) &&
Sandeep Puligillae0875662016-02-12 16:09:21 -08006525 (scan_params->obssScanActiveTotalPerChannel <
Wu Gaod8f3db02018-07-24 19:18:45 +08006526 cfg_max(CFG_OBSS_HT40_SCAN_ACTIVE_TOTAL_PER_CHANNEL)))
Sandeep Puligillae0875662016-02-12 16:09:21 -08006527 session->obss_ht40_scanparam.obss_active_total_per_channel =
6528 scan_params->obssScanActiveTotalPerChannel;
6529
6530 if ((scan_params->obssScanPassiveTotalPerChannel >
Wu Gaod8f3db02018-07-24 19:18:45 +08006531 cfg_min(CFG_OBSS_HT40_SCAN_PASSIVE_TOTAL_PER_CHANNEL)) &&
Sandeep Puligillae0875662016-02-12 16:09:21 -08006532 (scan_params->obssScanPassiveTotalPerChannel <
Wu Gaod8f3db02018-07-24 19:18:45 +08006533 cfg_max(CFG_OBSS_HT40_SCAN_PASSIVE_TOTAL_PER_CHANNEL)))
Sandeep Puligillae0875662016-02-12 16:09:21 -08006534 session->obss_ht40_scanparam.obss_passive_total_per_channel =
6535 scan_params->obssScanPassiveTotalPerChannel;
6536
6537 if ((scan_params->bssChannelWidthTriggerScanInterval >
Wu Gaod8f3db02018-07-24 19:18:45 +08006538 cfg_min(CFG_OBSS_HT40_SCAN_WIDTH_TRIGGER_INTERVAL)) &&
Sandeep Puligillae0875662016-02-12 16:09:21 -08006539 (scan_params->bssChannelWidthTriggerScanInterval <
Wu Gaod8f3db02018-07-24 19:18:45 +08006540 cfg_max(CFG_OBSS_HT40_SCAN_WIDTH_TRIGGER_INTERVAL)))
Sandeep Puligillae0875662016-02-12 16:09:21 -08006541 session->obss_ht40_scanparam.obss_width_trigger_interval =
6542 scan_params->bssChannelWidthTriggerScanInterval;
6543
6544 if ((scan_params->obssScanActivityThreshold >
Wu Gaod8f3db02018-07-24 19:18:45 +08006545 cfg_min(CFG_OBSS_HT40_SCAN_ACTIVITY_THRESHOLD)) &&
Sandeep Puligillae0875662016-02-12 16:09:21 -08006546 (scan_params->obssScanActivityThreshold <
Wu Gaod8f3db02018-07-24 19:18:45 +08006547 cfg_max(CFG_OBSS_HT40_SCAN_ACTIVITY_THRESHOLD)))
Sandeep Puligillae0875662016-02-12 16:09:21 -08006548 session->obss_ht40_scanparam.obss_activity_threshold =
6549 scan_params->obssScanActivityThreshold;
6550 return;
6551}
Rajeev Kumar03200802016-04-15 13:59:36 -07006552
6553/**
6554 * lim_is_robust_mgmt_action_frame() - Check if action category is
6555 * robust action frame
6556 * @action_category: Action frame category.
6557 *
6558 * This function is used to check if given action category is robust
6559 * action frame.
6560 *
6561 * Return: bool
6562 */
6563bool lim_is_robust_mgmt_action_frame(uint8_t action_category)
6564{
6565 switch (action_category) {
6566 /*
6567 * NOTE: This function doesn't take care of the DMG
6568 * (Directional Multi-Gigatbit) BSS case as 8011ad
6569 * support is not yet added. In future, if the support
6570 * is required then this function need few more arguments
6571 * and little change in logic.
6572 */
6573 case SIR_MAC_ACTION_SPECTRUM_MGMT:
6574 case SIR_MAC_ACTION_QOS_MGMT:
6575 case SIR_MAC_ACTION_DLP:
6576 case SIR_MAC_ACTION_BLKACK:
6577 case SIR_MAC_ACTION_RRM:
6578 case SIR_MAC_ACTION_FAST_BSS_TRNST:
6579 case SIR_MAC_ACTION_SA_QUERY:
6580 case SIR_MAC_ACTION_PROT_DUAL_PUB:
6581 case SIR_MAC_ACTION_WNM:
6582 case SIR_MAC_ACITON_MESH:
6583 case SIR_MAC_ACTION_MHF:
6584 case SIR_MAC_ACTION_FST:
6585 return true;
6586 default:
Naveen Rawat170420a2017-12-21 14:33:55 -08006587 pe_debug("non-PMF action category: %d", action_category);
Rajeev Kumar03200802016-04-15 13:59:36 -07006588 break;
6589 }
6590 return false;
6591}
Kapil Guptac03eb072016-08-09 14:01:36 +05306592
6593/**
Hu Wang411e0cc2016-10-28 14:56:01 +08006594 * lim_compute_ext_cap_ie_length - compute the length of ext cap ie
6595 * based on the bits set
Kapil Guptac03eb072016-08-09 14:01:36 +05306596 * @ext_cap: extended IEs structure
6597 *
Hu Wang411e0cc2016-10-28 14:56:01 +08006598 * Return: length of the ext cap ie, 0 means should not present
Kapil Guptac03eb072016-08-09 14:01:36 +05306599 */
Hu Wang411e0cc2016-10-28 14:56:01 +08006600uint8_t lim_compute_ext_cap_ie_length(tDot11fIEExtCap *ext_cap)
Kapil Guptac03eb072016-08-09 14:01:36 +05306601{
Hu Wang411e0cc2016-10-28 14:56:01 +08006602 uint8_t i = DOT11F_IE_EXTCAP_MAX_LEN;
Kapil Guptac03eb072016-08-09 14:01:36 +05306603
Hu Wang411e0cc2016-10-28 14:56:01 +08006604 while (i) {
6605 if (ext_cap->bytes[i-1])
6606 break;
6607 i--;
6608 }
Kapil Guptac03eb072016-08-09 14:01:36 +05306609
Hu Wang411e0cc2016-10-28 14:56:01 +08006610 return i;
Kapil Guptac03eb072016-08-09 14:01:36 +05306611}
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05306612
6613/**
6614 * lim_update_caps_info_for_bss - Update capability info for this BSS
6615 *
6616 * @mac_ctx: mac context
6617 * @caps: Pointer to capability info to be updated
6618 * @bss_caps: Capability info of the BSS
6619 *
6620 * Update the capability info in Assoc/Reassoc request frames and reset
6621 * the spectrum management, short preamble, immediate block ack bits
6622 * if the BSS doesnot support it
6623 *
6624 * Return: None
6625 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08006626void lim_update_caps_info_for_bss(struct mac_context *mac_ctx,
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05306627 uint16_t *caps, uint16_t bss_caps)
6628{
6629 if (!(bss_caps & LIM_SPECTRUM_MANAGEMENT_BIT_MASK)) {
6630 *caps &= (~LIM_SPECTRUM_MANAGEMENT_BIT_MASK);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306631 pe_debug("Clearing spectrum management:no AP support");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05306632 }
6633
6634 if (!(bss_caps & LIM_SHORT_PREAMBLE_BIT_MASK)) {
6635 *caps &= (~LIM_SHORT_PREAMBLE_BIT_MASK);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306636 pe_debug("Clearing short preamble:no AP support");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05306637 }
6638
6639 if (!(bss_caps & LIM_IMMEDIATE_BLOCK_ACK_MASK)) {
6640 *caps &= (~LIM_IMMEDIATE_BLOCK_ACK_MASK);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306641 pe_debug("Clearing Immed Blk Ack:no AP support");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05306642 }
6643}
Kiran Kumar Lokere6d3a30d2018-01-15 18:18:29 -08006644/**
6645 * lim_send_set_dtim_period(): Send SIR_HAL_SET_DTIM_PERIOD message
6646 * to set dtim period.
6647 *
6648 * @sesssion: LIM session
6649 * @dtim_period: dtim value
6650 * @mac_ctx: Mac context
6651 * @return None
6652 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08006653void lim_send_set_dtim_period(struct mac_context *mac_ctx, uint8_t dtim_period,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08006654 struct pe_session *session)
Kiran Kumar Lokere6d3a30d2018-01-15 18:18:29 -08006655{
6656 struct set_dtim_params *dtim_params = NULL;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006657 QDF_STATUS ret = QDF_STATUS_SUCCESS;
Kiran Kumar Lokere6d3a30d2018-01-15 18:18:29 -08006658 struct scheduler_msg msg = {0};
6659
6660 if (!session) {
6661 pe_err("Inavalid parameters");
6662 return;
6663 }
6664 dtim_params = qdf_mem_malloc(sizeof(*dtim_params));
Arif Hussainf5b6c412018-10-10 19:41:09 -07006665 if (!dtim_params)
Kiran Kumar Lokere6d3a30d2018-01-15 18:18:29 -08006666 return;
Kiran Kumar Lokere6d3a30d2018-01-15 18:18:29 -08006667 dtim_params->dtim_period = dtim_period;
6668 dtim_params->session_id = session->smeSessionId;
6669 msg.type = WMA_SET_DTIM_PERIOD;
6670 msg.bodyptr = dtim_params;
6671 msg.bodyval = 0;
6672 pe_debug("Post WMA_SET_DTIM_PERIOD to WMA");
6673 ret = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006674 if (QDF_STATUS_SUCCESS != ret) {
Kiran Kumar Lokere6d3a30d2018-01-15 18:18:29 -08006675 pe_err("wma_post_ctrl_msg() failed");
6676 qdf_mem_free(dtim_params);
6677 }
6678}
Arif Hussain776ee7a2016-11-10 20:28:50 -08006679
6680/**
6681 * lim_is_valid_frame(): validate RX frame using last processed frame details
6682 * to find if it is duplicate frame.
6683 *
6684 * @last_processed_frm: last processed frame pointer.
6685 * @pRxPacketInfo: RX packet.
6686 *
6687 * Frame treat as duplicate:
6688 * if retry bit is set and
Jeff Johnson560dc562017-03-17 15:19:31 -07006689 * if source address and seq number matches with the last processed frame
Arif Hussain776ee7a2016-11-10 20:28:50 -08006690 *
6691 * Return: false if duplicate frame, else true.
6692 */
6693bool lim_is_valid_frame(last_processed_msg *last_processed_frm,
6694 uint8_t *pRxPacketInfo)
6695{
6696 uint16_t seq_num;
6697 tpSirMacMgmtHdr pHdr;
6698
6699 if (!pRxPacketInfo) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306700 pe_err("Invalid RX frame");
Arif Hussain776ee7a2016-11-10 20:28:50 -08006701 return false;
6702 }
6703
6704 pHdr = WMA_GET_RX_MAC_HEADER(pRxPacketInfo);
6705
6706 if (pHdr->fc.retry == 0)
6707 return true;
6708
6709 seq_num = (((pHdr->seqControl.seqNumHi <<
6710 HIGH_SEQ_NUM_OFFSET) |
6711 pHdr->seqControl.seqNumLo));
6712
6713 if (last_processed_frm->seq_num == seq_num &&
6714 qdf_mem_cmp(last_processed_frm->sa, pHdr->sa, ETH_ALEN) == 0) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306715 pe_err("Duplicate frame from "MAC_ADDRESS_STR " Seq Number %d",
Arif Hussain776ee7a2016-11-10 20:28:50 -08006716 MAC_ADDR_ARRAY(pHdr->sa), seq_num);
6717 return false;
6718 }
6719 return true;
6720}
6721
6722/**
6723 * lim_update_last_processed_frame(): update new processed frame info to cache.
6724 *
6725 * @last_processed_frm: last processed frame pointer.
6726 * @pRxPacketInfo: Successfully processed RX packet.
6727 *
6728 * Return: None.
6729 */
6730void lim_update_last_processed_frame(last_processed_msg *last_processed_frm,
6731 uint8_t *pRxPacketInfo)
6732{
6733 uint16_t seq_num;
6734 tpSirMacMgmtHdr pHdr;
6735
6736 if (!pRxPacketInfo) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306737 pe_err("Invalid RX frame");
Arif Hussain776ee7a2016-11-10 20:28:50 -08006738 return;
6739 }
6740
6741 pHdr = WMA_GET_RX_MAC_HEADER(pRxPacketInfo);
6742 seq_num = (((pHdr->seqControl.seqNumHi <<
6743 HIGH_SEQ_NUM_OFFSET) |
6744 pHdr->seqControl.seqNumLo));
6745
6746 qdf_mem_copy(last_processed_frm->sa, pHdr->sa, ETH_ALEN);
6747 last_processed_frm->seq_num = seq_num;
6748}
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006749
6750#ifdef WLAN_FEATURE_11AX
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006751void lim_add_he_cap(tpAddStaParams add_sta_params, tpSirAssocReq assoc_req)
6752{
6753 if (!add_sta_params->he_capable || !assoc_req)
6754 return;
6755
6756 qdf_mem_copy(&add_sta_params->he_config, &assoc_req->he_cap,
6757 sizeof(add_sta_params->he_config));
6758}
6759
Jeff Johnsonc8baa902018-11-18 21:59:07 -08006760void lim_add_self_he_cap(tpAddStaParams add_sta_params, struct pe_session *session)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006761{
6762 if (!session)
6763 return;
6764
6765 add_sta_params->he_capable = true;
6766
6767 qdf_mem_copy(&add_sta_params->he_config, &session->he_config,
6768 sizeof(add_sta_params->he_config));
6769 qdf_mem_copy(&add_sta_params->he_op, &session->he_op,
6770 sizeof(add_sta_params->he_op));
6771}
6772
6773/**
6774 * lim_intersect_he_caps() - Intersect peer capability and self capability
6775 * @rcvd_he: pointer to received peer capability
6776 * @session_he: pointer to self capability
6777 * @peer_he: pointer to Intersected capability
6778 *
6779 * Return: None
6780 */
Naveen Rawatd8feac12017-09-08 15:08:39 -07006781static void lim_intersect_he_caps(tDot11fIEhe_cap *rcvd_he,
6782 tDot11fIEhe_cap *session_he,
6783 tDot11fIEhe_cap *peer_he)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006784{
6785 uint8_t val;
6786
6787 qdf_mem_copy(peer_he, rcvd_he, sizeof(*peer_he));
6788
6789 peer_he->fragmentation &= session_he->fragmentation;
6790
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -08006791 if (session_he->tx_stbc_lt_80mhz && peer_he->rx_stbc_lt_80mhz)
6792 peer_he->rx_stbc_lt_80mhz = 1;
6793 else
6794 peer_he->rx_stbc_lt_80mhz = 0;
Naveen Rawat4051b022017-09-08 16:17:54 -07006795
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -08006796 if (session_he->rx_stbc_lt_80mhz && peer_he->tx_stbc_lt_80mhz)
6797 peer_he->tx_stbc_lt_80mhz = 1;
6798 else
6799 peer_he->tx_stbc_lt_80mhz = 0;
6800
6801 if (session_he->tx_stbc_gt_80mhz && peer_he->rx_stbc_gt_80mhz)
6802 peer_he->rx_stbc_gt_80mhz = 1;
6803 else
6804 peer_he->rx_stbc_gt_80mhz = 0;
6805
6806 if (session_he->rx_stbc_gt_80mhz && peer_he->tx_stbc_gt_80mhz)
6807 peer_he->tx_stbc_gt_80mhz = 1;
6808 else
6809 peer_he->tx_stbc_gt_80mhz = 0;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006810
6811 /* Tx Doppler is first bit and Rx Doppler is second bit */
6812 if (session_he->doppler) {
6813 val = 0;
Naveen Rawat4051b022017-09-08 16:17:54 -07006814 if ((session_he->doppler & 0x1) && (peer_he->doppler & 0x10))
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006815 val |= (1 << 1);
Naveen Rawat4051b022017-09-08 16:17:54 -07006816 if ((session_he->doppler & 0x10) && (peer_he->doppler & 0x1))
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006817 val |= (1 << 0);
6818 peer_he->doppler = val;
6819 }
6820
6821 peer_he->su_beamformer = session_he->su_beamformee ?
6822 peer_he->su_beamformer : 0;
6823 peer_he->su_beamformee = (session_he->su_beamformer ||
6824 session_he->mu_beamformer) ?
6825 peer_he->su_beamformee : 0;
6826 peer_he->mu_beamformer = session_he->su_beamformee ?
6827 peer_he->mu_beamformer : 0;
6828
6829 peer_he->twt_request = session_he->twt_responder ?
6830 peer_he->twt_request : 0;
6831 peer_he->twt_responder = session_he->twt_request ?
6832 peer_he->twt_responder : 0;
6833}
6834
Jeff Johnsonc8baa902018-11-18 21:59:07 -08006835void lim_intersect_sta_he_caps(tpSirAssocReq assoc_req, struct pe_session *session,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006836 tpDphHashNode sta_ds)
6837{
Naveen Rawatd8feac12017-09-08 15:08:39 -07006838 tDot11fIEhe_cap *rcvd_he = &assoc_req->he_cap;
6839 tDot11fIEhe_cap *session_he = &session->he_config;
6840 tDot11fIEhe_cap *peer_he = &sta_ds->he_config;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006841
6842 if (sta_ds->mlmStaContext.he_capable)
6843 lim_intersect_he_caps(rcvd_he, session_he, peer_he);
6844}
6845
Jeff Johnsonc8baa902018-11-18 21:59:07 -08006846void lim_intersect_ap_he_caps(struct pe_session *session, tpAddBssParams add_bss,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006847 tSchBeaconStruct *beacon, tpSirAssocRsp assoc_rsp)
6848{
Naveen Rawatd8feac12017-09-08 15:08:39 -07006849 tDot11fIEhe_cap *rcvd_he;
6850 tDot11fIEhe_cap *session_he = &session->he_config;
6851 tDot11fIEhe_cap *peer_he = &add_bss->staContext.he_config;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006852
6853 if (beacon)
Naveen Rawatd8feac12017-09-08 15:08:39 -07006854 rcvd_he = &beacon->he_cap;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006855 else
Naveen Rawatd8feac12017-09-08 15:08:39 -07006856 rcvd_he = &assoc_rsp->he_cap;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006857
6858 lim_intersect_he_caps(rcvd_he, session_he, peer_he);
6859 add_bss->staContext.he_capable = true;
6860}
6861
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006862void lim_add_bss_he_cap(tpAddBssParams add_bss, tpSirAssocRsp assoc_rsp)
6863{
Naveen Rawatd8feac12017-09-08 15:08:39 -07006864 tDot11fIEhe_cap *he_cap;
6865 tDot11fIEhe_op *he_op;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006866
Naveen Rawatd8feac12017-09-08 15:08:39 -07006867 he_cap = &assoc_rsp->he_cap;
6868 he_op = &assoc_rsp->he_op;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006869 add_bss->he_capable = he_cap->present;
6870 if (he_cap)
6871 qdf_mem_copy(&add_bss->staContext.he_config,
6872 he_cap, sizeof(*he_cap));
6873 if (he_op)
6874 qdf_mem_copy(&add_bss->staContext.he_op,
6875 he_op, sizeof(*he_op));
6876}
6877
Jeff Johnsonc8baa902018-11-18 21:59:07 -08006878void lim_add_bss_he_cfg(tpAddBssParams add_bss, struct pe_session *session)
Manikandan Mohan39accff2017-05-02 16:09:00 -07006879{
6880 add_bss->he_sta_obsspd = session->he_sta_obsspd;
6881}
6882
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006883void lim_update_stads_he_caps(tpDphHashNode sta_ds, tpSirAssocRsp assoc_rsp,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08006884 struct pe_session *session_entry)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006885{
Naveen Rawatd8feac12017-09-08 15:08:39 -07006886 tDot11fIEhe_cap *he_cap;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006887
Naveen Rawatd8feac12017-09-08 15:08:39 -07006888 he_cap = &assoc_rsp->he_cap;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006889 sta_ds->mlmStaContext.he_capable = he_cap->present;
6890
6891 if (!he_cap->present)
6892 return;
6893
6894 qdf_mem_copy(&sta_ds->he_config, he_cap, sizeof(*he_cap));
6895
6896}
6897
Jeff Johnsond01da6b2018-12-02 12:10:22 -08006898void lim_update_usr_he_cap(struct mac_context *mac_ctx, struct pe_session *session)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006899{
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006900 tSirAddIeParams *add_ie = &session->addIeParams;
Naveen Rawatd8feac12017-09-08 15:08:39 -07006901 tDot11fIEhe_cap *he_cap = &session->he_config;
Naveen Rawat436979b2017-11-15 14:53:30 -08006902 struct he_cap_network_endian *he_cap_from_ie;
Kiran Kumar Lokere3a5b4242018-01-04 16:25:02 -08006903 uint8_t extracted_buff[DOT11F_IE_HE_CAP_MAX_LEN + 2];
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006904 QDF_STATUS status;
Kiran Kumar Lokere3a5b4242018-01-04 16:25:02 -08006905 qdf_mem_zero(extracted_buff, sizeof(extracted_buff));
6906 status = lim_strip_ie(mac_ctx, add_ie->probeRespBCNData_buff,
6907 &add_ie->probeRespBCNDataLen,
6908 DOT11F_EID_HE_CAP, ONE_BYTE,
6909 HE_CAP_OUI_TYPE, (uint8_t)HE_CAP_OUI_SIZE,
6910 extracted_buff, DOT11F_IE_HE_CAP_MAX_LEN);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006911 if (QDF_STATUS_SUCCESS != status) {
Kiran Kumar Lokere3a5b4242018-01-04 16:25:02 -08006912 pe_debug("Failed to strip HE cap IE status: %d", status);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006913 return;
6914 }
6915
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306916 pe_debug("Before update: su_beamformer: %d, su_beamformee: %d, mu_beamformer: %d",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006917 he_cap->su_beamformer, he_cap->su_beamformee, he_cap->mu_beamformer);
Naveen Rawat436979b2017-11-15 14:53:30 -08006918
Kiran Kumar Lokere3a5b4242018-01-04 16:25:02 -08006919 he_cap_from_ie = (struct he_cap_network_endian *)
6920 &extracted_buff[HE_CAP_OUI_SIZE + 2];
Naveen Rawat436979b2017-11-15 14:53:30 -08006921
6922 he_cap->su_beamformer =
6923 he_cap->su_beamformer & he_cap_from_ie->su_beamformer;
6924 he_cap->su_beamformee =
6925 he_cap->su_beamformee & he_cap_from_ie->su_beamformee;
6926 he_cap->mu_beamformer =
6927 he_cap->mu_beamformer & he_cap_from_ie->mu_beamformer;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006928
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306929 pe_debug("After update: su_beamformer: %d, su_beamformee: %d, mu_beamformer: %d",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006930 he_cap->su_beamformer, he_cap->su_beamformee, he_cap->mu_beamformer);
6931}
6932
Jeff Johnsond01da6b2018-12-02 12:10:22 -08006933void lim_decide_he_op(struct mac_context *mac_ctx, tpAddBssParams add_bss,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08006934 struct pe_session *session)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006935{
Naveen Rawat436979b2017-11-15 14:53:30 -08006936 uint32_t val;
Naveen Rawat807b6d02018-03-07 18:19:06 -08006937 uint8_t color;
Naveen Rawat436979b2017-11-15 14:53:30 -08006938 struct he_ops_network_endian *he_ops_from_ie;
Naveen Rawatd8feac12017-09-08 15:08:39 -07006939 tDot11fIEhe_op *he_ops = &add_bss->he_op;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006940 tSirAddIeParams *add_ie = &session->addIeParams;
Kiran Kumar Lokere3a5b4242018-01-04 16:25:02 -08006941 uint8_t extracted_buff[DOT11F_IE_HE_OP_MAX_LEN + 2];
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006942 QDF_STATUS status;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006943
Kiran Kumar Lokere3a5b4242018-01-04 16:25:02 -08006944 qdf_mem_zero(extracted_buff, sizeof(extracted_buff));
6945 status = lim_strip_ie(mac_ctx, add_ie->probeRespBCNData_buff,
6946 &add_ie->probeRespBCNDataLen,
6947 DOT11F_EID_HE_OP, ONE_BYTE,
6948 HE_OP_OUI_TYPE, (uint8_t)HE_OP_OUI_SIZE,
6949 extracted_buff, DOT11F_IE_HE_OP_MAX_LEN);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006950 if (QDF_STATUS_SUCCESS != status) {
Kiran Kumar Lokere3a5b4242018-01-04 16:25:02 -08006951 pe_debug("Failed to strip HE OP IE status: %d", status);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006952 return;
6953 }
Kiran Kumar Lokere3a5b4242018-01-04 16:25:02 -08006954 he_ops_from_ie = (struct he_ops_network_endian *)
6955 &extracted_buff[HE_OP_OUI_SIZE + 2];
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006956
Naveen Rawat807b6d02018-03-07 18:19:06 -08006957 if (he_ops_from_ie->bss_color) {
6958 he_ops->bss_color = he_ops_from_ie->bss_color;
6959 } else {
6960 cds_rand_get_bytes(0, &color, 1);
6961 /* make sure color is within 1-63*/
6962 he_ops->bss_color = (color % WNI_CFG_HE_OPS_BSS_COLOR_MAX) + 1;
6963 }
Naveen Rawat436979b2017-11-15 14:53:30 -08006964 he_ops->default_pe = he_ops_from_ie->default_pe;
6965 he_ops->twt_required = he_ops_from_ie->twt_required;
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07006966 he_ops->txop_rts_threshold = he_ops_from_ie->txop_rts_threshold;
Naveen Rawat436979b2017-11-15 14:53:30 -08006967 he_ops->partial_bss_col = he_ops_from_ie->partial_bss_col;
Naveen Rawat436979b2017-11-15 14:53:30 -08006968 he_ops->bss_col_disabled = he_ops_from_ie->bss_col_disabled;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006969
Bala Venkatesh6d537092018-09-25 10:38:36 +05306970 val = mac_ctx->mlme_cfg->he_caps.he_ops_basic_mcs_nss;
6971
Naveen Rawat436979b2017-11-15 14:53:30 -08006972 *((uint16_t *)he_ops->basic_mcs_nss) = (uint16_t)val;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006973
Naveen Rawat436979b2017-11-15 14:53:30 -08006974 qdf_mem_copy(&session->he_op, he_ops, sizeof(*he_ops));
6975
6976 pe_debug("HE Op: bss_color: 0x%0x, default_pe_duration: 0x%0x",
6977 he_ops->bss_color, he_ops->default_pe);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07006978 pe_debug("He Op: twt_required: 0x%0x, txop_rts_threshold: 0x%0x",
6979 he_ops->twt_required, he_ops->txop_rts_threshold);
6980 pe_debug("HE Op: partial_bss_color: 0x%0x",
6981 he_ops->partial_bss_col);
Naveen Rawat436979b2017-11-15 14:53:30 -08006982 pe_debug("HE Op: BSS color disabled: 0x%0x",
Naveen Rawat4051b022017-09-08 16:17:54 -07006983 he_ops->bss_col_disabled);
Naveen Rawat436979b2017-11-15 14:53:30 -08006984 pe_debug("HE Op: Basic MCS NSS: 0x%04x",
6985 *((uint16_t *)he_ops->basic_mcs_nss));
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006986}
6987
Jeff Johnsonc8baa902018-11-18 21:59:07 -08006988void lim_copy_bss_he_cap(struct pe_session *session,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006989 tpSirSmeStartBssReq sme_start_bss_req)
6990{
6991 qdf_mem_copy(&(session->he_config), &(sme_start_bss_req->he_config),
6992 sizeof(session->he_config));
6993}
6994
Jeff Johnsonc8baa902018-11-18 21:59:07 -08006995void lim_copy_join_req_he_cap(struct pe_session *session,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006996 tpSirSmeJoinReq sme_join_req)
6997{
6998 qdf_mem_copy(&(session->he_config), &(sme_join_req->he_config),
6999 sizeof(session->he_config));
Naveen Rawataeca1b92017-10-16 16:55:31 -07007000
7001 if (session->ch_width <= CH_WIDTH_80MHZ) {
7002 *(uint16_t *)session->he_config.rx_he_mcs_map_160 =
7003 HE_MCS_ALL_DISABLED;
7004 *(uint16_t *)session->he_config.tx_he_mcs_map_160 =
7005 HE_MCS_ALL_DISABLED;
7006 *(uint16_t *)session->he_config.rx_he_mcs_map_80_80 =
7007 HE_MCS_ALL_DISABLED;
7008 *(uint16_t *)session->he_config.tx_he_mcs_map_80_80 =
7009 HE_MCS_ALL_DISABLED;
7010 }
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007011}
7012
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007013void lim_log_he_cap(struct mac_context *mac, tDot11fIEhe_cap *he_cap)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007014{
Naveen Rawataeca1b92017-10-16 16:55:31 -07007015 uint8_t chan_width;
Naveen Rawat819158d2018-01-16 10:56:45 -08007016 struct ppet_hdr *hdr;
Naveen Rawataeca1b92017-10-16 16:55:31 -07007017
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007018 if (!he_cap->present)
7019 return;
7020
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307021 pe_debug("HE Capabilities:");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007022
7023 /* HE MAC capabilities */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307024 pe_debug("\tHTC-HE conrol: 0x%01x", he_cap->htc_he);
7025 pe_debug("\tTWT Requestor support: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007026 he_cap->twt_request);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307027 pe_debug("\tTWT Responder support: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007028 he_cap->twt_responder);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307029 pe_debug("\tFragmentation support: 0x%02x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007030 he_cap->fragmentation);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307031 pe_debug("\tMax no.of frag MSDUs: 0x%03x",
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007032 he_cap->max_num_frag_msdu_amsdu_exp);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307033 pe_debug("\tMin. frag size: 0x%02x", he_cap->min_frag_size);
7034 pe_debug("\tTrigger MAC pad duration: 0x%02x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007035 he_cap->trigger_frm_mac_pad);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007036 pe_debug("\tMulti-TID aggr Rx support: 0x%03x",
7037 he_cap->multi_tid_aggr_rx_supp);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307038 pe_debug("\tLink adaptation: 0x%02x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007039 he_cap->he_link_adaptation);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307040 pe_debug("\tAll ACK support: 0x%01x", he_cap->all_ack);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007041 pe_debug("\tTriggered resp. scheduling: 0x%01x",
7042 he_cap->trigd_rsp_sched);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307043 pe_debug("\tA-Buff status report: 0x%01x", he_cap->a_bsr);
7044 pe_debug("\tBroadcast TWT support: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007045 he_cap->broadcast_twt);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307046 pe_debug("\t32bit BA bitmap support: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007047 he_cap->ba_32bit_bitmap);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307048 pe_debug("\tMU Cascading support: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007049 he_cap->mu_cascade);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307050 pe_debug("\tACK enabled Multi-TID: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007051 he_cap->ack_enabled_multitid);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307052 pe_debug("\tOMI A-Control support: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007053 he_cap->omi_a_ctrl);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307054 pe_debug("\tOFDMA RA support: 0x%01x", he_cap->ofdma_ra);
7055 pe_debug("\tMax A-MPDU Length: 0x%02x",
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007056 he_cap->max_ampdu_len_exp_ext);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307057 pe_debug("\tA-MSDU Fragmentation: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007058 he_cap->amsdu_frag);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307059 pe_debug("\tFlex. TWT sched support: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007060 he_cap->flex_twt_sched);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307061 pe_debug("\tRx Ctrl frame to MBSS: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007062 he_cap->rx_ctrl_frame);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307063 pe_debug("\tBSRP A-MPDU Aggregation: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007064 he_cap->bsrp_ampdu_aggr);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307065 pe_debug("\tQuite Time Period support: 0x%01x", he_cap->qtp);
7066 pe_debug("\tA-BQR support: 0x%01x", he_cap->a_bqr);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007067 pe_debug("\tSR Reponder support: 0x%01x",
7068 he_cap->spatial_reuse_param_rspder);
Naveen Rawat4051b022017-09-08 16:17:54 -07007069 pe_debug("\tNDP Feedback support: 0x%01x", he_cap->ndp_feedback_supp);
7070 pe_debug("\tOPS support: 0x%01x", he_cap->ops_supp);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007071 pe_debug("\tAMSDU in AMPDU: 0x%01x", he_cap->amsdu_in_ampdu);
7072 pe_debug("\tMulti-TID aggr Tx support: 0x%03x",
7073 he_cap->multi_tid_aggr_tx_supp);
7074 pe_debug("\tHE sub ch sel tx supp: 0x%01x",
7075 he_cap->he_sub_ch_sel_tx_supp);
7076 pe_debug("\tUL 2x996 tone RU supp: 0x%01x",
7077 he_cap->ul_2x996_tone_ru_supp);
7078 pe_debug("\tOM ctrl UL MU data dis rx supp: 0x%01x",
7079 he_cap->om_ctrl_ul_mu_data_dis_rx);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007080 /* HE PHY capabilities */
Naveen Rawataeca1b92017-10-16 16:55:31 -07007081 chan_width = HE_CH_WIDTH_COMBINE(he_cap->chan_width_0,
7082 he_cap->chan_width_1, he_cap->chan_width_2,
7083 he_cap->chan_width_3, he_cap->chan_width_4,
7084 he_cap->chan_width_5, he_cap->chan_width_6);
7085
7086 pe_debug("\tChannel width support: 0x%07x", chan_width);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307087 pe_debug("\tPreamble puncturing Rx: 0x%04x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007088 he_cap->rx_pream_puncturing);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307089 pe_debug("\tClass of device: 0x%01x", he_cap->device_class);
7090 pe_debug("\tLDPC coding support: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007091 he_cap->ldpc_coding);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307092 pe_debug("\tLTF and GI for HE PPDUs: 0x%02x",
Naveen Rawat4051b022017-09-08 16:17:54 -07007093 he_cap->he_1x_ltf_800_gi_ppdu);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007094 pe_debug("\tMidamble TX Rx MAX NSTS: 0x%02x",
7095 he_cap->midamble_tx_rx_max_nsts);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307096 pe_debug("\tLTF and GI for NDP: 0x%02x",
Naveen Rawat4051b022017-09-08 16:17:54 -07007097 he_cap->he_4x_ltf_3200_gi_ndp);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -08007098 pe_debug("\tSTBC Tx support (<= 80MHz): 0x%01x",
7099 he_cap->tx_stbc_lt_80mhz);
7100 pe_debug("\tSTBC Rx support (<= 80MHz): 0x%01x",
7101 he_cap->rx_stbc_lt_80mhz);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307102 pe_debug("\tDoppler support: 0x%02x", he_cap->doppler);
7103 pe_debug("\tUL MU: 0x%02x", he_cap->ul_mu);
7104 pe_debug("\tDCM encoding Tx: 0x%03x", he_cap->dcm_enc_tx);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007105 pe_debug("\tDCM encoding Rx: 0x%03x", he_cap->dcm_enc_rx);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307106 pe_debug("\tHE MU PPDU payload support: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007107 he_cap->ul_he_mu);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307108 pe_debug("\tSU Beamformer: 0x%01x", he_cap->su_beamformer);
7109 pe_debug("\tSU Beamformee: 0x%01x", he_cap->su_beamformee);
7110 pe_debug("\tMU Beamformer: 0x%01x", he_cap->mu_beamformer);
7111 pe_debug("\tBeamformee STS for <= 80Mhz: 0x%03x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007112 he_cap->bfee_sts_lt_80);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307113 pe_debug("\tBeamformee STS for > 80Mhz: 0x%03x",
Naveen Rawat4051b022017-09-08 16:17:54 -07007114 he_cap->bfee_sts_gt_80);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307115 pe_debug("\tNo. of sounding dim <= 80Mhz: 0x%03x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007116 he_cap->num_sounding_lt_80);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307117 pe_debug("\tNo. of sounding dim > 80Mhz: 0x%03x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007118 he_cap->num_sounding_gt_80);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307119 pe_debug("\tNg=16 for SU feedback support: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007120 he_cap->su_feedback_tone16);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307121 pe_debug("\tNg=16 for MU feedback support: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007122 he_cap->mu_feedback_tone16);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307123 pe_debug("\tCodebook size for SU: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007124 he_cap->codebook_su);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307125 pe_debug("\tCodebook size for MU: 0x%01x ",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007126 he_cap->codebook_mu);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307127 pe_debug("\tBeamforming trigger w/ Trigger: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007128 he_cap->beamforming_feedback);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307129 pe_debug("\tHE ER SU PPDU payload: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007130 he_cap->he_er_su_ppdu);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307131 pe_debug("\tDL MUMIMO on partial BW: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007132 he_cap->dl_mu_mimo_part_bw);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307133 pe_debug("\tPPET present: 0x%01x", he_cap->ppet_present);
7134 pe_debug("\tSRP based SR-support: 0x%01x", he_cap->srp);
7135 pe_debug("\tPower boost factor: 0x%01x", he_cap->power_boost);
Naveen Rawat4051b022017-09-08 16:17:54 -07007136 pe_debug("\t4x HE LTF support: 0x%01x", he_cap->he_ltf_800_gi_4x);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -08007137 pe_debug("\tSTBC Tx support (> 80MHz): 0x%01x",
7138 he_cap->tx_stbc_gt_80mhz);
7139 pe_debug("\tSTBC Rx support (> 80MHz): 0x%01x",
7140 he_cap->rx_stbc_gt_80mhz);
Naveen Rawat4051b022017-09-08 16:17:54 -07007141 pe_debug("\tMax Nc: 0x%03x", he_cap->max_nc);
7142 pe_debug("\tER 4x HE LTF support: 0x%01x", he_cap->er_he_ltf_800_gi_4x);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007143 pe_debug("\tHE ppdu 20 in 40M in 2.4G: 0x%01x",
Naveen Rawatfc530312017-10-23 14:34:12 -07007144 he_cap->he_ppdu_20_in_40Mhz_2G);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007145 pe_debug("\tHE ppdu 20 in 160 and 80p80: 0x%01x",
Naveen Rawatfc530312017-10-23 14:34:12 -07007146 he_cap->he_ppdu_20_in_160_80p80Mhz);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007147 pe_debug("\tHE ppdu 80 in 160 and 80p80: 0x%01x",
Naveen Rawatfc530312017-10-23 14:34:12 -07007148 he_cap->he_ppdu_80_in_160_80p80Mhz);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007149 pe_debug("\tER 1x HE LTF GI support: 0x%01x",
Naveen Rawatfc530312017-10-23 14:34:12 -07007150 he_cap->er_1x_he_ltf_gi);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007151 pe_debug("\tmidamble txrx 1x he LTF: 0x%01x",
7152 he_cap->midamble_tx_rx_1x_he_ltf);
7153 pe_debug("\tDCM max BW: 0x%02x",
7154 he_cap->dcm_max_bw);
7155 pe_debug("\tlonger_than_16_he_sigb_ofdm_sym: 0x%01x",
7156 he_cap->longer_than_16_he_sigb_ofdm_sym);
7157 pe_debug("\tnon_trig_cqi_feedback: 0x%01x",
7158 he_cap->non_trig_cqi_feedback);
7159 pe_debug("\ttx_1024_qam_lt_242_tone_ru: 0x%01x",
7160 he_cap->tx_1024_qam_lt_242_tone_ru);
7161 pe_debug("\trx_1024_qam_lt_242_tone_ru: 0x%01x",
7162 he_cap->rx_1024_qam_lt_242_tone_ru);
7163 pe_debug("\trx_full_bw_su_he_mu_compress_sigb: 0x%01x",
7164 he_cap->rx_full_bw_su_he_mu_compress_sigb);
7165 pe_debug("\trx_full_bw_su_he_mu_non_cmpr_sigb: 0x%01x",
7166 he_cap->rx_full_bw_su_he_mu_non_cmpr_sigb);
Naveen Rawataeca1b92017-10-16 16:55:31 -07007167 pe_debug("\tRx MCS map for <= 80 Mhz: 0x%04x",
7168 he_cap->rx_he_mcs_map_lt_80);
7169 pe_debug("\tTx MCS map for <= 80 Mhz: 0x%04x",
7170 he_cap->tx_he_mcs_map_lt_80);
7171 pe_debug("\tRx MCS map for <= 160 Mhz: 0x%04x",
7172 *((uint16_t *)he_cap->rx_he_mcs_map_160));
7173 pe_debug("\tTx MCS map for <= 160 Mhz: 0x%04x",
7174 *((uint16_t *)he_cap->tx_he_mcs_map_160));
7175 pe_debug("\tRx MCS map for <= 80+80 Mhz: 0x%04x",
7176 *((uint16_t *)he_cap->rx_he_mcs_map_80_80));
7177 pe_debug("\tTx MCS map for <= 80+80 Mhz: 0x%04x",
7178 *((uint16_t *)he_cap->tx_he_mcs_map_80_80));
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007179
Naveen Rawat819158d2018-01-16 10:56:45 -08007180 hdr = (struct ppet_hdr *)&he_cap->ppet;
7181 pe_debug("\t ppe_th:: nss_count: %d, ru_idx_msk: %d",
7182 hdr->nss, hdr->ru_idx_mask);
Naveen Rawat01213762018-01-04 17:25:31 -08007183
7184 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat819158d2018-01-16 10:56:45 -08007185 &he_cap->ppet, HE_MAX_PPET_SIZE);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007186}
7187
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007188void lim_log_he_op(struct mac_context *mac, tDot11fIEhe_op *he_ops)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007189{
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007190 pe_debug("bss_color: %0x, default_pe_duration: %0x, twt_required: %0x, txop_rts_threshold: %0x, vht_oper_present: %0x",
7191 he_ops->bss_color, he_ops->default_pe,
7192 he_ops->twt_required, he_ops->txop_rts_threshold,
7193 he_ops->vht_oper_present);
7194 pe_debug("\tpart_bss_color %0x, Co-located BSS %0x, BSS color dis %0x",
7195 he_ops->partial_bss_col, he_ops->co_located_bss,
7196 he_ops->bss_col_disabled);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007197
Naveen Rawat436979b2017-11-15 14:53:30 -08007198 pe_debug("he basic mcs nss: 0x%04x",
7199 *((uint16_t *)he_ops->basic_mcs_nss));
7200
Naveen Rawat4051b022017-09-08 16:17:54 -07007201 if (he_ops->vht_oper_present)
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307202 pe_debug("VHT Info not present in HE Operation");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007203 else
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307204 pe_debug("VHT Info: chan_width: %d, center_freq0: %d, center_freq1: %d",
Naveen Rawat4051b022017-09-08 16:17:54 -07007205 he_ops->vht_oper.info.chan_width,
7206 he_ops->vht_oper.info.center_freq_seg0,
7207 he_ops->vht_oper.info.center_freq_seg1);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007208}
7209
Peng Xu6363ec62017-05-15 11:06:33 -07007210#ifdef WLAN_FEATURE_11AX_BSS_COLOR
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007211void lim_log_he_bss_color(struct mac_context *mac,
Peng Xu6363ec62017-05-15 11:06:33 -07007212 tDot11fIEbss_color_change *he_bss_color)
7213{
7214 pe_debug("countdown: %d, new_color: %d",
7215 he_bss_color->countdown, he_bss_color->new_color);
7216}
7217#endif
7218
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007219void lim_update_sta_he_capable(struct mac_context *mac,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007220 tpAddStaParams add_sta_params, tpDphHashNode sta_ds,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08007221 struct pe_session *session_entry)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007222{
7223 if (LIM_IS_AP_ROLE(session_entry) || LIM_IS_IBSS_ROLE(session_entry))
7224 add_sta_params->he_capable = sta_ds->mlmStaContext.he_capable;
7225 else
7226 add_sta_params->he_capable = session_entry->he_capable;
7227
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307228 pe_debug("he_capable: %d", add_sta_params->he_capable);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007229}
7230
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007231void lim_update_bss_he_capable(struct mac_context *mac, tpAddBssParams add_bss)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007232{
7233 add_bss->he_capable = true;
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307234 pe_debug("he_capable: %d", add_bss->he_capable);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007235}
7236
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007237void lim_update_stads_he_capable(tpDphHashNode sta_ds, tpSirAssocReq assoc_req)
7238{
7239 sta_ds->mlmStaContext.he_capable = assoc_req->he_cap.present;
7240}
7241
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007242void lim_update_session_he_capable(struct mac_context *mac, struct pe_session *session)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007243{
7244 session->he_capable = true;
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307245 pe_debug("he_capable: %d", session->he_capable);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007246}
7247
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007248void lim_update_chan_he_capable(struct mac_context *mac, tpSwitchChannelParams chan)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007249{
7250 chan->he_capable = true;
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307251 pe_debug("he_capable: %d", chan->he_capable);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007252}
7253
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007254void lim_set_he_caps(struct mac_context *mac, struct pe_session *session, uint8_t *ie_start,
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007255 uint32_t num_bytes)
7256{
Naveen Rawat08db88f2017-09-08 15:07:48 -07007257 const uint8_t *ie = NULL;
Naveen Rawatd8feac12017-09-08 15:08:39 -07007258 tDot11fIEhe_cap dot11_cap;
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007259 struct he_capability_info *he_cap;
7260
7261 populate_dot11f_he_caps(mac, session, &dot11_cap);
7262 lim_log_he_cap(mac, &dot11_cap);
Naveen Rawatd8feac12017-09-08 15:08:39 -07007263 ie = wlan_get_ext_ie_ptr_from_ext_id(HE_CAP_OUI_TYPE,
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007264 HE_CAP_OUI_SIZE, ie_start, num_bytes);
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007265 if (ie) {
7266 /* convert from unpacked to packed structure */
7267 he_cap = (struct he_capability_info *) &ie[2 + HE_CAP_OUI_SIZE];
7268
7269 he_cap->htc_he = dot11_cap.htc_he;
7270 he_cap->twt_request = dot11_cap.twt_request;
7271 he_cap->twt_responder = dot11_cap.twt_responder;
7272 he_cap->fragmentation = dot11_cap.fragmentation;
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007273 he_cap->max_num_frag_msdu_amsdu_exp =
7274 dot11_cap.max_num_frag_msdu_amsdu_exp;
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007275 he_cap->min_frag_size = dot11_cap.min_frag_size;
7276 he_cap->trigger_frm_mac_pad = dot11_cap.trigger_frm_mac_pad;
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007277 he_cap->multi_tid_aggr_rx_supp =
7278 dot11_cap.multi_tid_aggr_rx_supp;
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007279 he_cap->he_link_adaptation = dot11_cap.he_link_adaptation;
7280 he_cap->all_ack = dot11_cap.all_ack;
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007281 he_cap->trigd_rsp_sched = dot11_cap.trigd_rsp_sched;
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007282 he_cap->a_bsr = dot11_cap.a_bsr;
7283 he_cap->broadcast_twt = dot11_cap.broadcast_twt;
7284 he_cap->ba_32bit_bitmap = dot11_cap.ba_32bit_bitmap;
7285 he_cap->mu_cascade = dot11_cap.mu_cascade;
7286 he_cap->ack_enabled_multitid = dot11_cap.ack_enabled_multitid;
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007287 he_cap->omi_a_ctrl = dot11_cap.omi_a_ctrl;
7288 he_cap->ofdma_ra = dot11_cap.ofdma_ra;
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007289 he_cap->max_ampdu_len_exp_ext = dot11_cap.max_ampdu_len_exp_ext;
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007290 he_cap->amsdu_frag = dot11_cap.amsdu_frag;
7291 he_cap->flex_twt_sched = dot11_cap.flex_twt_sched;
7292 he_cap->rx_ctrl_frame = dot11_cap.rx_ctrl_frame;
7293
7294 he_cap->bsrp_ampdu_aggr = dot11_cap.bsrp_ampdu_aggr;
7295 he_cap->qtp = dot11_cap.qtp;
7296 he_cap->a_bqr = dot11_cap.a_bqr;
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007297 he_cap->spatial_reuse_param_rspder =
7298 dot11_cap.spatial_reuse_param_rspder;
Naveen Rawat4051b022017-09-08 16:17:54 -07007299 he_cap->ops_supp = dot11_cap.ops_supp;
7300 he_cap->ndp_feedback_supp = dot11_cap.ndp_feedback_supp;
Naveen Rawatfc530312017-10-23 14:34:12 -07007301 he_cap->amsdu_in_ampdu = dot11_cap.amsdu_in_ampdu;
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007302 he_cap->reserved1 = dot11_cap.reserved1;
7303
Naveen Rawataeca1b92017-10-16 16:55:31 -07007304 he_cap->chan_width = HE_CH_WIDTH_COMBINE(dot11_cap.chan_width_0,
7305 dot11_cap.chan_width_1, dot11_cap.chan_width_2,
7306 dot11_cap.chan_width_3, dot11_cap.chan_width_4,
7307 dot11_cap.chan_width_5, dot11_cap.chan_width_6);
7308
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007309 he_cap->rx_pream_puncturing = dot11_cap.rx_pream_puncturing;
7310 he_cap->device_class = dot11_cap.device_class;
7311 he_cap->ldpc_coding = dot11_cap.ldpc_coding;
Naveen Rawat4051b022017-09-08 16:17:54 -07007312 he_cap->he_1x_ltf_800_gi_ppdu = dot11_cap.he_1x_ltf_800_gi_ppdu;
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007313 he_cap->midamble_tx_rx_max_nsts =
7314 dot11_cap.midamble_tx_rx_max_nsts;
Naveen Rawat4051b022017-09-08 16:17:54 -07007315 he_cap->he_4x_ltf_3200_gi_ndp = dot11_cap.he_4x_ltf_3200_gi_ndp;
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -08007316 he_cap->tx_stbc_lt_80mhz = dot11_cap.tx_stbc_lt_80mhz;
7317 he_cap->rx_stbc_lt_80mhz = dot11_cap.rx_stbc_lt_80mhz;
7318 he_cap->tx_stbc_gt_80mhz = dot11_cap.tx_stbc_gt_80mhz;
7319 he_cap->rx_stbc_gt_80mhz = dot11_cap.rx_stbc_gt_80mhz;
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007320 he_cap->doppler = dot11_cap.doppler;
7321 he_cap->ul_mu = dot11_cap.ul_mu;
7322 he_cap->dcm_enc_tx = dot11_cap.dcm_enc_tx;
7323 he_cap->dcm_enc_rx = dot11_cap.dcm_enc_rx;
7324 he_cap->ul_he_mu = dot11_cap.ul_he_mu;
7325 he_cap->su_beamformer = dot11_cap.su_beamformer;
7326
7327 he_cap->su_beamformee = dot11_cap.su_beamformee;
7328 he_cap->mu_beamformer = dot11_cap.mu_beamformer;
7329 he_cap->bfee_sts_lt_80 = dot11_cap.bfee_sts_lt_80;
Naveen Rawat4051b022017-09-08 16:17:54 -07007330 he_cap->bfee_sts_gt_80 = dot11_cap.bfee_sts_gt_80;
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007331 he_cap->num_sounding_lt_80 = dot11_cap.num_sounding_lt_80;
7332 he_cap->num_sounding_gt_80 = dot11_cap.num_sounding_gt_80;
7333 he_cap->su_feedback_tone16 = dot11_cap.su_feedback_tone16;
7334 he_cap->mu_feedback_tone16 = dot11_cap.mu_feedback_tone16;
7335 he_cap->codebook_su = dot11_cap.codebook_su;
7336 he_cap->codebook_mu = dot11_cap.codebook_mu;
7337 he_cap->beamforming_feedback = dot11_cap.beamforming_feedback;
7338 he_cap->he_er_su_ppdu = dot11_cap.he_er_su_ppdu;
7339 he_cap->dl_mu_mimo_part_bw = dot11_cap.dl_mu_mimo_part_bw;
7340 he_cap->ppet_present = dot11_cap.ppet_present;
7341 he_cap->srp = dot11_cap.srp;
7342 he_cap->power_boost = dot11_cap.power_boost;
7343
Naveen Rawat4051b022017-09-08 16:17:54 -07007344 he_cap->he_ltf_800_gi_4x = dot11_cap.he_ltf_800_gi_4x;
7345 he_cap->max_nc = dot11_cap.max_nc;
7346 he_cap->er_he_ltf_800_gi_4x = dot11_cap.er_he_ltf_800_gi_4x;
Naveen Rawatfc530312017-10-23 14:34:12 -07007347 he_cap->he_ppdu_20_in_40Mhz_2G =
7348 dot11_cap.he_ppdu_20_in_40Mhz_2G;
7349 he_cap->he_ppdu_20_in_160_80p80Mhz =
7350 dot11_cap.he_ppdu_20_in_160_80p80Mhz;
7351 he_cap->he_ppdu_80_in_160_80p80Mhz =
7352 dot11_cap.he_ppdu_80_in_160_80p80Mhz;
7353 he_cap->er_1x_he_ltf_gi =
7354 dot11_cap.er_1x_he_ltf_gi;
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007355 he_cap->midamble_tx_rx_1x_he_ltf =
7356 dot11_cap.midamble_tx_rx_1x_he_ltf;
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007357 he_cap->reserved2 = dot11_cap.reserved2;
7358
Naveen Rawataeca1b92017-10-16 16:55:31 -07007359 he_cap->rx_he_mcs_map_lt_80 = dot11_cap.rx_he_mcs_map_lt_80;
7360 he_cap->tx_he_mcs_map_lt_80 = dot11_cap.tx_he_mcs_map_lt_80;
7361 he_cap->rx_he_mcs_map_160 =
7362 *((uint16_t *)dot11_cap.rx_he_mcs_map_160);
7363 he_cap->tx_he_mcs_map_160 =
7364 *((uint16_t *)dot11_cap.tx_he_mcs_map_160);
7365 he_cap->rx_he_mcs_map_80_80 =
7366 *((uint16_t *)dot11_cap.rx_he_mcs_map_80_80);
7367 he_cap->tx_he_mcs_map_80_80 =
7368 *((uint16_t *)dot11_cap.tx_he_mcs_map_80_80);
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007369 }
7370}
7371
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007372QDF_STATUS lim_send_he_caps_ie(struct mac_context *mac_ctx, struct pe_session *session,
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007373 uint8_t vdev_id)
7374{
Naveen Rawataeca1b92017-10-16 16:55:31 -07007375 uint8_t he_caps[SIR_MAC_HE_CAP_MIN_LEN + 3];
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007376 struct he_capability_info *he_cap;
7377 QDF_STATUS status_5g, status_2g;
7378
7379 /* Sending only minimal info(no PPET) to FW now, update if required */
Naveen Rawataeca1b92017-10-16 16:55:31 -07007380 qdf_mem_zero(he_caps, SIR_MAC_HE_CAP_MIN_LEN + 3);
Naveen Rawatd8feac12017-09-08 15:08:39 -07007381 he_caps[0] = DOT11F_EID_HE_CAP;
Naveen Rawataeca1b92017-10-16 16:55:31 -07007382 he_caps[1] = SIR_MAC_HE_CAP_MIN_LEN;
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007383 qdf_mem_copy(&he_caps[2], HE_CAP_OUI_TYPE, HE_CAP_OUI_SIZE);
7384 lim_set_he_caps(mac_ctx, session, he_caps,
Naveen Rawataeca1b92017-10-16 16:55:31 -07007385 SIR_MAC_HE_CAP_MIN_LEN + 3);
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007386 he_cap = (struct he_capability_info *) (&he_caps[2 + HE_CAP_OUI_SIZE]);
7387 he_cap->ppet_present = 0;
7388
Naveen Rawatd8feac12017-09-08 15:08:39 -07007389 status_5g = lim_send_ie(mac_ctx, vdev_id, DOT11F_EID_HE_CAP,
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007390 CDS_BAND_5GHZ, &he_caps[2],
Naveen Rawataeca1b92017-10-16 16:55:31 -07007391 SIR_MAC_HE_CAP_MIN_LEN + 1);
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007392 if (QDF_IS_STATUS_ERROR(status_5g))
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307393 pe_err("Unable send HE Cap IE for 5GHZ band, status: %d",
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007394 status_5g);
7395
Naveen Rawatd8feac12017-09-08 15:08:39 -07007396 status_2g = lim_send_ie(mac_ctx, vdev_id, DOT11F_EID_HE_CAP,
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007397 CDS_BAND_2GHZ, &he_caps[2],
Naveen Rawataeca1b92017-10-16 16:55:31 -07007398 SIR_MAC_HE_CAP_MIN_LEN + 1);
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007399 if (QDF_IS_STATUS_ERROR(status_2g))
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307400 pe_err("Unable send HE Cap IE for 2GHZ band, status: %d",
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007401 status_2g);
7402
7403 if (QDF_IS_STATUS_SUCCESS(status_2g) &&
7404 QDF_IS_STATUS_SUCCESS(status_5g))
7405 return QDF_STATUS_SUCCESS;
7406
7407 return QDF_STATUS_E_FAILURE;
7408}
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07007409
7410/**
Naveen Rawataeca1b92017-10-16 16:55:31 -07007411 * lim_populate_he_mcs_per_bw() - pouldate HE mcs set per BW (le 80, 160, 80+80)
7412 * @mac_ctx: Global MAC context
7413 * @self_rx: self rx mcs set
7414 * @self_tx: self tx mcs set
7415 * @peer_rx: peer rx mcs set
7416 * @peer_tx: peer tx mcs set
7417 * @nss: nss
7418 * @cfg_rx_param: rx wni param to read
7419 * @cfg_tx_param: tx wni param to read
7420 *
7421 * MCS values are interpreted as in IEEE 11ax-D1.4 spec onwards
7422 * +-----------------------------------------------------+
7423 * | SS8 | SS7 | SS6 | SS5 | SS4 | SS3 | SS2 | SS1 |
7424 * +-----------------------------------------------------+
7425 * | 15-14 | 13-12 | 11-10 | 9-8 | 7-6 | 5-4 | 3-2 | 1-0 |
7426 * +-----------------------------------------------------+
7427 *
7428 * Return: status of operation
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07007429 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007430static QDF_STATUS lim_populate_he_mcs_per_bw(struct mac_context *mac_ctx,
Naveen Rawataeca1b92017-10-16 16:55:31 -07007431 uint16_t *self_rx, uint16_t *self_tx,
7432 uint16_t peer_rx, uint16_t peer_tx, uint8_t nss,
Bala Venkatesh6d537092018-09-25 10:38:36 +05307433 uint16_t rx_mcs, uint16_t tx_mcs)
Naveen Rawataeca1b92017-10-16 16:55:31 -07007434{
Naveen Rawataeca1b92017-10-16 16:55:31 -07007435
7436 pe_debug("peer rates: rx_mcs - 0x%04x tx_mcs - 0x%04x",
7437 peer_rx, peer_tx);
Bala Venkatesh6d537092018-09-25 10:38:36 +05307438
7439 *self_rx = rx_mcs;
7440 *self_tx = tx_mcs;
Naveen Rawataeca1b92017-10-16 16:55:31 -07007441
7442 *self_rx = HE_INTERSECT_MCS(*self_rx, peer_tx);
7443 *self_tx = HE_INTERSECT_MCS(*self_tx, peer_rx);
7444
7445 if (nss == NSS_1x1_MODE) {
7446 *self_rx |= HE_MCS_INV_MSK_4_NSS(1);
7447 *self_tx |= HE_MCS_INV_MSK_4_NSS(1);
7448 }
7449 /* if nss is 2, disable higher NSS */
7450 if (nss == NSS_2x2_MODE) {
7451 *self_rx |= (HE_MCS_INV_MSK_4_NSS(1) & HE_MCS_INV_MSK_4_NSS(2));
7452 *self_tx |= (HE_MCS_INV_MSK_4_NSS(1) & HE_MCS_INV_MSK_4_NSS(2));
7453 }
7454
7455 return QDF_STATUS_SUCCESS;
7456}
7457
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007458QDF_STATUS lim_populate_he_mcs_set(struct mac_context *mac_ctx,
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07007459 tpSirSupportedRates rates,
Naveen Rawatd8feac12017-09-08 15:08:39 -07007460 tDot11fIEhe_cap *peer_he_caps,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08007461 struct pe_session *session_entry, uint8_t nss)
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07007462{
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07007463 bool support_2x2 = false;
Naveen Rawataeca1b92017-10-16 16:55:31 -07007464 uint32_t self_sta_dot11mode = 0;
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07007465
7466 wlan_cfg_get_int(mac_ctx, WNI_CFG_DOT11_MODE, &self_sta_dot11mode);
7467
7468 if (!IS_DOT11_MODE_HE(self_sta_dot11mode))
7469 return QDF_STATUS_SUCCESS;
7470
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07007471 if ((peer_he_caps == NULL) || (!peer_he_caps->present)) {
Naveen Rawataeca1b92017-10-16 16:55:31 -07007472 pe_debug("peer not he capable or he_caps NULL");
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07007473 return QDF_STATUS_SUCCESS;
7474 }
7475
Naveen Rawataeca1b92017-10-16 16:55:31 -07007476 pe_debug("peer rates lt 80: rx_mcs - 0x%04x tx_mcs - 0x%04x",
7477 peer_he_caps->rx_he_mcs_map_lt_80,
7478 peer_he_caps->tx_he_mcs_map_lt_80);
7479 pe_debug("peer rates 160: rx_mcs - 0x%04x tx_mcs - 0x%04x",
7480 (*(uint16_t *)peer_he_caps->rx_he_mcs_map_160),
7481 (*(uint16_t *)peer_he_caps->tx_he_mcs_map_160));
7482 pe_debug("peer rates 80+80: rx_mcs - 0x%04x tx_mcs - 0x%04x",
7483 (*(uint16_t *)peer_he_caps->rx_he_mcs_map_80_80),
7484 (*(uint16_t *)peer_he_caps->tx_he_mcs_map_80_80));
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07007485
7486 if (session_entry && session_entry->nss == NSS_2x2_MODE) {
7487 if (mac_ctx->lteCoexAntShare &&
7488 IS_24G_CH(session_entry->currentOperChannel)) {
7489 if (IS_2X2_CHAIN(session_entry->chainMask))
7490 support_2x2 = true;
7491 else
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307492 pe_err("2x2 not enabled %d",
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07007493 session_entry->chainMask);
7494 } else {
7495 support_2x2 = true;
7496 }
7497 }
7498
Naveen Rawataeca1b92017-10-16 16:55:31 -07007499 lim_populate_he_mcs_per_bw(mac_ctx,
7500 &rates->rx_he_mcs_map_lt_80, &rates->tx_he_mcs_map_lt_80,
7501 peer_he_caps->rx_he_mcs_map_lt_80,
7502 peer_he_caps->tx_he_mcs_map_lt_80, nss,
Bala Venkatesh6d537092018-09-25 10:38:36 +05307503 mac_ctx->mlme_cfg->he_caps.dot11_he_cap.rx_he_mcs_map_lt_80,
7504 mac_ctx->mlme_cfg->he_caps.dot11_he_cap.tx_he_mcs_map_lt_80);
Naveen Rawataeca1b92017-10-16 16:55:31 -07007505 lim_populate_he_mcs_per_bw(mac_ctx,
7506 &rates->rx_he_mcs_map_160, &rates->tx_he_mcs_map_160,
7507 *((uint16_t *)peer_he_caps->rx_he_mcs_map_160),
7508 *((uint16_t *)peer_he_caps->tx_he_mcs_map_160), nss,
Bala Venkatesh6d537092018-09-25 10:38:36 +05307509 *((uint16_t *)mac_ctx->mlme_cfg->he_caps.dot11_he_cap.
7510 rx_he_mcs_map_160),
7511 *((uint16_t *)mac_ctx->mlme_cfg->he_caps.dot11_he_cap.
7512 tx_he_mcs_map_160));
Naveen Rawataeca1b92017-10-16 16:55:31 -07007513 lim_populate_he_mcs_per_bw(mac_ctx,
7514 &rates->rx_he_mcs_map_80_80, &rates->tx_he_mcs_map_80_80,
7515 *((uint16_t *)peer_he_caps->rx_he_mcs_map_80_80),
7516 *((uint16_t *)peer_he_caps->tx_he_mcs_map_80_80), nss,
Bala Venkatesh6d537092018-09-25 10:38:36 +05307517 *((uint16_t *)mac_ctx->mlme_cfg->he_caps.dot11_he_cap.
7518 rx_he_mcs_map_80_80),
7519 *((uint16_t *)mac_ctx->mlme_cfg->he_caps.dot11_he_cap.
7520 tx_he_mcs_map_80_80));
Naveen Rawataeca1b92017-10-16 16:55:31 -07007521 if (!support_2x2) {
7522 /* disable 2 and higher NSS MCS sets */
Naveen Rawatcbcc6542017-10-30 17:55:03 -07007523 rates->rx_he_mcs_map_lt_80 |= HE_MCS_INV_MSK_4_NSS(1);
7524 rates->tx_he_mcs_map_lt_80 |= HE_MCS_INV_MSK_4_NSS(1);
7525 rates->rx_he_mcs_map_160 |= HE_MCS_INV_MSK_4_NSS(1);
7526 rates->tx_he_mcs_map_160 |= HE_MCS_INV_MSK_4_NSS(1);
7527 rates->rx_he_mcs_map_80_80 |= HE_MCS_INV_MSK_4_NSS(1);
7528 rates->tx_he_mcs_map_80_80 |= HE_MCS_INV_MSK_4_NSS(1);
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07007529 }
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07007530
Naveen Rawataeca1b92017-10-16 16:55:31 -07007531 pe_debug("enable2x2 - %d nss %d",
Abhinav Kumarb074f2f2018-09-15 15:32:11 +05307532 mac_ctx->mlme_cfg->vht_caps.vht_cap_info.enable2x2, nss);
Naveen Rawataeca1b92017-10-16 16:55:31 -07007533 pe_debug("he_rx_lt_80 - 0x%x he_tx_lt_80 0x%x",
7534 rates->rx_he_mcs_map_lt_80, rates->tx_he_mcs_map_lt_80);
7535 pe_debug("he_rx_160 - 0x%x he_tx_160 0x%x",
7536 rates->rx_he_mcs_map_160, rates->tx_he_mcs_map_160);
7537 pe_debug("he_rx_80_80 - 0x%x he_tx_80_80 0x%x",
7538 rates->rx_he_mcs_map_80_80, rates->tx_he_mcs_map_80_80);
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07007539 return QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07007540}
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007541#endif
Sreelakshmi Konamki6d478cd2017-03-28 11:59:25 +05307542
Abhishek Singhf3756fc2017-06-28 16:04:06 +05307543/**
7544 * lim_assoc_rej_get_remaining_delta() - Get remaining time delta for
7545 * the rssi based disallowed list entry
7546 * @node: rssi based disallowed list entry
7547 *
7548 * Return: remaining delta, can be -ve if time has already expired.
7549 */
7550static inline int
7551lim_assoc_rej_get_remaining_delta(struct sir_rssi_disallow_lst *node)
7552{
7553 qdf_time_t cur_time;
7554 uint32_t time_diff;
7555
7556 cur_time = qdf_do_div(qdf_get_monotonic_boottime(),
7557 QDF_MC_TIMER_TO_MS_UNIT);
7558 time_diff = cur_time - node->time_during_rejection;
7559
7560 return node->retry_delay - time_diff;
7561}
7562
7563/**
7564 * lim_assoc_rej_rem_entry_with_lowest_delta() - Remove the entry
7565 * with lowest time delta
7566 * @list: rssi based rejected BSSID list
7567 *
7568 * Return: QDF_STATUS
7569 */
7570static QDF_STATUS
7571lim_assoc_rej_rem_entry_with_lowest_delta(qdf_list_t *list)
7572{
7573 struct sir_rssi_disallow_lst *oldest_node = NULL;
7574 struct sir_rssi_disallow_lst *cur_node;
7575 qdf_list_node_t *cur_list = NULL;
7576 qdf_list_node_t *next_list = NULL;
7577
7578 qdf_list_peek_front(list, &cur_list);
7579 while (cur_list) {
7580 cur_node = qdf_container_of(cur_list,
7581 struct sir_rssi_disallow_lst, node);
7582 if (!oldest_node ||
7583 (lim_assoc_rej_get_remaining_delta(oldest_node) >
7584 lim_assoc_rej_get_remaining_delta(cur_node)))
7585 oldest_node = cur_node;
7586
7587 qdf_list_peek_next(list, cur_list, &next_list);
7588 cur_list = next_list;
7589 next_list = NULL;
7590 }
7591
7592 if (oldest_node) {
7593 pe_debug("remove node %pM with lowest delta %d",
7594 oldest_node->bssid.bytes,
7595 lim_assoc_rej_get_remaining_delta(oldest_node));
7596 qdf_list_remove_node(list, &oldest_node->node);
7597 qdf_mem_free(oldest_node);
7598 return QDF_STATUS_SUCCESS;
7599 }
7600
7601 return QDF_STATUS_E_INVAL;
7602}
7603
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007604void lim_assoc_rej_add_to_rssi_based_reject_list(struct mac_context *mac_ctx,
Abhishek Singhf3756fc2017-06-28 16:04:06 +05307605 tDot11fTLVrssi_assoc_rej *rssi_assoc_rej,
7606 tSirMacAddr bssid, int8_t rssi)
7607{
7608 struct sir_rssi_disallow_lst *entry;
7609 QDF_STATUS status = QDF_STATUS_SUCCESS;
7610
7611 entry = qdf_mem_malloc(sizeof(*entry));
Arif Hussainf5b6c412018-10-10 19:41:09 -07007612 if (!entry)
Abhishek Singhf3756fc2017-06-28 16:04:06 +05307613 return;
Abhishek Singhf3756fc2017-06-28 16:04:06 +05307614
7615 pe_debug("%pM: assoc resp rssi %d, delta rssi %d retry delay %d sec and list size %d",
7616 bssid, rssi, rssi_assoc_rej->delta_rssi,
7617 rssi_assoc_rej->retry_delay,
7618 qdf_list_size(&mac_ctx->roam.rssi_disallow_bssid));
7619
7620 qdf_mem_copy(entry->bssid.bytes,
7621 bssid, QDF_MAC_ADDR_SIZE);
7622 entry->retry_delay = rssi_assoc_rej->retry_delay *
7623 QDF_MC_TIMER_TO_MS_UNIT;
7624 entry->expected_rssi = rssi + rssi_assoc_rej->delta_rssi;
7625 entry->time_during_rejection =
7626 qdf_do_div(qdf_get_monotonic_boottime(),
7627 QDF_MC_TIMER_TO_MS_UNIT);
7628
7629 if (qdf_list_size(&mac_ctx->roam.rssi_disallow_bssid) >=
7630 MAX_RSSI_AVOID_BSSID_LIST) {
7631 status = lim_assoc_rej_rem_entry_with_lowest_delta(
7632 &mac_ctx->roam.rssi_disallow_bssid);
7633 if (QDF_IS_STATUS_ERROR(status))
7634 pe_err("Failed to remove entry with lowest delta");
7635 }
7636
7637 if (QDF_IS_STATUS_SUCCESS(status))
7638 status = qdf_list_insert_back(
7639 &mac_ctx->roam.rssi_disallow_bssid,
7640 &entry->node);
7641
7642 if (QDF_IS_STATUS_ERROR(status)) {
7643 pe_err("Failed to enqueue bssid entry");
7644 qdf_mem_free(entry);
7645 }
7646}
7647
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007648void lim_decrement_pending_mgmt_count(struct mac_context *mac_ctx)
Sreelakshmi Konamki6d478cd2017-03-28 11:59:25 +05307649{
7650 qdf_spin_lock(&mac_ctx->sys.bbt_mgmt_lock);
7651 if (!mac_ctx->sys.sys_bbt_pending_mgmt_count) {
7652 qdf_spin_unlock(&mac_ctx->sys.bbt_mgmt_lock);
Sreelakshmi Konamki6d478cd2017-03-28 11:59:25 +05307653 return;
7654 }
7655 mac_ctx->sys.sys_bbt_pending_mgmt_count--;
7656 qdf_spin_unlock(&mac_ctx->sys.bbt_mgmt_lock);
7657}
Arif Hussain7631afa2017-02-08 14:35:00 -08007658
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007659struct csr_roam_session *lim_get_session_by_macaddr(struct mac_context *mac_ctx,
Arif Hussain7631afa2017-02-08 14:35:00 -08007660 tSirMacAddr self_mac)
7661{
7662 int i = 0;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307663 struct csr_roam_session *session;
Arif Hussain7631afa2017-02-08 14:35:00 -08007664
7665 if (!mac_ctx || !self_mac) {
7666 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
7667 FL("Invalid arguments"));
7668 return NULL;
7669 }
7670
7671 for (i = 0; i < mac_ctx->sme.max_intf_count; i++) {
7672 session = CSR_GET_SESSION(mac_ctx, i);
7673 if (!session)
7674 continue;
7675 else if (!qdf_mem_cmp(&session->selfMacAddr,
7676 self_mac, sizeof(tSirMacAddr))) {
7677
7678 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
7679 FL("session %d exists with mac address "
7680 MAC_ADDRESS_STR), session->sessionId,
7681 MAC_ADDR_ARRAY(self_mac));
7682
7683 return session;
7684 }
7685 }
7686
7687 return NULL;
7688}
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307689
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007690bool lim_check_if_vendor_oui_match(struct mac_context *mac_ctx,
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307691 uint8_t *oui, uint8_t oui_len,
7692 uint8_t *ie, uint8_t ie_len)
7693{
7694 uint8_t *ptr = ie;
Abhishek Singhe4b6b4e2017-05-05 19:00:17 +05307695 uint8_t elem_id;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307696
7697 if (NULL == ie || 0 == ie_len) {
7698 pe_err("IE Null or ie len zero %d", ie_len);
7699 return false;
7700 }
7701
Abhishek Singhe4b6b4e2017-05-05 19:00:17 +05307702 elem_id = *ie;
7703
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307704 if (elem_id == IE_EID_VENDOR &&
7705 !qdf_mem_cmp(&ptr[2], oui, oui_len))
7706 return true;
7707 else
7708 return false;
7709}
Sandeep Puligillad9f88ce2017-04-11 19:41:57 -07007710
7711QDF_STATUS lim_util_get_type_subtype(void *pkt, uint8_t *type,
7712 uint8_t *subtype)
7713{
7714 cds_pkt_t *cds_pkt;
7715 QDF_STATUS status;
7716 tpSirMacMgmtHdr hdr;
7717 uint8_t *rxpktinfor;
7718
7719 cds_pkt = (cds_pkt_t *) pkt;
7720 if (!cds_pkt) {
7721 pe_err("NULL packet received");
7722 return QDF_STATUS_E_FAILURE;
7723 }
7724 status =
7725 wma_ds_peek_rx_packet_info(cds_pkt, (void *)&rxpktinfor, false);
7726 if (!QDF_IS_STATUS_SUCCESS(status)) {
7727 pe_err("Failed extract cds packet. status %d", status);
7728 return QDF_STATUS_E_FAILURE;
7729 }
7730
7731 hdr = WMA_GET_RX_MAC_HEADER(rxpktinfor);
7732 if (hdr->fc.type == SIR_MAC_MGMT_FRAME) {
Arif Hussainda9ba082017-11-02 23:33:54 -07007733 pe_debug("RxBd: %pK mHdr: %pK Type: %d Subtype: %d SizeFC: %zu",
7734 rxpktinfor, hdr, hdr->fc.type, hdr->fc.subType,
7735 sizeof(tSirMacFrameCtl));
Sandeep Puligillad9f88ce2017-04-11 19:41:57 -07007736 *type = hdr->fc.type;
7737 *subtype = hdr->fc.subType;
7738 } else {
Jeff Johnson47d75242018-05-12 15:58:53 -07007739 pe_err("Not a management packet type %d", hdr->fc.type);
Sandeep Puligillad9f88ce2017-04-11 19:41:57 -07007740 return QDF_STATUS_E_INVAL;
7741 }
7742 return QDF_STATUS_SUCCESS;
7743}
Naveen Rawat296a5182017-09-25 14:02:48 -07007744
Jeff Johnsonc8baa902018-11-18 21:59:07 -08007745enum rateid lim_get_min_session_txrate(struct pe_session *session)
Naveen Rawat296a5182017-09-25 14:02:48 -07007746{
7747 enum rateid rid = RATEID_DEFAULT;
7748 uint8_t min_rate = SIR_MAC_RATE_54, curr_rate, i;
7749 tSirMacRateSet *rateset = &session->rateSet;
7750
7751 if (!session)
7752 return rid;
7753
7754 for (i = 0; i < rateset->numRates; i++) {
7755 /* Ignore MSB - set to indicate basic rate */
7756 curr_rate = rateset->rate[i] & 0x7F;
7757 min_rate = (curr_rate < min_rate) ? curr_rate : min_rate;
7758 }
7759 pe_debug("supported min_rate: %0x(%d)", min_rate, min_rate);
7760
7761 switch (min_rate) {
7762 case SIR_MAC_RATE_1:
7763 rid = RATEID_1MBPS;
7764 break;
7765 case SIR_MAC_RATE_2:
7766 rid = RATEID_2MBPS;
7767 break;
7768 case SIR_MAC_RATE_5_5:
7769 rid = RATEID_5_5MBPS;
7770 break;
7771 case SIR_MAC_RATE_11:
7772 rid = RATEID_11MBPS;
7773 break;
7774 case SIR_MAC_RATE_6:
7775 rid = RATEID_6MBPS;
7776 break;
7777 case SIR_MAC_RATE_9:
7778 rid = RATEID_9MBPS;
7779 break;
7780 case SIR_MAC_RATE_12:
7781 rid = RATEID_12MBPS;
7782 break;
7783 case SIR_MAC_RATE_18:
7784 rid = RATEID_18MBPS;
7785 break;
7786 case SIR_MAC_RATE_24:
7787 rid = RATEID_24MBPS;
7788 break;
7789 case SIR_MAC_RATE_36:
7790 rid = RATEID_36MBPS;
7791 break;
7792 case SIR_MAC_RATE_48:
7793 rid = RATEID_48MBPS;
7794 break;
7795 case SIR_MAC_RATE_54:
7796 rid = RATEID_54MBPS;
7797 break;
7798 default:
7799 rid = RATEID_DEFAULT;
7800 break;
7801 }
7802
7803 return rid;
7804}
Abhinav Kumar49d08a72018-02-14 17:36:12 +05307805
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007806void lim_convert_active_channel_to_passive_channel(struct mac_context *mac_ctx)
Abhinav Kumar49d08a72018-02-14 17:36:12 +05307807{
7808 uint64_t current_time;
7809 uint64_t last_time = 0;
7810 uint64_t time_diff;
7811 uint8_t i;
7812
7813 current_time = (uint64_t)qdf_mc_timer_get_system_time();
7814 for (i = 1; i < SIR_MAX_24G_5G_CHANNEL_RANGE; i++) {
7815 if ((mac_ctx->lim.dfschannelList.timeStamp[i]) != 0) {
7816 last_time = mac_ctx->lim.dfschannelList.timeStamp[i];
7817 if (current_time >= last_time) {
7818 time_diff = (current_time - last_time);
7819 } else {
7820 time_diff =
7821 (0xFFFFFFFF - last_time) + current_time;
7822 }
7823
7824 if (time_diff >= MAX_TIME_TO_BE_ACTIVE_CHANNEL) {
7825 lim_covert_channel_scan_type(mac_ctx, i, false);
7826 mac_ctx->lim.dfschannelList.timeStamp[i] = 0;
7827 }
7828 }
7829 }
7830 /*
7831 * last_time is zero if there is no DFS active channels in the list.
7832 * If this is non zero then we have active DFS channels so restart
7833 * the timer.
7834 */
7835 if (last_time != 0) {
7836 if (tx_timer_activate
7837 (&mac_ctx->lim.limTimers.gLimActiveToPassiveChannelTimer)
7838 != TX_SUCCESS) {
7839 pe_err("Active to Passive Channel timer not activated");
7840 }
7841 }
7842 return;
7843}
7844
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007845void lim_send_sme_mgmt_frame_ind(struct mac_context *mac_ctx, uint8_t frame_type,
Abhinav Kumar49d08a72018-02-14 17:36:12 +05307846 uint8_t *frame, uint32_t frame_len,
7847 uint16_t session_id, uint32_t rx_channel,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08007848 struct pe_session *psession_entry, int8_t rx_rssi)
Abhinav Kumar49d08a72018-02-14 17:36:12 +05307849{
7850 tpSirSmeMgmtFrameInd sme_mgmt_frame = NULL;
7851 uint16_t length;
7852
7853 length = sizeof(tSirSmeMgmtFrameInd) + frame_len;
7854
7855 sme_mgmt_frame = qdf_mem_malloc(length);
Arif Hussainf5b6c412018-10-10 19:41:09 -07007856 if (!sme_mgmt_frame)
Abhinav Kumar49d08a72018-02-14 17:36:12 +05307857 return;
Abhinav Kumar49d08a72018-02-14 17:36:12 +05307858
7859 if (qdf_is_macaddr_broadcast(
Varun Reddy Yeturu8e94f722018-05-17 14:57:18 -07007860 (struct qdf_mac_addr *)(frame + 4)) &&
Abhinav Kumar49d08a72018-02-14 17:36:12 +05307861 !session_id) {
7862 pe_debug("Broadcast action frame");
7863 session_id = SME_SESSION_ID_BROADCAST;
7864 }
7865
7866 sme_mgmt_frame->frame_len = frame_len;
7867 sme_mgmt_frame->sessionId = session_id;
7868 sme_mgmt_frame->frameType = frame_type;
7869 sme_mgmt_frame->rxRssi = rx_rssi;
7870 sme_mgmt_frame->rxChan = rx_channel;
7871
7872 qdf_mem_zero(sme_mgmt_frame->frameBuf, frame_len);
7873 qdf_mem_copy(sme_mgmt_frame->frameBuf, frame, frame_len);
7874
7875 if (mac_ctx->mgmt_frame_ind_cb)
7876 mac_ctx->mgmt_frame_ind_cb(sme_mgmt_frame);
7877 else
7878 pe_debug_rl("Management indication callback not registered!!");
7879 qdf_mem_free(sme_mgmt_frame);
7880 return;
7881}
7882
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05307883void
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007884lim_send_dfs_chan_sw_ie_update(struct mac_context *mac_ctx, struct pe_session *session)
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05307885{
7886 /* Update the beacon template and send to FW */
7887 if (sch_set_fixed_beacon_fields(mac_ctx, session) !=
7888 QDF_STATUS_SUCCESS) {
7889 pe_err("Unable to set CSA IE in beacon");
7890 return;
7891 }
7892
7893 /* Send update beacon template message */
Abhishek Singhfc740be2018-10-12 11:34:26 +05307894 lim_send_beacon_ind(mac_ctx, session, REASON_CHANNEL_SWITCH);
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05307895 pe_debug("Updated CSA IE, IE COUNT: %d",
7896 session->gLimChannelSwitch.switchCount);
7897}
7898
7899void lim_process_ap_ecsa_timeout(void *data)
7900{
Jeff Johnsonc8baa902018-11-18 21:59:07 -08007901 struct pe_session *session = (struct pe_session *)data;
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007902 struct mac_context *mac_ctx;
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05307903 uint8_t bcn_int, ch, ch_width;
7904 QDF_STATUS status;
7905
7906 if (!session) {
7907 pe_err("Session is NULL");
7908 return;
7909 }
7910
Abhishek Singhdfa69c32018-08-30 15:39:34 +05307911 mac_ctx = session->mac_ctx;
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05307912
7913 if (!session->dfsIncludeChanSwIe) {
7914 pe_debug("session->dfsIncludeChanSwIe not set");
7915 return;
7916 }
7917
7918 if (session->gLimChannelSwitch.switchCount) {
7919 /* Decrement the beacon switch count */
7920 session->gLimChannelSwitch.switchCount--;
7921 pe_debug("current beacon count %d",
7922 session->gLimChannelSwitch.switchCount);
7923 }
7924
7925 /*
7926 * Send only g_sap_chanswitch_beacon_cnt beacons with CSA IE Set in
7927 * when a radar is detected
7928 */
7929 if (session->gLimChannelSwitch.switchCount > 0) {
7930 /* Send the next beacon with updated CSA IE count */
7931 lim_send_dfs_chan_sw_ie_update(mac_ctx, session);
7932
7933 ch = session->gLimChannelSwitch.primaryChannel;
7934 ch_width = session->gLimChannelSwitch.ch_width;
Arif Hussain224d3812018-11-16 17:58:38 -08007935 if (mac_ctx->mlme_cfg->dfs_cfg.dfs_beacon_tx_enhanced)
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05307936 /* Send Action frame after updating beacon */
7937 lim_send_chan_switch_action_frame(mac_ctx, ch, ch_width,
7938 session);
7939
7940 /* Restart the timer */
7941 if (session->beaconParams.beaconInterval)
7942 bcn_int = session->beaconParams.beaconInterval;
7943 else
Pragaspathi Thilagaraj3cf0f652018-10-29 16:40:35 +05307944 bcn_int = MLME_CFG_BEACON_INTERVAL_DEF;
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05307945
Dustin Brown7dede432018-08-15 17:26:31 -07007946 status = qdf_mc_timer_start(&session->ap_ecsa_timer,
7947 bcn_int);
7948 if (QDF_IS_STATUS_ERROR(status)) {
7949 pe_err("cannot start ap_ecsa_timer");
7950 lim_process_ap_ecsa_timeout(session);
7951 }
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05307952 } else {
7953 tSirSmeCSAIeTxCompleteRsp *chan_switch_tx_rsp;
7954 struct scheduler_msg msg = {0};
7955 uint8_t length = sizeof(*chan_switch_tx_rsp);
7956
7957 /* Done with CSA IE update, send response back to SME */
7958 session->gLimChannelSwitch.switchCount = 0;
7959 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
7960 session->gLimChannelSwitch.switchMode = 0;
7961 session->dfsIncludeChanSwIe = false;
7962 session->dfsIncludeChanWrapperIe = false;
7963
7964 chan_switch_tx_rsp = qdf_mem_malloc(length);
Arif Hussainf5b6c412018-10-10 19:41:09 -07007965 if (!chan_switch_tx_rsp)
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05307966 return;
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05307967
7968 chan_switch_tx_rsp->sessionId = session->smeSessionId;
7969 chan_switch_tx_rsp->chanSwIeTxStatus = QDF_STATUS_SUCCESS;
7970
7971 msg.type = eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND;
7972 msg.bodyptr = chan_switch_tx_rsp;
7973
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05307974 status = scheduler_post_message(QDF_MODULE_ID_PE,
7975 QDF_MODULE_ID_SME,
7976 QDF_MODULE_ID_SME, &msg);
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05307977 if (QDF_IS_STATUS_ERROR(status)) {
7978 sme_err("Failed to post eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND");
7979 qdf_mem_free(chan_switch_tx_rsp);
7980 }
7981 }
7982}
Abhishek Singhdfa69c32018-08-30 15:39:34 +05307983
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05307984#ifdef CONFIG_VDEV_SM
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07007985QDF_STATUS lim_sta_mlme_vdev_start_send(struct vdev_mlme_obj *vdev_mlme,
7986 uint16_t data_len, void *data)
7987{
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007988 struct mac_context *mac_ctx;
Jianmin Zhu09236602018-10-15 15:36:10 +08007989 enum vdev_assoc_type assoc_type;
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07007990
7991 mac_ctx = cds_get_context(QDF_MODULE_ID_PE);
7992 if (!mac_ctx) {
7993 pe_err("mac_ctx is NULL");
7994 if (data)
7995 qdf_mem_free(data);
7996 return QDF_STATUS_E_INVAL;
7997 }
7998
Jianmin Zhu09236602018-10-15 15:36:10 +08007999 assoc_type = mlme_get_assoc_type(vdev_mlme->vdev);
8000 switch (assoc_type) {
8001 case VDEV_ASSOC:
8002 lim_process_mlm_join_req(mac_ctx, (tLimMlmJoinReq *)data);
8003 break;
8004 case VDEV_REASSOC:
8005 lim_process_mlm_reassoc_req(mac_ctx, (tLimMlmReassocReq *)data);
8006 break;
8007 case VDEV_FT_REASSOC:
Abhishek Singh254d5512018-10-30 12:17:05 +05308008 lim_process_mlm_ft_reassoc_req(mac_ctx,
8009 (tLimMlmReassocReq *)data);
Jianmin Zhu09236602018-10-15 15:36:10 +08008010 break;
8011 default:
8012 pe_err("assoc_type %d is invalid", assoc_type);
8013 }
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07008014 return QDF_STATUS_SUCCESS;
8015}
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308016
Jianmin Zhu69e7bf32018-11-22 11:56:10 +08008017QDF_STATUS lim_sta_mlme_vdev_restart_send(struct vdev_mlme_obj *vdev_mlme,
8018 uint16_t data_len, void *data)
8019{
8020 if (!vdev_mlme) {
8021 pe_err("vdev_mlme is NULL");
8022 return QDF_STATUS_E_INVAL;
8023 }
8024 if (!data) {
8025 pe_err("event_data is NULL");
8026 return QDF_STATUS_E_INVAL;
8027 }
8028 if (mlme_is_chan_switch_in_progress(vdev_mlme->vdev))
Jeff Johnsond01da6b2018-12-02 12:10:22 -08008029 __lim_process_channel_switch_timeout((struct mac_context *)data);
Jianmin Zhu69e7bf32018-11-22 11:56:10 +08008030
8031 return QDF_STATUS_SUCCESS;
8032}
8033
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07008034QDF_STATUS lim_sta_mlme_vdev_stop_send(struct vdev_mlme_obj *vdev_mlme,
8035 uint16_t data_len, void *data)
8036{
Sandeep Puligilla2a7fa842018-10-02 01:00:56 -07008037 QDF_STATUS status;
8038 bool connection_fail;
8039
Jianmin Zhu69e7bf32018-11-22 11:56:10 +08008040 if (!vdev_mlme) {
8041 pe_err("vdev_mlme is NULL");
8042 return QDF_STATUS_E_INVAL;
8043 }
Sandeep Puligilla2a7fa842018-10-02 01:00:56 -07008044 if (!data) {
8045 pe_err("event_data is NULL");
8046 return QDF_STATUS_E_INVAL;
8047 }
8048
8049 connection_fail = mlme_is_connection_fail(vdev_mlme->vdev);
8050 pe_info("Send vdev stop, connection_fail %d", connection_fail);
8051 if (connection_fail) {
8052 status = lim_sta_send_down_link((join_params *)data);
8053 mlme_set_connection_fail(vdev_mlme->vdev, false);
8054 } else {
Jeff Johnsonc8baa902018-11-18 21:59:07 -08008055 status = lim_sta_send_del_bss((struct pe_session *)data);
Sandeep Puligilla2a7fa842018-10-02 01:00:56 -07008056 }
8057
8058 return status;
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07008059}
8060
Jeff Johnsond01da6b2018-12-02 12:10:22 -08008061void lim_send_beacon(struct mac_context *mac_ctx, struct pe_session *session)
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308062{
8063 if (wlan_vdev_mlme_get_state(session->vdev) ==
8064 WLAN_VDEV_S_DFS_CAC_WAIT)
8065 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
8066 WLAN_VDEV_SM_EV_DFS_CAC_COMPLETED,
8067 sizeof(*session), session);
8068 else
8069 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
8070 WLAN_VDEV_SM_EV_START_SUCCESS,
8071 sizeof(*session), session);
8072}
8073
Jeff Johnsonc8baa902018-11-18 21:59:07 -08008074void lim_ndi_mlme_vdev_up_transition(struct pe_session *session)
Manikandan Mohan4cc1c5a2018-10-09 13:25:30 -07008075{
8076 if (!LIM_IS_NDI_ROLE(session))
8077 return;
8078
8079 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
8080 WLAN_VDEV_SM_EV_START_SUCCESS,
8081 sizeof(*session), session);
8082}
8083
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308084QDF_STATUS lim_ap_mlme_vdev_start_send(struct vdev_mlme_obj *vdev_mlme,
8085 uint16_t data_len, void *data)
8086{
Jeff Johnsonc8baa902018-11-18 21:59:07 -08008087 struct pe_session *session;
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +05308088 tSirResultCodes ret;
8089 tpLimMlmStartReq start_req = (tLimMlmStartReq *)data;
Jeff Johnsond01da6b2018-12-02 12:10:22 -08008090 struct mac_context *mac_ctx;
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308091
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +05308092 if (!data) {
8093 pe_err("data is NULL");
8094 return QDF_STATUS_E_INVAL;
8095 }
8096
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308097 mac_ctx = cds_get_context(QDF_MODULE_ID_PE);
8098 if (!mac_ctx) {
8099 pe_err("mac_ctx is NULL");
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308100 return QDF_STATUS_E_INVAL;
8101 }
8102
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +05308103 session = pe_find_session_by_session_id(mac_ctx,
8104 start_req->sessionId);
8105 if (!session) {
8106 pe_err("session is NULL");
8107 return QDF_STATUS_E_INVAL;
8108 }
8109
8110 if (LIM_IS_IBSS_ROLE(session) &&
8111 session->mac_ctx->lim.gLimIbssCoalescingHappened) {
8112 ibss_bss_add(session->mac_ctx, session);
8113 ret = lim_mlm_add_bss(session->mac_ctx, start_req, session);
8114 if (ret != eSIR_SME_SUCCESS) {
8115 pe_err("AddBss failure");
8116 return QDF_STATUS_E_INVAL;
8117 }
8118 } else {
8119 lim_process_mlm_start_req(session->mac_ctx, start_req);
8120 }
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308121
8122 return QDF_STATUS_SUCCESS;
8123}
8124
Jeff Johnsond01da6b2018-12-02 12:10:22 -08008125static inline void lim_send_csa_restart_resp(struct mac_context *mac_ctx,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08008126 struct pe_session *session)
Abhishek Singh20a8e442018-09-12 15:50:44 +05308127{
8128 struct scheduler_msg msg = {0};
8129 QDF_STATUS status;
8130
8131 msg.type = eWNI_SME_CSA_RESTART_RSP;
8132 msg.bodyptr = NULL;
8133 msg.bodyval = session->smeSessionId;
8134
8135 status = scheduler_post_msg(QDF_MODULE_ID_SME, &msg);
8136 if (QDF_IS_STATUS_ERROR(status))
8137 sme_err("Failed to post eWNI_SME_CSA_RESTART_RSP");
8138}
8139
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308140QDF_STATUS lim_ap_mlme_vdev_update_beacon(struct vdev_mlme_obj *vdev_mlme,
8141 enum beacon_update_op op,
8142 uint16_t data_len, void *data)
8143{
Jeff Johnsonc8baa902018-11-18 21:59:07 -08008144 struct pe_session *session;
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308145
8146 if (!data) {
8147 pe_err("event_data is NULL");
8148 return QDF_STATUS_E_INVAL;
8149 }
Jeff Johnsonc8baa902018-11-18 21:59:07 -08008150 session = (struct pe_session *)data;
Manikandan Mohan4cc1c5a2018-10-09 13:25:30 -07008151 if (LIM_IS_NDI_ROLE(session))
8152 return QDF_STATUS_SUCCESS;
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308153
Abhishek Singh20a8e442018-09-12 15:50:44 +05308154 if (op == BEACON_INIT)
Abhishek Singhfc740be2018-10-12 11:34:26 +05308155 lim_send_beacon_ind(session->mac_ctx, session, REASON_DEFAULT);
Abhishek Singh20a8e442018-09-12 15:50:44 +05308156 else if (op == BEACON_CSA)
8157 lim_send_csa_restart_resp(session->mac_ctx, session);
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308158
8159 return QDF_STATUS_SUCCESS;
8160}
8161
8162QDF_STATUS lim_ap_mlme_vdev_up_send(struct vdev_mlme_obj *vdev_mlme,
8163 uint16_t data_len, void *data)
8164{
8165 struct scheduler_msg msg = {0};
8166 QDF_STATUS status;
Jeff Johnsonc8baa902018-11-18 21:59:07 -08008167 struct pe_session *session = (struct pe_session *)data;
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308168
8169 if (!session) {
8170 pe_err("session is NULL");
8171 return QDF_STATUS_E_INVAL;
8172 }
Manikandan Mohan4cc1c5a2018-10-09 13:25:30 -07008173 if (LIM_IS_NDI_ROLE(session))
8174 return QDF_STATUS_SUCCESS;
8175
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308176
8177 msg.type = SIR_HAL_SEND_AP_VDEV_UP;
8178 msg.bodyval = session->smeSessionId;
8179
8180 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
8181 if (QDF_IS_STATUS_ERROR(status))
8182 WMA_LOGE("Failed to post SIR_HAL_SEND_AP_VDEV_UP");
8183
8184 return status;
8185}
8186
Abhishek Singhcaa61852018-09-12 15:50:04 +05308187QDF_STATUS lim_ap_mlme_vdev_disconnect_peers(struct vdev_mlme_obj *vdev_mlme,
8188 uint16_t data_len, void *data)
8189{
Jeff Johnsonc8baa902018-11-18 21:59:07 -08008190 struct pe_session *session = (struct pe_session *)data;
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +05308191
8192 if (!data) {
8193 pe_err("data is NULL");
8194 return QDF_STATUS_E_INVAL;
8195 }
8196
8197 if (LIM_IS_IBSS_ROLE(session))
8198 lim_ibss_delete_all_peers(session->mac_ctx, session);
8199 else
8200 lim_delete_all_peers(session);
Abhishek Singhcaa61852018-09-12 15:50:04 +05308201
8202 return QDF_STATUS_SUCCESS;
8203}
8204
8205QDF_STATUS lim_ap_mlme_vdev_stop_send(struct vdev_mlme_obj *vdev_mlme,
8206 uint16_t data_len, void *data)
8207{
Jeff Johnsonc8baa902018-11-18 21:59:07 -08008208 struct pe_session *session = (struct pe_session *)data;
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +05308209 QDF_STATUS status = QDF_STATUS_SUCCESS;
8210
8211 if (!data) {
8212 pe_err("data is NULL");
8213 return QDF_STATUS_E_INVAL;
8214 }
8215
8216 if (LIM_IS_IBSS_ROLE(session) &&
8217 session->mac_ctx->lim.gLimIbssCoalescingHappened)
8218 ibss_bss_delete(session->mac_ctx, session);
8219 else
8220 status = lim_send_vdev_stop(session);
8221
8222 return status;
Abhishek Singhcaa61852018-09-12 15:50:04 +05308223}
8224
Abhishek Singh20a8e442018-09-12 15:50:44 +05308225QDF_STATUS lim_ap_mlme_vdev_restart_send(struct vdev_mlme_obj *vdev_mlme,
8226 uint16_t data_len, void *data)
8227{
Jeff Johnsonc8baa902018-11-18 21:59:07 -08008228 struct pe_session *session = (struct pe_session *)data;
Abhishek Singh20a8e442018-09-12 15:50:44 +05308229
8230 if (!data) {
8231 pe_err("data is NULL");
8232 return QDF_STATUS_E_INVAL;
8233 }
8234
Abhishek Singha063f1c2018-09-19 11:37:51 +05308235 if (ap_mlme_is_hidden_ssid_restart_in_progress(vdev_mlme->vdev))
Abhishek Singh6c681f42018-09-12 15:52:36 +05308236 lim_send_vdev_restart(session->mac_ctx, session,
8237 session->smeSessionId);
8238 else
8239 lim_set_channel(session->mac_ctx, session->currentOperChannel,
8240 session->ch_center_freq_seg0,
8241 session->ch_center_freq_seg1,
8242 session->ch_width, session->maxTxPower,
8243 session->peSessionId, session->cac_duration_ms,
8244 session->dfs_regdomain);
Abhishek Singh20a8e442018-09-12 15:50:44 +05308245
8246 return QDF_STATUS_SUCCESS;
8247}
8248
Abhishek Singhc5a54082018-09-12 16:08:03 +05308249QDF_STATUS lim_ap_mlme_vdev_start_req_failed(struct vdev_mlme_obj *vdev_mlme,
8250 uint16_t data_len, void *data)
8251{
Jeff Johnsond01da6b2018-12-02 12:10:22 -08008252 struct mac_context *mac_ctx;
Abhishek Singhc5a54082018-09-12 16:08:03 +05308253
8254 /* store mac ctx in vdev_mlme legacy_vdev_ptr?*/
8255 mac_ctx = cds_get_context(QDF_MODULE_ID_PE);
8256 if (!mac_ctx) {
8257 pe_err("mac_ctx is NULL");
8258 if (data)
8259 qdf_mem_free(data);
8260 return QDF_STATUS_E_INVAL;
8261 }
8262
8263 lim_process_mlm_start_cnf(mac_ctx, data);
8264
8265 return QDF_STATUS_SUCCESS;
8266}
8267
Jeff Johnsond01da6b2018-12-02 12:10:22 -08008268void lim_send_start_bss_confirm(struct mac_context *mac_ctx,
Abhishek Singhc5a54082018-09-12 16:08:03 +05308269 tLimMlmStartCnf *start_cnf)
8270{
8271 if (start_cnf->resultCode == eSIR_SME_SUCCESS) {
8272 lim_post_sme_message(mac_ctx, LIM_MLM_START_CNF,
8273 (uint32_t *)start_cnf);
8274 } else {
Jeff Johnsonc8baa902018-11-18 21:59:07 -08008275 struct pe_session *session;
Abhishek Singhc5a54082018-09-12 16:08:03 +05308276
8277 session = pe_find_session_by_session_id(mac_ctx,
8278 start_cnf->sessionId);
8279 if (!session) {
8280 pe_err("session is NULL");
8281 return;
8282 }
Abhishek Singha063f1c2018-09-19 11:37:51 +05308283 mlme_set_vdev_start_failed(session->vdev, true);
Abhishek Singhc5a54082018-09-12 16:08:03 +05308284 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
8285 WLAN_VDEV_SM_EV_START_REQ_FAIL,
8286 sizeof(*start_cnf), start_cnf);
8287 }
8288}
8289
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308290#else
8291
Jeff Johnsond01da6b2018-12-02 12:10:22 -08008292void lim_send_start_bss_confirm(struct mac_context *mac_ctx,
Abhishek Singhc5a54082018-09-12 16:08:03 +05308293 tLimMlmStartCnf *start_cnf)
8294{
8295 lim_post_sme_message(mac_ctx, LIM_MLM_START_CNF,
8296 (uint32_t *)start_cnf);
8297}
8298
Jeff Johnsond01da6b2018-12-02 12:10:22 -08008299void lim_send_beacon(struct mac_context *mac_ctx, struct pe_session *session)
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308300{
Abhishek Singhfc740be2018-10-12 11:34:26 +05308301 lim_send_beacon_ind(mac_ctx, session, REASON_DEFAULT);
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308302}
Manikandan Mohan4cc1c5a2018-10-09 13:25:30 -07008303
Jeff Johnsonc8baa902018-11-18 21:59:07 -08008304void lim_ndi_mlme_vdev_up_transition(struct pe_session *session)
Manikandan Mohan4cc1c5a2018-10-09 13:25:30 -07008305{
8306}
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308307#endif