net/bnxt: refactor host session failure cleanup
[dpdk.git] / drivers / net / bnxt / tf_core / tf_msg.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019-2021 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_em_common.h"
13 #include "tf_tbl.h"
14 #include "tf_rm.h"
15 #include "tf_tcam.h"
16 #include "tf_global_cfg.h"
17 #include "bnxt.h"
18
19 struct tf;
20
21 /* HWRM Direct messages */
22
23 /**
24  * Sends session open request to Firmware
25  *
26  * [in] bp
27  *   Pointer to bnxt handle
28  *
29  * [in] ctrl_chan_name
30  *   PCI name of the control channel
31  *
32  * [in/out] fw_session_id
33  *   Pointer to the fw_session_id that is allocated on firmware side
34  *
35  * [in/out] fw_session_client_id
36  *   Pointer to the fw_session_client_id that is allocated on firmware side
37  *
38  * [in/out] dev
39  *   Pointer to the associated device
40  *
41  * [out] shared_session_creator
42  *   Pointer to the shared_session_creator
43  *
44  * Returns:
45  *   0 on Success else internal Truflow error
46  */
47 int tf_msg_session_open(struct bnxt *bp,
48                         char *ctrl_chan_name,
49                         uint8_t *fw_session_id,
50                         uint8_t *fw_session_client_id,
51                         struct tf_dev_info *dev,
52                         bool *shared_session_creator);
53
54 /**
55  * Sends session close request to Firmware
56  *
57  * [in] session
58  *   Pointer to session handle
59  *
60  * [in] ctrl_chan_name
61  *   PCI name of the control channel
62  *
63  * [in] fw_session_id
64  *   Pointer to the fw_session_id that is assigned to the session at
65  *   time of session open
66  *
67  * Returns:
68  *   0 on Success else internal Truflow error
69  */
70 int tf_msg_session_attach(struct tf *tfp,
71                           char *ctrl_channel_name,
72                           uint8_t tf_fw_session_id);
73
74 /**
75  * Sends session client register request to Firmware
76  *
77  * [in] session
78  *   Pointer to session handle
79  *
80  * [in] ctrl_chan_name
81  *   PCI name of the control channel
82  *
83  * [in/out] fw_session_client_id
84  *   Pointer to the fw_session_client_id that is allocated on firmware
85  *   side
86  *
87  * Returns:
88  *   0 on Success else internal Truflow error
89  */
90 int tf_msg_session_client_register(struct tf *tfp,
91                                    struct tf_session *tfs,
92                                    char *ctrl_channel_name,
93                                    uint8_t *fw_session_client_id);
94
95 /**
96  * Sends session client unregister request to Firmware
97  *
98  * [in] session
99  *   Pointer to session handle
100  *
101  * [in/out] fw_session_client_id
102  *   Pointer to the fw_session_client_id that is allocated on firmware
103  *   side
104  *
105  * Returns:
106  *   0 on Success else internal Truflow error
107  */
108 int tf_msg_session_client_unregister(struct tf *tfp,
109                                      struct tf_session *tfs,
110                                      uint8_t fw_session_client_id);
111
112 /**
113  * Sends session close request to Firmware
114  *
115  * [in] session
116  *   Pointer to session handle
117  *
118  * [in] fw_session_id
119  *   fw session id
120  *
121  * [in] mailbox
122  *   mailbox
123  *
124  * Returns:
125  *   0 on Success else internal Truflow error
126  */
127 int tf_msg_session_close(struct tf *tfp,
128                          uint8_t fw_session_id,
129                          int mailbox);
130
131 /**
132  * Sends session query config request to TF Firmware
133  *
134  * [in] session
135  *   Pointer to session handle
136  *
137  * Returns:
138  *   0 on Success else internal Truflow error
139  */
140 int tf_msg_session_qcfg(struct tf *tfp);
141
142 /**
143  * Sends session HW resource query capability request to TF Firmware
144  *
145  * [in] tfp
146  *   Pointer to TF handle
147  *
148  * [in] dir
149  *   Receive or Transmit direction
150  *
151  * [in] size
152  *   Number of elements in the query. Should be set to the max
153  *   elements for the device type
154  *
155  * [out] query
156  *   Pointer to an array of query elements
157  *
158  * [out] resv_strategy
159  *   Pointer to the reservation strategy
160  *
161  * Returns:
162  *   0 on Success else internal Truflow error
163  */
164 int tf_msg_session_resc_qcaps(struct tf *tfp,
165                               struct tf_dev_info *dev,
166                               enum tf_dir dir,
167                               uint16_t size,
168                               struct tf_rm_resc_req_entry *query,
169                               enum tf_rm_resc_resv_strategy *resv_strategy);
170
171 /**
172  * Sends session HW resource allocation request to TF Firmware
173  *
174  * [in] tfp
175  *   Pointer to TF handle
176  *
177  * [in] dir
178  *   Receive or Transmit direction
179  *
180  * [in] size
181  *   Number of elements in the req and resv arrays
182  *
183  * [in] req
184  *   Pointer to an array of request elements
185  *
186  * [in] resv
187  *   Pointer to an array of reserved elements
188  *
189  * Returns:
190  *   0 on Success else internal Truflow error
191  */
192 int tf_msg_session_resc_alloc(struct tf *tfp,
193                               struct tf_dev_info *dev,
194                               enum tf_dir dir,
195                               uint16_t size,
196                               struct tf_rm_resc_req_entry *request,
197                               struct tf_rm_resc_entry *resv);
198
199 /**
200  * Sends session HW resource allocation request to TF Firmware
201  *
202  * [in] tfp
203  *   Pointer to TF handle
204  *
205  * [in] dir
206  *   Receive or Transmit direction
207  *
208  * [in] size
209  *   Number of elements in the req and resv arrays
210  *
211  * [in] req
212  *   Pointer to an array of request elements
213  *
214  * [in] resv
215  *   Pointer to an array of reserved elements
216  *
217  * Returns:
218  *   0 on Success else internal Truflow error
219  */
220 int tf_msg_session_resc_info(struct tf *tfp,
221                               struct tf_dev_info *dev,
222                               enum tf_dir dir,
223                               uint16_t size,
224                               struct tf_rm_resc_req_entry *request,
225                               struct tf_rm_resc_entry *resv);
226
227 /**
228  * Sends session resource flush request to TF Firmware
229  *
230  * [in] tfp
231  *   Pointer to TF handle
232  *
233  * [in] dir
234  *   Receive or Transmit direction
235  *
236  * [in] size
237  *   Number of elements in the req and resv arrays
238  *
239  * [in] resv
240  *   Pointer to an array of reserved elements that needs to be flushed
241  *
242  * Returns:
243  *   0 on Success else internal Truflow error
244  */
245 int tf_msg_session_resc_flush(struct tf *tfp,
246                               enum tf_dir dir,
247                               uint16_t size,
248                               struct tf_rm_resc_entry *resv);
249 /**
250  * Sends EM internal insert request to Firmware
251  *
252  * [in] tfp
253  *   Pointer to TF handle
254  *
255  * [in] params
256  *   Pointer to em insert parameter list
257  *
258  * [in] rptr_index
259  *   Record ptr index
260  *
261  * [in] rptr_entry
262  *   Record ptr entry
263  *
264  * [in] num_of_entries
265  *   Number of entries to insert
266  *
267  * Returns:
268  *   0 on Success else internal Truflow error
269  */
270 int tf_msg_insert_em_internal_entry(struct tf *tfp,
271                                     struct tf_insert_em_entry_parms *params,
272                                     uint16_t *rptr_index,
273                                     uint8_t *rptr_entry,
274                                     uint8_t *num_of_entries);
275 /**
276  * Sends EM hash internal insert request to Firmware
277  *
278  * [in] tfp
279  *   Pointer to TF handle
280  *
281  * [in] params
282  *   Pointer to em insert parameter list
283  *
284  * [in] key0_hash
285  *      CRC32 hash of key
286  *
287  * [in] key1_hash
288  *      Lookup3 hash of key
289  *
290  * [in] rptr_index
291  *   Record ptr index
292  *
293  * [in] rptr_entry
294  *   Record ptr entry
295  *
296  * [in] num_of_entries
297  *   Number of entries to insert
298  *
299  * Returns:
300  *   0 on Success else internal Truflow error
301  */
302 int
303 tf_msg_hash_insert_em_internal_entry(struct tf *tfp,
304                                 struct tf_insert_em_entry_parms *em_parms,
305                                 uint32_t key0_hash,
306                                 uint32_t key1_hash,
307                                 uint16_t *rptr_index,
308                                 uint8_t *rptr_entry,
309                                 uint8_t *num_of_entries);
310 /**
311  * Sends EM internal delete request to Firmware
312  *
313  * [in] tfp
314  *   Pointer to TF handle
315  *
316  * [in] em_parms
317  *   Pointer to em delete parameters
318  *
319  * Returns:
320  *   0 on Success else internal Truflow error
321  */
322 int tf_msg_delete_em_entry(struct tf *tfp,
323                            struct tf_delete_em_entry_parms *em_parms);
324
325 /**
326  * Sends EM internal move request to Firmware
327  *
328  * [in] tfp
329  *   Pointer to TF handle
330  *
331  * [in] em_parms
332  *   Pointer to em move parameters
333  *
334  * Returns:
335  *   0 on Success else internal Truflow error
336  */
337 int tf_msg_move_em_entry(struct tf *tfp,
338                          struct tf_move_em_entry_parms *em_parms);
339
340 /**
341  * Sends Ext EM mem allocation request to Firmware
342  *
343  * [in] tfp
344  *   Pointer to TF handle
345  *
346  * [in] tbl
347  *   memory allocation details
348  *
349  * [out] dma_addr
350  *   memory address
351  *
352  * [out] page_lvl
353  *   page level
354  *
355  * [out] page_size
356  *   page size
357  *
358  * Returns:
359  *   0 on Success else internal Truflow error
360  */
361 int tf_msg_ext_em_ctxt_mem_alloc(struct tf *tfp,
362                         struct hcapi_cfa_em_table *tbl,
363                         uint64_t *dma_addr,
364                         uint32_t *page_lvl,
365                         uint32_t *page_size);
366
367 /**
368  * Sends Ext EM mem allocation request to Firmware
369  *
370  * [in] tfp
371  *   Pointer to TF handle
372  *
373  * [in] mem_size_k
374  *   memory size in KB
375  *
376  * [in] page_dir
377  *   Pointer to the PBL or PDL depending on number of levels
378  *
379  * [in] page_level
380  *   PBL indirect levels
381  *
382  * [in] page_size
383  *   page size
384  *
385  * Returns:
386  *   0 on Success else internal Truflow error
387  */
388 int tf_msg_ext_em_ctxt_mem_free(struct tf *tfp,
389                                 uint32_t mem_size_k,
390                                 uint64_t dma_addr,
391                                 uint8_t page_level,
392                                 uint8_t page_size);
393
394 /**
395  * Sends EM mem register request to Firmware
396  *
397  * [in] tfp
398  *   Pointer to TF handle
399  *
400  * [in] page_lvl
401  *   Page level
402  *
403  * [in] page_size
404  *   Page size
405  *
406  * [in] dma_addr
407  *   DMA Address for the memory page
408  *
409  * [in] ctx_id
410  *   Context id
411  *
412  * Returns:
413  *   0 on Success else internal Truflow error
414  */
415 int tf_msg_em_mem_rgtr(struct tf *tfp,
416                        int page_lvl,
417                        int page_size,
418                        uint64_t dma_addr,
419                        uint16_t *ctx_id);
420
421 /**
422  * Sends EM mem unregister request to Firmware
423  *
424  * [in] tfp
425  *   Pointer to TF handle
426  *
427  * [in] ctx_id
428  *   Context id
429  *
430  * Returns:
431  *   0 on Success else internal Truflow error
432  */
433 int tf_msg_em_mem_unrgtr(struct tf *tfp,
434                          uint16_t *ctx_id);
435
436 /**
437  * Sends EM qcaps request to Firmware
438  *
439  * [in] tfp
440  *   Pointer to TF handle
441  *
442  * [in] dir
443  *   Receive or Transmit direction
444  *
445  * [in] em_caps
446  *   Pointer to EM capabilities
447  *
448  * Returns:
449  *   0 on Success else internal Truflow error
450  */
451 int tf_msg_em_qcaps(struct tf *tfp,
452                     int dir,
453                     struct tf_em_caps *em_caps);
454
455 /**
456  * Sends EM config request to Firmware
457  *
458  * [in] tfp
459  *   Pointer to TF handle
460  *
461  * [in] num_entries
462  *   EM Table, key 0, number of entries to configure
463  *
464  * [in] key0_ctx_id
465  *   EM Table, Key 0 context id
466  *
467  * [in] key1_ctx_id
468  *   EM Table, Key 1 context id
469  *
470  * [in] record_ctx_id
471  *   EM Table, Record context id
472  *
473  * [in] efc_ctx_id
474  *   EM Table, EFC Table context id
475  *
476  * [in] flush_interval
477  *   Flush pending HW cached flows every 1/10th of value set in
478  *   seconds, both idle and active flows are flushed from the HW
479  *   cache. If set to 0, this feature will be disabled.
480  *
481  * [in] dir
482  *   Receive or Transmit direction
483  *
484  * Returns:
485  *   0 on Success else internal Truflow error
486  */
487 int tf_msg_em_cfg(struct tf *tfp,
488                   uint32_t num_entries,
489                   uint16_t key0_ctx_id,
490                   uint16_t key1_ctx_id,
491                   uint16_t record_ctx_id,
492                   uint16_t efc_ctx_id,
493                   uint8_t flush_interval,
494                   int dir);
495
496 /**
497  * Sends Ext EM config request to Firmware
498  *
499  * [in] tfp
500  *   Pointer to TF handle
501  *
502  * [in] fw_se_id
503  *   FW session id
504  *
505  * [in] tbl_scope_cb
506  *   Table scope parameters
507  *
508  * [in] st_buckets
509  *   static bucket size
510  *
511  * [in] flush_interval
512  *   Flush pending HW cached flows every 1/10th of value set in
513  *   seconds, both idle and active flows are flushed from the HW
514  *   cache. If set to 0, this feature will be disabled.
515  *
516  * [in] dir
517  *   Receive or Transmit direction
518  *
519  * Returns:
520  *   0 on Success else internal Truflow error
521  */
522 int tf_msg_ext_em_cfg(struct tf *tfp,
523                       struct tf_tbl_scope_cb *tbl_scope_cb,
524                       uint32_t st_buckets,
525                       uint8_t flush_interval,
526                       enum tf_dir dir);
527
528 /**
529  * Sends EM operation request to Firmware
530  *
531  * [in] tfp
532  *   Pointer to TF handle
533  *
534  * [in] dir
535  *   Receive or Transmit direction
536  *
537  * [in] op
538  *   CFA Operator
539  *
540  * Returns:
541  *   0 on Success else internal Truflow error
542  */
543 int tf_msg_em_op(struct tf *tfp,
544                  int dir,
545                  uint16_t op);
546
547 /**
548  * Sends tcam entry 'set' to the Firmware.
549  *
550  * [in] tfp
551  *   Pointer to session handle
552  *
553  * [in] parms
554  *   Pointer to set parameters
555  *
556  * Returns:
557  *  0 on Success else internal Truflow error
558  */
559 int tf_msg_tcam_entry_set(struct tf *tfp,
560                           struct tf_dev_info *dev,
561                           struct tf_tcam_set_parms *parms);
562
563 /**
564  * Sends tcam entry 'get' to the Firmware.
565  *
566  * [in] tfp
567  *   Pointer to session handle
568  *
569  * [in] parms
570  *   Pointer to get parameters
571  *
572  * Returns:
573  *  0 on Success else internal Truflow error
574  */
575 int tf_msg_tcam_entry_get(struct tf *tfp,
576                           struct tf_dev_info *dev,
577                           struct tf_tcam_get_parms *parms);
578
579 /**
580  * Sends tcam entry 'free' to the Firmware.
581  *
582  * [in] tfp
583  *   Pointer to session handle
584  *
585  * [in] parms
586  *   Pointer to free parameters
587  *
588  * Returns:
589  *  0 on Success else internal Truflow error
590  */
591 int tf_msg_tcam_entry_free(struct tf *tfp,
592                            struct tf_dev_info *dev,
593                            struct tf_tcam_free_parms *parms);
594
595 /**
596  * Sends Set message of a Table Type element to the firmware.
597  *
598  * [in] tfp
599  *   Pointer to session handle
600  *
601  * [in] dir
602  *   Direction location of the element to set
603  *
604  * [in] hcapi_type
605  *   Type of the object to set
606  *
607  * [in] size
608  *   Size of the data to set
609  *
610  * [in] data
611  *   Data to set
612  *
613  * [in] index
614  *   Index to set
615  *
616  * Returns:
617  *   0 - Success
618  */
619 int tf_msg_set_tbl_entry(struct tf *tfp,
620                          enum tf_dir dir,
621                          uint16_t hcapi_type,
622                          uint16_t size,
623                          uint8_t *data,
624                          uint32_t index);
625
626 /**
627  * Sends get message of a Table Type element to the firmware.
628  *
629  * [in] tfp
630  *   Pointer to session handle
631  *
632  * [in] dir
633  *   Direction location of the element to get
634  *
635  * [in] hcapi_type
636  *   Type of the object to get
637  *
638  * [in] size
639  *   Size of the data read
640  *
641  * [in] data
642  *   Data read
643  *
644  * [in] index
645  *   Index to get
646  *
647  * Returns:
648  *   0 - Success
649  */
650 int tf_msg_get_tbl_entry(struct tf *tfp,
651                          enum tf_dir dir,
652                          uint16_t hcapi_type,
653                          uint16_t size,
654                          uint8_t *data,
655                          uint32_t index);
656
657 /* HWRM Tunneled messages */
658
659 /**
660  * Sends global cfg read request to Firmware
661  *
662  * [in] tfp
663  *   Pointer to TF handle
664  *
665  * [in] params
666  *   Pointer to read parameters
667  *
668  * Returns:
669  *   0 on Success else internal Truflow error
670  */
671 int tf_msg_get_global_cfg(struct tf *tfp,
672                           struct tf_global_cfg_parms *params);
673
674 /**
675  * Sends global cfg update request to Firmware
676  *
677  * [in] tfp
678  *   Pointer to TF handle
679  *
680  * [in] params
681  *   Pointer to write parameters
682  *
683  * Returns:
684  *   0 on Success else internal Truflow error
685  */
686 int tf_msg_set_global_cfg(struct tf *tfp,
687                           struct tf_global_cfg_parms *params);
688
689 /**
690  * Sends bulk get message of a Table Type element to the firmware.
691  *
692  * [in] tfp
693  *   Pointer to session handle
694  *
695  * [in] parms
696  *   Pointer to table get bulk parameters
697  *
698  * Returns:
699  *  0 on Success else internal Truflow error
700  */
701 int tf_msg_bulk_get_tbl_entry(struct tf *tfp,
702                               enum tf_dir dir,
703                               uint16_t hcapi_type,
704                               uint32_t starting_idx,
705                               uint16_t num_entries,
706                               uint16_t entry_sz_in_bytes,
707                               uint64_t physical_mem_addr);
708
709 /**
710  * Sends Set message of a IF Table Type element to the firmware.
711  *
712  * [in] tfp
713  *   Pointer to session handle
714  *
715  * [in] parms
716  *   Pointer to IF table set parameters
717  *
718  * Returns:
719  *  0 on Success else internal Truflow error
720  */
721 int tf_msg_set_if_tbl_entry(struct tf *tfp,
722                             struct tf_if_tbl_set_parms *params);
723
724 /**
725  * Sends get message of a IF Table Type element to the firmware.
726  *
727  * [in] tfp
728  *   Pointer to session handle
729  *
730  * [in] parms
731  *   Pointer to IF table get parameters
732  *
733  * Returns:
734  *  0 on Success else internal Truflow error
735  */
736 int tf_msg_get_if_tbl_entry(struct tf *tfp,
737                             struct tf_if_tbl_get_parms *params);
738
739 #endif  /* _TF_MSG_H_ */