Merge `mtr_color_reg` and `mlx5_flow_hw_aso_tag` into `aso_reg` Signed-off-by: Gregory Etelson <getel...@nvidia.com> Acked-by: Ori Kam <or...@nvidia.com> --- drivers/net/mlx5/linux/mlx5_os.c | 10 +++++----- drivers/net/mlx5/mlx5.h | 3 +-- drivers/net/mlx5/mlx5_flow.c | 16 ++++++++-------- drivers/net/mlx5/mlx5_flow.h | 3 +-- drivers/net/mlx5/mlx5_flow_dv.c | 7 ++++--- drivers/net/mlx5/mlx5_flow_hw.c | 3 +-- drivers/net/mlx5/mlx5_flow_meter.c | 4 ++-- 7 files changed, 22 insertions(+), 24 deletions(-)
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 96d32d11d8..ed273e14cf 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -1328,14 +1328,14 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, * Prefer REG_C_3 if it is available. */ if (reg_c_mask & (1 << (REG_C_3 - REG_C_0))) - sh->registers.mtr_color_reg = REG_C_3; + sh->registers.aso_reg = REG_C_3; else - sh->registers.mtr_color_reg = + sh->registers.aso_reg = ffs(reg_c_mask) - 1 + REG_C_0; priv->mtr_en = 1; priv->mtr_reg_share = hca_attr->qos.flow_meter; DRV_LOG(DEBUG, "The REG_C meter uses is %d", - sh->registers.mtr_color_reg); + sh->registers.aso_reg); } } if (hca_attr->qos.sup && hca_attr->qos.flow_meter_aso_sup) { @@ -1360,7 +1360,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, sh->tunnel_header_2_3 = 1; #endif #ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO - if (hca_attr->flow_hit_aso && sh->registers.mtr_color_reg == REG_C_3) { + if (hca_attr->flow_hit_aso && sh->registers.aso_reg == REG_C_3) { sh->flow_hit_aso_en = 1; err = mlx5_flow_aso_age_mng_init(sh); if (err) { @@ -1374,7 +1374,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, defined (HAVE_MLX5_DR_ACTION_ASO_CT) /* HWS create CT ASO SQ based on HWS configure queue number. */ if (sh->config.dv_flow_en != 2 && - hca_attr->ct_offload && sh->registers.mtr_color_reg == REG_C_3) { + hca_attr->ct_offload && sh->registers.aso_reg == REG_C_3) { err = mlx5_flow_aso_ct_mng_init(sh); if (err) { err = -err; diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 01cb21fc93..99a2ad88ed 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1376,8 +1376,7 @@ struct mlx5_hws_cnt_svc_mng { #define MLX5_FLOW_HW_TAGS_MAX 8 struct mlx5_dev_registers { - enum modify_reg mlx5_flow_hw_aso_tag; - enum modify_reg mtr_color_reg; /* Meter color match REG_C. */ + enum modify_reg aso_reg; enum modify_reg hw_avl_tags[MLX5_FLOW_HW_TAGS_MAX]; }; diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 3ddc3ba772..ad9a2f2273 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -1364,23 +1364,23 @@ mlx5_flow_get_reg_id(struct rte_eth_dev *dev, * should use the meter color register for match. */ if (priv->mtr_reg_share) - return reg->mtr_color_reg; + return reg->aso_reg; else - return reg->mtr_color_reg != REG_C_2 ? REG_C_2 : + return reg->aso_reg != REG_C_2 ? REG_C_2 : REG_C_3; case MLX5_MTR_COLOR: case MLX5_ASO_FLOW_HIT: case MLX5_ASO_CONNTRACK: case MLX5_SAMPLE_ID: /* All features use the same REG_C. */ - MLX5_ASSERT(reg->mtr_color_reg != REG_NON); - return reg->mtr_color_reg; + MLX5_ASSERT(reg->aso_reg != REG_NON); + return reg->aso_reg; case MLX5_COPY_MARK: /* * Metadata COPY_MARK register using is in meter suffix sub * flow while with meter. It's safe to share the same register. */ - return reg->mtr_color_reg != REG_C_2 ? REG_C_2 : REG_C_3; + return reg->aso_reg != REG_C_2 ? REG_C_2 : REG_C_3; case MLX5_APP_TAG: /* * If meter is enable, it will engage the register for color @@ -1389,7 +1389,7 @@ mlx5_flow_get_reg_id(struct rte_eth_dev *dev, * match. * If meter is disable, free to use all available registers. */ - start_reg = reg->mtr_color_reg != REG_C_2 ? REG_C_2 : + start_reg = reg->aso_reg != REG_C_2 ? REG_C_2 : (priv->mtr_reg_share ? REG_C_3 : REG_C_4); skip_mtr_reg = !!(priv->mtr_en && start_reg == REG_C_2); if (id > (uint32_t)(REG_C_7 - start_reg)) @@ -1407,7 +1407,7 @@ mlx5_flow_get_reg_id(struct rte_eth_dev *dev, * color register. */ if (skip_mtr_reg && priv->sh->flow_mreg_c - [id + start_reg - REG_C_0] >= reg->mtr_color_reg) { + [id + start_reg - REG_C_0] >= reg->aso_reg) { if (id >= (uint32_t)(REG_C_7 - start_reg)) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, @@ -6480,7 +6480,7 @@ flow_sample_split_prep(struct rte_eth_dev *dev, * metadata regC is REG_NON, back to use application tag * index 0. */ - if (unlikely(priv->sh->registers.mtr_color_reg == REG_NON)) + if (unlikely(priv->sh->registers.aso_reg == REG_NON)) ret = mlx5_flow_get_reg_id(dev, MLX5_APP_TAG, 0, error); else ret = mlx5_flow_get_reg_id(dev, MLX5_SAMPLE_ID, 0, error); diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 011db1fb75..250d9eb1fc 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1663,7 +1663,6 @@ flow_hw_get_wire_port(struct ibv_context *ibctx) * Convert metadata or tag to the actual register. * META: Can only be used to match in the FDB in this stage, fixed C_1. * TAG: C_x expect meter color reg and the reserved ones. - * TODO: Per port / device, FDB or NIC for Meta matching. */ static __rte_always_inline int flow_hw_get_reg_id(struct rte_eth_dev *dev, @@ -1692,7 +1691,7 @@ flow_hw_get_reg_id(struct rte_eth_dev *dev, return REG_A; case RTE_FLOW_ITEM_TYPE_CONNTRACK: case RTE_FLOW_ITEM_TYPE_METER_COLOR: - return reg->mlx5_flow_hw_aso_tag; + return reg->aso_reg; case RTE_FLOW_ITEM_TYPE_TAG: if (id == MLX5_LINEAR_HASH_TAG_INDEX) return REG_C_3; diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 024023abb5..9268a07c84 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -2026,7 +2026,8 @@ mlx5_flow_field_id_to_modify_info if (priv->sh->config.dv_flow_en == 2) reg = flow_hw_get_reg_id - (dev, RTE_FLOW_ITEM_TYPE_METER_COLOR, 0); + (dev, + RTE_FLOW_ITEM_TYPE_METER_COLOR, 0); else reg = mlx5_flow_get_reg_id(dev, MLX5_MTR_COLOR, 0, error); @@ -3923,7 +3924,7 @@ flow_dv_validate_item_meter_color(struct rte_eth_dev *dev, }; int ret; - if (priv->sh->registers.mtr_color_reg == REG_NON) + if (priv->sh->registers.aso_reg == REG_NON) return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ITEM, item, "meter color register" @@ -8375,7 +8376,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, return ret; if ((action_flags & MLX5_FLOW_ACTION_SET_TAG) && tag_id == 0 && - priv->sh->registers.mtr_color_reg == REG_NON) + priv->sh->registers.aso_reg == REG_NON) return rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, NULL, "sample after tag action causes metadata tag index 0 corruption"); diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 22cf412035..c48c2eec39 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -8469,7 +8469,7 @@ void flow_hw_init_tags_set(struct rte_eth_dev *dev) * The CAPA is global for common device but only used in net. * It is shared per eswitch domain. */ - unset |= 1 << mlx5_regc_index(reg->mtr_color_reg); + unset |= 1 << mlx5_regc_index(reg->aso_reg); unset |= 1 << mlx5_regc_index(REG_C_6); if (sh->config.dv_esw_en) unset |= 1 << mlx5_regc_index(REG_C_0); @@ -8480,7 +8480,6 @@ void flow_hw_init_tags_set(struct rte_eth_dev *dev) if (!!((1 << i) & masks)) reg->hw_avl_tags[j++] = mlx5_regc_value(i); } - reg->mlx5_flow_hw_aso_tag = reg->mtr_color_reg; } static int diff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c index eb88dfe39c..7cbf772ea4 100644 --- a/drivers/net/mlx5/mlx5_flow_meter.c +++ b/drivers/net/mlx5/mlx5_flow_meter.c @@ -67,7 +67,7 @@ mlx5_flow_meter_action_create(struct mlx5_priv *priv, val = (ebs_eir >> ASO_DSEG_EBS_MAN_OFFSET) & ASO_DSEG_MAN_MASK; MLX5_SET(flow_meter_parameters, fmp, ebs_mantissa, val); mtr_init.next_table = def_policy->sub_policy.tbl_rsc->obj; - mtr_init.reg_c_index = priv->sh->registers.mtr_color_reg - REG_C_0; + mtr_init.reg_c_index = priv->sh->registers.aso_reg - REG_C_0; mtr_init.flow_meter_parameter = fmp; mtr_init.flow_meter_parameter_sz = MLX5_ST_SZ_BYTES(flow_meter_parameters); @@ -1618,7 +1618,7 @@ mlx5_flow_meter_action_modify(struct mlx5_priv *priv, return ret; } else { /* Fill command parameters. */ - mod_attr.reg_c_index = sh->registers.mtr_color_reg - REG_C_0; + mod_attr.reg_c_index = sh->registers.aso_reg - REG_C_0; mod_attr.flow_meter_parameter = in; mod_attr.flow_meter_parameter_sz = MLX5_ST_SZ_BYTES(flow_meter_parameters); -- 2.39.2