[PATCH v9 18/26] net/iavf: avoid rte malloc in VF mailbox for IPsec

Anatoly Burakov
2026-02-24T15:16:58Z

Currently, when calling down into the VF mailbox, IPsec code will use
rte_malloc to allocate VF message structures. This memory does not need
to be stored in hugepage memory and the allocation size is pretty small,
so replace it with regular malloc/free.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
drivers/net/intel/iavf/iavf_ipsec_crypto.c | 60 ++++++++++------------
1 file changed, 28 insertions(+), 32 deletions(-)

diff --git a/drivers/net/intel/iavf/iavf_ipsec_crypto.c b/drivers/net/intel/iavf/iavf_ipsec_crypto.c
index 82323b9aa9..fe540e76cb 100644
--- a/drivers/net/intel/iavf/iavf_ipsec_crypto.c
+++ b/drivers/net/intel/iavf/iavf_ipsec_crypto.c
@@ -467,7 +467,7 @@ iavf_ipsec_crypto_security_association_add(struct iavf_adapter *adapter,
request_len = sizeof(struct inline_ipsec_msg) +
sizeof(struct virtchnl_ipsec_sa_cfg);

- request = rte_malloc("iavf-sad-add-request", request_len, 0);
+ request = calloc(1, request_len);
if (request == NULL) {
rc = -ENOMEM;
goto update_cleanup;
@@ -475,7 +475,7 @@ iavf_ipsec_crypto_security_association_add(struct iavf_adapter *adapter,

response_len = sizeof(struct inline_ipsec_msg) +
sizeof(struct virtchnl_ipsec_sa_cfg_resp);
- response = rte_malloc("iavf-sad-add-response", response_len, 0);
+ response = calloc(1, response_len);
if (response == NULL) {
rc = -ENOMEM;
goto update_cleanup;
@@ -553,8 +553,8 @@ iavf_ipsec_crypto_security_association_add(struct iavf_adapter *adapter,
else
rc = response->ipsec_data.sa_cfg_resp->sa_handle;
update_cleanup:
- rte_free(response);
- rte_free(request);
+ free(response);
+ free(request);

return rc;
}
@@ -728,8 +728,7 @@ iavf_ipsec_crypto_inbound_security_policy_add(struct iavf_adapter *adapter,

request_len = sizeof(struct inline_ipsec_msg) +
sizeof(struct virtchnl_ipsec_sp_cfg);
- request = rte_malloc("iavf-inbound-security-policy-add-request",
- request_len, 0);
+ request = calloc(1, request_len);
if (request == NULL) {
rc = -ENOMEM;
goto update_cleanup;
@@ -770,8 +769,7 @@ iavf_ipsec_crypto_inbound_security_policy_add(struct iavf_adapter *adapter,

response_len = sizeof(struct inline_ipsec_msg) +
sizeof(struct virtchnl_ipsec_sp_cfg_resp);
- response = rte_malloc("iavf-inbound-security-policy-add-response",
- response_len, 0);
+ response = calloc(1, response_len);
if (response == NULL) {
rc = -ENOMEM;
goto update_cleanup;
@@ -792,8 +790,8 @@ iavf_ipsec_crypto_inbound_security_policy_add(struct iavf_adapter *adapter,
rc = response->ipsec_data.sp_cfg_resp->rule_id;

update_cleanup:
- rte_free(request);
- rte_free(response);
+ free(request);
+ free(response);

return rc;
}
@@ -808,7 +806,7 @@ iavf_ipsec_crypto_sa_update_esn(struct iavf_adapter *adapter,

request_len = sizeof(struct inline_ipsec_msg) +
sizeof(struct virtchnl_ipsec_sa_update);
- request = rte_malloc("iavf-sa-update-request", request_len, 0);
+ request = calloc(1, request_len);
if (request == NULL) {
rc = -ENOMEM;
goto update_cleanup;
@@ -816,7 +814,7 @@ iavf_ipsec_crypto_sa_update_esn(struct iavf_adapter *adapter,

response_len = sizeof(struct inline_ipsec_msg) +
sizeof(struct virtchnl_ipsec_resp);
- response = rte_malloc("iavf-sa-update-response", response_len, 0);
+ response = calloc(1, response_len);
if (response == NULL) {
rc = -ENOMEM;
goto update_cleanup;
@@ -846,8 +844,8 @@ iavf_ipsec_crypto_sa_update_esn(struct iavf_adapter *adapter,
rc = response->ipsec_data.ipsec_resp->resp;

update_cleanup:
- rte_free(request);
- rte_free(response);
+ free(request);
+ free(response);

return rc;
}
@@ -905,7 +903,7 @@ iavf_ipsec_crypto_security_policy_delete(struct iavf_adapter *adapter,

request_len = sizeof(struct inline_ipsec_msg) +
sizeof(struct virtchnl_ipsec_sp_destroy);
- request = rte_malloc("iavf-sp-del-request", request_len, 0);
+ request = calloc(1, request_len);
if (request == NULL) {
rc = -ENOMEM;
goto update_cleanup;
@@ -913,7 +911,7 @@ iavf_ipsec_crypto_security_policy_delete(struct iavf_adapter *adapter,

response_len = sizeof(struct inline_ipsec_msg) +
sizeof(struct virtchnl_ipsec_resp);
- response = rte_malloc("iavf-sp-del-response", response_len, 0);
+ response = calloc(1, response_len);
if (response == NULL) {
rc = -ENOMEM;
goto update_cleanup;
@@ -944,8 +942,8 @@ iavf_ipsec_crypto_security_policy_delete(struct iavf_adapter *adapter,
return response->ipsec_data.ipsec_status->status;

update_cleanup:
- rte_free(request);
- rte_free(response);
+ free(request);
+ free(response);

return rc;
}
@@ -962,7 +960,7 @@ iavf_ipsec_crypto_sa_del(struct iavf_adapter *adapter,
request_len = sizeof(struct inline_ipsec_msg) +
sizeof(struct virtchnl_ipsec_sa_destroy);

- request = rte_malloc("iavf-sa-del-request", request_len, 0);
+ request = calloc(1, request_len);
if (request == NULL) {
rc = -ENOMEM;
goto update_cleanup;
@@ -971,7 +969,7 @@ iavf_ipsec_crypto_sa_del(struct iavf_adapter *adapter,
response_len = sizeof(struct inline_ipsec_msg) +
sizeof(struct virtchnl_ipsec_resp);

- response = rte_malloc("iavf-sa-del-response", response_len, 0);
+ response = calloc(1, response_len);
if (response == NULL) {
rc = -ENOMEM;
goto update_cleanup;
@@ -1013,8 +1011,8 @@ iavf_ipsec_crypto_sa_del(struct iavf_adapter *adapter,
rc = -EFAULT;

update_cleanup:
- rte_free(response);
- rte_free(request);
+ free(response);
+ free(request);

return rc;
}
@@ -1168,7 +1166,7 @@ iavf_ipsec_crypto_device_capabilities_get(struct iavf_adapter *adapter,

request_len = sizeof(struct inline_ipsec_msg);

- request = rte_malloc("iavf-device-capability-request", request_len, 0);
+ request = calloc(1, request_len);
if (request == NULL) {
rc = -ENOMEM;
goto update_cleanup;
@@ -1176,8 +1174,7 @@ iavf_ipsec_crypto_device_capabilities_get(struct iavf_adapter *adapter,

response_len = sizeof(struct inline_ipsec_msg) +
sizeof(struct virtchnl_ipsec_cap);
- response = rte_malloc("iavf-device-capability-response",
- response_len, 0);
+ response = calloc(1, response_len);
if (response == NULL) {
rc = -ENOMEM;
goto update_cleanup;
@@ -1203,8 +1200,8 @@ iavf_ipsec_crypto_device_capabilities_get(struct iavf_adapter *adapter,
memcpy(capability, response->ipsec_data.ipsec_cap, sizeof(*capability));

update_cleanup:
- rte_free(response);
- rte_free(request);
+ free(response);
+ free(request);

return rc;
}
@@ -1593,7 +1590,7 @@ iavf_ipsec_crypto_status_get(struct iavf_adapter *adapter,

request_len = sizeof(struct inline_ipsec_msg);

- request = rte_malloc("iavf-device-status-request", request_len, 0);
+ request = calloc(1, request_len);
if (request == NULL) {
rc = -ENOMEM;
goto update_cleanup;
@@ -1601,8 +1598,7 @@ iavf_ipsec_crypto_status_get(struct iavf_adapter *adapter,

response_len = sizeof(struct inline_ipsec_msg) +
sizeof(struct virtchnl_ipsec_status);
- response = rte_malloc("iavf-device-status-response",
- response_len, 0);
+ response = calloc(1, response_len);
if (response == NULL) {
rc = -ENOMEM;
goto update_cleanup;
@@ -1628,8 +1624,8 @@ iavf_ipsec_crypto_status_get(struct iavf_adapter *adapter,
memcpy(status, response->ipsec_data.ipsec_status, sizeof(*status));

update_cleanup:
- rte_free(response);
- rte_free(request);
+ free(response);
+ free(request);

return rc;
}
--
2.47.3