1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2021 Broadcom
6 #ifndef _TF_SHADOW_TBL_H_
7 #define _TF_SHADOW_TBL_H_
12 * The Shadow Table module provides shadow DB handling for table based
13 * TF types. A shadow DB provides the capability that allows for reuse
16 * A Shadow table DB is intended to be used by the Table Type module
21 * Shadow DB configuration information for a single table type.
23 * During Device initialization the HCAPI device specifics are learned
24 * and as well as the RM DB creation. From that those initial steps
25 * this structure can be populated.
28 * If used in an array of table types then such array must be ordered
29 * by the TF type is represents.
31 struct tf_shadow_tbl_cfg_parms {
33 * [in] The number of elements in the alloc_cnt and base_addr
34 * For now, it should always be equal to TF_TBL_TYPE_MAX
39 * [in] Resource allocation count array
40 * This array content originates from the tf_session_resources
41 * that is passed in on session open
42 * Array size is TF_TBL_TYPE_MAX
46 * [in] The base index for each table
48 uint16_t base_addr[TF_TBL_TYPE_MAX];
52 * Shadow table DB creation parameters
54 struct tf_shadow_tbl_create_db_parms {
56 * [in] Receive or transmit direction
60 * [in] Configuration information for the shadow db
62 struct tf_shadow_tbl_cfg_parms *cfg;
64 * [out] Shadow table DB handle
70 * Shadow table DB free parameters
72 struct tf_shadow_tbl_free_db_parms {
74 * [in] Shadow table DB handle
80 * Shadow table search parameters
82 struct tf_shadow_tbl_search_parms {
84 * [in] Shadow table DB handle
88 * [in,out] The search parms from tf core
90 struct tf_tbl_alloc_search_parms *sparms;
92 * [out] Reference count incremented if hit
98 * Shadow Table bind index parameters
100 struct tf_shadow_tbl_bind_index_parms {
102 * [in] Shadow tcam DB handle
106 * [in] receive or transmit direction
110 * [in] TCAM table type
112 enum tf_tbl_type type;
114 * [in] index of the entry to program
118 * [in] struct containing key
122 * [in] data size in bytes
124 uint16_t data_sz_in_bytes;
126 * [in] The hash bucket handled returned from the search
132 * Shadow table insert parameters
134 struct tf_shadow_tbl_insert_parms {
136 * [in] Shadow table DB handle
140 * [in] The insert parms from tf core
142 struct tf_tbl_set_parms *sparms;
146 * Shadow table remove parameters
148 struct tf_shadow_tbl_remove_parms {
150 * [in] Shadow table DB handle
154 * [in] The free parms from tf core
156 struct tf_tbl_free_parms *fparms;
160 * @page shadow_tbl Shadow table DB
162 * @ref tf_shadow_tbl_create_db
164 * @ref tf_shadow_tbl_free_db
166 * @reg tf_shadow_tbl_search
168 * @reg tf_shadow_tbl_insert
170 * @reg tf_shadow_tbl_remove
174 * Creates and fills a Shadow table DB. The DB is indexed per the
178 * Pointer to create db parameters
181 * - (0) if successful.
182 * - (-EINVAL) on failure.
184 int tf_shadow_tbl_create_db(struct tf_shadow_tbl_create_db_parms *parms);
187 * Closes the Shadow table DB and frees all allocated
188 * resources per the associated database.
191 * Pointer to the free DB parameters
194 * - (0) if successful.
195 * - (-EINVAL) on failure.
197 int tf_shadow_tbl_free_db(struct tf_shadow_tbl_free_db_parms *parms);
200 * Search Shadow table db for matching result
203 * Pointer to the search parameters
206 * - (0) if successful, element was found.
207 * - (-EINVAL) on failure.
209 * If there is a miss, but there is room for insertion, the hb_handle returned
210 * is used for insertion during the bind index API
212 int tf_shadow_tbl_search(struct tf_shadow_tbl_search_parms *parms);
215 * Bind Shadow table db hash and result tables with result from search/alloc
218 * Pointer to the search parameters
221 * - (0) if successful
222 * - (-EINVAL) on failure.
224 * This is only called after a MISS in the search returns a hb_handle
226 int tf_shadow_tbl_bind_index(struct tf_shadow_tbl_bind_index_parms *parms);
229 * Inserts an element into the Shadow table DB. Will fail if the
230 * elements ref_count is different from 0. Ref_count after insert will
234 * Pointer to insert parameters
237 * - (0) if successful.
238 * - (-EINVAL) on failure.
240 int tf_shadow_tbl_insert(struct tf_shadow_tbl_insert_parms *parms);
243 * Removes an element from the Shadow table DB. Will fail if the
244 * elements ref_count is 0. Ref_count after removal will be
248 * Pointer to remove parameter
251 * - (0) if successful.
252 * - (-EINVAL) on failure.
254 int tf_shadow_tbl_remove(struct tf_shadow_tbl_remove_parms *parms);
256 #endif /* _TF_SHADOW_TBL_H_ */