1 /* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
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.
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.
13 #ifndef _IPA_UC_OFFLOAD_H_
14 #define _IPA_UC_OFFLOAD_H_
16 #include <linux/ipa.h>
19 * enum ipa_uc_offload_proto
20 * Protocol type: either WDI or Neutrino
22 * @IPA_UC_WDI: wdi Protocol
23 * @IPA_UC_NTN: Neutrino Protocol
25 enum ipa_uc_offload_proto {
33 * struct ipa_hdr_info - Header to install on IPA HW
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
43 u8 dst_mac_addr_offset;
44 enum ipa_hdr_l2_type hdr_type;
48 * struct ipa_uc_offload_intf_params - parameters for uC offload
49 * interface registration
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
60 struct ipa_uc_offload_intf_params {
61 const char *netdev_name;
64 struct ipa_hdr_info hdr_info[IPA_IP_MAX];
65 u8 is_meta_data_valid;
68 enum ipa_uc_offload_proto proto;
69 enum ipa_client_type alt_dst_pipe;
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
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
84 struct ipa_ntn_setup_info {
85 enum ipa_client_type client;
86 phys_addr_t ring_base_pa;
89 phys_addr_t buff_pool_base_pa;
93 phys_addr_t ntn_reg_base_ptr_pa;
97 * struct ipa_uc_offload_out_params - out parameters for uC offload
99 * @clnt_hndl: Handle that client need to pass during
102 struct ipa_uc_offload_out_params {
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)
111 struct ipa_ntn_conn_in_params {
112 struct ipa_ntn_setup_info ul;
113 struct ipa_ntn_setup_info dl;
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
123 struct ipa_ntn_conn_out_params {
124 phys_addr_t ul_uc_db_pa;
125 phys_addr_t dl_uc_db_pa;
129 * struct ipa_uc_offload_conn_in_params - information provided by
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
135 struct ipa_uc_offload_conn_in_params {
138 struct ipa_ntn_conn_in_params ntn;
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
149 struct ipa_uc_offload_conn_out_params {
151 struct ipa_ntn_conn_out_params ntn;
156 * struct ipa_perf_profile - To set BandWidth profile
158 * @client: type of "client" (IPA_CLIENT_ODU#_PROD/CONS)
159 * @max_supported_bw_mbps: maximum bandwidth needed (in Mbps)
161 struct ipa_perf_profile {
162 enum ipa_client_type client;
163 u32 max_supported_bw_mbps;
167 * struct ipa_uc_ready_params - uC ready CB parameters
168 * @is_uC_ready: uC loaded or not
169 * @priv : callback cookie
171 * @proto: uC offload protocol type
173 struct ipa_uc_ready_params {
176 ipa_uc_ready_cb notify;
177 enum ipa_uc_offload_proto proto;
180 #if defined CONFIG_IPA || defined CONFIG_IPA3
183 * ipa_uc_offload_reg_intf - Client should call this function to
184 * init uC offload data path
186 * @init: [in] initialization parameters
188 * Note: Should not be called from atomic context and only
189 * after checking IPA readiness using ipa_register_ipa_ready_cb()
191 * @Return 0 on success, negative on failure
193 int ipa_uc_offload_reg_intf(
194 struct ipa_uc_offload_intf_params *in,
195 struct ipa_uc_offload_out_params *out);
198 * ipa_uc_offload_cleanup - Client Driver should call this
199 * function before unload and after disconnect
201 * @Return 0 on success, negative on failure
203 int ipa_uc_offload_cleanup(u32 clnt_hdl);
206 * ipa_uc_offload_conn_pipes - Client should call this
207 * function to connect uC pipe for offload data path
209 * @in: [in] input parameters from client
210 * @out: [out] output params to client
212 * Note: Should not be called from atomic context and only
213 * after checking IPA readiness using ipa_register_ipa_ready_cb()
215 * @Return 0 on success, negative on failure
217 int ipa_uc_offload_conn_pipes(struct ipa_uc_offload_conn_in_params *in,
218 struct ipa_uc_offload_conn_out_params *out);
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
225 * Note: Should not be called from atomic context
227 * Returns: 0 on success, negative on failure
229 int ipa_uc_offload_disconn_pipes(u32 clnt_hdl);
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
236 * Returns: 0 on success, negative on failure
238 int ipa_set_perf_profile(struct ipa_perf_profile *profile);
242 * To register uC ready callback if uC not ready
243 * and also check uC readiness
244 * if uC not ready only, register callback
246 int ipa_uc_offload_reg_rdyCB(struct ipa_uc_ready_params *param);
249 * To de-register uC ready callback
251 void ipa_uc_offload_dereg_rdyCB(enum ipa_uc_offload_proto proto);
253 #else /* (CONFIG_IPA || CONFIG_IPA3) */
255 static inline int ipa_uc_offload_reg_intf(
256 struct ipa_uc_offload_intf_params *in,
257 struct ipa_uc_offload_out_params *out)
262 static inline int ipa_uC_offload_cleanup(u32 clnt_hdl)
267 static 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)
274 static inline int ipa_uc_offload_disconn_pipes(u32 clnt_hdl)
279 static inline int ipa_set_perf_profile(struct ipa_perf_profile *profile)
284 static inline int ipa_uc_offload_reg_rdyCB(struct ipa_uc_ready_params *param)
289 static void ipa_uc_offload_dereg_rdyCB(enum ipa_uc_offload_proto proto)
293 #endif /* CONFIG_IPA3 */
295 #endif /* _IPA_UC_OFFLOAD_H_ */