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;
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;
211 * [in] Entry index to read
215 * [out] array containing key
219 * [out] array containing mask fields
227 * [out] array containing result
233 uint16_t result_size;
241 * @ref tf_tcam_unbind
247 * @ref tf_tcam_alloc_search
256 * Initializes the TCAM module with the requested DBs. Must be
257 * invoked as the first thing before any of the access functions.
260 * Pointer to TF handle, used for HCAPI communication
263 * Pointer to parameters
266 * - (0) if successful.
267 * - (-EINVAL) on failure.
269 int tf_tcam_bind(struct tf *tfp,
270 struct tf_tcam_cfg_parms *parms);
273 * Cleans up the private DBs and releases all the data.
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_unbind(struct tf *tfp);
288 * Allocates the requested tcam type from the internal RM DB.
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_alloc(struct tf *tfp,
301 struct tf_tcam_alloc_parms *parms);
304 * Free's the requested table type and returns it to the DB. If shadow
305 * DB is enabled its searched first and if found the element refcount
306 * is decremented. If refcount goes to 0 then its returned to the
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_free(struct tf *tfp,
320 struct tf_tcam_free_parms *parms);
323 * Supported if Shadow DB is configured. Searches the Shadow DB for
324 * any matching element. If found the refcount in the shadow DB is
325 * updated accordingly. If not found a new element is allocated and
326 * installed into the shadow DB.
329 * Pointer to TF handle, used for HCAPI communication
332 * Pointer to parameters
335 * - (0) if successful.
336 * - (-EINVAL) on failure.
338 int tf_tcam_alloc_search(struct tf *tfp,
339 struct tf_tcam_alloc_search_parms *parms);
342 * Configures the requested element by sending a firmware request which
343 * then installs it into the device internal structures.
346 * Pointer to TF handle, used for HCAPI communication
349 * Pointer to parameters
352 * - (0) if successful.
353 * - (-EINVAL) on failure.
355 int tf_tcam_set(struct tf *tfp,
356 struct tf_tcam_set_parms *parms);
359 * Retrieves the requested element by sending a firmware request to get
363 * Pointer to TF handle, used for HCAPI communication
366 * Pointer to parameters
369 * - (0) if successful.
370 * - (-EINVAL) on failure.
372 int tf_tcam_get(struct tf *tfp,
373 struct tf_tcam_get_parms *parms);
375 #endif /* _TF_TCAM_H */