From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4E1C4A00C5; Sun, 26 Apr 2020 04:51:38 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1F43A1C0AF; Sun, 26 Apr 2020 04:51:37 +0200 (CEST) Received: from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130]) by dpdk.org (Postfix) with ESMTP id 751D61C08E for ; Sun, 26 Apr 2020 04:51:35 +0200 (CEST) From: Suanming Mou To: Matan Azrad , Shahaf Shuler , Viacheslav Ovsiienko Cc: dev@dpdk.org, rasland@mellanox.com Date: Sun, 26 Apr 2020 10:51:25 +0800 Message-Id: <1587869486-60185-1-git-send-email-suanmingm@mellanox.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH] net/mlx5: save meter index instead of meter id X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Currently, while creating the flow with meter, meter id is saved to the rte flow. While destroying the flow, the meter object will be found by the meter id, so the meter object will be released accordingly. But as the meter id is configured by user, while the meter id is set to 0, it doesn't make any sense to flow destroy since 0 means flow doesn't have meter. The meter object with id 0 will be leaked. As meter object is allocated from indexed memory, and the index starts from 1, save the internal generated index instead of user defined meter id will never meet the issue as above. This patch saves meter index instead of meter id in rte flow. Signed-off-by: Suanming Mou --- drivers/net/mlx5/mlx5_flow_dv.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 6263ecc..2fdd403 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -7867,11 +7867,12 @@ struct field_modify_info modify_tcp[] = { NULL, "meter not found " "or invalid parameters"); - flow->meter = fm->meter_id; + flow->meter = fm->idx; } /* Set the meter action. */ if (!fm) { - fm = mlx5_flow_meter_find(priv, flow->meter); + fm = mlx5_ipool_get(priv->sh->ipool + [MLX5_IPOOL_MTR], flow->meter); if (!fm) return rte_flow_error_set(error, rte_errno, @@ -8591,7 +8592,8 @@ struct field_modify_info modify_tcp[] = { if (flow->meter) { struct mlx5_flow_meter *fm; - fm = mlx5_flow_meter_find(priv, flow->meter); + fm = mlx5_ipool_get(priv->sh->ipool[MLX5_IPOOL_MTR], + flow->meter); if (fm) mlx5_flow_meter_detach(fm); flow->meter = 0; -- 1.8.3.1