From: Dariusz Sosnowski <dsosnowski@nvidia.com>
To: 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>
Cc: <dev@dpdk.org>, Raslan Darawsheh <rasland@nvidia.com>
Subject: [PATCH 3/5] net/mlx5: rework root group checks in table create
Date: Tue, 4 Nov 2025 18:46:10 +0100 [thread overview]
Message-ID: <20251104174612.1341962-4-dsosnowski@nvidia.com> (raw)
In-Reply-To: <20251104174612.1341962-1-dsosnowski@nvidia.com>
Before this patch, during flow actions translation done in template
table create, there were a lot of checks for group with index 0.
This group is special, because flow rules in that group are created
through mlx5 kernel driver.
For this reason, this group is referred to as root group or root table.
This patch reworks these group index checks for clarity:
- A dedicated function for checking if group index refers to
root group is added.
- All direct group index checks in actions translation are replaced
with a check for result of that function.
- Redundant group translation checks in actions translation is removed.
Group indexes are already translated at that point.
- Root group check for internal default miss action is removed.
This action is supported on root group assuming rdma-core supports it.
If rdma-core core does not support it, then HWS layer will reject
accordingly.
Signed-off-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
---
drivers/net/mlx5/mlx5_flow.h | 17 +++++++++++++++++
drivers/net/mlx5/mlx5_flow_hw.c | 34 ++++++---------------------------
2 files changed, 23 insertions(+), 28 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index cfdd47ef50..9b0afa427e 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -1658,6 +1658,23 @@ struct mlx5_flow_group {
struct mlx5_list *matchers;
};
+/**
+ * Returns true if a group with the given index is a root group.
+ *
+ * @param group_id
+ * Group index.
+ * It is assumed that provided index is already translated from user index to PMD index
+ * (as is for transfer groups for example).
+ *
+ * @returns
+ * True if group is a root group.
+ * False otherwise.
+ */
+static inline bool
+mlx5_group_id_is_root(uint32_t group_id)
+{
+ return group_id == 0;
+}
#define MLX5_HW_TBL_MAX_ITEM_TEMPLATE 32
#define MLX5_HW_TBL_MAX_ACTION_TEMPLATE 32
diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index ff68483a40..de004f8c1c 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -2507,7 +2507,7 @@ __flow_hw_translate_actions_template(struct rte_eth_dev *dev,
unsigned int of_vlan_offset;
uint32_t ct_idx;
int ret, err;
- uint32_t target_grp = 0;
+ bool is_root = mlx5_group_id_is_root(cfg->attr.flow_attr.group);
bool unified_fdb = is_unified_fdb(priv);
flow_hw_modify_field_init(&mhdr, at);
@@ -2519,7 +2519,7 @@ __flow_hw_translate_actions_template(struct rte_eth_dev *dev,
switch ((int)actions->type) {
case RTE_FLOW_ACTION_TYPE_INDIRECT_LIST:
- if (!attr->group) {
+ if (is_root) {
DRV_LOG(ERR, "Indirect action is not supported in root table.");
goto err;
}
@@ -2529,7 +2529,7 @@ __flow_hw_translate_actions_template(struct rte_eth_dev *dev,
goto err;
break;
case RTE_FLOW_ACTION_TYPE_INDIRECT:
- if (!attr->group) {
+ if (is_root) {
DRV_LOG(ERR, "Indirect action is not supported in root table.");
goto err;
}
@@ -2550,10 +2550,6 @@ __flow_hw_translate_actions_template(struct rte_eth_dev *dev,
priv->hw_drop[!!attr->group];
break;
case RTE_FLOW_ACTION_TYPE_PORT_REPRESENTOR:
- if (!attr->group) {
- DRV_LOG(ERR, "Port representor is not supported in root table.");
- goto err;
- }
acts->rule_acts[dr_pos].action = priv->hw_def_miss;
break;
case RTE_FLOW_ACTION_TYPE_FLAG:
@@ -2745,11 +2741,7 @@ __flow_hw_translate_actions_template(struct rte_eth_dev *dev,
recom_type = MLX5DR_ACTION_TYP_POP_IPV6_ROUTE_EXT;
break;
case RTE_FLOW_ACTION_TYPE_SEND_TO_KERNEL:
- ret = flow_hw_translate_group(dev, cfg, attr->group,
- &target_grp, &sub_error);
- if (ret)
- goto err;
- if (target_grp == 0) {
+ if (is_root) {
__flow_hw_action_template_destroy(dev, acts);
rte_flow_error_set(&sub_error, ENOTSUP,
RTE_FLOW_ERROR_TYPE_ACTION,
@@ -2773,11 +2765,7 @@ __flow_hw_translate_actions_template(struct rte_eth_dev *dev,
goto err;
break;
case RTE_FLOW_ACTION_TYPE_AGE:
- ret = flow_hw_translate_group(dev, cfg, attr->group,
- &target_grp, &sub_error);
- if (ret)
- goto err;
- if (target_grp == 0) {
+ if (is_root) {
__flow_hw_action_template_destroy(dev, acts);
rte_flow_error_set(&sub_error, ENOTSUP,
RTE_FLOW_ERROR_TYPE_ACTION,
@@ -2792,11 +2780,7 @@ __flow_hw_translate_actions_template(struct rte_eth_dev *dev,
goto err;
break;
case RTE_FLOW_ACTION_TYPE_COUNT:
- ret = flow_hw_translate_group(dev, cfg, attr->group,
- &target_grp, &sub_error);
- if (ret)
- goto err;
- if (target_grp == 0) {
+ if (is_root) {
__flow_hw_action_template_destroy(dev, acts);
rte_flow_error_set(&sub_error, ENOTSUP,
RTE_FLOW_ERROR_TYPE_ACTION,
@@ -2855,12 +2839,6 @@ __flow_hw_translate_actions_template(struct rte_eth_dev *dev,
goto err;
break;
case MLX5_RTE_FLOW_ACTION_TYPE_DEFAULT_MISS:
- /* Internal, can be skipped. */
- if (!!attr->group) {
- DRV_LOG(ERR, "DEFAULT MISS action is only"
- " supported in root table.");
- goto err;
- }
acts->rule_acts[dr_pos].action = priv->hw_def_miss;
break;
case RTE_FLOW_ACTION_TYPE_NAT64:
--
2.39.5
next prev parent reply other threads:[~2025-11-04 17:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-04 17:46 [PATCH 0/5] net/mlx5: support count and age actions on root group Dariusz Sosnowski
2025-11-04 17:46 ` [PATCH 1/5] common/mlx5: detect DevX counters support in rdma-core Dariusz Sosnowski
2025-11-04 17:46 ` [PATCH 2/5] net/mlx5/hws: support counter from DevX bulk on root Dariusz Sosnowski
2025-11-04 17:46 ` Dariusz Sosnowski [this message]
2025-11-04 17:46 ` [PATCH 4/5] net/mlx5: improve error reporting on masked indirect actions Dariusz Sosnowski
2025-11-04 17:46 ` [PATCH 5/5] net/mlx5: support count and age on root group 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=20251104174612.1341962-4-dsosnowski@nvidia.com \
--to=dsosnowski@nvidia.com \
--cc=bingz@nvidia.com \
--cc=dev@dpdk.org \
--cc=matan@nvidia.com \
--cc=orika@nvidia.com \
--cc=rasland@nvidia.com \
--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).