[PATCH v6 27/27] net/ice: avoid rte malloc in flow pattern match

Anatoly Burakov
2026-02-19T16:26:34Z

Currently, when allocating buffers for pattern match items and flow item
storage, we are using rte_zmalloc followed by immediate rte_free. This
memory does not need to be stored in hugepage memory, so replace it with
regular malloc/free.

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
drivers/net/intel/ice/ice_acl_filter.c | 3 ++-
drivers/net/intel/ice/ice_fdir_filter.c | 5 +++--
drivers/net/intel/ice/ice_generic_flow.c | 15 +++++++--------
drivers/net/intel/ice/ice_hash.c | 3 ++-
drivers/net/intel/ice/ice_switch_filter.c | 5 +++--
5 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/drivers/net/intel/ice/ice_acl_filter.c b/drivers/net/intel/ice/ice_acl_filter.c
index 38e30a4f62..6754a40044 100644
--- a/drivers/net/intel/ice/ice_acl_filter.c
+++ b/drivers/net/intel/ice/ice_acl_filter.c
@@ -9,6 +9,7 @@
#include <string.h>
#include <unistd.h>
#include <stdarg.h>
+#include <stdlib.h>
#include <rte_debug.h>
#include <rte_ether.h>
#include <ethdev_driver.h>
@@ -1009,7 +1010,7 @@ ice_acl_parse(struct ice_adapter *ad,
*meta = filter;

error:
- rte_free(item);
+ free(item);
return ret;
}

diff --git a/drivers/net/intel/ice/ice_fdir_filter.c b/drivers/net/intel/ice/ice_fdir_filter.c
index 5f44b5c818..8cca831fa9 100644
--- a/drivers/net/intel/ice/ice_fdir_filter.c
+++ b/drivers/net/intel/ice/ice_fdir_filter.c
@@ -3,6 +3,7 @@
*/

#include <stdio.h>
+#include <stdlib.h>
#include <rte_flow.h>
#include <rte_hash.h>
#include <rte_hash_crc.h>
@@ -2504,11 +2505,11 @@ ice_fdir_parse(struct ice_adapter *ad,
rte_free(filter->pkt_buf);
}

- rte_free(item);
+ free(item);
return ret;
error:
rte_free(filter->pkt_buf);
- rte_free(item);
+ free(item);
return ret;
}

diff --git a/drivers/net/intel/ice/ice_generic_flow.c b/drivers/net/intel/ice/ice_generic_flow.c
index 4049157eab..3f7a9f4714 100644
--- a/drivers/net/intel/ice/ice_generic_flow.c
+++ b/drivers/net/intel/ice/ice_generic_flow.c
@@ -9,6 +9,7 @@
#include <string.h>
#include <unistd.h>
#include <stdarg.h>
+#include <stdlib.h>

#include <rte_ether.h>
#include <ethdev_driver.h>
@@ -2136,19 +2137,17 @@ ice_search_pattern_match_item(struct ice_adapter *ad,
}
item_num++;

- items = rte_zmalloc("ice_pattern",
- item_num * sizeof(struct rte_flow_item), 0);
+ items = calloc(item_num, sizeof(struct rte_flow_item));
if (!items) {
rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_ITEM_NUM,
NULL, "No memory for PMD internal items.");
return NULL;
}
- pattern_match_item = rte_zmalloc("ice_pattern_match_item",
- sizeof(struct ice_pattern_match_item), 0);
+ pattern_match_item = calloc(1, sizeof(struct ice_pattern_match_item));
if (!pattern_match_item) {
rte_flow_error_set(error, ENOMEM, RTE_FLOW_ERROR_TYPE_HANDLE,
NULL, "Failed to allocate memory.");
- rte_free(items);
+ free(items);
return NULL;
}

@@ -2167,7 +2166,7 @@ ice_search_pattern_match_item(struct ice_adapter *ad,
pattern_match_item->pattern_list =
array[i].pattern_list;
pattern_match_item->meta = array[i].meta;
- rte_free(items);
+ free(items);
return pattern_match_item;
}
}
@@ -2175,8 +2174,8 @@ ice_search_pattern_match_item(struct ice_adapter *ad,
unsupported:
rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM,
pattern, "Unsupported pattern");
- rte_free(items);
- rte_free(pattern_match_item);
+ free(items);
+ free(pattern_match_item);
return NULL;
}

diff --git a/drivers/net/intel/ice/ice_hash.c b/drivers/net/intel/ice/ice_hash.c
index 854c6e8dca..1174c505da 100644
--- a/drivers/net/intel/ice/ice_hash.c
+++ b/drivers/net/intel/ice/ice_hash.c
@@ -9,6 +9,7 @@
#include <string.h>
#include <unistd.h>
#include <stdarg.h>
+#include <stdlib.h>

#include <rte_debug.h>
#include <rte_ether.h>
@@ -1211,7 +1212,7 @@ ice_hash_parse_pattern_action(__rte_unused struct ice_adapter *ad,
*meta = rss_meta_ptr;
else
rte_free(rss_meta_ptr);
- rte_free(pattern_match_item);
+ free(pattern_match_item);

return ret;
}
diff --git a/drivers/net/intel/ice/ice_switch_filter.c b/drivers/net/intel/ice/ice_switch_filter.c
index 28bc775a2c..b25e5eaad3 100644
--- a/drivers/net/intel/ice/ice_switch_filter.c
+++ b/drivers/net/intel/ice/ice_switch_filter.c
@@ -9,6 +9,7 @@
#include <string.h>
#include <unistd.h>
#include <stdarg.h>
+#include <stdlib.h>
#include <rte_debug.h>
#include <rte_ether.h>
#include <ethdev_driver.h>
@@ -1877,14 +1878,14 @@ ice_switch_parse_pattern_action(struct ice_adapter *ad,
rte_free(sw_meta_ptr);
}

- rte_free(pattern_match_item);
+ free(pattern_match_item);

return 0;

error:
rte_free(list);
rte_free(sw_meta_ptr);
- rte_free(pattern_match_item);
+ free(pattern_match_item);

return -rte_errno;
}
--
2.47.3