blob: 0277e87a2570b93563c646120ef9dc44be7857d6 [file] [log] [blame]
Amir Levy9659e592016-10-27 18:08:27 +03001/* Copyright (c) 2016, The Linux Foundation. All rights reserved.
2 *
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
166#if defined CONFIG_IPA || defined CONFIG_IPA3
167
168/**
169 * ipa_uc_offload_reg_intf - Client should call this function to
170 * init uC offload data path
171 *
172 * @init: [in] initialization parameters
173 *
174 * Note: Should not be called from atomic context and only
175 * after checking IPA readiness using ipa_register_ipa_ready_cb()
176 *
177 * @Return 0 on success, negative on failure
178 */
179int ipa_uc_offload_reg_intf(
180 struct ipa_uc_offload_intf_params *in,
181 struct ipa_uc_offload_out_params *out);
182
183/**
184 * ipa_uc_offload_cleanup - Client Driver should call this
185 * function before unload and after disconnect
186 *
187 * @Return 0 on success, negative on failure
188 */
189int ipa_uc_offload_cleanup(u32 clnt_hdl);
190
191/**
192 * ipa_uc_offload_conn_pipes - Client should call this
193 * function to connect uC pipe for offload data path
194 *
195 * @in: [in] input parameters from client
196 * @out: [out] output params to client
197 *
198 * Note: Should not be called from atomic context and only
199 * after checking IPA readiness using ipa_register_ipa_ready_cb()
200 *
201 * @Return 0 on success, negative on failure
202 */
203int ipa_uc_offload_conn_pipes(struct ipa_uc_offload_conn_in_params *in,
204 struct ipa_uc_offload_conn_out_params *out);
205
206/**
207 * ipa_uc_offload_disconn_pipes() - Client should call this
208 * function to disconnect uC pipe to disable offload data path
209 * @clnt_hdl: [in] opaque client handle assigned by IPA to client
210 *
211 * Note: Should not be called from atomic context
212 *
213 * Returns: 0 on success, negative on failure
214 */
215int ipa_uc_offload_disconn_pipes(u32 clnt_hdl);
216
217/**
218 * ipa_set_perf_profile() - Client should call this function to
219 * set IPA clock Band Width based on data rates
220 * @profile: [in] BandWidth profile to use
221 *
222 * Returns: 0 on success, negative on failure
223 */
224int ipa_set_perf_profile(struct ipa_perf_profile *profile);
225
226#else /* (CONFIG_IPA || CONFIG_IPA3) */
227
228static inline int ipa_uc_offload_reg_intf(
229 struct ipa_uc_offload_intf_params *in,
230 struct ipa_uc_offload_out_params *out)
231{
232 return -EPERM;
233}
234
235static inline int ipa_uC_offload_cleanup(u32 clnt_hdl)
236{
237 return -EPERM;
238}
239
240static inline int ipa_uc_offload_conn_pipes(
241 struct ipa_uc_offload_conn_in_params *in,
242 struct ipa_uc_offload_conn_out_params *out)
243{
244 return -EPERM;
245}
246
247static inline int ipa_uc_offload_disconn_pipes(u32 clnt_hdl)
248{
249 return -EPERM;
250}
251
252static inline int ipa_set_perf_profile(struct ipa_perf_profile *profile)
253{
254 return -EPERM;
255}
256
257#endif /* CONFIG_IPA3 */
258
259#endif /* _IPA_UC_OFFLOAD_H_ */