git: 45e2e55df665 - main - mlx5: Add packet reformat support to flow rules
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 15 Nov 2023 23:09:08 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=45e2e55df665c9b5749c9f2269d1b804147917eb commit 45e2e55df665c9b5749c9f2269d1b804147917eb Author: Mark Bloch <mbloch@nvidia.com> AuthorDate: 2023-02-19 11:27:30 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2023-11-15 23:08:16 +0000 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 --- sys/dev/mlx5/fs.h | 4 ++++ sys/dev/mlx5/mlx5_core/fs_core.h | 5 ++--- sys/dev/mlx5/mlx5_core/mlx5_fs_cmd.c | 13 ++++++++++--- sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c | 19 ++++++++++++------- sys/dev/mlx5/mlx5_ifc.h | 1 + 5 files changed, 29 insertions(+), 13 deletions(-) diff --git a/sys/dev/mlx5/fs.h b/sys/dev/mlx5/fs.h index bb087718d12f..58bdf19ccdab 100644 --- a/sys/dev/mlx5/fs.h +++ b/sys/dev/mlx5/fs.h @@ -50,6 +50,8 @@ enum { #define FS_MAX_TYPES 10 #define FS_MAX_ENTRIES 32000U +#define FS_REFORMAT_KEYWORD "_reformat" + enum mlx5_flow_namespace_type { MLX5_FLOW_NAMESPACE_BYPASS, MLX5_FLOW_NAMESPACE_OFFLOADS, @@ -85,12 +87,14 @@ struct mlx5_flow_destination { enum mlx5_flow_act_actions { MLX5_FLOW_ACT_ACTIONS_FLOW_TAG = 1 << 0, MLX5_FLOW_ACT_ACTIONS_MODIFY_HDR = 1 << 1, + MLX5_FLOW_ACT_ACTIONS_PACKET_REFORMAT = 1 << 2, }; struct mlx5_flow_act { u32 actions; /* See enum mlx5_flow_act_actions */ u32 flow_tag; struct mlx5_modify_hdr *modify_hdr; + struct mlx5_pkt_reformat *pkt_reformat; }; #define FT_NAME_STR_SZ 20 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; } diff --git a/sys/dev/mlx5/mlx5_ifc.h b/sys/dev/mlx5/mlx5_ifc.h index 9534ac3d1c94..382d6c195ac9 100644 --- a/sys/dev/mlx5/mlx5_ifc.h +++ b/sys/dev/mlx5/mlx5_ifc.h @@ -2264,6 +2264,7 @@ enum { MLX5_FLOW_CONTEXT_ACTION_DROP = 0x2, MLX5_FLOW_CONTEXT_ACTION_FWD_DEST = 0x4, MLX5_FLOW_CONTEXT_ACTION_COUNT = 0x8, + MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT = 0x10, MLX5_FLOW_CONTEXT_ACTION_MOD_HDR = 0x40, };