X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=app%2Ftest-crypto-perf%2Fcperf_test_common.c;h=00aadc9a4731b131234a933a094a7d60f8a41780;hb=baef6bbfad1b9596c7051f5c1fcc308310296342;hp=058e0ba564423c95c9d493ea2693685c27594cbb;hpb=f2fc83b40f06da6a6b2476005279ba52d4ce3c44;p=dpdk.git diff --git a/app/test-crypto-perf/cperf_test_common.c b/app/test-crypto-perf/cperf_test_common.c index 058e0ba564..00aadc9a47 100644 --- a/app/test-crypto-perf/cperf_test_common.c +++ b/app/test-crypto-perf/cperf_test_common.c @@ -82,6 +82,20 @@ fill_multi_seg_mbuf(struct rte_mbuf *m, struct rte_mempool *mp, m->next = NULL; } +static void +mempool_asym_obj_init(struct rte_mempool *mp, __rte_unused void *opaque_arg, + void *obj, __rte_unused unsigned int i) +{ + struct rte_crypto_op *op = obj; + + /* Set crypto operation */ + op->type = RTE_CRYPTO_OP_TYPE_ASYMMETRIC; + op->status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED; + op->sess_type = RTE_CRYPTO_OP_WITH_SESSION; + op->phys_addr = rte_mem_virt2iova(obj); + op->mempool = mp; +} + static void mempool_obj_init(struct rte_mempool *mp, void *opaque_arg, @@ -140,6 +154,24 @@ cperf_alloc_common_memory(const struct cperf_options *options, uint16_t crypto_op_size = sizeof(struct rte_crypto_op) + sizeof(struct rte_crypto_sym_op); uint16_t crypto_op_private_size; + + if (options->op_type == CPERF_ASYM_MODEX) { + snprintf(pool_name, RTE_MEMPOOL_NAMESIZE, "perf_asym_op_pool%u", + rte_socket_id()); + *pool = rte_crypto_op_pool_create( + pool_name, RTE_CRYPTO_OP_TYPE_ASYMMETRIC, + options->pool_sz, RTE_MEMPOOL_CACHE_MAX_SIZE, 0, + rte_socket_id()); + if (*pool == NULL) { + RTE_LOG(ERR, USER1, + "Cannot allocate mempool for device %u\n", + dev_id); + return -1; + } + rte_mempool_obj_iter(*pool, mempool_asym_obj_init, NULL); + return 0; + } + /* * If doing AES-CCM, IV field needs to be 16 bytes long, * and AAD field needs to be long enough to have 18 bytes, @@ -194,7 +226,7 @@ cperf_alloc_common_memory(const struct cperf_options *options, (mbuf_size * segments_nb); params.dst_buf_offset = *dst_buf_offset; /* Destination buffer will be one segment only */ - obj_size += max_size; + obj_size += max_size + sizeof(struct rte_mbuf); } *pool = rte_mempool_create_empty(pool_name, @@ -230,3 +262,39 @@ cperf_alloc_common_memory(const struct cperf_options *options, return 0; } + +void +cperf_mbuf_set(struct rte_mbuf *mbuf, + const struct cperf_options *options, + const struct cperf_test_vector *test_vector) +{ + uint32_t segment_sz = options->segment_sz; + uint8_t *mbuf_data; + uint8_t *test_data; + uint32_t remaining_bytes = options->max_buffer_size; + + if (options->op_type == CPERF_AEAD) { + test_data = (options->aead_op == RTE_CRYPTO_AEAD_OP_ENCRYPT) ? + test_vector->plaintext.data : + test_vector->ciphertext.data; + } else { + test_data = + (options->cipher_op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) ? + test_vector->plaintext.data : + test_vector->ciphertext.data; + } + + while (remaining_bytes) { + mbuf_data = rte_pktmbuf_mtod(mbuf, uint8_t *); + + if (remaining_bytes <= segment_sz) { + memcpy(mbuf_data, test_data, remaining_bytes); + return; + } + + memcpy(mbuf_data, test_data, segment_sz); + remaining_bytes -= segment_sz; + test_data += segment_sz; + mbuf = mbuf->next; + } +}