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;
42 struct hcapi_cfa_em_ctx_mem_info em_ctx_info[TF_DIR_MAX];
43 struct tf_em_caps em_caps[TF_DIR_MAX];
44 struct stack ext_act_pool[TF_DIR_MAX];
45 uint32_t *ext_act_pool_mem[TF_DIR_MAX];
49 * Table configuration parameters
51 struct tf_tbl_cfg_parms {
53 * Number of table types in each of the configuration arrays
55 uint16_t num_elements;
57 * Table Type element configuration array
59 struct tf_rm_element_cfg *cfg;
61 * Shadow table type configuration array
63 struct tf_shadow_tbl_cfg *shadow_cfg;
65 * Boolean controlling the request shadow copy.
69 * Session resource allocations
71 struct tf_session_resources *resources;
75 * Table allocation parameters
77 struct tf_tbl_alloc_parms {
79 * [in] Receive or transmit direction
83 * [in] Type of the allocation
85 enum tf_tbl_type type;
87 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
89 uint32_t tbl_scope_id;
91 * [out] Idx of allocated entry or found entry (if search_enable)
97 * Table free parameters
99 struct tf_tbl_free_parms {
101 * [in] Receive or transmit direction
105 * [in] Type of the allocation type
107 enum tf_tbl_type type;
109 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
111 uint32_t tbl_scope_id;
117 * [out] Reference count after free, only valid if session has been
118 * created with shadow_copy.
124 * Table allocate search parameters
126 struct tf_tbl_alloc_search_parms {
128 * [in] Receive or transmit direction
132 * [in] Type of the allocation
134 enum tf_tbl_type type;
136 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
138 uint32_t tbl_scope_id;
140 * [in] Enable search for matching entry. If the table type is
141 * internal the shadow copy will be searched before
142 * alloc. Session must be configured with shadow copy enabled.
144 uint8_t search_enable;
146 * [in] Result data to search for (if search_enable)
150 * [in] Result data size in bytes (if search_enable)
152 uint16_t result_sz_in_bytes;
154 * [out] If search_enable, set if matching entry found
158 * [out] Current ref count after allocation (if search_enable)
162 * [out] Idx of allocated entry or found entry (if search_enable)
168 * Table set parameters
170 struct tf_tbl_set_parms {
172 * [in] Receive or transmit direction
176 * [in] Type of object to set
178 enum tf_tbl_type type;
180 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
182 uint32_t tbl_scope_id;
190 uint16_t data_sz_in_bytes;
192 * [in] Entry index to write to
198 * Table get parameters
200 struct tf_tbl_get_parms {
202 * [in] Receive or transmit direction
206 * [in] Type of object to get
208 enum tf_tbl_type type;
216 uint16_t data_sz_in_bytes;
218 * [in] Entry index to read
224 * Table get bulk parameters
226 struct tf_tbl_get_bulk_parms {
228 * [in] Receive or transmit direction
232 * [in] Type of object to get
234 enum tf_tbl_type type;
236 * [in] Starting index to read from
238 uint32_t starting_idx;
240 * [in] Number of sequential entries
242 uint16_t num_entries;
244 * [in] Size of the single entry
246 uint16_t entry_sz_in_bytes;
248 * [out] Host physical address, where the data
249 * will be copied to by the firmware.
250 * Use tfp_calloc() API and mem_pa
251 * variable of the tfp_calloc_parms
252 * structure for the physical address.
254 uint64_t physical_mem_addr;
268 * @ref tf_tbl_alloc_search
274 * @ref tf_tbl_bulk_get
278 * Initializes the Table module with the requested DBs. Must be
279 * invoked as the first thing before any of the access functions.
282 * Pointer to TF handle, used for HCAPI communication
285 * Pointer to Table configuration parameters
288 * - (0) if successful.
289 * - (-EINVAL) on failure.
291 int tf_tbl_bind(struct tf *tfp,
292 struct tf_tbl_cfg_parms *parms);
295 * Cleans up the private DBs and releases all the data.
298 * Pointer to TF handle, used for HCAPI communication
301 * Pointer to parameters
304 * - (0) if successful.
305 * - (-EINVAL) on failure.
307 int tf_tbl_unbind(struct tf *tfp);
310 * Allocates the requested table type from the internal RM DB.
313 * Pointer to TF handle, used for HCAPI communication
316 * Pointer to Table allocation parameters
319 * - (0) if successful.
320 * - (-EINVAL) on failure.
322 int tf_tbl_alloc(struct tf *tfp,
323 struct tf_tbl_alloc_parms *parms);
326 * Free's the requested table type and returns it to the DB. If shadow
327 * DB is enabled its searched first and if found the element refcount
328 * is decremented. If refcount goes to 0 then its returned to the
332 * Pointer to TF handle, used for HCAPI communication
335 * Pointer to Table free parameters
338 * - (0) if successful.
339 * - (-EINVAL) on failure.
341 int tf_tbl_free(struct tf *tfp,
342 struct tf_tbl_free_parms *parms);
345 * Supported if Shadow DB is configured. Searches the Shadow DB for
346 * any matching element. If found the refcount in the shadow DB is
347 * updated accordingly. If not found a new element is allocated and
348 * installed into the shadow DB.
351 * Pointer to TF handle, used for HCAPI communication
354 * Pointer to parameters
357 * - (0) if successful.
358 * - (-EINVAL) on failure.
360 int tf_tbl_alloc_search(struct tf *tfp,
361 struct tf_tbl_alloc_search_parms *parms);
364 * Configures the requested element by sending a firmware request which
365 * then installs it into the device internal structures.
368 * Pointer to TF handle, used for HCAPI communication
371 * Pointer to Table set parameters
374 * - (0) if successful.
375 * - (-EINVAL) on failure.
377 int tf_tbl_set(struct tf *tfp,
378 struct tf_tbl_set_parms *parms);
381 * Retrieves the requested element by sending a firmware request to get
385 * Pointer to TF handle, used for HCAPI communication
388 * Pointer to Table get parameters
391 * - (0) if successful.
392 * - (-EINVAL) on failure.
394 int tf_tbl_get(struct tf *tfp,
395 struct tf_tbl_get_parms *parms);
398 * Retrieves bulk block of elements by sending a firmware request to
402 * Pointer to TF handle, used for HCAPI communication
405 * Pointer to Table get bulk parameters
408 * - (0) if successful.
409 * - (-EINVAL) on failure.
411 int tf_tbl_bulk_get(struct tf *tfp,
412 struct tf_tbl_get_bulk_parms *parms);
414 #endif /* TF_TBL_TYPE_H */