xref: /openbmc/linux/drivers/net/ipa/ipa_data.h (revision b58c6630)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
4  * Copyright (C) 2019-2020 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 resources, endpoints, and
22  * channels.
23  *
24  * Resources are data structures used internally by the IPA hardware.  The
25  * configuration data defines the number (or limits of the number) of various
26  * types of these resources.
27  *
28  * Endpoint configuration data defines properties of both IPA endpoints and
29  * GSI channels.  A channel is a GSI construct, and represents a single
30  * communication path between the IPA and a particular execution environment
31  * (EE), such as the AP or Modem.  Each EE has a set of channels associated
32  * with it, and each channel has an ID unique for that EE.  For the most part
33  * the only GSI channels of concern to this driver belong to the AP
34  *
35  * An endpoint is an IPA construct representing a single channel anywhere
36  * in the system.  An IPA endpoint ID maps directly to an (EE, channel_id)
37  * pair.  Generally, this driver is concerned with only endpoints associated
38  * with the AP, however this will change when support for routing (etc.) is
39  * added.  IPA endpoint and GSI channel configuration data are defined
40  * together, establishing the endpoint_id->(EE, channel_id) mapping.
41  *
42  * Endpoint configuration data consists of three parts:  properties that
43  * are common to IPA and GSI (EE ID, channel ID, endpoint ID, and direction);
44  * properties associated with the GSI channel; and properties associated with
45  * the IPA endpoint.
46  */
47 
48 /* The maximum value returned by ipa_resource_group_count() */
49 #define IPA_RESOURCE_GROUP_COUNT	4
50 
51 /** enum ipa_resource_type_src - source resource types */
52 /**
53  * struct gsi_channel_data - GSI channel configuration data
54  * @tre_count:		number of TREs in the channel ring
55  * @event_count:	number of slots in the associated event ring
56  * @tlv_count:		number of entries in channel's TLV FIFO
57  *
58  * A GSI channel is a unidirectional means of transferring data to or
59  * from (and through) the IPA.  A GSI channel has a ring buffer made
60  * up of "transfer elements" (TREs) that specify individual data transfers
61  * or IPA immediate commands.  TREs are filled by the AP, and control
62  * is passed to IPA hardware by writing the last written element
63  * into a doorbell register.
64  *
65  * When data transfer commands have completed the GSI generates an
66  * event (a structure of data) and optionally signals the AP with
67  * an interrupt.  Event structures are implemented by another ring
68  * buffer, directed toward the AP from the IPA.
69  *
70  * The input to a GSI channel is a FIFO of type/length/value (TLV)
71  * elements, and the size of this FIFO limits the number of TREs
72  * that can be included in a single transaction.
73  */
74 struct gsi_channel_data {
75 	u16 tre_count;
76 	u16 event_count;
77 	u8 tlv_count;
78 };
79 
80 /**
81  * struct ipa_endpoint_tx_data - configuration data for TX endpoints
82  * @status_endpoint:	endpoint to which status elements are sent
83  * @delay:		whether endpoint starts in delay mode
84  *
85  * Delay mode prevents a TX endpoint from transmitting anything, even if
86  * commands have been presented to the hardware.  Once the endpoint exits
87  * delay mode, queued transfer commands are sent.
88  *
89  * The @status_endpoint is only valid if the endpoint's @status_enable
90  * flag is set.
91  */
92 struct ipa_endpoint_tx_data {
93 	enum ipa_endpoint_name status_endpoint;
94 	bool delay;
95 };
96 
97 /**
98  * struct ipa_endpoint_rx_data - configuration data for RX endpoints
99  * @pad_align:	power-of-2 boundary to which packet payload is aligned
100  * @aggr_close_eof: whether aggregation closes on end-of-frame
101  *
102  * With each packet it transfers, the IPA hardware can perform certain
103  * transformations of its packet data.  One of these is adding pad bytes
104  * to the end of the packet data so the result ends on a power-of-2 boundary.
105  *
106  * It is also able to aggregate multiple packets into a single receive buffer.
107  * Aggregation is "open" while a buffer is being filled, and "closes" when
108  * certain criteria are met.  One of those criteria is the sender indicating
109  * a "frame" consisting of several transfers has ended.
110  */
111 struct ipa_endpoint_rx_data {
112 	u32 pad_align;
113 	bool aggr_close_eof;
114 };
115 
116 /**
117  * struct ipa_endpoint_config_data - IPA endpoint hardware configuration
118  * @checksum:		whether checksum offload is enabled
119  * @qmap:		whether endpoint uses QMAP protocol
120  * @aggregation:	whether endpoint supports aggregation
121  * @status_enable:	whether endpoint uses status elements
122  * @dma_mode:		whether endpoint operates in DMA mode
123  * @dma_endpoint:	peer endpoint, if operating in DMA mode
124  * @tx:			TX-specific endpoint information (see above)
125  * @rx:			RX-specific endpoint information (see above)
126  */
127 struct ipa_endpoint_config_data {
128 	bool checksum;
129 	bool qmap;
130 	bool aggregation;
131 	bool status_enable;
132 	bool dma_mode;
133 	enum ipa_endpoint_name dma_endpoint;
134 	union {
135 		struct ipa_endpoint_tx_data tx;
136 		struct ipa_endpoint_rx_data rx;
137 	};
138 };
139 
140 /**
141  * struct ipa_endpoint_data - IPA endpoint configuration data
142  * @filter_support:	whether endpoint supports filtering
143  * @seq_type:		hardware sequencer type used for endpoint
144  * @config:		hardware configuration (see above)
145  *
146  * Not all endpoints support the IPA filtering capability.  A filter table
147  * defines the filters to apply for those endpoints that support it.  The
148  * AP is responsible for initializing this table, and it must include entries
149  * for non-AP endpoints.  For this reason we define *all* endpoints used
150  * in the system, and indicate whether they support filtering.
151  *
152  * The remaining endpoint configuration data applies only to AP endpoints.
153  * The IPA hardware is implemented by sequencers, and the AP must program
154  * the type(s) of these sequencers at initialization time.  The remaining
155  * endpoint configuration data is defined above.
156  */
157 struct ipa_endpoint_data {
158 	bool filter_support;
159 	/* The next two are specified only for AP endpoints */
160 	enum ipa_seq_type seq_type;
161 	struct ipa_endpoint_config_data config;
162 };
163 
164 /**
165  * struct ipa_gsi_endpoint_data - GSI channel/IPA endpoint data
166  * ee:		GSI execution environment ID
167  * channel_id:	GSI channel ID
168  * endpoint_id:	IPA endpoint ID
169  * toward_ipa:	direction of data transfer
170  * gsi:		GSI channel configuration data (see above)
171  * ipa:		IPA endpoint configuration data (see above)
172  */
173 struct ipa_gsi_endpoint_data {
174 	u8 ee_id;		/* enum gsi_ee_id */
175 	u8 channel_id;
176 	u8 endpoint_id;
177 	bool toward_ipa;
178 
179 	struct gsi_channel_data channel;
180 	struct ipa_endpoint_data endpoint;
181 };
182 
183 /** enum ipa_resource_type_src - source resource types */
184 enum ipa_resource_type_src {
185 	IPA_RESOURCE_TYPE_SRC_PKT_CONTEXTS,
186 	IPA_RESOURCE_TYPE_SRC_DESCRIPTOR_LISTS,
187 	IPA_RESOURCE_TYPE_SRC_DESCRIPTOR_BUFF,
188 	IPA_RESOURCE_TYPE_SRC_HPS_DMARS,
189 	IPA_RESOURCE_TYPE_SRC_ACK_ENTRIES,
190 };
191 
192 /** enum ipa_resource_type_dst - destination resource types */
193 enum ipa_resource_type_dst {
194 	IPA_RESOURCE_TYPE_DST_DATA_SECTORS,
195 	IPA_RESOURCE_TYPE_DST_DPS_DMARS,
196 };
197 
198 /**
199  * struct ipa_resource_limits - minimum and maximum resource counts
200  * @min:	minimum number of resources of a given type
201  * @max:	maximum number of resources of a given type
202  */
203 struct ipa_resource_limits {
204 	u32 min;
205 	u32 max;
206 };
207 
208 /**
209  * struct ipa_resource_src - source endpoint group resource usage
210  * @type:	source group resource type
211  * @limits:	array of limits to use for each resource group
212  */
213 struct ipa_resource_src {
214 	enum ipa_resource_type_src type;
215 	struct ipa_resource_limits limits[IPA_RESOURCE_GROUP_COUNT];
216 };
217 
218 /**
219  * struct ipa_resource_dst - destination endpoint group resource usage
220  * @type:	destination group resource type
221  * @limits:	array of limits to use for each resource group
222  */
223 struct ipa_resource_dst {
224 	enum ipa_resource_type_dst type;
225 	struct ipa_resource_limits limits[IPA_RESOURCE_GROUP_COUNT];
226 };
227 
228 /**
229  * struct ipa_resource_data - IPA resource configuration data
230  * @resource_src_count:	number of entries in the resource_src array
231  * @resource_src:	source endpoint group resources
232  * @resource_dst_count:	number of entries in the resource_dst array
233  * @resource_dst:	destination endpoint group resources
234  *
235  * In order to manage quality of service between endpoints, certain resources
236  * required for operation are allocated to groups of endpoints.  Generally
237  * this information is invisible to the AP, but the AP is responsible for
238  * programming it at initialization time, so we specify it here.
239  */
240 struct ipa_resource_data {
241 	u32 resource_src_count;
242 	const struct ipa_resource_src *resource_src;
243 	u32 resource_dst_count;
244 	const struct ipa_resource_dst *resource_dst;
245 };
246 
247 /**
248  * struct ipa_mem - IPA-local memory region description
249  * @offset:		offset in IPA memory space to base of the region
250  * @size:		size in bytes base of the region
251  * @canary_count:	number of 32-bit "canary" values that precede region
252  */
253 struct ipa_mem_data {
254 	u32 offset;
255 	u16 size;
256 	u16 canary_count;
257 };
258 
259 /**
260  * struct ipa_data - combined IPA/GSI configuration data
261  * @version:		IPA hardware version
262  * @endpoint_count:	number of entries in endpoint_data array
263  * @endpoint_data:	IPA endpoint/GSI channel data
264  * @resource_data:	IPA resource configuration data
265  * @mem_count:		number of entries in mem_data array
266  * @mem_data:		IPA-local shared memory region data
267  */
268 struct ipa_data {
269 	enum ipa_version version;
270 	u32 endpoint_count;	/* # entries in endpoint_data[] */
271 	const struct ipa_gsi_endpoint_data *endpoint_data;
272 	const struct ipa_resource_data *resource_data;
273 	u32 mem_count;		/* # entries in mem_data[] */
274 	const struct ipa_mem *mem_data;
275 };
276 
277 extern const struct ipa_data ipa_data_sdm845;
278 extern const struct ipa_data ipa_data_sc7180;
279 
280 #endif /* _IPA_DATA_H_ */
281