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 574ADA0577; Wed, 15 Apr 2020 08:41:05 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 234411D416; Wed, 15 Apr 2020 08:40:18 +0200 (CEST) Received: from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130]) by dpdk.org (Postfix) with ESMTP id 64C881D16B for ; Wed, 15 Apr 2020 08:40:15 +0200 (CEST) From: Suanming Mou To: Matan Azrad , Shahaf Shuler , Viacheslav Ovsiienko Cc: wentaoc@mellanox.com, rasland@mellanox.com, dev@dpdk.org Date: Wed, 15 Apr 2020 14:39:53 +0800 Message-Id: <1586932797-99533-7-git-send-email-suanmingm@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1586932797-99533-1-git-send-email-suanmingm@mellanox.com> References: <1586932797-99533-1-git-send-email-suanmingm@mellanox.com> Subject: [dpdk-dev] [PATCH 06/10] net/mlx5: optimize flow meter handle type 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" While flow attaches the meter handle, the meter id can be the unique tag for the flow to get the meter handle. It's no need for flow to save the pointer of the meter handle. Save the meter id instead of pointer helps reduce the size for rte flow structure. As the supported maximum meter rule is 4K, uint16_t type is selected for the meter id. Signed-off-by: Suanming Mou --- drivers/net/mlx5/mlx5_flow.h | 2 +- drivers/net/mlx5/mlx5_flow_dv.c | 29 ++++++++++++++++++++++------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index e220647..983ccc1 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -759,7 +759,7 @@ struct rte_flow { uint32_t counter; /**< Holds flow counter. */ struct mlx5_flow_mreg_copy_resource *mreg_copy; /**< pointer to metadata register copy table resource. */ - struct mlx5_flow_meter *meter; /**< Holds flow meter. */ + uint16_t meter; /**< Holds flow meter id. */ uint32_t dev_handles; /**< Device flow handles that are part of the flow. */ struct mlx5_fdir *fdir; /**< Pointer to associated FDIR if any. */ diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 26733e0..28010ca 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -7396,6 +7396,7 @@ struct field_modify_info modify_tcp[] = { struct mlx5_flow_dv_port_id_action_resource port_id_resource; int action_type = actions->type; const struct rte_flow_action *found_action = NULL; + struct mlx5_flow_meter *fm = NULL; switch (action_type) { case RTE_FLOW_ACTION_TYPE_VOID: @@ -7772,20 +7773,30 @@ struct field_modify_info modify_tcp[] = { case RTE_FLOW_ACTION_TYPE_METER: mtr = actions->conf; if (!flow->meter) { - flow->meter = mlx5_flow_meter_attach(priv, - mtr->mtr_id, attr, - error); - if (!flow->meter) + fm = mlx5_flow_meter_attach(priv, mtr->mtr_id, + attr, error); + if (!fm) return rte_flow_error_set(error, rte_errno, RTE_FLOW_ERROR_TYPE_ACTION, NULL, "meter not found " "or invalid parameters"); + flow->meter = fm->meter_id; } /* Set the meter action. */ + if (!fm) { + fm = mlx5_flow_meter_find(priv, flow->meter); + if (!fm) + return rte_flow_error_set(error, + rte_errno, + RTE_FLOW_ERROR_TYPE_ACTION, + NULL, + "meter not found " + "or invalid parameters"); + } dev_flow->dv.actions[actions_n++] = - flow->meter->mfts->meter_action; + fm->mfts->meter_action; action_flags |= MLX5_FLOW_ACTION_METER; break; case RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP: @@ -8472,8 +8483,12 @@ struct field_modify_info modify_tcp[] = { flow->counter = 0; } if (flow->meter) { - mlx5_flow_meter_detach(flow->meter); - flow->meter = NULL; + struct mlx5_flow_meter *fm; + + fm = mlx5_flow_meter_find(priv, flow->meter); + if (fm) + mlx5_flow_meter_detach(fm); + flow->meter = 0; } while (flow->dev_handles) { uint32_t tmp_idx = flow->dev_handles; -- 1.8.3.1