1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2021 Marvell.
5 #ifndef __ROC_IE_ON_H__
6 #define __ROC_IE_ON_H__
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
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,
24 #define ROC_IE_ON_INB_RPTR_HDR 0x8
27 ROC_IE_ON_SA_ENC_NULL = 0,
28 ROC_IE_ON_SA_ENC_DES_CBC = 1,
29 ROC_IE_ON_SA_ENC_3DES_CBC = 2,
30 ROC_IE_ON_SA_ENC_AES_CBC = 3,
31 ROC_IE_ON_SA_ENC_AES_CTR = 4,
32 ROC_IE_ON_SA_ENC_AES_GCM = 5,
33 ROC_IE_ON_SA_ENC_AES_CCM = 6,
37 ROC_IE_ON_SA_AUTH_NULL = 0,
38 ROC_IE_ON_SA_AUTH_MD5 = 1,
39 ROC_IE_ON_SA_AUTH_SHA1 = 2,
40 ROC_IE_ON_SA_AUTH_SHA2_224 = 3,
41 ROC_IE_ON_SA_AUTH_SHA2_256 = 4,
42 ROC_IE_ON_SA_AUTH_SHA2_384 = 5,
43 ROC_IE_ON_SA_AUTH_SHA2_512 = 6,
44 ROC_IE_ON_SA_AUTH_AES_GMAC = 7,
45 ROC_IE_ON_SA_AUTH_AES_XCBC_128 = 8,
49 ROC_IE_ON_SA_FRAG_POST = 0,
50 ROC_IE_ON_SA_FRAG_PRE = 1,
54 ROC_IE_ON_SA_ENCAP_NONE = 0,
55 ROC_IE_ON_SA_ENCAP_UDP = 1,
58 struct roc_ie_on_outb_hdr {
64 union roc_ie_on_bit_perfect_iv {
74 struct roc_ie_on_traffic_selector {
89 struct roc_ie_on_ip_template {
104 union roc_on_ipsec_outb_param1 {
107 uint16_t frag_num : 4;
108 uint16_t rsvd_4_6 : 3;
109 uint16_t gre_select : 1;
112 uint16_t min_frag_size : 1;
113 uint16_t per_pkt_iv : 1;
114 uint16_t tfc_pad_enable : 1;
115 uint16_t tfc_dummy_pkt : 1;
116 uint16_t rfc_or_override_mode : 1;
117 uint16_t custom_hdr_or_p99 : 1;
121 union roc_on_ipsec_inb_param2 {
124 uint16_t rsvd_0_10 : 11;
125 uint16_t gre_select : 1;
127 uint16_t udp_cksum : 1;
128 uint16_t ctx_addr_sel : 1;
129 uint16_t custom_hdr_or_p99 : 1;
133 struct roc_ie_on_sa_ctl {
135 uint64_t exp_proto_inter_frag : 8;
136 uint64_t copy_df : 1;
137 uint64_t frag_type : 1;
138 uint64_t explicit_iv_en : 1;
140 uint64_t rsvd_45_44 : 2;
141 uint64_t encap_type : 2;
142 uint64_t enc_type : 3;
143 uint64_t rsvd_48 : 1;
144 uint64_t auth_type : 4;
146 uint64_t direction : 1;
147 uint64_t outer_ip_ver : 1;
148 uint64_t inner_ip_ver : 1;
149 uint64_t ipsec_mode : 1;
150 uint64_t ipsec_proto : 1;
151 uint64_t aes_key_len : 2;
154 struct roc_ie_on_common_sa {
156 struct roc_ie_on_sa_ctl ctl;
159 uint8_t cipher_key[32];
162 union roc_ie_on_bit_perfect_iv iv;
169 struct roc_ie_on_outb_sa {
171 struct roc_ie_on_common_sa common_sa;
176 struct roc_ie_on_ip_template template;
179 uint8_t hmac_key[24];
181 struct roc_ie_on_ip_template template;
184 uint8_t hmac_key[64];
186 struct roc_ie_on_ip_template template;
191 struct roc_ie_on_inb_sa {
193 struct roc_ie_on_common_sa common_sa;
196 uint8_t udp_encap[8];
201 uint8_t hmac_key[48];
202 struct roc_ie_on_traffic_selector selector;
205 uint8_t hmac_key[64];
207 struct roc_ie_on_traffic_selector selector;
214 /* CN9K IPsec FP opcodes */
215 #define ROC_IE_ONF_MAJOR_OP_PROCESS_OUTBOUND_IPSEC 0x25UL
216 #define ROC_IE_ONF_MAJOR_OP_PROCESS_INBOUND_IPSEC 0x26UL
218 /* Ucode completion codes */
219 #define ROC_IE_ONF_UCC_SUCCESS 0
221 struct roc_ie_onf_sa_ctl {
223 uint64_t exp_proto_inter_frag : 8;
224 uint64_t rsvd_41_40 : 2;
225 /* Disable SPI, SEQ data in RPTR for Inbound inline */
226 uint64_t spi_seq_dis : 1;
228 uint64_t rsvd_44_45 : 2;
229 uint64_t encap_type : 2;
230 uint64_t enc_type : 3;
231 uint64_t rsvd_48 : 1;
232 uint64_t auth_type : 4;
234 uint64_t direction : 1;
235 uint64_t outer_ip_ver : 1;
236 uint64_t inner_ip_ver : 1;
237 uint64_t ipsec_mode : 1;
238 uint64_t ipsec_proto : 1;
239 uint64_t aes_key_len : 2;
242 struct roc_onf_ipsec_outb_sa {
244 struct roc_ie_onf_sa_ctl ctl;
256 uint8_t cipher_key[32];
259 uint8_t hmac_key[48];
262 struct roc_onf_ipsec_inb_sa {
264 struct roc_ie_onf_sa_ctl ctl;
267 uint8_t nonce[4]; /* Only for AES-GCM */
275 uint8_t cipher_key[32];
278 uint8_t hmac_key[48];
281 #define ROC_ONF_IPSEC_INB_MAX_L2_SZ 32UL
282 #define ROC_ONF_IPSEC_OUTB_MAX_L2_SZ 30UL
283 #define ROC_ONF_IPSEC_OUTB_MAX_L2_INFO_SZ (ROC_ONF_IPSEC_OUTB_MAX_L2_SZ + 2)
285 #define ROC_ONF_IPSEC_INB_RES_OFF 80
286 #define ROC_ONF_IPSEC_INB_SPI_SEQ_SZ 16
288 struct roc_onf_ipsec_outb_hdr {
294 #endif /* __ROC_IE_ON_H__ */