Skip to content

Commit

Permalink
crypto/ipsec_mb: optimize allocation in session
Browse files Browse the repository at this point in the history
[ upstream commit db7dc9070bf42593e3fca5f2f47ac0344e1b5cb6 ]

When configuring the session, use the queue pair mb_mgr that was already
allocated if possible. If this doesn't exist, then allocate a new mb_mgr.

This reduces unnecessary cycles creating an mb_mgr for every session
configured.

Fixes: c75542a ("crypto/ipsec_mb: introduce IPsec_mb framework")

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Signed-off-by: Ciara Power <ciara.power@intel.com>
Acked-by: Kai Ji <kai.ji@intel.com>
  • Loading branch information
ciarapow authored and kevintraynor committed Jul 11, 2023
1 parent 2487cb3 commit f329acb
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions drivers/crypto/ipsec_mb/ipsec_mb_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,15 +319,22 @@ ipsec_mb_sym_session_configure(
struct ipsec_mb_dev_private *internals = dev->data->dev_private;
struct ipsec_mb_internals *pmd_data =
&ipsec_mb_pmds[internals->pmd_type];
IMB_MGR *mb_mgr = alloc_init_mb_mgr();
struct ipsec_mb_qp *qp = dev->data->queue_pairs[0];
IMB_MGR *mb_mgr;
int ret = 0;

if (qp != NULL)
mb_mgr = qp->mb_mgr;
else
mb_mgr = alloc_init_mb_mgr();

if (!mb_mgr)
return -ENOMEM;

if (unlikely(sess == NULL)) {
IPSEC_MB_LOG(ERR, "invalid session struct");
free_mb_mgr(mb_mgr);
if (qp == NULL)
free_mb_mgr(mb_mgr);
return -EINVAL;
}

Expand All @@ -343,13 +350,15 @@ ipsec_mb_sym_session_configure(

/* Return session to mempool */
rte_mempool_put(mempool, sess_private_data);
free_mb_mgr(mb_mgr);
if (qp == NULL)
free_mb_mgr(mb_mgr);
return ret;
}

set_sym_session_private_data(sess, dev->driver_id, sess_private_data);

free_mb_mgr(mb_mgr);
if (qp == NULL)
free_mb_mgr(mb_mgr);
return 0;
}

Expand Down

0 comments on commit f329acb

Please sign in to comment.