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;
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;
84 * [out] Reference count after free, only valid if session has been
85 * created with shadow_copy.
91 * TCAM allocate search parameters
93 struct tf_tcam_alloc_search_parms {
95 * [in] receive or transmit direction
99 * [in] TCAM table type
101 enum tf_tcam_tbl_type type;
103 * [in] Enable search for matching entry
105 uint8_t search_enable;
107 * [in] Key data to match on (if search)
111 * [in] key size (if search)
115 * [in] Mask data to match on (if search)
119 * [in] Priority of entry requested (definition TBD)
123 * [out] If search, set if matching entry found
127 * [out] Current refcnt after allocation
131 * [out] Idx allocated
138 * TCAM set parameters
140 struct tf_tcam_set_parms {
142 * [in] Receive or transmit direction
146 * [in] Type of object to set
148 enum tf_tcam_tbl_type type;
154 * [in] Entry index to write to
158 * [in] array containing key
162 * [in] array containing mask fields
170 * [in] array containing result
176 uint16_t result_size;
180 * TCAM get parameters
182 struct tf_tcam_get_parms {
184 * [in] Receive or transmit direction
188 * [in] Type of object to get
190 enum tf_tcam_tbl_type type;
192 * [in] Entry index to read
196 * [out] array containing key
200 * [out] array containing mask fields
208 * [out] array containing result
214 uint16_t result_size;
222 * @ref tf_tcam_unbind
228 * @ref tf_tcam_alloc_search
237 * Initializes the TCAM module with the requested DBs. Must be
238 * invoked as the first thing before any of the access functions.
241 * Pointer to TF handle, used for HCAPI communication
244 * Pointer to parameters
247 * - (0) if successful.
248 * - (-EINVAL) on failure.
250 int tf_tcam_bind(struct tf *tfp,
251 struct tf_tcam_cfg_parms *parms);
254 * Cleans up the private DBs and releases all the data.
257 * Pointer to TF handle, used for HCAPI communication
260 * Pointer to parameters
263 * - (0) if successful.
264 * - (-EINVAL) on failure.
266 int tf_tcam_unbind(struct tf *tfp);
269 * Allocates the requested tcam type from the internal RM DB.
272 * Pointer to TF handle, used for HCAPI communication
275 * Pointer to parameters
278 * - (0) if successful.
279 * - (-EINVAL) on failure.
281 int tf_tcam_alloc(struct tf *tfp,
282 struct tf_tcam_alloc_parms *parms);
285 * Free's the requested table type and returns it to the DB. If shadow
286 * DB is enabled its searched first and if found the element refcount
287 * is decremented. If refcount goes to 0 then its returned to the
291 * Pointer to TF handle, used for HCAPI communication
294 * Pointer to parameters
297 * - (0) if successful.
298 * - (-EINVAL) on failure.
300 int tf_tcam_free(struct tf *tfp,
301 struct tf_tcam_free_parms *parms);
304 * Supported if Shadow DB is configured. Searches the Shadow DB for
305 * any matching element. If found the refcount in the shadow DB is
306 * updated accordingly. If not found a new element is allocated and
307 * installed into the shadow DB.
310 * Pointer to TF handle, used for HCAPI communication
313 * Pointer to parameters
316 * - (0) if successful.
317 * - (-EINVAL) on failure.
319 int tf_tcam_alloc_search(struct tf *tfp,
320 struct tf_tcam_alloc_search_parms *parms);
323 * Configures the requested element by sending a firmware request which
324 * then installs it into the device internal structures.
327 * Pointer to TF handle, used for HCAPI communication
330 * Pointer to parameters
333 * - (0) if successful.
334 * - (-EINVAL) on failure.
336 int tf_tcam_set(struct tf *tfp,
337 struct tf_tcam_set_parms *parms);
340 * Retrieves the requested element by sending a firmware request to get
344 * Pointer to TF handle, used for HCAPI communication
347 * Pointer to parameters
350 * - (0) if successful.
351 * - (-EINVAL) on failure.
353 int tf_tcam_get(struct tf *tfp,
354 struct tf_tcam_get_parms *parms);
356 #endif /* _TF_TCAM_H */