xref: /wlan-dirver/qcacld-3.0/core/sap/inc/sap_api.h (revision af88fc7dfcd4d710a850de08f8ee561cd4d43663)
1 /*
2  * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
3  *
4  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5  *
6  *
7  * Permission to use, copy, modify, and/or distribute this software for
8  * any purpose with or without fee is hereby granted, provided that the
9  * above copyright notice and this permission notice appear in all
10  * copies.
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19  * PERFORMANCE OF THIS SOFTWARE.
20  */
21 
22 /*
23  * This file was originally distributed by Qualcomm Atheros, Inc.
24  * under proprietary terms before Copyright ownership was assigned
25  * to the Linux Foundation.
26  */
27 
28 #ifndef WLAN_QCT_WLANSAP_H
29 #define WLAN_QCT_WLANSAP_H
30 
31 /**
32  * W L A N   S O F T A P  P A L   L A Y E R
33  * E X T E R N A L  A P I
34  *
35  * DESCRIPTION
36  * This file contains the external API exposed by the wlan SAP PAL layer
37  *  module.
38  */
39 
40 /*----------------------------------------------------------------------------
41  * Include Files
42  * -------------------------------------------------------------------------*/
43 #include "cds_api.h"
44 #include "cds_packet.h"
45 #include "qdf_types.h"
46 
47 #include "p2p_api.h"
48 #include "sme_api.h"
49 /*----------------------------------------------------------------------------
50  * Preprocessor Definitions and Constants
51  * -------------------------------------------------------------------------*/
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
56 /*---------------------------------------------------------------------------
57  * defines and enum
58  *--------------------------------------------------------------------------*/
59 #define       MAX_SSID_LEN                 32
60 #define       MAX_ACL_MAC_ADDRESS          32
61 #define       AUTO_CHANNEL_SELECT          0
62 #define       MAX_ASSOC_IND_IE_LEN         255
63 
64 /* defines for WPS config states */
65 #define       SAP_WPS_DISABLED             0
66 #define       SAP_WPS_ENABLED_UNCONFIGURED 1
67 #define       SAP_WPS_ENABLED_CONFIGURED   2
68 #define       MAX_NAME_SIZE                64
69 #define       MAX_TEXT_SIZE                32
70 
71 #define       MAX_CHANNEL_LIST_LEN         256
72 #define       QDF_MAX_NO_OF_SAP_MODE       2    /* max # of SAP */
73 #define       SAP_MAX_NUM_SESSION          5
74 #define       SAP_MAX_OBSS_STA_CNT         1    /* max # of OBSS STA */
75 #define       SAP_ACS_WEIGHT_MAX           (4444)
76 
77 /*--------------------------------------------------------------------------
78  * reasonCode taken from 802.11 standard.
79  * ------------------------------------------------------------------------*/
80 
81 typedef enum {
82 	eSAP_RC_RESERVED0,              /*0 */
83 	eSAP_RC_UNSPECIFIED,            /*1 */
84 	eSAP_RC_PREV_AUTH_INVALID,      /*2 */
85 	eSAP_RC_STA_LEFT_DEAUTH,        /*3 */
86 	eSAP_RC_INACTIVITY_DISASSOC,    /*4 */
87 	eSAP_RC_AP_CAPACITY_FULL,       /*5 */
88 	eSAP_RC_CLS2_FROM_NON_AUTH_STA, /*6 */
89 	eSAP_RC_CLS3_FROM_NON_AUTH_STA, /*7 */
90 	eSAP_RC_STA_LEFT_DISASSOC,      /*8 */
91 	eSAP_RC_STA_NOT_AUTH,           /*9 */
92 	eSAP_RC_PC_UNACCEPTABLE,        /*10 */
93 	eSAP_RC_SC_UNACCEPTABLE,        /*11 */
94 	eSAP_RC_RESERVED1,              /*12 */
95 	eSAP_RC_INVALID_IE,             /*13 */
96 	eSAP_RC_MIC_FAIL,               /*14 */
97 	eSAP_RC_4_WAY_HANDSHAKE_TO,     /*15 */
98 	eSAP_RC_GO_KEY_HANDSHAKE_TO,    /*16 */
99 	eSAP_RC_IE_MISMATCH,            /*17 */
100 	eSAP_RC_INVALID_GRP_CHIPHER,    /*18 */
101 	eSAP_RC_INVALID_PAIR_CHIPHER,   /*19 */
102 	eSAP_RC_INVALID_AKMP,           /*20 */
103 	eSAP_RC_UNSUPPORTED_RSN,        /*21 */
104 	eSAP_RC_INVALID_RSN,            /*22 */
105 	eSAP_RC_1X_AUTH_FAILED,         /*23 */
106 	eSAP_RC_CHIPER_SUITE_REJECTED,  /*24 */
107 } eSapReasonCode;
108 
109 typedef enum {
110 	eSAP_ACCEPT_UNLESS_DENIED = 0,
111 	eSAP_DENY_UNLESS_ACCEPTED = 1,
112 	/* this type is added to support accept & deny list at the same time */
113 	eSAP_SUPPORT_ACCEPT_AND_DENY = 2,
114 	/*In this mode all MAC addresses are allowed to connect */
115 	eSAP_ALLOW_ALL = 3,
116 } eSapMacAddrACL;
117 
118 typedef enum {
119 	eSAP_BLACK_LIST = 0,   /* List of mac addresses NOT allowed to assoc */
120 	eSAP_WHITE_LIST = 1,   /* List of mac addresses allowed to assoc */
121 } eSapACLType;
122 
123 typedef enum {
124 	ADD_STA_TO_ACL = 0,       /* cmd to add STA to access control list */
125 	DELETE_STA_FROM_ACL = 1,  /* cmd to del STA from access control list */
126 } eSapACLCmdType;
127 
128 typedef enum {
129 	eSAP_START_BSS_EVENT = 0,     /* Event sent when BSS is started */
130 	eSAP_STOP_BSS_EVENT,          /* Event sent when BSS is stopped */
131 	eSAP_STA_ASSOC_IND,           /* Indicate assoc req to upper layers */
132 	/*
133 	 * Event sent when we have successfully associated a station and
134 	 * upper layer neeeds to allocate a context
135 	 */
136 	eSAP_STA_ASSOC_EVENT,
137 	/*
138 	 * Event sent when we have successfully reassociated a station and
139 	 * upper layer neeeds to allocate a context
140 	 */
141 	eSAP_STA_REASSOC_EVENT,
142 	/*
143 	 * Event sent when associated a station has disassociated as a
144 	 * result of various conditions
145 	 */
146 	eSAP_STA_DISASSOC_EVENT,
147 	/* Event sent when user called wlansap_set_key_sta */
148 	eSAP_STA_SET_KEY_EVENT,
149 	/* Event sent whenever there is MIC failure detected */
150 	eSAP_STA_MIC_FAILURE_EVENT,
151 	/* Event sent when user called wlansap_get_assoc_stations */
152 	eSAP_ASSOC_STA_CALLBACK_EVENT,
153 	/* Event send when user call  wlansap_get_wps_session_overlap */
154 	eSAP_GET_WPSPBC_SESSION_EVENT,
155 	/* Event send on WPS PBC probe request is received */
156 	eSAP_WPS_PBC_PROBE_REQ_EVENT,
157 	eSAP_REMAIN_CHAN_READY,
158 	eSAP_DISCONNECT_ALL_P2P_CLIENT,
159 	eSAP_MAC_TRIG_STOP_BSS_EVENT,
160 	/*
161 	 * Event send when a STA in neither white list or black list tries to
162 	 * associate in softap mode
163 	 */
164 	eSAP_UNKNOWN_STA_JOIN,
165 	/* Event send when a new STA is rejected association since softAP
166 	 * max assoc limit has reached
167 	 */
168 	eSAP_MAX_ASSOC_EXCEEDED,
169 	eSAP_CHANNEL_CHANGE_EVENT,
170 	eSAP_DFS_CAC_START,
171 	eSAP_DFS_CAC_INTERRUPTED,
172 	eSAP_DFS_CAC_END,
173 	eSAP_DFS_PRE_CAC_END,
174 	eSAP_DFS_RADAR_DETECT,
175 	eSAP_DFS_RADAR_DETECT_DURING_PRE_CAC,
176 	/* Event sent when user need to get the DFS NOL from CNSS */
177 	eSAP_DFS_NOL_GET,
178 	/* Event sent when user need to set the DFS NOL to CNSS */
179 	eSAP_DFS_NOL_SET,
180 	/* No ch available after DFS RADAR detect */
181 	eSAP_DFS_NO_AVAILABLE_CHANNEL,
182 	eSAP_ACS_SCAN_SUCCESS_EVENT,
183 	eSAP_ACS_CHANNEL_SELECTED,
184 	eSAP_ECSA_CHANGE_CHAN_IND,
185 } eSapHddEvent;
186 
187 typedef enum {
188 	eSAP_OPEN_SYSTEM,
189 	eSAP_SHARED_KEY,
190 	eSAP_AUTO_SWITCH
191 } eSapAuthType;
192 
193 typedef enum {
194 	/* Disassociation was internally initated from CORE stack */
195 	eSAP_MAC_INITATED_DISASSOC = 0x10000,
196 	/*
197 	 * Disassociation was internally initated from host by
198 	 * invoking wlansap_disassoc_sta call
199 	 */
200 	eSAP_USR_INITATED_DISASSOC
201 } eSapDisassocReason;
202 
203 /*Handle bool over here*/
204 typedef enum {
205 	eSAP_FALSE,
206 	eSAP_TRUE,
207 } eSapBool;
208 
209 typedef enum {
210 	eSAP_DFS_NOL_CLEAR,
211 	eSAP_DFS_NOL_RANDOMIZE,
212 } eSapDfsNolType;
213 
214 /*---------------------------------------------------------------------------
215   SAP PAL "status" and "reason" error code defines
216   ---------------------------------------------------------------------------*/
217 typedef enum {
218 	eSAP_STATUS_SUCCESS,            /* Success.  */
219 	eSAP_STATUS_FAILURE,            /* General Failure.  */
220 	/* Channel not selected during intial scan.  */
221 	eSAP_START_BSS_CHANNEL_NOT_SELECTED,
222 	eSAP_ERROR_MAC_START_FAIL,     /* Failed to start Infra BSS */
223 } eSapStatus;
224 
225 /*---------------------------------------------------------------------------
226   SAP PAL "status" and "reason" error code defines
227   ---------------------------------------------------------------------------*/
228 typedef enum {
229 	eSAP_WPSPBC_OVERLAP_IN120S,  /* Overlap */
230 	/* no WPS probe request in 120 second */
231 	eSAP_WPSPBC_NO_WPSPBC_PROBE_REQ_IN120S,
232 	/* One WPS probe request in 120 second  */
233 	eSAP_WPSPBC_ONE_WPSPBC_PROBE_REQ_IN120S,
234 } eWPSPBCOverlap;
235 
236 /*----------------------------------------------------------------------------
237  *  Typedefs
238  * -------------------------------------------------------------------------*/
239 typedef struct sap_StartBssCompleteEvent_s {
240 	uint8_t status;
241 	uint8_t operatingChannel;
242 	uint16_t staId;         /* self StaID */
243 	uint8_t sessionId;      /* SoftAP SME session ID */
244 } tSap_StartBssCompleteEvent;
245 
246 typedef struct sap_StopBssCompleteEvent_s {
247 	uint8_t status;
248 } tSap_StopBssCompleteEvent;
249 
250 typedef struct sap_StationAssocIndication_s {
251 	struct qdf_mac_addr staMac;
252 	uint8_t assoId;
253 	uint8_t staId;
254 	uint8_t status;
255 	/* Required for indicating the frames to upper layer */
256 	uint32_t beaconLength;
257 	uint8_t *beaconPtr;
258 	uint32_t assocReqLength;
259 	uint8_t *assocReqPtr;
260 	bool fWmmEnabled;
261 	eCsrAuthType negotiatedAuthType;
262 	eCsrEncryptionType negotiatedUCEncryptionType;
263 	eCsrEncryptionType negotiatedMCEncryptionType;
264 	bool fAuthRequired;
265 } tSap_StationAssocIndication;
266 
267 typedef struct sap_StationAssocReassocCompleteEvent_s {
268 	struct qdf_mac_addr staMac;
269 	uint8_t staId;
270 	uint8_t status;
271 	uint8_t ies[MAX_ASSOC_IND_IE_LEN];
272 	uint16_t iesLen;
273 	uint32_t statusCode;
274 	eSapAuthType SapAuthType;
275 	bool wmmEnabled;
276 	/* Required for indicating the frames to upper layer */
277 	uint32_t beaconLength;
278 	uint8_t *beaconPtr;
279 	uint32_t assocReqLength;
280 	uint8_t *assocReqPtr;
281 	uint32_t assocRespLength;
282 	uint8_t *assocRespPtr;
283 	uint8_t timingMeasCap;
284 	tSirSmeChanInfo chan_info;
285 } tSap_StationAssocReassocCompleteEvent;
286 
287 typedef struct sap_StationDisassocCompleteEvent_s {
288 	struct qdf_mac_addr staMac;
289 	uint8_t staId;          /* STAID should not be used */
290 	uint8_t status;
291 	uint32_t statusCode;
292 	eSapDisassocReason reason;
293 } tSap_StationDisassocCompleteEvent;
294 
295 typedef struct sap_StationSetKeyCompleteEvent_s {
296 	uint8_t status;
297 	struct qdf_mac_addr peerMacAddr;
298 } tSap_StationSetKeyCompleteEvent;
299 
300 /*struct corresponding to SAP_STA_MIC_FAILURE_EVENT */
301 typedef struct sap_StationMICFailureEvent_s {
302 	struct qdf_mac_addr srcMacAddr;    /* address used to compute MIC */
303 	struct qdf_mac_addr staMac;        /* taMacAddr transmitter address */
304 	struct qdf_mac_addr dstMacAddr;
305 	eSapBool multicast;
306 	uint8_t IV1;            /* first byte of IV */
307 	uint8_t keyId;          /* second byte of IV */
308 	uint8_t TSC[SIR_CIPHER_SEQ_CTR_SIZE];           /* sequence number */
309 
310 } tSap_StationMICFailureEvent;
311 /*Structure to return MAC address of associated stations */
312 typedef struct sap_AssocMacAddr_s {
313 	struct qdf_mac_addr staMac; /* Associated station's MAC address */
314 	uint8_t assocId;            /* Associated station's Association ID */
315 	uint8_t staId;              /* Allocated station Id */
316 	uint8_t ShortGI40Mhz;
317 	uint8_t ShortGI20Mhz;
318 	uint8_t Support40Mhz;
319 	uint32_t requestedMCRate;
320 	tSirSupportedRates supportedRates;
321 } tSap_AssocMacAddr, *tpSap_AssocMacAddr;
322 
323 /*struct corresponding to SAP_ASSOC_STA_CALLBACK_EVENT */
324 typedef struct sap_AssocStaListEvent_s {
325 	QDF_MODULE_ID module;
326 	/* module id that was passed in wlansap_get_assoc_stations API */
327 	uint8_t noOfAssocSta;           /* Number of associated stations */
328 	tpSap_AssocMacAddr pAssocStas;
329 	/*
330 	 * Pointer to pre allocated memory to obtain list of
331 	 * associated stations passed in wlansap_get_assoc_stations API
332 	 */
333 } tSap_AssocStaListEvent;
334 
335 typedef struct sap_GetWPSPBCSessionEvent_s {
336 	uint8_t status;
337 	/* module id that was passed in wlansap_get_assoc_stations API */
338 	QDF_MODULE_ID module;
339 	uint8_t UUID_E[16];             /* Unique identifier of the AP. */
340 	struct qdf_mac_addr addr;
341 	eWPSPBCOverlap wpsPBCOverlap;
342 } tSap_GetWPSPBCSessionEvent;
343 
344 typedef struct sap_WPSPBCProbeReqEvent_s {
345 	uint8_t status;
346 	/* module id that was passed in wlansap_get_assoc_stations API */
347 	QDF_MODULE_ID module;
348 	tSirWPSPBCProbeReq WPSPBCProbeReq;
349 } tSap_WPSPBCProbeReqEvent;
350 
351 typedef struct sap_ManagementFrameInfo_s {
352 	uint32_t nFrameLength;
353 	uint8_t frameType;
354 	uint32_t rxChan;           /* Channel of where packet is received */
355 	/*
356 	 * Point to a buffer contain the beacon, assoc req, assoc rsp frame,
357 	 * in that order user needs to use nBeaconLength, nAssocReqLength,
358 	 * nAssocRspLength to desice where each frame starts and ends.
359 	 */
360 	uint8_t *pbFrames;
361 } tSap_ManagementFrameInfo;
362 
363 typedef struct sap_SendActionCnf_s {
364 	eSapStatus actionSendSuccess;
365 } tSap_SendActionCnf;
366 
367 typedef struct sap_UnknownSTAJoinEvent_s {
368 	struct qdf_mac_addr macaddr;
369 } tSap_UnknownSTAJoinEvent;
370 
371 typedef struct sap_MaxAssocExceededEvent_s {
372 	struct qdf_mac_addr macaddr;
373 } tSap_MaxAssocExceededEvent;
374 
375 typedef struct sap_DfsNolInfo_s {
376 	uint16_t sDfsList;              /* size of pDfsList in byte */
377 	void *pDfsList;             /* pointer to pDfsList buffer */
378 } tSap_DfsNolInfo;
379 
380 /**
381  * sap_acs_ch_selected_s - the structure to hold the selected channels
382  * @pri_channel:	   Holds the ACS selected primary channel
383  * @sec_channel:	   Holds the ACS selected secondary channel
384  *
385  * Holds the primary and secondary channel selected by ACS and is
386  * used to send it to the HDD.
387  */
388 struct sap_ch_selected_s {
389 	uint16_t pri_ch;
390 	uint16_t ht_sec_ch;
391 	uint16_t vht_seg0_center_ch;
392 	uint16_t vht_seg1_center_ch;
393 	uint16_t ch_width;
394 };
395 
396 /**
397  * sap_roc_ready_ind_s - the structure to hold the scan id
398  * @scan_id: scan identifier
399  *
400  * Holds scan identifier
401  */
402 struct sap_roc_ready_ind_s {
403 	uint32_t scan_id;
404 };
405 
406 /**
407  * struct sap_acs_scan_complete_event - acs scan complete event
408  * @status: status of acs scan
409  * @channellist: acs scan channels
410  * @num_of_channels: number of channels
411  */
412 struct sap_acs_scan_complete_event{
413 	uint8_t status;
414 	uint8_t *channellist;
415 	uint8_t num_of_channels;
416 };
417 
418 /**
419  * struct sap_ch_change_ind - channel change indication
420  * @new_chan: channel to change
421  */
422 struct sap_ch_change_ind {
423 	uint16_t new_chan;
424 };
425 
426 /*
427  * This struct will be filled in and passed to tpWLAN_SAPEventCB that is
428  * provided during wlansap_start_bss call The event id corresponding to
429  * structure  in the union is defined in comment next to the structure
430  */
431 
432 typedef struct sap_Event_s {
433 	eSapHddEvent sapHddEventCode;
434 	union {
435 		/*SAP_START_BSS_EVENT */
436 		tSap_StartBssCompleteEvent sapStartBssCompleteEvent;
437 		/*SAP_STOP_BSS_EVENT */
438 		tSap_StopBssCompleteEvent sapStopBssCompleteEvent;
439 		/*SAP_ASSOC_INDICATION */
440 		tSap_StationAssocIndication sapAssocIndication;
441 		/*SAP_STA_ASSOC_EVENT, SAP_STA_REASSOC_EVENT */
442 		tSap_StationAssocReassocCompleteEvent
443 				sapStationAssocReassocCompleteEvent;
444 		/*SAP_STA_DISASSOC_EVENT */
445 		tSap_StationDisassocCompleteEvent
446 				sapStationDisassocCompleteEvent;
447 		/*SAP_STA_SET_KEY_EVENT */
448 		tSap_StationSetKeyCompleteEvent sapStationSetKeyCompleteEvent;
449 		/*SAP_STA_MIC_FAILURE_EVENT */
450 		tSap_StationMICFailureEvent sapStationMICFailureEvent;
451 		/*SAP_ASSOC_STA_CALLBACK_EVENT */
452 		tSap_AssocStaListEvent sapAssocStaListEvent;
453 		/*SAP_GET_WPSPBC_SESSION_EVENT */
454 		tSap_GetWPSPBCSessionEvent sapGetWPSPBCSessionEvent;
455 		/*eSAP_WPS_PBC_PROBE_REQ_EVENT */
456 		tSap_WPSPBCProbeReqEvent sapPBCProbeReqEvent;
457 		tSap_SendActionCnf sapActionCnf;
458 		/* eSAP_UNKNOWN_STA_JOIN */
459 		tSap_UnknownSTAJoinEvent sapUnknownSTAJoin;
460 		/* eSAP_MAX_ASSOC_EXCEEDED */
461 		tSap_MaxAssocExceededEvent sapMaxAssocExceeded;
462 		/*eSAP_DFS_NOL_XXX */
463 		tSap_DfsNolInfo sapDfsNolInfo;
464 		struct sap_ch_selected_s sap_ch_selected;
465 		struct sap_roc_ready_ind_s sap_roc_ind;
466 		struct sap_ch_change_ind sap_chan_cng_ind;
467 		struct sap_acs_scan_complete_event sap_acs_scan_comp;
468 	} sapevt;
469 } tSap_Event, *tpSap_Event;
470 
471 typedef struct sap_SSID {
472 	uint8_t length;
473 	uint8_t ssId[MAX_SSID_LEN];
474 } qdf_packed tSap_SSID_t;
475 
476 typedef struct sap_SSIDInfo {
477 	tSap_SSID_t ssid;     /* SSID of the AP */
478 	/* SSID should/shouldn't be bcast in probe RSP & beacon */
479 	uint8_t ssidHidden;
480 } qdf_packed tSap_SSIDInfo_t;
481 
482 struct sap_acs_cfg {
483 	/* ACS Algo Input */
484 	uint8_t    acs_mode;
485 	uint32_t    hw_mode;
486 	uint8_t    start_ch;
487 	uint8_t    end_ch;
488 	uint8_t    *ch_list;
489 	uint8_t    ch_list_count;
490 #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE
491 	uint8_t    skip_scan_status;
492 	uint8_t    skip_scan_range1_stch;
493 	uint8_t    skip_scan_range1_endch;
494 	uint8_t    skip_scan_range2_stch;
495 	uint8_t    skip_scan_range2_endch;
496 #endif
497 
498 	uint16_t   ch_width;
499 	uint8_t    pcl_channels[QDF_MAX_NUM_CHAN];
500 	uint32_t   pcl_ch_count;
501 	/* ACS Algo Output */
502 	uint8_t    pri_ch;
503 	uint8_t    ht_sec_ch;
504 	uint8_t    vht_seg0_center_ch;
505 	uint8_t    vht_seg1_center_ch;
506 };
507 
508 /*
509  * enum vendor_ie_access_policy- access policy
510  * @ACCESS_POLICY_NONE: access policy attribute is not valid
511  * @ACCESS_POLICY_RESPOND_IF_IE_IS_PRESENT: respond to probe req/assoc req
512  *  only if ie is present
513  * @ACCESS_POLICY_DONOT_RESPOND_IF_IE_IS_PRESENT: do not respond to probe req/
514  *  assoc req if ie is present
515 */
516 enum vendor_ie_access_policy {
517 	ACCESS_POLICY_NONE,
518 	ACCESS_POLICY_RESPOND_IF_IE_IS_PRESENT,
519 	ACCESS_POLICY_DONOT_RESPOND_IF_IE_IS_PRESENT,
520 };
521 
522 /*
523  * enum sap_acs_dfs_mode- state of DFS mode
524  * @ACS_DFS_MODE_NONE: DFS mode attribute is not valid
525  * @ACS_DFS_MODE_ENABLE:  DFS mode is enabled
526  * @ACS_DFS_MODE_DISABLE: DFS mode is disabled
527  * @ACS_DFS_MODE_DEPRIORITIZE: Deprioritize DFS channels in scanning
528  */
529 enum  sap_acs_dfs_mode {
530 	ACS_DFS_MODE_NONE,
531 	ACS_DFS_MODE_ENABLE,
532 	ACS_DFS_MODE_DISABLE,
533 	ACS_DFS_MODE_DEPRIORITIZE
534 };
535 
536 typedef struct sap_Config {
537 	tSap_SSIDInfo_t SSIDinfo;
538 	eCsrPhyMode SapHw_mode;         /* Wireless Mode */
539 	eSapMacAddrACL SapMacaddr_acl;
540 	struct qdf_mac_addr accept_mac[MAX_ACL_MAC_ADDRESS]; /* MAC filtering */
541 	bool ieee80211d;      /* Specify if 11D is enabled or disabled */
542 	bool protEnabled;     /* Specify if protection is enabled or disabled */
543 	/* Specify if OBSS protection is enabled or disabled */
544 	bool obssProtEnabled;
545 	struct qdf_mac_addr deny_mac[MAX_ACL_MAC_ADDRESS];  /* MAC filtering */
546 	struct qdf_mac_addr self_macaddr;       /* self macaddress or BSSID */
547 	uint8_t channel;          /* Operation channel */
548 	uint8_t sec_ch;
549 	struct ch_params_s ch_params;
550 	uint32_t ch_width_orig;
551 	uint8_t max_num_sta;      /* maximum number of STAs in station table */
552 	uint8_t dtim_period;      /* dtim interval */
553 	uint8_t num_accept_mac;
554 	uint8_t num_deny_mac;
555 	/* Max ie length 255 * 2(WPA+RSN) + 2 bytes(vendor specific ID) * 2 */
556 	uint8_t RSNWPAReqIE[(SIR_MAC_MAX_IE_LENGTH * 2) + 4];
557 	/* it is ignored if [0] is 0. */
558 	uint8_t countryCode[WNI_CFG_COUNTRY_CODE_LEN];
559 	uint8_t RSNAuthType;
560 	uint8_t RSNEncryptType;
561 	uint8_t mcRSNEncryptType;
562 	eSapAuthType authType;
563 	bool privacy;
564 	bool UapsdEnable;
565 	bool fwdWPSPBCProbeReq;
566 	/* 0 - disabled, 1 - not configured , 2 - configured */
567 	uint8_t wps_state;
568 	uint16_t ht_capab;
569 	uint16_t RSNWPAReqIELength;     /* The byte count in the pWPAReqIE */
570 	uint32_t beacon_int;            /* Beacon Interval */
571 	uint32_t ap_table_max_size;
572 	uint32_t ap_table_expiration_time;
573 	uint32_t ht_op_mode_fixed;
574 	enum tQDF_ADAPTER_MODE persona; /* Tells us which persona, GO or AP */
575 	uint8_t disableDFSChSwitch;
576 	bool enOverLapCh;
577 #ifdef WLAN_FEATURE_11W
578 	bool mfpRequired;
579 	bool mfpCapable;
580 #endif
581 #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
582 	uint8_t cc_switch_mode;
583 #endif
584 	struct sap_acs_cfg acs_cfg;
585 	uint16_t probeRespIEsBufferLen;
586 	/* buffer for addn ies comes from hostapd */
587 	void *pProbeRespIEsBuffer;
588 	uint16_t assocRespIEsLen;
589 	/* buffer for addn ies comes from hostapd */
590 	void *pAssocRespIEsBuffer;
591 	uint16_t probeRespBcnIEsLen;
592 	/* buffer for addn ies comes from hostapd */
593 	void *pProbeRespBcnIEsBuffer;
594 	uint8_t sap_dot11mc; /* Specify if 11MC is enabled or disabled*/
595 	uint8_t beacon_tx_rate;
596 	uint8_t *vendor_ie;
597 	enum vendor_ie_access_policy vendor_ie_access_policy;
598 	uint16_t sta_inactivity_timeout;
599 	uint16_t tx_pkt_fail_cnt_threshold;
600 	uint8_t short_retry_limit;
601 	uint8_t long_retry_limit;
602 	uint8_t ampdu_size;
603 	tSirMacRateSet supported_rates;
604 	tSirMacRateSet extended_rates;
605 	enum sap_acs_dfs_mode acs_dfs_mode;
606 } tsap_Config_t;
607 
608 #ifdef FEATURE_WLAN_AP_AP_ACS_OPTIMIZE
609 typedef enum {
610 	eSAP_DO_NEW_ACS_SCAN,
611 	eSAP_DO_PAR_ACS_SCAN,
612 	eSAP_SKIP_ACS_SCAN
613 } tSap_skip_acs_scan;
614 #endif
615 
616 typedef enum {
617 	eSAP_WPS_PROBE_RSP_IE,
618 	eSAP_WPS_BEACON_IE,
619 	eSAP_WPS_ASSOC_RSP_IE
620 } eSapWPSIE_CODE;
621 
622 typedef struct sSapName {
623 	uint8_t num_name;
624 	uint8_t name[MAX_NAME_SIZE];
625 } tSapName;
626 
627 typedef struct sSapText {
628 	uint8_t num_text;
629 	uint8_t text[MAX_TEXT_SIZE];
630 } tSapText;
631 
632 typedef enum {
633 	eSAP_DFS_DO_NOT_SKIP_CAC,
634 	eSAP_DFS_SKIP_CAC
635 } eSapDfsCACState_t;
636 
637 typedef enum {
638 	eSAP_DFS_CHANNEL_USABLE,
639 	eSAP_DFS_CHANNEL_AVAILABLE,
640 	eSAP_DFS_CHANNEL_UNAVAILABLE
641 } eSapDfsChanStatus_t;
642 
643 typedef struct sSapDfsNolInfo {
644 	uint8_t dfs_channel_number;
645 	eSapDfsChanStatus_t radar_status_flag;
646 	uint64_t radar_found_timestamp;
647 } tSapDfsNolInfo;
648 
649 typedef struct sSapDfsInfo {
650 	qdf_mc_timer_t sap_dfs_cac_timer;
651 	uint8_t sap_radar_found_status;
652 	/*
653 	 * New channel to move to when a  Radar is
654 	 * detected on current Channel
655 	 */
656 	uint8_t target_channel;
657 	uint8_t last_radar_found_channel;
658 	uint8_t ignore_cac;
659 	eSapDfsCACState_t cac_state;
660 	uint8_t user_provided_target_channel;
661 
662 	/*
663 	 * Requests for Channel Switch Announcement IE
664 	 * generation and transmission
665 	 */
666 	uint8_t csaIERequired;
667 	uint8_t numCurrentRegDomainDfsChannels;
668 	tSapDfsNolInfo sapDfsChannelNolList[NUM_5GHZ_CHANNELS];
669 	uint8_t is_dfs_cac_timer_running;
670 	/*
671 	 * New channel width and new channel bonding mode
672 	 * will only be updated via channel fallback mechanism
673 	 */
674 	enum phy_ch_width orig_chanWidth;
675 	enum phy_ch_width new_chanWidth;
676 	struct ch_params_s new_ch_params;
677 
678 	/*
679 	 * INI param to enable/disable SAP W53
680 	 * channel operation.
681 	 */
682 	uint8_t is_dfs_w53_disabled;
683 
684 	/*
685 	 * sap_operating_channel_location holds SAP indoor,
686 	 * outdoor location information. Currently, if this
687 	 * param is  set this Indoor/outdoor channel interop
688 	 * restriction will only be implemented for JAPAN
689 	 * regulatory domain.
690 	 *
691 	 * 0 - Indicates that location unknown
692 	 * (or) SAP Indoor/outdoor interop is allowed
693 	 *
694 	 * 1 - Indicates device is operating on Indoor channels
695 	 * and SAP cannot pick next random channel from outdoor
696 	 * list of channels when a radar is found on current operating
697 	 * DFS channel.
698 	 *
699 	 * 2 - Indicates device is operating on Outdoor Channels
700 	 * and SAP cannot pick next random channel from indoor
701 	 * list of channels when a radar is found on current
702 	 * operating DFS channel.
703 	 */
704 	uint8_t sap_operating_chan_preferred_location;
705 
706 	/*
707 	 * Flag to indicate if DFS test mode is enabled and
708 	 * channel switch is disabled.
709 	 */
710 	uint8_t disable_dfs_ch_switch;
711 } tSapDfsInfo;
712 
713 typedef struct tagSapCtxList {
714 	uint8_t sessionID;
715 	void *pSapContext;
716 	enum tQDF_ADAPTER_MODE sapPersona;
717 } tSapCtxList, tpSapCtxList;
718 
719 typedef struct tagSapStruct {
720 	/* Information Required for SAP DFS Master mode */
721 	tSapDfsInfo SapDfsInfo;
722 	tSapCtxList sapCtxList[SAP_MAX_NUM_SESSION];
723 #ifdef FEATURE_AP_MCC_CH_AVOIDANCE
724 	bool sap_channel_avoidance;
725 #endif /* FEATURE_AP_MCC_CH_AVOIDANCE */
726 	bool enable_dfs_phy_error_logs;
727 } tSapStruct, *tpSapStruct;
728 
729 #define WPS_PROBRSP_VER_PRESENT                          0x00000001
730 #define WPS_PROBRSP_STATE_PRESENT                        0x00000002
731 #define WPS_PROBRSP_APSETUPLOCK_PRESENT                  0x00000004
732 #define WPS_PROBRSP_SELECTEDREGISTRA_PRESENT             0x00000008
733 #define WPS_PROBRSP_DEVICEPASSWORDID_PRESENT             0x00000010
734 #define WPS_PROBRSP_SELECTEDREGISTRACFGMETHOD_PRESENT    0x00000020
735 #define WPS_PROBRSP_RESPONSETYPE_PRESENT                 0x00000040
736 #define WPS_PROBRSP_UUIDE_PRESENT                        0x00000080
737 #define WPS_PROBRSP_MANUFACTURE_PRESENT                  0x00000100
738 #define WPS_PROBRSP_MODELNAME_PRESENT                    0x00000200
739 #define WPS_PROBRSP_MODELNUMBER_PRESENT                  0x00000400
740 #define WPS_PROBRSP_SERIALNUMBER_PRESENT                 0x00000800
741 #define WPS_PROBRSP_PRIMARYDEVICETYPE_PRESENT            0x00001000
742 #define WPS_PROBRSP_DEVICENAME_PRESENT                   0x00002000
743 #define WPS_PROBRSP_CONFIGMETHODS_PRESENT                0x00004000
744 #define WPS_PROBRSP_RF_BANDS_PRESENT                     0x00008000
745 
746 typedef struct sap_WPSProbeRspIE_s {
747 	uint32_t FieldPresent;
748 	uint32_t Version;         /* Version. 0x10 = version 1.0, 0x11 = etc. */
749 	uint32_t wpsState;        /* 1 = unconfigured, 2 = configured. */
750 	bool APSetupLocked;       /* Must be included if value is true */
751 	/* indicates if user has recently activated a reg to add an Enrollee. */
752 	bool SelectedRegistra;
753 	uint16_t DevicePasswordID;              /* Device Password ID */
754 	/* Selected Registrar config method */
755 	uint16_t SelectedRegistraCfgMethod;
756 	uint8_t ResponseType;           /* Response type */
757 	uint8_t UUID_E[16];             /* Unique identifier of the AP. */
758 	tSapName Manufacture;
759 	tSapText ModelName;
760 	tSapText ModelNumber;
761 	tSapText SerialNumber;
762 	/* Device Category ID: 1Computer, 2Input Device, ... */
763 	uint32_t PrimaryDeviceCategory;
764 	/* Vendor specific OUI for Device Sub Category */
765 	uint8_t PrimaryDeviceOUI[4];
766 	/*
767 	 * Device Sub Category ID: 1-PC,
768 	 * 2-Server if Device Category is computer
769 	 */
770 	uint32_t DeviceSubCategory;
771 	tSapText DeviceName;
772 	uint16_t ConfigMethod;  /* Configuaration method */
773 	uint8_t RFBand;         /* RF bands available on the AP */
774 } tSap_WPSProbeRspIE;
775 
776 #define WPS_BEACON_VER_PRESENT                         0x00000001
777 #define WPS_BEACON_STATE_PRESENT                       0x00000002
778 #define WPS_BEACON_APSETUPLOCK_PRESENT                 0x00000004
779 #define WPS_BEACON_SELECTEDREGISTRA_PRESENT            0x00000008
780 #define WPS_BEACON_DEVICEPASSWORDID_PRESENT            0x00000010
781 #define WPS_BEACON_SELECTEDREGISTRACFGMETHOD_PRESENT   0x00000020
782 #define WPS_BEACON_UUIDE_PRESENT                       0x00000080
783 #define WPS_BEACON_RF_BANDS_PRESENT                    0x00000100
784 
785 typedef struct sap_WPSBeaconIE_s {
786 	uint32_t FieldPresent;
787 	uint32_t Version;         /* Version. 0x10 = version 1.0, 0x11 = etc. */
788 	uint32_t wpsState;        /* 1 = unconfigured, 2 = configured. */
789 	bool APSetupLocked;       /* Must be included if value is true */
790 	/* indicates if user has recently activated a reg to add an Enrollee. */
791 	bool SelectedRegistra;
792 	uint16_t DevicePasswordID;              /* Device Password ID */
793 	uint16_t SelectedRegistraCfgMethod;     /* Selected reg config method */
794 	uint8_t UUID_E[16];     /* Unique identifier of the AP. */
795 	uint8_t RFBand;         /* RF bands available on the AP */
796 } tSap_WPSBeaconIE;
797 
798 #define WPS_ASSOCRSP_VER_PRESENT             0x00000001
799 #define WPS_ASSOCRSP_RESPONSETYPE_PRESENT    0x00000002
800 
801 typedef struct sap_WPSAssocRspIE_s {
802 	uint32_t FieldPresent;
803 	uint32_t Version;
804 	uint8_t ResposeType;
805 } tSap_WPSAssocRspIE;
806 
807 typedef struct sap_WPSIE_s {
808 	eSapWPSIE_CODE sapWPSIECode;
809 	union {
810 		tSap_WPSProbeRspIE sapWPSProbeRspIE; /* WPS Set Probe Resp IE */
811 		tSap_WPSBeaconIE sapWPSBeaconIE;     /* WPS Set Beacon IE */
812 		tSap_WPSAssocRspIE sapWPSAssocRspIE; /* WPS Set Assoc Resp IE */
813 	} sapwpsie;
814 } tSap_WPSIE, *tpSap_WPSIE;
815 
816 #ifdef WLANTL_DEBUG
817 #define MAX_RATE_INDEX      136
818 #define MAX_NUM_RSSI        100
819 #define MAX_RSSI_INTERVAL     5
820 #endif
821 
822 typedef struct sap_SoftapStats_s {
823 	uint32_t txUCFcnt;
824 	uint32_t txMCFcnt;
825 	uint32_t txBCFcnt;
826 	uint32_t txUCBcnt;
827 	uint32_t txMCBcnt;
828 	uint32_t txBCBcnt;
829 	uint32_t rxUCFcnt;
830 	uint32_t rxMCFcnt;
831 	uint32_t rxBCFcnt;
832 	uint32_t rxUCBcnt;
833 	uint32_t rxMCBcnt;
834 	uint32_t rxBCBcnt;
835 	uint32_t rxBcnt;
836 	uint32_t rxBcntCRCok;
837 	uint32_t rxRate;
838 #ifdef WLANTL_DEBUG
839 	uint32_t pktCounterRateIdx[MAX_RATE_INDEX];
840 	uint32_t pktCounterRssi[MAX_NUM_RSSI];
841 #endif
842 } tSap_SoftapStats, *tpSap_SoftapStats;
843 
844 #ifdef FEATURE_WLAN_CH_AVOID
845 /* Store channel safety information */
846 typedef struct {
847 	uint16_t channelNumber;
848 	bool isSafe;
849 } sapSafeChannelType;
850 #endif /* FEATURE_WLAN_CH_AVOID */
851 void sap_cleanup_channel_list(void *sapContext);
852 void sapCleanupAllChannelList(void);
853 QDF_STATUS wlansap_set_wps_ie(void *p_cds_gctx, tSap_WPSIE *pWPSIe);
854 QDF_STATUS wlansap_update_wps_ie(void *p_cds_gctx);
855 QDF_STATUS wlansap_stop_Wps(void *p_cds_gctx);
856 QDF_STATUS wlansap_get_wps_state(void *p_cds_gctx, bool *pbWPSState);
857 void *wlansap_open(void *p_cds_gctx);
858 QDF_STATUS wlansap_global_init(void);
859 QDF_STATUS wlansap_global_deinit(void);
860 QDF_STATUS wlansap_start(void *p_cds_gctx, enum tQDF_ADAPTER_MODE mode,
861 			 uint8_t *addr, uint32_t *session_id);
862 QDF_STATUS wlansap_stop(void *p_cds_gctx);
863 QDF_STATUS wlansap_close(void *p_cds_gctx);
864 typedef QDF_STATUS (*tpWLAN_SAPEventCB)(tpSap_Event pSapEvent,
865 					void *pUsrContext);
866 uint8_t wlansap_get_state(void *p_cds_gctx);
867 
868 QDF_STATUS wlansap_start_bss(void *p_cds_gctx,
869 	 tpWLAN_SAPEventCB pSapEventCallback,
870 	 tsap_Config_t *pConfig, void *pUsrContext);
871 QDF_STATUS wlan_sap_set_pre_cac_status(void *ctx, bool status,
872 		tHalHandle handle);
873 QDF_STATUS wlan_sap_set_chan_before_pre_cac(void *ctx,
874 		uint8_t chan_before_pre_cac);
875 QDF_STATUS wlan_sap_set_pre_cac_complete_status(void *ctx, bool status);
876 bool wlan_sap_is_pre_cac_active(tHalHandle handle);
877 QDF_STATUS wlan_sap_get_pre_cac_vdev_id(tHalHandle handle, uint8_t *vdev_id);
878 #ifdef FEATURE_WLAN_MCC_TO_SCC_SWITCH
879 uint16_t wlansap_check_cc_intf(void *Ctx);
880 #endif
881 QDF_STATUS wlansap_set_mac_acl(void *p_cds_gctx, tsap_Config_t *pConfig);
882 QDF_STATUS wlansap_stop_bss(void *p_cds_gctx);
883 QDF_STATUS wlansap_disassoc_sta(void *p_cds_gctx,
884 				struct tagCsrDelStaParams *p_del_sta_params);
885 QDF_STATUS wlansap_deauth_sta(void *p_cds_gctx,
886 			struct tagCsrDelStaParams *pDelStaParams);
887 QDF_STATUS wlansap_set_channel_change_with_csa(void *p_cds_gctx,
888 			uint32_t targetChannel, enum phy_ch_width target_bw);
889 QDF_STATUS wlansap_set_key_sta(void *p_cds_gctx,
890 	tCsrRoamSetKey *pSetKeyInfo);
891 QDF_STATUS wlansap_get_assoc_stations(void *p_cds_gctx,
892 	 QDF_MODULE_ID module, tpSap_AssocMacAddr pAssocStas);
893 QDF_STATUS wlansap_remove_wps_session_overlap(void *p_cds_gctx,
894 	struct qdf_mac_addr pRemoveMac);
895 QDF_STATUS wlansap_get_wps_session_overlap(void *p_cds_gctx);
896 QDF_STATUS wlansap_set_counter_measure(void *p_cds_gctx, bool bEnable);
897 QDF_STATUS wlan_sap_getstation_ie_information(void *p_cds_gctx,
898 	uint32_t *pLen, uint8_t *pBuf);
899 QDF_STATUS wlansap_clear_acl(void *p_cds_gctx);
900 QDF_STATUS wlansap_get_acl_accept_list(void *p_cds_gctx,
901 	 struct qdf_mac_addr *pAcceptList, uint8_t *nAcceptList);
902 QDF_STATUS wlansap_get_acl_deny_list(void *pCtx,
903 	struct qdf_mac_addr *pDenyList, uint8_t *nDenyList);
904 QDF_STATUS wlansap_set_mode(void *p_cds_gctx, uint32_t mode);
905 QDF_STATUS wlansap_get_acl_mode(void *p_cds_gctx, eSapMacAddrACL *mode);
906 QDF_STATUS wlansap_modify_acl(void *p_cds_gctx,
907 	 uint8_t *pPeerStaMac, eSapACLType listType, eSapACLCmdType cmd);
908 QDF_STATUS wlansap_set_wparsn_ies
909 	(void *p_cds_gctx, uint8_t *pWPARSNIEs, uint32_t WPARSNIEsLen);
910 QDF_STATUS wlansap_send_action
911 	(void *p_cds_gctx,
912 	 const uint8_t *pBuf, uint32_t len, uint16_t wait, uint16_t channel_freq);
913 QDF_STATUS wlansap_remain_on_channel
914 	(void *p_cds_gctx,
915 	 uint8_t channel,
916 	 uint32_t duration, remainOnChanCallback callback, void *pContext,
917 	 uint32_t *scan_id);
918 QDF_STATUS wlansap_cancel_remain_on_channel(void *p_cds_gctx,
919 		uint32_t scan_id);
920 QDF_STATUS wlansap_register_mgmt_frame
921 	(void *p_cds_gctx,
922 	 uint16_t frameType, uint8_t *matchData, uint16_t matchLen);
923 QDF_STATUS wlansap_de_register_mgmt_frame
924 	(void *p_cds_gctx,
925 	 uint16_t frameType, uint8_t *matchData, uint16_t matchLen);
926 QDF_STATUS wlansap_channel_change_request(void *p_cds_gctx,
927 		uint8_t tArgetChannel);
928 QDF_STATUS wlansap_start_beacon_req(void *pSapCtx);
929 QDF_STATUS wlansap_dfs_send_csa_ie_request(void *pSapCtx);
930 QDF_STATUS wlansap_get_dfs_ignore_cac(tHalHandle hHal, uint8_t *pIgnore_cac);
931 QDF_STATUS wlansap_set_dfs_ignore_cac(tHalHandle hHal, uint8_t ignore_cac);
932 QDF_STATUS wlansap_set_dfs_restrict_japan_w53(tHalHandle hHal,
933 			uint8_t disable_Dfs_JapanW3);
934 
935 #ifdef FEATURE_AP_MCC_CH_AVOIDANCE
936 QDF_STATUS
937 wlan_sap_set_channel_avoidance(tHalHandle hal, bool sap_channel_avoidance);
938 #endif
939 
940 QDF_STATUS wlansap_set_dfs_preferred_channel_location(tHalHandle hHal,
941 		uint8_t dfs_Preferred_Channels_location);
942 QDF_STATUS wlansap_set_dfs_target_chnl(tHalHandle hHal,
943 			uint8_t target_channel);
944 uint32_t wlan_sap_get_vht_ch_width(void *ctx);
945 void wlan_sap_set_vht_ch_width(void *ctx, uint32_t vht_channel_width);
946 QDF_STATUS wlansap_update_sap_config_add_ie(tsap_Config_t *pConfig,
947 		const uint8_t *
948 		pAdditionIEBuffer,
949 		uint16_t additionIELength,
950 		eUpdateIEsType updateType);
951 QDF_STATUS wlansap_reset_sap_config_add_ie(tsap_Config_t *pConfig,
952 			eUpdateIEsType updateType);
953 void wlansap_extend_to_acs_range(uint8_t *startChannelNum,
954 		uint8_t *endChannelNum,
955 		uint8_t *bandStartChannel,
956 		uint8_t *bandEndChannel);
957 QDF_STATUS wlansap_get_dfs_nol(void *pSapCtx, uint8_t *nol, uint32_t *nol_len);
958 QDF_STATUS wlansap_set_dfs_nol(void *pSapCtx, eSapDfsNolType conf);
959 void wlansap_populate_del_sta_params(const uint8_t *mac,
960 		uint16_t reason_code,
961 		uint8_t subtype,
962 		struct tagCsrDelStaParams *pDelStaParams);
963 QDF_STATUS wlansap_acs_chselect(void *pvos_gctx,
964 		tpWLAN_SAPEventCB pacs_event_callback,
965 		tsap_Config_t *pconfig,
966 		void *pusr_context);
967 uint32_t wlansap_get_chan_width(void *cds_ctx);
968 
969 #ifdef __cplusplus
970 }
971 #endif
972 #endif /* #ifndef WLAN_QCT_WLANSAP_H */
973