1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2020 Broadcom
10 #include "tf_identifier.h"
13 #include "tf_if_tbl.h"
14 #include "tf_global_cfg.h"
22 enum tf_device_module_type {
26 TF_DEVICE_MODULE_TYPE_IDENTIFIER,
30 TF_DEVICE_MODULE_TYPE_TABLE,
34 TF_DEVICE_MODULE_TYPE_TCAM,
38 TF_DEVICE_MODULE_TYPE_EM,
39 TF_DEVICE_MODULE_TYPE_MAX
43 * The Device module provides a general device template. A supported
44 * device type should implement one or more of the listed function
45 * pointers according to its capabilities.
47 * If a device function pointer is NULL the device capability is not
52 * TF device information
55 enum tf_device_type type;
56 const struct tf_dev_ops *ops;
68 * Device bind handles the initialization of the specified device
72 * Pointer to TF handle
78 * Pointer to resource allocation information
84 * - (0) if successful.
85 * - (-EINVAL) parameter failure.
86 * - (-ENODEV) no such device supported.
88 int tf_dev_bind(struct tf *tfp,
89 enum tf_device_type type,
91 struct tf_session_resources *resources,
92 struct tf_dev_info *dev_handle);
95 * Device release handles cleanup of the device specific information.
98 * Pointer to TF handle
104 * - (0) if successful.
105 * - (-EINVAL) parameter failure.
106 * - (-ENODEV) no such device supported.
108 int tf_dev_unbind(struct tf *tfp,
109 struct tf_dev_info *dev_handle);
112 * Truflow device specific function hooks structure
114 * The following device hooks can be defined; unless noted otherwise,
115 * they are optional and can be filled with a null pointer. The
116 * purpose of these hooks is to support Truflow device operations for
117 * different device variants.
121 * Retrieves the MAX number of resource types that the device
125 * Pointer to TF handle
128 * Pointer to MAX number of types the device supports
131 * - (0) if successful.
132 * - (-EINVAL) on failure.
134 int (*tf_dev_get_max_types)(struct tf *tfp,
135 uint16_t *max_types);
138 * Retrieves the WC TCAM slice information that the device
142 * Pointer to TF handle
150 * [out] num_slices_per_row
151 * Pointer to number of slices per row the device supports
154 * - (0) if successful.
155 * - (-EINVAL) on failure.
157 int (*tf_dev_get_tcam_slice_info)(struct tf *tfp,
158 enum tf_tcam_tbl_type type,
160 uint16_t *num_slices_per_row);
163 * Allocation of an identifier element.
165 * This API allocates the specified identifier element from a
166 * device specific identifier DB. The allocated element is
170 * Pointer to TF handle
173 * Pointer to identifier allocation parameters
176 * - (0) if successful.
177 * - (-EINVAL) on failure.
179 int (*tf_dev_alloc_ident)(struct tf *tfp,
180 struct tf_ident_alloc_parms *parms);
183 * Free of an identifier element.
185 * This API free's a previous allocated identifier element from a
186 * device specific identifier DB.
189 * Pointer to TF handle
192 * Pointer to identifier free parameters
195 * - (0) if successful.
196 * - (-EINVAL) on failure.
198 int (*tf_dev_free_ident)(struct tf *tfp,
199 struct tf_ident_free_parms *parms);
202 * Search of an identifier element.
204 * This API search the specified identifier element from a
205 * device specific identifier shadow DB. The allocated element
209 * Pointer to TF handle
212 * Pointer to identifier search parameters
215 * - (0) if successful.
216 * - (-EINVAL) on failure.
218 int (*tf_dev_search_ident)(struct tf *tfp,
219 struct tf_ident_search_parms *parms);
222 * Allocation of a table type element.
224 * This API allocates the specified table type element from a
225 * device specific table type DB. The allocated element is
229 * Pointer to TF handle
232 * Pointer to table allocation parameters
235 * - (0) if successful.
236 * - (-EINVAL) on failure.
238 int (*tf_dev_alloc_tbl)(struct tf *tfp,
239 struct tf_tbl_alloc_parms *parms);
242 * Allocation of a external table type element.
244 * This API allocates the specified table type element from a
245 * device specific table type DB. The allocated element is
249 * Pointer to TF handle
252 * Pointer to table allocation parameters
255 * - (0) if successful.
256 * - (-EINVAL) on failure.
258 int (*tf_dev_alloc_ext_tbl)(struct tf *tfp,
259 struct tf_tbl_alloc_parms *parms);
262 * Free of a table type element.
264 * This API free's a previous allocated table type element from a
265 * device specific table type DB.
268 * Pointer to TF handle
271 * Pointer to table free parameters
274 * - (0) if successful.
275 * - (-EINVAL) on failure.
277 int (*tf_dev_free_tbl)(struct tf *tfp,
278 struct tf_tbl_free_parms *parms);
281 * Free of a external table type element.
283 * This API free's a previous allocated table type element from a
284 * device specific table type DB.
287 * Pointer to TF handle
290 * Pointer to table free parameters
293 * - (0) if successful.
294 * - (-EINVAL) on failure.
296 int (*tf_dev_free_ext_tbl)(struct tf *tfp,
297 struct tf_tbl_free_parms *parms);
300 * Searches for the specified table type element in a shadow DB.
302 * This API searches for the specified table type element in a
303 * device specific shadow DB. If the element is found the
304 * reference count for the element is updated. If the element
305 * is not found a new element is allocated from the table type
306 * DB and then inserted into the shadow DB.
309 * Pointer to TF handle
312 * Pointer to table allocation and search parameters
315 * - (0) if successful.
316 * - (-EINVAL) on failure.
318 int (*tf_dev_alloc_search_tbl)(struct tf *tfp,
319 struct tf_tbl_alloc_search_parms *parms);
322 * Sets the specified table type element.
324 * This API sets the specified element data by invoking the
328 * Pointer to TF handle
331 * Pointer to table set parameters
334 * - (0) if successful.
335 * - (-EINVAL) on failure.
337 int (*tf_dev_set_tbl)(struct tf *tfp,
338 struct tf_tbl_set_parms *parms);
341 * Sets the specified external table type element.
343 * This API sets the specified element data by invoking the
347 * Pointer to TF handle
350 * Pointer to table set parameters
353 * - (0) if successful.
354 * - (-EINVAL) on failure.
356 int (*tf_dev_set_ext_tbl)(struct tf *tfp,
357 struct tf_tbl_set_parms *parms);
360 * Retrieves the specified table type element.
362 * This API retrieves the specified element data by invoking the
366 * Pointer to TF handle
369 * Pointer to table get parameters
372 * - (0) if successful.
373 * - (-EINVAL) on failure.
375 int (*tf_dev_get_tbl)(struct tf *tfp,
376 struct tf_tbl_get_parms *parms);
379 * Retrieves the specified table type element using 'bulk'
382 * This API retrieves the specified element data by invoking the
386 * Pointer to TF handle
389 * Pointer to table get bulk parameters
392 * - (0) if successful.
393 * - (-EINVAL) on failure.
395 int (*tf_dev_get_bulk_tbl)(struct tf *tfp,
396 struct tf_tbl_get_bulk_parms *parms);
399 * Allocation of a tcam element.
401 * This API allocates the specified tcam element from a device
402 * specific tcam DB. The allocated element is returned.
405 * Pointer to TF handle
408 * Pointer to tcam allocation parameters
411 * - (0) if successful.
412 * - (-EINVAL) on failure.
414 int (*tf_dev_alloc_tcam)(struct tf *tfp,
415 struct tf_tcam_alloc_parms *parms);
418 * Free of a tcam element.
420 * This API free's a previous allocated tcam element from a
421 * device specific tcam DB.
424 * Pointer to TF handle
427 * Pointer to tcam free parameters
430 * - (0) if successful.
431 * - (-EINVAL) on failure.
433 int (*tf_dev_free_tcam)(struct tf *tfp,
434 struct tf_tcam_free_parms *parms);
437 * Searches for the specified tcam element in a shadow DB.
439 * This API searches for the specified tcam element in a
440 * device specific shadow DB. If the element is found the
441 * reference count for the element is updated. If the element
442 * is not found a new element is allocated from the tcam DB
443 * and then inserted into the shadow DB.
446 * Pointer to TF handle
449 * Pointer to tcam allocation and search parameters
452 * - (0) if successful.
453 * - (-EINVAL) on failure.
455 int (*tf_dev_alloc_search_tcam)
457 struct tf_tcam_alloc_search_parms *parms);
460 * Sets the specified tcam element.
462 * This API sets the specified element data by invoking the
466 * Pointer to TF handle
469 * Pointer to tcam set parameters
472 * - (0) if successful.
473 * - (-EINVAL) on failure.
475 int (*tf_dev_set_tcam)(struct tf *tfp,
476 struct tf_tcam_set_parms *parms);
479 * Retrieves the specified tcam element.
481 * This API retrieves the specified element data by invoking the
485 * Pointer to TF handle
488 * Pointer to tcam get parameters
491 * - (0) if successful.
492 * - (-EINVAL) on failure.
494 int (*tf_dev_get_tcam)(struct tf *tfp,
495 struct tf_tcam_get_parms *parms);
498 * Insert EM hash entry API
501 * Pointer to TF handle
504 * Pointer to E/EM insert parameters
510 int (*tf_dev_insert_int_em_entry)(struct tf *tfp,
511 struct tf_insert_em_entry_parms *parms);
514 * Delete EM hash entry API
517 * Pointer to TF handle
520 * Pointer to E/EM delete parameters
526 int (*tf_dev_delete_int_em_entry)(struct tf *tfp,
527 struct tf_delete_em_entry_parms *parms);
530 * Insert EEM hash entry API
533 * Pointer to TF handle
536 * Pointer to E/EM insert parameters
542 int (*tf_dev_insert_ext_em_entry)(struct tf *tfp,
543 struct tf_insert_em_entry_parms *parms);
546 * Delete EEM hash entry API
549 * Pointer to TF handle
552 * Pointer to E/EM delete parameters
558 int (*tf_dev_delete_ext_em_entry)(struct tf *tfp,
559 struct tf_delete_em_entry_parms *parms);
562 * Allocate EEM table scope
565 * Pointer to TF handle
568 * Pointer to table scope alloc parameters
574 int (*tf_dev_alloc_tbl_scope)(struct tf *tfp,
575 struct tf_alloc_tbl_scope_parms *parms);
578 * Free EEM table scope
581 * Pointer to TF handle
584 * Pointer to table scope free parameters
590 int (*tf_dev_free_tbl_scope)(struct tf *tfp,
591 struct tf_free_tbl_scope_parms *parms);
594 * Sets the specified interface table type element.
596 * This API sets the specified element data by invoking the
600 * Pointer to TF handle
603 * Pointer to interface table set parameters
606 * - (0) if successful.
607 * - (-EINVAL) on failure.
609 int (*tf_dev_set_if_tbl)(struct tf *tfp,
610 struct tf_if_tbl_set_parms *parms);
613 * Retrieves the specified interface table type element.
615 * This API retrieves the specified element data by invoking the
619 * Pointer to TF handle
622 * Pointer to table get parameters
625 * - (0) if successful.
626 * - (-EINVAL) on failure.
628 int (*tf_dev_get_if_tbl)(struct tf *tfp,
629 struct tf_if_tbl_get_parms *parms);
635 * Pointer to TF handle
638 * Pointer to global cfg parameters
644 int (*tf_dev_set_global_cfg)(struct tf *tfp,
645 struct tf_dev_global_cfg_parms *parms);
651 * Pointer to TF handle
654 * Pointer to global cfg parameters
660 int (*tf_dev_get_global_cfg)(struct tf *tfp,
661 struct tf_dev_global_cfg_parms *parms);
665 * Supported device operation structures
667 extern const struct tf_dev_ops tf_dev_ops_p4_init;
668 extern const struct tf_dev_ops tf_dev_ops_p4;
670 #endif /* _TF_DEVICE_H_ */