1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2020 Broadcom
6 #ifndef _TF_SHADOW_TCAM_H_
7 #define _TF_SHADOW_TCAM_H_
14 * The Shadow tcam module provides shadow DB handling for tcam based
15 * TF types. A shadow DB provides the capability that allows for reuse
18 * A Shadow tcam DB is intended to be used by the Tcam module only.
22 * Shadow DB configuration information for a single tcam type.
24 * During Device initialization the HCAPI device specifics are learned
25 * and as well as the RM DB creation. From that those initial steps
26 * this structure can be populated.
29 * If used in an array of tcam types then such array must be ordered
30 * by the TF type is represents.
32 struct tf_shadow_tcam_cfg_parms {
36 enum tf_tcam_tbl_type type;
39 * Number of entries the Shadow DB needs to hold
44 * Element width for this table type
50 * Shadow tcam DB creation parameters
52 struct tf_shadow_tcam_create_db_parms {
54 * [in] Configuration information for the shadow db
56 struct tf_shadow_tcam_cfg_parms *cfg;
58 * [in] Number of elements in the parms structure
60 uint16_t num_elements;
62 * [out] Shadow tcam DB handle
64 void *tf_shadow_tcam_db;
68 * Shadow tcam DB free parameters
70 struct tf_shadow_tcam_free_db_parms {
72 * Shadow tcam DB handle
74 void *tf_shadow_tcam_db;
78 * Shadow tcam search parameters
80 struct tf_shadow_tcam_search_parms {
82 * [in] Shadow tcam DB handle
84 void *tf_shadow_tcam_db;
88 enum tf_tcam_tbl_type type;
90 * [in] Pointer to entry blob value in remap table to match
94 * [in] Size of the entry blob passed in bytes
98 * [out] Index of the found element returned if hit
102 * [out] Reference count incremented if hit
108 * Shadow tcam insert parameters
110 struct tf_shadow_tcam_insert_parms {
112 * [in] Shadow tcam DB handle
114 void *tf_shadow_tcam_db;
118 enum tf_tcam_tbl_type type;
120 * [in] Pointer to entry blob value in remap table to match
124 * [in] Size of the entry blob passed in bytes
128 * [in] Entry to update
132 * [out] Reference count after insert
138 * Shadow tcam remove parameters
140 struct tf_shadow_tcam_remove_parms {
142 * [in] Shadow tcam DB handle
144 void *tf_shadow_tcam_db;
148 enum tf_tcam_tbl_type type;
150 * [in] Entry to update
154 * [out] Reference count after removal
160 * @page shadow_tcam Shadow tcam DB
162 * @ref tf_shadow_tcam_create_db
164 * @ref tf_shadow_tcam_free_db
166 * @reg tf_shadow_tcam_search
168 * @reg tf_shadow_tcam_insert
170 * @reg tf_shadow_tcam_remove
174 * Creates and fills a Shadow tcam 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_tcam_create_db(struct tf_shadow_tcam_create_db_parms *parms);
187 * Closes the Shadow tcam 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_tcam_free_db(struct tf_shadow_tcam_free_db_parms *parms);
200 * Search Shadow tcam db for matching result
203 * Pointer to the search parameters
206 * - (0) if successful, element was found.
207 * - (-EINVAL) on failure.
209 int tf_shadow_tcam_search(struct tf_shadow_tcam_search_parms *parms);
212 * Inserts an element into the Shadow tcam DB. Will fail if the
213 * elements ref_count is different from 0. Ref_count after insert will
217 * Pointer to insert parameters
220 * - (0) if successful.
221 * - (-EINVAL) on failure.
223 int tf_shadow_tcam_insert(struct tf_shadow_tcam_insert_parms *parms);
226 * Removes an element from the Shadow tcam DB. Will fail if the
227 * elements ref_count is 0. Ref_count after removal will be
231 * Pointer to remove parameter
234 * - (0) if successful.
235 * - (-EINVAL) on failure.
237 int tf_shadow_tcam_remove(struct tf_shadow_tcam_remove_parms *parms);
239 #endif /* _TF_SHADOW_TCAM_H_ */