xref: /wlan-dirver/qca-wifi-host-cmn/umac/regulatory/core/src/reg_priv_objs.h (revision 45a38684b07295822dc8eba39e293408f203eec8)
1 /*
2  * Copyright (c) 2017-2020 The Linux Foundation. All rights reserved.
3  *
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 /**
21  * DOC: reg_priv_objs.h
22  * This file contains regulatory component private data structures.
23  */
24 
25 #ifndef __REG_PRIV_OBJS_H
26 #define __REG_PRIV_OBJS_H
27 
28 #include <wlan_scan_public_structs.h>
29 
30 #define reg_alert(params...) \
31 	QDF_TRACE_FATAL(QDF_MODULE_ID_REGULATORY, params)
32 #define reg_err(params...) \
33 	QDF_TRACE_ERROR(QDF_MODULE_ID_REGULATORY, params)
34 #define reg_err_rl(params...) \
35 	QDF_TRACE_ERROR_RL(QDF_MODULE_ID_REGULATORY, params)
36 #define reg_warn(params...) \
37 	QDF_TRACE_WARN(QDF_MODULE_ID_REGULATORY, params)
38 #define reg_notice(params...) \
39 	QDF_TRACE_INFO(QDF_MODULE_ID_REGULATORY, params)
40 #define reg_info(params...) \
41 	QDF_TRACE_INFO(QDF_MODULE_ID_REGULATORY, params)
42 #define reg_debug(params...) \
43 	QDF_TRACE_DEBUG(QDF_MODULE_ID_REGULATORY, params)
44 #define reg_debug_rl(params...) \
45 	QDF_TRACE_DEBUG_RL(QDF_MODULE_ID_REGULATORY, params)
46 
47 #define reg_nofl_alert(params...) \
48 	QDF_TRACE_FATAL_NO_FL(QDF_MODULE_ID_REGULATORY, params)
49 #define reg_nofl_err(params...) \
50 	QDF_TRACE_ERROR_NO_FL(QDF_MODULE_ID_REGULATORY, params)
51 #define reg_nofl_warn(params...) \
52 	QDF_TRACE_WARN_NO_FL(QDF_MODULE_ID_REGULATORY, params)
53 #define reg_nofl_info(params...) \
54 	QDF_TRACE_INFO_NO_FL(QDF_MODULE_ID_REGULATORY, params)
55 #define reg_nofl_debug(params...) \
56 	QDF_TRACE_DEBUG_NO_FL(QDF_MODULE_ID_REGULATORY, params)
57 
58 /**
59  * typedef reg_chan_change_callback() - Regulatory channel change callback
60  * @psoc: Pointer to psoc
61  * @pdev: Pointer to pdev
62  * @chan_list: Pointer to regulatory channel list
63  * @avoid_freq_ind: Pointer to avoid frequencies
64  * @arg: list of arguments
65  */
66 typedef void (*reg_chan_change_callback)(
67 		struct wlan_objmgr_psoc *psoc,
68 		struct wlan_objmgr_pdev *pdev,
69 		struct regulatory_channel *chan_list,
70 		struct avoid_freq_ind_data *avoid_freq_ind,
71 		void *arg);
72 
73 /**
74  * struct chan_change_cbk_entry - Channel change callback entry
75  * @cbk: Callback
76  * @arg: Arguments
77  */
78 struct chan_change_cbk_entry {
79 	reg_chan_change_callback cbk;
80 	void *arg;
81 };
82 
83 /**
84  * struct wlan_regulatory_psoc_priv_obj - wlan regulatory psoc private object
85  * @chan_list_recvd: whether channel list has been received
86  * @new_user_ctry_pending: In this array, element[phy_id] is true if any user
87  *	country update is pending for pdev (phy_id), used in case of MCL.
88  * @new_init_ctry_pending: In this array, element[phy_id] is true if any user
89  *	country update is pending for pdev (phy_id), used in case of WIN.
90  * @new_11d_ctry_pending: In this array, element[phy_id] is true if any 11d
91  *	country update is pending for pdev (phy_id).
92  * @world_country_pending: In this array, element[phy_id] is true if any world
93  *	country update is pending for pdev (phy_id).
94  * @band_capability: bitmap of bands enabled, using enum reg_wifi_band as the
95  *	bit position value
96  * @ignore_fw_reg_offload_ind: Ignore FW reg offload indication
97  * @six_ghz_supported: whether 6ghz is supported
98  * @five_dot_nine_ghz_supported: whether 5.9ghz is supported
99  *	(service bit WMI_SERVICE_5_DOT_9GHZ_SUPPORT)
100  * @enable_5dot9_ghz_chan_in_master_mode: 5.9 GHz channel support in
101  *	master mode (ini fcc_5dot9_ghz_chan_in_master_mode)
102  * @retain_nol_across_regdmn_update: Retain the NOL list across the regdomain
103  *	changes.
104  */
105 struct wlan_regulatory_psoc_priv_obj {
106 	struct mas_chan_params mas_chan_params[PSOC_MAX_PHY_REG_CAP];
107 	bool chan_list_recvd[PSOC_MAX_PHY_REG_CAP];
108 	bool offload_enabled;
109 	bool six_ghz_supported;
110 	bool five_dot_nine_ghz_supported;
111 	uint8_t num_phy;
112 	char cur_country[REG_ALPHA2_LEN + 1];
113 	char def_country[REG_ALPHA2_LEN + 1];
114 	uint16_t def_country_code;
115 	uint16_t def_region_domain;
116 	enum country_src cc_src;
117 	struct wlan_objmgr_psoc *psoc_ptr;
118 	bool new_user_ctry_pending[PSOC_MAX_PHY_REG_CAP];
119 	bool new_init_ctry_pending[PSOC_MAX_PHY_REG_CAP];
120 	bool new_11d_ctry_pending[PSOC_MAX_PHY_REG_CAP];
121 	bool world_country_pending[PSOC_MAX_PHY_REG_CAP];
122 	bool dfs_enabled;
123 	uint32_t band_capability;
124 	bool indoor_chan_enabled;
125 	bool ignore_fw_reg_offload_ind;
126 	bool enable_11d_supp_original;
127 	bool enable_11d_supp;
128 	bool is_11d_offloaded;
129 	uint8_t vdev_id_for_11d_scan;
130 	uint8_t master_vdev_cnt;
131 	uint8_t vdev_cnt_11d;
132 	uint32_t scan_11d_interval;
133 #ifdef HOST_11D_SCAN
134 	bool is_host_11d_inited;
135 	wlan_scan_requester scan_req_id;
136 	uint32_t scan_id;
137 	qdf_mc_timer_t timer;
138 #endif
139 	uint8_t vdev_ids_11d[MAX_STA_VDEV_CNT];
140 	bool user_ctry_priority;
141 	bool user_ctry_set;
142 	struct chan_change_cbk_entry cbk_list[REG_MAX_CHAN_CHANGE_CBKS];
143 	uint8_t num_chan_change_cbks;
144 	uint8_t ch_avoid_ind;
145 	struct unsafe_ch_list unsafe_chan_list;
146 	struct ch_avoid_ind_type avoid_freq_list;
147 	enum restart_beaconing_on_ch_avoid_rule restart_beaconing;
148 	struct wlan_psoc_host_hal_reg_capabilities_ext
149 			reg_cap[PSOC_MAX_PHY_REG_CAP];
150 	bool force_ssc_disable_indoor_channel;
151 	bool enable_srd_chan_in_master_mode;
152 	bool enable_11d_in_world_mode;
153 	bool enable_5dot9_ghz_chan_in_master_mode;
154 	qdf_spinlock_t cbk_list_lock;
155 	bool retain_nol_across_regdmn_update;
156 };
157 
158 /**
159  * struct wlan_regulatory_pdev_priv_obj - wlan regulatory pdev private object
160  * @pdev_opened: whether pdev has been opened by application
161  * @band_capability: bitmap of bands enabled, using enum reg_wifi_band as the
162  *	bit position value
163  */
164 struct wlan_regulatory_pdev_priv_obj {
165 	struct regulatory_channel cur_chan_list[NUM_CHANNELS];
166 	struct regulatory_channel mas_chan_list[NUM_CHANNELS];
167 #ifdef DISABLE_CHANNEL_LIST
168 	struct regulatory_channel cache_disable_chan_list[NUM_CHANNELS];
169 	uint32_t num_cache_channels;
170 	bool disable_cached_channels;
171 #endif
172 	char default_country[REG_ALPHA2_LEN + 1];
173 	uint16_t def_region_domain;
174 	uint16_t def_country_code;
175 	char current_country[REG_ALPHA2_LEN + 1];
176 	uint16_t reg_dmn_pair;
177 	uint16_t ctry_code;
178 #ifdef DISABLE_UNII_SHARED_BANDS
179 	uint8_t unii_5g_bitmap;
180 #endif
181 	enum dfs_reg dfs_region;
182 	uint32_t phybitmap;
183 	struct wlan_objmgr_pdev *pdev_ptr;
184 	qdf_freq_t range_2g_low;
185 	qdf_freq_t range_2g_high;
186 	qdf_freq_t range_5g_low;
187 	qdf_freq_t range_5g_high;
188 	bool dfs_enabled;
189 	bool set_fcc_channel;
190 	uint32_t band_capability;
191 	bool indoor_chan_enabled;
192 	bool en_chan_144;
193 	uint32_t wireless_modes;
194 	struct ch_avoid_ind_type freq_avoid_list;
195 	bool force_ssc_disable_indoor_channel;
196 	bool sap_state;
197 	struct reg_rule_info reg_rules;
198 	qdf_spinlock_t reg_rules_lock;
199 	bool chan_list_recvd;
200 	bool pdev_opened;
201 };
202 
203 /**
204  * reg_get_psoc_obj() - Provides the reg component object pointer
205  * @psoc: pointer to psoc object.
206  *
207  * Return: reg component object pointer
208  */
209 struct wlan_regulatory_psoc_priv_obj *reg_get_psoc_obj(
210 		struct wlan_objmgr_psoc *psoc);
211 
212 /**
213  * reg_get_pdev_obj() - Provides the reg component object pointer
214  * @psoc: pointer to psoc object.
215  *
216  * Return: reg component object pointer
217  */
218 struct wlan_regulatory_pdev_priv_obj *reg_get_pdev_obj(
219 		struct wlan_objmgr_pdev *pdev);
220 
221 /**
222  * wlan_regulatory_psoc_obj_created_notification() - PSOC obj create callback
223  * @psoc: PSOC object
224  * @arg_list: Variable argument list
225  *
226  * This callback is registered with object manager during initialization to
227  * get notified when the object is created.
228  *
229  * Return: Success or Failure
230  */
231 QDF_STATUS wlan_regulatory_psoc_obj_created_notification(
232 		struct wlan_objmgr_psoc *psoc, void *arg_list);
233 
234 /**
235  * wlan_regulatory_psoc_obj_destroyed_notification() - PSOC obj delete callback
236  * @psoc: PSOC object
237  * @arg_list: Variable argument list
238  *
239  * This callback is registered with object manager during initialization to
240  * get notified when the object is deleted.
241  *
242  * Return: Success or Failure
243  */
244 QDF_STATUS wlan_regulatory_psoc_obj_destroyed_notification(
245 	struct wlan_objmgr_psoc *psoc, void *arg_list);
246 
247 /**
248  * wlan_regulatory_pdev_obj_created_notification() - PDEV obj create callback
249  * @pdev: pdev object
250  * @arg_list: Variable argument list
251  *
252  * This callback is registered with object manager during initialization to
253  * get notified when the pdev object is created.
254  *
255  * Return: Success or Failure
256  */
257 QDF_STATUS wlan_regulatory_pdev_obj_created_notification(
258 	struct wlan_objmgr_pdev *pdev, void *arg_list);
259 
260 /**
261  * wlan_regulatory_pdev_obj_destroyed_notification() - PDEV obj destroy callback
262  * @pdev: pdev object
263  * @arg_list: Variable argument list
264  *
265  * This callback is registered with object manager during initialization to
266  * get notified when the pdev object is destroyed.
267  *
268  * Return: Success or Failure
269  */
270 QDF_STATUS wlan_regulatory_pdev_obj_destroyed_notification(
271 		struct wlan_objmgr_pdev *pdev, void *arg_list);
272 #endif
273