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