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;
245 * @ref tf_tcam_unbind
251 * @ref tf_tcam_alloc_search
260 * Initializes the TCAM module with the requested DBs. Must be
261 * invoked as the first thing before any of the access functions.
264 * Pointer to TF handle, used for HCAPI communication
267 * Pointer to parameters
270 * - (0) if successful.
271 * - (-EINVAL) on failure.
273 int tf_tcam_bind(struct tf *tfp,
274 struct tf_tcam_cfg_parms *parms);
277 * Cleans up the private DBs and releases all the data.
280 * Pointer to TF handle, used for HCAPI communication
283 * Pointer to parameters
286 * - (0) if successful.
287 * - (-EINVAL) on failure.
289 int tf_tcam_unbind(struct tf *tfp);
292 * Allocates the requested tcam type from the internal RM DB.
295 * Pointer to TF handle, used for HCAPI communication
298 * Pointer to parameters
301 * - (0) if successful.
302 * - (-EINVAL) on failure.
304 int tf_tcam_alloc(struct tf *tfp,
305 struct tf_tcam_alloc_parms *parms);
308 * Free's the requested table type and returns it to the DB. If shadow
309 * DB is enabled its searched first and if found the element refcount
310 * is decremented. If refcount goes to 0 then its returned to the
314 * Pointer to TF handle, used for HCAPI communication
317 * Pointer to parameters
320 * - (0) if successful.
321 * - (-EINVAL) on failure.
323 int tf_tcam_free(struct tf *tfp,
324 struct tf_tcam_free_parms *parms);
327 * Supported if Shadow DB is configured. Searches the Shadow DB for
328 * any matching element. If found the refcount in the shadow DB is
329 * updated accordingly. If not found a new element is allocated and
330 * installed into the shadow DB.
333 * Pointer to TF handle, used for HCAPI communication
336 * Pointer to parameters
339 * - (0) if successful.
340 * - (-EINVAL) on failure.
342 int tf_tcam_alloc_search(struct tf *tfp,
343 struct tf_tcam_alloc_search_parms *parms);
346 * Configures the requested element by sending a firmware request which
347 * then installs it into the device internal structures.
350 * Pointer to TF handle, used for HCAPI communication
353 * Pointer to parameters
356 * - (0) if successful.
357 * - (-EINVAL) on failure.
359 int tf_tcam_set(struct tf *tfp,
360 struct tf_tcam_set_parms *parms);
363 * Retrieves the requested element by sending a firmware request to get
367 * Pointer to TF handle, used for HCAPI communication
370 * Pointer to parameters
373 * - (0) if successful.
374 * - (-EINVAL) on failure.
376 int tf_tcam_get(struct tf *tfp,
377 struct tf_tcam_get_parms *parms);
379 #endif /* _TF_TCAM_H */