summaryrefslogtreecommitdiffstats
path: root/drivers/net/ipa/ipa_data.h
blob: 0ed5ffe2b8da0eea2fb1cbfdafa6a19bd5d07abb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
/* SPDX-License-Identifier: GPL-2.0 */

/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
 * Copyright (C) 2019-2020 Linaro Ltd.
 */
#ifndef _IPA_DATA_H_
#define _IPA_DATA_H_

#include <linux/types.h>

#include "ipa_version.h"
#include "ipa_endpoint.h"
#include "ipa_mem.h"

/**
 * DOC: IPA/GSI Configuration Data
 *
 * Boot-time configuration data is used to define the configuration of the
 * IPA and GSI resources to use for a given platform.  This data is supplied
 * via the Device Tree match table, associated with a particular compatible
 * string.  The data defines information about resources, endpoints, and
 * channels.
 *
 * Resources are data structures used internally by the IPA hardware.  The
 * configuration data defines the number (or limits of the number) of various
 * types of these resources.
 *
 * Endpoint configuration data defines properties of both IPA endpoints and
 * GSI channels.  A channel is a GSI construct, and represents a single
 * communication path between the IPA and a particular execution environment
 * (EE), such as the AP or Modem.  Each EE has a set of channels associated
 * with it, and each channel has an ID unique for that EE.  For the most part
 * the only GSI channels of concern to this driver belong to the AP
 *
 * An endpoint is an IPA construct representing a single channel anywhere
 * in the system.  An IPA endpoint ID maps directly to an (EE, channel_id)
 * pair.  Generally, this driver is concerned with only endpoints associated
 * with the AP, however this will change when support for routing (etc.) is
 * added.  IPA endpoint and GSI channel configuration data are defined
 * together, establishing the endpoint_id->(EE, channel_id) mapping.
 *
 * Endpoint configuration data consists of three parts:  properties that
 * are common to IPA and GSI (EE ID, channel ID, endpoint ID, and direction);
 * properties associated with the GSI channel; and properties associated with
 * the IPA endpoint.
 */

/* The maximum value returned by ipa_resource_group_{src,dst}_count() */
#define IPA_RESOURCE_GROUP_SRC_MAX	5
#define IPA_RESOURCE_GROUP_DST_MAX	5

/**
 * struct gsi_channel_data - GSI channel configuration data
 * @tre_count:		number of TREs in the channel ring
 * @event_count:	number of slots in the associated event ring
 * @tlv_count:		number of entries in channel's TLV FIFO
 *
 * A GSI channel is a unidirectional means of transferring data to or
 * from (and through) the IPA.  A GSI channel has a ring buffer made
 * up of "transfer elements" (TREs) that specify individual data transfers
 * or IPA immediate commands.  TREs are filled by the AP, and control
 * is passed to IPA hardware by writing the last written element
 * into a doorbell register.
 *
 * When data transfer commands have completed the GSI generates an
 * event (a structure of data) and optionally signals the AP with
 * an interrupt.  Event structures are implemented by another ring
 * buffer, directed toward the AP from the IPA.
 *
 * The input to a GSI channel is a FIFO of type/length/value (TLV)
 * elements, and the size of this FIFO limits the number of TREs
 * that can be included in a single transaction.
 */
struct gsi_channel_data {
	u16 tre_count;
	u16 event_count;
	u8 tlv_count;
};

/**
 * struct ipa_endpoint_tx_data - configuration data for TX endpoints
 * @status_endpoint:	endpoint to which status elements are sent
 *
 * The @status_endpoint is only valid if the endpoint's @status_enable
 * flag is set.
 */
struct ipa_endpoint_tx_data {
	enum ipa_endpoint_name status_endpoint;
};

