15 #ifndef __DPDK_ESP_H__ 16 #define __DPDK_ESP_H__ 24 enum rte_crypto_cipher_algorithm algo;
26 enum rte_crypto_aead_algorithm aead_algo;
34 enum rte_crypto_auth_algorithm algo;
56 c->
algo = RTE_CRYPTO_CIPHER_AES_CBC;
61 c->
algo = RTE_CRYPTO_CIPHER_AES_CBC;
66 c->
algo = RTE_CRYPTO_CIPHER_AES_CBC;
72 c->
algo = RTE_CRYPTO_CIPHER_AES_GCM;
82 i->
algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
86 i->
algo = RTE_CRYPTO_AUTH_SHA256_HMAC;
90 i->
algo = RTE_CRYPTO_AUTH_SHA256_HMAC;
94 i->
algo = RTE_CRYPTO_AUTH_SHA384_HMAC;
98 i->
algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
102 i->
algo = RTE_CRYPTO_AUTH_AES_GCM;
109 struct rte_crypto_sym_xform *xform,
u8 use_esn)
113 sizeof (
struct rte_crypto_op) + sizeof (struct rte_crypto_sym_op) +
114 offsetof (dpdk_cop_priv_t, cb);
117 xform->type = RTE_CRYPTO_SYM_XFORM_CIPHER;
121 case IPSEC_CRYPTO_ALG_NONE:
123 xform->cipher.iv.offset = iv_off;
124 xform->cipher.iv.length = 0;
126 xform->cipher.algo = RTE_CRYPTO_CIPHER_NULL;
128 case IPSEC_CRYPTO_ALG_AES_CBC_128:
129 case IPSEC_CRYPTO_ALG_AES_CBC_192:
130 case IPSEC_CRYPTO_ALG_AES_CBC_256:
132 xform->cipher.iv.offset = iv_off;
133 xform->cipher.iv.length = 16;
135 xform->cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
137 case IPSEC_CRYPTO_ALG_AES_GCM_128:
139 xform->cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
141 xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
142 xform->aead.algo = RTE_CRYPTO_AEAD_AES_GCM;
143 xform->aead.iv.offset = iv_off;
144 xform->aead.iv.length = 12;
145 xform->aead.digest_length = 16;
146 xform->aead.aad_length = use_esn ? 12 : 8;
158 struct rte_crypto_sym_xform *auth_xform,
u8 use_esn)
160 auth_xform->type = RTE_CRYPTO_SYM_XFORM_AUTH;
164 case IPSEC_INTEG_ALG_NONE:
165 auth_xform->auth.algo = RTE_CRYPTO_AUTH_NULL;
166 auth_xform->auth.digest_length = 0;
168 case IPSEC_INTEG_ALG_SHA1_96:
169 auth_xform->auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
170 auth_xform->auth.digest_length = 12;
172 case IPSEC_INTEG_ALG_SHA_256_96:
173 auth_xform->auth.algo = RTE_CRYPTO_AUTH_SHA256_HMAC;
174 auth_xform->auth.digest_length = 12;
176 case IPSEC_INTEG_ALG_SHA_256_128:
177 auth_xform->auth.algo = RTE_CRYPTO_AUTH_SHA256_HMAC;
178 auth_xform->auth.digest_length = 16;
180 case IPSEC_INTEG_ALG_SHA_384_192:
181 auth_xform->auth.algo = RTE_CRYPTO_AUTH_SHA384_HMAC;
182 auth_xform->auth.digest_length = 24;
184 case IPSEC_INTEG_ALG_SHA_512_256:
185 auth_xform->auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
186 auth_xform->auth.digest_length = 32;
189 case IPSEC_INTEG_ALG_AES_GCM_128:
190 auth_xform->auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
191 auth_xform->auth.digest_length = 16;
192 auth_xform->auth.add_auth_data_length = use_esn ? 12 : 8;
209 struct rte_crypto_sym_xform cipher_xform = { 0 };
210 struct rte_crypto_sym_xform auth_xform = { 0 };
211 struct rte_crypto_sym_xform *xfs;
212 uword key = 0, *data;
215 i32 socket_id = rte_socket_id ();
219 if (sa->
crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_128)
239 if (sa->
crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_128)
245 cipher_xform.cipher.op =
246 (
enum rte_crypto_cipher_operation) RTE_CRYPTO_AEAD_OP_ENCRYPT;
248 cipher_xform.cipher.op =
249 (
enum rte_crypto_cipher_operation) RTE_CRYPTO_AEAD_OP_DECRYPT;
250 cipher_xform.next =
NULL;
257 cipher_xform.cipher.key.data = sa->
crypto_key;
260 auth_xform.auth.key.data = sa->
integ_key;
265 cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
266 auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
267 cipher_xform.next = &auth_xform;
272 cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
273 auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
274 auth_xform.next = &cipher_xform;
288 rte_cryptodev_sym_session_create (cwm->
qp_data[*data].
dev_id, xfs);
293 rte_cryptodev_sym_session_create (dcm->
sess_h_pools[socket_id]);
316 icb->
cnt = clib_host_to_net_u32 (1);
320 #define __unused __attribute__((unused)) 323 struct rte_crypto_op *cop,
void *session,
324 u32 cipher_off,
u32 cipher_len,
325 u8 * icb __unused,
u32 iv_size __unused,
326 u32 auth_off,
u32 auth_len,
327 u8 * aad __unused,
u32 aad_size __unused,
328 u8 * digest,
u64 digest_paddr,
u32 digest_size __unused)
330 struct rte_crypto_sym_op *sym_cop;
332 sym_cop = (
struct rte_crypto_sym_op *) (cop + 1);
334 sym_cop->m_src = mb0;
335 rte_crypto_op_attach_sym_session (cop, session);
338 sym_cop->cipher.data.offset = cipher_off;
339 sym_cop->cipher.data.length = cipher_len;
341 sym_cop->cipher.iv.data = icb;
342 sym_cop->cipher.iv.phys_addr =
343 cop->phys_addr + (uintptr_t) icb - (uintptr_t) cop;
344 sym_cop->cipher.iv.length = iv_size;
348 sym_cop->auth.aad.data = aad;
349 sym_cop->auth.aad.phys_addr =
350 cop->phys_addr + (uintptr_t) aad - (uintptr_t) cop;
351 sym_cop->auth.aad.length = aad_size;
355 sym_cop->auth.data.offset = auth_off;
356 sym_cop->auth.data.length = auth_len;
359 sym_cop->auth.digest.data = digest;
360 sym_cop->auth.digest.phys_addr = digest_paddr;
361 sym_cop->auth.digest.length = digest_size;
365 sym_cop->aead.data.offset = cipher_off;
366 sym_cop->aead.data.length = cipher_len;
368 sym_cop->aead.aad.data = aad;
369 sym_cop->aead.aad.phys_addr =
370 cop->phys_addr + (uintptr_t) aad - (uintptr_t) cop;
372 sym_cop->aead.digest.data = digest;
373 sym_cop->aead.digest.phys_addr = digest_paddr;
377 sym_cop->cipher.data.offset = cipher_off;
378 sym_cop->cipher.data.length = cipher_len;
380 sym_cop->auth.data.offset = auth_off;
381 sym_cop->auth.data.length = auth_len;
383 sym_cop->auth.digest.data = digest;
384 sym_cop->auth.digest.phys_addr = digest_paddr;
#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
enum rte_crypto_aead_algorithm aead_algo
static_always_inline i32 create_sym_sess(ipsec_sa_t *sa, crypto_sa_session_t *sa_sess, u8 is_outbound)
ipsec_integ_alg_t integ_alg
static u64 clib_cpu_time_now(void)
struct rte_mempool ** sess_pools
dpdk_crypto_main_t dpdk_crypto_main
static_always_inline void dpdk_esp_init()
#define static_always_inline
dpdk_esp_main_t dpdk_esp_main
dpdk_esp_integ_alg_t * esp_integ_algs
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 *xform, u8 use_esn)
static_always_inline void crypto_op_setup(u8 is_aead, struct rte_mbuf *mb0, struct rte_crypto_op *cop, void *session, u32 cipher_off, u32 cipher_len, u8 *icb __unused, u32 iv_size __unused, u32 auth_off, u32 auth_len, u8 *aad __unused, u32 aad_size __unused, u8 *digest, u64 digest_paddr, u32 digest_size __unused)
static_always_inline uword vlib_get_thread_index(void)
#define clib_memcpy(a, b, c)
enum rte_crypto_auth_algorithm algo
static_always_inline int translate_integ_algo(ipsec_integ_alg_t integ_alg, struct rte_crypto_sym_xform *auth_xform, u8 use_esn)
static_always_inline void crypto_set_icb(dpdk_gcm_cnt_blk *icb, u32 salt, u32 seq, u32 seq_hi)
crypto_worker_main_t * workers_main
crypto_qp_data_t * qp_data
static u32 random_u32(u32 *seed)
32-bit random number generator
ipsec_crypto_alg_t crypto_alg
enum rte_crypto_cipher_algorithm algo
struct rte_mempool ** sess_h_pools