For ASO max allocations in non-template mode, Read FW capabilities instead of using consts.
Signed-off-by: Maayan Kashani <mkash...@nvidia.com> Acked-by: Dariusz Sosnowski <dsosnow...@nvidia.com> --- drivers/net/mlx5/mlx5.h | 17 ++++++++++++----- drivers/net/mlx5/mlx5_flow_hw.c | 13 +++++++++---- drivers/net/mlx5/mlx5_flow_meter.c | 25 +++++++++++++++++++++---- 3 files changed, 42 insertions(+), 13 deletions(-) diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 5789cc6ef17..159ea10018e 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -812,12 +812,18 @@ struct mlx5_dev_shared_port { /* Only yellow color valid. */ #define MLX5_MTR_POLICY_MODE_OY 3 +/* Max number of meters. */ +#define MLX5_MTR_MAX(priv) (mlx5_flow_mtr_max_get(priv)) /* Max number of meters allocated in non template mode. */ -#define MLX5_MTR_NT_MAX (1 << 23) -/* Max number of connection tracking allocated in non template mode */ -#define MLX5_CT_NT_MAX (1 << 23) -/* Max number of counters allocated in non template mode */ -#define MLX5_CNT_MAX (1 << 23) +#define MLX5_MTR_NT_MAX(priv) (MLX5_MTR_MAX(priv) >> 1) +/* Max number of connection tracking. */ +#define MLX5_CT_MAX(priv) (1 << (priv)->sh->cdev->config.hca_attr.log_max_conn_track_offload) +/* Max number of connection tracking allocated in non template mode. */ +#define MLX5_CT_NT_MAX(priv) (MLX5_CT_MAX(priv) >> 1) +/* Max number of counters. */ +#define MLX5_CNT_MAX(priv) ((priv)->sh->hws_max_nb_counters) +/* Max number of counters allocated in non template mode. */ +#define MLX5_CNT_NT_MAX(priv) (MLX5_CNT_MAX(priv) >> 1) enum mlx5_meter_domain { MLX5_MTR_DOMAIN_INGRESS, @@ -2457,6 +2463,7 @@ mlx5_flow_meter_hierarchy_get_final_policy(struct rte_eth_dev *dev, int mlx5_flow_meter_flush(struct rte_eth_dev *dev, struct rte_mtr_error *error); void mlx5_flow_meter_rxq_flush(struct rte_eth_dev *dev); +uint32_t mlx5_flow_mtr_max_get(struct mlx5_priv *priv); /* mlx5_os.c */ diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index f326ca0a21c..b4b0de417a8 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -13114,6 +13114,7 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev, bool actions_end = false; struct mlx5_priv *priv = dev->data->dev_private; int ret; + uint obj_num; for (; !actions_end; actions++) { switch ((int)actions->type) { @@ -13122,7 +13123,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev, if (!priv->hws_age_req) { /* If no counters were previously allocated. */ if (!priv->hws_cpool) { - ret = mlx5_hws_cnt_pool_create(dev, MLX5_CNT_MAX, + obj_num = MLX5_CNT_NT_MAX(priv); + ret = mlx5_hws_cnt_pool_create(dev, obj_num, priv->nb_queue, NULL); if (ret) goto err; @@ -13140,7 +13142,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev, case RTE_FLOW_ACTION_TYPE_COUNT: /* If no counters were previously allocated. */ if (!priv->hws_cpool) { - ret = mlx5_hws_cnt_pool_create(dev, MLX5_CNT_MAX, + obj_num = MLX5_CNT_NT_MAX(priv); + ret = mlx5_hws_cnt_pool_create(dev, obj_num, priv->nb_queue, NULL); if (ret) goto err; @@ -13149,7 +13152,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev, case RTE_FLOW_ACTION_TYPE_CONNTRACK: /* If no CT were previously allocated. */ if (!priv->hws_ctpool) { - ret = mlx5_flow_ct_init(dev, MLX5_CT_NT_MAX, priv->nb_queue); + obj_num = MLX5_CT_NT_MAX(priv); + ret = mlx5_flow_ct_init(dev, obj_num, priv->nb_queue); if (ret) goto err; } @@ -13157,7 +13161,8 @@ static int flow_hw_ensure_action_pools_allocated(struct rte_eth_dev *dev, case RTE_FLOW_ACTION_TYPE_METER_MARK: /* If no meters were previously allocated. */ if (!priv->hws_mpool) { - ret = mlx5_flow_meter_init(dev, MLX5_MTR_NT_MAX, 0, 0, + obj_num = MLX5_MTR_NT_MAX(priv); + ret = mlx5_flow_meter_init(dev, obj_num, 0, 0, priv->nb_queue); if (ret) goto err; diff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c index da3289b2189..19d86070707 100644 --- a/drivers/net/mlx5/mlx5_flow_meter.c +++ b/drivers/net/mlx5/mlx5_flow_meter.c @@ -704,6 +704,26 @@ mlx5_flow_meter_param_fill(struct mlx5_flow_meter_profile *fmp, return 0; } +/** + * Callback to get MTR maximum objects number. + * + * @param[in] priv + * Pointer to Ethernet device. + * + * @return + * Max number of meters. + */ +uint32_t +mlx5_flow_mtr_max_get(struct mlx5_priv *priv) +{ + struct mlx5_hca_qos_attr *qattr = &priv->sh->cdev->config.hca_attr.qos; + + /* Max number of meters. */ + return ((priv->sh->meter_aso_en) ? + 1 << (qattr->log_max_num_meter_aso + 1) : + qattr->log_max_flow_meter); +} + /** * Callback to get MTR capabilities. * @@ -730,14 +750,11 @@ mlx5_flow_mtr_cap_get(struct rte_eth_dev *dev, RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL, "Meter is not supported"); memset(cap, 0, sizeof(*cap)); + cap->n_max = mlx5_flow_mtr_max_get(priv); if (priv->sh->meter_aso_en) { - /* 2 meters per one ASO cache line. */ - cap->n_max = 1 << (qattr->log_max_num_meter_aso + 1); cap->srtcm_rfc2697_packet_mode_supported = 1; cap->trtcm_rfc2698_packet_mode_supported = 1; cap->trtcm_rfc4115_packet_mode_supported = 1; - } else { - cap->n_max = 1 << qattr->log_max_flow_meter; } cap->srtcm_rfc2697_byte_mode_supported = 1; cap->trtcm_rfc2698_byte_mode_supported = 1; -- 2.21.0