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