xref: /wlan-driver/qca-wifi-host-cmn/target_if/regulatory/src/target_if_reg_lte.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1*5113495bSYour Name /*
2*5113495bSYour Name  * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved.
3*5113495bSYour Name  *
4*5113495bSYour Name  *
5*5113495bSYour Name  * Permission to use, copy, modify, and/or distribute this software for
6*5113495bSYour Name  * any purpose with or without fee is hereby granted, provided that the
7*5113495bSYour Name  * above copyright notice and this permission notice appear in all
8*5113495bSYour Name  * copies.
9*5113495bSYour Name  *
10*5113495bSYour Name  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11*5113495bSYour Name  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12*5113495bSYour Name  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13*5113495bSYour Name  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14*5113495bSYour Name  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15*5113495bSYour Name  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16*5113495bSYour Name  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17*5113495bSYour Name  * PERFORMANCE OF THIS SOFTWARE.
18*5113495bSYour Name  */
19*5113495bSYour Name 
20*5113495bSYour Name /**
21*5113495bSYour Name  * DOC: target_if_reg_lte.c
22*5113495bSYour Name  * This file contains regulatory target LTE interface
23*5113495bSYour Name  */
24*5113495bSYour Name 
25*5113495bSYour Name #ifdef LTE_COEX
26*5113495bSYour Name 
27*5113495bSYour Name #include "target_if_reg_lte.h"
28*5113495bSYour Name 
29*5113495bSYour Name /**
30*5113495bSYour Name  * tgt_reg_ch_avoid_event_handler() - Avoid channel list event handler.
31*5113495bSYour Name  * @handle: Pointer to scn handler.
32*5113495bSYour Name  * @event_buf: Pointer to event buffer.
33*5113495bSYour Name  * @len: Buffer length.
34*5113495bSYour Name  *
35*5113495bSYour Name  * Return: Error code.
36*5113495bSYour Name  */
tgt_reg_ch_avoid_event_handler(ol_scn_t handle,uint8_t * event_buf,uint32_t len)37*5113495bSYour Name static int tgt_reg_ch_avoid_event_handler(ol_scn_t handle, uint8_t *event_buf,
38*5113495bSYour Name 					  uint32_t len)
39*5113495bSYour Name {
40*5113495bSYour Name 	struct wlan_objmgr_psoc *psoc;
41*5113495bSYour Name 	struct wlan_lmac_if_reg_rx_ops *reg_rx_ops;
42*5113495bSYour Name 	struct ch_avoid_ind_type ch_avoid_event;
43*5113495bSYour Name 	QDF_STATUS status;
44*5113495bSYour Name 	struct wmi_unified *wmi_handle;
45*5113495bSYour Name 
46*5113495bSYour Name 	TARGET_IF_ENTER();
47*5113495bSYour Name 
48*5113495bSYour Name 	psoc = target_if_get_psoc_from_scn_hdl(handle);
49*5113495bSYour Name 	if (!psoc) {
50*5113495bSYour Name 		target_if_err("psoc ptr is NULL");
51*5113495bSYour Name 		return -EINVAL;
52*5113495bSYour Name 	}
53*5113495bSYour Name 
54*5113495bSYour Name 	reg_rx_ops = target_if_regulatory_get_rx_ops(psoc);
55*5113495bSYour Name 	if (!reg_rx_ops) {
56*5113495bSYour Name 		target_if_err("reg_rx_ops is NULL");
57*5113495bSYour Name 		return -EINVAL;
58*5113495bSYour Name 	}
59*5113495bSYour Name 
60*5113495bSYour Name 	if (!reg_rx_ops->reg_ch_avoid_event_handler) {
61*5113495bSYour Name 		target_if_err("reg_ch_avoid_event_handler is NULL");
62*5113495bSYour Name 		return -EINVAL;
63*5113495bSYour Name 	}
64*5113495bSYour Name 
65*5113495bSYour Name 	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
66*5113495bSYour Name 	if (!wmi_handle) {
67*5113495bSYour Name 		target_if_err("Invalid WMI handle");
68*5113495bSYour Name 		return -EINVAL;
69*5113495bSYour Name 	}
70*5113495bSYour Name 
71*5113495bSYour Name 	if (wmi_extract_reg_ch_avoid_event(
72*5113495bSYour Name 				wmi_handle, event_buf, &ch_avoid_event, len)
73*5113495bSYour Name 	    != QDF_STATUS_SUCCESS) {
74*5113495bSYour Name 		target_if_err("Extraction of CH avoid event failed");
75*5113495bSYour Name 		return -EFAULT;
76*5113495bSYour Name 	}
77*5113495bSYour Name 
78*5113495bSYour Name 	status = reg_rx_ops->reg_ch_avoid_event_handler(psoc, &ch_avoid_event);
79*5113495bSYour Name 	if (status != QDF_STATUS_SUCCESS) {
80*5113495bSYour Name 		target_if_err("Failed to process CH avoid event");
81*5113495bSYour Name 		return -EFAULT;
82*5113495bSYour Name 	}
83*5113495bSYour Name 
84*5113495bSYour Name 	TARGET_IF_EXIT();
85*5113495bSYour Name 
86*5113495bSYour Name 	return 0;
87*5113495bSYour Name }
88*5113495bSYour Name 
tgt_if_regulatory_register_ch_avoid_event_handler(struct wlan_objmgr_psoc * psoc,void * arg)89*5113495bSYour Name QDF_STATUS tgt_if_regulatory_register_ch_avoid_event_handler(
90*5113495bSYour Name 	struct wlan_objmgr_psoc *psoc, void *arg)
91*5113495bSYour Name {
92*5113495bSYour Name 	wmi_unified_t wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
93*5113495bSYour Name 
94*5113495bSYour Name 	if (!wmi_handle)
95*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
96*5113495bSYour Name 
97*5113495bSYour Name 	return wmi_unified_register_event(wmi_handle,
98*5113495bSYour Name 					  wmi_wlan_freq_avoid_event_id,
99*5113495bSYour Name 					  tgt_reg_ch_avoid_event_handler);
100*5113495bSYour Name }
101*5113495bSYour Name 
tgt_if_regulatory_unregister_ch_avoid_event_handler(struct wlan_objmgr_psoc * psoc,void * arg)102*5113495bSYour Name QDF_STATUS tgt_if_regulatory_unregister_ch_avoid_event_handler(
103*5113495bSYour Name 	struct wlan_objmgr_psoc *psoc, void *arg)
104*5113495bSYour Name {
105*5113495bSYour Name 	wmi_unified_t wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
106*5113495bSYour Name 
107*5113495bSYour Name 	if (!wmi_handle)
108*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
109*5113495bSYour Name 
110*5113495bSYour Name 	return wmi_unified_unregister_event(wmi_handle,
111*5113495bSYour Name 			wmi_wlan_freq_avoid_event_id);
112*5113495bSYour Name }
113*5113495bSYour Name #endif
114