From: Maayan Kashani <mkashani@nvidia.com>
To: <dev@dpdk.org>
Cc: <mkashani@nvidia.com>, <rasland@nvidia.com>, <stable@dpdk.org>,
"Gregory Etelson" <getelson@nvidia.com>,
Dariusz Sosnowski <dsosnowski@nvidia.com>,
Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
Bing Zhao <bingz@nvidia.com>, Ori Kam <orika@nvidia.com>,
Suanming Mou <suanmingm@nvidia.com>,
Matan Azrad <matan@nvidia.com>
Subject: [PATCH 3/4] net/mlx5: fix internal HWS pattern template creation
Date: Mon, 12 Jan 2026 11:24:37 +0200 [thread overview]
Message-ID: <20260112092439.14843-4-mkashani@nvidia.com> (raw)
In-Reply-To: <20260112092439.14843-1-mkashani@nvidia.com>
HWS pattern template creation tries to build a table with
the tested items after basic verifications to check
if the pattern is valid.
Time consumed in that table creation can be critical for applications
that require fast PMD initialization.
The patch separates pattern templates to internal and external.
Internal templates are created by the PMD and are considered safe and
can skip some validations.
Pattern templates provided by applications will be fully validated.
Fixes: a190f25e6a93 ("net/mlx5: improve pattern template validation")
Cc: stable@dpdk.org
Signed-off-by: Gregory Etelson <getelson@nvidia.com>
Signed-off-by: Maayan Kashani <mkashani@nvidia.com>
---
drivers/net/mlx5/mlx5_flow_hw.c | 35 +++++++++++++++++++++++----------
1 file changed, 25 insertions(+), 10 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 1dada2e7cef..4af654967ca 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -9110,6 +9110,7 @@ static struct rte_flow_pattern_template *
flow_hw_pattern_template_create(struct rte_eth_dev *dev,
const struct rte_flow_pattern_template_attr *attr,
const struct rte_flow_item items[],
+ bool external,
struct rte_flow_error *error)
{
struct mlx5_priv *priv = dev->data->dev_private;
@@ -9264,9 +9265,11 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev,
}
}
rte_atomic_fetch_add_explicit(&it->refcnt, 1, rte_memory_order_relaxed);
- rc = pattern_template_validate(dev, &it, 1, error);
- if (rc)
- goto error;
+ if (external) {
+ rc = pattern_template_validate(dev, &it, 1, error);
+ if (rc)
+ goto error;
+ }
LIST_INSERT_HEAD(&priv->flow_hw_itt, it, next);
return it;
error:
@@ -9285,6 +9288,16 @@ flow_hw_pattern_template_create(struct rte_eth_dev *dev,
return NULL;
}
+static struct rte_flow_pattern_template *
+flow_hw_external_pattern_template_create
+ (struct rte_eth_dev *dev,
+ const struct rte_flow_pattern_template_attr *attr,
+ const struct rte_flow_item items[],
+ struct rte_flow_error *error)
+{
+ return flow_hw_pattern_template_create(dev, attr, items, true, error);
+}
+
/**
* Destroy flow item template.
*
@@ -9890,7 +9903,7 @@ flow_hw_create_tx_repr_sq_pattern_tmpl(struct rte_eth_dev *dev, struct rte_flow_
},
};
- return flow_hw_pattern_template_create(dev, &attr, items, error);
+ return flow_hw_pattern_template_create(dev, &attr, items, false, error);
}
static __rte_always_inline uint32_t
@@ -10182,7 +10195,7 @@ flow_hw_create_ctrl_esw_mgr_pattern_template(struct rte_eth_dev *dev,
},
};
- return flow_hw_pattern_template_create(dev, &attr, items, error);
+ return flow_hw_pattern_template_create(dev, &attr, items, false, error);
}
/**
@@ -10236,7 +10249,7 @@ flow_hw_create_ctrl_regc_sq_pattern_template(struct rte_eth_dev *dev,
},
};
- return flow_hw_pattern_template_create(dev, &attr, items, error);
+ return flow_hw_pattern_template_create(dev, &attr, items, false, error);
}
/**
@@ -10273,7 +10286,7 @@ flow_hw_create_ctrl_port_pattern_template(struct rte_eth_dev *dev,
},
};
- return flow_hw_pattern_template_create(dev, &attr, items, error);
+ return flow_hw_pattern_template_create(dev, &attr, items, false, error);
}
/*
@@ -10309,7 +10322,8 @@ flow_hw_create_lacp_rx_pattern_template(struct rte_eth_dev *dev, struct rte_flow
.type = RTE_FLOW_ITEM_TYPE_END,
},
};
- return flow_hw_pattern_template_create(dev, &pa_attr, eth_all, error);
+ return flow_hw_pattern_template_create(dev, &pa_attr, eth_all,
+ false, error);
}
/**
@@ -11553,7 +11567,7 @@ flow_hw_create_ctrl_rx_pattern_template
{ .type = RTE_FLOW_ITEM_TYPE_END }
};
- return flow_hw_pattern_template_create(dev, &attr, items, NULL);
+ return flow_hw_pattern_template_create(dev, &attr, items, false, NULL);
}
int
@@ -15574,6 +15588,7 @@ flow_hw_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
return 0;
}
+
const struct mlx5_flow_driver_ops mlx5_flow_hw_drv_ops = {
.list_create = flow_hw_list_create,
.list_destroy = flow_hw_list_destroy,
@@ -15581,7 +15596,7 @@ const struct mlx5_flow_driver_ops mlx5_flow_hw_drv_ops = {
.info_get = flow_hw_info_get,
.configure = flow_hw_configure,
.pattern_validate = flow_hw_pattern_validate,
- .pattern_template_create = flow_hw_pattern_template_create,
+ .pattern_template_create = flow_hw_external_pattern_template_create,
.pattern_template_destroy = flow_hw_pattern_template_destroy,
.actions_validate = flow_hw_actions_validate,
.actions_template_create = flow_hw_actions_template_create,
--
2.21.0
next prev parent reply other threads:[~2026-01-12 9:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-12 9:24 [PATCH 0/4] net/mlx5: future HW devargs defaults and fixes Maayan Kashani
2026-01-12 9:24 ` [PATCH 1/4] drivers: fix flow devarg handling for future HW Maayan Kashani
2026-01-12 18:17 ` Dariusz Sosnowski
2026-01-12 9:24 ` [PATCH 2/4] net/mlx5: fix default memzone requirements in HWS Maayan Kashani
2026-01-12 9:24 ` Maayan Kashani [this message]
2026-01-12 18:18 ` [PATCH 3/4] net/mlx5: fix internal HWS pattern template creation Dariusz Sosnowski
2026-01-12 9:24 ` [PATCH 4/4] net/mlx5: fix redundant control rules in promiscuous mode Maayan Kashani
2026-01-12 18:19 ` Dariusz Sosnowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260112092439.14843-4-mkashani@nvidia.com \
--to=mkashani@nvidia.com \
--cc=bingz@nvidia.com \
--cc=dev@dpdk.org \
--cc=dsosnowski@nvidia.com \
--cc=getelson@nvidia.com \
--cc=matan@nvidia.com \
--cc=orika@nvidia.com \
--cc=rasland@nvidia.com \
--cc=stable@dpdk.org \
--cc=suanmingm@nvidia.com \
--cc=viacheslavo@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).