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 /* IOMMU bypass - indicates whether objects of this container are permitted
98 * to bypass the IOMMU.
100 #define DPRC_CFG_OPT_IOMMU_BYPASS 0x00000010
102 /* AIOP - Indicates that container belongs to AIOP. */
103 #define DPRC_CFG_OPT_AIOP 0x00000020
105 /* IRQ Config - Indicates that the container allowed to configure its IRQs. */
106 #define DPRC_CFG_OPT_IRQ_CFG_ALLOWED 0x00000040
109 * struct dprc_cfg - Container configuration options
110 * @icid: Container's ICID; if set to 'DPRC_GET_ICID_FROM_POOL', a free
111 * ICID value is allocated by the DPRC
112 * @portal_id: Portal ID; if set to 'DPRC_GET_PORTAL_ID_FROM_POOL', a free
113 * portal ID is allocated by the DPRC
114 * @options: Combination of 'DPRC_CFG_OPT_<X>' options
115 * @label: Object's label
124 int dprc_create_container(struct fsl_mc_io *mc_io,
127 struct dprc_cfg *cfg,
128 int *child_container_id,
129 u64 *child_portal_offset);
131 int dprc_destroy_container(struct fsl_mc_io *mc_io,
134 int child_container_id);
136 int dprc_reset_container(struct fsl_mc_io *mc_io,
139 int child_container_id);
144 #define DPRC_IRQ_INDEX 0
146 /* Number of dprc's IRQs */
147 #define DPRC_NUM_OF_IRQS 1
149 /* DPRC IRQ events */
151 /* IRQ event - Indicates that a new object added to the container */
152 #define DPRC_IRQ_EVENT_OBJ_ADDED 0x00000001
153 /* IRQ event - Indicates that an object was removed from the container */
154 #define DPRC_IRQ_EVENT_OBJ_REMOVED 0x00000002
155 /* IRQ event - Indicates that resources added to the container */
156 #define DPRC_IRQ_EVENT_RES_ADDED 0x00000004
157 /* IRQ event - Indicates that resources removed from the container */
158 #define DPRC_IRQ_EVENT_RES_REMOVED 0x00000008
159 /* IRQ event - Indicates that one of the descendant containers that opened by
160 * this container is destroyed
162 #define DPRC_IRQ_EVENT_CONTAINER_DESTROYED 0x00000010
164 /* IRQ event - Indicates that on one of the container's opened object is
167 #define DPRC_IRQ_EVENT_OBJ_DESTROYED 0x00000020
169 /* Irq event - Indicates that object is created at the container */
170 #define DPRC_IRQ_EVENT_OBJ_CREATED 0x00000040
173 * struct dprc_irq_cfg - IRQ configuration
174 * @paddr: Address that must be written to signal a message-based interrupt
175 * @val: Value to write into irq_addr address
176 * @user_irq_id: A user defined number associated with this IRQ
178 struct dprc_irq_cfg {
184 int dprc_set_irq(struct fsl_mc_io *mc_io,
188 struct dprc_irq_cfg *irq_cfg);
190 int dprc_get_irq(struct fsl_mc_io *mc_io,
195 struct dprc_irq_cfg *irq_cfg);
197 int dprc_set_irq_enable(struct fsl_mc_io *mc_io,
203 int dprc_get_irq_enable(struct fsl_mc_io *mc_io,
209 int dprc_set_irq_mask(struct fsl_mc_io *mc_io,
215 int dprc_get_irq_mask(struct fsl_mc_io *mc_io,
221 int dprc_get_irq_status(struct fsl_mc_io *mc_io,
227 int dprc_clear_irq_status(struct fsl_mc_io *mc_io,
234 * struct dprc_attributes - Container attributes
235 * @container_id: Container's ID
236 * @icid: Container's ICID
237 * @portal_id: Container's portal ID
238 * @options: Container's options as set at container's creation
239 * @version: DPRC version
241 struct dprc_attributes {
247 * struct version - DPRC version
248 * @major: DPRC major version
249 * @minor: DPRC minor version
257 int dprc_get_attributes(struct fsl_mc_io *mc_io,
260 struct dprc_attributes *attributes);
262 int dprc_set_res_quota(struct fsl_mc_io *mc_io,
265 int child_container_id,
269 int dprc_get_res_quota(struct fsl_mc_io *mc_io,
272 int child_container_id,
276 /* Resource request options */
278 /* Explicit resource ID request - The requested objects/resources
279 * are explicit and sequential (in case of resources).
280 * The base ID is given at res_req at base_align field
282 #define DPRC_RES_REQ_OPT_EXPLICIT 0x00000001
284 /* Aligned resources request - Relevant only for resources
285 * request (and not objects). Indicates that resources base ID should be
286 * sequential and aligned to the value given at dprc_res_req base_align field
288 #define DPRC_RES_REQ_OPT_ALIGNED 0x00000002
290 /* Plugged Flag - Relevant only for object assignment request.
291 * Indicates that after all objects assigned. An interrupt will be invoked at
292 * the relevant GPP. The assigned object will be marked as plugged.
293 * plugged objects can't be assigned from their container
295 #define DPRC_RES_REQ_OPT_PLUGGED 0x00000004
298 * struct dprc_res_req - Resource request descriptor, to be used in assignment
299 * or un-assignment of resources and objects.
300 * @type: Resource/object type: Represent as a NULL terminated string.
301 * This string may received by using dprc_get_pool() to get resource
302 * type and dprc_get_obj() to get object type;
303 * Note: it is not possible to assign/un-assign DPRC objects
304 * @num: Number of resources
305 * @options: Request options: combination of DPRC_RES_REQ_OPT_ options
306 * @id_base_align: In case of explicit assignment (DPRC_RES_REQ_OPT_EXPLICIT
307 * is set at option), this field represents the required base ID
308 * for resource allocation; In case of aligned assignment
309 * (DPRC_RES_REQ_OPT_ALIGNED is set at option), this field
310 * indicates the required alignment for the resource ID(s) -
311 * use 0 if there is no alignment or explicit ID requirements
313 struct dprc_res_req {
320 int dprc_assign(struct fsl_mc_io *mc_io,
324 struct dprc_res_req *res_req);
326 int dprc_unassign(struct fsl_mc_io *mc_io,
329 int child_container_id,
330 struct dprc_res_req *res_req);
332 int dprc_get_pool_count(struct fsl_mc_io *mc_io,
337 int dprc_get_pool(struct fsl_mc_io *mc_io,
343 int dprc_get_obj_count(struct fsl_mc_io *mc_io,
348 /* Objects Attributes Flags */
350 /* Opened state - Indicates that an object is open by at least one owner */
351 #define DPRC_OBJ_STATE_OPEN 0x00000001
352 /* Plugged state - Indicates that the object is plugged */
353 #define DPRC_OBJ_STATE_PLUGGED 0x00000002
356 * struct dprc_obj_desc - Object descriptor, returned from dprc_get_obj()
357 * @type: Type of object: NULL terminated string
358 * @id: ID of logical object resource
359 * @vendor: Object vendor identifier
360 * @ver_major: Major version number
361 * @ver_minor: Minor version number
362 * @irq_count: Number of interrupts supported by the object
363 * @region_count: Number of mappable regions supported by the object
364 * @state: Object state: combination of DPRC_OBJ_STATE_ states
365 * @label: Object label
367 struct dprc_obj_desc {
379 int dprc_get_obj(struct fsl_mc_io *mc_io,
383 struct dprc_obj_desc *obj_desc);
385 int dprc_get_obj_desc(struct fsl_mc_io *mc_io,
390 struct dprc_obj_desc *obj_desc);
392 int dprc_set_obj_irq(struct fsl_mc_io *mc_io,
398 struct dprc_irq_cfg *irq_cfg);
400 int dprc_get_obj_irq(struct fsl_mc_io *mc_io,
407 struct dprc_irq_cfg *irq_cfg);
409 int dprc_get_res_count(struct fsl_mc_io *mc_io,
416 * enum dprc_iter_status - Iteration status
417 * @DPRC_ITER_STATUS_FIRST: Perform first iteration
418 * @DPRC_ITER_STATUS_MORE: Indicates more/next iteration is needed
419 * @DPRC_ITER_STATUS_LAST: Indicates last iteration
421 enum dprc_iter_status {
422 DPRC_ITER_STATUS_FIRST = 0,
423 DPRC_ITER_STATUS_MORE = 1,
424 DPRC_ITER_STATUS_LAST = 2
428 * struct dprc_res_ids_range_desc - Resource ID range descriptor
429 * @base_id: Base resource ID of this range
430 * @last_id: Last resource ID of this range
431 * @iter_status: Iteration status - should be set to DPRC_ITER_STATUS_FIRST at
432 * first iteration; while the returned marker is DPRC_ITER_STATUS_MORE,
433 * additional iterations are needed, until the returned marker is
434 * DPRC_ITER_STATUS_LAST
436 struct dprc_res_ids_range_desc {
439 enum dprc_iter_status iter_status;
442 int dprc_get_res_ids(struct fsl_mc_io *mc_io,
446 struct dprc_res_ids_range_desc *range_desc);
449 /* Cacheable - Indicates that region should be mapped as cacheable */
450 #define DPRC_REGION_CACHEABLE 0x00000001
453 * enum dprc_region_type - Region type
454 * @DPRC_REGION_TYPE_MC_PORTAL: MC portal region
455 * @DPRC_REGION_TYPE_QBMAN_PORTAL: Qbman portal region
457 enum dprc_region_type {
458 DPRC_REGION_TYPE_MC_PORTAL,
459 DPRC_REGION_TYPE_QBMAN_PORTAL
463 * struct dprc_region_desc - Mappable region descriptor
464 * @base_offset: Region offset from region's base address.
465 * For DPMCP and DPRC objects, region base is offset from SoC MC portals
466 * base address; For DPIO, region base is offset from SoC QMan portals
468 * @size: Region size (in bytes)
469 * @flags: Region attributes
470 * @type: Portal region type
472 struct dprc_region_desc {
476 enum dprc_region_type type;
479 int dprc_get_obj_region(struct fsl_mc_io *mc_io,
485 struct dprc_region_desc *region_desc);
487 int dprc_set_obj_label(struct fsl_mc_io *mc_io,
495 * struct dprc_endpoint - Endpoint description for link connect/disconnect
497 * @type: Endpoint object type: NULL terminated string
498 * @id: Endpoint object ID
499 * @if_id: Interface ID; should be set for endpoints with multiple
500 * interfaces ("dpsw", "dpdmux"); for others, always set to 0
502 struct dprc_endpoint {
509 * struct dprc_connection_cfg - Connection configuration.
510 * Used for virtual connections only
511 * @committed_rate: Committed rate (Mbits/s)
512 * @max_rate: Maximum rate (Mbits/s)
514 struct dprc_connection_cfg {
519 int dprc_connect(struct fsl_mc_io *mc_io,
522 const struct dprc_endpoint *endpoint1,
523 const struct dprc_endpoint *endpoint2,
524 const struct dprc_connection_cfg *cfg);
526 int dprc_disconnect(struct fsl_mc_io *mc_io,
529 const struct dprc_endpoint *endpoint);
531 int dprc_get_connection(struct fsl_mc_io *mc_io,
534 const struct dprc_endpoint *endpoint1,
535 struct dprc_endpoint *endpoint2,
538 #endif /* _FSL_DPRC_H */