1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2019-2020 Broadcom
10 #include "tf_identifier.h"
11 #include "tf_tbl_type.h"
18 * The Device module provides a general device template. A supported
19 * device type should implement one or more of the listed function
20 * pointers according to its capabilities.
22 * If a device function pointer is NULL the device capability is not
27 * TF device information
30 const struct tf_dev_ops *ops;
42 * Device bind handles the initialization of the specified device
46 * Pointer to TF handle
52 * Pointer to resource allocation information
58 * - (0) if successful.
59 * - (-EINVAL) on failure.
61 int dev_bind(struct tf *tfp,
62 enum tf_device_type type,
63 struct tf_session_resources *resources,
64 struct tf_dev_info *dev_handle);
67 * Device release handles cleanup of the device specific information.
70 * Pointer to TF handle
75 int dev_unbind(struct tf *tfp,
76 struct tf_dev_info *dev_handle);
79 * Truflow device specific function hooks structure
81 * The following device hooks can be defined; unless noted otherwise,
82 * they are optional and can be filled with a null pointer. The
83 * purpose of these hooks is to support Truflow device operations for
84 * different device variants.
88 * Allocation of an identifier element.
90 * This API allocates the specified identifier element from a
91 * device specific identifier DB. The allocated element is
95 * Pointer to TF handle
98 * Pointer to identifier allocation parameters
101 * - (0) if successful.
102 * - (-EINVAL) on failure.
104 int (*tf_dev_alloc_ident)(struct tf *tfp,
105 struct tf_ident_alloc_parms *parms);
108 * Free of an identifier element.
110 * This API free's a previous allocated identifier element from a
111 * device specific identifier DB.
114 * Pointer to TF handle
117 * Pointer to identifier free parameters
120 * - (0) if successful.
121 * - (-EINVAL) on failure.
123 int (*tf_dev_free_ident)(struct tf *tfp,
124 struct tf_ident_free_parms *parms);
127 * Allocation of a table type element.
129 * This API allocates the specified table type element from a
130 * device specific table type DB. The allocated element is
134 * Pointer to TF handle
137 * Pointer to table type allocation parameters
140 * - (0) if successful.
141 * - (-EINVAL) on failure.
143 int (*tf_dev_alloc_tbl_type)(struct tf *tfp,
144 struct tf_tbl_type_alloc_parms *parms);
147 * Free of a table type element.
149 * This API free's a previous allocated table type element from a
150 * device specific table type DB.
153 * Pointer to TF handle
156 * Pointer to table type free parameters
159 * - (0) if successful.
160 * - (-EINVAL) on failure.
162 int (*tf_dev_free_tbl_type)(struct tf *tfp,
163 struct tf_tbl_type_free_parms *parms);
166 * Searches for the specified table type element in a shadow DB.
168 * This API searches for the specified table type element in a
169 * device specific shadow DB. If the element is found the
170 * reference count for the element is updated. If the element
171 * is not found a new element is allocated from the table type
172 * DB and then inserted into the shadow DB.
175 * Pointer to TF handle
178 * Pointer to table type allocation and search parameters
181 * - (0) if successful.
182 * - (-EINVAL) on failure.
184 int (*tf_dev_alloc_search_tbl_type)
186 struct tf_tbl_type_alloc_search_parms *parms);
189 * Sets the specified table type element.
191 * This API sets the specified element data by invoking the
195 * Pointer to TF handle
198 * Pointer to table type set parameters
201 * - (0) if successful.
202 * - (-EINVAL) on failure.
204 int (*tf_dev_set_tbl_type)(struct tf *tfp,
205 struct tf_tbl_type_set_parms *parms);
208 * Retrieves the specified table type element.
210 * This API retrieves the specified element data by invoking the
214 * Pointer to TF handle
217 * Pointer to table type get parameters
220 * - (0) if successful.
221 * - (-EINVAL) on failure.
223 int (*tf_dev_get_tbl_type)(struct tf *tfp,
224 struct tf_tbl_type_get_parms *parms);
227 * Allocation of a tcam element.
229 * This API allocates the specified tcam element from a device
230 * specific tcam DB. The allocated element is returned.
233 * Pointer to TF handle
236 * Pointer to tcam allocation parameters
239 * - (0) if successful.
240 * - (-EINVAL) on failure.
242 int (*tf_dev_alloc_tcam)(struct tf *tfp,
243 struct tf_tcam_alloc_parms *parms);
246 * Free of a tcam element.
248 * This API free's a previous allocated tcam element from a
249 * device specific tcam DB.
252 * Pointer to TF handle
255 * Pointer to tcam free parameters
258 * - (0) if successful.
259 * - (-EINVAL) on failure.
261 int (*tf_dev_free_tcam)(struct tf *tfp,
262 struct tf_tcam_free_parms *parms);
265 * Searches for the specified tcam element in a shadow DB.
267 * This API searches for the specified tcam element in a
268 * device specific shadow DB. If the element is found the
269 * reference count for the element is updated. If the element
270 * is not found a new element is allocated from the tcam DB
271 * and then inserted into the shadow DB.
274 * Pointer to TF handle
277 * Pointer to tcam allocation and search parameters
280 * - (0) if successful.
281 * - (-EINVAL) on failure.
283 int (*tf_dev_alloc_search_tcam)
285 struct tf_tcam_alloc_search_parms *parms);
288 * Sets the specified tcam element.
290 * This API sets the specified element data by invoking the
294 * Pointer to TF handle
297 * Pointer to tcam set parameters
300 * - (0) if successful.
301 * - (-EINVAL) on failure.
303 int (*tf_dev_set_tcam)(struct tf *tfp,
304 struct tf_tcam_set_parms *parms);
307 * Retrieves the specified tcam element.
309 * This API retrieves the specified element data by invoking the
313 * Pointer to TF handle
316 * Pointer to tcam get parameters
319 * - (0) if successful.
320 * - (-EINVAL) on failure.
322 int (*tf_dev_get_tcam)(struct tf *tfp,
323 struct tf_tcam_get_parms *parms);
327 * Supported device operation structures
329 extern const struct tf_dev_ops tf_dev_ops_p4;
331 #endif /* _TF_DEVICE_H_ */