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 * [out] Idx of allocated entry or found entry (if search_enable)
93 * Table free parameters
95 struct tf_tbl_free_parms {
97 * [in] Receive or transmit direction
101 * [in] Type of the allocation type
103 enum tf_tbl_type type;
109 * [out] Reference count after free, only valid if session has been
110 * created with shadow_copy.
116 * Table allocate search parameters
118 struct tf_tbl_alloc_search_parms {
120 * [in] Receive or transmit direction
124 * [in] Type of the allocation
126 enum tf_tbl_type type;
128 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
130 uint32_t tbl_scope_id;
132 * [in] Enable search for matching entry. If the table type is
133 * internal the shadow copy will be searched before
134 * alloc. Session must be configured with shadow copy enabled.
136 uint8_t search_enable;
138 * [in] Result data to search for (if search_enable)
142 * [in] Result data size in bytes (if search_enable)
144 uint16_t result_sz_in_bytes;
146 * [out] If search_enable, set if matching entry found
150 * [out] Current ref count after allocation (if search_enable)
154 * [out] Idx of allocated entry or found entry (if search_enable)
160 * Table set parameters
162 struct tf_tbl_set_parms {
164 * [in] Receive or transmit direction
168 * [in] Type of object to set
170 enum tf_tbl_type type;
178 uint16_t data_sz_in_bytes;
180 * [in] Entry index to write to
186 * Table get parameters
188 struct tf_tbl_get_parms {
190 * [in] Receive or transmit direction
194 * [in] Type of object to get
196 enum tf_tbl_type type;
204 uint16_t data_sz_in_bytes;
206 * [in] Entry index to read
212 * Table get bulk parameters
214 struct tf_tbl_get_bulk_parms {
216 * [in] Receive or transmit direction
220 * [in] Type of object to get
222 enum tf_tbl_type type;
224 * [in] Starting index to read from
226 uint32_t starting_idx;
228 * [in] Number of sequential entries
230 uint16_t num_entries;
232 * [in] Size of the single entry
234 uint16_t entry_sz_in_bytes;
236 * [out] Host physical address, where the data
237 * will be copied to by the firmware.
238 * Use tfp_calloc() API and mem_pa
239 * variable of the tfp_calloc_parms
240 * structure for the physical address.
242 uint64_t physical_mem_addr;
256 * @ref tf_tbl_alloc_search
262 * @ref tf_tbl_bulk_get
266 * Initializes the Table module with the requested DBs. Must be
267 * invoked as the first thing before any of the access functions.
270 * Pointer to TF handle, used for HCAPI communication
273 * Pointer to Table configuration parameters
276 * - (0) if successful.
277 * - (-EINVAL) on failure.
279 int tf_tbl_bind(struct tf *tfp,
280 struct tf_tbl_cfg_parms *parms);
283 * Cleans up the private DBs and releases all the data.
286 * Pointer to TF handle, used for HCAPI communication
289 * Pointer to parameters
292 * - (0) if successful.
293 * - (-EINVAL) on failure.
295 int tf_tbl_unbind(struct tf *tfp);
298 * Allocates the requested table type from the internal RM DB.
301 * Pointer to TF handle, used for HCAPI communication
304 * Pointer to Table allocation parameters
307 * - (0) if successful.
308 * - (-EINVAL) on failure.
310 int tf_tbl_alloc(struct tf *tfp,
311 struct tf_tbl_alloc_parms *parms);
314 * Free's the requested table type and returns it to the DB. If shadow
315 * DB is enabled its searched first and if found the element refcount
316 * is decremented. If refcount goes to 0 then its returned to the
320 * Pointer to TF handle, used for HCAPI communication
323 * Pointer to Table free parameters
326 * - (0) if successful.
327 * - (-EINVAL) on failure.
329 int tf_tbl_free(struct tf *tfp,
330 struct tf_tbl_free_parms *parms);
333 * Supported if Shadow DB is configured. Searches the Shadow DB for
334 * any matching element. If found the refcount in the shadow DB is
335 * updated accordingly. If not found a new element is allocated and
336 * installed into the shadow DB.
339 * Pointer to TF handle, used for HCAPI communication
342 * Pointer to parameters
345 * - (0) if successful.
346 * - (-EINVAL) on failure.
348 int tf_tbl_alloc_search(struct tf *tfp,
349 struct tf_tbl_alloc_search_parms *parms);
352 * Configures the requested element by sending a firmware request which
353 * then installs it into the device internal structures.
356 * Pointer to TF handle, used for HCAPI communication
359 * Pointer to Table set parameters
362 * - (0) if successful.
363 * - (-EINVAL) on failure.
365 int tf_tbl_set(struct tf *tfp,
366 struct tf_tbl_set_parms *parms);
369 * Retrieves the requested element by sending a firmware request to get
373 * Pointer to TF handle, used for HCAPI communication
376 * Pointer to Table get parameters
379 * - (0) if successful.
380 * - (-EINVAL) on failure.
382 int tf_tbl_get(struct tf *tfp,
383 struct tf_tbl_get_parms *parms);
386 * Retrieves bulk block of elements by sending a firmware request to
390 * Pointer to TF handle, used for HCAPI communication
393 * Pointer to Table get bulk parameters
396 * - (0) if successful.
397 * - (-EINVAL) on failure.
399 int tf_tbl_bulk_get(struct tf *tfp,
400 struct tf_tbl_get_bulk_parms *parms);
402 #endif /* TF_TBL_TYPE_H */