From patchwork Thu Apr 18 20:02:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 139507 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 9C76543EA8; Thu, 18 Apr 2024 22:04:02 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4F02240A7F; Thu, 18 Apr 2024 22:03:00 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id E9CD3402D0 for ; Thu, 18 Apr 2024 22:02:45 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 8C59120FDA96; Thu, 18 Apr 2024 13:02:44 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 8C59120FDA96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1713470564; bh=HeHi4aMWlrcn3F3Uhgdo2uidpSzU8SkkucPl4eL1FZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YPUhBeclPgKJUqHzcm5H7lGF5Go1x7NntH/+w47HZKa6kES2gH69+bUZcRT2oD307 tysG+bvyeEuWz0If9/v4fEA8LyY6jgYWQtXzJGrn4VRy9aDRJUdOBvRo+viIqAwibe Lh8yd5rvLLWBkBYJ6RqEbkl4h4Lh6mRJU+yQq7Vo= 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 v2 11/19] app/testpmd: remove use of VLAs for Windows built code Date: Thu, 18 Apr 2024 13:02:34 -0700 Message-Id: <1713470562-17415-12-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1713470562-17415-1-git-send-email-roretzla@linux.microsoft.com> References: <1713397319-26135-1-git-send-email-roretzla@linux.microsoft.com> <1713470562-17415-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 --- app/test-pmd/cmdline.c | 2 +- app/test-pmd/cmdline_flow.c | 9 ++++----- app/test-pmd/config.c | 16 +++++++++------- app/test-pmd/shared_rxq_fwd.c | 2 +- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index b7759e3..dee8f5f 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -12902,7 +12902,7 @@ struct cmd_set_port_ptypes_result { return; } - uint32_t ptypes[ret]; + uint32_t *ptypes = alloca(sizeof(uint32_t) * ret); ret = rte_eth_dev_set_ptypes(port_id, ptype_mask, ptypes, ret); if (ret < 0) { diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 60ee933..a4fe8d9 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -11546,8 +11546,7 @@ struct indlst_conf { char tmp[16]; /* Ought to be enough. */ int ret; unsigned int hexlen = len; - unsigned int length = 256; - uint8_t hex_tmp[length]; + uint8_t hex_tmp[256]; /* Arguments are expected. */ if (!arg_data) @@ -11574,7 +11573,7 @@ struct indlst_conf { str += 2; hexlen -= 2; } - if (hexlen > length) + if (hexlen > RTE_DIM(hex_tmp)) goto error; ret = parse_hex_string(str, hex_tmp, &hexlen); if (ret < 0) @@ -11707,7 +11706,7 @@ struct indlst_conf { void *buf, unsigned int size) { const struct arg *arg = pop_args(ctx); - char str2[len + 1]; + char *str2 = alloca(len + 1); struct in_addr tmp; int ret; @@ -11753,7 +11752,7 @@ struct indlst_conf { void *buf, unsigned int size) { const struct arg *arg = pop_args(ctx); - char str2[len + 1]; + char *str2 = alloca(len + 1); struct in6_addr tmp; int ret; diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index ba1007a..4dce6fa 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1760,7 +1760,8 @@ void port_flow_tunnel_create(portid_t port_id, const struct tunnel_ops *ops) { struct rte_port *port; struct rte_flow_error error; - const struct rte_flow_queue_attr *attr_list[nb_queue]; + const struct rte_flow_queue_attr **attr_list = + alloca(sizeof(struct rte_flow_queue_attr *) * nb_queue); int std_queue; if (port_id_is_invalid(port_id, ENABLED_WARN) || @@ -2577,10 +2578,10 @@ struct rte_flow_meter_policy * int ret; uint32_t i; struct rte_flow_error error; - struct rte_flow_pattern_template - *flow_pattern_templates[nb_pattern_templates]; - struct rte_flow_actions_template - *flow_actions_templates[nb_actions_templates]; + struct rte_flow_pattern_template **flow_pattern_templates = + alloca(sizeof(struct rte_flow_pattern_template *) * nb_pattern_templates); + struct rte_flow_actions_template **flow_actions_templates = + alloca(sizeof(struct rte_flow_actions_template *) * nb_actions_templates); if (port_id_is_invalid(port_id, ENABLED_WARN) || port_id == (portid_t)RTE_PORT_ALL) @@ -5460,7 +5461,7 @@ struct igb_ring_desc_16_bytes { char *end = NULL; int min, max; int value, i; - unsigned int marked[maxsize]; + unsigned int *marked = alloca(sizeof(unsigned int) * maxsize); if (list == NULL || values == NULL) return 0; @@ -7201,7 +7202,8 @@ static const char *get_ptype_str(uint32_t ptype) if (eth_dev_info_get_print_err(port_id, &dev_info)) return; - struct rte_ether_addr addr[dev_info.max_mac_addrs]; + struct rte_ether_addr *addr = + alloca(sizeof(struct rte_ether_addr) * dev_info.max_mac_addrs); rc = rte_eth_macaddrs_get(port_id, addr, dev_info.max_mac_addrs); if (rc < 0) return; diff --git a/app/test-pmd/shared_rxq_fwd.c b/app/test-pmd/shared_rxq_fwd.c index 623d62d..5d4ffff 100644 --- a/app/test-pmd/shared_rxq_fwd.c +++ b/app/test-pmd/shared_rxq_fwd.c @@ -92,7 +92,7 @@ static bool shared_rxq_fwd(struct fwd_stream *fs) { - struct rte_mbuf *pkts_burst[nb_pkt_per_burst]; + struct rte_mbuf **pkts_burst = alloca(sizeof(struct rte_mbuf *) * nb_pkt_per_burst); uint16_t nb_rx; nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst);