1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2020 Broadcom
12 * The TCAM module provides processing of Internal TCAM types.
16 * TCAM configuration parameters
18 struct tf_tcam_cfg_parms {
20 * Number of tcam types in each of the configuration arrays
22 uint16_t num_elements;
25 * TCAM configuration array
27 struct tf_rm_element_cfg *tcam_cfg[TF_DIR_MAX];
30 * Shadow table type configuration array
32 struct tf_shadow_tcam_cfg *tcam_shadow_cfg[TF_DIR_MAX];
36 * TCAM allocation parameters
38 struct tf_tcam_alloc_parms {
40 * [in] Receive or transmit direction
44 * [in] Type of the allocation
46 enum tf_tcam_tbl_type type;
48 * [out] Idx of allocated entry or found entry (if search_enable)
54 * TCAM free parameters
56 struct tf_tcam_free_parms {
58 * [in] Receive or transmit direction
62 * [in] Type of the allocation type
64 enum tf_tcam_tbl_type type;
70 * [out] Reference count after free, only valid if session has been
71 * created with shadow_copy.
77 * TCAM allocate search parameters
79 struct tf_tcam_alloc_search_parms {
81 * [in] receive or transmit direction
85 * [in] TCAM table type
87 enum tf_tcam_tbl_type tcam_tbl_type;
89 * [in] Enable search for matching entry
91 uint8_t search_enable;
93 * [in] Key data to match on (if search)
97 * [in] key size in bits (if search)
99 uint16_t key_sz_in_bits;
101 * [in] Mask data to match on (if search)
105 * [in] Priority of entry requested (definition TBD)
109 * [out] If search, set if matching entry found
113 * [out] Current refcnt after allocation
117 * [out] Idx allocated
124 * TCAM set parameters
126 struct tf_tcam_set_parms {
128 * [in] Receive or transmit direction
132 * [in] Type of object to set
134 enum tf_tcam_tbl_type type;
142 uint16_t data_sz_in_bytes;
144 * [in] Entry index to write to
150 * TCAM get parameters
152 struct tf_tcam_get_parms {
154 * [in] Receive or transmit direction
158 * [in] Type of object to get
160 enum tf_tcam_tbl_type type;
168 uint16_t data_sz_in_bytes;
170 * [in] Entry index to read
180 * @ref tf_tcam_unbind
186 * @ref tf_tcam_alloc_search
195 * Initializes the TCAM module with the requested DBs. Must be
196 * invoked as the first thing before any of the access functions.
199 * Pointer to TF handle, used for HCAPI communication
202 * Pointer to parameters
205 * - (0) if successful.
206 * - (-EINVAL) on failure.
208 int tf_tcam_bind(struct tf *tfp,
209 struct tf_tcam_cfg_parms *parms);
212 * Cleans up the private DBs and releases all the data.
215 * Pointer to TF handle, used for HCAPI communication
218 * Pointer to parameters
221 * - (0) if successful.
222 * - (-EINVAL) on failure.
224 int tf_tcam_unbind(struct tf *tfp);
227 * Allocates the requested tcam type from the internal RM DB.
230 * Pointer to TF handle, used for HCAPI communication
233 * Pointer to parameters
236 * - (0) if successful.
237 * - (-EINVAL) on failure.
239 int tf_tcam_alloc(struct tf *tfp,
240 struct tf_tcam_alloc_parms *parms);
243 * Free's the requested table type and returns it to the DB. If shadow
244 * DB is enabled its searched first and if found the element refcount
245 * is decremented. If refcount goes to 0 then its returned to the
249 * Pointer to TF handle, used for HCAPI communication
252 * Pointer to parameters
255 * - (0) if successful.
256 * - (-EINVAL) on failure.
258 int tf_tcam_free(struct tf *tfp,
259 struct tf_tcam_free_parms *parms);
262 * Supported if Shadow DB is configured. Searches the Shadow DB for
263 * any matching element. If found the refcount in the shadow DB is
264 * updated accordingly. If not found a new element is allocated and
265 * installed into the shadow DB.
268 * Pointer to TF handle, used for HCAPI communication
271 * Pointer to parameters
274 * - (0) if successful.
275 * - (-EINVAL) on failure.
277 int tf_tcam_alloc_search(struct tf *tfp,
278 struct tf_tcam_alloc_search_parms *parms);
281 * Configures the requested element by sending a firmware request which
282 * then installs it into the device internal structures.
285 * Pointer to TF handle, used for HCAPI communication
288 * Pointer to parameters
291 * - (0) if successful.
292 * - (-EINVAL) on failure.
294 int tf_tcam_set(struct tf *tfp,
295 struct tf_tcam_set_parms *parms);
298 * Retrieves the requested element by sending a firmware request to get
302 * Pointer to TF handle, used for HCAPI communication
305 * Pointer to parameters
308 * - (0) if successful.
309 * - (-EINVAL) on failure.
311 int tf_tcam_get(struct tf *tfp,
312 struct tf_tcam_get_parms *parms);
314 #endif /* _TF_TCAM_H */