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 * Allocation of a external table type element.
222 * This API allocates the specified table type element from a
223 * device specific table type DB. The allocated element is
227 * Pointer to TF handle
230 * Pointer to table allocation parameters
233 * - (0) if successful.
234 * - (-EINVAL) on failure.
236 int (*tf_dev_alloc_ext_tbl)(struct tf *tfp,
237 struct tf_tbl_alloc_parms *parms);
240 * Free of a table type element.
242 * This API free's a previous allocated table type element from a
243 * device specific table type DB.
246 * Pointer to TF handle
249 * Pointer to table free parameters
252 * - (0) if successful.
253 * - (-EINVAL) on failure.
255 int (*tf_dev_free_tbl)(struct tf *tfp,
256 struct tf_tbl_free_parms *parms);
259 * Free of a external table type element.
261 * This API free's a previous allocated table type element from a
262 * device specific table type DB.
265 * Pointer to TF handle
268 * Pointer to table free parameters
271 * - (0) if successful.
272 * - (-EINVAL) on failure.
274 int (*tf_dev_free_ext_tbl)(struct tf *tfp,
275 struct tf_tbl_free_parms *parms);
278 * Searches for the specified table type element in a shadow DB.
280 * This API searches for the specified table type element in a
281 * device specific shadow DB. If the element is found the
282 * reference count for the element is updated. If the element
283 * is not found a new element is allocated from the table type
284 * DB and then inserted into the shadow DB.
287 * Pointer to TF handle
290 * Pointer to table allocation and search parameters
293 * - (0) if successful.
294 * - (-EINVAL) on failure.
296 int (*tf_dev_alloc_search_tbl)(struct tf *tfp,
297 struct tf_tbl_alloc_search_parms *parms);
300 * Sets the specified table type element.
302 * This API sets the specified element data by invoking the
306 * Pointer to TF handle
309 * Pointer to table set parameters
312 * - (0) if successful.
313 * - (-EINVAL) on failure.
315 int (*tf_dev_set_tbl)(struct tf *tfp,
316 struct tf_tbl_set_parms *parms);
319 * Sets the specified external table type element.
321 * This API sets the specified element data by invoking the
325 * Pointer to TF handle
328 * Pointer to table set parameters
331 * - (0) if successful.
332 * - (-EINVAL) on failure.
334 int (*tf_dev_set_ext_tbl)(struct tf *tfp,
335 struct tf_tbl_set_parms *parms);
338 * Retrieves the specified table type element.
340 * This API retrieves the specified element data by invoking the
344 * Pointer to TF handle
347 * Pointer to table get parameters
350 * - (0) if successful.
351 * - (-EINVAL) on failure.
353 int (*tf_dev_get_tbl)(struct tf *tfp,
354 struct tf_tbl_get_parms *parms);
357 * Retrieves the specified table type element using 'bulk'
360 * This API retrieves the specified element data by invoking the
364 * Pointer to TF handle
367 * Pointer to table get bulk parameters
370 * - (0) if successful.
371 * - (-EINVAL) on failure.
373 int (*tf_dev_get_bulk_tbl)(struct tf *tfp,
374 struct tf_tbl_get_bulk_parms *parms);
377 * Allocation of a tcam element.
379 * This API allocates the specified tcam element from a device
380 * specific tcam DB. The allocated element is returned.
383 * Pointer to TF handle
386 * Pointer to tcam allocation parameters
389 * - (0) if successful.
390 * - (-EINVAL) on failure.
392 int (*tf_dev_alloc_tcam)(struct tf *tfp,
393 struct tf_tcam_alloc_parms *parms);
396 * Free of a tcam element.
398 * This API free's a previous allocated tcam element from a
399 * device specific tcam DB.
402 * Pointer to TF handle
405 * Pointer to tcam free parameters
408 * - (0) if successful.
409 * - (-EINVAL) on failure.
411 int (*tf_dev_free_tcam)(struct tf *tfp,
412 struct tf_tcam_free_parms *parms);
415 * Searches for the specified tcam element in a shadow DB.
417 * This API searches for the specified tcam element in a
418 * device specific shadow DB. If the element is found the
419 * reference count for the element is updated. If the element
420 * is not found a new element is allocated from the tcam DB
421 * and then inserted into the shadow DB.
424 * Pointer to TF handle
427 * Pointer to tcam allocation and search parameters
430 * - (0) if successful.
431 * - (-EINVAL) on failure.
433 int (*tf_dev_alloc_search_tcam)
435 struct tf_tcam_alloc_search_parms *parms);
438 * Sets the specified tcam element.
440 * This API sets the specified element data by invoking the
444 * Pointer to TF handle
447 * Pointer to tcam set parameters
450 * - (0) if successful.
451 * - (-EINVAL) on failure.
453 int (*tf_dev_set_tcam)(struct tf *tfp,
454 struct tf_tcam_set_parms *parms);
457 * Retrieves the specified tcam element.
459 * This API retrieves the specified element data by invoking the
463 * Pointer to TF handle
466 * Pointer to tcam get parameters
469 * - (0) if successful.
470 * - (-EINVAL) on failure.
472 int (*tf_dev_get_tcam)(struct tf *tfp,
473 struct tf_tcam_get_parms *parms);
476 * Insert EM hash entry API
479 * Pointer to TF handle
482 * Pointer to E/EM insert parameters
488 int (*tf_dev_insert_int_em_entry)(struct tf *tfp,
489 struct tf_insert_em_entry_parms *parms);
492 * Delete EM hash entry API
495 * Pointer to TF handle
498 * Pointer to E/EM delete parameters
504 int (*tf_dev_delete_int_em_entry)(struct tf *tfp,
505 struct tf_delete_em_entry_parms *parms);
508 * Insert EEM hash entry API
511 * Pointer to TF handle
514 * Pointer to E/EM insert parameters
520 int (*tf_dev_insert_ext_em_entry)(struct tf *tfp,
521 struct tf_insert_em_entry_parms *parms);
524 * Delete EEM hash entry API
527 * Pointer to TF handle
530 * Pointer to E/EM delete parameters
536 int (*tf_dev_delete_ext_em_entry)(struct tf *tfp,
537 struct tf_delete_em_entry_parms *parms);
540 * Allocate EEM table scope
543 * Pointer to TF handle
546 * Pointer to table scope alloc parameters
552 int (*tf_dev_alloc_tbl_scope)(struct tf *tfp,
553 struct tf_alloc_tbl_scope_parms *parms);
556 * Free EEM table scope
559 * Pointer to TF handle
562 * Pointer to table scope free parameters
568 int (*tf_dev_free_tbl_scope)(struct tf *tfp,
569 struct tf_free_tbl_scope_parms *parms);
573 * Supported device operation structures
575 extern const struct tf_dev_ops tf_dev_ops_p4_init;
576 extern const struct tf_dev_ops tf_dev_ops_p4;
578 #endif /* _TF_DEVICE_H_ */