X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=examples%2Fvhost_crypto%2Fmain.c;h=11b022e813e65ba4fed0693410671181f0d98769;hb=57680e34498b7f941f86bb38537bc49854880b6d;hp=cbb5e49d292dd680c45d7c5f343eb8e9c96001ee;hpb=709521f4c2cdf9f8c8ca4cb455cdac2e3a539238;p=dpdk.git diff --git a/examples/vhost_crypto/main.c b/examples/vhost_crypto/main.c index cbb5e49d29..11b022e813 100644 --- a/examples/vhost_crypto/main.c +++ b/examples/vhost_crypto/main.c @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -45,6 +46,7 @@ struct vhost_crypto_info { int vids[MAX_NB_SOCKETS]; uint32_t nb_vids; struct rte_mempool *sess_pool; + struct rte_mempool *sess_priv_pool; struct rte_mempool *cop_pool; uint8_t cid; uint32_t qid; @@ -288,6 +290,7 @@ new_device(int vid) } ret = rte_vhost_crypto_create(vid, info->cid, info->sess_pool, + info->sess_priv_pool, rte_lcore_to_socket_id(options.los[i].lcore_id)); if (ret) { RTE_LOG(ERR, USER1, "Cannot create vhost crypto\n"); @@ -351,12 +354,6 @@ static const struct vhost_device_ops virtio_crypto_device_ops = { .destroy_device = destroy_device, }; -__attribute__((unused)) -static void clrscr(void) -{ - system("@cls||clear"); -} - static int vhost_crypto_worker(void *arg) { @@ -442,8 +439,12 @@ free_resource(void) struct lcore_option *lo = &options.los[i]; struct vhost_crypto_info *info = options.infos[i]; + if (!info) + continue; + rte_mempool_free(info->cop_pool); rte_mempool_free(info->sess_pool); + rte_mempool_free(info->sess_priv_pool); for (j = 0; j < lo->nb_sockets; j++) { rte_vhost_driver_unregister(lo->socket_files[i]); @@ -459,7 +460,7 @@ free_resource(void) int main(int argc, char *argv[]) { - struct rte_cryptodev_qp_conf qp_conf = {NB_CRYPTO_DESCRIPTORS}; + struct rte_cryptodev_qp_conf qp_conf; struct rte_cryptodev_config config; struct rte_cryptodev_info dev_info; char name[128]; @@ -493,6 +494,20 @@ main(int argc, char *argv[]) info->nb_vids = lo->nb_sockets; rte_cryptodev_info_get(info->cid, &dev_info); + if (options.zero_copy == RTE_VHOST_CRYPTO_ZERO_COPY_ENABLE) { +#define VHOST_CRYPTO_CDEV_NAME_AESNI_MB_PMD crypto_aesni_mb +#define VHOST_CRYPTO_CDEV_NAME_AESNI_GCM_PMD crypto_aesni_gcm + if (strstr(dev_info.driver_name, + RTE_STR(VHOST_CRYPTO_CDEV_NAME_AESNI_MB_PMD)) || + strstr(dev_info.driver_name, + RTE_STR(VHOST_CRYPTO_CDEV_NAME_AESNI_GCM_PMD))) { + RTE_LOG(ERR, USER1, "Cannot enable zero-copy in %s\n", + dev_info.driver_name); + ret = -EPERM; + goto error_exit; + } + } + if (dev_info.max_nb_queue_pairs < info->qid + 1) { RTE_LOG(ERR, USER1, "Number of queues cannot over %u", dev_info.max_nb_queue_pairs); @@ -501,6 +516,7 @@ main(int argc, char *argv[]) config.nb_queue_pairs = dev_info.max_nb_queue_pairs; config.socket_id = rte_lcore_to_socket_id(lo->lcore_id); + config.ff_disable = RTE_CRYPTODEV_FF_SECURITY; ret = rte_cryptodev_configure(info->cid, &config); if (ret < 0) { @@ -510,11 +526,17 @@ main(int argc, char *argv[]) } snprintf(name, 127, "SESS_POOL_%u", lo->lcore_id); - info->sess_pool = rte_mempool_create(name, SESSION_MAP_ENTRIES, + info->sess_pool = rte_cryptodev_sym_session_pool_create(name, + SESSION_MAP_ENTRIES, 0, 0, 0, + rte_lcore_to_socket_id(lo->lcore_id)); + + snprintf(name, 127, "SESS_POOL_PRIV_%u", lo->lcore_id); + info->sess_priv_pool = rte_mempool_create(name, + SESSION_MAP_ENTRIES, rte_cryptodev_sym_get_private_session_size( info->cid), 64, 0, NULL, NULL, NULL, NULL, rte_lcore_to_socket_id(lo->lcore_id), 0); - if (!info->sess_pool) { + if (!info->sess_priv_pool || !info->sess_pool) { RTE_LOG(ERR, USER1, "Failed to create mempool"); goto error_exit; } @@ -522,7 +544,7 @@ main(int argc, char *argv[]) snprintf(name, 127, "COPPOOL_%u", lo->lcore_id); info->cop_pool = rte_crypto_op_pool_create(name, RTE_CRYPTO_OP_TYPE_SYMMETRIC, NB_MEMPOOL_OBJS, - NB_CACHE_OBJS, 0, + NB_CACHE_OBJS, VHOST_CRYPTO_MAX_IV_LEN, rte_lcore_to_socket_id(lo->lcore_id)); if (!info->cop_pool) { @@ -533,11 +555,14 @@ main(int argc, char *argv[]) options.infos[i] = info; + qp_conf.nb_descriptors = NB_CRYPTO_DESCRIPTORS; + qp_conf.mp_session = info->sess_pool; + qp_conf.mp_session_private = info->sess_priv_pool; + for (j = 0; j < dev_info.max_nb_queue_pairs; j++) { ret = rte_cryptodev_queue_pair_setup(info->cid, j, &qp_conf, rte_lcore_to_socket_id( - lo->lcore_id), - info->sess_pool); + lo->lcore_id)); if (ret < 0) { RTE_LOG(ERR, USER1, "Failed to configure qp\n"); goto error_exit;