xref: /wlan-dirver/qca-wifi-host-cmn/target_if/regulatory/src/target_if_reg.c (revision 8cfe6b10058a04cafb17eed051f2ddf11bee8931)
1 /*
2  * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  *
6  * Permission to use, copy, modify, and/or distribute this software for
7  * any purpose with or without fee is hereby granted, provided that the
8  * above copyright notice and this permission notice appear in all
9  * copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
12  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
13  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
14  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
15  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
16  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
17  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18  * PERFORMANCE OF THIS SOFTWARE.
19  */
20 
21 /**
22  * DOC: target_if_reg.c
23  * This file contains regulatory target interfaces.
24  */
25 
26 #include <wmi_unified_api.h>
27 #include <reg_services_public_struct.h>
28 #include <wlan_reg_tgt_api.h>
29 #include <target_if.h>
30 #include <target_if_reg.h>
31 #include <wmi_unified_reg_api.h>
32 #include <qdf_platform.h>
33 #include <target_if_reg_11d.h>
34 #include <target_if_reg_lte.h>
35 #include <wlan_reg_ucfg_api.h>
36 #include <wlan_utility.h>
37 #ifdef CONFIG_REG_CLIENT
38 #include <wlan_dcs_tgt_api.h>
39 #endif
40 
41 /**
42  * get_chan_list_cc_event_id() - Get chan_list_cc event i
43  *
44  * Return: Event id
45  */
46 static inline uint32_t get_chan_list_cc_event_id(void)
47 {
48 	return wmi_reg_chan_list_cc_event_id;
49 }
50 
51 /**
52  * tgt_if_regulatory_is_regdb_offloaded() - Check if regdb is offloaded
53  * @psoc: Pointer to psoc
54  *
55  * Return: true if regdb if offloaded, else false
56  */
57 static bool tgt_if_regulatory_is_regdb_offloaded(struct wlan_objmgr_psoc *psoc)
58 {
59 	struct wlan_lmac_if_reg_rx_ops *reg_rx_ops;
60 
61 	wmi_unified_t wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
62 
63 	reg_rx_ops = target_if_regulatory_get_rx_ops(psoc);
64 	if (!reg_rx_ops) {
65 		target_if_err("reg_rx_ops is NULL");
66 		return false;
67 	}
68 
69 	if (!wmi_handle)
70 		return false;
71 
72 	if (reg_rx_ops->reg_ignore_fw_reg_offload_ind &&
73 	    reg_rx_ops->reg_ignore_fw_reg_offload_ind(psoc)) {
74 		target_if_debug("User disabled regulatory offload from ini");
75 		return 0;
76 	}
77 
78 	return wmi_service_enabled(wmi_handle, wmi_service_regulatory_db);
79 }
80 
81 /**
82  * tgt_if_regulatory_is_6ghz_supported() - Check if 6ghz is supported
83  * @psoc: Pointer to psoc
84  *
85  * Return: true if regdb if offloaded, else false
86  */
87 static bool tgt_if_regulatory_is_6ghz_supported(struct wlan_objmgr_psoc *psoc)
88 {
89 	wmi_unified_t wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
90 
91 	if (!wmi_handle)
92 		return false;
93 
94 	return wmi_service_enabled(wmi_handle, wmi_service_6ghz_support);
95 }
96 
97 /**
98  * tgt_if_regulatory_is_5dot9_ghz_supported() - Check if 5.9ghz is supported
99  * @psoc: Pointer to psoc
100  *
101  * Return: true if regdb if offloaded, else false
102  */
103 static bool
104 tgt_if_regulatory_is_5dot9_ghz_supported(struct wlan_objmgr_psoc *psoc)
105 {
106 	wmi_unified_t wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
107 
108 	if (!wmi_handle)
109 		return false;
110 
111 	return wmi_service_enabled(wmi_handle, wmi_service_5dot9_ghz_support);
112 }
113 
114 /**
115  * tgt_if_regulatory_is_there_serv_ready_extn() - Check for service ready
116  * extension
117  * @psoc: Pointer to psoc object
118  *
119  * Return: true if service ready extension is present, else false.
120  */
121 static bool tgt_if_regulatory_is_there_serv_ready_extn(
122 		struct wlan_objmgr_psoc *psoc)
123 {
124 	wmi_unified_t wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
125 
126 	if (!wmi_handle)
127 		return false;
128 
129 	return wmi_service_enabled(wmi_handle, wmi_service_ext_msg);
130 }
131 
132 /**
133  * target_if_regulatory_get_rx_ops() - Get regdb rx ops
134  * @psoc: Pointer to psoc object
135  *
136  * Return: Reg rx_ops
137  */
138 struct wlan_lmac_if_reg_rx_ops *
139 target_if_regulatory_get_rx_ops(struct wlan_objmgr_psoc *psoc)
140 {
141 	struct wlan_lmac_if_rx_ops *rx_ops;
142 
143 	rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
144 	if (!rx_ops) {
145 		target_if_err("rx_ops is NULL");
146 		return NULL;
147 	}
148 
149 	return &rx_ops->reg_rx_ops;
150 }
151 
152 struct wlan_lmac_if_reg_tx_ops *
153 target_if_regulatory_get_tx_ops(struct wlan_objmgr_psoc *psoc)
154 {
155 	struct wlan_lmac_if_tx_ops *tx_ops;
156 
157 	tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
158 	if (!tx_ops) {
159 		target_if_err("tx_ops is NULL");
160 		return NULL;
161 	}
162 
163 	return &tx_ops->reg_ops;
164 }
165 
166 QDF_STATUS target_if_reg_set_offloaded_info(struct wlan_objmgr_psoc *psoc)
167 {
168 	struct wlan_lmac_if_reg_rx_ops *reg_rx_ops;
169 
170 	reg_rx_ops = target_if_regulatory_get_rx_ops(psoc);
171 	if (!reg_rx_ops) {
172 		target_if_err("reg_rx_ops is NULL");
173 		return QDF_STATUS_E_FAILURE;
174 	}
175 
176 	if (reg_rx_ops->reg_set_regdb_offloaded)
177 		reg_rx_ops->reg_set_regdb_offloaded(
178 				psoc,
179 				tgt_if_regulatory_is_regdb_offloaded(psoc));
180 
181 	if (reg_rx_ops->reg_set_11d_offloaded)
182 		reg_rx_ops->reg_set_11d_offloaded(
183 				psoc, tgt_if_regulatory_is_11d_offloaded(psoc));
184 
185 	return QDF_STATUS_SUCCESS;
186 }
187 
188 QDF_STATUS target_if_reg_set_6ghz_info(struct wlan_objmgr_psoc *psoc)
189 {
190 	struct wlan_lmac_if_reg_rx_ops *reg_rx_ops;
191 
192 	reg_rx_ops = target_if_regulatory_get_rx_ops(psoc);
193 	if (!reg_rx_ops) {
194 		target_if_err("reg_rx_ops is NULL");
195 		return QDF_STATUS_E_FAILURE;
196 	}
197 
198 	if (reg_rx_ops->reg_set_6ghz_supported)
199 		reg_rx_ops->reg_set_6ghz_supported(
200 			psoc,
201 			tgt_if_regulatory_is_6ghz_supported(psoc));
202 
203 	return QDF_STATUS_SUCCESS;
204 }
205 
206 QDF_STATUS target_if_reg_set_5dot9_ghz_info(struct wlan_objmgr_psoc *psoc)
207 {
208 	struct wlan_lmac_if_reg_rx_ops *reg_rx_ops;
209 
210 	reg_rx_ops = target_if_regulatory_get_rx_ops(psoc);
211 	if (!reg_rx_ops) {
212 		target_if_err("reg_rx_ops is NULL");
213 		return QDF_STATUS_E_FAILURE;
214 	}
215 
216 	if (reg_rx_ops->reg_set_5dot9_ghz_supported)
217 		reg_rx_ops->reg_set_5dot9_ghz_supported(
218 			psoc,
219 			tgt_if_regulatory_is_5dot9_ghz_supported(psoc));
220 
221 	return QDF_STATUS_SUCCESS;
222 }
223 
224 bool
225 target_if_reg_is_reg_cc_ext_event_host_supported(struct wlan_objmgr_psoc *psoc)
226 {
227 	struct wlan_lmac_if_reg_tx_ops *reg_tx_ops;
228 	bool reg_ext_cc_supp = false;
229 
230 	reg_tx_ops = target_if_regulatory_get_tx_ops(psoc);
231 	if (!reg_tx_ops) {
232 		target_if_err("reg_tx_ops is NULL");
233 		return reg_ext_cc_supp;
234 	}
235 
236 	if (reg_tx_ops->register_master_ext_handler)
237 		reg_ext_cc_supp = true;
238 
239 	return reg_ext_cc_supp;
240 }
241 
242 /**
243  * tgt_reg_chan_list_update_handler() - Channel list update handler
244  * @handle: scn handle
245  * @event_buf: pointer to event buffer
246  * @len: buffer length
247  *
248  * Return: 0 on success
249  */
250 static int tgt_reg_chan_list_update_handler(ol_scn_t handle, uint8_t *event_buf,
251 					    uint32_t len)
252 {
253 	struct wlan_objmgr_psoc *psoc;
254 	struct wlan_lmac_if_reg_rx_ops *reg_rx_ops;
255 	struct cur_regulatory_info *reg_info;
256 	QDF_STATUS status;
257 	struct wmi_unified *wmi_handle;
258 	int ret_val = 0;
259 
260 	TARGET_IF_ENTER();
261 
262 	psoc = target_if_get_psoc_from_scn_hdl(handle);
263 	if (!psoc) {
264 		target_if_err("psoc ptr is NULL");
265 		return -EINVAL;
266 	}
267 
268 	reg_rx_ops = target_if_regulatory_get_rx_ops(psoc);
269 	if (!reg_rx_ops) {
270 		target_if_err("reg_rx_ops is NULL");
271 		return -EINVAL;
272 	}
273 
274 	if (!reg_rx_ops->master_list_handler) {
275 		target_if_err("master_list_handler is NULL");
276 		return -EINVAL;
277 	}
278 
279 	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
280 	if (!wmi_handle) {
281 		target_if_err("invalid wmi handle");
282 		return -EINVAL;
283 	}
284 
285 	reg_info = qdf_mem_malloc(sizeof(*reg_info));
286 	if (!reg_info)
287 		return -ENOMEM;
288 
289 	if (wmi_extract_reg_chan_list_update_event(wmi_handle,
290 						   event_buf, reg_info, len)
291 	    != QDF_STATUS_SUCCESS) {
292 		target_if_err("Extraction of channel list event failed");
293 		ret_val = -EFAULT;
294 		goto clean;
295 	}
296 
297 	if (reg_info->phy_id >= PSOC_MAX_PHY_REG_CAP) {
298 		target_if_err_rl("phy_id %d is out of bounds",
299 				 reg_info->phy_id);
300 		ret_val = -EFAULT;
301 		goto clean;
302 	}
303 
304 	reg_info->psoc = psoc;
305 
306 	status = reg_rx_ops->master_list_handler(reg_info);
307 	if (status != QDF_STATUS_SUCCESS) {
308 		target_if_err("Failed to process master channel list handler");
309 		ret_val = -EFAULT;
310 	}
311 
312 clean:
313 	qdf_mem_free(reg_info->reg_rules_2g_ptr);
314 	qdf_mem_free(reg_info->reg_rules_5g_ptr);
315 	qdf_mem_free(reg_info);
316 
317 	TARGET_IF_EXIT();
318 
319 	return ret_val;
320 }
321 
322 /**
323  * tgt_if_regulatory_register_master_list_handler() - Register master channel
324  * list
325  * @psoc: Pointer to psoc
326  * @arg: Pointer to argument list
327  *
328  * Return: QDF_STATUS
329  */
330 static QDF_STATUS tgt_if_regulatory_register_master_list_handler(
331 	struct wlan_objmgr_psoc *psoc, void *arg)
332 {
333 	wmi_unified_t wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
334 
335 	if (!wmi_handle)
336 		return QDF_STATUS_E_FAILURE;
337 
338 	return wmi_unified_register_event_handler(
339 			wmi_handle, wmi_reg_chan_list_cc_event_id,
340 			tgt_reg_chan_list_update_handler, WMI_RX_WORK_CTX);
341 }
342 
343 /**
344  * tgt_if_regulatory_unregister_master_list_handler() - Unregister master
345  * channel list
346  * @psoc: Pointer to psoc
347  * @arg: Pointer to argument list
348  *
349  * Return: QDF_STATUS
350  */
351 static QDF_STATUS tgt_if_regulatory_unregister_master_list_handler(
352 	struct wlan_objmgr_psoc *psoc, void *arg)
353 {
354 	wmi_unified_t wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
355 
356 	if (!wmi_handle)
357 		return QDF_STATUS_E_FAILURE;
358 
359 	return wmi_unified_unregister_event_handler(
360 			wmi_handle, wmi_reg_chan_list_cc_event_id);
361 }
362 
363 #ifdef CONFIG_BAND_6GHZ
364 #ifdef CONFIG_REG_CLIENT
365 /**
366  * tgt_mem_free_fcc_rules() - Free regulatory fcc rules
367  * @reg_info: Pointer to regulatory info
368  *
369  */
370 static void tgt_reg_mem_free_fcc_rules(struct cur_regulatory_info *reg_info)
371 {
372 	qdf_mem_free(reg_info->fcc_rules_ptr);
373 }
374 #else
375 static void tgt_reg_mem_free_fcc_rules(struct cur_regulatory_info *reg_info)
376 {
377 }
378 #endif
379 
380 /**
381  * tgt_reg_chan_list_ext_update_handler() - Extended channel list update handler
382  * @handle: scn handle
383  * @event_buf: pointer to event buffer
384  * @len: buffer length
385  *
386  * Return: 0 on success
387  */
388 static int tgt_reg_chan_list_ext_update_handler(ol_scn_t handle,
389 						uint8_t *event_buf,
390 						uint32_t len)
391 {
392 	struct wlan_objmgr_psoc *psoc;
393 	struct wlan_lmac_if_reg_rx_ops *reg_rx_ops;
394 	struct cur_regulatory_info *reg_info;
395 	QDF_STATUS status;
396 	struct wmi_unified *wmi_handle;
397 	int ret_val = 0;
398 	uint32_t i;
399 
400 	TARGET_IF_ENTER();
401 
402 	psoc = target_if_get_psoc_from_scn_hdl(handle);
403 	if (!psoc) {
404 		target_if_err("psoc ptr is NULL");
405 		return -EINVAL;
406 	}
407 
408 	reg_rx_ops = target_if_regulatory_get_rx_ops(psoc);
409 	if (!reg_rx_ops) {
410 		target_if_err("reg_rx_ops is NULL");
411 		return -EINVAL;
412 	}
413 
414 	if (!reg_rx_ops->master_list_ext_handler) {
415 		target_if_err("master_list_ext_handler is NULL");
416 		return -EINVAL;
417 	}
418 
419 	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
420 	if (!wmi_handle) {
421 		target_if_err("invalid wmi handle");
422 		return -EINVAL;
423 	}
424 
425 	reg_info = qdf_mem_malloc(sizeof(*reg_info));
426 	if (!reg_info)
427 		return -ENOMEM;
428 
429 	status = wmi_extract_reg_chan_list_ext_update_event(wmi_handle,
430 							    event_buf,
431 							    reg_info, len);
432 	if (!QDF_IS_STATUS_SUCCESS(status)) {
433 		target_if_err("Extraction of ext channel list event failed");
434 		ret_val = -EFAULT;
435 		goto clean;
436 	}
437 
438 	if (reg_info->phy_id >= PSOC_MAX_PHY_REG_CAP) {
439 		target_if_err_rl("phy_id %d is out of bounds",
440 				 reg_info->phy_id);
441 		ret_val = -EFAULT;
442 		goto clean;
443 	}
444 
445 	reg_info->psoc = psoc;
446 
447 	status = reg_rx_ops->master_list_ext_handler(reg_info);
448 	if (!QDF_IS_STATUS_SUCCESS(status)) {
449 		target_if_err("Failed to process master ext channel list handler");
450 		ret_val = -EFAULT;
451 	}
452 
453 clean:
454 	qdf_mem_free(reg_info->reg_rules_2g_ptr);
455 	qdf_mem_free(reg_info->reg_rules_5g_ptr);
456 	tgt_reg_mem_free_fcc_rules(reg_info);
457 
458 	for (i = 0; i < REG_CURRENT_MAX_AP_TYPE; i++) {
459 		qdf_mem_free(reg_info->reg_rules_6g_ap_ptr[i]);
460 		qdf_mem_free(reg_info->
461 			reg_rules_6g_client_ptr[i][REG_DEFAULT_CLIENT]);
462 		qdf_mem_free(reg_info->
463 			reg_rules_6g_client_ptr[i][REG_SUBORDINATE_CLIENT]);
464 	}
465 
466 	qdf_mem_free(reg_info);
467 
468 	TARGET_IF_EXIT();
469 
470 	return ret_val;
471 }
472 
473 /**
474  * tgt_if_regulatory_register_master_list_ext_handler() - Register extended
475  * master channel list event handler
476  * @psoc: Pointer to psoc
477  * @arg: Pointer to argument list
478  *
479  * Return: QDF_STATUS
480  */
481 static QDF_STATUS tgt_if_regulatory_register_master_list_ext_handler(
482 	struct wlan_objmgr_psoc *psoc, void *arg)
483 {
484 	wmi_unified_t wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
485 
486 	if (!wmi_handle)
487 		return QDF_STATUS_E_FAILURE;
488 
489 	return wmi_unified_register_event_handler(
490 			wmi_handle, wmi_reg_chan_list_cc_ext_event_id,
491 			tgt_reg_chan_list_ext_update_handler, WMI_RX_WORK_CTX);
492 }
493 
494 /**
495  * tgt_if_regulatory_unregister_master_list_ext_handler() - Unregister extended
496  * master channel list event handler
497  * @psoc: Pointer to psoc
498  * @arg: Pointer to argument list
499  *
500  * Return: QDF_STATUS
501  */
502 static QDF_STATUS tgt_if_regulatory_unregister_master_list_ext_handler(
503 	struct wlan_objmgr_psoc *psoc, void *arg)
504 {
505 	wmi_unified_t wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
506 
507 	if (!wmi_handle)
508 		return QDF_STATUS_E_FAILURE;
509 
510 	return wmi_unified_unregister_event_handler(
511 			wmi_handle, wmi_reg_chan_list_cc_ext_event_id);
512 }
513 
514 #ifdef CONFIG_AFC_SUPPORT
515 /**
516  * tgt_afc_event_handler() - Handler for AFC Event
517  * @handle: scn handle
518  * @event_buf: pointer to event buffer
519  * @len: buffer length
520  *
521  * Return: 0 on success
522  */
523 static int
524 tgt_afc_event_handler(ol_scn_t handle, uint8_t *event_buf, uint32_t len)
525 {
526 	struct wlan_objmgr_psoc *psoc;
527 	struct wlan_lmac_if_reg_rx_ops *reg_rx_ops;
528 	struct afc_regulatory_info *afc_info;
529 	QDF_STATUS status;
530 	struct wmi_unified *wmi_handle;
531 	int ret_val = 0;
532 
533 	TARGET_IF_ENTER();
534 
535 	psoc = target_if_get_psoc_from_scn_hdl(handle);
536 	if (!psoc) {
537 		target_if_err("psoc ptr is NULL");
538 		return -EINVAL;
539 	}
540 
541 	reg_rx_ops = target_if_regulatory_get_rx_ops(psoc);
542 	if (!reg_rx_ops) {
543 		target_if_err("reg_rx_ops is NULL");
544 		return -EINVAL;
545 	}
546 
547 	if (!reg_rx_ops->afc_event_handler) {
548 		target_if_err("afc_event_handler is NULL");
549 		return -EINVAL;
550 	}
551 
552 	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
553 	if (!wmi_handle) {
554 		target_if_err("invalid wmi handle");
555 		return -EINVAL;
556 	}
557 
558 	afc_info = qdf_mem_malloc(sizeof(*afc_info));
559 	if (!afc_info)
560 		return -ENOMEM;
561 
562 	status = wmi_extract_afc_event(wmi_handle, event_buf, afc_info, len);
563 	if (!QDF_IS_STATUS_SUCCESS(status)) {
564 		target_if_err("Extraction of AFC event failed");
565 		ret_val = -EFAULT;
566 		goto clean;
567 	}
568 
569 	if (afc_info->phy_id >= PSOC_MAX_PHY_REG_CAP) {
570 		target_if_err_rl("phy_id %d is out of bounds",
571 				 afc_info->phy_id);
572 		ret_val = -EFAULT;
573 		goto clean;
574 	}
575 
576 	afc_info->psoc = psoc;
577 
578 	status = reg_rx_ops->afc_event_handler(afc_info);
579 	if (!QDF_IS_STATUS_SUCCESS(status)) {
580 		target_if_err("Failed to process AFC event handler");
581 		ret_val = -EFAULT;
582 		goto clean;
583 	}
584 
585 clean:
586 	qdf_mem_free(afc_info);
587 	TARGET_IF_EXIT();
588 
589 	return ret_val;
590 }
591 
592 /**
593  * tgt_if_regulatory_register_afc_event_handler() - Register AFC event
594  * handler
595  * @psoc: Pointer to psoc
596  * @arg: Pointer to argument list
597  *
598  * Return: QDF_STATUS
599  */
600 static QDF_STATUS tgt_if_regulatory_register_afc_event_handler(
601 	struct wlan_objmgr_psoc *psoc, void *arg)
602 {
603 	wmi_unified_t wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
604 
605 	if (!wmi_handle)
606 		return QDF_STATUS_E_FAILURE;
607 
608 	return wmi_unified_register_event_handler(
609 			wmi_handle, wmi_afc_event_id,
610 			tgt_afc_event_handler, WMI_RX_WORK_CTX);
611 }
612 
613 /**
614  * tgt_if_regulatory_unregister_afc_event_handler() - Unregister AFC event
615  * handler
616  * @psoc: Pointer to psoc
617  * @arg: Pointer to argument list
618  *
619  * Return: QDF_STATUS
620  */
621 static QDF_STATUS
622 tgt_if_regulatory_unregister_afc_event_handler(struct wlan_objmgr_psoc *psoc,
623 					       void *arg)
624 {
625 	wmi_unified_t wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
626 
627 	if (!wmi_handle)
628 		return QDF_STATUS_E_FAILURE;
629 
630 	return wmi_unified_unregister_event_handler(
631 			wmi_handle, wmi_afc_event_id);
632 }
633 #endif
634 #endif
635 
636 /**
637  * tgt_if_regulatory_set_country_code() - Set country code
638  * @psoc: Pointer to psoc
639  * @arg: Pointer to argument list
640  *
641  * Return: QDF_STATUS
642  */
643 static QDF_STATUS tgt_if_regulatory_set_country_code(
644 	struct wlan_objmgr_psoc *psoc, void *arg)
645 {
646 	wmi_unified_t wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
647 
648 	if (!wmi_handle)
649 		return QDF_STATUS_E_FAILURE;
650 
651 	return wmi_unified_set_country_cmd_send(wmi_handle, arg);
652 }
653 
654 /**
655  * tgt_if_regulatory_set_user_country_code() - Set user country code
656  * @psoc: Pointer to psoc
657  * @pdev_id: Pdev id
658  * @rd: Pointer to regdomain structure
659  *
660  * Return: QDF_STATUS
661  */
662 static QDF_STATUS tgt_if_regulatory_set_user_country_code(
663 	struct wlan_objmgr_psoc *psoc, uint8_t pdev_id, struct cc_regdmn_s *rd)
664 {
665 	struct wlan_objmgr_pdev *pdev;
666 	wmi_unified_t wmi_handle;
667 	QDF_STATUS status;
668 
669 	pdev = wlan_objmgr_get_pdev_by_id(psoc, pdev_id,
670 					  WLAN_REGULATORY_NB_ID);
671 
672 	wmi_handle = get_wmi_unified_hdl_from_pdev(pdev);
673 
674 	if (!wmi_handle) {
675 		status = QDF_STATUS_E_FAILURE;
676 		goto free_pdevref;
677 	}
678 
679 	status = wmi_unified_set_user_country_code_cmd_send(wmi_handle,
680 							    pdev_id, rd);
681 	if (QDF_IS_STATUS_ERROR(status))
682 		target_if_err("Set user country code failed,status %d",
683 			      status);
684 free_pdevref:
685 	wlan_objmgr_pdev_release_ref(pdev, WLAN_REGULATORY_NB_ID);
686 
687 	return status;
688 }
689 
690 QDF_STATUS tgt_if_regulatory_modify_freq_range(struct wlan_objmgr_psoc *psoc)
691 {
692 	struct wlan_psoc_host_hal_reg_capabilities_ext *reg_cap;
693 
694 	reg_cap = ucfg_reg_get_hal_reg_cap(psoc);
695 	if (!reg_cap) {
696 		target_if_err("reg cap is NULL");
697 		return QDF_STATUS_E_FAILURE;
698 	}
699 
700 	if (!(reg_cap->wireless_modes & HOST_REGDMN_MODE_11A)) {
701 		reg_cap->low_5ghz_chan = 0;
702 		reg_cap->high_5ghz_chan = 0;
703 	}
704 
705 	if (!(reg_cap->wireless_modes &
706 	     (HOST_REGDMN_MODE_11B | HOST_REGDMN_MODE_PUREG))) {
707 		reg_cap->low_2ghz_chan = 0;
708 		reg_cap->high_2ghz_chan = 0;
709 	}
710 
711 	target_if_debug("phy_id = %d - low_2ghz_chan = %d high_2ghz_chan = %d low_5ghz_chan = %d high_5ghz_chan = %d",
712 			reg_cap->phy_id,
713 			reg_cap->low_2ghz_chan,
714 			reg_cap->high_2ghz_chan,
715 			reg_cap->low_5ghz_chan,
716 			reg_cap->high_5ghz_chan);
717 
718 	return QDF_STATUS_SUCCESS;
719 }
720 
721 #ifdef CONFIG_REG_CLIENT
722 /**
723  * tgt_if_regulatory_send_ctl_info() - Send CTL info to firmware
724  * @psoc: Pointer to psoc
725  * @params: Pointer to reg control params
726  *
727  * Return: QDF_STATUS
728  */
729 static QDF_STATUS
730 tgt_if_regulatory_send_ctl_info(struct wlan_objmgr_psoc *psoc,
731 				struct reg_ctl_params *params)
732 {
733 	wmi_unified_t wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
734 
735 	if (!wmi_handle)
736 		return QDF_STATUS_E_FAILURE;
737 
738 	return wmi_unified_send_regdomain_info_to_fw_cmd(wmi_handle,
739 							 params->regd,
740 							 params->regd_2g,
741 							 params->regd_5g,
742 							 params->ctl_2g,
743 							 params->ctl_5g);
744 }
745 #else
746 static QDF_STATUS
747 tgt_if_regulatory_send_ctl_info(struct wlan_objmgr_psoc *psoc,
748 				struct reg_ctl_params *params)
749 {
750 	return QDF_STATUS_SUCCESS;
751 }
752 #endif
753 
754 /**
755  * tgt_if_regulatory_get_phy_id_from_pdev_id() - Get phy_id from pdev_id
756  * @psoc: Pointer to psoc
757  * @pdev_id: Pdev id
758  * @phy_id: phy_id
759  *
760  * Return: QDF_STATUS
761  */
762 static QDF_STATUS tgt_if_regulatory_get_phy_id_from_pdev_id(
763 	struct wlan_objmgr_psoc *psoc, uint8_t pdev_id, uint8_t *phy_id)
764 {
765 	struct target_psoc_info *tgt_if_handle = psoc->tgt_if_handle;
766 	uint8_t ret;
767 
768 	if (pdev_id >= WLAN_UMAC_MAX_PDEVS) {
769 		target_if_err("pdev_id is greater than WLAN_UMAC_MAX_PDEVS");
770 		return QDF_STATUS_E_FAILURE;
771 	}
772 
773 	/* By default pdev_id and phy_id have one to one mapping */
774 	*phy_id = pdev_id;
775 
776 	if (!(tgt_if_handle &&
777 	      tgt_if_handle->info.is_pdevid_to_phyid_map))
778 		return QDF_STATUS_SUCCESS;
779 
780 	ret = tgt_if_handle->info.pdev_id_to_phy_id_map[pdev_id];
781 
782 	if (ret < PSOC_MAX_PHY_REG_CAP) {
783 		*phy_id = ret;
784 	} else {
785 		target_if_err("phy_id is greater than PSOC_MAX_PHY_REG_CAP");
786 		return QDF_STATUS_E_FAILURE;
787 	}
788 
789 	return QDF_STATUS_SUCCESS;
790 }
791 
792 /**
793  * tgt_if_regulatory_get_pdev_id_from_phy_id() - Get pdev_id for phy_id
794  * @psoc: Pointer to psoc
795  * @phy_id: Phy id
796  * @pdev_id: Pdev id
797  *
798  * Return: QDF_STATUS
799  */
800 static QDF_STATUS tgt_if_regulatory_get_pdev_id_from_phy_id(
801 	struct wlan_objmgr_psoc *psoc, uint8_t phy_id, uint8_t *pdev_id)
802 {
803 	struct target_psoc_info *tgt_if_handle = psoc->tgt_if_handle;
804 	uint8_t i;
805 
806 	if (phy_id >= PSOC_MAX_PHY_REG_CAP) {
807 		target_if_err("phy_id is greater than PSOC_MAX_PHY_REG_CAP");
808 		return QDF_STATUS_E_FAILURE;
809 	}
810 
811 	/* By default pdev_id and phy_id have one to one mapping */
812 	*pdev_id = phy_id;
813 
814 	if (!(tgt_if_handle &&
815 	      tgt_if_handle->info.is_pdevid_to_phyid_map))
816 		return QDF_STATUS_SUCCESS;
817 
818 	for (i = 0; i < WLAN_UMAC_MAX_PDEVS; i++) {
819 		if (tgt_if_handle->info.pdev_id_to_phy_id_map[i] == phy_id)
820 			break;
821 	}
822 
823 	if (i < WLAN_UMAC_MAX_PDEVS) {
824 		*pdev_id = i;
825 	} else {
826 		target_if_err("pdev_id is greater than WLAN_UMAC_MAX_PDEVS");
827 		return QDF_STATUS_E_FAILURE;
828 	}
829 
830 	return QDF_STATUS_SUCCESS;
831 }
832 
833 #ifdef CONFIG_BAND_6GHZ
834 static void target_if_register_master_ext_handler(
835 				struct wlan_lmac_if_reg_tx_ops *reg_ops)
836 {
837 	reg_ops->register_master_ext_handler =
838 		tgt_if_regulatory_register_master_list_ext_handler;
839 
840 	reg_ops->unregister_master_ext_handler =
841 		tgt_if_regulatory_unregister_master_list_ext_handler;
842 }
843 
844 #ifdef CONFIG_AFC_SUPPORT
845 static void target_if_register_afc_event_handler(
846 				struct wlan_lmac_if_reg_tx_ops *reg_ops)
847 {
848 	reg_ops->register_afc_event_handler =
849 		tgt_if_regulatory_register_afc_event_handler;
850 
851 	reg_ops->unregister_afc_event_handler =
852 		tgt_if_regulatory_unregister_afc_event_handler;
853 }
854 
855 #ifdef CONFIG_REG_CLIENT
856 static void target_if_register_acs_trigger_for_afc
857 				(struct wlan_lmac_if_reg_tx_ops *reg_ops)
858 {
859 	reg_ops->trigger_acs_for_afc = tgt_afc_trigger_dcs;
860 }
861 #else
862 static void target_if_register_acs_trigger_for_afc
863 				(struct wlan_lmac_if_reg_tx_ops *reg_ops)
864 {
865 	reg_ops->trigger_acs_for_afc = NULL;
866 }
867 #endif
868 #else
869 static void target_if_register_afc_event_handler(
870 				struct wlan_lmac_if_reg_tx_ops *reg_ops)
871 {
872 }
873 
874 static void target_if_register_acs_trigger_for_afc
875 				(struct wlan_lmac_if_reg_tx_ops *reg_ops)
876 {
877 }
878 #endif
879 #else
880 static inline void
881 target_if_register_master_ext_handler(struct wlan_lmac_if_reg_tx_ops *reg_ops)
882 {
883 }
884 
885 static void target_if_register_afc_event_handler(
886 				struct wlan_lmac_if_reg_tx_ops *reg_ops)
887 {
888 }
889 
890 static void target_if_register_acs_trigger_for_afc
891 				(struct wlan_lmac_if_reg_tx_ops *reg_ops)
892 {
893 }
894 #endif
895 
896 static QDF_STATUS
897 tgt_if_regulatory_set_tpc_power(struct wlan_objmgr_psoc *psoc,
898 				uint8_t vdev_id,
899 				struct reg_tpc_power_info *param)
900 {
901 	wmi_unified_t wmi_handle;
902 	uint8_t pdev_id;
903 	struct wlan_objmgr_pdev *pdev;
904 	QDF_STATUS status;
905 
906 	pdev_id = wlan_get_pdev_id_from_vdev_id(psoc,
907 						vdev_id, WLAN_REGULATORY_NB_ID);
908 
909 	pdev = wlan_objmgr_get_pdev_by_id(psoc, pdev_id,
910 					  WLAN_REGULATORY_NB_ID);
911 
912 	wmi_handle = get_wmi_unified_hdl_from_pdev(pdev);
913 
914 	if (!wmi_handle) {
915 		status = QDF_STATUS_E_FAILURE;
916 		goto free_pdevref;
917 	}
918 	status = wmi_unified_send_set_tpc_power_cmd(wmi_handle, vdev_id, param);
919 	if (QDF_IS_STATUS_ERROR(status))
920 		target_if_err("send tpc power cmd failed, status: %d", status);
921 
922 free_pdevref:
923 	wlan_objmgr_pdev_release_ref(pdev, WLAN_REGULATORY_NB_ID);
924 
925 	return status;
926 }
927 
928 #ifdef CONFIG_AFC_SUPPORT
929 /**
930  * tgt_if_regulatory_send_afc_cmd() - Send AFC command to the FW
931  *
932  * @psoc: Pointer to psoc
933  * @pdev_id: Pdev id
934  * @param: Pointer to hold AFC indication.
935  *
936  * Return: QDF_STATUS_SUCCESS if WMI_AFC_CMD is sent, else QDF_STATUS_E_FAILURE
937  */
938 static QDF_STATUS
939 tgt_if_regulatory_send_afc_cmd(struct wlan_objmgr_psoc *psoc,
940 			       uint8_t pdev_id,
941 			       struct reg_afc_resp_rx_ind_info *param)
942 {
943 	struct wlan_objmgr_pdev *pdev;
944 	wmi_unified_t wmi_handle;
945 	QDF_STATUS status;
946 
947 	pdev = wlan_objmgr_get_pdev_by_id(psoc, pdev_id,
948 					  WLAN_REGULATORY_NB_ID);
949 
950 	wmi_handle = get_wmi_unified_hdl_from_pdev(pdev);
951 
952 	if (!wmi_handle) {
953 		status = QDF_STATUS_E_FAILURE;
954 		goto free_pdevref;
955 	}
956 
957 	status = wmi_unified_send_afc_cmd(wmi_handle, pdev_id, param);
958 
959 	if (QDF_IS_STATUS_ERROR(status))
960 		target_if_err("send afc  cmd failed, status: %d", status);
961 
962 free_pdevref:
963 	wlan_objmgr_pdev_release_ref(pdev, WLAN_REGULATORY_NB_ID);
964 
965 	return status;
966 }
967 
968 static void
969 tgt_if_register_afc_callback(struct wlan_lmac_if_reg_tx_ops *reg_ops)
970 {
971 	reg_ops->send_afc_ind = tgt_if_regulatory_send_afc_cmd;
972 	reg_ops->reg_get_min_psd = NULL;
973 }
974 #else
975 static void
976 tgt_if_register_afc_callback(struct wlan_lmac_if_reg_tx_ops *reg_ops)
977 {
978 }
979 #endif
980 
981 /**
982  * tgt_if_regulatory_is_ext_tpc_supported() - Check if FW supports new
983  * WMI command for TPC power
984  *
985  * @psoc: Pointer to psoc
986  *
987  * Return: true if FW supports new WMI command for TPC, else false
988  */
989 static bool
990 tgt_if_regulatory_is_ext_tpc_supported(struct wlan_objmgr_psoc *psoc)
991 {
992 	wmi_unified_t wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
993 
994 	if (!wmi_handle)
995 		return false;
996 
997 	return wmi_service_enabled(wmi_handle,
998 				   wmi_service_ext_tpc_reg_support);
999 }
1000 
1001 QDF_STATUS target_if_regulatory_set_ext_tpc(struct wlan_objmgr_psoc *psoc)
1002 {
1003 	struct wlan_lmac_if_reg_rx_ops *reg_rx_ops;
1004 
1005 	reg_rx_ops = target_if_regulatory_get_rx_ops(psoc);
1006 	if (!reg_rx_ops) {
1007 		target_if_err("reg_rx_ops is NULL");
1008 		return QDF_STATUS_E_FAILURE;
1009 	}
1010 
1011 	if (reg_rx_ops->reg_set_ext_tpc_supported)
1012 		reg_rx_ops->reg_set_ext_tpc_supported(
1013 			psoc,
1014 			tgt_if_regulatory_is_ext_tpc_supported(psoc));
1015 
1016 	return QDF_STATUS_SUCCESS;
1017 }
1018 
1019 #if defined(CONFIG_BAND_6GHZ) && defined(CONFIG_AFC_SUPPORT)
1020 void tgt_if_set_reg_afc_configure(struct target_psoc_info *tgt_hdl,
1021 				  struct wlan_objmgr_psoc *psoc)
1022 {
1023 	struct tgt_info *info;
1024 	wmi_unified_t wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
1025 
1026 	if (!wmi_handle || !tgt_hdl)
1027 		return;
1028 
1029 	if (!wmi_service_enabled(wmi_handle, wmi_service_afc_support)) {
1030 		target_if_err("service afc support not enable");
1031 		return;
1032 	}
1033 
1034 	info = (&tgt_hdl->info);
1035 
1036 	info->wlan_res_cfg.is_6ghz_sp_pwrmode_supp_enabled =
1037 		ucfg_reg_get_enable_6ghz_sp_mode_support(psoc);
1038 	info->wlan_res_cfg.afc_timer_check_disable =
1039 		ucfg_reg_get_afc_disable_timer_check(psoc);
1040 	info->wlan_res_cfg.afc_req_id_check_disable =
1041 		ucfg_reg_get_afc_disable_request_id_check(psoc);
1042 }
1043 #endif
1044 
1045 #if defined(CONFIG_BAND_6GHZ)
1046 /**
1047  * tgt_if_regulatory_is_lower_6g_edge_ch_supp() - Check if lower 6ghz
1048  * edge channel (5935MHz) is supported
1049  * @psoc: Pointer to psoc
1050  *
1051  * Return: true if channel is supported, else false
1052  */
1053 static bool
1054 tgt_if_regulatory_is_lower_6g_edge_ch_supp(struct wlan_objmgr_psoc *psoc)
1055 {
1056 	wmi_unified_t wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
1057 
1058 	if (!wmi_handle)
1059 		return false;
1060 
1061 	return wmi_service_enabled(wmi_handle,
1062 				   wmi_service_lower_6g_edge_ch_supp);
1063 }
1064 
1065 /**
1066  * tgt_if_regulatory_is_upper_6g_edge_ch_disabled() - Check if upper
1067  * 6ghz edge channel (7115MHz) is disabled
1068  * @psoc: Pointer to psoc
1069  *
1070  * Return: true if channel is disabled, else false
1071  */
1072 static bool
1073 tgt_if_regulatory_is_upper_6g_edge_ch_disabled(struct wlan_objmgr_psoc *psoc)
1074 {
1075 	wmi_unified_t wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
1076 
1077 	if (!wmi_handle)
1078 		return false;
1079 
1080 	return wmi_service_enabled(wmi_handle,
1081 				   wmi_service_disable_upper_6g_edge_ch_supp);
1082 }
1083 
1084 QDF_STATUS
1085 target_if_reg_set_lower_6g_edge_ch_info(struct wlan_objmgr_psoc *psoc)
1086 {
1087 	struct wlan_lmac_if_reg_rx_ops *reg_rx_ops;
1088 
1089 	reg_rx_ops = target_if_regulatory_get_rx_ops(psoc);
1090 	if (!reg_rx_ops) {
1091 		target_if_err("reg_rx_ops is NULL");
1092 		return QDF_STATUS_E_FAILURE;
1093 	}
1094 
1095 	if (reg_rx_ops->reg_set_lower_6g_edge_ch_supp)
1096 		reg_rx_ops->reg_set_lower_6g_edge_ch_supp(
1097 			psoc,
1098 			tgt_if_regulatory_is_lower_6g_edge_ch_supp(psoc));
1099 
1100 	return QDF_STATUS_SUCCESS;
1101 }
1102 
1103 QDF_STATUS
1104 target_if_reg_set_disable_upper_6g_edge_ch_info(struct wlan_objmgr_psoc *psoc)
1105 {
1106 	struct wlan_lmac_if_reg_rx_ops *reg_rx_ops;
1107 
1108 	reg_rx_ops = target_if_regulatory_get_rx_ops(psoc);
1109 	if (!reg_rx_ops) {
1110 		target_if_err("reg_rx_ops is NULL");
1111 		return QDF_STATUS_E_FAILURE;
1112 	}
1113 
1114 	if (reg_rx_ops->reg_set_disable_upper_6g_edge_ch_supp)
1115 		reg_rx_ops->reg_set_disable_upper_6g_edge_ch_supp(
1116 			psoc,
1117 			tgt_if_regulatory_is_upper_6g_edge_ch_disabled(psoc));
1118 
1119 	return QDF_STATUS_SUCCESS;
1120 }
1121 #else
1122 static inline bool
1123 tgt_if_regulatory_is_lower_6g_edge_ch_supp(struct wlan_objmgr_psoc *psoc)
1124 {
1125 	return false;
1126 }
1127 
1128 static inline bool
1129 tgt_if_regulatory_is_upper_6g_edge_ch_disabled(struct wlan_objmgr_psoc *psoc)
1130 {
1131 	return false;
1132 }
1133 #endif
1134 
1135 #if defined(CONFIG_AFC_SUPPORT)
1136 QDF_STATUS
1137 target_if_reg_set_afc_dev_type(struct wlan_objmgr_psoc *psoc,
1138 			       struct target_psoc_info *tgt_hdl)
1139 {
1140 	struct wlan_lmac_if_reg_rx_ops *reg_rx_ops;
1141 	struct tgt_info *info;
1142 
1143 	if (!tgt_hdl) {
1144 		target_if_err("target_psoc_info is null");
1145 		return QDF_STATUS_E_FAILURE;
1146 	}
1147 
1148 	reg_rx_ops = target_if_regulatory_get_rx_ops(psoc);
1149 	if (!reg_rx_ops) {
1150 		target_if_err("reg_rx_ops is NULL");
1151 		return QDF_STATUS_E_FAILURE;
1152 	}
1153 
1154 	info = (&tgt_hdl->info);
1155 
1156 	if (reg_rx_ops->reg_set_afc_dev_type)
1157 		reg_rx_ops->reg_set_afc_dev_type(
1158 			psoc,
1159 			info->service_ext2_param.afc_dev_type);
1160 
1161 	return QDF_STATUS_SUCCESS;
1162 }
1163 
1164 QDF_STATUS
1165 target_if_reg_get_afc_dev_type(struct wlan_objmgr_psoc *psoc,
1166 			       enum reg_afc_dev_deploy_type *reg_afc_dev_type)
1167 {
1168 	struct wlan_lmac_if_reg_rx_ops *reg_rx_ops;
1169 
1170 	reg_rx_ops = target_if_regulatory_get_rx_ops(psoc);
1171 	if (!reg_rx_ops) {
1172 		target_if_err("reg_rx_ops is NULL");
1173 		return QDF_STATUS_E_FAILURE;
1174 	}
1175 
1176 	if (reg_rx_ops->reg_get_afc_dev_type)
1177 		reg_rx_ops->reg_get_afc_dev_type(
1178 			psoc,
1179 			reg_afc_dev_type);
1180 
1181 	return QDF_STATUS_SUCCESS;
1182 }
1183 
1184 /**
1185  * tgt_if_regulatory_is_eirp_preferred_support() - Check if FW prefers EIRP
1186  * support for TPC power command.
1187  *
1188  * @psoc: Pointer to psoc
1189  *
1190  * Return: true if FW prefers EIRP format for TPC, else false
1191  */
1192 static bool
1193 target_if_regulatory_is_eirp_preferred_support(struct wlan_objmgr_psoc *psoc)
1194 {
1195 	wmi_unified_t wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
1196 
1197 	if (!wmi_handle)
1198 		return false;
1199 
1200 	return wmi_service_enabled(wmi_handle,
1201 				   wmi_service_eirp_preferred_support);
1202 }
1203 
1204 QDF_STATUS
1205 target_if_set_regulatory_eirp_preferred_support(struct wlan_objmgr_psoc *psoc)
1206 {
1207 	struct wlan_lmac_if_reg_rx_ops *reg_rx_ops;
1208 
1209 	reg_rx_ops = target_if_regulatory_get_rx_ops(psoc);
1210 	if (!reg_rx_ops) {
1211 		target_if_err("reg_rx_ops is NULL");
1212 		return QDF_STATUS_E_FAILURE;
1213 	}
1214 
1215 	if (reg_rx_ops->reg_set_eirp_preferred_support)
1216 		reg_rx_ops->reg_set_eirp_preferred_support(
1217 			psoc,
1218 			target_if_regulatory_is_eirp_preferred_support(psoc));
1219 
1220 	return QDF_STATUS_SUCCESS;
1221 }
1222 #endif
1223 
1224 /**
1225  * tgt_if_reg_is_chip_11be_cap() - Finds out if the hardware is capable
1226  * of 11BE. The capability bit is read from mac_phy_cap populated by the
1227  * FW per pdev.
1228  * @psoc: Pointer to psoc
1229  * @phy_id: phy_id
1230  *
1231  * Return: True if chip is 11BE capable, false otherwise.
1232  */
1233 #ifdef WLAN_FEATURE_11BE
1234 static bool tgt_if_reg_is_chip_11be_cap(struct wlan_objmgr_psoc *psoc,
1235 					uint16_t phy_id)
1236 {
1237 	struct wlan_psoc_host_mac_phy_caps *mac_phy_cap_arr, *mac_phy_cap;
1238 	struct target_psoc_info *tgt_hdl;
1239 	uint8_t pdev_id;
1240 	struct wlan_lmac_if_reg_tx_ops *reg_tx_ops;
1241 
1242 	reg_tx_ops = target_if_regulatory_get_tx_ops(psoc);
1243 
1244 	if (!reg_tx_ops) {
1245 		target_if_err("reg_tx_ops is NULL");
1246 		return false;
1247 	}
1248 
1249 	if (reg_tx_ops->get_pdev_id_from_phy_id)
1250 		reg_tx_ops->get_pdev_id_from_phy_id(psoc, phy_id, &pdev_id);
1251 	else
1252 		pdev_id = phy_id;
1253 
1254 	tgt_hdl = wlan_psoc_get_tgt_if_handle(psoc);
1255 	if (tgt_hdl) {
1256 		mac_phy_cap_arr = target_psoc_get_mac_phy_cap(tgt_hdl);
1257 		if (!mac_phy_cap_arr)
1258 			return false;
1259 		mac_phy_cap = &mac_phy_cap_arr[pdev_id];
1260 		if (mac_phy_cap && mac_phy_cap->supports_11be)
1261 			return true;
1262 	}
1263 	return false;
1264 }
1265 #else
1266 static bool tgt_if_reg_is_chip_11be_cap(struct wlan_objmgr_psoc *psoc,
1267 					uint16_t phy_id)
1268 {
1269 	return false;
1270 }
1271 #endif
1272 
1273 QDF_STATUS target_if_register_regulatory_tx_ops(
1274 		struct wlan_lmac_if_tx_ops *tx_ops)
1275 {
1276 	struct wlan_lmac_if_reg_tx_ops *reg_ops = &tx_ops->reg_ops;
1277 
1278 	reg_ops->register_master_handler =
1279 		tgt_if_regulatory_register_master_list_handler;
1280 
1281 	reg_ops->unregister_master_handler =
1282 		tgt_if_regulatory_unregister_master_list_handler;
1283 
1284 	target_if_register_master_ext_handler(reg_ops);
1285 
1286 	target_if_register_afc_event_handler(reg_ops);
1287 
1288 	reg_ops->set_country_code = tgt_if_regulatory_set_country_code;
1289 
1290 	reg_ops->fill_umac_legacy_chanlist = NULL;
1291 
1292 	reg_ops->set_country_failed = NULL;
1293 
1294 	target_if_register_acs_trigger_for_afc(reg_ops);
1295 
1296 	reg_ops->register_11d_new_cc_handler =
1297 		tgt_if_regulatory_register_11d_new_cc_handler;
1298 
1299 	reg_ops->unregister_11d_new_cc_handler =
1300 		tgt_if_regulatory_unregister_11d_new_cc_handler;
1301 
1302 	reg_ops->start_11d_scan = tgt_if_regulatory_start_11d_scan;
1303 
1304 	reg_ops->stop_11d_scan = tgt_if_regulatory_stop_11d_scan;
1305 
1306 	reg_ops->is_there_serv_ready_extn =
1307 		tgt_if_regulatory_is_there_serv_ready_extn;
1308 
1309 	reg_ops->set_user_country_code =
1310 		tgt_if_regulatory_set_user_country_code;
1311 
1312 	reg_ops->register_ch_avoid_event_handler =
1313 		tgt_if_regulatory_register_ch_avoid_event_handler;
1314 
1315 	reg_ops->unregister_ch_avoid_event_handler =
1316 		tgt_if_regulatory_unregister_ch_avoid_event_handler;
1317 
1318 	reg_ops->send_ctl_info = tgt_if_regulatory_send_ctl_info;
1319 
1320 	reg_ops->get_phy_id_from_pdev_id =
1321 			tgt_if_regulatory_get_phy_id_from_pdev_id;
1322 
1323 	reg_ops->get_pdev_id_from_phy_id =
1324 			tgt_if_regulatory_get_pdev_id_from_phy_id;
1325 
1326 	reg_ops->set_tpc_power = tgt_if_regulatory_set_tpc_power;
1327 
1328 	reg_ops->get_opclass_tbl_idx = NULL;
1329 
1330 	tgt_if_register_afc_callback(reg_ops);
1331 
1332 	reg_ops->is_chip_11be = tgt_if_reg_is_chip_11be_cap;
1333 
1334 	return QDF_STATUS_SUCCESS;
1335 }
1336