blob: 94d8a8a2a34aee756dab59e545366f5579e67ab8 [file] [log] [blame]
Michael Adisumartab1bafa42018-04-16 16:48:10 -07001/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
Amir Levy9659e592016-10-27 18:08:27 +03002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef _IPA_UC_OFFLOAD_H_
14#define _IPA_UC_OFFLOAD_H_
15
16#include <linux/ipa.h>
17
18/**
19 * enum ipa_uc_offload_proto
20 * Protocol type: either WDI or Neutrino
21 *
22 * @IPA_UC_WDI: wdi Protocol
23 * @IPA_UC_NTN: Neutrino Protocol
24 */
25enum ipa_uc_offload_proto {
26 IPA_UC_INVALID = 0,
27 IPA_UC_WDI = 1,
28 IPA_UC_NTN = 2,
29 IPA_UC_MAX_PROT_SIZE
30};
31
32/**
33 * struct ipa_hdr_info - Header to install on IPA HW
34 *
35 * @hdr: header to install on IPA HW
36 * @hdr_len: length of header
37 * @dst_mac_addr_offset: destination mac address offset
38 * @hdr_type: layer two header type
39 */
40struct ipa_hdr_info {
41 u8 *hdr;
42 u8 hdr_len;
43 u8 dst_mac_addr_offset;
44 enum ipa_hdr_l2_type hdr_type;
45};
46
47/**
48 * struct ipa_uc_offload_intf_params - parameters for uC offload
49 * interface registration
50 *
51 * @netdev_name: network interface name
52 * @notify: callback for exception/embedded packets
53 * @priv: callback cookie
54 * @hdr_info: header information
55 * @meta_data: meta data if any
56 * @meta_data_mask: meta data mask
57 * @proto: uC offload protocol type
58 * @alt_dst_pipe: alternate routing output pipe
59 */
60struct ipa_uc_offload_intf_params {
61 const char *netdev_name;
62 ipa_notify_cb notify;
63 void *priv;
64 struct ipa_hdr_info hdr_info[IPA_IP_MAX];
65 u8 is_meta_data_valid;
66 u32 meta_data;
67 u32 meta_data_mask;
68 enum ipa_uc_offload_proto proto;
69 enum ipa_client_type alt_dst_pipe;
70};
71
72/**
Michael Adisumartab1bafa42018-04-16 16:48:10 -070073 * struct ntn_buff_smmu_map - IPA iova->pa SMMU mapping
74 * @iova: virtual address of the data buffer
75 * @pa: physical address of the data buffer
76 */
77struct ntn_buff_smmu_map {
78 dma_addr_t iova;
79 phys_addr_t pa;
80};
81
82/**
Amir Levy9659e592016-10-27 18:08:27 +030083 * struct ipa_ntn_setup_info - NTN TX/Rx configuration
84 * @client: type of "client" (IPA_CLIENT_ODU#_PROD/CONS)
Michael Adisumartab1bafa42018-04-16 16:48:10 -070085 * @smmu_enabled: SMMU is enabled for uC or not
Amir Levy9659e592016-10-27 18:08:27 +030086 * @ring_base_pa: physical address of the base of the Tx/Rx ring
Michael Adisumartab1bafa42018-04-16 16:48:10 -070087 * @ring_base_iova: virtual address of the base of the Tx/Rx ring
88 * @ring_base_sgt:Scatter table for ntn_rings,contains valid non NULL
89 * value when ENAC S1-SMMU enabed, else NULL.
Amir Levy9659e592016-10-27 18:08:27 +030090 * @ntn_ring_size: size of the Tx/Rx ring (in terms of elements)
Michael Adisumartab1bafa42018-04-16 16:48:10 -070091 * @buff_pool_base_pa: physical address of the base of the Tx/Rx buffer pool
92 * @buff_pool_base_iova: virtual address of the base of the Tx/Rx buffer pool
93 * @buff_pool_base_sgt: Scatter table for buffer pools,contains valid non NULL
94 * value when EMAC S1-SMMU enabed, else NULL.
Amir Levy9659e592016-10-27 18:08:27 +030095 * @num_buffers: Rx/Tx buffer pool size (in terms of elements)
96 * @data_buff_size: size of the each data buffer allocated in DDR
97 * @ntn_reg_base_ptr_pa: physical address of the Tx/Rx NTN Ring's
98 * tail pointer
99 */
100struct ipa_ntn_setup_info {
101 enum ipa_client_type client;
Michael Adisumartab1bafa42018-04-16 16:48:10 -0700102 bool smmu_enabled;
Amir Levy9659e592016-10-27 18:08:27 +0300103 phys_addr_t ring_base_pa;
Michael Adisumartab1bafa42018-04-16 16:48:10 -0700104 dma_addr_t ring_base_iova;
105 struct sg_table *ring_base_sgt;
106
Amir Levy9659e592016-10-27 18:08:27 +0300107 u32 ntn_ring_size;
108
109 phys_addr_t buff_pool_base_pa;
Michael Adisumartab1bafa42018-04-16 16:48:10 -0700110 dma_addr_t buff_pool_base_iova;
111 struct sg_table *buff_pool_base_sgt;
112
113 struct ntn_buff_smmu_map *data_buff_list;
114
Amir Levy9659e592016-10-27 18:08:27 +0300115 u32 num_buffers;
Michael Adisumartab1bafa42018-04-16 16:48:10 -0700116
Amir Levy9659e592016-10-27 18:08:27 +0300117 u32 data_buff_size;
118
119 phys_addr_t ntn_reg_base_ptr_pa;
120};
121
122/**
123 * struct ipa_uc_offload_out_params - out parameters for uC offload
124 *
125 * @clnt_hndl: Handle that client need to pass during
126 * further operations
127 */
128struct ipa_uc_offload_out_params {
129 u32 clnt_hndl;
130};
131
132/**
133 * struct ipa_ntn_conn_in_params - NTN TX/Rx connect parameters
134 * @ul: parameters to connect UL pipe(from Neutrino to IPA)
135 * @dl: parameters to connect DL pipe(from IPA to Neutrino)
136 */
137struct ipa_ntn_conn_in_params {
138 struct ipa_ntn_setup_info ul;
139 struct ipa_ntn_setup_info dl;
140};
141
142/**
143 * struct ipa_ntn_conn_out_params - information provided
144 * to uC offload client
145 * @ul_uc_db_pa: physical address of IPA uc doorbell for UL
146 * @dl_uc_db_pa: physical address of IPA uc doorbell for DL
147 * @clnt_hdl: opaque handle assigned to offload client
148 */
149struct ipa_ntn_conn_out_params {
150 phys_addr_t ul_uc_db_pa;
151 phys_addr_t dl_uc_db_pa;
152};
153
154/**
155 * struct ipa_uc_offload_conn_in_params - information provided by
156 * uC offload client
157 * @clnt_hndl: Handle that return as part of reg interface
158 * @proto: Protocol to use for offload data path
159 * @ntn: uC RX/Tx configuration info
160 */
161struct ipa_uc_offload_conn_in_params {
162 u32 clnt_hndl;
163 union {
164 struct ipa_ntn_conn_in_params ntn;
165 } u;
166};
167
168/**
169 * struct ipa_uc_offload_conn_out_params - information provided
170 * to uC offload client
171 * @ul_uc_db_pa: physical address of IPA uc doorbell for UL
172 * @dl_uc_db_pa: physical address of IPA uc doorbell for DL
173 * @clnt_hdl: opaque handle assigned to offload client
174 */
175struct ipa_uc_offload_conn_out_params {
176 union {
177 struct ipa_ntn_conn_out_params ntn;
178 } u;
179};
180
181/**
182 * struct ipa_perf_profile - To set BandWidth profile
183 *
184 * @client: type of "client" (IPA_CLIENT_ODU#_PROD/CONS)
185 * @max_supported_bw_mbps: maximum bandwidth needed (in Mbps)
186 */
187struct ipa_perf_profile {
188 enum ipa_client_type client;
189 u32 max_supported_bw_mbps;
190};
191
Sunil Paidimarrifbbcd072017-04-04 17:43:50 -0700192/**
193 * struct ipa_uc_ready_params - uC ready CB parameters
194 * @is_uC_ready: uC loaded or not
195 * @priv : callback cookie
196 * @notify: callback
197 * @proto: uC offload protocol type
198 */
199struct ipa_uc_ready_params {
200 bool is_uC_ready;
201 void *priv;
202 ipa_uc_ready_cb notify;
203 enum ipa_uc_offload_proto proto;
204};
205
Amir Levy9659e592016-10-27 18:08:27 +0300206#if defined CONFIG_IPA || defined CONFIG_IPA3
207
208/**
209 * ipa_uc_offload_reg_intf - Client should call this function to
210 * init uC offload data path
211 *
212 * @init: [in] initialization parameters
213 *
214 * Note: Should not be called from atomic context and only
215 * after checking IPA readiness using ipa_register_ipa_ready_cb()
216 *
217 * @Return 0 on success, negative on failure
218 */
219int ipa_uc_offload_reg_intf(
220 struct ipa_uc_offload_intf_params *in,
221 struct ipa_uc_offload_out_params *out);
222
223/**
224 * ipa_uc_offload_cleanup - Client Driver should call this
225 * function before unload and after disconnect
226 *
227 * @Return 0 on success, negative on failure
228 */
229int ipa_uc_offload_cleanup(u32 clnt_hdl);
230
231/**
232 * ipa_uc_offload_conn_pipes - Client should call this
233 * function to connect uC pipe for offload data path
234 *
235 * @in: [in] input parameters from client
236 * @out: [out] output params to client
237 *
238 * Note: Should not be called from atomic context and only
239 * after checking IPA readiness using ipa_register_ipa_ready_cb()
240 *
241 * @Return 0 on success, negative on failure
242 */
243int ipa_uc_offload_conn_pipes(struct ipa_uc_offload_conn_in_params *in,
244 struct ipa_uc_offload_conn_out_params *out);
245
246/**
247 * ipa_uc_offload_disconn_pipes() - Client should call this
248 * function to disconnect uC pipe to disable offload data path
249 * @clnt_hdl: [in] opaque client handle assigned by IPA to client
250 *
251 * Note: Should not be called from atomic context
252 *
253 * Returns: 0 on success, negative on failure
254 */
255int ipa_uc_offload_disconn_pipes(u32 clnt_hdl);
256
257/**
258 * ipa_set_perf_profile() - Client should call this function to
259 * set IPA clock Band Width based on data rates
260 * @profile: [in] BandWidth profile to use
261 *
262 * Returns: 0 on success, negative on failure
263 */
264int ipa_set_perf_profile(struct ipa_perf_profile *profile);
265
Sunil Paidimarrifbbcd072017-04-04 17:43:50 -0700266
267/*
268 * To register uC ready callback if uC not ready
269 * and also check uC readiness
270 * if uC not ready only, register callback
271 */
272int ipa_uc_offload_reg_rdyCB(struct ipa_uc_ready_params *param);
273
274/*
275 * To de-register uC ready callback
276 */
277void ipa_uc_offload_dereg_rdyCB(enum ipa_uc_offload_proto proto);
278
Amir Levy9659e592016-10-27 18:08:27 +0300279#else /* (CONFIG_IPA || CONFIG_IPA3) */
280
281static inline int ipa_uc_offload_reg_intf(
282 struct ipa_uc_offload_intf_params *in,
283 struct ipa_uc_offload_out_params *out)
284{
285 return -EPERM;
286}
287
288static inline int ipa_uC_offload_cleanup(u32 clnt_hdl)
289{
290 return -EPERM;
291}
292
293static inline int ipa_uc_offload_conn_pipes(
294 struct ipa_uc_offload_conn_in_params *in,
295 struct ipa_uc_offload_conn_out_params *out)
296{
297 return -EPERM;
298}
299
300static inline int ipa_uc_offload_disconn_pipes(u32 clnt_hdl)
301{
302 return -EPERM;
303}
304
305static inline int ipa_set_perf_profile(struct ipa_perf_profile *profile)
306{
307 return -EPERM;
308}
309
Sunil Paidimarrifbbcd072017-04-04 17:43:50 -0700310static inline int ipa_uc_offload_reg_rdyCB(struct ipa_uc_ready_params *param)
311{
312 return -EPERM;
313}
314
315static void ipa_uc_offload_dereg_rdyCB(enum ipa_uc_offload_proto proto)
316{
317}
318
Amir Levy9659e592016-10-27 18:08:27 +0300319#endif /* CONFIG_IPA3 */
320
321#endif /* _IPA_UC_OFFLOAD_H_ */