1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2021 Marvell.
5 #ifndef __ROC_IE_OT_H__
6 #define __ROC_IE_OT_H__
8 /* PKIND to be used for CPT Meta parsing */
9 #define ROC_OT_CPT_META_PKIND 58
11 /* CN10K IPSEC opcodes */
12 #define ROC_IE_OT_MAJOR_OP_PROCESS_OUTBOUND_IPSEC 0x28UL
13 #define ROC_IE_OT_MAJOR_OP_PROCESS_INBOUND_IPSEC 0x29UL
15 enum roc_ie_ot_ucc_ipsec {
16 ROC_IE_OT_UCC_SUCCESS = 0x00,
17 ROC_IE_OT_UCC_SUCCESS_PKT_IP_GOODCSUM = 0x02,
18 ROC_IE_OT_UCC_ERR_SA_INVAL = 0x03,
19 ROC_IE_OT_UCC_SUCCESS_PKT_IP_BADCSUM = 0x04,
20 ROC_IE_OT_UCC_ERR_SA_EXPIRED = 0x05,
21 ROC_IE_OT_UCC_SUCCESS_PKT_L4_GOODCSUM = 0x06,
22 ROC_IE_OT_UCC_ERR_SA_OVERFLOW = 0x07,
23 ROC_IE_OT_UCC_SUCCESS_PKT_L4_BADCSUM = 0x08,
24 ROC_IE_OT_UCC_ERR_SA_ESP_BAD_ALGO = 0x09,
25 ROC_IE_OT_UCC_SUCCESS_PKT_UDPESP_NZCSUM = 0x0a,
26 ROC_IE_OT_UCC_ERR_SA_ESP_BAD_KEYS = 0x0b,
27 ROC_IE_OT_UCC_SUCCESS_SA_SOFTEXP_FIRST = 0x0c,
28 ROC_IE_OT_UCC_ERR_SA_AH_BAD_ALGO = 0x0d,
29 ROC_IE_OT_UCC_SUCCESS_SA_SOFTEXP_AGAIN = 0x0e,
30 ROC_IE_OT_UCC_ERR_SA_AH_BAD_KEYS = 0x0f,
31 ROC_IE_OT_UCC_ERR_SA_BAD_IP = 0x11,
32 ROC_IE_OT_UCC_ERR_SA_BAD_CTX = 0x13,
33 ROC_IE_OT_UCC_ERR_AOP_IPSEC = 0x17,
34 ROC_IE_OT_UCC_ERR_PKT_IP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C_IE_OT_SA_DEFRAG_IN_ORDER = 1,
76 ROC_IE_OT_SA_DEFRAG_IN_REV_ORDER = 2,
80 ROC_IE_OT_SA_IV_SRC_DEFAULT = 0,
81 ROC_IE_OT_SA_IV_SRC_ENC_CTR = 1,
82 ROC_IE_OT_SA_IV_SRC_FROM_SA = 2,
86 ROC_IE_OT_SA_COPY_FROM_SA = 0,
87 ROC_IE_OT_SA_COPY_FROM_INNER_IP_HDR = 1,
91 ROC_IE_OT_SA_INNER_PKT_IP_CSUM_ENABLE = 0,
92 ROC_IE_OT_SA_INNER_PKT_IP_CSUM_DISABLE = 1,
96 ROC_IE_OT_SA_INNER_PKT_L4_CSUM_ENABLE = 0,
97 ROC_IE_OT_SA_INNER_PKT_L4_CSUM_DISABLE = 1,
101 ROC_IE_OT_SA_ENC_NULL = 0,
102 ROC_IE_OT_SA_ENC_3DES_CBC = 2,
103 ROC_IE_OT_SA_ENC_AES_CBC = 3,
104 ROC_IE_OT_SA_ENC_AES_CTR = 4,
105 ROC_IE_OT_SA_ENC_AES_GCM = 5,
106 ROC_IE_OT_SA_ENC_AES_CCM = 6,
110 ROC_IE_OT_SA_AUTH_NULL = 0,
111 ROC_IE_OT_SA_AUTH_SHA1 = 2,
112 ROC_IE_OT_SA_AUTH_SHA2_256 = 4,
113 ROC_IE_OT_SA_AUTH_SHA2_384 = 5,
114 ROC_IE_OT_SA_AUTH_SHA2_512 = 6,
115 ROC_IE_OT_SA_AUTH_AES_GMAC = 7,
116 ROC_IE_OT_SA_AUTH_AES_XCBC_128 = 8,
120 ROC_IE_OT_SA_ENCAP_NONE = 0,
121 ROC_IE_OT_SA_ENCAP_UDP = 1,
122 ROC_IE_OT_SA_ENCAP_TCP = 2,
126 ROC_IE_OT_SA_LIFE_UNIT_OCTETS = 0,
127 ROC_IE_OT_SA_LIFE_UNIT_PKTS = 1,
131 ROC_IE_OT_SA_IP_HDR_VERIFY_DISABLED = 0,
132 ROC_IE_OT_SA_IP_HDR_VERIFY_DST_ADDR = 1,
133 ROC_IE_OT_SA_IP_HDR_VERIFY_SRC_DST_ADDR = 2,
137 ROC_IE_OT_REAS_STS_SUCCESS = 0,
138 ROC_IE_OT_REAS_STS_TIMEOUT = 1,
139 ROC_IE_OT_REAS_STS_EVICT = 2,
140 ROC_IE_OT_REAS_STS_BAD_ORDER = 3,
141 ROC_IE_OT_REAS_STS_TOO_MANY = 4,
142 ROC_IE_OT_REAS_STS_HSH_EVICT = 5,
143 ROC_IE_OT_REAS_STS_OVERLAP = 6,
144 ROC_IE_OT_REAS_STS_ZOMBIE = 7,
145 ROC_IE_OT_REAS_STS_L3P_ERR = 8,
146 ROC_IE_OT_REAS_STS_MAX = 9
148 /* Context units in bytes */
149 #define ROC_CTX_UNIT_8B 8
150 #define ROC_CTX_UNIT_128B 128
151 #define ROC_CTX_MAX_CKEY_LEN 32
152 #define ROC_CTX_MAX_OPAD_IPAD_LEN 128
154 /* Anti reply window size supported */
155 #define ROC_AR_WIN_SIZE_MIN 64
156 #define ROC_AR_WIN_SIZE_MAX 4096
157 #define ROC_LOG_MIN_AR_WIN_SIZE_M1 5
159 /* u64 array size to fit anti replay window bits */
160 #define ROC_AR_WINBITS_SZ \
161 (PLT_ALIGN_CEIL(ROC_AR_WIN_SIZE_MAX, BITS_PER_LONG_LONG) / \
164 /* Common bit fields between inbound and outbound SA */
165 union roc_ot_ipsec_sa_word2 {
169 uint64_t outer_ip_ver : 1;
172 uint64_t protocol : 1;
173 uint64_t aes_key_len : 2;
175 uint64_t enc_type : 3;
176 uint64_t life_unit : 1;
177 uint64_t auth_type : 4;
179 uint64_t encap_type : 2;
183 uint64_t async_mode : 1;
190 PLT_STATIC_ASSERT(sizeof(union roc_ot_ipsec_sa_word2) == 1 * sizeof(uint64_t));
192 union roc_ot_ipsec_outer_ip_hdr {
198 uint8_t src_addr[16];
199 uint8_t dst_addr[16];
203 struct roc_ot_ipsec_inb_ctx_update_reg {
205 uint64_t ar_valid_mask;
210 uint64_t ar_winbits[ROC_AR_WINBITS_SZ];
213 union roc_ot_ipsec_outb_iv {
225 struct roc_ot_ipsec_outb_ctx_update_reg {
234 union roc_ot_ipsec_outb_param1 {
237 uint16_t l4_csum_disable : 1;
238 uint16_t ip_csum_disable : 1;
239 uint16_t ttl_or_hop_limit : 1;
240 uint16_t dummy_pkt : 1;
241 uint16_t rfc_or_override_mode : 1;
242 uint16_t reserved_5_15 : 11;
246 union roc_ot_ipsec_inb_param1 {
249 uint16_t l4_csum_disable : 1;
250 uint16_t ip_csum_disable : 1;
251 uint16_t esp_trailer_disable : 1;
252 uint16_t reserved_3_15 : 13;
256 struct roc_ot_ipsec_inb_sa {
261 uint64_t hard_life_dec : 1;
262 uint64_t soft_life_dec : 1;
263 uint64_t count_glb_octets : 1;
264 uint64_t count_glb_pkts : 1;
265 uint64_t count_mib_bytes : 1;
267 uint64_t count_mib_pkts : 1;
268 uint64_t hw_ctx_off : 7;
270 uint64_t ctx_id : 16;
272 uint64_t orig_pkt_fabs : 1;
273 uint64_t orig_pkt_free : 1;
277 uint64_t et_ovrwr : 1;
278 uint64_t pkt_output : 2;
279 uint64_t pkt_format : 1;
280 uint64_t defrag_opt : 2;
281 uint64_t x2p_dst : 1;
283 uint64_t ctx_push_size : 7;
286 uint64_t ctx_hdr_size : 2;
287 uint64_t aop_valid : 1;
289 uint64_t ctx_size : 4;
297 uint64_t orig_pkt_aura : 20;
299 uint64_t orig_pkt_foff : 8;
300 uint64_t cookie : 32;
310 uint64_t outer_ip_ver : 1;
312 uint64_t ipsec_mode : 1;
313 uint64_t ipsec_protocol : 1;
314 uint64_t aes_key_len : 2;
316 uint64_t enc_type : 3;
317 uint64_t life_unit : 1;
318 uint64_t auth_type : 4;
320 uint64_t encap_type : 2;
321 uint64_t et_ovrwr_ddr_en : 1;
323 uint64_t tport_l4_incr_csum : 1;
324 uint64_t ip_hdr_verify : 2;
328 uint64_t async_mode : 1;
339 uint8_t cipher_key[ROC_CTX_MAX_CKEY_LEN];
354 uint64_t rsvd10 : 32;
355 uint64_t udp_src_port : 16;
356 uint64_t udp_dst_port : 16;
361 /* Word11 - Word14 */
362 union roc_ot_ipsec_outer_ip_hdr outer_hdr;
364 /* Word15 - Word30 */
365 uint8_t hmac_opad_ipad[ROC_CTX_MAX_OPAD_IPAD_LEN];
367 /* Word31 - Word100 */
368 struct roc_ot_ipsec_inb_ctx_update_reg ctx;
371 PLT_STATIC_ASSERT(offsetof(struct roc_ot_ipsec_inb_sa, w1) ==
372 1 * sizeof(uint64_t));
373 PLT_STATIC_ASSERT(offsetof(struct roc_ot_ipsec_inb_sa, w2) ==
374 2 * sizeof(uint64_t));
375 PLT_STATIC_ASSERT(offsetof(struct roc_ot_ipsec_inb_sa, cipher_key) ==
376 4 * sizeof(uint64_t));
377 PLT_STATIC_ASSERT(offsetof(struct roc_ot_ipsec_inb_sa, w8) ==
378 8 * sizeof(uint64_t));
379 PLT_STATIC_ASSERT(offsetof(struct roc_ot_ipsec_inb_sa, w10) ==
380 10 * sizeof(uint64_t));
381 PLT_STATIC_ASSERT(offsetof(struct roc_ot_ipsec_inb_sa, outer_hdr) ==
382 11 * sizeof(uint64_t));
383 PLT_STATIC_ASSERT(offsetof(struct roc_ot_ipsec_inb_sa, hmac_opad_ipad) ==
384 15 * sizeof(uint64_t));
385 PLT_STATIC_ASSERT(offsetof(struct roc_ot_ipsec_inb_sa, ctx) ==
386 31 * sizeof(uint64_t));
388 struct roc_ot_ipsec_outb_sa {
395 uint64_t hard_life_dec : 1;
396 uint64_t soft_life_dec : 1;
397 uint64_t count_glb_octets : 1;
398 uint64_t count_glb_pkts : 1;
399 uint64_t count_mib_bytes : 1;
401 uint64_t count_mib_pkts : 1;
402 uint64_t hw_ctx_off : 7;
406 uint64_t ctx_push_size : 7;
409 uint64_t ctx_hdr_size : 2;
410 uint64_t aop_valid : 1;
412 uint64_t ctx_size : 4;
421 uint64_t cookie : 32;
431 uint64_t outer_ip_ver : 1;
433 uint64_t ipsec_mode : 1;
434 uint64_t ipsec_protocol : 1;
435 uint64_t aes_key_len : 2;
437 uint64_t enc_type : 3;
438 uint64_t life_unit : 1;
439 uint64_t auth_type : 4;
441 uint64_t encap_type : 2;
442 uint64_t ipv4_df_src_or_ipv6_flw_lbl_src : 1;
443 uint64_t dscp_src : 1;
445 uint64_t ipid_gen : 1;
449 uint64_t async_mode : 1;
460 uint8_t cipher_key[ROC_CTX_MAX_CKEY_LEN];
463 union roc_ot_ipsec_outb_iv iv;
469 uint64_t ipv4_df_or_ipv6_flw_lbl : 20;
474 uint64_t udp_dst_port : 16;
476 uint64_t udp_src_port : 16;
481 /* Word11 - Word14 */
482 union roc_ot_ipsec_outer_ip_hdr outer_hdr;
484 /* Word15 - Word30 */
485 uint8_t hmac_opad_ipad[ROC_CTX_MAX_OPAD_IPAD_LEN];
487 /* Word31 - Word36 */
488 struct roc_ot_ipsec_outb_ctx_update_reg ctx;
491 PLT_STATIC_ASSERT(offsetof(struct roc_ot_ipsec_outb_sa, w1) ==
492 1 * sizeof(uint64_t));
493 PLT_STATIC_ASSERT(offsetof(struct roc_ot_ipsec_outb_sa, w2) ==
494 2 * sizeof(uint64_t));
495 PLT_STATIC_ASSERT(offsetof(struct roc_ot_ipsec_outb_sa, cipher_key) ==
496 4 * sizeof(uint64_t));
497 PLT_STATIC_ASSERT(offsetof(struct roc_ot_ipsec_outb_sa, iv) ==
498 8 * sizeof(uint64_t));
499 PLT_STATIC_ASSERT(offsetof(struct roc_ot_ipsec_outb_sa, w10) ==
500 10 * sizeof(uint64_t));
501 PLT_STATIC_ASSERT(offsetof(struct roc_ot_ipsec_outb_sa, outer_hdr) ==
502 11 * sizeof(uint64_t));
503 PLT_STATIC_ASSERT(offsetof(struct roc_ot_ipsec_outb_sa, hmac_opad_ipad) ==
504 15 * sizeof(uint64_t));
505 PLT_STATIC_ASSERT(offsetof(struct roc_ot_ipsec_outb_sa, ctx) ==
506 31 * sizeof(uint64_t));
508 #endif /* __ROC_IE_OT_H__ */