]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blob - drivers/net/ipa/ipa_data.h
Merge tag 'xfs-5.10-merge-5' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
[mirror_ubuntu-hirsute-kernel.git] / drivers / net / ipa / ipa_data.h
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 *
84 * The @status_endpoint is only valid if the endpoint's @status_enable
85 * flag is set.
86 */
87 struct ipa_endpoint_tx_data {
88 enum ipa_endpoint_name status_endpoint;
89 };
90
91 /**
92 * struct ipa_endpoint_rx_data - configuration data for RX endpoints
93 * @pad_align: power-of-2 boundary to which packet payload is aligned
94 * @aggr_close_eof: whether aggregation closes on end-of-frame
95 *
96 * With each packet it transfers, the IPA hardware can perform certain
97 * transformations of its packet data. One of these is adding pad bytes
98 * to the end of the packet data so the result ends on a power-of-2 boundary.
99 *
100 * It is also able to aggregate multiple packets into a single receive buffer.
101 * Aggregation is "open" while a buffer is being filled, and "closes" when
102 * certain criteria are met. One of those criteria is the sender indicating
103 * a "frame" consisting of several transfers has ended.
104 */
105 struct ipa_endpoint_rx_data {
106 u32 pad_align;
107 bool aggr_close_eof;
108 };
109
110 /**
111 * struct ipa_endpoint_config_data - IPA endpoint hardware configuration
112 * @checksum: whether checksum offload is enabled
113 * @qmap: whether endpoint uses QMAP protocol
114 * @aggregation: whether endpoint supports aggregation
115 * @status_enable: whether endpoint uses status elements
116 * @dma_mode: whether endpoint operates in DMA mode
117 * @dma_endpoint: peer endpoint, if operating in DMA mode
118 * @tx: TX-specific endpoint information (see above)
119 * @rx: RX-specific endpoint information (see above)
120 */
121 struct ipa_endpoint_config_data {
122 bool checksum;
123 bool qmap;
124 bool aggregation;
125 bool status_enable;
126 bool dma_mode;
127 enum ipa_endpoint_name dma_endpoint;
128 union {
129 struct ipa_endpoint_tx_data tx;
130 struct ipa_endpoint_rx_data rx;
131 };
132 };
133
134 /**
135 * struct ipa_endpoint_data - IPA endpoint configuration data
136 * @filter_support: whether endpoint supports filtering
137 * @seq_type: hardware sequencer type used for endpoint
138 * @config: hardware configuration (see above)
139 *
140 * Not all endpoints support the IPA filtering capability. A filter table
141 * defines the filters to apply for those endpoints that support it. The
142 * AP is responsible for initializing this table, and it must include entries
143 * for non-AP endpoints. For this reason we define *all* endpoints used
144 * in the system, and indicate whether they support filtering.
145 *
146 * The remaining endpoint configuration data applies only to AP endpoints.
147 * The IPA hardware is implemented by sequencers, and the AP must program
148 * the type(s) of these sequencers at initialization time. The remaining
149 * endpoint configuration data is defined above.
150 */
151 struct ipa_endpoint_data {
152 bool filter_support;
153 /* The next two are specified only for AP endpoints */
154 enum ipa_seq_type seq_type;
155 struct ipa_endpoint_config_data config;
156 };
157
158 /**
159 * struct ipa_gsi_endpoint_data - GSI channel/IPA endpoint data
160 * ee: GSI execution environment ID
161 * channel_id: GSI channel ID
162 * endpoint_id: IPA endpoint ID
163 * toward_ipa: direction of data transfer
164 * gsi: GSI channel configuration data (see above)
165 * ipa: IPA endpoint configuration data (see above)
166 */
167 struct ipa_gsi_endpoint_data {
168 u8 ee_id; /* enum gsi_ee_id */
169 u8 channel_id;
170 u8 endpoint_id;
171 bool toward_ipa;
172
173 struct gsi_channel_data channel;
174 struct ipa_endpoint_data endpoint;
175 };
176
177 /** enum ipa_resource_type_src - source resource types */
178 enum ipa_resource_type_src {
179 IPA_RESOURCE_TYPE_SRC_PKT_CONTEXTS,
180 IPA_RESOURCE_TYPE_SRC_DESCRIPTOR_LISTS,
181 IPA_RESOURCE_TYPE_SRC_DESCRIPTOR_BUFF,
182 IPA_RESOURCE_TYPE_SRC_HPS_DMARS,
183 IPA_RESOURCE_TYPE_SRC_ACK_ENTRIES,
184 };
185
186 /** enum ipa_resource_type_dst - destination resource types */
187 enum ipa_resource_type_dst {
188 IPA_RESOURCE_TYPE_DST_DATA_SECTORS,
189 IPA_RESOURCE_TYPE_DST_DPS_DMARS,
190 };
191
192 /**
193 * struct ipa_resource_limits - minimum and maximum resource counts
194 * @min: minimum number of resources of a given type
195 * @max: maximum number of resources of a given type
196 */
197 struct ipa_resource_limits {
198 u32 min;
199 u32 max;
200 };
201
202 /**
203 * struct ipa_resource_src - source endpoint group resource usage
204 * @type: source group resource type
205 * @limits: array of limits to use for each resource group
206 */
207 struct ipa_resource_src {
208 enum ipa_resource_type_src type;
209 struct ipa_resource_limits limits[IPA_RESOURCE_GROUP_COUNT];
210 };
211
212 /**
213 * struct ipa_resource_dst - destination endpoint group resource usage
214 * @type: destination group resource type
215 * @limits: array of limits to use for each resource group
216 */
217 struct ipa_resource_dst {
218 enum ipa_resource_type_dst type;
219 struct ipa_resource_limits limits[IPA_RESOURCE_GROUP_COUNT];
220 };
221
222 /**
223 * struct ipa_resource_data - IPA resource configuration data
224 * @resource_src_count: number of entries in the resource_src array
225 * @resource_src: source endpoint group resources
226 * @resource_dst_count: number of entries in the resource_dst array
227 * @resource_dst: destination endpoint group resources
228 *
229 * In order to manage quality of service between endpoints, certain resources
230 * required for operation are allocated to groups of endpoints. Generally
231 * this information is invisible to the AP, but the AP is responsible for
232 * programming it at initialization time, so we specify it here.
233 */
234 struct ipa_resource_data {
235 u32 resource_src_count;
236 const struct ipa_resource_src *resource_src;
237 u32 resource_dst_count;
238 const struct ipa_resource_dst *resource_dst;
239 };
240
241 /**
242 * struct ipa_mem - description of IPA memory regions
243 * @local_count: number of regions defined in the local[] array
244 * @local: array of IPA-local memory region descriptors
245 * @imem_addr: physical address of IPA region within IMEM
246 * @imem_size: size in bytes of IPA IMEM region
247 * @smem_id: item identifier for IPA region within SMEM memory
248 * @imem_size: size in bytes of the IPA SMEM region
249 */
250 struct ipa_mem_data {
251 u32 local_count;
252 const struct ipa_mem *local;
253 u32 imem_addr;
254 u32 imem_size;
255 u32 smem_id;
256 u32 smem_size;
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 const struct ipa_mem_data *mem_data;
274 };
275
276 extern const struct ipa_data ipa_data_sdm845;
277 extern const struct ipa_data ipa_data_sc7180;
278
279 #endif /* _IPA_DATA_H_ */