net/bnxt: add dpool allocator for EM allocation
[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 EM internal move request to Firmware
320  *
321  * [in] tfp
322  *   Pointer to TF handle
323  *
324  * [in] em_parms
325  *   Pointer to em move parameters
326  *
327  * Returns:
328  *   0 on Success else internal Truflow error
329  */
330 int tf_msg_move_em_entry(struct tf *tfp,
331                          struct tf_move_em_entry_parms *em_parms);
332
333 /**
334  * Sends Ext EM mem allocation request to Firmware
335  *
336  * [in] tfp
337  *   Pointer to TF handle
338  *
339  * [in] tbl
340  *   memory allocation details
341  *
342  * [out] dma_addr
343  *   memory address
344  *
345  * [out] page_lvl
346  *   page level
347  *
348  * [out] page_size
349  *   page size
350  *
351  * Returns:
352  *   0 on Success else internal Truflow error
353  */
354 int tf_msg_ext_em_ctxt_mem_alloc(struct tf *tfp,
355                         struct hcapi_cfa_em_table *tbl,
356                         uint64_t *dma_addr,
357                         uint32_t *page_lvl,
358                         uint32_t *page_size);
359
360 /**
361  * Sends Ext EM mem allocation request to Firmware
362  *
363  * [in] tfp
364  *   Pointer to TF handle
365  *
366  * [in] mem_size_k
367  *   memory size in KB
368  *
369  * [in] page_dir
370  *   Pointer to the PBL or PDL depending on number of levels
371  *
372  * [in] page_level
373  *   PBL indirect levels
374  *
375  * [in] page_size
376  *   page size
377  *
378  * Returns:
379  *   0 on Success else internal Truflow error
380  */
381 int tf_msg_ext_em_ctxt_mem_free(struct tf *tfp,
382                                 uint32_t mem_size_k,
383                                 uint64_t dma_addr,
384                                 uint8_t page_level,
385                                 uint8_t page_size);
386
387 /**
388  * Sends EM mem register request to Firmware
389  *
390  * [in] tfp
391  *   Pointer to TF handle
392  *
393  * [in] page_lvl
394  *   Page level
395  *
396  * [in] page_size
397  *   Page size
398  *
399  * [in] dma_addr
400  *   DMA Address for the memory page
401  *
402  * [in] ctx_id
403  *   Context id
404  *
405  * Returns:
406  *   0 on Success else internal Truflow error
407  */
408 int tf_msg_em_mem_rgtr(struct tf *tfp,
409                        int page_lvl,
410                        int page_size,
411                        uint64_t dma_addr,
412                        uint16_t *ctx_id);
413
414 /**
415  * Sends EM mem unregister request to Firmware
416  *
417  * [in] tfp
418  *   Pointer to TF handle
419  *
420  * [in] ctx_id
421  *   Context id
422  *
423  * Returns:
424  *   0 on Success else internal Truflow error
425  */
426 int tf_msg_em_mem_unrgtr(struct tf *tfp,
427                          uint16_t *ctx_id);
428
429 /**
430  * Sends EM qcaps request to Firmware
431  *
432  * [in] tfp
433  *   Pointer to TF handle
434  *
435  * [in] dir
436  *   Receive or Transmit direction
437  *
438  * [in] em_caps
439  *   Pointer to EM capabilities
440  *
441  * Returns:
442  *   0 on Success else internal Truflow error
443  */
444 int tf_msg_em_qcaps(struct tf *tfp,
445                     int dir,
446                     struct tf_em_caps *em_caps);
447
448 /**
449  * Sends EM config request to Firmware
450  *
451  * [in] tfp
452  *   Pointer to TF handle
453  *
454  * [in] num_entries
455  *   EM Table, key 0, number of entries to configure
456  *
457  * [in] key0_ctx_id
458  *   EM Table, Key 0 context id
459  *
460  * [in] key1_ctx_id
461  *   EM Table, Key 1 context id
462  *
463  * [in] record_ctx_id
464  *   EM Table, Record context id
465  *
466  * [in] efc_ctx_id
467  *   EM Table, EFC Table context id
468  *
469  * [in] flush_interval
470  *   Flush pending HW cached flows every 1/10th of value set in
471  *   seconds, both idle and active flows are flushed from the HW
472  *   cache. If set to 0, this feature will be disabled.
473  *
474  * [in] dir
475  *   Receive or Transmit direction
476  *
477  * Returns:
478  *   0 on Success else internal Truflow error
479  */
480 int tf_msg_em_cfg(struct tf *tfp,
481                   uint32_t num_entries,
482                   uint16_t key0_ctx_id,
483                   uint16_t key1_ctx_id,
484                   uint16_t record_ctx_id,
485                   uint16_t efc_ctx_id,
486                   uint8_t flush_interval,
487                   int dir);
488
489 /**
490  * Sends Ext EM config request to Firmware
491  *
492  * [in] tfp
493  *   Pointer to TF handle
494  *
495  * [in] fw_se_id
496  *   FW session id
497  *
498  * [in] tbl_scope_cb
499  *   Table scope parameters
500  *
501  * [in] st_buckets
502  *   static bucket size
503  *
504  * [in] flush_interval
505  *   Flush pending HW cached flows every 1/10th of value set in
506  *   seconds, both idle and active flows are flushed from the HW
507  *   cache. If set to 0, this feature will be disabled.
508  *
509  * [in] dir
510  *   Receive or Transmit direction
511  *
512  * Returns:
513  *   0 on Success else internal Truflow error
514  */
515 int tf_msg_ext_em_cfg(struct tf *tfp,
516                       struct tf_tbl_scope_cb *tbl_scope_cb,
517                       uint32_t st_buckets,
518                       uint8_t flush_interval,
519                       enum tf_dir dir);
520
521 /**
522  * Sends EM operation request to Firmware
523  *
524  * [in] tfp
525  *   Pointer to TF handle
526  *
527  * [in] dir
528  *   Receive or Transmit direction
529  *
530  * [in] op
531  *   CFA Operator
532  *
533  * Returns:
534  *   0 on Success else internal Truflow error
535  */
536 int tf_msg_em_op(struct tf *tfp,
537                  int dir,
538                  uint16_t op);
539
540 /**
541  * Sends tcam entry 'set' to the Firmware.
542  *
543  * [in] tfp
544  *   Pointer to session handle
545  *
546  * [in] parms
547  *   Pointer to set parameters
548  *
549  * Returns:
550  *  0 on Success else internal Truflow error
551  */
552 int tf_msg_tcam_entry_set(struct tf *tfp,
553                           struct tf_dev_info *dev,
554                           struct tf_tcam_set_parms *parms);
555
556 /**
557  * Sends tcam entry 'get' to the Firmware.
558  *
559  * [in] tfp
560  *   Pointer to session handle
561  *
562  * [in] parms
563  *   Pointer to get parameters
564  *
565  * Returns:
566  *  0 on Success else internal Truflow error
567  */
568 int tf_msg_tcam_entry_get(struct tf *tfp,
569                           struct tf_dev_info *dev,
570                           struct tf_tcam_get_parms *parms);
571
572 /**
573  * Sends tcam entry 'free' to the Firmware.
574  *
575  * [in] tfp
576  *   Pointer to session handle
577  *
578  * [in] parms
579  *   Pointer to free parameters
580  *
581  * Returns:
582  *  0 on Success else internal Truflow error
583  */
584 int tf_msg_tcam_entry_free(struct tf *tfp,
585                            struct tf_dev_info *dev,
586                            struct tf_tcam_free_parms *parms);
587
588 /**
589  * Sends Set message of a Table Type element to the firmware.
590  *
591  * [in] tfp
592  *   Pointer to session handle
593  *
594  * [in] dir
595  *   Direction location of the element to set
596  *
597  * [in] hcapi_type
598  *   Type of the object to set
599  *
600  * [in] size
601  *   Size of the data to set
602  *
603  * [in] data
604  *   Data to set
605  *
606  * [in] index
607  *   Index to set
608  *
609  * Returns:
610  *   0 - Success
611  */
612 int tf_msg_set_tbl_entry(struct tf *tfp,
613                          enum tf_dir dir,
614                          uint16_t hcapi_type,
615                          uint16_t size,
616                          uint8_t *data,
617                          uint32_t index);
618
619 /**
620  * Sends get message of a Table Type element to the firmware.
621  *
622  * [in] tfp
623  *   Pointer to session handle
624  *
625  * [in] dir
626  *   Direction location of the element to get
627  *
628  * [in] hcapi_type
629  *   Type of the object to get
630  *
631  * [in] size
632  *   Size of the data read
633  *
634  * [in] data
635  *   Data read
636  *
637  * [in] index
638  *   Index to get
639  *
640  * Returns:
641  *   0 - Success
642  */
643 int tf_msg_get_tbl_entry(struct tf *tfp,
644                          enum tf_dir dir,
645                          uint16_t hcapi_type,
646                          uint16_t size,
647                          uint8_t *data,
648                          uint32_t index);
649
650 /* HWRM Tunneled messages */
651
652 /**
653  * Sends global cfg read request to Firmware
654  *
655  * [in] tfp
656  *   Pointer to TF handle
657  *
658  * [in] params
659  *   Pointer to read parameters
660  *
661  * Returns:
662  *   0 on Success else internal Truflow error
663  */
664 int tf_msg_get_global_cfg(struct tf *tfp,
665                           struct tf_global_cfg_parms *params);
666
667 /**
668  * Sends global cfg update request to Firmware
669  *
670  * [in] tfp
671  *   Pointer to TF handle
672  *
673  * [in] params
674  *   Pointer to write parameters
675  *
676  * Returns:
677  *   0 on Success else internal Truflow error
678  */
679 int tf_msg_set_global_cfg(struct tf *tfp,
680                           struct tf_global_cfg_parms *params);
681
682 /**
683  * Sends bulk get message of a Table Type element to the firmware.
684  *
685  * [in] tfp
686  *   Pointer to session handle
687  *
688  * [in] parms
689  *   Pointer to table get bulk parameters
690  *
691  * Returns:
692  *  0 on Success else internal Truflow error
693  */
694 int tf_msg_bulk_get_tbl_entry(struct tf *tfp,
695                               enum tf_dir dir,
696                               uint16_t hcapi_type,
697                               uint32_t starting_idx,
698                               uint16_t num_entries,
699                               uint16_t entry_sz_in_bytes,
700                               uint64_t physical_mem_addr);
701
702 /**
703  * Sends Set 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 set parameters
710  *
711  * Returns:
712  *  0 on Success else internal Truflow error
713  */
714 int tf_msg_set_if_tbl_entry(struct tf *tfp,
715                             struct tf_if_tbl_set_parms *params);
716
717 /**
718  * Sends get message of a IF Table Type element to the firmware.
719  *
720  * [in] tfp
721  *   Pointer to session handle
722  *
723  * [in] parms
724  *   Pointer to IF table get parameters
725  *
726  * Returns:
727  *  0 on Success else internal Truflow error
728  */
729 int tf_msg_get_if_tbl_entry(struct tf *tfp,
730                             struct tf_if_tbl_get_parms *params);
731
732 #endif  /* _TF_MSG_H_ */