blob: aed8c5944e7e466066446d104ea5b516321dbb3c [file] [log] [blame]
Skylar Chang852379b2016-12-13 14:00:19 -08001/* Copyright (c) 2017, 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_WDI3_H_
14#define _IPA_WDI3_H_
15
16#include <linux/ipa.h>
17
18#define IPA_HW_WDI3_TCL_DATA_CMD_ER_DESC_SIZE 32
19#define IPA_HW_WDI3_IPA2FW_ER_DESC_SIZE 8
20
21#define IPA_HW_WDI3_MAX_ER_DESC_SIZE \
22 (((IPA_HW_WDI3_TCL_DATA_CMD_ER_DESC_SIZE) > \
23 (IPA_HW_WDI3_IPA2FW_ER_DESC_SIZE)) ? \
24 (IPA_HW_WDI3_TCL_DATA_CMD_ER_DESC_SIZE) : \
25 (IPA_HW_WDI3_IPA2FW_ER_DESC_SIZE))
26
27/**
28 * struct ipa_wdi3_hdr_info - Header to install on IPA HW
29 *
30 * @hdr: header to install on IPA HW
31 * @hdr_len: length of header
32 * @dst_mac_addr_offset: destination mac address offset
33 * @hdr_type: layer two header type
34 */
35struct ipa_wdi3_hdr_info {
36 u8 *hdr;
37 u8 hdr_len;
38 u8 dst_mac_addr_offset;
39 enum ipa_hdr_l2_type hdr_type;
40};
41
42/**
43 * struct ipa_wdi3_reg_intf_in_params - parameters for uC offload
44 * interface registration
45 *
46 * @netdev_name: network interface name
47 * @hdr_info: header information
48 * @is_meta_data_valid: if meta data is valid
49 * @meta_data: meta data if any
50 * @meta_data_mask: meta data mask
51 */
52struct ipa_wdi3_reg_intf_in_params {
53 const char *netdev_name;
54 struct ipa_wdi3_hdr_info hdr_info[IPA_IP_MAX];
55 u8 is_meta_data_valid;
56 u32 meta_data;
57 u32 meta_data_mask;
58};
59
60/**
61 * struct ipa_wdi3_setup_info - WDI3 TX/Rx configuration
62 * @ipa_ep_cfg: ipa endpoint configuration
63 * @client: type of "client"
64 * @transfer_ring_base_pa: physical address of the base of the transfer ring
65 * @transfer_ring_size: size of the transfer ring
66 * @transfer_ring_doorbell_pa: physical address of the doorbell that
67 IPA uC will update the tailpointer of the transfer ring
68 * @event_ring_base_pa: physical address of the base of the event ring
69 * @event_ring_size: event ring size
70 * @event_ring_doorbell_pa: physical address of the doorbell that IPA uC
71 will update the headpointer of the event ring
72 * @num_pkt_buffers: Number of pkt buffers allocated. The size of the event
73 ring and the transfer ring has to be atleast ( num_pkt_buffers + 1)
74 * @pkt_offset: packet offset (wdi3 header length)
75 * @desc_format_template[IPA_HW_WDI3_MAX_ER_DESC_SIZE]: Holds a cached
76 template of the desc format
77 */
78struct ipa_wdi3_setup_info {
79 struct ipa_ep_cfg ipa_ep_cfg;
80 enum ipa_client_type client;
81 dma_addr_t transfer_ring_base_pa;
82 u32 transfer_ring_size;
83 dma_addr_t transfer_ring_doorbell_pa;
84
85 dma_addr_t event_ring_base_pa;
86 u32 event_ring_size;
87 dma_addr_t event_ring_doorbell_pa;
88 u16 num_pkt_buffers;
89
90 u16 pkt_offset;
91
92 u32 desc_format_template[IPA_HW_WDI3_MAX_ER_DESC_SIZE];
93};
94
95/**
96 * struct ipa_wdi3_conn_in_params - information provided by
97 * uC offload client
98 * @notify: client callback function
99 * @priv: client cookie
100 * @tx: parameters to connect TX pipe(from IPA to WLAN)
101 * @rx: parameters to connect RX pipe(from WLAN to IPA)
102 */
103struct ipa_wdi3_conn_in_params {
104 ipa_notify_cb notify;
105 void *priv;
106 struct ipa_wdi3_setup_info tx;
107 struct ipa_wdi3_setup_info rx;
108};
109
110/**
111 * struct ipa_wdi3_conn_out_params - information provided
112 * to WLAN driver
113 * @tx_uc_db_pa: physical address of IPA uC doorbell for TX
114 * @tx_uc_db_va: virtual address of IPA uC doorbell for TX
115 * @rx_uc_db_pa: physical address of IPA uC doorbell for RX
116 */
117struct ipa_wdi3_conn_out_params {
118 dma_addr_t tx_uc_db_pa;
119 void __iomem *tx_uc_db_va;
120 dma_addr_t rx_uc_db_pa;
121};
122
123/**
124 * struct ipa_wdi3_perf_profile - To set BandWidth profile
125 *
126 * @client: type of client
127 * @max_supported_bw_mbps: maximum bandwidth needed (in Mbps)
128 */
129struct ipa_wdi3_perf_profile {
130 enum ipa_client_type client;
131 u32 max_supported_bw_mbps;
132};
133
134#if defined CONFIG_IPA || defined CONFIG_IPA3
135
136/**
137 * ipa_wdi3_reg_intf - Client should call this function to
138 * init WDI3 IPA offload data path
139 *
140 * Note: Should not be called from atomic context and only
141 * after checking IPA readiness using ipa_register_ipa_ready_cb()
142 *
143 * @Return 0 on success, negative on failure
144 */
145int ipa_wdi3_reg_intf(
146 struct ipa_wdi3_reg_intf_in_params *in);
147
148/**
149 * ipa_wdi3_dereg_intf - Client Driver should call this
150 * function to deregister before unload and after disconnect
151 *
152 * @Return 0 on success, negative on failure
153 */
154int ipa_wdi3_dereg_intf(const char *netdev_name);
155
156/**
157 * ipa_wdi3_conn_pipes - Client should call this
158 * function to connect pipes
159 *
160 * @in: [in] input parameters from client
161 * @out: [out] output params to client
162 *
163 * Note: Should not be called from atomic context and only
164 * after checking IPA readiness using ipa_register_ipa_ready_cb()
165 *
166 * @Return 0 on success, negative on failure
167 */
168int ipa_wdi3_conn_pipes(struct ipa_wdi3_conn_in_params *in,
169 struct ipa_wdi3_conn_out_params *out);
170
171/**
172 * ipa_wdi3_disconn_pipes() - Client should call this
173 * function to disconnect pipes
174 *
175 * Note: Should not be called from atomic context
176 *
177 * Returns: 0 on success, negative on failure
178 */
179int ipa_wdi3_disconn_pipes(void);
180
181/**
182 * ipa_wdi3_enable_pipes() - Client should call this
183 * function to enable IPA offload data path
184 *
185 * Note: Should not be called from atomic context
186 *
187 * Returns: 0 on success, negative on failure
188 */
189int ipa_wdi3_enable_pipes(void);
190
191/**
192 * ipa_wdi3_disable_pipes() - Client should call this
193 * function to disable IPA offload data path
194 *
195 * Note: Should not be called from atomic context
196 *
197 * Returns: 0 on success, negative on failure
198 */
199int ipa_wdi3_disable_pipes(void);
200
201/**
202 * ipa_wdi3_set_perf_profile() - Client should call this function to
203 * set IPA clock bandwidth based on data rates
204 *
205 * @profile: [in] BandWidth profile to use
206 *
207 * Returns: 0 on success, negative on failure
208 */
209int ipa_wdi3_set_perf_profile(struct ipa_wdi3_perf_profile *profile);
210
211
212#else /* (CONFIG_IPA || CONFIG_IPA3) */
213
214static inline int ipa_wdi3_reg_intf(
215 struct ipa_wdi3_reg_intf_in_params *in)
216{
217 return -EPERM;
218}
219
220static inline int ipa_wdi3_dereg_intf(const char *netdev_name)
221{
222 return -EPERM;
223}
224
225static inline int ipa_wdi3_conn_pipes(struct ipa_wdi3_conn_in_params *in,
226 struct ipa_wdi3_conn_out_params *out)
227{
228 return -EPERM;
229}
230
231static inline int ipa_wdi3_disconn_pipes(void)
232{
233 return -EPERM;
234}
235
236static inline int ipa_wdi3_enable_pipes(void)
237{
238 return -EPERM;
239}
240
241static inline int ipa_wdi3_disable_pipes(void)
242{
243 return -EPERM;
244}
245
246static inline int ipa_wdi3_set_perf_profile(
247 struct ipa_wdi3_perf_profile *profile)
248{
249 return -EPERM;
250}
251
252#endif /* CONFIG_IPA3 */
253
254#endif /* _IPA_WDI3_H_ */