xref: /wlan-driver/qca-wifi-host-cmn/target_if/direct_buf_rx/inc/target_if_direct_buf_rx_api.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2017-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef _TARGET_IF_DIRECT_BUF_RX_API_H_
21 #define _TARGET_IF_DIRECT_BUF_RX_API_H_
22 
23 #include "qdf_nbuf.h"
24 #include "qdf_atomic.h"
25 #include "wmi_unified_api.h"
26 
27 /**
28  * enum DBR_MODULE - Enum containing the modules supporting direct buf rx
29  * @DBR_MODULE_SPECTRAL: Module ID for Spectral
30  * @DBR_MODULE_CFR: Module ID for CFR
31  * @DBR_MODULE_CBF: Module ID for TXBF CBF CV upload
32  * @DBR_MODULE_MAX: Max module ID
33  */
34 enum DBR_MODULE {
35 	DBR_MODULE_SPECTRAL = 0,
36 	DBR_MODULE_CFR      = 1,
37 	DBR_MODULE_CBF      = 2,
38 	DBR_MODULE_MAX,
39 };
40 
41 #ifdef DIRECT_BUF_RX_ENABLE
42 #ifdef WLAN_DEBUGFS
43 #ifdef DIRECT_BUF_RX_DEBUG
44 /* Base debugfs entry for DBR module */
45 extern qdf_dentry_t dbr_debugfs_entry;
46 #endif /* DIRECT_BUF_RX_DEBUG */
47 #endif /* WLAN_DEBUGFS */
48 
49 #define direct_buf_rx_alert(params...) \
50 	QDF_TRACE_FATAL(QDF_MODULE_ID_DIRECT_BUF_RX, params)
51 #define direct_buf_rx_err(params...) \
52 	QDF_TRACE_ERROR(QDF_MODULE_ID_DIRECT_BUF_RX, params)
53 #define direct_buf_rx_warn(params...) \
54 	QDF_TRACE_WARN(QDF_MODULE_ID_DIRECT_BUF_RX, params)
55 #define direct_buf_rx_notice(params...) \
56 	QDF_TRACE_INFO(QDF_MODULE_ID_DIRECT_BUF_RX, params)
57 #define direct_buf_rx_info(params...) \
58 	QDF_TRACE_INFO(QDF_MODULE_ID_DIRECT_BUF_RX, params)
59 #define direct_buf_rx_debug(params...) \
60 	QDF_TRACE_DEBUG(QDF_MODULE_ID_DIRECT_BUF_RX, params)
61 #define direct_buf_rx_enter() \
62 	QDF_TRACE_ENTER(QDF_MODULE_ID_DIRECT_BUF_RX, "enter")
63 #define direct_buf_rx_exit() \
64 	QDF_TRACE_EXIT(QDF_MODULE_ID_DIRECT_BUF_RX, "exit")
65 
66 #define directbuf_nofl_alert(params...) \
67 	QDF_TRACE_FATAL_NO_FL(QDF_MODULE_ID_DIRECT_BUF_RX, params)
68 #define directbuf_nofl_err(params...) \
69 	QDF_TRACE_ERROR_NO_FL(QDF_MODULE_ID_DIRECT_BUF_RX, params)
70 #define directbuf_nofl_warn(params...) \
71 	QDF_TRACE_WARN_NO_FL(QDF_MODULE_ID_DIRECT_BUF_RX, params)
72 #define directbuf_nofl_info(params...) \
73 	QDF_TRACE_INFO_NO_FL(QDF_MODULE_ID_DIRECT_BUF_RX, params)
74 #define directbuf_nofl_debug(params...) \
75 	QDF_TRACE_DEBUG_NO_FL(QDF_MODULE_ID_DIRECT_BUF_RX, params)
76 
77 #define DBR_MAX_CHAINS      (8)
78 
79 struct wlan_objmgr_psoc;
80 struct wlan_lmac_if_tx_ops;
81 
82 #ifdef WMI_DBR_SUPPORT
83 /**
84  * struct direct_buf_rx_data - direct buffer rx data
85  * @dbr_len: Length of the buffer DMAed
86  * @vaddr: Virtual address of the buffer that has DMAed data
87  * @cookie: Cookie for the buffer rxed from target
88  * @paddr: physical address of buffer corresponding to vaddr
89  * @meta_data_valid: Indicates that metadata is valid
90  * @cv_meta_data_valid: Indicates that CV upload metadata is valid
91  * @cqi_meta_data_valid: Indicates that CQI upload metadata is valid
92  * @meta_data: Meta data
93  * @cv_meta_data: TxBF CV Meta data
94  * @cqi_meta_data: TxBF CQI Meta data
95  */
96 struct direct_buf_rx_data {
97 	size_t dbr_len;
98 	void *vaddr;
99 	uint32_t cookie;
100 	qdf_dma_addr_t paddr;
101 	bool meta_data_valid;
102 	bool cv_meta_data_valid;
103 	bool cqi_meta_data_valid;
104 	union {
105 		struct direct_buf_rx_metadata meta_data;
106 		struct direct_buf_rx_cv_metadata cv_meta_data;
107 		struct direct_buf_rx_cqi_metadata cqi_meta_data;
108 	};
109 };
110 #endif
111 
112 /**
113  * struct dbr_module_config - module configuration for dbr
114  * @num_resp_per_event: Number of events to be packed together
115  * @event_timeout_in_ms: Timeout until which multiple events can be packed
116  */
117 struct dbr_module_config {
118 	uint32_t num_resp_per_event;
119 	uint32_t event_timeout_in_ms;
120 };
121 
122 /**
123  * direct_buf_rx_init() - Function to initialize direct buf rx module
124  *
125  * Return: QDF status of operation
126  */
127 QDF_STATUS direct_buf_rx_init(void);
128 
129 /**
130  * direct_buf_rx_deinit() - Function to deinitialize direct buf rx module
131  *
132  * Return: QDF status of operation
133  */
134 QDF_STATUS direct_buf_rx_deinit(void);
135 
136 /**
137  * direct_buf_rx_target_attach() - Attach hal_soc,osdev in direct buf rx psoc obj
138  * @psoc: pointer to psoc object
139  * @hal_soc: Opaque HAL SOC handle
140  * @osdev: QDF os device handle
141  *
142  * Return: QDF status of operation
143  */
144 QDF_STATUS direct_buf_rx_target_attach(struct wlan_objmgr_psoc *psoc,
145 				void *hal_soc, qdf_device_t osdev);
146 
147 /**
148  * target_if_direct_buf_rx_register_tx_ops() - Register tx ops for direct buffer
149  *                                             rx module
150  * @tx_ops: pointer to lmac interface tx ops
151  *
152  * Return: None
153  */
154 void target_if_direct_buf_rx_register_tx_ops(
155 				struct wlan_lmac_if_tx_ops *tx_ops);
156 
157 /**
158  * target_if_dbr_cookie_lookup() - Function to retrieve cookie from
159  *                                 buffer address(paddr)
160  * @pdev: pointer to pdev object
161  * @mod_id: module id indicating the module using direct buffer rx framework
162  * @paddr: Physical address of buffer for which cookie info is required
163  * @cookie: cookie will be returned in this param
164  * @srng_id: srng ID
165  *
166  * Return: QDF status of operation
167  */
168 QDF_STATUS target_if_dbr_cookie_lookup(struct wlan_objmgr_pdev *pdev,
169 				       uint8_t mod_id, qdf_dma_addr_t paddr,
170 				       uint32_t *cookie, uint8_t srng_id);
171 
172 /**
173  * target_if_dbr_buf_release() - Notify direct buf that a previously provided
174  *                               buffer can be released.
175  * @pdev: pointer to pdev object
176  * @mod_id: module id indicating the module using direct buffer rx framework
177  * @paddr: Physical address of buffer for which cookie info is required
178  * @cookie: cookie value corresponding to the paddr
179  * @srng_id: srng ID
180  *
181  * Return: QDF status of operation
182  */
183 QDF_STATUS target_if_dbr_buf_release(struct wlan_objmgr_pdev *pdev,
184 				     uint8_t mod_id, qdf_dma_addr_t paddr,
185 				     uint32_t cookie, uint8_t srng_id);
186 
187 /**
188  * target_if_dbr_update_pdev_for_hw_mode_change() - Update DBR object in pdev
189  * structure for hw mode change
190  * @pdev: pointer to pdev object
191  * @phy_idx: Phy index
192  */
193 QDF_STATUS target_if_dbr_update_pdev_for_hw_mode_change(
194 		struct wlan_objmgr_pdev *pdev, int phy_idx);
195 
196 /**
197  * target_if_dbr_set_event_handler_ctx() - Set the context for
198  *                                         DBR event execution
199  * @psoc: Pointer to psoc object
200  * @dbr_handler_ctx: DBR event handler context
201  *
202  * Return: QDF status of operation
203  */
204 QDF_STATUS target_if_dbr_set_event_handler_ctx(
205 		struct wlan_objmgr_psoc *psoc,
206 		enum wmi_rx_exec_ctx dbr_handler_ctx);
207 #else /* DIRECT_BUF_RX_ENABLE*/
208 
209 static inline QDF_STATUS
target_if_dbr_cookie_lookup(struct wlan_objmgr_pdev * pdev,uint8_t mod_id,qdf_dma_addr_t paddr,uint32_t * cookie,uint8_t srng_id)210 target_if_dbr_cookie_lookup(struct wlan_objmgr_pdev *pdev,
211 			    uint8_t mod_id, qdf_dma_addr_t paddr,
212 			    uint32_t *cookie, uint8_t srng_id)
213 {
214 	return QDF_STATUS_SUCCESS;
215 }
216 
217 static inline QDF_STATUS
target_if_dbr_buf_release(struct wlan_objmgr_pdev * pdev,uint8_t mod_id,qdf_dma_addr_t paddr,uint32_t cookie,uint8_t srng_id)218 target_if_dbr_buf_release(struct wlan_objmgr_pdev *pdev,
219 			  uint8_t mod_id, qdf_dma_addr_t paddr,
220 			  uint32_t cookie, uint8_t srng_id)
221 {
222 	return QDF_STATUS_SUCCESS;
223 }
224 
225 static inline QDF_STATUS
target_if_dbr_update_pdev_for_hw_mode_change(struct wlan_objmgr_pdev * pdev,int phy_idx)226 target_if_dbr_update_pdev_for_hw_mode_change(
227 		struct wlan_objmgr_pdev *pdev, int phy_idx)
228 {
229 	return QDF_STATUS_SUCCESS;
230 }
231 
232 static inline QDF_STATUS
target_if_dbr_set_event_handler_ctx(struct wlan_objmgr_psoc * psoc,enum wmi_rx_exec_ctx dbr_handler_ctx)233 target_if_dbr_set_event_handler_ctx(
234 		struct wlan_objmgr_psoc *psoc,
235 		enum wmi_rx_exec_ctx dbr_handler_ctx)
236 {
237 	return QDF_STATUS_SUCCESS;
238 }
239 #endif /* DIRECT_BUF_RX_ENABLE */
240 #endif /* _TARGET_IF_DIRECT_BUF_RX_API_H_ */
241