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