1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2020 Broadcom
15 * The Table module provides processing of Internal TF table types.
19 * Table scope control block content
24 uint32_t max_entries_supported;
25 uint16_t key_entry_size;
26 uint16_t record_entry_size;
27 uint16_t efc_entry_size;
30 /** Invalid table scope id */
31 #define TF_TBL_SCOPE_INVALID 0xffffffff
34 * Table Scope Control Block
36 * Holds private data for a table scope. Only one instance of a table
37 * scope with Internal EM is supported.
39 struct tf_tbl_scope_cb {
40 uint32_t tbl_scope_id;
41 #ifdef TF_USE_SYSTEM_MEM
45 int fd[TF_DIR_MAX][TF_MAX_TABLE];
49 struct hcapi_cfa_em_ctx_mem_info em_ctx_info[TF_DIR_MAX];
50 struct tf_em_caps em_caps[TF_DIR_MAX];
51 struct stack ext_act_pool[TF_DIR_MAX];
52 uint32_t *ext_act_pool_mem[TF_DIR_MAX];
56 * Table configuration parameters
58 struct tf_tbl_cfg_parms {
60 * Number of table types in each of the configuration arrays
62 uint16_t num_elements;
64 * Table Type element configuration array
66 struct tf_rm_element_cfg *cfg;
68 * Shadow table type configuration array
70 struct tf_shadow_tbl_cfg *shadow_cfg;
72 * Boolean controlling the request shadow copy.
76 * Session resource allocations
78 struct tf_session_resources *resources;
82 * Table allocation parameters
84 struct tf_tbl_alloc_parms {
86 * [in] Receive or transmit direction
90 * [in] Type of the allocation
92 enum tf_tbl_type type;
94 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
96 uint32_t tbl_scope_id;
98 * [out] Idx of allocated entry or found entry (if search_enable)
104 * Table free parameters
106 struct tf_tbl_free_parms {
108 * [in] Receive or transmit direction
112 * [in] Type of the allocation type
114 enum tf_tbl_type type;
116 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
118 uint32_t tbl_scope_id;
124 * [out] Reference count after free, only valid if session has been
125 * created with shadow_copy.
131 * Table allocate search parameters
133 struct tf_tbl_alloc_search_parms {
135 * [in] Receive or transmit direction
139 * [in] Type of the allocation
141 enum tf_tbl_type type;
143 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
145 uint32_t tbl_scope_id;
147 * [in] Enable search for matching entry. If the table type is
148 * internal the shadow copy will be searched before
149 * alloc. Session must be configured with shadow copy enabled.
151 uint8_t search_enable;
153 * [in] Result data to search for (if search_enable)
157 * [in] Result data size in bytes (if search_enable)
159 uint16_t result_sz_in_bytes;
161 * [out] If search_enable, set if matching entry found
165 * [out] Current ref count after allocation (if search_enable)
169 * [out] Idx of allocated entry or found entry (if search_enable)
175 * Table set parameters
177 struct tf_tbl_set_parms {
179 * [in] Receive or transmit direction
183 * [in] Type of object to set
185 enum tf_tbl_type type;
187 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
189 uint32_t tbl_scope_id;
197 uint16_t data_sz_in_bytes;
199 * [in] Entry index to write to
205 * Table get parameters
207 struct tf_tbl_get_parms {
209 * [in] Receive or transmit direction
213 * [in] Type of object to get
215 enum tf_tbl_type type;
223 uint16_t data_sz_in_bytes;
225 * [in] Entry index to read
231 * Table get bulk parameters
233 struct tf_tbl_get_bulk_parms {
235 * [in] Receive or transmit direction
239 * [in] Type of object to get
241 enum tf_tbl_type type;
243 * [in] Starting index to read from
245 uint32_t starting_idx;
247 * [in] Number of sequential entries
249 uint16_t num_entries;
251 * [in] Size of the single entry
253 uint16_t entry_sz_in_bytes;
255 * [out] Host physical address, where the data
256 * will be copied to by the firmware.
257 * Use tfp_calloc() API and mem_pa
258 * variable of the tfp_calloc_parms
259 * structure for the physical address.
261 uint64_t physical_mem_addr;
275 * @ref tf_tbl_alloc_search
281 * @ref tf_tbl_bulk_get
285 * Initializes the Table module with the requested DBs. Must be
286 * invoked as the first thing before any of the access functions.
289 * Pointer to TF handle, used for HCAPI communication
292 * Pointer to Table configuration parameters
295 * - (0) if successful.
296 * - (-EINVAL) on failure.
298 int tf_tbl_bind(struct tf *tfp,
299 struct tf_tbl_cfg_parms *parms);
302 * Cleans up the private DBs and releases all the data.
305 * Pointer to TF handle, used for HCAPI communication
308 * Pointer to parameters
311 * - (0) if successful.
312 * - (-EINVAL) on failure.
314 int tf_tbl_unbind(struct tf *tfp);
317 * Allocates the requested table type from the internal RM DB.
320 * Pointer to TF handle, used for HCAPI communication
323 * Pointer to Table allocation parameters
326 * - (0) if successful.
327 * - (-EINVAL) on failure.
329 int tf_tbl_alloc(struct tf *tfp,
330 struct tf_tbl_alloc_parms *parms);
333 * Free's the requested table type and returns it to the DB. If shadow
334 * DB is enabled its searched first and if found the element refcount
335 * is decremented. If refcount goes to 0 then its returned to the
339 * Pointer to TF handle, used for HCAPI communication
342 * Pointer to Table free parameters
345 * - (0) if successful.
346 * - (-EINVAL) on failure.
348 int tf_tbl_free(struct tf *tfp,
349 struct tf_tbl_free_parms *parms);
352 * Supported if Shadow DB is configured. Searches the Shadow DB for
353 * any matching element. If found the refcount in the shadow DB is
354 * updated accordingly. If not found a new element is allocated and
355 * installed into the shadow DB.
358 * Pointer to TF handle, used for HCAPI communication
361 * Pointer to parameters
364 * - (0) if successful.
365 * - (-EINVAL) on failure.
367 int tf_tbl_alloc_search(struct tf *tfp,
368 struct tf_tbl_alloc_search_parms *parms);
371 * Configures the requested element by sending a firmware request which
372 * then installs it into the device internal structures.
375 * Pointer to TF handle, used for HCAPI communication
378 * Pointer to Table set parameters
381 * - (0) if successful.
382 * - (-EINVAL) on failure.
384 int tf_tbl_set(struct tf *tfp,
385 struct tf_tbl_set_parms *parms);
388 * Retrieves the requested element by sending a firmware request to get
392 * Pointer to TF handle, used for HCAPI communication
395 * Pointer to Table get parameters
398 * - (0) if successful.
399 * - (-EINVAL) on failure.
401 int tf_tbl_get(struct tf *tfp,
402 struct tf_tbl_get_parms *parms);
405 * Retrieves bulk block of elements by sending a firmware request to
409 * Pointer to TF handle, used for HCAPI communication
412 * Pointer to Table get bulk parameters
415 * - (0) if successful.
416 * - (-EINVAL) on failure.
418 int tf_tbl_bulk_get(struct tf *tfp,
419 struct tf_tbl_get_bulk_parms *parms);
421 #endif /* TF_TBL_TYPE_H */