common/cnxk: make IPsec defines common
[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 opcodes */
9 #define ROC_IE_ONL_MAJOR_OP_WRITE_IPSEC_OUTBOUND   0x20
10 #define ROC_IE_ONL_MAJOR_OP_WRITE_IPSEC_INBOUND    0x21
11 #define ROC_IE_ONL_MAJOR_OP_PROCESS_OUTBOUND_IPSEC 0x23
12 #define ROC_IE_ONL_MAJOR_OP_PROCESS_INBOUND_IPSEC  0x24
13
14 /* CN9K IPSEC FP opcodes */
15 #define ROC_IE_ONF_MAJOR_OP_PROCESS_OUTBOUND_IPSEC 0x25UL
16 #define ROC_IE_ONF_MAJOR_OP_PROCESS_INBOUND_IPSEC  0x26UL
17
18 /* Ucode completion codes */
19 #define ROC_IE_ONF_UCC_SUCCESS 0
20
21 enum {
22         ROC_IE_ON_SA_ENC_NULL = 0,
23         ROC_IE_ON_SA_ENC_DES_CBC = 1,
24         ROC_IE_ON_SA_ENC_3DES_CBC = 2,
25         ROC_IE_ON_SA_ENC_AES_CBC = 3,
26         ROC_IE_ON_SA_ENC_AES_CTR = 4,
27         ROC_IE_ON_SA_ENC_AES_GCM = 5,
28         ROC_IE_ON_SA_ENC_AES_CCM = 6,
29 };
30
31 enum {
32         ROC_IE_ON_SA_AUTH_NULL = 0,
33         ROC_IE_ON_SA_AUTH_MD5 = 1,
34         ROC_IE_ON_SA_AUTH_SHA1 = 2,
35         ROC_IE_ON_SA_AUTH_SHA2_224 = 3,
36         ROC_IE_ON_SA_AUTH_SHA2_256 = 4,
37         ROC_IE_ON_SA_AUTH_SHA2_384 = 5,
38         ROC_IE_ON_SA_AUTH_SHA2_512 = 6,
39         ROC_IE_ON_SA_AUTH_AES_GMAC = 7,
40         ROC_IE_ON_SA_AUTH_AES_XCBC_128 = 8,
41 };
42
43 enum {
44         ROC_IE_ON_SA_FRAG_POST = 0,
45         ROC_IE_ON_SA_FRAG_PRE = 1,
46 };
47
48 enum {
49         ROC_IE_ON_SA_ENCAP_NONE = 0,
50         ROC_IE_ON_SA_ENCAP_UDP = 1,
51 };
52
53 struct roc_ie_onf_sa_ctl {
54         uint32_t spi;
55         uint64_t exp_proto_inter_frag : 8;
56         uint64_t rsvd_41_40 : 2;
57         /* Disable SPI, SEQ data in RPTR for Inbound inline */
58         uint64_t spi_seq_dis : 1;
59         uint64_t esn_en : 1;
60         uint64_t rsvd_44_45 : 2;
61         uint64_t encap_type : 2;
62         uint64_t enc_type : 3;
63         uint64_t rsvd_48 : 1;
64         uint64_t auth_type : 4;
65         uint64_t valid : 1;
66         uint64_t direction : 1;
67         uint64_t outer_ip_ver : 1;
68         uint64_t inner_ip_ver : 1;
69         uint64_t ipsec_mode : 1;
70         uint64_t ipsec_proto : 1;
71         uint64_t aes_key_len : 2;
72 };
73
74 struct roc_onf_ipsec_outb_sa {
75         /* w0 */
76         struct roc_ie_onf_sa_ctl ctl;
77
78         /* w1 */
79         uint8_t nonce[4];
80         uint16_t udp_src;
81         uint16_t udp_dst;
82
83         /* w2 */
84         uint32_t ip_src;
85         uint32_t ip_dst;
86
87         /* w3-w6 */
88         uint8_t cipher_key[32];
89
90         /* w7-w12 */
91         uint8_t hmac_key[48];
92 };
93
94 struct roc_onf_ipsec_inb_sa {
95         /* w0 */
96         struct roc_ie_onf_sa_ctl ctl;
97
98         /* w1 */
99         uint8_t nonce[4]; /* Only for AES-GCM */
100         uint32_t unused;
101
102         /* w2 */
103         uint32_t esn_hi;
104         uint32_t esn_low;
105
106         /* w3-w6 */
107         uint8_t cipher_key[32];
108
109         /* w7-w12 */
110         uint8_t hmac_key[48];
111 };
112
113 #define ROC_ONF_IPSEC_INB_MAX_L2_SZ       32UL
114 #define ROC_ONF_IPSEC_OUTB_MAX_L2_SZ      30UL
115 #define ROC_ONF_IPSEC_OUTB_MAX_L2_INFO_SZ (ROC_ONF_IPSEC_OUTB_MAX_L2_SZ + 2)
116
117 #define ROC_ONF_IPSEC_INB_RES_OFF    80
118 #define ROC_ONF_IPSEC_INB_SPI_SEQ_SZ 16
119
120 struct roc_onf_ipsec_outb_hdr {
121         uint32_t ip_id;
122         uint32_t seq;
123         uint8_t iv[16];
124 };
125
126 #endif /* __ROC_IE_ON_H__ */