net/tap: fix to populate FDs in secondary process
[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  * [out] sram_profile
162  *   Pointer to the sram profile
163  *
164  * Returns:
165  *   0 on Success else internal Truflow error
166  */
167 int tf_msg_session_resc_qcaps(struct tf *tfp,
168                               struct tf_dev_info *dev,
169                               enum tf_dir dir,
170                               uint16_t size,
171                               struct tf_rm_resc_req_entry *query,
172                               enum tf_rm_resc_resv_strategy *resv_strategy,
173                               uint8_t *sram_profile);
174
175 /**
176  * Sends session HW resource allocation request to TF Firmware
177  *
178  * [in] tfp
179  *   Pointer to TF handle
180  *
181  * [in] dir
182  *   Receive or Transmit direction
183  *
184  * [in] size
185  *   Number of elements in the req and resv arrays
186  *
187  * [in] req
188  *   Pointer to an array of request elements
189  *
190  * [in] resv
191  *   Pointer to an array of reserved elements
192  *
193  * Returns:
194  *   0 on Success else internal Truflow error
195  */
196 int tf_msg_session_resc_alloc(struct tf *tfp,
197                               struct tf_dev_info *dev,
198                               enum tf_dir dir,
199                               uint16_t size,
200                               struct tf_rm_resc_req_entry *request,
201                               struct tf_rm_resc_entry *resv);
202
203 /**
204  * Sends session HW resource allocation request to TF Firmware
205  *
206  * [in] tfp
207  *   Pointer to TF handle
208  *
209  * [in] dir
210  *   Receive or Transmit direction
211  *
212  * [in] size
213  *   Number of elements in the req and resv arrays
214  *
215  * [in] req
216  *   Pointer to an array of request elements
217  *
218  * [in] resv
219  *   Pointer to an array of reserved elements
220  *
221  * Returns:
222  *   0 on Success else internal Truflow error
223  */
224 int tf_msg_session_resc_info(struct tf *tfp,
225                               struct tf_dev_info *dev,
226                               enum tf_dir dir,
227                               uint16_t size,
228                               struct tf_rm_resc_req_entry *request,
229                               struct tf_rm_resc_entry *resv);
230
231 /**
232  * Sends session resource flush request to TF Firmware
233  *
234  * [in] tfp
235  *   Pointer to TF handle
236  *
237  * [in] dir
238  *   Receive or Transmit direction
239  *
240  * [in] size
241  *   Number of elements in the req and resv arrays
242  *
243  * [in] resv
244  *   Pointer to an array of reserved elements that needs to be flushed
245  *
246  * Returns:
247  *   0 on Success else internal Truflow error
248  */
249 int tf_msg_session_resc_flush(struct tf *tfp,
250                               enum tf_dir dir,
251                               uint16_t size,
252                               struct tf_rm_resc_entry *resv);
253 /**
254  * Sends EM internal insert request to Firmware
255  *
256  * [in] tfp
257  *   Pointer to TF handle
258  *
259  * [in] params
260  *   Pointer to em insert parameter list
261  *
262  * [in] rptr_index
263  *   Record ptr index
264  *
265  * [in] rptr_entry
266  *   Record ptr entry
267  *
268  * [in] num_of_entries
269  *   Number of entries to insert
270  *
271  * Returns:
272  *   0 on Success else internal Truflow error
273  */
274 int tf_msg_insert_em_internal_entry(struct tf *tfp,
275                                     struct tf_insert_em_entry_parms *params,
276                                     uint16_t *rptr_index,
277                                     uint8_t *rptr_entry,
278                                     uint8_t *num_of_entries);
279 /**
280  * Sends EM hash internal insert request to Firmware
281  *
282  * [in] tfp
283  *   Pointer to TF handle
284  *
285  * [in] params
286  *   Pointer to em insert parameter list
287  *
288  * [in] key0_hash
289  *      CRC32 hash of key
290  *
291  * [in] key1_hash
292  *      Lookup3 hash of key
293  *
294  * [in] rptr_index
295  *   Record ptr index
296  *
297  * [in] rptr_entry
298  *   Record ptr entry
299  *
300  * [in] num_of_entries
301  *   Number of entries to insert
302  *
303  * Returns:
304  *   0 on Success else internal Truflow error
305  */
306 int
307 tf_msg_hash_insert_em_internal_entry(struct tf *tfp,
308                                 struct tf_insert_em_entry_parms *em_parms,
309                                 uint32_t key0_hash,
310                                 uint32_t key1_hash,
311                                 uint16_t *rptr_index,
312                                 uint8_t *rptr_entry,
313                                 uint8_t *num_of_entries);
314 /**
315  * Sends EM internal delete request to Firmware
316  *
317  * [in] tfp
318  *   Pointer to TF handle
319  *
320  * [in] em_parms
321  *   Pointer to em delete parameters
322  *
323  * Returns:
324  *   0 on Success else internal Truflow error
325  */
326 int tf_msg_delete_em_entry(struct tf *tfp,
327                            struct tf_delete_em_entry_parms *em_parms);
328
329 /**
330  * Sends EM internal move request to Firmware
331  *
332  * [in] tfp
333  *   Pointer to TF handle
334  *
335  * [in] em_parms
336  *   Pointer to em move parameters
337  *
338  * Returns:
339  *   0 on Success else internal Truflow error
340  */
341 int tf_msg_move_em_entry(struct tf *tfp,
342                          struct tf_move_em_entry_parms *em_parms);
343
344 /**
345  * Sends Ext EM mem allocation request to Firmware
346  *
347  * [in] tfp
348  *   Pointer to TF handle
349  *
350  * [in] tbl
351  *   memory allocation details
352  *
353  * [out] dma_addr
354  *   memory address
355  *
356  * [out] page_lvl
357  *   page level
358  *
359  * [out] page_size
360  *   page size
361  *
362  * Returns:
363  *   0 on Success else internal Truflow error
364  */
365 int tf_msg_ext_em_ctxt_mem_alloc(struct tf *tfp,
366                         struct hcapi_cfa_em_table *tbl,
367                         uint64_t *dma_addr,
368                         uint32_t *page_lvl,
369                         uint32_t *page_size);
370
371 /**
372  * Sends Ext EM mem allocation request to Firmware
373  *
374  * [in] tfp
375  *   Pointer to TF handle
376  *
377  * [in] mem_size_k
378  *   memory size in KB
379  *
380  * [in] page_dir
381  *   Pointer to the PBL or PDL depending on number of levels
382  *
383  * [in] page_level
384  *   PBL indirect levels
385  *
386  * [in] page_size
387  *   page size
388  *
389  * Returns:
390  *   0 on Success else internal Truflow error
391  */
392 int tf_msg_ext_em_ctxt_mem_free(struct tf *tfp,
393                                 uint32_t mem_size_k,
394                                 uint64_t dma_addr,
395                                 uint8_t page_level,
396                                 uint8_t page_size);
397
398 /**
399  * Sends EM mem register request to Firmware
400  *
401  * [in] tfp
402  *   Pointer to TF handle
403  *
404  * [in] page_lvl
405  *   Page level
406  *
407  * [in] page_size
408  *   Page size
409  *
410  * [in] dma_addr
411  *   DMA Address for the memory page
412  *
413  * [in] ctx_id
414  *   Context id
415  *
416  * Returns:
417  *   0 on Success else internal Truflow error
418  */
419 int tf_msg_em_mem_rgtr(struct tf *tfp,
420                        int page_lvl,
421                        int page_size,
422                        uint64_t dma_addr,
423                        uint16_t *ctx_id);
424
425 /**
426  * Sends EM mem unregister request to Firmware
427  *
428  * [in] tfp
429  *   Pointer to TF handle
430  *
431  * [in] ctx_id
432  *   Context id
433  *
434  * Returns:
435  *   0 on Success else internal Truflow error
436  */
437 int tf_msg_em_mem_unrgtr(struct tf *tfp,
438                          uint16_t *ctx_id);
439
440 /**
441  * Sends EM qcaps request to Firmware
442  *
443  * [in] tfp
444  *   Pointer to TF handle
445  *
446  * [in] dir
447  *   Receive or Transmit direction
448  *
449  * [in] em_caps
450  *   Pointer to EM capabilities
451  *
452  * Returns:
453  *   0 on Success else internal Truflow error
454  */
455 int tf_msg_em_qcaps(struct tf *tfp,
456                     int dir,
457                     struct tf_em_caps *em_caps);
458
459 /**
460  * Sends EM config request to Firmware
461  *
462  * [in] tfp
463  *   Pointer to TF handle
464  *
465  * [in] num_entries
466  *   EM Table, key 0, number of entries to configure
467  *
468  * [in] key0_ctx_id
469  *   EM Table, Key 0 context id
470  *
471  * [in] key1_ctx_id
472  *   EM Table, Key 1 context id
473  *
474  * [in] record_ctx_id
475  *   EM Table, Record context id
476  *
477  * [in] efc_ctx_id
478  *   EM Table, EFC Table context id
479  *
480  * [in] flush_interval
481  *   Flush pending HW cached flows every 1/10th of value set in
482  *   seconds, both idle and active flows are flushed from the HW
483  *   cache. If set to 0, this feature will be disabled.
484  *
485  * [in] dir
486  *   Receive or Transmit direction
487  *
488  * Returns:
489  *   0 on Success else internal Truflow error
490  */
491 int tf_msg_em_cfg(struct tf *tfp,
492                   uint32_t num_entries,
493                   uint16_t key0_ctx_id,
494                   uint16_t key1_ctx_id,
495                   uint16_t record_ctx_id,
496                   uint16_t efc_ctx_id,
497                   uint8_t flush_interval,
498                   int dir);
499
500 /**
501  * Sends Ext EM config request to Firmware
502  *
503  * [in] tfp
504  *   Pointer to TF handle
505  *
506  * [in] fw_se_id
507  *   FW session id
508  *
509  * [in] tbl_scope_cb
510  *   Table scope parameters
511  *
512  * [in] st_buckets
513  *   static bucket size
514  *
515  * [in] flush_interval
516  *   Flush pending HW cached flows every 1/10th of value set in
517  *   seconds, both idle and active flows are flushed from the HW
518  *   cache. If set to 0, this feature will be disabled.
519  *
520  * [in] dir
521  *   Receive or Transmit direction
522  *
523  * Returns:
524  *   0 on Success else internal Truflow error
525  */
526 int tf_msg_ext_em_cfg(struct tf *tfp,
527                       struct tf_tbl_scope_cb *tbl_scope_cb,
528                       uint32_t st_buckets,
529                       uint8_t flush_interval,
530                       enum tf_dir dir);
531
532 /**
533  * Sends EM operation request to Firmware
534  *
535  * [in] tfp
536  *   Pointer to TF handle
537  *
538  * [in] dir
539  *   Receive or Transmit direction
540  *
541  * [in] op
542  *   CFA Operator
543  *
544  * Returns:
545  *   0 on Success else internal Truflow error
546  */
547 int tf_msg_em_op(struct tf *tfp,
548                  int dir,
549                  uint16_t op);
550
551 /**
552  * Sends tcam entry 'set' to the Firmware.
553  *
554  * [in] tfp
555  *   Pointer to session handle
556  *
557  * [in] parms
558  *   Pointer to set parameters
559  *
560  * Returns:
561  *  0 on Success else internal Truflow error
562  */
563 int tf_msg_tcam_entry_set(struct tf *tfp,
564                           struct tf_dev_info *dev,
565                           struct tf_tcam_set_parms *parms);
566
567 /**
568  * Sends tcam entry 'get' to the Firmware.
569  *
570  * [in] tfp
571  *   Pointer to session handle
572  *
573  * [in] parms
574  *   Pointer to get parameters
575  *
576  * Returns:
577  *  0 on Success else internal Truflow error
578  */
579 int tf_msg_tcam_entry_get(struct tf *tfp,
580                           struct tf_dev_info *dev,
581                           struct tf_tcam_get_parms *parms);
582
583 /**
584  * Sends tcam entry 'free' to the Firmware.
585  *
586  * [in] tfp
587  *   Pointer to session handle
588  *
589  * [in] parms
590  *   Pointer to free parameters
591  *
592  * Returns:
593  *  0 on Success else internal Truflow error
594  */
595 int tf_msg_tcam_entry_free(struct tf *tfp,
596                            struct tf_dev_info *dev,
597                            struct tf_tcam_free_parms *parms);
598
599 /**
600  * Sends Set message of a Table Type element to the firmware.
601  *
602  * [in] tfp
603  *   Pointer to session handle
604  *
605  * [in] dir
606  *   Direction location of the element to set
607  *
608  * [in] hcapi_type
609  *   Type of the object to set
610  *
611  * [in] size
612  *   Size of the data to set
613  *
614  * [in] data
615  *   Data to set
616  *
617  * [in] index
618  *   Index to set
619  *
620  * Returns:
621  *   0 - Success
622  */
623 int tf_msg_set_tbl_entry(struct tf *tfp,
624                          enum tf_dir dir,
625                          uint16_t hcapi_type,
626                          uint16_t size,
627                          uint8_t *data,
628                          uint32_t index);
629
630 /**
631  * Sends get message of a Table Type element to the firmware.
632  *
633  * [in] tfp
634  *   Pointer to session handle
635  *
636  * [in] dir
637  *   Direction location of the element to get
638  *
639  * [in] hcapi_type
640  *   Type of the object to get
641  *
642  * [in] size
643  *   Size of the data read
644  *
645  * [in] data
646  *   Data read
647  *
648  * [in] index
649  *   Index to get
650  *
651  * Returns:
652  *   0 - Success
653  */
654 int tf_msg_get_tbl_entry(struct tf *tfp,
655                          enum tf_dir dir,
656                          uint16_t hcapi_type,
657                          uint16_t size,
658                          uint8_t *data,
659                          uint32_t index,
660                          bool clear_on_read);
661
662 /* HWRM Tunneled messages */
663
664 /**
665  * Sends global cfg read request to Firmware
666  *
667  * [in] tfp
668  *   Pointer to TF handle
669  *
670  * [in] params
671  *   Pointer to read parameters
672  *
673  * Returns:
674  *   0 on Success else internal Truflow error
675  */
676 int tf_msg_get_global_cfg(struct tf *tfp,
677                           struct tf_global_cfg_parms *params);
678
679 /**
680  * Sends global cfg update request to Firmware
681  *
682  * [in] tfp
683  *   Pointer to TF handle
684  *
685  * [in] params
686  *   Pointer to write parameters
687  *
688  * Returns:
689  *   0 on Success else internal Truflow error
690  */
691 int tf_msg_set_global_cfg(struct tf *tfp,
692                           struct tf_global_cfg_parms *params);
693
694 /**
695  * Sends bulk get message of a Table Type element to the firmware.
696  *
697  * [in] tfp
698  *   Pointer to session handle
699  *
700  * [in] parms
701  *   Pointer to table get bulk parameters
702  *
703  * Returns:
704  *  0 on Success else internal Truflow error
705  */
706 int tf_msg_bulk_get_tbl_entry(struct tf *tfp,
707                               enum tf_dir dir,
708                               uint16_t hcapi_type,
709                               uint32_t starting_idx,
710                               uint16_t num_entries,
711                               uint16_t entry_sz_in_bytes,
712                               uint64_t physical_mem_addr,
713                               bool clear_on_read);
714
715 /**
716  * Sends Set message of a IF Table Type element to the firmware.
717  *
718  * [in] tfp
719  *   Pointer to session handle
720  *
721  * [in] parms
722  *   Pointer to IF table set parameters
723  *
724  * Returns:
725  *  0 on Success else internal Truflow error
726  */
727 int tf_msg_set_if_tbl_entry(struct tf *tfp,
728                             struct tf_if_tbl_set_parms *params);
729
730 /**
731  * Sends get message of a IF Table Type element to the firmware.
732  *
733  * [in] tfp
734  *   Pointer to session handle
735  *
736  * [in] parms
737  *   Pointer to IF table get parameters
738  *
739  * Returns:
740  *  0 on Success else internal Truflow error
741  */
742 int tf_msg_get_if_tbl_entry(struct tf *tfp,
743                             struct tf_if_tbl_get_parms *params);
744
745 /**
746  * Send get version request to the firmware.
747  *
748  * [in] bp
749  *   Pointer to bnxt handle
750  *
751  * [in] dev
752  *   Pointer to the associated device
753  *
754  * [in/out] parms
755  *   Pointer to the version info parameter
756  *
757  * Returns:
758  *  0 on Success else internal Truflow error
759  */
760 int
761 tf_msg_get_version(struct bnxt *bp,
762                    struct tf_dev_info *dev,
763                    struct tf_get_version_parms *parms);
764 #endif  /* _TF_MSG_H_ */