xref: /wlan-driver/qcacld-3.0/core/sap/inc/sap_api.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2012-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-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 #ifndef WLAN_QCT_WLANSAP_H
21 #define WLAN_QCT_WLANSAP_H
22 
23 /*
24  * W L A N   S O F T A P  P A L   L A Y E R
25  * E X T E R N A L  A P I
26  *
27  * DESCRIPTION
28  * This file contains the external API exposed by the wlan SAP PAL layer
29  *  module.
30  */
31 
32 /*----------------------------------------------------------------------------
33  * Include Files
34  * -------------------------------------------------------------------------*/
35 #include "cds_api.h"
36 #include "cds_packet.h"
37 #include "qdf_types.h"
38 
39 #include "sme_api.h"
40 /*----------------------------------------------------------------------------
41  * Preprocessor Definitions and Constants
42  * -------------------------------------------------------------------------*/
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 /*---------------------------------------------------------------------------
48  * defines and enum
49  *--------------------------------------------------------------------------*/
50 #define       MAX_ACL_MAC_ADDRESS          32
51 #define       AUTO_CHANNEL_SELECT          0
52 #define       MAX_ASSOC_IND_IE_LEN         255
53 #define       MAX_ASSOC_REQ_IE_LEN         2000
54 #define       ASSOC_REQ_IE_OFFSET          4
55 
56 /* defines for WPS config states */
57 #define       SAP_WPS_DISABLED             0
58 #define       SAP_WPS_ENABLED_UNCONFIGURED 1
59 #define       SAP_WPS_ENABLED_CONFIGURED   2
60 
61 #define       MAX_CHANNEL_LIST_LEN         256
62 #ifndef QDF_MAX_NO_OF_SAP_MODE
63 #define       QDF_MAX_NO_OF_SAP_MODE       2    /* max # of SAP */
64 #endif
65 #define       SAP_MAX_NUM_SESSION          5
66 #define       SAP_MAX_OBSS_STA_CNT         1    /* max # of OBSS STA */
67 #define       SAP_ACS_WEIGHT_MAX           (26664)
68 /* ACS will mark non ACS channels(filtered by PCL) or channels not in
69  * ACS scan list to SAP_ACS_WEIGHT_MAX.
70  * But the filtered channel still need a reasonable weight to
71  * calculate the combined weight for ACS bw 40/80/160/320.
72  * Assign SAP_ACS_WEIGHT_ADJUSTABLE to such channels and update it
73  * with reasonable weight after all channels weight are computed.
74  */
75 #define       SAP_ACS_WEIGHT_ADJUSTABLE    (SAP_ACS_WEIGHT_MAX - 1)
76 
77 #define SAP_DEFAULT_24GHZ_CHANNEL     (6)
78 #define SAP_DEFAULT_5GHZ_CHANNEL      (40)
79 #define SAP_CHANNEL_NOT_SELECTED (0)
80 
81 #define SAP_PRE_CAC_IFNAME "precac"
82 
83 /*--------------------------------------------------------------------------
84  * reasonCode taken from 802.11 standard.
85  * ------------------------------------------------------------------------*/
86 
87 typedef enum {
88 	eSAP_RC_RESERVED0,              /*0 */
89 	eSAP_RC_UNSPECIFIED,            /*1 */
90 	eSAP_RC_PREV_AUTH_INVALID,      /*2 */
91 	eSAP_RC_STA_LEFT_DEAUTH,        /*3 */
92 	eSAP_RC_INACTIVITY_DISASSOC,    /*4 */
93 	eSAP_RC_AP_CAPACITY_FULL,       /*5 */
94 	eSAP_RC_CLS2_FROM_NON_AUTH_STA, /*6 */
95 	eSAP_RC_CLS3_FROM_NON_AUTH_STA, /*7 */
96 	eSAP_RC_STA_LEFT_DISASSOC,      /*8 */
97 	eSAP_RC_STA_NOT_AUTH,           /*9 */
98 	eSAP_RC_PC_UNACCEPTABLE,        /*10 */
99 	eSAP_RC_SC_UNACCEPTABLE,        /*11 */
100 	eSAP_RC_RESERVED1,              /*12 */
101 	eSAP_RC_INVALID_IE,             /*13 */
102 	eSAP_RC_MIC_FAIL,               /*14 */
103 	eSAP_RC_4_WAY_HANDSHAKE_TO,     /*15 */
104 	eSAP_RC_GO_KEY_HANDSHAKE_TO,    /*16 */
105 	eSAP_RC_IE_MISMATCH,            /*17 */
106 	eSAP_RC_INVALID_GRP_CHIPHER,    /*18 */
107 	eSAP_RC_INVALID_PAIR_CHIPHER,   /*19 */
108 	eSAP_RC_INVALID_AKMP,           /*20 */
109 	eSAP_RC_UNSUPPORTED_RSN,        /*21 */
110 	eSAP_RC_INVALID_RSN,            /*22 */
111 	eSAP_RC_1X_AUTH_FAILED,         /*23 */
112 	eSAP_RC_CHIPER_SUITE_REJECTED,  /*24 */
113 } eSapReasonCode;
114 
115 typedef enum {
116 	eSAP_ACCEPT_UNLESS_DENIED = 0,
117 	eSAP_DENY_UNLESS_ACCEPTED = 1,
118 	/* this type is added to support accept & deny list at the same time */
119 	eSAP_SUPPORT_ACCEPT_AND_DENY = 2,
120 	/*In this mode all MAC addresses are allowed to connect */
121 	eSAP_ALLOW_ALL = 3,
122 } eSapMacAddrACL;
123 
124 typedef enum {
125 	SAP_DENY_LIST = 0,   /* List of mac addresses NOT allowed to assoc */
126 	SAP_ALLOW_LIST = 1,   /* List of mac addresses allowed to assoc */
127 } eSapACLType;
128 
129 typedef enum {
130 	ADD_STA_TO_ACL = 0,       /* cmd to add STA to access control list */
131 	DELETE_STA_FROM_ACL = 1,  /* cmd to del STA from access control list */
132 	/* only add STA to ACL, do not trigger deauth */
133 	ADD_STA_TO_ACL_NO_DEAUTH = 2,
134 	/* only delete STA from ACL, do not trigger deauth */
135 	DELETE_STA_FROM_ACL_NO_DEAUTH = 3,
136 } eSapACLCmdType;
137 
138 typedef enum {
139 	eSAP_START_BSS_EVENT = 0,     /* Event sent when BSS is started */
140 	eSAP_STOP_BSS_EVENT,          /* Event sent when BSS is stopped */
141 	eSAP_STA_ASSOC_IND,           /* Indicate assoc req to upper layers */
142 	/*
143 	 * Event sent when we have successfully associated a station and
144 	 * upper layer needs to allocate a context
145 	 */
146 	eSAP_STA_ASSOC_EVENT,
147 	/*
148 	 * Event sent when we have successfully reassociated a station and
149 	 * upper layer needs to allocate a context
150 	 */
151 	eSAP_STA_REASSOC_EVENT,
152 	/*
153 	 * Event sent when associated a station has disassociated as a
154 	 * result of various conditions
155 	 */
156 	eSAP_STA_DISASSOC_EVENT,
157 	/* Event sent when user called wlansap_set_key_sta */
158 	eSAP_STA_SET_KEY_EVENT,
159 	/* Event sent whenever there is MIC failure detected */
160 	eSAP_STA_MIC_FAILURE_EVENT,
161 	/* Event send on WPS PBC probe request is received */
162 	eSAP_WPS_PBC_PROBE_REQ_EVENT,
163 	eSAP_DISCONNECT_ALL_P2P_CLIENT,
164 	eSAP_MAC_TRIG_STOP_BSS_EVENT,
165 	/*
166 	 * Event send when a STA in neither allow list or deny list tries to
167 	 * associate in softap mode
168 	 */
169 	eSAP_UNKNOWN_STA_JOIN,
170 	/* Event send when a new STA is rejected association since softAP
171 	 * max assoc limit has reached
172 	 */
173 	eSAP_MAX_ASSOC_EXCEEDED,
174 	eSAP_CHANNEL_CHANGE_EVENT,
175 	eSAP_DFS_CAC_START,
176 	eSAP_DFS_CAC_INTERRUPTED,
177 	eSAP_DFS_CAC_END,
178 	eSAP_DFS_RADAR_DETECT,
179 	/* No ch available after DFS RADAR detect */
180 	eSAP_DFS_NO_AVAILABLE_CHANNEL,
181 	eSAP_STOP_BSS_DUE_TO_NO_CHNL,
182 	eSAP_ACS_SCAN_SUCCESS_EVENT,
183 	eSAP_ACS_CHANNEL_SELECTED,
184 	eSAP_ECSA_CHANGE_CHAN_IND,
185 	eSAP_DFS_NEXT_CHANNEL_REQ,
186 	/* Event sent channel switch status to upper layer */
187 	eSAP_CHANNEL_CHANGE_RESP,
188 } eSapHddEvent;
189 
190 typedef enum {
191 	eSAP_OPEN_SYSTEM,
192 	eSAP_SHARED_KEY,
193 	eSAP_AUTO_SWITCH
194 } eSapAuthType;
195 
196 typedef enum {
197 	/* Disassociation was internally initiated from CORE stack */
198 	eSAP_MAC_INITATED_DISASSOC = 0x10000,
199 	/*
200 	 * Disassociation was internally initiated from host by
201 	 * invoking wlansap_disassoc_sta call
202 	 */
203 	eSAP_USR_INITATED_DISASSOC
204 } eSapDisassocReason;
205 
206 typedef enum {
207 	eSAP_DFS_NOL_CLEAR,
208 	eSAP_DFS_NOL_RANDOMIZE,
209 } eSapDfsNolType;
210 
211 /*---------------------------------------------------------------------------
212   SAP PAL "status" and "reason" error code defines
213   ---------------------------------------------------------------------------*/
214 typedef enum {
215 	eSAP_STATUS_SUCCESS,            /* Success.  */
216 	eSAP_STATUS_FAILURE,            /* General Failure.  */
217 	/* Channel not selected during initial scan.  */
218 	eSAP_START_BSS_CHANNEL_NOT_SELECTED,
219 	eSAP_ERROR_MAC_START_FAIL,     /* Failed to start Infra BSS */
220 } eSapStatus;
221 
222 /*---------------------------------------------------------------------------
223   SAP PAL "status" and "reason" error code defines
224   ---------------------------------------------------------------------------*/
225 typedef enum {
226 	eSAP_WPSPBC_OVERLAP_IN120S,  /* Overlap */
227 	/* no WPS probe request in 120 second */
228 	eSAP_WPSPBC_NO_WPSPBC_PROBE_REQ_IN120S,
229 	/* One WPS probe request in 120 second  */
230 	eSAP_WPSPBC_ONE_WPSPBC_PROBE_REQ_IN120S,
231 } eWPSPBCOverlap;
232 
233 /*---------------------------------------------------------------------------
234   SAP Associated station types
235   ---------------------------------------------------------------------------*/
236 typedef enum {
237 	eSTA_TYPE_NONE    = 0x00000000,  /* No station type */
238 	eSTA_TYPE_INFRA   = 0x00000001,  /* legacy station */
239 	eSTA_TYPE_P2P_CLI = 0x00000002,  /* p2p client */
240 } eStationType;
241 
242 /*----------------------------------------------------------------------------
243  *  Typedefs
244  * -------------------------------------------------------------------------*/
245 typedef struct sap_StartBssCompleteEvent_s {
246 	uint8_t status;
247 	uint32_t operating_chan_freq;
248 	enum phy_ch_width ch_width;
249 	uint16_t staId;         /* self StaID */
250 	uint8_t sessionId;      /* SoftAP SME session ID */
251 } tSap_StartBssCompleteEvent;
252 
253 typedef struct sap_StopBssCompleteEvent_s {
254 	uint8_t status;
255 } tSap_StopBssCompleteEvent;
256 
257 typedef struct sap_StationAssocIndication_s {
258 	struct qdf_mac_addr staMac;
259 	uint8_t staId;
260 	uint8_t status;
261 	/* Required for indicating the frames to upper layer */
262 	uint32_t assocReqLength;
263 	uint8_t *assocReqPtr;
264 	bool fWmmEnabled;
265 	uint8_t ecsa_capable;
266 	uint32_t owe_ie_len;
267 	uint8_t *owe_ie;
268 } tSap_StationAssocIndication;
269 
270 typedef struct sap_StationAssocReassocCompleteEvent_s {
271 	struct qdf_mac_addr staMac;
272 	eStationType staType;
273 	uint8_t staId;
274 	uint8_t status;
275 	uint8_t *ies;
276 	uint32_t ies_len;
277 	uint32_t status_code;
278 	bool wmmEnabled;
279 	uint8_t timingMeasCap;
280 	struct oem_channel_info chan_info;
281 	bool ampdu;
282 	bool sgi_enable;
283 	bool tx_stbc;
284 	bool rx_stbc;
285 	tSirMacHTChannelWidth ch_width;
286 	enum sir_sme_phy_mode mode;
287 	uint8_t max_supp_idx;
288 	uint8_t max_ext_idx;
289 	uint8_t max_mcs_idx;
290 	uint8_t max_real_mcs_idx;
291 	uint8_t rx_mcs_map;
292 	uint8_t tx_mcs_map;
293 	uint8_t ecsa_capable;
294 	uint32_t ext_cap;
295 	uint8_t supported_band;
296 	tDot11fIEHTCaps ht_caps;
297 	tDot11fIEVHTCaps vht_caps;
298 	bool eht_caps_present;
299 	tSirMacCapabilityInfo capability_info;
300 	bool he_caps_present;
301 	struct qdf_mac_addr sta_mld;
302 } tSap_StationAssocReassocCompleteEvent;
303 
304 typedef struct sap_StationDisassocCompleteEvent_s {
305 	struct qdf_mac_addr staMac;
306 	uint8_t staId;          /* STAID should not be used */
307 	uint8_t status;
308 	uint32_t status_code;
309 	uint32_t reason_code;
310 	eSapDisassocReason reason;
311 	int rssi;
312 	int tx_rate;
313 	int rx_rate;
314 	uint32_t rx_mc_bc_cnt;
315 	uint32_t rx_retry_cnt;
316 } tSap_StationDisassocCompleteEvent;
317 
318 typedef struct sap_StationSetKeyCompleteEvent_s {
319 	uint8_t status;
320 	struct qdf_mac_addr peerMacAddr;
321 } tSap_StationSetKeyCompleteEvent;
322 
323 /*struct corresponding to SAP_STA_MIC_FAILURE_EVENT */
324 typedef struct sap_StationMICFailureEvent_s {
325 	struct qdf_mac_addr srcMacAddr;    /* address used to compute MIC */
326 	struct qdf_mac_addr staMac;        /* taMacAddr transmitter address */
327 	struct qdf_mac_addr dstMacAddr;
328 	bool multicast;
329 	uint8_t IV1;            /* first byte of IV */
330 	uint8_t keyId;          /* second byte of IV */
331 	uint8_t TSC[SIR_CIPHER_SEQ_CTR_SIZE];           /* sequence number */
332 
333 } tSap_StationMICFailureEvent;
334 
335 typedef struct sap_WPSPBCProbeReqEvent_s {
336 	uint8_t status;
337 	/* module id that was passed in wlansap_get_assoc_stations API */
338 	QDF_MODULE_ID module;
339 	tSirWPSPBCProbeReq WPSPBCProbeReq;
340 } tSap_WPSPBCProbeReqEvent;
341 
342 typedef struct sap_SendActionCnf_s {
343 	eSapStatus actionSendSuccess;
344 } tSap_SendActionCnf;
345 
346 typedef struct sap_UnknownSTAJoinEvent_s {
347 	struct qdf_mac_addr macaddr;
348 } tSap_UnknownSTAJoinEvent;
349 
350 typedef struct sap_MaxAssocExceededEvent_s {
351 	struct qdf_mac_addr macaddr;
352 } tSap_MaxAssocExceededEvent;
353 
354 /**
355  * struct sap_ch_selected_s - structure to hold the selected channels
356  * @pri_ch_freq: Holds the ACS selected primary channel frequency
357  * @ht_sec_ch_freq: Holds the ACS selected secondary ht channel frequency
358  * @vht_seg0_center_ch_freq: Holds the ACS selected center channel of vht seg0
359  * @vht_seg1_center_ch_freq: Holds the ACS selected center channel of vht seg1
360  * @ch_width: Holds the ACS selected channel bandwidth
361  *
362  * Holds the primary and secondary channel selected by ACS and is
363  * used to send it to the HDD.
364  */
365 struct sap_ch_selected_s {
366 	uint32_t pri_ch_freq;
367 	uint32_t ht_sec_ch_freq;
368 	uint16_t vht_seg0_center_ch_freq;
369 	uint16_t vht_seg1_center_ch_freq;
370 	uint16_t ch_width;
371 };
372 
373 /**
374  * struct sap_acs_scan_complete_event - acs scan complete event
375  * @status: status of acs scan
376  * @freq_list: acs scan channel frequency list
377  * @num_of_channels: number of channels
378  */
379 struct sap_acs_scan_complete_event {
380 	uint8_t status;
381 	uint32_t *freq_list;
382 	uint8_t num_of_channels;
383 };
384 
385 /**
386  * struct sap_ch_change_ind - channel change indication
387  * @new_chan_freq: channel frequency to change to
388  */
389 struct sap_ch_change_ind {
390 	uint32_t new_chan_freq;
391 };
392 
393 /**
394  * struct sap_ch_change_rsp - channel change response
395  * @sap_ch_selected: channel parameters of new channel
396  * @ch_change_rsp_status: channel change response status
397  */
398 struct sap_ch_change_rsp {
399 	struct sap_ch_selected_s sap_ch_selected;
400 	eSapStatus ch_change_rsp_status;
401 };
402 
403 /*
404  * This struct will be filled in and passed to sap_event_cb that is
405  * provided during wlansap_start_bss call The event id corresponding to
406  * structure  in the union is defined in comment next to the structure
407  */
408 
409 struct sap_event {
410 	eSapHddEvent sapHddEventCode;
411 	union {
412 		/*SAP_START_BSS_EVENT */
413 		tSap_StartBssCompleteEvent sapStartBssCompleteEvent;
414 		/*SAP_STOP_BSS_EVENT */
415 		tSap_StopBssCompleteEvent sapStopBssCompleteEvent;
416 		/*SAP_ASSOC_INDICATION */
417 		tSap_StationAssocIndication sapAssocIndication;
418 		/*SAP_STA_ASSOC_EVENT, SAP_STA_REASSOC_EVENT */
419 		tSap_StationAssocReassocCompleteEvent
420 				sapStationAssocReassocCompleteEvent;
421 		/*SAP_STA_DISASSOC_EVENT */
422 		tSap_StationDisassocCompleteEvent
423 				sapStationDisassocCompleteEvent;
424 		/*SAP_STA_SET_KEY_EVENT */
425 		tSap_StationSetKeyCompleteEvent sapStationSetKeyCompleteEvent;
426 		/*SAP_STA_MIC_FAILURE_EVENT */
427 		tSap_StationMICFailureEvent sapStationMICFailureEvent;
428 		/*eSAP_WPS_PBC_PROBE_REQ_EVENT */
429 		tSap_WPSPBCProbeReqEvent sapPBCProbeReqEvent;
430 		tSap_SendActionCnf sapActionCnf;
431 		/* eSAP_UNKNOWN_STA_JOIN */
432 		tSap_UnknownSTAJoinEvent sapUnknownSTAJoin;
433 		/* eSAP_MAX_ASSOC_EXCEEDED */
434 		tSap_MaxAssocExceededEvent sapMaxAssocExceeded;
435 		struct sap_ch_selected_s sap_ch_selected;
436 		struct sap_ch_change_ind sap_chan_cng_ind;
437 		struct sap_ch_change_rsp sap_chan_cng_rsp;
438 		struct sap_acs_scan_complete_event sap_acs_scan_comp;
439 	} sapevt;
440 };
441 
442 typedef struct sap_SSID {
443 	uint8_t length;
444 	uint8_t ssId[WLAN_SSID_MAX_LEN];
445 } qdf_packed tSap_SSID_t;
446 
447 typedef struct sap_SSIDInfo {
448 	tSap_SSID_t ssid;     /* SSID of the AP */
449 	/* SSID should/shouldn't be bcast in probe RSP & beacon */
450 	uint8_t ssidHidden;
451 } qdf_packed tSap_SSIDInfo_t;
452 
453 /**
454  * struct master_acs - acs attributes received from userspace
455  * @hw_mode: hw mode
456  * @ht: ht flag
457  * @ht40: ht40 flag
458  * @vht: vht flag
459  * @eht: eht flag
460  * @ch_width: channel bandwidth
461  */
462 struct master_acs {
463 	uint8_t    hw_mode;
464 	uint8_t    ht;
465 	uint8_t    ht40;
466 	uint8_t    vht;
467 	uint8_t    eht;
468 	uint16_t   ch_width;
469 };
470 
471 struct sap_acs_cfg {
472 	/* ACS Algo Input */
473 	uint8_t    acs_mode;
474 	eCsrPhyMode hw_mode;
475 	qdf_freq_t    start_ch_freq;
476 	qdf_freq_t    end_ch_freq;
477 	qdf_freq_t   *freq_list;
478 	uint8_t    ch_list_count;
479 	qdf_freq_t   *master_freq_list;
480 	uint8_t    master_ch_list_count;
481 	bool master_ch_list_updated;
482 #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE
483 	uint8_t    skip_scan_status;
484 	uint32_t    skip_scan_range1_stch;
485 	uint32_t    skip_scan_range1_endch;
486 	uint32_t    skip_scan_range2_stch;
487 	uint32_t    skip_scan_range2_endch;
488 #endif
489 
490 	uint16_t   ch_width;
491 	uint32_t   pcl_chan_freq[NUM_CHANNELS];
492 	uint8_t    pcl_channels_weight_list[NUM_CHANNELS];
493 	uint32_t   pcl_ch_count;
494 	uint8_t    is_ht_enabled;
495 	uint8_t    is_vht_enabled;
496 	/* ACS Algo Output */
497 	uint32_t   pri_ch_freq;
498 	uint32_t   ht_sec_ch_freq;
499 	uint32_t    vht_seg0_center_ch_freq;
500 	uint32_t    vht_seg1_center_ch_freq;
501 	uint32_t   band;
502 #ifdef WLAN_FEATURE_11BE
503 	bool       is_eht_enabled;
504 	uint16_t   acs_puncture_bitmap;
505 #endif
506 	bool       skip_acs_scan;
507 	uint32_t   last_scan_ageout_time;
508 	struct master_acs master_acs_cfg;
509 };
510 
511 /*
512  * enum sap_acs_dfs_mode- state of DFS mode
513  * @ACS_DFS_MODE_NONE: DFS mode attribute is not valid
514  * @ACS_DFS_MODE_ENABLE:  DFS mode is enabled
515  * @ACS_DFS_MODE_DISABLE: DFS mode is disabled
516  * @ACS_DFS_MODE_DEPRIORITIZE: Deprioritize DFS channels in scanning
517  */
518 enum  sap_acs_dfs_mode {
519 	ACS_DFS_MODE_NONE,
520 	ACS_DFS_MODE_ENABLE,
521 	ACS_DFS_MODE_DISABLE,
522 	ACS_DFS_MODE_DEPRIORITIZE
523 };
524 
525 struct sap_config {
526 	tSap_SSIDInfo_t SSIDinfo;
527 	eCsrPhyMode sap_orig_hw_mode;	/* Previous wireless Mode */
528 	eCsrPhyMode SapHw_mode;         /* Wireless Mode */
529 	eSapMacAddrACL SapMacaddr_acl;
530 	struct qdf_mac_addr accept_mac[MAX_ACL_MAC_ADDRESS]; /* MAC filtering */
531 	struct qdf_mac_addr deny_mac[MAX_ACL_MAC_ADDRESS];  /* MAC filtering */
532 	struct qdf_mac_addr self_macaddr;       /* self macaddress or BSSID */
533 	uint32_t chan_freq;          /* Operation channel frequency */
534 	uint32_t sec_ch_freq;
535 	struct ch_params ch_params;
536 	enum phy_ch_width ch_width_orig;
537 	uint8_t dtim_period;      /* dtim interval */
538 	uint16_t num_accept_mac;
539 	uint16_t num_deny_mac;
540 	/* Max ie length 255 * 2(WPA+RSN) + 2 bytes(vendor specific ID) * 2 */
541 	uint8_t RSNWPAReqIE[(WLAN_MAX_IE_LEN * 2) + 4];
542 	eSapAuthType authType;
543 	tCsrAuthList akm_list;
544 	bool privacy;
545 	/* 0 - disabled, 1 - not configured , 2 - configured */
546 	uint8_t wps_state;
547 	uint16_t RSNWPAReqIELength;     /* The byte count in the pWPAReqIE */
548 	uint32_t beacon_int;            /* Beacon Interval */
549 	enum QDF_OPMODE persona; /* Tells us which persona, GO or AP */
550 	bool enOverLapCh;
551 #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
552 	uint8_t cc_switch_mode;
553 #endif
554 	struct sap_acs_cfg acs_cfg;
555 	uint16_t probeRespIEsBufferLen;
556 	/* buffer for addn ies comes from hostapd */
557 	void *pProbeRespIEsBuffer;
558 	uint16_t assocRespIEsLen;
559 	/* buffer for addn ies comes from hostapd */
560 	void *pAssocRespIEsBuffer;
561 	uint16_t probeRespBcnIEsLen;
562 	/* buffer for addn ies comes from hostapd */
563 	void *pProbeRespBcnIEsBuffer;
564 	uint16_t beacon_tx_rate;
565 	uint8_t *vendor_ie;
566 	tSirMacRateSet supported_rates;
567 	tSirMacRateSet extended_rates;
568 	bool require_h2e;
569 	enum sap_acs_dfs_mode acs_dfs_mode;
570 	struct hdd_channel_info *channel_info;
571 	uint32_t channel_info_count;
572 	bool dfs_cac_offload;
573 #ifdef WLAN_SUPPORT_TWT
574 	bool cfg80211_twt_responder;
575 #endif
576 #ifdef WLAN_FEATURE_11BE_MLO
577 	bool mlo_sap;
578 	uint8_t link_id;
579 	uint8_t num_link;
580 #endif
581 	qdf_freq_t last_acs_freq;
582 	qdf_time_t last_acs_complete_time;
583 };
584 
585 #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE
586 typedef enum {
587 	eSAP_DO_NEW_ACS_SCAN,
588 	eSAP_DO_PAR_ACS_SCAN,
589 	eSAP_SKIP_ACS_SCAN
590 } tSap_skip_acs_scan;
591 #endif
592 
593 typedef enum {
594 	eSAP_DFS_DO_NOT_SKIP_CAC,
595 	eSAP_DFS_SKIP_CAC
596 } eSapDfsCACState_t;
597 
598 typedef enum {
599 	eSAP_DFS_CHANNEL_USABLE,
600 	eSAP_DFS_CHANNEL_AVAILABLE,
601 	eSAP_DFS_CHANNEL_UNAVAILABLE
602 } eSapDfsChanStatus_t;
603 
604 typedef struct sSapDfsNolInfo {
605 	uint8_t dfs_channel_number;
606 	eSapDfsChanStatus_t radar_status_flag;
607 	uint64_t radar_found_timestamp;
608 } tSapDfsNolInfo;
609 
610 typedef struct sSapDfsInfo {
611 	qdf_mc_timer_t sap_dfs_cac_timer;
612 	/*
613 	 * New channel frequency to move to when a  Radar is
614 	 * detected on current Channel
615 	 */
616 	uint32_t target_chan_freq;
617 	uint8_t ignore_cac;
618 	uint32_t user_provided_target_chan_freq;
619 
620 	/*
621 	 * Requests for Channel Switch Announcement IE
622 	 * generation and transmission
623 	 */
624 	uint8_t csaIERequired;
625 	uint8_t is_dfs_cac_timer_running;
626 	/*
627 	 * New channel width and new channel bonding mode
628 	 * will only be updated via channel fallback mechanism
629 	 */
630 	enum phy_ch_width orig_chanWidth;
631 	enum phy_ch_width new_chanWidth;
632 	struct ch_params new_ch_params;
633 
634 	/*
635 	 * sap_operating_channel_location holds SAP indoor,
636 	 * outdoor location information. Currently, if this
637 	 * param is  set this Indoor/outdoor channel interop
638 	 * restriction will only be implemented for JAPAN
639 	 * regulatory domain.
640 	 *
641 	 * 0 - Indicates that location unknown
642 	 * (or) SAP Indoor/outdoor interop is allowed
643 	 *
644 	 * 1 - Indicates device is operating on Indoor channels
645 	 * and SAP cannot pick next random channel from outdoor
646 	 * list of channels when a radar is found on current operating
647 	 * DFS channel.
648 	 *
649 	 * 2 - Indicates device is operating on Outdoor Channels
650 	 * and SAP cannot pick next random channel from indoor
651 	 * list of channels when a radar is found on current
652 	 * operating DFS channel.
653 	 */
654 	uint8_t sap_operating_chan_preferred_location;
655 
656 	/*
657 	 * Flag to indicate if DFS test mode is enabled and
658 	 * channel switch is disabled.
659 	 */
660 	uint8_t disable_dfs_ch_switch;
661 	uint16_t tx_leakage_threshold;
662 	/* beacon count before channel switch */
663 	uint8_t sap_ch_switch_beacon_cnt;
664 	uint8_t sap_ch_switch_mode;
665 	uint16_t reduced_beacon_interval;
666 	uint8_t vdev_id;
667 } tSapDfsInfo;
668 
669 /* MAX number of CAC channels to be recorded */
670 #define MAX_NUM_OF_CAC_HISTORY 8
671 
672 /**
673  * struct prev_cac_result - previous cac result
674  * @ap_start_time: ap start timestamp
675  * @ap_end_time: ap stop or cac end timestamp
676  * @cac_complete: cac complete without found radar event
677  * @cac_ch_param: ap channel parameters
678  */
679 struct prev_cac_result {
680 	uint64_t ap_start_time;
681 	uint64_t ap_end_time;
682 	bool cac_complete;
683 	struct ch_params cac_ch_param;
684 };
685 
686 /**
687  * struct dfs_radar_history - radar found history element
688  * @time: timestamp in us from system boot
689  * @radar_found: radar found or not
690  * @ch_freq: channel frequency in Mhz
691  */
692 struct dfs_radar_history {
693 	uint64_t time;
694 	bool radar_found;
695 	uint16_t ch_freq;
696 };
697 
698 #ifdef DCS_INTERFERENCE_DETECTION
699 /**
700  * struct sap_dcs_info - record sap dcs information.
701  * @wlan_interference_mitigation_enable: wlan interference mitigation
702  *                                       is enabled per vdev.
703  * @is_vdev_starting: is vdev doing restart because of dcs.
704  */
705 struct sap_dcs_info {
706 	bool wlan_interference_mitigation_enable[WLAN_MAX_VDEVS];
707 	bool is_vdev_starting[WLAN_MAX_VDEVS];
708 };
709 #endif
710 
711 struct sap_ctx_list {
712 	void *sap_context;
713 	enum QDF_OPMODE sapPersona;
714 };
715 
716 typedef struct tagSapStruct {
717 	/* Information Required for SAP DFS Master mode */
718 	tSapDfsInfo SapDfsInfo;
719 	struct sap_ctx_list sapCtxList[SAP_MAX_NUM_SESSION];
720 #ifdef FEATURE_AP_MCC_CH_AVOIDANCE
721 	bool sap_channel_avoidance;
722 #endif /* FEATURE_AP_MCC_CH_AVOIDANCE */
723 	bool acs_with_more_param;
724 	bool enable_dfs_phy_error_logs;
725 	uint8_t one_time_csa_count;
726 #ifdef DCS_INTERFERENCE_DETECTION
727 	struct sap_dcs_info dcs_info;
728 #endif
729 } tSapStruct, *tpSapStruct;
730 
731 /*
732  * struct sap_context - per-BSS Context for SAP
733  *
734  * struct sap_context is used to share per-BSS context between SAP and
735  * its clients. A context is generated by sap_create_ctx() and is
736  * destroyed by sap_destroy_ctx(). During the lifetime of the BSS the
737  * SAP context is passed as the primary parameter to SAP APIs. Note
738  * that by design the contents of the structure are opaque to the
739  * clients and a SAP context pointer must only be dereferenced by SAP.
740  */
741 struct sap_context;
742 
743 /**
744  * wlansap_roam_callback() - API to get the events for SAP persona
745  * @ctx: callback context registered with SME (sap context is registered)
746  * @csr_roam_info: pointer to SME CSR roam info structure
747  * @roam_status: status of the event reported by SME to SAP
748  * @roam_result: result of the event reported by SME to SAP
749  *
750  * Any activity like start_bss, stop_bss, and etc for SAP persona
751  * happens, SME reports the result of those events to SAP through this
752  * callback.
753  *
754  * Return: QDF_STATUS based on overall result
755  */
756 QDF_STATUS wlansap_roam_callback(void *ctx,
757 				 struct csr_roam_info *csr_roam_info,
758 				 eRoamCmdStatus roam_status,
759 				 eCsrRoamResult roam_result);
760 
761 /**
762  * sap_create_ctx() - API to create the sap context
763  *
764  * This API assigns the sap context from global sap context pool
765  * stored in gp_sap_ctx[i] array.
766  *
767  * Return: Pointer to the SAP context, or NULL if a context could not
768  * be allocated
769  */
770 struct sap_context *sap_create_ctx(void);
771 
772 /**
773  * sap_destroy_ctx - API to destroy the sap context
774  * @sap_ctx: Pointer to the SAP context
775  *
776  * This API puts back the given sap context to global sap context pool which
777  * makes current sap session's sap context invalid.
778  *
779  * Return: The result code associated with performing the operation
780  *         QDF_STATUS_E_FAULT: Pointer to SAP cb is NULL;
781  *                             access would cause a page fault
782  *         QDF_STATUS_SUCCESS: Success
783  */
784 QDF_STATUS sap_destroy_ctx(struct sap_context *sap_ctx);
785 
786 /**
787  * sap_init_ctx - Initialize the sap context
788  * @sap_ctx: Pointer to the SAP context
789  * @mode: Device mode
790  * @addr: MAC address of the SAP
791  * @session_id: Pointer to the session id
792  * @reinit: if called as part of reinit
793  *
794  * sap_create_ctx() allocates the sap context which is uninitialized.
795  * This API needs to be called to properly initialize the sap context
796  * which is just created.
797  *
798  * Return: The result code associated with performing the operation
799  *         QDF_STATUS_E_FAULT: BSS could not be started
800  *         QDF_STATUS_SUCCESS: Success
801  */
802 QDF_STATUS sap_init_ctx(struct sap_context *sap_ctx,
803 			 enum QDF_OPMODE mode,
804 			 uint8_t *addr, uint32_t session_id, bool reinit);
805 
806 /**
807  * sap_deinit_ctx() - De-initialize the sap context
808  * @sap_ctx: Pointer to the SAP context
809  *
810  * When SAP session is about to close, this API needs to be called
811  * to de-initialize all the members of sap context structure, so that
812  * nobody can accidentally start using the sap context.
813  *
814  * Return: The result code associated with performing the operation
815  *         QDF_STATUS_E_FAULT: BSS could not be stopped
816  *         QDF_STATUS_SUCCESS: Success
817  */
818 QDF_STATUS sap_deinit_ctx(struct sap_context *sap_ctx);
819 
820 /**
821  * sap_is_auto_channel_select() - is channel AUTO_CHANNEL_SELECT
822  * @sapcontext: Pointer to the SAP context
823  *
824  * Return: true on AUTO_CHANNEL_SELECT, false otherwise
825  */
826 bool sap_is_auto_channel_select(struct sap_context *sapcontext);
827 
828 QDF_STATUS wlansap_global_init(void);
829 QDF_STATUS wlansap_global_deinit(void);
830 typedef QDF_STATUS (*sap_event_cb)(struct sap_event *sap_event,
831 				   void *user_context);
832 
833 /**
834  * wlansap_is_channel_in_nol_list() - This API checks if channel is
835  * in nol list
836  * @sap_ctx: SAP context pointer
837  * @chan_freq: channel frequency
838  * @chanBondState: channel bonding state
839  *
840  * Return: True if the channel is in the NOL list, false otherwise
841  */
842 bool wlansap_is_channel_in_nol_list(struct sap_context *sap_ctx,
843 				    qdf_freq_t chan_freq,
844 				    ePhyChanBondState chanBondState);
845 
846 /**
847  * wlansap_is_channel_leaking_in_nol() - This API checks if channel is leaking
848  * in nol list
849  * @sap_ctx: SAP context pointer
850  * @chan_freq: channel frequency
851  * @chan_bw: channel bandwidth
852  *
853  * Return: True/False
854  */
855 bool wlansap_is_channel_leaking_in_nol(struct sap_context *sap_ctx,
856 				       uint16_t chan_freq,
857 				       uint8_t chan_bw);
858 
859 /**
860  * wlansap_start_bss() - start BSS
861  * @sap_ctx: Pointer to the SAP context
862  * @sap_event_cb: Callback function in HDD called by SAP to inform HDD
863  *                        about SAP results
864  * @config: Pointer to configuration structure passed down from
865  *                    HDD(HostApd for Android)
866  * @user_context: Parameter that will be passed back in all the SAP callback
867  *               events.
868  *
869  * This api function provides SAP FSM event eWLAN_SAP_PHYSICAL_LINK_CREATE for
870  * starting AP BSS
871  *
872  * Return: The result code associated with performing the operation
873  *         QDF_STATUS_E_FAULT: Pointer to SAP cb is NULL;
874  *                             access would cause a page fault
875  *         QDF_STATUS_SUCCESS: Success
876  */
877 QDF_STATUS wlansap_start_bss(struct sap_context *sap_ctx,
878 			     sap_event_cb sap_event_cb,
879 			     struct sap_config *config, void *user_context);
880 
881 /**
882  * wlansap_stop_bss() - stop BSS.
883  * @sap_ctx: Pointer to SAP context
884  *
885  * This api function provides SAP FSM event eSAP_HDD_STOP_INFRA_BSS for
886  * stopping AP BSS
887  *
888  * Return: The result code associated with performing the operation
889  *         QDF_STATUS_E_FAULT: Pointer to SAP cb is NULL;
890  *                             access would cause a page fault
891  *         QDF_STATUS_SUCCESS: Success
892  */
893 QDF_STATUS wlansap_stop_bss(struct sap_context *sap_ctx);
894 
895 /**
896  * wlan_sap_update_next_channel() - Update next channel configured using vendor
897  * command in SAP context
898  * @sap_ctx: SAP context
899  * @channel: channel number
900  * @chan_bw: channel width
901  *
902  * Return: QDF_STATUS
903  */
904 QDF_STATUS wlan_sap_update_next_channel(struct sap_context *sap_ctx,
905 					uint8_t channel,
906 					enum phy_ch_width chan_bw);
907 
908 #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
909 /**
910  * wlansap_check_cc_intf() - Get interfering concurrent channel
911  * @sap_ctx: SAP context pointer
912  *
913  * Determine if a concurrent channel is interfering.
914  *
915  * Return: Channel freq (Mhz) of the interfering channel, or 0 if none.
916  */
917 uint16_t wlansap_check_cc_intf(struct sap_context *sap_ctx);
918 #endif
919 
920 /**
921  * wlansap_set_mac_acl() - set MAC list entry in ACL.
922  * @sap_ctx: Pointer to the SAP context
923  * @config: Pointer to SAP config.
924  *
925  * This api function provides SAP to set mac list entry in accept list as well
926  * as deny list
927  *
928  * Return: The result code associated with performing the operation
929  *         QDF_STATUS_E_FAULT: Pointer to SAP cb is NULL;
930  *                             access would cause a page fault
931  *         QDF_STATUS_SUCCESS: Success
932  */
933 QDF_STATUS wlansap_set_mac_acl(struct sap_context *sap_ctx,
934 			       struct sap_config *config);
935 
936 /**
937  * wlansap_disassoc_sta() - initiate disassociation of station.
938  * @sap_ctx: Pointer to the SAP context
939  * @p_del_sta_params: pointer to station deletion parameters
940  *
941  * This api function provides for Ap App/HDD initiated disassociation of station
942  *
943  * Return: The QDF_STATUS code associated with performing the operation
944  *         QDF_STATUS_SUCCESS:  Success
945  */
946 QDF_STATUS wlansap_disassoc_sta(struct sap_context *sap_ctx,
947 				struct csr_del_sta_params *p_del_sta_params);
948 
949 /**
950  * wlansap_deauth_sta() - Ap App/HDD initiated deauthentication of station
951  * @sap_ctx: Pointer to the SAP context
952  * @pDelStaParams: Pointer to parameters of the station to deauthenticate
953  *
954  * This api function provides for Ap App/HDD initiated deauthentication of
955  * station
956  *
957  * Return: The QDF_STATUS code associated with performing the operation
958  */
959 QDF_STATUS wlansap_deauth_sta(struct sap_context *sap_ctx,
960 			      struct csr_del_sta_params *pDelStaParams);
961 
962 /**
963  * wlansap_set_channel_change_with_csa() - Set channel change with CSA
964  * @sap_ctx: Pointer to SAP context
965  * @target_chan_freq: Target channel frequency
966  * @target_bw: Target bandwidth
967  * @strict: if true switch to the requested channel always, fail
968  *        otherwise
969  *
970  * This api function does a channel change to the target channel specified.
971  * CSA IE is included in the beacons before doing a channel change.
972  *
973  * Return: QDF_STATUS
974  */
975 QDF_STATUS wlansap_set_channel_change_with_csa(struct sap_context *sap_ctx,
976 					       uint32_t target_chan_freq,
977 					       enum phy_ch_width target_bw,
978 					       bool strict);
979 
980 
981 /**
982  * wlan_sap_getstation_ie_information() - RSNIE Population
983  * @sap_ctx: Pointer to the SAP context
984  * @len: Length of @buf
985  * @buf: RSNIE IE data
986  *
987  *  Populate RSN IE from CSR to HDD context
988  *
989  * Return: QDF_STATUS enumeration
990  */
991 
992 QDF_STATUS wlan_sap_getstation_ie_information(struct sap_context *sap_ctx,
993 					      uint32_t *len, uint8_t *buf);
994 
995 /**
996  * wlansap_clear_acl() - Clear all ACLs
997  * @sap_ctx: Pointer to the SAP context
998  *
999  * Return: QDF_STATUS. If success the ACLs were cleared, otherwise an
1000  *    error occurred.
1001  */
1002 QDF_STATUS wlansap_clear_acl(struct sap_context *sap_ctx);
1003 
1004 /**
1005  * wlansap_get_acl_accept_list() - Get ACL accept list
1006  * @sap_ctx: Pointer to the SAP context
1007  * @pAcceptList: Pointer to the buffer to store the ACL accept list
1008  * @nAcceptList: Pointer to the location to store the number of
1009  *    entries in the ACL accept list.
1010  *
1011  * Return: QDF_STATUS. If success the data was returned, otherwise an
1012  *    error occurred.
1013  */
1014 QDF_STATUS wlansap_get_acl_accept_list(struct sap_context *sap_ctx,
1015 				       struct qdf_mac_addr *pAcceptList,
1016 				       uint16_t *nAcceptList);
1017 
1018 /**
1019  * wlansap_is_channel_present_in_acs_list() - Freq present in ACS list or not
1020  * @freq: Frequency to be searched
1021  * @ch_freq_list: channel frequency list.
1022  * @ch_count: Channel frequency list count
1023  *
1024  * Return: True is found, false otherwise
1025  */
1026 bool wlansap_is_channel_present_in_acs_list(uint32_t freq,
1027 					    uint32_t *ch_freq_list,
1028 					    uint8_t ch_count);
1029 
1030 /**
1031  * wlansap_get_acl_deny_list() - Get ACL deny list
1032  * @sap_ctx: Pointer to the SAP context
1033  * @pDenyList: Pointer to the buffer to store the ACL deny list
1034  * @nDenyList: Pointer to the location to store the number of
1035  *    entries in the ACL deny list.
1036  *
1037  * Return: QDF_STATUS. If success the data was returned, otherwise an
1038  *    error occurred.
1039  */
1040 QDF_STATUS wlansap_get_acl_deny_list(struct sap_context *sap_ctx,
1041 				     struct qdf_mac_addr *pDenyList,
1042 				     uint16_t *nDenyList);
1043 
1044 /**
1045  * wlansap_set_acl_mode() - Set the SAP ACL mode
1046  * @sap_ctx: The SAP context pointer
1047  * @mode: the desired ACL mode
1048  *
1049  * Return: QDF_STATUS
1050  */
1051 QDF_STATUS wlansap_set_acl_mode(struct sap_context *sap_ctx,
1052 				eSapMacAddrACL mode);
1053 
1054 /**
1055  * wlansap_get_acl_mode() - Get the SAP ACL mode
1056  * @sap_ctx: The SAP context pointer
1057  * @mode: Pointer where to return the current ACL mode
1058  *
1059  * Return: QDF_STATUS
1060  */
1061 QDF_STATUS wlansap_get_acl_mode(struct sap_context *sap_ctx,
1062 				eSapMacAddrACL *mode);
1063 
1064 /**
1065  * wlansap_modify_acl() - Update ACL entries
1066  * @sap_ctx: Pointer to the SAP context
1067  * @peer_sta_mac: peer sta mac to be updated.
1068  * @list_type: allow/Deny list type.
1069  * @cmd: command to be executed on ACL.
1070  *
1071  * This function is called when a peer needs to be added or deleted from the
1072  * allow/deny ACL
1073  *
1074  * Return: Status
1075  */
1076 QDF_STATUS wlansap_modify_acl(struct sap_context *sap_ctx,
1077 			      uint8_t *peer_sta_mac,
1078 			      eSapACLType list_type, eSapACLCmdType cmd);
1079 
1080 /**
1081  * wlansap_channel_change_request() - Send channel change request
1082  * @sap_ctx: Pointer to the SAP context
1083  * @target_chan_freq: Target channel
1084  *
1085  * This API is used to send an Indication to SME/PE to change the
1086  * current operating channel to a different target channel.
1087  *
1088  * The Channel change will be issued by SAP under the following
1089  * scenarios.
1090  * 1. A radar indication is received  during SAP CAC WAIT STATE and
1091  *    channel change is required.
1092  * 2. A radar indication is received during SAP STARTED STATE and
1093  *    channel change is required.
1094  *
1095  * Return: The QDF_STATUS code associated with performing the operation
1096  *   QDF_STATUS_SUCCESS:  Success
1097  *
1098  */
1099 QDF_STATUS wlansap_channel_change_request(struct sap_context *sap_ctx,
1100 					  uint32_t target_chan_freq);
1101 
1102 /**
1103  * wlansap_get_sec_channel() - get the secondary sap channel
1104  * @sec_ch_offset: secondary channel offset.
1105  * @op_chan_freq: Operating sap channel frequency.
1106  * @sec_chan_freq: channel frequency to be filled.
1107  *
1108  * This API will get the secondary sap channel from the offset, and
1109  * operating channel.
1110  *
1111  * Return: None
1112  *
1113  */
1114 void wlansap_get_sec_channel(uint8_t sec_ch_offset,
1115 			     uint32_t op_chan_freq,
1116 			     uint32_t *sec_chan_freq);
1117 
1118 /**
1119  * wlansap_start_beacon_req() - Send Start Beaconing Request
1120  * @sap_ctx: Pointer to the SAP context
1121  *
1122  * This API is used to send an Indication to SME/PE to start
1123  * beaconing on the current operating channel.
1124  *
1125  * When SAP is started on DFS channel and when ADD BSS RESP is received
1126  * LIM temporarily holds off Beaconing for SAP to do CAC WAIT. When
1127  * CAC WAIT is done SAP resumes the Beacon Tx by sending a start beacon
1128  * request to LIM.
1129  *
1130  * Return: The QDF_STATUS code associated with performing the operation
1131  *   QDF_STATUS_SUCCESS:  Success
1132  */
1133 QDF_STATUS wlansap_start_beacon_req(struct sap_context *sap_ctx);
1134 
1135 /**
1136  * wlansap_dfs_send_csa_ie_request() - Send CSA IE
1137  * @sap_ctx: Pointer to the SAP context
1138  *
1139  * This API is used to send channel switch announcement request to PE
1140  *
1141  * Return: The QDF_STATUS code associated with performing the operation
1142  *    QDF_STATUS_SUCCESS:  Success
1143  */
1144 QDF_STATUS wlansap_dfs_send_csa_ie_request(struct sap_context *sap_ctx);
1145 
1146 /**
1147  * wlansap_get_dfs_ignore_cac() - Get ignore_cac value
1148  * @mac_handle: Opaque handle to the global MAC context
1149  * @ignore_cac: Location to store ignore_cac value
1150  *
1151  * This API is used to Get the value of ignore_cac value
1152  *
1153  * Return: The QDF_STATUS code associated with performing the operation
1154  */
1155 QDF_STATUS wlansap_get_dfs_ignore_cac(mac_handle_t mac_handle,
1156 				      uint8_t *ignore_cac);
1157 
1158 /**
1159  * wlansap_set_dfs_ignore_cac() - Set ignore_cac value
1160  * @mac_handle: Opaque handle to the global MAC context
1161  * @ignore_cac: value to set for ignore_cac variable in DFS global structure.
1162  *
1163  * This API is used to Set the value of ignore_cac value
1164  *
1165  * Return: The QDF_STATUS code associated with performing the operation
1166  */
1167 QDF_STATUS wlansap_set_dfs_ignore_cac(mac_handle_t mac_handle,
1168 				      uint8_t ignore_cac);
1169 /**
1170  * wlansap_get_dfs_cac_state() - Get cac_state value
1171  * @mac_handle: Opaque handle to the global MAC context
1172  * @sap_context: sap adapter context
1173  * @cac_state: Location to store cac_state value
1174  *
1175  * This API is used to Get the value of current cac state
1176  *
1177  * Return: The QDF_STATUS code associated with performing the operation
1178  */
1179 QDF_STATUS wlansap_get_dfs_cac_state(mac_handle_t mac_handle,
1180 				     struct sap_context *sap_context,
1181 				     bool *cac_state);
1182 
1183 /**
1184  * wlansap_get_csa_chanwidth_from_phymode() - function to populate
1185  * channel width from user configured phymode for csa
1186  * @sap_context: sap adapter context
1187  * @chan_freq: target channel frequency (MHz)
1188  * @tgt_ch_params: target new channel bw parameters to be updated
1189  *
1190  * Return: phy_ch_width
1191  */
1192 enum phy_ch_width
1193 wlansap_get_csa_chanwidth_from_phymode(struct sap_context *sap_context,
1194 				       uint32_t chan_freq,
1195 				       struct ch_params *tgt_ch_params);
1196 
1197 #ifdef FEATURE_AP_MCC_CH_AVOIDANCE
1198 QDF_STATUS
1199 wlan_sap_set_channel_avoidance(mac_handle_t mac_handle,
1200 			       bool sap_channel_avoidance);
1201 #endif
1202 
1203 /**
1204  * wlan_sap_set_acs_with_more_param() - sets acs_with_more_param ini param
1205  * @mac_handle: Opaque handle to the global MAC context
1206  * @acs_with_more_param: ini parameter value
1207  *
1208  * Return: The QDF_STATUS code.
1209  */
1210 QDF_STATUS
1211 wlan_sap_set_acs_with_more_param(mac_handle_t mac_handle,
1212 				 bool acs_with_more_param);
1213 
1214 /**
1215  * wlansap_set_dfs_preferred_channel_location() - set dfs preferred channel
1216  * @mac_handle: Opaque handle to the global MAC context
1217  *
1218  * This API is used to set sap preferred channels location
1219  * to resetrict the DFS random channel selection algorithm
1220  * either Indoor/Outdoor channels only.
1221  * dfs_Preferred_Channels_location :
1222  *       0 - Indicates No preferred channel location restrictions
1223  *       1 - Indicates SAP Indoor Channels operation only.
1224  *       2 - Indicates SAP Outdoor Channels operation only.
1225  *
1226  * Return: The QDF_STATUS code associated with performing the operation
1227  *         QDF_STATUS_SUCCESS:  Success and error code otherwise.
1228  */
1229 QDF_STATUS wlansap_set_dfs_preferred_channel_location(mac_handle_t mac_handle);
1230 
1231 /**
1232  * wlansap_set_dfs_target_chnl() - Set target channel
1233  * @mac_handle: Opaque handle for the global MAC context
1234  * @target_chan_freq: target channel frequency to be set
1235  *
1236  * This API is used to set next target chnl as provided channel.
1237  * you can provide any valid channel to this API.
1238  *
1239  * Return: The QDF_STATUS code associated with performing the operation
1240  */
1241 QDF_STATUS wlansap_set_dfs_target_chnl(mac_handle_t mac_handle,
1242 				       uint32_t target_chan_freq);
1243 
1244 /**
1245  * wlan_sap_get_phymode() - Returns sap phymode.
1246  * @sap_ctx:	Pointer to Sap Context.
1247  *
1248  * This function provides the SAP current phymode.
1249  *
1250  * Return: phymode
1251  */
1252 eCsrPhyMode wlan_sap_get_phymode(struct sap_context *sap_ctx);
1253 
1254 /**
1255  * wlan_sap_get_concurrent_bw() - Returns SAP BW based on concurrent channel &
1256  *                                STA DFS channel
1257  * @pdev: Pointer to Pdev
1258  * @psoc: Pointer to Psoc
1259  * @con_ch_freq: interfering concurrent channel
1260  * @channel_width: Channel width
1261  *
1262  * Return: Channel width. If STA is not present on con_ch_freq, it returns
1263  *        max of STA BW and 80 Mhz. If STA is not connected in dfs chan or STA
1264  *........BW is not 160 Mhz (which includes DFS channel), then it will return
1265  *        BW maximum of STA BW and 80 Mhz. If DFS STA is present, then return
1266  *        BW as min of 80 and STA BW.
1267  */
1268 enum phy_ch_width wlan_sap_get_concurrent_bw(struct wlan_objmgr_pdev *pdev,
1269 					     struct wlan_objmgr_psoc *psoc,
1270 					     qdf_freq_t con_ch_freq,
1271 					     enum phy_ch_width channel_width);
1272 
1273 /**
1274  * wlan_sap_get_vht_ch_width() - Returns SAP VHT channel width.
1275  * @sap_ctx:	Pointer to Sap Context
1276  *
1277  * This function provides the SAP current VHT channel with.
1278  *
1279  * Return: VHT channel width
1280  */
1281 uint32_t wlan_sap_get_vht_ch_width(struct sap_context *sap_ctx);
1282 
1283 /**
1284  * wlan_sap_get_ch_params() - get ch params
1285  * @sap_ctx: Pointer to Sap Context
1286  * @ch_params: returned ch_params
1287  *
1288  * This function get sap's ch_params
1289  *
1290  * Return: true for success
1291  */
1292 bool wlan_sap_get_ch_params(struct sap_context *sap_ctx,
1293 			    struct ch_params *ch_params);
1294 
1295 /**
1296  * wlan_sap_set_sap_ctx_acs_cfg() - Sets acs cfg
1297  * @sap_ctx:  Pointer to Sap Context
1298  * @sap_config:  Pointer to sap config
1299  *
1300  * This function sets the acs cfg in sap context.
1301  *
1302  * Return: None
1303  */
1304 void wlan_sap_set_sap_ctx_acs_cfg(struct sap_context *sap_ctx,
1305 				  struct sap_config *sap_config);
1306 
1307 void sap_config_acs_result(mac_handle_t mac_handle,
1308 			   struct sap_context *sap_ctx,
1309 			   uint32_t sec_ch_freq);
1310 
1311 QDF_STATUS wlansap_update_sap_config_add_ie(struct sap_config *config,
1312 					    const uint8_t *pAdditionIEBuffer,
1313 					    uint16_t additionIELength,
1314 					    eUpdateIEsType updateType);
1315 
1316 QDF_STATUS wlansap_reset_sap_config_add_ie(struct sap_config *config,
1317 					   eUpdateIEsType updateType);
1318 
1319 void wlansap_extend_to_acs_range(mac_handle_t mac_handle,
1320 				 uint32_t *start_ch_freq,
1321 				 uint32_t *end_ch_freq,
1322 				 uint32_t *bandStartChannel,
1323 				 uint32_t *bandEndChannel);
1324 
1325 #ifdef WLAN_FEATURE_SON
1326 /**
1327  * wlansap_son_update_sap_config_phymode() - update sap config according to
1328  *                                           phy_mode. This API is for son,
1329  *                                           There is no band switching when
1330  *                                           son phy mode is changed.
1331  * @vdev:  Pointer to vdev object
1332  * @config:  Pointer to sap config
1333  * @phy_mode: pointer to phy mode
1334  *
1335  * Return: QDF_STATUS
1336  */
1337 QDF_STATUS
1338 wlansap_son_update_sap_config_phymode(struct wlan_objmgr_vdev *vdev,
1339 				      struct sap_config *config,
1340 				      enum qca_wlan_vendor_phy_mode phy_mode);
1341 #endif
1342 
1343 /**
1344  * wlansap_set_dfs_nol() - Set dfs nol
1345  * @sap_ctx: SAP context
1346  * @conf: set type
1347  *
1348  * Return: QDF_STATUS
1349  */
1350 #ifdef DFS_COMPONENT_ENABLE
1351 QDF_STATUS wlansap_set_dfs_nol(struct sap_context *sap_ctx,
1352 			       eSapDfsNolType conf);
1353 #else
wlansap_set_dfs_nol(struct sap_context * sap_ctx,eSapDfsNolType conf)1354 static inline QDF_STATUS wlansap_set_dfs_nol(struct sap_context *sap_ctx,
1355 			       eSapDfsNolType conf)
1356 {
1357 	return QDF_STATUS_SUCCESS;
1358 }
1359 #endif
1360 
1361 /**
1362  * wlan_sap_set_dfs_pri_multiplier() - Set dfs_pri_multiplier
1363  * @mac_handle: Opaque handle to the global MAC context
1364  *
1365  * Return: none
1366  */
1367 #ifdef DFS_PRI_MULTIPLIER
1368 void wlan_sap_set_dfs_pri_multiplier(mac_handle_t mac_handle);
1369 #else
wlan_sap_set_dfs_pri_multiplier(mac_handle_t mac_handle)1370 static inline void wlan_sap_set_dfs_pri_multiplier(mac_handle_t mac_handle)
1371 {
1372 }
1373 #endif
1374 
1375 /**
1376  * wlan_sap_set_vendor_acs() - Set vendor specific acs in sap context
1377  * @sap_context: SAP context
1378  * @is_vendor_acs: if vendor specific acs is enabled
1379  *
1380  * Return: QDF_STATUS
1381  */
1382 QDF_STATUS wlan_sap_set_vendor_acs(struct sap_context *sap_context,
1383 				   bool is_vendor_acs);
1384 
1385 /**
1386  * wlansap_populate_del_sta_params() - populate delete station parameter
1387  * @mac: Pointer to peer mac address.
1388  * @reason_code: Reason code for the disassoc/deauth.
1389  * @subtype: Subtype points to either disassoc/deauth frame.
1390  * @params: Parameters to be populated.
1391  *
1392  * This API is used to populate delete station parameter structure
1393  *
1394  * Return: none
1395  */
1396 void wlansap_populate_del_sta_params(const uint8_t *mac,
1397 				     uint16_t reason_code,
1398 				     uint8_t subtype,
1399 				     struct csr_del_sta_params *params);
1400 
1401 /**
1402  * wlansap_acs_chselect() - Initiates acs channel selection
1403  * @sap_context:               Pointer to SAP context structure
1404  * @acs_event_callback:       Callback function in hdd called by sap
1405  *                             to inform hdd about channel selection result
1406  * @config:                   Pointer to configuration structure
1407  *                             passed down from hdd
1408  * @pusr_context:              Parameter that will be passed back in all
1409  *                             the sap callback events.
1410  *
1411  * This function serves as an api for hdd to initiate acs scan pre
1412  * start bss.
1413  *
1414  * Return: The QDF_STATUS code associated with performing the operation.
1415  */
1416 QDF_STATUS wlansap_acs_chselect(struct sap_context *sap_context,
1417 				sap_event_cb acs_event_callback,
1418 				struct sap_config *config,
1419 				void *pusr_context);
1420 
1421 /**
1422  * sap_undo_acs() - Undo acs i.e free the allocated ch lists
1423  * @sap_context: pointer to the SAP context
1424  * @sap_cfg: pointer to the SAP confid structure
1425  *
1426  * This function will free the memory allocated to the sap ctx channel list, acs
1427  * cfg ch list and master ch list.
1428  *
1429  * Return: None
1430  */
1431 void sap_undo_acs(struct sap_context *sap_context, struct sap_config *sap_cfg);
1432 
1433 /**
1434  * wlansap_get_chan_width() - get sap channel width.
1435  * @sap_ctx: pointer to the SAP context
1436  *
1437  * This function get channel width of sap.
1438  *
1439  * Return: sap channel width
1440  */
1441 uint32_t wlansap_get_chan_width(struct sap_context *sap_ctx);
1442 
1443 /**
1444  * wlansap_get_max_bw_by_phymode() - get max channel width based on phymode
1445  * @sap_ctx: pointer to the SAP context
1446  *
1447  * This function get max channel width of sap based on phymode.
1448  *
1449  * Return: channel width
1450  */
1451 enum phy_ch_width
1452 wlansap_get_max_bw_by_phymode(struct sap_context *sap_ctx);
1453 
1454 /*
1455  * wlansap_set_invalid_session() - set session ID to invalid
1456  * @sap_ctx: pointer to the SAP context
1457  *
1458  * This function sets session ID to invalid
1459  *
1460  * Return: QDF_STATUS
1461  */
1462 QDF_STATUS wlansap_set_invalid_session(struct sap_context *sap_ctx);
1463 
1464 /*
1465  * wlansap_set_invalid_session() - Release vdev ref taken by sap context
1466  * @sap_ctx: pointer to the SAP context
1467  *
1468  * Return: QDF_STATUS
1469  */
1470 QDF_STATUS wlansap_release_vdev_ref(struct sap_context *sap_ctx);
1471 
1472 /**
1473  * sap_get_cac_dur_dfs_region() - get cac duration and dfs region.
1474  * @sap_ctx: sap context
1475  * @cac_duration_ms: pointer to cac duration
1476  * @dfs_region: pointer to dfs region
1477  * @chan_freq: channel frequency
1478  * @ch_params: pointer to ch_params
1479  *
1480  * Get cac duration and dfs region.
1481  *
1482  * Return: None
1483  */
1484 void sap_get_cac_dur_dfs_region(struct sap_context *sap_ctx,
1485 				uint32_t *cac_duration_ms,
1486 				uint32_t *dfs_region,
1487 				qdf_freq_t chan_freq,
1488 				struct ch_params *ch_params);
1489 
1490 /**
1491  * sap_clear_global_dfs_param() - Reset global dfs param of sap ctx
1492  * @mac_handle: pointer to mac handle
1493  * @sap_ctx: sap context
1494  *
1495  * This API resets global dfs param of sap ctx.
1496  *
1497  * Return: QDF_STATUS
1498  */
1499 QDF_STATUS sap_clear_global_dfs_param(mac_handle_t mac_handle,
1500 				      struct sap_context *sap_ctx);
1501 
1502 /**
1503  * sap_dfs_set_current_channel() - Set current channel params in dfs component
1504  * @sap_ctx: sap context
1505  *
1506  * Set current channel params in dfs component, this info will be used to mark
1507  * the channels in nol when radar is detected.
1508  *
1509  * Return: None
1510  */
1511 void sap_dfs_set_current_channel(void *sap_ctx);
1512 
1513 /**
1514  * wlansap_cleanup_cac_timer() - Force cleanup DFS CAC timer
1515  * @sap_ctx: sap context
1516  *
1517  * Force cleanup DFS CAC timer when reset all adapters. It will not
1518  * check concurrency SAP since just called when reset all adapters.
1519  *
1520  * Return: None
1521  */
1522 void wlansap_cleanup_cac_timer(struct sap_context *sap_ctx);
1523 
1524 /**
1525  * wlansap_update_owe_info() - Update OWE info
1526  * @sap_ctx: sap context
1527  * @peer: peer mac
1528  * @ie: IE from hostapd
1529  * @ie_len: IE length
1530  * @owe_status: status from hostapd
1531  *
1532  * Return: QDF_STATUS
1533  */
1534 QDF_STATUS wlansap_update_owe_info(struct sap_context *sap_ctx,
1535 				   uint8_t *peer, const uint8_t *ie,
1536 				   uint32_t ie_len, uint16_t owe_status);
1537 
1538 /**
1539  * wlansap_update_ft_info() - Update FT info
1540  * @sap_ctx: sap context
1541  * @peer: peer mac
1542  * @ie: IE from hostapd
1543  * @ie_len: IE length
1544  * @ft_status: wlan status codes
1545  *
1546  * Return: QDF_STATUS
1547  */
1548 QDF_STATUS wlansap_update_ft_info(struct sap_context *sap_ctx,
1549 				  uint8_t *peer, const uint8_t *ie,
1550 				  uint32_t ie_len, uint16_t ft_status);
1551 
1552 /**
1553  * wlansap_filter_ch_based_acs() -filter out channel based on acs
1554  * @sap_ctx: sap context
1555  * @ch_freq_list: pointer to channel frequency list
1556  * @ch_cnt: channel number of channel list
1557  *
1558  * Return: QDF_STATUS
1559  */
1560 QDF_STATUS wlansap_filter_ch_based_acs(struct sap_context *sap_ctx,
1561 				       uint32_t *ch_freq_list,
1562 				       uint32_t *ch_cnt);
1563 
1564 /**
1565  * wlansap_is_6ghz_included_in_acs_range() - check 6ghz channel included in
1566  * ACS range
1567  * @sap_ctx: sap context
1568  *
1569  * Return: QDF_STATUS
1570  */
1571 bool wlansap_is_6ghz_included_in_acs_range(struct sap_context *sap_ctx);
1572 
1573 /**
1574  * wlansap_get_safe_channel_from_pcl_and_acs_range() - Get safe channel for SAP
1575  * restart
1576  * @sap_ctx: sap context
1577  * @ch_width: selected channel bandwdith
1578  *
1579  * Get a safe channel to restart SAP. PCL already takes into account the
1580  * unsafe channels. So, the PCL is validated with the ACS range to provide
1581  * a safe channel for the SAP to restart.
1582  *
1583  * Return: Chan freq num to restart SAP in case of success. In case of any
1584  * failure, the channel number returned is zero.
1585  */
1586 uint32_t
1587 wlansap_get_safe_channel_from_pcl_and_acs_range(struct sap_context *sap_ctx,
1588 						enum phy_ch_width *ch_width);
1589 
1590 /**
1591  * wlansap_get_safe_channel_from_pcl_for_sap() - Get safe and active channel
1592  * for SAP restart
1593  * @sap_ctx: sap context
1594  *
1595  * Get a safe and active channel to restart SAP. PCL already takes into account
1596  * the unsafe channels.
1597  *
1598  * Return: Chan freq num to restart SAP in case of success. In case of any
1599  * failure, the channel number returned is zero.
1600  */
1601 uint32_t wlansap_get_safe_channel_from_pcl_for_sap(struct sap_context *sap_ctx);
1602 
1603 /**
1604  * wlansap_get_chan_band_restrict() -  get new chan for band change
1605  * @sap_ctx: sap context pointer
1606  * @csa_reason: channel switch reason to update
1607  *
1608  * Sap/p2p go channel switch from 5G to 2G by CSA when 5G band disabled to
1609  * avoid conflict with modem N79.
1610  * Sap/p2p go channel restore to 5G channel when 5G band enabled.
1611  * Note: csa_reason is only updated when channel is disabled or band is
1612  * restricted, so it must be initialized to a default value beforehand
1613  *
1614  * Return - restart channel in MHZ
1615  */
1616 qdf_freq_t wlansap_get_chan_band_restrict(struct sap_context *sap_ctx,
1617 					  enum sap_csa_reason_code *csa_reason);
1618 
1619 /**
1620  * wlansap_override_csa_strict_for_sap() - check user CSA strict or not
1621  * @mac_handle: Opaque handle to the global MAC context
1622  * @sap_ctx: sap context
1623  * @target_chan_freq: target channel frequency in MHz
1624  * @strict: CSA strict flag
1625  *
1626  * If force SCC enabled, user trigger SAP CSA and target channel
1627  * doesn't cause MCC with existing STA/CLI, then override strict flag to
1628  * true, so that driver can skip the overlap interference check and
1629  * allow the CSA go through. This is to allow SAP/GO force SCC in
1630  * same band.
1631  *
1632  * Return: true if CSA is strict, otherwise false
1633  */
1634 bool
1635 wlansap_override_csa_strict_for_sap(mac_handle_t mac_handle,
1636 				    struct sap_context *sap_ctx,
1637 				    uint32_t target_chan_freq,
1638 				    bool strict);
1639 
1640 /**
1641  * wlansap_validate_channel_post_csa() - Check SAP channel unsafe or not
1642  * after CSA
1643  * @mac_handle: global MAC context
1644  * @sap_ctx: SAP context
1645  *
1646  * Return: bool
1647  */
1648 bool wlansap_validate_channel_post_csa(mac_handle_t mac_handle,
1649 				       struct sap_context *sap_ctx);
1650 
1651 /**
1652  * sap_get_csa_reason_str() - Get csa reason in string
1653  * @reason: sap reason enum value
1654  *
1655  * Return: string reason
1656  */
1657 const char *sap_get_csa_reason_str(enum sap_csa_reason_code reason);
1658 
1659 #ifdef FEATURE_RADAR_HISTORY
1660 /**
1661  * wlansap_query_radar_history() -  get radar history info
1662  * @mac_handle: mac context
1663  * @radar_history: radar history buffer to be returned
1664  * @count: total history count
1665  *
1666  * The API will return the dfs nol list(Radar found history) and
1667  * CAC history (no Radar found).
1668  *
1669  * Return - QDF_STATUS
1670  */
1671 QDF_STATUS
1672 wlansap_query_radar_history(mac_handle_t mac_handle,
1673 			    struct dfs_radar_history **radar_history,
1674 			    uint32_t *count);
1675 #endif
1676 
1677 #ifdef DCS_INTERFERENCE_DETECTION
1678 /**
1679  * wlansap_dcs_set_vdev_wlan_interference_mitigation() - set wlan
1680  * interference mitigation enable information per vdev
1681  * @sap_context: sap context
1682  * @wlan_interference_mitigation_enable: wlan interference mitigation
1683  *                                       enable or not
1684  *
1685  * This function is used to set whether wlan interference mitigation
1686  * enable or not
1687  *
1688  * Return: QDF_STATUS
1689  */
1690 QDF_STATUS wlansap_dcs_set_vdev_wlan_interference_mitigation(
1691 				struct sap_context *sap_context,
1692 				bool wlan_interference_mitigation_enable);
1693 
1694 /**
1695  * wlansap_dcs_set_wlan_interference_mitigation_on_band() - set wlan
1696  * interference mitigation enable information based on band information
1697  * @sap_context: sap context
1698  * @sap_cfg: sap config
1699  *
1700  * This function is used to set whether wlan interference mitigation
1701  * enable or not based on band information
1702  *
1703  * Return: QDF_STATUS
1704  */
1705 QDF_STATUS wlansap_dcs_set_wlan_interference_mitigation_on_band(
1706 					struct sap_context *sap_context,
1707 					struct sap_config *sap_cfg);
1708 
1709 /**
1710  * wlansap_dcs_set_vdev_starting() - set vdev starting
1711  * @sap_context: sap context
1712  * @vdev_starting: vdev in starting states
1713  *
1714  * This function is used to set whether vdev starting or not
1715  *
1716  * Return: QDF_STATUS
1717  */
1718 QDF_STATUS wlansap_dcs_set_vdev_starting(struct sap_context *sap_context,
1719 					 bool vdev_starting);
1720 
1721 /**
1722  * wlansap_dcs_is_wlan_interference_mitigation_enabled() - get wlan interference
1723  * mitigation enabled information
1724  * @sap_context: sap context
1725  *
1726  * This function is used to get wlan interference mitigation enabled information
1727  * with given sap
1728  *
1729  * Return: true if wlan interference mitigation is enabled with given sap
1730  */
1731 bool wlansap_dcs_is_wlan_interference_mitigation_enabled(
1732 					struct sap_context *sap_context);
1733 
1734 /**
1735  * wlansap_dcs_get_freq() - get dcs channel frequency
1736  * @sap_context: sap context
1737  *
1738  * This function is used to get dcs channel frequency with give sap
1739  *
1740  * Return: sap dcs channel frequency
1741  */
1742 qdf_freq_t wlansap_dcs_get_freq(struct sap_context *sap_context);
1743 #else
wlansap_dcs_set_vdev_wlan_interference_mitigation(struct sap_context * sap_context,bool wlan_interference_mitigation_enable)1744 static inline QDF_STATUS wlansap_dcs_set_vdev_wlan_interference_mitigation(
1745 				struct sap_context *sap_context,
1746 				bool wlan_interference_mitigation_enable)
1747 {
1748 	return QDF_STATUS_SUCCESS;
1749 }
1750 
wlansap_dcs_set_wlan_interference_mitigation_on_band(struct sap_context * sap_context,struct sap_config * sap_cfg)1751 static inline QDF_STATUS wlansap_dcs_set_wlan_interference_mitigation_on_band(
1752 						struct sap_context *sap_context,
1753 						struct sap_config *sap_cfg)
1754 {
1755 	return QDF_STATUS_SUCCESS;
1756 }
1757 
wlansap_dcs_set_vdev_starting(struct sap_context * sap_context,bool vdev_starting)1758 static inline QDF_STATUS wlansap_dcs_set_vdev_starting(
1759 	struct sap_context *sap_context, bool vdev_starting)
1760 {
1761 	return QDF_STATUS_SUCCESS;
1762 }
1763 
wlansap_dcs_is_wlan_interference_mitigation_enabled(struct sap_context * sap_context)1764 static inline bool wlansap_dcs_is_wlan_interference_mitigation_enabled(
1765 					struct sap_context *sap_context)
1766 {
1767 	return false;
1768 }
1769 
wlansap_dcs_get_freq(struct sap_context * sap_context)1770 static inline qdf_freq_t wlansap_dcs_get_freq(struct sap_context *sap_context)
1771 {
1772 	return 0;
1773 }
1774 #endif
1775 
1776 /**
1777  * wlansap_filter_vendor_unsafe_ch_freq() - filter sap acs ch list by
1778  *  vendor unsafe ch freq ranges
1779  * @sap_context: sap context
1780  * @sap_config: sap conifg
1781  *
1782  * This function is used to filter out unsafe channel frequency from acs
1783  * channel frequency list based on vendor unsafe channel frequency ranges.
1784  *
1785  * Return: true if vendor unsafe ch range is present, otherwise false
1786  */
1787 bool wlansap_filter_vendor_unsafe_ch_freq(
1788 	struct sap_context *sap_context, struct sap_config *sap_config);
1789 
1790 /**
1791  * wlansap_dump_acs_ch_freq() - print acs channel frequency
1792  * @sap_context: sap context
1793  *
1794  * This function is used to print acs channel frequecny
1795  *
1796  * Return: None
1797  */
1798 void wlansap_dump_acs_ch_freq(struct sap_context *sap_context);
1799 
1800 /**
1801  * wlansap_set_acs_ch_freq() - set acs channel frequency
1802  * @sap_context: sap context
1803  * @ch_freq: ch_freq to be set
1804  *
1805  * This function is used to set acs channel frequency
1806  *
1807  * Return: None
1808  */
1809 void wlansap_set_acs_ch_freq(struct sap_context *sap_context,
1810 			     qdf_freq_t ch_freq);
1811 
1812 /**
1813  * sap_acquire_vdev_ref() - Increment reference count for vdev object
1814  * @psoc: Object Manager PSoC object
1815  * @sap_ctx: to store vdev object pointer
1816  * @session_id: used to get vdev object
1817  *
1818  * This function is used to increment vdev object reference count and store
1819  * vdev pointer in sap_ctx.
1820  *
1821  * Return: QDF_STATUS_SUCCESS - If able to get vdev object reference
1822  *				else qdf status failure codes
1823  */
1824 QDF_STATUS sap_acquire_vdev_ref(struct wlan_objmgr_psoc *psoc,
1825 				struct sap_context *sap_ctx,
1826 				uint8_t session_id);
1827 
1828 /**
1829  * sap_dump_acs_channel() - dump acs channel list
1830  * @acs_cfg: acs config
1831  *
1832  * This function dump acs channel list
1833  *
1834  * Return: void.
1835  */
1836 void sap_dump_acs_channel(struct sap_acs_cfg *acs_cfg);
1837 
1838 /**
1839  * sap_release_vdev_ref() - Decrement reference count for vdev object
1840  * @sap_ctx: for which vdev reference is to be decremented
1841  *
1842  * Return: None
1843  */
1844 void sap_release_vdev_ref(struct sap_context *sap_ctx);
1845 
1846 #ifdef CONFIG_AFC_SUPPORT
1847 /**
1848  * sap_afc_dcs_sel_chan() - API to select best SAP best channel/bandwidth with
1849  *                          channel ACS weighted algorithm
1850  * @sap_ctx: SAP context handle
1851  * @cur_freq: SAP current home channel frequency
1852  * @cur_bw: SAP current channel bandwidth
1853  * @pref_bw: pointer to channel bandwidth prefer to set as input, and target
1854  *           channel bandwidth can set as output
1855  *
1856  * Return: target home channel frequency selected
1857  */
1858 qdf_freq_t sap_afc_dcs_sel_chan(struct sap_context *sap_ctx,
1859 				qdf_freq_t cur_freq,
1860 				enum phy_ch_width cur_bw,
1861 				enum phy_ch_width *pref_bw);
1862 #endif
1863 
1864 #ifdef WLAN_FEATURE_11BE
1865 /**
1866  * sap_phymode_is_eht() - Is sap phymode EHT
1867  * @phymode: phy mode
1868  *
1869  * Return: true if phy mode is EHT
1870  */
1871 bool sap_phymode_is_eht(eCsrPhyMode phymode);
1872 
1873 /**
1874  * sap_acs_is_puncture_applicable() - Is static puncturing applicable according
1875  *                                    to ACS configure of given sap acs config.
1876  * @acs_cfg: pointer to sap_acs_cfg
1877  *
1878  * Return: true if static puncturing is applicable to given sap acs config.
1879  */
1880 bool sap_acs_is_puncture_applicable(struct sap_acs_cfg *acs_cfg);
1881 
1882 /**
1883  * sap_acs_set_puncture_support() - Set puncturing support according
1884  *                                  to ACS configure of given sap.
1885  * @sap_ctx: Pointer to SAP Context
1886  * @ch_params: pointer to ch_params
1887  *
1888  * Return: void.
1889  */
1890 void sap_acs_set_puncture_support(struct sap_context *sap_ctx,
1891 				  struct ch_params *ch_params);
1892 #else
sap_phymode_is_eht(eCsrPhyMode phymode)1893 static inline bool sap_phymode_is_eht(eCsrPhyMode phymode)
1894 {
1895 	return false;
1896 }
1897 
sap_acs_is_puncture_applicable(struct sap_acs_cfg * acs_cfg)1898 static inline bool sap_acs_is_puncture_applicable(struct sap_acs_cfg *acs_cfg)
1899 {
1900 	return false;
1901 }
1902 
sap_acs_set_puncture_support(struct sap_context * sap_ctx,struct ch_params * ch_params)1903 static inline void sap_acs_set_puncture_support(struct sap_context *sap_ctx,
1904 						struct ch_params *ch_params)
1905 {
1906 }
1907 #endif /* WLAN_FEATURE_11BE */
1908 
1909 /**
1910  * sap_cac_end_notify() - Notify CAC end to HDD
1911  * @mac_handle: Opaque handle to the global MAC context
1912  * @roamInfo: pointer to the struct csr_roam_info
1913  *
1914  * Function will be called to notify eSAP_DFS_CAC_END event to HDD
1915  *
1916  * Return: QDF_STATUS_SUCCESS if the notification was sent, otherwise
1917  *         an appropriate QDF_STATUS error
1918  */
1919 QDF_STATUS sap_cac_end_notify(mac_handle_t mac_handle,
1920 			      struct csr_roam_info *roamInfo);
1921 
1922 #ifdef WLAN_FEATURE_SAP_ACS_OPTIMIZE
sap_is_acs_scan_optimize_enable(void)1923 static inline bool sap_is_acs_scan_optimize_enable(void)
1924 {
1925 	return true;
1926 }
1927 
1928 void wlansap_process_chan_info_event(struct sap_context *sap_ctx,
1929 				     struct csr_roam_info *roam_info);
1930 #else
sap_is_acs_scan_optimize_enable(void)1931 static inline bool sap_is_acs_scan_optimize_enable(void)
1932 {
1933 	return false;
1934 }
1935 
1936 static inline
wlansap_process_chan_info_event(struct sap_context * sap_ctx,struct csr_roam_info * roam_info)1937 void wlansap_process_chan_info_event(struct sap_context *sap_ctx,
1938 				     struct csr_roam_info *roam_info)
1939 {
1940 }
1941 #endif
1942 
1943 /**
1944  * wlansap_update_ll_lt_sap_acs_result() - Update acs result of LL_LT_SAP
1945  * @sap_ctx: sap context
1946  * @last_acs_freq: last acs frequency to be set
1947  *
1948  * This function is used to update stored acs channel frequency
1949  *
1950  * Return: None
1951  */
1952 void wlansap_update_ll_lt_sap_acs_result(struct sap_context *sap_ctx,
1953 					 qdf_freq_t last_acs_freq);
1954 
1955 /**
1956  * wlansap_update_sap_chan_list() - set channel list of sap
1957  * @sap_config: sap config
1958  * @freq_list: freq list sent by userspace
1959  * @count: valid freq count
1960  *
1961  * Return: 0 on success, else error number
1962  */
1963 int wlansap_update_sap_chan_list(struct sap_config *sap_config,
1964 				 qdf_freq_t *freq_list, uint16_t count);
1965 
1966 /**
1967  * wlansap_sort_channel_list() - Sort channel list
1968  * @vdev_id: Vdev Id
1969  * @list: List of channels which needs to sort
1970  * @ch_info: Fill sorted channels list in ch_info
1971  *
1972  * Return: QDF_STATUS
1973  */
1974 QDF_STATUS wlansap_sort_channel_list(uint8_t vdev_id, qdf_list_t *list,
1975 				     struct sap_sel_ch_info *ch_info);
1976 
1977 /**
1978  * wlansap_free_chan_info() - API to free allocated memory
1979  * @ch_param: Pointer to sap_sel_ch_info structure
1980  *
1981  * Return: None
1982  */
1983 void wlansap_free_chan_info(struct sap_sel_ch_info *ch_param);
1984 
1985 /**
1986  * wlansap_get_user_config_acs_ch_list() - Get user config ACS channel list
1987  * @vdev_id: Vdev Id
1988  * @filter: Filter to apply to get scan result
1989  *
1990  * Return: None
1991  */
1992 void wlansap_get_user_config_acs_ch_list(uint8_t vdev_id,
1993 					 struct scan_filter *filter);
1994 #ifdef __cplusplus
1995 }
1996 #endif
1997 #endif /* #ifndef WLAN_QCT_WLANSAP_H */
1998