xref: /wlan-driver/qca-wifi-host-cmn/target_if/dfs/src/target_if_dfs_partial_offload.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1*5113495bSYour Name /*
2*5113495bSYour Name  * Copyright (c) 2017-2018 The Linux Foundation. All rights reserved.
3*5113495bSYour Name  * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
4*5113495bSYour Name  *
5*5113495bSYour Name  *
6*5113495bSYour Name  * Permission to use, copy, modify, and/or distribute this software for
7*5113495bSYour Name  * any purpose with or without fee is hereby granted, provided that the
8*5113495bSYour Name  * above copyright notice and this permission notice appear in all
9*5113495bSYour Name  * copies.
10*5113495bSYour Name  *
11*5113495bSYour Name  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
12*5113495bSYour Name  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
13*5113495bSYour Name  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
14*5113495bSYour Name  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
15*5113495bSYour Name  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
16*5113495bSYour Name  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
17*5113495bSYour Name  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18*5113495bSYour Name  * PERFORMANCE OF THIS SOFTWARE.
19*5113495bSYour Name  */
20*5113495bSYour Name 
21*5113495bSYour Name /**
22*5113495bSYour Name  * DOC: target_if_dfs_partial_offload.c
23*5113495bSYour Name  * This file contains dfs target interface for partial offload
24*5113495bSYour Name  */
25*5113495bSYour Name 
26*5113495bSYour Name #include <target_if.h>
27*5113495bSYour Name #include "target_type.h"
28*5113495bSYour Name #include "target_if_dfs_partial_offload.h"
29*5113495bSYour Name #include "target_if_dfs.h"
30*5113495bSYour Name 
target_if_dfs_reg_phyerr_events(struct wlan_objmgr_psoc * psoc)31*5113495bSYour Name QDF_STATUS target_if_dfs_reg_phyerr_events(struct wlan_objmgr_psoc *psoc)
32*5113495bSYour Name {
33*5113495bSYour Name 	/* TODO: dfs non-offload case */
34*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
35*5113495bSYour Name }
36*5113495bSYour Name 
target_if_dfs_get_caps(struct wlan_objmgr_pdev * pdev,struct wlan_dfs_caps * dfs_caps)37*5113495bSYour Name QDF_STATUS target_if_dfs_get_caps(struct wlan_objmgr_pdev *pdev,
38*5113495bSYour Name 		struct wlan_dfs_caps *dfs_caps)
39*5113495bSYour Name {
40*5113495bSYour Name 	struct wlan_objmgr_psoc *psoc = NULL;
41*5113495bSYour Name 	struct target_psoc_info *tgt_psoc_info;
42*5113495bSYour Name 
43*5113495bSYour Name 	if (!dfs_caps) {
44*5113495bSYour Name 		target_if_err("null dfs_caps");
45*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
46*5113495bSYour Name 	}
47*5113495bSYour Name 
48*5113495bSYour Name 	dfs_caps->wlan_dfs_combined_rssi_ok = 0;
49*5113495bSYour Name 	dfs_caps->wlan_dfs_ext_chan_ok = 0;
50*5113495bSYour Name 	dfs_caps->wlan_dfs_use_enhancement = 0;
51*5113495bSYour Name 	dfs_caps->wlan_strong_signal_diversiry = 0;
52*5113495bSYour Name 	dfs_caps->wlan_fastdiv_val = 0;
53*5113495bSYour Name 	dfs_caps->wlan_chip_is_bb_tlv = 1;
54*5113495bSYour Name 	dfs_caps->wlan_chip_is_over_sampled = 0;
55*5113495bSYour Name 	dfs_caps->wlan_chip_is_ht160 = 0;
56*5113495bSYour Name 	dfs_caps->wlan_chip_is_false_detect = 0;
57*5113495bSYour Name 
58*5113495bSYour Name 	psoc = wlan_pdev_get_psoc(pdev);
59*5113495bSYour Name 	if (!psoc) {
60*5113495bSYour Name 		target_if_err("null psoc");
61*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
62*5113495bSYour Name 	}
63*5113495bSYour Name 
64*5113495bSYour Name 	tgt_psoc_info = wlan_psoc_get_tgt_if_handle(psoc);
65*5113495bSYour Name 	if (!tgt_psoc_info) {
66*5113495bSYour Name 		target_if_err("null tgt_psoc_info");
67*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
68*5113495bSYour Name 	}
69*5113495bSYour Name 
70*5113495bSYour Name 	switch (target_psoc_get_target_type(tgt_psoc_info)) {
71*5113495bSYour Name 	case TARGET_TYPE_AR900B:
72*5113495bSYour Name 		break;
73*5113495bSYour Name 
74*5113495bSYour Name 	case TARGET_TYPE_AR9888:
75*5113495bSYour Name 		dfs_caps->wlan_chip_is_over_sampled = 1;
76*5113495bSYour Name 		break;
77*5113495bSYour Name 
78*5113495bSYour Name 	case TARGET_TYPE_QCA9984:
79*5113495bSYour Name 	case TARGET_TYPE_QCA9888:
80*5113495bSYour Name 		dfs_caps->wlan_chip_is_ht160 = 1;
81*5113495bSYour Name 		break;
82*5113495bSYour Name 	default:
83*5113495bSYour Name 		break;
84*5113495bSYour Name 	}
85*5113495bSYour Name 
86*5113495bSYour Name 	return QDF_STATUS_SUCCESS;
87*5113495bSYour Name }
88*5113495bSYour Name 
89*5113495bSYour Name #if defined(HOST_DFS_SPOOF_TEST)
target_if_dfs_send_avg_params_to_fw(struct wlan_objmgr_pdev * pdev,struct dfs_radar_found_params * params)90*5113495bSYour Name QDF_STATUS target_if_dfs_send_avg_params_to_fw(
91*5113495bSYour Name 		struct wlan_objmgr_pdev *pdev,
92*5113495bSYour Name 		struct dfs_radar_found_params *params)
93*5113495bSYour Name {
94*5113495bSYour Name 	QDF_STATUS status;
95*5113495bSYour Name 	wmi_unified_t wmi_handle;
96*5113495bSYour Name 
97*5113495bSYour Name 	if (!pdev) {
98*5113495bSYour Name 		target_if_err("null pdev");
99*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
100*5113495bSYour Name 	}
101*5113495bSYour Name 
102*5113495bSYour Name 	wmi_handle = get_wmi_unified_hdl_from_pdev(pdev);
103*5113495bSYour Name 	if (!wmi_handle) {
104*5113495bSYour Name 		target_if_err("null wmi_handle");
105*5113495bSYour Name 		return QDF_STATUS_E_FAILURE;
106*5113495bSYour Name 	}
107*5113495bSYour Name 
108*5113495bSYour Name 	status = wmi_unified_dfs_send_avg_params_cmd(wmi_handle,
109*5113495bSYour Name 						     params);
110*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(status))
111*5113495bSYour Name 		target_if_err("dfs radar found average parameters send failed: %d",
112*5113495bSYour Name 			      status);
113*5113495bSYour Name 
114*5113495bSYour Name 	return status;
115*5113495bSYour Name }
116*5113495bSYour Name 
target_if_dfs_status_check_event_handler(ol_scn_t scn,uint8_t * data,uint32_t datalen)117*5113495bSYour Name int target_if_dfs_status_check_event_handler(ol_scn_t scn,
118*5113495bSYour Name 					     uint8_t *data,
119*5113495bSYour Name 					     uint32_t datalen)
120*5113495bSYour Name {
121*5113495bSYour Name 	struct wlan_objmgr_psoc *psoc;
122*5113495bSYour Name 	struct wlan_objmgr_pdev *pdev;
123*5113495bSYour Name 	struct wlan_lmac_if_dfs_rx_ops *dfs_rx_ops;
124*5113495bSYour Name 	u_int32_t dfs_status_check;
125*5113495bSYour Name 	wmi_unified_t wmi_hdl;
126*5113495bSYour Name 
127*5113495bSYour Name 	if (!scn || !data) {
128*5113495bSYour Name 		target_if_err("scn: %pK, data: %pK", scn, data);
129*5113495bSYour Name 		return -EINVAL;
130*5113495bSYour Name 	}
131*5113495bSYour Name 
132*5113495bSYour Name 	psoc = target_if_get_psoc_from_scn_hdl(scn);
133*5113495bSYour Name 	if (!psoc) {
134*5113495bSYour Name 		target_if_err("null psoc");
135*5113495bSYour Name 		return -EINVAL;
136*5113495bSYour Name 	}
137*5113495bSYour Name 
138*5113495bSYour Name 	/* Since Partial Offload chipsets have only one pdev per psoc, the first
139*5113495bSYour Name 	 * pdev from the pdev list is used.
140*5113495bSYour Name 	 */
141*5113495bSYour Name 	pdev = wlan_objmgr_get_pdev_by_id(psoc, 0, WLAN_DFS_ID);
142*5113495bSYour Name 	if (!pdev) {
143*5113495bSYour Name 		target_if_err("null pdev");
144*5113495bSYour Name 		return -EINVAL;
145*5113495bSYour Name 	}
146*5113495bSYour Name 
147*5113495bSYour Name 	dfs_rx_ops = target_if_dfs_get_rx_ops(psoc);
148*5113495bSYour Name 	if (!dfs_rx_ops) {
149*5113495bSYour Name 		target_if_err("null dfs_rx_ops");
150*5113495bSYour Name 		wlan_objmgr_pdev_release_ref(pdev, WLAN_DFS_ID);
151*5113495bSYour Name 		return -EINVAL;
152*5113495bSYour Name 	}
153*5113495bSYour Name 
154*5113495bSYour Name 	if (!dfs_rx_ops->dfs_action_on_status) {
155*5113495bSYour Name 		target_if_err("dfs_rx_ops->dfs_action_on_status is NULL");
156*5113495bSYour Name 		wlan_objmgr_pdev_release_ref(pdev, WLAN_DFS_ID);
157*5113495bSYour Name 		return -EINVAL;
158*5113495bSYour Name 	}
159*5113495bSYour Name 
160*5113495bSYour Name 	wmi_hdl = get_wmi_unified_hdl_from_pdev(pdev);
161*5113495bSYour Name 	if (!wmi_hdl) {
162*5113495bSYour Name 		target_if_err("wmi_hdl is NULL");
163*5113495bSYour Name 		wlan_objmgr_pdev_release_ref(pdev, WLAN_DFS_ID);
164*5113495bSYour Name 		return -EINVAL;
165*5113495bSYour Name 	}
166*5113495bSYour Name 
167*5113495bSYour Name 	if (wmi_extract_dfs_status_from_fw(wmi_hdl, data, &dfs_status_check) !=
168*5113495bSYour Name 			QDF_STATUS_SUCCESS) {
169*5113495bSYour Name 		target_if_err("failed to extract status response from FW");
170*5113495bSYour Name 		wlan_objmgr_pdev_release_ref(pdev, WLAN_DFS_ID);
171*5113495bSYour Name 		return -EINVAL;
172*5113495bSYour Name 	}
173*5113495bSYour Name 
174*5113495bSYour Name 	if (dfs_rx_ops->dfs_action_on_status(pdev, &dfs_status_check) !=
175*5113495bSYour Name 		QDF_STATUS_SUCCESS) {
176*5113495bSYour Name 		target_if_err("dfs action on host dfs status from FW failed");
177*5113495bSYour Name 		wlan_objmgr_pdev_release_ref(pdev, WLAN_DFS_ID);
178*5113495bSYour Name 		return -EINVAL;
179*5113495bSYour Name 	}
180*5113495bSYour Name 
181*5113495bSYour Name 	wlan_objmgr_pdev_release_ref(pdev, WLAN_DFS_ID);
182*5113495bSYour Name 
183*5113495bSYour Name 	return 0;
184*5113495bSYour Name }
185*5113495bSYour Name #endif
186