xref: /wlan-dirver/qca-wifi-host-cmn/dp/inc/cdp_txrx_ipa.h (revision 97f44cd39e4ff816eaa1710279d28cf6b9e65ad9)
1 /*
2  * Copyright (c) 2016-2020 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_ipa.h
21  * @brief Define the host data path IP Acceleraor API functions
22  */
23 #ifndef _CDP_TXRX_IPA_H_
24 #define _CDP_TXRX_IPA_H_
25 
26 #ifdef IPA_OFFLOAD
27 #ifdef CONFIG_IPA_WDI_UNIFIED_API
28 #include <qdf_ipa_wdi3.h>
29 #else
30 #include <qdf_ipa.h>
31 #endif
32 #include <cdp_txrx_cmn.h>
33 #include "cdp_txrx_handle.h"
34 
35 /**
36  * cdp_ipa_get_resource() - Get allocated WLAN resources for IPA data path
37  * @soc - data path soc handle
38  * @pdev_id - device instance id
39  *
40  * Get allocated WLAN resources for IPA data path
41  *
42  * return QDF_STATUS_SUCCESS
43  */
44 static inline QDF_STATUS
45 cdp_ipa_get_resource(ol_txrx_soc_handle soc, uint8_t pdev_id)
46 {
47 	if (!soc || !soc->ops || !soc->ops->ipa_ops) {
48 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
49 			"%s invalid instance", __func__);
50 		return QDF_STATUS_E_FAILURE;
51 	}
52 
53 	if (soc->ops->ipa_ops->ipa_get_resource)
54 		return soc->ops->ipa_ops->ipa_get_resource(soc, pdev_id);
55 
56 	return QDF_STATUS_SUCCESS;
57 }
58 
59 /**
60  * cdp_ipa_set_doorbell_paddr() - give IPA db paddr to FW
61  * @soc - data path soc handle
62  * @pdev_id - device instance id
63  *
64  * give IPA db paddr to FW
65  *
66  * return QDF_STATUS_SUCCESS
67  */
68 static inline QDF_STATUS
69 cdp_ipa_set_doorbell_paddr(ol_txrx_soc_handle soc, uint8_t pdev_id)
70 {
71 	if (!soc || !soc->ops || !soc->ops->ipa_ops) {
72 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
73 			"%s invalid instance", __func__);
74 		return QDF_STATUS_E_FAILURE;
75 	}
76 
77 	if (soc->ops->ipa_ops->ipa_set_doorbell_paddr)
78 		return soc->ops->ipa_ops->ipa_set_doorbell_paddr(soc, pdev_id);
79 
80 	return QDF_STATUS_SUCCESS;
81 }
82 
83 /**
84  * cdp_ipa_set_active() - activate/de-ctivate IPA offload path
85  * @soc - data path soc handle
86  * @pdev_id - device instance id
87  * @uc_active - activate or de-activate
88  * @is_tx - toggle tx or rx data path
89  *
90  * activate/de-ctivate IPA offload path
91  *
92  * return QDF_STATUS_SUCCESS
93  */
94 static inline QDF_STATUS
95 cdp_ipa_set_active(ol_txrx_soc_handle soc, uint8_t pdev_id, bool uc_active,
96 		   bool is_tx)
97 {
98 	if (!soc || !soc->ops || !soc->ops->ipa_ops) {
99 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
100 			"%s invalid instance", __func__);
101 		return QDF_STATUS_E_FAILURE;
102 	}
103 
104 	if (soc->ops->ipa_ops->ipa_set_active)
105 		return soc->ops->ipa_ops->ipa_set_active(soc, pdev_id,
106 				uc_active, is_tx);
107 
108 	return QDF_STATUS_SUCCESS;
109 }
110 
111 /**
112  * cdp_ipa_op_response() - event handler from FW
113  * @soc - data path soc handle
114  * @pdev_id - device instance id
115  * @op_msg - event contents from firmware
116  *
117  * event handler from FW
118  *
119  * return QDF_STATUS_SUCCESS
120  */
121 static inline QDF_STATUS
122 cdp_ipa_op_response(ol_txrx_soc_handle soc, uint8_t pdev_id, uint8_t *op_msg)
123 {
124 	if (!soc || !soc->ops || !soc->ops->ipa_ops) {
125 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
126 			"%s invalid instance", __func__);
127 		return QDF_STATUS_E_FAILURE;
128 	}
129 
130 	if (soc->ops->ipa_ops->ipa_op_response)
131 		return soc->ops->ipa_ops->ipa_op_response(soc, pdev_id, op_msg);
132 
133 	return QDF_STATUS_SUCCESS;
134 }
135 
136 /**
137  * cdp_ipa_register_op_cb() - register event handler function pointer
138  * @soc - data path soc handle
139  * @pdev_id - device instance id
140  * @op_cb - event handler callback function pointer
141  * @usr_ctxt - user context to registered
142  *
143  * register event handler function pointer
144  *
145  * return QDF_STATUS_SUCCESS
146  */
147 static inline QDF_STATUS
148 cdp_ipa_register_op_cb(ol_txrx_soc_handle soc, uint8_t pdev_id,
149 		       ipa_uc_op_cb_type op_cb, void *usr_ctxt)
150 {
151 	if (!soc || !soc->ops || !soc->ops->ipa_ops) {
152 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
153 			"%s invalid instance", __func__);
154 		return QDF_STATUS_E_FAILURE;
155 	}
156 
157 	if (soc->ops->ipa_ops->ipa_register_op_cb)
158 		return soc->ops->ipa_ops->ipa_register_op_cb(soc, pdev_id,
159 							     op_cb, usr_ctxt);
160 
161 	return QDF_STATUS_SUCCESS;
162 }
163 
164 /**
165  * cdp_ipa_deregister_op_cb() - deregister event handler function pointer
166  * @soc - data path soc handle
167  * @pdev_id - device instance id
168  *
169  * Deregister event handler function pointer from pdev
170  *
171  * return QDF_STATUS_SUCCESS
172  */
173 static inline
174 void cdp_ipa_deregister_op_cb(ol_txrx_soc_handle soc, uint8_t pdev_id)
175 {
176 	if (!soc || !soc->ops || !soc->ops->ipa_ops) {
177 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
178 			  "%s invalid instance", __func__);
179 		return;
180 	}
181 
182 	if (soc->ops->ipa_ops->ipa_deregister_op_cb)
183 		soc->ops->ipa_ops->ipa_deregister_op_cb(soc, pdev_id);
184 }
185 
186 /**
187  * cdp_ipa_get_stat() - get IPA data path stats from FW
188  * @soc - data path soc handle
189  * @pdev_id - device instance id
190  *
191  * get IPA data path stats from FW async
192  *
193  * return QDF_STATUS_SUCCESS
194  */
195 static inline QDF_STATUS
196 cdp_ipa_get_stat(ol_txrx_soc_handle soc, uint8_t pdev_id)
197 {
198 	if (!soc || !soc->ops || !soc->ops->ipa_ops) {
199 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
200 			"%s invalid instance", __func__);
201 		return QDF_STATUS_E_FAILURE;
202 	}
203 
204 	if (soc->ops->ipa_ops->ipa_get_stat)
205 		return soc->ops->ipa_ops->ipa_get_stat(soc, pdev_id);
206 
207 	return QDF_STATUS_SUCCESS;
208 }
209 
210 /**
211  * cdp_tx_send_ipa_data_frame() - send IPA data frame
212  * @soc - data path soc handle
213  * @vdev_id: vdev id
214  * @skb: skb
215  *
216  * Return: skb/ NULL is for success
217  */
218 static inline qdf_nbuf_t cdp_ipa_tx_send_data_frame(ol_txrx_soc_handle soc,
219 						    uint8_t vdev_id,
220 						    qdf_nbuf_t skb)
221 {
222 	if (!soc || !soc->ops || !soc->ops->ipa_ops) {
223 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
224 			"%s invalid instance", __func__);
225 		return skb;
226 	}
227 
228 	if (soc->ops->ipa_ops->ipa_tx_data_frame)
229 		return soc->ops->ipa_ops->ipa_tx_data_frame(soc, vdev_id, skb);
230 
231 	return skb;
232 }
233 
234 /**
235  * cdp_ipa_set_uc_tx_partition_base() - set tx packet partition base
236  * @soc - data path soc handle
237  * @cfg_pdev: physical device instance config
238  * @value: partition base value
239  *
240  * Return: QDF_STATUS
241  */
242 static inline QDF_STATUS
243 cdp_ipa_set_uc_tx_partition_base(ol_txrx_soc_handle soc,
244 				struct cdp_cfg *cfg_pdev, uint32_t value)
245 {
246 	if (!soc || !soc->ops || !soc->ops->ipa_ops || !cfg_pdev) {
247 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
248 			"%s invalid instance", __func__);
249 		return QDF_STATUS_E_FAILURE;
250 	}
251 
252 	if (soc->ops->ipa_ops->ipa_set_uc_tx_partition_base)
253 		soc->ops->ipa_ops->ipa_set_uc_tx_partition_base(cfg_pdev,
254 								value);
255 
256 	return QDF_STATUS_SUCCESS;
257 }
258 
259 #ifdef FEATURE_METERING
260 /**
261  * cdp_ipa_uc_get_share_stats() - get Tx/Rx byte stats from FW
262  * @soc - data path soc handle
263  * @pdev_id: physical device instance number
264  * @value: reset stats
265  *
266  * Return: QDF_STATUS
267  */
268 static inline QDF_STATUS
269 cdp_ipa_uc_get_share_stats(ol_txrx_soc_handle soc, uint8_t pdev_id,
270 			   uint8_t value)
271 {
272 	if (!soc || !soc->ops || !soc->ops->ipa_ops) {
273 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
274 			"%s invalid instance", __func__);
275 		return QDF_STATUS_E_FAILURE;
276 	}
277 
278 	if (soc->ops->ipa_ops->ipa_uc_get_share_stats)
279 		return soc->ops->ipa_ops->ipa_uc_get_share_stats(soc, pdev_id,
280 								 value);
281 
282 	return QDF_STATUS_SUCCESS;
283 }
284 
285 /**
286  * cdp_ipa_uc_set_quota() - set quota limit to FW
287  * @soc - data path soc handle
288  * @pdev_id: physical device instance number
289  * @value: quota limit bytes
290  *
291  * Return: QDF_STATUS
292  */
293 static inline QDF_STATUS
294 cdp_ipa_uc_set_quota(ol_txrx_soc_handle soc, uint8_t pdev_id, uint64_t value)
295 {
296 	if (!soc || !soc->ops || !soc->ops->ipa_ops) {
297 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
298 			"%s invalid instance", __func__);
299 		return QDF_STATUS_E_FAILURE;
300 	}
301 
302 	if (soc->ops->ipa_ops->ipa_uc_set_quota)
303 		return soc->ops->ipa_ops->ipa_uc_set_quota(soc, pdev_id, value);
304 
305 	return QDF_STATUS_SUCCESS;
306 }
307 #endif
308 
309 /**
310  * cdp_ipa_enable_autonomy() - Enable autonomy RX data path
311  * @soc: data path soc handle
312  * @pdev_id: physical device instance number
313  *
314  * IPA Data path is enabled and resumed.
315  * All autonomy data path elements are ready to deliver packet
316  * All RX packet should routed to IPA_REO ring, then IPA can receive packet
317  * from WLAN
318  *
319  * Return: QDF_STATUS
320  */
321 static inline QDF_STATUS
322 cdp_ipa_enable_autonomy(ol_txrx_soc_handle soc, uint8_t pdev_id)
323 {
324 	if (!soc || !soc->ops || !soc->ops->ipa_ops) {
325 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
326 			"%s invalid instance", __func__);
327 		return QDF_STATUS_E_FAILURE;
328 	}
329 
330 	if (soc->ops->ipa_ops->ipa_enable_autonomy)
331 		return soc->ops->ipa_ops->ipa_enable_autonomy(soc, pdev_id);
332 
333 	return QDF_STATUS_SUCCESS;
334 }
335 
336 /**
337  * cdp_ipa_disable_autonomy() - Disable autonomy RX data path
338  * @soc: data path soc handle
339  * @pdev_id: physical device instance number
340  *
341  * IPA Data path is enabled and resumed.
342  * All autonomy datapath elements are ready to deliver packet
343  * All RX packet should routed to IPA_REO ring, then IPA can receive packet
344  * from WLAN
345  *
346  * Return: QDF_STATUS
347  */
348 static inline QDF_STATUS
349 cdp_ipa_disable_autonomy(ol_txrx_soc_handle soc, uint8_t pdev_id)
350 {
351 	if (!soc || !soc->ops || !soc->ops->ipa_ops) {
352 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
353 			"%s invalid instance", __func__);
354 		return QDF_STATUS_E_FAILURE;
355 	}
356 	if (soc->ops->ipa_ops->ipa_disable_autonomy)
357 		return soc->ops->ipa_ops->ipa_disable_autonomy(soc, pdev_id);
358 
359 	return QDF_STATUS_SUCCESS;
360 }
361 
362 #ifdef CONFIG_IPA_WDI_UNIFIED_API
363 /**
364  * cdp_ipa_setup() - Setup and connect IPA pipes
365  * @soc: data path soc handle
366  * @pdev_id: handle to the device instance number
367  * @ipa_i2w_cb: IPA to WLAN callback
368  * @ipa_w2i_cb: WLAN to IPA callback
369  * @ipa_wdi_meter_notifier_cb: IPA WDI metering callback
370  * @ipa_desc_size: IPA descriptor size
371  * @ipa_priv: handle to the HTT instance
372  * @is_rm_enabled: Is IPA RM enabled or not
373  * @tx_pipe_handle: pointer to Tx pipe handle
374  * @rx_pipe_handle: pointer to Rx pipe handle
375  * @is_smmu_enabled: Is SMMU enabled or not
376  * @sys_in: parameters to setup sys pipe in mcc mode
377  * @over_gsi: Is IPA using GSI
378  *
379  * Return: QDF_STATUS
380  */
381 static inline QDF_STATUS
382 cdp_ipa_setup(ol_txrx_soc_handle soc, uint8_t pdev_id, void *ipa_i2w_cb,
383 	      void *ipa_w2i_cb, void *ipa_wdi_meter_notifier_cb,
384 	      uint32_t ipa_desc_size, void *ipa_priv, bool is_rm_enabled,
385 	      uint32_t *tx_pipe_handle, uint32_t *rx_pipe_handle,
386 	      bool is_smmu_enabled, qdf_ipa_sys_connect_params_t *sys_in,
387 	      bool over_gsi)
388 {
389 	if (!soc || !soc->ops || !soc->ops->ipa_ops) {
390 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
391 			"%s invalid instance", __func__);
392 		return QDF_STATUS_E_FAILURE;
393 	}
394 
395 	if (soc->ops->ipa_ops->ipa_setup)
396 		return soc->ops->ipa_ops->ipa_setup(soc, pdev_id, ipa_i2w_cb,
397 						    ipa_w2i_cb,
398 						    ipa_wdi_meter_notifier_cb,
399 						    ipa_desc_size, ipa_priv,
400 						    is_rm_enabled,
401 						    tx_pipe_handle,
402 						    rx_pipe_handle,
403 						    is_smmu_enabled,
404 						    sys_in, over_gsi);
405 
406 	return QDF_STATUS_SUCCESS;
407 }
408 #else /* CONFIG_IPA_WDI_UNIFIED_API */
409 /**
410  * cdp_ipa_setup() - Setup and connect IPA pipes
411  * @soc: data path soc handle
412  * @pdev_id: handle to the device instance number
413  * @ipa_i2w_cb: IPA to WLAN callback
414  * @ipa_w2i_cb: WLAN to IPA callback
415  * @ipa_wdi_meter_notifier_cb: IPA WDI metering callback
416  * @ipa_desc_size: IPA descriptor size
417  * @ipa_priv: handle to the HTT instance
418  * @is_rm_enabled: Is IPA RM enabled or not
419  * @tx_pipe_handle: pointer to Tx pipe handle
420  * @rx_pipe_handle: pointer to Rx pipe handle
421  *
422  * Return: QDF_STATUS
423  */
424 static inline QDF_STATUS
425 cdp_ipa_setup(ol_txrx_soc_handle soc, uint8_t pdev_id, void *ipa_i2w_cb,
426 	      void *ipa_w2i_cb, void *ipa_wdi_meter_notifier_cb,
427 	      uint32_t ipa_desc_size, void *ipa_priv, bool is_rm_enabled,
428 	      uint32_t *tx_pipe_handle, uint32_t *rx_pipe_handle)
429 {
430 	if (!soc || !soc->ops || !soc->ops->ipa_ops) {
431 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
432 			"%s invalid instance", __func__);
433 		return QDF_STATUS_E_FAILURE;
434 	}
435 
436 	if (soc->ops->ipa_ops->ipa_setup)
437 		return soc->ops->ipa_ops->ipa_setup(soc, pdev_id, ipa_i2w_cb,
438 						    ipa_w2i_cb,
439 						    ipa_wdi_meter_notifier_cb,
440 						    ipa_desc_size, ipa_priv,
441 						    is_rm_enabled,
442 						    tx_pipe_handle,
443 						    rx_pipe_handle);
444 
445 	return QDF_STATUS_SUCCESS;
446 }
447 #endif /* CONFIG_IPA_WDI_UNIFIED_API */
448 
449 /**
450  * cdp_ipa_cleanup() - Disconnect IPA pipes
451  * @soc: data path soc handle
452  * @pdev_id: handle to the device instance number
453  * @tx_pipe_handle: Tx pipe handle
454  * @rx_pipe_handle: Rx pipe handle
455  *
456  * Return: QDF_STATUS
457  */
458 static inline QDF_STATUS
459 cdp_ipa_cleanup(ol_txrx_soc_handle soc, uint8_t pdev_id,
460 		uint32_t tx_pipe_handle, uint32_t rx_pipe_handle)
461 {
462 	if (!soc || !soc->ops || !soc->ops->ipa_ops) {
463 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
464 			"%s invalid instance", __func__);
465 		return QDF_STATUS_E_FAILURE;
466 	}
467 
468 	if (soc->ops->ipa_ops->ipa_cleanup)
469 		return soc->ops->ipa_ops->ipa_cleanup(soc, pdev_id,
470 						      tx_pipe_handle,
471 						      rx_pipe_handle);
472 
473 	return QDF_STATUS_SUCCESS;
474 }
475 
476 /**
477  * cdp_ipa_setup_iface() - Setup IPA header and register interface
478  * @soc: data path soc handle
479  * @ifname: Interface name
480  * @mac_addr: Interface MAC address
481  * @prod_client: IPA prod client type
482  * @cons_client: IPA cons client type
483  * @session_id: Session ID
484  * @is_ipv6_enabled: Is IPV6 enabled or not
485  *
486  * Return: QDF_STATUS
487  */
488 static inline QDF_STATUS
489 cdp_ipa_setup_iface(ol_txrx_soc_handle soc, char *ifname, uint8_t *mac_addr,
490 		    qdf_ipa_client_type_t prod_client,
491 		    qdf_ipa_client_type_t cons_client,
492 		    uint8_t session_id, bool is_ipv6_enabled)
493 {
494 	if (!soc || !soc->ops || !soc->ops->ipa_ops) {
495 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
496 			"%s invalid instance", __func__);
497 		return QDF_STATUS_E_FAILURE;
498 	}
499 
500 	if (soc->ops->ipa_ops->ipa_setup_iface)
501 		return soc->ops->ipa_ops->ipa_setup_iface(ifname, mac_addr,
502 							  prod_client,
503 							  cons_client,
504 							  session_id,
505 							  is_ipv6_enabled);
506 
507 	return QDF_STATUS_SUCCESS;
508 }
509 
510 /**
511  * cdp_ipa_cleanup_iface() - Cleanup IPA header and deregister interface
512  * @soc: data path soc handle
513  * @ifname: Interface name
514  * @is_ipv6_enabled: Is IPV6 enabled or not
515  *
516  * Return: QDF_STATUS
517  */
518 static inline QDF_STATUS
519 cdp_ipa_cleanup_iface(ol_txrx_soc_handle soc, char *ifname,
520 		      bool is_ipv6_enabled)
521 {
522 	if (!soc || !soc->ops || !soc->ops->ipa_ops) {
523 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
524 			"%s invalid instance", __func__);
525 		return QDF_STATUS_E_FAILURE;
526 	}
527 
528 	if (soc->ops->ipa_ops->ipa_cleanup_iface)
529 		return soc->ops->ipa_ops->ipa_cleanup_iface(ifname,
530 							    is_ipv6_enabled);
531 
532 	return QDF_STATUS_SUCCESS;
533 }
534 
535  /**
536  * cdp_ipa_uc_enable_pipes() - Enable and resume traffic on Tx/Rx pipes
537  * @soc - data path soc handle
538  * @pdev_id - device instance id
539  *
540  * Return: QDF_STATUS
541  */
542 static inline QDF_STATUS
543 cdp_ipa_enable_pipes(ol_txrx_soc_handle soc, uint8_t pdev_id)
544 {
545 	if (!soc || !soc->ops || !soc->ops->ipa_ops) {
546 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
547 			"%s invalid instance", __func__);
548 		return QDF_STATUS_E_FAILURE;
549 	}
550 
551 	if (soc->ops->ipa_ops->ipa_enable_pipes)
552 		return soc->ops->ipa_ops->ipa_enable_pipes(soc, pdev_id);
553 
554 	return QDF_STATUS_SUCCESS;
555 }
556 
557 /**
558  * cdp_ipa_uc_disable_pipes() - Suspend traffic and disable Tx/Rx pipes
559  * @soc: data path soc handle
560  * @pdev_id - device instance id
561  *
562  * Return: QDF_STATUS
563  */
564 static inline QDF_STATUS
565 cdp_ipa_disable_pipes(ol_txrx_soc_handle soc, uint8_t pdev_id)
566 {
567 	if (!soc || !soc->ops || !soc->ops->ipa_ops) {
568 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
569 			"%s invalid instance", __func__);
570 		return QDF_STATUS_E_FAILURE;
571 	}
572 
573 	if (soc->ops->ipa_ops->ipa_disable_pipes)
574 		return soc->ops->ipa_ops->ipa_disable_pipes(soc, pdev_id);
575 
576 	return QDF_STATUS_SUCCESS;
577 }
578 
579 /**
580  * cdp_ipa_set_perf_level() - Set IPA clock bandwidth based on data rates
581  * @soc: data path soc handle
582  * @client: WLAN Client ID
583  * @max_supported_bw_mbps: Maximum bandwidth needed (in Mbps)
584  *
585  * Return: 0 on success, negative errno on error
586  */
587 static inline QDF_STATUS
588 cdp_ipa_set_perf_level(ol_txrx_soc_handle soc, int client,
589 		       uint32_t max_supported_bw_mbps)
590 {
591 	if (!soc || !soc->ops || !soc->ops->ipa_ops) {
592 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
593 			"%s invalid instance", __func__);
594 		return QDF_STATUS_E_FAILURE;
595 	}
596 
597 	if (soc->ops->ipa_ops->ipa_set_perf_level)
598 		return soc->ops->ipa_ops->ipa_set_perf_level(client,
599 				max_supported_bw_mbps);
600 
601 	return QDF_STATUS_SUCCESS;
602 }
603 
604 /**
605  * cdp_ipa_rx_intrabss_fwd() - Perform intra-bss fwd for IPA RX path
606  *
607  * @soc: data path soc handle
608  * @vdev_id: vdev id
609  * @nbuf: pointer to skb of ethernet packet received from IPA RX path
610  * @fwd_success: pointer to indicate if skb succeeded in intra-bss TX
611  *
612  * This function performs intra-bss forwarding for WDI 3.0 IPA RX path.
613  *
614  * Return: true if packet is intra-bss fwd-ed and no need to pass to
615  *	   network stack. false if packet needs to be passed to network stack.
616  */
617 static inline bool
618 cdp_ipa_rx_intrabss_fwd(ol_txrx_soc_handle soc, uint8_t vdev_id,
619 			qdf_nbuf_t nbuf, bool *fwd_success)
620 {
621 	if (!soc || !soc->ops || !soc->ops->ipa_ops || !fwd_success) {
622 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
623 			  "%s invalid instance", __func__);
624 		return QDF_STATUS_E_FAILURE;
625 	}
626 
627 	if (soc->ops->ipa_ops->ipa_rx_intrabss_fwd)
628 		return soc->ops->ipa_ops->ipa_rx_intrabss_fwd(soc, vdev_id,
629 							      nbuf,
630 							      fwd_success);
631 
632 	/* Fall back to pass up to stack */
633 	return false;
634 }
635 
636 /**
637  * cdp_ipa_tx_buf_smmu_mapping() - Create SMMU mappings for Tx
638  *				   buffers allocated to IPA
639  * @soc: data path soc handle
640  * @pdev_id: device instance id
641  *
642  * Create SMMU mappings for Tx buffers allocated to IPA
643  *
644  * return QDF_STATUS_SUCCESS
645  */
646 static inline QDF_STATUS
647 cdp_ipa_tx_buf_smmu_mapping(ol_txrx_soc_handle soc, uint8_t pdev_id)
648 {
649 	if (!soc || !soc->ops || !soc->ops->ipa_ops) {
650 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
651 			  "%s invalid instance", __func__);
652 		return QDF_STATUS_E_FAILURE;
653 	}
654 
655 	if (soc->ops->ipa_ops->ipa_tx_buf_smmu_mapping)
656 		return soc->ops->ipa_ops->ipa_tx_buf_smmu_mapping(soc, pdev_id);
657 
658 	return QDF_STATUS_SUCCESS;
659 }
660 
661 /**
662  * cdp_ipa_tx_buf_smmu_unmapping() - Release SMMU mappings for Tx
663  *				     buffers allocated to IPA
664  * @soc: data path soc handle
665  * @pdev_id: device instance id
666  *
667  * Release SMMU mappings for Tx buffers allocated to IPA
668  *
669  * return QDF_STATUS_SUCCESS
670  */
671 static inline QDF_STATUS
672 cdp_ipa_tx_buf_smmu_unmapping(ol_txrx_soc_handle soc, uint8_t pdev_id)
673 {
674 	if (!soc || !soc->ops || !soc->ops->ipa_ops) {
675 		QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_FATAL,
676 			  "%s invalid instance", __func__);
677 		return QDF_STATUS_E_FAILURE;
678 	}
679 
680 	if (soc->ops->ipa_ops->ipa_tx_buf_smmu_unmapping)
681 		return soc->ops->ipa_ops->ipa_tx_buf_smmu_unmapping(soc,
682 								    pdev_id);
683 
684 	return QDF_STATUS_SUCCESS;
685 }
686 #endif /* IPA_OFFLOAD */
687 
688 #endif /* _CDP_TXRX_IPA_H_ */
689 
690