1 /*
2  * Copyright (c) 2011-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-2024 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  *   \file csr_api.h
22  *
23  *   Exports and types for the Common Scan and Roaming Module interfaces.
24  */
25 
26 #ifndef CSRAPI_H__
27 #define CSRAPI_H__
28 
29 #include "sir_api.h"
30 #include "sir_mac_prot_def.h"
31 #include "csr_link_list.h"
32 #include "wlan_scan_public_structs.h"
33 #include "wlan_mlme_public_struct.h"
34 #include "wlan_mlme_main.h"
35 
36 #define CSR_INVALID_SCANRESULT_HANDLE       (NULL)
37 
38 /* Length to print MAC 12 char + 5 ":" + 2 space + mld string */
39 #define MAC_ADDR_DUMP_LEN 26
40 
41 enum csr_akm_type {
42 	/* never used */
43 	eCSR_AUTH_TYPE_NONE,
44 	/* MAC layer authentication types */
45 	eCSR_AUTH_TYPE_OPEN_SYSTEM,
46 	eCSR_AUTH_TYPE_SHARED_KEY,
47 	eCSR_AUTH_TYPE_SAE,
48 	eCSR_AUTH_TYPE_AUTOSWITCH,
49 
50 	/* Upper layer authentication types */
51 	eCSR_AUTH_TYPE_WPA,
52 	eCSR_AUTH_TYPE_WPA_PSK,
53 	eCSR_AUTH_TYPE_WPA_NONE,
54 
55 	eCSR_AUTH_TYPE_RSN,
56 	eCSR_AUTH_TYPE_RSN_PSK,
57 	eCSR_AUTH_TYPE_FT_RSN,
58 	eCSR_AUTH_TYPE_FT_RSN_PSK,
59 #ifdef FEATURE_WLAN_WAPI
60 	eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE,
61 	eCSR_AUTH_TYPE_WAPI_WAI_PSK,
62 #endif /* FEATURE_WLAN_WAPI */
63 	eCSR_AUTH_TYPE_CCKM_WPA,
64 	eCSR_AUTH_TYPE_CCKM_RSN,
65 	eCSR_AUTH_TYPE_RSN_PSK_SHA256,
66 	eCSR_AUTH_TYPE_RSN_8021X_SHA256,
67 	eCSR_AUTH_TYPE_FILS_SHA256,
68 	eCSR_AUTH_TYPE_FILS_SHA384,
69 	eCSR_AUTH_TYPE_FT_FILS_SHA256,
70 	eCSR_AUTH_TYPE_FT_FILS_SHA384,
71 	eCSR_AUTH_TYPE_DPP_RSN,
72 	eCSR_AUTH_TYPE_OWE,
73 	eCSR_AUTH_TYPE_SUITEB_EAP_SHA256,
74 	eCSR_AUTH_TYPE_SUITEB_EAP_SHA384,
75 	eCSR_AUTH_TYPE_OSEN,
76 	eCSR_AUTH_TYPE_FT_SAE,
77 	eCSR_AUTH_TYPE_FT_SUITEB_EAP_SHA384,
78 	eCSR_AUTH_TYPE_SAE_EXT_KEY,
79 	eCSR_AUTH_TYPE_FT_SAE_EXT_KEY,
80 	eCSR_NUM_OF_SUPPORT_AUTH_TYPE,
81 	eCSR_AUTH_TYPE_FAILED = 0xff,
82 	eCSR_AUTH_TYPE_UNKNOWN = eCSR_AUTH_TYPE_FAILED,
83 
84 };
85 
86 typedef enum {
87 	eCSR_ENCRYPT_TYPE_NONE,
88 	eCSR_ENCRYPT_TYPE_WEP40_STATICKEY,
89 	eCSR_ENCRYPT_TYPE_WEP104_STATICKEY,
90 	eCSR_ENCRYPT_TYPE_WEP40,
91 	eCSR_ENCRYPT_TYPE_WEP104,
92 	eCSR_ENCRYPT_TYPE_TKIP,
93 	eCSR_ENCRYPT_TYPE_AES,/* CCMP */
94 #ifdef FEATURE_WLAN_WAPI
95 	/* WAPI */
96 	eCSR_ENCRYPT_TYPE_WPI,
97 #endif  /* FEATURE_WLAN_WAPI */
98 	eCSR_ENCRYPT_TYPE_KRK,
99 	eCSR_ENCRYPT_TYPE_BTK,
100 	eCSR_ENCRYPT_TYPE_AES_CMAC,
101 	eCSR_ENCRYPT_TYPE_AES_GMAC_128,
102 	eCSR_ENCRYPT_TYPE_AES_GMAC_256,
103 	eCSR_ENCRYPT_TYPE_AES_GCMP,
104 	eCSR_ENCRYPT_TYPE_AES_GCMP_256,
105 	eCSR_ENCRYPT_TYPE_ANY,
106 	eCSR_NUM_OF_ENCRYPT_TYPE = eCSR_ENCRYPT_TYPE_ANY,
107 
108 	eCSR_ENCRYPT_TYPE_FAILED = 0xff,
109 	eCSR_ENCRYPT_TYPE_UNKNOWN = eCSR_ENCRYPT_TYPE_FAILED,
110 
111 } eCsrEncryptionType;
112 
113 typedef enum {
114 	/* 11a/b/g only, no HT, no proprietary */
115 	eCSR_DOT11_MODE_abg = 0x0001,
116 	eCSR_DOT11_MODE_11a = 0x0002,
117 	eCSR_DOT11_MODE_11b = 0x0004,
118 	eCSR_DOT11_MODE_11g = 0x0008,
119 	eCSR_DOT11_MODE_11n = 0x0010,
120 	eCSR_DOT11_MODE_11g_ONLY = 0x0020,
121 	eCSR_DOT11_MODE_11n_ONLY = 0x0040,
122 	eCSR_DOT11_MODE_11b_ONLY = 0x0080,
123 	eCSR_DOT11_MODE_11ac = 0x0100,
124 	eCSR_DOT11_MODE_11ac_ONLY = 0x0200,
125 	/*
126 	 * This is for WIFI test. It is same as eWNIAPI_MAC_PROTOCOL_ALL
127 	 * It is for CSR internal use
128 	 */
129 	eCSR_DOT11_MODE_AUTO = 0x0400,
130 	eCSR_DOT11_MODE_11ax = 0x0800,
131 	eCSR_DOT11_MODE_11ax_ONLY = 0x1000,
132 	eCSR_DOT11_MODE_11be = 0x2000,
133 	eCSR_DOT11_MODE_11be_ONLY = 0x4000,
134 
135 	/* specify the number of maximum bits for phyMode */
136 	eCSR_NUM_PHY_MODE = 18,
137 } eCsrPhyMode;
138 
139 #ifdef WLAN_FEATURE_11BE
140 #define CSR_IS_DOT11_PHY_MODE_11BE(dot11mode) \
141 	((dot11mode) == eCSR_DOT11_MODE_11be)
142 #define CSR_IS_DOT11_PHY_MODE_11BE_ONLY(dot11mode) \
143 	((dot11mode) == eCSR_DOT11_MODE_11be_ONLY)
144 #else
145 #define CSR_IS_DOT11_PHY_MODE_11BE(dot11mode) 0
146 #define CSR_IS_DOT11_PHY_MODE_11BE_ONLY(dot11mode) 0
147 #endif
148 
149 /**
150  * enum eCsrRoamBssType - BSS type in CSR operations
151  * @eCSR_BSS_TYPE_INFRASTRUCTURE: Infrastructure station
152  * @eCSR_BSS_TYPE_INFRA_AP: SoftAP
153  * @eCSR_BSS_TYPE_NDI: NAN datapath interface
154  * @eCSR_BSS_TYPE_ANY: any BSS type
155  */
156 typedef enum {
157 	eCSR_BSS_TYPE_INFRASTRUCTURE,
158 	eCSR_BSS_TYPE_INFRA_AP,
159 	eCSR_BSS_TYPE_NDI,
160 	eCSR_BSS_TYPE_ANY,
161 } eCsrRoamBssType;
162 
163 typedef enum {
164 	eCSR_SCAN_SUCCESS,
165 	eCSR_SCAN_FAILURE,
166 	eCSR_SCAN_ABORT,
167 	eCSR_SCAN_FOUND_PEER,
168 } eCsrScanStatus;
169 
170 typedef enum {
171 	eCSR_BW_20MHz_VAL = 20,
172 	eCSR_BW_40MHz_VAL = 40,
173 	eCSR_BW_80MHz_VAL = 80,
174 	eCSR_BW_160MHz_VAL = 160
175 } eCSR_BW_Val;
176 
177 typedef enum {
178 	eCSR_INI_SINGLE_CHANNEL_CENTERED = 0,
179 	eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY = 1,
180 	eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY = 3,
181 	eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED = 4,
182 	eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED = 5,
183 	eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED = 6,
184 	eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW = 7,
185 	eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW = 8,
186 	eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH = 9,
187 	eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH = 10,
188 	eCSR_INI_CHANNEL_BONDING_STATE_MAX = 11
189 } eIniChanBondState;
190 
191 typedef struct tagCsrChannelInfo {
192 	uint8_t numOfChannels;
193 	uint32_t *freq_list;
194 } tCsrChannelInfo, *tpCsrChannelInfo;
195 
196 typedef enum {
197 	eHIDDEN_SSID_NOT_IN_USE,
198 	eHIDDEN_SSID_ZERO_LEN,
199 	eHIDDEN_SSID_ZERO_CONTENTS
200 } tHiddenssId;
201 
202 typedef struct tagCsrSSIDInfo {
203 	tSirMacSSid SSID;
204 	tHiddenssId ssidHidden;
205 } tCsrSSIDInfo;
206 
207 typedef struct tagCsrSSIDs {
208 	uint32_t numOfSSIDs;
209 	tCsrSSIDInfo *SSIDList; /* To be allocated for array of SSIDs */
210 } tCsrSSIDs;
211 
212 typedef struct tagCsrBSSIDs {
213 	uint32_t numOfBSSIDs;
214 	struct qdf_mac_addr *bssid;
215 } tCsrBSSIDs;
216 
217 typedef struct tagCsrScanResultInfo {
218 	/*
219 	 * Carry the IEs for the current BSSDescription.
220 	 * A pointer to tDot11fBeaconIEs. Maybe NULL for start BSS.
221 	 */
222 	void *pvIes;
223 	tAniSSID ssId;
224 	unsigned long timer;           /* timer is variable for hidden SSID timer */
225 	/*
226 	 * This member must be the last in the structure because the
227 	 * end of struct bss_description is an
228 	 * array with nonknown size at this time */
229 	struct bss_description BssDescriptor;
230 } tCsrScanResultInfo;
231 
232 typedef struct tagCsrAuthList {
233 	uint32_t numEntries;
234 	enum csr_akm_type authType[eCSR_NUM_OF_SUPPORT_AUTH_TYPE];
235 } tCsrAuthList, *tpCsrAuthList;
236 
237 typedef struct sCsrChannel_ {
238 	uint8_t numChannels;
239 	uint32_t channel_freq_list[CFG_VALID_CHANNEL_LIST_LEN];
240 } sCsrChannel;
241 
242 typedef struct sCsrChnPower_ {
243 	uint32_t first_chan_freq;
244 	uint8_t numChannels;
245 	uint8_t maxtxPower;
246 } sCsrChnPower;
247 
248 typedef struct tagCsr11dinfo {
249 	sCsrChannel Channels;
250 	/* max power channel list */
251 	sCsrChnPower ChnPower[CFG_VALID_CHANNEL_LIST_LEN];
252 } tCsr11dinfo;
253 
254 typedef enum {
255 	/* CSR is done lostlink roaming and still cannot reconnect */
256 	eCSR_ROAM_LOSTLINK = 12,
257 	/*
258 	 * TKIP MIC error detected, callback gets a pointer
259 	 * to struct mic_failure_ind
260 	 */
261 	eCSR_ROAM_MIC_ERROR_IND = 14,
262 	eCSR_ROAM_SET_KEY_COMPLETE = 17,
263 	/* BSS in SoftAP mode status indication */
264 	eCSR_ROAM_INFRA_IND = 18,
265 	eCSR_ROAM_WPS_PBC_PROBE_REQ_IND = 19,
266 	/* Disaconnect all the clients */
267 	eCSR_ROAM_DISCONNECT_ALL_P2P_CLIENTS = 31,
268 	/* Stopbss triggered from SME due to different */
269 	eCSR_ROAM_SEND_P2P_STOP_BSS = 32,
270 	/* beacon interval */
271 	eCSR_ROAM_UNPROT_MGMT_FRAME_IND = 33,
272 
273 #ifdef FEATURE_WLAN_ESE
274 	eCSR_ROAM_TSM_IE_IND = 34,
275 	eCSR_ROAM_ESE_ADJ_AP_REPORT_IND = 36,
276 	eCSR_ROAM_ESE_BCN_REPORT_IND = 37,
277 #endif /* FEATURE_WLAN_ESE */
278 
279 	/* Radar indication from lower layers */
280 	eCSR_ROAM_DFS_RADAR_IND = 38,
281 	eCSR_ROAM_SET_CHANNEL_RSP = 39,
282 
283 	/* Channel sw update notification */
284 	eCSR_ROAM_DFS_CHAN_SW_NOTIFY = 40,
285 	eCSR_ROAM_EXT_CHG_CHNL_IND = 41,
286 	eCSR_ROAM_STA_CHANNEL_SWITCH = 42,
287 	eCSR_ROAM_NDP_STATUS_UPDATE = 43,
288 	eCSR_ROAM_CHANNEL_COMPLETE_IND = 47,
289 	eCSR_ROAM_CAC_COMPLETE_IND = 48,
290 	eCSR_ROAM_SAE_COMPUTE = 49,
291 	eCSR_ROAM_CHANNEL_INFO_EVENT_IND = 50,
292 } eRoamCmdStatus;
293 
294 /* comment inside indicates what roaming callback gets */
295 typedef enum {
296 	eCSR_ROAM_RESULT_NONE,
297 	eCSR_ROAM_RESULT_SUCCESS = eCSR_ROAM_RESULT_NONE,
298 	/*
299 	 * If roamStatus is eCSR_ROAM_ASSOCIATION_COMPLETION,
300 	 * struct csr_roam_info's bss_desc may pass back
301 	 */
302 	eCSR_ROAM_RESULT_FAILURE,
303 	/* Pass back pointer to struct csr_roam_info */
304 	eCSR_ROAM_RESULT_ASSOCIATED,
305 	eCSR_ROAM_RESULT_NOT_ASSOCIATED,
306 	eCSR_ROAM_RESULT_MIC_FAILURE,
307 	eCSR_ROAM_RESULT_FORCED,
308 	eCSR_ROAM_RESULT_DISASSOC_IND,
309 	eCSR_ROAM_RESULT_DEAUTH_IND,
310 	eCSR_ROAM_RESULT_CAP_CHANGED,
311 	eCSR_ROAM_RESULT_LOSTLINK,
312 	eCSR_ROAM_RESULT_MIC_ERROR_UNICAST,
313 	eCSR_ROAM_RESULT_MIC_ERROR_GROUP,
314 	eCSR_ROAM_RESULT_AUTHENTICATED,
315 	eCSR_ROAM_RESULT_NEW_RSN_BSS,
316 #ifdef FEATURE_WLAN_WAPI
317 	eCSR_ROAM_RESULT_NEW_WAPI_BSS,
318 #endif /* FEATURE_WLAN_WAPI */
319 	/* INFRA started successfully */
320 	eCSR_ROAM_RESULT_INFRA_STARTED,
321 	/* INFRA start failed */
322 	eCSR_ROAM_RESULT_INFRA_START_FAILED,
323 	/* INFRA stopped */
324 	eCSR_ROAM_RESULT_INFRA_STOPPED,
325 	/* A station joining INFRA AP */
326 	eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND,
327 	/* A station joined INFRA AP */
328 	eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF,
329 	/* INFRA disassociated */
330 	eCSR_ROAM_RESULT_INFRA_DISASSOCIATED,
331 	eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND,
332 	eCSR_ROAM_RESULT_SEND_ACTION_FAIL,
333 	/* peer rejected assoc because max assoc limit reached */
334 	eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED,
335 	/* Assoc rejected due to concurrent session running on a diff channel */
336 	eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL,
337 	/* TDLS events */
338 	eCSR_ROAM_RESULT_ADD_TDLS_PEER,
339 	eCSR_ROAM_RESULT_UPDATE_TDLS_PEER,
340 	eCSR_ROAM_RESULT_DELETE_TDLS_PEER,
341 	eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND,
342 	eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND,
343 	eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP,
344 	eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER,
345 	eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN,
346 	eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED,
347 	eCSR_ROAM_RESULT_TDLS_CONNECTION_TRACKER_NOTIFICATION,
348 	eCSR_ROAM_RESULT_DFS_RADAR_FOUND_IND,
349 	eCSR_ROAM_RESULT_CHANNEL_CHANGE_SUCCESS,
350 	eCSR_ROAM_RESULT_CHANNEL_CHANGE_FAILURE,
351 	eCSR_ROAM_RESULT_CSA_RESTART_RSP,
352 	eCSR_ROAM_RESULT_DFS_CHANSW_UPDATE_SUCCESS,
353 	eCSR_ROAM_EXT_CHG_CHNL_UPDATE_IND,
354 
355 	eCSR_ROAM_RESULT_NDI_CREATE_RSP,
356 	eCSR_ROAM_RESULT_NDI_DELETE_RSP,
357 	eCSR_ROAM_RESULT_NDP_INITIATOR_RSP,
358 	eCSR_ROAM_RESULT_NDP_NEW_PEER_IND,
359 	eCSR_ROAM_RESULT_NDP_CONFIRM_IND,
360 	eCSR_ROAM_RESULT_NDP_INDICATION,
361 	eCSR_ROAM_RESULT_NDP_SCHED_UPDATE_RSP,
362 	eCSR_ROAM_RESULT_NDP_RESPONDER_RSP,
363 	eCSR_ROAM_RESULT_NDP_END_RSP,
364 	eCSR_ROAM_RESULT_NDP_PEER_DEPARTED_IND,
365 	eCSR_ROAM_RESULT_NDP_END_IND,
366 	eCSR_ROAM_RESULT_CAC_END_IND,
367 	/* If Scan for SSID failed to found proper BSS */
368 	eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE,
369 	eCSR_ROAM_RESULT_INVOKE_FAILED,
370 } eCsrRoamResult;
371 
372 typedef enum {
373 	/* Not associated in Infra or participating in an Ad-hoc */
374 	eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED,
375 	/* Participating in WDS network in AP/STA mode but not connected yet */
376 	eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED,
377 	/* Participating in a WDS network and connected peer to peer */
378 	eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED,
379 	/* Participating in a Infra network in AP not yet in connected state */
380 	eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED,
381 	/* Participating in a Infra network and connected to a peer */
382 	eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED,
383 	/* NAN Data interface not started */
384 	eCSR_CONNECT_STATE_TYPE_NDI_NOT_STARTED,
385 	/* NAN Data interface started */
386 	eCSR_CONNECT_STATE_TYPE_NDI_STARTED,
387 } eCsrConnectState;
388 
389 typedef enum {
390 	eCSR_OPERATING_CHANNEL_ALL = 0,
391 	eCSR_OPERATING_CHANNEL_AUTO = eCSR_OPERATING_CHANNEL_ALL,
392 	eCSR_OPERATING_CHANNEL_ANY = eCSR_OPERATING_CHANNEL_ALL,
393 } eOperationChannel;
394 
395 typedef enum {
396 	/*
397 	 * Roaming because HDD requested for reassoc by changing one of the
398 	 * fields in tCsrRoamModifyProfileFields. OR Roaming because SME
399 	 * requested for reassoc by changing one of the fields in
400 	 * tCsrRoamModifyProfileFields.
401 	 */
402 	eCsrRoamReasonStaCapabilityChanged,
403 	/*
404 	 * Roaming because SME requested for reassoc to a different AP,
405 	 * as part of inter AP handoff.
406 	 */
407 	eCsrRoamReasonBetterAP,
408 	/*
409 	 * Roaming because SME requested it as the link is lost - placeholder,
410 	 * will clean it up once handoff code gets in
411 	 */
412 	eCsrRoamReasonSmeIssuedForLostLink,
413 
414 } eCsrRoamReasonCodes;
415 
416 /*
417  * Following fields might need modification dynamically once STA is up
418  * & running & this'd trigger reassoc.
419  */
420 typedef struct tagCsrRoamModifyProfileFields {
421 	/*
422 	 * during connect this specifies ACs U-APSD is to be setup
423 	 * for (Bit0:VO; Bit1:VI; Bit2:BK; Bit3:BE all other bits are ignored).
424 	 * During assoc response this COULD carry confirmation of what
425 	 * ACs U-APSD got setup for. Later if an APP looking for APSD,
426 	 * SME-QoS might need to modify this field
427 	 */
428 	uint8_t uapsd_mask;
429 } tCsrRoamModifyProfileFields;
430 
431 struct csr_roam_profile {
432 	tCsrSSIDs SSIDs;
433 	tCsrBSSIDs BSSIDs;
434 	/* this is bit mask of all the needed phy mode defined in eCsrPhyMode */
435 	uint32_t phyMode;
436 	eCsrRoamBssType BSSType;
437 	tCsrChannelInfo ChannelInfo;
438 	uint32_t op_freq;
439 	struct ch_params ch_params;
440 	/* If this is 0, SME will fill in for caller. */
441 	uint16_t beaconInterval;
442 	/*
443 	 * during connect this specifies ACs U-APSD is to be setup
444 	 * for (Bit0:VO; Bit1:VI; Bit2:BK; Bit3:BE all other bits are ignored).
445 	 * During assoc resp this'd carry cnf of what ACs U-APSD got setup for
446 	 */
447 	uint8_t uapsd_mask;
448 	uint32_t nRSNReqIELength; /* The byte count in the pRSNReqIE */
449 	uint8_t *pRSNReqIE;       /* If not null,it's IE byte stream for RSN */
450 	uint8_t privacy;
451 	tAniAuthType csr80211AuthType;
452 	uint32_t dtimPeriod;
453 	bool chan_switch_hostapd_rate_enabled;
454 	uint16_t cfg_protection;
455 	uint8_t wps_state;
456 	enum QDF_OPMODE csrPersona;
457 	/* addIe params */
458 	struct add_ie_params add_ie_params;
459 	uint16_t beacon_tx_rate;
460 	tSirMacRateSet  supported_rates;
461 	tSirMacRateSet  extended_rates;
462 	bool require_h2e;
463 	uint32_t cac_duration_ms;
464 	uint32_t dfs_regdomain;
465 };
466 
467 struct csr_config_params {
468 	/* keep this uint32_t. This gets converted to ePhyChannelBondState */
469 	uint32_t channelBondingMode24GHz;
470 	uint32_t channelBondingMode5GHz;
471 	eCsrPhyMode phyMode;
472 	uint32_t HeartbeatThresh50;
473 	enum wmm_user_mode WMMSupportMode;
474 	bool Is11eSupportEnabled;
475 	bool ProprietaryRatesEnabled;
476 	/* to set MCC Enable/Disable mode */
477 	uint8_t fEnableMCCMode;
478 	bool mcc_rts_cts_prot_enable;
479 	bool mcc_bcast_prob_resp_enable;
480 	/*
481 	 * To allow MCC GO different B.I than STA's.
482 	 * NOTE: make sure if RIVA firmware can handle this combination before
483 	 * enabling this at the moment, this flag is provided only to pass
484 	 * Wi-Fi Cert. 5.1.12
485 	 */
486 	uint8_t fAllowMCCGODiffBI;
487 	tCsr11dinfo Csr11dinfo;
488 	/*
489 	 * Customer wants to optimize the scan time. Avoiding scans(passive)
490 	 * on DFS channels while swipping through both bands can save some time
491 	 * (apprx 1.3 sec)
492 	 */
493 	uint8_t fEnableDFSChnlScan;
494 	bool send_smps_action;
495 
496 #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
497 	uint8_t cc_switch_mode;
498 #endif
499 	bool obssEnabled;
500 	uint8_t conc_custom_rule1;
501 	uint8_t conc_custom_rule2;
502 	uint8_t is_sta_connection_in_5gz_enabled;
503 
504 	uint8_t max_intf_count;
505 	uint32_t f_sta_miracast_mcc_rest_time_val;
506 #ifdef FEATURE_AP_MCC_CH_AVOIDANCE
507 	bool sap_channel_avoidance;
508 #endif /* FEATURE_AP_MCC_CH_AVOIDANCE */
509 	enum force_1x1_type is_force_1x1;
510 	bool wep_tkip_in_he;
511 };
512 
513 #ifdef WLAN_FEATURE_ROAM_OFFLOAD
514 #define DEFAULT_REASSOC_FAILURE_TIMEOUT 1000
515 #endif
516 
517 struct csr_roam_info {
518 	uint32_t nFrameLength;
519 	uint8_t frameType;
520 	/*
521 	 * Point to a buffer contain the beacon, assoc req, assoc rsp frame,
522 	 * in that order user needs to use nBeaconLength, nAssocReqLength,
523 	 * nAssocRspLength to desice where each frame starts and ends.
524 	 */
525 	uint8_t *pbFrames;
526 	bool fReassocReq;       /* set to true if for re-association */
527 	struct qdf_mac_addr bssid;
528 	struct qdf_mac_addr peerMac;
529 	tSirResultCodes status_code;
530 	/* this'd be our own defined or sent from otherBSS(per 802.11spec) */
531 	uint32_t reasonCode;
532 
533 	uint8_t disassoc_reason;
534 
535 	uint8_t staId;         /* Peer stationId when connected */
536 	/* false means auth needed from supplicant. true means authenticated */
537 	bool fAuthRequired;
538 	uint8_t rsnIELen;
539 	uint8_t *prsnIE;
540 	uint8_t wapiIELen;
541 	uint8_t *pwapiIE;
542 	uint8_t addIELen;
543 	uint8_t *paddIE;
544 	union {
545 		tSirMicFailureInfo *pMICFailureInfo;
546 		tSirWPSPBCProbeReq *pWPSPBCProbeReq;
547 	} u;
548 	bool wmmEnabledSta;  /* set to true if WMM enabled STA */
549 #ifdef FEATURE_WLAN_ESE
550 	struct tsm_ie tsm_ie;
551 	uint16_t tsmRoamDelay;
552 	struct ese_bcn_report_rsp *pEseBcnReportRsp;
553 #endif
554 	/* Required for indicating the frames to upper layer */
555 	uint32_t assocReqLength;
556 	uint8_t *assocReqPtr;
557 	tSirChanChangeResponse *channelChangeRespEvent;
558 	/* Timing and fine Timing measurement capability clubbed together */
559 	uint8_t timingMeasCap;
560 	struct oem_channel_info chan_info;
561 	uint32_t target_chan_freq;
562 
563 #ifdef WLAN_FEATURE_NAN
564 	union {
565 		struct ndi_create_rsp ndi_create_params;
566 		struct ndi_delete_rsp ndi_delete_params;
567 	} ndp;
568 #endif
569 	tDot11fIEHTCaps ht_caps;
570 	tDot11fIEVHTCaps vht_caps;
571 	bool he_caps_present;
572 	bool eht_caps_present;
573 	bool ampdu;
574 	bool sgi_enable;
575 	bool tx_stbc;
576 	bool rx_stbc;
577 	tSirMacHTChannelWidth ch_width;
578 	enum sir_sme_phy_mode mode;
579 	uint8_t max_supp_idx;
580 	uint8_t max_ext_idx;
581 	uint8_t max_real_mcs_idx;
582 	uint8_t max_mcs_idx;
583 	uint8_t rx_mcs_map;
584 	uint8_t tx_mcs_map;
585 	/* Extended capabilities of STA */
586 	uint8_t ecsa_capable;
587 	uint32_t ext_cap;
588 	uint8_t supported_band;
589 	int rssi;
590 	int tx_rate;
591 	int rx_rate;
592 	tSirMacCapabilityInfo capability_info;
593 	uint32_t rx_mc_bc_cnt;
594 	uint32_t rx_retry_cnt;
595 #ifdef WLAN_FEATURE_SAE
596 	struct sir_sae_info *sae_info;
597 #endif
598 	struct assoc_ind *owe_pending_assoc_ind;
599 	struct assoc_ind *ft_pending_assoc_ind;
600 
601 	struct qdf_mac_addr peer_mld;
602 #ifdef WLAN_FEATURE_SAP_ACS_OPTIMIZE
603 	uint32_t chan_info_freq;
604 #endif
605 };
606 
607 typedef struct sSirSmeAssocIndToUpperLayerCnf {
608 	uint16_t messageType;   /* eWNI_SME_ASSOC_CNF */
609 	uint16_t length;
610 	uint8_t sessionId;
611 	tSirResultCodes status_code;
612 	tSirMacAddr bssId;      /* Self BSSID */
613 	tSirMacAddr peerMacAddr;
614 	uint16_t aid;
615 	uint8_t wmmEnabledSta;  /* set to true if WMM enabled STA */
616 	tSirRSNie rsnIE;        /* RSN IE received from peer */
617 	tSirWAPIie wapiIE;      /* WAPI IE received from peer */
618 	tSirAddie addIE;        /* this can be WSC and/or P2P IE */
619 	uint8_t reassocReq;     /* set to true if reassoc */
620 	/* Timing and fine Timing measurement capability clubbed together */
621 	uint8_t timingMeasCap;
622 	struct oem_channel_info chan_info;
623 	uint8_t target_channel;
624 	bool ampdu;
625 	bool sgi_enable;
626 	bool tx_stbc;
627 	tSirMacHTChannelWidth ch_width;
628 	enum sir_sme_phy_mode mode;
629 	bool rx_stbc;
630 	uint8_t max_supp_idx;
631 	uint8_t max_ext_idx;
632 	uint8_t max_mcs_idx;
633 	uint8_t max_real_mcs_idx;
634 	uint8_t rx_mcs_map;
635 	uint8_t tx_mcs_map;
636 	/* Extended capabilities of STA */
637 	uint8_t              ecsa_capable;
638 	uint32_t ext_cap;
639 	uint8_t supported_band;
640 
641 	uint32_t ies_len;
642 	uint8_t *ies;
643 	tDot11fIEHTCaps ht_caps;
644 	tDot11fIEVHTCaps vht_caps;
645 	tSirMacCapabilityInfo capability_info;
646 	bool he_caps_present;
647 	bool eht_caps_present;
648 #ifdef WLAN_FEATURE_11BE_MLO
649 	tSirMacAddr peer_mld_addr;
650 #endif
651 } tSirSmeAssocIndToUpperLayerCnf, *tpSirSmeAssocIndToUpperLayerCnf;
652 
653 typedef struct tagCsrSummaryStatsInfo {
654 	uint32_t snr;
655 	int8_t rssi;
656 	uint32_t retry_cnt[4];
657 	uint32_t multiple_retry_cnt[4];
658 	uint32_t tx_frm_cnt[4];
659 	/* uint32_t num_rx_frm_crc_err; same as rx_error_cnt */
660 	/* uint32_t num_rx_frm_crc_ok; same as rx_frm_cnt */
661 	uint32_t rx_frm_cnt;
662 	uint32_t frm_dup_cnt;
663 	uint32_t fail_cnt[4];
664 	uint32_t rts_fail_cnt;
665 	uint32_t ack_fail_cnt;
666 	uint32_t rts_succ_cnt;
667 	uint32_t rx_discard_cnt;
668 	uint32_t rx_error_cnt;
669 	uint32_t tx_byte_cnt;
670 
671 } tCsrSummaryStatsInfo;
672 
673 typedef struct tagCsrGlobalClassAStatsInfo {
674 	uint8_t tx_nss;
675 	uint8_t rx_nss;
676 	uint8_t rx_preamble;
677 	uint8_t rx_bw;
678 	uint32_t max_pwr;
679 	uint32_t tx_rate;
680 	uint32_t rx_rate;
681 	/* mcs index for HT20 and HT40 rates */
682 	uint32_t tx_mcs_index;
683 	uint32_t rx_mcs_index;
684 	enum tx_rate_info tx_mcs_rate_flags;
685 	enum tx_rate_info rx_mcs_rate_flags;
686 	uint8_t  tx_dcm;
687 	uint8_t  rx_dcm;
688 	enum txrate_gi  tx_gi;
689 	enum txrate_gi  rx_gi;
690 	/* to diff between HT20 & HT40 rates;short & long guard interval */
691 	enum tx_rate_info tx_rx_rate_flags;
692 
693 } tCsrGlobalClassAStatsInfo;
694 
695 typedef struct tagCsrGlobalClassDStatsInfo {
696 	uint32_t tx_uc_frm_cnt;
697 	uint32_t tx_mc_frm_cnt;
698 	uint32_t tx_bc_frm_cnt;
699 	uint32_t rx_uc_frm_cnt;
700 	uint32_t rx_mc_frm_cnt;
701 	uint32_t rx_bc_frm_cnt;
702 	uint32_t tx_uc_byte_cnt[4];
703 	uint32_t tx_mc_byte_cnt;
704 	uint32_t tx_bc_byte_cnt;
705 	uint32_t rx_uc_byte_cnt[4];
706 	uint32_t rx_mc_byte_cnt;
707 	uint32_t rx_bc_byte_cnt;
708 	uint32_t rx_byte_cnt;
709 	uint32_t num_rx_bytes_crc_ok;
710 	uint32_t rx_rate;
711 
712 } tCsrGlobalClassDStatsInfo;
713 
714 /**
715  * struct csr_per_chain_rssi_stats_info - stores chain rssi
716  * @rssi: array containing rssi for all chains
717  * @peer_mac_addr: peer mac address
718  */
719 struct csr_per_chain_rssi_stats_info {
720 	int8_t rssi[NUM_CHAINS_MAX];
721 	tSirMacAddr peer_mac_addr;
722 };
723 
724 typedef void *tScanResultHandle;
725 
726 typedef enum {
727 	REASSOC = 0,
728 	FASTREASSOC = 1,
729 	CONNECT_CMD_USERSPACE = 2,
730 } handoff_src;
731 
732 typedef struct tagCsrHandoffRequest {
733 	struct qdf_mac_addr bssid;
734 	uint32_t ch_freq;
735 	uint8_t src;   /* To check if its a REASSOC or a FASTREASSOC IOCTL */
736 } tCsrHandoffRequest;
737 
738 #ifdef FEATURE_WLAN_ESE
739 typedef struct tagCsrEseBeaconReqParams {
740 	uint16_t measurementToken;
741 	uint32_t ch_freq;
742 	uint8_t scanMode;
743 	uint16_t measurementDuration;
744 } tCsrEseBeaconReqParams, *tpCsrEseBeaconReqParams;
745 
746 typedef struct tagCsrEseBeaconReq {
747 	uint8_t numBcnReqIe;
748 	tCsrEseBeaconReqParams bcnReq[SIR_ESE_MAX_MEAS_IE_REQS];
749 } tCsrEseBeaconReq, *tpCsrEseBeaconReq;
750 #endif /* FEATURE_WLAN_ESE */
751 
752 struct csr_del_sta_params {
753 	struct qdf_mac_addr peerMacAddr;
754 	struct qdf_mac_addr peer_mld_addr;
755 	uint16_t reason_code;
756 	uint8_t subtype;
757 };
758 
759 /* Struct bss_dot11_config - Dot11 parameters for
760  * SAP operation
761  * @vdev_id: vdev id
762  * @privacy: privacy config
763  * @phy_mode: phy mode
764  * @bss_op_ch_freq: operational frequency
765  * @dot11_mode: dot11 mode
766  * @nw_type: network type
767  * @p_band: operating band
768  * @opr_rates: operational rates
769  * @ext_rates: extended rates
770  */
771 struct bss_dot11_config {
772 	uint8_t vdev_id;
773 	uint8_t privacy;
774 	eCsrPhyMode phy_mode;
775 	uint32_t bss_op_ch_freq;
776 	uint8_t dot11_mode;
777 	tSirNwType nw_type;
778 	enum reg_wifi_band p_band;
779 	tSirMacRateSet opr_rates;
780 	tSirMacRateSet ext_rates;
781 };
782 
783 typedef QDF_STATUS (*csr_roam_complete_cb)(struct wlan_objmgr_psoc *psoc,
784 					   uint8_t session_id,
785 					   struct csr_roam_info *param,
786 					   eRoamCmdStatus roam_status,
787 					   eCsrRoamResult roam_result);
788 typedef QDF_STATUS (*csr_session_close_cb)(uint8_t session_id);
789 
790 #define CSR_IS_ANY_BSS_TYPE(pProfile) (eCSR_BSS_TYPE_ANY == \
791 				       (pProfile)->BSSType)
792 #define CSR_IS_INFRA_AP(pProfile) (eCSR_BSS_TYPE_INFRA_AP ==  \
793 				   (pProfile)->BSSType)
794 #ifdef WLAN_FEATURE_NAN
795 #define CSR_IS_NDI(profile)  (eCSR_BSS_TYPE_NDI == (profile)->BSSType)
796 #else
797 #define CSR_IS_NDI(profile)  (false)
798 #endif
799 
800 #ifdef WLAN_FEATURE_NAN
801 #define CSR_IS_CONN_NDI(profile)  (eCSR_BSS_TYPE_NDI == (profile)->BSSType)
802 #else
803 #define CSR_IS_CONN_NDI(profile)  (false)
804 #endif
805 
806 QDF_STATUS csr_set_channels(struct mac_context *mac,
807 			    struct csr_config_params *pParam);
808 
809 /* enum to string conversion for debug output */
810 const char *get_e_roam_cmd_status_str(eRoamCmdStatus val);
811 const char *get_e_csr_roam_result_str(eCsrRoamResult val);
812 const char *csr_phy_mode_str(eCsrPhyMode phy_mode);
813 
814 #ifdef FEATURE_WLAN_ESE
815 typedef void (*tCsrTsmStatsCallback)(tAniTrafStrmMetrics tsmMetrics,
816 				     void *pContext);
817 #endif /* FEATURE_WLAN_ESE */
818 typedef void (*tCsrSnrCallback)(int8_t snr, void *pContext);
819 
820 typedef void (*csr_readyToSuspendCallback)(void *pContext, bool suspended);
821 #ifdef WLAN_FEATURE_EXTWOW_SUPPORT
822 typedef void (*csr_readyToExtWoWCallback)(void *pContext, bool status);
823 #endif
824 typedef void (*csr_link_status_callback)(uint8_t status, void *context);
825 
826 typedef void (*sme_get_raom_scan_ch_callback)(
827 				hdd_handle_t hdd_handle,
828 				struct roam_scan_ch_resp *roam_ch,
829 				void *context);
830 
831 #if defined(WLAN_LOGGING_SOCK_SVC_ENABLE) && \
832 	defined(CONNECTIVITY_PKTLOG)
833 /**
834  * csr_packetdump_timer_stop() - stops packet dump timer
835  *
836  * This function is used to stop packet dump timer
837  *
838  * Return: None
839  *
840  */
841 void csr_packetdump_timer_stop(void);
842 
843 /**
844  * csr_packetdump_timer_start() - start packet dump timer
845  *
846  * This function is used to start packet dump timer
847  *
848  * Return: None
849  *
850  */
851 void csr_packetdump_timer_start(void);
852 #else
csr_packetdump_timer_stop(void)853 static inline void csr_packetdump_timer_stop(void) {}
csr_packetdump_timer_start(void)854 static inline void csr_packetdump_timer_start(void) {}
855 #endif
856 
857 /**
858  * csr_update_owe_info() - Update OWE info
859  * @mac: mac context
860  * @assoc_ind: assoc ind
861  *
862  * Return: QDF_STATUS
863  */
864 QDF_STATUS csr_update_owe_info(struct mac_context *mac,
865 			       struct assoc_ind *assoc_ind);
866 
867 /**
868  * csr_update_ft_info() - Update FT info
869  * @mac: mac context
870  * @assoc_ind: assoc ind
871  *
872  * Return: QDF_STATUS
873  */
874 
875 QDF_STATUS csr_update_ft_info(struct mac_context *mac,
876 			      struct assoc_ind *assoc_ind);
877 
878 typedef void (*csr_ani_callback)(int8_t *ani, void *context);
879 
880 /*
881  * csr_convert_to_reg_phy_mode() - CSR API to convert CSR phymode into
882  * regulatory phymode
883  * @csr_phy_mode: csr phymode with type eCsrPhyMode
884  * @freq: current operating frequency
885  *
886  * This API is used to convert a phymode from CSR to a phymode from regulatory
887  *
888  * Return: regulatory phymode that is comparable to input
889  */
890 enum reg_phymode csr_convert_to_reg_phy_mode(eCsrPhyMode csr_phy_mode,
891 				       qdf_freq_t freq);
892 
893 /*
894  * csr_convert_from_reg_phy_mode() - CSR API to convert regulatory phymode into
895  * CSR phymode
896  * @reg_phymode: regulatory phymode
897  *
898  * This API is used to convert a regulatory phymode to a CSR phymode
899  *
900  * Return: eCSR phymode that is comparable to input
901  */
902 eCsrPhyMode csr_convert_from_reg_phy_mode(enum reg_phymode phymode);
903 
904 /*
905  * csr_update_beacon() - CSR API to update beacon template
906  * @mac: mac context
907  *
908  * This API is used to update beacon template to FW
909  *
910  * Return: None
911  */
912 void csr_update_beacon(struct mac_context *mac);
913 
914 /**
915  * csr_fill_enc_type() - converts crypto cipher set to csr specific cipher type
916  * @cipher_type: output csr cipher type
917  * @ cipherset:input cipher set
918  *
919  * Return: None
920  */
921 void csr_fill_enc_type(eCsrEncryptionType *cipher_type, uint32_t cipherset);
922 
923 /**
924  * csr_fill_auth_type() - auth mode set to csr specific auth type
925  * @auth_type: output csr auth type
926  * @ authmodeset: authmode set
927  * @akm: akm
928  * @ucastcipherset: ucastcipherset
929  *
930  * Return: None
931  */
932 void csr_fill_auth_type(enum csr_akm_type *auth_type,
933 			uint32_t authmodeset, uint32_t akm,
934 			uint32_t ucastcipherset);
935 
936 /**
937  * csr_phy_mode_to_dot11mode() - converts phy mode to dot11 mode
938  * @phy_mode: wlan phy mode
939  *
940  * Return: csr_cfgdot11mode
941  */
942 enum csr_cfgdot11mode csr_phy_mode_to_dot11mode(enum wlan_phymode phy_mode);
943 
944 /*
945  * csr_mlme_vdev_disconnect_all_p2p_client_event() - Callback for MLME module
946  *	to send a disconnect all P2P event to the SAP event handler
947  * @vdev_id: vdev id of SAP
948  *
949  * Return: QDF_STATUS
950  */
951 QDF_STATUS csr_mlme_vdev_disconnect_all_p2p_client_event(uint8_t vdev_id);
952 
953 /*
954  * csr_mlme_vdev_stop_bss() - Callback for MLME module to send a stop BSS event
955  *	to the SAP event handler
956  * @vdev_id: vdev id of SAP
957  *
958  * Return: QDF_STATUS
959  */
960 QDF_STATUS csr_mlme_vdev_stop_bss(uint8_t vdev_id);
961 
962 /*
963  * csr_mlme_get_concurrent_operation_freq() - Callback for MLME module to
964  *	get the concurrent operation frequency
965  *
966  * Return: concurrent frequency
967  */
968 qdf_freq_t csr_mlme_get_concurrent_operation_freq(void);
969 
970 /* csr_convert_mode_to_nw_type() - CSR API to convert dot11 mode
971  * to network type.
972  *
973  * @dot11_mode: dot11 mode
974  * @band: reg band
975  *
976  * Return: network type
977  */
978 tSirNwType
979 csr_convert_mode_to_nw_type(enum csr_cfgdot11mode dot11_mode,
980 			    enum reg_wifi_band band);
981 
982 /*
983  * csr_roam_get_phy_mode_band_for_bss() - CSR API to get phy mode and
984  * band for particular dot11 config
985  * @mac : mac context
986  * @dot11_cfg : pointer to the dot11 config
987  *
988  * Return : Void
989  */
990 enum csr_cfgdot11mode
991 csr_roam_get_phy_mode_band_for_bss(struct mac_context *mac,
992 				   struct bss_dot11_config *dot11_cfg);
993 #endif
994