84ebf2d56e80cf51470b1d6f0f9eb52b90760363
[dpdk.git] / drivers / common / cnxk / hw / cpt.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2021 Marvell.
3  */
4
5 #ifndef __CPT_HW_H__
6 #define __CPT_HW_H__
7
8 /* Register offsets */
9
10 #define CPT_COMP_NOT_DONE (0x0ull)
11 #define CPT_COMP_GOOD     (0x1ull)
12 #define CPT_COMP_FAULT    (0x2ull)
13 #define CPT_COMP_SWERR    (0x3ull)
14 #define CPT_COMP_HWERR    (0x4ull)
15 #define CPT_COMP_INSTERR  (0x5ull)
16 #define CPT_COMP_WARN     (0x6ull) /* [CN10K, .) */
17
18 #define CPT_LF_INT_VEC_MISC     (0x0ull)
19 #define CPT_LF_INT_VEC_DONE     (0x1ull)
20 #define CPT_LF_CTL              (0x10ull)
21 #define CPT_LF_DONE_WAIT        (0x30ull)
22 #define CPT_LF_INPROG           (0x40ull)
23 #define CPT_LF_DONE             (0x50ull)
24 #define CPT_LF_DONE_ACK         (0x60ull)
25 #define CPT_LF_DONE_INT_ENA_W1S (0x90ull)
26 #define CPT_LF_DONE_INT_ENA_W1C (0xa0ull)
27 #define CPT_LF_MISC_INT         (0xb0ull)
28 #define CPT_LF_MISC_INT_W1S     (0xc0ull)
29 #define CPT_LF_MISC_INT_ENA_W1S (0xd0ull)
30 #define CPT_LF_MISC_INT_ENA_W1C (0xe0ull)
31 #define CPT_LF_Q_BASE           (0xf0ull)
32 #define CPT_LF_Q_SIZE           (0x100ull)
33 #define CPT_LF_Q_INST_PTR       (0x110ull)
34 #define CPT_LF_Q_GRP_PTR        (0x120ull)
35 #define CPT_LF_NQX(a)           (0x400ull | (uint64_t)(a) << 3)
36 #define CPT_LF_CTX_CTL          (0x500ull)
37 #define CPT_LF_CTX_FLUSH        (0x510ull)
38 #define CPT_LF_CTX_ERR          (0x520ull)
39 #define CPT_LF_CTX_ENC_BYTE_CNT (0x530ull)
40 #define CPT_LF_CTX_ENC_PKT_CNT  (0x540ull)
41 #define CPT_LF_CTX_DEC_BYTE_CNT (0x550ull)
42 #define CPT_LF_CTX_DEC_PKT_CNT  (0x560ull)
43
44 #define CPT_AF_LFX_CTL(a)  (0x27000ull | (uint64_t)(a) << 3)
45 #define CPT_AF_LFX_CTL2(a) (0x29000ull | (uint64_t)(a) << 3)
46
47 /* Structures definitions */
48
49 union cpt_lf_ctl {
50         uint64_t u;
51         struct cpt_lf_ctl_s {
52                 uint64_t ena : 1;
53                 uint64_t fc_ena : 1;
54                 uint64_t fc_up_crossing : 1;
55                 uint64_t reserved_3_3 : 1;
56                 uint64_t fc_hyst_bits : 4;
57                 uint64_t reserved_8_63 : 56;
58         } s;
59 };
60
61 union cpt_lf_ctx_flush {
62         uint64_t u;
63         struct {
64                 uint64_t cptr : 46;
65                 uint64_t inval : 1;
66                 uint64_t res : 1;
67                 uint64_t pf_func : 16;
68         } s;
69 };
70
71 union cpt_lf_inprog {
72         uint64_t u;
73         struct cpt_lf_inprog_s {
74                 uint64_t inflight : 9;
75                 uint64_t reserved_9_15 : 7;
76                 uint64_t eena : 1;
77                 uint64_t grp_drp : 1;
78                 uint64_t reserved_18_30 : 13;
79                 uint64_t grb_partial : 1;
80                 uint64_t grb_cnt : 8;
81                 uint64_t gwb_cnt : 8;
82                 uint64_t reserved_48_63 : 16;
83         } s;
84 };
85
86 union cpt_lf_q_base {
87         uint64_t u;
88         struct cpt_lf_q_base_s {
89                 uint64_t fault : 1;
90                 uint64_t stopped : 1;
91                 uint64_t reserved_2_6 : 5;
92                 uint64_t addr : 46;
93                 uint64_t reserved_53_63 : 11;
94         } s;
95 };
96
97 union cpt_lf_q_size {
98         uint64_t u;
99         struct cpt_lf_q_size_s {
100                 uint64_t size_div40 : 15;
101                 uint64_t reserved_15_63 : 49;
102         } s;
103 };
104
105 union cpt_lf_misc_int {
106         uint64_t u;
107         struct cpt_lf_misc_int_s {
108                 uint64_t reserved_0_0 : 1;
109                 uint64_t nqerr : 1;
110                 uint64_t irde : 1;
111                 uint64_t nwrp : 1;
112                 uint64_t reserved_4_4 : 1;
113                 uint64_t hwerr : 1;
114                 uint64_t fault : 1;
115                 uint64_t reserved_7_63 : 57;
116         } s;
117 };
118
119 union cpt_inst_w4 {
120         uint64_t u64;
121         struct {
122                 uint64_t dlen : 16;
123                 uint64_t param2 : 16;
124                 uint64_t param1 : 16;
125                 uint64_t opcode_major : 8;
126                 uint64_t opcode_minor : 8;
127         } s;
128 };
129
130 union cpt_inst_w7 {
131         uint64_t u64;
132         struct {
133                 uint64_t cptr : 60;
134                 uint64_t ctx_val : 1;
135                 uint64_t egrp : 3;
136         } s;
137 };
138
139 struct cpt_inst_s {
140         union cpt_inst_w0 {
141                 struct {
142                         uint64_t nixtxl : 3;
143                         uint64_t doneint : 1;
144                         uint64_t nixtx_addr : 60;
145                 } s;
146                 uint64_t u64;
147         } w0;
148
149         uint64_t res_addr;
150
151         union cpt_inst_w2 {
152                 struct {
153                         uint64_t tag : 32;
154                         uint64_t tt : 2;
155                         uint64_t grp : 10;
156                         uint64_t reserved_172_175 : 4;
157                         uint64_t rvu_pf_func : 16;
158                 } s;
159                 uint64_t u64;
160         } w2;
161
162         union cpt_inst_w3 {
163                 struct {
164                         uint64_t qord : 1;
165                         uint64_t reserved_194_193 : 2;
166                         uint64_t wqe_ptr : 61;
167                 } s;
168                 uint64_t u64;
169         } w3;
170
171         union cpt_inst_w4 w4;
172
173         uint64_t dptr;
174
175         uint64_t rptr;
176
177         union cpt_inst_w7 w7;
178 };
179
180 union cpt_res_s {
181         struct cpt_cn10k_res_s {
182                 uint64_t compcode : 7;
183                 uint64_t doneint : 1;
184                 uint64_t uc_compcode : 8;
185                 uint64_t rlen : 16;
186                 uint64_t spi : 32;
187
188                 uint64_t esn;
189         } cn10k;
190
191         struct cpt_cn9k_res_s {
192                 uint64_t compcode : 8;
193                 uint64_t uc_compcode : 8;
194                 uint64_t doneint : 1;
195                 uint64_t reserved_17_63 : 47;
196
197                 uint64_t reserved_64_127;
198         } cn9k;
199 };
200
201 /* [CN10K, .) */
202 struct cpt_parse_hdr_s {
203         /* WORD 0 */
204         union {
205                 uint64_t u64;
206                 struct {
207                         uint8_t pad_len : 3;
208                         uint8_t num_frags : 3;
209                         uint8_t pkt_out : 2;
210
211                         uint8_t err_sum : 1;
212                         uint8_t reas_sts : 4;
213                         uint8_t reserved_53 : 1;
214                         uint8_t et_owr : 1;
215                         uint8_t pkt_fmt : 1;
216
217                         uint16_t match_id : 16;
218
219                         uint32_t cookie : 32;
220                 };
221         } w0;
222
223         /* WORD 1 */
224         uint64_t wqe_ptr;
225
226         /* WORD 2 */
227         union {
228                 uint64_t u64;
229                 struct {
230                         uint8_t fi_pad : 3;
231                         uint8_t fi_offset : 5;
232                         uint8_t il3_off;
233                         uint16_t orig_pf_func;
234                         uint16_t reserved_145_160;
235                         uint16_t frag_age;
236                 };
237         } w2;
238
239         /* WORD 3 */
240         union {
241                 uint64_t u64;
242                 struct {
243                         uint32_t spi;
244                         uint16_t reserved_209_224;
245                         uint8_t uc_ccode;
246                         uint8_t hw_ccode;
247                 };
248         } w3;
249
250         /* WORD 4 */
251         union {
252                 uint64_t u64;
253                 uint64_t esn;
254                 uint64_t frag1_wqe_ptr;
255         };
256 };
257
258 union cpt_frag_info {
259         uint16_t info;
260         struct {
261                 uint16_t f_off : 13;
262                 uint16_t f_mf : 1;
263                 uint16_t f_rsv : 2;
264         };
265 };
266
267 struct cpt_frag_info_s {
268         /* WORD 0 */
269         union {
270                 uint64_t u64;
271                 struct {
272                         union cpt_frag_info f3;
273                         union cpt_frag_info f2;
274                         union cpt_frag_info f1;
275                         union cpt_frag_info f0;
276                 };
277         } w0;
278
279         /* WORD 1 */
280         union {
281                 uint64_t u64;
282                 struct {
283                         uint16_t frag_size3;
284                         uint16_t frag_size2;
285                         uint16_t frag_size1;
286                         uint16_t frag_size0;
287                 };
288         } w1;
289 };
290
291 #endif /* __CPT_HW_H__ */