From: Tariq Toukan <tariqt@nvidia.com>
To: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Andrew Lunn <andrew+netdev@lunn.ch>
Cc: Gal Pressman <gal@nvidia.com>, Mark Bloch <mbloch@nvidia.com>,
"Moshe Shemesh" <moshe@nvidia.com>,
Saeed Mahameed <saeedm@nvidia.com>,
"Leon Romanovsky" <leon@kernel.org>,
Tariq Toukan <tariqt@nvidia.com>, <netdev@vger.kernel.org>,
<linux-rdma@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH net-next 3/3] net/mlx5: fs, add support for dest flow sampler HWS action
Date: Sun, 9 Mar 2025 20:07:43 +0200 [thread overview]
Message-ID: <1741543663-22123-4-git-send-email-tariqt@nvidia.com> (raw)
In-Reply-To: <1741543663-22123-1-git-send-email-tariqt@nvidia.com>
From: Moshe Shemesh <moshe@nvidia.com>
Add support for HW Steering action of flow sampler destination. For each
flow sampler created cache the hws action by sampler id as a key. Hold
refcount for each rule using the cached action.
Signed-off-by: Moshe Shemesh <moshe@nvidia.com>
Reviewed-by: Mark Bloch <mbloch@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
---
.../mellanox/mlx5/core/steering/hws/fs_hws.c | 54 +++++++++++++++++++
.../mellanox/mlx5/core/steering/hws/fs_hws.h | 2 +
2 files changed, 56 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.c
index edf7db1e6e9c..1b787cd66e6f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.c
@@ -67,6 +67,7 @@ static int mlx5_fs_init_hws_actions_pool(struct mlx5_core_dev *dev,
xa_init(&hws_pool->vport_dests);
xa_init(&hws_pool->vport_vhca_dests);
xa_init(&hws_pool->aso_meters);
+ xa_init(&hws_pool->sample_dests);
return 0;
cleanup_insert_hdr:
@@ -94,6 +95,9 @@ static void mlx5_fs_cleanup_hws_actions_pool(struct mlx5_fs_hws_context *fs_ctx)
struct mlx5_fs_pool *pool;
unsigned long i;
+ xa_for_each(&hws_pool->sample_dests, i, fs_hws_data)
+ kfree(fs_hws_data);
+ xa_destroy(&hws_pool->sample_dests);
xa_for_each(&hws_pool->aso_meters, i, fs_hws_data)
kfree(fs_hws_data);
xa_destroy(&hws_pool->aso_meters);
@@ -528,6 +532,42 @@ static void mlx5_fs_put_action_aso_meter(struct mlx5_fs_hws_context *fs_ctx,
return mlx5_fs_put_hws_action(meter_hws_data);
}
+static struct mlx5hws_action *
+mlx5_fs_get_dest_action_sampler(struct mlx5_fs_hws_context *fs_ctx,
+ struct mlx5_flow_rule *dst)
+{
+ struct mlx5_fs_hws_create_action_ctx create_ctx;
+ struct mlx5hws_context *ctx = fs_ctx->hws_ctx;
+ struct mlx5_fs_hws_data *sampler_hws_data;
+ u32 id = dst->dest_attr.sampler_id;
+ struct xarray *sampler_xa;
+
+ sampler_xa = &fs_ctx->hws_pool.sample_dests;
+ sampler_hws_data = mlx5_fs_get_cached_hws_data(sampler_xa, id);
+ if (!sampler_hws_data)
+ return NULL;
+
+ create_ctx.hws_ctx = ctx;
+ create_ctx.actions_type = MLX5HWS_ACTION_TYP_SAMPLER;
+ create_ctx.id = id;
+
+ return mlx5_fs_get_hws_action(sampler_hws_data, &create_ctx);
+}
+
+static void mlx5_fs_put_dest_action_sampler(struct mlx5_fs_hws_context *fs_ctx,
+ u32 sampler_id)
+{
+ struct mlx5_fs_hws_data *sampler_hws_data;
+ struct xarray *sampler_xa;
+
+ sampler_xa = &fs_ctx->hws_pool.sample_dests;
+ sampler_hws_data = xa_load(sampler_xa, sampler_id);
+ if (!sampler_hws_data)
+ return;
+
+ mlx5_fs_put_hws_action(sampler_hws_data);
+}
+
static struct mlx5hws_action *
mlx5_fs_create_action_dest_array(struct mlx5hws_context *ctx,
struct mlx5hws_action_dest_attr *dests,
@@ -602,6 +642,9 @@ mlx5_fs_create_hws_action(struct mlx5_fs_hws_create_action_ctx *create_ctx)
create_ctx->id,
create_ctx->return_reg_id,
flags);
+ case MLX5HWS_ACTION_TYP_SAMPLER:
+ return mlx5hws_action_create_flow_sampler(create_ctx->hws_ctx,
+ create_ctx->id, flags);
default:
return NULL;
}
@@ -662,6 +705,9 @@ static void mlx5_fs_destroy_fs_action(struct mlx5_flow_root_namespace *ns,
case MLX5HWS_ACTION_TYP_ASO_METER:
mlx5_fs_put_action_aso_meter(fs_ctx, fs_action->exe_aso);
break;
+ case MLX5HWS_ACTION_TYP_SAMPLER:
+ mlx5_fs_put_dest_action_sampler(fs_ctx, fs_action->sampler_id);
+ break;
default:
mlx5hws_action_destroy(fs_action->action);
}
@@ -939,6 +985,14 @@ static int mlx5_fs_fte_get_hws_actions(struct mlx5_flow_root_namespace *ns,
dest_action = mlx5_fs_get_dest_action_vport(fs_ctx, dst,
type_uplink);
break;
+ case MLX5_FLOW_DESTINATION_TYPE_FLOW_SAMPLER:
+ dest_action =
+ mlx5_fs_get_dest_action_sampler(fs_ctx,
+ dst);
+ fs_actions[num_fs_actions].action = dest_action;
+ fs_actions[num_fs_actions++].sampler_id =
+ dst->dest_attr.sampler_id;
+ break;
default:
err = -EOPNOTSUPP;
goto free_actions;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.h b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.h
index 6970b1aa9540..8b56298288da 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/fs_hws.h
@@ -23,6 +23,7 @@ struct mlx5_fs_hws_actions_pool {
struct xarray vport_vhca_dests;
struct xarray vport_dests;
struct xarray aso_meters;
+ struct xarray sample_dests;
};
struct mlx5_fs_hws_context {
@@ -51,6 +52,7 @@ struct mlx5_fs_hws_rule_action {
union {
struct mlx5_fc *counter;
struct mlx5_exe_aso *exe_aso;
+ u32 sampler_id;
};
};
--
2.45.0
next prev parent reply other threads:[~2025-03-09 18:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-09 18:07 [PATCH net-next 0/3] mlx5: Support HWS flow meter/sampler actions in FS core Tariq Toukan
2025-03-09 18:07 ` [PATCH net-next 1/3] net/mlx5: fs, add API for sharing HWS action by refcount Tariq Toukan
2025-03-12 22:48 ` Jacob Keller
2025-03-09 18:07 ` [PATCH net-next 2/3] net/mlx5: fs, add support for flow meters HWS action Tariq Toukan
2025-03-12 22:50 ` Jacob Keller
2025-03-09 18:07 ` Tariq Toukan [this message]
2025-03-12 22:50 ` [PATCH net-next 3/3] net/mlx5: fs, add support for dest flow sampler " Jacob Keller
2025-03-17 18:10 ` [PATCH net-next 0/3] mlx5: Support HWS flow meter/sampler actions in FS core patchwork-bot+netdevbpf
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=1741543663-22123-4-git-send-email-tariqt@nvidia.com \
--to=tariqt@nvidia.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gal@nvidia.com \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=mbloch@nvidia.com \
--cc=moshe@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saeedm@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).