bf01df9b8db36f5e1b3a3a1632a2ce8af4f5105b
[dpdk.git] / drivers / net / bnxt / tf_core / tf_em_common.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019-2020 Broadcom
3  * All rights reserved.
4  */
5
6 #ifndef _TF_EM_COMMON_H_
7 #define _TF_EM_COMMON_H_
8
9 #include "tf_core.h"
10 #include "tf_session.h"
11
12
13 /**
14  * Function to search for table scope control block structure
15  * with specified table scope ID.
16  *
17  * [in] tbl_scope_id
18  *   Table scope ID to search for
19  *
20  * Returns:
21  *  Pointer to the found table scope control block struct or NULL if
22  *   table scope control block struct not found
23  */
24 struct tf_tbl_scope_cb *tbl_scope_cb_find(uint32_t tbl_scope_id);
25
26 /**
27  * Create and initialize a stack to use for action entries
28  *
29  * [in] dir
30  *   Direction
31  * [in] tbl_scope_id
32  *   Table scope ID
33  * [in] num_entries
34  *   Number of EEM entries
35  * [in] entry_sz_bytes
36  *   Size of the entry
37  *
38  * Returns:
39  *   0       - Success
40  *   -ENOMEM - Out of memory
41  *   -EINVAL - Failure
42  */
43 int tf_create_tbl_pool_external(enum tf_dir dir,
44                                 struct tf_tbl_scope_cb *tbl_scope_cb,
45                                 uint32_t num_entries,
46                                 uint32_t entry_sz_bytes);
47
48 /**
49  * Delete and cleanup action record allocation stack
50  *
51  * [in] dir
52  *   Direction
53  * [in] tbl_scope_id
54  *   Table scope ID
55  *
56  */
57 void tf_destroy_tbl_pool_external(enum tf_dir dir,
58                                   struct tf_tbl_scope_cb *tbl_scope_cb);
59
60 /**
61  * Get hash mask for current EEM table size
62  *
63  * [in] num_entries
64  *   Number of EEM entries
65  */
66 uint32_t tf_em_get_key_mask(int num_entries);
67
68 /**
69  * Populate key_entry
70  *
71  * [in] result
72  *   Entry data
73  * [in] in_key
74  *   Key data
75  * [out] key_entry
76  *   Completed key record
77  */
78 void tf_em_create_key_entry(struct cfa_p4_eem_entry_hdr *result,
79                             uint8_t            *in_key,
80                             struct cfa_p4_eem_64b_entry *key_entry);
81
82 /**
83  * Find base page address for offset into specified table type
84  *
85  * [in] tbl_scope_cb
86  *   Table scope
87  * [in] dir
88  *   Direction
89  * [in] Offset
90  *   Offset in to table
91  * [in] table_type
92  *   Table type
93  *
94  * Returns:
95  *
96  * 0                                 - Failure
97  * Void pointer to page base address - Success
98  */
99 void *tf_em_get_table_page(struct tf_tbl_scope_cb *tbl_scope_cb,
100                            enum tf_dir dir,
101                            uint32_t offset,
102                            enum hcapi_cfa_em_table_type table_type);
103
104 #endif /* _TF_EM_COMMON_H_ */