xref: /dpdk/drivers/net/bnxt/tf_core/tf_device.h (revision 580fcb3d718069a8058f4395dd64d19fed0c1f65)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019-2024 Broadcom
3  * All rights reserved.
4  */
5 
6 #ifndef _TF_DEVICE_H_
7 #define _TF_DEVICE_H_
8 
9 #include "cfa_resource_types.h"
10 #include "tf_core.h"
11 #include "tf_identifier.h"
12 #include "tf_tbl.h"
13 #include "tf_tcam.h"
14 #include "tf_tcam_shared.h"
15 #include "tf_if_tbl.h"
16 #include "tf_global_cfg.h"
17 
18 struct tf;
19 struct tf_session;
20 
21 /**
22  * The Device module provides a general device template. A supported
23  * device type should implement one or more of the listed function
24  * pointers according to its capabilities.
25  *
26  * If a device function pointer is NULL the device capability is not
27  * supported.
28  */
29 
30 /**
31  * TF device information
32  */
33 struct tf_dev_info {
34 	enum tf_device_type type;
35 	const struct tf_dev_ops *ops;
36 };
37 
38 /**
39  * This structure can be used to translate the CFA resource type to TF type.
40  */
41 struct tf_hcapi_resource_map {
42 	/**
43 	 * Truflow module type associated with this resource type.
44 	 */
45 	enum tf_module_type module_type;
46 
47 	/**
48 	 * Bitmap of TF sub-type for the element.
49 	 */
50 	uint32_t type_caps;
51 };
52 
53 /**
54  * @page device Device
55  *
56  * @ref tf_dev_bind
57  *
58  * @ref tf_dev_unbind
59  */
60 
61 /**
62  * Device bind handles the initialization of the specified device
63  * type.
64  *
65  * [in] tfp
66  *   Pointer to TF handle
67  *
68  * [in] type
69  *   Device type
70  *
71  * [in] resources
72  *   Pointer to resource allocation information
73  *
74  * [in] wc_num_slices
75  *   Number of slices per row for WC
76  *
77  * [out] dev_handle
78  *   Device handle
79  *
80  * Returns
81  *   - (0) if successful.
82  *   - (-EINVAL) parameter failure.
83  *   - (-ENODEV) no such device supported.
84  */
85 int tf_dev_bind(struct tf *tfp,
86 		enum tf_device_type type,
87 		struct tf_session_resources *resources,
88 		uint16_t wc_num_slices,
89 		struct tf_dev_info *dev_handle);
90 
91 /**
92  * Device release handles cleanup of the device specific information.
93  *
94  * [in] tfp
95  *   Pointer to TF handle
96  *
97  * [in] dev_handle
98  *   Device handle
99  *
100  * Returns
101  *   - (0) if successful.
102  *   - (-EINVAL) parameter failure.
103  *   - (-ENODEV) no such device supported.
104  */
105 int tf_dev_unbind(struct tf *tfp,
106 		  struct tf_dev_info *dev_handle);
107 
108 int
109 tf_dev_bind_ops(enum tf_device_type type,
110 		struct tf_dev_info *dev_handle);
111 
112 /**
113  * Truflow device specific function hooks structure
114  *
115  * The following device hooks can be defined; unless noted otherwise,
116  * they are optional and can be filled with a null pointer. The
117  * purpose of these hooks is to support Truflow device operations for
118  * different device variants.
119  */
120 struct tf_dev_ops {
121 	/**
122 	 * Retrieves the MAX number of resource types that the device
123 	 * supports.
124 	 *
125 	 * [in] tfp
126 	 *   Pointer to TF handle
127 	 *
128 	 * [out] max_types
129 	 *   Pointer to MAX number of types the device supports
130 	 *
131 	 * Returns
132 	 *   - (0) if successful.
133 	 *   - (-EINVAL) on failure.
134 	 */
135 	int (*tf_dev_get_max_types)(struct tf *tfp,
136 				    uint16_t *max_types);
137 
138 	/**
139 	 * Retrieves the string description for the CFA resource
140 	 * type
141 	 *
142 	 * [in] tfp
143 	 *   Pointer to TF handle
144 	 *
145 	 * [in] resource_id
146 	 *   HCAPI cfa resource type id
147 	 *
148 	 * [out] resource_str
149 	 *   Pointer to a string
150 	 *
151 	 * Returns
152 	 *   - (0) if successful.
153 	 *   - (-EINVAL) on failure.
154 	 */
155 	int (*tf_dev_get_resource_str)(struct tf *tfp,
156 				       uint16_t resource_id,
157 				       const char **resource_str);
158 
159 	/**
160 	 * Set the WC TCAM slice information that the device
161 	 * supports.
162 	 *
163 	 * [in] tfp
164 	 *   Pointer to TF handle
165 	 *
166 	 * [in] num_slices_per_row
167 	 *   Number of slices per row the device supports
168 	 *
169 	 * Returns
170 	 *   - (0) if successful.
171 	 *   - (-EINVAL) on failure.
172 	 */
173 	int (*tf_dev_set_tcam_slice_info)(struct tf *tfp,
174 					  enum tf_wc_num_slice num_slices_per_row);
175 
176 	/**
177 	 * Retrieves the WC TCAM slice information that the device
178 	 * supports.
179 	 *
180 	 * [in] tfp
181 	 *   Pointer to TF handle
182 	 *
183 	 * [in] type
184 	 *   TCAM table type
185 	 *
186 	 * [in] key_sz
187 	 *   Key size
188 	 *
189 	 * [out] num_slices_per_row
190 	 *   Pointer to number of slices per row the device supports
191 	 *
192 	 * Returns
193 	 *   - (0) if successful.
194 	 *   - (-EINVAL) on failure.
195 	 */
196 	int (*tf_dev_get_tcam_slice_info)(struct tf *tfp,
197 					  enum tf_tcam_tbl_type type,
198 					  uint16_t key_sz,
199 					  uint16_t *num_slices_per_row);
200 
201 	/**
202 	 * Allocation of an identifier element.
203 	 *
204 	 * This API allocates the specified identifier element from a
205 	 * device specific identifier DB. The allocated element is
206 	 * returned.
207 	 *
208 	 * [in] tfp
209 	 *   Pointer to TF handle
210 	 *
211 	 * [in] parms
212 	 *   Pointer to identifier allocation parameters
213 	 *
214 	 * Returns
215 	 *   - (0) if successful.
216 	 *   - (-EINVAL) on failure.
217 	 */
218 	int (*tf_dev_alloc_ident)(struct tf *tfp,
219 				  struct tf_ident_alloc_parms *parms);
220 
221 	/**
222 	 * Free of an identifier element.
223 	 *
224 	 * This API free's a previous allocated identifier element from a
225 	 * device specific identifier DB.
226 	 *
227 	 * [in] tfp
228 	 *   Pointer to TF handle
229 	 *
230 	 * [in] parms
231 	 *   Pointer to identifier free parameters
232 	 *
233 	 * Returns
234 	 *   - (0) if successful.
235 	 *   - (-EINVAL) on failure.
236 	 */
237 	int (*tf_dev_free_ident)(struct tf *tfp,
238 				 struct tf_ident_free_parms *parms);
239 
240 	/**
241 	 * Search of an identifier element.
242 	 *
243 	 * This API search the specified identifier element from a
244 	 * device specific identifier shadow DB. The allocated element
245 	 * is returned.
246 	 *
247 	 * [in] tfp
248 	 *   Pointer to TF handle
249 	 *
250 	 * [in] parms
251 	 *   Pointer to identifier search parameters
252 	 *
253 	 * Returns
254 	 *   - (0) if successful.
255 	 *   - (-EINVAL) on failure.
256 	 */
257 	int (*tf_dev_search_ident)(struct tf *tfp,
258 				   struct tf_ident_search_parms *parms);
259 
260 	/**
261 	 * Retrieves the identifier resource info.
262 	 *
263 	 * This API retrieves the identifier resource info from the rm db.
264 	 *
265 	 * [in] tfp
266 	 *   Pointer to TF handle
267 	 *
268 	 * [in] parms
269 	 *   Pointer to identifier info
270 	 *
271 	 * Returns
272 	 *   - (0) if successful.
273 	 *   - (-EINVAL) on failure.
274 	 */
275 	int (*tf_dev_get_ident_resc_info)(struct tf *tfp,
276 					  struct tf_identifier_resource_info *parms);
277 
278 	/**
279 	 * Indicates whether the index table type is SRAM managed
280 	 *
281 	 * [in] tfp
282 	 *   Pointer to TF handle
283 	 *
284 	 * [in] type
285 	 *   Truflow index table type, e.g. TF_TYPE_FULL_ACT_RECORD
286 	 *
287 	 * Returns
288 	 *   - (0) if the table is not managed by the SRAM manager
289 	 *   - (1) if the table is managed by the SRAM manager
290 	 */
291 	bool (*tf_dev_is_sram_managed)(struct tf *tfp,
292 				       enum tf_tbl_type tbl_type);
293 
294 	/**
295 	 * Get SRAM table information.
296 	 *
297 	 * Converts an internal RM allocated element offset to
298 	 * a user address and vice versa.
299 	 *
300 	 * [in] tfp
301 	 *   Pointer to TF handle
302 	 *
303 	 * [in] type
304 	 *   Truflow index table type, e.g. TF_TYPE_FULL_ACT_RECORD
305 	 *
306 	 * [in/out] base
307 	 *   Pointer to the base address of the associated table type.
308 	 *
309 	 * [in/out] shift
310 	 *   Pointer to any shift required for the associated table type.
311 	 *
312 	 * Returns
313 	 *   - (0) if successful.
314 	 *   - (-EINVAL) on failure.
315 	 */
316 	int (*tf_dev_get_tbl_info)(struct tf *tfp,
317 				   void *tbl_db,
318 				   enum tf_tbl_type type,
319 				   uint16_t *base,
320 				   uint16_t *shift);
321 
322 	/**
323 	 * Allocation of an index table type element.
324 	 *
325 	 * This API allocates the specified table type element from a
326 	 * device specific table type DB. The allocated element is
327 	 * returned.
328 	 *
329 	 * [in] tfp
330 	 *   Pointer to TF handle
331 	 *
332 	 * [in] parms
333 	 *   Pointer to table allocation parameters
334 	 *
335 	 * Returns
336 	 *   - (0) if successful.
337 	 *   - (-EINVAL) on failure.
338 	 */
339 	int (*tf_dev_alloc_tbl)(struct tf *tfp,
340 				struct tf_tbl_alloc_parms *parms);
341 
342 	/**
343 	 * Allocation of an SRAM index table type element.
344 	 *
345 	 * This API allocates the specified table type element from a
346 	 * device specific table type DB. The allocated element is
347 	 * returned.
348 	 *
349 	 * [in] tfp
350 	 *   Pointer to TF handle
351 	 *
352 	 * [in] parms
353 	 *   Pointer to table allocation parameters
354 	 *
355 	 * Returns
356 	 *   - (0) if successful.
357 	 *   - (-EINVAL) on failure.
358 	 */
359 	int (*tf_dev_alloc_sram_tbl)(struct tf *tfp,
360 				     struct tf_tbl_alloc_parms *parms);
361 	/**
362 	 * Allocation of a external table type element.
363 	 *
364 	 * This API allocates the specified table type element from a
365 	 * device specific table type DB. The allocated element is
366 	 * returned.
367 	 *
368 	 * [in] tfp
369 	 *   Pointer to TF handle
370 	 *
371 	 * [in] parms
372 	 *   Pointer to table allocation parameters
373 	 *
374 	 * Returns
375 	 *   - (0) if successful.
376 	 *   - (-EINVAL) on failure.
377 	 */
378 	int (*tf_dev_alloc_ext_tbl)(struct tf *tfp,
379 				    struct tf_tbl_alloc_parms *parms);
380 
381 	/**
382 	 * Free of a table type element.
383 	 *
384 	 * This API free's a previous allocated table type element from a
385 	 * device specific table type DB.
386 	 *
387 	 * [in] tfp
388 	 *   Pointer to TF handle
389 	 *
390 	 * [in] parms
391 	 *   Pointer to table free parameters
392 	 *
393 	 * Returns
394 	 *   - (0) if successful.
395 	 *   - (-EINVAL) on failure.
396 	 */
397 	int (*tf_dev_free_tbl)(struct tf *tfp,
398 			       struct tf_tbl_free_parms *parms);
399 	/**
400 	 * Free of an SRAM table type element.
401 	 *
402 	 * This API free's a previous allocated table type element from a
403 	 * device specific table type DB.
404 	 *
405 	 * [in] tfp
406 	 *   Pointer to TF handle
407 	 *
408 	 * [in] parms
409 	 *   Pointer to table free parameters
410 	 *
411 	 * Returns
412 	 *   - (0) if successful.
413 	 *   - (-EINVAL) on failure.
414 	 */
415 	int (*tf_dev_free_sram_tbl)(struct tf *tfp,
416 				    struct tf_tbl_free_parms *parms);
417 	/**
418 	 * Free of a external table type element.
419 	 *
420 	 * This API free's a previous allocated table type element from a
421 	 * device specific table type DB.
422 	 *
423 	 * [in] tfp
424 	 *   Pointer to TF handle
425 	 *
426 	 * [in] parms
427 	 *   Pointer to table free parameters
428 	 *
429 	 * Returns
430 	 *   - (0) if successful.
431 	 *   - (-EINVAL) on failure.
432 	 */
433 	int (*tf_dev_free_ext_tbl)(struct tf *tfp,
434 				   struct tf_tbl_free_parms *parms);
435 
436 	/**
437 	 * Sets the specified table type element.
438 	 *
439 	 * This API sets the specified element data by invoking the
440 	 * firmware.
441 	 *
442 	 * [in] tfp
443 	 *   Pointer to TF handle
444 	 *
445 	 * [in] parms
446 	 *   Pointer to table set parameters
447 	 *
448 	 * Returns
449 	 *   - (0) if successful.
450 	 *   - (-EINVAL) on failure.
451 	 */
452 	int (*tf_dev_set_tbl)(struct tf *tfp,
453 			      struct tf_tbl_set_parms *parms);
454 
455 	/**
456 	 * Sets the specified external table type element.
457 	 *
458 	 * This API sets the specified element data by invoking the
459 	 * firmware.
460 	 *
461 	 * [in] tfp
462 	 *   Pointer to TF handle
463 	 *
464 	 * [in] parms
465 	 *   Pointer to table set parameters
466 	 *
467 	 * Returns
468 	 *   - (0) if successful.
469 	 *   - (-EINVAL) on failure.
470 	 */
471 	int (*tf_dev_set_ext_tbl)(struct tf *tfp,
472 				  struct tf_tbl_set_parms *parms);
473 
474 	/**
475 	 * Sets the specified SRAM table type element.
476 	 *
477 	 * This API sets the specified element data by invoking the
478 	 * firmware.
479 	 *
480 	 * [in] tfp
481 	 *   Pointer to TF handle
482 	 *
483 	 * [in] parms
484 	 *   Pointer to table set parameters
485 	 *
486 	 * Returns
487 	 *   - (0) if successful.
488 	 *   - (-EINVAL) on failure.
489 	 */
490 	int (*tf_dev_set_sram_tbl)(struct tf *tfp,
491 				   struct tf_tbl_set_parms *parms);
492 
493 	/**
494 	 * Retrieves the specified table type element.
495 	 *
496 	 * This API retrieves the specified element data by invoking the
497 	 * firmware.
498 	 *
499 	 * [in] tfp
500 	 *   Pointer to TF handle
501 	 *
502 	 * [in] parms
503 	 *   Pointer to table get parameters
504 	 *
505 	 * Returns
506 	 *   - (0) if successful.
507 	 *   - (-EINVAL) on failure.
508 	 */
509 	int (*tf_dev_get_tbl)(struct tf *tfp,
510 			      struct tf_tbl_get_parms *parms);
511 
512 	/**
513 	 * Retrieves the specified SRAM table type element.
514 	 *
515 	 * This API retrieves the specified element data by invoking the
516 	 * firmware.
517 	 *
518 	 * [in] tfp
519 	 *   Pointer to TF handle
520 	 *
521 	 * [in] parms
522 	 *   Pointer to table get parameters
523 	 *
524 	 * Returns
525 	 *   - (0) if successful.
526 	 *   - (-EINVAL) on failure.
527 	 */
528 	int (*tf_dev_get_sram_tbl)(struct tf *tfp,
529 				   struct tf_tbl_get_parms *parms);
530 
531 	/**
532 	 * Retrieves the specified table type element using 'bulk'
533 	 * mechanism.
534 	 *
535 	 * This API retrieves the specified element data by invoking the
536 	 * firmware.
537 	 *
538 	 * [in] tfp
539 	 *   Pointer to TF handle
540 	 *
541 	 * [in] parms
542 	 *   Pointer to table get bulk parameters
543 	 *
544 	 * Returns
545 	 *   - (0) if successful.
546 	 *   - (-EINVAL) on failure.
547 	 */
548 	int (*tf_dev_get_bulk_tbl)(struct tf *tfp,
549 				   struct tf_tbl_get_bulk_parms *parms);
550 
551 	/**
552 	 * Retrieves the specified SRAM table type element using 'bulk'
553 	 * mechanism.
554 	 *
555 	 * This API retrieves the specified element data by invoking the
556 	 * firmware.
557 	 *
558 	 * [in] tfp
559 	 *   Pointer to TF handle
560 	 *
561 	 * [in] parms
562 	 *   Pointer to table get bulk parameters
563 	 *
564 	 * Returns
565 	 *   - (0) if successful.
566 	 *   - (-EINVAL) on failure.
567 	 */
568 	int (*tf_dev_get_bulk_sram_tbl)(struct tf *tfp,
569 					struct tf_tbl_get_bulk_parms *parms);
570 
571 	/**
572 	 * Gets the increment value to add to the shared session resource
573 	 * start offset by for each count in the "stride"
574 	 *
575 	 * [in] tfp
576 	 *   Pointer to TF handle
577 	 *
578 	 * [in] parms
579 	 *   Pointer to get shared tbl increment parameters
580 	 *
581 	 * Returns
582 	 *   - (0) if successful.
583 	 *   - (-EINVAL) on failure.
584 	 */
585 	int (*tf_dev_get_shared_tbl_increment)(struct tf *tfp,
586 				struct tf_get_shared_tbl_increment_parms *parms);
587 
588 	/**
589 	 * Retrieves the table resource info.
590 	 *
591 	 * This API retrieves the table resource info from the rm db.
592 	 *
593 	 * [in] tfp
594 	 *   Pointer to TF handle
595 	 *
596 	 * [in] parms
597 	 *   Pointer to tbl info
598 	 *
599 	 * Returns
600 	 *   - (0) if successful.
601 	 *   - (-EINVAL) on failure.
602 	 */
603 	int (*tf_dev_get_tbl_resc_info)(struct tf *tfp,
604 					 struct tf_tbl_resource_info *parms);
605 
606 	/**
607 	 * Allocation of a tcam element.
608 	 *
609 	 * This API allocates the specified tcam element from a device
610 	 * specific tcam DB. The allocated element is returned.
611 	 *
612 	 * [in] tfp
613 	 *   Pointer to TF handle
614 	 *
615 	 * [in] parms
616 	 *   Pointer to tcam allocation parameters
617 	 *
618 	 * Returns
619 	 *   - (0) if successful.
620 	 *   - (-EINVAL) on failure.
621 	 */
622 	int (*tf_dev_alloc_tcam)(struct tf *tfp,
623 				 struct tf_tcam_alloc_parms *parms);
624 
625 	/**
626 	 * Free of a tcam element.
627 	 *
628 	 * This API free's a previous allocated tcam element from a
629 	 * device specific tcam DB.
630 	 *
631 	 * [in] tfp
632 	 *   Pointer to TF handle
633 	 *
634 	 * [in] parms
635 	 *   Pointer to tcam free parameters
636 	 *
637 	 * Returns
638 	 *   - (0) if successful.
639 	 *   - (-EINVAL) on failure.
640 	 */
641 	int (*tf_dev_free_tcam)(struct tf *tfp,
642 				struct tf_tcam_free_parms *parms);
643 
644 	/**
645 	 * Searches for the specified tcam element in a shadow DB.
646 	 *
647 	 * This API searches for the specified tcam element in a
648 	 * device specific shadow DB. If the element is found the
649 	 * reference count for the element is updated. If the element
650 	 * is not found a new element is allocated from the tcam DB
651 	 * and then inserted into the shadow DB.
652 	 *
653 	 * [in] tfp
654 	 *   Pointer to TF handle
655 	 *
656 	 * [in] parms
657 	 *   Pointer to tcam allocation and search parameters
658 	 *
659 	 * Returns
660 	 *   - (0) if successful.
661 	 *   - (-EINVAL) on failure.
662 	 */
663 	int (*tf_dev_alloc_search_tcam)
664 			(struct tf *tfp,
665 			struct tf_tcam_alloc_search_parms *parms);
666 
667 	/**
668 	 * Sets the specified tcam element.
669 	 *
670 	 * This API sets the specified element data by invoking the
671 	 * firmware.
672 	 *
673 	 * [in] tfp
674 	 *   Pointer to TF handle
675 	 *
676 	 * [in] parms
677 	 *   Pointer to tcam set parameters
678 	 *
679 	 * Returns
680 	 *   - (0) if successful.
681 	 *   - (-EINVAL) on failure.
682 	 */
683 	int (*tf_dev_set_tcam)(struct tf *tfp,
684 			       struct tf_tcam_set_parms *parms);
685 
686 	/**
687 	 * Retrieves the specified tcam element.
688 	 *
689 	 * This API retrieves the specified element data by invoking the
690 	 * firmware.
691 	 *
692 	 * [in] tfp
693 	 *   Pointer to TF handle
694 	 *
695 	 * [in] parms
696 	 *   Pointer to tcam get parameters
697 	 *
698 	 * Returns
699 	 *   - (0) if successful.
700 	 *   - (-EINVAL) on failure.
701 	 */
702 	int (*tf_dev_get_tcam)(struct tf *tfp,
703 			       struct tf_tcam_get_parms *parms);
704 
705 	/**
706 	 * Move TCAM shared entries
707 	 *
708 	 * [in] tfp
709 	 *   Pointer to TF handle
710 	 *
711 	 * [in] parms
712 	 *   Pointer to parameters
713 	 *
714 	 *    returns:
715 	 *    0       - Success
716 	 *    -EINVAL - Error
717 	 */
718 	int (*tf_dev_move_tcam)(struct tf *tfp,
719 			       struct tf_move_tcam_shared_entries_parms *parms);
720 
721 	/**
722 	 * Move TCAM shared entries
723 	 *
724 	 * [in] tfp
725 	 *   Pointer to TF handle
726 	 *
727 	 * [in] parms
728 	 *   Pointer to parameters
729 	 *
730 	 *    returns:
731 	 *    0       - Success
732 	 *    -EINVAL - Error
733 	 */
734 	int (*tf_dev_clear_tcam)(struct tf *tfp,
735 			      struct tf_clear_tcam_shared_entries_parms *parms);
736 
737 	/**
738 	 * Retrieves the tcam resource info.
739 	 *
740 	 * This API retrieves the tcam resource info from the rm db.
741 	 *
742 	 * [in] tfp
743 	 *   Pointer to TF handle
744 	 *
745 	 * [in] parms
746 	 *   Pointer to tcam info
747 	 *
748 	 * Returns
749 	 *   - (0) if successful.
750 	 *   - (-EINVAL) on failure.
751 	 */
752 	int (*tf_dev_get_tcam_resc_info)(struct tf *tfp,
753 					 struct tf_tcam_resource_info *parms);
754 
755 	/**
756 	 * Insert EM hash entry API
757 	 *
758 	 * [in] tfp
759 	 *   Pointer to TF handle
760 	 *
761 	 * [in] parms
762 	 *   Pointer to E/EM insert parameters
763 	 *
764 	 *  Returns:
765 	 *    0       - Success
766 	 *    -EINVAL - Error
767 	 */
768 	int (*tf_dev_insert_int_em_entry)(struct tf *tfp,
769 					  struct tf_insert_em_entry_parms *parms);
770 
771 	/**
772 	 * Delete EM hash entry API
773 	 *
774 	 * [in] tfp
775 	 *   Pointer to TF handle
776 	 *
777 	 * [in] parms
778 	 *   Pointer to E/EM delete parameters
779 	 *
780 	 *    returns:
781 	 *    0       - Success
782 	 *    -EINVAL - Error
783 	 */
784 	int (*tf_dev_delete_int_em_entry)(struct tf *tfp,
785 					  struct tf_delete_em_entry_parms *parms);
786 
787 	/**
788 	 * Move EM hash entry API
789 	 *
790 	 * [in] tfp
791 	 *   Pointer to TF handle
792 	 *
793 	 * [in] parms
794 	 *   Pointer to E/EM move parameters
795 	 *
796 	 *    returns:
797 	 *    0       - Success
798 	 *    -EINVAL - Error
799 	 */
800 	int (*tf_dev_move_int_em_entry)(struct tf *tfp,
801 					struct tf_move_em_entry_parms *parms);
802 
803 	/**
804 	 * Insert EEM hash entry API
805 	 *
806 	 * [in] tfp
807 	 *   Pointer to TF handle
808 	 *
809 	 * [in] parms
810 	 *   Pointer to E/EM insert parameters
811 	 *
812 	 *  Returns:
813 	 *    0       - Success
814 	 *    -EINVAL - Error
815 	 */
816 	int (*tf_dev_insert_ext_em_entry)(struct tf *tfp,
817 					  struct tf_insert_em_entry_parms *parms);
818 
819 	/**
820 	 * Delete EEM hash entry API
821 	 *
822 	 * [in] tfp
823 	 *   Pointer to TF handle
824 	 *
825 	 * [in] parms
826 	 *   Pointer to E/EM delete parameters
827 	 *
828 	 *    returns:
829 	 *    0       - Success
830 	 *    -EINVAL - Error
831 	 */
832 	int (*tf_dev_delete_ext_em_entry)(struct tf *tfp,
833 					  struct tf_delete_em_entry_parms *parms);
834 
835 	/**
836 	 * Retrieves the em resource info.
837 	 *
838 	 * This API retrieves the em resource info from the rm db.
839 	 *
840 	 * [in] tfp
841 	 *   Pointer to TF handle
842 	 *
843 	 * [in] parms
844 	 *   Pointer to em info
845 	 *
846 	 * Returns
847 	 *   - (0) if successful.
848 	 *   - (-EINVAL) on failure.
849 	 */
850 	int (*tf_dev_get_em_resc_info)(struct tf *tfp,
851 				       struct tf_em_resource_info *parms);
852 
853 	/**
854 	 * Move EEM hash entry API
855 	 *
856 	 *   Pointer to E/EM move parameters
857 	 *
858 	 * [in] tfp
859 	 *   Pointer to TF handle
860 	 *
861 	 * [in] parms
862 	 *   Pointer to em info
863 	 *
864 	 *    returns:
865 	 *    0       - Success
866 	 *    -EINVAL - Error
867 	 */
868 	int (*tf_dev_move_ext_em_entry)(struct tf *tfp,
869 					struct tf_move_em_entry_parms *parms);
870 
871 	/**
872 	 * Allocate EEM table scope
873 	 *
874 	 * [in] tfp
875 	 *   Pointer to TF handle
876 	 *
877 	 * [in] parms
878 	 *   Pointer to table scope alloc parameters
879 	 *
880 	 *    returns:
881 	 *    0       - Success
882 	 *    -EINVAL - Error
883 	 */
884 	int (*tf_dev_alloc_tbl_scope)(struct tf *tfp,
885 				      struct tf_alloc_tbl_scope_parms *parms);
886 	/**
887 	 * Map EEM parif
888 	 *
889 	 * [in] tfp
890 	 *   Pointer to TF handle
891 	 *
892 	 * [in] pf
893 	 * PF associated with the table scope
894 	 *
895 	 * [in] parif_bitmask
896 	 * Bitmask of PARIFs to enable
897 	 *
898 	 * [in/out] pointer to the parif_2_pf data to be updated
899 	 *
900 	 * [in/out] pointer to the parif_2_pf mask to be updated
901 	 *
902 	 * [in] sz_in_bytes - number of bytes to be written
903 	 *
904 	 *    returns:
905 	 *    0       - Success
906 	 *    -EINVAL - Error
907 	 */
908 	int (*tf_dev_map_parif)(struct tf *tfp,
909 				uint16_t parif_bitmask,
910 				uint16_t pf,
911 				uint8_t *data,
912 				uint8_t *mask,
913 				uint16_t sz_in_bytes);
914 	/**
915 	 * Map EEM table scope
916 	 *
917 	 * [in] tfp
918 	 *   Pointer to TF handle
919 	 *
920 	 * [in] parms
921 	 *   Pointer to table scope map parameters
922 	 *
923 	 *    returns:
924 	 *    0       - Success
925 	 *    -EINVAL - Error
926 	 */
927 	int (*tf_dev_map_tbl_scope)(struct tf *tfp,
928 				    struct tf_map_tbl_scope_parms *parms);
929 
930 	/**
931 	 * Free EEM table scope
932 	 *
933 	 * [in] tfp
934 	 *   Pointer to TF handle
935 	 *
936 	 * [in] parms
937 	 *   Pointer to table scope free parameters
938 	 *
939 	 *    returns:
940 	 *    0       - Success
941 	 *    -EINVAL - Error
942 	 */
943 	int (*tf_dev_free_tbl_scope)(struct tf *tfp,
944 				     struct tf_free_tbl_scope_parms *parms);
945 
946 	/**
947 	 * Sets the specified interface table type element.
948 	 *
949 	 * This API sets the specified element data by invoking the
950 	 * firmware.
951 	 *
952 	 * [in] tfp
953 	 *   Pointer to TF handle
954 	 *
955 	 * [in] parms
956 	 *   Pointer to interface table set parameters
957 	 *
958 	 * Returns
959 	 *   - (0) if successful.
960 	 *   - (-EINVAL) on failure.
961 	 */
962 	int (*tf_dev_set_if_tbl)(struct tf *tfp,
963 				 struct tf_if_tbl_set_parms *parms);
964 
965 	/**
966 	 * Retrieves the specified interface table type element.
967 	 *
968 	 * This API retrieves the specified element data by invoking the
969 	 * firmware.
970 	 *
971 	 * [in] tfp
972 	 *   Pointer to TF handle
973 	 *
974 	 * [in] parms
975 	 *   Pointer to table get parameters
976 	 *
977 	 * Returns
978 	 *   - (0) if successful.
979 	 *   - (-EINVAL) on failure.
980 	 */
981 	int (*tf_dev_get_if_tbl)(struct tf *tfp,
982 				 struct tf_if_tbl_get_parms *parms);
983 
984 	/**
985 	 * Update global cfg
986 	 *
987 	 * [in] tfp
988 	 *   Pointer to TF handle
989 	 *
990 	 * [in] parms
991 	 *   Pointer to global cfg parameters
992 	 *
993 	 *    returns:
994 	 *    0       - Success
995 	 *    -EINVAL - Error
996 	 */
997 	int (*tf_dev_set_global_cfg)(struct tf *tfp,
998 				     struct tf_global_cfg_parms *parms);
999 
1000 	/**
1001 	 * Get global cfg
1002 	 *
1003 	 * [in] tfp
1004 	 *   Pointer to TF handle
1005 	 *
1006 	 * [in] parms
1007 	 *   Pointer to global cfg parameters
1008 	 *
1009 	 *    returns:
1010 	 *    0       - Success
1011 	 *    -EINVAL - Error
1012 	 */
1013 	int (*tf_dev_get_global_cfg)(struct tf *tfp,
1014 				     struct tf_global_cfg_parms *parms);
1015 
1016 	/**
1017 	 * Get mailbox
1018 	 *
1019 	 *    returns:
1020 	 *      mailbox
1021 	 */
1022 	int (*tf_dev_get_mailbox)(void);
1023 
1024 	/**
1025 	 * Convert length in bit to length in byte and align to word.
1026 	 * The word length depends on device type.
1027 	 *
1028 	 * [in] size
1029 	 *   Size in bit
1030 	 *
1031 	 * Returns
1032 	 *   Size in byte
1033 	 */
1034 	int (*tf_dev_word_align)(uint16_t size);
1035 
1036 	/**
1037 	 * Hash key using crc32 and lookup3
1038 	 *
1039 	 * [in] key_data
1040 	 *   Pointer to key
1041 	 *
1042 	 * [in] bitlen
1043 	 *   Number of key bits
1044 	 *
1045 	 * Returns
1046 	 *   Hashes
1047 	 */
1048 	uint64_t (*tf_dev_cfa_key_hash)(uint64_t *key_data,
1049 					  uint16_t bitlen);
1050 
1051 	/**
1052 	 * Translate the CFA resource type to Truflow type
1053 	 *
1054 	 * [in] hcapi_types
1055 	 *   CFA resource type bitmap
1056 	 *
1057 	 * [out] ident_types
1058 	 *   Pointer to identifier type bitmap
1059 	 *
1060 	 * [out] tcam_types
1061 	 *   Pointer to tcam type bitmap
1062 	 *
1063 	 * [out] tbl_types
1064 	 *   Pointer to table type bitmap
1065 	 *
1066 	 * [out] em_types
1067 	 *   Pointer to em type bitmap
1068 	 *
1069 	 * Returns
1070 	 *   - (0) if successful.
1071 	 *   - (-EINVAL) on failure.
1072 	 */
1073 	int (*tf_dev_map_hcapi_caps)(uint64_t hcapi_caps,
1074 				     uint32_t *ident_caps,
1075 				     uint32_t *tcam_caps,
1076 				     uint32_t *tbl_caps,
1077 				     uint32_t *em_caps);
1078 
1079 	/**
1080 	 * Device specific function that retrieves the sram resource
1081 	 *
1082 	 * [in] query
1083 	 *   Point to resources query result
1084 	 *
1085 	 * [out] sram_bank_caps
1086 	 *   Pointer to SRAM bank capabilities
1087 	 *
1088 	 * [out] dynamic_sram_capable
1089 	 *   Pointer to dynamic sram capable
1090 	 *
1091 	 * Returns
1092 	 *   - (0) if successful.
1093 	 *   - (-EINVAL) on failure.
1094 	 */
1095 	int (*tf_dev_get_sram_resources)(void *query,
1096 					 uint32_t *sram_bank_caps,
1097 					 bool *dynamic_sram_capable);
1098 
1099 	/**
1100 	 * Device specific function that sets the sram policy
1101 	 *
1102 	 * [in] dir
1103 	 *   Receive or transmit direction
1104 	 *
1105 	 * [in] band_id
1106 	 *   SRAM bank id
1107 	 *
1108 	 * Returns
1109 	 *   - (0) if successful.
1110 	 *   - (-EINVAL) on failure.
1111 	 */
1112 	int (*tf_dev_set_sram_policy)(enum tf_dir dir,
1113 				      enum tf_sram_bank_id *bank_id);
1114 
1115 	/**
1116 	 * Device specific function that gets the sram policy
1117 	 *
1118 	 * [in] dir
1119 	 *   Receive or transmit direction
1120 	 *
1121 	 * [in] band_id
1122 	 *   pointer to SRAM bank id
1123 	 *
1124 	 * Returns
1125 	 *   - (0) if successful.
1126 	 *   - (-EINVAL) on failure.
1127 	 */
1128 	int (*tf_dev_get_sram_policy)(enum tf_dir dir,
1129 				      enum tf_sram_bank_id *bank_id);
1130 
1131 #ifdef TF_FLOW_SCALE_QUERY
1132 	/**
1133 	 * Update resource usage state with firmware
1134 	 *
1135 	 * [in] tfp
1136 	 *   Pointer to TF handle
1137 	 *
1138 	 * [in] dir
1139 	 *   Receive or transmit direction
1140 	 *
1141 	 * [in] flow_resc_type
1142 	 *   Resource type to update its usage state
1143 	 *
1144 	 *    returns:
1145 	 *    0       - Success
1146 	 *    -EINVAL - Error
1147 	 */
1148 	int (*tf_dev_update_resc_usage)(struct tf *tfp,
1149 					enum tf_dir dir,
1150 					enum tf_flow_resc_type flow_resc_type);
1151 
1152 	/**
1153 	 * Query resource usage state from firmware
1154 	 *
1155 	 * [in] tfp
1156 	 *   Pointer to TF handle
1157 	 *
1158 	 * [in] dir
1159 	 *   Receive or transmit direction
1160 	 *
1161 	 * [in] flow_resc_type
1162 	 *   Resource type to query its usage state
1163 	 *
1164 	 *    returns:
1165 	 *    0       - Success
1166 	 *    -EINVAL - Error
1167 	 */
1168 	int (*tf_dev_query_resc_usage)(struct tf *tfp,
1169 				       struct tf_query_resc_usage_parms *parms);
1170 
1171 	/**
1172 	 * Update buffer of table usage
1173 	 *
1174 	 * [in] session_id
1175 	 *   The TruFlow session id
1176 	 *
1177 	 * [in] dir
1178 	 *   Receive or transmit direction
1179 	 *
1180 	 * [in] tbl_type
1181 	 *   SRAM table type to update its usage state
1182 	 *
1183 	 * [in] resc_opt
1184 	 *   Alloca or free resource
1185 	 *
1186 	 *    returns:
1187 	 *    0       - Success
1188 	 *    -EINVAL - Error
1189 	 */
1190 	int (*tf_dev_update_tbl_usage_buffer)(struct tf *tfp,
1191 					      enum tf_dir dir,
1192 					      enum tf_tbl_type tbl_type,
1193 					      uint32_t resc_opt);
1194 #endif /* TF_FLOW_SCALE_QUERY */
1195 };
1196 
1197 /**
1198  * Supported device operation structures
1199  */
1200 extern const struct tf_dev_ops tf_dev_ops_p4_init;
1201 extern const struct tf_dev_ops tf_dev_ops_p4;
1202 extern const struct tf_dev_ops tf_dev_ops_p58_init;
1203 extern const struct tf_dev_ops tf_dev_ops_p58;
1204 
1205 /**
1206  * Supported device resource type mapping structures
1207  */
1208 extern const struct tf_hcapi_resource_map tf_hcapi_res_map_p4[CFA_RESOURCE_TYPE_P4_LAST + 1];
1209 extern const struct tf_hcapi_resource_map tf_hcapi_res_map_p58[CFA_RESOURCE_TYPE_P58_LAST + 1];
1210 #endif /* _TF_DEVICE_H_ */
1211