1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2019-2023 Broadcom 3 * All rights reserved. 4 */ 5 6 #ifndef TF_TBL_TYPE_H_ 7 #define TF_TBL_TYPE_H_ 8 9 #include "tf_core.h" 10 #include "stack.h" 11 12 struct tf; 13 14 /** 15 * The Table module provides processing of Internal TF table types. 16 */ 17 18 /** 19 * Table configuration parameters 20 */ 21 struct tf_tbl_cfg_parms { 22 /** 23 * Number of table types in each of the configuration arrays 24 */ 25 uint16_t num_elements; 26 /** 27 * Table Type element configuration array 28 */ 29 struct tf_rm_element_cfg *cfg; 30 /** 31 * Session resource allocations 32 */ 33 struct tf_session_resources *resources; 34 }; 35 36 /** 37 * Table allocation parameters 38 */ 39 struct tf_tbl_alloc_parms { 40 /** 41 * [in] Receive or transmit direction 42 */ 43 enum tf_dir dir; 44 /** 45 * [in] Type of the allocation 46 */ 47 enum tf_tbl_type type; 48 /** 49 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT) 50 */ 51 uint32_t tbl_scope_id; 52 /** 53 * [out] Idx of allocated entry or found entry (if search_enable) 54 */ 55 uint32_t *idx; 56 }; 57 58 /** 59 * Table free parameters 60 */ 61 struct tf_tbl_free_parms { 62 /** 63 * [in] Receive or transmit direction 64 */ 65 enum tf_dir dir; 66 /** 67 * [in] Type of the allocation type 68 */ 69 enum tf_tbl_type type; 70 /** 71 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT) 72 */ 73 uint32_t tbl_scope_id; 74 /** 75 * [in] Index to free 76 */ 77 uint32_t idx; 78 }; 79 80 /** 81 * Table set parameters 82 */ 83 struct tf_tbl_set_parms { 84 /** 85 * [in] Receive or transmit direction 86 */ 87 enum tf_dir dir; 88 /** 89 * [in] Type of object to set 90 */ 91 enum tf_tbl_type type; 92 /** 93 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT) 94 */ 95 uint32_t tbl_scope_id; 96 /** 97 * [in] Entry data 98 */ 99 uint8_t *data; 100 /** 101 * [in] Entry size 102 */ 103 uint16_t data_sz_in_bytes; 104 /** 105 * [in] Entry index to write to 106 */ 107 uint32_t idx; 108 }; 109 110 /** 111 * Table get parameters 112 */ 113 struct tf_tbl_get_parms { 114 /** 115 * [in] Receive or transmit direction 116 */ 117 enum tf_dir dir; 118 /** 119 * [in] Type of object to get 120 */ 121 enum tf_tbl_type type; 122 /** 123 * [out] Entry data 124 */ 125 uint8_t *data; 126 /** 127 * [out] Entry size 128 */ 129 uint16_t data_sz_in_bytes; 130 /** 131 * [in] Entry index to read 132 */ 133 uint32_t idx; 134 }; 135 136 /** 137 * Table get bulk parameters 138 */ 139 struct tf_tbl_get_bulk_parms { 140 /** 141 * [in] Receive or transmit direction 142 */ 143 enum tf_dir dir; 144 /** 145 * [in] Type of object to get 146 */ 147 enum tf_tbl_type type; 148 /** 149 * [in] Starting index to read from 150 */ 151 uint32_t starting_idx; 152 /** 153 * [in] Number of sequential entries 154 */ 155 uint16_t num_entries; 156 /** 157 * [in] Size of the single entry 158 */ 159 uint16_t entry_sz_in_bytes; 160 /** 161 * [out] Host physical address, where the data 162 * will be copied to by the firmware. 163 * Use tfp_calloc() API and mem_pa 164 * variable of the tfp_calloc_parms 165 * structure for the physical address. 166 */ 167 uint64_t physical_mem_addr; 168 }; 169 170 /** 171 * Table RM database 172 * 173 * Table rm database 174 * 175 */ 176 struct tbl_rm_db { 177 struct rm_db *tbl_db[TF_DIR_MAX]; 178 }; 179 180 /** 181 * @page tbl Table 182 * 183 * @ref tf_tbl_bind 184 * 185 * @ref tf_tbl_unbind 186 * 187 * @ref tf_tbl_alloc 188 * 189 * @ref tf_tbl_free 190 * 191 * @ref tf_tbl_set 192 * 193 * @ref tf_tbl_get 194 * 195 * @ref tf_tbl_bulk_get 196 */ 197 198 /** 199 * Initializes the Table module with the requested DBs. Must be 200 * invoked as the first thing before any of the access functions. 201 * 202 * [in] tfp 203 * Pointer to TF handle, used for HCAPI communication 204 * 205 * [in] parms 206 * Pointer to Table configuration parameters 207 * 208 * Returns 209 * - (0) if successful. 210 * - (-EINVAL) on failure. 211 */ 212 int tf_tbl_bind(struct tf *tfp, 213 struct tf_tbl_cfg_parms *parms); 214 215 /** 216 * Cleans up the private DBs and releases all the data. 217 * 218 * [in] tfp 219 * Pointer to TF handle, used for HCAPI communication 220 * 221 * [in] parms 222 * Pointer to parameters 223 * 224 * Returns 225 * - (0) if successful. 226 * - (-EINVAL) on failure. 227 */ 228 int tf_tbl_unbind(struct tf *tfp); 229 230 /** 231 * Allocates the requested table type from the internal RM DB. 232 * 233 * [in] tfp 234 * Pointer to TF handle, used for HCAPI communication 235 * 236 * [in] parms 237 * Pointer to Table allocation parameters 238 * 239 * Returns 240 * - (0) if successful. 241 * - (-EINVAL) on failure. 242 */ 243 int tf_tbl_alloc(struct tf *tfp, 244 struct tf_tbl_alloc_parms *parms); 245 246 /** 247 * Frees the requested table type and returns it to the DB. 248 * 249 * [in] tfp 250 * Pointer to TF handle, used for HCAPI communication 251 * 252 * [in] parms 253 * Pointer to Table free parameters 254 * 255 * Returns 256 * - (0) if successful. 257 * - (-EINVAL) on failure. 258 */ 259 int tf_tbl_free(struct tf *tfp, 260 struct tf_tbl_free_parms *parms); 261 262 /** 263 * Configures the requested element by sending a firmware request which 264 * then installs it into the device internal structures. 265 * 266 * [in] tfp 267 * Pointer to TF handle, used for HCAPI communication 268 * 269 * [in] parms 270 * Pointer to Table set parameters 271 * 272 * Returns 273 * - (0) if successful. 274 * - (-EINVAL) on failure. 275 */ 276 int tf_tbl_set(struct tf *tfp, 277 struct tf_tbl_set_parms *parms); 278 279 /** 280 * Retrieves the requested element by sending a firmware request to get 281 * the element. 282 * 283 * [in] tfp 284 * Pointer to TF handle, used for HCAPI communication 285 * 286 * [in] parms 287 * Pointer to Table get parameters 288 * 289 * Returns 290 * - (0) if successful. 291 * - (-EINVAL) on failure. 292 */ 293 int tf_tbl_get(struct tf *tfp, 294 struct tf_tbl_get_parms *parms); 295 296 /** 297 * Retrieves bulk block of elements by sending a firmware request to 298 * get the elements. 299 * 300 * [in] tfp 301 * Pointer to TF handle, used for HCAPI communication 302 * 303 * [in] parms 304 * Pointer to Table get bulk parameters 305 * 306 * Returns 307 * - (0) if successful. 308 * - (-EINVAL) on failure. 309 */ 310 int tf_tbl_bulk_get(struct tf *tfp, 311 struct tf_tbl_get_bulk_parms *parms); 312 313 /** 314 * Retrieves the allocated resource info 315 * 316 * [in] tfp 317 * Pointer to TF handle, used for HCAPI communication 318 * 319 * [in] parms 320 * Pointer to Table resource info parameters 321 * 322 * Returns 323 * - (0) if successful. 324 * - (-EINVAL) on failure. 325 */ 326 int 327 tf_tbl_get_resc_info(struct tf *tfp, 328 struct tf_tbl_resource_info *tbl); 329 #endif /* TF_TBL_TYPE_H */ 330