xref: /wlan-dirver/qca-wifi-host-cmn/umac/regulatory/dispatcher/src/wlan_reg_services_api.c (revision f28396d060cff5c6519f883cb28ae0116ce479f1)
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  * @file wlan_reg_services_api.c
22  * @brief contains regulatory service functions
23  */
24 
25 
26 #include <qdf_status.h>
27 #include <qdf_types.h>
28 #include <qdf_module.h>
29 #include <wlan_cmn.h>
30 #include <reg_services_public_struct.h>
31 #include <wlan_reg_services_api.h>
32 #include <wlan_objmgr_psoc_obj.h>
33 #include <wlan_objmgr_pdev_obj.h>
34 #include "../../core/src/reg_priv_objs.h"
35 #include "../../core/src/reg_utils.h"
36 #include "../../core/src/reg_services_common.h"
37 #include "../../core/src/reg_db.h"
38 #include "../../core/src/reg_db_parser.h"
39 #include <../../core/src/reg_build_chan_list.h>
40 #include <../../core/src/reg_opclass.h>
41 #include <../../core/src/reg_callbacks.h>
42 #include <../../core/src/reg_offload_11d_scan.h>
43 #include <wlan_objmgr_global_obj.h>
44 
45 #ifdef CONFIG_CHAN_NUM_API
46 /**
47  * wlan_reg_get_channel_list_with_power() - Provide the channel list with power
48  * @ch_list: pointer to the channel list.
49  *
50  * Return: QDF_STATUS
51  */
52 QDF_STATUS wlan_reg_get_channel_list_with_power(struct wlan_objmgr_pdev *pdev,
53 						struct channel_power *ch_list,
54 						uint8_t *num_chan)
55 {
56 	/*
57 	 * Update the channel list with channel information with power.
58 	 */
59 	return reg_get_channel_list_with_power(pdev, ch_list, num_chan);
60 }
61 #endif /* CONFIG_CHAN_NUM_API */
62 
63 /**
64  * wlan_reg_read_default_country() - Read the default country for the regdomain
65  * @country: pointer to the country code.
66  *
67  * Return: None
68  */
69 QDF_STATUS wlan_reg_read_default_country(struct wlan_objmgr_psoc *psoc,
70 					 uint8_t *country)
71 {
72 	/*
73 	 * Get the default country information
74 	 */
75 	return reg_read_default_country(psoc, country);
76 }
77 
78 QDF_STATUS wlan_reg_read_current_country(struct wlan_objmgr_psoc *psoc,
79 					 uint8_t *country)
80 {
81 	/*
82 	 * Get the current country information
83 	 */
84 	return reg_read_current_country(psoc, country);
85 }
86 
87 #ifdef CONFIG_CHAN_NUM_API
88 /**
89  * wlan_reg_get_channel_state() - Get channel state from regulatory
90  * @ch: channel number.
91  *
92  * Return: channel state
93  */
94 enum channel_state wlan_reg_get_channel_state(struct wlan_objmgr_pdev *pdev,
95 					      uint8_t ch)
96 {
97 	/*
98 	 * Get channel state from regulatory
99 	 */
100 	return reg_get_channel_state(pdev, ch);
101 }
102 
103 bool
104 wlan_reg_chan_has_dfs_attribute(struct wlan_objmgr_pdev *pdev, uint8_t ch)
105 {
106 	return reg_chan_has_dfs_attribute(pdev, ch);
107 }
108 
109 /**
110  * wlan_reg_get_5g_bonded_channel_state() - Get 5G bonded channel state
111  * @ch: channel number.
112  * @bw: channel band width
113  *
114  * Return: channel state
115  */
116 enum channel_state wlan_reg_get_5g_bonded_channel_state(
117 	struct wlan_objmgr_pdev *pdev, uint8_t ch,
118 	enum phy_ch_width bw)
119 {
120 	/*
121 	 * Get channel state from regulatory
122 	 */
123 	return reg_get_5g_bonded_channel_state(pdev, ch, bw);
124 }
125 
126 /**
127  * wlan_reg_get_2g_bonded_channel_state() - Get 2G bonded channel state
128  * @ch: channel number.
129  * @bw: channel band width
130  *
131  * Return: channel state
132  */
133 enum channel_state wlan_reg_get_2g_bonded_channel_state(
134 		struct wlan_objmgr_pdev *pdev, uint8_t ch,
135 		uint8_t sec_ch, enum phy_ch_width bw)
136 {
137 	/*
138 	 * Get channel state from regulatory
139 	 */
140 	return reg_get_2g_bonded_channel_state(pdev, ch, sec_ch, bw);
141 }
142 
143 /**
144  * wlan_reg_set_channel_params() - Sets channel parameteres for given bandwidth
145  * @ch: channel number.
146  * @ch_params: pointer to the channel parameters.
147  *
148  * Return: None
149  */
150 void wlan_reg_set_channel_params(struct wlan_objmgr_pdev *pdev, uint8_t ch,
151 				 uint8_t sec_ch_2g,
152 				 struct ch_params *ch_params)
153 {
154 	/*
155 	 * Set channel parameters like center frequency for a bonded channel
156 	 * state. Also return the maximum bandwidth supported by the channel.
157 	 */
158 	reg_set_channel_params(pdev, ch, sec_ch_2g, ch_params);
159 }
160 #endif /* CONFIG_CHAN_NUM_API */
161 
162 /**
163  * wlan_reg_get_dfs_region () - Get the current dfs region
164  * @dfs_reg: pointer to dfs region
165  *
166  * Return: Status
167  */
168 QDF_STATUS wlan_reg_get_dfs_region(struct wlan_objmgr_pdev *pdev,
169 			     enum dfs_reg *dfs_reg)
170 {
171 	/*
172 	 * Get the current dfs region
173 	 */
174 	reg_get_current_dfs_region(pdev, dfs_reg);
175 
176 	return QDF_STATUS_SUCCESS;
177 }
178 
179 #ifdef CONFIG_CHAN_NUM_API
180 uint32_t wlan_reg_get_channel_reg_power(struct wlan_objmgr_pdev *pdev,
181 					uint8_t chan_num)
182 {
183 	return reg_get_channel_reg_power(pdev, chan_num);
184 }
185 
186 /**
187  * wlan_reg_get_channel_freq() - get regulatory power for channel
188  * @chan_num: channel number
189  *
190  * Return: int
191  */
192 qdf_freq_t wlan_reg_get_channel_freq(struct wlan_objmgr_pdev *pdev,
193 				     uint8_t chan_num)
194 {
195 	return reg_get_channel_freq(pdev, chan_num);
196 }
197 #endif /* CONFIG_CHAN_NUM_API */
198 
199 QDF_STATUS wlan_reg_get_current_chan_list(struct wlan_objmgr_pdev *pdev,
200 		struct regulatory_channel *chan_list)
201 {
202 	return reg_get_current_chan_list(pdev, chan_list);
203 }
204 
205 qdf_export_symbol(wlan_reg_get_current_chan_list);
206 
207 /**
208  * wlan_reg_get_bw_value() - give bandwidth value
209  * bw: bandwidth enum
210  *
211  * Return: uint16_t
212  */
213 uint16_t wlan_reg_get_bw_value(enum phy_ch_width bw)
214 {
215 	return reg_get_bw_value(bw);
216 }
217 
218 qdf_export_symbol(wlan_reg_get_bw_value);
219 
220 #ifdef CONFIG_CHAN_NUM_API
221 /**
222  * wlan_reg_get_bonded_channel_state() - Get 2G bonded channel state
223  * @ch: channel number.
224  * @bw: channel band width
225  *
226  * Return: channel state
227  */
228 enum channel_state wlan_reg_get_bonded_channel_state(
229 	struct wlan_objmgr_pdev *pdev, uint8_t ch,
230 	enum phy_ch_width bw, uint8_t sec_ch)
231 {
232 	if (WLAN_REG_IS_24GHZ_CH(ch))
233 		return reg_get_2g_bonded_channel_state(pdev, ch,
234 						       sec_ch, bw);
235 	else
236 		return reg_get_5g_bonded_channel_state(pdev, ch,
237 						       bw);
238 }
239 #endif /* CONFIG_CHAN_NUM_API */
240 
241 /**
242  * wlan_reg_set_dfs_region () - Get the current dfs region
243  * @dfs_reg: pointer to dfs region
244  *
245  * Return: None
246  */
247 void wlan_reg_set_dfs_region(struct wlan_objmgr_pdev *pdev,
248 			     enum dfs_reg dfs_reg)
249 {
250 	reg_set_dfs_region(pdev, dfs_reg);
251 }
252 
253 QDF_STATUS wlan_reg_get_domain_from_country_code(v_REGDOMAIN_t *reg_domain_ptr,
254 		const uint8_t *country_alpha2, enum country_src source)
255 {
256 
257 	return reg_get_domain_from_country_code(reg_domain_ptr,
258 			country_alpha2, source);
259 }
260 
261 
262 uint16_t wlan_reg_dmn_get_opclass_from_channel(uint8_t *country,
263 					       uint8_t channel,
264 					       uint8_t offset)
265 {
266 	return reg_dmn_get_opclass_from_channel(country, channel,
267 						offset);
268 }
269 
270 uint8_t wlan_reg_get_opclass_from_freq_width(uint8_t *country,
271 					     qdf_freq_t freq,
272 					     uint8_t ch_width,
273 					     uint16_t behav_limit)
274 {
275 	return reg_dmn_get_opclass_from_freq_width(country, freq, ch_width,
276 						   behav_limit);
277 }
278 
279 void wlan_reg_dmn_print_channels_in_opclass(uint8_t *country,
280 					    uint8_t opclass)
281 {
282 	reg_dmn_print_channels_in_opclass(country, opclass);
283 }
284 
285 uint16_t wlan_reg_dmn_get_chanwidth_from_opclass(uint8_t *country,
286 						 uint8_t channel,
287 						 uint8_t opclass)
288 {
289 	return reg_dmn_get_chanwidth_from_opclass(country, channel,
290 						  opclass);
291 }
292 
293 uint16_t wlan_reg_dmn_set_curr_opclasses(uint8_t num_classes,
294 					 uint8_t *class)
295 {
296 	return reg_dmn_set_curr_opclasses(num_classes, class);
297 }
298 
299 uint16_t wlan_reg_dmn_get_curr_opclasses(uint8_t *num_classes,
300 					 uint8_t *class)
301 {
302 	return reg_dmn_get_curr_opclasses(num_classes, class);
303 }
304 
305 QDF_STATUS
306 wlan_reg_get_opclass_details(struct wlan_objmgr_pdev *pdev,
307 			     struct regdmn_ap_cap_opclass_t *reg_ap_cap,
308 			     uint8_t *n_opclasses,
309 			     uint8_t max_supp_op_class,
310 			     bool global_tbl_lookup)
311 {
312 	return reg_get_opclass_details(pdev, reg_ap_cap, n_opclasses,
313 				       max_supp_op_class,
314 				       global_tbl_lookup);
315 }
316 
317 QDF_STATUS wlan_regulatory_init(void)
318 {
319 	QDF_STATUS status;
320 
321 	status = wlan_objmgr_register_psoc_create_handler(
322 		WLAN_UMAC_COMP_REGULATORY,
323 		wlan_regulatory_psoc_obj_created_notification, NULL);
324 	if (status != QDF_STATUS_SUCCESS) {
325 		reg_err("failed to register reg psoc obj create handler");
326 		return status;
327 	}
328 
329 	status = wlan_objmgr_register_psoc_destroy_handler(
330 		WLAN_UMAC_COMP_REGULATORY,
331 		wlan_regulatory_psoc_obj_destroyed_notification, NULL);
332 	if (status != QDF_STATUS_SUCCESS) {
333 		reg_err("failed to register reg psoc obj create handler");
334 		goto unreg_psoc_create;
335 	}
336 
337 	status = wlan_objmgr_register_pdev_create_handler(
338 		WLAN_UMAC_COMP_REGULATORY,
339 		wlan_regulatory_pdev_obj_created_notification, NULL);
340 	if (status != QDF_STATUS_SUCCESS) {
341 		reg_err("failed to register reg psoc obj create handler");
342 		goto unreg_psoc_destroy;
343 	}
344 
345 	status = wlan_objmgr_register_pdev_destroy_handler(
346 		WLAN_UMAC_COMP_REGULATORY,
347 		wlan_regulatory_pdev_obj_destroyed_notification, NULL);
348 	if (status != QDF_STATUS_SUCCESS) {
349 		reg_err("failed to register reg psoc obj create handler");
350 		goto unreg_pdev_create;
351 	}
352 	channel_map = channel_map_global;
353 	reg_debug("regulatory handlers registered with obj mgr");
354 
355 	return status;
356 
357 unreg_pdev_create:
358 	status = wlan_objmgr_unregister_pdev_create_handler(
359 		WLAN_UMAC_COMP_REGULATORY,
360 		wlan_regulatory_pdev_obj_created_notification,
361 		NULL);
362 
363 unreg_psoc_destroy:
364 	status = wlan_objmgr_unregister_psoc_destroy_handler(
365 		WLAN_UMAC_COMP_REGULATORY,
366 		wlan_regulatory_psoc_obj_destroyed_notification,
367 		NULL);
368 
369 unreg_psoc_create:
370 	status = wlan_objmgr_unregister_psoc_create_handler(
371 		WLAN_UMAC_COMP_REGULATORY,
372 		wlan_regulatory_psoc_obj_created_notification,
373 		NULL);
374 
375 	return QDF_STATUS_E_FAILURE;
376 }
377 
378 QDF_STATUS wlan_regulatory_deinit(void)
379 {
380 	QDF_STATUS status, ret_status = QDF_STATUS_SUCCESS;
381 
382 	status = wlan_objmgr_unregister_pdev_destroy_handler(
383 		WLAN_UMAC_COMP_REGULATORY,
384 		wlan_regulatory_pdev_obj_destroyed_notification, NULL);
385 	if (status != QDF_STATUS_SUCCESS) {
386 		reg_err("failed to unregister reg pdev obj destroy handler");
387 		ret_status = status;
388 	}
389 
390 	status = wlan_objmgr_unregister_pdev_create_handler(
391 		WLAN_UMAC_COMP_REGULATORY,
392 		wlan_regulatory_pdev_obj_created_notification, NULL);
393 	if (status != QDF_STATUS_SUCCESS) {
394 		reg_err("failed to unregister reg pdev obj create handler");
395 		ret_status = status;
396 	}
397 
398 	status = wlan_objmgr_unregister_psoc_destroy_handler(
399 		WLAN_UMAC_COMP_REGULATORY,
400 		wlan_regulatory_psoc_obj_destroyed_notification, NULL);
401 	if (status != QDF_STATUS_SUCCESS) {
402 		reg_err("failed to unregister reg psoc obj destroy handler");
403 		ret_status = status;
404 	}
405 
406 	status = wlan_objmgr_unregister_psoc_create_handler(
407 			WLAN_UMAC_COMP_REGULATORY,
408 			wlan_regulatory_psoc_obj_created_notification, NULL);
409 	if (status != QDF_STATUS_SUCCESS) {
410 		reg_err("failed to unregister reg psoc obj create handler");
411 		ret_status = status;
412 	}
413 
414 	reg_debug("deregistered callbacks with obj mgr");
415 
416 	return ret_status;
417 }
418 
419 QDF_STATUS regulatory_psoc_open(struct wlan_objmgr_psoc *psoc)
420 {
421 	struct wlan_lmac_if_reg_tx_ops *tx_ops;
422 
423 	tx_ops = reg_get_psoc_tx_ops(psoc);
424 	if (tx_ops->register_master_handler)
425 		tx_ops->register_master_handler(psoc, NULL);
426 	if (tx_ops->register_11d_new_cc_handler)
427 		tx_ops->register_11d_new_cc_handler(psoc, NULL);
428 	if (tx_ops->register_ch_avoid_event_handler)
429 		tx_ops->register_ch_avoid_event_handler(psoc, NULL);
430 
431 	return QDF_STATUS_SUCCESS;
432 }
433 
434 QDF_STATUS regulatory_psoc_close(struct wlan_objmgr_psoc *psoc)
435 {
436 	struct wlan_lmac_if_reg_tx_ops *tx_ops;
437 
438 	tx_ops = reg_get_psoc_tx_ops(psoc);
439 	if (tx_ops->unregister_11d_new_cc_handler)
440 		tx_ops->unregister_11d_new_cc_handler(psoc, NULL);
441 	if (tx_ops->unregister_master_handler)
442 		tx_ops->unregister_master_handler(psoc, NULL);
443 	if (tx_ops->unregister_ch_avoid_event_handler)
444 		tx_ops->unregister_ch_avoid_event_handler(psoc, NULL);
445 
446 	return QDF_STATUS_SUCCESS;
447 }
448 
449 QDF_STATUS regulatory_pdev_open(struct wlan_objmgr_pdev *pdev)
450 {
451 	struct wlan_objmgr_psoc *parent_psoc;
452 
453 	parent_psoc = wlan_pdev_get_psoc(pdev);
454 
455 	reg_send_scheduler_msg_nb(parent_psoc, pdev);
456 
457 	return QDF_STATUS_SUCCESS;
458 }
459 
460 QDF_STATUS regulatory_pdev_close(struct wlan_objmgr_pdev *pdev)
461 {
462 	struct wlan_objmgr_psoc *psoc;
463 	struct wlan_regulatory_psoc_priv_obj *soc_reg;
464 
465 	psoc = wlan_pdev_get_psoc(pdev);
466 	soc_reg = reg_get_psoc_obj(psoc);
467 	if (!soc_reg) {
468 		reg_err("reg psoc private obj is NULL");
469 		return QDF_STATUS_E_FAULT;
470 	}
471 
472 	reg_reset_ctry_pending_hints(soc_reg);
473 
474 	return QDF_STATUS_SUCCESS;
475 }
476 
477 #ifdef CONFIG_CHAN_NUM_API
478 void wlan_reg_update_nol_ch(struct wlan_objmgr_pdev *pdev, uint8_t *ch_list,
479 		uint8_t num_ch, bool nol_ch)
480 {
481 	reg_update_nol_ch(pdev, ch_list, num_ch, nol_ch);
482 }
483 
484 void wlan_reg_update_nol_history_ch(struct wlan_objmgr_pdev *pdev,
485 				    uint8_t *ch_list, uint8_t num_ch,
486 				    bool nol_history_ch)
487 {
488 	reg_update_nol_history_ch(pdev, ch_list, num_ch, nol_history_ch);
489 }
490 
491 bool wlan_reg_is_passive_or_disable_ch(struct wlan_objmgr_pdev *pdev,
492 				       uint8_t chan)
493 {
494 	return reg_is_passive_or_disable_ch(pdev, chan);
495 }
496 
497 bool wlan_reg_is_disable_ch(struct wlan_objmgr_pdev *pdev,
498 				       uint8_t chan)
499 {
500 	return reg_is_disable_ch(pdev, chan);
501 }
502 #endif /* CONFIG_CHAN_NUM_API */
503 
504 uint8_t wlan_reg_freq_to_chan(struct wlan_objmgr_pdev *pdev,
505 			      qdf_freq_t freq)
506 {
507 	return reg_freq_to_chan(pdev, freq);
508 }
509 
510 qdf_export_symbol(wlan_reg_freq_to_chan);
511 
512 #ifdef CONFIG_CHAN_NUM_API
513 qdf_freq_t wlan_reg_chan_to_freq(struct wlan_objmgr_pdev *pdev,
514 				 uint8_t chan_num)
515 {
516 	return reg_chan_to_freq(pdev, chan_num);
517 }
518 
519 qdf_export_symbol(wlan_reg_chan_to_freq);
520 
521 qdf_freq_t wlan_reg_legacy_chan_to_freq(struct wlan_objmgr_pdev *pdev,
522 					uint8_t chan_num)
523 {
524 	return reg_legacy_chan_to_freq(pdev, chan_num);
525 }
526 
527 bool wlan_reg_chan_is_49ghz(struct wlan_objmgr_pdev *pdev,
528 			    uint8_t chan_num)
529 {
530 	return reg_chan_is_49ghz(pdev, chan_num);
531 }
532 #endif /* CONFIG_CHAN_NUM_API */
533 
534 QDF_STATUS wlan_reg_set_country(struct wlan_objmgr_pdev *pdev,
535 				       uint8_t *country)
536 {
537 	return reg_set_country(pdev, country);
538 }
539 
540 QDF_STATUS wlan_reg_set_11d_country(struct wlan_objmgr_pdev *pdev,
541 				    uint8_t *country)
542 {
543 	return reg_set_11d_country(pdev, country);
544 }
545 
546 bool wlan_reg_is_world(uint8_t *country)
547 {
548 	return reg_is_world_alpha2(country);
549 }
550 
551 bool wlan_reg_is_us(uint8_t *country)
552 {
553 	return reg_is_us_alpha2(country);
554 }
555 
556 void wlan_reg_register_chan_change_callback(struct wlan_objmgr_psoc *psoc,
557 					    void *cbk, void *arg)
558 {
559 	reg_register_chan_change_callback(psoc, (reg_chan_change_callback)cbk,
560 					  arg);
561 
562 }
563 
564 void wlan_reg_unregister_chan_change_callback(struct wlan_objmgr_psoc *psoc,
565 					      void *cbk)
566 {
567 	reg_unregister_chan_change_callback(psoc,
568 					    (reg_chan_change_callback)cbk);
569 }
570 
571 bool wlan_reg_is_11d_offloaded(struct wlan_objmgr_psoc *psoc)
572 {
573 	return reg_is_11d_offloaded(psoc);
574 }
575 
576 bool wlan_reg_11d_enabled_on_host(struct wlan_objmgr_psoc *psoc)
577 {
578 	return reg_11d_enabled_on_host(psoc);
579 }
580 
581 #ifdef CONFIG_CHAN_NUM_API
582 bool wlan_reg_is_dsrc_chan(struct wlan_objmgr_pdev *pdev, uint8_t chan_num)
583 {
584 	return reg_is_dsrc_chan(pdev, chan_num);
585 }
586 
587 bool wlan_reg_is_etsi13_srd_chan(struct wlan_objmgr_pdev *pdev,
588 				 uint8_t chan_num)
589 {
590 	return reg_is_etsi13_srd_chan(pdev, chan_num);
591 }
592 #endif /* CONFIG_CHAN_NUM_API */
593 
594 bool wlan_reg_is_etsi13_regdmn(struct wlan_objmgr_pdev *pdev)
595 {
596 	return reg_is_etsi13_regdmn(pdev);
597 }
598 
599 bool wlan_reg_is_etsi13_srd_chan_allowed_master_mode(struct wlan_objmgr_pdev
600 						     *pdev)
601 {
602 	return reg_is_etsi13_srd_chan_allowed_master_mode(pdev);
603 }
604 
605 bool wlan_reg_get_fcc_constraint(struct wlan_objmgr_pdev *pdev, uint32_t freq)
606 {
607 	return reg_get_fcc_constraint(pdev, freq);
608 }
609 
610 QDF_STATUS wlan_reg_get_chip_mode(struct wlan_objmgr_pdev *pdev,
611 		uint32_t *chip_mode)
612 {
613 	struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj;
614 
615 	pdev_priv_obj = wlan_objmgr_pdev_get_comp_private_obj(pdev,
616 			WLAN_UMAC_COMP_REGULATORY);
617 
618 	if (!pdev_priv_obj) {
619 		reg_err("reg pdev private obj is NULL");
620 		return QDF_STATUS_E_FAULT;
621 	}
622 
623 	*chip_mode = pdev_priv_obj->wireless_modes;
624 
625 	return QDF_STATUS_SUCCESS;
626 }
627 
628 bool wlan_reg_is_11d_scan_inprogress(struct wlan_objmgr_psoc *psoc)
629 {
630 	return reg_is_11d_scan_inprogress(psoc);
631 }
632 
633 QDF_STATUS wlan_reg_get_freq_range(struct wlan_objmgr_pdev *pdev,
634 		qdf_freq_t *low_2g,
635 		qdf_freq_t *high_2g,
636 		qdf_freq_t *low_5g,
637 		qdf_freq_t *high_5g)
638 {
639 	struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj;
640 
641 	pdev_priv_obj = wlan_objmgr_pdev_get_comp_private_obj(pdev,
642 			WLAN_UMAC_COMP_REGULATORY);
643 
644 	if (!pdev_priv_obj) {
645 		reg_err("reg pdev private obj is NULL");
646 		return QDF_STATUS_E_FAULT;
647 	}
648 
649 	*low_2g = pdev_priv_obj->range_2g_low;
650 	*high_2g = pdev_priv_obj->range_2g_high;
651 	*low_5g = pdev_priv_obj->range_5g_low;
652 	*high_5g = pdev_priv_obj->range_5g_high;
653 
654 	return QDF_STATUS_SUCCESS;
655 }
656 
657 struct wlan_lmac_if_reg_tx_ops *
658 wlan_reg_get_tx_ops(struct wlan_objmgr_psoc *psoc)
659 {
660 	return reg_get_psoc_tx_ops(psoc);
661 }
662 
663 QDF_STATUS wlan_reg_get_curr_regdomain(struct wlan_objmgr_pdev *pdev,
664 		struct cur_regdmn_info *cur_regdmn)
665 {
666 	return reg_get_curr_regdomain(pdev, cur_regdmn);
667 }
668 
669 #ifdef CONFIG_CHAN_NUM_API
670 uint8_t wlan_reg_min_24ghz_ch_num(void)
671 {
672 	return reg_min_24ghz_ch_num();
673 }
674 
675 uint8_t wlan_reg_max_24ghz_ch_num(void)
676 {
677 	return reg_max_24ghz_ch_num();
678 }
679 
680 uint8_t wlan_reg_min_5ghz_ch_num(void)
681 {
682 	return reg_min_5ghz_ch_num();
683 }
684 
685 uint8_t wlan_reg_max_5ghz_ch_num(void)
686 {
687 	return reg_max_5ghz_ch_num();
688 }
689 #endif /* CONFIG_CHAN_NUM_API */
690 
691 #ifdef CONFIG_CHAN_FREQ_API
692 qdf_freq_t wlan_reg_min_24ghz_chan_freq(void)
693 {
694 	return reg_min_24ghz_chan_freq();
695 }
696 
697 qdf_freq_t wlan_reg_max_24ghz_chan_freq(void)
698 {
699 	return reg_max_24ghz_chan_freq();
700 }
701 
702 qdf_freq_t wlan_reg_min_5ghz_chan_freq(void)
703 {
704 	return reg_min_5ghz_chan_freq();
705 }
706 
707 qdf_freq_t wlan_reg_max_5ghz_chan_freq(void)
708 {
709 	return reg_max_5ghz_chan_freq();
710 }
711 #endif /* CONFIG_CHAN_FREQ_API */
712 
713 #ifdef CONFIG_CHAN_NUM_API
714 bool wlan_reg_is_24ghz_ch(uint8_t chan)
715 {
716 	return reg_is_24ghz_ch(chan);
717 }
718 
719 bool wlan_reg_is_5ghz_ch(uint8_t chan)
720 {
721 	return reg_is_5ghz_ch(chan);
722 }
723 #endif /* CONFIG_CHAN_NUM_API */
724 
725 bool wlan_reg_is_24ghz_ch_freq(qdf_freq_t freq)
726 {
727 	return reg_is_24ghz_ch_freq(freq);
728 }
729 
730 bool wlan_reg_is_5ghz_ch_freq(qdf_freq_t freq)
731 {
732 	return reg_is_5ghz_ch_freq(freq);
733 }
734 
735 #ifdef CONFIG_BAND_6GHZ
736 bool wlan_reg_is_6ghz_chan_freq(uint16_t freq)
737 {
738 	return reg_is_6ghz_chan_freq(freq);
739 }
740 
741 uint16_t wlan_reg_min_6ghz_chan_freq(void)
742 {
743 	return reg_min_6ghz_chan_freq();
744 }
745 
746 uint16_t wlan_reg_max_6ghz_chan_freq(void)
747 {
748 	return reg_max_6ghz_chan_freq();
749 }
750 
751 bool wlan_reg_is_6ghz_psc_chan_freq(uint16_t freq)
752 {
753 	return reg_is_6ghz_psc_chan_freq(freq);
754 }
755 
756 #endif /* CONFIG_BAND_6GHZ */
757 
758 uint16_t
759 wlan_reg_get_band_channel_list(struct wlan_objmgr_pdev *pdev,
760 			       uint8_t band_mask,
761 			       struct regulatory_channel *channel_list)
762 {
763 	if (!pdev) {
764 		reg_err("pdev object is NULL");
765 		return 0;
766 	}
767 
768 	return reg_get_band_channel_list(pdev, band_mask, channel_list);
769 }
770 
771 qdf_freq_t wlan_reg_chan_band_to_freq(struct wlan_objmgr_pdev *pdev,
772 				      uint8_t chan, uint8_t band_mask)
773 {
774 	return reg_chan_band_to_freq(pdev, chan, band_mask);
775 }
776 
777 bool wlan_reg_is_49ghz_freq(qdf_freq_t freq)
778 {
779 	return reg_is_49ghz_freq(freq);
780 }
781 
782 uint8_t wlan_reg_ch_num(uint32_t ch_enum)
783 {
784 	return reg_ch_num(ch_enum);
785 }
786 
787 qdf_freq_t wlan_reg_ch_to_freq(uint32_t ch_enum)
788 {
789 	return reg_ch_to_freq(ch_enum);
790 }
791 
792 #ifdef CONFIG_CHAN_NUM_API
793 bool wlan_reg_is_same_band_channels(uint8_t chan_num1, uint8_t chan_num2)
794 {
795 	return reg_is_same_band_channels(chan_num1, chan_num2);
796 }
797 
798 bool wlan_reg_is_channel_valid_5g_sbs(uint8_t curchan, uint8_t newchan)
799 {
800 	return reg_is_channel_valid_5g_sbs(curchan, newchan);
801 }
802 
803 enum band_info wlan_reg_chan_to_band(uint8_t chan_num)
804 {
805 	return reg_chan_to_band(chan_num);
806 }
807 
808 qdf_export_symbol(wlan_reg_chan_to_band);
809 
810 /**
811  * wlan_reg_get_chan_enum() - Get channel enum for given channel number
812  * @chan_num: Channel number
813  *
814  * Return: Channel enum
815  */
816 enum channel_enum wlan_reg_get_chan_enum(uint8_t chan_num)
817 {
818 	return reg_get_chan_enum(chan_num);
819 }
820 #endif /* CONFIG_CHAN_NUM_API */
821 
822 bool wlan_reg_is_regdmn_en302502_applicable(struct wlan_objmgr_pdev *pdev)
823 {
824 	return reg_is_regdmn_en302502_applicable(pdev);
825 }
826 
827 /**
828  * wlan_reg_modify_pdev_chan_range() - Compute current channel list for the
829  * modified regcap.
830  * @pdev: pointer to struct wlan_objmgr_pdev
831  *
832  */
833 QDF_STATUS wlan_reg_modify_pdev_chan_range(struct wlan_objmgr_pdev *pdev)
834 {
835 	return reg_modify_pdev_chan_range(pdev);
836 }
837 
838 #ifdef DISABLE_UNII_SHARED_BANDS
839 QDF_STATUS wlan_reg_disable_chan_coex(struct wlan_objmgr_pdev *pdev,
840 				      uint8_t unii_5g_bitmap)
841 {
842 	return reg_disable_chan_coex(pdev, unii_5g_bitmap);
843 }
844 #endif
845 
846 #ifdef CONFIG_CHAN_FREQ_API
847 bool wlan_reg_is_same_band_freqs(qdf_freq_t freq1, qdf_freq_t freq2)
848 {
849 	return reg_is_same_band_freqs(freq1, freq2);
850 }
851 
852 bool wlan_reg_is_frequency_valid_5g_sbs(qdf_freq_t curfreq, qdf_freq_t newfreq)
853 {
854 	return reg_is_frequency_valid_5g_sbs(curfreq, newfreq);
855 }
856 
857 enum channel_enum wlan_reg_get_chan_enum_for_freq(qdf_freq_t freq)
858 {
859 	return reg_get_chan_enum_for_freq(freq);
860 }
861 
862 bool wlan_reg_is_etsi13_srd_chan_for_freq(struct wlan_objmgr_pdev *pdev,
863 					  qdf_freq_t freq)
864 {
865 	return reg_is_etsi13_srd_chan_for_freq(pdev, freq);
866 }
867 
868 bool wlan_reg_is_dsrc_freq(qdf_freq_t freq)
869 {
870 	return reg_is_dsrc_freq(freq);
871 }
872 
873 void wlan_reg_update_nol_ch_for_freq(struct wlan_objmgr_pdev *pdev,
874 				     uint16_t *chan_freq_list,
875 				     uint8_t num_ch,
876 				     bool nol_ch)
877 {
878 	reg_update_nol_ch_for_freq(pdev, chan_freq_list, num_ch, nol_ch);
879 }
880 
881 void wlan_reg_update_nol_history_ch_for_freq(struct wlan_objmgr_pdev *pdev,
882 					     uint16_t *ch_list,
883 					     uint8_t num_ch,
884 					     bool nol_history_ch)
885 {
886 	reg_update_nol_history_ch_for_freq(pdev,
887 					   ch_list,
888 					   num_ch,
889 					   nol_history_ch);
890 }
891 
892 bool wlan_reg_is_dfs_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq)
893 {
894 	return reg_is_dfs_for_freq(pdev, freq);
895 }
896 
897 bool wlan_reg_is_passive_or_disable_for_freq(struct wlan_objmgr_pdev *pdev,
898 					     qdf_freq_t freq)
899 {
900 	return reg_is_passive_or_disable_for_freq(pdev, freq);
901 }
902 
903 bool wlan_reg_is_disable_for_freq(struct wlan_objmgr_pdev *pdev,
904 				  qdf_freq_t freq)
905 {
906 	return reg_is_disable_for_freq(pdev, freq);
907 }
908 
909 QDF_STATUS
910 wlan_reg_get_channel_list_with_power_for_freq(struct wlan_objmgr_pdev *pdev,
911 					      struct channel_power *ch_list,
912 					      uint8_t *num_chan)
913 {
914 	return reg_get_channel_list_with_power_for_freq(pdev,
915 							ch_list,
916 							num_chan);
917 }
918 
919 bool
920 wlan_reg_chan_has_dfs_attribute_for_freq(struct wlan_objmgr_pdev *pdev,
921 					 qdf_freq_t freq)
922 {
923 	return reg_chan_has_dfs_attribute_for_freq(pdev, freq);
924 }
925 
926 enum channel_state
927 wlan_reg_get_5g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev,
928 					      qdf_freq_t freq,
929 					      enum phy_ch_width bw)
930 {
931 	return reg_get_5g_bonded_channel_state_for_freq(pdev, freq, bw);
932 }
933 
934 enum channel_state
935 wlan_reg_get_2g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev,
936 					      qdf_freq_t freq,
937 					      qdf_freq_t sec_ch_freq,
938 					      enum phy_ch_width bw)
939 {
940 	return reg_get_2g_bonded_channel_state_for_freq(pdev,
941 							freq,
942 							sec_ch_freq,
943 							bw);
944 }
945 
946 void wlan_reg_set_channel_params_for_freq(struct wlan_objmgr_pdev *pdev,
947 					  qdf_freq_t freq,
948 					  qdf_freq_t sec_ch_2g_freq,
949 					  struct ch_params *ch_params)
950 {
951 	reg_set_channel_params_for_freq(pdev, freq, sec_ch_2g_freq, ch_params);
952 }
953 
954 enum channel_state
955 wlan_reg_get_channel_state_for_freq(struct wlan_objmgr_pdev *pdev,
956 				    qdf_freq_t freq)
957 {
958 	return reg_get_channel_state_for_freq(pdev, freq);
959 }
960 
961 uint8_t wlan_reg_get_channel_reg_power_for_freq(struct wlan_objmgr_pdev *pdev,
962 						qdf_freq_t freq)
963 {
964 	return reg_get_channel_reg_power_for_freq(pdev, freq);
965 }
966 
967 enum reg_wifi_band wlan_reg_freq_to_band(qdf_freq_t freq)
968 {
969 	return reg_freq_to_band(freq);
970 }
971 qdf_export_symbol(wlan_reg_freq_to_band);
972 
973 qdf_freq_t wlan_reg_min_chan_freq(void)
974 {
975 	return reg_min_chan_freq();
976 }
977 
978 qdf_freq_t wlan_reg_max_chan_freq(void)
979 {
980 	return reg_max_chan_freq();
981 }
982 
983 void wlan_reg_freq_width_to_chan_op_class(struct wlan_objmgr_pdev *pdev,
984 					  qdf_freq_t freq,
985 					  uint16_t chan_width,
986 					  bool global_tbl_lookup,
987 					  uint16_t behav_limit,
988 					  uint8_t *op_class,
989 					  uint8_t *chan_num)
990 {
991 	return reg_freq_width_to_chan_op_class(pdev, freq, chan_width,
992 					       global_tbl_lookup,
993 					       behav_limit,
994 					       op_class,
995 					       chan_num);
996 }
997 
998 void wlan_reg_freq_to_chan_op_class(struct wlan_objmgr_pdev *pdev,
999 				    qdf_freq_t freq,
1000 				    bool global_tbl_lookup,
1001 				    uint16_t behav_limit,
1002 				    uint8_t *op_class,
1003 				    uint8_t *chan_num)
1004 {
1005 	return reg_freq_to_chan_op_class(pdev, freq,
1006 					 global_tbl_lookup,
1007 					 behav_limit,
1008 					 op_class,
1009 					 chan_num);
1010 }
1011 
1012 enum channel_state
1013 wlan_reg_get_5g_bonded_channel_and_state_for_freq(struct wlan_objmgr_pdev *pdev,
1014 						  uint16_t freq,
1015 						  enum phy_ch_width bw,
1016 						  const
1017 						  struct bonded_channel_freq
1018 						  **bonded_chan_ptr_ptr)
1019 {
1020 	/*
1021 	 * Get channel frequencies and state from regulatory
1022 	 */
1023 	return reg_get_5g_bonded_channel_for_freq(pdev, freq, bw,
1024 						  bonded_chan_ptr_ptr);
1025 }
1026 
1027 qdf_export_symbol(wlan_reg_get_5g_bonded_channel_and_state_for_freq);
1028 
1029 #endif /* CONFIG CHAN FREQ API */
1030 
1031 uint16_t wlan_reg_get_op_class_width(struct wlan_objmgr_pdev *pdev,
1032 				     uint8_t op_class,
1033 				     bool global_tbl_lookup)
1034 {
1035 	return reg_get_op_class_width(pdev, op_class,
1036 				      global_tbl_lookup);
1037 }
1038 
1039 bool wlan_reg_is_6ghz_op_class(struct wlan_objmgr_pdev *pdev,
1040 			       uint8_t op_class)
1041 {
1042 	return reg_is_6ghz_op_class(pdev, op_class);
1043 }
1044 
1045 bool wlan_reg_is_6ghz_supported(struct wlan_objmgr_pdev *pdev)
1046 {
1047 	return reg_is_6ghz_supported(pdev);
1048 }
1049 
1050 uint16_t wlan_reg_chan_opclass_to_freq(uint8_t chan,
1051 				       uint8_t op_class,
1052 				       bool global_tbl_lookup)
1053 {
1054 	if (!chan || !op_class)
1055 		return 0;
1056 
1057 	return reg_chan_opclass_to_freq(chan, op_class, global_tbl_lookup);
1058 }
1059