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;
54 * [out] Idx of allocated entry or found entry (if search_enable)
60 * TCAM free parameters
62 struct tf_tcam_free_parms {
64 * [in] Receive or transmit direction
68 * [in] Type of the allocation type
70 enum tf_tcam_tbl_type type;
76 * [out] Reference count after free, only valid if session has been
77 * created with shadow_copy.
83 * TCAM allocate search parameters
85 struct tf_tcam_alloc_search_parms {
87 * [in] receive or transmit direction
91 * [in] TCAM table type
93 enum tf_tcam_tbl_type tcam_tbl_type;
95 * [in] Enable search for matching entry
97 uint8_t search_enable;
99 * [in] Key data to match on (if search)
103 * [in] key size in bits (if search)
105 uint16_t key_sz_in_bits;
107 * [in] Mask data to match on (if search)
111 * [in] Priority of entry requested (definition TBD)
115 * [out] If search, set if matching entry found
119 * [out] Current refcnt after allocation
123 * [out] Idx allocated
130 * TCAM set parameters
132 struct tf_tcam_set_parms {
134 * [in] Receive or transmit direction
138 * [in] Type of object to set
140 enum tf_tcam_tbl_type type;
148 uint16_t data_sz_in_bytes;
150 * [in] Entry index to write to
156 * TCAM get parameters
158 struct tf_tcam_get_parms {
160 * [in] Receive or transmit direction
164 * [in] Type of object to get
166 enum tf_tcam_tbl_type type;
174 uint16_t data_sz_in_bytes;
176 * [in] Entry index to read
186 * @ref tf_tcam_unbind
192 * @ref tf_tcam_alloc_search
201 * Initializes the TCAM module with the requested DBs. Must be
202 * invoked as the first thing before any of the access functions.
205 * Pointer to TF handle, used for HCAPI communication
208 * Pointer to parameters
211 * - (0) if successful.
212 * - (-EINVAL) on failure.
214 int tf_tcam_bind(struct tf *tfp,
215 struct tf_tcam_cfg_parms *parms);
218 * Cleans up the private DBs and releases all the data.
221 * Pointer to TF handle, used for HCAPI communication
224 * Pointer to parameters
227 * - (0) if successful.
228 * - (-EINVAL) on failure.
230 int tf_tcam_unbind(struct tf *tfp);
233 * Allocates the requested tcam type from the internal RM DB.
236 * Pointer to TF handle, used for HCAPI communication
239 * Pointer to parameters
242 * - (0) if successful.
243 * - (-EINVAL) on failure.
245 int tf_tcam_alloc(struct tf *tfp,
246 struct tf_tcam_alloc_parms *parms);
249 * Free's the requested table type and returns it to the DB. If shadow
250 * DB is enabled its searched first and if found the element refcount
251 * is decremented. If refcount goes to 0 then its returned to the
255 * Pointer to TF handle, used for HCAPI communication
258 * Pointer to parameters
261 * - (0) if successful.
262 * - (-EINVAL) on failure.
264 int tf_tcam_free(struct tf *tfp,
265 struct tf_tcam_free_parms *parms);
268 * Supported if Shadow DB is configured. Searches the Shadow DB for
269 * any matching element. If found the refcount in the shadow DB is
270 * updated accordingly. If not found a new element is allocated and
271 * installed into the shadow DB.
274 * Pointer to TF handle, used for HCAPI communication
277 * Pointer to parameters
280 * - (0) if successful.
281 * - (-EINVAL) on failure.
283 int tf_tcam_alloc_search(struct tf *tfp,
284 struct tf_tcam_alloc_search_parms *parms);
287 * Configures the requested element by sending a firmware request which
288 * then installs it into the device internal structures.
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_set(struct tf *tfp,
301 struct tf_tcam_set_parms *parms);
304 * Retrieves the requested element by sending a firmware request to get
308 * Pointer to TF handle, used for HCAPI communication
311 * Pointer to parameters
314 * - (0) if successful.
315 * - (-EINVAL) on failure.
317 int tf_tcam_get(struct tf *tfp,
318 struct tf_tcam_get_parms *parms);
320 #endif /* _TF_TCAM_H */