git: 6a6af22b6ec4 - main - mlx5: Add a no-append flow insertion mode

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Wed, 15 Nov 2023 23:09:12 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=6a6af22b6ec42eb0436381fae8dd1b86bc4c6327

commit 6a6af22b6ec42eb0436381fae8dd1b86bc4c6327
Author:     Mark Bloch <mbloch@nvidia.com>
AuthorDate: 2023-02-20 15:46:42 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-11-15 23:08:16 +0000

    mlx5: Add a no-append flow insertion mode
    
    This allows to insert a rule and make sure it doesn't get
    combined by the steering layer with any other rule.
    
    Signed-off-by: Mark Bloch <mbloch@nvidia.com>
    Sponsored by:   NVidia networking
    MFC after:      1 week
---
 sys/dev/mlx5/fs.h                     | 5 +++++
 sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c | 4 ++++
 2 files changed, 9 insertions(+)

diff --git a/sys/dev/mlx5/fs.h b/sys/dev/mlx5/fs.h
index d61a2bb498b7..f62716d806d0 100644
--- a/sys/dev/mlx5/fs.h
+++ b/sys/dev/mlx5/fs.h
@@ -96,8 +96,13 @@ enum mlx5_flow_act_actions {
 	MLX5_FLOW_ACT_ACTIONS_PACKET_REFORMAT = 1 << 2,
 };
 
+enum MLX5_FLOW_ACT_FLAGS {
+	MLX5_FLOW_ACT_NO_APPEND = 1 << 0,
+};
+
 struct mlx5_flow_act {
 	u32 actions; /* See enum mlx5_flow_act_actions */
+	u32 flags;
 	u32 flow_tag;
 	struct mlx5_modify_hdr *modify_hdr;
 	struct mlx5_pkt_reformat *pkt_reformat;
diff --git a/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c b/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c
index dcf93e5fc892..c4edc940b1bc 100644
--- a/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c
+++ b/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c
@@ -1806,6 +1806,9 @@ static struct mlx5_flow_rule *fs_add_dst_fg(struct mlx5_flow_group *fg,
 	char fte_name[20];
 
 	mutex_lock(&fg->base.lock);
+	if (flow_act->flags & MLX5_FLOW_ACT_NO_APPEND)
+		goto insert_fte;
+
 	fs_for_each_fte(fte, fg) {
 		/* TODO: Check of size against PRM max size */
 		mutex_lock(&fte->base.lock);
@@ -1821,6 +1824,7 @@ static struct mlx5_flow_rule *fs_add_dst_fg(struct mlx5_flow_group *fg,
 		mutex_unlock(&fte->base.lock);
 	}
 
+insert_fte:
 	fs_get_parent(ft, fg);
 	if (fg->num_ftes == fg->max_ftes) {
 		dst = ERR_PTR(-ENOSPC);