/**
 * struct ipa_endpoint_rx_data - configuration data for RX endpoints
 * @pad_align:	power-of-2 boundary to which packet payload is aligned
 * @aggr_close_eof: whether aggregation closes on end-of-frame
 *
 * With each packet it transfers, the IPA hardware can perform certain
 * transformations of its packet data.  One of these is adding pad bytes
 * to the end of the packet data so the result ends on a power-of-2 boundary.
 *
 * It is also able to aggregate multiple packets into a single receive buffer.
 * Aggregation is "open" while a buffer is being filled, and "closes" when
 * certain criteria are met.  One of those criteria is the sender indicating
 * a "frame" consisting of several transfers has ended.
 */
struct ipa_endpoint_rx_data {
	u32 pad_align;
	bool aggr_close_eof;
};

/**
 * struct ipa_endpoint_config_data - IPA endpoint hardware configuration
 * @resource_group:	resource group to assign endpoint to
 * @checksum:		whether checksum offload is enabled
 * @qmap:		whether endpoint uses QMAP protocol
 * @aggregation:	whether endpoint supports aggregation
 * @status_enable:	whether endpoint uses status elements
 * @dma_mode:		whether endpoint operates in DMA mode
 * @dma_endpoint:	peer endpoint, if operating in DMA mode
 * @tx:			TX-specific endpoint information (see above)
 * @rx:			RX-specific endpoint information (see above)
 */
struct ipa_endpoint_config_data {
	u32 resource_group;
	bool checksum;
	bool qmap;
	bool aggregation;
	bool status_enable;
	bool dma_mode;
	enum ipa_endpoint_name dma_endpoint;
	union {
		struct ipa_endpoint_tx_data tx;
		struct ipa_endpoint_rx_data rx;
	};
};

/**
 * struct ipa_endpoint_data - IPA endpoint configuration data
 * @filter_support:	whether endpoint supports filtering
 * @seq_type:		hardware sequencer type used for endpoint
 * @config:		hardware configuration (see above)
 *
 * Not all endpoints support the IPA filtering capability.  A filter table
 * defines the filters to apply for those endpoints that support it.  The
 * AP is responsible for initializing this table, and it must include entries
 * for non-AP endpoints.  For this reason we define *all* endpoints used
 * in the system, and indicate whether they support filtering.
 *
 * The remaining endpoint configuration data applies only to AP endpoints.
 * The IPA hardware is implemented by sequencers, and the AP must program
 * the type(s) of these sequencers at initialization time.  The remaining
 * endpoint configuration data is defined above.
 */
struct ipa_endpoint_data {
	bool filter_support;
	/* The next two are specified only for AP endpoints */
	enum ipa_seq_type seq_type;
	struct ipa_endpoint_config_data config;
};

/**
 * struct ipa_gsi_endpoint_data - GSI channel/IPA endpoint data
 * ee:		GSI execution environment ID
 * channel_id:	GSI channel ID
 * endpoint_id:	IPA endpoint ID
 * toward_ipa:	direction of data transfer
 * gsi:		GSI channel configuration data (see above)
 * ipa:		IPA endpoint configuration data (see above)
 */
struct ipa_gsi_endpoint_data {
	u8 ee_id;		/* enum gsi_ee_id */
	u8 channel_id;
	u8 endpoint_id;
	bool toward_ipa;

	struct gsi_channel_data channel;
	struct ipa_endpoint_data endpoint;
};

/** enum ipa_resource_type_src - source resource types */
enum ipa_resource_type_src {
	IPA_RESOURCE_TYPE_SRC_PKT_CONTEXTS,
	IPA_RESOURCE_TYPE_SRC_DESCRIPTOR_LISTS,
	IPA_RESOURCE_TYPE_SRC_DESCRIPTOR_BUFF,
	IPA_RESOURCE_TYPE_SRC_HPS_DMARS,
	IPA_RESOURCE_TYPE_SRC_ACK_ENTRIES,
};

/** enum ipa_resource_type_dst - destination resource types */
enum ipa_resource_type_dst {
	IPA_RESOURCE_TYPE_DST_DATA_SECTORS,
	IPA_RESOURCE_TYPE_DST_DPS_DMARS,
};

/**
 * struct ipa_resource_limits - minimum and maximum resource counts
 * @min:	minimum number of resources of a given type
 * @max:	maximum number of resources of a given type
 */
