1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2020 Broadcom
6 #ifndef _TF_SHADOW_TBL_H_
7 #define _TF_SHADOW_TBL_H_
14 * The Shadow Table module provides shadow DB handling for table based
15 * TF types. A shadow DB provides the capability that allows for reuse
18 * A Shadow table DB is intended to be used by the Table Type module
23 * Shadow DB configuration information for a single table type.
25 * During Device initialization the HCAPI device specifics are learned
26 * and as well as the RM DB creation. From that those initial steps
27 * this structure can be populated.
30 * If used in an array of table types then such array must be ordered
31 * by the TF type is represents.
33 struct tf_shadow_tbl_cfg_parms {
37 enum tf_tbl_type type;
40 * Number of entries the Shadow DB needs to hold
45 * Element width for this table type
51 * Shadow table DB creation parameters
53 struct tf_shadow_tbl_create_db_parms {
55 * [in] Configuration information for the shadow db
57 struct tf_shadow_tbl_cfg_parms *cfg;
59 * [in] Number of elements in the parms structure
61 uint16_t num_elements;
63 * [out] Shadow table DB handle
65 void *tf_shadow_tbl_db;
69 * Shadow table DB free parameters
71 struct tf_shadow_tbl_free_db_parms {
73 * Shadow table DB handle
75 void *tf_shadow_tbl_db;
79 * Shadow table search parameters
81 struct tf_shadow_tbl_search_parms {
83 * [in] Shadow table DB handle
85 void *tf_shadow_tbl_db;
89 enum tf_tbl_type type;
91 * [in] Pointer to entry blob value in remap table to match
95 * [in] Size of the entry blob passed in bytes
99 * [out] Index of the found element returned if hit
103 * [out] Reference count incremented if hit
109 * Shadow table insert parameters
111 struct tf_shadow_tbl_insert_parms {
113 * [in] Shadow table DB handle
115 void *tf_shadow_tbl_db;
119 enum tf_tbl_type type;
121 * [in] Pointer to entry blob value in remap table to match
125 * [in] Size of the entry blob passed in bytes
129 * [in] Entry to update
133 * [out] Reference count after insert
139 * Shadow table remove parameters
141 struct tf_shadow_tbl_remove_parms {
143 * [in] Shadow table DB handle
145 void *tf_shadow_tbl_db;
149 enum tf_tbl_type type;
151 * [in] Entry to update
155 * [out] Reference count after removal
161 * @page shadow_tbl Shadow table DB
163 * @ref tf_shadow_tbl_create_db
165 * @ref tf_shadow_tbl_free_db
167 * @reg tf_shadow_tbl_search
169 * @reg tf_shadow_tbl_insert
171 * @reg tf_shadow_tbl_remove
175 * Creates and fills a Shadow table DB. The DB is indexed per the
179 * Pointer to create db parameters
182 * - (0) if successful.
183 * - (-EINVAL) on failure.
185 int tf_shadow_tbl_create_db(struct tf_shadow_tbl_create_db_parms *parms);
188 * Closes the Shadow table DB and frees all allocated
189 * resources per the associated database.
192 * Pointer to the free DB parameters
195 * - (0) if successful.
196 * - (-EINVAL) on failure.
198 int tf_shadow_tbl_free_db(struct tf_shadow_tbl_free_db_parms *parms);
201 * Search Shadow table db for matching result
204 * Pointer to the search parameters
207 * - (0) if successful, element was found.
208 * - (-EINVAL) on failure.
210 int tf_shadow_tbl_search(struct tf_shadow_tbl_search_parms *parms);
213 * Inserts an element into the Shadow table DB. Will fail if the
214 * elements ref_count is different from 0. Ref_count after insert will
218 * Pointer to insert parameters
221 * - (0) if successful.
222 * - (-EINVAL) on failure.
224 int tf_shadow_tbl_insert(struct tf_shadow_tbl_insert_parms *parms);
227 * Removes an element from the Shadow table DB. Will fail if the
228 * elements ref_count is 0. Ref_count after removal will be
232 * Pointer to remove parameter
235 * - (0) if successful.
236 * - (-EINVAL) on failure.
238 int tf_shadow_tbl_remove(struct tf_shadow_tbl_remove_parms *parms);
240 #endif /* _TF_SHADOW_TBL_H_ */