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;
150 * [in] Entry index to write to
154 * [in] array containing key
158 * [in] array containing mask fields
166 * [in] array containing result
172 uint16_t result_size;
176 * TCAM get parameters
178 struct tf_tcam_get_parms {
180 * [in] Receive or transmit direction
184 * [in] Type of object to get
186 enum tf_tcam_tbl_type type;
188 * [in] Entry index to read
192 * [out] array containing key
196 * [out] array containing mask fields
204 * [out] array containing result
210 uint16_t result_size;
218 * @ref tf_tcam_unbind
224 * @ref tf_tcam_alloc_search
233 * Initializes the TCAM module with the requested DBs. Must be
234 * invoked as the first thing before any of the access functions.
237 * Pointer to TF handle, used for HCAPI communication
240 * Pointer to parameters
243 * - (0) if successful.
244 * - (-EINVAL) on failure.
246 int tf_tcam_bind(struct tf *tfp,
247 struct tf_tcam_cfg_parms *parms);
250 * Cleans up the private DBs and releases all the data.
253 * Pointer to TF handle, used for HCAPI communication
256 * Pointer to parameters
259 * - (0) if successful.
260 * - (-EINVAL) on failure.
262 int tf_tcam_unbind(struct tf *tfp);
265 * Allocates the requested tcam type from the internal RM 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(struct tf *tfp,
278 struct tf_tcam_alloc_parms *parms);
281 * Free's the requested table type and returns it to the DB. If shadow
282 * DB is enabled its searched first and if found the element refcount
283 * is decremented. If refcount goes to 0 then its returned to the
287 * Pointer to TF handle, used for HCAPI communication
290 * Pointer to parameters
293 * - (0) if successful.
294 * - (-EINVAL) on failure.
296 int tf_tcam_free(struct tf *tfp,
297 struct tf_tcam_free_parms *parms);
300 * Supported if Shadow DB is configured. Searches the Shadow DB for
301 * any matching element. If found the refcount in the shadow DB is
302 * updated accordingly. If not found a new element is allocated and
303 * installed into the shadow DB.
306 * Pointer to TF handle, used for HCAPI communication
309 * Pointer to parameters
312 * - (0) if successful.
313 * - (-EINVAL) on failure.
315 int tf_tcam_alloc_search(struct tf *tfp,
316 struct tf_tcam_alloc_search_parms *parms);
319 * Configures the requested element by sending a firmware request which
320 * then installs it into the device internal structures.
323 * Pointer to TF handle, used for HCAPI communication
326 * Pointer to parameters
329 * - (0) if successful.
330 * - (-EINVAL) on failure.
332 int tf_tcam_set(struct tf *tfp,
333 struct tf_tcam_set_parms *parms);
336 * Retrieves the requested element by sending a firmware request to get
340 * Pointer to TF handle, used for HCAPI communication
343 * Pointer to parameters
346 * - (0) if successful.
347 * - (-EINVAL) on failure.
349 int tf_tcam_get(struct tf *tfp,
350 struct tf_tcam_get_parms *parms);
352 #endif /* _TF_TCAM_H */