1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Intel Corporation
8 #include <rte_rwlock.h>
10 #define IPSEC_MAX_HDR_SIZE 64
11 #define IPSEC_MAX_IV_SIZE 16
12 #define IPSEC_MAX_IV_QWORD (IPSEC_MAX_IV_SIZE / sizeof(uint64_t))
14 /* padding alignment for different algorithms */
16 IPSEC_PAD_DEFAULT = 4,
17 IPSEC_PAD_3DES_CBC = 8,
18 IPSEC_PAD_AES_CBC = IPSEC_MAX_IV_SIZE,
19 IPSEC_PAD_AES_CTR = IPSEC_PAD_DEFAULT,
20 IPSEC_PAD_AES_GCM = IPSEC_PAD_DEFAULT,
21 IPSEC_PAD_NULL = IPSEC_PAD_DEFAULT,
24 /* iv sizes for different algorithms */
26 IPSEC_IV_SIZE_DEFAULT = IPSEC_MAX_IV_SIZE,
27 IPSEC_AES_CTR_IV_SIZE = sizeof(uint64_t),
28 /* TripleDES supports IV size of 32bits or 64bits but he library
29 * only supports 64bits.
31 IPSEC_3DES_IV_SIZE = sizeof(uint64_t),
34 /* these definitions probably has to be in rte_crypto_sym.h */
44 #ifdef __SIZEOF_INT128__
53 #define REPLAY_SQN_NUM 2
54 #define REPLAY_SQN_NEXT(n) ((n) ^ 1)
59 __extension__ uint64_t window[0];
62 /*IPSEC SA supported algorithms */
74 uint64_t type; /* type of given SA */
75 uint64_t udata; /* user defined */
76 uint32_t size; /* size of given sa object */
78 /* sqn calculations related */
83 uint16_t bucket_index_mask;
85 /* template for crypto op fields */
87 union sym_op_ofslen cipher;
88 union sym_op_ofslen auth;
90 /* tx_offload template for tunnel mbuf */
97 uint8_t proto; /* next proto */
103 uint8_t iv_ofs; /* offset for algo-specific IV inside crypto op */
107 /* template for tunnel header */
108 uint8_t hdr[IPSEC_MAX_HDR_SIZE];
111 * sqn and replay window
112 * In case of SA handled by multiple threads *sqn* cacheline
113 * could be shared by multiple cores.
114 * To minimise perfomance impact, we try to locate in a separate
115 * place from other frequently accesed data.
123 uint32_t rdidx; /* read index */
124 uint32_t wridx; /* write index */
125 struct replay_sqn *rsn[REPLAY_SQN_NUM];
129 } __rte_cache_aligned;
132 ipsec_sa_pkt_func_select(const struct rte_ipsec_session *ss,
133 const struct rte_ipsec_sa *sa, struct rte_ipsec_sa_pkt_func *pf);
135 /* inbound processing */
138 esp_inb_pkt_prepare(const struct rte_ipsec_session *ss, struct rte_mbuf *mb[],
139 struct rte_crypto_op *cop[], uint16_t num);
142 esp_inb_tun_pkt_process(const struct rte_ipsec_session *ss,
143 struct rte_mbuf *mb[], uint16_t num);
146 esp_inb_trs_pkt_process(const struct rte_ipsec_session *ss,
147 struct rte_mbuf *mb[], uint16_t num);
149 /* outbound processing */
152 esp_outb_tun_prepare(const struct rte_ipsec_session *ss, struct rte_mbuf *mb[],
153 struct rte_crypto_op *cop[], uint16_t num);
156 esp_outb_trs_prepare(const struct rte_ipsec_session *ss, struct rte_mbuf *mb[],
157 struct rte_crypto_op *cop[], uint16_t num);
160 esp_outb_sqh_process(const struct rte_ipsec_session *ss, struct rte_mbuf *mb[],
164 inline_outb_tun_pkt_process(const struct rte_ipsec_session *ss,
165 struct rte_mbuf *mb[], uint16_t num);
168 inline_outb_trs_pkt_process(const struct rte_ipsec_session *ss,
169 struct rte_mbuf *mb[], uint16_t num);
172 inline_proto_outb_pkt_process(const struct rte_ipsec_session *ss,
173 struct rte_mbuf *mb[], uint16_t num);