1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2019-2023 Broadcom 3 * All rights reserved. 4 */ 5 6 #ifndef TF_IF_TBL_TYPE_H_ 7 #define TF_IF_TBL_TYPE_H_ 8 9 #include "tf_core.h" 10 #include "stack.h" 11 12 /* 13 * This is the constant used to define invalid CFA 14 * types across all devices. 15 */ 16 #define CFA_IF_TBL_TYPE_INVALID 65535 17 18 struct tf; 19 20 /** 21 * The IF Table module provides processing of Internal TF interface table types. 22 */ 23 24 /** 25 * IF table configuration enumeration. 26 */ 27 enum tf_if_tbl_cfg_type { 28 /** 29 * No configuration 30 */ 31 TF_IF_TBL_CFG_NULL, 32 /** 33 * HCAPI 'controlled' 34 */ 35 TF_IF_TBL_CFG, 36 }; 37 38 /** 39 * IF table configuration structure, used by the Device to configure 40 * how an individual TF type is configured in regard to the HCAPI type. 41 */ 42 struct tf_if_tbl_cfg { 43 /** 44 * IF table config controls how the DB for that element is 45 * processed. 46 */ 47 enum tf_if_tbl_cfg_type cfg_type; 48 49 /** 50 * HCAPI Type for the element. Used for TF to HCAPI type 51 * conversion. 52 */ 53 uint16_t hcapi_type; 54 }; 55 56 /** 57 * Get HCAPI type parameters for a single element 58 */ 59 struct tf_if_tbl_get_hcapi_parms { 60 /** 61 * [in] IF Tbl DB Handle 62 */ 63 void *tbl_db; 64 /** 65 * [in] DB Index, indicates which DB entry to perform the 66 * action on. 67 */ 68 uint16_t db_index; 69 /** 70 * [out] Pointer to the hcapi type for the specified db_index 71 */ 72 uint16_t *hcapi_type; 73 }; 74 75 /** 76 * Table configuration parameters 77 */ 78 struct tf_if_tbl_cfg_parms { 79 /** 80 * Number of table types in each of the configuration arrays 81 */ 82 uint16_t num_elements; 83 /** 84 * Table Type element configuration array 85 */ 86 struct tf_if_tbl_cfg *cfg; 87 }; 88 89 /** 90 * IF Table set parameters 91 */ 92 struct tf_if_tbl_set_parms { 93 /** 94 * [in] Receive or transmit direction 95 */ 96 enum tf_dir dir; 97 /** 98 * [in] Type of object to set 99 */ 100 enum tf_if_tbl_type type; 101 /** 102 * [in] Type of HCAPI 103 */ 104 uint16_t hcapi_type; 105 /** 106 * [in] Entry data 107 */ 108 uint8_t *data; 109 /** 110 * [in] Entry size 111 */ 112 uint16_t data_sz_in_bytes; 113 /** 114 * [in] Entry index to write to 115 */ 116 uint32_t idx; 117 }; 118 119 /** 120 * IF Table get parameters 121 */ 122 struct tf_if_tbl_get_parms { 123 /** 124 * [in] Receive or transmit direction 125 */ 126 enum tf_dir dir; 127 /** 128 * [in] Type of object to get 129 */ 130 enum tf_if_tbl_type type; 131 /** 132 * [in] Type of HCAPI 133 */ 134 uint16_t hcapi_type; 135 /** 136 * [out] Entry data 137 */ 138 uint8_t *data; 139 /** 140 * [out] Entry size 141 */ 142 uint16_t data_sz_in_bytes; 143 /** 144 * [in] Entry index to read 145 */ 146 uint32_t idx; 147 }; 148 149 /** 150 * @page if tbl Table 151 * 152 * @ref tf_if_tbl_bind 153 * 154 * @ref tf_if_tbl_unbind 155 * 156 * @ref tf_tbl_set 157 * 158 * @ref tf_tbl_get 159 * 160 * @ref tf_tbl_restore 161 */ 162 /** 163 * Initializes the Table module with the requested DBs. Must be 164 * invoked as the first thing before any of the access functions. 165 * 166 * [in] tfp 167 * Pointer to TF handle, used for HCAPI communication 168 * 169 * [in] parms 170 * Pointer to Table configuration parameters 171 * 172 * Returns 173 * - (0) if successful. 174 * - (-EINVAL) on failure. 175 */ 176 int tf_if_tbl_bind(struct tf *tfp, 177 struct tf_if_tbl_cfg_parms *parms); 178 179 /** 180 * Cleans up the private DBs and releases all the data. 181 * 182 * [in] tfp 183 * Pointer to TF handle, used for HCAPI communication 184 * 185 * [in] parms 186 * Pointer to parameters 187 * 188 * Returns 189 * - (0) if successful. 190 * - (-EINVAL) on failure. 191 */ 192 int tf_if_tbl_unbind(struct tf *tfp); 193 194 /** 195 * Configures the requested element by sending a firmware request which 196 * then installs it into the device internal structures. 197 * 198 * [in] tfp 199 * Pointer to TF handle, used for HCAPI communication 200 * 201 * [in] parms 202 * Pointer to Interface Table set parameters 203 * 204 * Returns 205 * - (0) if successful. 206 * - (-EINVAL) on failure. 207 */ 208 int tf_if_tbl_set(struct tf *tfp, 209 struct tf_if_tbl_set_parms *parms); 210 211 /** 212 * Retrieves the requested element by sending a firmware request to get 213 * the element. 214 * 215 * [in] tfp 216 * Pointer to TF handle, used for HCAPI communication 217 * 218 * [in] parms 219 * Pointer to Table get parameters 220 * 221 * Returns 222 * - (0) if successful. 223 * - (-EINVAL) on failure. 224 */ 225 int tf_if_tbl_get(struct tf *tfp, 226 struct tf_if_tbl_get_parms *parms); 227 #endif /* TF_IF_TBL_TYPE_H */ 228