xref: /linux-6.15/drivers/net/ipa/ipa_data.h (revision 4bcfb35e)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
4  * Copyright (C) 2019-2021 Linaro Ltd.
5  */
6 #ifndef _IPA_DATA_H_
7 #define _IPA_DATA_H_
8 
9 #include <linux/types.h>
10 
11 #include "ipa_version.h"
12 #include "ipa_endpoint.h"
13 #include "ipa_mem.h"
14 
15 /**
16  * DOC: IPA/GSI Configuration Data
17  *
18  * Boot-time configuration data is used to define the configuration of the
19  * IPA and GSI resources to use for a given platform.  This data is supplied
20  * via the Device Tree match table, associated with a particular compatible
21  * string.  The data defines information about how resources, endpoints and
22  * channels, memory, clocking and so on are allocated and used for the
23  * platform.
24  *
25  * Resources are data structures used internally by the IPA hardware.  The
26  * configuration data defines the number (or limits of the number) of various
27  * types of these resources.
28  *
29  * Endpoint configuration data defines properties of both IPA endpoints and
30  * GSI channels.  A channel is a GSI construct, and represents a single
31  * communication path between the IPA and a particular execution environment
32  * (EE), such as the AP or Modem.  Each EE has a set of channels associated
33  * with it, and each channel has an ID unique for that EE.  For the most part
34  * the only GSI channels of concern to this driver belong to the AP
35  *
36  * An endpoint is an IPA construct representing a single channel anywhere
37  * in the system.  An IPA endpoint ID maps directly to an (EE, channel_id)
38  * pair.  Generally, this driver is concerned with only endpoints associated
39  * with the AP, however this will change when support for routing (etc.) is
40  * added.  IPA endpoint and GSI channel configuration data are defined
41  * together, establishing the endpoint_id->(EE, channel_id) mapping.
42  *
43  * Endpoint configuration data consists of three parts:  properties that
44  * are common to IPA and GSI (EE ID, channel ID, endpoint ID, and direction);
45  * properties associated with the GSI channel; and properties associated with
46  * the IPA endpoint.
47  */
48 
49 /* The maximum value returned by ipa_resource_group_{src,dst}_count() */
50 #define IPA_RESOURCE_GROUP_SRC_MAX	5
51 #define IPA_RESOURCE_GROUP_DST_MAX	5
52 
53 /** enum ipa_qsb_master_id - array index for IPA QSB configuration data */
54 enum ipa_qsb_master_id {
55 	IPA_QSB_MASTER_DDR,
56 	IPA_QSB_MASTER_PCIE,
57 };
58 
59 /**
60  * struct ipa_qsb_data - Qualcomm System Bus configuration data
61  * @max_writes:	Maximum outstanding write requests for this master
62  * @max_reads:	Maximum outstanding read requests for this master
63  * @max_reads_beats: Max outstanding read bytes in 8-byte "beats" (if non-zero)
64  */
65 struct ipa_qsb_data {
66 	u8 max_writes;
67 	u8 max_reads;
68 	u8 max_reads_beats;		/* Not present for IPA v3.5.1 */
69 };
70 
71 /**
72  * struct gsi_channel_data - GSI channel configuration data
73  * @tre_count:		number of TREs in the channel ring
74  * @event_count:	number of slots in the associated event ring
75  * @tlv_count:		number of entries in channel's TLV FIFO
76  *
77  * A GSI channel is a unidirectional means of transferring data to or
78  * from (and through) the IPA.  A GSI channel has a ring buffer made
79  * up of "transfer ring elements" (TREs) that specify individual data
80  * transfers or IPA immediate commands.  TREs are filled by the AP,
81  * and control is passed to IPA hardware by writing the last written
82  * element into a doorbell register.
83  *
84  * When data transfer commands have completed the GSI generates an
85  * event (a structure of data) and optionally signals the AP with
86  * an interrupt.  Event structures are implemented by another ring
87  * buffer, directed toward the AP from the IPA.
88  *
89  * The input to a GSI channel is a FIFO of type/length/value (TLV)
90  * elements, and the size of this FIFO limits the number of TREs
91  * that can be included in a single transaction.
92  */
93 struct gsi_channel_data {
94 	u16 tre_count;
95 	u16 event_count;
96 	u8 tlv_count;
97 };
98 
99 /**
100  * struct ipa_endpoint_tx_data - configuration data for TX endpoints
101  * @seq_type:		primary packet processing sequencer type
102  * @seq_rep_type:	sequencer type for replication processing
103  * @status_endpoint:	endpoint to which status elements are sent
104  *
105  * The @status_endpoint is only valid if the endpoint's @status_enable
106  * flag is set.
107  */
108 struct ipa_endpoint_tx_data {
109 	enum ipa_seq_type seq_type;
110 	enum ipa_seq_rep_type seq_rep_type;
111 	enum ipa_endpoint_name status_endpoint;
112 };
113 
114 /**
115  * struct ipa_endpoint_rx_data - configuration data for RX endpoints
116  * @pad_align:	power-of-2 boundary to which packet payload is aligned
117  * @aggr_close_eof: whether aggregation closes on end-of-frame
118  *
119  * With each packet it transfers, the IPA hardware can perform certain
120  * transformations of its packet data.  One of these is adding pad bytes
121  * to the end of the packet data so the result ends on a power-of-2 boundary.
122  *
123  * It is also able to aggregate multiple packets into a single receive buffer.
124  * Aggregation is "open" while a buffer is being filled, and "closes" when
125  * certain criteria are met.  One of those criteria is the sender indicating
126  * a "frame" consisting of several transfers has ended.
127  */
128 struct ipa_endpoint_rx_data {
129 	u32 pad_align;
130 	bool aggr_close_eof;
131 };
132 
133 /**
134  * struct ipa_endpoint_config_data - IPA endpoint hardware configuration
135  * @resource_group:	resource group to assign endpoint to
136  * @checksum:		whether checksum offload is enabled
137  * @qmap:		whether endpoint uses QMAP protocol
138  * @aggregation:	whether endpoint supports aggregation
139  * @status_enable:	whether endpoint uses status elements
140  * @dma_mode:		whether endpoint operates in DMA mode
141  * @dma_endpoint:	peer endpoint, if operating in DMA mode
142  * @tx:			TX-specific endpoint information (see above)
143  * @rx:			RX-specific endpoint information (see above)
144  */
145 struct ipa_endpoint_config_data {
146 	u32 resource_group;
147 	bool checksum;
148 	bool qmap;
149 	bool aggregation;
150 	bool status_enable;
151 	bool dma_mode;
152 	enum ipa_endpoint_name dma_endpoint;
153 	union {
154 		struct ipa_endpoint_tx_data tx;
155 		struct ipa_endpoint_rx_data rx;
156 	};
157 };
158 
159 /**
160  * struct ipa_endpoint_data - IPA endpoint configuration data
161  * @filter_support:	whether endpoint supports filtering
162  * @config:		hardware configuration (see above)
163  *
164  * Not all endpoints support the IPA filtering capability.  A filter table
165  * defines the filters to apply for those endpoints that support it.  The
166  * AP is responsible for initializing this table, and it must include entries
167  * for non-AP endpoints.  For this reason we define *all* endpoints used
168  * in the system, and indicate whether they support filtering.
169  *
170  * The remaining endpoint configuration data applies only to AP endpoints.
171  */
172 struct ipa_endpoint_data {
173 	bool filter_support;
174 	/* Everything else is specified only for AP endpoints */
175 	struct ipa_endpoint_config_data config;
176 };
177 
178 /**
179  * struct ipa_gsi_endpoint_data - GSI channel/IPA endpoint data
180  * @ee_id:	GSI execution environment ID
181  * @channel_id:	GSI channel ID
182  * @endpoint_id: IPA endpoint ID
183  * @toward_ipa:	direction of data transfer
184  * @channel:	GSI channel configuration data (see above)
185  * @endpoint:	IPA endpoint configuration data (see above)
186  */
187 struct ipa_gsi_endpoint_data {
188 	u8 ee_id;		/* enum gsi_ee_id */
189 	u8 channel_id;
190 	u8 endpoint_id;
191 	bool toward_ipa;
192 
193 	struct gsi_channel_data channel;
194 	struct ipa_endpoint_data endpoint;
195 };
196 
197 /** enum ipa_resource_type - IPA resource types */
198 enum ipa_resource_type {
199 	/* Source resource types; first must have value 0 */
200 	IPA_RESOURCE_TYPE_SRC_PKT_CONTEXTS		= 0,
201 	IPA_RESOURCE_TYPE_SRC_DESCRIPTOR_LISTS,
202 	IPA_RESOURCE_TYPE_SRC_DESCRIPTOR_BUFF,
203 	IPA_RESOURCE_TYPE_SRC_HPS_DMARS,
204 	IPA_RESOURCE_TYPE_SRC_ACK_ENTRIES,
205 
206 	/* Destination resource types; first must have value 0 */
207 	IPA_RESOURCE_TYPE_DST_DATA_SECTORS		= 0,
208 	IPA_RESOURCE_TYPE_DST_DPS_DMARS,
209 };
210 
211 /**
212  * struct ipa_resource_limits - minimum and maximum resource counts
213  * @min:	minimum number of resources of a given type
214  * @max:	maximum number of resources of a given type
215  */
216 struct ipa_resource_limits {
217 	u32 min;
218 	u32 max;
219 };
220 
221 /**
222  * struct ipa_resource_src - source endpoint group resource usage
223  * @limits:	array of limits to use for each resource group
224  */
225 struct ipa_resource_src {
226 	struct ipa_resource_limits limits[IPA_RESOURCE_GROUP_SRC_MAX];
227 };
228 
229 /**
230  * struct ipa_resource_dst - destination endpoint group resource usage
231  * @limits:	array of limits to use for each resource group
232  */
233 struct ipa_resource_dst {
234 	struct ipa_resource_limits limits[IPA_RESOURCE_GROUP_DST_MAX];
235 };
236 
237 /**
238  * struct ipa_resource_data - IPA resource configuration data
239  * @resource_src_count:	number of entries in the resource_src array
240  * @resource_src:	source endpoint group resources
241  * @resource_dst_count:	number of entries in the resource_dst array
242  * @resource_dst:	destination endpoint group resources
243  *
244  * In order to manage quality of service between endpoints, certain resources
245  * required for operation are allocated to groups of endpoints.  Generally
246  * this information is invisible to the AP, but the AP is responsible for
247  * programming it at initialization time, so we specify it here.
248  */
249 struct ipa_resource_data {
250 	u32 resource_src_count;
251 	const struct ipa_resource_src *resource_src;
252 	u32 resource_dst_count;
253 	const struct ipa_resource_dst *resource_dst;
254 };
255 
256 /**
257  * struct ipa_mem_data - description of IPA memory regions
258  * @local_count:	number of regions defined in the local[] array
259  * @local:		array of IPA-local memory region descriptors
260  * @imem_addr:		physical address of IPA region within IMEM
261  * @imem_size:		size in bytes of IPA IMEM region
262  * @smem_id:		item identifier for IPA region within SMEM memory
263  * @smem_size:		size in bytes of the IPA SMEM region
264  */
265 struct ipa_mem_data {
266 	u32 local_count;
267 	const struct ipa_mem *local;
268 	u32 imem_addr;
269 	u32 imem_size;
270 	u32 smem_id;
271 	u32 smem_size;
272 };
273 
274 /**
275  * struct ipa_interconnect_data - description of IPA interconnect bandwidths
276  * @name:		Interconnect name (matches interconnect-name in DT)
277  * @peak_bandwidth:	Peak interconnect bandwidth (in 1000 byte/sec units)
278  * @average_bandwidth:	Average interconnect bandwidth (in 1000 byte/sec units)
279  */
280 struct ipa_interconnect_data {
281 	const char *name;
282 	u32 peak_bandwidth;
283 	u32 average_bandwidth;
284 };
285 
286 /**
287  * struct ipa_clock_data - description of IPA clock and interconnect rates
288  * @core_clock_rate:	Core clock rate (Hz)
289  * @interconnect_count:	Number of entries in the interconnect_data array
290  * @interconnect_data:	IPA interconnect configuration data
291  */
292 struct ipa_clock_data {
293 	u32 core_clock_rate;
294 	u32 interconnect_count;		/* # entries in interconnect_data[] */
295 	const struct ipa_interconnect_data *interconnect_data;
296 };
297 
298 /**
299  * struct ipa_data - combined IPA/GSI configuration data
300  * @version:		IPA hardware version
301  * @qsb_count:		number of entries in the qsb_data array
302  * @qsb_data:		Qualcomm System Bus configuration data
303  * @endpoint_count:	number of entries in the endpoint_data array
304  * @endpoint_data:	IPA endpoint/GSI channel data
305  * @resource_data:	IPA resource configuration data
306  * @mem_data:		IPA memory region data
307  * @clock_data:		IPA clock and interconnect data
308  */
309 struct ipa_data {
310 	enum ipa_version version;
311 	u32 qsb_count;		/* number of entries in qsb_data[] */
312 	const struct ipa_qsb_data *qsb_data;
313 	u32 endpoint_count;	/* number of entries in endpoint_data[] */
314 	const struct ipa_gsi_endpoint_data *endpoint_data;
315 	const struct ipa_resource_data *resource_data;
316 	const struct ipa_mem_data *mem_data;
317 	const struct ipa_clock_data *clock_data;
318 };
319 
320 extern const struct ipa_data ipa_data_sdm845;
321 extern const struct ipa_data ipa_data_sc7180;
322 
323 #endif /* _IPA_DATA_H_ */
324