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;
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;
107 * [in] Enable search for matching entry
109 uint8_t search_enable;
111 * [in] Key data to match on (if search)
115 * [in] key size (if search)
119 * [in] Mask data to match on (if search)
123 * [in] Priority of entry requested (definition TBD)
127 * [out] If search, set if matching entry found
131 * [out] Current refcnt after allocation
135 * [out] Idx allocated
142 * TCAM set parameters
144 struct tf_tcam_set_parms {
146 * [in] Receive or transmit direction
150 * [in] Type of object to set
152 enum tf_tcam_tbl_type type;
158 * [in] Entry index to write to
162 * [in] array containing key
166 * [in] array containing mask fields
174 * [in] array containing result
180 uint16_t result_size;
184 * TCAM get parameters
186 struct tf_tcam_get_parms {
188 * [in] Receive or transmit direction
192 * [in] Type of object to get
194 enum tf_tcam_tbl_type type;
196 * [in] Entry index to read
200 * [out] array containing key
204 * [out] array containing mask fields
212 * [out] array containing result
218 uint16_t result_size;
226 * @ref tf_tcam_unbind
232 * @ref tf_tcam_alloc_search
241 * Initializes the TCAM module with the requested DBs. Must be
242 * invoked as the first thing before any of the access functions.
245 * Pointer to TF handle, used for HCAPI communication
248 * Pointer to parameters
251 * - (0) if successful.
252 * - (-EINVAL) on failure.
254 int tf_tcam_bind(struct tf *tfp,
255 struct tf_tcam_cfg_parms *parms);
258 * Cleans up the private DBs and releases all the data.
261 * Pointer to TF handle, used for HCAPI communication
264 * Pointer to parameters
267 * - (0) if successful.
268 * - (-EINVAL) on failure.
270 int tf_tcam_unbind(struct tf *tfp);
273 * Allocates the requested tcam type from the internal RM DB.
276 * Pointer to TF handle, used for HCAPI communication
279 * Pointer to parameters
282 * - (0) if successful.
283 * - (-EINVAL) on failure.
285 int tf_tcam_alloc(struct tf *tfp,
286 struct tf_tcam_alloc_parms *parms);
289 * Free's the requested table type and returns it to the DB. If shadow
290 * DB is enabled its searched first and if found the element refcount
291 * is decremented. If refcount goes to 0 then its returned to the
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_free(struct tf *tfp,
305 struct tf_tcam_free_parms *parms);
308 * Supported if Shadow DB is configured. Searches the Shadow DB for
309 * any matching element. If found the refcount in the shadow DB is
310 * updated accordingly. If not found a new element is allocated and
311 * installed into the shadow DB.
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_alloc_search(struct tf *tfp,
324 struct tf_tcam_alloc_search_parms *parms);
327 * Configures the requested element by sending a firmware request which
328 * then installs it into the device internal structures.
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_set(struct tf *tfp,
341 struct tf_tcam_set_parms *parms);
344 * Retrieves the requested element by sending a firmware request to get
348 * Pointer to TF handle, used for HCAPI communication
351 * Pointer to parameters
354 * - (0) if successful.
355 * - (-EINVAL) on failure.
357 int tf_tcam_get(struct tf *tfp,
358 struct tf_tcam_get_parms *parms);
360 #endif /* _TF_TCAM_H */