diff options
author | Mark Bloch <mbloch@nvidia.com> | 2023-02-19 12:25:10 +0000 |
---|---|---|
committer | Konstantin Belousov <kib@FreeBSD.org> | 2023-11-15 23:08:16 +0000 |
commit | 76ed99ed8ad259792fea752461e2cd1ed481e8e1 (patch) | |
tree | 04236aec6009a9da391947693709d2d1f165bd27 /sys/dev/mlx5/mlx5_core | |
parent | 45e2e55df665c9b5749c9f2269d1b804147917eb (diff) |
mlx5: Use software enum in APIs instead of PRM
Users of the steering APIs shouldn't use the PRM directly.
Create an software enum to be used instead.
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 | 4 | ||||
-rw-r--r-- | sys/dev/mlx5/mlx5_core/mlx5_eswitch.c | 8 | ||||
-rw-r--r-- | sys/dev/mlx5/mlx5_core/mlx5_fs_cmd.c | 14 | ||||
-rw-r--r-- | sys/dev/mlx5/mlx5_core/mlx5_fs_tcp.c | 4 | ||||
-rw-r--r-- | sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c | 32 |
5 files changed, 35 insertions, 27 deletions
diff --git a/sys/dev/mlx5/mlx5_core/fs_core.h b/sys/dev/mlx5/mlx5_core/fs_core.h index 34dacf1af253..3eae7868833f 100644 --- a/sys/dev/mlx5/mlx5_core/fs_core.h +++ b/sys/dev/mlx5/mlx5_core/fs_core.h @@ -81,7 +81,7 @@ struct fs_fte { struct list_head dests; uint32_t index; /* index in ft */ struct mlx5_flow_act flow_act; - u8 action; /* MLX5_FLOW_CONTEXT_ACTION */ + u32 sw_action; /* enum mlx5_rule_fwd_action */ enum fs_fte_status status; }; @@ -290,7 +290,7 @@ int mlx5_cmd_fs_set_fte(struct mlx5_core_dev *dev, enum fs_ft_type type, unsigned int table_id, unsigned int index, unsigned int group_id, struct mlx5_flow_act *flow_act, - unsigned short action, int dest_size, + u32 sw_action, int dest_size, struct list_head *dests); /* mlx5_flow_desination */ int mlx5_cmd_fs_delete_fte(struct mlx5_core_dev *dev, diff --git a/sys/dev/mlx5/mlx5_core/mlx5_eswitch.c b/sys/dev/mlx5/mlx5_core/mlx5_eswitch.c index 9f9350e0260b..15f5f0ff0336 100644 --- a/sys/dev/mlx5/mlx5_core/mlx5_eswitch.c +++ b/sys/dev/mlx5/mlx5_core/mlx5_eswitch.c @@ -253,7 +253,7 @@ esw_fdb_set_vport_rule(struct mlx5_eswitch *esw, u8 mac[ETH_ALEN], u32 vport) match_header, match_c, match_v, - MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, + MLX5_FLOW_RULE_FWD_ACTION_DEST, &flow_act, &dest); if (IS_ERR_OR_NULL(flow_rule)) { printf("mlx5_core: WARN: ""FDB: Failed to add flow rule: dmac_v(%pM) dmac_c(%pM) -> vport(%d), err(%ld)\n", dmac_v, dmac_c, vport, PTR_ERR(flow_rule)); @@ -825,7 +825,7 @@ static int esw_vport_ingress_config(struct mlx5_eswitch *esw, MLX5_MATCH_OUTER_HEADERS, match_c, match_v, - MLX5_FLOW_CONTEXT_ACTION_DROP, + MLX5_FLOW_RULE_FWD_ACTION_DROP, &flow_act, &dest); if (IS_ERR_OR_NULL(vport->ingress.drop_rule)) { err = PTR_ERR(vport->ingress.drop_rule); @@ -885,7 +885,7 @@ static int esw_vport_egress_config(struct mlx5_eswitch *esw, MLX5_MATCH_OUTER_HEADERS, match_c, match_v, - MLX5_FLOW_CONTEXT_ACTION_ALLOW, + MLX5_FLOW_RULE_FWD_ACTION_ALLOW, &flow_act, &dest); if (IS_ERR_OR_NULL(vport->egress.allowed_vlan)) { err = PTR_ERR(vport->egress.allowed_vlan); @@ -902,7 +902,7 @@ static int esw_vport_egress_config(struct mlx5_eswitch *esw, 0, match_c, match_v, - MLX5_FLOW_CONTEXT_ACTION_DROP, + MLX5_FLOW_RULE_FWD_ACTION_DROP, &flow_act, &dest); if (IS_ERR_OR_NULL(vport->egress.drop_rule)) { err = PTR_ERR(vport->egress.drop_rule); diff --git a/sys/dev/mlx5/mlx5_core/mlx5_fs_cmd.c b/sys/dev/mlx5/mlx5_core/mlx5_fs_cmd.c index 8c2708c504ee..8032d1a632e5 100644 --- a/sys/dev/mlx5/mlx5_core/mlx5_fs_cmd.c +++ b/sys/dev/mlx5/mlx5_core/mlx5_fs_cmd.c @@ -167,7 +167,7 @@ int mlx5_cmd_fs_set_fte(struct mlx5_core_dev *dev, enum fs_ft_type type, unsigned int table_id, unsigned int index, unsigned int group_id, struct mlx5_flow_act *flow_act, - unsigned short action, int dest_size, + u32 sw_action, int dest_size, struct list_head *dests) /* mlx5_flow_desination */ { u32 out[MLX5_ST_SZ_DW(set_fte_out)] = {0}; @@ -183,10 +183,18 @@ int mlx5_cmd_fs_set_fte(struct mlx5_core_dev *dev, int atomic_mod_cap; u32 prm_action = 0; - if (action != MLX5_FLOW_CONTEXT_ACTION_FWD_DEST) + if (sw_action != MLX5_FLOW_RULE_FWD_ACTION_DEST) dest_size = 0; - prm_action = action; + if (sw_action & MLX5_FLOW_RULE_FWD_ACTION_ALLOW) + prm_action |= MLX5_FLOW_CONTEXT_ACTION_ALLOW; + + if (sw_action & MLX5_FLOW_RULE_FWD_ACTION_DROP) + prm_action |= MLX5_FLOW_CONTEXT_ACTION_DROP; + + if (sw_action & MLX5_FLOW_RULE_FWD_ACTION_DEST) + prm_action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST; + inlen = MLX5_ST_SZ_BYTES(set_fte_in) + dest_size * MLX5_ST_SZ_BYTES(dest_format_struct); diff --git a/sys/dev/mlx5/mlx5_core/mlx5_fs_tcp.c b/sys/dev/mlx5/mlx5_core/mlx5_fs_tcp.c index 69df9ecba210..d7d63d7932a1 100644 --- a/sys/dev/mlx5/mlx5_core/mlx5_fs_tcp.c +++ b/sys/dev/mlx5/mlx5_core/mlx5_fs_tcp.c @@ -164,7 +164,7 @@ mlx5e_accel_fs_add_inpcb(struct mlx5e_priv *priv, flow = mlx5_add_flow_rule(ft->t, spec->match_criteria_enable, spec->match_criteria, spec->match_value, - MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, + MLX5_FLOW_RULE_FWD_ACTION_DEST, &flow_act, &dest); out: @@ -200,7 +200,7 @@ accel_fs_tcp_add_default_rule(struct mlx5e_priv *priv, int type) priv->fts.vlan.t : fs_tcp->tables[type + 1].t; rule = mlx5_add_flow_rule(fs_tcp->tables[type].t, 0, match_criteria, match_value, - MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, &flow_act, &dest); + MLX5_FLOW_RULE_FWD_ACTION_DEST, &flow_act, &dest); if (IS_ERR(rule)) return (PTR_ERR(rule)); diff --git a/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c b/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c index 55d7e69d6140..60353e4b3d5b 100644 --- a/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c +++ b/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c @@ -302,7 +302,7 @@ static void fs_remove_node_parent_locked(struct fs_base *node) kfree(node); } -static struct fs_fte *fs_alloc_fte(u8 action, +static struct fs_fte *fs_alloc_fte(u32 sw_action, struct mlx5_flow_act *flow_act, u32 *match_value, unsigned int index) @@ -320,7 +320,7 @@ static struct fs_fte *fs_alloc_fte(u8 action, fte->index = index; INIT_LIST_HEAD(&fte->dests); fte->flow_act = *flow_act; - fte->action = action; + fte->sw_action = sw_action; return fte; } @@ -341,7 +341,7 @@ static struct fs_fte *alloc_star_ft_entry(struct mlx5_flow_table *ft, if (fg->num_ftes == fg->max_ftes) return ERR_PTR(-ENOSPC); - fte = fs_alloc_fte(MLX5_FLOW_CONTEXT_ACTION_FWD_DEST, + fte = fs_alloc_fte(MLX5_FLOW_RULE_FWD_ACTION_DEST, &flow_act, match_value, index); if (IS_ERR(fte)) return fte; @@ -447,7 +447,7 @@ static int fs_set_star_rule(struct mlx5_core_dev *dev, src_ft->id, src_fte->index, src_ft->star_rule.fg->id, &src_fte->flow_act, - src_fte->action, + src_fte->sw_action, src_fte->dests_size, &src_fte->dests); if (err) @@ -1590,7 +1590,7 @@ static struct mlx5_flow_rule *_fs_add_dst_fte(struct fs_fte *fte, &fte->status, fte->val, ft->type, ft->id, fte->index, fg->id, &fte->flow_act, - fte->action, fte->dests_size, &fte->dests); + fte->sw_action, fte->dests_size, &fte->dests); if (err) goto free_dst; @@ -1652,7 +1652,7 @@ static unsigned int fs_get_free_fg_index(struct mlx5_flow_group *fg, static struct fs_fte *fs_create_fte(struct mlx5_flow_group *fg, u32 *match_value, - u8 action, + u32 sw_action, struct mlx5_flow_act *flow_act, struct list_head **prev) { @@ -1660,7 +1660,7 @@ static struct fs_fte *fs_create_fte(struct mlx5_flow_group *fg, int index = 0; index = fs_get_free_fg_index(fg, prev); - fte = fs_alloc_fte(action, flow_act, match_value, index); + fte = fs_alloc_fte(sw_action, flow_act, match_value, index); if (IS_ERR(fte)) return fte; @@ -1710,7 +1710,7 @@ static void fs_del_dst(struct mlx5_flow_rule *dst) err = mlx5_cmd_fs_set_fte(dev, ft->vport, &fte->status, match_value, ft->type, ft->id, fte->index, fg->id, - &fte->flow_act, fte->action, + &fte->flow_act, fte->sw_action, fte->dests_size, &fte->dests); if (err) { mlx5_core_warn(dev, "%s can't delete dst %s\n", @@ -1776,7 +1776,7 @@ static bool check_conflicting_actions(const struct mlx5_flow_act *act1, /* Add dst algorithm */ static struct mlx5_flow_rule *fs_add_dst_fg(struct mlx5_flow_group *fg, u32 *match_value, - u8 action, + u32 sw_action, struct mlx5_flow_act *flow_act, struct mlx5_flow_destination *dest) { @@ -1791,7 +1791,7 @@ static struct mlx5_flow_rule *fs_add_dst_fg(struct mlx5_flow_group *fg, /* TODO: Check of size against PRM max size */ mutex_lock(&fte->base.lock); if (fs_match_exact_val(&fg->mask, match_value, &fte->val) && - action == fte->action && + sw_action == fte->sw_action && !check_conflicting_actions(flow_act, &fte->flow_act)) { dst = _fs_add_dst_fte(fte, fg, dest); mutex_unlock(&fte->base.lock); @@ -1808,7 +1808,7 @@ static struct mlx5_flow_rule *fs_add_dst_fg(struct mlx5_flow_group *fg, goto unlock_fg; } - fte = fs_create_fte(fg, match_value, action, flow_act, &prev); + fte = fs_create_fte(fg, match_value, sw_action, flow_act, &prev); if (IS_ERR(fte)) { dst = (void *)fte; goto unlock_fg; @@ -1836,7 +1836,7 @@ static struct mlx5_flow_rule *fs_add_dst_ft(struct mlx5_flow_table *ft, u8 match_criteria_enable, u32 *match_criteria, u32 *match_value, - u8 action, + u32 sw_action, struct mlx5_flow_act *flow_act, struct mlx5_flow_destination *dest) { @@ -1853,7 +1853,7 @@ static struct mlx5_flow_rule *fs_add_dst_ft(struct mlx5_flow_table *ft, match_criteria)) { mutex_unlock(&ft->base.lock); - dst = fs_add_dst_fg(g, match_value, action, flow_act, dest); + dst = fs_add_dst_fg(g, match_value, sw_action, flow_act, dest); if (PTR_ERR(dst) && PTR_ERR(dst) != -ENOSPC) goto unlock; } @@ -1866,7 +1866,7 @@ static struct mlx5_flow_rule *fs_add_dst_ft(struct mlx5_flow_table *ft, } dst = fs_add_dst_fg(g, match_value, - action, flow_act, dest); + sw_action, flow_act, dest); if (IS_ERR(dst)) { /* Remove assumes refcount > 0 and autogroup creates a group * with a refcount = 0. @@ -1886,7 +1886,7 @@ mlx5_add_flow_rule(struct mlx5_flow_table *ft, u8 match_criteria_enable, u32 *match_criteria, u32 *match_value, - u32 action, + u32 sw_action, struct mlx5_flow_act *flow_act, struct mlx5_flow_destination *dest) { @@ -1897,7 +1897,7 @@ mlx5_add_flow_rule(struct mlx5_flow_table *ft, if (ns) down_read(&ns->dests_rw_sem); dst = fs_add_dst_ft(ft, match_criteria_enable, match_criteria, - match_value, action, flow_act, dest); + match_value, sw_action, flow_act, dest); if (ns) up_read(&ns->dests_rw_sem); |