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