xref: /wlan-dirver/qca-wifi-host-cmn/umac/regulatory/dispatcher/inc/wlan_reg_ucfg_api.h (revision 901120c066e139c7f8a2c8e4820561fdd83c67ef)
1 /*
2  * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  *
6  * Permission to use, copy, modify, and/or distribute this software for
7  * any purpose with or without fee is hereby granted, provided that the
8  * above copyright notice and this permission notice appear in all
9  * copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
12  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
13  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
14  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
15  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
16  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
17  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18  * PERFORMANCE OF THIS SOFTWARE.
19  */
20 
21 /**
22  * DOC: wlan_reg_ucfg_api.h
23  * This file provides prototypes of the regulatory component user
24  * config interface routines
25  */
26 
27 #ifndef __WLAN_REG_UCFG_API_H
28 #define __WLAN_REG_UCFG_API_H
29 
30 #ifdef CONFIG_AFC_SUPPORT
31 #include <wlan_reg_afc.h>
32 #endif
33 #include <reg_services_public_struct.h>
34 
35 typedef QDF_STATUS (*reg_event_cb)(void *status_struct);
36 
37 /**
38  * ucfg_reg_set_band() - Sets the band information for the PDEV
39  * @pdev: The physical pdev to set the band for
40  * @band_bitmap: The band bitmap parameter (over reg_wifi_band) to configure
41  *	for the physical device
42  *
43  * Return: QDF_STATUS
44  */
45 QDF_STATUS ucfg_reg_set_band(struct wlan_objmgr_pdev *pdev,
46 			     uint32_t band_bitmap);
47 
48 /**
49  * ucfg_reg_get_band() - Gets the band information for the PDEV
50  * @pdev: The physical pdev to get the band for
51  * @band_bitmap: The band parameter of the physical device
52  *
53  * Return: QDF_STATUS
54  */
55 QDF_STATUS ucfg_reg_get_band(struct wlan_objmgr_pdev *pdev,
56 			     uint32_t *band_bitmap);
57 
58 /**
59  * ucfg_reg_notify_sap_event() - Notify regulatory domain for sap event
60  * @pdev: The physical dev to set the band for
61  * @sap_state: true for sap start else false
62  *
63  * Return: QDF_STATUS
64  */
65 QDF_STATUS ucfg_reg_notify_sap_event(struct wlan_objmgr_pdev *pdev,
66 			bool sap_state);
67 
68 /**
69  * ucfg_reg_cache_channel_freq_state() - Cache the current state of the
70  * channels based on the channel center frequency.
71  * @pdev: Pointer to pdev.
72  * @channel_list: List of the channels for which states need to be cached.
73  * @num_channels: Number of channels in the list.
74  *
75  * Return: QDF_STATUS
76  */
77 #if defined(DISABLE_CHANNEL_LIST) && defined(CONFIG_CHAN_FREQ_API)
78 void ucfg_reg_cache_channel_freq_state(struct wlan_objmgr_pdev *pdev,
79 				       uint32_t *channel_list,
80 				       uint32_t num_channels);
81 #else
82 static inline
83 void ucfg_reg_cache_channel_freq_state(struct wlan_objmgr_pdev *pdev,
84 				       uint32_t *channel_list,
85 				       uint32_t num_channels)
86 {
87 }
88 #endif /* CONFIG_CHAN_FREQ_API */
89 
90 #ifdef DISABLE_CHANNEL_LIST
91 /**
92  * ucfg_reg_disable_cached_channels() - Disable cached channels
93  * @pdev: The physical dev to cache the channels for
94  *
95  * Return: Void
96  */
97 void ucfg_reg_disable_cached_channels(struct wlan_objmgr_pdev *pdev);
98 
99 /**
100  * ucfg_reg_restore_cached_channels() - Restore disabled cached channels
101  * @pdev: The physical dev to cache the channels for
102  *
103  * Return: Void
104  */
105 void ucfg_reg_restore_cached_channels(struct wlan_objmgr_pdev *pdev);
106 #else
107 static inline
108 void ucfg_reg_disable_cached_channels(struct wlan_objmgr_pdev *pdev)
109 {
110 }
111 
112 static inline
113 void ucfg_reg_restore_cached_channels(struct wlan_objmgr_pdev *pdev)
114 {
115 }
116 #endif
117 
118 /**
119  * ucfg_reg_set_fcc_constraint() - apply fcc constraints on channels 12/13
120  * @pdev: The physical pdev to reduce tx power for
121  *
122  * This function adjusts the transmit power on channels 12 and 13, to comply
123  * with FCC regulations in the USA.
124  *
125  * Return: QDF_STATUS
126  */
127 QDF_STATUS ucfg_reg_set_fcc_constraint(struct wlan_objmgr_pdev *pdev,
128 		bool fcc_constraint);
129 
130 /**
131  * ucfg_reg_get_default_country() - Get the default regulatory country
132  * @psoc: The physical SoC to get default country from
133  * @country_code: the buffer to populate the country code into
134  *
135  * Return: QDF_STATUS
136  */
137 QDF_STATUS ucfg_reg_get_default_country(struct wlan_objmgr_psoc *psoc,
138 					       uint8_t *country_code);
139 
140 /**
141  * ucfg_reg_get_current_country() - Get the current regulatory country
142  * @psoc: The physical SoC to get current country from
143  * @country_code: the buffer to populate the country code into
144  *
145  * Return: QDF_STATUS
146  */
147 QDF_STATUS ucfg_reg_get_current_country(struct wlan_objmgr_psoc *psoc,
148 					       uint8_t *country_code);
149 /**
150  * ucfg_reg_set_default_country() - Set the default regulatory country
151  * @psoc: The physical SoC to set default country for
152  * @country_code: The country information to configure
153  *
154  * Return: QDF_STATUS
155  */
156 QDF_STATUS ucfg_reg_set_default_country(struct wlan_objmgr_psoc *psoc,
157 					       uint8_t *country_code);
158 
159 /**
160  * ucfg_reg_set_country() - Set the current regulatory country
161  * @pdev: The physical dev to set current country for
162  * @country_code: The country information to configure
163  *
164  * Return: QDF_STATUS
165  */
166 QDF_STATUS ucfg_reg_set_country(struct wlan_objmgr_pdev *dev,
167 				uint8_t *country_code);
168 
169 /**
170  * ucfg_reg_reset_country() - Reset the regulatory country to default
171  * @psoc: The physical SoC to reset country for
172  *
173  * Return: QDF_STATUS
174  */
175 QDF_STATUS ucfg_reg_reset_country(struct wlan_objmgr_psoc *psoc);
176 
177 /**
178  * ucfg_reg_enable_dfs_channels() - Enable the use of DFS channels
179  * @pdev: The physical dev to enable DFS channels for
180  *
181  * Return: QDF_STATUS
182  */
183 QDF_STATUS ucfg_reg_enable_dfs_channels(struct wlan_objmgr_pdev *pdev,
184 		bool dfs_enable);
185 
186 QDF_STATUS ucfg_reg_register_event_handler(uint8_t vdev_id, reg_event_cb cb,
187 		void *arg);
188 QDF_STATUS ucfg_reg_unregister_event_handler(uint8_t vdev_id, reg_event_cb cb,
189 		void *arg);
190 QDF_STATUS ucfg_reg_init_handler(uint8_t pdev_id);
191 
192 #ifdef WLAN_REG_PARTIAL_OFFLOAD
193 /**
194  * ucfg_reg_program_default_cc() - Program default country code
195  * @pdev: Pdev pointer
196  * @regdmn: Regdomain value
197  *
198  * Return: QDF_STATUS
199  */
200 QDF_STATUS ucfg_reg_program_default_cc(struct wlan_objmgr_pdev *pdev,
201 				       uint16_t regdmn);
202 #endif
203 
204 /**
205  * ucfg_reg_program_cc() - Program user country code or regdomain
206  * @pdev: The physical dev to program country code or regdomain
207  * @rd: User country code or regdomain
208  *
209  * Return: QDF_STATUS
210  */
211 QDF_STATUS ucfg_reg_program_cc(struct wlan_objmgr_pdev *pdev,
212 			       struct cc_regdmn_s *rd);
213 
214 /**
215  * ucfg_reg_get_current_cc() - get current country code or regdomain
216  * @pdev: The physical dev to program country code or regdomain
217  * @rd: Pointer to country code or regdomain
218  *
219  * Return: QDF_STATUS
220  */
221 QDF_STATUS ucfg_reg_get_current_cc(struct wlan_objmgr_pdev *pdev,
222 				   struct cc_regdmn_s *rd);
223 
224 /**
225  * ucfg_reg_set_config_vars () - Set the config vars in reg component
226  * @psoc: psoc ptr
227  * @config_vars: config variables structure
228  *
229  * Return: QDF_STATUS
230  */
231 QDF_STATUS ucfg_reg_set_config_vars(struct wlan_objmgr_psoc *psoc,
232 				    struct reg_config_vars config_vars);
233 
234 /**
235  * ucfg_reg_get_current_chan_list () - get current channel list
236  * @pdev: pdev ptr
237  * @chan_list: channel list
238  *
239  * Return: QDF_STATUS
240  */
241 QDF_STATUS ucfg_reg_get_current_chan_list(struct wlan_objmgr_pdev *pdev,
242 				    struct regulatory_channel *chan_list);
243 
244 /**
245  * ucfg_reg_modify_chan_144() - Enable/Disable channel 144
246  * @pdev: pdev pointer
247  * @enable_chan_144: flag to disable/enable channel 144
248  *
249  * Return: Success or Failure
250  */
251 QDF_STATUS ucfg_reg_modify_chan_144(struct wlan_objmgr_pdev *pdev,
252 				    bool enable_ch_144);
253 
254 /**
255  * ucfg_reg_get_en_chan_144() - get en_chan_144 flag value
256  * @pdev: pdev pointer
257  *
258  * Return: en_chan_144 flag value
259  */
260 bool ucfg_reg_get_en_chan_144(struct wlan_objmgr_pdev *pdev);
261 
262 /**
263  * ucfg_reg_is_regdb_offloaded () - is regulatory database offloaded
264  * @psoc: psoc ptr
265  *
266  * Return: bool
267  */
268 bool ucfg_reg_is_regdb_offloaded(struct wlan_objmgr_psoc *psoc);
269 
270 /**
271  * ucfg_reg_program_mas_chan_list () - program master channel list
272  * @psoc: psoc ptr
273  * @reg_channels: regulatory channels
274  * @alpha2: country code
275  * @dfs_region: dfs region
276  *
277  * Return: void
278  */
279 void ucfg_reg_program_mas_chan_list(struct wlan_objmgr_psoc *psoc,
280 				    struct regulatory_channel *reg_channels,
281 				    uint8_t *alpha2,
282 				    enum dfs_reg dfs_region);
283 
284 /**
285  * ucfg_reg_get_regd_rules() - provides the reg domain rules info pointer
286  * @pdev: pdev ptr
287  * @reg_rules: regulatory rules
288  *
289  * Return: QDF_STATUS
290  */
291 QDF_STATUS ucfg_reg_get_regd_rules(struct wlan_objmgr_pdev *pdev,
292 				   struct reg_rule_info *reg_rules);
293 
294 /**
295  * ucfg_reg_register_chan_change_callback () - add chan change cbk
296  * @psoc: psoc ptr
297  * @cbk: callback
298  * @arg: argument
299  *
300  * Return: void
301  */
302 void ucfg_reg_register_chan_change_callback(struct wlan_objmgr_psoc *psoc,
303 					    void *cbk, void *arg);
304 
305 /**
306  * ucfg_reg_unregister_chan_change_callback () - remove chan change cbk
307  * @psoc: psoc ptr
308  * @cbk: callback
309  *
310  * Return: void
311  */
312 void ucfg_reg_unregister_chan_change_callback(struct wlan_objmgr_psoc *psoc,
313 					      void *cbk);
314 
315 #ifdef CONFIG_AFC_SUPPORT
316 /**
317  * ucfg_reg_register_afc_req_rx_callback () - add AFC request received callback
318  * @pdev: Pointer to pdev
319  * @cbf: Pointer to callback function
320  * @arg: Pointer to opaque argument
321  *
322  * Return: QDF_STATUS
323  */
324 QDF_STATUS ucfg_reg_register_afc_req_rx_callback(struct wlan_objmgr_pdev *pdev,
325 						 afc_req_rx_evt_handler cbf,
326 						 void *arg);
327 
328 /**
329  * ucfg_reg_unregister_afc_req_rx_callback () - remove AFC request received
330  * callback
331  * @pdev: Pointer to pdev
332  * @cbf: Pointer to callback function
333  *
334  * Return: QDF_STATUS
335  */
336 QDF_STATUS ucfg_reg_unregister_afc_req_rx_callback(struct wlan_objmgr_pdev *pdev,
337 						   afc_req_rx_evt_handler cbf);
338 
339 /**
340  * ucfg_reg_get_partial_afc_req_info() - Get the the frequency ranges and
341  * opclass + channel ranges. This is partial because in the AFC request there
342  * are a few more parameters: Longitude, Latitude a few other information
343  * @pdev: Pointer to PDEV object.
344  * @afc_req: Address of AFC request pointer.
345  * @req_id: AFC request ID.
346  *
347  * Return: QDF_STATUS_E_INVAL if unable to set and QDF_STATUS_SUCCESS is set.
348  */
349 QDF_STATUS ucfg_reg_get_partial_afc_req_info(
350 		struct wlan_objmgr_pdev *pdev,
351 		struct wlan_afc_host_partial_request **afc_req,
352 		uint64_t req_id);
353 
354 /**
355  * ucfg_reg_register_afc_power_event_callback() - add AFC power event received
356  * @pdev: Pointer to pdev
357  * @cbf: Pointer to callback function
358  * @arg: Pointer to opaque argument
359  *
360  * Return: QDF_STATUS
361  */
362 QDF_STATUS
363 ucfg_reg_register_afc_power_event_callback(struct wlan_objmgr_pdev *pdev,
364 					   afc_power_tx_evt_handler cbf,
365 					   void *arg);
366 
367 /**
368  * ucfg_reg_unregister_afc_power_event_callback() - remove AFC power event
369  * received callback
370  * @pdev: Pointer to pdev
371  * @cbf: Pointer to callback function
372  *
373  * Return: QDF_STATUS
374  */
375 QDF_STATUS
376 ucfg_reg_unregister_afc_power_event_callback(struct wlan_objmgr_pdev *pdev,
377 					     afc_power_tx_evt_handler cbf);
378 #endif
379 
380 /**
381  * ucfg_reg_get_cc_and_src () - get country code and src
382  * @psoc: psoc ptr
383  * @alpha2: country code alpha2
384  *
385  * Return: void
386  */
387 enum country_src ucfg_reg_get_cc_and_src(struct wlan_objmgr_psoc *psoc,
388 					 uint8_t *alpha2);
389 
390 /**
391  * ucfg_reg_unit_simulate_ch_avoid () - fake a ch avoid event
392  * @psoc: psoc ptr
393  * @ch_avoid: ch_avoid_ind_type ranges
394  *
395  * This function inject a ch_avoid event for unit test sap chan switch.
396  *
397  * Return: void
398  */
399 void ucfg_reg_unit_simulate_ch_avoid(struct wlan_objmgr_psoc *psoc,
400 	struct ch_avoid_ind_type *ch_avoid);
401 
402 /**
403  * ucfg_reg_ch_avoid () - Send channel avoid cmd to regulatory
404  * @psoc: psoc ptr
405  * @ch_avoid: ch_avoid_ind_type ranges
406  *
407  * This function send channel avoid cmd to regulatory from os_if/upper layer
408  *
409  * Return: void
410  */
411 void ucfg_reg_ch_avoid(struct wlan_objmgr_psoc *psoc,
412 		       struct ch_avoid_ind_type *ch_avoid);
413 
414 #ifdef FEATURE_WLAN_CH_AVOID_EXT
415 /**
416  * ucfg_reg_ch_avoid_ext () - Send channel avoid extend cmd to regulatory
417  * @psoc: psoc ptr
418  * @ch_avoid: ch_avoid_ind_type ranges
419  *
420  * This function send channel avoid extend cmd to regulatory from
421  * os_if/upper layer
422  *
423  * Return: void
424  */
425 void ucfg_reg_ch_avoid_ext(struct wlan_objmgr_psoc *psoc,
426 			   struct ch_avoid_ind_type *ch_avoid);
427 #endif
428 
429 /**
430  * ucfg_reg_11d_vdev_delete_update() - update vdev delete to regulatory
431  * @vdev: vdev ptr
432  *
433  * Return: QDF_STATUS
434  */
435 QDF_STATUS ucfg_reg_11d_vdev_delete_update(struct wlan_objmgr_vdev *vdev);
436 
437 /**
438  * ucfg_reg_11d_vdev_created_update() - update vdev create to regulatory
439  * @vdev: vdev ptr
440  *
441  * Return: QDF_STATUS
442  */
443 QDF_STATUS ucfg_reg_11d_vdev_created_update(struct wlan_objmgr_vdev *vdev);
444 
445 /**
446  * ucfg_reg_get_hal_reg_cap() - return hal reg cap
447  * @psoc: psoc ptr
448  *
449  * Return: ptr to  wlan_psoc_host_hal_reg_capabilities_ext
450  */
451 struct wlan_psoc_host_hal_reg_capabilities_ext *ucfg_reg_get_hal_reg_cap(
452 				struct wlan_objmgr_psoc *psoc);
453 
454 /**
455  * ucfg_reg_set_hal_reg_cap() - update hal reg cap
456  * @psoc: psoc ptr
457  * @reg_cap: Regulatory cap array
458  * @phy_cnt: Number of phy
459  *
460  * Return: QDF_STATUS
461  */
462 QDF_STATUS ucfg_reg_set_hal_reg_cap(struct wlan_objmgr_psoc *psoc,
463 			struct wlan_psoc_host_hal_reg_capabilities_ext *reg_cap,
464 			uint16_t phy_cnt);
465 
466 /**
467  * ucfg_reg_update_hal_reg_cap() - update hal reg cap
468  * @psoc: psoc ptr
469  * @wireless_modes: 11AX wireless modes
470  * @phy_id: phy id
471  *
472  * Return: QDF_STATUS
473  */
474 QDF_STATUS ucfg_reg_update_hal_reg_cap(struct wlan_objmgr_psoc *psoc,
475 				       uint64_t wireless_modes, uint8_t phy_id);
476 
477 /**
478  * ucfg_set_ignore_fw_reg_offload_ind() - API to set ignore regdb offload ind
479  * @psoc: psoc ptr
480  *
481  * Return: QDF_STATUS
482  */
483 QDF_STATUS ucfg_set_ignore_fw_reg_offload_ind(struct wlan_objmgr_psoc *psoc);
484 
485 /**
486  * ucfg_reg_get_unii_5g_bitmap() - get unii_5g_bitmap value
487  * @pdev: pdev pointer
488  * @bitmap: Pointer to retrieve unii_5g_bitmap of enum reg_unii_band.
489  *
490  * Return: QDF_STATUS
491  */
492 #ifdef DISABLE_UNII_SHARED_BANDS
493 QDF_STATUS
494 ucfg_reg_get_unii_5g_bitmap(struct wlan_objmgr_pdev *pdev, uint8_t *bitmap);
495 #else
496 static inline QDF_STATUS
497 ucfg_reg_get_unii_5g_bitmap(struct wlan_objmgr_pdev *pdev, uint8_t *bitmap)
498 {
499 	*bitmap = 0;
500 	return QDF_STATUS_SUCCESS;
501 }
502 #endif
503 
504 #if defined(CONFIG_BAND_6GHZ)
505 /**
506  * ucfg_reg_get_cur_6g_ap_pwr_type() - Get the current 6G regulatory AP power
507  * type.
508  * @pdev: Pointer to PDEV object.
509  * @reg_6g_ap_pwr_type: The current regulatory 6G AP type ie VLPI/LPI/SP.
510  *
511  * Return: QDF_STATUS.
512  */
513 QDF_STATUS
514 ucfg_reg_get_cur_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev,
515 				enum reg_6g_ap_type *reg_cur_6g_ap_pwr_type);
516 
517 /**
518  * ucfg_reg_set_cur_6g_ap_pwr_type() - Set the current 6G regulatory AP power
519  * type.
520  * @pdev: Pointer to PDEV object.
521  * @reg_6g_ap_pwr_type: Regulatory 6G AP type ie VLPI/LPI/SP.
522  *
523  * Return: QDF_STATUS_E_INVAL if unable to set and QDF_STATUS_SUCCESS is set.
524  */
525 QDF_STATUS
526 ucfg_reg_set_cur_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev,
527 				enum reg_6g_ap_type reg_cur_6g_ap_type);
528 #else
529 static inline QDF_STATUS
530 ucfg_reg_get_cur_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev,
531 				enum reg_6g_ap_type *reg_cur_6g_ap_pwr_type)
532 {
533 	*reg_cur_6g_ap_pwr_type = REG_INDOOR_AP;
534 	return QDF_STATUS_E_NOSUPPORT;
535 }
536 
537 static inline QDF_STATUS
538 ucfg_reg_set_cur_6g_ap_pwr_type(struct wlan_objmgr_pdev *pdev,
539 				enum reg_6g_ap_type reg_cur_6g_ap_type)
540 {
541 	return QDF_STATUS_E_NOSUPPORT;
542 }
543 #endif
544 
545 #if defined(CONFIG_AFC_SUPPORT) && defined(CONFIG_BAND_6GHZ)
546 /**
547  * ucfg_reg_send_afc_resp_rx_ind() - Send AFC response received indication to
548  * the FW.
549  * @pdev: pdev ptr
550  * @afc_ind_obj: Pointer to hold AFC indication
551  *
552  * Return: QDF_STATUS_SUCCESS if the WMI command is sent or QDF_STATUS_E_FAILURE
553  * otherwise
554  */
555 QDF_STATUS
556 ucfg_reg_send_afc_resp_rx_ind(struct wlan_objmgr_pdev *pdev,
557 			      struct reg_afc_resp_rx_ind_info *afc_ind_obj);
558 
559 /**
560  * ucfg_reg_afc_start() - Start the AFC request from regulatory. This finally
561  *                   sends the request to registered callbacks
562  * @pdev: Pointer to pdev
563  * @req_id: The AFC request ID
564  *
565  * Return: QDF_STATUS
566  */
567 QDF_STATUS ucfg_reg_afc_start(struct wlan_objmgr_pdev *pdev, uint64_t req_id);
568 #endif
569 #endif
570