diff options
author | Mark Bloch <mbloch@nvidia.com> | 2023-02-19 11:27:30 +0000 |
---|---|---|
committer | Konstantin Belousov <kib@FreeBSD.org> | 2023-11-15 23:08:16 +0000 |
commit | 45e2e55df665c9b5749c9f2269d1b804147917eb (patch) | |
tree | d8a9cba8a9f9ddc1240a7173edaa491b2204904a /sys/dev/mlx5/mlx5_core | |
parent | 847542c60c2b3d922d636cc36ce51714032f9825 (diff) |
mlx5: Add packet reformat support to flow rules
Allow attaching a packet reformat action to a flow rule.
Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Sponsored by: NVidia networking
MFC after: 1 week
Diffstat (limited to 'sys/dev/mlx5/mlx5_core')
-rw-r--r-- | sys/dev/mlx5/mlx5_core/fs_core.h | 5 | ||||
-rw-r--r-- | sys/dev/mlx5/mlx5_core/mlx5_fs_cmd.c | 13 | ||||
-rw-r--r-- | sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c | 19 |
3 files changed, 24 insertions, 13 deletions
diff --git a/sys/dev/mlx5/mlx5_core/fs_core.h b/sys/dev/mlx5/mlx5_core/fs_core.h index 40c6cadf3223..34dacf1af253 100644 --- a/sys/dev/mlx5/mlx5_core/fs_core.h +++ b/sys/dev/mlx5/mlx5_core/fs_core.h @@ -264,9 +264,8 @@ void _fs_remove_node(struct kref *kref); &(fte)->dests) int mlx5_cmd_fs_create_ft(struct mlx5_core_dev *dev, - u16 vport, - enum fs_ft_type type, unsigned int level, - unsigned int log_size, unsigned int *table_id); + u16 vport, enum fs_ft_type type, unsigned int level, + unsigned int log_size, const char *name, unsigned int *table_id); int mlx5_cmd_fs_destroy_ft(struct mlx5_core_dev *dev, u16 vport, diff --git a/sys/dev/mlx5/mlx5_core/mlx5_fs_cmd.c b/sys/dev/mlx5/mlx5_core/mlx5_fs_cmd.c index 22bc945a4b62..8c2708c504ee 100644 --- a/sys/dev/mlx5/mlx5_core/mlx5_fs_cmd.c +++ b/sys/dev/mlx5/mlx5_core/mlx5_fs_cmd.c @@ -54,9 +54,8 @@ int mlx5_cmd_update_root_ft(struct mlx5_core_dev *dev, } int mlx5_cmd_fs_create_ft(struct mlx5_core_dev *dev, - u16 vport, - enum fs_ft_type type, unsigned int level, - unsigned int log_size, unsigned int *table_id) + u16 vport, enum fs_ft_type type, unsigned int level, + unsigned int log_size, const char *name, unsigned int *table_id) { u32 in[MLX5_ST_SZ_DW(create_flow_table_in)] = {0}; u32 out[MLX5_ST_SZ_DW(create_flow_table_out)] = {0}; @@ -72,6 +71,9 @@ int mlx5_cmd_fs_create_ft(struct mlx5_core_dev *dev, MLX5_SET(create_flow_table_in, in, flow_table_context.level, level); MLX5_SET(create_flow_table_in, in, flow_table_context.log_size, log_size); + if (strstr(name, FS_REFORMAT_KEYWORD) != NULL) + MLX5_SET(create_flow_table_in, in, + flow_table_context.reformat_en, 1); if (vport) { MLX5_SET(create_flow_table_in, in, vport_number, vport); MLX5_SET(create_flow_table_in, in, other_vport, 1); @@ -228,6 +230,11 @@ int mlx5_cmd_fs_set_fte(struct mlx5_core_dev *dev, flow_act->modify_hdr->id); prm_action |= MLX5_FLOW_CONTEXT_ACTION_MOD_HDR; } + if (flow_act->actions & MLX5_FLOW_ACT_ACTIONS_PACKET_REFORMAT) { + MLX5_SET(flow_context, in_flow_context, packet_reformat_id, + flow_act->pkt_reformat->id); + prm_action |= MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT; + } MLX5_SET(flow_context, in_flow_context, destination_list_size, dest_size); in_match_value = MLX5_ADDR_OF(flow_context, in_flow_context, diff --git a/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c b/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c index 7c3eb1e86d6d..55d7e69d6140 100644 --- a/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c +++ b/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c @@ -816,8 +816,14 @@ static struct mlx5_flow_table *_create_ft_common(struct mlx5_flow_namespace *ns, /*User isn't aware to those rules*/ ft->max_fte = ft_size - 2; log_table_sz = ilog2(ft_size); + + if (name == NULL || name[0] == '\0') { + snprintf(gen_name, sizeof(gen_name), "flow_table_%u", ft->id); + name = gen_name; + } + err = mlx5_cmd_fs_create_ft(root->dev, ft->vport, ft->type, - ft->level, log_table_sz, &ft->id); + ft->level, log_table_sz, name, &ft->id); if (err) goto free_ft; @@ -832,12 +838,8 @@ static struct mlx5_flow_table *_create_ft_common(struct mlx5_flow_namespace *ns, goto destroy_star_rule; } - if (!name || !strlen(name)) { - snprintf(gen_name, 20, "flow_table_%u", ft->id); - _fs_add_node(&ft->base, gen_name, &fs_prio->base); - } else { - _fs_add_node(&ft->base, name, &fs_prio->base); - } + _fs_add_node(&ft->base, name, &fs_prio->base); + list_add_tail(&ft->base.list, &fs_prio->objs); fs_prio->num_ft++; @@ -1764,6 +1766,9 @@ static bool check_conflicting_actions(const struct mlx5_flow_act *act1, if (action1 & MLX5_FLOW_ACT_ACTIONS_MODIFY_HDR) return true; + if (action1 & MLX5_FLOW_ACT_ACTIONS_PACKET_REFORMAT) + return true; + return false; } |