+/* Yellow is not supported. */
+#define MLX5_MTR_RTE_COLORS (RTE_COLOR_GREEN + 1)
+/* table_id 22 bits in mlx5_flow_tbl_key so limit policy number. */
+#define MLX5_MAX_SUB_POLICY_TBL_NUM 0x3FFFFF
+#define MLX5_INVALID_POLICY_ID UINT32_MAX
+/* Suffix table_id on MLX5_FLOW_TABLE_LEVEL_METER. */
+#define MLX5_MTR_TABLE_ID_SUFFIX 1
+/* Drop table_id on MLX5_FLOW_TABLE_LEVEL_METER. */
+#define MLX5_MTR_TABLE_ID_DROP 2
+
+enum mlx5_meter_domain {
+ MLX5_MTR_DOMAIN_INGRESS,
+ MLX5_MTR_DOMAIN_EGRESS,
+ MLX5_MTR_DOMAIN_TRANSFER,
+ MLX5_MTR_DOMAIN_MAX,
+};
+#define MLX5_MTR_DOMAIN_INGRESS_BIT (1 << MLX5_MTR_DOMAIN_INGRESS)
+#define MLX5_MTR_DOMAIN_EGRESS_BIT (1 << MLX5_MTR_DOMAIN_EGRESS)
+#define MLX5_MTR_DOMAIN_TRANSFER_BIT (1 << MLX5_MTR_DOMAIN_TRANSFER)
+#define MLX5_MTR_ALL_DOMAIN_BIT (MLX5_MTR_DOMAIN_INGRESS_BIT | \
+ MLX5_MTR_DOMAIN_EGRESS_BIT | \
+ MLX5_MTR_DOMAIN_TRANSFER_BIT)
+
+/*
+ * Meter sub-policy structure.
+ * Each RSS TIR in meter policy need its own sub-policy resource.
+ */
+struct mlx5_flow_meter_sub_policy {
+ uint32_t main_policy_id:1;
+ /* Main policy id is same as this sub_policy id. */
+ uint32_t idx:31;
+ /* Index to sub_policy ipool entity. */
+ void *main_policy;
+ /* Point to struct mlx5_flow_meter_policy. */
+ struct mlx5_flow_tbl_resource *tbl_rsc;
+ /* The sub-policy table resource. */
+ uint32_t rix_hrxq[MLX5_MTR_RTE_COLORS];
+ /* Index to TIR resource. */
+ struct mlx5_flow_tbl_resource *jump_tbl[MLX5_MTR_RTE_COLORS];
+ /* Meter jump/drop table. */
+ struct mlx5_flow_dv_matcher *color_matcher[RTE_COLORS];
+ /* Matcher for Color. */
+ void *color_rule[RTE_COLORS];
+ /* Meter green/yellow/drop rule. */
+};
+
+struct mlx5_meter_policy_acts {
+ uint8_t actions_n;
+ /* Number of actions. */
+ void *dv_actions[MLX5_DV_MAX_NUMBER_OF_ACTIONS];
+ /* Action list. */
+};
+
+struct mlx5_meter_policy_action_container {
+ uint32_t rix_mark;
+ /* Index to the mark action. */
+ struct mlx5_flow_dv_modify_hdr_resource *modify_hdr;
+ /* Pointer to modify header resource in cache. */
+ uint8_t fate_action;
+ /* Fate action type. */
+ union {
+ struct rte_flow_action *rss;
+ /* Rss action configuration. */
+ uint32_t rix_port_id_action;
+ /* Index to port ID action resource. */
+ void *dr_jump_action[MLX5_MTR_DOMAIN_MAX];
+ /* Jump/drop action per color. */
+ uint16_t queue;
+ /* Queue action configuration. */
+ };
+};