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 * Allocation of a table type element.
204 * This API allocates the specified table type element from a
205 * device specific table type DB. The allocated element is
209 * Pointer to TF handle
212 * Pointer to table allocation parameters
215 * - (0) if successful.
216 * - (-EINVAL) on failure.
218 int (*tf_dev_alloc_tbl)(struct tf *tfp,
219 struct tf_tbl_alloc_parms *parms);
222 * Allocation of a external 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_ext_tbl)(struct tf *tfp,
239 struct tf_tbl_alloc_parms *parms);
242 * Free of a table type element.
244 * This API free's a previous allocated table type element from a
245 * device specific table type DB.
248 * Pointer to TF handle
251 * Pointer to table free parameters
254 * - (0) if successful.
255 * - (-EINVAL) on failure.
257 int (*tf_dev_free_tbl)(struct tf *tfp,
258 struct tf_tbl_free_parms *parms);
261 * Free of a external table type element.
263 * This API free's a previous allocated table type element from a
264 * device specific table type DB.
267 * Pointer to TF handle
270 * Pointer to table free parameters
273 * - (0) if successful.
274 * - (-EINVAL) on failure.
276 int (*tf_dev_free_ext_tbl)(struct tf *tfp,
277 struct tf_tbl_free_parms *parms);
280 * Searches for the specified table type element in a shadow DB.
282 * This API searches for the specified table type element in a
283 * device specific shadow DB. If the element is found the
284 * reference count for the element is updated. If the element
285 * is not found a new element is allocated from the table type
286 * DB and then inserted into the shadow DB.
289 * Pointer to TF handle
292 * Pointer to table allocation and search parameters
295 * - (0) if successful.
296 * - (-EINVAL) on failure.
298 int (*tf_dev_alloc_search_tbl)(struct tf *tfp,
299 struct tf_tbl_alloc_search_parms *parms);
302 * Sets the specified table type element.
304 * This API sets the specified element data by invoking the
308 * Pointer to TF handle
311 * Pointer to table set parameters
314 * - (0) if successful.
315 * - (-EINVAL) on failure.
317 int (*tf_dev_set_tbl)(struct tf *tfp,
318 struct tf_tbl_set_parms *parms);
321 * Sets the specified external table type element.
323 * This API sets the specified element data by invoking the
327 * Pointer to TF handle
330 * Pointer to table set parameters
333 * - (0) if successful.
334 * - (-EINVAL) on failure.
336 int (*tf_dev_set_ext_tbl)(struct tf *tfp,
337 struct tf_tbl_set_parms *parms);
340 * Retrieves the specified table type element.
342 * This API retrieves the specified element data by invoking the
346 * Pointer to TF handle
349 * Pointer to table get parameters
352 * - (0) if successful.
353 * - (-EINVAL) on failure.
355 int (*tf_dev_get_tbl)(struct tf *tfp,
356 struct tf_tbl_get_parms *parms);
359 * Retrieves the specified table type element using 'bulk'
362 * This API retrieves the specified element data by invoking the
366 * Pointer to TF handle
369 * Pointer to table get bulk parameters
372 * - (0) if successful.
373 * - (-EINVAL) on failure.
375 int (*tf_dev_get_bulk_tbl)(struct tf *tfp,
376 struct tf_tbl_get_bulk_parms *parms);
379 * Allocation of a tcam element.
381 * This API allocates the specified tcam element from a device
382 * specific tcam DB. The allocated element is returned.
385 * Pointer to TF handle
388 * Pointer to tcam allocation parameters
391 * - (0) if successful.
392 * - (-EINVAL) on failure.
394 int (*tf_dev_alloc_tcam)(struct tf *tfp,
395 struct tf_tcam_alloc_parms *parms);
398 * Free of a tcam element.
400 * This API free's a previous allocated tcam element from a
401 * device specific tcam DB.
404 * Pointer to TF handle
407 * Pointer to tcam free parameters
410 * - (0) if successful.
411 * - (-EINVAL) on failure.
413 int (*tf_dev_free_tcam)(struct tf *tfp,
414 struct tf_tcam_free_parms *parms);
417 * Searches for the specified tcam element in a shadow DB.
419 * This API searches for the specified tcam element in a
420 * device specific shadow DB. If the element is found the
421 * reference count for the element is updated. If the element
422 * is not found a new element is allocated from the tcam DB
423 * and then inserted into the shadow DB.
426 * Pointer to TF handle
429 * Pointer to tcam allocation and search parameters
432 * - (0) if successful.
433 * - (-EINVAL) on failure.
435 int (*tf_dev_alloc_search_tcam)
437 struct tf_tcam_alloc_search_parms *parms);
440 * Sets the specified tcam element.
442 * This API sets the specified element data by invoking the
446 * Pointer to TF handle
449 * Pointer to tcam set parameters
452 * - (0) if successful.
453 * - (-EINVAL) on failure.
455 int (*tf_dev_set_tcam)(struct tf *tfp,
456 struct tf_tcam_set_parms *parms);
459 * Retrieves the specified tcam element.
461 * This API retrieves the specified element data by invoking the
465 * Pointer to TF handle
468 * Pointer to tcam get parameters
471 * - (0) if successful.
472 * - (-EINVAL) on failure.
474 int (*tf_dev_get_tcam)(struct tf *tfp,
475 struct tf_tcam_get_parms *parms);
478 * Insert EM hash entry API
481 * Pointer to TF handle
484 * Pointer to E/EM insert parameters
490 int (*tf_dev_insert_int_em_entry)(struct tf *tfp,
491 struct tf_insert_em_entry_parms *parms);
494 * Delete EM hash entry API
497 * Pointer to TF handle
500 * Pointer to E/EM delete parameters
506 int (*tf_dev_delete_int_em_entry)(struct tf *tfp,
507 struct tf_delete_em_entry_parms *parms);
510 * Insert EEM hash entry API
513 * Pointer to TF handle
516 * Pointer to E/EM insert parameters
522 int (*tf_dev_insert_ext_em_entry)(struct tf *tfp,
523 struct tf_insert_em_entry_parms *parms);
526 * Delete EEM hash entry API
529 * Pointer to TF handle
532 * Pointer to E/EM delete parameters
538 int (*tf_dev_delete_ext_em_entry)(struct tf *tfp,
539 struct tf_delete_em_entry_parms *parms);
542 * Allocate EEM table scope
545 * Pointer to TF handle
548 * Pointer to table scope alloc parameters
554 int (*tf_dev_alloc_tbl_scope)(struct tf *tfp,
555 struct tf_alloc_tbl_scope_parms *parms);
558 * Free EEM table scope
561 * Pointer to TF handle
564 * Pointer to table scope free parameters
570 int (*tf_dev_free_tbl_scope)(struct tf *tfp,
571 struct tf_free_tbl_scope_parms *parms);
574 * Sets the specified interface table type element.
576 * This API sets the specified element data by invoking the
580 * Pointer to TF handle
583 * Pointer to interface table set parameters
586 * - (0) if successful.
587 * - (-EINVAL) on failure.
589 int (*tf_dev_set_if_tbl)(struct tf *tfp,
590 struct tf_if_tbl_set_parms *parms);
593 * Retrieves the specified interface table type element.
595 * This API retrieves the specified element data by invoking the
599 * Pointer to TF handle
602 * Pointer to table get parameters
605 * - (0) if successful.
606 * - (-EINVAL) on failure.
608 int (*tf_dev_get_if_tbl)(struct tf *tfp,
609 struct tf_if_tbl_get_parms *parms);
615 * Pointer to TF handle
618 * Pointer to global cfg parameters
624 int (*tf_dev_set_global_cfg)(struct tf *tfp,
625 struct tf_dev_global_cfg_parms *parms);
631 * Pointer to TF handle
634 * Pointer to global cfg parameters
640 int (*tf_dev_get_global_cfg)(struct tf *tfp,
641 struct tf_dev_global_cfg_parms *parms);
645 * Supported device operation structures
647 extern const struct tf_dev_ops tf_dev_ops_p4_init;
648 extern const struct tf_dev_ops tf_dev_ops_p4;
650 #endif /* _TF_DEVICE_H_ */