net/bnxt: remove unused macro
[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  * Function to search for table scope control block structure
14  * with specified table scope ID.
15  *
16  * [in] tbl_scope_id
17  *   Table scope ID to search for
18  *
19  * Returns:
20  *  Pointer to the found table scope control block struct or NULL if
21  *   table scope control block struct not found
22  */
23 struct tf_tbl_scope_cb *tbl_scope_cb_find(uint32_t tbl_scope_id);
24
25 /**
26  * Table Scope Allocate
27  *
28  * Allocate a table scope
29  *
30  * [in/out] pointer to tbl_scope_id
31  *
32  * Returns:
33  *  0 - success
34  *  -EINVAL - error
35  */
36 int tf_tbl_scope_alloc(uint32_t *tbl_scope_id);
37
38 /**
39  * Table Scope Free
40  *
41  * Free a table scope
42  *
43  * [in] tbl_scope_id to free
44  *
45  * Returns:
46  *  0 - success
47  *  -EINVAL - error
48  */
49 int tf_tbl_scope_free(uint32_t tbl_scope_id);
50
51 /**
52  * Create and initialize a stack to use for action entries
53  *
54  * [in] dir
55  *   Direction
56  * [in] tbl_scope_id
57  *   Table scope ID
58  * [in] num_entries
59  *   Number of EEM entries
60  * [in] entry_sz_bytes
61  *   Size of the entry
62  *
63  * Returns:
64  *   0       - Success
65  *   -ENOMEM - Out of memory
66  *   -EINVAL - Failure
67  */
68 int tf_create_tbl_pool_external(enum tf_dir dir,
69                                 struct tf_tbl_scope_cb *tbl_scope_cb,
70                                 uint32_t num_entries,
71                                 uint32_t entry_sz_bytes);
72
73 /**
74  * Delete and cleanup action record allocation stack
75  *
76  * [in] dir
77  *   Direction
78  * [in] tbl_scope_id
79  *   Table scope ID
80  *
81  */
82 void tf_destroy_tbl_pool_external(enum tf_dir dir,
83                                   struct tf_tbl_scope_cb *tbl_scope_cb);
84
85 /**
86  * Get hash mask for current EEM table size
87  *
88  * [in] num_entries
89  *   Number of EEM entries
90  */
91 uint32_t tf_em_get_key_mask(int num_entries);
92
93 /**
94  * Populate key_entry
95  *
96  * [in] result
97  *   Entry data
98  * [in] in_key
99  *   Key data
100  * [out] key_entry
101  *   Completed key record
102  */
103 void tf_em_create_key_entry(struct cfa_p4_eem_entry_hdr *result,
104                             uint8_t            *in_key,
105                             struct cfa_p4_eem_64b_entry *key_entry);
106
107 /**
108  * Find base page address for offset into specified table type
109  *
110  * [in] tbl_scope_cb
111  *   Table scope
112  * [in] dir
113  *   Direction
114  * [in] Offset
115  *   Offset in to table
116  * [in] table_type
117  *   Table type
118  *
119  * Returns:
120  *
121  * 0                                 - Failure
122  * Void pointer to page base address - Success
123  */
124 void *tf_em_get_table_page(struct tf_tbl_scope_cb *tbl_scope_cb,
125                            enum tf_dir dir,
126                            uint32_t offset,
127                            enum hcapi_cfa_em_table_type table_type);
128
129 /**
130  * Validates EM number of entries requested
131  *
132  * [in] tbl_scope_cb
133  *   Pointer to table scope control block to be populated
134  *
135  * [in] parms
136  *   Pointer to input parameters
137  *
138  * Returns:
139  *   0       - Success
140  *   -EINVAL - Parameter error
141  */
142 int tf_em_validate_num_entries(struct tf_tbl_scope_cb *tbl_scope_cb,
143                                struct tf_alloc_tbl_scope_parms *parms);
144
145 /**
146  * Size the EM table based on capabilities
147  *
148  * [in] tbl
149  *   EM table to size
150  *
151  * Returns:
152  *   0        - Success
153  *   - EINVAL - Parameter error
154  *   - ENOMEM - Out of memory
155  */
156 int tf_em_size_table(struct hcapi_cfa_em_table *tbl,
157                      uint32_t page_size);
158
159 #endif /* _TF_EM_COMMON_H_ */