xref: /wlan-driver/qca-wifi-host-cmn/target_if/dfs/src/target_if_dfs.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1*5113495bSYour Name /*
2*5113495bSYour Name  * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved.
3*5113495bSYour Name  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
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_dfs.c
22*5113495bSYour Name  * This file contains dfs target interface
23*5113495bSYour Name  */
24*5113495bSYour Name 
25*5113495bSYour Name #include <target_if.h>
26*5113495bSYour Name #include <qdf_types.h>
27*5113495bSYour Name #include <qdf_status.h>
28*5113495bSYour Name #include <target_if_dfs.h>
29*5113495bSYour Name #include <wlan_module_ids.h>
30*5113495bSYour Name #include <wmi_unified_api.h>
31*5113495bSYour Name #include <wlan_lmac_if_def.h>
32*5113495bSYour Name #include <wmi_unified_priv.h>
33*5113495bSYour Name #include <wlan_scan_tgt_api.h>
34*5113495bSYour Name #include <wmi_unified_param.h>
35*5113495bSYour Name #include <wmi_unified_dfs_api.h>
36*5113495bSYour Name #include "wlan_dfs_tgt_api.h"
37*5113495bSYour Name #include "target_type.h"
38*5113495bSYour Name #include <init_deinit_lmac.h>
39*5113495bSYour Name #include <wlan_reg_ucfg_api.h>
40*5113495bSYour Name #include <target_if_dfs_full_offload.h>
41*5113495bSYour Name #include <target_if_dfs_partial_offload.h>
42*5113495bSYour Name 
43*5113495bSYour Name /**
44*5113495bSYour Name  * target_if_dfs_register_host_status_check_event() - Register host dfs
45*5113495bSYour Name  * confirmation event.
46*5113495bSYour Name  * @psoc: pointer to psoc.
47*5113495bSYour Name  *
48*5113495bSYour Name  * Return: QDF_STATUS.
49*5113495bSYour Name  */
50*5113495bSYour Name #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(HOST_DFS_SPOOF_TEST)
target_if_dfs_register_host_status_check_event(struct wlan_objmgr_psoc * psoc)51*5113495bSYour Name static QDF_STATUS target_if_dfs_register_host_status_check_event(
52*5113495bSYour Name 		struct wlan_objmgr_psoc *psoc)
53*5113495bSYour Name 
54*5113495bSYour Name {
55*5113495bSYour Name 	wmi_unified_t wmi_handle;
56*5113495bSYour Name 	QDF_STATUS retval;
57*5113495bSYour Name 
58*5113495bSYour Name 	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
59*5113495bSYour Name 	if (!wmi_handle) {
60*5113495bSYour Name 		target_if_err("null wmi_handle");
61*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
62*5113495bSYour Name 	}
63*5113495bSYour Name 
64*5113495bSYour Name 	retval = wmi_unified_register_event(wmi_handle,
65*5113495bSYour Name 			wmi_host_dfs_status_check_event_id,
66*5113495bSYour Name 			target_if_dfs_status_check_event_handler);
67*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(retval))
68*5113495bSYour Name 		target_if_err("wmi_dfs_radar_detection_event_id ret=%d",
69*5113495bSYour Name 			      retval);
70*5113495bSYour Name 
71*5113495bSYour Name 	return retval;
72*5113495bSYour Name }
73*5113495bSYour Name #else
target_if_dfs_register_host_status_check_event(struct wlan_objmgr_psoc * psoc)74*5113495bSYour Name static QDF_STATUS target_if_dfs_register_host_status_check_event(
75*5113495bSYour Name 		struct wlan_objmgr_psoc *psoc)
76*5113495bSYour Name {
77*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
78*5113495bSYour Name }
79*5113495bSYour Name #endif
80*5113495bSYour Name 
81*5113495bSYour Name /**
82*5113495bSYour Name  * target_if_is_dfs_3() - Is dfs3 support or not
83*5113495bSYour Name  * @target_type: target type being used.
84*5113495bSYour Name  *
85*5113495bSYour Name  * Return: true if dfs3 is supported, false otherwise.
86*5113495bSYour Name  */
target_if_is_dfs_3(uint32_t target_type)87*5113495bSYour Name static bool target_if_is_dfs_3(uint32_t target_type)
88*5113495bSYour Name {
89*5113495bSYour Name 	bool is_dfs_3;
90*5113495bSYour Name 
91*5113495bSYour Name 	switch (target_type) {
92*5113495bSYour Name 	case TARGET_TYPE_AR6320:
93*5113495bSYour Name 		is_dfs_3 = false;
94*5113495bSYour Name 		break;
95*5113495bSYour Name 	case TARGET_TYPE_ADRASTEA:
96*5113495bSYour Name 		is_dfs_3 = true;
97*5113495bSYour Name 		break;
98*5113495bSYour Name 	default:
99*5113495bSYour Name 		is_dfs_3 = true;
100*5113495bSYour Name 	}
101*5113495bSYour Name 
102*5113495bSYour Name 	return is_dfs_3;
103*5113495bSYour Name }
104*5113495bSYour Name 
105*5113495bSYour Name #ifdef MOBILE_DFS_SUPPORT
106*5113495bSYour Name /**
107*5113495bSYour Name  * target_if_radar_event_handler() - handle radar event when
108*5113495bSYour Name  * phyerr filter offload is enabled.
109*5113495bSYour Name  * @scn: Handle to HIF context
110*5113495bSYour Name  * @data: radar event buffer
111*5113495bSYour Name  * @datalen: radar event buffer length
112*5113495bSYour Name  *
113*5113495bSYour Name  * Return: 0 on success; error code otherwise
114*5113495bSYour Name  */
target_if_radar_event_handler(ol_scn_t scn,uint8_t * data,uint32_t datalen)115*5113495bSYour Name static int target_if_radar_event_handler(
116*5113495bSYour Name 	ol_scn_t scn, uint8_t *data, uint32_t datalen)
117*5113495bSYour Name {
118*5113495bSYour Name 	struct radar_event_info wlan_radar_event;
119*5113495bSYour Name 	struct wlan_objmgr_psoc *psoc;
120*5113495bSYour Name 	struct wlan_objmgr_pdev *pdev;
121*5113495bSYour Name 	struct wlan_lmac_if_dfs_rx_ops *dfs_rx_ops;
122*5113495bSYour Name 	struct wmi_unified *wmi_handle;
123*5113495bSYour Name 
124*5113495bSYour Name 	if (!scn || !data) {
125*5113495bSYour Name 		target_if_err("scn: %pK, data: %pK", scn, data);
126*5113495bSYour Name 		return -EINVAL;
127*5113495bSYour Name 	}
128*5113495bSYour Name 	psoc = target_if_get_psoc_from_scn_hdl(scn);
129*5113495bSYour Name 	if (!psoc) {
130*5113495bSYour Name 		target_if_err("null psoc");
131*5113495bSYour Name 		return -EINVAL;
132*5113495bSYour Name 	}
133*5113495bSYour Name 	dfs_rx_ops = target_if_dfs_get_rx_ops(psoc);
134*5113495bSYour Name 
135*5113495bSYour Name 	if (!dfs_rx_ops || !dfs_rx_ops->dfs_process_phyerr_filter_offload) {
136*5113495bSYour Name 		target_if_err("Invalid dfs_rx_ops: %pK", dfs_rx_ops);
137*5113495bSYour Name 		return -EINVAL;
138*5113495bSYour Name 	}
139*5113495bSYour Name 
140*5113495bSYour Name 	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
141*5113495bSYour Name 	if (!wmi_handle) {
142*5113495bSYour Name 		target_if_err("Invalid WMI context");
143*5113495bSYour Name 		return -EINVAL;
144*5113495bSYour Name 	}
145*5113495bSYour Name 
146*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(wmi_extract_wlan_radar_event_info(
147*5113495bSYour Name 			wmi_handle, data,
148*5113495bSYour Name 			&wlan_radar_event, datalen))) {
149*5113495bSYour Name 		target_if_err("failed to extract wlan radar event");
150*5113495bSYour Name 		return -EFAULT;
151*5113495bSYour Name 	}
152*5113495bSYour Name 	pdev = wlan_objmgr_get_pdev_by_id(psoc, wlan_radar_event.pdev_id,
153*5113495bSYour Name 					WLAN_DFS_ID);
154*5113495bSYour Name 	if (!pdev) {
155*5113495bSYour Name 		target_if_err("null pdev");
156*5113495bSYour Name 		return -EINVAL;
157*5113495bSYour Name 	}
158*5113495bSYour Name 	dfs_rx_ops->dfs_process_phyerr_filter_offload(pdev,
159*5113495bSYour Name 					&wlan_radar_event);
160*5113495bSYour Name 	wlan_objmgr_pdev_release_ref(pdev, WLAN_DFS_ID);
161*5113495bSYour Name 
162*5113495bSYour Name 	return 0;
163*5113495bSYour Name }
164*5113495bSYour Name 
165*5113495bSYour Name /**
166*5113495bSYour Name  * target_if_reg_phyerr_events_dfs2() - register dfs phyerr radar event.
167*5113495bSYour Name  * @psoc: pointer to psoc.
168*5113495bSYour Name  *
169*5113495bSYour Name  * Return: QDF_STATUS.
170*5113495bSYour Name  */
target_if_reg_phyerr_events_dfs2(struct wlan_objmgr_psoc * psoc)171*5113495bSYour Name static QDF_STATUS target_if_reg_phyerr_events_dfs2(
172*5113495bSYour Name 				struct wlan_objmgr_psoc *psoc)
173*5113495bSYour Name {
174*5113495bSYour Name 	QDF_STATUS ret;
175*5113495bSYour Name 	wmi_unified_t wmi_handle;
176*5113495bSYour Name 
177*5113495bSYour Name 	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
178*5113495bSYour Name 	if (!wmi_handle) {
179*5113495bSYour Name 		target_if_err("null wmi_handle");
180*5113495bSYour Name 		return QDF_STATUS_E_INVAL;
181*5113495bSYour Name 	}
182*5113495bSYour Name 
183*5113495bSYour Name 	ret = wmi_unified_register_event(wmi_handle,
184*5113495bSYour Name 					 wmi_dfs_radar_event_id,
185*5113495bSYour Name 					 target_if_radar_event_handler);
186*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(ret)) {
187*5113495bSYour Name 		target_if_err("failed to register wmi_dfs_radar_event_id");
188*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
189*5113495bSYour Name 	}
190*5113495bSYour Name 
191*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
192*5113495bSYour Name }
193*5113495bSYour Name #else
target_if_reg_phyerr_events_dfs2(struct wlan_objmgr_psoc * psoc)194*5113495bSYour Name static QDF_STATUS target_if_reg_phyerr_events_dfs2(
195*5113495bSYour Name 				struct wlan_objmgr_psoc *psoc)
196*5113495bSYour Name {
197*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
198*5113495bSYour Name }
199*5113495bSYour Name #endif
200*5113495bSYour Name 
target_if_dfs_offload(struct wlan_objmgr_psoc * psoc)201*5113495bSYour Name static bool target_if_dfs_offload(struct wlan_objmgr_psoc *psoc)
202*5113495bSYour Name {
203*5113495bSYour Name 	wmi_unified_t wmi_handle;
204*5113495bSYour Name 
205*5113495bSYour Name 	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
206*5113495bSYour Name 	if (!wmi_handle) {
207*5113495bSYour Name 		target_if_err("null wmi_handle");
208*5113495bSYour Name 		return false;
209*5113495bSYour Name 	}
210*5113495bSYour Name 
211*5113495bSYour Name 	return wmi_service_enabled(wmi_handle,
212*5113495bSYour Name 				   wmi_service_dfs_phyerr_offload);
213*5113495bSYour Name }
214*5113495bSYour Name 
215*5113495bSYour Name /**
216*5113495bSYour Name  * target_if_dfs_bangradar_320_supp: Check if bang radar 320 is supported
217*5113495bSYour Name  * @psoc: psoc handle
218*5113495bSYour Name  *
219*5113495bSYour Name  * Check the service of 'wmi_service_bang_radar_320_support' whether
220*5113495bSYour Name  * the bang radar 320 is supported or not.
221*5113495bSYour Name  *
222*5113495bSYour Name  * Return: true if the service is enabled, false otherwise
223*5113495bSYour Name  */
224*5113495bSYour Name 
target_if_dfs_bangradar_320_supp(struct wlan_objmgr_psoc * psoc)225*5113495bSYour Name static bool target_if_dfs_bangradar_320_supp(struct wlan_objmgr_psoc *psoc)
226*5113495bSYour Name {
227*5113495bSYour Name 	wmi_unified_t wmi_handle;
228*5113495bSYour Name 
229*5113495bSYour Name 	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
230*5113495bSYour Name 	if (!wmi_handle) {
231*5113495bSYour Name 		target_if_err("null wmi_handle");
232*5113495bSYour Name 		return false;
233*5113495bSYour Name 	}
234*5113495bSYour Name 
235*5113495bSYour Name 	return wmi_service_enabled(wmi_handle,
236*5113495bSYour Name 				   wmi_service_bang_radar_320_support);
237*5113495bSYour Name }
238*5113495bSYour Name 
239*5113495bSYour Name #ifdef WLAN_FEATURE_11BE
240*5113495bSYour Name /**
241*5113495bSYour Name  * target_if_dfs_is_radar_found_chan_freq_eq_center_freq() -
242*5113495bSYour Name  *			Check if service 'radar_found_chan_freq' is supported
243*5113495bSYour Name  * @psoc: psoc handle
244*5113495bSYour Name  *
245*5113495bSYour Name  * Check whether the service of 'radar_found_chan_freq' representing
246*5113495bSYour Name  * the center frequency of the radar segment is supported or not. If
247*5113495bSYour Name  * the service is not enabled, then chan_freq will indicate the
248*5113495bSYour Name  * channel's primary 20MHz center.
249*5113495bSYour Name  *
250*5113495bSYour Name  * Return: true if wmi_service_radar_found_chan_freq_eq_center_freq is
251*5113495bSYour Name  *         supported, false otherwise
252*5113495bSYour Name  */
253*5113495bSYour Name static bool
target_if_dfs_is_radar_found_chan_freq_eq_center_freq(struct wlan_objmgr_psoc * psoc)254*5113495bSYour Name target_if_dfs_is_radar_found_chan_freq_eq_center_freq(
255*5113495bSYour Name 						struct wlan_objmgr_psoc *psoc)
256*5113495bSYour Name {
257*5113495bSYour Name 	wmi_unified_t wmi_handle;
258*5113495bSYour Name 
259*5113495bSYour Name 	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
260*5113495bSYour Name 	if (!wmi_handle) {
261*5113495bSYour Name 		target_if_err("null wmi_handle");
262*5113495bSYour Name 		return false;
263*5113495bSYour Name 	}
264*5113495bSYour Name 	return wmi_service_enabled
265*5113495bSYour Name 		(wmi_handle,
266*5113495bSYour Name 		 wmi_service_radar_found_chan_freq_eq_center_freq);
267*5113495bSYour Name }
268*5113495bSYour Name #else
269*5113495bSYour Name static bool
target_if_dfs_is_radar_found_chan_freq_eq_center_freq(struct wlan_objmgr_psoc * psoc)270*5113495bSYour Name target_if_dfs_is_radar_found_chan_freq_eq_center_freq(
271*5113495bSYour Name 						struct wlan_objmgr_psoc *psoc)
272*5113495bSYour Name {
273*5113495bSYour Name 	return false;
274*5113495bSYour Name }
275*5113495bSYour Name #endif
276*5113495bSYour Name 
target_if_dfs_get_target_type(struct wlan_objmgr_pdev * pdev,uint32_t * target_type)277*5113495bSYour Name static QDF_STATUS target_if_dfs_get_target_type(struct wlan_objmgr_pdev *pdev,
278*5113495bSYour Name 						uint32_t *target_type)
279*5113495bSYour Name {
280*5113495bSYour Name 	struct wlan_objmgr_psoc *psoc;
281*5113495bSYour Name 	struct target_psoc_info *tgt_psoc_info;
282*5113495bSYour Name 
283*5113495bSYour Name 	psoc = wlan_pdev_get_psoc(pdev);
284*5113495bSYour Name 	if (!psoc) {
285*5113495bSYour Name 		target_if_err("null psoc");
286*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
287*5113495bSYour Name 	}
288*5113495bSYour Name 
289*5113495bSYour Name 	tgt_psoc_info = wlan_psoc_get_tgt_if_handle(psoc);
290*5113495bSYour Name 	if (!tgt_psoc_info) {
291*5113495bSYour Name 		target_if_err("null tgt_psoc_info");
292*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
293*5113495bSYour Name 	}
294*5113495bSYour Name 	*target_type = target_psoc_get_target_type(tgt_psoc_info);
295*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
296*5113495bSYour Name }
297*5113495bSYour Name 
target_if_dfs_register_event_handler(struct wlan_objmgr_psoc * psoc)298*5113495bSYour Name static QDF_STATUS target_if_dfs_register_event_handler(
299*5113495bSYour Name 		struct wlan_objmgr_psoc *psoc)
300*5113495bSYour Name {
301*5113495bSYour Name 	struct target_psoc_info *tgt_psoc_info;
302*5113495bSYour Name 
303*5113495bSYour Name 	if (!psoc) {
304*5113495bSYour Name 		target_if_err("null psoc");
305*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
306*5113495bSYour Name 	}
307*5113495bSYour Name 
308*5113495bSYour Name 	if (!target_if_dfs_offload(psoc)) {
309*5113495bSYour Name 		tgt_psoc_info = wlan_psoc_get_tgt_if_handle(psoc);
310*5113495bSYour Name 		if (!tgt_psoc_info) {
311*5113495bSYour Name 			target_if_err("null tgt_psoc_info");
312*5113495bSYour Name 			return QDF_STATUS_E_FAILURE;
313*5113495bSYour Name 		}
314*5113495bSYour Name 
315*5113495bSYour Name 		target_if_dfs_register_host_status_check_event(psoc);
316*5113495bSYour Name 
317*5113495bSYour Name 		if (target_if_is_dfs_3(
318*5113495bSYour Name 				target_psoc_get_target_type(tgt_psoc_info)))
319*5113495bSYour Name 			return target_if_dfs_reg_phyerr_events(psoc);
320*5113495bSYour Name 		else
321*5113495bSYour Name 			return target_if_reg_phyerr_events_dfs2(psoc);
322*5113495bSYour Name 	} else {
323*5113495bSYour Name 		return target_if_dfs_reg_offload_events(psoc);
324*5113495bSYour Name 	}
325*5113495bSYour Name }
326*5113495bSYour Name 
target_if_dfs_is_pdev_5ghz(struct wlan_objmgr_pdev * pdev,bool * is_5ghz)327*5113495bSYour Name static QDF_STATUS target_if_dfs_is_pdev_5ghz(struct wlan_objmgr_pdev *pdev,
328*5113495bSYour Name 		bool *is_5ghz)
329*5113495bSYour Name {
330*5113495bSYour Name 	struct wlan_objmgr_psoc *psoc;
331*5113495bSYour Name 	uint8_t pdev_id;
332*5113495bSYour Name 	struct wlan_psoc_host_hal_reg_capabilities_ext *reg_cap_ptr;
333*5113495bSYour Name 
334*5113495bSYour Name 	psoc = wlan_pdev_get_psoc(pdev);
335*5113495bSYour Name 	if (!psoc) {
336*5113495bSYour Name 		target_if_err("dfs: null psoc");
337*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
338*5113495bSYour Name 	}
339*5113495bSYour Name 
340*5113495bSYour Name 	pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
341*5113495bSYour Name 
342*5113495bSYour Name 	reg_cap_ptr = ucfg_reg_get_hal_reg_cap(psoc);
343*5113495bSYour Name 	if (!reg_cap_ptr) {
344*5113495bSYour Name 		target_if_err("dfs: reg cap null");
345*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
346*5113495bSYour Name 	}
347*5113495bSYour Name 
348*5113495bSYour Name 	if (reg_cap_ptr[pdev_id].wireless_modes &
349*5113495bSYour Name 			HOST_REGDMN_MODE_11A)
350*5113495bSYour Name 		*is_5ghz = true;
351*5113495bSYour Name 	else
352*5113495bSYour Name 		*is_5ghz = false;
353*5113495bSYour Name 
354*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
355*5113495bSYour Name }
356*5113495bSYour Name 
357*5113495bSYour Name #ifdef MOBILE_DFS_SUPPORT
358*5113495bSYour Name /**
359*5113495bSYour Name  * target_if_dfs_set_phyerr_filter_offload() - config phyerr filter offload.
360*5113495bSYour Name  * @pdev: Pointer to DFS pdev object.
361*5113495bSYour Name  * @dfs_phyerr_filter_offload: Phyerr filter offload value.
362*5113495bSYour Name  *
363*5113495bSYour Name  * Return: QDF_STATUS
364*5113495bSYour Name  */
target_if_dfs_set_phyerr_filter_offload(struct wlan_objmgr_pdev * pdev,bool dfs_phyerr_filter_offload)365*5113495bSYour Name static QDF_STATUS target_if_dfs_set_phyerr_filter_offload(
366*5113495bSYour Name 					struct wlan_objmgr_pdev *pdev,
367*5113495bSYour Name 					bool dfs_phyerr_filter_offload)
368*5113495bSYour Name {
369*5113495bSYour Name 	QDF_STATUS status;
370*5113495bSYour Name 	wmi_unified_t wmi_handle;
371*5113495bSYour Name 
372*5113495bSYour Name 	if (!pdev) {
373*5113495bSYour Name 		target_if_err("null pdev");
374*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
375*5113495bSYour Name 	}
376*5113495bSYour Name 
377*5113495bSYour Name 	wmi_handle = GET_WMI_HDL_FROM_PDEV(pdev);
378*5113495bSYour Name 	if (!wmi_handle) {
379*5113495bSYour Name 		target_if_err("null wmi_handle");
380*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
381*5113495bSYour Name 	}
382*5113495bSYour Name 
383*5113495bSYour Name 	status = wmi_unified_dfs_phyerr_filter_offload_en_cmd(wmi_handle,
384*5113495bSYour Name 					dfs_phyerr_filter_offload);
385*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(status))
386*5113495bSYour Name 		target_if_err("phyerr filter offload %d set fail: %d",
387*5113495bSYour Name 			      dfs_phyerr_filter_offload, status);
388*5113495bSYour Name 
389*5113495bSYour Name 	return status;
390*5113495bSYour Name }
391*5113495bSYour Name #else
target_if_dfs_set_phyerr_filter_offload(struct wlan_objmgr_pdev * pdev,bool dfs_phyerr_filter_offload)392*5113495bSYour Name static QDF_STATUS target_if_dfs_set_phyerr_filter_offload(
393*5113495bSYour Name 					struct wlan_objmgr_pdev *pdev,
394*5113495bSYour Name 					bool dfs_phyerr_filter_offload)
395*5113495bSYour Name {
396*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
397*5113495bSYour Name }
398*5113495bSYour Name #endif
399*5113495bSYour Name 
target_send_dfs_offload_enable_cmd(struct wlan_objmgr_pdev * pdev,bool enable)400*5113495bSYour Name static QDF_STATUS target_send_dfs_offload_enable_cmd(
401*5113495bSYour Name 		struct wlan_objmgr_pdev *pdev, bool enable)
402*5113495bSYour Name {
403*5113495bSYour Name 	QDF_STATUS status = QDF_STATUS_SUCCESS;
404*5113495bSYour Name 	uint8_t pdev_id;
405*5113495bSYour Name 	void *wmi_hdl;
406*5113495bSYour Name 
407*5113495bSYour Name 	if (!pdev) {
408*5113495bSYour Name 		target_if_err("null pdev");
409*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
410*5113495bSYour Name 	}
411*5113495bSYour Name 
412*5113495bSYour Name 	wmi_hdl = GET_WMI_HDL_FROM_PDEV(pdev);
413*5113495bSYour Name 	if (!wmi_hdl) {
414*5113495bSYour Name 		target_if_err("null wmi_hdl");
415*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
416*5113495bSYour Name 	}
417*5113495bSYour Name 
418*5113495bSYour Name 	pdev_id = wlan_objmgr_pdev_get_pdev_id(pdev);
419*5113495bSYour Name 
420*5113495bSYour Name 	if (enable)
421*5113495bSYour Name 		status = wmi_unified_dfs_phyerr_offload_en_cmd(wmi_hdl,
422*5113495bSYour Name 							       pdev_id);
423*5113495bSYour Name 	else
424*5113495bSYour Name 		status = wmi_unified_dfs_phyerr_offload_dis_cmd(wmi_hdl,
425*5113495bSYour Name 								pdev_id);
426*5113495bSYour Name 
427*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(status))
428*5113495bSYour Name 		target_if_err("dfs: dfs offload cmd failed, enable:%d, pdev:%d",
429*5113495bSYour Name 			      enable, pdev_id);
430*5113495bSYour Name 	else
431*5113495bSYour Name 		target_if_debug("dfs: sent dfs offload cmd, enable:%d, pdev:%d",
432*5113495bSYour Name 				enable, pdev_id);
433*5113495bSYour Name 
434*5113495bSYour Name 	return status;
435*5113495bSYour Name }
436*5113495bSYour Name 
437*5113495bSYour Name #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(HOST_DFS_SPOOF_TEST)
target_if_register_dfs_tx_ops_send_avg(struct wlan_lmac_if_dfs_tx_ops * dfs_tx_ops)438*5113495bSYour Name static void target_if_register_dfs_tx_ops_send_avg(
439*5113495bSYour Name 		struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops)
440*5113495bSYour Name {
441*5113495bSYour Name 	dfs_tx_ops->dfs_send_avg_radar_params_to_fw =
442*5113495bSYour Name 		&target_if_dfs_send_avg_params_to_fw;
443*5113495bSYour Name }
444*5113495bSYour Name #else
target_if_register_dfs_tx_ops_send_avg(struct wlan_lmac_if_dfs_tx_ops * dfs_tx_ops)445*5113495bSYour Name static inline void target_if_register_dfs_tx_ops_send_avg(
446*5113495bSYour Name 		struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops)
447*5113495bSYour Name {
448*5113495bSYour Name }
449*5113495bSYour Name #endif
450*5113495bSYour Name 
target_if_register_dfs_tx_ops(struct wlan_lmac_if_tx_ops * tx_ops)451*5113495bSYour Name QDF_STATUS target_if_register_dfs_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
452*5113495bSYour Name {
453*5113495bSYour Name 	struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops;
454*5113495bSYour Name 
455*5113495bSYour Name 	if (!tx_ops) {
456*5113495bSYour Name 		target_if_err("invalid tx_ops");
457*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
458*5113495bSYour Name 	}
459*5113495bSYour Name 
460*5113495bSYour Name 	dfs_tx_ops = &tx_ops->dfs_tx_ops;
461*5113495bSYour Name 	dfs_tx_ops->dfs_reg_ev_handler = &target_if_dfs_register_event_handler;
462*5113495bSYour Name 
463*5113495bSYour Name 	dfs_tx_ops->dfs_process_emulate_bang_radar_cmd =
464*5113495bSYour Name 				&target_process_bang_radar_cmd;
465*5113495bSYour Name 	dfs_tx_ops->dfs_agile_ch_cfg_cmd =
466*5113495bSYour Name 				&target_send_agile_ch_cfg_cmd;
467*5113495bSYour Name 	dfs_tx_ops->dfs_ocac_abort_cmd =
468*5113495bSYour Name 				&target_send_ocac_abort_cmd;
469*5113495bSYour Name 	dfs_tx_ops->dfs_is_pdev_5ghz = &target_if_dfs_is_pdev_5ghz;
470*5113495bSYour Name 	dfs_tx_ops->dfs_send_offload_enable_cmd =
471*5113495bSYour Name 		&target_send_dfs_offload_enable_cmd;
472*5113495bSYour Name 
473*5113495bSYour Name 	dfs_tx_ops->dfs_set_phyerr_filter_offload =
474*5113495bSYour Name 				&target_if_dfs_set_phyerr_filter_offload;
475*5113495bSYour Name 
476*5113495bSYour Name 	dfs_tx_ops->dfs_get_caps = &target_if_dfs_get_caps;
477*5113495bSYour Name 
478*5113495bSYour Name 	target_if_register_dfs_tx_ops_send_avg(dfs_tx_ops);
479*5113495bSYour Name 
480*5113495bSYour Name 	dfs_tx_ops->dfs_is_tgt_offload = &target_if_dfs_offload;
481*5113495bSYour Name 	dfs_tx_ops->dfs_is_tgt_bangradar_320_supp =
482*5113495bSYour Name 				&target_if_dfs_bangradar_320_supp;
483*5113495bSYour Name 	dfs_tx_ops->dfs_is_tgt_radar_found_chan_freq_eq_center_freq =
484*5113495bSYour Name 		&target_if_dfs_is_radar_found_chan_freq_eq_center_freq;
485*5113495bSYour Name 
486*5113495bSYour Name 	dfs_tx_ops->dfs_send_usenol_pdev_param =
487*5113495bSYour Name 		&target_send_usenol_pdev_param;
488*5113495bSYour Name 	dfs_tx_ops->dfs_send_subchan_marking_pdev_param =
489*5113495bSYour Name 		&target_send_subchan_marking_pdev_param;
490*5113495bSYour Name 	dfs_tx_ops->dfs_get_target_type = &target_if_dfs_get_target_type;
491*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
492*5113495bSYour Name }
493