net/softnic: use separate session mempools
This patch uses the two session mempool approach to softnic PMD. One mempool is for session header objects, and the other is for session private data. Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com> Acked-by: Fiona Trahe <fiona.trahe@intel.com> Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
This commit is contained in:
parent
d4ad392cbb
commit
61826a1e48
@ -1092,7 +1092,7 @@ cmd_tap(struct pmd_internals *softnic,
|
||||
|
||||
/**
|
||||
* cryptodev <tap_name> dev <device_name> | dev_id <device_id>
|
||||
* queue <n_queues> <queue_size>
|
||||
* queue <n_queues> <queue_size> max_sessions <n_sessions>
|
||||
**/
|
||||
|
||||
static void
|
||||
@ -1106,7 +1106,7 @@ cmd_cryptodev(struct pmd_internals *softnic,
|
||||
char *name;
|
||||
|
||||
memset(¶ms, 0, sizeof(params));
|
||||
if (n_tokens != 7) {
|
||||
if (n_tokens != 9) {
|
||||
snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
|
||||
return;
|
||||
}
|
||||
@ -1145,6 +1145,19 @@ cmd_cryptodev(struct pmd_internals *softnic,
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcmp(tokens[7], "max_sessions")) {
|
||||
snprintf(out, out_size, MSG_ARG_NOT_FOUND,
|
||||
"4");
|
||||
return;
|
||||
}
|
||||
|
||||
if (softnic_parser_read_uint32(¶ms.session_pool_size, tokens[8])
|
||||
< 0) {
|
||||
snprintf(out, out_size, MSG_ARG_INVALID,
|
||||
"q");
|
||||
return;
|
||||
}
|
||||
|
||||
if (softnic_cryptodev_create(softnic, name, ¶ms) == NULL) {
|
||||
snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
|
||||
return;
|
||||
@ -1739,6 +1752,41 @@ cmd_table_action_profile(struct pmd_internals *softnic,
|
||||
t0 += 1;
|
||||
} /* decap */
|
||||
|
||||
if (t0 < n_tokens && (strcmp(tokens[t0], "sym_crypto") == 0)) {
|
||||
struct softnic_cryptodev *cryptodev;
|
||||
|
||||
if (n_tokens < t0 + 5 ||
|
||||
strcmp(tokens[t0 + 1], "dev") ||
|
||||
strcmp(tokens[t0 + 3], "offset")) {
|
||||
snprintf(out, out_size, MSG_ARG_MISMATCH,
|
||||
"table action profile sym_crypto");
|
||||
return;
|
||||
}
|
||||
|
||||
cryptodev = softnic_cryptodev_find(softnic, tokens[t0 + 2]);
|
||||
if (cryptodev == NULL) {
|
||||
snprintf(out, out_size, MSG_ARG_INVALID,
|
||||
"table action profile sym_crypto");
|
||||
return;
|
||||
}
|
||||
|
||||
p.sym_crypto.cryptodev_id = cryptodev->dev_id;
|
||||
|
||||
if (softnic_parser_read_uint32(&p.sym_crypto.op_offset,
|
||||
tokens[t0 + 4]) != 0) {
|
||||
snprintf(out, out_size, MSG_ARG_INVALID,
|
||||
"table action profile sym_crypto");
|
||||
return;
|
||||
}
|
||||
|
||||
p.sym_crypto.mp_create = cryptodev->mp_create;
|
||||
p.sym_crypto.mp_init = cryptodev->mp_init;
|
||||
|
||||
p.action_mask |= 1LLU << RTE_TABLE_ACTION_SYM_CRYPTO;
|
||||
|
||||
t0 += 5;
|
||||
} /* sym_crypto */
|
||||
|
||||
if (t0 < n_tokens) {
|
||||
snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
|
||||
return;
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
#include "rte_eth_softnic_internals.h"
|
||||
|
||||
#define SOFTNIC_CRYPTO_SESSION_CACHE_SIZE 128
|
||||
|
||||
int
|
||||
softnic_cryptodev_init(struct pmd_internals *p)
|
||||
{
|
||||
@ -61,13 +63,16 @@ softnic_cryptodev_create(struct pmd_internals *p,
|
||||
struct softnic_cryptodev *cryptodev;
|
||||
uint32_t dev_id, i;
|
||||
uint32_t socket_id;
|
||||
uint32_t cache_size;
|
||||
char mp_name[NAME_SIZE];
|
||||
int status;
|
||||
|
||||
/* Check input params */
|
||||
if ((name == NULL) ||
|
||||
softnic_cryptodev_find(p, name) ||
|
||||
(params->n_queues == 0) ||
|
||||
(params->queue_size == 0))
|
||||
(params->queue_size == 0) ||
|
||||
(params->session_pool_size == 0))
|
||||
return NULL;
|
||||
|
||||
if (params->dev_name) {
|
||||
@ -83,6 +88,11 @@ softnic_cryptodev_create(struct pmd_internals *p,
|
||||
dev_id = params->dev_id;
|
||||
}
|
||||
|
||||
cache_size = (params->session_pool_size / 2 <
|
||||
SOFTNIC_CRYPTO_SESSION_CACHE_SIZE) ?
|
||||
(params->session_pool_size / 2) :
|
||||
SOFTNIC_CRYPTO_SESSION_CACHE_SIZE;
|
||||
|
||||
socket_id = rte_cryptodev_socket_id(dev_id);
|
||||
rte_cryptodev_info_get(dev_id, &dev_info);
|
||||
|
||||
@ -119,7 +129,42 @@ softnic_cryptodev_create(struct pmd_internals *p,
|
||||
cryptodev->dev_id = dev_id;
|
||||
cryptodev->n_queues = params->n_queues;
|
||||
|
||||
snprintf(mp_name, NAME_SIZE, "%s_mp%u", name, dev_id);
|
||||
cryptodev->mp_create = rte_cryptodev_sym_session_pool_create(mp_name,
|
||||
params->session_pool_size,
|
||||
0,
|
||||
cache_size,
|
||||
0,
|
||||
socket_id);
|
||||
if (!cryptodev->mp_create)
|
||||
goto error_exit;
|
||||
|
||||
snprintf(mp_name, NAME_SIZE, "%s_priv_mp%u", name, dev_id);
|
||||
cryptodev->mp_init = rte_mempool_create(mp_name,
|
||||
params->session_pool_size,
|
||||
rte_cryptodev_sym_get_private_session_size(dev_id),
|
||||
cache_size,
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
socket_id,
|
||||
0);
|
||||
if (!cryptodev->mp_init)
|
||||
goto error_exit;
|
||||
|
||||
TAILQ_INSERT_TAIL(&p->cryptodev_list, cryptodev, node);
|
||||
|
||||
return cryptodev;
|
||||
|
||||
error_exit:
|
||||
if (cryptodev->mp_create)
|
||||
rte_mempool_free(cryptodev->mp_create);
|
||||
if (cryptodev->mp_init)
|
||||
rte_mempool_free(cryptodev->mp_init);
|
||||
|
||||
free(cryptodev);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -287,6 +287,7 @@ struct softnic_cryptodev_params {
|
||||
uint32_t dev_id; /**< Valid only when *dev_name* is NULL. */
|
||||
uint32_t n_queues;
|
||||
uint32_t queue_size;
|
||||
uint32_t session_pool_size;
|
||||
};
|
||||
|
||||
struct softnic_cryptodev {
|
||||
@ -294,6 +295,8 @@ struct softnic_cryptodev {
|
||||
char name[NAME_SIZE];
|
||||
uint16_t dev_id;
|
||||
uint32_t n_queues;
|
||||
struct rte_mempool *mp_create;
|
||||
struct rte_mempool *mp_init;
|
||||
};
|
||||
|
||||
TAILQ_HEAD(softnic_cryptodev_list, softnic_cryptodev);
|
||||
|
Loading…
x
Reference in New Issue
Block a user