DPDK patches and discussions
 help / color / mirror / Atom feed
From: Suanming Mou <suanmingm@mellanox.com>
To: Matan Azrad <matan@mellanox.com>,
	Shahaf Shuler <shahafs@mellanox.com>,
	Viacheslav Ovsiienko <viacheslavo@mellanox.com>
Cc: wentaoc@mellanox.com, rasland@mellanox.com, dev@dpdk.org
Subject: [dpdk-dev] [PATCH 10/10] net/mlx5: reorganize rte flow structure
Date: Wed, 15 Apr 2020 14:39:57 +0800	[thread overview]
Message-ID: <1586932797-99533-11-git-send-email-suanmingm@mellanox.com> (raw)
In-Reply-To: <1586932797-99533-1-git-send-email-suanmingm@mellanox.com>

Currently, the rte flow structure is not fully aligned and has some
bits wasted. The members can be optimized and reorganized to save
memory.

1. The drv_type uses only limited bits, change the type to 2 bits what
it needs.

2. Align the hairpin_flow_id, drv_type, fdir, copy_applied to 32 bits.
As hairpin never uses the full 32 bits.

3. The RSS queue number type is 16 bits, combine it with the 16 bits
meter id has a better organize for the struct.

4. __rte_packed helps tight up the structure memory layout.

The optimization totally helps save 20 bytes for the structure.

Signed-off-by: Suanming Mou <suanmingm@mellanox.com>
---
 drivers/net/mlx5/mlx5.c      |  3 ++-
 drivers/net/mlx5/mlx5_flow.h | 19 +++++++++++--------
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 767fd9c..8f4843e 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -764,7 +764,8 @@ struct mlx5_flow_id_pool *
 			goto error;
 		}
 	}
-	sh->flow_id_pool = mlx5_flow_id_pool_alloc(UINT32_MAX);
+	sh->flow_id_pool = mlx5_flow_id_pool_alloc
+					((1 << HAIRPIN_FLOW_ID_BITS) - 1);
 	if (!sh->flow_id_pool) {
 		DRV_LOG(ERR, "can't create flow id pool");
 		err = ENOMEM;
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 911007b..0d32896 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -760,22 +760,25 @@ struct mlx5_fdir_flow {
 	struct rte_flow *flow; /* Pointer to flow. */
 };
 
+#define HAIRPIN_FLOW_ID_BITS 28
+
 /* Flow structure. */
 struct rte_flow {
 	TAILQ_ENTRY(rte_flow) next; /**< Pointer to the next flow structure. */
-	enum mlx5_flow_drv_type drv_type; /**< Driver type. */
-	struct mlx5_flow_rss_queue rss; /**< RSS queue context. */
-	uint32_t counter; /**< Holds flow counter. */
-	uint32_t mreg_copy;
-	/**< Index to metadata register copy table resource. */
-	uint16_t meter; /**< Holds flow meter id. */
 	uint32_t dev_handles;
 	/**< Device flow handles that are part of the flow. */
+	uint32_t drv_type:2; /**< Driver type. */
 	uint32_t fdir:1; /**< Identifier of associated FDIR if any. */
-	uint32_t hairpin_flow_id; /**< The flow id used for hairpin. */
+	uint32_t hairpin_flow_id:HAIRPIN_FLOW_ID_BITS;
+	/**< The flow id used for hairpin. */
 	uint32_t copy_applied:1; /**< The MARK copy Flow os applied. */
+	uint32_t mreg_copy;
+	/**< Index to metadata register copy table resource. */
+	uint32_t counter; /**< Holds flow counter. */
+	uint16_t meter; /**< Holds flow meter id. */
+	struct mlx5_flow_rss_queue rss; /**< RSS queue context. */
 	uint32_t idx; /**< Index to the rte flow allocated from indexed pool. */
-};
+} __rte_packed;
 
 typedef int (*mlx5_flow_validate_t)(struct rte_eth_dev *dev,
 				    const struct rte_flow_attr *attr,
-- 
1.8.3.1


      parent reply	other threads:[~2020-04-15  6:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-15  6:39 [dpdk-dev] [PATCH 00/10] net/mlx5: optimize " Suanming Mou
2020-04-15  6:39 ` [dpdk-dev] [PATCH 01/10] net/mlx5: reorganize fate actions as union Suanming Mou
2020-04-15  6:39 ` [dpdk-dev] [PATCH 02/10] net/mlx5: optimize action flags in flow handle Suanming Mou
2020-04-15  6:39 ` [dpdk-dev] [PATCH 03/10] net/mlx5: reorganize the mlx5 flow handle struct Suanming Mou
2020-04-15  6:39 ` [dpdk-dev] [PATCH 04/10] net/mlx5: optimize mlx5 flow RSS struct Suanming Mou
2020-04-15  6:39 ` [dpdk-dev] [PATCH 05/10] net/mlx5: allocate rte flow from indexed pool Suanming Mou
2020-04-15  6:39 ` [dpdk-dev] [PATCH 06/10] net/mlx5: optimize flow meter handle type Suanming Mou
2020-04-15  6:39 ` [dpdk-dev] [PATCH 07/10] net/mlx5: allocate meter from indexed pool Suanming Mou
2020-04-15  6:39 ` [dpdk-dev] [PATCH 08/10] net/mlx5: allocate metadata object " Suanming Mou
2020-04-15  6:39 ` [dpdk-dev] [PATCH 09/10] net/mlx5: optimize flow director filter memory Suanming Mou
2020-04-15  6:39 ` Suanming Mou [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1586932797-99533-11-git-send-email-suanmingm@mellanox.com \
    --to=suanmingm@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=matan@mellanox.com \
    --cc=rasland@mellanox.com \
    --cc=shahafs@mellanox.com \
    --cc=viacheslavo@mellanox.com \
    --cc=wentaoc@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).