cryptodev: do not create session mempool internally
Instead of creating the session mempool while configuring the crypto device, apps will create the mempool themselves. This way, it gives flexibility to the user to have a single mempool for all devices (as long as the objects are big enough to contain the biggest private session size) or separate mempools for different drivers. Also, since the mempool is now created outside the device configuration function, now it needs to be passed through this function, which will be eventually passed when setting up the queue pairs, as ethernet devices do. Signed-off-by: Slawomir Mrozowicz <slawomirx.mrozowicz@intel.com> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com> Acked-by: Declan Doherty <declan.doherty@intel.com> Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
This commit is contained in:
parent
e2acaa0a45
commit
2c59bd32b7
@ -43,6 +43,9 @@
|
|||||||
#include "cperf_test_latency.h"
|
#include "cperf_test_latency.h"
|
||||||
#include "cperf_test_verify.h"
|
#include "cperf_test_verify.h"
|
||||||
|
|
||||||
|
#define NUM_SESSIONS 2048
|
||||||
|
#define SESS_MEMPOOL_CACHE_SIZE 64
|
||||||
|
|
||||||
const char *cperf_test_type_strs[] = {
|
const char *cperf_test_type_strs[] = {
|
||||||
[CPERF_TEST_TYPE_THROUGHPUT] = "throughput",
|
[CPERF_TEST_TYPE_THROUGHPUT] = "throughput",
|
||||||
[CPERF_TEST_TYPE_LATENCY] = "latency",
|
[CPERF_TEST_TYPE_LATENCY] = "latency",
|
||||||
@ -76,9 +79,11 @@ const struct cperf_test cperf_testmap[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs)
|
cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs,
|
||||||
|
struct rte_mempool *session_pool_socket[])
|
||||||
{
|
{
|
||||||
uint8_t cdev_id, enabled_cdev_count = 0, nb_lcores;
|
uint8_t enabled_cdev_count = 0, nb_lcores, cdev_id;
|
||||||
|
unsigned int i;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
enabled_cdev_count = rte_cryptodev_devices_get(opts->device_type,
|
enabled_cdev_count = rte_cryptodev_devices_get(opts->device_type,
|
||||||
@ -98,40 +103,76 @@ cperf_initialize_cryptodev(struct cperf_options *opts, uint8_t *enabled_cdevs)
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (cdev_id = 0; cdev_id < enabled_cdev_count &&
|
/* Create a mempool shared by all the devices */
|
||||||
cdev_id < RTE_CRYPTO_MAX_DEVS; cdev_id++) {
|
uint32_t max_sess_size = 0, sess_size;
|
||||||
|
|
||||||
|
for (cdev_id = 0; cdev_id < rte_cryptodev_count(); cdev_id++) {
|
||||||
|
sess_size = sizeof(struct rte_cryptodev_sym_session) +
|
||||||
|
rte_cryptodev_get_private_session_size(cdev_id);
|
||||||
|
if (sess_size > max_sess_size)
|
||||||
|
max_sess_size = sess_size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (i = 0; i < enabled_cdev_count &&
|
||||||
|
i < RTE_CRYPTO_MAX_DEVS; i++) {
|
||||||
|
cdev_id = enabled_cdevs[i];
|
||||||
|
uint8_t socket_id = rte_cryptodev_socket_id(cdev_id);
|
||||||
|
|
||||||
struct rte_cryptodev_config conf = {
|
struct rte_cryptodev_config conf = {
|
||||||
.nb_queue_pairs = 1,
|
.nb_queue_pairs = 1,
|
||||||
.socket_id = SOCKET_ID_ANY,
|
.socket_id = socket_id
|
||||||
.session_mp = {
|
};
|
||||||
.nb_objs = 2048,
|
|
||||||
.cache_size = 64
|
|
||||||
}
|
|
||||||
};
|
|
||||||
struct rte_cryptodev_qp_conf qp_conf = {
|
struct rte_cryptodev_qp_conf qp_conf = {
|
||||||
.nb_descriptors = 2048
|
.nb_descriptors = 2048
|
||||||
};
|
};
|
||||||
|
|
||||||
ret = rte_cryptodev_configure(enabled_cdevs[cdev_id], &conf);
|
|
||||||
|
if (session_pool_socket[socket_id] == NULL) {
|
||||||
|
char mp_name[RTE_MEMPOOL_NAMESIZE];
|
||||||
|
struct rte_mempool *sess_mp;
|
||||||
|
|
||||||
|
snprintf(mp_name, RTE_MEMPOOL_NAMESIZE,
|
||||||
|
"sess_mp_%u", socket_id);
|
||||||
|
|
||||||
|
sess_mp = rte_mempool_create(mp_name,
|
||||||
|
NUM_SESSIONS,
|
||||||
|
max_sess_size,
|
||||||
|
SESS_MEMPOOL_CACHE_SIZE,
|
||||||
|
0, NULL, NULL, NULL,
|
||||||
|
NULL, socket_id,
|
||||||
|
0);
|
||||||
|
|
||||||
|
if (sess_mp == NULL) {
|
||||||
|
printf("Cannot create session pool on socket %d\n",
|
||||||
|
socket_id);
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Allocated session pool on socket %d\n", socket_id);
|
||||||
|
session_pool_socket[socket_id] = sess_mp;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = rte_cryptodev_configure(cdev_id, &conf,
|
||||||
|
session_pool_socket[socket_id]);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
printf("Failed to configure cryptodev %u",
|
printf("Failed to configure cryptodev %u", cdev_id);
|
||||||
enabled_cdevs[cdev_id]);
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = rte_cryptodev_queue_pair_setup(enabled_cdevs[cdev_id], 0,
|
ret = rte_cryptodev_queue_pair_setup(cdev_id, 0, &qp_conf,
|
||||||
&qp_conf, SOCKET_ID_ANY);
|
socket_id);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
printf("Failed to setup queue pair %u on "
|
printf("Failed to setup queue pair %u on "
|
||||||
"cryptodev %u", 0, cdev_id);
|
"cryptodev %u", 0, cdev_id);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = rte_cryptodev_start(enabled_cdevs[cdev_id]);
|
ret = rte_cryptodev_start(cdev_id);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
printf("Failed to start device %u: error %d\n",
|
printf("Failed to start device %u: error %d\n",
|
||||||
enabled_cdevs[cdev_id], ret);
|
cdev_id, ret);
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -339,6 +380,7 @@ main(int argc, char **argv)
|
|||||||
struct cperf_op_fns op_fns;
|
struct cperf_op_fns op_fns;
|
||||||
|
|
||||||
void *ctx[RTE_MAX_LCORE] = { };
|
void *ctx[RTE_MAX_LCORE] = { };
|
||||||
|
struct rte_mempool *session_pool_socket[RTE_MAX_NUMA_NODES] = { 0 };
|
||||||
|
|
||||||
int nb_cryptodevs = 0;
|
int nb_cryptodevs = 0;
|
||||||
uint8_t cdev_id, i;
|
uint8_t cdev_id, i;
|
||||||
@ -374,7 +416,8 @@ main(int argc, char **argv)
|
|||||||
if (!opts.silent)
|
if (!opts.silent)
|
||||||
cperf_options_dump(&opts);
|
cperf_options_dump(&opts);
|
||||||
|
|
||||||
nb_cryptodevs = cperf_initialize_cryptodev(&opts, enabled_cdevs);
|
nb_cryptodevs = cperf_initialize_cryptodev(&opts, enabled_cdevs,
|
||||||
|
session_pool_socket);
|
||||||
if (nb_cryptodevs < 1) {
|
if (nb_cryptodevs < 1) {
|
||||||
RTE_LOG(ERR, USER1, "Failed to initialise requested crypto "
|
RTE_LOG(ERR, USER1, "Failed to initialise requested crypto "
|
||||||
"device type\n");
|
"device type\n");
|
||||||
|
@ -217,6 +217,8 @@ API Changes
|
|||||||
by the new function ``rte_crypto_count_by_driver()``.
|
by the new function ``rte_crypto_count_by_driver()``.
|
||||||
* Moved crypto device driver names definitions to the particular PMDs.
|
* Moved crypto device driver names definitions to the particular PMDs.
|
||||||
These names are not public anymore.
|
These names are not public anymore.
|
||||||
|
* ``rte_cryptodev_configure()`` does not create the session mempool
|
||||||
|
for the device anymore.
|
||||||
|
|
||||||
|
|
||||||
ABI Changes
|
ABI Changes
|
||||||
@ -252,6 +254,8 @@ ABI Changes
|
|||||||
``rte_cryptodev_info``, ``rte_cryptodev`` and ``rte_cryptodev_sym_session``
|
``rte_cryptodev_info``, ``rte_cryptodev`` and ``rte_cryptodev_sym_session``
|
||||||
structures.
|
structures.
|
||||||
|
|
||||||
|
* Removed ``session_mp`` from ``rte_cryptodev_config``.
|
||||||
|
|
||||||
|
|
||||||
Shared Library Versions
|
Shared Library Versions
|
||||||
-----------------------
|
-----------------------
|
||||||
|
@ -85,10 +85,8 @@ scheduler_attach_init_slave(struct rte_cryptodev *dev)
|
|||||||
/** Configure device */
|
/** Configure device */
|
||||||
static int
|
static int
|
||||||
scheduler_pmd_config(struct rte_cryptodev *dev,
|
scheduler_pmd_config(struct rte_cryptodev *dev,
|
||||||
struct rte_cryptodev_config *config)
|
struct rte_cryptodev_config *config __rte_unused)
|
||||||
{
|
{
|
||||||
struct scheduler_ctx *sched_ctx = dev->data->dev_private;
|
|
||||||
uint32_t i;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* although scheduler_attach_init_slave presents multiple times,
|
/* although scheduler_attach_init_slave presents multiple times,
|
||||||
@ -98,14 +96,6 @@ scheduler_pmd_config(struct rte_cryptodev *dev,
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
for (i = 0; i < sched_ctx->nb_slaves; i++) {
|
|
||||||
uint8_t slave_dev_id = sched_ctx->slaves[i].dev_id;
|
|
||||||
|
|
||||||
ret = rte_cryptodev_configure(slave_dev_id, config);
|
|
||||||
if (ret < 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -710,10 +710,12 @@ main_loop(__attribute__((unused)) void *dummy)
|
|||||||
qconf->inbound.sp6_ctx = socket_ctx[socket_id].sp_ip6_in;
|
qconf->inbound.sp6_ctx = socket_ctx[socket_id].sp_ip6_in;
|
||||||
qconf->inbound.sa_ctx = socket_ctx[socket_id].sa_in;
|
qconf->inbound.sa_ctx = socket_ctx[socket_id].sa_in;
|
||||||
qconf->inbound.cdev_map = cdev_map_in;
|
qconf->inbound.cdev_map = cdev_map_in;
|
||||||
|
qconf->inbound.session_pool = socket_ctx[socket_id].session_pool;
|
||||||
qconf->outbound.sp4_ctx = socket_ctx[socket_id].sp_ip4_out;
|
qconf->outbound.sp4_ctx = socket_ctx[socket_id].sp_ip4_out;
|
||||||
qconf->outbound.sp6_ctx = socket_ctx[socket_id].sp_ip6_out;
|
qconf->outbound.sp6_ctx = socket_ctx[socket_id].sp_ip6_out;
|
||||||
qconf->outbound.sa_ctx = socket_ctx[socket_id].sa_out;
|
qconf->outbound.sa_ctx = socket_ctx[socket_id].sa_out;
|
||||||
qconf->outbound.cdev_map = cdev_map_out;
|
qconf->outbound.cdev_map = cdev_map_out;
|
||||||
|
qconf->outbound.session_pool = socket_ctx[socket_id].session_pool;
|
||||||
|
|
||||||
if (qconf->nb_rx_queue == 0) {
|
if (qconf->nb_rx_queue == 0) {
|
||||||
RTE_LOG(INFO, IPSEC, "lcore %u has nothing to do\n", lcore_id);
|
RTE_LOG(INFO, IPSEC, "lcore %u has nothing to do\n", lcore_id);
|
||||||
@ -1238,6 +1240,14 @@ cryptodevs_init(void)
|
|||||||
|
|
||||||
printf("lcore/cryptodev/qp mappings:\n");
|
printf("lcore/cryptodev/qp mappings:\n");
|
||||||
|
|
||||||
|
uint32_t max_sess_sz = 0, sess_sz;
|
||||||
|
for (cdev_id = 0; cdev_id < rte_cryptodev_count(); cdev_id++) {
|
||||||
|
sess_sz = sizeof(struct rte_cryptodev_sym_session) +
|
||||||
|
rte_cryptodev_get_private_session_size(cdev_id);
|
||||||
|
if (sess_sz > max_sess_sz)
|
||||||
|
max_sess_sz = sess_sz;
|
||||||
|
}
|
||||||
|
|
||||||
idx = 0;
|
idx = 0;
|
||||||
/* Start from last cdev id to give HW priority */
|
/* Start from last cdev id to give HW priority */
|
||||||
for (cdev_id = rte_cryptodev_count() - 1; cdev_id >= 0; cdev_id--) {
|
for (cdev_id = rte_cryptodev_count() - 1; cdev_id >= 0; cdev_id--) {
|
||||||
@ -1266,11 +1276,33 @@ cryptodevs_init(void)
|
|||||||
|
|
||||||
dev_conf.socket_id = rte_cryptodev_socket_id(cdev_id);
|
dev_conf.socket_id = rte_cryptodev_socket_id(cdev_id);
|
||||||
dev_conf.nb_queue_pairs = qp;
|
dev_conf.nb_queue_pairs = qp;
|
||||||
dev_conf.session_mp.nb_objs = CDEV_MP_NB_OBJS;
|
|
||||||
dev_conf.session_mp.cache_size = CDEV_MP_CACHE_SZ;
|
|
||||||
|
|
||||||
if (rte_cryptodev_configure(cdev_id, &dev_conf))
|
if (!socket_ctx[dev_conf.socket_id].session_pool) {
|
||||||
rte_panic("Failed to initialize crypodev %u\n",
|
char mp_name[RTE_MEMPOOL_NAMESIZE];
|
||||||
|
struct rte_mempool *sess_mp;
|
||||||
|
|
||||||
|
snprintf(mp_name, RTE_MEMPOOL_NAMESIZE,
|
||||||
|
"sess_mp_%u", dev_conf.socket_id);
|
||||||
|
sess_mp = rte_mempool_create(mp_name,
|
||||||
|
CDEV_MP_NB_OBJS,
|
||||||
|
max_sess_sz,
|
||||||
|
CDEV_MP_CACHE_SZ,
|
||||||
|
0, NULL, NULL, NULL,
|
||||||
|
NULL, dev_conf.socket_id,
|
||||||
|
0);
|
||||||
|
if (sess_mp == NULL)
|
||||||
|
rte_exit(EXIT_FAILURE,
|
||||||
|
"Cannot create session pool on socket %d\n",
|
||||||
|
dev_conf.socket_id);
|
||||||
|
else
|
||||||
|
printf("Allocated session pool on socket %d\n",
|
||||||
|
dev_conf.socket_id);
|
||||||
|
socket_ctx[dev_conf.socket_id].session_pool = sess_mp;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rte_cryptodev_configure(cdev_id, &dev_conf,
|
||||||
|
socket_ctx[dev_conf.socket_id].session_pool))
|
||||||
|
rte_panic("Failed to initialize cryptodev %u\n",
|
||||||
cdev_id);
|
cdev_id);
|
||||||
|
|
||||||
qp_conf.nb_descriptors = CDEV_QUEUE_DESC;
|
qp_conf.nb_descriptors = CDEV_QUEUE_DESC;
|
||||||
@ -1433,7 +1465,7 @@ main(int32_t argc, char **argv)
|
|||||||
|
|
||||||
nb_lcores = rte_lcore_count();
|
nb_lcores = rte_lcore_count();
|
||||||
|
|
||||||
/* Replicate each contex per socket */
|
/* Replicate each context per socket */
|
||||||
for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
|
for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
|
||||||
if (rte_lcore_is_enabled(lcore_id) == 0)
|
if (rte_lcore_is_enabled(lcore_id) == 0)
|
||||||
continue;
|
continue;
|
||||||
|
@ -143,6 +143,7 @@ struct ipsec_ctx {
|
|||||||
uint16_t nb_qps;
|
uint16_t nb_qps;
|
||||||
uint16_t last_qp;
|
uint16_t last_qp;
|
||||||
struct cdev_qp tbl[MAX_QP_PER_LCORE];
|
struct cdev_qp tbl[MAX_QP_PER_LCORE];
|
||||||
|
struct rte_mempool *session_pool;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cdev_key {
|
struct cdev_key {
|
||||||
@ -161,6 +162,7 @@ struct socket_ctx {
|
|||||||
struct rt_ctx *rt_ip4;
|
struct rt_ctx *rt_ip4;
|
||||||
struct rt_ctx *rt_ip6;
|
struct rt_ctx *rt_ip6;
|
||||||
struct rte_mempool *mbuf_pool;
|
struct rte_mempool *mbuf_pool;
|
||||||
|
struct rte_mempool *session_pool;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cnt_blk {
|
struct cnt_blk {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*-
|
/*-
|
||||||
* BSD LICENSE
|
* BSD LICENSE
|
||||||
*
|
*
|
||||||
* Copyright(c) 2015-2017 Intel Corporation. All rights reserved.
|
* Copyright(c) 2015-2016 Intel Corporation. All rights reserved.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -88,6 +88,8 @@ enum cdev_type {
|
|||||||
#define MAX_KEY_SIZE 128
|
#define MAX_KEY_SIZE 128
|
||||||
#define MAX_PKT_BURST 32
|
#define MAX_PKT_BURST 32
|
||||||
#define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */
|
#define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */
|
||||||
|
#define MAX_SESSIONS 32
|
||||||
|
#define SESSION_POOL_CACHE_SIZE 0
|
||||||
|
|
||||||
#define MAXIMUM_IV_LENGTH 16
|
#define MAXIMUM_IV_LENGTH 16
|
||||||
#define IV_OFFSET (sizeof(struct rte_crypto_op) + \
|
#define IV_OFFSET (sizeof(struct rte_crypto_op) + \
|
||||||
@ -249,6 +251,7 @@ static const struct rte_eth_conf port_conf = {
|
|||||||
|
|
||||||
struct rte_mempool *l2fwd_pktmbuf_pool;
|
struct rte_mempool *l2fwd_pktmbuf_pool;
|
||||||
struct rte_mempool *l2fwd_crypto_op_pool;
|
struct rte_mempool *l2fwd_crypto_op_pool;
|
||||||
|
struct rte_mempool *session_pool_socket[RTE_MAX_NUMA_NODES] = { 0 };
|
||||||
|
|
||||||
/* Per-port statistics struct */
|
/* Per-port statistics struct */
|
||||||
struct l2fwd_port_statistics {
|
struct l2fwd_port_statistics {
|
||||||
@ -643,8 +646,7 @@ generate_random_key(uint8_t *key, unsigned length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct rte_cryptodev_sym_session *
|
static struct rte_cryptodev_sym_session *
|
||||||
initialize_crypto_session(struct l2fwd_crypto_options *options,
|
initialize_crypto_session(struct l2fwd_crypto_options *options, uint8_t cdev_id)
|
||||||
uint8_t cdev_id)
|
|
||||||
{
|
{
|
||||||
struct rte_crypto_sym_xform *first_xform;
|
struct rte_crypto_sym_xform *first_xform;
|
||||||
|
|
||||||
@ -662,7 +664,6 @@ initialize_crypto_session(struct l2fwd_crypto_options *options,
|
|||||||
first_xform = &options->auth_xform;
|
first_xform = &options->auth_xform;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Setup Cipher Parameters */
|
|
||||||
return rte_cryptodev_sym_session_create(cdev_id, first_xform);
|
return rte_cryptodev_sym_session_create(cdev_id, first_xform);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -684,6 +685,7 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options)
|
|||||||
US_PER_S * BURST_TX_DRAIN_US;
|
US_PER_S * BURST_TX_DRAIN_US;
|
||||||
struct l2fwd_crypto_params *cparams;
|
struct l2fwd_crypto_params *cparams;
|
||||||
struct l2fwd_crypto_params port_cparams[qconf->nb_crypto_devs];
|
struct l2fwd_crypto_params port_cparams[qconf->nb_crypto_devs];
|
||||||
|
struct rte_cryptodev_sym_session *session;
|
||||||
|
|
||||||
if (qconf->nb_rx_ports == 0) {
|
if (qconf->nb_rx_ports == 0) {
|
||||||
RTE_LOG(INFO, L2FWD, "lcore %u has nothing to do\n", lcore_id);
|
RTE_LOG(INFO, L2FWD, "lcore %u has nothing to do\n", lcore_id);
|
||||||
@ -786,11 +788,13 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options)
|
|||||||
options->cipher_iv.length;
|
options->cipher_iv.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
port_cparams[i].session = initialize_crypto_session(options,
|
session = initialize_crypto_session(options,
|
||||||
port_cparams[i].dev_id);
|
port_cparams[i].dev_id);
|
||||||
|
if (session == NULL)
|
||||||
|
rte_exit(EXIT_FAILURE, "Failed to initialize crypto session\n");
|
||||||
|
|
||||||
|
port_cparams[i].session = session;
|
||||||
|
|
||||||
if (port_cparams[i].session == NULL)
|
|
||||||
return;
|
|
||||||
RTE_LOG(INFO, L2FWD, " -- lcoreid=%u cryptoid=%u\n", lcore_id,
|
RTE_LOG(INFO, L2FWD, " -- lcoreid=%u cryptoid=%u\n", lcore_id,
|
||||||
port_cparams[i].dev_id);
|
port_cparams[i].dev_id);
|
||||||
}
|
}
|
||||||
@ -1921,6 +1925,7 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
|
|||||||
{
|
{
|
||||||
unsigned int cdev_id, cdev_count, enabled_cdev_count = 0;
|
unsigned int cdev_id, cdev_count, enabled_cdev_count = 0;
|
||||||
const struct rte_cryptodev_capabilities *cap;
|
const struct rte_cryptodev_capabilities *cap;
|
||||||
|
unsigned int sess_sz, max_sess_sz = 0;
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
cdev_count = rte_cryptodev_count();
|
cdev_count = rte_cryptodev_count();
|
||||||
@ -1929,18 +1934,22 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (cdev_id = 0; cdev_id < cdev_count; cdev_id++) {
|
||||||
|
sess_sz = sizeof(struct rte_cryptodev_sym_session) +
|
||||||
|
rte_cryptodev_get_private_session_size(cdev_id);
|
||||||
|
if (sess_sz > max_sess_sz)
|
||||||
|
max_sess_sz = sess_sz;
|
||||||
|
}
|
||||||
|
|
||||||
for (cdev_id = 0; cdev_id < cdev_count && enabled_cdev_count < nb_ports;
|
for (cdev_id = 0; cdev_id < cdev_count && enabled_cdev_count < nb_ports;
|
||||||
cdev_id++) {
|
cdev_id++) {
|
||||||
struct rte_cryptodev_qp_conf qp_conf;
|
struct rte_cryptodev_qp_conf qp_conf;
|
||||||
struct rte_cryptodev_info dev_info;
|
struct rte_cryptodev_info dev_info;
|
||||||
|
uint8_t socket_id = rte_cryptodev_socket_id(cdev_id);
|
||||||
|
|
||||||
struct rte_cryptodev_config conf = {
|
struct rte_cryptodev_config conf = {
|
||||||
.nb_queue_pairs = 1,
|
.nb_queue_pairs = 1,
|
||||||
.socket_id = SOCKET_ID_ANY,
|
.socket_id = socket_id,
|
||||||
.session_mp = {
|
|
||||||
.nb_objs = 2048,
|
|
||||||
.cache_size = 64
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (check_cryptodev_mask(options, (uint8_t)cdev_id))
|
if (check_cryptodev_mask(options, (uint8_t)cdev_id))
|
||||||
@ -1948,6 +1957,35 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
|
|||||||
|
|
||||||
rte_cryptodev_info_get(cdev_id, &dev_info);
|
rte_cryptodev_info_get(cdev_id, &dev_info);
|
||||||
|
|
||||||
|
if (session_pool_socket[socket_id] == NULL) {
|
||||||
|
char mp_name[RTE_MEMPOOL_NAMESIZE];
|
||||||
|
struct rte_mempool *sess_mp;
|
||||||
|
|
||||||
|
snprintf(mp_name, RTE_MEMPOOL_NAMESIZE,
|
||||||
|
"sess_mp_%u", socket_id);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create enough objects for session headers and
|
||||||
|
* device private data
|
||||||
|
*/
|
||||||
|
sess_mp = rte_mempool_create(mp_name,
|
||||||
|
MAX_SESSIONS * 2,
|
||||||
|
max_sess_sz,
|
||||||
|
SESSION_POOL_CACHE_SIZE,
|
||||||
|
0, NULL, NULL, NULL,
|
||||||
|
NULL, socket_id,
|
||||||
|
0);
|
||||||
|
|
||||||
|
if (sess_mp == NULL) {
|
||||||
|
printf("Cannot create session pool on socket %d\n",
|
||||||
|
socket_id);
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Allocated session pool on socket %d\n", socket_id);
|
||||||
|
session_pool_socket[socket_id] = sess_mp;
|
||||||
|
}
|
||||||
|
|
||||||
/* Set AEAD parameters */
|
/* Set AEAD parameters */
|
||||||
if (options->xform_chain == L2FWD_CRYPTO_AEAD) {
|
if (options->xform_chain == L2FWD_CRYPTO_AEAD) {
|
||||||
/* Check if device supports AEAD algo */
|
/* Check if device supports AEAD algo */
|
||||||
@ -2183,7 +2221,8 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
|
|||||||
cap->sym.auth.digest_size.min;
|
cap->sym.auth.digest_size.min;
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = rte_cryptodev_configure(cdev_id, &conf);
|
retval = rte_cryptodev_configure(cdev_id, &conf,
|
||||||
|
session_pool_socket[socket_id]);
|
||||||
if (retval < 0) {
|
if (retval < 0) {
|
||||||
printf("Failed to configure cryptodev %u", cdev_id);
|
printf("Failed to configure cryptodev %u", cdev_id);
|
||||||
return -1;
|
return -1;
|
||||||
@ -2192,7 +2231,7 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
|
|||||||
qp_conf.nb_descriptors = 2048;
|
qp_conf.nb_descriptors = 2048;
|
||||||
|
|
||||||
retval = rte_cryptodev_queue_pair_setup(cdev_id, 0, &qp_conf,
|
retval = rte_cryptodev_queue_pair_setup(cdev_id, 0, &qp_conf,
|
||||||
SOCKET_ID_ANY);
|
socket_id);
|
||||||
if (retval < 0) {
|
if (retval < 0) {
|
||||||
printf("Failed to setup queue pair %u on cryptodev %u",
|
printf("Failed to setup queue pair %u on cryptodev %u",
|
||||||
0, cdev_id);
|
0, cdev_id);
|
||||||
|
@ -744,12 +744,9 @@ rte_cryptodev_queue_pair_stop(uint8_t dev_id, uint16_t queue_pair_id)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
rte_cryptodev_sym_session_pool_create(struct rte_cryptodev *dev,
|
|
||||||
unsigned nb_objs, unsigned obj_cache_size, int socket_id);
|
|
||||||
|
|
||||||
int
|
int
|
||||||
rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config)
|
rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config,
|
||||||
|
struct rte_mempool *session_pool)
|
||||||
{
|
{
|
||||||
struct rte_cryptodev *dev;
|
struct rte_cryptodev *dev;
|
||||||
int diag;
|
int diag;
|
||||||
@ -769,6 +766,8 @@ rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config)
|
|||||||
|
|
||||||
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_configure, -ENOTSUP);
|
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_configure, -ENOTSUP);
|
||||||
|
|
||||||
|
dev->data->session_pool = session_pool;
|
||||||
|
|
||||||
/* Setup new number of queue pairs and reconfigure device. */
|
/* Setup new number of queue pairs and reconfigure device. */
|
||||||
diag = rte_cryptodev_queue_pairs_config(dev, config->nb_queue_pairs,
|
diag = rte_cryptodev_queue_pairs_config(dev, config->nb_queue_pairs,
|
||||||
config->socket_id);
|
config->socket_id);
|
||||||
@ -778,14 +777,6 @@ rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config)
|
|||||||
return diag;
|
return diag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Setup Session mempool for device */
|
|
||||||
diag = rte_cryptodev_sym_session_pool_create(dev,
|
|
||||||
config->session_mp.nb_objs,
|
|
||||||
config->session_mp.cache_size,
|
|
||||||
config->socket_id);
|
|
||||||
if (diag != 0)
|
|
||||||
return diag;
|
|
||||||
|
|
||||||
return (*dev->dev_ops->dev_configure)(dev, config);
|
return (*dev->dev_ops->dev_configure)(dev, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1104,66 +1095,6 @@ rte_cryptodev_sym_session_init(struct rte_mempool *mp,
|
|||||||
(*dev->dev_ops->session_initialize)(mp, sess);
|
(*dev->dev_ops->session_initialize)(mp, sess);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
rte_cryptodev_sym_session_pool_create(struct rte_cryptodev *dev,
|
|
||||||
unsigned nb_objs, unsigned obj_cache_size, int socket_id)
|
|
||||||
{
|
|
||||||
char mp_name[RTE_CRYPTODEV_NAME_MAX_LEN];
|
|
||||||
unsigned priv_sess_size;
|
|
||||||
|
|
||||||
unsigned n = snprintf(mp_name, sizeof(mp_name), "cdev_%d_sess_mp",
|
|
||||||
dev->data->dev_id);
|
|
||||||
if (n > sizeof(mp_name)) {
|
|
||||||
CDEV_LOG_ERR("Unable to create unique name for session mempool");
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->session_get_size, -ENOTSUP);
|
|
||||||
priv_sess_size = (*dev->dev_ops->session_get_size)(dev);
|
|
||||||
if (priv_sess_size == 0) {
|
|
||||||
CDEV_LOG_ERR("%s returned and invalid private session size ",
|
|
||||||
dev->data->name);
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned elt_size = sizeof(struct rte_cryptodev_sym_session) +
|
|
||||||
priv_sess_size;
|
|
||||||
|
|
||||||
dev->data->session_pool = rte_mempool_lookup(mp_name);
|
|
||||||
if (dev->data->session_pool != NULL) {
|
|
||||||
if ((dev->data->session_pool->elt_size != elt_size) ||
|
|
||||||
(dev->data->session_pool->cache_size <
|
|
||||||
obj_cache_size) ||
|
|
||||||
(dev->data->session_pool->size < nb_objs)) {
|
|
||||||
|
|
||||||
CDEV_LOG_ERR("%s mempool already exists with different"
|
|
||||||
" initialization parameters", mp_name);
|
|
||||||
dev->data->session_pool = NULL;
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
dev->data->session_pool = rte_mempool_create(
|
|
||||||
mp_name, /* mempool name */
|
|
||||||
nb_objs, /* number of elements*/
|
|
||||||
elt_size, /* element size*/
|
|
||||||
obj_cache_size, /* Cache size*/
|
|
||||||
0, /* private data size */
|
|
||||||
NULL, /* obj initialization constructor */
|
|
||||||
NULL, /* obj initialization constructor arg */
|
|
||||||
NULL, /**< obj constructor*/
|
|
||||||
dev, /* obj constructor arg */
|
|
||||||
socket_id, /* socket id */
|
|
||||||
0); /* flags */
|
|
||||||
|
|
||||||
if (dev->data->session_pool == NULL) {
|
|
||||||
CDEV_LOG_ERR("%s mempool allocation failed", mp_name);
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CDEV_LOG_DEBUG("%s mempool created!", mp_name);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct rte_cryptodev_sym_session *
|
struct rte_cryptodev_sym_session *
|
||||||
rte_cryptodev_sym_session_create(uint8_t dev_id,
|
rte_cryptodev_sym_session_create(uint8_t dev_id,
|
||||||
|
@ -514,11 +514,6 @@ struct rte_cryptodev_config {
|
|||||||
int socket_id; /**< Socket to allocate resources on */
|
int socket_id; /**< Socket to allocate resources on */
|
||||||
uint16_t nb_queue_pairs;
|
uint16_t nb_queue_pairs;
|
||||||
/**< Number of queue pairs to configure on device */
|
/**< Number of queue pairs to configure on device */
|
||||||
|
|
||||||
struct {
|
|
||||||
uint32_t nb_objs; /**< Number of objects in mempool */
|
|
||||||
uint32_t cache_size; /**< l-core object cache size */
|
|
||||||
} session_mp; /**< Session mempool configuration */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -530,13 +525,15 @@ struct rte_cryptodev_config {
|
|||||||
*
|
*
|
||||||
* @param dev_id The identifier of the device to configure.
|
* @param dev_id The identifier of the device to configure.
|
||||||
* @param config The crypto device configuration structure.
|
* @param config The crypto device configuration structure.
|
||||||
|
* @param session_pool Pointer to device session mempool
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* - 0: Success, device configured.
|
* - 0: Success, device configured.
|
||||||
* - <0: Error code returned by the driver configuration function.
|
* - <0: Error code returned by the driver configuration function.
|
||||||
*/
|
*/
|
||||||
extern int
|
extern int
|
||||||
rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config);
|
rte_cryptodev_configure(uint8_t dev_id, struct rte_cryptodev_config *config,
|
||||||
|
struct rte_mempool *session_pool);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start an device.
|
* Start an device.
|
||||||
|
@ -67,6 +67,8 @@ struct crypto_testsuite_params {
|
|||||||
struct rte_mempool *mbuf_pool;
|
struct rte_mempool *mbuf_pool;
|
||||||
struct rte_mempool *large_mbuf_pool;
|
struct rte_mempool *large_mbuf_pool;
|
||||||
struct rte_mempool *op_mpool;
|
struct rte_mempool *op_mpool;
|
||||||
|
struct rte_mempool *session_mpool;
|
||||||
|
struct rte_mempool *slave_session_mpool;
|
||||||
struct rte_cryptodev_config conf;
|
struct rte_cryptodev_config conf;
|
||||||
struct rte_cryptodev_qp_conf qp_conf;
|
struct rte_cryptodev_qp_conf qp_conf;
|
||||||
|
|
||||||
@ -384,10 +386,23 @@ testsuite_setup(void)
|
|||||||
|
|
||||||
ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
|
ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
|
||||||
ts_params->conf.socket_id = SOCKET_ID_ANY;
|
ts_params->conf.socket_id = SOCKET_ID_ANY;
|
||||||
ts_params->conf.session_mp.nb_objs = info.sym.max_nb_sessions;
|
|
||||||
|
unsigned int session_size = sizeof(struct rte_cryptodev_sym_session) +
|
||||||
|
rte_cryptodev_get_private_session_size(dev_id);
|
||||||
|
|
||||||
|
ts_params->session_mpool = rte_mempool_create(
|
||||||
|
"test_sess_mp",
|
||||||
|
info.sym.max_nb_sessions,
|
||||||
|
session_size,
|
||||||
|
0, 0, NULL, NULL, NULL,
|
||||||
|
NULL, SOCKET_ID_ANY,
|
||||||
|
0);
|
||||||
|
|
||||||
|
TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
|
||||||
|
"session mempool allocation failed");
|
||||||
|
|
||||||
TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
|
TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
|
||||||
&ts_params->conf),
|
&ts_params->conf, ts_params->session_mpool),
|
||||||
"Failed to configure cryptodev %u with %u qps",
|
"Failed to configure cryptodev %u with %u qps",
|
||||||
dev_id, ts_params->conf.nb_queue_pairs);
|
dev_id, ts_params->conf.nb_queue_pairs);
|
||||||
|
|
||||||
@ -419,6 +434,16 @@ testsuite_teardown(void)
|
|||||||
rte_mempool_avail_count(ts_params->op_mpool));
|
rte_mempool_avail_count(ts_params->op_mpool));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Free session mempools */
|
||||||
|
if (ts_params->session_mpool != NULL) {
|
||||||
|
rte_mempool_free(ts_params->session_mpool);
|
||||||
|
ts_params->session_mpool = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ts_params->slave_session_mpool != NULL) {
|
||||||
|
rte_mempool_free(ts_params->slave_session_mpool);
|
||||||
|
ts_params->slave_session_mpool = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -434,10 +459,9 @@ ut_setup(void)
|
|||||||
|
|
||||||
/* Reconfigure device to default parameters */
|
/* Reconfigure device to default parameters */
|
||||||
ts_params->conf.socket_id = SOCKET_ID_ANY;
|
ts_params->conf.socket_id = SOCKET_ID_ANY;
|
||||||
ts_params->conf.session_mp.nb_objs = DEFAULT_NUM_OPS_INFLIGHT;
|
|
||||||
|
|
||||||
TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
|
TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
|
||||||
&ts_params->conf),
|
&ts_params->conf, ts_params->session_mpool),
|
||||||
"Failed to configure cryptodev %u",
|
"Failed to configure cryptodev %u",
|
||||||
ts_params->valid_devs[0]);
|
ts_params->valid_devs[0]);
|
||||||
|
|
||||||
@ -520,20 +544,23 @@ test_device_configure_invalid_dev_id(void)
|
|||||||
/* Stop the device in case it's started so it can be configured */
|
/* Stop the device in case it's started so it can be configured */
|
||||||
rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
|
rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
|
||||||
|
|
||||||
TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
|
TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf,
|
||||||
|
ts_params->session_mpool),
|
||||||
"Failed test for rte_cryptodev_configure: "
|
"Failed test for rte_cryptodev_configure: "
|
||||||
"invalid dev_num %u", dev_id);
|
"invalid dev_num %u", dev_id);
|
||||||
|
|
||||||
/* invalid dev_id values */
|
/* invalid dev_id values */
|
||||||
dev_id = num_devs;
|
dev_id = num_devs;
|
||||||
|
|
||||||
TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
|
TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf,
|
||||||
|
ts_params->session_mpool),
|
||||||
"Failed test for rte_cryptodev_configure: "
|
"Failed test for rte_cryptodev_configure: "
|
||||||
"invalid dev_num %u", dev_id);
|
"invalid dev_num %u", dev_id);
|
||||||
|
|
||||||
dev_id = 0xff;
|
dev_id = 0xff;
|
||||||
|
|
||||||
TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
|
TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf,
|
||||||
|
ts_params->session_mpool),
|
||||||
"Failed test for rte_cryptodev_configure:"
|
"Failed test for rte_cryptodev_configure:"
|
||||||
"invalid dev_num %u", dev_id);
|
"invalid dev_num %u", dev_id);
|
||||||
|
|
||||||
@ -553,7 +580,7 @@ test_device_configure_invalid_queue_pair_ids(void)
|
|||||||
ts_params->conf.nb_queue_pairs = 1;
|
ts_params->conf.nb_queue_pairs = 1;
|
||||||
|
|
||||||
TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
|
TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
|
||||||
&ts_params->conf),
|
&ts_params->conf, ts_params->session_mpool),
|
||||||
"Failed to configure cryptodev: dev_id %u, qp_id %u",
|
"Failed to configure cryptodev: dev_id %u, qp_id %u",
|
||||||
ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
|
ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
|
||||||
|
|
||||||
@ -562,16 +589,17 @@ test_device_configure_invalid_queue_pair_ids(void)
|
|||||||
ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
|
ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
|
||||||
|
|
||||||
TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
|
TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
|
||||||
&ts_params->conf),
|
&ts_params->conf, ts_params->session_mpool),
|
||||||
"Failed to configure cryptodev: dev_id %u, qp_id %u",
|
"Failed to configure cryptodev: dev_id %u, qp_id %u",
|
||||||
ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
|
ts_params->valid_devs[0],
|
||||||
|
ts_params->conf.nb_queue_pairs);
|
||||||
|
|
||||||
|
|
||||||
/* invalid - zero queue pairs */
|
/* invalid - zero queue pairs */
|
||||||
ts_params->conf.nb_queue_pairs = 0;
|
ts_params->conf.nb_queue_pairs = 0;
|
||||||
|
|
||||||
TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
|
TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
|
||||||
&ts_params->conf),
|
&ts_params->conf, ts_params->session_mpool),
|
||||||
"Failed test for rte_cryptodev_configure, dev_id %u,"
|
"Failed test for rte_cryptodev_configure, dev_id %u,"
|
||||||
" invalid qps: %u",
|
" invalid qps: %u",
|
||||||
ts_params->valid_devs[0],
|
ts_params->valid_devs[0],
|
||||||
@ -582,7 +610,7 @@ test_device_configure_invalid_queue_pair_ids(void)
|
|||||||
ts_params->conf.nb_queue_pairs = UINT16_MAX;
|
ts_params->conf.nb_queue_pairs = UINT16_MAX;
|
||||||
|
|
||||||
TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
|
TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
|
||||||
&ts_params->conf),
|
&ts_params->conf, ts_params->session_mpool),
|
||||||
"Failed test for rte_cryptodev_configure, dev_id %u,"
|
"Failed test for rte_cryptodev_configure, dev_id %u,"
|
||||||
" invalid qps: %u",
|
" invalid qps: %u",
|
||||||
ts_params->valid_devs[0],
|
ts_params->valid_devs[0],
|
||||||
@ -593,7 +621,7 @@ test_device_configure_invalid_queue_pair_ids(void)
|
|||||||
ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
|
ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
|
||||||
|
|
||||||
TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
|
TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
|
||||||
&ts_params->conf),
|
&ts_params->conf, ts_params->session_mpool),
|
||||||
"Failed test for rte_cryptodev_configure, dev_id %u,"
|
"Failed test for rte_cryptodev_configure, dev_id %u,"
|
||||||
" invalid qps: %u",
|
" invalid qps: %u",
|
||||||
ts_params->valid_devs[0],
|
ts_params->valid_devs[0],
|
||||||
@ -622,13 +650,11 @@ test_queue_pair_descriptor_setup(void)
|
|||||||
|
|
||||||
rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
|
rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
|
||||||
|
|
||||||
ts_params->conf.session_mp.nb_objs = dev_info.sym.max_nb_sessions;
|
|
||||||
|
|
||||||
TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
|
TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
|
||||||
&ts_params->conf), "Failed to configure cryptodev %u",
|
&ts_params->conf, ts_params->session_mpool),
|
||||||
|
"Failed to configure cryptodev %u",
|
||||||
ts_params->valid_devs[0]);
|
ts_params->valid_devs[0]);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Test various ring sizes on this device. memzones can't be
|
* Test various ring sizes on this device. memzones can't be
|
||||||
* freed so are re-used if ring is released and re-created.
|
* freed so are re-used if ring is released and re-created.
|
||||||
@ -7683,6 +7709,31 @@ test_scheduler_attach_slave_op(void)
|
|||||||
RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
|
RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create a separate mempool for the slaves, as they need different
|
||||||
|
* session size and then configure them to store the pointer
|
||||||
|
* to this mempool
|
||||||
|
*/
|
||||||
|
unsigned int session_size = sizeof(struct rte_cryptodev_sym_session) +
|
||||||
|
rte_cryptodev_get_private_session_size(i);
|
||||||
|
|
||||||
|
if (ts_params->slave_session_mpool == NULL) {
|
||||||
|
ts_params->slave_session_mpool = rte_mempool_create(
|
||||||
|
"test_slave_sess_mp",
|
||||||
|
info.sym.max_nb_sessions,
|
||||||
|
session_size,
|
||||||
|
0, 0, NULL, NULL, NULL, NULL,
|
||||||
|
SOCKET_ID_ANY, 0);
|
||||||
|
|
||||||
|
TEST_ASSERT_NOT_NULL(ts_params->slave_session_mpool,
|
||||||
|
"session mempool allocation failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_ASSERT_SUCCESS(rte_cryptodev_configure(i,
|
||||||
|
&ts_params->conf, ts_params->slave_session_mpool),
|
||||||
|
"Failed to configure cryptodev %u with %u qps",
|
||||||
|
i, ts_params->conf.nb_queue_pairs);
|
||||||
|
|
||||||
ret = rte_cryptodev_scheduler_slave_attach(sched_id,
|
ret = rte_cryptodev_scheduler_slave_attach(sched_id,
|
||||||
(uint8_t)i);
|
(uint8_t)i);
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@
|
|||||||
struct crypto_testsuite_params {
|
struct crypto_testsuite_params {
|
||||||
struct rte_mempool *mbuf_mp;
|
struct rte_mempool *mbuf_mp;
|
||||||
struct rte_mempool *op_mpool;
|
struct rte_mempool *op_mpool;
|
||||||
|
struct rte_mempool *sess_mp;
|
||||||
|
|
||||||
uint16_t nb_queue_pairs;
|
uint16_t nb_queue_pairs;
|
||||||
|
|
||||||
@ -404,10 +405,23 @@ testsuite_setup(void)
|
|||||||
|
|
||||||
ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
|
ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
|
||||||
ts_params->conf.socket_id = SOCKET_ID_ANY;
|
ts_params->conf.socket_id = SOCKET_ID_ANY;
|
||||||
ts_params->conf.session_mp.nb_objs = info.sym.max_nb_sessions;
|
|
||||||
|
unsigned int session_size = sizeof(struct rte_cryptodev_sym_session) +
|
||||||
|
rte_cryptodev_get_private_session_size(ts_params->dev_id);
|
||||||
|
|
||||||
|
ts_params->sess_mp = rte_mempool_create(
|
||||||
|
"test_sess_mp_perf",
|
||||||
|
info.sym.max_nb_sessions,
|
||||||
|
session_size,
|
||||||
|
0, 0, NULL, NULL, NULL,
|
||||||
|
NULL, SOCKET_ID_ANY,
|
||||||
|
0);
|
||||||
|
|
||||||
|
TEST_ASSERT_NOT_NULL(ts_params->sess_mp,
|
||||||
|
"session mempool allocation failed");
|
||||||
|
|
||||||
TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->dev_id,
|
TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->dev_id,
|
||||||
&ts_params->conf),
|
&ts_params->conf, ts_params->sess_mp),
|
||||||
"Failed to configure cryptodev %u",
|
"Failed to configure cryptodev %u",
|
||||||
ts_params->dev_id);
|
ts_params->dev_id);
|
||||||
|
|
||||||
@ -436,6 +450,12 @@ testsuite_teardown(void)
|
|||||||
if (ts_params->op_mpool != NULL)
|
if (ts_params->op_mpool != NULL)
|
||||||
RTE_LOG(DEBUG, USER1, "CRYPTO_PERF_OP POOL count %u\n",
|
RTE_LOG(DEBUG, USER1, "CRYPTO_PERF_OP POOL count %u\n",
|
||||||
rte_mempool_avail_count(ts_params->op_mpool));
|
rte_mempool_avail_count(ts_params->op_mpool));
|
||||||
|
/* Free session mempool */
|
||||||
|
if (ts_params->sess_mp != NULL) {
|
||||||
|
rte_mempool_free(ts_params->sess_mp);
|
||||||
|
ts_params->sess_mp = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
Reference in New Issue
Block a user