* Re: [PATCH v4 2/2] mempool/cnxk: add halo support in mempool
From: Stephen Hemminger @ 2026-02-19 17:33 UTC (permalink / raw)
To: Nawal Kishor; +Cc: dev, Ashwin Sekhar T K, Pavan Nikhilesh, jerinj
In-Reply-To: <20260217103932.679806-3-nkishor@marvell.com>
On Tue, 17 Feb 2026 16:09:22 +0530
Nawal Kishor <nkishor@marvell.com> wrote:
> +static struct rte_mempool_ops cn20k_mempool_ops = {
> + .name = "cn20k_mempool_ops",
> + .alloc = cn20k_mempool_alloc,
> + .free = cn10k_mempool_free,
> + .enqueue = cn10k_mempool_enq,
> + .dequeue = cn10k_mempool_deq,
> + .get_count = cn10k_mempool_get_count,
> + .calc_mem_size = cnxk_mempool_calc_mem_size,
> + .populate = cnxk_mempool_populate,
> +};
> +
If possible ops structures should be const to protect from modification.
> +static int
> +parse_halo_ena_handler(const char *key, const char *value, void *extra_args)
> +{
> + RTE_SET_USED(key);
Prefer __rte_unused attribute
> + uint8_t val;
> +
> + val = atoi(value);
> + if (val != 0 && val != 1)
> + return -EINVAL;
> +
> + *(uint8_t *)extra_args = val;
> + return 0;
> +}
Using atoi() allows non-string values. You should be using a more robust handler.
Actually kvargs should have handlers for common types, but that is an enhancement.
^ permalink raw reply
* [DPDK/ethdev Bug 1891] Flow validate bug in mlx5 driver on CX-5 NIC
From: bugzilla @ 2026-02-19 17:20 UTC (permalink / raw)
To: dev
http://bugs.dpdk.org/show_bug.cgi?id=1891
Bug ID: 1891
Summary: Flow validate bug in mlx5 driver on CX-5 NIC
Product: DPDK
Version: unspecified
Hardware: All
OS: All
Status: UNCONFIRMED
Severity: normal
Priority: Normal
Component: ethdev
Assignee: dev@dpdk.org
Reporter: dmarx@iol.unh.edu
Target Milestone: ---
There seems to be a discrepancy between flow validate and flow create when
using the JUMP action on an mlx5 pmd:
testpmd> flow validate 0 group 0 ingress pattern eth src is 02:00:00:00:00:00 /
end actions jump group 1 / end
Flow rule validated
testpmd> flow create 0 group 0 ingress pattern eth src is 02:00:00:00:00:00 /
end actions jump group 1 / end
port_flow_complain(): Caught PMD error type 16 (specific action): cannot create
jump action.: Operation not supported
--
You are receiving this mail because:
You are the assignee for the bug.
^ permalink raw reply
* Re: [PATCH v7 0/7] Add support for L2TPV2 over UDP to ICE PMD
From: Bruce Richardson @ 2026-02-19 16:52 UTC (permalink / raw)
To: Shaiq Wani; +Cc: dev, aman.deep.singh
In-Reply-To: <20260219112103.2370766-1-shaiq.wani@intel.com>
On Thu, Feb 19, 2026 at 04:50:56PM +0530, Shaiq Wani wrote:
> This patchset enables L2TPv2 over UDP support in the ice PMD via rte_flow,
> allowing flow classification and RSS hashing for L2TPv2 traffic.
>
> v7: removed FDIR in doc and commit log titles.
>
> v6: split patch 3 into 2 separate patches.
>
> v5: Resending v4 patches with correct cover letter and threading.
>
> v4: *Version 3 patchset was incomplete due to a server reboot.
> *V4 includes all patches for review.
>
> v3: Fixed compilation issues.
> v2: Addressed AI generated comments.
>
>
Patchset applied to dpdk-next-net-intel,
Thanks,
/Bruce
^ permalink raw reply
* Re: [PATCH 10/11] bus/fslmc: fix devargs not propagated on hotplug
From: David Marchand @ 2026-02-19 16:52 UTC (permalink / raw)
To: Maxime Leroy, hemant.agrawal; +Cc: dev
In-Reply-To: <CAHHRULXWDg2qpc-WR1pehzZ6+PasdeNx3aqOjVj_0K12Zk-UgQ@mail.gmail.com>
Hello,
On Thu, 19 Feb 2026 at 10:06, Maxime Leroy <maxime@leroys.fr> wrote:
> > > diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
> > > index abdb0ad50d..a539753649 100644
> > > --- a/drivers/bus/fslmc/fslmc_bus.c
> > > +++ b/drivers/bus/fslmc/fslmc_bus.c
> > > @@ -596,6 +596,11 @@ fslmc_bus_plug(struct rte_device *rte_dev)
> > > struct rte_dpaa2_device, device);
> > > struct rte_dpaa2_driver *drv;
> > >
> > > + /* Refresh devargs from the EAL devargs list, as they may
> > > + * have been added after the initial bus scan (e.g. hotplug).
> > > + */
> > > + dev->device.devargs = fslmc_devargs_lookup(dev);
> > > +
> > > TAILQ_FOREACH(drv, &rte_fslmc_bus.driver_list, next) {
> > > ret = rte_fslmc_match(drv, dev);
> > > if (ret)
> >
> > This looks like a strange location for a fix.
> >
> > The hotplug path calls this bus ->scan() which is supposed to refresh
> > the devices.
> > Could you double check if something is wrong on this side?
> >
> Hi David,
>
> rte_fslmc_scan() is guarded by a process_once flag and returns
> immediately after the initial bus scan. During hotplug,
> local_dev_probe() does call bus->scan(), but it is a no-op -
> scan_one_fslmc_device()
> (which calls fslmc_devargs_lookup()) is never reached.
>
> The device already exists in the bus device list from the initial
> scan, so find_device() succeeds, but its devargs pointer is stale
> (NULL).
>
> You are right that insert_in_device_list() does not handle the comp ==
> 0 case (unlike PCI which refreshes the existing object and frees the
> duplicate). Fixing that and removing process_once would allow scan to
> properly refresh devargs on rescan.
>
> However it is a larger change: beyond the dedup fix, device_count
> would need to be kept consistent, and fslmc_vfio_process_group()
> removes infrastructure objects (DPMCP, DPRC, excess DPIO) from the
> device list during the initial probe, so a rescan would re-insert them
> as new entries that would need to be handled as well.
>
> Making the fslmc bus scan re-entrant is a significant rework of a
> critical code path, for a use case (true hotplug of dynamically
> created devices) that is not common on NXP platforms.
> I think this is best left to the NXP maintainers who know this code
> intimately. My use case is grout, which uses the EAL hotplug API to
> late-probe devices that already exist in the DPRC at boot time.
Ok, thanks for the explanations.
I agree, it seems too intrusive for fixing this issue.
>
> That said, you are right that scan is the proper place for this fix.
> Rather than making it fully re-entrant, a simpler approach is to
> refresh devargs on existing devices when scan is called again:
>
> if (process_once) {
> DPAA2_BUS_DEBUG("Fslmc bus already scanned. Not rescanning");
> TAILQ_FOREACH(dev, &rte_fslmc_bus.device_list, next)
> dev->device.devargs = fslmc_devargs_lookup(dev);
> return 0;
> }
>
> Let me know what you think of this approach.
That seems a good trade off, as it avoids mixing responsibilities in
this bus code.
What do you think Hemant?
--
David Marchand
^ permalink raw reply
* Re: [PATCH] net/iavf: explicitly pass flags param to Tx context fns
From: Medvedkin, Vladimir @ 2026-02-19 16:25 UTC (permalink / raw)
To: Bruce Richardson, dev
In-Reply-To: <20260219160726.2117208-1-bruce.richardson@intel.com>
Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
On 2/19/2026 4:07 PM, Bruce Richardson wrote:
> The get_context_desc() function takes as an explicit parameter the
> ol_flags from the packet, which saves re-reading them from the mbuf. The
> subfunctions for creating the segmentation part of the descriptor or the
> ipsec handling do not take this parameter though, and then re-read the
> ol_flags from the mbuf. While essentially harmless, this does confuse
> static analysis tools like converity which does not realise that
> ol_flags and m->ol_flags are the same, leading to false positives
> like [1].
>
> Fix this and avoid coverity false positives by just passing the local
> ol_flags variable so all code uses the same flags source and avoid
> unnecessary mbuf reads.
>
> [1] Coverity Issue: 501497
>
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
> NOTE: Not flagging this as a bugfix since there is no actual bug here,
> just a code improvement to try and prevent false positives.
> ---
> drivers/net/intel/iavf/iavf_rxtx.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/net/intel/iavf/iavf_rxtx.c b/drivers/net/intel/iavf/iavf_rxtx.c
> index e621d4bf47..2464a988eb 100644
> --- a/drivers/net/intel/iavf/iavf_rxtx.c
> +++ b/drivers/net/intel/iavf/iavf_rxtx.c
> @@ -2361,14 +2361,14 @@ iavf_calc_context_desc(const struct rte_mbuf *mb, uint8_t vlan_flag)
> }
>
> static inline void
> -iavf_fill_ctx_desc_tunnelling_field(uint64_t *qw0, const struct rte_mbuf *m)
> +iavf_fill_ctx_desc_tunnelling_field(uint64_t *qw0, uint64_t ol_flags, const struct rte_mbuf *m)
> {
> uint64_t eip_typ = IAVF_TX_CTX_DESC_EIPT_NONE;
> uint64_t eip_len = 0;
> uint64_t eip_noinc = 0;
> /* Default - IP_ID is increment in each segment of LSO */
>
> - switch (m->ol_flags & (RTE_MBUF_F_TX_OUTER_IPV4 |
> + switch (ol_flags & (RTE_MBUF_F_TX_OUTER_IPV4 |
> RTE_MBUF_F_TX_OUTER_IPV6 |
> RTE_MBUF_F_TX_OUTER_IP_CKSUM)) {
> case RTE_MBUF_F_TX_OUTER_IPV4:
> @@ -2385,9 +2385,9 @@ iavf_fill_ctx_desc_tunnelling_field(uint64_t *qw0, const struct rte_mbuf *m)
> break;
> }
>
> - if (!(m->ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD)) {
> + if (!(ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD)) {
> /* L4TUNT: L4 Tunneling Type */
> - switch (m->ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) {
> + switch (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) {
> case RTE_MBUF_F_TX_TUNNEL_IPIP:
> /* for non UDP / GRE tunneling, set to 00b */
> break;
> @@ -2425,7 +2425,7 @@ iavf_fill_ctx_desc_tunnelling_field(uint64_t *qw0, const struct rte_mbuf *m)
> IAVF_TX_CTX_EXT_IP_IPV4 |
> IAVF_TX_CTX_EXT_IP_IPV4_NO_CSUM)) &&
> (eip_typ & IAVF_TXD_CTX_UDP_TUNNELING) &&
> - (m->ol_flags & RTE_MBUF_F_TX_OUTER_UDP_CKSUM))
> + (ol_flags & RTE_MBUF_F_TX_OUTER_UDP_CKSUM))
> eip_typ |= IAVF_TXD_CTX_QW0_L4T_CS_MASK;
> }
>
> @@ -2435,18 +2435,18 @@ iavf_fill_ctx_desc_tunnelling_field(uint64_t *qw0, const struct rte_mbuf *m)
> }
>
> static inline uint16_t
> -iavf_fill_ctx_desc_segmentation_field(volatile uint64_t *field,
> +iavf_fill_ctx_desc_segmentation_field(volatile uint64_t *field, uint64_t ol_flags,
> const struct rte_mbuf *m, struct iavf_ipsec_crypto_pkt_metadata *ipsec_md)
> {
> uint64_t segmentation_field = 0;
> uint64_t total_length = 0;
>
> - if (m->ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD) {
> + if (ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD) {
> total_length = ipsec_md->l4_payload_len;
> } else {
> total_length = m->pkt_len - (m->l2_len + m->l3_len + m->l4_len);
>
> - if (m->ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK)
> + if (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK)
> total_length -= m->outer_l3_len + m->outer_l2_len;
> }
>
> @@ -2573,7 +2573,7 @@ iavf_get_context_desc(uint64_t ol_flags, const struct rte_mbuf *mbuf,
> }
>
> /* TSO segmentation field */
> - iavf_fill_ctx_desc_segmentation_field(&cd_type_cmd, mbuf, ipsec_md);
> + iavf_fill_ctx_desc_segmentation_field(&cd_type_cmd, ol_flags, mbuf, ipsec_md);
> }
>
> /* VLAN field for L2TAG2 */
> @@ -2589,7 +2589,7 @@ iavf_get_context_desc(uint64_t ol_flags, const struct rte_mbuf *mbuf,
>
> /* Tunneling field */
> if (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK)
> - iavf_fill_ctx_desc_tunnelling_field((uint64_t *)&cd_tunneling_params, mbuf);
> + iavf_fill_ctx_desc_tunnelling_field(&cd_tunneling_params, ol_flags, mbuf);
>
> /* L2TAG2 field (VLAN) */
> if (ol_flags & RTE_MBUF_F_TX_QINQ) {
--
Regards,
Vladimir
^ permalink raw reply
* [PATCH v6 27/27] net/ice: avoid rte malloc in flow pattern match
From: Anatoly Burakov @ 2026-02-19 16:23 UTC (permalink / raw)
To: dev, Bruce Richardson
In-Reply-To: <cover.1771518103.git.anatoly.burakov@intel.com>
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
^ permalink raw reply related
* [PATCH v6 26/27] net/ice: avoid rte malloc in raw pattern parsing
From: Anatoly Burakov @ 2026-02-19 16:23 UTC (permalink / raw)
To: dev, Bruce Richardson
In-Reply-To: <cover.1771518103.git.anatoly.burakov@intel.com>
Currently, when parsing raw flow patterns, 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 regular malloc/free.
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
drivers/net/intel/ice/ice_fdir_filter.c | 14 +++++++-------
drivers/net/intel/ice/ice_hash.c | 10 +++++-----
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/drivers/net/intel/ice/ice_fdir_filter.c b/drivers/net/intel/ice/ice_fdir_filter.c
index da22b65a77..5f44b5c818 100644
--- a/drivers/net/intel/ice/ice_fdir_filter.c
+++ b/drivers/net/intel/ice/ice_fdir_filter.c
@@ -1879,13 +1879,13 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
pkt_len)
return -rte_errno;
- tmp_spec = rte_zmalloc(NULL, pkt_len / 2, 0);
+ tmp_spec = calloc(1, pkt_len / 2);
if (!tmp_spec)
return -rte_errno;
- tmp_mask = rte_zmalloc(NULL, pkt_len / 2, 0);
+ tmp_mask = calloc(1, pkt_len / 2);
if (!tmp_mask) {
- rte_free(tmp_spec);
+ free(tmp_spec);
return -rte_errno;
}
@@ -1950,13 +1950,13 @@ ice_fdir_parse_pattern(__rte_unused struct ice_adapter *ad,
filter->parser_ena = true;
- rte_free(tmp_spec);
- rte_free(tmp_mask);
+ free(tmp_spec);
+ free(tmp_mask);
break;
raw_error:
- rte_free(tmp_spec);
- rte_free(tmp_mask);
+ free(tmp_spec);
+ free(tmp_mask);
return ret_val;
}
diff --git a/drivers/net/intel/ice/ice_hash.c b/drivers/net/intel/ice/ice_hash.c
index afdc8f220a..854c6e8dca 100644
--- a/drivers/net/intel/ice/ice_hash.c
+++ b/drivers/net/intel/ice/ice_hash.c
@@ -676,13 +676,13 @@ ice_hash_parse_raw_pattern(struct ice_adapter *ad,
pkt_len = spec_len / 2;
- pkt_buf = rte_zmalloc(NULL, pkt_len, 0);
+ pkt_buf = calloc(1, pkt_len);
if (!pkt_buf)
return -ENOMEM;
- msk_buf = rte_zmalloc(NULL, pkt_len, 0);
+ msk_buf = calloc(1, pkt_len);
if (!msk_buf) {
- rte_free(pkt_buf);
+ free(pkt_buf);
return -ENOMEM;
}
@@ -733,8 +733,8 @@ ice_hash_parse_raw_pattern(struct ice_adapter *ad,
rte_memcpy(&meta->raw.prof, &prof, sizeof(prof));
free_mem:
- rte_free(pkt_buf);
- rte_free(msk_buf);
+ free(pkt_buf);
+ free(msk_buf);
return ret;
}
--
2.47.3
^ permalink raw reply related
* [PATCH v6 25/27] net/ice: avoid rte malloc in MAC address operations
From: Anatoly Burakov @ 2026-02-19 16:23 UTC (permalink / raw)
To: dev, Bruce Richardson
In-Reply-To: <cover.1771518103.git.anatoly.burakov@intel.com>
Currently, when adding or deleting MAC addresses, 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 <anatoly.burakov@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
drivers/net/intel/ice/ice_dcf_ethdev.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/drivers/net/intel/ice/ice_dcf_ethdev.c b/drivers/net/intel/ice/ice_dcf_ethdev.c
index 037382b336..332f1e356e 100644
--- a/drivers/net/intel/ice/ice_dcf_ethdev.c
+++ b/drivers/net/intel/ice/ice_dcf_ethdev.c
@@ -928,19 +928,14 @@ dcf_add_del_mc_addr_list(struct ice_dcf_hw *hw,
struct rte_ether_addr *mc_addrs,
uint32_t mc_addrs_num, bool add)
{
- struct virtchnl_ether_addr_list *list;
- struct dcf_virtchnl_cmd args;
+ struct {
+ struct virtchnl_ether_addr_list list;
+ struct virtchnl_ether_addr addr[DCF_NUM_MACADDR_MAX];
+ } list_req = {0};
+ struct virtchnl_ether_addr_list *list = &list_req.list;
+ struct dcf_virtchnl_cmd args = {0};
uint32_t i;
- int len, err = 0;
-
- len = sizeof(struct virtchnl_ether_addr_list);
- len += sizeof(struct virtchnl_ether_addr) * mc_addrs_num;
-
- list = rte_zmalloc(NULL, len, 0);
- if (!list) {
- PMD_DRV_LOG(ERR, "fail to allocate memory");
- return -ENOMEM;
- }
+ int err = 0;
for (i = 0; i < mc_addrs_num; i++) {
memcpy(list->list[i].addr, mc_addrs[i].addr_bytes,
@@ -955,13 +950,12 @@ dcf_add_del_mc_addr_list(struct ice_dcf_hw *hw,
args.v_op = add ? VIRTCHNL_OP_ADD_ETH_ADDR :
VIRTCHNL_OP_DEL_ETH_ADDR;
args.req_msg = (uint8_t *)list;
- args.req_msglen = len;
+ args.req_msglen = sizeof(list_req);
err = ice_dcf_execute_virtchnl_cmd(hw, &args);
if (err)
PMD_DRV_LOG(ERR, "fail to execute command %s",
add ? "OP_ADD_ETHER_ADDRESS" :
"OP_DEL_ETHER_ADDRESS");
- rte_free(list);
return err;
}
--
2.47.3
^ permalink raw reply related
* [PATCH v6 24/27] net/ice: avoid rte malloc in RSS RETA operations
From: Anatoly Burakov @ 2026-02-19 16:23 UTC (permalink / raw)
To: dev, Bruce Richardson
In-Reply-To: <cover.1771518103.git.anatoly.burakov@intel.com>
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 <anatoly.burakov@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
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
^ permalink raw reply related
* [PATCH v6 23/27] net/iavf: avoid rte malloc in irq map config
From: Anatoly Burakov @ 2026-02-19 16:23 UTC (permalink / raw)
To: dev, Vladimir Medvedkin
In-Reply-To: <cover.1771518103.git.anatoly.burakov@intel.com>
Currently, when configuring IRQ maps, 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.
The original code did not check maximum IRQ map size, because the design
was built around an anti-pattern of caller having to chunk the IRQ map
calls. This has now been corrected as well.
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
drivers/net/intel/iavf/iavf.h | 3 +-
drivers/net/intel/iavf/iavf_ethdev.c | 15 +---
drivers/net/intel/iavf/iavf_vchnl.c | 110 +++++++++++++++++----------
3 files changed, 72 insertions(+), 56 deletions(-)
diff --git a/drivers/net/intel/iavf/iavf.h b/drivers/net/intel/iavf/iavf.h
index 77a2c94290..f9bb398a77 100644
--- a/drivers/net/intel/iavf/iavf.h
+++ b/drivers/net/intel/iavf/iavf.h
@@ -511,8 +511,7 @@ int iavf_add_del_vlan_v2(struct iavf_adapter *adapter, uint16_t vlanid,
bool add);
int iavf_get_vlan_offload_caps_v2(struct iavf_adapter *adapter);
int iavf_config_irq_map(struct iavf_adapter *adapter);
-int iavf_config_irq_map_lv(struct iavf_adapter *adapter, uint16_t num,
- uint16_t index);
+int iavf_config_irq_map_lv(struct iavf_adapter *adapter, uint16_t num);
void iavf_add_del_all_mac_addr(struct iavf_adapter *adapter, bool add);
int iavf_dev_link_update(struct rte_eth_dev *dev,
__rte_unused int wait_to_complete);
diff --git a/drivers/net/intel/iavf/iavf_ethdev.c b/drivers/net/intel/iavf/iavf_ethdev.c
index f7bfd099ed..89826547f0 100644
--- a/drivers/net/intel/iavf/iavf_ethdev.c
+++ b/drivers/net/intel/iavf/iavf_ethdev.c
@@ -919,20 +919,7 @@ static int iavf_config_rx_queues_irqs(struct rte_eth_dev *dev,
goto config_irq_map_err;
}
} else {
- uint16_t num_qv_maps = dev->data->nb_rx_queues;
- uint16_t index = 0;
-
- while (num_qv_maps > IAVF_IRQ_MAP_NUM_PER_BUF) {
- if (iavf_config_irq_map_lv(adapter,
- IAVF_IRQ_MAP_NUM_PER_BUF, index)) {
- PMD_DRV_LOG(ERR, "config interrupt mapping for large VF failed");
- goto config_irq_map_err;
- }
- num_qv_maps -= IAVF_IRQ_MAP_NUM_PER_BUF;
- index += IAVF_IRQ_MAP_NUM_PER_BUF;
- }
-
- if (iavf_config_irq_map_lv(adapter, num_qv_maps, index)) {
+ if (iavf_config_irq_map_lv(adapter, dev->data->nb_rx_queues)) {
PMD_DRV_LOG(ERR, "config interrupt mapping for large VF failed");
goto config_irq_map_err;
}
diff --git a/drivers/net/intel/iavf/iavf_vchnl.c b/drivers/net/intel/iavf/iavf_vchnl.c
index f0ab3b950b..baadb4b686 100644
--- a/drivers/net/intel/iavf/iavf_vchnl.c
+++ b/drivers/net/intel/iavf/iavf_vchnl.c
@@ -1314,81 +1314,111 @@ int
iavf_config_irq_map(struct iavf_adapter *adapter)
{
struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
- struct virtchnl_irq_map_info *map_info;
- struct virtchnl_vector_map *vecmap;
- struct iavf_cmd_info args;
- int len, i, err;
+ struct {
+ struct virtchnl_irq_map_info map_info;
+ struct virtchnl_vector_map vecmap[IAVF_MAX_NUM_QUEUES_DFLT];
+ } map_req = {0};
+ struct virtchnl_irq_map_info *map_info = &map_req.map_info;
+ struct iavf_cmd_info args = {0};
+ int i, err, max_vmi = -1;
- len = sizeof(struct virtchnl_irq_map_info) +
- sizeof(struct virtchnl_vector_map) * vf->nb_msix;
+ if (adapter->dev_data->nb_rx_queues > IAVF_MAX_NUM_QUEUES_DFLT) {
+ PMD_DRV_LOG(ERR, "number of queues (%u) exceeds the max supported (%u)",
+ adapter->dev_data->nb_rx_queues, IAVF_MAX_NUM_QUEUES_DFLT);
+ return -EINVAL;
+ }
- map_info = rte_zmalloc("map_info", len, 0);
- if (!map_info)
- return -ENOMEM;
-
- map_info->num_vectors = vf->nb_msix;
for (i = 0; i < adapter->dev_data->nb_rx_queues; i++) {
- vecmap =
- &map_info->vecmap[vf->qv_map[i].vector_id - vf->msix_base];
+ struct virtchnl_vector_map *vecmap;
+ /* always 0 for 1 MSIX, never bigger than rxq for multi MSIX */
+ uint16_t vmi = vf->qv_map[i].vector_id - vf->msix_base;
+
+ /* can't happen but avoid static analysis warnings */
+ if (vmi >= IAVF_MAX_NUM_QUEUES_DFLT) {
+ PMD_DRV_LOG(ERR, "vector id (%u) exceeds the max supported (%u)",
+ vf->qv_map[i].vector_id,
+ vf->msix_base + IAVF_MAX_NUM_QUEUES_DFLT - 1);
+ return -EINVAL;
+ }
+
+ vecmap = &map_info->vecmap[vmi];
vecmap->vsi_id = vf->vsi_res->vsi_id;
vecmap->rxitr_idx = IAVF_ITR_INDEX_DEFAULT;
vecmap->vector_id = vf->qv_map[i].vector_id;
vecmap->txq_map = 0;
vecmap->rxq_map |= 1 << vf->qv_map[i].queue_id;
+
+ /* MSIX vectors round robin so look for max */
+ if (vmi > max_vmi) {
+ map_info->num_vectors++;
+ max_vmi = vmi;
+ }
}
args.ops = VIRTCHNL_OP_CONFIG_IRQ_MAP;
args.in_args = (u8 *)map_info;
- args.in_args_size = len;
+ args.in_args_size = sizeof(map_req);
args.out_buffer = vf->aq_resp;
args.out_size = IAVF_AQ_BUF_SZ;
err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
if (err)
PMD_DRV_LOG(ERR, "fail to execute command OP_CONFIG_IRQ_MAP");
- rte_free(map_info);
return err;
}
-int
-iavf_config_irq_map_lv(struct iavf_adapter *adapter, uint16_t num,
- uint16_t index)
+static int
+iavf_config_irq_map_lv_chunk(struct iavf_adapter *adapter, uint16_t chunk_sz, uint16_t chunk_start)
{
+ struct {
+ struct virtchnl_queue_vector_maps map_info;
+ struct virtchnl_queue_vector qv_maps[IAVF_CFG_Q_NUM_PER_BUF];
+ } chunk_req = {0};
struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
- struct virtchnl_queue_vector_maps *map_info;
- struct virtchnl_queue_vector *qv_maps;
- struct iavf_cmd_info args;
- int len, i, err;
- int count = 0;
+ struct iavf_cmd_info args = {0};
+ struct virtchnl_queue_vector_maps *map_info = &chunk_req.map_info;
+ struct virtchnl_queue_vector *qv_maps = chunk_req.qv_maps;
+ uint16_t chunk_end = chunk_start + chunk_sz;
+ uint16_t i;
- len = sizeof(struct virtchnl_queue_vector_maps) +
- sizeof(struct virtchnl_queue_vector) * (num - 1);
-
- map_info = rte_zmalloc("map_info", len, 0);
- if (!map_info)
- return -ENOMEM;
+ if (chunk_sz > IAVF_CFG_Q_NUM_PER_BUF)
+ return -EINVAL;
map_info->vport_id = vf->vsi_res->vsi_id;
- map_info->num_qv_maps = num;
- for (i = index; i < index + map_info->num_qv_maps; i++) {
- qv_maps = &map_info->qv_maps[count++];
+ map_info->num_qv_maps = chunk_sz;
+ for (i = chunk_start; i < chunk_end; i++) {
+ qv_maps = &map_info->qv_maps[i];
qv_maps->itr_idx = VIRTCHNL_ITR_IDX_0;
qv_maps->queue_type = VIRTCHNL_QUEUE_TYPE_RX;
- qv_maps->queue_id = vf->qv_map[i].queue_id;
- qv_maps->vector_id = vf->qv_map[i].vector_id;
+ qv_maps->queue_id = vf->qv_map[chunk_start + i].queue_id;
+ qv_maps->vector_id = vf->qv_map[chunk_start + i].vector_id;
}
args.ops = VIRTCHNL_OP_MAP_QUEUE_VECTOR;
args.in_args = (u8 *)map_info;
- args.in_args_size = len;
+ args.in_args_size = sizeof(chunk_req);
args.out_buffer = vf->aq_resp;
args.out_size = IAVF_AQ_BUF_SZ;
- err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
- if (err)
- PMD_DRV_LOG(ERR, "fail to execute command OP_MAP_QUEUE_VECTOR");
- rte_free(map_info);
- return err;
+ return iavf_execute_vf_cmd_safe(adapter, &args, 0);
+}
+
+int
+iavf_config_irq_map_lv(struct iavf_adapter *adapter, uint16_t num)
+{
+ uint16_t c;
+ int err;
+
+ for (c = 0; c < num; c += IAVF_CFG_Q_NUM_PER_BUF) {
+ uint16_t chunk_sz = RTE_MIN(num - c, IAVF_CFG_Q_NUM_PER_BUF);
+ err = iavf_config_irq_map_lv_chunk(adapter, chunk_sz, c);
+ if (err) {
+ PMD_DRV_LOG(ERR, "Failed to configure irq map chunk [%u, %u)",
+ c, c + chunk_sz);
+ return err;
+ }
+ }
+ return 0;
}
void
--
2.47.3
^ permalink raw reply related
* [PATCH v6 22/27] net/iavf: avoid rte malloc in queue operations
From: Anatoly Burakov @ 2026-02-19 16:23 UTC (permalink / raw)
To: dev, Vladimir Medvedkin
In-Reply-To: <cover.1771518103.git.anatoly.burakov@intel.com>
Currently, when enabling, disabling, or switching queues, we are using
rte_malloc followed by an immediate rte_free. This is not needed as these
structures are not being stored anywhere, so replace them with stack
allocation.
The original code did not check maximum queue number, because the design
was built around an anti-pattern of caller having to chunk the queue
configuration. This has now been corrected as well.
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
drivers/net/intel/iavf/iavf.h | 3 +-
drivers/net/intel/iavf/iavf_ethdev.c | 15 +-
drivers/net/intel/iavf/iavf_vchnl.c | 212 ++++++++++++++-------------
3 files changed, 115 insertions(+), 115 deletions(-)
diff --git a/drivers/net/intel/iavf/iavf.h b/drivers/net/intel/iavf/iavf.h
index 6054321771..77a2c94290 100644
--- a/drivers/net/intel/iavf/iavf.h
+++ b/drivers/net/intel/iavf/iavf.h
@@ -503,8 +503,7 @@ int iavf_disable_queues(struct iavf_adapter *adapter);
int iavf_disable_queues_lv(struct iavf_adapter *adapter);
int iavf_configure_rss_lut(struct iavf_adapter *adapter);
int iavf_configure_rss_key(struct iavf_adapter *adapter);
-int iavf_configure_queues(struct iavf_adapter *adapter,
- uint16_t num_queue_pairs, uint16_t index);
+int iavf_configure_queues(struct iavf_adapter *adapter, uint16_t num_queue_pairs);
int iavf_get_supported_rxdid(struct iavf_adapter *adapter);
int iavf_config_vlan_strip_v2(struct iavf_adapter *adapter, bool enable);
int iavf_config_vlan_insert_v2(struct iavf_adapter *adapter, bool enable);
diff --git a/drivers/net/intel/iavf/iavf_ethdev.c b/drivers/net/intel/iavf/iavf_ethdev.c
index f74a0cb21f..f7bfd099ed 100644
--- a/drivers/net/intel/iavf/iavf_ethdev.c
+++ b/drivers/net/intel/iavf/iavf_ethdev.c
@@ -1036,20 +1036,7 @@ iavf_dev_start(struct rte_eth_dev *dev)
if (iavf_set_vf_quanta_size(adapter, index, num_queue_pairs) != 0)
PMD_DRV_LOG(WARNING, "configure quanta size failed");
- /* If needed, send configure queues msg multiple times to make the
- * adminq buffer length smaller than the 4K limitation.
- */
- while (num_queue_pairs > IAVF_CFG_Q_NUM_PER_BUF) {
- if (iavf_configure_queues(adapter,
- IAVF_CFG_Q_NUM_PER_BUF, index) != 0) {
- PMD_DRV_LOG(ERR, "configure queues failed");
- goto error;
- }
- num_queue_pairs -= IAVF_CFG_Q_NUM_PER_BUF;
- index += IAVF_CFG_Q_NUM_PER_BUF;
- }
-
- if (iavf_configure_queues(adapter, num_queue_pairs, index) != 0) {
+ if (iavf_configure_queues(adapter, num_queue_pairs) != 0) {
PMD_DRV_LOG(ERR, "configure queues failed");
goto error;
}
diff --git a/drivers/net/intel/iavf/iavf_vchnl.c b/drivers/net/intel/iavf/iavf_vchnl.c
index f44dc7e7be..f0ab3b950b 100644
--- a/drivers/net/intel/iavf/iavf_vchnl.c
+++ b/drivers/net/intel/iavf/iavf_vchnl.c
@@ -1020,19 +1020,15 @@ int
iavf_enable_queues_lv(struct iavf_adapter *adapter)
{
struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
- struct virtchnl_del_ena_dis_queues *queue_select;
- struct virtchnl_queue_chunk *queue_chunk;
+ struct {
+ struct virtchnl_del_ena_dis_queues msg;
+ struct virtchnl_queue_chunk chunks[IAVF_RXTX_QUEUE_CHUNKS_NUM - 1];
+ } queue_req = {0};
+ struct virtchnl_del_ena_dis_queues *queue_select = &queue_req.msg;
+ struct virtchnl_queue_chunk *queue_chunk = queue_select->chunks.chunks;
struct iavf_cmd_info args;
- int err, len;
+ int err;
- len = sizeof(struct virtchnl_del_ena_dis_queues) +
- sizeof(struct virtchnl_queue_chunk) *
- (IAVF_RXTX_QUEUE_CHUNKS_NUM - 1);
- queue_select = rte_zmalloc("queue_select", len, 0);
- if (!queue_select)
- return -ENOMEM;
-
- queue_chunk = queue_select->chunks.chunks;
queue_select->chunks.num_chunks = IAVF_RXTX_QUEUE_CHUNKS_NUM;
queue_select->vport_id = vf->vsi_res->vsi_id;
@@ -1048,7 +1044,7 @@ iavf_enable_queues_lv(struct iavf_adapter *adapter)
args.ops = VIRTCHNL_OP_ENABLE_QUEUES_V2;
args.in_args = (u8 *)queue_select;
- args.in_args_size = len;
+ args.in_args_size = sizeof(queue_req);
args.out_buffer = vf->aq_resp;
args.out_size = IAVF_AQ_BUF_SZ;
err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
@@ -1056,7 +1052,6 @@ iavf_enable_queues_lv(struct iavf_adapter *adapter)
PMD_DRV_LOG(ERR,
"Failed to execute command of OP_ENABLE_QUEUES_V2");
- rte_free(queue_select);
return err;
}
@@ -1064,19 +1059,15 @@ int
iavf_disable_queues_lv(struct iavf_adapter *adapter)
{
struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
- struct virtchnl_del_ena_dis_queues *queue_select;
- struct virtchnl_queue_chunk *queue_chunk;
+ struct {
+ struct virtchnl_del_ena_dis_queues msg;
+ struct virtchnl_queue_chunk chunks[IAVF_RXTX_QUEUE_CHUNKS_NUM - 1];
+ } queue_req = {0};
+ struct virtchnl_del_ena_dis_queues *queue_select = &queue_req.msg;
+ struct virtchnl_queue_chunk *queue_chunk = queue_select->chunks.chunks;
struct iavf_cmd_info args;
- int err, len;
+ int err;
- len = sizeof(struct virtchnl_del_ena_dis_queues) +
- sizeof(struct virtchnl_queue_chunk) *
- (IAVF_RXTX_QUEUE_CHUNKS_NUM - 1);
- queue_select = rte_zmalloc("queue_select", len, 0);
- if (!queue_select)
- return -ENOMEM;
-
- queue_chunk = queue_select->chunks.chunks;
queue_select->chunks.num_chunks = IAVF_RXTX_QUEUE_CHUNKS_NUM;
queue_select->vport_id = vf->vsi_res->vsi_id;
@@ -1092,7 +1083,7 @@ iavf_disable_queues_lv(struct iavf_adapter *adapter)
args.ops = VIRTCHNL_OP_DISABLE_QUEUES_V2;
args.in_args = (u8 *)queue_select;
- args.in_args_size = len;
+ args.in_args_size = sizeof(queue_req);
args.out_buffer = vf->aq_resp;
args.out_size = IAVF_AQ_BUF_SZ;
err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
@@ -1100,7 +1091,6 @@ iavf_disable_queues_lv(struct iavf_adapter *adapter)
PMD_DRV_LOG(ERR,
"Failed to execute command of OP_DISABLE_QUEUES_V2");
- rte_free(queue_select);
return err;
}
@@ -1109,17 +1099,14 @@ iavf_switch_queue_lv(struct iavf_adapter *adapter, uint16_t qid,
bool rx, bool on)
{
struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
- struct virtchnl_del_ena_dis_queues *queue_select;
- struct virtchnl_queue_chunk *queue_chunk;
+ struct {
+ struct virtchnl_del_ena_dis_queues msg;
+ } queue_req = {0};
+ struct virtchnl_del_ena_dis_queues *queue_select = &queue_req.msg;
+ struct virtchnl_queue_chunk *queue_chunk = queue_select->chunks.chunks;
struct iavf_cmd_info args;
- int err, len;
+ int err;
- len = sizeof(struct virtchnl_del_ena_dis_queues);
- queue_select = rte_zmalloc("queue_select", len, 0);
- if (!queue_select)
- return -ENOMEM;
-
- queue_chunk = queue_select->chunks.chunks;
queue_select->chunks.num_chunks = 1;
queue_select->vport_id = vf->vsi_res->vsi_id;
@@ -1138,7 +1125,7 @@ iavf_switch_queue_lv(struct iavf_adapter *adapter, uint16_t qid,
else
args.ops = VIRTCHNL_OP_DISABLE_QUEUES_V2;
args.in_args = (u8 *)queue_select;
- args.in_args_size = len;
+ args.in_args_size = sizeof(queue_req);
args.out_buffer = vf->aq_resp;
args.out_size = IAVF_AQ_BUF_SZ;
err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
@@ -1146,7 +1133,6 @@ iavf_switch_queue_lv(struct iavf_adapter *adapter, uint16_t qid,
PMD_DRV_LOG(ERR, "Failed to execute command of %s",
on ? "OP_ENABLE_QUEUES_V2" : "OP_DISABLE_QUEUES_V2");
- rte_free(queue_select);
return err;
}
@@ -1214,88 +1200,116 @@ iavf_configure_rss_key(struct iavf_adapter *adapter)
return err;
}
-int
-iavf_configure_queues(struct iavf_adapter *adapter,
- uint16_t num_queue_pairs, uint16_t index)
+static void
+iavf_configure_queue_pair(struct iavf_adapter *adapter,
+ struct virtchnl_queue_pair_info *vc_qp,
+ uint16_t q_idx)
{
+ struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
struct ci_rx_queue **rxq = (struct ci_rx_queue **)adapter->dev_data->rx_queues;
struct ci_tx_queue **txq = (struct ci_tx_queue **)adapter->dev_data->tx_queues;
+
+ /* common parts */
+ vc_qp->txq.vsi_id = vf->vsi_res->vsi_id;
+ vc_qp->txq.queue_id = q_idx;
+
+ vc_qp->rxq.vsi_id = vf->vsi_res->vsi_id;
+ vc_qp->rxq.queue_id = q_idx;
+ vc_qp->rxq.max_pkt_size = vf->max_pkt_len;
+
+ /* is this txq active? */
+ if (q_idx < adapter->dev_data->nb_tx_queues) {
+ vc_qp->txq.ring_len = txq[q_idx]->nb_tx_desc;
+ vc_qp->txq.dma_ring_addr = txq[q_idx]->tx_ring_dma;
+ }
+
+ /* is this rxq active? */
+ if (q_idx >= adapter->dev_data->nb_rx_queues)
+ return;
+
+ vc_qp->rxq.ring_len = rxq[q_idx]->nb_rx_desc;
+ vc_qp->rxq.dma_ring_addr = rxq[q_idx]->rx_ring_phys_addr;
+ vc_qp->rxq.databuffer_size = rxq[q_idx]->rx_buf_len;
+ vc_qp->rxq.crc_disable = rxq[q_idx]->crc_len != 0 ? 1 : 0;
+ if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC) {
+ if (vf->supported_rxdid & RTE_BIT64(rxq[q_idx]->rxdid)) {
+ vc_qp->rxq.rxdid = rxq[q_idx]->rxdid;
+ PMD_DRV_LOG(NOTICE, "request RXDID[%d] in Queue[%d]",
+ vc_qp->rxq.rxdid, q_idx);
+ } else {
+ PMD_DRV_LOG(NOTICE, "RXDID[%d] is not supported, "
+ "request default RXDID[%d] in Queue[%d]",
+ rxq[q_idx]->rxdid, IAVF_RXDID_LEGACY_1, q_idx);
+ vc_qp->rxq.rxdid = IAVF_RXDID_LEGACY_1;
+ }
+
+ if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_CAP_PTP &&
+ vf->ptp_caps & VIRTCHNL_1588_PTP_CAP_RX_TSTAMP &&
+ rxq[q_idx]->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
+ vc_qp->rxq.flags |= VIRTCHNL_PTP_RX_TSTAMP;
+ }
+}
+
+static int
+iavf_configure_queue_chunk(struct iavf_adapter *adapter,
+ uint16_t chunk_sz,
+ uint16_t chunk_start)
+{
struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
- struct virtchnl_vsi_queue_config_info *vc_config;
- struct virtchnl_queue_pair_info *vc_qp;
- struct iavf_cmd_info args;
- uint16_t i, size;
+ struct {
+ struct virtchnl_vsi_queue_config_info config;
+ struct virtchnl_queue_pair_info qp[IAVF_CFG_Q_NUM_PER_BUF];
+ } queue_req = {0};
+ struct iavf_cmd_info args = {0};
+ struct virtchnl_vsi_queue_config_info *vc_config = &queue_req.config;
+ struct virtchnl_queue_pair_info *vc_qp = vc_config->qpair;
+ uint16_t chunk_end = chunk_start + chunk_sz;
+ uint16_t i;
int err;
- size = sizeof(*vc_config) +
- sizeof(vc_config->qpair[0]) * num_queue_pairs;
- vc_config = rte_zmalloc("cfg_queue", size, 0);
- if (!vc_config)
- return -ENOMEM;
+ if (chunk_sz > IAVF_CFG_Q_NUM_PER_BUF)
+ return -EINVAL;
vc_config->vsi_id = vf->vsi_res->vsi_id;
- vc_config->num_queue_pairs = num_queue_pairs;
+ vc_config->num_queue_pairs = chunk_sz;
- for (i = index, vc_qp = vc_config->qpair;
- i < index + num_queue_pairs;
- i++, vc_qp++) {
- vc_qp->txq.vsi_id = vf->vsi_res->vsi_id;
- vc_qp->txq.queue_id = i;
+ for (i = chunk_start; i < chunk_end; i++, vc_qp++)
+ iavf_configure_queue_pair(adapter, vc_qp, i);
- /* Virtchnnl configure tx queues by pairs */
- if (i < adapter->dev_data->nb_tx_queues) {
- vc_qp->txq.ring_len = txq[i]->nb_tx_desc;
- vc_qp->txq.dma_ring_addr = txq[i]->tx_ring_dma;
- }
-
- vc_qp->rxq.vsi_id = vf->vsi_res->vsi_id;
- vc_qp->rxq.queue_id = i;
- vc_qp->rxq.max_pkt_size = vf->max_pkt_len;
-
- if (i >= adapter->dev_data->nb_rx_queues)
- continue;
-
- /* Virtchnnl configure rx queues by pairs */
- vc_qp->rxq.ring_len = rxq[i]->nb_rx_desc;
- vc_qp->rxq.dma_ring_addr = rxq[i]->rx_ring_phys_addr;
- vc_qp->rxq.databuffer_size = rxq[i]->rx_buf_len;
- vc_qp->rxq.crc_disable = rxq[i]->crc_len != 0 ? 1 : 0;
- if (vf->vf_res->vf_cap_flags &
- VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC) {
- if (vf->supported_rxdid & RTE_BIT64(rxq[i]->rxdid)) {
- vc_qp->rxq.rxdid = rxq[i]->rxdid;
- PMD_DRV_LOG(NOTICE, "request RXDID[%d] in Queue[%d]",
- vc_qp->rxq.rxdid, i);
- } else {
- PMD_DRV_LOG(NOTICE, "RXDID[%d] is not supported, "
- "request default RXDID[%d] in Queue[%d]",
- rxq[i]->rxdid, IAVF_RXDID_LEGACY_1, i);
- vc_qp->rxq.rxdid = IAVF_RXDID_LEGACY_1;
- }
-
- if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_CAP_PTP &&
- vf->ptp_caps & VIRTCHNL_1588_PTP_CAP_RX_TSTAMP &&
- rxq[i]->offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
- vc_qp->rxq.flags |= VIRTCHNL_PTP_RX_TSTAMP;
- }
- }
-
- memset(&args, 0, sizeof(args));
args.ops = VIRTCHNL_OP_CONFIG_VSI_QUEUES;
args.in_args = (uint8_t *)vc_config;
- args.in_args_size = size;
+ args.in_args_size = sizeof(queue_req);
args.out_buffer = vf->aq_resp;
args.out_size = IAVF_AQ_BUF_SZ;
err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
if (err)
- PMD_DRV_LOG(ERR, "Failed to execute command of"
- " VIRTCHNL_OP_CONFIG_VSI_QUEUES");
-
- rte_free(vc_config);
+ PMD_DRV_LOG(ERR, "Failed to execute command VIRTCHNL_OP_CONFIG_VSI_QUEUES");
return err;
}
+int
+iavf_configure_queues(struct iavf_adapter *adapter, uint16_t num_queue_pairs)
+{
+ uint16_t c;
+ int err;
+
+ /*
+ * we cannot configure all queues in one go because they won't fit into
+ * adminq buffer, so we're going to chunk them instead
+ */
+ for (c = 0; c < num_queue_pairs; c += IAVF_CFG_Q_NUM_PER_BUF) {
+ uint16_t chunk_sz = RTE_MIN(num_queue_pairs - c, IAVF_CFG_Q_NUM_PER_BUF);
+ err = iavf_configure_queue_chunk(adapter, chunk_sz, c);
+ if (err) {
+ PMD_DRV_LOG(ERR, "Failed to configure queues chunk [%u, %u)",
+ c, c + chunk_sz);
+ return err;
+ }
+ }
+ return 0;
+}
+
int
iavf_config_irq_map(struct iavf_adapter *adapter)
{
--
2.47.3
^ permalink raw reply related
* [PATCH v6 21/27] net/iavf: avoid rte malloc in IPsec operations
From: Anatoly Burakov @ 2026-02-19 16:23 UTC (permalink / raw)
To: dev, Vladimir Medvedkin
In-Reply-To: <cover.1771518103.git.anatoly.burakov@intel.com>
Currently, when performing IPsec security association operations and
retrieving device capabilities, we are using rte_malloc followed by
immediate rte_free. This memory does not need to be stored in hugepage
memory and the allocation size can be pretty small, so replace with stack
allocation.
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
drivers/net/intel/iavf/iavf_ipsec_crypto.c | 122 +++++++--------------
1 file changed, 38 insertions(+), 84 deletions(-)
diff --git a/drivers/net/intel/iavf/iavf_ipsec_crypto.c b/drivers/net/intel/iavf/iavf_ipsec_crypto.c
index aa4cf1d96d..98aa8b115b 100644
--- a/drivers/net/intel/iavf/iavf_ipsec_crypto.c
+++ b/drivers/net/intel/iavf/iavf_ipsec_crypto.c
@@ -3,6 +3,7 @@
*/
#include <stdalign.h>
+#include <stdlib.h>
#include <rte_cryptodev.h>
#include <rte_ethdev.h>
@@ -902,29 +903,18 @@ static uint32_t
iavf_ipsec_crypto_sa_del(struct iavf_adapter *adapter,
struct iavf_security_session *sess)
{
- struct inline_ipsec_msg *request = NULL, *response = NULL;
- size_t request_len, response_len;
+ struct {
+ struct inline_ipsec_msg msg;
+ struct virtchnl_ipsec_sa_destroy sa_destroy;
+ } req = {0};
+ struct {
+ struct inline_ipsec_msg msg;
+ struct virtchnl_ipsec_resp resp;
+ } resp = {0};
+ struct inline_ipsec_msg *request = &req.msg, *response = &resp.msg;
int rc = 0;
- request_len = sizeof(struct inline_ipsec_msg) +
- sizeof(struct virtchnl_ipsec_sa_destroy);
-
- request = rte_malloc("iavf-sa-del-request", request_len, 0);
- if (request == NULL) {
- rc = -ENOMEM;
- goto update_cleanup;
- }
-
- response_len = sizeof(struct inline_ipsec_msg) +
- sizeof(struct virtchnl_ipsec_resp);
-
- response = rte_malloc("iavf-sa-del-response", response_len, 0);
- if (response == NULL) {
- rc = -ENOMEM;
- goto update_cleanup;
- }
-
/* set msg header params */
request->ipsec_opcode = INLINE_IPSEC_OP_SA_DESTROY;
request->req_id = (uint16_t)0xDEADBEEF;
@@ -942,10 +932,10 @@ iavf_ipsec_crypto_sa_del(struct iavf_adapter *adapter,
/* send virtual channel request to add SA to hardware database */
rc = iavf_ipsec_crypto_request(adapter,
- (uint8_t *)request, request_len,
- (uint8_t *)response, response_len);
+ (uint8_t *)request, sizeof(req),
+ (uint8_t *)response, sizeof(resp));
if (rc)
- goto update_cleanup;
+ return rc;
/* verify response */
if (response->ipsec_opcode != request->ipsec_opcode ||
@@ -960,10 +950,6 @@ iavf_ipsec_crypto_sa_del(struct iavf_adapter *adapter,
response->ipsec_data.ipsec_status->status)
rc = -EFAULT;
-update_cleanup:
- rte_free(response);
- rte_free(request);
-
return rc;
}
@@ -1109,51 +1095,35 @@ static int
iavf_ipsec_crypto_device_capabilities_get(struct iavf_adapter *adapter,
struct virtchnl_ipsec_cap *capability)
{
+ struct {
+ struct inline_ipsec_msg msg;
+ } req = {0};
+ struct {
+ struct inline_ipsec_msg msg;
+ struct virtchnl_ipsec_cap cap;
+ } resp = {0};
/* Perform pf-vf comms */
- struct inline_ipsec_msg *request = NULL, *response = NULL;
- size_t request_len, response_len;
+ struct inline_ipsec_msg *request = &req.msg, *response = &resp.msg;
int rc;
- request_len = sizeof(struct inline_ipsec_msg);
-
- request = rte_malloc("iavf-device-capability-request", request_len, 0);
- if (request == NULL) {
- rc = -ENOMEM;
- goto update_cleanup;
- }
-
- response_len = sizeof(struct inline_ipsec_msg) +
- sizeof(struct virtchnl_ipsec_cap);
- response = rte_malloc("iavf-device-capability-response",
- response_len, 0);
- if (response == NULL) {
- rc = -ENOMEM;
- goto update_cleanup;
- }
-
/* set msg header params */
request->ipsec_opcode = INLINE_IPSEC_OP_GET_CAP;
request->req_id = (uint16_t)0xDEADBEEF;
/* send virtual channel request to add SA to hardware database */
rc = iavf_ipsec_crypto_request(adapter,
- (uint8_t *)request, request_len,
- (uint8_t *)response, response_len);
+ (uint8_t *)request, sizeof(req),
+ (uint8_t *)response, sizeof(resp));
if (rc)
- goto update_cleanup;
+ return rc;
/* verify response id */
if (response->ipsec_opcode != request->ipsec_opcode ||
response->req_id != request->req_id){
- rc = -EFAULT;
- goto update_cleanup;
+ return -EFAULT;
}
memcpy(capability, response->ipsec_data.ipsec_cap, sizeof(*capability));
-update_cleanup:
- rte_free(response);
- rte_free(request);
-
return rc;
}
@@ -1535,50 +1505,34 @@ iavf_ipsec_crypto_status_get(struct iavf_adapter *adapter,
struct virtchnl_ipsec_status *status)
{
/* Perform pf-vf comms */
- struct inline_ipsec_msg *request = NULL, *response = NULL;
- size_t request_len, response_len;
+ struct {
+ struct inline_ipsec_msg msg;
+ } req = {0};
+ struct {
+ struct inline_ipsec_msg msg;
+ struct virtchnl_ipsec_cap cap;
+ } resp = {0};
+ struct inline_ipsec_msg *request = &req.msg, *response = &resp.msg;
int rc;
- request_len = sizeof(struct inline_ipsec_msg);
-
- request = rte_malloc("iavf-device-status-request", request_len, 0);
- if (request == NULL) {
- rc = -ENOMEM;
- goto update_cleanup;
- }
-
- response_len = sizeof(struct inline_ipsec_msg) +
- sizeof(struct virtchnl_ipsec_cap);
- response = rte_malloc("iavf-device-status-response",
- response_len, 0);
- if (response == NULL) {
- rc = -ENOMEM;
- goto update_cleanup;
- }
-
/* set msg header params */
request->ipsec_opcode = INLINE_IPSEC_OP_GET_STATUS;
request->req_id = (uint16_t)0xDEADBEEF;
/* send virtual channel request to add SA to hardware database */
rc = iavf_ipsec_crypto_request(adapter,
- (uint8_t *)request, request_len,
- (uint8_t *)response, response_len);
+ (uint8_t *)request, sizeof(req),
+ (uint8_t *)response, sizeof(resp));
if (rc)
- goto update_cleanup;
+ return rc;
/* verify response id */
if (response->ipsec_opcode != request->ipsec_opcode ||
- response->req_id != request->req_id){
- rc = -EFAULT;
- goto update_cleanup;
+ response->req_id != request->req_id){
+ return -EFAULT;
}
memcpy(status, response->ipsec_data.ipsec_status, sizeof(*status));
-update_cleanup:
- rte_free(response);
- rte_free(request);
-
return rc;
}
--
2.47.3
^ permalink raw reply related
* [PATCH v6 20/27] net/iavf: avoid rte malloc in MAC address operations
From: Anatoly Burakov @ 2026-02-19 16:23 UTC (permalink / raw)
To: dev, Vladimir Medvedkin
In-Reply-To: <cover.1771518103.git.anatoly.burakov@intel.com>
Currently, when adding or deleting MAC addresses, 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.
The original code also had a loop attempting to split up sending MAC
address list into multiple virtchnl messages. However, maximum number of
MAC addresses is 64, sizeof() each MAC address is 8 bytes, and maximum
virtchnl message size is 4K, so splitting it up is actually unnecessary.
This loop has been removed.
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
drivers/net/intel/iavf/iavf_vchnl.c | 82 ++++++++++-------------------
1 file changed, 29 insertions(+), 53 deletions(-)
diff --git a/drivers/net/intel/iavf/iavf_vchnl.c b/drivers/net/intel/iavf/iavf_vchnl.c
index 55986ef909..f44dc7e7be 100644
--- a/drivers/net/intel/iavf/iavf_vchnl.c
+++ b/drivers/net/intel/iavf/iavf_vchnl.c
@@ -1380,63 +1380,39 @@ iavf_config_irq_map_lv(struct iavf_adapter *adapter, uint16_t num,
void
iavf_add_del_all_mac_addr(struct iavf_adapter *adapter, bool add)
{
- struct virtchnl_ether_addr_list *list;
+ struct {
+ struct virtchnl_ether_addr_list list;
+ struct virtchnl_ether_addr addr[IAVF_NUM_MACADDR_MAX];
+ } list_req = {0};
+ struct virtchnl_ether_addr_list *list = &list_req.list;
struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(adapter);
- struct rte_ether_addr *addr;
- struct iavf_cmd_info args;
- int len, err, i, j;
- int next_begin = 0;
- int begin = 0;
+ struct iavf_cmd_info args = {0};
+ int err, i;
- do {
- j = 0;
- len = sizeof(struct virtchnl_ether_addr_list);
- for (i = begin; i < IAVF_NUM_MACADDR_MAX; i++, next_begin++) {
- addr = &adapter->dev_data->mac_addrs[i];
- if (rte_is_zero_ether_addr(addr))
- continue;
- len += sizeof(struct virtchnl_ether_addr);
- if (len >= IAVF_AQ_BUF_SZ) {
- next_begin = i + 1;
- break;
- }
- }
+ for (i = 0; i < IAVF_NUM_MACADDR_MAX; i++) {
+ struct rte_ether_addr *addr = &adapter->dev_data->mac_addrs[i];
+ struct virtchnl_ether_addr *vc_addr = &list->list[list->num_elements];
- list = rte_zmalloc("iavf_del_mac_buffer", len, 0);
- if (!list) {
- PMD_DRV_LOG(ERR, "fail to allocate memory");
- return;
- }
+ /* ignore empty addresses */
+ if (rte_is_zero_ether_addr(addr))
+ continue;
+ list->num_elements++;
- for (i = begin; i < next_begin; i++) {
- addr = &adapter->dev_data->mac_addrs[i];
- if (rte_is_zero_ether_addr(addr))
- continue;
- rte_memcpy(list->list[j].addr, addr->addr_bytes,
- sizeof(addr->addr_bytes));
- list->list[j].type = (j == 0 ?
- VIRTCHNL_ETHER_ADDR_PRIMARY :
- VIRTCHNL_ETHER_ADDR_EXTRA);
- PMD_DRV_LOG(DEBUG, "add/rm mac:" RTE_ETHER_ADDR_PRT_FMT,
- RTE_ETHER_ADDR_BYTES(addr));
- j++;
- }
- list->vsi_id = vf->vsi_res->vsi_id;
- list->num_elements = j;
- args.ops = add ? VIRTCHNL_OP_ADD_ETH_ADDR :
- VIRTCHNL_OP_DEL_ETH_ADDR;
- args.in_args = (uint8_t *)list;
- args.in_args_size = len;
- args.out_buffer = vf->aq_resp;
- args.out_size = IAVF_AQ_BUF_SZ;
- err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
- if (err)
- PMD_DRV_LOG(ERR, "fail to execute command %s",
- add ? "OP_ADD_ETHER_ADDRESS" :
- "OP_DEL_ETHER_ADDRESS");
- rte_free(list);
- begin = next_begin;
- } while (begin < IAVF_NUM_MACADDR_MAX);
+ memcpy(vc_addr->addr, addr->addr_bytes, sizeof(addr->addr_bytes));
+ vc_addr->type = (list->num_elements == 1) ?
+ VIRTCHNL_ETHER_ADDR_PRIMARY :
+ VIRTCHNL_ETHER_ADDR_EXTRA;
+ }
+ list->vsi_id = vf->vsi_res->vsi_id;
+ args.ops = add ? VIRTCHNL_OP_ADD_ETH_ADDR : VIRTCHNL_OP_DEL_ETH_ADDR;
+ args.in_args = (uint8_t *)list;
+ args.in_args_size = sizeof(list_req);
+ args.out_buffer = vf->aq_resp;
+ args.out_size = IAVF_AQ_BUF_SZ;
+ err = iavf_execute_vf_cmd_safe(adapter, &args, 0);
+ if (err)
+ PMD_DRV_LOG(ERR, "fail to execute command %s",
+ add ? "OP_ADD_ETHER_ADDRESS" : "OP_DEL_ETHER_ADDRESS");
}
int
--
2.47.3
^ permalink raw reply related
* [PATCH v6 19/27] net/iavf: avoid rte malloc in RSS configuration
From: Anatoly Burakov @ 2026-02-19 16:23 UTC (permalink / raw)
To: dev, Vladimir Medvedkin
In-Reply-To: <cover.1771518103.git.anatoly.burakov@intel.com>
Currently, when configuring RSS (redirection table, lookup table, and
hash key), we are using rte_zmalloc followed by an immediate rte_free.
This memory does not need to be stored in hugepage memory, and in context
of IAVF we do not define how big these structures can be, so replace the
allocations with regular malloc/free.
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
drivers/net/intel/iavf/iavf_ethdev.c | 4 ++--
drivers/net/intel/iavf/iavf_vchnl.c | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/net/intel/iavf/iavf_ethdev.c b/drivers/net/intel/iavf/iavf_ethdev.c
index e978284bf2..f74a0cb21f 100644
--- a/drivers/net/intel/iavf/iavf_ethdev.c
+++ b/drivers/net/intel/iavf/iavf_ethdev.c
@@ -1553,7 +1553,7 @@ iavf_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;
@@ -1573,7 +1573,7 @@ iavf_dev_rss_reta_update(struct rte_eth_dev *dev,
ret = iavf_configure_rss_lut(adapter);
if (ret) /* revert back */
rte_memcpy(vf->rss_lut, lut, reta_size);
- rte_free(lut);
+ free(lut);
return ret;
}
diff --git a/drivers/net/intel/iavf/iavf_vchnl.c b/drivers/net/intel/iavf/iavf_vchnl.c
index 9ad39300c6..55986ef909 100644
--- a/drivers/net/intel/iavf/iavf_vchnl.c
+++ b/drivers/net/intel/iavf/iavf_vchnl.c
@@ -1159,7 +1159,7 @@ iavf_configure_rss_lut(struct iavf_adapter *adapter)
int len, err = 0;
len = sizeof(*rss_lut) + vf->vf_res->rss_lut_size - 1;
- rss_lut = rte_zmalloc("rss_lut", len, 0);
+ rss_lut = calloc(1, len);
if (!rss_lut)
return -ENOMEM;
@@ -1178,7 +1178,7 @@ iavf_configure_rss_lut(struct iavf_adapter *adapter)
PMD_DRV_LOG(ERR,
"Failed to execute command of OP_CONFIG_RSS_LUT");
- rte_free(rss_lut);
+ free(rss_lut);
return err;
}
@@ -1191,7 +1191,7 @@ iavf_configure_rss_key(struct iavf_adapter *adapter)
int len, err = 0;
len = sizeof(*rss_key) + vf->vf_res->rss_key_size - 1;
- rss_key = rte_zmalloc("rss_key", len, 0);
+ rss_key = calloc(1, len);
if (!rss_key)
return -ENOMEM;
@@ -1210,7 +1210,7 @@ iavf_configure_rss_key(struct iavf_adapter *adapter)
PMD_DRV_LOG(ERR,
"Failed to execute command of OP_CONFIG_RSS_KEY");
- rte_free(rss_key);
+ free(rss_key);
return err;
}
--
2.47.3
^ permalink raw reply related
* [PATCH v6 18/27] net/iavf: avoid rte malloc in VF mailbox for IPsec
From: Anatoly Burakov @ 2026-02-19 16:23 UTC (permalink / raw)
To: dev, Vladimir Medvedkin
In-Reply-To: <cover.1771518103.git.anatoly.burakov@intel.com>
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 stack allocation.
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
drivers/net/intel/iavf/iavf_ipsec_crypto.c | 160 +++++++--------------
1 file changed, 54 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..aa4cf1d96d 100644
--- a/drivers/net/intel/iavf/iavf_ipsec_crypto.c
+++ b/drivers/net/intel/iavf/iavf_ipsec_crypto.c
@@ -458,36 +458,25 @@ 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 = {0};
+ struct {
+ struct inline_ipsec_msg msg;
+ struct virtchnl_ipsec_sa_cfg_resp sa_cfg_resp;
+ } sa_resp = {0};
+ struct inline_ipsec_msg *request = &sa_req.msg;
+ struct inline_ipsec_msg *response = &sa_resp.msg;
+ struct virtchnl_ipsec_sa_cfg *sa_cfg = &sa_req.sa_cfg;
int rc;
- request_len = sizeof(struct inline_ipsec_msg) +
- sizeof(struct virtchnl_ipsec_sa_cfg);
-
- request = rte_malloc("iavf-sad-add-request", request_len, 0);
- if (request == NULL) {
- rc = -ENOMEM;
- goto update_cleanup;
- }
-
- response_len = sizeof(struct inline_ipsec_msg) +
- sizeof(struct virtchnl_ipsec_sa_cfg_resp);
- response = rte_malloc("iavf-sad-add-response", response_len, 0);
- if (response == NULL) {
- rc = -ENOMEM;
- goto update_cleanup;
- }
-
/* set msg header params */
request->ipsec_opcode = INLINE_IPSEC_OP_SA_CREATE;
request->req_id = (uint16_t)0xDEADBEEF;
/* set SA configuration params */
- sa_cfg = (struct virtchnl_ipsec_sa_cfg *)(request + 1);
-
sa_cfg->spi = conf->ipsec.spi;
sa_cfg->virtchnl_protocol_type = VIRTCHNL_PROTO_ESP;
sa_cfg->virtchnl_direction =
@@ -541,10 +530,10 @@ iavf_ipsec_crypto_security_association_add(struct iavf_adapter *adapter,
/* send virtual channel request to add SA to hardware database */
rc = iavf_ipsec_crypto_request(adapter,
- (uint8_t *)request, request_len,
- (uint8_t *)response, response_len);
+ (uint8_t *)request, sizeof(sa_req),
+ (uint8_t *)response, sizeof(sa_resp));
if (rc)
- goto update_cleanup;
+ return rc;
/* verify response id */
if (response->ipsec_opcode != request->ipsec_opcode ||
@@ -552,9 +541,6 @@ iavf_ipsec_crypto_security_association_add(struct iavf_adapter *adapter,
rc = -EFAULT;
else
rc = response->ipsec_data.sa_cfg_resp->sa_handle;
-update_cleanup:
- rte_free(response);
- rte_free(request);
return rc;
}
@@ -722,19 +708,18 @@ iavf_ipsec_crypto_inbound_security_policy_add(struct iavf_adapter *adapter,
bool is_udp,
uint16_t udp_port)
{
- struct inline_ipsec_msg *request = NULL, *response = NULL;
- size_t request_len, response_len;
+ struct {
+ struct inline_ipsec_msg msg;
+ struct virtchnl_ipsec_sp_cfg sp_cfg;
+ } sp_req = {0};
+ struct {
+ struct inline_ipsec_msg msg;
+ struct virtchnl_ipsec_sp_cfg_resp sp_cfg_resp;
+ } sp_resp = {0};
+ struct inline_ipsec_msg *request = &sp_req.msg;
+ struct inline_ipsec_msg *response = &sp_resp.msg;
int rc = 0;
- 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);
- if (request == NULL) {
- rc = -ENOMEM;
- goto update_cleanup;
- }
-
/* set msg header params */
request->ipsec_opcode = INLINE_IPSEC_OP_SP_CREATE;
request->req_id = (uint16_t)0xDEADBEEF;
@@ -768,21 +753,12 @@ iavf_ipsec_crypto_inbound_security_policy_add(struct iavf_adapter *adapter,
request->ipsec_data.sp_cfg->is_udp = is_udp;
request->ipsec_data.sp_cfg->udp_port = htons(udp_port);
- 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);
- if (response == NULL) {
- rc = -ENOMEM;
- goto update_cleanup;
- }
-
/* send virtual channel request to add SA to hardware database */
rc = iavf_ipsec_crypto_request(adapter,
- (uint8_t *)request, request_len,
- (uint8_t *)response, response_len);
+ (uint8_t *)request, sizeof(sp_req),
+ (uint8_t *)response, sizeof(sp_resp));
if (rc)
- goto update_cleanup;
+ return rc;
/* verify response */
if (response->ipsec_opcode != request->ipsec_opcode ||
@@ -791,10 +767,6 @@ iavf_ipsec_crypto_inbound_security_policy_add(struct iavf_adapter *adapter,
else
rc = response->ipsec_data.sp_cfg_resp->rule_id;
-update_cleanup:
- rte_free(request);
- rte_free(response);
-
return rc;
}
@@ -802,26 +774,18 @@ static uint32_t
iavf_ipsec_crypto_sa_update_esn(struct iavf_adapter *adapter,
struct iavf_security_session *sess)
{
- struct inline_ipsec_msg *request = NULL, *response = NULL;
- size_t request_len, response_len;
+ struct {
+ struct inline_ipsec_msg msg;
+ struct virtchnl_ipsec_sa_update sa_update;
+ } sp_req = {0};
+ struct {
+ struct inline_ipsec_msg msg;
+ struct virtchnl_ipsec_resp ipsec_resp;
+ } sp_resp = {0};
+ struct inline_ipsec_msg *request = &sp_req.msg;
+ struct inline_ipsec_msg *response = &sp_resp.msg;
int rc = 0;
- request_len = sizeof(struct inline_ipsec_msg) +
- sizeof(struct virtchnl_ipsec_sa_update);
- request = rte_malloc("iavf-sa-update-request", request_len, 0);
- if (request == NULL) {
- rc = -ENOMEM;
- goto update_cleanup;
- }
-
- response_len = sizeof(struct inline_ipsec_msg) +
- sizeof(struct virtchnl_ipsec_resp);
- response = rte_malloc("iavf-sa-update-response", response_len, 0);
- if (response == NULL) {
- rc = -ENOMEM;
- goto update_cleanup;
- }
-
/* set msg header params */
request->ipsec_opcode = INLINE_IPSEC_OP_SA_UPDATE;
request->req_id = (uint16_t)0xDEADBEEF;
@@ -833,10 +797,10 @@ iavf_ipsec_crypto_sa_update_esn(struct iavf_adapter *adapter,
/* send virtual channel request to add SA to hardware database */
rc = iavf_ipsec_crypto_request(adapter,
- (uint8_t *)request, request_len,
- (uint8_t *)response, response_len);
+ (uint8_t *)request, sizeof(sp_req),
+ (uint8_t *)response, sizeof(sp_resp));
if (rc)
- goto update_cleanup;
+ return rc;
/* verify response */
if (response->ipsec_opcode != request->ipsec_opcode ||
@@ -845,10 +809,6 @@ iavf_ipsec_crypto_sa_update_esn(struct iavf_adapter *adapter,
else
rc = response->ipsec_data.ipsec_resp->resp;
-update_cleanup:
- rte_free(request);
- rte_free(response);
-
return rc;
}
@@ -899,26 +859,18 @@ int
iavf_ipsec_crypto_security_policy_delete(struct iavf_adapter *adapter,
uint8_t is_v4, uint32_t flow_id)
{
- struct inline_ipsec_msg *request = NULL, *response = NULL;
- size_t request_len, response_len;
+ struct {
+ struct inline_ipsec_msg msg;
+ struct virtchnl_ipsec_sp_destroy sp_destroy;
+ } sp_req = {0};
+ struct {
+ struct inline_ipsec_msg msg;
+ struct virtchnl_ipsec_resp resp;
+ } sp_resp = {0};
+ struct inline_ipsec_msg *request = &sp_req.msg;
+ struct inline_ipsec_msg *response = &sp_resp.msg;
int rc = 0;
- request_len = sizeof(struct inline_ipsec_msg) +
- sizeof(struct virtchnl_ipsec_sp_destroy);
- request = rte_malloc("iavf-sp-del-request", request_len, 0);
- if (request == NULL) {
- rc = -ENOMEM;
- goto update_cleanup;
- }
-
- response_len = sizeof(struct inline_ipsec_msg) +
- sizeof(struct virtchnl_ipsec_resp);
- response = rte_malloc("iavf-sp-del-response", response_len, 0);
- if (response == NULL) {
- rc = -ENOMEM;
- goto update_cleanup;
- }
-
/* set msg header params */
request->ipsec_opcode = INLINE_IPSEC_OP_SP_DESTROY;
request->req_id = (uint16_t)0xDEADBEEF;
@@ -931,21 +883,17 @@ iavf_ipsec_crypto_security_policy_delete(struct iavf_adapter *adapter,
/* send virtual channel request to add SA to hardware database */
rc = iavf_ipsec_crypto_request(adapter,
- (uint8_t *)request, request_len,
- (uint8_t *)response, response_len);
+ (uint8_t *)request, sizeof(sp_req),
+ (uint8_t *)response, sizeof(sp_resp));
if (rc)
- goto update_cleanup;
+ return rc;
/* verify response */
if (response->ipsec_opcode != request->ipsec_opcode ||
response->req_id != request->req_id)
rc = -EFAULT;
else
- return response->ipsec_data.ipsec_status->status;
-
-update_cleanup:
- rte_free(request);
- rte_free(response);
+ rc = response->ipsec_data.ipsec_status->status;
return rc;
}
--
2.47.3
^ permalink raw reply related
* [PATCH v6 17/27] net/iavf: decouple hash uninit from parser uninit
From: Anatoly Burakov @ 2026-02-19 16:23 UTC (permalink / raw)
To: dev, Vladimir Medvedkin
In-Reply-To: <cover.1771518103.git.anatoly.burakov@intel.com>
Currently, parser deinitialization will trigger removal of current RSS
configuration. This should not be done as part of parser deinitialization,
but should rather be a separate step in dev close flow.
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
drivers/net/intel/iavf/iavf.h | 1 +
drivers/net/intel/iavf/iavf_ethdev.c | 3 +++
drivers/net/intel/iavf/iavf_hash.c | 12 ++++++++----
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/net/intel/iavf/iavf.h b/drivers/net/intel/iavf/iavf.h
index 39949acc11..6054321771 100644
--- a/drivers/net/intel/iavf/iavf.h
+++ b/drivers/net/intel/iavf/iavf.h
@@ -566,4 +566,5 @@ void iavf_dev_watchdog_disable(struct iavf_adapter *adapter);
void iavf_handle_hw_reset(struct rte_eth_dev *dev, bool vf_initiated_reset);
void iavf_set_no_poll(struct iavf_adapter *adapter, bool link_change);
bool is_iavf_supported(struct rte_eth_dev *dev);
+void iavf_hash_uninit(struct iavf_adapter *ad);
#endif /* _IAVF_ETHDEV_H_ */
diff --git a/drivers/net/intel/iavf/iavf_ethdev.c b/drivers/net/intel/iavf/iavf_ethdev.c
index 802e095174..e978284bf2 100644
--- a/drivers/net/intel/iavf/iavf_ethdev.c
+++ b/drivers/net/intel/iavf/iavf_ethdev.c
@@ -2972,6 +2972,9 @@ iavf_dev_close(struct rte_eth_dev *dev)
/* free iAVF security device context all related resources */
iavf_security_ctx_destroy(adapter);
+ /* remove RSS configuration */
+ iavf_hash_uninit(adapter);
+
iavf_flow_flush(dev, NULL);
iavf_flow_uninit(adapter);
diff --git a/drivers/net/intel/iavf/iavf_hash.c b/drivers/net/intel/iavf/iavf_hash.c
index a40fed7542..cb10eeab78 100644
--- a/drivers/net/intel/iavf/iavf_hash.c
+++ b/drivers/net/intel/iavf/iavf_hash.c
@@ -77,7 +77,7 @@ static int
iavf_hash_destroy(struct iavf_adapter *ad, struct rte_flow *flow,
struct rte_flow_error *error);
static void
-iavf_hash_uninit(struct iavf_adapter *ad);
+iavf_hash_uninit_parser(struct iavf_adapter *ad);
static void
iavf_hash_free(struct rte_flow *flow);
static int
@@ -680,7 +680,7 @@ static struct iavf_flow_engine iavf_hash_engine = {
.init = iavf_hash_init,
.create = iavf_hash_create,
.destroy = iavf_hash_destroy,
- .uninit = iavf_hash_uninit,
+ .uninit = iavf_hash_uninit_parser,
.free = iavf_hash_free,
.type = IAVF_FLOW_ENGINE_HASH,
};
@@ -1641,6 +1641,12 @@ iavf_hash_destroy(__rte_unused struct iavf_adapter *ad,
}
static void
+iavf_hash_uninit_parser(struct iavf_adapter *ad)
+{
+ iavf_unregister_parser(&iavf_hash_parser, ad);
+}
+
+void
iavf_hash_uninit(struct iavf_adapter *ad)
{
struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(ad);
@@ -1658,8 +1664,6 @@ iavf_hash_uninit(struct iavf_adapter *ad)
rss_conf = &ad->dev_data->dev_conf.rx_adv_conf.rss_conf;
if (iavf_rss_hash_set(ad, rss_conf->rss_hf, false))
PMD_DRV_LOG(ERR, "fail to delete default RSS");
-
- iavf_unregister_parser(&iavf_hash_parser, ad);
}
static void
--
2.47.3
^ permalink raw reply related
* [PATCH v6 16/27] net/iavf: remove remnants of pipeline mode
From: Anatoly Burakov @ 2026-02-19 16:22 UTC (permalink / raw)
To: dev, Vladimir Medvedkin
In-Reply-To: <cover.1771518103.git.anatoly.burakov@intel.com>
When pipeline mode was removed, some of the things used by pipelines were
left in the code. Remove them as they are unused.
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
drivers/net/intel/iavf/iavf_fdir.c | 1 -
drivers/net/intel/iavf/iavf_fsub.c | 1 -
drivers/net/intel/iavf/iavf_generic_flow.h | 15 ---------------
drivers/net/intel/iavf/iavf_hash.c | 1 -
drivers/net/intel/iavf/iavf_ipsec_crypto.c | 1 -
5 files changed, 19 deletions(-)
diff --git a/drivers/net/intel/iavf/iavf_fdir.c b/drivers/net/intel/iavf/iavf_fdir.c
index 0ef6e0d04a..9eae874800 100644
--- a/drivers/net/intel/iavf/iavf_fdir.c
+++ b/drivers/net/intel/iavf/iavf_fdir.c
@@ -1632,7 +1632,6 @@ static struct iavf_flow_parser iavf_fdir_parser = {
.array = iavf_fdir_pattern,
.array_len = RTE_DIM(iavf_fdir_pattern),
.parse_pattern_action = iavf_fdir_parse,
- .stage = IAVF_FLOW_STAGE_DISTRIBUTOR,
};
RTE_INIT(iavf_fdir_engine_register)
diff --git a/drivers/net/intel/iavf/iavf_fsub.c b/drivers/net/intel/iavf/iavf_fsub.c
index cf1030320f..bfb34695de 100644
--- a/drivers/net/intel/iavf/iavf_fsub.c
+++ b/drivers/net/intel/iavf/iavf_fsub.c
@@ -814,7 +814,6 @@ iavf_flow_parser iavf_fsub_parser = {
.array = iavf_fsub_pattern_list,
.array_len = RTE_DIM(iavf_fsub_pattern_list),
.parse_pattern_action = iavf_fsub_parse,
- .stage = IAVF_FLOW_STAGE_DISTRIBUTOR,
};
RTE_INIT(iavf_fsub_engine_init)
diff --git a/drivers/net/intel/iavf/iavf_generic_flow.h b/drivers/net/intel/iavf/iavf_generic_flow.h
index b11bb4cf2b..b97cf8b7ff 100644
--- a/drivers/net/intel/iavf/iavf_generic_flow.h
+++ b/drivers/net/intel/iavf/iavf_generic_flow.h
@@ -485,20 +485,6 @@ enum iavf_flow_engine_type {
IAVF_FLOW_ENGINE_MAX,
};
-/**
- * classification stages.
- * for non-pipeline mode, we have two classification stages: Distributor/RSS
- * for pipeline-mode we have three classification stages:
- * Permission/Distributor/RSS
- */
-enum iavf_flow_classification_stage {
- IAVF_FLOW_STAGE_NONE = 0,
- IAVF_FLOW_STAGE_IPSEC_CRYPTO,
- IAVF_FLOW_STAGE_RSS,
- IAVF_FLOW_STAGE_DISTRIBUTOR,
- IAVF_FLOW_STAGE_MAX,
-};
-
/* Struct to store engine created. */
struct iavf_flow_engine {
TAILQ_ENTRY(iavf_flow_engine) node;
@@ -527,7 +513,6 @@ struct iavf_flow_parser {
struct iavf_pattern_match_item *array;
uint32_t array_len;
parse_pattern_action_t parse_pattern_action;
- enum iavf_flow_classification_stage stage;
};
/* Struct to store parser created. */
diff --git a/drivers/net/intel/iavf/iavf_hash.c b/drivers/net/intel/iavf/iavf_hash.c
index 1725c2b2b9..a40fed7542 100644
--- a/drivers/net/intel/iavf/iavf_hash.c
+++ b/drivers/net/intel/iavf/iavf_hash.c
@@ -691,7 +691,6 @@ static struct iavf_flow_parser iavf_hash_parser = {
.array = iavf_hash_pattern_list,
.array_len = RTE_DIM(iavf_hash_pattern_list),
.parse_pattern_action = iavf_hash_parse_pattern_action,
- .stage = IAVF_FLOW_STAGE_RSS,
};
int
diff --git a/drivers/net/intel/iavf/iavf_ipsec_crypto.c b/drivers/net/intel/iavf/iavf_ipsec_crypto.c
index 6d41b1744e..66eaea8715 100644
--- a/drivers/net/intel/iavf/iavf_ipsec_crypto.c
+++ b/drivers/net/intel/iavf/iavf_ipsec_crypto.c
@@ -1983,7 +1983,6 @@ static struct iavf_flow_parser iavf_ipsec_flow_parser = {
.array = iavf_ipsec_flow_pattern,
.array_len = RTE_DIM(iavf_ipsec_flow_pattern),
.parse_pattern_action = iavf_ipsec_flow_parse,
- .stage = IAVF_FLOW_STAGE_IPSEC_CRYPTO,
};
RTE_INIT(iavf_ipsec_flow_engine_register)
--
2.47.3
^ permalink raw reply related
* [PATCH v6 15/27] net/i40e: avoid rte malloc in DDP ptype handling
From: Anatoly Burakov @ 2026-02-19 16:22 UTC (permalink / raw)
To: dev, Bruce Richardson
In-Reply-To: <cover.1771518103.git.anatoly.burakov@intel.com>
Currently, when updating customized protocol and packet type information
via DDP packages, 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 stack allocation or regular calloc/free as appropriate.
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
drivers/net/intel/i40e/i40e_ethdev.c | 43 ++++++++--------------------
1 file changed, 12 insertions(+), 31 deletions(-)
diff --git a/drivers/net/intel/i40e/i40e_ethdev.c b/drivers/net/intel/i40e/i40e_ethdev.c
index fff832fba1..faf35acde0 100644
--- a/drivers/net/intel/i40e/i40e_ethdev.c
+++ b/drivers/net/intel/i40e/i40e_ethdev.c
@@ -11718,8 +11718,7 @@ i40e_update_customized_pctype(struct rte_eth_dev *dev, uint8_t *pkg,
{
struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
uint32_t pctype_num;
- struct rte_pmd_i40e_ptype_info *pctype;
- uint32_t buff_size;
+ struct rte_pmd_i40e_ptype_info pctype[I40E_CUSTOMIZED_MAX] = {0};
struct i40e_customized_pctype *new_pctype = NULL;
uint8_t proto_id;
uint8_t pctype_value;
@@ -11745,19 +11744,16 @@ i40e_update_customized_pctype(struct rte_eth_dev *dev, uint8_t *pkg,
return -1;
}
- buff_size = pctype_num * sizeof(struct rte_pmd_i40e_proto_info);
- pctype = rte_zmalloc("new_pctype", buff_size, 0);
- if (!pctype) {
- PMD_DRV_LOG(ERR, "Failed to allocate memory");
+ if (pctype_num > RTE_DIM(pctype)) {
+ PMD_DRV_LOG(ERR, "Pctype number exceeds maximum supported");
return -1;
}
/* get information about new pctype list */
ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
- (uint8_t *)pctype, buff_size,
+ (uint8_t *)pctype, sizeof(pctype),
RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST);
if (ret) {
PMD_DRV_LOG(ERR, "Failed to get pctype list");
- rte_free(pctype);
return -1;
}
@@ -11838,7 +11834,6 @@ i40e_update_customized_pctype(struct rte_eth_dev *dev, uint8_t *pkg,
}
}
- rte_free(pctype);
return 0;
}
@@ -11848,11 +11843,10 @@ i40e_update_customized_ptype(struct rte_eth_dev *dev, uint8_t *pkg,
struct rte_pmd_i40e_proto_info *proto,
enum rte_pmd_i40e_package_op op)
{
- struct rte_pmd_i40e_ptype_mapping *ptype_mapping;
+ struct rte_pmd_i40e_ptype_mapping ptype_mapping[I40E_MAX_PKT_TYPE] = {0};
uint16_t port_id = dev->data->port_id;
uint32_t ptype_num;
- struct rte_pmd_i40e_ptype_info *ptype;
- uint32_t buff_size;
+ struct rte_pmd_i40e_ptype_info ptype[I40E_MAX_PKT_TYPE] = {0};
uint8_t proto_id;
char name[RTE_PMD_I40E_DDP_NAME_SIZE];
uint32_t i, j, n;
@@ -11883,31 +11877,20 @@ i40e_update_customized_ptype(struct rte_eth_dev *dev, uint8_t *pkg,
return -1;
}
- buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_info);
- ptype = rte_zmalloc("new_ptype", buff_size, 0);
- if (!ptype) {
- PMD_DRV_LOG(ERR, "Failed to allocate memory");
+ if (ptype_num > RTE_DIM(ptype)) {
+ PMD_DRV_LOG(ERR, "Too many ptypes");
return -1;
}
/* get information about new ptype list */
ret = rte_pmd_i40e_get_ddp_info(pkg, pkg_size,
- (uint8_t *)ptype, buff_size,
+ (uint8_t *)ptype, sizeof(ptype),
RTE_PMD_I40E_PKG_INFO_PTYPE_LIST);
if (ret) {
PMD_DRV_LOG(ERR, "Failed to get ptype list");
- rte_free(ptype);
return ret;
}
- buff_size = ptype_num * sizeof(struct rte_pmd_i40e_ptype_mapping);
- ptype_mapping = rte_zmalloc("ptype_mapping", buff_size, 0);
- if (!ptype_mapping) {
- PMD_DRV_LOG(ERR, "Failed to allocate memory");
- rte_free(ptype);
- return -1;
- }
-
/* Update ptype mapping table. */
for (i = 0; i < ptype_num; i++) {
ptype_mapping[i].hw_ptype = ptype[i].ptype_id;
@@ -12042,8 +12025,6 @@ i40e_update_customized_ptype(struct rte_eth_dev *dev, uint8_t *pkg,
if (ret)
PMD_DRV_LOG(ERR, "Failed to update ptype mapping table.");
- rte_free(ptype_mapping);
- rte_free(ptype);
return ret;
}
@@ -12078,7 +12059,7 @@ i40e_update_customized_info(struct rte_eth_dev *dev, uint8_t *pkg,
}
buff_size = proto_num * sizeof(struct rte_pmd_i40e_proto_info);
- proto = rte_zmalloc("new_proto", buff_size, 0);
+ proto = calloc(proto_num, sizeof(struct rte_pmd_i40e_proto_info));
if (!proto) {
PMD_DRV_LOG(ERR, "Failed to allocate memory");
return;
@@ -12090,7 +12071,7 @@ i40e_update_customized_info(struct rte_eth_dev *dev, uint8_t *pkg,
RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST);
if (ret) {
PMD_DRV_LOG(ERR, "Failed to get protocol list");
- rte_free(proto);
+ free(proto);
return;
}
@@ -12128,7 +12109,7 @@ i40e_update_customized_info(struct rte_eth_dev *dev, uint8_t *pkg,
if (ret)
PMD_DRV_LOG(INFO, "No ptype is updated.");
- rte_free(proto);
+ free(proto);
}
/* Create a QinQ cloud filter
--
2.47.3
^ permalink raw reply related
* [PATCH v6 14/27] net/i40e: avoid rte malloc in DDP package handling
From: Anatoly Burakov @ 2026-02-19 16:22 UTC (permalink / raw)
To: dev, Bruce Richardson
In-Reply-To: <cover.1771518103.git.anatoly.burakov@intel.com>
Currently, when processing Dynamic Driver Profile (DDP) packages and
checking profile information, 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 stack allocation.
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
drivers/net/intel/i40e/rte_pmd_i40e.c | 43 +++++----------------------
1 file changed, 8 insertions(+), 35 deletions(-)
diff --git a/drivers/net/intel/i40e/rte_pmd_i40e.c b/drivers/net/intel/i40e/rte_pmd_i40e.c
index 4839a1d9bf..7892fa8a4e 100644
--- a/drivers/net/intel/i40e/rte_pmd_i40e.c
+++ b/drivers/net/intel/i40e/rte_pmd_i40e.c
@@ -1557,7 +1557,7 @@ i40e_check_profile_info(uint16_t port, uint8_t *profile_info_sec)
{
struct rte_eth_dev *dev = &rte_eth_devices[port];
struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
- uint8_t *buff;
+ uint8_t buff[(I40E_MAX_PROFILE_NUM + 4) * I40E_PROFILE_INFO_SIZE] = {0};
struct rte_pmd_i40e_profile_list *p_list;
struct rte_pmd_i40e_profile_info *pinfo, *p;
uint32_t i;
@@ -1570,13 +1570,6 @@ i40e_check_profile_info(uint16_t port, uint8_t *profile_info_sec)
PMD_DRV_LOG(INFO, "Read-only profile.");
return 0;
}
- buff = rte_zmalloc("pinfo_list",
- (I40E_PROFILE_INFO_SIZE * I40E_MAX_PROFILE_NUM + 4),
- 0);
- if (!buff) {
- PMD_DRV_LOG(ERR, "failed to allocate memory");
- return -1;
- }
ret = i40e_aq_get_ddp_list(
hw, (void *)buff,
@@ -1584,7 +1577,6 @@ i40e_check_profile_info(uint16_t port, uint8_t *profile_info_sec)
0, NULL);
if (ret) {
PMD_DRV_LOG(ERR, "Failed to get profile info list.");
- rte_free(buff);
return -1;
}
p_list = (struct rte_pmd_i40e_profile_list *)buff;
@@ -1592,20 +1584,17 @@ i40e_check_profile_info(uint16_t port, uint8_t *profile_info_sec)
p = &p_list->p_info[i];
if (pinfo->track_id == p->track_id) {
PMD_DRV_LOG(INFO, "Profile exists.");
- rte_free(buff);
return 1;
}
}
/* profile with group id 0xff is compatible with any other profile */
if ((pinfo->track_id & group_mask) == group_mask) {
- rte_free(buff);
return 0;
}
for (i = 0; i < p_list->p_count; i++) {
p = &p_list->p_info[i];
if ((p->track_id & group_mask) == 0) {
PMD_DRV_LOG(INFO, "Profile of the group 0 exists.");
- rte_free(buff);
return 2;
}
}
@@ -1616,12 +1605,9 @@ i40e_check_profile_info(uint16_t port, uint8_t *profile_info_sec)
if ((pinfo->track_id & group_mask) !=
(p->track_id & group_mask)) {
PMD_DRV_LOG(INFO, "Profile of different group exists.");
- rte_free(buff);
return 3;
}
}
-
- rte_free(buff);
return 0;
}
@@ -1637,7 +1623,10 @@ rte_pmd_i40e_process_ddp_package(uint16_t port, uint8_t *buff,
struct i40e_generic_seg_header *profile_seg_hdr;
struct i40e_generic_seg_header *metadata_seg_hdr;
uint32_t track_id;
- uint8_t *profile_info_sec;
+ struct {
+ struct i40e_profile_section_header sec;
+ struct i40e_profile_info info;
+ } profile_info_sec = {0};
int is_exist;
enum i40e_status_code status = I40E_SUCCESS;
static const uint32_t type_mask = 0xff000000;
@@ -1702,26 +1691,15 @@ rte_pmd_i40e_process_ddp_package(uint16_t port, uint8_t *buff,
return -EINVAL;
}
- profile_info_sec = rte_zmalloc(
- "i40e_profile_info",
- sizeof(struct i40e_profile_section_header) +
- sizeof(struct i40e_profile_info),
- 0);
- if (!profile_info_sec) {
- PMD_DRV_LOG(ERR, "Failed to allocate memory");
- return -EINVAL;
- }
-
/* Check if the profile already loaded */
i40e_generate_profile_info_sec(
((struct i40e_profile_segment *)profile_seg_hdr)->name,
&((struct i40e_profile_segment *)profile_seg_hdr)->version,
- track_id, profile_info_sec,
+ track_id, (uint8_t* )&profile_info_sec,
op == RTE_PMD_I40E_PKG_OP_WR_ADD);
- is_exist = i40e_check_profile_info(port, profile_info_sec);
+ is_exist = i40e_check_profile_info(port, (uint8_t* )&profile_info_sec);
if (is_exist < 0) {
PMD_DRV_LOG(ERR, "Failed to check profile.");
- rte_free(profile_info_sec);
return -EINVAL;
}
@@ -1734,13 +1712,11 @@ rte_pmd_i40e_process_ddp_package(uint16_t port, uint8_t *buff,
else if (is_exist == 3)
PMD_DRV_LOG(ERR, "Profile of different group already exists");
i40e_update_customized_info(dev, buff, size, op);
- rte_free(profile_info_sec);
return -EEXIST;
}
} else if (op == RTE_PMD_I40E_PKG_OP_WR_DEL) {
if (is_exist != 1) {
PMD_DRV_LOG(ERR, "Profile does not exist.");
- rte_free(profile_info_sec);
return -EACCES;
}
}
@@ -1752,7 +1728,6 @@ rte_pmd_i40e_process_ddp_package(uint16_t port, uint8_t *buff,
track_id);
if (status) {
PMD_DRV_LOG(ERR, "Failed to write profile for delete.");
- rte_free(profile_info_sec);
return status;
}
} else {
@@ -1765,14 +1740,13 @@ rte_pmd_i40e_process_ddp_package(uint16_t port, uint8_t *buff,
PMD_DRV_LOG(ERR, "Failed to write profile for add.");
else
PMD_DRV_LOG(ERR, "Failed to write profile.");
- rte_free(profile_info_sec);
return status;
}
}
if (track_id && (op != RTE_PMD_I40E_PKG_OP_WR_ONLY)) {
/* Modify loaded profiles info list */
- status = i40e_add_rm_profile_info(hw, profile_info_sec);
+ status = i40e_add_rm_profile_info(hw, (uint8_t* )&profile_info_sec);
if (status) {
if (op == RTE_PMD_I40E_PKG_OP_WR_ADD)
PMD_DRV_LOG(ERR, "Failed to add profile to info list.");
@@ -1785,7 +1759,6 @@ rte_pmd_i40e_process_ddp_package(uint16_t port, uint8_t *buff,
op == RTE_PMD_I40E_PKG_OP_WR_DEL)
i40e_update_customized_info(dev, buff, size, op);
- rte_free(profile_info_sec);
return status;
}
--
2.47.3
^ permalink raw reply related
* [PATCH v6 13/27] net/i40e: avoid rte malloc in adminq operations
From: Anatoly Burakov @ 2026-02-19 16:22 UTC (permalink / raw)
To: dev, Bruce Richardson
In-Reply-To: <cover.1771518103.git.anatoly.burakov@intel.com>
Currently, when processing admin queue messages, 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 <anatoly.burakov@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
drivers/net/intel/i40e/i40e_ethdev.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/net/intel/i40e/i40e_ethdev.c b/drivers/net/intel/i40e/i40e_ethdev.c
index 72ff2ea59c..fff832fba1 100644
--- a/drivers/net/intel/i40e/i40e_ethdev.c
+++ b/drivers/net/intel/i40e/i40e_ethdev.c
@@ -6872,14 +6872,11 @@ i40e_dev_handle_aq_msg(struct rte_eth_dev *dev)
struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
struct i40e_arq_event_info info;
uint16_t pending, opcode;
+ uint8_t msg_buf[I40E_AQ_BUF_SZ] = {0};
int ret;
- info.buf_len = I40E_AQ_BUF_SZ;
- info.msg_buf = rte_zmalloc("msg_buffer", info.buf_len, 0);
- if (!info.msg_buf) {
- PMD_DRV_LOG(ERR, "Failed to allocate mem");
- return;
- }
+ info.buf_len = sizeof(msg_buf);
+ info.msg_buf = msg_buf;
pending = 1;
while (pending) {
@@ -6915,7 +6912,6 @@ i40e_dev_handle_aq_msg(struct rte_eth_dev *dev)
break;
}
}
- rte_free(info.msg_buf);
}
static void
--
2.47.3
^ permalink raw reply related
* [PATCH v6 12/27] net/i40e: avoid rte malloc in VF resource queries
From: Anatoly Burakov @ 2026-02-19 16:22 UTC (permalink / raw)
To: dev, Bruce Richardson
In-Reply-To: <cover.1771518103.git.anatoly.burakov@intel.com>
Currently, when responding to VF resource queries, we are dynamically
allocating a temporary buffer with rte_zmalloc followed by an immediate
rte_free. This memory does not need to be stored in hugepage memory and
the allocation size is pretty small, so replace it with stack allocation.
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
---
drivers/net/intel/i40e/i40e_pf.c | 26 +++++++-------------------
1 file changed, 7 insertions(+), 19 deletions(-)
diff --git a/drivers/net/intel/i40e/i40e_pf.c b/drivers/net/intel/i40e/i40e_pf.c
index ebe1deeade..08cdd6bc4d 100644
--- a/drivers/net/intel/i40e/i40e_pf.c
+++ b/drivers/net/intel/i40e/i40e_pf.c
@@ -309,9 +309,14 @@ static int
i40e_pf_host_process_cmd_get_vf_resource(struct i40e_pf_vf *vf, uint8_t *msg,
bool b_op)
{
- struct virtchnl_vf_resource *vf_res = NULL;
+ /* only have 1 VSI by default */
+ struct {
+ struct virtchnl_vf_resource vf_res;
+ struct virtchnl_vsi_resource vsi_res;
+ } res = {0};
+ struct virtchnl_vf_resource *vf_res = &res.vf_res;
struct i40e_hw *hw = I40E_PF_TO_HW(vf->pf);
- uint32_t len = 0;
+ uint32_t len = sizeof(res);
uint64_t default_hena = I40E_RSS_HENA_ALL;
int ret = I40E_SUCCESS;
@@ -322,20 +327,6 @@ i40e_pf_host_process_cmd_get_vf_resource(struct i40e_pf_vf *vf, uint8_t *msg,
return ret;
}
- /* only have 1 VSI by default */
- len = sizeof(struct virtchnl_vf_resource) +
- I40E_DEFAULT_VF_VSI_NUM *
- sizeof(struct virtchnl_vsi_resource);
-
- vf_res = rte_zmalloc("i40e_vf_res", len, 0);
- if (vf_res == NULL) {
- PMD_DRV_LOG(ERR, "failed to allocate mem");
- ret = I40E_ERR_NO_MEMORY;
- vf_res = NULL;
- len = 0;
- goto send_msg;
- }
-
if (VF_IS_V10(&vf->version)) /* doesn't support offload negotiate */
vf->request_caps = VIRTCHNL_VF_OFFLOAD_L2 |
VIRTCHNL_VF_OFFLOAD_VLAN;
@@ -377,11 +368,8 @@ i40e_pf_host_process_cmd_get_vf_resource(struct i40e_pf_vf *vf, uint8_t *msg,
rte_ether_addr_copy(&vf->mac_addr,
(struct rte_ether_addr *)vf_res->vsi_res[0].default_mac_addr);
-send_msg:
i40e_pf_host_send_msg_to_vf(vf, VIRTCHNL_OP_GET_VF_RESOURCES,
ret, (uint8_t *)vf_res, len);
- rte_free(vf_res);
-
return ret;
}
--
2.47.3
^ permalink raw reply related
* [PATCH v6 11/27] net/i40e: avoid rte malloc in MAC/VLAN filtering
From: Anatoly Burakov @ 2026-02-19 16:22 UTC (permalink / raw)
To: dev, Bruce Richardson
In-Reply-To: <cover.1771518103.git.anatoly.burakov@intel.com>
Currently, when adding, removing, or configuring MAC and VLAN filters,
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 regular
malloc/free or stack allocation where appropriate.
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
drivers/net/intel/i40e/i40e_ethdev.c | 135 +++++++++++---------------
drivers/net/intel/i40e/rte_pmd_i40e.c | 17 ++--
2 files changed, 65 insertions(+), 87 deletions(-)
diff --git a/drivers/net/intel/i40e/i40e_ethdev.c b/drivers/net/intel/i40e/i40e_ethdev.c
index d1f8e12689..72ff2ea59c 100644
--- a/drivers/net/intel/i40e/i40e_ethdev.c
+++ b/drivers/net/intel/i40e/i40e_ethdev.c
@@ -6,6 +6,7 @@
#include <stdio.h>
#include <errno.h>
#include <stdint.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdarg.h>
@@ -4128,7 +4129,6 @@ static int
i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask)
{
struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
- struct i40e_mac_filter_info *mac_filter;
struct i40e_vsi *vsi = pf->main_vsi;
struct rte_eth_rxmode *rxmode;
struct i40e_mac_filter *f;
@@ -4163,12 +4163,12 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask)
}
if (mask & RTE_ETH_VLAN_EXTEND_MASK) {
+ struct i40e_mac_filter_info mac_filter[I40E_NUM_MACADDR_MAX] = {0};
i = 0;
num = vsi->mac_num;
- mac_filter = rte_zmalloc("mac_filter_info_data",
- num * sizeof(*mac_filter), 0);
- if (mac_filter == NULL) {
- PMD_DRV_LOG(ERR, "failed to allocate memory");
+
+ if (num > I40E_NUM_MACADDR_MAX) {
+ PMD_DRV_LOG(ERR, "Too many MAC addresses");
return I40E_ERR_NO_MEMORY;
}
@@ -4206,7 +4206,6 @@ i40e_vlan_offload_set(struct rte_eth_dev *dev, int mask)
if (ret)
PMD_DRV_LOG(ERR, "i40e vsi add mac fail.");
}
- rte_free(mac_filter);
}
if (mask & RTE_ETH_QINQ_STRIP_MASK) {
@@ -6200,7 +6199,7 @@ i40e_vsi_config_vlan_filter(struct i40e_vsi *vsi, bool on)
int i, num;
struct i40e_mac_filter *f;
void *temp;
- struct i40e_mac_filter_info *mac_filter;
+ struct i40e_mac_filter_info mac_filter[I40E_NUM_MACADDR_MAX] = {0};
enum i40e_mac_filter_type desired_filter;
int ret = I40E_SUCCESS;
@@ -6213,12 +6212,9 @@ i40e_vsi_config_vlan_filter(struct i40e_vsi *vsi, bool on)
}
num = vsi->mac_num;
-
- mac_filter = rte_zmalloc("mac_filter_info_data",
- num * sizeof(*mac_filter), 0);
- if (mac_filter == NULL) {
- PMD_DRV_LOG(ERR, "failed to allocate memory");
- return I40E_ERR_NO_MEMORY;
+ if (num > I40E_NUM_MACADDR_MAX) {
+ PMD_DRV_LOG(ERR, "Too many MAC addresses");
+ return -1;
}
i = 0;
@@ -6230,7 +6226,7 @@ i40e_vsi_config_vlan_filter(struct i40e_vsi *vsi, bool on)
if (ret) {
PMD_DRV_LOG(ERR, "Update VSI failed to %s vlan filter",
on ? "enable" : "disable");
- goto DONE;
+ return ret;
}
i++;
}
@@ -6242,13 +6238,11 @@ i40e_vsi_config_vlan_filter(struct i40e_vsi *vsi, bool on)
if (ret) {
PMD_DRV_LOG(ERR, "Update VSI failed to %s vlan filter",
on ? "enable" : "disable");
- goto DONE;
+ return ret;
}
}
-DONE:
- rte_free(mac_filter);
- return ret;
+ return 0;
}
/* Configure vlan stripping on or off */
@@ -7130,19 +7124,20 @@ i40e_add_macvlan_filters(struct i40e_vsi *vsi,
uint16_t flags;
int ret = I40E_SUCCESS;
struct i40e_hw *hw = I40E_VSI_TO_HW(vsi);
- struct i40e_aqc_add_macvlan_element_data *req_list;
+ uint8_t aq_buff[I40E_AQ_BUF_SZ] = {0};
+ struct i40e_aqc_add_macvlan_element_data *req_list =
+ (struct i40e_aqc_add_macvlan_element_data *)aq_buff;
+
+ if (hw->aq.asq_buf_size > I40E_AQ_BUF_SZ) {
+ PMD_DRV_LOG(ERR, "AdminQ size biffer than max");
+ return I40E_ERR_NO_MEMORY;
+ }
if (filter == NULL || total == 0)
return I40E_ERR_PARAM;
ele_num = hw->aq.asq_buf_size / sizeof(*req_list);
ele_buff_size = hw->aq.asq_buf_size;
- req_list = rte_zmalloc("macvlan_add", ele_buff_size, 0);
- if (req_list == NULL) {
- PMD_DRV_LOG(ERR, "Fail to allocate memory");
- return I40E_ERR_NO_MEMORY;
- }
-
num = 0;
do {
actual_num = (num + ele_num > total) ? (total - num) : ele_num;
@@ -7171,8 +7166,7 @@ i40e_add_macvlan_filters(struct i40e_vsi *vsi,
break;
default:
PMD_DRV_LOG(ERR, "Invalid MAC match type");
- ret = I40E_ERR_PARAM;
- goto DONE;
+ return I40E_ERR_PARAM;
}
req_list[i].queue_number = 0;
@@ -7184,14 +7178,11 @@ i40e_add_macvlan_filters(struct i40e_vsi *vsi,
actual_num, NULL);
if (ret != I40E_SUCCESS) {
PMD_DRV_LOG(ERR, "Failed to add macvlan filter");
- goto DONE;
+ return ret;
}
num += actual_num;
} while (num < total);
-
-DONE:
- rte_free(req_list);
- return ret;
+ return I40E_SUCCESS;
}
int
@@ -7204,21 +7195,22 @@ i40e_remove_macvlan_filters(struct i40e_vsi *vsi,
uint16_t flags;
int ret = I40E_SUCCESS;
struct i40e_hw *hw = I40E_VSI_TO_HW(vsi);
- struct i40e_aqc_remove_macvlan_element_data *req_list;
+ uint8_t aq_buff[I40E_AQ_BUF_SZ] = {0};
+ struct i40e_aqc_remove_macvlan_element_data *req_list =
+ (struct i40e_aqc_remove_macvlan_element_data *)aq_buff;
enum i40e_admin_queue_err aq_status;
if (filter == NULL || total == 0)
return I40E_ERR_PARAM;
- ele_num = hw->aq.asq_buf_size / sizeof(*req_list);
- ele_buff_size = hw->aq.asq_buf_size;
-
- req_list = rte_zmalloc("macvlan_remove", ele_buff_size, 0);
- if (req_list == NULL) {
- PMD_DRV_LOG(ERR, "Fail to allocate memory");
+ if (hw->aq.asq_buf_size > I40E_AQ_BUF_SZ) {
+ PMD_DRV_LOG(ERR, "AdminQ size biffer than max");
return I40E_ERR_NO_MEMORY;
}
+ ele_num = hw->aq.asq_buf_size / sizeof(*req_list);
+ ele_buff_size = hw->aq.asq_buf_size;
+
num = 0;
do {
actual_num = (num + ele_num > total) ? (total - num) : ele_num;
@@ -7247,8 +7239,7 @@ i40e_remove_macvlan_filters(struct i40e_vsi *vsi,
break;
default:
PMD_DRV_LOG(ERR, "Invalid MAC filter type");
- ret = I40E_ERR_PARAM;
- goto DONE;
+ return I40E_ERR_PARAM;
}
req_list[i].flags = rte_cpu_to_le_16(flags);
}
@@ -7262,15 +7253,13 @@ i40e_remove_macvlan_filters(struct i40e_vsi *vsi,
ret = I40E_SUCCESS;
} else {
PMD_DRV_LOG(ERR, "Failed to remove macvlan filter");
- goto DONE;
+ return ret;
}
}
num += actual_num;
} while (num < total);
-DONE:
- rte_free(req_list);
- return ret;
+ return I40E_SUCCESS;
}
/* Find out specific MAC filter */
@@ -7438,7 +7427,7 @@ i40e_vsi_remove_all_macvlan_filter(struct i40e_vsi *vsi)
else
num = vsi->mac_num * vsi->vlan_num;
- mv_f = rte_zmalloc("macvlan_data", num * sizeof(*mv_f), 0);
+ mv_f = calloc(num, sizeof(*mv_f));
if (mv_f == NULL) {
PMD_DRV_LOG(ERR, "failed to allocate memory");
return I40E_ERR_NO_MEMORY;
@@ -7467,7 +7456,7 @@ i40e_vsi_remove_all_macvlan_filter(struct i40e_vsi *vsi)
ret = i40e_remove_macvlan_filters(vsi, mv_f, num);
DONE:
- rte_free(mv_f);
+ free(mv_f);
return ret;
}
@@ -7475,7 +7464,7 @@ i40e_vsi_remove_all_macvlan_filter(struct i40e_vsi *vsi)
int
i40e_vsi_add_vlan(struct i40e_vsi *vsi, uint16_t vlan)
{
- struct i40e_macvlan_filter *mv_f;
+ struct i40e_macvlan_filter mv_f[I40E_NUM_MACADDR_MAX] = {0};
int mac_num;
int ret = I40E_SUCCESS;
@@ -7492,37 +7481,31 @@ i40e_vsi_add_vlan(struct i40e_vsi *vsi, uint16_t vlan)
PMD_DRV_LOG(ERR, "Error! VSI doesn't have a mac addr");
return I40E_ERR_PARAM;
}
-
- mv_f = rte_zmalloc("macvlan_data", mac_num * sizeof(*mv_f), 0);
-
- if (mv_f == NULL) {
- PMD_DRV_LOG(ERR, "failed to allocate memory");
- return I40E_ERR_NO_MEMORY;
+ if (mac_num > I40E_NUM_MACADDR_MAX) {
+ PMD_DRV_LOG(ERR, "Error! Too many MAC addresses");
+ return I40E_ERR_PARAM;
}
ret = i40e_find_all_mac_for_vlan(vsi, mv_f, mac_num, vlan);
if (ret != I40E_SUCCESS)
- goto DONE;
+ return ret;
ret = i40e_add_macvlan_filters(vsi, mv_f, mac_num);
if (ret != I40E_SUCCESS)
- goto DONE;
+ return ret;
i40e_set_vlan_filter(vsi, vlan, 1);
vsi->vlan_num++;
- ret = I40E_SUCCESS;
-DONE:
- rte_free(mv_f);
- return ret;
+ return I40E_SUCCESS;
}
int
i40e_vsi_delete_vlan(struct i40e_vsi *vsi, uint16_t vlan)
{
- struct i40e_macvlan_filter *mv_f;
+ struct i40e_macvlan_filter mv_f[I40E_NUM_MACADDR_MAX] = {0};
int mac_num;
int ret = I40E_SUCCESS;
@@ -7543,42 +7526,36 @@ i40e_vsi_delete_vlan(struct i40e_vsi *vsi, uint16_t vlan)
PMD_DRV_LOG(ERR, "Error! VSI doesn't have a mac addr");
return I40E_ERR_PARAM;
}
-
- mv_f = rte_zmalloc("macvlan_data", mac_num * sizeof(*mv_f), 0);
-
- if (mv_f == NULL) {
- PMD_DRV_LOG(ERR, "failed to allocate memory");
- return I40E_ERR_NO_MEMORY;
+ if (mac_num > I40E_NUM_MACADDR_MAX) {
+ PMD_DRV_LOG(ERR, "Error! Too many MAC addresses");
+ return I40E_ERR_PARAM;
}
ret = i40e_find_all_mac_for_vlan(vsi, mv_f, mac_num, vlan);
if (ret != I40E_SUCCESS)
- goto DONE;
+ return ret;
ret = i40e_remove_macvlan_filters(vsi, mv_f, mac_num);
if (ret != I40E_SUCCESS)
- goto DONE;
+ return ret;
/* This is last vlan to remove, replace all mac filter with vlan 0 */
if (vsi->vlan_num == 1) {
ret = i40e_find_all_mac_for_vlan(vsi, mv_f, mac_num, 0);
if (ret != I40E_SUCCESS)
- goto DONE;
+ return ret;
ret = i40e_add_macvlan_filters(vsi, mv_f, mac_num);
if (ret != I40E_SUCCESS)
- goto DONE;
+ return ret;
}
i40e_set_vlan_filter(vsi, vlan, 0);
vsi->vlan_num--;
- ret = I40E_SUCCESS;
-DONE:
- rte_free(mv_f);
- return ret;
+ return I40E_SUCCESS;
}
int
@@ -7609,7 +7586,7 @@ i40e_vsi_add_mac(struct i40e_vsi *vsi, struct i40e_mac_filter_info *mac_filter)
mac_filter->filter_type == I40E_MAC_HASH_MATCH)
vlan_num = 1;
- mv_f = rte_zmalloc("macvlan_data", vlan_num * sizeof(*mv_f), 0);
+ mv_f = calloc(vlan_num, sizeof(*mv_f));
if (mv_f == NULL) {
PMD_DRV_LOG(ERR, "failed to allocate memory");
return I40E_ERR_NO_MEMORY;
@@ -7648,7 +7625,7 @@ i40e_vsi_add_mac(struct i40e_vsi *vsi, struct i40e_mac_filter_info *mac_filter)
ret = I40E_SUCCESS;
DONE:
- rte_free(mv_f);
+ free(mv_f);
return ret;
}
@@ -7679,7 +7656,7 @@ i40e_vsi_delete_mac(struct i40e_vsi *vsi, struct rte_ether_addr *addr)
filter_type == I40E_MAC_HASH_MATCH)
vlan_num = 1;
- mv_f = rte_zmalloc("macvlan_data", vlan_num * sizeof(*mv_f), 0);
+ mv_f = calloc(vlan_num, sizeof(*mv_f));
if (mv_f == NULL) {
PMD_DRV_LOG(ERR, "failed to allocate memory");
return I40E_ERR_NO_MEMORY;
@@ -7708,7 +7685,7 @@ i40e_vsi_delete_mac(struct i40e_vsi *vsi, struct rte_ether_addr *addr)
ret = I40E_SUCCESS;
DONE:
- rte_free(mv_f);
+ free(mv_f);
return ret;
}
diff --git a/drivers/net/intel/i40e/rte_pmd_i40e.c b/drivers/net/intel/i40e/rte_pmd_i40e.c
index a358f68bc5..4839a1d9bf 100644
--- a/drivers/net/intel/i40e/rte_pmd_i40e.c
+++ b/drivers/net/intel/i40e/rte_pmd_i40e.c
@@ -2,6 +2,7 @@
* Copyright(c) 2010-2017 Intel Corporation
*/
+#include <stdlib.h>
#include <eal_export.h>
#include <rte_string_fns.h>
#include <rte_malloc.h>
@@ -233,7 +234,7 @@ i40e_vsi_rm_mac_filter(struct i40e_vsi *vsi)
filter_type == I40E_MAC_HASH_MATCH)
vlan_num = 1;
- mv_f = rte_zmalloc("macvlan_data", vlan_num * sizeof(*mv_f), 0);
+ mv_f = calloc(vlan_num, sizeof(*mv_f));
if (!mv_f) {
PMD_DRV_LOG(ERR, "failed to allocate memory");
return I40E_ERR_NO_MEMORY;
@@ -250,18 +251,18 @@ i40e_vsi_rm_mac_filter(struct i40e_vsi *vsi)
ret = i40e_find_all_vlan_for_mac(vsi, mv_f, vlan_num,
&f->mac_info.mac_addr);
if (ret != I40E_SUCCESS) {
- rte_free(mv_f);
+ free(mv_f);
return ret;
}
}
ret = i40e_remove_macvlan_filters(vsi, mv_f, vlan_num);
if (ret != I40E_SUCCESS) {
- rte_free(mv_f);
+ free(mv_f);
return ret;
}
- rte_free(mv_f);
+ free(mv_f);
ret = I40E_SUCCESS;
}
@@ -294,7 +295,7 @@ i40e_vsi_restore_mac_filter(struct i40e_vsi *vsi)
f->mac_info.filter_type == I40E_MAC_HASH_MATCH)
vlan_num = 1;
- mv_f = rte_zmalloc("macvlan_data", vlan_num * sizeof(*mv_f), 0);
+ mv_f = calloc(vlan_num, sizeof(*mv_f));
if (!mv_f) {
PMD_DRV_LOG(ERR, "failed to allocate memory");
return I40E_ERR_NO_MEMORY;
@@ -312,18 +313,18 @@ i40e_vsi_restore_mac_filter(struct i40e_vsi *vsi)
ret = i40e_find_all_vlan_for_mac(vsi, mv_f, vlan_num,
&f->mac_info.mac_addr);
if (ret != I40E_SUCCESS) {
- rte_free(mv_f);
+ free(mv_f);
return ret;
}
}
ret = i40e_add_macvlan_filters(vsi, mv_f, vlan_num);
if (ret != I40E_SUCCESS) {
- rte_free(mv_f);
+ free(mv_f);
return ret;
}
- rte_free(mv_f);
+ free(mv_f);
ret = I40E_SUCCESS;
}
--
2.47.3
^ permalink raw reply related
* [PATCH v6 10/27] net/i40e: avoid rte malloc in RSS RETA operations
From: Anatoly Burakov @ 2026-02-19 16:22 UTC (permalink / raw)
To: dev, Bruce Richardson
In-Reply-To: <cover.1771518103.git.anatoly.burakov@intel.com>
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
^ permalink raw reply related
* [PATCH v6 09/27] net/i40e: avoid rte malloc in tunnel set
From: Anatoly Burakov @ 2026-02-19 16:22 UTC (permalink / raw)
To: dev, Bruce Richardson
In-Reply-To: <cover.1771518103.git.anatoly.burakov@intel.com>
Currently, when setting tunnel configuration, we are using rte_zmalloc
followed by an immediate rte_free. This memory does not need to be stored
in hugepage memory and the allocation size is pretty small, so replace it
with stack allocation.
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
---
drivers/net/intel/i40e/i40e_ethdev.c | 124 ++++++++++++---------------
1 file changed, 53 insertions(+), 71 deletions(-)
diff --git a/drivers/net/intel/i40e/i40e_ethdev.c b/drivers/net/intel/i40e/i40e_ethdev.c
index 608a6cff4d..d3404d7720 100644
--- a/drivers/net/intel/i40e/i40e_ethdev.c
+++ b/drivers/net/intel/i40e/i40e_ethdev.c
@@ -8511,38 +8511,27 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
struct i40e_pf_vf *vf = NULL;
struct i40e_hw *hw = I40E_PF_TO_HW(pf);
struct i40e_vsi *vsi;
- struct i40e_aqc_cloud_filters_element_bb *cld_filter;
- struct i40e_aqc_cloud_filters_element_bb *pfilter;
+ struct i40e_aqc_cloud_filters_element_bb cld_filter = {0};
struct i40e_tunnel_rule *tunnel_rule = &pf->tunnel;
- struct i40e_tunnel_filter *tunnel, *node;
+ struct i40e_tunnel_filter *node;
struct i40e_tunnel_filter check_filter; /* Check if filter exists */
uint32_t teid_le;
bool big_buffer = 0;
- cld_filter = rte_zmalloc("tunnel_filter",
- sizeof(struct i40e_aqc_add_rm_cloud_filt_elem_ext),
- 0);
-
- if (cld_filter == NULL) {
- PMD_DRV_LOG(ERR, "Failed to alloc memory.");
- return -ENOMEM;
- }
- pfilter = cld_filter;
-
rte_ether_addr_copy(&tunnel_filter->outer_mac,
- (struct rte_ether_addr *)&pfilter->element.outer_mac);
+ (struct rte_ether_addr *)&cld_filter.element.outer_mac);
rte_ether_addr_copy(&tunnel_filter->inner_mac,
- (struct rte_ether_addr *)&pfilter->element.inner_mac);
+ (struct rte_ether_addr *)&cld_filter.element.inner_mac);
- pfilter->element.inner_vlan =
+ cld_filter.element.inner_vlan =
rte_cpu_to_le_16(tunnel_filter->inner_vlan);
if (tunnel_filter->ip_type == I40E_TUNNEL_IPTYPE_IPV4) {
ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV4;
ipv4_addr = rte_be_to_cpu_32(tunnel_filter->ip_addr.ipv4_addr);
ipv4_addr_le = rte_cpu_to_le_32(ipv4_addr);
- rte_memcpy(&pfilter->element.ipaddr.v4.data,
+ rte_memcpy(&cld_filter.element.ipaddr.v4.data,
&ipv4_addr_le,
- sizeof(pfilter->element.ipaddr.v4.data));
+ sizeof(cld_filter.element.ipaddr.v4.data));
} else {
ip_type = I40E_AQC_ADD_CLOUD_FLAGS_IPV6;
for (i = 0; i < 4; i++) {
@@ -8550,9 +8539,9 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
rte_cpu_to_le_32(rte_be_to_cpu_32(
tunnel_filter->ip_addr.ipv6_addr[i]));
}
- rte_memcpy(&pfilter->element.ipaddr.v6.data,
+ rte_memcpy(&cld_filter.element.ipaddr.v6.data,
&convert_ipv6,
- sizeof(pfilter->element.ipaddr.v6.data));
+ sizeof(cld_filter.element.ipaddr.v6.data));
}
/* check tunneled type */
@@ -8573,11 +8562,11 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
pf->mpls_replace_flag = 1;
}
teid_le = rte_cpu_to_le_32(tunnel_filter->tenant_id);
- pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0] =
+ cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0] =
teid_le >> 4;
- pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1] =
+ cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1] =
(teid_le & 0xF) << 12;
- pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2] =
+ cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2] =
0x40;
big_buffer = 1;
tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_MPLSOUDP;
@@ -8589,11 +8578,11 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
pf->mpls_replace_flag = 1;
}
teid_le = rte_cpu_to_le_32(tunnel_filter->tenant_id);
- pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0] =
+ cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0] =
teid_le >> 4;
- pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1] =
+ cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1] =
(teid_le & 0xF) << 12;
- pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2] =
+ cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2] =
0x0;
big_buffer = 1;
tun_type = I40E_AQC_ADD_CLOUD_TNL_TYPE_MPLSOGRE;
@@ -8605,11 +8594,11 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
pf->gtp_replace_flag = 1;
}
teid_le = rte_cpu_to_le_32(tunnel_filter->tenant_id);
- pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD0] =
+ cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD0] =
(teid_le >> 16) & 0xFFFF;
- pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD1] =
+ cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD1] =
teid_le & 0xFFFF;
- pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD2] =
+ cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X12_WORD2] =
0x0;
big_buffer = 1;
break;
@@ -8620,11 +8609,11 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
pf->gtp_replace_flag = 1;
}
teid_le = rte_cpu_to_le_32(tunnel_filter->tenant_id);
- pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD0] =
+ cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD0] =
(teid_le >> 16) & 0xFFFF;
- pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD1] =
+ cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD1] =
teid_le & 0xFFFF;
- pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD2] =
+ cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X13_WORD2] =
0x0;
big_buffer = 1;
break;
@@ -8641,8 +8630,8 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
* Big Buffer should be set, see changes in
* i40e_aq_add_cloud_filters
*/
- pfilter->general_fields[0] = tunnel_filter->inner_vlan;
- pfilter->general_fields[1] = tunnel_filter->outer_vlan;
+ cld_filter.general_fields[0] = tunnel_filter->inner_vlan;
+ cld_filter.general_fields[1] = tunnel_filter->outer_vlan;
big_buffer = 1;
break;
case I40E_CLOUD_TYPE_UDP:
@@ -8657,20 +8646,20 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
pf->sport_replace_flag = 1;
}
teid_le = rte_cpu_to_le_32(tunnel_filter->tenant_id);
- pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0] =
+ cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD0] =
I40E_DIRECTION_INGRESS_KEY;
if (tunnel_filter->tunnel_type == I40E_CLOUD_TYPE_UDP)
- pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1] =
+ cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1] =
I40E_TR_L4_TYPE_UDP;
else if (tunnel_filter->tunnel_type == I40E_CLOUD_TYPE_TCP)
- pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1] =
+ cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1] =
I40E_TR_L4_TYPE_TCP;
else
- pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1] =
+ cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD1] =
I40E_TR_L4_TYPE_SCTP;
- pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2] =
+ cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X11_WORD2] =
(teid_le >> 16) & 0xFFFF;
big_buffer = 1;
} else {
@@ -8682,20 +8671,20 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
pf->dport_replace_flag = 1;
}
teid_le = rte_cpu_to_le_32(tunnel_filter->tenant_id);
- pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD0] =
+ cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD0] =
I40E_DIRECTION_INGRESS_KEY;
if (tunnel_filter->tunnel_type == I40E_CLOUD_TYPE_UDP)
- pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1] =
+ cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1] =
I40E_TR_L4_TYPE_UDP;
else if (tunnel_filter->tunnel_type == I40E_CLOUD_TYPE_TCP)
- pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1] =
+ cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1] =
I40E_TR_L4_TYPE_TCP;
else
- pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1] =
+ cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD1] =
I40E_TR_L4_TYPE_SCTP;
- pfilter->general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD2] =
+ cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X10_WORD2] =
(teid_le >> 16) & 0xFFFF;
big_buffer = 1;
}
@@ -8704,48 +8693,46 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
default:
/* Other tunnel types is not supported. */
PMD_DRV_LOG(ERR, "tunnel type is not supported.");
- rte_free(cld_filter);
return -EINVAL;
}
if (tunnel_filter->tunnel_type == I40E_TUNNEL_TYPE_MPLSoUDP)
- pfilter->element.flags =
+ cld_filter.element.flags =
I40E_AQC_ADD_CLOUD_FILTER_0X11;
else if (tunnel_filter->tunnel_type == I40E_TUNNEL_TYPE_MPLSoGRE)
- pfilter->element.flags =
+ cld_filter.element.flags =
I40E_AQC_ADD_CLOUD_FILTER_0X12;
else if (tunnel_filter->tunnel_type == I40E_TUNNEL_TYPE_GTPC)
- pfilter->element.flags =
+ cld_filter.element.flags =
I40E_AQC_ADD_CLOUD_FILTER_0X11;
else if (tunnel_filter->tunnel_type == I40E_TUNNEL_TYPE_GTPU)
- pfilter->element.flags =
+ cld_filter.element.flags =
I40E_AQC_ADD_CLOUD_FILTER_0X12;
else if (tunnel_filter->tunnel_type == I40E_TUNNEL_TYPE_QINQ)
- pfilter->element.flags |=
+ cld_filter.element.flags |=
I40E_AQC_ADD_CLOUD_FILTER_0X10;
else if (tunnel_filter->tunnel_type == I40E_CLOUD_TYPE_UDP ||
tunnel_filter->tunnel_type == I40E_CLOUD_TYPE_TCP ||
tunnel_filter->tunnel_type == I40E_CLOUD_TYPE_SCTP) {
if (tunnel_filter->l4_port_type == I40E_L4_PORT_TYPE_SRC)
- pfilter->element.flags |=
+ cld_filter.element.flags |=
I40E_AQC_ADD_CLOUD_FILTER_0X11;
else
- pfilter->element.flags |=
+ cld_filter.element.flags |=
I40E_AQC_ADD_CLOUD_FILTER_0X10;
} else {
val = i40e_dev_get_filter_type(tunnel_filter->filter_type,
- &pfilter->element.flags);
+ &cld_filter.element.flags);
if (val < 0) {
- rte_free(cld_filter);
return -EINVAL;
}
}
- pfilter->element.flags |= rte_cpu_to_le_16(
- I40E_AQC_ADD_CLOUD_FLAGS_TO_QUEUE |
- ip_type | (tun_type << I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT));
- pfilter->element.tenant_id = rte_cpu_to_le_32(tunnel_filter->tenant_id);
- pfilter->element.queue_number =
+ cld_filter.element.flags |=
+ rte_cpu_to_le_16(I40E_AQC_ADD_CLOUD_FLAGS_TO_QUEUE | ip_type |
+ (tun_type << I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT));
+ cld_filter.element.tenant_id = rte_cpu_to_le_32(tunnel_filter->tenant_id);
+ cld_filter.element.queue_number =
rte_cpu_to_le_16(tunnel_filter->queue_id);
if (!tunnel_filter->is_to_vf)
@@ -8753,7 +8740,6 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
else {
if (tunnel_filter->vf_id >= pf->vf_num) {
PMD_DRV_LOG(ERR, "Invalid argument.");
- rte_free(cld_filter);
return -EINVAL;
}
vf = &pf->vfs[tunnel_filter->vf_id];
@@ -8762,38 +8748,36 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
/* Check if there is the filter in SW list */
memset(&check_filter, 0, sizeof(check_filter));
- i40e_tunnel_filter_convert(cld_filter, &check_filter);
+ i40e_tunnel_filter_convert(&cld_filter, &check_filter);
check_filter.is_to_vf = tunnel_filter->is_to_vf;
check_filter.vf_id = tunnel_filter->vf_id;
node = i40e_sw_tunnel_filter_lookup(tunnel_rule, &check_filter.input);
if (add && node) {
PMD_DRV_LOG(ERR, "Conflict with existing tunnel rules!");
- rte_free(cld_filter);
return -EINVAL;
}
if (!add && !node) {
PMD_DRV_LOG(ERR, "There's no corresponding tunnel filter!");
- rte_free(cld_filter);
return -EINVAL;
}
if (add) {
+ struct i40e_tunnel_filter *tunnel;
+
if (big_buffer)
ret = i40e_aq_add_cloud_filters_bb(hw,
- vsi->seid, cld_filter, 1);
+ vsi->seid, &cld_filter, 1);
else
ret = i40e_aq_add_cloud_filters(hw,
- vsi->seid, &cld_filter->element, 1);
+ vsi->seid, &cld_filter.element, 1);
if (ret < 0) {
PMD_DRV_LOG(ERR, "Failed to add a tunnel filter.");
- rte_free(cld_filter);
return -ENOTSUP;
}
tunnel = rte_zmalloc("tunnel_filter", sizeof(*tunnel), 0);
if (tunnel == NULL) {
PMD_DRV_LOG(ERR, "Failed to alloc memory.");
- rte_free(cld_filter);
return -ENOMEM;
}
@@ -8804,19 +8788,17 @@ i40e_dev_consistent_tunnel_filter_set(struct i40e_pf *pf,
} else {
if (big_buffer)
ret = i40e_aq_rem_cloud_filters_bb(
- hw, vsi->seid, cld_filter, 1);
+ hw, vsi->seid, &cld_filter, 1);
else
ret = i40e_aq_rem_cloud_filters(hw, vsi->seid,
- &cld_filter->element, 1);
+ &cld_filter.element, 1);
if (ret < 0) {
PMD_DRV_LOG(ERR, "Failed to delete a tunnel filter.");
- rte_free(cld_filter);
return -ENOTSUP;
}
ret = i40e_sw_tunnel_filter_del(pf, &node->input);
}
- rte_free(cld_filter);
return ret;
}
--
2.47.3
^ permalink raw reply related
* [PATCH v6 08/27] net/i40e: remove global pattern variable
From: Anatoly Burakov @ 2026-02-19 16:22 UTC (permalink / raw)
To: dev, Bruce Richardson
In-Reply-To: <cover.1771518103.git.anatoly.burakov@intel.com>
When parsing flow patterns, current code cleans up the pattern list by
removing void flow items, and copies the patterns into an array. That
array, when dealing with under 32 flow items, is allocated on the stack,
but when the pattern is big enough, a new list is dynamically allocated.
This allocated list is a global variable, and is allocated using
rte_zmalloc call which seems like overkill for this use case.
Remove the global variable, and replace the split behavior with
unconditional allocation.
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
---
drivers/net/intel/i40e/i40e_flow.c | 30 ++++++++++--------------------
1 file changed, 10 insertions(+), 20 deletions(-)
diff --git a/drivers/net/intel/i40e/i40e_flow.c b/drivers/net/intel/i40e/i40e_flow.c
index e611de0c06..2791139e59 100644
--- a/drivers/net/intel/i40e/i40e_flow.c
+++ b/drivers/net/intel/i40e/i40e_flow.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>
@@ -145,9 +146,6 @@ const struct rte_flow_ops i40e_flow_ops = {
.query = i40e_flow_query,
};
-/* internal pattern w/o VOID items */
-struct rte_flow_item g_items[32];
-
/* Pattern matched ethertype filter */
static enum rte_flow_item_type pattern_ethertype[] = {
RTE_FLOW_ITEM_TYPE_ETH,
@@ -3837,19 +3835,13 @@ i40e_flow_check(struct rte_eth_dev *dev,
i++;
}
item_num++;
-
- if (item_num <= ARRAY_SIZE(g_items)) {
- items = g_items;
- } else {
- items = rte_zmalloc("i40e_pattern",
- item_num * sizeof(struct rte_flow_item), 0);
- if (!items) {
- rte_flow_error_set(error, ENOMEM,
- RTE_FLOW_ERROR_TYPE_ITEM_NUM,
- NULL,
- "No memory for PMD internal items.");
- return -ENOMEM;
- }
+ items = calloc(item_num, sizeof(struct rte_flow_item));
+ if (items == NULL) {
+ rte_flow_error_set(error, ENOMEM,
+ RTE_FLOW_ERROR_TYPE_ITEM_NUM,
+ NULL,
+ "No memory for PMD internal items.");
+ return -ENOMEM;
}
i40e_pattern_skip_void_item(items, pattern);
@@ -3862,8 +3854,7 @@ i40e_flow_check(struct rte_eth_dev *dev,
RTE_FLOW_ERROR_TYPE_ITEM,
pattern, "Unsupported pattern");
- if (items != g_items)
- rte_free(items);
+ free(items);
return -rte_errno;
}
@@ -3873,8 +3864,7 @@ i40e_flow_check(struct rte_eth_dev *dev,
flag = true;
} while ((ret < 0) && (i < RTE_DIM(i40e_supported_patterns)));
- if (items != g_items)
- rte_free(items);
+ free(items);
return ret;
}
--
2.47.3
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox