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, so replace it with stack
allocation.

Signed-off-by: Anatoly Burakov <[email protected]>
Acked-by: Bruce Richardson <[email protected]>
---
 drivers/net/intel/ice/ice_dcf_ethdev.c |  4 ++--
 drivers/net/intel/ice/ice_ethdev.c     | 29 ++++++--------------------
 2 files changed, 8 insertions(+), 25 deletions(-)

diff --git a/drivers/net/intel/ice/ice_dcf_ethdev.c 
b/drivers/net/intel/ice/ice_dcf_ethdev.c
index 81da5a4656..037382b336 100644
--- a/drivers/net/intel/ice/ice_dcf_ethdev.c
+++ b/drivers/net/intel/ice/ice_dcf_ethdev.c
@@ -1338,7 +1338,7 @@ ice_dcf_dev_rss_reta_update(struct rte_eth_dev *dev,
                return -EINVAL;
        }
 
-       lut = rte_zmalloc("rss_lut", reta_size, 0);
+       lut = calloc(1, reta_size);
        if (!lut) {
                PMD_DRV_LOG(ERR, "No memory can be allocated");
                return -ENOMEM;
@@ -1358,7 +1358,7 @@ ice_dcf_dev_rss_reta_update(struct rte_eth_dev *dev,
        ret = ice_dcf_configure_rss_lut(hw);
        if (ret) /* revert back */
                rte_memcpy(hw->rss_lut, lut, reta_size);
-       rte_free(lut);
+       free(lut);
 
        return ret;
 }
diff --git a/drivers/net/intel/ice/ice_ethdev.c 
b/drivers/net/intel/ice/ice_ethdev.c
index ade13600de..b9d8b2a3ac 100644
--- a/drivers/net/intel/ice/ice_ethdev.c
+++ b/drivers/net/intel/ice/ice_ethdev.c
@@ -5566,7 +5566,7 @@ ice_rss_reta_update(struct rte_eth_dev *dev,
        struct ice_pf *pf = ICE_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[ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_2K] = {0};
        int ret;
 
        if (reta_size != ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_128 &&
@@ -5583,14 +5583,9 @@ ice_rss_reta_update(struct rte_eth_dev *dev,
        /* It MUST use the current LUT size to get the RSS lookup table,
         * otherwise if will fail with -100 error code.
         */
-       lut = rte_zmalloc(NULL,  RTE_MAX(reta_size, lut_size), 0);
-       if (!lut) {
-               PMD_DRV_LOG(ERR, "No memory can be allocated");
-               return -ENOMEM;
-       }
        ret = ice_get_rss_lut(pf->main_vsi, lut, lut_size);
        if (ret)
-               goto out;
+               return ret;
 
        for (i = 0; i < reta_size; i++) {
                idx = i / RTE_ETH_RETA_GROUP_SIZE;
@@ -5606,10 +5601,7 @@ ice_rss_reta_update(struct rte_eth_dev *dev,
                pf->hash_lut_size = reta_size;
        }
 
-out:
-       rte_free(lut);
-
-       return ret;
+       return 0;
 }
 
 static int
@@ -5620,7 +5612,7 @@ ice_rss_reta_query(struct rte_eth_dev *dev,
        struct ice_pf *pf = ICE_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[ICE_AQC_GSET_RSS_LUT_TABLE_SIZE_2K] = {0};
        int ret;
 
        if (reta_size != lut_size) {
@@ -5632,15 +5624,9 @@ ice_rss_reta_query(struct rte_eth_dev *dev,
                return -EINVAL;
        }
 
-       lut = rte_zmalloc(NULL, reta_size, 0);
-       if (!lut) {
-               PMD_DRV_LOG(ERR, "No memory can be allocated");
-               return -ENOMEM;
-       }
-
        ret = ice_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;
@@ -5649,10 +5635,7 @@ ice_rss_reta_query(struct rte_eth_dev *dev,
                        reta_conf[idx].reta[shift] = lut[i];
        }
 
-out:
-       rte_free(lut);
-
-       return ret;
+       return 0;
 }
 
 static int
-- 
2.47.3

Reply via email to