From patchwork Sun Feb 21 14:28:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 88065 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 4F6C4A034F; Sun, 21 Feb 2021 15:29:14 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 21B3F22A2D9; Sun, 21 Feb 2021 15:28:37 +0100 (CET) Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) by mails.dpdk.org (Postfix) with ESMTP id BF8B322A2C3 for ; Sun, 21 Feb 2021 15:28:33 +0100 (CET) Received: by mail-lj1-f175.google.com with SMTP id e8so10453169ljj.5 for ; Sun, 21 Feb 2021 06:28:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Hj6nlfyINy4JqhZBvmbQFP7COVG0nPkA5j9iJp4hv5M=; b=oFRccWRRM7Te0A8QdY/itQZCDHmm7yHBOIx28GD/hvwv73R5X/BqmlFt4jfyILU0Qt b4s6AzhNd6hvyDITGkw62E7YkPNLKXhBqF6Bf2SppBA6fezHuGbeMxjXyht0hPT65rfW hXMCHPOKUmI56K9DpI5v1FXs9P8Hfxi7oeOyiWarOHrwtm9s/A8RECtNkUv/ZeJO4R6J 8gFjUqDh7gqcaj3E7eXBwbzuVWskGFuQRV9hB7+gEk/9/QQM6bvgAsHX9VOdngKgdTEp zLAaglLC5SoY2oNu/18lUQ5iKHRrvDvfvL+euGwgkrslP5UOt+WMEb6knBYy/CCko9uZ 5sPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Hj6nlfyINy4JqhZBvmbQFP7COVG0nPkA5j9iJp4hv5M=; b=FHJZv8aKXz6jUgolPFFMpHljxIHprLvysCnN+HASIHFYTFriJXq74WgPrPklGLGTOj waVHxUyDTin++kHWJYLejfiAfSjJY2F/sPK9Gy0OBJN7k8tPcygiA7GHxlIb3HUmZUtY 03xNWmTawn4UDJeR6ranVBijT1XOQpiPqwaFqxNaOwxK9eliQwwKrD42R/lZ/SVhpiQI 7IOwaTN3GQc8Z+Tivse7zyrZUNqesnmNWOZO7O/5a6c/QJltrig6z4+KhgmJdsf8Yh7Z vZL56zb8MyNqZjRUvKe6V2nUEUjy2F12P9ygU8WSd+Ac05IYhZYJW4ZdwKrXjwIsjaLe 7tdg== X-Gm-Message-State: AOAM533Zj+Yzuy2hGomTkXKXRb1dUrTYY+6G5kchSo038aNdmH1/PUUK XTImfy6Ja7QvoIK3BfT3yY//Y/AI6if8sdXY X-Google-Smtp-Source: ABdhPJx4FkdHamyZzqvGBAzeKXDah7iIMJg3XsDmM+R31v/LE99oZGBCbCNyBNI+w6YGhMT6wZJgMw== X-Received: by 2002:a2e:9903:: with SMTP id v3mr9921198lji.179.1613917713066; Sun, 21 Feb 2021 06:28:33 -0800 (PST) Received: from localhost.localdomain (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id a30sm1569885lfo.56.2021.02.21.06.28.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Feb 2021 06:28:32 -0800 (PST) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Tal Shnaiderman , Dmitry Kozlyuk , Matan Azrad , Shahaf Shuler , Viacheslav Ovsiienko , Beilei Xing , Jeff Guo Date: Sun, 21 Feb 2021 17:28:18 +0300 Message-Id: <20210221142819.6769-7-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210221142819.6769-1-dmitry.kozliuk@gmail.com> References: <20210221012831.14643-1-dmitry.kozliuk@gmail.com> <20210221142819.6769-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v3 6/7] drivers: remove POSIX dependencies 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 Sender: "dev" Replace POSIX strncasecmp() with EAL rte_strncasecmp(). Replace POSIX strtok_r() with EAL rte_strtok(). Replace POSIX strdup() with EAL rte_strdup(). Signed-off-by: Dmitry Kozlyuk Acked-by: Khoa To --- i40e: checkpatches.sh complains about long lines (it's ~85). I doubt that mechanical fix would keep the code readable. It's on 5th level of indentation, so I'd extract a function, but would like to hear from maintainers first. drivers/bus/pci/private.h | 2 +- drivers/bus/vdev/vdev.c | 4 +- drivers/bus/vdev/vdev_params.c | 3 +- drivers/common/mlx5/mlx5_common_pci.c | 6 +-- drivers/common/mlx5/mlx5_common_pci.h | 1 + drivers/net/i40e/i40e_ethdev.c | 56 +++++++++++++-------------- drivers/net/mlx5/mlx5.c | 4 ++ 7 files changed, 41 insertions(+), 35 deletions(-) diff --git a/drivers/bus/pci/private.h b/drivers/bus/pci/private.h index f566943f5..5648916d1 100644 --- a/drivers/bus/pci/private.h +++ b/drivers/bus/pci/private.h @@ -92,7 +92,7 @@ struct mapped_pci_resource { TAILQ_ENTRY(mapped_pci_resource) next; struct rte_pci_addr pci_addr; - char path[PATH_MAX]; + char path[RTE_PATH_MAX]; int nb_maps; struct pci_map maps[PCI_MAX_RESOURCE]; struct pci_msix_table msix_table; diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c index 9a673347a..a490d26a2 100644 --- a/drivers/bus/vdev/vdev.c +++ b/drivers/bus/vdev/vdev.c @@ -245,9 +245,9 @@ alloc_devargs(const char *name, const char *args) devargs->bus = &rte_vdev_bus; if (args) - devargs->args = strdup(args); + devargs->args = rte_strdup(args); else - devargs->args = strdup(""); + devargs->args = rte_strdup(""); ret = strlcpy(devargs->name, name, sizeof(devargs->name)); if (ret < 0 || ret >= (int)sizeof(devargs->name)) { diff --git a/drivers/bus/vdev/vdev_params.c b/drivers/bus/vdev/vdev_params.c index 6f74704d1..64848f4c2 100644 --- a/drivers/bus/vdev/vdev_params.c +++ b/drivers/bus/vdev/vdev_params.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "vdev_logs.h" #include "vdev_private.h" @@ -31,7 +32,7 @@ vdev_dev_match(const struct rte_device *dev, char *name; /* cannot pass const dev->name to rte_kvargs_process() */ - name = strdup(dev->name); + name = rte_strdup(dev->name); if (name == NULL) return -1; ret = rte_kvargs_process(kvlist, diff --git a/drivers/common/mlx5/mlx5_common_pci.c b/drivers/common/mlx5/mlx5_common_pci.c index 2b657686d..0b2c50f46 100644 --- a/drivers/common/mlx5/mlx5_common_pci.c +++ b/drivers/common/mlx5/mlx5_common_pci.c @@ -82,13 +82,13 @@ bus_cmdline_options_handler(__rte_unused const char *key, char *refstr = NULL; *ret = 0; - nstr = strdup(class_names); + nstr = rte_strdup(class_names); if (!nstr) { *ret = -ENOMEM; return *ret; } nstr_org = nstr; - found = strtok_r(nstr, ":", &refstr); + found = rte_strtok(nstr, ":", &refstr); if (!found) goto err; do { @@ -102,7 +102,7 @@ bus_cmdline_options_handler(__rte_unused const char *key, goto err; } *ret |= class_val; - found = strtok_r(NULL, ":", &refstr); + found = rte_strtok(NULL, ":", &refstr); } while (found); err: free(nstr_org); diff --git a/drivers/common/mlx5/mlx5_common_pci.h b/drivers/common/mlx5/mlx5_common_pci.h index de89bb98b..729d0f4cc 100644 --- a/drivers/common/mlx5/mlx5_common_pci.h +++ b/drivers/common/mlx5/mlx5_common_pci.h @@ -45,6 +45,7 @@ extern "C" { #include #include +#include #include diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index d7cd04989..5b806d201 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -12036,110 +12036,110 @@ i40e_update_customized_ptype(struct rte_eth_dev *dev, uint8_t *pkg, memset(name, 0, sizeof(name)); strcpy(name, proto[n].name); PMD_DRV_LOG(INFO, "name = %s\n", name); - if (!strncasecmp(name, "PPPOE", 5)) + if (!rte_strncasecmp(name, "PPPOE", 5)) ptype_mapping[i].sw_ptype |= RTE_PTYPE_L2_ETHER_PPPOE; - else if (!strncasecmp(name, "IPV4FRAG", 8) && + else if (!rte_strncasecmp(name, "IPV4FRAG", 8) && !in_tunnel) { ptype_mapping[i].sw_ptype |= RTE_PTYPE_L3_IPV4_EXT_UNKNOWN; ptype_mapping[i].sw_ptype |= RTE_PTYPE_L4_FRAG; - } else if (!strncasecmp(name, "IPV4FRAG", 8) && + } else if (!rte_strncasecmp(name, "IPV4FRAG", 8) && in_tunnel) { ptype_mapping[i].sw_ptype |= RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN; ptype_mapping[i].sw_ptype |= RTE_PTYPE_INNER_L4_FRAG; - } else if (!strncasecmp(name, "OIPV4", 5)) { + } else if (!rte_strncasecmp(name, "OIPV4", 5)) { ptype_mapping[i].sw_ptype |= RTE_PTYPE_L3_IPV4_EXT_UNKNOWN; in_tunnel = true; - } else if (!strncasecmp(name, "IPV4", 4) && + } else if (!rte_strncasecmp(name, "IPV4", 4) && !in_tunnel) ptype_mapping[i].sw_ptype |= RTE_PTYPE_L3_IPV4_EXT_UNKNOWN; - else if (!strncasecmp(name, "IPV4", 4) && + else if (!rte_strncasecmp(name, "IPV4", 4) && in_tunnel) ptype_mapping[i].sw_ptype |= RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN; - else if (!strncasecmp(name, "IPV6FRAG", 8) && + else if (!rte_strncasecmp(name, "IPV6FRAG", 8) && !in_tunnel) { ptype_mapping[i].sw_ptype |= RTE_PTYPE_L3_IPV6_EXT_UNKNOWN; ptype_mapping[i].sw_ptype |= RTE_PTYPE_L4_FRAG; - } else if (!strncasecmp(name, "IPV6FRAG", 8) && + } else if (!rte_strncasecmp(name, "IPV6FRAG", 8) && in_tunnel) { ptype_mapping[i].sw_ptype |= RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN; ptype_mapping[i].sw_ptype |= RTE_PTYPE_INNER_L4_FRAG; - } else if (!strncasecmp(name, "OIPV6", 5)) { + } else if (!rte_strncasecmp(name, "OIPV6", 5)) { ptype_mapping[i].sw_ptype |= RTE_PTYPE_L3_IPV6_EXT_UNKNOWN; in_tunnel = true; - } else if (!strncasecmp(name, "IPV6", 4) && + } else if (!rte_strncasecmp(name, "IPV6", 4) && !in_tunnel) ptype_mapping[i].sw_ptype |= RTE_PTYPE_L3_IPV6_EXT_UNKNOWN; - else if (!strncasecmp(name, "IPV6", 4) && + else if (!rte_strncasecmp(name, "IPV6", 4) && in_tunnel) ptype_mapping[i].sw_ptype |= RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN; - else if (!strncasecmp(name, "UDP", 3) && + else if (!rte_strncasecmp(name, "UDP", 3) && !in_tunnel) ptype_mapping[i].sw_ptype |= RTE_PTYPE_L4_UDP; - else if (!strncasecmp(name, "UDP", 3) && + else if (!rte_strncasecmp(name, "UDP", 3) && in_tunnel) ptype_mapping[i].sw_ptype |= RTE_PTYPE_INNER_L4_UDP; - else if (!strncasecmp(name, "TCP", 3) && + else if (!rte_strncasecmp(name, "TCP", 3) && !in_tunnel) ptype_mapping[i].sw_ptype |= RTE_PTYPE_L4_TCP; - else if (!strncasecmp(name, "TCP", 3) && + else if (!rte_strncasecmp(name, "TCP", 3) && in_tunnel) ptype_mapping[i].sw_ptype |= RTE_PTYPE_INNER_L4_TCP; - else if (!strncasecmp(name, "SCTP", 4) && + else if (!rte_strncasecmp(name, "SCTP", 4) && !in_tunnel) ptype_mapping[i].sw_ptype |= RTE_PTYPE_L4_SCTP; - else if (!strncasecmp(name, "SCTP", 4) && + else if (!rte_strncasecmp(name, "SCTP", 4) && in_tunnel) ptype_mapping[i].sw_ptype |= RTE_PTYPE_INNER_L4_SCTP; - else if ((!strncasecmp(name, "ICMP", 4) || - !strncasecmp(name, "ICMPV6", 6)) && + else if ((!rte_strncasecmp(name, "ICMP", 4) || + !rte_strncasecmp(name, "ICMPV6", 6)) && !in_tunnel) ptype_mapping[i].sw_ptype |= RTE_PTYPE_L4_ICMP; - else if ((!strncasecmp(name, "ICMP", 4) || - !strncasecmp(name, "ICMPV6", 6)) && + else if ((!rte_strncasecmp(name, "ICMP", 4) || + !rte_strncasecmp(name, "ICMPV6", 6)) && in_tunnel) ptype_mapping[i].sw_ptype |= RTE_PTYPE_INNER_L4_ICMP; - else if (!strncasecmp(name, "GTPC", 4)) { + else if (!rte_strncasecmp(name, "GTPC", 4)) { ptype_mapping[i].sw_ptype |= RTE_PTYPE_TUNNEL_GTPC; in_tunnel = true; - } else if (!strncasecmp(name, "GTPU", 4)) { + } else if (!rte_strncasecmp(name, "GTPU", 4)) { ptype_mapping[i].sw_ptype |= RTE_PTYPE_TUNNEL_GTPU; in_tunnel = true; - } else if (!strncasecmp(name, "ESP", 3)) { + } else if (!rte_strncasecmp(name, "ESP", 3)) { ptype_mapping[i].sw_ptype |= RTE_PTYPE_TUNNEL_ESP; in_tunnel = true; - } else if (!strncasecmp(name, "GRENAT", 6)) { + } else if (!rte_strncasecmp(name, "GRENAT", 6)) { ptype_mapping[i].sw_ptype |= RTE_PTYPE_TUNNEL_GRENAT; in_tunnel = true; - } else if (!strncasecmp(name, "L2TPV2CTL", 9) || - !strncasecmp(name, "L2TPV2", 6) || - !strncasecmp(name, "L2TPV3", 6)) { + } else if (!rte_strncasecmp(name, "L2TPV2CTL", 9) || + !rte_strncasecmp(name, "L2TPV2", 6) || + !rte_strncasecmp(name, "L2TPV3", 6)) { ptype_mapping[i].sw_ptype |= RTE_PTYPE_TUNNEL_L2TP; in_tunnel = true; diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index aae2ef9af..22fbcef7e 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -41,6 +41,10 @@ #include "mlx5_flow_os.h" #include "rte_pmd_mlx5.h" +#ifdef RTE_EXEC_ENV_WINDOWS +#define close _close +#endif + /* Device parameter to enable RX completion queue compression. */ #define MLX5_RXQ_CQE_COMP_EN "rxq_cqe_comp_en"