xref: /dpdk/drivers/common/cnxk/roc_sso.h (revision 62afdd8d493d8f563c053a4afccb3c5acd1acf54)
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 #include "hw/ssow.h"
9 
10 #define ROC_SSO_AW_PER_LMT_LINE_LOG2 3
11 #define ROC_SSO_MAX_HWGRP_PER_PF     256
12 
13 struct roc_sso_hwgrp_qos {
14 	uint16_t hwgrp;
15 	uint8_t xaq_prcnt;
16 	uint8_t iaq_prcnt;
17 	uint8_t taq_prcnt;
18 };
19 
20 struct roc_sso_hwgrp_stash {
21 	uint16_t hwgrp;
22 	uint8_t stash_offset;
23 	uint8_t stash_count;
24 };
25 
26 struct roc_sso_hws_stats {
27 	uint64_t arbitration;
28 };
29 
30 struct roc_sso_hwgrp_stats {
31 	uint64_t ws_pc;
32 	uint64_t ext_pc;
33 	uint64_t wa_pc;
34 	uint64_t ts_pc;
35 	uint64_t ds_pc;
36 	uint64_t dq_pc;
37 	uint64_t aw_status;
38 	uint64_t page_cnt;
39 };
40 
41 struct roc_sso_xaq_data {
42 	uint32_t nb_xaq;
43 	uint32_t nb_xae;
44 	uint32_t xaq_lmt;
45 	uint64_t aura_handle;
46 	void *fc;
47 	void *mem;
48 };
49 
50 struct roc_sso_agq_data {
51 	uint8_t tt;
52 	uint8_t cnt_ena;
53 	uint8_t xqe_type;
54 	uint16_t stag;
55 	uint32_t tag;
56 	uint32_t vwqe_max_sz_exp;
57 	uint64_t vwqe_wait_tmo;
58 	uint64_t vwqe_aura;
59 };
60 
61 struct roc_sso {
62 	struct plt_pci_device *pci_dev;
63 	/* Public data. */
64 	uint16_t max_hwgrp;
65 	uint16_t max_hws;
66 	uint16_t nb_hwgrp;
67 	uint8_t nb_hws;
68 	uintptr_t lmt_base;
69 	struct roc_sso_xaq_data xaq;
70 	/* HW Const. */
71 	struct sso_feat_info feat;
72 	/* Private data. */
73 #define ROC_SSO_MEM_SZ (16 * 1024)
74 	uint8_t reserved[ROC_SSO_MEM_SZ] __plt_cache_aligned;
75 } __plt_cache_aligned;
76 
77 /* SSO device initialization */
78 int __roc_api roc_sso_dev_init(struct roc_sso *roc_sso);
79 int __roc_api roc_sso_dev_fini(struct roc_sso *roc_sso);
80 
81 /* SSO device configuration */
82 int __roc_api roc_sso_rsrc_init(struct roc_sso *roc_sso, uint8_t nb_hws, uint16_t nb_hwgrp,
83 				uint16_t nb_tim_lfs);
84 void __roc_api roc_sso_rsrc_fini(struct roc_sso *roc_sso);
85 int __roc_api roc_sso_hwgrp_qos_config(struct roc_sso *roc_sso,
86 				       struct roc_sso_hwgrp_qos *qos,
87 				       uint16_t nb_qos);
88 int __roc_api roc_sso_hwgrp_alloc_xaq(struct roc_sso *roc_sso,
89 				      uint32_t npa_aura_id, uint16_t hwgrps);
90 int __roc_api roc_sso_hwgrp_release_xaq(struct roc_sso *roc_sso,
91 					uint16_t hwgrps);
92 int __roc_api roc_sso_hwgrp_set_priority(struct roc_sso *roc_sso,
93 					 uint16_t hwgrp, uint8_t weight,
94 					 uint8_t affinity, uint8_t priority);
95 uint64_t __roc_api roc_sso_ns_to_gw(uint64_t base, uint64_t ns);
96 int __roc_api roc_sso_hws_link(struct roc_sso *roc_sso, uint8_t hws, uint16_t hwgrp[],
97 			       uint16_t nb_hwgrp, uint8_t set, bool use_mbox);
98 int __roc_api roc_sso_hws_unlink(struct roc_sso *roc_sso, uint8_t hws, uint16_t hwgrp[],
99 				 uint16_t nb_hwgrp, uint8_t set, bool use_mbox);
100 int __roc_api roc_sso_hwgrp_hws_link_status(struct roc_sso *roc_sso,
101 					    uint8_t hws, uint16_t hwgrp);
102 uintptr_t __roc_api roc_sso_hws_base_get(struct roc_sso *roc_sso, uint8_t hws);
103 uintptr_t __roc_api roc_sso_hwgrp_base_get(struct roc_sso *roc_sso,
104 					   uint16_t hwgrp);
105 int __roc_api roc_sso_hwgrp_init_xaq_aura(struct roc_sso *roc_sso,
106 					  uint32_t nb_xae);
107 int __roc_api roc_sso_hwgrp_free_xaq_aura(struct roc_sso *roc_sso,
108 					  uint16_t nb_hwgrp);
109 int __roc_api roc_sso_hwgrp_stash_config(struct roc_sso *roc_sso,
110 					 struct roc_sso_hwgrp_stash *stash,
111 					 uint16_t nb_stash);
112 void __roc_api roc_sso_hws_gwc_invalidate(struct roc_sso *roc_sso, uint8_t *hws,
113 					  uint8_t nb_hws);
114 int __roc_api roc_sso_hwgrp_agq_alloc(struct roc_sso *roc_sso, uint16_t hwgrp,
115 				      struct roc_sso_agq_data *data);
116 void __roc_api roc_sso_hwgrp_agq_free(struct roc_sso *roc_sso, uint16_t hwgrp, uint32_t agq_id);
117 void __roc_api roc_sso_hwgrp_agq_release(struct roc_sso *roc_sso, uint16_t hwgrp);
118 uint32_t __roc_api roc_sso_hwgrp_agq_from_tag(struct roc_sso *roc_sso, uint16_t hwgrp, uint32_t tag,
119 					      uint8_t xqe_type);
120 
121 /* Utility function */
122 uint16_t __roc_api roc_sso_pf_func_get(void);
123 
124 /* Debug */
125 void __roc_api roc_sso_dump(struct roc_sso *roc_sso, uint8_t nb_hws,
126 			    uint16_t hwgrp, FILE *f);
127 int __roc_api roc_sso_hwgrp_stats_get(struct roc_sso *roc_sso, uint16_t hwgrp,
128 				      struct roc_sso_hwgrp_stats *stats);
129 int __roc_api roc_sso_hws_stats_get(struct roc_sso *roc_sso, uint8_t hws,
130 				    struct roc_sso_hws_stats *stats);
131 
132 #endif /* _ROC_SSOW_H_ */
133