Re: [PATCH v4 17/27] net/iavf: avoid rte malloc in VF mailbox for IPsec

Bruce Richardson
2026-02-16T17:19:35Z

On Fri, Feb 13, 2026 at 10:26:28AM +0000, Anatoly Burakov wrote:
> Currently, when calling down into the VF mailbox, IPsec code will use
> dynamic memory allocation (rte_malloc one at that!) to allocate VF message
> structures which are ~40 bytes in size, and then immediately frees them.
> This is wasteful and unnecessary, so use stack allocation instead.
>
> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
> ---
> drivers/net/intel/iavf/iavf_ipsec_crypto.c | 157 +++++++--------------
> 1 file changed, 51 insertions(+), 106 deletions(-)
>
> diff --git a/drivers/net/intel/iavf/iavf_ipsec_crypto.c b/drivers/net/intel/iavf/iavf_ipsec_crypto.c
> index 66eaea8715..cb437d3212 100644
> --- a/drivers/net/intel/iavf/iavf_ipsec_crypto.c
> +++ b/drivers/net/intel/iavf/iavf_ipsec_crypto.c
> @@ -458,36 +458,24 @@ static uint32_t
> iavf_ipsec_crypto_security_association_add(struct iavf_adapter *adapter,
> struct rte_security_session_conf *conf)
> {
> - struct inline_ipsec_msg *request = NULL, *response = NULL;
> - struct virtchnl_ipsec_sa_cfg *sa_cfg;
> - size_t request_len, response_len;
> + struct {
> + struct inline_ipsec_msg msg;
> + struct virtchnl_ipsec_sa_cfg sa_cfg;
> + } sa_req;
> + struct {
> + struct inline_ipsec_msg msg;
> + struct virtchnl_ipsec_sa_cfg_resp sa_cfg_resp;
> + } sa_resp;
> + struct inline_ipsec_msg *request = &sa_req.msg, *response = &sa_resp.msg;

Nit: Split these across two lines, since the assignments are a little long.

Acked-by: Bruce Richardson <bruce.richardson@intel.com>