xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/nxp/mlan/mlan_11h.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /** @file mlan_11h.h
2  *
3  *  @brief This header file contains data structures and
4  *  function declarations of 802.11h
5  *
6  *
7  *  Copyright 2008-2021 NXP
8  *
9  *  This software file (the File) is distributed by NXP
10  *  under the terms of the GNU General Public License Version 2, June 1991
11  *  (the License).  You may use, redistribute and/or modify the File in
12  *  accordance with the terms and conditions of the License, a copy of which
13  *  is available by writing to the Free Software Foundation, Inc.,
14  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
15  *  worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
16  *
17  *  THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
18  *  IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
19  *  ARE EXPRESSLY DISCLAIMED.  The License provides additional details about
20  *  this warranty disclaimer.
21  *
22  */
23 
24 /*************************************************************
25 Change Log:
26     03/26/2009: initial creation
27 *************************************************************/
28 
29 #ifndef _MLAN_11H_
30 #define _MLAN_11H_
31 
32 /** 11H OID bitmasks */
33 #define ENABLE_11H_MASK MBIT(0)
34 #define MASTER_RADAR_DET_MASK MBIT(1)
35 #define SLAVE_RADAR_DET_MASK MBIT(2)
36 
37 /** DFS Master Radar Detect global enable */
38 #define DFS_MASTER_RADAR_DETECT_EN (MTRUE)
39 /** DFS Slave Radar Detect global enable */
40 #define DFS_SLAVE_RADAR_DETECT_EN (MFALSE)
41 
42 #define CHANNEL_OFFSET_MASK 0x30
43 #define CHANNEL_BANDWIDTH_MASK 0x0C
44 
45 /**
46  *  11H APIs
47  */
48 
49 /* Is master radar detection enabled in firmware? */
50 extern t_bool wlan_11h_is_master_radar_det_active(mlan_private *priv);
51 
52 /** Configure master radar detection.
53  *  Need call wlan_11h_check_update_radar_det_state() after.
54  */
55 extern mlan_status wlan_11h_config_master_radar_det(mlan_private *priv,
56 						    t_bool enable);
57 
58 /** Configure slave radar detection.
59  *  Need call wlan_11h_check_update_radar_det_state() after.
60  */
61 extern mlan_status wlan_11h_config_slave_radar_det(mlan_private *priv,
62 						   t_bool enable);
63 
64 /** Checks all interfaces and updates radar detect flags if necessary */
65 extern mlan_status wlan_11h_check_update_radar_det_state(mlan_private *pmpriv);
66 #ifdef UAP_SUPPORT
67 /** update dfs master state from uap interface */
68 void wlan_11h_update_dfs_master_state_by_uap(mlan_private *pmpriv);
69 /** update dfs master when station disconnected */
70 void wlan_11h_update_dfs_master_state_on_disconect(mlan_private *priv);
71 /** update dfs master state from STA interface */
72 void wlan_11h_update_dfs_master_state_by_sta(mlan_private *pmpriv);
73 #endif
74 
75 /** Return 1 if 11h is active in the firmware, 0 if it is inactive */
76 extern t_bool wlan_11h_is_active(mlan_private *priv);
77 
78 /** Enable the tx interface and record the new transmit state */
79 extern void wlan_11h_tx_enable(mlan_private *priv);
80 
81 /** Disable the tx interface and record the new transmit state */
82 extern void wlan_11h_tx_disable(mlan_private *priv);
83 
84 /** Activate 11h extensions in the firmware */
85 extern mlan_status wlan_11h_activate(mlan_private *priv, t_void *pioctl_buf,
86 				     t_bool flag);
87 
88 /** Initialize the 11h device structure */
89 extern void wlan_11h_init(mlan_adapter *pmadapter);
90 
91 /** Cleanup for the 11h device structure */
92 extern void wlan_11h_cleanup(mlan_adapter *pmadapter);
93 
94 /** Initialize the 11h interface structure */
95 extern void wlan_11h_priv_init(mlan_private *pmpriv);
96 
97 /** Get an initial random channel to start an adhoc network on */
98 extern t_u8 wlan_11h_get_adhoc_start_channel(mlan_private *priv);
99 
100 /** Get channel that has been closed via Channel Switch Announcement */
101 extern t_u8 wlan_11h_get_csa_closed_channel(mlan_private *priv);
102 
103 /** Check if radar detection is required on the specified channel */
104 extern t_bool wlan_11h_radar_detect_required(mlan_private *priv, t_u8 channel);
105 
106 /** Perform a standard availibility check on the specified channel */
107 extern t_s32 wlan_11h_issue_radar_detect(mlan_private *priv,
108 					 pmlan_ioctl_req pioctl_req,
109 					 t_u8 channel, Band_Config_t bandcfg);
110 
111 /** Check previously issued radar report for a channel */
112 extern mlan_status wlan_11h_check_chan_report(mlan_private *priv, t_u8 chan);
113 
114 /** Add any 11h TLVs necessary to complete an adhoc start command */
115 extern t_s32 wlan_11h_process_start(mlan_private *priv, t_u8 **ppbuffer,
116 				    IEEEtypes_CapInfo_t *pcap_info,
117 				    t_u32 channel,
118 				    wlan_11h_bss_info_t *p11h_bss_info);
119 
120 /** Add any 11h TLVs necessary to complete a join command (adhoc or infra) */
121 extern t_s32 wlan_11h_process_join(mlan_private *priv, t_u8 **ppbuffer,
122 				   IEEEtypes_CapInfo_t *pcap_info, t_u16 band,
123 				   t_u32 channel,
124 				   wlan_11h_bss_info_t *p11h_bss_info);
125 
126 /** Complete the firmware command preparation for an 11h command function */
127 extern mlan_status wlan_11h_cmd_process(mlan_private *priv,
128 					HostCmd_DS_COMMAND *pcmd_ptr,
129 					const t_void *pinfo_buf);
130 
131 /** Process the response of an 11h firmware command */
132 extern mlan_status wlan_11h_cmdresp_process(mlan_private *priv,
133 					    const HostCmd_DS_COMMAND *resp);
134 
135 /** Receive IEs from scan processing and record any needed info for 11h */
136 extern mlan_status wlan_11h_process_bss_elem(mlan_adapter *pmadapter,
137 					     wlan_11h_bss_info_t *p11h_bss_info,
138 					     const t_u8 *pelement);
139 
140 /** Handler for EVENT_CHANNEL_SWITCH_ANN */
141 extern mlan_status wlan_11h_handle_event_chanswann(mlan_private *priv);
142 
143 /** Handler for EVENT_CHANNEL_REPORT_RDY */
144 extern mlan_status wlan_11h_handle_event_chanrpt_ready(mlan_private *priv,
145 						       mlan_event *pevent,
146 						       t_u8 *radar_chan,
147 						       t_u8 *bandwidth);
148 
149 /** Debug output for EVENT_RADAR_DETECTED */
150 mlan_status wlan_11h_print_event_radar_detected(mlan_private *priv,
151 						mlan_event *pevent,
152 						t_u8 *radar_chan,
153 						t_u8 *bandwidth);
154 
155 t_s32 wlan_11h_cancel_radar_detect(mlan_private *priv);
156 /** Handler for DFS_TESTING IOCTL */
157 extern mlan_status wlan_11h_ioctl_dfs_testing(pmlan_adapter pmadapter,
158 					      pmlan_ioctl_req pioctl_req);
159 extern mlan_status wlan_11h_ioctl_channel_nop_info(pmlan_adapter pmadapter,
160 						   pmlan_ioctl_req pioctl_req);
161 extern mlan_status wlan_11h_ioctl_nop_channel_list(pmlan_adapter pmadapter,
162 						   pmlan_ioctl_req pioctl_req);
163 
164 extern mlan_status wlan_11h_ioctl_dfs_chan_report(mlan_private *priv,
165 						  pmlan_ioctl_req pioctl_req);
166 extern mlan_status wlan_11h_ioctl_chan_switch_count(pmlan_adapter pmadapter,
167 						    pmlan_ioctl_req pioctl_req);
168 
169 /** get/set channel dfs state */
170 mlan_status wlan_11h_ioctl_chan_dfs_state(pmlan_adapter pmadapter,
171 					  pmlan_ioctl_req pioctl_req);
172 
173 /** get/set dfs w53 cfg */
174 mlan_status wlan_11h_ioctl_dfs_w53_cfg(pmlan_adapter pmadapter,
175 				       pmlan_ioctl_req pioctl_req);
176 
177 /** get/set dfs mode */
178 mlan_status wlan_11h_ioctl_dfs_mode(pmlan_adapter pmadapter,
179 				    pmlan_ioctl_req pioctl_req);
180 /** Check if channel is under a NOP duration (should not be used) */
181 extern t_bool wlan_11h_is_channel_under_nop(mlan_adapter *pmadapter,
182 					    t_u8 channel);
183 
184 /** Check if RADAR_DETECTED handling is blocking data tx */
185 extern t_bool wlan_11h_radar_detected_tx_blocked(mlan_adapter *pmadapter);
186 
187 /** Callback for RADAR_DETECTED (for UAP cmdresp) */
188 extern mlan_status wlan_11h_radar_detected_callback(t_void *priv);
189 /** set dfs check channel */
190 void wlan_11h_set_dfs_check_chan(mlan_private *priv, t_u8 chan, t_u8 bandwidth);
191 
192 #ifdef UAP_SUPPORT
193 /** BW_change event Handler for dfs_repeater */
194 void wlan_dfs_rep_bw_change(mlan_adapter *pmadapter);
195 
196 /** disconnect event Handler for dfs_repeater */
197 void wlan_dfs_rep_disconnect(mlan_adapter *pmadapter);
198 #endif
199 
200 /** Handler for RADAR_DETECTED */
201 extern mlan_status wlan_11h_radar_detected_handling(mlan_adapter *pmadapter,
202 						    mlan_private *priv);
203 
204 mlan_status wlan_11h_remove_custom_ie(mlan_adapter *pmadapter,
205 				      mlan_private *pmpriv);
206 
207 /** DFS Event pre-processing */
208 extern mlan_status wlan_11h_dfs_event_preprocessing(mlan_adapter *pmadapter);
209 
210 /** DFS switch to non-DFS channel */
211 extern mlan_status wlan_11h_switch_non_dfs_chan(mlan_private *priv, t_u8 *chan);
212 
213 extern void wlan_11h_update_bandcfg(mlan_private *pmpriv,
214 				    Band_Config_t *uap_band_cfg,
215 				    t_u8 new_channel);
216 
217 /** function checks if interface is active. **/
218 extern t_bool wlan_is_intf_active(mlan_private *pmpriv);
219 
220 #endif /*_MLAN_11H_ */
221