mirror of
https://github.com/opnsense/src.git
synced 2026-04-07 18:35:22 -04:00
mlx5: Add packet reformat support to flow rules
(cherry picked from commit 45e2e55df665c9b5749c9f2269d1b804147917eb)
This commit is contained in:
parent
8895a05096
commit
6fb2eebf64
5 changed files with 29 additions and 13 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue