25 #define DPDK_CRYPTO_NB_SESS_OBJS 20000 26 #define DPDK_CRYPTO_CACHE_SIZE 512 27 #define DPDK_CRYPTO_PRIV_SIZE 128 28 #define DPDK_CRYPTO_N_QUEUE_DESC 1024 29 #define DPDK_CRYPTO_NB_COPS (1024 * 4) 50 for (is_outbound = 0; is_outbound < 2; is_outbound++)
67 ret = (rte_cryptodev_sym_session_free(dev_id, sa_sess->
sess) ==
NULL);
70 ret = rte_cryptodev_sym_session_clear(dev_id, sa_sess->
sess);
73 ret = rte_cryptodev_sym_session_free(sa_sess->
sess);
76 memset(sa_sess, 0,
sizeof(sa_sess[0]));
87 u8 cdev_id,
u16 qp_id,
u8 is_outbound,
u16 * idx)
96 if (qpd->
dev_id == cdev_id && qpd->
qp_id == qp_id &&
116 u8 cdev_id,
u16 qp,
u8 is_outbound,
117 const struct rte_cryptodev_capabilities *cipher_cap,
118 const struct rte_cryptodev_capabilities *auth_cap)
121 uword key = 0, data, *ret;
128 p_key->
is_aead = cipher_cap->sym.xform_type == RTE_CRYPTO_SYM_XFORM_AEAD;
137 data = (
uword) qp_index;
150 struct rte_cryptodev_info *dev_info,
u8 cdev_id,
151 u16 qp,
u8 is_outbound)
153 const struct rte_cryptodev_capabilities *
i, *j;
156 for (i = dev_info->capabilities; i->op != RTE_CRYPTO_OP_TYPE_UNDEFINED; i++)
159 if (i->sym.xform_type == RTE_CRYPTO_SYM_XFORM_AEAD)
161 struct rte_cryptodev_capabilities none = { 0 };
166 none.sym.auth.algo = RTE_CRYPTO_AUTH_NULL;
168 mapped |=
add_mapping (cwm, cdev_id, qp, is_outbound, i, &none);
172 if (i->sym.xform_type != RTE_CRYPTO_SYM_XFORM_CIPHER)
178 for (j = dev_info->capabilities; j->op != RTE_CRYPTO_OP_TYPE_UNDEFINED;
181 if (j->sym.xform_type != RTE_CRYPTO_SYM_XFORM_AUTH)
187 mapped |=
add_mapping (cwm, cdev_id, qp, is_outbound, i, j);
204 for (cdev_id = 0; cdev_id < rte_cryptodev_count (); cdev_id++)
206 struct rte_cryptodev_info cdev_info;
208 rte_cryptodev_info_get (cdev_id, &cdev_info);
211 (cdev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING))
214 n_qs += cdev_info.max_nb_queue_pairs;
217 if (n_qs >= n_req_qs)
226 if (sa->
crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_128)
228 if (sa->
integ_alg != IPSEC_INTEG_ALG_NONE)
230 "crypto-alg aes-gcm-128",
233 sa->
integ_alg = IPSEC_INTEG_ALG_AES_GCM_128;
237 else if (sa->
crypto_alg == IPSEC_CRYPTO_ALG_NONE ||
239 sa->
integ_alg == IPSEC_INTEG_ALG_AES_GCM_128)
241 else if (sa->
integ_alg == IPSEC_INTEG_ALG_NONE)
244 "unsupported integ-alg %U with crypto-alg %U",
258 struct rte_cryptodev_config dev_conf;
259 struct rte_cryptodev_qp_conf qp_conf;
260 struct rte_cryptodev_info cdev_info;
261 struct rte_mempool *rmp;
265 u32 max_sess_size = 0, sess_size;
271 clib_warning (
"not enough Cryptodevs, default to OpenSSL IPsec");
281 fprintf (stdout,
"DPDK Cryptodevs info:\n");
282 fprintf (stdout,
"dev_id\tn_qp\tnb_obj\tcache_size\n");
284 for (dev_id = rte_cryptodev_count () - 1; dev_id >= 0; dev_id--)
286 u16 max_nb_qp, qp = 0;
288 rte_cryptodev_info_get (dev_id, &cdev_info);
291 (cdev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING))
294 max_nb_qp = cdev_info.max_nb_queue_pairs;
310 clib_warning (
"unable to create hash table for worker %u",
317 for (is_outbound = 0; is_outbound < 2 && qp < max_nb_qp;
325 dev_conf.socket_id = rte_cryptodev_socket_id (dev_id);
326 dev_conf.nb_queue_pairs = cdev_info.max_nb_queue_pairs;
331 ret = rte_cryptodev_configure (dev_id, &dev_conf);
339 for (qp = 0; qp < dev_conf.nb_queue_pairs; qp++)
342 ret = rte_cryptodev_queue_pair_setup (dev_id, qp, &qp_conf,
345 ret = rte_cryptodev_queue_pair_setup (dev_id, qp, &qp_conf,
346 dev_conf.socket_id,
NULL);
350 clib_warning (
"cryptodev %u qp %u setup error", dev_id, qp);
357 sess_size = rte_cryptodev_get_private_session_size (dev_id);
358 if (sess_size > max_sess_size)
359 max_sess_size = sess_size;
364 u8 *pool_name =
format (0,
"crypto_op_pool_socket%u%c",
365 dev_conf.socket_id, 0);
367 rmp = rte_crypto_op_pool_create ((
char *) pool_name,
368 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
385 fprintf (stdout,
"%u\t%u\t%u\t%u\n", dev_id, dev_conf.nb_queue_pairs,
399 pool_name =
format (0,
"crypto_sess_h_socket%u%c",
403 rte_cryptodev_get_header_session_size (),
416 pool_name =
format (0,
"crypto_sess_socket%u%c",
460 VLIB_NODE_STATE_POLLING);
469 struct rte_mempool **mp;
477 rte_mempool_free (mp[0]);
490 .name =
"dpdk-ipsec-process",
491 .process_log2_n_stack_bytes = 17,
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
static int add_mapping(crypto_worker_main_t *cwm, u8 cdev_id, u16 qp, u8 is_outbound, const struct rte_cryptodev_capabilities *cipher_cap, const struct rte_cryptodev_capabilities *auth_cap)
#define vec_foreach_index(var, v)
Iterate over vector indices.
#define hash_set(h, key, value)
sll srl srl sll sra u16x4 i
i32(* add_del_sa_sess_cb)(u32 sa_index, u8 is_add)
#define vec_add2_aligned(V, P, N, A)
Add N elements to end of vector V, return pointer to new elements in P.
#define DPDK_CRYPTO_NB_SESS_OBJS
ipsec_integ_alg_t integ_alg
#define DPDK_CRYPTO_PRIV_SIZE
struct rte_mempool ** sess_pools
vlib_node_registration_t dpdk_crypto_input_node
(constructor) VLIB_REGISTER_NODE (dpdk_crypto_input_node)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
#define vec_alloc(V, N)
Allocate space for N more elements (no header, unspecified alignment)
vlib_main_t ** vlib_mains
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
dpdk_crypto_main_t dpdk_crypto_main
static void update_qp_data(crypto_worker_main_t *cwm, u8 cdev_id, u16 qp_id, u8 is_outbound, u16 *idx)
static_always_inline void dpdk_esp_init()
u32 esp_encrypt_next_index
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_error_return(e, args...)
ipsec_main_callbacks_t cb
u8 * format_ipsec_crypto_alg(u8 *s, va_list *args)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
clib_error_t *(* check_support_cb)(ipsec_sa_t *sa)
#define DPDK_CRYPTO_NB_COPS
static int check_cryptodev_queues()
u32 esp_encrypt_node_index
#define vec_free(V)
Free vector's memory (no header).
u32 esp_decrypt_next_index
#define clib_warning(format, args...)
static int add_del_sa_sess(u32 sa_index, u8 is_add)
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
static int add_cdev_mapping(crypto_worker_main_t *cwm, struct rte_cryptodev_info *dev_info, u8 cdev_id, u16 qp, u8 is_outbound)
#define hash_create(elts, value_bytes)
struct rte_mempool ** cop_pools
crypto_worker_main_t * workers_main
#define DPDK_CRYPTO_CACHE_SIZE
static void vlib_node_set_state(vlib_main_t *vm, u32 node_index, vlib_node_state_t new_state)
Set node dispatch state.
crypto_qp_data_t * qp_data
crypto_sa_session_t * sa_sess_d[2]
#define vec_elt(v, i)
Get vector value at index i.
u8 * format_ipsec_integ_alg(u8 *s, va_list *args)
static vlib_node_registration_t dpdk_ipsec_process_node
(constructor) VLIB_REGISTER_NODE (dpdk_ipsec_process_node)
static_always_inline int check_algo_is_supported(const struct rte_cryptodev_capabilities *cap, char *name)
#define DPDK_CRYPTO_N_QUEUE_DESC
ipsec_crypto_alg_t crypto_alg
#define VLIB_REGISTER_NODE(x,...)
static vlib_thread_main_t * vlib_get_thread_main()
static u32 vlib_num_workers()
static uword dpdk_ipsec_process(vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
#define vec_foreach(var, vec)
Vector iterator.
#define CLIB_CACHE_LINE_BYTES
struct rte_mempool ** sess_h_pools
static clib_error_t * dpdk_ipsec_check_support(ipsec_sa_t *sa)
u32 esp_decrypt_node_index