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
125 * [out] num_slices_per_row
126 * Pointer to number of slices per row the device supports
129 * - (0) if successful.
130 * - (-EINVAL) on failure.
132 int (*tf_dev_get_tcam_slice_info)(struct tf *tfp,
133 enum tf_tcam_tbl_type type,
135 uint16_t *num_slices_per_row);
138 * Allocation of an identifier element.
140 * This API allocates the specified identifier element from a
141 * device specific identifier DB. The allocated element is
145 * Pointer to TF handle
148 * Pointer to identifier allocation parameters
151 * - (0) if successful.
152 * - (-EINVAL) on failure.
154 int (*tf_dev_alloc_ident)(struct tf *tfp,
155 struct tf_ident_alloc_parms *parms);
158 * Free of an identifier element.
160 * This API free's a previous allocated identifier element from a
161 * device specific identifier DB.
164 * Pointer to TF handle
167 * Pointer to identifier free parameters
170 * - (0) if successful.
171 * - (-EINVAL) on failure.
173 int (*tf_dev_free_ident)(struct tf *tfp,
174 struct tf_ident_free_parms *parms);
177 * Allocation of a table type element.
179 * This API allocates the specified table type element from a
180 * device specific table type DB. The allocated element is
184 * Pointer to TF handle
187 * Pointer to table allocation parameters
190 * - (0) if successful.
191 * - (-EINVAL) on failure.
193 int (*tf_dev_alloc_tbl)(struct tf *tfp,
194 struct tf_tbl_alloc_parms *parms);
197 * Free of a table type element.
199 * This API free's a previous allocated table type element from a
200 * device specific table type DB.
203 * Pointer to TF handle
206 * Pointer to table free parameters
209 * - (0) if successful.
210 * - (-EINVAL) on failure.
212 int (*tf_dev_free_tbl)(struct tf *tfp,
213 struct tf_tbl_free_parms *parms);
216 * Searches for the specified table type element in a shadow DB.
218 * This API searches for the specified table type element in a
219 * device specific shadow DB. If the element is found the
220 * reference count for the element is updated. If the element
221 * is not found a new element is allocated from the table type
222 * DB and then inserted into the shadow DB.
225 * Pointer to TF handle
228 * Pointer to table allocation and search parameters
231 * - (0) if successful.
232 * - (-EINVAL) on failure.
234 int (*tf_dev_alloc_search_tbl)(struct tf *tfp,
235 struct tf_tbl_alloc_search_parms *parms);
238 * Sets the specified table type element.
240 * This API sets the specified element data by invoking the
244 * Pointer to TF handle
247 * Pointer to table set parameters
250 * - (0) if successful.
251 * - (-EINVAL) on failure.
253 int (*tf_dev_set_tbl)(struct tf *tfp,
254 struct tf_tbl_set_parms *parms);
257 * Retrieves the specified table type element.
259 * This API retrieves the specified element data by invoking the
263 * Pointer to TF handle
266 * Pointer to table get parameters
269 * - (0) if successful.
270 * - (-EINVAL) on failure.
272 int (*tf_dev_get_tbl)(struct tf *tfp,
273 struct tf_tbl_get_parms *parms);
276 * Allocation of a tcam element.
278 * This API allocates the specified tcam element from a device
279 * specific tcam DB. The allocated element is returned.
282 * Pointer to TF handle
285 * Pointer to tcam allocation parameters
288 * - (0) if successful.
289 * - (-EINVAL) on failure.
291 int (*tf_dev_alloc_tcam)(struct tf *tfp,
292 struct tf_tcam_alloc_parms *parms);
295 * Free of a tcam element.
297 * This API free's a previous allocated tcam element from a
298 * device specific tcam DB.
301 * Pointer to TF handle
304 * Pointer to tcam free parameters
307 * - (0) if successful.
308 * - (-EINVAL) on failure.
310 int (*tf_dev_free_tcam)(struct tf *tfp,
311 struct tf_tcam_free_parms *parms);
314 * Searches for the specified tcam element in a shadow DB.
316 * This API searches for the specified tcam element in a
317 * device specific shadow DB. If the element is found the
318 * reference count for the element is updated. If the element
319 * is not found a new element is allocated from the tcam DB
320 * and then inserted into the shadow DB.
323 * Pointer to TF handle
326 * Pointer to tcam allocation and search parameters
329 * - (0) if successful.
330 * - (-EINVAL) on failure.
332 int (*tf_dev_alloc_search_tcam)
334 struct tf_tcam_alloc_search_parms *parms);
337 * Sets the specified tcam element.
339 * This API sets the specified element data by invoking the
343 * Pointer to TF handle
346 * Pointer to tcam set parameters
349 * - (0) if successful.
350 * - (-EINVAL) on failure.
352 int (*tf_dev_set_tcam)(struct tf *tfp,
353 struct tf_tcam_set_parms *parms);
356 * Retrieves the specified tcam element.
358 * This API retrieves the specified element data by invoking the
362 * Pointer to TF handle
365 * Pointer to tcam get parameters
368 * - (0) if successful.
369 * - (-EINVAL) on failure.
371 int (*tf_dev_get_tcam)(struct tf *tfp,
372 struct tf_tcam_get_parms *parms);
375 * Insert EM hash entry API
378 * Pointer to TF handle
381 * Pointer to E/EM insert parameters
387 int (*tf_dev_insert_em_entry)(struct tf *tfp,
388 struct tf_insert_em_entry_parms *parms);
391 * Delete EM hash entry API
394 * Pointer to TF handle
397 * Pointer to E/EM delete parameters
403 int (*tf_dev_delete_em_entry)(struct tf *tfp,
404 struct tf_delete_em_entry_parms *parms);
408 * Supported device operation structures
410 extern const struct tf_dev_ops tf_dev_ops_p4;
412 #endif /* _TF_DEVICE_H_ */