DPDK patches and discussions
 help / color / mirror / Atom feed
From: Matan Azrad <matan@mellanox.com>
To: Shahaf Shuler <shahafs@mellanox.com>,
	Yongseok Koh <yskoh@mellanox.com>,
	Viacheslav Ovsiienko <viacheslavo@mellanox.com>
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 2/4] net/mlx5: resize a full counter container
Date: Mon,  8 Jul 2019 14:07:39 +0000	[thread overview]
Message-ID: <1562594861-27123-3-git-send-email-matan@mellanox.com> (raw)
In-Reply-To: <1562594861-27123-1-git-send-email-matan@mellanox.com>

When the counter countainer has no more space to store more counter
pools try to resize the container to allow more pools to be created.

So, the only limitation for the maximum counter number is the memory.

Signed-off-by: Matan Azrad <matan@mellanox.com>
Acked-by: Shahaf Shuler <shahafs@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow_dv.c | 43 +++++++++++++++++++++++------------------
 1 file changed, 24 insertions(+), 19 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 9654c3b..3b7a43e 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -2114,7 +2114,7 @@ struct field_modify_info modify_tcp[] = {
 	return 0;
 }
 
-#define MLX5_CNT_CONTAINER_SIZE 64
+#define MLX5_CNT_CONTAINER_RESIZE 64
 #define MLX5_CNT_CONTAINER(priv, batch) (&(priv)->sh->cmng.ccont[batch])
 
 /**
@@ -2230,7 +2230,7 @@ struct field_modify_info modify_tcp[] = {
 }
 
 /**
- * Prepare a counter container.
+ * Resize a counter container.
  *
  * @param[in] dev
  *   Pointer to the Ethernet device structure.
@@ -2241,26 +2241,34 @@ struct field_modify_info modify_tcp[] = {
  *   The container pointer on success, otherwise NULL and rte_errno is set.
  */
 static struct mlx5_pools_container *
-flow_dv_container_prepare(struct rte_eth_dev *dev, uint32_t batch)
+flow_dv_container_resize(struct rte_eth_dev *dev, uint32_t batch)
 {
 	struct mlx5_priv *priv = dev->data->dev_private;
 	struct mlx5_pools_container *cont = MLX5_CNT_CONTAINER(priv, batch);
 	struct mlx5_counter_stats_mem_mng *mem_mng;
-	uint32_t size = MLX5_CNT_CONTAINER_SIZE;
-	uint32_t mem_size = sizeof(struct mlx5_flow_counter_pool *) * size;
-
-	cont->pools = rte_calloc(__func__, 1, mem_size, 0);
-	if (!cont->pools) {
+	uint32_t resize = cont->n + MLX5_CNT_CONTAINER_RESIZE;
+	uint32_t mem_size = sizeof(struct mlx5_flow_counter_pool *) * resize;
+	struct mlx5_flow_counter_pool **new_pools = rte_calloc(__func__, 1,
+							       mem_size, 0);
+	if (!new_pools) {
 		rte_errno = ENOMEM;
 		return NULL;
 	}
-	mem_mng = flow_dv_create_counter_stat_mem_mng(dev, size);
+	mem_mng = flow_dv_create_counter_stat_mem_mng(dev,
+						    MLX5_CNT_CONTAINER_RESIZE);
 	if (!mem_mng) {
-		rte_free(cont->pools);
+		rte_free(new_pools);
 		return NULL;
 	}
-	cont->n = size;
-	TAILQ_INIT(&cont->pool_list);
+	if (cont->n) {
+		memcpy(new_pools, cont->pools,
+		       cont->n * sizeof(struct mlx5_flow_counter_pool *));
+		rte_free(cont->pools);
+	} else {
+		TAILQ_INIT(&cont->pool_list);
+	}
+	cont->pools = new_pools;
+	cont->n = resize;
 	cont->init_mem_mng = mem_mng;
 	return cont;
 }
@@ -2328,14 +2336,10 @@ struct field_modify_info modify_tcp[] = {
 	struct mlx5_pools_container *cont = MLX5_CNT_CONTAINER(priv, batch);
 	uint32_t size;
 
-	if (!cont->n) {
-		cont = flow_dv_container_prepare(dev, batch);
+	if (cont->n == cont->n_valid) {
+		cont = flow_dv_container_resize(dev, batch);
 		if (!cont)
 			return NULL;
-	} else if (cont->n == cont->n_valid) {
-		DRV_LOG(ERR, "No space in container to allocate a new pool\n");
-		rte_errno = ENOSPC;
-		return NULL;
 	}
 	size = sizeof(*pool) + MLX5_COUNTERS_PER_POOL *
 			sizeof(struct mlx5_flow_counter);
@@ -2345,7 +2349,8 @@ struct field_modify_info modify_tcp[] = {
 		return NULL;
 	}
 	pool->min_dcs = dcs;
-	pool->raw = cont->init_mem_mng->raws + cont->n_valid;
+	pool->raw = cont->init_mem_mng->raws + cont->n_valid  %
+			MLX5_CNT_CONTAINER_RESIZE;
 	TAILQ_INIT(&pool->counters);
 	TAILQ_INSERT_TAIL(&cont->pool_list, pool, next);
 	cont->pools[cont->n_valid] = pool;
-- 
1.8.3.1


  parent reply	other threads:[~2019-07-08 14:08 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-08 14:07 [dpdk-dev] [PATCH 0/4] net/mlx5: accelerate DV flow counters mangement Matan Azrad
2019-07-08 14:07 ` [dpdk-dev] [PATCH 1/4] net/mlx5: accelerate DV flow counter transactions Matan Azrad
2019-07-08 14:07 ` Matan Azrad [this message]
2019-07-08 14:07 ` [dpdk-dev] [PATCH 3/4] net/mlx5: accelerate DV flow counter query Matan Azrad
2019-07-08 14:07 ` [dpdk-dev] [PATCH 4/4] net/mlx5: allow basic counter management fallback Matan Azrad
2019-07-16 14:34 ` [dpdk-dev] [PATCH 0/4] net/mlx5: accelerate DV flow counters mangement Matan Azrad
2019-07-16 14:34   ` [dpdk-dev] [PATCH 1/4] net/mlx5: accelerate DV flow counter transactions Matan Azrad
2019-07-16 14:34   ` [dpdk-dev] [PATCH 2/4] net/mlx5: resize a full counter container Matan Azrad
2019-07-16 14:34   ` [dpdk-dev] [PATCH 3/4] net/mlx5: accelerate DV flow counter query Matan Azrad
2019-07-16 14:34   ` [dpdk-dev] [PATCH 4/4] net/mlx5: allow basic counter management fallback Matan Azrad
2019-07-17  6:50   ` [dpdk-dev] [PATCH 0/4] net/mlx5: accelerate DV flow counters mangement 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=1562594861-27123-3-git-send-email-matan@mellanox.com \
    --to=matan@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=shahafs@mellanox.com \
    --cc=viacheslavo@mellanox.com \
    --cc=yskoh@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).