Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Freescale Layerscape MC I/O wrapper |
| 4 | * |
Yogesh Gaur | 1a0c4ae | 2018-05-09 10:52:17 +0530 | [diff] [blame] | 5 | * Copyright 2013-2016 Freescale Semiconductor, Inc. |
Ioana Ciornei | 4b4370e | 2023-05-31 19:04:32 +0300 | [diff] [blame] | 6 | * Copyright 2017, 2023 NXP |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 7 | */ |
| 8 | #ifndef _FSL_DPRC_H |
| 9 | #define _FSL_DPRC_H |
| 10 | |
| 11 | /* DPRC Version */ |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 12 | #define DPRC_VER_MAJOR 6 |
Prabhakar Kushwaha | c3d06e3 | 2015-12-24 15:32:49 +0530 | [diff] [blame] | 13 | #define DPRC_VER_MINOR 1 |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 14 | |
| 15 | /* Command IDs */ |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 16 | #define DPRC_CMDID_CLOSE 0x8001 |
| 17 | #define DPRC_CMDID_OPEN 0x8051 |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 18 | |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 19 | #define DPRC_CMDID_GET_API_VERSION 0xa051 |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 20 | |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 21 | #define DPRC_CMDID_CREATE_CONT 0x1511 |
| 22 | #define DPRC_CMDID_DESTROY_CONT 0x1521 |
| 23 | #define DPRC_CMDID_GET_CONT_ID 0x8301 |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 24 | |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 25 | #define DPRC_CMDID_CONNECT 0x1671 |
| 26 | #define DPRC_CMDID_DISCONNECT 0x1681 |
| 27 | #define DPRC_CMDID_GET_CONNECTION 0x16C1 |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 28 | |
Ioana Ciornei | 4b4370e | 2023-05-31 19:04:32 +0300 | [diff] [blame] | 29 | #pragma pack(push, 1) |
| 30 | struct dprc_cmd_open { |
| 31 | __le32 container_id; |
| 32 | }; |
| 33 | |
| 34 | struct dprc_cmd_create_container { |
| 35 | __le32 options; |
| 36 | __le32 icid; |
| 37 | __le32 pad1; |
| 38 | __le32 portal_id; |
| 39 | u8 label[16]; |
| 40 | }; |
| 41 | |
| 42 | struct dprc_rsp_create_container { |
| 43 | __le64 pad0; |
| 44 | __le32 child_container_id; |
| 45 | __le32 pad1; |
| 46 | __le64 child_portal_addr; |
| 47 | }; |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 48 | |
Ioana Ciornei | 4b4370e | 2023-05-31 19:04:32 +0300 | [diff] [blame] | 49 | struct dprc_cmd_destroy_container { |
| 50 | __le32 child_container_id; |
| 51 | }; |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 52 | |
Ioana Ciornei | 4b4370e | 2023-05-31 19:04:32 +0300 | [diff] [blame] | 53 | struct dprc_cmd_connect { |
| 54 | __le32 ep1_id; |
| 55 | __le16 ep1_interface_id; |
| 56 | __le16 pad0; |
Prabhakar Kushwaha | cf0c8cf | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 57 | |
Ioana Ciornei | 4b4370e | 2023-05-31 19:04:32 +0300 | [diff] [blame] | 58 | __le32 ep2_id; |
| 59 | __le16 ep2_interface_id; |
| 60 | __le16 pad1; |
Prabhakar Kushwaha | cf0c8cf | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 61 | |
Ioana Ciornei | 4b4370e | 2023-05-31 19:04:32 +0300 | [diff] [blame] | 62 | u8 ep1_type[16]; |
Prabhakar Kushwaha | cf0c8cf | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 63 | |
Ioana Ciornei | 4b4370e | 2023-05-31 19:04:32 +0300 | [diff] [blame] | 64 | __le32 max_rate; |
| 65 | __le32 committed_rate; |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 66 | |
Ioana Ciornei | 4b4370e | 2023-05-31 19:04:32 +0300 | [diff] [blame] | 67 | u8 ep2_type[16]; |
| 68 | }; |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 69 | |
Ioana Ciornei | 4b4370e | 2023-05-31 19:04:32 +0300 | [diff] [blame] | 70 | struct dprc_cmd_disconnect { |
| 71 | __le32 id; |
| 72 | __le32 interface_id; |
| 73 | u8 type[16]; |
| 74 | }; |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 75 | |
Ioana Ciornei | 4b4370e | 2023-05-31 19:04:32 +0300 | [diff] [blame] | 76 | struct dprc_cmd_get_connection { |
| 77 | __le32 ep1_id; |
| 78 | __le16 ep1_interface_id; |
| 79 | __le16 pad; |
| 80 | |
| 81 | u8 ep1_type[16]; |
| 82 | }; |
| 83 | |
| 84 | struct dprc_rsp_get_connection { |
| 85 | __le64 pad[3]; |
| 86 | __le32 ep2_id; |
| 87 | __le16 ep2_interface_id; |
| 88 | __le16 pad1; |
| 89 | u8 ep2_type[16]; |
| 90 | __le32 state; |
| 91 | }; |
| 92 | |
| 93 | #pragma pack(pop) |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 94 | |
| 95 | /* Data Path Resource Container API |
| 96 | * Contains DPRC API for managing and querying DPAA resources |
| 97 | */ |
Prabhakar Kushwaha | fd5d127 | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 98 | |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 99 | struct fsl_mc_io; |
| 100 | |
| 101 | /** |
| 102 | * Set this value as the icid value in dprc_cfg structure when creating a |
| 103 | * container, in case the ICID is not selected by the user and should be |
| 104 | * allocated by the DPRC from the pool of ICIDs. |
| 105 | */ |
Ioana Ciornei | 4b4370e | 2023-05-31 19:04:32 +0300 | [diff] [blame] | 106 | #define DPRC_GET_ICID_FROM_POOL (u16)(~(0)) |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 107 | |
| 108 | /** |
| 109 | * Set this value as the portal_id value in dprc_cfg structure when creating a |
| 110 | * container, in case the portal ID is not specifically selected by the |
| 111 | * user and should be allocated by the DPRC from the pool of portal ids. |
| 112 | */ |
| 113 | #define DPRC_GET_PORTAL_ID_FROM_POOL (int)(~(0)) |
| 114 | |
Ioana Ciornei | 4b4370e | 2023-05-31 19:04:32 +0300 | [diff] [blame] | 115 | int dprc_get_container_id(struct fsl_mc_io *mc_io, u32 cmd_flags, int *container_id); |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 116 | |
Ioana Ciornei | 4b4370e | 2023-05-31 19:04:32 +0300 | [diff] [blame] | 117 | int dprc_open(struct fsl_mc_io *mc_io, u32 cmd_flags, int container_id, u16 *token); |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 118 | |
Ioana Ciornei | 4b4370e | 2023-05-31 19:04:32 +0300 | [diff] [blame] | 119 | int dprc_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token); |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 120 | |
| 121 | /** |
| 122 | * Container general options |
| 123 | * |
| 124 | * These options may be selected at container creation by the container creator |
| 125 | * and can be retrieved using dprc_get_attributes() |
| 126 | */ |
| 127 | |
| 128 | /* Spawn Policy Option allowed - Indicates that the new container is allowed |
| 129 | * to spawn and have its own child containers. |
| 130 | */ |
| 131 | #define DPRC_CFG_OPT_SPAWN_ALLOWED 0x00000001 |
| 132 | |
| 133 | /* General Container allocation policy - Indicates that the new container is |
| 134 | * allowed to allocate requested resources from its parent container; if not |
| 135 | * set, the container is only allowed to use resources in its own pools; Note |
| 136 | * that this is a container's global policy, but the parent container may |
| 137 | * override it and set specific quota per resource type. |
| 138 | */ |
| 139 | #define DPRC_CFG_OPT_ALLOC_ALLOWED 0x00000002 |
| 140 | |
| 141 | /* Object initialization allowed - software context associated with this |
| 142 | * container is allowed to invoke object initialization operations. |
| 143 | */ |
Prabhakar Kushwaha | fd5d127 | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 144 | #define DPRC_CFG_OPT_OBJ_CREATE_ALLOWED 0x00000004 |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 145 | |
| 146 | /* Topology change allowed - software context associated with this |
| 147 | * container is allowed to invoke topology operations, such as attach/detach |
| 148 | * of network objects. |
| 149 | */ |
| 150 | #define DPRC_CFG_OPT_TOPOLOGY_CHANGES_ALLOWED 0x00000008 |
| 151 | |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 152 | |
Prabhakar Kushwaha | c3d06e3 | 2015-12-24 15:32:49 +0530 | [diff] [blame] | 153 | /* AIOP - Indicates that container belongs to AIOP. */ |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 154 | #define DPRC_CFG_OPT_AIOP 0x00000020 |
| 155 | |
Prabhakar Kushwaha | c3d06e3 | 2015-12-24 15:32:49 +0530 | [diff] [blame] | 156 | /* IRQ Config - Indicates that the container allowed to configure its IRQs.*/ |
| 157 | #define DPRC_CFG_OPT_IRQ_CFG_ALLOWED 0x00000040 |
| 158 | |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 159 | /** |
| 160 | * struct dprc_cfg - Container configuration options |
| 161 | * @icid: Container's ICID; if set to 'DPRC_GET_ICID_FROM_POOL', a free |
| 162 | * ICID value is allocated by the DPRC |
| 163 | * @portal_id: Portal ID; if set to 'DPRC_GET_PORTAL_ID_FROM_POOL', a free |
| 164 | * portal ID is allocated by the DPRC |
| 165 | * @options: Combination of 'DPRC_CFG_OPT_<X>' options |
Prabhakar Kushwaha | fd5d127 | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 166 | * @label: Object's label |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 167 | */ |
| 168 | struct dprc_cfg { |
Ioana Ciornei | 4b4370e | 2023-05-31 19:04:32 +0300 | [diff] [blame] | 169 | u16 icid; |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 170 | int portal_id; |
| 171 | uint64_t options; |
Prabhakar Kushwaha | fd5d127 | 2015-07-02 11:28:59 +0530 | [diff] [blame] | 172 | char label[16]; |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 173 | }; |
| 174 | |
Ioana Ciornei | 4b4370e | 2023-05-31 19:04:32 +0300 | [diff] [blame] | 175 | int dprc_create_container(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, |
| 176 | struct dprc_cfg *cfg, int *child_container_id, |
| 177 | uint64_t *child_portal_offset); |
Prabhakar Kushwaha | cf0c8cf | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 178 | |
Ioana Ciornei | 4b4370e | 2023-05-31 19:04:32 +0300 | [diff] [blame] | 179 | int dprc_destroy_container(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, |
| 180 | int child_container_id); |
Prabhakar Kushwaha | 9564df6 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 181 | |
| 182 | /** |
| 183 | * struct dprc_connection_cfg - Connection configuration. |
| 184 | * Used for virtual connections only |
| 185 | * @committed_rate: Committed rate (Mbits/s) |
| 186 | * @max_rate: Maximum rate (Mbits/s) |
| 187 | */ |
| 188 | struct dprc_connection_cfg { |
Ioana Ciornei | 4b4370e | 2023-05-31 19:04:32 +0300 | [diff] [blame] | 189 | u32 committed_rate; |
| 190 | u32 max_rate; |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 191 | }; |
| 192 | |
| 193 | /** |
Ioana Ciornei | 4b4370e | 2023-05-31 19:04:32 +0300 | [diff] [blame] | 194 | * struct dprc_endpoint - Endpoint description for link connect/disconnect |
| 195 | * operations |
| 196 | * @type: Endpoint object type: NULL terminated string |
| 197 | * @id: Endpoint object ID |
| 198 | * @if_id: Interface ID; should be set for endpoints with multiple |
| 199 | * interfaces ("dpsw", "dpdmux"); for others, always set to 0 |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 200 | */ |
Ioana Ciornei | 4b4370e | 2023-05-31 19:04:32 +0300 | [diff] [blame] | 201 | struct dprc_endpoint { |
| 202 | char type[16]; |
| 203 | int id; |
| 204 | u16 if_id; |
| 205 | }; |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 206 | |
Ioana Ciornei | 4b4370e | 2023-05-31 19:04:32 +0300 | [diff] [blame] | 207 | int dprc_connect(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, |
| 208 | const struct dprc_endpoint *endpoint1, |
| 209 | const struct dprc_endpoint *endpoint2, |
| 210 | const struct dprc_connection_cfg *cfg); |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 211 | |
Ioana Ciornei | 4b4370e | 2023-05-31 19:04:32 +0300 | [diff] [blame] | 212 | int dprc_disconnect(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, |
| 213 | const struct dprc_endpoint *endpoint); |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 214 | |
Ioana Ciornei | 4b4370e | 2023-05-31 19:04:32 +0300 | [diff] [blame] | 215 | int dprc_get_connection(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, |
| 216 | const struct dprc_endpoint *endpoint1, |
| 217 | struct dprc_endpoint *endpoint2, int *state); |
| 218 | |
| 219 | int dprc_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags, |
| 220 | u16 *major_ver, u16 *minor_ver); |
Yogesh Gaur | 318c32f | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 221 | |
Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 222 | #endif /* _FSL_DPRC_H */ |