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 99C08A0471 for ; Tue, 16 Jul 2019 16:35:03 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 50CA62BF5; Tue, 16 Jul 2019 16:35:03 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 6A8482BF5 for ; Tue, 16 Jul 2019 16:35:01 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE2 (envelope-from matan@mellanox.com) with ESMTPS (AES256-SHA encrypted); 16 Jul 2019 17:34:59 +0300 Received: from pegasus07.mtr.labs.mlnx (pegasus07.mtr.labs.mlnx [10.210.16.112]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x6GEYxoN013824; Tue, 16 Jul 2019 17:34:59 +0300 From: Matan Azrad To: Shahaf Shuler , Yongseok Koh , Viacheslav Ovsiienko Cc: dev@dpdk.org Date: Tue, 16 Jul 2019 14:34:54 +0000 Message-Id: <1563287696-10509-3-git-send-email-matan@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1563287696-10509-1-git-send-email-matan@mellanox.com> References: <1562594861-27123-1-git-send-email-matan@mellanox.com> <1563287696-10509-1-git-send-email-matan@mellanox.com> Subject: [dpdk-dev] [PATCH 2/4] net/mlx5: resize a full counter container 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" 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 Acked-by: Shahaf Shuler --- 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 da16e48..693848e 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -2147,7 +2147,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]) /** @@ -2263,7 +2263,7 @@ struct field_modify_info modify_tcp[] = { } /** - * Prepare a counter container. + * Resize a counter container. * * @param[in] dev * Pointer to the Ethernet device structure. @@ -2274,26 +2274,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; } @@ -2361,14 +2369,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); @@ -2378,7 +2382,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