15 #ifndef __DPDK_IPSEC_H__
16 #define __DPDK_IPSEC_H__
24 #include <rte_config.h>
25 #include <rte_crypto.h>
26 #include <rte_cryptodev.h>
29 #define always_inline static inline
31 #define always_inline static inline __attribute__ ((__always_inline__))
34 #define DPDK_CRYPTO_N_QUEUE_DESC 2048
35 #define DPDK_CRYPTO_NB_SESS_OBJS 20000
37 #define foreach_dpdk_crypto_input_next \
38 _(DROP, "error-drop") \
39 _(IP4_LOOKUP, "ip4-lookup") \
40 _(IP6_LOOKUP, "ip6-lookup") \
41 _(INTERFACE_OUTPUT, "interface-output") \
42 _(MIDCHAIN, "adj-midchain-tx") \
43 _(DECRYPT4_POST, "dpdk-esp4-decrypt-post") \
44 _(DECRYPT6_POST, "dpdk-esp6-decrypt-post")
48 #define _(f,s) DPDK_CRYPTO_INPUT_NEXT_##f,
54 #define MAX_QP_PER_LCORE 16
77 struct rte_crypto_op **
ops;
87 enum rte_crypto_sym_xform_type
type;
178 { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0 };
191 sizeof (
struct rte_crypto_op) + sizeof (struct rte_crypto_sym_op);
193 return ((op_size + align - 1) & ~(align - 1)) +
sizeof (
dpdk_op_priv_t);
199 const u32 align = 16;
202 offset =
sizeof (
struct rte_crypto_op) + sizeof (struct rte_crypto_sym_op);
231 if (_vec_len (
data->session_by_drv_id_and_sa_index) <= sa_idx)
235 return (sess_by_sa->
dev_mask & (1L << drv_id)) ? sess_by_sa->
session : NULL;
246 struct rte_cryptodev_sym_session *sess;
268 is_aead = ((sa->
crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_128) ||
269 (sa->
crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_192) ||
270 (sa->
crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_256));
275 if (cipher_res == auth_res)
291 ret = rte_mempool_get_bulk (
data->crypto_op, (
void **) ops, n);
294 data->crypto_op_get_failed += ! !ret;
309 rte_mempool_put_bulk (
data->crypto_op, (
void **) ops, n);
330 n_ops = res->
n_ops < n_ops ? res->
n_ops : n_ops;
331 enq = rte_cryptodev_enqueue_burst (res->
dev_id, res->
qp_id,
359 struct rte_crypto_op *op,
void *session,
360 u32 cipher_off,
u32 cipher_len,
361 u32 auth_off,
u32 auth_len,
362 u8 * aad,
u8 * digest,
u64 digest_paddr)
364 struct rte_crypto_sym_op *sym_op;
366 sym_op = (
struct rte_crypto_sym_op *) (op + 1);
369 sym_op->session = session;
373 sym_op->aead.data.offset = cipher_off;
374 sym_op->aead.data.length = cipher_len;
376 sym_op->aead.aad.data = aad;
377 sym_op->aead.aad.phys_addr =
378 op->phys_addr + (uintptr_t) aad - (uintptr_t) op;
380 sym_op->aead.digest.data = digest;
381 sym_op->aead.digest.phys_addr = digest_paddr;
385 sym_op->cipher.data.offset = cipher_off;
386 sym_op->cipher.data.length = cipher_len;
388 sym_op->auth.data.offset = auth_off;
389 sym_op->auth.data.length = auth_len;
391 sym_op->auth.digest.data = digest;
392 sym_op->auth.digest.phys_addr = digest_paddr;