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 enum tf_device_type type;
31 const struct tf_dev_ops *ops;
43 * Device bind handles the initialization of the specified device
47 * Pointer to TF handle
53 * Pointer to resource allocation information
59 * - (0) if successful.
60 * - (-EINVAL) parameter failure.
61 * - (-ENODEV) no such device supported.
63 int dev_bind(struct tf *tfp,
64 enum tf_device_type type,
66 struct tf_session_resources *resources,
67 struct tf_dev_info *dev_handle);
70 * Device release handles cleanup of the device specific information.
73 * Pointer to TF handle
79 * - (0) if successful.
80 * - (-EINVAL) parameter failure.
81 * - (-ENODEV) no such device supported.
83 int dev_unbind(struct tf *tfp,
84 struct tf_dev_info *dev_handle);
87 * Truflow device specific function hooks structure
89 * The following device hooks can be defined; unless noted otherwise,
90 * they are optional and can be filled with a null pointer. The
91 * purpose of these hooks is to support Truflow device operations for
92 * different device variants.
96 * Retrieves the MAX number of resource types that the device
100 * Pointer to TF handle
103 * Pointer to MAX number of types the device supports
106 * - (0) if successful.
107 * - (-EINVAL) on failure.
109 int (*tf_dev_get_max_types)(struct tf *tfp,
110 uint16_t *max_types);
113 * Retrieves the WC TCAM slice information that the device
117 * Pointer to TF handle
120 * Pointer to slice size the device supports
122 * [out] num_slices_per_row
123 * Pointer to number of slices per row the device supports
126 * - (0) if successful.
127 * - (-EINVAL) on failure.
129 int (*tf_dev_get_wc_tcam_slices)(struct tf *tfp,
130 uint16_t *slice_size,
131 uint16_t *num_slices_per_row);
134 * Allocation of an identifier element.
136 * This API allocates the specified identifier element from a
137 * device specific identifier DB. The allocated element is
141 * Pointer to TF handle
144 * Pointer to identifier allocation parameters
147 * - (0) if successful.
148 * - (-EINVAL) on failure.
150 int (*tf_dev_alloc_ident)(struct tf *tfp,
151 struct tf_ident_alloc_parms *parms);
154 * Free of an identifier element.
156 * This API free's a previous allocated identifier element from a
157 * device specific identifier DB.
160 * Pointer to TF handle
163 * Pointer to identifier free parameters
166 * - (0) if successful.
167 * - (-EINVAL) on failure.
169 int (*tf_dev_free_ident)(struct tf *tfp,
170 struct tf_ident_free_parms *parms);
173 * Allocation of a table type element.
175 * This API allocates the specified table type element from a
176 * device specific table type DB. The allocated element is
180 * Pointer to TF handle
183 * Pointer to table allocation parameters
186 * - (0) if successful.
187 * - (-EINVAL) on failure.
189 int (*tf_dev_alloc_tbl)(struct tf *tfp,
190 struct tf_tbl_alloc_parms *parms);
193 * Free of a table type element.
195 * This API free's a previous allocated table type element from a
196 * device specific table type DB.
199 * Pointer to TF handle
202 * Pointer to table free parameters
205 * - (0) if successful.
206 * - (-EINVAL) on failure.
208 int (*tf_dev_free_tbl)(struct tf *tfp,
209 struct tf_tbl_free_parms *parms);
212 * Searches for the specified table type element in a shadow DB.
214 * This API searches for the specified table type element in a
215 * device specific shadow DB. If the element is found the
216 * reference count for the element is updated. If the element
217 * is not found a new element is allocated from the table type
218 * DB and then inserted into the shadow DB.
221 * Pointer to TF handle
224 * Pointer to table allocation and search parameters
227 * - (0) if successful.
228 * - (-EINVAL) on failure.
230 int (*tf_dev_alloc_search_tbl)(struct tf *tfp,
231 struct tf_tbl_alloc_search_parms *parms);
234 * Sets the specified table type element.
236 * This API sets the specified element data by invoking the
240 * Pointer to TF handle
243 * Pointer to table set parameters
246 * - (0) if successful.
247 * - (-EINVAL) on failure.
249 int (*tf_dev_set_tbl)(struct tf *tfp,
250 struct tf_tbl_set_parms *parms);
253 * Retrieves the specified table type element.
255 * This API retrieves the specified element data by invoking the
259 * Pointer to TF handle
262 * Pointer to table get parameters
265 * - (0) if successful.
266 * - (-EINVAL) on failure.
268 int (*tf_dev_get_tbl)(struct tf *tfp,
269 struct tf_tbl_get_parms *parms);
272 * Allocation of a tcam element.
274 * This API allocates the specified tcam element from a device
275 * specific tcam DB. The allocated element is returned.
278 * Pointer to TF handle
281 * Pointer to tcam allocation parameters
284 * - (0) if successful.
285 * - (-EINVAL) on failure.
287 int (*tf_dev_alloc_tcam)(struct tf *tfp,
288 struct tf_tcam_alloc_parms *parms);
291 * Free of a tcam element.
293 * This API free's a previous allocated tcam element from a
294 * device specific tcam DB.
297 * Pointer to TF handle
300 * Pointer to tcam free parameters
303 * - (0) if successful.
304 * - (-EINVAL) on failure.
306 int (*tf_dev_free_tcam)(struct tf *tfp,
307 struct tf_tcam_free_parms *parms);
310 * Searches for the specified tcam element in a shadow DB.
312 * This API searches for the specified tcam element in a
313 * device specific shadow DB. If the element is found the
314 * reference count for the element is updated. If the element
315 * is not found a new element is allocated from the tcam DB
316 * and then inserted into the shadow DB.
319 * Pointer to TF handle
322 * Pointer to tcam allocation and search parameters
325 * - (0) if successful.
326 * - (-EINVAL) on failure.
328 int (*tf_dev_alloc_search_tcam)
330 struct tf_tcam_alloc_search_parms *parms);
333 * Sets the specified tcam element.
335 * This API sets the specified element data by invoking the
339 * Pointer to TF handle
342 * Pointer to tcam set parameters
345 * - (0) if successful.
346 * - (-EINVAL) on failure.
348 int (*tf_dev_set_tcam)(struct tf *tfp,
349 struct tf_tcam_set_parms *parms);
352 * Retrieves the specified tcam element.
354 * This API retrieves the specified element data by invoking the
358 * Pointer to TF handle
361 * Pointer to tcam get parameters
364 * - (0) if successful.
365 * - (-EINVAL) on failure.
367 int (*tf_dev_get_tcam)(struct tf *tfp,
368 struct tf_tcam_get_parms *parms);
372 * Supported device operation structures
374 extern const struct tf_dev_ops tf_dev_ops_p4;
376 #endif /* _TF_DEVICE_H_ */