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