net/netvsc: fix multiple channel Rx
[dpdk.git] / drivers / net / bnxt / tf_core / tf_tbl.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019-2020 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  * Table scope control block content
20  */
21 struct tf_em_caps {
22         uint32_t flags;
23         uint32_t supported;
24         uint32_t max_entries_supported;
25         uint16_t key_entry_size;
26         uint16_t record_entry_size;
27         uint16_t efc_entry_size;
28 };
29
30 /** Invalid table scope id */
31 #define TF_TBL_SCOPE_INVALID 0xffffffff
32
33 /**
34  * Table Scope Control Block
35  *
36  * Holds private data for a table scope. Only one instance of a table
37  * scope with Internal EM is supported.
38  */
39 struct tf_tbl_scope_cb {
40         uint32_t tbl_scope_id;
41         int index;
42         struct hcapi_cfa_em_ctx_mem_info em_ctx_info[TF_DIR_MAX];
43         struct tf_em_caps em_caps[TF_DIR_MAX];
44         struct stack ext_act_pool[TF_DIR_MAX];
45         uint32_t *ext_act_pool_mem[TF_DIR_MAX];
46 };
47
48 /**
49  * Table configuration parameters
50  */
51 struct tf_tbl_cfg_parms {
52         /**
53          * Number of table types in each of the configuration arrays
54          */
55         uint16_t num_elements;
56         /**
57          * Table Type element configuration array
58          */
59         struct tf_rm_element_cfg *cfg;
60         /**
61          * Shadow table type configuration array
62          */
63         struct tf_shadow_tbl_cfg *shadow_cfg;
64         /**
65          * Boolean controlling the request shadow copy.
66          */
67         bool shadow_copy;
68         /**
69          * Session resource allocations
70          */
71         struct tf_session_resources *resources;
72 };
73
74 /**
75  * Table allocation parameters
76  */
77 struct tf_tbl_alloc_parms {
78         /**
79          * [in] Receive or transmit direction
80          */
81         enum tf_dir dir;
82         /**
83          * [in] Type of the allocation
84          */
85         enum tf_tbl_type type;
86         /**
87          * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
88          */
89         uint32_t tbl_scope_id;
90         /**
91          * [out] Idx of allocated entry or found entry (if search_enable)
92          */
93         uint32_t *idx;
94 };
95
96 /**
97  * Table free parameters
98  */
99 struct tf_tbl_free_parms {
100         /**
101          * [in] Receive or transmit direction
102          */
103         enum tf_dir dir;
104         /**
105          * [in] Type of the allocation type
106          */
107         enum tf_tbl_type type;
108         /**
109          * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
110          */
111         uint32_t tbl_scope_id;
112         /**
113          * [in] Index to free
114          */
115         uint32_t idx;
116         /**
117          * [out] Reference count after free, only valid if session has been
118          * created with shadow_copy.
119          */
120         uint16_t ref_cnt;
121 };
122
123 /**
124  * Table allocate search parameters
125  */
126 struct tf_tbl_alloc_search_parms {
127         /**
128          * [in] Receive or transmit direction
129          */
130         enum tf_dir dir;
131         /**
132          * [in] Type of the allocation
133          */
134         enum tf_tbl_type type;
135         /**
136          * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
137          */
138         uint32_t tbl_scope_id;
139         /**
140          * [in] Result data to search for
141          */
142         uint8_t *result;
143         /**
144          * [in] Result data size in bytes
145          */
146         uint16_t result_sz_in_bytes;
147         /**
148          * [in] Whether or not to allocate on MISS, 1 is allocate.
149          */
150         uint8_t alloc;
151         /**
152          * [out] If search_enable, set if matching entry found
153          */
154         uint8_t hit;
155         /**
156          * [out] The status of the search (REJECT, MISS, HIT)
157          */
158         enum tf_search_status search_status;
159         /**
160          * [out] Current ref count after allocation
161          */
162         uint16_t ref_cnt;
163         /**
164          * [out] Idx of allocated entry or found entry
165          */
166         uint32_t idx;
167 };
168
169 /**
170  * Table set parameters
171  */
172 struct tf_tbl_set_parms {
173         /**
174          * [in] Receive or transmit direction
175          */
176         enum tf_dir dir;
177         /**
178          * [in] Type of object to set
179          */
180         enum tf_tbl_type type;
181         /**
182          * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
183          */
184         uint32_t tbl_scope_id;
185         /**
186          * [in] Entry data
187          */
188         uint8_t *data;
189         /**
190          * [in] Entry size
191          */
192         uint16_t data_sz_in_bytes;
193         /**
194          * [in] Entry index to write to
195          */
196         uint32_t idx;
197 };
198
199 /**
200  * Table get parameters
201  */
202 struct tf_tbl_get_parms {
203         /**
204          * [in] Receive or transmit direction
205          */
206         enum tf_dir dir;
207         /**
208          * [in] Type of object to get
209          */
210         enum tf_tbl_type type;
211         /**
212          * [out] Entry data
213          */
214         uint8_t *data;
215         /**
216          * [out] Entry size
217          */
218         uint16_t data_sz_in_bytes;
219         /**
220          * [in] Entry index to read
221          */
222         uint32_t idx;
223 };
224
225 /**
226  * Table get bulk parameters
227  */
228 struct tf_tbl_get_bulk_parms {
229         /**
230          * [in] Receive or transmit direction
231          */
232         enum tf_dir dir;
233         /**
234          * [in] Type of object to get
235          */
236         enum tf_tbl_type type;
237         /**
238          * [in] Starting index to read from
239          */
240         uint32_t starting_idx;
241         /**
242          * [in] Number of sequential entries
243          */
244         uint16_t num_entries;
245         /**
246          * [in] Size of the single entry
247          */
248         uint16_t entry_sz_in_bytes;
249         /**
250          * [out] Host physical address, where the data
251          * will be copied to by the firmware.
252          * Use tfp_calloc() API and mem_pa
253          * variable of the tfp_calloc_parms
254          * structure for the physical address.
255          */
256         uint64_t physical_mem_addr;
257 };
258
259 /**
260  * @page tbl Table
261  *
262  * @ref tf_tbl_bind
263  *
264  * @ref tf_tbl_unbind
265  *
266  * @ref tf_tbl_alloc
267  *
268  * @ref tf_tbl_free
269  *
270  * @ref tf_tbl_alloc_search
271  *
272  * @ref tf_tbl_set
273  *
274  * @ref tf_tbl_get
275  *
276  * @ref tf_tbl_bulk_get
277  */
278
279 /**
280  * Initializes the Table module with the requested DBs. Must be
281  * invoked as the first thing before any of the access functions.
282  *
283  * [in] tfp
284  *   Pointer to TF handle, used for HCAPI communication
285  *
286  * [in] parms
287  *   Pointer to Table configuration parameters
288  *
289  * Returns
290  *   - (0) if successful.
291  *   - (-EINVAL) on failure.
292  */
293 int tf_tbl_bind(struct tf *tfp,
294                 struct tf_tbl_cfg_parms *parms);
295
296 /**
297  * Cleans up the private DBs and releases all the data.
298  *
299  * [in] tfp
300  *   Pointer to TF handle, used for HCAPI communication
301  *
302  * [in] parms
303  *   Pointer to parameters
304  *
305  * Returns
306  *   - (0) if successful.
307  *   - (-EINVAL) on failure.
308  */
309 int tf_tbl_unbind(struct tf *tfp);
310
311 /**
312  * Allocates the requested table type from the internal RM DB.
313  *
314  * [in] tfp
315  *   Pointer to TF handle, used for HCAPI communication
316  *
317  * [in] parms
318  *   Pointer to Table allocation parameters
319  *
320  * Returns
321  *   - (0) if successful.
322  *   - (-EINVAL) on failure.
323  */
324 int tf_tbl_alloc(struct tf *tfp,
325                  struct tf_tbl_alloc_parms *parms);
326
327 /**
328  * Free's the requested table type and returns it to the DB. If shadow
329  * DB is enabled its searched first and if found the element refcount
330  * is decremented. If refcount goes to 0 then its returned to the
331  * table type DB.
332  *
333  * [in] tfp
334  *   Pointer to TF handle, used for HCAPI communication
335  *
336  * [in] parms
337  *   Pointer to Table free parameters
338  *
339  * Returns
340  *   - (0) if successful.
341  *   - (-EINVAL) on failure.
342  */
343 int tf_tbl_free(struct tf *tfp,
344                 struct tf_tbl_free_parms *parms);
345
346 /**
347  * Supported if Shadow DB is configured. Searches the Shadow DB for
348  * any matching element. If found the refcount in the shadow DB is
349  * updated accordingly. If not found a new element is allocated and
350  * installed into the shadow DB.
351  *
352  * [in] tfp
353  *   Pointer to TF handle, used for HCAPI communication
354  *
355  * [in] parms
356  *   Pointer to parameters
357  *
358  * Returns
359  *   - (0) if successful.
360  *   - (-EINVAL) on failure.
361  */
362 int tf_tbl_alloc_search(struct tf *tfp,
363                         struct tf_tbl_alloc_search_parms *parms);
364
365 /**
366  * Configures the requested element by sending a firmware request which
367  * then installs it into the device internal structures.
368  *
369  * [in] tfp
370  *   Pointer to TF handle, used for HCAPI communication
371  *
372  * [in] parms
373  *   Pointer to Table set parameters
374  *
375  * Returns
376  *   - (0) if successful.
377  *   - (-EINVAL) on failure.
378  */
379 int tf_tbl_set(struct tf *tfp,
380                struct tf_tbl_set_parms *parms);
381
382 /**
383  * Retrieves the requested element by sending a firmware request to get
384  * the element.
385  *
386  * [in] tfp
387  *   Pointer to TF handle, used for HCAPI communication
388  *
389  * [in] parms
390  *   Pointer to Table get parameters
391  *
392  * Returns
393  *   - (0) if successful.
394  *   - (-EINVAL) on failure.
395  */
396 int tf_tbl_get(struct tf *tfp,
397                struct tf_tbl_get_parms *parms);
398
399 /**
400  * Retrieves bulk block of elements by sending a firmware request to
401  * get the elements.
402  *
403  * [in] tfp
404  *   Pointer to TF handle, used for HCAPI communication
405  *
406  * [in] parms
407  *   Pointer to Table get bulk parameters
408  *
409  * Returns
410  *   - (0) if successful.
411  *   - (-EINVAL) on failure.
412  */
413 int tf_tbl_bulk_get(struct tf *tfp,
414                     struct tf_tbl_get_bulk_parms *parms);
415
416 #endif /* TF_TBL_TYPE_H */