2017-12-19 15:48:59 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
* Copyright(c) 2016-2017 Intel Corporation
|
2017-07-02 05:41:15 +00:00
|
|
|
*/
|
|
|
|
|
2017-01-25 16:27:33 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2017-12-13 13:14:08 +00:00
|
|
|
#include <rte_malloc.h>
|
|
|
|
#include <rte_random.h>
|
2017-01-25 16:27:33 +00:00
|
|
|
#include <rte_eal.h>
|
|
|
|
#include <rte_cryptodev.h>
|
2020-10-15 15:05:54 +00:00
|
|
|
#ifdef RTE_CRYPTO_SCHEDULER
|
2017-10-04 03:46:12 +00:00
|
|
|
#include <rte_cryptodev_scheduler.h>
|
|
|
|
#endif
|
2017-01-25 16:27:33 +00:00
|
|
|
|
|
|
|
#include "cperf.h"
|
|
|
|
#include "cperf_options.h"
|
|
|
|
#include "cperf_test_vector_parsing.h"
|
|
|
|
#include "cperf_test_throughput.h"
|
|
|
|
#include "cperf_test_latency.h"
|
2017-03-27 11:26:01 +00:00
|
|
|
#include "cperf_test_verify.h"
|
2017-09-12 09:36:26 +00:00
|
|
|
#include "cperf_test_pmd_cyclecount.h"
|
2017-01-25 16:27:33 +00:00
|
|
|
|
2019-01-10 14:50:13 +00:00
|
|
|
static struct {
|
|
|
|
struct rte_mempool *sess_mp;
|
|
|
|
struct rte_mempool *priv_mp;
|
|
|
|
} session_pool_socket[RTE_MAX_NUMA_NODES];
|
2017-07-05 05:26:12 +00:00
|
|
|
|
2017-01-25 16:27:33 +00:00
|
|
|
const char *cperf_test_type_strs[] = {
|
|
|
|
[CPERF_TEST_TYPE_THROUGHPUT] = "throughput",
|
2017-03-27 11:26:01 +00:00
|
|
|
[CPERF_TEST_TYPE_LATENCY] = "latency",
|
2017-09-12 09:36:26 +00:00
|
|
|
[CPERF_TEST_TYPE_VERIFY] = "verify",
|
|
|
|
[CPERF_TEST_TYPE_PMDCC] = "pmd-cyclecount"
|
2017-01-25 16:27:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const char *cperf_op_type_strs[] = {
|
|
|
|
[CPERF_CIPHER_ONLY] = "cipher-only",
|
|
|
|
[CPERF_AUTH_ONLY] = "auth-only",
|
|
|
|
[CPERF_CIPHER_THEN_AUTH] = "cipher-then-auth",
|
|
|
|
[CPERF_AUTH_THEN_CIPHER] = "auth-then-cipher",
|
2019-11-08 10:46:10 +00:00
|
|
|
[CPERF_AEAD] = "aead",
|
2020-07-03 12:39:33 +00:00
|
|
|
[CPERF_PDCP] = "pdcp",
|
2021-09-16 08:38:38 +00:00
|
|
|
[CPERF_DOCSIS] = "docsis",
|
app/crypto-perf: support lookaside IPsec
Added support for lookaside IPsec protocol offload.
Supported cases:
-AEAD
-Cipher+auth
Command used for testing:
./dpdk-test-crypto-perf -c 0xf -- --devtype crypto_octeontx2 --ptest
throughput --optype ipsec --cipher-algo aes-cbc --pool-sz 16384
--cipher-op encrypt --cipher-key-sz 16 --cipher-iv-sz 16 --auth-algo
sha1-hmac --auth-op generate --digest-sz 16 --total-ops 10000000
--burst-sz 32 --buffer-sz 64,128,256,512,1024,1280,2048
./dpdk-test-crypto-perf -c 0xf -- --devtype crypto_octeontx2 --ptest
throughput --optype ipsec --aead-algo aes-gcm --pool-sz 16384
--aead-op encrypt --aead-key-sz 32 --aead-iv-sz 12 --aead-aad-sz 16
--digest-sz 16 --total-ops 10000000 --burst-sz 32
--buffer-sz 64,128,256,512,1024,1280,2048
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
Signed-off-by: Archana Muniganti <marchana@marvell.com>
2021-10-12 10:07:19 +00:00
|
|
|
[CPERF_IPSEC] = "ipsec",
|
2021-09-16 08:38:38 +00:00
|
|
|
[CPERF_ASYM_MODEX] = "modex"
|
2017-01-25 16:27:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const struct cperf_test cperf_testmap[] = {
|
|
|
|
[CPERF_TEST_TYPE_THROUGHPUT] = {
|
|
|
|
cperf_throughput_test_constructor,
|
|
|
|
cperf_throughput_test_runner,
|
|
|
|
cperf_throughput_test_destructor
|
|
|
|
},
|
|
|
|
[CPERF_TEST_TYPE_LATENCY] = {
|
|
|
|
cperf_latency_test_constructor,
|
|
|
|
cperf_latency_test_runner,
|
|
|
|
cperf_latency_test_destructor
|
2017-03-27 11:26:01 +00:00
|
|
|
},
|
|
|
|
[CPERF_TEST_TYPE_VERIFY] = {
|
|
|
|
cperf_verify_test_constructor,
|
|
|
|
cperf_verify_test_runner,
|
|
|
|
cperf_verify_test_destructor
|
2017-09-12 09:36:26 +00:00
|
|
|
},
|
|
|
|
[CPERF_TEST_TYPE_PMDCC] = {
|
|
|
|
cperf_pmd_cyclecount_test_constructor,
|
|
|
|
cperf_pmd_cyclecount_test_runner,
|
|
|
|
cperf_pmd_cyclecount_test_destructor
|
2017-01-25 16:27:33 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-09-16 08:38:38 +00:00
|
|
|
static int
|
|
|
|
create_asym_op_pool_socket(uint8_t dev_id, int32_t socket_id,
|
|
|
|
uint32_t nb_sessions)
|
|
|
|
{
|
|
|
|
char mp_name[RTE_MEMPOOL_NAMESIZE];
|
|
|
|
struct rte_mempool *mpool = NULL;
|
|
|
|
unsigned int session_size =
|
|
|
|
RTE_MAX(rte_cryptodev_asym_get_private_session_size(dev_id),
|
|
|
|
rte_cryptodev_asym_get_header_session_size());
|
|
|
|
|
|
|
|
if (session_pool_socket[socket_id].priv_mp == NULL) {
|
|
|
|
snprintf(mp_name, RTE_MEMPOOL_NAMESIZE, "perf_asym_priv_pool%u",
|
|
|
|
socket_id);
|
|
|
|
|
|
|
|
mpool = rte_mempool_create(mp_name, nb_sessions, session_size,
|
|
|
|
0, 0, NULL, NULL, NULL, NULL,
|
|
|
|
socket_id, 0);
|
|
|
|
if (mpool == NULL) {
|
|
|
|
printf("Cannot create pool \"%s\" on socket %d\n",
|
|
|
|
mp_name, socket_id);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
printf("Allocated pool \"%s\" on socket %d\n", mp_name,
|
|
|
|
socket_id);
|
|
|
|
session_pool_socket[socket_id].priv_mp = mpool;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (session_pool_socket[socket_id].sess_mp == NULL) {
|
|
|
|
|
|
|
|
snprintf(mp_name, RTE_MEMPOOL_NAMESIZE, "perf_asym_sess_pool%u",
|
|
|
|
socket_id);
|
|
|
|
mpool = rte_mempool_create(mp_name, nb_sessions,
|
|
|
|
session_size, 0, 0, NULL, NULL, NULL,
|
|
|
|
NULL, socket_id, 0);
|
|
|
|
if (mpool == NULL) {
|
|
|
|
printf("Cannot create pool \"%s\" on socket %d\n",
|
|
|
|
mp_name, socket_id);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
session_pool_socket[socket_id].sess_mp = mpool;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-01-25 16:27:33 +00:00
|
|
|
static int
|
2019-01-10 14:50:13 +00:00
|
|
|
fill_session_pool_socket(int32_t socket_id, uint32_t session_priv_size,
|
|
|
|
uint32_t nb_sessions)
|
|
|
|
{
|
|
|
|
char mp_name[RTE_MEMPOOL_NAMESIZE];
|
|
|
|
struct rte_mempool *sess_mp;
|
|
|
|
|
|
|
|
if (session_pool_socket[socket_id].priv_mp == NULL) {
|
|
|
|
snprintf(mp_name, RTE_MEMPOOL_NAMESIZE,
|
|
|
|
"priv_sess_mp_%u", socket_id);
|
|
|
|
|
|
|
|
sess_mp = rte_mempool_create(mp_name,
|
|
|
|
nb_sessions,
|
|
|
|
session_priv_size,
|
|
|
|
0, 0, NULL, NULL, NULL,
|
|
|
|
NULL, socket_id,
|
|
|
|
0);
|
|
|
|
|
|
|
|
if (sess_mp == NULL) {
|
|
|
|
printf("Cannot create pool \"%s\" on socket %d\n",
|
|
|
|
mp_name, socket_id);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Allocated pool \"%s\" on socket %d\n",
|
|
|
|
mp_name, socket_id);
|
|
|
|
session_pool_socket[socket_id].priv_mp = sess_mp;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (session_pool_socket[socket_id].sess_mp == NULL) {
|
|
|
|
|
|
|
|
snprintf(mp_name, RTE_MEMPOOL_NAMESIZE,
|
|
|
|
"sess_mp_%u", socket_id);
|
|
|
|
|
|
|
|
sess_mp = rte_cryptodev_sym_session_pool_create(mp_name,
|
|
|
|
nb_sessions, 0, 0, 0, socket_id);
|
|
|
|
|
|
|
|
if (sess_mp == NULL) {
|
|
|
|
printf("Cannot create pool \"%s\" on socket %d\n",
|
|
|
|
mp_name, socket_id);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Allocated pool \"%s\" on socket %d\n",
|
|
|
|
mp_name, socket_id);
|
|
|
|
session_pool_socket[socket_id].sess_mp = sess_mp;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs)
|
2017-01-25 16:27:33 +00:00
|
|
|
{
|
2017-07-05 05:26:12 +00:00
|
|
|
uint8_t enabled_cdev_count = 0, nb_lcores, cdev_id;
|
2018-07-05 02:07:52 +00:00
|
|
|
uint32_t sessions_needed = 0;
|
2017-10-04 03:46:12 +00:00
|
|
|
unsigned int i, j;
|
2017-01-25 16:27:33 +00:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
enabled_cdev_count = rte_cryptodev_devices_get(opts->device_type,
|
2017-02-10 13:26:15 +00:00
|
|
|
enabled_cdevs, RTE_CRYPTO_MAX_DEVS);
|
2017-01-25 16:27:33 +00:00
|
|
|
if (enabled_cdev_count == 0) {
|
|
|
|
printf("No crypto devices type %s available\n",
|
|
|
|
opts->device_type);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
nb_lcores = rte_lcore_count() - 1;
|
|
|
|
|
2018-05-09 09:44:21 +00:00
|
|
|
if (nb_lcores < 1) {
|
|
|
|
RTE_LOG(ERR, USER1,
|
|
|
|
"Number of enabled cores need to be higher than 1\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2018-04-02 15:33:15 +00:00
|
|
|
/*
|
|
|
|
* Use less number of devices,
|
|
|
|
* if there are more available than cores.
|
|
|
|
*/
|
|
|
|
if (enabled_cdev_count > nb_lcores)
|
|
|
|
enabled_cdev_count = nb_lcores;
|
2017-01-25 16:27:33 +00:00
|
|
|
|
2017-07-05 05:26:12 +00:00
|
|
|
/* Create a mempool shared by all the devices */
|
|
|
|
uint32_t max_sess_size = 0, sess_size;
|
|
|
|
|
|
|
|
for (cdev_id = 0; cdev_id < rte_cryptodev_count(); cdev_id++) {
|
2018-05-21 13:08:41 +00:00
|
|
|
sess_size = rte_cryptodev_sym_get_private_session_size(cdev_id);
|
2017-07-05 05:26:12 +00:00
|
|
|
if (sess_size > max_sess_size)
|
|
|
|
max_sess_size = sess_size;
|
|
|
|
}
|
2020-10-15 15:05:54 +00:00
|
|
|
#ifdef RTE_LIB_SECURITY
|
2020-10-18 09:40:41 +00:00
|
|
|
for (cdev_id = 0; cdev_id < rte_cryptodev_count(); cdev_id++) {
|
|
|
|
sess_size = rte_security_session_get_size(
|
|
|
|
rte_cryptodev_get_sec_ctx(cdev_id));
|
|
|
|
if (sess_size > max_sess_size)
|
|
|
|
max_sess_size = sess_size;
|
|
|
|
}
|
|
|
|
#endif
|
2017-10-04 03:46:12 +00:00
|
|
|
/*
|
|
|
|
* Calculate number of needed queue pairs, based on the amount
|
|
|
|
* of available number of logical cores and crypto devices.
|
|
|
|
* For instance, if there are 4 cores and 2 crypto devices,
|
|
|
|
* 2 queue pairs will be set up per device.
|
|
|
|
*/
|
|
|
|
opts->nb_qps = (nb_lcores % enabled_cdev_count) ?
|
|
|
|
(nb_lcores / enabled_cdev_count) + 1 :
|
|
|
|
nb_lcores / enabled_cdev_count;
|
|
|
|
|
2017-07-05 05:26:12 +00:00
|
|
|
for (i = 0; i < enabled_cdev_count &&
|
|
|
|
i < RTE_CRYPTO_MAX_DEVS; i++) {
|
|
|
|
cdev_id = enabled_cdevs[i];
|
2020-10-15 15:05:54 +00:00
|
|
|
#ifdef RTE_CRYPTO_SCHEDULER
|
2017-10-04 03:46:12 +00:00
|
|
|
/*
|
|
|
|
* If multi-core scheduler is used, limit the number
|
|
|
|
* of queue pairs to 1, as there is no way to know
|
|
|
|
* how many cores are being used by the PMD, and
|
|
|
|
* how many will be available for the application.
|
|
|
|
*/
|
|
|
|
if (!strcmp((const char *)opts->device_type, "crypto_scheduler") &&
|
|
|
|
rte_cryptodev_scheduler_mode_get(cdev_id) ==
|
|
|
|
CDEV_SCHED_MODE_MULTICORE)
|
|
|
|
opts->nb_qps = 1;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct rte_cryptodev_info cdev_info;
|
2017-07-05 05:26:12 +00:00
|
|
|
uint8_t socket_id = rte_cryptodev_socket_id(cdev_id);
|
2019-04-08 09:25:14 +00:00
|
|
|
/* range check the socket_id - negative values become big
|
|
|
|
* positive ones due to use of unsigned value
|
|
|
|
*/
|
|
|
|
if (socket_id >= RTE_MAX_NUMA_NODES)
|
|
|
|
socket_id = 0;
|
2017-01-25 16:27:33 +00:00
|
|
|
|
2017-10-04 03:46:12 +00:00
|
|
|
rte_cryptodev_info_get(cdev_id, &cdev_info);
|
2021-09-16 08:38:38 +00:00
|
|
|
|
|
|
|
if (opts->op_type == CPERF_ASYM_MODEX) {
|
|
|
|
if ((cdev_info.feature_flags &
|
|
|
|
RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO) == 0)
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-10-04 03:46:12 +00:00
|
|
|
if (opts->nb_qps > cdev_info.max_nb_queue_pairs) {
|
|
|
|
printf("Number of needed queue pairs is higher "
|
|
|
|
"than the maximum number of queue pairs "
|
|
|
|
"per device.\n");
|
|
|
|
printf("Lower the number of cores or increase "
|
|
|
|
"the number of crypto devices\n");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2017-01-25 16:27:33 +00:00
|
|
|
struct rte_cryptodev_config conf = {
|
2017-10-04 03:46:12 +00:00
|
|
|
.nb_queue_pairs = opts->nb_qps,
|
2019-06-25 05:39:24 +00:00
|
|
|
.socket_id = socket_id,
|
2017-07-05 05:26:12 +00:00
|
|
|
};
|
|
|
|
|
2021-09-16 08:38:38 +00:00
|
|
|
switch (opts->op_type) {
|
|
|
|
case CPERF_ASYM_MODEX:
|
|
|
|
conf.ff_disable |= (RTE_CRYPTODEV_FF_SECURITY |
|
|
|
|
RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO);
|
|
|
|
break;
|
|
|
|
case CPERF_CIPHER_ONLY:
|
|
|
|
case CPERF_AUTH_ONLY:
|
|
|
|
case CPERF_CIPHER_THEN_AUTH:
|
|
|
|
case CPERF_AUTH_THEN_CIPHER:
|
|
|
|
case CPERF_AEAD:
|
2020-07-16 15:29:52 +00:00
|
|
|
conf.ff_disable |= RTE_CRYPTODEV_FF_SECURITY;
|
2021-09-16 08:38:38 +00:00
|
|
|
/* Fall through */
|
|
|
|
case CPERF_PDCP:
|
|
|
|
case CPERF_DOCSIS:
|
app/crypto-perf: support lookaside IPsec
Added support for lookaside IPsec protocol offload.
Supported cases:
-AEAD
-Cipher+auth
Command used for testing:
./dpdk-test-crypto-perf -c 0xf -- --devtype crypto_octeontx2 --ptest
throughput --optype ipsec --cipher-algo aes-cbc --pool-sz 16384
--cipher-op encrypt --cipher-key-sz 16 --cipher-iv-sz 16 --auth-algo
sha1-hmac --auth-op generate --digest-sz 16 --total-ops 10000000
--burst-sz 32 --buffer-sz 64,128,256,512,1024,1280,2048
./dpdk-test-crypto-perf -c 0xf -- --devtype crypto_octeontx2 --ptest
throughput --optype ipsec --aead-algo aes-gcm --pool-sz 16384
--aead-op encrypt --aead-key-sz 32 --aead-iv-sz 12 --aead-aad-sz 16
--digest-sz 16 --total-ops 10000000 --burst-sz 32
--buffer-sz 64,128,256,512,1024,1280,2048
Signed-off-by: Akhil Goyal <gakhil@marvell.com>
Signed-off-by: Archana Muniganti <marchana@marvell.com>
2021-10-12 10:07:19 +00:00
|
|
|
case CPERF_IPSEC:
|
2021-09-16 08:38:38 +00:00
|
|
|
/* Fall through */
|
|
|
|
default:
|
|
|
|
conf.ff_disable |= RTE_CRYPTODEV_FF_ASYMMETRIC_CRYPTO;
|
|
|
|
}
|
2020-07-16 15:29:52 +00:00
|
|
|
|
2017-01-25 16:27:33 +00:00
|
|
|
struct rte_cryptodev_qp_conf qp_conf = {
|
2017-10-04 03:46:12 +00:00
|
|
|
.nb_descriptors = opts->nb_descriptors
|
2017-01-25 16:27:33 +00:00
|
|
|
};
|
|
|
|
|
2018-07-10 14:42:38 +00:00
|
|
|
/**
|
|
|
|
* Device info specifies the min headroom and tailroom
|
|
|
|
* requirement for the crypto PMD. This need to be honoured
|
|
|
|
* by the application, while creating mbuf.
|
|
|
|
*/
|
|
|
|
if (opts->headroom_sz < cdev_info.min_mbuf_headroom_req) {
|
|
|
|
/* Update headroom */
|
|
|
|
opts->headroom_sz = cdev_info.min_mbuf_headroom_req;
|
|
|
|
}
|
|
|
|
if (opts->tailroom_sz < cdev_info.min_mbuf_tailroom_req) {
|
|
|
|
/* Update tailroom */
|
|
|
|
opts->tailroom_sz = cdev_info.min_mbuf_tailroom_req;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update segment size to include headroom & tailroom */
|
|
|
|
opts->segment_sz += (opts->headroom_sz + opts->tailroom_sz);
|
|
|
|
|
2018-07-05 02:07:52 +00:00
|
|
|
uint32_t dev_max_nb_sess = cdev_info.sym.max_nb_sessions;
|
|
|
|
/*
|
|
|
|
* Two sessions objects are required for each session
|
|
|
|
* (one for the header, one for the private data)
|
|
|
|
*/
|
|
|
|
if (!strcmp((const char *)opts->device_type,
|
|
|
|
"crypto_scheduler")) {
|
2020-10-15 15:05:54 +00:00
|
|
|
#ifdef RTE_CRYPTO_SCHEDULER
|
2018-07-05 02:07:52 +00:00
|
|
|
uint32_t nb_slaves =
|
2020-09-28 14:16:33 +00:00
|
|
|
rte_cryptodev_scheduler_workers_get(cdev_id,
|
2018-07-05 02:07:52 +00:00
|
|
|
NULL);
|
|
|
|
|
2019-01-10 14:50:13 +00:00
|
|
|
sessions_needed = enabled_cdev_count *
|
2018-07-05 02:07:52 +00:00
|
|
|
opts->nb_qps * nb_slaves;
|
|
|
|
#endif
|
|
|
|
} else
|
2020-10-18 09:40:41 +00:00
|
|
|
sessions_needed = enabled_cdev_count * opts->nb_qps;
|
2018-07-05 02:07:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* A single session is required per queue pair
|
|
|
|
* in each device
|
|
|
|
*/
|
2018-07-05 02:07:57 +00:00
|
|
|
if (dev_max_nb_sess != 0 && dev_max_nb_sess < opts->nb_qps) {
|
2018-07-05 02:07:52 +00:00
|
|
|
RTE_LOG(ERR, USER1,
|
|
|
|
"Device does not support at least "
|
|
|
|
"%u sessions\n", opts->nb_qps);
|
|
|
|
return -ENOTSUP;
|
|
|
|
}
|
2017-07-05 05:26:12 +00:00
|
|
|
|
2021-09-16 08:38:38 +00:00
|
|
|
if (opts->op_type == CPERF_ASYM_MODEX)
|
|
|
|
ret = create_asym_op_pool_socket(cdev_id, socket_id,
|
|
|
|
sessions_needed);
|
|
|
|
else
|
|
|
|
ret = fill_session_pool_socket(socket_id, max_sess_size,
|
|
|
|
sessions_needed);
|
2019-01-10 14:50:13 +00:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2017-07-05 05:26:12 +00:00
|
|
|
|
2019-01-10 14:50:13 +00:00
|
|
|
qp_conf.mp_session = session_pool_socket[socket_id].sess_mp;
|
|
|
|
qp_conf.mp_session_private =
|
|
|
|
session_pool_socket[socket_id].priv_mp;
|
2019-01-10 14:50:11 +00:00
|
|
|
|
2021-09-16 08:38:38 +00:00
|
|
|
if (opts->op_type == CPERF_ASYM_MODEX) {
|
|
|
|
qp_conf.mp_session = NULL;
|
|
|
|
qp_conf.mp_session_private = NULL;
|
|
|
|
}
|
|
|
|
|
2017-07-05 05:26:18 +00:00
|
|
|
ret = rte_cryptodev_configure(cdev_id, &conf);
|
2017-01-25 16:27:33 +00:00
|
|
|
if (ret < 0) {
|
2017-07-05 05:26:12 +00:00
|
|
|
printf("Failed to configure cryptodev %u", cdev_id);
|
2017-01-25 16:27:33 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2017-10-04 03:46:12 +00:00
|
|
|
for (j = 0; j < opts->nb_qps; j++) {
|
|
|
|
ret = rte_cryptodev_queue_pair_setup(cdev_id, j,
|
2019-01-10 14:50:11 +00:00
|
|
|
&qp_conf, socket_id);
|
2017-07-05 05:26:18 +00:00
|
|
|
if (ret < 0) {
|
|
|
|
printf("Failed to setup queue pair %u on "
|
2017-10-04 03:46:12 +00:00
|
|
|
"cryptodev %u", j, cdev_id);
|
2017-07-05 05:26:18 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2017-10-04 03:46:12 +00:00
|
|
|
}
|
2017-01-25 16:27:33 +00:00
|
|
|
|
2017-07-05 05:26:12 +00:00
|
|
|
ret = rte_cryptodev_start(cdev_id);
|
2017-01-25 16:27:33 +00:00
|
|
|
if (ret < 0) {
|
|
|
|
printf("Failed to start device %u: error %d\n",
|
2017-07-05 05:26:12 +00:00
|
|
|
cdev_id, ret);
|
2017-01-25 16:27:33 +00:00
|
|
|
return -EPERM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return enabled_cdev_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
cperf_verify_devices_capabilities(struct cperf_options *opts,
|
|
|
|
uint8_t *enabled_cdevs, uint8_t nb_cryptodevs)
|
|
|
|
{
|
|
|
|
struct rte_cryptodev_sym_capability_idx cap_idx;
|
|
|
|
const struct rte_cryptodev_symmetric_capability *capability;
|
2021-09-16 08:38:38 +00:00
|
|
|
struct rte_cryptodev_asym_capability_idx asym_cap_idx;
|
|
|
|
const struct rte_cryptodev_asymmetric_xform_capability *asym_capability;
|
|
|
|
|
2017-01-25 16:27:33 +00:00
|
|
|
|
|
|
|
uint8_t i, cdev_id;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
for (i = 0; i < nb_cryptodevs; i++) {
|
|
|
|
|
|
|
|
cdev_id = enabled_cdevs[i];
|
|
|
|
|
2021-09-16 08:38:38 +00:00
|
|
|
if (opts->op_type == CPERF_ASYM_MODEX) {
|
|
|
|
asym_cap_idx.type = RTE_CRYPTO_ASYM_XFORM_MODEX;
|
|
|
|
asym_capability = rte_cryptodev_asym_capability_get(
|
|
|
|
cdev_id, &asym_cap_idx);
|
|
|
|
if (asym_capability == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
ret = rte_cryptodev_asym_xform_capability_check_modlen(
|
|
|
|
asym_capability, sizeof(perf_mod_p));
|
|
|
|
if (ret != 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-01-25 16:27:33 +00:00
|
|
|
if (opts->op_type == CPERF_AUTH_ONLY ||
|
|
|
|
opts->op_type == CPERF_CIPHER_THEN_AUTH ||
|
2017-07-02 05:41:23 +00:00
|
|
|
opts->op_type == CPERF_AUTH_THEN_CIPHER) {
|
2017-01-25 16:27:33 +00:00
|
|
|
|
|
|
|
cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
|
|
|
|
cap_idx.algo.auth = opts->auth_algo;
|
|
|
|
|
|
|
|
capability = rte_cryptodev_sym_capability_get(cdev_id,
|
|
|
|
&cap_idx);
|
|
|
|
if (capability == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
ret = rte_cryptodev_sym_capability_check_auth(
|
|
|
|
capability,
|
|
|
|
opts->auth_key_sz,
|
2017-07-02 05:41:23 +00:00
|
|
|
opts->digest_sz,
|
2017-07-02 05:41:15 +00:00
|
|
|
opts->auth_iv_sz);
|
2017-01-25 16:27:33 +00:00
|
|
|
if (ret != 0)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (opts->op_type == CPERF_CIPHER_ONLY ||
|
|
|
|
opts->op_type == CPERF_CIPHER_THEN_AUTH ||
|
2017-07-02 05:41:23 +00:00
|
|
|
opts->op_type == CPERF_AUTH_THEN_CIPHER) {
|
2017-01-25 16:27:33 +00:00
|
|
|
|
|
|
|
cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
|
|
|
|
cap_idx.algo.cipher = opts->cipher_algo;
|
|
|
|
|
|
|
|
capability = rte_cryptodev_sym_capability_get(cdev_id,
|
|
|
|
&cap_idx);
|
|
|
|
if (capability == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
ret = rte_cryptodev_sym_capability_check_cipher(
|
|
|
|
capability,
|
|
|
|
opts->cipher_key_sz,
|
|
|
|
opts->cipher_iv_sz);
|
|
|
|
if (ret != 0)
|
|
|
|
return ret;
|
|
|
|
}
|
2017-07-02 05:41:23 +00:00
|
|
|
|
|
|
|
if (opts->op_type == CPERF_AEAD) {
|
|
|
|
|
|
|
|
cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
|
|
|
|
cap_idx.algo.aead = opts->aead_algo;
|
|
|
|
|
|
|
|
capability = rte_cryptodev_sym_capability_get(cdev_id,
|
|
|
|
&cap_idx);
|
|
|
|
if (capability == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
ret = rte_cryptodev_sym_capability_check_aead(
|
|
|
|
capability,
|
|
|
|
opts->aead_key_sz,
|
|
|
|
opts->digest_sz,
|
|
|
|
opts->aead_aad_sz,
|
|
|
|
opts->aead_iv_sz);
|
|
|
|
if (ret != 0)
|
|
|
|
return ret;
|
|
|
|
}
|
2017-01-25 16:27:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2017-02-08 16:04:40 +00:00
|
|
|
cperf_check_test_vector(struct cperf_options *opts,
|
|
|
|
struct cperf_test_vector *test_vec)
|
2017-01-25 16:27:33 +00:00
|
|
|
{
|
2017-02-08 16:04:40 +00:00
|
|
|
if (opts->op_type == CPERF_CIPHER_ONLY) {
|
|
|
|
if (opts->cipher_algo == RTE_CRYPTO_CIPHER_NULL) {
|
|
|
|
if (test_vec->plaintext.data == NULL)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
2020-11-19 11:58:59 +00:00
|
|
|
} else {
|
2017-02-08 16:04:40 +00:00
|
|
|
if (test_vec->plaintext.data == NULL)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
2017-03-27 11:26:04 +00:00
|
|
|
if (test_vec->plaintext.length < opts->max_buffer_size)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
2017-02-08 16:04:40 +00:00
|
|
|
if (test_vec->ciphertext.data == NULL)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
2017-03-27 11:26:04 +00:00
|
|
|
if (test_vec->ciphertext.length < opts->max_buffer_size)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
2018-09-14 09:24:48 +00:00
|
|
|
/* Cipher IV is only required for some algorithms */
|
|
|
|
if (opts->cipher_iv_sz &&
|
|
|
|
test_vec->cipher_iv.data == NULL)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
2017-07-02 05:41:15 +00:00
|
|
|
if (test_vec->cipher_iv.length != opts->cipher_iv_sz)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
2017-02-08 16:04:40 +00:00
|
|
|
if (test_vec->cipher_key.data == NULL)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
2017-02-08 16:04:40 +00:00
|
|
|
if (test_vec->cipher_key.length != opts->cipher_key_sz)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2017-02-08 16:04:40 +00:00
|
|
|
} else if (opts->op_type == CPERF_AUTH_ONLY) {
|
|
|
|
if (opts->auth_algo != RTE_CRYPTO_AUTH_NULL) {
|
|
|
|
if (test_vec->plaintext.data == NULL)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
2017-03-27 11:26:04 +00:00
|
|
|
if (test_vec->plaintext.length < opts->max_buffer_size)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
2018-09-14 09:24:47 +00:00
|
|
|
/* Auth key is only required for some algorithms */
|
|
|
|
if (opts->auth_key_sz &&
|
|
|
|
test_vec->auth_key.data == NULL)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
2017-02-08 16:04:40 +00:00
|
|
|
if (test_vec->auth_key.length != opts->auth_key_sz)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
2017-07-02 05:41:15 +00:00
|
|
|
if (test_vec->auth_iv.length != opts->auth_iv_sz)
|
|
|
|
return -1;
|
|
|
|
/* Auth IV is only required for some algorithms */
|
|
|
|
if (opts->auth_iv_sz && test_vec->auth_iv.data == NULL)
|
|
|
|
return -1;
|
2017-02-08 16:04:40 +00:00
|
|
|
if (test_vec->digest.data == NULL)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
2017-07-02 05:41:23 +00:00
|
|
|
if (test_vec->digest.length < opts->digest_sz)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2017-02-08 16:04:40 +00:00
|
|
|
} else if (opts->op_type == CPERF_CIPHER_THEN_AUTH ||
|
|
|
|
opts->op_type == CPERF_AUTH_THEN_CIPHER) {
|
|
|
|
if (opts->cipher_algo == RTE_CRYPTO_CIPHER_NULL) {
|
|
|
|
if (test_vec->plaintext.data == NULL)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
2017-03-27 11:26:04 +00:00
|
|
|
if (test_vec->plaintext.length < opts->max_buffer_size)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
2020-11-19 11:58:59 +00:00
|
|
|
} else {
|
2017-02-08 16:04:40 +00:00
|
|
|
if (test_vec->plaintext.data == NULL)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
2017-03-27 11:26:04 +00:00
|
|
|
if (test_vec->plaintext.length < opts->max_buffer_size)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
2017-02-08 16:04:40 +00:00
|
|
|
if (test_vec->ciphertext.data == NULL)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
2017-03-27 11:26:04 +00:00
|
|
|
if (test_vec->ciphertext.length < opts->max_buffer_size)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
2017-07-02 05:41:15 +00:00
|
|
|
if (test_vec->cipher_iv.data == NULL)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
2017-07-02 05:41:15 +00:00
|
|
|
if (test_vec->cipher_iv.length != opts->cipher_iv_sz)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
2017-02-08 16:04:40 +00:00
|
|
|
if (test_vec->cipher_key.data == NULL)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
2017-02-08 16:04:40 +00:00
|
|
|
if (test_vec->cipher_key.length != opts->cipher_key_sz)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2017-02-08 16:04:40 +00:00
|
|
|
if (opts->auth_algo != RTE_CRYPTO_AUTH_NULL) {
|
|
|
|
if (test_vec->auth_key.data == NULL)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
2017-02-08 16:04:40 +00:00
|
|
|
if (test_vec->auth_key.length != opts->auth_key_sz)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
2017-07-02 05:41:15 +00:00
|
|
|
if (test_vec->auth_iv.length != opts->auth_iv_sz)
|
|
|
|
return -1;
|
|
|
|
/* Auth IV is only required for some algorithms */
|
|
|
|
if (opts->auth_iv_sz && test_vec->auth_iv.data == NULL)
|
|
|
|
return -1;
|
2017-02-08 16:04:40 +00:00
|
|
|
if (test_vec->digest.data == NULL)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
2017-07-02 05:41:23 +00:00
|
|
|
if (test_vec->digest.length < opts->digest_sz)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2017-02-08 16:04:40 +00:00
|
|
|
} else if (opts->op_type == CPERF_AEAD) {
|
|
|
|
if (test_vec->plaintext.data == NULL)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
2017-03-27 11:26:04 +00:00
|
|
|
if (test_vec->plaintext.length < opts->max_buffer_size)
|
|
|
|
return -1;
|
|
|
|
if (test_vec->ciphertext.data == NULL)
|
|
|
|
return -1;
|
|
|
|
if (test_vec->ciphertext.length < opts->max_buffer_size)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
2018-09-14 09:24:46 +00:00
|
|
|
if (test_vec->aead_key.data == NULL)
|
|
|
|
return -1;
|
|
|
|
if (test_vec->aead_key.length != opts->aead_key_sz)
|
|
|
|
return -1;
|
2017-07-02 05:41:23 +00:00
|
|
|
if (test_vec->aead_iv.data == NULL)
|
2017-07-02 05:41:15 +00:00
|
|
|
return -1;
|
2017-07-02 05:41:23 +00:00
|
|
|
if (test_vec->aead_iv.length != opts->aead_iv_sz)
|
2017-07-02 05:41:15 +00:00
|
|
|
return -1;
|
2017-02-08 16:04:40 +00:00
|
|
|
if (test_vec->aad.data == NULL)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
2017-07-02 05:41:23 +00:00
|
|
|
if (test_vec->aad.length != opts->aead_aad_sz)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
2017-02-08 16:04:40 +00:00
|
|
|
if (test_vec->digest.data == NULL)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
2017-07-02 05:41:23 +00:00
|
|
|
if (test_vec->digest.length < opts->digest_sz)
|
2017-01-25 16:27:33 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
struct cperf_options opts = {0};
|
|
|
|
struct cperf_test_vector *t_vec = NULL;
|
|
|
|
struct cperf_op_fns op_fns;
|
|
|
|
void *ctx[RTE_MAX_LCORE] = { };
|
2017-02-10 09:22:32 +00:00
|
|
|
int nb_cryptodevs = 0;
|
2017-10-13 09:20:14 +00:00
|
|
|
uint16_t total_nb_qps = 0;
|
2017-01-25 16:27:33 +00:00
|
|
|
uint8_t cdev_id, i;
|
|
|
|
uint8_t enabled_cdevs[RTE_CRYPTO_MAX_DEVS] = { 0 };
|
|
|
|
|
2017-03-27 11:26:04 +00:00
|
|
|
uint8_t buffer_size_idx = 0;
|
|
|
|
|
2017-01-25 16:27:33 +00:00
|
|
|
int ret;
|
|
|
|
uint32_t lcore_id;
|
|
|
|
|
|
|
|
/* Initialise DPDK EAL */
|
|
|
|
ret = rte_eal_init(argc, argv);
|
|
|
|
if (ret < 0)
|
|
|
|
rte_exit(EXIT_FAILURE, "Invalid EAL arguments!\n");
|
|
|
|
argc -= ret;
|
|
|
|
argv += ret;
|
|
|
|
|
|
|
|
cperf_options_default(&opts);
|
|
|
|
|
|
|
|
ret = cperf_options_parse(&opts, argc, argv);
|
|
|
|
if (ret) {
|
2021-01-18 11:34:10 +00:00
|
|
|
RTE_LOG(ERR, USER1, "Parsing one or more user options failed\n");
|
2017-01-25 16:27:33 +00:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = cperf_options_check(&opts);
|
|
|
|
if (ret) {
|
|
|
|
RTE_LOG(ERR, USER1,
|
2021-01-18 11:34:10 +00:00
|
|
|
"Checking one or more user options failed\n");
|
2017-01-25 16:27:33 +00:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2019-01-10 14:50:13 +00:00
|
|
|
nb_cryptodevs = cperf_initialize_cryptodev(&opts, enabled_cdevs);
|
2017-10-04 03:46:12 +00:00
|
|
|
|
2017-01-25 16:27:33 +00:00
|
|
|
if (!opts.silent)
|
|
|
|
cperf_options_dump(&opts);
|
|
|
|
|
|
|
|
if (nb_cryptodevs < 1) {
|
|
|
|
RTE_LOG(ERR, USER1, "Failed to initialise requested crypto "
|
|
|
|
"device type\n");
|
2017-02-10 09:22:32 +00:00
|
|
|
nb_cryptodevs = 0;
|
2017-01-25 16:27:33 +00:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = cperf_verify_devices_capabilities(&opts, enabled_cdevs,
|
|
|
|
nb_cryptodevs);
|
|
|
|
if (ret) {
|
|
|
|
RTE_LOG(ERR, USER1, "Crypto device type does not support "
|
|
|
|
"capabilities requested\n");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (opts.test_file != NULL) {
|
|
|
|
t_vec = cperf_test_vector_get_from_file(&opts);
|
|
|
|
if (t_vec == NULL) {
|
|
|
|
RTE_LOG(ERR, USER1,
|
|
|
|
"Failed to create test vector for"
|
|
|
|
" specified file\n");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2017-02-08 16:04:40 +00:00
|
|
|
if (cperf_check_test_vector(&opts, t_vec)) {
|
2017-01-25 16:27:33 +00:00
|
|
|
RTE_LOG(ERR, USER1, "Incomplete necessary test vectors"
|
|
|
|
"\n");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
t_vec = cperf_test_vector_get_dummy(&opts);
|
|
|
|
if (t_vec == NULL) {
|
|
|
|
RTE_LOG(ERR, USER1,
|
|
|
|
"Failed to create test vector for"
|
|
|
|
" specified algorithms\n");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = cperf_get_op_functions(&opts, &op_fns);
|
|
|
|
if (ret) {
|
|
|
|
RTE_LOG(ERR, USER1, "Failed to find function ops set for "
|
|
|
|
"specified algorithms combination\n");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2020-04-29 10:57:04 +00:00
|
|
|
if (!opts.silent && opts.test != CPERF_TEST_TYPE_THROUGHPUT &&
|
|
|
|
opts.test != CPERF_TEST_TYPE_LATENCY)
|
2017-01-25 16:27:33 +00:00
|
|
|
show_test_vector(t_vec);
|
|
|
|
|
2017-10-13 09:20:14 +00:00
|
|
|
total_nb_qps = nb_cryptodevs * opts.nb_qps;
|
2017-10-04 03:46:12 +00:00
|
|
|
|
2017-01-25 16:27:33 +00:00
|
|
|
i = 0;
|
2017-10-04 03:46:12 +00:00
|
|
|
uint8_t qp_id = 0, cdev_index = 0;
|
2020-10-15 22:57:19 +00:00
|
|
|
RTE_LCORE_FOREACH_WORKER(lcore_id) {
|
2017-01-25 16:27:33 +00:00
|
|
|
|
2017-10-04 03:46:12 +00:00
|
|
|
if (i == total_nb_qps)
|
2017-01-25 16:27:33 +00:00
|
|
|
break;
|
|
|
|
|
2017-10-04 03:46:12 +00:00
|
|
|
cdev_id = enabled_cdevs[cdev_index];
|
2017-01-25 16:27:33 +00:00
|
|
|
|
2017-07-05 05:26:17 +00:00
|
|
|
uint8_t socket_id = rte_cryptodev_socket_id(cdev_id);
|
|
|
|
|
2017-10-04 03:46:12 +00:00
|
|
|
ctx[i] = cperf_testmap[opts.test].constructor(
|
2019-01-10 14:50:13 +00:00
|
|
|
session_pool_socket[socket_id].sess_mp,
|
|
|
|
session_pool_socket[socket_id].priv_mp,
|
|
|
|
cdev_id, qp_id,
|
2017-01-25 16:27:33 +00:00
|
|
|
&opts, t_vec, &op_fns);
|
2017-10-04 03:46:12 +00:00
|
|
|
if (ctx[i] == NULL) {
|
2017-01-25 16:27:33 +00:00
|
|
|
RTE_LOG(ERR, USER1, "Test run constructor failed\n");
|
|
|
|
goto err;
|
|
|
|
}
|
2017-10-04 03:46:12 +00:00
|
|
|
qp_id = (qp_id + 1) % opts.nb_qps;
|
|
|
|
if (qp_id == 0)
|
|
|
|
cdev_index++;
|
2017-01-25 16:27:33 +00:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2017-12-13 13:14:08 +00:00
|
|
|
if (opts.imix_distribution_count != 0) {
|
|
|
|
uint8_t buffer_size_count = opts.buffer_size_count;
|
|
|
|
uint16_t distribution_total[buffer_size_count];
|
|
|
|
uint32_t op_idx;
|
|
|
|
uint32_t test_average_size = 0;
|
|
|
|
const uint32_t *buffer_size_list = opts.buffer_size_list;
|
|
|
|
const uint32_t *imix_distribution_list = opts.imix_distribution_list;
|
|
|
|
|
|
|
|
opts.imix_buffer_sizes = rte_malloc(NULL,
|
|
|
|
sizeof(uint32_t) * opts.pool_sz,
|
|
|
|
0);
|
|
|
|
/*
|
|
|
|
* Calculate accumulated distribution of
|
|
|
|
* probabilities per packet size
|
|
|
|
*/
|
|
|
|
distribution_total[0] = imix_distribution_list[0];
|
|
|
|
for (i = 1; i < buffer_size_count; i++)
|
|
|
|
distribution_total[i] = imix_distribution_list[i] +
|
|
|
|
distribution_total[i-1];
|
|
|
|
|
|
|
|
/* Calculate a random sequence of packet sizes, based on distribution */
|
|
|
|
for (op_idx = 0; op_idx < opts.pool_sz; op_idx++) {
|
|
|
|
uint16_t random_number = rte_rand() %
|
|
|
|
distribution_total[buffer_size_count - 1];
|
|
|
|
for (i = 0; i < buffer_size_count; i++)
|
|
|
|
if (random_number < distribution_total[i])
|
|
|
|
break;
|
|
|
|
|
|
|
|
opts.imix_buffer_sizes[op_idx] = buffer_size_list[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Calculate average buffer size for the IMIX distribution */
|
|
|
|
for (i = 0; i < buffer_size_count; i++)
|
|
|
|
test_average_size += buffer_size_list[i] *
|
|
|
|
imix_distribution_list[i];
|
|
|
|
|
|
|
|
opts.test_buffer_size = test_average_size /
|
|
|
|
distribution_total[buffer_size_count - 1];
|
2017-01-25 16:27:33 +00:00
|
|
|
|
2017-03-27 11:26:04 +00:00
|
|
|
i = 0;
|
2020-10-15 22:57:19 +00:00
|
|
|
RTE_LCORE_FOREACH_WORKER(lcore_id) {
|
2017-01-25 16:27:33 +00:00
|
|
|
|
2017-10-04 03:46:12 +00:00
|
|
|
if (i == total_nb_qps)
|
2017-03-27 11:26:04 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
rte_eal_remote_launch(cperf_testmap[opts.test].runner,
|
2017-10-04 03:46:12 +00:00
|
|
|
ctx[i], lcore_id);
|
2017-03-27 11:26:04 +00:00
|
|
|
i++;
|
|
|
|
}
|
2017-06-14 08:44:33 +00:00
|
|
|
i = 0;
|
2020-10-15 22:57:19 +00:00
|
|
|
RTE_LCORE_FOREACH_WORKER(lcore_id) {
|
2017-06-14 08:44:33 +00:00
|
|
|
|
2017-10-04 03:46:12 +00:00
|
|
|
if (i == total_nb_qps)
|
2017-06-14 08:44:33 +00:00
|
|
|
break;
|
2019-06-14 20:56:45 +00:00
|
|
|
ret |= rte_eal_wait_lcore(lcore_id);
|
2017-06-14 08:44:33 +00:00
|
|
|
i++;
|
|
|
|
}
|
2019-06-14 20:56:45 +00:00
|
|
|
|
|
|
|
if (ret != EXIT_SUCCESS)
|
|
|
|
goto err;
|
2017-12-13 13:14:08 +00:00
|
|
|
} else {
|
2017-03-27 11:26:04 +00:00
|
|
|
|
|
|
|
/* Get next size from range or list */
|
|
|
|
if (opts.inc_buffer_size != 0)
|
2017-12-13 13:14:08 +00:00
|
|
|
opts.test_buffer_size = opts.min_buffer_size;
|
|
|
|
else
|
|
|
|
opts.test_buffer_size = opts.buffer_size_list[0];
|
|
|
|
|
|
|
|
while (opts.test_buffer_size <= opts.max_buffer_size) {
|
|
|
|
i = 0;
|
2020-10-15 22:57:19 +00:00
|
|
|
RTE_LCORE_FOREACH_WORKER(lcore_id) {
|
2017-12-13 13:14:08 +00:00
|
|
|
|
2018-01-23 14:22:55 +00:00
|
|
|
if (i == total_nb_qps)
|
2017-12-13 13:14:08 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
rte_eal_remote_launch(cperf_testmap[opts.test].runner,
|
2018-01-23 14:22:55 +00:00
|
|
|
ctx[i], lcore_id);
|
2017-12-13 13:14:08 +00:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
i = 0;
|
2020-10-15 22:57:19 +00:00
|
|
|
RTE_LCORE_FOREACH_WORKER(lcore_id) {
|
2017-12-13 13:14:08 +00:00
|
|
|
|
2018-01-23 14:22:55 +00:00
|
|
|
if (i == total_nb_qps)
|
2017-12-13 13:14:08 +00:00
|
|
|
break;
|
2019-06-14 20:56:45 +00:00
|
|
|
ret |= rte_eal_wait_lcore(lcore_id);
|
2017-12-13 13:14:08 +00:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2019-06-14 20:56:45 +00:00
|
|
|
if (ret != EXIT_SUCCESS)
|
|
|
|
goto err;
|
|
|
|
|
2017-12-13 13:14:08 +00:00
|
|
|
/* Get next size from range or list */
|
|
|
|
if (opts.inc_buffer_size != 0)
|
|
|
|
opts.test_buffer_size += opts.inc_buffer_size;
|
|
|
|
else {
|
|
|
|
if (++buffer_size_idx == opts.buffer_size_count)
|
|
|
|
break;
|
|
|
|
opts.test_buffer_size =
|
|
|
|
opts.buffer_size_list[buffer_size_idx];
|
|
|
|
}
|
2017-03-27 11:26:04 +00:00
|
|
|
}
|
2017-01-25 16:27:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
i = 0;
|
2020-10-15 22:57:19 +00:00
|
|
|
RTE_LCORE_FOREACH_WORKER(lcore_id) {
|
2017-01-25 16:27:33 +00:00
|
|
|
|
2017-10-04 03:46:12 +00:00
|
|
|
if (i == total_nb_qps)
|
2017-01-25 16:27:33 +00:00
|
|
|
break;
|
|
|
|
|
2017-10-04 03:46:12 +00:00
|
|
|
cperf_testmap[opts.test].destructor(ctx[i]);
|
2017-01-25 16:27:33 +00:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2017-10-04 03:46:12 +00:00
|
|
|
for (i = 0; i < nb_cryptodevs &&
|
2021-04-09 12:13:01 +00:00
|
|
|
i < RTE_CRYPTO_MAX_DEVS; i++) {
|
2017-10-04 03:46:12 +00:00
|
|
|
rte_cryptodev_stop(enabled_cdevs[i]);
|
2021-04-09 12:13:01 +00:00
|
|
|
ret = rte_cryptodev_close(enabled_cdevs[i]);
|
|
|
|
if (ret)
|
|
|
|
RTE_LOG(ERR, USER1,
|
|
|
|
"Crypto device close error %d\n", ret);
|
|
|
|
}
|
2017-10-04 03:46:12 +00:00
|
|
|
|
2017-01-25 16:27:33 +00:00
|
|
|
free_test_vector(t_vec, &opts);
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
|
|
|
|
err:
|
|
|
|
i = 0;
|
2020-10-15 22:57:19 +00:00
|
|
|
RTE_LCORE_FOREACH_WORKER(lcore_id) {
|
2017-10-04 03:46:12 +00:00
|
|
|
if (i == total_nb_qps)
|
2017-01-25 16:27:33 +00:00
|
|
|
break;
|
|
|
|
|
2017-10-04 03:46:12 +00:00
|
|
|
if (ctx[i] && cperf_testmap[opts.test].destructor)
|
|
|
|
cperf_testmap[opts.test].destructor(ctx[i]);
|
2017-01-25 16:27:33 +00:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2017-10-04 03:46:12 +00:00
|
|
|
for (i = 0; i < nb_cryptodevs &&
|
2021-04-09 12:13:01 +00:00
|
|
|
i < RTE_CRYPTO_MAX_DEVS; i++) {
|
2017-10-04 03:46:12 +00:00
|
|
|
rte_cryptodev_stop(enabled_cdevs[i]);
|
2021-04-09 12:13:01 +00:00
|
|
|
ret = rte_cryptodev_close(enabled_cdevs[i]);
|
|
|
|
if (ret)
|
|
|
|
RTE_LOG(ERR, USER1,
|
|
|
|
"Crypto device close error %d\n", ret);
|
|
|
|
|
|
|
|
}
|
2017-12-13 13:14:08 +00:00
|
|
|
rte_free(opts.imix_buffer_sizes);
|
2017-01-25 16:27:33 +00:00
|
|
|
free_test_vector(t_vec, &opts);
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|