- if (id > (REG_C_7 - REG_C_4))
- return rte_flow_error_set
- (error, EINVAL,
- RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
- NULL, "invalid tag id");
- if (config->flow_mreg_c[id + REG_C_4 - REG_C_0] == REG_NONE)
- return rte_flow_error_set
- (error, ENOTSUP,
- RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
- NULL, "unsupported tag id");
- return config->flow_mreg_c[id + REG_C_4 - REG_C_0];
+ if (priv->mtr_color_reg != REG_NONE)
+ start_reg = priv->mtr_color_reg != REG_C_2 ? REG_C_3 :
+ REG_C_4;
+ else
+ start_reg = REG_C_2;
+ if (id > (REG_C_7 - start_reg))
+ return rte_flow_error_set(error, EINVAL,
+ RTE_FLOW_ERROR_TYPE_ITEM,
+ NULL, "invalid tag id");
+ if (config->flow_mreg_c[id + start_reg - REG_C_0] == REG_NONE)
+ return rte_flow_error_set(error, ENOTSUP,
+ RTE_FLOW_ERROR_TYPE_ITEM,
+ NULL, "unsupported tag id");
+ /*
+ * This case means meter is using the REG_C_x great than 2.
+ * Take care not to conflict with meter color REG_C_x.
+ * If the available index REG_C_y >= REG_C_x, skip the
+ * color register.
+ */
+ if (start_reg == REG_C_3 && config->flow_mreg_c
+ [id + REG_C_3 - REG_C_0] >= priv->mtr_color_reg) {
+ if (config->flow_mreg_c[id + 1 + REG_C_3 - REG_C_0] !=
+ REG_NONE)
+ return config->flow_mreg_c
+ [id + 1 + REG_C_3 - REG_C_0];
+ return rte_flow_error_set(error, ENOTSUP,
+ RTE_FLOW_ERROR_TYPE_ITEM,
+ NULL, "unsupported tag id");
+ }
+ return config->flow_mreg_c[id + start_reg - REG_C_0];