blob: 85d0ce92e6f6a0118372039a771727751d72475f [file] [log] [blame]
Sunil Paidimarrifbbcd072017-04-04 17:43:50 -07001/* Copyright (c) 2016-2017, 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/**
73 * struct ipa_ntn_setup_info - NTN TX/Rx configuration
74 * @client: type of "client" (IPA_CLIENT_ODU#_PROD/CONS)
75 * @ring_base_pa: physical address of the base of the Tx/Rx ring
76 * @ntn_ring_size: size of the Tx/Rx ring (in terms of elements)
77 * @buff_pool_base_pa: physical address of the base of the Tx/Rx
78 * buffer pool
79 * @num_buffers: Rx/Tx buffer pool size (in terms of elements)
80 * @data_buff_size: size of the each data buffer allocated in DDR
81 * @ntn_reg_base_ptr_pa: physical address of the Tx/Rx NTN Ring's
82 * tail pointer
83 */
84struct ipa_ntn_setup_info {
85 enum ipa_client_type client;
86 phys_addr_t ring_base_pa;
87 u32 ntn_ring_size;
88
89 phys_addr_t buff_pool_base_pa;
90 u32 num_buffers;
91 u32 data_buff_size;
92
93 phys_addr_t ntn_reg_base_ptr_pa;
94};
95
96/**
97 * struct ipa_uc_offload_out_params - out parameters for uC offload
98 *
99 * @clnt_hndl: Handle that client need to pass during
100 * further operations
101 */
102struct ipa_uc_offload_out_params {
103 u32 clnt_hndl;
104};
105
106/**
107 * struct ipa_ntn_conn_in_params - NTN TX/Rx connect parameters
108 * @ul: parameters to connect UL pipe(from Neutrino to IPA)
109 * @dl: parameters to connect DL pipe(from IPA to Neutrino)
110 */
111struct ipa_ntn_conn_in_params {
112 struct ipa_ntn_setup_info ul;
113 struct ipa_ntn_setup_info dl;
114};
115
116/**
117 * struct ipa_ntn_conn_out_params - information provided
118 * to uC offload client
119 * @ul_uc_db_pa: physical address of IPA uc doorbell for UL
120 * @dl_uc_db_pa: physical address of IPA uc doorbell for DL
121 * @clnt_hdl: opaque handle assigned to offload client
122 */
123struct ipa_ntn_conn_out_params {
124 phys_addr_t ul_uc_db_pa;
125 phys_addr_t dl_uc_db_pa;
126};
127
128/**
129 * struct ipa_uc_offload_conn_in_params - information provided by
130 * uC offload client
131 * @clnt_hndl: Handle that return as part of reg interface
132 * @proto: Protocol to use for offload data path
133 * @ntn: uC RX/Tx configuration info
134 */
135struct ipa_uc_offload_conn_in_params {
136 u32 clnt_hndl;
137 union {
138 struct ipa_ntn_conn_in_params ntn;
139 } u;
140};
141
142/**
143 * struct ipa_uc_offload_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_uc_offload_conn_out_params {
150 union {
151 struct ipa_ntn_conn_out_params ntn;
152 } u;
153};
154
155/**
156 * struct ipa_perf_profile - To set BandWidth profile
157 *
158 * @client: type of "client" (IPA_CLIENT_ODU#_PROD/CONS)
159 * @max_supported_bw_mbps: maximum bandwidth needed (in Mbps)
160 */
161struct ipa_perf_profile {
162 enum ipa_client_type client;
163 u32 max_supported_bw_mbps;
164};
165
Sunil Paidimarrifbbcd072017-04-04 17:43:50 -0700166/**
167 * struct ipa_uc_ready_params - uC ready CB parameters
168 * @is_uC_ready: uC loaded or not
169 * @priv : callback cookie
170 * @notify: callback
171 * @proto: uC offload protocol type
172 */
173struct ipa_uc_ready_params {
174 bool is_uC_ready;
175 void *priv;
176 ipa_uc_ready_cb notify;
177 enum ipa_uc_offload_proto proto;
178};
179
Amir Levy9659e592016-10-27 18:08:27 +0300180#if defined CONFIG_IPA || defined CONFIG_IPA3
181
182/**
183 * ipa_uc_offload_reg_intf - Client should call this function to
184 * init uC offload data path
185 *
186 * @init: [in] initialization parameters
187 *
188 * Note: Should not be called from atomic context and only
189 * after checking IPA readiness using ipa_register_ipa_ready_cb()
190 *
191 * @Return 0 on success, negative on failure
192 */
193int ipa_uc_offload_reg_intf(
194 struct ipa_uc_offload_intf_params *in,
195 struct ipa_uc_offload_out_params *out);
196
197/**
198 * ipa_uc_offload_cleanup - Client Driver should call this
199 * function before unload and after disconnect
200 *
201 * @Return 0 on success, negative on failure
202 */
203int ipa_uc_offload_cleanup(u32 clnt_hdl);
204
205/**
206 * ipa_uc_offload_conn_pipes - Client should call this
207 * function to connect uC pipe for offload data path
208 *
209 * @in: [in] input parameters from client
210 * @out: [out] output params to client
211 *
212 * Note: Should not be called from atomic context and only
213 * after checking IPA readiness using ipa_register_ipa_ready_cb()
214 *
215 * @Return 0 on success, negative on failure
216 */
217int ipa_uc_offload_conn_pipes(struct ipa_uc_offload_conn_in_params *in,
218 struct ipa_uc_offload_conn_out_params *out);
219
220/**
221 * ipa_uc_offload_disconn_pipes() - Client should call this
222 * function to disconnect uC pipe to disable offload data path
223 * @clnt_hdl: [in] opaque client handle assigned by IPA to client
224 *
225 * Note: Should not be called from atomic context
226 *
227 * Returns: 0 on success, negative on failure
228 */
229int ipa_uc_offload_disconn_pipes(u32 clnt_hdl);
230
231/**
232 * ipa_set_perf_profile() - Client should call this function to
233 * set IPA clock Band Width based on data rates
234 * @profile: [in] BandWidth profile to use
235 *
236 * Returns: 0 on success, negative on failure
237 */
238int ipa_set_perf_profile(struct ipa_perf_profile *profile);
239
Sunil Paidimarrifbbcd072017-04-04 17:43:50 -0700240
241/*
242 * To register uC ready callback if uC not ready
243 * and also check uC readiness
244 * if uC not ready only, register callback
245 */
246int ipa_uc_offload_reg_rdyCB(struct ipa_uc_ready_params *param);
247
248/*
249 * To de-register uC ready callback
250 */
251void ipa_uc_offload_dereg_rdyCB(enum ipa_uc_offload_proto proto);
252
Amir Levy9659e592016-10-27 18:08:27 +0300253#else /* (CONFIG_IPA || CONFIG_IPA3) */
254
255static inline int ipa_uc_offload_reg_intf(
256 struct ipa_uc_offload_intf_params *in,
257 struct ipa_uc_offload_out_params *out)
258{
259 return -EPERM;
260}
261
262static inline int ipa_uC_offload_cleanup(u32 clnt_hdl)
263{
264 return -EPERM;
265}
266
267static inline int ipa_uc_offload_conn_pipes(
268 struct ipa_uc_offload_conn_in_params *in,
269 struct ipa_uc_offload_conn_out_params *out)
270{
271 return -EPERM;
272}
273
274static inline int ipa_uc_offload_disconn_pipes(u32 clnt_hdl)
275{
276 return -EPERM;
277}
278
279static inline int ipa_set_perf_profile(struct ipa_perf_profile *profile)
280{
281 return -EPERM;
282}
283
Sunil Paidimarrifbbcd072017-04-04 17:43:50 -0700284static inline int ipa_uc_offload_reg_rdyCB(struct ipa_uc_ready_params *param)
285{
286 return -EPERM;
287}
288
289static void ipa_uc_offload_dereg_rdyCB(enum ipa_uc_offload_proto proto)
290{
291}
292
Amir Levy9659e592016-10-27 18:08:27 +0300293#endif /* CONFIG_IPA3 */
294
295#endif /* _IPA_UC_OFFLOAD_H_ */