1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2021 Broadcom
15 * The Table module provides processing of Internal TF table types.
18 /** Invalid table scope id */
19 #define TF_TBL_SCOPE_INVALID 0xffffffff
22 * Table configuration parameters
24 struct tf_tbl_cfg_parms {
26 * Number of table types in each of the configuration arrays
28 uint16_t num_elements;
30 * Table Type element configuration array
32 struct tf_rm_element_cfg *cfg;
34 * Shadow table type configuration array
36 struct tf_shadow_tbl_cfg *shadow_cfg;
38 * Boolean controlling the request shadow copy.
42 * Session resource allocations
44 struct tf_session_resources *resources;
48 * Table allocation parameters
50 struct tf_tbl_alloc_parms {
52 * [in] Receive or transmit direction
56 * [in] Type of the allocation
58 enum tf_tbl_type type;
60 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
62 uint32_t tbl_scope_id;
64 * [out] Idx of allocated entry or found entry (if search_enable)
70 * Table free parameters
72 struct tf_tbl_free_parms {
74 * [in] Receive or transmit direction
78 * [in] Type of the allocation type
80 enum tf_tbl_type type;
82 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
84 uint32_t tbl_scope_id;
90 * [out] Reference count after free, only valid if session has been
91 * created with shadow_copy.
97 * Table allocate search parameters
99 struct tf_tbl_alloc_search_parms {
101 * [in] Receive or transmit direction
105 * [in] Type of the allocation
107 enum tf_tbl_type type;
109 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
111 uint32_t tbl_scope_id;
113 * [in] Result data to search for
117 * [in] Result data size in bytes
119 uint16_t result_sz_in_bytes;
121 * [in] Whether or not to allocate on MISS, 1 is allocate.
125 * [out] If search_enable, set if matching entry found
129 * [out] The status of the search (REJECT, MISS, HIT)
131 enum tf_search_status search_status;
133 * [out] Current ref count after allocation
137 * [out] Idx of allocated entry or found entry
143 * Table set parameters
145 struct tf_tbl_set_parms {
147 * [in] Receive or transmit direction
151 * [in] Type of object to set
153 enum tf_tbl_type type;
155 * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
157 uint32_t tbl_scope_id;
165 uint16_t data_sz_in_bytes;
167 * [in] Entry index to write to
173 * Table get parameters
175 struct tf_tbl_get_parms {
177 * [in] Receive or transmit direction
181 * [in] Type of object to get
183 enum tf_tbl_type type;
191 uint16_t data_sz_in_bytes;
193 * [in] Entry index to read
199 * Table get bulk parameters
201 struct tf_tbl_get_bulk_parms {
203 * [in] Receive or transmit direction
207 * [in] Type of object to get
209 enum tf_tbl_type type;
211 * [in] Starting index to read from
213 uint32_t starting_idx;
215 * [in] Number of sequential entries
217 uint16_t num_entries;
219 * [in] Size of the single entry
221 uint16_t entry_sz_in_bytes;
223 * [out] Host physical address, where the data
224 * will be copied to by the firmware.
225 * Use tfp_calloc() API and mem_pa
226 * variable of the tfp_calloc_parms
227 * structure for the physical address.
229 uint64_t physical_mem_addr;
239 struct rm_db *tbl_db[TF_DIR_MAX];
253 * @ref tf_tbl_alloc_search
259 * @ref tf_tbl_bulk_get
263 * Initializes the Table module with the requested DBs. Must be
264 * invoked as the first thing before any of the access functions.
267 * Pointer to TF handle, used for HCAPI communication
270 * Pointer to Table configuration parameters
273 * - (0) if successful.
274 * - (-EINVAL) on failure.
276 int tf_tbl_bind(struct tf *tfp,
277 struct tf_tbl_cfg_parms *parms);
280 * Cleans up the private DBs and releases all the data.
283 * Pointer to TF handle, used for HCAPI communication
286 * Pointer to parameters
289 * - (0) if successful.
290 * - (-EINVAL) on failure.
292 int tf_tbl_unbind(struct tf *tfp);
295 * Allocates the requested table type from the internal RM DB.
298 * Pointer to TF handle, used for HCAPI communication
301 * Pointer to Table allocation parameters
304 * - (0) if successful.
305 * - (-EINVAL) on failure.
307 int tf_tbl_alloc(struct tf *tfp,
308 struct tf_tbl_alloc_parms *parms);
311 * Free's the requested table type and returns it to the DB. If shadow
312 * DB is enabled its searched first and if found the element refcount
313 * is decremented. If refcount goes to 0 then its returned to the
317 * Pointer to TF handle, used for HCAPI communication
320 * Pointer to Table free parameters
323 * - (0) if successful.
324 * - (-EINVAL) on failure.
326 int tf_tbl_free(struct tf *tfp,
327 struct tf_tbl_free_parms *parms);
330 * Supported if Shadow DB is configured. Searches the Shadow DB for
331 * any matching element. If found the refcount in the shadow DB is
332 * updated accordingly. If not found a new element is allocated and
333 * installed into the shadow DB.
336 * Pointer to TF handle, used for HCAPI communication
339 * Pointer to parameters
342 * - (0) if successful.
343 * - (-EINVAL) on failure.
345 int tf_tbl_alloc_search(struct tf *tfp,
346 struct tf_tbl_alloc_search_parms *parms);
349 * Configures the requested element by sending a firmware request which
350 * then installs it into the device internal structures.
353 * Pointer to TF handle, used for HCAPI communication
356 * Pointer to Table set parameters
359 * - (0) if successful.
360 * - (-EINVAL) on failure.
362 int tf_tbl_set(struct tf *tfp,
363 struct tf_tbl_set_parms *parms);
366 * Retrieves the requested element by sending a firmware request to get
370 * Pointer to TF handle, used for HCAPI communication
373 * Pointer to Table get parameters
376 * - (0) if successful.
377 * - (-EINVAL) on failure.
379 int tf_tbl_get(struct tf *tfp,
380 struct tf_tbl_get_parms *parms);
383 * Retrieves bulk block of elements by sending a firmware request to
387 * Pointer to TF handle, used for HCAPI communication
390 * Pointer to Table get bulk parameters
393 * - (0) if successful.
394 * - (-EINVAL) on failure.
396 int tf_tbl_bulk_get(struct tf *tfp,
397 struct tf_tbl_get_bulk_parms *parms);
399 #endif /* TF_TBL_TYPE_H */