linux/drivers/staging/fsl-mc/include/dprc.h
<<
>>
Prefs
   1/* Copyright 2013-2015 Freescale Semiconductor Inc.
   2 *
   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.
  13 *
  14 *
  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
  18 * later version.
  19 *
  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.
  31 */
  32#ifndef _FSL_DPRC_H
  33#define _FSL_DPRC_H
  34
  35#include "mc-cmd.h"
  36
  37/* Data Path Resource Container API
  38 * Contains DPRC API for managing and querying DPAA resources
  39 */
  40
  41struct fsl_mc_io;
  42
  43/**
  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.
  47 */
  48#define DPRC_GET_ICID_FROM_POOL                 (u16)(~(0))
  49
  50/**
  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.
  54 */
  55#define DPRC_GET_PORTAL_ID_FROM_POOL    (int)(~(0))
  56
  57int dprc_open(struct fsl_mc_io *mc_io,
  58              u32 cmd_flags,
  59              int container_id,
  60              u16 *token);
  61
  62int dprc_close(struct fsl_mc_io *mc_io,
  63               u32 cmd_flags,
  64               u16 token);
  65
  66/**
  67 * Container general options
  68 *
  69 * These options may be selected at container creation by the container creator
  70 * and can be retrieved using dprc_get_attributes()
  71 */
  72
  73/* Spawn Policy Option allowed - Indicates that the new container is allowed
  74 * to spawn and have its own child containers.
  75 */
  76#define DPRC_CFG_OPT_SPAWN_ALLOWED              0x00000001
  77
  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.
  83 */
  84#define DPRC_CFG_OPT_ALLOC_ALLOWED              0x00000002
  85
  86/* Object initialization allowed - software context associated with this
  87 * container is allowed to invoke object initialization operations.
  88 */
  89#define DPRC_CFG_OPT_OBJ_CREATE_ALLOWED 0x00000004
  90
  91/* Topology change allowed - software context associated with this
  92 * container is allowed to invoke topology operations, such as attach/detach
  93 * of network objects.
  94 */
  95#define DPRC_CFG_OPT_TOPOLOGY_CHANGES_ALLOWED   0x00000008
  96
  97/* AIOP - Indicates that container belongs to AIOP.  */
  98#define DPRC_CFG_OPT_AIOP                       0x00000020
  99
 100/* IRQ Config - Indicates that the container allowed to configure its IRQs.  */
 101#define DPRC_CFG_OPT_IRQ_CFG_ALLOWED            0x00000040
 102
 103/**
 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
 111 */
 112struct dprc_cfg {
 113        u16 icid;
 114        int portal_id;
 115        u64 options;
 116        char label[16];
 117};
 118
 119int dprc_create_container(struct fsl_mc_io      *mc_io,
 120                          u32           cmd_flags,
 121                          u16           token,
 122                          struct dprc_cfg       *cfg,
 123                          int                   *child_container_id,
 124                          u64           *child_portal_offset);
 125
 126int dprc_destroy_container(struct fsl_mc_io     *mc_io,
 127                           u32          cmd_flags,
 128                           u16          token,
 129                           int                  child_container_id);
 130
 131int dprc_reset_container(struct fsl_mc_io *mc_io,
 132                         u32 cmd_flags,
 133                         u16 token,
 134                         int child_container_id);
 135
 136/* IRQ */
 137
 138/* IRQ index */
 139#define DPRC_IRQ_INDEX          0
 140
 141/* Number of dprc's IRQs */
 142#define DPRC_NUM_OF_IRQS                1
 143
 144/* DPRC IRQ events */
 145
 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
 156 */
 157#define DPRC_IRQ_EVENT_CONTAINER_DESTROYED      0x00000010
 158
 159/* IRQ event - Indicates that on one of the container's opened object is
 160 * destroyed
 161 */
 162#define DPRC_IRQ_EVENT_OBJ_DESTROYED            0x00000020
 163
 164/* Irq event - Indicates that object is created at the container */
 165#define DPRC_IRQ_EVENT_OBJ_CREATED              0x00000040
 166
 167/**
 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
 172 */
 173struct dprc_irq_cfg {
 174             phys_addr_t        paddr;
 175             u32                val;
 176             int                irq_num;
 177};
 178
 179int dprc_set_irq(struct fsl_mc_io       *mc_io,
 180                 u32            cmd_flags,
 181                 u16            token,
 182                 u8             irq_index,
 183                 struct dprc_irq_cfg    *irq_cfg);
 184
 185int dprc_get_irq(struct fsl_mc_io       *mc_io,
 186                 u32            cmd_flags,
 187                 u16            token,
 188                 u8             irq_index,
 189                 int                    *type,
 190                 struct dprc_irq_cfg    *irq_cfg);
 191
 192int dprc_set_irq_enable(struct fsl_mc_io        *mc_io,
 193                        u32             cmd_flags,
 194                        u16             token,
 195                        u8                      irq_index,
 196                        u8                      en);
 197
 198int dprc_get_irq_enable(struct fsl_mc_io        *mc_io,
 199                        u32             cmd_flags,
 200                        u16             token,
 201                        u8                      irq_index,
 202                        u8                      *en);
 203
 204int dprc_set_irq_mask(struct fsl_mc_io  *mc_io,
 205                      u32               cmd_flags,
 206                      u16               token,
 207                      u8                irq_index,
 208                      u32               mask);
 209
 210int dprc_get_irq_mask(struct fsl_mc_io  *mc_io,
 211                      u32               cmd_flags,
 212                      u16               token,
 213                      u8                irq_index,
 214                      u32               *mask);
 215
 216int dprc_get_irq_status(struct fsl_mc_io        *mc_io,
 217                        u32             cmd_flags,
 218                        u16             token,
 219                        u8                      irq_index,
 220                        u32             *status);
 221
 222int dprc_clear_irq_status(struct fsl_mc_io      *mc_io,
 223                          u32           cmd_flags,
 224                          u16           token,
 225                          u8            irq_index,
 226                          u32           status);
 227
 228/**
 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
 235 */
 236struct dprc_attributes {
 237        int container_id;
 238        u16 icid;
 239        int portal_id;
 240        u64 options;
 241        /**
 242         * struct version - DPRC version
 243         * @major: DPRC major version
 244         * @minor: DPRC minor version
 245         */
 246        struct {
 247                u16 major;
 248                u16 minor;
 249        } version;
 250};
 251
 252int dprc_get_attributes(struct fsl_mc_io        *mc_io,
 253                        u32             cmd_flags,
 254                        u16             token,
 255                        struct dprc_attributes  *attributes);
 256
 257int dprc_set_res_quota(struct fsl_mc_io *mc_io,
 258                       u32              cmd_flags,
 259                       u16              token,
 260                       int              child_container_id,
 261                       char             *type,
 262                       u16              quota);
 263
 264int dprc_get_res_quota(struct fsl_mc_io *mc_io,
 265                       u32              cmd_flags,
 266                       u16              token,
 267                       int              child_container_id,
 268                       char             *type,
 269                       u16              *quota);
 270
 271/* Resource request options */
 272
 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
 276 */
 277#define DPRC_RES_REQ_OPT_EXPLICIT               0x00000001
 278
 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
 282 */
 283#define DPRC_RES_REQ_OPT_ALIGNED                0x00000002
 284
 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
 289 */
 290#define DPRC_RES_REQ_OPT_PLUGGED                0x00000004
 291
 292/**
 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
 307 */
 308struct dprc_res_req {
 309        char type[16];
 310        u32 num;
 311        u32 options;
 312        int id_base_align;
 313};
 314
 315int dprc_assign(struct fsl_mc_io        *mc_io,
 316                u32             cmd_flags,
 317                u16             token,
 318                int                     container_id,
 319                struct dprc_res_req     *res_req);
 320
 321int dprc_unassign(struct fsl_mc_io      *mc_io,
 322                  u32           cmd_flags,
 323                  u16           token,
 324                  int                   child_container_id,
 325                  struct dprc_res_req   *res_req);
 326
 327int dprc_get_pool_count(struct fsl_mc_io        *mc_io,
 328                        u32             cmd_flags,
 329                        u16             token,
 330                        int                     *pool_count);
 331
 332int dprc_get_pool(struct fsl_mc_io      *mc_io,
 333                  u32           cmd_flags,
 334                  u16           token,
 335                  int                   pool_index,
 336                  char                  *type);
 337
 338int dprc_get_obj_count(struct fsl_mc_io *mc_io,
 339                       u32              cmd_flags,
 340                       u16              token,
 341                       int              *obj_count);
 342
 343/* Objects Attributes Flags */
 344
 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
 349
 350/**
 351 * Shareability flag - Object flag indicating no memory shareability.
 352 * the object generates memory accesses that are non coherent with other
 353 * masters;
 354 * user is responsible for proper memory handling through IOMMU configuration.
 355 */
 356#define DPRC_OBJ_FLAG_NO_MEM_SHAREABILITY               0x0001
 357
 358/**
 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
 370 */
 371struct dprc_obj_desc {
 372        char type[16];
 373        int id;
 374        u16 vendor;
 375        u16 ver_major;
 376        u16 ver_minor;
 377        u8 irq_count;
 378        u8 region_count;
 379        u32 state;
 380        char label[16];
 381        u16 flags;
 382};
 383
 384int dprc_get_obj(struct fsl_mc_io       *mc_io,
 385                 u32            cmd_flags,
 386                 u16            token,
 387                 int                    obj_index,
 388                 struct dprc_obj_desc   *obj_desc);
 389
 390int dprc_get_obj_desc(struct fsl_mc_io          *mc_io,
 391                      u32               cmd_flags,
 392                        u16             token,
 393                        char                    *obj_type,
 394                        int                     obj_id,
 395                        struct dprc_obj_desc    *obj_desc);
 396
 397int dprc_set_obj_irq(struct fsl_mc_io           *mc_io,
 398                     u32                        cmd_flags,
 399                     u16                        token,
 400                     char                       *obj_type,
 401                     int                        obj_id,
 402                     u8                 irq_index,
 403                     struct dprc_irq_cfg        *irq_cfg);
 404
 405int dprc_get_obj_irq(struct fsl_mc_io           *mc_io,
 406                     u32                        cmd_flags,
 407                     u16                        token,
 408                     char                       *obj_type,
 409                     int                        obj_id,
 410                     u8                 irq_index,
 411                     int                        *type,
 412                     struct dprc_irq_cfg        *irq_cfg);
 413
 414int dprc_get_res_count(struct fsl_mc_io *mc_io,
 415                       u32              cmd_flags,
 416                       u16              token,
 417                       char             *type,
 418                       int              *res_count);
 419
 420/**
 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
 425 */
 426enum dprc_iter_status {
 427        DPRC_ITER_STATUS_FIRST = 0,
 428        DPRC_ITER_STATUS_MORE = 1,
 429        DPRC_ITER_STATUS_LAST = 2
 430};
 431
 432/**
 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
 440 */
 441struct dprc_res_ids_range_desc {
 442        int base_id;
 443        int last_id;
 444        enum dprc_iter_status iter_status;
 445};
 446
 447int dprc_get_res_ids(struct fsl_mc_io                   *mc_io,
 448                     u32                                cmd_flags,
 449                     u16                                token,
 450                     char                               *type,
 451                     struct dprc_res_ids_range_desc     *range_desc);
 452
 453/* Region flags */
 454/* Cacheable - Indicates that region should be mapped as cacheable */
 455#define DPRC_REGION_CACHEABLE   0x00000001
 456
 457/**
 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
 461 */
 462enum dprc_region_type {
 463        DPRC_REGION_TYPE_MC_PORTAL,
 464        DPRC_REGION_TYPE_QBMAN_PORTAL
 465};
 466
 467/**
 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
 472 *      base address
 473 * @size: Region size (in bytes)
 474 * @flags: Region attributes
 475 * @type: Portal region type
 476 */
 477struct dprc_region_desc {
 478        u32 base_offset;
 479        u32 size;
 480        u32 flags;
 481        enum dprc_region_type type;
 482};
 483
 484int dprc_get_obj_region(struct fsl_mc_io        *mc_io,
 485                        u32             cmd_flags,
 486                        u16             token,
 487                        char                    *obj_type,
 488                        int                     obj_id,
 489                        u8                      region_index,
 490                        struct dprc_region_desc *region_desc);
 491
 492int dprc_set_obj_label(struct fsl_mc_io *mc_io,
 493                       u32              cmd_flags,
 494                       u16              token,
 495                       char             *obj_type,
 496                       int              obj_id,
 497                       char             *label);
 498
 499/**
 500 * struct dprc_endpoint - Endpoint description for link connect/disconnect
 501 *                      operations
 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
 506 */
 507struct dprc_endpoint {
 508        char type[16];
 509        int id;
 510        int if_id;
 511};
 512
 513/**
 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)
 518 */
 519struct dprc_connection_cfg {
 520        u32 committed_rate;
 521        u32 max_rate;
 522};
 523
 524int dprc_connect(struct fsl_mc_io               *mc_io,
 525                 u32                    cmd_flags,
 526                 u16                    token,
 527                 const struct dprc_endpoint     *endpoint1,
 528                 const struct dprc_endpoint     *endpoint2,
 529                 const struct dprc_connection_cfg *cfg);
 530
 531int dprc_disconnect(struct fsl_mc_io            *mc_io,
 532                    u32                 cmd_flags,
 533                    u16                 token,
 534                    const struct dprc_endpoint  *endpoint);
 535
 536int dprc_get_connection(struct fsl_mc_io                *mc_io,
 537                        u32                     cmd_flags,
 538                        u16                     token,
 539                        const struct dprc_endpoint      *endpoint1,
 540                        struct dprc_endpoint            *endpoint2,
 541                        int                             *state);
 542
 543#endif /* _FSL_DPRC_H */
 544
 545