diff options
author | Raed Salem <raeds@mellanox.com> | 2017-07-30 04:02:51 -0400 |
---|---|---|
committer | Saeed Mahameed <saeedm@mellanox.com> | 2017-09-28 00:23:09 -0400 |
commit | 16f1c5bb3ed75b3cf3ced537db40f7e1a244debe (patch) | |
tree | a61474d598ef7cdc97934816a0ad82cd34b10fae | |
parent | 99d3cd27f755d63fd6cf85169eaa873d90769aa5 (diff) |
net/mlx5: Check device capability for maximum flow counters
Added check for the maximal number of flow counters attached
to rule (FTE).
Fixes: bd5251dbf156b ('net/mlx5_core: Introduce flow steering destination of type counter')
Signed-off-by: Raed Salem <raeds@mellanox.com>
Reviewed-by: Maor Gottlieb <maorg@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c | 8 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx5/core/fs_core.h | 11 | ||||
-rw-r--r-- | include/linux/mlx5/mlx5_ifc.h | 3 |
3 files changed, 21 insertions, 1 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c index e0d0efd903bc..36ecc2b2e187 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_cmd.c | |||
@@ -293,6 +293,9 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev, | |||
293 | } | 293 | } |
294 | 294 | ||
295 | if (fte->action & MLX5_FLOW_CONTEXT_ACTION_COUNT) { | 295 | if (fte->action & MLX5_FLOW_CONTEXT_ACTION_COUNT) { |
296 | int max_list_size = BIT(MLX5_CAP_FLOWTABLE_TYPE(dev, | ||
297 | log_max_flow_counter, | ||
298 | ft->type)); | ||
296 | int list_size = 0; | 299 | int list_size = 0; |
297 | 300 | ||
298 | list_for_each_entry(dst, &fte->node.children, node.list) { | 301 | list_for_each_entry(dst, &fte->node.children, node.list) { |
@@ -305,12 +308,17 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev, | |||
305 | in_dests += MLX5_ST_SZ_BYTES(dest_format_struct); | 308 | in_dests += MLX5_ST_SZ_BYTES(dest_format_struct); |
306 | list_size++; | 309 | list_size++; |
307 | } | 310 | } |
311 | if (list_size > max_list_size) { | ||
312 | err = -EINVAL; | ||
313 | goto err_out; | ||
314 | } | ||
308 | 315 | ||
309 | MLX5_SET(flow_context, in_flow_context, flow_counter_list_size, | 316 | MLX5_SET(flow_context, in_flow_context, flow_counter_list_size, |
310 | list_size); | 317 | list_size); |
311 | } | 318 | } |
312 | 319 | ||
313 | err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out)); | 320 | err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out)); |
321 | err_out: | ||
314 | kvfree(in); | 322 | kvfree(in); |
315 | return err; | 323 | return err; |
316 | } | 324 | } |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h index 5509a752f98e..48dd78975062 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/fs_core.h | |||
@@ -52,6 +52,7 @@ enum fs_flow_table_type { | |||
52 | FS_FT_FDB = 0X4, | 52 | FS_FT_FDB = 0X4, |
53 | FS_FT_SNIFFER_RX = 0X5, | 53 | FS_FT_SNIFFER_RX = 0X5, |
54 | FS_FT_SNIFFER_TX = 0X6, | 54 | FS_FT_SNIFFER_TX = 0X6, |
55 | FS_FT_MAX_TYPE = FS_FT_SNIFFER_TX, | ||
55 | }; | 56 | }; |
56 | 57 | ||
57 | enum fs_flow_table_op_mod { | 58 | enum fs_flow_table_op_mod { |
@@ -260,4 +261,14 @@ void mlx5_cleanup_fs(struct mlx5_core_dev *dev); | |||
260 | #define fs_for_each_dst(pos, fte) \ | 261 | #define fs_for_each_dst(pos, fte) \ |
261 | fs_list_for_each_entry(pos, &(fte)->node.children) | 262 | fs_list_for_each_entry(pos, &(fte)->node.children) |
262 | 263 | ||
264 | #define MLX5_CAP_FLOWTABLE_TYPE(mdev, cap, type) ( \ | ||
265 | (type == FS_FT_NIC_RX) ? MLX5_CAP_FLOWTABLE_NIC_RX(mdev, cap) : \ | ||
266 | (type == FS_FT_ESW_EGRESS_ACL) ? MLX5_CAP_ESW_EGRESS_ACL(mdev, cap) : \ | ||
267 | (type == FS_FT_ESW_INGRESS_ACL) ? MLX5_CAP_ESW_INGRESS_ACL(mdev, cap) : \ | ||
268 | (type == FS_FT_FDB) ? MLX5_CAP_ESW_FLOWTABLE_FDB(mdev, cap) : \ | ||
269 | (type == FS_FT_SNIFFER_RX) ? MLX5_CAP_FLOWTABLE_SNIFFER_RX(mdev, cap) : \ | ||
270 | (type == FS_FT_SNIFFER_TX) ? MLX5_CAP_FLOWTABLE_SNIFFER_TX(mdev, cap) : \ | ||
271 | (BUILD_BUG_ON_ZERO(FS_FT_SNIFFER_TX != FS_FT_MAX_TYPE))\ | ||
272 | ) | ||
273 | |||
263 | #endif | 274 | #endif |
diff --git a/include/linux/mlx5/mlx5_ifc.h b/include/linux/mlx5/mlx5_ifc.h index a528b35a022e..69772347f866 100644 --- a/include/linux/mlx5/mlx5_ifc.h +++ b/include/linux/mlx5/mlx5_ifc.h | |||
@@ -327,7 +327,8 @@ struct mlx5_ifc_flow_table_prop_layout_bits { | |||
327 | u8 reserved_at_80[0x18]; | 327 | u8 reserved_at_80[0x18]; |
328 | u8 log_max_destination[0x8]; | 328 | u8 log_max_destination[0x8]; |
329 | 329 | ||
330 | u8 reserved_at_a0[0x18]; | 330 | u8 log_max_flow_counter[0x8]; |
331 | u8 reserved_at_a8[0x10]; | ||
331 | u8 log_max_flow[0x8]; | 332 | u8 log_max_flow[0x8]; |
332 | 333 | ||
333 | u8 reserved_at_c0[0x40]; | 334 | u8 reserved_at_c0[0x40]; |