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] Result data to search for
144 * [in] Result data size in bytes
146 uint16_t result_sz_in_bytes;
148 * [in] Whether or not to allocate on MISS, 1 is allocate.
152 * [out] If search_enable, set if matching entry found
156 * [out] The status of the search (REJECT, MISS, HIT)
158 enum tf_search_status search_status;
160 * [out] Current ref count after allocation
164 * [out] Idx of allocated entry or found entry
170 * Table set parameters
172 struct tf_tbl_set_parms {
174 * [in] Receive or transmit direction
178 * [in] Type of object to set
180 enum tf_tbl_type type;
182 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
184 uint32_t tbl_scope_id;
192 uint16_t data_sz_in_bytes;
194 * [in] Entry index to write to
200 * Table get parameters
202 struct tf_tbl_get_parms {
204 * [in] Receive or transmit direction
208 * [in] Type of object to get
210 enum tf_tbl_type type;
218 uint16_t data_sz_in_bytes;
220 * [in] Entry index to read
226 * Table get bulk parameters
228 struct tf_tbl_get_bulk_parms {
230 * [in] Receive or transmit direction
234 * [in] Type of object to get
236 enum tf_tbl_type type;
238 * [in] Starting index to read from
240 uint32_t starting_idx;
242 * [in] Number of sequential entries
244 uint16_t num_entries;
246 * [in] Size of the single entry
248 uint16_t entry_sz_in_bytes;
250 * [out] Host physical address, where the data
251 * will be copied to by the firmware.
252 * Use tfp_calloc() API and mem_pa
253 * variable of the tfp_calloc_parms
254 * structure for the physical address.
256 uint64_t physical_mem_addr;
270 * @ref tf_tbl_alloc_search
276 * @ref tf_tbl_bulk_get
280 * Initializes the Table module with the requested DBs. Must be
281 * invoked as the first thing before any of the access functions.
284 * Pointer to TF handle, used for HCAPI communication
287 * Pointer to Table configuration parameters
290 * - (0) if successful.
291 * - (-EINVAL) on failure.
293 int tf_tbl_bind(struct tf *tfp,
294 struct tf_tbl_cfg_parms *parms);
297 * Cleans up the private DBs and releases all the data.
300 * Pointer to TF handle, used for HCAPI communication
303 * Pointer to parameters
306 * - (0) if successful.
307 * - (-EINVAL) on failure.
309 int tf_tbl_unbind(struct tf *tfp);
312 * Allocates the requested table type from the internal RM DB.
315 * Pointer to TF handle, used for HCAPI communication
318 * Pointer to Table allocation parameters
321 * - (0) if successful.
322 * - (-EINVAL) on failure.
324 int tf_tbl_alloc(struct tf *tfp,
325 struct tf_tbl_alloc_parms *parms);
328 * Free's the requested table type and returns it to the DB. If shadow
329 * DB is enabled its searched first and if found the element refcount
330 * is decremented. If refcount goes to 0 then its returned to the
334 * Pointer to TF handle, used for HCAPI communication
337 * Pointer to Table free parameters
340 * - (0) if successful.
341 * - (-EINVAL) on failure.
343 int tf_tbl_free(struct tf *tfp,
344 struct tf_tbl_free_parms *parms);
347 * Supported if Shadow DB is configured. Searches the Shadow DB for
348 * any matching element. If found the refcount in the shadow DB is
349 * updated accordingly. If not found a new element is allocated and
350 * installed into the shadow DB.
353 * Pointer to TF handle, used for HCAPI communication
356 * Pointer to parameters
359 * - (0) if successful.
360 * - (-EINVAL) on failure.
362 int tf_tbl_alloc_search(struct tf *tfp,
363 struct tf_tbl_alloc_search_parms *parms);
366 * Configures the requested element by sending a firmware request which
367 * then installs it into the device internal structures.
370 * Pointer to TF handle, used for HCAPI communication
373 * Pointer to Table set parameters
376 * - (0) if successful.
377 * - (-EINVAL) on failure.
379 int tf_tbl_set(struct tf *tfp,
380 struct tf_tbl_set_parms *parms);
383 * Retrieves the requested element by sending a firmware request to get
387 * Pointer to TF handle, used for HCAPI communication
390 * Pointer to Table get parameters
393 * - (0) if successful.
394 * - (-EINVAL) on failure.
396 int tf_tbl_get(struct tf *tfp,
397 struct tf_tbl_get_parms *parms);
400 * Retrieves bulk block of elements by sending a firmware request to
404 * Pointer to TF handle, used for HCAPI communication
407 * Pointer to Table get bulk parameters
410 * - (0) if successful.
411 * - (-EINVAL) on failure.
413 int tf_tbl_bulk_get(struct tf *tfp,
414 struct tf_tbl_get_bulk_parms *parms);
416 #endif /* TF_TBL_TYPE_H */