diff options
author | Mark Bloch <mbloch@nvidia.com> | 2023-02-22 05:44:56 +0000 |
---|---|---|
committer | Konstantin Belousov <kib@FreeBSD.org> | 2023-11-15 23:08:17 +0000 |
commit | ad744541311bfddd74ea3c5d49d52a4c366b9762 (patch) | |
tree | 0d03124f9d28fec93434db3b2bfbdf2a5db54472 | |
parent | 35bbcf0916992d77fe1521962db42b3106a701fb (diff) | |
download | src-ad744541311bfddd74ea3c5d49d52a4c366b9762.tar.gz src-ad744541311bfddd74ea3c5d49d52a4c366b9762.zip |
mlx5: add ability to attach flow counter to steering rule
Expose a way to attach a counter to a flow rule.
Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Sponsored by: NVidia networking
MFC after: 1 week
-rw-r--r-- | sys/dev/mlx5/fs.h | 2 | ||||
-rw-r--r-- | sys/dev/mlx5/mlx5_core/mlx5_fs_cmd.c | 19 | ||||
-rw-r--r-- | sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c | 3 |
3 files changed, 22 insertions, 2 deletions
diff --git a/sys/dev/mlx5/fs.h b/sys/dev/mlx5/fs.h index 65d38b9ee67a..8aaa0e201f4a 100644 --- a/sys/dev/mlx5/fs.h +++ b/sys/dev/mlx5/fs.h @@ -94,6 +94,7 @@ 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, + MLX5_FLOW_ACT_ACTIONS_COUNT = 1 << 3, }; enum MLX5_FLOW_ACT_FLAGS { @@ -106,6 +107,7 @@ struct mlx5_flow_act { u32 flow_tag; struct mlx5_modify_hdr *modify_hdr; struct mlx5_pkt_reformat *pkt_reformat; + struct mlx5_fc *counter; }; #define FT_NAME_STR_SZ 20 diff --git a/sys/dev/mlx5/mlx5_core/mlx5_fs_cmd.c b/sys/dev/mlx5/mlx5_core/mlx5_fs_cmd.c index 8032d1a632e5..0f827f0e69d3 100644 --- a/sys/dev/mlx5/mlx5_core/mlx5_fs_cmd.c +++ b/sys/dev/mlx5/mlx5_core/mlx5_fs_cmd.c @@ -182,6 +182,7 @@ int mlx5_cmd_fs_set_fte(struct mlx5_core_dev *dev, int modify_mask = 0; int atomic_mod_cap; u32 prm_action = 0; + int count_list = 0; if (sw_action != MLX5_FLOW_RULE_FWD_ACTION_DEST) dest_size = 0; @@ -195,8 +196,13 @@ int mlx5_cmd_fs_set_fte(struct mlx5_core_dev *dev, if (sw_action & MLX5_FLOW_RULE_FWD_ACTION_DEST) prm_action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST; + if (flow_act->actions & MLX5_FLOW_ACT_ACTIONS_COUNT) { + prm_action |= MLX5_FLOW_CONTEXT_ACTION_COUNT; + count_list = 1; + } + inlen = MLX5_ST_SZ_BYTES(set_fte_in) + - dest_size * MLX5_ST_SZ_BYTES(dest_format_struct); + (dest_size + count_list) * MLX5_ST_SZ_BYTES(dest_format_struct); if (!dev) return -EINVAL; @@ -248,8 +254,10 @@ int mlx5_cmd_fs_set_fte(struct mlx5_core_dev *dev, in_match_value = MLX5_ADDR_OF(flow_context, in_flow_context, match_value); memcpy(in_match_value, match_val, MLX5_ST_SZ_BYTES(fte_match_param)); + + in_dests = MLX5_ADDR_OF(flow_context, in_flow_context, destination); + if (dest_size) { - in_dests = MLX5_ADDR_OF(flow_context, in_flow_context, destination); list_for_each_entry(dst, dests, base.list) { unsigned int id; @@ -265,6 +273,13 @@ int mlx5_cmd_fs_set_fte(struct mlx5_core_dev *dev, } } + if (flow_act->actions & MLX5_FLOW_ACT_ACTIONS_COUNT) { + MLX5_SET(dest_format_struct, in_dests, destination_id, + mlx5_fc_id(flow_act->counter)); + in_dests += MLX5_ST_SZ_BYTES(dest_format_struct); + MLX5_SET(flow_context, in_flow_context, flow_counter_list_size, 1); + } + MLX5_SET(flow_context, in_flow_context, action, prm_action); err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out)); if (!err) diff --git a/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c b/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c index 91543d3878ef..5966a73c58d1 100644 --- a/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c +++ b/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c @@ -1788,6 +1788,9 @@ static bool check_conflicting_actions(const struct mlx5_flow_act *act1, if (action1 & MLX5_FLOW_ACT_ACTIONS_PACKET_REFORMAT) return true; + if (action1 & MLX5_FLOW_ACT_ACTIONS_COUNT) + return true; + return false; } |