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 5F213A0577; Wed, 15 Apr 2020 08:40:33 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C75C71D16C; Wed, 15 Apr 2020 08:40:11 +0200 (CEST) Received: from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130]) by dpdk.org (Postfix) with ESMTP id 4A0A01D15F for ; Wed, 15 Apr 2020 08:40:09 +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:50 +0800 Message-Id: <1586932797-99533-4-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 03/10] net/mlx5: reorganize the mlx5 flow handle struct 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, the mlx5_flow_handle struct is not fully aligned and has some bits wasted. The members can be optimized and reorganized to save memory. 1. As metadata and meter is sharing the same flow match id, now the flow id is limited to 24 bits due to the 8 MSBs are used as for the meter color. Align the flow id to other bit members to 32 bits to save the mlx5 flow handle memory. 2. The vlan_vf in struct mlx5_flow_handle_dv was already moved to struct mlx5_flow_handle. Remove the legacy vlan_vf in struct mlx5_flow_handle_dv. 3. Reorganize the vlan_vf in mlx5_flow_handle with member SILIST_ENTRY next to make it align with 8 bytes. 4. Reorganize the header modify in mlx5_flow_handle_dv to ILIST_ENTRY next to make it align to with bytes. 5. Introduce __rte_pack attribute to make the struct tightly organized. It will totally save 20 bytes memory for mlx5_flow_handle struct. Signed-off-by: Suanming Mou --- drivers/net/mlx5/mlx5_flow.c | 8 ++++---- drivers/net/mlx5/mlx5_flow.h | 17 ++++++----------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index ffc2910..71c6bce 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -2323,8 +2323,8 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, SILIST_FOREACH(priv->sh->ipool[MLX5_IPOOL_MLX5_FLOW], flow->dev_handles, handle_idx, dev_handle, next) - if (dev_handle->qrss_id) - flow_qrss_free_id(dev, dev_handle->qrss_id); + if (dev_handle->flow_id) + flow_qrss_free_id(dev, dev_handle->flow_id); } static int @@ -3988,7 +3988,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, * reallocation becomes possible (for example, for * other flows in other threads). */ - dev_flow->handle->qrss_id = qrss_id; + dev_flow->handle->flow_id = qrss_id; ret = mlx5_flow_get_reg_id(dev, MLX5_COPY_MARK, 0, error); if (ret < 0) @@ -4101,7 +4101,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, ret = -rte_errno; goto exit; } - dev_flow->handle->mtr_flow_id = mtr_tag_id; + dev_flow->handle->flow_id = mtr_tag_id; /* Setting the sfx group atrr. */ sfx_attr.group = sfx_attr.transfer ? (MLX5_FLOW_TABLE_LEVEL_SUFFIX - 1) : diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 0f5c5d4..db42189 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -494,30 +494,25 @@ struct mlx5_flow_rss { struct mlx5_flow_handle_dv { /* Flow DV api: */ struct mlx5_flow_dv_matcher *matcher; /**< Cache to matcher. */ - uint32_t encap_decap; - /**< Index to encap/decap resource in cache. */ struct mlx5_flow_dv_modify_hdr_resource *modify_hdr; /**< Pointer to modify header resource in cache. */ - struct mlx5_vf_vlan vf_vlan; - /**< Structure for VF VLAN workaround. */ + uint32_t encap_decap; + /**< Index to encap/decap resource in cache. */ uint32_t push_vlan_res; /**< Index to push VLAN action resource in cache. */ uint32_t tag_resource; /**< Index to the tag action. */ -}; +} __rte_packed; /** Device flow handle structure: used both for creating & destroying. */ struct mlx5_flow_handle { SILIST_ENTRY(uint32_t)next; + struct mlx5_vf_vlan vf_vlan; /**< Structure for VF VLAN workaround. */ /**< Index to next device flow handle. */ uint64_t layers; /**< Bit-fields of present layers, see MLX5_FLOW_LAYER_*. */ void *ib_flow; /**< Verbs flow pointer. */ - struct mlx5_vf_vlan vf_vlan; /**< Structure for VF VLAN workaround. */ - union { - uint32_t qrss_id; /**< Uniqie Q/RSS suffix subflow tag. */ - uint32_t mtr_flow_id; /**< Unique meter match flow id. */ - }; + uint32_t flow_id:28; /**< Unique match flow id. */ uint32_t mark:1; /**< Metadate rxq mark flag. */ uint32_t fate_action:3; /**< Fate action type. */ union { @@ -529,7 +524,7 @@ struct mlx5_flow_handle { #ifdef HAVE_IBV_FLOW_DV_SUPPORT struct mlx5_flow_handle_dv dvh; #endif -}; +} __rte_packed; /* * Size for Verbs device flow handle structure only. Do not use the DV only -- 1.8.3.1