fb635f6dc8fc53fdd6295c5a42470860595f087f
[dpdk.git] / drivers / net / bnxt / tf_core / tf_msg.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019-2020 Broadcom
3  * All rights reserved.
4  */
5
6 #ifndef _TF_MSG_H_
7 #define _TF_MSG_H_
8
9 #include <rte_common.h>
10 #include <hsi_struct_def_dpdk.h>
11
12 #include "tf_tbl.h"
13 #include "tf_rm.h"
14 #include "tf_rm_new.h"
15 #include "tf_tcam.h"
16
17 struct tf;
18
19 /**
20  * Sends session open request to Firmware
21  *
22  * [in] session
23  *   Pointer to session handle
24  *
25  * [in] ctrl_chan_name
26  *   PCI name of the control channel
27  *
28  * [in/out] fw_session_id
29  *   Pointer to the fw_session_id that is allocated on firmware side
30  *
31  * Returns:
32  *
33  */
34 int tf_msg_session_open(struct tf *tfp,
35                         char *ctrl_chan_name,
36                         uint8_t *fw_session_id);
37
38 /**
39  * Sends session close request to Firmware
40  *
41  * [in] session
42  *   Pointer to session handle
43  *
44  * [in] fw_session_id
45  *   Pointer to the fw_session_id that is assigned to the session at
46  *   time of session open
47  *
48  * Returns:
49  *
50  */
51 int tf_msg_session_attach(struct tf *tfp,
52                           char *ctrl_channel_name,
53                           uint8_t tf_fw_session_id);
54
55 /**
56  * Sends session close request to Firmware
57  *
58  * [in] session
59  *   Pointer to session handle
60  *
61  * Returns:
62  *
63  */
64 int tf_msg_session_close(struct tf *tfp);
65
66 /**
67  * Sends session query config request to TF Firmware
68  */
69 int tf_msg_session_qcfg(struct tf *tfp);
70
71 /**
72  * Sends session HW resource query capability request to TF Firmware
73  */
74 int tf_msg_session_hw_resc_qcaps(struct tf *tfp,
75                                  enum tf_dir dir,
76                                  struct tf_rm_hw_query *hw_query);
77
78 /**
79  * Sends session HW resource allocation request to TF Firmware
80  */
81 int tf_msg_session_hw_resc_alloc(struct tf *tfp,
82                                  enum tf_dir dir,
83                                  struct tf_rm_hw_alloc *hw_alloc,
84                                  struct tf_rm_entry *hw_entry);
85
86 /**
87  * Sends session HW resource free request to TF Firmware
88  */
89 int tf_msg_session_hw_resc_free(struct tf *tfp,
90                                 enum tf_dir dir,
91                                 struct tf_rm_entry *hw_entry);
92
93 /**
94  * Sends session HW resource flush request to TF Firmware
95  */
96 int tf_msg_session_hw_resc_flush(struct tf *tfp,
97                                  enum tf_dir dir,
98                                  struct tf_rm_entry *hw_entry);
99
100 /**
101  * Sends session SRAM resource query capability request to TF Firmware
102  */
103 int tf_msg_session_sram_resc_qcaps(struct tf *tfp,
104                                    enum tf_dir dir,
105                                    struct tf_rm_sram_query *sram_query);
106
107 /**
108  * Sends session SRAM resource allocation request to TF Firmware
109  */
110 int tf_msg_session_sram_resc_alloc(struct tf *tfp,
111                                    enum tf_dir dir,
112                                    struct tf_rm_sram_alloc *sram_alloc,
113                                    struct tf_rm_entry *sram_entry);
114
115 /**
116  * Sends session SRAM resource free request to TF Firmware
117  */
118 int tf_msg_session_sram_resc_free(struct tf *tfp,
119                                   enum tf_dir dir,
120                                   struct tf_rm_entry *sram_entry);
121
122 /**
123  * Sends session SRAM resource flush request to TF Firmware
124  */
125 int tf_msg_session_sram_resc_flush(struct tf *tfp,
126                                    enum tf_dir dir,
127                                    struct tf_rm_entry *sram_entry);
128
129 /**
130  * Sends session HW resource query capability request to TF Firmware
131  *
132  * [in] tfp
133  *   Pointer to TF handle
134  *
135  * [in] dir
136  *   Receive or Transmit direction
137  *
138  * [in] size
139  *   Number of elements in the query. Should be set to the max
140  *   elements for the device type
141  *
142  * [out] query
143  *   Pointer to an array of query elements
144  *
145  * [out] resv_strategy
146  *   Pointer to the reservation strategy
147  *
148  * Returns:
149  *   0 on Success else internal Truflow error
150  */
151 int tf_msg_session_resc_qcaps(struct tf *tfp,
152                               enum tf_dir dir,
153                               uint16_t size,
154                               struct tf_rm_resc_req_entry *query,
155                               enum tf_rm_resc_resv_strategy *resv_strategy);
156
157 /**
158  * Sends session HW resource allocation request to TF Firmware
159  *
160  * [in] tfp
161  *   Pointer to TF handle
162  *
163  * [in] dir
164  *   Receive or Transmit direction
165  *
166  * [in] size
167  *   Number of elements in the req and resv arrays
168  *
169  * [in] req
170  *   Pointer to an array of request elements
171  *
172  * [in] resv
173  *   Pointer to an array of reserved elements
174  *
175  * Returns:
176  *   0 on Success else internal Truflow error
177  */
178 int tf_msg_session_resc_alloc(struct tf *tfp,
179                               enum tf_dir dir,
180                               uint16_t size,
181                               struct tf_rm_resc_req_entry *request,
182                               struct tf_rm_resc_entry *resv);
183
184 /**
185  * Sends EM internal insert request to Firmware
186  */
187 int tf_msg_insert_em_internal_entry(struct tf *tfp,
188                                     struct tf_insert_em_entry_parms *params,
189                                     uint16_t *rptr_index,
190                                     uint8_t *rptr_entry,
191                                     uint8_t *num_of_entries);
192 /**
193  * Sends EM internal delete request to Firmware
194  */
195 int tf_msg_delete_em_entry(struct tf *tfp,
196                            struct tf_delete_em_entry_parms *em_parms);
197 /**
198  * Sends EM mem register request to Firmware
199  */
200 int tf_msg_em_mem_rgtr(struct tf *tfp,
201                        int           page_lvl,
202                        int           page_size,
203                        uint64_t      dma_addr,
204                        uint16_t     *ctx_id);
205
206 /**
207  * Sends EM mem unregister request to Firmware
208  */
209 int tf_msg_em_mem_unrgtr(struct tf *tfp,
210                          uint16_t     *ctx_id);
211
212 /**
213  * Sends EM qcaps request to Firmware
214  */
215 int tf_msg_em_qcaps(struct tf *tfp,
216                     int dir,
217                     struct tf_em_caps *em_caps);
218
219 /**
220  * Sends EM config request to Firmware
221  */
222 int tf_msg_em_cfg(struct tf *tfp,
223                   uint32_t      num_entries,
224                   uint16_t      key0_ctx_id,
225                   uint16_t      key1_ctx_id,
226                   uint16_t      record_ctx_id,
227                   uint16_t      efc_ctx_id,
228                   uint8_t       flush_interval,
229                   int           dir);
230
231 /**
232  * Sends EM operation request to Firmware
233  */
234 int tf_msg_em_op(struct tf *tfp,
235                  int        dir,
236                  uint16_t   op);
237
238 /**
239  * Sends tcam entry 'set' to the Firmware.
240  *
241  * [in] tfp
242  *   Pointer to session handle
243  *
244  * [in] parms
245  *   Pointer to set parameters
246  *
247  * Returns:
248  *  0 on Success else internal Truflow error
249  */
250 int tf_msg_tcam_entry_set(struct tf *tfp,
251                           struct tf_tcam_set_parms *parms);
252
253 /**
254  * Sends tcam entry 'free' to the Firmware.
255  *
256  * [in] tfp
257  *   Pointer to session handle
258  *
259  * [in] parms
260  *   Pointer to free parameters
261  *
262  * Returns:
263  *  0 on Success else internal Truflow error
264  */
265 int tf_msg_tcam_entry_free(struct tf *tfp,
266                            struct tf_tcam_free_parms *parms);
267
268 /**
269  * Sends Set message of a Table Type element to the firmware.
270  *
271  * [in] tfp
272  *   Pointer to session handle
273  *
274  * [in] dir
275  *   Direction location of the element to set
276  *
277  * [in] type
278  *   Type of the object to set
279  *
280  * [in] size
281  *   Size of the data to set
282  *
283  * [in] data
284  *   Data to set
285  *
286  * [in] index
287  *   Index to set
288  *
289  * Returns:
290  *   0 - Success
291  */
292 int tf_msg_set_tbl_entry(struct tf *tfp,
293                          enum tf_dir dir,
294                          enum tf_tbl_type type,
295                          uint16_t size,
296                          uint8_t *data,
297                          uint32_t index);
298
299 /**
300  * Sends get message of a Table Type element to the firmware.
301  *
302  * [in] tfp
303  *   Pointer to session handle
304  *
305  * [in] dir
306  *   Direction location of the element to get
307  *
308  * [in] type
309  *   Type of the object to get
310  *
311  * [in] size
312  *   Size of the data read
313  *
314  * [in] data
315  *   Data read
316  *
317  * [in] index
318  *   Index to get
319  *
320  * Returns:
321  *   0 - Success
322  */
323 int tf_msg_get_tbl_entry(struct tf *tfp,
324                          enum tf_dir dir,
325                          enum tf_tbl_type type,
326                          uint16_t size,
327                          uint8_t *data,
328                          uint32_t index);
329
330 /**
331  * Sends bulk get message of a Table Type element to the firmware.
332  *
333  * [in] tfp
334  *   Pointer to session handle
335  *
336  * [in] parms
337  *   Pointer to table get bulk parameters
338  *
339  * Returns:
340  *  0 on Success else internal Truflow error
341  */
342 int tf_msg_bulk_get_tbl_entry(struct tf *tfp,
343                           struct tf_bulk_get_tbl_entry_parms *parms);
344
345 #endif  /* _TF_MSG_H_ */