blob: a4f007b3aad905d0e954ff78fb96242b7018ebbc [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;
2485 uint32_t cfgValue;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002486 tSirMacTxBFCapabilityInfo macTxBFCapabilityInfo = { 0 };
2487 tSirMacASCapabilityInfo macASCapabilityInfo = { 0 };
2488
2489 /* */
2490 /* Determine which CFG to read from. Not ALL of the HT */
2491 /* related CFG's need to be read each time this API is */
2492 /* accessed */
2493 /* */
2494 if (htCap >= eHT_ANTENNA_SELECTION && htCap < eHT_SI_GRANULARITY) {
2495 /* Get Antenna Seletion HT Capabilities */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002496 if (QDF_STATUS_SUCCESS !=
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002497 wlan_cfg_get_int(mac, WNI_CFG_AS_CAP, &cfgValue))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002498 cfgValue = 0;
2499 ptr = (uint8_t *) &macASCapabilityInfo;
2500 *((uint8_t *) ptr) = (uint8_t) (cfgValue & 0xff);
Vignesh Viswanathanddc89e52018-11-02 18:43:42 +05302501 } else if (htCap >= eHT_TX_BEAMFORMING &&
2502 htCap < eHT_ANTENNA_SELECTION) {
2503 /* Get Transmit Beam Forming HT Capabilities */
2504 if (QDF_STATUS_SUCCESS !=
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002505 wlan_cfg_get_int(mac, WNI_CFG_TX_BF_CAP, &cfgValue))
Vignesh Viswanathanddc89e52018-11-02 18:43:42 +05302506 cfgValue = 0;
2507 ptr = (uint8_t *)&macTxBFCapabilityInfo;
2508 *((uint32_t *)ptr) = (uint32_t)(cfgValue);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002509 }
2510
2511 switch (htCap) {
2512 case eHT_LSIG_TXOP_PROTECTION:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002513 retVal = mac->lim.gHTLsigTXOPProtection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002514 break;
2515
2516 case eHT_STBC_CONTROL_FRAME:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002517 retVal = (uint8_t)mac->mlme_cfg->ht_caps.ht_cap_info.
Vignesh Viswanathanddc89e52018-11-02 18:43:42 +05302518 stbc_control_frame;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002519 break;
2520
2521 case eHT_PSMP:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002522 retVal = mac->lim.gHTPSMPSupport;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002523 break;
2524
2525 case eHT_DSSS_CCK_MODE_40MHZ:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002526 retVal = mac->lim.gHTDsssCckRate40MHzSupport;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002527 break;
2528
2529 case eHT_MAX_AMSDU_LENGTH:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002530 retVal = (uint8_t)mac->mlme_cfg->ht_caps.ht_cap_info.
Vignesh Viswanathanddc89e52018-11-02 18:43:42 +05302531 maximal_amsdu_size;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002532 break;
2533
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07002534 case eHT_MAX_AMSDU_NUM:
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002535 retVal = (uint8_t) pe_session->max_amsdu_num;
Deepak Dhamdhere612392c2016-08-28 02:56:51 -07002536 break;
2537
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002538 case eHT_RX_STBC:
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002539 retVal = (uint8_t) pe_session->htConfig.ht_rx_stbc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002540 break;
2541
2542 case eHT_TX_STBC:
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002543 retVal = (uint8_t) pe_session->htConfig.ht_tx_stbc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002544 break;
2545
2546 case eHT_SHORT_GI_40MHZ:
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002547 retVal = (uint8_t)(pe_session->htConfig.ht_sgi40) ?
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002548 mac->mlme_cfg->ht_caps.ht_cap_info.short_gi_40_mhz : 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002549 break;
2550
2551 case eHT_SHORT_GI_20MHZ:
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002552 retVal = (uint8_t)(pe_session->htConfig.ht_sgi20) ?
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002553 mac->mlme_cfg->ht_caps.ht_cap_info.short_gi_20_mhz : 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002554 break;
2555
2556 case eHT_GREENFIELD:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002557 retVal = (uint8_t)mac->mlme_cfg->ht_caps.ht_cap_info.
Vignesh Viswanathanddc89e52018-11-02 18:43:42 +05302558 green_field;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002559 break;
2560
2561 case eHT_MIMO_POWER_SAVE:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002562 retVal = (uint8_t) mac->lim.gHTMIMOPSState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002563 break;
2564
2565 case eHT_SUPPORTED_CHANNEL_WIDTH_SET:
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002566 retVal = (uint8_t) pe_session->htSupportedChannelWidthSet;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002567 break;
2568
2569 case eHT_ADVANCED_CODING:
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002570 retVal = (uint8_t) pe_session->htConfig.ht_rx_ldpc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002571 break;
2572
2573 case eHT_MAX_RX_AMPDU_FACTOR:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002574 retVal = mac->lim.gHTMaxRxAMpduFactor;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002575 break;
2576
2577 case eHT_MPDU_DENSITY:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002578 retVal = mac->lim.gHTAMpduDensity;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002579 break;
2580
2581 case eHT_PCO:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002582 retVal = (uint8_t)mac->mlme_cfg->ht_caps.ext_cap_info.pco;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002583 break;
2584
2585 case eHT_TRANSITION_TIME:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002586 retVal = (uint8_t)mac->mlme_cfg->ht_caps.ext_cap_info.
Vignesh Viswanathanddc89e52018-11-02 18:43:42 +05302587 transition_time;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002588 break;
2589
2590 case eHT_MCS_FEEDBACK:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002591 retVal = (uint8_t)mac->mlme_cfg->ht_caps.ext_cap_info.
Vignesh Viswanathanddc89e52018-11-02 18:43:42 +05302592 mcs_feedback;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002593 break;
2594
2595 case eHT_TX_BEAMFORMING:
2596 retVal = (uint8_t) macTxBFCapabilityInfo.txBF;
2597 break;
2598
2599 case eHT_ANTENNA_SELECTION:
2600 retVal = (uint8_t) macASCapabilityInfo.antennaSelection;
2601 break;
2602
2603 case eHT_SI_GRANULARITY:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002604 retVal = mac->lim.gHTServiceIntervalGranularity;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002605 break;
2606
2607 case eHT_CONTROLLED_ACCESS:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002608 retVal = mac->lim.gHTControlledAccessOnly;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002609 break;
2610
2611 case eHT_RIFS_MODE:
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002612 retVal = pe_session->beaconParams.fRIFSMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002613 break;
2614
2615 case eHT_RECOMMENDED_TX_WIDTH_SET:
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002616 retVal = pe_session->htRecommendedTxWidthSet;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002617 break;
2618
2619 case eHT_EXTENSION_CHANNEL_OFFSET:
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002620 retVal = pe_session->htSecondaryChannelOffset;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002621 break;
2622
2623 case eHT_OP_MODE:
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002624 if (LIM_IS_AP_ROLE(pe_session))
2625 retVal = pe_session->htOperMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002626 else
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002627 retVal = mac->lim.gHTOperMode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002628 break;
2629
2630 case eHT_BASIC_STBC_MCS:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002631 retVal = mac->lim.gHTSTBCBasicMCS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002632 break;
2633
2634 case eHT_DUAL_CTS_PROTECTION:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002635 retVal = mac->lim.gHTDualCTSProtection;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002636 break;
2637
2638 case eHT_LSIG_TXOP_PROTECTION_FULL_SUPPORT:
2639 retVal =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08002640 pe_session->beaconParams.fLsigTXOPProtectionFullSupport;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002641 break;
2642
2643 case eHT_PCO_ACTIVE:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002644 retVal = mac->lim.gHTPCOActive;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002645 break;
2646
2647 case eHT_PCO_PHASE:
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08002648 retVal = mac->lim.gHTPCOPhase;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002649 break;
2650
2651 default:
2652 break;
2653 }
2654
2655 return retVal;
2656}
2657
2658/**
2659 * lim_enable_11a_protection() - updates protection params for enable 11a
2660 * protection request
2661 * @mac_ctx: pointer to Global MAC structure
2662 * @overlap: 1=> called from overlap context, 0 => called from assoc context.
2663 * @bcn_prms: beacon parameters
2664 * @pe_session: pe session entry
2665 *
Jeff Johnson47d75242018-05-12 15:58:53 -07002666 * This function updates protection params for enable 11a protection request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002667 *
2668 * @Return: void
2669 */
2670static void
Jeff Johnsond01da6b2018-12-02 12:10:22 -08002671lim_enable_11a_protection(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002672 uint8_t overlap,
2673 tpUpdateBeaconParams bcn_prms,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08002674 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002675{
2676 /*
2677 * If we are AP and HT capable, we need to set the HT OP mode
2678 * appropriately.
2679 */
Rajeev Kumar0ac9f2a2016-04-15 15:54:18 -07002680 if (LIM_IS_AP_ROLE(pe_session) && (true == pe_session->htCapability)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002681 if (overlap) {
Arif Hussain1cd8abf2017-12-17 19:37:50 -08002682 pe_session->gLimOverlap11aParams.protectionEnabled =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002683 true;
2684 if ((eSIR_HT_OP_MODE_OVERLAP_LEGACY !=
2685 mac_ctx->lim.gHTOperMode)
2686 && (eSIR_HT_OP_MODE_MIXED !=
2687 mac_ctx->lim.gHTOperMode)) {
2688 mac_ctx->lim.gHTOperMode =
2689 eSIR_HT_OP_MODE_OVERLAP_LEGACY;
2690 pe_session->htOperMode =
2691 eSIR_HT_OP_MODE_OVERLAP_LEGACY;
2692 lim_enable_ht_rifs_protection(mac_ctx, true,
2693 overlap, bcn_prms, pe_session);
2694 lim_enable_ht_obss_protection(mac_ctx, true,
2695 overlap, bcn_prms, pe_session);
2696 }
2697 } else {
2698 pe_session->gLim11aParams.protectionEnabled = true;
2699 if (eSIR_HT_OP_MODE_MIXED != pe_session->htOperMode) {
2700 mac_ctx->lim.gHTOperMode =
2701 eSIR_HT_OP_MODE_MIXED;
2702 pe_session->htOperMode = eSIR_HT_OP_MODE_MIXED;
2703 lim_enable_ht_rifs_protection(mac_ctx, true,
2704 overlap, bcn_prms, pe_session);
2705 lim_enable_ht_obss_protection(mac_ctx, true,
2706 overlap, bcn_prms, pe_session);
2707 }
2708 }
2709 }
2710 /* This part is common for station as well. */
2711 if (false == pe_session->beaconParams.llaCoexist) {
Yeshwanth Sriram Guntukacbe61442018-08-23 18:08:44 +05302712 pe_debug(" => protection from 11A Enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002713 bcn_prms->llaCoexist = true;
2714 pe_session->beaconParams.llaCoexist = true;
2715 bcn_prms->paramChangeBitmap |= PARAM_llACOEXIST_CHANGED;
2716 }
2717}
2718
2719/**
2720 * lim_disable_11a_protection() - updates protection params for disable 11a
2721 * protection request
2722 * @mac_ctx: pointer to Global MAC structure
2723 * @overlap: 1=> called from overlap context, 0 => called from assoc context.
2724 * @bcn_prms: beacon parameters
2725 * @pe_session: pe session entry
2726 *
Jeff Johnson47d75242018-05-12 15:58:53 -07002727 * This function updates protection params for disable 11a protection request
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002728 *
2729 * @Return: void
2730 */
2731static void
Jeff Johnsond01da6b2018-12-02 12:10:22 -08002732lim_disable_11a_protection(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002733 uint8_t overlap,
2734 tpUpdateBeaconParams bcn_prms,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08002735 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002736{
2737 if (false == pe_session->beaconParams.llaCoexist)
2738 return;
2739
2740 /* for station role */
2741 if (!LIM_IS_AP_ROLE(pe_session)) {
yeshwanth sriram guntukaca71d032017-07-20 18:26:35 +05302742 pe_debug("===> Protection from 11A Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002743 bcn_prms->llaCoexist = false;
2744 pe_session->beaconParams.llaCoexist = false;
2745 bcn_prms->paramChangeBitmap |= PARAM_llACOEXIST_CHANGED;
2746 return;
2747 }
2748 /*
2749 * for AP role.
2750 * we need to take care of HT OP mode change if needed.
2751 * We need to take care of Overlap cases.
2752 */
2753 if (overlap) {
2754 /* Overlap Legacy protection disabled. */
Arif Hussain1cd8abf2017-12-17 19:37:50 -08002755 pe_session->gLimOverlap11aParams.protectionEnabled = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002756
2757 /*
2758 * We need to take care of HT OP mode iff we are HT AP.
2759 * OR no HT op-mode change is needed if any of the overlap
2760 * protection enabled.
2761 */
2762 if (!pe_session->htCapability ||
Arif Hussain1cd8abf2017-12-17 19:37:50 -08002763 (pe_session->gLimOverlap11aParams.protectionEnabled
2764 || pe_session->gLimOverlapHt20Params.protectionEnabled
2765 || pe_session->gLimOverlapNonGfParams.protectionEnabled))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002766 goto disable_11a_end;
2767
2768 /* Check if there is a need to change HT OP mode. */
2769 if (eSIR_HT_OP_MODE_OVERLAP_LEGACY ==
2770 mac_ctx->lim.gHTOperMode) {
2771 lim_enable_ht_rifs_protection(mac_ctx, false, overlap,
2772 bcn_prms, pe_session);
2773 lim_enable_ht_obss_protection(mac_ctx, false, overlap,
2774 bcn_prms, pe_session);
2775
2776 if (pe_session->gLimHt20Params.protectionEnabled)
2777 mac_ctx->lim.gHTOperMode =
2778 eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
2779 else
2780 mac_ctx->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
2781 }
2782 } else {
2783 /* Disable protection from 11A stations. */
2784 pe_session->gLim11aParams.protectionEnabled = false;
2785 lim_enable_ht_obss_protection(mac_ctx, false, overlap,
2786 bcn_prms, pe_session);
2787
2788 /*
2789 * Check if any other non-HT protection enabled. Right now we
2790 * are in HT OP Mixed mode. Change HT op mode appropriately.
2791 */
2792
2793 /* Change HT OP mode to 01 if any overlap protection enabled */
Arif Hussain1cd8abf2017-12-17 19:37:50 -08002794 if (pe_session->gLimOverlap11aParams.protectionEnabled
2795 || pe_session->gLimOverlapHt20Params.protectionEnabled
2796 || pe_session->gLimOverlapNonGfParams.protectionEnabled) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002797 mac_ctx->lim.gHTOperMode =
2798 eSIR_HT_OP_MODE_OVERLAP_LEGACY;
2799 pe_session->htOperMode = eSIR_HT_OP_MODE_OVERLAP_LEGACY;
2800 lim_enable_ht_rifs_protection(mac_ctx, true, overlap,
2801 bcn_prms, pe_session);
2802 } else if (pe_session->gLimHt20Params.protectionEnabled) {
2803 mac_ctx->lim.gHTOperMode =
2804 eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
2805 pe_session->htOperMode =
2806 eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
2807 lim_enable_ht_rifs_protection(mac_ctx, false, overlap,
2808 bcn_prms, pe_session);
2809 } else {
2810 mac_ctx->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
2811 pe_session->htOperMode = eSIR_HT_OP_MODE_PURE;
2812 lim_enable_ht_rifs_protection(mac_ctx, false, overlap,
2813 bcn_prms, pe_session);
2814 }
2815 }
2816
2817disable_11a_end:
Arif Hussain1cd8abf2017-12-17 19:37:50 -08002818 if (!pe_session->gLimOverlap11aParams.protectionEnabled &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002819 !pe_session->gLim11aParams.protectionEnabled) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05302820 pe_warn("===> Protection from 11A Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002821 bcn_prms->llaCoexist = false;
2822 pe_session->beaconParams.llaCoexist = false;
2823 bcn_prms->paramChangeBitmap |= PARAM_llACOEXIST_CHANGED;
2824 }
2825}
2826
2827/**
2828 * lim_update_11a_protection() - based on config setting enables\disables 11a
2829 * protection.
2830 * @mac_ctx: pointer to Global MAC structure
2831 * @enable: 1=> enable protection, 0=> disable protection.
2832 * @overlap: 1=> called from overlap context, 0 => called from assoc context.
2833 * @bcn_prms: beacon parameters
2834 * @session: pe session entry
2835 *
2836 * This based on config setting enables\disables 11a protection.
2837 *
2838 * @Return: success of failure of operation
2839 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002840QDF_STATUS
Jeff Johnsond01da6b2018-12-02 12:10:22 -08002841lim_update_11a_protection(struct mac_context *mac_ctx, uint8_t enable,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002842 uint8_t overlap, tpUpdateBeaconParams bcn_prms,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08002843 struct pe_session *session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002844{
2845 if (NULL == session) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05302846 pe_err("session is NULL");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002847 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002848 }
2849 /* overlapping protection configuration check. */
2850 if (!overlap) {
2851 /* normal protection config check */
2852 if ((LIM_IS_AP_ROLE(session)) &&
2853 (!session->cfgProtection.fromlla)) {
2854 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05302855 pe_warn("protection from 11a is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002856 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002857 }
2858 }
2859
2860 if (enable)
2861 lim_enable_11a_protection(mac_ctx, overlap, bcn_prms, session);
2862 else
2863 lim_disable_11a_protection(mac_ctx, overlap, bcn_prms, session);
2864
Jeff Johnson0301ecb2018-06-29 09:36:23 -07002865 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002866}
2867
2868/**
2869 * lim_handle_enable11g_protection_enabled() - handle 11g protection enabled
2870 * @mac_ctx: pointer to Globale Mac structure
2871 * @beaconparams: pointer to tpUpdateBeaconParams
2872 * @overlap: 1=> called from overlap context, 0 => called from assoc context.
Jeff Johnsonc8baa902018-11-18 21:59:07 -08002873 * @session_entry: pointer to struct pe_session *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002874 *
2875 * Function handles 11g protection enaled case
2876 *
2877 * Return: none
2878 */
2879static void
Jeff Johnsond01da6b2018-12-02 12:10:22 -08002880lim_handle_enable11g_protection_enabled(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002881 tpUpdateBeaconParams beaconparams,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08002882 uint8_t overlap, struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002883{
2884 /*
2885 * If we are AP and HT capable, we need to set the HT OP mode
2886 * appropriately.
2887 */
2888 if (LIM_IS_AP_ROLE(session_entry) && overlap) {
2889 session_entry->gLimOlbcParams.protectionEnabled = true;
2890
Nishank Aggarwal0402b432017-03-24 19:17:36 +05302891 pe_debug("protection from olbc is enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002892
2893 if (true == session_entry->htCapability) {
2894 if ((eSIR_HT_OP_MODE_OVERLAP_LEGACY !=
2895 session_entry->htOperMode) &&
2896 (eSIR_HT_OP_MODE_MIXED !=
2897 session_entry->htOperMode)) {
2898 session_entry->htOperMode =
2899 eSIR_HT_OP_MODE_OVERLAP_LEGACY;
2900 }
2901 /*
2902 * CR-263021: OBSS bit is not switching back to 0 after
2903 * disabling the overlapping legacy BSS
2904 */
2905 /*
2906 * This fixes issue of OBSS bit not set after 11b, 11g
2907 * station leaves
2908 */
2909 lim_enable_ht_rifs_protection(mac_ctx, true,
2910 overlap, beaconparams, session_entry);
2911 /*
2912 * Not processing OBSS bit from other APs, as we are
2913 * already taking care of Protection from overlapping
2914 * BSS based on erp IE or useProtection bit
2915 */
2916 lim_enable_ht_obss_protection(mac_ctx, true,
2917 overlap, beaconparams, session_entry);
2918 }
2919 } else if (LIM_IS_AP_ROLE(session_entry) && !overlap) {
2920 session_entry->gLim11bParams.protectionEnabled = true;
Nishank Aggarwal0402b432017-03-24 19:17:36 +05302921 pe_debug("protection from 11b is enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002922 if (true == session_entry->htCapability) {
2923 if (eSIR_HT_OP_MODE_MIXED !=
2924 session_entry->htOperMode) {
2925 session_entry->htOperMode =
2926 eSIR_HT_OP_MODE_MIXED;
2927 lim_enable_ht_rifs_protection(mac_ctx,
2928 true, overlap, beaconparams,
2929 session_entry);
2930 lim_enable_ht_obss_protection(mac_ctx,
2931 true, overlap, beaconparams,
2932 session_entry);
2933 }
2934 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002935 }
Rajeev Kumar0ac9f2a2016-04-15 15:54:18 -07002936
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002937 /* This part is common for staiton as well. */
2938 if (false == session_entry->beaconParams.llbCoexist) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05302939 pe_debug("=> 11G Protection Enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002940 beaconparams->llbCoexist =
2941 session_entry->beaconParams.llbCoexist = true;
2942 beaconparams->paramChangeBitmap |=
2943 PARAM_llBCOEXIST_CHANGED;
2944 }
2945}
2946
2947/**
2948 * lim_handle_11g_protection_for_11bcoexist() - 11g protection for 11b co-ex
2949 * @mac_ctx: pointer to Globale Mac structure
2950 * @beaconparams: pointer to tpUpdateBeaconParams
2951 * @overlap: 1=> called from overlap context, 0 => called from assoc context.
Jeff Johnsonc8baa902018-11-18 21:59:07 -08002952 * @session_entry: pointer to struct pe_session *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002953 *
2954 * Function handles 11g protection for 11b co-exist
2955 *
2956 * Return: none
2957 */
2958static void
Jeff Johnsond01da6b2018-12-02 12:10:22 -08002959lim_handle_11g_protection_for_11bcoexist(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002960 tpUpdateBeaconParams beaconparams,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08002961 uint8_t overlap, struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002962{
2963 /*
2964 * For AP role:
2965 * we need to take care of HT OP mode change if needed.
2966 * We need to take care of Overlap cases.
2967 */
2968 if (LIM_IS_AP_ROLE(session_entry) && overlap) {
2969 /* Overlap Legacy protection disabled. */
2970 session_entry->gLimOlbcParams.protectionEnabled = false;
2971
2972 /* We need to take care of HT OP mode if we are HT AP. */
2973 if (session_entry->htCapability) {
2974 /*
2975 * no HT op mode change if any of the overlap
2976 * protection enabled.
2977 */
2978 if (!(session_entry->gLimOverlap11gParams.
2979 protectionEnabled ||
2980 session_entry->gLimOverlapHt20Params.
2981 protectionEnabled ||
2982 session_entry->gLimOverlapNonGfParams.
2983 protectionEnabled) &&
2984 /*
2985 * Check if there is a need to change HT
2986 * OP mode.
2987 */
2988 (eSIR_HT_OP_MODE_OVERLAP_LEGACY ==
2989 session_entry->htOperMode)) {
2990 lim_enable_ht_rifs_protection(mac_ctx, false,
2991 overlap, beaconparams, session_entry);
2992 lim_enable_ht_obss_protection(mac_ctx, false,
2993 overlap, beaconparams, session_entry);
2994 if (session_entry->gLimHt20Params.
2995 protectionEnabled) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302996 if (eHT_CHANNEL_WIDTH_20MHZ ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002997 session_entry->htSupportedChannelWidthSet)
2998 session_entry->htOperMode =
2999 eSIR_HT_OP_MODE_PURE;
3000 else
3001 session_entry->htOperMode =
3002 eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
3003 } else
3004 session_entry->htOperMode =
3005 eSIR_HT_OP_MODE_PURE;
3006 }
3007 }
3008 } else if (LIM_IS_AP_ROLE(session_entry) && !overlap) {
3009 /* Disable protection from 11B stations. */
3010 session_entry->gLim11bParams.protectionEnabled = false;
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303011 pe_debug("===> 11B Protection Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003012 /* Check if any other non-HT protection enabled. */
3013 if (!session_entry->gLim11gParams.protectionEnabled) {
3014 /* Right now we are in HT OP Mixed mode. */
3015 /* Change HT op mode appropriately. */
3016 lim_enable_ht_obss_protection(mac_ctx, false, overlap,
3017 beaconparams, session_entry);
3018 /*
3019 * Change HT OP mode to 01 if any overlap protection
3020 * enabled
3021 */
3022 if (session_entry->gLimOlbcParams.protectionEnabled ||
3023 session_entry->gLimOverlap11gParams.
3024 protectionEnabled ||
3025 session_entry->gLimOverlapHt20Params.
3026 protectionEnabled ||
3027 session_entry->gLimOverlapNonGfParams.
3028 protectionEnabled) {
3029 session_entry->htOperMode =
3030 eSIR_HT_OP_MODE_OVERLAP_LEGACY;
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303031 pe_debug("===> 11G Protection Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003032 lim_enable_ht_rifs_protection(mac_ctx, true,
3033 overlap, beaconparams,
3034 session_entry);
3035 } else if (session_entry->gLimHt20Params.
3036 protectionEnabled) {
3037 /* Commenting because of CR 258588 WFA cert */
3038 /* session_entry->htOperMode =
3039 eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT; */
3040 session_entry->htOperMode =
3041 eSIR_HT_OP_MODE_PURE;
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303042 pe_debug("===> 11G Protection Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003043 lim_enable_ht_rifs_protection(mac_ctx, false,
3044 overlap, beaconparams,
3045 session_entry);
3046 } else {
3047 session_entry->htOperMode =
3048 eSIR_HT_OP_MODE_PURE;
3049 lim_enable_ht_rifs_protection(mac_ctx, false,
3050 overlap, beaconparams,
3051 session_entry);
3052 }
3053 }
3054 }
3055 if (LIM_IS_AP_ROLE(session_entry)) {
3056 if (!session_entry->gLimOlbcParams.protectionEnabled &&
3057 !session_entry->gLim11bParams.protectionEnabled) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303058 pe_debug("===> 11G Protection Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003059 beaconparams->llbCoexist =
3060 session_entry->beaconParams.llbCoexist =
3061 false;
3062 beaconparams->paramChangeBitmap |=
3063 PARAM_llBCOEXIST_CHANGED;
3064 }
3065 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003066 /* For station role */
Rajeev Kumar0ac9f2a2016-04-15 15:54:18 -07003067 if (!LIM_IS_AP_ROLE(session_entry)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303068 pe_debug("===> 11G Protection Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003069 beaconparams->llbCoexist =
3070 session_entry->beaconParams.llbCoexist = false;
3071 beaconparams->paramChangeBitmap |=
3072 PARAM_llBCOEXIST_CHANGED;
3073 }
3074}
3075
3076/**
3077 * lim_enable11g_protection() - Function to enable 11g protection
3078 * @mac_ctx: pointer to Global Mac structure
3079 * @enable: 1=> enable protection, 0=> disable protection.
3080 * @overlap: 1=> called from overlap context, 0 => called from assoc context.
3081 * @beaconparams: pointer to tpUpdateBeaconParams
Jeff Johnsonc8baa902018-11-18 21:59:07 -08003082 * @session_entry: pointer to struct pe_session *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003083 *
3084 * based on config setting enables\disables 11g protection.
3085 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003086 * Return: Success - QDF_STATUS_SUCCESS - Success, Error number - Failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003087 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003088QDF_STATUS
Jeff Johnsond01da6b2018-12-02 12:10:22 -08003089lim_enable11g_protection(struct mac_context *mac_ctx, uint8_t enable,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003090 uint8_t overlap, tpUpdateBeaconParams beaconparams,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08003091 struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003092{
3093
3094 /* overlapping protection configuration check. */
3095 if (!overlap) {
3096 /* normal protection config check */
3097 if ((LIM_IS_AP_ROLE(session_entry)) &&
3098 !session_entry->cfgProtection.fromllb) {
3099 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303100 pe_debug("protection from 11b is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003101 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003102 } else if (!LIM_IS_AP_ROLE(session_entry)) {
3103 if (!mac_ctx->lim.cfgProtection.fromllb) {
3104 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303105 pe_debug("protection from 11b is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003106 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003107 }
3108 }
3109 }
3110
3111 if (enable) {
3112 lim_handle_enable11g_protection_enabled(mac_ctx, beaconparams,
3113 overlap, session_entry);
3114 } else if (true == session_entry->beaconParams.llbCoexist) {
3115 lim_handle_11g_protection_for_11bcoexist(mac_ctx, beaconparams,
3116 overlap, session_entry);
3117 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003118 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003119}
3120
3121/** -------------------------------------------------------------
3122 \fn lim_enable_ht_protection_from11g
3123 \brief based on cofig enables\disables protection from 11g.
3124 \param uint8_t enable : 1=> enable protection, 0=> disable protection.
3125 \param uint8_t overlap: 1=> called from overlap context, 0 => called from assoc context.
3126 \param tpUpdateBeaconParams pBeaconParams
3127 \return None
3128 -------------------------------------------------------------*/
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003129QDF_STATUS
Jeff Johnsond01da6b2018-12-02 12:10:22 -08003130lim_enable_ht_protection_from11g(struct mac_context *mac, uint8_t enable,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003131 uint8_t overlap,
3132 tpUpdateBeaconParams pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003133 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003134{
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003135 if (!pe_session->htCapability)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003136 return QDF_STATUS_SUCCESS; /* protection from 11g is only for HT stations. */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003137
3138 /* overlapping protection configuration check. */
3139 if (overlap) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003140 if ((LIM_IS_AP_ROLE(pe_session))
3141 && (!pe_session->cfgProtection.overlapFromllg)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003142 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303143 pe_debug("overlap protection from 11g is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003144 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003145 }
3146 } else {
3147 /* normal protection config check */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003148 if (LIM_IS_AP_ROLE(pe_session) &&
3149 !pe_session->cfgProtection.fromllg) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003150 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303151 pe_debug("protection from 11g is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003152 return QDF_STATUS_SUCCESS;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003153 } else if (!LIM_IS_AP_ROLE(pe_session)) {
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003154 if (!mac->lim.cfgProtection.fromllg) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003155 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303156 pe_debug("protection from 11g is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003157 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003158 }
3159 }
3160 }
3161 if (enable) {
3162 /* If we are AP and HT capable, we need to set the HT OP mode */
3163 /* appropriately. */
3164
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003165 if (LIM_IS_AP_ROLE(pe_session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003166 if (overlap) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003167 pe_session->gLimOverlap11gParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003168 protectionEnabled = true;
3169 /* 11g exists in overlap BSS. */
3170 /* need not to change the operating mode to overlap_legacy */
3171 /* if higher or same protection operating mode is enabled right now. */
3172 if ((eSIR_HT_OP_MODE_OVERLAP_LEGACY !=
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003173 pe_session->htOperMode)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003174 && (eSIR_HT_OP_MODE_MIXED !=
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003175 pe_session->htOperMode)) {
3176 pe_session->htOperMode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003177 eSIR_HT_OP_MODE_OVERLAP_LEGACY;
3178 }
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003179 lim_enable_ht_rifs_protection(mac, true, overlap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003180 pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003181 pe_session);
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003182 lim_enable_ht_obss_protection(mac, true, overlap,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003183 pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003184 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003185 } else {
3186 /* 11g is associated to an AP operating in 11n mode. */
3187 /* Change the HT operating mode to 'mixed mode'. */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003188 pe_session->gLim11gParams.protectionEnabled =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003189 true;
3190 if (eSIR_HT_OP_MODE_MIXED !=
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003191 pe_session->htOperMode) {
3192 pe_session->htOperMode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003193 eSIR_HT_OP_MODE_MIXED;
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003194 lim_enable_ht_rifs_protection(mac, true,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003195 overlap,
3196 pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003197 pe_session);
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003198 lim_enable_ht_obss_protection(mac, true,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003199 overlap,
3200 pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003201 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003202 }
3203 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003204 }
3205 /* This part is common for staiton as well. */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003206 if (false == pe_session->beaconParams.llgCoexist) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003207 pBeaconParams->llgCoexist =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003208 pe_session->beaconParams.llgCoexist = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003209 pBeaconParams->paramChangeBitmap |=
3210 PARAM_llGCOEXIST_CHANGED;
3211 } else if (true ==
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003212 pe_session->gLimOverlap11gParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003213 protectionEnabled) {
3214 /* As operating mode changed after G station assoc some way to update beacon */
3215 /* This addresses the issue of mode not changing to - 11 in beacon when OBSS overlap is enabled */
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003216 /* mac->sch.schObject.fBeaconChanged = 1; */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003217 pBeaconParams->paramChangeBitmap |=
3218 PARAM_llGCOEXIST_CHANGED;
3219 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003220 } else if (true == pe_session->beaconParams.llgCoexist) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003221 /* for AP role. */
3222 /* we need to take care of HT OP mode change if needed. */
3223 /* We need to take care of Overlap cases. */
3224
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003225 if (LIM_IS_AP_ROLE(pe_session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003226 if (overlap) {
3227 /* Overlap Legacy protection disabled. */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003228 if (pe_session->gLim11gParams.numSta == 0)
3229 pe_session->gLimOverlap11gParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003230 protectionEnabled = false;
3231
3232 /* no HT op mode change if any of the overlap protection enabled. */
3233 if (!
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003234 (pe_session->gLimOlbcParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003235 protectionEnabled
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003236 || pe_session->gLimOverlapHt20Params.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003237 protectionEnabled
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003238 || pe_session->gLimOverlapNonGfParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003239 protectionEnabled)) {
3240 /* Check if there is a need to change HT OP mode. */
3241 if (eSIR_HT_OP_MODE_OVERLAP_LEGACY ==
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003242 pe_session->htOperMode) {
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003243 lim_enable_ht_rifs_protection(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003244 false,
3245 overlap,
3246 pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003247 pe_session);
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003248 lim_enable_ht_obss_protection(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003249 false,
3250 overlap,
3251 pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003252 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003253
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003254 if (pe_session->gLimHt20Params.protectionEnabled) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303255 if (eHT_CHANNEL_WIDTH_20MHZ ==
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003256 pe_session->htSupportedChannelWidthSet)
3257 pe_session->htOperMode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003258 eSIR_HT_OP_MODE_PURE;
3259 else
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003260 pe_session->htOperMode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003261 eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
3262 } else
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003263 pe_session->htOperMode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003264 eSIR_HT_OP_MODE_PURE;
3265 }
3266 }
3267 } else {
3268 /* Disable protection from 11G stations. */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003269 pe_session->gLim11gParams.protectionEnabled =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003270 false;
3271 /* Check if any other non-HT protection enabled. */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003272 if (!pe_session->gLim11bParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003273 protectionEnabled) {
3274
3275 /* Right now we are in HT OP Mixed mode. */
3276 /* Change HT op mode appropriately. */
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003277 lim_enable_ht_obss_protection(mac, false,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003278 overlap,
3279 pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003280 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003281
3282 /* Change HT OP mode to 01 if any overlap protection enabled */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003283 if (pe_session->gLimOlbcParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003284 protectionEnabled
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003285 || pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003286 gLimOverlap11gParams.
3287 protectionEnabled
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003288 || pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003289 gLimOverlapHt20Params.
3290 protectionEnabled
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003291 || pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003292 gLimOverlapNonGfParams.
3293 protectionEnabled) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003294 pe_session->htOperMode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003295 eSIR_HT_OP_MODE_OVERLAP_LEGACY;
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003296 lim_enable_ht_rifs_protection(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003297 true,
3298 overlap,
3299 pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003300 pe_session);
3301 } else if (pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003302 gLimHt20Params.
3303 protectionEnabled) {
3304 /* Commenting because of CR 258588 WFA cert */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003305 /* pe_session->htOperMode = eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT; */
3306 pe_session->htOperMode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003307 eSIR_HT_OP_MODE_PURE;
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003308 lim_enable_ht_rifs_protection(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003309 false,
3310 overlap,
3311 pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003312 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003313 } else {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003314 pe_session->htOperMode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003315 eSIR_HT_OP_MODE_PURE;
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003316 lim_enable_ht_rifs_protection(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003317 false,
3318 overlap,
3319 pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003320 pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003321 }
3322 }
3323 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003324 if (!pe_session->gLimOverlap11gParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003325 protectionEnabled
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003326 && !pe_session->gLim11gParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003327 protectionEnabled) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303328 pe_debug("===> Protection from 11G Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003329 pBeaconParams->llgCoexist =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003330 pe_session->beaconParams.llgCoexist =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003331 false;
3332 pBeaconParams->paramChangeBitmap |=
3333 PARAM_llGCOEXIST_CHANGED;
3334 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003335 }
3336 /* for station role */
3337 else {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303338 pe_debug("===> Protection from 11G Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003339 pBeaconParams->llgCoexist =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003340 pe_session->beaconParams.llgCoexist = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003341 pBeaconParams->paramChangeBitmap |=
3342 PARAM_llGCOEXIST_CHANGED;
3343 }
3344 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003345 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003346}
3347
3348/* FIXME_PROTECTION : need to check for no APSD whenever we want to enable this protection. */
3349/* This check will be done at the caller. */
3350
3351/** -------------------------------------------------------------
3352 \fn limEnableHtObssProtection
3353 \brief based on cofig enables\disables obss protection.
3354 \param uint8_t enable : 1=> enable protection, 0=> disable protection.
3355 \param uint8_t overlap: 1=> called from overlap context, 0 => called from assoc context.
3356 \param tpUpdateBeaconParams pBeaconParams
3357 \return None
3358 -------------------------------------------------------------*/
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003359QDF_STATUS
Jeff Johnsond01da6b2018-12-02 12:10:22 -08003360lim_enable_ht_obss_protection(struct mac_context *mac, uint8_t enable,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003361 uint8_t overlap, tpUpdateBeaconParams pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003362 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003363{
3364
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003365 if (!pe_session->htCapability)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003366 return QDF_STATUS_SUCCESS; /* this protection is only for HT stations. */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003367
3368 /* overlapping protection configuration check. */
3369 if (overlap) {
3370 /* overlapping protection configuration check. */
3371 } else {
3372 /* normal protection config check */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003373 if ((LIM_IS_AP_ROLE(pe_session)) &&
3374 !pe_session->cfgProtection.obss) { /* ToDo Update this field */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003375 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303376 pe_debug("protection from Obss is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003377 return QDF_STATUS_SUCCESS;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003378 } else if (!LIM_IS_AP_ROLE(pe_session)) {
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003379 if (!mac->lim.cfgProtection.obss) { /* ToDo Update this field */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003380 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303381 pe_debug("protection from Obss is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003382 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003383 }
3384 }
3385 }
3386
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003387 if (LIM_IS_AP_ROLE(pe_session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003388 if ((enable)
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003389 && (false == pe_session->beaconParams.gHTObssMode)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303390 pe_debug("=>obss protection enabled");
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003391 pe_session->beaconParams.gHTObssMode = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003392 pBeaconParams->paramChangeBitmap |= PARAM_OBSS_MODE_CHANGED; /* UPDATE AN ENUM FOR OBSS MODE <todo> */
3393
3394 } else if (!enable
3395 && (true ==
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003396 pe_session->beaconParams.gHTObssMode)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303397 pe_debug("===> obss Protection disabled");
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003398 pe_session->beaconParams.gHTObssMode = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003399 pBeaconParams->paramChangeBitmap |=
3400 PARAM_OBSS_MODE_CHANGED;
3401
3402 }
3403/* CR-263021: OBSS bit is not switching back to 0 after disabling the overlapping legacy BSS */
3404 if (!enable && !overlap) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003405 pe_session->gLimOverlap11gParams.protectionEnabled =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003406 false;
3407 }
3408 } else {
3409 if ((enable)
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003410 && (false == pe_session->beaconParams.gHTObssMode)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303411 pe_debug("=>obss protection enabled");
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003412 pe_session->beaconParams.gHTObssMode = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003413 pBeaconParams->paramChangeBitmap |= PARAM_OBSS_MODE_CHANGED; /* UPDATE AN ENUM FOR OBSS MODE <todo> */
3414
3415 } else if (!enable
3416 && (true ==
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003417 pe_session->beaconParams.gHTObssMode)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303418 pe_debug("===> obss Protection disabled");
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003419 pe_session->beaconParams.gHTObssMode = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003420 pBeaconParams->paramChangeBitmap |=
3421 PARAM_OBSS_MODE_CHANGED;
3422
3423 }
3424 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003425 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003426}
3427
3428/**
3429 * lim_handle_ht20protection_enabled() - Handle ht20 protection enabled
3430 * @mac_ctx: pointer to Gloal Mac Structure
3431 * @overlap: variable for overlap detection
3432 * @beaconparams: pointer to tpUpdateBeaconParams
Jeff Johnsonc8baa902018-11-18 21:59:07 -08003433 * @session_entry: pointer to struct pe_session *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003434 *
3435 * Function handles ht20 protection enabled
3436 *
3437 * Return: none
3438 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08003439static void lim_handle_ht20protection_enabled(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003440 uint8_t overlap, tpUpdateBeaconParams beaconparams,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08003441 struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003442{
3443 /*
3444 * If we are AP and HT capable, we need to set the HT OP mode
3445 * appropriately.
3446 */
3447 if (LIM_IS_AP_ROLE(session_entry) && overlap) {
3448 session_entry->gLimOverlapHt20Params.protectionEnabled = true;
3449 if ((eSIR_HT_OP_MODE_OVERLAP_LEGACY !=
3450 session_entry->htOperMode) &&
3451 (eSIR_HT_OP_MODE_MIXED !=
3452 session_entry->htOperMode)) {
3453 session_entry->htOperMode =
3454 eSIR_HT_OP_MODE_OVERLAP_LEGACY;
3455 lim_enable_ht_rifs_protection(mac_ctx, true,
3456 overlap, beaconparams, session_entry);
3457 }
3458 } else if (LIM_IS_AP_ROLE(session_entry) && !overlap) {
3459 session_entry->gLimHt20Params.protectionEnabled = true;
3460 if (eSIR_HT_OP_MODE_PURE == session_entry->htOperMode) {
Naveen Rawate702e9b2015-11-17 11:50:40 -08003461 if (session_entry->htSupportedChannelWidthSet !=
3462 eHT_CHANNEL_WIDTH_20MHZ)
3463 session_entry->htOperMode =
3464 eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003465 lim_enable_ht_rifs_protection(mac_ctx, false,
3466 overlap, beaconparams, session_entry);
3467 lim_enable_ht_obss_protection(mac_ctx, false,
3468 overlap, beaconparams, session_entry);
3469 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003470 }
3471 /* This part is common for staiton as well. */
3472 if (false == session_entry->beaconParams.ht20Coexist) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303473 pe_debug("=> Protection from HT20 Enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003474 beaconparams->ht20MhzCoexist =
3475 session_entry->beaconParams.ht20Coexist = true;
3476 beaconparams->paramChangeBitmap |=
3477 PARAM_HT20MHZCOEXIST_CHANGED;
3478 }
3479}
3480
3481/**
3482 * lim_handle_ht20coexist_ht20protection() - ht20 protection for ht20 coexist
3483 * @mac_ctx: pointer to Gloal Mac Structure
3484 * @beaconparams: pointer to tpUpdateBeaconParams
Jeff Johnsonc8baa902018-11-18 21:59:07 -08003485 * @session_entry: pointer to struct pe_session *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003486 * @overlap: variable for overlap detection
3487 *
3488 * Function handles ht20 protection for ht20 coexist
3489 *
3490 * Return: none
3491 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08003492static void lim_handle_ht20coexist_ht20protection(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003493 tpUpdateBeaconParams beaconparams,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08003494 struct pe_session *session_entry, uint8_t overlap)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003495{
3496 /*
3497 * For AP role:
3498 * we need to take care of HT OP mode change if needed.
3499 * We need to take care of Overlap cases.
3500 */
3501 if (LIM_IS_AP_ROLE(session_entry) && overlap) {
3502 /* Overlap Legacy protection disabled. */
3503 session_entry->gLimOverlapHt20Params.protectionEnabled =
3504 false;
3505 /*
3506 * no HT op mode change if any of the overlap
3507 * protection enabled.
3508 */
3509 if (!(session_entry->gLimOlbcParams.protectionEnabled ||
3510 session_entry->gLimOverlap11gParams.protectionEnabled ||
3511 session_entry->gLimOverlapHt20Params.protectionEnabled
3512 || session_entry->gLimOverlapNonGfParams.
3513 protectionEnabled) &&
3514 /*
3515 * Check if there is a need to change HT
3516 * OP mode.
3517 */
3518 (eSIR_HT_OP_MODE_OVERLAP_LEGACY ==
3519 session_entry->htOperMode)) {
wadesong42968e92017-06-08 14:11:21 +08003520 if (session_entry->gLimHt20Params.
3521 protectionEnabled) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303522 if (eHT_CHANNEL_WIDTH_20MHZ ==
wadesong42968e92017-06-08 14:11:21 +08003523 session_entry->
3524 htSupportedChannelWidthSet)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003525 session_entry->htOperMode =
3526 eSIR_HT_OP_MODE_PURE;
3527 else
3528 session_entry->htOperMode =
3529 eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT;
3530
wadesong42968e92017-06-08 14:11:21 +08003531 lim_enable_ht_rifs_protection(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003532 false, overlap, beaconparams,
3533 session_entry);
wadesong42968e92017-06-08 14:11:21 +08003534 lim_enable_ht_obss_protection(mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003535 false, overlap, beaconparams,
3536 session_entry);
wadesong42968e92017-06-08 14:11:21 +08003537 } else {
3538 session_entry->htOperMode =
3539 eSIR_HT_OP_MODE_PURE;
3540 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003541 }
3542 } else if (LIM_IS_AP_ROLE(session_entry) && !overlap) {
3543 /* Disable protection from 11G stations. */
3544 session_entry->gLimHt20Params.protectionEnabled = false;
3545 /* Change HT op mode appropriately. */
3546 if (eSIR_HT_OP_MODE_NO_LEGACY_20MHZ_HT ==
3547 session_entry->htOperMode) {
3548 session_entry->htOperMode =
3549 eSIR_HT_OP_MODE_PURE;
3550 lim_enable_ht_rifs_protection(mac_ctx, false,
3551 overlap, beaconparams, session_entry);
3552 lim_enable_ht_obss_protection(mac_ctx, false,
3553 overlap, beaconparams, session_entry);
3554 }
3555 }
3556 if (LIM_IS_AP_ROLE(session_entry)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303557 pe_debug("===> Protection from HT 20 Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003558 beaconparams->ht20MhzCoexist =
3559 session_entry->beaconParams.ht20Coexist = false;
3560 beaconparams->paramChangeBitmap |=
3561 PARAM_HT20MHZCOEXIST_CHANGED;
3562 }
Rajeev Kumar0ac9f2a2016-04-15 15:54:18 -07003563 if (!LIM_IS_AP_ROLE(session_entry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003564 /* For station role */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303565 pe_debug("===> Protection from HT20 Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003566 beaconparams->ht20MhzCoexist =
3567 session_entry->beaconParams.ht20Coexist = false;
3568 beaconparams->paramChangeBitmap |=
3569 PARAM_HT20MHZCOEXIST_CHANGED;
3570 }
3571}
3572
3573/**
3574 * lim_enable_ht20_protection() - Function to enable ht20 protection
3575 * @mac_ctx: pointer to Global Mac structure
3576 * @enable: 1=> enable protection, 0=> disable protection.
3577 * @overlap: 1=> called from overlap context, 0 => called from assoc context.
3578 * @beaconparams: pointer to tpUpdateBeaconParams
Jeff Johnsonc8baa902018-11-18 21:59:07 -08003579 * @session_entry: pointer to struct pe_session *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003580 *
3581 * based on cofig enables\disables protection from Ht20
3582 *
3583 * Return: 0 - success
3584 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08003585QDF_STATUS lim_enable_ht20_protection(struct mac_context *mac_ctx, uint8_t enable,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003586 uint8_t overlap, tpUpdateBeaconParams beaconparams,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08003587 struct pe_session *session_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003588{
3589 /* This protection is only for HT stations. */
3590 if (!session_entry->htCapability)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003591 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003592
3593 /* overlapping protection configuration check. */
3594 if (!overlap) {
3595 /* normal protection config check */
3596 if ((LIM_IS_AP_ROLE(session_entry)) &&
3597 !session_entry->cfgProtection.ht20) {
3598 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303599 pe_debug("protection from HT20 is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003600 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003601 } else if (!LIM_IS_AP_ROLE(session_entry)) {
3602 if (!mac_ctx->lim.cfgProtection.ht20) {
3603 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303604 pe_debug("protection from HT20 is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003605 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003606 }
3607 }
3608 }
3609
3610 if (enable)
3611 lim_handle_ht20protection_enabled(mac_ctx, overlap,
3612 beaconparams, session_entry);
3613 else if (true == session_entry->beaconParams.ht20Coexist)
3614 lim_handle_ht20coexist_ht20protection(mac_ctx, beaconparams,
3615 session_entry, overlap);
3616
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003617 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003618}
3619
3620/** -------------------------------------------------------------
3621 \fn lim_enable_ht_non_gf_protection
3622 \brief based on cofig enables\disables protection from NonGf.
3623 \param uint8_t enable : 1=> enable protection, 0=> disable protection.
3624 \param uint8_t overlap: 1=> called from overlap context, 0 => called from assoc context.
3625 \param tpUpdateBeaconParams pBeaconParams
3626 \return None
3627 -------------------------------------------------------------*/
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003628QDF_STATUS
Jeff Johnsond01da6b2018-12-02 12:10:22 -08003629lim_enable_ht_non_gf_protection(struct mac_context *mac, uint8_t enable,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003630 uint8_t overlap, tpUpdateBeaconParams pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003631 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003632{
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003633 if (!pe_session->htCapability)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003634 return QDF_STATUS_SUCCESS; /* this protection is only for HT stations. */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003635
3636 /* overlapping protection configuration check. */
3637 if (overlap) {
3638 } else {
3639 /* normal protection config check */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003640 if (LIM_IS_AP_ROLE(pe_session) &&
3641 !pe_session->cfgProtection.nonGf) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003642 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303643 pe_debug("protection from NonGf is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003644 return QDF_STATUS_SUCCESS;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003645 } else if (!LIM_IS_AP_ROLE(pe_session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003646 /* normal protection config check */
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003647 if (!mac->lim.cfgProtection.nonGf) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003648 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303649 pe_debug("protection from NonGf is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003650 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003651 }
3652 }
3653 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003654 if (LIM_IS_AP_ROLE(pe_session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003655 if ((enable)
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003656 && (false == pe_session->beaconParams.llnNonGFCoexist)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303657 pe_debug(" => Protection from non GF Enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003658 pBeaconParams->llnNonGFCoexist =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003659 pe_session->beaconParams.llnNonGFCoexist = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003660 pBeaconParams->paramChangeBitmap |=
3661 PARAM_NON_GF_DEVICES_PRESENT_CHANGED;
3662 } else if (!enable
3663 && (true ==
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003664 pe_session->beaconParams.llnNonGFCoexist)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303665 pe_debug("===> Protection from Non GF Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003666 pBeaconParams->llnNonGFCoexist =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003667 pe_session->beaconParams.llnNonGFCoexist = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003668 pBeaconParams->paramChangeBitmap |=
3669 PARAM_NON_GF_DEVICES_PRESENT_CHANGED;
3670 }
3671 } else {
3672 if ((enable)
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003673 && (false == pe_session->beaconParams.llnNonGFCoexist)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303674 pe_debug(" => Protection from non GF Enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003675 pBeaconParams->llnNonGFCoexist =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003676 pe_session->beaconParams.llnNonGFCoexist = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003677 pBeaconParams->paramChangeBitmap |=
3678 PARAM_NON_GF_DEVICES_PRESENT_CHANGED;
3679 } else if (!enable
3680 && (true ==
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003681 pe_session->beaconParams.llnNonGFCoexist)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303682 pe_debug("===> Protection from Non GF Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003683 pBeaconParams->llnNonGFCoexist =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003684 pe_session->beaconParams.llnNonGFCoexist = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003685 pBeaconParams->paramChangeBitmap |=
3686 PARAM_NON_GF_DEVICES_PRESENT_CHANGED;
3687 }
3688 }
3689
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003690 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003691}
3692
3693/** -------------------------------------------------------------
3694 \fn lim_enable_ht_lsig_txop_protection
3695 \brief based on cofig enables\disables LsigTxop protection.
3696 \param uint8_t enable : 1=> enable protection, 0=> disable protection.
3697 \param uint8_t overlap: 1=> called from overlap context, 0 => called from assoc context.
3698 \param tpUpdateBeaconParams pBeaconParams
3699 \return None
3700 -------------------------------------------------------------*/
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003701QDF_STATUS
Jeff Johnsond01da6b2018-12-02 12:10:22 -08003702lim_enable_ht_lsig_txop_protection(struct mac_context *mac, uint8_t enable,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003703 uint8_t overlap,
3704 tpUpdateBeaconParams pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003705 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003706{
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003707 if (!pe_session->htCapability)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003708 return QDF_STATUS_SUCCESS; /* this protection is only for HT stations. */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003709
3710 /* overlapping protection configuration check. */
3711 if (overlap) {
3712 } else {
3713 /* normal protection config check */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003714 if (LIM_IS_AP_ROLE(pe_session) &&
3715 !pe_session->cfgProtection.lsigTxop) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003716 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303717 pe_debug("protection from LsigTxop not supported is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003718 return QDF_STATUS_SUCCESS;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003719 } else if (!LIM_IS_AP_ROLE(pe_session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003720 /* normal protection config check */
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003721 if (!mac->lim.cfgProtection.lsigTxop) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003722 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303723 pe_debug("protection from LsigTxop not supported is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003724 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003725 }
3726 }
3727 }
3728
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003729 if (LIM_IS_AP_ROLE(pe_session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003730 if ((enable)
3731 && (false ==
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003732 pe_session->beaconParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003733 fLsigTXOPProtectionFullSupport)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303734 pe_debug(" => Protection from LsigTxop Enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003735 pBeaconParams->fLsigTXOPProtectionFullSupport =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003736 pe_session->beaconParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003737 fLsigTXOPProtectionFullSupport = true;
3738 pBeaconParams->paramChangeBitmap |=
3739 PARAM_LSIG_TXOP_FULL_SUPPORT_CHANGED;
3740 } else if (!enable
3741 && (true ==
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003742 pe_session->beaconParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003743 fLsigTXOPProtectionFullSupport)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303744 pe_debug("===> Protection from LsigTxop Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003745 pBeaconParams->fLsigTXOPProtectionFullSupport =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003746 pe_session->beaconParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003747 fLsigTXOPProtectionFullSupport = false;
3748 pBeaconParams->paramChangeBitmap |=
3749 PARAM_LSIG_TXOP_FULL_SUPPORT_CHANGED;
3750 }
3751 } else {
3752 if ((enable)
3753 && (false ==
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003754 pe_session->beaconParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003755 fLsigTXOPProtectionFullSupport)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303756 pe_debug(" => Protection from LsigTxop Enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003757 pBeaconParams->fLsigTXOPProtectionFullSupport =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003758 pe_session->beaconParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003759 fLsigTXOPProtectionFullSupport = true;
3760 pBeaconParams->paramChangeBitmap |=
3761 PARAM_LSIG_TXOP_FULL_SUPPORT_CHANGED;
3762 } else if (!enable
3763 && (true ==
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003764 pe_session->beaconParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003765 fLsigTXOPProtectionFullSupport)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303766 pe_debug("===> Protection from LsigTxop Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003767 pBeaconParams->fLsigTXOPProtectionFullSupport =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003768 pe_session->beaconParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003769 fLsigTXOPProtectionFullSupport = false;
3770 pBeaconParams->paramChangeBitmap |=
3771 PARAM_LSIG_TXOP_FULL_SUPPORT_CHANGED;
3772 }
3773 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003774 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003775}
3776
3777/* FIXME_PROTECTION : need to check for no APSD whenever we want to enable this protection. */
3778/* This check will be done at the caller. */
3779/** -------------------------------------------------------------
3780 \fn lim_enable_ht_rifs_protection
3781 \brief based on cofig enables\disables Rifs protection.
3782 \param uint8_t enable : 1=> enable protection, 0=> disable protection.
3783 \param uint8_t overlap: 1=> called from overlap context, 0 => called from assoc context.
3784 \param tpUpdateBeaconParams pBeaconParams
3785 \return None
3786 -------------------------------------------------------------*/
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003787QDF_STATUS
Jeff Johnsond01da6b2018-12-02 12:10:22 -08003788lim_enable_ht_rifs_protection(struct mac_context *mac, uint8_t enable,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003789 uint8_t overlap, tpUpdateBeaconParams pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003790 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003791{
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003792 if (!pe_session->htCapability)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003793 return QDF_STATUS_SUCCESS; /* this protection is only for HT stations. */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003794
3795 /* overlapping protection configuration check. */
3796 if (overlap) {
3797 } else {
3798 /* normal protection config check */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003799 if (LIM_IS_AP_ROLE(pe_session) &&
3800 !pe_session->cfgProtection.rifs) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003801 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303802 pe_debug("protection from Rifs is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003803 return QDF_STATUS_SUCCESS;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003804 } else if (!LIM_IS_AP_ROLE(pe_session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003805 /* normal protection config check */
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003806 if (!mac->lim.cfgProtection.rifs) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003807 /* protection disabled. */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303808 pe_debug("protection from Rifs is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003809 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003810 }
3811 }
3812 }
3813
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003814 if (LIM_IS_AP_ROLE(pe_session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003815 /* Disabling the RIFS Protection means Enable the RIFS mode of operation in the BSS */
3816 if ((!enable)
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003817 && (false == pe_session->beaconParams.fRIFSMode)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303818 pe_debug(" => Rifs protection Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003819 pBeaconParams->fRIFSMode =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003820 pe_session->beaconParams.fRIFSMode = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003821 pBeaconParams->paramChangeBitmap |=
3822 PARAM_RIFS_MODE_CHANGED;
3823 }
3824 /* Enabling the RIFS Protection means Disable the RIFS mode of operation in the BSS */
3825 else if (enable
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003826 && (true == pe_session->beaconParams.fRIFSMode)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303827 pe_debug("===> Rifs Protection Enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003828 pBeaconParams->fRIFSMode =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003829 pe_session->beaconParams.fRIFSMode = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003830 pBeaconParams->paramChangeBitmap |=
3831 PARAM_RIFS_MODE_CHANGED;
3832 }
3833 } else {
3834 /* Disabling the RIFS Protection means Enable the RIFS mode of operation in the BSS */
3835 if ((!enable)
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003836 && (false == pe_session->beaconParams.fRIFSMode)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303837 pe_debug(" => Rifs protection Disabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003838 pBeaconParams->fRIFSMode =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003839 pe_session->beaconParams.fRIFSMode = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003840 pBeaconParams->paramChangeBitmap |=
3841 PARAM_RIFS_MODE_CHANGED;
3842 }
3843 /* Enabling the RIFS Protection means Disable the RIFS mode of operation in the BSS */
3844 else if (enable
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003845 && (true == pe_session->beaconParams.fRIFSMode)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303846 pe_debug("===> Rifs Protection Enabled");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003847 pBeaconParams->fRIFSMode =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003848 pe_session->beaconParams.fRIFSMode = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003849 pBeaconParams->paramChangeBitmap |=
3850 PARAM_RIFS_MODE_CHANGED;
3851 }
3852 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003853 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003854}
3855
3856/* --------------------------------------------------------------------- */
3857/**
3858 * lim_enable_short_preamble
3859 *
3860 * FUNCTION:
3861 * Enable/Disable short preamble
3862 *
3863 * LOGIC:
3864 *
3865 * ASSUMPTIONS:
3866 *
3867 * NOTE:
3868 *
3869 * @param enable Flag to enable/disable short preamble
3870 * @return None
3871 */
3872
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003873QDF_STATUS
Jeff Johnsond01da6b2018-12-02 12:10:22 -08003874lim_enable_short_preamble(struct mac_context *mac, uint8_t enable,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003875 tpUpdateBeaconParams pBeaconParams,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003876 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003877{
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003878 if (!mac->mlme_cfg->ht_caps.short_preamble)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003879 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003880
gaurank kathpaliae5a17e42018-09-10 10:05:25 +05303881 /* 11G short preamble switching is disabled. */
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003882 if (!mac->mlme_cfg->feature_flags.enable_short_preamble_11g)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003883 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003884
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003885 if (LIM_IS_AP_ROLE(pe_session)) {
3886 if (enable && (pe_session->beaconParams.fShortPreamble == 0)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303887 pe_debug("===> Short Preamble Enabled");
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003888 pe_session->beaconParams.fShortPreamble = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003889 pBeaconParams->fShortPreamble =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003890 (uint8_t) pe_session->beaconParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003891 fShortPreamble;
3892 pBeaconParams->paramChangeBitmap |=
3893 PARAM_SHORT_PREAMBLE_CHANGED;
3894 } else if (!enable
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003895 && (pe_session->beaconParams.fShortPreamble ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003896 1)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303897 pe_debug("===> Short Preamble Disabled");
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003898 pe_session->beaconParams.fShortPreamble = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003899 pBeaconParams->fShortPreamble =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003900 (uint8_t) pe_session->beaconParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003901 fShortPreamble;
3902 pBeaconParams->paramChangeBitmap |=
3903 PARAM_SHORT_PREAMBLE_CHANGED;
3904 }
3905 }
3906
Jeff Johnson0301ecb2018-06-29 09:36:23 -07003907 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003908}
3909
3910/**
3911 * lim_tx_complete
3912 *
3913 * Function:
3914 * This is LIM's very own "TX MGMT frame complete" completion routine.
3915 *
3916 * Logic:
3917 * LIM wants to send a MGMT frame (broadcast or unicast)
3918 * LIM allocates memory using cds_packet_alloc( ..., **pData, **pPacket )
3919 * LIM transmits the MGMT frame using the API:
3920 * wma_tx_frame( ... pPacket, ..., (void *) lim_tx_complete, pData )
3921 * HDD, via wma_tx_frame/DXE, "transfers" the packet over to BMU
3922 * HDD, if it determines that a TX completion routine (in this case
3923 * lim_tx_complete) has been provided, will invoke this callback
3924 * LIM will try to free the TX MGMT packet that was earlier allocated, in order
3925 * to send this MGMT frame, using the PAL API cds_packet_free( ... pData, pPacket )
3926 *
3927 * Assumptions:
3928 * Presently, this is ONLY being used for MGMT frames/packets
3929 * TODO:
3930 * Would it do good for LIM to have some sort of "signature" validation to
3931 * ensure that the pData argument passed in was a buffer that was actually
3932 * allocated by LIM and/or is not corrupted?
3933 *
3934 * Note: FIXME and TODO
3935 * Looks like cds_packet_free() is interested in pPacket. But, when this completion
3936 * routine is called, only pData is made available to LIM!!
3937 *
3938 * @param void A pointer to pData. Shouldn't it be pPacket?!
3939 *
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303940 * @return QDF_STATUS_SUCCESS - in case of success
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003941 */
Jeff Johnson8390fe22018-06-09 21:59:32 -07003942QDF_STATUS lim_tx_complete(void *context, qdf_nbuf_t buf, bool free)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003943{
3944 if (free)
Himanshu Agarwal2fdf77a2016-12-29 11:41:00 +05303945 cds_packet_free((void *)buf);
3946
3947 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003948}
3949
3950/**
3951 * \brief This function updates lim global structure, if CB parameters in the BSS
3952 * have changed, and sends an indication to HAL also with the
3953 * updated HT Parameters.
3954 * This function does not detect the change in the primary channel, that is done as part
3955 * of channel Swtich IE processing.
3956 * If STA is configured with '20Mhz only' mode, then this function does not do anything
3957 * This function changes the CB mode, only if the self capability is set to '20 as well as 40Mhz'
3958 *
3959 *
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003960 * \param mac Pointer to global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003961 *
3962 * \param pRcvdHTInfo Pointer to HT Info IE obtained from a Beacon or
3963 * Probe Response
3964 *
3965 * \param bssIdx BSS Index of the Bss to which Station is associated.
3966 *
3967 *
3968 */
3969
Jeff Johnsond01da6b2018-12-02 12:10:22 -08003970void lim_update_sta_run_time_ht_switch_chnl_params(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003971 tDot11fIEHTInfo *pHTInfo,
3972 uint8_t bssIdx,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003973 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003974{
3975 uint8_t center_freq = 0;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08003976 enum phy_ch_width ch_width = CH_WIDTH_20MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003977
3978 /* If self capability is set to '20Mhz only', then do not change the CB mode. */
3979 if (!lim_get_ht_capability
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003980 (mac, eHT_SUPPORTED_CHANNEL_WIDTH_SET, pe_session))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003981 return;
3982
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003983 if (WLAN_REG_IS_24GHZ_CH(pe_session->currentOperChannel) &&
3984 pe_session->force_24ghz_in_ht20) {
Abhishek Singhb59f8d42017-07-31 14:42:47 +05303985 pe_debug("force_24ghz_in_ht20 is set and channel is 2.4 Ghz");
3986 return;
3987 }
3988
Jeff Johnsonb5c13332018-12-03 09:54:51 -08003989 if (pe_session->ftPEContext.ftPreAuthSession) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05303990 pe_err("FT PREAUTH channel change is in progress");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003991 return;
3992 }
3993
Kiran Kumar Lokerea3e5e0b2015-11-03 14:17:26 -08003994 /*
3995 * Do not try to switch channel if RoC is in progress. RoC code path
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003996 * uses mac->lim.gpLimRemainOnChanReq to notify the upper layers that
Kiran Kumar Lokerea3e5e0b2015-11-03 14:17:26 -08003997 * the device has started listening on the channel requested as part of
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08003998 * RoC, if we set mac->lim.gpLimRemainOnChanReq to NULL as we do below
Kiran Kumar Lokerea3e5e0b2015-11-03 14:17:26 -08003999 * then the upper layers will think that the channel change is not
4000 * successful and the RoC from the upper layer perspective will never
4001 * end...
4002 */
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004003 if (mac->lim.gpLimRemainOnChanReq) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304004 pe_debug("RoC is in progress");
Kiran Kumar Lokerea3e5e0b2015-11-03 14:17:26 -08004005 return;
4006 }
4007
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004008 if (pe_session->ch_switch_in_progress == true) {
Kiran Kumar Lokeref9dc7912017-06-28 18:10:58 -07004009 pe_debug("ch switch is in progress, ignore HT IE BW update");
4010 return;
4011 }
4012
Abhishek Singh7889a7e2017-06-23 14:58:02 +05304013 if (!pHTInfo->primaryChannel) {
4014 pe_debug("Ignore as primary channel is 0 in HT info");
4015 return;
4016 }
4017
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004018 if (pe_session->htSecondaryChannelOffset !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004019 (uint8_t) 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) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004022 pe_session->htSecondaryChannelOffset =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004023 (ePhyChanBondState) pHTInfo->secondaryChannelOffset;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004024 pe_session->htRecommendedTxWidthSet =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004025 (uint8_t) pHTInfo->recommendedTxWidthSet;
4026 if (eHT_CHANNEL_WIDTH_40MHZ ==
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004027 pe_session->htRecommendedTxWidthSet) {
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08004028 ch_width = CH_WIDTH_40MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004029 if (PHY_DOUBLE_CHANNEL_LOW_PRIMARY ==
4030 pHTInfo->secondaryChannelOffset)
4031 center_freq = pHTInfo->primaryChannel + 2;
4032 else if (PHY_DOUBLE_CHANNEL_HIGH_PRIMARY ==
4033 pHTInfo->secondaryChannelOffset)
4034 center_freq = pHTInfo->primaryChannel - 2;
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08004035 else
4036 ch_width = CH_WIDTH_20MHZ;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004037 }
4038
4039 /* notify HAL */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304040 pe_debug("Channel Information in HT IE change"
4041 "d; sending notification to HAL.");
4042 pe_debug("Primary Channel: %d Secondary Chan"
4043 "nel Offset: %d Channel Width: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004044 pHTInfo->primaryChannel, center_freq,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004045 pe_session->htRecommendedTxWidthSet);
4046 pe_session->channelChangeReasonCode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004047 LIM_SWITCH_CHANNEL_OPERATION;
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004048 mac->lim.gpchangeChannelCallback = NULL;
4049 mac->lim.gpchangeChannelData = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004050
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004051 lim_send_switch_chnl_params(mac, (uint8_t) pHTInfo->primaryChannel,
Kiran Kumar Lokere05a0658a2018-02-01 21:34:27 -08004052 center_freq, 0, ch_width,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004053 pe_session->maxTxPower,
4054 pe_session->peSessionId,
Arif Hussain671a1902017-03-17 09:08:32 -07004055 true, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004056
4057 /* In case of IBSS, if STA should update HT Info IE in its beacons. */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004058 if (LIM_IS_IBSS_ROLE(pe_session)) {
4059 sch_set_fixed_beacon_fields(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004060 }
4061
4062 }
4063} /* End limUpdateStaRunTimeHTParams. */
4064
4065/**
4066 * \brief This function updates the lim global structure, if any of the
4067 * HT Capabilities have changed.
4068 *
4069 *
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004070 * \param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004071 *
4072 * \param pHTCapability Pointer to HT Capability Information Element
4073 * obtained from a Beacon or Probe Response
4074 *
4075 *
4076 *
4077 */
4078
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004079void lim_update_sta_run_time_ht_capability(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004080 tDot11fIEHTCaps *pHTCaps)
4081{
4082
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004083 if (mac->lim.gHTLsigTXOPProtection !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004084 (uint8_t) pHTCaps->lsigTXOPProtection) {
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004085 mac->lim.gHTLsigTXOPProtection =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004086 (uint8_t) pHTCaps->lsigTXOPProtection;
4087 /* Send change notification to HAL */
4088 }
4089
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004090 if (mac->lim.gHTAMpduDensity != (uint8_t) pHTCaps->mpduDensity) {
4091 mac->lim.gHTAMpduDensity = (uint8_t) pHTCaps->mpduDensity;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004092 /* Send change notification to HAL */
4093 }
4094
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004095 if (mac->lim.gHTMaxRxAMpduFactor !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004096 (uint8_t) pHTCaps->maxRxAMPDUFactor) {
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004097 mac->lim.gHTMaxRxAMpduFactor =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004098 (uint8_t) pHTCaps->maxRxAMPDUFactor;
4099 /* Send change notification to HAL */
4100 }
4101
4102} /* End lim_update_sta_run_time_ht_capability. */
4103
4104/**
4105 * \brief This function updates lim global structure, if any of the HT
4106 * Info Parameters have changed.
4107 *
4108 *
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004109 * \param mac Pointer to the global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004110 *
4111 * \param pHTInfo Pointer to the HT Info IE obtained from a Beacon or
4112 * Probe Response
4113 *
4114 *
4115 */
4116
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004117void lim_update_sta_run_time_ht_info(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004118 tDot11fIEHTInfo *pHTInfo,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004119 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004120{
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004121 if (pe_session->htRecommendedTxWidthSet !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004122 (uint8_t) pHTInfo->recommendedTxWidthSet) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004123 pe_session->htRecommendedTxWidthSet =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004124 (uint8_t) pHTInfo->recommendedTxWidthSet;
4125 /* Send change notification to HAL */
4126 }
4127
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004128 if (pe_session->beaconParams.fRIFSMode !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004129 (uint8_t) pHTInfo->rifsMode) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004130 pe_session->beaconParams.fRIFSMode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004131 (uint8_t) pHTInfo->rifsMode;
4132 /* Send change notification to HAL */
4133 }
4134
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004135 if (mac->lim.gHTServiceIntervalGranularity !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004136 (uint8_t) pHTInfo->serviceIntervalGranularity) {
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004137 mac->lim.gHTServiceIntervalGranularity =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004138 (uint8_t) pHTInfo->serviceIntervalGranularity;
4139 /* Send change notification to HAL */
4140 }
4141
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004142 if (mac->lim.gHTOperMode != (tSirMacHTOperatingMode) pHTInfo->opMode) {
4143 mac->lim.gHTOperMode =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004144 (tSirMacHTOperatingMode) pHTInfo->opMode;
4145 /* Send change notification to HAL */
4146 }
4147
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004148 if (pe_session->beaconParams.llnNonGFCoexist !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004149 pHTInfo->nonGFDevicesPresent) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004150 pe_session->beaconParams.llnNonGFCoexist =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004151 (uint8_t) pHTInfo->nonGFDevicesPresent;
4152 }
4153
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004154 if (mac->lim.gHTSTBCBasicMCS != (uint8_t) pHTInfo->basicSTBCMCS) {
4155 mac->lim.gHTSTBCBasicMCS = (uint8_t) pHTInfo->basicSTBCMCS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004156 /* Send change notification to HAL */
4157 }
4158
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004159 if (mac->lim.gHTDualCTSProtection !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004160 (uint8_t) pHTInfo->dualCTSProtection) {
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004161 mac->lim.gHTDualCTSProtection =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004162 (uint8_t) pHTInfo->dualCTSProtection;
4163 /* Send change notification to HAL */
4164 }
4165
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004166 if (mac->lim.gHTSecondaryBeacon != (uint8_t) pHTInfo->secondaryBeacon) {
4167 mac->lim.gHTSecondaryBeacon =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004168 (uint8_t) pHTInfo->secondaryBeacon;
4169 /* Send change notification to HAL */
4170 }
4171
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004172 if (pe_session->beaconParams.fLsigTXOPProtectionFullSupport !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004173 (uint8_t) pHTInfo->lsigTXOPProtectionFullSupport) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004174 pe_session->beaconParams.fLsigTXOPProtectionFullSupport =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004175 (uint8_t) pHTInfo->lsigTXOPProtectionFullSupport;
4176 /* Send change notification to HAL */
4177 }
4178
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004179 if (mac->lim.gHTPCOActive != (uint8_t) pHTInfo->pcoActive) {
4180 mac->lim.gHTPCOActive = (uint8_t) pHTInfo->pcoActive;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004181 /* Send change notification to HAL */
4182 }
4183
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004184 if (mac->lim.gHTPCOPhase != (uint8_t) pHTInfo->pcoPhase) {
4185 mac->lim.gHTPCOPhase = (uint8_t) pHTInfo->pcoPhase;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004186 /* Send change notification to HAL */
4187 }
4188
4189} /* End lim_update_sta_run_time_ht_info. */
4190
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004191/**
4192 * lim_validate_delts_req() - This function validates DelTs req
4193 * @mac_ctx: pointer to Global Mac structure
4194 * @delts_req: pointer to delete traffic stream structure
4195 * @peer_mac_addr: variable for peer mac address
4196 *
4197 * Function validates DelTs req originated by SME or by HAL and also
4198 * sends halMsg_DelTs to HAL
4199 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004200 * Return: QDF_STATUS_SUCCESS - Success, QDF_STATUS_E_FAILURE - Failure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004201 */
4202
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004203QDF_STATUS
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004204lim_validate_delts_req(struct mac_context *mac_ctx, tpSirDeltsReq delts_req,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08004205 tSirMacAddr peer_mac_addr, struct pe_session *psession_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004206{
4207 tpDphHashNode sta;
4208 uint8_t ts_status;
4209 tSirMacTSInfo *tsinfo;
4210 uint32_t i;
4211 uint8_t tspec_idx;
4212
4213 /*
4214 * if sta
4215 * - verify assoc state
4216 * - del tspec locally
4217 * if ap
4218 * - verify sta is in assoc state
4219 * - del sta tspec locally
4220 */
4221 if (delts_req == NULL) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304222 pe_err("Delete TS request pointer is NULL");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004223 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004224 }
4225
Rajeev Kumar0ac9f2a2016-04-15 15:54:18 -07004226 if (LIM_IS_STA_ROLE(psession_entry)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004227 uint32_t val;
4228
4229 /* station always talks to the AP */
4230 sta = dph_get_hash_entry(mac_ctx, DPH_STA_HASH_INDEX_PEER,
4231 &psession_entry->dph.dphHashTable);
4232
4233 val = sizeof(tSirMacAddr);
4234 sir_copy_mac_addr(peer_mac_addr, psession_entry->bssId);
4235
4236 } else {
4237 uint16_t associd;
4238 uint8_t *macaddr = (uint8_t *) peer_mac_addr;
4239
4240 associd = delts_req->aid;
4241 if (associd != 0)
4242 sta = dph_get_hash_entry(mac_ctx, associd,
4243 &psession_entry->dph.dphHashTable);
4244 else
4245 sta = dph_lookup_hash_entry(mac_ctx,
Srinivas Girigowdabab88932015-12-03 19:18:11 -08004246 delts_req->macaddr.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004247 &associd,
4248 &psession_entry->dph.
4249 dphHashTable);
4250
4251 if (sta != NULL)
4252 /* TBD: check sta assoc state as well */
4253 for (i = 0; i < sizeof(tSirMacAddr); i++)
4254 macaddr[i] = sta->staAddr[i];
4255 }
4256
4257 if (sta == NULL) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304258 pe_err("Cannot find station context for delts req");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004259 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004260 }
4261
4262 if ((!sta->valid) ||
4263 (sta->mlmStaContext.mlmState !=
4264 eLIM_MLM_LINK_ESTABLISHED_STATE)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304265 pe_err("Invalid Sta (or state) for DelTsReq");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004266 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004267 }
4268
4269 delts_req->req.wsmTspecPresent = 0;
4270 delts_req->req.wmeTspecPresent = 0;
4271 delts_req->req.lleTspecPresent = 0;
4272
4273 if ((sta->wsmEnabled) &&
4274 (delts_req->req.tspec.tsinfo.traffic.accessPolicy !=
4275 SIR_MAC_ACCESSPOLICY_EDCA))
4276 delts_req->req.wsmTspecPresent = 1;
4277 else if (sta->wmeEnabled)
4278 delts_req->req.wmeTspecPresent = 1;
4279 else if (sta->lleEnabled)
4280 delts_req->req.lleTspecPresent = 1;
4281 else {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304282 pe_warn("DELTS_REQ ignore - qos is disabled");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004283 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004284 }
4285
4286 tsinfo = delts_req->req.wmeTspecPresent ? &delts_req->req.tspec.tsinfo
4287 : &delts_req->req.tsinfo;
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304288 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 -08004289 delts_req->req.wmeTspecPresent,
4290 delts_req->req.lleTspecPresent,
4291 delts_req->req.wsmTspecPresent, tsinfo->traffic.tsid,
4292 tsinfo->traffic.userPrio, tsinfo->traffic.direction);
4293
4294 /* if no Access Control, ignore the request */
4295 if (lim_admit_control_delete_ts(mac_ctx, sta->assocId, tsinfo,
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004296 &ts_status, &tspec_idx) != QDF_STATUS_SUCCESS) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304297 pe_err("DELTS request for sta assocId: %d tsid: %d up: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004298 sta->assocId, tsinfo->traffic.tsid,
4299 tsinfo->traffic.userPrio);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004300 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004301 } else if ((tsinfo->traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_HCCA)
4302 || (tsinfo->traffic.accessPolicy ==
4303 SIR_MAC_ACCESSPOLICY_BOTH)) {
4304 /* edca only now. */
4305 } else if (tsinfo->traffic.accessPolicy == SIR_MAC_ACCESSPOLICY_EDCA) {
4306 /* send message to HAL to delete TS */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004307 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004308 lim_send_hal_msg_del_ts(mac_ctx, sta->staIndex,
4309 tspec_idx, delts_req->req,
4310 psession_entry->peSessionId,
4311 psession_entry->bssId)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304312 pe_warn("DelTs with UP: %d failed in lim_send_hal_msg_del_ts - ignoring request",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004313 tsinfo->traffic.userPrio);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004314 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004315 }
4316 }
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004317 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004318}
4319
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004320/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004321 * @function : lim_post_sm_state_update()
4322 *
4323 * @brief : This function Updates the HAL and Softmac about the change in the STA's SMPS state.
4324 *
4325 * LOGIC:
4326 *
4327 * ASSUMPTIONS:
4328 * NA
4329 *
4330 * NOTE:
4331 * NA
4332 *
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004333 * @param mac - Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004334 * @param limMsg - Lim Message structure object with the MimoPSparam in body
4335 * @return None
4336 */
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004337QDF_STATUS
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004338lim_post_sm_state_update(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004339 uint16_t staIdx, tSirMacHTMIMOPowerSaveState state,
4340 uint8_t *pPeerStaMac, uint8_t sessionId)
4341{
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004342 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Rajeev Kumar37d478b2017-04-17 16:59:28 -07004343 struct scheduler_msg msgQ = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004344 tpSetMIMOPS pMIMO_PSParams;
4345
4346 msgQ.reserved = 0;
4347 msgQ.type = WMA_SET_MIMOPS_REQ;
4348
4349 /* Allocate for WMA_SET_MIMOPS_REQ */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304350 pMIMO_PSParams = qdf_mem_malloc(sizeof(tSetMIMOPS));
Arif Hussainf5b6c412018-10-10 19:41:09 -07004351 if (!pMIMO_PSParams)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004352 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004353
4354 pMIMO_PSParams->htMIMOPSState = state;
4355 pMIMO_PSParams->staIdx = staIdx;
4356 pMIMO_PSParams->fsendRsp = true;
4357 pMIMO_PSParams->sessionId = sessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304358 qdf_mem_copy(pMIMO_PSParams->peerMac, pPeerStaMac, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004359
4360 msgQ.bodyptr = pMIMO_PSParams;
4361 msgQ.bodyval = 0;
4362
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304363 pe_debug("Sending WMA_SET_MIMOPS_REQ");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004364
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004365 MTRACE(mac_trace_msg_tx(mac, NO_SESSION, msgQ.type));
4366 retCode = wma_post_ctrl_msg(mac, &msgQ);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004367 if (QDF_STATUS_SUCCESS != retCode) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304368 pe_err("Posting WMA_SET_MIMOPS_REQ to HAL failed! Reason: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004369 retCode);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304370 qdf_mem_free(pMIMO_PSParams);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004371 return retCode;
4372 }
4373
4374 return retCode;
4375}
4376
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004377void lim_pkt_free(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004378 eFrameType frmType, uint8_t *pRxPacketInfo, void *pBody)
4379{
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004380 (void)mac;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004381 (void)frmType;
4382 (void)pRxPacketInfo;
4383 (void)pBody;
4384}
4385
4386/**
4387 * lim_get_b_dfrom_rx_packet()
4388 *
4389 ***FUNCTION:
4390 * This function is called to get pointer to Polaris
4391 * Buffer Descriptor containing MAC header & other control
4392 * info from the body of the message posted to LIM.
4393 *
4394 ***LOGIC:
4395 * NA
4396 *
4397 ***ASSUMPTIONS:
4398 * NA
4399 *
4400 ***NOTE:
4401 * NA
4402 *
4403 * @param body - Received message body
4404 * @param pRxPacketInfo - Pointer to received BD
4405 * @return None
4406 */
4407
4408void
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004409lim_get_b_dfrom_rx_packet(struct mac_context *mac, void *body, uint32_t **pRxPacketInfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004410{
4411 *pRxPacketInfo = (uint32_t *) body;
4412} /*** end lim_get_b_dfrom_rx_packet() ***/
4413
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004414void lim_add_channel_status_info(struct mac_context *p_mac,
gaoleze5108942017-03-31 16:56:42 +08004415 struct lim_channel_status *channel_stat,
4416 uint8_t channel_id)
4417{
4418 uint8_t i;
4419 bool found = false;
4420 struct lim_scan_channel_status *channel_info =
4421 &p_mac->lim.scan_channel_status;
4422 struct lim_channel_status *channel_status_list =
4423 channel_info->channel_status_list;
4424 uint8_t total_channel = channel_info->total_channel;
4425
4426 if (!p_mac->sap.acs_with_more_param)
4427 return;
4428
4429 for (i = 0; i < total_channel; i++) {
4430 if (channel_status_list[i].channel_id == channel_id) {
4431 if (channel_stat->cmd_flags ==
4432 WMI_CHAN_InFO_END_RESP &&
4433 channel_status_list[i].cmd_flags ==
4434 WMI_CHAN_InFO_START_RESP) {
4435 /* adjust to delta value for counts */
4436 channel_stat->rx_clear_count -=
4437 channel_status_list[i].rx_clear_count;
4438 channel_stat->cycle_count -=
4439 channel_status_list[i].cycle_count;
4440 channel_stat->rx_frame_count -=
4441 channel_status_list[i].rx_frame_count;
4442 channel_stat->tx_frame_count -=
4443 channel_status_list[i].tx_frame_count;
4444 channel_stat->bss_rx_cycle_count -=
4445 channel_status_list[i].bss_rx_cycle_count;
4446 }
4447 qdf_mem_copy(&channel_status_list[i], channel_stat,
4448 sizeof(*channel_status_list));
4449 found = true;
4450 break;
4451 }
4452 }
4453
4454 if (!found) {
4455 if (total_channel < SIR_MAX_SUPPORTED_CHANNEL_LIST) {
4456 qdf_mem_copy(&channel_status_list[total_channel++],
4457 channel_stat,
4458 sizeof(*channel_status_list));
4459 channel_info->total_channel = total_channel;
4460 } else {
4461 pe_warn("Chan cnt exceed, channel_id=%d", channel_id);
4462 }
4463 }
4464
4465 return;
4466}
4467
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004468/**
4469 * @function : lim_is_channel_valid_for_channel_switch()
4470 *
4471 * @brief : This function checks if the channel to which AP
4472 * is expecting us to switch, is a valid channel for us.
4473 * LOGIC:
4474 *
4475 * ASSUMPTIONS:
4476 * NA
4477 *
4478 * NOTE:
4479 * NA
4480 *
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004481 * @param mac - Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004482 * @param channel - New channel to which we are expected to move
4483 * @return None
4484 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004485bool lim_is_channel_valid_for_channel_switch(struct mac_context *mac, uint8_t channel)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004486{
4487 uint8_t index;
4488 uint32_t validChannelListLen = WNI_CFG_VALID_CHANNEL_LIST_LEN;
4489 tSirMacChanNum validChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN];
Bala Venkatesh867d4112018-06-08 12:53:31 +05304490 bool ok = false;
Ajit Pal Singh7ae88fb2017-09-06 16:14:35 +05304491
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004492 if (policy_mgr_is_chan_ok_for_dnbs(mac->psoc, channel, &ok)) {
Ajit Pal Singh7ae88fb2017-09-06 16:14:35 +05304493 pe_err("policy_mgr_is_chan_ok_for_dnbs() returned error");
4494 return false;
4495 }
4496
4497 if (!ok) {
4498 pe_debug("channel not ok for DNBS");
4499 return false;
4500 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004501
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004502 if (wlan_cfg_get_str(mac, WNI_CFG_VALID_CHANNEL_LIST,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004503 (uint8_t *) validChannelList,
4504 (uint32_t *) &validChannelListLen) !=
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004505 QDF_STATUS_SUCCESS) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304506 pe_err("could not retrieve valid channel list");
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07004507 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004508 }
4509
4510 for (index = 0; index < validChannelListLen; index++) {
Bala Venkatesh867d4112018-06-08 12:53:31 +05304511 if (validChannelList[index] != channel)
4512 continue;
4513
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004514 ok = policy_mgr_is_valid_for_channel_switch(mac->psoc,
Bala Venkatesh867d4112018-06-08 12:53:31 +05304515 channel);
4516 return ok;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004517 }
4518
4519 /* channel does not belong to list of valid channels */
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07004520 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004521}
4522
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004523/**
4524 * @function : lim_restore_pre_channel_switch_state()
4525 *
4526 * @brief : This API is called by the user to undo any
4527 * specific changes done on the device during
4528 * channel switch.
4529 * LOGIC:
4530 *
4531 * ASSUMPTIONS:
4532 * NA
4533 *
4534 * NOTE:
4535 * NA
4536 *
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004537 * @param mac - Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004538 * @return None
4539 */
4540
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004541QDF_STATUS
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004542lim_restore_pre_channel_switch_state(struct mac_context *mac, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004543{
4544
Jeff Johnson0301ecb2018-06-29 09:36:23 -07004545 QDF_STATUS retCode = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004546
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004547 if (!LIM_IS_STA_ROLE(pe_session))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004548 return retCode;
4549
4550 /* Channel switch should be ready for the next time */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004551 pe_session->gLimSpecMgmt.dot11hChanSwState = eLIM_11H_CHANSW_INIT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004552
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004553 return retCode;
4554}
4555
4556/**
4557 * @function: lim_prepare_for11h_channel_switch()
4558 *
4559 * @brief : This API is called by the user to prepare for
4560 * 11h channel switch. As of now, the API does
4561 * very minimal work. User can add more into the
4562 * same API if needed.
4563 * LOGIC:
4564 *
4565 * ASSUMPTIONS:
4566 * NA
4567 *
4568 * NOTE:
4569 * NA
4570 *
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004571 * @param mac - Pointer to Global MAC structure
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004572 * @param pe_session
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004573 * @return None
4574 */
4575void
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004576lim_prepare_for11h_channel_switch(struct mac_context *mac, struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004577{
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004578 if (!LIM_IS_STA_ROLE(pe_session))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004579 return;
4580
4581 /* Flag to indicate 11h channel switch in progress */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004582 pe_session->gLimSpecMgmt.dot11hChanSwState = eLIM_11H_CHANSW_RUNNING;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004583
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004584 if (mac->lim.gLimSmeState == eLIM_SME_LINK_EST_WT_SCAN_STATE ||
4585 mac->lim.gLimSmeState == eLIM_SME_CHANNEL_SCAN_STATE) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304586 pe_debug("Posting finish scan as we are in scan state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004587 /* Stop ongoing scanning if any */
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004588 if (GET_LIM_PROCESS_DEFD_MESGS(mac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004589 /* Set the resume channel to Any valid channel (invalid). */
4590 /* This will instruct HAL to set it to any previous valid channel. */
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004591 pe_set_resume_channel(mac, 0, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004592 } else {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004593 lim_restore_pre_channel_switch_state(mac, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004594 }
4595 return;
4596 } else {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304597 pe_debug("Not in scan state, start channel switch timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004598 /** We are safe to switch channel at this point */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004599 lim_stop_tx_and_switch_channel(mac, pe_session->peSessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004600 }
4601}
4602
4603/**----------------------------------------------------
4604 \fn lim_get_nw_type
4605
4606 \brief Get type of the network from data packet or beacon
Jeff Johnson982fe962018-11-28 17:07:01 -08004607 \param mac
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004608 \param channelNum - Channel number
4609 \param type - Type of packet.
4610 \param pBeacon - Pointer to beacon or probe response
4611
4612 \return Network type a/b/g.
4613 -----------------------------------------------------*/
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004614tSirNwType lim_get_nw_type(struct mac_context *mac, uint8_t channelNum, uint32_t type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004615 tpSchBeaconStruct pBeacon)
4616{
4617 tSirNwType nwType = eSIR_11B_NW_TYPE;
4618
4619 if (type == SIR_MAC_DATA_FRAME) {
4620 if ((channelNum > 0) && (channelNum < 15)) {
4621 nwType = eSIR_11G_NW_TYPE;
4622 } else {
4623 nwType = eSIR_11A_NW_TYPE;
4624 }
4625 } else {
4626 if ((channelNum > 0) && (channelNum < 15)) {
4627 int i;
4628 /* 11b or 11g packet */
4629 /* 11g iff extended Rate IE is present or */
4630 /* if there is an A rate in suppRate IE */
4631 for (i = 0; i < pBeacon->supportedRates.numRates; i++) {
4632 if (sirIsArate
4633 (pBeacon->supportedRates.rate[i] & 0x7f)) {
4634 nwType = eSIR_11G_NW_TYPE;
4635 break;
4636 }
4637 }
4638 if (pBeacon->extendedRatesPresent) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004639 nwType = eSIR_11G_NW_TYPE;
yeshwanth sriram guntuka47f26e62017-03-07 12:43:02 +05304640 } else if (pBeacon->HTInfo.present ||
4641 IS_BSS_VHT_CAPABLE(pBeacon->VHTCaps)) {
4642 nwType = eSIR_11G_NW_TYPE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004643 }
4644 } else {
4645 /* 11a packet */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004646 nwType = eSIR_11A_NW_TYPE;
4647 }
4648 }
4649 return nwType;
4650}
4651
4652/**---------------------------------------------------------
4653 \fn lim_get_channel_from_beacon
4654 \brief To extract channel number from beacon
4655
Jeff Johnson982fe962018-11-28 17:07:01 -08004656 \param mac
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004657 \param pBeacon - Pointer to beacon or probe rsp
4658 \return channel number
4659 -----------------------------------------------------------*/
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004660uint8_t lim_get_channel_from_beacon(struct mac_context *mac, tpSchBeaconStruct pBeacon)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004661{
4662 uint8_t channelNum = 0;
4663
4664 if (pBeacon->dsParamsPresent)
4665 channelNum = pBeacon->channelNumber;
4666 else if (pBeacon->HTInfo.present)
4667 channelNum = pBeacon->HTInfo.primaryChannel;
4668 else
4669 channelNum = pBeacon->channelNumber;
4670
4671 return channelNum;
4672}
4673
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004674void lim_set_tspec_uapsd_mask_per_session(struct mac_context *mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004675 struct pe_session *pe_session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004676 tSirMacTSInfo *pTsInfo, uint32_t action)
4677{
4678 uint8_t userPrio = (uint8_t) pTsInfo->traffic.userPrio;
4679 uint16_t direction = pTsInfo->traffic.direction;
4680 uint8_t ac = upToAc(userPrio);
4681
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304682 pe_debug("Set UAPSD mask for AC: %d dir: %d action: %d"
4683 , ac, direction, action);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004684
4685 /* Converting AC to appropriate Uapsd Bit Mask
4686 * AC_BE(0) --> UAPSD_BITOFFSET_ACVO(3)
4687 * AC_BK(1) --> UAPSD_BITOFFSET_ACVO(2)
4688 * AC_VI(2) --> UAPSD_BITOFFSET_ACVO(1)
4689 * AC_VO(3) --> UAPSD_BITOFFSET_ACVO(0)
4690 */
4691 ac = ((~ac) & 0x3);
4692
4693 if (action == CLEAR_UAPSD_MASK) {
4694 if (direction == SIR_MAC_DIRECTION_UPLINK)
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004695 pe_session->gUapsdPerAcTriggerEnableMask &=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004696 ~(1 << ac);
4697 else if (direction == SIR_MAC_DIRECTION_DNLINK)
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004698 pe_session->gUapsdPerAcDeliveryEnableMask &=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004699 ~(1 << ac);
4700 else if (direction == SIR_MAC_DIRECTION_BIDIR) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004701 pe_session->gUapsdPerAcTriggerEnableMask &=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004702 ~(1 << ac);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004703 pe_session->gUapsdPerAcDeliveryEnableMask &=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004704 ~(1 << ac);
4705 }
4706 } else if (action == SET_UAPSD_MASK) {
4707 if (direction == SIR_MAC_DIRECTION_UPLINK)
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004708 pe_session->gUapsdPerAcTriggerEnableMask |=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004709 (1 << ac);
4710 else if (direction == SIR_MAC_DIRECTION_DNLINK)
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004711 pe_session->gUapsdPerAcDeliveryEnableMask |=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004712 (1 << ac);
4713 else if (direction == SIR_MAC_DIRECTION_BIDIR) {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004714 pe_session->gUapsdPerAcTriggerEnableMask |=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004715 (1 << ac);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004716 pe_session->gUapsdPerAcDeliveryEnableMask |=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004717 (1 << ac);
4718 }
4719 }
4720
Jeff Johnsonb5c13332018-12-03 09:54:51 -08004721 pe_debug("New pe_session->gUapsdPerAcTriggerEnableMask 0x%x pe_session->gUapsdPerAcDeliveryEnableMask 0x%x",
4722 pe_session->gUapsdPerAcTriggerEnableMask,
4723 pe_session->gUapsdPerAcDeliveryEnableMask);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004724
4725 return;
4726}
4727
4728/**
4729 * lim_handle_heart_beat_timeout_for_session() - Handle heart beat time out
4730 * @mac_ctx: pointer to Global Mac Structure
Jeff Johnsonc8baa902018-11-18 21:59:07 -08004731 * @psession_entry: pointer to struct pe_session *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004732 *
4733 * Function handles heart beat time out for session
4734 *
4735 * Return: none
4736 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004737void lim_handle_heart_beat_timeout_for_session(struct mac_context *mac_ctx,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08004738 struct pe_session *psession_entry)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004739{
4740 if (psession_entry->valid == true) {
4741 if (psession_entry->bssType == eSIR_IBSS_MODE)
4742 lim_ibss_heart_beat_handle(mac_ctx, psession_entry);
4743
4744 if ((psession_entry->bssType == eSIR_INFRASTRUCTURE_MODE) &&
4745 (LIM_IS_STA_ROLE(psession_entry)))
4746 lim_handle_heart_beat_failure(mac_ctx, psession_entry);
4747 }
4748 /*
4749 * In the function lim_handle_heart_beat_failure things can change
4750 * so check for the session entry valid and the other things
4751 * again
4752 */
4753 if ((psession_entry->valid == true) &&
4754 (psession_entry->bssType == eSIR_INFRASTRUCTURE_MODE) &&
4755 (LIM_IS_STA_ROLE(psession_entry)) &&
4756 (psession_entry->LimHBFailureStatus == true)) {
4757 tLimTimers *lim_timer = &mac_ctx->lim.limTimers;
4758 /*
4759 * Activate Probe After HeartBeat Timer incase HB
4760 * Failure detected
4761 */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304762 pe_debug("Sending Probe for Session: %d",
4763 psession_entry->bssIdx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004764 lim_deactivate_and_change_timer(mac_ctx,
4765 eLIM_PROBE_AFTER_HB_TIMER);
4766 MTRACE(mac_trace(mac_ctx, TRACE_CODE_TIMER_ACTIVATE, 0,
4767 eLIM_PROBE_AFTER_HB_TIMER));
4768 if (tx_timer_activate(&lim_timer->gLimProbeAfterHBTimer)
4769 != TX_SUCCESS)
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304770 pe_err("Fail to re-activate Probe-after-hb timer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004771 }
4772}
4773
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004774uint8_t lim_get_current_operating_channel(struct mac_context *mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004775{
4776 uint8_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07004777
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004778 for (i = 0; i < mac->lim.maxBssId; i++) {
4779 if (mac->lim.gpSession[i].valid == true) {
4780 if ((mac->lim.gpSession[i].bssType ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004781 eSIR_INFRASTRUCTURE_MODE)
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004782 && (mac->lim.gpSession[i].limSystemRole ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004783 eLIM_STA_ROLE)) {
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004784 return mac->lim.gpSession[i].
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004785 currentOperChannel;
4786 }
4787 }
4788 }
4789 return 0;
4790}
4791
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07004792/**
4793 * lim_process_add_sta_rsp() - process WDA_ADD_STA_RSP from WMA
4794 * @mac_ctx: Pointer to Global MAC structure
4795 * @msg: msg from WMA
4796 *
4797 * @Return: void
4798 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004799void lim_process_add_sta_rsp(struct mac_context *mac_ctx, struct scheduler_msg *msg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004800{
Jeff Johnsonc8baa902018-11-18 21:59:07 -08004801 struct pe_session *session;
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07004802 tpAddStaParams add_sta_params;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004803
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07004804 add_sta_params = (tpAddStaParams) msg->bodyptr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004805
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07004806 session = pe_find_session_by_session_id(mac_ctx,
4807 add_sta_params->sessionId);
4808 if (session == NULL) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304809 pe_err("Session Does not exist for given sessionID");
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07004810 qdf_mem_free(add_sta_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004811 return;
4812 }
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07004813 session->csaOffloadEnable = add_sta_params->csaOffloadEnable;
4814 if (LIM_IS_IBSS_ROLE(session))
4815 (void)lim_ibss_add_sta_rsp(mac_ctx, msg->bodyptr, session);
4816 else if (LIM_IS_NDI_ROLE(session))
4817 lim_ndp_add_sta_rsp(mac_ctx, session, msg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004818#ifdef FEATURE_WLAN_TDLS
Bala Venkatesh6e3925b2018-07-19 12:31:21 +05304819 else if (add_sta_params->staType == STA_ENTRY_TDLS_PEER)
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07004820 lim_process_tdls_add_sta_rsp(mac_ctx, msg->bodyptr, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004821#endif
4822 else
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07004823 lim_process_mlm_add_sta_rsp(mac_ctx, msg, session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004824
4825}
4826
4827/**
4828 * lim_update_beacon() - This function updates beacon
4829 * @mac_ctx: pointer to Global Mac Structure
4830 *
4831 * This Function is invoked to update the beacon
4832 *
4833 * Return: none
4834 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004835void lim_update_beacon(struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004836{
4837 uint8_t i;
4838
4839 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
4840 if (mac_ctx->lim.gpSession[i].valid != true)
4841 continue;
4842 if (((mac_ctx->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE)
4843 || (mac_ctx->lim.gpSession[i].limSystemRole ==
4844 eLIM_STA_IN_IBSS_ROLE))
4845 && (eLIM_SME_NORMAL_STATE ==
4846 mac_ctx->lim.gpSession[i].limSmeState)) {
4847
4848 sch_set_fixed_beacon_fields(mac_ctx,
4849 &mac_ctx->lim.gpSession[i]);
4850
4851 if (false == mac_ctx->sap.SapDfsInfo.
4852 is_dfs_cac_timer_running)
4853 lim_send_beacon_ind(mac_ctx,
Abhishek Singhfc740be2018-10-12 11:34:26 +05304854 &mac_ctx->lim.gpSession[i],
4855 REASON_DEFAULT);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004856 }
4857 }
4858}
4859
4860/**
4861 * lim_handle_heart_beat_failure_timeout - handle heart beat failure
4862 * @mac_ctx: pointer to Global Mac Structure
4863 *
4864 * Function handle heart beat failure timeout
4865 *
4866 * Return: none
4867 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004868void lim_handle_heart_beat_failure_timeout(struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004869{
4870 uint8_t i;
Jeff Johnsonc8baa902018-11-18 21:59:07 -08004871 struct pe_session *psession_entry;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004872 /*
4873 * Probe response is not received after HB failure.
4874 * This is handled by LMM sub module.
4875 */
4876 for (i = 0; i < mac_ctx->lim.maxBssId; i++) {
4877 if (mac_ctx->lim.gpSession[i].valid != true)
4878 continue;
4879 psession_entry = &mac_ctx->lim.gpSession[i];
4880 if (psession_entry->LimHBFailureStatus != true)
4881 continue;
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304882 pe_debug("SME: %d MLME: %d HB-Count: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004883 psession_entry->limSmeState,
4884 psession_entry->limMlmState,
4885 psession_entry->LimRxedBeaconCntDuringHB);
4886
4887#ifdef FEATURE_WLAN_DIAG_SUPPORT_LIM
4888 lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_HB_FAILURE_TIMEOUT,
4889 psession_entry, 0, 0);
4890#endif
4891 if ((psession_entry->limMlmState ==
4892 eLIM_MLM_LINK_ESTABLISHED_STATE) &&
4893 (psession_entry->limSmeState !=
4894 eLIM_SME_WT_DISASSOC_STATE) &&
4895 (psession_entry->limSmeState !=
4896 eLIM_SME_WT_DEAUTH_STATE) &&
4897 ((!LIM_IS_CONNECTION_ACTIVE(psession_entry)) ||
4898 /*
4899 * Disconnect even if we have not received a single
4900 * beacon after connection.
4901 */
4902 (psession_entry->currentBssBeaconCnt == 0))) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304903 pe_debug("for session: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004904 psession_entry->peSessionId);
Paul Zhange73d1a32017-05-09 23:08:17 +08004905
4906 lim_send_deauth_mgmt_frame(mac_ctx,
4907 eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON,
4908 psession_entry->bssId, psession_entry, false);
4909
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004910 /*
4911 * AP did not respond to Probe Request.
4912 * Tear down link with it.
4913 */
4914 lim_tear_down_link_with_ap(mac_ctx,
4915 psession_entry->peSessionId,
4916 eSIR_BEACON_MISSED);
4917 mac_ctx->lim.gLimProbeFailureAfterHBfailedCnt++;
4918 } else {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05304919 pe_err("Unexpected wt-probe-timeout in state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004920 lim_print_mlm_state(mac_ctx, LOGE,
4921 psession_entry->limMlmState);
Varun Reddy Yeturu076eaa82018-01-16 12:16:14 -08004922 if (mac_ctx->sme.tx_queue_cb)
Jeff Johnson6aaaa992018-06-30 10:43:04 -07004923 mac_ctx->sme.tx_queue_cb(mac_ctx->hdd_handle,
Varun Reddy Yeturu076eaa82018-01-16 12:16:14 -08004924 psession_entry->smeSessionId,
4925 WLAN_WAKE_ALL_NETIF_QUEUE,
4926 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004927 }
4928 }
4929 /*
4930 * Deactivate Timer ProbeAfterHB Timer -> As its a oneshot timer,
4931 * need not deactivate the timer
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004932 * tx_timer_deactivate(&mac->lim.limTimers.gLimProbeAfterHBTimer);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004933 */
4934}
4935
4936/*
4937 * This function assumes there will not be more than one IBSS session active at any time.
4938 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004939struct pe_session *lim_is_ibss_session_active(struct mac_context *mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004940{
4941 uint8_t i;
4942
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004943 for (i = 0; i < mac->lim.maxBssId; i++) {
4944 if ((mac->lim.gpSession[i].valid) &&
4945 (mac->lim.gpSession[i].limSystemRole ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004946 eLIM_STA_IN_IBSS_ROLE))
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004947 return &mac->lim.gpSession[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004948 }
4949
4950 return NULL;
4951}
4952
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004953struct pe_session *lim_is_ap_session_active(struct mac_context *mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004954{
4955 uint8_t i;
4956
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004957 for (i = 0; i < mac->lim.maxBssId; i++) {
4958 if (mac->lim.gpSession[i].valid &&
4959 (mac->lim.gpSession[i].limSystemRole == eLIM_AP_ROLE))
4960 return &mac->lim.gpSession[i];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004961 }
4962
4963 return NULL;
4964}
4965
4966/**---------------------------------------------------------
4967 \fn lim_handle_defer_msg_error
4968 \brief handles error scenario, when the msg can not be deferred.
Jeff Johnson982fe962018-11-28 17:07:01 -08004969 \param mac
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004970 \param pLimMsg LIM msg, which could not be deferred.
4971 \return void
4972 -----------------------------------------------------------*/
4973
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004974void lim_handle_defer_msg_error(struct mac_context *mac,
Rajeev Kumarfeb96382017-01-22 19:42:09 -08004975 struct scheduler_msg *pLimMsg)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004976{
4977 if (SIR_BB_XPORT_MGMT_MSG == pLimMsg->type) {
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08004978 lim_decrement_pending_mgmt_count(mac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004979 cds_pkt_return_packet((cds_pkt_t *) pLimMsg->bodyptr);
4980 pLimMsg->bodyptr = NULL;
4981 } else if (pLimMsg->bodyptr != NULL) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304982 qdf_mem_free(pLimMsg->bodyptr);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004983 pLimMsg->bodyptr = NULL;
4984 }
4985
4986}
4987
4988#ifdef FEATURE_WLAN_DIAG_SUPPORT
4989/**---------------------------------------------------------
4990 \fn lim_diag_event_report
4991 \brief This function reports Diag event
Jeff Johnson982fe962018-11-28 17:07:01 -08004992 \param mac
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004993 \param eventType
4994 \param bssid
4995 \param status
4996 \param reasonCode
4997 \return void
4998 -----------------------------------------------------------*/
Jeff Johnsond01da6b2018-12-02 12:10:22 -08004999void lim_diag_event_report(struct mac_context *mac, uint16_t eventType,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005000 struct pe_session *pe_session, uint16_t status,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005001 uint16_t reasonCode)
5002{
5003 tSirMacAddr nullBssid = { 0, 0, 0, 0, 0, 0 };
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07005004
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005005 WLAN_HOST_DIAG_EVENT_DEF(peEvent, host_event_wlan_pe_payload_type);
5006
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305007 qdf_mem_set(&peEvent, sizeof(host_event_wlan_pe_payload_type), 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005008
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005009 if (NULL == pe_session) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305010 qdf_mem_copy(peEvent.bssid, nullBssid, sizeof(tSirMacAddr));
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08005011 peEvent.sme_state = (uint16_t) mac->lim.gLimSmeState;
5012 peEvent.mlm_state = (uint16_t) mac->lim.gLimMlmState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005013
5014 } else {
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005015 qdf_mem_copy(peEvent.bssid, pe_session->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005016 sizeof(tSirMacAddr));
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005017 peEvent.sme_state = (uint16_t) pe_session->limSmeState;
5018 peEvent.mlm_state = (uint16_t) pe_session->limMlmState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005019 }
5020 peEvent.event_type = eventType;
5021 peEvent.status = status;
5022 peEvent.reason_code = reasonCode;
5023
5024 WLAN_HOST_DIAG_EVENT_REPORT(&peEvent, EVENT_WLAN_PE);
5025 return;
5026}
5027
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005028static void lim_diag_fill_mgmt_event_report(struct mac_context *mac_ctx,
Krunal Sonic65fc492018-03-09 15:53:28 -08005029 tpSirMacMgmtHdr mac_hdr,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08005030 struct pe_session *session, uint16_t result_code,
Krunal Sonic65fc492018-03-09 15:53:28 -08005031 uint16_t reason_code,
5032 struct host_event_wlan_mgmt_payload_type *mgmt_event)
5033{
5034 uint8_t length;
5035
5036 qdf_mem_set(mgmt_event, sizeof(*mgmt_event), 0);
5037 mgmt_event->mgmt_type = mac_hdr->fc.type;
5038 mgmt_event->mgmt_subtype = mac_hdr->fc.subType;
5039 qdf_mem_copy(mgmt_event->self_mac_addr, session->selfMacAddr,
5040 QDF_MAC_ADDR_SIZE);
5041 qdf_mem_copy(mgmt_event->bssid, session->bssId,
5042 QDF_MAC_ADDR_SIZE);
5043 length = session->ssId.length;
5044 if (length > SIR_MAC_MAX_SSID_LENGTH)
5045 length = SIR_MAC_MAX_SSID_LENGTH;
5046 qdf_mem_copy(mgmt_event->ssid, session->ssId.ssId, length);
5047 mgmt_event->ssid_len = length;
5048 mgmt_event->operating_channel = session->currentOperChannel;
5049 mgmt_event->result_code = result_code;
5050 mgmt_event->reason_code = reason_code;
5051}
5052
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005053void lim_diag_mgmt_tx_event_report(struct mac_context *mac_ctx, void *mgmt_hdr,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08005054 struct pe_session *session, uint16_t result_code,
Krunal Sonic65fc492018-03-09 15:53:28 -08005055 uint16_t reason_code)
5056{
5057 tpSirMacMgmtHdr mac_hdr = mgmt_hdr;
5058
5059 WLAN_HOST_DIAG_EVENT_DEF(mgmt_event,
5060 struct host_event_wlan_mgmt_payload_type);
5061 if (!session || !mac_hdr) {
5062 pe_err("not valid input");
5063 return;
5064 }
5065 lim_diag_fill_mgmt_event_report(mac_ctx, mac_hdr, session,
5066 result_code, reason_code, &mgmt_event);
5067
5068 pe_debug("TX frame: type:%d sub_type:%d seq_num:%d ssid:%.*s selfmacaddr:%pM bssid:%pM channel:%d",
5069 mgmt_event.mgmt_type, mgmt_event.mgmt_subtype,
5070 ((mac_hdr->seqControl.seqNumHi << 4) |
5071 mac_hdr->seqControl.seqNumLo),
5072 mgmt_event.ssid_len, mgmt_event.ssid,
5073 mgmt_event.self_mac_addr, mgmt_event.bssid,
5074 mgmt_event.operating_channel);
5075 WLAN_HOST_DIAG_EVENT_REPORT(&mgmt_event, EVENT_WLAN_HOST_MGMT_TX_V2);
5076}
5077
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005078void lim_diag_mgmt_rx_event_report(struct mac_context *mac_ctx, void *mgmt_hdr,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08005079 struct pe_session *session, uint16_t result_code,
Krunal Sonic65fc492018-03-09 15:53:28 -08005080 uint16_t reason_code)
5081{
5082 tpSirMacMgmtHdr mac_hdr = mgmt_hdr;
5083
5084 WLAN_HOST_DIAG_EVENT_DEF(mgmt_event,
5085 struct host_event_wlan_mgmt_payload_type);
5086 if (!session || !mac_hdr) {
Yeshwanth Sriram Guntukacbe61442018-08-23 18:08:44 +05305087 pe_debug("not valid input");
Krunal Sonic65fc492018-03-09 15:53:28 -08005088 return;
5089 }
5090 lim_diag_fill_mgmt_event_report(mac_ctx, mac_hdr, session,
5091 result_code, reason_code, &mgmt_event);
5092 pe_debug("RX frame: type:%d sub_type:%d seq_num:%d ssid:%.*s selfmacaddr:%pM bssid:%pM channel:%d",
5093 mgmt_event.mgmt_type, mgmt_event.mgmt_subtype,
5094 ((mac_hdr->seqControl.seqNumHi << 4) |
5095 mac_hdr->seqControl.seqNumLo),
5096 mgmt_event.ssid_len, mgmt_event.ssid,
5097 mgmt_event.self_mac_addr, mgmt_event.bssid,
5098 mgmt_event.operating_channel);
5099 WLAN_HOST_DIAG_EVENT_REPORT(&mgmt_event, EVENT_WLAN_HOST_MGMT_RX_V2);
5100}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005101#endif /* FEATURE_WLAN_DIAG_SUPPORT */
5102
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005103/* Returns length of P2P stream and Pointer ie passed to this function is filled with noa stream */
5104
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005105uint8_t lim_build_p2p_ie(struct mac_context *mac, uint8_t *ie, uint8_t *data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005106 uint8_t ie_len)
5107{
5108 int length = 0;
5109 uint8_t *ptr = ie;
5110
5111 ptr[length++] = SIR_MAC_EID_VENDOR;
5112 ptr[length++] = ie_len + SIR_MAC_P2P_OUI_SIZE;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305113 qdf_mem_copy(&ptr[length], SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE);
5114 qdf_mem_copy(&ptr[length + SIR_MAC_P2P_OUI_SIZE], data, ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005115 return ie_len + SIR_P2P_IE_HEADER_LEN;
5116}
5117
5118/* Returns length of NoA stream and Pointer pNoaStream passed to this function is filled with noa stream */
5119
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005120uint8_t lim_get_noa_attr_stream_in_mult_p2p_ies(struct mac_context *mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005121 uint8_t *noaStream, uint8_t noaLen,
5122 uint8_t overFlowLen)
5123{
5124 uint8_t overFlowP2pStream[SIR_MAX_NOA_ATTR_LEN];
5125
5126 if ((noaLen <= (SIR_MAX_NOA_ATTR_LEN + SIR_P2P_IE_HEADER_LEN)) &&
5127 (noaLen >= overFlowLen) && (overFlowLen <= SIR_MAX_NOA_ATTR_LEN)) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305128 qdf_mem_copy(overFlowP2pStream,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005129 noaStream + noaLen - overFlowLen, overFlowLen);
5130 noaStream[noaLen - overFlowLen] = SIR_MAC_EID_VENDOR;
5131 noaStream[noaLen - overFlowLen + 1] =
5132 overFlowLen + SIR_MAC_P2P_OUI_SIZE;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305133 qdf_mem_copy(noaStream + noaLen - overFlowLen + 2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005134 SIR_MAC_P2P_OUI, SIR_MAC_P2P_OUI_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305135 qdf_mem_copy(noaStream + noaLen + 2 + SIR_MAC_P2P_OUI_SIZE -
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005136 overFlowLen, overFlowP2pStream, overFlowLen);
5137 }
5138
5139 return noaLen + SIR_P2P_IE_HEADER_LEN;
5140
5141}
5142
5143/* Returns length of NoA stream and Pointer pNoaStream passed to this function is filled with noa stream */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005144uint8_t lim_get_noa_attr_stream(struct mac_context *mac, uint8_t *pNoaStream,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005145 struct pe_session *pe_session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005146{
5147 uint8_t len = 0;
5148
5149 uint8_t *pBody = pNoaStream;
5150
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005151 if ((pe_session != NULL) && (pe_session->valid) &&
5152 (pe_session->pePersona == QDF_P2P_GO_MODE)) {
5153 if ((!(pe_session->p2pGoPsUpdate.uNoa1Duration))
5154 && (!(pe_session->p2pGoPsUpdate.uNoa2Duration))
5155 && (!pe_session->p2pGoPsUpdate.oppPsFlag)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005156 )
5157 return 0; /* No NoA Descriptor then return 0 */
5158
5159 pBody[0] = SIR_P2P_NOA_ATTR;
5160
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005161 pBody[3] = pe_session->p2pGoPsUpdate.index;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005162 pBody[4] =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005163 pe_session->p2pGoPsUpdate.ctWin | (pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005164 p2pGoPsUpdate.
5165 oppPsFlag << 7);
5166 len = 5;
5167 pBody += len;
5168
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005169 if (pe_session->p2pGoPsUpdate.uNoa1Duration) {
5170 *pBody = pe_session->p2pGoPsUpdate.uNoa1IntervalCnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005171 pBody += 1;
5172 len += 1;
5173
5174 *((uint32_t *) (pBody)) =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005175 sir_swap_u32if_needed(pe_session->p2pGoPsUpdate.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005176 uNoa1Duration);
5177 pBody += sizeof(uint32_t);
5178 len += 4;
5179
5180 *((uint32_t *) (pBody)) =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005181 sir_swap_u32if_needed(pe_session->p2pGoPsUpdate.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005182 uNoa1Interval);
5183 pBody += sizeof(uint32_t);
5184 len += 4;
5185
5186 *((uint32_t *) (pBody)) =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005187 sir_swap_u32if_needed(pe_session->p2pGoPsUpdate.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005188 uNoa1StartTime);
5189 pBody += sizeof(uint32_t);
5190 len += 4;
5191
5192 }
5193
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005194 if (pe_session->p2pGoPsUpdate.uNoa2Duration) {
5195 *pBody = pe_session->p2pGoPsUpdate.uNoa2IntervalCnt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005196 pBody += 1;
5197 len += 1;
5198
5199 *((uint32_t *) (pBody)) =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005200 sir_swap_u32if_needed(pe_session->p2pGoPsUpdate.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005201 uNoa2Duration);
5202 pBody += sizeof(uint32_t);
5203 len += 4;
5204
5205 *((uint32_t *) (pBody)) =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005206 sir_swap_u32if_needed(pe_session->p2pGoPsUpdate.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005207 uNoa2Interval);
5208 pBody += sizeof(uint32_t);
5209 len += 4;
5210
5211 *((uint32_t *) (pBody)) =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005212 sir_swap_u32if_needed(pe_session->p2pGoPsUpdate.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005213 uNoa2StartTime);
5214 pBody += sizeof(uint32_t);
5215 len += 4;
5216
5217 }
5218
5219 pBody = pNoaStream + 1;
5220 *((uint16_t *) (pBody)) = sir_swap_u16if_needed(len - 3); /*one byte for Attr and 2 bytes for length */
5221
5222 return len;
5223
5224 }
5225 return 0;
5226
5227}
5228
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005229void pe_set_resume_channel(struct mac_context *mac, uint16_t channel,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005230 ePhyChanBondState phyCbState)
5231{
5232
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08005233 mac->lim.gResumeChannel = channel;
5234 mac->lim.gResumePhyCbState = phyCbState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005235}
5236
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005237bool lim_is_noa_insert_reqd(struct mac_context *mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005238{
5239 uint8_t i;
Srinivas Girigowda4d65ebe2017-10-13 21:41:42 -07005240
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08005241 for (i = 0; i < mac->lim.maxBssId; i++) {
5242 if (mac->lim.gpSession[i].valid == true) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005243 if ((eLIM_AP_ROLE ==
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08005244 mac->lim.gpSession[i].limSystemRole)
Anurag Chouhan6d760662016-02-20 16:05:43 +05305245 && (QDF_P2P_GO_MODE ==
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08005246 mac->lim.gpSession[i].pePersona)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005247 ) {
5248 return true;
5249 }
5250 }
5251 }
5252 return false;
5253}
5254
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005255bool lim_isconnected_on_dfs_channel(struct mac_context *mac_ctx,
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005256 uint8_t currentChannel)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005257{
5258 if (CHANNEL_STATE_DFS ==
Kiran Kumar Lokerea3de2262017-04-12 12:15:04 -07005259 wlan_reg_get_channel_state(mac_ctx->pdev, currentChannel)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005260 return true;
5261 } else {
5262 return false;
5263 }
5264}
5265
5266#ifdef WLAN_FEATURE_11W
5267void lim_pmf_sa_query_timer_handler(void *pMacGlobal, uint32_t param)
5268{
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005269 struct mac_context *mac = (struct mac_context *) pMacGlobal;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005270 tPmfSaQueryTimerId timerId;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005271 struct pe_session *pe_session;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005272 tpDphHashNode pSta;
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05305273 uint8_t maxretries;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005274
Nishank Aggarwal0402b432017-03-24 19:17:36 +05305275 pe_debug("SA Query timer fires");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005276 timerId.value = param;
5277
5278 /* Check that SA Query is in progress */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005279 pe_session = pe_find_session_by_session_id(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005280 timerId.fields.sessionId);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005281 if (pe_session == NULL) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05305282 pe_err("Session does not exist for given session ID: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005283 timerId.fields.sessionId);
5284 return;
5285 }
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08005286 pSta = dph_get_hash_entry(mac, timerId.fields.peerIdx,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005287 &pe_session->dph.dphHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005288 if (pSta == NULL) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05305289 pe_err("Entry does not exist for given peer index: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005290 timerId.fields.peerIdx);
5291 return;
5292 }
5293 if (DPH_SA_QUERY_IN_PROGRESS != pSta->pmfSaQueryState)
5294 return;
5295
5296 /* Increment the retry count, check if reached maximum */
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08005297 maxretries = mac->mlme_cfg->gen.pmf_sa_query_max_retries;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005298 pSta->pmfSaQueryRetryCount++;
Karthik Kantamneni24f71bc2018-09-11 19:08:38 +05305299 if (pSta->pmfSaQueryRetryCount >= maxretries) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05305300 pe_err("SA Query timed out,Deleting STA");
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08005301 lim_print_mac_addr(mac, pSta->staAddr, LOGE);
5302 lim_send_disassoc_mgmt_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005303 eSIR_MAC_DISASSOC_DUE_TO_INACTIVITY_REASON,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005304 pSta->staAddr, pe_session, false);
5305 lim_trigger_sta_deletion(mac, pSta, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005306 pSta->pmfSaQueryState = DPH_SA_QUERY_TIMED_OUT;
5307 return;
5308 }
5309 /* Retry SA Query */
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08005310 lim_send_sa_query_request_frame(mac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005311 (uint8_t *) &(pSta->
5312 pmfSaQueryCurrentTransId),
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005313 pSta->staAddr, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005314 pSta->pmfSaQueryCurrentTransId++;
Nishank Aggarwal0402b432017-03-24 19:17:36 +05305315 pe_debug("Starting SA Query retry: %d", pSta->pmfSaQueryRetryCount);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005316 if (tx_timer_activate(&pSta->pmfSaQueryTimer) != TX_SUCCESS) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05305317 pe_err("PMF SA Query timer activation failed!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005318 pSta->pmfSaQueryState = DPH_SA_QUERY_NOT_IN_PROGRESS;
5319 }
5320}
5321#endif
5322
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005323bool lim_check_vht_op_mode_change(struct mac_context *mac, struct pe_session *pe_session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005324 uint8_t chanWidth, uint8_t staId,
5325 uint8_t *peerMac)
5326{
5327 tUpdateVHTOpMode tempParam;
5328
5329 tempParam.opMode = chanWidth;
5330 tempParam.staId = staId;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005331 tempParam.smesessionId = pe_session->smeSessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305332 qdf_mem_copy(tempParam.peer_mac, peerMac, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005333
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005334 lim_send_mode_update(mac, &tempParam, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005335
5336 return true;
5337}
5338
Krunal Sonib7f20432017-04-27 13:01:02 -07005339#ifdef WLAN_FEATURE_11AX_BSS_COLOR
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005340bool lim_send_he_ie_update(struct mac_context *mac_ctx, struct pe_session *pe_session)
Krunal Sonib7f20432017-04-27 13:01:02 -07005341{
Krunal Sonib7f20432017-04-27 13:01:02 -07005342 QDF_STATUS status;
5343
Krunal Sonib7f20432017-04-27 13:01:02 -07005344 status = wma_update_he_ops_ie(cds_get_context(QDF_MODULE_ID_WMA),
Naveen Rawatdf221b72017-11-15 11:32:31 -08005345 pe_session->smeSessionId,
5346 &pe_session->he_op);
5347 if (QDF_IS_STATUS_ERROR(status))
Krunal Sonib7f20432017-04-27 13:01:02 -07005348 return false;
Krunal Sonib7f20432017-04-27 13:01:02 -07005349
5350 return true;
Krunal Sonib7f20432017-04-27 13:01:02 -07005351}
5352#endif
5353
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005354bool lim_set_nss_change(struct mac_context *mac, struct pe_session *pe_session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005355 uint8_t rxNss, uint8_t staId, uint8_t *peerMac)
5356{
5357 tUpdateRxNss tempParam;
5358
Himanshu Agarwala79c6762017-12-28 21:25:00 +05305359 if (!rxNss) {
5360 pe_err("Invalid rxNss value: %u", rxNss);
Dustin Brown83044c22018-08-13 15:00:44 -07005361 cds_trigger_recovery(QDF_REASON_UNSPECIFIED);
Himanshu Agarwala79c6762017-12-28 21:25:00 +05305362 }
5363
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005364 tempParam.rxNss = rxNss;
5365 tempParam.staId = staId;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005366 tempParam.smesessionId = pe_session->smeSessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305367 qdf_mem_copy(tempParam.peer_mac, peerMac, sizeof(tSirMacAddr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005368
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005369 lim_send_rx_nss_update(mac, &tempParam, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005370
5371 return true;
5372}
5373
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005374bool lim_check_membership_user_position(struct mac_context *mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005375 struct pe_session *pe_session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005376 uint32_t membership, uint32_t userPosition,
5377 uint8_t staId)
5378{
5379 tUpdateMembership tempParamMembership;
5380 tUpdateUserPos tempParamUserPosition;
5381
5382 tempParamMembership.membership = membership;
5383 tempParamMembership.staId = staId;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005384 tempParamMembership.smesessionId = pe_session->smeSessionId;
5385 qdf_mem_copy(tempParamMembership.peer_mac, pe_session->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005386 sizeof(tSirMacAddr));
5387
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005388 lim_set_membership(mac, &tempParamMembership, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005389
5390 tempParamUserPosition.userPos = userPosition;
5391 tempParamUserPosition.staId = staId;
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005392 tempParamUserPosition.smesessionId = pe_session->smeSessionId;
5393 qdf_mem_copy(tempParamUserPosition.peer_mac, pe_session->bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005394 sizeof(tSirMacAddr));
5395
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005396 lim_set_user_pos(mac, &tempParamUserPosition, pe_session);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005397
5398 return true;
5399}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005400
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005401void lim_get_short_slot_from_phy_mode(struct mac_context *mac, struct pe_session *pe_session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005402 uint32_t phyMode, uint8_t *pShortSlotEnabled)
5403{
5404 uint8_t val = 0;
5405
5406 /* only 2.4G band should have short slot enable, rest it should be default */
5407 if (phyMode == WNI_CFG_PHY_MODE_11G) {
5408 /* short slot is default in all other modes */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005409 if ((pe_session->pePersona == QDF_SAP_MODE) ||
5410 (pe_session->pePersona == QDF_IBSS_MODE) ||
5411 (pe_session->pePersona == QDF_P2P_GO_MODE)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005412 val = true;
5413 }
5414 /* Program Polaris based on AP capability */
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005415 if (pe_session->limMlmState == eLIM_MLM_WT_JOIN_BEACON_STATE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005416 /* Joining BSS. */
5417 val =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005418 SIR_MAC_GET_SHORT_SLOT_TIME(pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005419 limCurrentBssCaps);
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005420 } else if (pe_session->limMlmState ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005421 eLIM_MLM_WT_REASSOC_RSP_STATE) {
5422 /* Reassociating with AP. */
5423 val =
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005424 SIR_MAC_GET_SHORT_SLOT_TIME(pe_session->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005425 limReassocBssCaps);
5426 }
5427 } else {
5428 /*
5429 * 11B does not short slot and short slot is default
5430 * for 11A mode. Hence, not need to set this bit
5431 */
5432 val = false;
5433 }
5434
Nishank Aggarwal0402b432017-03-24 19:17:36 +05305435 pe_debug("phyMode: %u shortslotsupported: %u", phyMode, val);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005436 *pShortSlotEnabled = val;
5437}
5438
5439#ifdef WLAN_FEATURE_11W
5440/**
5441 *
5442 * \brief This function is called by various LIM modules to correctly set
5443 * the Protected bit in the Frame Control Field of the 802.11 frame MAC header
5444 *
5445 *
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08005446 * \param mac Pointer to Global MAC structure
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005447 *
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005448 * \param pe_session Pointer to session corresponding to the connection
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005449 *
5450 * \param peer Peer address of the STA to which the frame is to be sent
5451 *
5452 * \param pMacHdr Pointer to the frame MAC header
5453 *
5454 * \return nothing
5455 *
5456 *
5457 */
5458void
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005459lim_set_protected_bit(struct mac_context *mac,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005460 struct pe_session *pe_session,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005461 tSirMacAddr peer, tpSirMacMgmtHdr pMacHdr)
5462{
5463 uint16_t aid;
5464 tpDphHashNode pStaDs;
5465
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005466 if (LIM_IS_AP_ROLE(pe_session)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005467
Jeff Johnson0a0f42a2018-11-21 20:42:36 -08005468 pStaDs = dph_lookup_hash_entry(mac, peer, &aid,
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005469 &pe_session->dph.dphHashTable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005470 if (pStaDs != NULL) {
5471 /* rmfenabled will be set at the time of addbss.
5472 * but sometimes EAP auth fails and keys are not
5473 * installed then if we send any management frame
5474 * like deauth/disassoc with this bit set then
5475 * firmware crashes. so check for keys are
5476 * installed or not also before setting the bit
5477 */
5478 if (pStaDs->rmfEnabled && pStaDs->is_key_installed)
5479 pMacHdr->fc.wep = 1;
5480 }
Jeff Johnsonb5c13332018-12-03 09:54:51 -08005481 } else if (pe_session->limRmfEnabled &&
5482 pe_session->is_key_installed) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005483 pMacHdr->fc.wep = 1;
5484 }
5485} /*** end lim_set_protected_bit() ***/
5486#endif
5487
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005488void lim_set_ht_caps(struct mac_context *p_mac, struct pe_session *p_session_entry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005489 uint8_t *p_ie_start, uint32_t num_bytes)
5490{
Naveen Rawat08db88f2017-09-08 15:07:48 -07005491 const uint8_t *p_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005492 tDot11fIEHTCaps dot11_ht_cap = {0,};
5493
5494 populate_dot11f_ht_caps(p_mac, p_session_entry, &dot11_ht_cap);
Naveen Rawat08db88f2017-09-08 15:07:48 -07005495 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_HTCAPS,
5496 p_ie_start, num_bytes);
Jeff Johnson11bd4f32017-09-18 08:15:17 -07005497 pe_debug("p_ie: %pK dot11_ht_cap.supportedMCSSet[0]: 0x%x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005498 p_ie, dot11_ht_cap.supportedMCSSet[0]);
5499 if (p_ie) {
5500 /* convert from unpacked to packed structure */
5501 tHtCaps *p_ht_cap = (tHtCaps *) &p_ie[2];
5502
5503 p_ht_cap->advCodingCap = dot11_ht_cap.advCodingCap;
5504 p_ht_cap->supportedChannelWidthSet =
5505 dot11_ht_cap.supportedChannelWidthSet;
5506 p_ht_cap->mimoPowerSave = dot11_ht_cap.mimoPowerSave;
5507 p_ht_cap->greenField = dot11_ht_cap.greenField;
5508 p_ht_cap->shortGI20MHz = dot11_ht_cap.shortGI20MHz;
5509 p_ht_cap->shortGI40MHz = dot11_ht_cap.shortGI40MHz;
5510 p_ht_cap->txSTBC = dot11_ht_cap.txSTBC;
5511 p_ht_cap->rxSTBC = dot11_ht_cap.rxSTBC;
5512 p_ht_cap->delayedBA = dot11_ht_cap.delayedBA;
5513 p_ht_cap->maximalAMSDUsize = dot11_ht_cap.maximalAMSDUsize;
5514 p_ht_cap->dsssCckMode40MHz = dot11_ht_cap.dsssCckMode40MHz;
5515 p_ht_cap->psmp = dot11_ht_cap.psmp;
5516 p_ht_cap->stbcControlFrame = dot11_ht_cap.stbcControlFrame;
5517 p_ht_cap->lsigTXOPProtection = dot11_ht_cap.lsigTXOPProtection;
5518 p_ht_cap->maxRxAMPDUFactor = dot11_ht_cap.maxRxAMPDUFactor;
5519 p_ht_cap->mpduDensity = dot11_ht_cap.mpduDensity;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305520 qdf_mem_copy((void *)p_ht_cap->supportedMCSSet,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005521 (void *)(dot11_ht_cap.supportedMCSSet),
5522 sizeof(p_ht_cap->supportedMCSSet));
5523 p_ht_cap->pco = dot11_ht_cap.pco;
5524 p_ht_cap->transitionTime = dot11_ht_cap.transitionTime;
5525 p_ht_cap->mcsFeedback = dot11_ht_cap.mcsFeedback;
5526 p_ht_cap->txBF = dot11_ht_cap.txBF;
5527 p_ht_cap->rxStaggeredSounding =
5528 dot11_ht_cap.rxStaggeredSounding;
5529 p_ht_cap->txStaggeredSounding =
5530 dot11_ht_cap.txStaggeredSounding;
5531 p_ht_cap->rxZLF = dot11_ht_cap.rxZLF;
5532 p_ht_cap->txZLF = dot11_ht_cap.txZLF;
5533 p_ht_cap->implicitTxBF = dot11_ht_cap.implicitTxBF;
5534 p_ht_cap->calibration = dot11_ht_cap.calibration;
5535 p_ht_cap->explicitCSITxBF = dot11_ht_cap.explicitCSITxBF;
5536 p_ht_cap->explicitUncompressedSteeringMatrix =
5537 dot11_ht_cap.explicitUncompressedSteeringMatrix;
5538 p_ht_cap->explicitBFCSIFeedback =
5539 dot11_ht_cap.explicitBFCSIFeedback;
5540 p_ht_cap->explicitUncompressedSteeringMatrixFeedback =
5541 dot11_ht_cap.explicitUncompressedSteeringMatrixFeedback;
5542 p_ht_cap->explicitCompressedSteeringMatrixFeedback =
5543 dot11_ht_cap.explicitCompressedSteeringMatrixFeedback;
5544 p_ht_cap->csiNumBFAntennae = dot11_ht_cap.csiNumBFAntennae;
5545 p_ht_cap->uncompressedSteeringMatrixBFAntennae =
5546 dot11_ht_cap.uncompressedSteeringMatrixBFAntennae;
5547 p_ht_cap->compressedSteeringMatrixBFAntennae =
5548 dot11_ht_cap.compressedSteeringMatrixBFAntennae;
5549 p_ht_cap->antennaSelection = dot11_ht_cap.antennaSelection;
5550 p_ht_cap->explicitCSIFeedbackTx =
5551 dot11_ht_cap.explicitCSIFeedbackTx;
5552 p_ht_cap->antennaIndicesFeedbackTx =
5553 dot11_ht_cap.antennaIndicesFeedbackTx;
5554 p_ht_cap->explicitCSIFeedback =
5555 dot11_ht_cap.explicitCSIFeedback;
5556 p_ht_cap->antennaIndicesFeedback =
5557 dot11_ht_cap.antennaIndicesFeedback;
5558 p_ht_cap->rxAS = dot11_ht_cap.rxAS;
5559 p_ht_cap->txSoundingPPDUs = dot11_ht_cap.txSoundingPPDUs;
5560 }
5561}
5562
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005563void lim_set_vht_caps(struct mac_context *p_mac, struct pe_session *p_session_entry,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005564 uint8_t *p_ie_start, uint32_t num_bytes)
5565{
Naveen Rawat08db88f2017-09-08 15:07:48 -07005566 const uint8_t *p_ie = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005567 tDot11fIEVHTCaps dot11_vht_cap;
5568
5569 populate_dot11f_vht_caps(p_mac, p_session_entry, &dot11_vht_cap);
Naveen Rawat08db88f2017-09-08 15:07:48 -07005570 p_ie = wlan_get_ie_ptr_from_eid(DOT11F_EID_VHTCAPS, p_ie_start,
5571 num_bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005572 if (p_ie) {
5573 tSirMacVHTCapabilityInfo *vht_cap =
5574 (tSirMacVHTCapabilityInfo *) &p_ie[2];
5575 tSirVhtMcsInfo *vht_mcs = (tSirVhtMcsInfo *) &p_ie[2 +
5576 sizeof(tSirMacVHTCapabilityInfo)];
5577
5578 union {
5579 uint16_t u_value;
5580 tSirMacVHTRxSupDataRateInfo vht_rx_supp_rate;
5581 tSirMacVHTTxSupDataRateInfo vht_tx_supp_rate;
5582 } u_vht_data_rate_info;
5583
5584 vht_cap->maxMPDULen = dot11_vht_cap.maxMPDULen;
5585 vht_cap->supportedChannelWidthSet =
5586 dot11_vht_cap.supportedChannelWidthSet;
5587 vht_cap->ldpcCodingCap = dot11_vht_cap.ldpcCodingCap;
5588 vht_cap->shortGI80MHz = dot11_vht_cap.shortGI80MHz;
5589 vht_cap->shortGI160and80plus80MHz =
5590 dot11_vht_cap.shortGI160and80plus80MHz;
5591 vht_cap->txSTBC = dot11_vht_cap.txSTBC;
5592 vht_cap->rxSTBC = dot11_vht_cap.rxSTBC;
5593 vht_cap->suBeamFormerCap = dot11_vht_cap.suBeamFormerCap;
5594 vht_cap->suBeamformeeCap = dot11_vht_cap.suBeamformeeCap;
5595 vht_cap->csnofBeamformerAntSup =
5596 dot11_vht_cap.csnofBeamformerAntSup;
5597 vht_cap->numSoundingDim = dot11_vht_cap.numSoundingDim;
5598 vht_cap->muBeamformerCap = dot11_vht_cap.muBeamformerCap;
5599 vht_cap->muBeamformeeCap = dot11_vht_cap.muBeamformeeCap;
5600 vht_cap->vhtTXOPPS = dot11_vht_cap.vhtTXOPPS;
5601 vht_cap->htcVHTCap = dot11_vht_cap.htcVHTCap;
5602 vht_cap->maxAMPDULenExp = dot11_vht_cap.maxAMPDULenExp;
5603 vht_cap->vhtLinkAdaptCap = dot11_vht_cap.vhtLinkAdaptCap;
5604 vht_cap->rxAntPattern = dot11_vht_cap.rxAntPattern;
5605 vht_cap->txAntPattern = dot11_vht_cap.txAntPattern;
5606 vht_cap->reserved1 = dot11_vht_cap.reserved1;
5607
5608 /* Populate VHT MCS Information */
5609 vht_mcs->rxMcsMap = dot11_vht_cap.rxMCSMap;
5610 u_vht_data_rate_info.vht_rx_supp_rate.rxSupDataRate =
5611 dot11_vht_cap.rxHighSupDataRate;
5612 u_vht_data_rate_info.vht_rx_supp_rate.reserved =
5613 dot11_vht_cap.reserved2;
5614 vht_mcs->rxHighest = u_vht_data_rate_info.u_value;
5615
5616 vht_mcs->txMcsMap = dot11_vht_cap.txMCSMap;
5617 u_vht_data_rate_info.vht_tx_supp_rate.txSupDataRate =
5618 dot11_vht_cap.txSupDataRate;
5619 u_vht_data_rate_info.vht_tx_supp_rate.reserved =
5620 dot11_vht_cap.reserved3;
5621 vht_mcs->txHighest = u_vht_data_rate_info.u_value;
5622 }
5623}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005624
5625/**
5626 * lim_validate_received_frame_a1_addr() - To validate received frame's A1 addr
5627 * @mac_ctx: pointer to mac context
5628 * @a1: received frame's a1 address which is nothing but our self address
5629 * @session: PE session pointer
5630 *
Jeff Johnsonbe7f4fd2018-05-11 21:05:54 -07005631 * This routine will validate, A1 address of the received frame
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005632 *
5633 * Return: true or false
5634 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005635bool lim_validate_received_frame_a1_addr(struct mac_context *mac_ctx,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08005636 tSirMacAddr a1, struct pe_session *session)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005637{
5638 if (mac_ctx == NULL || session == NULL) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05305639 pe_err("mac or session context is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005640 /* let main routine handle it */
5641 return true;
5642 }
5643 if (lim_is_group_addr(a1) || lim_is_addr_bc(a1)) {
5644 /* just for fail safe, don't handle MC/BC a1 in this routine */
5645 return true;
5646 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305647 if (qdf_mem_cmp(a1, session->selfMacAddr, 6)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05305648 pe_err("Invalid A1 address in received frame");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005649 return false;
5650 }
5651 return true;
5652}
5653
5654/**
5655 * lim_check_and_reset_protection_params() - reset protection related parameters
5656 *
5657 * @mac_ctx: pointer to global mac structure
5658 *
5659 * resets protection related global parameters if the pe active session count
5660 * is zero.
5661 *
5662 * Return: None
5663 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005664void lim_check_and_reset_protection_params(struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005665{
5666 if (!pe_get_active_session_count(mac_ctx)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005667 mac_ctx->lim.gHTOperMode = eSIR_HT_OP_MODE_PURE;
5668 }
5669}
5670
5671/**
5672 * lim_set_stads_rtt_cap() - update station node RTT capability
5673 * @sta_ds: Station hash node
5674 * @ext_cap: Pointer to extended capability
5675 * @mac_ctx: global MAC context
5676 *
5677 * This funciton update hash node's RTT capability based on received
5678 * Extended capability IE.
5679 *
5680 * Return: None
5681 */
5682void lim_set_stads_rtt_cap(tpDphHashNode sta_ds, struct s_ext_cap *ext_cap,
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005683 struct mac_context *mac_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005684{
5685 sta_ds->timingMeasCap = 0;
5686 sta_ds->timingMeasCap |= (ext_cap->timing_meas) ?
5687 RTT_TIMING_MEAS_CAPABILITY :
5688 RTT_INVALID;
5689 sta_ds->timingMeasCap |= (ext_cap->fine_time_meas_initiator) ?
5690 RTT_FINE_TIME_MEAS_INITIATOR_CAPABILITY :
5691 RTT_INVALID;
5692 sta_ds->timingMeasCap |= (ext_cap->fine_time_meas_responder) ?
5693 RTT_FINE_TIME_MEAS_RESPONDER_CAPABILITY :
5694 RTT_INVALID;
5695
Nishank Aggarwal0402b432017-03-24 19:17:36 +05305696 pe_debug("ExtCap present, timingMeas: %d Initiator: %d Responder: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005697 ext_cap->timing_meas, ext_cap->fine_time_meas_initiator,
5698 ext_cap->fine_time_meas_responder);
5699}
5700
Varun Reddy Yeturu4f849e52018-06-15 18:08:37 -07005701#ifdef WLAN_SUPPORT_TWT
Jeff Johnsonc8baa902018-11-18 21:59:07 -08005702void lim_set_peer_twt_cap(struct pe_session *session, struct s_ext_cap *ext_cap)
Varun Reddy Yeturu4f849e52018-06-15 18:08:37 -07005703{
Arif Hussain6686c0b2018-08-21 18:21:05 -07005704 if (session->enable_session_twt_support) {
5705 session->peer_twt_requestor = ext_cap->twt_requestor_support;
5706 session->peer_twt_responder = ext_cap->twt_responder_support;
5707 }
Varun Reddy Yeturu4f849e52018-06-15 18:08:37 -07005708
Arif Hussain6686c0b2018-08-21 18:21:05 -07005709 pe_debug("Ext Cap peer TWT requestor: %d, responder: %d, enable_twt %d",
Varun Reddy Yeturu4f849e52018-06-15 18:08:37 -07005710 ext_cap->twt_requestor_support,
Arif Hussain6686c0b2018-08-21 18:21:05 -07005711 ext_cap->twt_responder_support,
5712 session->enable_session_twt_support);
Varun Reddy Yeturu4f849e52018-06-15 18:08:37 -07005713}
5714#endif
5715
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005716/**
Naveen Rawat03e8d952016-08-01 15:22:20 -07005717 * lim_send_ie() - sends IE to wma
5718 * @mac_ctx: global MAC context
5719 * @sme_session_id: sme session id
5720 * @eid: IE id
5721 * @band: band for which IE is intended
5722 * @buf: buffer containing IE
5723 * @len: length of buffer
5724 *
5725 * This funciton sends the IE data to WMA.
5726 *
5727 * Return: status of operation
5728 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005729static QDF_STATUS lim_send_ie(struct mac_context *mac_ctx, uint32_t sme_session_id,
Jeff Johnson22496442016-10-07 07:34:46 -07005730 uint8_t eid, enum cds_band_type band,
5731 uint8_t *buf, uint32_t len)
Naveen Rawat03e8d952016-08-01 15:22:20 -07005732{
5733 struct vdev_ie_info *ie_msg;
Rajeev Kumarf7d84422017-01-21 15:45:44 -08005734 struct scheduler_msg msg = {0};
Naveen Rawat03e8d952016-08-01 15:22:20 -07005735 QDF_STATUS status;
5736
5737 /* Allocate memory for the WMI request */
5738 ie_msg = qdf_mem_malloc(sizeof(*ie_msg) + len);
Arif Hussainf5b6c412018-10-10 19:41:09 -07005739 if (!ie_msg)
Naveen Rawat03e8d952016-08-01 15:22:20 -07005740 return QDF_STATUS_E_NOMEM;
Naveen Rawat03e8d952016-08-01 15:22:20 -07005741
5742 ie_msg->vdev_id = sme_session_id;
5743 ie_msg->ie_id = eid;
5744 ie_msg->length = len;
5745 ie_msg->band = band;
5746 /* IE data buffer starts at end of the struct */
5747 ie_msg->data = (uint8_t *)&ie_msg[1];
5748
5749 qdf_mem_copy(ie_msg->data, buf, len);
5750 msg.type = WMA_SET_IE_INFO;
5751 msg.bodyptr = ie_msg;
5752 msg.reserved = 0;
5753
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05305754 status = scheduler_post_message(QDF_MODULE_ID_PE,
5755 QDF_MODULE_ID_WMA,
5756 QDF_MODULE_ID_WMA, &msg);
Naveen Rawat03e8d952016-08-01 15:22:20 -07005757 if (QDF_STATUS_SUCCESS != status) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05305758 pe_err("Not able to post WMA_SET_IE_INFO to WMA");
Naveen Rawat03e8d952016-08-01 15:22:20 -07005759 qdf_mem_free(ie_msg);
5760 return status;
5761 }
5762
5763 return status;
5764}
5765
5766/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07005767 * lim_get_rx_ldpc() - gets ldpc setting for given channel(band)
5768 * @mac_ctx: global mac context
Krunal Soni3512f6b2017-06-30 12:43:40 -07005769 * @ch: channel enum for which ldpc setting is required
5770 * Note: ch param is not absolute channel number rather it is
5771 * channel number enum.
Naveen Rawat03e8d952016-08-01 15:22:20 -07005772 *
Naveen Rawata410c5a2016-09-19 14:22:33 -07005773 * Return: true if enabled and false otherwise
Naveen Rawat03e8d952016-08-01 15:22:20 -07005774 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005775static inline bool lim_get_rx_ldpc(struct mac_context *mac_ctx, enum channel_enum ch)
Naveen Rawat03e8d952016-08-01 15:22:20 -07005776{
Vignesh Viswanathanecd4de72018-11-22 13:02:20 +05305777 if (mac_ctx->mlme_cfg->ht_caps.ht_cap_info.adv_coding_cap &&
5778 wma_is_rx_ldpc_supported_for_channel(WLAN_REG_CH_NUM(ch)))
Naveen Rawata410c5a2016-09-19 14:22:33 -07005779 return true;
5780 else
5781 return false;
Naveen Rawat03e8d952016-08-01 15:22:20 -07005782}
5783
5784/**
gaurank kathpaliaad980492018-10-31 19:22:30 +05305785 * lim_populate_mcs_set_ht_per_vdev() - update the MCS set according to vdev nss
5786 * @mac_ctx: global mac context
5787 * @ht_cap: pointer to ht caps
5788 * @vdev_id: vdev for which IE is targeted
5789 * @band: band for which the MCS set has to be updated
5790 *
gaurank kathpaliab414bce2018-11-09 18:44:46 +05305791 * This function updates the MCS set according to vdev nss
gaurank kathpaliaad980492018-10-31 19:22:30 +05305792 *
5793 * Return: None
5794 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005795static void lim_populate_mcs_set_ht_per_vdev(struct mac_context *mac_ctx,
gaurank kathpaliaad980492018-10-31 19:22:30 +05305796 struct sHtCaps *ht_cap,
5797 uint8_t vdev_id,
5798 uint8_t band)
5799{
5800 struct wlan_mlme_nss_chains *nss_chains_ini_cfg;
5801 struct wlan_objmgr_vdev *vdev =
5802 wlan_objmgr_get_vdev_by_id_from_psoc(mac_ctx->psoc,
5803 vdev_id,
5804 WLAN_MLME_SB_ID);
5805 if (!vdev) {
5806 pe_err("Got NULL vdev obj, returning");
5807 return;
5808 }
5809 if (!ht_cap->supportedMCSSet[1])
5810 goto end;
5811 nss_chains_ini_cfg = mlme_get_ini_vdev_config(vdev);
5812 if (!nss_chains_ini_cfg) {
5813 pe_err("nss chain dynamic config NULL");
5814 goto end;
5815 }
5816
5817 /* convert from unpacked to packed structure */
5818 if (nss_chains_ini_cfg->rx_nss[band] == 1)
5819 ht_cap->supportedMCSSet[1] = 0;
5820
5821end:
5822 wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_SB_ID);
5823}
5824
5825/**
5826 * lim_populate_mcs_set_vht_per_vdev() - update MCS set according to vdev nss
5827 * @mac_ctx: global mac context
5828 * @vht_caps: pointer to vht_caps
5829 * @vdev_id: vdev for which IE is targeted
5830 * @band: band for which the MCS set has to be updated
5831 *
gaurank kathpaliab414bce2018-11-09 18:44:46 +05305832 * This function updates the MCS set according to vdev nss
gaurank kathpaliaad980492018-10-31 19:22:30 +05305833 *
5834 * Return: None
5835 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005836static void lim_populate_mcs_set_vht_per_vdev(struct mac_context *mac_ctx,
gaurank kathpaliaad980492018-10-31 19:22:30 +05305837 uint8_t *vht_caps,
5838 uint8_t vdev_id,
5839 uint8_t band)
5840{
5841 struct wlan_mlme_nss_chains *nss_chains_ini_cfg;
5842 tSirVhtMcsInfo *vht_mcs;
5843 struct wlan_objmgr_vdev *vdev =
5844 wlan_objmgr_get_vdev_by_id_from_psoc(mac_ctx->psoc,
5845 vdev_id,
5846 WLAN_MLME_SB_ID);
5847 if (!vdev) {
5848 pe_err("Got NULL vdev obj, returning");
5849 return;
5850 }
5851
5852 nss_chains_ini_cfg = mlme_get_ini_vdev_config(vdev);
5853 if (!nss_chains_ini_cfg) {
5854 pe_err("nss chain dynamic config NULL");
5855 goto end;
5856 }
5857
5858 vht_mcs = (tSirVhtMcsInfo *)&vht_caps[2 +
5859 sizeof(tSirMacVHTCapabilityInfo)];
5860 if (nss_chains_ini_cfg->tx_nss[band] == 1) {
5861 /* Populate VHT MCS Information */
5862 vht_mcs->txMcsMap |= DISABLE_NSS2_MCS;
5863 vht_mcs->txHighest =
5864 VHT_TX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
5865 }
5866
5867 if (nss_chains_ini_cfg->rx_nss[band] == 1) {
5868 /* Populate VHT MCS Information */
5869 vht_mcs->rxMcsMap |= DISABLE_NSS2_MCS;
5870 vht_mcs->rxHighest =
5871 VHT_RX_HIGHEST_SUPPORTED_DATA_RATE_1_1;
5872 }
5873
5874end:
5875 wlan_objmgr_vdev_release_ref(vdev, WLAN_MLME_SB_ID);
5876}
5877
5878/**
Naveen Rawata410c5a2016-09-19 14:22:33 -07005879 * lim_send_ies_per_band() - gets ht and vht capability and send to firmware via
Naveen Rawat03e8d952016-08-01 15:22:20 -07005880 * wma
Naveen Rawata410c5a2016-09-19 14:22:33 -07005881 * @mac_ctx: global mac context
5882 * @session: pe session. This can be NULL. In that case self cap will be sent
5883 * @vdev_id: vdev for which IE is targeted
Naveen Rawat03e8d952016-08-01 15:22:20 -07005884 *
5885 * This funciton gets ht and vht capability and send to firmware via wma
5886 *
5887 * Return: status of operation
5888 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005889QDF_STATUS lim_send_ies_per_band(struct mac_context *mac_ctx,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08005890 struct pe_session *session,
Naveen Rawata410c5a2016-09-19 14:22:33 -07005891 uint8_t vdev_id)
Naveen Rawat03e8d952016-08-01 15:22:20 -07005892{
Naveen Rawata410c5a2016-09-19 14:22:33 -07005893 uint8_t ht_caps[DOT11F_IE_HTCAPS_MIN_LEN + 2] = {0};
5894 uint8_t vht_caps[DOT11F_IE_VHTCAPS_MAX_LEN + 2] = {0};
Naveen Rawat1620ecb2016-10-10 15:25:50 -07005895 tHtCaps *p_ht_cap = (tHtCaps *)(&ht_caps[2]);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005896 tSirMacVHTCapabilityInfo *p_vht_cap =
Naveen Rawat1620ecb2016-10-10 15:25:50 -07005897 (tSirMacVHTCapabilityInfo *)(&vht_caps[2]);
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08005898 QDF_STATUS status;
Naveen Rawat03e8d952016-08-01 15:22:20 -07005899
Naveen Rawata410c5a2016-09-19 14:22:33 -07005900 /*
5901 * Note: Do not use Dot11f VHT structure, since 1 byte present flag in
5902 * it is causing weird padding errors. Instead use Sir Mac VHT struct
5903 * to send IE to wma.
5904 */
5905 ht_caps[0] = DOT11F_EID_HTCAPS;
5906 ht_caps[1] = DOT11F_IE_HTCAPS_MIN_LEN;
5907 lim_set_ht_caps(mac_ctx, session, ht_caps,
5908 DOT11F_IE_HTCAPS_MIN_LEN + 2);
5909 /* Get LDPC and over write for 2G */
5910 p_ht_cap->advCodingCap = lim_get_rx_ldpc(mac_ctx, CHAN_ENUM_6);
Naveen Rawat1620ecb2016-10-10 15:25:50 -07005911 /* Get self cap for HT40 support in 2G */
5912 if (mac_ctx->roam.configParam.channelBondingMode24GHz) {
5913 p_ht_cap->supportedChannelWidthSet = 1;
5914 p_ht_cap->shortGI40MHz = 1;
5915 } else {
5916 p_ht_cap->supportedChannelWidthSet = 0;
5917 p_ht_cap->shortGI40MHz = 0;
5918 }
gaurank kathpaliab414bce2018-11-09 18:44:46 +05305919 lim_populate_mcs_set_ht_per_vdev(mac_ctx, p_ht_cap, vdev_id,
5920 NSS_CHAINS_BAND_2GHZ);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005921 lim_send_ie(mac_ctx, vdev_id, DOT11F_EID_HTCAPS,
5922 CDS_BAND_2GHZ, &ht_caps[2], DOT11F_IE_HTCAPS_MIN_LEN);
5923 /*
5924 * Get LDPC and over write for 5G - using channel 64 because it
5925 * is available in all reg domains.
5926 */
5927 p_ht_cap->advCodingCap = lim_get_rx_ldpc(mac_ctx, CHAN_ENUM_64);
Naveen Rawat1620ecb2016-10-10 15:25:50 -07005928 /* Get self cap for HT40 support in 5G */
5929 if (mac_ctx->roam.configParam.channelBondingMode5GHz) {
5930 p_ht_cap->supportedChannelWidthSet = 1;
5931 p_ht_cap->shortGI40MHz = 1;
5932 } else {
5933 p_ht_cap->supportedChannelWidthSet = 0;
5934 p_ht_cap->shortGI40MHz = 0;
5935 }
gaurank kathpaliab414bce2018-11-09 18:44:46 +05305936 lim_populate_mcs_set_ht_per_vdev(mac_ctx, p_ht_cap, vdev_id,
5937 NSS_CHAINS_BAND_5GHZ);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005938 lim_send_ie(mac_ctx, vdev_id, DOT11F_EID_HTCAPS,
5939 CDS_BAND_5GHZ, &ht_caps[2], DOT11F_IE_HTCAPS_MIN_LEN);
Naveen Rawat03e8d952016-08-01 15:22:20 -07005940
Naveen Rawata410c5a2016-09-19 14:22:33 -07005941 vht_caps[0] = DOT11F_EID_VHTCAPS;
5942 vht_caps[1] = DOT11F_IE_VHTCAPS_MAX_LEN;
Naveen Rawata410c5a2016-09-19 14:22:33 -07005943 lim_set_vht_caps(mac_ctx, session, vht_caps,
5944 DOT11F_IE_VHTCAPS_MIN_LEN + 2);
Naveen Rawata410c5a2016-09-19 14:22:33 -07005945 /*
5946 * Get LDPC and over write for 5G - using channel 64 because it
5947 * is available in all reg domains.
5948 */
5949 p_vht_cap->ldpcCodingCap = lim_get_rx_ldpc(mac_ctx, CHAN_ENUM_64);
gaurank kathpaliaad980492018-10-31 19:22:30 +05305950 lim_populate_mcs_set_vht_per_vdev(mac_ctx, vht_caps,
gaurank kathpaliab414bce2018-11-09 18:44:46 +05305951 vdev_id, NSS_CHAINS_BAND_5GHZ);
gaurank kathpaliaad980492018-10-31 19:22:30 +05305952
Naveen Rawat1620ecb2016-10-10 15:25:50 -07005953 /* Self VHT channel width for 5G is already negotiated with FW */
Naveen Rawata410c5a2016-09-19 14:22:33 -07005954 lim_send_ie(mac_ctx, vdev_id, DOT11F_EID_VHTCAPS,
5955 CDS_BAND_5GHZ, &vht_caps[2], DOT11F_IE_VHTCAPS_MIN_LEN);
Naveen Rawat03e8d952016-08-01 15:22:20 -07005956
Naveen Rawat2347f9d2016-11-21 12:55:12 -08005957 /* Get LDPC and over write for 2G */
5958 p_vht_cap->ldpcCodingCap = lim_get_rx_ldpc(mac_ctx, CHAN_ENUM_6);
5959 /* Self VHT 80/160/80+80 channel width for 2G is 0 */
5960 p_vht_cap->supportedChannelWidthSet = 0;
5961 p_vht_cap->shortGI80MHz = 0;
5962 p_vht_cap->shortGI160and80plus80MHz = 0;
gaurank kathpaliaad980492018-10-31 19:22:30 +05305963 lim_populate_mcs_set_vht_per_vdev(mac_ctx, vht_caps,
gaurank kathpaliab414bce2018-11-09 18:44:46 +05305964 vdev_id, NSS_CHAINS_BAND_2GHZ);
Naveen Rawat2347f9d2016-11-21 12:55:12 -08005965 lim_send_ie(mac_ctx, vdev_id, DOT11F_EID_VHTCAPS,
5966 CDS_BAND_2GHZ, &vht_caps[2], DOT11F_IE_VHTCAPS_MIN_LEN);
5967
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08005968 status = lim_send_he_caps_ie(mac_ctx, session, vdev_id);
5969
5970 return status;
Naveen Rawat03e8d952016-08-01 15:22:20 -07005971}
5972
5973/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005974 * lim_send_ext_cap_ie() - send ext cap IE to FW
5975 * @mac_ctx: global MAC context
5976 * @session_entry: PE session
5977 * @extra_extcap: extracted ext cap
5978 * @merge: merge extra ext cap
5979 *
5980 * This function is invoked after VDEV is created to update firmware
5981 * about the extended capabilities that the corresponding VDEV is capable
5982 * of. Since STA/SAP can have different Extended capabilities set, this function
5983 * is called per vdev creation.
5984 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305985 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005986 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08005987QDF_STATUS lim_send_ext_cap_ie(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005988 uint32_t session_id,
5989 tDot11fIEExtCap *extra_extcap, bool merge)
5990{
5991 tDot11fIEExtCap ext_cap_data = {0};
5992 uint32_t dot11mode, num_bytes;
5993 bool vht_enabled = false;
5994 struct vdev_ie_info *vdev_ie;
Rajeev Kumarf7d84422017-01-21 15:45:44 -08005995 struct scheduler_msg msg = {0};
Jeff Johnson0301ecb2018-06-29 09:36:23 -07005996 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005997
5998 wlan_cfg_get_int(mac_ctx, WNI_CFG_DOT11_MODE, &dot11mode);
5999 if (IS_DOT11_MODE_VHT(dot11mode))
6000 vht_enabled = true;
6001
6002 status = populate_dot11f_ext_cap(mac_ctx, vht_enabled, &ext_cap_data,
6003 NULL);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006004 if (QDF_STATUS_SUCCESS != status) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306005 pe_err("Failed to populate ext cap IE");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306006 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006007 }
6008
6009 num_bytes = ext_cap_data.num_bytes;
6010
6011 if (merge && NULL != extra_extcap && extra_extcap->num_bytes > 0) {
6012 if (extra_extcap->num_bytes > ext_cap_data.num_bytes)
6013 num_bytes = extra_extcap->num_bytes;
Hu Wangfbd279d2016-10-31 18:24:34 +08006014 lim_merge_extcap_struct(&ext_cap_data, extra_extcap, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006015 }
6016
6017 /* Allocate memory for the WMI request, and copy the parameter */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306018 vdev_ie = qdf_mem_malloc(sizeof(*vdev_ie) + num_bytes);
Arif Hussainf5b6c412018-10-10 19:41:09 -07006019 if (!vdev_ie)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306020 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006021
6022 vdev_ie->vdev_id = session_id;
6023 vdev_ie->ie_id = DOT11F_EID_EXTCAP;
6024 vdev_ie->length = num_bytes;
Naveen Rawat03e8d952016-08-01 15:22:20 -07006025 vdev_ie->band = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006026
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006027 vdev_ie->data = (uint8_t *)vdev_ie + sizeof(*vdev_ie);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306028 qdf_mem_copy(vdev_ie->data, ext_cap_data.bytes, num_bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006029
6030 msg.type = WMA_SET_IE_INFO;
6031 msg.bodyptr = vdev_ie;
6032 msg.reserved = 0;
6033
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306034 if (QDF_STATUS_SUCCESS !=
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05306035 scheduler_post_message(QDF_MODULE_ID_PE,
6036 QDF_MODULE_ID_WMA,
6037 QDF_MODULE_ID_WMA, &msg)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306038 pe_err("Not able to post WMA_SET_IE_INFO to WDA");
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306039 qdf_mem_free(vdev_ie);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306040 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006041 }
6042
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05306043 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006044}
6045
6046/**
Naveen Rawat30b84502016-10-13 17:44:48 -07006047 * lim_strip_ie() - strip requested IE from IE buffer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006048 * @mac_ctx: global MAC context
6049 * @addn_ie: Additional IE buffer
6050 * @addn_ielen: Length of additional IE
Naveen Rawat30b84502016-10-13 17:44:48 -07006051 * @eid: EID of IE to strip
Jeff Johnsonfe8e9492018-05-06 15:40:52 -07006052 * @size_of_len_field: length of IE length field
Naveen Rawat30b84502016-10-13 17:44:48 -07006053 * @oui: if present matches OUI also
6054 * @oui_length: if previous present, this is length of oui
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006055 * @extracted_ie: if not NULL, copy the stripped IE to this buffer
6056 *
Naveen Rawat30b84502016-10-13 17:44:48 -07006057 * This utility function is used to strip of the requested IE if present
6058 * in IE buffer.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006059 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006060 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006061 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08006062QDF_STATUS lim_strip_ie(struct mac_context *mac_ctx,
Naveen Rawat30b84502016-10-13 17:44:48 -07006063 uint8_t *addn_ie, uint16_t *addn_ielen,
6064 uint8_t eid, eSizeOfLenField size_of_len_field,
Arif Hussain6cec6bc2017-02-14 13:46:26 -08006065 uint8_t *oui, uint8_t oui_length, uint8_t *extracted_ie,
6066 uint32_t eid_max_len)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006067{
6068 uint8_t *tempbuf = NULL;
6069 uint16_t templen = 0;
6070 int left = *addn_ielen;
6071 uint8_t *ptr = addn_ie;
Naveen Rawat30b84502016-10-13 17:44:48 -07006072 uint8_t elem_id;
6073 uint16_t elem_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006074
6075 if (NULL == addn_ie) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05306076 pe_debug("NULL addn_ie pointer");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006077 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006078 }
6079
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306080 tempbuf = qdf_mem_malloc(left);
Arif Hussainf5b6c412018-10-10 19:41:09 -07006081 if (!tempbuf)
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006082 return QDF_STATUS_E_NOMEM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006083
6084 while (left >= 2) {
6085 elem_id = ptr[0];
Naveen Rawat30b84502016-10-13 17:44:48 -07006086 left -= 1;
6087 if (size_of_len_field == TWO_BYTE) {
6088 elem_len = *((uint16_t *)&ptr[1]);
6089 left -= 2;
6090 } else {
6091 elem_len = ptr[1];
6092 left -= 1;
6093 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006094 if (elem_len > left) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306095 pe_err("Invalid IEs eid: %d elem_len: %d left: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006096 elem_id, elem_len, left);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306097 qdf_mem_free(tempbuf);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006098 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006099 }
Naveen Rawat30b84502016-10-13 17:44:48 -07006100
6101 if (eid != elem_id ||
6102 (oui && qdf_mem_cmp(oui,
6103 &ptr[size_of_len_field + 1],
6104 oui_length))) {
6105 qdf_mem_copy(tempbuf + templen, &ptr[0],
6106 elem_len + size_of_len_field + 1);
6107 templen += (elem_len + size_of_len_field + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006108 } else {
Naveen Rawat30b84502016-10-13 17:44:48 -07006109 /*
6110 * eid matched and if provided OUI also matched
6111 * take oui IE and store in provided buffer.
6112 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006113 if (NULL != extracted_ie) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306114 qdf_mem_set(extracted_ie,
Arif Hussain6cec6bc2017-02-14 13:46:26 -08006115 eid_max_len + size_of_len_field + 1,
6116 0);
6117 if (elem_len <= eid_max_len)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306118 qdf_mem_copy(extracted_ie, &ptr[0],
Arif Hussain6cec6bc2017-02-14 13:46:26 -08006119 elem_len + size_of_len_field + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006120 }
6121 }
6122 left -= elem_len;
Naveen Rawat30b84502016-10-13 17:44:48 -07006123 ptr += (elem_len + size_of_len_field + 1);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006124 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306125 qdf_mem_copy(addn_ie, tempbuf, templen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006126
6127 *addn_ielen = templen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306128 qdf_mem_free(tempbuf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006129
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006130 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006131}
6132
Krunal Sonid3c86d42017-10-19 12:12:21 -07006133#ifdef WLAN_FEATURE_11W
Jeff Johnsond01da6b2018-12-02 12:10:22 -08006134void lim_del_pmf_sa_query_timer(struct mac_context *mac_ctx, struct pe_session *pe_session)
Krunal Sonid3c86d42017-10-19 12:12:21 -07006135{
6136 uint32_t associated_sta;
6137 tpDphHashNode sta_ds = NULL;
6138
6139 for (associated_sta = 1;
Bala Venkatesh2fde2c62018-09-11 20:33:24 +05306140 associated_sta <
6141 mac_ctx->mlme_cfg->sap_cfg.assoc_sta_limit;
Krunal Sonid3c86d42017-10-19 12:12:21 -07006142 associated_sta++) {
6143 sta_ds = dph_get_hash_entry(mac_ctx, associated_sta,
6144 &pe_session->dph.dphHashTable);
6145 if (NULL == sta_ds)
6146 continue;
Krunal Sonia59e8a42017-11-19 09:00:56 -08006147 if (!sta_ds->rmfEnabled) {
6148 pe_debug("no PMF timer for sta-idx:%d assoc-id:%d",
6149 sta_ds->staIndex, sta_ds->assocId);
6150 continue;
6151 }
Krunal Sonid3c86d42017-10-19 12:12:21 -07006152
Krunal Sonia59e8a42017-11-19 09:00:56 -08006153 pe_debug("Deleting pmfSaQueryTimer for sta-idx:%d assoc-id:%d",
6154 sta_ds->staIndex, sta_ds->assocId);
Krunal Sonid3c86d42017-10-19 12:12:21 -07006155 tx_timer_deactivate(&sta_ds->pmfSaQueryTimer);
6156 tx_timer_delete(&sta_ds->pmfSaQueryTimer);
6157 }
6158}
6159#endif
6160
Jeff Johnsond01da6b2018-12-02 12:10:22 -08006161QDF_STATUS lim_strip_supp_op_class_update_struct(struct mac_context *mac_ctx,
Arif Hussain6cec6bc2017-02-14 13:46:26 -08006162 uint8_t *addn_ie, uint16_t *addn_ielen,
6163 tDot11fIESuppOperatingClasses *dst)
6164{
6165 uint8_t extracted_buff[DOT11F_IE_SUPPOPERATINGCLASSES_MAX_LEN + 2];
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006166 QDF_STATUS status;
Arif Hussain6cec6bc2017-02-14 13:46:26 -08006167
6168 qdf_mem_set((uint8_t *)&extracted_buff[0],
6169 DOT11F_IE_SUPPOPERATINGCLASSES_MAX_LEN + 2,
6170 0);
6171 status = lim_strip_ie(mac_ctx, addn_ie, addn_ielen,
6172 DOT11F_EID_SUPPOPERATINGCLASSES, ONE_BYTE,
6173 NULL, 0, extracted_buff,
6174 DOT11F_IE_SUPPOPERATINGCLASSES_MAX_LEN);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006175 if (QDF_STATUS_SUCCESS != status) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306176 pe_warn("Failed to strip supp_op_mode IE status: %d",
Arif Hussain6cec6bc2017-02-14 13:46:26 -08006177 status);
6178 return status;
6179 }
6180
6181 if (DOT11F_EID_SUPPOPERATINGCLASSES != extracted_buff[0] ||
6182 extracted_buff[1] > DOT11F_IE_SUPPOPERATINGCLASSES_MAX_LEN) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306183 pe_warn("Invalid IEs eid: %d elem_len: %d",
Arif Hussain6cec6bc2017-02-14 13:46:26 -08006184 extracted_buff[0], extracted_buff[1]);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006185 return QDF_STATUS_E_FAILURE;
Arif Hussain6cec6bc2017-02-14 13:46:26 -08006186 }
6187
6188 /* update the extracted supp op class to struct*/
6189 if (DOT11F_PARSE_SUCCESS != dot11f_unpack_ie_supp_operating_classes(
Selvaraj, Sridhar75afbeb2017-04-03 17:08:59 +05306190 mac_ctx, &extracted_buff[2], extracted_buff[1], dst, false)) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306191 pe_err("dot11f_unpack Parse Error");
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006192 return QDF_STATUS_E_FAILURE;
Arif Hussain6cec6bc2017-02-14 13:46:26 -08006193 }
6194
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006195 return QDF_STATUS_SUCCESS;
Arif Hussain6cec6bc2017-02-14 13:46:26 -08006196}
6197
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006198/**
6199 * lim_update_extcap_struct() - poputlate the dot11f structure
6200 * @mac_ctx: global MAC context
6201 * @buf: extracted IE buffer
6202 * @dst: extended capability IE structure to be updated
6203 *
6204 * This function is used to update the extended capability structure
6205 * with @buf.
6206 *
6207 * Return: None
6208 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08006209void lim_update_extcap_struct(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006210 uint8_t *buf, tDot11fIEExtCap *dst)
6211{
6212 uint8_t out[DOT11F_IE_EXTCAP_MAX_LEN];
Padma, Santhosh Kumar92234472017-04-19 18:20:02 +05306213 uint32_t status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006214
6215 if (NULL == buf) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306216 pe_err("Invalid Buffer Address");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006217 return;
6218 }
6219
6220 if (NULL == dst) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306221 pe_err("NULL dst pointer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006222 return;
6223 }
6224
6225 if (DOT11F_EID_EXTCAP != buf[0] || buf[1] > DOT11F_IE_EXTCAP_MAX_LEN) {
Dustin Brown897dae42018-03-13 17:08:47 -07006226 pe_debug_rl("Invalid IEs eid: %d elem_len: %d", buf[0], buf[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006227 return;
6228 }
6229
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306230 qdf_mem_set((uint8_t *)&out[0], DOT11F_IE_EXTCAP_MAX_LEN, 0);
Hu Wang411e0cc2016-10-28 14:56:01 +08006231 qdf_mem_copy(&out[0], &buf[2], buf[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006232
Padma, Santhosh Kumar92234472017-04-19 18:20:02 +05306233 status = dot11f_unpack_ie_ext_cap(mac_ctx, &out[0],
6234 buf[1], dst, false);
6235 if (DOT11F_PARSE_SUCCESS != status)
6236 pe_err("dot11f_unpack Parse Error %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006237}
6238
6239/**
6240 * lim_strip_extcap_update_struct - strip extended capability IE and populate
6241 * the dot11f structure
6242 * @mac_ctx: global MAC context
6243 * @addn_ie: Additional IE buffer
6244 * @addn_ielen: Length of additional IE
6245 * @dst: extended capability IE structure to be updated
6246 *
6247 * This function is used to strip extended capability IE from IE buffer and
6248 * update the passed structure.
6249 *
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006250 * Return: QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006251 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08006252QDF_STATUS lim_strip_extcap_update_struct(struct mac_context *mac_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006253 uint8_t *addn_ie, uint16_t *addn_ielen, tDot11fIEExtCap *dst)
6254{
6255 uint8_t extracted_buff[DOT11F_IE_EXTCAP_MAX_LEN + 2];
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006256 QDF_STATUS status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006257
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306258 qdf_mem_set((uint8_t *)&extracted_buff[0], DOT11F_IE_EXTCAP_MAX_LEN + 2,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006259 0);
Naveen Rawat30b84502016-10-13 17:44:48 -07006260 status = lim_strip_ie(mac_ctx, addn_ie, addn_ielen,
6261 DOT11F_EID_EXTCAP, ONE_BYTE,
Arif Hussain6cec6bc2017-02-14 13:46:26 -08006262 NULL, 0, extracted_buff,
6263 DOT11F_IE_EXTCAP_MAX_LEN);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006264 if (QDF_STATUS_SUCCESS != status) {
Abhishek Singh5d8d7332017-08-10 15:15:24 +05306265 pe_debug("Failed to strip extcap IE status: %d", status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006266 return status;
6267 }
6268
6269 /* update the extracted ExtCap to struct*/
6270 lim_update_extcap_struct(mac_ctx, extracted_buff, dst);
6271 return status;
6272}
6273
6274/**
6275 * lim_merge_extcap_struct() - merge extended capabilities info
6276 * @dst: destination extended capabilities
6277 * @src: source extended capabilities
Jeff Johnson118a4a02018-05-06 00:14:15 -07006278 * @add: true if add the capabilities, false if strip the capabilities.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006279 *
Hu Wangfbd279d2016-10-31 18:24:34 +08006280 * This function is used to take @src info and add/strip it to/from
6281 * @dst extended capabilities info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006282 *
6283 * Return: None
6284 */
6285void lim_merge_extcap_struct(tDot11fIEExtCap *dst,
Hu Wangfbd279d2016-10-31 18:24:34 +08006286 tDot11fIEExtCap *src,
6287 bool add)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006288{
6289 uint8_t *tempdst = (uint8_t *)dst->bytes;
6290 uint8_t *tempsrc = (uint8_t *)src->bytes;
6291 uint8_t structlen = member_size(tDot11fIEExtCap, bytes);
6292
Hu Wangfbd279d2016-10-31 18:24:34 +08006293 /* Return if @src not present */
6294 if (!src->present)
6295 return;
6296
Jeff Johnson118a4a02018-05-06 00:14:15 -07006297 /* Return if strip the capabilities from @dst which not present */
Hu Wangfbd279d2016-10-31 18:24:34 +08006298 if (!dst->present && !add)
6299 return;
6300
Jeff Johnson118a4a02018-05-06 00:14:15 -07006301 /* Merge the capabilities info in other cases */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006302 while (tempdst && tempsrc && structlen--) {
Hu Wangfbd279d2016-10-31 18:24:34 +08006303 if (add)
6304 *tempdst |= *tempsrc;
6305 else
6306 *tempdst &= *tempsrc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006307 tempdst++;
6308 tempsrc++;
6309 }
Hu Wang411e0cc2016-10-28 14:56:01 +08006310 dst->num_bytes = lim_compute_ext_cap_ie_length(dst);
Hu Wangfbd279d2016-10-31 18:24:34 +08006311 if (dst->num_bytes == 0)
6312 dst->present = 0;
6313 else
6314 dst->present = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006315}
6316
Naveen Rawatc0c91cd2015-11-05 14:27:37 -08006317/**
Kiran Kumar Lokereee205772018-09-27 00:27:27 -07006318 * lim_send_action_frm_tb_ppdu_cfg_flush_cb() - flush TB PPDU cfg msg
6319 * @msg: Message pointer
6320 *
6321 * Flushes the send action frame in HE TB PPDU configuration message.
6322 *
6323 * Return: None
6324 */
6325static void lim_send_action_frm_tb_ppdu_cfg_flush_cb(struct scheduler_msg *msg)
6326{
6327 if (msg->bodyptr) {
6328 qdf_mem_free(msg->bodyptr);
6329 msg->bodyptr = NULL;
6330 }
6331}
6332
6333/**
6334 * lim_send_action_frm_tb_ppdu_cfg() - sets action frame in TB PPDU cfg to FW
6335 * @mac_ctx: global MAC context
6336 * @session_id: SME session id
6337 * @cfg: config setting
6338 *
6339 * Preapres the vendor action frame and send action frame in HE TB PPDU
6340 * configuration to FW.
6341 *
6342 * Return: QDF_STATUS
6343 */
6344QDF_STATUS lim_send_action_frm_tb_ppdu_cfg(struct mac_context *mac_ctx,
6345 uint32_t session_id,
6346 uint8_t cfg)
6347{
6348 tDot11fvendor_action_frame *frm;
6349 uint8_t frm_len = sizeof(*frm);
Jeff Johnsonc8baa902018-11-18 21:59:07 -08006350 struct pe_session *session;
Kiran Kumar Lokereee205772018-09-27 00:27:27 -07006351 struct cfg_action_frm_tb_ppdu *cfg_msg;
6352 struct scheduler_msg msg = {0};
6353 uint8_t *data_buf;
6354
6355 session = pe_find_session_by_sme_session_id(mac_ctx, session_id);
6356
6357 if (!session) {
6358 pe_err("pe session does not exist for sme session id %d",
6359 session_id);
6360 return QDF_STATUS_E_FAILURE;
6361 }
6362
6363 data_buf = qdf_mem_malloc(frm_len + sizeof(*cfg_msg));
6364 if (!data_buf)
6365 return QDF_STATUS_E_FAILURE;
6366
6367 cfg_msg = (struct cfg_action_frm_tb_ppdu *)data_buf;
6368
6369 frm = (tDot11fvendor_action_frame *)(data_buf + sizeof(*cfg_msg));
6370
6371 frm->Category.category = SIR_MAC_ACTION_VENDOR_SPECIFIC_CATEGORY;
6372
6373 frm->vendor_oui.oui_data[0] = 0x00;
6374 frm->vendor_oui.oui_data[1] = 0xA0;
6375 frm->vendor_oui.oui_data[2] = 0xC6;
6376
6377 frm->vendor_action_subtype.subtype = 0xFF;
6378
6379 cfg_msg->vdev_id = session_id;
6380 cfg_msg->cfg = cfg;
6381 cfg_msg->frm_len = frm_len;
6382 cfg_msg->data = (uint8_t *)frm;
6383
6384 msg.type = WMA_CFG_VENDOR_ACTION_TB_PPDU;
6385 msg.bodyptr = cfg_msg;
6386 msg.reserved = 0;
6387 msg.flush_callback = lim_send_action_frm_tb_ppdu_cfg_flush_cb;
6388
6389 if (QDF_STATUS_SUCCESS !=
6390 scheduler_post_message(QDF_MODULE_ID_PE,
6391 QDF_MODULE_ID_WMA,
6392 QDF_MODULE_ID_WMA, &msg)) {
6393 pe_err("Not able to post WMA_SET_IE_INFO to WDA");
6394 qdf_mem_free(data_buf);
6395 return QDF_STATUS_E_FAILURE;
6396 }
6397
6398 return QDF_STATUS_SUCCESS;
6399}
6400
6401/**
Naveen Rawatc0c91cd2015-11-05 14:27:37 -08006402 * lim_get_80Mhz_center_channel - finds 80 Mhz center channel
6403 *
6404 * @primary_channel: Primary channel for given 80 MHz band
6405 *
6406 * There are fixed 80MHz band and for each fixed band there is only one center
6407 * valid channel. Also location of primary channel decides what 80 MHz band will
6408 * it use, hence it decides what center channel will be used. This function
6409 * does thus calculation and returns the center channel.
6410 *
6411 * Return: center channel
6412 */
6413uint8_t
6414lim_get_80Mhz_center_channel(uint8_t primary_channel)
6415{
6416 if (primary_channel >= 36 && primary_channel <= 48)
6417 return (36+48)/2;
6418 if (primary_channel >= 52 && primary_channel <= 64)
6419 return (52+64)/2;
6420 if (primary_channel >= 100 && primary_channel <= 112)
6421 return (100+112)/2;
6422 if (primary_channel >= 116 && primary_channel <= 128)
6423 return (116+128)/2;
6424 if (primary_channel >= 132 && primary_channel <= 144)
6425 return (132+144)/2;
6426 if (primary_channel >= 149 && primary_channel <= 161)
6427 return (149+161)/2;
6428
6429 return INVALID_CHANNEL_ID;
6430}
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05306431
6432/**
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05306433 * lim_bss_type_to_string(): converts bss type enum to string.
6434 * @bss_type: enum value of bss_type.
6435 *
6436 * Return: Printable string for bss_type
6437 */
6438const char *lim_bss_type_to_string(const uint16_t bss_type)
6439{
6440 switch (bss_type) {
6441 CASE_RETURN_STRING(eSIR_INFRASTRUCTURE_MODE);
6442 CASE_RETURN_STRING(eSIR_INFRA_AP_MODE);
6443 CASE_RETURN_STRING(eSIR_IBSS_MODE);
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05306444 CASE_RETURN_STRING(eSIR_AUTO_MODE);
Deepak Dhamdheree2dd5442016-05-27 15:05:51 -07006445 CASE_RETURN_STRING(eSIR_NDI_MODE);
Sreelakshmi Konamki39acb132015-12-16 13:06:22 +05306446 default:
6447 return "Unknown bss_type";
6448 }
6449}
Sandeep Puligillae0875662016-02-12 16:09:21 -08006450
6451/**
6452 * lim_init_obss_params(): Initializes the OBSS Scan Parameters
6453 * @sesssion: LIM session
6454 * @mac_ctx: Mac context
6455 *
6456 * Return: None
6457 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08006458void lim_init_obss_params(struct mac_context *mac_ctx, struct pe_session *session)
Sandeep Puligillae0875662016-02-12 16:09:21 -08006459{
Wu Gaod8f3db02018-07-24 19:18:45 +08006460 struct wlan_mlme_obss_ht40 *obss_ht40;
Sandeep Puligillae0875662016-02-12 16:09:21 -08006461
Wu Gaod8f3db02018-07-24 19:18:45 +08006462 if (!(mac_ctx->mlme_cfg)) {
6463 pe_err("invalid mlme cfg");
Sandeep Puligillae0875662016-02-12 16:09:21 -08006464 return;
6465 }
Sandeep Puligillae0875662016-02-12 16:09:21 -08006466
Wu Gaod8f3db02018-07-24 19:18:45 +08006467 obss_ht40 = &mac_ctx->mlme_cfg->obss_ht40;
Sandeep Puligillae0875662016-02-12 16:09:21 -08006468
Wu Gaod8f3db02018-07-24 19:18:45 +08006469 session->obss_ht40_scanparam.obss_active_dwelltime =
6470 obss_ht40->active_dwelltime;
Sandeep Puligillae0875662016-02-12 16:09:21 -08006471
Wu Gaod8f3db02018-07-24 19:18:45 +08006472 session->obss_ht40_scanparam.obss_passive_dwelltime =
6473 obss_ht40->passive_dwelltime;
6474
6475 session->obss_ht40_scanparam.obss_width_trigger_interval =
6476 obss_ht40->width_trigger_interval;
6477
6478 session->obss_ht40_scanparam.obss_active_total_per_channel =
6479 obss_ht40->active_per_channel;
6480
6481 session->obss_ht40_scanparam.obss_passive_total_per_channel =
6482 obss_ht40->passive_per_channel;
6483
Sandeep Puligillae0875662016-02-12 16:09:21 -08006484 session->obss_ht40_scanparam.bsswidth_ch_trans_delay =
Wu Gaod8f3db02018-07-24 19:18:45 +08006485 obss_ht40->width_trans_delay;
Sandeep Puligillae0875662016-02-12 16:09:21 -08006486
Wu Gaod8f3db02018-07-24 19:18:45 +08006487 session->obss_ht40_scanparam.obss_activity_threshold =
6488 obss_ht40->scan_activity_threshold;
Sandeep Puligillae0875662016-02-12 16:09:21 -08006489}
6490
6491/**
6492 * lim_update_obss_scanparams(): Updates OBSS SCAN IE parameters to session
6493 * @sesssion: LIM session
6494 * @scan_params: Scan parameters
6495 *
6496 * Return: None
6497 */
Jeff Johnsonc8baa902018-11-18 21:59:07 -08006498void lim_update_obss_scanparams(struct pe_session *session,
Sandeep Puligillae0875662016-02-12 16:09:21 -08006499 tDot11fIEOBSSScanParameters *scan_params)
6500{
6501 /*
Jeff Johnson4ceed382018-05-06 16:24:57 -07006502 * If the received value is not in the range specified
Sandeep Puligillae0875662016-02-12 16:09:21 -08006503 * by the Specification then it will be the default value
6504 * configured through cfg
6505 */
6506 if ((scan_params->obssScanActiveDwell >
Wu Gaod8f3db02018-07-24 19:18:45 +08006507 cfg_min(CFG_OBSS_HT40_SCAN_ACTIVE_DWELL_TIME)) &&
Sandeep Puligillae0875662016-02-12 16:09:21 -08006508 (scan_params->obssScanActiveDwell <
Wu Gaod8f3db02018-07-24 19:18:45 +08006509 cfg_max(CFG_OBSS_HT40_SCAN_ACTIVE_DWELL_TIME)))
Sandeep Puligillae0875662016-02-12 16:09:21 -08006510 session->obss_ht40_scanparam.obss_active_dwelltime =
6511 scan_params->obssScanActiveDwell;
6512
6513 if ((scan_params->obssScanPassiveDwell >
Wu Gaod8f3db02018-07-24 19:18:45 +08006514 cfg_min(CFG_OBSS_HT40_SCAN_PASSIVE_DWELL_TIME)) &&
Sandeep Puligillae0875662016-02-12 16:09:21 -08006515 (scan_params->obssScanPassiveDwell <
Wu Gaod8f3db02018-07-24 19:18:45 +08006516 cfg_max(CFG_OBSS_HT40_SCAN_PASSIVE_DWELL_TIME)))
Will Huang1655c222018-05-14 15:27:56 +08006517 session->obss_ht40_scanparam.obss_passive_dwelltime =
Sandeep Puligillae0875662016-02-12 16:09:21 -08006518 scan_params->obssScanPassiveDwell;
6519
6520 if ((scan_params->bssWidthChannelTransitionDelayFactor >
Wu Gaod8f3db02018-07-24 19:18:45 +08006521 cfg_min(CFG_OBSS_HT40_WIDTH_CH_TRANSITION_DELAY)) &&
Sandeep Puligillae0875662016-02-12 16:09:21 -08006522 (scan_params->bssWidthChannelTransitionDelayFactor <
Wu Gaod8f3db02018-07-24 19:18:45 +08006523 cfg_max(CFG_OBSS_HT40_WIDTH_CH_TRANSITION_DELAY)))
Sandeep Puligillae0875662016-02-12 16:09:21 -08006524 session->obss_ht40_scanparam.bsswidth_ch_trans_delay =
6525 scan_params->bssWidthChannelTransitionDelayFactor;
6526
6527 if ((scan_params->obssScanActiveTotalPerChannel >
Wu Gaod8f3db02018-07-24 19:18:45 +08006528 cfg_min(CFG_OBSS_HT40_SCAN_ACTIVE_TOTAL_PER_CHANNEL)) &&
Sandeep Puligillae0875662016-02-12 16:09:21 -08006529 (scan_params->obssScanActiveTotalPerChannel <
Wu Gaod8f3db02018-07-24 19:18:45 +08006530 cfg_max(CFG_OBSS_HT40_SCAN_ACTIVE_TOTAL_PER_CHANNEL)))
Sandeep Puligillae0875662016-02-12 16:09:21 -08006531 session->obss_ht40_scanparam.obss_active_total_per_channel =
6532 scan_params->obssScanActiveTotalPerChannel;
6533
6534 if ((scan_params->obssScanPassiveTotalPerChannel >
Wu Gaod8f3db02018-07-24 19:18:45 +08006535 cfg_min(CFG_OBSS_HT40_SCAN_PASSIVE_TOTAL_PER_CHANNEL)) &&
Sandeep Puligillae0875662016-02-12 16:09:21 -08006536 (scan_params->obssScanPassiveTotalPerChannel <
Wu Gaod8f3db02018-07-24 19:18:45 +08006537 cfg_max(CFG_OBSS_HT40_SCAN_PASSIVE_TOTAL_PER_CHANNEL)))
Sandeep Puligillae0875662016-02-12 16:09:21 -08006538 session->obss_ht40_scanparam.obss_passive_total_per_channel =
6539 scan_params->obssScanPassiveTotalPerChannel;
6540
6541 if ((scan_params->bssChannelWidthTriggerScanInterval >
Wu Gaod8f3db02018-07-24 19:18:45 +08006542 cfg_min(CFG_OBSS_HT40_SCAN_WIDTH_TRIGGER_INTERVAL)) &&
Sandeep Puligillae0875662016-02-12 16:09:21 -08006543 (scan_params->bssChannelWidthTriggerScanInterval <
Wu Gaod8f3db02018-07-24 19:18:45 +08006544 cfg_max(CFG_OBSS_HT40_SCAN_WIDTH_TRIGGER_INTERVAL)))
Sandeep Puligillae0875662016-02-12 16:09:21 -08006545 session->obss_ht40_scanparam.obss_width_trigger_interval =
6546 scan_params->bssChannelWidthTriggerScanInterval;
6547
6548 if ((scan_params->obssScanActivityThreshold >
Wu Gaod8f3db02018-07-24 19:18:45 +08006549 cfg_min(CFG_OBSS_HT40_SCAN_ACTIVITY_THRESHOLD)) &&
Sandeep Puligillae0875662016-02-12 16:09:21 -08006550 (scan_params->obssScanActivityThreshold <
Wu Gaod8f3db02018-07-24 19:18:45 +08006551 cfg_max(CFG_OBSS_HT40_SCAN_ACTIVITY_THRESHOLD)))
Sandeep Puligillae0875662016-02-12 16:09:21 -08006552 session->obss_ht40_scanparam.obss_activity_threshold =
6553 scan_params->obssScanActivityThreshold;
6554 return;
6555}
Rajeev Kumar03200802016-04-15 13:59:36 -07006556
6557/**
6558 * lim_is_robust_mgmt_action_frame() - Check if action category is
6559 * robust action frame
6560 * @action_category: Action frame category.
6561 *
6562 * This function is used to check if given action category is robust
6563 * action frame.
6564 *
6565 * Return: bool
6566 */
6567bool lim_is_robust_mgmt_action_frame(uint8_t action_category)
6568{
6569 switch (action_category) {
6570 /*
6571 * NOTE: This function doesn't take care of the DMG
6572 * (Directional Multi-Gigatbit) BSS case as 8011ad
6573 * support is not yet added. In future, if the support
6574 * is required then this function need few more arguments
6575 * and little change in logic.
6576 */
6577 case SIR_MAC_ACTION_SPECTRUM_MGMT:
6578 case SIR_MAC_ACTION_QOS_MGMT:
6579 case SIR_MAC_ACTION_DLP:
6580 case SIR_MAC_ACTION_BLKACK:
6581 case SIR_MAC_ACTION_RRM:
6582 case SIR_MAC_ACTION_FAST_BSS_TRNST:
6583 case SIR_MAC_ACTION_SA_QUERY:
6584 case SIR_MAC_ACTION_PROT_DUAL_PUB:
6585 case SIR_MAC_ACTION_WNM:
6586 case SIR_MAC_ACITON_MESH:
6587 case SIR_MAC_ACTION_MHF:
6588 case SIR_MAC_ACTION_FST:
6589 return true;
6590 default:
Naveen Rawat170420a2017-12-21 14:33:55 -08006591 pe_debug("non-PMF action category: %d", action_category);
Rajeev Kumar03200802016-04-15 13:59:36 -07006592 break;
6593 }
6594 return false;
6595}
Kapil Guptac03eb072016-08-09 14:01:36 +05306596
6597/**
Hu Wang411e0cc2016-10-28 14:56:01 +08006598 * lim_compute_ext_cap_ie_length - compute the length of ext cap ie
6599 * based on the bits set
Kapil Guptac03eb072016-08-09 14:01:36 +05306600 * @ext_cap: extended IEs structure
6601 *
Hu Wang411e0cc2016-10-28 14:56:01 +08006602 * Return: length of the ext cap ie, 0 means should not present
Kapil Guptac03eb072016-08-09 14:01:36 +05306603 */
Hu Wang411e0cc2016-10-28 14:56:01 +08006604uint8_t lim_compute_ext_cap_ie_length(tDot11fIEExtCap *ext_cap)
Kapil Guptac03eb072016-08-09 14:01:36 +05306605{
Hu Wang411e0cc2016-10-28 14:56:01 +08006606 uint8_t i = DOT11F_IE_EXTCAP_MAX_LEN;
Kapil Guptac03eb072016-08-09 14:01:36 +05306607
Hu Wang411e0cc2016-10-28 14:56:01 +08006608 while (i) {
6609 if (ext_cap->bytes[i-1])
6610 break;
6611 i--;
6612 }
Kapil Guptac03eb072016-08-09 14:01:36 +05306613
Hu Wang411e0cc2016-10-28 14:56:01 +08006614 return i;
Kapil Guptac03eb072016-08-09 14:01:36 +05306615}
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05306616
6617/**
6618 * lim_update_caps_info_for_bss - Update capability info for this BSS
6619 *
6620 * @mac_ctx: mac context
6621 * @caps: Pointer to capability info to be updated
6622 * @bss_caps: Capability info of the BSS
6623 *
6624 * Update the capability info in Assoc/Reassoc request frames and reset
6625 * the spectrum management, short preamble, immediate block ack bits
6626 * if the BSS doesnot support it
6627 *
6628 * Return: None
6629 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08006630void lim_update_caps_info_for_bss(struct mac_context *mac_ctx,
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05306631 uint16_t *caps, uint16_t bss_caps)
6632{
6633 if (!(bss_caps & LIM_SPECTRUM_MANAGEMENT_BIT_MASK)) {
6634 *caps &= (~LIM_SPECTRUM_MANAGEMENT_BIT_MASK);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306635 pe_debug("Clearing spectrum management:no AP support");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05306636 }
6637
6638 if (!(bss_caps & LIM_SHORT_PREAMBLE_BIT_MASK)) {
6639 *caps &= (~LIM_SHORT_PREAMBLE_BIT_MASK);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306640 pe_debug("Clearing short preamble:no AP support");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05306641 }
6642
6643 if (!(bss_caps & LIM_IMMEDIATE_BLOCK_ACK_MASK)) {
6644 *caps &= (~LIM_IMMEDIATE_BLOCK_ACK_MASK);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306645 pe_debug("Clearing Immed Blk Ack:no AP support");
Selvaraj, Sridharaf54e2e2016-06-24 12:25:02 +05306646 }
6647}
Kiran Kumar Lokere6d3a30d2018-01-15 18:18:29 -08006648/**
6649 * lim_send_set_dtim_period(): Send SIR_HAL_SET_DTIM_PERIOD message
6650 * to set dtim period.
6651 *
6652 * @sesssion: LIM session
6653 * @dtim_period: dtim value
6654 * @mac_ctx: Mac context
6655 * @return None
6656 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08006657void lim_send_set_dtim_period(struct mac_context *mac_ctx, uint8_t dtim_period,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08006658 struct pe_session *session)
Kiran Kumar Lokere6d3a30d2018-01-15 18:18:29 -08006659{
6660 struct set_dtim_params *dtim_params = NULL;
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006661 QDF_STATUS ret = QDF_STATUS_SUCCESS;
Kiran Kumar Lokere6d3a30d2018-01-15 18:18:29 -08006662 struct scheduler_msg msg = {0};
6663
6664 if (!session) {
6665 pe_err("Inavalid parameters");
6666 return;
6667 }
6668 dtim_params = qdf_mem_malloc(sizeof(*dtim_params));
Arif Hussainf5b6c412018-10-10 19:41:09 -07006669 if (!dtim_params)
Kiran Kumar Lokere6d3a30d2018-01-15 18:18:29 -08006670 return;
Kiran Kumar Lokere6d3a30d2018-01-15 18:18:29 -08006671 dtim_params->dtim_period = dtim_period;
6672 dtim_params->session_id = session->smeSessionId;
6673 msg.type = WMA_SET_DTIM_PERIOD;
6674 msg.bodyptr = dtim_params;
6675 msg.bodyval = 0;
6676 pe_debug("Post WMA_SET_DTIM_PERIOD to WMA");
6677 ret = wma_post_ctrl_msg(mac_ctx, &msg);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006678 if (QDF_STATUS_SUCCESS != ret) {
Kiran Kumar Lokere6d3a30d2018-01-15 18:18:29 -08006679 pe_err("wma_post_ctrl_msg() failed");
6680 qdf_mem_free(dtim_params);
6681 }
6682}
Arif Hussain776ee7a2016-11-10 20:28:50 -08006683
6684/**
6685 * lim_is_valid_frame(): validate RX frame using last processed frame details
6686 * to find if it is duplicate frame.
6687 *
6688 * @last_processed_frm: last processed frame pointer.
6689 * @pRxPacketInfo: RX packet.
6690 *
6691 * Frame treat as duplicate:
6692 * if retry bit is set and
Jeff Johnson560dc562017-03-17 15:19:31 -07006693 * if source address and seq number matches with the last processed frame
Arif Hussain776ee7a2016-11-10 20:28:50 -08006694 *
6695 * Return: false if duplicate frame, else true.
6696 */
6697bool lim_is_valid_frame(last_processed_msg *last_processed_frm,
6698 uint8_t *pRxPacketInfo)
6699{
6700 uint16_t seq_num;
6701 tpSirMacMgmtHdr pHdr;
6702
6703 if (!pRxPacketInfo) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306704 pe_err("Invalid RX frame");
Arif Hussain776ee7a2016-11-10 20:28:50 -08006705 return false;
6706 }
6707
6708 pHdr = WMA_GET_RX_MAC_HEADER(pRxPacketInfo);
6709
6710 if (pHdr->fc.retry == 0)
6711 return true;
6712
6713 seq_num = (((pHdr->seqControl.seqNumHi <<
6714 HIGH_SEQ_NUM_OFFSET) |
6715 pHdr->seqControl.seqNumLo));
6716
6717 if (last_processed_frm->seq_num == seq_num &&
6718 qdf_mem_cmp(last_processed_frm->sa, pHdr->sa, ETH_ALEN) == 0) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306719 pe_err("Duplicate frame from "MAC_ADDRESS_STR " Seq Number %d",
Arif Hussain776ee7a2016-11-10 20:28:50 -08006720 MAC_ADDR_ARRAY(pHdr->sa), seq_num);
6721 return false;
6722 }
6723 return true;
6724}
6725
6726/**
6727 * lim_update_last_processed_frame(): update new processed frame info to cache.
6728 *
6729 * @last_processed_frm: last processed frame pointer.
6730 * @pRxPacketInfo: Successfully processed RX packet.
6731 *
6732 * Return: None.
6733 */
6734void lim_update_last_processed_frame(last_processed_msg *last_processed_frm,
6735 uint8_t *pRxPacketInfo)
6736{
6737 uint16_t seq_num;
6738 tpSirMacMgmtHdr pHdr;
6739
6740 if (!pRxPacketInfo) {
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306741 pe_err("Invalid RX frame");
Arif Hussain776ee7a2016-11-10 20:28:50 -08006742 return;
6743 }
6744
6745 pHdr = WMA_GET_RX_MAC_HEADER(pRxPacketInfo);
6746 seq_num = (((pHdr->seqControl.seqNumHi <<
6747 HIGH_SEQ_NUM_OFFSET) |
6748 pHdr->seqControl.seqNumLo));
6749
6750 qdf_mem_copy(last_processed_frm->sa, pHdr->sa, ETH_ALEN);
6751 last_processed_frm->seq_num = seq_num;
6752}
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006753
6754#ifdef WLAN_FEATURE_11AX
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006755void lim_add_he_cap(tpAddStaParams add_sta_params, tpSirAssocReq assoc_req)
6756{
6757 if (!add_sta_params->he_capable || !assoc_req)
6758 return;
6759
6760 qdf_mem_copy(&add_sta_params->he_config, &assoc_req->he_cap,
6761 sizeof(add_sta_params->he_config));
6762}
6763
Jeff Johnsonc8baa902018-11-18 21:59:07 -08006764void lim_add_self_he_cap(tpAddStaParams add_sta_params, struct pe_session *session)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006765{
6766 if (!session)
6767 return;
6768
6769 add_sta_params->he_capable = true;
6770
6771 qdf_mem_copy(&add_sta_params->he_config, &session->he_config,
6772 sizeof(add_sta_params->he_config));
6773 qdf_mem_copy(&add_sta_params->he_op, &session->he_op,
6774 sizeof(add_sta_params->he_op));
6775}
6776
6777/**
6778 * lim_intersect_he_caps() - Intersect peer capability and self capability
6779 * @rcvd_he: pointer to received peer capability
6780 * @session_he: pointer to self capability
6781 * @peer_he: pointer to Intersected capability
6782 *
6783 * Return: None
6784 */
Naveen Rawatd8feac12017-09-08 15:08:39 -07006785static void lim_intersect_he_caps(tDot11fIEhe_cap *rcvd_he,
6786 tDot11fIEhe_cap *session_he,
6787 tDot11fIEhe_cap *peer_he)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006788{
6789 uint8_t val;
6790
6791 qdf_mem_copy(peer_he, rcvd_he, sizeof(*peer_he));
6792
6793 peer_he->fragmentation &= session_he->fragmentation;
6794
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -08006795 if (session_he->tx_stbc_lt_80mhz && peer_he->rx_stbc_lt_80mhz)
6796 peer_he->rx_stbc_lt_80mhz = 1;
6797 else
6798 peer_he->rx_stbc_lt_80mhz = 0;
Naveen Rawat4051b022017-09-08 16:17:54 -07006799
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -08006800 if (session_he->rx_stbc_lt_80mhz && peer_he->tx_stbc_lt_80mhz)
6801 peer_he->tx_stbc_lt_80mhz = 1;
6802 else
6803 peer_he->tx_stbc_lt_80mhz = 0;
6804
6805 if (session_he->tx_stbc_gt_80mhz && peer_he->rx_stbc_gt_80mhz)
6806 peer_he->rx_stbc_gt_80mhz = 1;
6807 else
6808 peer_he->rx_stbc_gt_80mhz = 0;
6809
6810 if (session_he->rx_stbc_gt_80mhz && peer_he->tx_stbc_gt_80mhz)
6811 peer_he->tx_stbc_gt_80mhz = 1;
6812 else
6813 peer_he->tx_stbc_gt_80mhz = 0;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006814
6815 /* Tx Doppler is first bit and Rx Doppler is second bit */
6816 if (session_he->doppler) {
6817 val = 0;
Naveen Rawat4051b022017-09-08 16:17:54 -07006818 if ((session_he->doppler & 0x1) && (peer_he->doppler & 0x10))
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006819 val |= (1 << 1);
Naveen Rawat4051b022017-09-08 16:17:54 -07006820 if ((session_he->doppler & 0x10) && (peer_he->doppler & 0x1))
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006821 val |= (1 << 0);
6822 peer_he->doppler = val;
6823 }
6824
6825 peer_he->su_beamformer = session_he->su_beamformee ?
6826 peer_he->su_beamformer : 0;
6827 peer_he->su_beamformee = (session_he->su_beamformer ||
6828 session_he->mu_beamformer) ?
6829 peer_he->su_beamformee : 0;
6830 peer_he->mu_beamformer = session_he->su_beamformee ?
6831 peer_he->mu_beamformer : 0;
6832
6833 peer_he->twt_request = session_he->twt_responder ?
6834 peer_he->twt_request : 0;
6835 peer_he->twt_responder = session_he->twt_request ?
6836 peer_he->twt_responder : 0;
6837}
6838
Jeff Johnsonc8baa902018-11-18 21:59:07 -08006839void lim_intersect_sta_he_caps(tpSirAssocReq assoc_req, struct pe_session *session,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006840 tpDphHashNode sta_ds)
6841{
Naveen Rawatd8feac12017-09-08 15:08:39 -07006842 tDot11fIEhe_cap *rcvd_he = &assoc_req->he_cap;
6843 tDot11fIEhe_cap *session_he = &session->he_config;
6844 tDot11fIEhe_cap *peer_he = &sta_ds->he_config;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006845
6846 if (sta_ds->mlmStaContext.he_capable)
6847 lim_intersect_he_caps(rcvd_he, session_he, peer_he);
6848}
6849
Jeff Johnsonc8baa902018-11-18 21:59:07 -08006850void lim_intersect_ap_he_caps(struct pe_session *session, tpAddBssParams add_bss,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006851 tSchBeaconStruct *beacon, tpSirAssocRsp assoc_rsp)
6852{
Naveen Rawatd8feac12017-09-08 15:08:39 -07006853 tDot11fIEhe_cap *rcvd_he;
6854 tDot11fIEhe_cap *session_he = &session->he_config;
6855 tDot11fIEhe_cap *peer_he = &add_bss->staContext.he_config;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006856
6857 if (beacon)
Naveen Rawatd8feac12017-09-08 15:08:39 -07006858 rcvd_he = &beacon->he_cap;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006859 else
Naveen Rawatd8feac12017-09-08 15:08:39 -07006860 rcvd_he = &assoc_rsp->he_cap;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006861
6862 lim_intersect_he_caps(rcvd_he, session_he, peer_he);
6863 add_bss->staContext.he_capable = true;
6864}
6865
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006866void lim_add_bss_he_cap(tpAddBssParams add_bss, tpSirAssocRsp assoc_rsp)
6867{
Naveen Rawatd8feac12017-09-08 15:08:39 -07006868 tDot11fIEhe_cap *he_cap;
6869 tDot11fIEhe_op *he_op;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006870
Naveen Rawatd8feac12017-09-08 15:08:39 -07006871 he_cap = &assoc_rsp->he_cap;
6872 he_op = &assoc_rsp->he_op;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006873 add_bss->he_capable = he_cap->present;
6874 if (he_cap)
6875 qdf_mem_copy(&add_bss->staContext.he_config,
6876 he_cap, sizeof(*he_cap));
6877 if (he_op)
6878 qdf_mem_copy(&add_bss->staContext.he_op,
6879 he_op, sizeof(*he_op));
6880}
6881
Jeff Johnsonc8baa902018-11-18 21:59:07 -08006882void lim_add_bss_he_cfg(tpAddBssParams add_bss, struct pe_session *session)
Manikandan Mohan39accff2017-05-02 16:09:00 -07006883{
6884 add_bss->he_sta_obsspd = session->he_sta_obsspd;
6885}
6886
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006887void lim_update_stads_he_caps(tpDphHashNode sta_ds, tpSirAssocRsp assoc_rsp,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08006888 struct pe_session *session_entry)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006889{
Naveen Rawatd8feac12017-09-08 15:08:39 -07006890 tDot11fIEhe_cap *he_cap;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006891
Naveen Rawatd8feac12017-09-08 15:08:39 -07006892 he_cap = &assoc_rsp->he_cap;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006893 sta_ds->mlmStaContext.he_capable = he_cap->present;
6894
6895 if (!he_cap->present)
6896 return;
6897
6898 qdf_mem_copy(&sta_ds->he_config, he_cap, sizeof(*he_cap));
6899
6900}
6901
Jeff Johnsond01da6b2018-12-02 12:10:22 -08006902void lim_update_usr_he_cap(struct mac_context *mac_ctx, struct pe_session *session)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006903{
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006904 tSirAddIeParams *add_ie = &session->addIeParams;
Naveen Rawatd8feac12017-09-08 15:08:39 -07006905 tDot11fIEhe_cap *he_cap = &session->he_config;
Naveen Rawat436979b2017-11-15 14:53:30 -08006906 struct he_cap_network_endian *he_cap_from_ie;
Kiran Kumar Lokere3a5b4242018-01-04 16:25:02 -08006907 uint8_t extracted_buff[DOT11F_IE_HE_CAP_MAX_LEN + 2];
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006908 QDF_STATUS status;
Kiran Kumar Lokere3a5b4242018-01-04 16:25:02 -08006909 qdf_mem_zero(extracted_buff, sizeof(extracted_buff));
6910 status = lim_strip_ie(mac_ctx, add_ie->probeRespBCNData_buff,
6911 &add_ie->probeRespBCNDataLen,
6912 DOT11F_EID_HE_CAP, ONE_BYTE,
6913 HE_CAP_OUI_TYPE, (uint8_t)HE_CAP_OUI_SIZE,
6914 extracted_buff, DOT11F_IE_HE_CAP_MAX_LEN);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006915 if (QDF_STATUS_SUCCESS != status) {
Kiran Kumar Lokere3a5b4242018-01-04 16:25:02 -08006916 pe_debug("Failed to strip HE cap IE status: %d", status);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006917 return;
6918 }
6919
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306920 pe_debug("Before update: su_beamformer: %d, su_beamformee: %d, mu_beamformer: %d",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006921 he_cap->su_beamformer, he_cap->su_beamformee, he_cap->mu_beamformer);
Naveen Rawat436979b2017-11-15 14:53:30 -08006922
Kiran Kumar Lokere3a5b4242018-01-04 16:25:02 -08006923 he_cap_from_ie = (struct he_cap_network_endian *)
6924 &extracted_buff[HE_CAP_OUI_SIZE + 2];
Naveen Rawat436979b2017-11-15 14:53:30 -08006925
6926 he_cap->su_beamformer =
6927 he_cap->su_beamformer & he_cap_from_ie->su_beamformer;
6928 he_cap->su_beamformee =
6929 he_cap->su_beamformee & he_cap_from_ie->su_beamformee;
6930 he_cap->mu_beamformer =
6931 he_cap->mu_beamformer & he_cap_from_ie->mu_beamformer;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006932
Nishank Aggarwal0402b432017-03-24 19:17:36 +05306933 pe_debug("After update: su_beamformer: %d, su_beamformee: %d, mu_beamformer: %d",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006934 he_cap->su_beamformer, he_cap->su_beamformee, he_cap->mu_beamformer);
6935}
6936
Jeff Johnsond01da6b2018-12-02 12:10:22 -08006937void lim_decide_he_op(struct mac_context *mac_ctx, tpAddBssParams add_bss,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08006938 struct pe_session *session)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006939{
Naveen Rawat436979b2017-11-15 14:53:30 -08006940 uint32_t val;
Naveen Rawat807b6d02018-03-07 18:19:06 -08006941 uint8_t color;
Naveen Rawat436979b2017-11-15 14:53:30 -08006942 struct he_ops_network_endian *he_ops_from_ie;
Naveen Rawatd8feac12017-09-08 15:08:39 -07006943 tDot11fIEhe_op *he_ops = &add_bss->he_op;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006944 tSirAddIeParams *add_ie = &session->addIeParams;
Kiran Kumar Lokere3a5b4242018-01-04 16:25:02 -08006945 uint8_t extracted_buff[DOT11F_IE_HE_OP_MAX_LEN + 2];
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006946 QDF_STATUS status;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006947
Kiran Kumar Lokere3a5b4242018-01-04 16:25:02 -08006948 qdf_mem_zero(extracted_buff, sizeof(extracted_buff));
6949 status = lim_strip_ie(mac_ctx, add_ie->probeRespBCNData_buff,
6950 &add_ie->probeRespBCNDataLen,
6951 DOT11F_EID_HE_OP, ONE_BYTE,
6952 HE_OP_OUI_TYPE, (uint8_t)HE_OP_OUI_SIZE,
6953 extracted_buff, DOT11F_IE_HE_OP_MAX_LEN);
Jeff Johnson0301ecb2018-06-29 09:36:23 -07006954 if (QDF_STATUS_SUCCESS != status) {
Kiran Kumar Lokere3a5b4242018-01-04 16:25:02 -08006955 pe_debug("Failed to strip HE OP IE status: %d", status);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006956 return;
6957 }
Kiran Kumar Lokere3a5b4242018-01-04 16:25:02 -08006958 he_ops_from_ie = (struct he_ops_network_endian *)
6959 &extracted_buff[HE_OP_OUI_SIZE + 2];
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006960
Naveen Rawat807b6d02018-03-07 18:19:06 -08006961 if (he_ops_from_ie->bss_color) {
6962 he_ops->bss_color = he_ops_from_ie->bss_color;
6963 } else {
6964 cds_rand_get_bytes(0, &color, 1);
6965 /* make sure color is within 1-63*/
6966 he_ops->bss_color = (color % WNI_CFG_HE_OPS_BSS_COLOR_MAX) + 1;
6967 }
Naveen Rawat436979b2017-11-15 14:53:30 -08006968 he_ops->default_pe = he_ops_from_ie->default_pe;
6969 he_ops->twt_required = he_ops_from_ie->twt_required;
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07006970 he_ops->txop_rts_threshold = he_ops_from_ie->txop_rts_threshold;
Naveen Rawat436979b2017-11-15 14:53:30 -08006971 he_ops->partial_bss_col = he_ops_from_ie->partial_bss_col;
Naveen Rawat436979b2017-11-15 14:53:30 -08006972 he_ops->bss_col_disabled = he_ops_from_ie->bss_col_disabled;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006973
Bala Venkatesh6d537092018-09-25 10:38:36 +05306974 val = mac_ctx->mlme_cfg->he_caps.he_ops_basic_mcs_nss;
6975
Naveen Rawat436979b2017-11-15 14:53:30 -08006976 *((uint16_t *)he_ops->basic_mcs_nss) = (uint16_t)val;
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006977
Naveen Rawat436979b2017-11-15 14:53:30 -08006978 qdf_mem_copy(&session->he_op, he_ops, sizeof(*he_ops));
6979
6980 pe_debug("HE Op: bss_color: 0x%0x, default_pe_duration: 0x%0x",
6981 he_ops->bss_color, he_ops->default_pe);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07006982 pe_debug("He Op: twt_required: 0x%0x, txop_rts_threshold: 0x%0x",
6983 he_ops->twt_required, he_ops->txop_rts_threshold);
6984 pe_debug("HE Op: partial_bss_color: 0x%0x",
6985 he_ops->partial_bss_col);
Naveen Rawat436979b2017-11-15 14:53:30 -08006986 pe_debug("HE Op: BSS color disabled: 0x%0x",
Naveen Rawat4051b022017-09-08 16:17:54 -07006987 he_ops->bss_col_disabled);
Naveen Rawat436979b2017-11-15 14:53:30 -08006988 pe_debug("HE Op: Basic MCS NSS: 0x%04x",
6989 *((uint16_t *)he_ops->basic_mcs_nss));
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006990}
6991
Jeff Johnsonc8baa902018-11-18 21:59:07 -08006992void lim_copy_bss_he_cap(struct pe_session *session,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08006993 tpSirSmeStartBssReq sme_start_bss_req)
6994{
6995 qdf_mem_copy(&(session->he_config), &(sme_start_bss_req->he_config),
6996 sizeof(session->he_config));
6997}
6998
Jeff Johnsonc8baa902018-11-18 21:59:07 -08006999void lim_copy_join_req_he_cap(struct pe_session *session,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007000 tpSirSmeJoinReq sme_join_req)
7001{
7002 qdf_mem_copy(&(session->he_config), &(sme_join_req->he_config),
7003 sizeof(session->he_config));
Naveen Rawataeca1b92017-10-16 16:55:31 -07007004
7005 if (session->ch_width <= CH_WIDTH_80MHZ) {
7006 *(uint16_t *)session->he_config.rx_he_mcs_map_160 =
7007 HE_MCS_ALL_DISABLED;
7008 *(uint16_t *)session->he_config.tx_he_mcs_map_160 =
7009 HE_MCS_ALL_DISABLED;
7010 *(uint16_t *)session->he_config.rx_he_mcs_map_80_80 =
7011 HE_MCS_ALL_DISABLED;
7012 *(uint16_t *)session->he_config.tx_he_mcs_map_80_80 =
7013 HE_MCS_ALL_DISABLED;
7014 }
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007015}
7016
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007017void lim_log_he_cap(struct mac_context *mac, tDot11fIEhe_cap *he_cap)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007018{
Naveen Rawataeca1b92017-10-16 16:55:31 -07007019 uint8_t chan_width;
Naveen Rawat819158d2018-01-16 10:56:45 -08007020 struct ppet_hdr *hdr;
Naveen Rawataeca1b92017-10-16 16:55:31 -07007021
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007022 if (!he_cap->present)
7023 return;
7024
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307025 pe_debug("HE Capabilities:");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007026
7027 /* HE MAC capabilities */
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307028 pe_debug("\tHTC-HE conrol: 0x%01x", he_cap->htc_he);
7029 pe_debug("\tTWT Requestor support: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007030 he_cap->twt_request);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307031 pe_debug("\tTWT Responder support: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007032 he_cap->twt_responder);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307033 pe_debug("\tFragmentation support: 0x%02x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007034 he_cap->fragmentation);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307035 pe_debug("\tMax no.of frag MSDUs: 0x%03x",
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007036 he_cap->max_num_frag_msdu_amsdu_exp);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307037 pe_debug("\tMin. frag size: 0x%02x", he_cap->min_frag_size);
7038 pe_debug("\tTrigger MAC pad duration: 0x%02x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007039 he_cap->trigger_frm_mac_pad);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007040 pe_debug("\tMulti-TID aggr Rx support: 0x%03x",
7041 he_cap->multi_tid_aggr_rx_supp);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307042 pe_debug("\tLink adaptation: 0x%02x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007043 he_cap->he_link_adaptation);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307044 pe_debug("\tAll ACK support: 0x%01x", he_cap->all_ack);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007045 pe_debug("\tTriggered resp. scheduling: 0x%01x",
7046 he_cap->trigd_rsp_sched);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307047 pe_debug("\tA-Buff status report: 0x%01x", he_cap->a_bsr);
7048 pe_debug("\tBroadcast TWT support: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007049 he_cap->broadcast_twt);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307050 pe_debug("\t32bit BA bitmap support: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007051 he_cap->ba_32bit_bitmap);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307052 pe_debug("\tMU Cascading support: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007053 he_cap->mu_cascade);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307054 pe_debug("\tACK enabled Multi-TID: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007055 he_cap->ack_enabled_multitid);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307056 pe_debug("\tOMI A-Control support: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007057 he_cap->omi_a_ctrl);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307058 pe_debug("\tOFDMA RA support: 0x%01x", he_cap->ofdma_ra);
7059 pe_debug("\tMax A-MPDU Length: 0x%02x",
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007060 he_cap->max_ampdu_len_exp_ext);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307061 pe_debug("\tA-MSDU Fragmentation: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007062 he_cap->amsdu_frag);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307063 pe_debug("\tFlex. TWT sched support: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007064 he_cap->flex_twt_sched);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307065 pe_debug("\tRx Ctrl frame to MBSS: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007066 he_cap->rx_ctrl_frame);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307067 pe_debug("\tBSRP A-MPDU Aggregation: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007068 he_cap->bsrp_ampdu_aggr);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307069 pe_debug("\tQuite Time Period support: 0x%01x", he_cap->qtp);
7070 pe_debug("\tA-BQR support: 0x%01x", he_cap->a_bqr);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007071 pe_debug("\tSR Reponder support: 0x%01x",
7072 he_cap->spatial_reuse_param_rspder);
Naveen Rawat4051b022017-09-08 16:17:54 -07007073 pe_debug("\tNDP Feedback support: 0x%01x", he_cap->ndp_feedback_supp);
7074 pe_debug("\tOPS support: 0x%01x", he_cap->ops_supp);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007075 pe_debug("\tAMSDU in AMPDU: 0x%01x", he_cap->amsdu_in_ampdu);
7076 pe_debug("\tMulti-TID aggr Tx support: 0x%03x",
7077 he_cap->multi_tid_aggr_tx_supp);
7078 pe_debug("\tHE sub ch sel tx supp: 0x%01x",
7079 he_cap->he_sub_ch_sel_tx_supp);
7080 pe_debug("\tUL 2x996 tone RU supp: 0x%01x",
7081 he_cap->ul_2x996_tone_ru_supp);
7082 pe_debug("\tOM ctrl UL MU data dis rx supp: 0x%01x",
7083 he_cap->om_ctrl_ul_mu_data_dis_rx);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007084 /* HE PHY capabilities */
Naveen Rawataeca1b92017-10-16 16:55:31 -07007085 chan_width = HE_CH_WIDTH_COMBINE(he_cap->chan_width_0,
7086 he_cap->chan_width_1, he_cap->chan_width_2,
7087 he_cap->chan_width_3, he_cap->chan_width_4,
7088 he_cap->chan_width_5, he_cap->chan_width_6);
7089
7090 pe_debug("\tChannel width support: 0x%07x", chan_width);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307091 pe_debug("\tPreamble puncturing Rx: 0x%04x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007092 he_cap->rx_pream_puncturing);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307093 pe_debug("\tClass of device: 0x%01x", he_cap->device_class);
7094 pe_debug("\tLDPC coding support: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007095 he_cap->ldpc_coding);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307096 pe_debug("\tLTF and GI for HE PPDUs: 0x%02x",
Naveen Rawat4051b022017-09-08 16:17:54 -07007097 he_cap->he_1x_ltf_800_gi_ppdu);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007098 pe_debug("\tMidamble TX Rx MAX NSTS: 0x%02x",
7099 he_cap->midamble_tx_rx_max_nsts);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307100 pe_debug("\tLTF and GI for NDP: 0x%02x",
Naveen Rawat4051b022017-09-08 16:17:54 -07007101 he_cap->he_4x_ltf_3200_gi_ndp);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -08007102 pe_debug("\tSTBC Tx support (<= 80MHz): 0x%01x",
7103 he_cap->tx_stbc_lt_80mhz);
7104 pe_debug("\tSTBC Rx support (<= 80MHz): 0x%01x",
7105 he_cap->rx_stbc_lt_80mhz);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307106 pe_debug("\tDoppler support: 0x%02x", he_cap->doppler);
7107 pe_debug("\tUL MU: 0x%02x", he_cap->ul_mu);
7108 pe_debug("\tDCM encoding Tx: 0x%03x", he_cap->dcm_enc_tx);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007109 pe_debug("\tDCM encoding Rx: 0x%03x", he_cap->dcm_enc_rx);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307110 pe_debug("\tHE MU PPDU payload support: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007111 he_cap->ul_he_mu);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307112 pe_debug("\tSU Beamformer: 0x%01x", he_cap->su_beamformer);
7113 pe_debug("\tSU Beamformee: 0x%01x", he_cap->su_beamformee);
7114 pe_debug("\tMU Beamformer: 0x%01x", he_cap->mu_beamformer);
7115 pe_debug("\tBeamformee STS for <= 80Mhz: 0x%03x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007116 he_cap->bfee_sts_lt_80);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307117 pe_debug("\tBeamformee STS for > 80Mhz: 0x%03x",
Naveen Rawat4051b022017-09-08 16:17:54 -07007118 he_cap->bfee_sts_gt_80);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307119 pe_debug("\tNo. of sounding dim <= 80Mhz: 0x%03x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007120 he_cap->num_sounding_lt_80);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307121 pe_debug("\tNo. of sounding dim > 80Mhz: 0x%03x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007122 he_cap->num_sounding_gt_80);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307123 pe_debug("\tNg=16 for SU feedback support: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007124 he_cap->su_feedback_tone16);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307125 pe_debug("\tNg=16 for MU feedback support: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007126 he_cap->mu_feedback_tone16);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307127 pe_debug("\tCodebook size for SU: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007128 he_cap->codebook_su);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307129 pe_debug("\tCodebook size for MU: 0x%01x ",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007130 he_cap->codebook_mu);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307131 pe_debug("\tBeamforming trigger w/ Trigger: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007132 he_cap->beamforming_feedback);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307133 pe_debug("\tHE ER SU PPDU payload: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007134 he_cap->he_er_su_ppdu);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307135 pe_debug("\tDL MUMIMO on partial BW: 0x%01x",
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007136 he_cap->dl_mu_mimo_part_bw);
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307137 pe_debug("\tPPET present: 0x%01x", he_cap->ppet_present);
7138 pe_debug("\tSRP based SR-support: 0x%01x", he_cap->srp);
7139 pe_debug("\tPower boost factor: 0x%01x", he_cap->power_boost);
Naveen Rawat4051b022017-09-08 16:17:54 -07007140 pe_debug("\t4x HE LTF support: 0x%01x", he_cap->he_ltf_800_gi_4x);
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -08007141 pe_debug("\tSTBC Tx support (> 80MHz): 0x%01x",
7142 he_cap->tx_stbc_gt_80mhz);
7143 pe_debug("\tSTBC Rx support (> 80MHz): 0x%01x",
7144 he_cap->rx_stbc_gt_80mhz);
Naveen Rawat4051b022017-09-08 16:17:54 -07007145 pe_debug("\tMax Nc: 0x%03x", he_cap->max_nc);
7146 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 -07007147 pe_debug("\tHE ppdu 20 in 40M in 2.4G: 0x%01x",
Naveen Rawatfc530312017-10-23 14:34:12 -07007148 he_cap->he_ppdu_20_in_40Mhz_2G);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007149 pe_debug("\tHE ppdu 20 in 160 and 80p80: 0x%01x",
Naveen Rawatfc530312017-10-23 14:34:12 -07007150 he_cap->he_ppdu_20_in_160_80p80Mhz);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007151 pe_debug("\tHE ppdu 80 in 160 and 80p80: 0x%01x",
Naveen Rawatfc530312017-10-23 14:34:12 -07007152 he_cap->he_ppdu_80_in_160_80p80Mhz);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007153 pe_debug("\tER 1x HE LTF GI support: 0x%01x",
Naveen Rawatfc530312017-10-23 14:34:12 -07007154 he_cap->er_1x_he_ltf_gi);
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007155 pe_debug("\tmidamble txrx 1x he LTF: 0x%01x",
7156 he_cap->midamble_tx_rx_1x_he_ltf);
7157 pe_debug("\tDCM max BW: 0x%02x",
7158 he_cap->dcm_max_bw);
7159 pe_debug("\tlonger_than_16_he_sigb_ofdm_sym: 0x%01x",
7160 he_cap->longer_than_16_he_sigb_ofdm_sym);
7161 pe_debug("\tnon_trig_cqi_feedback: 0x%01x",
7162 he_cap->non_trig_cqi_feedback);
7163 pe_debug("\ttx_1024_qam_lt_242_tone_ru: 0x%01x",
7164 he_cap->tx_1024_qam_lt_242_tone_ru);
7165 pe_debug("\trx_1024_qam_lt_242_tone_ru: 0x%01x",
7166 he_cap->rx_1024_qam_lt_242_tone_ru);
7167 pe_debug("\trx_full_bw_su_he_mu_compress_sigb: 0x%01x",
7168 he_cap->rx_full_bw_su_he_mu_compress_sigb);
7169 pe_debug("\trx_full_bw_su_he_mu_non_cmpr_sigb: 0x%01x",
7170 he_cap->rx_full_bw_su_he_mu_non_cmpr_sigb);
Naveen Rawataeca1b92017-10-16 16:55:31 -07007171 pe_debug("\tRx MCS map for <= 80 Mhz: 0x%04x",
7172 he_cap->rx_he_mcs_map_lt_80);
7173 pe_debug("\tTx MCS map for <= 80 Mhz: 0x%04x",
7174 he_cap->tx_he_mcs_map_lt_80);
7175 pe_debug("\tRx MCS map for <= 160 Mhz: 0x%04x",
7176 *((uint16_t *)he_cap->rx_he_mcs_map_160));
7177 pe_debug("\tTx MCS map for <= 160 Mhz: 0x%04x",
7178 *((uint16_t *)he_cap->tx_he_mcs_map_160));
7179 pe_debug("\tRx MCS map for <= 80+80 Mhz: 0x%04x",
7180 *((uint16_t *)he_cap->rx_he_mcs_map_80_80));
7181 pe_debug("\tTx MCS map for <= 80+80 Mhz: 0x%04x",
7182 *((uint16_t *)he_cap->tx_he_mcs_map_80_80));
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007183
Naveen Rawat819158d2018-01-16 10:56:45 -08007184 hdr = (struct ppet_hdr *)&he_cap->ppet;
7185 pe_debug("\t ppe_th:: nss_count: %d, ru_idx_msk: %d",
7186 hdr->nss, hdr->ru_idx_mask);
Naveen Rawat01213762018-01-04 17:25:31 -08007187
7188 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat819158d2018-01-16 10:56:45 -08007189 &he_cap->ppet, HE_MAX_PPET_SIZE);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007190}
7191
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007192void lim_log_he_op(struct mac_context *mac, tDot11fIEhe_op *he_ops)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007193{
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007194 pe_debug("bss_color: %0x, default_pe_duration: %0x, twt_required: %0x, txop_rts_threshold: %0x, vht_oper_present: %0x",
7195 he_ops->bss_color, he_ops->default_pe,
7196 he_ops->twt_required, he_ops->txop_rts_threshold,
7197 he_ops->vht_oper_present);
7198 pe_debug("\tpart_bss_color %0x, Co-located BSS %0x, BSS color dis %0x",
7199 he_ops->partial_bss_col, he_ops->co_located_bss,
7200 he_ops->bss_col_disabled);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007201
Naveen Rawat436979b2017-11-15 14:53:30 -08007202 pe_debug("he basic mcs nss: 0x%04x",
7203 *((uint16_t *)he_ops->basic_mcs_nss));
7204
Naveen Rawat4051b022017-09-08 16:17:54 -07007205 if (he_ops->vht_oper_present)
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307206 pe_debug("VHT Info not present in HE Operation");
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007207 else
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307208 pe_debug("VHT Info: chan_width: %d, center_freq0: %d, center_freq1: %d",
Naveen Rawat4051b022017-09-08 16:17:54 -07007209 he_ops->vht_oper.info.chan_width,
7210 he_ops->vht_oper.info.center_freq_seg0,
7211 he_ops->vht_oper.info.center_freq_seg1);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007212}
7213
Peng Xu6363ec62017-05-15 11:06:33 -07007214#ifdef WLAN_FEATURE_11AX_BSS_COLOR
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007215void lim_log_he_bss_color(struct mac_context *mac,
Peng Xu6363ec62017-05-15 11:06:33 -07007216 tDot11fIEbss_color_change *he_bss_color)
7217{
7218 pe_debug("countdown: %d, new_color: %d",
7219 he_bss_color->countdown, he_bss_color->new_color);
7220}
7221#endif
7222
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007223void lim_update_sta_he_capable(struct mac_context *mac,
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007224 tpAddStaParams add_sta_params, tpDphHashNode sta_ds,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08007225 struct pe_session *session_entry)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007226{
7227 if (LIM_IS_AP_ROLE(session_entry) || LIM_IS_IBSS_ROLE(session_entry))
7228 add_sta_params->he_capable = sta_ds->mlmStaContext.he_capable;
7229 else
7230 add_sta_params->he_capable = session_entry->he_capable;
7231
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307232 pe_debug("he_capable: %d", add_sta_params->he_capable);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007233}
7234
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007235void lim_update_bss_he_capable(struct mac_context *mac, tpAddBssParams add_bss)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007236{
7237 add_bss->he_capable = true;
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307238 pe_debug("he_capable: %d", add_bss->he_capable);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007239}
7240
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007241void lim_update_stads_he_capable(tpDphHashNode sta_ds, tpSirAssocReq assoc_req)
7242{
7243 sta_ds->mlmStaContext.he_capable = assoc_req->he_cap.present;
7244}
7245
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007246void lim_update_session_he_capable(struct mac_context *mac, struct pe_session *session)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007247{
7248 session->he_capable = true;
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307249 pe_debug("he_capable: %d", session->he_capable);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007250}
7251
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007252void lim_update_chan_he_capable(struct mac_context *mac, tpSwitchChannelParams chan)
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007253{
7254 chan->he_capable = true;
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307255 pe_debug("he_capable: %d", chan->he_capable);
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007256}
7257
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007258void lim_set_he_caps(struct mac_context *mac, struct pe_session *session, uint8_t *ie_start,
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007259 uint32_t num_bytes)
7260{
Naveen Rawat08db88f2017-09-08 15:07:48 -07007261 const uint8_t *ie = NULL;
Naveen Rawatd8feac12017-09-08 15:08:39 -07007262 tDot11fIEhe_cap dot11_cap;
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007263 struct he_capability_info *he_cap;
7264
7265 populate_dot11f_he_caps(mac, session, &dot11_cap);
7266 lim_log_he_cap(mac, &dot11_cap);
Naveen Rawatd8feac12017-09-08 15:08:39 -07007267 ie = wlan_get_ext_ie_ptr_from_ext_id(HE_CAP_OUI_TYPE,
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007268 HE_CAP_OUI_SIZE, ie_start, num_bytes);
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007269 if (ie) {
7270 /* convert from unpacked to packed structure */
7271 he_cap = (struct he_capability_info *) &ie[2 + HE_CAP_OUI_SIZE];
7272
7273 he_cap->htc_he = dot11_cap.htc_he;
7274 he_cap->twt_request = dot11_cap.twt_request;
7275 he_cap->twt_responder = dot11_cap.twt_responder;
7276 he_cap->fragmentation = dot11_cap.fragmentation;
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007277 he_cap->max_num_frag_msdu_amsdu_exp =
7278 dot11_cap.max_num_frag_msdu_amsdu_exp;
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007279 he_cap->min_frag_size = dot11_cap.min_frag_size;
7280 he_cap->trigger_frm_mac_pad = dot11_cap.trigger_frm_mac_pad;
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007281 he_cap->multi_tid_aggr_rx_supp =
7282 dot11_cap.multi_tid_aggr_rx_supp;
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007283 he_cap->he_link_adaptation = dot11_cap.he_link_adaptation;
7284 he_cap->all_ack = dot11_cap.all_ack;
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007285 he_cap->trigd_rsp_sched = dot11_cap.trigd_rsp_sched;
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007286 he_cap->a_bsr = dot11_cap.a_bsr;
7287 he_cap->broadcast_twt = dot11_cap.broadcast_twt;
7288 he_cap->ba_32bit_bitmap = dot11_cap.ba_32bit_bitmap;
7289 he_cap->mu_cascade = dot11_cap.mu_cascade;
7290 he_cap->ack_enabled_multitid = dot11_cap.ack_enabled_multitid;
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007291 he_cap->omi_a_ctrl = dot11_cap.omi_a_ctrl;
7292 he_cap->ofdma_ra = dot11_cap.ofdma_ra;
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007293 he_cap->max_ampdu_len_exp_ext = dot11_cap.max_ampdu_len_exp_ext;
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007294 he_cap->amsdu_frag = dot11_cap.amsdu_frag;
7295 he_cap->flex_twt_sched = dot11_cap.flex_twt_sched;
7296 he_cap->rx_ctrl_frame = dot11_cap.rx_ctrl_frame;
7297
7298 he_cap->bsrp_ampdu_aggr = dot11_cap.bsrp_ampdu_aggr;
7299 he_cap->qtp = dot11_cap.qtp;
7300 he_cap->a_bqr = dot11_cap.a_bqr;
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007301 he_cap->spatial_reuse_param_rspder =
7302 dot11_cap.spatial_reuse_param_rspder;
Naveen Rawat4051b022017-09-08 16:17:54 -07007303 he_cap->ops_supp = dot11_cap.ops_supp;
7304 he_cap->ndp_feedback_supp = dot11_cap.ndp_feedback_supp;
Naveen Rawatfc530312017-10-23 14:34:12 -07007305 he_cap->amsdu_in_ampdu = dot11_cap.amsdu_in_ampdu;
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007306 he_cap->reserved1 = dot11_cap.reserved1;
7307
Naveen Rawataeca1b92017-10-16 16:55:31 -07007308 he_cap->chan_width = HE_CH_WIDTH_COMBINE(dot11_cap.chan_width_0,
7309 dot11_cap.chan_width_1, dot11_cap.chan_width_2,
7310 dot11_cap.chan_width_3, dot11_cap.chan_width_4,
7311 dot11_cap.chan_width_5, dot11_cap.chan_width_6);
7312
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007313 he_cap->rx_pream_puncturing = dot11_cap.rx_pream_puncturing;
7314 he_cap->device_class = dot11_cap.device_class;
7315 he_cap->ldpc_coding = dot11_cap.ldpc_coding;
Naveen Rawat4051b022017-09-08 16:17:54 -07007316 he_cap->he_1x_ltf_800_gi_ppdu = dot11_cap.he_1x_ltf_800_gi_ppdu;
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007317 he_cap->midamble_tx_rx_max_nsts =
7318 dot11_cap.midamble_tx_rx_max_nsts;
Naveen Rawat4051b022017-09-08 16:17:54 -07007319 he_cap->he_4x_ltf_3200_gi_ndp = dot11_cap.he_4x_ltf_3200_gi_ndp;
Kiran Kumar Lokere13dedac2018-02-05 19:51:59 -08007320 he_cap->tx_stbc_lt_80mhz = dot11_cap.tx_stbc_lt_80mhz;
7321 he_cap->rx_stbc_lt_80mhz = dot11_cap.rx_stbc_lt_80mhz;
7322 he_cap->tx_stbc_gt_80mhz = dot11_cap.tx_stbc_gt_80mhz;
7323 he_cap->rx_stbc_gt_80mhz = dot11_cap.rx_stbc_gt_80mhz;
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007324 he_cap->doppler = dot11_cap.doppler;
7325 he_cap->ul_mu = dot11_cap.ul_mu;
7326 he_cap->dcm_enc_tx = dot11_cap.dcm_enc_tx;
7327 he_cap->dcm_enc_rx = dot11_cap.dcm_enc_rx;
7328 he_cap->ul_he_mu = dot11_cap.ul_he_mu;
7329 he_cap->su_beamformer = dot11_cap.su_beamformer;
7330
7331 he_cap->su_beamformee = dot11_cap.su_beamformee;
7332 he_cap->mu_beamformer = dot11_cap.mu_beamformer;
7333 he_cap->bfee_sts_lt_80 = dot11_cap.bfee_sts_lt_80;
Naveen Rawat4051b022017-09-08 16:17:54 -07007334 he_cap->bfee_sts_gt_80 = dot11_cap.bfee_sts_gt_80;
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007335 he_cap->num_sounding_lt_80 = dot11_cap.num_sounding_lt_80;
7336 he_cap->num_sounding_gt_80 = dot11_cap.num_sounding_gt_80;
7337 he_cap->su_feedback_tone16 = dot11_cap.su_feedback_tone16;
7338 he_cap->mu_feedback_tone16 = dot11_cap.mu_feedback_tone16;
7339 he_cap->codebook_su = dot11_cap.codebook_su;
7340 he_cap->codebook_mu = dot11_cap.codebook_mu;
7341 he_cap->beamforming_feedback = dot11_cap.beamforming_feedback;
7342 he_cap->he_er_su_ppdu = dot11_cap.he_er_su_ppdu;
7343 he_cap->dl_mu_mimo_part_bw = dot11_cap.dl_mu_mimo_part_bw;
7344 he_cap->ppet_present = dot11_cap.ppet_present;
7345 he_cap->srp = dot11_cap.srp;
7346 he_cap->power_boost = dot11_cap.power_boost;
7347
Naveen Rawat4051b022017-09-08 16:17:54 -07007348 he_cap->he_ltf_800_gi_4x = dot11_cap.he_ltf_800_gi_4x;
7349 he_cap->max_nc = dot11_cap.max_nc;
7350 he_cap->er_he_ltf_800_gi_4x = dot11_cap.er_he_ltf_800_gi_4x;
Naveen Rawatfc530312017-10-23 14:34:12 -07007351 he_cap->he_ppdu_20_in_40Mhz_2G =
7352 dot11_cap.he_ppdu_20_in_40Mhz_2G;
7353 he_cap->he_ppdu_20_in_160_80p80Mhz =
7354 dot11_cap.he_ppdu_20_in_160_80p80Mhz;
7355 he_cap->he_ppdu_80_in_160_80p80Mhz =
7356 dot11_cap.he_ppdu_80_in_160_80p80Mhz;
7357 he_cap->er_1x_he_ltf_gi =
7358 dot11_cap.er_1x_he_ltf_gi;
Kiran Kumar Lokere1f96b4a2018-08-22 14:47:11 -07007359 he_cap->midamble_tx_rx_1x_he_ltf =
7360 dot11_cap.midamble_tx_rx_1x_he_ltf;
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007361 he_cap->reserved2 = dot11_cap.reserved2;
7362
Naveen Rawataeca1b92017-10-16 16:55:31 -07007363 he_cap->rx_he_mcs_map_lt_80 = dot11_cap.rx_he_mcs_map_lt_80;
7364 he_cap->tx_he_mcs_map_lt_80 = dot11_cap.tx_he_mcs_map_lt_80;
7365 he_cap->rx_he_mcs_map_160 =
7366 *((uint16_t *)dot11_cap.rx_he_mcs_map_160);
7367 he_cap->tx_he_mcs_map_160 =
7368 *((uint16_t *)dot11_cap.tx_he_mcs_map_160);
7369 he_cap->rx_he_mcs_map_80_80 =
7370 *((uint16_t *)dot11_cap.rx_he_mcs_map_80_80);
7371 he_cap->tx_he_mcs_map_80_80 =
7372 *((uint16_t *)dot11_cap.tx_he_mcs_map_80_80);
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007373 }
7374}
7375
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007376QDF_STATUS lim_send_he_caps_ie(struct mac_context *mac_ctx, struct pe_session *session,
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007377 uint8_t vdev_id)
7378{
Naveen Rawataeca1b92017-10-16 16:55:31 -07007379 uint8_t he_caps[SIR_MAC_HE_CAP_MIN_LEN + 3];
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007380 struct he_capability_info *he_cap;
7381 QDF_STATUS status_5g, status_2g;
7382
7383 /* Sending only minimal info(no PPET) to FW now, update if required */
Naveen Rawataeca1b92017-10-16 16:55:31 -07007384 qdf_mem_zero(he_caps, SIR_MAC_HE_CAP_MIN_LEN + 3);
Naveen Rawatd8feac12017-09-08 15:08:39 -07007385 he_caps[0] = DOT11F_EID_HE_CAP;
Naveen Rawataeca1b92017-10-16 16:55:31 -07007386 he_caps[1] = SIR_MAC_HE_CAP_MIN_LEN;
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007387 qdf_mem_copy(&he_caps[2], HE_CAP_OUI_TYPE, HE_CAP_OUI_SIZE);
7388 lim_set_he_caps(mac_ctx, session, he_caps,
Naveen Rawataeca1b92017-10-16 16:55:31 -07007389 SIR_MAC_HE_CAP_MIN_LEN + 3);
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007390 he_cap = (struct he_capability_info *) (&he_caps[2 + HE_CAP_OUI_SIZE]);
7391 he_cap->ppet_present = 0;
7392
Naveen Rawatd8feac12017-09-08 15:08:39 -07007393 status_5g = lim_send_ie(mac_ctx, vdev_id, DOT11F_EID_HE_CAP,
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007394 CDS_BAND_5GHZ, &he_caps[2],
Naveen Rawataeca1b92017-10-16 16:55:31 -07007395 SIR_MAC_HE_CAP_MIN_LEN + 1);
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007396 if (QDF_IS_STATUS_ERROR(status_5g))
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307397 pe_err("Unable send HE Cap IE for 5GHZ band, status: %d",
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007398 status_5g);
7399
Naveen Rawatd8feac12017-09-08 15:08:39 -07007400 status_2g = lim_send_ie(mac_ctx, vdev_id, DOT11F_EID_HE_CAP,
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007401 CDS_BAND_2GHZ, &he_caps[2],
Naveen Rawataeca1b92017-10-16 16:55:31 -07007402 SIR_MAC_HE_CAP_MIN_LEN + 1);
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007403 if (QDF_IS_STATUS_ERROR(status_2g))
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307404 pe_err("Unable send HE Cap IE for 2GHZ band, status: %d",
Krishna Kumaar Natarajan1cd73ae2017-02-22 15:56:00 -08007405 status_2g);
7406
7407 if (QDF_IS_STATUS_SUCCESS(status_2g) &&
7408 QDF_IS_STATUS_SUCCESS(status_5g))
7409 return QDF_STATUS_SUCCESS;
7410
7411 return QDF_STATUS_E_FAILURE;
7412}
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07007413
7414/**
Naveen Rawataeca1b92017-10-16 16:55:31 -07007415 * lim_populate_he_mcs_per_bw() - pouldate HE mcs set per BW (le 80, 160, 80+80)
7416 * @mac_ctx: Global MAC context
7417 * @self_rx: self rx mcs set
7418 * @self_tx: self tx mcs set
7419 * @peer_rx: peer rx mcs set
7420 * @peer_tx: peer tx mcs set
7421 * @nss: nss
7422 * @cfg_rx_param: rx wni param to read
7423 * @cfg_tx_param: tx wni param to read
7424 *
7425 * MCS values are interpreted as in IEEE 11ax-D1.4 spec onwards
7426 * +-----------------------------------------------------+
7427 * | SS8 | SS7 | SS6 | SS5 | SS4 | SS3 | SS2 | SS1 |
7428 * +-----------------------------------------------------+
7429 * | 15-14 | 13-12 | 11-10 | 9-8 | 7-6 | 5-4 | 3-2 | 1-0 |
7430 * +-----------------------------------------------------+
7431 *
7432 * Return: status of operation
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07007433 */
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007434static QDF_STATUS lim_populate_he_mcs_per_bw(struct mac_context *mac_ctx,
Naveen Rawataeca1b92017-10-16 16:55:31 -07007435 uint16_t *self_rx, uint16_t *self_tx,
7436 uint16_t peer_rx, uint16_t peer_tx, uint8_t nss,
Bala Venkatesh6d537092018-09-25 10:38:36 +05307437 uint16_t rx_mcs, uint16_t tx_mcs)
Naveen Rawataeca1b92017-10-16 16:55:31 -07007438{
Naveen Rawataeca1b92017-10-16 16:55:31 -07007439
7440 pe_debug("peer rates: rx_mcs - 0x%04x tx_mcs - 0x%04x",
7441 peer_rx, peer_tx);
Bala Venkatesh6d537092018-09-25 10:38:36 +05307442
7443 *self_rx = rx_mcs;
7444 *self_tx = tx_mcs;
Naveen Rawataeca1b92017-10-16 16:55:31 -07007445
7446 *self_rx = HE_INTERSECT_MCS(*self_rx, peer_tx);
7447 *self_tx = HE_INTERSECT_MCS(*self_tx, peer_rx);
7448
7449 if (nss == NSS_1x1_MODE) {
7450 *self_rx |= HE_MCS_INV_MSK_4_NSS(1);
7451 *self_tx |= HE_MCS_INV_MSK_4_NSS(1);
7452 }
7453 /* if nss is 2, disable higher NSS */
7454 if (nss == NSS_2x2_MODE) {
7455 *self_rx |= (HE_MCS_INV_MSK_4_NSS(1) & HE_MCS_INV_MSK_4_NSS(2));
7456 *self_tx |= (HE_MCS_INV_MSK_4_NSS(1) & HE_MCS_INV_MSK_4_NSS(2));
7457 }
7458
7459 return QDF_STATUS_SUCCESS;
7460}
7461
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007462QDF_STATUS lim_populate_he_mcs_set(struct mac_context *mac_ctx,
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07007463 tpSirSupportedRates rates,
Naveen Rawatd8feac12017-09-08 15:08:39 -07007464 tDot11fIEhe_cap *peer_he_caps,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08007465 struct pe_session *session_entry, uint8_t nss)
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07007466{
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07007467 bool support_2x2 = false;
Naveen Rawataeca1b92017-10-16 16:55:31 -07007468 uint32_t self_sta_dot11mode = 0;
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07007469
7470 wlan_cfg_get_int(mac_ctx, WNI_CFG_DOT11_MODE, &self_sta_dot11mode);
7471
7472 if (!IS_DOT11_MODE_HE(self_sta_dot11mode))
7473 return QDF_STATUS_SUCCESS;
7474
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07007475 if ((peer_he_caps == NULL) || (!peer_he_caps->present)) {
Naveen Rawataeca1b92017-10-16 16:55:31 -07007476 pe_debug("peer not he capable or he_caps NULL");
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07007477 return QDF_STATUS_SUCCESS;
7478 }
7479
Naveen Rawataeca1b92017-10-16 16:55:31 -07007480 pe_debug("peer rates lt 80: rx_mcs - 0x%04x tx_mcs - 0x%04x",
7481 peer_he_caps->rx_he_mcs_map_lt_80,
7482 peer_he_caps->tx_he_mcs_map_lt_80);
7483 pe_debug("peer rates 160: rx_mcs - 0x%04x tx_mcs - 0x%04x",
7484 (*(uint16_t *)peer_he_caps->rx_he_mcs_map_160),
7485 (*(uint16_t *)peer_he_caps->tx_he_mcs_map_160));
7486 pe_debug("peer rates 80+80: rx_mcs - 0x%04x tx_mcs - 0x%04x",
7487 (*(uint16_t *)peer_he_caps->rx_he_mcs_map_80_80),
7488 (*(uint16_t *)peer_he_caps->tx_he_mcs_map_80_80));
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07007489
7490 if (session_entry && session_entry->nss == NSS_2x2_MODE) {
7491 if (mac_ctx->lteCoexAntShare &&
7492 IS_24G_CH(session_entry->currentOperChannel)) {
7493 if (IS_2X2_CHAIN(session_entry->chainMask))
7494 support_2x2 = true;
7495 else
Nishank Aggarwal0402b432017-03-24 19:17:36 +05307496 pe_err("2x2 not enabled %d",
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07007497 session_entry->chainMask);
7498 } else {
7499 support_2x2 = true;
7500 }
7501 }
7502
Naveen Rawataeca1b92017-10-16 16:55:31 -07007503 lim_populate_he_mcs_per_bw(mac_ctx,
7504 &rates->rx_he_mcs_map_lt_80, &rates->tx_he_mcs_map_lt_80,
7505 peer_he_caps->rx_he_mcs_map_lt_80,
7506 peer_he_caps->tx_he_mcs_map_lt_80, nss,
Bala Venkatesh6d537092018-09-25 10:38:36 +05307507 mac_ctx->mlme_cfg->he_caps.dot11_he_cap.rx_he_mcs_map_lt_80,
7508 mac_ctx->mlme_cfg->he_caps.dot11_he_cap.tx_he_mcs_map_lt_80);
Naveen Rawataeca1b92017-10-16 16:55:31 -07007509 lim_populate_he_mcs_per_bw(mac_ctx,
7510 &rates->rx_he_mcs_map_160, &rates->tx_he_mcs_map_160,
7511 *((uint16_t *)peer_he_caps->rx_he_mcs_map_160),
7512 *((uint16_t *)peer_he_caps->tx_he_mcs_map_160), nss,
Bala Venkatesh6d537092018-09-25 10:38:36 +05307513 *((uint16_t *)mac_ctx->mlme_cfg->he_caps.dot11_he_cap.
7514 rx_he_mcs_map_160),
7515 *((uint16_t *)mac_ctx->mlme_cfg->he_caps.dot11_he_cap.
7516 tx_he_mcs_map_160));
Naveen Rawataeca1b92017-10-16 16:55:31 -07007517 lim_populate_he_mcs_per_bw(mac_ctx,
7518 &rates->rx_he_mcs_map_80_80, &rates->tx_he_mcs_map_80_80,
7519 *((uint16_t *)peer_he_caps->rx_he_mcs_map_80_80),
7520 *((uint16_t *)peer_he_caps->tx_he_mcs_map_80_80), nss,
Bala Venkatesh6d537092018-09-25 10:38:36 +05307521 *((uint16_t *)mac_ctx->mlme_cfg->he_caps.dot11_he_cap.
7522 rx_he_mcs_map_80_80),
7523 *((uint16_t *)mac_ctx->mlme_cfg->he_caps.dot11_he_cap.
7524 tx_he_mcs_map_80_80));
Naveen Rawataeca1b92017-10-16 16:55:31 -07007525 if (!support_2x2) {
7526 /* disable 2 and higher NSS MCS sets */
Naveen Rawatcbcc6542017-10-30 17:55:03 -07007527 rates->rx_he_mcs_map_lt_80 |= HE_MCS_INV_MSK_4_NSS(1);
7528 rates->tx_he_mcs_map_lt_80 |= HE_MCS_INV_MSK_4_NSS(1);
7529 rates->rx_he_mcs_map_160 |= HE_MCS_INV_MSK_4_NSS(1);
7530 rates->tx_he_mcs_map_160 |= HE_MCS_INV_MSK_4_NSS(1);
7531 rates->rx_he_mcs_map_80_80 |= HE_MCS_INV_MSK_4_NSS(1);
7532 rates->tx_he_mcs_map_80_80 |= HE_MCS_INV_MSK_4_NSS(1);
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07007533 }
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07007534
Naveen Rawataeca1b92017-10-16 16:55:31 -07007535 pe_debug("enable2x2 - %d nss %d",
Abhinav Kumarb074f2f2018-09-15 15:32:11 +05307536 mac_ctx->mlme_cfg->vht_caps.vht_cap_info.enable2x2, nss);
Naveen Rawataeca1b92017-10-16 16:55:31 -07007537 pe_debug("he_rx_lt_80 - 0x%x he_tx_lt_80 0x%x",
7538 rates->rx_he_mcs_map_lt_80, rates->tx_he_mcs_map_lt_80);
7539 pe_debug("he_rx_160 - 0x%x he_tx_160 0x%x",
7540 rates->rx_he_mcs_map_160, rates->tx_he_mcs_map_160);
7541 pe_debug("he_rx_80_80 - 0x%x he_tx_80_80 0x%x",
7542 rates->rx_he_mcs_map_80_80, rates->tx_he_mcs_map_80_80);
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07007543 return QDF_STATUS_SUCCESS;
Krishna Kumaar Natarajand1cd56e2016-09-30 08:43:03 -07007544}
Krishna Kumaar Natarajan0103ef82017-02-17 18:15:56 -08007545#endif
Sreelakshmi Konamki6d478cd2017-03-28 11:59:25 +05307546
Abhishek Singhf3756fc2017-06-28 16:04:06 +05307547/**
7548 * lim_assoc_rej_get_remaining_delta() - Get remaining time delta for
7549 * the rssi based disallowed list entry
7550 * @node: rssi based disallowed list entry
7551 *
7552 * Return: remaining delta, can be -ve if time has already expired.
7553 */
7554static inline int
7555lim_assoc_rej_get_remaining_delta(struct sir_rssi_disallow_lst *node)
7556{
7557 qdf_time_t cur_time;
7558 uint32_t time_diff;
7559
7560 cur_time = qdf_do_div(qdf_get_monotonic_boottime(),
7561 QDF_MC_TIMER_TO_MS_UNIT);
7562 time_diff = cur_time - node->time_during_rejection;
7563
7564 return node->retry_delay - time_diff;
7565}
7566
7567/**
7568 * lim_assoc_rej_rem_entry_with_lowest_delta() - Remove the entry
7569 * with lowest time delta
7570 * @list: rssi based rejected BSSID list
7571 *
7572 * Return: QDF_STATUS
7573 */
7574static QDF_STATUS
7575lim_assoc_rej_rem_entry_with_lowest_delta(qdf_list_t *list)
7576{
7577 struct sir_rssi_disallow_lst *oldest_node = NULL;
7578 struct sir_rssi_disallow_lst *cur_node;
7579 qdf_list_node_t *cur_list = NULL;
7580 qdf_list_node_t *next_list = NULL;
7581
7582 qdf_list_peek_front(list, &cur_list);
7583 while (cur_list) {
7584 cur_node = qdf_container_of(cur_list,
7585 struct sir_rssi_disallow_lst, node);
7586 if (!oldest_node ||
7587 (lim_assoc_rej_get_remaining_delta(oldest_node) >
7588 lim_assoc_rej_get_remaining_delta(cur_node)))
7589 oldest_node = cur_node;
7590
7591 qdf_list_peek_next(list, cur_list, &next_list);
7592 cur_list = next_list;
7593 next_list = NULL;
7594 }
7595
7596 if (oldest_node) {
7597 pe_debug("remove node %pM with lowest delta %d",
7598 oldest_node->bssid.bytes,
7599 lim_assoc_rej_get_remaining_delta(oldest_node));
7600 qdf_list_remove_node(list, &oldest_node->node);
7601 qdf_mem_free(oldest_node);
7602 return QDF_STATUS_SUCCESS;
7603 }
7604
7605 return QDF_STATUS_E_INVAL;
7606}
7607
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007608void lim_assoc_rej_add_to_rssi_based_reject_list(struct mac_context *mac_ctx,
Abhishek Singhf3756fc2017-06-28 16:04:06 +05307609 tDot11fTLVrssi_assoc_rej *rssi_assoc_rej,
7610 tSirMacAddr bssid, int8_t rssi)
7611{
7612 struct sir_rssi_disallow_lst *entry;
7613 QDF_STATUS status = QDF_STATUS_SUCCESS;
7614
7615 entry = qdf_mem_malloc(sizeof(*entry));
Arif Hussainf5b6c412018-10-10 19:41:09 -07007616 if (!entry)
Abhishek Singhf3756fc2017-06-28 16:04:06 +05307617 return;
Abhishek Singhf3756fc2017-06-28 16:04:06 +05307618
7619 pe_debug("%pM: assoc resp rssi %d, delta rssi %d retry delay %d sec and list size %d",
7620 bssid, rssi, rssi_assoc_rej->delta_rssi,
7621 rssi_assoc_rej->retry_delay,
7622 qdf_list_size(&mac_ctx->roam.rssi_disallow_bssid));
7623
7624 qdf_mem_copy(entry->bssid.bytes,
7625 bssid, QDF_MAC_ADDR_SIZE);
7626 entry->retry_delay = rssi_assoc_rej->retry_delay *
7627 QDF_MC_TIMER_TO_MS_UNIT;
7628 entry->expected_rssi = rssi + rssi_assoc_rej->delta_rssi;
7629 entry->time_during_rejection =
7630 qdf_do_div(qdf_get_monotonic_boottime(),
7631 QDF_MC_TIMER_TO_MS_UNIT);
7632
7633 if (qdf_list_size(&mac_ctx->roam.rssi_disallow_bssid) >=
7634 MAX_RSSI_AVOID_BSSID_LIST) {
7635 status = lim_assoc_rej_rem_entry_with_lowest_delta(
7636 &mac_ctx->roam.rssi_disallow_bssid);
7637 if (QDF_IS_STATUS_ERROR(status))
7638 pe_err("Failed to remove entry with lowest delta");
7639 }
7640
7641 if (QDF_IS_STATUS_SUCCESS(status))
7642 status = qdf_list_insert_back(
7643 &mac_ctx->roam.rssi_disallow_bssid,
7644 &entry->node);
7645
7646 if (QDF_IS_STATUS_ERROR(status)) {
7647 pe_err("Failed to enqueue bssid entry");
7648 qdf_mem_free(entry);
7649 }
7650}
7651
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007652void lim_decrement_pending_mgmt_count(struct mac_context *mac_ctx)
Sreelakshmi Konamki6d478cd2017-03-28 11:59:25 +05307653{
7654 qdf_spin_lock(&mac_ctx->sys.bbt_mgmt_lock);
7655 if (!mac_ctx->sys.sys_bbt_pending_mgmt_count) {
7656 qdf_spin_unlock(&mac_ctx->sys.bbt_mgmt_lock);
Sreelakshmi Konamki6d478cd2017-03-28 11:59:25 +05307657 return;
7658 }
7659 mac_ctx->sys.sys_bbt_pending_mgmt_count--;
7660 qdf_spin_unlock(&mac_ctx->sys.bbt_mgmt_lock);
7661}
Arif Hussain7631afa2017-02-08 14:35:00 -08007662
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007663struct csr_roam_session *lim_get_session_by_macaddr(struct mac_context *mac_ctx,
Arif Hussain7631afa2017-02-08 14:35:00 -08007664 tSirMacAddr self_mac)
7665{
7666 int i = 0;
gaurank kathpalia14e2f912017-08-31 14:51:45 +05307667 struct csr_roam_session *session;
Arif Hussain7631afa2017-02-08 14:35:00 -08007668
7669 if (!mac_ctx || !self_mac) {
7670 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_ERROR,
7671 FL("Invalid arguments"));
7672 return NULL;
7673 }
7674
7675 for (i = 0; i < mac_ctx->sme.max_intf_count; i++) {
7676 session = CSR_GET_SESSION(mac_ctx, i);
7677 if (!session)
7678 continue;
7679 else if (!qdf_mem_cmp(&session->selfMacAddr,
7680 self_mac, sizeof(tSirMacAddr))) {
7681
7682 QDF_TRACE(QDF_MODULE_ID_PE, QDF_TRACE_LEVEL_INFO,
7683 FL("session %d exists with mac address "
7684 MAC_ADDRESS_STR), session->sessionId,
7685 MAC_ADDR_ARRAY(self_mac));
7686
7687 return session;
7688 }
7689 }
7690
7691 return NULL;
7692}
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307693
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007694bool lim_check_if_vendor_oui_match(struct mac_context *mac_ctx,
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307695 uint8_t *oui, uint8_t oui_len,
7696 uint8_t *ie, uint8_t ie_len)
7697{
7698 uint8_t *ptr = ie;
Abhishek Singhe4b6b4e2017-05-05 19:00:17 +05307699 uint8_t elem_id;
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307700
7701 if (NULL == ie || 0 == ie_len) {
7702 pe_err("IE Null or ie len zero %d", ie_len);
7703 return false;
7704 }
7705
Abhishek Singhe4b6b4e2017-05-05 19:00:17 +05307706 elem_id = *ie;
7707
Sridhar Selvaraj0d5d2c72017-08-17 17:30:01 +05307708 if (elem_id == IE_EID_VENDOR &&
7709 !qdf_mem_cmp(&ptr[2], oui, oui_len))
7710 return true;
7711 else
7712 return false;
7713}
Sandeep Puligillad9f88ce2017-04-11 19:41:57 -07007714
7715QDF_STATUS lim_util_get_type_subtype(void *pkt, uint8_t *type,
7716 uint8_t *subtype)
7717{
7718 cds_pkt_t *cds_pkt;
7719 QDF_STATUS status;
7720 tpSirMacMgmtHdr hdr;
7721 uint8_t *rxpktinfor;
7722
7723 cds_pkt = (cds_pkt_t *) pkt;
7724 if (!cds_pkt) {
7725 pe_err("NULL packet received");
7726 return QDF_STATUS_E_FAILURE;
7727 }
7728 status =
7729 wma_ds_peek_rx_packet_info(cds_pkt, (void *)&rxpktinfor, false);
7730 if (!QDF_IS_STATUS_SUCCESS(status)) {
7731 pe_err("Failed extract cds packet. status %d", status);
7732 return QDF_STATUS_E_FAILURE;
7733 }
7734
7735 hdr = WMA_GET_RX_MAC_HEADER(rxpktinfor);
7736 if (hdr->fc.type == SIR_MAC_MGMT_FRAME) {
Arif Hussainda9ba082017-11-02 23:33:54 -07007737 pe_debug("RxBd: %pK mHdr: %pK Type: %d Subtype: %d SizeFC: %zu",
7738 rxpktinfor, hdr, hdr->fc.type, hdr->fc.subType,
7739 sizeof(tSirMacFrameCtl));
Sandeep Puligillad9f88ce2017-04-11 19:41:57 -07007740 *type = hdr->fc.type;
7741 *subtype = hdr->fc.subType;
7742 } else {
Jeff Johnson47d75242018-05-12 15:58:53 -07007743 pe_err("Not a management packet type %d", hdr->fc.type);
Sandeep Puligillad9f88ce2017-04-11 19:41:57 -07007744 return QDF_STATUS_E_INVAL;
7745 }
7746 return QDF_STATUS_SUCCESS;
7747}
Naveen Rawat296a5182017-09-25 14:02:48 -07007748
Jeff Johnsonc8baa902018-11-18 21:59:07 -08007749enum rateid lim_get_min_session_txrate(struct pe_session *session)
Naveen Rawat296a5182017-09-25 14:02:48 -07007750{
7751 enum rateid rid = RATEID_DEFAULT;
7752 uint8_t min_rate = SIR_MAC_RATE_54, curr_rate, i;
7753 tSirMacRateSet *rateset = &session->rateSet;
7754
7755 if (!session)
7756 return rid;
7757
7758 for (i = 0; i < rateset->numRates; i++) {
7759 /* Ignore MSB - set to indicate basic rate */
7760 curr_rate = rateset->rate[i] & 0x7F;
7761 min_rate = (curr_rate < min_rate) ? curr_rate : min_rate;
7762 }
7763 pe_debug("supported min_rate: %0x(%d)", min_rate, min_rate);
7764
7765 switch (min_rate) {
7766 case SIR_MAC_RATE_1:
7767 rid = RATEID_1MBPS;
7768 break;
7769 case SIR_MAC_RATE_2:
7770 rid = RATEID_2MBPS;
7771 break;
7772 case SIR_MAC_RATE_5_5:
7773 rid = RATEID_5_5MBPS;
7774 break;
7775 case SIR_MAC_RATE_11:
7776 rid = RATEID_11MBPS;
7777 break;
7778 case SIR_MAC_RATE_6:
7779 rid = RATEID_6MBPS;
7780 break;
7781 case SIR_MAC_RATE_9:
7782 rid = RATEID_9MBPS;
7783 break;
7784 case SIR_MAC_RATE_12:
7785 rid = RATEID_12MBPS;
7786 break;
7787 case SIR_MAC_RATE_18:
7788 rid = RATEID_18MBPS;
7789 break;
7790 case SIR_MAC_RATE_24:
7791 rid = RATEID_24MBPS;
7792 break;
7793 case SIR_MAC_RATE_36:
7794 rid = RATEID_36MBPS;
7795 break;
7796 case SIR_MAC_RATE_48:
7797 rid = RATEID_48MBPS;
7798 break;
7799 case SIR_MAC_RATE_54:
7800 rid = RATEID_54MBPS;
7801 break;
7802 default:
7803 rid = RATEID_DEFAULT;
7804 break;
7805 }
7806
7807 return rid;
7808}
Abhinav Kumar49d08a72018-02-14 17:36:12 +05307809
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007810void lim_convert_active_channel_to_passive_channel(struct mac_context *mac_ctx)
Abhinav Kumar49d08a72018-02-14 17:36:12 +05307811{
7812 uint64_t current_time;
7813 uint64_t last_time = 0;
7814 uint64_t time_diff;
7815 uint8_t i;
7816
7817 current_time = (uint64_t)qdf_mc_timer_get_system_time();
7818 for (i = 1; i < SIR_MAX_24G_5G_CHANNEL_RANGE; i++) {
7819 if ((mac_ctx->lim.dfschannelList.timeStamp[i]) != 0) {
7820 last_time = mac_ctx->lim.dfschannelList.timeStamp[i];
7821 if (current_time >= last_time) {
7822 time_diff = (current_time - last_time);
7823 } else {
7824 time_diff =
7825 (0xFFFFFFFF - last_time) + current_time;
7826 }
7827
7828 if (time_diff >= MAX_TIME_TO_BE_ACTIVE_CHANNEL) {
7829 lim_covert_channel_scan_type(mac_ctx, i, false);
7830 mac_ctx->lim.dfschannelList.timeStamp[i] = 0;
7831 }
7832 }
7833 }
7834 /*
7835 * last_time is zero if there is no DFS active channels in the list.
7836 * If this is non zero then we have active DFS channels so restart
7837 * the timer.
7838 */
7839 if (last_time != 0) {
7840 if (tx_timer_activate
7841 (&mac_ctx->lim.limTimers.gLimActiveToPassiveChannelTimer)
7842 != TX_SUCCESS) {
7843 pe_err("Active to Passive Channel timer not activated");
7844 }
7845 }
7846 return;
7847}
7848
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007849void lim_send_sme_mgmt_frame_ind(struct mac_context *mac_ctx, uint8_t frame_type,
Abhinav Kumar49d08a72018-02-14 17:36:12 +05307850 uint8_t *frame, uint32_t frame_len,
7851 uint16_t session_id, uint32_t rx_channel,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08007852 struct pe_session *psession_entry, int8_t rx_rssi)
Abhinav Kumar49d08a72018-02-14 17:36:12 +05307853{
7854 tpSirSmeMgmtFrameInd sme_mgmt_frame = NULL;
7855 uint16_t length;
7856
7857 length = sizeof(tSirSmeMgmtFrameInd) + frame_len;
7858
7859 sme_mgmt_frame = qdf_mem_malloc(length);
Arif Hussainf5b6c412018-10-10 19:41:09 -07007860 if (!sme_mgmt_frame)
Abhinav Kumar49d08a72018-02-14 17:36:12 +05307861 return;
Abhinav Kumar49d08a72018-02-14 17:36:12 +05307862
7863 if (qdf_is_macaddr_broadcast(
Varun Reddy Yeturu8e94f722018-05-17 14:57:18 -07007864 (struct qdf_mac_addr *)(frame + 4)) &&
Abhinav Kumar49d08a72018-02-14 17:36:12 +05307865 !session_id) {
7866 pe_debug("Broadcast action frame");
7867 session_id = SME_SESSION_ID_BROADCAST;
7868 }
7869
7870 sme_mgmt_frame->frame_len = frame_len;
7871 sme_mgmt_frame->sessionId = session_id;
7872 sme_mgmt_frame->frameType = frame_type;
7873 sme_mgmt_frame->rxRssi = rx_rssi;
7874 sme_mgmt_frame->rxChan = rx_channel;
7875
7876 qdf_mem_zero(sme_mgmt_frame->frameBuf, frame_len);
7877 qdf_mem_copy(sme_mgmt_frame->frameBuf, frame, frame_len);
7878
7879 if (mac_ctx->mgmt_frame_ind_cb)
7880 mac_ctx->mgmt_frame_ind_cb(sme_mgmt_frame);
7881 else
7882 pe_debug_rl("Management indication callback not registered!!");
7883 qdf_mem_free(sme_mgmt_frame);
7884 return;
7885}
7886
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05307887void
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007888lim_send_dfs_chan_sw_ie_update(struct mac_context *mac_ctx, struct pe_session *session)
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05307889{
7890 /* Update the beacon template and send to FW */
7891 if (sch_set_fixed_beacon_fields(mac_ctx, session) !=
7892 QDF_STATUS_SUCCESS) {
7893 pe_err("Unable to set CSA IE in beacon");
7894 return;
7895 }
7896
7897 /* Send update beacon template message */
Abhishek Singhfc740be2018-10-12 11:34:26 +05307898 lim_send_beacon_ind(mac_ctx, session, REASON_CHANNEL_SWITCH);
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05307899 pe_debug("Updated CSA IE, IE COUNT: %d",
7900 session->gLimChannelSwitch.switchCount);
7901}
7902
7903void lim_process_ap_ecsa_timeout(void *data)
7904{
Jeff Johnsonc8baa902018-11-18 21:59:07 -08007905 struct pe_session *session = (struct pe_session *)data;
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007906 struct mac_context *mac_ctx;
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05307907 uint8_t bcn_int, ch, ch_width;
7908 QDF_STATUS status;
7909
7910 if (!session) {
7911 pe_err("Session is NULL");
7912 return;
7913 }
7914
Abhishek Singhdfa69c32018-08-30 15:39:34 +05307915 mac_ctx = session->mac_ctx;
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05307916
7917 if (!session->dfsIncludeChanSwIe) {
7918 pe_debug("session->dfsIncludeChanSwIe not set");
7919 return;
7920 }
7921
7922 if (session->gLimChannelSwitch.switchCount) {
7923 /* Decrement the beacon switch count */
7924 session->gLimChannelSwitch.switchCount--;
7925 pe_debug("current beacon count %d",
7926 session->gLimChannelSwitch.switchCount);
7927 }
7928
7929 /*
7930 * Send only g_sap_chanswitch_beacon_cnt beacons with CSA IE Set in
7931 * when a radar is detected
7932 */
7933 if (session->gLimChannelSwitch.switchCount > 0) {
7934 /* Send the next beacon with updated CSA IE count */
7935 lim_send_dfs_chan_sw_ie_update(mac_ctx, session);
7936
7937 ch = session->gLimChannelSwitch.primaryChannel;
7938 ch_width = session->gLimChannelSwitch.ch_width;
Arif Hussain224d3812018-11-16 17:58:38 -08007939 if (mac_ctx->mlme_cfg->dfs_cfg.dfs_beacon_tx_enhanced)
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05307940 /* Send Action frame after updating beacon */
7941 lim_send_chan_switch_action_frame(mac_ctx, ch, ch_width,
7942 session);
7943
7944 /* Restart the timer */
7945 if (session->beaconParams.beaconInterval)
7946 bcn_int = session->beaconParams.beaconInterval;
7947 else
Pragaspathi Thilagaraj3cf0f652018-10-29 16:40:35 +05307948 bcn_int = MLME_CFG_BEACON_INTERVAL_DEF;
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05307949
Dustin Brown7dede432018-08-15 17:26:31 -07007950 status = qdf_mc_timer_start(&session->ap_ecsa_timer,
7951 bcn_int);
7952 if (QDF_IS_STATUS_ERROR(status)) {
7953 pe_err("cannot start ap_ecsa_timer");
7954 lim_process_ap_ecsa_timeout(session);
7955 }
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05307956 } else {
7957 tSirSmeCSAIeTxCompleteRsp *chan_switch_tx_rsp;
7958 struct scheduler_msg msg = {0};
7959 uint8_t length = sizeof(*chan_switch_tx_rsp);
7960
7961 /* Done with CSA IE update, send response back to SME */
7962 session->gLimChannelSwitch.switchCount = 0;
7963 if (mac_ctx->sap.SapDfsInfo.disable_dfs_ch_switch == false)
7964 session->gLimChannelSwitch.switchMode = 0;
7965 session->dfsIncludeChanSwIe = false;
7966 session->dfsIncludeChanWrapperIe = false;
7967
7968 chan_switch_tx_rsp = qdf_mem_malloc(length);
Arif Hussainf5b6c412018-10-10 19:41:09 -07007969 if (!chan_switch_tx_rsp)
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05307970 return;
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05307971
7972 chan_switch_tx_rsp->sessionId = session->smeSessionId;
7973 chan_switch_tx_rsp->chanSwIeTxStatus = QDF_STATUS_SUCCESS;
7974
7975 msg.type = eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND;
7976 msg.bodyptr = chan_switch_tx_rsp;
7977
gaurank kathpalia3a7f25b2018-08-28 16:26:39 +05307978 status = scheduler_post_message(QDF_MODULE_ID_PE,
7979 QDF_MODULE_ID_SME,
7980 QDF_MODULE_ID_SME, &msg);
Pragaspathi Thilagaraj934275c2018-08-07 14:55:35 +05307981 if (QDF_IS_STATUS_ERROR(status)) {
7982 sme_err("Failed to post eWNI_SME_DFS_CSAIE_TX_COMPLETE_IND");
7983 qdf_mem_free(chan_switch_tx_rsp);
7984 }
7985 }
7986}
Abhishek Singhdfa69c32018-08-30 15:39:34 +05307987
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05307988#ifdef CONFIG_VDEV_SM
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07007989QDF_STATUS lim_sta_mlme_vdev_start_send(struct vdev_mlme_obj *vdev_mlme,
7990 uint16_t data_len, void *data)
7991{
Jeff Johnsond01da6b2018-12-02 12:10:22 -08007992 struct mac_context *mac_ctx;
Jianmin Zhu09236602018-10-15 15:36:10 +08007993 enum vdev_assoc_type assoc_type;
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07007994
7995 mac_ctx = cds_get_context(QDF_MODULE_ID_PE);
7996 if (!mac_ctx) {
7997 pe_err("mac_ctx is NULL");
7998 if (data)
7999 qdf_mem_free(data);
8000 return QDF_STATUS_E_INVAL;
8001 }
8002
Jianmin Zhu09236602018-10-15 15:36:10 +08008003 assoc_type = mlme_get_assoc_type(vdev_mlme->vdev);
8004 switch (assoc_type) {
8005 case VDEV_ASSOC:
8006 lim_process_mlm_join_req(mac_ctx, (tLimMlmJoinReq *)data);
8007 break;
8008 case VDEV_REASSOC:
8009 lim_process_mlm_reassoc_req(mac_ctx, (tLimMlmReassocReq *)data);
8010 break;
8011 case VDEV_FT_REASSOC:
Abhishek Singh254d5512018-10-30 12:17:05 +05308012 lim_process_mlm_ft_reassoc_req(mac_ctx,
8013 (tLimMlmReassocReq *)data);
Jianmin Zhu09236602018-10-15 15:36:10 +08008014 break;
8015 default:
8016 pe_err("assoc_type %d is invalid", assoc_type);
8017 }
Sandeep Puligilla45e0c5e2018-09-21 00:38:23 -07008018 return QDF_STATUS_SUCCESS;
8019}
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308020
Jianmin Zhu69e7bf32018-11-22 11:56:10 +08008021QDF_STATUS lim_sta_mlme_vdev_restart_send(struct vdev_mlme_obj *vdev_mlme,
8022 uint16_t data_len, void *data)
8023{
8024 if (!vdev_mlme) {
8025 pe_err("vdev_mlme is NULL");
8026 return QDF_STATUS_E_INVAL;
8027 }
8028 if (!data) {
8029 pe_err("event_data is NULL");
8030 return QDF_STATUS_E_INVAL;
8031 }
8032 if (mlme_is_chan_switch_in_progress(vdev_mlme->vdev))
Jeff Johnsond01da6b2018-12-02 12:10:22 -08008033 __lim_process_channel_switch_timeout((struct mac_context *)data);
Jianmin Zhu69e7bf32018-11-22 11:56:10 +08008034
8035 return QDF_STATUS_SUCCESS;
8036}
8037
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07008038QDF_STATUS lim_sta_mlme_vdev_stop_send(struct vdev_mlme_obj *vdev_mlme,
8039 uint16_t data_len, void *data)
8040{
Sandeep Puligilla2a7fa842018-10-02 01:00:56 -07008041 QDF_STATUS status;
8042 bool connection_fail;
8043
Jianmin Zhu69e7bf32018-11-22 11:56:10 +08008044 if (!vdev_mlme) {
8045 pe_err("vdev_mlme is NULL");
8046 return QDF_STATUS_E_INVAL;
8047 }
Sandeep Puligilla2a7fa842018-10-02 01:00:56 -07008048 if (!data) {
8049 pe_err("event_data is NULL");
8050 return QDF_STATUS_E_INVAL;
8051 }
8052
8053 connection_fail = mlme_is_connection_fail(vdev_mlme->vdev);
8054 pe_info("Send vdev stop, connection_fail %d", connection_fail);
8055 if (connection_fail) {
8056 status = lim_sta_send_down_link((join_params *)data);
8057 mlme_set_connection_fail(vdev_mlme->vdev, false);
8058 } else {
Jeff Johnsonc8baa902018-11-18 21:59:07 -08008059 status = lim_sta_send_del_bss((struct pe_session *)data);
Sandeep Puligilla2a7fa842018-10-02 01:00:56 -07008060 }
8061
8062 return status;
Sandeep Puligilla30bb8402018-09-23 22:01:08 -07008063}
8064
Jeff Johnsond01da6b2018-12-02 12:10:22 -08008065void lim_send_beacon(struct mac_context *mac_ctx, struct pe_session *session)
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308066{
8067 if (wlan_vdev_mlme_get_state(session->vdev) ==
8068 WLAN_VDEV_S_DFS_CAC_WAIT)
8069 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
8070 WLAN_VDEV_SM_EV_DFS_CAC_COMPLETED,
8071 sizeof(*session), session);
8072 else
8073 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
8074 WLAN_VDEV_SM_EV_START_SUCCESS,
8075 sizeof(*session), session);
8076}
8077
Jeff Johnsonc8baa902018-11-18 21:59:07 -08008078void lim_ndi_mlme_vdev_up_transition(struct pe_session *session)
Manikandan Mohan4cc1c5a2018-10-09 13:25:30 -07008079{
8080 if (!LIM_IS_NDI_ROLE(session))
8081 return;
8082
8083 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
8084 WLAN_VDEV_SM_EV_START_SUCCESS,
8085 sizeof(*session), session);
8086}
8087
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308088QDF_STATUS lim_ap_mlme_vdev_start_send(struct vdev_mlme_obj *vdev_mlme,
8089 uint16_t data_len, void *data)
8090{
Jeff Johnsonc8baa902018-11-18 21:59:07 -08008091 struct pe_session *session;
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +05308092 tSirResultCodes ret;
8093 tpLimMlmStartReq start_req = (tLimMlmStartReq *)data;
Jeff Johnsond01da6b2018-12-02 12:10:22 -08008094 struct mac_context *mac_ctx;
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308095
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +05308096 if (!data) {
8097 pe_err("data is NULL");
8098 return QDF_STATUS_E_INVAL;
8099 }
8100
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308101 mac_ctx = cds_get_context(QDF_MODULE_ID_PE);
8102 if (!mac_ctx) {
8103 pe_err("mac_ctx is NULL");
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308104 return QDF_STATUS_E_INVAL;
8105 }
8106
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +05308107 session = pe_find_session_by_session_id(mac_ctx,
8108 start_req->sessionId);
8109 if (!session) {
8110 pe_err("session is NULL");
8111 return QDF_STATUS_E_INVAL;
8112 }
8113
8114 if (LIM_IS_IBSS_ROLE(session) &&
8115 session->mac_ctx->lim.gLimIbssCoalescingHappened) {
8116 ibss_bss_add(session->mac_ctx, session);
8117 ret = lim_mlm_add_bss(session->mac_ctx, start_req, session);
8118 if (ret != eSIR_SME_SUCCESS) {
8119 pe_err("AddBss failure");
8120 return QDF_STATUS_E_INVAL;
8121 }
8122 } else {
8123 lim_process_mlm_start_req(session->mac_ctx, start_req);
8124 }
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308125
8126 return QDF_STATUS_SUCCESS;
8127}
8128
Jeff Johnsond01da6b2018-12-02 12:10:22 -08008129static inline void lim_send_csa_restart_resp(struct mac_context *mac_ctx,
Jeff Johnsonc8baa902018-11-18 21:59:07 -08008130 struct pe_session *session)
Abhishek Singh20a8e442018-09-12 15:50:44 +05308131{
8132 struct scheduler_msg msg = {0};
8133 QDF_STATUS status;
8134
8135 msg.type = eWNI_SME_CSA_RESTART_RSP;
8136 msg.bodyptr = NULL;
8137 msg.bodyval = session->smeSessionId;
8138
8139 status = scheduler_post_msg(QDF_MODULE_ID_SME, &msg);
8140 if (QDF_IS_STATUS_ERROR(status))
8141 sme_err("Failed to post eWNI_SME_CSA_RESTART_RSP");
8142}
8143
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308144QDF_STATUS lim_ap_mlme_vdev_update_beacon(struct vdev_mlme_obj *vdev_mlme,
8145 enum beacon_update_op op,
8146 uint16_t data_len, void *data)
8147{
Jeff Johnsonc8baa902018-11-18 21:59:07 -08008148 struct pe_session *session;
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308149
8150 if (!data) {
8151 pe_err("event_data is NULL");
8152 return QDF_STATUS_E_INVAL;
8153 }
Jeff Johnsonc8baa902018-11-18 21:59:07 -08008154 session = (struct pe_session *)data;
Manikandan Mohan4cc1c5a2018-10-09 13:25:30 -07008155 if (LIM_IS_NDI_ROLE(session))
8156 return QDF_STATUS_SUCCESS;
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308157
Abhishek Singh20a8e442018-09-12 15:50:44 +05308158 if (op == BEACON_INIT)
Abhishek Singhfc740be2018-10-12 11:34:26 +05308159 lim_send_beacon_ind(session->mac_ctx, session, REASON_DEFAULT);
Abhishek Singh20a8e442018-09-12 15:50:44 +05308160 else if (op == BEACON_CSA)
8161 lim_send_csa_restart_resp(session->mac_ctx, session);
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308162
8163 return QDF_STATUS_SUCCESS;
8164}
8165
8166QDF_STATUS lim_ap_mlme_vdev_up_send(struct vdev_mlme_obj *vdev_mlme,
8167 uint16_t data_len, void *data)
8168{
8169 struct scheduler_msg msg = {0};
8170 QDF_STATUS status;
Jeff Johnsonc8baa902018-11-18 21:59:07 -08008171 struct pe_session *session = (struct pe_session *)data;
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308172
8173 if (!session) {
8174 pe_err("session is NULL");
8175 return QDF_STATUS_E_INVAL;
8176 }
Manikandan Mohan4cc1c5a2018-10-09 13:25:30 -07008177 if (LIM_IS_NDI_ROLE(session))
8178 return QDF_STATUS_SUCCESS;
8179
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308180
8181 msg.type = SIR_HAL_SEND_AP_VDEV_UP;
8182 msg.bodyval = session->smeSessionId;
8183
8184 status = scheduler_post_msg(QDF_MODULE_ID_WMA, &msg);
8185 if (QDF_IS_STATUS_ERROR(status))
8186 WMA_LOGE("Failed to post SIR_HAL_SEND_AP_VDEV_UP");
8187
8188 return status;
8189}
8190
Abhishek Singhcaa61852018-09-12 15:50:04 +05308191QDF_STATUS lim_ap_mlme_vdev_disconnect_peers(struct vdev_mlme_obj *vdev_mlme,
8192 uint16_t data_len, void *data)
8193{
Jeff Johnsonc8baa902018-11-18 21:59:07 -08008194 struct pe_session *session = (struct pe_session *)data;
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +05308195
8196 if (!data) {
8197 pe_err("data is NULL");
8198 return QDF_STATUS_E_INVAL;
8199 }
8200
8201 if (LIM_IS_IBSS_ROLE(session))
8202 lim_ibss_delete_all_peers(session->mac_ctx, session);
8203 else
8204 lim_delete_all_peers(session);
Abhishek Singhcaa61852018-09-12 15:50:04 +05308205
8206 return QDF_STATUS_SUCCESS;
8207}
8208
8209QDF_STATUS lim_ap_mlme_vdev_stop_send(struct vdev_mlme_obj *vdev_mlme,
8210 uint16_t data_len, void *data)
8211{
Jeff Johnsonc8baa902018-11-18 21:59:07 -08008212 struct pe_session *session = (struct pe_session *)data;
Rajeev Kumar Sirasanagandla2f17f8d2018-10-03 17:24:20 +05308213 QDF_STATUS status = QDF_STATUS_SUCCESS;
8214
8215 if (!data) {
8216 pe_err("data is NULL");
8217 return QDF_STATUS_E_INVAL;
8218 }
8219
8220 if (LIM_IS_IBSS_ROLE(session) &&
8221 session->mac_ctx->lim.gLimIbssCoalescingHappened)
8222 ibss_bss_delete(session->mac_ctx, session);
8223 else
8224 status = lim_send_vdev_stop(session);
8225
8226 return status;
Abhishek Singhcaa61852018-09-12 15:50:04 +05308227}
8228
Abhishek Singh20a8e442018-09-12 15:50:44 +05308229QDF_STATUS lim_ap_mlme_vdev_restart_send(struct vdev_mlme_obj *vdev_mlme,
8230 uint16_t data_len, void *data)
8231{
Jeff Johnsonc8baa902018-11-18 21:59:07 -08008232 struct pe_session *session = (struct pe_session *)data;
Abhishek Singh20a8e442018-09-12 15:50:44 +05308233
8234 if (!data) {
8235 pe_err("data is NULL");
8236 return QDF_STATUS_E_INVAL;
8237 }
8238
Abhishek Singha063f1c2018-09-19 11:37:51 +05308239 if (ap_mlme_is_hidden_ssid_restart_in_progress(vdev_mlme->vdev))
Abhishek Singh6c681f42018-09-12 15:52:36 +05308240 lim_send_vdev_restart(session->mac_ctx, session,
8241 session->smeSessionId);
8242 else
8243 lim_set_channel(session->mac_ctx, session->currentOperChannel,
8244 session->ch_center_freq_seg0,
8245 session->ch_center_freq_seg1,
8246 session->ch_width, session->maxTxPower,
8247 session->peSessionId, session->cac_duration_ms,
8248 session->dfs_regdomain);
Abhishek Singh20a8e442018-09-12 15:50:44 +05308249
8250 return QDF_STATUS_SUCCESS;
8251}
8252
Abhishek Singhc5a54082018-09-12 16:08:03 +05308253QDF_STATUS lim_ap_mlme_vdev_start_req_failed(struct vdev_mlme_obj *vdev_mlme,
8254 uint16_t data_len, void *data)
8255{
Jeff Johnsond01da6b2018-12-02 12:10:22 -08008256 struct mac_context *mac_ctx;
Abhishek Singhc5a54082018-09-12 16:08:03 +05308257
8258 /* store mac ctx in vdev_mlme legacy_vdev_ptr?*/
8259 mac_ctx = cds_get_context(QDF_MODULE_ID_PE);
8260 if (!mac_ctx) {
8261 pe_err("mac_ctx is NULL");
8262 if (data)
8263 qdf_mem_free(data);
8264 return QDF_STATUS_E_INVAL;
8265 }
8266
8267 lim_process_mlm_start_cnf(mac_ctx, data);
8268
8269 return QDF_STATUS_SUCCESS;
8270}
8271
Jeff Johnsond01da6b2018-12-02 12:10:22 -08008272void lim_send_start_bss_confirm(struct mac_context *mac_ctx,
Abhishek Singhc5a54082018-09-12 16:08:03 +05308273 tLimMlmStartCnf *start_cnf)
8274{
8275 if (start_cnf->resultCode == eSIR_SME_SUCCESS) {
8276 lim_post_sme_message(mac_ctx, LIM_MLM_START_CNF,
8277 (uint32_t *)start_cnf);
8278 } else {
Jeff Johnsonc8baa902018-11-18 21:59:07 -08008279 struct pe_session *session;
Abhishek Singhc5a54082018-09-12 16:08:03 +05308280
8281 session = pe_find_session_by_session_id(mac_ctx,
8282 start_cnf->sessionId);
8283 if (!session) {
8284 pe_err("session is NULL");
8285 return;
8286 }
Abhishek Singha063f1c2018-09-19 11:37:51 +05308287 mlme_set_vdev_start_failed(session->vdev, true);
Abhishek Singhc5a54082018-09-12 16:08:03 +05308288 wlan_vdev_mlme_sm_deliver_evt(session->vdev,
8289 WLAN_VDEV_SM_EV_START_REQ_FAIL,
8290 sizeof(*start_cnf), start_cnf);
8291 }
8292}
8293
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308294#else
8295
Jeff Johnsond01da6b2018-12-02 12:10:22 -08008296void lim_send_start_bss_confirm(struct mac_context *mac_ctx,
Abhishek Singhc5a54082018-09-12 16:08:03 +05308297 tLimMlmStartCnf *start_cnf)
8298{
8299 lim_post_sme_message(mac_ctx, LIM_MLM_START_CNF,
8300 (uint32_t *)start_cnf);
8301}
8302
Jeff Johnsond01da6b2018-12-02 12:10:22 -08008303void lim_send_beacon(struct mac_context *mac_ctx, struct pe_session *session)
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308304{
Abhishek Singhfc740be2018-10-12 11:34:26 +05308305 lim_send_beacon_ind(mac_ctx, session, REASON_DEFAULT);
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308306}
Manikandan Mohan4cc1c5a2018-10-09 13:25:30 -07008307
Jeff Johnsonc8baa902018-11-18 21:59:07 -08008308void lim_ndi_mlme_vdev_up_transition(struct pe_session *session)
Manikandan Mohan4cc1c5a2018-10-09 13:25:30 -07008309{
8310}
Abhishek Singh3d30a3b2018-09-12 15:49:18 +05308311#endif