1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2021 Broadcom
10 #include "tf_identifier.h"
13 #include "tf_if_tbl.h"
14 #include "tf_global_cfg.h"
20 * The Device module provides a general device template. A supported
21 * device type should implement one or more of the listed function
22 * pointers according to its capabilities.
24 * If a device function pointer is NULL the device capability is not
29 * TF device information
32 enum tf_device_type type;
33 const struct tf_dev_ops *ops;
45 * Device bind handles the initialization of the specified device
49 * Pointer to TF handle
55 * Pointer to resource allocation information
61 * - (0) if successful.
62 * - (-EINVAL) parameter failure.
63 * - (-ENODEV) no such device supported.
65 int tf_dev_bind(struct tf *tfp,
66 enum tf_device_type type,
68 struct tf_session_resources *resources,
69 struct tf_dev_info *dev_handle);
72 * Device release handles cleanup of the device specific information.
75 * Pointer to TF handle
81 * - (0) if successful.
82 * - (-EINVAL) parameter failure.
83 * - (-ENODEV) no such device supported.
85 int tf_dev_unbind(struct tf *tfp,
86 struct tf_dev_info *dev_handle);
89 tf_dev_bind_ops(enum tf_device_type type,
90 struct tf_dev_info *dev_handle);
93 * Truflow device specific function hooks structure
95 * The following device hooks can be defined; unless noted otherwise,
96 * they are optional and can be filled with a null pointer. The
97 * purpose of these hooks is to support Truflow device operations for
98 * different device variants.
102 * Retrieves the MAX number of resource types that the device
106 * Pointer to TF handle
109 * Pointer to MAX number of types the device supports
112 * - (0) if successful.
113 * - (-EINVAL) on failure.
115 int (*tf_dev_get_max_types)(struct tf *tfp,
116 uint16_t *max_types);
119 * Retrieves the string description for the CFA resource
123 * Pointer to TF handle
126 * HCAPI cfa resource type id
129 * Pointer to a string
132 * - (0) if successful.
133 * - (-EINVAL) on failure.
135 int (*tf_dev_get_resource_str)(struct tf *tfp,
136 uint16_t resource_id,
137 const char **resource_str);
141 * Retrieves the WC TCAM slice information that the device
145 * Pointer to TF handle
153 * [out] num_slices_per_row
154 * Pointer to number of slices per row the device supports
157 * - (0) if successful.
158 * - (-EINVAL) on failure.
160 int (*tf_dev_get_tcam_slice_info)(struct tf *tfp,
161 enum tf_tcam_tbl_type type,
163 uint16_t *num_slices_per_row);
166 * Allocation of an identifier element.
168 * This API allocates the specified identifier element from a
169 * device specific identifier DB. The allocated element is
173 * Pointer to TF handle
176 * Pointer to identifier allocation parameters
179 * - (0) if successful.
180 * - (-EINVAL) on failure.
182 int (*tf_dev_alloc_ident)(struct tf *tfp,
183 struct tf_ident_alloc_parms *parms);
186 * Free of an identifier element.
188 * This API free's a previous allocated identifier element from a
189 * device specific identifier DB.
192 * Pointer to TF handle
195 * Pointer to identifier free parameters
198 * - (0) if successful.
199 * - (-EINVAL) on failure.
201 int (*tf_dev_free_ident)(struct tf *tfp,
202 struct tf_ident_free_parms *parms);
205 * Search of an identifier element.
207 * This API search the specified identifier element from a
208 * device specific identifier shadow DB. The allocated element
212 * Pointer to TF handle
215 * Pointer to identifier search parameters
218 * - (0) if successful.
219 * - (-EINVAL) on failure.
221 int (*tf_dev_search_ident)(struct tf *tfp,
222 struct tf_ident_search_parms *parms);
224 * Get SRAM table information.
226 * Converts an internal RM allocated element offset to
227 * a user address and vice versa.
230 * Pointer to TF handle
233 * Truflow index table type, e.g. TF_TYPE_FULL_ACT_RECORD
236 * Pointer to the base address of the associated table type.
239 * Pointer to any shift required for the associated table type.
242 * - (0) if successful.
243 * - (-EINVAL) on failure.
245 int (*tf_dev_get_tbl_info)(struct tf *tfp,
247 enum tf_tbl_type type,
252 * Allocation of an index table type element.
254 * This API allocates the specified table type element from a
255 * device specific table type DB. The allocated element is
259 * Pointer to TF handle
262 * Pointer to table allocation parameters
265 * - (0) if successful.
266 * - (-EINVAL) on failure.
268 int (*tf_dev_alloc_tbl)(struct tf *tfp,
269 struct tf_tbl_alloc_parms *parms);
272 * Allocation of a external table type element.
274 * This API allocates the specified table type element from a
275 * device specific table type DB. The allocated element is
279 * Pointer to TF handle
282 * Pointer to table allocation parameters
285 * - (0) if successful.
286 * - (-EINVAL) on failure.
288 int (*tf_dev_alloc_ext_tbl)(struct tf *tfp,
289 struct tf_tbl_alloc_parms *parms);
292 * Free of a table type element.
294 * This API free's a previous allocated table type element from a
295 * device specific table type DB.
298 * Pointer to TF handle
301 * Pointer to table free parameters
304 * - (0) if successful.
305 * - (-EINVAL) on failure.
307 int (*tf_dev_free_tbl)(struct tf *tfp,
308 struct tf_tbl_free_parms *parms);
311 * Free of a external table type element.
313 * This API free's a previous allocated table type element from a
314 * device specific table type DB.
317 * Pointer to TF handle
320 * Pointer to table free parameters
323 * - (0) if successful.
324 * - (-EINVAL) on failure.
326 int (*tf_dev_free_ext_tbl)(struct tf *tfp,
327 struct tf_tbl_free_parms *parms);
330 * Searches for the specified table type element in a shadow DB.
332 * This API searches for the specified table type element in a
333 * device specific shadow DB. If the element is found the
334 * reference count for the element is updated. If the element
335 * is not found a new element is allocated from the table type
336 * DB and then inserted into the shadow DB.
339 * Pointer to TF handle
342 * Pointer to table allocation and search parameters
345 * - (0) if successful.
346 * - (-EINVAL) on failure.
348 int (*tf_dev_alloc_search_tbl)(struct tf *tfp,
349 struct tf_tbl_alloc_search_parms *parms);
352 * Sets the specified table type element.
354 * This API sets the specified element data by invoking the
358 * Pointer to TF handle
361 * Pointer to table set parameters
364 * - (0) if successful.
365 * - (-EINVAL) on failure.
367 int (*tf_dev_set_tbl)(struct tf *tfp,
368 struct tf_tbl_set_parms *parms);
371 * Sets the specified external table type element.
373 * This API sets the specified element data by invoking the
377 * Pointer to TF handle
380 * Pointer to table set parameters
383 * - (0) if successful.
384 * - (-EINVAL) on failure.
386 int (*tf_dev_set_ext_tbl)(struct tf *tfp,
387 struct tf_tbl_set_parms *parms);
390 * Retrieves the specified table type element.
392 * This API retrieves the specified element data by invoking the
396 * Pointer to TF handle
399 * Pointer to table get parameters
402 * - (0) if successful.
403 * - (-EINVAL) on failure.
405 int (*tf_dev_get_tbl)(struct tf *tfp,
406 struct tf_tbl_get_parms *parms);
409 * Retrieves the specified table type element using 'bulk'
412 * This API retrieves the specified element data by invoking the
416 * Pointer to TF handle
419 * Pointer to table get bulk parameters
422 * - (0) if successful.
423 * - (-EINVAL) on failure.
425 int (*tf_dev_get_bulk_tbl)(struct tf *tfp,
426 struct tf_tbl_get_bulk_parms *parms);
429 * Allocation of a tcam element.
431 * This API allocates the specified tcam element from a device
432 * specific tcam DB. The allocated element is returned.
435 * Pointer to TF handle
438 * Pointer to tcam allocation parameters
441 * - (0) if successful.
442 * - (-EINVAL) on failure.
444 int (*tf_dev_alloc_tcam)(struct tf *tfp,
445 struct tf_tcam_alloc_parms *parms);
448 * Free of a tcam element.
450 * This API free's a previous allocated tcam element from a
451 * device specific tcam DB.
454 * Pointer to TF handle
457 * Pointer to tcam free parameters
460 * - (0) if successful.
461 * - (-EINVAL) on failure.
463 int (*tf_dev_free_tcam)(struct tf *tfp,
464 struct tf_tcam_free_parms *parms);
467 * Searches for the specified tcam element in a shadow DB.
469 * This API searches for the specified tcam element in a
470 * device specific shadow DB. If the element is found the
471 * reference count for the element is updated. If the element
472 * is not found a new element is allocated from the tcam DB
473 * and then inserted into the shadow DB.
476 * Pointer to TF handle
479 * Pointer to tcam allocation and search parameters
482 * - (0) if successful.
483 * - (-EINVAL) on failure.
485 int (*tf_dev_alloc_search_tcam)
487 struct tf_tcam_alloc_search_parms *parms);
490 * Sets the specified tcam element.
492 * This API sets the specified element data by invoking the
496 * Pointer to TF handle
499 * Pointer to tcam set parameters
502 * - (0) if successful.
503 * - (-EINVAL) on failure.
505 int (*tf_dev_set_tcam)(struct tf *tfp,
506 struct tf_tcam_set_parms *parms);
509 * Retrieves the specified tcam element.
511 * This API retrieves the specified element data by invoking the
515 * Pointer to TF handle
518 * Pointer to tcam get parameters
521 * - (0) if successful.
522 * - (-EINVAL) on failure.
524 int (*tf_dev_get_tcam)(struct tf *tfp,
525 struct tf_tcam_get_parms *parms);
528 * Insert EM hash entry API
531 * Pointer to TF handle
534 * Pointer to E/EM insert parameters
540 int (*tf_dev_insert_int_em_entry)(struct tf *tfp,
541 struct tf_insert_em_entry_parms *parms);
544 * Delete EM hash entry API
547 * Pointer to TF handle
550 * Pointer to E/EM delete parameters
556 int (*tf_dev_delete_int_em_entry)(struct tf *tfp,
557 struct tf_delete_em_entry_parms *parms);
560 * Insert EEM hash entry API
563 * Pointer to TF handle
566 * Pointer to E/EM insert parameters
572 int (*tf_dev_insert_ext_em_entry)(struct tf *tfp,
573 struct tf_insert_em_entry_parms *parms);
576 * Delete EEM hash entry API
579 * Pointer to TF handle
582 * Pointer to E/EM delete parameters
588 int (*tf_dev_delete_ext_em_entry)(struct tf *tfp,
589 struct tf_delete_em_entry_parms *parms);
592 * Allocate EEM table scope
595 * Pointer to TF handle
598 * Pointer to table scope alloc parameters
604 int (*tf_dev_alloc_tbl_scope)(struct tf *tfp,
605 struct tf_alloc_tbl_scope_parms *parms);
610 * Pointer to TF handle
613 * PF associated with the table scope
616 * Bitmask of PARIFs to enable
618 * [in/out] pointer to the parif_2_pf data to be updated
620 * [in/out] pointer to the parif_2_pf mask to be updated
622 * [in] sz_in_bytes - number of bytes to be written
628 int (*tf_dev_map_parif)(struct tf *tfp,
629 uint16_t parif_bitmask,
633 uint16_t sz_in_bytes);
635 * Map EEM table scope
638 * Pointer to TF handle
641 * Pointer to table scope map parameters
647 int (*tf_dev_map_tbl_scope)(struct tf *tfp,
648 struct tf_map_tbl_scope_parms *parms);
651 * Free EEM table scope
654 * Pointer to TF handle
657 * Pointer to table scope free parameters
663 int (*tf_dev_free_tbl_scope)(struct tf *tfp,
664 struct tf_free_tbl_scope_parms *parms);
667 * Sets the specified interface table type element.
669 * This API sets the specified element data by invoking the
673 * Pointer to TF handle
676 * Pointer to interface table set parameters
679 * - (0) if successful.
680 * - (-EINVAL) on failure.
682 int (*tf_dev_set_if_tbl)(struct tf *tfp,
683 struct tf_if_tbl_set_parms *parms);
686 * Retrieves the specified interface table type element.
688 * This API retrieves the specified element data by invoking the
692 * Pointer to TF handle
695 * Pointer to table get parameters
698 * - (0) if successful.
699 * - (-EINVAL) on failure.
701 int (*tf_dev_get_if_tbl)(struct tf *tfp,
702 struct tf_if_tbl_get_parms *parms);
708 * Pointer to TF handle
711 * Pointer to global cfg parameters
717 int (*tf_dev_set_global_cfg)(struct tf *tfp,
718 struct tf_global_cfg_parms *parms);
724 * Pointer to TF handle
727 * Pointer to global cfg parameters
733 int (*tf_dev_get_global_cfg)(struct tf *tfp,
734 struct tf_global_cfg_parms *parms);
742 int (*tf_dev_get_mailbox)(void);
745 * Convert length in bit to length in byte and align to word.
746 * The word length depends on device type.
754 int (*tf_dev_word_align)(uint16_t size);
758 * Supported device operation structures
760 extern const struct tf_dev_ops tf_dev_ops_p4_init;
761 extern const struct tf_dev_ops tf_dev_ops_p4;
762 extern const struct tf_dev_ops tf_dev_ops_p58_init;
763 extern const struct tf_dev_ops tf_dev_ops_p58;
765 #endif /* _TF_DEVICE_H_ */