examples/ipsec_secgw: create session mempools for ethdevs
Also moved offloaded packets from cryptodev queues Signed-off-by: Radu Nicolau <radu.nicolau@intel.com> Reviewed-by: Akhil Goyal <akhil.goyal@nxp.com>
This commit is contained in:
parent
d3ec528ffc
commit
3da37f6821
@ -1354,7 +1354,7 @@ cryptodevs_init(void)
|
|||||||
struct rte_cryptodev_config dev_conf;
|
struct rte_cryptodev_config dev_conf;
|
||||||
struct rte_cryptodev_qp_conf qp_conf;
|
struct rte_cryptodev_qp_conf qp_conf;
|
||||||
uint16_t idx, max_nb_qps, qp, i;
|
uint16_t idx, max_nb_qps, qp, i;
|
||||||
int16_t cdev_id;
|
int16_t cdev_id, port_id;
|
||||||
struct rte_hash_parameters params = { 0 };
|
struct rte_hash_parameters params = { 0 };
|
||||||
|
|
||||||
params.entries = CDEV_MAP_ENTRIES;
|
params.entries = CDEV_MAP_ENTRIES;
|
||||||
@ -1383,6 +1383,14 @@ cryptodevs_init(void)
|
|||||||
if (sess_sz > max_sess_sz)
|
if (sess_sz > max_sess_sz)
|
||||||
max_sess_sz = sess_sz;
|
max_sess_sz = sess_sz;
|
||||||
}
|
}
|
||||||
|
for (port_id = 0; port_id < rte_eth_dev_count(); port_id++) {
|
||||||
|
if ((enabled_port_mask & (1 << port_id)) == 0)
|
||||||
|
continue;
|
||||||
|
sess_sz = rte_security_session_get_size(
|
||||||
|
rte_eth_dev_get_sec_ctx(port_id));
|
||||||
|
if (sess_sz > max_sess_sz)
|
||||||
|
max_sess_sz = sess_sz;
|
||||||
|
}
|
||||||
|
|
||||||
idx = 0;
|
idx = 0;
|
||||||
for (cdev_id = 0; cdev_id < rte_cryptodev_count(); cdev_id++) {
|
for (cdev_id = 0; cdev_id < rte_cryptodev_count(); cdev_id++) {
|
||||||
@ -1455,6 +1463,38 @@ cryptodevs_init(void)
|
|||||||
cdev_id);
|
cdev_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* create session pools for eth devices that implement security */
|
||||||
|
for (port_id = 0; port_id < rte_eth_dev_count(); port_id++) {
|
||||||
|
if ((enabled_port_mask & (1 << port_id)) &&
|
||||||
|
rte_eth_dev_get_sec_ctx(port_id)) {
|
||||||
|
int socket_id = rte_eth_dev_socket_id(port_id);
|
||||||
|
|
||||||
|
if (!socket_ctx[socket_id].session_pool) {
|
||||||
|
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,
|
||||||
|
CDEV_MP_NB_OBJS,
|
||||||
|
max_sess_sz,
|
||||||
|
CDEV_MP_CACHE_SZ,
|
||||||
|
0, NULL, NULL, NULL,
|
||||||
|
NULL, socket_id,
|
||||||
|
0);
|
||||||
|
if (sess_mp == NULL)
|
||||||
|
rte_exit(EXIT_FAILURE,
|
||||||
|
"Cannot create session pool "
|
||||||
|
"on socket %d\n", socket_id);
|
||||||
|
else
|
||||||
|
printf("Allocated session pool "
|
||||||
|
"on socket %d\n", socket_id);
|
||||||
|
socket_ctx[socket_id].session_pool = sess_mp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -368,7 +368,6 @@ ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx,
|
|||||||
struct ipsec_mbuf_metadata *priv;
|
struct ipsec_mbuf_metadata *priv;
|
||||||
struct rte_crypto_sym_op *sym_cop;
|
struct rte_crypto_sym_op *sym_cop;
|
||||||
struct ipsec_sa *sa;
|
struct ipsec_sa *sa;
|
||||||
struct cdev_qp *cqp;
|
|
||||||
|
|
||||||
for (i = 0; i < nb_pkts; i++) {
|
for (i = 0; i < nb_pkts; i++) {
|
||||||
if (unlikely(sas[i] == NULL)) {
|
if (unlikely(sas[i] == NULL)) {
|
||||||
@ -431,8 +430,7 @@ ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
cqp = &ipsec_ctx->tbl[sa->cdev_id_qp];
|
ipsec_ctx->ol_pkts[ipsec_ctx->ol_pkts_cnt++] = pkts[i];
|
||||||
cqp->ol_pkts[cqp->ol_pkts_cnt++] = pkts[i];
|
|
||||||
if (sa->ol_flags & RTE_SECURITY_TX_OLOAD_NEED_MDATA)
|
if (sa->ol_flags & RTE_SECURITY_TX_OLOAD_NEED_MDATA)
|
||||||
rte_security_set_pkt_metadata(
|
rte_security_set_pkt_metadata(
|
||||||
sa->security_ctx,
|
sa->security_ctx,
|
||||||
@ -459,8 +457,7 @@ ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
cqp = &ipsec_ctx->tbl[sa->cdev_id_qp];
|
ipsec_ctx->ol_pkts[ipsec_ctx->ol_pkts_cnt++] = pkts[i];
|
||||||
cqp->ol_pkts[cqp->ol_pkts_cnt++] = pkts[i];
|
|
||||||
if (sa->ol_flags & RTE_SECURITY_TX_OLOAD_NEED_MDATA)
|
if (sa->ol_flags & RTE_SECURITY_TX_OLOAD_NEED_MDATA)
|
||||||
rte_security_set_pkt_metadata(
|
rte_security_set_pkt_metadata(
|
||||||
sa->security_ctx,
|
sa->security_ctx,
|
||||||
@ -485,11 +482,10 @@ ipsec_dequeue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx,
|
|||||||
|
|
||||||
for (i = 0; i < ipsec_ctx->nb_qps && nb_pkts < max_pkts;) {
|
for (i = 0; i < ipsec_ctx->nb_qps && nb_pkts < max_pkts;) {
|
||||||
struct cdev_qp *cqp;
|
struct cdev_qp *cqp;
|
||||||
|
|
||||||
cqp = &ipsec_ctx->tbl[ipsec_ctx->last_qp];
|
cqp = &ipsec_ctx->tbl[ipsec_ctx->last_qp];
|
||||||
|
|
||||||
while (cqp->ol_pkts_cnt > 0 && nb_pkts < max_pkts) {
|
while (ipsec_ctx->ol_pkts_cnt > 0 && nb_pkts < max_pkts) {
|
||||||
pkt = cqp->ol_pkts[--cqp->ol_pkts_cnt];
|
pkt = ipsec_ctx->ol_pkts[--ipsec_ctx->ol_pkts_cnt];
|
||||||
rte_prefetch0(pkt);
|
rte_prefetch0(pkt);
|
||||||
priv = get_priv(pkt);
|
priv = get_priv(pkt);
|
||||||
sa = priv->sa;
|
sa = priv->sa;
|
||||||
|
@ -130,8 +130,6 @@ struct cdev_qp {
|
|||||||
uint16_t in_flight;
|
uint16_t in_flight;
|
||||||
uint16_t len;
|
uint16_t len;
|
||||||
struct rte_crypto_op *buf[MAX_PKT_BURST] __rte_aligned(sizeof(void *));
|
struct rte_crypto_op *buf[MAX_PKT_BURST] __rte_aligned(sizeof(void *));
|
||||||
struct rte_mbuf *ol_pkts[MAX_PKT_BURST] __rte_aligned(sizeof(void *));
|
|
||||||
uint16_t ol_pkts_cnt;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ipsec_ctx {
|
struct ipsec_ctx {
|
||||||
@ -143,6 +141,8 @@ struct ipsec_ctx {
|
|||||||
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 rte_mempool *session_pool;
|
||||||
|
struct rte_mbuf *ol_pkts[MAX_PKT_BURST] __rte_aligned(sizeof(void *));
|
||||||
|
uint16_t ol_pkts_cnt;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cdev_key {
|
struct cdev_key {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user