xref: /wlan-dirver/qca-wifi-host-cmn/dp/inc/cdp_txrx_cfg.h (revision 503663c6daafffe652fa360bde17243568cd6d2a)
1 /*
2  * Copyright (c) 2016-2019 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /**
20  * @file cdp_txrx_cfg.h
21  * @brief Define the host data path configuration API functions
22  */
23 #ifndef _CDP_TXRX_CFG_H_
24 #define _CDP_TXRX_CFG_H_
25 #include "cdp_txrx_handle.h"
26 /**
27  * cdp_cfg_set_rx_fwd_disabled() - enable/disable rx forwarding
28  * @soc - data path soc handle
29  * @pdev - data path device instance
30  * @disable_rx_fwd - enable or disable rx forwarding
31  *
32  * enable/disable rx forwarding
33  *
34  * return NONE
35  */
36 static inline void
37 cdp_cfg_set_rx_fwd_disabled(ol_txrx_soc_handle soc, struct cdp_cfg *cfg_pdev,
38 		uint8_t disable_rx_fwd)
39 {
40 	if (!soc || !soc->ops) {
41 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
42 			"%s invalid instance", __func__);
43 		QDF_BUG(0);
44 		return;
45 	}
46 
47 	if (!soc->ops->cfg_ops ||
48 	    !soc->ops->cfg_ops->set_cfg_rx_fwd_disabled)
49 		return;
50 
51 	soc->ops->cfg_ops->set_cfg_rx_fwd_disabled(cfg_pdev,
52 			disable_rx_fwd);
53 }
54 
55 /**
56  * cdp_cfg_set_packet_log_enabled() - enable/disable packet log
57  * @soc - data path soc handle
58  * @pdev - data path device instance
59  * @val - enable or disable packet log
60  *
61  * packet log enable or disable
62  *
63  * return NONE
64  */
65 static inline void
66 cdp_cfg_set_packet_log_enabled(ol_txrx_soc_handle soc,
67 		struct cdp_cfg *cfg_pdev, uint8_t val)
68 {
69 	if (!soc || !soc->ops) {
70 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
71 			"%s invalid instance", __func__);
72 		QDF_BUG(0);
73 		return;
74 	}
75 
76 	if (!soc->ops->cfg_ops ||
77 	    !soc->ops->cfg_ops->set_cfg_packet_log_enabled)
78 		return;
79 
80 	soc->ops->cfg_ops->set_cfg_packet_log_enabled(cfg_pdev,
81 				val);
82 }
83 
84 /**
85  * cdp_cfg_attach() - attach config module
86  * @soc - data path soc handle
87  * @osdev - os instance
88  * @cfg_param - configuration parameter should be propagated
89  *
90  * Allocate configuration module instance, and propagate configuration values
91  *
92  * return soc configuration module instance
93  */
94 static inline struct cdp_cfg
95 *cdp_cfg_attach(ol_txrx_soc_handle soc,
96 		qdf_device_t osdev, void *cfg_param)
97 {
98 	if (!soc || !soc->ops) {
99 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
100 			"%s invalid instance", __func__);
101 		QDF_BUG(0);
102 		return NULL;
103 	}
104 
105 	if (!soc->ops->cfg_ops ||
106 	    !soc->ops->cfg_ops->cfg_attach)
107 		return NULL;
108 
109 	return soc->ops->cfg_ops->cfg_attach(osdev, cfg_param);
110 }
111 
112 /**
113  * cdp_cfg_vdev_rx_set_intrabss_fwd() - enable/disable intra bass forwarding
114  * @soc - data path soc handle
115  * @vdev_id - virtual interface id
116  * @val - enable or disable intra bss forwarding
117  *
118  * ap isolate, do not forward intra bss traffic
119  *
120  * return NONE
121  */
122 static inline void
123 cdp_cfg_vdev_rx_set_intrabss_fwd(ol_txrx_soc_handle soc,
124 				 uint8_t vdev_id, bool val)
125 {
126 	if (!soc || !soc->ops) {
127 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
128 			"%s invalid instance", __func__);
129 		QDF_BUG(0);
130 		return;
131 	}
132 
133 	if (!soc->ops->cfg_ops ||
134 	    !soc->ops->cfg_ops->vdev_rx_set_intrabss_fwd)
135 		return;
136 
137 	soc->ops->cfg_ops->vdev_rx_set_intrabss_fwd(soc, vdev_id, val);
138 }
139 
140 /**
141  * cdp_cfg_is_rx_fwd_disabled() - get vdev rx forward
142  * @soc - data path soc handle
143  * @vdev - virtual interface instance
144  *
145  * Return rx forward feature enable status
146  *
147  * return 1 enabled
148  *        0 disabled
149  */
150 static inline uint8_t
151 cdp_cfg_is_rx_fwd_disabled(ol_txrx_soc_handle soc, struct cdp_vdev *vdev)
152 {
153 	if (!soc || !soc->ops) {
154 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
155 			"%s invalid instance", __func__);
156 		QDF_BUG(0);
157 		return 0;
158 	}
159 
160 	if (!soc->ops->cfg_ops ||
161 	    !soc->ops->cfg_ops->is_rx_fwd_disabled)
162 		return 0;
163 
164 	return soc->ops->cfg_ops->is_rx_fwd_disabled(vdev);
165 
166 }
167 
168 /**
169  * cdp_cfg_tx_set_is_mgmt_over_wmi_enabled() - mgmt tx over wmi enable/disable
170  * @soc - data path soc handle
171  * @value - feature enable or disable
172  *
173  * Enable or disable management packet TX over WMI feature
174  *
175  * return None
176  */
177 static inline void
178 cdp_cfg_tx_set_is_mgmt_over_wmi_enabled(ol_txrx_soc_handle soc,
179 		uint8_t value)
180 {
181 	if (!soc || !soc->ops) {
182 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
183 			"%s invalid instance", __func__);
184 		QDF_BUG(0);
185 		return;
186 	}
187 
188 	if (!soc->ops->cfg_ops ||
189 	    !soc->ops->cfg_ops->tx_set_is_mgmt_over_wmi_enabled)
190 		return;
191 
192 	soc->ops->cfg_ops->tx_set_is_mgmt_over_wmi_enabled(value);
193 }
194 
195 /**
196  * cdp_cfg_is_high_latency() - query data path is in high or low latency
197  * @soc - data path soc handle
198  * @pdev - data path device instance
199  *
200  * query data path is in high or low latency
201  *
202  * return 1 high latency data path, usb or sdio
203  *        0 low latency data path
204  */
205 static inline int
206 cdp_cfg_is_high_latency(ol_txrx_soc_handle soc, struct cdp_cfg *cfg_pdev)
207 {
208 	if (!soc || !soc->ops) {
209 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
210 			"%s invalid instance", __func__);
211 		QDF_BUG(0);
212 		return 0;
213 	}
214 
215 	if (!soc->ops->cfg_ops ||
216 	    !soc->ops->cfg_ops->is_high_latency)
217 		return 0;
218 
219 	return soc->ops->cfg_ops->is_high_latency(cfg_pdev);
220 }
221 
222 /**
223  * cdp_cfg_set_flow_control_parameters() - set flow control params
224  * @soc - data path soc handle
225  * @cfg - dp config module instance
226  * @param - parameters should set
227  *
228  * set flow control params
229  *
230  * return None
231  */
232 static inline void
233 cdp_cfg_set_flow_control_parameters(ol_txrx_soc_handle soc,
234 		struct cdp_cfg *cfg_pdev, void *param)
235 {
236 	if (!soc || !soc->ops) {
237 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
238 			"%s invalid instance", __func__);
239 		QDF_BUG(0);
240 		return;
241 	}
242 
243 	if (!soc->ops->cfg_ops ||
244 	    !soc->ops->cfg_ops->set_flow_control_parameters)
245 		return;
246 
247 	soc->ops->cfg_ops->set_flow_control_parameters(cfg_pdev,
248 						       param);
249 }
250 
251 /**
252  * cdp_cfg_set_flow_steering - Set Rx flow steering config based on CFG ini
253  *			config.
254  *
255  * @pdev - handle to the physical device
256  * @val - 0 - disable, 1 - enable
257  *
258  * Return: None
259  */
260 static inline void cdp_cfg_set_flow_steering(ol_txrx_soc_handle soc,
261 		struct cdp_cfg *cfg_pdev, uint8_t val)
262 {
263 	if (!soc || !soc->ops) {
264 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
265 			"%s invalid instance", __func__);
266 		QDF_BUG(0);
267 		return;
268 	}
269 
270 	if (!soc->ops->cfg_ops ||
271 	    !soc->ops->cfg_ops->set_flow_steering)
272 		return;
273 
274 	soc->ops->cfg_ops->set_flow_steering(cfg_pdev, val);
275 }
276 
277 static inline void cdp_cfg_get_max_peer_id(ol_txrx_soc_handle soc,
278 		struct cdp_cfg *cfg_pdev)
279 {
280 }
281 
282 /**
283  * cdp_cfg_set_ptp_rx_opt_enabled() - enable/disable ptp rx timestamping
284  * @soc - data path soc handle
285  * @pdev - data path device instance
286  * @val - enable or disable packet log
287  *
288  * ptp rx timestamping enable or disable
289  *
290  * return NONE
291  */
292 static inline void
293 cdp_cfg_set_ptp_rx_opt_enabled(ol_txrx_soc_handle soc,
294 			       struct cdp_cfg *cfg_pdev, uint8_t val)
295 {
296 	if (!soc || !soc->ops) {
297 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
298 			  "%s invalid instance", __func__);
299 		QDF_BUG(0);
300 		return;
301 	}
302 
303 	if (!soc->ops->cfg_ops ||
304 	    !soc->ops->cfg_ops->set_ptp_rx_opt_enabled)
305 		return;
306 
307 	soc->ops->cfg_ops->set_ptp_rx_opt_enabled(cfg_pdev, val);
308 }
309 
310 /**
311  * cdp_cfg_set_new_htt_msg_format() - set htt h2t msg feature
312  * @soc - datapath soc handle
313  * @val - enable or disable new htt h2t msg feature
314  *
315  * Enable whether htt h2t message length includes htc header length
316  *
317  * return NONE
318  */
319 static inline void
320 cdp_cfg_set_new_htt_msg_format(ol_txrx_soc_handle soc,
321 			       uint8_t val)
322 {
323 	if (!soc || !soc->ops) {
324 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
325 			  "%s invalid instance", __func__);
326 		return;
327 	}
328 
329 	if (!soc->ops->cfg_ops ||
330 	    !soc->ops->cfg_ops->set_new_htt_msg_format)
331 		return;
332 
333 	soc->ops->cfg_ops->set_new_htt_msg_format(val);
334 }
335 
336 /**
337  * cdp_cfg_set_peer_unmap_conf_support() - set peer unmap conf feature
338  * @soc - datapath soc handle
339  * @val - enable or disable peer unmap conf feature
340  *
341  * Set if peer unmap confirmation feature is supported by both FW and in INI
342  *
343  * return NONE
344  */
345 static inline void
346 cdp_cfg_set_peer_unmap_conf_support(ol_txrx_soc_handle soc, bool val)
347 {
348 	if (!soc || !soc->ops) {
349 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
350 			  "%s invalid instance", __func__);
351 		QDF_BUG(0);
352 		return;
353 	}
354 
355 	if (!soc->ops->cfg_ops ||
356 	    !soc->ops->cfg_ops->set_peer_unmap_conf_support)
357 		return;
358 
359 	soc->ops->cfg_ops->set_peer_unmap_conf_support(val);
360 }
361 
362 /**
363  * cdp_cfg_get_peer_unmap_conf_support() - check peer unmap conf feature
364  * @soc - datapath soc handle
365  *
366  * Check if peer unmap confirmation feature is enabled
367  *
368  * return true is peer unmap confirmation feature is enabled else false
369  */
370 static inline bool
371 cdp_cfg_get_peer_unmap_conf_support(ol_txrx_soc_handle soc)
372 {
373 	if (!soc || !soc->ops) {
374 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_DEBUG,
375 			  "%s invalid instance", __func__);
376 		QDF_BUG(0);
377 		return false;
378 	}
379 
380 	if (!soc->ops->cfg_ops ||
381 	    !soc->ops->cfg_ops->get_peer_unmap_conf_support)
382 		return false;
383 
384 	return soc->ops->cfg_ops->get_peer_unmap_conf_support();
385 }
386 
387 static inline void
388 cdp_cfg_set_tx_compl_tsf64(ol_txrx_soc_handle soc,
389 			   uint8_t val)
390 {
391 	if (!soc || !soc->ops) {
392 		dp_debug("invalid instance");
393 		return;
394 	}
395 
396 	if (!soc->ops->cfg_ops ||
397 	    !soc->ops->cfg_ops->set_tx_compl_tsf64)
398 		return;
399 
400 	soc->ops->cfg_ops->set_tx_compl_tsf64(val);
401 }
402 
403 static inline bool
404 cdp_cfg_get_tx_compl_tsf64(ol_txrx_soc_handle soc)
405 {
406 	if (!soc || !soc->ops) {
407 		dp_debug("invalid instance");
408 		return false;
409 	}
410 
411 	if (!soc->ops->cfg_ops ||
412 	    !soc->ops->cfg_ops->get_tx_compl_tsf64)
413 		return false;
414 
415 	return soc->ops->cfg_ops->get_tx_compl_tsf64();
416 }
417 
418 #endif /* _CDP_TXRX_CFG_H_ */
419