[PATCH v6 10/27] net/i40e: avoid rte malloc in RSS RETA operations

Anatoly Burakov
2026-02-19T16:24:36Z

Currently, when updating or querying RSS redirection table (RETA), we
are using rte_zmalloc followed by an immediate rte_free. This memory does
not need to be stored in hugepage memory and the maximum LUT size is 512
bytes, so replace it with stack-based allocation.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
drivers/net/intel/i40e/i40e_ethdev.c | 25 ++++---------------------
1 file changed, 4 insertions(+), 21 deletions(-)

diff --git a/drivers/net/intel/i40e/i40e_ethdev.c b/drivers/net/intel/i40e/i40e_ethdev.c
index d3404d7720..d1f8e12689 100644
--- a/drivers/net/intel/i40e/i40e_ethdev.c
+++ b/drivers/net/intel/i40e/i40e_ethdev.c
@@ -4619,7 +4619,7 @@ i40e_dev_rss_reta_update(struct rte_eth_dev *dev,
struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
uint16_t i, lut_size = pf->hash_lut_size;
uint16_t idx, shift;
- uint8_t *lut;
+ uint8_t lut[RTE_ETH_RSS_RETA_SIZE_512] = {0};
int ret;

if (reta_size != lut_size ||
@@ -4630,14 +4630,9 @@ i40e_dev_rss_reta_update(struct rte_eth_dev *dev,
return -EINVAL;
}

- lut = rte_zmalloc("i40e_rss_lut", reta_size, 0);
- if (!lut) {
- PMD_DRV_LOG(ERR, "No memory can be allocated");
- return -ENOMEM;
- }
ret = i40e_get_rss_lut(pf->main_vsi, lut, reta_size);
if (ret)
- goto out;
+ return ret;
for (i = 0; i < reta_size; i++) {
idx = i / RTE_ETH_RETA_GROUP_SIZE;
shift = i % RTE_ETH_RETA_GROUP_SIZE;
@@ -4648,9 +4643,6 @@ i40e_dev_rss_reta_update(struct rte_eth_dev *dev,

pf->adapter->rss_reta_updated = 1;

-out:
- rte_free(lut);
-
return ret;
}

@@ -4662,7 +4654,7 @@ i40e_dev_rss_reta_query(struct rte_eth_dev *dev,
struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
uint16_t i, lut_size = pf->hash_lut_size;
uint16_t idx, shift;
- uint8_t *lut;
+ uint8_t lut[RTE_ETH_RSS_RETA_SIZE_512] = {0};
int ret;

if (reta_size != lut_size ||
@@ -4673,15 +4665,9 @@ i40e_dev_rss_reta_query(struct rte_eth_dev *dev,
return -EINVAL;
}

- lut = rte_zmalloc("i40e_rss_lut", reta_size, 0);
- if (!lut) {
- PMD_DRV_LOG(ERR, "No memory can be allocated");
- return -ENOMEM;
- }
-
ret = i40e_get_rss_lut(pf->main_vsi, lut, reta_size);
if (ret)
- goto out;
+ return ret;
for (i = 0; i < reta_size; i++) {
idx = i / RTE_ETH_RETA_GROUP_SIZE;
shift = i % RTE_ETH_RETA_GROUP_SIZE;
@@ -4689,9 +4675,6 @@ i40e_dev_rss_reta_query(struct rte_eth_dev *dev,
reta_conf[idx].reta[shift] = lut[i];
}

-out:
- rte_free(lut);
-
return ret;
}

--
2.47.3