xref: /wlan-dirver/qca-wifi-host-cmn/dp/wifi3.0/be/dp_be_rx.h (revision 5611ef508114526caa3c58ffe2e188650c7b53d1)
1 /*
2  * Copyright (c) 2016-2021 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 #ifndef _DP_BE_RX_H_
20 #define _DP_BE_RX_H_
21 
22 #include <dp_types.h>
23 #include "dp_be.h"
24 
25 uint32_t dp_rx_process_be(struct dp_intr *int_ctx,
26 			  hal_ring_handle_t hal_ring_hdl, uint8_t reo_ring_num,
27 			  uint32_t quota);
28 
29 /**
30  * dp_rx_desc_pool_init_be() - Initialize Rx Descriptor pool(s)
31  * @soc: Handle to DP Soc structure
32  * @rx_desc_pool: Rx descriptor pool handler
33  * @pool_id: Rx descriptor pool ID
34  *
35  * Return: QDF_STATUS_SUCCESS - succeeded, others - failed
36  */
37 QDF_STATUS dp_rx_desc_pool_init_be(struct dp_soc *soc,
38 				   struct rx_desc_pool *rx_desc_pool,
39 				   uint32_t pool_id);
40 
41 /**
42  * dp_rx_desc_pool_deinit_be() - De-initialize Rx Descriptor pool(s)
43  * @soc: Handle to DP Soc structure
44  * @rx_desc_pool: Rx descriptor pool handler
45  * @pool_id: Rx descriptor pool ID
46  *
47  * Return: None
48  */
49 void dp_rx_desc_pool_deinit_be(struct dp_soc *soc,
50 			       struct rx_desc_pool *rx_desc_pool,
51 			       uint32_t pool_id);
52 
53 /**
54  * dp_wbm_get_rx_desc_from_hal_desc_be() - Get corresponding Rx Desc
55  *					address from WBM ring Desc
56  * @soc: Handle to DP Soc structure
57  * @ring_desc: ring descriptor structure pointer
58  * @r_rx_desc: pointer to a pointer of Rx Desc
59  *
60  * Return: QDF_STATUS_SUCCESS - succeeded, others - failed
61  */
62 QDF_STATUS dp_wbm_get_rx_desc_from_hal_desc_be(struct dp_soc *soc,
63 					       void *ring_desc,
64 					       struct dp_rx_desc **r_rx_desc);
65 
66 /**
67  * dp_rx_desc_cookie_2_va_be() - Convert RX Desc cookie ID to VA
68  * @soc:Handle to DP Soc structure
69  * @cookie: cookie used to lookup virtual address
70  *
71  * Return: Rx descriptor virtual address
72  */
73 struct dp_rx_desc *dp_rx_desc_cookie_2_va_be(struct dp_soc *soc,
74 					     uint32_t cookie);
75 
76 #if !defined(DP_FEATURE_HW_COOKIE_CONVERSION) || \
77 		defined(DP_HW_COOKIE_CONVERT_EXCEPTION)
78 /**
79  * dp_rx_desc_sw_cc_check() - check if RX desc VA is got correctly,
80 			      if not, do SW cookie conversion.
81  * @soc:Handle to DP Soc structure
82  * @rx_buf_cookie: RX desc cookie ID
83  * @r_rx_desc: double pointer for RX desc
84  *
85  * Return: None
86  */
87 static inline void
88 dp_rx_desc_sw_cc_check(struct dp_soc *soc,
89 		       uint32_t rx_buf_cookie,
90 		       struct dp_rx_desc **r_rx_desc)
91 {
92 	if (qdf_unlikely(!(*r_rx_desc))) {
93 		*r_rx_desc = (struct dp_rx_desc *)
94 				dp_cc_desc_find(soc,
95 						rx_buf_cookie);
96 	}
97 }
98 #else
99 static inline void
100 dp_rx_desc_sw_cc_check(struct dp_soc *soc,
101 		       uint32_t rx_buf_cookie,
102 		       struct dp_rx_desc **r_rx_desc)
103 {
104 }
105 #endif /* DP_FEATURE_HW_COOKIE_CONVERSION && DP_HW_COOKIE_CONVERT_EXCEPTION */
106 
107 #ifdef WLAN_FEATURE_NEAR_FULL_IRQ
108 /**
109  * dp_rx_nf_process() - Near Full state handler for RX rings.
110  * @int_ctx: interrupt context
111  * @hal_ring_hdl: Rx ring handle
112  * @reo_ring_num: RX ring number
113  * @quota: Quota of work to be done
114  *
115  * Return: work done in the handler
116  */
117 uint32_t dp_rx_nf_process(struct dp_intr *int_ctx,
118 			  hal_ring_handle_t hal_ring_hdl,
119 			  uint8_t reo_ring_num,
120 			  uint32_t quota);
121 #else
122 static inline
123 uint32_t dp_rx_nf_process(struct dp_intr *int_ctx,
124 			  hal_ring_handle_t hal_ring_hdl,
125 			  uint8_t reo_ring_num,
126 			  uint32_t quota)
127 {
128 	return 0;
129 }
130 #endif /*WLAN_FEATURE_NEAR_FULL_IRQ */
131 #endif
132