1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2 /* Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */
3 
4 #ifndef __MLX5_EN_POST_METER_H__
5 #define __MLX5_EN_POST_METER_H__
6 
7 #define packet_color_to_reg { \
8 	.mfield = MLX5_ACTION_IN_FIELD_METADATA_REG_C_5, \
9 	.moffset = 0, \
10 	.mlen = 8, \
11 	.soffset = MLX5_BYTE_OFF(fte_match_param, \
12 				 misc_parameters_2.metadata_reg_c_5), \
13 }
14 
15 struct mlx5e_post_meter_priv;
16 
17 enum mlx5e_post_meter_type {
18 	MLX5E_POST_METER_RATE = 0,
19 	MLX5E_POST_METER_MTU
20 };
21 
22 #if IS_ENABLED(CONFIG_MLX5_CLS_ACT)
23 
24 struct mlx5_flow_table *
25 mlx5e_post_meter_get_ft(struct mlx5e_post_meter_priv *post_meter);
26 
27 struct mlx5_flow_table *
28 mlx5e_post_meter_get_mtu_true_ft(struct mlx5e_post_meter_priv *post_meter);
29 
30 struct mlx5_flow_table *
31 mlx5e_post_meter_get_mtu_false_ft(struct mlx5e_post_meter_priv *post_meter);
32 
33 struct mlx5e_post_meter_priv *
34 mlx5e_post_meter_init(struct mlx5e_priv *priv,
35 		      enum mlx5_flow_namespace_type ns_type,
36 		      struct mlx5e_post_act *post_act,
37 		      enum mlx5e_post_meter_type type,
38 		      struct mlx5_fc *act_counter,
39 		      struct mlx5_fc *drop_counter,
40 		      struct mlx5_flow_attr *branch_true,
41 		      struct mlx5_flow_attr *branch_false);
42 
43 void
44 mlx5e_post_meter_cleanup(struct mlx5_eswitch *esw, struct mlx5e_post_meter_priv *post_meter);
45 
46 #else /* CONFIG_MLX5_CLS_ACT */
47 
48 static inline struct mlx5_flow_table *
mlx5e_post_meter_get_mtu_true_ft(struct mlx5e_post_meter_priv * post_meter)49 mlx5e_post_meter_get_mtu_true_ft(struct mlx5e_post_meter_priv *post_meter)
50 {
51 	return NULL;
52 }
53 
54 static inline struct mlx5_flow_table *
mlx5e_post_meter_get_mtu_false_ft(struct mlx5e_post_meter_priv * post_meter)55 mlx5e_post_meter_get_mtu_false_ft(struct mlx5e_post_meter_priv *post_meter)
56 {
57 	return NULL;
58 }
59 
60 #endif
61 
62 #endif /* __MLX5_EN_POST_METER_H__ */
63