1 /* Copyright 2013-2015 Freescale Semiconductor Inc.
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are met:
5 * * Redistributions of source code must retain the above copyright
6 * notice, this list of conditions and the following disclaimer.
7 * * Redistributions in binary form must reproduce the above copyright
8 * notice, this list of conditions and the following disclaimer in the
9 * documentation and/or other materials provided with the distribution.
10 * * Neither the name of the above-listed copyright holders nor the
11 * names of any contributors may be used to endorse or promote products
12 * derived from this software without specific prior written permission.
15 * ALTERNATIVELY, this software may be distributed under the terms of the
16 * GNU General Public License ("GPL") as published by the Free Software
17 * Foundation, either version 2 of that License or (at your option) any
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
37 /* Data Path Resource Container API
38 * Contains DPRC API for managing and querying DPAA resources
44 * Set this value as the icid value in dprc_cfg structure when creating a
45 * container, in case the ICID is not selected by the user and should be
46 * allocated by the DPRC from the pool of ICIDs.
48 #define DPRC_GET_ICID_FROM_POOL (u16)(~(0))
51 * Set this value as the portal_id value in dprc_cfg structure when creating a
52 * container, in case the portal ID is not specifically selected by the
53 * user and should be allocated by the DPRC from the pool of portal ids.
55 #define DPRC_GET_PORTAL_ID_FROM_POOL (int)(~(0))
57 int dprc_open(struct fsl_mc_io *mc_io,
62 int dprc_close(struct fsl_mc_io *mc_io,
67 * Container general options
69 * These options may be selected at container creation by the container creator
70 * and can be retrieved using dprc_get_attributes()
73 /* Spawn Policy Option allowed - Indicates that the new container is allowed
74 * to spawn and have its own child containers.
76 #define DPRC_CFG_OPT_SPAWN_ALLOWED 0x00000001
78 /* General Container allocation policy - Indicates that the new container is
79 * allowed to allocate requested resources from its parent container; if not
80 * set, the container is only allowed to use resources in its own pools; Note
81 * that this is a container's global policy, but the parent container may
82 * override it and set specific quota per resource type.
84 #define DPRC_CFG_OPT_ALLOC_ALLOWED 0x00000002
86 /* Object initialization allowed - software context associated with this
87 * container is allowed to invoke object initialization operations.
89 #define DPRC_CFG_OPT_OBJ_CREATE_ALLOWED 0x00000004
91 /* Topology change allowed - software context associated with this
92 * container is allowed to invoke topology operations, such as attach/detach
95 #define DPRC_CFG_OPT_TOPOLOGY_CHANGES_ALLOWED 0x00000008
97 /* AIOP - Indicates that container belongs to AIOP. */
98 #define DPRC_CFG_OPT_AIOP 0x00000020
100 /* IRQ Config - Indicates that the container allowed to configure its IRQs. */
101 #define DPRC_CFG_OPT_IRQ_CFG_ALLOWED 0x00000040
104 * struct dprc_cfg - Container configuration options
105 * @icid: Container's ICID; if set to 'DPRC_GET_ICID_FROM_POOL', a free
106 * ICID value is allocated by the DPRC
107 * @portal_id: Portal ID; if set to 'DPRC_GET_PORTAL_ID_FROM_POOL', a free
108 * portal ID is allocated by the DPRC
109 * @options: Combination of 'DPRC_CFG_OPT_<X>' options
110 * @label: Object's label
119 int dprc_create_container(struct fsl_mc_io *mc_io,
122 struct dprc_cfg *cfg,
123 int *child_container_id,
124 u64 *child_portal_offset);
126 int dprc_destroy_container(struct fsl_mc_io *mc_io,
129 int child_container_id);
131 int dprc_reset_container(struct fsl_mc_io *mc_io,
134 int child_container_id);
139 #define DPRC_IRQ_INDEX 0
141 /* Number of dprc's IRQs */
142 #define DPRC_NUM_OF_IRQS 1
144 /* DPRC IRQ events */
146 /* IRQ event - Indicates that a new object added to the container */
147 #define DPRC_IRQ_EVENT_OBJ_ADDED 0x00000001
148 /* IRQ event - Indicates that an object was removed from the container */
149 #define DPRC_IRQ_EVENT_OBJ_REMOVED 0x00000002
150 /* IRQ event - Indicates that resources added to the container */
151 #define DPRC_IRQ_EVENT_RES_ADDED 0x00000004
152 /* IRQ event - Indicates that resources removed from the container */
153 #define DPRC_IRQ_EVENT_RES_REMOVED 0x00000008
154 /* IRQ event - Indicates that one of the descendant containers that opened by
155 * this container is destroyed
157 #define DPRC_IRQ_EVENT_CONTAINER_DESTROYED 0x00000010
159 /* IRQ event - Indicates that on one of the container's opened object is
162 #define DPRC_IRQ_EVENT_OBJ_DESTROYED 0x00000020
164 /* Irq event - Indicates that object is created at the container */
165 #define DPRC_IRQ_EVENT_OBJ_CREATED 0x00000040
168 * struct dprc_irq_cfg - IRQ configuration
169 * @paddr: Address that must be written to signal a message-based interrupt
170 * @val: Value to write into irq_addr address
171 * @irq_num: A user defined number associated with this IRQ
173 struct dprc_irq_cfg {
179 int dprc_set_irq(struct fsl_mc_io *mc_io,
183 struct dprc_irq_cfg *irq_cfg);
185 int dprc_get_irq(struct fsl_mc_io *mc_io,
190 struct dprc_irq_cfg *irq_cfg);
192 int dprc_set_irq_enable(struct fsl_mc_io *mc_io,
198 int dprc_get_irq_enable(struct fsl_mc_io *mc_io,
204 int dprc_set_irq_mask(struct fsl_mc_io *mc_io,
210 int dprc_get_irq_mask(struct fsl_mc_io *mc_io,
216 int dprc_get_irq_status(struct fsl_mc_io *mc_io,
222 int dprc_clear_irq_status(struct fsl_mc_io *mc_io,
229 * struct dprc_attributes - Container attributes
230 * @container_id: Container's ID
231 * @icid: Container's ICID
232 * @portal_id: Container's portal ID
233 * @options: Container's options as set at container's creation
234 * @version: DPRC version
236 struct dprc_attributes {
242 * struct version - DPRC version
243 * @major: DPRC major version
244 * @minor: DPRC minor version
252 int dprc_get_attributes(struct fsl_mc_io *mc_io,
255 struct dprc_attributes *attributes);
257 int dprc_set_res_quota(struct fsl_mc_io *mc_io,
260 int child_container_id,
264 int dprc_get_res_quota(struct fsl_mc_io *mc_io,
267 int child_container_id,
271 /* Resource request options */
273 /* Explicit resource ID request - The requested objects/resources
274 * are explicit and sequential (in case of resources).
275 * The base ID is given at res_req at base_align field
277 #define DPRC_RES_REQ_OPT_EXPLICIT 0x00000001
279 /* Aligned resources request - Relevant only for resources
280 * request (and not objects). Indicates that resources base ID should be
281 * sequential and aligned to the value given at dprc_res_req base_align field
283 #define DPRC_RES_REQ_OPT_ALIGNED 0x00000002
285 /* Plugged Flag - Relevant only for object assignment request.
286 * Indicates that after all objects assigned. An interrupt will be invoked at
287 * the relevant GPP. The assigned object will be marked as plugged.
288 * plugged objects can't be assigned from their container
290 #define DPRC_RES_REQ_OPT_PLUGGED 0x00000004
293 * struct dprc_res_req - Resource request descriptor, to be used in assignment
294 * or un-assignment of resources and objects.
295 * @type: Resource/object type: Represent as a NULL terminated string.
296 * This string may received by using dprc_get_pool() to get resource
297 * type and dprc_get_obj() to get object type;
298 * Note: it is not possible to assign/un-assign DPRC objects
299 * @num: Number of resources
300 * @options: Request options: combination of DPRC_RES_REQ_OPT_ options
301 * @id_base_align: In case of explicit assignment (DPRC_RES_REQ_OPT_EXPLICIT
302 * is set at option), this field represents the required base ID
303 * for resource allocation; In case of aligned assignment
304 * (DPRC_RES_REQ_OPT_ALIGNED is set at option), this field
305 * indicates the required alignment for the resource ID(s) -
306 * use 0 if there is no alignment or explicit ID requirements
308 struct dprc_res_req {
315 int dprc_assign(struct fsl_mc_io *mc_io,
319 struct dprc_res_req *res_req);
321 int dprc_unassign(struct fsl_mc_io *mc_io,
324 int child_container_id,
325 struct dprc_res_req *res_req);
327 int dprc_get_pool_count(struct fsl_mc_io *mc_io,
332 int dprc_get_pool(struct fsl_mc_io *mc_io,
338 int dprc_get_obj_count(struct fsl_mc_io *mc_io,
343 /* Objects Attributes Flags */
345 /* Opened state - Indicates that an object is open by at least one owner */
346 #define DPRC_OBJ_STATE_OPEN 0x00000001
347 /* Plugged state - Indicates that the object is plugged */
348 #define DPRC_OBJ_STATE_PLUGGED 0x00000002
351 * Shareability flag - Object flag indicating no memory shareability.
352 * the object generates memory accesses that are non coherent with other
354 * user is responsible for proper memory handling through IOMMU configuration.
356 #define DPRC_OBJ_FLAG_NO_MEM_SHAREABILITY 0x0001
359 * struct dprc_obj_desc - Object descriptor, returned from dprc_get_obj()
360 * @type: Type of object: NULL terminated string
361 * @id: ID of logical object resource
362 * @vendor: Object vendor identifier
363 * @ver_major: Major version number
364 * @ver_minor: Minor version number
365 * @irq_count: Number of interrupts supported by the object
366 * @region_count: Number of mappable regions supported by the object
367 * @state: Object state: combination of DPRC_OBJ_STATE_ states
368 * @label: Object label
369 * @flags: Object's flags
371 struct dprc_obj_desc {
384 int dprc_get_obj(struct fsl_mc_io *mc_io,
388 struct dprc_obj_desc *obj_desc);
390 int dprc_get_obj_desc(struct fsl_mc_io *mc_io,
395 struct dprc_obj_desc *obj_desc);
397 int dprc_set_obj_irq(struct fsl_mc_io *mc_io,
403 struct dprc_irq_cfg *irq_cfg);
405 int dprc_get_obj_irq(struct fsl_mc_io *mc_io,
412 struct dprc_irq_cfg *irq_cfg);
414 int dprc_get_res_count(struct fsl_mc_io *mc_io,
421 * enum dprc_iter_status - Iteration status
422 * @DPRC_ITER_STATUS_FIRST: Perform first iteration
423 * @DPRC_ITER_STATUS_MORE: Indicates more/next iteration is needed
424 * @DPRC_ITER_STATUS_LAST: Indicates last iteration
426 enum dprc_iter_status {
427 DPRC_ITER_STATUS_FIRST = 0,
428 DPRC_ITER_STATUS_MORE = 1,
429 DPRC_ITER_STATUS_LAST = 2
433 * struct dprc_res_ids_range_desc - Resource ID range descriptor
434 * @base_id: Base resource ID of this range
435 * @last_id: Last resource ID of this range
436 * @iter_status: Iteration status - should be set to DPRC_ITER_STATUS_FIRST at
437 * first iteration; while the returned marker is DPRC_ITER_STATUS_MORE,
438 * additional iterations are needed, until the returned marker is
439 * DPRC_ITER_STATUS_LAST
441 struct dprc_res_ids_range_desc {
444 enum dprc_iter_status iter_status;
447 int dprc_get_res_ids(struct fsl_mc_io *mc_io,
451 struct dprc_res_ids_range_desc *range_desc);
454 /* Cacheable - Indicates that region should be mapped as cacheable */
455 #define DPRC_REGION_CACHEABLE 0x00000001
458 * enum dprc_region_type - Region type
459 * @DPRC_REGION_TYPE_MC_PORTAL: MC portal region
460 * @DPRC_REGION_TYPE_QBMAN_PORTAL: Qbman portal region
462 enum dprc_region_type {
463 DPRC_REGION_TYPE_MC_PORTAL,
464 DPRC_REGION_TYPE_QBMAN_PORTAL
468 * struct dprc_region_desc - Mappable region descriptor
469 * @base_offset: Region offset from region's base address.
470 * For DPMCP and DPRC objects, region base is offset from SoC MC portals
471 * base address; For DPIO, region base is offset from SoC QMan portals
473 * @size: Region size (in bytes)
474 * @flags: Region attributes
475 * @type: Portal region type
477 struct dprc_region_desc {
481 enum dprc_region_type type;
484 int dprc_get_obj_region(struct fsl_mc_io *mc_io,
490 struct dprc_region_desc *region_desc);
492 int dprc_set_obj_label(struct fsl_mc_io *mc_io,
500 * struct dprc_endpoint - Endpoint description for link connect/disconnect
502 * @type: Endpoint object type: NULL terminated string
503 * @id: Endpoint object ID
504 * @if_id: Interface ID; should be set for endpoints with multiple
505 * interfaces ("dpsw", "dpdmux"); for others, always set to 0
507 struct dprc_endpoint {
514 * struct dprc_connection_cfg - Connection configuration.
515 * Used for virtual connections only
516 * @committed_rate: Committed rate (Mbits/s)
517 * @max_rate: Maximum rate (Mbits/s)
519 struct dprc_connection_cfg {
524 int dprc_connect(struct fsl_mc_io *mc_io,
527 const struct dprc_endpoint *endpoint1,
528 const struct dprc_endpoint *endpoint2,
529 const struct dprc_connection_cfg *cfg);
531 int dprc_disconnect(struct fsl_mc_io *mc_io,
534 const struct dprc_endpoint *endpoint);
536 int dprc_get_connection(struct fsl_mc_io *mc_io,
539 const struct dprc_endpoint *endpoint1,
540 struct dprc_endpoint *endpoint2,
543 #endif /* _FSL_DPRC_H */