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