From patchwork Mon May 6 18:18:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 139958 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3AA6043F5C; Mon, 6 May 2024 20:20:40 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 37B9740E54; Mon, 6 May 2024 20:19:21 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 6337540684 for ; Mon, 6 May 2024 20:18:55 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id BA23620B2C9C; Mon, 6 May 2024 11:18:53 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com BA23620B2C9C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1715019533; bh=k3CYQT0gKPaUKQb+synqrou+8ObN5NXsie4r2fIPSgo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RMcsWqrW6MCFhPZAEbiMhpflZmqwMgj8T75hWyWCMTMveWPLxEwRmeH0HiVt33bGO QwxPxTGfOH9vA9o8lwrC5sT36R0by5gZQoTYUhLQ1UXzvEFZNcYIAP2VUh97lRD3jO tgXGdKuFD3WDCKZnrFc6hQYVRSdUl4vQ+Zsi44Ac= From: Tyler Retzlaff To: dev@dpdk.org Cc: =?utf-8?q?Morten_Br=C3=B8rup?= , Akhil Goyal , Aman Singh , Anatoly Burakov , Andrew Rybchenko , Bruce Richardson , Chengwen Feng , Dariusz Sosnowski , Dmitry Kozlyuk , Fan Zhang , Ferruh Yigit , Harman Kalra , Harry van Haaren , Honnappa Nagarahalli , Jiayu Hu , Jingjing Wu , Kevin Laatz , Konstantin Ananyev , Matan Azrad , Ori Kam , Pallavi Kadam , Reshma Pattan , Sameh Gobriel , Suanming Mou , Thomas Monjalon , Tyler Retzlaff , Viacheslav Ovsiienko , Vladimir Medvedkin , Volodymyr Fialko , Yipeng Wang Subject: [PATCH v3 17/19] common/mlx5: remove use of VLAs for Windows built code Date: Mon, 6 May 2024 11:18:49 -0700 Message-Id: <1715019531-22796-18-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1715019531-22796-1-git-send-email-roretzla@linux.microsoft.com> References: <1713397319-26135-1-git-send-email-roretzla@linux.microsoft.com> <1715019531-22796-1-git-send-email-roretzla@linux.microsoft.com> X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org MSVC does not support VLAs, replace VLAs with standard C arrays or alloca(). alloca() is available for all toolchain/platform combinations officially supported by DPDK. Signed-off-by: Tyler Retzlaff --- drivers/common/mlx5/mlx5_common.h | 4 ++-- drivers/common/mlx5/mlx5_devx_cmds.c | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h index 9c80277..76eba1c 100644 --- a/drivers/common/mlx5/mlx5_common.h +++ b/drivers/common/mlx5/mlx5_common.h @@ -112,10 +112,10 @@ /* Allocate a buffer on the stack and fill it with a printf format string. */ #define MKSTR(name, ...) \ int mkstr_size_##name = snprintf(NULL, 0, "" __VA_ARGS__); \ - char name[mkstr_size_##name + 1]; \ + char *name = alloca(mkstr_size_##name + 1); \ \ memset(name, 0, mkstr_size_##name + 1); \ - snprintf(name, sizeof(name), "" __VA_ARGS__) + snprintf(name, mkstr_size_##name + 1, "" __VA_ARGS__) enum { PCI_VENDOR_ID_MELLANOX = 0x15b3, diff --git a/drivers/common/mlx5/mlx5_devx_cmds.c b/drivers/common/mlx5/mlx5_devx_cmds.c index 9b7abab..bac272f 100644 --- a/drivers/common/mlx5/mlx5_devx_cmds.c +++ b/drivers/common/mlx5/mlx5_devx_cmds.c @@ -284,10 +284,9 @@ struct mlx5_devx_obj * void *cmd_comp, uint64_t async_id) { - int out_len = MLX5_ST_SZ_BYTES(query_flow_counter_out) + - MLX5_ST_SZ_BYTES(traffic_counter); - uint32_t out[out_len]; + uint32_t out[MLX5_ST_SZ_BYTES(query_flow_counter_out) + MLX5_ST_SZ_BYTES(traffic_counter)]; uint32_t in[MLX5_ST_SZ_DW(query_flow_counter_in)] = {0}; + const int out_len = RTE_DIM(out); void *stats; int rc; @@ -346,7 +345,7 @@ struct mlx5_devx_obj * int klm_num = attr->klm_num; int in_size_dw = MLX5_ST_SZ_DW(create_mkey_in) + (klm_num ? RTE_ALIGN(klm_num, 4) : 0) * MLX5_ST_SZ_DW(klm); - uint32_t in[in_size_dw]; + uint32_t *in = alloca(sizeof(uint32_t) * in_size_dw); uint32_t out[MLX5_ST_SZ_DW(create_mkey_out)] = {0}; void *mkc; struct mlx5_devx_obj *mkey = mlx5_malloc(MLX5_MEM_ZERO, sizeof(*mkey),