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_PER_PKT_IV BIT(11)
25 #define ROC_IE_ON_INB_RPTR_HDR 0x8
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,
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,
50 ROC_IE_ON_SA_FRAG_POST = 0,
51 ROC_IE_ON_SA_FRAG_PRE = 1,
55 ROC_IE_ON_SA_ENCAP_NONE = 0,
56 ROC_IE_ON_SA_ENCAP_UDP = 1,
59 struct roc_ie_on_outb_hdr {
65 union roc_ie_on_bit_perfect_iv {
75 struct roc_ie_on_traffic_selector {
90 struct roc_ie_on_ip_template {
105 struct roc_ie_on_sa_ctl {
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;
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;
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;
126 struct roc_ie_on_common_sa {
128 struct roc_ie_on_sa_ctl ctl;
131 uint8_t cipher_key[32];
134 union roc_ie_on_bit_perfect_iv iv;
141 struct roc_ie_on_outb_sa {
143 struct roc_ie_on_common_sa common_sa;
148 struct roc_ie_on_ip_template template;
151 uint8_t hmac_key[24];
153 struct roc_ie_on_ip_template template;
156 uint8_t hmac_key[64];
158 struct roc_ie_on_ip_template template;
163 struct roc_ie_on_inb_sa {
165 struct roc_ie_on_common_sa common_sa;
168 uint8_t udp_encap[8];
173 uint8_t hmac_key[48];
174 struct roc_ie_on_traffic_selector selector;
177 uint8_t hmac_key[64];
179 struct roc_ie_on_traffic_selector selector;
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
190 /* Ucode completion codes */
191 #define ROC_IE_ONF_UCC_SUCCESS 0
193 struct roc_ie_onf_sa_ctl {
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;
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;
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;
214 struct roc_onf_ipsec_outb_sa {
216 struct roc_ie_onf_sa_ctl ctl;
228 uint8_t cipher_key[32];
231 uint8_t hmac_key[48];
234 struct roc_onf_ipsec_inb_sa {
236 struct roc_ie_onf_sa_ctl ctl;
239 uint8_t nonce[4]; /* Only for AES-GCM */
247 uint8_t cipher_key[32];
250 uint8_t hmac_key[48];
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)
257 #define ROC_ONF_IPSEC_INB_RES_OFF 80
258 #define ROC_ONF_IPSEC_INB_SPI_SEQ_SZ 16
260 struct roc_onf_ipsec_outb_hdr {
266 #endif /* __ROC_IE_ON_H__ */