1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2020 Broadcom
10 #include "tf_identifier.h"
11 #include "tf_tbl_type.h"
20 enum tf_device_module_type {
21 TF_DEVICE_MODULE_TYPE_IDENTIFIER,
22 TF_DEVICE_MODULE_TYPE_TABLE,
23 TF_DEVICE_MODULE_TYPE_TCAM,
24 TF_DEVICE_MODULE_TYPE_EM,
25 TF_DEVICE_MODULE_TYPE_MAX
29 * The Device module provides a general device template. A supported
30 * device type should implement one or more of the listed function
31 * pointers according to its capabilities.
33 * If a device function pointer is NULL the device capability is not
38 * TF device information
41 enum tf_device_type type;
42 const struct tf_dev_ops *ops;
54 * Device bind handles the initialization of the specified device
58 * Pointer to TF handle
64 * Pointer to resource allocation information
70 * - (0) if successful.
71 * - (-EINVAL) parameter failure.
72 * - (-ENODEV) no such device supported.
74 int tf_dev_bind(struct tf *tfp,
75 enum tf_device_type type,
77 struct tf_session_resources *resources,
78 struct tf_dev_info *dev_handle);
81 * Device release handles cleanup of the device specific information.
84 * Pointer to TF handle
90 * - (0) if successful.
91 * - (-EINVAL) parameter failure.
92 * - (-ENODEV) no such device supported.
94 int tf_dev_unbind(struct tf *tfp,
95 struct tf_dev_info *dev_handle);
98 * Truflow device specific function hooks structure
100 * The following device hooks can be defined; unless noted otherwise,
101 * they are optional and can be filled with a null pointer. The
102 * purpose of these hooks is to support Truflow device operations for
103 * different device variants.
107 * Retrieves the MAX number of resource types that the device
111 * Pointer to TF handle
114 * Pointer to MAX number of types the device supports
117 * - (0) if successful.
118 * - (-EINVAL) on failure.
120 int (*tf_dev_get_max_types)(struct tf *tfp,
121 uint16_t *max_types);
124 * Retrieves the WC TCAM slice information that the device
128 * Pointer to TF handle
136 * [out] num_slices_per_row
137 * Pointer to number of slices per row the device supports
140 * - (0) if successful.
141 * - (-EINVAL) on failure.
143 int (*tf_dev_get_tcam_slice_info)(struct tf *tfp,
144 enum tf_tcam_tbl_type type,
146 uint16_t *num_slices_per_row);
149 * Allocation of an identifier element.
151 * This API allocates the specified identifier element from a
152 * device specific identifier DB. The allocated element is
156 * Pointer to TF handle
159 * Pointer to identifier allocation parameters
162 * - (0) if successful.
163 * - (-EINVAL) on failure.
165 int (*tf_dev_alloc_ident)(struct tf *tfp,
166 struct tf_ident_alloc_parms *parms);
169 * Free of an identifier element.
171 * This API free's a previous allocated identifier element from a
172 * device specific identifier DB.
175 * Pointer to TF handle
178 * Pointer to identifier free parameters
181 * - (0) if successful.
182 * - (-EINVAL) on failure.
184 int (*tf_dev_free_ident)(struct tf *tfp,
185 struct tf_ident_free_parms *parms);
188 * Allocation of a table type element.
190 * This API allocates the specified table type element from a
191 * device specific table type DB. The allocated element is
195 * Pointer to TF handle
198 * Pointer to table allocation parameters
201 * - (0) if successful.
202 * - (-EINVAL) on failure.
204 int (*tf_dev_alloc_tbl)(struct tf *tfp,
205 struct tf_tbl_alloc_parms *parms);
208 * Free of a table type element.
210 * This API free's a previous allocated table type element from a
211 * device specific table type DB.
214 * Pointer to TF handle
217 * Pointer to table free parameters
220 * - (0) if successful.
221 * - (-EINVAL) on failure.
223 int (*tf_dev_free_tbl)(struct tf *tfp,
224 struct tf_tbl_free_parms *parms);
227 * Searches for the specified table type element in a shadow DB.
229 * This API searches for the specified table type element in a
230 * device specific shadow DB. If the element is found the
231 * reference count for the element is updated. If the element
232 * is not found a new element is allocated from the table type
233 * DB and then inserted into the shadow DB.
236 * Pointer to TF handle
239 * Pointer to table allocation and search parameters
242 * - (0) if successful.
243 * - (-EINVAL) on failure.
245 int (*tf_dev_alloc_search_tbl)(struct tf *tfp,
246 struct tf_tbl_alloc_search_parms *parms);
249 * Sets the specified table type element.
251 * This API sets the specified element data by invoking the
255 * Pointer to TF handle
258 * Pointer to table set parameters
261 * - (0) if successful.
262 * - (-EINVAL) on failure.
264 int (*tf_dev_set_tbl)(struct tf *tfp,
265 struct tf_tbl_set_parms *parms);
268 * Retrieves the specified table type element.
270 * This API retrieves the specified element data by invoking the
274 * Pointer to TF handle
277 * Pointer to table get parameters
280 * - (0) if successful.
281 * - (-EINVAL) on failure.
283 int (*tf_dev_get_tbl)(struct tf *tfp,
284 struct tf_tbl_get_parms *parms);
287 * Allocation of a tcam element.
289 * This API allocates the specified tcam element from a device
290 * specific tcam DB. The allocated element is returned.
293 * Pointer to TF handle
296 * Pointer to tcam allocation parameters
299 * - (0) if successful.
300 * - (-EINVAL) on failure.
302 int (*tf_dev_alloc_tcam)(struct tf *tfp,
303 struct tf_tcam_alloc_parms *parms);
306 * Free of a tcam element.
308 * This API free's a previous allocated tcam element from a
309 * device specific tcam DB.
312 * Pointer to TF handle
315 * Pointer to tcam free parameters
318 * - (0) if successful.
319 * - (-EINVAL) on failure.
321 int (*tf_dev_free_tcam)(struct tf *tfp,
322 struct tf_tcam_free_parms *parms);
325 * Searches for the specified tcam element in a shadow DB.
327 * This API searches for the specified tcam element in a
328 * device specific shadow DB. If the element is found the
329 * reference count for the element is updated. If the element
330 * is not found a new element is allocated from the tcam DB
331 * and then inserted into the shadow DB.
334 * Pointer to TF handle
337 * Pointer to tcam allocation and search parameters
340 * - (0) if successful.
341 * - (-EINVAL) on failure.
343 int (*tf_dev_alloc_search_tcam)
345 struct tf_tcam_alloc_search_parms *parms);
348 * Sets the specified tcam element.
350 * This API sets the specified element data by invoking the
354 * Pointer to TF handle
357 * Pointer to tcam set parameters
360 * - (0) if successful.
361 * - (-EINVAL) on failure.
363 int (*tf_dev_set_tcam)(struct tf *tfp,
364 struct tf_tcam_set_parms *parms);
367 * Retrieves the specified tcam element.
369 * This API retrieves the specified element data by invoking the
373 * Pointer to TF handle
376 * Pointer to tcam get parameters
379 * - (0) if successful.
380 * - (-EINVAL) on failure.
382 int (*tf_dev_get_tcam)(struct tf *tfp,
383 struct tf_tcam_get_parms *parms);
386 * Insert EM hash entry API
389 * Pointer to TF handle
392 * Pointer to E/EM insert parameters
398 int (*tf_dev_insert_em_entry)(struct tf *tfp,
399 struct tf_insert_em_entry_parms *parms);
402 * Delete EM hash entry API
405 * Pointer to TF handle
408 * Pointer to E/EM delete parameters
414 int (*tf_dev_delete_em_entry)(struct tf *tfp,
415 struct tf_delete_em_entry_parms *parms);
419 * Supported device operation structures
421 extern const struct tf_dev_ops tf_dev_ops_p4_init;
422 extern const struct tf_dev_ops tf_dev_ops_p4;
424 #endif /* _TF_DEVICE_H_ */