xref: /wlan-driver/qca-wifi-host-cmn/qdf/linux/src/i_qdf_ipa_wdi3.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 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 /**
19  * DOC: i_qdf_ipa_wdi3.h
20  * This file provides OS dependent IPA WDI APIs.
21  */
22 
23 #ifndef I_QDF_IPA_WDI_H
24 #define I_QDF_IPA_WDI_H
25 
26 #ifdef IPA_OFFLOAD
27 
28 #include <qdf_status.h>         /* QDF_STATUS */
29 #include <linux/ipa_wdi3.h>
30 #include <linux/version.h>
31 
32 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0)) || \
33 	defined(CONFIG_IPA_WDI_UNIFIED_API)
34 
35 /**
36  * __qdf_ipa_wdi_version_t - IPA WDI version
37  */
38 typedef enum ipa_wdi_version __qdf_ipa_wdi_version_t;
39 
40 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0))
41 /**
42  * __qdf_ipa_wdi_hdl_t - IPA WDI hdl
43  */
44 typedef ipa_wdi_hdl_t __qdf_ipa_wdi_hdl_t;
45 
46 /**
47  * __qdf_ipa_wdi_capabilities_out_params_t - IPA WDI capabilities output params
48  */
49 typedef struct ipa_wdi_capabilities_out_params \
50 		__qdf_ipa_wdi_capabilities_out_params_t;
51 
52 #define __QDF_IPA_WDI_CAPABILITIES_OUT_PARAMS_NUM_INSTANCES(out_params)	\
53 	(((struct ipa_wdi_capabilities_out_params *)(out_params))->num_of_instances)
54 
55 static inline
__qdf_ipa_wdi_get_capabilities(__qdf_ipa_wdi_capabilities_out_params_t * out)56 int __qdf_ipa_wdi_get_capabilities(__qdf_ipa_wdi_capabilities_out_params_t *out)
57 {
58 	return ipa_wdi_get_capabilities(out);
59 }
60 #else
61 /**
62  * __qdf_ipa_wdi_hdl_t - IPA WDI hdl
63  */
64 typedef unsigned int  __qdf_ipa_wdi_hdl_t;
65 
66 /**
67  * ipa_wdi_capabilities_out_params - IPA WDI capabilities out params
68  */
69 struct ipa_wdi_capabilities_out_params {
70 	uint8_t num_of_instances;
71 };
72 
73 /**
74  * __qdf_ipa_wdi_capabilities_out_params_t - IPA WDI capabilities output params
75  */
76 typedef struct ipa_wdi_capabilities_out_params \
77 		__qdf_ipa_wdi_capabilities_out_params_t;
78 
79 #define __QDF_IPA_WDI_CAPABILITIES_OUT_PARAMS_NUM_INSTANCES(out_params)	\
80 	(((struct ipa_wdi_capabilities_out_params *)(out_params))->num_of_instances)
81 
82 static inline
__qdf_ipa_wdi_get_capabilities(__qdf_ipa_wdi_capabilities_out_params_t * out)83 int __qdf_ipa_wdi_get_capabilities(__qdf_ipa_wdi_capabilities_out_params_t *out)
84 {
85 	out->num_of_instances = 1;
86 	return 1;
87 }
88 
89 /**
90  * ipa_wdi_init_in_params_inst - IPA WDI init in params instance id
91  */
92 struct ipa_wdi_init_in_params_inst {
93 	uint8_t inst_id;
94 };
95 
96 #define __QDF_IPA_WDI_INIT_IN_PARAMS_INSTANCE_ID(in_params)	\
97 	(((struct ipa_wdi_init_in_params_inst *)(in_params))->inst_id)
98 
99 /**
100  * ipa_wdi_init_out_params_inst - IPA WDI init out params IPA handle
101  */
102 struct ipa_wdi_init_out_params_inst {
103 	uint8_t hdl;
104 };
105 
106 #define __QDF_IPA_WDI_INIT_OUT_PARAMS_HANDLE(out_params)	\
107 	(((struct ipa_wdi_init_out_params_inst *)(out_params))->hdl)
108 #endif
109 
110 /**
111  * __qdf_ipa_wdi_init_in_params_t - wdi init input parameters
112  */
113 typedef struct ipa_wdi_init_in_params __qdf_ipa_wdi_init_in_params_t;
114 
115 #define __QDF_IPA_WDI_INIT_IN_PARAMS_WDI_VERSION(in_params)	\
116 	(((struct ipa_wdi_init_in_params *)(in_params))->wdi_version)
117 #define __QDF_IPA_WDI_INIT_IN_PARAMS_NOTIFY(in_params)	\
118 	(((struct ipa_wdi_init_in_params *)(in_params))->notify)
119 #define __QDF_IPA_WDI_INIT_IN_PARAMS_PRIV(in_params)	\
120 	(((struct ipa_wdi_init_in_params *)(in_params))->priv)
121 #define __QDF_IPA_WDI_INIT_IN_PARAMS_WDI_NOTIFY(in_params)	\
122 	(((struct ipa_wdi_init_in_params *)(in_params))->wdi_notify)
123 
124 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0))
125 #define __QDF_IPA_WDI_INIT_IN_PARAMS_INSTANCE_ID(in_params)	\
126 	(((struct ipa_wdi_init_in_params *)(in_params))->inst_id)
127 #endif
128 
129 #ifdef IPA_WDS_EASYMESH_FEATURE
130 #define __QDF_IPA_WDI_INIT_IN_PARAMS_WDS_UPDATE(in_params)	\
131 	(((struct ipa_wdi_init_in_params *)(in_params))->ast_update)
132 #endif
133 
134 /**
135  * __qdf_ipa_wdi_init_out_params_t - wdi init output parameters
136  */
137 typedef struct ipa_wdi_init_out_params __qdf_ipa_wdi_init_out_params_t;
138 
139 #define __QDF_IPA_WDI_INIT_OUT_PARAMS_IS_UC_READY(out_params)	\
140 	(((struct ipa_wdi_init_out_params *)(out_params))->is_uC_ready)
141 #define __QDF_IPA_WDI_INIT_OUT_PARAMS_IS_SMMU_ENABLED(out_params)	\
142 	(((struct ipa_wdi_init_out_params *)(out_params))->is_smmu_enabled)
143 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0))
144 #define __QDF_IPA_WDI_INIT_OUT_PARAMS_OPT_WIFI_DP(out_params)	\
145 	(((struct ipa_wdi_init_out_params *)(out_params))->opt_wdi_dpath)
146 #endif
147 
148 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0))
149 #define __QDF_IPA_WDI_INIT_OUT_PARAMS_HANDLE(out_params)	\
150 	(((struct ipa_wdi_init_out_params *)(out_params))->hdl)
151 #endif
152 
153 #if (defined(IPA_WDI3_GSI)) || (defined(IPA_WDI2_GSI))
154 #define QDF_IPA_WDI_INIT_OUT_PARAMS_IS_OVER_GSI(out_params)	\
155 	(((struct ipa_wdi_init_out_params *)(out_params))->is_over_gsi)
156 #else
157 #define QDF_IPA_WDI_INIT_OUT_PARAMS_IS_OVER_GSI(out_params)	\
158 	false
159 #endif
160 
161 /**
162  * __qdf_ipa_wdi_hdr_info_t - Header to install on IPA HW
163  */
164 typedef struct ipa_wdi_hdr_info  __qdf_ipa_wdi_hdr_info_t;
165 
166 #define __QDF_IPA_WDI_HDR_INFO_HDR(hdr_info)	\
167 	(((struct ipa_wdi_hdr_info *)(hdr_info))->hdr)
168 #define __QDF_IPA_WDI_HDR_INFO_HDR_LEN(hdr_info)	\
169 	(((struct ipa_wdi_hdr_info *)(hdr_info))->hdr_len)
170 #define __QDF_IPA_WDI_HDR_INFO_DST_MAC_ADDR_OFFSET(hdr_info)	\
171 	(((struct ipa_wdi_hdr_info *)(hdr_info))->dst_mac_addr_offset)
172 #define __QDF_IPA_WDI_HDR_INFO_HDR_TYPE(hdr_info)	\
173 	(((struct ipa_wdi_hdr_info *)(hdr_info))->hdr_type)
174 
175 /**
176  * __qdf_ipa_wdi_reg_intf_in_params_t - parameters for uC offload
177  *	interface registration
178  */
179 typedef struct ipa_wdi_reg_intf_in_params  __qdf_ipa_wdi_reg_intf_in_params_t;
180 
181 #define __QDF_IPA_WDI_REG_INTF_IN_PARAMS_NETDEV_NAME(in)	\
182 	(((struct ipa_wdi_reg_intf_in_params *)(in))->netdev_name)
183 #define __QDF_IPA_WDI_REG_INTF_IN_PARAMS_HDR_INFO(in)	\
184 	(((struct ipa_wdi_reg_intf_in_params *)(in))->hdr_info)
185 #define __QDF_IPA_WDI_REG_INTF_IN_PARAMS_ALT_DST_PIPE(in)	\
186 	(((struct ipa_wdi_reg_intf_in_params *)(in))->alt_dst_pipe)
187 #define __QDF_IPA_WDI_REG_INTF_IN_PARAMS_IS_META_DATA_VALID(in)	\
188 	(((struct ipa_wdi_reg_intf_in_params *)(in))->is_meta_data_valid)
189 #define __QDF_IPA_WDI_REG_INTF_IN_PARAMS_META_DATA(in)	\
190 	(((struct ipa_wdi_reg_intf_in_params *)(in))->meta_data)
191 #define __QDF_IPA_WDI_REG_INTF_IN_PARAMS_META_DATA_MASK(in)	\
192 	(((struct ipa_wdi_reg_intf_in_params *)(in))->meta_data_mask)
193 #define __QDF_IPA_WDI_REG_INTF_IN_PARAMS_HANDLE(in)	\
194 	(((struct ipa_wdi_reg_intf_in_params *)(in))->hdl)
195 #ifdef IPA_WDI3_TX_TWO_PIPES
196 #define __QDF_IPA_WDI_REG_INTF_IN_PARAMS_IS_TX1_USED(in)	\
197 	(((struct ipa_wdi_reg_intf_in_params *)(in))->is_tx1_used)
198 #endif
199 #ifdef IPA_WDI3_VLAN_SUPPORT
200 #define __QDF_IPA_WDI_REG_INTF_IN_PARAMS_IS_RX1_USED(in)	\
201 	(((struct ipa_wdi_reg_intf_in_params *)(in))->is_rx1_used)
202 #endif
203 
204 typedef struct ipa_ep_cfg __qdf_ipa_ep_cfg_t;
205 
206 #define __QDF_IPA_EP_CFG_NAT_EN(cfg)	\
207 	(((struct ipa_ep_cfg *)(cfg))->nat.nat_en)
208 #define __QDF_IPA_EP_CFG_HDR_LEN(cfg)	\
209 	(((struct ipa_ep_cfg *)(cfg))->hdr.hdr_len)
210 #define __QDF_IPA_EP_CFG_HDR_OFST_METADATA_VALID(cfg)	\
211 	(((struct ipa_ep_cfg *)(cfg))->hdr.hdr_ofst_metadata_valid)
212 #define __QDF_IPA_EP_CFG_HDR_METADATA_REG_VALID(cfg)	\
213 	(((struct ipa_ep_cfg *)(cfg))->hdr.hdr_metadata_reg_valid)
214 #define __QDF_IPA_EP_CFG_HDR_OFST_PKT_SIZE_VALID(cfg)	\
215 	(((struct ipa_ep_cfg *)(cfg))->hdr.hdr_ofst_pkt_size_valid)
216 #define __QDF_IPA_EP_CFG_HDR_OFST_PKT_SIZE(cfg)	\
217 	(((struct ipa_ep_cfg *)(cfg))->hdr.hdr_ofst_pkt_size)
218 #define __QDF_IPA_EP_CFG_HDR_ADDITIONAL_CONST_LEN(cfg)	\
219 	(((struct ipa_ep_cfg *)(cfg))->hdr.hdr_additional_const_len)
220 #define __QDF_IPA_EP_CFG_MODE(cfg)	\
221 	(((struct ipa_ep_cfg *)(cfg))->mode.mode)
222 #define __QDF_IPA_EP_CFG_HDR_LITTLE_ENDIAN(cfg)	\
223 	(((struct ipa_ep_cfg *)(cfg))->hdr_ext.hdr_little_endian)
224 
225 /**
226  * __qdf_ipa_wdi_pipe_setup_info_t - WDI TX/Rx configuration
227  */
228 typedef struct ipa_wdi_pipe_setup_info  __qdf_ipa_wdi_pipe_setup_info_t;
229 
230 #define __QDF_IPA_WDI_SETUP_INFO_EP_CFG(txrx)	\
231 	(((struct ipa_wdi_pipe_setup_info *)(txrx))->ipa_ep_cfg)
232 
233 #define __QDF_IPA_WDI_SETUP_INFO_CLIENT(txrx)	\
234 	(((struct ipa_wdi_pipe_setup_info *)(txrx))->client)
235 #define __QDF_IPA_WDI_SETUP_INFO_TRANSFER_RING_BASE_PA(txrx)	\
236 	(((struct ipa_wdi_pipe_setup_info *)(txrx))->transfer_ring_base_pa)
237 #define __QDF_IPA_WDI_SETUP_INFO_TRANSFER_RING_SIZE(txrx)	\
238 	(((struct ipa_wdi_pipe_setup_info *)(txrx))->transfer_ring_size)
239 #define __QDF_IPA_WDI_SETUP_INFO_TRANSFER_RING_DOORBELL_PA(txrx)	\
240 	(((struct ipa_wdi_pipe_setup_info *)(txrx))->transfer_ring_doorbell_pa)
241 #define __QDF_IPA_WDI_SETUP_INFO_IS_TXR_RN_DB_PCIE_ADDR(txrx)  \
242 	(((struct ipa_wdi_pipe_setup_info *)(txrx))->is_txr_rn_db_pcie_addr)
243 #define __QDF_IPA_WDI_SETUP_INFO_EVENT_RING_BASE_PA(txrx)	\
244 	(((struct ipa_wdi_pipe_setup_info *)(txrx))->event_ring_base_pa)
245 #define __QDF_IPA_WDI_SETUP_INFO_EVENT_RING_SIZE(txrx)	\
246 	(((struct ipa_wdi_pipe_setup_info *)(txrx))->event_ring_size)
247 #define __QDF_IPA_WDI_SETUP_INFO_EVENT_RING_DOORBELL_PA(txrx)	\
248 	(((struct ipa_wdi_pipe_setup_info *)(txrx))->event_ring_doorbell_pa)
249 #define __QDF_IPA_WDI_SETUP_INFO_IS_EVT_RN_DB_PCIE_ADDR(txrx) \
250 	(((struct ipa_wdi_pipe_setup_info *)(txrx))->is_evt_rn_db_pcie_addr)
251 #define __QDF_IPA_WDI_SETUP_INFO_NUM_PKT_BUFFERS(txrx)	\
252 	(((struct ipa_wdi_pipe_setup_info *)(txrx))->num_pkt_buffers)
253 #define __QDF_IPA_WDI_SETUP_INFO_PKT_OFFSET(txrx)	\
254 	(((struct ipa_wdi_pipe_setup_info *)(txrx))->pkt_offset)
255 #define __QDF_IPA_WDI_SETUP_INFO_DESC_FORMAT_TEMPLATE(txrx)	\
256 	(((struct ipa_wdi_pipe_setup_info *)(txrx))->desc_format_template)
257 
258 /**
259  * __qdf_ipa_wdi_pipe_setup_info_smmu_t - WDI TX/Rx configuration
260  */
261 typedef struct ipa_wdi_pipe_setup_info_smmu __qdf_ipa_wdi_pipe_setup_info_smmu_t;
262 
263 #define __QDF_IPA_WDI_SETUP_INFO_SMMU_EP_CFG(txrx)	\
264 	(((struct ipa_wdi_pipe_setup_info_smmu *)(txrx))->ipa_ep_cfg)
265 
266 #define __QDF_IPA_WDI_SETUP_INFO_SMMU_CLIENT(txrx)	\
267 	(((struct ipa_wdi_pipe_setup_info_smmu *)(txrx))->client)
268 #define __QDF_IPA_WDI_SETUP_INFO_SMMU_TRANSFER_RING_BASE(txrx)	\
269 	(((struct ipa_wdi_pipe_setup_info_smmu *)(txrx))->transfer_ring_base)
270 #define __QDF_IPA_WDI_SETUP_INFO_SMMU_TRANSFER_RING_SIZE(txrx)	\
271 	(((struct ipa_wdi_pipe_setup_info_smmu *)(txrx))->transfer_ring_size)
272 #define __QDF_IPA_WDI_SETUP_INFO_SMMU_TRANSFER_RING_DOORBELL_PA(txrx)	\
273 	(((struct ipa_wdi_pipe_setup_info_smmu *)(txrx))->transfer_ring_doorbell_pa)
274 #define __QDF_IPA_WDI_SETUP_INFO_SMMU_IS_TXR_RN_DB_PCIE_ADDR(txrx)  \
275 	(((struct ipa_wdi_pipe_setup_info_smmu *) \
276 	  (txrx))->is_txr_rn_db_pcie_addr)
277 #define __QDF_IPA_WDI_SETUP_INFO_SMMU_EVENT_RING_BASE(txrx)	\
278 	(((struct ipa_wdi_pipe_setup_info_smmu *)(txrx))->event_ring_base)
279 #define __QDF_IPA_WDI_SETUP_INFO_SMMU_EVENT_RING_SIZE(txrx)	\
280 	(((struct ipa_wdi_pipe_setup_info_smmu *)(txrx))->event_ring_size)
281 #define __QDF_IPA_WDI_SETUP_INFO_SMMU_EVENT_RING_DOORBELL_PA(txrx)	\
282 	(((struct ipa_wdi_pipe_setup_info_smmu *)(txrx))->event_ring_doorbell_pa)
283 #define __QDF_IPA_WDI_SETUP_INFO_SMMU_IS_EVT_RN_DB_PCIE_ADDR(txrx) \
284 	(((struct ipa_wdi_pipe_setup_info_smmu *) \
285 	  (txrx))->is_evt_rn_db_pcie_addr)
286 #define __QDF_IPA_WDI_SETUP_INFO_SMMU_NUM_PKT_BUFFERS(txrx)	\
287 	(((struct ipa_wdi_pipe_setup_info_smmu *)(txrx))->num_pkt_buffers)
288 #define __QDF_IPA_WDI_SETUP_INFO_SMMU_PKT_OFFSET(txrx)	\
289 	(((struct ipa_wdi_pipe_setup_info_smmu *)(txrx))->pkt_offset)
290 #define __QDF_IPA_WDI_SETUP_INFO_SMMU_DESC_FORMAT_TEMPLATE(txrx)	\
291 	(((struct ipa_wdi_pipe_setup_info_smmu *)(txrx))->desc_format_template)
292 
293 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 41))
294 /* MSM kernel support added in I6418ae5bc4f030f6348e0f580b61b6adc1b92cf3 */
295 #define __QDF_IPA_WDI_SETUP_INFO_RX_BANK_ID(txrx, bid)	\
296 	((((struct ipa_wdi_pipe_setup_info *)(txrx))->rx_bank_id) = (bid))
297 
298 #define __QDF_IPA_WDI_SETUP_INFO_SMMU_RX_BANK_ID(txrx, bid)	\
299 	((((struct ipa_wdi_pipe_setup_info_smmu *)(txrx))->rx_bank_id) = (bid))
300 
301 /*
302  * rx_pmac_id was added to struct ipa_wdi_pipe_setup_info with
303  * Change-Id Ic9ee13be05b11004982e9a38cb503b3c4d0f81f3. This change
304  * also modified macro IPA_WDI_INST_MAX from 2 to 3, so we can use
305  * this to know if the change is present or not.
306  */
307 #if defined(IPA_WDI_INST_MAX) && (IPA_WDI_INST_MAX >= 3)
308 #define __QDF_IPA_WDI_SETUP_INFO_RX_PMAC_ID(txrx, pmac_id)	\
309 	((((struct ipa_wdi_pipe_setup_info *)(txrx))->rx_pmac_id) = (pmac_id))
310 
311 #define __QDF_IPA_WDI_SETUP_INFO_SMMU_RX_PMAC_ID(txrx, pmac_id)	\
312 	((((struct ipa_wdi_pipe_setup_info_smmu *)(txrx))->rx_pmac_id) = (pmac_id))
313 #else
314 #define __QDF_IPA_WDI_SETUP_INFO_RX_PMAC_ID(txrx, pmac_id)
315 #define __QDF_IPA_WDI_SETUP_INFO_SMMU_RX_PMAC_ID(txrx, pmac_id)
316 #endif
317 #else
318 #define __QDF_IPA_WDI_SETUP_INFO_RX_BANK_ID(txrx, bid)
319 #define __QDF_IPA_WDI_SETUP_INFO_SMMU_RX_BANK_ID(txrx, bid)
320 #define __QDF_IPA_WDI_SETUP_INFO_RX_PMAC_ID(txrx, pmac_id)
321 #define __QDF_IPA_WDI_SETUP_INFO_SMMU_RX_PMAC_ID(txrx, pmac_id)
322 #endif
323 
324 /**
325  * __qdf_ipa_wdi_conn_in_params_t - information provided by
326  *		uC offload client
327  */
328 typedef struct ipa_wdi_conn_in_params  __qdf_ipa_wdi_conn_in_params_t;
329 
330 #define __QDF_IPA_WDI_CONN_IN_PARAMS_NOTIFY(pipe_in)	\
331 	(((struct ipa_wdi_conn_in_params *)(pipe_in))->notify)
332 #define __QDF_IPA_WDI_CONN_IN_PARAMS_PRIV(pipe_in)	\
333 	(((struct ipa_wdi_conn_in_params *)(pipe_in))->priv)
334 #define __QDF_IPA_WDI_CONN_IN_PARAMS_SMMU_ENABLED(pipe_in)	\
335 	(((struct ipa_wdi_conn_in_params *)(pipe_in))->is_smmu_enabled)
336 #define __QDF_IPA_WDI_CONN_IN_PARAMS_NUM_SYS_PIPE_NEEDED(pipe_in)	\
337 	(((struct ipa_wdi_conn_in_params *)(pipe_in))->num_sys_pipe_needed)
338 #define __QDF_IPA_WDI_CONN_IN_PARAMS_SYS_IN(in)	\
339 	(((struct ipa_wdi_conn_in_params *)(pipe_in))->sys_in)
340 #define __QDF_IPA_WDI_CONN_IN_PARAMS_TX(pipe_in)	\
341 	(((struct ipa_wdi_conn_in_params *)(pipe_in))->u_tx.tx)
342 #define __QDF_IPA_WDI_CONN_IN_PARAMS_TX_SMMU(pipe_in)	\
343 	(((struct ipa_wdi_conn_in_params *)(pipe_in))->u_tx.tx_smmu)
344 #ifdef IPA_WDI3_TX_TWO_PIPES
345 #define __QDF_IPA_WDI_CONN_IN_PARAMS_IS_TX1_USED(pipe_in)	\
346 	(((struct ipa_wdi_conn_in_params *)(pipe_in))->is_tx1_used)
347 #define __QDF_IPA_WDI_CONN_IN_PARAMS_TX_ALT_PIPE(pipe_in)	\
348 	(((struct ipa_wdi_conn_in_params *)(pipe_in))->u_tx1.tx)
349 #define __QDF_IPA_WDI_CONN_IN_PARAMS_TX_ALT_PIPE_SMMU(pipe_in)	\
350 	(((struct ipa_wdi_conn_in_params *)(pipe_in))->u_tx1.tx_smmu)
351 #endif
352 #define __QDF_IPA_WDI_CONN_IN_PARAMS_RX(pipe_in)	\
353 	(((struct ipa_wdi_conn_in_params *)(pipe_in))->u_rx.rx)
354 #define __QDF_IPA_WDI_CONN_IN_PARAMS_RX_SMMU(pipe_in)	\
355 	(((struct ipa_wdi_conn_in_params *)(pipe_in))->u_rx.rx_smmu)
356 #ifdef IPA_WDI3_VLAN_SUPPORT
357 #define __QDF_IPA_WDI_CONN_IN_PARAMS_IS_RX1_USED(pipe_in)	\
358 	(((struct ipa_wdi_conn_in_params *)(pipe_in))->is_rx1_used)
359 #define __QDF_IPA_WDI_CONN_IN_PARAMS_RX_ALT(pipe_in)	\
360 	(((struct ipa_wdi_conn_in_params *)(pipe_in))->u_rx1.rx)
361 #define __QDF_IPA_WDI_CONN_IN_PARAMS_RX_ALT_SMMU(pipe_in)	\
362 	(((struct ipa_wdi_conn_in_params *)(pipe_in))->u_rx1.rx_smmu)
363 #endif
364 #define __QDF_IPA_WDI_CONN_IN_PARAMS_HANDLE(pipe_in)	\
365 	(((struct ipa_wdi_conn_in_params *)(pipe_in))->hdl)
366 
367 #ifdef IPA_WDS_EASYMESH_FEATURE
368 #define __QDF_IPA_WDI_CONN_IN_PARAMS_AST_NOTIFY(pipe_in)	\
369 	(((struct ipa_wdi_conn_in_params *)(pipe_in))->ast_notify)
370 #endif
371 
372 /**
373  * __qdf_ipa_wdi_conn_out_params_t - information provided
374  *				to WLAN druver
375  */
376 typedef struct ipa_wdi_conn_out_params  __qdf_ipa_wdi_conn_out_params_t;
377 
378 #define __QDF_IPA_WDI_CONN_OUT_PARAMS_TX_UC_DB_PA(pipe_out)	\
379 	(((struct ipa_wdi_conn_out_params *)(pipe_out))->tx_uc_db_pa)
380 #ifdef IPA_WDI3_TX_TWO_PIPES
381 #define __QDF_IPA_WDI_CONN_OUT_PARAMS_TX_UC_ALT_DB_PA(pipe_out)	\
382 	(((struct ipa_wdi_conn_out_params *)(pipe_out))->tx1_uc_db_pa)
383 #endif
384 #define __QDF_IPA_WDI_CONN_OUT_PARAMS_RX_UC_DB_PA(pipe_out)	\
385 	(((struct ipa_wdi_conn_out_params *)(pipe_out))->rx_uc_db_pa)
386 #ifdef IPA_WDI3_VLAN_SUPPORT
387 #define __QDF_IPA_WDI_CONN_OUT_PARAMS_RX_ALT_UC_DB_PA(pipe_out)	\
388 	(((struct ipa_wdi_conn_out_params *)(pipe_out))->rx1_uc_db_pa)
389 #endif
390 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0))
391 #define __QDF_IPA_WDI_CONN_OUT_PARAMS_IS_DB_DDR_MAPPED(pipe_out)	\
392 	(((struct ipa_wdi_conn_out_params *)(pipe_out))->is_ddr_mapped)
393 #else
394 #define __QDF_IPA_WDI_CONN_OUT_PARAMS_IS_DB_DDR_MAPPED(pipe_out) false
395 #endif
396 
397 /**
398  * __qdf_ipa_wdi_perf_profile_t - To set BandWidth profile
399  */
400 typedef struct ipa_wdi_perf_profile  __qdf_ipa_wdi_perf_profile_t;
401 
402 #define __QDF_IPA_WDI_PERF_PROFILE_CLIENT(profile)	\
403 	(((struct ipa_wdi_perf_profile *)(profile))->client)
404 #define __QDF_IPA_WDI_PERF_PROFILE_MAX_SUPPORTED_BW_MBPS(profile)	\
405 	(((struct ipa_wdi_perf_profile *)(profile))->max_supported_bw_mbps)
406 
407 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0))
408 /**
409  * __qdf_ipa_wdi_init - Client should call this function to
410  * init WDI IPA offload data path
411  *
412  * Note: Should not be called from atomic context and only
413  * after checking IPA readiness using ipa_register_ipa_ready_cb()
414  *
415  * @Return 0 on success, negative on failure
416  */
__qdf_ipa_wdi_init(struct ipa_wdi_init_in_params * in,struct ipa_wdi_init_out_params * out)417 static inline int __qdf_ipa_wdi_init(struct ipa_wdi_init_in_params *in,
418 		 struct ipa_wdi_init_out_params *out)
419 {
420 	return ipa_wdi_init_per_inst(in, out);
421 }
422 
423 /**
424  * __qdf_ipa_wdi_cleanup - Client should call this function to
425  * clean up WDI IPA offload data path
426  * @hdl: IPA handle
427  *
428  * @Return 0 on success, negative on failure
429  */
__qdf_ipa_wdi_cleanup(__qdf_ipa_wdi_hdl_t hdl)430 static inline int __qdf_ipa_wdi_cleanup(__qdf_ipa_wdi_hdl_t hdl)
431 {
432 	return ipa_wdi_cleanup_per_inst(hdl);
433 }
434 
435 /**
436  * __qdf_ipa_wdi_reg_intf - Client should call this function to
437  * init WDI IPA offload data path
438  *
439  * Note: Should not be called from atomic context and only
440  * after checking IPA readiness using ipa_register_ipa_ready_cb()
441  *
442  * @Return 0 on success, negative on failure
443  */
__qdf_ipa_wdi_reg_intf(struct ipa_wdi_reg_intf_in_params * in)444 static inline int __qdf_ipa_wdi_reg_intf(
445 	struct ipa_wdi_reg_intf_in_params *in)
446 {
447 	return ipa_wdi_reg_intf_per_inst(in);
448 }
449 
450 #ifdef IPA_OPT_WIFI_DP
451 /**
452  * __qdf_ipa_wdi_register_flt_cb() - register callbacks for optional wifi dp
453  * @hdl: ipa_hdl
454  * @flt_rsrv_cb: filter reserve cb function
455  * @flt_rsrv_rel_cb: filter release cb function
456  * @flt_add_cb: filter add cb function
457  * @flt_rem_cb: filter remove cb
458  *
459  * Note: Should not be called from atomic context and only
460  * after checking IPA readiness using ipa_register_ipa_ready_cb()
461  *
462  * @Return 0 on successful register of filter cb, negative on failure
463  */
__qdf_ipa_wdi_register_flt_cb(ipa_wdi_hdl_t hdl,ipa_wdi_opt_dpath_flt_rsrv_cb flt_rsrv_cb,ipa_wdi_opt_dpath_flt_rsrv_rel_cb flt_rsrv_rel_cb,ipa_wdi_opt_dpath_flt_add_cb flt_add_cb,ipa_wdi_opt_dpath_flt_rem_cb flt_rem_cb)464 static inline int __qdf_ipa_wdi_register_flt_cb(
465 			ipa_wdi_hdl_t hdl,
466 			ipa_wdi_opt_dpath_flt_rsrv_cb flt_rsrv_cb,
467 			ipa_wdi_opt_dpath_flt_rsrv_rel_cb flt_rsrv_rel_cb,
468 			ipa_wdi_opt_dpath_flt_add_cb flt_add_cb,
469 			ipa_wdi_opt_dpath_flt_rem_cb flt_rem_cb)
470 {
471 	return ipa_wdi_opt_dpath_register_flt_cb_per_inst(
472 					hdl, flt_rsrv_cb,
473 					flt_rsrv_rel_cb,
474 					flt_add_cb, flt_rem_cb);
475 }
476 
477 /**
478  * __qdf_ipa_wdi_opt_dpath_notify_flt_rsvd_per_inst() - notify response to
479  * filter reserve request from IPA
480  * @hdl: ipa_hdl
481  * @is_success: result of filter reservation
482  *
483  * Note: Should not be called from atomic context and only
484  * after checking IPA readiness using ipa_register_ipa_ready_cb()
485  *
486  * @Return 0 if ipa received the notification, negative on failure
487  */
__qdf_ipa_wdi_opt_dpath_notify_flt_rsvd_per_inst(ipa_wdi_hdl_t hdl,bool is_success)488 static inline int __qdf_ipa_wdi_opt_dpath_notify_flt_rsvd_per_inst(
489 			ipa_wdi_hdl_t hdl, bool is_success)
490 {
491 	return ipa_wdi_opt_dpath_notify_flt_rsvd_per_inst(hdl, is_success);
492 }
493 
494 /**
495  *__qdf_ipa_wdi_opt_dpath_notify_flt_rlsd_per_inst() notify response to
496  *filter release request from IPA
497  * @hdl: ipa_hdl
498  * @is_success: result of filter release
499  *
500  * Note: Should not be called from atomic context and only
501  * after checking IPA readiness using ipa_register_ipa_ready_cb()
502  *
503  * @Return 0 if ipa received the notification, negative on failure
504  */
__qdf_ipa_wdi_opt_dpath_notify_flt_rlsd_per_inst(ipa_wdi_hdl_t hdl,bool is_success)505 static inline int __qdf_ipa_wdi_opt_dpath_notify_flt_rlsd_per_inst(
506 			ipa_wdi_hdl_t hdl, bool is_success)
507 {
508 	return ipa_wdi_opt_dpath_notify_flt_rlsd_per_inst(hdl, is_success);
509 }
510 #endif /*IPA_OPT_WIFI_DP */
511 /**
512  * __qdf_ipa_wdi_dereg_intf - Client Driver should call this
513  * function to deregister before unload and after disconnect
514  * @hdl: IPA handle
515  *
516  * @Return 0 on success, negative on failure
517  */
__qdf_ipa_wdi_dereg_intf(const char * netdev_name,__qdf_ipa_wdi_hdl_t hdl)518 static inline int __qdf_ipa_wdi_dereg_intf(const char *netdev_name,
519 					   __qdf_ipa_wdi_hdl_t hdl)
520 {
521 	return ipa_wdi_dereg_intf_per_inst(netdev_name, hdl);
522 }
523 
524 /**
525  * __qdf_ipa_wdi_conn_pipes - Client should call this
526  * function to connect pipes
527  * @in:	[in] input parameters from client
528  * @out: [out] output params to client
529  *
530  * Note: Should not be called from atomic context and only
531  * after checking IPA readiness using ipa_register_ipa_ready_cb()
532  *
533  * @Return 0 on success, negative on failure
534  */
__qdf_ipa_wdi_conn_pipes(struct ipa_wdi_conn_in_params * in,struct ipa_wdi_conn_out_params * out)535 static inline int __qdf_ipa_wdi_conn_pipes(struct ipa_wdi_conn_in_params *in,
536 			struct ipa_wdi_conn_out_params *out)
537 {
538 	return ipa_wdi_conn_pipes_per_inst(in, out);
539 }
540 
541 /**
542  * __qdf_ipa_wdi_disconn_pipes() - Client should call this
543  *		function to disconnect pipes
544  * @hdl: IPA handle
545  *
546  * Note: Should not be called from atomic context
547  *
548  * Returns: 0 on success, negative on failure
549  */
__qdf_ipa_wdi_disconn_pipes(__qdf_ipa_wdi_hdl_t hdl)550 static inline int __qdf_ipa_wdi_disconn_pipes(__qdf_ipa_wdi_hdl_t hdl)
551 {
552 	return ipa_wdi_disconn_pipes_per_inst(hdl);
553 }
554 
555 /**
556  * __qdf_ipa_wdi_enable_pipes() - Client should call this
557  *		function to enable IPA offload data path
558  * @hdl: IPA handle
559  *
560  * Note: Should not be called from atomic context
561  *
562  * Returns: 0 on success, negative on failure
563  */
__qdf_ipa_wdi_enable_pipes(__qdf_ipa_wdi_hdl_t hdl)564 static inline int __qdf_ipa_wdi_enable_pipes(__qdf_ipa_wdi_hdl_t hdl)
565 {
566 	return ipa_wdi_enable_pipes_per_inst(hdl);
567 }
568 
569 /**
570  * __qdf_ipa_wdi_disable_pipes() - Client should call this
571  *		function to disable IPA offload data path
572  * @hdl: IPA handle
573  *
574  * Note: Should not be called from atomic context
575  *
576  * Returns: 0 on success, negative on failure
577  */
__qdf_ipa_wdi_disable_pipes(__qdf_ipa_wdi_hdl_t hdl)578 static inline int __qdf_ipa_wdi_disable_pipes(__qdf_ipa_wdi_hdl_t hdl)
579 {
580 	return ipa_wdi_disable_pipes_per_inst(hdl);
581 }
582 
583 /**
584  * __qdf_ipa_wdi_set_perf_profile() - Client should call this function to
585  *		set IPA clock bandwidth based on data rates
586  * @hdl: IPA handle
587  * @profile: [in] BandWidth profile to use
588  *
589  * Returns: 0 on success, negative on failure
590  */
__qdf_ipa_wdi_set_perf_profile(__qdf_ipa_wdi_hdl_t hdl,struct ipa_wdi_perf_profile * profile)591 static inline int __qdf_ipa_wdi_set_perf_profile(__qdf_ipa_wdi_hdl_t hdl,
592 						 struct ipa_wdi_perf_profile *profile)
593 {
594 	return ipa_wdi_set_perf_profile_per_inst(hdl, profile);
595 }
596 
597 /**
598  * __qdf_ipa_wdi_create_smmu_mapping() - Client should call this function to
599  *		create smmu mapping
600  * @hdl: IPA handle
601  * @num_buffers: [in] number of buffers
602  * @info: [in] wdi buffer info
603  *
604  * Returns: 0 on success, negative on failure
605  */
__qdf_ipa_wdi_create_smmu_mapping(__qdf_ipa_wdi_hdl_t hdl,u32 num_buffers,struct ipa_wdi_buffer_info * info)606 static inline int __qdf_ipa_wdi_create_smmu_mapping(__qdf_ipa_wdi_hdl_t hdl,
607 						    u32 num_buffers,
608 						    struct ipa_wdi_buffer_info *info)
609 {
610 	return ipa_wdi_create_smmu_mapping_per_inst(hdl, num_buffers, info);
611 }
612 
613 /**
614  * __qdf_ipa_wdi_release_smmu_mapping() - Client should call this function to
615  *		release smmu mapping
616  * @hdl: IPA handle
617  * @num_buffers: [in] number of buffers
618  * @info: [in] wdi buffer info
619  *
620  * Returns: 0 on success, negative on failure
621  */
__qdf_ipa_wdi_release_smmu_mapping(__qdf_ipa_wdi_hdl_t hdl,u32 num_buffers,struct ipa_wdi_buffer_info * info)622 static inline int __qdf_ipa_wdi_release_smmu_mapping(__qdf_ipa_wdi_hdl_t hdl,
623 						     u32 num_buffers,
624 						     struct ipa_wdi_buffer_info *info)
625 {
626 	return ipa_wdi_release_smmu_mapping_per_inst(hdl, num_buffers, info);
627 }
628 #else
629 /**
630  * __qdf_ipa_wdi_init - Client should call this function to
631  * init WDI IPA offload data path
632  *
633  * Note: Should not be called from atomic context and only
634  * after checking IPA readiness using ipa_register_ipa_ready_cb()
635  *
636  * @Return 0 on success, negative on failure
637  */
__qdf_ipa_wdi_init(struct ipa_wdi_init_in_params * in,struct ipa_wdi_init_out_params * out)638 static inline int __qdf_ipa_wdi_init(struct ipa_wdi_init_in_params *in,
639 		 struct ipa_wdi_init_out_params *out)
640 {
641 	return ipa_wdi_init(in, out);
642 }
643 
644 /**
645  * __qdf_ipa_wdi_cleanup - Client should call this function to
646  * clean up WDI IPA offload data path
647  * @hdl: IPA handle
648  *
649  * @Return 0 on success, negative on failure
650  */
__qdf_ipa_wdi_cleanup(__qdf_ipa_wdi_hdl_t hdl)651 static inline int __qdf_ipa_wdi_cleanup(__qdf_ipa_wdi_hdl_t hdl)
652 {
653 	return ipa_wdi_cleanup();
654 }
655 
656 /**
657  * __qdf_ipa_wdi_reg_intf - Client should call this function to
658  * init WDI IPA offload data path
659  *
660  * Note: Should not be called from atomic context and only
661  * after checking IPA readiness using ipa_register_ipa_ready_cb()
662  *
663  * @Return 0 on success, negative on failure
664  */
__qdf_ipa_wdi_reg_intf(struct ipa_wdi_reg_intf_in_params * in)665 static inline int __qdf_ipa_wdi_reg_intf(
666 	struct ipa_wdi_reg_intf_in_params *in)
667 {
668 	return ipa_wdi_reg_intf(in);
669 }
670 
671 /**
672  * __qdf_ipa_wdi_dereg_intf - Client Driver should call this
673  * function to deregister before unload and after disconnect
674  * @hdl: IPA handle
675  *
676  * @Return 0 on success, negative on failure
677  */
__qdf_ipa_wdi_dereg_intf(const char * netdev_name,__qdf_ipa_wdi_hdl_t hdl)678 static inline int __qdf_ipa_wdi_dereg_intf(const char *netdev_name,
679 					   __qdf_ipa_wdi_hdl_t hdl)
680 {
681 	return ipa_wdi_dereg_intf(netdev_name);
682 }
683 
684 /**
685  * __qdf_ipa_wdi_conn_pipes - Client should call this
686  * function to connect pipes
687  * @in:	[in] input parameters from client
688  * @out: [out] output params to client
689  *
690  * Note: Should not be called from atomic context and only
691  * after checking IPA readiness using ipa_register_ipa_ready_cb()
692  *
693  * @Return 0 on success, negative on failure
694  */
__qdf_ipa_wdi_conn_pipes(struct ipa_wdi_conn_in_params * in,struct ipa_wdi_conn_out_params * out)695 static inline int __qdf_ipa_wdi_conn_pipes(struct ipa_wdi_conn_in_params *in,
696 			struct ipa_wdi_conn_out_params *out)
697 {
698 	return ipa_wdi_conn_pipes(in, out);
699 }
700 
701 /**
702  * __qdf_ipa_wdi_disconn_pipes() - Client should call this
703  *		function to disconnect pipes
704  * @hdl: IPA handle
705  *
706  * Note: Should not be called from atomic context
707  *
708  * Returns: 0 on success, negative on failure
709  */
__qdf_ipa_wdi_disconn_pipes(__qdf_ipa_wdi_hdl_t hdl)710 static inline int __qdf_ipa_wdi_disconn_pipes(__qdf_ipa_wdi_hdl_t hdl)
711 {
712 	return ipa_wdi_disconn_pipes();
713 }
714 
715 /**
716  * __qdf_ipa_wdi_enable_pipes() - Client should call this
717  *		function to enable IPA offload data path
718  * @hdl: IPA handle
719  *
720  * Note: Should not be called from atomic context
721  *
722  * Returns: 0 on success, negative on failure
723  */
__qdf_ipa_wdi_enable_pipes(__qdf_ipa_wdi_hdl_t hdl)724 static inline int __qdf_ipa_wdi_enable_pipes(__qdf_ipa_wdi_hdl_t hdl)
725 {
726 	return ipa_wdi_enable_pipes();
727 }
728 
729 /**
730  * __qdf_ipa_wdi_disable_pipes() - Client should call this
731  *		function to disable IPA offload data path
732  * @hdl: IPA handle
733  *
734  * Note: Should not be called from atomic context
735  *
736  * Returns: 0 on success, negative on failure
737  */
__qdf_ipa_wdi_disable_pipes(__qdf_ipa_wdi_hdl_t hdl)738 static inline int __qdf_ipa_wdi_disable_pipes(__qdf_ipa_wdi_hdl_t hdl)
739 {
740 	return ipa_wdi_disable_pipes();
741 }
742 
743 /**
744  * __qdf_ipa_wdi_set_perf_profile() - Client should call this function to
745  *		set IPA clock bandwidth based on data rates
746  * @hdl: IPA handle
747  * @profile: [in] BandWidth profile to use
748  *
749  * Returns: 0 on success, negative on failure
750  */
__qdf_ipa_wdi_set_perf_profile(__qdf_ipa_wdi_hdl_t hdl,struct ipa_wdi_perf_profile * profile)751 static inline int __qdf_ipa_wdi_set_perf_profile(__qdf_ipa_wdi_hdl_t hdl,
752 						 struct ipa_wdi_perf_profile *profile)
753 {
754 	return ipa_wdi_set_perf_profile(profile);
755 }
756 
757 /**
758  * __qdf_ipa_wdi_create_smmu_mapping() - Client should call this function to
759  *		create smmu mapping
760  * @hdl: IPA handle
761  * @num_buffers: [in] number of buffers
762  * @info: [in] wdi buffer info
763  *
764  * Returns: 0 on success, negative on failure
765  */
__qdf_ipa_wdi_create_smmu_mapping(__qdf_ipa_wdi_hdl_t hdl,u32 num_buffers,struct ipa_wdi_buffer_info * info)766 static inline int __qdf_ipa_wdi_create_smmu_mapping(__qdf_ipa_wdi_hdl_t hdl,
767 						    u32 num_buffers,
768 						    struct ipa_wdi_buffer_info *info)
769 {
770 	return ipa_wdi_create_smmu_mapping(num_buffers, info);
771 }
772 
773 /**
774  * __qdf_ipa_wdi_release_smmu_mapping() - Client should call this function to
775  *		release smmu mapping
776  * @hdl: IPA handle
777  * @num_buffers: [in] number of buffers
778  * @info: [in] wdi buffer info
779  *
780  * Returns: 0 on success, negative on failure
781  */
__qdf_ipa_wdi_release_smmu_mapping(__qdf_ipa_wdi_hdl_t hdl,u32 num_buffers,struct ipa_wdi_buffer_info * info)782 static inline int __qdf_ipa_wdi_release_smmu_mapping(__qdf_ipa_wdi_hdl_t hdl,
783 						     u32 num_buffers,
784 						     struct ipa_wdi_buffer_info *info)
785 {
786 	return ipa_wdi_release_smmu_mapping(num_buffers, info);
787 }
788 
789 #endif
790 
791 #ifdef WDI3_STATS_UPDATE
792 /**
793  * __qdf_ipa_wdi_wlan_stats() - Client should call this function to
794  *		send Tx byte counts to IPA driver
795  * @tx_stats: number of Tx bytes on STA and SAP
796  *
797  * Returns: 0 on success, negative on failure
798  */
__qdf_ipa_wdi_wlan_stats(struct ipa_wdi_tx_info * tx_stats)799 static inline int __qdf_ipa_wdi_wlan_stats(struct ipa_wdi_tx_info *tx_stats)
800 {
801 	return ipa_wdi_sw_stats(tx_stats);
802 }
803 
804 /**
805  * ipa_uc_bw_monitor() - start/stop uc bw monitoring
806  * @bw_info: set bw info levels to monitor
807  *
808  * Returns: 0 on success, negative on failure
809  */
__qdf_ipa_uc_bw_monitor(struct ipa_wdi_bw_info * bw_info)810 static inline int __qdf_ipa_uc_bw_monitor(struct ipa_wdi_bw_info *bw_info)
811 {
812 	return ipa_uc_bw_monitor(bw_info);
813 }
814 #endif
815 #else /* CONFIG_IPA_WDI_UNIFIED_API */
816 
817 /**
818  * __qdf_ipa_wdi_hdr_info_t - Header to install on IPA HW
819  */
820 typedef struct ipa_wdi3_hdr_info  __qdf_ipa_wdi_hdr_info_t;
821 
822 #define __QDF_IPA_WDI_HDR_INFO_HDR(hdr_info)	\
823 	(((struct ipa_wdi3_hdr_info *)(hdr_info))->hdr)
824 #define __QDF_IPA_WDI_HDR_INFO_HDR_LEN(hdr_info)	\
825 	(((struct ipa_wdi3_hdr_info *)(hdr_info))->hdr_len)
826 #define __QDF_IPA_WDI_HDR_INFO_DST_MAC_ADDR_OFFSET(hdr_info)	\
827 	(((struct ipa_wdi3_hdr_info *)(hdr_info))->dst_mac_addr_offset)
828 #define __QDF_IPA_WDI_HDR_INFO_HDR_TYPE(hdr_info)	\
829 	(((struct ipa_wdi3_hdr_info *)(hdr_info))->hdr_type)
830 
831 /**
832  * __qdf_ipa_wdi_reg_intf_in_params_t - parameters for uC offload
833  *	interface registration
834  */
835 typedef struct ipa_wdi3_reg_intf_in_params  __qdf_ipa_wdi_reg_intf_in_params_t;
836 
837 #define __QDF_IPA_WDI_REG_INTF_IN_PARAMS_NETDEV_NAME(in)	\
838 	(((struct ipa_wdi3_reg_intf_in_params *)(in))->netdev_name)
839 #define __QDF_IPA_WDI_REG_INTF_IN_PARAMS_HDR_INFO(in)	\
840 	(((struct ipa_wdi3_reg_intf_in_params *)(in))->hdr_info)
841 #define __QDF_IPA_WDI_REG_INTF_IN_PARAMS_IS_META_DATA_VALID(in)	\
842 	(((struct ipa_wdi3_reg_intf_in_params *)(in))->is_meta_data_valid)
843 #define __QDF_IPA_WDI_REG_INTF_IN_PARAMS_META_DATA(in)	\
844 	(((struct ipa_wdi3_reg_intf_in_params *)(in))->meta_data)
845 #define __QDF_IPA_WDI_REG_INTF_IN_PARAMS_META_DATA_MASK(in)	\
846 	(((struct ipa_wdi3_reg_intf_in_params *)(in))->meta_data_mask)
847 #define __QDF_IPA_WDI_REG_INTF_IN_PARAMS_HANDLE(in)	\
848 	(((struct ipa_wdi3_reg_intf_in_params *)(in))->hdl)
849 
850 /**
851  * __qdf_ipa_wdi_setup_info_t - WDI3 TX/Rx configuration
852  */
853 typedef struct ipa_wdi3_setup_info  __qdf_ipa_wdi_pipe_setup_info_t;
854 
855 #define __QDF_IPA_WDI_SETUP_INFO_NAT_EN(txrx)	\
856 	(((struct ipa_wdi3_setup_info *)(txrx))->ipa_ep_cfg.nat.nat_en)
857 #define __QDF_IPA_WDI_SETUP_INFO_HDR_LEN(txrx)	\
858 	(((struct ipa_wdi3_setup_info *)(txrx))->ipa_ep_cfg.hdr.hdr_len)
859 #define __QDF_IPA_WDI_SETUP_INFO_HDR_OFST_METADATA_VALID(txrx)	\
860 	(((struct ipa_wdi3_setup_info *)(txrx))->ipa_ep_cfg.hdr.hdr_ofst_metadata_valid)
861 #define __QDF_IPA_WDI_SETUP_INFO_HDR_METADATA_REG_VALID(txrx)	\
862 	(((struct ipa_wdi3_setup_info *)(txrx))->ipa_ep_cfg.hdr.hdr_metadata_reg_valid)
863 #define __QDF_IPA_WDI_SETUP_INFO_HDR_OFST_PKT_SIZE_VALID(txrx)	\
864 	(((struct ipa_wdi3_setup_info *)(txrx))->ipa_ep_cfg.hdr.hdr_ofst_pkt_size_valid)
865 #define __QDF_IPA_WDI_SETUP_INFO_HDR_OFST_PKT_SIZE(txrx)	\
866 	(((struct ipa_wdi3_setup_info *)(txrx))->ipa_ep_cfg.hdr.hdr_ofst_pkt_size)
867 #define __QDF_IPA_WDI_SETUP_INFO_HDR_ADDITIONAL_CONST_LEN(txrx)	\
868 	(((struct ipa_wdi3_setup_info *)(txrx))->ipa_ep_cfg.hdr.hdr_additional_const_len)
869 #define __QDF_IPA_WDI_SETUP_INFO_MODE(txrx)	\
870 	(((struct ipa_wdi3_setup_info *)(txrx))->ipa_ep_cfg.mode.mode)
871 #define __QDF_IPA_WDI_SETUP_INFO_HDR_LITTLE_ENDIAN(txrx)	\
872 	(((struct ipa_wdi3_setup_info *)(txrx))->ipa_ep_cfg.hdr_ext.hdr_little_endian)
873 
874 #define __QDF_IPA_WDI_SETUP_INFO_CLIENT(txrx)	\
875 	(((struct ipa_wdi3_setup_info *)(txrx))->client)
876 #define __QDF_IPA_WDI_SETUP_INFO_TRANSFER_RING_BASE_PA(txrx)	\
877 	(((struct ipa_wdi3_setup_info *)(txrx))->transfer_ring_base_pa)
878 #define __QDF_IPA_WDI_SETUP_INFO_TRANSFER_RING_SIZE(txrx)	\
879 	(((struct ipa_wdi3_setup_info *)(txrx))->transfer_ring_size)
880 #define __QDF_IPA_WDI_SETUP_INFO_TRANSFER_RING_DOORBELL_PA(txrx)	\
881 	(((struct ipa_wdi3_setup_info *)(txrx))->transfer_ring_doorbell_pa)
882 #define __QDF_IPA_WDI_SETUP_INFO_EVENT_RING_BASE_PA(txrx)	\
883 	(((struct ipa_wdi3_setup_info *)(txrx))->event_ring_base_pa)
884 #define __QDF_IPA_WDI_SETUP_INFO_EVENT_RING_SIZE(txrx)	\
885 	(((struct ipa_wdi3_setup_info *)(txrx))->event_ring_size)
886 #define __QDF_IPA_WDI_SETUP_INFO_EVENT_RING_DOORBELL_PA(txrx)	\
887 	(((struct ipa_wdi3_setup_info *)(txrx))->event_ring_doorbell_pa)
888 #define __QDF_IPA_WDI_SETUP_INFO_NUM_PKT_BUFFERS(txrx)	\
889 	(((struct ipa_wdi3_setup_info *)(txrx))->num_pkt_buffers)
890 #define __QDF_IPA_WDI_SETUP_INFO_PKT_OFFSET(txrx)	\
891 	(((struct ipa_wdi3_setup_info *)(txrx))->pkt_offset)
892 #define __QDF_IPA_WDI_SETUP_INFO_DESC_FORMAT_TEMPLATE(txrx)	\
893 	(((struct ipa_wdi3_setup_info *)(txrx))->desc_format_template)
894 
895 /**
896  * __qdf_ipa_wdi_conn_in_params_t - information provided by
897  *		uC offload client
898  */
899 typedef struct ipa_wdi3_conn_in_params  __qdf_ipa_wdi_conn_in_params_t;
900 
901 #define __QDF_IPA_WDI_CONN_IN_PARAMS_NOTIFY(pipe_in)	\
902 	(((struct ipa_wdi3_conn_in_params *)(pipe_in))->notify)
903 #define __QDF_IPA_WDI_CONN_IN_PARAMS_PRIV(pipe_in)	\
904 	(((struct ipa_wdi3_conn_in_params *)(pipe_in))->priv)
905 #define __QDF_IPA_WDI_CONN_IN_PARAMS_TX(pipe_in)	\
906 	(((struct ipa_wdi3_conn_in_params *)(pipe_in))->tx)
907 #define __QDF_IPA_WDI_CONN_IN_PARAMS_RX(pipe_in)	\
908 	(((struct ipa_wdi3_conn_in_params *)(pipe_in))->rx)
909 
910 /**
911  * __qdf_ipa_wdi_conn_out_params_t - information provided
912  *				to WLAN druver
913  */
914 typedef struct ipa_wdi3_conn_out_params  __qdf_ipa_wdi_conn_out_params_t;
915 
916 #define __QDF_IPA_WDI_CONN_OUT_PARAMS_TX_UC_DB_PA(pipe_out)	\
917 	(((struct ipa_wdi3_conn_out_params *)(pipe_out))->tx_uc_db_pa)
918 #define __QDF_IPA_WDI_CONN_OUT_PARAMS_TX_UC_DB_VA(pipe_out)	\
919 	(((struct ipa_wdi3_conn_out_params *)(pipe_out))->tx_uc_db_va)
920 #define __QDF_IPA_WDI_CONN_OUT_PARAMS_RX_UC_DB_PA(pipe_out)	\
921 	(((struct ipa_wdi3_conn_out_params *)(pipe_out))->rx_uc_db_pa)
922 
923 /**
924  * __qdf_ipa_wdi_perf_profile_t - To set BandWidth profile
925  */
926 typedef struct ipa_wdi3_perf_profile  __qdf_ipa_wdi_perf_profile_t;
927 
928 #define __QDF_IPA_WDI_PERF_PROFILE_CLIENT(profile)	\
929 	(((struct ipa_wdi3_perf_profile *)(profile))->client)
930 #define __QDF_IPA_WDI_PERF_PROFILE_MAX_SUPPORTED_BW_MBPS(profile)	\
931 	(((struct ipa_wdi3_perf_profile *)(profile))->max_supported_bw_mbps)
932 
933 /**
934  * __qdf_ipa_wdi_reg_intf - Client should call this function to
935  * init WDI3 IPA offload data path
936  *
937  * Note: Should not be called from atomic context and only
938  * after checking IPA readiness using ipa_register_ipa_ready_cb()
939  *
940  * @Return 0 on success, negative on failure
941  */
__qdf_ipa_wdi_reg_intf(struct ipa_wdi3_reg_intf_in_params * in)942 static inline int __qdf_ipa_wdi_reg_intf(
943 	struct ipa_wdi3_reg_intf_in_params *in)
944 {
945 	return ipa_wdi3_reg_intf(in);
946 }
947 
948 /**
949  * __qdf_ipa_wdi_dereg_intf - Client Driver should call this
950  * function to deregister before unload and after disconnect
951  *
952  * @Return 0 on success, negative on failure
953  */
__qdf_ipa_wdi_dereg_intf(const char * netdev_name)954 static inline int __qdf_ipa_wdi_dereg_intf(const char *netdev_name)
955 {
956 	return ipa_wdi3_dereg_intf(netdev_name);
957 }
958 
959 /**
960  * __qdf_ipa_wdi_conn_pipes - Client should call this
961  * function to connect pipes
962  * @in:	[in] input parameters from client
963  * @out: [out] output params to client
964  *
965  * Note: Should not be called from atomic context and only
966  * after checking IPA readiness using ipa_register_ipa_ready_cb()
967  *
968  * @Return 0 on success, negative on failure
969  */
__qdf_ipa_wdi_conn_pipes(struct ipa_wdi3_conn_in_params * in,struct ipa_wdi3_conn_out_params * out)970 static inline int __qdf_ipa_wdi_conn_pipes(struct ipa_wdi3_conn_in_params *in,
971 					   struct ipa_wdi3_conn_out_params *out)
972 {
973 	return ipa_wdi3_conn_pipes(in, out);
974 }
975 
976 /**
977  * __qdf_ipa_wdi_disconn_pipes() - Client should call this
978  *		function to disconnect pipes
979  *
980  * Note: Should not be called from atomic context
981  *
982  * Returns: 0 on success, negative on failure
983  */
__qdf_ipa_wdi_disconn_pipes(__qdf_ipa_wdi_hdl_t hdl)984 static inline int __qdf_ipa_wdi_disconn_pipes(__qdf_ipa_wdi_hdl_t hdl)
985 {
986 	return ipa_wdi3_disconn_pipes_per_inst(hdl);
987 }
988 
989 /**
990  * __qdf_ipa_wdi_enable_pipes() - Client should call this
991  *		function to enable IPA offload data path
992  * @hdl: IPA handle
993  *
994  * Note: Should not be called from atomic context
995  *
996  * Returns: 0 on success, negative on failure
997  */
__qdf_ipa_wdi_enable_pipes(__qdf_ipa_wdi_hdl_t hdl)998 static inline int __qdf_ipa_wdi_enable_pipes(__qdf_ipa_wdi_hdl_t hdl)
999 {
1000 	return ipa_wdi3_enable_pipes_per_inst(hdl);
1001 }
1002 
1003 /**
1004  * __qdf_ipa_wdi_disable_pipes() - Client should call this
1005  *		function to disable IPA offload data path
1006  * @hdl: IPA handle
1007  *
1008  * Note: Should not be called from atomic context
1009  *
1010  * Returns: 0 on success, negative on failure
1011  */
__qdf_ipa_wdi_disable_pipes(__qdf_ipa_wdi_hdl_t hdl)1012 static inline int __qdf_ipa_wdi_disable_pipes(__qdf_ipa_wdi_hdl_t hdl)
1013 {
1014 	return ipa_wdi3_disable_pipes_per_inst(hdl);
1015 }
1016 
1017 /**
1018  * __qdf_ipa_wdi_set_perf_profile() - Client should call this function to
1019  *		set IPA clock bandwidth based on data rates
1020  * @profile: [in] BandWidth profile to use
1021  *
1022  * Returns: 0 on success, negative on failure
1023  */
__qdf_ipa_wdi_set_perf_profile(struct ipa_wdi3_perf_profile * profile)1024 static inline int __qdf_ipa_wdi_set_perf_profile(
1025 			struct ipa_wdi3_perf_profile *profile)
1026 {
1027 	return ipa_wdi3_set_perf_profile(profile);
1028 }
1029 
1030 #endif /* CONFIG_IPA_WDI_UNIFIED_API */
1031 
1032 #endif /* IPA_OFFLOAD */
1033 #endif /* I_QDF_IPA_WDI_H */
1034