15 #ifndef __DPDK_ESP_H__ 16 #define __DPDK_ESP_H__ 24 enum rte_crypto_cipher_algorithm algo;
31 enum rte_crypto_auth_algorithm algo;
53 c->
algo = RTE_CRYPTO_CIPHER_AES_CBC;
58 c->
algo = RTE_CRYPTO_CIPHER_AES_CBC;
63 c->
algo = RTE_CRYPTO_CIPHER_AES_CBC;
68 c->
algo = RTE_CRYPTO_CIPHER_AES_GCM;
75 i->
algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
79 i->
algo = RTE_CRYPTO_AUTH_SHA256_HMAC;
83 i->
algo = RTE_CRYPTO_AUTH_SHA256_HMAC;
87 i->
algo = RTE_CRYPTO_AUTH_SHA384_HMAC;
91 i->
algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
95 i->
algo = RTE_CRYPTO_AUTH_AES_GCM;
118 for (is_outbound = 0; is_outbound < 2; is_outbound++)
134 if (rte_cryptodev_sym_session_free(dev_id, sa_sess->
sess))
139 memset(sa_sess, 0,
sizeof(sa_sess[0]));
150 struct rte_crypto_sym_xform *cipher_xform)
154 case IPSEC_CRYPTO_ALG_NONE:
155 cipher_xform->cipher.algo = RTE_CRYPTO_CIPHER_NULL;
157 case IPSEC_CRYPTO_ALG_AES_CBC_128:
158 case IPSEC_CRYPTO_ALG_AES_CBC_192:
159 case IPSEC_CRYPTO_ALG_AES_CBC_256:
160 cipher_xform->cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
162 case IPSEC_CRYPTO_ALG_AES_GCM_128:
163 cipher_xform->cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
169 cipher_xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
176 struct rte_crypto_sym_xform *auth_xform,
int use_esn)
179 case IPSEC_INTEG_ALG_NONE:
180 auth_xform->auth.algo = RTE_CRYPTO_AUTH_NULL;
181 auth_xform->auth.digest_length = 0;
183 case IPSEC_INTEG_ALG_SHA1_96:
184 auth_xform->auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
185 auth_xform->auth.digest_length = 12;
187 case IPSEC_INTEG_ALG_SHA_256_96:
188 auth_xform->auth.algo = RTE_CRYPTO_AUTH_SHA256_HMAC;
189 auth_xform->auth.digest_length = 12;
191 case IPSEC_INTEG_ALG_SHA_256_128:
192 auth_xform->auth.algo = RTE_CRYPTO_AUTH_SHA256_HMAC;
193 auth_xform->auth.digest_length = 16;
195 case IPSEC_INTEG_ALG_SHA_384_192:
196 auth_xform->auth.algo = RTE_CRYPTO_AUTH_SHA384_HMAC;
197 auth_xform->auth.digest_length = 24;
199 case IPSEC_INTEG_ALG_SHA_512_256:
200 auth_xform->auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
201 auth_xform->auth.digest_length = 32;
203 case IPSEC_INTEG_ALG_AES_GCM_128:
204 auth_xform->auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
205 auth_xform->auth.digest_length = 16;
206 auth_xform->auth.add_auth_data_length = use_esn? 12 : 8;
212 auth_xform->type = RTE_CRYPTO_SYM_XFORM_AUTH;
223 struct rte_crypto_sym_xform cipher_xform = {0};
224 struct rte_crypto_sym_xform auth_xform = {0};
225 struct rte_crypto_sym_xform *xfs;
226 uword key = 0, *data;
229 if (sa->
crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_128)
239 cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
240 cipher_xform.cipher.key.data = sa->
crypto_key;
243 auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
244 auth_xform.auth.key.data = sa->
integ_key;
257 cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
258 auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
259 cipher_xform.next = &auth_xform;
264 cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
265 auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
266 auth_xform.next = &cipher_xform;
277 rte_cryptodev_sym_session_create(cwm->
qp_data[*data].
dev_id, xfs);
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
sll srl srl sll sra u16x4 i
static_always_inline int add_del_sa_sess(u32 sa_index, u8 is_add)
ipsec_integ_alg_t integ_alg
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
#define static_always_inline
#define clib_warning(format, args...)
dpdk_esp_integ_alg_t * esp_integ_algs
static_always_inline int create_sym_sess(ipsec_sa_t *sa, crypto_sa_session_t *sa_sess, u8 is_outbound)
dpdk_esp_crypto_alg_t * esp_crypto_algs
static_always_inline int translate_crypto_algo(ipsec_crypto_alg_t crypto_algo, struct rte_crypto_sym_xform *cipher_xform)
dpdk_crypto_main_t dpdk_crypto_main
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
uword os_get_cpu_number(void)
dpdk_esp_main_t dpdk_esp_main
#define clib_memcpy(a, b, c)
static_always_inline void dpdk_esp_init()
enum rte_crypto_auth_algorithm algo
crypto_worker_main_t * workers_main
crypto_qp_data_t * qp_data
crypto_sa_session_t * sa_sess_d[2]
static_always_inline int translate_integ_algo(ipsec_integ_alg_t integ_alg, struct rte_crypto_sym_xform *auth_xform, int use_esn)
ipsec_crypto_alg_t crypto_alg
static u32 vlib_num_workers()
#define vec_foreach(var, vec)
Vector iterator.
enum rte_crypto_cipher_algorithm algo