struct ipa_resource_limits {
	u32 min;
	u32 max;
};

/**
 * struct ipa_resource_src - source endpoint group resource usage
 * @type:	source group resource type
 * @limits:	array of limits to use for each resource group
 */
struct ipa_resource_src {
	enum ipa_resource_type_src type;
	struct ipa_resource_limits limits[IPA_RESOURCE_GROUP_SRC_MAX];
};

/**
 * struct ipa_resource_dst - destination endpoint group resource usage
 * @type:	destination group resource type
 * @limits:	array of limits to use for each resource group
 */
struct ipa_resource_dst {
	enum ipa_resource_type_dst type;
	struct ipa_resource_limits limits[IPA_RESOURCE_GROUP_DST_MAX];
};

/**
 * struct ipa_resource_data - IPA resource configuration data
 * @resource_src_count:	number of entries in the resource_src array
 * @resource_src:	source endpoint group resources
 * @resource_dst_count:	number of entries in the resource_dst array
 * @resource_dst:	destination endpoint group resources
 *
 * In order to manage quality of service between endpoints, certain resources
 * required for operation are allocated to groups of endpoints.  Generally
 * this information is invisible to the AP, but the AP is responsible for
 * programming it at initialization time, so we specify it here.
 */
struct ipa_resource_data {
	u32 resource_src_count;
	const struct ipa_resource_src *resource_src;
	u32 resource_dst_count;
	const struct ipa_resource_dst *resource_dst;
};

/**
 * struct ipa_mem_data - description of IPA memory regions
 * @local_count:	number of regions defined in the local[] array
 * @local:		array of IPA-local memory region descriptors
 * @imem_addr:		physical address of IPA region within IMEM
 * @imem_size:		size in bytes of IPA IMEM region
 * @smem_id:		item identifier for IPA region within SMEM memory
 * @imem_size:		size in bytes of the IPA SMEM region
 */
struct ipa_mem_data {
	u32 local_count;
	const struct ipa_mem *local;
	u32 imem_addr;
	u32 imem_size;
	u32 smem_id;
	u32 smem_size;
};

/** enum ipa_interconnect_id - IPA interconnect identifier */
enum ipa_interconnect_id {
	IPA_INTERCONNECT_MEMORY,
	IPA_INTERCONNECT_IMEM,
	IPA_INTERCONNECT_CONFIG,
	IPA_INTERCONNECT_COUNT,		/* Last; not an interconnect */
};

/**
 * struct ipa_interconnect_data - description of IPA interconnect rates
 * @peak_rate:		Peak interconnect bandwidth (in 1000 byte/sec units)
 * @average_rate:	Average interconnect bandwidth (in 1000 byte/sec units)
 */
struct ipa_interconnect_data {
	u32 peak_rate;
	u32 average_rate;
};

/**
 * struct ipa_clock_data - description of IPA clock and interconnect rates
 * @core_clock_rate:	Core clock rate (Hz)
 * @interconnect:	Array of interconnect bandwidth parameters
 */
struct ipa_clock_data {
	u32 core_clock_rate;
	struct ipa_interconnect_data interconnect[IPA_INTERCONNECT_COUNT];
};

/**
 * struct ipa_data - combined IPA/GSI configuration data
 * @version:		IPA hardware version
 * @endpoint_count:	number of entries in endpoint_data array
 * @endpoint_data:	IPA endpoint/GSI channel data
 * @resource_data:	IPA resource configuration data
 * @mem_count:		number of entries in mem_data array
 * @mem_data:		IPA-local shared memory region data
 */
struct ipa_data {
	enum ipa_version version;
	u32 endpoint_count;	/* # entries in endpoint_data[] */
	const struct ipa_gsi_endpoint_data *endpoint_data;
	const struct ipa_resource_data *resource_data;
	const struct ipa_mem_data *mem_data;
	const struct ipa_clock_data *clock_data;
};

extern const struct ipa_data ipa_data_sdm845;
extern const struct ipa_data ipa_data_sc7180;

#endif /* _IPA_DATA_H_ */