1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 /* 3 * Freescale Layerscape MC I/O wrapper 4 * 5 * Copyright 2013-2016 Freescale Semiconductor, Inc. 6 * Copyright 2017, 2023 NXP 7 */ 8 #ifndef _FSL_DPRC_H 9 #define _FSL_DPRC_H 10 11 /* DPRC Version */ 12 #define DPRC_VER_MAJOR 6 13 #define DPRC_VER_MINOR 1 14 15 /* Command IDs */ 16 #define DPRC_CMDID_CLOSE 0x8001 17 #define DPRC_CMDID_OPEN 0x8051 18 19 #define DPRC_CMDID_GET_API_VERSION 0xa051 20 21 #define DPRC_CMDID_CREATE_CONT 0x1511 22 #define DPRC_CMDID_DESTROY_CONT 0x1521 23 #define DPRC_CMDID_GET_CONT_ID 0x8301 24 25 #define DPRC_CMDID_CONNECT 0x1671 26 #define DPRC_CMDID_DISCONNECT 0x1681 27 #define DPRC_CMDID_GET_CONNECTION 0x16C1 28 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 }; 48 49 struct dprc_cmd_destroy_container { 50 __le32 child_container_id; 51 }; 52 53 struct dprc_cmd_connect { 54 __le32 ep1_id; 55 __le16 ep1_interface_id; 56 __le16 pad0; 57 58 __le32 ep2_id; 59 __le16 ep2_interface_id; 60 __le16 pad1; 61 62 u8 ep1_type[16]; 63 64 __le32 max_rate; 65 __le32 committed_rate; 66 67 u8 ep2_type[16]; 68 }; 69 70 struct dprc_cmd_disconnect { 71 __le32 id; 72 __le32 interface_id; 73 u8 type[16]; 74 }; 75 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) 94 95 /* Data Path Resource Container API 96 * Contains DPRC API for managing and querying DPAA resources 97 */ 98 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 */ 106 #define DPRC_GET_ICID_FROM_POOL (u16)(~(0)) 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 115 int dprc_get_container_id(struct fsl_mc_io *mc_io, u32 cmd_flags, int *container_id); 116 117 int dprc_open(struct fsl_mc_io *mc_io, u32 cmd_flags, int container_id, u16 *token); 118 119 int dprc_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token); 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 */ 144 #define DPRC_CFG_OPT_OBJ_CREATE_ALLOWED 0x00000004 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 152 /* AIOP - Indicates that container belongs to AIOP. */ 153 #define DPRC_CFG_OPT_AIOP 0x00000020 154 155 /* IRQ Config - Indicates that the container allowed to configure its IRQs.*/ 156 #define DPRC_CFG_OPT_IRQ_CFG_ALLOWED 0x00000040 157 158 /** 159 * struct dprc_cfg - Container configuration options 160 * @icid: Container's ICID; if set to 'DPRC_GET_ICID_FROM_POOL', a free 161 * ICID value is allocated by the DPRC 162 * @portal_id: Portal ID; if set to 'DPRC_GET_PORTAL_ID_FROM_POOL', a free 163 * portal ID is allocated by the DPRC 164 * @options: Combination of 'DPRC_CFG_OPT_<X>' options 165 * @label: Object's label 166 */ 167 struct dprc_cfg { 168 u16 icid; 169 int portal_id; 170 uint64_t options; 171 char label[16]; 172 }; 173 174 int dprc_create_container(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, 175 struct dprc_cfg *cfg, int *child_container_id, 176 uint64_t *child_portal_offset); 177 178 int dprc_destroy_container(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, 179 int child_container_id); 180 181 /** 182 * struct dprc_connection_cfg - Connection configuration. 183 * Used for virtual connections only 184 * @committed_rate: Committed rate (Mbits/s) 185 * @max_rate: Maximum rate (Mbits/s) 186 */ 187 struct dprc_connection_cfg { 188 u32 committed_rate; 189 u32 max_rate; 190 }; 191 192 /** 193 * struct dprc_endpoint - Endpoint description for link connect/disconnect 194 * operations 195 * @type: Endpoint object type: NULL terminated string 196 * @id: Endpoint object ID 197 * @if_id: Interface ID; should be set for endpoints with multiple 198 * interfaces ("dpsw", "dpdmux"); for others, always set to 0 199 */ 200 struct dprc_endpoint { 201 char type[16]; 202 int id; 203 u16 if_id; 204 }; 205 206 int dprc_connect(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, 207 const struct dprc_endpoint *endpoint1, 208 const struct dprc_endpoint *endpoint2, 209 const struct dprc_connection_cfg *cfg); 210 211 int dprc_disconnect(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, 212 const struct dprc_endpoint *endpoint); 213 214 int dprc_get_connection(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token, 215 const struct dprc_endpoint *endpoint1, 216 struct dprc_endpoint *endpoint2, int *state); 217 218 int dprc_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags, 219 u16 *major_ver, u16 *minor_ver); 220 221 #endif /* _FSL_DPRC_H */ 222