xref: /wlan-driver/qcacld-3.0/core/mac/src/pe/include/lim_global.h (revision 5113495b16420b49004c444715d2daae2066e7dc) !
1 /*
2  * Copyright (c) 2011-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /*
21  *
22  * This file lim_global.h contains the definitions exported by
23  * LIM module.
24  * Author:        Chandra Modumudi
25  * Date:          02/11/02
26  * History:-
27  * Date           Modified by    Modification Information
28  * --------------------------------------------------------------------
29  *
30  */
31 #ifndef __LIM_GLOBAL_H
32 #define __LIM_GLOBAL_H
33 
34 #include "wni_api.h"
35 #include "sir_api.h"
36 #include "sir_mac_prot_def.h"
37 #include "sir_mac_prop_exts.h"
38 #include "sir_common.h"
39 #include "sir_debug.h"
40 #include "wni_cfg.h"
41 #include "csr_api.h"
42 #include "sap_api.h"
43 #include "dot11f.h"
44 #include "wma_if.h"
45 
46 /* Deferred Message Queue Length */
47 #define MAX_DEFERRED_QUEUE_LEN                  80
48 
49 #ifdef CHANNEL_HOPPING_ALL_BANDS
50 #define CHAN_HOP_ALL_BANDS_ENABLE        1
51 #else
52 #define CHAN_HOP_ALL_BANDS_ENABLE        0
53 #endif
54 
55 /* enums exported by LIM are as follows */
56 
57 /*System role definition */
58 typedef enum eLimSystemRole {
59 	eLIM_UNKNOWN_ROLE,
60 	eLIM_AP_ROLE,
61 	eLIM_STA_ROLE,
62 	eLIM_P2P_DEVICE_ROLE,
63 	eLIM_P2P_DEVICE_GO,
64 	eLIM_P2P_DEVICE_CLIENT,
65 	eLIM_NDI_ROLE
66 } tLimSystemRole;
67 
68 /*
69  * SME state definition accessible across all Sirius modules.
70  * AP only states are LIM_SME_CHANNEL_SCAN_STATE &
71  * LIM_SME_NORMAL_CHANNEL_SCAN_STATE.
72  * Note that these states may also be present in STA
73  * side too when DFS support is present for a STA in IBSS mode.
74  */
75 typedef enum eLimSmeStates {
76 	eLIM_SME_OFFLINE_STATE,
77 	eLIM_SME_IDLE_STATE,
78 	eLIM_SME_SUSPEND_STATE,
79 	eLIM_SME_WT_JOIN_STATE,
80 	eLIM_SME_WT_AUTH_STATE,
81 	eLIM_SME_WT_ASSOC_STATE,
82 	eLIM_SME_WT_REASSOC_STATE,
83 	eLIM_SME_JOIN_FAILURE_STATE,
84 	eLIM_SME_ASSOCIATED_STATE,
85 	eLIM_SME_REASSOCIATED_STATE,
86 	eLIM_SME_LINK_EST_STATE,
87 	eLIM_SME_WT_PRE_AUTH_STATE,
88 	eLIM_SME_WT_DISASSOC_STATE,
89 	eLIM_SME_WT_DEAUTH_STATE,
90 	eLIM_SME_WT_START_BSS_STATE,
91 	eLIM_SME_WT_STOP_BSS_STATE,
92 	eLIM_SME_NORMAL_STATE,
93 } tLimSmeStates;
94 
95 /*
96  * MLM state definition.
97  * While these states are present on AP too when it is
98  * STA mode, per-STA MLM state exclusive to AP is:
99  * eLIM_MLM_WT_AUTH_FRAME3.
100  */
101 typedef enum eLimMlmStates {
102 	eLIM_MLM_OFFLINE_STATE,
103 	eLIM_MLM_IDLE_STATE,
104 	eLIM_MLM_WT_JOIN_BEACON_STATE,
105 	eLIM_MLM_JOINED_STATE,
106 	eLIM_MLM_BSS_STARTED_STATE,
107 	eLIM_MLM_WT_AUTH_FRAME2_STATE,
108 	eLIM_MLM_WT_AUTH_FRAME3_STATE,
109 	eLIM_MLM_WT_AUTH_FRAME4_STATE,
110 	eLIM_MLM_AUTH_RSP_TIMEOUT_STATE,
111 	eLIM_MLM_AUTHENTICATED_STATE,
112 	eLIM_MLM_WT_ASSOC_RSP_STATE,
113 	eLIM_MLM_WT_REASSOC_RSP_STATE,
114 	eLIM_MLM_ASSOCIATED_STATE,
115 	eLIM_MLM_REASSOCIATED_STATE,
116 	eLIM_MLM_LINK_ESTABLISHED_STATE,
117 	eLIM_MLM_WT_ASSOC_CNF_STATE,
118 	eLIM_MLM_WT_ADD_BSS_RSP_STATE,
119 	eLIM_MLM_WT_DEL_BSS_RSP_STATE,
120 	eLIM_MLM_WT_ADD_BSS_RSP_ASSOC_STATE,
121 	eLIM_MLM_WT_ADD_BSS_RSP_REASSOC_STATE,
122 	eLIM_MLM_WT_ADD_BSS_RSP_PREASSOC_STATE,
123 	eLIM_MLM_WT_ADD_STA_RSP_STATE,
124 	eLIM_MLM_WT_DEL_STA_RSP_STATE,
125 	/*
126 	 * MLM goes to this state when LIM initiates DELETE_STA
127 	 * as processing of Assoc req because the entry already exists.
128 	 * LIM comes out of this state when DELETE_STA response from
129 	 * HAL is received. LIM needs to maintain this state so that ADD_STA
130 	 * can be issued while processing DELETE_STA response from HAL.
131 	 */
132 	eLIM_MLM_WT_ASSOC_DEL_STA_RSP_STATE,
133 	eLIM_MLM_WT_SET_BSS_KEY_STATE,
134 	eLIM_MLM_WT_SET_STA_KEY_STATE,
135 	eLIM_MLM_WT_SET_STA_BCASTKEY_STATE,
136 	eLIM_MLM_WT_ADD_BSS_RSP_FT_REASSOC_STATE,
137 	eLIM_MLM_WT_FT_REASSOC_RSP_STATE,
138 	eLIM_MLM_WT_SAE_AUTH_STATE,
139 	eLIM_MLM_WT_FT_AUTH_STATE,
140 } tLimMlmStates;
141 
142 /* 11h channel switch states */
143 
144 /*
145  * This enum indicates in which state the channel-swith
146  * is presently operating.
147  * eLIM_11H_CHANSW_INIT - Default state
148  * eLIM_11H_CHANSW_RUNNING - When channel switch is running
149  * eLIM_11H_CHANSW_END - After channel switch is complete
150  */
151 typedef enum eLimDot11hChanSwStates {
152 	eLIM_11H_CHANSW_INIT,
153 	eLIM_11H_CHANSW_RUNNING,
154 	eLIM_11H_CHANSW_END
155 } tLimDot11hChanSwStates;
156 
157 /* MLM Req/Cnf structure definitions */
158 typedef struct sLimMlmAuthReq {
159 	tSirMacAddr peerMacAddr;
160 	tAniAuthType authType;
161 	uint8_t sessionId;
162 } tLimMlmAuthReq, *tpLimMlmAuthReq;
163 
164 typedef struct sLimMlmJoinReq {
165 	uint8_t sessionId;
166 	struct bss_description bssDescription;
167 	/*
168 	 * WARNING: Pls make bssDescription as last variable in struct
169 	 * tLimMlmJoinReq as it has ieFields followed after this bss
170 	 * description. Adding a variable after this corrupts the ieFields
171 	 */
172 } tLimMlmJoinReq, *tpLimMlmJoinReq;
173 
174 /* Forward declarations */
175 struct sSirAssocReq;
176 struct sDphHashNode;
177 
178 /* struct lim_assoc_data - Assoc data to be cached to defer association
179  *			   indication to SME
180  * @present: Indicates whether assoc data is present or not
181  * @sub_type: Indicates whether it is Association Request(=0) or Reassociation
182  *            Request(=1) frame
183  * @sa: Mac address of requesting peer
184  * @assoc_req: pointer to parsed ASSOC/REASSOC Request frame
185  * @pmf_connection: flag indicating pmf connection
186  * @assoc_req_copied: boolean to indicate if assoc req was copied to tmp above
187  * @dup_entry: flag indicating if duplicate entry found
188  * @sta_ds: station dph entry
189  * @partner_peer_idx: peer_idx which is already allocated by partner link
190  */
191 struct lim_assoc_data {
192 	bool present;
193 	uint8_t sub_type;
194 	tSirMacAddr sa;
195 	struct sSirAssocReq *assoc_req;
196 	bool pmf_connection;
197 	bool assoc_req_copied;
198 	bool dup_entry;
199 	struct sDphHashNode *sta_ds;
200 	uint16_t partner_peer_idx;
201 };
202 
203 /* Pre-authentication structure definition */
204 typedef struct tLimPreAuthNode {
205 	struct tLimPreAuthNode *next;
206 	tSirMacAddr peerMacAddr;
207 	tAniAuthType authType;
208 	tLimMlmStates mlmState;
209 	uint8_t authNodeIdx;
210 	uint8_t challengeText[SIR_MAC_AUTH_CHALLENGE_LENGTH];
211 	uint8_t fTimerStarted:1;
212 	uint8_t fSeen:1;
213 	uint8_t fFree:1;
214 	uint8_t rsvd:5;
215 	TX_TIMER timer;
216 	uint16_t seq_num;
217 	unsigned long timestamp;
218 	/* keeping copy of association request received, this is
219 	 * to defer the association request processing
220 	 */
221 	struct lim_assoc_data assoc_req;
222 	bool is_mlo_ie_present;
223 #ifdef WLAN_FEATURE_11BE_MLO
224 	tSirMacAddr peer_mld;
225 #endif
226 } tLimPreAuthNode, *tpLimPreAuthNode;
227 
228 /* Pre-authentication table definition */
229 typedef struct tLimPreAuthTable {
230 	uint32_t numEntry;
231 	tLimPreAuthNode **pTable;
232 } tLimPreAuthTable, *tpLimPreAuthTable;
233 
234 /**
235  * struct lim_sta_context - LIM per STA structure
236  * @mlmState: LIM State
237  * @authType: Authentication algorithm
238  * @akm_type: AKM of the connection
239  * @listenInterval: Listen interval
240  * @capabilityInfo: Capabilities
241  * @disassocReason: Disassociation reason code
242  * @resultCode:     Result code
243  * @subType:        Indicates association or reassociation
244  * @updateContext:  Update context
245  * @schClean:       Scheduler clean
246  * @htCapability:   802.11n HT capability
247  * @vhtCapability:  802.11ac VHT capability
248  * @cleanupTrigger: Cleanup trigger
249  * @protStatusCode: Protocol Status code
250  * @he_capable:     802.11ax HE capability
251  * @owe_ie:         Pointer to OWE IE
252  * @owe_ie_len:     Length of OWE IE
253  * @ft_ie:         Pointer to FT related IE
254  * @ft_ie_len:     Length of FT related IE
255  * @eht_capable:     802.11be EHT capability
256  */
257 struct lim_sta_context {
258 	tLimMlmStates mlmState;
259 	tAniAuthType authType;		/* auth algo in auth frame */
260 	enum ani_akm_type akm_type;	/* akm in rsn/wpa ie */
261 	uint16_t listenInterval;
262 	tSirMacCapabilityInfo capabilityInfo;
263 	enum wlan_reason_code disassocReason;
264 
265 	tSirResultCodes resultCode;
266 
267 	uint8_t subType:1;      /* Indicates ASSOC (0) or REASSOC (1) */
268 	uint8_t updateContext:1;
269 	uint8_t schClean:1;
270 	/* 802.11n HT Capability in Station: Enabled 1 or DIsabled 0 */
271 	uint8_t htCapability:1;
272 	uint8_t vhtCapability:1;
273 	uint16_t cleanupTrigger;
274 	uint16_t protStatusCode;
275 #ifdef WLAN_FEATURE_11AX
276 	bool he_capable;
277 #endif
278 	bool force_1x1;
279 	uint8_t *owe_ie;
280 	uint32_t owe_ie_len;
281 	uint8_t *ft_ie;
282 	uint32_t ft_ie_len;
283 #ifdef WLAN_FEATURE_11BE
284 	bool eht_capable;
285 #endif
286 };
287 
288 /* Structure definition to hold deferred messages queue parameters */
289 typedef struct sLimDeferredMsgQParams {
290 	struct scheduler_msg deferredQueue[MAX_DEFERRED_QUEUE_LEN];
291 	uint16_t size;
292 	uint16_t read;
293 	uint16_t write;
294 } tLimDeferredMsgQParams, *tpLimDeferredMsgQParams;
295 
296 typedef struct sCfgProtection {
297 	uint32_t overlapFromlla:1;
298 	uint32_t overlapFromllb:1;
299 	uint32_t overlapFromllg:1;
300 	uint32_t overlapHt20:1;
301 	uint32_t overlapNonGf:1;
302 	uint32_t overlapLsigTxop:1;
303 	uint32_t overlapRifs:1;
304 	uint32_t overlapOBSS:1; /* added for obss */
305 	uint32_t fromlla:1;
306 	uint32_t fromllb:1;
307 	uint32_t fromllg:1;
308 	uint32_t ht20:1;
309 	uint32_t nonGf:1;
310 	uint32_t lsigTxop:1;
311 	uint32_t rifs:1;
312 	uint32_t obss:1;        /* added for Obss */
313 } tCfgProtection, *tpCfgProtection;
314 
315 typedef enum eLimProtStaCacheType {
316 	eLIM_PROT_STA_CACHE_TYPE_INVALID,
317 	eLIM_PROT_STA_CACHE_TYPE_llB,
318 	eLIM_PROT_STA_CACHE_TYPE_llG,
319 	eLIM_PROT_STA_CACHE_TYPE_HT20
320 } tLimProtStaCacheType;
321 
322 typedef struct sCacheParams {
323 	uint8_t active;
324 	tSirMacAddr addr;
325 	tLimProtStaCacheType protStaCacheType;
326 
327 } tCacheParams, *tpCacheParams;
328 
329 #define LIM_PROT_STA_OVERLAP_CACHE_SIZE    HAL_NUM_ASSOC_STA
330 #define LIM_PROT_STA_CACHE_SIZE            HAL_NUM_ASSOC_STA
331 
332 typedef struct sLimProtStaParams {
333 	uint8_t numSta;
334 	uint8_t protectionEnabled;
335 } tLimProtStaParams, *tpLimProtStaParams;
336 
337 typedef struct sLimNoShortParams {
338 	uint8_t numNonShortPreambleSta;
339 	tCacheParams staNoShortCache[LIM_PROT_STA_CACHE_SIZE];
340 } tLimNoShortParams, *tpLimNoShortParams;
341 
342 typedef struct sLimNoShortSlotParams {
343 	uint8_t numNonShortSlotSta;
344 	tCacheParams staNoShortSlotCache[LIM_PROT_STA_CACHE_SIZE];
345 } tLimNoShortSlotParams, *tpLimNoShortSlotParams;
346 
347 /* Enums used for channel switching. */
348 typedef enum eLimChannelSwitchState {
349 	eLIM_CHANNEL_SWITCH_IDLE,
350 	eLIM_CHANNEL_SWITCH_PRIMARY_ONLY,
351 	eLIM_CHANNEL_SWITCH_PRIMARY_AND_SECONDARY
352 } tLimChannelSwitchState;
353 
354 /* Channel Switch Info */
355 typedef struct sLimChannelSwitchInfo {
356 	tLimChannelSwitchState state;
357 	uint32_t sw_target_freq;
358 	uint8_t primaryChannel;
359 	uint8_t ch_center_freq_seg0;
360 	uint8_t ch_center_freq_seg1;
361 	uint8_t sec_ch_offset;
362 	enum phy_ch_width ch_width;
363 #ifdef WLAN_FEATURE_11BE
364 	uint16_t puncture_bitmap;
365 #endif
366 	int8_t switchCount;
367 	uint32_t switchTimeoutValue;
368 	uint8_t switchMode;
369 } tLimChannelSwitchInfo, *tpLimChannelSwitchInfo;
370 
371 typedef struct sLimOperatingModeInfo {
372 	uint8_t present;
373 	uint8_t chanWidth:4;
374 	uint8_t rxNSS:3;
375 	uint8_t rxNSSType:1;
376 } tLimOperatingModeInfo, *tpLimOperatingModeInfo;
377 
378 typedef struct sLimWiderBWChannelSwitch {
379 	uint8_t newChanWidth;
380 	uint8_t newCenterChanFreq0;
381 	uint8_t newCenterChanFreq1;
382 } tLimWiderBWChannelSwitchInfo, *tpLimWiderBWChannelSwitchInfo;
383 
384 typedef struct sLimTspecInfo {
385 	/* 0==free, else used */
386 	uint8_t inuse;
387 	/* index in list */
388 	uint8_t idx;
389 	tSirMacAddr staAddr;
390 	uint16_t assocId;
391 	struct mac_tspec_ie tspec;
392 	/* number of Tclas elements */
393 	uint8_t numTclas;
394 	tSirTclasInfo tclasInfo[SIR_MAC_TCLASIE_MAXNUM];
395 	uint8_t tclasProc;
396 	/* tclassProc is valid only if this is set to 1. */
397 	uint8_t tclasProcPresent:1;
398 } qdf_packed tLimTspecInfo, *tpLimTspecInfo;
399 
400 typedef struct sLimAdmitPolicyInfo {
401 	/* admit control policy type */
402 	uint8_t type;
403 	/* oversubscription factor : 0 means nothing is allowed */
404 	uint8_t bw_factor;
405 	/* valid only when 'type' is set BW_FACTOR */
406 } tLimAdmitPolicyInfo, *tpLimAdmitPolicyInfo;
407 
408 typedef enum eLimWscEnrollState {
409 	eLIM_WSC_ENROLL_NOOP,
410 	eLIM_WSC_ENROLL_BEGIN,
411 	eLIM_WSC_ENROLL_IN_PROGRESS,
412 	eLIM_WSC_ENROLL_END
413 } tLimWscEnrollState;
414 
415 #define WSC_PASSWD_ID_PUSH_BUTTON         (0x0004)
416 
417 typedef struct sLimWscIeInfo {
418 	bool apSetupLocked;
419 	bool selectedRegistrar;
420 	uint16_t selectedRegistrarConfigMethods;
421 	tLimWscEnrollState wscEnrollmentState;
422 	tLimWscEnrollState probeRespWscEnrollmentState;
423 	uint8_t reqType;
424 	uint8_t respType;
425 } tLimWscIeInfo, *tpLimWscIeInfo;
426 
427 /* maximum number of tspec's supported */
428 #define LIM_NUM_TSPEC_MAX      15
429 
430 /* structure to hold all 11h specific data */
431 typedef struct sLimSpecMgmtInfo {
432 	tLimDot11hChanSwStates dot11hChanSwState;
433 } tLimSpecMgmtInfo, *tpLimSpecMgmtInfo;
434 
435 /**
436  * struct lim_delba_req_info - Delba request struct
437  * @vdev_id: vdev id
438  * @peer_macaddr: peer mac address
439  * @tid: tid
440  * @reason_code: reason code
441  */
442 struct lim_delba_req_info {
443 	uint8_t vdev_id;
444 	tSirMacAddr peer_macaddr;
445 	uint8_t tid;
446 	uint8_t reason_code;
447 };
448 #endif
449