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] Result data to search for
151 * [in] Result data size in bytes
153 uint16_t result_sz_in_bytes;
155 * [in] Whether or not to allocate on MISS, 1 is allocate.
159 * [out] If search_enable, set if matching entry found
163 * [out] The status of the search (REJECT, MISS, HIT)
165 enum tf_search_status search_status;
167 * [out] Current ref count after allocation
171 * [out] Idx of allocated entry or found entry
177 * Table set parameters
179 struct tf_tbl_set_parms {
181 * [in] Receive or transmit direction
185 * [in] Type of object to set
187 enum tf_tbl_type type;
189 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
191 uint32_t tbl_scope_id;
199 uint16_t data_sz_in_bytes;
201 * [in] Entry index to write to
207 * Table get parameters
209 struct tf_tbl_get_parms {
211 * [in] Receive or transmit direction
215 * [in] Type of object to get
217 enum tf_tbl_type type;
225 uint16_t data_sz_in_bytes;
227 * [in] Entry index to read
233 * Table get bulk parameters
235 struct tf_tbl_get_bulk_parms {
237 * [in] Receive or transmit direction
241 * [in] Type of object to get
243 enum tf_tbl_type type;
245 * [in] Starting index to read from
247 uint32_t starting_idx;
249 * [in] Number of sequential entries
251 uint16_t num_entries;
253 * [in] Size of the single entry
255 uint16_t entry_sz_in_bytes;
257 * [out] Host physical address, where the data
258 * will be copied to by the firmware.
259 * Use tfp_calloc() API and mem_pa
260 * variable of the tfp_calloc_parms
261 * structure for the physical address.
263 uint64_t physical_mem_addr;
277 * @ref tf_tbl_alloc_search
283 * @ref tf_tbl_bulk_get
287 * Initializes the Table module with the requested DBs. Must be
288 * invoked as the first thing before any of the access functions.
291 * Pointer to TF handle, used for HCAPI communication
294 * Pointer to Table configuration parameters
297 * - (0) if successful.
298 * - (-EINVAL) on failure.
300 int tf_tbl_bind(struct tf *tfp,
301 struct tf_tbl_cfg_parms *parms);
304 * Cleans up the private DBs and releases all the data.
307 * Pointer to TF handle, used for HCAPI communication
310 * Pointer to parameters
313 * - (0) if successful.
314 * - (-EINVAL) on failure.
316 int tf_tbl_unbind(struct tf *tfp);
319 * Allocates the requested table type from the internal RM DB.
322 * Pointer to TF handle, used for HCAPI communication
325 * Pointer to Table allocation parameters
328 * - (0) if successful.
329 * - (-EINVAL) on failure.
331 int tf_tbl_alloc(struct tf *tfp,
332 struct tf_tbl_alloc_parms *parms);
335 * Free's the requested table type and returns it to the DB. If shadow
336 * DB is enabled its searched first and if found the element refcount
337 * is decremented. If refcount goes to 0 then its returned to the
341 * Pointer to TF handle, used for HCAPI communication
344 * Pointer to Table free parameters
347 * - (0) if successful.
348 * - (-EINVAL) on failure.
350 int tf_tbl_free(struct tf *tfp,
351 struct tf_tbl_free_parms *parms);
354 * Supported if Shadow DB is configured. Searches the Shadow DB for
355 * any matching element. If found the refcount in the shadow DB is
356 * updated accordingly. If not found a new element is allocated and
357 * installed into the shadow DB.
360 * Pointer to TF handle, used for HCAPI communication
363 * Pointer to parameters
366 * - (0) if successful.
367 * - (-EINVAL) on failure.
369 int tf_tbl_alloc_search(struct tf *tfp,
370 struct tf_tbl_alloc_search_parms *parms);
373 * Configures the requested element by sending a firmware request which
374 * then installs it into the device internal structures.
377 * Pointer to TF handle, used for HCAPI communication
380 * Pointer to Table set parameters
383 * - (0) if successful.
384 * - (-EINVAL) on failure.
386 int tf_tbl_set(struct tf *tfp,
387 struct tf_tbl_set_parms *parms);
390 * Retrieves the requested element by sending a firmware request to get
394 * Pointer to TF handle, used for HCAPI communication
397 * Pointer to Table get parameters
400 * - (0) if successful.
401 * - (-EINVAL) on failure.
403 int tf_tbl_get(struct tf *tfp,
404 struct tf_tbl_get_parms *parms);
407 * Retrieves bulk block of elements by sending a firmware request to
411 * Pointer to TF handle, used for HCAPI communication
414 * Pointer to Table get bulk parameters
417 * - (0) if successful.
418 * - (-EINVAL) on failure.
420 int tf_tbl_bulk_get(struct tf *tfp,
421 struct tf_tbl_get_bulk_parms *parms);
423 #endif /* TF_TBL_TYPE_H */