1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2020 Broadcom
10 #include "tf_identifier.h"
20 enum tf_device_module_type {
24 TF_DEVICE_MODULE_TYPE_IDENTIFIER,
28 TF_DEVICE_MODULE_TYPE_TABLE,
32 TF_DEVICE_MODULE_TYPE_TCAM,
36 TF_DEVICE_MODULE_TYPE_EM,
37 TF_DEVICE_MODULE_TYPE_MAX
41 * The Device module provides a general device template. A supported
42 * device type should implement one or more of the listed function
43 * pointers according to its capabilities.
45 * If a device function pointer is NULL the device capability is not
50 * TF device information
53 enum tf_device_type type;
54 const struct tf_dev_ops *ops;
66 * Device bind handles the initialization of the specified device
70 * Pointer to TF handle
76 * Pointer to resource allocation information
82 * - (0) if successful.
83 * - (-EINVAL) parameter failure.
84 * - (-ENODEV) no such device supported.
86 int tf_dev_bind(struct tf *tfp,
87 enum tf_device_type type,
89 struct tf_session_resources *resources,
90 struct tf_dev_info *dev_handle);
93 * Device release handles cleanup of the device specific information.
96 * Pointer to TF handle
102 * - (0) if successful.
103 * - (-EINVAL) parameter failure.
104 * - (-ENODEV) no such device supported.
106 int tf_dev_unbind(struct tf *tfp,
107 struct tf_dev_info *dev_handle);
110 * Truflow device specific function hooks structure
112 * The following device hooks can be defined; unless noted otherwise,
113 * they are optional and can be filled with a null pointer. The
114 * purpose of these hooks is to support Truflow device operations for
115 * different device variants.
119 * Retrieves the MAX number of resource types that the device
123 * Pointer to TF handle
126 * Pointer to MAX number of types the device supports
129 * - (0) if successful.
130 * - (-EINVAL) on failure.
132 int (*tf_dev_get_max_types)(struct tf *tfp,
133 uint16_t *max_types);
136 * Retrieves the WC TCAM slice information that the device
140 * Pointer to TF handle
148 * [out] num_slices_per_row
149 * Pointer to number of slices per row the device supports
152 * - (0) if successful.
153 * - (-EINVAL) on failure.
155 int (*tf_dev_get_tcam_slice_info)(struct tf *tfp,
156 enum tf_tcam_tbl_type type,
158 uint16_t *num_slices_per_row);
161 * Allocation of an identifier element.
163 * This API allocates the specified identifier element from a
164 * device specific identifier DB. The allocated element is
168 * Pointer to TF handle
171 * Pointer to identifier allocation parameters
174 * - (0) if successful.
175 * - (-EINVAL) on failure.
177 int (*tf_dev_alloc_ident)(struct tf *tfp,
178 struct tf_ident_alloc_parms *parms);
181 * Free of an identifier element.
183 * This API free's a previous allocated identifier element from a
184 * device specific identifier DB.
187 * Pointer to TF handle
190 * Pointer to identifier free parameters
193 * - (0) if successful.
194 * - (-EINVAL) on failure.
196 int (*tf_dev_free_ident)(struct tf *tfp,
197 struct tf_ident_free_parms *parms);
200 * Allocation of a table type element.
202 * This API allocates the specified table type element from a
203 * device specific table type DB. The allocated element is
207 * Pointer to TF handle
210 * Pointer to table allocation parameters
213 * - (0) if successful.
214 * - (-EINVAL) on failure.
216 int (*tf_dev_alloc_tbl)(struct tf *tfp,
217 struct tf_tbl_alloc_parms *parms);
220 * Free of a table type element.
222 * This API free's a previous allocated table type element from a
223 * device specific table type DB.
226 * Pointer to TF handle
229 * Pointer to table free parameters
232 * - (0) if successful.
233 * - (-EINVAL) on failure.
235 int (*tf_dev_free_tbl)(struct tf *tfp,
236 struct tf_tbl_free_parms *parms);
239 * Searches for the specified table type element in a shadow DB.
241 * This API searches for the specified table type element in a
242 * device specific shadow DB. If the element is found the
243 * reference count for the element is updated. If the element
244 * is not found a new element is allocated from the table type
245 * DB and then inserted into the shadow DB.
248 * Pointer to TF handle
251 * Pointer to table allocation and search parameters
254 * - (0) if successful.
255 * - (-EINVAL) on failure.
257 int (*tf_dev_alloc_search_tbl)(struct tf *tfp,
258 struct tf_tbl_alloc_search_parms *parms);
261 * Sets the specified table type element.
263 * This API sets the specified element data by invoking the
267 * Pointer to TF handle
270 * Pointer to table set parameters
273 * - (0) if successful.
274 * - (-EINVAL) on failure.
276 int (*tf_dev_set_tbl)(struct tf *tfp,
277 struct tf_tbl_set_parms *parms);
280 * Retrieves the specified table type element.
282 * This API retrieves the specified element data by invoking the
286 * Pointer to TF handle
289 * Pointer to table get parameters
292 * - (0) if successful.
293 * - (-EINVAL) on failure.
295 int (*tf_dev_get_tbl)(struct tf *tfp,
296 struct tf_tbl_get_parms *parms);
299 * Retrieves the specified table type element using 'bulk'
302 * This API retrieves the specified element data by invoking the
306 * Pointer to TF handle
309 * Pointer to table get bulk parameters
312 * - (0) if successful.
313 * - (-EINVAL) on failure.
315 int (*tf_dev_get_bulk_tbl)(struct tf *tfp,
316 struct tf_tbl_get_bulk_parms *parms);
319 * Allocation of a tcam element.
321 * This API allocates the specified tcam element from a device
322 * specific tcam DB. The allocated element is returned.
325 * Pointer to TF handle
328 * Pointer to tcam allocation parameters
331 * - (0) if successful.
332 * - (-EINVAL) on failure.
334 int (*tf_dev_alloc_tcam)(struct tf *tfp,
335 struct tf_tcam_alloc_parms *parms);
338 * Free of a tcam element.
340 * This API free's a previous allocated tcam element from a
341 * device specific tcam DB.
344 * Pointer to TF handle
347 * Pointer to tcam free parameters
350 * - (0) if successful.
351 * - (-EINVAL) on failure.
353 int (*tf_dev_free_tcam)(struct tf *tfp,
354 struct tf_tcam_free_parms *parms);
357 * Searches for the specified tcam element in a shadow DB.
359 * This API searches for the specified tcam element in a
360 * device specific shadow DB. If the element is found the
361 * reference count for the element is updated. If the element
362 * is not found a new element is allocated from the tcam DB
363 * and then inserted into the shadow DB.
366 * Pointer to TF handle
369 * Pointer to tcam allocation and search parameters
372 * - (0) if successful.
373 * - (-EINVAL) on failure.
375 int (*tf_dev_alloc_search_tcam)
377 struct tf_tcam_alloc_search_parms *parms);
380 * Sets the specified tcam element.
382 * This API sets the specified element data by invoking the
386 * Pointer to TF handle
389 * Pointer to tcam set parameters
392 * - (0) if successful.
393 * - (-EINVAL) on failure.
395 int (*tf_dev_set_tcam)(struct tf *tfp,
396 struct tf_tcam_set_parms *parms);
399 * Retrieves the specified tcam element.
401 * This API retrieves the specified element data by invoking the
405 * Pointer to TF handle
408 * Pointer to tcam get parameters
411 * - (0) if successful.
412 * - (-EINVAL) on failure.
414 int (*tf_dev_get_tcam)(struct tf *tfp,
415 struct tf_tcam_get_parms *parms);
418 * Insert EM hash entry API
421 * Pointer to TF handle
424 * Pointer to E/EM insert parameters
430 int (*tf_dev_insert_int_em_entry)(struct tf *tfp,
431 struct tf_insert_em_entry_parms *parms);
434 * Delete EM hash entry API
437 * Pointer to TF handle
440 * Pointer to E/EM delete parameters
446 int (*tf_dev_delete_int_em_entry)(struct tf *tfp,
447 struct tf_delete_em_entry_parms *parms);
450 * Insert EEM hash entry API
453 * Pointer to TF handle
456 * Pointer to E/EM insert parameters
462 int (*tf_dev_insert_ext_em_entry)(struct tf *tfp,
463 struct tf_insert_em_entry_parms *parms);
466 * Delete EEM hash entry API
469 * Pointer to TF handle
472 * Pointer to E/EM delete parameters
478 int (*tf_dev_delete_ext_em_entry)(struct tf *tfp,
479 struct tf_delete_em_entry_parms *parms);
482 * Allocate EEM table scope
485 * Pointer to TF handle
488 * Pointer to table scope alloc parameters
494 int (*tf_dev_alloc_tbl_scope)(struct tf *tfp,
495 struct tf_alloc_tbl_scope_parms *parms);
498 * Free EEM table scope
501 * Pointer to TF handle
504 * Pointer to table scope free parameters
510 int (*tf_dev_free_tbl_scope)(struct tf *tfp,
511 struct tf_free_tbl_scope_parms *parms);
515 * Supported device operation structures
517 extern const struct tf_dev_ops tf_dev_ops_p4_init;
518 extern const struct tf_dev_ops tf_dev_ops_p4;
520 #endif /* _TF_DEVICE_H_ */