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