]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net/mlx5: fs, Add other_eswitch support for steering tables
authorPatrisious Haddad <phaddad@nvidia.com>
Wed, 29 Oct 2025 15:42:54 +0000 (17:42 +0200)
committerLeon Romanovsky <leon@kernel.org>
Sun, 9 Nov 2025 10:16:53 +0000 (05:16 -0500)
Add other_eswitch support which allows flow tables creation above vports
that reside on different esw managers.

The new flag MLX5_FLOW_TABLE_OTHER_ESWITCH indicates if the
esw_owner_vhca_id attribute is supported.

Note that this is only supported if the Advanced-RDMA cap-
rdma_transport_manager_other_eswitch is set.
And it is the caller responsibility to check that.

Signed-off-by: Patrisious Haddad <phaddad@nvidia.com>
Signed-off-by: Edward Srouji <edwards@nvidia.com>
Link: https://patch.msgid.link/20251029-support-other-eswitch-v1-2-98bb707b5d57@nvidia.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c
drivers/net/ethernet/mellanox/mlx5/core/fs_core.c
drivers/net/ethernet/mellanox/mlx5/core/fs_core.h
include/linux/mlx5/fs.h

index 1af76da8b1320e2f05091f260055e593c13aa350..ced747bef6415f5bd9a09a7576e18762e7e7aa8a 100644 (file)
@@ -239,6 +239,10 @@ static int mlx5_cmd_update_root_ft(struct mlx5_flow_root_namespace *ns,
        MLX5_SET(set_flow_table_root_in, in, vport_number, ft->vport);
        MLX5_SET(set_flow_table_root_in, in, other_vport,
                 !!(ft->flags & MLX5_FLOW_TABLE_OTHER_VPORT));
+       MLX5_SET(set_flow_table_root_in, in, eswitch_owner_vhca_id,
+                ft->esw_owner_vhca_id);
+       MLX5_SET(set_flow_table_root_in, in, other_eswitch,
+                !!(ft->flags & MLX5_FLOW_TABLE_OTHER_ESWITCH));
 
        err = mlx5_cmd_exec_in(dev, set_flow_table_root, in);
        if (!err &&
@@ -302,6 +306,10 @@ static int mlx5_cmd_create_flow_table(struct mlx5_flow_root_namespace *ns,
        MLX5_SET(create_flow_table_in, in, vport_number, ft->vport);
        MLX5_SET(create_flow_table_in, in, other_vport,
                 !!(ft->flags & MLX5_FLOW_TABLE_OTHER_VPORT));
+       MLX5_SET(create_flow_table_in, in, eswitch_owner_vhca_id,
+                ft->esw_owner_vhca_id);
+       MLX5_SET(create_flow_table_in, in, other_eswitch,
+                !!(ft->flags & MLX5_FLOW_TABLE_OTHER_ESWITCH));
 
        MLX5_SET(create_flow_table_in, in, flow_table_context.decap_en,
                 en_decap);
@@ -360,6 +368,10 @@ static int mlx5_cmd_destroy_flow_table(struct mlx5_flow_root_namespace *ns,
        MLX5_SET(destroy_flow_table_in, in, vport_number, ft->vport);
        MLX5_SET(destroy_flow_table_in, in, other_vport,
                 !!(ft->flags & MLX5_FLOW_TABLE_OTHER_VPORT));
+       MLX5_SET(destroy_flow_table_in, in, eswitch_owner_vhca_id,
+                ft->esw_owner_vhca_id);
+       MLX5_SET(destroy_flow_table_in, in, other_eswitch,
+                !!(ft->flags & MLX5_FLOW_TABLE_OTHER_ESWITCH));
 
        err = mlx5_cmd_exec_in(dev, destroy_flow_table, in);
        if (!err)
@@ -394,6 +406,10 @@ static int mlx5_cmd_modify_flow_table(struct mlx5_flow_root_namespace *ns,
                MLX5_SET(modify_flow_table_in, in, vport_number, ft->vport);
                MLX5_SET(modify_flow_table_in, in, other_vport,
                         !!(ft->flags & MLX5_FLOW_TABLE_OTHER_VPORT));
+               MLX5_SET(modify_flow_table_in, in, eswitch_owner_vhca_id,
+                        ft->esw_owner_vhca_id);
+               MLX5_SET(modify_flow_table_in, in, other_eswitch,
+                        !!(ft->flags & MLX5_FLOW_TABLE_OTHER_ESWITCH));
                MLX5_SET(modify_flow_table_in, in, modify_field_select,
                         MLX5_MODIFY_FLOW_TABLE_MISS_TABLE_ID);
                if (next_ft) {
@@ -429,6 +445,10 @@ static int mlx5_cmd_create_flow_group(struct mlx5_flow_root_namespace *ns,
        MLX5_SET(create_flow_group_in, in, vport_number, ft->vport);
        MLX5_SET(create_flow_group_in, in, other_vport,
                 !!(ft->flags & MLX5_FLOW_TABLE_OTHER_VPORT));
+       MLX5_SET(create_flow_group_in, in, eswitch_owner_vhca_id,
+                ft->esw_owner_vhca_id);
+       MLX5_SET(create_flow_group_in, in, other_eswitch,
+                !!(ft->flags & MLX5_FLOW_TABLE_OTHER_ESWITCH));
        err = mlx5_cmd_exec_inout(dev, create_flow_group, in, out);
        if (!err)
                fg->id = MLX5_GET(create_flow_group_out, out,
@@ -451,6 +471,10 @@ static int mlx5_cmd_destroy_flow_group(struct mlx5_flow_root_namespace *ns,
        MLX5_SET(destroy_flow_group_in, in, vport_number, ft->vport);
        MLX5_SET(destroy_flow_group_in, in, other_vport,
                 !!(ft->flags & MLX5_FLOW_TABLE_OTHER_VPORT));
+       MLX5_SET(destroy_flow_group_in, in, eswitch_owner_vhca_id,
+                ft->esw_owner_vhca_id);
+       MLX5_SET(destroy_flow_group_in, in, other_eswitch,
+                !!(ft->flags & MLX5_FLOW_TABLE_OTHER_ESWITCH));
        return mlx5_cmd_exec_in(dev, destroy_flow_group, in);
 }
 
@@ -559,6 +583,9 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev,
        MLX5_SET(set_fte_in, in, vport_number, ft->vport);
        MLX5_SET(set_fte_in, in, other_vport,
                 !!(ft->flags & MLX5_FLOW_TABLE_OTHER_VPORT));
+       MLX5_SET(set_fte_in, in, eswitch_owner_vhca_id, ft->esw_owner_vhca_id);
+       MLX5_SET(set_fte_in, in, other_eswitch,
+                !!(ft->flags & MLX5_FLOW_TABLE_OTHER_ESWITCH));
 
        in_flow_context = MLX5_ADDR_OF(set_fte_in, in, flow_context);
        MLX5_SET(flow_context, in_flow_context, group_id, group_id);
@@ -788,6 +815,10 @@ static int mlx5_cmd_delete_fte(struct mlx5_flow_root_namespace *ns,
        MLX5_SET(delete_fte_in, in, vport_number, ft->vport);
        MLX5_SET(delete_fte_in, in, other_vport,
                 !!(ft->flags & MLX5_FLOW_TABLE_OTHER_VPORT));
+       MLX5_SET(delete_fte_in, in, eswitch_owner_vhca_id,
+                ft->esw_owner_vhca_id);
+       MLX5_SET(delete_fte_in, in, other_eswitch,
+                !!(ft->flags & MLX5_FLOW_TABLE_OTHER_ESWITCH));
 
        return mlx5_cmd_exec_in(dev, delete_fte, in);
 }
index 2db3ffb0a2b286f12475cfc057aa9174f89588ae..87e381c82ed3f5a97e569ebbc74b16379b927c47 100644 (file)
@@ -939,10 +939,10 @@ static struct mlx5_flow_group *alloc_insert_flow_group(struct mlx5_flow_table *f
        return fg;
 }
 
-static struct mlx5_flow_table *alloc_flow_table(int level, u16 vport,
-                                               enum fs_flow_table_type table_type,
-                                               enum fs_flow_table_op_mod op_mod,
-                                               u32 flags)
+static struct mlx5_flow_table *
+alloc_flow_table(struct mlx5_flow_table_attr *ft_attr, u16 vport,
+                enum fs_flow_table_type table_type,
+                enum fs_flow_table_op_mod op_mod)
 {
        struct mlx5_flow_table *ft;
        int ret;
@@ -957,12 +957,13 @@ static struct mlx5_flow_table *alloc_flow_table(int level, u16 vport,
                return ERR_PTR(ret);
        }
 
-       ft->level = level;
+       ft->level = ft_attr->level;
        ft->node.type = FS_TYPE_FLOW_TABLE;
        ft->op_mod = op_mod;
        ft->type = table_type;
        ft->vport = vport;
-       ft->flags = flags;
+       ft->esw_owner_vhca_id = ft_attr->esw_owner_vhca_id;
+       ft->flags = ft_attr->flags;
        INIT_LIST_HEAD(&ft->fwd_rules);
        mutex_init(&ft->lock);
 
@@ -1370,10 +1371,7 @@ static struct mlx5_flow_table *__mlx5_create_flow_table(struct mlx5_flow_namespa
        /* The level is related to the
         * priority level range.
         */
-       ft = alloc_flow_table(ft_attr->level,
-                             vport,
-                             root->table_type,
-                             op_mod, ft_attr->flags);
+       ft = alloc_flow_table(ft_attr, vport, root->table_type, op_mod);
        if (IS_ERR(ft)) {
                err = PTR_ERR(ft);
                goto unlock_root;
index 8458ce203dac6aaa38a7d62d7dd99409f5fa0d61..0a9a5ef34c21e209c41035bc7b61f96c309ef9a4 100644 (file)
@@ -205,6 +205,7 @@ struct mlx5_flow_table {
        };
        u32                             id;
        u16                             vport;
+       u16                             esw_owner_vhca_id;
        unsigned int                    max_fte;
        unsigned int                    level;
        enum fs_flow_table_type         type;
index 6ac76a0c38277304a26d091f0ef6b41e49cde5f2..6325a7fa0df203f68c71f60aaa023437b67ecda9 100644 (file)
@@ -71,6 +71,7 @@ enum {
        MLX5_FLOW_TABLE_UNMANAGED = BIT(3),
        MLX5_FLOW_TABLE_OTHER_VPORT = BIT(4),
        MLX5_FLOW_TABLE_UPLINK_VPORT = BIT(5),
+       MLX5_FLOW_TABLE_OTHER_ESWITCH = BIT(6),
 };
 
 #define LEFTOVERS_RULE_NUM      2
@@ -208,6 +209,7 @@ struct mlx5_flow_table_attr {
        u32 flags;
        u16 uid;
        u16 vport;
+       u16 esw_owner_vhca_id;
        struct mlx5_flow_table *next_ft;
 
        struct {