common/cnxk: support setting BPHY CGX/RPM FEC
[dpdk.git] / drivers / common / cnxk / roc_sso.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2021 Marvell.
3  */
4
5 #ifndef _ROC_SSO_H_
6 #define _ROC_SSO_H_
7
8 struct roc_sso_hwgrp_qos {
9         uint16_t hwgrp;
10         uint8_t xaq_prcnt;
11         uint8_t iaq_prcnt;
12         uint8_t taq_prcnt;
13 };
14
15 struct roc_sso_hws_stats {
16         uint64_t arbitration;
17 };
18
19 struct roc_sso_hwgrp_stats {
20         uint64_t ws_pc;
21         uint64_t ext_pc;
22         uint64_t wa_pc;
23         uint64_t ts_pc;
24         uint64_t ds_pc;
25         uint64_t dq_pc;
26         uint64_t aw_status;
27         uint64_t page_cnt;
28 };
29
30 struct roc_sso {
31         struct plt_pci_device *pci_dev;
32         /* Public data. */
33         uint16_t max_hwgrp;
34         uint16_t max_hws;
35         uint16_t nb_hwgrp;
36         uint8_t nb_hws;
37         uintptr_t lmt_base;
38         /* HW Const. */
39         uint32_t xae_waes;
40         uint32_t xaq_buf_size;
41         uint32_t iue;
42         /* Private data. */
43 #define ROC_SSO_MEM_SZ (16 * 1024)
44         uint8_t reserved[ROC_SSO_MEM_SZ] __plt_cache_aligned;
45 } __plt_cache_aligned;
46
47 static __plt_always_inline void
48 roc_sso_hws_head_wait(uintptr_t tag_op)
49 {
50 #ifdef RTE_ARCH_ARM64
51         uint64_t tag;
52
53         asm volatile(PLT_CPU_FEATURE_PREAMBLE
54                      "          ldr %[tag], [%[tag_op]] \n"
55                      "          tbnz %[tag], 35, done%=         \n"
56                      "          sevl                            \n"
57                      "rty%=:    wfe                             \n"
58                      "          ldr %[tag], [%[tag_op]] \n"
59                      "          tbz %[tag], 35, rty%=           \n"
60                      "done%=:                                   \n"
61                      : [tag] "=&r"(tag)
62                      : [tag_op] "r"(tag_op));
63 #else
64         /* Wait for the SWTAG/SWTAG_FULL operation */
65         while (!(plt_read64(tag_op) & BIT_ULL(35)))
66                 ;
67 #endif
68 }
69
70 /* SSO device initialization */
71 int __roc_api roc_sso_dev_init(struct roc_sso *roc_sso);
72 int __roc_api roc_sso_dev_fini(struct roc_sso *roc_sso);
73
74 /* SSO device configuration */
75 int __roc_api roc_sso_rsrc_init(struct roc_sso *roc_sso, uint8_t nb_hws,
76                                 uint16_t nb_hwgrp);
77 void __roc_api roc_sso_rsrc_fini(struct roc_sso *roc_sso);
78 int __roc_api roc_sso_hwgrp_qos_config(struct roc_sso *roc_sso,
79                                        struct roc_sso_hwgrp_qos *qos,
80                                        uint8_t nb_qos, uint32_t nb_xaq);
81 int __roc_api roc_sso_hwgrp_alloc_xaq(struct roc_sso *roc_sso,
82                                       uint32_t npa_aura_id, uint16_t hwgrps);
83 int __roc_api roc_sso_hwgrp_release_xaq(struct roc_sso *roc_sso,
84                                         uint16_t hwgrps);
85 int __roc_api roc_sso_hwgrp_set_priority(struct roc_sso *roc_sso,
86                                          uint16_t hwgrp, uint8_t weight,
87                                          uint8_t affinity, uint8_t priority);
88 uint64_t __roc_api roc_sso_ns_to_gw(struct roc_sso *roc_sso, uint64_t ns);
89 int __roc_api roc_sso_hws_link(struct roc_sso *roc_sso, uint8_t hws,
90                                uint16_t hwgrp[], uint16_t nb_hwgrp);
91 int __roc_api roc_sso_hws_unlink(struct roc_sso *roc_sso, uint8_t hws,
92                                  uint16_t hwgrp[], uint16_t nb_hwgrp);
93 int __roc_api roc_sso_hwgrp_hws_link_status(struct roc_sso *roc_sso,
94                                             uint8_t hws, uint16_t hwgrp);
95 uintptr_t __roc_api roc_sso_hws_base_get(struct roc_sso *roc_sso, uint8_t hws);
96 uintptr_t __roc_api roc_sso_hwgrp_base_get(struct roc_sso *roc_sso,
97                                            uint16_t hwgrp);
98
99 /* Debug */
100 void __roc_api roc_sso_dump(struct roc_sso *roc_sso, uint8_t nb_hws,
101                             uint16_t hwgrp, FILE *f);
102 int __roc_api roc_sso_hwgrp_stats_get(struct roc_sso *roc_sso, uint8_t hwgrp,
103                                       struct roc_sso_hwgrp_stats *stats);
104 int __roc_api roc_sso_hws_stats_get(struct roc_sso *roc_sso, uint8_t hws,
105                                     struct roc_sso_hws_stats *stats);
106
107 #endif /* _ROC_SSOW_H_ */