From patchwork Wed Apr 14 22:06:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 91476 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 47E8DA0A02; Thu, 15 Apr 2021 00:07:07 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 12B0C161D70; Thu, 15 Apr 2021 00:07:06 +0200 (CEST) Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) by mails.dpdk.org (Postfix) with ESMTP id 8850E40685 for ; Thu, 15 Apr 2021 00:07:01 +0200 (CEST) Received: by mail-lf1-f48.google.com with SMTP id x19so5342138lfa.2 for ; Wed, 14 Apr 2021 15:07:01 -0700 (PDT) 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=cQFDOb309YnT7nxvUJfm9vl/Al/wDVZLeqExIlgjCXY=; b=K0BmtpXuq+/sSFbCYrObrCPKTlb3RlJrKOa5tZUjo4U9pQ3mXFvN5I0Xu06rLzMHck o5PqFEeKJ2kLEv+LYVi2xSSuK4aqdL1PcaDQxxjG7rNBYQZkVoZLBnkoNaOzUPb8oMXO Rfsgn2v7e+Ypq1r45r8uiWvvlOO9585UbungEDNdbuctPww33J1Ff5TTkDufiSl1vaN8 bAuniKlVZpXu+1mi7vrMm2FtWhwC98sGjAE9ftGtU4CgYxpIx8VOZIKiKfV6jFvsfSV3 r3RgPxdq/5dS3n/kguOCnQ0HaxuOe/xBpkSHT4CG20XFjyImA/wHMaM8AShK+gPcP/JT xv0A== 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=cQFDOb309YnT7nxvUJfm9vl/Al/wDVZLeqExIlgjCXY=; b=pR1OvAf2y1foAomollD2mtccPMCDN/FhoSQscKRHDxpdtf+MiYEZf+gTcytHppR7GI qviKBaK+Cj2JXSqhOX4i/XsbpXTvPyCZIAKVRa6DJCGqfxzELVGdD9RxRB0oJUZMo3Q6 1Ysnd2b4XTkBZutN1JsZv5moWnbX2Vyq9r72GSyomDgXr+pUDwgM/6zzZT69Rh1JYQBy 9D/UDfQtBh3gJMPjHFMNhLXILr4/WCRNrLaFDDL+RLxy2ci1+HIMKKzlh74bSyIngavt INTLfmgoyklCVmipLom81upggvIwMBoliestKv2zHrHtEZWkZjmYP14wHRKwxIruC612 djWA== X-Gm-Message-State: AOAM531zflPx/jWX/U2wRQ0RchMi9obDbss03MRN2X7JpOFf3SlJ6WGk txmKMSWue6n7i2szLnqJMc2p/ZQNvXOwFHOr X-Google-Smtp-Source: ABdhPJyo/2d3I5U+Va6pZZxB3c2Mk6rTT9p0Ey5Td4tyo2NhIBdb2mGaYet9JArg/vJPp1UunZtzGw== X-Received: by 2002:a05:6512:ba6:: with SMTP id b38mr235128lfv.128.1618438020766; Wed, 14 Apr 2021 15:07:00 -0700 (PDT) Received: from localhost.localdomain (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id m28sm271489lfo.278.2021.04.14.15.06.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Apr 2021 15:06:59 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Kozlyuk , Khoa To , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam Date: Thu, 15 Apr 2021 01:06:48 +0300 Message-Id: <20210414220651.28691-2-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.29.3 In-Reply-To: <20210414220651.28691-1-dmitry.kozliuk@gmail.com> References: <20210410224732.20234-1-dmitry.kozliuk@gmail.com> <20210414220651.28691-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v10 1/4] eal/windows: hide asprintf() shim 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" Make asprintf(3) implementation for Windows private to EAL, so that it's hidden from external consumers. It is not exposed to internal consumers either, because they don't need asprintf() and also because callers from other modules would have no reliable way to free allocated memory. Signed-off-by: Dmitry Kozlyuk Acked-by: Khoa To --- lib/librte_eal/common/eal_private.h | 11 +++++++++ lib/librte_eal/windows/eal.c | 30 +++++++++++++++++++++++++ lib/librte_eal/windows/include/rte_os.h | 30 ------------------------- 3 files changed, 41 insertions(+), 30 deletions(-) diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h index e3512111d9..64cf4e81c8 100644 --- a/lib/librte_eal/common/eal_private.h +++ b/lib/librte_eal/common/eal_private.h @@ -716,4 +716,15 @@ void __rte_thread_init(unsigned int lcore_id, rte_cpuset_t *cpuset); */ void __rte_thread_uninit(void); +/** + * asprintf(3) replacement for Windows. + */ +#ifdef RTE_EXEC_ENV_WINDOWS +__rte_format_printf(2, 3) +int eal_asprintf(char **buffer, const char *format, ...); + +#define asprintf(buffer, format, ...) \ + eal_asprintf(buffer, format, ##__VA_ARGS__) +#endif + #endif /* _EAL_PRIVATE_H_ */ diff --git a/lib/librte_eal/windows/eal.c b/lib/librte_eal/windows/eal.c index 41be20d89f..28c787c0b0 100644 --- a/lib/librte_eal/windows/eal.c +++ b/lib/librte_eal/windows/eal.c @@ -2,6 +2,8 @@ * Copyright(c) 2019 Intel Corporation */ +#include + #include #include #include @@ -416,6 +418,34 @@ rte_eal_init(int argc, char **argv) return fctret; } +/* Don't use MinGW asprintf() to have identical code with all toolchains. */ +int +eal_asprintf(char **buffer, const char *format, ...) +{ + int size, ret; + va_list arg; + + va_start(arg, format); + size = vsnprintf(NULL, 0, format, arg); + va_end(arg); + if (size < 0) + return -1; + size++; + + *buffer = malloc(size); + if (*buffer == NULL) + return -1; + + va_start(arg, format); + ret = vsnprintf(*buffer, size, format, arg); + va_end(arg); + if (ret != size - 1) { + free(*buffer); + return -1; + } + return ret; +} + int rte_vfio_container_dma_map(__rte_unused int container_fd, __rte_unused uint64_t vaddr, diff --git a/lib/librte_eal/windows/include/rte_os.h b/lib/librte_eal/windows/include/rte_os.h index f0512f20a6..1afe49f35e 100644 --- a/lib/librte_eal/windows/include/rte_os.h +++ b/lib/librte_eal/windows/include/rte_os.h @@ -10,7 +10,6 @@ * which is not supported natively or named differently in Windows. */ -#include #include #include #include @@ -71,34 +70,6 @@ extern "C" { typedef long long ssize_t; #ifndef RTE_TOOLCHAIN_GCC - -static inline int -asprintf(char **buffer, const char *format, ...) -{ - int size, ret; - va_list arg; - - va_start(arg, format); - size = vsnprintf(NULL, 0, format, arg); - va_end(arg); - if (size < 0) - return -1; - size++; - - *buffer = (char *)malloc(size); - if (*buffer == NULL) - return -1; - - va_start(arg, format); - ret = vsnprintf(*buffer, size, format, arg); - va_end(arg); - if (ret != size - 1) { - free(*buffer); - return -1; - } - return ret; -} - static inline const char * eal_strerror(int code) { @@ -111,7 +82,6 @@ eal_strerror(int code) #ifndef strerror #define strerror eal_strerror #endif - #endif /* RTE_TOOLCHAIN_GCC */ #ifdef __cplusplus From patchwork Wed Apr 14 22:06:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 91477 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 3AD93A0A02; Thu, 15 Apr 2021 00:07:13 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4FE3D161D76; Thu, 15 Apr 2021 00:07:07 +0200 (CEST) Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) by mails.dpdk.org (Postfix) with ESMTP id 3339F161D6C for ; Thu, 15 Apr 2021 00:07:03 +0200 (CEST) Received: by mail-lf1-f42.google.com with SMTP id n138so35851075lfa.3 for ; Wed, 14 Apr 2021 15:07:03 -0700 (PDT) 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=3EFhcgW43bh1WtSGNJaUd4mPjxS6YGcUqSOwf2GvXls=; b=k1OhLDMu6g3YiFJuVIk3CsNiMy3diQDEN+MvdkUafOz31fIxdDqc076lfiltSoU7Xj R+lO5kXNdM7lLVVmoLXpzeSLR7z5maBSJJsM9fo0A0bnm3EgOLVjhHmJkVyPKxQ2q106 TViP8BCYghHBiZ6DNThpNpXvTlr/v6ott8qYwP5u4V5hILep7khg8hCVDss18zFZgrHF vTFNuTj5hSQqtUQZIknm4q/YmK0QposRNMJKI4QLp3MxIZ7TUTySLe1eiNFKBTSKrDln ZhPwFk3pFCUE/cr/cxiULxD5Ak/KAoPb3ox3p8OwQmEdIY02anR8oRjlLzkCh/7VpHKm +6TQ== 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=3EFhcgW43bh1WtSGNJaUd4mPjxS6YGcUqSOwf2GvXls=; b=KLpuLRY9EAyZwulT+7ZHKrL2mIxhY4gAE5U9oyhhOwOkOgbEdvCPmQPji9b1WPhNhy gN6P/gcljHnmr56Gj3O6hMFRKja1xKapH8PsWr6Gj/ZXN9yCReg8qKO+DKNnjLgI0dxt T2m3BbUdVEWq3Jp/MUclPda4+4eYeTtPDnQhIGqMw/GAOdJI9v/TShCbJ5gVlHGN3OhG t62vEVbsFP+QT/Me9SZS3rJtc6d1L+V6gBHe4V2Q5R6MGAiytl/WpZkGk5kZTEoqZun4 KKcgu8JKO1JDYw1ijZ1VxDdWHHUWqRDxwJU/rB9xSCn/0qTdKvfWiGTTlnOLrtZKkbvy hiPg== X-Gm-Message-State: AOAM531VrnwuFoDlWEhbMCa6OutzmUnc8HnGtuUH2K+L6nwM4uliTRmW txWWoxATZnU+rYyIuU7o7awfTG24qjGlB/xb X-Google-Smtp-Source: ABdhPJxbesU3OeyM3TI7YBN/rnVYbZFots9qdWUF6bNcmg/WrUqBb0OhnTMdi+A5IMmXy7ggQHHs4w== X-Received: by 2002:a05:6512:2341:: with SMTP id p1mr205712lfu.507.1618438022334; Wed, 14 Apr 2021 15:07:02 -0700 (PDT) Received: from localhost.localdomain (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id m28sm271489lfo.278.2021.04.14.15.07.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Apr 2021 15:07:01 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Kozlyuk , Thomas Monjalon , Matan Azrad , Shahaf Shuler , Viacheslav Ovsiienko , Beilei Xing , Jeff Guo , Harry van Haaren , Olivier Matz , Bruce Richardson , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam , Ferruh Yigit , Andrew Rybchenko Date: Thu, 15 Apr 2021 01:06:49 +0300 Message-Id: <20210414220651.28691-3-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.29.3 In-Reply-To: <20210414220651.28691-1-dmitry.kozliuk@gmail.com> References: <20210410224732.20234-1-dmitry.kozliuk@gmail.com> <20210414220651.28691-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v10 2/4] eal: make OS shims internal 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" DPDK code often relies on functions and macros that are not standard C, but are found on all platforms, even if by slightly different names. Windows provided macros or inline definitions for such symbols. However, when placed in public header, these symbols were unnecessarily exposed, breaking consumer POSIX compatibility code. Move most of the shims to , a header to be used instead of by internal code. Include it in libraries and PMDs that previously imported shims from . Directly replace shims that were only used inside EAL: * index -> strchr, rindex -> strrchr * sleep -> rte_delay_us_sleep * strerror_r -> strerror_s Remove sleep(3) shim in favour of rte_delay_us_sleep(). Signed-off-by: Dmitry Kozlyuk Acked-by: Thomas Monjalon --- drivers/bus/pci/private.h | 4 +- drivers/bus/vdev/vdev_private.h | 2 + drivers/common/mlx5/mlx5_common.h | 1 + drivers/net/i40e/i40e_ethdev.c | 1 + examples/service_cores/main.c | 4 +- lib/librte_cmdline/cmdline.c | 4 -- lib/librte_cmdline/cmdline_os_windows.c | 2 - lib/librte_cmdline/cmdline_private.h | 1 + lib/librte_cmdline/cmdline_socket.c | 4 -- lib/librte_eal/common/eal_common_config.c | 1 - lib/librte_eal/common/eal_common_errno.c | 4 ++ lib/librte_eal/common/eal_common_log.c | 1 + lib/librte_eal/common/eal_common_options.c | 2 +- lib/librte_eal/common/eal_common_timer.c | 4 +- lib/librte_eal/common/eal_internal_cfg.h | 1 + lib/librte_eal/freebsd/include/rte_os_shim.h | 14 +++++ lib/librte_eal/linux/include/rte_os_shim.h | 14 +++++ lib/librte_eal/windows/eal_hugepages.c | 1 - lib/librte_eal/windows/eal_lcore.c | 1 - lib/librte_eal/windows/eal_memalloc.c | 1 - lib/librte_eal/windows/include/rte_os.h | 62 ++------------------ lib/librte_eal/windows/include/rte_os_shim.h | 28 +++++++++ lib/librte_ethdev/ethdev_private.h | 2 + lib/librte_kvargs/rte_kvargs.c | 1 + 24 files changed, 82 insertions(+), 78 deletions(-) create mode 100644 lib/librte_eal/freebsd/include/rte_os_shim.h create mode 100644 lib/librte_eal/linux/include/rte_os_shim.h create mode 100644 lib/librte_eal/windows/include/rte_os_shim.h diff --git a/drivers/bus/pci/private.h b/drivers/bus/pci/private.h index f566943f5e..4cd9d14ec7 100644 --- a/drivers/bus/pci/private.h +++ b/drivers/bus/pci/private.h @@ -7,8 +7,10 @@ #include #include -#include + #include +#include +#include extern struct rte_pci_bus rte_pci_bus; diff --git a/drivers/bus/vdev/vdev_private.h b/drivers/bus/vdev/vdev_private.h index ba6dc48ff3..e683f5f133 100644 --- a/drivers/bus/vdev/vdev_private.h +++ b/drivers/bus/vdev/vdev_private.h @@ -5,6 +5,8 @@ #ifndef _VDEV_PRIVATE_H_ #define _VDEV_PRIVATE_H_ +#include + #ifdef __cplusplus extern "C" { #endif diff --git a/drivers/common/mlx5/mlx5_common.h b/drivers/common/mlx5/mlx5_common.h index 327374fdcf..f3c6beb23b 100644 --- a/drivers/common/mlx5/mlx5_common.h +++ b/drivers/common/mlx5/mlx5_common.h @@ -14,6 +14,7 @@ #include #include #include +#include #include "mlx5_prm.h" #include "mlx5_devx_cmds.h" diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index c03e4a0a4b..ea5d384283 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "i40e_logs.h" #include "base/i40e_prototype.h" diff --git a/examples/service_cores/main.c b/examples/service_cores/main.c index c7c792810d..0b3d8c8073 100644 --- a/examples/service_cores/main.c +++ b/examples/service_cores/main.c @@ -209,10 +209,10 @@ main(int argc, char **argv) apply_profile(i); printf("\n==> Profile: %s\n\n", profiles[i].name); - sleep(1); + rte_delay_us_sleep(1 * US_PER_S); rte_service_dump(stdout, UINT32_MAX); - sleep(5); + rte_delay_us_sleep(5 * US_PER_S); rte_service_dump(stdout, UINT32_MAX); i++; diff --git a/lib/librte_cmdline/cmdline.c b/lib/librte_cmdline/cmdline.c index 79ea5f98c8..49770869bb 100644 --- a/lib/librte_cmdline/cmdline.c +++ b/lib/librte_cmdline/cmdline.c @@ -18,10 +18,6 @@ #include "cmdline_private.h" -#ifdef RTE_EXEC_ENV_WINDOWS -#define write _write -#endif - static void cmdline_valid_buffer(struct rdline *rdl, const char *buf, __rte_unused unsigned int size) diff --git a/lib/librte_cmdline/cmdline_os_windows.c b/lib/librte_cmdline/cmdline_os_windows.c index e9585c9eea..73ed9ba290 100644 --- a/lib/librte_cmdline/cmdline_os_windows.c +++ b/lib/librte_cmdline/cmdline_os_windows.c @@ -4,8 +4,6 @@ #include -#include - #include "cmdline_private.h" /* Missing from some MinGW-w64 distributions. */ diff --git a/lib/librte_cmdline/cmdline_private.h b/lib/librte_cmdline/cmdline_private.h index a8a6ee9e69..a87c45275c 100644 --- a/lib/librte_cmdline/cmdline_private.h +++ b/lib/librte_cmdline/cmdline_private.h @@ -8,6 +8,7 @@ #include #include +#include #ifdef RTE_EXEC_ENV_WINDOWS #include #endif diff --git a/lib/librte_cmdline/cmdline_socket.c b/lib/librte_cmdline/cmdline_socket.c index 0fe1497008..998e8ade25 100644 --- a/lib/librte_cmdline/cmdline_socket.c +++ b/lib/librte_cmdline/cmdline_socket.c @@ -16,10 +16,6 @@ #include "cmdline_private.h" #include "cmdline_socket.h" -#ifdef RTE_EXEC_ENV_WINDOWS -#define open _open -#endif - struct cmdline * cmdline_file_new(cmdline_parse_ctx_t *ctx, const char *prompt, const char *path) { diff --git a/lib/librte_eal/common/eal_common_config.c b/lib/librte_eal/common/eal_common_config.c index 56d09dda7f..1c4c4dd585 100644 --- a/lib/librte_eal/common/eal_common_config.c +++ b/lib/librte_eal/common/eal_common_config.c @@ -3,7 +3,6 @@ */ #include -#include #include #include "eal_private.h" diff --git a/lib/librte_eal/common/eal_common_errno.c b/lib/librte_eal/common/eal_common_errno.c index 2a10fb823f..f86802705a 100644 --- a/lib/librte_eal/common/eal_common_errno.c +++ b/lib/librte_eal/common/eal_common_errno.c @@ -15,6 +15,10 @@ #include #include +#ifdef RTE_EXEC_ENV_WINDOWS +#define strerror_r(errnum, buf, buflen) strerror_s(buf, buflen, errnum) +#endif + RTE_DEFINE_PER_LCORE(int, _rte_errno); const char * diff --git a/lib/librte_eal/common/eal_common_log.c b/lib/librte_eal/common/eal_common_log.c index bed83a402a..cedf9f0894 100644 --- a/lib/librte_eal/common/eal_common_log.c +++ b/lib/librte_eal/common/eal_common_log.c @@ -13,6 +13,7 @@ #include #include +#include #include #include "eal_log.h" diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index 2951b1aca2..66f9114715 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -1959,7 +1959,7 @@ eal_check_common_options(struct internal_config *internal_cfg) RTE_LOG(ERR, EAL, "Invalid length of --" OPT_MBUF_POOL_OPS_NAME" option\n"); return -1; } - if (index(eal_get_hugefile_prefix(), '%') != NULL) { + if (strchr(eal_get_hugefile_prefix(), '%') != NULL) { RTE_LOG(ERR, EAL, "Invalid char, '%%', in --"OPT_FILE_PREFIX" " "option\n"); return -1; diff --git a/lib/librte_eal/common/eal_common_timer.c b/lib/librte_eal/common/eal_common_timer.c index 71e0bd035a..86f8429847 100644 --- a/lib/librte_eal/common/eal_common_timer.c +++ b/lib/librte_eal/common/eal_common_timer.c @@ -47,9 +47,9 @@ estimate_tsc_freq(void) #define CYC_PER_10MHZ 1E7 RTE_LOG(WARNING, EAL, "WARNING: TSC frequency estimated roughly" " - clock timings may be less accurate.\n"); - /* assume that the sleep(1) will sleep for 1 second */ + /* assume that the rte_delay_us_sleep() will sleep for 1 second */ uint64_t start = rte_rdtsc(); - sleep(1); + rte_delay_us_sleep(US_PER_S); /* Round up to 10Mhz. 1E7 ~ 10Mhz */ return RTE_ALIGN_MUL_NEAR(rte_rdtsc() - start, CYC_PER_10MHZ); } diff --git a/lib/librte_eal/common/eal_internal_cfg.h b/lib/librte_eal/common/eal_internal_cfg.h index 51dbe86e2b..d6c0470eb8 100644 --- a/lib/librte_eal/common/eal_internal_cfg.h +++ b/lib/librte_eal/common/eal_internal_cfg.h @@ -11,6 +11,7 @@ #define EAL_INTERNAL_CFG_H #include +#include #include #include "eal_thread.h" diff --git a/lib/librte_eal/freebsd/include/rte_os_shim.h b/lib/librte_eal/freebsd/include/rte_os_shim.h new file mode 100644 index 0000000000..1e85229ca9 --- /dev/null +++ b/lib/librte_eal/freebsd/include/rte_os_shim.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ + +#ifndef _RTE_OS_SHIM_ +#define _RTE_OS_SHIM_ + +#include + +/** + * @file + * @internal + * Provides semi-standard OS facilities by convenient names. + */ + +#endif /* _RTE_OS_SHIM_ */ diff --git a/lib/librte_eal/linux/include/rte_os_shim.h b/lib/librte_eal/linux/include/rte_os_shim.h new file mode 100644 index 0000000000..1e85229ca9 --- /dev/null +++ b/lib/librte_eal/linux/include/rte_os_shim.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ + +#ifndef _RTE_OS_SHIM_ +#define _RTE_OS_SHIM_ + +#include + +/** + * @file + * @internal + * Provides semi-standard OS facilities by convenient names. + */ + +#endif /* _RTE_OS_SHIM_ */ diff --git a/lib/librte_eal/windows/eal_hugepages.c b/lib/librte_eal/windows/eal_hugepages.c index 83a3d0ffc6..b007dceb39 100644 --- a/lib/librte_eal/windows/eal_hugepages.c +++ b/lib/librte_eal/windows/eal_hugepages.c @@ -6,7 +6,6 @@ #include #include #include -#include #include "eal_private.h" #include "eal_filesystem.h" diff --git a/lib/librte_eal/windows/eal_lcore.c b/lib/librte_eal/windows/eal_lcore.c index a85149be95..476c2d2bdf 100644 --- a/lib/librte_eal/windows/eal_lcore.c +++ b/lib/librte_eal/windows/eal_lcore.c @@ -9,7 +9,6 @@ #include #include #include -#include #include "eal_private.h" #include "eal_thread.h" diff --git a/lib/librte_eal/windows/eal_memalloc.c b/lib/librte_eal/windows/eal_memalloc.c index 85a9712cea..4459d59b1a 100644 --- a/lib/librte_eal/windows/eal_memalloc.c +++ b/lib/librte_eal/windows/eal_memalloc.c @@ -3,7 +3,6 @@ */ #include -#include #include "eal_internal_cfg.h" #include "eal_memalloc.h" diff --git a/lib/librte_eal/windows/include/rte_os.h b/lib/librte_eal/windows/include/rte_os.h index 1afe49f35e..66c711d458 100644 --- a/lib/librte_eal/windows/include/rte_os.h +++ b/lib/librte_eal/windows/include/rte_os.h @@ -18,72 +18,18 @@ extern "C" { #endif -/* limits.h replacement, value as in */ -#ifndef PATH_MAX -#define PATH_MAX _MAX_PATH -#endif - -#ifndef sleep -#define sleep(x) Sleep(1000 * (x)) -#endif - -#ifndef strerror_r -#define strerror_r(a, b, c) strerror_s(b, c, a) -#endif - -#ifndef strdup -/* strdup is deprecated in Microsoft libc and _strdup is preferred */ -#define strdup(str) _strdup(str) -#endif - -#ifndef strtok_r -#define strtok_r(str, delim, saveptr) strtok_s(str, delim, saveptr) -#endif - -#ifndef index -#define index(a, b) strchr(a, b) -#endif - -#ifndef rindex -#define rindex(a, b) strrchr(a, b) -#endif - -#ifndef strncasecmp -#define strncasecmp(s1, s2, count) _strnicmp(s1, s2, count) -#endif - -#ifndef close -#define close _close -#endif - -#ifndef unlink -#define unlink _unlink -#endif - /* cpu_set macros implementation */ #define RTE_CPU_AND(dst, src1, src2) CPU_AND(dst, src1, src2) #define RTE_CPU_OR(dst, src1, src2) CPU_OR(dst, src1, src2) #define RTE_CPU_FILL(set) CPU_FILL(set) #define RTE_CPU_NOT(dst, src) CPU_NOT(dst, src) -/* as in */ +/* This is an exception without "rte_" prefix, because Windows does have + * ssize_t, but it's defined in which we avoid to expose. + * If ssize_t is defined in user code, it necessarily has the same type. + */ typedef long long ssize_t; -#ifndef RTE_TOOLCHAIN_GCC -static inline const char * -eal_strerror(int code) -{ - static char buffer[128]; - - strerror_s(buffer, sizeof(buffer), code); - return buffer; -} - -#ifndef strerror -#define strerror eal_strerror -#endif -#endif /* RTE_TOOLCHAIN_GCC */ - #ifdef __cplusplus } #endif diff --git a/lib/librte_eal/windows/include/rte_os_shim.h b/lib/librte_eal/windows/include/rte_os_shim.h new file mode 100644 index 0000000000..edd9a1082c --- /dev/null +++ b/lib/librte_eal/windows/include/rte_os_shim.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ + +#ifndef _RTE_OS_SHIM_ +#define _RTE_OS_SHIM_ + +#include + +/** + * @file + * @internal + * Provides semi-standard OS facilities by convenient names. + */ + +#ifndef PATH_MAX +#define PATH_MAX _MAX_PATH +#endif + +#define strdup(str) _strdup(str) +#define strtok_r(str, delim, saveptr) strtok_s(str, delim, saveptr) +#define strncasecmp(s1, s2, count) _strnicmp(s1, s2, count) + +#define open(path, flags, ...) _open(path, flags, ##__VA_ARGS__) +#define read(fd, buf, n) _read(fd, buf, n) +#define write(fd, buf, n) _write(fd, buf, n) +#define close(fd) _close(fd) +#define unlink(path) _unlink(path) + +#endif /* _RTE_OS_SHIM_ */ diff --git a/lib/librte_ethdev/ethdev_private.h b/lib/librte_ethdev/ethdev_private.h index 220ddd4408..9bb0879538 100644 --- a/lib/librte_ethdev/ethdev_private.h +++ b/lib/librte_ethdev/ethdev_private.h @@ -5,6 +5,8 @@ #ifndef _ETH_PRIVATE_H_ #define _ETH_PRIVATE_H_ +#include + #include "rte_ethdev.h" #ifdef __cplusplus diff --git a/lib/librte_kvargs/rte_kvargs.c b/lib/librte_kvargs/rte_kvargs.c index 4cce8e953b..38e9d5c1ca 100644 --- a/lib/librte_kvargs/rte_kvargs.c +++ b/lib/librte_kvargs/rte_kvargs.c @@ -7,6 +7,7 @@ #include #include +#include #include #include "rte_kvargs.h" From patchwork Wed Apr 14 22:06:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 91478 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 EA243A0A02; Thu, 15 Apr 2021 00:07:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 915CA161D7D; Thu, 15 Apr 2021 00:07:08 +0200 (CEST) Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) by mails.dpdk.org (Postfix) with ESMTP id F28E9161D6D for ; Thu, 15 Apr 2021 00:07:03 +0200 (CEST) Received: by mail-lj1-f172.google.com with SMTP id o16so24922464ljp.3 for ; Wed, 14 Apr 2021 15:07:03 -0700 (PDT) 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=RVMkF7yTN6CjFo8o+yAjaTX5ihWMsqzlSo3HRJD7omk=; b=Ss0sG/KD74B+jbDFJjeYohrmGmvBcb9Pj9ztRiU7YX4+ib7Ubbfdr2rMiL3doAHzNF 3U9QcXk13Srrc5XdtVQ/Xi/jM0/TJ+gtr+p7WNRGchfG0s9k64a/OqtiuW9xPrwG6LJf HNEjiUCeb+qNGUhltSjo8nXBGcEO3VHVE/m8aU5NXvpJGJqlzslXFZI1UOrEaTJvjWnF Uif6oQKRiA5Z3L4oTv6UpMX5bHIBToghZmhyhpRwCPoPs3VtleOyqoadTyJM/DqScqop vX1sT/mx+NdjceFfuHseG9b3PguM9clxKVBetw79WA50ySbzxJKKGBHXVnTTiYKGEXMe k/Ng== 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=RVMkF7yTN6CjFo8o+yAjaTX5ihWMsqzlSo3HRJD7omk=; b=iUFK2Ch9BZjsacStTGWypzalxYUPflfuikS7rP7lVg84yn1cLYJwBXd2TIUXx6kvzF 8+3l/LwHyyw8SrJIsuPxXyhx3lEwrZUimWZ0TGVhM5rbhDsitXp4CdvIZqJqoWVEFJ7c Wr0mLFtlYaKWlSKe3/+zqV9xGzCjyNpSF6GubpZQIGKX+D70lcMe/dPg2uIiHl4V/7ol 3mS2us4VQONk8oIqSX+Jz5GiAsP4PEf1w5SRjuwgl7EnjgG2A/sye5ztgO/7612shKHe qOT5ASdyDxRHMp1/vG9cSIjMyiNJoafXhPhZ6UDZ0BZqEnz+GwQ79yrLr8Ig0dKwQLS5 YIcQ== X-Gm-Message-State: AOAM531O7rDzD7JP4BnengW0FZhXJV9iicZFiryqQdWincfyIZ6OnTum Ub5rtUJHzyF3aLsLxt9DZrvwShdLgpncEOjj X-Google-Smtp-Source: ABdhPJxshy+ij3GhtO4zhPkxh+h1y5a0w1CsGqq1SSZF9qGL75ZEn9szNETp6kaYeKmaAhH0NrMp2w== X-Received: by 2002:a2e:8084:: with SMTP id i4mr85079ljg.122.1618438023277; Wed, 14 Apr 2021 15:07:03 -0700 (PDT) Received: from localhost.localdomain (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id m28sm271489lfo.278.2021.04.14.15.07.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Apr 2021 15:07:02 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Kozlyuk , Ranjit Menon , Olivier Matz Date: Thu, 15 Apr 2021 01:06:50 +0300 Message-Id: <20210414220651.28691-4-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.29.3 In-Reply-To: <20210414220651.28691-1-dmitry.kozliuk@gmail.com> References: <20210410224732.20234-1-dmitry.kozliuk@gmail.com> <20210414220651.28691-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v10 3/4] net: work around s_addr macro on Windows 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" Windows Sockets headers contain `#define s_addr S_un.S_addr`, which conflicts with definition of `s_addr` field of `struct rte_ether_hdr`. Prieviously `s_addr` was undefined in , which had been breaking access to `s_addr` field of `struct in_addr`, so some DPDK and Windows headers could not be included in one file. Renaming of `struct rte_ether_hdr` is planned: https://mails.dpdk.org/archives/dev/2021-March/201444.html Temporarily disable `s_addr` macro around `struct rte_ether_hdr` definition to avoid conflict. Place source MAC address in both `s_addr` and `S_un.S_addr` fields, so that access works either directly or through the macro as defined in Windows headers. Signed-off-by: Dmitry Kozlyuk Acked-by: Ranjit Menon --- lib/librte_net/rte_ether.h | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/lib/librte_net/rte_ether.h b/lib/librte_net/rte_ether.h index 060b63fc9b..a303c24a8c 100644 --- a/lib/librte_net/rte_ether.h +++ b/lib/librte_net/rte_ether.h @@ -23,10 +23,6 @@ extern "C" { #include #include -#ifdef RTE_EXEC_ENV_WINDOWS /* Workaround conflict with rte_ether_hdr. */ -#undef s_addr /* Defined in winsock2.h included in windows.h. */ -#endif - #define RTE_ETHER_ADDR_LEN 6 /**< Length of Ethernet address. */ #define RTE_ETHER_TYPE_LEN 2 /**< Length of Ethernet type field. */ #define RTE_ETHER_CRC_LEN 4 /**< Length of Ethernet CRC. */ @@ -257,16 +253,34 @@ __rte_experimental int rte_ether_unformat_addr(const char *str, struct rte_ether_addr *eth_addr); +/* Windows Sockets headers contain `#define s_addr S_un.S_addr`. + * Temporarily disable this macro to avoid conflict at definition. + * Place source MAC address in both `s_addr` and `S_un.S_addr` fields, + * so that access works either directly or through the macro. + */ +#pragma push_macro("s_addr") +#ifdef s_addr +#undef s_addr +#endif + /** * Ethernet header: Contains the destination address, source address * and frame type. */ struct rte_ether_hdr { struct rte_ether_addr d_addr; /**< Destination address. */ - struct rte_ether_addr s_addr; /**< Source address. */ - uint16_t ether_type; /**< Frame type. */ + RTE_STD_C11 + union { + struct rte_ether_addr s_addr; /**< Source address. */ + struct { + struct rte_ether_addr S_addr; + } S_un; /**< Do not use directly; use s_addr instead.*/ + }; + uint16_t ether_type; /**< Frame type. */ } __rte_aligned(2); +#pragma pop_macro("s_addr") + /** * Ethernet VLAN Header. * Contains the 16-bit VLAN Tag Control Identifier and the Ethernet type From patchwork Wed Apr 14 22:06:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Kozlyuk X-Patchwork-Id: 91479 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 24DD7A0A02; Thu, 15 Apr 2021 00:07:29 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 339CD161D82; Thu, 15 Apr 2021 00:07:13 +0200 (CEST) Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) by mails.dpdk.org (Postfix) with ESMTP id 5052E161D6F for ; Thu, 15 Apr 2021 00:07:05 +0200 (CEST) Received: by mail-lf1-f50.google.com with SMTP id z13so18722953lfd.9 for ; Wed, 14 Apr 2021 15:07:05 -0700 (PDT) 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=hj3m8hhGktWOd++3lidkzkqhtP7pXFjVuOXolzudUC0=; b=RapDW5di7YTq1Ie3RLdtCxlTxssVtU1PBmSDiXMGD8SjlWp0yWGUGfrEGyRpszPtqy hhWIeFLKfI76cpcK1qOOYtjPajiOc3I+hnzZHHCXAjRNpElQEpDIT/U/O91EWoG25vD9 4oI2Tw+GHnYYYNqEKQtf2eRuf1uLEzPSVaZpkT3dLsZu/uPs5J06AbY4zZlGnSPYBxVe 3nvtNPIGxThs9CMWG1ib9x13VDCLPCn0jEYCiG3C01552duC+ax0akFqqy74v5aSYpJ/ 6rEqPAIFXDd+96OzRIX1+YKw/NvsCxHPxHNNCPl0iA58A/5XuHk9MCTpq2yN6KnM9hz0 3OGQ== 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=hj3m8hhGktWOd++3lidkzkqhtP7pXFjVuOXolzudUC0=; b=Av77MxZJWmMVJQYFmv1gFjsQkEvCpqSrs3tQjd/mp5/rd3YCPXXWttRlx3MatfsU0s rl2GpObpa22ahTWYCRYBIjcTSF5h4xggz1r8jHFpRIDgPEtvVGoYforhLPrp7OWp8Zou uxY4LP+5WHqGYPQ0MHn90nzG/O+4SQi5VjX3dIY6U4aThGsAn9nfhg9k8Kvcf6l/qiEd t4XY1jS5fopOA8CcKWwi5JeK/Lfw+VcDahVxtJRx255YKYxfhkbuYTsCwHXDlda6L5gn zPUXXIJrW0nN+e54Zc04NW3p99DRc0OlV2O2qV8OS/J001+dObHsXdSfAFb9U3vP7dDG Wa9w== X-Gm-Message-State: AOAM532PIDXQkUZCc7brC00ErMvAx09jPi/ca5avvar+21cw/CmakE2Q 7Jpq3DuY0Pjc2CWXxy12MuYlMYOnNyjvokZM X-Google-Smtp-Source: ABdhPJxHADyrmOTHTgLmQB9S4kFmDVTRprX/LajI11GS6Drm2nHj9n3cMLzYKqmSeNClLIHFqxwk1w== X-Received: by 2002:a05:6512:38c9:: with SMTP id p9mr217732lft.572.1618438024567; Wed, 14 Apr 2021 15:07:04 -0700 (PDT) Received: from localhost.localdomain (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id m28sm271489lfo.278.2021.04.14.15.07.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Apr 2021 15:07:04 -0700 (PDT) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Dmitry Kozlyuk , Beilei Xing , Jeff Guo , Matan Azrad , Shahaf Shuler , Viacheslav Ovsiienko , Olivier Matz , Ori Kam , Bruce Richardson , Narcisa Ana Maria Vasile , Dmitry Malloy , Pallavi Kadam , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Date: Thu, 15 Apr 2021 01:06:51 +0300 Message-Id: <20210414220651.28691-5-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.29.3 In-Reply-To: <20210414220651.28691-1-dmitry.kozliuk@gmail.com> References: <20210410224732.20234-1-dmitry.kozliuk@gmail.com> <20210414220651.28691-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v10 4/4] net: provide IP-related API on any OS 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" Users of relied on it to provide IP-related defines, like IPPROTO_* constants, but still had to include POSIX headers for inet_pton() and other standard IP-related facilities. Extend so that it is a single header to gain access to IP-related facilities on any OS. Use it to replace POSIX includes in components enabled on Windows. Move missing constants from Windows networking shim to OS shim header and include it where needed. Remove Windows networking shim that is no longer needed. Signed-off-by: Dmitry Kozlyuk --- drivers/net/i40e/i40e_fdir.c | 1 + drivers/net/mlx5/mlx5.h | 1 - drivers/net/mlx5/mlx5_flow.c | 4 +-- drivers/net/mlx5/mlx5_flow.h | 3 +- drivers/net/mlx5/mlx5_mac.c | 1 - examples/cmdline/commands.c | 5 --- examples/cmdline/parse_obj_list.c | 2 -- examples/flow_filtering/main.c | 1 - examples/l2fwd/main.c | 1 - examples/link_status_interrupt/main.c | 1 - lib/librte_cmdline/cmdline.c | 1 - lib/librte_cmdline/cmdline_parse.c | 2 -- lib/librte_cmdline/cmdline_parse_etheraddr.c | 6 ---- lib/librte_cmdline/cmdline_parse_ipaddr.c | 6 ---- lib/librte_cmdline/cmdline_parse_ipaddr.h | 2 +- lib/librte_eal/windows/include/arpa/inet.h | 30 ---------------- lib/librte_eal/windows/include/netinet/in.h | 38 -------------------- lib/librte_eal/windows/include/netinet/ip.h | 10 ------ lib/librte_eal/windows/include/rte_os_shim.h | 8 +++++ lib/librte_eal/windows/include/sys/socket.h | 24 ------------- lib/librte_ethdev/rte_ethdev.c | 12 +++---- lib/librte_ethdev/rte_ethdev_core.h | 1 - lib/librte_net/rte_ip.h | 7 ++++ lib/librte_net/rte_net.c | 1 + 24 files changed, 24 insertions(+), 144 deletions(-) delete mode 100644 lib/librte_eal/windows/include/arpa/inet.h delete mode 100644 lib/librte_eal/windows/include/netinet/in.h delete mode 100644 lib/librte_eal/windows/include/netinet/ip.h delete mode 100644 lib/librte_eal/windows/include/sys/socket.h diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c index da089baa4d..22e6e34640 100644 --- a/drivers/net/i40e/i40e_fdir.c +++ b/drivers/net/i40e/i40e_fdir.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "i40e_logs.h" #include "base/i40e_type.h" diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index 0f69f9d125..bac8bc0377 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -10,7 +10,6 @@ #include #include #include -#include #include #include diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index c347f8130e..0f1a9c5ed9 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -3,12 +3,11 @@ * Copyright 2016 Mellanox Technologies, Ltd */ -#include -#include #include #include #include #include +#include #include #include @@ -8241,4 +8240,3 @@ mlx5_release_tunnel_hub(__rte_unused struct mlx5_dev_ctx_shared *sh, { } #endif /* HAVE_IBV_FLOW_DV_SUPPORT */ - diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index ec673c29ab..1ee5a9eb15 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -5,11 +5,10 @@ #ifndef RTE_PMD_MLX5_FLOW_H_ #define RTE_PMD_MLX5_FLOW_H_ -#include -#include #include #include #include +#include #include #include diff --git a/drivers/net/mlx5/mlx5_mac.c b/drivers/net/mlx5/mlx5_mac.c index a7946f7756..19981d26d8 100644 --- a/drivers/net/mlx5/mlx5_mac.c +++ b/drivers/net/mlx5/mlx5_mac.c @@ -8,7 +8,6 @@ #include #include #include -#include #include #include diff --git a/examples/cmdline/commands.c b/examples/cmdline/commands.c index f43eacfbad..9ce8ef389f 100644 --- a/examples/cmdline/commands.c +++ b/examples/cmdline/commands.c @@ -8,12 +8,7 @@ #include #include #include -#include #include -#include -#ifdef RTE_EXEC_ENV_FREEBSD -#include -#endif #include #include diff --git a/examples/cmdline/parse_obj_list.c b/examples/cmdline/parse_obj_list.c index b04adbea58..959bcd1452 100644 --- a/examples/cmdline/parse_obj_list.c +++ b/examples/cmdline/parse_obj_list.c @@ -6,11 +6,9 @@ #include #include -#include #include #include #include -#include #include #include diff --git a/examples/flow_filtering/main.c b/examples/flow_filtering/main.c index 93523d625b..bc28468f17 100644 --- a/examples/flow_filtering/main.c +++ b/examples/flow_filtering/main.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c index 3377b08322..be5bf7bc90 100644 --- a/examples/l2fwd/main.c +++ b/examples/l2fwd/main.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include diff --git a/examples/link_status_interrupt/main.c b/examples/link_status_interrupt/main.c index f1653b4fb8..8ca3586e05 100644 --- a/examples/link_status_interrupt/main.c +++ b/examples/link_status_interrupt/main.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/librte_cmdline/cmdline.c b/lib/librte_cmdline/cmdline.c index 49770869bb..a176d15130 100644 --- a/lib/librte_cmdline/cmdline.c +++ b/lib/librte_cmdline/cmdline.c @@ -12,7 +12,6 @@ #include #include #include -#include #include diff --git a/lib/librte_cmdline/cmdline_parse.c b/lib/librte_cmdline/cmdline_parse.c index fe366841cd..f5cc934782 100644 --- a/lib/librte_cmdline/cmdline_parse.c +++ b/lib/librte_cmdline/cmdline_parse.c @@ -11,8 +11,6 @@ #include #include -#include - #include #include "cmdline_private.h" diff --git a/lib/librte_cmdline/cmdline_parse_etheraddr.c b/lib/librte_cmdline/cmdline_parse_etheraddr.c index 5cb10de321..433b828a72 100644 --- a/lib/librte_cmdline/cmdline_parse_etheraddr.c +++ b/lib/librte_cmdline/cmdline_parse_etheraddr.c @@ -5,13 +5,7 @@ */ #include -#include -#include -#include -#include -#include #include -#include #include #include diff --git a/lib/librte_cmdline/cmdline_parse_ipaddr.c b/lib/librte_cmdline/cmdline_parse_ipaddr.c index f8dbdf204c..5e278c963f 100644 --- a/lib/librte_cmdline/cmdline_parse_ipaddr.c +++ b/lib/librte_cmdline/cmdline_parse_ipaddr.c @@ -6,14 +6,8 @@ #include #include -#include -#include -#include #include #include -#include -#include -#include #include diff --git a/lib/librte_cmdline/cmdline_parse_ipaddr.h b/lib/librte_cmdline/cmdline_parse_ipaddr.h index 0ba81647bc..0118c31d44 100644 --- a/lib/librte_cmdline/cmdline_parse_ipaddr.h +++ b/lib/librte_cmdline/cmdline_parse_ipaddr.h @@ -8,7 +8,7 @@ #define _PARSE_IPADDR_H_ #include -#include +#include #ifdef __cplusplus extern "C" { diff --git a/lib/librte_eal/windows/include/arpa/inet.h b/lib/librte_eal/windows/include/arpa/inet.h deleted file mode 100644 index 96b6984383..0000000000 --- a/lib/librte_eal/windows/include/arpa/inet.h +++ /dev/null @@ -1,30 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright (c) 2020 Dmitry Kozlyuk - */ - -#ifndef _ARPA_INET_H_ -#define _ARPA_INET_H_ - -/** - * @file - * - * Compatibility header - * - * Although symbols declared here are present on Windows, - * including would expose too much macros breaking common code. - */ - -#include -#include - -/* defined in ws2_32.dll */ -__attribute__((stdcall)) -int -inet_pton(int af, const char *src, void *dst); - -/* defined in ws2_32.dll */ -__attribute__((stdcall)) -const char * -inet_ntop(int af, const void *src, char *dst, socklen_t size); - -#endif /* _ARPA_INET_H_ */ diff --git a/lib/librte_eal/windows/include/netinet/in.h b/lib/librte_eal/windows/include/netinet/in.h deleted file mode 100644 index 6455b9ba51..0000000000 --- a/lib/librte_eal/windows/include/netinet/in.h +++ /dev/null @@ -1,38 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright 2020 Mellanox Technologies, Ltd - */ - -#ifndef _IN_H_ -#define _IN_H_ - -#include -#include - -#define IPPROTO_IP 0 -#define IPPROTO_HOPOPTS 0 -#define IPPROTO_ICMP 1 -#define IPPROTO_IPIP 4 -#define IPPROTO_TCP 6 -#define IPPROTO_UDP 17 -#define IPPROTO_IPV6 41 -#define IPPROTO_ROUTING 43 -#define IPPROTO_FRAGMENT 44 -#define IPPROTO_GRE 47 -#define IPPROTO_ESP 50 -#define IPPROTO_AH 51 -#define IPPROTO_ICMPV6 58 -#define IPPROTO_NONE 59 -#define IPPROTO_DSTOPTS 60 -#define IPPROTO_SCTP 132 - -#define INET6_ADDRSTRLEN 46 - -struct in_addr { - uint32_t s_addr; -}; - -struct in6_addr { - uint8_t s6_addr[16]; -}; - -#endif diff --git a/lib/librte_eal/windows/include/netinet/ip.h b/lib/librte_eal/windows/include/netinet/ip.h deleted file mode 100644 index 2126498797..0000000000 --- a/lib/librte_eal/windows/include/netinet/ip.h +++ /dev/null @@ -1,10 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright 2020 Mellanox Technologies, Ltd - */ - -#ifndef _IP_H_ -#define _IP_H_ - -#define IPVERSION 4 - -#endif diff --git a/lib/librte_eal/windows/include/rte_os_shim.h b/lib/librte_eal/windows/include/rte_os_shim.h index edd9a1082c..f40fb62d1d 100644 --- a/lib/librte_eal/windows/include/rte_os_shim.h +++ b/lib/librte_eal/windows/include/rte_os_shim.h @@ -25,4 +25,12 @@ #define close(fd) _close(fd) #define unlink(path) _unlink(path) +#define IPVERSION 4 + +#define IPPROTO_IPIP 4 +#define IPPROTO_GRE 47 +#ifdef RTE_TOOLCHAIN_GCC +#define IPPROTO_SCTP 132 +#endif + #endif /* _RTE_OS_SHIM_ */ diff --git a/lib/librte_eal/windows/include/sys/socket.h b/lib/librte_eal/windows/include/sys/socket.h deleted file mode 100644 index 9536cf8e62..0000000000 --- a/lib/librte_eal/windows/include/sys/socket.h +++ /dev/null @@ -1,24 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright (c) 2020 Dmitry Kozlyuk - */ - -#ifndef _SYS_SOCKET_H_ -#define _SYS_SOCKET_H_ - -/** - * @file - * - * Compatibility header - * - * Although symbols declared here are present on Windows, - * including would expose too much macros breaking common code. - */ - -#include - -#define AF_INET 2 -#define AF_INET6 23 - -typedef size_t socklen_t; - -#endif /* _SYS_SOCKET_H_ */ diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 0419500fc3..c73d263c2f 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -2,18 +2,14 @@ * Copyright(c) 2010-2017 Intel Corporation */ -#include -#include #include -#include -#include -#include -#include #include +#include #include #include -#include -#include +#include +#include +#include #include #include diff --git a/lib/librte_ethdev/rte_ethdev_core.h b/lib/librte_ethdev/rte_ethdev_core.h index 918a34ed1f..4679d948fa 100644 --- a/lib/librte_ethdev/rte_ethdev_core.h +++ b/lib/librte_ethdev/rte_ethdev_core.h @@ -6,7 +6,6 @@ #define _RTE_ETHDEV_CORE_H_ #include -#include /** * @file diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h index b59c4d67a3..8c189009b0 100644 --- a/lib/librte_net/rte_ip.h +++ b/lib/librte_net/rte_ip.h @@ -16,9 +16,16 @@ */ #include + +#ifdef RTE_EXEC_ENV_WINDOWS +#include +#else +#include #include +#include #include #include +#endif #include #include diff --git a/lib/librte_net/rte_net.c b/lib/librte_net/rte_net.c index bfe5003976..d680accc16 100644 --- a/lib/librte_net/rte_net.c +++ b/lib/librte_net/rte_net.c @@ -15,6 +15,7 @@ #include #include #include +#include /* get l3 packet type from ip6 next protocol */ static uint32_t