23 #define DPDK_CRYPTO_NB_OBJS 2048 24 #define DPDK_CRYPTO_CACHE_SIZE 512 25 #define DPDK_CRYPTO_PRIV_SIZE 128 26 #define DPDK_CRYPTO_N_QUEUE_DESC 512 27 #define DPDK_CRYPTO_NB_COPS (1024 * 4) 37 u8 cdev_id,
u16 qp_id,
u8 is_outbound,
u16 * idx)
46 if (qpd->
dev_id == cdev_id && qpd->
qp_id == qp_id &&
69 u8 cdev_id,
u16 qp,
u8 is_outbound,
70 const struct rte_cryptodev_capabilities *cipher_cap,
71 const struct rte_cryptodev_capabilities *auth_cap)
75 uword key = 0, data, *ret;
86 mapped =
update_qp_data (cwm, cdev_id, qp, is_outbound, &qp_index);
90 data = (
uword) qp_index;
94 rte_panic (
"Failed to insert hash table\n");
106 struct rte_cryptodev_info *dev_info,
u8 cdev_id,
107 u16 qp,
u8 is_outbound)
109 const struct rte_cryptodev_capabilities *
i, *j;
112 for (i = dev_info->capabilities; i->op != RTE_CRYPTO_OP_TYPE_UNDEFINED; i++)
114 if (i->sym.xform_type != RTE_CRYPTO_SYM_XFORM_CIPHER)
120 for (j = dev_info->capabilities; j->op != RTE_CRYPTO_OP_TYPE_UNDEFINED;
125 if (j->sym.xform_type != RTE_CRYPTO_SYM_XFORM_AUTH)
131 status =
add_mapping (cwm, cdev_id, qp, is_outbound, i, j);
152 for (cdev_id = 0; cdev_id < rte_cryptodev_count (); cdev_id++)
154 struct rte_cryptodev_info cdev_info;
156 rte_cryptodev_info_get (cdev_id, &cdev_info);
159 (cdev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING))
162 n_qs += cdev_info.max_nb_queue_pairs;
165 if (n_qs >= n_req_qs)
176 struct rte_cryptodev_config dev_conf;
177 struct rte_cryptodev_qp_conf qp_conf;
178 struct rte_cryptodev_info cdev_info;
179 struct rte_mempool *rmp;
189 fprintf (stdout,
"DPDK Cryptodevs info:\n");
190 fprintf (stdout,
"dev_id\tn_qp\tnb_obj\tcache_size\n");
192 for (dev_id = rte_cryptodev_count () - 1; dev_id >= 0; dev_id--)
194 u16 max_nb_qp, qp = 0;
197 rte_cryptodev_info_get (dev_id, &cdev_info);
200 (cdev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_OPERATION_CHAINING))
203 max_nb_qp = cdev_info.max_nb_queue_pairs;
230 for (is_outbound = 0; is_outbound < 2 && qp < max_nb_qp;
234 dev_id, qp, is_outbound);
240 "too many queues for one worker");
247 dev_conf.socket_id = rte_cryptodev_socket_id (dev_id);
248 dev_conf.nb_queue_pairs = cdev_info.max_nb_queue_pairs;
252 ret = rte_cryptodev_configure (dev_id, &dev_conf);
257 for (qp = 0; qp < dev_conf.nb_queue_pairs; qp++)
259 ret = rte_cryptodev_queue_pair_setup (dev_id, qp, &qp_conf,
265 fprintf (stdout,
"%u\t%u\t%u\t%u\n", dev_id, dev_conf.nb_queue_pairs,
277 u8 *pool_name =
format (0,
"crypto_op_pool_socket%u%c", socket_id, 0);
279 rmp = rte_crypto_op_pool_create ((
char *) pool_name,
280 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
296 VLIB_NODE_STATE_POLLING);
300 VLIB_NODE_STATE_POLLING);
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
static clib_error_t * dpdk_ipsec_init(vlib_main_t *vm)
#define VLIB_MAIN_LOOP_ENTER_FUNCTION(x)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
vlib_node_registration_t dpdk_crypto_input_node
(constructor) VLIB_REGISTER_NODE (dpdk_crypto_input_node)
static int update_qp_data(crypto_worker_main_t *cwm, u8 cdev_id, u16 qp_id, u8 is_outbound, u16 *idx)
#define vec_alloc(V, N)
Allocate space for N more elements (no header, unspecified alignment)
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 DPDK_CRYPTO_NB_COPS
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
dpdk_crypto_main_t dpdk_crypto_main
#define DPDK_CRYPTO_PRIV_SIZE
#define vec_free(V)
Free vector's memory (no header).
static vlib_thread_main_t * vlib_get_thread_main()
#define DPDK_CRYPTO_NB_OBJS
static_always_inline void dpdk_esp_init()
vlib_main_t vlib_global_main
#define DPDK_CRYPTO_N_QUEUE_DESC
#define hash_create(elts, value_bytes)
struct rte_mempool ** cop_pools
crypto_worker_main_t * workers_main
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
static_always_inline int check_algo_is_supported(const struct rte_cryptodev_capabilities *cap, char *name)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define DPDK_CRYPTO_CACHE_SIZE
static int check_cryptodev_queues()
vlib_main_t ** vlib_mains
static u32 vlib_num_workers()
#define clib_error_return(e, args...)
#define CLIB_CACHE_LINE_BYTES