cf799c200d0f4a5374569618128f26acb5bca82d
[dpdk.git] / drivers / net / bnxt / tf_core / tf_em.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019-2020 Broadcom
3  * All rights reserved.
4  */
5
6 #ifndef _TF_EM_H_
7 #define _TF_EM_H_
8
9 #include "tf_core.h"
10 #include "tf_session.h"
11
12 #define TF_HACK_TBL_SCOPE_BASE 68
13 #define SUPPORT_CFA_HW_P4 1
14 #define SUPPORT_CFA_HW_P58 0
15 #define SUPPORT_CFA_HW_P59 0
16 #define SUPPORT_CFA_HW_ALL 0
17
18 #include "hcapi/hcapi_cfa_defs.h"
19
20 #define TF_HW_EM_KEY_MAX_SIZE 52
21 #define TF_EM_KEY_RECORD_SIZE 64
22
23 #define TF_EM_MAX_MASK 0x7FFF
24 #define TF_EM_MAX_ENTRY (128 * 1024 * 1024)
25
26 /*
27  * Used to build GFID:
28  *
29  *   15           2  0
30  *  +--------------+--+
31  *  |   Index      |E |
32  *  +--------------+--+
33  *
34  * E = Entry (bucket inndex)
35  */
36 #define TF_EM_INTERNAL_INDEX_SHIFT 2
37 #define TF_EM_INTERNAL_INDEX_MASK 0xFFFC
38 #define TF_EM_INTERNAL_ENTRY_MASK  0x3
39
40 /** EM Entry
41  *  Each EM entry is 512-bit (64-bytes) but ordered differently to
42  *  EEM.
43  */
44 struct tf_em_64b_entry {
45         /** Header is 8 bytes long */
46         struct cfa_p4_eem_entry_hdr hdr;
47         /** Key is 448 bits - 56 bytes */
48         uint8_t key[TF_EM_KEY_RECORD_SIZE - sizeof(struct cfa_p4_eem_entry_hdr)];
49 };
50
51 /** EEM Memory Type
52  *
53  */
54 enum tf_mem_type {
55         TF_EEM_MEM_TYPE_INVALID,
56         TF_EEM_MEM_TYPE_HOST,
57         TF_EEM_MEM_TYPE_SYSTEM
58 };
59
60 /**
61  * tf_em_cfg_parms definition
62  */
63 struct tf_em_cfg_parms {
64         /**
65          * [in] Num entries in resource config
66          */
67         uint16_t num_elements;
68         /**
69          * [in] Resource config
70          */
71         struct tf_rm_element_cfg *cfg;
72         /**
73          * Session resource allocations
74          */
75         struct tf_session_resources *resources;
76         /**
77          * [in] Memory type.
78          */
79         enum tf_mem_type mem_type;
80 };
81
82 /**
83  * @page table Table
84  *
85  * @ref tf_alloc_eem_tbl_scope
86  *
87  * @ref tf_free_eem_tbl_scope_cb
88  *
89  * @ref tbl_scope_cb_find
90  */
91
92 /**
93  * Allocates EEM Table scope
94  *
95  * [in] tfp
96  *   Pointer to TruFlow handle
97  *
98  * [in] parms
99  *   Pointer to input parameters
100  *
101  * Returns:
102  *   0       - Success
103  *   -EINVAL - Parameter error
104  *   -ENOMEM - Out of memory
105  */
106 int tf_alloc_eem_tbl_scope(struct tf *tfp,
107                            struct tf_alloc_tbl_scope_parms *parms);
108
109 /**
110  * Free's EEM Table scope control block
111  *
112  * [in] tfp
113  *   Pointer to TruFlow handle
114  *
115  * [in] parms
116  *   Pointer to input parameters
117  *
118  * Returns:
119  *   0       - Success
120  *   -EINVAL - Parameter error
121  */
122 int tf_free_eem_tbl_scope_cb(struct tf *tfp,
123                              struct tf_free_tbl_scope_parms *parms);
124
125 /**
126  * Insert record in to internal EM table
127  *
128  * [in] tfp
129  *   Pointer to TruFlow handle
130  *
131  * [in] parms
132  *   Pointer to input parameters
133  *
134  * Returns:
135  *   0       - Success
136  *   -EINVAL - Parameter error
137  */
138 int tf_em_insert_int_entry(struct tf *tfp,
139                            struct tf_insert_em_entry_parms *parms);
140
141 /**
142  * Delete record from internal EM table
143  *
144  * [in] tfp
145  *   Pointer to TruFlow handle
146  *
147  * [in] parms
148  *   Pointer to input parameters
149  *
150  * Returns:
151  *   0       - Success
152  *   -EINVAL - Parameter error
153  */
154 int tf_em_delete_int_entry(struct tf *tfp,
155                            struct tf_delete_em_entry_parms *parms);
156
157 /**
158  * Insert record in to external EEM table
159  *
160  * [in] tfp
161  *   Pointer to TruFlow handle
162  *
163  * [in] parms
164  *   Pointer to input parameters
165  *
166  * Returns:
167  *   0       - Success
168  *   -EINVAL - Parameter error
169  */
170 int tf_em_insert_ext_entry(struct tf *tfp,
171                            struct tf_insert_em_entry_parms *parms);
172
173 /**
174  * Insert record from external EEM table
175  *
176  * [in] tfp
177  *   Pointer to TruFlow handle
178  *
179  * [in] parms
180  *   Pointer to input parameters
181  *
182  * Returns:
183  *   0       - Success
184  *   -EINVAL - Parameter error
185  */
186 int tf_em_delete_ext_entry(struct tf *tfp,
187                            struct tf_delete_em_entry_parms *parms);
188
189 /**
190  * Insert record in to external system EEM table
191  *
192  * [in] tfp
193  *   Pointer to TruFlow handle
194  *
195  * [in] parms
196  *   Pointer to input parameters
197  *
198  * Returns:
199  *   0       - Success
200  *   -EINVAL - Parameter error
201  */
202 int tf_em_insert_ext_sys_entry(struct tf *tfp,
203                                struct tf_insert_em_entry_parms *parms);
204
205 /**
206  * Delete record from external system EEM table
207  *
208  * [in] tfp
209  *   Pointer to TruFlow handle
210  *
211  * [in] parms
212  *   Pointer to input parameters
213  *
214  * Returns:
215  *   0       - Success
216  *   -EINVAL - Parameter error
217  */
218 int tf_em_delete_ext_sys_entry(struct tf *tfp,
219                                struct tf_delete_em_entry_parms *parms);
220
221 /**
222  * Bind internal EM device interface
223  *
224  * [in] tfp
225  *   Pointer to TruFlow handle
226  *
227  * [in] parms
228  *   Pointer to input parameters
229  *
230  * Returns:
231  *   0       - Success
232  *   -EINVAL - Parameter error
233  */
234 int tf_em_int_bind(struct tf *tfp,
235                    struct tf_em_cfg_parms *parms);
236
237 /**
238  * Unbind internal EM device interface
239  *
240  * [in] tfp
241  *   Pointer to TruFlow handle
242  *
243  * [in] parms
244  *   Pointer to input parameters
245  *
246  * Returns:
247  *   0       - Success
248  *   -EINVAL - Parameter error
249  */
250 int tf_em_int_unbind(struct tf *tfp);
251
252 /**
253  * Common bind for EEM device interface. Used for both host and
254  * system memory
255  *
256  * [in] tfp
257  *   Pointer to TruFlow handle
258  *
259  * [in] parms
260  *   Pointer to input parameters
261  *
262  * Returns:
263  *   0       - Success
264  *   -EINVAL - Parameter error
265  */
266 int tf_em_ext_common_bind(struct tf *tfp,
267                           struct tf_em_cfg_parms *parms);
268
269 /**
270  * Common unbind for EEM device interface. Used for both host and
271  * system memory
272  *
273  * [in] tfp
274  *   Pointer to TruFlow handle
275  *
276  * [in] parms
277  *   Pointer to input parameters
278  *
279  * Returns:
280  *   0       - Success
281  *   -EINVAL - Parameter error
282  */
283 int tf_em_ext_common_unbind(struct tf *tfp);
284
285 /**
286  * Alloc for external EEM using host memory
287  *
288  * [in] tfp
289  *   Pointer to TruFlow handle
290  *
291  * [in] parms
292  *   Pointer to input parameters
293  *
294  * Returns:
295  *   0       - Success
296  *   -EINVAL - Parameter error
297  */
298 int tf_em_ext_host_alloc(struct tf *tfp,
299                          struct tf_alloc_tbl_scope_parms *parms);
300
301 /**
302  * Free for external EEM using host memory
303  *
304  * [in] tfp
305  *   Pointer to TruFlow handle
306  *
307  * [in] parms
308  *   Pointer to input parameters
309  *
310  * Returns:
311  *   0       - Success
312  *   -EINVAL - Parameter error
313  */
314 int tf_em_ext_host_free(struct tf *tfp,
315                         struct tf_free_tbl_scope_parms *parms);
316
317 /**
318  * Alloc for external EEM using system memory
319  *
320  * [in] tfp
321  *   Pointer to TruFlow handle
322  *
323  * [in] parms
324  *   Pointer to input parameters
325  *
326  * Returns:
327  *   0       - Success
328  *   -EINVAL - Parameter error
329  */
330 int tf_em_ext_system_alloc(struct tf *tfp,
331                          struct tf_alloc_tbl_scope_parms *parms);
332
333 /**
334  * Free for external EEM using system memory
335  *
336  * [in] tfp
337  *   Pointer to TruFlow handle
338  *
339  * [in] parms
340  *   Pointer to input parameters
341  *
342  * Returns:
343  *   0       - Success
344  *   -EINVAL - Parameter error
345  */
346 int tf_em_ext_system_free(struct tf *tfp,
347                         struct tf_free_tbl_scope_parms *parms);
348
349 /**
350  * Common free for external EEM using host or system memory
351  *
352  * [in] tfp
353  *   Pointer to TruFlow handle
354  *
355  * [in] parms
356  *   Pointer to input parameters
357  *
358  * Returns:
359  *   0       - Success
360  *   -EINVAL - Parameter error
361  */
362 int tf_em_ext_common_free(struct tf *tfp,
363                           struct tf_free_tbl_scope_parms *parms);
364
365 /**
366  * Common alloc for external EEM using host or system memory
367  *
368  * [in] tfp
369  *   Pointer to TruFlow handle
370  *
371  * [in] parms
372  *   Pointer to input parameters
373  *
374  * Returns:
375  *   0       - Success
376  *   -EINVAL - Parameter error
377  */
378 int tf_em_ext_common_alloc(struct tf *tfp,
379                            struct tf_alloc_tbl_scope_parms *parms);
380 #endif /* _TF_EM_H_ */