xref: /wlan-driver/qcacld-3.0/core/dp/txrx/ol_txrx_ipa.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
3  * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17 
18 #ifndef _OL_TXRX_IPA_H_
19 #define _OL_TXRX_IPA_H_
20 
21 #ifdef IPA_OFFLOAD
22 
23 #include <cdp_txrx_cmn.h>       /* ol_txrx_vdev_t, etc. */
24 #include <ol_txrx_types.h>
25 
26 /**
27  * struct frag_header - fragment header type registered to IPA hardware
28  * @length:    fragment length
29  * @reserved1: Reserved not used
30  * @reserved2: Reserved not used
31  *
32  */
33 #ifdef QCA_WIFI_3_0
34 struct frag_header {
35 	uint16_t length;
36 	uint32_t reserved1;
37 	uint32_t reserved2;
38 } __packed;
39 #else
40 struct frag_header {
41 	uint32_t
42 		length:16,
43 		reserved16:16;
44 	uint32_t reserved2;
45 } __packed;
46 #endif
47 
48 /**
49  * struct ipa_header - ipa header type registered to IPA hardware
50  * @vdev_id:  vdev id
51  * @reserved: Reserved not used
52  *
53  */
54 struct ipa_header {
55 	uint32_t
56 		vdev_id:8,      /* vdev_id field is LSB of IPA DESC */
57 		reserved:24;
58 } __packed;
59 
60 /**
61  * struct ol_txrx_ipa_uc_tx_hdr - full tx header registered to IPA hardware
62  * @frag_hd: fragment header
63  * @ipa_hd:  ipa header
64  * @eth:     ether II header
65  *
66  */
67 struct ol_txrx_ipa_uc_tx_hdr {
68 	struct frag_header frag_hd;
69 	struct ipa_header ipa_hd;
70 	struct ethhdr eth;
71 } __packed;
72 
73 /**
74  * struct ol_txrx_ipa_uc_rx_hdr - full rx header registered to IPA hardware
75  * @eth:     ether II header
76  *
77  */
78 struct ol_txrx_ipa_uc_rx_hdr {
79 	struct ethhdr eth;
80 } __packed;
81 
82 #define OL_TXRX_IPA_UC_WLAN_8023_HDR_SIZE      14
83 
84 #define OL_TXRX_IPA_IPV4_NAME_EXT              "_ipv4"
85 #define OL_TXRX_IPA_IPV6_NAME_EXT              "_ipv6"
86 
87 #define OL_TXRX_IPA_MAX_IFACE                  MAX_IPA_IFACE
88 
89 #define OL_TXRX_IPA_WLAN_FRAG_HEADER        sizeof(struct frag_header)
90 #define OL_TXRX_IPA_WLAN_IPA_HEADER         sizeof(struct ipa_header)
91 #define OL_TXRX_IPA_UC_WLAN_TX_HDR_LEN      sizeof(struct ol_txrx_ipa_uc_tx_hdr)
92 #define OL_TXRX_IPA_UC_WLAN_RX_HDR_LEN      sizeof(struct ol_txrx_ipa_uc_rx_hdr)
93 #define OL_TXRX_IPA_UC_WLAN_HDR_DES_MAC_OFFSET \
94 	(OL_TXRX_IPA_WLAN_FRAG_HEADER + OL_TXRX_IPA_WLAN_IPA_HEADER)
95 
96 #if defined(QCA_WIFI_3_0) && defined(CONFIG_IPA3)
97 #define OL_TXRX_IPA_WDI2_SET(pipe_in, ipa_res, osdev) \
98 	do { \
99 		QDF_IPA_PIPE_IN_UL_RDY_RING_RP_VA(pipe_in) = \
100 			ipa_res->rx_proc_done_idx->vaddr; \
101 		QDF_IPA_PIPE_IN_UL_RDY_COMP_RING(pipe_in) = \
102 			qdf_mem_get_dma_addr(osdev, \
103 				&ipa_res->rx2_rdy_ring->mem_info);\
104 		QDF_IPA_PIPE_IN_UL_RDY_COMP_RING_SIZE(pipe_in) = \
105 			ipa_res->rx2_rdy_ring->mem_info.size; \
106 		QDF_IPA_PIPE_IN_UL_RDY_COMP_RING_WP_PA(pipe_in) = \
107 			qdf_mem_get_dma_addr(osdev, \
108 				&ipa_res->rx2_proc_done_idx->mem_info); \
109 		QDF_IPA_PIPE_IN_UL_RDY_COMP_RING_WP_VA(pipe_in) = \
110 			ipa_res->rx2_proc_done_idx->vaddr; \
111 	} while (0)
112 #else
113 /* Do nothing */
114 #define OL_TXRX_IPA_WDI2_SET(pipe_in, ipa_res, osdev)
115 #endif /* IPA3 */
116 
117 /**
118  * ol_txrx_ipa_uc_get_resource() - Client request resource information
119  * @soc_hdl: data path soc handle
120  * @pdev_id: device instance id
121  *
122  *  OL client will request IPA UC related resource information
123  *  Resource information will be distributted to IPA module
124  *  All of the required resources should be pre-allocated
125  *
126  * Return: QDF_STATUS
127  */
128 QDF_STATUS ol_txrx_ipa_uc_get_resource(struct cdp_soc_t *soc_hdl,
129 				       uint8_t pdev_id);
130 
131 /**
132  * ol_txrx_ipa_uc_set_doorbell_paddr() - Client set IPA UC doorbell register
133  * @soc_hdl: data path soc handle
134  * @pdev_id: device instance id
135  *
136  *  IPA UC let know doorbell register physical address
137  *  WLAN firmware will use this physical address to notify IPA UC
138  *
139  * Return: QDF_STATUS
140  */
141 QDF_STATUS ol_txrx_ipa_uc_set_doorbell_paddr(struct cdp_soc_t *soc_hdl,
142 					     uint8_t pdev_id);
143 
144 /**
145  * ol_txrx_ipa_uc_set_active() - Client notify IPA UC data path active or not
146  * @soc_hdl: data path soc handle
147  * @pdev_id: device instance id
148  * @uc_active: WDI UC path enable or not
149  * @is_tx: TX path or RX path
150  *
151  *  IPA UC let know doorbell register physical address
152  *  WLAN firmware will use this physical address to notify IPA UC
153  *
154  * Return: QDF_STATUS
155  */
156 QDF_STATUS ol_txrx_ipa_uc_set_active(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
157 				     bool uc_active, bool is_tx);
158 
159 /**
160  * ol_txrx_ipa_uc_op_response() - Handle OP command response from firmware
161  * @soc_hdl: data path soc handle
162  * @pdev_id: device instance id
163  * @op_msg: op response message from firmware
164  *
165  * Return: none
166  */
167 QDF_STATUS ol_txrx_ipa_uc_op_response(struct cdp_soc_t *soc_hdl,
168 				      uint8_t pdev_id, uint8_t *op_msg);
169 
170 /**
171  * ol_txrx_ipa_uc_register_op_cb() - Register OP handler function
172  * @soc_hdl: data path soc handle
173  * @pdev_id: device instance id
174  * @op_cb: handler function pointer
175  *
176  * Return: none
177  */
178 QDF_STATUS ol_txrx_ipa_uc_register_op_cb(struct cdp_soc_t *soc_hdl,
179 					 uint8_t pdev_id,
180 					 ipa_uc_op_cb_type op_cb,
181 					 void *usr_ctxt);
182 
183 /**
184  * ol_txrx_ipa_uc_get_stat() - Get firmware wdi status
185  * @soc_hdl: data path soc handle
186  * @pdev_id: device instance id
187  *
188  * Return: none
189  */
190 QDF_STATUS ol_txrx_ipa_uc_get_stat(struct cdp_soc_t *soc_hdl, uint8_t pdev_id);
191 
192 /**
193  * ol_txrx_ipa_enable_autonomy() - Enable autonomy RX path
194  * @soc_hdl: data path soc handle
195  * @pdev_id: device instance id
196  *
197  * Set all RX packet route to IPA
198  * Return: none
199  */
200 QDF_STATUS ol_txrx_ipa_enable_autonomy(struct cdp_soc_t *soc_hdl,
201 				       uint8_t pdev_id);
202 
203 /**
204  * ol_txrx_ipa_disable_autonomy() - Disable autonomy RX path
205  * @soc_hdl: data path soc handle
206  * @pdev_id: device instance id
207  *
208  * Disable RX packet route to host
209  * Return: none
210  */
211 QDF_STATUS ol_txrx_ipa_disable_autonomy(struct cdp_soc_t *soc_hdl,
212 					uint8_t pdev_id);
213 
214 /**
215  * ol_txrx_ipa_tx_buf_smmu_mapping() - Create SMMU mappings for IPA
216  *				       allocated TX buffers
217  * @soc_hdl: handle to the soc
218  * @pdev_id: pdev id number, to get the handle
219  *
220  * Return: QDF_STATUS
221  */
222 QDF_STATUS ol_txrx_ipa_tx_buf_smmu_mapping(struct cdp_soc_t *soc_hdl,
223 					   uint8_t pdev_id,
224 					   const char *func,
225 					   uint32_t line);
226 
227 /**
228  * ol_txrx_ipa_tx_buf_smmu_unmapping() - Release SMMU mappings for IPA
229  *					 allocated TX buffers
230  * @soc_hdl: handle to the soc
231  * @pdev_id: pdev id number, to get the handle
232  *
233  * Return: QDF_STATUS
234  */
235 QDF_STATUS ol_txrx_ipa_tx_buf_smmu_unmapping(struct cdp_soc_t *soc_hdl,
236 					     uint8_t pdev_id,
237 					     const char *func,
238 					     uint32_t line);
239 
240 #ifdef CONFIG_IPA_WDI_UNIFIED_API
241 /**
242  * ol_txrx_ipa_setup() - Setup and connect IPA pipes
243  * @soc_hdl: data path soc handle
244  * @pdev_id: device instance id
245  * @ipa_i2w_cb: IPA to WLAN callback
246  * @ipa_w2i_cb: WLAN to IPA callback
247  * @ipa_wdi_meter_notifier_cb: IPA WDI metering callback
248  * @ipa_desc_size: IPA descriptor size
249  * @ipa_priv: handle to the HTT instance
250  * @is_rm_enabled: Is IPA RM enabled or not
251  * @p_tx_pipe_handle: pointer to Tx pipe handle
252  * @p_rx_pipe_handle: pointer to Rx pipe handle
253  * @is_smmu_enabled: Is SMMU enabled or not
254  * @sys_in: parameters to setup sys pipe in mcc mode
255  * @over_gsi: is ipa ver gsi fw
256  *
257  * Return: QDF_STATUS
258  */
259 QDF_STATUS ol_txrx_ipa_setup(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
260 			     void *ipa_i2w_cb, void *ipa_w2i_cb,
261 			     void *ipa_wdi_meter_notifier_cb,
262 			     uint32_t ipa_desc_size,
263 			     void *ipa_priv, bool is_rm_enabled,
264 			     uint32_t *tx_pipe_handle, uint32_t *rx_pipe_handle,
265 			     bool is_smmu_enabled,
266 			     qdf_ipa_sys_connect_params_t *sys_in,
267 			     bool over_gsi,
268 			     qdf_ipa_wdi_hdl_t hdl,
269 			     qdf_ipa_wdi_hdl_t id,
270 			     void *ipa_ast_notify_cb);
271 #else /* CONFIG_IPA_WDI_UNIFIED_API */
272 /**
273  * ol_txrx_ipa_setup() - Setup and connect IPA pipes
274  * @soc_hdl: data path soc handle
275  * @pdev_id: device instance id
276  * @ipa_i2w_cb: IPA to WLAN callback
277  * @ipa_w2i_cb: WLAN to IPA callback
278  * @ipa_wdi_meter_notifier_cb: IPA WDI metering callback
279  * @ipa_desc_size: IPA descriptor size
280  * @ipa_priv: handle to the HTT instance
281  * @is_rm_enabled: Is IPA RM enabled or not
282  * @p_tx_pipe_handle: pointer to Tx pipe handle
283  * @p_rx_pipe_handle: pointer to Rx pipe handle
284  *
285  * Return: QDF_STATUS
286  */
287 QDF_STATUS ol_txrx_ipa_setup(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
288 			     void *ipa_i2w_cb, void *ipa_w2i_cb,
289 			     void *ipa_wdi_meter_notifier_cb,
290 			     uint32_t ipa_desc_size, void *ipa_priv,
291 			     bool is_rm_enabled, uint32_t *tx_pipe_handle,
292 			     uint32_t *rx_pipe_handle,
293 			     qdf_ipa_wdi_hdl_t hdl);
294 #endif /* CONFIG_IPA_WDI_UNIFIED_API */
295 QDF_STATUS ol_txrx_ipa_cleanup(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
296 			       uint32_t tx_pipe_handle,
297 			       uint32_t rx_pipe_handle,
298 			       qdf_ipa_wdi_hdl_t hdl);
299 QDF_STATUS ol_txrx_ipa_setup_iface(char *ifname, uint8_t *mac_addr,
300 		qdf_ipa_client_type_t prod_client,
301 		qdf_ipa_client_type_t cons_client,
302 		uint8_t session_id, bool is_ipv6_enabled,
303 		qdf_ipa_wdi_hdl_t hdl);
304 QDF_STATUS ol_txrx_ipa_cleanup_iface(char *ifname, bool is_ipv6_enabled,
305 				     qdf_ipa_wdi_hdl_t hdl);
306 
307 /**
308  * ol_txrx_ipa_enable_pipes() - Enable and resume traffic on Tx/Rx pipes
309  * @soc_hdl: data path soc handle
310  * @pdev_id: device instance id
311  *
312  * Return: QDF_STATUS
313  */
314 QDF_STATUS ol_txrx_ipa_enable_pipes(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
315 				    qdf_ipa_wdi_hdl_t hdl);
316 
317 /**
318  * ol_txrx_ipa_disable_pipes() – Suspend traffic and disable Tx/Rx pipes
319  * @soc_hdl: data path soc handle
320  * @pdev_id: device instance id
321  *
322  * Return: QDF_STATUS
323  */
324 QDF_STATUS ol_txrx_ipa_disable_pipes(struct cdp_soc_t *soc_hdl,
325 				     uint8_t pdev_id,
326 				     qdf_ipa_wdi_hdl_t hdl);
327 QDF_STATUS ol_txrx_ipa_set_perf_level(int client,
328 				      uint32_t max_supported_bw_mbps,
329 				      qdf_ipa_wdi_hdl_t hdl);
330 #ifdef FEATURE_METERING
331 /**
332  * ol_txrx_ipa_uc_get_share_stats() - get Tx/Rx byte stats from FW
333  * @soc_hdl: data path soc handle
334  * @pdev_id: physical device instance id
335  * @value: reset stats
336  *
337  * Return: QDF_STATUS
338  */
339 QDF_STATUS ol_txrx_ipa_uc_get_share_stats(struct cdp_soc_t *soc_hdl,
340 					  uint8_t pdev_id, uint8_t reset_stats);
341 /**
342  * ol_txrx_ipa_uc_set_quota() - set quota limit to FW
343  * @soc_hdl: data path soc handle
344  * @pdev_id: physical device instance number
345  * @value: quota limit bytes
346  *
347  * Return: QDF_STATUS
348  */
349 QDF_STATUS ol_txrx_ipa_uc_set_quota(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
350 				    uint64_t quota_bytes);
351 #endif
352 #endif
353 #endif /* _OL_TXRX_IPA_H_*/
354