eal: remove sys/queue.h from public headers
[dpdk.git] / drivers / net / bnxt / tf_core / tf_tbl.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019-2021 Broadcom
3  * All rights reserved.
4  */
5
6 #ifndef TF_TBL_TYPE_H_
7 #define TF_TBL_TYPE_H_
8
9 #include "tf_core.h"
10 #include "stack.h"
11
12 struct tf;
13
14 /**
15  * The Table module provides processing of Internal TF table types.
16  */
17
18
19 /**
20  * Table configuration parameters
21  */
22 struct tf_tbl_cfg_parms {
23         /**
24          * Number of table types in each of the configuration arrays
25          */
26         uint16_t num_elements;
27         /**
28          * Table Type element configuration array
29          */
30         struct tf_rm_element_cfg *cfg;
31         /**
32          * Session resource allocations
33          */
34         struct tf_session_resources *resources;
35 };
36
37 /**
38  * Table allocation parameters
39  */
40 struct tf_tbl_alloc_parms {
41         /**
42          * [in] Receive or transmit direction
43          */
44         enum tf_dir dir;
45         /**
46          * [in] Type of the allocation
47          */
48         enum tf_tbl_type type;
49         /**
50          * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
51          */
52         uint32_t tbl_scope_id;
53         /**
54          * [out] Idx of allocated entry or found entry (if search_enable)
55          */
56         uint32_t *idx;
57 };
58
59 /**
60  * Table free parameters
61  */
62 struct tf_tbl_free_parms {
63         /**
64          * [in] Receive or transmit direction
65          */
66         enum tf_dir dir;
67         /**
68          * [in] Type of the allocation type
69          */
70         enum tf_tbl_type type;
71         /**
72          * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
73          */
74         uint32_t tbl_scope_id;
75         /**
76          * [in] Index to free
77          */
78         uint32_t idx;
79 };
80
81 /**
82  * Table set parameters
83  */
84 struct tf_tbl_set_parms {
85         /**
86          * [in] Receive or transmit direction
87          */
88         enum tf_dir dir;
89         /**
90          * [in] Type of object to set
91          */
92         enum tf_tbl_type type;
93         /**
94          * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
95          */
96         uint32_t tbl_scope_id;
97         /**
98          * [in] Entry data
99          */
100         uint8_t *data;
101         /**
102          * [in] Entry size
103          */
104         uint16_t data_sz_in_bytes;
105         /**
106          * [in] Entry index to write to
107          */
108         uint32_t idx;
109 };
110
111 /**
112  * Table get parameters
113  */
114 struct tf_tbl_get_parms {
115         /**
116          * [in] Receive or transmit direction
117          */
118         enum tf_dir dir;
119         /**
120          * [in] Type of object to get
121          */
122         enum tf_tbl_type type;
123         /**
124          * [out] Entry data
125          */
126         uint8_t *data;
127         /**
128          * [out] Entry size
129          */
130         uint16_t data_sz_in_bytes;
131         /**
132          * [in] Entry index to read
133          */
134         uint32_t idx;
135 };
136
137 /**
138  * Table get bulk parameters
139  */
140 struct tf_tbl_get_bulk_parms {
141         /**
142          * [in] Receive or transmit direction
143          */
144         enum tf_dir dir;
145         /**
146          * [in] Type of object to get
147          */
148         enum tf_tbl_type type;
149         /**
150          * [in] Starting index to read from
151          */
152         uint32_t starting_idx;
153         /**
154          * [in] Number of sequential entries
155          */
156         uint16_t num_entries;
157         /**
158          * [in] Size of the single entry
159          */
160         uint16_t entry_sz_in_bytes;
161         /**
162          * [out] Host physical address, where the data
163          * will be copied to by the firmware.
164          * Use tfp_calloc() API and mem_pa
165          * variable of the tfp_calloc_parms
166          * structure for the physical address.
167          */
168         uint64_t physical_mem_addr;
169 };
170
171 /**
172  * Table RM database
173  *
174  * Table rm database
175  *
176  */
177 struct tbl_rm_db {
178         struct rm_db *tbl_db[TF_DIR_MAX];
179 };
180
181 /**
182  * @page tbl Table
183  *
184  * @ref tf_tbl_bind
185  *
186  * @ref tf_tbl_unbind
187  *
188  * @ref tf_tbl_alloc
189  *
190  * @ref tf_tbl_free
191  *
192  * @ref tf_tbl_set
193  *
194  * @ref tf_tbl_get
195  *
196  * @ref tf_tbl_bulk_get
197  */
198
199 /**
200  * Initializes the Table module with the requested DBs. Must be
201  * invoked as the first thing before any of the access functions.
202  *
203  * [in] tfp
204  *   Pointer to TF handle, used for HCAPI communication
205  *
206  * [in] parms
207  *   Pointer to Table configuration parameters
208  *
209  * Returns
210  *   - (0) if successful.
211  *   - (-EINVAL) on failure.
212  */
213 int tf_tbl_bind(struct tf *tfp,
214                 struct tf_tbl_cfg_parms *parms);
215
216 /**
217  * Cleans up the private DBs and releases all the data.
218  *
219  * [in] tfp
220  *   Pointer to TF handle, used for HCAPI communication
221  *
222  * [in] parms
223  *   Pointer to parameters
224  *
225  * Returns
226  *   - (0) if successful.
227  *   - (-EINVAL) on failure.
228  */
229 int tf_tbl_unbind(struct tf *tfp);
230
231 /**
232  * Allocates the requested table type from the internal RM DB.
233  *
234  * [in] tfp
235  *   Pointer to TF handle, used for HCAPI communication
236  *
237  * [in] parms
238  *   Pointer to Table allocation parameters
239  *
240  * Returns
241  *   - (0) if successful.
242  *   - (-EINVAL) on failure.
243  */
244 int tf_tbl_alloc(struct tf *tfp,
245                  struct tf_tbl_alloc_parms *parms);
246
247 /**
248  * Frees the requested table type and returns it to the DB.
249  *
250  * [in] tfp
251  *   Pointer to TF handle, used for HCAPI communication
252  *
253  * [in] parms
254  *   Pointer to Table free parameters
255  *
256  * Returns
257  *   - (0) if successful.
258  *   - (-EINVAL) on failure.
259  */
260 int tf_tbl_free(struct tf *tfp,
261                 struct tf_tbl_free_parms *parms);
262
263 /**
264  * Configures the requested element by sending a firmware request which
265  * then installs it into the device internal structures.
266  *
267  * [in] tfp
268  *   Pointer to TF handle, used for HCAPI communication
269  *
270  * [in] parms
271  *   Pointer to Table set parameters
272  *
273  * Returns
274  *   - (0) if successful.
275  *   - (-EINVAL) on failure.
276  */
277 int tf_tbl_set(struct tf *tfp,
278                struct tf_tbl_set_parms *parms);
279
280 /**
281  * Retrieves the requested element by sending a firmware request to get
282  * the element.
283  *
284  * [in] tfp
285  *   Pointer to TF handle, used for HCAPI communication
286  *
287  * [in] parms
288  *   Pointer to Table get parameters
289  *
290  * Returns
291  *   - (0) if successful.
292  *   - (-EINVAL) on failure.
293  */
294 int tf_tbl_get(struct tf *tfp,
295                struct tf_tbl_get_parms *parms);
296
297 /**
298  * Retrieves bulk block of elements by sending a firmware request to
299  * get the elements.
300  *
301  * [in] tfp
302  *   Pointer to TF handle, used for HCAPI communication
303  *
304  * [in] parms
305  *   Pointer to Table get bulk parameters
306  *
307  * Returns
308  *   - (0) if successful.
309  *   - (-EINVAL) on failure.
310  */
311 int tf_tbl_bulk_get(struct tf *tfp,
312                     struct tf_tbl_get_bulk_parms *parms);
313
314 /**
315  * Retrieves the allocated resource info
316  *
317  * [in] tfp
318  *   Pointer to TF handle, used for HCAPI communication
319  *
320  * [in] parms
321  *   Pointer to Table resource info parameters
322  *
323  * Returns
324  *   - (0) if successful.
325  *   - (-EINVAL) on failure.
326  */
327 int
328 tf_tbl_get_resc_info(struct tf *tfp,
329                      struct tf_tbl_resource_info *tbl);
330
331 #endif /* TF_TBL_TYPE_H */