1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2021 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;
24 * TCAM configuration array
26 struct tf_rm_element_cfg *cfg;
28 * Shadow table type configuration array
30 struct tf_shadow_tcam_cfg *shadow_cfg;
32 * Boolean controlling the request shadow copy.
36 * Session resource allocations
38 struct tf_session_resources *resources;
42 * TCAM allocation parameters
44 struct tf_tcam_alloc_parms {
46 * [in] Receive or transmit direction
50 * [in] Type of the allocation
52 enum tf_tcam_tbl_type type;
58 * [in] Priority of entry requested (definition TBD)
62 * [out] Idx of allocated entry or found entry (if search_enable)
68 * TCAM free parameters
70 struct tf_tcam_free_parms {
72 * [in] Receive or transmit direction
76 * [in] Type of the allocation type
78 enum tf_tcam_tbl_type type;
88 * [out] Reference count after free, only valid if session has been
89 * created with shadow_copy.
95 * TCAM allocate search parameters
97 struct tf_tcam_alloc_search_parms {
99 * [in] receive or transmit direction
103 * [in] TCAM table type
105 enum tf_tcam_tbl_type type;
111 * [in] Key data to match on
115 * [in] key size in bits
119 * [in] Mask data to match on
123 * [in] Priority of entry requested (definition TBD)
127 * [in] Allocate on miss.
131 * [out] Set if matching entry found
135 * [out] Search result status (hit, miss, reject)
137 enum tf_search_status search_status;
139 * [out] Current refcnt after allocation
143 * [in,out] The result data from the search is copied here
147 * [in,out] result size in bits for the result data
149 uint16_t result_size;
157 * TCAM set parameters
159 struct tf_tcam_set_parms {
161 * [in] Receive or transmit direction
165 * [in] Type of object to set
167 enum tf_tcam_tbl_type type;
173 * [in] Entry index to write to
177 * [in] array containing key
181 * [in] array containing mask fields
189 * [in] array containing result
195 uint16_t result_size;
199 * TCAM get parameters
201 struct tf_tcam_get_parms {
203 * [in] Receive or transmit direction
207 * [in] Type of object to get
209 enum tf_tcam_tbl_type type;
215 * [in] Entry index to read
219 * [out] array containing key
223 * [out] array containing mask fields
231 * [out] array containing result
237 uint16_t result_size;
247 struct rm_db *tcam_db[TF_DIR_MAX];
255 * @ref tf_tcam_unbind
261 * @ref tf_tcam_alloc_search
270 * Initializes the TCAM module with the requested DBs. Must be
271 * invoked as the first thing before any of the access functions.
274 * Pointer to TF handle, used for HCAPI communication
277 * Pointer to parameters
280 * - (0) if successful.
281 * - (-EINVAL) on failure.
283 int tf_tcam_bind(struct tf *tfp,
284 struct tf_tcam_cfg_parms *parms);
287 * Cleans up the private DBs and releases all the data.
290 * Pointer to TF handle, used for HCAPI communication
293 * Pointer to parameters
296 * - (0) if successful.
297 * - (-EINVAL) on failure.
299 int tf_tcam_unbind(struct tf *tfp);
302 * Allocates the requested tcam type from the internal RM DB.
305 * Pointer to TF handle, used for HCAPI communication
308 * Pointer to parameters
311 * - (0) if successful.
312 * - (-EINVAL) on failure.
314 int tf_tcam_alloc(struct tf *tfp,
315 struct tf_tcam_alloc_parms *parms);
318 * Free's the requested table type and returns it to the DB. If shadow
319 * DB is enabled its searched first and if found the element refcount
320 * is decremented. If refcount goes to 0 then its returned to the
324 * Pointer to TF handle, used for HCAPI communication
327 * Pointer to parameters
330 * - (0) if successful.
331 * - (-EINVAL) on failure.
333 int tf_tcam_free(struct tf *tfp,
334 struct tf_tcam_free_parms *parms);
337 * Supported if Shadow DB is configured. Searches the Shadow DB for
338 * any matching element. If found the refcount in the shadow DB is
339 * updated accordingly. If not found a new element is allocated and
340 * installed into the shadow DB.
343 * Pointer to TF handle, used for HCAPI communication
346 * Pointer to parameters
349 * - (0) if successful.
350 * - (-EINVAL) on failure.
352 int tf_tcam_alloc_search(struct tf *tfp,
353 struct tf_tcam_alloc_search_parms *parms);
356 * Configures the requested element by sending a firmware request which
357 * then installs it into the device internal structures.
360 * Pointer to TF handle, used for HCAPI communication
363 * Pointer to parameters
366 * - (0) if successful.
367 * - (-EINVAL) on failure.
369 int tf_tcam_set(struct tf *tfp,
370 struct tf_tcam_set_parms *parms);
373 * Retrieves the requested element by sending a firmware request to get
377 * Pointer to TF handle, used for HCAPI communication
380 * Pointer to parameters
383 * - (0) if successful.
384 * - (-EINVAL) on failure.
386 int tf_tcam_get(struct tf *tfp,
387 struct tf_tcam_get_parms *parms);
389 #endif /* _TF_TCAM_H */