1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2021 Broadcom
12 * The TCAM module provides processing of Internal TCAM types.
15 /* Number of slices per row for WC TCAM */
16 extern uint16_t g_wc_num_slices_per_row;
19 * TCAM configuration parameters
21 struct tf_tcam_cfg_parms {
23 * Number of tcam types in each of the configuration arrays
25 uint16_t num_elements;
27 * TCAM configuration array
29 struct tf_rm_element_cfg *cfg;
31 * Shadow table type configuration array
33 struct tf_shadow_tcam_cfg *shadow_cfg;
35 * Boolean controlling the request shadow copy.
39 * Session resource allocations
41 struct tf_session_resources *resources;
43 * WC number of slices per row.
45 enum tf_wc_num_slice wc_num_slices;
49 * TCAM allocation parameters
51 struct tf_tcam_alloc_parms {
53 * [in] Receive or transmit direction
57 * [in] Type of the allocation
59 enum tf_tcam_tbl_type type;
65 * [in] Priority of entry requested (definition TBD)
69 * [out] Idx of allocated entry or found entry (if search_enable)
75 * TCAM free parameters
77 struct tf_tcam_free_parms {
79 * [in] Receive or transmit direction
83 * [in] Type of the allocation type
85 enum tf_tcam_tbl_type type;
95 * [out] Reference count after free, only valid if session has been
96 * created with shadow_copy.
102 * TCAM allocate search parameters
104 struct tf_tcam_alloc_search_parms {
106 * [in] receive or transmit direction
110 * [in] TCAM table type
112 enum tf_tcam_tbl_type type;
118 * [in] Key data to match on
122 * [in] key size in bits
126 * [in] Mask data to match on
130 * [in] Priority of entry requested (definition TBD)
134 * [in] Allocate on miss.
138 * [out] Set if matching entry found
142 * [out] Search result status (hit, miss, reject)
144 enum tf_search_status search_status;
146 * [out] Current refcnt after allocation
150 * [in,out] The result data from the search is copied here
154 * [in,out] result size in bits for the result data
156 uint16_t result_size;
164 * TCAM set parameters
166 struct tf_tcam_set_parms {
168 * [in] Receive or transmit direction
172 * [in] Type of object to set
174 enum tf_tcam_tbl_type type;
180 * [in] Entry index to write to
184 * [in] array containing key
188 * [in] array containing mask fields
196 * [in] array containing result
202 uint16_t result_size;
206 * TCAM get parameters
208 struct tf_tcam_get_parms {
210 * [in] Receive or transmit direction
214 * [in] Type of object to get
216 enum tf_tcam_tbl_type type;
222 * [in] Entry index to read
226 * [out] array containing key
230 * [out] array containing mask fields
238 * [out] array containing result
244 uint16_t result_size;
254 struct rm_db *tcam_db[TF_DIR_MAX];
262 * @ref tf_tcam_unbind
268 * @ref tf_tcam_alloc_search
277 * Initializes the TCAM module with the requested DBs. Must be
278 * invoked as the first thing before any of the access functions.
281 * Pointer to TF handle, used for HCAPI communication
284 * Pointer to parameters
287 * - (0) if successful.
288 * - (-EINVAL) on failure.
290 int tf_tcam_bind(struct tf *tfp,
291 struct tf_tcam_cfg_parms *parms);
294 * Cleans up the private DBs and releases all the data.
297 * Pointer to TF handle, used for HCAPI communication
300 * Pointer to parameters
303 * - (0) if successful.
304 * - (-EINVAL) on failure.
306 int tf_tcam_unbind(struct tf *tfp);
309 * Allocates the requested tcam type from the internal RM DB.
312 * Pointer to TF handle, used for HCAPI communication
315 * Pointer to parameters
318 * - (0) if successful.
319 * - (-EINVAL) on failure.
321 int tf_tcam_alloc(struct tf *tfp,
322 struct tf_tcam_alloc_parms *parms);
325 * Free's the requested table type and returns it to the DB. If shadow
326 * DB is enabled its searched first and if found the element refcount
327 * is decremented. If refcount goes to 0 then its returned to the
331 * Pointer to TF handle, used for HCAPI communication
334 * Pointer to parameters
337 * - (0) if successful.
338 * - (-EINVAL) on failure.
340 int tf_tcam_free(struct tf *tfp,
341 struct tf_tcam_free_parms *parms);
344 * Supported if Shadow DB is configured. Searches the Shadow DB for
345 * any matching element. If found the refcount in the shadow DB is
346 * updated accordingly. If not found a new element is allocated and
347 * installed into the shadow DB.
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_alloc_search(struct tf *tfp,
360 struct tf_tcam_alloc_search_parms *parms);
363 * Configures the requested element by sending a firmware request which
364 * then installs it into the device internal structures.
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_set(struct tf *tfp,
377 struct tf_tcam_set_parms *parms);
380 * Retrieves the requested element by sending a firmware request to get
384 * Pointer to TF handle, used for HCAPI communication
387 * Pointer to parameters
390 * - (0) if successful.
391 * - (-EINVAL) on failure.
393 int tf_tcam_get(struct tf *tfp,
394 struct tf_tcam_get_parms *parms);
397 * Retrieves the allocated resource info
400 * Pointer to TF handle, used for HCAPI communication
403 * Pointer to parameters
406 * - (0) if successful.
407 * - (-EINVAL) on failure.
409 int tf_tcam_get_resc_info(struct tf *tfp,
410 struct tf_tcam_resource_info *parms);
412 #endif /* _TF_TCAM_H */