From: Suanming Mou <suanmingm@mellanox.com>
To: viacheslavo@mellanox.com, matan@mellanox.com
Cc: orika@mellanox.com, wentaoc@mellanox.com, rasland@mellanox.com,
dev@dpdk.org
Subject: [dpdk-dev] [PATCH v2 05/10] net/mlx5: allocate meter from indexed pool
Date: Thu, 16 Apr 2020 16:34:26 +0800 [thread overview]
Message-ID: <1587026071-422636-6-git-send-email-suanmingm@mellanox.com> (raw)
In-Reply-To: <1587026071-422636-1-git-send-email-suanmingm@mellanox.com>
This patch allocate the meter object memory from indexed memory pool
which will help to save the MALLOC_ELEM_OVERHEAD memory taken by
rte_malloc().
Signed-off-by: Suanming Mou <suanmingm@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
---
drivers/net/mlx5/mlx5.c | 11 +++++++++++
drivers/net/mlx5/mlx5.h | 1 +
drivers/net/mlx5/mlx5_flow.h | 1 +
drivers/net/mlx5/mlx5_flow_meter.c | 11 ++++++-----
4 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index 331318a..ac9391b 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -257,6 +257,17 @@ struct mlx5_dev_spawn_data {
},
#endif
{
+ .size = sizeof(struct mlx5_flow_meter),
+ .trunk_size = 64,
+ .grow_trunk = 3,
+ .grow_shift = 2,
+ .need_lock = 0,
+ .release_mem_en = 1,
+ .malloc = rte_malloc_socket,
+ .free = rte_free,
+ .type = "mlx5_meter_ipool",
+ },
+ {
.size = (sizeof(struct mlx5_hrxq) + MLX5_RSS_HASH_KEY_LEN),
.trunk_size = 64,
.grow_trunk = 3,
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 2c4e823..009c1da 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -52,6 +52,7 @@ enum mlx5_ipool_index {
MLX5_IPOOL_PORT_ID, /* Pool for port id resource. */
MLX5_IPOOL_JUMP, /* Pool for jump resource. */
#endif
+ MLX5_IPOOL_MTR, /* Pool for meter resource. */
MLX5_IPOOL_HRXQ, /* Pool for hrxq resource. */
MLX5_IPOOL_MLX5_FLOW, /* Pool for mlx5 flow handle. */
MLX5_IPOOL_MAX,
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index bf0345a..b508299 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -703,6 +703,7 @@ struct mlx5_meter_domains_infos {
struct mlx5_flow_meter {
TAILQ_ENTRY(mlx5_flow_meter) next;
/**< Pointer to the next flow meter structure. */
+ uint32_t idx; /* Index to meter object. */
uint32_t meter_id;
/**< Meter id. */
struct rte_mtr_params params;
diff --git a/drivers/net/mlx5/mlx5_flow_meter.c b/drivers/net/mlx5/mlx5_flow_meter.c
index aa0fd7a..b5fbf5d 100644
--- a/drivers/net/mlx5/mlx5_flow_meter.c
+++ b/drivers/net/mlx5/mlx5_flow_meter.c
@@ -631,6 +631,7 @@
};
int ret;
unsigned int i;
+ uint32_t idx = 0;
if (!priv->mtr_en)
return -rte_mtr_error_set(error, ENOTSUP,
@@ -647,12 +648,12 @@
RTE_MTR_ERROR_TYPE_METER_PROFILE_ID,
NULL, "Meter profile id not valid.");
/* Allocate the flow meter memory. */
- fm = rte_calloc(__func__, 1,
- sizeof(struct mlx5_flow_meter), RTE_CACHE_LINE_SIZE);
+ fm = mlx5_ipool_zmalloc(priv->sh->ipool[MLX5_IPOOL_MTR], &idx);
if (fm == NULL)
return -rte_mtr_error_set(error, ENOMEM,
RTE_MTR_ERROR_TYPE_UNSPECIFIED, NULL,
"Memory alloc failed for meter.");
+ fm->idx = idx;
/* Fill the flow meter parameters. */
fm->meter_id = meter_id;
fm->profile = fmp;
@@ -683,7 +684,7 @@
for (i = 0; i < RTE_DIM(fm->policer_stats.cnt); i++)
if (fm->policer_stats.cnt[i])
mlx5_counter_free(dev, fm->policer_stats.cnt[i]);
- rte_free(fm);
+ mlx5_ipool_free(priv->sh->ipool[MLX5_IPOOL_MTR], idx);
return -rte_mtr_error_set(error, -ret,
RTE_MTR_ERROR_TYPE_UNSPECIFIED,
NULL, "Failed to create devx meter.");
@@ -746,7 +747,7 @@
/* Free meter flow table */
mlx5_flow_destroy_policer_rules(dev, fm, &attr);
mlx5_flow_destroy_mtr_tbls(dev, fm->mfts);
- rte_free(fm);
+ mlx5_ipool_free(priv->sh->ipool[MLX5_IPOOL_MTR], fm->idx);
return 0;
}
@@ -1274,7 +1275,7 @@ struct mlx5_flow_meter *
/* Free meter flow table. */
mlx5_flow_destroy_policer_rules(dev, fm, &attr);
mlx5_flow_destroy_mtr_tbls(dev, fm->mfts);
- rte_free(fm);
+ mlx5_ipool_free(priv->sh->ipool[MLX5_IPOOL_MTR], fm->idx);
}
TAILQ_FOREACH_SAFE(fmp, fmps, next, tmp) {
/* Check unused. */
--
1.8.3.1
next prev parent reply other threads:[~2020-04-16 8:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <https://patches.dpdk.org/cover/68470/>
2020-04-16 8:34 ` [dpdk-dev] [PATCH v2 00/10] net/mlx5: optimize flow structure Suanming Mou
2020-04-16 8:34 ` [dpdk-dev] [PATCH v2 01/10] net/mlx5: reorganize fate actions as union Suanming Mou
2020-04-16 8:34 ` [dpdk-dev] [PATCH v2 02/10] net/mlx5: optimize action flags in flow handle Suanming Mou
2020-04-16 8:34 ` [dpdk-dev] [PATCH v2 03/10] net/mlx5: reorganize the mlx5 flow handle struct Suanming Mou
2020-04-16 8:34 ` [dpdk-dev] [PATCH v2 04/10] net/mlx5: optimize flow meter handle type Suanming Mou
2020-04-16 8:34 ` Suanming Mou [this message]
2020-04-16 8:34 ` [dpdk-dev] [PATCH v2 06/10] net/mlx5: convert mark copy resource to indexed Suanming Mou
2020-04-16 8:34 ` [dpdk-dev] [PATCH v2 07/10] net/mlx5: optimize flow director filter memory Suanming Mou
2020-04-16 8:34 ` [dpdk-dev] [PATCH v2 08/10] net/mlx5: optimize mlx5 flow RSS struct Suanming Mou
2020-04-16 8:34 ` [dpdk-dev] [PATCH v2 09/10] net/mlx5: allocate rte flow from indexed pool Suanming Mou
2020-04-16 8:34 ` [dpdk-dev] [PATCH v2 10/10] net/mlx5: reorganize rte flow structure Suanming Mou
2020-04-16 17:08 ` [dpdk-dev] [PATCH v2 00/10] net/mlx5: optimize " Raslan Darawsheh
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=1587026071-422636-6-git-send-email-suanmingm@mellanox.com \
--to=suanmingm@mellanox.com \
--cc=dev@dpdk.org \
--cc=matan@mellanox.com \
--cc=orika@mellanox.com \
--cc=rasland@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).