From 9dbaf7eef6e17113f5c681c3c4fcee6bcda4b5f0 Mon Sep 17 00:00:00 2001 From: Suanming Mou Date: Mon, 13 Apr 2020 21:29:12 +0800 Subject: [PATCH] net/mlx5: fix meter suffix table leak Currently, the meter suffix table is created and saved in the mlx5 shared struct. It causes the suffix table will never be released even without any meter rules. Move the suffix table to meter domain struct to help the suffix table be released when all the meter rules are destroyed. Fixes: 46a5e6bc6a85 ("net/mlx5: prepare meter flow tables") Cc: stable@dpdk.org Signed-off-by: Suanming Mou Acked-by: Viacheslav Ovsiienko --- drivers/net/mlx5/mlx5.h | 6 ----- drivers/net/mlx5/mlx5_flow.h | 2 ++ drivers/net/mlx5/mlx5_flow_dv.c | 48 +++++++++++++++------------------ 3 files changed, 23 insertions(+), 33 deletions(-) diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 94178e7ae7..1850cf94ab 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -455,14 +455,8 @@ struct mlx5_ibv_shared { uint32_t dv_regc0_mask; /* available bits of metatada reg_c[0]. */ uint32_t dv_refcnt; /* DV/DR data reference counter. */ void *fdb_domain; /* FDB Direct Rules name space handle. */ - struct mlx5_flow_tbl_resource *fdb_mtr_sfx_tbl; - /* FDB meter suffix rules table. */ void *rx_domain; /* RX Direct Rules name space handle. */ - struct mlx5_flow_tbl_resource *rx_mtr_sfx_tbl; - /* RX meter suffix rules table. */ void *tx_domain; /* TX Direct Rules name space handle. */ - struct mlx5_flow_tbl_resource *tx_mtr_sfx_tbl; - /* TX meter suffix rules table. */ struct mlx5_hlist *flow_tbls; /* Direct Rules tables for FDB, NIC TX+RX */ void *esw_drop_action; /* Pointer to DR E-Switch drop action. */ diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index daa1f84145..df09d0bb6f 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -642,6 +642,8 @@ struct mlx5_flow_policer_stats { struct mlx5_meter_domain_info { struct mlx5_flow_tbl_resource *tbl; /**< Meter table. */ + struct mlx5_flow_tbl_resource *sfx_tbl; + /**< Meter suffix table. */ void *any_matcher; /**< Meter color not match default criteria. */ void *color_matcher; diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 18ea577f8c..0676b6f203 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -8516,6 +8516,9 @@ flow_dv_destroy_mtr_tbl(struct rte_eth_dev *dev, if (mtd->egress.tbl) claim_zero(flow_dv_tbl_resource_release(dev, mtd->egress.tbl)); + if (mtd->egress.sfx_tbl) + claim_zero(flow_dv_tbl_resource_release(dev, + mtd->egress.sfx_tbl)); if (mtd->ingress.color_matcher) claim_zero(mlx5_glue->dv_destroy_flow_matcher (mtd->ingress.color_matcher)); @@ -8525,6 +8528,9 @@ flow_dv_destroy_mtr_tbl(struct rte_eth_dev *dev, if (mtd->ingress.tbl) claim_zero(flow_dv_tbl_resource_release(dev, mtd->ingress.tbl)); + if (mtd->ingress.sfx_tbl) + claim_zero(flow_dv_tbl_resource_release(dev, + mtd->ingress.sfx_tbl)); if (mtd->transfer.color_matcher) claim_zero(mlx5_glue->dv_destroy_flow_matcher (mtd->transfer.color_matcher)); @@ -8534,6 +8540,9 @@ flow_dv_destroy_mtr_tbl(struct rte_eth_dev *dev, if (mtd->transfer.tbl) claim_zero(flow_dv_tbl_resource_release(dev, mtd->transfer.tbl)); + if (mtd->transfer.sfx_tbl) + claim_zero(flow_dv_tbl_resource_release(dev, + mtd->transfer.sfx_tbl)); if (mtd->drop_actn) claim_zero(mlx5_glue->destroy_flow_action(mtd->drop_actn)); rte_free(mtd); @@ -8581,31 +8590,16 @@ flow_dv_prepare_mtr_tables(struct rte_eth_dev *dev, .match_mask = (void *)&mask, }; void *actions[METER_ACTIONS]; - struct mlx5_flow_tbl_resource **sfx_tbl; struct mlx5_meter_domain_info *dtb; struct rte_flow_error error; int i = 0; - if (transfer) { - sfx_tbl = &sh->fdb_mtr_sfx_tbl; + if (transfer) dtb = &mtb->transfer; - } else if (egress) { - sfx_tbl = &sh->tx_mtr_sfx_tbl; + else if (egress) dtb = &mtb->egress; - } else { - sfx_tbl = &sh->rx_mtr_sfx_tbl; + else dtb = &mtb->ingress; - } - /* If the suffix table in missing, create it. */ - if (!(*sfx_tbl)) { - *sfx_tbl = flow_dv_tbl_resource_get(dev, - MLX5_FLOW_TABLE_LEVEL_SUFFIX, - egress, transfer, &error); - if (!(*sfx_tbl)) { - DRV_LOG(ERR, "Failed to create meter suffix table."); - return -1; - } - } /* Create the meter table with METER level. */ dtb->tbl = flow_dv_tbl_resource_get(dev, MLX5_FLOW_TABLE_LEVEL_METER, egress, transfer, &error); @@ -8613,6 +8607,14 @@ flow_dv_prepare_mtr_tables(struct rte_eth_dev *dev, DRV_LOG(ERR, "Failed to create meter policer table."); return -1; } + /* Create the meter suffix table with SUFFIX level. */ + dtb->sfx_tbl = flow_dv_tbl_resource_get(dev, + MLX5_FLOW_TABLE_LEVEL_SUFFIX, + egress, transfer, &error); + if (!dtb->sfx_tbl) { + DRV_LOG(ERR, "Failed to create meter suffix table."); + return -1; + } /* Create matchers, Any and Color. */ dv_attr.priority = 3; dv_attr.match_criteria_enable = 0; @@ -8786,8 +8788,6 @@ flow_dv_destroy_policer_rules(struct rte_eth_dev *dev __rte_unused, * Pointer to flow meter structure. * @param[in] mtb * Pointer to DV meter table set. - * @param[in] sfx_tb - * Pointer to suffix table. * @param[in] mtr_reg_c * Color match REG_C. * @@ -8797,7 +8797,6 @@ flow_dv_destroy_policer_rules(struct rte_eth_dev *dev __rte_unused, static int flow_dv_create_policer_forward_rule(struct mlx5_flow_meter *fm, struct mlx5_meter_domain_info *dtb, - struct mlx5_flow_tbl_resource *sfx_tb, uint8_t mtr_reg_c) { struct mlx5_flow_dv_match_params matcher = { @@ -8811,12 +8810,10 @@ flow_dv_create_policer_forward_rule(struct mlx5_flow_meter *fm, int i; /* Create jump action. */ - if (!sfx_tb) - return -1; if (!dtb->jump_actn) dtb->jump_actn = mlx5_glue->dr_create_flow_action_dest_flow_tbl - (sfx_tb->obj); + (dtb->sfx_tbl->obj); if (!dtb->jump_actn) { DRV_LOG(ERR, "Failed to create policer jump action."); goto error; @@ -8871,7 +8868,6 @@ flow_dv_create_policer_rules(struct rte_eth_dev *dev, if (attr->egress) { ret = flow_dv_create_policer_forward_rule(fm, &mtb->egress, - priv->sh->tx_mtr_sfx_tbl, priv->mtr_color_reg); if (ret) { DRV_LOG(ERR, "Failed to create egress policer."); @@ -8880,7 +8876,6 @@ flow_dv_create_policer_rules(struct rte_eth_dev *dev, } if (attr->ingress) { ret = flow_dv_create_policer_forward_rule(fm, &mtb->ingress, - priv->sh->rx_mtr_sfx_tbl, priv->mtr_color_reg); if (ret) { DRV_LOG(ERR, "Failed to create ingress policer."); @@ -8889,7 +8884,6 @@ flow_dv_create_policer_rules(struct rte_eth_dev *dev, } if (attr->transfer) { ret = flow_dv_create_policer_forward_rule(fm, &mtb->transfer, - priv->sh->fdb_mtr_sfx_tbl, priv->mtr_color_reg); if (ret) { DRV_LOG(ERR, "Failed to create transfer policer."); -- 2.20.1