e258ca51d74102c6387dc22f205daeb4c46b3c7c
[dpdk.git] / drivers / common / cnxk / roc_cpt.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2021 Marvell.
3  */
4
5 #ifndef _ROC_CPT_H_
6 #define _ROC_CPT_H_
7
8 #include "roc_api.h"
9
10 /* Default engine groups */
11 #define ROC_CPT_DFLT_ENG_GRP_SE    0UL
12 #define ROC_CPT_DFLT_ENG_GRP_SE_IE 1UL
13 #define ROC_CPT_DFLT_ENG_GRP_AE    2UL
14
15 #define ROC_CPT_MAX_LFS 64
16
17 struct roc_cpt_lf {
18         /* Input parameters */
19         uint16_t lf_id;
20         uint32_t nb_desc;
21         /* End of Input parameters */
22         struct plt_pci_device *pci_dev;
23         struct dev *dev;
24         struct roc_cpt *roc_cpt;
25         uintptr_t rbase;
26         uintptr_t lmt_base;
27         uint16_t msixoff;
28         uint16_t pf_func;
29         uint64_t *fc_addr;
30         uint64_t io_addr;
31         uint8_t *iq_vaddr;
32 } __plt_cache_aligned;
33
34 struct roc_cpt {
35         struct plt_pci_device *pci_dev;
36         struct roc_cpt_lf *lf[ROC_CPT_MAX_LFS];
37         uint16_t nb_lf;
38         uint16_t nb_lf_avail;
39         uintptr_t lmt_base;
40         /**< CPT device capabilities */
41         union cpt_eng_caps hw_caps[CPT_MAX_ENG_TYPES];
42         uint8_t eng_grp[CPT_MAX_ENG_TYPES];
43
44 #define ROC_CPT_MEM_SZ (6 * 1024)
45         uint8_t reserved[ROC_CPT_MEM_SZ] __plt_cache_aligned;
46 } __plt_cache_aligned;
47
48 struct roc_cpt_rxc_time_cfg {
49         uint32_t step;
50         uint16_t active_limit;
51         uint16_t active_thres;
52         uint16_t zombie_limit;
53         uint16_t zombie_thres;
54 };
55
56 int __roc_api roc_cpt_rxc_time_cfg(struct roc_cpt *roc_cpt,
57                                    struct roc_cpt_rxc_time_cfg *cfg);
58 int __roc_api roc_cpt_dev_init(struct roc_cpt *roc_cpt);
59 int __roc_api roc_cpt_dev_fini(struct roc_cpt *roc_cpt);
60 int __roc_api roc_cpt_eng_grp_add(struct roc_cpt *roc_cpt,
61                                   enum cpt_eng_type eng_type);
62 int __roc_api roc_cpt_dev_configure(struct roc_cpt *roc_cpt, int nb_lf);
63 void __roc_api roc_cpt_dev_clear(struct roc_cpt *roc_cpt);
64 int __roc_api roc_cpt_lf_init(struct roc_cpt *roc_cpt, struct roc_cpt_lf *lf);
65 void __roc_api roc_cpt_lf_fini(struct roc_cpt_lf *lf);
66 void __roc_api roc_cpt_iq_disable(struct roc_cpt_lf *lf);
67 #endif /* _ROC_CPT_H_ */