net/mlx5: remove redundant flag in device config
[dpdk.git] / drivers / common / cnxk / roc_ie_on.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2021 Marvell.
3  */
4
5 #ifndef __ROC_IE_ON_H__
6 #define __ROC_IE_ON_H__
7
8 /* CN9K IPsec LA */
9
10 /* CN9K IPsec LA opcodes */
11 #define ROC_IE_ON_MAJOR_OP_WRITE_IPSEC_OUTBOUND   0x20
12 #define ROC_IE_ON_MAJOR_OP_WRITE_IPSEC_INBOUND    0x21
13 #define ROC_IE_ON_MAJOR_OP_PROCESS_OUTBOUND_IPSEC 0x23
14 #define ROC_IE_ON_MAJOR_OP_PROCESS_INBOUND_IPSEC  0x24
15
16 /* Ucode completion codes */
17 enum roc_ie_on_ucc_ipsec {
18         ROC_IE_ON_UCC_SUCCESS = 0,
19         ROC_IE_ON_AUTH_UNSUPPORTED = 0xB0,
20         ROC_IE_ON_ENCRYPT_UNSUPPORTED = 0xB1,
21 };
22
23 /* Helper macros */
24 #define ROC_IE_ON_PER_PKT_IV   BIT(11)
25 #define ROC_IE_ON_INB_RPTR_HDR 0x8
26
27 enum {
28         ROC_IE_ON_SA_ENC_NULL = 0,
29         ROC_IE_ON_SA_ENC_DES_CBC = 1,
30         ROC_IE_ON_SA_ENC_3DES_CBC = 2,
31         ROC_IE_ON_SA_ENC_AES_CBC = 3,
32         ROC_IE_ON_SA_ENC_AES_CTR = 4,
33         ROC_IE_ON_SA_ENC_AES_GCM = 5,
34         ROC_IE_ON_SA_ENC_AES_CCM = 6,
35 };
36
37 enum {
38         ROC_IE_ON_SA_AUTH_NULL = 0,
39         ROC_IE_ON_SA_AUTH_MD5 = 1,
40         ROC_IE_ON_SA_AUTH_SHA1 = 2,
41         ROC_IE_ON_SA_AUTH_SHA2_224 = 3,
42         ROC_IE_ON_SA_AUTH_SHA2_256 = 4,
43         ROC_IE_ON_SA_AUTH_SHA2_384 = 5,
44         ROC_IE_ON_SA_AUTH_SHA2_512 = 6,
45         ROC_IE_ON_SA_AUTH_AES_GMAC = 7,
46         ROC_IE_ON_SA_AUTH_AES_XCBC_128 = 8,
47 };
48
49 enum {
50         ROC_IE_ON_SA_FRAG_POST = 0,
51         ROC_IE_ON_SA_FRAG_PRE = 1,
52 };
53
54 enum {
55         ROC_IE_ON_SA_ENCAP_NONE = 0,
56         ROC_IE_ON_SA_ENCAP_UDP = 1,
57 };
58
59 struct roc_ie_on_outb_hdr {
60         uint32_t ip_id;
61         uint32_t seq;
62         uint8_t iv[16];
63 };
64
65 union roc_ie_on_bit_perfect_iv {
66         uint8_t aes_iv[16];
67         uint8_t des_iv[8];
68         struct {
69                 uint8_t nonce[4];
70                 uint8_t iv[8];
71                 uint8_t counter[4];
72         } gcm;
73 };
74
75 struct roc_ie_on_traffic_selector {
76         uint16_t src_port[2];
77         uint16_t dst_port[2];
78         union {
79                 struct {
80                         uint32_t src_addr[2];
81                         uint32_t dst_addr[2];
82                 } ipv4;
83                 struct {
84                         uint8_t src_addr[32];
85                         uint8_t dst_addr[32];
86                 } ipv6;
87         };
88 };
89
90 struct roc_ie_on_ip_template {
91         union {
92                 struct {
93                         uint8_t ipv4_hdr[20];
94                         uint16_t udp_src;
95                         uint16_t udp_dst;
96                 } ip4;
97                 struct {
98                         uint8_t ipv6_hdr[40];
99                         uint16_t udp_src;
100                         uint16_t udp_dst;
101                 } ip6;
102         };
103 };
104
105 struct roc_ie_on_sa_ctl {
106         uint64_t spi : 32;
107         uint64_t exp_proto_inter_frag : 8;
108         uint64_t copy_df : 1;
109         uint64_t frag_type : 1;
110         uint64_t explicit_iv_en : 1;
111         uint64_t esn_en : 1;
112         uint64_t rsvd_45_44 : 2;
113         uint64_t encap_type : 2;
114         uint64_t enc_type : 3;
115         uint64_t rsvd_48 : 1;
116         uint64_t auth_type : 4;
117         uint64_t valid : 1;
118         uint64_t direction : 1;
119         uint64_t outer_ip_ver : 1;
120         uint64_t inner_ip_ver : 1;
121         uint64_t ipsec_mode : 1;
122         uint64_t ipsec_proto : 1;
123         uint64_t aes_key_len : 2;
124 };
125
126 struct roc_ie_on_common_sa {
127         /* w0 */
128         struct roc_ie_on_sa_ctl ctl;
129
130         /* w1-w4 */
131         uint8_t cipher_key[32];
132
133         /* w5-w6 */
134         union roc_ie_on_bit_perfect_iv iv;
135
136         /* w7 */
137         uint32_t esn_hi;
138         uint32_t esn_low;
139 };
140
141 struct roc_ie_on_outb_sa {
142         /* w0 - w7 */
143         struct roc_ie_on_common_sa common_sa;
144
145         /* w8-w55 */
146         union {
147                 struct {
148                         struct roc_ie_on_ip_template template;
149                 } aes_gcm;
150                 struct {
151                         uint8_t hmac_key[24];
152                         uint8_t unused[24];
153                         struct roc_ie_on_ip_template template;
154                 } sha1;
155                 struct {
156                         uint8_t hmac_key[64];
157                         uint8_t hmac_iv[64];
158                         struct roc_ie_on_ip_template template;
159                 } sha2;
160         };
161 };
162
163 struct roc_ie_on_inb_sa {
164         /* w0 - w7 */
165         struct roc_ie_on_common_sa common_sa;
166
167         /* w8 */
168         uint8_t udp_encap[8];
169
170         /* w9-w33 */
171         union {
172                 struct {
173                         uint8_t hmac_key[48];
174                         struct roc_ie_on_traffic_selector selector;
175                 } sha1_or_gcm;
176                 struct {
177                         uint8_t hmac_key[64];
178                         uint8_t hmac_iv[64];
179                         struct roc_ie_on_traffic_selector selector;
180                 } sha2;
181         };
182 };
183
184 /* CN9K IPsec FP */
185
186 /* CN9K IPsec FP opcodes */
187 #define ROC_IE_ONF_MAJOR_OP_PROCESS_OUTBOUND_IPSEC 0x25UL
188 #define ROC_IE_ONF_MAJOR_OP_PROCESS_INBOUND_IPSEC  0x26UL
189
190 /* Ucode completion codes */
191 #define ROC_IE_ONF_UCC_SUCCESS 0
192
193 struct roc_ie_onf_sa_ctl {
194         uint32_t spi;
195         uint64_t exp_proto_inter_frag : 8;
196         uint64_t rsvd_41_40 : 2;
197         /* Disable SPI, SEQ data in RPTR for Inbound inline */
198         uint64_t spi_seq_dis : 1;
199         uint64_t esn_en : 1;
200         uint64_t rsvd_44_45 : 2;
201         uint64_t encap_type : 2;
202         uint64_t enc_type : 3;
203         uint64_t rsvd_48 : 1;
204         uint64_t auth_type : 4;
205         uint64_t valid : 1;
206         uint64_t direction : 1;
207         uint64_t outer_ip_ver : 1;
208         uint64_t inner_ip_ver : 1;
209         uint64_t ipsec_mode : 1;
210         uint64_t ipsec_proto : 1;
211         uint64_t aes_key_len : 2;
212 };
213
214 struct roc_onf_ipsec_outb_sa {
215         /* w0 */
216         struct roc_ie_onf_sa_ctl ctl;
217
218         /* w1 */
219         uint8_t nonce[4];
220         uint16_t udp_src;
221         uint16_t udp_dst;
222
223         /* w2 */
224         uint32_t ip_src;
225         uint32_t ip_dst;
226
227         /* w3-w6 */
228         uint8_t cipher_key[32];
229
230         /* w7-w12 */
231         uint8_t hmac_key[48];
232 };
233
234 struct roc_onf_ipsec_inb_sa {
235         /* w0 */
236         struct roc_ie_onf_sa_ctl ctl;
237
238         /* w1 */
239         uint8_t nonce[4]; /* Only for AES-GCM */
240         uint32_t unused;
241
242         /* w2 */
243         uint32_t esn_hi;
244         uint32_t esn_low;
245
246         /* w3-w6 */
247         uint8_t cipher_key[32];
248
249         /* w7-w12 */
250         uint8_t hmac_key[48];
251 };
252
253 #define ROC_ONF_IPSEC_INB_MAX_L2_SZ       32UL
254 #define ROC_ONF_IPSEC_OUTB_MAX_L2_SZ      30UL
255 #define ROC_ONF_IPSEC_OUTB_MAX_L2_INFO_SZ (ROC_ONF_IPSEC_OUTB_MAX_L2_SZ + 2)
256
257 #define ROC_ONF_IPSEC_INB_RES_OFF    80
258 #define ROC_ONF_IPSEC_INB_SPI_SEQ_SZ 16
259
260 struct roc_onf_ipsec_outb_hdr {
261         uint32_t ip_id;
262         uint32_t seq;
263         uint8_t iv[16];
264 };
265
266 #endif /* __ROC_IE_ON_H__ */