net/bnxt: support bulk table get and mirror
[dpdk.git] / drivers / net / bnxt / tf_core / tf_tbl_type.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
11 struct tf;
12
13 /**
14  * The Table Type module provides processing of Internal TF table types.
15  */
16
17 /**
18  * Table Type configuration parameters
19  */
20 struct tf_tbl_type_cfg_parms {
21         /**
22          * Number of table types in each of the configuration arrays
23          */
24         uint16_t num_elements;
25
26         /**
27          * Table Type element configuration array
28          */
29         struct tf_rm_element_cfg *tbl_cfg[TF_DIR_MAX];
30
31         /**
32          * Shadow table type configuration array
33          */
34         struct tf_shadow_tbl_type_cfg *tbl_shadow_cfg[TF_DIR_MAX];
35 };
36
37 /**
38  * Table Type allocation parameters
39  */
40 struct tf_tbl_type_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          * [out] Idx of allocated entry or found entry (if search_enable)
51          */
52         uint32_t idx;
53 };
54
55 /**
56  * Table Type free parameters
57  */
58 struct tf_tbl_type_free_parms {
59         /**
60          * [in] Receive or transmit direction
61          */
62         enum tf_dir dir;
63         /**
64          * [in] Type of the allocation type
65          */
66         enum tf_tbl_type type;
67         /**
68          * [in] Index to free
69          */
70         uint32_t idx;
71         /**
72          * [out] Reference count after free, only valid if session has been
73          * created with shadow_copy.
74          */
75         uint16_t ref_cnt;
76 };
77
78 struct tf_tbl_type_alloc_search_parms {
79         /**
80          * [in] Receive or transmit direction
81          */
82         enum tf_dir dir;
83         /**
84          * [in] Type of the allocation
85          */
86         enum tf_tbl_type type;
87         /**
88          * [in] Table scope identifier (ignored unless TF_TBL_TYPE_EXT)
89          */
90         uint32_t tbl_scope_id;
91         /**
92          * [in] Enable search for matching entry. If the table type is
93          * internal the shadow copy will be searched before
94          * alloc. Session must be configured with shadow copy enabled.
95          */
96         uint8_t search_enable;
97         /**
98          * [in] Result data to search for (if search_enable)
99          */
100         uint8_t *result;
101         /**
102          * [in] Result data size in bytes (if search_enable)
103          */
104         uint16_t result_sz_in_bytes;
105         /**
106          * [out] If search_enable, set if matching entry found
107          */
108         uint8_t hit;
109         /**
110          * [out] Current ref count after allocation (if search_enable)
111          */
112         uint16_t ref_cnt;
113         /**
114          * [out] Idx of allocated entry or found entry (if search_enable)
115          */
116         uint32_t idx;
117 };
118
119 /**
120  * Table Type set parameters
121  */
122 struct tf_tbl_type_set_parms {
123         /**
124          * [in] Receive or transmit direction
125          */
126         enum tf_dir dir;
127         /**
128          * [in] Type of object to set
129          */
130         enum tf_tbl_type type;
131         /**
132          * [in] Entry data
133          */
134         uint8_t *data;
135         /**
136          * [in] Entry size
137          */
138         uint16_t data_sz_in_bytes;
139         /**
140          * [in] Entry index to write to
141          */
142         uint32_t idx;
143 };
144
145 /**
146  * Table Type get parameters
147  */
148 struct tf_tbl_type_get_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          * [out] Entry data
159          */
160         uint8_t *data;
161         /**
162          * [out] Entry size
163          */
164         uint16_t data_sz_in_bytes;
165         /**
166          * [in] Entry index to read
167          */
168         uint32_t idx;
169 };
170
171 /**
172  * @page tbl_type Table Type
173  *
174  * @ref tf_tbl_type_bind
175  *
176  * @ref tf_tbl_type_unbind
177  *
178  * @ref tf_tbl_type_alloc
179  *
180  * @ref tf_tbl_type_free
181  *
182  * @ref tf_tbl_type_alloc_search
183  *
184  * @ref tf_tbl_type_set
185  *
186  * @ref tf_tbl_type_get
187  */
188
189 /**
190  * Initializes the Table Type module with the requested DBs. Must be
191  * invoked as the first thing before any of the access functions.
192  *
193  * [in] tfp
194  *   Pointer to TF handle, used for HCAPI communication
195  *
196  * [in] parms
197  *   Pointer to parameters
198  *
199  * Returns
200  *   - (0) if successful.
201  *   - (-EINVAL) on failure.
202  */
203 int tf_tbl_type_bind(struct tf *tfp,
204                      struct tf_tbl_type_cfg_parms *parms);
205
206 /**
207  * Cleans up the private DBs and releases all the data.
208  *
209  * [in] tfp
210  *   Pointer to TF handle, used for HCAPI communication
211  *
212  * [in] parms
213  *   Pointer to parameters
214  *
215  * Returns
216  *   - (0) if successful.
217  *   - (-EINVAL) on failure.
218  */
219 int tf_tbl_type_unbind(struct tf *tfp);
220
221 /**
222  * Allocates the requested table type from the internal RM DB.
223  *
224  * [in] tfp
225  *   Pointer to TF handle, used for HCAPI communication
226  *
227  * [in] parms
228  *   Pointer to parameters
229  *
230  * Returns
231  *   - (0) if successful.
232  *   - (-EINVAL) on failure.
233  */
234 int tf_tbl_type_alloc(struct tf *tfp,
235                       struct tf_tbl_type_alloc_parms *parms);
236
237 /**
238  * Free's the requested table type and returns it to the DB. If shadow
239  * DB is enabled its searched first and if found the element refcount
240  * is decremented. If refcount goes to 0 then its returned to the
241  * table type DB.
242  *
243  * [in] tfp
244  *   Pointer to TF handle, used for HCAPI communication
245  *
246  * [in] parms
247  *   Pointer to parameters
248  *
249  * Returns
250  *   - (0) if successful.
251  *   - (-EINVAL) on failure.
252  */
253 int tf_tbl_type_free(struct tf *tfp,
254                      struct tf_tbl_type_free_parms *parms);
255
256 /**
257  * Supported if Shadow DB is configured. Searches the Shadow DB for
258  * any matching element. If found the refcount in the shadow DB is
259  * updated accordingly. If not found a new element is allocated and
260  * installed into the shadow DB.
261  *
262  * [in] tfp
263  *   Pointer to TF handle, used for HCAPI communication
264  *
265  * [in] parms
266  *   Pointer to parameters
267  *
268  * Returns
269  *   - (0) if successful.
270  *   - (-EINVAL) on failure.
271  */
272 int tf_tbl_type_alloc_search(struct tf *tfp,
273                              struct tf_tbl_type_alloc_search_parms *parms);
274
275 /**
276  * Configures the requested element by sending a firmware request which
277  * then installs it into the device internal structures.
278  *
279  * [in] tfp
280  *   Pointer to TF handle, used for HCAPI communication
281  *
282  * [in] parms
283  *   Pointer to parameters
284  *
285  * Returns
286  *   - (0) if successful.
287  *   - (-EINVAL) on failure.
288  */
289 int tf_tbl_type_set(struct tf *tfp,
290                     struct tf_tbl_type_set_parms *parms);
291
292 /**
293  * Retrieves the requested element by sending a firmware request to get
294  * the element.
295  *
296  * [in] tfp
297  *   Pointer to TF handle, used for HCAPI communication
298  *
299  * [in] parms
300  *   Pointer to parameters
301  *
302  * Returns
303  *   - (0) if successful.
304  *   - (-EINVAL) on failure.
305  */
306 int tf_tbl_type_get(struct tf *tfp,
307                     struct tf_tbl_type_get_parms *parms);
308
309 #endif /* TF_TBL_TYPE_H */