xref: /wlan-driver/qca-wifi-host-cmn/umac/dfs/dispatcher/src/wlan_dfs_lmac_api.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1*5113495bSYour Name /*
2*5113495bSYour Name  * Copyright (c) 2016-2020 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: Functions to call lmac/offload functions from DFS component.
22*5113495bSYour Name  */
23*5113495bSYour Name 
24*5113495bSYour Name #include "wlan_dfs_lmac_api.h"
25*5113495bSYour Name #include "../../core/src/dfs_internal.h"
26*5113495bSYour Name #include <wlan_reg_services_api.h>
27*5113495bSYour Name #include <wlan_lmac_if_def.h>
28*5113495bSYour Name 
lmac_get_caps(struct wlan_objmgr_pdev * pdev,struct wlan_dfs_caps * dfs_caps)29*5113495bSYour Name void lmac_get_caps(struct wlan_objmgr_pdev *pdev,
30*5113495bSYour Name 		struct wlan_dfs_caps *dfs_caps)
31*5113495bSYour Name {
32*5113495bSYour Name 	struct wlan_objmgr_psoc *psoc;
33*5113495bSYour Name 	struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops;
34*5113495bSYour Name 	struct wlan_lmac_if_tx_ops *tx_ops;
35*5113495bSYour Name 
36*5113495bSYour Name 	psoc = wlan_pdev_get_psoc(pdev);
37*5113495bSYour Name 	tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
38*5113495bSYour Name 	if (!tx_ops) {
39*5113495bSYour Name 		dfs_err(NULL, WLAN_DEBUG_DFS_ALWAYS,  "tx_ops is null");
40*5113495bSYour Name 		return;
41*5113495bSYour Name 	}
42*5113495bSYour Name 
43*5113495bSYour Name 	dfs_tx_ops = &tx_ops->dfs_tx_ops;
44*5113495bSYour Name 
45*5113495bSYour Name 	if (dfs_tx_ops->dfs_get_caps)
46*5113495bSYour Name 		dfs_tx_ops->dfs_get_caps(pdev, dfs_caps);
47*5113495bSYour Name }
48*5113495bSYour Name 
lmac_get_tsf64(struct wlan_objmgr_pdev * pdev)49*5113495bSYour Name uint64_t lmac_get_tsf64(struct wlan_objmgr_pdev *pdev)
50*5113495bSYour Name {
51*5113495bSYour Name 	struct wlan_objmgr_psoc *psoc;
52*5113495bSYour Name 	struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops;
53*5113495bSYour Name 	uint64_t tsf64 = 0;
54*5113495bSYour Name 	struct wlan_lmac_if_tx_ops *tx_ops;
55*5113495bSYour Name 
56*5113495bSYour Name 	psoc = wlan_pdev_get_psoc(pdev);
57*5113495bSYour Name 	tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
58*5113495bSYour Name 	if (!tx_ops) {
59*5113495bSYour Name 		dfs_err(NULL, WLAN_DEBUG_DFS_ALWAYS,  "tx_ops is null");
60*5113495bSYour Name 		return tsf64;
61*5113495bSYour Name 	}
62*5113495bSYour Name 
63*5113495bSYour Name 	dfs_tx_ops = &tx_ops->dfs_tx_ops;
64*5113495bSYour Name 
65*5113495bSYour Name 	if (dfs_tx_ops->dfs_gettsf64)
66*5113495bSYour Name 		dfs_tx_ops->dfs_gettsf64(pdev, &tsf64);
67*5113495bSYour Name 
68*5113495bSYour Name 	return tsf64;
69*5113495bSYour Name }
70*5113495bSYour Name 
lmac_dfs_disable(struct wlan_objmgr_pdev * pdev,int no_cac)71*5113495bSYour Name void lmac_dfs_disable(struct wlan_objmgr_pdev *pdev, int no_cac)
72*5113495bSYour Name {
73*5113495bSYour Name 	struct wlan_objmgr_psoc *psoc;
74*5113495bSYour Name 	struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops;
75*5113495bSYour Name 	struct wlan_lmac_if_tx_ops *tx_ops;
76*5113495bSYour Name 
77*5113495bSYour Name 	psoc = wlan_pdev_get_psoc(pdev);
78*5113495bSYour Name 	tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
79*5113495bSYour Name 	if (!tx_ops) {
80*5113495bSYour Name 		dfs_err(NULL, WLAN_DEBUG_DFS_ALWAYS,  "tx_ops is null");
81*5113495bSYour Name 		return;
82*5113495bSYour Name 	}
83*5113495bSYour Name 
84*5113495bSYour Name 	dfs_tx_ops = &tx_ops->dfs_tx_ops;
85*5113495bSYour Name 
86*5113495bSYour Name 	if (dfs_tx_ops->dfs_disable)
87*5113495bSYour Name 		dfs_tx_ops->dfs_disable(pdev, no_cac);
88*5113495bSYour Name }
89*5113495bSYour Name 
lmac_dfs_enable(struct wlan_objmgr_pdev * pdev,int * is_fastclk,struct wlan_dfs_phyerr_param * param,int dfsdomain)90*5113495bSYour Name void lmac_dfs_enable(struct wlan_objmgr_pdev *pdev,
91*5113495bSYour Name 		int *is_fastclk,
92*5113495bSYour Name 		struct wlan_dfs_phyerr_param *param,
93*5113495bSYour Name 		int dfsdomain)
94*5113495bSYour Name {
95*5113495bSYour Name 	struct wlan_objmgr_psoc *psoc;
96*5113495bSYour Name 	struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops;
97*5113495bSYour Name 	struct wlan_lmac_if_tx_ops *tx_ops;
98*5113495bSYour Name 
99*5113495bSYour Name 	psoc = wlan_pdev_get_psoc(pdev);
100*5113495bSYour Name 	tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
101*5113495bSYour Name 	if (!tx_ops) {
102*5113495bSYour Name 		dfs_err(NULL, WLAN_DEBUG_DFS_ALWAYS,  "tx_ops is null");
103*5113495bSYour Name 		return;
104*5113495bSYour Name 	}
105*5113495bSYour Name 
106*5113495bSYour Name 	dfs_tx_ops = &tx_ops->dfs_tx_ops;
107*5113495bSYour Name 
108*5113495bSYour Name 	if (dfs_tx_ops->dfs_enable)
109*5113495bSYour Name 		dfs_tx_ops->dfs_enable(pdev,
110*5113495bSYour Name 				is_fastclk,
111*5113495bSYour Name 				param,
112*5113495bSYour Name 				dfsdomain);
113*5113495bSYour Name }
114*5113495bSYour Name 
lmac_dfs_get_thresholds(struct wlan_objmgr_pdev * pdev,struct wlan_dfs_phyerr_param * param)115*5113495bSYour Name void lmac_dfs_get_thresholds(struct wlan_objmgr_pdev *pdev,
116*5113495bSYour Name 		struct wlan_dfs_phyerr_param *param)
117*5113495bSYour Name {
118*5113495bSYour Name 	struct wlan_objmgr_psoc *psoc;
119*5113495bSYour Name 	struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops;
120*5113495bSYour Name 	struct wlan_lmac_if_tx_ops *tx_ops;
121*5113495bSYour Name 
122*5113495bSYour Name 	psoc = wlan_pdev_get_psoc(pdev);
123*5113495bSYour Name 	tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
124*5113495bSYour Name 	if (!tx_ops) {
125*5113495bSYour Name 		dfs_err(NULL, WLAN_DEBUG_DFS_ALWAYS,  "tx_ops is null");
126*5113495bSYour Name 		return;
127*5113495bSYour Name 	}
128*5113495bSYour Name 
129*5113495bSYour Name 	dfs_tx_ops = &tx_ops->dfs_tx_ops;
130*5113495bSYour Name 
131*5113495bSYour Name 	if (dfs_tx_ops->dfs_get_thresholds)
132*5113495bSYour Name 		dfs_tx_ops->dfs_get_thresholds(pdev, param);
133*5113495bSYour Name }
134*5113495bSYour Name 
lmac_get_ah_devid(struct wlan_objmgr_pdev * pdev)135*5113495bSYour Name uint16_t lmac_get_ah_devid(struct wlan_objmgr_pdev *pdev)
136*5113495bSYour Name {
137*5113495bSYour Name 	struct wlan_objmgr_psoc *psoc;
138*5113495bSYour Name 	struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops;
139*5113495bSYour Name 	uint16_t devid = 0;
140*5113495bSYour Name 	struct wlan_lmac_if_tx_ops *tx_ops;
141*5113495bSYour Name 
142*5113495bSYour Name 	psoc = wlan_pdev_get_psoc(pdev);
143*5113495bSYour Name 	tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
144*5113495bSYour Name 	if (!tx_ops) {
145*5113495bSYour Name 		dfs_err(NULL, WLAN_DEBUG_DFS_ALWAYS,  "tx_ops is null");
146*5113495bSYour Name 		return devid;
147*5113495bSYour Name 	}
148*5113495bSYour Name 
149*5113495bSYour Name 	dfs_tx_ops = &tx_ops->dfs_tx_ops;
150*5113495bSYour Name 
151*5113495bSYour Name 	if (dfs_tx_ops->dfs_get_ah_devid)
152*5113495bSYour Name 		dfs_tx_ops->dfs_get_ah_devid(pdev, &devid);
153*5113495bSYour Name 
154*5113495bSYour Name 	return devid;
155*5113495bSYour Name }
156*5113495bSYour Name 
lmac_get_ext_busy(struct wlan_objmgr_pdev * pdev)157*5113495bSYour Name uint32_t lmac_get_ext_busy(struct wlan_objmgr_pdev *pdev)
158*5113495bSYour Name {
159*5113495bSYour Name 	struct wlan_objmgr_psoc *psoc;
160*5113495bSYour Name 	struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops;
161*5113495bSYour Name 	uint32_t ext_chan_busy = 0;
162*5113495bSYour Name 	struct wlan_lmac_if_tx_ops *tx_ops;
163*5113495bSYour Name 
164*5113495bSYour Name 	psoc = wlan_pdev_get_psoc(pdev);
165*5113495bSYour Name 	tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
166*5113495bSYour Name 	if (!tx_ops) {
167*5113495bSYour Name 		dfs_err(NULL, WLAN_DEBUG_DFS_ALWAYS,  "tx_ops is null");
168*5113495bSYour Name 		return ext_chan_busy;
169*5113495bSYour Name 	}
170*5113495bSYour Name 
171*5113495bSYour Name 	dfs_tx_ops = &tx_ops->dfs_tx_ops;
172*5113495bSYour Name 
173*5113495bSYour Name 	if (dfs_tx_ops->dfs_get_ext_busy)
174*5113495bSYour Name 		dfs_tx_ops->dfs_get_ext_busy(pdev, &ext_chan_busy);
175*5113495bSYour Name 
176*5113495bSYour Name 	return ext_chan_busy;
177*5113495bSYour Name }
178*5113495bSYour Name 
lmac_set_use_cac_prssi(struct wlan_objmgr_pdev * pdev)179*5113495bSYour Name void lmac_set_use_cac_prssi(struct wlan_objmgr_pdev *pdev)
180*5113495bSYour Name {
181*5113495bSYour Name 	struct wlan_objmgr_psoc *psoc;
182*5113495bSYour Name 	struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops;
183*5113495bSYour Name 	struct wlan_lmac_if_tx_ops *tx_ops;
184*5113495bSYour Name 
185*5113495bSYour Name 	psoc = wlan_pdev_get_psoc(pdev);
186*5113495bSYour Name 	tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
187*5113495bSYour Name 	if (!tx_ops) {
188*5113495bSYour Name 		dfs_err(NULL, WLAN_DEBUG_DFS_ALWAYS,  "tx_ops is null");
189*5113495bSYour Name 		return;
190*5113495bSYour Name 	}
191*5113495bSYour Name 
192*5113495bSYour Name 	dfs_tx_ops = &tx_ops->dfs_tx_ops;
193*5113495bSYour Name 
194*5113495bSYour Name 	if (dfs_tx_ops->dfs_set_use_cac_prssi)
195*5113495bSYour Name 		dfs_tx_ops->dfs_set_use_cac_prssi(pdev);
196*5113495bSYour Name }
197*5113495bSYour Name 
lmac_get_target_type(struct wlan_objmgr_pdev * pdev)198*5113495bSYour Name uint32_t lmac_get_target_type(struct wlan_objmgr_pdev *pdev)
199*5113495bSYour Name {
200*5113495bSYour Name 	struct wlan_objmgr_psoc *psoc;
201*5113495bSYour Name 	struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops;
202*5113495bSYour Name 	uint32_t target_type = 0;
203*5113495bSYour Name 	struct wlan_lmac_if_tx_ops *tx_ops;
204*5113495bSYour Name 
205*5113495bSYour Name 	psoc = wlan_pdev_get_psoc(pdev);
206*5113495bSYour Name 	tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
207*5113495bSYour Name 	if (!tx_ops) {
208*5113495bSYour Name 		dfs_err(NULL, WLAN_DEBUG_DFS_ALWAYS,  "tx_ops is null");
209*5113495bSYour Name 		return target_type;
210*5113495bSYour Name 	}
211*5113495bSYour Name 
212*5113495bSYour Name 	dfs_tx_ops = &tx_ops->dfs_tx_ops;
213*5113495bSYour Name 
214*5113495bSYour Name 	if (dfs_tx_ops->dfs_get_target_type)
215*5113495bSYour Name 		dfs_tx_ops->dfs_get_target_type(pdev, &target_type);
216*5113495bSYour Name 
217*5113495bSYour Name 	return target_type;
218*5113495bSYour Name }
219*5113495bSYour Name 
lmac_get_phymode_info(struct wlan_objmgr_pdev * pdev,uint32_t chan_mode)220*5113495bSYour Name uint32_t lmac_get_phymode_info(struct wlan_objmgr_pdev *pdev,
221*5113495bSYour Name 		uint32_t chan_mode)
222*5113495bSYour Name {
223*5113495bSYour Name 	struct wlan_objmgr_psoc *psoc;
224*5113495bSYour Name 	struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops;
225*5113495bSYour Name 	uint32_t mode_info = 0;
226*5113495bSYour Name 	struct wlan_lmac_if_tx_ops *tx_ops;
227*5113495bSYour Name 
228*5113495bSYour Name 	psoc = wlan_pdev_get_psoc(pdev);
229*5113495bSYour Name 	tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
230*5113495bSYour Name 	if (!tx_ops) {
231*5113495bSYour Name 		dfs_err(NULL, WLAN_DEBUG_DFS_ALWAYS,  "tx_ops is null");
232*5113495bSYour Name 		return mode_info;
233*5113495bSYour Name 	}
234*5113495bSYour Name 
235*5113495bSYour Name 	dfs_tx_ops = &tx_ops->dfs_tx_ops;
236*5113495bSYour Name 
237*5113495bSYour Name 	/* since dfs never comes into 2G, hardcode is_2gvht_en flag to false */
238*5113495bSYour Name 	if (dfs_tx_ops->dfs_get_phymode_info)
239*5113495bSYour Name 		dfs_tx_ops->dfs_get_phymode_info(pdev, chan_mode, &mode_info,
240*5113495bSYour Name 						 false);
241*5113495bSYour Name 
242*5113495bSYour Name 	return mode_info;
243*5113495bSYour Name }
244*5113495bSYour Name 
245*5113495bSYour Name #if defined(WLAN_DFS_PARTIAL_OFFLOAD) && defined(HOST_DFS_SPOOF_TEST)
lmac_is_host_dfs_check_support_enabled(struct wlan_objmgr_pdev * pdev)246*5113495bSYour Name bool lmac_is_host_dfs_check_support_enabled(struct wlan_objmgr_pdev *pdev)
247*5113495bSYour Name {
248*5113495bSYour Name 	struct wlan_objmgr_psoc *psoc;
249*5113495bSYour Name 	struct wlan_lmac_if_dfs_tx_ops *dfs_tx_ops;
250*5113495bSYour Name 	bool enabled = false;
251*5113495bSYour Name 	struct wlan_lmac_if_tx_ops *tx_ops;
252*5113495bSYour Name 
253*5113495bSYour Name 	psoc = wlan_pdev_get_psoc(pdev);
254*5113495bSYour Name 	tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
255*5113495bSYour Name 	if (!tx_ops) {
256*5113495bSYour Name 		dfs_err(NULL, WLAN_DEBUG_DFS_ALWAYS,  "tx_ops is null");
257*5113495bSYour Name 		return enabled;
258*5113495bSYour Name 	}
259*5113495bSYour Name 
260*5113495bSYour Name 	dfs_tx_ops = &tx_ops->dfs_tx_ops;
261*5113495bSYour Name 
262*5113495bSYour Name 	if (dfs_tx_ops->dfs_host_dfs_check_support)
263*5113495bSYour Name 		dfs_tx_ops->dfs_host_dfs_check_support(pdev, &enabled);
264*5113495bSYour Name 
265*5113495bSYour Name 	return enabled;
266*5113495bSYour Name }
267*5113495bSYour Name #endif
268