xref: /wlan-dirver/qca-wifi-host-cmn/umac/regulatory/dispatcher/src/wlan_reg_services_api.c (revision 503663c6daafffe652fa360bde17243568cd6d2a)
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 					      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_dfs_ch(struct wlan_objmgr_pdev *pdev,
492 			uint8_t chan)
493 {
494 	return reg_is_dfs_ch(pdev, chan);
495 }
496 
497 bool wlan_reg_is_passive_or_disable_ch(struct wlan_objmgr_pdev *pdev,
498 				       uint8_t chan)
499 {
500 	return reg_is_passive_or_disable_ch(pdev, chan);
501 }
502 
503 bool wlan_reg_is_disable_ch(struct wlan_objmgr_pdev *pdev,
504 				       uint8_t chan)
505 {
506 	return reg_is_disable_ch(pdev, chan);
507 }
508 #endif /* CONFIG_CHAN_NUM_API */
509 
510 uint8_t wlan_reg_freq_to_chan(struct wlan_objmgr_pdev *pdev,
511 			      qdf_freq_t freq)
512 {
513 	return reg_freq_to_chan(pdev, freq);
514 }
515 
516 qdf_export_symbol(wlan_reg_freq_to_chan);
517 
518 #ifdef CONFIG_CHAN_NUM_API
519 qdf_freq_t wlan_reg_chan_to_freq(struct wlan_objmgr_pdev *pdev,
520 				 uint8_t chan_num)
521 {
522 	return reg_chan_to_freq(pdev, chan_num);
523 }
524 
525 qdf_export_symbol(wlan_reg_chan_to_freq);
526 
527 qdf_freq_t wlan_reg_legacy_chan_to_freq(struct wlan_objmgr_pdev *pdev,
528 					uint8_t chan_num)
529 {
530 	return reg_legacy_chan_to_freq(pdev, chan_num);
531 }
532 
533 bool wlan_reg_chan_is_49ghz(struct wlan_objmgr_pdev *pdev,
534 			    uint8_t chan_num)
535 {
536 	return reg_chan_is_49ghz(pdev, chan_num);
537 }
538 #endif /* CONFIG_CHAN_NUM_API */
539 
540 QDF_STATUS wlan_reg_set_country(struct wlan_objmgr_pdev *pdev,
541 				       uint8_t *country)
542 {
543 	return reg_set_country(pdev, country);
544 }
545 
546 QDF_STATUS wlan_reg_set_11d_country(struct wlan_objmgr_pdev *pdev,
547 				    uint8_t *country)
548 {
549 	return reg_set_11d_country(pdev, country);
550 }
551 
552 bool wlan_reg_is_world(uint8_t *country)
553 {
554 	return reg_is_world_alpha2(country);
555 }
556 
557 bool wlan_reg_is_us(uint8_t *country)
558 {
559 	return reg_is_us_alpha2(country);
560 }
561 
562 void wlan_reg_register_chan_change_callback(struct wlan_objmgr_psoc *psoc,
563 					    void *cbk, void *arg)
564 {
565 	reg_register_chan_change_callback(psoc, (reg_chan_change_callback)cbk,
566 					  arg);
567 
568 }
569 
570 void wlan_reg_unregister_chan_change_callback(struct wlan_objmgr_psoc *psoc,
571 					      void *cbk)
572 {
573 	reg_unregister_chan_change_callback(psoc,
574 					    (reg_chan_change_callback)cbk);
575 }
576 
577 bool wlan_reg_is_11d_offloaded(struct wlan_objmgr_psoc *psoc)
578 {
579 	return reg_is_11d_offloaded(psoc);
580 }
581 
582 bool wlan_reg_11d_enabled_on_host(struct wlan_objmgr_psoc *psoc)
583 {
584 	return reg_11d_enabled_on_host(psoc);
585 }
586 
587 #ifdef CONFIG_CHAN_NUM_API
588 bool wlan_reg_is_dsrc_chan(struct wlan_objmgr_pdev *pdev, uint8_t chan_num)
589 {
590 	return reg_is_dsrc_chan(pdev, chan_num);
591 }
592 
593 bool wlan_reg_is_etsi13_srd_chan(struct wlan_objmgr_pdev *pdev,
594 				 uint8_t chan_num)
595 {
596 	return reg_is_etsi13_srd_chan(pdev, chan_num);
597 }
598 #endif /* CONFIG_CHAN_NUM_API */
599 
600 bool wlan_reg_is_etsi13_regdmn(struct wlan_objmgr_pdev *pdev)
601 {
602 	return reg_is_etsi13_regdmn(pdev);
603 }
604 
605 bool wlan_reg_is_etsi13_srd_chan_allowed_master_mode(struct wlan_objmgr_pdev
606 						     *pdev)
607 {
608 	return reg_is_etsi13_srd_chan_allowed_master_mode(pdev);
609 }
610 
611 bool wlan_reg_get_fcc_constraint(struct wlan_objmgr_pdev *pdev, uint32_t freq)
612 {
613 	return reg_get_fcc_constraint(pdev, freq);
614 }
615 
616 QDF_STATUS wlan_reg_get_chip_mode(struct wlan_objmgr_pdev *pdev,
617 		uint32_t *chip_mode)
618 {
619 	struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj;
620 
621 	pdev_priv_obj = wlan_objmgr_pdev_get_comp_private_obj(pdev,
622 			WLAN_UMAC_COMP_REGULATORY);
623 
624 	if (!pdev_priv_obj) {
625 		reg_err("reg pdev private obj is NULL");
626 		return QDF_STATUS_E_FAULT;
627 	}
628 
629 	*chip_mode = pdev_priv_obj->wireless_modes;
630 
631 	return QDF_STATUS_SUCCESS;
632 }
633 
634 bool wlan_reg_is_11d_scan_inprogress(struct wlan_objmgr_psoc *psoc)
635 {
636 	return reg_is_11d_scan_inprogress(psoc);
637 }
638 
639 QDF_STATUS wlan_reg_get_freq_range(struct wlan_objmgr_pdev *pdev,
640 		qdf_freq_t *low_2g,
641 		qdf_freq_t *high_2g,
642 		qdf_freq_t *low_5g,
643 		qdf_freq_t *high_5g)
644 {
645 	struct wlan_regulatory_pdev_priv_obj *pdev_priv_obj;
646 
647 	pdev_priv_obj = wlan_objmgr_pdev_get_comp_private_obj(pdev,
648 			WLAN_UMAC_COMP_REGULATORY);
649 
650 	if (!pdev_priv_obj) {
651 		reg_err("reg pdev private obj is NULL");
652 		return QDF_STATUS_E_FAULT;
653 	}
654 
655 	*low_2g = pdev_priv_obj->range_2g_low;
656 	*high_2g = pdev_priv_obj->range_2g_high;
657 	*low_5g = pdev_priv_obj->range_5g_low;
658 	*high_5g = pdev_priv_obj->range_5g_high;
659 
660 	return QDF_STATUS_SUCCESS;
661 }
662 
663 struct wlan_lmac_if_reg_tx_ops *
664 wlan_reg_get_tx_ops(struct wlan_objmgr_psoc *psoc)
665 {
666 	return reg_get_psoc_tx_ops(psoc);
667 }
668 
669 QDF_STATUS wlan_reg_get_curr_regdomain(struct wlan_objmgr_pdev *pdev,
670 		struct cur_regdmn_info *cur_regdmn)
671 {
672 	return reg_get_curr_regdomain(pdev, cur_regdmn);
673 }
674 
675 #ifdef CONFIG_CHAN_NUM_API
676 uint8_t wlan_reg_min_24ghz_ch_num(void)
677 {
678 	return reg_min_24ghz_ch_num();
679 }
680 
681 uint8_t wlan_reg_max_24ghz_ch_num(void)
682 {
683 	return reg_max_24ghz_ch_num();
684 }
685 
686 uint8_t wlan_reg_min_5ghz_ch_num(void)
687 {
688 	return reg_min_5ghz_ch_num();
689 }
690 
691 uint8_t wlan_reg_max_5ghz_ch_num(void)
692 {
693 	return reg_max_5ghz_ch_num();
694 }
695 #endif /* CONFIG_CHAN_NUM_API */
696 
697 #ifdef CONFIG_CHAN_FREQ_API
698 qdf_freq_t wlan_reg_min_24ghz_chan_freq(void)
699 {
700 	return reg_min_24ghz_chan_freq();
701 }
702 
703 qdf_freq_t wlan_reg_max_24ghz_chan_freq(void)
704 {
705 	return reg_max_24ghz_chan_freq();
706 }
707 
708 qdf_freq_t wlan_reg_min_5ghz_chan_freq(void)
709 {
710 	return reg_min_5ghz_chan_freq();
711 }
712 
713 qdf_freq_t wlan_reg_max_5ghz_chan_freq(void)
714 {
715 	return reg_max_5ghz_chan_freq();
716 }
717 #endif /* CONFIG_CHAN_FREQ_API */
718 
719 #ifdef CONFIG_CHAN_NUM_API
720 bool wlan_reg_is_24ghz_ch(uint8_t chan)
721 {
722 	return reg_is_24ghz_ch(chan);
723 }
724 
725 bool wlan_reg_is_5ghz_ch(uint8_t chan)
726 {
727 	return reg_is_5ghz_ch(chan);
728 }
729 #endif /* CONFIG_CHAN_NUM_API */
730 
731 bool wlan_reg_is_24ghz_ch_freq(qdf_freq_t freq)
732 {
733 	return reg_is_24ghz_ch_freq(freq);
734 }
735 
736 bool wlan_reg_is_5ghz_ch_freq(qdf_freq_t freq)
737 {
738 	return reg_is_5ghz_ch_freq(freq);
739 }
740 
741 #ifdef CONFIG_BAND_6GHZ
742 bool wlan_reg_is_6ghz_chan_freq(uint16_t freq)
743 {
744 	return reg_is_6ghz_chan_freq(freq);
745 }
746 
747 uint16_t wlan_reg_min_6ghz_chan_freq(void)
748 {
749 	return reg_min_6ghz_chan_freq();
750 }
751 
752 uint16_t wlan_reg_max_6ghz_chan_freq(void)
753 {
754 	return reg_max_6ghz_chan_freq();
755 }
756 
757 bool wlan_reg_is_6ghz_psc_chan_freq(uint16_t freq)
758 {
759 	return reg_is_6ghz_psc_chan_freq(freq);
760 }
761 
762 #endif /* CONFIG_BAND_6GHZ */
763 
764 uint16_t
765 wlan_reg_get_band_channel_list(struct wlan_objmgr_pdev *pdev,
766 			       uint8_t band_mask,
767 			       struct regulatory_channel *channel_list)
768 {
769 	if (!pdev) {
770 		reg_err("pdev object is NULL");
771 		return 0;
772 	}
773 
774 	return reg_get_band_channel_list(pdev, band_mask, channel_list);
775 }
776 
777 qdf_freq_t wlan_reg_chan_band_to_freq(struct wlan_objmgr_pdev *pdev,
778 				      uint8_t chan, uint8_t band_mask)
779 {
780 	return reg_chan_band_to_freq(pdev, chan, band_mask);
781 }
782 
783 bool wlan_reg_is_49ghz_freq(qdf_freq_t freq)
784 {
785 	return reg_is_49ghz_freq(freq);
786 }
787 
788 uint8_t wlan_reg_ch_num(uint32_t ch_enum)
789 {
790 	return reg_ch_num(ch_enum);
791 }
792 
793 qdf_freq_t wlan_reg_ch_to_freq(uint32_t ch_enum)
794 {
795 	return reg_ch_to_freq(ch_enum);
796 }
797 
798 #ifdef CONFIG_CHAN_NUM_API
799 bool wlan_reg_is_same_band_channels(uint8_t chan_num1, uint8_t chan_num2)
800 {
801 	return reg_is_same_band_channels(chan_num1, chan_num2);
802 }
803 
804 bool wlan_reg_is_channel_valid_5g_sbs(uint8_t curchan, uint8_t newchan)
805 {
806 	return reg_is_channel_valid_5g_sbs(curchan, newchan);
807 }
808 
809 enum band_info wlan_reg_chan_to_band(uint8_t chan_num)
810 {
811 	return reg_chan_to_band(chan_num);
812 }
813 
814 qdf_export_symbol(wlan_reg_chan_to_band);
815 
816 /**
817  * wlan_reg_get_chan_enum() - Get channel enum for given channel number
818  * @chan_num: Channel number
819  *
820  * Return: Channel enum
821  */
822 enum channel_enum wlan_reg_get_chan_enum(uint8_t chan_num)
823 {
824 	return reg_get_chan_enum(chan_num);
825 }
826 #endif /* CONFIG_CHAN_NUM_API */
827 
828 bool wlan_reg_is_regdmn_en302502_applicable(struct wlan_objmgr_pdev *pdev)
829 {
830 	return reg_is_regdmn_en302502_applicable(pdev);
831 }
832 
833 /**
834  * wlan_reg_modify_pdev_chan_range() - Compute current channel list for the
835  * modified regcap.
836  * @pdev: pointer to struct wlan_objmgr_pdev
837  *
838  */
839 QDF_STATUS wlan_reg_modify_pdev_chan_range(struct wlan_objmgr_pdev *pdev)
840 {
841 	return reg_modify_pdev_chan_range(pdev);
842 }
843 
844 #ifdef DISABLE_UNII_SHARED_BANDS
845 QDF_STATUS wlan_reg_disable_chan_coex(struct wlan_objmgr_pdev *pdev,
846 				      uint8_t unii_5g_bitmap)
847 {
848 	return reg_disable_chan_coex(pdev, unii_5g_bitmap);
849 }
850 #endif
851 
852 #ifdef CONFIG_CHAN_FREQ_API
853 bool wlan_reg_is_same_band_freqs(qdf_freq_t freq1, qdf_freq_t freq2)
854 {
855 	return reg_is_same_band_freqs(freq1, freq2);
856 }
857 
858 bool wlan_reg_is_frequency_valid_5g_sbs(qdf_freq_t curfreq, qdf_freq_t newfreq)
859 {
860 	return reg_is_frequency_valid_5g_sbs(curfreq, newfreq);
861 }
862 
863 enum channel_enum wlan_reg_get_chan_enum_for_freq(qdf_freq_t freq)
864 {
865 	return reg_get_chan_enum_for_freq(freq);
866 }
867 
868 bool wlan_reg_is_etsi13_srd_chan_for_freq(struct wlan_objmgr_pdev *pdev,
869 					  qdf_freq_t freq)
870 {
871 	return reg_is_etsi13_srd_chan_for_freq(pdev, freq);
872 }
873 
874 bool wlan_reg_is_dsrc_freq(qdf_freq_t freq)
875 {
876 	return reg_is_dsrc_freq(freq);
877 }
878 
879 void wlan_reg_update_nol_ch_for_freq(struct wlan_objmgr_pdev *pdev,
880 				     uint16_t *chan_freq_list,
881 				     uint8_t num_ch,
882 				     bool nol_ch)
883 {
884 	reg_update_nol_ch_for_freq(pdev, chan_freq_list, num_ch, nol_ch);
885 }
886 
887 void wlan_reg_update_nol_history_ch_for_freq(struct wlan_objmgr_pdev *pdev,
888 					     uint16_t *ch_list,
889 					     uint8_t num_ch,
890 					     bool nol_history_ch)
891 {
892 	reg_update_nol_history_ch_for_freq(pdev,
893 					   ch_list,
894 					   num_ch,
895 					   nol_history_ch);
896 }
897 
898 bool wlan_reg_is_dfs_for_freq(struct wlan_objmgr_pdev *pdev, qdf_freq_t freq)
899 {
900 	return reg_is_dfs_for_freq(pdev, freq);
901 }
902 
903 bool wlan_reg_is_passive_or_disable_for_freq(struct wlan_objmgr_pdev *pdev,
904 					     qdf_freq_t freq)
905 {
906 	return reg_is_passive_or_disable_for_freq(pdev, freq);
907 }
908 
909 bool wlan_reg_is_disable_for_freq(struct wlan_objmgr_pdev *pdev,
910 				  qdf_freq_t freq)
911 {
912 	return reg_is_disable_for_freq(pdev, freq);
913 }
914 
915 QDF_STATUS
916 wlan_reg_get_channel_list_with_power_for_freq(struct wlan_objmgr_pdev *pdev,
917 					      struct channel_power *ch_list,
918 					      uint8_t *num_chan)
919 {
920 	return reg_get_channel_list_with_power_for_freq(pdev,
921 							ch_list,
922 							num_chan);
923 }
924 
925 bool
926 wlan_reg_chan_has_dfs_attribute_for_freq(struct wlan_objmgr_pdev *pdev,
927 					 qdf_freq_t freq)
928 {
929 	return reg_chan_has_dfs_attribute_for_freq(pdev, freq);
930 }
931 
932 enum channel_state
933 wlan_reg_get_5g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev,
934 					      qdf_freq_t freq,
935 					      enum phy_ch_width bw)
936 {
937 	return reg_get_5g_bonded_channel_state_for_freq(pdev, freq, bw);
938 }
939 
940 enum channel_state
941 wlan_reg_get_2g_bonded_channel_state_for_freq(struct wlan_objmgr_pdev *pdev,
942 					      qdf_freq_t freq,
943 					      qdf_freq_t sec_ch_freq,
944 					      enum phy_ch_width bw)
945 {
946 	return reg_get_2g_bonded_channel_state_for_freq(pdev,
947 							freq,
948 							sec_ch_freq,
949 							bw);
950 }
951 
952 void wlan_reg_set_channel_params_for_freq(struct wlan_objmgr_pdev *pdev,
953 					  qdf_freq_t freq,
954 					  qdf_freq_t sec_ch_2g_freq,
955 					  struct ch_params *ch_params)
956 {
957 	reg_set_channel_params_for_freq(pdev, freq, sec_ch_2g_freq, ch_params);
958 }
959 
960 enum channel_state
961 wlan_reg_get_channel_state_for_freq(struct wlan_objmgr_pdev *pdev,
962 				    qdf_freq_t freq)
963 {
964 	return reg_get_channel_state_for_freq(pdev, freq);
965 }
966 
967 uint8_t wlan_reg_get_channel_reg_power_for_freq(struct wlan_objmgr_pdev *pdev,
968 						qdf_freq_t freq)
969 {
970 	return reg_get_channel_reg_power_for_freq(pdev, freq);
971 }
972 
973 enum reg_wifi_band wlan_reg_freq_to_band(qdf_freq_t freq)
974 {
975 	return reg_freq_to_band(freq);
976 }
977 qdf_export_symbol(wlan_reg_freq_to_band);
978 
979 qdf_freq_t wlan_reg_min_chan_freq(void)
980 {
981 	return reg_min_chan_freq();
982 }
983 
984 qdf_freq_t wlan_reg_max_chan_freq(void)
985 {
986 	return reg_max_chan_freq();
987 }
988 
989 void wlan_reg_freq_width_to_chan_op_class(struct wlan_objmgr_pdev *pdev,
990 					  qdf_freq_t freq,
991 					  uint16_t chan_width,
992 					  bool global_tbl_lookup,
993 					  uint16_t behav_limit,
994 					  uint8_t *op_class,
995 					  uint8_t *chan_num)
996 {
997 	return reg_freq_width_to_chan_op_class(pdev, freq, chan_width,
998 					       global_tbl_lookup,
999 					       behav_limit,
1000 					       op_class,
1001 					       chan_num);
1002 }
1003 
1004 void wlan_reg_freq_to_chan_op_class(struct wlan_objmgr_pdev *pdev,
1005 				    qdf_freq_t freq,
1006 				    bool global_tbl_lookup,
1007 				    uint16_t behav_limit,
1008 				    uint8_t *op_class,
1009 				    uint8_t *chan_num)
1010 {
1011 	return reg_freq_to_chan_op_class(pdev, freq,
1012 					 global_tbl_lookup,
1013 					 behav_limit,
1014 					 op_class,
1015 					 chan_num);
1016 }
1017 
1018 enum channel_state
1019 wlan_reg_get_5g_bonded_channel_and_state_for_freq(struct wlan_objmgr_pdev *pdev,
1020 						  uint16_t freq,
1021 						  enum phy_ch_width bw,
1022 						  const
1023 						  struct bonded_channel_freq
1024 						  **bonded_chan_ptr_ptr)
1025 {
1026 	/*
1027 	 * Get channel frequencies and state from regulatory
1028 	 */
1029 	return reg_get_5g_bonded_channel_for_freq(pdev, freq, bw,
1030 						  bonded_chan_ptr_ptr);
1031 }
1032 
1033 qdf_export_symbol(wlan_reg_get_5g_bonded_channel_and_state_for_freq);
1034 
1035 #endif /* CONFIG CHAN FREQ API */
1036 
1037 uint16_t wlan_reg_get_op_class_width(struct wlan_objmgr_pdev *pdev,
1038 				     uint8_t op_class,
1039 				     bool global_tbl_lookup)
1040 {
1041 	return reg_get_op_class_width(pdev, op_class,
1042 				      global_tbl_lookup);
1043 }
1044 
1045 bool wlan_reg_is_6ghz_op_class(struct wlan_objmgr_pdev *pdev,
1046 			       uint8_t op_class)
1047 {
1048 	return reg_is_6ghz_op_class(pdev, op_class);
1049 }
1050 
1051 bool wlan_reg_is_6ghz_supported(struct wlan_objmgr_pdev *pdev)
1052 {
1053 	return reg_is_6ghz_supported(pdev);
1054 }
1055 
1056 uint16_t wlan_reg_chan_opclass_to_freq(uint8_t chan,
1057 				       uint8_t op_class,
1058 				       bool global_tbl_lookup)
1059 {
1060 	if (!chan || !op_class)
1061 		return 0;
1062 
1063 	return reg_chan_opclass_to_freq(chan, op_class, global_tbl_lookup);
1064 }
1065